PageSourceSearch

https://drophighlight.com/assets/CampaignBuilder-fnRBYF8-.js

js drophighlight.com collected 2026-09-30 06:39:20 UTC 60,792 bytes, 75 lines download raw bytes

1import{r as _,j as e,I as re,T as fe,o as oe,K as Ie,a3 as Oe,a4 as Ke,B as de,a5 as Je,s as E,f as Qe,m as Ze,q as et,a as tt,G as _e,t as $e,C as ue,l as xe,h as Se,i as ke,E as st,M as at,J as be}from"./index-P0N1Je5T.js";import{A as qe}from"./AppleIntelligenceButton-BYIEZF3c.js";import{u as it,E as lt}from"./useEmailDomainStatus-CYqZ9wTr.js";import{u as nt}from"./useAudiences-DyctrA36.js";import{a as Ce}from"./internationalization-ClDqWLdo.js";import{g as je}from"./urlBuilder-aqAknea8.js";import{g as ze}from"./coverUrls-CgXMhAXv.js";import{I as ee}from"./input-1tKBwIjz.js";import{S as rt,a as ot,b as dt,c as ct,d as He}from"./select-Supfcq-S.js";import{S as Te}from"./skeleton-CeSviFvH.js";import{M as mt}from"./monitor-qt2MUyGV.js";import{S as ut}from"./smartphone-JVYc6m6J.js";import{P as xt}from"./play-B168p-g_.js";import{P as Fe}from"./pencil-CE5cIgkq.js";import{S as gt}from"./sparkles-Xyayynck.js";import{L as ye}from"./label-CoHN_xq2.js";import{C as Ee}from"./checkbox-wSZ1kz90.js";import{T as ht,a as pt,b as Me,c as Le}from"./tabs-DitHknAx.js";import{u as ft,T as Ge,R as _t,E as bt}from"./EmailPreviewReadonly-CgDYXFSm.js";import{A as ve}from"./arrow-right-DPBZU1JC.js";import{M as jt}from"./map-pin-vvbH8j3Q.js";import{C as yt}from"./calendar-D19SFwpy.js";import{C as vt}from"./circle-check-CYFFE5P4.js";import{T as wt}from"./triangle-alert-Dfdm1-MX.js";import{U as Ue}from"./users-BWumBODg.js";import{A as Nt}from"./archive-B1aoBXiv.js";import{T as $t}from"./trash-2-Dwmr_5Bh.js";import{S as St}from"./star-D5Er7kP8.js";import{C as kt}from"./clock-CxwmHBif.js";import"./useMutation-DJI0oEf-.js";import"./circle-x-C-UIuONs.js";function We(t){var c;const l=(c=t.file_type)==null?void 0:c.startsWith("video");return t.grid_thumbnail_url||t.thumbnail_url||(l?null:t.file_url)||null}function Ct(t,l){const x=t.slice(0,4).map(d=>({...d,_thumb:We(d)})).filter(d=>d._thumb);if(x.length===0)return"";const c=270,p=d=>l?`<a href="${l}" style="text-decoration:none;display:block;">${d}</a>`:d,m=d=>`
2    <td width="${c}" height="${c}" style="padding:3px;">
3      ${p(`<img src="${d._thumb}" alt="${H(d.title||"")}" width="${c}" height="${c}" style="display:block;width:${c}px;height:${c}px;object-fit:cover;border-radius:8px;border:0;" />`)}
4    </td>`,b=[];for(let d=0;d<x.length;d+=2){const y=x.slice(d,d+2).map(m).join(""),k=d+1>=x.length?`<td width="${c}" height="${c}" style="padding:3px;"></td>`:"";b.push(`<tr>${y}${k}</tr>`)}return`<tr><td style="padding:0 24px 16px;">
5    <table width="100%" cellpadding="0" cellspacing="0" role="presentation" style="border-collapse:collapse;">
6      ${b.join("")}
7    </table>
8  </td></tr>`}function zt(t,l,x){const c=t.slice(0,2).map(u=>({...u,_thumb:We(u)})).filter(u=>u._thumb);if(c.length===0)return"";const p=(x==null?void 0:x.title)||"Gallery",b=(l.email_title||"").trim().toLowerCase()===p.trim().toLowerCase()?"":H(p),d=H(l.company_name),y=l.company_light_logo_url||l.company_logo_url,k=y?`<img src="${y}" alt="${d}" style="height:16px;margin-top:4px;${l.company_light_logo_url?"":"filter:brightness(0) invert(1);"}" />`:`<span style="color:rgba(255,255,255,0.7);font-size:10px;">${d}</span>`,r=(u,h,L,B,s)=>`
9    <div style="position:absolute;left:50%;top:50%;margin-left:-130px;margin-top:-170px;width:260px;height:340px;border-radius:24px;overflow:hidden;box-shadow:0 10px 30px rgba(0,0,0,0.25);transform:rotate(${h}) translateX(${L}px) translateY(${B}px);z-index:${s};background:#e4e4e7;">
10      <img src="${u}" alt="" width="260" height="340" style="width:260px;height:340px;object-fit:cover;display:block;" />
11      <div style="position:absolute;left:0;right:0;bottom:0;padding:20px;background:linear-gradient(to top,rgba(0,0,0,0.8),rgba(0,0,0,0.2) 60%,transparent);">
12        ${b?`<div style="color:#fff;font-size:18px;font-weight:700;line-height:1.3;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;margin-bottom:12px;">${b}</div>`:""}
13        ${k}
14      </div>
15    </div>`,v=c[0]?r(c[0]._thumb,"-12deg",-30,-70,30):"",g=c[1]?r(c[1]._thumb,"8deg",80,70,20):"",w=c[0]?`
16    <div style="position:absolute;left:50%;
16top:50%;margin-left:-130px;margin-top:-170px;width:260px;height:340px;border-radius:24px;overflow:hidden;opacity:0.3;filter:blur(2px);transform:rotate(-18deg) translateX(-60px) translateY(-10px);z-index:10;background:#e4e4e7;">
17      <img src="${c[0]._thumb}" alt="" width="260" height="340" style="width:260px;height:340px;object-fit:cover;display:block;" />
18    </div>`:"";return`<tr><td style="padding:0;">
19    <!--[if mso]>
20    <table width="100%" cellpadding="0" cellspacing="0"><tr>${c.map(u=>`<td style="padding:8px;"><img src="${u._thumb}" alt="" width="200" height="260" style="width:200px;height:260px;object-fit:cover;border-radius:16px;" /></td>`).join("")}</tr></table>
21    <![endif]-->
22    <!--[if !mso]><!-->
23    <div style="position:relative;height:520px;background:#fafafa;overflow:hidden;">
24      <div style="position:relative;width:420px;height:520px;margin:0 auto;">
25        ${w}${v}${g}
26      </div>
27    </div>
28    <!--<![endif]-->
29  </td></tr>`}function Ve({templateId:t,data:l,selectedMedia:x,cardMedia:c,galleryUrl:p,landingUrl:m,galleryContext:b,cardHeroImageUrl:d}){const y=l.cta_button_target==="landing"&&m||p,k=Ct(x,p),r=C=>p?`<a href="${p}" style="text-decoration:none;display:block;">${C}</a>`:C;let v="";t==="cards"&&(d?v=`<tr><td style="padding:0;font-size:0;line-height:0;">
30        ${r(`<img src="${d}" alt="" width="600" height="600" style="width:100%;max-width:600px;height:auto;display:block;border:0;" />`)}
31      </td></tr>`:v=zt(c||[],l,b));const g=H(l.cta_button_text||"View Gallery"),w=y?`<tr><td style="padding:8px 24px 16px;">
32        <a href="${y}" class="email-cta" style="background-color:#000;color:#fff;border:2px solid #000;padding:12px 24px;border-radius:6px;text-decoration:none;font-size:14px;font-weight:500;display:block;text-align:center;box-sizing:border-box;">${g}</a>
33      </td></tr>`:`<tr><td style="padding:8px 24px 16px;">
34        <span class="email-cta" style="background-color:#000;color:#fff;border:2px solid #000;padding:12px 24px;border-radius:6px;font-size:14px;font-weight:500;display:block;text-align:center;box-sizing:border-box;">${g}</span>
35      </td></tr>`,j=l.cta2_button_text?H(l.cta2_button_text):"",u=j?l.cta2_button_url?`<tr><td style="padding:0 24px 16px;">
36          <a href="${l.cta2_button_url}" class="email-cta email-cta-secondary" style="border:2px solid #000;color:#000;background-color:#fff;padding:12px 24px;border-radius:6px;text-decoration:none;font-size:14px;font-weight:500;display:block;text-align:center;box-sizing:border-box;">${j}</a>
37        </td></tr>`:`<tr><td style="padding:0 24px 16px;">
38          <span class="email-cta email-cta-secondary" style="border:2px solid #000;color:#000;background-color:#fff;padding:12px 24px;border-radius:6px;font-size:14px;font-weight:500;display:block;text-align:center;box-sizing:border-box;">${j}</span>
39        </td></tr>`:"",h=(l.preview_text||l.email_subtitle||l.email_tagline||l.email_body||"").trim(),L=h.length>140?`${h.slice(0,137)}…`:h,B=L&&L.length<100?`${L}${" ".repeat(Math.max(0,100-L.length))}`:L,s=B?`<div style="display:none;font-size:1px;color:#f4f4f5;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden;mso-hide:all;">${H(B)}</div>
40<div style="display:none;max-height:0;overflow:hidden;mso-hide:all;">${"&#847;&zwnj;&nbsp;".repeat(200)}</div>`:"";return`<!DOCTYPE html>
41<html lang="en">
42<head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1.0">
43<title>${H(l.email_title)}</title>
44<style>
45body, table, td, a { -webkit-text-size-adjust: 100%; -ms-text-size-adjust: 100%; }
46@media only screen and (max-width: 600px) {
47  .email-logo { height: 60px !important; }
48  .email-title { font-size: 32px !important; line-height: 1.2 !important; padding: 20px 24px 8px !important; }
49  .email-subtitle { font-size: 18px !important; padding: 4px 24px 6px !important; }
50  .email-tagline { font-size: 13px !important; padding: 0 24px 14px !important; }
51  .email-body { font-size: 16px !important; line-height: 1.6 !important; padding: 8px 24px 20px !important; }
52  .email-cta { font-size: 16px !important; padding: 16px 24px !important; }
53}
54</style>
55</head>
56<body style="margin:0;padding:0;background-color:#f4f4f5;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;-webkit-text-size-adjust:100%;">
57${s}
58<table width="100%" cellpadding="0" cellspacing="0" role="presentation" style="background-color:#f4f4f5;">
59<tr><td align="center" style="padding:24px 16px;">
60<table width="600" cellpadding="0" cellspacing="0" role="presentation" style="background-color:#ffffff;border-radius:12px;overflow:hidden;max-width:600px;width:100%;">
61  ${v}
62  ${t!=="cards"&&t!=="minimal"&&l.cover_image_url?`<tr><td bgcolor="#f0f0f0" style="font-size:0;line-height:0;background-color:#f0f0f0;">${r(`<img src="${l.cover_image_url}" alt="${H(l.email_title||l.company_name||"Cover")}" width="600" height="338" style="width:100%;max-width:600px;height:338px;display:block;object-fit:cover;border:0;outline:none;text-decoration:none;" />`)}</td></tr>`:""}
63  ${l.company_logo_url?`<tr><td align="center" style="padding:${t==="minimal"?"31":"26"}px 24px 8px;"><img src="${l.company_logo_url}" alt="${H(l.company_name)}" class="email-logo" style="height:${t==="minimal"?"96":"72"}px;display:block;" /></td></tr>`:""}
64  <tr><td align="center" class="email-title" style="padding:16px 24px 6px;font-size:28px;font-weight:700;color:#111;line-height:1.25;">${H(l.email_title)}</td></tr>
65  ${l.email_subtitle?`<tr><td align="center" class="email-subtitle" style="padding:4px 24px 4px;font-size:16px;font-weight:500;color:#333;">${H(l.email_subtitle)}</td></tr>`:""}
66  ${l.email_tagline?`<tr><td align="center" class="email-tagline" style="padding:0 24px 10px;font-size:13px;color:#71717a;">${H(l.email_tagline)}</td></tr>`:""}
67  ${l.email_body?`<tr><td align="center" class="email-body" style="padding:6px 24px 18px;font-size:14px;line-height:1.6;color:#555;">${H(l.email_body)}</td></tr>`:""}
68
69  ${k}
70  ${w}
71  ${u}
72  <tr><td align="center" style="padding:16px 24px 12px;border-top:1px solid #e4e4e7;font-size:11px;color:#a1a1aa;">${H(l.company_name)}</td></tr>
73</table>
74</td></tr></table>
75</body></html>`}function H(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const Re=1200,Be=1200,ge=520,ie=680,Tt=48;function De(t){return new Promise((l,x)=>{const c=new Image;c.crossOrigin="anonymous",c.onload=()=>l(c),c.onerror=()=>x(new Error(`Failed to load image: ${t}`)),c.src=t})}function Et(t,l,x,c,p,m){t.beginPath(),t.moveTo(l+m,x),t.lineTo(l+c-m,x),t.arcTo(l+c,x,l+c,x+m,m),t.lineTo(l+c,x+p-m),t.arcTo(l+c,x+p,l+c-m,x+p,m),t.lineTo(l+m,x+p),t.arcTo(l,x+p,l,x+p-m,m),t.lineTo(l,x+m),t.arcTo(l,x,l+m,x,m),t.closePath()}function Mt(t,l,x,c,p,m,b,d,y,k){const r=Re/2,v=Be/2;t.save(),y&&(t.globalAlpha=.3,t.filter="blur(4px)"),t.translate(r-260,v-340);const g=x*Math.PI/180;t.translate(c*2,p*2),t.rotate(g),Et(t,0,0,ge,ie,Tt),t.clip();
75const w=l.naturalWidth/l.naturalHeight,j=ge/ie;let u,h,L,B;if(w>j?(h=l.naturalHeight,u=h*j,L=(l.naturalWidth-u)/2,B=0):(u=l.naturalWidth,h=u/j,L=0,B=(l.naturalHeight-h)/2),t.drawImage(l,L,B,u,h,0,0,ge,ie),!y){const s=t.createLinearGradient(0,ie,0,0);s.addColorStop(0,"rgba(0,0,0,0.8)"),s.addColorStop(.4,"rgba(0,0,0,0.2)"),s.addColorStop(1,"rgba(0,0,0,0)"),t.fillStyle=s,t.fillRect(0,0,ge,ie),t.fillStyle="#ffffff",t.font='bold 36px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',t.textBaseline="bottom";const C=ge-80,F=m.split(" "),X=[];let R="";for(const P of F){const W=R?`${R} ${P}`:P;t.measureText(W).width>C&&R?(X.push(R),R=P):R=W}R&&X.push(R);const D=X.slice(0,2);X.length>2&&(D[1]=D[1].slice(0,-3)+"...");const S=44,te=ie-(d?90:50);if(D.forEach((P,W)=>{const V=te-(D.length-1-W)*S;t.fillText(P,40,V)}),d){const V=ie-80;t.beginPath(),t.arc(40+48/2,V+48/2,48/2,0,Math.PI*2),t.fillStyle="rgba(255,255,255,0.1)",t.fill();let se=d;if(!k){const Y=document.createElement("canvas");Y.width=48,Y.height=48;const J=Y.getContext("2d");J.drawImage(d,0,0,48,48),J.globalCompositeOperation="source-in",J.fillStyle="#ffffff",J.fillRect(0,0,48,48),se=Y}t.save(),t.beginPath(),t.arc(40+48/2,V+48/2,48/2,0,Math.PI*2),t.clip(),t.drawImage(se,40,V,48,48),t.restore(),t.fillStyle="rgba(255,255,255,0.8)",t.font='500 24px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',t.textBaseline="middle",t.fillText(b,104,V+48/2)}else t.fillStyle="rgba(255,255,255,0.7)",t.font='20px -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',t.textBaseline="bottom",t.fillText(b,40,ie-40)}t.restore()}async function Lt(t){const{imageUrls:l,galleryTitle:x,companyName:c,companyLogoUrl:p,isLightLogo:m}=t;if(l.length===0)throw new Error("At least one image URL is required");const b=l.map(j=>De(j).catch(()=>null));p&&b.push(De(p).catch(()=>null));const d=await Promise.all(b),y=d.slice(0,l.length).filter(Boolean),k=p?d[l.length]:null;if(y.length===0)throw new Error("Failed to load any images");const r=document.createElement("canvas");r.width=Re,r.height=Be;const v=r.getContext("2d");if(!v)throw new Error("Canvas context unavailable");v.fillStyle="#fafafa",v.fillRect(0,0,Re,Be);const w=[...[{rotate:-18,tx:-60,ty:-10,zIndex:10,isGhost:!0},{rotate:8,tx:80,ty:70,zIndex:20},{rotate:-12,tx:-30,ty:-70,zIndex:30}]].sort((j,u)=>j.zIndex-u.zIndex);for(const j of w){const u=j.isGhost||j.zIndex===30?0:1,h=y[u]||y[0];Mt(v,h,j.rotate,j.tx,j.ty,x,c,k,j.isGhost,m)}return new Promise((j,u)=>{r.toBlob(h=>{h?j(h):u(new Error("Failed to create blob"))},"image/jpeg",.92)})}const At=[{id:"classic",name:"Classic",description:"Clean layout with hero image"},{id:"minimal",name:"Minimal",description:"Simple and elegant"},{id:"cards",name:"Cards",description:"Stacked cards with gallery art"}];function we({type:t,galleryContext:l,companyName:x,onSelect:c}){const[p,m]=_.useState(!1),[b,d]=_.useState(!1),[y,k]=_.useState([]),[r,v]=_.useState(null),g=async()=>{d(!0),v(null),k([]);try{const{data:u,error:h}=await E.functions.invoke("generate-email-copy",{body:{type:t,gallery_title:(l==null?void 0:l.title)||"",company_name:x,location:(l==null?void 0:l.location)||null,date:(l==null?void 0:l.date)||null,media_count:(l==null?void 0:l.media_count)||0,category:(l==null?void 0:l.category)||null}});if(h)throw new Error(h.message);if(u!=null&&u.error)throw new Error(u.error);if(!(u!=null&&u.suggestions))throw new Error("No suggestions returned");k(u.suggestions)}catch(u){v(u.message||"Failed to generate suggestions")}finally{d(!1)}},w=u=>{m(u),u&&y.length===0&&!b&&g()},j=u=>{c(u),m(!1)};return e.jsxs(Oe,{open:p,onOpenChange:w,children:[e.jsx(Ke,{asChild:!0,children:e.jsxs(de,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs gap-1 text-muted-foreground hover:text-primary",children:[e.jsx(gt,{className:"h-3 w-3"}),"Generate"]})}),e.jsx(Je,{className:"w-[640px] p-3",align:"start",children:e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground",children:"AI Suggestions"}),!b&&y.length>0&&e.jsx(de,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px]",onClick:g,children:"Regenerate"})]}),b&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(Te,{className:"h-14 w-full"}),e.jsx(Te,{className:"h-14 w-full"}),e.jsx(Te,{className:"h-14 w-full"})]}),r&&e.jsxs("div",{className:"text-xs text-destructive p-2 bg-destructive/10 rounded",children:[r,e.jsx(de,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-2 text-[10px] mt-1 block",onClick:g,children:"Try Again"})]}),!b&&!r&&y.map((u,h)=>e.jsx("button",{onClick:()=>j(u),className:"w-full text-left p-2.5 rounded-md border border-border hover:border-primary hover:bg-primary/5 transition-all text-sm leading-snug",children:u},h))]})})]})}const It=({data:t,mediaItems:l,selectedMediaIds:x,mediaSlots:c,cardMediaIds:p,templateId:m,galleryContext:b,onDataChange:d,onToggleMedia:y,onToggleCardMedia:k,onTemplateChange:r})=>{var W,V,se,Y,J,le,Q,Z,me,ce,ne,he;const[v,g]=_.useState("desktop"),w=v==="mobile",u=(c?c.filter(i=>!!i):x).map(i=>l.find(z=>z.id===i)).filter(i=>!!i),h=l.filter(i=>p.includes(i.id)),L=_.useRef(null),[B,s]=_.useState(0);_.useEffect(()=>{const i=L.current;if(!i)return;const z=new ResizeObserver(([q])=>{s(q.contentRect.height)});return z.observe(i),()=>z.disconnect()},[]);const C=400-t.email_body.length,F=_.useRef(null),X=_.useRef(null),R=_.useRef(null),D=_.useRef(null),S=_.useCallback(()=>{const i=F.current;i&&(i.style.height="auto",i.style.height=i.scrollHeight+"px")},[]),te=_.useCallback(()=>{const i=R.current;i&&(i.style.height="auto",i.style.height=i.scrollHeight+"px")},[]),P=_.useCallback(()=>{const i=X.current;i&&(i.style.height="auto",i.style.height=i.scrollHeight+"px")},[]);return _.useEffect(()=>{S()},[t.email_title,w,S]),_.useEffect(()=>{te()},[t.email_body,w,te]),_.useEffect(()=>{P()},[t.email_subtitle,w,P]),_.useEffect(()=>{t.email_title.length>50&&d("email_title",t.email_title.slice(0,50))},[]),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium mb-2",children:"Template"}),e.jsx("div",{className:"grid grid-cols-3 gap-3 w-full",children:At.map(i=>e.jsxs("button",{onClick:()=>r(i.id),className:`flex flex-col items-start p-3 rounded-lg border-2 transition-all text-left w-full ${m===i.id?"border-primary bg-primary/5":"border-border hover:border-primary/40"}`,children:[e.jsx("span",{className:"text-sm font-medium",children:i.name}),e.jsx("span",{className:"text-xs text-muted-foreground",children:i.description})]},i.id))})]}),e.jsx("div",{className:"flex items-center justify-center",children:e.jsxs("div",{className:"inline-flex h-10 items-center rounded-lg bg-muted p-1 w-1/2",children:[e.jsxs("button",{onClick:()=>g("desktop"),className:`flex-1 inline-flex items-center justify-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${v==="desktop"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(mt,{className:"h-4 w-4"}),"Desktop"]}),e.jsxs("button",{onClick:()=>g("mobile"),className:`flex-1 inline-flex items-center justify-center gap-2 rounded-md px-3 py-1.5 text-sm font-medium transition-colors ${v==="mobile"?"bg-background text-foreground shadow-sm":"text-muted-foreground hover:text-foreground"}`,children:[e.jsx(ut,{className:"h-4 w-4"}),"Mobile"]})]})}),e.jsx("div",{className:"bg-muted/30 rounded-xl p-6 flex justify-center",children:e.jsxs("div",{className:`w-full flex gap-4 items-start transition-all duration-300 ${w?"flex-row max-w-[800px] justify-center mx-auto":"flex-col md:flex-row max-w-[1000px]"}`,children:[e.jsx("div",{className:w?"w-[375px] mx-auto":"flex-1 min-w-0 max-w-[600px]",children:e.jsxs("div",{className:"bg-background rounded-lg shadow-lg border overflow-hidden w-full",children:[m==="cards"?e.jsx("div",{ref:L,className:"relative bg-muted/40 overflow-hidden flex items-center justify-center",style:{height:w?"400px":"600px"},children:(()=>{const i=h.slice(0,2),z=i[0]?i[0].grid_thumbnail_url||i[0].thumbnail_url||i[0].file_url:null,q=i[1]?i[1].grid_thumbnail_url||i[1].thumbnail_url||i[1].file_url:null,G=[{rotate:-12,translateX:-30,translateY:-70,zIndex:30},{rotate:8,translateX:80,translateY:70,zIndex:20}],O=[z,q];return e.jsxs("div",{className:"relative w-[420px] h-[600px]",children:[e.jsx("div",{className:"absolute w-[260px] h-[340px] rounded-3xl overflow-hidden shadow-2xl opacity-30 blur-[2px] bg-muted",style:{transform:"rotate(-18deg) translateX(-60px) translateY(-10px)",zIndex:10,left:"50%",top:"50%",marginLeft:"-130px",marginTop:"-170px"},children:z&&e.jsx("img",{src:z,alt:"",className:"w-full h-full object-cover"})}),G.map((U,K)=>e.jsxs("div",{className:"absolute w-[260px] h-[340px] rounded-3xl overflow-hidden shadow-2xl",style:{transform:`rotate(${U.rotate}deg) translateX(${U.translateX}px) translateY(${U.translateY}px)`,zIndex:U.zIndex,left:"50%",top:"50%",marginLeft:"-130px",marginTop:"-170px"},children:[O[K]?e.jsx("img",{src:O[K],alt:"",className:"absolute inset-0 w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full bg-muted",children:e.jsx(re,{className:"h-10 w-10 text-muted-foreground"})}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent"}),e.jsxs("div",{className:"absolute bottom-0 left-0 right-0 p-5",children:[e.jsx("h3",{className:"text-white font-bold text-lg leading-tight line-clamp-2 mb-3",children:(b==null?void 0:b.title)||"Gallery"}),t.company_light_logo_url||t.company_logo_url?e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:t.company_light_logo_url||t.company_logo_url,alt:t.company_name,className:`w-6 h-6 rounded-full object-contain bg-white/10 ${t.company_light_logo_url?"":"brightness-0 invert"}`}),e.jsx("span",{className:"text-white/80 text-sm font-medium",children:t.company_name})]}):e.jsx("span",{className:"text-white/80 text-sm font-medium",children:t.company_name})]})]},K))]})})()}
75):m==="minimal"?e.jsx("div",{ref:L,style:{display:"none"}}):e.jsx("div",{ref:L,className:"aspect-[16/9] bg-muted relative overflow-hidden",children:t.cover_image_url?e.jsx("img",{src:t.cover_image_url,alt:"Cover",className:"w-full h-full object-cover"}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(re,{className:"h-12 w-12 text-muted-foreground"})})}),e.jsxs("div",{className:"p-6 space-y-4",children:[t.company_logo_url&&e.jsx("div",{className:`flex justify-center pb-2 ${m==="minimal"?"pt-[5px]":""}`,children:e.jsx("img",{src:t.company_logo_url,alt:t.company_name,className:`${m==="minimal"?"h-16":"h-12"} object-contain`})}),e.jsx(fe,{ref:F,value:t.email_title,onChange:i=>{const z=i.target.value.replace(/\n/g," ");d("email_title",z.slice(0,50))},maxLength:50,style:{fontSize:w?"1.5rem":"2rem",lineHeight:"1.2"},className:"font-bold border-none shadow-none p-0 h-auto min-h-0 text-center focus-visible:ring-1 focus-visible:ring-primary rounded resize-none overflow-hidden",placeholder:"Campaign title",rows:1,onKeyDown:i=>{i.key==="Enter"&&i.preventDefault()}}),e.jsx(fe,{ref:X,value:t.email_subtitle,onChange:i=>{const z=i.target.value.replace(/\n/g," ");d("email_subtitle",z)},className:`font-medium border-none shadow-none p-0 h-auto min-h-0 resize-none overflow-hidden text-center leading-snug focus-visible:ring-1 focus-visible:ring-primary rounded ${w?"text-sm":"text-base"}`,placeholder:"Add a subtitle...",rows:1,onKeyDown:i=>{i.key==="Enter"&&i.preventDefault()}}),e.jsx(ee,{value:t.email_tagline,onChange:i=>d("email_tagline",i.target.value),className:`text-muted-foreground border-none shadow-none p-0 h-auto text-center focus-visible:ring-1 focus-visible:ring-primary rounded ${w?"text-xs":"text-sm"}`,placeholder:"Location, Date"}),e.jsx(fe,{ref:R,value:t.email_body,onChange:i=>{i.target.value.length<=400&&d("email_body",i.target.value)},className:"border-none shadow-none p-0 min-h-[60px] resize-none overflow-hidden text-center focus-visible:ring-1 focus-visible:ring-primary rounded text-sm",placeholder:"Write a short message for your audience...",rows:2}),u.length>0&&e.jsx("div",{className:"grid grid-cols-2 gap-3 pt-2",children:u.slice(0,4).map(i=>{var G;const z=i.grid_thumbnail_url||i.thumbnail_url||i.file_url,q=(G=i.file_type)==null?void 0:G.startsWith("video");return e.jsxs("div",{className:"aspect-square rounded-lg overflow-hidden bg-muted relative",children:[e.jsx("img",{src:z,alt:i.title||"",className:"w-full h-full object-cover"}),q&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/20",children:e.jsx(xt,{className:"h-6 w-6 text-white fill-white"})})]},i.id)})}),e.jsxs("div",{className:"pt-2 space-y-2",children:[e.jsx("div",{className:"bg-primary text-primary-foreground w-full rounded-md font-medium text-center text-sm py-2.5",children:t.cta_button_text||"View Gallery"}),t.cta2_button_text&&e.jsx("div",{className:"w-full py-2.5 rounded-md text-sm font-medium text-center border-2 border-primary text-primary",children:t.cta2_button_text})]}),e.jsx("p",{className:"text-[11px] text-muted-foreground text-center pt-4 border-t",children:t.company_name})]})]})}),e.jsxs("div",{className:`flex-col shrink-0 self-stretch ${w?"flex w-[200px]":"hidden md:flex w-[200px]"}`,children:[e.jsxs("div",{className:"flex flex-col gap-3",style:{paddingTop:`${B}px`},children:[e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Title"}),e.jsx(ee,{value:t.email_title,onChange:i=>d("email_title",i.target.value.replace(/\n/g," ").slice(0,50)),maxLength:50,placeholder:"Campaign title",className:"h-7 text-xs"}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:`text-[11px] tabular-nums ${t.email_title.length>40?"text-destructive":"text-muted-foreground"}`,children:[t.email_title.length,"/50"]})}),e.jsx("div",{className:"w-full bg-muted rounded-full h-1",children:e.jsx("div",{className:`h-1 rounded-full transition-all ${t.email_title.length>40?"bg-destructive":"bg-primary"}`,style:{width:`${Math.min(100,t.email_title.length/50*100)}%`}})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Subtitle"}),e.jsx(fe,{value:t.email_subtitle,onChange:i=>d("email_subtitle",i.target.value.replace(/\n/g," ")),placeholder:"Add a subtitle…",rows:2,className:"text-xs min-h-[44px] resize-none"}),e.jsx(we,{type:"subtitle",galleryContext:b,companyName:t.company_name,onSelect:i=>d("email_subtitle",i)})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Body"}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:`text-[11px] tabular-nums ${C<50?"text-destructive":"text-muted-foreground"}`,children:[t.email_body.length,"/400"]})}),e.jsx("div",{className:"w-full bg-muted rounded-full h-1",children:e.jsx("div",{className:`h-1 rounded-full transition-all ${C<50?"bg-destructive":"bg-primary"}`,style:{width:`${Math.min(100,t.email_body.length/400*100)}%`}})}),e.jsx(we,{type:"body",galleryContext:b,companyName:t.company_name,onSelect:i=>d("email_body",i)})]})]}),e.jsxs("div",{className:"mt-3 rounded-lg border bg-card p-3 shadow-sm space-y-1.5",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Media"}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[x.length,"/4 selected"]})}),e.jsxs("button",{onClick:()=>{var i;return(i=D.current)==null?void 0:i.scrollIntoView({behavior:"smooth",block:"center"})},className:"flex items-center gap-1.5 text-[11px] text-primary hover:underline",children:[e.jsx(Fe,{className:"h-3 w-3"})," Edit selection"]})]}),e.jsxs("div",{className:"mt-3 flex flex-col gap-3 pb-12",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-medium text-foreground",children:["Button ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(Main Link)"})]}),e.jsx(ee,{value:t.cta_button_text,onChange:i=>d("cta_button_text",i.target.value.slice(0,25)),maxLength:25,placeholder:"View Gallery",className:"h-7 text-xs"}),e.jsxs(rt,{value:t.cta_button_target||"gallery",onValueChange:i=>d("cta_button_target",i),children:[e.jsx(ot,{className:"h-7 text-xs",children:e.jsx(dt,{})}),e.jsxs(ct,{children:[e.jsx(He,{value:"gallery",className:"text-xs",children:"Link to gallery"}),e.jsx(He,{value:"landing",className:"text-xs",children:"Link to landing page"})]})]}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:`text-[11px] tabular-nums ${(((W=t.cta_button_text)==null?void 0:W.length)||0)>20?"text-destructive":"text-muted-foreground"}`,children:[((V=t.cta_button_text)==null?void 0:V.length)||0,"/25"]})}),e.jsx("div",{className:"w-full bg-muted rounded-full h-1",children:e.jsx("div",{className:`h-1 rounded-full transition-all ${(((se=t.cta_button_text)==null?void 0:se.length)||0)>20?"bg-destructive":"bg-primary"}`,style:{width:`${Math.min(100,(((Y=t.cta_button_text)==null?void 0:Y.length)||0)/25*100)}%`}})})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5",children:[e.jsxs("p",{className:"text-[11px] font-medium text-foreground",children:["Secondary Button ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(optional)"})]}),e.jsx(ee,{value:t.cta2_button_text,onChange:i=>d("cta2_button_text",i.target.value.slice(0,25)),maxLength:25,placeholder:"Add second button...",className:"h-7 text-xs"}),e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs("span",{className:`text-[11px] tabular-nums ${(((J=t.cta2_button_text)==null?void 0:J.length)||0)>20?"text-destructive":"text-muted-foreground"}`,children:[((le=t.cta2_button_text)==null?void 0:le.length)||0,"/25"]})}),e.jsx("div",{className:"w-full bg-muted rounded-full h-1",children:e.jsx("div",{className:`h-1 rounded-full transition-all ${(((Q=t.cta2_button_text)==null?void 0:Q.length)||0)>20?"bg-destructive":"bg-primary"}`,style:{width:`${Math.min(100,(((Z=t.cta2_button_text)==null?void 0:Z.length)||0)/25*100)}%`}})}),e.jsx(ee,{value:t.cta2_button_url,onChange:i=>d("cta2_button_url",i.target.value),placeholder:"https://...",className:"h-7 text-xs"})]})]})]}),e.jsxs("div",{className:"flex md:hidden flex-row gap-3 w-full overflow-x-auto pb-2",children:[e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5 min-w-[150px]",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Title"}),e.jsxs("span",{className:`text-[11px] tabular-nums ${t.email_title.length>40?"text-destructive":"text-muted-foreground"}`,children:[t.email_title.length,"/50"]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1 min-w-[150px]",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Subtitle"}),e.jsx(we,{type:"subtitle",galleryContext:b,companyName:t.company_name,onSelect:i=>d("email_subtitle",i)})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5 min-w-[150px]",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Body"}),e.jsxs("span",{className:`text-[11px] tabular-nums ${C<50?"text-destructive":"text-muted-foreground"}`,children:[t.email_body.length,"/400"]}),e.jsx(we,{type:"body",galleryContext:b,companyName:t.company_name,onSelect:i=>d("email_body",i)})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5 min-w-[150px]",children:[e.jsxs("p",{className:"text-[11px] font-medium text-foreground",children:["Button ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(Gallery Link)"})]}),e.jsxs("span",{className:`text-[11px] tabular-nums ${(((me=t.cta_button_text)==null?void 0:me.length)||0)>20?"text-destructive":"text-muted-foreground"}`,children:[((ce=t.cta_button_text)==null?void 0:ce.length)||0,"/25"]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5 min-w-[150px]",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Media"}),e.jsxs("span",{className:"text-[11px] tabular-nums text-muted-foreground",children:[x.length,"/4 selected"]}),e.jsxs("button",{onClick:()=>{var i;return(i=D.current)==null?void 0:i.scrollIntoView({behavior:"smooth",block:"center"})},className:"flex items-center gap-1.5 text-[11px] text-primary hover:underline",children:[e.jsx(Fe,{className:"h-3 w-3"})," Edit selection"]})]}),e.jsxs("div",{className:"rounded-lg border bg-card p-3 shadow-sm space-y-1.5 min-w-[150px]",children:[e.jsx("p",{className:"text-[11px] font-medium text-foreground",children:"Secondary Button"}),e.jsxs("span",{className:`text-[11px] tabular-nums ${(((ne=t.cta2_button_text)==null?void 0:ne.length)||0)>20?"text-destructive":"text-muted-foreground"}`,children:[((he=t.cta2_button_text)==null?void 0:he.length)||0,"/25"]})]})]})]})}),m==="cards"&&l.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium mb-2",children:["Select 2 images for the cards ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(up to 2)"})]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-2",children:l.map(i=>{var U;const z=i.grid_thumbnail_url||i.thumbnail_url||i.file_url,q=p.includes(i.id),G=(U=i.file_type)==null?void 0:U.startsWith("video"),O=q||p.length<2;return e.jsxs("button",{onClick:()=>O&&k(i.id),disabled:!O,className:`aspect-square rounded-md overflow-hidden relative border-2 transition-all ${q?"border-primary ring-1 ring-primary":"border-transparent hover:border-primary/40"} ${O?"cursor-pointer":"opacity-40 cursor-not-allowed"}`,children:[e.jsx("img",{src:z,alt:"",className:"w-full h-full object-cover"}),G&&e.jsx(oe,{variant:"secondary",className:"absolute bottom-0.5 left-0.5 text-[9px] px-1 py-0",children:"Video"}),q&&e.jsx("div",{className:"absolute top-0.5 right-0.5 bg-primary text-primary-foreground rounded-full p-0.5",children:e.jsx(Ie,{className:"h-3 w-3"})})]},i.id)})})]}),l.length>0&&e.jsxs("div",{ref:D,children:[e.jsxs("p",{className:"text-sm font-medium mb-2",children:["Select media to feature ",e.jsx("span",{className:"text-muted-foreground font-normal",children:"(up to 4)"})]}),e.jsx("div",{className:"grid grid-cols-4 sm:grid-cols-6 md:grid-cols-8 gap-2",children:l.map(i=>{var K;const z=i.grid_thumbnail_url||i.thumbnail_url||i.file_url,q=c?c.indexOf(i.id):x.indexOf(i.id),G=q!==-1,O=c?c.filter(
75Boolean).length:x.length,U=G||O<4;return e.jsxs("button",{onClick:()=>U&&y(i.id),disabled:!U,className:`aspect-square rounded-md overflow-hidden relative border-2 transition-all ${G?"border-primary ring-1 ring-primary":"border-transparent hover:border-primary/40"} ${U?"cursor-pointer":"opacity-40 cursor-not-allowed"}`,children:[e.jsx("img",{src:z,alt:"",className:"w-full h-full object-cover"}),((K=i.file_type)==null?void 0:K.startsWith("video"))&&e.jsx(oe,{variant:"secondary",className:"absolute bottom-0.5 left-0.5 text-[9px] px-1 py-0",children:"Video"}),G&&e.jsx("div",{className:"absolute top-0.5 right-0.5 bg-primary text-primary-foreground rounded-full h-5 w-5 flex items-center justify-center text-[10px] font-semibold tabular-nums shadow",children:q+1})]},i.id)})})]})]})},Ae=["Gallery","Setup","Content","Audience","Review"],xs=()=>{const t=Qe(),{campaignId:l}=Ze(),x=!!l,{createCampaign:c,updateCampaign:p}=it(),[m,b]=_.useState(l||null),[d,y]=_.useState(!1),{data:k}=nt(),{company:r}=et(),{language:v}=tt(),[g,w]=_.useState(x?2:0),[j,u]=_.useState(!1),{data:h,isLoading:L}=_e({queryKey:["campaign-galleries",r==null?void 0:r.id],queryFn:async()=>{if(!(r!=null&&r.id))return[];const{data:a,error:n}=await E.from("galleries").select("id, title, location, date, cover_image_url, status, slug").eq("company_id",r.id).eq("status","published").order("created_at",{ascending:!1});if(n)throw n;return a||[]},enabled:!!(r!=null&&r.id),refetchOnMount:"always",staleTime:0}),{data:B}=_e({queryKey:["campaign-gallery-affinity-counts",r==null?void 0:r.id,h==null?void 0:h.map(a=>a.id).join(",")],queryFn:async()=>{if(!h||h.length===0)return{};const a={};return await Promise.all(h.map(async n=>{const{count:o}=await E.from("fan_gallery_affinity").select("id",{count:"exact",head:!0}).eq("gallery_id",n.id);a[n.id]=o||0})),a},enabled:!!h&&h.length>0,staleTime:6e4}),[s,C]=_.useState({gallery_id:"",name:"",subject:"",preview_text:"",from_name:"",audience_ids:[],segment_ids:[],source_gallery_ids:[],template_id:"classic",email_title:"",email_tagline:"",email_subtitle:"",email_body:"",selected_media_ids:[],media_slots:[null,null,null,null],card_media_ids:[],cta_button_text:"",cta_button_target:"gallery",cta2_button_text:"",cta2_button_url:""}),[F,X]=_.useState([]),[R,D]=_.useState(null),[S,te]=_.useState(void 0),[P,W]=_.useState(null),[V,se]=_.useState(null),{senderEmail:Y,hasCustomDomain:J}=ft(s.from_name),{data:le}=_e({queryKey:["campaign-edit",l],queryFn:async()=>{if(!l)return null;const{data:a,error:n}=await E.from("email_campaigns").select("*, audiences(name)").eq("id",l).single();if(n)throw n;return a},enabled:!!l});_.useEffect(()=>{if(!le||j)return;(async()=>{const n=le.gallery_id;if(n){const{data:f}=await E.from("galleries").select("id, title, location, date, cover_image_url, slug").eq("id",n).maybeSingle();if(f){D(f.cover_image_url||null),W(f.slug||null),te({title:f.title,location:f.location||null,date:f.date||null,media_count:0});const{data:$}=await E.from("gallery_items").select("id, file_url, file_type, thumbnail_url, grid_thumbnail_url, title, sort_order").eq("gallery_id",f.id).order("sort_order",{ascending:!0}),T=$||[];X(T),te(M=>M&&{...M,media_count:T.length})}}const o=le;o.card_hero_image_url&&se(o.card_hero_image_url);const N=S!=null&&S.date?Ce(S.date,v):"",A=[S==null?void 0:S.location,N].filter(Boolean).join(", ");if(C(f=>{var $,T,M,I;return{...f,gallery_id:o.gallery_id||"",name:o.name,subject:o.subject,preview_text:o.preview_text||"",from_name:o.from_name||"",audience_ids:[],segment_ids:[],source_gallery_ids:o.source_gallery_ids||[],template_id:o.template_id||"classic",email_title:o.email_title||o.name,email_tagline:o.email_tagline||A,email_subtitle:o.email_subtitle||"",email_body:o.email_body||"",selected_media_ids:o.selected_media_ids||[],media_slots:[(($=o.selected_media_ids)==null?void 0:$[0])??null,((T=o.selected_media_ids)==null?void 0:T[1])??null,((M=o.selected_media_ids)==null?void 0:M[2])??null,((I=o.selected_media_ids)==null?void 0:I[3])??null],card_media_ids:o.card_media_ids||[],cta_button_text:o.cta_button_text||"",cta_button_target:o.cta_button_target||"gallery",cta2_button_text:o.cta2_button_text||"",cta2_button_url:o.cta2_button_url||""}}),l){const{data:f}=await E.from("campaign_audiences").select("audience_id").eq("campaign_id",l);f&&f.length>0?C(T=>({...T,audience_ids:f.map(M=>M.audience_id)})):o.audience_id&&C(T=>({...T,audience_ids:[o.audience_id]}));const{data:$}=await E.from("campaign_segments").select("fan_segment_id").eq("campaign_id",l);$&&$.length>0&&C(T=>({...T,segment_ids:$.map(M=>M.fan_segment_id)}))}u(!0)})()},[le,j,v]);const Q=(a,n)=>C(o=>({...o,[a]:n})),Z=(k==null?void 0:k.filter(a=>s.audience_ids.includes(a.id)))||[],me=Z.reduce((a,n)=>a+(n.contact_count||0),0),{data:ce}=_e({queryKey:["campaign-gallery-segments",r==null?void 0:r.id],queryFn:async()=>
75{if(!(r!=null&&r.id))return[];const{data:a,error:n}=await E.from("fan_segments").select("id, name, description, member_count, segment_type").eq("company_id",r.id).eq("segment_type","gallery_metadata").order("name");if(n)throw n;return a||[]},enabled:!!(r!=null&&r.id)}),ne=(ce||[]).filter(a=>s.segment_ids.includes(a.id));ne.reduce((a,n)=>a+(n.member_count||0),0);const he=a=>{C(n=>{const o=n.segment_ids.includes(a)?n.segment_ids.filter(N=>N!==a):[...n.segment_ids,a];return{...n,segment_ids:o}})},i=a=>{C(n=>{const o=n.audience_ids.includes(a)?n.audience_ids.filter(N=>N!==a):[...n.audience_ids,a];return{...n,audience_ids:o}})},z=a=>{C(n=>{const o=n.source_gallery_ids.includes(a)?n.source_gallery_ids.filter(N=>N!==a):[...n.source_gallery_ids,a];return{...n,source_gallery_ids:o}})},q=async a=>{const n=a.date?Ce(a.date,v):"",o=[a.location,n].filter(Boolean).join(", "),N={gallery_id:a.id,name:a.title,from_name:(r==null?void 0:r.name)||"",subject:`Your highlights are waiting - ${a.title}`,preview_text:o,email_title:a.title,email_tagline:o,email_subtitle:"",email_body:"",selected_media_ids:[],media_slots:[null,null,null,null],card_media_ids:[],template_id:s.template_id,audience_ids:s.audience_ids,segment_ids:s.segment_ids,source_gallery_ids:s.source_gallery_ids,cta_button_text:"",cta_button_target:"gallery",cta2_button_text:"",cta2_button_url:""};C(N),D(a.cover_image_url||null),W(a.slug||null);const{data:A}=await E.from("gallery_items").select("id, file_url, file_type, thumbnail_url, grid_thumbnail_url, title, sort_order").eq("gallery_id",a.id).order("sort_order",{ascending:!0}),f=A||[],T=f.filter(I=>{var ae;return!((ae=I.file_type)!=null&&ae.startsWith("video"))}).slice(0,2).map(I=>I.id);N.card_media_ids=T;const M=f.slice(0,4).map(I=>I.id);N.selected_media_ids=M,N.media_slots=[M[0]??null,M[1]??null,M[2]??null,M[3]??null],X(f),te({title:a.title,location:a.location||null,date:a.date||null,media_count:f.length})},G=async()=>{y(!0);try{if(g===0){const n={name:s.name,subject:s.subject,preview_text:s.preview_text||null,from_name:s.from_name||null,gallery_id:s.gallery_id||null,template_id:s.template_id,email_title:s.email_title,email_tagline:s.email_tagline,email_subtitle:s.email_subtitle||null,email_body:s.email_body||null,selected_media_ids:s.selected_media_ids,card_media_ids:s.card_media_ids};if(m)await p.mutateAsync({id:m,...n});else{const o=await c.mutateAsync({...n,html_content:""});b(o.id)}w(1);return}if(!m)throw new Error("No draft ID");const a={id:m,name:s.name,subject:s.subject,preview_text:s.preview_text||null,from_name:s.from_name||null,gallery_id:s.gallery_id||null,template_id:s.template_id,email_title:s.email_title,email_tagline:s.email_tagline,email_subtitle:s.email_subtitle||null,email_body:s.email_body||null,selected_media_ids:s.selected_media_ids,card_media_ids:s.card_media_ids,cta_button_text:s.cta_button_text||null,cta_button_target:s.cta_button_target||"gallery",cta2_button_text:s.cta2_button_text||null,cta2_button_url:s.cta2_button_url||null};if(g===2){let n=V;if(s.template_id==="cards"&&s.card_media_ids.length>0)try{const M=F.filter(I=>s.card_media_ids.includes(I.id)).map(I=>{var ae;return I.grid_thumbnail_url||I.thumbnail_url||((ae=I.file_type)!=null&&ae.startsWith("video")?null:I.file_url)}).filter(Boolean);if(M.length>0){const I=await Lt({imageUrls:M,galleryTitle:(S==null?void 0:S.title)||s.email_title,companyName:(r==null?void 0:r.name)||"",companyLogoUrl:(r==null?void 0:r.light_logo_url)||(r==null?void 0:r.logo_url),isLightLogo:!!(r!=null&&r.light_logo_url)}),ae=`campaigns/${m}/card-hero.jpg`,{error:Ye}=await E.storage.from("thumbnails").upload(ae,I,{contentType:"image/jpeg",upsert:!0});if(!Ye){const{data:Xe}=E.storage.from("thumbnails").getPublicUrl(ae);n=`${Xe.publicUrl}?t=${Date.now()}`,se(n),a.card_hero_image_url=n}}}catch(T){console.error("Failed to render card hero image:",T)}const o=F.filter(T=>s.selected_media_ids.includes(T.id)),N=F.filter(T=>s.card_media_ids.includes(T.id)),A=(r==null?void 0:r.slug)||"",f=P&&A?`${je()}/${A}/highlights/${P}`:void 0,$=A?`${je()}/${A}`:void 0;a.html_content=Ve({templateId:s.template_id,data:pe,selectedMedia:o,cardMedia:N,galleryUrl:f,landingUrl:$,galleryContext:S?{title:S.title}:void 0,cardHeroImageUrl:n||void 0})}else g===3&&(a.audience_id=s.audience_ids[0]||null,a.source_gallery_ids=s.source_gallery_ids,m&&(await E.from("campaign_audiences").delete().eq("campaign_id",m),s.audience_ids.length>0&&await E.from("campaign_audiences").insert(s.audience_ids.map(n=>({campaign_id:m,audience_id:n}))),await E.from("campaign_segments").delete().eq("campaign_id",m),s.segment_ids.length>0&&await E.from("campaign_segments").insert(s.segment_ids.map(n=>({campaign_id:m,fan_segment_id:n})))));await p.mutateAsync(a),be.success("Draft saved"),w(g+1)}catch{be.error("Failed to save progress")}finally{y(!1)}},O=a=>{C(n=>{const o=[...n.media_slots],N=o.indexOf(a);if(N!==-1)o[N]=null;else{const A=o.indexOf(null);if(A===-1)return n;o[A]=a}return{...n,media_slots:o,selected_media_ids:o.filter(A=>!!A)}})},U=a=>{C(n=>{const o=n.card_media_ids.includes(a)?n.card_media_ids.filter(N=>N!==a):[...n.card_media_ids,a].slice(0,2);return{...n,card_media_ids:o}})},K=R?ze(R).social:null;R&&K!==R&&console.info("[Campaign][CoverEmail] using optimized variant:",K
75);const pe={email_title:s.email_title,email_tagline:s.email_tagline,email_subtitle:s.email_subtitle,email_body:s.email_body,cta_button_text:s.cta_button_text,cta_button_target:s.cta_button_target,cta2_button_text:s.cta2_button_text,cta2_button_url:s.cta2_button_url,cover_image_url:K,company_name:(r==null?void 0:r.name)||"",company_logo_url:(r==null?void 0:r.logo_url)||null,company_light_logo_url:(r==null?void 0:r.light_logo_url)||null},Ne=()=>g===0?!!s.gallery_id:g===1?s.name.trim()&&s.subject.trim():g===2?s.email_title.trim():g===3?s.audience_ids.length>0||s.segment_ids.length>0||s.source_gallery_ids.length>0:!0,Pe=async()=>{if(m){y(!0);try{const a=F.filter($=>s.selected_media_ids.includes($.id)),n=F.filter($=>s.card_media_ids.includes($.id)),o=(r==null?void 0:r.slug)||"",N=P&&o?`${je()}/${o}/highlights/${P}`:void 0,A=o?`${je()}/${o}`:void 0,f=Ve({templateId:s.template_id,data:pe,selectedMedia:a,cardMedia:n,galleryUrl:N,landingUrl:A,galleryContext:S?{title:S.title}:void 0,cardHeroImageUrl:V||void 0});await p.mutateAsync({id:m,name:s.name,subject:s.subject,preview_text:s.preview_text||null,from_name:s.from_name||null,html_content:f,audience_id:s.audience_ids[0]||null,source_gallery_ids:s.source_gallery_ids,gallery_id:s.gallery_id||null,template_id:s.template_id,email_title:s.email_title,email_tagline:s.email_tagline,email_subtitle:s.email_subtitle||null,email_body:s.email_body||null,selected_media_ids:s.selected_media_ids,card_media_ids:s.card_media_ids}),await E.from("campaign_audiences").delete().eq("campaign_id",m),s.audience_ids.length>0&&await E.from("campaign_audiences").insert(s.audience_ids.map($=>({campaign_id:m,audience_id:$}))),await E.from("campaign_segments").delete().eq("campaign_id",m),s.segment_ids.length>0&&await E.from("campaign_segments").insert(s.segment_ids.map($=>({campaign_id:m,fan_segment_id:$}))),be.success("Campaign saved"),t(`/admin/campaigns/${m}`)}catch{be.error("Failed to save campaign")}finally{y(!1)}}};return e.jsxs("div",{className:"space-y-6 max-w-4xl mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(de,{"aria-label":"Back",title:"Back",variant:"ghost",size:"icon",onClick:()=>t(x?`/admin/campaigns/${l}`:"/admin/campaigns"),children:e.jsx($e,{className:"h-4 w-4"})}),e.jsxs("h1",{className:"text-2xl font-bold",children:[x?"Edit Campaign":"New Campaign",g>=2&&s.name.trim()&&e.jsxs("span",{className:"text-muted-foreground font-normal",children:[" — ",s.name]})]})]}),e.jsx("div",{className:"flex items-center gap-2",children:Ae.map((a,n)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:`flex items-center justify-center w-8 h-8 rounded-full text-sm font-medium ${n<g||n===g?"bg-primary text-primary-foreground":"bg-muted text-muted-foreground"}`,children:n<g?e.jsx(Ie,{className:"h-4 w-4"}):n+1}),e.jsx("span",{className:`text-sm ${n===g?"font-bold text-foreground":n<g?"font-bold text-muted-foreground":"text-muted-foreground"}`,children:a}),n<Ae.length-1&&e.jsx("div",{className:"w-8 h-px bg-border"})]},a))}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(de,{variant:"outline",onClick:()=>g>0?w(g-1):t("/admin/campaigns"),children:[e.jsx($e,{className:"h-4 w-4 mr-2"}),g===0?"Cancel":"Back"]}),g<Ae.length-1?Ne()&&!d?e.jsxs(qe,{onClick:G,children:["Next ",e.jsx(ve,{className:"h-4 w-4 ml-2"})]}):e.jsxs(de,{onClick:G,disabled:!Ne()||d,children:[d?"Saving...":"Next",e.jsx(ve,{className:"h-4 w-4 ml-2"})]}):Ne()&&!d?e.jsxs(qe,{onClick:Pe,children:["Next ",e.jsx(ve,{className:"h-4 w-4 ml-2"})]}):e.jsxs(de,{onClick:Pe,disabled:d,children:[d?"Saving...":"Next",e.jsx(ve,{className:"h-4 w-4 ml-2"})]})]}),g===0&&e.jsxs("div",{className:"space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Select a gallery to create a campaign for."}),L?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Loading galleries..."}):h!=null&&h.length?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:h.map(a=>e.jsxs(ue,{className:`cursor-pointer transition-all hover:shadow-md ${s.gallery_id===a.id?"ring-2 ring-primary border-primary":"hover:border-primary/50"}`,onClick:()=>q(a),children:[e.jsxs("div",{className:"aspect-video relative overflow-hidden rounded-t-lg bg-muted",children:[a.cover_image_url?e.jsx("img",{src:ze(a.cover_image_url).thumbnail,alt:a.title,className:"w-full h-full object-cover",loading:"lazy",onError:n=>{const o=n.currentTarget;!o.dataset.fallback&&a.cover_image_url&&(o.dataset.fallback="1",o.src=a.c
75over_image_url)}}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(re,{className:"h-8 w-8 text-muted-foreground"})}),s.gallery_id===a.id&&e.jsx("div",{className:"absolute top-2 right-2 bg-primary text-primary-foreground rounded-full p-1",children:e.jsx(Ie,{className:"h-4 w-4"})})]}),e.jsxs(xe,{className:"p-3 space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.title}),e.jsx(oe,{variant:a.status==="published"?"default":"secondary",className:"text-xs ml-2 shrink-0 capitalize",children:a.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[a.location&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(jt,{className:"h-3 w-3"}),a.location]}),a.date&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(yt,{className:"h-3 w-3"}),Ce(a.date,v)]})]})]})]},a.id))}):e.jsx(ue,{children:e.jsxs(xe,{className:"py-12 text-center",children:[e.jsx(re,{className:"h-10 w-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground",children:"No galleries found. Create a gallery first."})]})})]}),g===1&&e.jsxs(ue,{children:[e.jsx(Se,{children:e.jsx(ke,{children:"Campaign Setup"})}),e.jsxs(xe,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(ye,{children:"Campaign Name *"}),e.jsx(ee,{value:s.name,onChange:a=>Q("name",a.target.value),placeholder:"e.g., March Newsletter"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Subject Line *"}),e.jsx(ee,{value:s.subject,onChange:a=>Q("subject",a.target.value),placeholder:"e.g., Check out our latest updates"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"Preview Text"}),e.jsx(ee,{value:s.preview_text,onChange:a=>Q("preview_text",a.target.value),placeholder:"Text shown after subject in inbox"})]}),e.jsxs("div",{children:[e.jsx(ye,{children:"From Name"}),e.jsx(ee,{value:s.from_name,onChange:a=>Q("from_name",a.target.value),placeholder:"e.g., Your Brand Name"})]}),e.jsx("div",{className:"flex items-start gap-2 px-1",children:J?e.jsxs(e.Fragment,{children:[e.jsx(vt,{className:"h-4 w-4 text-green-500 mt-0.5 shrink-0"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Emails will be sent from ",e.jsx("span",{className:"font-medium text-foreground",children:Y})]}),e.jsx(Ge,{variant:"badge",className:"shrink-0"})]}):e.jsxs(e.Fragment,{children:[e.jsx(wt,{className:"h-4 w-4 text-primary mt-0.5 shrink-0"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Emails will be sent from ",e.jsx("span",{className:"font-medium text-foreground",children:Y}),e.jsxs("a",{href:"/admin/settings/integrations",className:"ml-1.5 inline-flex items-center gap-1 text-primary hover:underline text-xs",children:["Configure custom domain ",e.jsx(st,{className:"h-3 w-3"})]})]})]})})]})]}),g===2&&e.jsx(It,{data:pe,mediaItems:F,selectedMediaIds:s.selected_media_ids,mediaSlots:s.media_slots,cardMediaIds:s.card_media_ids,templateId:s.template_id,galleryContext:S,onDataChange:(a,n)=>Q(a,n),onToggleMedia:O,onToggleCardMedia:U,onTemplateChange:a=>Q("template_id",a)}),g===3&&e.jsxs(ue,{children:[e.jsx(Se,{children:e.jsx(ke,{children:"Select Recipients"})}),e.jsxs(xe,{className:"space-y-4",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pick audiences and/or gallery-metadata segments. Recipients are de-duplicated by email."}),e.jsxs(ht,{defaultValue:"audiences",className:"w-full",children:[e.jsxs(pt,{children:[e.jsxs(Me,{value:"audiences",children:[e.jsx(Ue,{className:"h-4 w-4 mr-1.5"})," Audiences (",s.audience_ids.length,")"]}),e.jsxs(Me,{value:"segments",children:[e.jsx(re,{className:"h-4 w-4 mr-1.5"})," Gallery Segments (",s.segment_ids.length,")"]}),e.jsxs(Me,{value:"galleries",children:[e.jsx(re,{className:"h-4 w-4 mr-1.5"})," Galleries (",s.source_gallery_ids.length,")"]})]}),e.jsxs(Le,{value:"audiences",className:"space-y-2 mt-4",children:[(k||[]).length===0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"No audiences yet."}),(k||[]).map(a=>e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${s.audience_ids.includes(a.id)?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,children:[e.jsx(Ee,{checked:s.audience_ids.includes(a.id),onCheckedChange:()=>i(a.id)}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:a.name}),a.description&&e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["— ",a.description]}),a.type==="imported"&&e.jsx(oe,{variant:"secondary",className:"text-xs shrink-0",children:"Imported"})]}),e.jsxs(oe,{variant:"outline",className:"text-xs shrink-0",children:[a.contact_count," contacts"]})]},a.id))]}),e.jsx(Le,{value:"segments",className:"space-y-2 mt-4",children:(ce||[]).length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No gallery segments yet. Create one in Fan Segments to target fans by artist, country, location, tags or interaction."}):(ce||[]).map(a=>e.jsxs("label",{className:`flex items-center gap-3 p-3 rounded-lg border cursor-pointer transition-colors ${s.segment_ids.includes(a.id)?"border-primary bg-primary/5":"border-border hover:border-primary/50"}`,children:[e.jsx(Ee,{checked:s.segment_ids.includes(a.id),onCheckedChange:()=>he(a.id)}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx("span",{className:"font-medium text-sm truncate",children:a.name}),a.description&&e.jsxs("span",{className:"text-xs text-muted-foreground truncate",children:["— ",a.description]})]}),e.jsxs(oe,{variant:"outline",className:"text-xs shrink-0",children:[a.member_count," fans"]})]},a.id))}),e.jsxs(Le,{value:"galleries",className:"space-y-3 mt-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"Send to every fan with affinity to the selected galleries. Takes precedence over Audiences and Segments (duplicates collapse to this source)."}),(h||[]).length===0?e.jsx("p",{className:"text-xs text-muted-foreground",children:"No published galleries yet."}):e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:(h||[]).map(a=>{const n=s.source_gallery_ids.includes(a.id),o=ze(a.cover_image_url).medium,N=(B==null?void 0:B[a.id])??0;return e.jsxs("label",{className:`relative flex flex-col rounded-lg border overflow-hidden cursor-pointer transition-colors ${n?"border-primary ring-2 ring-primary/30":"border-border hover:border-primary/50"}`,children:[e.jsx("div",{className:"absolute top-2 left-2 z-10",children:e.jsx(Ee,{checked:n,onCheckedChange:()=>z(a.id),className:"bg-background/90 backdrop-blur"})}),e.jsx("div",{className:"aspect-video bg-muted overflow-hidden",children:o?e.jsx("img",{src:o,alt:a.title,loading:"lazy",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-muted-foreground",children:e.jsx(re,{className:"h-8 w-8"})})}),e.jsxs("div",{className:"p-3 space-y-1",children:[e.jsx("p",{className:"font-medium text-sm truncate",children:a.title}),e.jsxs("div",{className:"flex items-center justify-between text-xs text-muted-foreground",children:[e.jsx("span",{className:"truncate",children:a.location||"—"}),e.jsxs(oe,{variant:"outline",className:"text-xs shrink-0",children:[N," fans"]})]})]})]},a.id)})})]})]}),(Z.length>0||ne.length>0||s.source_gallery_ids.length>0)&&e.jsxs("div",{className:"flex items-start gap-2 p-3 bg-muted rounded-lg",children:[e.jsx(Ue,{className:"h-5 w-5 text-muted-foreground mt-0.5"}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-medium text-sm",children:[s.source_gallery_ids.length," gallery shortcut",s.source_gallery_ids.length!==1?"s":""," · ",ne.length," segment",ne.length!==1?"s":""," · ",Z.length," audience",Z.length!==1?"s":""]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Precedence: Gallery shortcut > Segment > Audience. Exact total is computed on the Review step."})]})]})]})]}),g===4&&(()=>{const a=s.selected_media_ids.map(f=>F.find($=>
75$.id===f)).filter(Boolean),n=s.card_media_ids.map(f=>F.find($=>$.id===f)).filter(Boolean),o=s.from_name||(r==null?void 0:r.name)||"Your Brand",A=new Date().toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});return e.jsxs("div",{className:"space-y-6",children:[e.jsx(Ge,{}),e.jsxs(ue,{children:[e.jsx(Se,{children:e.jsx(ke,{children:"Review Campaign"})}),e.jsxs(xe,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Campaign Name"}),e.jsx("p",{className:"font-medium",children:s.name})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Subject"}),e.jsx("p",{className:"font-medium",children:s.subject})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"From"}),e.jsx("p",{className:"font-medium",children:o})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Audiences"}),e.jsxs("p",{className:"font-medium",children:[Z.map(f=>f.name).join(", ")," (",me," contacts)"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Template"}),e.jsx("p",{className:"font-medium capitalize",children:s.template_id})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Media cards"}),e.jsxs("p",{className:"font-medium",children:[s.selected_media_ids.length," selected"]})]})]}),e.jsx("div",{className:"border-t pt-4",children:e.jsx("p",{className:"text-sm text-muted-foreground mb-2",children:"This will save the campaign as a draft. You can send it from the campaign detail page."})})]})]}),e.jsxs("div",{className:"rounded-xl border bg-card shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1 px-4 py-2 border-b bg-muted/30",children:[e.jsx($e,{className:"h-4 w-4 text-muted-foreground"}),e.jsxs("div",{className:"flex items-center gap-2 ml-3",children:[e.jsx(Nt,{className:"h-4 w-4 text-muted-foreground"}),e.jsx($t,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(at,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(_t,{className:"h-4 w-4 text-muted-foreground"}),e.jsx(lt,{className:"h-4 w-4 text-muted-foreground"})]})]}),e.jsxs("div",{className:"px-5 py-4 border-b space-y-2",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold leading-tight",children:s.subject||"No subject"}),e.jsx("div",{className:"flex items-center gap-2 shrink-0 ml-4",children:e.jsx(St,{className:"h-4 w-4 text-muted-foreground"})})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-9 w-9 rounded-full bg-primary/10 flex items-center justify-center text-primary font-semibold text-sm shrink-0",children:o.charAt(0).toUpperCase()}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"font-medium text-sm",children:o}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:["<",Y,">"]})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["to ",Z.map(f=>f.name).join(", ")||"recipients"]}),e.jsxs("span",{className:"text-muted-foreground/60",children:["(",me,")"]})]})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 text-xs text-muted-foreground shrink-0",children:[e.jsx(kt,{className:"h-3 w-3"}),e.jsx("span",{children:A})]})]})]}),e.jsx("div",{className:"bg-muted/20 p-6",children:e.jsx(bt,{templateId:s.template_id,data:pe,selectedMedia:a,cardMedia:n,galleryContext:S})})]})]})})()]})};export{xs as default};

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.