@one-million-lines/email-builder 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +42 -0
- package/dist/email-builder.cjs +10 -10
- package/dist/email-builder.cjs.map +1 -1
- package/dist/email-builder.js +2530 -1684
- package/dist/email-builder.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/templates/backInStock.d.ts +3 -0
- package/dist/templates/birthdayReward.d.ts +3 -0
- package/dist/templates/postPurchaseFollowUp.d.ts +3 -0
- package/dist/templates/priceDropAlert.d.ts +3 -0
- package/dist/templates/replenishmentReminder.d.ts +3 -0
- package/dist/templates/reviewRequest.d.ts +3 -0
- package/dist/templates/vipEarlyAccess.d.ts +3 -0
- package/dist/templates/winBackCampaign.d.ts +3 -0
- package/package.json +3 -2
package/dist/email-builder.cjs
CHANGED
|
@@ -3,12 +3,12 @@ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.
|
|
|
3
3
|
<w:anchorlock/>
|
|
4
4
|
<center style="color:${a};font-family:${c};font-size:${s}px;font-weight:${l};">${d}</center>
|
|
5
5
|
</v:roundrect>
|
|
6
|
-
<![endif]-->`,h=`<!--[if !mso]><!-- --><a href="${f}"${p} style="${u}">${d}</a><!--<![endif]-->`,g=ie(t,e.style);return`<div${g?` class="${g}"`:``} style="${r}">${m}${h}</div>`}function ce(e){return`<div style="height:${e.height}px;line-height:${e.height}px;font-size:1px;mso-line-height-rule:exactly;"> </div>`}function le(e,t){let n=S(e.style??{},t.theme),r=E(n.paddingTop,8),i=E(n.paddingBottom,8),a=n.color??`#E5E7EB`;return`<div style="padding-top:${r};padding-bottom:${i};"><hr style="border:0;border-top:${n.thickness??1}px solid ${a};margin:0;height:0;" /></div>`}function O(e,t){switch(e.type){case`text`:return ae(e,t);case`image`:return oe(e,t);case`button`:return se(e,t);case`spacer`:return ce(e);case`divider`:return le(e,t);case`productGrid`:return ue(e,t)}}function ue(e,t){let n=S(e.style??{},t.theme),r=e.columns,i=e.products.slice(0,r*6),a=n.cardBackgroundColor??n.backgroundColor??`transparent`,o=n.nameColor??`{colors.text}`,s=n.finalPriceColor??`{colors.primary}`,c=n.oldPriceColor??`#9CA3AF`,l=n.buttonBackgroundColor??`{colors.buttonBackground}`,u=n.buttonColor??`{colors.buttonText}`,d=n.borderRadius??0,f=E(n.paddingTop,16),p=E(n.paddingBottom,16),m=E(n.paddingLeft,16),h=E(n.paddingRight,16),g=`${Math.floor(100/r)}%`,_=(n,r)=>{let i=`<span class="final_price" style="color:${
|
|
7
|
-
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" href="${T(_)}" style="height:36px;v-text-anchor:middle;width:140px;" arcsize="15%" stroke="f" fillcolor="${
|
|
8
|
-
<![endif]--><!--[if !mso]><!-- --><a href="${T(_)}" style="display:inline-block;padding:10px 18px;font-family:Arial,Helvetica,sans-serif;font-size:13px;font-weight:bold;color:${
|
|
9
|
-
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:${
|
|
6
|
+
<![endif]-->`,h=`<!--[if !mso]><!-- --><a href="${f}"${p} style="${u}">${d}</a><!--<![endif]-->`,g=ie(t,e.style);return`<div${g?` class="${g}"`:``} style="${r}">${m}${h}</div>`}function ce(e){return`<div style="height:${e.height}px;line-height:${e.height}px;font-size:1px;mso-line-height-rule:exactly;"> </div>`}function le(e,t){let n=S(e.style??{},t.theme),r=E(n.paddingTop,8),i=E(n.paddingBottom,8),a=n.color??`#E5E7EB`;return`<div style="padding-top:${r};padding-bottom:${i};"><hr style="border:0;border-top:${n.thickness??1}px solid ${a};margin:0;height:0;" /></div>`}function O(e,t){switch(e.type){case`text`:return ae(e,t);case`image`:return oe(e,t);case`button`:return se(e,t);case`spacer`:return ce(e);case`divider`:return le(e,t);case`productGrid`:return ue(e,t)}}function ue(e,t){let n=S(e.style??{},t.theme),r=e.columns,i=e.products.slice(0,r*6),a=n.cardBackgroundColor??n.backgroundColor??`transparent`,o=n.nameColor??`{colors.text}`,s=n.finalPriceColor??`{colors.primary}`,c=n.oldPriceColor??`#9CA3AF`,l=n.buttonBackgroundColor??`{colors.buttonBackground}`,u=n.buttonColor??`{colors.buttonText}`,d=n.borderRadius??0,f=E(n.paddingTop,16),p=E(n.paddingBottom,16),m=E(n.paddingLeft,16),h=E(n.paddingRight,16),g=`${Math.floor(100/r)}%`,_=(n,r)=>{let i=`<span class="final_price" style="color:${de(s,t.theme)};font-weight:bold;font-size:18px;">${w(n.finalPrice)}</span>`,f=e.showOldPrice&&n.oldPrice?`<span class="old_price" style="color:${de(c,t.theme)};text-decoration:line-through;font-size:14px;margin-right:8px;">${w(n.oldPrice)}</span>`:``,p=e.showDescription&&n.description?`<div style="font-family:Arial,Helvetica,sans-serif;font-size:13px;line-height:1.5;color:#6B7280;padding:0 0 12px 0;">${w(n.description)}</div>`:``,m=e.showStars&&n.stars!=null?`<div style="font-family:Arial,Helvetica,sans-serif;font-size:15px;letter-spacing:1px;color:${ee};">${te(n.stars)}</div>`:``,h=n.buttonLabel??e.buttonLabel??`Shop now`,_=n.link??`#`,v=e.showButton?`<table role="presentation" cellpadding="0" cellspacing="0" border="0" style="margin:0 auto;"><tr><td align="center" bgcolor="${de(l,t.theme)}" style="border-radius:6px;"><!--[if mso]>
|
|
7
|
+
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" href="${T(_)}" style="height:36px;v-text-anchor:middle;width:140px;" arcsize="15%" stroke="f" fillcolor="${de(l,t.theme)}"><w:anchorlock/><center style="color:${de(u,t.theme)};font-family:Arial,sans-serif;font-size:13px;font-weight:bold;">${w(h)}</center></v:roundrect>
|
|
8
|
+
<![endif]--><!--[if !mso]><!-- --><a href="${T(_)}" style="display:inline-block;padding:10px 18px;font-family:Arial,Helvetica,sans-serif;font-size:13px;font-weight:bold;color:${de(u,t.theme)};background-color:${de(l,t.theme)};border-radius:6px;text-decoration:none;">${w(h)}</a><!--<![endif]--></td></tr></table>`:``,y=`<img src="${w(n.image)}" alt="${w(n.imageAlt??n.name)}" width="100%" style="display:block;width:100%;max-width:100%;height:auto;border:0;outline:none;text-decoration:none;border-radius:${d}px;" />`,b=n.link?`<a href="${T(n.link)}" style="text-decoration:none;color:inherit;">${y}</a>`:y;return`<td class="stack" valign="top" style="padding:0 ${r?0:8}px 16px 0px;width:${g};vertical-align:top;">
|
|
9
|
+
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0" style="background-color:${de(a,t.theme)};border-radius:${d}px;">
|
|
10
10
|
<tr><td style="padding:0;font-size:0;line-height:0;">${b}</td></tr>
|
|
11
|
-
<tr><td style="padding:12px 12px 4px 12px;font-family:Arial,Helvetica,sans-serif;font-size:15px;font-weight:bold;color:${
|
|
11
|
+
<tr><td style="padding:12px 12px 4px 12px;font-family:Arial,Helvetica,sans-serif;font-size:15px;font-weight:bold;color:${de(o,t.theme)};line-height:1.3;">${w(n.name)}</td></tr>
|
|
12
12
|
${m?`<tr><td style="padding:0 12px 4px 12px;">${m}</td></tr>`:``}
|
|
13
13
|
<tr><td style="padding:0 12px 8px 12px;font-family:Arial,Helvetica,sans-serif;">${f}${i}</td></tr>
|
|
14
14
|
${p?`<tr><td style="padding:0 12px 4px 12px;">${p}</td></tr>`:``}
|
|
@@ -22,8 +22,8 @@ ${v.join(`
|
|
|
22
22
|
`)}
|
|
23
23
|
</table>
|
|
24
24
|
<!--[if mso | IE]></td></tr></table><![endif]-->
|
|
25
|
-
</div>`}function
|
|
26
|
-
`),a=ie(t,e.style);return`<tr><td${a?` class="${a}"`:``} style="${r}">${i}</td></tr>`}function
|
|
25
|
+
</div>`}function de(e,t){if(!e)return``;let n=x(e,t);return typeof n==`string`?n:String(n)}function fe(e,t){let n=S(e.style??{},t.theme),r=D({"background-color":n.backgroundColor,"padding-top":E(n.paddingTop,0),"padding-bottom":E(n.paddingBottom,0),"padding-left":E(n.paddingLeft,0),"padding-right":E(n.paddingRight,0),"border-radius":n.borderRadius?`${n.borderRadius}px`:void 0}),i=e.children.map(e=>O(e,t)).join(`
|
|
26
|
+
`),a=ie(t,e.style);return`<tr><td${a?` class="${a}"`:``} style="${r}">${i}</td></tr>`}function k(e){let t=x(e.settings.backgroundColor,e.theme),n=x(e.settings.contentBackgroundColor,e.theme),r=e.settings.width,i={theme:e.theme,mobileRules:[],classCounter:{n:0}},a=e.modules.map(e=>fe(e,i)).join(`
|
|
27
27
|
`),o=w(e.meta.previewText??``),s=i.mobileRules.join(`
|
|
28
28
|
`);return`<!doctype html>
|
|
29
29
|
<html lang="en" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
|
|
@@ -72,11 +72,11 @@ ${a}
|
|
|
72
72
|
</td></tr>
|
|
73
73
|
</table>
|
|
74
74
|
</body>
|
|
75
|
-
</html>`}var fe={id:`minimal-saas`,name:`Minimal SaaS`,tokens:{colors:{background:`#F4F5F7`,surface:`#FFFFFF`,primary:`#2563EB`,text:`#0F172A`,muted:`#64748B`,buttonBackground:`#2563EB`,buttonText:`#FFFFFF`},fonts:{heading:`Helvetica, Arial, sans-serif`,body:`Helvetica, Arial, sans-serif`,button:`Helvetica, Arial, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:24,xl:40},radius:{sm:4,md:8,lg:16}}},j={id:`ecommerce-promo`,name:`Ecommerce Promo`,tokens:{colors:{background:`#FFF7ED`,surface:`#FFFFFF`,primary:`#EA580C`,text:`#1C1917`,muted:`#78716C`,buttonBackground:`#EA580C`,buttonText:`#FFFFFF`},fonts:{heading:`Georgia, serif`,body:`Arial, Helvetica, sans-serif`,button:`Arial, Helvetica, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:24,xl:40},radius:{sm:4,md:8,lg:24}}},M={id:`luxury-black`,name:`Luxury Black`,tokens:{colors:{background:`#000000`,surface:`#0A0A0A`,primary:`#D4AF37`,text:`#F5F5F5`,muted:`#9CA3AF`,buttonBackground:`#D4AF37`,buttonText:`#000000`},fonts:{heading:`Georgia, serif`,body:`Georgia, serif`,button:`Helvetica, Arial, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:24,xl:48},radius:{sm:0,md:0,lg:0}}},pe={id:`green-eco`,name:`Green Eco`,tokens:{colors:{background:`#BEC0B6`,surface:`#FFFFFF`,primary:`#3A7D52`,text:`#2C2928`,muted:`#6B6B6B`,buttonBackground:`#3A7D52`,buttonText:`#FFFFFF`},fonts:{heading:`Georgia, serif`,body:`Arial, Helvetica, sans-serif`,button:`Arial, Helvetica, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:24,xl:40},radius:{sm:4,md:8,lg:16}}},me={id:`newsletter-editorial`,name:`Newsletter Editorial`,tokens:{colors:{background:`#FAFAF9`,surface:`#FFFFFF`,primary:`#111827`,text:`#111827`,muted:`#6B7280`,buttonBackground:`#111827`,buttonText:`#FFFFFF`},fonts:{heading:`Georgia, 'Times New Roman', serif`,body:`Georgia, 'Times New Roman', serif`,button:`Helvetica, Arial, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:32,xl:48},radius:{sm:2,md:4,lg:8}}},he=[fe,j,M,pe,me],ge=`openpostcards.draft`;function _e(e){return{version:`1.0`,meta:{name:`Untitled email`,previewText:``},theme:e,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[]}}var N=(0,d.create)((e,t)=>({doc:_e(he[0]),selection:{kind:`email`},past:[],future:[],themes:he,viewMode:`desktop`,setSelection:t=>e({selection:t}),setViewMode:t=>e({viewMode:t}),applyDoc:(t,n=!0)=>e(e=>n?{doc:t,past:[...e.past,e.doc].slice(-50),future:[]}:{doc:t}),undo:()=>e(e=>e.past.length===0?e:{doc:e.past[e.past.length-1],past:e.past.slice(0,-1),future:[e.doc,...e.future]}),redo:()=>e(e=>{if(e.future.length===0)return e;let[t,...n]=e.future;return{doc:t,past:[...e.past,e.doc],future:n}}),addModule:(n,r)=>{let{doc:i,applyDoc:a}=t(),o=r??i.modules.length,s=[...i.modules];s.splice(o,0,n),a({...i,modules:s}),e({selection:{kind:`module`,moduleId:n.id}})},deleteModule:n=>{let{doc:r,applyDoc:i}=t(),a=r.modules.filter(e=>e.id!==n);i({...r,modules:a}),e({selection:{kind:`email`}})},duplicateModule:n=>{let{doc:r,applyDoc:i}=t(),a=r.modules.findIndex(e=>e.id===n);if(a===-1)return;let o=r.modules[a],s={...o,id:C(`module`),children:o.children.map(e=>({...e,id:C(`el`)}))},c=[...r.modules];c.splice(a+1,0,s),i({...r,modules:c}),e({selection:{kind:`module`,moduleId:s.id}})},reorderModules:(e,n)=>{let{doc:r,applyDoc:i}=t();if(e===n)return;let a=[...r.modules],[o]=a.splice(e,1);a.splice(n,0,o),i({...r,modules:a})},updateModule:(e,n)=>{let{doc:r,applyDoc:i}=t(),a=r.modules.map(t=>t.id===e?{...t,...n,style:{...t.style,...n.style}}:t);i({...r,modules:a})},updateElement:(e,n,r)=>{let{doc:i,applyDoc:a}=t(),o=i.modules.map(t=>{if(t.id!==e)return t;let i=t.children.map(e=>{if(e.id!==n)return e;let t={...e,...r};return`style`in e&&`style`in r&&(t.style={...e.style,...r.style}),t});return{...t,children:i}});a({...i,modules:o})},deleteElement:(n,r)=>{let{doc:i,applyDoc:a}=t(),o=i.modules.map(e=>e.id===n?{...e,children:e.children.filter(e=>e.id!==r)}:e);a({...i,modules:o}),e({selection:{kind:`module`,moduleId:n}})},reorderElement:(e,n,r)=>{let{doc:i,applyDoc:a}=t(),o=i.modules.map(t=>{if(t.id!==e||n<0||n>=t.children.length||r<0||r>=t.children.length||n===r)return t;let i=[...t.children],[a]=i.splice(n,1);return i.splice(r,0,a),{...t,children:i}});a({...i,modules:o})},moveElement:(e,n,r)=>{let{doc:i,reorderElement:a}=t(),o=i.modules.find(t=>t.id===e);if(!o)return;let s=o.children.findIndex(e=>e.id===n);s!==-1&&a(e,s,s+r)},applyTheme:e=>{let{doc:n,applyDoc:r}=t();r({...n,theme:e})},updateMeta:e=>{let{doc:n,applyDoc:r}=t();r({...n,meta:{...n.meta,...e}})},updateSettings:e=>{let{doc:n,applyDoc:r}=t();r({...n,settings:{...n.settings,...e}})},loadTemplate:n=>{let r=n.build();t().applyDoc(r),e({selection:{kind:`email`},past:[],future:[]})},resetDocument:()=>{let{doc:n,applyDoc:r}=t();r(_e(n.theme)),e({selection:{kind:`email`},past:[],future:[]})},exportJson:()=>JSON.stringify(t().doc,null,2),importJson:e=>{try{let n=JSON.parse(e),r=b.safeParse(n);return r.success?(t().applyDoc(r.data),{ok:!0}):{ok:!1,error:r.error.message}}catch(e){return{ok:!1,error:e.message}}},exportHtml:()=>A(t().doc),loadFromLocalStorage:()=>{try{let t=localStorage.getItem(ge);if(!t)return;let n=b.safeParse(JSON.parse(t));n.success&&e({doc:n.data,past:[],future:[]})}catch{}},saveToLocalStorage:()=>{localStorage.setItem(ge,JSON.stringify(t().doc))}})),P=new class{templates=new Map;register(e){this.templates.set(e.id,e)}get(e){return this.templates.get(e)}list(){return Array.from(this.templates.values())}byCategory(e){return this.list().filter(t=>t.category===e)}},ve={newsletter:`Newsletter`,ecommerce:`Ecommerce`,abandoned_cart:`Abandoned Cart`,product_launch:`Product Launch`,onboarding:`Onboarding`,event:`Event`,transactional:`Transactional`,publishing:`Publishing`},ye={unsubscribe:`{{unsubscribe_url}}`,view_in_browser:`{{view_in_browser_url}}`,manage_preferences:`{{manage_preferences_url}}`,user_profile:`{{user_profile_url}}`},F=(e,t={})=>{let n=t.fontSize??16,r={paddingLeft:16,paddingRight:16};return n>=28?r.fontSize=Math.max(22,Math.round(n*.78)):n>=22&&(r.fontSize=Math.max(20,Math.round(n*.85))),{id:C(`el`),type:`text`,role:t.role,content:e,style:{fontFamily:t.fontFamily??`{fonts.body}`,fontSize:n,fontWeight:t.fontWeight,color:t.color??`{colors.text}`,align:t.align??`left`,paddingTop:t.paddingTop??8,paddingBottom:t.paddingBottom??8,paddingLeft:t.paddingLeft??24,paddingRight:t.paddingRight??24,lineHeight:t.lineHeight??1.5,letterSpacing:t.letterSpacing,link:t.link,linkType:t.linkType,mobile:{...r,...t.mobile??{}}}}},I=(e,t,n={})=>{let r=n.width??552,i=r>343?{width:343,align:`center`}:{};return{id:C(`el`),type:`image`,src:e,alt:t,link:n.link,style:{width:r,height:n.height,align:n.align??`center`,paddingTop:n.paddingTop??8,paddingBottom:n.paddingBottom??8,borderRadius:n.borderRadius,mobile:{...i,...n.mobile??{}}}}},L=(e,t=`#`,n={})=>({id:C(`el`),type:`button`,label:e,link:t,linkType:n.linkType,style:{backgroundColor:n.backgroundColor??`{colors.buttonBackground}`,color:n.color??`{colors.buttonText}`,fontFamily:`{fonts.button}`,fontSize:n.fontSize??16,borderRadius:n.borderRadius??8,align:n.align??`center`,paddingTop:n.paddingTop??16,paddingBottom:n.paddingBottom??16,mobile:{align:`center`,...n.mobile??{}}}}),R=(e=16)=>({id:C(`el`),type:`spacer`,height:e}),z=(e={})=>({id:C(`el`),type:`divider`,style:{color:e.color??`#E5E7EB`,thickness:e.thickness??1,paddingTop:e.paddingTop??8,paddingBottom:e.paddingBottom??8}}),B=(e,t,n,r)=>({id:C(`module`),type:e,name:t,style:r??{backgroundColor:`{colors.surface}`,paddingTop:16,paddingBottom:16,mobile:{paddingLeft:0,paddingRight:0}},children:n}),V=(e,t={})=>F(e,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:t.fontSize??{1:32,2:24,3:18}[t.level??2],fontWeight:`bold`,align:t.align,paddingTop:t.paddingTop??16,paddingBottom:t.paddingBottom??8,lineHeight:1.25}),H=(e,t={})=>F(e.toUpperCase(),{fontSize:12,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:2,align:t.align,paddingTop:t.paddingTop??16,paddingBottom:t.paddingBottom??4}),U=(e,t={})=>F(e,{color:`{colors.muted}`,align:t.align,fontSize:t.fontSize??14,paddingTop:t.paddingTop,paddingBottom:t.paddingBottom,lineHeight:t.lineHeight,link:t.link,linkType:t.linkType,letterSpacing:t.letterSpacing}),be=(e,t={})=>F(e,{role:`voucherCode`,fontFamily:`{fonts.heading}`,fontSize:t.fontSize??36,fontWeight:`bold`,align:`center`,color:t.color??`{colors.primary}`,letterSpacing:4,paddingTop:4,paddingBottom:16}),W=(e,t,n=`Image`)=>`https://placehold.co/${e}x${t}?text=${encodeURIComponent(n)}`,xe=0,G=e=>(xe+=1,{id:C(`prod`),image:e.image??W(400,400,e.name),imageAlt:e.imageAlt??e.name,name:e.name,finalPrice:e.finalPrice,oldPrice:e.oldPrice,description:e.description,link:e.link??`#`,buttonLabel:e.buttonLabel,stars:e.stars}),Se=(e,t={})=>({id:C(`el`),type:`productGrid`,products:e,columns:t.columns??(e.length>=3?3:2),showOldPrice:t.showOldPrice??e.some(e=>!!e.oldPrice),showButton:t.showButton??!0,showDescription:t.showDescription??!1,showStars:t.showStars??e.some(e=>e.stars!=null),buttonLabel:t.buttonLabel??`Shop now`,style:{cardBackgroundColor:t.cardBackgroundColor??`{colors.surface}`,nameColor:t.nameColor??`{colors.text}`,finalPriceColor:t.finalPriceColor??`{colors.primary}`,oldPriceColor:t.oldPriceColor??`#9CA3AF`,buttonBackgroundColor:t.buttonBackgroundColor??`{colors.buttonBackground}`,buttonColor:t.buttonColor??`{colors.buttonText}`,borderRadius:t.borderRadius??8,paddingTop:t.paddingTop??8,paddingBottom:t.paddingBottom??8,paddingLeft:t.paddingLeft??16,paddingRight:t.paddingRight??16}}),Ce=(e,t={})=>{let n=t.separator??` · `;return F(e.map(e=>`<a href="${ye[e.type]}" data-link-type="${e.type}" style="color:inherit;text-decoration:underline">${e.label}</a>`).join(n),{color:t.color??`{colors.muted}`,align:t.align??`center`,fontSize:t.fontSize??12,paddingTop:t.paddingTop??4,paddingBottom:t.paddingBottom??24})};P.register({id:`weekly-newsletter`,name:`The Weekly Digest`,category:`newsletter`,description:`Editorial weekly newsletter with masthead, in-this-issue table of contents, three article summaries, and a footer.`,tags:[`newsletter`,`editorial`,`weekly`,`publishing`],thumbnail:`https://placehold.co/600x800/F5F1EA/1F2937?text=The+Weekly`,build:()=>({version:`1.0`,meta:{name:`The Weekly Digest — Issue 42`,previewText:`This week: AI in the newsroom, three reads, and a recipe.`},theme:me,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[B(`header.masthead`,`Masthead`,[F(`THE WEEKLY`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:32,fontWeight:`bold`,letterSpacing:6,paddingTop:32,paddingBottom:4}),U(`Issue 42 · April 30, 2026`,{align:`center`,paddingBottom:24}),z({paddingTop:0,paddingBottom:0})]),B(`content.article`,`Lead Story`,[H(`LEAD STORY`,{paddingTop:24}),V(`AI Comes to the Newsroom — and It's Helping`,{fontSize:28,paddingTop:4,paddingBottom:12}),I(W(560,320,`Lead+Story`),`Newsroom`,{width:560}),F(`A new generation of editorial assistants is changing how stories get written, fact-checked and published. Here's what we found in three newsrooms.`,{paddingTop:16,paddingBottom:12}),F(`Read the full piece →`,{color:`{colors.primary}`,fontWeight:`bold`,link:`#`,paddingBottom:8})]),B(`content.three_reads`,`Three More Reads`,[H(`ALSO THIS WEEK`,{paddingTop:16}),V(`Three more reads`,{paddingBottom:12}),F(`01 · The hidden cost of free tier APIs`,{fontWeight:`bold`,link:`#`,paddingTop:4,paddingBottom:4}),U(`How startups are quietly burning runway on metered cloud calls.`,{paddingBottom:12}),z({paddingTop:4,paddingBottom:4}),F(`02 · A field guide to product-led onboarding`,{fontWeight:`bold`,link:`#`,paddingBottom:4}),U(`Stop sending welcome emails. Start designing the first 5 minutes.`,{paddingBottom:12}),z({paddingTop:4,paddingBottom:4}),F(`03 · Inside the new Madrid co-working scene`,{fontWeight:`bold`,link:`#`,paddingBottom:4}),U(`Why founders are leaving Lisbon for Spain's quiet capital.`,{paddingBottom:16})]),B(`cta.subscribe_share`,`Forward to a friend`,[z({paddingTop:8,paddingBottom:8}),F(`Liked this? Forward it to a friend.`,{align:`center`,paddingTop:16,paddingBottom:12}),L(`Share The Weekly`,`#`),R(16)]),B(`footer.simple`,`Footer`,[U(`© 2026 The Weekly · 350 Madison Ave · NY 10017`,{align:`center`,paddingTop:16}),U(`Manage preferences · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})}),P.register({id:`flash-sale`,name:`Flash Sale — 24h`,category:`ecommerce`,description:`Urgency-driven 24-hour flash sale with countdown headline, three featured products with old/final prices, and a closing CTA.`,tags:[`ecommerce`,`sale`,`promo`,`discount`,`urgency`],thumbnail:`https://placehold.co/600x800/EA580C/FFFFFF?text=FLASH+SALE`,build:()=>({version:`1.0`,meta:{name:`Flash Sale — 24h only`,previewText:`Up to 50% off — ends midnight tonight.`},theme:j,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[B(`hero.flash`,`Flash hero`,[F(`⏰ FLASH SALE — ENDS IN 24H`,{color:`{colors.buttonText}`,align:`center`,fontWeight:`bold`,letterSpacing:3,paddingTop:24,paddingBottom:8}),F(`Up to 50% off everything`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:32,fontWeight:`bold`,paddingBottom:16}),L(`Shop the sale`,`#`,{backgroundColor:`{colors.surface}`,color:`{colors.primary}`}),R(24)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0}),B(`ecom.featured_grid`,`Featured products`,[F(`Today's picks`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:24,fontWeight:`bold`,paddingTop:24,paddingBottom:16}),Se([G({name:`Linen Tote Bag`,image:W(400,400,`Tote`),oldPrice:`$59`,finalPrice:`$29`}),G({name:`Ceramic Mug Set`,image:W(400,400,`Mug+Set`),oldPrice:`$48`,finalPrice:`$24`}),G({name:`Brass Desk Lamp`,image:W(400,400,`Lamp`),oldPrice:`$159`,finalPrice:`$79`})],{columns:3,showOldPrice:!0,buttonLabel:`Add to bag`})]),B(`cta.urgency`,`Final CTA`,[F(`Don't sleep on it — this ends at midnight.`,{align:`center`,fontWeight:`bold`,paddingTop:16,paddingBottom:12}),L(`Shop now`,`#`),R(24)]),B(`footer.simple`,`Footer`,[U(`© 2026 Acme Co · Unsubscribe · Manage preferences`,{align:`center`,paddingTop:16,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})}),P.register({id:`abandoned-cart`,name:`Abandoned Cart Recovery`,category:`abandoned_cart`,description:`Friendly reminder showing items left in the cart, a discount nudge, and a return-to-cart button. For automated cart-recovery flows.`,tags:[`abandoned-cart`,`recovery`,`automation`,`ecommerce`],thumbnail:`https://placehold.co/600x800/F5F1EA/2C2928?text=Cart+Reminder`,build:()=>({version:`1.0`,meta:{name:`You left something behind`,previewText:`Your cart is waiting — and we saved your spot.`},theme:pe,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[B(`header.logo`,`Logo`,[F(`ACME`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,letterSpacing:4,paddingTop:24,paddingBottom:24})]),B(`hero.text`,`Headline`,[V(`You left something behind`,{align:`center`,fontSize:28,paddingTop:16,paddingBottom:8}),U(`We saved your bag. Pick up right where you left off.`,{align:`center`,paddingBottom:16})]),B(`ecom.cart_items`,`Cart items`,[Se([G({name:`Linen Tote Bag`,image:W(400,400,`Tote`),oldPrice:`$59`,finalPrice:`$39`,description:`Heavyweight natural linen, made in Portugal.`}),G({name:`Cast Iron Skillet`,image:W(400,400,`Skillet`),finalPrice:`$89`,description:`Pre-seasoned, lifetime guarantee.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`Return to cart`})]),B(`cta.discount`,`Discount nudge`,[z({paddingTop:8,paddingBottom:16}),F(`Here's 10% off to seal the deal`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,paddingBottom:4}),F(`COMEBACK10`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:4,paddingBottom:16}),L(`Complete your order`),R(24)]),B(`footer.simple`,`Footer`,[U(`Questions? hello@acme.shop`,{align:`center`,paddingTop:16}),U(`© 2026 Acme · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})}),P.register({id:`product-launch`,name:`Product Launch — Drop`,category:`product_launch`,description:`Bold full-bleed product launch announcement: hero image, big headline, three new products, and an early-access CTA.`,tags:[`launch`,`drop`,`new-arrivals`,`ecommerce`],thumbnail:`https://placehold.co/600x800/000000/D4AF37?text=NEW+DROP`,build:()=>({version:`1.0`,meta:{name:`AUREX 02 — New Drop`,previewText:`The new collection lands today. Limited stock.`},theme:M,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[B(`hero.full_bleed`,`Full-bleed hero`,[I(W(600,700,`AUREX+02`),`AUREX 02 hero`,{width:600,paddingTop:0,paddingBottom:0}),F(`AUREX 02`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:40,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:6,paddingTop:32,paddingBottom:8}),F(`Pure performance. Limited release.`,{align:`center`,color:`{colors.text}`,paddingBottom:24}),L(`Shop the drop`,`#`),R(40)],{backgroundColor:`{colors.surface}`,paddingTop:0,paddingBottom:0}),B(`ecom.collection`,`The Collection`,[U(`THE COLLECTION`,{align:`center`,letterSpacing:4,paddingTop:24,paddingBottom:4}),V(`Meet the line-up`,{align:`center`,fontSize:26,paddingBottom:16}),Se([G({name:`AUREX 02 — Carbon`,image:W(400,400,`Carbon`),finalPrice:`$329`}),G({name:`AUREX 02 — Sand`,image:W(400,400,`Sand`),finalPrice:`$329`}),G({name:`AUREX 02 — Sage`,image:W(400,400,`Sage`),finalPrice:`$329`})],{columns:3,showOldPrice:!1,buttonLabel:`View`})]),B(`cta.early_access`,`Early access`,[F(`Members get 24h early access`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,color:`{colors.text}`,paddingTop:32,paddingBottom:16}),L(`Become a member`,`#`),R(40)],{backgroundColor:`{colors.surface}`,paddingTop:0,paddingBottom:0}),B(`footer.brand`,`Footer`,[U(`AUREX · Designed in Berlin · Made in Italy`,{align:`center`,paddingTop:16}),U(`Manage preferences · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})}),P.register({id:`welcome-onboarding`,name:`SaaS Welcome & Onboarding`,category:`onboarding`,description:`First-touch SaaS welcome with a personal note, a 3-step getting-started checklist, and a CTA to the app.`,tags:[`welcome`,`onboarding`,`saas`,`checklist`],thumbnail:`https://placehold.co/600x800/F4F5F7/2563EB?text=Welcome`,build:()=>({version:`1.0`,meta:{name:`Welcome to Acme`,previewText:`Three quick steps to get the most out of Acme.`},theme:fe,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[B(`header.logo`,`Logo`,[I(W(120,40,`ACME`),`Acme`,{width:120,paddingTop:24})]),B(`hero.welcome`,`Welcome`,[V(`Welcome aboard, friend 👋`,{align:`center`,fontSize:28,paddingTop:8,paddingBottom:8}),F(`I'm Maya, the founder of Acme. Thanks for signing up — I wanted to send you a quick note (and a 3-step checklist) so you get value fast.`,{align:`center`,paddingBottom:24})]),B(`content.checklist`,`Checklist`,[F(`✅ 1. Connect your data`,{fontWeight:`bold`,paddingTop:8,paddingBottom:4}),U(`Hook up Stripe, HubSpot or Salesforce in 30 seconds.`,{paddingBottom:12}),z({paddingTop:4,paddingBottom:4}),F(`⚡ 2. Run your first report`,{fontWeight:`bold`,paddingTop:4,paddingBottom:4}),U(`Pick a template, click Run, watch the magic.`,{paddingBottom:12}),z({paddingTop:4,paddingBottom:4}),F(`👯 3. Invite a teammate`,{fontWeight:`bold`,paddingTop:4,paddingBottom:4}),U(`Acme is more fun (and useful) with your team.`,{paddingBottom:16})]),B(`cta.app`,`Open the app`,[L(`Open Acme`,`#`),R(8),U(`Or reply to this email — a real human will read it.`,{align:`center`,paddingBottom:24})]),B(`footer.simple`,`Footer`,[U(`Acme, Inc · 100 Market St · San Francisco, CA`,{align:`center`,paddingTop:16}),U(`Manage notifications · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})});var we={id:`event-invite`,name:`Event Invite`,category:`event`,description:`Invite to a live event with a header image, date / time / location card, agenda highlights, and an RSVP button.`,tags:[`event`,`invite`,`rsvp`,`conference`,`meetup`],thumbnail:`https://placehold.co/600x800/111827/FAFAF9?text=You're+Invited`,build:()=>({version:`1.0`,meta:{name:`You're invited: Acme Summit 2026`,previewText:`Join us June 12 in Brooklyn for talks, food and a rooftop after-party.`},theme:me,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[B(`header.logo`,`Logo`,[F(`ACME SUMMIT`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,letterSpacing:6,paddingTop:24,paddingBottom:16})]),B(`hero.event`,`Event hero`,[I(W(600,320,`Acme+Summit`),`Acme Summit`,{width:600,paddingTop:0,paddingBottom:16}),V(`You're invited.`,{align:`center`,fontSize:32,paddingTop:8,paddingBottom:4}),U(`A one-day gathering for builders. Brooklyn, NY.`,{align:`center`,paddingBottom:24})]),B(`content.event_card`,`Event details`,[F(`📅 Friday, June 12, 2026`,{align:`center`,fontWeight:`bold`,paddingTop:24,paddingBottom:4}),F(`⏰ 9:00 AM — 6:00 PM`,{align:`center`,paddingBottom:4}),F(`📍 The Invisible Dog · 51 Bergen St, Brooklyn`,{align:`center`,paddingBottom:16}),L(`RSVP — free`,`#`),R(24)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0}),B(`content.agenda`,`Agenda`,[z({paddingTop:16,paddingBottom:16}),Te(`AGENDA HIGHLIGHTS`),Ee(`9:30`,`Opening keynote — Maya Chen, Acme`),Ee(`11:00`,`Workshop: shipping AI features users actually want`),Ee(`13:00`,`Lunch + open conversations`),Ee(`15:30`,`Panel: building durable companies`),Ee(`18:00`,`Rooftop after-party`),R(16)]),B(`footer.simple`,`Footer`,[U(`Acme, Inc · 100 Market St · San Francisco, CA`,{align:`center`,paddingTop:16}),U(`Update preferences · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};function Te(e){return F(e,{fontFamily:`{fonts.button}`,color:`{colors.muted}`,fontSize:11,fontWeight:`bold`,letterSpacing:3,paddingBottom:12})}function Ee(e,t){return F(`<b>${e}</b> · ${t}`,{paddingTop:6,paddingBottom:6})}P.register(we),P.register({id:`order-receipt`,name:`Order Receipt`,category:`transactional`,description:`Transactional order confirmation with order number, an itemized table, totals, shipping address and a help footer.`,tags:[`transactional`,`receipt`,`order`,`confirmation`],thumbnail:`https://placehold.co/600x800/F4F5F7/0F172A?text=Order+%23A12345`,build:()=>({version:`1.0`,meta:{name:`Your order #A12345 is confirmed`,previewText:`Thanks for your order! Here's your receipt.`},theme:fe,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[B(`header.logo`,`Logo`,[F(`ACME`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,letterSpacing:4,paddingTop:24,paddingBottom:24})]),B(`hero.confirmation`,`Confirmation`,[V(`Thanks, your order is confirmed`,{align:`center`,fontSize:26,paddingTop:8,paddingBottom:4}),U(`Order #A12345 · placed April 30, 2026`,{align:`center`,paddingBottom:24})]),B(`tx.items`,`Items`,[F(`ITEMS`,{fontSize:11,letterSpacing:3,fontWeight:`bold`,color:`{colors.muted}`,paddingTop:8,paddingBottom:12}),F(`Linen Tote Bag · Natural · Qty 1`,{fontWeight:`bold`,paddingBottom:4}),U(`$39.00`,{paddingBottom:12}),z({paddingTop:4,paddingBottom:4}),F(`Ceramic Mug · Sand · Qty 2`,{fontWeight:`bold`,paddingBottom:4}),U(`$48.00`,{paddingBottom:16}),z({paddingTop:8,paddingBottom:12}),F(`Subtotal · $87.00`,{align:`right`,paddingBottom:4}),F(`Shipping · $9.00`,{align:`right`,paddingBottom:4}),F(`<b>Total · $96.00</b>`,{align:`right`,fontSize:18,paddingBottom:16})]),B(`tx.shipping`,`Shipping address`,[F(`SHIPPING TO`,{fontSize:11,letterSpacing:3,fontWeight:`bold`,color:`{colors.muted}`,paddingTop:16,paddingBottom:8}),F(`Alex Rada<br/>350 Madison Ave<br/>New York, NY 10017`,{paddingBottom:16}),L(`Track shipment`,`#`),R(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0}),B(`footer.help`,`Help`,[U(`Questions about your order? help@acme.shop`,{align:`center`,paddingTop:16}),U(`© 2026 Acme · Privacy`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})});var De={id:`blog-digest`,name:`Blog / Publishing Digest`,category:`publishing`,description:`Editorial digest of three blog posts: each with a thumbnail, title, dek and read-link. Best for media and creators.`,tags:[`blog`,`digest`,`publishing`,`media`],thumbnail:`https://placehold.co/600x800/FAFAF9/111827?text=Blog+Digest`,build:()=>({version:`1.0`,meta:{name:`This week on the blog`,previewText:`Three new pieces — including our deep dive on micro-SaaS in 2026.`},theme:me,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[B(`header.publication`,`Publication header`,[F(`THE LEDGER`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,letterSpacing:6,paddingTop:32,paddingBottom:4}),U(`Notes on building, weekly`,{align:`center`,paddingBottom:24}),z({paddingTop:0,paddingBottom:0})]),Oe(`Micro-SaaS in 2026: smaller, sharper, more profitable`,`Why the next wave of indie founders is winning by going narrower than you think.`,`Maya Chen · 8 min read`,W(560,280,`Post+1`)),Oe(`Stop A/B testing your homepage`,`An evidence-based case for spending that energy on your activation flow instead.`,`Jordan Lee · 6 min read`,W(560,280,`Post+2`)),Oe(`The five-line founder check-in`,`A weekly journaling pattern that keeps the team aligned and the founder sane.`,`Sam Park · 4 min read`,W(560,280,`Post+3`)),B(`footer.simple`,`Footer`,[U(`The Ledger · Published Tuesdays`,{align:`center`,paddingTop:16}),U(`© 2026 · Manage subscription · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};function Oe(e,t,n,r){return B(`content.post`,`Post`,[I(r,e,{width:560,paddingTop:24,paddingBottom:16}),V(e,{fontSize:24,paddingBottom:8}),F(t,{paddingBottom:8}),U(n,{paddingBottom:4}),F(`Read the full post →`,{color:`{colors.primary}`,fontWeight:`bold`,link:`#`,paddingTop:4,paddingBottom:8}),R(8)])}P.register(De);function ke({open:e,onClose:t}){let n=N(e=>e.loadTemplate),r=N(e=>e.doc.modules.length>0),[i,a]=(0,l.useState)(`all`),[o,s]=(0,l.useState)(``);(0,l.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let c=(0,l.useMemo)(()=>P.list(),[e]),u=(0,l.useMemo)(()=>{let e=c;if(i!==`all`&&(e=e.filter(e=>e.category===i)),o.trim()){let t=o.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||(e.tags??[]).some(e=>e.toLowerCase().includes(t)))}return e},[c,i,o]);if(!e)return null;let d=e=>{r&&!window.confirm(`Loading "${e.name}" will replace your current email. Continue?`)||(n(e),t())},m=[{key:`all`,label:`All templates`},...Object.entries(ve).map(([e,t])=>({key:e,label:t}))];return(0,p.jsx)(`div`,{className:`fixed inset-0 z-50 flex bg-black/60 backdrop-blur-sm`,children:(0,p.jsxs)(`div`,{className:`m-auto flex h-[92vh] w-[96vw] max-w-350 flex-col overflow-hidden rounded-2xl bg-white shadow-2xl`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-200 px-6 py-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{className:`text-lg font-semibold text-neutral-900`,children:`Start from a template`}),(0,p.jsx)(`p`,{className:`text-sm text-neutral-500`,children:`Pick a fully-built email and tweak from there.`})]}),(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg p-2 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900`,"aria-label":`Close`,children:(0,p.jsx)(f.X,{size:20})})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsxs)(`aside`,{className:`w-56 shrink-0 overflow-y-auto border-r border-neutral-200 bg-neutral-50 p-3`,children:[(0,p.jsxs)(`div`,{className:`relative mb-3`,children:[(0,p.jsx)(f.Search,{size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-400`}),(0,p.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Search…`,className:`w-full rounded-md border border-neutral-200 bg-white py-1.5 pl-7 pr-2 text-sm outline-none focus:border-neutral-400`})]}),(0,p.jsx)(`ul`,{className:`space-y-0.5`,children:m.map(e=>(0,p.jsx)(`li`,{children:(0,p.jsx)(`button`,{onClick:()=>a(e.key),className:`block w-full rounded-md px-2.5 py-1.5 text-left text-sm transition `+(e.key===i?`bg-neutral-900 text-white`:`text-neutral-700 hover:bg-neutral-200`),children:e.label})},e.key))})]}),(0,p.jsx)(`main`,{className:`flex-1 overflow-y-auto p-6`,children:u.length===0?(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-sm text-neutral-500`,children:`No templates match.`}):(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-5 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5`,children:u.map(e=>(0,p.jsx)(Ae,{def:e,onPick:()=>d(e)},e.id))})})]})]})})}function Ae({def:e,onPick:t}){return(0,p.jsxs)(`button`,{onClick:t,className:`group flex flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white text-left transition hover:-translate-y-0.5 hover:border-neutral-400 hover:shadow-lg`,children:[(0,p.jsx)(`div`,{className:`aspect-3/4 w-full overflow-hidden bg-neutral-100`,children:e.thumbnail?(0,p.jsx)(`img`,{src:e.thumbnail,alt:e.name,className:`h-full w-full object-cover transition group-hover:scale-[1.02]`}):(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-xs text-neutral-400`,children:`No preview`})}),(0,p.jsxs)(`div`,{className:`flex flex-col gap-1 p-3`,children:[(0,p.jsx)(`div`,{className:`text-xs uppercase tracking-wider text-neutral-500`,children:ve[e.category]}),(0,p.jsx)(`div`,{className:`line-clamp-1 text-sm font-semibold text-neutral-900`,children:e.name}),(0,p.jsx)(`div`,{className:`line-clamp-2 text-xs text-neutral-500`,children:e.description})]})]})}function je(){let{doc:e,updateMeta:t,undo:n,redo:r,past:i,future:a,exportJson:o,importJson:s,exportHtml:c,saveToLocalStorage:u,viewMode:d,setViewMode:m,resetDocument:h}=N(),g=(0,l.useRef)(null),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(!1),x=()=>{e.modules.length!==0&&window.confirm(`Reset the editor? Your current email will be cleared.`)&&h()},S=(e,t,n)=>{let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),URL.revokeObjectURL(i)};return(0,p.jsxs)(`div`,{className:`flex items-center h-12 px-4 bg-white border-b border-gray-200 shrink-0`,children:[(0,p.jsx)(`div`,{className:`shrink-0 w-48`,children:(0,p.jsx)(`input`,{className:`font-medium text-sm px-2 py-1 rounded hover:bg-gray-50 focus:bg-gray-50 outline-none w-full`,value:e.meta.name,onChange:e=>t({name:e.target.value})})}),(0,p.jsxs)(`div`,{className:`flex-1 flex items-center justify-center gap-1`,children:[(0,p.jsxs)(`div`,{className:`inline-flex items-center bg-gray-100 rounded p-0.5 mr-1`,children:[(0,p.jsxs)(`button`,{title:`Desktop preview`,onClick:()=>m(`desktop`),className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${d===`desktop`?`bg-white shadow text-gray-900`:`text-gray-500 hover:text-gray-700`}`,children:[(0,p.jsx)(f.Monitor,{size:14}),` Desktop`]}),(0,p.jsxs)(`button`,{title:`Mobile preview`,onClick:()=>m(`mobile`),className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${d===`mobile`?`bg-white shadow text-gray-900`:`text-gray-500 hover:text-gray-700`}`,children:[(0,p.jsx)(f.Smartphone,{size:14}),` Mobile`]})]}),(0,p.jsxs)(Pe,{title:`Browse templates`,onClick:()=>b(!0),children:[(0,p.jsx)(f.LayoutTemplate,{size:16}),` Templates`]}),(0,p.jsxs)(Pe,{title:`Reset editor`,onClick:x,disabled:e.modules.length===0,children:[(0,p.jsx)(f.RotateCcw,{size:16}),` Reset`]}),(0,p.jsx)(Fe,{}),(0,p.jsx)(Pe,{title:`Undo`,onClick:n,disabled:i.length===0,children:(0,p.jsx)(f.Undo2,{size:16})}),(0,p.jsx)(Pe,{title:`Redo`,onClick:r,disabled:a.length===0,children:(0,p.jsx)(f.Redo2,{size:16})}),(0,p.jsx)(Fe,{}),(0,p.jsx)(Pe,{title:`Save draft (local)`,onClick:u,children:(0,p.jsx)(f.Save,{size:16})}),(0,p.jsxs)(Pe,{title:`Preview`,onClick:()=>{let e=c(),t=window.open(``,`_blank`);t&&(t.document.write(e),t.document.close()),v(!0),setTimeout(()=>v(!1),600)},children:[(0,p.jsx)(f.Eye,{size:16}),` `,_?`Opened`:`Preview`]})]}),(0,p.jsxs)(`div`,{className:`shrink-0 flex justify-end w-48`,children:[(0,p.jsx)(`input`,{ref:g,type:`file`,accept:`.json`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&(t.text().then(e=>{let t=s(e);t.ok||alert(`Import failed: ${t.error}`)}),e.target.value=``)}}),(0,p.jsx)(Me,{onImport:()=>g.current?.click(),onExportJson:()=>{S(`${e.meta.name||`email`}.json`,o(),`application/json`)},onExportHtml:()=>{let t=c();S(`${e.meta.name||`email`}.html`,t,`text/html`)}})]}),(0,p.jsx)(ke,{open:y,onClose:()=>b(!1)})]})}function Me({onImport:e,onExportJson:t,onExportHtml:n}){let[r,i]=(0,l.useState)(!1),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!r)return;let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]),(0,p.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,p.jsxs)(`button`,{onClick:()=>i(e=>!e),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded text-sm text-gray-700 hover:bg-gray-100 border border-gray-200 transition-colors`,title:`Import / Export`,children:[(0,p.jsx)(f.FileCode,{size:16}),`Export`,(0,p.jsx)(f.ChevronDown,{size:14,className:`transition-transform ${r?`rotate-180`:``}`})]}),r&&(0,p.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-white border border-gray-200 rounded-lg shadow-lg z-50 py-1 text-sm`,children:[(0,p.jsx)(Ne,{icon:(0,p.jsx)(f.Upload,{size:14}),label:`Import JSON`,onClick:()=>{e(),i(!1)}}),(0,p.jsx)(`div`,{className:`mx-2 my-1 border-t border-gray-100`}),(0,p.jsx)(Ne,{icon:(0,p.jsx)(f.Download,{size:14}),label:`Export JSON`,onClick:()=>{t(),i(!1)}}),(0,p.jsx)(Ne,{icon:(0,p.jsx)(f.FileCode,{size:14}),label:`Export HTML`,onClick:()=>{n(),i(!1)}})]})]})}function Ne({icon:e,label:t,onClick:n,highlight:r}){return(0,p.jsxs)(`button`,{onClick:n,className:`w-full flex items-center gap-2 px-3 py-2 hover:bg-gray-50 transition-colors text-left ${r?`text-blue-600 font-medium`:`text-gray-700`}`,children:[e,t]})}function Pe({children:e,onClick:t,disabled:n,title:r,primary:i}){return(0,p.jsx)(`button`,{title:r,disabled:n,onClick:t,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded text-sm transition-colors ${i?`bg-blue-600 text-white hover:bg-blue-700 disabled:bg-gray-300`:`text-gray-700 hover:bg-gray-100 disabled:text-gray-300 disabled:hover:bg-transparent`}`,children:e})}function Fe(){return(0,p.jsx)(`div`,{className:`w-px h-5 bg-gray-200 mx-1`})}var Ie=new class{modules=new Map;register(e){this.modules.set(e.type,e)}get(e){return this.modules.get(e)}list(){return Array.from(this.modules.values())}byCategory(e){return this.list().filter(t=>t.category===e)}},Le={basic:`Basic`,menu:`Menu`,header:`Header`,content:`Content`,feature:`Feature`,call_to_action:`Call to Action`,ecommerce:`Ecommerce`,transactional:`Transactional`,social:`Social`,footer:`Footer`},Re=null,ze=new Set,Be=0;function Ve(){Be+=1;for(let e of ze)e()}function He(e){Re!==e&&(Re=e,Ve())}function Ue(){return Re}var We=e=>(ze.add(e),()=>{ze.delete(e)}),Ge=()=>Be;function Ke(){return Ie.list().map(e=>({type:e.type,category:e.category,name:e.name,description:e.description,tags:e.tags??[],source:`module`,sample:e.create()}))}function qe(e,t){let n=e;for(let e of t)n=Je(n,e);return n}function Je(e,t){switch(t.type){case`update_meta`:return{...e,meta:{...e.meta,...t.patch}};case`update_settings`:return{...e,settings:{...e.settings,...t.patch}};case`apply_theme`:return{...e,theme:t.theme};case`insert_module`:{let n=t.index??e.modules.length,r=[...e.modules];return r.splice(n,0,t.module),{...e,modules:r}}case`delete_module`:return{...e,modules:e.modules.filter(e=>e.id!==t.moduleId)};case`update_module`:return{...e,modules:e.modules.map(e=>e.id===t.moduleId?{...e,...t.patch}:e)};case`update_element`:return{...e,modules:e.modules.map(e=>e.id===t.moduleId?{...e,children:e.children.map(e=>e.id===t.elementId?{...e,...t.patch}:e)}:e)}}}function Ye(e){let t=b.safeParse(e);return t.success?{ok:!0,document:t.data}:{ok:!1,error:t.error.message}}var Xe={async generate(e){return e.task===`rewrite_text`&&e.instruction?{text:`[AI rewrite] ${e.instruction}`}:e.task===`generate_subject`?{text:`Your weekly insight is here ✨`}:e.task===`generate_preview`?{text:`A short summary that nudges readers to open.`}:{actions:[]}}};function Ze(e){return JSON.parse(JSON.stringify(e))}function Qe(e){let t=Ze(e);return{...t,id:C(`module`),children:(t.children??[]).map(e=>({...e,id:C(`el`)}))}}function $e(e){return e.map(e=>e.type===`insert_module`?{...e,module:Qe(e.module)}:e)}function et(e,t){if(t.document){let e=Ye(Ze(t.document));return e.ok?{ok:!0,result:{document:e.document,text:t.text,summary:`Replaced the email with a freshly generated document.`}}:{ok:!1,error:e.error}}if(t.actions&&t.actions.length>0){let n=Ye(Ze(qe(e,$e(t.actions))));return n.ok?{ok:!0,result:{document:n.document,text:t.text,summary:tt(t.actions)}}:{ok:!1,error:n.error}}return{ok:!0,result:{document:e,text:t.text,summary:t.text?``:`No changes were suggested.`}}}function tt(e){let t={};for(let n of e)t[n.type]=(t[n.type]??0)+1;let n={insert_module:`added block`,delete_module:`removed block`,update_module:`updated block`,update_element:`edited content`,update_meta:`updated meta`,update_settings:`updated settings`,apply_theme:`applied theme`},r=Object.entries(t).map(([e,t])=>{let r=n[e]??e;return t>1?`${t} ${r}s`:r});return r.length?`Applied: ${r.join(`, `)}.`:`No changes applied.`}var nt=[`Create a welcome email for new subscribers`,`Build a flash sale announcement with a product grid`,`Write a weekly newsletter with a lead story and footer`];function rt(){return(0,l.useSyncExternalStore)(We,Ge,Ge),Ue()!==null}function it(){let{doc:e,applyDoc:t}=N(),[n,r]=(0,l.useState)([]),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(!1),c=(0,l.useRef)(null);(0,l.useEffect)(()=>{c.current?.scrollTo({top:c.current.scrollHeight})},[n,o]);let u=async n=>{let i=Ue();if(!i||!n.trim()||o)return;let c={id:crypto.randomUUID(),role:`user`,text:n};r(e=>[...e,c]),a(``),s(!0);let l={task:`create_email`,document:e,instruction:n,context:{catalog:Ke()}};try{let n=await i.generate(l),r=et(e,n);if(!r.ok)d(`I produced an invalid document and stopped. (${r.error})`,!0);else{let{document:n,text:i,summary:a}=r.result;n!==e&&t(n),d([i,a].filter(Boolean).join(`
|
|
75
|
+
</html>`}var pe={id:`minimal-saas`,name:`Minimal SaaS`,tokens:{colors:{background:`#F4F5F7`,surface:`#FFFFFF`,primary:`#2563EB`,text:`#0F172A`,muted:`#64748B`,buttonBackground:`#2563EB`,buttonText:`#FFFFFF`},fonts:{heading:`Helvetica, Arial, sans-serif`,body:`Helvetica, Arial, sans-serif`,button:`Helvetica, Arial, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:24,xl:40},radius:{sm:4,md:8,lg:16}}},A={id:`ecommerce-promo`,name:`Ecommerce Promo`,tokens:{colors:{background:`#FFF7ED`,surface:`#FFFFFF`,primary:`#EA580C`,text:`#1C1917`,muted:`#78716C`,buttonBackground:`#EA580C`,buttonText:`#FFFFFF`},fonts:{heading:`Georgia, serif`,body:`Arial, Helvetica, sans-serif`,button:`Arial, Helvetica, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:24,xl:40},radius:{sm:4,md:8,lg:24}}},j={id:`luxury-black`,name:`Luxury Black`,tokens:{colors:{background:`#000000`,surface:`#0A0A0A`,primary:`#D4AF37`,text:`#F5F5F5`,muted:`#9CA3AF`,buttonBackground:`#D4AF37`,buttonText:`#000000`},fonts:{heading:`Georgia, serif`,body:`Georgia, serif`,button:`Helvetica, Arial, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:24,xl:48},radius:{sm:0,md:0,lg:0}}},me={id:`green-eco`,name:`Green Eco`,tokens:{colors:{background:`#BEC0B6`,surface:`#FFFFFF`,primary:`#3A7D52`,text:`#2C2928`,muted:`#6B6B6B`,buttonBackground:`#3A7D52`,buttonText:`#FFFFFF`},fonts:{heading:`Georgia, serif`,body:`Arial, Helvetica, sans-serif`,button:`Arial, Helvetica, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:24,xl:40},radius:{sm:4,md:8,lg:16}}},he={id:`newsletter-editorial`,name:`Newsletter Editorial`,tokens:{colors:{background:`#FAFAF9`,surface:`#FFFFFF`,primary:`#111827`,text:`#111827`,muted:`#6B7280`,buttonBackground:`#111827`,buttonText:`#FFFFFF`},fonts:{heading:`Georgia, 'Times New Roman', serif`,body:`Georgia, 'Times New Roman', serif`,button:`Helvetica, Arial, sans-serif`},spacing:{xs:4,sm:8,md:16,lg:32,xl:48},radius:{sm:2,md:4,lg:8}}},ge=[pe,A,j,me,he],_e=`openpostcards.draft`;function ve(e){return{version:`1.0`,meta:{name:`Untitled email`,previewText:``},theme:e,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[]}}var M=(0,d.create)((e,t)=>({doc:ve(ge[0]),selection:{kind:`email`},past:[],future:[],themes:ge,viewMode:`desktop`,setSelection:t=>e({selection:t}),setViewMode:t=>e({viewMode:t}),applyDoc:(t,n=!0)=>e(e=>n?{doc:t,past:[...e.past,e.doc].slice(-50),future:[]}:{doc:t}),undo:()=>e(e=>e.past.length===0?e:{doc:e.past[e.past.length-1],past:e.past.slice(0,-1),future:[e.doc,...e.future]}),redo:()=>e(e=>{if(e.future.length===0)return e;let[t,...n]=e.future;return{doc:t,past:[...e.past,e.doc],future:n}}),addModule:(n,r)=>{let{doc:i,applyDoc:a}=t(),o=r??i.modules.length,s=[...i.modules];s.splice(o,0,n),a({...i,modules:s}),e({selection:{kind:`module`,moduleId:n.id}})},deleteModule:n=>{let{doc:r,applyDoc:i}=t(),a=r.modules.filter(e=>e.id!==n);i({...r,modules:a}),e({selection:{kind:`email`}})},duplicateModule:n=>{let{doc:r,applyDoc:i}=t(),a=r.modules.findIndex(e=>e.id===n);if(a===-1)return;let o=r.modules[a],s={...o,id:C(`module`),children:o.children.map(e=>({...e,id:C(`el`)}))},c=[...r.modules];c.splice(a+1,0,s),i({...r,modules:c}),e({selection:{kind:`module`,moduleId:s.id}})},reorderModules:(e,n)=>{let{doc:r,applyDoc:i}=t();if(e===n)return;let a=[...r.modules],[o]=a.splice(e,1);a.splice(n,0,o),i({...r,modules:a})},updateModule:(e,n)=>{let{doc:r,applyDoc:i}=t(),a=r.modules.map(t=>t.id===e?{...t,...n,style:{...t.style,...n.style}}:t);i({...r,modules:a})},updateElement:(e,n,r)=>{let{doc:i,applyDoc:a}=t(),o=i.modules.map(t=>{if(t.id!==e)return t;let i=t.children.map(e=>{if(e.id!==n)return e;let t={...e,...r};return`style`in e&&`style`in r&&(t.style={...e.style,...r.style}),t});return{...t,children:i}});a({...i,modules:o})},deleteElement:(n,r)=>{let{doc:i,applyDoc:a}=t(),o=i.modules.map(e=>e.id===n?{...e,children:e.children.filter(e=>e.id!==r)}:e);a({...i,modules:o}),e({selection:{kind:`module`,moduleId:n}})},reorderElement:(e,n,r)=>{let{doc:i,applyDoc:a}=t(),o=i.modules.map(t=>{if(t.id!==e||n<0||n>=t.children.length||r<0||r>=t.children.length||n===r)return t;let i=[...t.children],[a]=i.splice(n,1);return i.splice(r,0,a),{...t,children:i}});a({...i,modules:o})},moveElement:(e,n,r)=>{let{doc:i,reorderElement:a}=t(),o=i.modules.find(t=>t.id===e);if(!o)return;let s=o.children.findIndex(e=>e.id===n);s!==-1&&a(e,s,s+r)},applyTheme:e=>{let{doc:n,applyDoc:r}=t();r({...n,theme:e})},updateMeta:e=>{let{doc:n,applyDoc:r}=t();r({...n,meta:{...n.meta,...e}})},updateSettings:e=>{let{doc:n,applyDoc:r}=t();r({...n,settings:{...n.settings,...e}})},loadTemplate:n=>{let r=n.build();t().applyDoc(r),e({selection:{kind:`email`},past:[],future:[]})},resetDocument:()=>{let{doc:n,applyDoc:r}=t();r(ve(n.theme)),e({selection:{kind:`email`},past:[],future:[]})},exportJson:()=>JSON.stringify(t().doc,null,2),importJson:e=>{try{let n=JSON.parse(e),r=b.safeParse(n);return r.success?(t().applyDoc(r.data),{ok:!0}):{ok:!1,error:r.error.message}}catch(e){return{ok:!1,error:e.message}}},exportHtml:()=>k(t().doc),loadFromLocalStorage:()=>{try{let t=localStorage.getItem(_e);if(!t)return;let n=b.safeParse(JSON.parse(t));n.success&&e({doc:n.data,past:[],future:[]})}catch{}},saveToLocalStorage:()=>{localStorage.setItem(_e,JSON.stringify(t().doc))}})),N=new class{templates=new Map;register(e){this.templates.set(e.id,e)}get(e){return this.templates.get(e)}list(){return Array.from(this.templates.values())}byCategory(e){return this.list().filter(t=>t.category===e)}},ye={newsletter:`Newsletter`,ecommerce:`Ecommerce`,abandoned_cart:`Abandoned Cart`,product_launch:`Product Launch`,onboarding:`Onboarding`,event:`Event`,transactional:`Transactional`,publishing:`Publishing`},be={unsubscribe:`{{unsubscribe_url}}`,view_in_browser:`{{view_in_browser_url}}`,manage_preferences:`{{manage_preferences_url}}`,user_profile:`{{user_profile_url}}`},P=(e,t={})=>{let n=t.fontSize??16,r={paddingLeft:16,paddingRight:16};return n>=28?r.fontSize=Math.max(22,Math.round(n*.78)):n>=22&&(r.fontSize=Math.max(20,Math.round(n*.85))),{id:C(`el`),type:`text`,role:t.role,content:e,style:{fontFamily:t.fontFamily??`{fonts.body}`,fontSize:n,fontWeight:t.fontWeight,color:t.color??`{colors.text}`,align:t.align??`left`,paddingTop:t.paddingTop??8,paddingBottom:t.paddingBottom??8,paddingLeft:t.paddingLeft??24,paddingRight:t.paddingRight??24,lineHeight:t.lineHeight??1.5,letterSpacing:t.letterSpacing,link:t.link,linkType:t.linkType,mobile:{...r,...t.mobile??{}}}}},F=(e,t,n={})=>{let r=n.width??552,i=r>343?{width:343,align:`center`}:{};return{id:C(`el`),type:`image`,src:e,alt:t,link:n.link,style:{width:r,height:n.height,align:n.align??`center`,paddingTop:n.paddingTop??8,paddingBottom:n.paddingBottom??8,borderRadius:n.borderRadius,mobile:{...i,...n.mobile??{}}}}},I=(e,t=`#`,n={})=>({id:C(`el`),type:`button`,label:e,link:t,linkType:n.linkType,style:{backgroundColor:n.backgroundColor??`{colors.buttonBackground}`,color:n.color??`{colors.buttonText}`,fontFamily:`{fonts.button}`,fontSize:n.fontSize??16,borderRadius:n.borderRadius??8,align:n.align??`center`,paddingTop:n.paddingTop??16,paddingBottom:n.paddingBottom??16,mobile:{align:`center`,...n.mobile??{}}}}),L=(e=16)=>({id:C(`el`),type:`spacer`,height:e}),R=(e={})=>({id:C(`el`),type:`divider`,style:{color:e.color??`#E5E7EB`,thickness:e.thickness??1,paddingTop:e.paddingTop??8,paddingBottom:e.paddingBottom??8}}),z=(e,t,n,r)=>({id:C(`module`),type:e,name:t,style:r??{backgroundColor:`{colors.surface}`,paddingTop:16,paddingBottom:16,mobile:{paddingLeft:0,paddingRight:0}},children:n}),B=(e,t={})=>P(e,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:t.fontSize??{1:32,2:24,3:18}[t.level??2],fontWeight:`bold`,align:t.align,paddingTop:t.paddingTop??16,paddingBottom:t.paddingBottom??8,lineHeight:1.25}),V=(e,t={})=>P(e.toUpperCase(),{fontSize:12,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:2,align:t.align,paddingTop:t.paddingTop??16,paddingBottom:t.paddingBottom??4}),H=(e,t={})=>P(e,{color:`{colors.muted}`,align:t.align,fontSize:t.fontSize??14,paddingTop:t.paddingTop,paddingBottom:t.paddingBottom,lineHeight:t.lineHeight,link:t.link,linkType:t.linkType,letterSpacing:t.letterSpacing}),xe=(e,t={})=>P(e,{role:`voucherCode`,fontFamily:`{fonts.heading}`,fontSize:t.fontSize??36,fontWeight:`bold`,align:`center`,color:t.color??`{colors.primary}`,letterSpacing:4,paddingTop:4,paddingBottom:16}),U=(e,t,n=`Image`)=>`https://placehold.co/${e}x${t}?text=${encodeURIComponent(n)}`,Se=0,W=e=>(Se+=1,{id:C(`prod`),image:e.image??U(400,400,e.name),imageAlt:e.imageAlt??e.name,name:e.name,finalPrice:e.finalPrice,oldPrice:e.oldPrice,description:e.description,link:e.link??`#`,buttonLabel:e.buttonLabel,stars:e.stars}),G=(e,t={})=>({id:C(`el`),type:`productGrid`,products:e,columns:t.columns??(e.length>=3?3:2),showOldPrice:t.showOldPrice??e.some(e=>!!e.oldPrice),showButton:t.showButton??!0,showDescription:t.showDescription??!1,showStars:t.showStars??e.some(e=>e.stars!=null),buttonLabel:t.buttonLabel??`Shop now`,style:{cardBackgroundColor:t.cardBackgroundColor??`{colors.surface}`,nameColor:t.nameColor??`{colors.text}`,finalPriceColor:t.finalPriceColor??`{colors.primary}`,oldPriceColor:t.oldPriceColor??`#9CA3AF`,buttonBackgroundColor:t.buttonBackgroundColor??`{colors.buttonBackground}`,buttonColor:t.buttonColor??`{colors.buttonText}`,borderRadius:t.borderRadius??8,paddingTop:t.paddingTop??8,paddingBottom:t.paddingBottom??8,paddingLeft:t.paddingLeft??16,paddingRight:t.paddingRight??16}}),K=(e,t={})=>{let n=t.separator??` · `;return P(e.map(e=>`<a href="${be[e.type]}" data-link-type="${e.type}" style="color:inherit;text-decoration:underline">${e.label}</a>`).join(n),{color:t.color??`{colors.muted}`,align:t.align??`center`,fontSize:t.fontSize??12,paddingTop:t.paddingTop??4,paddingBottom:t.paddingBottom??24})};N.register({id:`weekly-newsletter`,name:`The Weekly Digest`,category:`newsletter`,description:`Editorial weekly newsletter with masthead, in-this-issue table of contents, three article summaries, and a footer.`,tags:[`newsletter`,`editorial`,`weekly`,`publishing`],thumbnail:`https://placehold.co/600x800/F5F1EA/1F2937?text=The+Weekly`,build:()=>({version:`1.0`,meta:{name:`The Weekly Digest — Issue 42`,previewText:`This week: AI in the newsroom, three reads, and a recipe.`},theme:he,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`header.masthead`,`Masthead`,[P(`THE WEEKLY`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:32,fontWeight:`bold`,letterSpacing:6,paddingTop:32,paddingBottom:4}),H(`Issue 42 · April 30, 2026`,{align:`center`,paddingBottom:24}),R({paddingTop:0,paddingBottom:0})]),z(`content.article`,`Lead Story`,[V(`LEAD STORY`,{paddingTop:24}),B(`AI Comes to the Newsroom — and It's Helping`,{fontSize:28,paddingTop:4,paddingBottom:12}),F(U(560,320,`Lead+Story`),`Newsroom`,{width:560}),P(`A new generation of editorial assistants is changing how stories get written, fact-checked and published. Here's what we found in three newsrooms.`,{paddingTop:16,paddingBottom:12}),P(`Read the full piece →`,{color:`{colors.primary}`,fontWeight:`bold`,link:`#`,paddingBottom:8})]),z(`content.three_reads`,`Three More Reads`,[V(`ALSO THIS WEEK`,{paddingTop:16}),B(`Three more reads`,{paddingBottom:12}),P(`01 · The hidden cost of free tier APIs`,{fontWeight:`bold`,link:`#`,paddingTop:4,paddingBottom:4}),H(`How startups are quietly burning runway on metered cloud calls.`,{paddingBottom:12}),R({paddingTop:4,paddingBottom:4}),P(`02 · A field guide to product-led onboarding`,{fontWeight:`bold`,link:`#`,paddingBottom:4}),H(`Stop sending welcome emails. Start designing the first 5 minutes.`,{paddingBottom:12}),R({paddingTop:4,paddingBottom:4}),P(`03 · Inside the new Madrid co-working scene`,{fontWeight:`bold`,link:`#`,paddingBottom:4}),H(`Why founders are leaving Lisbon for Spain's quiet capital.`,{paddingBottom:16})]),z(`cta.subscribe_share`,`Forward to a friend`,[R({paddingTop:8,paddingBottom:8}),P(`Liked this? Forward it to a friend.`,{align:`center`,paddingTop:16,paddingBottom:12}),I(`Share The Weekly`,`#`),L(16)]),z(`footer.simple`,`Footer`,[H(`© 2026 The Weekly · 350 Madison Ave · NY 10017`,{align:`center`,paddingTop:16}),H(`Manage preferences · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})}),N.register({id:`flash-sale`,name:`Flash Sale — 24h`,category:`ecommerce`,description:`Urgency-driven 24-hour flash sale with countdown headline, three featured products with old/final prices, and a closing CTA.`,tags:[`ecommerce`,`sale`,`promo`,`discount`,`urgency`],thumbnail:`https://placehold.co/600x800/EA580C/FFFFFF?text=FLASH+SALE`,build:()=>({version:`1.0`,meta:{name:`Flash Sale — 24h only`,previewText:`Up to 50% off — ends midnight tonight.`},theme:A,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.flash`,`Flash hero`,[P(`⏰ FLASH SALE — ENDS IN 24H`,{color:`{colors.buttonText}`,align:`center`,fontWeight:`bold`,letterSpacing:3,paddingTop:24,paddingBottom:8}),P(`Up to 50% off everything`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:32,fontWeight:`bold`,paddingBottom:16}),I(`Shop the sale`,`#`,{backgroundColor:`{colors.surface}`,color:`{colors.primary}`}),L(24)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0}),z(`ecom.featured_grid`,`Featured products`,[P(`Today's picks`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:24,fontWeight:`bold`,paddingTop:24,paddingBottom:16}),G([W({name:`Linen Tote Bag`,image:U(400,400,`Tote`),oldPrice:`$59`,finalPrice:`$29`}),W({name:`Ceramic Mug Set`,image:U(400,400,`Mug+Set`),oldPrice:`$48`,finalPrice:`$24`}),W({name:`Brass Desk Lamp`,image:U(400,400,`Lamp`),oldPrice:`$159`,finalPrice:`$79`})],{columns:3,showOldPrice:!0,buttonLabel:`Add to bag`})]),z(`cta.urgency`,`Final CTA`,[P(`Don't sleep on it — this ends at midnight.`,{align:`center`,fontWeight:`bold`,paddingTop:16,paddingBottom:12}),I(`Shop now`,`#`),L(24)]),z(`footer.simple`,`Footer`,[H(`© 2026 Acme Co · Unsubscribe · Manage preferences`,{align:`center`,paddingTop:16,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})}),N.register({id:`abandoned-cart`,name:`Abandoned Cart Recovery`,category:`abandoned_cart`,description:`Friendly reminder showing items left in the cart, a discount nudge, and a return-to-cart button. For automated cart-recovery flows.`,tags:[`abandoned-cart`,`recovery`,`automation`,`ecommerce`],thumbnail:`https://placehold.co/600x800/F5F1EA/2C2928?text=Cart+Reminder`,build:()=>({version:`1.0`,meta:{name:`You left something behind`,previewText:`Your cart is waiting — and we saved your spot.`},theme:me,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`header.logo`,`Logo`,[P(`ACME`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,letterSpacing:4,paddingTop:24,paddingBottom:24})]),z(`hero.text`,`Headline`,[B(`You left something behind`,{align:`center`,fontSize:28,paddingTop:16,paddingBottom:8}),H(`We saved your bag. Pick up right where you left off.`,{align:`center`,paddingBottom:16})]),z(`ecom.cart_items`,`Cart items`,[G([W({name:`Linen Tote Bag`,image:U(400,400,`Tote`),oldPrice:`$59`,finalPrice:`$39`,description:`Heavyweight natural linen, made in Portugal.`}),W({name:`Cast Iron Skillet`,image:U(400,400,`Skillet`),finalPrice:`$89`,description:`Pre-seasoned, lifetime guarantee.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`Return to cart`})]),z(`cta.discount`,`Discount nudge`,[R({paddingTop:8,paddingBottom:16}),P(`Here's 10% off to seal the deal`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,paddingBottom:4}),P(`COMEBACK10`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:4,paddingBottom:16}),I(`Complete your order`),L(24)]),z(`footer.simple`,`Footer`,[H(`Questions? hello@acme.shop`,{align:`center`,paddingTop:16}),H(`© 2026 Acme · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})}),N.register({id:`product-launch`,name:`Product Launch — Drop`,category:`product_launch`,description:`Bold full-bleed product launch announcement: hero image, big headline, three new products, and an early-access CTA.`,tags:[`launch`,`drop`,`new-arrivals`,`ecommerce`],thumbnail:`https://placehold.co/600x800/000000/D4AF37?text=NEW+DROP`,build:()=>({version:`1.0`,meta:{name:`AUREX 02 — New Drop`,previewText:`The new collection lands today. Limited stock.`},theme:j,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.full_bleed`,`Full-bleed hero`,[F(U(600,700,`AUREX+02`),`AUREX 02 hero`,{width:600,paddingTop:0,paddingBottom:0}),P(`AUREX 02`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:40,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:6,paddingTop:32,paddingBottom:8}),P(`Pure performance. Limited release.`,{align:`center`,color:`{colors.text}`,paddingBottom:24}),I(`Shop the drop`,`#`),L(40)],{backgroundColor:`{colors.surface}`,paddingTop:0,paddingBottom:0}),z(`ecom.collection`,`The Collection`,[H(`THE COLLECTION`,{align:`center`,letterSpacing:4,paddingTop:24,paddingBottom:4}),B(`Meet the line-up`,{align:`center`,fontSize:26,paddingBottom:16}),G([W({name:`AUREX 02 — Carbon`,image:U(400,400,`Carbon`),finalPrice:`$329`}),W({name:`AUREX 02 — Sand`,image:U(400,400,`Sand`),finalPrice:`$329`}),W({name:`AUREX 02 — Sage`,image:U(400,400,`Sage`),finalPrice:`$329`})],{columns:3,showOldPrice:!1,buttonLabel:`View`})]),z(`cta.early_access`,`Early access`,[P(`Members get 24h early access`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,color:`{colors.text}`,paddingTop:32,paddingBottom:16}),I(`Become a member`,`#`),L(40)],{backgroundColor:`{colors.surface}`,paddingTop:0,paddingBottom:0}),z(`footer.brand`,`Footer`,[H(`AUREX · Designed in Berlin · Made in Italy`,{align:`center`,paddingTop:16}),H(`Manage preferences · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})}),N.register({id:`welcome-onboarding`,name:`SaaS Welcome & Onboarding`,category:`onboarding`,description:`First-touch SaaS welcome with a personal note, a 3-step getting-started checklist, and a CTA to the app.`,tags:[`welcome`,`onboarding`,`saas`,`checklist`],thumbnail:`https://placehold.co/600x800/F4F5F7/2563EB?text=Welcome`,build:()=>({version:`1.0`,meta:{name:`Welcome to Acme`,previewText:`Three quick steps to get the most out of Acme.`},theme:pe,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`header.logo`,`Logo`,[F(U(120,40,`ACME`),`Acme`,{width:120,paddingTop:24})]),z(`hero.welcome`,`Welcome`,[B(`Welcome aboard, friend 👋`,{align:`center`,fontSize:28,paddingTop:8,paddingBottom:8}),P(`I'm Maya, the founder of Acme. Thanks for signing up — I wanted to send you a quick note (and a 3-step checklist) so you get value fast.`,{align:`center`,paddingBottom:24})]),z(`content.checklist`,`Checklist`,[P(`✅ 1. Connect your data`,{fontWeight:`bold`,paddingTop:8,paddingBottom:4}),H(`Hook up Stripe, HubSpot or Salesforce in 30 seconds.`,{paddingBottom:12}),R({paddingTop:4,paddingBottom:4}),P(`⚡ 2. Run your first report`,{fontWeight:`bold`,paddingTop:4,paddingBottom:4}),H(`Pick a template, click Run, watch the magic.`,{paddingBottom:12}),R({paddingTop:4,paddingBottom:4}),P(`👯 3. Invite a teammate`,{fontWeight:`bold`,paddingTop:4,paddingBottom:4}),H(`Acme is more fun (and useful) with your team.`,{paddingBottom:16})]),z(`cta.app`,`Open the app`,[I(`Open Acme`,`#`),L(8),H(`Or reply to this email — a real human will read it.`,{align:`center`,paddingBottom:24})]),z(`footer.simple`,`Footer`,[H(`Acme, Inc · 100 Market St · San Francisco, CA`,{align:`center`,paddingTop:16}),H(`Manage notifications · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})});var Ce={id:`event-invite`,name:`Event Invite`,category:`event`,description:`Invite to a live event with a header image, date / time / location card, agenda highlights, and an RSVP button.`,tags:[`event`,`invite`,`rsvp`,`conference`,`meetup`],thumbnail:`https://placehold.co/600x800/111827/FAFAF9?text=You're+Invited`,build:()=>({version:`1.0`,meta:{name:`You're invited: Acme Summit 2026`,previewText:`Join us June 12 in Brooklyn for talks, food and a rooftop after-party.`},theme:he,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`header.logo`,`Logo`,[P(`ACME SUMMIT`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,letterSpacing:6,paddingTop:24,paddingBottom:16})]),z(`hero.event`,`Event hero`,[F(U(600,320,`Acme+Summit`),`Acme Summit`,{width:600,paddingTop:0,paddingBottom:16}),B(`You're invited.`,{align:`center`,fontSize:32,paddingTop:8,paddingBottom:4}),H(`A one-day gathering for builders. Brooklyn, NY.`,{align:`center`,paddingBottom:24})]),z(`content.event_card`,`Event details`,[P(`📅 Friday, June 12, 2026`,{align:`center`,fontWeight:`bold`,paddingTop:24,paddingBottom:4}),P(`⏰ 9:00 AM — 6:00 PM`,{align:`center`,paddingBottom:4}),P(`📍 The Invisible Dog · 51 Bergen St, Brooklyn`,{align:`center`,paddingBottom:16}),I(`RSVP — free`,`#`),L(24)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0}),z(`content.agenda`,`Agenda`,[R({paddingTop:16,paddingBottom:16}),we(`AGENDA HIGHLIGHTS`),Te(`9:30`,`Opening keynote — Maya Chen, Acme`),Te(`11:00`,`Workshop: shipping AI features users actually want`),Te(`13:00`,`Lunch + open conversations`),Te(`15:30`,`Panel: building durable companies`),Te(`18:00`,`Rooftop after-party`),L(16)]),z(`footer.simple`,`Footer`,[H(`Acme, Inc · 100 Market St · San Francisco, CA`,{align:`center`,paddingTop:16}),H(`Update preferences · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};function we(e){return P(e,{fontFamily:`{fonts.button}`,color:`{colors.muted}`,fontSize:11,fontWeight:`bold`,letterSpacing:3,paddingBottom:12})}function Te(e,t){return P(`<b>${e}</b> · ${t}`,{paddingTop:6,paddingBottom:6})}N.register(Ce),N.register({id:`order-receipt`,name:`Order Receipt`,category:`transactional`,description:`Transactional order confirmation with order number, an itemized table, totals, shipping address and a help footer.`,tags:[`transactional`,`receipt`,`order`,`confirmation`],thumbnail:`https://placehold.co/600x800/F4F5F7/0F172A?text=Order+%23A12345`,build:()=>({version:`1.0`,meta:{name:`Your order #A12345 is confirmed`,previewText:`Thanks for your order! Here's your receipt.`},theme:pe,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`header.logo`,`Logo`,[P(`ACME`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,letterSpacing:4,paddingTop:24,paddingBottom:24})]),z(`hero.confirmation`,`Confirmation`,[B(`Thanks, your order is confirmed`,{align:`center`,fontSize:26,paddingTop:8,paddingBottom:4}),H(`Order #A12345 · placed April 30, 2026`,{align:`center`,paddingBottom:24})]),z(`tx.items`,`Items`,[P(`ITEMS`,{fontSize:11,letterSpacing:3,fontWeight:`bold`,color:`{colors.muted}`,paddingTop:8,paddingBottom:12}),P(`Linen Tote Bag · Natural · Qty 1`,{fontWeight:`bold`,paddingBottom:4}),H(`$39.00`,{paddingBottom:12}),R({paddingTop:4,paddingBottom:4}),P(`Ceramic Mug · Sand · Qty 2`,{fontWeight:`bold`,paddingBottom:4}),H(`$48.00`,{paddingBottom:16}),R({paddingTop:8,paddingBottom:12}),P(`Subtotal · $87.00`,{align:`right`,paddingBottom:4}),P(`Shipping · $9.00`,{align:`right`,paddingBottom:4}),P(`<b>Total · $96.00</b>`,{align:`right`,fontSize:18,paddingBottom:16})]),z(`tx.shipping`,`Shipping address`,[P(`SHIPPING TO`,{fontSize:11,letterSpacing:3,fontWeight:`bold`,color:`{colors.muted}`,paddingTop:16,paddingBottom:8}),P(`Alex Rada<br/>350 Madison Ave<br/>New York, NY 10017`,{paddingBottom:16}),I(`Track shipment`,`#`),L(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0}),z(`footer.help`,`Help`,[H(`Questions about your order? help@acme.shop`,{align:`center`,paddingTop:16}),H(`© 2026 Acme · Privacy`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})});var Ee={id:`blog-digest`,name:`Blog / Publishing Digest`,category:`publishing`,description:`Editorial digest of three blog posts: each with a thumbnail, title, dek and read-link. Best for media and creators.`,tags:[`blog`,`digest`,`publishing`,`media`],thumbnail:`https://placehold.co/600x800/FAFAF9/111827?text=Blog+Digest`,build:()=>({version:`1.0`,meta:{name:`This week on the blog`,previewText:`Three new pieces — including our deep dive on micro-SaaS in 2026.`},theme:he,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`header.publication`,`Publication header`,[P(`THE LEDGER`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,letterSpacing:6,paddingTop:32,paddingBottom:4}),H(`Notes on building, weekly`,{align:`center`,paddingBottom:24}),R({paddingTop:0,paddingBottom:0})]),De(`Micro-SaaS in 2026: smaller, sharper, more profitable`,`Why the next wave of indie founders is winning by going narrower than you think.`,`Maya Chen · 8 min read`,U(560,280,`Post+1`)),De(`Stop A/B testing your homepage`,`An evidence-based case for spending that energy on your activation flow instead.`,`Jordan Lee · 6 min read`,U(560,280,`Post+2`)),De(`The five-line founder check-in`,`A weekly journaling pattern that keeps the team aligned and the founder sane.`,`Sam Park · 4 min read`,U(560,280,`Post+3`)),z(`footer.simple`,`Footer`,[H(`The Ledger · Published Tuesdays`,{align:`center`,paddingTop:16}),H(`© 2026 · Manage subscription · Unsubscribe`,{align:`center`,paddingTop:4,paddingBottom:24,link:`#`})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};function De(e,t,n,r){return z(`content.post`,`Post`,[F(r,e,{width:560,paddingTop:24,paddingBottom:16}),B(e,{fontSize:24,paddingBottom:8}),P(t,{paddingBottom:8}),H(n,{paddingBottom:4}),P(`Read the full post →`,{color:`{colors.primary}`,fontWeight:`bold`,link:`#`,paddingTop:4,paddingBottom:8}),L(8)])}N.register(Ee);var Oe={id:`back-in-stock`,name:`Back in Stock Spotlight`,category:`ecommerce`,description:`Urgency-led back-in-stock alert featuring a single bestselling item, social proof, limited-stock messaging, and a fast path to purchase.`,tags:[`ecommerce`,`back-in-stock`,`urgency`,`product`,`automation`],thumbnail:U(600,800,`Back in Stock`),build:()=>({version:`1.0`,meta:{name:`It's back — and already moving fast`,previewText:`Good news, {user.firstname}: your saved favorite is back in stock.`},theme:A,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.back_in_stock`,`Back in stock hero`,[V(`It's back!`,{align:`center`,paddingTop:28}),B(`Your wait is over, {user.firstname}`,{align:`center`,fontSize:30,paddingTop:6,paddingBottom:8}),H(`The bestseller you checked out is back on the shelf — but only in a small restock batch.`,{align:`center`,paddingBottom:20})]),z(`ecom.product_spotlight`,`Product spotlight`,[G([W({name:`CloudSoft Lounge Set`,image:U(520,520,`CloudSoft Lounge Set`),oldPrice:`$128`,finalPrice:`$96`,description:`Rated 4.9/5 for the buttery-soft feel and all-day comfort.`,stars:5,buttonLabel:`Shop before it's gone`})],{columns:1,showOldPrice:!0,showDescription:!0,showStars:!0,buttonLabel:`Shop before it's gone`})]),z(`content.urgency`,`Urgency note`,[R({color:`{colors.background}`,paddingTop:8,paddingBottom:12}),P(`Only a limited number are available in your size range.`,{align:`center`,fontWeight:`bold`,color:`{colors.primary}`,paddingTop:0,paddingBottom:6}),H(`Popular restocks like this usually sell through within a day, so we wanted you to have first dibs.`,{align:`center`,paddingBottom:16}),I(`Shop before it's gone`),L(16)]),z(`footer.simple`,`Footer`,[H(`Acme Store · Curated essentials you actually reach for`,{align:`center`,paddingTop:16,paddingBottom:4}),K([{label:`Unsubscribe`,type:`unsubscribe`},{label:`Manage preferences`,type:`manage_preferences`}],{align:`center`,paddingTop:0,paddingBottom:24})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};N.register(Oe);var ke={id:`price-drop-alert`,name:`Price Drop Alert`,category:`ecommerce`,description:`Savings-focused alert for recently discounted products, combining social proof, urgency, and a concise shop-now call to action.`,tags:[`ecommerce`,`price-drop`,`discount`,`savings`,`automation`],thumbnail:U(600,800,`Price Drop Alert`),build:()=>({version:`1.0`,meta:{name:`Prices just dropped on your saved picks`,previewText:`A deal worth opening: your favorites are now marked down.`},theme:A,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.price_drop`,`Price drop hero`,[V(`Price Drop Alert`,{align:`center`,paddingTop:28}),B(`Save more on the pieces you had your eye on`,{align:`center`,fontSize:30,paddingTop:6,paddingBottom:8}),H(`Fresh markdowns just landed, {user.firstname}. These are the deals shoppers are adding to bag first.`,{align:`center`,paddingBottom:20})]),z(`ecom.deal_grid`,`Deal grid`,[G([W({name:`Weekend Travel Tote`,image:U(400,400,`Travel Tote`),oldPrice:`$89`,finalPrice:`$64`,stars:5}),W({name:`Stoneware Dinner Set`,image:U(400,400,`Dinner Set`),oldPrice:`$120`,finalPrice:`$82`,stars:4}),W({name:`Everyday Knit Throw`,image:U(400,400,`Knit Throw`),oldPrice:`$72`,finalPrice:`$49`,stars:5})],{columns:3,showOldPrice:!0,showStars:!0,buttonLabel:`See details`})]),z(`cta.deal`,`Deal CTA`,[P(`Prices may change anytime.`,{align:`center`,fontWeight:`bold`,color:`{colors.primary}`,paddingTop:12,paddingBottom:6}),H(`If you've been waiting for the right moment, this is a very good one.`,{align:`center`,paddingBottom:16}),I(`Grab the deal`),L(16)]),z(`footer.simple`,`Footer`,[H(`Acme Store · Thoughtful finds, better prices`,{align:`center`,paddingTop:16,paddingBottom:4}),K([{label:`Unsubscribe`,type:`unsubscribe`},{label:`View in browser`,type:`view_in_browser`}],{align:`center`,paddingTop:0,paddingBottom:24})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};N.register(ke);var Ae={id:`post-purchase-follow-up`,name:`Post-Purchase Follow-Up`,category:`transactional`,description:`Warm after-purchase email with confirmation messaging, practical usage guidance, support reassurance, and a gentle review request.`,tags:[`transactional`,`post-purchase`,`onboarding`,`follow-up`,`review`],thumbnail:U(600,800,`Post Purchase`),build:()=>({version:`1.0`,meta:{name:`Thanks again for your order, {user.firstname}`,previewText:`A few simple tips to help you get the most from your new purchase.`},theme:me,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.follow_up`,`Follow-up hero`,[V(`Thank you`,{align:`center`,paddingTop:28}),B(`Thanks for your order, {user.firstname}`,{align:`center`,fontSize:28,paddingTop:6,paddingBottom:8}),H(`Your order is confirmed, packed with care, and on its way to becoming a favorite.`,{align:`center`,paddingBottom:16})]),z(`content.tips_visual`,`Usage image`,[F(U(552,260,`Getting Started Tips`),`Getting started tips`,{width:552,paddingTop:0,paddingBottom:8})]),z(`content.usage_tips`,`Usage tips`,[P(`1. Unbox and set up with intention`,{fontWeight:`bold`,paddingTop:8,paddingBottom:4}),H(`Start with the quick-start guide included in the package for the smoothest first use.`,{paddingBottom:12}),R({color:`{colors.background}`,paddingTop:4,paddingBottom:4}),P(`2. Make it part of your weekly routine`,{fontWeight:`bold`,paddingTop:4,paddingBottom:4}),H(`The best results come from small, consistent use — a few minutes goes a long way.`,{paddingBottom:12}),R({color:`{colors.background}`,paddingTop:4,paddingBottom:4}),P(`3. Save this email for care and support`,{fontWeight:`bold`,paddingTop:4,paddingBottom:4}),H(`Need help later? We've included the fastest way to reach us just below.`,{paddingBottom:12})]),z(`support.help`,`Support`,[P(`Need a hand?`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,paddingTop:8,paddingBottom:4}),H(`Reply directly to this email or visit our help center any time. Our team is happy to help with setup, care, and product questions.`,{align:`center`,paddingBottom:16}),I(`Leave a review`,`#`,{backgroundColor:`{colors.surface}`,color:`{colors.primary}`}),L(8),H(`If you're loving it, a quick review helps other customers feel confident too.`,{align:`center`,paddingBottom:20})]),z(`footer.simple`,`Footer`,[H(`Acme Care Team · Here when you need us`,{align:`center`,paddingTop:16,paddingBottom:4}),K([{label:`Unsubscribe`,type:`unsubscribe`},{label:`Manage preferences`,type:`manage_preferences`}],{align:`center`,paddingTop:0,paddingBottom:24})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};N.register(Ae);var je={id:`review-request`,name:`Review Request`,category:`transactional`,description:`Clean post-purchase review request with a product visual, rating prompt, founder note, and a simple one-click review CTA.`,tags:[`transactional`,`review`,`rating`,`social-proof`,`post-purchase`],thumbnail:U(600,800,`Review Request`),build:()=>({version:`1.0`,meta:{name:`How did you like it?`,previewText:`A quick review from you would mean a lot to us.`},theme:pe,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.product_review`,`Product review hero`,[F(U(552,320,`Your Recent Purchase`),`Your recent purchase`,{width:552,paddingTop:24,paddingBottom:12}),B(`How did you like it?`,{align:`center`,fontSize:28,paddingTop:4,paddingBottom:8}),P(`⭐⭐⭐⭐⭐`,{align:`center`,fontSize:26,paddingTop:0,paddingBottom:8}),H(`Your honest rating helps us improve and helps other shoppers buy with confidence.`,{align:`center`,paddingBottom:16})]),z(`content.founder_note`,`Founder note`,[P(`A quick personal note from our founder`,{fontFamily:`{fonts.heading}`,fontSize:22,fontWeight:`bold`,align:`center`,paddingTop:8,paddingBottom:6}),H(`Hi {user.firstname}, I'm Lena, founder at Acme. We read every review because thoughtful feedback shapes what we make next. If you have 60 seconds, we'd be grateful to hear what you think.`,{align:`center`,paddingBottom:16}),I(`Write a review`),L(8),H(`As a thank-you, you'll unlock early access to future launches and members-only offers.`,{align:`center`,fontSize:13,paddingBottom:20})]),z(`footer.simple`,`Footer`,[H(`Acme · Built with customer feedback at the center`,{align:`center`,paddingTop:16,paddingBottom:4}),K([{label:`Unsubscribe`,type:`unsubscribe`},{label:`View in browser`,type:`view_in_browser`}],{align:`center`,paddingTop:0,paddingBottom:24})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};N.register(je);var Me={id:`replenishment-reminder`,name:`Replenishment Reminder`,category:`ecommerce`,description:`Restock-focused reminder with recent order context, a quick reorder path, and a gentle subscription nudge for repeat purchases.`,tags:[`ecommerce`,`replenishment`,`reorder`,`subscription`,`automation`],thumbnail:U(600,800,`Restock Reminder`),build:()=>({version:`1.0`,meta:{name:`Time to restock your favorite`,previewText:`Running low? Reordering takes one click.`},theme:me,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.restock`,`Restock hero`,[V(`Running low?`,{align:`center`,paddingTop:28}),B(`Time to restock, {user.firstname}`,{align:`center`,fontSize:30,paddingTop:6,paddingBottom:8}),H(`We thought we'd send a nudge before you run out of the good stuff.`,{align:`center`,paddingBottom:16})]),z(`content.product_image`,`Product image`,[F(U(552,320,`Daily Essentials Refill`),`Daily essentials refill`,{width:552,paddingTop:0,paddingBottom:12})]),z(`content.reorder_note`,`Reorder details`,[H(`Last ordered 32 days ago · Daily Greens Blend · 1 pack`,{align:`center`,paddingTop:4,paddingBottom:12}),P(`Reordering now means you stay stocked without missing a beat.`,{align:`center`,fontWeight:`bold`,paddingTop:0,paddingBottom:12}),I(`Reorder now`),L(8),H(`Want one less thing to remember? Switch to subscribe & save for automatic delivery and a little extra value each month.`,{align:`center`,paddingBottom:20})]),z(`footer.simple`,`Footer`,[H(`Acme Refill Club · Practical reminders, never spam`,{align:`center`,paddingTop:16,paddingBottom:4}),K([{label:`Unsubscribe`,type:`unsubscribe`},{label:`Manage preferences`,type:`manage_preferences`}],{align:`center`,paddingTop:0,paddingBottom:24})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};N.register(Me);var Ne={id:`vip-early-access`,name:`VIP Early Access`,category:`ecommerce`,description:`Exclusive loyalty email offering a 24-hour head start, premium styling, curated preview products, and a private-access CTA.`,tags:[`ecommerce`,`vip`,`exclusive`,`early-access`,`loyalty`],thumbnail:U(600,800,`VIP Early Access`),build:()=>({version:`1.0`,meta:{name:`VIP early access starts now`,previewText:`You're in — enjoy 24 hours before everyone else.`},theme:j,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.vip`,`VIP hero`,[P(`VIP EARLY ACCESS`,{align:`center`,color:`{colors.primary}`,fontWeight:`bold`,letterSpacing:3,paddingTop:28,paddingBottom:8}),B(`You're in. 24h before everyone else.`,{align:`center`,fontSize:32,paddingTop:0,paddingBottom:10}),H(`Because you're one of our most valued customers, {user.firstname}, the collection is open to you first.`,{align:`center`,paddingBottom:18}),I(`Shop my early access`,`#`,{backgroundColor:`{colors.primary}`,color:`{colors.buttonText}`}),L(16)],{backgroundColor:`{colors.surface}`,paddingTop:0,paddingBottom:0}),z(`ecom.preview_grid`,`Preview grid`,[G([W({name:`Noir Leather Weekender`,image:U(400,400,`Leather Weekender`),finalPrice:`$320`,description:`Soft-grain finish with understated gold hardware.`}),W({name:`Reserve Silk Robe`,image:U(400,400,`Silk Robe`),finalPrice:`$210`,description:`Cut for quiet drama with fluid drape and shine.`})],{columns:2,showOldPrice:!1,showDescription:!0,buttonLabel:`Preview piece`})]),z(`content.exclusive_note`,`Exclusive note`,[P(`Your private window closes tomorrow at midnight.`,{align:`center`,color:`{colors.primary}`,fontWeight:`bold`,paddingTop:8,paddingBottom:20})]),z(`footer.simple`,`Footer`,[H(`Acme Private Client · Reserved access for loyal members`,{align:`center`,paddingTop:16,paddingBottom:4}),K([{label:`Unsubscribe`,type:`unsubscribe`},{label:`Manage preferences`,type:`manage_preferences`}],{align:`center`,color:`{colors.muted}`,paddingTop:0,paddingBottom:24})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};N.register(Ne);var Pe={id:`birthday-reward`,name:`Birthday Reward`,category:`ecommerce`,description:`Personalized birthday email with a celebratory headline, warm note, redeemable voucher code, and a gift-led call to action.`,tags:[`ecommerce`,`birthday`,`reward`,`loyalty`,`personalisation`],thumbnail:U(600,800,`Birthday Reward`),build:()=>({version:`1.0`,meta:{name:`Happy Birthday, {user.firstname}!`,previewText:`A little birthday gift from us to you.`},theme:A,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.birthday`,`Birthday hero`,[V(`A gift for you`,{align:`center`,paddingTop:28}),B(`🎂 Happy Birthday {user.firstname}! 🎉`,{align:`center`,fontSize:32,paddingTop:6,paddingBottom:10}),H(`We're celebrating you with something sweet: a birthday reward to spend on anything that makes this year feel extra good.`,{align:`center`,paddingBottom:14})]),z(`content.reward`,`Birthday reward`,[P(`Your birthday treat is ready to unwrap:`,{align:`center`,fontWeight:`bold`,paddingTop:8,paddingBottom:4}),xe(`BDAY20`),H(`Use this code at checkout to enjoy your birthday savings on your next order.`,{align:`center`,paddingTop:0,paddingBottom:16}),I(`Claim my birthday gift`),L(8),H(`Expires in 7 days, so don't let your gift sit unopened.`,{align:`center`,fontSize:13,paddingBottom:20})]),z(`footer.simple`,`Footer`,[H(`Acme Rewards · Celebrating the good stuff with you`,{align:`center`,paddingTop:16,paddingBottom:4}),K([{label:`Unsubscribe`,type:`unsubscribe`},{label:`View in browser`,type:`view_in_browser`}],{align:`center`,paddingTop:0,paddingBottom:24})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};N.register(Pe);var Fe={id:`win-back`,name:`Win-Back Campaign`,category:`ecommerce`,description:`Editorial-style re-engagement email with a personal note, a what's-new product preview, and a simple incentive to return.`,tags:[`ecommerce`,`win-back`,`re-engagement`,`lapsed`,`discount`],thumbnail:U(600,800,`We Miss You`),build:()=>({version:`1.0`,meta:{name:`We miss you, {user.firstname}`,previewText:`It's been a while — here's what's new and a reason to come back.`},theme:he,settings:{width:600,backgroundColor:`{colors.background}`,contentBackgroundColor:`{colors.surface}`},modules:[z(`hero.win_back`,`Win-back hero`,[V(`We miss you`,{align:`center`,paddingTop:28}),B(`It's been a little while, {user.firstname}`,{align:`center`,fontSize:30,paddingTop:6,paddingBottom:8}),H(`Since your last order about 6 months ago, we've added new favorites, improved bestsellers, and kept the experience even easier.`,{align:`center`,paddingBottom:18})]),z(`editorial.whats_new`,`What's new`,[P(`What's new`,{align:`center`,fontFamily:`{fonts.heading}`,fontSize:24,fontWeight:`bold`,paddingTop:8,paddingBottom:16}),G([W({name:`Studio Candle Trio`,image:U(400,400,`Candle Trio`),finalPrice:`$58`,description:`Three layered scents designed for calm evenings in.`}),W({name:`Washed Cotton Throw`,image:U(400,400,`Cotton Throw`),finalPrice:`$74`,description:`An easy, year-round layer customers keep reordering.`})],{columns:2,showOldPrice:!1,showDescription:!0,buttonLabel:`See what's new`})]),z(`offer.comeback`,`Comeback offer`,[P(`Your best offer to return`,{align:`center`,fontWeight:`bold`,paddingTop:12,paddingBottom:4}),xe(`COMEBACK15`),H(`Use this discount code on your next order — no hoops, just a warm welcome back.`,{align:`center`,paddingTop:0,paddingBottom:16}),I(`Come back →`),L(16)]),z(`footer.simple`,`Footer`,[H(`Acme Editorial · Notes, launches, and thoughtful offers`,{align:`center`,paddingTop:16,paddingBottom:4}),K([{label:`Unsubscribe`,type:`unsubscribe`},{label:`Manage preferences`,type:`manage_preferences`}],{align:`center`,paddingTop:0,paddingBottom:24})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})]})};N.register(Fe);function Ie({open:e,onClose:t}){let n=M(e=>e.loadTemplate),r=M(e=>e.doc.modules.length>0),[i,a]=(0,l.useState)(`all`),[o,s]=(0,l.useState)(``);(0,l.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]);let c=(0,l.useMemo)(()=>N.list(),[e]),u=(0,l.useMemo)(()=>{let e=c;if(i!==`all`&&(e=e.filter(e=>e.category===i)),o.trim()){let t=o.toLowerCase();e=e.filter(e=>e.name.toLowerCase().includes(t)||e.description.toLowerCase().includes(t)||(e.tags??[]).some(e=>e.toLowerCase().includes(t)))}return e},[c,i,o]);if(!e)return null;let d=e=>{r&&!window.confirm(`Loading "${e.name}" will replace your current email. Continue?`)||(n(e),t())},m=[{key:`all`,label:`All templates`},...Object.entries(ye).map(([e,t])=>({key:e,label:t}))];return(0,p.jsx)(`div`,{className:`fixed inset-0 z-50 flex bg-black/60 backdrop-blur-sm`,children:(0,p.jsxs)(`div`,{className:`m-auto flex h-[92vh] w-[96vw] max-w-350 flex-col overflow-hidden rounded-2xl bg-white shadow-2xl`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-200 px-6 py-4`,children:[(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`h2`,{className:`text-lg font-semibold text-neutral-900`,children:`Start from a template`}),(0,p.jsx)(`p`,{className:`text-sm text-neutral-500`,children:`Pick a fully-built email and tweak from there.`})]}),(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg p-2 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900`,"aria-label":`Close`,children:(0,p.jsx)(f.X,{size:20})})]}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsxs)(`aside`,{className:`w-56 shrink-0 overflow-y-auto border-r border-neutral-200 bg-neutral-50 p-3`,children:[(0,p.jsxs)(`div`,{className:`relative mb-3`,children:[(0,p.jsx)(f.Search,{size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-neutral-400`}),(0,p.jsx)(`input`,{value:o,onChange:e=>s(e.target.value),placeholder:`Search…`,className:`w-full rounded-md border border-neutral-200 bg-white py-1.5 pl-7 pr-2 text-sm outline-none focus:border-neutral-400`})]}),(0,p.jsx)(`ul`,{className:`space-y-0.5`,children:m.map(e=>(0,p.jsx)(`li`,{children:(0,p.jsx)(`button`,{onClick:()=>a(e.key),className:`block w-full rounded-md px-2.5 py-1.5 text-left text-sm transition `+(e.key===i?`bg-neutral-900 text-white`:`text-neutral-700 hover:bg-neutral-200`),children:e.label})},e.key))})]}),(0,p.jsx)(`main`,{className:`flex-1 overflow-y-auto p-6`,children:u.length===0?(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-sm text-neutral-500`,children:`No templates match.`}):(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-5 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5`,children:u.map(e=>(0,p.jsx)(Le,{def:e,onPick:()=>d(e)},e.id))})})]})]})})}function Le({def:e,onPick:t}){return(0,p.jsxs)(`button`,{onClick:t,className:`group flex flex-col overflow-hidden rounded-xl border border-neutral-200 bg-white text-left transition hover:-translate-y-0.5 hover:border-neutral-400 hover:shadow-lg`,children:[(0,p.jsx)(`div`,{className:`aspect-3/4 w-full overflow-hidden bg-neutral-100`,children:e.thumbnail?(0,p.jsx)(`img`,{src:e.thumbnail,alt:e.name,className:`h-full w-full object-cover transition group-hover:scale-[1.02]`}):(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-xs text-neutral-400`,children:`No preview`})}),(0,p.jsxs)(`div`,{className:`flex flex-col gap-1 p-3`,children:[(0,p.jsx)(`div`,{className:`text-xs uppercase tracking-wider text-neutral-500`,children:ye[e.category]}),(0,p.jsx)(`div`,{className:`line-clamp-1 text-sm font-semibold text-neutral-900`,children:e.name}),(0,p.jsx)(`div`,{className:`line-clamp-2 text-xs text-neutral-500`,children:e.description})]})]})}function Re(){let{doc:e,updateMeta:t,undo:n,redo:r,past:i,future:a,exportJson:o,importJson:s,exportHtml:c,saveToLocalStorage:u,viewMode:d,setViewMode:m,resetDocument:h}=M(),g=(0,l.useRef)(null),[_,v]=(0,l.useState)(!1),[y,b]=(0,l.useState)(!1),x=()=>{e.modules.length!==0&&window.confirm(`Reset the editor? Your current email will be cleared.`)&&h()},S=(e,t,n)=>{let r=new Blob([t],{type:n}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=e,a.click(),URL.revokeObjectURL(i)};return(0,p.jsxs)(`div`,{className:`flex items-center h-12 px-4 bg-white border-b border-gray-200 shrink-0`,children:[(0,p.jsx)(`div`,{className:`shrink-0 w-48`,children:(0,p.jsx)(`input`,{className:`font-medium text-sm px-2 py-1 rounded hover:bg-gray-50 focus:bg-gray-50 outline-none w-full`,value:e.meta.name,onChange:e=>t({name:e.target.value})})}),(0,p.jsxs)(`div`,{className:`flex-1 flex items-center justify-center gap-1`,children:[(0,p.jsxs)(`div`,{className:`inline-flex items-center bg-gray-100 rounded p-0.5 mr-1`,children:[(0,p.jsxs)(`button`,{title:`Desktop preview`,onClick:()=>m(`desktop`),className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${d===`desktop`?`bg-white shadow text-gray-900`:`text-gray-500 hover:text-gray-700`}`,children:[(0,p.jsx)(f.Monitor,{size:14}),` Desktop`]}),(0,p.jsxs)(`button`,{title:`Mobile preview`,onClick:()=>m(`mobile`),className:`flex items-center gap-1 px-2 py-1 rounded text-xs transition-colors ${d===`mobile`?`bg-white shadow text-gray-900`:`text-gray-500 hover:text-gray-700`}`,children:[(0,p.jsx)(f.Smartphone,{size:14}),` Mobile`]})]}),(0,p.jsxs)(Ve,{title:`Browse templates`,onClick:()=>b(!0),children:[(0,p.jsx)(f.LayoutTemplate,{size:16}),` Templates`]}),(0,p.jsxs)(Ve,{title:`Reset editor`,onClick:x,disabled:e.modules.length===0,children:[(0,p.jsx)(f.RotateCcw,{size:16}),` Reset`]}),(0,p.jsx)(He,{}),(0,p.jsx)(Ve,{title:`Undo`,onClick:n,disabled:i.length===0,children:(0,p.jsx)(f.Undo2,{size:16})}),(0,p.jsx)(Ve,{title:`Redo`,onClick:r,disabled:a.length===0,children:(0,p.jsx)(f.Redo2,{size:16})}),(0,p.jsx)(He,{}),(0,p.jsx)(Ve,{title:`Save draft (local)`,onClick:u,children:(0,p.jsx)(f.Save,{size:16})}),(0,p.jsxs)(Ve,{title:`Preview`,onClick:()=>{let e=c(),t=window.open(``,`_blank`);t&&(t.document.write(e),t.document.close()),v(!0),setTimeout(()=>v(!1),600)},children:[(0,p.jsx)(f.Eye,{size:16}),` `,_?`Opened`:`Preview`]})]}),(0,p.jsxs)(`div`,{className:`shrink-0 flex justify-end w-48`,children:[(0,p.jsx)(`input`,{ref:g,type:`file`,accept:`.json`,hidden:!0,onChange:e=>{let t=e.target.files?.[0];t&&(t.text().then(e=>{let t=s(e);t.ok||alert(`Import failed: ${t.error}`)}),e.target.value=``)}}),(0,p.jsx)(ze,{onImport:()=>g.current?.click(),onExportJson:()=>{S(`${e.meta.name||`email`}.json`,o(),`application/json`)},onExportHtml:()=>{let t=c();S(`${e.meta.name||`email`}.html`,t,`text/html`)}})]}),(0,p.jsx)(Ie,{open:y,onClose:()=>b(!1)})]})}function ze({onImport:e,onExportJson:t,onExportHtml:n}){let[r,i]=(0,l.useState)(!1),a=(0,l.useRef)(null);return(0,l.useEffect)(()=>{if(!r)return;let e=e=>{a.current&&!a.current.contains(e.target)&&i(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[r]),(0,p.jsxs)(`div`,{ref:a,className:`relative`,children:[(0,p.jsxs)(`button`,{onClick:()=>i(e=>!e),className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded text-sm text-gray-700 hover:bg-gray-100 border border-gray-200 transition-colors`,title:`Import / Export`,children:[(0,p.jsx)(f.FileCode,{size:16}),`Export`,(0,p.jsx)(f.ChevronDown,{size:14,className:`transition-transform ${r?`rotate-180`:``}`})]}),r&&(0,p.jsxs)(`div`,{className:`absolute right-0 top-full mt-1 w-48 bg-white border border-gray-200 rounded-lg shadow-lg z-50 py-1 text-sm`,children:[(0,p.jsx)(Be,{icon:(0,p.jsx)(f.Upload,{size:14}),label:`Import JSON`,onClick:()=>{e(),i(!1)}}),(0,p.jsx)(`div`,{className:`mx-2 my-1 border-t border-gray-100`}),(0,p.jsx)(Be,{icon:(0,p.jsx)(f.Download,{size:14}),label:`Export JSON`,onClick:()=>{t(),i(!1)}}),(0,p.jsx)(Be,{icon:(0,p.jsx)(f.FileCode,{size:14}),label:`Export HTML`,onClick:()=>{n(),i(!1)}})]})]})}function Be({icon:e,label:t,onClick:n,highlight:r}){return(0,p.jsxs)(`button`,{onClick:n,className:`w-full flex items-center gap-2 px-3 py-2 hover:bg-gray-50 transition-colors text-left ${r?`text-blue-600 font-medium`:`text-gray-700`}`,children:[e,t]})}function Ve({children:e,onClick:t,disabled:n,title:r,primary:i}){return(0,p.jsx)(`button`,{title:r,disabled:n,onClick:t,className:`flex items-center gap-1.5 px-2.5 py-1.5 rounded text-sm transition-colors ${i?`bg-blue-600 text-white hover:bg-blue-700 disabled:bg-gray-300`:`text-gray-700 hover:bg-gray-100 disabled:text-gray-300 disabled:hover:bg-transparent`}`,children:e})}function He(){return(0,p.jsx)(`div`,{className:`w-px h-5 bg-gray-200 mx-1`})}var Ue=new class{modules=new Map;register(e){this.modules.set(e.type,e)}get(e){return this.modules.get(e)}list(){return Array.from(this.modules.values())}byCategory(e){return this.list().filter(t=>t.category===e)}},We={basic:`Basic`,menu:`Menu`,header:`Header`,content:`Content`,feature:`Feature`,call_to_action:`Call to Action`,ecommerce:`Ecommerce`,transactional:`Transactional`,social:`Social`,footer:`Footer`},Ge=null,Ke=new Set,qe=0;function Je(){qe+=1;for(let e of Ke)e()}function Ye(e){Ge!==e&&(Ge=e,Je())}function Xe(){return Ge}var Ze=e=>(Ke.add(e),()=>{Ke.delete(e)}),Qe=()=>qe;function $e(){return Ue.list().map(e=>({type:e.type,category:e.category,name:e.name,description:e.description,tags:e.tags??[],source:`module`,sample:e.create()}))}function et(e,t){let n=e;for(let e of t)n=tt(n,e);return n}function tt(e,t){switch(t.type){case`update_meta`:return{...e,meta:{...e.meta,...t.patch}};case`update_settings`:return{...e,settings:{...e.settings,...t.patch}};case`apply_theme`:return{...e,theme:t.theme};case`insert_module`:{let n=t.index??e.modules.length,r=[...e.modules];return r.splice(n,0,t.module),{...e,modules:r}}case`delete_module`:return{...e,modules:e.modules.filter(e=>e.id!==t.moduleId)};case`update_module`:return{...e,modules:e.modules.map(e=>e.id===t.moduleId?{...e,...t.patch}:e)};case`update_element`:return{...e,modules:e.modules.map(e=>e.id===t.moduleId?{...e,children:e.children.map(e=>e.id===t.elementId?{...e,...t.patch}:e)}:e)}}}function nt(e){let t=b.safeParse(e);return t.success?{ok:!0,document:t.data}:{ok:!1,error:t.error.message}}var rt={async generate(e){return e.task===`rewrite_text`&&e.instruction?{text:`[AI rewrite] ${e.instruction}`}:e.task===`generate_subject`?{text:`Your weekly insight is here ✨`}:e.task===`generate_preview`?{text:`A short summary that nudges readers to open.`}:{actions:[]}}};function it(e){return JSON.parse(JSON.stringify(e))}function at(e){let t=it(e);return{...t,id:C(`module`),children:(t.children??[]).map(e=>({...e,id:C(`el`)}))}}function ot(e){return e.map(e=>e.type===`insert_module`?{...e,module:at(e.module)}:e)}function st(e,t){if(t.document){let e=nt(it(t.document));return e.ok?{ok:!0,result:{document:e.document,text:t.text,summary:`Replaced the email with a freshly generated document.`}}:{ok:!1,error:e.error}}if(t.actions&&t.actions.length>0){let n=nt(it(et(e,ot(t.actions))));return n.ok?{ok:!0,result:{document:n.document,text:t.text,summary:ct(t.actions)}}:{ok:!1,error:n.error}}return{ok:!0,result:{document:e,text:t.text,summary:t.text?``:`No changes were suggested.`}}}function ct(e){let t={};for(let n of e)t[n.type]=(t[n.type]??0)+1;let n={insert_module:`added block`,delete_module:`removed block`,update_module:`updated block`,update_element:`edited content`,update_meta:`updated meta`,update_settings:`updated settings`,apply_theme:`applied theme`},r=Object.entries(t).map(([e,t])=>{let r=n[e]??e;return t>1?`${t} ${r}s`:r});return r.length?`Applied: ${r.join(`, `)}.`:`No changes applied.`}var lt=[`Create a welcome email for new subscribers`,`Build a flash sale announcement with a product grid`,`Write a weekly newsletter with a lead story and footer`];function ut(){return(0,l.useSyncExternalStore)(Ze,Qe,Qe),Xe()!==null}function dt(){let{doc:e,applyDoc:t}=M(),[n,r]=(0,l.useState)([]),[i,a]=(0,l.useState)(``),[o,s]=(0,l.useState)(!1),c=(0,l.useRef)(null);(0,l.useEffect)(()=>{c.current?.scrollTo({top:c.current.scrollHeight})},[n,o]);let u=async n=>{let i=Xe();if(!i||!n.trim()||o)return;let c={id:crypto.randomUUID(),role:`user`,text:n};r(e=>[...e,c]),a(``),s(!0);let l={task:`create_email`,document:e,instruction:n,context:{catalog:$e()}};try{let n=await i.generate(l),r=st(e,n);if(!r.ok)d(`I produced an invalid document and stopped. (${r.error})`,!0);else{let{document:n,text:i,summary:a}=r.result;n!==e&&t(n),d([i,a].filter(Boolean).join(`
|
|
76
76
|
|
|
77
|
-
`)||`Done.`)}}catch(e){d(e.message||`The AI request failed.`,!0)}finally{s(!1)}},d=(e,t=!1)=>r(n=>[...n,{id:crypto.randomUUID(),role:`assistant`,text:e,error:t}]);return(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,p.jsx)(f.Sparkles,{size:16,className:`text-blue-600`}),(0,p.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500`,children:`AI Assistant`})]}),(0,p.jsxs)(`div`,{ref:c,className:`flex-1 overflow-y-auto pr-1 flex flex-col gap-2`,children:[n.length===0&&(0,p.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[(0,p.jsx)(`p`,{className:`mb-2`,children:`Describe the email you want and I'll assemble it from the available blocks.`}),(0,p.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:nt.map(e=>(0,p.jsx)(`button`,{onClick:()=>u(e),className:`text-left text-xs px-2.5 py-2 rounded border border-gray-200 bg-white hover:border-blue-400 hover:bg-blue-50 transition-colors`,children:e},e))})]}),n.map(e=>(0,p.jsxs)(`div`,{className:`text-xs rounded-lg px-3 py-2 whitespace-pre-wrap ${e.role===`user`?`bg-blue-600 text-white self-end max-w-[85%]`:e.error?`bg-red-50 text-red-700 border border-red-200 self-start max-w-[95%]`:`bg-gray-100 text-gray-800 self-start max-w-[95%]`}`,children:[e.error&&(0,p.jsx)(f.AlertTriangle,{size:12,className:`inline mr-1 -mt-0.5`,"aria-hidden":!0}),e.text]},e.id)),o&&(0,p.jsxs)(`div`,{className:`text-xs text-gray-500 flex items-center gap-1.5 self-start`,children:[(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}),` Thinking…`]})]}),(0,p.jsxs)(`form`,{className:`mt-2 flex items-end gap-1.5`,onSubmit:e=>{e.preventDefault(),u(i)},children:[(0,p.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),u(i))},rows:2,placeholder:`Ask the AI to build or edit your email…`,className:`flex-1 resize-none text-xs rounded border border-gray-300 px-2 py-1.5 outline-none focus:border-blue-500`}),(0,p.jsx)(`button`,{type:`submit`,disabled:o||!i.trim(),title:`Send`,className:`p-2 rounded bg-blue-600 text-white hover:bg-blue-700 disabled:bg-gray-300`,children:o?(0,p.jsx)(f.Loader2,{size:14,className:`animate-spin`}):(0,p.jsx)(f.Send,{size:14})})]})]})}var at=[{id:`basic`,icon:f.Square},{id:`menu`,icon:f.Menu},{id:`header`,icon:f.LayoutTemplate},{id:`content`,icon:f.Type},{id:`feature`,icon:f.Star},{id:`call_to_action`,icon:f.MousePointerClick},{id:`ecommerce`,icon:f.ShoppingCart},{id:`transactional`,icon:f.Receipt},{id:`social`,icon:f.Share2},{id:`footer`,icon:f.AlignVerticalJustifyEnd}];function ot(){let[e,t]=(0,l.useState)(`layers`),[n,r]=(0,l.useState)(!0),{addModule:i,themes:a,applyTheme:o,doc:s}=N(),c=rt(),u=e=>{t(e),r(!0)};return(0,p.jsxs)(`div`,{className:`flex h-full bg-white border-r border-gray-200 shrink-0`,children:[(0,p.jsxs)(`div`,{className:`w-16 border-r border-gray-200 flex flex-col items-center py-2 gap-1`,children:[c&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`button`,{onClick:()=>u(`ai`),title:`AI Assistant`,className:`flex flex-col items-center gap-0.5 w-14 py-2 rounded text-[10px] transition-colors ${e===`ai`&&n?`bg-blue-50 text-blue-700`:`text-blue-600 hover:bg-blue-50`}`,children:[(0,p.jsx)(f.Sparkles,{size:20}),(0,p.jsx)(`span`,{children:`AI`})]}),(0,p.jsx)(`div`,{className:`h-px w-10 bg-gray-200 my-1`})]}),(0,p.jsxs)(`button`,{onClick:()=>u(`layers`),title:`Layout overview`,className:`flex flex-col items-center gap-0.5 w-14 py-2 rounded text-[10px] transition-colors ${e===`layers`&&n?`bg-blue-50 text-blue-700`:`text-gray-600 hover:bg-gray-50`}`,children:[(0,p.jsx)(f.Layers,{size:20}),(0,p.jsx)(`span`,{children:`Layers`})]}),(0,p.jsx)(`div`,{className:`h-px w-10 bg-gray-200 my-1`}),at.map(t=>{let r=t.icon,i=e===t.id&&n;return(0,p.jsxs)(`button`,{onClick:()=>u(t.id),title:Le[t.id],className:`flex flex-col items-center gap-0.5 w-14 py-2 rounded text-[10px] transition-colors ${i?`bg-blue-50 text-blue-700`:`text-gray-600 hover:bg-gray-50`}`,children:[(0,p.jsx)(r,{size:20}),(0,p.jsx)(`span`,{className:`leading-tight text-center`,children:Le[t.id]})]},t.id)}),(0,p.jsx)(`div`,{className:`mt-auto`,children:(0,p.jsxs)(`button`,{onClick:()=>u(`themes`),title:`Themes`,className:`flex flex-col items-center gap-0.5 w-14 py-2 rounded text-[10px] transition-colors ${e===`themes`&&n?`bg-blue-50 text-blue-700`:`text-gray-600 hover:bg-gray-50`}`,children:[(0,p.jsx)(f.Palette,{size:20}),(0,p.jsx)(`span`,{children:`Themes`})]})})]}),n&&(0,p.jsxs)(`div`,{className:`w-64 overflow-y-auto p-3 flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gray-400`,children:e===`layers`?`Layout`:e===`ai`?`AI`:e===`themes`?`Themes`:Le[e]}),(0,p.jsx)(`button`,{onClick:()=>r(!1),title:`Hide panel`,className:`text-gray-400 hover:text-gray-600 rounded p-0.5 hover:bg-gray-100 transition-colors`,children:(0,p.jsx)(f.PanelLeftClose,{size:15})})]}),e===`layers`?(0,p.jsx)(st,{}):e===`ai`?(0,p.jsx)(it,{}):e===`themes`?(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,p.jsxs)(`button`,{onClick:()=>o(e),className:`text-left p-3 rounded border transition-colors ${s.theme.id===e.id?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300 bg-white`}`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,p.jsx)(`div`,{className:`w-4 h-4 rounded`,style:{background:e.tokens.colors.primary}}),(0,p.jsx)(`div`,{className:`w-4 h-4 rounded border border-gray-200`,style:{background:e.tokens.colors.surface}}),(0,p.jsx)(`div`,{className:`w-4 h-4 rounded`,style:{background:e.tokens.colors.text}})]}),(0,p.jsx)(`div`,{className:`text-sm font-medium`,children:e.name})]},e.id))}):(0,p.jsx)(p.Fragment,{children:(0,p.jsxs)(`div`,{className:`grid grid-cols-1 gap-2`,children:[Ie.byCategory(e).map(e=>(0,p.jsxs)(`button`,{onClick:()=>i(e.create()),className:`text-left p-3 rounded border border-gray-200 bg-white hover:border-blue-400 hover:shadow-sm transition-all`,children:[(0,p.jsx)(`div`,{className:`h-12 bg-gray-50 rounded mb-2 flex items-center justify-center text-xs text-gray-400`,children:e.name}),(0,p.jsx)(`div`,{className:`text-xs font-medium text-gray-700`,children:e.name})]},e.type)),Ie.byCategory(e).length===0&&(0,p.jsx)(`div`,{className:`text-xs text-gray-400 italic py-4 text-center`,children:`No modules in this category yet.`})]})})]}),!n&&(0,p.jsx)(`button`,{onClick:()=>r(!0),title:`Show panel`,className:`flex items-center justify-center w-5 h-full text-gray-400 hover:text-gray-600 hover:bg-gray-50 transition-colors border-r border-gray-200`,children:(0,p.jsx)(f.PanelLeftOpen,{size:14})})]})}function st(){let{doc:e,selection:t,setSelection:n,reorderModules:r,deleteModule:i,duplicateModule:a}=N();return e.modules.length===0?(0,p.jsx)(`p`,{className:`text-xs text-gray-400 italic`,children:`No blocks yet. Pick a category from the rail to add modules.`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`text-[10px] text-gray-400 mb-3`,children:[e.modules.length,` block`,e.modules.length===1?``:`s`,` · click to select`]}),(0,p.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.modules.map((o,s)=>(0,p.jsxs)(`li`,{className:`flex items-center gap-1 rounded border px-2 py-1.5 text-xs cursor-pointer transition-colors ${t?.kind!==`email`&&t?.moduleId===o.id?`border-blue-500 bg-blue-50 text-blue-900`:`border-gray-200 bg-white hover:border-gray-300`}`,onClick:()=>n({kind:`module`,moduleId:o.id}),children:[(0,p.jsx)(`span`,{className:`text-[10px] text-gray-400 w-4 shrink-0`,children:s+1}),(0,p.jsxs)(`span`,{className:`flex-1 truncate`,children:[o.name,(0,p.jsxs)(`span`,{className:`text-[10px] text-gray-400 ml-1`,children:[`(`,o.children.length,`)`]})]}),(0,p.jsx)(`button`,{disabled:s===0,onClick:e=>{e.stopPropagation(),r(s,s-1)},className:`p-0.5 text-gray-500 hover:text-blue-600 disabled:opacity-30`,title:`Move up`,children:(0,p.jsx)(f.ArrowUp,{size:12})}),(0,p.jsx)(`button`,{disabled:s===e.modules.length-1,onClick:e=>{e.stopPropagation(),r(s,s+1)},className:`p-0.5 text-gray-500 hover:text-blue-600 disabled:opacity-30`,title:`Move down`,children:(0,p.jsx)(f.ArrowDown,{size:12})}),(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a(o.id)},className:`p-0.5 text-gray-500 hover:text-blue-600`,title:`Duplicate`,children:(0,p.jsx)(f.Copy,{size:12})}),(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i(o.id)},className:`p-0.5 text-gray-500 hover:text-red-600`,title:`Delete`,children:(0,p.jsx)(f.Trash2,{size:12})})]},o.id))})]})}function ct(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,l.useMemo)(()=>e=>{t.forEach(t=>t(e))},t)}var lt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function ut(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function dt(e){return`nodeType`in e}function K(e){return e?ut(e)?e:dt(e)?e.ownerDocument?.defaultView??window:window:window}function ft(e){let{Document:t}=K(e);return e instanceof t}function pt(e){return ut(e)?!1:e instanceof K(e).HTMLElement}function mt(e){return e instanceof K(e).SVGElement}function ht(e){return e?ut(e)?e.document:dt(e)?ft(e)?e:pt(e)||mt(e)?e.ownerDocument:document:document:document}var gt=lt?l.useLayoutEffect:l.useEffect;function _t(e){let t=(0,l.useRef)(e);return gt(()=>{t.current=e}),(0,l.useCallback)(function(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.current==null?void 0:t.current(...n)},[])}function vt(){let e=(0,l.useRef)(null);return[(0,l.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,l.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function yt(e,t){t===void 0&&(t=[e]);let n=(0,l.useRef)(e);return gt(()=>{n.current!==e&&(n.current=e)},t),n}function bt(e,t){let n=(0,l.useRef)();return(0,l.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function xt(e){let t=_t(e),n=(0,l.useRef)(null);return[n,(0,l.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function St(e){let t=(0,l.useRef)();return(0,l.useEffect)(()=>{t.current=e},[e]),t.current}var Ct={};function wt(e,t){return(0,l.useMemo)(()=>{if(t)return t;let n=Ct[e]==null?0:Ct[e]+1;return Ct[e]=n,e+`-`+n},[e,t])}function Tt(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var Et=Tt(1),Dt=Tt(-1);function Ot(e){return`clientX`in e&&`clientY`in e}function kt(e){if(!e)return!1;let{KeyboardEvent:t}=K(e.target);return t&&e instanceof t}function At(e){if(!e)return!1;let{TouchEvent:t}=K(e.target);return t&&e instanceof t}function jt(e){if(At(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Ot(e)?{x:e.clientX,y:e.clientY}:null}var Mt=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[Mt.Translate.toString(e),Mt.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),Nt=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Pt(e){return e.matches(Nt)?e:e.querySelector(Nt)}var Ft={display:`none`};function It(e){let{id:t,value:n}=e;return l.default.createElement(`div`,{id:t,style:Ft},n)}function Lt(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return l.default.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function Rt(){let[e,t]=(0,l.useState)(``);return{announce:(0,l.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var zt=(0,l.createContext)(null);function Bt(e){let t=(0,l.useContext)(zt);(0,l.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Vt(){let[e]=(0,l.useState)(()=>new Set),t=(0,l.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,l.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Ht={draggable:`
|
|
77
|
+
`)||`Done.`)}}catch(e){d(e.message||`The AI request failed.`,!0)}finally{s(!1)}},d=(e,t=!1)=>r(n=>[...n,{id:crypto.randomUUID(),role:`assistant`,text:e,error:t}]);return(0,p.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,p.jsx)(f.Sparkles,{size:16,className:`text-blue-600`}),(0,p.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500`,children:`AI Assistant`})]}),(0,p.jsxs)(`div`,{ref:c,className:`flex-1 overflow-y-auto pr-1 flex flex-col gap-2`,children:[n.length===0&&(0,p.jsxs)(`div`,{className:`text-xs text-gray-500`,children:[(0,p.jsx)(`p`,{className:`mb-2`,children:`Describe the email you want and I'll assemble it from the available blocks.`}),(0,p.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:lt.map(e=>(0,p.jsx)(`button`,{onClick:()=>u(e),className:`text-left text-xs px-2.5 py-2 rounded border border-gray-200 bg-white hover:border-blue-400 hover:bg-blue-50 transition-colors`,children:e},e))})]}),n.map(e=>(0,p.jsxs)(`div`,{className:`text-xs rounded-lg px-3 py-2 whitespace-pre-wrap ${e.role===`user`?`bg-blue-600 text-white self-end max-w-[85%]`:e.error?`bg-red-50 text-red-700 border border-red-200 self-start max-w-[95%]`:`bg-gray-100 text-gray-800 self-start max-w-[95%]`}`,children:[e.error&&(0,p.jsx)(f.AlertTriangle,{size:12,className:`inline mr-1 -mt-0.5`,"aria-hidden":!0}),e.text]},e.id)),o&&(0,p.jsxs)(`div`,{className:`text-xs text-gray-500 flex items-center gap-1.5 self-start`,children:[(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}),` Thinking…`]})]}),(0,p.jsxs)(`form`,{className:`mt-2 flex items-end gap-1.5`,onSubmit:e=>{e.preventDefault(),u(i)},children:[(0,p.jsx)(`textarea`,{value:i,onChange:e=>a(e.target.value),onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),u(i))},rows:2,placeholder:`Ask the AI to build or edit your email…`,className:`flex-1 resize-none text-xs rounded border border-gray-300 px-2 py-1.5 outline-none focus:border-blue-500`}),(0,p.jsx)(`button`,{type:`submit`,disabled:o||!i.trim(),title:`Send`,className:`p-2 rounded bg-blue-600 text-white hover:bg-blue-700 disabled:bg-gray-300`,children:o?(0,p.jsx)(f.Loader2,{size:14,className:`animate-spin`}):(0,p.jsx)(f.Send,{size:14})})]})]})}var ft=[{id:`basic`,icon:f.Square},{id:`menu`,icon:f.Menu},{id:`header`,icon:f.LayoutTemplate},{id:`content`,icon:f.Type},{id:`feature`,icon:f.Star},{id:`call_to_action`,icon:f.MousePointerClick},{id:`ecommerce`,icon:f.ShoppingCart},{id:`transactional`,icon:f.Receipt},{id:`social`,icon:f.Share2},{id:`footer`,icon:f.AlignVerticalJustifyEnd}];function pt(){let[e,t]=(0,l.useState)(`layers`),[n,r]=(0,l.useState)(!0),{addModule:i,themes:a,applyTheme:o,doc:s}=M(),c=ut(),u=e=>{t(e),r(!0)};return(0,p.jsxs)(`div`,{className:`flex h-full bg-white border-r border-gray-200 shrink-0`,children:[(0,p.jsxs)(`div`,{className:`w-16 border-r border-gray-200 flex flex-col items-center py-2 gap-1`,children:[c&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`button`,{onClick:()=>u(`ai`),title:`AI Assistant`,className:`flex flex-col items-center gap-0.5 w-14 py-2 rounded text-[10px] transition-colors ${e===`ai`&&n?`bg-blue-50 text-blue-700`:`text-blue-600 hover:bg-blue-50`}`,children:[(0,p.jsx)(f.Sparkles,{size:20}),(0,p.jsx)(`span`,{children:`AI`})]}),(0,p.jsx)(`div`,{className:`h-px w-10 bg-gray-200 my-1`})]}),(0,p.jsxs)(`button`,{onClick:()=>u(`layers`),title:`Layout overview`,className:`flex flex-col items-center gap-0.5 w-14 py-2 rounded text-[10px] transition-colors ${e===`layers`&&n?`bg-blue-50 text-blue-700`:`text-gray-600 hover:bg-gray-50`}`,children:[(0,p.jsx)(f.Layers,{size:20}),(0,p.jsx)(`span`,{children:`Layers`})]}),(0,p.jsx)(`div`,{className:`h-px w-10 bg-gray-200 my-1`}),ft.map(t=>{let r=t.icon,i=e===t.id&&n;return(0,p.jsxs)(`button`,{onClick:()=>u(t.id),title:We[t.id],className:`flex flex-col items-center gap-0.5 w-14 py-2 rounded text-[10px] transition-colors ${i?`bg-blue-50 text-blue-700`:`text-gray-600 hover:bg-gray-50`}`,children:[(0,p.jsx)(r,{size:20}),(0,p.jsx)(`span`,{className:`leading-tight text-center`,children:We[t.id]})]},t.id)}),(0,p.jsx)(`div`,{className:`mt-auto`,children:(0,p.jsxs)(`button`,{onClick:()=>u(`themes`),title:`Themes`,className:`flex flex-col items-center gap-0.5 w-14 py-2 rounded text-[10px] transition-colors ${e===`themes`&&n?`bg-blue-50 text-blue-700`:`text-gray-600 hover:bg-gray-50`}`,children:[(0,p.jsx)(f.Palette,{size:20}),(0,p.jsx)(`span`,{children:`Themes`})]})})]}),n&&(0,p.jsxs)(`div`,{className:`w-64 overflow-y-auto p-3 flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-gray-400`,children:e===`layers`?`Layout`:e===`ai`?`AI`:e===`themes`?`Themes`:We[e]}),(0,p.jsx)(`button`,{onClick:()=>r(!1),title:`Hide panel`,className:`text-gray-400 hover:text-gray-600 rounded p-0.5 hover:bg-gray-100 transition-colors`,children:(0,p.jsx)(f.PanelLeftClose,{size:15})})]}),e===`layers`?(0,p.jsx)(mt,{}):e===`ai`?(0,p.jsx)(dt,{}):e===`themes`?(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:a.map(e=>(0,p.jsxs)(`button`,{onClick:()=>o(e),className:`text-left p-3 rounded border transition-colors ${s.theme.id===e.id?`border-blue-500 bg-blue-50`:`border-gray-200 hover:border-gray-300 bg-white`}`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,p.jsx)(`div`,{className:`w-4 h-4 rounded`,style:{background:e.tokens.colors.primary}}),(0,p.jsx)(`div`,{className:`w-4 h-4 rounded border border-gray-200`,style:{background:e.tokens.colors.surface}}),(0,p.jsx)(`div`,{className:`w-4 h-4 rounded`,style:{background:e.tokens.colors.text}})]}),(0,p.jsx)(`div`,{className:`text-sm font-medium`,children:e.name})]},e.id))}):(0,p.jsx)(p.Fragment,{children:(0,p.jsxs)(`div`,{className:`grid grid-cols-1 gap-2`,children:[Ue.byCategory(e).map(e=>(0,p.jsxs)(`button`,{onClick:()=>i(e.create()),className:`text-left p-3 rounded border border-gray-200 bg-white hover:border-blue-400 hover:shadow-sm transition-all`,children:[(0,p.jsx)(`div`,{className:`h-12 bg-gray-50 rounded mb-2 flex items-center justify-center text-xs text-gray-400`,children:e.name}),(0,p.jsx)(`div`,{className:`text-xs font-medium text-gray-700`,children:e.name})]},e.type)),Ue.byCategory(e).length===0&&(0,p.jsx)(`div`,{className:`text-xs text-gray-400 italic py-4 text-center`,children:`No modules in this category yet.`})]})})]}),!n&&(0,p.jsx)(`button`,{onClick:()=>r(!0),title:`Show panel`,className:`flex items-center justify-center w-5 h-full text-gray-400 hover:text-gray-600 hover:bg-gray-50 transition-colors border-r border-gray-200`,children:(0,p.jsx)(f.PanelLeftOpen,{size:14})})]})}function mt(){let{doc:e,selection:t,setSelection:n,reorderModules:r,deleteModule:i,duplicateModule:a}=M();return e.modules.length===0?(0,p.jsx)(`p`,{className:`text-xs text-gray-400 italic`,children:`No blocks yet. Pick a category from the rail to add modules.`}):(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`p`,{className:`text-[10px] text-gray-400 mb-3`,children:[e.modules.length,` block`,e.modules.length===1?``:`s`,` · click to select`]}),(0,p.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.modules.map((o,s)=>(0,p.jsxs)(`li`,{className:`flex items-center gap-1 rounded border px-2 py-1.5 text-xs cursor-pointer transition-colors ${t?.kind!==`email`&&t?.moduleId===o.id?`border-blue-500 bg-blue-50 text-blue-900`:`border-gray-200 bg-white hover:border-gray-300`}`,onClick:()=>n({kind:`module`,moduleId:o.id}),children:[(0,p.jsx)(`span`,{className:`text-[10px] text-gray-400 w-4 shrink-0`,children:s+1}),(0,p.jsxs)(`span`,{className:`flex-1 truncate`,children:[o.name,(0,p.jsxs)(`span`,{className:`text-[10px] text-gray-400 ml-1`,children:[`(`,o.children.length,`)`]})]}),(0,p.jsx)(`button`,{disabled:s===0,onClick:e=>{e.stopPropagation(),r(s,s-1)},className:`p-0.5 text-gray-500 hover:text-blue-600 disabled:opacity-30`,title:`Move up`,children:(0,p.jsx)(f.ArrowUp,{size:12})}),(0,p.jsx)(`button`,{disabled:s===e.modules.length-1,onClick:e=>{e.stopPropagation(),r(s,s+1)},className:`p-0.5 text-gray-500 hover:text-blue-600 disabled:opacity-30`,title:`Move down`,children:(0,p.jsx)(f.ArrowDown,{size:12})}),(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),a(o.id)},className:`p-0.5 text-gray-500 hover:text-blue-600`,title:`Duplicate`,children:(0,p.jsx)(f.Copy,{size:12})}),(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i(o.id)},className:`p-0.5 text-gray-500 hover:text-red-600`,title:`Delete`,children:(0,p.jsx)(f.Trash2,{size:12})})]},o.id))})]})}function ht(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,l.useMemo)(()=>e=>{t.forEach(t=>t(e))},t)}var gt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function _t(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function vt(e){return`nodeType`in e}function q(e){return e?_t(e)?e:vt(e)?e.ownerDocument?.defaultView??window:window:window}function yt(e){let{Document:t}=q(e);return e instanceof t}function bt(e){return _t(e)?!1:e instanceof q(e).HTMLElement}function xt(e){return e instanceof q(e).SVGElement}function St(e){return e?_t(e)?e.document:vt(e)?yt(e)?e:bt(e)||xt(e)?e.ownerDocument:document:document:document}var Ct=gt?l.useLayoutEffect:l.useEffect;function wt(e){let t=(0,l.useRef)(e);return Ct(()=>{t.current=e}),(0,l.useCallback)(function(){for(var e=arguments.length,n=Array(e),r=0;r<e;r++)n[r]=arguments[r];return t.current==null?void 0:t.current(...n)},[])}function Tt(){let e=(0,l.useRef)(null);return[(0,l.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,l.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function Et(e,t){t===void 0&&(t=[e]);let n=(0,l.useRef)(e);return Ct(()=>{n.current!==e&&(n.current=e)},t),n}function Dt(e,t){let n=(0,l.useRef)();return(0,l.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function Ot(e){let t=wt(e),n=(0,l.useRef)(null);return[n,(0,l.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function kt(e){let t=(0,l.useRef)();return(0,l.useEffect)(()=>{t.current=e},[e]),t.current}var At={};function jt(e,t){return(0,l.useMemo)(()=>{if(t)return t;let n=At[e]==null?0:At[e]+1;return At[e]=n,e+`-`+n},[e,t])}function Mt(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var Nt=Mt(1),Pt=Mt(-1);function Ft(e){return`clientX`in e&&`clientY`in e}function It(e){if(!e)return!1;let{KeyboardEvent:t}=q(e.target);return t&&e instanceof t}function Lt(e){if(!e)return!1;let{TouchEvent:t}=q(e.target);return t&&e instanceof t}function Rt(e){if(Lt(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return Ft(e)?{x:e.clientX,y:e.clientY}:null}var zt=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[zt.Translate.toString(e),zt.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),Bt=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Vt(e){return e.matches(Bt)?e:e.querySelector(Bt)}var Ht={display:`none`};function Ut(e){let{id:t,value:n}=e;return l.default.createElement(`div`,{id:t,style:Ht},n)}function Wt(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return l.default.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function Gt(){let[e,t]=(0,l.useState)(``);return{announce:(0,l.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Kt=(0,l.createContext)(null);function qt(e){let t=(0,l.useContext)(Kt);(0,l.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Jt(){let[e]=(0,l.useState)(()=>new Set),t=(0,l.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,l.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Yt={draggable:`
|
|
78
78
|
To pick up a draggable item, press the space bar.
|
|
79
79
|
While dragging, use the arrow keys to move the item.
|
|
80
80
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
81
|
-
`},Ut={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function Wt(e){let{announcements:t=Ut,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Ht}=e,{announce:a,announcement:o}=Rt(),s=wt(`DndLiveRegion`),[c,u]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{u(!0)},[]),Bt((0,l.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let d=l.default.createElement(l.default.Fragment,null,l.default.createElement(It,{id:r,value:i.draggable}),l.default.createElement(Lt,{id:s,announcement:o}));return n?(0,m.createPortal)(d,n):d}var q;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(q||={});function Gt(){}function Kt(e,t){return(0,l.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function qt(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,l.useMemo)(()=>[...t].filter(e=>e!=null),[...t])}var Jt=Object.freeze({x:0,y:0});function Yt(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Xt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function Zt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Qt(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function $t(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function en(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var tn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=en(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Yt(en(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(Xt)},nn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=Qt(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Qt(r),o=i.reduce((e,t,r)=>e+Yt(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(Xt)};function rn(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var an=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=rn(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(Zt)};function on(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function sn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Jt}function cn(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var ln=cn(1);function un(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function dn(e,t,n){let r=un(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var fn={ignoreTransform:!1};function pn(e,t){t===void 0&&(t=fn);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=K(e).getComputedStyle(e);t&&(n=dn(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function mn(e){return pn(e,{ignoreTransform:!0})}function hn(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function gn(e,t){return t===void 0&&(t=K(e).getComputedStyle(e)),t.position===`fixed`}function _n(e,t){t===void 0&&(t=K(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function vn(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(ft(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!pt(i)||mt(i)||n.includes(i))return n;let a=K(e).getComputedStyle(i);return i!==e&&_n(i,a)&&n.push(i),gn(i,a)?n:r(i.parentNode)}return e?r(e):n}function yn(e){let[t]=vn(e,1);return t??null}function bn(e){return!lt||!e?null:ut(e)?e:dt(e)?ft(e)||e===ht(e).scrollingElement?window:pt(e)?e:null:null}function xn(e){return ut(e)?e.scrollX:e.scrollLeft}function Sn(e){return ut(e)?e.scrollY:e.scrollTop}function Cn(e){return{x:xn(e),y:Sn(e)}}var J;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(J||={});function wn(e){return!lt||!e?!1:e===document.scrollingElement}function Tn(e){let t={x:0,y:0},n=wn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var En={x:.2,y:.2};function Dn(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=En);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Tn(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=J.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=J.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=J.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=J.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function On(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function kn(e){return e.reduce((e,t)=>Et(e,Cn(t)),Jt)}function An(e){return e.reduce((e,t)=>e+xn(t),0)}function jn(e){return e.reduce((e,t)=>e+Sn(t),0)}function Mn(e,t){if(t===void 0&&(t=pn),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);yn(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Nn=[[`x`,[`left`,`right`],An],[`y`,[`top`,`bottom`],jn]],Pn=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=vn(t),r=kn(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Nn)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Fn=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function In(e){let{EventTarget:t}=K(e);return e instanceof t?e:ht(e)}function Ln(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Rn;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Rn||={});function zn(e){e.preventDefault()}function Bn(e){e.stopPropagation()}var Y;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(Y||={});var Vn={start:[Y.Space,Y.Enter],cancel:[Y.Esc],end:[Y.Space,Y.Enter,Y.Tab]},Hn=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Y.Right:return{...n,x:n.x+25};case Y.Left:return{...n,x:n.x-25};case Y.Down:return{...n,y:n.y+25};case Y.Up:return{...n,y:n.y-25}}},Un=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Fn(ht(t)),this.windowListeners=new Fn(K(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Rn.Resize,this.handleCancel),this.windowListeners.add(Rn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Rn.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Mn(n),t(Jt)}handleKeyDown(e){if(kt(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Vn,coordinateGetter:a=Hn,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:Jt;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Dt(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Tn(n),p=On(n),m={x:Math.min(i===Y.Right?p.right-p.width/2:p.right,Math.max(i===Y.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===Y.Down?p.bottom-p.height/2:p.bottom,Math.max(i===Y.Down?p.top:p.top+p.height/2,u.y))},h=i===Y.Right&&!s||i===Y.Left&&!c,g=i===Y.Down&&!l||i===Y.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===Y.Right&&e<=d.x||i===Y.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===Y.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===Y.Down&&e<=d.y||i===Y.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===Y.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Et(Dt(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Un.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Vn,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Wn(e){return!!(e&&`distance`in e)}function Gn(e){return!!(e&&`delay`in e)}var Kn=class{constructor(e,t,n){n===void 0&&(n=In(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=ht(i),this.documentListeners=new Fn(this.document),this.listeners=new Fn(n),this.windowListeners=new Fn(K(i)),this.initialCoordinates=jt(r)??Jt,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Rn.Resize,this.handleCancel),this.windowListeners.add(Rn.DragStart,zn),this.windowListeners.add(Rn.VisibilityChange,this.handleCancel),this.windowListeners.add(Rn.ContextMenu,zn),this.documentListeners.add(Rn.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Gn(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Wn(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Rn.Click,Bn,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Rn.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=jt(e)??Jt,s=Dt(n,o);if(!t&&a){if(Wn(a)){if(a.tolerance!=null&&Ln(s,a.tolerance))return this.handleCancel();if(Ln(s,a.distance))return this.handleStart()}if(Gn(a)&&Ln(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===Y.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},qn={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Jn=class extends Kn{constructor(e){let{event:t}=e,n=ht(t.target);super(e,qn,n)}};Jn.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Yn={move:{name:`mousemove`},end:{name:`mouseup`}},Xn;(function(e){e[e.RightClick=2]=`RightClick`})(Xn||={});var Zn=class extends Kn{constructor(e){super(e,Yn,ht(e.event.target))}};Zn.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Xn.RightClick?!1:(r?.({event:n}),!0)}}];var Qn={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},$n=class extends Kn{constructor(e){super(e,Qn)}static setup(){return window.addEventListener(Qn.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Qn.move.name,e)};function e(){}}};$n.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var er;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(er||={});var tr;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(tr||={});function nr(e){let{acceleration:t,activator:n=er.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=tr.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:p}=e,m=ir({delta:f,disabled:!a}),[h,g]=vt(),_=(0,l.useRef)({x:0,y:0}),v=(0,l.useRef)({x:0,y:0}),y=(0,l.useMemo)(()=>{switch(n){case er.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case er.DraggableRect:return i}},[n,i,c]),b=(0,l.useRef)(null),x=(0,l.useCallback)(()=>{let e=b.current;if(!e)return;let t=_.current.x*v.current.x,n=_.current.y*v.current.y;e.scrollBy(t,n)},[]),S=(0,l.useMemo)(()=>s===tr.TreeOrder?[...u].reverse():u,[s,u]);(0,l.useEffect)(()=>{if(!a||!u.length||!y){g();return}for(let e of S){if(r?.(e)===!1)continue;let n=u.indexOf(e),i=d[n];if(!i)continue;let{direction:a,speed:s}=Dn(e,i,y,t,p);for(let e of[`x`,`y`])m[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){g(),b.current=e,h(x,o),_.current=s,v.current=a;return}}_.current={x:0,y:0},v.current={x:0,y:0},g()},[t,x,r,g,a,o,JSON.stringify(y),JSON.stringify(m),h,u,S,d,JSON.stringify(p)])}var rr={x:{[J.Backward]:!1,[J.Forward]:!1},y:{[J.Backward]:!1,[J.Forward]:!1}};function ir(e){let{delta:t,disabled:n}=e,r=St(t);return bt(e=>{if(n||!r||!e)return rr;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[J.Backward]:e.x[J.Backward]||i.x===-1,[J.Forward]:e.x[J.Forward]||i.x===1},y:{[J.Backward]:e.y[J.Backward]||i.y===-1,[J.Forward]:e.y[J.Forward]||i.y===1}}},[n,t,r])}function ar(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return bt(e=>t==null?null:r??e??null,[r,t])}function or(e,t){return(0,l.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var sr;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(sr||={});var cr;(function(e){e.Optimized=`optimized`})(cr||={});var lr=new Map;function ur(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,l.useState)(null),{frequency:s,measure:c,strategy:u}=i,d=(0,l.useRef)(e),f=_(),p=yt(f),m=(0,l.useCallback)(function(e){e===void 0&&(e=[]),!p.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[p]),h=(0,l.useRef)(null),g=bt(t=>{if(f&&!n)return lr;if(!t||t===lr||d.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Pn(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,f,c]);return(0,l.useEffect)(()=>{d.current=e},[e]),(0,l.useEffect)(()=>{f||m()},[n,f]),(0,l.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,l.useEffect)(()=>{f||typeof s!=`number`||h.current!==null||(h.current=setTimeout(()=>{m(),h.current=null},s))},[s,f,m,...r]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:a!=null};function _(){switch(u){case sr.Always:return!1;case sr.BeforeDragging:return n;default:return!n}}}function dr(e,t){return bt(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function fr(e,t){return dr(e,t)}function pr(e){let{callback:t,disabled:n}=e,r=_t(t),i=(0,l.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,l.useEffect)(()=>()=>i?.disconnect(),[i]),i}function mr(e){let{callback:t,disabled:n}=e,r=_t(t),i=(0,l.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,l.useEffect)(()=>()=>i?.disconnect(),[i]),i}function hr(e){return new Pn(pn(e),e)}function gr(e,t,n){t===void 0&&(t=hr);let[r,i]=(0,l.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=pr({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=mr({callback:a});return gt(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function _r(e){return sn(e,dr(e))}var vr=[];function yr(e){let t=(0,l.useRef)(e),n=bt(n=>e?n&&n!==vr&&e&&t.current&&e.parentNode===t.current.parentNode?n:vn(e):vr,[e]);return(0,l.useEffect)(()=>{t.current=e},[e]),n}function br(e){let[t,n]=(0,l.useState)(null),r=(0,l.useRef)(e),i=(0,l.useCallback)(e=>{let t=bn(e.target);t&&n(e=>e?(e.set(t,Cn(t)),new Map(e)):null)},[]);return(0,l.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=bn(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Cn(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{bn(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,l.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Et(e,t),Jt):kn(e):Jt,[e,t])}function xr(e,t){t===void 0&&(t=[]);let n=(0,l.useRef)(null);return(0,l.useEffect)(()=>{n.current=null},t),(0,l.useEffect)(()=>{let t=e!==Jt;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Dt(e,n.current):Jt}function Sr(e){(0,l.useEffect)(()=>{if(!lt)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Cr(e,t){return(0,l.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function wr(e){return(0,l.useMemo)(()=>e?hn(e):null,[e])}var Tr=[];function Er(e,t){t===void 0&&(t=pn);let[n]=e,r=wr(n?K(n):null),[i,a]=(0,l.useState)(Tr);function o(){a(()=>e.length?e.map(e=>wn(e)?r:new Pn(t(e),e)):Tr)}let s=mr({callback:o});return gt(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Dr(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return pt(t)?t:e}function Or(e){let{measure:t}=e,[n,r]=(0,l.useState)(null),i=mr({callback:(0,l.useCallback)(e=>{for(let{target:n}of e)if(pt(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=xt((0,l.useCallback)(e=>{let n=Dr(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,l.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var kr=[{sensor:Jn,options:{}},{sensor:Un,options:{}}],Ar={current:{}},jr={draggable:{measure:mn},droppable:{measure:mn,strategy:sr.WhileDragging,frequency:cr.Optimized},dragOverlay:{measure:pn}},Mr=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Nr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Mr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Gt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:jr,measureDroppableContainers:Gt,windowRect:null,measuringScheduled:!1},Pr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Gt,draggableNodes:new Map,over:null,measureDroppableContainers:Gt},Fr=(0,l.createContext)(Pr),Ir=(0,l.createContext)(Nr);function Lr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Mr}}}function Rr(e,t){switch(t.type){case q.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case q.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case q.DragEnd:case q.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case q.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Mr(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case q.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Mr(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case q.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Mr(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function zr(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,l.useContext)(Fr),a=St(r),o=St(n?.id);return(0,l.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!kt(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Pt(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Br(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Vr(e){return(0,l.useMemo)(()=>({draggable:{...jr.draggable,...e?.draggable},droppable:{...jr.droppable,...e?.droppable},dragOverlay:{...jr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Hr(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,l.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;gt(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=sn(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=yn(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Ur=(0,l.createContext)({...Jt,scaleX:1,scaleY:1}),Wr;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Wr||={});var Gr=(0,l.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=kr,collisionDetection:o=an,measuring:s,modifiers:c,...u}=e,[d,f]=(0,l.useReducer)(Rr,void 0,Lr),[p,h]=Vt(),[g,_]=(0,l.useState)(Wr.Uninitialized),v=g===Wr.Initialized,{draggable:{active:y,nodes:b,translate:x},droppable:{containers:S}}=d,C=y==null?null:b.get(y),w=(0,l.useRef)({initial:null,translated:null}),T=(0,l.useMemo)(()=>y==null?null:{id:y,data:C?.data??Ar,rect:w},[y,C]),ee=(0,l.useRef)(null),[te,E]=(0,l.useState)(null),[D,ne]=(0,l.useState)(null),re=yt(u,Object.values(u)),ie=wt(`DndDescribedBy`,t),ae=(0,l.useMemo)(()=>S.getEnabled(),[S]),oe=Vr(s),{droppableRects:se,measureDroppableContainers:ce,measuringScheduled:le}=ur(ae,{dragging:v,dependencies:[x.x,x.y],config:oe.droppable}),O=ar(b,y),ue=(0,l.useMemo)(()=>D?jt(D):null,[D]),k=Te(),de=fr(O,oe.draggable.measure);Hr({activeNode:y==null?null:b.get(y),config:k.layoutShiftCompensation,initialRect:de,measure:oe.draggable.measure});let A=gr(O,oe.draggable.measure,de),fe=gr(O?O.parentElement:null),j=(0,l.useRef)({activatorEvent:null,active:null,activeNode:O,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:b,draggingNode:null,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),M=S.getNodeFor(j.current.over?.id),pe=Or({measure:oe.dragOverlay.measure}),me=pe.nodeRef.current??O,he=v?pe.rect??A:null,ge=!!(pe.nodeRef.current&&pe.rect),_e=_r(ge?null:A),N=wr(me?K(me):null),P=yr(v?M??O:null),ve=Er(P),ye=Br(c,{transform:{x:x.x-_e.x,y:x.y-_e.y,scaleX:1,scaleY:1},activatorEvent:D,active:T,activeNodeRect:A,containerNodeRect:fe,draggingNodeRect:he,over:j.current.over,overlayNodeRect:pe.rect,scrollableAncestors:P,scrollableAncestorRects:ve,windowRect:N}),F=ue?Et(ue,x):null,I=br(P),L=xr(I),R=xr(I,[A]),z=Et(ye,L),B=he?ln(he,ye):null,V=T&&B?o({active:T,collisionRect:B,droppableRects:se,droppableContainers:ae,pointerCoordinates:F}):null,H=$t(V,`id`),[U,be]=(0,l.useState)(null),W=on(ge?ye:Et(ye,R),U?.rect??null,A),xe=(0,l.useRef)(null),G=(0,l.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(ee.current==null)return;let i=b.get(ee.current);if(!i)return;let a=e.nativeEvent,o=new n({active:ee.current,activeNode:i,event:a,options:r,context:j,onAbort(e){if(!b.get(e))return;let{onDragAbort:t}=re.current,n={id:e};t?.(n),p({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!b.get(e))return;let{onDragPending:i}=re.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),p({type:`onDragPending`,event:a})},onStart(e){let t=ee.current;if(t==null)return;let n=b.get(t);if(!n)return;let{onDragStart:r}=re.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:w}};(0,m.unstable_batchedUpdates)(()=>{r?.(i),_(Wr.Initializing),f({type:q.DragStart,initialCoordinates:e,active:t}),p({type:`onDragStart`,event:i}),E(xe.current),ne(a)})},onMove(e){f({type:q.DragMove,coordinates:e})},onEnd:s(q.DragEnd),onCancel:s(q.DragCancel)});xe.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=j.current,o=null;if(t&&i){let{cancelDrop:s}=re.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===q.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=q.DragCancel)}ee.current=null,(0,m.unstable_batchedUpdates)(()=>{f({type:e}),_(Wr.Uninitialized),be(null),E(null),ne(null),xe.current=null;let t=e===q.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=re.current[t];e?.(o),p({type:t,event:o})}})}}},[b]),Se=or(a,(0,l.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=b.get(r);if(ee.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},ee.current=r,G(n,t))},[b,G]));Sr(a),gt(()=>{A&&g===Wr.Initializing&&_(Wr.Initialized)},[A,g]),(0,l.useEffect)(()=>{let{onDragMove:e}=re.current,{active:t,activatorEvent:n,collisions:r,over:i}=j.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:z.x,y:z.y},over:i};(0,m.unstable_batchedUpdates)(()=>{e?.(a),p({type:`onDragMove`,event:a})})},[z.x,z.y]),(0,l.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=j.current;if(!e||ee.current==null||!t||!i)return;let{onDragOver:a}=re.current,o=r.get(H),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,m.unstable_batchedUpdates)(()=>{be(s),a?.(c),p({type:`onDragOver`,event:c})})},[H]),gt(()=>{j.current={activatorEvent:D,active:T,activeNode:O,collisionRect:B,collisions:V,droppableRects:se,draggableNodes:b,draggingNode:me,draggingNodeRect:he,droppableContainers:S,over:U,scrollableAncestors:P,scrollAdjustedTranslate:z},w.current={initial:he,translated:B}},[T,O,V,B,b,me,he,se,S,U,P,z]),nr({...k,delta:x,draggingRect:B,pointerCoordinates:F,scrollableAncestors:P,scrollableAncestorRects:ve});let Ce=(0,l.useMemo)(()=>({active:T,activeNode:O,activeNodeRect:A,activatorEvent:D,collisions:V,containerNodeRect:fe,dragOverlay:pe,draggableNodes:b,droppableContainers:S,droppableRects:se,over:U,measureDroppableContainers:ce,scrollableAncestors:P,scrollableAncestorRects:ve,measuringConfiguration:oe,measuringScheduled:le,windowRect:N}),[T,O,A,D,V,fe,pe,b,S,se,U,ce,P,ve,oe,le,N]),we=(0,l.useMemo)(()=>({activatorEvent:D,activators:Se,active:T,activeNodeRect:A,ariaDescribedById:{draggable:ie},dispatch:f,draggableNodes:b,over:U,measureDroppableContainers:ce}),[D,Se,T,A,f,ie,b,U,ce]);return l.default.createElement(zt.Provider,{value:h},l.default.createElement(Fr.Provider,{value:we},l.default.createElement(Ir.Provider,{value:Ce},l.default.createElement(Ur.Provider,{value:W},i)),l.default.createElement(zr,{disabled:n?.restoreFocus===!1})),l.default.createElement(Wt,{...n,hiddenTextDescribedById:ie}));function Te(){let e=te?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=v&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),Kr=(0,l.createContext)(null),qr=`button`,Jr=`Draggable`;function Yr(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=wt(Jr),{activators:o,activatorEvent:s,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:p}=(0,l.useContext)(Fr),{role:m=qr,roleDescription:h=`draggable`,tabIndex:g=0}=i??{},_=c?.id===t,v=(0,l.useContext)(_?Ur:Kr),[y,b]=xt(),[x,S]=xt(),C=Cr(o,t),w=yt(n);return gt(()=>(f.set(t,{id:t,key:a,node:y,activatorNode:x,data:w}),()=>{let e=f.get(t);e&&e.key===a&&f.delete(t)}),[f,t]),{active:c,activatorEvent:s,activeNodeRect:u,attributes:(0,l.useMemo)(()=>({role:m,tabIndex:g,"aria-disabled":r,"aria-pressed":_&&m===qr?!0:void 0,"aria-roledescription":h,"aria-describedby":d.draggable}),[r,m,g,_,h,d.draggable]),isDragging:_,listeners:r?void 0:C,node:y,over:p,setNodeRef:b,setActivatorNodeRef:S,transform:v}}function Xr(){return(0,l.useContext)(Ir)}var Zr=`Droppable`,Qr={timeout:25};function $r(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=wt(Zr),{active:o,dispatch:s,over:c,measureDroppableContainers:u}=(0,l.useContext)(Fr),d=(0,l.useRef)({disabled:n}),f=(0,l.useRef)(!1),p=(0,l.useRef)(null),m=(0,l.useRef)(null),{disabled:h,updateMeasurementsFor:g,timeout:_}={...Qr,...i},v=yt(g??r),y=mr({callback:(0,l.useCallback)(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),m.current=null},_)},[_]),disabled:h||!o}),[b,x]=xt((0,l.useCallback)((e,t)=>{y&&(t&&(y.unobserve(t),f.current=!1),e&&y.observe(e))},[y])),S=yt(t);return(0,l.useEffect)(()=>{!y||!b.current||(y.disconnect(),f.current=!1,y.observe(b.current))},[b,y]),(0,l.useEffect)(()=>(s({type:q.RegisterDroppable,element:{id:r,key:a,disabled:n,node:b,rect:p,data:S}}),()=>s({type:q.UnregisterDroppable,key:a,id:r})),[r]),(0,l.useEffect)(()=>{n!==d.current.disabled&&(s({type:q.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,s]),{active:o,rect:p,isOver:c?.id===r,node:b,over:c,setNodeRef:x}}function ei(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function ti(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function ni(e){return e!==null&&e>=0}function ri(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ii(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var ai=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=ei(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},oi={scaleX:1,scaleY:1},si=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...oi}:null}let s=ci(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...oi}:r<t&&r>=a?{x:0,y:o.height+s,...oi}:{x:0,y:0,...oi}};function ci(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var li=`Sortable`,ui=l.default.createContext({activeIndex:-1,containerId:li,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:ai,disabled:{draggable:!1,droppable:!1}});function di(e){let{children:t,id:n,items:r,strategy:i=ai,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:u,measureDroppableContainers:d}=Xr(),f=wt(li,n),p=s.rect!==null,m=(0,l.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),h=o!=null,g=o?m.indexOf(o.id):-1,_=u?m.indexOf(u.id):-1,v=(0,l.useRef)(m),y=!ri(m,v.current),b=_!==-1&&g===-1||y,x=ii(a);gt(()=>{y&&h&&d(m)},[y,m,h,d]),(0,l.useEffect)(()=>{v.current=m},[m]);let S=(0,l.useMemo)(()=>({activeIndex:g,containerId:f,disabled:x,disableTransforms:b,items:m,overIndex:_,useDragOverlay:p,sortedRects:ti(m,c),strategy:i}),[g,f,x.draggable,x.droppable,b,m,_,c,p,i]);return l.default.createElement(ui.Provider,{value:S},t)}var fi=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return ei(n,r,i).indexOf(t)},pi=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},mi={duration:200,easing:`ease`},hi=`transform`,gi=Mt.Transition.toString({property:hi,duration:0,easing:`linear`}),_i={roleDescription:`sortable`};function vi(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,l.useState)(null),s=(0,l.useRef)(n);return gt(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=pn(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,l.useEffect)(()=>{a&&o(null)},[a]),a}function yi(e){let{animateLayoutChanges:t=pi,attributes:n,disabled:r,data:i,getNewIndex:a=fi,id:o,strategy:s,resizeObserverConfig:c,transition:u=mi}=e,{items:d,containerId:f,activeIndex:p,disabled:m,disableTransforms:h,sortedRects:g,overIndex:_,useDragOverlay:v,strategy:y}=(0,l.useContext)(ui),b=bi(r,m),x=d.indexOf(o),S=(0,l.useMemo)(()=>({sortable:{containerId:f,index:x,items:d},...i}),[f,i,x,d]),C=(0,l.useMemo)(()=>d.slice(d.indexOf(o)),[d,o]),{rect:w,node:T,isOver:ee,setNodeRef:te}=$r({id:o,data:S,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:E,activatorEvent:D,activeNodeRect:ne,attributes:re,setNodeRef:ie,listeners:ae,isDragging:oe,over:se,setActivatorNodeRef:ce,transform:le}=Yr({id:o,data:S,attributes:{..._i,...n},disabled:b.draggable}),O=ct(te,ie),ue=!!E,k=ue&&!h&&ni(p)&&ni(_),de=!v&&oe,A=k?(de&&k?le:null)??(s??y)({rects:g,activeNodeRect:ne,activeIndex:p,overIndex:_,index:x}):null,fe=ni(p)&&ni(_)?a({id:o,items:d,activeIndex:p,overIndex:_}):x,j=E?.id,M=(0,l.useRef)({activeId:j,items:d,newIndex:fe,containerId:f}),pe=d!==M.current.items,me=t({active:E,containerId:f,isDragging:oe,isSorting:ue,id:o,index:x,items:d,newIndex:M.current.newIndex,previousItems:M.current.items,previousContainerId:M.current.containerId,transition:u,wasDragging:M.current.activeId!=null}),he=vi({disabled:!me,index:x,node:T,rect:w});return(0,l.useEffect)(()=>{ue&&M.current.newIndex!==fe&&(M.current.newIndex=fe),f!==M.current.containerId&&(M.current.containerId=f),d!==M.current.items&&(M.current.items=d)},[ue,fe,f,d]),(0,l.useEffect)(()=>{if(j===M.current.activeId)return;if(j!=null&&M.current.activeId==null){M.current.activeId=j;return}let e=setTimeout(()=>{M.current.activeId=j},50);return()=>clearTimeout(e)},[j]),{active:E,activeIndex:p,attributes:re,data:S,rect:w,index:x,newIndex:fe,items:d,isOver:ee,isSorting:ue,isDragging:oe,listeners:ae,node:T,overIndex:_,over:se,setNodeRef:O,setActivatorNodeRef:ce,setDroppableNodeRef:te,setDraggableNodeRef:ie,transform:he??A,transition:ge()};function ge(){if(he||pe&&M.current.newIndex===x)return gi;if(!(de&&!kt(D)||!u)&&(ue||me))return Mt.Transition.toString({...u,property:hi})}}function bi(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function xi(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var Si=[Y.Down,Y.Right,Y.Up,Y.Left],Ci=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(Si.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case Y.Down:r.top<a.top&&t.push(n);break;case Y.Up:r.top>a.top&&t.push(n);break;case Y.Left:r.left>a.left&&t.push(n);break;case Y.Right:r.left<a.left&&t.push(n);break}});let c=nn({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=$t(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=vn(c).some((e,t)=>s[t]!==e),i=wi(e,t),a=Ti(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:Dt(u,l)}}}};function wi(e,t){return!xi(e)||!xi(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Ti(e,t){return!xi(e)||!xi(t)||!wi(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var Ei=(0,d.create)(e=>({activeEl:null,setActiveEl:t=>e({activeEl:t})})),Di=(0,d.create)(e=>({mergeTags:[],setMergeTags:t=>e({mergeTags:t})}));function Oi(e){Di.getState().setMergeTags(e)}var ki=[{label:`Default`,value:``},{label:`Arial`,value:`Arial, Helvetica, sans-serif`},{label:`Georgia`,value:`Georgia, 'Times New Roman', serif`},{label:`Tahoma`,value:`Tahoma, Geneva, sans-serif`},{label:`Trebuchet MS`,value:`'Trebuchet MS', Helvetica, sans-serif`},{label:`Verdana`,value:`Verdana, Geneva, sans-serif`},{label:`Courier New`,value:`'Courier New', Courier, monospace`},{label:`Times New Roman`,value:`'Times New Roman', Times, serif`}],Ai=[`10`,`11`,`12`,`13`,`14`,`15`,`16`,`18`,`20`,`22`,`24`,`28`,`32`,`36`,`48`],ji=[`#111827`,`#374151`,`#6B7280`,`#9CA3AF`,`#D1D5DB`,`#F3F4F6`,`#FFFFFF`,`#DC2626`,`#F97316`,`#EAB308`,`#22C55E`,`#3B82F6`,`#8B5CF6`,`#EC4899`,`#B91C1C`,`#C2410C`,`#A16207`,`#15803D`,`#1D4ED8`,`#6D28D9`,`#BE185D`],Mi=`😀.😊.😍.🥰.😎.🤩.👋.🙌.👍.💪.❤️.💙.💚.💛.🧡.💜.🎉.🔥.✨.⭐.🏆.🥇.🎁.🎯.🚀.💡.📧.💌.📱.💻.✅.❌.⚠️.🔔.📊.📈.💰.💳.🛒.🏷️.📍.🗓️.⚡.🌟`.split(`.`),Ni={unsubscribe:`Unsubscribe`,view_in_browser:`View in browser`,manage_preferences:`Manage preferences`,user_profile:`User profile`};function Pi(){let e=window.getSelection();if(!e||e.isCollapsed||e.rangeCount===0)return``;let t=e.getRangeAt(0).cloneContents(),n=document.createElement(`div`);return n.appendChild(t),n.innerHTML}function Fi(e,t){document.execCommand(e,!1,t)}function Ii(e){document.execCommand(`insertHTML`,!1,e)}function Li(e,t){let n=Pi();n&&Ii(`<span style="${e}:${t}">${n}</span>`)}function Ri(){let e=window.getSelection();return!e||e.rangeCount===0?null:e.getRangeAt(0).cloneRange()}function zi(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e))}function Bi({title:e,active:t,disabled:n,onMouseDown:r,children:i}){return(0,p.jsx)(`button`,{title:e,disabled:n,onMouseDown:r,className:`flex items-center justify-center w-7 h-7 rounded text-xs transition-colors ${t?`bg-blue-600 text-white`:`text-gray-700 hover:bg-gray-100 disabled:opacity-30`}`,children:i})}function Vi(){return(0,p.jsx)(`div`,{className:`w-px h-5 bg-gray-200 mx-0.5 shrink-0`})}function Hi({savedRange:e,onClose:t}){let[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),o=(0,l.useRef)(null);(0,l.useEffect)(()=>{setTimeout(()=>o.current?.focus(),30)},[]);let s=()=>{if(!n&&!i){t();return}let r=i?ye[i]:n;if(!r){t();return}let a=e?(()=>{let t=document.createElement(`div`),n=e.cloneContents();return t.appendChild(n),t.innerHTML||t.textContent||r})():r;if(e){zi(e);let t=window.getSelection();t&&t.isCollapsed}Ii(`<a href="${r}"${i?` data-link-type="${i}"`:``} style="color:inherit;text-decoration:underline">${a}</a>`),t()};return(0,p.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-3 w-80`,onMouseDown:e=>e.stopPropagation(),children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsx)(`span`,{className:`text-xs font-semibold text-gray-700`,children:`Insert link`}),(0,p.jsx)(`button`,{onClick:t,className:`text-gray-400 hover:text-gray-600 p-0.5 rounded`,children:(0,p.jsx)(f.X,{size:13})})]}),(0,p.jsx)(`input`,{ref:o,type:`url`,placeholder:`https://example.com`,value:n,onChange:e=>{r(e.target.value),e.target.value&&a(``)},className:`w-full px-2 py-1.5 text-xs border border-gray-200 rounded mb-2 focus:border-blue-500 focus:outline-none`,onKeyDown:e=>{e.key===`Enter`&&s(),e.key===`Escape`&&t()}}),(0,p.jsxs)(`div`,{className:`mb-2`,children:[(0,p.jsx)(`div`,{className:`text-[10px] text-gray-500 mb-1`,children:`Or use a special link`}),(0,p.jsxs)(`select`,{value:i,onChange:e=>{a(e.target.value),e.target.value&&r(``)},className:`w-full px-2 py-1.5 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`,children:[(0,p.jsx)(`option`,{value:``,children:`— none —`}),Object.keys(Ni).map(e=>(0,p.jsx)(`option`,{value:e,children:Ni[e]},e))]})]}),i&&(0,p.jsxs)(`p`,{className:`text-[10px] text-blue-600 mb-2`,children:[`Placeholder: `,(0,p.jsx)(`code`,{children:ye[i]})]}),(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsx)(`button`,{onClick:s,className:`flex-1 px-3 py-1.5 bg-blue-600 text-white text-xs rounded hover:bg-blue-700`,children:`Apply`}),(0,p.jsx)(`button`,{onClick:t,className:`px-3 py-1.5 text-xs border border-gray-200 rounded hover:bg-gray-50`,children:`Cancel`})]})]})}function Ui({onClose:e}){let[t,n]=(0,l.useState)(``),r=t=>{document.execCommand(`styleWithCSS`,!1,`true`),document.execCommand(`foreColor`,!1,t),e()};return(0,p.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-3`,style:{width:196},onMouseDown:e=>e.stopPropagation(),children:[(0,p.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-2`,children:ji.map(e=>(0,p.jsx)(`button`,{title:e,onClick:()=>r(e),className:`w-6 h-6 rounded border border-gray-200 hover:scale-110 transition-transform shrink-0`,style:{background:e}},e))}),(0,p.jsxs)(`div`,{className:`flex gap-1`,children:[(0,p.jsx)(`input`,{type:`text`,placeholder:`#hex or color`,value:t,onChange:e=>n(e.target.value),onKeyDown:n=>{n.key===`Enter`&&t&&r(t),n.key===`Escape`&&e()},className:`flex-1 px-2 py-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`}),(0,p.jsx)(`button`,{onClick:()=>t&&r(t),className:`px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700`,children:`✓`})]})]})}function Wi({onClose:e}){let t=t=>{Ii(t),e()};return(0,p.jsx)(`div`,{className:`absolute top-full right-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-2`,style:{width:260},onMouseDown:e=>e.stopPropagation(),children:(0,p.jsx)(`div`,{className:`flex flex-wrap gap-0.5`,children:Mi.map(e=>(0,p.jsx)(`button`,{onClick:()=>t(e),className:`w-8 h-8 text-lg hover:bg-gray-100 rounded flex items-center justify-center`,children:e},e))})})}function Gi({onClose:e}){let t=Di(e=>e.mergeTags),n=t=>{Ii(`{${t}}`),e()};return t.length===0?null:(0,p.jsx)(`div`,{className:`absolute top-full right-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl py-1`,style:{minWidth:200},onMouseDown:e=>e.stopPropagation(),children:t.map(e=>(0,p.jsxs)(`button`,{onClick:()=>n(e.attribute),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-blue-50 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`span`,{children:e.title}),(0,p.jsx)(`code`,{className:`text-[10px] text-gray-400`,children:`{${e.attribute}}`})]},e.attribute))})}function Ki(){let e=Ei(e=>e.activeEl),t=Di(e=>e.mergeTags),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)({top:0,left:0}),[o,s]=(0,l.useState)({bold:!1,italic:!1,underline:!1}),[c,u]=(0,l.useState)(null),[d,m]=(0,l.useState)(null),h=(0,l.useRef)(null),g=(0,l.useRef)(null),_=(0,l.useCallback)(()=>u(null),[]),v=(0,l.useCallback)(()=>{let t=window.getSelection();if(!t)return;let n=null;if(!t.isCollapsed&&t.rangeCount>0?n=t.getRangeAt(0).getBoundingClientRect():e&&(n=e.getBoundingClientRect()),!n||n.width===0&&n.height===0)return;let r=h.current?.offsetWidth??480,i=n.top-40-6+window.scrollY,o=n.left+n.width/2-r/2+window.scrollX;i<8&&(i=n.bottom+6+window.scrollY),o<8&&(o=8),o+r>window.innerWidth-8&&(o=window.innerWidth-r-8),a({top:i,left:o})},[e]),y=(0,l.useCallback)(()=>{s({bold:document.queryCommandState(`bold`),italic:document.queryCommandState(`italic`),underline:document.queryCommandState(`underline`)})},[]);if((0,l.useEffect)(()=>{if(!e){g.current&&clearTimeout(g.current),g.current=setTimeout(()=>r(!1),150);return}g.current&&clearTimeout(g.current),r(!0),v(),y()},[e,v,y]),(0,l.useEffect)(()=>{let t=()=>{e&&(v(),y())};return document.addEventListener(`selectionchange`,t),()=>document.removeEventListener(`selectionchange`,t)},[e,v,y]),(0,l.useEffect)(()=>{let e=e=>{h.current&&!h.current.contains(e.target)&&_()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[_]),!n||!e)return null;let b=e=>t=>{t.preventDefault(),e()},x=e=>{u(t=>t===e?null:e),e===`link`&&m(Ri())},S=()=>{let e=window.getSelection();return e&&!e.isCollapsed};return(0,p.jsxs)(`div`,{ref:h,"data-rich-toolbar":`true`,className:`fixed z-[9999] flex items-center gap-0.5 bg-white border border-gray-200 rounded-lg shadow-lg px-1.5 py-1 select-none`,style:{top:i.top,left:i.left},onMouseDown:e=>e.preventDefault(),children:[(0,p.jsx)(Bi,{title:`Bold (Ctrl+B)`,active:o.bold,onMouseDown:b(()=>Fi(`bold`)),children:(0,p.jsx)(f.Bold,{size:13})}),(0,p.jsx)(Bi,{title:`Italic (Ctrl+I)`,active:o.italic,onMouseDown:b(()=>Fi(`italic`)),children:(0,p.jsx)(f.Italic,{size:13})}),(0,p.jsx)(Bi,{title:`Underline (Ctrl+U)`,active:o.underline,onMouseDown:b(()=>Fi(`underline`)),children:(0,p.jsx)(f.Underline,{size:13})}),(0,p.jsx)(Vi,{}),(0,p.jsx)(`select`,{title:`Font family`,className:`h-7 px-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white max-w-[110px]`,defaultValue:``,onMouseDown:e=>e.stopPropagation(),onChange:t=>{let n=t.target.value;if(n){if(!S()){e?.focus();return}Li(`font-family`,n),e?.focus()}},children:ki.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.label))}),(0,p.jsxs)(`select`,{title:`Font size`,className:`h-7 px-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white w-14`,defaultValue:``,onMouseDown:e=>e.stopPropagation(),onChange:t=>{let n=t.target.value;if(n){if(!S()){e?.focus();return}Li(`font-size`,`${n}px`),e?.focus()}},children:[(0,p.jsx)(`option`,{value:``,children:`Size`}),Ai.map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))]}),(0,p.jsx)(Vi,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(Bi,{title:`Text color`,onMouseDown:b(()=>x(`color`)),children:(0,p.jsxs)(`span`,{className:`flex flex-col items-center gap-0.5`,children:[(0,p.jsx)(`span`,{className:`text-xs font-bold leading-none`,style:{fontFamily:`serif`},children:`A`}),(0,p.jsx)(`span`,{className:`w-4 h-1 rounded-sm bg-current`})]})}),c===`color`&&(0,p.jsx)(Ui,{onClose:_})]}),(0,p.jsx)(Vi,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(Bi,{title:`Insert link`,onMouseDown:b(()=>x(`link`)),children:(0,p.jsx)(f.Link2,{size:13})}),c===`link`&&(0,p.jsx)(Hi,{savedRange:d,onClose:_})]}),(0,p.jsx)(Vi,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(Bi,{title:`Insert emoji`,onMouseDown:b(()=>x(`emoji`)),children:(0,p.jsx)(f.Smile,{size:13})}),c===`emoji`&&(0,p.jsx)(Wi,{onClose:_})]}),t.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Vi,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(Bi,{title:`Insert merge tag`,onMouseDown:b(()=>x(`mergeTag`)),children:(0,p.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] font-mono`,children:[(0,p.jsx)(f.Tag,{size:11}),(0,p.jsx)(f.ChevronDown,{size:10})]})}),c===`mergeTag`&&(0,p.jsx)(Gi,{onClose:_})]})]})]})}var qi=375;function Ji(e){let t=e.replace(`#`,``);if(t.length!==3&&t.length!==6)return e===`white`||e===`#fff`||e===`#ffffff`;let n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255;return .2126*r+.7152*i+.0722*a>.82}function Yi(e,t){let n=e??{};if(t!==`mobile`)return n;let r=n.mobile??{};return{...n,...r}}function Xi(){let{doc:e,selection:t,setSelection:n,reorderModules:r,deleteModule:i,duplicateModule:a,deleteElement:o,moveElement:s,viewMode:c}=N(),u=qt(Kt(Jn,{activationConstraint:{distance:5}}),Kt(Un,{coordinateGetter:Ci})),d=t=>{let{active:n,over:i}=t;if(!i||n.id===i.id)return;let a=e.modules.findIndex(e=>e.id===n.id),o=e.modules.findIndex(e=>e.id===i.id);a===-1||o===-1||r(a,o)};(0,l.useEffect)(()=>{let e=e=>{if(e.key!==`Delete`&&e.key!==`Backspace`)return;let n=e.target;n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable||(t?.kind===`module`?i(t.moduleId):t?.kind===`element`&&o(t.moduleId,t.elementId))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i,o]);let f=x(e.settings.backgroundColor,e.theme),m=x(e.settings.contentBackgroundColor,e.theme),h=e.modules.map(e=>e.id),g=c===`mobile`?qi:e.settings.width;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ki,{}),(0,p.jsx)(`div`,{className:`flex-1 overflow-y-auto`,style:{background:f},onClick:()=>n({kind:`email`}),children:(0,p.jsx)(`div`,{className:`py-8 flex justify-center`,children:(0,p.jsxs)(`div`,{className:`shadow-lg transition-all duration-200 ${c===`mobile`?`rounded-[28px] border-[10px] border-gray-800`:``}`,style:{width:g,background:m,minHeight:300},onClick:e=>e.stopPropagation(),children:[e.modules.length===0&&(0,p.jsx)(`div`,{className:`p-12 text-center text-gray-400 text-sm`,children:`Add modules from the left sidebar to start building your email.`}),(0,p.jsx)(Gr,{sensors:u,collisionDetection:tn,onDragEnd:d,children:(0,p.jsx)(di,{items:h,strategy:si,children:e.modules.map((r,o)=>(0,p.jsx)(Zi,{mod:r,index:o,viewMode:c,selected:t?.kind===`module`&&t.moduleId===r.id,selectionEl:t?.kind===`element`&&t.moduleId===r.id?t.elementId:null,theme:e.theme,onSelectModule:()=>n({kind:`module`,moduleId:r.id}),onSelectElement:e=>n({kind:`element`,moduleId:r.id,elementId:e}),onDuplicate:()=>a(r.id),onDelete:()=>i(r.id)},r.id))})})]})})})]})}function Zi(e){let{attributes:t,listeners:n,setNodeRef:r,transform:i,transition:a,isDragging:o}=yi({id:e.mod.id});return(0,p.jsx)(`div`,{ref:r,style:{transform:Mt.Transform.toString(i),transition:a,opacity:o?.5:1,position:`relative`,zIndex:e.selected?10:`auto`},children:(0,p.jsx)(Qi,{mod:e.mod,viewMode:e.viewMode,selected:e.selected,selectionEl:e.selectionEl,theme:e.theme,onSelectModule:e.onSelectModule,onSelectElement:e.onSelectElement,onDuplicate:e.onDuplicate,onDelete:e.onDelete,dragHandle:(0,p.jsx)(`button`,{...t,...n,className:`bg-blue-600 text-white p-1 rounded cursor-grab active:cursor-grabbing`,title:`Drag to reorder`,onClick:e=>e.stopPropagation(),children:(0,p.jsx)(f.GripVertical,{size:14})})})})}function Qi({mod:e,viewMode:t,selected:n,selectionEl:r,theme:i,onSelectModule:a,onSelectElement:o,onDuplicate:s,onDelete:c,dragHandle:u}){let d=e.style??{};if(d.hideOn===t)return null;let m=S(Yi(d,t),i),[h,g]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{style:{backgroundColor:m.backgroundColor,paddingTop:m.paddingTop??0,paddingBottom:m.paddingBottom??0,paddingLeft:m.paddingLeft??0,paddingRight:m.paddingRight??0,borderRadius:m.borderRadius,position:`relative`,outline:n?`2px solid #2563eb`:h?`1px dashed #93c5fd`:`1px dashed transparent`,outlineOffset:-2,cursor:`pointer`},onClick:e=>{e.stopPropagation(),a()},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[!n&&h&&(0,p.jsxs)(`div`,{className:`absolute top-0 right-0 z-10 bg-blue-600 text-white text-[10px] px-1.5 py-0.5 rounded-bl pointer-events-none`,children:[`Click to select: `,e.name]}),n&&(0,p.jsxs)(`div`,{className:`absolute top-0 left-0 z-20 flex items-center gap-1 p-1 rounded-br bg-blue-600 shadow-md`,onClick:e=>e.stopPropagation(),children:[u,(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s()},className:`text-white p-1 rounded hover:bg-blue-700`,title:`Duplicate`,children:(0,p.jsx)(f.Copy,{size:14})}),(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c()},className:`text-white p-1 rounded hover:bg-red-600`,title:`Delete`,children:(0,p.jsx)(f.Trash2,{size:14})}),(0,p.jsx)(`span`,{className:`text-white text-[10px] font-medium px-1.5 py-0.5`,children:e.name})]}),e.children.map((s,c)=>(0,p.jsx)($i,{el:s,index:c,totalElements:e.children.length,viewMode:t,theme:i,moduleId:e.id,moduleSelected:n,selected:r===s.id,onSelect:()=>o(s.id),onSelectModule:a},s.id))]})}function $i({el:e,index:t,totalElements:n,viewMode:r,theme:i,moduleId:a,moduleSelected:o,selected:s,onSelect:c,onSelectModule:l}){let u=N(e=>e.moveElement),d=N(e=>e.deleteElement);if(e.style?.hideOn===r)return null;let m={outline:s?`2px solid #f59e0b`:`1px dashed rgba(0,0,0,0.08)`,outlineOffset:-1,position:`relative`},h=e=>{if(e.stopPropagation(),!o&&!s){l();return}c()},g=s&&(0,p.jsxs)(`div`,{className:`absolute top-0 right-0 z-20 flex items-center gap-1 p-1 rounded-bl bg-amber-500 shadow-md`,onClick:e=>e.stopPropagation(),children:[(0,p.jsx)(`button`,{onClick:()=>l(),className:`text-white p-1 rounded hover:bg-amber-600`,title:`Select parent block`,children:(0,p.jsx)(f.MousePointer2,{size:12})}),(0,p.jsx)(`button`,{disabled:t===0,onClick:()=>u(a,e.id,-1),className:`text-white p-1 rounded disabled:opacity-40 hover:bg-amber-600`,title:`Move up`,children:(0,p.jsx)(f.ArrowUp,{size:12})}),(0,p.jsx)(`button`,{disabled:t===n-1,onClick:()=>u(a,e.id,1),className:`text-white p-1 rounded disabled:opacity-40 hover:bg-amber-600`,title:`Move down`,children:(0,p.jsx)(f.ArrowDown,{size:12})}),(0,p.jsx)(`button`,{onClick:()=>d(a,e.id),className:`text-white p-1 rounded hover:bg-red-600`,title:`Delete element`,children:(0,p.jsx)(f.Trash2,{size:12})}),(0,p.jsx)(`span`,{className:`text-white text-[10px] font-medium px-1 py-0.5`,children:e.type})]}),_=e=>(0,p.jsxs)(`div`,{style:m,onClick:h,children:[g,e]});switch(e.type){case`text`:return _((0,p.jsx)(ea,{el:e,viewMode:r,theme:i,moduleId:a}));case`image`:return _((0,p.jsx)(ta,{el:e,viewMode:r,theme:i}));case`button`:return _((0,p.jsx)(na,{el:e,viewMode:r,theme:i}));case`spacer`:return _((0,p.jsx)(ra,{el:e}));case`divider`:return _((0,p.jsx)(ia,{el:e,viewMode:r,theme:i}));case`productGrid`:return _((0,p.jsx)(aa,{el:e,viewMode:r,theme:i}))}}function ea({el:e,viewMode:t,theme:n,moduleId:r}){let i=N(e=>e.updateElement),a=Ei(e=>e.setActiveEl),o=(0,l.useRef)(!1),s=S(Yi(e.style,t),n),c=s.color??`#000000`,u=Ji(c);return(0,p.jsx)(`div`,{"data-email-text":`true`,style:{fontFamily:s.fontFamily,fontSize:s.fontSize,lineHeight:s.lineHeight,letterSpacing:s.letterSpacing,fontWeight:s.fontWeight,color:c,textAlign:s.align,paddingTop:s.paddingTop??8,paddingBottom:s.paddingBottom??8,paddingLeft:s.paddingLeft??16,paddingRight:s.paddingRight??16,margin:0,minHeight:`1.5em`,outline:`none`,...u?{textShadow:`0 0 8px rgba(0,0,0,0.55), 0 1px 2px rgba(0,0,0,0.45)`}:void 0},contentEditable:!0,suppressContentEditableWarning:!0,onFocus:e=>{o.current=!0,a(e.currentTarget)},onBlur:t=>{o.current=!1,t.relatedTarget?.closest(`[data-rich-toolbar]`)||a(null);let n=t.currentTarget.innerHTML;n!==e.content&&i(r,e.id,{content:n})},onClick:e=>{o.current&&e.stopPropagation()},dangerouslySetInnerHTML:{__html:e.content}})}function ta({el:e,viewMode:t,theme:n}){let r=S(Yi(e.style,t),n),i={textAlign:r.align??`center`,paddingTop:r.paddingTop??0,paddingBottom:r.paddingBottom??0,paddingLeft:r.paddingLeft??0,paddingRight:r.paddingRight??0},a={display:`inline-block`,maxWidth:`100%`,width:r.width,height:r.height||`auto`,borderRadius:r.borderRadius};return(0,p.jsx)(`div`,{style:i,children:(0,p.jsx)(`img`,{src:e.src,alt:e.alt??``,style:a})})}function na({el:e,viewMode:t,theme:n}){let r=S(Yi(e.style,t),n);return(0,p.jsx)(`div`,{style:{textAlign:r.align??`center`,paddingTop:r.paddingTop??12,paddingBottom:r.paddingBottom??12,paddingLeft:r.paddingLeft??16,paddingRight:r.paddingRight??16},children:(0,p.jsx)(`span`,{style:{display:`inline-block`,backgroundColor:r.backgroundColor??`#3A7D52`,color:r.color??`#fff`,fontFamily:r.fontFamily,fontSize:r.fontSize??16,fontWeight:r.fontWeight??`bold`,borderRadius:r.borderRadius??6,padding:`12px 24px`,textDecoration:`none`},children:e.label})})}function ra({el:e}){return(0,p.jsx)(`div`,{style:{height:e.height,background:`rgba(0,0,0,0.02)`}})}function ia({el:e,viewMode:t,theme:n}){let r=S(Yi(e.style,t),n);return(0,p.jsx)(`div`,{style:{paddingTop:r.paddingTop??8,paddingBottom:r.paddingBottom??8},children:(0,p.jsx)(`hr`,{style:{border:0,borderTop:`${r.thickness??1}px solid ${r.color??`#E5E7EB`}`,margin:0}})})}function aa({el:e,viewMode:t,theme:n}){let r=S(Yi(e.style,t),n),i=t===`mobile`,a=e.columns,o=r.cardBackgroundColor??r.backgroundColor??`transparent`,s=r.nameColor??`#111827`,c=r.finalPriceColor??`#3A7D52`,l=r.oldPriceColor??`#9CA3AF`,u=r.buttonBackgroundColor??`#3A7D52`,d=r.buttonColor??`#FFFFFF`,f=r.borderRadius??0;return(0,p.jsx)(`div`,{style:{paddingTop:r.paddingTop??16,paddingBottom:r.paddingBottom??16,paddingLeft:r.paddingLeft??16,paddingRight:r.paddingRight??16,display:`flex`,flexWrap:`wrap`,gap:8},children:e.products.map(t=>(0,p.jsxs)(`div`,{style:{width:i?`100%`:`calc(${100/a}% - 8px)`,background:o,borderRadius:f,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:[(0,p.jsx)(`img`,{src:t.image,alt:t.imageAlt??t.name,style:{display:`block`,width:`100%`,height:`auto`,borderRadius:f}}),(0,p.jsx)(`div`,{style:{padding:`12px 12px 4px 12px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:15,fontWeight:`bold`,color:s,lineHeight:1.3},children:t.name}),e.showStars&&t.stars!=null&&(0,p.jsx)(`div`,{className:`stars`,style:{padding:`0 12px 4px 12px`,color:`#F5A623`,fontSize:15,letterSpacing:1},"aria-label":`${t.stars} out of 5 stars`,children:te(t.stars)}),(0,p.jsxs)(`div`,{style:{padding:`0 12px 8px 12px`,fontFamily:`Arial, Helvetica, sans-serif`},children:[e.showOldPrice&&t.oldPrice&&(0,p.jsx)(`span`,{className:`old_price`,style:{color:l,textDecoration:`line-through`,fontSize:14,marginRight:8},children:t.oldPrice}),(0,p.jsx)(`span`,{className:`final_price`,style:{color:c,fontWeight:`bold`,fontSize:18},children:t.finalPrice})]}),e.showDescription&&t.description&&(0,p.jsx)(`div`,{style:{padding:`0 12px 8px 12px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:13,color:`#6B7280`,lineHeight:1.5},children:t.description}),e.showButton&&(0,p.jsx)(`div`,{style:{padding:`4px 12px 12px 12px`,textAlign:`center`,marginTop:`auto`},children:(0,p.jsx)(`span`,{style:{display:`inline-block`,padding:`10px 18px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:13,fontWeight:`bold`,color:d,backgroundColor:u,borderRadius:6},children:t.buttonLabel??e.buttonLabel??`Shop now`})})]},t.id))})}var oa=null,sa=new Set,ca=0;function la(){ca+=1;for(let e of sa)e()}function ua(e){oa!==e&&(oa=e,la())}function da(){return oa}var fa=e=>(sa.add(e),()=>{sa.delete(e)}),pa=()=>ca,ma=null,ha={status:`idle`,vouchers:[]},ga=null,_a=new Set,va=0;function ya(){va+=1;for(let e of _a)e()}function ba(e){ma!==e&&(ma=e,ha={status:`idle`,vouchers:[]},ga=null,ya())}function xa(){return ma}function Sa(){return ha}function Ca(e=!1){if(!ma)return Promise.resolve([]);if(!e&&ha.status===`loaded`)return Promise.resolve(ha.vouchers);if(ga)return ga;ha={status:`loading`,vouchers:ha.vouchers},ya();let t=ma.list().then(e=>(ha={status:`loaded`,vouchers:Array.isArray(e)?e:[]},ga=null,ya(),ha.vouchers)).catch(e=>(ha={status:`error`,vouchers:[],error:e instanceof Error?e.message:String(e)},ga=null,ya(),[]));return ga=t,t}var wa=e=>(_a.add(e),()=>{_a.delete(e)}),Ta=()=>va,Ea=[],Da=null,Oa={registerModule:e=>Ie.register(e),registerTheme:e=>Ea.push(e),registerAssetProvider:e=>{Da=e},registerProductProvider:e=>{ua(e)},registerVoucherProvider:e=>{ba(e)},setAIProvider:e=>{He(e)},registerMergeTags:e=>Oi(e)};function ka(e){e.setup(Oa)}function Aa(){return Da}var ja={key:`days`,label:`Time window`,type:`select`,default:7,options:[{value:7,label:`Last 7 days`},{value:14,label:`Last 14 days`},{value:30,label:`Last 30 days`}]},Ma=[{id:`abandoned-cart`,label:`Abandoned basket products`,group:`behavioral`},{id:`bestseller-conversion`,label:`Best seller by Conversion`,group:`catalog`,params:[ja]},{id:`bestseller-units`,label:`Best seller by Units`,group:`catalog`,params:[ja]},{id:`new-products`,label:`New items added`,group:`catalog`,params:[ja]},{id:`cross-sell`,label:`Products Cross-Sell`,group:`contextual`},{id:`upsell`,label:`Products Upsell`,group:`contextual`},{id:`viewed-categories`,label:`Items from viewed categories`,group:`behavioral`},{id:`viewed-items`,label:`Items viewed`,group:`behavioral`},{id:`similar-basket`,label:`Similar to basket items`,group:`behavioral`},{id:`bought-together`,label:`Items bought together`,group:`contextual`},{id:`best-discount`,label:`Items with the best discount`,group:`catalog`},{id:`match-data`,label:`Items matching specific attributes`,group:`catalog`},{id:`last-purchased`,label:`Last purchased items`,group:`personal`},{id:`similar-to-purchased`,label:`Similar to last purchase`,group:`personal`},{id:`cross-sell-purchased`,label:`Cross-sell to last purchase`,group:`personal`},{id:`similar-items`,label:`Similar items`,group:`contextual`}],Na=Object.fromEntries(Ma.map(e=>[e.id,e])),Pa=[{value:`smart-reccs`,label:`Smart Recommendations`,description:`Best generic algorithm — recommended default.`},{value:`random`,label:`Random items (strict filters)`,description:`Random items that still pass include/exclude filters.`},{value:`ignore`,label:`Ignore position`,description:`Skip the slot if no items found.`},{value:`stop`,label:`Don't display`,description:`Don't render the email if the slot can't be filled.`}];function Fa(e=2){return{mode:`recommender`,noProducts:e,sourceFeed:``,manualProducts:[],stack:[{algorithm:`abandoned-cart`}],fallback:`smart-reccs`,filters:{includeProducts:[],excludeProducts:[],includeCategories:[],excludeCategories:[],minStock:0,minPrice:0,mainOnly:!1,higherPrice:!1,salesPrice:!1,sameCategory:!1,matchTitle:!1,sameField:``}}}function Ia(e){if(!e)return null;let t=e.recommendations;return!t||typeof t!=`object`?null:t}function La(e){return e?.children?e.children.some(e=>e.type===`productGrid`):!1}function Ra(e){if(!e?.children)return 0;let t=0;for(let n of e.children)n.type===`productGrid`&&(t+=n.products.length);return t}function za(e){return{params:{selection:e.mode===`manual`?`manual`:`recommender`,include:{item:e.filters.includeProducts,category:e.filters.includeCategories},exclude:{item:e.filters.excludeProducts,category:e.filters.excludeCategories},higherPrice:e.filters.higherPrice??!1,salesPrice:e.filters.salesPrice??!1,sameCategory:e.filters.sameCategory??!1,matchTitle:e.filters.matchTitle??!1,sameField:e.filters.sameField??``,mainOnly:e.filters.mainOnly??!1},noProducts:String(e.noProducts),fallback:e.fallback,stack:e.mode===`manual`?[]:e.stack,minStock:String(e.filters.minStock??0),minPrice:String(e.filters.minPrice??0),sourceFeed:e.sourceFeed??``,manualProducts:e.manualProducts}}function Ba({mod:e}){let t=N(e=>e.updateModule),n=Ra(e)||2,r=Ia(e.data)??Fa(n),i=n=>{let i={...r,...n};t(e.id,{data:{...e.data??{},recommendations:i}})};return(0,p.jsxs)(`div`,{className:`border border-blue-200 rounded-lg bg-blue-50/40 mt-4 overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 border-b border-blue-200 bg-blue-50`,children:[(0,p.jsx)(f.Sparkles,{size:14,className:`text-blue-700`}),(0,p.jsx)(`div`,{className:`text-xs font-semibold text-blue-900 uppercase tracking-wide`,children:`Products Source`})]}),(0,p.jsx)(`div`,{className:`p-3 bg-white border-b border-blue-100`,children:(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Wa,{active:r.mode===`manual`,title:`Select Items`,subtitle:`Hand-pick from a feed`,onClick:()=>i({mode:`manual`})}),(0,p.jsx)(Wa,{active:r.mode===`recommender`,title:`Recommender`,subtitle:`Algorithms + filters`,onClick:()=>i({mode:`recommender`})})]})}),(0,p.jsxs)(`div`,{className:`p-3 bg-white space-y-3`,children:[(0,p.jsxs)(X,{label:`Number of products`,children:[(0,p.jsx)(`input`,{type:`number`,min:1,max:20,value:r.noProducts,onChange:e=>i({noProducts:Number(e.target.value)||1}),className:Ua}),(0,p.jsxs)(`div`,{className:`text-[11px] text-gray-500 mt-1`,children:[`Block has `,n,` slot`,n===1?``:`s`,` in the design.`]})]}),r.mode===`manual`?(0,p.jsx)(Va,{logic:r,update:i}):(0,p.jsx)(Ha,{logic:r,update:i,updateFilters:e=>i({filters:{...r.filters,...e}})}),(0,p.jsxs)(`details`,{className:`border border-gray-200 rounded`,children:[(0,p.jsx)(`summary`,{className:`px-2 py-1.5 text-[11px] font-medium text-gray-600 cursor-pointer select-none`,children:`View saved JSON`}),(0,p.jsx)(`pre`,{className:`text-[10px] bg-gray-900 text-gray-100 p-2 overflow-auto max-h-60 leading-tight`,children:JSON.stringify(r,null,2)})]})]})]})}function Va({logic:e,update:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(X,{label:`Source feed`,children:(0,p.jsx)(`input`,{type:`text`,placeholder:`e.g. main-catalog`,value:e.sourceFeed??``,onChange:e=>t({sourceFeed:e.target.value}),className:Ua})}),(0,p.jsx)(X,{label:`Items to include (product IDs / SKUs)`,children:(0,p.jsx)(Xa,{value:e.manualProducts,onChange:e=>t({manualProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(`div`,{className:`text-[11px] text-gray-500`,children:`Items are sent to the renderer as-is in the order shown.`})]})}function Ha({logic:e,update:t,updateFilters:n}){let[r,i]=(0,l.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,p.jsxs)(`label`,{className:`text-xs font-medium text-gray-700`,children:[`Algorithms (max `,3,`)`]}),(0,p.jsx)(Ya,{disabled:e.stack.length>=3,existing:e.stack.map(e=>e.algorithm),onPick:n=>t({stack:[...e.stack,{algorithm:n}]})})]}),(0,p.jsx)(Ja,{stack:e.stack,onChange:e=>t({stack:e})})]}),(0,p.jsxs)(X,{label:`Fallback`,children:[(0,p.jsx)(`select`,{value:e.fallback,onChange:e=>t({fallback:e.target.value}),className:Ua,children:Pa.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,p.jsx)(`div`,{className:`text-[11px] text-gray-500 mt-1`,children:Pa.find(t=>t.value===e.fallback)?.description})]}),(0,p.jsx)(Ga,{title:`Include & Exclude filters`,right:(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(Ka,{active:!r,onClick:()=>i(!1),children:`Basic`}),(0,p.jsx)(Ka,{active:r,onClick:()=>i(!0),children:`Advanced`})]})}),(0,p.jsx)(X,{label:`Exclude products`,children:(0,p.jsx)(Xa,{value:e.filters.excludeProducts,onChange:e=>n({excludeProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(X,{label:`Include products`,children:(0,p.jsx)(Xa,{value:e.filters.includeProducts,onChange:e=>n({includeProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(X,{label:`Exclude categories`,children:(0,p.jsx)(Xa,{value:e.filters.excludeCategories,onChange:e=>n({excludeCategories:e}),placeholder:`Add category`})}),(0,p.jsx)(X,{label:`Include categories`,children:(0,p.jsx)(Xa,{value:e.filters.includeCategories,onChange:e=>n({includeCategories:e}),placeholder:`Add category`})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(X,{label:`Minimum stock`,children:(0,p.jsx)(`input`,{type:`number`,min:0,value:e.filters.minStock??0,onChange:e=>n({minStock:Number(e.target.value)||0}),className:Ua})}),(0,p.jsx)(X,{label:`Minimum price`,children:(0,p.jsx)(`input`,{type:`number`,min:0,value:e.filters.minPrice??0,onChange:e=>n({minPrice:Number(e.target.value)||0}),className:Ua})})]}),(0,p.jsx)(qa,{label:`Only main items`,checked:!!e.filters.mainOnly,onChange:e=>n({mainOnly:e})}),(0,p.jsx)(qa,{label:`Higher price than current item (upsell)`,checked:!!e.filters.higherPrice,onChange:e=>n({higherPrice:e})}),(0,p.jsx)(qa,{label:`On sale only`,checked:!!e.filters.salesPrice,onChange:e=>n({salesPrice:e})}),(0,p.jsx)(qa,{label:`Same category as current`,checked:!!e.filters.sameCategory,onChange:e=>n({sameCategory:e})}),(0,p.jsx)(qa,{label:`Match title keywords`,checked:!!e.filters.matchTitle,onChange:e=>n({matchTitle:e})}),(0,p.jsx)(X,{label:`Match same fields (comma-separated)`,children:(0,p.jsx)(`input`,{type:`text`,placeholder:`brand, color`,value:e.filters.sameField??``,onChange:e=>n({sameField:e.target.value}),className:Ua})}),r&&(0,p.jsx)(X,{label:`Advanced JSON overrides`,children:(0,p.jsx)(Za,{value:e.filters.advanced??{},onChange:e=>n({advanced:e})})})]})}var Ua=`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`;function Wa({active:e,icon:t,title:n,subtitle:r,onClick:i}){return(0,p.jsxs)(`button`,{onClick:i,className:`flex flex-col items-start gap-0.5 p-2.5 rounded border text-left transition `+(e?`border-teal-600 bg-teal-50 ring-1 ring-teal-600`:`border-gray-200 bg-white hover:border-gray-300`),children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 `+(e?`text-teal-700`:`text-gray-700`),children:[t,(0,p.jsx)(`span`,{className:`text-xs font-semibold`,children:n})]}),(0,p.jsx)(`span`,{className:`text-[10px] text-gray-500`,children:r})]})}function Ga({title:e,right:t}){return(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-200 pt-3 mt-3`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-gray-600`,children:e}),t]})}function X({label:e,children:t}){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-gray-700 mb-1`,children:e}),t]})}function Ka({active:e,onClick:t,children:n}){return(0,p.jsx)(`button`,{onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide `+(e?`bg-teal-600 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`),children:n})}function qa({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center justify-between gap-2 text-xs text-gray-700 py-1`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked),className:`h-4 w-4 accent-teal-600`})]})}function Ja({stack:e,onChange:t}){if(e.length===0)return(0,p.jsxs)(`div`,{className:`text-[11px] text-gray-500 italic border border-dashed border-gray-300 rounded px-2 py-3 text-center`,children:[`No algorithms yet. Click `,(0,p.jsx)(`b`,{children:`Add algorithm`}),` to start.`]});let n=(n,r)=>{let i=n+r;if(i<0||i>=e.length)return;let a=e.slice();[a[n],a[i]]=[a[i],a[n]],t(a)},r=n=>t(e.filter((e,t)=>t!==n)),i=(n,r,i)=>{let a=e.slice();a[n]={...a[n],params:{...a[n].params??{},[r]:i}},t(a)};return(0,p.jsx)(`div`,{className:`space-y-1.5`,children:e.map((t,a)=>{let o=Na[t.algorithm];return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded px-2 py-1.5 bg-white flex flex-col gap-1`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(`span`,{className:`flex-1 text-xs text-gray-800 truncate`,children:o?.label??t.algorithm}),(0,p.jsx)(`button`,{title:`Move up`,onClick:()=>n(a,-1),disabled:a===0,className:`p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30`,children:(0,p.jsx)(f.ChevronUp,{size:13})}),(0,p.jsx)(`button`,{title:`Move down`,onClick:()=>n(a,1),disabled:a===e.length-1,className:`p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30`,children:(0,p.jsx)(f.ChevronDown,{size:13})}),(0,p.jsx)(`button`,{title:`Remove`,onClick:()=>r(a),className:`p-1 text-gray-400 hover:text-red-600`,children:(0,p.jsx)(f.Trash2,{size:13})})]}),o?.params?.map(e=>(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`text-[10px] text-gray-500 w-20 shrink-0`,children:e.label}),e.type===`select`?(0,p.jsx)(`select`,{value:String(t.params?.[e.key]??e.default??``),onChange:t=>i(a,e.key,t.target.value),className:`flex-1 text-xs border border-gray-200 rounded px-1.5 py-1 bg-white`,children:e.options?.map(e=>(0,p.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))}):(0,p.jsx)(`input`,{type:e.type===`number`?`number`:`text`,value:String(t.params?.[e.key]??e.default??``),onChange:t=>i(a,e.key,e.type===`number`?Number(t.target.value):t.target.value),className:`flex-1 text-xs border border-gray-200 rounded px-1.5 py-1`})]},e.key))]},a)})})}function Ya({disabled:e,existing:t,onPick:n}){let[r,i]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsxs)(`button`,{disabled:e,onClick:()=>i(e=>!e),className:`flex items-center gap-1 px-2 py-1 rounded text-[11px] font-semibold uppercase `+(e?`bg-gray-200 text-gray-400 cursor-not-allowed`:`bg-teal-600 text-white hover:bg-teal-700`),children:[(0,p.jsx)(f.Plus,{size:12}),` Add`]}),r&&!e&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>i(!1)}),(0,p.jsx)(`div`,{className:`absolute right-0 top-full mt-1 w-64 max-h-80 overflow-auto bg-white border border-gray-200 rounded shadow-lg z-20`,children:Ma.map(e=>{let r=t.includes(e.id);return(0,p.jsxs)(`button`,{disabled:r,onClick:()=>{n(e.id),i(!1)},className:`block w-full text-left px-2.5 py-1.5 text-xs `+(r?`text-gray-400 cursor-not-allowed`:`text-gray-700 hover:bg-teal-50 hover:text-teal-700`),children:[e.label,r&&(0,p.jsx)(`span`,{className:`ml-1 text-[10px]`,children:`· added`})]},e.id)})})]})]})}function Xa({value:e,onChange:t,placeholder:n}){let[r,i]=(0,l.useState)(``),a=()=>{let n=r.trim();n&&(e.includes(n)||(t([...e,n]),i(``)))};return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded bg-white p-1 flex flex-wrap items-center gap-1 focus-within:border-blue-500`,children:[e.map(n=>(0,p.jsxs)(`span`,{className:`inline-flex items-center gap-1 bg-gray-100 text-gray-800 text-[11px] rounded px-1.5 py-0.5`,children:[n,(0,p.jsx)(`button`,{onClick:()=>t(e.filter(e=>e!==n)),className:`text-gray-500 hover:text-red-600`,children:(0,p.jsx)(f.X,{size:10})})]},n)),(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`||n.key===`,`?(n.preventDefault(),a()):n.key===`Backspace`&&!r&&e.length&&t(e.slice(0,-1))},onBlur:a,placeholder:e.length===0?n:``,className:`flex-1 min-w-20 outline-none text-xs bg-transparent px-1 py-0.5`})]})}function Za({value:e,onChange:t}){let[n,r]=(0,l.useState)(()=>JSON.stringify(e,null,2)),[i,a]=(0,l.useState)(null);return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`textarea`,{value:n,onChange:e=>{let n=e.target.value;r(n);try{let e=JSON.parse(n||`{}`);a(null),t(e)}catch(e){a(String(e.message))}},rows:6,spellCheck:!1,className:`w-full font-mono text-[11px] border border-gray-200 rounded p-2 bg-gray-50 focus:border-blue-500 focus:outline-none`}),i&&(0,p.jsx)(`div`,{className:`text-[10px] text-red-600 mt-1`,children:i})]})}function Qa(){(0,l.useSyncExternalStore)(wa,Ta,Ta);let e=xa()!==null,t=Sa();return(0,l.useEffect)(()=>{e&&t.status===`idle`&&Ca()},[e,t.status]),{available:e,status:t.status,vouchers:t.vouchers,error:t.error,reload:()=>void Ca(!0)}}function $a(e){return e?.children?.find(e=>e.type===`text`&&e.role===`voucherCode`)}function eo(e){return!!$a(e)}function to(e){let t=e?.data?.voucher;return t&&typeof t==`object`&&`code`in t?t:null}function no(e){return{id:e.id,title:e.title,code:e.code}}function ro({mod:e}){let t=N(e=>e.updateElement),n=N(e=>e.updateModule),{available:r,status:i,vouchers:a,error:o,reload:s}=Qa(),c=$a(e),l=to(e),u=l&&a.some(e=>e.id===l.id)?l.id:``,d=r=>{if(!r){n(e.id,{data:{...e.data??{},voucher:void 0}});return}c&&t(e.id,c.id,{content:r.code}),n(e.id,{data:{...e.data??{},voucher:no(r)}})};return(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:[(0,p.jsx)(f.Ticket,{size:13,className:`text-blue-600`}),` Voucher`]}),r&&(0,p.jsxs)(`button`,{type:`button`,onClick:s,disabled:i===`loading`,className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded disabled:opacity-50`,title:`Reload vouchers`,children:[i===`loading`?(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}):(0,p.jsx)(f.RefreshCw,{size:12}),`Reload`]})]}),r?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`label`,{className:`block mb-2`,children:[(0,p.jsx)(`span`,{className:`block text-xs text-gray-600 mb-1`,children:`Select voucher`}),(0,p.jsxs)(`select`,{value:u,disabled:i===`loading`&&a.length===0,onChange:e=>{let t=a.find(t=>t.id===e.target.value)??null;d(t)},className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded bg-white focus:border-blue-500 focus:outline-none disabled:bg-gray-50`,children:[(0,p.jsx)(`option`,{value:``,children:i===`loading`&&a.length===0?`Loading vouchers…`:`Please select a voucher…`}),a.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),i===`error`&&(0,p.jsxs)(`p`,{className:`flex items-start gap-1 text-[11px] text-red-600 mb-2`,children:[(0,p.jsx)(f.AlertTriangle,{size:12,className:`mt-0.5 shrink-0`}),o??`Failed to load vouchers.`]}),i===`loaded`&&a.length===0&&(0,p.jsx)(`p`,{className:`text-[11px] text-gray-400 mb-2`,children:`No vouchers found.`}),l&&(0,p.jsxs)(`div`,{className:`rounded border border-green-200 bg-green-50 px-2.5 py-2 text-[12px] text-green-800`,children:[`Voucher code: `,(0,p.jsx)(`span`,{className:`font-semibold`,children:l.code})]})]}):(0,p.jsxs)(`p`,{className:`text-[11px] text-gray-400`,children:[`Register a voucher provider (`,(0,p.jsx)(`code`,{children:`voucherPlugin`}),`) to pick codes from your catalog. You can still edit the code text directly.`]})]})}function io({open:e,onClose:t,onSave:n,initialQuery:r,title:i}){let[a,o]=(0,l.useState)(r??``),[s,c]=(0,l.useState)(!1),[u,d]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),[g,_]=(0,l.useState)(!1),v=(0,l.useRef)(null);if((0,l.useEffect)(()=>{if(!e)return;o(r??``),h(null),d(null),_(!1);let n=setTimeout(()=>v.current?.focus(),40),i=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,i),()=>{clearTimeout(n),window.removeEventListener(`keydown`,i)}},[e,r,t]),!e)return null;let y=async()=>{let e=da(),t=a.trim();if(!(!e||!t||s)){c(!0),d(null),h(null),_(!0);try{let n=await e.search(t);h(n)}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1)}}};return(0,p.jsx)(`div`,{className:`fixed inset-0 z-50 flex bg-black/60 backdrop-blur-sm p-4`,children:(0,p.jsxs)(`div`,{className:`m-auto flex max-h-[90vh] w-full max-w-lg flex-col overflow-hidden rounded-2xl bg-white shadow-2xl`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-200 px-5 py-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(f.PackageSearch,{size:18,className:`text-blue-600`}),(0,p.jsx)(`h2`,{className:`text-base font-semibold text-neutral-900`,children:i??`Find a product`})]}),(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg p-1.5 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900`,"aria-label":`Close`,children:(0,p.jsx)(f.X,{size:18})})]}),(0,p.jsx)(`div`,{className:`border-b border-neutral-100 px-5 py-3`,children:(0,p.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,p.jsxs)(`div`,{className:`relative flex-1`,children:[(0,p.jsx)(f.Search,{size:15,className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-neutral-400`}),(0,p.jsx)(`input`,{ref:v,value:a,onChange:e=>o(e.target.value),placeholder:`Search your catalog by name or SKU…`,className:`w-full rounded-lg border border-neutral-200 bg-white py-2 pl-9 pr-3 text-sm outline-none focus:border-blue-500`})]}),(0,p.jsxs)(`button`,{type:`submit`,disabled:s||!a.trim(),className:`flex shrink-0 items-center gap-1.5 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:bg-neutral-300`,children:[s?(0,p.jsx)(f.Loader2,{size:15,className:`animate-spin`}):(0,p.jsx)(f.Search,{size:15}),`Search`]})]})}),(0,p.jsxs)(`div`,{className:`min-h-[220px] flex-1 overflow-y-auto p-5`,children:[s&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-sm text-neutral-500`,children:[(0,p.jsx)(f.Loader2,{size:22,className:`animate-spin`}),`Searching…`]}),!s&&u&&(0,p.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700`,children:u}),!s&&!u&&g&&!m&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-center text-sm text-neutral-500`,children:[(0,p.jsx)(f.PackageSearch,{size:22,className:`text-neutral-300`}),`No product matched “`,a.trim(),`”. Try another name or SKU.`]}),!s&&!u&&!g&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-center text-sm text-neutral-400`,children:[(0,p.jsx)(f.PackageSearch,{size:22,className:`text-neutral-300`}),`Search your catalog, then preview and save the product.`]}),!s&&m&&(0,p.jsx)(ao,{result:m})]}),(0,p.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-neutral-200 px-5 py-3`,children:[(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg px-4 py-2 text-sm font-medium text-neutral-600 hover:bg-neutral-100`,children:`Cancel`}),(0,p.jsxs)(`button`,{onClick:()=>{m&&(n(m),t())},disabled:!m,className:`flex items-center gap-1.5 rounded-lg bg-green-600 px-4 py-2 text-sm font-medium text-white hover:bg-green-700 disabled:bg-neutral-300`,children:[(0,p.jsx)(f.Check,{size:15}),` Save product`]})]})]})})}function ao({result:e}){return(0,p.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-neutral-200`,children:[(0,p.jsx)(`div`,{className:`aspect-video w-full overflow-hidden bg-neutral-100`,children:e.image?(0,p.jsx)(`img`,{src:e.image,alt:e.imageAlt??e.name,className:`h-full w-full object-contain`}):(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-xs text-neutral-400`,children:`No image`})}),(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-neutral-900`,children:e.name}),e.stars!=null&&(0,p.jsxs)(`div`,{className:`flex items-center gap-0.5`,"aria-label":`${e.stars} out of 5`,children:[Array.from({length:5}).map((t,n)=>(0,p.jsx)(f.Star,{size:14,className:n<Math.round(e.stars??0)?`fill-amber-400 text-amber-400`:`text-neutral-300`},n)),(0,p.jsx)(`span`,{className:`ml-1 text-xs text-neutral-500`,children:e.stars})]}),(0,p.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[e.oldPrice&&(0,p.jsx)(`span`,{className:`text-sm text-neutral-400 line-through`,children:e.oldPrice}),(0,p.jsx)(`span`,{className:`text-lg font-bold text-blue-600`,children:e.finalPrice})]}),e.description&&(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-neutral-600`,children:e.description}),e.link&&(0,p.jsxs)(`a`,{href:e.link,target:`_blank`,rel:`noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs text-blue-600 hover:underline`,children:[(0,p.jsx)(f.ExternalLink,{size:12}),` View source`]})]})]})}function oo(){return(0,l.useSyncExternalStore)(fa,pa,pa),da()!==null}function so(){let{selection:e,doc:t,viewMode:n}=N(),[r,i]=(0,l.useState)(!0);return r?(0,p.jsxs)(`div`,{className:`w-72 bg-white border-l border-gray-200 shrink-0 overflow-y-auto flex flex-col`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 text-[11px] flex items-center gap-1.5 border-b shrink-0 ${n===`mobile`?`bg-amber-50 text-amber-800 border-amber-200`:`bg-blue-50 text-blue-800 border-blue-100`}`,children:[n===`mobile`?(0,p.jsx)(f.Smartphone,{size:12}):(0,p.jsx)(f.Monitor,{size:12}),(0,p.jsxs)(`span`,{className:`flex-1`,children:[`Editing `,n,` styles`]}),(0,p.jsx)(`button`,{onClick:()=>i(!1),title:`Hide properties`,className:`ml-auto p-0.5 rounded hover:bg-black/10 transition-colors ${n===`mobile`?`text-amber-700 hover:text-amber-900`:`text-blue-700 hover:text-blue-900`}`,children:(0,p.jsx)(f.PanelRightClose,{size:13})})]}),(0,p.jsx)(`div`,{className:`p-4 flex-1`,children:!e||e.kind===`email`?(0,p.jsx)(yo,{}):e.kind===`module`?(()=>{let n=t.modules.find(t=>t.id===e.moduleId);return n?(0,p.jsx)(So,{mod:n}):(0,p.jsx)(co,{})})():(()=>{let n=t.modules.find(t=>t.id===e.moduleId),r=n?.children.find(t=>t.id===e.elementId);return n&&r?(0,p.jsx)(Co,{mod:n,el:r}):(0,p.jsx)(co,{})})()})]}):(0,p.jsx)(`div`,{className:`flex flex-col items-center w-6 bg-white border-l border-gray-200 shrink-0`,children:(0,p.jsx)(`button`,{onClick:()=>i(!0),title:`Show properties`,className:`flex items-center justify-center w-full py-3 text-gray-400 hover:text-gray-600 hover:bg-gray-50 transition-colors`,children:(0,p.jsx)(f.PanelRightOpen,{size:14})})})}function co(){return(0,p.jsx)(`div`,{className:`text-xs text-gray-400`,children:`Nothing selected.`})}function lo(e,t){if(t!==`mobile`)return e;let n=e.mobile??{};return{...e,...n}}function uo(e,t,n){if(n!==`mobile`)return{...e,...t};let r=e.mobile??{};return{...e,mobile:{...r,...t}}}function fo({overridden:e}){return e?(0,p.jsx)(`span`,{className:`ml-1 text-[9px] uppercase tracking-wide bg-amber-100 text-amber-800 px-1 rounded`,children:`mobile`}):null}function po({hideOn:e,onChange:t}){return(0,p.jsx)(Z,{label:`Visibility`,children:(0,p.jsxs)(_o,{value:e??``,onChange:e=>{let n=e.target.value;t(n===``?void 0:n)},children:[(0,p.jsx)(`option`,{value:``,children:`Show on all`}),(0,p.jsx)(`option`,{value:`mobile`,children:`Hide on mobile`}),(0,p.jsx)(`option`,{value:`desktop`,children:`Hide on desktop`})]})})}function mo({children:e}){return(0,p.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500 mb-3`,children:e})}function Z({label:e,children:t}){return(0,p.jsxs)(`label`,{className:`block mb-3`,children:[(0,p.jsx)(`span`,{className:`flex items-center text-xs text-gray-600 mb-1`,children:e}),t]})}function Q(e){return(0,p.jsx)(`input`,{...e,className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none`})}function $(e){return(0,p.jsx)(Q,{type:`number`,...e})}function ho({value:e,onChange:t,onAlt:n}){let r=Aa(),i=(0,l.useRef)(null),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(null),u=async e=>{if(r){o(!0),c(null);try{let i=await r.upload(e);t(i.url),i.alt&&n&&n(i.alt)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1),i.current&&(i.current.value=``)}}};return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex gap-1`,children:[(0,p.jsx)(Q,{value:e??``,onChange:e=>t(e.target.value)}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&u(t)}}),(0,p.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>i.current?.click(),className:`shrink-0 px-2 py-1.5 text-xs border border-gray-200 rounded hover:bg-gray-50 disabled:opacity-50 flex items-center gap-1`,title:`Upload image`,children:a?(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}):(0,p.jsx)(f.Upload,{size:12})})]})]}),s&&(0,p.jsx)(`p`,{className:`text-[10px] text-red-600 mt-1`,children:s}),!r&&(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:`Tip: register an image uploader plugin to enable file uploads.`})]})}function go({value:e,onChange:t,defaultValue:n}){let r=N(e=>e.doc.theme),i=typeof e==`string`&&e.startsWith(`{`),a=(0,l.useRef)(n&&n.startsWith(`{`)?n:i?e:void 0);(0,l.useEffect)(()=>{i?a.current=e:n&&n.startsWith(`{`)&&(a.current=n)},[e,i,n]);let o=(()=>{let t=x(e,r);return typeof t==`string`&&/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)?t.length===4?`#`+t.slice(1).split(``).map(e=>e+e).join(``):t:`#000000`})(),s=n??a.current,c=!!s&&s!==e,[u,d]=(0,l.useState)(e??``);return(0,l.useEffect)(()=>d(e??``),[e]),(0,p.jsxs)(`div`,{className:`flex gap-1 items-center`,children:[(0,p.jsxs)(`label`,{className:`relative w-9 h-8 border border-gray-200 rounded cursor-pointer overflow-hidden shrink-0`,title:i?`Token → ${o} (click to override)`:`Pick color`,style:{background:o},children:[(0,p.jsx)(`input`,{type:`color`,value:o,onChange:e=>t(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer`}),i&&(0,p.jsx)(`span`,{className:`absolute inset-0 pointer-events-none border-2 border-dashed rounded`,style:{borderColor:`rgba(255,255,255,0.6)`}})]}),(0,p.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),onBlur:()=>u!==e&&t(u),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`}),c&&(0,p.jsx)(`button`,{type:`button`,onClick:()=>t(s),className:`shrink-0 p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded`,title:`Reset to ${s}`,children:(0,p.jsx)(f.RotateCcw,{size:12})})]})}function _o(e){return(0,p.jsx)(`select`,{...e,className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`})}function vo({linkType:e,onChangeLinkType:t,onChangeLink:n}){return(0,p.jsxs)(Z,{label:`Link role`,children:[(0,p.jsxs)(_o,{value:e??``,onChange:e=>{let r=e.target.value;r===``?t(void 0):(t(r),n(ye[r]))},children:[(0,p.jsx)(`option`,{value:``,children:`— None —`}),(0,p.jsx)(`option`,{value:`unsubscribe`,children:`Unsubscribe`}),(0,p.jsx)(`option`,{value:`view_in_browser`,children:`View in browser`}),(0,p.jsx)(`option`,{value:`manage_preferences`,children:`Manage preferences`}),(0,p.jsx)(`option`,{value:`user_profile`,children:`User profile`})]}),e&&(0,p.jsxs)(`p`,{className:`text-[10px] text-blue-600 mt-1 flex items-center gap-1`,children:[(0,p.jsx)(f.Tag,{size:10}),`Placeholder: `,(0,p.jsx)(`code`,{className:`font-mono`,children:ye[e]})]})]})}function yo(){let{doc:e,updateMeta:t,updateSettings:n}=N();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Email`}),(0,p.jsx)(Z,{label:`Name`,children:(0,p.jsx)(Q,{value:e.meta.name,onChange:e=>t({name:e.target.value})})}),(0,p.jsx)(Z,{label:`Preview text`,children:(0,p.jsx)(Q,{value:e.meta.previewText,onChange:e=>t({previewText:e.target.value})})}),(0,p.jsx)(Z,{label:`Width (px)`,children:(0,p.jsx)($,{value:e.settings.width,onChange:e=>n({width:Number(e.target.value)||600})})}),(0,p.jsx)(Z,{label:`Background color`,children:(0,p.jsx)(go,{value:e.settings.backgroundColor,onChange:e=>n({backgroundColor:e})})}),(0,p.jsx)(Z,{label:`Content background color`,children:(0,p.jsx)(go,{value:e.settings.contentBackgroundColor,onChange:e=>n({contentBackgroundColor:e})})}),(0,p.jsx)(`div`,{className:`mt-6 pt-4 border-t border-gray-100`,children:(0,p.jsx)(bo,{})})]})}function bo(){let{doc:e,themes:t,applyTheme:n}=N(),r=e.theme,i=t.find(e=>e.id===r.id),a=i!=null&&Object.entries(r.tokens.colors).some(([e,t])=>i.tokens.colors[e]!==t),o=(e,t)=>{n({...r,tokens:{...r.tokens,colors:{...r.tokens.colors,[e]:t}}})};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsx)(mo,{children:`Theme`}),a&&(0,p.jsx)(`button`,{onClick:()=>i&&n(i),className:`text-[10px] text-blue-600 hover:underline mb-3`,title:`Discard color changes and restore the preset`,children:`Reset to preset`})]}),(0,p.jsx)(`div`,{className:`flex flex-col gap-1.5 mb-4`,children:t.map(e=>{let t=e.id===r.id;return(0,p.jsxs)(`button`,{onClick:()=>n(e),title:e.name,className:`flex items-center gap-2 px-2.5 py-2 rounded border text-xs transition-colors ${t?`border-blue-500 bg-blue-50 text-blue-700`:`border-gray-200 bg-white hover:border-gray-300 text-gray-700`}`,children:[(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.primary}}),(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.background}}),(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.text}}),(0,p.jsx)(`span`,{className:`flex-1 text-left`,children:e.name}),t&&(0,p.jsx)(f.Check,{size:12,className:`text-blue-600 shrink-0`})]},e.id)})}),(0,p.jsxs)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500 mb-2`,children:[`Colors`,a&&(0,p.jsx)(`span`,{className:`ml-2 normal-case font-normal text-[10px] bg-amber-100 text-amber-700 px-1.5 py-0.5 rounded`,children:`customised`})]}),(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:Object.entries(r.tokens.colors).map(([e,t])=>(0,p.jsx)(xo,{label:e,value:t,onChange:t=>o(e,t)},e))})]})}function xo({label:e,value:t,onChange:n}){let[r,i]=(0,l.useState)(t);(0,l.useEffect)(()=>i(t),[t]);let a=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)?t.length===4?`#`+t.slice(1).split(``).map(e=>e+e).join(``):t:`#000000`,o=e=>{let t=e.trim();t&&n(t)};return(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`text-xs text-gray-500 w-28 shrink-0 truncate`,title:e,children:e}),(0,p.jsx)(`label`,{className:`relative w-7 h-7 rounded border border-gray-200 cursor-pointer overflow-hidden shrink-0`,style:{background:a},title:`Pick ${e} color`,children:(0,p.jsx)(`input`,{type:`color`,value:a,onChange:e=>n(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full`})}),(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onBlur:()=>o(r),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},className:`flex-1 min-w-0 px-2 py-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`,spellCheck:!1})]})}function So({mod:e}){let t=N(e=>e.updateModule),n=N(e=>e.viewMode),r=e.style??{},i=lo(r,n),a=new Set(Object.keys(r.mobile??{})),o=i=>t(e.id,{style:uo(r,i,n)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:e.name}),(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Background color`,(0,p.jsx)(fo,{overridden:a.has(`backgroundColor`)})]}),children:(0,p.jsx)(go,{value:i.backgroundColor??``,onChange:e=>o({backgroundColor:e})})}),(0,p.jsx)(wo,{style:i,mobileKeys:a,onSet:o}),(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Border radius`,(0,p.jsx)(fo,{overridden:a.has(`borderRadius`)})]}),children:(0,p.jsx)($,{value:i.borderRadius??0,onChange:e=>o({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(po,{hideOn:r.hideOn,onChange:n=>t(e.id,{style:{...r,hideOn:n}})}),La(e)&&(0,p.jsx)(Ba,{mod:e}),eo(e)&&(0,p.jsx)(ro,{mod:e})]})}function Co({mod:e,el:t}){switch(t.type){case`text`:return(0,p.jsx)(Eo,{mod:e,el:t});case`image`:return(0,p.jsx)(Do,{mod:e,el:t});case`button`:return(0,p.jsx)(Oo,{mod:e,el:t});case`spacer`:return(0,p.jsx)(ko,{mod:e,el:t});case`divider`:return(0,p.jsx)(Ao,{mod:e,el:t});case`productGrid`:return(0,p.jsx)(Mo,{mod:e,el:t})}}function wo({style:e,mobileKeys:t,onSet:n}){return(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2 mb-3`,children:[`paddingTop`,`paddingBottom`,`paddingLeft`,`paddingRight`].map(r=>(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[r.replace(`padding`,`Pad `),(0,p.jsx)(fo,{overridden:!!t?.has(r)})]}),children:(0,p.jsx)($,{value:e[r]??0,onChange:e=>n({[r]:Number(e.target.value)})})},r))})}function To(e,t){let n=N(e=>e.updateElement);return r=>n(e.id,t.id,r)}function Eo({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:uo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Text block`}),(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mb-3 leading-relaxed`,children:`Click the text in the canvas to edit it inline. Select words to apply bold, italic, colour, links and more using the floating toolbar.`}),(0,p.jsx)(Z,{label:`Default align`,children:(0,p.jsxs)(_o,{value:a.align??`left`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:`Line height`,children:(0,p.jsx)($,{step:.1,value:a.lineHeight??1.5,onChange:e=>s({lineHeight:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Letter spacing`,children:(0,p.jsx)($,{value:a.letterSpacing??0,onChange:e=>s({letterSpacing:Number(e.target.value)})})})]}),(0,p.jsx)(wo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(po,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function Do({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:uo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Image`}),(0,p.jsx)(Z,{label:`Image URL`,children:(0,p.jsx)(ho,{value:t.src,onChange:e=>n({src:e}),onAlt:e=>n({alt:e})})}),(0,p.jsx)(Z,{label:`Alt text`,children:(0,p.jsx)(Q,{value:t.alt??``,onChange:e=>n({alt:e.target.value})})}),(0,p.jsx)(Z,{label:`Link`,children:(0,p.jsx)(Q,{value:t.link??``,onChange:e=>n({link:e.target.value})})}),(0,p.jsx)(vo,{linkType:t.linkType,onChangeLinkType:e=>n({linkType:e}),onChangeLink:e=>n({link:e})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Width`,(0,p.jsx)(fo,{overridden:o.has(`width`)})]}),children:(0,p.jsx)($,{value:a.width??0,onChange:e=>s({width:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Height`,(0,p.jsx)(fo,{overridden:o.has(`height`)})]}),children:(0,p.jsx)($,{value:a.height??0,onChange:e=>s({height:Number(e.target.value)||void 0})})})]}),(0,p.jsx)(Z,{label:`Border radius`,children:(0,p.jsx)($,{value:a.borderRadius??0,onChange:e=>s({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Align`,children:(0,p.jsxs)(_o,{value:a.align??`center`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsx)(wo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(po,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function Oo({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:uo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Button`}),(0,p.jsx)(Z,{label:`Label`,children:(0,p.jsx)(Q,{value:t.label,onChange:e=>n({label:e.target.value})})}),(0,p.jsx)(Z,{label:`Link`,children:(0,p.jsx)(Q,{value:t.link,onChange:e=>n({link:e.target.value})})}),(0,p.jsx)(vo,{linkType:t.linkType,onChangeLinkType:e=>n({linkType:e}),onChangeLink:e=>n({link:e})}),(0,p.jsx)(Z,{label:`Background color`,children:(0,p.jsx)(go,{value:a.backgroundColor??``,onChange:e=>s({backgroundColor:e})})}),(0,p.jsx)(Z,{label:`Text color`,children:(0,p.jsx)(go,{value:a.color??`#FFFFFF`,onChange:e=>s({color:e})})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:`Font size`,children:(0,p.jsx)($,{value:a.fontSize??16,onChange:e=>s({fontSize:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Border radius`,children:(0,p.jsx)($,{value:a.borderRadius??6,onChange:e=>s({borderRadius:Number(e.target.value)})})})]}),(0,p.jsx)(Z,{label:`Align`,children:(0,p.jsxs)(_o,{value:a.align??`center`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsx)(wo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(po,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function ko({mod:e,el:t}){let n=To(e,t);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Spacer`}),(0,p.jsx)(Z,{label:`Height (px)`,children:(0,p.jsx)($,{value:t.height,onChange:e=>n({height:Number(e.target.value)||0})})})]})}function Ao({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:uo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Divider`}),(0,p.jsx)(Z,{label:`Color`,children:(0,p.jsx)(go,{value:a.color??`#E5E7EB`,onChange:e=>s({color:e})})}),(0,p.jsx)(Z,{label:`Thickness`,children:(0,p.jsx)($,{value:a.thickness??1,onChange:e=>s({thickness:Number(e.target.value)})})}),(0,p.jsx)(wo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(po,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function jo(e=0){let t=e+1;return{id:`p_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,image:`https://placehold.co/400x400?text=Product+${t}`,imageAlt:`Product ${t}`,name:`Product ${t}`,oldPrice:`$59`,finalPrice:`$39`,description:`Short product description.`,link:`#`}}function Mo({mod:e,el:t}){let n=To(e,t),r=N(e=>e.viewMode),i=t.style??{},a=lo(i,r),o=e=>n({style:uo(i,e,r)}),s=e=>n({products:e}),c=e=>{let r=e,i=t.products.slice();if(i.length<r)for(;i.length<r;)i.push(jo(i.length));n({columns:e,products:i})},u=oo(),[d,m]=(0,l.useState)(null);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(mo,{children:`Product Grid`}),(0,p.jsxs)(Z,{label:`Columns (desktop)`,children:[(0,p.jsx)(`div`,{className:`inline-flex bg-gray-100 rounded p-0.5 w-full`,children:[1,2,3].map(e=>(0,p.jsxs)(`button`,{onClick:()=>c(e),className:`flex-1 px-2 py-1 text-xs rounded ${t.columns===e?`bg-white shadow text-gray-900`:`text-gray-500 hover:text-gray-700`}`,children:[e,` `,e===1?`col`:`cols`]},e))}),(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:`Always stacks to 1 column on mobile.`})]}),(0,p.jsx)(Po,{label:`Show old price`,checked:t.showOldPrice,onChange:e=>n({showOldPrice:e})}),(0,p.jsx)(Po,{label:`Show description`,checked:t.showDescription,onChange:e=>n({showDescription:e})}),(0,p.jsx)(Po,{label:`Show stars`,checked:t.showStars??!1,onChange:e=>n({showStars:e})}),(0,p.jsx)(Po,{label:`Show button`,checked:t.showButton,onChange:e=>n({showButton:e})}),(0,p.jsx)(Z,{label:`Default button label`,children:(0,p.jsx)(Q,{value:t.buttonLabel??``,placeholder:`Shop now`,onChange:e=>n({buttonLabel:e.target.value})})}),(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(mo,{children:[`Products (`,t.products.length,`)`]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u&&(0,p.jsxs)(`button`,{onClick:()=>m({index:null,query:``}),className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded`,title:`Find a product from your catalog`,children:[(0,p.jsx)(f.Search,{size:12}),` Find`]}),(0,p.jsxs)(`button`,{onClick:()=>s([...t.products,jo(t.products.length)]),className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded`,title:`Add product`,children:[(0,p.jsx)(f.Plus,{size:12}),` Add`]})]})]}),t.products.map((e,n)=>(0,p.jsx)(Fo,{index:n,product:e,canSearch:u,onSearch:()=>m({index:n,query:e.name}),onChange:e=>{let r=[...t.products];r[n]=e,s(r)},onDelete:()=>s(t.products.filter((e,t)=>t!==n))},e.id))]}),(0,p.jsx)(io,{open:d!==null,initialQuery:d?.query,title:d?.index==null?`Add product from search`:`Replace product`,onClose:()=>m(null),onSave:e=>{let r=G({name:e.name,finalPrice:e.finalPrice,oldPrice:e.oldPrice,description:e.description,link:e.link,image:e.image,imageAlt:e.imageAlt,stars:e.stars}),i={};e.oldPrice&&!t.showOldPrice&&(i.showOldPrice=!0),e.description&&!t.showDescription&&(i.showDescription=!0),e.stars!=null&&!t.showStars&&(i.showStars=!0);let a=t.products.slice();if(d?.index!=null){let e=a[d.index];a[d.index]={...r,id:e.id,buttonLabel:e.buttonLabel}}else a.push(r);n({products:a,...i})}}),(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsx)(mo,{children:`Style`}),(0,p.jsx)(Z,{label:`Card background`,children:(0,p.jsx)(go,{value:a.cardBackgroundColor??``,onChange:e=>o({cardBackgroundColor:e})})}),(0,p.jsx)(Z,{label:`Name color`,children:(0,p.jsx)(go,{value:a.nameColor??``,onChange:e=>o({nameColor:e})})}),(0,p.jsx)(Z,{label:`Final price color`,children:(0,p.jsx)(go,{value:a.finalPriceColor??``,onChange:e=>o({finalPriceColor:e})})}),(0,p.jsx)(Z,{label:`Old price color`,children:(0,p.jsx)(go,{value:a.oldPriceColor??``,onChange:e=>o({oldPriceColor:e})})}),(0,p.jsx)(Z,{label:`Button background`,children:(0,p.jsx)(go,{value:a.buttonBackgroundColor??``,onChange:e=>o({buttonBackgroundColor:e})})}),(0,p.jsx)(Z,{label:`Button text color`,children:(0,p.jsx)(go,{value:a.buttonColor??``,onChange:e=>o({buttonColor:e})})}),(0,p.jsx)(Z,{label:`Card radius`,children:(0,p.jsx)($,{value:a.borderRadius??0,onChange:e=>o({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(wo,{style:a,onSet:o})]})]})}function No({checked:e,onChange:t}){return(0,p.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:n=>{n.preventDefault(),n.stopPropagation(),t(!e)},className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ${e?`bg-blue-600`:`bg-gray-300`}`,children:(0,p.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?`translate-x-4`:`translate-x-0.5`}`})})}function Po({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`span`,{className:`text-xs text-gray-600`,children:e}),(0,p.jsx)(No,{checked:t,onChange:n})]})}function Fo({index:e,product:t,canSearch:n,onSearch:r,onChange:i,onDelete:a}){let o=e=>i({...t,...e});return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded p-2 mb-2 bg-gray-50`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-600`,children:[`#`,e+1]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n&&(0,p.jsx)(`button`,{type:`button`,onClick:r,className:`text-gray-400 hover:text-blue-600`,title:`Replace from product search`,children:(0,p.jsx)(f.Search,{size:12})}),(0,p.jsx)(`button`,{type:`button`,onClick:a,className:`text-gray-400 hover:text-red-600`,title:`Remove product`,children:(0,p.jsx)(f.Trash2,{size:12})})]})]}),(0,p.jsx)(Z,{label:`Name`,children:(0,p.jsx)(Q,{value:t.name,onChange:e=>o({name:e.target.value})})}),(0,p.jsx)(Z,{label:`Image URL`,children:(0,p.jsx)(ho,{value:t.image,onChange:e=>o({image:e}),onAlt:e=>o({imageAlt:e})})}),(0,p.jsx)(Z,{label:`Link`,children:(0,p.jsx)(Q,{value:t.link??``,onChange:e=>o({link:e.target.value})})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:`Final price`,children:(0,p.jsx)(Q,{value:t.finalPrice,onChange:e=>o({finalPrice:e.target.value})})}),(0,p.jsx)(Z,{label:`Old price`,children:(0,p.jsx)(Q,{value:t.oldPrice??``,placeholder:`Optional`,onChange:e=>o({oldPrice:e.target.value||void 0})})})]}),(0,p.jsx)(Z,{label:`Description`,children:(0,p.jsx)(Q,{value:t.description??``,onChange:e=>o({description:e.target.value||void 0})})}),(0,p.jsx)(Z,{label:`Stars (0–5, optional)`,children:(0,p.jsx)($,{value:t.stars??``,min:0,max:5,step:.5,placeholder:`e.g. 4.5`,onChange:e=>o({stars:e.target.value===``?void 0:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Button label (override)`,children:(0,p.jsx)(Q,{value:t.buttonLabel??``,placeholder:`Inherit default`,onChange:e=>o({buttonLabel:e.target.value||void 0})})})]})}var Io=[{type:`basic.text`,category:`basic`,name:`Text Block`,description:`Single editable paragraph of body copy. Use for short notes, intros, or filler text between sections.`,tags:[`text`,`paragraph`,`body`],create:()=>B(`basic.text`,`Text Block`,[F(`Write your text here.`,{role:`body`})])},{type:`basic.heading`,category:`basic`,name:`Heading`,description:`Bold standalone heading using the theme heading font. Use to introduce a section without other elements.`,tags:[`heading`,`title`,`section`],create:()=>B(`basic.heading`,`Heading`,[F(`A clear section heading`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingTop:16,paddingBottom:8,lineHeight:1.25})])},{type:`basic.image`,category:`basic`,name:`Image`,description:`Single full-width image, centered. Use for hero photography, illustrations, or screenshots.`,tags:[`image`,`media`,`photo`],create:()=>B(`basic.image`,`Image`,[I(W(600,300),`Placeholder`)])},{type:`basic.image_caption`,category:`basic`,name:`Image with Caption`,description:`Image followed by a small italicized caption underneath. Editorial style for newsletters.`,tags:[`image`,`caption`,`editorial`],create:()=>B(`basic.image_caption`,`Image + Caption`,[I(W(600,360),`Photo`),F(`Photo: caption goes here.`,{color:`{colors.muted}`,fontSize:13,align:`center`,paddingTop:4,paddingBottom:16})])},{type:`basic.spacer`,category:`basic`,name:`Spacer`,description:`Empty vertical space. Use to separate modules with breathing room.`,tags:[`spacer`,`spacing`,`gap`],create:()=>B(`basic.spacer`,`Spacer`,[R(32)])},{type:`basic.divider`,category:`basic`,name:`Divider`,description:`Thin horizontal rule across the email. Use to visually separate sections.`,tags:[`divider`,`separator`,`rule`],create:()=>B(`basic.divider`,`Divider`,[z()])}],Lo=[{type:`header.logo`,category:`header`,name:`Logo Centered`,description:`Centered brand logo. The simplest header used at the top of almost every newsletter.`,tags:[`logo`,`brand`,`centered`],create:()=>B(`header.logo`,`Logo Header`,[I(W(180,56,`LOGO`),`Logo`,{width:180,paddingTop:24,paddingBottom:24})])},{type:`header.logo_left_date_right`,category:`header`,name:`Logo Left + Date Right`,description:`Two-column header with logo on the left and a date or issue label on the right. Common for periodical newsletters and digests.`,tags:[`logo`,`date`,`issue`,`publication`,`newsletter`],create:()=>B(`header.logo_left_date_right`,`Logo + Date`,[I(W(140,36,`LOGO`),`Logo`,{width:140,align:`left`,paddingTop:16,paddingBottom:16}),F(`Issue #128 · April 29, 2026`,{color:`{colors.muted}`,fontSize:13,align:`right`,paddingTop:0,paddingBottom:16}),z({paddingTop:0,paddingBottom:0})])},{type:`header.publication`,category:`header`,name:`Publication Masthead`,description:`Editorial masthead with publication name in serif type, tagline, and a divider. Mimics print magazine and newspaper newsletters.`,tags:[`masthead`,`publication`,`editorial`,`serif`,`newspaper`,`magazine`],create:()=>B(`header.publication`,`Masthead`,[F(`THE WEEKLY`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,letterSpacing:6,paddingTop:32,paddingBottom:4}),F(`Curated reading for thoughtful people`,{color:`{colors.muted}`,align:`center`,fontSize:13,paddingBottom:16}),z({paddingTop:0,paddingBottom:0})])},{type:`header.hero`,category:`header`,name:`Hero with Headline & Image`,description:`Big headline, subtitle and a wide hero image. Use for the lead story or campaign announcement.`,tags:[`hero`,`headline`,`image`,`lead`,`feature`],create:()=>B(`header.hero`,`Hero`,[F(`Steps Towards a Greener World`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,paddingTop:32,lineHeight:1.2}),F(`Small actions, big impact.`,{color:`{colors.muted}`,align:`center`,paddingBottom:16}),I(W(560,280,`Hero`),`Hero`,{width:560})])},{type:`header.hero_text_only`,category:`header`,name:`Hero Text Only`,description:`Centered eyebrow + large headline + supporting paragraph, no image. Editorial intro for opinion or essay newsletters.`,tags:[`hero`,`text`,`essay`,`editorial`,`minimal`],create:()=>B(`header.hero_text_only`,`Hero Text`,[F(`ESSAY · ISSUE 42`,{fontSize:12,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:3,align:`center`,paddingTop:32,paddingBottom:8}),F(`On building things slowly`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:40,fontWeight:`bold`,align:`center`,lineHeight:1.15,paddingBottom:8}),F(`Why patience and craft still win in a world of shortcuts.`,{color:`{colors.muted}`,align:`center`,fontSize:16,paddingBottom:32})])},{type:`header.announcement`,category:`header`,name:`Announcement Bar`,description:`Thin colored top bar with a single line of promotional text. Use for free shipping, sales, or alerts.`,tags:[`announcement`,`bar`,`promo`,`alert`],create:()=>B(`header.announcement`,`Announcement`,[F(`✨ Free shipping on orders over $50`,{color:`{colors.buttonText}`,align:`center`,fontSize:14,paddingTop:12,paddingBottom:12})],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`header.logo_with_view_browser`,category:`header`,name:`Logo + View in Browser`,description:`Logo with a small 'View in browser' link above it. Standard for marketing newsletters that may render poorly.`,tags:[`logo`,`view-in-browser`,`marketing`,`preheader`],create:()=>B(`header.logo_with_view_browser`,`Logo + Browser Link`,[F(`View in browser`,{color:`{colors.muted}`,fontSize:11,align:`right`,paddingTop:8,paddingBottom:0,link:`#`}),I(W(160,48,`LOGO`),`Logo`,{width:160,paddingTop:8,paddingBottom:16})])},{type:`header.welcome`,category:`header`,name:`Welcome Header`,description:`Friendly greeting with first name placeholder, used at the top of welcome and onboarding emails.`,tags:[`welcome`,`onboarding`,`greeting`,`personalized`],create:()=>B(`header.welcome`,`Welcome`,[F(`👋 Welcome aboard, {{first_name}}`,{fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,align:`center`,paddingTop:32,paddingBottom:8}),F(`We're glad you're here. Here's what to do next.`,{color:`{colors.muted}`,align:`center`,paddingBottom:16})])},{type:`header.logo_with_tagline`,category:`header`,name:`Logo + Tagline`,description:`Centered logo above a one-line tagline. Friendly brand-forward header.`,tags:[`logo`,`tagline`,`brand`],create:()=>B(`header.logo_with_tagline`,`Logo + Tagline`,[I(W(160,48,`LOGO`),`Logo`,{width:160,paddingTop:24,paddingBottom:4}),F(`Newsletters that respect your time.`,{align:`center`,color:`{colors.muted}`,fontSize:14,paddingBottom:24})])},{type:`header.story_label`,category:`header`,name:`Story Label Header`,description:`Small category label (e.g. 'Top story', 'Deep dive') above the masthead. Used by The Hustle, Morning Brew style newsletters.`,tags:[`label`,`category`,`story`,`newsletter`,`topic`],create:()=>B(`header.story_label`,`Story Label`,[F(`TODAY'S TOP STORY`,{color:`{colors.primary}`,fontSize:12,fontWeight:`bold`,letterSpacing:3,align:`center`,paddingTop:24,paddingBottom:4}),F(`AI editing tools come for the inbox`,{fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,align:`center`,paddingBottom:16,lineHeight:1.2})])}],Ro=[{type:`menu.horizontal`,category:`menu`,name:`Horizontal Nav`,description:`Horizontal menu with 3-5 inline links separated by dots. Common publication navigation under the masthead.`,tags:[`menu`,`nav`,`horizontal`,`publication`],create:()=>B(`menu.horizontal`,`Horizontal Menu`,[F(`Home · Articles · Podcast · About · Subscribe`,{align:`center`,color:`{colors.text}`,fontSize:13,paddingTop:12,paddingBottom:12})])},{type:`menu.sections`,category:`menu`,name:`Section Tabs`,description:`Linked section labels representing the contents of today's issue (e.g. News · Markets · Tech · Culture). Used by daily digests.`,tags:[`menu`,`sections`,`tabs`,`digest`,`daily`],create:()=>B(`menu.sections`,`Section Tabs`,[z({paddingTop:0,paddingBottom:8}),F(`NEWS · MARKETS · TECH · CULTURE · WEEKEND`,{align:`center`,color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,paddingTop:0,paddingBottom:8}),z({paddingTop:0,paddingBottom:8})])},{type:`menu.in_this_issue`,category:`menu`,name:`In This Issue`,description:`Table-of-contents box listing the items in this newsletter issue with anchor links. Helps readers scan long emails.`,tags:[`toc`,`menu`,`issue`,`summary`,`table of contents`],create:()=>B(`menu.in_this_issue`,`In This Issue`,[F(`IN THIS ISSUE`,{fontSize:11,fontWeight:`bold`,color:`{colors.muted}`,letterSpacing:2,paddingTop:16,paddingBottom:8}),F(`→ Lead story: AI in the inbox`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#lead`}),F(`→ 3 things worth your time`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#picks`}),F(`→ Reader question of the week`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#qa`}),F(`→ Upcoming events`,{fontSize:14,paddingTop:2,paddingBottom:16,link:`#events`})],{backgroundColor:`{colors.background}`,paddingTop:8,paddingBottom:8,paddingLeft:16,paddingRight:16})},{type:`menu.cta_strip`,category:`menu`,name:`Linked Action Strip`,description:`Three short text actions in a row (e.g. 'Read · Share · Reply'). Light alternative to a button bar.`,tags:[`menu`,`actions`,`links`,`strip`],create:()=>B(`menu.cta_strip`,`Action Strip`,[F(`Read online · Share · Reply with feedback`,{align:`center`,color:`{colors.primary}`,fontSize:13,paddingTop:12,paddingBottom:12})])}],zo=[{type:`content.headline_body`,category:`content`,name:`Headline + Body`,description:`Section title with one paragraph of body text. The most generic written content block.`,tags:[`headline`,`body`,`paragraph`,`article`],create:()=>B(`content.headline_body`,`Headline + Body`,[V(`A compelling headline`,{paddingTop:24}),F(`Tell your story with a clear, concise paragraph. Keep readers engaged with short sentences and meaningful detail.`,{paddingBottom:24})])},{type:`content.lead_story`,category:`content`,name:`Lead Story`,description:`Top story of the issue: eyebrow label, big headline, hero image, lead paragraph and a 'Continue reading' link. Used by news and editorial newsletters.`,tags:[`lead`,`story`,`feature`,`news`,`editorial`,`long-form`],create:()=>B(`content.lead_story`,`Lead Story`,[H(`Lead story`),V(`Inside the new wave of indie publishers`,{level:1,paddingBottom:4}),U(`By Jane Doe · 6 min read`,{fontSize:13}),I(W(560,320,`Lead`),`Lead`,{width:560,paddingTop:12}),F(`A growing group of writers are leaving big media to build their own readerships, betting that quality and a direct relationship beat scale.`,{paddingTop:16}),F(`Continue reading →`,{color:`{colors.primary}`,fontWeight:`bold`,paddingTop:4,paddingBottom:24,link:`#`})])},{type:`content.article_summary`,category:`content`,name:`Article Summary Card`,description:`Compact link-out card: image on top, category label, title, one-line summary, and 'Read more'. Use repeatedly to list secondary articles.`,tags:[`article`,`summary`,`card`,`link-out`,`newsletter`],create:()=>B(`content.article_summary`,`Article Card`,[I(W(560,280,`Article`),`Article`,{width:560}),F(`CULTURE`,{color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,paddingTop:12,paddingBottom:4}),V(`How long-form writing made a comeback`,{paddingTop:0,paddingBottom:4}),F(`Why subscribers are paying for slower, deeper coverage — and what it means for publishers.`,{paddingBottom:8}),F(`Read more →`,{color:`{colors.primary}`,fontWeight:`bold`,paddingBottom:24,link:`#`})])},{type:`content.image_text`,category:`content`,name:`Image + Text Beside`,description:`Image with article title and short summary stacked below. Standard editorial card.`,tags:[`image`,`text`,`article`,`stacked`],create:()=>B(`content.image_text`,`Image + Text`,[I(W(560,300,`Article`),`Article`,{width:560}),V(`Article title`,{paddingTop:16,paddingBottom:4}),F(`A short summary of the article goes here, two or three lines is plenty.`)])},{type:`content.two_column_articles`,category:`content`,name:`Two Column Stories`,description:`Two short article previews shown side-by-side as stacked blocks (renders as full-width on mobile). Use to tease two related stories.`,tags:[`two-column`,`articles`,`side-by-side`,`preview`],create:()=>B(`content.two_column_articles`,`Two Stories`,[H(`More to read`),I(W(272,180,`Story A`),`Story A`,{width:272}),F(`Story A title`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),F(`One sentence about story A.`,{fontSize:14,paddingBottom:16}),I(W(272,180,`Story B`),`Story B`,{width:272}),F(`Story B title`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),F(`One sentence about story B.`,{fontSize:14,paddingBottom:16})])},{type:`content.three_picks`,category:`content`,name:`Three Picks (Numbered)`,description:`Numbered list of three short recommendations or links. Used by curators ('3 things to read this week').`,tags:[`list`,`picks`,`curated`,`links`,`recommendations`],create:()=>B(`content.three_picks`,`Three Picks`,[H(`Three picks`),F(`01 / How to stay focused in 2026`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),U(`Notes on attention, deep work, and the slow internet.`,{fontSize:14}),z({paddingTop:12,paddingBottom:8}),F(`02 / The case for boring software`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),U(`Why teams are returning to simpler, predictable tools.`,{fontSize:14}),z({paddingTop:12,paddingBottom:8}),F(`03 / A short history of the inbox`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),U(`From memos to MIME, and what comes next.`,{fontSize:14,paddingBottom:24})])},{type:`content.quote`,category:`content`,name:`Pull Quote`,description:`Centered serif pull quote with attribution. Adds rhythm to long editorial newsletters.`,tags:[`quote`,`pull-quote`,`editorial`,`attribution`],create:()=>B(`content.quote`,`Pull Quote`,[F(`“The best way to predict the future is to create it.”`,{fontFamily:`{fonts.heading}`,fontSize:22,align:`center`,paddingTop:24,lineHeight:1.4}),F(`— Peter Drucker`,{color:`{colors.muted}`,align:`center`,paddingBottom:24})])},{type:`content.author_byline`,category:`content`,name:`Author Byline`,description:`Round avatar + author name + role on one line. Drop above or below an article body for personal newsletters.`,tags:[`author`,`byline`,`avatar`,`personal`],create:()=>B(`content.author_byline`,`Byline`,[I(W(64,64,`👤`),`Author`,{width:64,borderRadius:32,paddingTop:16,paddingBottom:0}),F(`Jane Doe`,{align:`center`,fontWeight:`bold`,paddingTop:8,paddingBottom:0}),U(`Editor, The Weekly`,{align:`center`,fontSize:13}),R(16)])},{type:`content.editor_note`,category:`content`,name:`Editor's Note`,description:`Personal letter-style block: 'Hi {{first_name}}', a few paragraphs and a sign-off. Ideal for newsletters with a strong author voice.`,tags:[`editor`,`note`,`letter`,`personal`,`voice`],create:()=>B(`content.editor_note`,`Editor's Note`,[F(`Hi {{first_name}},`,{paddingTop:24,paddingBottom:8}),F(`This week I've been thinking about what makes a newsletter feel like a letter rather than a broadcast. Spoiler: it's not the format, it's the tone.`,{paddingBottom:8,lineHeight:1.7}),F(`Let me know what you think — just hit reply.`,{paddingBottom:8,lineHeight:1.7}),F(`— Jane`,{fontFamily:`{fonts.heading}`,paddingBottom:24})])},{type:`content.tip_box`,category:`content`,name:`Tip / Callout Box`,description:`Highlighted background box with an icon, short title and one-paragraph tip. Use for 'pro tips', notes, and warnings.`,tags:[`tip`,`callout`,`box`,`highlight`,`note`],create:()=>B(`content.tip_box`,`Tip Box`,[F(`💡 PRO TIP`,{color:`{colors.primary}`,fontSize:12,fontWeight:`bold`,letterSpacing:2,paddingTop:16,paddingBottom:4}),F(`Always preview your email on mobile before sending — most opens happen there.`,{paddingBottom:16})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16})},{type:`content.numbered_list`,category:`content`,name:`Numbered List`,description:`Vertical numbered list of 4-5 short items with optional sub-text. Use for tutorials, checklists and 'how-to' newsletters.`,tags:[`list`,`numbered`,`tutorial`,`checklist`,`how-to`],create:()=>B(`content.numbered_list`,`Numbered List`,[V(`How to do it in 4 steps`,{paddingTop:16,paddingBottom:12}),F(`1. Define the goal`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),U(`Write down the outcome in one sentence.`),F(`2. List constraints`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`Time, budget, scope. Be specific.`),F(`3. Plan the smallest version`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`What can you ship this week?`),F(`4. Ship it`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`Refine after real feedback.`,{fontSize:14}),R(16)])},{type:`content.bullet_list`,category:`content`,name:`Bullet List`,description:`Simple unordered list of takeaways or facts. Concise summary block.`,tags:[`list`,`bullets`,`takeaways`,`summary`],create:()=>B(`content.bullet_list`,`Bullets`,[V(`Key takeaways`,{paddingTop:16,paddingBottom:8}),F(`• Newsletters are growing 20% YoY`,{paddingTop:2,paddingBottom:2}),F(`• Mobile opens crossed 70%`,{paddingTop:2,paddingBottom:2}),F(`• Plain-text emails outperform image-heavy ones in B2B`,{paddingTop:2,paddingBottom:2}),F(`• Personalization drives 2x click-through`,{paddingTop:2,paddingBottom:16})])},{type:`content.qa`,category:`content`,name:`Q&A Block`,description:`Question in bold followed by an answer paragraph. Use for FAQ, reader mailbags, or AMAs.`,tags:[`qa`,`faq`,`ama`,`mailbag`,`reader-questions`],create:()=>B(`content.qa`,`Q&A`,[H(`Reader question`),F(`Q: How do I get my first 100 subscribers?`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:4,paddingBottom:8,lineHeight:1.3}),F(`A: Tell ten people who already know you. Then ask each of them to forward to one friend. The first 100 don't come from algorithms — they come from your network.`,{paddingBottom:24,lineHeight:1.7})])},{type:`content.stats_row`,category:`content`,name:`Stat Row`,description:`Big numbers with short labels (e.g. '12k readers · 4.8★ rating · 96% open rate'). Used for impact summaries and social proof.`,tags:[`stats`,`numbers`,`metrics`,`social-proof`],create:()=>B(`content.stats_row`,`Stat Row`,[H(`By the numbers`,{align:`center`}),F(`12,400`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,color:`{colors.primary}`,paddingTop:4,paddingBottom:0}),U(`active readers this month`,{align:`center`,fontSize:13}),R(8),F(`96% · 4.8★ · 32 issues shipped`,{align:`center`,color:`{colors.text}`,fontSize:14,paddingBottom:24})])},{type:`content.timeline`,category:`content`,name:`Timeline / What Happened`,description:`Chronological list of recent events with dates. Used by news roundups and changelog newsletters.`,tags:[`timeline`,`changelog`,`news`,`events`,`what-happened`],create:()=>B(`content.timeline`,`Timeline`,[H(`This week`),F(`Mon · Acme launches plan B`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`After 6 months of beta testing.`,{fontSize:14}),F(`Wed · New funding round announced`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`$24M Series A led by Foundry.`,{fontSize:14}),F(`Fri · Industry report drops`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),U(`Open rates up across the board.`,{fontSize:14,paddingBottom:24})])},{type:`content.podcast_episode`,category:`content`,name:`Podcast Episode`,description:`Episode artwork, episode number, title, short description and a 'Listen' button. For shows that announce episodes by email.`,tags:[`podcast`,`episode`,`audio`,`listen`,`show`],create:()=>B(`content.podcast_episode`,`Podcast Episode`,[I(W(220,220,`Cover`),`Cover`,{width:220,borderRadius:12}),F(`EPISODE 042`,{color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,align:`center`,paddingTop:12,paddingBottom:4}),V(`Why publishers are betting on email`,{align:`center`,paddingTop:0,paddingBottom:4}),U(`With Jane Doe · 38 min`,{align:`center`,fontSize:13}),L(`Listen now`,`https://example.com`),R(16)])},{type:`content.video_thumbnail`,category:`content`,name:`Video Thumbnail`,description:`Video thumbnail with overlay-feeling play button (image only, links to a hosted player). Title and duration below.`,tags:[`video`,`thumbnail`,`watch`,`play`,`media`],create:()=>B(`content.video_thumbnail`,`Video`,[I(W(560,315,`▶ Watch`),`Video`,{width:560,link:`#`,borderRadius:8}),V(`Watch: a guided tour of our 2026 launches`,{paddingTop:12,paddingBottom:4}),U(`4 min watch`,{fontSize:13,paddingBottom:16})])},{type:`content.event_card`,category:`content`,name:`Event Card`,description:`Date badge with event title, location, time and an RSVP button. For event-driven newsletters and community digests.`,tags:[`event`,`rsvp`,`community`,`date`,`card`],create:()=>B(`content.event_card`,`Event`,[F(`MAY`,{align:`center`,color:`{colors.buttonText}`,fontSize:12,fontWeight:`bold`,letterSpacing:2,paddingTop:12,paddingBottom:0}),F(`12`,{align:`center`,color:`{colors.buttonText}`,fontSize:36,fontWeight:`bold`,paddingTop:0,paddingBottom:12})],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`content.code_block`,category:`content`,name:`Code Snippet`,description:`Monospaced code block on a tinted background. For developer newsletters and changelog excerpts.`,tags:[`code`,`snippet`,`developer`,`monospace`,`changelog`],create:()=>B(`content.code_block`,`Code`,[F(`npm install @one-million-lines/email-builder`,{fontFamily:`Menlo, Consolas, monospace`,fontSize:13,color:`{colors.text}`,paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16})}],Bo=[{type:`feature.list`,category:`feature`,name:`Checkmark Feature List`,description:`Centered title with 3-4 short checkmarked benefits. Good for product newsletters and onboarding emails.`,tags:[`features`,`benefits`,`checkmarks`,`list`],create:()=>B(`feature.list`,`Feature List`,[V(`Why people love it`,{align:`center`,paddingTop:24}),F(`✓ Fast and reliable`,{align:`center`}),F(`✓ Beautiful out of the box`,{align:`center`}),F(`✓ Backed by humans, not bots`,{align:`center`,paddingBottom:24})])},{type:`feature.icon_three`,category:`feature`,name:`Three Icon Features`,description:`Three stacked feature blocks with an emoji/icon, short title and one-line description. Use to highlight 3 product capabilities.`,tags:[`features`,`icons`,`three-up`,`product`],create:()=>B(`feature.icon_three`,`Three Features`,[F(`⚡`,{align:`center`,fontSize:32,paddingTop:24,paddingBottom:4}),F(`Fast`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),U(`Built to render in milliseconds.`,{align:`center`,fontSize:14}),R(16),F(`🧩`,{align:`center`,fontSize:32,paddingBottom:4}),F(`Modular`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),U(`Compose any layout from blocks.`,{align:`center`,fontSize:14}),R(16),F(`🤖`,{align:`center`,fontSize:32,paddingBottom:4}),F(`AI-ready`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),U(`Edit emails as JSON, not HTML.`,{align:`center`,fontSize:14,paddingBottom:24})])},{type:`feature.before_after`,category:`feature`,name:`Before / After`,description:`Two stacked images labeled 'Before' and 'After'. For product transformations, redesigns and case studies.`,tags:[`before-after`,`comparison`,`case-study`,`transformation`],create:()=>B(`feature.before_after`,`Before / After`,[H(`Before`),I(W(560,280,`Before`),`Before`,{width:560}),R(8),H(`After`),I(W(560,280,`After`),`After`,{width:560}),R(16)])},{type:`feature.benefit_pair`,category:`feature`,name:`Image + Benefit Pair`,description:`Repeat-use block: one supporting image plus a title and benefit paragraph beside it. Stack 2-3 of these for a feature tour.`,tags:[`benefit`,`feature`,`image-text`,`pair`],create:()=>B(`feature.benefit_pair`,`Benefit Pair`,[I(W(560,240,`Feature`),`Feature`,{width:560,paddingTop:16}),V(`Send 10x faster`,{paddingTop:12,paddingBottom:4}),F(`Reusable modules and theme tokens let teams ship campaigns in minutes, not days.`,{paddingBottom:24})])},{type:`feature.testimonial`,category:`feature`,name:`Testimonial`,description:`Customer quote in large type with avatar and attribution. Social proof block.`,tags:[`testimonial`,`review`,`social-proof`,`customer`],create:()=>B(`feature.testimonial`,`Testimonial`,[F(`“This cut our email production from a week to an afternoon.”`,{fontFamily:`{fonts.heading}`,fontSize:22,align:`center`,paddingTop:24,paddingBottom:12,lineHeight:1.4}),I(W(56,56,`👤`),`Customer`,{width:56,borderRadius:28}),F(`Alex Kim · Head of Lifecycle, Acme`,{align:`center`,color:`{colors.muted}`,fontSize:13,paddingTop:4,paddingBottom:24})])},{type:`feature.logo_strip`,category:`feature`,name:`Customer Logo Strip`,description:`Small horizontal row implying customer logos for credibility ('Trusted by'). Logos shown as a placeholder image.`,tags:[`logos`,`trusted-by`,`social-proof`,`strip`],create:()=>B(`feature.logo_strip`,`Logo Strip`,[U(`TRUSTED BY`,{align:`center`,fontSize:11}),I(W(520,60,`LOGOS`),`Customer logos`,{width:520,paddingTop:8,paddingBottom:16})])},{type:`feature.gradient_hero`,category:`feature`,name:`Gradient Hero CTA`,description:`Bold centered hero with an eyebrow, oversized headline and a primary CTA button. Great for launch announcements and campaign openers.`,tags:[`hero`,`launch`,`cta`,`bold`,`announcement`],create:()=>B(`feature.gradient_hero`,`Gradient Hero CTA`,[H(`Introducing`,{align:`center`}),V(`Something new is here`,{level:1,align:`center`,paddingTop:4,paddingBottom:8}),F(`A fresh way to reach your audience — crafted for the inbox.`,{align:`center`,color:`{colors.muted}`,fontSize:16,paddingBottom:20}),L(`Explore now`,`#`,{align:`center`})],{backgroundColor:`{colors.surface}`,paddingTop:40,paddingBottom:40})},{type:`feature.pull_quote`,category:`feature`,name:`Pull Quote`,description:`Large centered quotation with an attribution line. Use to highlight a testimonial or a memorable line.`,tags:[`quote`,`testimonial`,`highlight`,`pull-quote`],create:()=>B(`feature.pull_quote`,`Pull Quote`,[F(`“This is the fastest we’ve ever shipped a campaign.”`,{fontFamily:`{fonts.heading}`,fontSize:24,align:`center`,lineHeight:1.4,paddingTop:28,paddingBottom:8}),U(`— A very happy customer`,{align:`center`,paddingBottom:28})])},{type:`feature.stat_row`,category:`feature`,name:`Stat Row`,description:`Three short number + label pairs in a row. Use to show traction, metrics or highlights.`,tags:[`stats`,`metrics`,`numbers`,`row`,`kpi`],create:()=>B(`feature.stat_row`,`Stat Row`,[V(`By the numbers`,{align:`center`,paddingTop:24}),F(`<b>10k+</b> subscribers · <b>98%</b> delivery · <b>4.9★</b> rating`,{align:`center`,color:`{colors.muted}`,paddingBottom:24})])},{type:`feature.single_product_spotlight`,category:`feature`,name:`Single Product Spotlight`,description:`One product with image, name, price and buy button. Use to feature a hero product in a feature-focused email.`,tags:[`product`,`spotlight`,`single`,`buy`,`shop`,`ecommerce`],create:()=>B(`feature.single_product_spotlight`,`Product Spotlight`,[Se([G({name:`The Signature Bag`,finalPrice:`$129`,oldPrice:`$159`,description:`Handmade, built to last.`,image:W(520,520,`Product`)})],{columns:1,showDescription:!0,buttonLabel:`Buy now`})])},{type:`feature.pill_nav`,category:`feature`,name:`Pill Navigation`,description:`Centered row of navigation links with a divider below. Compact feature nav block for use inside email content sections.`,tags:[`menu`,`nav`,`links`,`pill`],create:()=>B(`feature.pill_nav`,`Pill Navigation`,[I(W(120,32,`LOGO`),`Logo`,{width:120,paddingBottom:8}),F(`<a href="#">Shop</a> <a href="#">New</a> <a href="#">Sale</a> <a href="#">About</a>`,{align:`center`,color:`{colors.primary}`,paddingBottom:8}),z({paddingTop:4,paddingBottom:0})])}],Vo=[{type:`cta.simple`,category:`call_to_action`,name:`Simple CTA`,description:`Centered headline + body + primary button. The default call-to-action block for any newsletter or promo.`,tags:[`cta`,`primary`,`centered`,`button`],create:()=>B(`cta.simple`,`Simple CTA`,[V(`Ready to get started?`,{align:`center`,paddingTop:24}),U(`Create better emails faster.`,{align:`center`}),L(`Start now`,`https://example.com`),R(16)])},{type:`cta.banner`,category:`call_to_action`,name:`Colored Banner CTA`,description:`Full-width colored band with eyebrow, big headline and a contrasting button. Use to draw attention to sales or launches.`,tags:[`cta`,`banner`,`colored`,`promo`,`sale`],create:()=>B(`cta.banner`,`CTA Banner`,[F(`Limited time offer`,{color:`{colors.buttonText}`,align:`center`,fontSize:14,paddingTop:24,paddingBottom:4}),F(`Save 30% this week only`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingBottom:16}),L(`Shop the sale`),R(24)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`cta.button_only`,category:`call_to_action`,name:`Button Only`,description:`Single primary button on a clean background. Use as a follow-up CTA after a content block.`,tags:[`cta`,`button`,`minimal`],create:()=>B(`cta.button_only`,`Button`,[L(`Click here`,`https://example.com`)])},{type:`cta.dual_button`,category:`call_to_action`,name:`Two Button Choice`,description:`Two side-by-side actions: a primary and a ghost-styled secondary. Use when offering 'Learn more' vs 'Get started'.`,tags:[`cta`,`buttons`,`two-options`,`choice`],create:()=>B(`cta.dual_button`,`Two Buttons`,[V(`Pick your path`,{align:`center`,paddingTop:24}),U(`Choose what fits your team.`,{align:`center`}),L(`Get started`,`https://example.com`),L(`Learn more`,`https://example.com`,{backgroundColor:`transparent`,color:`{colors.primary}`}),R(16)])},{type:`cta.image_overlay`,category:`call_to_action`,name:`Image + Overlay CTA`,description:`Lead image with a headline, supporting text, and a button immediately below. Strong visual call to action.`,tags:[`cta`,`image`,`visual`,`hero`],create:()=>B(`cta.image_overlay`,`Image CTA`,[I(W(560,280,`Visual`),`Visual`,{width:560,paddingTop:16}),V(`Stop guessing. Start measuring.`,{align:`center`,paddingTop:16}),U(`Free for 14 days. No credit card.`,{align:`center`}),L(`Try it free`),R(16)])},{type:`cta.subscribe`,category:`call_to_action`,name:`Subscribe / Forward`,description:`Friendly 'Was this forwarded? Subscribe' block that grows the list virally. Common at the end of newsletters.`,tags:[`cta`,`subscribe`,`forward`,`growth`,`newsletter`],create:()=>B(`cta.subscribe`,`Subscribe`,[H(`Was this forwarded?`,{align:`center`}),V(`Get the next issue in your inbox`,{align:`center`,paddingTop:0,paddingBottom:8}),L(`Subscribe free`),R(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})},{type:`cta.referral`,category:`call_to_action`,name:`Referral / Share`,description:`Encourages readers to share the newsletter with a unique referral link. Includes a 'Share' button and a personalized URL.`,tags:[`cta`,`referral`,`share`,`viral`,`growth`],create:()=>B(`cta.referral`,`Referral`,[H(`Tell a friend`,{align:`center`}),V(`Share & earn perks`,{align:`center`,paddingTop:0,paddingBottom:8}),U(`Refer 3 friends and unlock the bonus issue.`,{align:`center`}),F(`yourname.com/r/abc123`,{align:`center`,color:`{colors.primary}`,fontFamily:`Menlo, Consolas, monospace`,fontSize:14,paddingTop:8,paddingBottom:8}),L(`Share now`),R(16)])},{type:`cta.upgrade`,category:`call_to_action`,name:`Upgrade / Paid`,description:`Conversion block that promotes a paid plan or premium tier. Includes price, benefits and an upgrade button.`,tags:[`cta`,`upgrade`,`paid`,`premium`,`conversion`],create:()=>B(`cta.upgrade`,`Upgrade`,[H(`Become a member`,{align:`center`}),V(`$5 / month`,{align:`center`,level:1}),U(`Unlock the archive, weekly bonus and member chat.`,{align:`center`,fontSize:14}),L(`Upgrade`),R(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})},{type:`cta.feedback`,category:`call_to_action`,name:`Feedback Reply`,description:`Asks the reader to reply with feedback ('Hit reply and let me know'). Personal, no button.`,tags:[`cta`,`feedback`,`reply`,`personal`],create:()=>B(`cta.feedback`,`Feedback`,[F(`How did this issue land for you? Just hit reply — I read every message.`,{align:`center`,paddingTop:24,paddingBottom:24,lineHeight:1.6})])}],Ho=[{type:`ecom.product_single`,category:`ecommerce`,name:`Single Product`,description:`One product with image, title, price, short description and Buy button. Use to feature a hero product. Supports old/final price and per-product link.`,tags:[`product`,`single`,`buy`,`hero`],create:()=>B(`ecom.product_single`,`Single Product`,[Se([G({name:`Linen Tote Bag`,image:W(560,400,`Product`),oldPrice:`$59.00`,finalPrice:`$39.00`,description:`Heavyweight natural linen, made in Portugal.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`Buy now`})])},{type:`ecom.product_grid_2`,category:`ecommerce`,name:`Product Grid (2 up)`,description:`Two products side-by-side on desktop, stacked on mobile. Each card has image, name, old/final price, optional description and Shop button. Curated picks layout.`,tags:[`product`,`grid`,`two-up`,`curated`,`responsive`],create:()=>B(`ecom.product_grid_2`,`Product Grid 2`,[Se([G({name:`Product A`,finalPrice:`$29`,oldPrice:`$39`}),G({name:`Product B`,finalPrice:`$34`,oldPrice:`$45`})],{columns:2,showOldPrice:!0})])},{type:`ecom.product_grid_3`,category:`ecommerce`,name:`Product Grid (3 up)`,description:`Three product cards in a row on desktop, stacked on mobile. Use for 'New arrivals' or 'Bestsellers' rows.`,tags:[`product`,`grid`,`three-up`,`bestsellers`,`new-arrivals`,`responsive`],create:()=>B(`ecom.product_grid_3`,`Product Grid 3`,[H(`New arrivals`,{align:`center`}),Se([G({name:`Product 1`,finalPrice:`$19`}),G({name:`Product 2`,finalPrice:`$24`}),G({name:`Product 3`,finalPrice:`$32`})],{columns:3,showOldPrice:!1})])},{type:`ecom.collection_banner`,category:`ecommerce`,name:`Collection Banner`,description:`Wide collection banner with title and 'Shop the collection' button overlaying or under an image. Use for category drops.`,tags:[`collection`,`banner`,`category`,`drop`],create:()=>B(`ecom.collection_banner`,`Collection`,[I(W(560,300,`Collection`),`Collection`,{width:560}),V(`Spring Collection 2026`,{align:`center`,paddingTop:16}),U(`Lighter fabrics, brighter colors.`,{align:`center`}),L(`Shop the collection`),R(16)])},{type:`ecom.discount`,category:`ecommerce`,name:`Discount Code`,description:`Big discount code in monospaced caps with 'Your code' label and a Redeem button.`,tags:[`discount`,`promo`,`code`,`coupon`],create:()=>B(`ecom.discount`,`Discount Code`,[U(`Your code`,{align:`center`}),F(`SAVE20`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,color:`{colors.primary}`,letterSpacing:4,paddingTop:4,paddingBottom:16}),L(`Redeem`),R(24)])},{type:`ecom.voucher`,category:`ecommerce`,name:`Voucher Code`,description:`Personalized voucher block: 'Your code' label, a large voucher code and a Redeem button. With the voucher-select plugin, pick a code from your backend catalog; otherwise edit the code text directly.`,tags:[`voucher`,`coupon`,`discount`,`code`,`promo`,`redeem`],create:()=>B(`ecom.voucher`,`Voucher Code`,[U(`Your code`,{align:`center`}),be(`SAVE20`),L(`Redeem`),R(24)])},{type:`ecom.flash_sale`,category:`ecommerce`,name:`Flash Sale Banner`,description:`Urgency-driven banner with countdown-style copy ('Ends in 24h'), discount value and a shop button.`,tags:[`flash-sale`,`urgency`,`promo`,`banner`,`countdown`],create:()=>B(`ecom.flash_sale`,`Flash Sale`,[F(`⏰ FLASH SALE — ENDS IN 24H`,{color:`{colors.buttonText}`,align:`center`,fontWeight:`bold`,letterSpacing:2,paddingTop:16,paddingBottom:4}),F(`Up to 50% off everything`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingBottom:12}),L(`Shop now`,`#`,{backgroundColor:`{colors.surface}`,color:`{colors.primary}`}),R(16)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`ecom.abandoned_cart`,category:`ecommerce`,name:`Abandoned Cart Reminder`,description:`Friendly reminder showing the items left in the cart with a return-to-cart button. For cart recovery automations.`,tags:[`abandoned-cart`,`recovery`,`automation`,`reminder`],create:()=>B(`ecom.abandoned_cart`,`Abandoned Cart`,[V(`You left something behind`,{align:`center`,paddingTop:16}),U(`Pick up where you left off.`,{align:`center`}),R(8),Se([G({name:`Linen Tote Bag`,image:W(400,400,`Item`),finalPrice:`$39`,oldPrice:`$49`})],{columns:1,showOldPrice:!0,buttonLabel:`Return to cart`})])},{type:`ecom.review_request`,category:`ecommerce`,name:`Review Request`,description:`Post-purchase block asking for a 1-5 star rating with stacked star buttons. For review-collection emails.`,tags:[`review`,`rating`,`post-purchase`,`feedback`],create:()=>B(`ecom.review_request`,`Review`,[V(`How did we do?`,{align:`center`,paddingTop:24}),U(`Tap a star to leave a quick review.`,{align:`center`}),F(`☆ ☆ ☆ ☆ ☆`,{align:`center`,fontSize:32,color:`{colors.primary}`,paddingTop:12,paddingBottom:24,link:`#`})])},{type:`ecom.gift_guide`,category:`ecommerce`,name:`Gift Guide Pick`,description:`Editorial gift-guide pick: persona eyebrow + a single product card with full details (image, name, old/final price, description, CTA).`,tags:[`gift-guide`,`curated`,`editorial`,`holiday`],create:()=>B(`ecom.gift_guide`,`Gift Pick`,[H(`For the home cook`),Se([G({name:`Cast Iron Skillet`,image:W(560,300,`Pick`),oldPrice:`$119`,finalPrice:`$89`,description:`Pre-seasoned, lifetime-guarantee. Made in USA.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`View product`})])},{type:`ecom.bestseller_list`,category:`ecommerce`,name:`Bestseller Grid`,description:`Top products grid (3 up) with old/final prices. Used by retailers for weekly bestsellers.`,tags:[`bestsellers`,`grid`,`ranking`,`top`],create:()=>B(`ecom.bestseller_list`,`Bestsellers`,[H(`Top 3 this week`),Se([G({name:`Linen Tote`,finalPrice:`$39`,oldPrice:`$49`}),G({name:`Ceramic Mug`,finalPrice:`$24`}),G({name:`Brass Lamp`,finalPrice:`$129`,oldPrice:`$149`})],{columns:3,showOldPrice:!0})])}],Uo=[{type:`tx.order_summary`,category:`transactional`,name:`Order Summary`,description:`Order confirmation summary: order number, line items with thumbnails and totals row. Used in post-purchase emails.`,tags:[`order`,`summary`,`receipt`,`post-purchase`,`ecommerce`],create:()=>B(`tx.order_summary`,`Order Summary`,[H(`Order #1024`),V(`Thanks for your order`,{paddingTop:0}),U(`We'll email you again when it ships.`),z({paddingTop:16,paddingBottom:8}),F(`Linen Tote Bag · 1 × $39.00`,{paddingTop:4,paddingBottom:4}),F(`Ceramic Mug · 2 × $24.00`,{paddingTop:4,paddingBottom:4}),z({paddingTop:8,paddingBottom:8}),F(`Subtotal: $87.00`,{paddingTop:2,paddingBottom:2}),F(`Shipping: $5.00`,{paddingTop:2,paddingBottom:2}),F(`Total: $92.00`,{fontWeight:`bold`,paddingTop:2,paddingBottom:16})])},{type:`tx.shipping_update`,category:`transactional`,name:`Shipping Update`,description:`Shipping confirmation with tracking number, carrier, expected delivery date and a Track button.`,tags:[`shipping`,`tracking`,`delivery`,`post-purchase`],create:()=>B(`tx.shipping_update`,`Shipping Update`,[F(`📦`,{align:`center`,fontSize:40,paddingTop:24}),V(`Your order is on the way`,{align:`center`,paddingTop:8}),U(`Carrier: USPS · Expected: May 4, 2026`,{align:`center`}),F(`Tracking: 9400 1108 ...`,{align:`center`,color:`{colors.muted}`,fontFamily:`Menlo, Consolas, monospace`,fontSize:13}),L(`Track package`),R(16)])},{type:`tx.invoice`,category:`transactional`,name:`Invoice`,description:`Itemized invoice with billing period, services and totals. Used by SaaS and B2B billing emails.`,tags:[`invoice`,`billing`,`saas`,`b2b`,`receipt`],create:()=>B(`tx.invoice`,`Invoice`,[H(`Invoice INV-2026-04`),V(`April 2026 invoice`),U(`Billed to: Acme Inc · Period: Apr 1 – Apr 30`),z({paddingTop:16,paddingBottom:8}),F(`Pro plan · $49.00`,{paddingTop:4,paddingBottom:4}),F(`Add-on seats (3) · $36.00`,{paddingTop:4,paddingBottom:4}),z({paddingTop:8,paddingBottom:8}),F(`Total due: $85.00`,{fontWeight:`bold`,paddingBottom:16}),L(`Download invoice (PDF)`),R(16)])},{type:`tx.password_reset`,category:`transactional`,name:`Password Reset`,description:`Authentication email with a reset button and a fallback link. Includes 'expires in X minutes' notice.`,tags:[`auth`,`password`,`reset`,`security`],create:()=>B(`tx.password_reset`,`Password Reset`,[V(`Reset your password`,{align:`center`,paddingTop:16}),F(`Click the button below to set a new password. This link expires in 30 minutes.`,{align:`center`,paddingBottom:16}),L(`Reset password`),U(`If the button doesn't work, paste this link in your browser:`,{align:`center`,fontSize:12}),F(`https://example.com/reset/abc123`,{align:`center`,color:`{colors.primary}`,fontSize:12,paddingBottom:24})])},{type:`tx.verify_email`,category:`transactional`,name:`Verify Email`,description:`Single-purpose 'verify your email' transactional with one centered button.`,tags:[`auth`,`verify`,`email-confirmation`],create:()=>B(`tx.verify_email`,`Verify Email`,[V(`One last step`,{align:`center`,paddingTop:16}),F(`Confirm your email address to activate your account.`,{align:`center`,paddingBottom:8}),L(`Verify email`),R(24)])},{type:`tx.appointment`,category:`transactional`,name:`Appointment Confirmation`,description:`Booking/meeting confirmation with date, time, location and add-to-calendar links.`,tags:[`appointment`,`booking`,`calendar`,`meeting`],create:()=>B(`tx.appointment`,`Appointment`,[H(`Confirmed`,{align:`center`}),V(`Your appointment is set`,{align:`center`,paddingTop:0}),F(`Tuesday, May 12 · 10:00 AM`,{align:`center`,fontWeight:`bold`,paddingTop:8}),U(`123 Main St, Suite 4 · Brooklyn, NY`,{align:`center`}),L(`Add to calendar`),R(16)])}],Wo=[{type:`social.icons`,category:`social`,name:`Social Icons Row`,description:`Centered 'Follow us' label with text-link icons in a row. Light footer-style social block.`,tags:[`social`,`follow`,`icons`,`row`],create:()=>B(`social.icons`,`Social Icons`,[U(`Follow us`,{align:`center`}),F(`Twitter · Instagram · LinkedIn · YouTube`,{align:`center`,color:`{colors.primary}`,paddingBottom:16})])},{type:`social.share`,category:`social`,name:`Share This Email`,description:`'Share this email' bar with Forward · Tweet · Share text links. Used at the end of newsletters.`,tags:[`social`,`share`,`forward`,`viral`],create:()=>B(`social.share`,`Share Bar`,[F(`Share this email`,{align:`center`,paddingTop:8}),F(`Forward · Tweet · Share`,{align:`center`,color:`{colors.primary}`,paddingBottom:8})])},{type:`social.featured_post`,category:`social`,name:`Featured Social Post`,description:`Embed-style preview of a single social post: avatar, name, post text and a link to view it on the platform.`,tags:[`social`,`post`,`embed`,`twitter`,`instagram`],create:()=>B(`social.featured_post`,`Social Post`,[H(`From the community`),I(W(48,48,`👤`),`Avatar`,{width:48,borderRadius:24}),F(`@maker · 2h`,{color:`{colors.muted}`,fontSize:13,paddingTop:4,paddingBottom:4}),F(`"Just shipped my newsletter using OpenPostcards. Honestly the smoothest email build I've ever done."`,{paddingBottom:8,lineHeight:1.6}),F(`View on Twitter →`,{color:`{colors.primary}`,paddingBottom:16,link:`#`})])},{type:`social.instagram_grid`,category:`social`,name:`Instagram Grid`,description:`3 small square thumbnails in a row representing recent Instagram posts, with handle and link.`,tags:[`social`,`instagram`,`grid`,`thumbnails`],create:()=>B(`social.instagram_grid`,`IG Grid`,[U(`@youraccount on Instagram`,{align:`center`}),I(W(180,180,`1`),`Post 1`,{width:180}),I(W(180,180,`2`),`Post 2`,{width:180}),I(W(180,180,`3`),`Post 3`,{width:180}),F(`View profile →`,{align:`center`,color:`{colors.primary}`,paddingTop:8,paddingBottom:16,link:`#`})])},{type:`social.community_stats`,category:`social`,name:`Community Stats`,description:`Short '12k Twitter · 4k IG · 2k YT' style row used to show following sizes.`,tags:[`social`,`stats`,`community`,`following`],create:()=>B(`social.community_stats`,`Community Stats`,[H(`Join the community`,{align:`center`}),F(`12k Twitter · 4k Instagram · 2k YouTube`,{align:`center`,paddingBottom:16}),R(8)])}],Go={backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0},Ko=[{type:`footer.simple`,category:`footer`,name:`Simple Footer`,description:`Minimal footer with copyright, address and unsubscribe links. The default for any newsletter.`,tags:[`footer`,`simple`,`copyright`,`unsubscribe`],create:()=>B(`footer.simple`,`Simple Footer`,[U(`© 2026 Your Company. All rights reserved.`,{align:`center`,fontSize:12}),U(`123 Main St · City · Country`,{align:`center`,fontSize:12}),Ce([{label:`Unsubscribe`,type:`unsubscribe`},{label:`View in browser`,type:`view_in_browser`}])],{...Go,paddingTop:24})},{type:`footer.social`,category:`footer`,name:`Footer with Social`,description:`Footer with social links row above the legal text.`,tags:[`footer`,`social`,`links`],create:()=>B(`footer.social`,`Social Footer`,[F(`Follow us`,{align:`center`,paddingTop:24}),F(`Twitter · Instagram · LinkedIn`,{align:`center`,color:`{colors.primary}`,paddingBottom:12}),z(),U(`© 2026 Your Company`,{align:`center`,fontSize:12}),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Go)},{type:`footer.legal`,category:`footer`,name:`Legal Footer`,description:`Long-form footer with explanation of why the user is receiving the email plus privacy/terms/unsubscribe links. Used by enterprise and finance newsletters.`,tags:[`footer`,`legal`,`compliance`,`enterprise`],create:()=>B(`footer.legal`,`Legal Footer`,[F(`You are receiving this email because you signed up for our newsletter. If you no longer wish to receive emails, you can unsubscribe at any time.`,{align:`center`,color:`{colors.muted}`,fontSize:11,lineHeight:1.6,paddingTop:24}),Ce([{label:`Privacy Policy`,type:`user_profile`},{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Go)},{type:`footer.publisher`,category:`footer`,name:`Publisher Footer`,description:`Magazine-style sign-off with logo, publication name, masthead credits, address and links.`,tags:[`footer`,`publisher`,`magazine`,`masthead`,`editorial`],create:()=>B(`footer.publisher`,`Publisher Footer`,[I(W(120,36,`LOGO`),`Logo`,{width:120,paddingTop:24,paddingBottom:8}),F(`THE WEEKLY`,{align:`center`,fontFamily:`{fonts.heading}`,fontWeight:`bold`,letterSpacing:4,paddingTop:0,paddingBottom:4}),U(`Editor: Jane Doe · Producer: Alex Kim`,{align:`center`,fontSize:12}),z({paddingTop:12,paddingBottom:12}),U(`© 2026 The Weekly · 350 Madison Ave · NY 10017`,{align:`center`,fontSize:11}),Ce([{label:`Manage preferences`,type:`manage_preferences`},{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Go)},{type:`footer.app_links`,category:`footer`,name:`Footer with App Store Badges`,description:`Footer including 'Get the app' app-store and play-store badge images. For consumer brand newsletters.`,tags:[`footer`,`app`,`download`,`ios`,`android`],create:()=>B(`footer.app_links`,`App Footer`,[F(`Get the app`,{align:`center`,fontWeight:`bold`,paddingTop:24,paddingBottom:8}),I(W(135,40,`App Store`),`App Store`,{width:135,align:`center`,paddingTop:0,paddingBottom:4}),I(W(135,40,`Google Play`),`Google Play`,{width:135,align:`center`,paddingTop:0,paddingBottom:16}),z(),U(`© 2026 Your Brand`,{align:`center`,fontSize:11}),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],Go)},{type:`footer.address_only`,category:`footer`,name:`Address Only`,description:`Just a centered postal address line — required for CAN-SPAM compliance when other footers are minimal.`,tags:[`footer`,`address`,`compliance`,`can-spam`],create:()=>B(`footer.address_only`,`Address`,[U(`Your Company · 123 Main St · Brooklyn, NY 11201 · USA`,{align:`center`,fontSize:11}),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:16})],{...Go,paddingTop:16})},{type:`footer.preferences`,category:`footer`,name:`Manage Preferences`,description:`Footer that emphasizes preference management ('Update your preferences', 'Send less often'). Reduces unsubscribes.`,tags:[`footer`,`preferences`,`frequency`,`retention`],create:()=>B(`footer.preferences`,`Preferences`,[F(`Getting too many emails?`,{align:`center`,paddingTop:24,paddingBottom:4}),Ce([{label:`Update your preferences`,type:`manage_preferences`},{label:`Unsubscribe`,type:`unsubscribe`}],{color:`{colors.primary}`,fontSize:13,paddingTop:4,paddingBottom:16}),z(),U(`© 2026 Your Company`,{align:`center`,fontSize:11}),F(` `,{align:`center`,paddingBottom:24})],Go)},{type:`footer.signature`,category:`footer`,name:`Signature Sign-off`,description:`Personal hand-signed style sign-off with author name and tiny legal block. For solo creator newsletters.`,tags:[`footer`,`signature`,`personal`,`creator`,`sign-off`],create:()=>B(`footer.signature`,`Signature`,[F(`Until next week,`,{paddingTop:24,paddingBottom:4}),F(`— Jane`,{fontFamily:`{fonts.heading}`,fontSize:22,paddingBottom:16}),z(),Ce([{label:`Unsubscribe`,type:`unsubscribe`}],{align:`left`,fontSize:11,paddingTop:4,paddingBottom:24,separator:` · `})],{...Go,paddingTop:0})}],qo=[...Io,...Lo,...Ro,...zo,...Bo,...Vo,...Ho,...Uo,...Wo,...Ko],Jo=!1;function Yo(){if(!Jo){for(let e of qo)Ie.register(e);Jo=!0}}Yo();function Xo(){let{doc:e,addModule:t,loadFromLocalStorage:n}=N();return(0,l.useEffect)(()=>{if(n(),N.getState().doc.modules.length===0){for(let e of[`header.hero`,`content.headline_body`,`cta.simple`,`footer.simple`]){let n=Ie.get(e);n&&t(n.create())}N.setState({selection:{kind:`email`},past:[],future:[]})}},[]),(0,l.useEffect)(()=>{let e=setTimeout(()=>N.getState().saveToLocalStorage(),500);return()=>clearTimeout(e)},[e]),(0,p.jsxs)(`div`,{className:`oml-email-builder h-full w-full flex flex-col bg-gray-100`,children:[(0,p.jsx)(je,{}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsx)(ot,{}),(0,p.jsx)(Xi,{}),(0,p.jsx)(so,{})]})]})}var Zo=e=>{if(e&&typeof e==`object`)return e;throw Error(`AI server returned a non-object response.`)};function Qo(e){let t=e.transformResponse??Zo,n=e.timeoutMs??6e4;return{async generate(r){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{let n=await fetch(e.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,body:JSON.stringify(r),signal:i.signal}),a=null,o=await n.text();try{a=o?JSON.parse(o):null}catch{}if(!n.ok){let e=(a&&typeof a==`object`&&`error`in a&&typeof a.error==`string`?a.error:null)??`AI request failed (HTTP ${n.status})`;throw Error(e)}return t(a)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`AI request timed out after ${n}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(a)}}}}function $o(e){let t=Qo(e);return{name:`ai-assistant`,type:`ai-provider`,setup(e){e.setAIProvider(t)}}}function es(e){if(e==null)return null;if(Array.isArray(e))return es(e[0]);if(typeof e!=`object`)return null;let t=e;for(let e of[`product`,`item`,`data`])if(t[e]&&typeof t[e]==`object`&&!Array.isArray(t[e]))return t[e];for(let e of[`results`,`products`,`items`,`hits`])if(Array.isArray(t[e]))return es(t[e]);return t}function ts(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t;if(typeof t==`number`)return String(t)}}function ns(e,t){for(let n of t){let t=e[n];if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`&&t.trim()!==``&&!Number.isNaN(Number(t)))return Number(t)}}var rs=e=>{let t=es(e);if(!t)return null;let n=ts(t,[`name`,`title`,`product_name`,`productName`]),r=ts(t,[`finalPrice`,`final_price`,`price`,`sale_price`,`salePrice`]);return!n||r==null?null:{name:n,finalPrice:r,oldPrice:ts(t,[`oldPrice`,`old_price`,`compare_at_price`,`compareAtPrice`,`list_price`,`listPrice`]),description:ts(t,[`description`,`desc`,`summary`]),link:ts(t,[`link`,`url`,`product_url`,`productUrl`,`permalink`]),image:ts(t,[`image`,`image_url`,`imageUrl`,`thumbnail`,`img`]),imageAlt:ts(t,[`imageAlt`,`image_alt`,`alt`]),stars:ns(t,[`stars`,`rating`,`review_score`,`reviewScore`,`score`]),sku:ts(t,[`sku`,`id`,`product_id`,`productId`])}};function is(e){let t=e.method??`GET`,n=e.queryParam??`q`,r=e.bodyParam??`query`,i=e.timeoutMs??15e3,a=e.transformResponse??rs;return{async search(o){let s=o.trim();if(!s)return null;let c=new AbortController,l=setTimeout(()=>c.abort(),i);try{let i=e.endpoint,o={method:t,headers:{...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,signal:c.signal};if(t===`GET`){let t=typeof location<`u`?location.href:void 0,r=new URL(e.endpoint,t);r.searchParams.set(n,s),i=r.toString()}else o.headers[`Content-Type`]=`application/json`,o.body=JSON.stringify({[r]:s});let l=await fetch(i,o),u=null,d=await l.text();try{u=d?JSON.parse(d):null}catch{}if(!l.ok){let e=(u&&typeof u==`object`&&`error`in u&&typeof u.error==`string`?u.error:null)??`Product search failed (HTTP ${l.status})`;throw Error(e)}return a(u)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`Product search timed out after ${i}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(l)}}}}function as(e){let t=is(e);return{name:`product-search`,type:`product-provider`,setup(e){e.registerProductProvider(t)}}}function os(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let t=e;for(let e of[`vouchers`,`results`,`items`,`data`,`coupons`])if(Array.isArray(t[e]))return t[e]}return[]}function ss(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t;if(typeof t==`number`)return String(t)}}var cs=e=>{let t=[];for(let n of os(e)){if(!n||typeof n!=`object`)continue;let e=n,r=ss(e,[`code`,`voucher_code`,`voucherCode`,`coupon`,`coupon_code`,`couponCode`,`value`]),i=ss(e,[`id`,`voucher_id`,`voucherId`,`uid`])??r;if(!i&&!r)continue;let a=ss(e,[`title`,`name`,`label`])??r??i??`Voucher`;t.push({id:i??a,title:a,code:r??i??a,description:ss(e,[`description`,`desc`,`summary`])})}return t};function ls(e){let t=e.method??`GET`,n=e.timeoutMs??15e3,r=e.transformResponse??cs;return{async list(){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{let n=await fetch(e.endpoint,{method:t,headers:{...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,signal:i.signal}),a=null,o=await n.text();try{a=o?JSON.parse(o):null}catch{}if(!n.ok){let e=(a&&typeof a==`object`&&`error`in a&&typeof a.error==`string`?a.error:null)??`Voucher request failed (HTTP ${n.status})`;throw Error(e)}return r(a)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`Voucher request timed out after ${n}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(a)}}}}function us(e){let t=ls(e);return{name:`voucher-select`,type:`voucher-provider`,setup(n){n.registerVoucherProvider(t),e.preload&&Ca()}}}var ds=e=>{if(e&&typeof e==`object`&&`url`in e&&typeof e.url==`string`){let t=e;return{url:t.url,alt:typeof t.alt==`string`?t.alt:void 0}}throw Error(`Server response missing "url" string field.`)};function fs(e){let t=e.fieldName??`file`,n=(e.maxSizeMB??10)*1024*1024,r=e.transformResponse??ds;return{upload(i){return i.type.startsWith(`image/`)?i.size>n?Promise.reject(Error(`File too large: ${(i.size/1024/1024).toFixed(2)} MB > ${e.maxSizeMB??10} MB`)):new Promise((n,a)=>{let o=new XMLHttpRequest,s=new FormData;if(s.append(t,i,i.name),o.open(`POST`,e.endpoint,!0),o.withCredentials=!!e.withCredentials,e.headers)for(let[t,n]of Object.entries(e.headers))o.setRequestHeader(t,n);e.onProgress&&o.upload&&(o.upload.onprogress=t=>{t.lengthComputable&&e.onProgress(Math.round(t.loaded/t.total*100))}),o.onload=()=>{let e=o.status>=200&&o.status<300,t=null;try{t=o.responseText?JSON.parse(o.responseText):null}catch{}if(!e){let e=(t&&typeof t==`object`&&`error`in t&&typeof t.error==`string`?t.error:null)??`Upload failed (HTTP ${o.status})`;return a(Error(e))}try{n(r(t))}catch(e){a(e instanceof Error?e:Error(String(e)))}},o.onerror=()=>a(Error(`Network error during upload`)),o.onabort=()=>a(Error(`Upload aborted`)),o.send(s)}):Promise.reject(Error(`Not an image: ${i.type||`unknown`}`))}}}function ps(e){return{name:`image-uploader`,type:`asset-provider`,setup(t){t.registerAssetProvider(fs(e))}}}function ms(e){return(0,l.useEffect)(()=>{if(Yo(),e.modules)for(let t of e.modules)Ie.register(t);if(e.themes&&N.setState({themes:e.themes}),e.aiProvider)Oa.setAIProvider(e.aiProvider);else if(e.aiEndpoint){let t=typeof e.aiEndpoint==`string`?{endpoint:e.aiEndpoint}:e.aiEndpoint;Oa.setAIProvider(Qo(t))}if(e.productProvider)Oa.registerProductProvider(e.productProvider);else if(e.productEndpoint){let t=typeof e.productEndpoint==`string`?{endpoint:e.productEndpoint}:e.productEndpoint;Oa.registerProductProvider(is(t))}if(e.voucherProvider)Oa.registerVoucherProvider(e.voucherProvider);else if(e.voucherEndpoint){let t=typeof e.voucherEndpoint==`string`?{endpoint:e.voucherEndpoint}:e.voucherEndpoint;Oa.registerVoucherProvider(ls(t)),typeof e.voucherEndpoint!=`string`&&e.voucherEndpoint.preload&&Ca()}if(e.mergeTags&&Oa.registerMergeTags(e.mergeTags),e.initialDocument){let t=b.safeParse(e.initialDocument);t.success&&N.getState().applyDoc(t.data,!1)}let t=N.subscribe((t,n)=>{t.doc!==n.doc&&e.onChange?.(t.doc)});return()=>t()},[]),(0,l.useEffect)(()=>{if(e.onExportHtml)return N.subscribe((t,n)=>{t.doc!==n.doc&&e.onExportHtml?.(A(t.doc))})},[e.onExportHtml]),(0,l.createElement)(Xo)}function hs(e){let t=(0,c.createRoot)(e.container);return t.render((0,l.createElement)(ms,e)),{destroy:()=>t.unmount(),getDocument:()=>N.getState().doc,exportHtml:()=>N.getState().exportHtml(),exportJson:()=>N.getState().exportJson()}}exports.ALGORITHMS=Ma,exports.ALGORITHM_BY_ID=Na,exports.EmailBuilder=ms,exports.FALLBACK_OPTIONS=Pa,exports.TEMPLATE_CATEGORY_LABELS=ve,exports.aiAssistantPlugin=$o,exports.applyAIActions=qe,exports.applyAIResponse=et,exports.buildCatalog=Ke,exports.createEmailBuilder=hs,exports.createHttpAIProvider=Qo,exports.createProductSearchProvider=is,exports.createVoucherProvider=ls,exports.defaultRecommendationsLogic=Fa,exports.documentSchema=b,exports.getActiveProductProvider=da,exports.getActiveVoucherProvider=xa,exports.imageUploaderPlugin=ps,exports.isVoucherAware=eo,exports.mockAIProvider=Xe,exports.productSearchPlugin=as,exports.readRecommendationsLogic=Ia,exports.recommendationsToLegacyShape=za,exports.registerPlugin=ka,exports.renderEmailHtml=A,exports.setActiveProductProvider=ua,exports.setActiveVoucherProvider=ba,exports.templateRegistry=P,exports.validateAIDocument=Ye,exports.voucherPlugin=us;
|
|
81
|
+
`},Xt={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function Zt(e){let{announcements:t=Xt,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Yt}=e,{announce:a,announcement:o}=Gt(),s=jt(`DndLiveRegion`),[c,u]=(0,l.useState)(!1);if((0,l.useEffect)(()=>{u(!0)},[]),qt((0,l.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let d=l.default.createElement(l.default.Fragment,null,l.default.createElement(Ut,{id:r,value:i.draggable}),l.default.createElement(Wt,{id:s,announcement:o}));return n?(0,m.createPortal)(d,n):d}var J;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(J||={});function Qt(){}function $t(e,t){return(0,l.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function en(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return(0,l.useMemo)(()=>[...t].filter(e=>e!=null),[...t])}var tn=Object.freeze({x:0,y:0});function nn(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function rn(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function an(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function on(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function sn(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function cn(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var ln=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=cn(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=nn(cn(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(rn)},un=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=on(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=on(r),o=i.reduce((e,t,r)=>e+nn(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(rn)};function dn(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var fn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=dn(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort(an)};function pn(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function mn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:tn}function hn(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return r.reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var gn=hn(1);function _n(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function vn(e,t,n){let r=_n(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var yn={ignoreTransform:!1};function bn(e,t){t===void 0&&(t=yn);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=q(e).getComputedStyle(e);t&&(n=vn(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function xn(e){return bn(e,{ignoreTransform:!0})}function Sn(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function Cn(e,t){return t===void 0&&(t=q(e).getComputedStyle(e)),t.position===`fixed`}function wn(e,t){t===void 0&&(t=q(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`?n.test(r):!1})}function Tn(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(yt(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!bt(i)||xt(i)||n.includes(i))return n;let a=q(e).getComputedStyle(i);return i!==e&&wn(i,a)&&n.push(i),Cn(i,a)?n:r(i.parentNode)}return e?r(e):n}function En(e){let[t]=Tn(e,1);return t??null}function Dn(e){return!gt||!e?null:_t(e)?e:vt(e)?yt(e)||e===St(e).scrollingElement?window:bt(e)?e:null:null}function On(e){return _t(e)?e.scrollX:e.scrollLeft}function kn(e){return _t(e)?e.scrollY:e.scrollTop}function An(e){return{x:On(e),y:kn(e)}}var Y;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Y||={});function jn(e){return!gt||!e?!1:e===document.scrollingElement}function Mn(e){let t={x:0,y:0},n=jn(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var Nn={x:.2,y:.2};function Pn(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=Nn);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Mn(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Y.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Y.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Y.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Y.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function Fn(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function In(e){return e.reduce((e,t)=>Nt(e,An(t)),tn)}function Ln(e){return e.reduce((e,t)=>e+On(t),0)}function Rn(e){return e.reduce((e,t)=>e+kn(t),0)}function zn(e,t){if(t===void 0&&(t=bn),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);En(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Bn=[[`x`,[`left`,`right`],Ln],[`y`,[`top`,`bottom`],Rn]],Vn=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=Tn(t),r=In(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Bn)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Hn=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Un(e){let{EventTarget:t}=q(e);return e instanceof t?e:St(e)}function Wn(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t?r>t.y:!1}var Gn;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Gn||={});function Kn(e){e.preventDefault()}function qn(e){e.stopPropagation()}var X;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})(X||={});var Jn={start:[X.Space,X.Enter],cancel:[X.Esc],end:[X.Space,X.Enter,X.Tab]},Yn=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case X.Right:return{...n,x:n.x+25};case X.Left:return{...n,x:n.x-25};case X.Down:return{...n,y:n.y+25};case X.Up:return{...n,y:n.y-25}}},Xn=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Hn(St(t)),this.windowListeners=new Hn(q(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Gn.Resize,this.handleCancel),this.windowListeners.add(Gn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Gn.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&zn(n),t(tn)}handleKeyDown(e){if(It(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Jn,coordinateGetter:a=Yn,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:tn;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=Pt(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Mn(n),p=Fn(n),m={x:Math.min(i===X.Right?p.right-p.width/2:p.right,Math.max(i===X.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===X.Down?p.bottom-p.height/2:p.bottom,Math.max(i===X.Down?p.top:p.top+p.height/2,u.y))},h=i===X.Right&&!s||i===X.Left&&!c,g=i===X.Down&&!l||i===X.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===X.Right&&e<=d.x||i===X.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===X.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===X.Down&&e<=d.y||i===X.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===X.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,Nt(Pt(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Xn.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Jn,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Zn(e){return!!(e&&`distance`in e)}function Qn(e){return!!(e&&`delay`in e)}var $n=class{constructor(e,t,n){n===void 0&&(n=Un(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=St(i),this.documentListeners=new Hn(this.document),this.listeners=new Hn(n),this.windowListeners=new Hn(q(i)),this.initialCoordinates=Rt(r)??tn,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Gn.Resize,this.handleCancel),this.windowListeners.add(Gn.DragStart,Kn),this.windowListeners.add(Gn.VisibilityChange,this.handleCancel),this.windowListeners.add(Gn.ContextMenu,Kn),this.documentListeners.add(Gn.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Qn(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Zn(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Gn.Click,qn,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Gn.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=Rt(e)??tn,s=Pt(n,o);if(!t&&a){if(Zn(a)){if(a.tolerance!=null&&Wn(s,a.tolerance))return this.handleCancel();if(Wn(s,a.distance))return this.handleStart()}if(Qn(a)&&Wn(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===X.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},er={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},tr=class extends $n{constructor(e){let{event:t}=e,n=St(t.target);super(e,er,n)}};tr.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var nr={move:{name:`mousemove`},end:{name:`mouseup`}},rr;(function(e){e[e.RightClick=2]=`RightClick`})(rr||={});var ir=class extends $n{constructor(e){super(e,nr,St(e.event.target))}};ir.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===rr.RightClick?!1:(r?.({event:n}),!0)}}];var ar={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},or=class extends $n{constructor(e){super(e,ar)}static setup(){return window.addEventListener(ar.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(ar.move.name,e)};function e(){}}};or.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var sr;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(sr||={});var cr;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(cr||={});function lr(e){let{acceleration:t,activator:n=sr.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=cr.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:d,delta:f,threshold:p}=e,m=dr({delta:f,disabled:!a}),[h,g]=Tt(),_=(0,l.useRef)({x:0,y:0}),v=(0,l.useRef)({x:0,y:0}),y=(0,l.useMemo)(()=>{switch(n){case sr.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case sr.DraggableRect:return i}},[n,i,c]),b=(0,l.useRef)(null),x=(0,l.useCallback)(()=>{let e=b.current;if(!e)return;let t=_.current.x*v.current.x,n=_.current.y*v.current.y;e.scrollBy(t,n)},[]),S=(0,l.useMemo)(()=>s===cr.TreeOrder?[...u].reverse():u,[s,u]);(0,l.useEffect)(()=>{if(!a||!u.length||!y){g();return}for(let e of S){if(r?.(e)===!1)continue;let n=u.indexOf(e),i=d[n];if(!i)continue;let{direction:a,speed:s}=Pn(e,i,y,t,p);for(let e of[`x`,`y`])m[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){g(),b.current=e,h(x,o),_.current=s,v.current=a;return}}_.current={x:0,y:0},v.current={x:0,y:0},g()},[t,x,r,g,a,o,JSON.stringify(y),JSON.stringify(m),h,u,S,d,JSON.stringify(p)])}var ur={x:{[Y.Backward]:!1,[Y.Forward]:!1},y:{[Y.Backward]:!1,[Y.Forward]:!1}};function dr(e){let{delta:t,disabled:n}=e,r=kt(t);return Dt(e=>{if(n||!r||!e)return ur;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Y.Backward]:e.x[Y.Backward]||i.x===-1,[Y.Forward]:e.x[Y.Forward]||i.x===1},y:{[Y.Backward]:e.y[Y.Backward]||i.y===-1,[Y.Forward]:e.y[Y.Forward]||i.y===1}}},[n,t,r])}function fr(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Dt(e=>t==null?null:r??e??null,[r,t])}function pr(e,t){return(0,l.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var mr;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(mr||={});var hr;(function(e){e.Optimized=`optimized`})(hr||={});var gr=new Map;function _r(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,l.useState)(null),{frequency:s,measure:c,strategy:u}=i,d=(0,l.useRef)(e),f=_(),p=Et(f),m=(0,l.useCallback)(function(e){e===void 0&&(e=[]),!p.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[p]),h=(0,l.useRef)(null),g=Dt(t=>{if(f&&!n)return gr;if(!t||t===gr||d.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new Vn(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,f,c]);return(0,l.useEffect)(()=>{d.current=e},[e]),(0,l.useEffect)(()=>{f||m()},[n,f]),(0,l.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,l.useEffect)(()=>{f||typeof s!=`number`||h.current!==null||(h.current=setTimeout(()=>{m(),h.current=null},s))},[s,f,m,...r]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:a!=null};function _(){switch(u){case mr.Always:return!1;case mr.BeforeDragging:return n;default:return!n}}}function vr(e,t){return Dt(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function yr(e,t){return vr(e,t)}function br(e){let{callback:t,disabled:n}=e,r=wt(t),i=(0,l.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,l.useEffect)(()=>()=>i?.disconnect(),[i]),i}function xr(e){let{callback:t,disabled:n}=e,r=wt(t),i=(0,l.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,l.useEffect)(()=>()=>i?.disconnect(),[i]),i}function Sr(e){return new Vn(bn(e),e)}function Cr(e,t,n){t===void 0&&(t=Sr);let[r,i]=(0,l.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=br({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=xr({callback:a});return Ct(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function wr(e){return mn(e,vr(e))}var Tr=[];function Er(e){let t=(0,l.useRef)(e),n=Dt(n=>e?n&&n!==Tr&&e&&t.current&&e.parentNode===t.current.parentNode?n:Tn(e):Tr,[e]);return(0,l.useEffect)(()=>{t.current=e},[e]),n}function Dr(e){let[t,n]=(0,l.useState)(null),r=(0,l.useRef)(e),i=(0,l.useCallback)(e=>{let t=Dn(e.target);t&&n(e=>e?(e.set(t,An(t)),new Map(e)):null)},[]);return(0,l.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Dn(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,An(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Dn(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,l.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>Nt(e,t),tn):In(e):tn,[e,t])}function Or(e,t){t===void 0&&(t=[]);let n=(0,l.useRef)(null);return(0,l.useEffect)(()=>{n.current=null},t),(0,l.useEffect)(()=>{let t=e!==tn;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?Pt(e,n.current):tn}function kr(e){(0,l.useEffect)(()=>{if(!gt)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function Ar(e,t){return(0,l.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function jr(e){return(0,l.useMemo)(()=>e?Sn(e):null,[e])}var Mr=[];function Nr(e,t){t===void 0&&(t=bn);let[n]=e,r=jr(n?q(n):null),[i,a]=(0,l.useState)(Mr);function o(){a(()=>e.length?e.map(e=>jn(e)?r:new Vn(t(e),e)):Mr)}let s=xr({callback:o});return Ct(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Pr(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return bt(t)?t:e}function Fr(e){let{measure:t}=e,[n,r]=(0,l.useState)(null),i=xr({callback:(0,l.useCallback)(e=>{for(let{target:n}of e)if(bt(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=Ot((0,l.useCallback)(e=>{let n=Pr(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,l.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Ir=[{sensor:tr,options:{}},{sensor:Xn,options:{}}],Lr={current:{}},Rr={draggable:{measure:xn},droppable:{measure:xn,strategy:mr.WhileDragging,frequency:hr.Optimized},dragOverlay:{measure:bn}},zr=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Br={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new zr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Qt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Rr,measureDroppableContainers:Qt,windowRect:null,measuringScheduled:!1},Vr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Qt,draggableNodes:new Map,over:null,measureDroppableContainers:Qt},Hr=(0,l.createContext)(Vr),Ur=(0,l.createContext)(Br);function Wr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new zr}}}function Gr(e,t){switch(t.type){case J.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case J.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case J.DragEnd:case J.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case J.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new zr(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case J.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new zr(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case J.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new zr(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Kr(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,l.useContext)(Hr),a=kt(r),o=kt(n?.id);return(0,l.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!It(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Vt(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function qr(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Jr(e){return(0,l.useMemo)(()=>({draggable:{...Rr.draggable,...e?.draggable},droppable:{...Rr.droppable,...e?.droppable},dragOverlay:{...Rr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Yr(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,l.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;Ct(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=mn(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=En(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Xr=(0,l.createContext)({...tn,scaleX:1,scaleY:1}),Zr;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Zr||={});var Qr=(0,l.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Ir,collisionDetection:o=fn,measuring:s,modifiers:c,...u}=e,[d,f]=(0,l.useReducer)(Gr,void 0,Wr),[p,h]=Jt(),[g,_]=(0,l.useState)(Zr.Uninitialized),v=g===Zr.Initialized,{draggable:{active:y,nodes:b,translate:x},droppable:{containers:S}}=d,C=y==null?null:b.get(y),w=(0,l.useRef)({initial:null,translated:null}),T=(0,l.useMemo)(()=>y==null?null:{id:y,data:C?.data??Lr,rect:w},[y,C]),ee=(0,l.useRef)(null),[te,E]=(0,l.useState)(null),[D,ne]=(0,l.useState)(null),re=Et(u,Object.values(u)),ie=jt(`DndDescribedBy`,t),ae=(0,l.useMemo)(()=>S.getEnabled(),[S]),oe=Jr(s),{droppableRects:se,measureDroppableContainers:ce,measuringScheduled:le}=_r(ae,{dragging:v,dependencies:[x.x,x.y],config:oe.droppable}),O=fr(b,y),ue=(0,l.useMemo)(()=>D?Rt(D):null,[D]),de=we(),fe=yr(O,oe.draggable.measure);Yr({activeNode:y==null?null:b.get(y),config:de.layoutShiftCompensation,initialRect:fe,measure:oe.draggable.measure});let k=Cr(O,oe.draggable.measure,fe),pe=Cr(O?O.parentElement:null),A=(0,l.useRef)({activatorEvent:null,active:null,activeNode:O,collisionRect:null,collisions:null,droppableRects:se,draggableNodes:b,draggingNode:null,draggingNodeRect:null,droppableContainers:S,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),j=S.getNodeFor(A.current.over?.id),me=Fr({measure:oe.dragOverlay.measure}),he=me.nodeRef.current??O,ge=v?me.rect??k:null,_e=!!(me.nodeRef.current&&me.rect),ve=wr(_e?null:k),M=jr(he?q(he):null),N=Er(v?j??O:null),ye=Nr(N),be=qr(c,{transform:{x:x.x-ve.x,y:x.y-ve.y,scaleX:1,scaleY:1},activatorEvent:D,active:T,activeNodeRect:k,containerNodeRect:pe,draggingNodeRect:ge,over:A.current.over,overlayNodeRect:me.rect,scrollableAncestors:N,scrollableAncestorRects:ye,windowRect:M}),P=ue?Nt(ue,x):null,F=Dr(N),I=Or(F),L=Or(F,[k]),R=Nt(be,I),z=ge?gn(ge,be):null,B=T&&z?o({active:T,collisionRect:z,droppableRects:se,droppableContainers:ae,pointerCoordinates:P}):null,V=sn(B,`id`),[H,xe]=(0,l.useState)(null),U=pn(_e?be:Nt(be,L),H?.rect??null,k),Se=(0,l.useRef)(null),W=(0,l.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(ee.current==null)return;let i=b.get(ee.current);if(!i)return;let a=e.nativeEvent,o=new n({active:ee.current,activeNode:i,event:a,options:r,context:A,onAbort(e){if(!b.get(e))return;let{onDragAbort:t}=re.current,n={id:e};t?.(n),p({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!b.get(e))return;let{onDragPending:i}=re.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),p({type:`onDragPending`,event:a})},onStart(e){let t=ee.current;if(t==null)return;let n=b.get(t);if(!n)return;let{onDragStart:r}=re.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:w}};(0,m.unstable_batchedUpdates)(()=>{r?.(i),_(Zr.Initializing),f({type:J.DragStart,initialCoordinates:e,active:t}),p({type:`onDragStart`,event:i}),E(Se.current),ne(a)})},onMove(e){f({type:J.DragMove,coordinates:e})},onEnd:s(J.DragEnd),onCancel:s(J.DragCancel)});Se.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=A.current,o=null;if(t&&i){let{cancelDrop:s}=re.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===J.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=J.DragCancel)}ee.current=null,(0,m.unstable_batchedUpdates)(()=>{f({type:e}),_(Zr.Uninitialized),xe(null),E(null),ne(null),Se.current=null;let t=e===J.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=re.current[t];e?.(o),p({type:t,event:o})}})}}},[b]),G=pr(a,(0,l.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=b.get(r);if(ee.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},ee.current=r,W(n,t))},[b,W]));kr(a),Ct(()=>{k&&g===Zr.Initializing&&_(Zr.Initialized)},[k,g]),(0,l.useEffect)(()=>{let{onDragMove:e}=re.current,{active:t,activatorEvent:n,collisions:r,over:i}=A.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:R.x,y:R.y},over:i};(0,m.unstable_batchedUpdates)(()=>{e?.(a),p({type:`onDragMove`,event:a})})},[R.x,R.y]),(0,l.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=A.current;if(!e||ee.current==null||!t||!i)return;let{onDragOver:a}=re.current,o=r.get(V),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,m.unstable_batchedUpdates)(()=>{xe(s),a?.(c),p({type:`onDragOver`,event:c})})},[V]),Ct(()=>{A.current={activatorEvent:D,active:T,activeNode:O,collisionRect:z,collisions:B,droppableRects:se,draggableNodes:b,draggingNode:he,draggingNodeRect:ge,droppableContainers:S,over:H,scrollableAncestors:N,scrollAdjustedTranslate:R},w.current={initial:ge,translated:z}},[T,O,B,z,b,he,ge,se,S,H,N,R]),lr({...de,delta:x,draggingRect:z,pointerCoordinates:P,scrollableAncestors:N,scrollableAncestorRects:ye});let K=(0,l.useMemo)(()=>({active:T,activeNode:O,activeNodeRect:k,activatorEvent:D,collisions:B,containerNodeRect:pe,dragOverlay:me,draggableNodes:b,droppableContainers:S,droppableRects:se,over:H,measureDroppableContainers:ce,scrollableAncestors:N,scrollableAncestorRects:ye,measuringConfiguration:oe,measuringScheduled:le,windowRect:M}),[T,O,k,D,B,pe,me,b,S,se,H,ce,N,ye,oe,le,M]),Ce=(0,l.useMemo)(()=>({activatorEvent:D,activators:G,active:T,activeNodeRect:k,ariaDescribedById:{draggable:ie},dispatch:f,draggableNodes:b,over:H,measureDroppableContainers:ce}),[D,G,T,k,f,ie,b,H,ce]);return l.default.createElement(Kt.Provider,{value:h},l.default.createElement(Hr.Provider,{value:Ce},l.default.createElement(Ur.Provider,{value:K},l.default.createElement(Xr.Provider,{value:U},i)),l.default.createElement(Kr,{disabled:n?.restoreFocus===!1})),l.default.createElement(Zt,{...n,hiddenTextDescribedById:ie}));function we(){let e=te?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=v&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),$r=(0,l.createContext)(null),ei=`button`,ti=`Draggable`;function ni(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=jt(ti),{activators:o,activatorEvent:s,active:c,activeNodeRect:u,ariaDescribedById:d,draggableNodes:f,over:p}=(0,l.useContext)(Hr),{role:m=ei,roleDescription:h=`draggable`,tabIndex:g=0}=i??{},_=c?.id===t,v=(0,l.useContext)(_?Xr:$r),[y,b]=Ot(),[x,S]=Ot(),C=Ar(o,t),w=Et(n);return Ct(()=>(f.set(t,{id:t,key:a,node:y,activatorNode:x,data:w}),()=>{let e=f.get(t);e&&e.key===a&&f.delete(t)}),[f,t]),{active:c,activatorEvent:s,activeNodeRect:u,attributes:(0,l.useMemo)(()=>({role:m,tabIndex:g,"aria-disabled":r,"aria-pressed":_&&m===ei?!0:void 0,"aria-roledescription":h,"aria-describedby":d.draggable}),[r,m,g,_,h,d.draggable]),isDragging:_,listeners:r?void 0:C,node:y,over:p,setNodeRef:b,setActivatorNodeRef:S,transform:v}}function ri(){return(0,l.useContext)(Ur)}var ii=`Droppable`,ai={timeout:25};function oi(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=jt(ii),{active:o,dispatch:s,over:c,measureDroppableContainers:u}=(0,l.useContext)(Hr),d=(0,l.useRef)({disabled:n}),f=(0,l.useRef)(!1),p=(0,l.useRef)(null),m=(0,l.useRef)(null),{disabled:h,updateMeasurementsFor:g,timeout:_}={...ai,...i},v=Et(g??r),y=xr({callback:(0,l.useCallback)(()=>{if(!f.current){f.current=!0;return}m.current!=null&&clearTimeout(m.current),m.current=setTimeout(()=>{u(Array.isArray(v.current)?v.current:[v.current]),m.current=null},_)},[_]),disabled:h||!o}),[b,x]=Ot((0,l.useCallback)((e,t)=>{y&&(t&&(y.unobserve(t),f.current=!1),e&&y.observe(e))},[y])),S=Et(t);return(0,l.useEffect)(()=>{!y||!b.current||(y.disconnect(),f.current=!1,y.observe(b.current))},[b,y]),(0,l.useEffect)(()=>(s({type:J.RegisterDroppable,element:{id:r,key:a,disabled:n,node:b,rect:p,data:S}}),()=>s({type:J.UnregisterDroppable,key:a,id:r})),[r]),(0,l.useEffect)(()=>{n!==d.current.disabled&&(s({type:J.SetDroppableDisabled,id:r,key:a,disabled:n}),d.current.disabled=n)},[r,a,n,s]),{active:o,rect:p,isOver:c?.id===r,node:b,over:c,setNodeRef:x}}function si(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function ci(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function li(e){return e!==null&&e>=0}function ui(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function di(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var fi=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=si(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},pi={scaleX:1,scaleY:1},mi=e=>{let{activeIndex:t,activeNodeRect:n,index:r,rects:i,overIndex:a}=e,o=i[t]??n;if(!o)return null;if(r===t){let e=i[a];return e?{x:0,y:t<a?e.top+e.height-(o.top+o.height):e.top-o.top,...pi}:null}let s=hi(i,r,t);return r>t&&r<=a?{x:0,y:-o.height-s,...pi}:r<t&&r>=a?{x:0,y:o.height+s,...pi}:{x:0,y:0,...pi}};function hi(e,t,n){let r=e[t],i=e[t-1],a=e[t+1];return r?n<t?i?r.top-(i.top+i.height):a?a.top-(r.top+r.height):0:a?a.top-(r.top+r.height):i?r.top-(i.top+i.height):0:0}var gi=`Sortable`,_i=l.default.createContext({activeIndex:-1,containerId:gi,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:fi,disabled:{draggable:!1,droppable:!1}});function vi(e){let{children:t,id:n,items:r,strategy:i=fi,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:u,measureDroppableContainers:d}=ri(),f=jt(gi,n),p=s.rect!==null,m=(0,l.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),h=o!=null,g=o?m.indexOf(o.id):-1,_=u?m.indexOf(u.id):-1,v=(0,l.useRef)(m),y=!ui(m,v.current),b=_!==-1&&g===-1||y,x=di(a);Ct(()=>{y&&h&&d(m)},[y,m,h,d]),(0,l.useEffect)(()=>{v.current=m},[m]);let S=(0,l.useMemo)(()=>({activeIndex:g,containerId:f,disabled:x,disableTransforms:b,items:m,overIndex:_,useDragOverlay:p,sortedRects:ci(m,c),strategy:i}),[g,f,x.draggable,x.droppable,b,m,_,c,p,i]);return l.default.createElement(_i.Provider,{value:S},t)}var yi=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return si(n,r,i).indexOf(t)},bi=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},xi={duration:200,easing:`ease`},Si=`transform`,Ci=zt.Transition.toString({property:Si,duration:0,easing:`linear`}),wi={roleDescription:`sortable`};function Ti(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,l.useState)(null),s=(0,l.useRef)(n);return Ct(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=bn(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,l.useEffect)(()=>{a&&o(null)},[a]),a}function Ei(e){let{animateLayoutChanges:t=bi,attributes:n,disabled:r,data:i,getNewIndex:a=yi,id:o,strategy:s,resizeObserverConfig:c,transition:u=xi}=e,{items:d,containerId:f,activeIndex:p,disabled:m,disableTransforms:h,sortedRects:g,overIndex:_,useDragOverlay:v,strategy:y}=(0,l.useContext)(_i),b=Di(r,m),x=d.indexOf(o),S=(0,l.useMemo)(()=>({sortable:{containerId:f,index:x,items:d},...i}),[f,i,x,d]),C=(0,l.useMemo)(()=>d.slice(d.indexOf(o)),[d,o]),{rect:w,node:T,isOver:ee,setNodeRef:te}=oi({id:o,data:S,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:C,...c}}),{active:E,activatorEvent:D,activeNodeRect:ne,attributes:re,setNodeRef:ie,listeners:ae,isDragging:oe,over:se,setActivatorNodeRef:ce,transform:le}=ni({id:o,data:S,attributes:{...wi,...n},disabled:b.draggable}),O=ht(te,ie),ue=!!E,de=ue&&!h&&li(p)&&li(_),fe=!v&&oe,k=de?(fe&&de?le:null)??(s??y)({rects:g,activeNodeRect:ne,activeIndex:p,overIndex:_,index:x}):null,pe=li(p)&&li(_)?a({id:o,items:d,activeIndex:p,overIndex:_}):x,A=E?.id,j=(0,l.useRef)({activeId:A,items:d,newIndex:pe,containerId:f}),me=d!==j.current.items,he=t({active:E,containerId:f,isDragging:oe,isSorting:ue,id:o,index:x,items:d,newIndex:j.current.newIndex,previousItems:j.current.items,previousContainerId:j.current.containerId,transition:u,wasDragging:j.current.activeId!=null}),ge=Ti({disabled:!he,index:x,node:T,rect:w});return(0,l.useEffect)(()=>{ue&&j.current.newIndex!==pe&&(j.current.newIndex=pe),f!==j.current.containerId&&(j.current.containerId=f),d!==j.current.items&&(j.current.items=d)},[ue,pe,f,d]),(0,l.useEffect)(()=>{if(A===j.current.activeId)return;if(A!=null&&j.current.activeId==null){j.current.activeId=A;return}let e=setTimeout(()=>{j.current.activeId=A},50);return()=>clearTimeout(e)},[A]),{active:E,activeIndex:p,attributes:re,data:S,rect:w,index:x,newIndex:pe,items:d,isOver:ee,isSorting:ue,isDragging:oe,listeners:ae,node:T,overIndex:_,over:se,setNodeRef:O,setActivatorNodeRef:ce,setDroppableNodeRef:te,setDraggableNodeRef:ie,transform:ge??k,transition:_e()};function _e(){if(ge||me&&j.current.newIndex===x)return Ci;if(!(fe&&!It(D)||!u)&&(ue||he))return zt.Transition.toString({...u,property:Si})}}function Di(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function Oi(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var ki=[X.Down,X.Right,X.Up,X.Left],Ai=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(ki.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case X.Down:r.top<a.top&&t.push(n);break;case X.Up:r.top>a.top&&t.push(n);break;case X.Left:r.left>a.left&&t.push(n);break;case X.Right:r.left<a.left&&t.push(n);break}});let c=un({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=sn(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=Tn(c).some((e,t)=>s[t]!==e),i=ji(e,t),a=Mi(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:Pt(u,l)}}}};function ji(e,t){return!Oi(e)||!Oi(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Mi(e,t){return!Oi(e)||!Oi(t)||!ji(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var Ni=(0,d.create)(e=>({activeEl:null,setActiveEl:t=>e({activeEl:t})})),Pi=(0,d.create)(e=>({mergeTags:[],setMergeTags:t=>e({mergeTags:t})}));function Fi(e){Pi.getState().setMergeTags(e)}var Ii=[{label:`Default`,value:``},{label:`Arial`,value:`Arial, Helvetica, sans-serif`},{label:`Georgia`,value:`Georgia, 'Times New Roman', serif`},{label:`Tahoma`,value:`Tahoma, Geneva, sans-serif`},{label:`Trebuchet MS`,value:`'Trebuchet MS', Helvetica, sans-serif`},{label:`Verdana`,value:`Verdana, Geneva, sans-serif`},{label:`Courier New`,value:`'Courier New', Courier, monospace`},{label:`Times New Roman`,value:`'Times New Roman', Times, serif`}],Li=[`10`,`11`,`12`,`13`,`14`,`15`,`16`,`18`,`20`,`22`,`24`,`28`,`32`,`36`,`48`],Ri=[`#111827`,`#374151`,`#6B7280`,`#9CA3AF`,`#D1D5DB`,`#F3F4F6`,`#FFFFFF`,`#DC2626`,`#F97316`,`#EAB308`,`#22C55E`,`#3B82F6`,`#8B5CF6`,`#EC4899`,`#B91C1C`,`#C2410C`,`#A16207`,`#15803D`,`#1D4ED8`,`#6D28D9`,`#BE185D`],zi=`😀.😊.😍.🥰.😎.🤩.👋.🙌.👍.💪.❤️.💙.💚.💛.🧡.💜.🎉.🔥.✨.⭐.🏆.🥇.🎁.🎯.🚀.💡.📧.💌.📱.💻.✅.❌.⚠️.🔔.📊.📈.💰.💳.🛒.🏷️.📍.🗓️.⚡.🌟`.split(`.`),Bi={unsubscribe:`Unsubscribe`,view_in_browser:`View in browser`,manage_preferences:`Manage preferences`,user_profile:`User profile`};function Vi(){let e=window.getSelection();if(!e||e.isCollapsed||e.rangeCount===0)return``;let t=e.getRangeAt(0).cloneContents(),n=document.createElement(`div`);return n.appendChild(t),n.innerHTML}function Hi(e,t){document.execCommand(e,!1,t)}function Ui(e){document.execCommand(`insertHTML`,!1,e)}function Wi(e,t){let n=Vi();n&&Ui(`<span style="${e}:${t}">${n}</span>`)}function Gi(){let e=window.getSelection();return!e||e.rangeCount===0?null:e.getRangeAt(0).cloneRange()}function Ki(e){let t=window.getSelection();t&&(t.removeAllRanges(),t.addRange(e))}function qi({title:e,active:t,disabled:n,onMouseDown:r,children:i}){return(0,p.jsx)(`button`,{title:e,disabled:n,onMouseDown:r,className:`flex items-center justify-center w-7 h-7 rounded text-xs transition-colors leading-none ${t?`bg-blue-600 text-white`:`text-gray-700 hover:bg-gray-100 disabled:opacity-30`}`,children:i})}function Ji(){return(0,p.jsx)(`div`,{className:`w-px h-5 bg-gray-200 mx-0.5 shrink-0`})}function Yi({savedRange:e,onClose:t}){let[n,r]=(0,l.useState)(``),[i,a]=(0,l.useState)(``),o=(0,l.useRef)(null);(0,l.useEffect)(()=>{setTimeout(()=>o.current?.focus(),30)},[]);let s=()=>{if(!n&&!i){t();return}let r=i?be[i]:n;if(!r){t();return}if(e){let t=e.commonAncestorContainer,n=(t.nodeType===Node.ELEMENT_NODE?t:t.parentElement)?.closest(`[data-email-text]`);n&&n.focus(),Ki(e)}let a=e?(()=>{let t=document.createElement(`div`);return t.appendChild(e.cloneContents()),t.innerHTML||t.textContent||r})():r;Ui(`<a href="${r}"${i?` data-link-type="${i}"`:``} style="color:inherit;text-decoration:underline">${a}</a>`),t()};return(0,p.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-3 w-80`,onMouseDown:e=>e.stopPropagation(),children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsx)(`span`,{className:`text-xs font-semibold text-gray-700`,children:`Insert link`}),(0,p.jsx)(`button`,{onClick:t,className:`text-gray-400 hover:text-gray-600 p-0.5 rounded`,children:(0,p.jsx)(f.X,{size:13})})]}),(0,p.jsx)(`input`,{ref:o,type:`url`,placeholder:`https://example.com`,value:n,onChange:e=>{r(e.target.value),e.target.value&&a(``)},className:`w-full px-2 py-1.5 text-xs border border-gray-200 rounded mb-2 focus:border-blue-500 focus:outline-none`,onKeyDown:e=>{e.key===`Enter`&&s(),e.key===`Escape`&&t()}}),(0,p.jsxs)(`div`,{className:`mb-2`,children:[(0,p.jsx)(`div`,{className:`text-[10px] text-gray-500 mb-1`,children:`Or use a special link`}),(0,p.jsxs)(`select`,{value:i,onChange:e=>{a(e.target.value),e.target.value&&r(``)},className:`w-full px-2 py-1.5 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`,children:[(0,p.jsx)(`option`,{value:``,children:`— none —`}),Object.keys(Bi).map(e=>(0,p.jsx)(`option`,{value:e,children:Bi[e]},e))]})]}),i&&(0,p.jsxs)(`p`,{className:`text-[10px] text-blue-600 mb-2`,children:[`Placeholder: `,(0,p.jsx)(`code`,{children:be[i]})]}),(0,p.jsxs)(`div`,{className:`flex gap-2`,children:[(0,p.jsx)(`button`,{onClick:s,className:`flex-1 px-3 py-1.5 bg-blue-600 text-white text-xs rounded hover:bg-blue-700`,children:`Apply`}),(0,p.jsx)(`button`,{onClick:t,className:`px-3 py-1.5 text-xs border border-gray-200 rounded hover:bg-gray-50`,children:`Cancel`})]})]})}function Xi({onClose:e}){let[t,n]=(0,l.useState)(``),r=t=>{document.execCommand(`styleWithCSS`,!1,`true`),document.execCommand(`foreColor`,!1,t),e()};return(0,p.jsxs)(`div`,{className:`absolute top-full left-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-3`,style:{width:196},onMouseDown:e=>e.stopPropagation(),children:[(0,p.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-2`,children:Ri.map(e=>(0,p.jsx)(`button`,{title:e,onClick:()=>r(e),className:`w-6 h-6 rounded border border-gray-200 hover:scale-110 transition-transform shrink-0`,style:{background:e}},e))}),(0,p.jsxs)(`div`,{className:`flex gap-1`,children:[(0,p.jsx)(`input`,{type:`text`,placeholder:`#hex or color`,value:t,onChange:e=>n(e.target.value),onKeyDown:n=>{n.key===`Enter`&&t&&r(t),n.key===`Escape`&&e()},className:`flex-1 px-2 py-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`}),(0,p.jsx)(`button`,{onClick:()=>t&&r(t),className:`px-2 py-1 text-xs bg-blue-600 text-white rounded hover:bg-blue-700`,children:`✓`})]})]})}function Zi({onClose:e}){let t=t=>{Ui(t),e()};return(0,p.jsx)(`div`,{className:`absolute top-full right-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl p-2`,style:{width:260},onMouseDown:e=>e.stopPropagation(),children:(0,p.jsx)(`div`,{className:`flex flex-wrap gap-0.5`,children:zi.map(e=>(0,p.jsx)(`button`,{onClick:()=>t(e),className:`w-8 h-8 text-lg hover:bg-gray-100 rounded flex items-center justify-center`,children:e},e))})})}function Qi({onClose:e}){let t=Pi(e=>e.mergeTags),n=t=>{Ui(`{${t}}`),e()};return t.length===0?null:(0,p.jsx)(`div`,{className:`absolute top-full right-0 mt-1 z-50 bg-white border border-gray-200 rounded-lg shadow-xl py-1`,style:{minWidth:200},onMouseDown:e=>e.stopPropagation(),children:t.map(e=>(0,p.jsxs)(`button`,{onClick:()=>n(e.attribute),className:`w-full text-left px-3 py-1.5 text-xs hover:bg-blue-50 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`span`,{children:e.title}),(0,p.jsx)(`code`,{className:`text-[10px] text-gray-400`,children:`{${e.attribute}}`})]},e.attribute))})}function $i(){let e=Ni(e=>e.activeEl),t=Pi(e=>e.mergeTags),[n,r]=(0,l.useState)(!1),[i,a]=(0,l.useState)({top:0,left:0}),[o,s]=(0,l.useState)({bold:!1,italic:!1,underline:!1}),[c,u]=(0,l.useState)(null),[d,m]=(0,l.useState)(null),h=(0,l.useRef)(null),g=(0,l.useRef)(null),_=(0,l.useCallback)(()=>u(null),[]),v=(0,l.useCallback)(()=>{let t=window.getSelection();if(!t)return;let n=null;if(!t.isCollapsed&&t.rangeCount>0?n=t.getRangeAt(0).getBoundingClientRect():e&&(n=e.getBoundingClientRect()),!n||n.width===0&&n.height===0)return;let r=h.current?.offsetWidth??480,i=n.top-40-6+window.scrollY,o=n.left+n.width/2-r/2+window.scrollX;i<8&&(i=n.bottom+6+window.scrollY),o<8&&(o=8),o+r>window.innerWidth-8&&(o=window.innerWidth-r-8),a({top:i,left:o})},[e]),y=(0,l.useCallback)(()=>{s({bold:document.queryCommandState(`bold`),italic:document.queryCommandState(`italic`),underline:document.queryCommandState(`underline`)})},[]);if((0,l.useEffect)(()=>{if(!e){g.current&&clearTimeout(g.current),g.current=setTimeout(()=>r(!1),150);return}g.current&&clearTimeout(g.current),r(!0),v(),y()},[e,v,y]),(0,l.useEffect)(()=>{let t=()=>{e&&(v(),y())};return document.addEventListener(`selectionchange`,t),()=>document.removeEventListener(`selectionchange`,t)},[e,v,y]),(0,l.useEffect)(()=>{let e=e=>{h.current&&!h.current.contains(e.target)&&_()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[_]),!n||!e)return null;let b=e=>t=>{t.preventDefault(),e()},x=e=>{u(t=>t===e?null:e),e===`link`&&m(Gi())},S=()=>{let e=window.getSelection();return e&&!e.isCollapsed};return(0,p.jsxs)(`div`,{ref:h,"data-rich-toolbar":`true`,className:`fixed z-[9999] flex items-center gap-0.5 bg-white border border-gray-200 rounded-lg shadow-lg px-1.5 py-1 select-none`,style:{top:i.top,left:i.left},onMouseDown:e=>e.preventDefault(),children:[(0,p.jsx)(qi,{title:`Bold (Ctrl+B)`,active:o.bold,onMouseDown:b(()=>Hi(`bold`)),children:(0,p.jsx)(`b`,{style:{fontSize:13,fontFamily:`inherit`},children:`B`})}),(0,p.jsx)(qi,{title:`Italic (Ctrl+I)`,active:o.italic,onMouseDown:b(()=>Hi(`italic`)),children:(0,p.jsx)(`i`,{style:{fontSize:13,fontFamily:`Georgia, serif`},children:`I`})}),(0,p.jsx)(qi,{title:`Underline (Ctrl+U)`,active:o.underline,onMouseDown:b(()=>Hi(`underline`)),children:(0,p.jsx)(`u`,{style:{fontSize:13},children:`U`})}),(0,p.jsx)(Ji,{}),(0,p.jsx)(`select`,{title:`Font family`,className:`h-7 px-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white max-w-[110px]`,defaultValue:``,onMouseDown:e=>e.stopPropagation(),onChange:t=>{let n=t.target.value;if(n){if(!S()){e?.focus();return}Wi(`font-family`,n),e?.focus()}},children:Ii.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.label))}),(0,p.jsxs)(`select`,{title:`Font size`,className:`h-7 px-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white w-14`,defaultValue:``,onMouseDown:e=>e.stopPropagation(),onChange:t=>{let n=t.target.value;if(n){if(!S()){e?.focus();return}Wi(`font-size`,`${n}px`),e?.focus()}},children:[(0,p.jsx)(`option`,{value:``,children:`Size`}),Li.map(e=>(0,p.jsx)(`option`,{value:e,children:e},e))]}),(0,p.jsx)(Ji,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(qi,{title:`Text color`,onMouseDown:b(()=>x(`color`)),children:(0,p.jsxs)(`span`,{className:`flex flex-col items-center gap-0.5`,children:[(0,p.jsx)(`span`,{className:`text-xs font-bold leading-none`,style:{fontFamily:`serif`},children:`A`}),(0,p.jsx)(`span`,{className:`w-4 h-1 rounded-sm bg-current`})]})}),c===`color`&&(0,p.jsx)(Xi,{onClose:_})]}),(0,p.jsx)(Ji,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(qi,{title:`Insert link`,onMouseDown:b(()=>x(`link`)),children:(0,p.jsx)(f.Link2,{size:13})}),c===`link`&&(0,p.jsx)(Yi,{savedRange:d,onClose:_})]}),(0,p.jsx)(Ji,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(qi,{title:`Insert emoji`,onMouseDown:b(()=>x(`emoji`)),children:(0,p.jsx)(f.Smile,{size:13})}),c===`emoji`&&(0,p.jsx)(Zi,{onClose:_})]}),t.length>0&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(Ji,{}),(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsx)(qi,{title:`Insert merge tag`,onMouseDown:b(()=>x(`mergeTag`)),children:(0,p.jsxs)(`span`,{className:`flex items-center gap-0.5 text-[10px] font-mono`,children:[(0,p.jsx)(f.Tag,{size:11}),(0,p.jsx)(f.ChevronDown,{size:10})]})}),c===`mergeTag`&&(0,p.jsx)(Qi,{onClose:_})]})]})]})}var ea=375;function ta(e){let t=e.replace(`#`,``);if(t.length!==3&&t.length!==6)return e===`white`||e===`#fff`||e===`#ffffff`;let n=t.length===3?t.split(``).map(e=>e+e).join(``):t,r=parseInt(n.slice(0,2),16)/255,i=parseInt(n.slice(2,4),16)/255,a=parseInt(n.slice(4,6),16)/255;return .2126*r+.7152*i+.0722*a>.82}function na(e,t){let n=e??{};if(t!==`mobile`)return n;let r=n.mobile??{};return{...n,...r}}function ra(){let{doc:e,selection:t,setSelection:n,reorderModules:r,deleteModule:i,duplicateModule:a,deleteElement:o,moveElement:s,viewMode:c}=M(),u=en($t(tr,{activationConstraint:{distance:5}}),$t(Xn,{coordinateGetter:Ai})),d=t=>{let{active:n,over:i}=t;if(!i||n.id===i.id)return;let a=e.modules.findIndex(e=>e.id===n.id),o=e.modules.findIndex(e=>e.id===i.id);a===-1||o===-1||r(a,o)};(0,l.useEffect)(()=>{let e=e=>{if(e.key!==`Delete`&&e.key!==`Backspace`)return;let n=e.target;n.tagName===`INPUT`||n.tagName===`TEXTAREA`||n.isContentEditable||(t?.kind===`module`?i(t.moduleId):t?.kind===`element`&&o(t.moduleId,t.elementId))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,i,o]);let f=x(e.settings.backgroundColor,e.theme),m=x(e.settings.contentBackgroundColor,e.theme),h=e.modules.map(e=>e.id),g=c===`mobile`?ea:e.settings.width;return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)($i,{}),(0,p.jsx)(`div`,{className:`flex-1 overflow-y-auto`,style:{background:f},onClick:()=>n({kind:`email`}),children:(0,p.jsx)(`div`,{className:`py-8 flex justify-center`,children:(0,p.jsxs)(`div`,{className:`shadow-lg transition-all duration-200 ${c===`mobile`?`rounded-[28px] border-[10px] border-gray-800`:``}`,style:{width:g,background:m,minHeight:300},onClick:e=>e.stopPropagation(),children:[e.modules.length===0&&(0,p.jsx)(`div`,{className:`p-12 text-center text-gray-400 text-sm`,children:`Add modules from the left sidebar to start building your email.`}),(0,p.jsx)(Qr,{sensors:u,collisionDetection:ln,onDragEnd:d,children:(0,p.jsx)(vi,{items:h,strategy:mi,children:e.modules.map((r,o)=>(0,p.jsx)(ia,{mod:r,index:o,viewMode:c,selected:t?.kind===`module`&&t.moduleId===r.id,selectionEl:t?.kind===`element`&&t.moduleId===r.id?t.elementId:null,theme:e.theme,onSelectModule:()=>n({kind:`module`,moduleId:r.id}),onSelectElement:e=>n({kind:`element`,moduleId:r.id,elementId:e}),onDuplicate:()=>a(r.id),onDelete:()=>i(r.id)},r.id))})})]})})})]})}function ia(e){let{attributes:t,listeners:n,setNodeRef:r,transform:i,transition:a,isDragging:o}=Ei({id:e.mod.id});return(0,p.jsx)(`div`,{ref:r,style:{transform:zt.Transform.toString(i),transition:a,opacity:o?.5:1,position:`relative`,zIndex:e.selected?10:`auto`},children:(0,p.jsx)(aa,{mod:e.mod,viewMode:e.viewMode,selected:e.selected,selectionEl:e.selectionEl,theme:e.theme,onSelectModule:e.onSelectModule,onSelectElement:e.onSelectElement,onDuplicate:e.onDuplicate,onDelete:e.onDelete,dragHandle:(0,p.jsx)(`button`,{...t,...n,className:`bg-blue-600 text-white p-1 rounded cursor-grab active:cursor-grabbing`,title:`Drag to reorder`,onClick:e=>e.stopPropagation(),children:(0,p.jsx)(f.GripVertical,{size:14})})})})}function aa({mod:e,viewMode:t,selected:n,selectionEl:r,theme:i,onSelectModule:a,onSelectElement:o,onDuplicate:s,onDelete:c,dragHandle:u}){let d=e.style??{};if(d.hideOn===t)return null;let m=S(na(d,t),i),[h,g]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{style:{backgroundColor:m.backgroundColor,paddingTop:m.paddingTop??0,paddingBottom:m.paddingBottom??0,paddingLeft:m.paddingLeft??0,paddingRight:m.paddingRight??0,borderRadius:m.borderRadius,position:`relative`,outline:n?`2px solid #2563eb`:h?`1px dashed #93c5fd`:`1px dashed transparent`,outlineOffset:-2,cursor:`pointer`},onClick:e=>{e.stopPropagation(),a()},onMouseEnter:()=>g(!0),onMouseLeave:()=>g(!1),children:[!n&&h&&(0,p.jsxs)(`div`,{className:`absolute top-0 right-0 z-10 bg-blue-600 text-white text-[10px] px-1.5 py-0.5 rounded-bl pointer-events-none`,children:[`Click to select: `,e.name]}),n&&(0,p.jsxs)(`div`,{className:`absolute top-0 left-0 z-20 flex items-center gap-1 p-1 rounded-br bg-blue-600 shadow-md`,onClick:e=>e.stopPropagation(),children:[u,(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),s()},className:`text-white p-1 rounded hover:bg-blue-700`,title:`Duplicate`,children:(0,p.jsx)(f.Copy,{size:14})}),(0,p.jsx)(`button`,{onClick:e=>{e.stopPropagation(),c()},className:`text-white p-1 rounded hover:bg-red-600`,title:`Delete`,children:(0,p.jsx)(f.Trash2,{size:14})}),(0,p.jsx)(`span`,{className:`text-white text-[10px] font-medium px-1.5 py-0.5`,children:e.name})]}),e.children.map((s,c)=>(0,p.jsx)(oa,{el:s,index:c,totalElements:e.children.length,viewMode:t,theme:i,moduleId:e.id,moduleSelected:n,selected:r===s.id,onSelect:()=>o(s.id),onSelectModule:a},s.id))]})}function oa({el:e,index:t,totalElements:n,viewMode:r,theme:i,moduleId:a,moduleSelected:o,selected:s,onSelect:c,onSelectModule:l}){let u=M(e=>e.moveElement),d=M(e=>e.deleteElement);if(e.style?.hideOn===r)return null;let m={outline:s?`2px solid #f59e0b`:`1px dashed rgba(0,0,0,0.08)`,outlineOffset:-1,position:`relative`},h=e=>{if(e.stopPropagation(),!o&&!s){l();return}c()},g=s&&(0,p.jsxs)(`div`,{className:`absolute top-0 right-0 z-20 flex items-center gap-1 p-1 rounded-bl bg-amber-500 shadow-md`,onClick:e=>e.stopPropagation(),children:[(0,p.jsx)(`button`,{onClick:()=>l(),className:`text-white p-1 rounded hover:bg-amber-600`,title:`Select parent block`,children:(0,p.jsx)(f.MousePointer2,{size:12})}),(0,p.jsx)(`button`,{disabled:t===0,onClick:()=>u(a,e.id,-1),className:`text-white p-1 rounded disabled:opacity-40 hover:bg-amber-600`,title:`Move up`,children:(0,p.jsx)(f.ArrowUp,{size:12})}),(0,p.jsx)(`button`,{disabled:t===n-1,onClick:()=>u(a,e.id,1),className:`text-white p-1 rounded disabled:opacity-40 hover:bg-amber-600`,title:`Move down`,children:(0,p.jsx)(f.ArrowDown,{size:12})}),(0,p.jsx)(`button`,{onClick:()=>d(a,e.id),className:`text-white p-1 rounded hover:bg-red-600`,title:`Delete element`,children:(0,p.jsx)(f.Trash2,{size:12})}),(0,p.jsx)(`span`,{className:`text-white text-[10px] font-medium px-1 py-0.5`,children:e.type})]}),_=e=>(0,p.jsxs)(`div`,{style:m,onClick:h,children:[g,e]});switch(e.type){case`text`:return _((0,p.jsx)(sa,{el:e,viewMode:r,theme:i,moduleId:a}));case`image`:return _((0,p.jsx)(ca,{el:e,viewMode:r,theme:i}));case`button`:return _((0,p.jsx)(la,{el:e,viewMode:r,theme:i}));case`spacer`:return _((0,p.jsx)(ua,{el:e}));case`divider`:return _((0,p.jsx)(da,{el:e,viewMode:r,theme:i}));case`productGrid`:return _((0,p.jsx)(fa,{el:e,viewMode:r,theme:i}))}}function sa({el:e,viewMode:t,theme:n,moduleId:r}){let i=M(e=>e.updateElement),a=Ni(e=>e.setActiveEl),o=(0,l.useRef)(null),s=(0,l.useRef)(!1),c=(0,l.useRef)(!1),u=(0,l.useRef)(e.content);u.current=e.content,(0,l.useEffect)(()=>{let t=o.current;!t||s.current||t.innerHTML!==e.content&&(t.innerHTML=e.content)});let d=S(na(e.style,t),n),f=d.color??`#000000`,m=ta(f);return(0,p.jsx)(`div`,{ref:o,"data-email-text":`true`,style:{fontFamily:d.fontFamily,fontSize:d.fontSize,lineHeight:d.lineHeight,letterSpacing:d.letterSpacing,fontWeight:d.fontWeight,color:f,textAlign:d.align,paddingTop:d.paddingTop??8,paddingBottom:d.paddingBottom??8,paddingLeft:d.paddingLeft??16,paddingRight:d.paddingRight??16,margin:0,minHeight:`1.5em`,outline:`none`,...m?{textShadow:`0 0 8px rgba(0,0,0,0.55), 0 1px 2px rgba(0,0,0,0.45)`}:void 0},contentEditable:!0,suppressContentEditableWarning:!0,onFocus:e=>{s.current=!0,c.current=!0,a(e.currentTarget)},onBlur:t=>{s.current=!1,c.current=!1,t.relatedTarget?.closest(`[data-rich-toolbar]`)||a(null);let n=t.currentTarget.innerHTML;n!==u.current&&i(r,e.id,{content:n})},onClick:e=>{c.current&&e.stopPropagation()}})}function ca({el:e,viewMode:t,theme:n}){let r=S(na(e.style,t),n),i={textAlign:r.align??`center`,paddingTop:r.paddingTop??0,paddingBottom:r.paddingBottom??0,paddingLeft:r.paddingLeft??0,paddingRight:r.paddingRight??0},a={display:`inline-block`,maxWidth:`100%`,width:r.width,height:r.height||`auto`,borderRadius:r.borderRadius};return(0,p.jsx)(`div`,{style:i,children:(0,p.jsx)(`img`,{src:e.src,alt:e.alt??``,style:a})})}function la({el:e,viewMode:t,theme:n}){let r=S(na(e.style,t),n);return(0,p.jsx)(`div`,{style:{textAlign:r.align??`center`,paddingTop:r.paddingTop??12,paddingBottom:r.paddingBottom??12,paddingLeft:r.paddingLeft??16,paddingRight:r.paddingRight??16},children:(0,p.jsx)(`span`,{style:{display:`inline-block`,backgroundColor:r.backgroundColor??`#3A7D52`,color:r.color??`#fff`,fontFamily:r.fontFamily,fontSize:r.fontSize??16,fontWeight:r.fontWeight??`bold`,borderRadius:r.borderRadius??6,padding:`12px 24px`,textDecoration:`none`},children:e.label})})}function ua({el:e}){return(0,p.jsx)(`div`,{style:{height:e.height,background:`rgba(0,0,0,0.02)`}})}function da({el:e,viewMode:t,theme:n}){let r=S(na(e.style,t),n);return(0,p.jsx)(`div`,{style:{paddingTop:r.paddingTop??8,paddingBottom:r.paddingBottom??8},children:(0,p.jsx)(`hr`,{style:{border:0,borderTop:`${r.thickness??1}px solid ${r.color??`#E5E7EB`}`,margin:0}})})}function fa({el:e,viewMode:t,theme:n}){let r=S(na(e.style,t),n),i=t===`mobile`,a=e.columns,o=r.cardBackgroundColor??r.backgroundColor??`transparent`,s=r.nameColor??`#111827`,c=r.finalPriceColor??`#3A7D52`,l=r.oldPriceColor??`#9CA3AF`,u=r.buttonBackgroundColor??`#3A7D52`,d=r.buttonColor??`#FFFFFF`,f=r.borderRadius??0;return(0,p.jsx)(`div`,{style:{paddingTop:r.paddingTop??16,paddingBottom:r.paddingBottom??16,paddingLeft:r.paddingLeft??16,paddingRight:r.paddingRight??16,display:`flex`,flexWrap:`wrap`,gap:8},children:e.products.map(t=>(0,p.jsxs)(`div`,{style:{width:i?`100%`:`calc(${100/a}% - 8px)`,background:o,borderRadius:f,overflow:`hidden`,display:`flex`,flexDirection:`column`},children:[(0,p.jsx)(`img`,{src:t.image,alt:t.imageAlt??t.name,style:{display:`block`,width:`100%`,height:`auto`,borderRadius:f}}),(0,p.jsx)(`div`,{style:{padding:`12px 12px 4px 12px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:15,fontWeight:`bold`,color:s,lineHeight:1.3},children:t.name}),e.showStars&&t.stars!=null&&(0,p.jsx)(`div`,{className:`stars`,style:{padding:`0 12px 4px 12px`,color:`#F5A623`,fontSize:15,letterSpacing:1},"aria-label":`${t.stars} out of 5 stars`,children:te(t.stars)}),(0,p.jsxs)(`div`,{style:{padding:`0 12px 8px 12px`,fontFamily:`Arial, Helvetica, sans-serif`},children:[e.showOldPrice&&t.oldPrice&&(0,p.jsx)(`span`,{className:`old_price`,style:{color:l,textDecoration:`line-through`,fontSize:14,marginRight:8},children:t.oldPrice}),(0,p.jsx)(`span`,{className:`final_price`,style:{color:c,fontWeight:`bold`,fontSize:18},children:t.finalPrice})]}),e.showDescription&&t.description&&(0,p.jsx)(`div`,{style:{padding:`0 12px 8px 12px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:13,color:`#6B7280`,lineHeight:1.5},children:t.description}),e.showButton&&(0,p.jsx)(`div`,{style:{padding:`4px 12px 12px 12px`,textAlign:`center`,marginTop:`auto`},children:(0,p.jsx)(`span`,{style:{display:`inline-block`,padding:`10px 18px`,fontFamily:`Arial, Helvetica, sans-serif`,fontSize:13,fontWeight:`bold`,color:d,backgroundColor:u,borderRadius:6},children:t.buttonLabel??e.buttonLabel??`Shop now`})})]},t.id))})}var pa=null,ma=new Set,ha=0;function ga(){ha+=1;for(let e of ma)e()}function _a(e){pa!==e&&(pa=e,ga())}function va(){return pa}var ya=e=>(ma.add(e),()=>{ma.delete(e)}),ba=()=>ha,xa=null,Sa={status:`idle`,vouchers:[]},Ca=null,wa=new Set,Ta=0;function Ea(){Ta+=1;for(let e of wa)e()}function Da(e){xa!==e&&(xa=e,Sa={status:`idle`,vouchers:[]},Ca=null,Ea())}function Oa(){return xa}function ka(){return Sa}function Aa(e=!1){if(!xa)return Promise.resolve([]);if(!e&&Sa.status===`loaded`)return Promise.resolve(Sa.vouchers);if(Ca)return Ca;Sa={status:`loading`,vouchers:Sa.vouchers},Ea();let t=xa.list().then(e=>(Sa={status:`loaded`,vouchers:Array.isArray(e)?e:[]},Ca=null,Ea(),Sa.vouchers)).catch(e=>(Sa={status:`error`,vouchers:[],error:e instanceof Error?e.message:String(e)},Ca=null,Ea(),[]));return Ca=t,t}var ja=e=>(wa.add(e),()=>{wa.delete(e)}),Ma=()=>Ta,Na=[],Pa=null,Fa={registerModule:e=>Ue.register(e),registerTheme:e=>Na.push(e),registerAssetProvider:e=>{Pa=e},registerProductProvider:e=>{_a(e)},registerVoucherProvider:e=>{Da(e)},setAIProvider:e=>{Ye(e)},registerMergeTags:e=>Fi(e)};function Ia(e){e.setup(Fa)}function La(){return Pa}var Ra={key:`days`,label:`Time window`,type:`select`,default:7,options:[{value:7,label:`Last 7 days`},{value:14,label:`Last 14 days`},{value:30,label:`Last 30 days`}]},za=[{id:`abandoned-cart`,label:`Abandoned basket products`,group:`behavioral`},{id:`bestseller-conversion`,label:`Best seller by Conversion`,group:`catalog`,params:[Ra]},{id:`bestseller-units`,label:`Best seller by Units`,group:`catalog`,params:[Ra]},{id:`new-products`,label:`New items added`,group:`catalog`,params:[Ra]},{id:`cross-sell`,label:`Products Cross-Sell`,group:`contextual`},{id:`upsell`,label:`Products Upsell`,group:`contextual`},{id:`viewed-categories`,label:`Items from viewed categories`,group:`behavioral`},{id:`viewed-items`,label:`Items viewed`,group:`behavioral`},{id:`similar-basket`,label:`Similar to basket items`,group:`behavioral`},{id:`bought-together`,label:`Items bought together`,group:`contextual`},{id:`best-discount`,label:`Items with the best discount`,group:`catalog`},{id:`match-data`,label:`Items matching specific attributes`,group:`catalog`},{id:`last-purchased`,label:`Last purchased items`,group:`personal`},{id:`similar-to-purchased`,label:`Similar to last purchase`,group:`personal`},{id:`cross-sell-purchased`,label:`Cross-sell to last purchase`,group:`personal`},{id:`similar-items`,label:`Similar items`,group:`contextual`}],Ba=Object.fromEntries(za.map(e=>[e.id,e])),Va=[{value:`smart-reccs`,label:`Smart Recommendations`,description:`Best generic algorithm — recommended default.`},{value:`random`,label:`Random items (strict filters)`,description:`Random items that still pass include/exclude filters.`},{value:`ignore`,label:`Ignore position`,description:`Skip the slot if no items found.`},{value:`stop`,label:`Don't display`,description:`Don't render the email if the slot can't be filled.`}];function Ha(e=2){return{mode:`recommender`,noProducts:e,sourceFeed:``,manualProducts:[],stack:[{algorithm:`abandoned-cart`}],fallback:`smart-reccs`,filters:{includeProducts:[],excludeProducts:[],includeCategories:[],excludeCategories:[],minStock:0,minPrice:0,mainOnly:!1,higherPrice:!1,salesPrice:!1,sameCategory:!1,matchTitle:!1,sameField:``}}}function Ua(e){if(!e)return null;let t=e.recommendations;return!t||typeof t!=`object`?null:t}function Wa(e){return e?.children?e.children.some(e=>e.type===`productGrid`):!1}function Ga(e){if(!e?.children)return 0;let t=0;for(let n of e.children)n.type===`productGrid`&&(t+=n.products.length);return t}function Ka(e){return{params:{selection:e.mode===`manual`?`manual`:`recommender`,include:{item:e.filters.includeProducts,category:e.filters.includeCategories},exclude:{item:e.filters.excludeProducts,category:e.filters.excludeCategories},higherPrice:e.filters.higherPrice??!1,salesPrice:e.filters.salesPrice??!1,sameCategory:e.filters.sameCategory??!1,matchTitle:e.filters.matchTitle??!1,sameField:e.filters.sameField??``,mainOnly:e.filters.mainOnly??!1},noProducts:String(e.noProducts),fallback:e.fallback,stack:e.mode===`manual`?[]:e.stack,minStock:String(e.filters.minStock??0),minPrice:String(e.filters.minPrice??0),sourceFeed:e.sourceFeed??``,manualProducts:e.manualProducts}}function qa({mod:e}){let t=M(e=>e.updateModule),n=Ga(e)||2,r=Ua(e.data)??Ha(n),i=n=>{let i={...r,...n};t(e.id,{data:{...e.data??{},recommendations:i}})};return(0,p.jsxs)(`div`,{className:`border border-blue-200 rounded-lg bg-blue-50/40 mt-4 overflow-hidden`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 flex items-center gap-2 border-b border-blue-200 bg-blue-50`,children:[(0,p.jsx)(f.Sparkles,{size:14,className:`text-blue-700`}),(0,p.jsx)(`div`,{className:`text-xs font-semibold text-blue-900 uppercase tracking-wide`,children:`Products Source`})]}),(0,p.jsx)(`div`,{className:`p-3 bg-white border-b border-blue-100`,children:(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Za,{active:r.mode===`manual`,title:`Select Items`,subtitle:`Hand-pick from a feed`,onClick:()=>i({mode:`manual`})}),(0,p.jsx)(Za,{active:r.mode===`recommender`,title:`Recommender`,subtitle:`Algorithms + filters`,onClick:()=>i({mode:`recommender`})})]})}),(0,p.jsxs)(`div`,{className:`p-3 bg-white space-y-3`,children:[(0,p.jsxs)($a,{label:`Number of products`,children:[(0,p.jsx)(`input`,{type:`number`,min:1,max:20,value:r.noProducts,onChange:e=>i({noProducts:Number(e.target.value)||1}),className:Xa}),(0,p.jsxs)(`div`,{className:`text-[11px] text-gray-500 mt-1`,children:[`Block has `,n,` slot`,n===1?``:`s`,` in the design.`]})]}),r.mode===`manual`?(0,p.jsx)(Ja,{logic:r,update:i}):(0,p.jsx)(Ya,{logic:r,update:i,updateFilters:e=>i({filters:{...r.filters,...e}})}),(0,p.jsxs)(`details`,{className:`border border-gray-200 rounded`,children:[(0,p.jsx)(`summary`,{className:`px-2 py-1.5 text-[11px] font-medium text-gray-600 cursor-pointer select-none`,children:`View saved JSON`}),(0,p.jsx)(`pre`,{className:`text-[10px] bg-gray-900 text-gray-100 p-2 overflow-auto max-h-60 leading-tight`,children:JSON.stringify(r,null,2)})]})]})]})}function Ja({logic:e,update:t}){return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)($a,{label:`Source feed`,children:(0,p.jsx)(`input`,{type:`text`,placeholder:`e.g. main-catalog`,value:e.sourceFeed??``,onChange:e=>t({sourceFeed:e.target.value}),className:Xa})}),(0,p.jsx)($a,{label:`Items to include (product IDs / SKUs)`,children:(0,p.jsx)(io,{value:e.manualProducts,onChange:e=>t({manualProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)(`div`,{className:`text-[11px] text-gray-500`,children:`Items are sent to the renderer as-is in the order shown.`})]})}function Ya({logic:e,update:t,updateFilters:n}){let[r,i]=(0,l.useState)(!1);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,p.jsxs)(`label`,{className:`text-xs font-medium text-gray-700`,children:[`Algorithms (max `,3,`)`]}),(0,p.jsx)(ro,{disabled:e.stack.length>=3,existing:e.stack.map(e=>e.algorithm),onPick:n=>t({stack:[...e.stack,{algorithm:n}]})})]}),(0,p.jsx)(no,{stack:e.stack,onChange:e=>t({stack:e})})]}),(0,p.jsxs)($a,{label:`Fallback`,children:[(0,p.jsx)(`select`,{value:e.fallback,onChange:e=>t({fallback:e.target.value}),className:Xa,children:Va.map(e=>(0,p.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,p.jsx)(`div`,{className:`text-[11px] text-gray-500 mt-1`,children:Va.find(t=>t.value===e.fallback)?.description})]}),(0,p.jsx)(Qa,{title:`Include & Exclude filters`,right:(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(eo,{active:!r,onClick:()=>i(!1),children:`Basic`}),(0,p.jsx)(eo,{active:r,onClick:()=>i(!0),children:`Advanced`})]})}),(0,p.jsx)($a,{label:`Exclude products`,children:(0,p.jsx)(io,{value:e.filters.excludeProducts,onChange:e=>n({excludeProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)($a,{label:`Include products`,children:(0,p.jsx)(io,{value:e.filters.includeProducts,onChange:e=>n({includeProducts:e}),placeholder:`Add product id`})}),(0,p.jsx)($a,{label:`Exclude categories`,children:(0,p.jsx)(io,{value:e.filters.excludeCategories,onChange:e=>n({excludeCategories:e}),placeholder:`Add category`})}),(0,p.jsx)($a,{label:`Include categories`,children:(0,p.jsx)(io,{value:e.filters.includeCategories,onChange:e=>n({includeCategories:e}),placeholder:`Add category`})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)($a,{label:`Minimum stock`,children:(0,p.jsx)(`input`,{type:`number`,min:0,value:e.filters.minStock??0,onChange:e=>n({minStock:Number(e.target.value)||0}),className:Xa})}),(0,p.jsx)($a,{label:`Minimum price`,children:(0,p.jsx)(`input`,{type:`number`,min:0,value:e.filters.minPrice??0,onChange:e=>n({minPrice:Number(e.target.value)||0}),className:Xa})})]}),(0,p.jsx)(to,{label:`Only main items`,checked:!!e.filters.mainOnly,onChange:e=>n({mainOnly:e})}),(0,p.jsx)(to,{label:`Higher price than current item (upsell)`,checked:!!e.filters.higherPrice,onChange:e=>n({higherPrice:e})}),(0,p.jsx)(to,{label:`On sale only`,checked:!!e.filters.salesPrice,onChange:e=>n({salesPrice:e})}),(0,p.jsx)(to,{label:`Same category as current`,checked:!!e.filters.sameCategory,onChange:e=>n({sameCategory:e})}),(0,p.jsx)(to,{label:`Match title keywords`,checked:!!e.filters.matchTitle,onChange:e=>n({matchTitle:e})}),(0,p.jsx)($a,{label:`Match same fields (comma-separated)`,children:(0,p.jsx)(`input`,{type:`text`,placeholder:`brand, color`,value:e.filters.sameField??``,onChange:e=>n({sameField:e.target.value}),className:Xa})}),r&&(0,p.jsx)($a,{label:`Advanced JSON overrides`,children:(0,p.jsx)(ao,{value:e.filters.advanced??{},onChange:e=>n({advanced:e})})})]})}var Xa=`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`;function Za({active:e,icon:t,title:n,subtitle:r,onClick:i}){return(0,p.jsxs)(`button`,{onClick:i,className:`flex flex-col items-start gap-0.5 p-2.5 rounded border text-left transition `+(e?`border-teal-600 bg-teal-50 ring-1 ring-teal-600`:`border-gray-200 bg-white hover:border-gray-300`),children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5 `+(e?`text-teal-700`:`text-gray-700`),children:[t,(0,p.jsx)(`span`,{className:`text-xs font-semibold`,children:n})]}),(0,p.jsx)(`span`,{className:`text-[10px] text-gray-500`,children:r})]})}function Qa({title:e,right:t}){return(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-t border-gray-200 pt-3 mt-3`,children:[(0,p.jsx)(`div`,{className:`text-[11px] font-semibold uppercase tracking-wide text-gray-600`,children:e}),t]})}function $a({label:e,children:t}){return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`label`,{className:`block text-xs font-medium text-gray-700 mb-1`,children:e}),t]})}function eo({active:e,onClick:t,children:n}){return(0,p.jsx)(`button`,{onClick:t,className:`px-2 py-0.5 rounded text-[10px] font-semibold uppercase tracking-wide `+(e?`bg-teal-600 text-white`:`bg-gray-100 text-gray-600 hover:bg-gray-200`),children:n})}function to({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`label`,{className:`flex items-center justify-between gap-2 text-xs text-gray-700 py-1`,children:[(0,p.jsx)(`span`,{children:e}),(0,p.jsx)(`input`,{type:`checkbox`,checked:t,onChange:e=>n(e.target.checked),className:`h-4 w-4 accent-teal-600`})]})}function no({stack:e,onChange:t}){if(e.length===0)return(0,p.jsxs)(`div`,{className:`text-[11px] text-gray-500 italic border border-dashed border-gray-300 rounded px-2 py-3 text-center`,children:[`No algorithms yet. Click `,(0,p.jsx)(`b`,{children:`Add algorithm`}),` to start.`]});let n=(n,r)=>{let i=n+r;if(i<0||i>=e.length)return;let a=e.slice();[a[n],a[i]]=[a[i],a[n]],t(a)},r=n=>t(e.filter((e,t)=>t!==n)),i=(n,r,i)=>{let a=e.slice();a[n]={...a[n],params:{...a[n].params??{},[r]:i}},t(a)};return(0,p.jsx)(`div`,{className:`space-y-1.5`,children:e.map((t,a)=>{let o=Ba[t.algorithm];return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded px-2 py-1.5 bg-white flex flex-col gap-1`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,p.jsx)(`span`,{className:`flex-1 text-xs text-gray-800 truncate`,children:o?.label??t.algorithm}),(0,p.jsx)(`button`,{title:`Move up`,onClick:()=>n(a,-1),disabled:a===0,className:`p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30`,children:(0,p.jsx)(f.ChevronUp,{size:13})}),(0,p.jsx)(`button`,{title:`Move down`,onClick:()=>n(a,1),disabled:a===e.length-1,className:`p-1 text-gray-400 hover:text-gray-700 disabled:opacity-30`,children:(0,p.jsx)(f.ChevronDown,{size:13})}),(0,p.jsx)(`button`,{title:`Remove`,onClick:()=>r(a),className:`p-1 text-gray-400 hover:text-red-600`,children:(0,p.jsx)(f.Trash2,{size:13})})]}),o?.params?.map(e=>(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`text-[10px] text-gray-500 w-20 shrink-0`,children:e.label}),e.type===`select`?(0,p.jsx)(`select`,{value:String(t.params?.[e.key]??e.default??``),onChange:t=>i(a,e.key,t.target.value),className:`flex-1 text-xs border border-gray-200 rounded px-1.5 py-1 bg-white`,children:e.options?.map(e=>(0,p.jsx)(`option`,{value:String(e.value),children:e.label},String(e.value)))}):(0,p.jsx)(`input`,{type:e.type===`number`?`number`:`text`,value:String(t.params?.[e.key]??e.default??``),onChange:t=>i(a,e.key,e.type===`number`?Number(t.target.value):t.target.value),className:`flex-1 text-xs border border-gray-200 rounded px-1.5 py-1`})]},e.key))]},a)})})}function ro({disabled:e,existing:t,onPick:n}){let[r,i]=(0,l.useState)(!1);return(0,p.jsxs)(`div`,{className:`relative`,children:[(0,p.jsxs)(`button`,{disabled:e,onClick:()=>i(e=>!e),className:`flex items-center gap-1 px-2 py-1 rounded text-[11px] font-semibold uppercase `+(e?`bg-gray-200 text-gray-400 cursor-not-allowed`:`bg-teal-600 text-white hover:bg-teal-700`),children:[(0,p.jsx)(f.Plus,{size:12}),` Add`]}),r&&!e&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`div`,{className:`fixed inset-0 z-10`,onClick:()=>i(!1)}),(0,p.jsx)(`div`,{className:`absolute right-0 top-full mt-1 w-64 max-h-80 overflow-auto bg-white border border-gray-200 rounded shadow-lg z-20`,children:za.map(e=>{let r=t.includes(e.id);return(0,p.jsxs)(`button`,{disabled:r,onClick:()=>{n(e.id),i(!1)},className:`block w-full text-left px-2.5 py-1.5 text-xs `+(r?`text-gray-400 cursor-not-allowed`:`text-gray-700 hover:bg-teal-50 hover:text-teal-700`),children:[e.label,r&&(0,p.jsx)(`span`,{className:`ml-1 text-[10px]`,children:`· added`})]},e.id)})})]})]})}function io({value:e,onChange:t,placeholder:n}){let[r,i]=(0,l.useState)(``),a=()=>{let n=r.trim();n&&(e.includes(n)||(t([...e,n]),i(``)))};return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded bg-white p-1 flex flex-wrap items-center gap-1 focus-within:border-blue-500`,children:[e.map(n=>(0,p.jsxs)(`span`,{className:`inline-flex items-center gap-1 bg-gray-100 text-gray-800 text-[11px] rounded px-1.5 py-0.5`,children:[n,(0,p.jsx)(`button`,{onClick:()=>t(e.filter(e=>e!==n)),className:`text-gray-500 hover:text-red-600`,children:(0,p.jsx)(f.X,{size:10})})]},n)),(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onKeyDown:n=>{n.key===`Enter`||n.key===`,`?(n.preventDefault(),a()):n.key===`Backspace`&&!r&&e.length&&t(e.slice(0,-1))},onBlur:a,placeholder:e.length===0?n:``,className:`flex-1 min-w-20 outline-none text-xs bg-transparent px-1 py-0.5`})]})}function ao({value:e,onChange:t}){let[n,r]=(0,l.useState)(()=>JSON.stringify(e,null,2)),[i,a]=(0,l.useState)(null);return(0,p.jsxs)(`div`,{children:[(0,p.jsx)(`textarea`,{value:n,onChange:e=>{let n=e.target.value;r(n);try{let e=JSON.parse(n||`{}`);a(null),t(e)}catch(e){a(String(e.message))}},rows:6,spellCheck:!1,className:`w-full font-mono text-[11px] border border-gray-200 rounded p-2 bg-gray-50 focus:border-blue-500 focus:outline-none`}),i&&(0,p.jsx)(`div`,{className:`text-[10px] text-red-600 mt-1`,children:i})]})}function oo(){(0,l.useSyncExternalStore)(ja,Ma,Ma);let e=Oa()!==null,t=ka();return(0,l.useEffect)(()=>{e&&t.status===`idle`&&Aa()},[e,t.status]),{available:e,status:t.status,vouchers:t.vouchers,error:t.error,reload:()=>void Aa(!0)}}function so(e){return e?.children?.find(e=>e.type===`text`&&e.role===`voucherCode`)}function co(e){return!!so(e)}function lo(e){let t=e?.data?.voucher;return t&&typeof t==`object`&&`code`in t?t:null}function uo(e){return{id:e.id,title:e.title,code:e.code}}function fo({mod:e}){let t=M(e=>e.updateElement),n=M(e=>e.updateModule),{available:r,status:i,vouchers:a,error:o,reload:s}=oo(),c=so(e),l=lo(e),u=l&&a.some(e=>e.id===l.id)?l.id:``,d=r=>{if(!r){n(e.id,{data:{...e.data??{},voucher:void 0}});return}c&&t(e.id,c.id,{content:r.code}),n(e.id,{data:{...e.data??{},voucher:uo(r)}})};return(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(`h3`,{className:`flex items-center gap-1.5 text-xs font-semibold uppercase tracking-wide text-gray-500`,children:[(0,p.jsx)(f.Ticket,{size:13,className:`text-blue-600`}),` Voucher`]}),r&&(0,p.jsxs)(`button`,{type:`button`,onClick:s,disabled:i===`loading`,className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded disabled:opacity-50`,title:`Reload vouchers`,children:[i===`loading`?(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}):(0,p.jsx)(f.RefreshCw,{size:12}),`Reload`]})]}),r?(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`label`,{className:`block mb-2`,children:[(0,p.jsx)(`span`,{className:`block text-xs text-gray-600 mb-1`,children:`Select voucher`}),(0,p.jsxs)(`select`,{value:u,disabled:i===`loading`&&a.length===0,onChange:e=>{let t=a.find(t=>t.id===e.target.value)??null;d(t)},className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded bg-white focus:border-blue-500 focus:outline-none disabled:bg-gray-50`,children:[(0,p.jsx)(`option`,{value:``,children:i===`loading`&&a.length===0?`Loading vouchers…`:`Please select a voucher…`}),a.map(e=>(0,p.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),i===`error`&&(0,p.jsxs)(`p`,{className:`flex items-start gap-1 text-[11px] text-red-600 mb-2`,children:[(0,p.jsx)(f.AlertTriangle,{size:12,className:`mt-0.5 shrink-0`}),o??`Failed to load vouchers.`]}),i===`loaded`&&a.length===0&&(0,p.jsx)(`p`,{className:`text-[11px] text-gray-400 mb-2`,children:`No vouchers found.`}),l&&(0,p.jsxs)(`div`,{className:`rounded border border-green-200 bg-green-50 px-2.5 py-2 text-[12px] text-green-800`,children:[`Voucher code: `,(0,p.jsx)(`span`,{className:`font-semibold`,children:l.code})]})]}):(0,p.jsxs)(`p`,{className:`text-[11px] text-gray-400`,children:[`Register a voucher provider (`,(0,p.jsx)(`code`,{children:`voucherPlugin`}),`) to pick codes from your catalog. You can still edit the code text directly.`]})]})}function po({open:e,onClose:t,onSave:n,initialQuery:r,title:i}){let[a,o]=(0,l.useState)(r??``),[s,c]=(0,l.useState)(!1),[u,d]=(0,l.useState)(null),[m,h]=(0,l.useState)(null),[g,_]=(0,l.useState)(!1),v=(0,l.useRef)(null);if((0,l.useEffect)(()=>{if(!e)return;o(r??``),h(null),d(null),_(!1);let n=setTimeout(()=>v.current?.focus(),40),i=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,i),()=>{clearTimeout(n),window.removeEventListener(`keydown`,i)}},[e,r,t]),!e)return null;let y=async()=>{let e=va(),t=a.trim();if(!(!e||!t||s)){c(!0),d(null),h(null),_(!0);try{let n=await e.search(t);h(n)}catch(e){d(e instanceof Error?e.message:String(e))}finally{c(!1)}}};return(0,p.jsx)(`div`,{className:`fixed inset-0 z-50 flex bg-black/60 backdrop-blur-sm p-4`,children:(0,p.jsxs)(`div`,{className:`m-auto flex max-h-[90vh] w-full max-w-lg flex-col overflow-hidden rounded-2xl bg-white shadow-2xl`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between border-b border-neutral-200 px-5 py-4`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(f.PackageSearch,{size:18,className:`text-blue-600`}),(0,p.jsx)(`h2`,{className:`text-base font-semibold text-neutral-900`,children:i??`Find a product`})]}),(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg p-1.5 text-neutral-500 hover:bg-neutral-100 hover:text-neutral-900`,"aria-label":`Close`,children:(0,p.jsx)(f.X,{size:18})})]}),(0,p.jsx)(`div`,{className:`border-b border-neutral-100 px-5 py-3`,children:(0,p.jsxs)(`form`,{className:`flex gap-2`,onSubmit:e=>{e.preventDefault(),y()},children:[(0,p.jsxs)(`div`,{className:`relative flex-1`,children:[(0,p.jsx)(f.Search,{size:15,className:`pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-neutral-400`}),(0,p.jsx)(`input`,{ref:v,value:a,onChange:e=>o(e.target.value),placeholder:`Search your catalog by name or SKU…`,className:`w-full rounded-lg border border-neutral-200 bg-white py-2 pl-9 pr-3 text-sm outline-none focus:border-blue-500`})]}),(0,p.jsxs)(`button`,{type:`submit`,disabled:s||!a.trim(),className:`flex shrink-0 items-center gap-1.5 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700 disabled:bg-neutral-300`,children:[s?(0,p.jsx)(f.Loader2,{size:15,className:`animate-spin`}):(0,p.jsx)(f.Search,{size:15}),`Search`]})]})}),(0,p.jsxs)(`div`,{className:`min-h-[220px] flex-1 overflow-y-auto p-5`,children:[s&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-sm text-neutral-500`,children:[(0,p.jsx)(f.Loader2,{size:22,className:`animate-spin`}),`Searching…`]}),!s&&u&&(0,p.jsx)(`div`,{className:`rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700`,children:u}),!s&&!u&&g&&!m&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-center text-sm text-neutral-500`,children:[(0,p.jsx)(f.PackageSearch,{size:22,className:`text-neutral-300`}),`No product matched “`,a.trim(),`”. Try another name or SKU.`]}),!s&&!u&&!g&&(0,p.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 py-10 text-center text-sm text-neutral-400`,children:[(0,p.jsx)(f.PackageSearch,{size:22,className:`text-neutral-300`}),`Search your catalog, then preview and save the product.`]}),!s&&m&&(0,p.jsx)(mo,{result:m})]}),(0,p.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-neutral-200 px-5 py-3`,children:[(0,p.jsx)(`button`,{onClick:t,className:`rounded-lg px-4 py-2 text-sm font-medium text-neutral-600 hover:bg-neutral-100`,children:`Cancel`}),(0,p.jsxs)(`button`,{onClick:()=>{m&&(n(m),t())},disabled:!m,className:`flex items-center gap-1.5 rounded-lg bg-green-600 px-4 py-2 text-sm font-medium text-white hover:bg-green-700 disabled:bg-neutral-300`,children:[(0,p.jsx)(f.Check,{size:15}),` Save product`]})]})]})})}function mo({result:e}){return(0,p.jsxs)(`div`,{className:`overflow-hidden rounded-xl border border-neutral-200`,children:[(0,p.jsx)(`div`,{className:`aspect-video w-full overflow-hidden bg-neutral-100`,children:e.image?(0,p.jsx)(`img`,{src:e.image,alt:e.imageAlt??e.name,className:`h-full w-full object-contain`}):(0,p.jsx)(`div`,{className:`grid h-full place-items-center text-xs text-neutral-400`,children:`No image`})}),(0,p.jsxs)(`div`,{className:`flex flex-col gap-2 p-4`,children:[(0,p.jsx)(`div`,{className:`text-sm font-semibold text-neutral-900`,children:e.name}),e.stars!=null&&(0,p.jsxs)(`div`,{className:`flex items-center gap-0.5`,"aria-label":`${e.stars} out of 5`,children:[Array.from({length:5}).map((t,n)=>(0,p.jsx)(f.Star,{size:14,className:n<Math.round(e.stars??0)?`fill-amber-400 text-amber-400`:`text-neutral-300`},n)),(0,p.jsx)(`span`,{className:`ml-1 text-xs text-neutral-500`,children:e.stars})]}),(0,p.jsxs)(`div`,{className:`flex items-baseline gap-2`,children:[e.oldPrice&&(0,p.jsx)(`span`,{className:`text-sm text-neutral-400 line-through`,children:e.oldPrice}),(0,p.jsx)(`span`,{className:`text-lg font-bold text-blue-600`,children:e.finalPrice})]}),e.description&&(0,p.jsx)(`p`,{className:`text-xs leading-relaxed text-neutral-600`,children:e.description}),e.link&&(0,p.jsxs)(`a`,{href:e.link,target:`_blank`,rel:`noreferrer`,className:`inline-flex w-fit items-center gap-1 text-xs text-blue-600 hover:underline`,children:[(0,p.jsx)(f.ExternalLink,{size:12}),` View source`]})]})]})}function ho(){return(0,l.useSyncExternalStore)(ya,ba,ba),va()!==null}function go(){let{selection:e,doc:t,viewMode:n}=M(),[r,i]=(0,l.useState)(!0),[a,o]=(0,l.useState)(!1);return r?(0,p.jsxs)(`div`,{className:`${a?`w-[576px]`:`w-72`} bg-white border-l border-gray-200 shrink-0 overflow-y-auto flex flex-col transition-all duration-200`,children:[(0,p.jsxs)(`div`,{className:`px-3 py-2 text-[11px] flex items-center gap-1.5 border-b shrink-0 ${n===`mobile`?`bg-amber-50 text-amber-800 border-amber-200`:`bg-blue-50 text-blue-800 border-blue-100`}`,children:[n===`mobile`?(0,p.jsx)(f.Smartphone,{size:12}):(0,p.jsx)(f.Monitor,{size:12}),(0,p.jsxs)(`span`,{className:`flex-1`,children:[`Editing `,n,` styles`]}),(0,p.jsx)(`button`,{onClick:()=>o(!a),title:a?`Narrow panel`:`Expand panel`,className:`p-0.5 rounded hover:bg-black/10 transition-colors ${n===`mobile`?`text-amber-700 hover:text-amber-900`:`text-blue-700 hover:text-blue-900`}`,children:a?(0,p.jsx)(f.ChevronsRight,{size:13}):(0,p.jsx)(f.ChevronsLeft,{size:13})}),(0,p.jsx)(`button`,{onClick:()=>i(!1),title:`Hide properties`,className:`p-0.5 rounded hover:bg-black/10 transition-colors ${n===`mobile`?`text-amber-700 hover:text-amber-900`:`text-blue-700 hover:text-blue-900`}`,children:(0,p.jsx)(f.PanelRightClose,{size:13})})]}),(0,p.jsx)(`div`,{className:`p-4 flex-1`,children:!e||e.kind===`email`?(0,p.jsx)(Do,{}):e.kind===`module`?(()=>{let n=t.modules.find(t=>t.id===e.moduleId);return n?(0,p.jsx)(Ao,{mod:n}):(0,p.jsx)(_o,{})})():(()=>{let n=t.modules.find(t=>t.id===e.moduleId),r=n?.children.find(t=>t.id===e.elementId);return n&&r?(0,p.jsx)(jo,{mod:n,el:r}):(0,p.jsx)(_o,{})})()})]}):(0,p.jsx)(`div`,{className:`flex flex-col items-center w-6 bg-white border-l border-gray-200 shrink-0`,children:(0,p.jsx)(`button`,{onClick:()=>i(!0),title:`Show properties`,className:`flex items-center justify-center w-full py-3 text-gray-400 hover:text-gray-600 hover:bg-gray-50 transition-colors`,children:(0,p.jsx)(f.PanelRightOpen,{size:14})})})}function _o(){return(0,p.jsx)(`div`,{className:`text-xs text-gray-400`,children:`Nothing selected.`})}function vo(e,t){if(t!==`mobile`)return e;let n=e.mobile??{};return{...e,...n}}function yo(e,t,n){if(n!==`mobile`)return{...e,...t};let r=e.mobile??{};return{...e,mobile:{...r,...t}}}function bo({overridden:e}){return e?(0,p.jsx)(`span`,{className:`ml-1 text-[9px] uppercase tracking-wide bg-amber-100 text-amber-800 px-1 rounded`,children:`mobile`}):null}function xo({hideOn:e,onChange:t}){return(0,p.jsx)(Z,{label:`Visibility`,children:(0,p.jsxs)(To,{value:e??``,onChange:e=>{let n=e.target.value;t(n===``?void 0:n)},children:[(0,p.jsx)(`option`,{value:``,children:`Show on all`}),(0,p.jsx)(`option`,{value:`mobile`,children:`Hide on mobile`}),(0,p.jsx)(`option`,{value:`desktop`,children:`Hide on desktop`})]})})}function So({children:e}){return(0,p.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500 mb-3`,children:e})}function Z({label:e,children:t}){return(0,p.jsxs)(`label`,{className:`block mb-3`,children:[(0,p.jsx)(`span`,{className:`flex items-center text-xs text-gray-600 mb-1`,children:e}),t]})}function Q(e){return(0,p.jsx)(`input`,{...e,className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none`})}function $(e){return(0,p.jsx)(Q,{type:`number`,...e})}function Co({value:e,onChange:t,onAlt:n}){let r=La(),i=(0,l.useRef)(null),[a,o]=(0,l.useState)(!1),[s,c]=(0,l.useState)(null),u=async e=>{if(r){o(!0),c(null);try{let i=await r.upload(e);t(i.url),i.alt&&n&&n(i.alt)}catch(e){c(e instanceof Error?e.message:String(e))}finally{o(!1),i.current&&(i.current.value=``)}}};return(0,p.jsxs)(`div`,{children:[(0,p.jsxs)(`div`,{className:`flex gap-1`,children:[(0,p.jsx)(Q,{value:e??``,onChange:e=>t(e.target.value)}),r&&(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(`input`,{ref:i,type:`file`,accept:`image/*`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&u(t)}}),(0,p.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>i.current?.click(),className:`shrink-0 px-2 py-1.5 text-xs border border-gray-200 rounded hover:bg-gray-50 disabled:opacity-50 flex items-center gap-1`,title:`Upload image`,children:a?(0,p.jsx)(f.Loader2,{size:12,className:`animate-spin`}):(0,p.jsx)(f.Upload,{size:12})})]})]}),s&&(0,p.jsx)(`p`,{className:`text-[10px] text-red-600 mt-1`,children:s}),!r&&(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:`Tip: register an image uploader plugin to enable file uploads.`})]})}function wo({value:e,onChange:t,defaultValue:n}){let r=M(e=>e.doc.theme),i=typeof e==`string`&&e.startsWith(`{`),a=(0,l.useRef)(n&&n.startsWith(`{`)?n:i?e:void 0);(0,l.useEffect)(()=>{i?a.current=e:n&&n.startsWith(`{`)&&(a.current=n)},[e,i,n]);let o=(()=>{let t=x(e,r);return typeof t==`string`&&/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)?t.length===4?`#`+t.slice(1).split(``).map(e=>e+e).join(``):t:`#000000`})(),s=n??a.current,c=!!s&&s!==e,[u,d]=(0,l.useState)(e??``);return(0,l.useEffect)(()=>d(e??``),[e]),(0,p.jsxs)(`div`,{className:`flex gap-1 items-center`,children:[(0,p.jsxs)(`label`,{className:`relative w-9 h-8 border border-gray-200 rounded cursor-pointer overflow-hidden shrink-0`,title:i?`Token → ${o} (click to override)`:`Pick color`,style:{background:o},children:[(0,p.jsx)(`input`,{type:`color`,value:o,onChange:e=>t(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer`}),i&&(0,p.jsx)(`span`,{className:`absolute inset-0 pointer-events-none border-2 border-dashed rounded`,style:{borderColor:`rgba(255,255,255,0.6)`}})]}),(0,p.jsx)(`input`,{value:u,onChange:e=>d(e.target.value),onBlur:()=>u!==e&&t(u),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`}),c&&(0,p.jsx)(`button`,{type:`button`,onClick:()=>t(s),className:`shrink-0 p-1.5 text-gray-400 hover:text-blue-600 hover:bg-blue-50 rounded`,title:`Reset to ${s}`,children:(0,p.jsx)(f.RotateCcw,{size:12})})]})}function To(e){return(0,p.jsx)(`select`,{...e,className:`w-full px-2 py-1.5 text-sm border border-gray-200 rounded focus:border-blue-500 focus:outline-none bg-white`})}function Eo({linkType:e,onChangeLinkType:t,onChangeLink:n}){return(0,p.jsxs)(Z,{label:`Link role`,children:[(0,p.jsxs)(To,{value:e??``,onChange:e=>{let r=e.target.value;r===``?t(void 0):(t(r),n(be[r]))},children:[(0,p.jsx)(`option`,{value:``,children:`— None —`}),(0,p.jsx)(`option`,{value:`unsubscribe`,children:`Unsubscribe`}),(0,p.jsx)(`option`,{value:`view_in_browser`,children:`View in browser`}),(0,p.jsx)(`option`,{value:`manage_preferences`,children:`Manage preferences`}),(0,p.jsx)(`option`,{value:`user_profile`,children:`User profile`})]}),e&&(0,p.jsxs)(`p`,{className:`text-[10px] text-blue-600 mt-1 flex items-center gap-1`,children:[(0,p.jsx)(f.Tag,{size:10}),`Placeholder: `,(0,p.jsx)(`code`,{className:`font-mono`,children:be[e]})]})]})}function Do(){let{doc:e,updateMeta:t,updateSettings:n}=M();return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(So,{children:`Email`}),(0,p.jsx)(Z,{label:`Name`,children:(0,p.jsx)(Q,{value:e.meta.name,onChange:e=>t({name:e.target.value})})}),(0,p.jsx)(Z,{label:`Preview text`,children:(0,p.jsx)(Q,{value:e.meta.previewText,onChange:e=>t({previewText:e.target.value})})}),(0,p.jsx)(Z,{label:`Width (px)`,children:(0,p.jsx)($,{value:e.settings.width,onChange:e=>n({width:Number(e.target.value)||600})})}),(0,p.jsx)(Z,{label:`Background color`,children:(0,p.jsx)(wo,{value:e.settings.backgroundColor,onChange:e=>n({backgroundColor:e})})}),(0,p.jsx)(Z,{label:`Content background color`,children:(0,p.jsx)(wo,{value:e.settings.contentBackgroundColor,onChange:e=>n({contentBackgroundColor:e})})}),(0,p.jsx)(`div`,{className:`mt-6 pt-4 border-t border-gray-100`,children:(0,p.jsx)(Oo,{})})]})}function Oo(){let{doc:e,themes:t,applyTheme:n}=M(),r=e.theme,i=t.find(e=>e.id===r.id),a=i!=null&&Object.entries(r.tokens.colors).some(([e,t])=>i.tokens.colors[e]!==t),o=(e,t)=>{n({...r,tokens:{...r.tokens,colors:{...r.tokens.colors,[e]:t}}})};return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsx)(So,{children:`Theme`}),a&&(0,p.jsx)(`button`,{onClick:()=>i&&n(i),className:`text-[10px] text-blue-600 hover:underline mb-3`,title:`Discard color changes and restore the preset`,children:`Reset to preset`})]}),(0,p.jsx)(`div`,{className:`flex flex-col gap-1.5 mb-4`,children:t.map(e=>{let t=e.id===r.id;return(0,p.jsxs)(`button`,{onClick:()=>n(e),title:e.name,className:`flex items-center gap-2 px-2.5 py-2 rounded border text-xs transition-colors ${t?`border-blue-500 bg-blue-50 text-blue-700`:`border-gray-200 bg-white hover:border-gray-300 text-gray-700`}`,children:[(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.primary}}),(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.background}}),(0,p.jsx)(`span`,{className:`w-3 h-3 rounded-full shrink-0 ring-1 ring-black/10`,style:{background:e.tokens.colors.text}}),(0,p.jsx)(`span`,{className:`flex-1 text-left`,children:e.name}),t&&(0,p.jsx)(f.Check,{size:12,className:`text-blue-600 shrink-0`})]},e.id)})}),(0,p.jsxs)(`div`,{className:`text-xs font-semibold uppercase tracking-wide text-gray-500 mb-2`,children:[`Colors`,a&&(0,p.jsx)(`span`,{className:`ml-2 normal-case font-normal text-[10px] bg-amber-100 text-amber-700 px-1.5 py-0.5 rounded`,children:`customised`})]}),(0,p.jsx)(`div`,{className:`flex flex-col gap-2`,children:Object.entries(r.tokens.colors).map(([e,t])=>(0,p.jsx)(ko,{label:e,value:t,onChange:t=>o(e,t)},e))})]})}function ko({label:e,value:t,onChange:n}){let[r,i]=(0,l.useState)(t);(0,l.useEffect)(()=>i(t),[t]);let a=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t)?t.length===4?`#`+t.slice(1).split(``).map(e=>e+e).join(``):t:`#000000`,o=e=>{let t=e.trim();t&&n(t)};return(0,p.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,p.jsx)(`span`,{className:`text-xs text-gray-500 w-28 shrink-0 truncate`,title:e,children:e}),(0,p.jsx)(`label`,{className:`relative w-7 h-7 rounded border border-gray-200 cursor-pointer overflow-hidden shrink-0`,style:{background:a},title:`Pick ${e} color`,children:(0,p.jsx)(`input`,{type:`color`,value:a,onChange:e=>n(e.target.value),className:`absolute inset-0 opacity-0 cursor-pointer w-full h-full`})}),(0,p.jsx)(`input`,{value:r,onChange:e=>i(e.target.value),onBlur:()=>o(r),onKeyDown:e=>{e.key===`Enter`&&e.target.blur()},className:`flex-1 min-w-0 px-2 py-1 text-xs border border-gray-200 rounded focus:border-blue-500 focus:outline-none font-mono`,spellCheck:!1})]})}function Ao({mod:e}){let t=M(e=>e.updateModule),n=M(e=>e.viewMode),r=e.style??{},i=vo(r,n),a=new Set(Object.keys(r.mobile??{})),o=i=>t(e.id,{style:yo(r,i,n)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(So,{children:e.name}),(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Background color`,(0,p.jsx)(bo,{overridden:a.has(`backgroundColor`)})]}),children:(0,p.jsx)(wo,{value:i.backgroundColor??``,onChange:e=>o({backgroundColor:e})})}),(0,p.jsx)(Mo,{style:i,mobileKeys:a,onSet:o}),(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Border radius`,(0,p.jsx)(bo,{overridden:a.has(`borderRadius`)})]}),children:(0,p.jsx)($,{value:i.borderRadius??0,onChange:e=>o({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(xo,{hideOn:r.hideOn,onChange:n=>t(e.id,{style:{...r,hideOn:n}})}),Wa(e)&&(0,p.jsx)(qa,{mod:e}),co(e)&&(0,p.jsx)(fo,{mod:e})]})}function jo({mod:e,el:t}){switch(t.type){case`text`:return(0,p.jsx)(Po,{mod:e,el:t});case`image`:return(0,p.jsx)(Fo,{mod:e,el:t});case`button`:return(0,p.jsx)(Io,{mod:e,el:t});case`spacer`:return(0,p.jsx)(Lo,{mod:e,el:t});case`divider`:return(0,p.jsx)(Ro,{mod:e,el:t});case`productGrid`:return(0,p.jsx)(Bo,{mod:e,el:t})}}function Mo({style:e,mobileKeys:t,onSet:n}){return(0,p.jsx)(`div`,{className:`grid grid-cols-2 gap-2 mb-3`,children:[`paddingTop`,`paddingBottom`,`paddingLeft`,`paddingRight`].map(r=>(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[r.replace(`padding`,`Pad `),(0,p.jsx)(bo,{overridden:!!t?.has(r)})]}),children:(0,p.jsx)($,{value:e[r]??0,onChange:e=>n({[r]:Number(e.target.value)})})},r))})}function No(e,t){let n=M(e=>e.updateElement);return r=>n(e.id,t.id,r)}function Po({mod:e,el:t}){let n=No(e,t),r=M(e=>e.viewMode),i=t.style??{},a=vo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:yo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(So,{children:`Text block`}),(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mb-3 leading-relaxed`,children:`Click the text in the canvas to edit it inline. Select words to apply bold, italic, colour, links and more using the floating toolbar.`}),(0,p.jsx)(Z,{label:`Default align`,children:(0,p.jsxs)(To,{value:a.align??`left`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:`Line height`,children:(0,p.jsx)($,{step:.1,value:a.lineHeight??1.5,onChange:e=>s({lineHeight:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Letter spacing`,children:(0,p.jsx)($,{value:a.letterSpacing??0,onChange:e=>s({letterSpacing:Number(e.target.value)})})})]}),(0,p.jsx)(Mo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(xo,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function Fo({mod:e,el:t}){let n=No(e,t),r=M(e=>e.viewMode),i=t.style??{},a=vo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:yo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(So,{children:`Image`}),(0,p.jsx)(Z,{label:`Image URL`,children:(0,p.jsx)(Co,{value:t.src,onChange:e=>n({src:e}),onAlt:e=>n({alt:e})})}),(0,p.jsx)(Z,{label:`Alt text`,children:(0,p.jsx)(Q,{value:t.alt??``,onChange:e=>n({alt:e.target.value})})}),(0,p.jsx)(Z,{label:`Link`,children:(0,p.jsx)(Q,{value:t.link??``,onChange:e=>n({link:e.target.value})})}),(0,p.jsx)(Eo,{linkType:t.linkType,onChangeLinkType:e=>n({linkType:e}),onChangeLink:e=>n({link:e})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Width`,(0,p.jsx)(bo,{overridden:o.has(`width`)})]}),children:(0,p.jsx)($,{value:a.width??0,onChange:e=>s({width:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:(0,p.jsxs)(p.Fragment,{children:[`Height`,(0,p.jsx)(bo,{overridden:o.has(`height`)})]}),children:(0,p.jsx)($,{value:a.height??0,onChange:e=>s({height:Number(e.target.value)||void 0})})})]}),(0,p.jsx)(Z,{label:`Border radius`,children:(0,p.jsx)($,{value:a.borderRadius??0,onChange:e=>s({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Align`,children:(0,p.jsxs)(To,{value:a.align??`center`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsx)(Mo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(xo,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function Io({mod:e,el:t}){let n=No(e,t),r=M(e=>e.viewMode),i=t.style??{},a=vo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:yo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(So,{children:`Button`}),(0,p.jsx)(Z,{label:`Label`,children:(0,p.jsx)(Q,{value:t.label,onChange:e=>n({label:e.target.value})})}),(0,p.jsx)(Z,{label:`Link`,children:(0,p.jsx)(Q,{value:t.link,onChange:e=>n({link:e.target.value})})}),(0,p.jsx)(Eo,{linkType:t.linkType,onChangeLinkType:e=>n({linkType:e}),onChangeLink:e=>n({link:e})}),(0,p.jsx)(Z,{label:`Background color`,children:(0,p.jsx)(wo,{value:a.backgroundColor??``,onChange:e=>s({backgroundColor:e})})}),(0,p.jsx)(Z,{label:`Text color`,children:(0,p.jsx)(wo,{value:a.color??`#FFFFFF`,onChange:e=>s({color:e})})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:`Font size`,children:(0,p.jsx)($,{value:a.fontSize??16,onChange:e=>s({fontSize:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Border radius`,children:(0,p.jsx)($,{value:a.borderRadius??6,onChange:e=>s({borderRadius:Number(e.target.value)})})})]}),(0,p.jsx)(Z,{label:`Align`,children:(0,p.jsxs)(To,{value:a.align??`center`,onChange:e=>s({align:e.target.value}),children:[(0,p.jsx)(`option`,{value:`left`,children:`Left`}),(0,p.jsx)(`option`,{value:`center`,children:`Center`}),(0,p.jsx)(`option`,{value:`right`,children:`Right`})]})}),(0,p.jsx)(Mo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(xo,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function Lo({mod:e,el:t}){let n=No(e,t);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(So,{children:`Spacer`}),(0,p.jsx)(Z,{label:`Height (px)`,children:(0,p.jsx)($,{value:t.height,onChange:e=>n({height:Number(e.target.value)||0})})})]})}function Ro({mod:e,el:t}){let n=No(e,t),r=M(e=>e.viewMode),i=t.style??{},a=vo(i,r),o=new Set(Object.keys(i.mobile??{})),s=e=>n({style:yo(i,e,r)});return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(So,{children:`Divider`}),(0,p.jsx)(Z,{label:`Color`,children:(0,p.jsx)(wo,{value:a.color??`#E5E7EB`,onChange:e=>s({color:e})})}),(0,p.jsx)(Z,{label:`Thickness`,children:(0,p.jsx)($,{value:a.thickness??1,onChange:e=>s({thickness:Number(e.target.value)})})}),(0,p.jsx)(Mo,{style:a,mobileKeys:o,onSet:s}),(0,p.jsx)(xo,{hideOn:i.hideOn,onChange:e=>n({style:{...i,hideOn:e}})})]})}function zo(e=0){let t=e+1;return{id:`p_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,image:`https://placehold.co/400x400?text=Product+${t}`,imageAlt:`Product ${t}`,name:`Product ${t}`,oldPrice:`$59`,finalPrice:`$39`,description:`Short product description.`,link:`#`}}function Bo({mod:e,el:t}){let n=No(e,t),r=M(e=>e.viewMode),i=t.style??{},a=vo(i,r),o=e=>n({style:yo(i,e,r)}),s=e=>n({products:e}),c=e=>{let r=e,i=t.products.slice();if(i.length<r)for(;i.length<r;)i.push(zo(i.length));n({columns:e,products:i})},u=ho(),[d,m]=(0,l.useState)(null);return(0,p.jsxs)(p.Fragment,{children:[(0,p.jsx)(So,{children:`Product Grid`}),(0,p.jsxs)(Z,{label:`Columns (desktop)`,children:[(0,p.jsx)(`div`,{className:`inline-flex bg-gray-100 rounded p-0.5 w-full`,children:[1,2,3].map(e=>(0,p.jsxs)(`button`,{onClick:()=>c(e),className:`flex-1 px-2 py-1 text-xs rounded ${t.columns===e?`bg-white shadow text-gray-900`:`text-gray-500 hover:text-gray-700`}`,children:[e,` `,e===1?`col`:`cols`]},e))}),(0,p.jsx)(`p`,{className:`text-[10px] text-gray-400 mt-1`,children:`Always stacks to 1 column on mobile.`})]}),(0,p.jsx)(Ho,{label:`Show old price`,checked:t.showOldPrice,onChange:e=>n({showOldPrice:e})}),(0,p.jsx)(Ho,{label:`Show description`,checked:t.showDescription,onChange:e=>n({showDescription:e})}),(0,p.jsx)(Ho,{label:`Show stars`,checked:t.showStars??!1,onChange:e=>n({showStars:e})}),(0,p.jsx)(Ho,{label:`Show button`,checked:t.showButton,onChange:e=>n({showButton:e})}),(0,p.jsx)(Z,{label:`Default button label`,children:(0,p.jsx)(Q,{value:t.buttonLabel??``,placeholder:`Shop now`,onChange:e=>n({buttonLabel:e.target.value})})}),(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(So,{children:[`Products (`,t.products.length,`)`]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1`,children:[u&&(0,p.jsxs)(`button`,{onClick:()=>m({index:null,query:``}),className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded`,title:`Find a product from your catalog`,children:[(0,p.jsx)(f.Search,{size:12}),` Find`]}),(0,p.jsxs)(`button`,{onClick:()=>s([...t.products,zo(t.products.length)]),className:`flex items-center gap-1 px-1.5 py-0.5 text-[11px] text-blue-600 hover:bg-blue-50 rounded`,title:`Add product`,children:[(0,p.jsx)(f.Plus,{size:12}),` Add`]})]})]}),t.products.map((e,n)=>(0,p.jsx)(Uo,{index:n,product:e,canSearch:u,onSearch:()=>m({index:n,query:e.name}),onChange:e=>{let r=[...t.products];r[n]=e,s(r)},onDelete:()=>s(t.products.filter((e,t)=>t!==n))},e.id))]}),(0,p.jsx)(po,{open:d!==null,initialQuery:d?.query,title:d?.index==null?`Add product from search`:`Replace product`,onClose:()=>m(null),onSave:e=>{let r=W({name:e.name,finalPrice:e.finalPrice,oldPrice:e.oldPrice,description:e.description,link:e.link,image:e.image,imageAlt:e.imageAlt,stars:e.stars}),i={};e.oldPrice&&!t.showOldPrice&&(i.showOldPrice=!0),e.description&&!t.showDescription&&(i.showDescription=!0),e.stars!=null&&!t.showStars&&(i.showStars=!0);let a=t.products.slice();if(d?.index!=null){let e=a[d.index];a[d.index]={...r,id:e.id,buttonLabel:e.buttonLabel}}else a.push(r);n({products:a,...i})}}),(0,p.jsxs)(`div`,{className:`mt-4 pt-3 border-t border-gray-100`,children:[(0,p.jsx)(So,{children:`Style`}),(0,p.jsx)(Z,{label:`Card background`,children:(0,p.jsx)(wo,{value:a.cardBackgroundColor??``,onChange:e=>o({cardBackgroundColor:e})})}),(0,p.jsx)(Z,{label:`Name color`,children:(0,p.jsx)(wo,{value:a.nameColor??``,onChange:e=>o({nameColor:e})})}),(0,p.jsx)(Z,{label:`Final price color`,children:(0,p.jsx)(wo,{value:a.finalPriceColor??``,onChange:e=>o({finalPriceColor:e})})}),(0,p.jsx)(Z,{label:`Old price color`,children:(0,p.jsx)(wo,{value:a.oldPriceColor??``,onChange:e=>o({oldPriceColor:e})})}),(0,p.jsx)(Z,{label:`Button background`,children:(0,p.jsx)(wo,{value:a.buttonBackgroundColor??``,onChange:e=>o({buttonBackgroundColor:e})})}),(0,p.jsx)(Z,{label:`Button text color`,children:(0,p.jsx)(wo,{value:a.buttonColor??``,onChange:e=>o({buttonColor:e})})}),(0,p.jsx)(Z,{label:`Card radius`,children:(0,p.jsx)($,{value:a.borderRadius??0,onChange:e=>o({borderRadius:Number(e.target.value)})})}),(0,p.jsx)(Mo,{style:a,onSet:o})]})]})}function Vo({checked:e,onChange:t}){return(0,p.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,onClick:n=>{n.preventDefault(),n.stopPropagation(),t(!e)},className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors ${e?`bg-blue-600`:`bg-gray-300`}`,children:(0,p.jsx)(`span`,{className:`inline-block h-4 w-4 transform rounded-full bg-white transition-transform ${e?`translate-x-4`:`translate-x-0.5`}`})})}function Ho({label:e,checked:t,onChange:n}){return(0,p.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-2`,children:[(0,p.jsx)(`span`,{className:`text-xs text-gray-600`,children:e}),(0,p.jsx)(Vo,{checked:t,onChange:n})]})}function Uo({index:e,product:t,canSearch:n,onSearch:r,onChange:i,onDelete:a}){let o=e=>i({...t,...e});return(0,p.jsxs)(`div`,{className:`border border-gray-200 rounded p-2 mb-2 bg-gray-50`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,p.jsxs)(`span`,{className:`text-[11px] font-semibold text-gray-600`,children:[`#`,e+1]}),(0,p.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[n&&(0,p.jsx)(`button`,{type:`button`,onClick:r,className:`text-gray-400 hover:text-blue-600`,title:`Replace from product search`,children:(0,p.jsx)(f.Search,{size:12})}),(0,p.jsx)(`button`,{type:`button`,onClick:a,className:`text-gray-400 hover:text-red-600`,title:`Remove product`,children:(0,p.jsx)(f.Trash2,{size:12})})]})]}),(0,p.jsx)(Z,{label:`Name`,children:(0,p.jsx)(Q,{value:t.name,onChange:e=>o({name:e.target.value})})}),(0,p.jsx)(Z,{label:`Image URL`,children:(0,p.jsx)(Co,{value:t.image,onChange:e=>o({image:e}),onAlt:e=>o({imageAlt:e})})}),(0,p.jsx)(Z,{label:`Link`,children:(0,p.jsx)(Q,{value:t.link??``,onChange:e=>o({link:e.target.value})})}),(0,p.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,p.jsx)(Z,{label:`Final price`,children:(0,p.jsx)(Q,{value:t.finalPrice,onChange:e=>o({finalPrice:e.target.value})})}),(0,p.jsx)(Z,{label:`Old price`,children:(0,p.jsx)(Q,{value:t.oldPrice??``,placeholder:`Optional`,onChange:e=>o({oldPrice:e.target.value||void 0})})})]}),(0,p.jsx)(Z,{label:`Description`,children:(0,p.jsx)(Q,{value:t.description??``,onChange:e=>o({description:e.target.value||void 0})})}),(0,p.jsx)(Z,{label:`Stars (0–5, optional)`,children:(0,p.jsx)($,{value:t.stars??``,min:0,max:5,step:.5,placeholder:`e.g. 4.5`,onChange:e=>o({stars:e.target.value===``?void 0:Number(e.target.value)})})}),(0,p.jsx)(Z,{label:`Button label (override)`,children:(0,p.jsx)(Q,{value:t.buttonLabel??``,placeholder:`Inherit default`,onChange:e=>o({buttonLabel:e.target.value||void 0})})})]})}var Wo=[{type:`basic.text`,category:`basic`,name:`Text Block`,description:`Single editable paragraph of body copy. Use for short notes, intros, or filler text between sections.`,tags:[`text`,`paragraph`,`body`],create:()=>z(`basic.text`,`Text Block`,[P(`Write your text here.`,{role:`body`})])},{type:`basic.heading`,category:`basic`,name:`Heading`,description:`Bold standalone heading using the theme heading font. Use to introduce a section without other elements.`,tags:[`heading`,`title`,`section`],create:()=>z(`basic.heading`,`Heading`,[P(`A clear section heading`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingTop:16,paddingBottom:8,lineHeight:1.25})])},{type:`basic.image`,category:`basic`,name:`Image`,description:`Single full-width image, centered. Use for hero photography, illustrations, or screenshots.`,tags:[`image`,`media`,`photo`],create:()=>z(`basic.image`,`Image`,[F(U(600,300),`Placeholder`)])},{type:`basic.image_caption`,category:`basic`,name:`Image with Caption`,description:`Image followed by a small italicized caption underneath. Editorial style for newsletters.`,tags:[`image`,`caption`,`editorial`],create:()=>z(`basic.image_caption`,`Image + Caption`,[F(U(600,360),`Photo`),P(`Photo: caption goes here.`,{color:`{colors.muted}`,fontSize:13,align:`center`,paddingTop:4,paddingBottom:16})])},{type:`basic.spacer`,category:`basic`,name:`Spacer`,description:`Empty vertical space. Use to separate modules with breathing room.`,tags:[`spacer`,`spacing`,`gap`],create:()=>z(`basic.spacer`,`Spacer`,[L(32)])},{type:`basic.divider`,category:`basic`,name:`Divider`,description:`Thin horizontal rule across the email. Use to visually separate sections.`,tags:[`divider`,`separator`,`rule`],create:()=>z(`basic.divider`,`Divider`,[R()])}],Go=[{type:`header.logo`,category:`header`,name:`Logo Centered`,description:`Centered brand logo. The simplest header used at the top of almost every newsletter.`,tags:[`logo`,`brand`,`centered`],create:()=>z(`header.logo`,`Logo Header`,[F(U(180,56,`LOGO`),`Logo`,{width:180,paddingTop:24,paddingBottom:24})])},{type:`header.logo_left_date_right`,category:`header`,name:`Logo Left + Date Right`,description:`Two-column header with logo on the left and a date or issue label on the right. Common for periodical newsletters and digests.`,tags:[`logo`,`date`,`issue`,`publication`,`newsletter`],create:()=>z(`header.logo_left_date_right`,`Logo + Date`,[F(U(140,36,`LOGO`),`Logo`,{width:140,align:`left`,paddingTop:16,paddingBottom:16}),P(`Issue #128 · April 29, 2026`,{color:`{colors.muted}`,fontSize:13,align:`right`,paddingTop:0,paddingBottom:16}),R({paddingTop:0,paddingBottom:0})])},{type:`header.publication`,category:`header`,name:`Publication Masthead`,description:`Editorial masthead with publication name in serif type, tagline, and a divider. Mimics print magazine and newspaper newsletters.`,tags:[`masthead`,`publication`,`editorial`,`serif`,`newspaper`,`magazine`],create:()=>z(`header.publication`,`Masthead`,[P(`THE WEEKLY`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,letterSpacing:6,paddingTop:32,paddingBottom:4}),P(`Curated reading for thoughtful people`,{color:`{colors.muted}`,align:`center`,fontSize:13,paddingBottom:16}),R({paddingTop:0,paddingBottom:0})])},{type:`header.hero`,category:`header`,name:`Hero with Headline & Image`,description:`Big headline, subtitle and a wide hero image. Use for the lead story or campaign announcement.`,tags:[`hero`,`headline`,`image`,`lead`,`feature`],create:()=>z(`header.hero`,`Hero`,[P(`Steps Towards a Greener World`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,paddingTop:32,lineHeight:1.2}),P(`Small actions, big impact.`,{color:`{colors.muted}`,align:`center`,paddingBottom:16}),F(U(560,280,`Hero`),`Hero`,{width:560})])},{type:`header.hero_text_only`,category:`header`,name:`Hero Text Only`,description:`Centered eyebrow + large headline + supporting paragraph, no image. Editorial intro for opinion or essay newsletters.`,tags:[`hero`,`text`,`essay`,`editorial`,`minimal`],create:()=>z(`header.hero_text_only`,`Hero Text`,[P(`ESSAY · ISSUE 42`,{fontSize:12,fontWeight:`bold`,color:`{colors.primary}`,letterSpacing:3,align:`center`,paddingTop:32,paddingBottom:8}),P(`On building things slowly`,{role:`headline`,fontFamily:`{fonts.heading}`,fontSize:40,fontWeight:`bold`,align:`center`,lineHeight:1.15,paddingBottom:8}),P(`Why patience and craft still win in a world of shortcuts.`,{color:`{colors.muted}`,align:`center`,fontSize:16,paddingBottom:32})])},{type:`header.announcement`,category:`header`,name:`Announcement Bar`,description:`Thin colored top bar with a single line of promotional text. Use for free shipping, sales, or alerts.`,tags:[`announcement`,`bar`,`promo`,`alert`],create:()=>z(`header.announcement`,`Announcement`,[P(`✨ Free shipping on orders over $50`,{color:`{colors.buttonText}`,align:`center`,fontSize:14,paddingTop:12,paddingBottom:12})],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`header.logo_with_view_browser`,category:`header`,name:`Logo + View in Browser`,description:`Logo with a small 'View in browser' link above it. Standard for marketing newsletters that may render poorly.`,tags:[`logo`,`view-in-browser`,`marketing`,`preheader`],create:()=>z(`header.logo_with_view_browser`,`Logo + Browser Link`,[P(`View in browser`,{color:`{colors.muted}`,fontSize:11,align:`right`,paddingTop:8,paddingBottom:0,link:`#`}),F(U(160,48,`LOGO`),`Logo`,{width:160,paddingTop:8,paddingBottom:16})])},{type:`header.welcome`,category:`header`,name:`Welcome Header`,description:`Friendly greeting with first name placeholder, used at the top of welcome and onboarding emails.`,tags:[`welcome`,`onboarding`,`greeting`,`personalized`],create:()=>z(`header.welcome`,`Welcome`,[P(`👋 Welcome aboard, {{first_name}}`,{fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,align:`center`,paddingTop:32,paddingBottom:8}),P(`We're glad you're here. Here's what to do next.`,{color:`{colors.muted}`,align:`center`,paddingBottom:16})])},{type:`header.logo_with_tagline`,category:`header`,name:`Logo + Tagline`,description:`Centered logo above a one-line tagline. Friendly brand-forward header.`,tags:[`logo`,`tagline`,`brand`],create:()=>z(`header.logo_with_tagline`,`Logo + Tagline`,[F(U(160,48,`LOGO`),`Logo`,{width:160,paddingTop:24,paddingBottom:4}),P(`Newsletters that respect your time.`,{align:`center`,color:`{colors.muted}`,fontSize:14,paddingBottom:24})])},{type:`header.story_label`,category:`header`,name:`Story Label Header`,description:`Small category label (e.g. 'Top story', 'Deep dive') above the masthead. Used by The Hustle, Morning Brew style newsletters.`,tags:[`label`,`category`,`story`,`newsletter`,`topic`],create:()=>z(`header.story_label`,`Story Label`,[P(`TODAY'S TOP STORY`,{color:`{colors.primary}`,fontSize:12,fontWeight:`bold`,letterSpacing:3,align:`center`,paddingTop:24,paddingBottom:4}),P(`AI editing tools come for the inbox`,{fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,align:`center`,paddingBottom:16,lineHeight:1.2})])}],Ko=[{type:`menu.horizontal`,category:`menu`,name:`Horizontal Nav`,description:`Horizontal menu with 3-5 inline links separated by dots. Common publication navigation under the masthead.`,tags:[`menu`,`nav`,`horizontal`,`publication`],create:()=>z(`menu.horizontal`,`Horizontal Menu`,[P(`Home · Articles · Podcast · About · Subscribe`,{align:`center`,color:`{colors.text}`,fontSize:13,paddingTop:12,paddingBottom:12})])},{type:`menu.sections`,category:`menu`,name:`Section Tabs`,description:`Linked section labels representing the contents of today's issue (e.g. News · Markets · Tech · Culture). Used by daily digests.`,tags:[`menu`,`sections`,`tabs`,`digest`,`daily`],create:()=>z(`menu.sections`,`Section Tabs`,[R({paddingTop:0,paddingBottom:8}),P(`NEWS · MARKETS · TECH · CULTURE · WEEKEND`,{align:`center`,color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,paddingTop:0,paddingBottom:8}),R({paddingTop:0,paddingBottom:8})])},{type:`menu.in_this_issue`,category:`menu`,name:`In This Issue`,description:`Table-of-contents box listing the items in this newsletter issue with anchor links. Helps readers scan long emails.`,tags:[`toc`,`menu`,`issue`,`summary`,`table of contents`],create:()=>z(`menu.in_this_issue`,`In This Issue`,[P(`IN THIS ISSUE`,{fontSize:11,fontWeight:`bold`,color:`{colors.muted}`,letterSpacing:2,paddingTop:16,paddingBottom:8}),P(`→ Lead story: AI in the inbox`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#lead`}),P(`→ 3 things worth your time`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#picks`}),P(`→ Reader question of the week`,{fontSize:14,paddingTop:2,paddingBottom:2,link:`#qa`}),P(`→ Upcoming events`,{fontSize:14,paddingTop:2,paddingBottom:16,link:`#events`})],{backgroundColor:`{colors.background}`,paddingTop:8,paddingBottom:8,paddingLeft:16,paddingRight:16})},{type:`menu.cta_strip`,category:`menu`,name:`Linked Action Strip`,description:`Three short text actions in a row (e.g. 'Read · Share · Reply'). Light alternative to a button bar.`,tags:[`menu`,`actions`,`links`,`strip`],create:()=>z(`menu.cta_strip`,`Action Strip`,[P(`Read online · Share · Reply with feedback`,{align:`center`,color:`{colors.primary}`,fontSize:13,paddingTop:12,paddingBottom:12})])}],qo=[{type:`content.headline_body`,category:`content`,name:`Headline + Body`,description:`Section title with one paragraph of body text. The most generic written content block.`,tags:[`headline`,`body`,`paragraph`,`article`],create:()=>z(`content.headline_body`,`Headline + Body`,[B(`A compelling headline`,{paddingTop:24}),P(`Tell your story with a clear, concise paragraph. Keep readers engaged with short sentences and meaningful detail.`,{paddingBottom:24})])},{type:`content.lead_story`,category:`content`,name:`Lead Story`,description:`Top story of the issue: eyebrow label, big headline, hero image, lead paragraph and a 'Continue reading' link. Used by news and editorial newsletters.`,tags:[`lead`,`story`,`feature`,`news`,`editorial`,`long-form`],create:()=>z(`content.lead_story`,`Lead Story`,[V(`Lead story`),B(`Inside the new wave of indie publishers`,{level:1,paddingBottom:4}),H(`By Jane Doe · 6 min read`,{fontSize:13}),F(U(560,320,`Lead`),`Lead`,{width:560,paddingTop:12}),P(`A growing group of writers are leaving big media to build their own readerships, betting that quality and a direct relationship beat scale.`,{paddingTop:16}),P(`Continue reading →`,{color:`{colors.primary}`,fontWeight:`bold`,paddingTop:4,paddingBottom:24,link:`#`})])},{type:`content.article_summary`,category:`content`,name:`Article Summary Card`,description:`Compact link-out card: image on top, category label, title, one-line summary, and 'Read more'. Use repeatedly to list secondary articles.`,tags:[`article`,`summary`,`card`,`link-out`,`newsletter`],create:()=>z(`content.article_summary`,`Article Card`,[F(U(560,280,`Article`),`Article`,{width:560}),P(`CULTURE`,{color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,paddingTop:12,paddingBottom:4}),B(`How long-form writing made a comeback`,{paddingTop:0,paddingBottom:4}),P(`Why subscribers are paying for slower, deeper coverage — and what it means for publishers.`,{paddingBottom:8}),P(`Read more →`,{color:`{colors.primary}`,fontWeight:`bold`,paddingBottom:24,link:`#`})])},{type:`content.image_text`,category:`content`,name:`Image + Text Beside`,description:`Image with article title and short summary stacked below. Standard editorial card.`,tags:[`image`,`text`,`article`,`stacked`],create:()=>z(`content.image_text`,`Image + Text`,[F(U(560,300,`Article`),`Article`,{width:560}),B(`Article title`,{paddingTop:16,paddingBottom:4}),P(`A short summary of the article goes here, two or three lines is plenty.`)])},{type:`content.two_column_articles`,category:`content`,name:`Two Column Stories`,description:`Two short article previews shown side-by-side as stacked blocks (renders as full-width on mobile). Use to tease two related stories.`,tags:[`two-column`,`articles`,`side-by-side`,`preview`],create:()=>z(`content.two_column_articles`,`Two Stories`,[V(`More to read`),F(U(272,180,`Story A`),`Story A`,{width:272}),P(`Story A title`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),P(`One sentence about story A.`,{fontSize:14,paddingBottom:16}),F(U(272,180,`Story B`),`Story B`,{width:272}),P(`Story B title`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),P(`One sentence about story B.`,{fontSize:14,paddingBottom:16})])},{type:`content.three_picks`,category:`content`,name:`Three Picks (Numbered)`,description:`Numbered list of three short recommendations or links. Used by curators ('3 things to read this week').`,tags:[`list`,`picks`,`curated`,`links`,`recommendations`],create:()=>z(`content.three_picks`,`Three Picks`,[V(`Three picks`),P(`01 / How to stay focused in 2026`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),H(`Notes on attention, deep work, and the slow internet.`,{fontSize:14}),R({paddingTop:12,paddingBottom:8}),P(`02 / The case for boring software`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),H(`Why teams are returning to simpler, predictable tools.`,{fontSize:14}),R({paddingTop:12,paddingBottom:8}),P(`03 / A short history of the inbox`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:8,paddingBottom:4,link:`#`}),H(`From memos to MIME, and what comes next.`,{fontSize:14,paddingBottom:24})])},{type:`content.quote`,category:`content`,name:`Pull Quote`,description:`Centered serif pull quote with attribution. Adds rhythm to long editorial newsletters.`,tags:[`quote`,`pull-quote`,`editorial`,`attribution`],create:()=>z(`content.quote`,`Pull Quote`,[P(`“The best way to predict the future is to create it.”`,{fontFamily:`{fonts.heading}`,fontSize:22,align:`center`,paddingTop:24,lineHeight:1.4}),P(`— Peter Drucker`,{color:`{colors.muted}`,align:`center`,paddingBottom:24})])},{type:`content.author_byline`,category:`content`,name:`Author Byline`,description:`Round avatar + author name + role on one line. Drop above or below an article body for personal newsletters.`,tags:[`author`,`byline`,`avatar`,`personal`],create:()=>z(`content.author_byline`,`Byline`,[F(U(64,64,`👤`),`Author`,{width:64,borderRadius:32,paddingTop:16,paddingBottom:0}),P(`Jane Doe`,{align:`center`,fontWeight:`bold`,paddingTop:8,paddingBottom:0}),H(`Editor, The Weekly`,{align:`center`,fontSize:13}),L(16)])},{type:`content.editor_note`,category:`content`,name:`Editor's Note`,description:`Personal letter-style block: 'Hi {{first_name}}', a few paragraphs and a sign-off. Ideal for newsletters with a strong author voice.`,tags:[`editor`,`note`,`letter`,`personal`,`voice`],create:()=>z(`content.editor_note`,`Editor's Note`,[P(`Hi {{first_name}},`,{paddingTop:24,paddingBottom:8}),P(`This week I've been thinking about what makes a newsletter feel like a letter rather than a broadcast. Spoiler: it's not the format, it's the tone.`,{paddingBottom:8,lineHeight:1.7}),P(`Let me know what you think — just hit reply.`,{paddingBottom:8,lineHeight:1.7}),P(`— Jane`,{fontFamily:`{fonts.heading}`,paddingBottom:24})])},{type:`content.tip_box`,category:`content`,name:`Tip / Callout Box`,description:`Highlighted background box with an icon, short title and one-paragraph tip. Use for 'pro tips', notes, and warnings.`,tags:[`tip`,`callout`,`box`,`highlight`,`note`],create:()=>z(`content.tip_box`,`Tip Box`,[P(`💡 PRO TIP`,{color:`{colors.primary}`,fontSize:12,fontWeight:`bold`,letterSpacing:2,paddingTop:16,paddingBottom:4}),P(`Always preview your email on mobile before sending — most opens happen there.`,{paddingBottom:16})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16})},{type:`content.numbered_list`,category:`content`,name:`Numbered List`,description:`Vertical numbered list of 4-5 short items with optional sub-text. Use for tutorials, checklists and 'how-to' newsletters.`,tags:[`list`,`numbered`,`tutorial`,`checklist`,`how-to`],create:()=>z(`content.numbered_list`,`Numbered List`,[B(`How to do it in 4 steps`,{paddingTop:16,paddingBottom:12}),P(`1. Define the goal`,{fontWeight:`bold`,paddingTop:4,paddingBottom:2}),H(`Write down the outcome in one sentence.`),P(`2. List constraints`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),H(`Time, budget, scope. Be specific.`),P(`3. Plan the smallest version`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),H(`What can you ship this week?`),P(`4. Ship it`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),H(`Refine after real feedback.`,{fontSize:14}),L(16)])},{type:`content.bullet_list`,category:`content`,name:`Bullet List`,description:`Simple unordered list of takeaways or facts. Concise summary block.`,tags:[`list`,`bullets`,`takeaways`,`summary`],create:()=>z(`content.bullet_list`,`Bullets`,[B(`Key takeaways`,{paddingTop:16,paddingBottom:8}),P(`• Newsletters are growing 20% YoY`,{paddingTop:2,paddingBottom:2}),P(`• Mobile opens crossed 70%`,{paddingTop:2,paddingBottom:2}),P(`• Plain-text emails outperform image-heavy ones in B2B`,{paddingTop:2,paddingBottom:2}),P(`• Personalization drives 2x click-through`,{paddingTop:2,paddingBottom:16})])},{type:`content.qa`,category:`content`,name:`Q&A Block`,description:`Question in bold followed by an answer paragraph. Use for FAQ, reader mailbags, or AMAs.`,tags:[`qa`,`faq`,`ama`,`mailbag`,`reader-questions`],create:()=>z(`content.qa`,`Q&A`,[V(`Reader question`),P(`Q: How do I get my first 100 subscribers?`,{fontFamily:`{fonts.heading}`,fontSize:18,fontWeight:`bold`,paddingTop:4,paddingBottom:8,lineHeight:1.3}),P(`A: Tell ten people who already know you. Then ask each of them to forward to one friend. The first 100 don't come from algorithms — they come from your network.`,{paddingBottom:24,lineHeight:1.7})])},{type:`content.stats_row`,category:`content`,name:`Stat Row`,description:`Big numbers with short labels (e.g. '12k readers · 4.8★ rating · 96% open rate'). Used for impact summaries and social proof.`,tags:[`stats`,`numbers`,`metrics`,`social-proof`],create:()=>z(`content.stats_row`,`Stat Row`,[V(`By the numbers`,{align:`center`}),P(`12,400`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,color:`{colors.primary}`,paddingTop:4,paddingBottom:0}),H(`active readers this month`,{align:`center`,fontSize:13}),L(8),P(`96% · 4.8★ · 32 issues shipped`,{align:`center`,color:`{colors.text}`,fontSize:14,paddingBottom:24})])},{type:`content.timeline`,category:`content`,name:`Timeline / What Happened`,description:`Chronological list of recent events with dates. Used by news roundups and changelog newsletters.`,tags:[`timeline`,`changelog`,`news`,`events`,`what-happened`],create:()=>z(`content.timeline`,`Timeline`,[V(`This week`),P(`Mon · Acme launches plan B`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),H(`After 6 months of beta testing.`,{fontSize:14}),P(`Wed · New funding round announced`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),H(`$24M Series A led by Foundry.`,{fontSize:14}),P(`Fri · Industry report drops`,{fontWeight:`bold`,paddingTop:8,paddingBottom:2}),H(`Open rates up across the board.`,{fontSize:14,paddingBottom:24})])},{type:`content.podcast_episode`,category:`content`,name:`Podcast Episode`,description:`Episode artwork, episode number, title, short description and a 'Listen' button. For shows that announce episodes by email.`,tags:[`podcast`,`episode`,`audio`,`listen`,`show`],create:()=>z(`content.podcast_episode`,`Podcast Episode`,[F(U(220,220,`Cover`),`Cover`,{width:220,borderRadius:12}),P(`EPISODE 042`,{color:`{colors.primary}`,fontSize:11,fontWeight:`bold`,letterSpacing:2,align:`center`,paddingTop:12,paddingBottom:4}),B(`Why publishers are betting on email`,{align:`center`,paddingTop:0,paddingBottom:4}),H(`With Jane Doe · 38 min`,{align:`center`,fontSize:13}),I(`Listen now`,`https://example.com`),L(16)])},{type:`content.video_thumbnail`,category:`content`,name:`Video Thumbnail`,description:`Video thumbnail with overlay-feeling play button (image only, links to a hosted player). Title and duration below.`,tags:[`video`,`thumbnail`,`watch`,`play`,`media`],create:()=>z(`content.video_thumbnail`,`Video`,[F(U(560,315,`▶ Watch`),`Video`,{width:560,link:`#`,borderRadius:8}),B(`Watch: a guided tour of our 2026 launches`,{paddingTop:12,paddingBottom:4}),H(`4 min watch`,{fontSize:13,paddingBottom:16})])},{type:`content.event_card`,category:`content`,name:`Event Card`,description:`Date badge with event title, location, time and an RSVP button. For event-driven newsletters and community digests.`,tags:[`event`,`rsvp`,`community`,`date`,`card`],create:()=>z(`content.event_card`,`Event`,[P(`MAY`,{align:`center`,color:`{colors.buttonText}`,fontSize:12,fontWeight:`bold`,letterSpacing:2,paddingTop:12,paddingBottom:0}),P(`12`,{align:`center`,color:`{colors.buttonText}`,fontSize:36,fontWeight:`bold`,paddingTop:0,paddingBottom:12})],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`content.code_block`,category:`content`,name:`Code Snippet`,description:`Monospaced code block on a tinted background. For developer newsletters and changelog excerpts.`,tags:[`code`,`snippet`,`developer`,`monospace`,`changelog`],create:()=>z(`content.code_block`,`Code`,[P(`npm install @one-million-lines/email-builder`,{fontFamily:`Menlo, Consolas, monospace`,fontSize:13,color:`{colors.text}`,paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16})],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0,paddingLeft:16,paddingRight:16})}],Jo=[{type:`feature.list`,category:`feature`,name:`Checkmark Feature List`,description:`Centered title with 3-4 short checkmarked benefits. Good for product newsletters and onboarding emails.`,tags:[`features`,`benefits`,`checkmarks`,`list`],create:()=>z(`feature.list`,`Feature List`,[B(`Why people love it`,{align:`center`,paddingTop:24}),P(`✓ Fast and reliable`,{align:`center`}),P(`✓ Beautiful out of the box`,{align:`center`}),P(`✓ Backed by humans, not bots`,{align:`center`,paddingBottom:24})])},{type:`feature.icon_three`,category:`feature`,name:`Three Icon Features`,description:`Three stacked feature blocks with an emoji/icon, short title and one-line description. Use to highlight 3 product capabilities.`,tags:[`features`,`icons`,`three-up`,`product`],create:()=>z(`feature.icon_three`,`Three Features`,[P(`⚡`,{align:`center`,fontSize:32,paddingTop:24,paddingBottom:4}),P(`Fast`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),H(`Built to render in milliseconds.`,{align:`center`,fontSize:14}),L(16),P(`🧩`,{align:`center`,fontSize:32,paddingBottom:4}),P(`Modular`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),H(`Compose any layout from blocks.`,{align:`center`,fontSize:14}),L(16),P(`🤖`,{align:`center`,fontSize:32,paddingBottom:4}),P(`AI-ready`,{align:`center`,fontWeight:`bold`,paddingBottom:2}),H(`Edit emails as JSON, not HTML.`,{align:`center`,fontSize:14,paddingBottom:24})])},{type:`feature.before_after`,category:`feature`,name:`Before / After`,description:`Two stacked images labeled 'Before' and 'After'. For product transformations, redesigns and case studies.`,tags:[`before-after`,`comparison`,`case-study`,`transformation`],create:()=>z(`feature.before_after`,`Before / After`,[V(`Before`),F(U(560,280,`Before`),`Before`,{width:560}),L(8),V(`After`),F(U(560,280,`After`),`After`,{width:560}),L(16)])},{type:`feature.benefit_pair`,category:`feature`,name:`Image + Benefit Pair`,description:`Repeat-use block: one supporting image plus a title and benefit paragraph beside it. Stack 2-3 of these for a feature tour.`,tags:[`benefit`,`feature`,`image-text`,`pair`],create:()=>z(`feature.benefit_pair`,`Benefit Pair`,[F(U(560,240,`Feature`),`Feature`,{width:560,paddingTop:16}),B(`Send 10x faster`,{paddingTop:12,paddingBottom:4}),P(`Reusable modules and theme tokens let teams ship campaigns in minutes, not days.`,{paddingBottom:24})])},{type:`feature.testimonial`,category:`feature`,name:`Testimonial`,description:`Customer quote in large type with avatar and attribution. Social proof block.`,tags:[`testimonial`,`review`,`social-proof`,`customer`],create:()=>z(`feature.testimonial`,`Testimonial`,[P(`“This cut our email production from a week to an afternoon.”`,{fontFamily:`{fonts.heading}`,fontSize:22,align:`center`,paddingTop:24,paddingBottom:12,lineHeight:1.4}),F(U(56,56,`👤`),`Customer`,{width:56,borderRadius:28}),P(`Alex Kim · Head of Lifecycle, Acme`,{align:`center`,color:`{colors.muted}`,fontSize:13,paddingTop:4,paddingBottom:24})])},{type:`feature.logo_strip`,category:`feature`,name:`Customer Logo Strip`,description:`Small horizontal row implying customer logos for credibility ('Trusted by'). Logos shown as a placeholder image.`,tags:[`logos`,`trusted-by`,`social-proof`,`strip`],create:()=>z(`feature.logo_strip`,`Logo Strip`,[H(`TRUSTED BY`,{align:`center`,fontSize:11}),F(U(520,60,`LOGOS`),`Customer logos`,{width:520,paddingTop:8,paddingBottom:16})])},{type:`feature.gradient_hero`,category:`feature`,name:`Gradient Hero CTA`,description:`Bold centered hero with an eyebrow, oversized headline and a primary CTA button. Great for launch announcements and campaign openers.`,tags:[`hero`,`launch`,`cta`,`bold`,`announcement`],create:()=>z(`feature.gradient_hero`,`Gradient Hero CTA`,[V(`Introducing`,{align:`center`}),B(`Something new is here`,{level:1,align:`center`,paddingTop:4,paddingBottom:8}),P(`A fresh way to reach your audience — crafted for the inbox.`,{align:`center`,color:`{colors.muted}`,fontSize:16,paddingBottom:20}),I(`Explore now`,`#`,{align:`center`})],{backgroundColor:`{colors.surface}`,paddingTop:40,paddingBottom:40})},{type:`feature.pull_quote`,category:`feature`,name:`Pull Quote`,description:`Large centered quotation with an attribution line. Use to highlight a testimonial or a memorable line.`,tags:[`quote`,`testimonial`,`highlight`,`pull-quote`],create:()=>z(`feature.pull_quote`,`Pull Quote`,[P(`“This is the fastest we’ve ever shipped a campaign.”`,{fontFamily:`{fonts.heading}`,fontSize:24,align:`center`,lineHeight:1.4,paddingTop:28,paddingBottom:8}),H(`— A very happy customer`,{align:`center`,paddingBottom:28})])},{type:`feature.stat_row`,category:`feature`,name:`Stat Row`,description:`Three short number + label pairs in a row. Use to show traction, metrics or highlights.`,tags:[`stats`,`metrics`,`numbers`,`row`,`kpi`],create:()=>z(`feature.stat_row`,`Stat Row`,[B(`By the numbers`,{align:`center`,paddingTop:24}),P(`<b>10k+</b> subscribers · <b>98%</b> delivery · <b>4.9★</b> rating`,{align:`center`,color:`{colors.muted}`,paddingBottom:24})])},{type:`feature.single_product_spotlight`,category:`feature`,name:`Single Product Spotlight`,description:`One product with image, name, price and buy button. Use to feature a hero product in a feature-focused email.`,tags:[`product`,`spotlight`,`single`,`buy`,`shop`,`ecommerce`],create:()=>z(`feature.single_product_spotlight`,`Product Spotlight`,[G([W({name:`The Signature Bag`,finalPrice:`$129`,oldPrice:`$159`,description:`Handmade, built to last.`,image:U(520,520,`Product`)})],{columns:1,showDescription:!0,buttonLabel:`Buy now`})])},{type:`feature.pill_nav`,category:`feature`,name:`Pill Navigation`,description:`Centered row of navigation links with a divider below. Compact feature nav block for use inside email content sections.`,tags:[`menu`,`nav`,`links`,`pill`],create:()=>z(`feature.pill_nav`,`Pill Navigation`,[F(U(120,32,`LOGO`),`Logo`,{width:120,paddingBottom:8}),P(`<a href="#">Shop</a> <a href="#">New</a> <a href="#">Sale</a> <a href="#">About</a>`,{align:`center`,color:`{colors.primary}`,paddingBottom:8}),R({paddingTop:4,paddingBottom:0})])}],Yo=[{type:`cta.simple`,category:`call_to_action`,name:`Simple CTA`,description:`Centered headline + body + primary button. The default call-to-action block for any newsletter or promo.`,tags:[`cta`,`primary`,`centered`,`button`],create:()=>z(`cta.simple`,`Simple CTA`,[B(`Ready to get started?`,{align:`center`,paddingTop:24}),H(`Create better emails faster.`,{align:`center`}),I(`Start now`,`https://example.com`),L(16)])},{type:`cta.banner`,category:`call_to_action`,name:`Colored Banner CTA`,description:`Full-width colored band with eyebrow, big headline and a contrasting button. Use to draw attention to sales or launches.`,tags:[`cta`,`banner`,`colored`,`promo`,`sale`],create:()=>z(`cta.banner`,`CTA Banner`,[P(`Limited time offer`,{color:`{colors.buttonText}`,align:`center`,fontSize:14,paddingTop:24,paddingBottom:4}),P(`Save 30% this week only`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingBottom:16}),I(`Shop the sale`),L(24)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`cta.button_only`,category:`call_to_action`,name:`Button Only`,description:`Single primary button on a clean background. Use as a follow-up CTA after a content block.`,tags:[`cta`,`button`,`minimal`],create:()=>z(`cta.button_only`,`Button`,[I(`Click here`,`https://example.com`)])},{type:`cta.dual_button`,category:`call_to_action`,name:`Two Button Choice`,description:`Two side-by-side actions: a primary and a ghost-styled secondary. Use when offering 'Learn more' vs 'Get started'.`,tags:[`cta`,`buttons`,`two-options`,`choice`],create:()=>z(`cta.dual_button`,`Two Buttons`,[B(`Pick your path`,{align:`center`,paddingTop:24}),H(`Choose what fits your team.`,{align:`center`}),I(`Get started`,`https://example.com`),I(`Learn more`,`https://example.com`,{backgroundColor:`transparent`,color:`{colors.primary}`}),L(16)])},{type:`cta.image_overlay`,category:`call_to_action`,name:`Image + Overlay CTA`,description:`Lead image with a headline, supporting text, and a button immediately below. Strong visual call to action.`,tags:[`cta`,`image`,`visual`,`hero`],create:()=>z(`cta.image_overlay`,`Image CTA`,[F(U(560,280,`Visual`),`Visual`,{width:560,paddingTop:16}),B(`Stop guessing. Start measuring.`,{align:`center`,paddingTop:16}),H(`Free for 14 days. No credit card.`,{align:`center`}),I(`Try it free`),L(16)])},{type:`cta.subscribe`,category:`call_to_action`,name:`Subscribe / Forward`,description:`Friendly 'Was this forwarded? Subscribe' block that grows the list virally. Common at the end of newsletters.`,tags:[`cta`,`subscribe`,`forward`,`growth`,`newsletter`],create:()=>z(`cta.subscribe`,`Subscribe`,[V(`Was this forwarded?`,{align:`center`}),B(`Get the next issue in your inbox`,{align:`center`,paddingTop:0,paddingBottom:8}),I(`Subscribe free`),L(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})},{type:`cta.referral`,category:`call_to_action`,name:`Referral / Share`,description:`Encourages readers to share the newsletter with a unique referral link. Includes a 'Share' button and a personalized URL.`,tags:[`cta`,`referral`,`share`,`viral`,`growth`],create:()=>z(`cta.referral`,`Referral`,[V(`Tell a friend`,{align:`center`}),B(`Share & earn perks`,{align:`center`,paddingTop:0,paddingBottom:8}),H(`Refer 3 friends and unlock the bonus issue.`,{align:`center`}),P(`yourname.com/r/abc123`,{align:`center`,color:`{colors.primary}`,fontFamily:`Menlo, Consolas, monospace`,fontSize:14,paddingTop:8,paddingBottom:8}),I(`Share now`),L(16)])},{type:`cta.upgrade`,category:`call_to_action`,name:`Upgrade / Paid`,description:`Conversion block that promotes a paid plan or premium tier. Includes price, benefits and an upgrade button.`,tags:[`cta`,`upgrade`,`paid`,`premium`,`conversion`],create:()=>z(`cta.upgrade`,`Upgrade`,[V(`Become a member`,{align:`center`}),B(`$5 / month`,{align:`center`,level:1}),H(`Unlock the archive, weekly bonus and member chat.`,{align:`center`,fontSize:14}),I(`Upgrade`),L(16)],{backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0})},{type:`cta.feedback`,category:`call_to_action`,name:`Feedback Reply`,description:`Asks the reader to reply with feedback ('Hit reply and let me know'). Personal, no button.`,tags:[`cta`,`feedback`,`reply`,`personal`],create:()=>z(`cta.feedback`,`Feedback`,[P(`How did this issue land for you? Just hit reply — I read every message.`,{align:`center`,paddingTop:24,paddingBottom:24,lineHeight:1.6})])}],Xo=[{type:`ecom.product_single`,category:`ecommerce`,name:`Single Product`,description:`One product with image, title, price, short description and Buy button. Use to feature a hero product. Supports old/final price and per-product link.`,tags:[`product`,`single`,`buy`,`hero`],create:()=>z(`ecom.product_single`,`Single Product`,[G([W({name:`Linen Tote Bag`,image:U(560,400,`Product`),oldPrice:`$59.00`,finalPrice:`$39.00`,description:`Heavyweight natural linen, made in Portugal.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`Buy now`})])},{type:`ecom.product_grid_2`,category:`ecommerce`,name:`Product Grid (2 up)`,description:`Two products side-by-side on desktop, stacked on mobile. Each card has image, name, old/final price, optional description and Shop button. Curated picks layout.`,tags:[`product`,`grid`,`two-up`,`curated`,`responsive`],create:()=>z(`ecom.product_grid_2`,`Product Grid 2`,[G([W({name:`Product A`,finalPrice:`$29`,oldPrice:`$39`}),W({name:`Product B`,finalPrice:`$34`,oldPrice:`$45`})],{columns:2,showOldPrice:!0})])},{type:`ecom.product_grid_3`,category:`ecommerce`,name:`Product Grid (3 up)`,description:`Three product cards in a row on desktop, stacked on mobile. Use for 'New arrivals' or 'Bestsellers' rows.`,tags:[`product`,`grid`,`three-up`,`bestsellers`,`new-arrivals`,`responsive`],create:()=>z(`ecom.product_grid_3`,`Product Grid 3`,[V(`New arrivals`,{align:`center`}),G([W({name:`Product 1`,finalPrice:`$19`}),W({name:`Product 2`,finalPrice:`$24`}),W({name:`Product 3`,finalPrice:`$32`})],{columns:3,showOldPrice:!1})])},{type:`ecom.collection_banner`,category:`ecommerce`,name:`Collection Banner`,description:`Wide collection banner with title and 'Shop the collection' button overlaying or under an image. Use for category drops.`,tags:[`collection`,`banner`,`category`,`drop`],create:()=>z(`ecom.collection_banner`,`Collection`,[F(U(560,300,`Collection`),`Collection`,{width:560}),B(`Spring Collection 2026`,{align:`center`,paddingTop:16}),H(`Lighter fabrics, brighter colors.`,{align:`center`}),I(`Shop the collection`),L(16)])},{type:`ecom.discount`,category:`ecommerce`,name:`Discount Code`,description:`Big discount code in monospaced caps with 'Your code' label and a Redeem button.`,tags:[`discount`,`promo`,`code`,`coupon`],create:()=>z(`ecom.discount`,`Discount Code`,[H(`Your code`,{align:`center`}),P(`SAVE20`,{fontFamily:`{fonts.heading}`,fontSize:36,fontWeight:`bold`,align:`center`,color:`{colors.primary}`,letterSpacing:4,paddingTop:4,paddingBottom:16}),I(`Redeem`),L(24)])},{type:`ecom.voucher`,category:`ecommerce`,name:`Voucher Code`,description:`Personalized voucher block: 'Your code' label, a large voucher code and a Redeem button. With the voucher-select plugin, pick a code from your backend catalog; otherwise edit the code text directly.`,tags:[`voucher`,`coupon`,`discount`,`code`,`promo`,`redeem`],create:()=>z(`ecom.voucher`,`Voucher Code`,[H(`Your code`,{align:`center`}),xe(`SAVE20`),I(`Redeem`),L(24)])},{type:`ecom.flash_sale`,category:`ecommerce`,name:`Flash Sale Banner`,description:`Urgency-driven banner with countdown-style copy ('Ends in 24h'), discount value and a shop button.`,tags:[`flash-sale`,`urgency`,`promo`,`banner`,`countdown`],create:()=>z(`ecom.flash_sale`,`Flash Sale`,[P(`⏰ FLASH SALE — ENDS IN 24H`,{color:`{colors.buttonText}`,align:`center`,fontWeight:`bold`,letterSpacing:2,paddingTop:16,paddingBottom:4}),P(`Up to 50% off everything`,{color:`{colors.buttonText}`,align:`center`,fontFamily:`{fonts.heading}`,fontSize:28,fontWeight:`bold`,paddingBottom:12}),I(`Shop now`,`#`,{backgroundColor:`{colors.surface}`,color:`{colors.primary}`}),L(16)],{backgroundColor:`{colors.primary}`,paddingTop:0,paddingBottom:0})},{type:`ecom.abandoned_cart`,category:`ecommerce`,name:`Abandoned Cart Reminder`,description:`Friendly reminder showing the items left in the cart with a return-to-cart button. For cart recovery automations.`,tags:[`abandoned-cart`,`recovery`,`automation`,`reminder`],create:()=>z(`ecom.abandoned_cart`,`Abandoned Cart`,[B(`You left something behind`,{align:`center`,paddingTop:16}),H(`Pick up where you left off.`,{align:`center`}),L(8),G([W({name:`Linen Tote Bag`,image:U(400,400,`Item`),finalPrice:`$39`,oldPrice:`$49`})],{columns:1,showOldPrice:!0,buttonLabel:`Return to cart`})])},{type:`ecom.review_request`,category:`ecommerce`,name:`Review Request`,description:`Post-purchase block asking for a 1-5 star rating with stacked star buttons. For review-collection emails.`,tags:[`review`,`rating`,`post-purchase`,`feedback`],create:()=>z(`ecom.review_request`,`Review`,[B(`How did we do?`,{align:`center`,paddingTop:24}),H(`Tap a star to leave a quick review.`,{align:`center`}),P(`☆ ☆ ☆ ☆ ☆`,{align:`center`,fontSize:32,color:`{colors.primary}`,paddingTop:12,paddingBottom:24,link:`#`})])},{type:`ecom.gift_guide`,category:`ecommerce`,name:`Gift Guide Pick`,description:`Editorial gift-guide pick: persona eyebrow + a single product card with full details (image, name, old/final price, description, CTA).`,tags:[`gift-guide`,`curated`,`editorial`,`holiday`],create:()=>z(`ecom.gift_guide`,`Gift Pick`,[V(`For the home cook`),G([W({name:`Cast Iron Skillet`,image:U(560,300,`Pick`),oldPrice:`$119`,finalPrice:`$89`,description:`Pre-seasoned, lifetime-guarantee. Made in USA.`})],{columns:1,showOldPrice:!0,showDescription:!0,buttonLabel:`View product`})])},{type:`ecom.bestseller_list`,category:`ecommerce`,name:`Bestseller Grid`,description:`Top products grid (3 up) with old/final prices. Used by retailers for weekly bestsellers.`,tags:[`bestsellers`,`grid`,`ranking`,`top`],create:()=>z(`ecom.bestseller_list`,`Bestsellers`,[V(`Top 3 this week`),G([W({name:`Linen Tote`,finalPrice:`$39`,oldPrice:`$49`}),W({name:`Ceramic Mug`,finalPrice:`$24`}),W({name:`Brass Lamp`,finalPrice:`$129`,oldPrice:`$149`})],{columns:3,showOldPrice:!0})])}],Zo=[{type:`tx.order_summary`,category:`transactional`,name:`Order Summary`,description:`Order confirmation summary: order number, line items with thumbnails and totals row. Used in post-purchase emails.`,tags:[`order`,`summary`,`receipt`,`post-purchase`,`ecommerce`],create:()=>z(`tx.order_summary`,`Order Summary`,[V(`Order #1024`),B(`Thanks for your order`,{paddingTop:0}),H(`We'll email you again when it ships.`),R({paddingTop:16,paddingBottom:8}),P(`Linen Tote Bag · 1 × $39.00`,{paddingTop:4,paddingBottom:4}),P(`Ceramic Mug · 2 × $24.00`,{paddingTop:4,paddingBottom:4}),R({paddingTop:8,paddingBottom:8}),P(`Subtotal: $87.00`,{paddingTop:2,paddingBottom:2}),P(`Shipping: $5.00`,{paddingTop:2,paddingBottom:2}),P(`Total: $92.00`,{fontWeight:`bold`,paddingTop:2,paddingBottom:16})])},{type:`tx.shipping_update`,category:`transactional`,name:`Shipping Update`,description:`Shipping confirmation with tracking number, carrier, expected delivery date and a Track button.`,tags:[`shipping`,`tracking`,`delivery`,`post-purchase`],create:()=>z(`tx.shipping_update`,`Shipping Update`,[P(`📦`,{align:`center`,fontSize:40,paddingTop:24}),B(`Your order is on the way`,{align:`center`,paddingTop:8}),H(`Carrier: USPS · Expected: May 4, 2026`,{align:`center`}),P(`Tracking: 9400 1108 ...`,{align:`center`,color:`{colors.muted}`,fontFamily:`Menlo, Consolas, monospace`,fontSize:13}),I(`Track package`),L(16)])},{type:`tx.invoice`,category:`transactional`,name:`Invoice`,description:`Itemized invoice with billing period, services and totals. Used by SaaS and B2B billing emails.`,tags:[`invoice`,`billing`,`saas`,`b2b`,`receipt`],create:()=>z(`tx.invoice`,`Invoice`,[V(`Invoice INV-2026-04`),B(`April 2026 invoice`),H(`Billed to: Acme Inc · Period: Apr 1 – Apr 30`),R({paddingTop:16,paddingBottom:8}),P(`Pro plan · $49.00`,{paddingTop:4,paddingBottom:4}),P(`Add-on seats (3) · $36.00`,{paddingTop:4,paddingBottom:4}),R({paddingTop:8,paddingBottom:8}),P(`Total due: $85.00`,{fontWeight:`bold`,paddingBottom:16}),I(`Download invoice (PDF)`),L(16)])},{type:`tx.password_reset`,category:`transactional`,name:`Password Reset`,description:`Authentication email with a reset button and a fallback link. Includes 'expires in X minutes' notice.`,tags:[`auth`,`password`,`reset`,`security`],create:()=>z(`tx.password_reset`,`Password Reset`,[B(`Reset your password`,{align:`center`,paddingTop:16}),P(`Click the button below to set a new password. This link expires in 30 minutes.`,{align:`center`,paddingBottom:16}),I(`Reset password`),H(`If the button doesn't work, paste this link in your browser:`,{align:`center`,fontSize:12}),P(`https://example.com/reset/abc123`,{align:`center`,color:`{colors.primary}`,fontSize:12,paddingBottom:24})])},{type:`tx.verify_email`,category:`transactional`,name:`Verify Email`,description:`Single-purpose 'verify your email' transactional with one centered button.`,tags:[`auth`,`verify`,`email-confirmation`],create:()=>z(`tx.verify_email`,`Verify Email`,[B(`One last step`,{align:`center`,paddingTop:16}),P(`Confirm your email address to activate your account.`,{align:`center`,paddingBottom:8}),I(`Verify email`),L(24)])},{type:`tx.appointment`,category:`transactional`,name:`Appointment Confirmation`,description:`Booking/meeting confirmation with date, time, location and add-to-calendar links.`,tags:[`appointment`,`booking`,`calendar`,`meeting`],create:()=>z(`tx.appointment`,`Appointment`,[V(`Confirmed`,{align:`center`}),B(`Your appointment is set`,{align:`center`,paddingTop:0}),P(`Tuesday, May 12 · 10:00 AM`,{align:`center`,fontWeight:`bold`,paddingTop:8}),H(`123 Main St, Suite 4 · Brooklyn, NY`,{align:`center`}),I(`Add to calendar`),L(16)])}],Qo=[{type:`social.icons`,category:`social`,name:`Social Icons Row`,description:`Centered 'Follow us' label with text-link icons in a row. Light footer-style social block.`,tags:[`social`,`follow`,`icons`,`row`],create:()=>z(`social.icons`,`Social Icons`,[H(`Follow us`,{align:`center`}),P(`Twitter · Instagram · LinkedIn · YouTube`,{align:`center`,color:`{colors.primary}`,paddingBottom:16})])},{type:`social.share`,category:`social`,name:`Share This Email`,description:`'Share this email' bar with Forward · Tweet · Share text links. Used at the end of newsletters.`,tags:[`social`,`share`,`forward`,`viral`],create:()=>z(`social.share`,`Share Bar`,[P(`Share this email`,{align:`center`,paddingTop:8}),P(`Forward · Tweet · Share`,{align:`center`,color:`{colors.primary}`,paddingBottom:8})])},{type:`social.featured_post`,category:`social`,name:`Featured Social Post`,description:`Embed-style preview of a single social post: avatar, name, post text and a link to view it on the platform.`,tags:[`social`,`post`,`embed`,`twitter`,`instagram`],create:()=>z(`social.featured_post`,`Social Post`,[V(`From the community`),F(U(48,48,`👤`),`Avatar`,{width:48,borderRadius:24}),P(`@maker · 2h`,{color:`{colors.muted}`,fontSize:13,paddingTop:4,paddingBottom:4}),P(`"Just shipped my newsletter using OpenPostcards. Honestly the smoothest email build I've ever done."`,{paddingBottom:8,lineHeight:1.6}),P(`View on Twitter →`,{color:`{colors.primary}`,paddingBottom:16,link:`#`})])},{type:`social.instagram_grid`,category:`social`,name:`Instagram Grid`,description:`3 small square thumbnails in a row representing recent Instagram posts, with handle and link.`,tags:[`social`,`instagram`,`grid`,`thumbnails`],create:()=>z(`social.instagram_grid`,`IG Grid`,[H(`@youraccount on Instagram`,{align:`center`}),F(U(180,180,`1`),`Post 1`,{width:180}),F(U(180,180,`2`),`Post 2`,{width:180}),F(U(180,180,`3`),`Post 3`,{width:180}),P(`View profile →`,{align:`center`,color:`{colors.primary}`,paddingTop:8,paddingBottom:16,link:`#`})])},{type:`social.community_stats`,category:`social`,name:`Community Stats`,description:`Short '12k Twitter · 4k IG · 2k YT' style row used to show following sizes.`,tags:[`social`,`stats`,`community`,`following`],create:()=>z(`social.community_stats`,`Community Stats`,[V(`Join the community`,{align:`center`}),P(`12k Twitter · 4k Instagram · 2k YouTube`,{align:`center`,paddingBottom:16}),L(8)])}],$o={backgroundColor:`{colors.background}`,paddingTop:0,paddingBottom:0},es=[{type:`footer.simple`,category:`footer`,name:`Simple Footer`,description:`Minimal footer with copyright, address and unsubscribe links. The default for any newsletter.`,tags:[`footer`,`simple`,`copyright`,`unsubscribe`],create:()=>z(`footer.simple`,`Simple Footer`,[H(`© 2026 Your Company. All rights reserved.`,{align:`center`,fontSize:12}),H(`123 Main St · City · Country`,{align:`center`,fontSize:12}),K([{label:`Unsubscribe`,type:`unsubscribe`},{label:`View in browser`,type:`view_in_browser`}])],{...$o,paddingTop:24})},{type:`footer.social`,category:`footer`,name:`Footer with Social`,description:`Footer with social links row above the legal text.`,tags:[`footer`,`social`,`links`],create:()=>z(`footer.social`,`Social Footer`,[P(`Follow us`,{align:`center`,paddingTop:24}),P(`Twitter · Instagram · LinkedIn`,{align:`center`,color:`{colors.primary}`,paddingBottom:12}),R(),H(`© 2026 Your Company`,{align:`center`,fontSize:12}),K([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],$o)},{type:`footer.legal`,category:`footer`,name:`Legal Footer`,description:`Long-form footer with explanation of why the user is receiving the email plus privacy/terms/unsubscribe links. Used by enterprise and finance newsletters.`,tags:[`footer`,`legal`,`compliance`,`enterprise`],create:()=>z(`footer.legal`,`Legal Footer`,[P(`You are receiving this email because you signed up for our newsletter. If you no longer wish to receive emails, you can unsubscribe at any time.`,{align:`center`,color:`{colors.muted}`,fontSize:11,lineHeight:1.6,paddingTop:24}),K([{label:`Privacy Policy`,type:`user_profile`},{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],$o)},{type:`footer.publisher`,category:`footer`,name:`Publisher Footer`,description:`Magazine-style sign-off with logo, publication name, masthead credits, address and links.`,tags:[`footer`,`publisher`,`magazine`,`masthead`,`editorial`],create:()=>z(`footer.publisher`,`Publisher Footer`,[F(U(120,36,`LOGO`),`Logo`,{width:120,paddingTop:24,paddingBottom:8}),P(`THE WEEKLY`,{align:`center`,fontFamily:`{fonts.heading}`,fontWeight:`bold`,letterSpacing:4,paddingTop:0,paddingBottom:4}),H(`Editor: Jane Doe · Producer: Alex Kim`,{align:`center`,fontSize:12}),R({paddingTop:12,paddingBottom:12}),H(`© 2026 The Weekly · 350 Madison Ave · NY 10017`,{align:`center`,fontSize:11}),K([{label:`Manage preferences`,type:`manage_preferences`},{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],$o)},{type:`footer.app_links`,category:`footer`,name:`Footer with App Store Badges`,description:`Footer including 'Get the app' app-store and play-store badge images. For consumer brand newsletters.`,tags:[`footer`,`app`,`download`,`ios`,`android`],create:()=>z(`footer.app_links`,`App Footer`,[P(`Get the app`,{align:`center`,fontWeight:`bold`,paddingTop:24,paddingBottom:8}),F(U(135,40,`App Store`),`App Store`,{width:135,align:`center`,paddingTop:0,paddingBottom:4}),F(U(135,40,`Google Play`),`Google Play`,{width:135,align:`center`,paddingTop:0,paddingBottom:16}),R(),H(`© 2026 Your Brand`,{align:`center`,fontSize:11}),K([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:24})],$o)},{type:`footer.address_only`,category:`footer`,name:`Address Only`,description:`Just a centered postal address line — required for CAN-SPAM compliance when other footers are minimal.`,tags:[`footer`,`address`,`compliance`,`can-spam`],create:()=>z(`footer.address_only`,`Address`,[H(`Your Company · 123 Main St · Brooklyn, NY 11201 · USA`,{align:`center`,fontSize:11}),K([{label:`Unsubscribe`,type:`unsubscribe`}],{paddingBottom:16})],{...$o,paddingTop:16})},{type:`footer.preferences`,category:`footer`,name:`Manage Preferences`,description:`Footer that emphasizes preference management ('Update your preferences', 'Send less often'). Reduces unsubscribes.`,tags:[`footer`,`preferences`,`frequency`,`retention`],create:()=>z(`footer.preferences`,`Preferences`,[P(`Getting too many emails?`,{align:`center`,paddingTop:24,paddingBottom:4}),K([{label:`Update your preferences`,type:`manage_preferences`},{label:`Unsubscribe`,type:`unsubscribe`}],{color:`{colors.primary}`,fontSize:13,paddingTop:4,paddingBottom:16}),R(),H(`© 2026 Your Company`,{align:`center`,fontSize:11}),P(` `,{align:`center`,paddingBottom:24})],$o)},{type:`footer.signature`,category:`footer`,name:`Signature Sign-off`,description:`Personal hand-signed style sign-off with author name and tiny legal block. For solo creator newsletters.`,tags:[`footer`,`signature`,`personal`,`creator`,`sign-off`],create:()=>z(`footer.signature`,`Signature`,[P(`Until next week,`,{paddingTop:24,paddingBottom:4}),P(`— Jane`,{fontFamily:`{fonts.heading}`,fontSize:22,paddingBottom:16}),R(),K([{label:`Unsubscribe`,type:`unsubscribe`}],{align:`left`,fontSize:11,paddingTop:4,paddingBottom:24,separator:` · `})],{...$o,paddingTop:0})}],ts=[...Wo,...Go,...Ko,...qo,...Jo,...Yo,...Xo,...Zo,...Qo,...es],ns=!1;function rs(){if(!ns){for(let e of ts)Ue.register(e);ns=!0}}rs();function is(){let{doc:e,addModule:t,loadFromLocalStorage:n}=M();return(0,l.useEffect)(()=>{if(n(),M.getState().doc.modules.length===0){for(let e of[`header.hero`,`content.headline_body`,`cta.simple`,`footer.simple`]){let n=Ue.get(e);n&&t(n.create())}M.setState({selection:{kind:`email`},past:[],future:[]})}},[]),(0,l.useEffect)(()=>{let e=setTimeout(()=>M.getState().saveToLocalStorage(),500);return()=>clearTimeout(e)},[e]),(0,p.jsxs)(`div`,{className:`oml-email-builder h-full w-full flex flex-col bg-gray-100`,children:[(0,p.jsx)(Re,{}),(0,p.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,p.jsx)(pt,{}),(0,p.jsx)(ra,{}),(0,p.jsx)(go,{})]})]})}var as=e=>{if(e&&typeof e==`object`)return e;throw Error(`AI server returned a non-object response.`)};function os(e){let t=e.transformResponse??as,n=e.timeoutMs??6e4;return{async generate(r){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{let n=await fetch(e.endpoint,{method:`POST`,headers:{"Content-Type":`application/json`,...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,body:JSON.stringify(r),signal:i.signal}),a=null,o=await n.text();try{a=o?JSON.parse(o):null}catch{}if(!n.ok){let e=(a&&typeof a==`object`&&`error`in a&&typeof a.error==`string`?a.error:null)??`AI request failed (HTTP ${n.status})`;throw Error(e)}return t(a)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`AI request timed out after ${n}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(a)}}}}function ss(e){let t=os(e);return{name:`ai-assistant`,type:`ai-provider`,setup(e){e.setAIProvider(t)}}}function cs(e){if(e==null)return null;if(Array.isArray(e))return cs(e[0]);if(typeof e!=`object`)return null;let t=e;for(let e of[`product`,`item`,`data`])if(t[e]&&typeof t[e]==`object`&&!Array.isArray(t[e]))return t[e];for(let e of[`results`,`products`,`items`,`hits`])if(Array.isArray(t[e]))return cs(t[e]);return t}function ls(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t;if(typeof t==`number`)return String(t)}}function us(e,t){for(let n of t){let t=e[n];if(typeof t==`number`&&Number.isFinite(t))return t;if(typeof t==`string`&&t.trim()!==``&&!Number.isNaN(Number(t)))return Number(t)}}var ds=e=>{let t=cs(e);if(!t)return null;let n=ls(t,[`name`,`title`,`product_name`,`productName`]),r=ls(t,[`finalPrice`,`final_price`,`price`,`sale_price`,`salePrice`]);return!n||r==null?null:{name:n,finalPrice:r,oldPrice:ls(t,[`oldPrice`,`old_price`,`compare_at_price`,`compareAtPrice`,`list_price`,`listPrice`]),description:ls(t,[`description`,`desc`,`summary`]),link:ls(t,[`link`,`url`,`product_url`,`productUrl`,`permalink`]),image:ls(t,[`image`,`image_url`,`imageUrl`,`thumbnail`,`img`]),imageAlt:ls(t,[`imageAlt`,`image_alt`,`alt`]),stars:us(t,[`stars`,`rating`,`review_score`,`reviewScore`,`score`]),sku:ls(t,[`sku`,`id`,`product_id`,`productId`])}};function fs(e){let t=e.method??`GET`,n=e.queryParam??`q`,r=e.bodyParam??`query`,i=e.timeoutMs??15e3,a=e.transformResponse??ds;return{async search(o){let s=o.trim();if(!s)return null;let c=new AbortController,l=setTimeout(()=>c.abort(),i);try{let i=e.endpoint,o={method:t,headers:{...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,signal:c.signal};if(t===`GET`){let t=typeof location<`u`?location.href:void 0,r=new URL(e.endpoint,t);r.searchParams.set(n,s),i=r.toString()}else o.headers[`Content-Type`]=`application/json`,o.body=JSON.stringify({[r]:s});let l=await fetch(i,o),u=null,d=await l.text();try{u=d?JSON.parse(d):null}catch{}if(!l.ok){let e=(u&&typeof u==`object`&&`error`in u&&typeof u.error==`string`?u.error:null)??`Product search failed (HTTP ${l.status})`;throw Error(e)}return a(u)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`Product search timed out after ${i}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(l)}}}}function ps(e){let t=fs(e);return{name:`product-search`,type:`product-provider`,setup(e){e.registerProductProvider(t)}}}function ms(e){if(Array.isArray(e))return e;if(e&&typeof e==`object`){let t=e;for(let e of[`vouchers`,`results`,`items`,`data`,`coupons`])if(Array.isArray(t[e]))return t[e]}return[]}function hs(e,t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim()!==``)return t;if(typeof t==`number`)return String(t)}}var gs=e=>{let t=[];for(let n of ms(e)){if(!n||typeof n!=`object`)continue;let e=n,r=hs(e,[`code`,`voucher_code`,`voucherCode`,`coupon`,`coupon_code`,`couponCode`,`value`]),i=hs(e,[`id`,`voucher_id`,`voucherId`,`uid`])??r;if(!i&&!r)continue;let a=hs(e,[`title`,`name`,`label`])??r??i??`Voucher`;t.push({id:i??a,title:a,code:r??i??a,description:hs(e,[`description`,`desc`,`summary`])})}return t};function _s(e){let t=e.method??`GET`,n=e.timeoutMs??15e3,r=e.transformResponse??gs;return{async list(){let i=new AbortController,a=setTimeout(()=>i.abort(),n);try{let n=await fetch(e.endpoint,{method:t,headers:{...e.headers??{}},credentials:e.withCredentials?`include`:`same-origin`,signal:i.signal}),a=null,o=await n.text();try{a=o?JSON.parse(o):null}catch{}if(!n.ok){let e=(a&&typeof a==`object`&&`error`in a&&typeof a.error==`string`?a.error:null)??`Voucher request failed (HTTP ${n.status})`;throw Error(e)}return r(a)}catch(e){throw e instanceof DOMException&&e.name===`AbortError`?Error(`Voucher request timed out after ${n}ms`):e instanceof Error?e:Error(String(e))}finally{clearTimeout(a)}}}}function vs(e){let t=_s(e);return{name:`voucher-select`,type:`voucher-provider`,setup(n){n.registerVoucherProvider(t),e.preload&&Aa()}}}var ys=e=>{if(e&&typeof e==`object`&&`url`in e&&typeof e.url==`string`){let t=e;return{url:t.url,alt:typeof t.alt==`string`?t.alt:void 0}}throw Error(`Server response missing "url" string field.`)};function bs(e){let t=e.fieldName??`file`,n=(e.maxSizeMB??10)*1024*1024,r=e.transformResponse??ys;return{upload(i){return i.type.startsWith(`image/`)?i.size>n?Promise.reject(Error(`File too large: ${(i.size/1024/1024).toFixed(2)} MB > ${e.maxSizeMB??10} MB`)):new Promise((n,a)=>{let o=new XMLHttpRequest,s=new FormData;if(s.append(t,i,i.name),o.open(`POST`,e.endpoint,!0),o.withCredentials=!!e.withCredentials,e.headers)for(let[t,n]of Object.entries(e.headers))o.setRequestHeader(t,n);e.onProgress&&o.upload&&(o.upload.onprogress=t=>{t.lengthComputable&&e.onProgress(Math.round(t.loaded/t.total*100))}),o.onload=()=>{let e=o.status>=200&&o.status<300,t=null;try{t=o.responseText?JSON.parse(o.responseText):null}catch{}if(!e){let e=(t&&typeof t==`object`&&`error`in t&&typeof t.error==`string`?t.error:null)??`Upload failed (HTTP ${o.status})`;return a(Error(e))}try{n(r(t))}catch(e){a(e instanceof Error?e:Error(String(e)))}},o.onerror=()=>a(Error(`Network error during upload`)),o.onabort=()=>a(Error(`Upload aborted`)),o.send(s)}):Promise.reject(Error(`Not an image: ${i.type||`unknown`}`))}}}function xs(e){return{name:`image-uploader`,type:`asset-provider`,setup(t){t.registerAssetProvider(bs(e))}}}function Ss(e){return(0,l.useEffect)(()=>{if(rs(),e.modules)for(let t of e.modules)Ue.register(t);if(e.themes&&M.setState({themes:e.themes}),e.aiProvider)Fa.setAIProvider(e.aiProvider);else if(e.aiEndpoint){let t=typeof e.aiEndpoint==`string`?{endpoint:e.aiEndpoint}:e.aiEndpoint;Fa.setAIProvider(os(t))}if(e.productProvider)Fa.registerProductProvider(e.productProvider);else if(e.productEndpoint){let t=typeof e.productEndpoint==`string`?{endpoint:e.productEndpoint}:e.productEndpoint;Fa.registerProductProvider(fs(t))}if(e.voucherProvider)Fa.registerVoucherProvider(e.voucherProvider);else if(e.voucherEndpoint){let t=typeof e.voucherEndpoint==`string`?{endpoint:e.voucherEndpoint}:e.voucherEndpoint;Fa.registerVoucherProvider(_s(t)),typeof e.voucherEndpoint!=`string`&&e.voucherEndpoint.preload&&Aa()}if(e.mergeTags&&Fa.registerMergeTags(e.mergeTags),e.initialDocument){let t=b.safeParse(e.initialDocument);t.success&&M.getState().applyDoc(t.data,!1)}let t=M.subscribe((t,n)=>{t.doc!==n.doc&&e.onChange?.(t.doc)});return()=>t()},[]),(0,l.useEffect)(()=>{if(e.onExportHtml)return M.subscribe((t,n)=>{t.doc!==n.doc&&e.onExportHtml?.(k(t.doc))})},[e.onExportHtml]),(0,l.createElement)(is)}function Cs(e){let t=(0,c.createRoot)(e.container);return t.render((0,l.createElement)(Ss,e)),{destroy:()=>t.unmount(),getDocument:()=>M.getState().doc,exportHtml:()=>M.getState().exportHtml(),exportJson:()=>M.getState().exportJson()}}exports.ALGORITHMS=za,exports.ALGORITHM_BY_ID=Ba,exports.EmailBuilder=Ss,exports.FALLBACK_OPTIONS=Va,exports.TEMPLATE_CATEGORY_LABELS=ye,exports.aiAssistantPlugin=ss,exports.applyAIActions=et,exports.applyAIResponse=st,exports.buildCatalog=$e,exports.createEmailBuilder=Cs,exports.createHttpAIProvider=os,exports.createProductSearchProvider=fs,exports.createVoucherProvider=_s,exports.defaultRecommendationsLogic=Ha,exports.documentSchema=b,exports.getActiveProductProvider=va,exports.getActiveVoucherProvider=Oa,exports.imageUploaderPlugin=xs,exports.isVoucherAware=co,exports.mockAIProvider=rt,exports.productSearchPlugin=ps,exports.readRecommendationsLogic=Ua,exports.recommendationsToLegacyShape=Ka,exports.registerPlugin=Ia,exports.renderEmailHtml=k,exports.setActiveProductProvider=_a,exports.setActiveVoucherProvider=Da,exports.templateRegistry=N,exports.validateAIDocument=nt,exports.voucherPlugin=vs;
|
|
82
82
|
//# sourceMappingURL=email-builder.cjs.map
|