vendor: 4,642 bytes, line 1
1import{r as l,j as e,aq as w,a4 as ge,q as fs,p as L,l as W,C as M,k as D,b as E,f as B,g as H,t as Ie,X as js,i as gs,B as ie,s as Re,h as oe,I as R,d as vs,S as bs,U as Ns,R as ys}from"./index-B6L1KSTD.js";import{p as Cs}from"./purify.es-A66Cw1IH.js";import{L as y}from"./label-D60HqABX.js";import{D as ce,b as de,c as me,d as xe,e as pe,f as he}from"./dialog-DfLyifF4.js";import{T as ws,a as Es,b as ue,c as fe}from"./tabs-CwHSaeeF.js";import{S as Z}from"./switch-ak_xmdb_.js";import{S as Ss}from"./scroll-area-Bbpp0DU1.js";import{T as ke}from"./textarea-j9KOl17C.js";import{c as Me,P as Q,a as De,u as Fe,e as Ts,b as Ps}from"./index-BZ1Goj1x.js";import{u as ve,a as Oe,c as As}from"./index-BnbJXjCs.js";import{P as Is}from"./index-Bd07huKK.js";import{C as Rs}from"./check-Bt7bXFFE.js";import{A as ks}from"./alert-circle-CKndZp2M.js";import{S as _s}from"./search-CmARInj3.js";import{L as Ms}from"./lock-BvMqRiao.js";import{E as Ds}from"./eye-YFTnOJ1I.js";import{P as Fs}from"./pen-square-D5EMeerR.js";import{R as Os}from"./refresh-cw-u3dpQegk.js";import{I as _e}from"./info-ClOaQ5ND.js";var se="Collapsible",[Ls,Le]=Me(se),[Bs,be]=Ls(se),Be=l.forwardRef((a,r)=>{const{__scopeCollapsible:t,open:n,defaultOpen:o,disabled:i,onOpenChange:x,...h}=a,[f,g]=ve({prop:n,defaultProp:o??!1,onChange:x,caller:se});return e.jsx(Bs,{scope:t,disabled:i,contentId:Oe(),open:f,onOpenToggle:l.useCallback(()=>g(v=>!v),[g]),children:e.jsx(Q.div,{"data-state":ye(f),"data-disabled":i?"":void 0,...h,ref:r})})});Be.displayName=se;var He="CollapsibleTrigger",Ue=l.forwardRef((a,r)=>{const{__scopeCollapsible:t,...n}=a,o=be(He,t);return e.jsx(Q.button,{type:"button","aria-controls":o.contentId,"aria-expanded":o.open||!1,"data-state":ye(o.open),"data-disabled":o.disabled?"":void 0,disabled:o.disabled,...n,ref:r,onClick:De(a.onClick,o.onOpenToggle)})});Ue.displayName=He;var Ne="CollapsibleContent",Ve=l.forwardRef((a,r)=>{const{forceMount:t,...n}=a,o=be(Ne,a.__scopeCollapsible);return e.jsx(Is,{present:t||o.open,children:({present:i})=>e.jsx(Hs,{...n,ref:r,present:i})})});Ve.displayName=Ne;var Hs=l.forwardRef((a,r)=>{const{__scopeCollapsible:t,present:n,children:o,...i}=a,x=be(Ne,t),[h,f]=l.useState(n),g=l.useRef(null),v=Fe(r,g),C=l.useRef(0),k=C.current,P=l.useRef(0),F=P.current,A=x.open||h,N=l.useRef(A),b=l.useRef(void 0);return l.useEffect(()=>{const p=requestAnimationFrame(()=>N.current=!1);return()=>cancelAnimationFrame(p)},[]),Ts(()=>{const p=g.current;if(p){b.current=b.current||{transitionDuration:p.style.transitionDuration,animationName:p.style.animationName},p.style.transitionDuration="0s",p.style.animationName="none";const O=p.getBoundingClientRect();C.current=O.height,P.current=O.width,N.current||(p.style.transitionDuration=b.current.transitionDuration,p.style.animationName=b.current.animationName),f(n)}},[x.open,n]),e.jsx(Q.div,{"data-state":ye(x.open),"data-disabled":x.disabled?"":void 0,id:x.contentId,hidden:!A,...i,ref:v,style:{"--radix-collapsible-content-height":k?`${k}px`:void 0,"--radix-collapsible-content-width":F?`${F}px`:void 0,...a.style},children:A&&o})});function ye(a){return a?"open":"closed"}var Us=Be,Vs=Ue,$s=Ve,T="Accordion",zs=["Home","End","ArrowDown","ArrowUp","ArrowLeft","ArrowRight"],[Ce,Gs,qs]=As(T),[ae]=Me(T,[qs,Le]),we=Le(),$e=w.forwardRef((a,r)=>{const{type:t,...n}=a,o=n,i=n;return e.jsx(Ce.Provider,{scope:a.__scopeAccordion,children:t==="multiple"?e.jsx(Xs,{...i,ref:r}):e.jsx(Ys,{...o,ref:r})})});$e.displayName=T;var[ze,Ks]=ae(T),[Ge,Qs]=ae(T,{collapsible:!1}),Ys=w.forwardRef((a,r)=>{const{value:t,defaultValue:n,onValueChange:o=()=>{},collapsible:i=!1,...x}=a,[h,f]=ve({prop:t,defaultProp:n??"",onChange:o,caller:T});return e.jsx(ze,{scope:a.__scopeAccordion,value:w.useMemo(()=>h?[h]:[],[h]),onItemOpen:f,onItemClose:w.useCallback(()=>i&&f(""),[i,f]),children:e.jsx(Ge,{scope:a.__scopeAccordion,collapsible:i,children:e.jsx(qe,{...x,ref:r})})})}),Xs=w.forwardRef((a,r)=>{const{value:t,defaultValue:n,onValueChange:o=()=>{},...i}=a,[x,h]=ve({prop:t,defaultProp:n??[],onChange:o,caller:T}),f=w.useCallback(v=>h((C=[])=>[...C,v]),[h]),g=w.useCallback(v=>h((C=[])=>C.filter(k=>k!==v)),[h]);return e.jsx(ze,{scope:a.__scopeAccordion,value:x,onItemOpen:f,onItemClose:g,children:e.jsx(Ge,{scope:a.__scopeAccordion,collapsible:!0,children:e.jsx(qe,{...i,ref:r})})})}),[Js,te]=ae(T),qe=w.forwardRef((a,r)=>{const{__scopeAccordion:t,disabled:n,dir:o,orientation:i="vertical",...x}=a,h=w.useRef(null),f=Fe(h,r),g=Gs(t),C=Ps(o)==="ltr",k=De(a.onKeyDown,P=>{var ne;if(!zs.includes(P.key))return;const F=P.target,A=g().filter(V=>{var Y;return!((Y=V.ref.current)!=null&&Y.disabled)}),N=A.findIndex(V=>
1V.ref.current===F),b=A.length;if(N===-1)return;P.preventDefault();let p=N;const O=0,z=b-1,_=()=>{p=N+1,p>z&&(p=O)},G=()=>{p=N-1,p<O&&(p=z)};switch(P.key){case"Home":p=O;break;case"End":p=z;break;case"ArrowRight":i==="horizontal"&&(C?_():G());break;case"ArrowDown":i==="vertical"&&_();break;case"ArrowLeft":i==="horizontal"&&(C?G():_());break;case"ArrowUp":i==="vertical"&&G();break}const U=p%b;(ne=A[U].ref.current)==null||ne.focus()});return e.jsx(Js,{scope:t,disabled:n,direction:o,orientation:i,children:e.jsx(Ce.Slot,{scope:t,children:e.jsx(Q.div,{...x,"data-orientation":i,ref:f,onKeyDown:n?void 0:k})})})}),ee="AccordionItem",[Ws,Ee]=ae(ee),Ke=w.forwardRef((a,r)=>{const{__scopeAccordion:t,value:n,...o}=a,i=te(ee,t),x=Ks(ee,t),h=we(t),f=Oe(),g=n&&x.value.includes(n)||!1,v=i.disabled||a.disabled;return e.jsx(Ws,{scope:t,open:g,disabled:v,triggerId:f,children:e.jsx(Us,{"data-orientation":i.orientation,"data-state":Ze(g),...h,...o,ref:r,disabled:v,open:g,onOpenChange:C=>{C?x.onItemOpen(n):x.onItemClose(n)}})})});Ke.displayName=ee;var Qe="AccordionHeader",Ye=w.forwardRef((a,r)=>{const{__scopeAccordion:t,...n}=a,o=te(T,t),i=Ee(Qe,t);return e.jsx(Q.h3,{"data-orientation":o.orientation,"data-state":Ze(i.open),"data-disabled":i.disabled?"":void 0,...n,ref:r})});Ye.displayName=Qe;var je="AccordionTrigger",Xe=w.forwardRef((a,r)=>{const{__scopeAccordion:t,...n}=a,o=te(T,t),i=Ee(je,t),x=Qs(je,t),h=we(t);return e.jsx(Ce.ItemSlot,{scope:t,children:e.jsx(Vs,{"aria-disabled":i.open&&!x.collapsible||void 0,"data-orientation":o.orientation,id:i.triggerId,...h,...n,ref:r})})});Xe.displayName=je;var Je="AccordionContent",We=w.forwardRef((a,r)=>{const{__scopeAccordion:t,...n}=a,o=te(T,t),i=Ee(Je,t),x=we(t);return e.jsx($s,{role:"region","aria-labelledby":i.triggerId,"data-orientation":o.orientation,...x,...n,ref:r,style:{"--radix-accordion-content-height":"var(--radix-collapsible-content-height)","--radix-accordion-content-width":"var(--radix-collapsible-content-width)",...a.style}})});We.displayName=Je;function Ze(a){return a?"open":"closed"}var Zs=$e,ea=Ke,sa=Ye,es=Xe,ss=We;const aa=Zs,as=l.forwardRef(({className:a,...r},t)=>e.jsx(ea,{ref:t,className:ge("border-b",a),...r}));as.displayName="AccordionItem";const ts=l.forwardRef(({className:a,children:r,...t},n)=>e.jsx(sa,{className:"flex",children:e.jsxs(es,{ref:n,className:ge("flex flex-1 items-center justify-between py-4 font-medium transition-all hover:underline [&[data-state=open]>svg]:rotate-180",a),...t,children:[r,e.jsx(fs,{className:"h-4 w-4 shrink-0 transition-transform duration-200"})]})}));ts.displayName=es.displayName;const ns=l.forwardRef(({className:a,children:r,...t},n)=>e.jsx(ss,{ref:n,className:"overflow-hidden text-sm transition-all data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down",...t,children:e.jsx("div",{className:ge("pb-4 pt-0",a),children:r})}));ns.displayName=ss.displayName;const ta={authentication:Ms,billing:ys,admin:Ns,device:bs,security:vs};function Ca(){const[a,r]=l.useState([]),[t,n]=l.useState({}),[o,i]=l.useState([]),[x,h]=l.useState(null),[f,g]=l.useState(!1),[v,C]=l.useState(""),[k,P]=l.useState(!0),[F,A]=l.useState(null),[N,b]=l.useState(!1),[p,O]=l.useState("templates"),[z,_]=l.useState(!1),[G,U]=l.useState(!1),[ne,V]=l.useState(!1),[Y,X]=l.useState(!1),[j,Se]=l.useState(null),[ls,rs]=l.useState(""),[is,os]=l.useState(""),[S,q]=l.useState({subject:"",htmlBody:"",textBody:"",isEnabled:!0}
1),[u,I]=l.useState({smtpHost:"",smtpPort:587,smtpSecure:!1,smtpUser:"",smtpPassword:"",fromEmail:"",fromName:"",replyToEmail:"",isEnabled:!1}),[K,cs]=l.useState(""),[le,J]=l.useState(null);l.useEffect(()=>{re()},[]);const re=async()=>{try{P(!0),A(null);const[s,c]=await Promise.all([L.getEmailTemplates(),L.getEmailSettings()]);if(r(s.data.templates),n(s.data.grouped),i(s.data.categories),h(c.data.settings),g(c.data.isConfigured),c.data.settings){const d=c.data.settings;I({smtpHost:d.smtpHost||"",smtpPort:d.smtpPort||587,smtpSecure:d.smtpSecure||!1,smtpUser:d.smtpUser||"",smtpPassword:d.smtpPassword||"",fromEmail:d.fromEmail||"",fromName:d.fromName||"",replyToEmail:d.replyToEmail||"",isEnabled:d.isEnabled||!1})}}catch(s){console.error("Failed to fetch email data:",s),A(s instanceof Error?s.message:"Failed to load email settings")}finally{P(!1)}},Te={};for(const[s,c]of Object.entries(t)){const d=c.filter(m=>{var $;return m.displayName.toLowerCase().includes(v.toLowerCase())||(($=m.description)==null?void 0:$.toLowerCase().includes(v.toLowerCase()))});d.length>0&&(Te[s]=d)}const ds=async s=>{try{const c=await L.toggleEmailTemplate(s);r(a.map(m=>m.id===s?{...m,isEnabled:c.data.isEnabled}:m));const d={...t};for(const m of Object.keys(d))d[m]=d[m].map($=>$.id===s?{...$,isEnabled:c.data.isEnabled}:$);n(d)}catch(c){console.error("Failed to toggle template:",c),alert(c instanceof Error?c.message:"Failed to toggle template")}},ms=s=>{Se(s),q({subject:s.subject,htmlBody:s.htmlBody,textBody:s.textBody||"",isEnabled:s.isEnabled}),_(!0)},xs=async()=>{if(j)try{b(!0),await L.updateEmailTemplate(j.id,S);const s={...j,...S};r(a.map(d=>d.id===j.id?s:d));const c={...t};for(const d of Object.keys(c))c[d]=c[d].map(m=>m.id===j.id?s:m);n(c),_(!1)}catch(s){console.error("Failed to update template:",s),alert(s instanceof Error?s.message:"Failed to update template")}finally{b(!1)}},ps=async s=>{try{b(!0);const c=await L.previewEmailTemplate(s.id);os(c.data.subject),rs(c.data.htmlBody),Se(s),U(!0)}catch(c){console.error("Failed to preview template:",c),alert(c instanceof Error?c.message:"Failed to preview template")}finally{b(!1)}},hs=async()=>{try{b(!0);const s=await L.updateEmailSettings(u);h(s.data.settings),g(s.data.isConfigured),V(!1)}catch(s){console.error("Failed to update settings:",s),alert(s instanceof Error?s.message:"Failed to update settings")}finally{b(!1)}},us=async()=>{if(K)try{b(!0),J(null),await L.sendTestEmail(K),J({success:!0,message:`Test email sent to ${K}`})}catch(s){J({success:!1,message:s.message||"Failed to send test email"})}finally{b(!1)}},Pe=a.filter(s=>s.isEnabled).length,Ae=a.length;return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold",children:"Email Notifications"}),e.jsx("p",{className:"text-muted-foreground mt-1",children:"Manage email templates and SMTP settings (Super Admin only)"})]}),k&&e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(W,{className:"h-8 w-8 animate-spin text-muted-foreground"})}),F&&e.jsx(M,{className:"border-destructive",children:e.jsxs(D,{className:"pt-6",children:[e.jsx("p",{className:"text-destructive text-center",children:F}),e.jsx("div",{className:"flex justify-center mt-4",children:e.jsx(E,{onClick:re,children:"Retry"})})]})}),!k&&!F&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid gap-4 md:grid-cols-4",children:[e.jsxs(M,{children:[e.jsxs(B,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(H,{className:"text-sm font-medium",children:"Total Templates"}),e.jsx(Ie,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(D,{children:[e.jsx("div",{className:"text-2xl font-bold",children:Ae}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email templates"})]})]}),e.jsxs(M,{children:[e.jsxs(B,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(H,{className:"text-sm font-medium",children:"Enabled"}),e.jsx(Rs,{className:"h-4 w-4 text-green-500"})]}),e.jsxs(D,{children:[e.jsx("div",{className:"text-2xl font-bold text-green-600",children:Pe}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Active templates"})]})]}),e.jsxs(M,{children:[e.jsxs(B,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(H,{className:"text-sm font-medium",children:"Disabled"}),e.jsx(js,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(D,{children:[e.jsx("div",{className:"text-2xl font-bold",children:Ae-Pe}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Inactive templates"})]})]}),e.jsxs(M,{children:[e.jsxs(B,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(H,{className:"text-sm font-medium",children:"SMTP Status"}),e.jsx(gs,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(D,{children:[e.jsx("div",{className:"text-2xl font-bold",children:e.jsx(ie,{variant:f?"success":"destructive",children:f?"Configured":"Not Configured"})}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email delivery"})]})]})]}),!f&&e.jsx(M,{className:"border-yellow-500 bg-yellow-500/10",children:e.jsx(D,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(ks,{className:"h-5 w-5 text-yellow-500"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-medium",children:"Email delivery not configured"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Configure SMTP settings to enable email notifications."})]}),e.jsx(E,{onClick:()=>V(!0),variant:"outline",children:"Configure SMTP"})]})})}),e.jsxs(ws,{value:p,onValueChange:O,children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(Es,{children:[e.jsx(ue,{value:"templates",children:"Templates"}),e.jsx(ue,{value:"settings",children:"SMTP Settings"}),e.jsx(ue,{value:"syntax",children:"Syntax Reference"})]}),e.jsx("div",{className:"flex gap-2",children:e.jsxs(E,{variant:"outline",onClick:()=>X(!0),disabled:!f,className:"gap-2",children:[e.jsx(Re,{className:"h-4 w-4"}),"Send Test Email"]})})]}),e.jsx(fe,{value:"templates",className:"mt-4",children:e.jsxs(M,{children:[e.jsx(B,{children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("div",{children:[e.jsx(H,{children:"Email Templates"}),e.jsx(oe,{children:"Customize email content and enable/disable notifications"})]})})}),e.jsxs(D,{className:"space-y-4",children:[e.jsxs("div",{className:"relative max-w-sm",children:[e.jsx(_s,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}
1),e.jsx(R,{placeholder:"Search templates...",value:v,onChange:s=>C(s.target.value),className:"pl-9"})]}),e.jsx(aa,{type:"multiple",defaultValue:o.map(s=>s.id),className:"space-y-2",children:o.map(s=>{const c=Te[s.id]||[];if(c.length===0&&v)return null;const d=ta[s.id]||Ie;return e.jsxs(as,{value:s.id,className:"border rounded-lg",children:[e.jsx(ts,{className:"px-4 hover:no-underline",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(d,{className:"h-5 w-5 text-muted-foreground"}),e.jsxs("div",{className:"text-left",children:[e.jsx("span",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-xs text-muted-foreground font-normal",children:s.description})]}),e.jsx(ie,{variant:"secondary",className:"ml-2",children:c.length})]})}),e.jsx(ns,{className:"px-4 pb-4",children:e.jsx("div",{className:"space-y-2",children:c.map(m=>e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-md border bg-card hover:bg-accent/50 transition-colors",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium",children:m.displayName}),e.jsx(ie,{variant:m.isEnabled?"success":"secondary",className:"text-xs",children:m.isEnabled?"Enabled":"Disabled"})]}),e.jsx("p",{className:"text-sm text-muted-foreground truncate",children:m.description}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Subject: ",m.subject]})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-4",children:[e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>ps(m),title:"Preview",children:e.jsx(Ds,{className:"h-4 w-4"})}),e.jsx(E,{variant:"ghost",size:"icon",onClick:()=>ms(m),title:"Edit",children:e.jsx(Fs,{className:"h-4 w-4"})}),e.jsx(Z,{checked:m.isEnabled,onCheckedChange:()=>ds(m.id)})]})]},m.id))})})]},s.id)})})]})]})}),e.jsx(fe,{value:"settings",className:"mt-4",children:e.jsxs(M,{children:[e.jsxs(B,{children:[e.jsx(H,{children:"SMTP Configuration"}),e.jsx(oe,{children:"Configure your email server settings for sending notifications"})]}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-medium",children:"Server Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"smtpHost",children:"SMTP Host"}),e.jsx(R,{id:"smtpHost",value:u.smtpHost,onChange:s=>I({...u,smtpHost:s.target.value}),placeholder:"smtp.example.com"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"smtpPort",children:"Port"}),e.jsx(R,{id:"smtpPort",type:"number",value:u.smtpPort,onChange:s=>I({...u,smtpPort:parseInt(s.target.value)||587})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Secure (TLS)"}),e.jsxs("div",{className:"flex items-center h-10",children:[e.jsx(Z,{checked:u.smtpSecure,onCheckedChange:s=>I({...u,smtpSecure:s})}),e.jsx("span",{className:"ml-2 text-sm text-muted-foreground",children:u.smtpSecure?"Enabled":"Disabled"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"smtpUser",children:"Username"}),e.jsx(R,{id:"smtpUser",value:u.smtpUser,onChange:s=>I({...u,smtpUser:s.target.value}),placeholder:"[email protected]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"smtpPassword",children:"Password"}),e.jsx(R,{id:"smtpPassword",type:"password",value:u.smtpPassword,onChange:s=>I({...u,smtpPassword:s.target.value}),placeholder:"Enter password or app-specific password"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx("h3",{className:"font-medium",children:"Sender Settings"}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"fromEmail",children:"From Email"}),e.jsx(R,{id:"fromEmail",type:"email",value:u.fromEmail,onChange:s=>I({...u,fromEmail:s.target.value}),placeholder:"[email protected]"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"fromName",children:"From Name"}),e.jsx(R,{id:"fromName",value:u.fromName,onChange:s=>I({...u,fromName:s.target.value}),placeholder:"Cheap MDM"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"replyToEmail",children:"Reply-To Email (optional)"}),e.jsx(R,{id:"replyToEmail",type:"email",value:u.replyToEmail,onChange:s=>I({...u,replyToEmail:s.target.value}),placeholder:"[email protected]"})]}),e.jsx("div",{className:"space-y-2 pt-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(y,{children:"Enable Email Sending"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Toggle to enable/disable all email notifications"})]}),e.jsx(Z,{checked:u.isEnabled,onCheckedChange:s=>I({...u,isEnabled:s})})]})})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 pt-4 border-t",children:[e.jsxs(E,{variant:"outline",onClick:re,children:[e.jsx(Os,{className:"h-4 w-4 mr-2"}),"Reset"]}),e.jsxs(E,{onClick:hs,disabled:N,children:[N&&e.jsx(W,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Settings"]})]})]})]})}),e.jsx(fe,{value:"syntax",className:"mt-4",children:e.jsxs(M,{children:[e.jsxs(B,{children:[e.jsx(H,{children:"Template Syntax Reference"}),e.jsx(oe,{children:"Learn how to customize email templates with variables and conditionals"})]}),e.jsxs(D,{className:"space-y-6",children:[e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Variable Syntax"]}),e.jsx("div",{className:"bg-muted p-4 rounded-md font-mono text-sm",children:"{{variableName}}"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Variables are replaced with their actual values when the email is sent. Use double curly braces around the variable name."}
1),e.jsx("h4",{className:"font-medium mt-4",children:"Common Variables"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between p-2 bg-muted rounded",children:[e.jsx("code",{children:"{{userName}}"}),e.jsx("span",{className:"text-muted-foreground",children:"User's display name"})]}),e.jsxs("div",{className:"flex justify-between p-2 bg-muted rounded",children:[e.jsx("code",{children:"{{userEmail}}"}),e.jsx("span",{className:"text-muted-foreground",children:"User's email address"})]}),e.jsxs("div",{className:"flex justify-between p-2 bg-muted rounded",children:[e.jsx("code",{children:"{{organizationName}}"}),e.jsx("span",{className:"text-muted-foreground",children:"Tenant/Organization name"})]}),e.jsxs("div",{className:"flex justify-between p-2 bg-muted rounded",children:[e.jsx("code",{children:"{{appName}}"}),e.jsx("span",{className:"text-muted-foreground",children:"Application name (Cheap MDM)"})]}),e.jsxs("div",{className:"flex justify-between p-2 bg-muted rounded",children:[e.jsx("code",{children:"{{loginUrl}}"}),e.jsx("span",{className:"text-muted-foreground",children:"Login page URL"})]}),e.jsxs("div",{className:"flex justify-between p-2 bg-muted rounded",children:[e.jsx("code",{children:"{{dashboardUrl}}"}),e.jsx("span",{className:"text-muted-foreground",children:"Dashboard URL"})]})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("h3",{className:"font-medium flex items-center gap-2",children:[e.jsx(_e,{className:"h-4 w-4"}),"Conditional Syntax"]}),e.jsx("div",{className:"bg-muted p-4 rounded-md font-mono text-sm whitespace-pre",children:`{{#if variableName}} 2 Content shown if variable exists 3{{/if}}`}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Conditionals allow you to show content only when a variable has a value. The content between the tags is only included if the variable is truthy."}),e.jsx("h4",{className:"font-medium mt-4",children:"Example Usage"}),e.jsx("div",{className:"bg-muted p-4 rounded-md font-mono text-sm whitespace-pre",children:`Hello {{userName}}, 4 5{{#if organizationName}} 6You've been added to {{organizationName}}. 7{{/if}} 8 9Best regards, 10{{appName}}`})]})]}),e.jsxs("div",{className:"border-t pt-6",children:[e.jsx("h3",{className:"font-medium mb-4",children:"Template-Specific Variables"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:'Each template has its own set of available variables. Click "Edit" on any template to see its specific variables and examples.'})]})]})]})})]}),e.jsx(ce,{open:z,onOpenChange:_,children:e.jsxs(de,{className:"max-w-4xl max-h-[90vh]",onClose:()=>_(!1),children:[e.jsxs(me,{children:[e.jsxs(xe,{children:["Edit Template: ",j==null?void 0:j.displayName]}),e.jsx(pe,{children:j==null?void 0:j.description})]}),e.jsxs("div",{className:"grid gap-6 md:grid-cols-2",children:[e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"subject",children:"Subject Line"}),e.jsx(R,{id:"subject",value:S.subject,onChange:s=>q({...S,subject:s.target.value})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"htmlBody",children:"HTML Body"}),e.jsx(ke,{id:"htmlBody",value:S.htmlBody,onChange:s=>q({...S,htmlBody:s.target.value}),rows:12,className:"font-mono text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"textBody",children:"Plain Text Body (optional)"}),e.jsx(ke,{id:"textBody",value:S.textBody,onChange:s=>q({...S,textBody:s.target.value}),rows:6,className:"font-mono text-sm",placeholder:"Plain text version for email clients that don't support HTML"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(y,{className:"mb-2 block",children:"Available Variables"}),e.jsx(Ss,{className:"h-[200px] border rounded-md p-3",children:e.jsx("div",{className:"space-y-2",children:j==null?void 0:j.variables.map(s=>e.jsxs("div",{className:"text-sm",children:[e.jsx("code",{className:"bg-muted px-1 rounded",children:`{{${s.name}}}`}),e.jsx("p",{className:"text-muted-foreground text-xs mt-0.5",children:s.description}),e.jsxs("p",{className:"text-xs text-blue-500",children:["Example: ",s.example]})]},s.name))})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{children:"Template Status"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Z,{checked:S.isEnabled,onCheckedChange:s=>q({...S,isEnabled:s})}),e.jsx("span",{className:"text-sm",children:S.isEnabled?"Enabled":"Disabled"})]})]})]})]}),e.jsxs(he,{children:[e.jsx(E,{variant:"outline",onClick:()=>_(!1),disabled:N,children:"Cancel"}),e.jsxs(E,{onClick:xs,disabled:N,children:[N&&e.jsx(W,{className:"mr-2 h-4 w-4 animate-spin"}),"Save Changes"]})]})]})}),e.jsx(ce,{open:G,onOpenChange:U,children:e.jsxs(de,{className:"max-w-3xl max-h-[90vh]",onClose:()=>U(!1),children:[e.jsxs(me,{children:[e.jsxs(xe,{children:["Preview: ",j==null?void 0:j.displayName]}),e.jsxs(pe,{children:["Subject: ",is]})]}),e.jsx("div",{className:"border rounded-md bg-white text-black p-4 max-h-[60vh] overflow-auto",children:e.jsx("div",{dangerouslySetInnerHTML:{__html:Cs.sanitize(ls
10)}})}),e.jsx(he,{children:e.jsx(E,{onClick:()=>U(!1),children:"Close"})})]})}),e.jsx(ce,{open:Y,onOpenChange:X,children:e.jsxs(de,{onClose:()=>X(!1),children:[e.jsxs(me,{children:[e.jsx(xe,{children:"Send Test Email"}),e.jsx(pe,{children:"Send a test email to verify your SMTP configuration is working"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(y,{htmlFor:"testEmail",children:"Email Address"}),e.jsx(R,{id:"testEmail",type:"email",value:K,onChange:s=>cs(s.target.value),placeholder:"[email protected]"})]}),le&&e.jsx("div",{className:`p-3 rounded-md ${le.success?"bg-green-500/10 text-green-500":"bg-red-500/10 text-red-500"}`,children:le.message})]}),e.jsxs(he,{children:[e.jsx(E,{variant:"outline",onClick:()=>{X(!1),J(null)},children:"Cancel"}),e.jsxs(E,{onClick:us,disabled:!K||N,children:[N&&e.jsx(W,{className:"mr-2 h-4 w-4 animate-spin"}),e.jsx(Re,{className:"mr-2 h-4 w-4"}),"Send Test"]})]})]})})]})]})}export{Ca as EmailNotificationsPage};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.