1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[8051],{23532:(e,t,r)=>{r.d(t,{A:()=>i});var n=r(95155);let a=[{id:"event_announcement",name:"Event Announcement",description:"New event with hero image, details, and CTA",icon:"\uD83C\uDF89",color:"rgb(var(--color-brand))"},{id:"event_reminder",name:"Event Reminder",description:"Countdown urgency with logistics",icon:"â°",color:"rgb(var(--color-yellow))"},{id:"post_event_followup",name:"Post-Event Follow-up",description:"Thank attendees and tease next event",icon:"\uD83D\uDE4C",color:"rgb(var(--color-green))"},{id:"newsletter",name:"Newsletter",description:"Multi-section updates and news",icon:"\uD83D\uDCF0",color:"rgb(var(--color-blue))"},{id:"re_engagement",name:"Re-engagement",description:"Win back inactive users",icon:"\uD83D\uDC9C",color:"#EC4899"},{id:"minimal",name:"Minimal",description:"Clean text-focused layout",icon:"âï¸",color:"rgb(var(--text-tertiary))"}];function i(e){let{selectedTemplate:t,onSelect:r}=e;return(0,n.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:8},children:a.map(e=>{let a=t===e.id;return(0,n.jsxs)("button",{onClick:()=>r(e.id),style:{padding:12,borderRadius:8,border:"2px solid ".concat(a?e.color:"var(--border-default)"),backgroundColor:a?"color-mix(in srgb, ".concat(e.color," 8%, transparent)"):"rgb(var(--surface-raised))",cursor:"pointer",textAlign:"left",transition:"all 0.15s ease"},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:4},children:[(0,n.jsx)("span",{style:{fontSize:16},children:e.icon}),(0,n.jsx)("span",{style:{fontSize:12,fontWeight:700,color:a?e.color:"rgb(var(--text-primary))"},children:e.name})]}),(0,n.jsx)("p",{style:{margin:0,fontSize:11,color:"rgb(var(--text-secondary))",lineHeight:"14px"},children:e.description})]},e.id)})})}},38051:(e,t,r)=>{r.r(t),r.d(t,{default:()=>T});var n=r(95155),a=r(12115),i=r(14585),o=r(29213),l=r(76849),s=r(39390),d=r(37401);let c=(0,l.httpsCallable)(i.functions,"previewNetworkSegment"),u=e=>({padding:"6px 14px",fontSize:12,borderRadius:999,cursor:"pointer",border:e?"1px solid #fff":"1px solid rgba(255,255,255,0.1)",backgroundColor:e?"#fff":"rgba(255,255,255,0.04)",color:e?"rgb(var(--surface-base))":"rgba(255,255,255,0.65)",transition:"all .15s"});function p(e){let{value:t,onChange:r,onPreview:o}=e,{user:l}=(0,d.Y)(),[p,g]=(0,a.useState)([]),[m,x]=(0,a.useState)(null),[v,b]=(0,a.useState)([]),[y,h]=(0,a.useState)([]),[f,j]=(0,a.useState)(!1),[S,k]=(0,a.useState)(null),[w,C]=(0,a.useState)(!1),z=(0,a.useRef)(0);(0,a.useEffect)(()=>{if(!l)return;let e=(0,s.onSnapshot)((0,s.query)((0,s.collection)(i.db,"users/".concat(l.uid,"/network_segments")),(0,s.orderBy)("updatedAt","desc")),e=>g(e.docs.map(e=>({id:e.id,...e.data()}))),()=>g([]));return(0,s.getDocs)((0,s.query)((0,s.collection)(i.db,"users/".concat(l.uid,"/distribution_lists")),(0,s.orderBy)("createdAt","desc"))).then(e=>b(e.docs.filter(e=>!e.data().deletedAt).map(e=>{var t;return{id:e.id,name:null!=(t=e.data().name)?t:e.id}}))).catch(()=>b([])),(0,s.getDocs)((0,s.query)((0,s.collection)(i.db,"users/".concat(l.uid,"/network_events")),(0,s.orderBy)("createdAt","desc"))).then(e=>h(e.docs.map(e=>{var t;return{id:e.id,name:null!=(t=e.data().name)?t:e.id}}))).catch(()=>h([])),e},[l]),(0,a.useEffect)(()=>{let e=++z.current;C(!0),o(S,!0);let r=setTimeout(async()=>{try{let r=await c({filters:t});z.current===e&&(k(r.data),o(r.data,!1))}catch(t){z.current===e&&(k(null),o(null,!1))}finally{z.current===e&&C(!1)}},450);return()=>clearTimeout(r)},[JSON.stringify(t),null==l?void 0:l.uid]);let I=null===m&&null===t.listIds&&!t.sources&&!t.eventIds&&!t.consentBasis&&!t.tags;return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:8},children:[(0,n.jsx)("button",{type:"button",onClick:()=>{x(null),j(!1),r({listIds:null})},style:u(I),children:"All my contacts"}),p.map(e=>(0,n.jsx)("button",{type:"button",onClick:()=>{var t;x(e.id),j(!1),r({...e.filters,listIds:null!=(t=e.filters.listIds)?t:null})},style:u(m===e.id),children:e.name},e.id)),(0,n.jsx)("button",{type:"button",onClick:()=>j(e=>!e),style:u(f||null!==t.listIds&&null===m),children:"Pick lists"}),y.map(e=>{var a;let i="nev:".concat(e.id),o=(null!=(a=t.tags)?a:[]).includes(i);return(0,n.jsxs)("button",{type:"button",onClick:()=>{x(null),r(o?{listIds:null}:{listIds:null,tags:[i]})},style:u(o),children:["Attended: ",e.name]},e.id)})]}),f&&(0,n.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:8},children:0===v.length?(0,n.jsx)("p",{style:{fontSize:11,color:"rgba(255,255,255,0.35)",margin:0},children:"No lists yet."}):v.map(e=>{var a;return(0,n.jsx)("button",{type:"button",onClick:()=>(e=>{var n;x(null);let a=null!=(n=t.listIds)?n:[],i=a.includes(e)?a.filter(t=>t!==e):[...a,e];r({listIds:0===i.length?null:i})})(e.id),style:u((null!=(a=t.listIds)?a:[]).includes(e.id)),children:e.name},e.id)})}),(0,n.jsx)("p",{style:{margin:"10px 0 0",fontSize:12,color:"rgba(255,255,255,0.45)"},children:w&&!S?"Countingâ¦":S?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("span",{style:{color:"rgba(255,255,255,0.85)",fontWeight:600}
1,children:[S.sendable.toLocaleString()," people"]})," ","will receive this",S.suppressed>0&&" \xb7 ".concat(S.suppressed.toLocaleString()," unsubscribed are skipped"),0===S.sendable&&" â nothing matches yet",S.missingListIds.length>0&&" \xb7 ".concat(S.missingListIds.length," referenced list(s) no longer exist")]}):"Count unavailable"})]})}let g=(0,l.httpsCallable)(i.functions,"getPromotableEvents"),m=e=>e?new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"}):"",x=e=>"%"===e.discountType?"".concat(e.discountValue,"% off"):"$".concat(e.discountValue," off"),v=e=>e.commissionValue?"%"===e.commissionType?"you earn ".concat(e.commissionValue,"%"):"you earn $".concat(e.commissionValue):null;function b(e){let{selected:t,code:r,onSelect:i,onCode:o,onClear:l}=e,[s,d]=(0,a.useState)(!1),[c,u]=(0,a.useState)(null),[p,b]=(0,a.useState)([]);if((0,a.useEffect)(()=>{s&&null===c&&g({}).then(e=>u(e.data.events)).catch(()=>u([]))},[s,c]),t){let e=p.find(e=>e.code===r);return(0,n.jsxs)("div",{style:{backgroundColor:"rgb(var(--surface-raised))",borderRadius:8,border:"1px solid var(--border-default)",padding:12},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:8},children:[(0,n.jsxs)("div",{style:{minWidth:0},children:[(0,n.jsxs)("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"rgb(var(--text-primary))"},children:[t.name,(0,n.jsx)("span",{style:{marginLeft:8,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.05em",padding:"2px 8px",borderRadius:999,backgroundColor:"rgba(255,255,255,0.08)",color:"rgba(255,255,255,0.6)"},children:"host"===t.role?"Your event":"Affiliate"})]}),(0,n.jsxs)("p",{style:{margin:"3px 0 0",fontSize:11,color:"rgba(255,255,255,0.4)"},children:[m(t.dateMs),e&&" \xb7 ".concat(e.code," â ").concat(x(e)),e&&v(e)&&" \xb7 ".concat(v(e))]})]}),(0,n.jsx)("button",{onClick:l,title:"Remove",style:{background:"none",border:"none",color:"rgba(255,255,255,0.35)",cursor:"pointer",fontSize:14,lineHeight:1,padding:4},children:"â"})]}),p.length>0&&(0,n.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6,marginTop:10},children:p.map(e=>{let t=e.code===r;return(0,n.jsxs)("button",{onClick:()=>o(t?null:e.code),style:{padding:"4px 10px",fontSize:11,borderRadius:999,cursor:"pointer",border:t?"1px solid #fff":"1px solid rgba(255,255,255,0.12)",backgroundColor:t?"#fff":"rgba(255,255,255,0.04)",color:t?"rgb(var(--surface-base))":"rgba(255,255,255,0.6)"},children:[e.code," \xb7 ",x(e),v(e)?" \xb7 ".concat(v(e)):""]},e.code)})}),(0,n.jsxs)("p",{style:{margin:"10px 0 0",fontSize:11,color:"rgba(255,255,255,0.35)"},children:["The email's button links to this event",r?" with your code attached â clicks and sales are attributed automatically":"","."]})]})}return s?(0,n.jsxs)("div",{style:{backgroundColor:"rgb(var(--surface-raised))",borderRadius:8,border:"1px solid var(--border-default)",padding:12},children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[(0,n.jsx)("p",{style:{margin:0,fontSize:12,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"Promote an event"}),(0,n.jsx)("button",{onClick:()=>d(!1),style:{background:"none",border:"none",color:"rgba(255,255,255,0.35)",cursor:"pointer",fontSize:12},children:"Cancel"})]}),null===c?(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"rgba(255,255,255,0.4)"},children:"Loading your eventsâ¦"}):0===c.length?(0,n.jsx)("p",{style:{margin:0,fontSize:12,color:"rgba(255,255,255,0.4)"},children:"No upcoming events to promote yet â create an event, or accept an affiliate invite, and it appears here."}):(0,n.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:2,maxHeight:220,overflowY:"auto"},children:c.map(e=>{let t=e.codes.map(v).find(Boolean);return(0,n.jsxs)("button",{onClick:()=>{b(e.codes),i(e),o("affiliate"===e.role&&e.codes.length>0?e.codes[0].code:null),d(!1)},style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:8,width:"100%",textAlign:"left",background:"none",border:"none",borderRadius:6,padding:"8px 8px",cursor:"pointer"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="rgba(255,255,255,0.04)"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="transparent"},children:[(0,n.jsxs)("span",{style:{minWidth:0,fontSize:13,color:"rgb(var(--text-primary))",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[e.eventName,(0,n.jsx)("span",{style:{marginLeft:8,fontSize:11,color:"rgba(255,255,255,0.35)"},children:m(e.eventDateMs)})]}),(0,n.jsx)("span",{style:{flexShrink:0,fontSize:11,color:"affiliate"===e.role?"var(--state-positive-fg)":"rgba(255,255,255,0.4)"},children:"host"===e.role?"Your event":null!=t?t:"Affiliate"})]},e.eventId)})})]}):(0,n.jsx)("button",{onClick:()=>d(!0),style:{background:"none",border:"none",padding:0,fontSize:12,color:"rgba(255,255,255,0.45)",cursor:"pointer"},children:"+ Promote an event â yours, or one you're an affiliate for"})}var y=r(12180),h=r(42143),f=r(23532);function j(e){let{stats:t}=e;if(0===t.sent&&0===t.delivered&&0===t.failed)return(0,n.jsx)("div",{style:{padding:24,textAlign:"center",backgroundColor:"rgb(var(--surface-raised))",borderRadius:8},children:(0,n.jsx)("p",{style:{margin:0,fontSize:14,color:"rgb(var(--text-secondary))"},children:"Delivery in progress... Stats will appear once emails are delivered."})});let r=t.sent>0?t.uniqueOpens/t.sent*100:0,a=t.sent>0?t.uniqueClicks/t.sent*100:0,i=t.sent>0?t.bounced/t.sent*100:0,o=t.audienceSize>
10?t.delivered/t.audienceSize*100:0,l=t.audienceSize>0?t.failed/t.audienceSize*100:0,s=t.audienceSize>0?t.bounced/t.audienceSize*100:0,d=Math.max(0,100-o-l-s);return(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(130px, 1fr))",gap:8,marginBottom:16},children:[(0,n.jsx)(S,{label:"Sent",value:t.sent.toString()}),(0,n.jsx)(S,{label:"Open Rate",value:"".concat(r.toFixed(1),"%"),accent:r>20}),(0,n.jsx)(S,{label:"Click Rate",value:"".concat(a.toFixed(1),"%"),accent:a>5}),(0,n.jsx)(S,{label:"Bounce Rate",value:"".concat(i.toFixed(1),"%"),warning:i>5})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:6},children:[(0,n.jsx)("span",{style:{fontSize:12,color:"rgb(var(--text-secondary))"},children:"Delivery breakdown"}),(0,n.jsxs)("span",{style:{fontSize:12,color:"rgb(var(--text-secondary))"},children:[t.delivered," delivered / ",t.audienceSize," total"]})]}),(0,n.jsxs)("div",{style:{height:8,borderRadius:4,backgroundColor:"var(--progress-track-bg)",overflow:"hidden",display:"flex"},children:[(0,n.jsx)("div",{style:{width:"".concat(o,"%"),backgroundColor:"rgb(var(--color-green))",transition:"width 0.3s ease"}}),(0,n.jsx)("div",{style:{width:"".concat(s,"%"),backgroundColor:"rgb(var(--color-yellow))",transition:"width 0.3s ease"}}),(0,n.jsx)("div",{style:{width:"".concat(l,"%"),backgroundColor:"rgb(var(--color-red))",transition:"width 0.3s ease"}}),(0,n.jsx)("div",{style:{width:"".concat(d,"%"),backgroundColor:"var(--progress-track-bg)"}})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:16,marginTop:6},children:[(0,n.jsx)(k,{color:"rgb(var(--color-green))",label:"Delivered",count:t.delivered}),(0,n.jsx)(k,{color:"rgb(var(--color-yellow))",label:"Bounced",count:t.bounced}),(0,n.jsx)(k,{color:"rgb(var(--color-red))",label:"Failed",count:t.failed}),t.complained>0&&(0,n.jsx)(k,{color:"#DC2626",label:"Complained",count:t.complained}),t.unsubscribed>0&&(0,n.jsx)(k,{color:"rgb(var(--text-tertiary))",label:"Unsubscribed",count:t.unsubscribed})]})]}),(t.opened>0||t.clicked>0)&&(0,n.jsxs)("div",{style:{marginTop:16,padding:12,backgroundColor:"rgb(var(--surface-raised))",borderRadius:8,display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{style:{margin:0,fontSize:11,color:"rgb(var(--text-secondary))",textTransform:"uppercase",letterSpacing:.5},children:"Opens"}),(0,n.jsxs)("p",{style:{margin:"4px 0 0",fontSize:16,fontWeight:700,color:"rgb(var(--text-primary))"},children:[t.uniqueOpens," unique / ",t.opened," total"]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{style:{margin:0,fontSize:11,color:"rgb(var(--text-secondary))",textTransform:"uppercase",letterSpacing:.5},children:"Clicks"}),(0,n.jsxs)("p",{style:{margin:"4px 0 0",fontSize:16,fontWeight:700,color:"rgb(var(--text-primary))"},children:[t.uniqueClicks," unique / ",t.clicked," total"]})]})]})]})}function S(e){let{label:t,value:r,accent:a,warning:i}=e,o="rgb(var(--text-primary))";return a&&(o="var(--state-positive-fg)"),i&&(o="var(--state-attention-fg)"),(0,n.jsxs)("div",{style:{backgroundColor:"rgb(var(--surface-raised))",borderRadius:8,padding:"12px 8px",textAlign:"center"},children:[(0,n.jsx)("p",{style:{margin:0,fontSize:11,color:"rgb(var(--text-secondary))",textTransform:"uppercase",letterSpacing:.5},children:t}),(0,n.jsx)("p",{style:{margin:"4px 0 0",fontSize:20,fontWeight:700,color:o},children:r})]})}function k(e){let{color:t,label:r,count:a}=e;return(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:4},children:[(0,n.jsx)("div",{style:{width:8,height:8,borderRadius:"50%",backgroundColor:t}}),(0,n.jsxs)("span",{style:{fontSize:11,color:"rgb(var(--text-secondary))"},children:[r,": ",a]})]})}var w=r(82146),C=r(12711),z=r(14115);let I=["Announce our upcoming event â create excitement and include event details","Send a reminder email 1 day before the event with logistics and CTA","Thank attendees for coming to our last event and tease what's next","Re-engage people who haven't attended recently, highlight upcoming events","Monthly newsletter with updates, upcoming events, and community highlights"];function T(e){var t,r,c,u;let{campaignId:g,duplicateFromId:m,viewMode:x="build",viewCampaignId:v,mode:S="event",onClose:k}=e,{user:T,userProfile:R,notify:W}=(0,d.Y)(),[A,N]=(0,a.useState)(g?"edit":"prompt"),[E,B]=(0,a.useState)(""),[L,_]=(0,a.useState)(!1),[M,P]=(0,a.useState)(""),[U,F]=(0,a.useState)(""),[O,q]=(0,a.useState)(""),[V,Y]=(0,a.useState)(""),[$,H]=(0,a.useState)("minimal"),[G,
1K]=(0,a.useState)(""),[J,Z]=(0,a.useState)(""),Q=[null==R?void 0:R.firstName,null==R?void 0:R.lastName].filter(Boolean).join(" ")||(null==T?void 0:T.displayName)||"",X=Q||"SocialLoop",ee="[email protected]",et="[email protected]",er="network"===S,en=er?"network_segment":"event_participants",[ea,ei]=(0,a.useState)({listIds:null}),[eo,el]=(0,a.useState)(null),[es,ed]=(0,a.useState)(!1),[ec,eu]=(0,a.useState)(null),[ep,eg]=(0,a.useState)(null),[em,ex]=(0,a.useState)(null),[ev,eb]=(0,a.useState)([]),[ey,eh]=(0,a.useState)({type:"user"}),[ef,ej]=(0,a.useState)({}),[eS,ek]=(0,a.useState)("now"),[ew,eC]=(0,a.useState)(""),[ez,eI]=(0,a.useState)(""),eT=(0,w._)(),eD=er?null:eT.eventId,eR=er?null:eT.eventData;(0,a.useEffect)(()=>{if(er&&(null==T?void 0:T.uid))return(0,s.onSnapshot)((0,s.query)((0,s.collection)(i.db,"users/".concat(T.uid,"/emailDomains"))),e=>eu(e.docs.some(e=>"verified"===e.data().status)),()=>eu(!1))},[er,null==T?void 0:T.uid]);let[eW,eA]=(0,a.useState)(0),[eN,eE]=(0,a.useState)(0);(0,a.useEffect)(()=>{if(!eD){eA(0),eE(0);return}fetch("/api/email-audience-count?eventId=".concat(eD)).then(e=>e.ok?e.json():null).then(e=>{e&&(eA(e.withEmail),eE(e.total))}).catch(()=>{eA(0),eE(0)})},[eD]),(0,a.useEffect)(()=>{let e=(null==eR?void 0:eR.communityIds)&&Array.isArray(eR.communityIds)?eR.communityIds:(null==eR?void 0:eR.organizerCollectiveId)?[eR.organizerCollectiveId]:[];if(0===e.length)return void eb([]);Promise.all(e.map(e=>(0,s.getDoc)((0,s.doc)(i.db,"collectives",e)))).then(e=>{eb(e.filter(e=>e.exists()).map(e=>{var t,r;return{id:e.id,name:(null==(t=e.data())?void 0:t.name)||"",iconURL:null==(r=e.data())?void 0:r.iconURL}}))}).catch(()=>{eb([])})},[null==eR?void 0:eR.communityIds,null==eR?void 0:eR.organizerCollectiveId]);let[eB,eL]=(0,a.useState)(!1),[e_,eM]=(0,a.useState)(!1),[eP,eU]=(0,a.useState)(!1),[eF,eO]=(0,a.useState)(""),[eq,eV]=(0,a.useState)(!1),eY=(0,a.useRef)(!1),e$=(0,a.useRef)(null),[eH,eG]=(0,a.useState)(null);(0,a.useEffect)(()=>{if(!eD)return void Z("");K(e=>e||"View Event"),fetch("/api/short-links",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({eventId:eD,utm_source:"email",utm_medium:"email_campaign",utm_campaign:"email_blast_".concat(eD),targetType:"loops"})}).then(e=>e.ok?e.json():null).then(e=>{(null==e?void 0:e.shortUrl)&&Z(e.shortUrl)}).catch(()=>Z("https://socialloop.ai/loops/".concat(eD)))}
1,[eD]),(0,a.useEffect)(()=>{let e=v||g||m;e&&(eL(!0),(async()=>{try{let n=await (0,s.getDoc)((0,s.doc)(i.db,"email_campaigns",e));if(!n.exists()){W({message:"Email campaign not found",type:"error"}),k();return}let a=(0,z.Y8)(n);if(!a){W({message:"Email campaign not found",type:"error"}),k();return}if(v)eG(a);else{var t,r;P(m?"".concat(a.name," (Copy)"):a.name),F(a.subject),q(a.preheaderText),Y(a.body),H(a.templateId),K(a.ctaText||"View Event"),Z(a.eventId?"https://socialloop.ai/loops/".concat(a.eventId):a.ctaUrl||"");let e=n.data();if(er&&(null==e?void 0:e.networkFilters)&&ei(e.networkFilters),er&&(null==e?void 0:e.eventId)&&(eg({id:e.eventId,name:e.eventName||"Promoted event",dateMs:null,role:"host"}),ex(null!=(r=e.attachedPromoCode)?r:null)),a.segmentFilters&&ej(a.segmentFilters),(null==(t=a.sendAs)?void 0:t.type)==="community"?eh({type:"community",communityId:a.sendAs.communityId}):eh({type:"user"}),a.scheduledAt&&!m){ek("later");let e=a.scheduledAt;eC(e.toISOString().split("T")[0]),eI(e.toTimeString().slice(0,5))}N("edit")}}catch(e){W({message:"Failed to load campaign: ".concat(e.message),type:"error"})}finally{eL(!1)}})())},[g,m,v]);let eK=async()=>{if(E.trim()){_(!0);try{var e,t;let r=(0,l.httpsCallable)(i.functions,"generateEmailFromPrompt"),{campaign:n}=(await r({prompt:er?ep?"".concat(E.trim(),'\n\n(This email promotes the event "').concat(ep.name,'" to my contact network').concat(em?" and includes the promo code ".concat(em," â mention it"):"",".)"):"".concat(E.trim(),"\n\n(This is a note to my own contact network â no event is linked. Do not use event placeholders like {{eventName}} or {{eventDate}}.)"):E.trim(),eventContext:er&&ep?{name:ep.name,date:ep.dateMs?new Date(ep.dateMs).toISOString():void 0}:eR?{name:eR.eventName,date:null==(e=eR.eventDate)?void 0:e.toISOString(),endDate:null==(t=eR.eventEndDate)?void 0:t.toISOString(),description:eR.eventDescription,venueName:eR.locationAddress,city:null,participantCount:eR.attendeeCount}:void 0})).data;P(n.name||""),F(n.subject||""),q(n.preheaderText||""),Y(n.body||""),H(n.templateId||"minimal"),K(n.ctaText||"View Event"),Z(eD?"https://socialloop.ai/loops/".concat(eD):n.ctaUrl||""),N("edit"),eY.current=!0}catch(e){W({message:"Generation failed: ".concat(e.message),type:"error"})}finally{_(!1)}}},eJ=async()=>{if(!e_&&(null==T?void 0:T.uid)&&M.trim()){eM(!0);try{var e,t,r;let n={name:M.trim(),subject:U.trim(),preheaderText:O.trim(),body:V.trim(),templateId:$,ctaText:G.trim(),ctaUrl:J.trim(),fromName:X.trim(),fromEmail:ee.trim(),replyTo:et.trim(),useAiPersonalization:!1,aiContext:"".trim(),audienceType:en,distributionListId:null,segmentFilters:ef||null,networkFilters:er?ea:null,sendAs:"community"===ey.type?{type:"community",communityId:ey.communityId}:null,eventId:er?null!=(e=null==ep?void 0:ep.id)?e:null:eD||null,eventName:er?null!=(t=null==ep?void 0:ep.name)?t:null:(null==eR?void 0:eR.eventName)||null,eventDate:er?(null==ep?void 0:ep.dateMs)?new Date(ep.dateMs).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}):null:(null==eR?void 0:eR.eventDate)?eR.eventDate.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}):null,eventVenue:(null==eR?void 0:eR.locationAddress)||null,attachedPromoCode:er?em:null,hostName:Q||"Your host",estimatedAudienceSize:er?null!=(r=null==eo?void 0:eo.sendable)?r:null:null!=eW?eW:null,status:"later"===eS&&ew&&ez?"scheduled":"draft",scheduledAt:"later"===eS&&ew&&ez?s.Timestamp.fromDate(new Date("".concat(ew,"T").concat(ez))):null,producerUserId:T.uid,createdBy:T.uid,updatedAt:(0,s.serverTimestamp)(),stats:z.Wh};if(g&&!m)await (0,s.updateDoc)((0,s.doc)(i.db,"email_campaigns",g),n),W({message:"Email campaign updated",type:"success"});else{let e=(0,s.doc)(i.db,"email_campaigns",(0,o.k)());await (0,s.setDoc)(e,{...n,createdAt:(0,s.serverTimestamp)()}),W({message:"Email campaign saved as draft",type:"success"})}eY.current=!1,k()}catch(e){W({message:"Save failed: ".concat(e.message),type:"error"})}finally{eM(!1)}}},eZ=async()=>{if(!eP){eV(!1),eU(!0),eO("");try{var e,t,r,n;let a={name:M.trim(),subject:U.trim(),preheaderText:O.trim(),body:V.trim(),templateId:$,ctaText:G.trim(),ctaUrl:J.trim(),fromName:X.trim(),fromEmail:ee.trim(),replyTo:et.trim(),useAiPersonalization:!1,aiContext:"".trim(),audienceType:en,distributionListId:null,segmentFilters:ef||null,networkFilters:er?ea:null,sendAs:"community"===ey.type?{type:"community",communityId:ey.communityId}:null,eventId:er?null!=(e=null==ep?void 0:ep.id)?e:null:eD||null,eventName:er?null!=(t=null==ep?void 0:ep.name)?t:null:(null==eR?void 0:eR.eventName)||null,eventDate:er?(null==ep?void 0:ep.dateMs)?new Date(ep.dateMs).toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}):null:(null==eR?void 0:eR.eventDate)?eR.eventDate.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric",year:"numeric"}):null,eventVenue:(null==eR?void 0:eR.locationAddress)||null,attachedPromoCode:er?em:null,hostName:Q||"Your host",estimatedAudienceSize:er?null!=(r=null==eo?void 0:eo.sendable)?r:null:null!=eW?eW:null,producerUserId:null==T?void 0:T.uid,createdBy:null==T?void 0:T.uid,updatedAt:(0,s.serverTimestamp)(),stats:z.Wh}
1,d=g;if(d&&!m?await (0,s.updateDoc)((0,s.doc)(i.db,"email_campaigns",d),{...a,status:"draft"}):(d=(0,o.k)(),await (0,s.setDoc)((0,s.doc)(i.db,"email_campaigns",d),{...a,status:"draft",createdAt:(0,s.serverTimestamp)()})),"later"===eS&&ew&&ez)await (0,s.updateDoc)((0,s.doc)(i.db,"email_campaigns",d),{status:"scheduled",scheduledAt:s.Timestamp.fromDate(new Date("".concat(ew,"T").concat(ez))),updatedAt:(0,s.serverTimestamp)()}),W({message:"Email campaign scheduled",type:"success"});else{let e=(0,l.httpsCallable)(i.functions,"sendEmailCampaign"),t=(await e({campaignId:d})).data;"sending"===t.status||t.jobId?W({message:"Email campaign queued and sending",type:"success"}):0===t.sent?W({message:t.message||"No recipients had email addresses on file. Emails could not be delivered.",type:"error"}):W({message:"Email campaign sent to ".concat(null!=(n=t.sent)?n:"?"," recipients!"),type:"success"})}eY.current=!1,k()}catch(e){eO(e.message),(0,y.WL)("EmailCampaign",W,{tab:"DISTRIBUTION",action:"email-campaign",meter:"marketingEmails"})(e)}finally{eU(!1)}}};if((0,a.useEffect)(()=>{let e=e=>{eY.current&&e.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[]),(0,a.useEffect)(()=>{if(!eq)return;let e=e=>{"Escape"===e.key&&eV(!1)};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[eq]),eB)return(0,n.jsx)("div",{style:{position:"fixed",inset:0,zIndex:50,backgroundColor:"rgb(var(--surface-base))",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[(0,n.jsx)("div",{style:{width:32,height:32,border:"2px solid rgba(255,255,255,0.1)",borderTopColor:"rgba(255,255,255,0.6)",borderRadius:"50%",animation:"spin 1s linear infinite"}}),(0,n.jsx)("p",{style:{color:"rgb(var(--text-secondary))",fontSize:14},children:"Loading campaign..."})]})});if("detail"===x&&eH){let e={sent:{bg:"var(--state-positive-bg)",text:"var(--state-positive-fg)"},sending:{bg:"var(--state-info-bg)",text:"var(--state-info-fg)"},scheduled:{bg:"rgb(var(--accent-purple) / 0.13)",text:"rgb(var(--accent-purple))"},draft:{bg:"var(--button-ghost-bg)",text:"rgb(var(--text-secondary))"},failed:{bg:"var(--state-negative-bg)",text:"var(--state-negative-fg)"},sent_empty:{bg:"var(--state-attention-bg)",text:"var(--state-attention-fg)"}},t=e[eH.status]||e.draft;return(0,n.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:50,backgroundColor:"rgb(var(--surface-base))",overflowY:"auto"},children:[(0,n.jsxs)("div",{style:{position:"sticky",top:0,zIndex:10,backgroundColor:"rgb(var(--surface-raised))",borderBottom:"1px solid var(--border-default)",padding:"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,n.jsx)("h2",{style:{margin:0,fontSize:18,fontWeight:700,color:"rgb(var(--text-primary))"},children:eH.name}),(0,n.jsx)(C.$n,{variant:"secondary",size:"md",onClick:k,children:"Close"})]}),(0,n.jsxs)("div",{style:{maxWidth:800,margin:"0 auto",padding:24},children:[(0,n.jsxs)("div",{style:{marginBottom:24,display:"flex",alignItems:"center",gap:12},children:[(0,n.jsx)("span",{style:{padding:"4px 10px",borderRadius:6,fontSize:12,fontWeight:600,backgroundColor:t.bg,color:t.text},children:"sent_empty"===eH.status?"NO RECIPIENTS":eH.status.toUpperCase()}),eH.sentAt&&(0,n.jsxs)("span",{style:{fontSize:13,color:"rgb(var(--text-secondary))"},children:["Sent ",eH.sentAt.toLocaleString()]})]}),"sent_empty"===eH.status&&(0,n.jsxs)("div",{style:{marginBottom:24,padding:16,backgroundColor:"var(--state-attention-bg)",borderRadius:8,border:"1px solid var(--state-attention-border)"},children:[(0,n.jsx)("p",{style:{margin:0,fontSize:14,fontWeight:600,color:"var(--state-attention-fg)"},children:"No emails were delivered"}),(0,n.jsx)("p",{style:{margin:"4px 0 0",fontSize:13,color:"rgb(var(--text-secondary))"},children:"None of the event participants had email addresses on file. Most users signed up via phone number only. To send emails, participants need to have an email address in their profile."})]}),eH.stats.sent>0&&(0,n.jsx)("div",{style:{marginBottom:24},children:(0,n.jsx)(j,{stats:eH.stats})}),(0,n.jsxs)("div",{style:{marginBottom:24},children:[(0,n.jsx)("p",{style:{margin:"0 0 12px",fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))",textTransform:"uppercase",letterSpacing:.5},children:"Email Preview"}),(0,n.jsx)(h.A,{subject:eH.subject,preheaderText:eH.preheaderText||"",body:eH.body||"",templateId:eH.templateId,ctaText:eH.ctaText,eventName:eH.eventName,eventDate:eH.eventDate,eventVenue:eH.eventVenue,eventImageUrl:eH.eventImageUrl,hostName:eH.hostName})]})]})]})}return(0,n.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:50,backgroundColor:"rgb(var(--surface-base))",overflowY:"auto"},children:[(0,n.jsx)("style",{children:"\n @keyframes spin { to { transform: rotate(360deg); } }\n @media (max-width: 900px) {\n .email-edit-grid { grid-template-columns: 1fr !important; }\n }\n @media (max-width: 600px) {\n .email-from-grid { grid-template-columns: 1fr !important; }\n .email-outer-pad { padding-left: 16px !important; padding-right: 16px !important; }\n .email-header-bar { padding-left: 12px !important; padding-right: 12px !important; }\n .email-header-bar h2 { font-size: 15px !important; }\n .email-header-bar button { padding: 6px 10px !important; font-size: 13px !important; }\n .email-prompt-area { max-width: 100% !important; }\n .email-cta-grid { grid-template-columns: 1fr !important; }\n }\n "}),(0,n.jsxs)("div",{className:"email-header-bar",style:{position:"sticky",top:0,zIndex:10,backgroundColor:"rgb(var(--surface-raised))",borderBottom:"1px solid var(--border-default)",padding:"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",flexWrap:"wrap",gap:8},children:[(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",minWidth:0},children:["edit"===A&&!g&&!m&&(0,n.jsx)("button",{onClick:()=>N("prompt"),style:{background:"none",border:"none",color:"rgb(var(--text-secondary))",cursor:"pointer",marginRight:8,fontSize:18},"aria-label":"Back to prompt",children:"â"}),(0,n.jsx)("h2",{style:{margin:0,fontSize:18,fontWeight:700,color:"rgb(var(--text-primary))",whiteSpace:"nowrap"},children:g?"Edit Email Campaign":"New Email Campaign"})]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:["edit"===A&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(C.$n,{variant:"secondary",size:"md",onClick:eJ,disabled:e_||!M.trim(),children:e_?"Saving...":"Save Draft"}),er&&!1===ec?(0,n.jsx)("span",{style:{display:"inline-flex",alignItems:"center",padding:"0 12px",fontSize:12,color:"rgba(255,255,255,0.55)",border:"1px dashed rgba(255,255,255,0.2)",borderRadius:8},children:"Connect your domain to send â takes ~5 minutes, in My Network"}):(0,n.jsx)(C.$n,{variant:"primary",size:"md",onClick:()=>{let e=(()=>
1{if(!M.trim())return"Campaign name is required";if(!U.trim())return"Subject line is required";if(!V.trim())return"Email body is required";if(!er&&!eD)return"Select an event to define your audience";if(er&&null!==eo&&0===eo.sendable)return"Nobody matches this audience yet â pick a different segment or list";if("later"===eS){if(!ew||!ez)return"Scheduled date and time are required";if(new Date("".concat(ew,"T").concat(ez))<=new Date)return"Scheduled time must be in the future"}return null})();if(e)return void eO(e);eV(!0)},disabled:eP||er&&null===ec,className:M.trim()&&U.trim()?"":"opacity-50",children:eP?"Sending...":"later"===eS?"Schedule":"Send Now"})]}),(0,n.jsx)(C.$n,{variant:"secondary",size:"md",onClick:()=>{(!eY.current||window.confirm("You have unsaved changes. Discard?"))&&k()},children:"Close"})]})]}),(0,n.jsxs)("div",{className:"email-outer-pad",style:{maxWidth:1400,margin:"0 auto",padding:"24px 32px"},children:["prompt"===A&&(0,n.jsxs)("div",{className:"email-prompt-area",style:{maxWidth:640,margin:"0 auto"},children:[(0,n.jsx)("h3",{style:{margin:"0 0 8px",fontSize:20,fontWeight:700,color:"rgb(var(--text-primary))"},children:"Describe your email campaign"}),(0,n.jsx)("p",{style:{margin:"0 0 20px",fontSize:14,color:"rgb(var(--text-secondary))"},children:"Our AI will generate subject line, body, template, and CTA based on your description."}),er&&(0,n.jsxs)("div",{style:{marginBottom:16},children:[(0,n.jsx)("p",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.25)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:"Promote"}),(0,n.jsx)(b,{selected:ep,code:em,onSelect:e=>eg({id:e.eventId,name:e.eventName,dateMs:e.eventDateMs,role:e.role}),onCode:ex,onClear:()=>{eg(null),ex(null)}})]}),(0,n.jsxs)("div",{style:{marginBottom:16},children:[(0,n.jsx)("p",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.25)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:"Audience"}),er?(0,n.jsx)("div",{style:{backgroundColor:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:8,padding:16},children:(0,n.jsx)(p,{value:ea,onChange:ei,onPreview:(e,t)=>{el(e),ed(t)}})}):(0,n.jsxs)("div",{style:{backgroundColor:"rgba(255,255,255,0.02)",border:"1px solid rgba(255,255,255,0.06)",borderRadius:8,padding:16,display:"flex",alignItems:"center",gap:10},children:[(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,style:{flexShrink:0,opacity:.6,color:"var(--state-positive-fg)"},children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18 18.72a9.094 9.094 0 003.741-.479 3 3 0 00-4.682-2.72m.94 3.198l.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0112 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 016 18.719m12 0a5.971 5.971 0 00-.941-3.197m0 0A5.995 5.995 0 0012 12.75a5.995 5.995 0 00-5.058 2.772m0 0a3 3 0 00-4.681 2.72 8.986 8.986 0 003.74.477m.94-3.197a5.971 5.971 0 00-.94 3.197M15 6.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z"})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{style:{margin:0,fontSize:13,color:"rgba(255,255,255,0.6)",fontWeight:500},children:(null==eR?void 0:eR.eventName)||"Event Participants"}),(0,n.jsxs)("p",{style:{margin:"2px 0 0",fontSize:11,color:"rgba(255,255,255,0.3)"},children:[eW," of ",eN," participants have email"]})]})]})]}),(0,n.jsx)("textarea",{value:E,onChange:e=>B(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),eK())},placeholder:"Describe the email you want to send...",rows:5,style:{width:"100%",padding:"12px",backgroundColor:"rgb(var(--surface-raised))",border:"1px solid var(--border-default)",borderRadius:8,color:"rgb(var(--text-primary))",fontSize:14,resize:"vertical"}}),(0,n.jsx)("p",{style:{margin:"4px 0 0",fontSize:11,color:"rgb(var(--text-quaternary))"},children:"â+Enter to generate"}),(0,n.jsx)("div",{style:{marginTop:12,display:"flex",flexWrap:"wrap",gap:6},children:I.map((e,t)=>(0,n.jsxs)("button",{onClick:()=>B(e),style:{padding:"6px 12px",borderRadius:16,border:"1px solid var(--border-default)",backgroundColor:"rgb(var(--surface-raised))",color:"rgb(var(--text-secondary))",fontSize:12,cursor:"pointer"},children:[e.slice(0,60),"..."]},t))}),(0,n.jsxs)("div",{style:{marginTop:20,display:"flex",gap:12,alignItems:"center"},children:[(0,n.jsx)(C.$n,{variant:"primary",size:"lg",onClick:eK,disabled:L||!E.trim(),children:L?"Generating...":"Generate Email"}),(0,n.jsx)(C.$n,{variant:"secondary",size:"lg",onClick:()=>N("edit"),children:"Manual setup"})]})]}),"edit"===A&&(0,n.jsxs)("div",{className:"email-edit-grid",style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr) minmax(360px, 480px)",gap:24},children:[(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[eF&&(0,n.jsx)("div",{style:{padding:12,backgroundColor:"var(--state-negative-bg)",borderRadius:8,border:"1px solid var(--state-negative-border)"},children:(0,n.jsx)("p",{style:{margin:0,fontSize:13,color:"var(--state-negative-fg)"},children:eF})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",marginBottom:4,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"Campaign Name"}),(0,n.jsx)("input",{value:M,onChange:e=>{P(e.target.value),eY.current=!0},placeholder:"e.g. Monthly Newsletter",style:{width:"100%",padding:"10px 12px",backgroundColor:"rgb(var(--surface-raised))",border:"1px solid var(--border-default)",borderRadius:8,color:"rgb(var(--text-primary))",fontSize:14}})]}),ev.length>0&&(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",marginBottom:6,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"Send As"}),(0,n.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[(0,n.jsxs)("button",{type:"button",onClick:()=>{eh({type:"user"}),eY.current=!0},style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",backgroundColor:"user"===ey.type?"rgba(255,255,255,0.12)":"rgba(255,255,255,0.04)",color:"user"===ey.type?"rgb(var(--text-primary))":"rgb(var(--text-secondary))",border:"user"===ey.type?"1px solid rgba(255,255,255,0.20)":"1px solid transparent"},children:[(null==R?void 0:R.profilePictureURL)?(0,n.jsx)("img",{src:R.profilePictureURL,alt:"",style:{width:16,height:16,borderRadius:"50%",objectFit:"cover"}}):(0,n.jsx)("div",{style:{width:16,height:16,borderRadius:"50%",backgroundColor:"rgba(255,255,255,0.10)"}}),"Me (",[null==R?void 0:R.firstName,null==R?void 0:R.lastName].filter(
1Boolean).join(" ")||"You",")"]}),ev.map(e=>{let t="community"===ey.type&&ey.communityId===e.id;return(0,n.jsxs)("button",{type:"button",onClick:()=>{eh({type:"community",communityId:e.id}),eY.current=!0},style:{display:"flex",alignItems:"center",gap:6,padding:"6px 12px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",backgroundColor:t?"rgba(255,255,255,0.12)":"rgba(255,255,255,0.04)",color:t?"rgb(var(--text-primary))":"rgb(var(--text-secondary))",border:t?"1px solid rgba(255,255,255,0.20)":"1px solid transparent"},children:[e.iconURL?(0,n.jsx)("img",{src:e.iconURL,alt:"",style:{width:16,height:16,borderRadius:"50%",objectFit:"cover"}}):(0,n.jsx)("div",{style:{width:16,height:16,borderRadius:"50%",backgroundColor:"rgba(255,255,255,0.10)"}}),e.name]},e.id)})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",marginBottom:4,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"Template"}),(0,n.jsx)(f.A,{selectedTemplate:$,onSelect:e=>{H(e),eY.current=!0}})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("label",{style:{display:"block",marginBottom:4,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:["Subject Line ",(0,n.jsxs)("span",{style:{color:U.length>60?"var(--state-attention-fg)":"rgb(var(--text-tertiary))",fontWeight:400},children:["(",U.length,"/60 recommended)"]})]}),(0,n.jsx)("input",{value:U,onChange:e=>{F(e.target.value),eY.current=!0},placeholder:"What should appear in the inbox?",style:{width:"100%",padding:"10px 12px",backgroundColor:"rgb(var(--surface-raised))",border:"1px solid var(--border-default)",borderRadius:8,color:"rgb(var(--text-primary))",fontSize:14}})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("label",{style:{display:"block",marginBottom:4,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:["Preheader Text ",(0,n.jsxs)("span",{style:{color:O.length>100?"var(--state-attention-fg)":"rgb(var(--text-tertiary))",fontWeight:400},children:["(",O.length,"/100 recommended)"]})]}),(0,n.jsx)("input",{value:O,onChange:e=>{q(e.target.value),eY.current=!0},placeholder:"Preview text shown in inbox",style:{width:"100%",padding:"10px 12px",backgroundColor:"rgb(var(--surface-raised))",border:"1px solid var(--border-default)",borderRadius:8,color:"rgb(var(--text-primary))",fontSize:14}})]}),(0,n.jsxs)("div",{children:[(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:4},children:[(0,n.jsx)("label",{style:{fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"Body"}),(0,n.jsx)("div",{style:{display:"flex",gap:4},children:z.kS.map(e=>(0,n.jsx)("button",{onClick:()=>(e=>{let t=e$.current,r="{{".concat(e,"}}");if(t){let e=t.selectionStart,n=t.selectionEnd;Y(V.slice(0,e)+r+V.slice(n)),eY.current=!0,requestAnimationFrame(()=>{t.selectionStart=t.selectionEnd=e+r.length,t.focus()})}else Y(e=>e+r),eY.current=!0}
1)(e.key),style:{padding:"3px 8px",borderRadius:4,border:"1px solid var(--border-default)",backgroundColor:"rgb(var(--surface-raised))",color:"rgba(255,255,255,0.5)",fontSize:11,cursor:"pointer"},children:"{{".concat(e.label,"}}")},e.key))})]}),(0,n.jsx)("textarea",{ref:e$,value:V,onChange:e=>{Y(e.target.value),eY.current=!0},rows:8,placeholder:"Write your email content...",style:{width:"100%",padding:"12px",backgroundColor:"rgb(var(--surface-raised))",border:"1px solid var(--border-default)",borderRadius:8,color:"rgb(var(--text-primary))",fontSize:14,resize:"vertical",lineHeight:"20px"}})]}),(0,n.jsxs)("div",{className:"email-cta-grid",style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",marginBottom:4,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"CTA Button Text"}),(0,n.jsx)("input",{value:G,onChange:e=>{K(e.target.value),eY.current=!0},placeholder:"View Event",style:{width:"100%",padding:"10px 12px",backgroundColor:"rgb(var(--surface-raised))",border:"1px solid var(--border-default)",borderRadius:8,color:"rgb(var(--text-primary))",fontSize:14}})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",marginBottom:4,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"CTA URL"}),(0,n.jsx)("div",{style:{width:"100%",padding:"10px 12px",backgroundColor:"rgb(var(--surface-base))",border:"1px solid var(--border-default)",borderRadius:8,color:"rgba(255,255,255,0.4)",fontSize:13,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:J||"Auto-generated tracking link"})]})]}),(0,n.jsxs)("div",{style:{padding:12,backgroundColor:"rgb(var(--surface-raised))",borderRadius:8,border:"1px solid var(--border-default)"},children:[(0,n.jsx)("label",{style:{display:"block",marginBottom:8,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"Sending As"}),(0,n.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:10},children:[(0,n.jsx)("div",{style:{width:36,height:36,borderRadius:"50%",backgroundColor:"rgba(255,255,255,0.08)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:15,fontWeight:700,color:"rgba(255,255,255,0.6)",flexShrink:0},children:(Q||"S")[0].toUpperCase()}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{style:{margin:0,fontSize:14,fontWeight:600,color:"rgb(var(--text-primary))"},children:X}),(0,n.jsxs)("p",{style:{margin:"2px 0 0",fontSize:12,color:"rgb(var(--text-secondary))"},children:["<",ee,">"]})]})]})]}),er&&(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",marginBottom:8,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"Promote"}),(0,n.jsx)(b,{selected:ep,code:em,onSelect:e=>eg({id:e.eventId,name:e.eventName,dateMs:e.eventDateMs,role:e.role}),onCode:ex,onClear:()=>{eg(null),ex(null)}})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",marginBottom:8,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"Audience"}),er?(0,n.jsx)("div",{style:{backgroundColor:"rgb(var(--surface-raised))",borderRadius:8,border:"1px solid var(--border-default)",padding:12},children:(0,n.jsx)(p,{value:ea,onChange:ei,onPreview:(e,t)=>{el(e),ed(t)}})}):(0,n.jsxs)("div",{style:{backgroundColor:"rgb(var(--surface-raised))",borderRadius:8,border:"1px solid var(--border-default)",padding:12,display:"flex",alignItems:"center",gap:10},children:[(0,n.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,style:{flexShrink:0,opacity:.6,color:"var(--state-positive-fg)"},children:(0,n.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M18 18.72a9.094 9.094 0 003.741-.479 3 3 0 00-4.682-2.72m.94 3.198l.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0112 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 016 18.719m12 0a5.971 5.971 0 00-.941-3.197m0 0A5.995 5.995 0 0012 12.75a5.995 5.995 0 00-5.058 2.772m0 0a3 3 0 00-4.681 2.72 8.986 8.986 0 003.74.477m.94-3.197a5.971 5.971 0 00-.94 3.197M15 6.75a3 3 0 11-6 0 3 3 0 016 0zm6 3a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0zm-13.5 0a2.25 2.25 0 11-4.5 0 2.25 2.25 0 014.5 0z"})}),(0,n.jsxs)("div",{children:[(0,n.jsx)("p",{style:{margin:0,fontSize:13,color:"rgba(255,255,255,0.6)",fontWeight:500},children:(null==eR?void 0:eR.eventName)||"Event Participants"}),(0,n.jsxs)("p",{style:{margin:"2px 0 0",fontSize:11,color:"rgba(255,255,255,0.3)"},children:[eW," of ",eN," participants have email"]})]})]})]}),(0,n.jsxs)("div",{children:[(0,n.jsx)("label",{style:{display:"block",marginBottom:8,fontSize:13,fontWeight:600,color:"rgb(var(--text-secondary))"},children:"Delivery"}),(0,n.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,n.jsx)("button",{onClick:()=>ek("now"),style:{padding:"8px 16px",borderRadius:8,border:"1px solid ".concat("now"===eS?"var(--border-emphasis)":"var(--border-default)"),backgroundColor:"now"===eS?"rgba(255,255,255,0.08)":"transparent",color:"now"===eS?"rgba(255,255,255,0.7)":"rgb(var(--text-secondary))",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Send Now"}),(0,n.jsx)("button",{onClick:()=>ek("later"),style:{padding:"8px 16px",borderRadius:8,border:"1px solid ".concat("later"===eS?"var(--border-emphasis)":"var(--border-default)"),backgroundColor:"later"===eS?"rgba(255,255,255,0.08)":"transparent",color:"later"===eS?"rgba(255,255,255,0.7)":"rgb(var(--text-secondary))",fontSize:13,fontWeight:600,cursor:"pointer"},children:"Schedule"})]}),"later"===eS&&(0,n.jsxs)("div",{style:{display:"flex",gap:8,marginTop:8,alignItems:"center"},children:[(0,n.jsx)("input",{type:"date",value:ew,onChange:e=>eC(e.target.value),min:new Date().toISOString().split("T")[0],style:{padding:"8px 12px",backgroundColor:"rgb(var(--surface-raised))",border:"1px solid var(--border-default)",borderRadius:8,color:"rgb(var(--text-primary))",fontSize:14}}),(0,n.jsx)("input",{type:"time",value:ez,onChange:e=>eI(e.target.value),style:{padding:"8px 12px",backgroundColor:"rgb(var(--surface-raised))",border:"1px solid var(--border-default)",borderRadius:8,color:"rgb(var(--text-primary))",fontSize:14}}),(0,n.jsx)("span",{style:{fontSize:11,color:"rgb(var(--text-secondary))",marginLeft:8},children:Intl.DateTimeFormat().resolvedOptions().timeZone})]})]})]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[(0,n.jsxs)("div",{style:{padding:16,backgroundColor:"rgb(var(--surface-raised))",borderRadius:8,border:"1px solid var(--border-default)"},children:[(0,n.jsx)("h3",{style:{margin:"0 0 12px",fontSize:14,fontWeight:700,color:"rgb(var(--text-secondary))"},children:"Preview"}),(0,n.jsx)(h.A,{subject:U,preheaderText:O,body:V,templateId:$,ctaText:G,eventName:(null==eR?void 0:eR.eventName)||"",eventDate:null==eR||null==(t=eR.eventDate)?void 0:t.toLocaleDateString("en-US",{weekday:"long",month:"long",day:"numeric"}),eventVenue:null==eR?void 0:eR.locationAddress,hostName:Q})]}),(0,n.jsxs)("div",{style:{padding:16,backgroundColor:"rgb(var(--surface-raised))",borderRadius:8,border:"1px solid var(--border-default)"},children:[(0,n.jsx)("h3",{style:{margin:"0 0 12px",fontSize:14,fontWeight:700,color:"rgb(var(--text-secondary))"},children:"Summary"}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[(0,n.jsx)(D,{label:"From",value:X}),(0,n.jsx)(D,{label:"Sender",value:ee}),!er&&(0,n.jsx)(D,{label:"Event",value:(null==eR?void 0:eR.eventName)||"Not selected"}),(0,n.jsx)(D,{label:"Template",value:$.replace(/_/g," ")}),(0,n.jsx)(D,{label:"Audience",value:er?"".concat((null!=(r=null==eo?void 0:eo.sendable)?r:0).toLocaleStr
1ing()," people").concat((null!=(c=null==eo?void 0:eo.suppressed)?c:0)>0?" (".concat(eo.suppressed," unsubscribed skipped)"):""):"".concat(eW," reachable (").concat(eN," total)")}),(0,n.jsx)(D,{label:"Delivery",value:"now"===eS?"Immediate":ew&&ez?"".concat(ew," at ").concat(ez):"Not set"})]})]})]})]})]}),eq&&(0,n.jsx)("div",{role:"dialog","aria-modal":"true",style:{position:"fixed",inset:0,zIndex:60,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(0,0,0,0.6)"},children:(0,n.jsxs)("div",{style:{backgroundColor:"rgb(var(--surface-raised))",borderRadius:12,border:"1px solid var(--border-default)",padding:24,maxWidth:400,width:"100%"},children:[(0,n.jsx)("h3",{style:{margin:"0 0 12px",fontSize:18,fontWeight:700,color:"rgb(var(--text-primary))"},children:"later"===eS?"Schedule email campaign?":"Send email campaign now?"}),(0,n.jsxs)("p",{style:{margin:"0 0 20px",fontSize:14,color:"rgb(var(--text-secondary))"},children:["This will ","later"===eS?"schedule":"immediately send",' "',U,'" from'," ",(0,n.jsx)("strong",{children:X})," to"," ",(0,n.jsx)("strong",{children:er?(null!=(u=null==eo?void 0:eo.sendable)?u:0).toLocaleString():eW})," recipients with email."]}),(0,n.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,n.jsx)(C.$n,{variant:"secondary",size:"md",autoFocus:!0,onClick:()=>eV(!1),children:"Cancel"}),(0,n.jsx)(C.$n,{variant:"primary",size:"md",onClick:eZ,children:"later"===eS?"Schedule":"Send Now"})]})]})})]})}function D(e){let{label:t,value:r}=e;return(0,n.jsxs)("div",{style:{display:"flex",justifyContent:"space-between"},children:[(0,n.jsx)("span",{style:{fontSize:13,color:"rgb(var(--text-secondary))"},children:t}),(0,n.jsx)("span",{style:{fontSize:13,color:"rgb(var(--text-primary))",fontWeight:500,textTransform:"capitalize"},children:r})]})}}}]);
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.