better-auth-studio 1.1.2-beta.19 → 1.1.2-beta.20
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.
|
@@ -940,7 +940,7 @@ export const auth = betterAuth({
|
|
|
940
940
|
},
|
|
941
941
|
}),
|
|
942
942
|
],
|
|
943
|
-
});`}[oe]||""},ue=oe=>{navigator.clipboard.writeText(oe),Y.success("Copied to clipboard")},ve=Object.values(Ca).filter(oe=>c==="all"||oe.category===c);return a.jsxs("div",{className:"h-full flex flex-col bg-black",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:"Emails"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Customize your email templates with a visual editor"})]})}),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"})]}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{className:"w-[340px] border-r border-dashed border-white/15 flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"p-4 border-b border-dashed border-white/15 flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-light text-white uppercase tracking-wider mb-4",children:"Templates"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:["all","authentication","organization","notification"].map(oe=>a.jsx("button",{onClick:()=>u(oe),className:`px-2 py-1 text-[10px] font-mono uppercase border border-dashed rounded-none transition-colors ${c===oe?"border-white/30 bg-white/5 text-white":"border-white/10 bg-black/40 text-gray-300 hover:border-white/20"}`,children:oe},oe))})]}),a.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-2",style:{overscrollBehavior:"contain"},children:ve.map(oe=>a.jsxs("button",{onClick:()=>F(oe.id),className:`w-full text-left p-3 border border-dashed rounded-none transition-colors ${e===oe.id?"border-white/30 bg-white/5 text-white":"border-white/15 bg-black/40 text-gray-300 hover:border-white/20 hover:bg-white/5"}`,children:[a.jsx("div",{className:"text-sm uppercase font-mono",children:oe.name}),a.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[oe.fields.length," fields"]})]},oe.id))})]}),a.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"border-b border-dashed border-white/15 p-4 flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-light text-white uppercase tracking-wider",children:(Ne=Ca[e])==null?void 0:Ne.name}),a.jsx("p",{className:"text-xs text-gray-400 font-mono mt-1",children:(Ee=Ca[e])==null?void 0:Ee.category})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs(q,{variant:"outline",onClick:()=>j(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(N3,{className:"w-4 h-4 mr-2"}),"Test Email"]}),a.jsxs(q,{variant:"outline",onClick:()=>{ee(e)&&l(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(wi,{className:"w-4 h-4 mr-2"}),"Export Code"]}),a.jsxs(q,{variant:"outline",onClick:()=>ue(n),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(Dc,{className:"w-4 h-4 mr-2"}),"Copy HTML"]})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsx("div",{className:"p-4 border-b border-dashed border-white/10 bg-black/40",children:a.jsxs("div",{className:"flex items-end gap-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject"}),a.jsx(we,{value:s,onChange:oe=>Q(oe.target.value),placeholder:"Email subject",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-sm"})]}),a.jsxs(q,{variant:"outline",onClick:()=>m(!f),className:"h-10 border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[f?"Hide":"Show"," Fields"]})]})}),f&&e&&a.jsxs("div",{className:"p-4 border-b overflow-hidden border-dashed border-white/10 bg-black/30",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Fields"}),a.jsx("div",{className:"grid grid-cols-2 gap-3 max-h-full overflow-y-hidden",children:(be=Ca[e])==null?void 0:be.fields.map(oe=>a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs font-mono text-gray-400 mb-1 block",children:oe}),a.jsx(we,{value:h[oe]||"",onChange:Me=>d(_e=>({..._e,[oe]:Me.target.value})),placeholder:`{{${oe}}}`,className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"})]},oe))}),a.jsx("div",{className:"mt-4 flex justify-end",children:a.jsx(q,{variant:"outline",onClick:ie,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Apply Changes"})})]}),e&&a.jsxs("div",{className:"p-4 border-b border-dashed border-white/10 bg-black/40",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Dynamic Fields"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:(Ae=Ca[e])==null?void 0:Ae.fields.map(oe=>a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>ue(`{{${oe}}}`),className:"text-xs rounded-none border border-dashed border-white/20 hover:bg-white/10",children:oe}),a.jsx("span",{className:"text-xs text-gray-500 font-mono",children:`{{${oe}}}`})]},oe))})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(zfe,{html:he,onChange:$})})]})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center min-h-0",children:a.jsxs("div",{className:"text-center",children:[a.jsx(_u,{className:"w-16 h-16 text-white/20 mx-auto mb-4"}),a.jsx("p",{className:"text-gray-400 font-mono uppercase text-sm",children:"Select a template to start editing"})]})})})]}),o&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&l(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-5xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-0 pt-2 border-white/15 border-b-0 bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between p-2 pt-2",children:a.jsxs("div",{className:"pb-2",children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Export"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Export the code for the selected template"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>l(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex flex-col items-center justify-center",children:[a.jsx("hr",{className:"w-full border-white/15 h-px"}),a.jsx("div",{className:"relative z-20 h-8 w-[calc(100%)] mx-auto -translate-x-1/2 left-1/2 bg-[repeating-linear-gradient(-45deg,#e0f2fe,#e0f2fe_1px,transparent_1px,transparent_6px)] opacity-[8%]"}),a.jsx("hr",{className:"w-full border-white/15 h-px"})]}),a.jsx("div",{className:"flex-1 overflow-auto p-6 bg-black",children:a.jsx(CE,{code:ee(e),language:"typescript",fileName:"auth.ts"})}),a.jsx("div",{className:"flex items-center justify-end p-6 border-t border-white/15 bg-black/50",children:a.jsx(q,{onClick:J,disabled:w,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2",children:w?"Applying...":"Apply to auth config"})})]})}),b&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&g(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-white/15 border-b bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Setup Required"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Install Resend before applying email template"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-8 bg-black",children:a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-md font-mono uppercase font-normal text-white mb-3",children:"Install Resend"}),a.jsx("p",{className:"text-gray-300 mb-4 font-sans leading-relaxed",children:"You need to install the Resend package to send emails. Run the following command in your terminal:"}),a.jsx("div",{className:"bg-black/80 border border-dashed border-white/20 p-2 pl-3 rounded-none font-mono text-sm relative group",children:a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("code",{className:"text-gray-200",children:[a.jsx("span",{className:"text-white",children:"$"})," ",a.jsx("span",{className:"text-blue-600",children:"pnpm"})," ",a.jsx("span",{className:"text-white",children:"install"})," ",a.jsx("span",{className:"text-white",children:"resend"})]}),a.jsx("button",{onClick:()=>{navigator.clipboard.writeText("pnpm install resend"),S(!0),setTimeout(()=>S(!1),2e3)},className:"flex items-center gap-2 px-2 py-1.5 rounded-none transition-colors text-gray-300 hover:text-white",title:"Copy command",children:N?a.jsx(a.Fragment,{children:a.jsx(qs,{className:"w-4 h-4"})}):a.jsx(a.Fragment,{children:a.jsx(Dc,{className:"w-4 h-4"})})})]})})]})})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/15 bg-black/50",children:[a.jsx(q,{variant:"ghost",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none font-mono uppercase text-xs px-6 py-2",children:"Cancel"}),a.jsx(q,{onClick:()=>X(e),disabled:w,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2",children:w?"Applying...":"Continue"})]})]})}),E&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&j(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-white/15 border-b bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Test Email"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Send a test email with dynamic values"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-8 bg-black",children:a.jsxs("div",{className:"space-y-6",children:[I==="checking"&&a.jsx("div",{className:"bg-black/90 flex border p-4 rounded-none border-dashed border-white/20",children:a.jsxs("p",{className:"text-white text-sm font-sans flex items-center gap-2 leading-relaxed",children:[a.jsx(ya,{className:"w-4 h-4 animate-spin mr-1"})," Checking for RESEND_API_KEY..."]})}),I==="missing"&&a.jsxs("div",{className:"bg-red-900/20 border border-red-500/30 border-dashed p-4 rounded-none",children:[a.jsx("p",{className:"text-red-200 text-sm font-sans leading-relaxed mb-2",children:a.jsx("strong",{className:"font-normal uppercase font-mono",children:"RESEND_API_KEY not found"})}),a.jsxs("p",{className:"text-red-200 text-sm font-sans leading-relaxed",children:["Please add"," ",a.jsx("code",{className:"bg-black/50 px-1 py-0.5 rounded font-mono text-xs",children:"RESEND_API_KEY"})," ","to your"," ",a.jsx("code",{className:"bg-black/50 px-1 py-0.5 rounded font-mono text-xs",children:".env"})," ","file."]})]}),I==="found"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"From Email (Verified Sender) *"}),k.length>0?a.jsx("select",{value:R,onChange:oe=>D(oe.target.value),className:"w-full bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs p-2 focus:outline-none focus:border-white/40",children:k.map(oe=>a.jsx("option",{value:oe,children:oe},oe))}):a.jsx(we,{type:"email",value:R,onChange:oe=>D(oe.target.value),placeholder:"noreply@yourdomain.com",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:k.length>0?"Select a verified sender email from your Resend account":"Enter a verified sender email address from your Resend account"})]}),a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject *"}),a.jsx(we,{type:"text",value:H,onChange:oe=>T(oe.target.value),placeholder:"Email subject",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:"Email subject line (supports dynamic placeholders)"})]}),a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"To Email Address *"}),a.jsx(we,{type:"email",value:_,onChange:oe=>L(oe.target.value),placeholder:"recipient@example.com",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:"Any email address to receive the test email"})]}),((Pe=Ca[e])==null?void 0:Pe.fields)&&Ca[e].fields.length>0&&a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Dynamic Values"}),a.jsx("div",{className:"space-y-3",children:Ca[e].fields.map(oe=>a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-500 mb-1 block",children:oe}),a.jsx(we,{value:P[oe]||"",onChange:Me=>U({...P,[oe]:Me.target.value}),placeholder:`Enter ${oe}`,className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"})]},oe))})]})]})]})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/15 bg-black/50",children:[a.jsx(q,{variant:"ghost",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none font-mono uppercase text-xs px-6 py-2",children:"Cancel"}),a.jsx(q,{onClick:B,disabled:O||I!=="found"||!_||!R||!H,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:O?"Sending...":"Send Test Email"})]})]})})]})}function _6(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Pm="Checkbox",[$fe]=ii(Pm),[Hfe,kE]=$fe(Pm);function qfe(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:i,form:o,name:l,onCheckedChange:c,required:u,value:h="on",internal_do_not_use_render:d}=e,[f,m]=Kc({prop:n,defaultProp:s??!1,onChange:c,caller:Pm}),[y,v]=p.useState(null),[w,x]=p.useState(null),b=p.useRef(!1),g=y?!!o||!!y.closest("form"):!0,N={checked:f,disabled:i,setChecked:m,control:y,setControl:v,name:l,form:o,value:h,hasConsumerStoppedPropagationRef:b,required:u,defaultChecked:Ji(s)?!1:s,isFormControl:g,bubbleInput:w,setBubbleInput:x};return a.jsx(Hfe,{scope:t,...N,children:Gfe(d)?d(N):r})}var R6="CheckboxTrigger",O6=p.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:i,value:o,disabled:l,checked:c,required:u,setControl:h,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:m,bubbleInput:y}=kE(R6,e),v=Mn(s,h),w=p.useRef(c);return p.useEffect(()=>{const x=i==null?void 0:i.form;if(x){const b=()=>d(w.current);return x.addEventListener("reset",b),()=>x.removeEventListener("reset",b)}},[i,d]),a.jsx(mn.button,{type:"button",role:"checkbox","aria-checked":Ji(c)?"mixed":c,"aria-required":u,"data-state":U6(c),"data-disabled":l?"":void 0,disabled:l,value:o,...r,ref:v,onKeyDown:Gt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Gt(n,x=>{d(b=>Ji(b)?!0:!b),y&&m&&(f.current=x.isPropagationStopped(),f.current||x.stopPropagation())})})});O6.displayName=R6;var AE=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:i,required:o,disabled:l,value:c,onCheckedChange:u,form:h,...d}=e;return a.jsx(qfe,{__scopeCheckbox:n,checked:s,defaultChecked:i,disabled:l,required:o,onCheckedChange:u,name:r,form:h,value:c,internal_do_not_use_render:({isFormControl:f})=>a.jsxs(a.Fragment,{children:[a.jsx(O6,{...d,ref:t,__scopeCheckbox:n}),f&&a.jsx(L6,{__scopeCheckbox:n})]})})});AE.displayName=Pm;var D6="CheckboxIndicator",I6=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,i=kE(D6,n);return a.jsx(oi,{present:r||Ji(i.checked)||i.checked===!0,children:a.jsx(mn.span,{"data-state":U6(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});I6.displayName=D6;var M6="CheckboxBubbleInput",L6=p.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:i,defaultChecked:o,required:l,disabled:c,name:u,value:h,form:d,bubbleInput:f,setBubbleInput:m}=kE(M6,e),y=Mn(n,m),v=_6(i),w=US(r);p.useEffect(()=>{const b=f;if(!b)return;const g=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(g,"checked").set,E=!s.current;if(v!==i&&S){const j=new Event("click",{bubbles:E});b.indeterminate=Ji(i),S.call(b,Ji(i)?!1:i),b.dispatchEvent(j)}},[f,v,i,s]);const x=p.useRef(Ji(i)?!1:i);return a.jsx(mn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??x.current,required:l,disabled:c,name:u,value:h,form:d,...t,tabIndex:-1,ref:y,style:{...t.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});L6.displayName=M6;function Gfe(e){return typeof e=="function"}function Ji(e){return e==="indeterminate"}function U6(e){return Ji(e)?"indeterminate":e?"checked":"unchecked"}const au=p.forwardRef(({className:e,...t},n)=>a.jsx(AE,{ref:n,className:at("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:a.jsx(I6,{className:at("flex items-center justify-center text-current"),children:a.jsx(wp,{className:"h-4 w-4"})})}));au.displayName=AE.displayName;const Vfe=["user.joined","user.logged_in","user.updated","user.logged_out","user.password_changed","user.email_verified","user.banned","user.unbanned","user.deleted","user.delete_verification_requested","organization.created","organization.deleted","organization.updated","member.added","member.removed","member.role_changed","session.created","password.reset_requested","password.reset_completed","password.reset_requested_otp","password.reset_completed_otp","oauth.linked","oauth.unlinked","oauth.sign_in","team.created","team.updated","team.deleted","team.member.added","team.member.removed","invitation.created","invitation.accepted","invitation.rejected","invitation.cancelled"],Wfe=e=>{if(!e)return"—";const t=typeof e=="string"?new Date(e):e;if(Number.isNaN(t.getTime()))return"—";const n=Dn(t,"MMM").toUpperCase(),r=Dn(t,"dd"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),o=String(t.getSeconds()).padStart(2,"0"),l=String(t.getMilliseconds()).padStart(2,"0").slice(0,2);return`${n} ${r} ${s}:${i}:${o}.${l}`},mO=(e,t)=>{if(t==="failed")return"text-red-400/70 border-white/15 bg-white/5";switch(e){case"success":return"text-green-400/70 border-white/15 bg-white/5";case"warning":return"text-yellow-400/70 border-white/15 bg-white/5";case"failed":return"text-red-400/70 border-white/15 bg-white/5";default:return"text-blue-400/70 border-white/15 bg-white/5"}},gO=(e,t,n)=>{if(e.includes("organization")||e.includes("member")||e.includes("team")||e.includes("invitation"))return a.jsx(Kn,{className:"w-4 h-4"});if(e.includes("user"))return a.jsx(qt,{className:"w-4 h-4"});if(e.includes("session")||e.includes("login"))return a.jsx(XW,{className:"w-4 h-4"});if(n==="failed"||t==="failed")return a.jsx(BU,{className:"w-4 h-4"});switch(t){case"success":return a.jsx(qs,{className:"w-4 h-4"});case"warning":return a.jsx(UU,{className:"w-4 h-4"});case"failed":return a.jsx(ZN,{className:"w-4 h-4"});default:return a.jsx(ZN,{className:"w-4 h-4"})}};function Yfe(){return window.__STUDIO_CONFIG__||{}}function Xfe(){return!!Yfe().basePath}function Kfe(){var Q,J,X,re,ie,he;const e=Na(),[t,n]=p.useState([]),[r,s]=p.useState(!0),[i,o]=p.useState(""),[l,c]=p.useState("all"),[u,h]=p.useState(!1),[d,f]=p.useState(null),[m,y]=p.useState(!1),[v,w]=p.useState(new Set),x=p.useRef(null),b=p.useRef(!1),g=p.useRef(null),N=2e3,[S,E]=p.useState(!1),[j,_]=p.useState(null),[L,P]=p.useState(!0),[U,O]=p.useState(null),[W,I]=p.useState(null),[z,k]=p.useState([]),C=p.useMemo(()=>{const ee=t.filter(Ee=>{var Pe;const be=Ee.status||"success",Ae=(Pe=Ee.display)==null?void 0:Pe.severity;return be==="failed"||Ae==="failed"}).length,ue=t.filter(Ee=>{var Ae;return((Ae=Ee.display)==null?void 0:Ae.severity)==="warning"}).length,ve=t.filter(Ee=>{var Pe;const be=Ee.status||"success",Ae=(Pe=Ee.display)==null?void 0:Pe.severity;return Ae==="info"||!Ae&&be!=="failed"}).length;return{success:t.filter(Ee=>{var _e;const be=Ee.status||"success",Ae=(_e=Ee.display)==null?void 0:_e.severity;return be==="success"&&!(be==="failed"||Ae==="failed")&&!(Ae==="warning")&&!(Ae==="info"||!Ae&&be!=="failed")}).length,failed:ee,warning:ue,info:ve}},[t]),R=p.useCallback(async(ee=!1)=>{var ue,ve;if(!(b.current&&!ee)){b.current=!0;try{const Ne=new URLSearchParams({limit:"50",sort:"desc"}),Ee=Mu("/api/events"),be=await fetch(`${Ee}?${Ne.toString()}`);if(!be.ok){if(be.status===500)try{const Pe=await be.json();if((ue=Pe.details)!=null&&ue.includes("not found in schema")||(ve=Pe.details)!=null&&ve.includes("Model")){y(!0),ee&&(n([]),s(!1));return}}catch{}throw new Error(`HTTP ${be.status}: ${be.statusText}`)}const Ae=await be.json();if(y(!0),Ae.events&&Array.isArray(Ae.events)){if(Ae.events.length===0&&ee){n([]),s(!1);return}ee?(n(Ae.events),Ae.events.length>0&&(g.current=Ae.events[0].id)):(n(Pe=>{const oe=new Set(Pe.map(_e=>_e.id)),Me=Ae.events.filter(_e=>!oe.has(_e.id));if(Me.length>0){const _e=new Set(Me.map(ct=>ct.id));return w(ct=>{const Je=new Set([...ct,..._e]);return setTimeout(()=>{w(De=>{const $e=new Set(De);return _e.forEach(Ye=>$e.delete(Ye)),$e})},3e3),Je}),[...Me,...Pe].slice(0,100)}return Pe}),Ae.events.length>0&&(g.current=Ae.events[0].id))}}catch(Ne){console.error("Failed to fetch events:",Ne),y(!1)}finally{b.current=!1,s(!1)}}},[]);p.useEffect(()=>{(async()=>{const ue=Xfe();if(E(ue),!ue){_(!1),P(!1);return}try{const Ne=await(await fetch(Mu("/api/events/status"))).json();_((Ne==null?void 0:Ne.enabled)===!0)}catch(ve){console.error("Failed to check events status:",ve),_(!1)}finally{P(!1)}})()},[]),p.useEffect(()=>{u?document.body.style.overflow="hidden":document.body.style.overflow="auto"},[u]),p.useEffect(()=>{if(L)return;if(!j||!S){s(!1);return}return R(!0),(()=>{x.current&&clearInterval(x.current),x.current=setInterval(()=>{R(!1)},N)})(),()=>{x.current&&clearInterval(x.current)}},[j,S,L,R]);const D=ee=>{f(ee),h(!0)},H=ee=>{z.some(ve=>ve.type===ee)||k(ee==="eventType"?ve=>[...ve,{type:ee,eventTypes:[]}]:ve=>[...ve,{type:ee}])},T=ee=>{k(ue=>ue.filter(ve=>ve.type!==ee))},A=(ee,ue)=>{k(ve=>ve.map(Ne=>Ne.type===ee?{...Ne,dateRange:ue}:Ne))},B=(ee,ue)=>{k(ve=>ve.map(Ne=>Ne.type===ee?{...Ne,eventTypes:ue}:Ne))},F=(ee,ue)=>{const ve=z.find(be=>be.type===ee);if(!ve)return;const Ne=ve.eventTypes||[],Ee=Ne.includes(ue)?Ne.filter(be=>be!==ue):[...Ne,ue];B(ee,Ee)},$=t.filter(ee=>{var Ne,Ee,be,Ae,Pe;const ue=ee.type.toLowerCase().includes(i.toLowerCase())||((Ee=(Ne=ee.display)==null?void 0:Ne.message)==null?void 0:Ee.toLowerCase().includes(i.toLowerCase()))||((be=ee.userId)==null?void 0:be.toLowerCase().includes(i.toLowerCase()))||ee.id.toLowerCase().includes(i.toLowerCase()),ve=l==="all"||l==="success"&&ee.status==="success"||l==="failed"&&ee.status==="failed"||l==="info"&&((Ae=ee.display)==null?void 0:Ae.severity)==="info"||l==="warning"&&((Pe=ee.display)==null?void 0:Pe.severity)==="warning";if(z.length>0){const oe=z.every(Me=>{var _e,Re,ct,Je;if(Me.type==="timestamp"){if(!((_e=Me.dateRange)!=null&&_e.from)&&!((Re=Me.dateRange)!=null&&Re.to))return!0;const De=new Date(ee.timestamp);if((ct=Me.dateRange)!=null&&ct.from){const $e=new Date(Me.dateRange.from);if($e.setHours(0,0,0,0),$e>De)return!1}if((Je=Me.dateRange)!=null&&Je.to){const $e=new Date(Me.dateRange.to);if($e.setHours(23,59,59,999),$e<De)return!1}return!0}return Me.type==="eventType"?!Me.eventTypes||Me.eventTypes.length===0?!0:Me.eventTypes.includes(ee.type):!0});return ue&&ve&&oe}return ue&&ve});return L?a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[a.jsx(ya,{className:"w-6 h-6 text-white animate-spin"}),a.jsx("div",{className:"text-white text-sm",children:"Checking configuration..."})]})}):!S||!j?a.jsxs("div",{className:"space-y-6 p-6",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl relative text-white font-light inline-flex items-start",children:"Events"}),a.jsx("p",{className:"text-gray-400 mt-1 uppercase font-mono text-sm font-light",children:"Real-time authentication events and activity"})]})}),a.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:a.jsxs("div",{className:"flex flex-col items-center justify-center space-y-6",children:[a.jsx("div",{className:"flex items-center space-x-3",children:a.jsxs("div",{className:"text-left",children:[a.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Event Ingestion Not Enabled"}),a.jsx("p",{className:"text-gray-400 text-sm font-mono",children:S?"Please enable event ingestion in your studio configuration to view events.":"Event ingestion is only available in self-hosted mode."})]})}),S&&a.jsxs("div",{className:"w-full max-w-4xl",children:[a.jsx("div",{className:"mb-4",children:a.jsxs("p",{className:"text-gray-300 text-sm font-mono mb-2",children:["Add the following configuration to your"," ",a.jsx("code",{className:"text-yellow-400",children:"studio.config.ts"}),":"]})}),a.jsx(CE,{code:`import { betterAuth } from 'better-auth';
|
|
943
|
+
});`}[oe]||""},ue=oe=>{navigator.clipboard.writeText(oe),Y.success("Copied to clipboard")},ve=Object.values(Ca).filter(oe=>c==="all"||oe.category===c);return a.jsxs("div",{className:"h-full flex flex-col bg-black",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:"Emails"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Customize your email templates with a visual editor"})]})}),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"})]}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{className:"w-[340px] border-r border-dashed border-white/15 flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"p-4 border-b border-dashed border-white/15 flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-light text-white uppercase tracking-wider mb-4",children:"Templates"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:["all","authentication","organization","notification"].map(oe=>a.jsx("button",{onClick:()=>u(oe),className:`px-2 py-1 text-[10px] font-mono uppercase border border-dashed rounded-none transition-colors ${c===oe?"border-white/30 bg-white/5 text-white":"border-white/10 bg-black/40 text-gray-300 hover:border-white/20"}`,children:oe},oe))})]}),a.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-2",style:{overscrollBehavior:"contain"},children:ve.map(oe=>a.jsxs("button",{onClick:()=>F(oe.id),className:`w-full text-left p-3 border border-dashed rounded-none transition-colors ${e===oe.id?"border-white/30 bg-white/5 text-white":"border-white/15 bg-black/40 text-gray-300 hover:border-white/20 hover:bg-white/5"}`,children:[a.jsx("div",{className:"text-sm uppercase font-mono",children:oe.name}),a.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[oe.fields.length," fields"]})]},oe.id))})]}),a.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"border-b border-dashed border-white/15 p-4 flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-light text-white uppercase tracking-wider",children:(Ne=Ca[e])==null?void 0:Ne.name}),a.jsx("p",{className:"text-xs text-gray-400 font-mono mt-1",children:(Ee=Ca[e])==null?void 0:Ee.category})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs(q,{variant:"outline",onClick:()=>j(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(N3,{className:"w-4 h-4 mr-2"}),"Test Email"]}),a.jsxs(q,{variant:"outline",onClick:()=>{ee(e)&&l(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(wi,{className:"w-4 h-4 mr-2"}),"Export Code"]}),a.jsxs(q,{variant:"outline",onClick:()=>ue(n),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(Dc,{className:"w-4 h-4 mr-2"}),"Copy HTML"]})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsx("div",{className:"p-4 border-b border-dashed border-white/10 bg-black/40",children:a.jsxs("div",{className:"flex items-end gap-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject"}),a.jsx(we,{value:s,onChange:oe=>Q(oe.target.value),placeholder:"Email subject",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-sm"})]}),a.jsxs(q,{variant:"outline",onClick:()=>m(!f),className:"h-10 border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[f?"Hide":"Show"," Fields"]})]})}),f&&e&&a.jsxs("div",{className:"p-4 border-b overflow-hidden border-dashed border-white/10 bg-black/30",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Fields"}),a.jsx("div",{className:"grid grid-cols-2 gap-3 max-h-full overflow-y-hidden",children:(be=Ca[e])==null?void 0:be.fields.map(oe=>a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs font-mono text-gray-400 mb-1 block",children:oe}),a.jsx(we,{value:h[oe]||"",onChange:Me=>d(_e=>({..._e,[oe]:Me.target.value})),placeholder:`{{${oe}}}`,className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"})]},oe))}),a.jsx("div",{className:"mt-4 flex justify-end",children:a.jsx(q,{variant:"outline",onClick:ie,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Apply Changes"})})]}),e&&a.jsxs("div",{className:"p-4 border-b border-dashed border-white/10 bg-black/40",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Dynamic Fields"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:(Ae=Ca[e])==null?void 0:Ae.fields.map(oe=>a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>ue(`{{${oe}}}`),className:"text-xs rounded-none border border-dashed border-white/20 hover:bg-white/10",children:oe}),a.jsx("span",{className:"text-xs text-gray-500 font-mono",children:`{{${oe}}}`})]},oe))})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(zfe,{html:he,onChange:$})})]})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center min-h-0",children:a.jsxs("div",{className:"text-center",children:[a.jsx(_u,{className:"w-16 h-16 text-white/20 mx-auto mb-4"}),a.jsx("p",{className:"text-gray-400 font-mono uppercase text-sm",children:"Select a template to start editing"})]})})})]}),o&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&l(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-5xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-0 pt-2 border-white/15 border-b-0 bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between p-2 pt-2",children:a.jsxs("div",{className:"pb-2",children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Export"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Export the code for the selected template"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>l(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex flex-col items-center justify-center",children:[a.jsx("hr",{className:"w-full border-white/15 h-px"}),a.jsx("div",{className:"relative z-20 h-8 w-[calc(100%)] mx-auto -translate-x-1/2 left-1/2 bg-[repeating-linear-gradient(-45deg,#e0f2fe,#e0f2fe_1px,transparent_1px,transparent_6px)] opacity-[8%]"}),a.jsx("hr",{className:"w-full border-white/15 h-px"})]}),a.jsx("div",{className:"flex-1 overflow-auto p-6 bg-black",children:a.jsx(CE,{code:ee(e),language:"typescript",fileName:"auth.ts"})}),a.jsx("div",{className:"flex items-center justify-end p-6 border-t border-white/15 bg-black/50",children:a.jsx(q,{onClick:J,disabled:w,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2",children:w?"Applying...":"Apply to auth config"})})]})}),b&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&g(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-white/15 border-b bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Setup Required"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Install Resend before applying email template"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-8 bg-black",children:a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-md font-mono uppercase font-normal text-white mb-3",children:"Install Resend"}),a.jsx("p",{className:"text-gray-300 mb-4 font-sans leading-relaxed",children:"You need to install the Resend package to send emails. Run the following command in your terminal:"}),a.jsx("div",{className:"bg-black/80 border border-dashed border-white/20 p-2 pl-3 rounded-none font-mono text-sm relative group",children:a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("code",{className:"text-gray-200",children:[a.jsx("span",{className:"text-white",children:"$"})," ",a.jsx("span",{className:"text-blue-600",children:"pnpm"})," ",a.jsx("span",{className:"text-white",children:"install"})," ",a.jsx("span",{className:"text-white",children:"resend"})]}),a.jsx("button",{onClick:()=>{navigator.clipboard.writeText("pnpm install resend"),S(!0),setTimeout(()=>S(!1),2e3)},className:"flex items-center gap-2 px-2 py-1.5 rounded-none transition-colors text-gray-300 hover:text-white",title:"Copy command",children:N?a.jsx(a.Fragment,{children:a.jsx(qs,{className:"w-4 h-4"})}):a.jsx(a.Fragment,{children:a.jsx(Dc,{className:"w-4 h-4"})})})]})})]})})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/15 bg-black/50",children:[a.jsx(q,{variant:"ghost",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none font-mono uppercase text-xs px-6 py-2",children:"Cancel"}),a.jsx(q,{onClick:()=>X(e),disabled:w,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2",children:w?"Applying...":"Continue"})]})]})}),E&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&j(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-white/15 border-b bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Test Email"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Send a test email with dynamic values"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-8 bg-black",children:a.jsxs("div",{className:"space-y-6",children:[I==="checking"&&a.jsx("div",{className:"bg-black/90 flex border p-4 rounded-none border-dashed border-white/20",children:a.jsxs("p",{className:"text-white text-sm font-sans flex items-center gap-2 leading-relaxed",children:[a.jsx(ya,{className:"w-4 h-4 animate-spin mr-1"})," Checking for RESEND_API_KEY..."]})}),I==="missing"&&a.jsxs("div",{className:"bg-red-900/20 border border-red-500/30 border-dashed p-4 rounded-none",children:[a.jsx("p",{className:"text-red-200 text-sm font-sans leading-relaxed mb-2",children:a.jsx("strong",{className:"font-normal uppercase font-mono",children:"RESEND_API_KEY not found"})}),a.jsxs("p",{className:"text-red-200 text-sm font-sans leading-relaxed",children:["Please add"," ",a.jsx("code",{className:"bg-black/50 px-1 py-0.5 rounded font-mono text-xs",children:"RESEND_API_KEY"})," ","to your"," ",a.jsx("code",{className:"bg-black/50 px-1 py-0.5 rounded font-mono text-xs",children:".env"})," ","file."]})]}),I==="found"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"From Email (Verified Sender) *"}),k.length>0?a.jsx("select",{value:R,onChange:oe=>D(oe.target.value),className:"w-full bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs p-2 focus:outline-none focus:border-white/40",children:k.map(oe=>a.jsx("option",{value:oe,children:oe},oe))}):a.jsx(we,{type:"email",value:R,onChange:oe=>D(oe.target.value),placeholder:"noreply@yourdomain.com",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:k.length>0?"Select a verified sender email from your Resend account":"Enter a verified sender email address from your Resend account"})]}),a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject *"}),a.jsx(we,{type:"text",value:H,onChange:oe=>T(oe.target.value),placeholder:"Email subject",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:"Email subject line (supports dynamic placeholders)"})]}),a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"To Email Address *"}),a.jsx(we,{type:"email",value:_,onChange:oe=>L(oe.target.value),placeholder:"recipient@example.com",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:"Any email address to receive the test email"})]}),((Pe=Ca[e])==null?void 0:Pe.fields)&&Ca[e].fields.length>0&&a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Dynamic Values"}),a.jsx("div",{className:"space-y-3",children:Ca[e].fields.map(oe=>a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-500 mb-1 block",children:oe}),a.jsx(we,{value:P[oe]||"",onChange:Me=>U({...P,[oe]:Me.target.value}),placeholder:`Enter ${oe}`,className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"})]},oe))})]})]})]})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/15 bg-black/50",children:[a.jsx(q,{variant:"ghost",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none font-mono uppercase text-xs px-6 py-2",children:"Cancel"}),a.jsx(q,{onClick:B,disabled:O||I!=="found"||!_||!R||!H,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:O?"Sending...":"Send Test Email"})]})]})})]})}function _6(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Pm="Checkbox",[$fe]=ii(Pm),[Hfe,kE]=$fe(Pm);function qfe(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:i,form:o,name:l,onCheckedChange:c,required:u,value:h="on",internal_do_not_use_render:d}=e,[f,m]=Kc({prop:n,defaultProp:s??!1,onChange:c,caller:Pm}),[y,v]=p.useState(null),[w,x]=p.useState(null),b=p.useRef(!1),g=y?!!o||!!y.closest("form"):!0,N={checked:f,disabled:i,setChecked:m,control:y,setControl:v,name:l,form:o,value:h,hasConsumerStoppedPropagationRef:b,required:u,defaultChecked:Ji(s)?!1:s,isFormControl:g,bubbleInput:w,setBubbleInput:x};return a.jsx(Hfe,{scope:t,...N,children:Gfe(d)?d(N):r})}var R6="CheckboxTrigger",O6=p.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:i,value:o,disabled:l,checked:c,required:u,setControl:h,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:m,bubbleInput:y}=kE(R6,e),v=Mn(s,h),w=p.useRef(c);return p.useEffect(()=>{const x=i==null?void 0:i.form;if(x){const b=()=>d(w.current);return x.addEventListener("reset",b),()=>x.removeEventListener("reset",b)}},[i,d]),a.jsx(mn.button,{type:"button",role:"checkbox","aria-checked":Ji(c)?"mixed":c,"aria-required":u,"data-state":U6(c),"data-disabled":l?"":void 0,disabled:l,value:o,...r,ref:v,onKeyDown:Gt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Gt(n,x=>{d(b=>Ji(b)?!0:!b),y&&m&&(f.current=x.isPropagationStopped(),f.current||x.stopPropagation())})})});O6.displayName=R6;var AE=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:i,required:o,disabled:l,value:c,onCheckedChange:u,form:h,...d}=e;return a.jsx(qfe,{__scopeCheckbox:n,checked:s,defaultChecked:i,disabled:l,required:o,onCheckedChange:u,name:r,form:h,value:c,internal_do_not_use_render:({isFormControl:f})=>a.jsxs(a.Fragment,{children:[a.jsx(O6,{...d,ref:t,__scopeCheckbox:n}),f&&a.jsx(L6,{__scopeCheckbox:n})]})})});AE.displayName=Pm;var D6="CheckboxIndicator",I6=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,i=kE(D6,n);return a.jsx(oi,{present:r||Ji(i.checked)||i.checked===!0,children:a.jsx(mn.span,{"data-state":U6(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});I6.displayName=D6;var M6="CheckboxBubbleInput",L6=p.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:i,defaultChecked:o,required:l,disabled:c,name:u,value:h,form:d,bubbleInput:f,setBubbleInput:m}=kE(M6,e),y=Mn(n,m),v=_6(i),w=US(r);p.useEffect(()=>{const b=f;if(!b)return;const g=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(g,"checked").set,E=!s.current;if(v!==i&&S){const j=new Event("click",{bubbles:E});b.indeterminate=Ji(i),S.call(b,Ji(i)?!1:i),b.dispatchEvent(j)}},[f,v,i,s]);const x=p.useRef(Ji(i)?!1:i);return a.jsx(mn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??x.current,required:l,disabled:c,name:u,value:h,form:d,...t,tabIndex:-1,ref:y,style:{...t.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});L6.displayName=M6;function Gfe(e){return typeof e=="function"}function Ji(e){return e==="indeterminate"}function U6(e){return Ji(e)?"indeterminate":e?"checked":"unchecked"}const au=p.forwardRef(({className:e,...t},n)=>a.jsx(AE,{ref:n,className:at("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:a.jsx(I6,{className:at("flex items-center justify-center text-current"),children:a.jsx(wp,{className:"h-4 w-4"})})}));au.displayName=AE.displayName;const Vfe=["user.joined","user.logged_in","user.updated","user.logged_out","user.password_changed","user.email_verified","user.banned","user.unbanned","user.deleted","user.delete_verification_requested","organization.created","organization.deleted","organization.updated","member.added","member.removed","member.role_changed","session.created","password.reset_requested","password.reset_completed","password.reset_requested_otp","password.reset_completed_otp","oauth.linked","oauth.unlinked","oauth.sign_in","team.created","team.updated","team.deleted","team.member.added","team.member.removed","invitation.created","invitation.accepted","invitation.rejected","invitation.cancelled"],Wfe=e=>{if(!e)return"—";const t=typeof e=="string"?new Date(e):e;if(Number.isNaN(t.getTime()))return"—";const n=Dn(t,"MMM").toUpperCase(),r=Dn(t,"dd"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),o=String(t.getSeconds()).padStart(2,"0"),l=String(t.getMilliseconds()).padStart(2,"0").slice(0,2);return`${n} ${r} ${s}:${i}:${o}.${l}`},mO=(e,t)=>{if(t==="failed")return"text-red-400/70 border-white/15 bg-white/5";switch(e){case"success":return"text-green-400/70 border-white/15 bg-white/5";case"warning":return"text-yellow-400/70 border-white/15 bg-white/5";case"failed":return"text-red-400/70 border-white/15 bg-white/5";default:return"text-blue-400/70 border-white/15 bg-white/5"}},gO=(e,t,n)=>{if(e.includes("organization")||e.includes("member")||e.includes("team")||e.includes("invitation"))return a.jsx(Kn,{className:"w-4 h-4"});if(e.includes("user"))return a.jsx(qt,{className:"w-4 h-4"});if(e.includes("session")||e.includes("login"))return a.jsx(XW,{className:"w-4 h-4"});if(n==="failed"||t==="failed")return a.jsx(BU,{className:"w-4 h-4"});switch(t){case"success":return a.jsx(qs,{className:"w-4 h-4"});case"warning":return a.jsx(UU,{className:"w-4 h-4"});case"failed":return a.jsx(ZN,{className:"w-4 h-4"});default:return a.jsx(ZN,{className:"w-4 h-4"})}};function Yfe(){return window.__STUDIO_CONFIG__||{}}function Xfe(){return!!Yfe().basePath}function Kfe(){var Q,J,X,re,ie,he;const e=Na(),[t,n]=p.useState([]),[r,s]=p.useState(!0),[i,o]=p.useState(""),[l,c]=p.useState("all"),[u,h]=p.useState(!1),[d,f]=p.useState(null),[m,y]=p.useState(!1),[v,w]=p.useState(new Set),x=p.useRef(null),b=p.useRef(!1),g=p.useRef(null),N=2e3,[S,E]=p.useState(!1),[j,_]=p.useState(null),[L,P]=p.useState(!0),[U,O]=p.useState(null),[W,I]=p.useState(null),[z,k]=p.useState([]),C=p.useMemo(()=>{const ee=t.filter(Ee=>{var Pe;const be=Ee.status||"success",Ae=(Pe=Ee.display)==null?void 0:Pe.severity;return be==="failed"||Ae==="failed"}).length,ue=t.filter(Ee=>{var Ae;return((Ae=Ee.display)==null?void 0:Ae.severity)==="warning"}).length,ve=t.filter(Ee=>{var Pe;const be=Ee.status||"success",Ae=(Pe=Ee.display)==null?void 0:Pe.severity;return Ae==="info"||!Ae&&be!=="failed"}).length;return{success:t.filter(Ee=>{var _e;const be=Ee.status||"success",Ae=(_e=Ee.display)==null?void 0:_e.severity;return be==="success"&&!(be==="failed"||Ae==="failed")&&!(Ae==="warning")&&!(Ae==="info"||!Ae&&be!=="failed")}).length,failed:ee,warning:ue,info:ve}},[t]),R=p.useCallback(async(ee=!1)=>{var ue,ve;if(!(b.current&&!ee)){b.current=!0;try{const Ne=new URLSearchParams({limit:"50",sort:"desc"}),Ee=Mu("/api/events"),be=await fetch(`${Ee}?${Ne.toString()}`);if(!be.ok){if(be.status===500)try{const Pe=await be.json();if((ue=Pe.details)!=null&&ue.includes("not found in schema")||(ve=Pe.details)!=null&&ve.includes("Model")){y(!0),ee&&(n([]),s(!1));return}}catch{}throw new Error(`HTTP ${be.status}: ${be.statusText}`)}const Ae=await be.json();if(y(!0),Ae.events&&Array.isArray(Ae.events)){if(Ae.events.length===0&&ee){n([]),s(!1);return}ee?(n(Ae.events),Ae.events.length>0&&(g.current=Ae.events[0].id)):(n(Pe=>{const oe=new Set(Pe.map(_e=>_e.id)),Me=Ae.events.filter(_e=>!oe.has(_e.id));if(Me.length>0){const _e=new Set(Me.map(ct=>ct.id));return w(ct=>{const Je=new Set([...ct,..._e]);return setTimeout(()=>{w(De=>{const $e=new Set(De);return _e.forEach(Ye=>$e.delete(Ye)),$e})},3e3),Je}),[...Me,...Pe].slice(0,100)}return Pe}),Ae.events.length>0&&(g.current=Ae.events[0].id))}}catch(Ne){console.error("Failed to fetch events:",Ne),y(!1)}finally{b.current=!1,s(!1)}}},[]);p.useEffect(()=>{(async()=>{const ue=Xfe();if(E(ue),!ue){_(!1),P(!1);return}try{const Ne=await(await fetch(Mu("/api/events/status"))).json();_((Ne==null?void 0:Ne.enabled)===!0)}catch(ve){console.error("Failed to check events status:",ve),_(!1)}finally{P(!1)}})()},[]),p.useEffect(()=>{u?document.body.style.overflow="hidden":document.body.style.overflow="auto"},[u]),p.useEffect(()=>{if(L)return;if(!j||!S){s(!1);return}return R(!0),(()=>{x.current&&clearInterval(x.current),x.current=setInterval(()=>{R(!1)},N)})(),()=>{x.current&&clearInterval(x.current)}},[j,S,L,R]);const D=ee=>{f(ee),h(!0)},H=ee=>{z.some(ve=>ve.type===ee)||k(ee==="eventType"?ve=>[...ve,{type:ee,eventTypes:[]}]:ve=>[...ve,{type:ee}])},T=ee=>{k(ue=>ue.filter(ve=>ve.type!==ee))},A=(ee,ue)=>{k(ve=>ve.map(Ne=>Ne.type===ee?{...Ne,dateRange:ue}:Ne))},B=(ee,ue)=>{k(ve=>ve.map(Ne=>Ne.type===ee?{...Ne,eventTypes:ue}:Ne))},F=(ee,ue)=>{const ve=z.find(be=>be.type===ee);if(!ve)return;const Ne=ve.eventTypes||[],Ee=Ne.includes(ue)?Ne.filter(be=>be!==ue):[...Ne,ue];B(ee,Ee)},$=t.filter(ee=>{var Ne,Ee,be,Ae,Pe;const ue=ee.type.toLowerCase().includes(i.toLowerCase())||((Ee=(Ne=ee.display)==null?void 0:Ne.message)==null?void 0:Ee.toLowerCase().includes(i.toLowerCase()))||((be=ee.userId)==null?void 0:be.toLowerCase().includes(i.toLowerCase()))||ee.id.toLowerCase().includes(i.toLowerCase()),ve=l==="all"||l==="success"&&ee.status==="success"||l==="failed"&&ee.status==="failed"||l==="info"&&((Ae=ee.display)==null?void 0:Ae.severity)==="info"||l==="warning"&&((Pe=ee.display)==null?void 0:Pe.severity)==="warning";if(z.length>0){const oe=z.every(Me=>{var _e,Re,ct,Je;if(Me.type==="timestamp"){if(!((_e=Me.dateRange)!=null&&_e.from)&&!((Re=Me.dateRange)!=null&&Re.to))return!0;const De=new Date(ee.timestamp);if((ct=Me.dateRange)!=null&&ct.from){const $e=new Date(Me.dateRange.from);if($e.setHours(0,0,0,0),$e>De)return!1}if((Je=Me.dateRange)!=null&&Je.to){const $e=new Date(Me.dateRange.to);if($e.setHours(23,59,59,999),$e<De)return!1}return!0}return Me.type==="eventType"?!Me.eventTypes||Me.eventTypes.length===0?!0:Me.eventTypes.includes(ee.type):!0});return ue&&ve&&oe}return ue&&ve});return L?a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[a.jsx(ya,{className:"w-6 h-6 text-white animate-spin"}),a.jsx("div",{className:"text-white text-sm",children:"Checking configuration..."})]})}):!S||!j?a.jsxs("div",{className:"space-y-6 p-6",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl relative text-white font-light inline-flex items-start",children:"Events"}),a.jsx("p",{className:"text-gray-400 mt-1 uppercase font-mono text-sm font-light",children:"Real-time authentication events and activity"})]})}),a.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:a.jsxs("div",{className:"flex flex-col items-center justify-center space-y-6",children:[a.jsx("div",{className:"flex items-center space-x-3",children:a.jsxs("div",{className:"text-left",children:[a.jsx("h2",{className:"text-xl text-white font-mono font-light mb-2",children:"Event Ingestion Not Enabled"}),a.jsx("p",{className:"text-gray-400 text-sm font-mono",children:S?"Please enable event ingestion in your studio configuration to view events.":"Event ingestion is only available in self-hosted mode."})]})}),S&&a.jsxs("div",{className:"w-full max-w-4xl",children:[a.jsx("div",{className:"mb-4",children:a.jsxs("p",{className:"text-gray-300 text-sm font-mono mb-2",children:["Add the following configuration to your"," ",a.jsx("code",{className:"text-yellow-400",children:"studio.config.ts"}),":"]})}),a.jsx(CE,{code:`import { betterAuth } from 'better-auth';
|
|
944
944
|
import { prismaAdapter } from 'better-auth/adapters/prisma';
|
|
945
945
|
import { studio } from '@better-auth/studio';
|
|
946
946
|
import { prisma } from './db';
|
package/dist/public/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/png" href="/logo.png" />
|
|
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-
|
|
8
|
+
<script type="module" crossorigin src="/assets/main-BeCk6LUx.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/main-w2bJSKlF.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/package.json
CHANGED
|
@@ -940,7 +940,7 @@ export const auth = betterAuth({
|
|
|
940
940
|
},
|
|
941
941
|
}),
|
|
942
942
|
],
|
|
943
|
-
});`}[oe]||""},ue=oe=>{navigator.clipboard.writeText(oe),Y.success("Copied to clipboard")},ve=Object.values(Ca).filter(oe=>c==="all"||oe.category===c);return a.jsxs("div",{className:"h-full flex flex-col bg-black",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:"Emails"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Customize your email templates with a visual editor"})]})}),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"})]}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{className:"w-[340px] border-r border-dashed border-white/15 flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"p-4 border-b border-dashed border-white/15 flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-light text-white uppercase tracking-wider mb-4",children:"Templates"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:["all","authentication","organization","notification"].map(oe=>a.jsx("button",{onClick:()=>u(oe),className:`px-2 py-1 text-[10px] font-mono uppercase border border-dashed rounded-none transition-colors ${c===oe?"border-white/30 bg-white/5 text-white":"border-white/10 bg-black/40 text-gray-300 hover:border-white/20"}`,children:oe},oe))})]}),a.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-2",style:{overscrollBehavior:"contain"},children:ve.map(oe=>a.jsxs("button",{onClick:()=>F(oe.id),className:`w-full text-left p-3 border border-dashed rounded-none transition-colors ${e===oe.id?"border-white/30 bg-white/5 text-white":"border-white/15 bg-black/40 text-gray-300 hover:border-white/20 hover:bg-white/5"}`,children:[a.jsx("div",{className:"text-sm uppercase font-mono",children:oe.name}),a.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[oe.fields.length," fields"]})]},oe.id))})]}),a.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"border-b border-dashed border-white/15 p-4 flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-light text-white uppercase tracking-wider",children:(Ne=Ca[e])==null?void 0:Ne.name}),a.jsx("p",{className:"text-xs text-gray-400 font-mono mt-1",children:(Ee=Ca[e])==null?void 0:Ee.category})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs(q,{variant:"outline",onClick:()=>j(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(N3,{className:"w-4 h-4 mr-2"}),"Test Email"]}),a.jsxs(q,{variant:"outline",onClick:()=>{ee(e)&&l(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(wi,{className:"w-4 h-4 mr-2"}),"Export Code"]}),a.jsxs(q,{variant:"outline",onClick:()=>ue(n),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(Dc,{className:"w-4 h-4 mr-2"}),"Copy HTML"]})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsx("div",{className:"p-4 border-b border-dashed border-white/10 bg-black/40",children:a.jsxs("div",{className:"flex items-end gap-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject"}),a.jsx(we,{value:s,onChange:oe=>Q(oe.target.value),placeholder:"Email subject",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-sm"})]}),a.jsxs(q,{variant:"outline",onClick:()=>m(!f),className:"h-10 border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[f?"Hide":"Show"," Fields"]})]})}),f&&e&&a.jsxs("div",{className:"p-4 border-b overflow-hidden border-dashed border-white/10 bg-black/30",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Fields"}),a.jsx("div",{className:"grid grid-cols-2 gap-3 max-h-full overflow-y-hidden",children:(be=Ca[e])==null?void 0:be.fields.map(oe=>a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs font-mono text-gray-400 mb-1 block",children:oe}),a.jsx(we,{value:h[oe]||"",onChange:Me=>d(_e=>({..._e,[oe]:Me.target.value})),placeholder:`{{${oe}}}`,className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"})]},oe))}),a.jsx("div",{className:"mt-4 flex justify-end",children:a.jsx(q,{variant:"outline",onClick:ie,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Apply Changes"})})]}),e&&a.jsxs("div",{className:"p-4 border-b border-dashed border-white/10 bg-black/40",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Dynamic Fields"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:(Ae=Ca[e])==null?void 0:Ae.fields.map(oe=>a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>ue(`{{${oe}}}`),className:"text-xs rounded-none border border-dashed border-white/20 hover:bg-white/10",children:oe}),a.jsx("span",{className:"text-xs text-gray-500 font-mono",children:`{{${oe}}}`})]},oe))})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(zfe,{html:he,onChange:$})})]})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center min-h-0",children:a.jsxs("div",{className:"text-center",children:[a.jsx(_u,{className:"w-16 h-16 text-white/20 mx-auto mb-4"}),a.jsx("p",{className:"text-gray-400 font-mono uppercase text-sm",children:"Select a template to start editing"})]})})})]}),o&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&l(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-5xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-0 pt-2 border-white/15 border-b-0 bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between p-2 pt-2",children:a.jsxs("div",{className:"pb-2",children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Export"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Export the code for the selected template"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>l(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex flex-col items-center justify-center",children:[a.jsx("hr",{className:"w-full border-white/15 h-px"}),a.jsx("div",{className:"relative z-20 h-8 w-[calc(100%)] mx-auto -translate-x-1/2 left-1/2 bg-[repeating-linear-gradient(-45deg,#e0f2fe,#e0f2fe_1px,transparent_1px,transparent_6px)] opacity-[8%]"}),a.jsx("hr",{className:"w-full border-white/15 h-px"})]}),a.jsx("div",{className:"flex-1 overflow-auto p-6 bg-black",children:a.jsx(CE,{code:ee(e),language:"typescript",fileName:"auth.ts"})}),a.jsx("div",{className:"flex items-center justify-end p-6 border-t border-white/15 bg-black/50",children:a.jsx(q,{onClick:J,disabled:w,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2",children:w?"Applying...":"Apply to auth config"})})]})}),b&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&g(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-white/15 border-b bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Setup Required"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Install Resend before applying email template"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-8 bg-black",children:a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-md font-mono uppercase font-normal text-white mb-3",children:"Install Resend"}),a.jsx("p",{className:"text-gray-300 mb-4 font-sans leading-relaxed",children:"You need to install the Resend package to send emails. Run the following command in your terminal:"}),a.jsx("div",{className:"bg-black/80 border border-dashed border-white/20 p-2 pl-3 rounded-none font-mono text-sm relative group",children:a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("code",{className:"text-gray-200",children:[a.jsx("span",{className:"text-white",children:"$"})," ",a.jsx("span",{className:"text-blue-600",children:"pnpm"})," ",a.jsx("span",{className:"text-white",children:"install"})," ",a.jsx("span",{className:"text-white",children:"resend"})]}),a.jsx("button",{onClick:()=>{navigator.clipboard.writeText("pnpm install resend"),S(!0),setTimeout(()=>S(!1),2e3)},className:"flex items-center gap-2 px-2 py-1.5 rounded-none transition-colors text-gray-300 hover:text-white",title:"Copy command",children:N?a.jsx(a.Fragment,{children:a.jsx(qs,{className:"w-4 h-4"})}):a.jsx(a.Fragment,{children:a.jsx(Dc,{className:"w-4 h-4"})})})]})})]})})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/15 bg-black/50",children:[a.jsx(q,{variant:"ghost",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none font-mono uppercase text-xs px-6 py-2",children:"Cancel"}),a.jsx(q,{onClick:()=>X(e),disabled:w,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2",children:w?"Applying...":"Continue"})]})]})}),E&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&j(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-white/15 border-b bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Test Email"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Send a test email with dynamic values"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-8 bg-black",children:a.jsxs("div",{className:"space-y-6",children:[I==="checking"&&a.jsx("div",{className:"bg-black/90 flex border p-4 rounded-none border-dashed border-white/20",children:a.jsxs("p",{className:"text-white text-sm font-sans flex items-center gap-2 leading-relaxed",children:[a.jsx(ya,{className:"w-4 h-4 animate-spin mr-1"})," Checking for RESEND_API_KEY..."]})}),I==="missing"&&a.jsxs("div",{className:"bg-red-900/20 border border-red-500/30 border-dashed p-4 rounded-none",children:[a.jsx("p",{className:"text-red-200 text-sm font-sans leading-relaxed mb-2",children:a.jsx("strong",{className:"font-normal uppercase font-mono",children:"RESEND_API_KEY not found"})}),a.jsxs("p",{className:"text-red-200 text-sm font-sans leading-relaxed",children:["Please add"," ",a.jsx("code",{className:"bg-black/50 px-1 py-0.5 rounded font-mono text-xs",children:"RESEND_API_KEY"})," ","to your"," ",a.jsx("code",{className:"bg-black/50 px-1 py-0.5 rounded font-mono text-xs",children:".env"})," ","file."]})]}),I==="found"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"From Email (Verified Sender) *"}),k.length>0?a.jsx("select",{value:R,onChange:oe=>D(oe.target.value),className:"w-full bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs p-2 focus:outline-none focus:border-white/40",children:k.map(oe=>a.jsx("option",{value:oe,children:oe},oe))}):a.jsx(we,{type:"email",value:R,onChange:oe=>D(oe.target.value),placeholder:"noreply@yourdomain.com",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:k.length>0?"Select a verified sender email from your Resend account":"Enter a verified sender email address from your Resend account"})]}),a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject *"}),a.jsx(we,{type:"text",value:H,onChange:oe=>T(oe.target.value),placeholder:"Email subject",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:"Email subject line (supports dynamic placeholders)"})]}),a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"To Email Address *"}),a.jsx(we,{type:"email",value:_,onChange:oe=>L(oe.target.value),placeholder:"recipient@example.com",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:"Any email address to receive the test email"})]}),((Pe=Ca[e])==null?void 0:Pe.fields)&&Ca[e].fields.length>0&&a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Dynamic Values"}),a.jsx("div",{className:"space-y-3",children:Ca[e].fields.map(oe=>a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-500 mb-1 block",children:oe}),a.jsx(we,{value:P[oe]||"",onChange:Me=>U({...P,[oe]:Me.target.value}),placeholder:`Enter ${oe}`,className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"})]},oe))})]})]})]})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/15 bg-black/50",children:[a.jsx(q,{variant:"ghost",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none font-mono uppercase text-xs px-6 py-2",children:"Cancel"}),a.jsx(q,{onClick:B,disabled:O||I!=="found"||!_||!R||!H,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:O?"Sending...":"Send Test Email"})]})]})})]})}function _6(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Pm="Checkbox",[$fe]=ii(Pm),[Hfe,kE]=$fe(Pm);function qfe(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:i,form:o,name:l,onCheckedChange:c,required:u,value:h="on",internal_do_not_use_render:d}=e,[f,m]=Kc({prop:n,defaultProp:s??!1,onChange:c,caller:Pm}),[y,v]=p.useState(null),[w,x]=p.useState(null),b=p.useRef(!1),g=y?!!o||!!y.closest("form"):!0,N={checked:f,disabled:i,setChecked:m,control:y,setControl:v,name:l,form:o,value:h,hasConsumerStoppedPropagationRef:b,required:u,defaultChecked:Ji(s)?!1:s,isFormControl:g,bubbleInput:w,setBubbleInput:x};return a.jsx(Hfe,{scope:t,...N,children:Gfe(d)?d(N):r})}var R6="CheckboxTrigger",O6=p.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:i,value:o,disabled:l,checked:c,required:u,setControl:h,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:m,bubbleInput:y}=kE(R6,e),v=Mn(s,h),w=p.useRef(c);return p.useEffect(()=>{const x=i==null?void 0:i.form;if(x){const b=()=>d(w.current);return x.addEventListener("reset",b),()=>x.removeEventListener("reset",b)}},[i,d]),a.jsx(mn.button,{type:"button",role:"checkbox","aria-checked":Ji(c)?"mixed":c,"aria-required":u,"data-state":U6(c),"data-disabled":l?"":void 0,disabled:l,value:o,...r,ref:v,onKeyDown:Gt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Gt(n,x=>{d(b=>Ji(b)?!0:!b),y&&m&&(f.current=x.isPropagationStopped(),f.current||x.stopPropagation())})})});O6.displayName=R6;var AE=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:i,required:o,disabled:l,value:c,onCheckedChange:u,form:h,...d}=e;return a.jsx(qfe,{__scopeCheckbox:n,checked:s,defaultChecked:i,disabled:l,required:o,onCheckedChange:u,name:r,form:h,value:c,internal_do_not_use_render:({isFormControl:f})=>a.jsxs(a.Fragment,{children:[a.jsx(O6,{...d,ref:t,__scopeCheckbox:n}),f&&a.jsx(L6,{__scopeCheckbox:n})]})})});AE.displayName=Pm;var D6="CheckboxIndicator",I6=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,i=kE(D6,n);return a.jsx(oi,{present:r||Ji(i.checked)||i.checked===!0,children:a.jsx(mn.span,{"data-state":U6(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});I6.displayName=D6;var M6="CheckboxBubbleInput",L6=p.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:i,defaultChecked:o,required:l,disabled:c,name:u,value:h,form:d,bubbleInput:f,setBubbleInput:m}=kE(M6,e),y=Mn(n,m),v=_6(i),w=US(r);p.useEffect(()=>{const b=f;if(!b)return;const g=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(g,"checked").set,E=!s.current;if(v!==i&&S){const j=new Event("click",{bubbles:E});b.indeterminate=Ji(i),S.call(b,Ji(i)?!1:i),b.dispatchEvent(j)}},[f,v,i,s]);const x=p.useRef(Ji(i)?!1:i);return a.jsx(mn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??x.current,required:l,disabled:c,name:u,value:h,form:d,...t,tabIndex:-1,ref:y,style:{...t.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});L6.displayName=M6;function Gfe(e){return typeof e=="function"}function Ji(e){return e==="indeterminate"}function U6(e){return Ji(e)?"indeterminate":e?"checked":"unchecked"}const au=p.forwardRef(({className:e,...t},n)=>a.jsx(AE,{ref:n,className:at("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:a.jsx(I6,{className:at("flex items-center justify-center text-current"),children:a.jsx(wp,{className:"h-4 w-4"})})}));au.displayName=AE.displayName;const Vfe=["user.joined","user.logged_in","user.updated","user.logged_out","user.password_changed","user.email_verified","user.banned","user.unbanned","user.deleted","user.delete_verification_requested","organization.created","organization.deleted","organization.updated","member.added","member.removed","member.role_changed","session.created","password.reset_requested","password.reset_completed","password.reset_requested_otp","password.reset_completed_otp","oauth.linked","oauth.unlinked","oauth.sign_in","team.created","team.updated","team.deleted","team.member.added","team.member.removed","invitation.created","invitation.accepted","invitation.rejected","invitation.cancelled"],Wfe=e=>{if(!e)return"—";const t=typeof e=="string"?new Date(e):e;if(Number.isNaN(t.getTime()))return"—";const n=Dn(t,"MMM").toUpperCase(),r=Dn(t,"dd"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),o=String(t.getSeconds()).padStart(2,"0"),l=String(t.getMilliseconds()).padStart(2,"0").slice(0,2);return`${n} ${r} ${s}:${i}:${o}.${l}`},mO=(e,t)=>{if(t==="failed")return"text-red-400/70 border-white/15 bg-white/5";switch(e){case"success":return"text-green-400/70 border-white/15 bg-white/5";case"warning":return"text-yellow-400/70 border-white/15 bg-white/5";case"failed":return"text-red-400/70 border-white/15 bg-white/5";default:return"text-blue-400/70 border-white/15 bg-white/5"}},gO=(e,t,n)=>{if(e.includes("organization")||e.includes("member")||e.includes("team")||e.includes("invitation"))return a.jsx(Kn,{className:"w-4 h-4"});if(e.includes("user"))return a.jsx(qt,{className:"w-4 h-4"});if(e.includes("session")||e.includes("login"))return a.jsx(XW,{className:"w-4 h-4"});if(n==="failed"||t==="failed")return a.jsx(BU,{className:"w-4 h-4"});switch(t){case"success":return a.jsx(qs,{className:"w-4 h-4"});case"warning":return a.jsx(UU,{className:"w-4 h-4"});case"failed":return a.jsx(ZN,{className:"w-4 h-4"});default:return a.jsx(ZN,{className:"w-4 h-4"})}};function Yfe(){return window.__STUDIO_CONFIG__||{}}function Xfe(){return!!Yfe().basePath}function Kfe(){var Q,J,X,re,ie,he;const e=Na(),[t,n]=p.useState([]),[r,s]=p.useState(!0),[i,o]=p.useState(""),[l,c]=p.useState("all"),[u,h]=p.useState(!1),[d,f]=p.useState(null),[m,y]=p.useState(!1),[v,w]=p.useState(new Set),x=p.useRef(null),b=p.useRef(!1),g=p.useRef(null),N=2e3,[S,E]=p.useState(!1),[j,_]=p.useState(null),[L,P]=p.useState(!0),[U,O]=p.useState(null),[W,I]=p.useState(null),[z,k]=p.useState([]),C=p.useMemo(()=>{const ee=t.filter(Ee=>{var Pe;const be=Ee.status||"success",Ae=(Pe=Ee.display)==null?void 0:Pe.severity;return be==="failed"||Ae==="failed"}).length,ue=t.filter(Ee=>{var Ae;return((Ae=Ee.display)==null?void 0:Ae.severity)==="warning"}).length,ve=t.filter(Ee=>{var Pe;const be=Ee.status||"success",Ae=(Pe=Ee.display)==null?void 0:Pe.severity;return Ae==="info"||!Ae&&be!=="failed"}).length;return{success:t.filter(Ee=>{var _e;const be=Ee.status||"success",Ae=(_e=Ee.display)==null?void 0:_e.severity;return be==="success"&&!(be==="failed"||Ae==="failed")&&!(Ae==="warning")&&!(Ae==="info"||!Ae&&be!=="failed")}).length,failed:ee,warning:ue,info:ve}},[t]),R=p.useCallback(async(ee=!1)=>{var ue,ve;if(!(b.current&&!ee)){b.current=!0;try{const Ne=new URLSearchParams({limit:"50",sort:"desc"}),Ee=Mu("/api/events"),be=await fetch(`${Ee}?${Ne.toString()}`);if(!be.ok){if(be.status===500)try{const Pe=await be.json();if((ue=Pe.details)!=null&&ue.includes("not found in schema")||(ve=Pe.details)!=null&&ve.includes("Model")){y(!0),ee&&(n([]),s(!1));return}}catch{}throw new Error(`HTTP ${be.status}: ${be.statusText}`)}const Ae=await be.json();if(y(!0),Ae.events&&Array.isArray(Ae.events)){if(Ae.events.length===0&&ee){n([]),s(!1);return}ee?(n(Ae.events),Ae.events.length>0&&(g.current=Ae.events[0].id)):(n(Pe=>{const oe=new Set(Pe.map(_e=>_e.id)),Me=Ae.events.filter(_e=>!oe.has(_e.id));if(Me.length>0){const _e=new Set(Me.map(ct=>ct.id));return w(ct=>{const Je=new Set([...ct,..._e]);return setTimeout(()=>{w(De=>{const $e=new Set(De);return _e.forEach(Ye=>$e.delete(Ye)),$e})},3e3),Je}),[...Me,...Pe].slice(0,100)}return Pe}),Ae.events.length>0&&(g.current=Ae.events[0].id))}}catch(Ne){console.error("Failed to fetch events:",Ne),y(!1)}finally{b.current=!1,s(!1)}}},[]);p.useEffect(()=>{(async()=>{const ue=Xfe();if(E(ue),!ue){_(!1),P(!1);return}try{const Ne=await(await fetch(Mu("/api/events/status"))).json();_((Ne==null?void 0:Ne.enabled)===!0)}catch(ve){console.error("Failed to check events status:",ve),_(!1)}finally{P(!1)}})()},[]),p.useEffect(()=>{u?document.body.style.overflow="hidden":document.body.style.overflow="auto"},[u]),p.useEffect(()=>{if(L)return;if(!j||!S){s(!1);return}return R(!0),(()=>{x.current&&clearInterval(x.current),x.current=setInterval(()=>{R(!1)},N)})(),()=>{x.current&&clearInterval(x.current)}},[j,S,L,R]);const D=ee=>{f(ee),h(!0)},H=ee=>{z.some(ve=>ve.type===ee)||k(ee==="eventType"?ve=>[...ve,{type:ee,eventTypes:[]}]:ve=>[...ve,{type:ee}])},T=ee=>{k(ue=>ue.filter(ve=>ve.type!==ee))},A=(ee,ue)=>{k(ve=>ve.map(Ne=>Ne.type===ee?{...Ne,dateRange:ue}:Ne))},B=(ee,ue)=>{k(ve=>ve.map(Ne=>Ne.type===ee?{...Ne,eventTypes:ue}:Ne))},F=(ee,ue)=>{const ve=z.find(be=>be.type===ee);if(!ve)return;const Ne=ve.eventTypes||[],Ee=Ne.includes(ue)?Ne.filter(be=>be!==ue):[...Ne,ue];B(ee,Ee)},$=t.filter(ee=>{var Ne,Ee,be,Ae,Pe;const ue=ee.type.toLowerCase().includes(i.toLowerCase())||((Ee=(Ne=ee.display)==null?void 0:Ne.message)==null?void 0:Ee.toLowerCase().includes(i.toLowerCase()))||((be=ee.userId)==null?void 0:be.toLowerCase().includes(i.toLowerCase()))||ee.id.toLowerCase().includes(i.toLowerCase()),ve=l==="all"||l==="success"&&ee.status==="success"||l==="failed"&&ee.status==="failed"||l==="info"&&((Ae=ee.display)==null?void 0:Ae.severity)==="info"||l==="warning"&&((Pe=ee.display)==null?void 0:Pe.severity)==="warning";if(z.length>0){const oe=z.every(Me=>{var _e,Re,ct,Je;if(Me.type==="timestamp"){if(!((_e=Me.dateRange)!=null&&_e.from)&&!((Re=Me.dateRange)!=null&&Re.to))return!0;const De=new Date(ee.timestamp);if((ct=Me.dateRange)!=null&&ct.from){const $e=new Date(Me.dateRange.from);if($e.setHours(0,0,0,0),$e>De)return!1}if((Je=Me.dateRange)!=null&&Je.to){const $e=new Date(Me.dateRange.to);if($e.setHours(23,59,59,999),$e<De)return!1}return!0}return Me.type==="eventType"?!Me.eventTypes||Me.eventTypes.length===0?!0:Me.eventTypes.includes(ee.type):!0});return ue&&ve&&oe}return ue&&ve});return L?a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[a.jsx(ya,{className:"w-6 h-6 text-white animate-spin"}),a.jsx("div",{className:"text-white text-sm",children:"Checking configuration..."})]})}):!S||!j?a.jsxs("div",{className:"space-y-6 p-6",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl relative text-white font-light inline-flex items-start",children:"Events"}),a.jsx("p",{className:"text-gray-400 mt-1 uppercase font-mono text-sm font-light",children:"Real-time authentication events and activity"})]})}),a.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:a.jsxs("div",{className:"flex flex-col items-center justify-center space-y-6",children:[a.jsx("div",{className:"flex items-center space-x-3",children:a.jsxs("div",{className:"text-left",children:[a.jsx("h2",{className:"text-xl text-white font-light mb-2",children:"Event Ingestion Not Enabled"}),a.jsx("p",{className:"text-gray-400 text-sm font-mono",children:S?"Please enable event ingestion in your studio configuration to view events.":"Event ingestion is only available in self-hosted mode."})]})}),S&&a.jsxs("div",{className:"w-full max-w-4xl",children:[a.jsx("div",{className:"mb-4",children:a.jsxs("p",{className:"text-gray-300 text-sm font-mono mb-2",children:["Add the following configuration to your"," ",a.jsx("code",{className:"text-yellow-400",children:"studio.config.ts"}),":"]})}),a.jsx(CE,{code:`import { betterAuth } from 'better-auth';
|
|
943
|
+
});`}[oe]||""},ue=oe=>{navigator.clipboard.writeText(oe),Y.success("Copied to clipboard")},ve=Object.values(Ca).filter(oe=>c==="all"||oe.category===c);return a.jsxs("div",{className:"h-full flex flex-col bg-black",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:"Emails"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Customize your email templates with a visual editor"})]})}),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"})]}),a.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[a.jsxs("div",{className:"w-[340px] border-r border-dashed border-white/15 flex flex-col overflow-hidden",children:[a.jsxs("div",{className:"p-4 border-b border-dashed border-white/15 flex-shrink-0",children:[a.jsx("h2",{className:"text-lg font-light text-white uppercase tracking-wider mb-4",children:"Templates"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:["all","authentication","organization","notification"].map(oe=>a.jsx("button",{onClick:()=>u(oe),className:`px-2 py-1 text-[10px] font-mono uppercase border border-dashed rounded-none transition-colors ${c===oe?"border-white/30 bg-white/5 text-white":"border-white/10 bg-black/40 text-gray-300 hover:border-white/20"}`,children:oe},oe))})]}),a.jsx("div",{className:"flex-1 overflow-y-auto overflow-x-hidden p-4 space-y-2",style:{overscrollBehavior:"contain"},children:ve.map(oe=>a.jsxs("button",{onClick:()=>F(oe.id),className:`w-full text-left p-3 border border-dashed rounded-none transition-colors ${e===oe.id?"border-white/30 bg-white/5 text-white":"border-white/15 bg-black/40 text-gray-300 hover:border-white/20 hover:bg-white/5"}`,children:[a.jsx("div",{className:"text-sm uppercase font-mono",children:oe.name}),a.jsxs("div",{className:"text-xs text-gray-500 mt-1",children:[oe.fields.length," fields"]})]},oe.id))})]}),a.jsx("div",{className:"flex-1 flex flex-col overflow-hidden",children:e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"border-b border-dashed border-white/15 p-4 flex items-center justify-between",children:[a.jsxs("div",{children:[a.jsx("h3",{className:"text-lg font-light text-white uppercase tracking-wider",children:(Ne=Ca[e])==null?void 0:Ne.name}),a.jsx("p",{className:"text-xs text-gray-400 font-mono mt-1",children:(Ee=Ca[e])==null?void 0:Ee.category})]}),a.jsxs("div",{className:"flex items-center space-x-2",children:[a.jsxs(q,{variant:"outline",onClick:()=>j(!0),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(N3,{className:"w-4 h-4 mr-2"}),"Test Email"]}),a.jsxs(q,{variant:"outline",onClick:()=>{ee(e)&&l(!0)},className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(wi,{className:"w-4 h-4 mr-2"}),"Export Code"]}),a.jsxs(q,{variant:"outline",onClick:()=>ue(n),className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[a.jsx(Dc,{className:"w-4 h-4 mr-2"}),"Copy HTML"]})]})]}),a.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[a.jsx("div",{className:"p-4 border-b border-dashed border-white/10 bg-black/40",children:a.jsxs("div",{className:"flex items-end gap-4",children:[a.jsxs("div",{className:"flex-1",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject"}),a.jsx(we,{value:s,onChange:oe=>Q(oe.target.value),placeholder:"Email subject",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-sm"})]}),a.jsxs(q,{variant:"outline",onClick:()=>m(!f),className:"h-10 border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:[f?"Hide":"Show"," Fields"]})]})}),f&&e&&a.jsxs("div",{className:"p-4 border-b overflow-hidden border-dashed border-white/10 bg-black/30",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Fields"}),a.jsx("div",{className:"grid grid-cols-2 gap-3 max-h-full overflow-y-hidden",children:(be=Ca[e])==null?void 0:be.fields.map(oe=>a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs font-mono text-gray-400 mb-1 block",children:oe}),a.jsx(we,{value:h[oe]||"",onChange:Me=>d(_e=>({..._e,[oe]:Me.target.value})),placeholder:`{{${oe}}}`,className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"})]},oe))}),a.jsx("div",{className:"mt-4 flex justify-end",children:a.jsx(q,{variant:"outline",onClick:ie,className:"border border-dashed border-white/20 text-white hover:bg-white/10 rounded-none",children:"Apply Changes"})})]}),e&&a.jsxs("div",{className:"p-4 border-b border-dashed border-white/10 bg-black/40",children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Dynamic Fields"}),a.jsx("div",{className:"flex flex-wrap gap-2",children:(Ae=Ca[e])==null?void 0:Ae.fields.map(oe=>a.jsxs("div",{className:"flex items-center gap-1",children:[a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>ue(`{{${oe}}}`),className:"text-xs rounded-none border border-dashed border-white/20 hover:bg-white/10",children:oe}),a.jsx("span",{className:"text-xs text-gray-500 font-mono",children:`{{${oe}}}`})]},oe))})]}),a.jsx("div",{className:"flex-1 overflow-hidden",children:a.jsx(zfe,{html:he,onChange:$})})]})]}):a.jsx("div",{className:"flex-1 flex items-center justify-center min-h-0",children:a.jsxs("div",{className:"text-center",children:[a.jsx(_u,{className:"w-16 h-16 text-white/20 mx-auto mb-4"}),a.jsx("p",{className:"text-gray-400 font-mono uppercase text-sm",children:"Select a template to start editing"})]})})})]}),o&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&l(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-5xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-0 pt-2 border-white/15 border-b-0 bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between p-2 pt-2",children:a.jsxs("div",{className:"pb-2",children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Export"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Export the code for the selected template"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>l(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsxs("div",{className:"flex flex-col items-center justify-center",children:[a.jsx("hr",{className:"w-full border-white/15 h-px"}),a.jsx("div",{className:"relative z-20 h-8 w-[calc(100%)] mx-auto -translate-x-1/2 left-1/2 bg-[repeating-linear-gradient(-45deg,#e0f2fe,#e0f2fe_1px,transparent_1px,transparent_6px)] opacity-[8%]"}),a.jsx("hr",{className:"w-full border-white/15 h-px"})]}),a.jsx("div",{className:"flex-1 overflow-auto p-6 bg-black",children:a.jsx(CE,{code:ee(e),language:"typescript",fileName:"auth.ts"})}),a.jsx("div",{className:"flex items-center justify-end p-6 border-t border-white/15 bg-black/50",children:a.jsx(q,{onClick:J,disabled:w,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2",children:w?"Applying...":"Apply to auth config"})})]})}),b&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&g(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-white/15 border-b bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Setup Required"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Install Resend before applying email template"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-8 bg-black",children:a.jsx("div",{className:"space-y-6",children:a.jsxs("div",{children:[a.jsx("h2",{className:"text-md font-mono uppercase font-normal text-white mb-3",children:"Install Resend"}),a.jsx("p",{className:"text-gray-300 mb-4 font-sans leading-relaxed",children:"You need to install the Resend package to send emails. Run the following command in your terminal:"}),a.jsx("div",{className:"bg-black/80 border border-dashed border-white/20 p-2 pl-3 rounded-none font-mono text-sm relative group",children:a.jsxs("div",{className:"flex items-center justify-between gap-4",children:[a.jsxs("code",{className:"text-gray-200",children:[a.jsx("span",{className:"text-white",children:"$"})," ",a.jsx("span",{className:"text-blue-600",children:"pnpm"})," ",a.jsx("span",{className:"text-white",children:"install"})," ",a.jsx("span",{className:"text-white",children:"resend"})]}),a.jsx("button",{onClick:()=>{navigator.clipboard.writeText("pnpm install resend"),S(!0),setTimeout(()=>S(!1),2e3)},className:"flex items-center gap-2 px-2 py-1.5 rounded-none transition-colors text-gray-300 hover:text-white",title:"Copy command",children:N?a.jsx(a.Fragment,{children:a.jsx(qs,{className:"w-4 h-4"})}):a.jsx(a.Fragment,{children:a.jsx(Dc,{className:"w-4 h-4"})})})]})})]})})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/15 bg-black/50",children:[a.jsx(q,{variant:"ghost",onClick:()=>g(!1),className:"text-gray-400 hover:text-white rounded-none font-mono uppercase text-xs px-6 py-2",children:"Cancel"}),a.jsx(q,{onClick:()=>X(e),disabled:w,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2",children:w?"Applying...":"Continue"})]})]})}),E&&e&&a.jsx("div",{className:"fixed inset-0 bg-black/95 flex items-center justify-center z-50 overflow-hidden",onClick:oe=>{oe.target===oe.currentTarget&&j(!1)},children:a.jsxs("div",{className:"bg-black border border-white/15 rounded-none p-0 w-full max-w-2xl max-h-[90vh] overflow-hidden flex flex-col",onClick:oe=>oe.stopPropagation(),children:[a.jsxs("div",{className:"flex items-center justify-between px-6 py-4 border-white/15 border-b bg-black/50",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-xl font-normal uppercase text-white tracking-tight",children:"Test Email"}),a.jsx("p",{className:"text-gray-300 mt-2 uppercase font-mono font-light text-xs",children:"Send a test email with dynamic values"})]})}),a.jsx(q,{variant:"ghost",size:"sm",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none",children:a.jsx(ln,{className:"w-4 h-4"})})]}),a.jsx("div",{className:"flex-1 overflow-auto p-8 bg-black",children:a.jsxs("div",{className:"space-y-6",children:[I==="checking"&&a.jsx("div",{className:"bg-black/90 flex border p-4 rounded-none border-dashed border-white/20",children:a.jsxs("p",{className:"text-white text-sm font-sans flex items-center gap-2 leading-relaxed",children:[a.jsx(ya,{className:"w-4 h-4 animate-spin mr-1"})," Checking for RESEND_API_KEY..."]})}),I==="missing"&&a.jsxs("div",{className:"bg-red-900/20 border border-red-500/30 border-dashed p-4 rounded-none",children:[a.jsx("p",{className:"text-red-200 text-sm font-sans leading-relaxed mb-2",children:a.jsx("strong",{className:"font-normal uppercase font-mono",children:"RESEND_API_KEY not found"})}),a.jsxs("p",{className:"text-red-200 text-sm font-sans leading-relaxed",children:["Please add"," ",a.jsx("code",{className:"bg-black/50 px-1 py-0.5 rounded font-mono text-xs",children:"RESEND_API_KEY"})," ","to your"," ",a.jsx("code",{className:"bg-black/50 px-1 py-0.5 rounded font-mono text-xs",children:".env"})," ","file."]})]}),I==="found"&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"From Email (Verified Sender) *"}),k.length>0?a.jsx("select",{value:R,onChange:oe=>D(oe.target.value),className:"w-full bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs p-2 focus:outline-none focus:border-white/40",children:k.map(oe=>a.jsx("option",{value:oe,children:oe},oe))}):a.jsx(we,{type:"email",value:R,onChange:oe=>D(oe.target.value),placeholder:"noreply@yourdomain.com",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:k.length>0?"Select a verified sender email from your Resend account":"Enter a verified sender email address from your Resend account"})]}),a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"Subject *"}),a.jsx(we,{type:"text",value:H,onChange:oe=>T(oe.target.value),placeholder:"Email subject",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:"Email subject line (supports dynamic placeholders)"})]}),a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-2 block",children:"To Email Address *"}),a.jsx(we,{type:"email",value:_,onChange:oe=>L(oe.target.value),placeholder:"recipient@example.com",className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"}),a.jsx("p",{className:"text-xs text-gray-500 mt-1 font-sans",children:"Any email address to receive the test email"})]}),((Pe=Ca[e])==null?void 0:Pe.fields)&&Ca[e].fields.length>0&&a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-400 mb-3 block",children:"Dynamic Values"}),a.jsx("div",{className:"space-y-3",children:Ca[e].fields.map(oe=>a.jsxs("div",{children:[a.jsx(ce,{className:"text-xs uppercase font-mono text-gray-500 mb-1 block",children:oe}),a.jsx(we,{value:P[oe]||"",onChange:Me=>U({...P,[oe]:Me.target.value}),placeholder:`Enter ${oe}`,className:"bg-black border border-dashed border-white/20 text-white rounded-none font-mono text-xs"})]},oe))})]})]})]})}),a.jsxs("div",{className:"flex items-center justify-end gap-3 p-6 border-t border-white/15 bg-black/50",children:[a.jsx(q,{variant:"ghost",onClick:()=>j(!1),className:"text-gray-400 hover:text-white rounded-none font-mono uppercase text-xs px-6 py-2",children:"Cancel"}),a.jsx(q,{onClick:B,disabled:O||I!=="found"||!_||!R||!H,className:"bg-white text-black hover:bg-white/90 rounded-none font-mono uppercase text-xs px-6 py-2 disabled:opacity-50 disabled:cursor-not-allowed",children:O?"Sending...":"Send Test Email"})]})]})})]})}function _6(e){const t=p.useRef({value:e,previous:e});return p.useMemo(()=>(t.current.value!==e&&(t.current.previous=t.current.value,t.current.value=e),t.current.previous),[e])}var Pm="Checkbox",[$fe]=ii(Pm),[Hfe,kE]=$fe(Pm);function qfe(e){const{__scopeCheckbox:t,checked:n,children:r,defaultChecked:s,disabled:i,form:o,name:l,onCheckedChange:c,required:u,value:h="on",internal_do_not_use_render:d}=e,[f,m]=Kc({prop:n,defaultProp:s??!1,onChange:c,caller:Pm}),[y,v]=p.useState(null),[w,x]=p.useState(null),b=p.useRef(!1),g=y?!!o||!!y.closest("form"):!0,N={checked:f,disabled:i,setChecked:m,control:y,setControl:v,name:l,form:o,value:h,hasConsumerStoppedPropagationRef:b,required:u,defaultChecked:Ji(s)?!1:s,isFormControl:g,bubbleInput:w,setBubbleInput:x};return a.jsx(Hfe,{scope:t,...N,children:Gfe(d)?d(N):r})}var R6="CheckboxTrigger",O6=p.forwardRef(({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},s)=>{const{control:i,value:o,disabled:l,checked:c,required:u,setControl:h,setChecked:d,hasConsumerStoppedPropagationRef:f,isFormControl:m,bubbleInput:y}=kE(R6,e),v=Mn(s,h),w=p.useRef(c);return p.useEffect(()=>{const x=i==null?void 0:i.form;if(x){const b=()=>d(w.current);return x.addEventListener("reset",b),()=>x.removeEventListener("reset",b)}},[i,d]),a.jsx(mn.button,{type:"button",role:"checkbox","aria-checked":Ji(c)?"mixed":c,"aria-required":u,"data-state":U6(c),"data-disabled":l?"":void 0,disabled:l,value:o,...r,ref:v,onKeyDown:Gt(t,x=>{x.key==="Enter"&&x.preventDefault()}),onClick:Gt(n,x=>{d(b=>Ji(b)?!0:!b),y&&m&&(f.current=x.isPropagationStopped(),f.current||x.stopPropagation())})})});O6.displayName=R6;var AE=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,name:r,checked:s,defaultChecked:i,required:o,disabled:l,value:c,onCheckedChange:u,form:h,...d}=e;return a.jsx(qfe,{__scopeCheckbox:n,checked:s,defaultChecked:i,disabled:l,required:o,onCheckedChange:u,name:r,form:h,value:c,internal_do_not_use_render:({isFormControl:f})=>a.jsxs(a.Fragment,{children:[a.jsx(O6,{...d,ref:t,__scopeCheckbox:n}),f&&a.jsx(L6,{__scopeCheckbox:n})]})})});AE.displayName=Pm;var D6="CheckboxIndicator",I6=p.forwardRef((e,t)=>{const{__scopeCheckbox:n,forceMount:r,...s}=e,i=kE(D6,n);return a.jsx(oi,{present:r||Ji(i.checked)||i.checked===!0,children:a.jsx(mn.span,{"data-state":U6(i.checked),"data-disabled":i.disabled?"":void 0,...s,ref:t,style:{pointerEvents:"none",...e.style}})})});I6.displayName=D6;var M6="CheckboxBubbleInput",L6=p.forwardRef(({__scopeCheckbox:e,...t},n)=>{const{control:r,hasConsumerStoppedPropagationRef:s,checked:i,defaultChecked:o,required:l,disabled:c,name:u,value:h,form:d,bubbleInput:f,setBubbleInput:m}=kE(M6,e),y=Mn(n,m),v=_6(i),w=US(r);p.useEffect(()=>{const b=f;if(!b)return;const g=window.HTMLInputElement.prototype,S=Object.getOwnPropertyDescriptor(g,"checked").set,E=!s.current;if(v!==i&&S){const j=new Event("click",{bubbles:E});b.indeterminate=Ji(i),S.call(b,Ji(i)?!1:i),b.dispatchEvent(j)}},[f,v,i,s]);const x=p.useRef(Ji(i)?!1:i);return a.jsx(mn.input,{type:"checkbox","aria-hidden":!0,defaultChecked:o??x.current,required:l,disabled:c,name:u,value:h,form:d,...t,tabIndex:-1,ref:y,style:{...t.style,...w,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})});L6.displayName=M6;function Gfe(e){return typeof e=="function"}function Ji(e){return e==="indeterminate"}function U6(e){return Ji(e)?"indeterminate":e?"checked":"unchecked"}const au=p.forwardRef(({className:e,...t},n)=>a.jsx(AE,{ref:n,className:at("peer h-4 w-4 shrink-0 rounded-sm border border-primary ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground",e),...t,children:a.jsx(I6,{className:at("flex items-center justify-center text-current"),children:a.jsx(wp,{className:"h-4 w-4"})})}));au.displayName=AE.displayName;const Vfe=["user.joined","user.logged_in","user.updated","user.logged_out","user.password_changed","user.email_verified","user.banned","user.unbanned","user.deleted","user.delete_verification_requested","organization.created","organization.deleted","organization.updated","member.added","member.removed","member.role_changed","session.created","password.reset_requested","password.reset_completed","password.reset_requested_otp","password.reset_completed_otp","oauth.linked","oauth.unlinked","oauth.sign_in","team.created","team.updated","team.deleted","team.member.added","team.member.removed","invitation.created","invitation.accepted","invitation.rejected","invitation.cancelled"],Wfe=e=>{if(!e)return"—";const t=typeof e=="string"?new Date(e):e;if(Number.isNaN(t.getTime()))return"—";const n=Dn(t,"MMM").toUpperCase(),r=Dn(t,"dd"),s=String(t.getHours()).padStart(2,"0"),i=String(t.getMinutes()).padStart(2,"0"),o=String(t.getSeconds()).padStart(2,"0"),l=String(t.getMilliseconds()).padStart(2,"0").slice(0,2);return`${n} ${r} ${s}:${i}:${o}.${l}`},mO=(e,t)=>{if(t==="failed")return"text-red-400/70 border-white/15 bg-white/5";switch(e){case"success":return"text-green-400/70 border-white/15 bg-white/5";case"warning":return"text-yellow-400/70 border-white/15 bg-white/5";case"failed":return"text-red-400/70 border-white/15 bg-white/5";default:return"text-blue-400/70 border-white/15 bg-white/5"}},gO=(e,t,n)=>{if(e.includes("organization")||e.includes("member")||e.includes("team")||e.includes("invitation"))return a.jsx(Kn,{className:"w-4 h-4"});if(e.includes("user"))return a.jsx(qt,{className:"w-4 h-4"});if(e.includes("session")||e.includes("login"))return a.jsx(XW,{className:"w-4 h-4"});if(n==="failed"||t==="failed")return a.jsx(BU,{className:"w-4 h-4"});switch(t){case"success":return a.jsx(qs,{className:"w-4 h-4"});case"warning":return a.jsx(UU,{className:"w-4 h-4"});case"failed":return a.jsx(ZN,{className:"w-4 h-4"});default:return a.jsx(ZN,{className:"w-4 h-4"})}};function Yfe(){return window.__STUDIO_CONFIG__||{}}function Xfe(){return!!Yfe().basePath}function Kfe(){var Q,J,X,re,ie,he;const e=Na(),[t,n]=p.useState([]),[r,s]=p.useState(!0),[i,o]=p.useState(""),[l,c]=p.useState("all"),[u,h]=p.useState(!1),[d,f]=p.useState(null),[m,y]=p.useState(!1),[v,w]=p.useState(new Set),x=p.useRef(null),b=p.useRef(!1),g=p.useRef(null),N=2e3,[S,E]=p.useState(!1),[j,_]=p.useState(null),[L,P]=p.useState(!0),[U,O]=p.useState(null),[W,I]=p.useState(null),[z,k]=p.useState([]),C=p.useMemo(()=>{const ee=t.filter(Ee=>{var Pe;const be=Ee.status||"success",Ae=(Pe=Ee.display)==null?void 0:Pe.severity;return be==="failed"||Ae==="failed"}).length,ue=t.filter(Ee=>{var Ae;return((Ae=Ee.display)==null?void 0:Ae.severity)==="warning"}).length,ve=t.filter(Ee=>{var Pe;const be=Ee.status||"success",Ae=(Pe=Ee.display)==null?void 0:Pe.severity;return Ae==="info"||!Ae&&be!=="failed"}).length;return{success:t.filter(Ee=>{var _e;const be=Ee.status||"success",Ae=(_e=Ee.display)==null?void 0:_e.severity;return be==="success"&&!(be==="failed"||Ae==="failed")&&!(Ae==="warning")&&!(Ae==="info"||!Ae&&be!=="failed")}).length,failed:ee,warning:ue,info:ve}},[t]),R=p.useCallback(async(ee=!1)=>{var ue,ve;if(!(b.current&&!ee)){b.current=!0;try{const Ne=new URLSearchParams({limit:"50",sort:"desc"}),Ee=Mu("/api/events"),be=await fetch(`${Ee}?${Ne.toString()}`);if(!be.ok){if(be.status===500)try{const Pe=await be.json();if((ue=Pe.details)!=null&&ue.includes("not found in schema")||(ve=Pe.details)!=null&&ve.includes("Model")){y(!0),ee&&(n([]),s(!1));return}}catch{}throw new Error(`HTTP ${be.status}: ${be.statusText}`)}const Ae=await be.json();if(y(!0),Ae.events&&Array.isArray(Ae.events)){if(Ae.events.length===0&&ee){n([]),s(!1);return}ee?(n(Ae.events),Ae.events.length>0&&(g.current=Ae.events[0].id)):(n(Pe=>{const oe=new Set(Pe.map(_e=>_e.id)),Me=Ae.events.filter(_e=>!oe.has(_e.id));if(Me.length>0){const _e=new Set(Me.map(ct=>ct.id));return w(ct=>{const Je=new Set([...ct,..._e]);return setTimeout(()=>{w(De=>{const $e=new Set(De);return _e.forEach(Ye=>$e.delete(Ye)),$e})},3e3),Je}),[...Me,...Pe].slice(0,100)}return Pe}),Ae.events.length>0&&(g.current=Ae.events[0].id))}}catch(Ne){console.error("Failed to fetch events:",Ne),y(!1)}finally{b.current=!1,s(!1)}}},[]);p.useEffect(()=>{(async()=>{const ue=Xfe();if(E(ue),!ue){_(!1),P(!1);return}try{const Ne=await(await fetch(Mu("/api/events/status"))).json();_((Ne==null?void 0:Ne.enabled)===!0)}catch(ve){console.error("Failed to check events status:",ve),_(!1)}finally{P(!1)}})()},[]),p.useEffect(()=>{u?document.body.style.overflow="hidden":document.body.style.overflow="auto"},[u]),p.useEffect(()=>{if(L)return;if(!j||!S){s(!1);return}return R(!0),(()=>{x.current&&clearInterval(x.current),x.current=setInterval(()=>{R(!1)},N)})(),()=>{x.current&&clearInterval(x.current)}},[j,S,L,R]);const D=ee=>{f(ee),h(!0)},H=ee=>{z.some(ve=>ve.type===ee)||k(ee==="eventType"?ve=>[...ve,{type:ee,eventTypes:[]}]:ve=>[...ve,{type:ee}])},T=ee=>{k(ue=>ue.filter(ve=>ve.type!==ee))},A=(ee,ue)=>{k(ve=>ve.map(Ne=>Ne.type===ee?{...Ne,dateRange:ue}:Ne))},B=(ee,ue)=>{k(ve=>ve.map(Ne=>Ne.type===ee?{...Ne,eventTypes:ue}:Ne))},F=(ee,ue)=>{const ve=z.find(be=>be.type===ee);if(!ve)return;const Ne=ve.eventTypes||[],Ee=Ne.includes(ue)?Ne.filter(be=>be!==ue):[...Ne,ue];B(ee,Ee)},$=t.filter(ee=>{var Ne,Ee,be,Ae,Pe;const ue=ee.type.toLowerCase().includes(i.toLowerCase())||((Ee=(Ne=ee.display)==null?void 0:Ne.message)==null?void 0:Ee.toLowerCase().includes(i.toLowerCase()))||((be=ee.userId)==null?void 0:be.toLowerCase().includes(i.toLowerCase()))||ee.id.toLowerCase().includes(i.toLowerCase()),ve=l==="all"||l==="success"&&ee.status==="success"||l==="failed"&&ee.status==="failed"||l==="info"&&((Ae=ee.display)==null?void 0:Ae.severity)==="info"||l==="warning"&&((Pe=ee.display)==null?void 0:Pe.severity)==="warning";if(z.length>0){const oe=z.every(Me=>{var _e,Re,ct,Je;if(Me.type==="timestamp"){if(!((_e=Me.dateRange)!=null&&_e.from)&&!((Re=Me.dateRange)!=null&&Re.to))return!0;const De=new Date(ee.timestamp);if((ct=Me.dateRange)!=null&&ct.from){const $e=new Date(Me.dateRange.from);if($e.setHours(0,0,0,0),$e>De)return!1}if((Je=Me.dateRange)!=null&&Je.to){const $e=new Date(Me.dateRange.to);if($e.setHours(23,59,59,999),$e<De)return!1}return!0}return Me.type==="eventType"?!Me.eventTypes||Me.eventTypes.length===0?!0:Me.eventTypes.includes(ee.type):!0});return ue&&ve&&oe}return ue&&ve});return L?a.jsx("div",{className:"flex items-center justify-center h-32",children:a.jsxs("div",{className:"flex flex-col items-center space-y-3",children:[a.jsx(ya,{className:"w-6 h-6 text-white animate-spin"}),a.jsx("div",{className:"text-white text-sm",children:"Checking configuration..."})]})}):!S||!j?a.jsxs("div",{className:"space-y-6 p-6",children:[a.jsx("div",{className:"flex items-center justify-between",children:a.jsxs("div",{children:[a.jsx("h1",{className:"text-2xl relative text-white font-light inline-flex items-start",children:"Events"}),a.jsx("p",{className:"text-gray-400 mt-1 uppercase font-mono text-sm font-light",children:"Real-time authentication events and activity"})]})}),a.jsx("div",{className:"bg-black/30 border border-dashed border-white/20 rounded-none p-8",children:a.jsxs("div",{className:"flex flex-col items-center justify-center space-y-6",children:[a.jsx("div",{className:"flex items-center space-x-3",children:a.jsxs("div",{className:"text-left",children:[a.jsx("h2",{className:"text-xl text-white font-mono font-light mb-2",children:"Event Ingestion Not Enabled"}),a.jsx("p",{className:"text-gray-400 text-sm font-mono",children:S?"Please enable event ingestion in your studio configuration to view events.":"Event ingestion is only available in self-hosted mode."})]})}),S&&a.jsxs("div",{className:"w-full max-w-4xl",children:[a.jsx("div",{className:"mb-4",children:a.jsxs("p",{className:"text-gray-300 text-sm font-mono mb-2",children:["Add the following configuration to your"," ",a.jsx("code",{className:"text-yellow-400",children:"studio.config.ts"}),":"]})}),a.jsx(CE,{code:`import { betterAuth } from 'better-auth';
|
|
944
944
|
import { prismaAdapter } from 'better-auth/adapters/prisma';
|
|
945
945
|
import { studio } from '@better-auth/studio';
|
|
946
946
|
import { prisma } from './db';
|
package/public/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" type="image/png" href="/logo.png" />
|
|
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-
|
|
8
|
+
<script type="module" crossorigin src="/assets/main-BeCk6LUx.js"></script>
|
|
9
9
|
<link rel="stylesheet" crossorigin href="/assets/main-w2bJSKlF.css">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|