@markopolo_ai_inc/markopolo-email-editor 1.0.74 → 1.0.75

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/lib/core/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";const t="https://api-alpha.markopolo.ai/v1",e="https://nbq-ml-api-stg.markopolo.ai/v1",n="https://backend-api-stg.markopolo.ai/v2",o="95b48b5b-cf5e-486d-817e-9839d4c4e618";function i(t){try{return t()}catch{return}}function r(n,o){const i=null!=(r=n)&&"string"==typeof r&&r.trim()?r.replace(/\/$/,""):t;var r;const l=function(t){return null!=t&&"string"==typeof t&&t.trim()?t.replace(/\/$/,""):e}(o);return{imageUploadEndpoint:`${i}/upload-file`,imageUploadQueryParams:{show:!1},imageUploadCompanyField:"comment",productsEndpoint:`${i}/knowledge-base/products`,universalEmailBlocksEndpoint:`${i}/universal-email-blocks`,mlEmailGenerateEndpoint:`${l}/ml-service/content/generate-email`}}function l(t){const e=String(t??"").trim();return/^(?:javascript|vbscript)\s*:/i.test(e)||/^data\s*:/i.test(e)}function a(t){let e=String(t??"").trim();if(!e)return"";if(l(e))return"";for(let t=0;t<e.length;t++){const n=e.charCodeAt(t),o=e[t];if(n<32||"<"===o||">"===o||'"'===o)return""}return e}function s(t){const e=String(t??"").trim().match(/^https?:\/\/(.+)/is);return!!e&&/^https?:\/\//i.test(e[1])}function c(t,e={}){const{allowMailtoTel:n=!0}=e,o=String(t??"").trim();if(!o)return null;if(l(o))return null;if(s(o))return null;if(n&&(/^mailto:/i.test(o)||/^tel:/i.test(o)))return o;const i=/^https?:\/\//i.test(o)?o:`https://${o.replace(/^\/+/,"")}`;return d(i,!1,e)?i:null}function d(t,e=!1,n={}){return null==u(t,e,n)}function u(t,e=!1,n={}){const{allowMailtoTel:o=!0}=n;if(null==t||""===String(t).trim())return e?null:"empty";const i=String(t).trim();if(l(i))return"blocked_scheme";if(s(i))return"duplicate_protocol";let r;if(/^https?:\/\//i.test(i)){const t=i.replace(/^https?:\/\//i,"");if(/^https?:\/\//i.test(t))return"duplicate_protocol";r=i}else r=o&&/^mailto:/i.test(i)||o&&/^tel:/i.test(i)?i:`https://${i}`;try{const t=new URL(r);return"http:"===t.protocol||"https:"===t.protocol?function(t){const e=String(t??"").trim().toLowerCase();return""!==e&&"http"!==e&&"https"!==e&&("localhost"===e||!!e.includes(":")||!!/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)||e.includes("."))}(t.hostname)?null:"missing_hostname_dot":o&&"mailto:"===t.protocol||o&&"tel:"===t.protocol?null:"invalid_protocol"}catch{return"invalid_url"}}function m(t){return!1!==t?.linkEnabled}const p={EMAIL_WIDTH:"email_width",CUSTOM_PX:"custom_px",FULL_BLEED:"full_bleed"};function g(t){const e=Math.round(Number(t));return!Number.isFinite(e)||e<=0?600:Math.min(1200,Math.max(280,e))}function f(t){return function(t){const e=t?.contentWidthMode;return Object.values(p).includes(e)?e:p.EMAIL_WIDTH}(t)===p.FULL_BLEED}const y={preHeader:"",contentWidth:600,stackColumnsOnMobile:!0,scaleFontOnMobile:!0,styles:{backgroundColor:"#F5F5F5",contentBg:"#FFFFFF",color:"#171717",headingColor:"#171717",linkColor:"#338AF3",fontFamily:"'Overused Grotesk', ui-sans-serif, system-ui, sans-serif"}};function b(t){const e=String(t??"").trim();return/^\{\{[A-Za-z_]\w*\}\}$/.test(e)}const k=/^\s*\{\{[\s\S]*\}\}\s*$/;function h(t){const e=String(t??"").trim();if(!e)return!1;if("#"===e)return!1;if(e.startsWith("#")&&e.length>1)return!1;if(k.test(e))return!1;if(b(e))return!1;const n=e.toLowerCase();return!n.startsWith("http://")&&!n.startsWith("https://")&&(!n.startsWith("mailto:")&&!n.startsWith("tel:")&&!n.startsWith("//"))}function $(t,e=!1){if(null==t||""===String(t).trim())return e;const n=String(t).trim();try{return/^https?:\/\//i.test(n)?new URL(n):new URL("https://"+n),!0}catch{return!1}}const x={text:"Text",heading:"Heading",button:"Button",image:"Image",video:"Video",avatar:"Profile image",menu:"Menu",social_link:"Social links",raw_html:"HTML"};const v={none:"Container",product:"Product",discount:"Discount",header:"Header",footer:"Footer",navigation_bar:"Navigation",introduction:"Introduction",hero:"Hero",hero_product:"Hero product",body:"Body",additional_product:"Additional product"};function S(t,e,n){const o=t.containerType??"none",i=function(t){const e=t??"none";return v[e]?v[e]:String(e).replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}(o);return n<=1?i:"none"===o?`${w(e+1)} section`:`${w(e+1)} ${i} block`}function w(t){const e=t%10,n=t%100;return 1===e&&11!==n?`${t}st`:2===e&&12!==n?`${t}nd`:3===e&&13!==n?`${t}rd`:`${t}th`}function C(t,e,n){const o=function(t){return x[t]?x[t]:String(t||"block").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}(e),i=[...t],r=i.length>0?i.join(" → "):"Email body";return n?`${o} ("${n}") — ${r}`:`${o} — ${r}`}function _(t,e){const n=function(t){return null==t||"object"!=typeof t?{...y,styles:{...y.styles}}:{preHeader:null!=t.preHeader?t.preHeader:y.preHeader,contentWidth:g(null!=t.contentWidth?t.contentWidth:y.contentWidth),stackColumnsOnMobile:!1!==t.stackColumnsOnMobile,scaleFontOnMobile:!1!==t.scaleFontOnMobile,styles:{backgroundColor:null!=t.styles?.backgroundColor?t.styles.backgroundColor:y.styles.backgroundColor,contentBg:null!=t.styles?.contentBg?t.styles.contentBg:y.styles.contentBg,color:null!=t.styles?.color?t.styles.color:y.styles.color,headingColor:null!=t.styles?.headingColor?t.styles.headingColor:y.styles.headingColor,linkColor:null!=t.styles?.linkColor?t.styles.linkColor:y.styles.linkColor,fontFamily:null!=t.styles?.fontFamily?t.styles.fontFamily:y.styles.fontFamily}}}(t);("number"!=typeof n.contentWidth||!Number.isFinite(n.contentWidth)||n.contentWidth<=0)&&e.push({severity:"error",code:"body_content_width_invalid",message:"Body content width must be between 280 and 1200 px.",location:"Theme settings"});const o=n.styles;null!=o.backgroundColor&&""!==String(o.backgroundColor).trim()||e.push({severity:"error",code:"body_background_color_missing",message:"Theme background color is missing.",location:"Theme settings"}),null!=o.color&&""!==String(o.color).trim()||e.push({severity:"error",code:"body_text_color_missing",message:"Theme text color is missing.",location:"Theme settings"}),null!=o.fontFamily&&""!==String(o.fontFamily).trim()||e.push({severity:"error",code:"body_font_family_missing",message:"Theme font family is missing.",location:"Theme settings"})}function A(t,e){t.push(e)}function L(t){return null==t?"":String(t).replace(/&amp;/gi,"&").replace(/&quot;/gi,'"').replace(/&#39;/g,"'").trim()}function P(t){if(null==t||"string"!=typeof t)return[];const e=[],n=/<a\b[^>]*?\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>"']+))/gi;let o=n.exec(t);for(;o;){const i=o[1]??o[2]??o[3]??"";e.push(L(i)),o=n.exec(t)}return e}function T(t,e=!0){const n=String(t??"").trim();return n?b(n)?null:u(n,!1,{allowMailtoTel:e}):null}function B(t,e,n){const o=t.linkURL,i=()=>C(e,"button",void 0),r=t.id??null;null==o||""===String(o).trim()?A(n,{severity:"warning",code:"button_empty_link",message:'Button link URL is empty; will be saved as href="https://".',location:i(),blockId:r}):l(o)?A(n,{severity:"error",code:"button_blocked_scheme",message:"Button link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",location:i(),blockId:r}):b(o)||d(o,!1,{allowMailtoTel:!0})?!b(o)&&h(o)&&A(n,{severity:"warning",code:"button_link_missing_protocol",message:"Button link should start with https://, http://, mailto:, or tel: for reliable email clients.",location:i(),blockId:r}):A(n,{severity:"warning",code:"button_invalid_link",message:"Button link URL format is invalid.",location:i(),blockId:r}),function(t,e,n,o,{invalidCode:i,invalidMessage:r,blockedCode:a,blockedMessage:s,missingProtocolCode:c,missingProtocolMessage:u}){P(t??"").forEach((t,m)=>{const p=String(t??"").trim();""!==p&&(l(p)?A(e,{severity:"error",code:a,message:s,location:n(m),blockId:o}):d(p,!1,{allowMailtoTel:!0})?h(p)&&A(e,{severity:"warning",code:c,message:u,location:n(m),blockId:o}):A(e,{severity:"warning",code:i,message:r,location:n(m),blockId:o}))})}(t.text,n,t=>C(e,"button",`label link ${t+1}`),r,{invalidCode:"button_label_invalid_link",invalidMessage:"Button label link URL format is invalid.",blockedCode:"button_label_blocked_link_scheme",blockedMessage:"Button label link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",missingProtocolCode:"button_label_link_missing_protocol",missingProtocolMessage:"Button label link should start with https://, http://, mailto:, or tel: for reliable email clients."})}const I=["product"];function U(t,e,n,o,i){(function(...t){const e=new Set,n=[];for(const o of t)if(null!=o&&""!==String(o).trim())for(const t of P(String(o))){const o=String(t).trim();o&&!e.has(o)&&(e.add(o),n.push(t))}return n})(t.text,t.dynamicSelectedContent).forEach((i,r)=>{const a=String(i??"").trim();""!==a&&(a.startsWith("#")||k.test(a)||(l(a)?A(n,{severity:"error",code:"text_blocked_link_scheme",message:"Text link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",location:C(e,o,`link ${r+1}`),blockId:t.id??null}):d(a,!1,{allowMailtoTel:!0})?h(a)&&A(n,{severity:"warning",code:"text_link_missing_protocol",message:"Text link should start with https://, http://, mailto:, or tel: for reliable email clients.",location:C(e,o,`link ${r+1}`),blockId:t.id??null}):A(n,{severity:"warning",code:"text_invalid_link",message:"Text link URL format is invalid.",location:C(e,o,`link ${r+1}`),blockId:t.id??null})))});if("dynamic"!==(t.contentType??"static"))return;const r=t.dynamicSelectedContent,a=null!=t?.id?i?.[t.id]?.selectedContent:void 0;let s=null!=r&&""!==String(r).trim()?r:a;var c;null!=s&&""!==String(s).trim()||null==t.text||""===(null==(c=t.text)?"":String(c).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())||(s=t.text),null!=s&&""!==String(s).trim()||A(n,{severity:"warning",code:"dynamic_content_empty",message:"Dynamic content not generated; export will use static text if available.",location:C(e,o,void 0),blockId:t.id??null})}function N(t,e,n){const o=t.list||[],i=new Set;o.forEach((o,r)=>{const a=o.title||o.image||`link ${r+1}`,s=t=>C(e,"social_link",t||a),c=function(t){const e=String(t?.image||"").trim();if(e)return`img:${e}`;const n=String(t?.title||"").trim().toLowerCase();return n?`title:${n}`:null}(o);c&&(i.has(c)?A(n,{severity:"warning",code:"social_duplicate_platform",message:"Duplicate social platform in this block; only one entry per platform should be kept.",location:s(a),blockId:t.id??null}):i.add(c));const u=o.linkURL;if(null==u||""===String(u).trim()){const e=String(o?.title||"").trim()||`Item ${r+1}`;A(n,{severity:"warning",code:"social_empty_link",message:`${e} URL is empty — add https URL before sending; the icon still previews without an outbound link.`,location:s(a),blockId:t.id??null})}else l(u)?A(n,{severity:"error",code:"social_blocked_scheme",message:"Social link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s) URLs only (e.g. www.example.com or https://…).",location:s(a),blockId:t.id??null}):d(u,!1,{allowMailtoTel:!1})||A(n,{severity:"warning",code:"social_invalid_link",message:"Social link URL format is invalid.",location:s(a),blockId:t.id??null});const m=o.image;null==m||""===String(m).trim()?A(n,{severity:"warning",code:"social_empty_icon",message:"Social link icon URL is empty; icon will not display.",location:s(a),blockId:t.id??null}):$(m,!1)||A(n,{severity:"warning",code:"social_invalid_icon",message:"Social link icon URL format is invalid.",location:s(a),blockId:t.id??null})}),0===o.length&&A(n,{severity:"info",code:"social_no_links",message:"Social link block has no links.",location:C(e,"social_link",void 0),blockId:t.id??null})}function E(t,e,n,o,i){if(!Array.isArray(t))return;const r=t.length;t.forEach((t,a)=>{if(!t||"object"!=typeof t)return;if(!0===t.hidden)return;const s=t.key;if("column"===s){const l=S(t,a,r),s=[...e,l];return function(t,e,n){const o=t.containerType??"none";if(!I.includes(o))return;const i=t.children??[],r=t.columnProducts??[];i.forEach((o,l)=>{const a=r[l];if(null==a||"object"==typeof a&&!a.id){const o=i.length>1?`Column ${l+1} of ${i.length}`:"This column",r=[...e,o].join(" → ");A(n,{severity:"warning",code:"container_product_not_assigned",message:"A product is not assigned to this column; assign a product in Container settings.",location:r,blockId:t.id??null})}})}(t,s,n),void(Array.isArray(t.children)&&E(t.children,s,n,o,i))}if("content"===s){const l=r>1?`Column ${a+1} of ${r}`:null,s=l?[...e,l]:e;return void(Array.isArray(t.children)&&E(t.children,s,n,o,i))}switch(s){case"image":!function(t,e,n){const o=t.src,i=()=>C(e,"image",void 0);null!=o&&""!==String(o).trim()?($(o,!1)||A(n,{severity:"warning",code:"image_invalid_src",message:"Image URL format is invalid.",location:i(),blockId:t.id??null}),m(t)&&T(t.linkURL,!0)&&A(n,{severity:"warning",code:"image_invalid_link",message:"Image link URL format is invalid.",location:i(),blockId:t.id??null}),null!=t.alt&&""!==String(t.alt).trim()||A(n,{severity:"info",code:"image_empty_alt",message:"Image alt text is empty; consider adding for accessibility.",location:i(),blockId:t.id??null})):A(n,{severity:"error",code:"image_empty_src",message:"Image URL is empty; the image will not display.",location:i(),blockId:t.id??null})}(t,e,n);break;case"video":!function(t,e,n){const o=()=>C(e,"video",void 0),i=null!=t.videoUrl?String(t.videoUrl).trim():"";i?$(i,!1)||A(n,{severity:"warning",code:"video_invalid_url",message:"Video URL format may be invalid.",location:o(),blockId:t.id??null}):A(n,{severity:"error",code:"video_empty_url",message:"Video URL is empty; the video will not display.",location:o(),blockId:t.id??null})}(t,e,n);break;case"avatar":!function(t,e,n){const o=t.src,i=()=>C(e,"avatar",void 0);null==o||""===String(o).trim()?A(n,{severity:"warning",code:"avatar_empty_src",message:"Avatar image URL is empty; avatar will not display.",location:i(),blockId:t.id??null}):$(o,!1)||A(n,{severity:"warning",code:"avatar_invalid_src",message:"Avatar image URL format is invalid.",location:i(),blockId:t.id??null}),T(t.linkURL,!0)&&A(n,{severity:"warning",code:"avatar_invalid_link",message:"Avatar link URL format is invalid.",location:i(),blockId:t.id??null})}(t,e,n);break;case"button":B(t,e,n);break;case"menu":!function(t,e,n){const o=t.list||[];o.forEach((o,i)=>{const r=String(o.label??"").trim()||`Item ${i+1}`,a=t=>C(e,"menu",t||`Item ${i+1}`);null!=o.label&&""!==String(o.label).trim()||A(n,{severity:"info",code:"menu_empty_label",message:'Navigation link label is empty; will display as "Link".',location:a(`item ${i+1}`),blockId:t.id??null});const s=o.url;null==s||""===String(s).trim()?A(n,{severity:"warning",code:"menu_empty_url",message:`"${r}" link URL is empty; will be saved as href="#". Add a destination URL (e.g. https://example.com) before sending.`,location:a(r),blockId:t.id??null}):l(s)?A(n,{severity:"error",code:"menu_blocked_scheme",message:`"${r}" link uses a blocked URL scheme (javascript:, data:, etc.). Use https://, mailto:, or tel: only.`,location:a(r),blockId:t.id??null}):d(s,!1,{allowMailtoTel:!0})?!b(s)&&h(s)&&A(n,{severity:"warning",code:"menu_item_url_missing_protocol",message:`"${r}" link should start with https://, http://, mailto:, or tel: for reliable email client support.`,location:a(r),blockId:t.id??null}):A(n,{severity:"warning",code:"menu_invalid_url",message:`"${r}" link URL is not valid. Use a full URL starting with https://example.com.`,location:a(r),blockId:t.id??null})}),0===o.length&&A(n,{severity:"info",code:"menu_no_items",message:"Menu block has no items.",location:C(e,"menu",void 0),blockId:t.id??null})}(t,e,n);break;case"social_link":N(t,e,n);break;case"raw_html":!function(t,e,n){const o=t.html;null!=o&&""!==String(o).trim()||A(n,{severity:"info",code:"raw_html_empty",message:"HTML block has no custom markup; export will include an empty wrapper.",location:C(e,"raw_html",void 0),blockId:t.id??null})}(t,e,n);break;case"text":U(t,e,n,"text",i);break;case"heading":U(t,e,n,"heading",i)}})}function M({blockList:t,bodySettings:e,aiContentRefs:n={}}){const o=[];return _(e,o),E(Array.isArray(t)?t:[],[],o,e,n),o}function R(){const t="undefined"!=typeof window&&null!=window?window:"undefined"!=typeof global&&null!=global?global:void 0;if(!t)return;const e=t.Image;return"function"==typeof e?e:void 0}const F=/^\{\{\s*[\w.]+\s*\}\}$/;function D(t){if(null==t||""===String(t).trim())return null;const e=String(t).trim();if(function(t){return null!=t&&"string"==typeof t&&F.test(t.trim())}(e))return null;if(/^https?:\/\//i.test(e))return $(e,!1)?e:null;if(e.startsWith("//")){const t=`https:${e}`;return $(t,!1)?t:null}return null}function j(t,e=[],n=t?.length??0){const o=[];return Array.isArray(t)?(t.forEach((t,i)=>{if(!t||"object"!=typeof t)return;if(!0===t.hidden)return;const r=t.key;if("column"===r){const r=S(t,i,n),l=[...e,r],a=t.children;return void o.push(...j(a,l,a?.length??0))}if("content"===r){const r=n>1?`Column ${i+1} of ${n}`:null,l=r?[...e,r]:e,a=t.children;return void o.push(...j(a,l,a?.length??0))}if("image"===r){const n=D(t.src);n&&o.push({url:n,location:C(e,"image",void 0),blockId:t.id??null})}}),o):o}function z(t,e=12e3){const n=R();if(!n)return Promise.resolve(!1);const o=String(t).trim();return o?new Promise(t=>{const i=new n;let r=!1;const l=e=>{r||(r=!0,clearTimeout(a),i.onload=null,i.onerror=null,t(e))},a=setTimeout(()=>l(!1),e);i.onload=()=>l(!0),i.onerror=()=>l(!1);try{i.src=o}catch{l(!1)}}):Promise.resolve(!1)}async function W(t,e={}){const{timeoutMs:n=12e3,concurrent:o=6}=e;if(!R())return[];const i=j(Array.isArray(t)?t:[]);if(0===i.length)return[];const r=new Map;for(const t of i)r.has(t.url)||r.set(t.url,[]),r.get(t.url).push(t.location);const l=[...r.keys()],a=new Map;let s=0;const c=Math.max(1,Math.min(o,l.length));await Promise.all(Array.from({length:c},()=>async function(){for(;s<l.length;){const t=s++,e=l[t],o=await z(e,n);a.set(e,o)}}()));const d=[];for(const[t,e]of r)if(!0!==a.get(t))for(const n of e)d.push({severity:"warning",code:"image_url_not_loadable",message:"Image URL could not be loaded or previewed; the link may be broken, expired, or blocked.",location:n,blockId:i.find(e=>e.url===t&&e.location===n)?.blockId??null});return d}async function O(t,e){return[...M(t),...await W(t?.blockList??[],e)]}var K={global:[{key:"CustomerName",token:"{{CustomerName}}",label:"Customer Name",labelKey:"variable_customer_name",type:"text",fallback:"Customer",source:"derived"},{key:"BrandName",token:"{{BrandName}}",label:"Brand Name",labelKey:"variable_brand_name",type:"text",fallback:"Company Name",source:"companyContext.name"},{key:"Tagline",token:"{{Tagline}}",label:"Tagline",labelKey:"variable_tagline",type:"text",fallback:"Your tagline here",source:"brandContext.tagline"},{key:"LogoUrl",token:"{{LogoUrl}}",label:"BrandLogo",labelKey:"variable_image_logo",type:"image",fallback:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",source:"brandContext.logo_url"},{key:"Website",token:"{{Website}}",label:"Website",labelKey:"variable_website",type:"text",fallback:"www.example.com",source:"companyContext.website"},{key:"Address",token:"{{Address}}",label:"Address",labelKey:"variable_address",type:"text",fallback:"",source:"companyContext.address"}],product:[{key:"ProductName",token:"{{ProductName}}",label:"Product Name",labelKey:"variable_product_name",type:"text",fallback:"Product Name",source:"content.products[].name"},{key:"ProductDescription",token:"{{ProductDescription}}",label:"Product Description",labelKey:"variable_product_description",type:"text",fallback:"Product description goes here.",source:"content.products[].description"},{key:"ProductImage",token:"{{ProductImage}}",label:"Product Image URL",labelKey:"variable_product_image",type:"image",fallback:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",source:"content.products[].image"},{key:"ProductLink",token:"{{ProductLink}}",label:"Product Link",labelKey:"variable_product_link",type:"url",fallback:"https://www.example.com",source:"content.products[].link"},{key:"ProductPrice",token:"{{ProductPrice}}",label:"Product Price (Amount)",labelKey:"variable_product_price",type:"number",fallback:"0",source:"content.products[].price.amount"},{key:"ProductCurrency",token:"{{ProductCurrency}}",label:"Product Currency",labelKey:"variable_product_currency",type:"text",fallback:"USD",source:"content.products[].price.currency"},{key:"ProductOldPrice",token:"{{ProductOldPrice}}",label:"Product Old Price",labelKey:"variable_product_old_price",type:"number",fallback:"0",source:"content.products[].old_price"},{key:"ProductNewPrice",token:"{{ProductNewPrice}}",label:"Product New Price",labelKey:"variable_product_new_price",type:"number",fallback:"0",source:"content.products[].new_price"},{key:"ProductPriceDisplay",token:"{{ProductPriceDisplay}}",label:"Product Price Display",labelKey:"variable_product_price_display",type:"text",fallback:"USD 0",source:"derived"}],discount:[{key:"DiscountValue",token:"{{DiscountValue}}",label:"Discount Value",labelKey:"variable_discount_value",type:"text",fallback:"20%",source:"content.discount.value"},{key:"DiscountCode",token:"{{DiscountCode}}",label:"Discount Code",labelKey:"variable_discount_code",type:"text",fallback:"SAVE20",source:"content.discount.code"},{key:"ValidUntil",token:"{{ValidUntil}}",label:"Valid Until",labelKey:"variable_valid_until",type:"date",fallback:"12-31-2025",source:"content.discount.valid_until"}]};const H="CustomerName",V="DiscountValue",G="DiscountCode",J="ValidUntil",Z="CompanyName",Y="Address",q="Website",X="BrandName",Q="LogoUrl",tt="Tagline",et="HeroBanner",nt="FooterBanner",ot="NavLabel",it="NavUrl",rt="ProductName",lt="ProductDescription",at="ProductImage",st="ProductLink",ct="ProductPrice",dt="ProductCurrency",ut="ProductOldPrice",mt="ProductNewPrice",pt="ProductPriceDisplay",gt="CTALabel",ft="CTAUrl",yt=new Set([ut,mt]);let bt=K;function kt(t,e=bt){return e&&Array.isArray(e[t])?e[t].map(t=>{return{...t,token:t.token||(e=t.key,`{{${e}}}`)};var e}):[]}let ht=[],$t=[],xt=[];!function(){ht=kt("global",bt),$t=kt("product",bt),xt=kt("discount",bt),[...ht,...$t,...xt].reduce((t,e)=>(t[e.key]=e,t),{}),xt.map(t=>({variableKey:t.key,labelKey:t.labelKey}));const t=$t.filter(t=>!yt.has(t.key));t.map(t=>({variableKey:t.key,labelKey:t.labelKey})),ht.map(t=>({value:t.token,label:t.label,key:t.key,labelKey:t.labelKey,source:t.source,type:t.type})),xt.map(t=>({value:t.token,label:t.label,key:t.key,labelKey:t.labelKey,source:t.source,type:t.type})),t.map(t=>({value:t.token,label:t.label,key:t.key,labelKey:t.labelKey,source:t.source,type:t.type}))}();const vt={[H]:"User",[V]:"20%",[G]:"SAVE20",[J]:"12-31-2025",[Z]:"Company Name",[X]:"Company Name",[Y]:"",[q]:"www.example.com",[Q]:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",[tt]:"Your tagline here",[et]:"https://via.placeholder.com/600x200/eeeeee/666666?text=Hero",[nt]:"https://via.placeholder.com/600x100/eeeeee/666666?text=Footer",[ot]:"Link",[it]:"https://www.example.com",[rt]:"Product Name",[lt]:"Product description goes here.",[at]:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",[st]:"https://www.example.com",[ct]:"0",[dt]:"USD",[ut]:"0",[mt]:"0",[pt]:"$0.00 USD",[gt]:"Shop Now",[ft]:"www.example.com"};function St(t){return null==t||"string"!=typeof t?"":t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const wt=new Set([pt]);function Ct(t,e,n={}){if(null==t||"string"!=typeof t)return"";const o=t.replace(/\{\{(\w+)\}\}/g,(t,o)=>{const i=It(e,o,n);return wt.has(o)?i:St(i)});return null==(i=o)||"string"!=typeof i?i:i.replace(/^(<p[^>]*>\s*(?:<br\s*\/?>|&nbsp;)?\s*<\/p>\s*)+/i,"");var i}function _t(t){return vt[t]??"—"}const At=/^\{\{\s*[\w.]+\s*\}\}$/;function Lt(t,e,{allowEmpty:n=!1}={}){if(null==t)return n?"":_t(e);const o=String(t).trim();return""===o?n?"":_t(e):function(t){return"string"==typeof t&&At.test(t.trim())}(o)?_t(e):o}const Pt={USD:"en-US",CAD:"en-CA",EUR:"de-DE",GBP:"en-GB",AUD:"en-AU",NZD:"en-NZ",SGD:"en-SG",INR:"en-IN",JPY:"ja-JP",CNY:"zh-CN",BDT:"bn-BD",AED:"ar-AE",SAR:"ar-SA"};function Tt(t){return function(t){return"string"==typeof t&&/^[A-Za-z]{3}$/.test(t.trim())}(t)?String(t).trim().toUpperCase():"USD"}function Bt(t,e){const n=function(t){if(null==t)return null;const e=String(t).replace(/,/g,"").trim();if(""===e)return null;const n=Number(e);return Number.isFinite(n)?n:null}(t);if(null==n)return null;const o=Tt(e),i=function(t){return Pt[t]??null}(o);if(!i)return null;const r=function(t){if(null==t)return 0;const e=String(t).trim().replace(/,/g,"");if(!e.includes("."))return 0;const[,n=""]=e.split(".");return Math.max(0,n.length)}(t);try{return`${new Intl.NumberFormat(i,{style:"currency",currency:o,minimumFractionDigits:r,maximumFractionDigits:r}).format(n)} ${o}`}catch{return null}}function It(t,e,n={}){if(!t)return _t(e);const{columnIndex:o,columnProduct:i}=n;let r=i;switch(!r&&t.content?.products&&"number"==typeof o&&(r=t.content.products[o]||null),e){case H:return Lt(t.user?.name,H);case V:return Lt(t.content?.discount?.value,V);case G:return Lt(t.content?.discount?.code,G);case J:return Lt(t.content?.discount?.valid_until,J);case Z:case X:return Lt(t.companyContext?.name,e);case Y:return Lt(t.companyContext?.address,Y,{allowEmpty:!0});case q:return Lt(t.companyContext?.website,q);case Q:return Lt(t.brandContext?.logo_url,Q);case tt:return Lt(t.brandContext?.tagline,tt);case et:return Lt(t.brandContext?.heroBanner,et);case nt:return Lt(t.brandContext?.footerBanner,nt);case ot:case it:return _t(e);case rt:return Lt(r?.name,rt);case lt:{const t=function(t){if(null==t)return"";const e=String(t).trim();if(!e)return"";const n=e.toLowerCase();return"none"===n||"null"===n||"undefined"===n?"":e}(r?.description);return t?Lt(t,lt,{allowEmpty:!0}):""}case at:return Lt(r?.image,at);case st:return Lt(r?.link,st);case ct:return null!=r?.price&&"number"==typeof r.price||null!=r?.price&&"string"==typeof r.price?String(r.price):null!=r?.new_price?String(r.new_price):_t(ct);case dt:return Lt(r?.currency,dt);case ut:return Lt(r?.old_price,ut);case mt:return null!=r?.new_price?Lt(r.new_price,mt):null!=r?.price?Lt(r.price,mt):_t(mt);case pt:{const t=Tt(r?.currency),e=null!=r?.price?r.price:r?.new_price,n=null!=r?.old_price||null!=r?.new_price,o=null!=r?.old_price?r.old_price:null,i=null!=r?.new_price?r.new_price:null!=r?.price?r.price:null;if(n&&(null!=o||null!=i)){const e=Bt(o,t),n=Bt(i,t),r=null!=(null!=e?e:null!=o?String(o):null)?St(null!=e?e:null!=o?String(o):""):"";return[""!==r?`<span style="text-decoration: line-through;">${r}</span>`:"",null!=(null!=n?n:null!=i?String(i):null)?St(null!=n?n:null!=i?String(i):""):""].filter(Boolean).join(" ")||_t(pt)}const l=Bt(e,t);return null!=l?St(l):null!=e?St(String(e)):_t(pt)}case gt:{const e=t.content?.cta?.text;return Lt(e,gt)}case ft:{const e=t.content?.cta?.url;return Lt(null!=e?e:t.companyContext?.website,ft)}default:return _t(e)}}function Ut(t,e,n={}){if(!t||!e)return t;const{useImportant:o=!1}=n,i=String(e).trim();if(!i)return t;const r=o?`color: ${i} !important`:`color: ${i}`;return String(t).replace(/<a\b([^>]*)>/gi,(t,e)=>{const n=e.match(/\sstyle\s*=\s*"([^"]*)"/i);if(n){const t=(n[1]||"").replace(/\s*color\s*:\s*[^;]+(!important)?\s*;?/gi,"").replace(/;\s*;/g,";").replace(/^\s*;|;\s*$/g,"").trim(),o=`${t?`${t}; `:""}${r};`;return`<a${e.replace(n[0],` style="${o}"`)}>`}const o=e.match(/\sstyle\s*=\s*'([^']*)'/i);if(o){const t=(o[1]||"").replace(/\s*color\s*:\s*[^;]+(!important)?\s*;?/gi,"").replace(/;\s*;/g,";").replace(/^\s*;|;\s*$/g,"").trim(),n=`${t?`${t}; `:""}${r};`;return`<a${e.replace(o[0],` style='${n}'`)}>`}return`<a${e} style="${r};">`})}const Nt=[{name:"Roboto",fallback:"Arial, sans-serif"},{name:"Open Sans",fallback:"Arial, sans-serif"},{name:"Lato",fallback:"Arial, sans-serif"},{name:"Montserrat",fallback:"Arial, sans-serif"},{name:"Poppins",fallback:"Arial, sans-serif"},{name:"Merriweather",fallback:"Georgia, serif"},{name:"Playfair Display",fallback:"Georgia, serif"},{name:"Cormorant Garamond",fallback:"Garamond, 'Times New Roman', serif"},{name:"Source Sans 3",fallback:"Arial, sans-serif"},{name:"Inter",fallback:"Arial, sans-serif"},{name:"Nunito",fallback:"Arial, sans-serif"},{name:"Nunito Sans",fallback:"Arial, sans-serif"},{name:"Raleway",fallback:"Arial, sans-serif"},{name:"Rubik",fallback:"Arial, sans-serif"},{name:"Work Sans",fallback:"Arial, sans-serif"},{name:"DM Sans",fallback:"Arial, sans-serif"},{name:"Manrope",fallback:"Arial, sans-serif"},{name:"Outfit",fallback:"Arial, sans-serif"},{name:"Plus Jakarta Sans",fallback:"Arial, sans-serif"},{name:"IBM Plex Sans",fallback:"Arial, sans-serif"},{name:"IBM Plex Serif",fallback:"Georgia, serif"},{name:"Noto Sans",fallback:"Arial, sans-serif"},{name:"Noto Serif",fallback:"Georgia, serif"},{name:"PT Sans",fallback:"Arial, sans-serif"},{name:"PT Serif",fallback:"Georgia, serif"},{name:"Ubuntu",fallback:"Arial, sans-serif"},{name:"Fira Sans",fallback:"Arial, sans-serif"},{name:"Barlow",fallback:"Arial, sans-serif"},{name:"Quicksand",fallback:"Arial, sans-serif"},{name:"Libre Baskerville",fallback:"Georgia, serif"},{name:"Libre Franklin",fallback:"Arial, sans-serif"},{name:"Crimson Pro",fallback:"Georgia, serif"},{name:"Lora",fallback:"Georgia, serif"},{name:"Space Grotesk",fallback:"Arial, sans-serif"},{name:"Archivo",fallback:"Arial, sans-serif"},{name:"Mulish",fallback:"Arial, sans-serif"},{name:"Figtree",fallback:"Arial, sans-serif"},{name:"Be Vietnam Pro",fallback:"Arial, sans-serif"},{name:"Sora",fallback:"Arial, sans-serif"},{name:"Josefin Sans",fallback:"Arial, sans-serif"}];function Et(t){return`https://fonts.googleapis.com/css2?family=${(t=>String(t).trim().replace(/\s+/g,"+"))(t)}:wght@400;700&display=swap`}function Mt(t){if(!t)return"";const e=String(t).split(",")[0];return String(e??"").trim().replace(/^['"]|['"]$/g,"")}function Rt(t){const e=String(t.name||"").trim(),n=String(t.url||"").trim();if(!e||!n)return"";const o=t.format?` format('${t.format}')`:"",i=t.weight?`font-weight:${t.weight};`:"",r=t.style?`font-style:${t.style};`:"";return`@font-face{font-family:${(t=>/\s/.test(String(t||""))?`'${String(t).replace(/'/g,"\\'")}'`:String(t))(e)};src:url('${n}')${o};${i}${r}}`}function Ft(t,e,n){const o=function(t,e){const n=new Set,o=t=>{null!=t&&""!==String(t).trim()&&n.add(String(t).trim())};o(e?.styles?.fontFamily);const i=t=>{Array.isArray(t)&&t.forEach(t=>{t&&"object"==typeof t&&(o(t?.styles?.desktop?.fontFamily),o(t?.styles?.mobile?.fontFamily),"image"===t.key&&Array.isArray(t.overlayItems)&&t.overlayItems.forEach(t=>{t&&"object"==typeof t&&o(t.fontFamily)}),Array.isArray(t.children)&&i(t.children))})};return i(t),[...n]}(t,e),i=new Set;o.forEach(t=>{const e=function(t){const e=Mt(t),n=Nt.find(t=>t.name.toLowerCase()===e.toLowerCase());return n?Et(n.name):null}(t);e&&i.add(e)});const r=(Array.isArray(n?.brandContext?.customFonts)?n.brandContext.customFonts:[]).map(Rt).filter(Boolean);return[...[...i].map(t=>`@import url('${t}');`),...r].join("\n")}function Dt(t){const e=String(t?.image||"").toLowerCase(),n=String(t?.title||"").toLowerCase().trim();return e.includes("/tc-x.svg")||e.includes("/brand-x.svg")||e.includes("/icons/x.svg")||e.includes("simple-icons")&&e.includes("/x.svg")||"x"===n||"twitter"===n}const jt=["default","white","black","gray"];function zt(t){if(!t||"object"!=typeof t)return{};const{padding:e,paddingTop:n,paddingRight:o,paddingBottom:i,paddingLeft:r,...l}=t;return l}const Wt={small:21,medium:24,large:32},Ot="https://unpkg.com/@tabler/icons@3.24.0/icons/outline",Kt={facebook:"brand-facebook",x:"brand-x",instagram:"brand-instagram",linkedin:"brand-linkedin",tiktok:"brand-tiktok",youtube:"brand-youtube",pinterest:"brand-pinterest"};function Ht(t){if(!t)return null;const e=Kt[t];return e?`${Ot}/${e}.svg`:null}function Vt(t){if(!t)return null;if(Dt(t))return"x";const e=String(t.image||"").toLowerCase(),n=String(t.title||"").toLowerCase();return e.includes("facebook")||n.includes("facebook")?"facebook":e.includes("instagram")||n.includes("instagram")?"instagram":e.includes("linkedin")||n.includes("linkedin")?"linkedin":e.includes("tiktok")||n.includes("tiktok")?"tiktok":e.includes("youtube")||n.includes("youtube")?"youtube":e.includes("pinterest")||n.includes("pinterest")?"pinterest":null}const Gt="https://s.magecdn.com/social";const Jt={facebook:"tc-facebook.svg",x:"tc-x.svg",instagram:"tc-instagram.svg",linkedin:"tc-linkedin.svg",tiktok:"tc-tiktok.svg",youtube:"tc-youtube.svg",pinterest:"tc-pinterest.svg"};function Zt(t){const e=String(t||"").toLowerCase();return Ht("twitter"===e?"x":e)}function Yt(t){const e=function(t){switch(t){case"white":return"brightness(0) invert(1)";case"black":return"brightness(0)";case"gray":return"brightness(0) opacity(0.55)";default:return""}}(t);return e?{filter:e}:{}}function qt(t,e,n){const o=Number(n)||Wt.medium,i={width:o,height:o,objectFit:"contain",display:"block",verticalAlign:"middle",flexShrink:0},r=e&&"default"!==e?e:"default",l=String(t?.image||"").trim(),a=function(t){return Ht(Vt(t))}(t),s=function(t){const e=Vt(t);if(!e)return null;const n=Jt[e];return n?`${Gt}/${n}`:null}(t);if(l&&!function(t){const e=String(t||"").trim().toLowerCase();return!(!e||!e.startsWith(String(Gt).toLowerCase())&&!e.startsWith(String(Ot).toLowerCase())&&!e.includes("unpkg.com/@tabler/icons"))}(l))return{src:l,style:i};if("default"===r)return s?{src:s,style:i}:{src:l,style:i};if(a){if("white"===r)return{src:a,style:{...i,filter:"brightness(0) invert(1)"}};if("gray"===r)return{src:a,style:{...i,filter:"brightness(0) opacity(0.55)"}};if("black"===r)return{src:a,style:i}}return l?{src:l,style:{...i,...Yt(r)}}:{src:"",style:i}}function Xt(t,e,n){const{src:o,style:i}=qt(t,e,n),r=Number(n)||Wt.medium,l=[`width:${r}px`,`height:${r}px`,"object-fit:contain","display:block","vertical-align:middle"];return"brightness(0) opacity(0.55)"===i.filter?l.push("opacity:0.55"):i.filter&&l.push(`filter:${i.filter}`),null!=i.opacity&&l.push(`opacity:${i.opacity}`),{src:o,styleAttr:l.join(";")}}const Qt="ee_cb";function te(t){const e=String(t??"").trim();if(!e)return e;try{const t="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(e,t);n.searchParams.delete(Qt);let o=n.toString();return o.endsWith("?")&&(o=o.slice(0,-1)),o}catch{return e.replace(new RegExp(`[?&]${Qt}=\\d+`,"g"),"").replace(/\?&/g,"?").replace(/&&+/g,"&").replace(/[?&]$/,"")}}function ee(t){const e=t??{};if(!1===e.containerBackgroundEnabled)return"";const n=te(e.containerBackgroundImage);if(!n||!String(n).trim())return"";return`background-image:url("${String(n??"").trim().replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"").replace(/\r/g,"")}");background-size:${{cover:"cover",contain:"contain",fill:"100% 100%"}[e.containerBackgroundSize||"cover"]||"cover"};background-position:${e.containerBackgroundPosition||"center center"};background-repeat:no-repeat;`}const ne=["tl","tc","tr","ml","mc","mr","bl","bc","br"],oe={tl:{top:"10%",left:"8%",transform:"translate(0, 0)",textAlign:"left"},tc:{top:"10%",left:"50%",transform:"translate(-50%, 0)",textAlign:"center"},tr:{top:"10%",right:"8%",transform:"translate(0, 0)",textAlign:"right"},ml:{top:"50%",left:"8%",transform:"translate(0, -50%)",textAlign:"left"},mc:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center"},mr:{top:"50%",right:"8%",transform:"translate(0, -50%)",textAlign:"right"},bl:{bottom:"10%",left:"8%",transform:"translate(0, 0)",textAlign:"left"},bc:{bottom:"10%",left:"50%",transform:"translate(-50%, 0)",textAlign:"center"},br:{bottom:"10%",right:"8%",transform:"translate(0, 0)",textAlign:"right"}};function ie(t){const e=String(t??"bc").toLowerCase();return ne.includes(e)?e:"bc"}function re(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}const le=[{key:"facebook",image:Zt("facebook"),title:"Facebook"},{key:"twitter",image:Zt("twitter"),title:"X"},{key:"instagram",image:Zt("instagram"),title:"Instagram"},{key:"linkedin",image:Zt("linkedin"),title:"LinkedIn"},{key:"tiktok",image:Zt("tiktok"),title:"TikTok"},{key:"youtube",image:Zt("youtube"),title:"YouTube"}];function ae(t){const e=t?.socialPlatformKey;if(e&&"string"==typeof e&&le.some(t=>t.key===e))return e;if(Dt(t))return"twitter";const n=String(t?.title??"").trim().toLowerCase(),o=String(t?.image??"").trim();for(const t of le){if(n&&n===t.title.toLowerCase())return t.key;if("twitter"===t.key&&n&&("twitter"===n||"tweet"===n||"tw"===n))return"twitter";if(o&&o===t.image)return t.key}return null}function se(t,e){if(null==t||""===t)return"";const n=String(t);return e?n.replace(/\{\{(\w+)\}\}/g,(t,n)=>{const o=It(e,n,{});if(null==o)return`{{${n}}}`;const i=String(o);return i.startsWith("{{")?`{{${n}}}`:i}):n}function ce(t,e){if(null==t||""===t)return"";const n=String(t);return e?n.replace(/\{\{(\w+)\}\}/g,(t,n)=>{const o=It(e,n,{}),i=null!=o?String(o).trim():"";return!i||"—"===i||i.startsWith("{{")?t:i}):n}function de(t){return(Array.isArray(t)&&0!==t.length?t:function(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:{},o=Array.isArray(t)?t:[],i=new Map,r=[];for(const t of o){const e=ae(t);e?i.set(e,t):r.push(t)}return[...le.map(t=>{const e=i.get(t.key),o=null!=n[t.key]?a(String(n[t.key]).trim()):"",r=null!=e?.linkURL?String(e.linkURL).trim():"",l=r?a(r):"",s=o||l||"";return{id:e?.id??re(),image:e?.image||t.image,title:e?.title||t.title,linkURL:s,socialPlatformKey:t.key}}),...r]}([],{})).map(t=>({id:t?.id,image:t?.image??"",title:t?.title??"",linkURL:t?.linkURL??"",socialPlatformKey:t?.socialPlatformKey}))}function ue(t){return Array.isArray(t)&&0!==t.length?t.map(t=>({id:t?.id,label:t?.label??"",url:t?.url??"",target:"_blank"===t?.target?"_blank":"_self"})):[{id:re(),label:"Privacy",url:"#",target:"_self"},{id:re(),label:"Terms",url:"#",target:"_self"}]}const me=t=>String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),pe=(t,e)=>{if(null==t||""===t)return e;if("number"==typeof t)return t;const n=parseInt(String(t).replace(/px/gi,""),10);return Number.isFinite(n)?n:e};function ge(t,e,n){const o=t,i=o.styles?.desktop??{},r=Boolean(o.showBrand??!0),l=Boolean(o.showTagline??!0),a=Boolean(o.footerShowLogo??!1),s=function(t,e){const n="string"==typeof t?t.trim():String(t??"").trim();if(!n)return"";const o=/^\{\{(\w+)\}\}$/.exec(n);if(o&&e){const t=It(e,o[1],{});if(null!=t&&""!==String(t).trim()&&!String(t).startsWith("{{"))return String(t).trim()}return n}(o.footerLogoSrc??"",n),d=se(String(o.footerLogoAlt??"Logo").trim()||"Logo",n).trim()||"Logo",u=o.footerLogoLink??"",m=pe(o.footerLogoMaxWidthPercent,30),p=pe(o.footerLogoPaddingPx,24),g=Boolean(o.showAddress??!0),f=Boolean(o.showUnsubscribe??!0),y=Boolean(o.showSocial??!1),b=Boolean(o.showSecondaryLinks??!1),k=Boolean(o.showCopyright??!0),h=se(o.brandName??"",n),$=se(o.brandTagline??"",n).trim(),x=se(o.address??"",n),v=se(o.copyrightText??"",n),S=o.unsubscribeUrl||"{{unsubscribe_url}}",w=null!=o.unsubscribeBodyText&&""!==String(o.unsubscribeBodyText).trim()?String(o.unsubscribeBodyText):"You are receiving this email because you subscribed.",{unsubscribeLinkLabel:C}=function(t){let e=null!=t?.unsubscribeLinkLabel&&""!==String(t.unsubscribeLinkLabel).trim()?String(t.unsubscribeLinkLabel).trim():"";const n=String(t?.unsubscribeText??"").trim();if(!e&&n){const t=n.split(/\s*[·•]\s*/);e=t[0]?.trim()||""}return{unsubscribeLinkLabel:e||"Unsubscribe"}}(o),_=ue(o.secondaryLinks),A=de(o.footerSocialList),L=i.color??"#737373",P=null!=i.linkColor&&""!==String(i.linkColor).trim()?String(i.linkColor).trim():L,T=pe(i.fontSize,12),B=i.textAlign??"center",I=pe(i.paddingTop,28),U=pe(i.paddingRight,24),N=pe(i.paddingBottom,28),E=pe(i.paddingLeft,24),M=function(t){const e=null!=t?String(t).trim():"";return e&&"transparent"!==e.toLowerCase()?e:"#ffffff"}(i.contentBackground),R=Boolean(o.showDivider??!1),F=me(o.dividerColor??"#374151"),D=Boolean(o.showBorderTop??!1),j=pe(o.borderTopWidth,1),z=o.borderTopStyle??"solid",W=me(o.borderTopColor??"#e5e7eb"),O=D&&j>0?`${j}px ${z} ${W}`:"",K=e?.width??"100%",H=e?.styleConfig?.mobile?` class="${e.styleConfig.className}"`:"",V=e?.styleConfig?.desktop??"",G=`margin:0;color:${me(L)};font-size:${T}px;line-height:1.5;font-family:Arial,sans-serif;text-align:${me(B)};`,J=`color:${me(P)};text-decoration:underline;`,Z=[];let Y="";if(R&&(Y+=`<div style="border-top:1px solid ${F};margin-bottom:14px;width:100%;font-size:0;line-height:0;">&nbsp;</div>`),a&&s.trim()){const t="left"===B?"left":"right"===B?"right":"center",e=`<img src="${me(s)}" alt="${me(d)}" width="570" style="max-width:${m}%;height:auto;display:inline-block;padding:${p}px;vertical-align:middle;border:0;outline:none;text-decoration:none;"/>`,o=c(ce(u,n)),i=o?`<a href="${me(o)}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;line-height:0;display:inline-block;">${e}</a>`:e;Y+=`<div style="text-align:${me(t)};margin-bottom:10px;line-height:0;">${i}</div>`}if(r&&h.trim()&&(Y+=`<p style="${G}font-weight:600;margin:0 0 10px 0;">${me(h)}</p>`),l&&$&&(Y+=`<p style="${G}margin:0 0 10px 0;opacity:0.92;">${me($)}</p>`),g&&x.trim()&&(Y+=`<p style="${G}margin:0 0 10px 0;">${me(x)}</p>`),y){const t=Array.isArray(A)?A.filter(Boolean):[];if(t.length>0){const e=Wt.medium,o=t.map(t=>{const o=c(ce(t.linkURL,n),{allowMailtoTel:!1}),{src:i,styleAttr:r}=Xt(t,"default",e),l=`<img src="${me(i)}" alt="" width="${e}" height="${e}" style="${r}" border="0"/>`,a="text-decoration:none;display:inline-block;vertical-align:middle;line-height:0;margin:0 6px;";return o?`<a href="${me(o)}" target="_blank" rel="noopener noreferrer" style="${a}">${l}</a>`:`<span style="${a}">${l}</span>`}).join(""),i="left"===B?"left":"right"===B?"right":"center";Y+=`<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;border-collapse:collapse;margin-bottom:10px;"><tr><td align="${i}" style="text-align:${i};font-size:0;line-height:0;">${o}</td></tr></table>`}}if(f){const t=me(se(w,n)),e=me(se(C,n)),o=me(c(ce(S,n)));let i=`<p style="${G}margin:0 0 10px 0;word-break:break-word;">`;t&&(i+=`${t} `),i+=`<a href="${o}" style="${J}">${e}</a>`,i+="</p>",Y+=i}if(b&&_.length>0){let t=`<p style="${G}margin:0 0 10px 0;word-break:break-word;">`;_.forEach((e,o)=>{o>0&&(t+='<span style="padding:0 6px;">·</span>');const i=me(se(e.label,n)),r=me(c(ce(e.url,n))),l="_blank"===e.target?' target="_blank" rel="noopener noreferrer"':"";t+=`<a href="${r}" style="${J}"${l}>${i||`#${o+1}`}</a>`}),t+="</p>",Y+=t}if(k&&v.trim()){const t=Math.max(10,T-1);Y+=`<p style="${G}font-size:${t}px;margin:0;opacity:0.9;">${me(v)}</p>`}var q;return Z.push(`<td${H} style="width:${K};${V}">${q=Y,`<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="width:100%;"><tr><td align="${me(B)}" style="${G}text-align:${me(B)};background-color:${me(M)};padding:${I}px ${U}px ${N}px ${E}px;${O?`border-top:${O};`:""}">${q}</td></tr></table>`}</td>`),Z.join("")}function fe(t){if(null==t)return"";const e=String(t).trim().toLowerCase();return/^#[0-9a-f]{3}$/.test(e)?`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`:e}const ye=new Set(["fontWeight","opacity","zIndex"]),be=t=>String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),ke=t=>be(t).replace(/"/g,"&quot;").replace(/'/g,"&#39;"),he=(t,e="#")=>{if(null==t)return e;const n=String(t).trim();if(!n)return e;const o=n.toLowerCase();return/^\s*(?:javascript|vbscript):/i.test(o)||/^\s*data:/i.test(o)?e:/^https?:\/\//i.test(n)||/^mailto:/i.test(n)||/^tel:/i.test(n)?n:n.startsWith("//")?`https:${n}`:/^[a-z][a-z\d+.-]*:/i.test(n)?n:`https://${n.replace(/^\/+/,"")}`},$e=(t,e)=>{const n=new RegExp(/[A-Z]/g),o=t=>t.replace(n,t=>`-${t.toLowerCase()}`),i={desktop:e?.desktop??{},mobile:e?.mobile??{}};let r={className:t,desktop:"",mobile:""};for(let t of Object.entries(i.desktop))if(t[1]&&"contentBackground"!==t[0]&&"horizontalAlign"!==t[0]&&"containerBackgroundImage"!==t[0]&&"containerBackgroundSize"!==t[0]&&"containerBackgroundPosition"!==t[0]){const e="number"!=typeof t[1]||ye.has(t[0])?t[1]:t[1]+"px";r.desktop+=`${o(t[0])}:${e};`}if(Object.keys(i.mobile).length){let e="";for(let t of Object.entries(i.mobile))if(t[1]&&"contentBackground"!==t[0]&&"horizontalAlign"!==t[0]&&"containerBackgroundImage"!==t[0]&&"containerBackgroundSize"!==t[0]&&"containerBackgroundPosition"!==t[0]){const n="number"!=typeof t[1]||ye.has(t[0])?t[1]:t[1]+"px";e+=`${o(t[0])}:${n} !important;`}r.mobile+=`@media(max-width:620px){\n .${t} {\n ${e}\n }\n }`}return r};function xe(t){if(!t||"object"!=typeof t)return{};const{marginLeft:e,marginTop:n,...o}=t;return o}function ve(t){const e=zt(t||{}),{linkColor:n,color:o,...i}=e,r=null!=n&&""!==String(n).trim()?String(n).trim():null,l=null!=o&&""!==String(o).trim()?String(o).trim():null,a=r??l;return null==a?i:{...i,color:a}}const Se=(t,e="",n=null)=>{const o=t.map((t,o)=>{let i={...t};const r=null!==n?`${n}-${o}`:`${o}`,l=t=>`e${r}-${t}`,a={desktop:t?.styles?.desktop??{},mobile:t?.styles?.mobile??{}},s="menu"===t.key?{desktop:ve(a.desktop),mobile:ve(a.mobile)}:"social_link"===t.key?{desktop:zt(a.desktop),mobile:zt(a.mobile)}:a;if(i.styleConfig=$e(l(t.key),s),i.contentStyles){const n={desktop:i.contentStyles?.desktop??{},mobile:i.contentStyles?.mobile??{}};let o=n;if(i.imageHostMarginStyleConfig=null,"image"===i.key){o={desktop:xe(n.desktop),mobile:xe(n.mobile)};const r={desktop:(n.desktop,{}),mobile:(n.mobile,{})};if(Object.keys(r.desktop).length||Object.keys(r.mobile).length){const n=$e(l(`${t.key}-hm`),r);i.imageHostMarginStyleConfig=n,n.mobile&&(e+=n.mobile)}}i.contentStyleConfig=$e(l(`${t.key}-c`),o),i.contentStyleConfig.mobile&&(e+=i.contentStyleConfig.mobile)}if("video"===i.key&&i.videoArea){const n={desktop:i.videoArea?.desktop??{},mobile:i.videoArea?.mobile??{}};i.videoAreaStyleConfig=$e(l(`${t.key}-va`),n),i.videoAreaStyleConfig.mobile&&(e+=i.videoAreaStyleConfig.mobile)}if(i.styleConfig.mobile&&(e+=i.styleConfig.mobile),t.hiddenOnMobile){const t=`@media(max-width:620px){.${i.styleConfig.className}{display:none !important;}}`;e+=t,i.styleConfig={...i.styleConfig,mobile:(i.styleConfig.mobile||"")+t}}if(s.desktop.contentBackground&&(i.contentStyleConfig||(i.contentStyleConfig={className:l(`${t.key}-c`),desktop:"",mobile:""}),i.contentStyleConfig.desktop+=`background-color:${s.desktop.contentBackground};`),s.mobile.contentBackground){i.contentStyleConfig||(i.contentStyleConfig={className:l(`${t.key}-c`),desktop:"",mobile:""});const n=`@media(max-width:620px){.${i.contentStyleConfig.className}{background-color:${s.mobile.contentBackground};}}`;i.contentStyleConfig.mobile=(i.contentStyleConfig.mobile||"")+n,e+=n}if("menu"===i.key){if("stack"===(t.mobileLayout??"inline")){const n=i.contentStyleConfig?.className??l(`${t.key}-c`);i.contentStyleConfig||(i.contentStyleConfig={className:n,desktop:"",mobile:""});const o=i.contentStyles?.desktop?.textAlign??i.contentStyles?.mobile?.textAlign??"center",r=String(o).toLowerCase(),a="left"===r?"flex-start":"right"===r?"flex-end":"center",s=["left","right","center","justify"].includes(r)?r:"center",c=t.linkGapPx,d=`@media(max-width:620px){\n.${n}{display:flex !important;flex-direction:column !important;align-items:${a} !important;flex-wrap:nowrap !important;}\n.${n}>span{display:none !important;}\n.${n}>a{display:block !important;width:100% !important;box-sizing:border-box !important;text-align:${s} !important;margin:0 0 ${"number"==typeof c&&Number.isFinite(c)&&c>=0?c:0}px 0 !important;}\n.${n}>a:last-child{margin-bottom:0 !important;}\n}`;i.contentStyleConfig.mobile=(i.contentStyleConfig.mobile||"")+d,e+=d}}if(t.children?.length){const{newBlockList:n,styles:o}=Se(t.children,"",r);e+=o,i.children=n}return{...i}});return{newBlockList:o,styles:e}};function we(t){const e=t.contentStyleConfig?.desktop??"",n=function(t){const e=t.contentStyles?.desktop??{},n=t.contentStyles?.mobile??{},o=null!=e.textAlign&&""!==String(e.textAlign).trim()?e.textAlign:n.textAlign,i=null!=o&&""!==String(o).trim()?String(o).trim():"center";return"start"===i?"left":"end"===i?"right":i}(t);return/\btext-align\s*:/i.test(e)?e:`${e}text-align:${n};`}const Ce=(t,e,n={},o=null)=>{let i=t.src||"";const r="string"==typeof t.src&&/^\{\{\s*[\w.]+\s*\}\}$/.test(t.src.trim())?t.src.trim():"";if(e&&r){const t=It(e,r.replace(/^\{\{\s*|\s*\}\}$/g,""),n);t&&!/^\{\{\s*[\w.]+\s*\}\}$/.test(String(t).trim())&&(i=t)}i=te(i);const l=ke(i),a=ke(t.alt||"Image"),s=null!=t.linkURL?String(t.linkURL).trim():"",c=Array.isArray(t.overlayItems)?t.overlayItems:[],d=c.some(t=>""!==String(t?.text??"").trim()),u=String(t.overlayText??"").trim(),p=Boolean(t.textOverlayEnabled)&&(d||""!==u)&&i,g=`${t.styleConfig?.desktop||""};max-width:100%;display:inline-block;vertical-align:top;`;let f=`<img src="${l}" alt="${a}" style="${g}" ${t.styleConfig?.mobile?`class="${t.styleConfig.className}"`:""}/>`;if(p){const e=function(t){const e=ie(t);return oe[e]}(ie(t.overlayPosition)),n=Object.entries({position:"absolute",...e,"z-index":"2","max-width":`${"number"==typeof t.overlayMaxWidth?t.overlayMaxWidth:100}%`,"box-sizing":"border-box","pointer-events":"none"}).map(([t,e])=>`${t}:${e};`).join(""),i="number"==typeof t.overlayPadding?t.overlayPadding:16,r=t.textShadowEnabled?"text-shadow:0 1px 3px rgba(0,0,0,0.55);":"";let s="";if(d){const e="number"==typeof t.overlayItemGap?t.overlayItemGap:8,n=c.filter(t=>String(t?.text??"").trim()).map(t=>{const e="number"==typeof t.fontSize?t.fontSize:16,n=ke(t.color||"#ffffff"),i=(t=>{switch(t){case"h1":case"h2":case"h3":return"700";case"subtitle":case"eyebrow":return"600";default:return"400"}})(t.kind),l=null!=t.fontFamily&&""!==String(t.fontFamily).trim()?String(t.fontFamily).trim():String(o?.styles?.fontFamily||"sans-serif").trim()||"sans-serif",a=ke(l),s=be(String(t.text??""));return`<div style="color:${n};font-size:${e}px;font-weight:${i};line-height:1.35;font-family:${a};${r}">${s}</div>`});s=`<div style="display:flex;flex-direction:column;gap:${e}px;width:100%;padding:${i}px;">${n.join("")}</div>`}else{s=`<div style="color:${ke(t.overlayTextColor||"#ffffff")};font-size:${"number"==typeof t.overlayFontSize?t.overlayFontSize:18}px;font-weight:600;line-height:1.35;${t.overlayBoxBackground?`background-color:${ke(t.overlayBoxBackground)};padding:8px 12px;`:`padding:${i}px;`}${r}">${be(u)}</div>`}f=`<div style="position:relative;display:inline-block;vertical-align:top;max-width:100%;overflow:hidden;line-height:0;">\n ${t.scrimEnabled?'<div style="position:absolute;left:0;top:0;width:100%;height:100%;z-index:1;pointer-events:none;background:linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0.12), transparent 55%);"></div>':""}\n <img src="${l}" alt="${a}" style="${g}position:relative;z-index:0;border-radius:0;" ${t.styleConfig?.mobile?`class="${t.styleConfig.className}"`:""}/>\n <div style="${n}">\n ${s}\n </div>\n </div>`}const y=m(t)&&""!==s?`<a href="${ke(he(s))}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;display:inline-block;max-width:100%;">${f}</a>`:f,b=t.imageHostMarginStyleConfig,k=b&&(b.desktop||b.mobile)?`<div ${b.mobile?`class="${b.className}"`:""} style="display:inline-block;vertical-align:top;max-width:100%;${b.desktop||""}">${y}</div>`:y;return`<div ${t.contentStyleConfig.mobile?`class="${t.contentStyleConfig.className}"`:""} \n style="${we(t)}">\n ${k}\n </div>`};const _e="#2faade";function Ae(t){const e=String(t??"");return null!=(n=e)&&"string"==typeof n&&/<[a-zA-Z!/?]/.test(n.trim())?function(t){if(!t||!/<a\b/i.test(t))return t;const e=(t,e,n)=>{const o=(e[1]||"").replace(/\s*text-decoration(-line)?\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),i=(o?`${o}; `:"")+"text-decoration: none;",r='"'===n?` style="${i}"`:` style='${i}'`;return`<a${t.replace(e[0],r)}>`};return String(t).replace(/<a\b([^>]*)>/gi,(t,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o)return e(n,o,'"');const i=n.match(/\sstyle\s*=\s*'([^']*)'/i);return i?e(n,i,"'"):`<a${n} style="text-decoration: none;">`})}(e):be(e);var n}function Le(t){const e=t?.dynamicSelectedContent,n=t?.text??"";if(null==e)return String(n);const o=String(e);return""===o.trim()?String(n):o}const Pe=(t,e,n={})=>{let o=Le(t);e&&o&&(o=Ct(o,e,n));const i=t?.styles?.desktop??{},r=null!=i.linkColor&&""!==String(i.linkColor).trim();return o=Ut(o,r?String(i.linkColor).trim():_e,{useImportant:r}),`<${t.type} ${t.styleConfig?.mobile?`class="${t.styleConfig.className}"`:""} \n style="${t.styleConfig?.desktop||""}">\n ${o}\n </${t.type}>`};const Te=(t,e,n={},o=null)=>{let i=t.text||"",r=t.linkURL||"";if(e){const o=i.match(/\{\{(\w+)\}\}/),l=t.labelVariable?t.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():o?o[1]:void 0;if(l){const t=It(e,l,n);null==t||String(t).startsWith("{{")||(i=String(t))}if(t.urlVariable){const o=It(e,t.urlVariable.replace(/^\{\{|\}\}$/g,""),n);o&&!o.startsWith("{{")&&(r=String(o))}else{const t=String(r||"").trim().match(/^\{\{(\w+)\}\}$/);if(t){const o=It(e,t[1],n);o&&!String(o).startsWith("{{")&&(r=String(o))}}}const l=Ae(i),a=ke(he(r)),s=function(t){if(null==t||"object"!=typeof t)return"#111111";const e=t.brandContext,n=e&&"object"==typeof e?e.brand_color??e.brandColor??null:null,o=t.brandColor,i=("string"==typeof n&&""!==n.trim()?n:"string"==typeof o&&""!==o.trim()?o:null)??"#111111",r=String(i).trim();return""!==r?r:"#111111"}(e);let c=t.styleConfig.desktop||"";var d;!function(t,e){if(!function(t){return!(!t||"column"!==t.key||"product"!==t.containerType)&&"additional"!==t.productRole&&("image_left"===t.mainProductLayout||"image_stacked"!==t.mainProductLayout&&function(t){const e=t?.children?.[0]?.children?.[0];return"column"===e?.key&&"2-3"===e?.type}(t))}(e))return!1;const n=t.styles?.desktop?.backgroundColor;return null==n||""===String(n).trim()||fe(n)===fe("#111827")}(t,o)?(d=t.styles?.desktop?.backgroundColor,fe(d)===fe("#263d2d")&&(c=c.replace(/background-color:\s*[^;]+;?/gi,""))):c=c.replace(/background-color:\s*[^;]+;?/gi,"");const u=c.includes("background-color:")?"":`background-color:${s};`,m=c.includes("box-sizing")?"":"box-sizing:border-box;";return`<div ${t.contentStyleConfig.mobile?`class="${t.contentStyleConfig.className}"`:""}\n style="${t.contentStyleConfig.desktop}">\n <a ${t.styleConfig.mobile?`class="${t.styleConfig.className}"`:""}\n style="${c}${u}${m}text-align:center;text-decoration:none;" target="_blank" rel="noopener noreferrer" href="${a}">${l}</a>\n </div>`};const Be=t=>{const e=Array.isArray(t.list)?t.list.filter(Boolean):[];if(0===e.length)return"";const n=Boolean(t.showTextLabel),o=function(t){const e=t?.iconSize;if(e&&null!=Wt[e])return Wt[e];const n=Number(t?.imageWidth);return Number.isFinite(n)&&n>0?Math.round(n):Wt.medium}(t),i=Math.max(11,Math.round(.58*o)),r=function(t){const e="string"==typeof t?t:"gray";return jt.includes(e)?e:"default"}(t.iconColor),l=t?.contentStyles?.desktop??{},a=l.textAlign||"center",s="justify"===a,d="right"===a?"right":"left"===a?"left":"center",u=l.columnGapPx,m="number"==typeof u&&Number.isFinite(u)&&u>=0?u:8,p=Math.max(0,Math.round(m/2)),g=t.styleConfig?.desktop||"",f=t.styleConfig?.mobile?` class="${t.styleConfig.className}"`:"",y=(t,e="")=>{const{title:l,linkURL:a}=t,s=c(a,{allowMailtoTel:!1}),{src:d,styleAttr:u}=Xt(t,r,o),m=n?u.replace(/display:\s*block/i,"display:inline-block"):u,p=`<img src="${ke(d)}" alt="${ke(l)}" width="${o}" height="${o}" style="${ke(m)}" border="0"${f}/>`,y=Dt(t)?"X":String(l??""),b=n?`<span style="font-size:${i}px;line-height:1.2;color:#525252;font-family:inherit;white-space:nowrap;display:inline-block;vertical-align:middle;margin-left:6px;">${be(y)}</span>`:"",k=`text-decoration:none;display:inline-block;vertical-align:middle;line-height:0;${e}${g?`;${g}`:""}`;return s?`<a target="_blank" rel="noopener noreferrer" href="${ke(s)}" style="${k}">${p}${b}</a>`:`<span style="${k}">${p}${b}</span>`},b=`${t.contentStyleConfig?.desktop||""};text-align:${d};`,k=t.contentStyleConfig?.mobile?` class="${t.contentStyleConfig.className}"`:"";let h;if(s&&e.length>1){const t=(100/e.length).toFixed(4);h=`<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;border-collapse:collapse;"><tr>${e.map((n,o)=>{const i=0===o?"left":o===e.length-1?"right":"center";return`<td width="${t}%" style="width:${t}%;text-align:${i};vertical-align:middle;line-height:0;font-size:0;padding:0;">${y(n)}</td>`}).join("")}</tr></table>`}else h=e.map(t=>y(t,`margin:0 ${p}px;`)).join("");return`<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;border-collapse:collapse;"><tr><td${k} align="${d}" style="${b}">${h}</td></tr></table>`};const Ie=(t,e,n,o,i,r)=>{let l="";const a={columnIndex:i??0,columnProduct:o?.columnProducts?.[r??0]??null};return t.forEach((t,s)=>{if("column"===t.key){const a=function(t){const e={...t?.desktop??{}},n=t?.mobile??{},o=String(e.containerBackgroundImage??"").trim(),i=String(n.containerBackgroundImage??"").trim();!o&&i&&(e.containerBackgroundImage=n.containerBackgroundImage,null!=n.containerBackgroundSize&&(e.containerBackgroundSize=n.containerBackgroundSize),null!=n.containerBackgroundPosition&&(e.containerBackgroundPosition=n.containerBackgroundPosition),void 0!==n.containerBackgroundEnabled&&(e.containerBackgroundEnabled=n.containerBackgroundEnabled));const r=e.minHeight,l=n.minHeight;return null!=r&&""!==String(r).trim()||null==l||""===String(l).trim()||(e.minHeight=l),e}(t.styles),c=t.styles?.desktop?.borderRadius,d=c?`border-radius:${"number"==typeof c?c+"px":c};`:"",u=d?"overflow:hidden;":"",m=ee(a),p=function(t){if(null==t)return"";if("number"==typeof t&&Number.isFinite(t))return`min-height:${t}px;`;const e=String(t).trim();return e?/^\d+$/.test(e)?`min-height:${e}px;`:`min-height:${e};`:""}(a.minHeight),y=String(a.contentBackground??"").trim(),b=y&&"transparent"!==y.toLowerCase()?`background-color:${y};`:"",k=void 0!==r,h=f(e)||k?"100%":`${function(t){return g(t?.contentWidth)}(e)}px`,$=t.containerType&&"none"!==t.containerType?t:o,x=t.containerType&&"none"!==t.containerType?s:i,v=t.containerType&&"none"!==t.containerType?0:r,S="footer"===t.containerType&&t.footerUnifiedLayout?ge(t,t.children?.find(t=>"content"===t.key)??t.children?.[0]??null,n):Ie(t.children,e,n,$,x,v);if("discount"===t.containerType){const e=t.styles?.desktop??{},n=t=>"number"==typeof t?`${t}px`:String(t??""),o=[e.paddingTop?`padding-top:${n(e.paddingTop)};`:"",e.paddingRight?`padding-right:${n(e.paddingRight)};`:"",e.paddingBottom?`padding-bottom:${n(e.paddingBottom)};`:"",e.paddingLeft?`padding-left:${n(e.paddingLeft)};`:""].join(""),i=t.styleConfig.desktop.replace(/padding(?:-(?:top|right|bottom|left))?:[^;]+;?\s*/gi,""),r=o?`<tr><td style="${o}"><table role="presentation" cellpadding="0" cellspacing="0" border="0" style="width:100%;border-collapse:collapse;"><tbody><tr>${S}</tr></tbody></table></td></tr>`:`<tr>${S}</tr>`;l+=`<div ${t.styleConfig.mobile?`class="${t.styleConfig.className}"`:""}\n style="${i}width:100%;display:block;${u}">\n <table ${t.contentStyleConfig.mobile?`class="${t.contentStyleConfig.className}"`:""}\n style="width:100%;max-width:${h};margin:0 auto;${d}${t.contentStyleConfig?.desktop??""}${b}${m}${p}">\n <tbody>${r}</tbody>\n </table></div>`}else l+=`<div ${t.styleConfig.mobile?`class="${t.styleConfig.className}"`:""}\n style="${t.styleConfig.desktop}width:100%;display:block;${u}">\n <table ${t.contentStyleConfig.mobile?`class="${t.contentStyleConfig.className}"`:""}\n style="width:100%;max-width:${h};margin:0 auto;${d}${t.contentStyleConfig?.desktop??""}${b}${m}${p}">\n <tbody><tr>${S}</tr></tbody>\n </table></div>`}if("content"===t.key&&(l+=`<td ${t.styleConfig.mobile?`class="${t.styleConfig.className}"`:""} \n style="width:${t.width}; ${t.styleConfig.desktop}">${Ie(t.children,e,n,o,i,s)}</td>`),"text"===t.key){const e=null!=o?{columnIndex:i??0,columnProduct:o?.columnProducts?.[r??0]??null}:a;t.type&&/^h[1-4]$/.test(t.type)?l+=Pe(t,n,e):l+=((t,e,n={},o=null)=>{let i=Le(t);e&&i&&(i=Ct(i,e,n));const r=t?.styles?.desktop??{},l=null!=r.linkColor&&""!==String(r.linkColor).trim();i=Ut(i,l?String(r.linkColor).trim():_e,{useImportant:l});const a="footer"===o?.containerType,s=null==(c=i)||"string"!=typeof c?"":c.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();var c;return!a||""!==s&&"{{Address}}"!==s&&"{{Tagline}}"!==s?`<div ${t.styleConfig?.mobile?`class="${t.styleConfig.className}"`:""} \n style="${t.styleConfig?.desktop||""}">${i}</div>`:""})(t,n,e,o)}if("heading"===t.key&&(l+=Pe(t,n,a)),"image"===t.key){l+=Ce(t,n,null!=o?{columnIndex:i??0,columnProduct:o?.columnProducts?.[r??0]??null}:a,e)}if("video"===t.key&&(l+=(t=>{const e=null!=t.videoUrl?String(t.videoUrl).trim():"",n=function(t,e){const n="string"==typeof e?e.trim():"";if(n)return n;const o=function(t){if(!t||"string"!=typeof t)return null;const e=t.trim(),n=[/(?:youtube\.com\/watch\?[^#]*[&?]v=)([a-zA-Z0-9_-]{11})/,/youtube\.com\/watch\?v=([a-zA-Z0-9_-]{11})/,/youtu\.be\/([a-zA-Z0-9_-]{11})/,/youtube\.com\/embed\/([a-zA-Z0-9_-]{11})/,/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/,/youtube-nocookie\.com\/embed\/([a-zA-Z0-9_-]{11})/];for(const t of n){const n=e.match(t);if(n?.[1])return n[1]}return null}(t||"");return o?`https://img.youtube.com/vi/${o}/hqdefault.jpg`:""}(e,null!=t.thumbnailUrl?String(t.thumbnailUrl).trim():""),o=e?he(e):"#",i=`${t.styleConfig?.desktop||""};max-width:100%;height:auto;display:block;border:0;`,r=t.contentStyleConfig?.desktop||"",l=t.videoAreaStyleConfig?.desktop||"";return`<div ${t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:""} style="${r}">\n <div ${t.videoAreaStyleConfig?.mobile?`class="${t.videoAreaStyleConfig.className}"`:""} style="${l}">\n ${n?`<a href="${ke(o)}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;display:inline-block;max-width:100%;line-height:0;"><img src="${ke(n)}" alt="${ke("Video")}" style="${i}"/></a>`:`<a href="${ke(o)}" target="_blank" rel="noopener noreferrer" style="display:inline-block;padding:14px 18px;background:#eeeeee;color:#333333;font-family:Arial,Helvetica,sans-serif;font-size:14px;font-weight:600;text-decoration:none;border-radius:4px;">Watch video</a>`}\n </div>\n</div>`})(t)),"button"===t.key){l+=Te(t,n,null!=o?{columnIndex:i??0,columnProduct:o?.columnProducts?.[r??0]??null}:a,o)}var c,d;"divider"===t.key&&(l+=`<div ${(c=t).contentStyleConfig.mobile?`class="${c.contentStyleConfig.className}"`:""} \n style="${c.contentStyleConfig.desktop}">\n <div ${c.styleConfig.mobile?`class="${c.styleConfig.className}"`:""} \n style="${c.styleConfig.desktop}"></div>\n </div>`),"spacer"===t.key&&(l+=(d=t,`<div ${d.contentStyleConfig?.mobile?`class="${d.contentStyleConfig.className}"`:""} \n style="${d.contentStyleConfig?.desktop||""}">\n <div ${d.styleConfig?.mobile?`class="${d.styleConfig.className}"`:""} \n style="${d.styleConfig?.desktop||""}"></div>\n </div>`)),"menu"===t.key&&(l+=(t=>{const e=t.list||[],n=null!=t.separator?String(t.separator):" | ",o=t.styleConfig?.desktop||"",i=t.contentStyleConfig?.desktop||"",r=t.linkGapPx,l="number"==typeof r&&Number.isFinite(r)&&r>=0?r:0,a=Boolean(t.linkUnderline),s=t.styles?.desktop??{},c=null!=s.fontSize&&Number.isFinite(Number(s.fontSize))?`${Number(s.fontSize)}px`:"14px",d=null!=s.color&&""!==String(s.color).trim()?String(s.color):"#333333";let u="";return e.forEach((t,e)=>{e>0&&(u+=`<span style="${l>0?`display:inline-block;margin-left:${l}px;margin-right:${l}px;font-size:${c};color:${d};`:`display:inline-block;padding-left:4px;padding-right:4px;font-size:${c};color:${d};`}">${be(n)}</span>`);const i=he(t.url,"#"),r="_blank"===t.target?"_blank":"_self",s=be(t.label||"Link"),m=a?"underline":"none";u+=`<a target="${r}" href="${ke(i)}" style="${o};text-decoration:${m};display:inline-block;">${s}</a>`}),`<div ${t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:""} style="${i}">${u}</div>`})(t)),"avatar"===t.key&&(l+=(t=>{const e=t.src||"",n=t.alt||"Avatar",o=t.linkURL,i=t.styleConfig?.desktop||"",r=t.styles?.desktop?.width??64,l=`max-width:100%;width:${"number"==typeof r?r+"px":r};height:${"number"==typeof r?r+"px":r};object-fit:cover;border-radius:${t.styles?.desktop?.borderRadius??"50%"};${i}`,a=ke(e),s=ke(n),c=e?`<img src="${a}" alt="${s}" style="${l}" />`:`<div style="${l};background:#eee;display:flex;align-items:center;justify-content:center;"></div>`,d=t.contentStyleConfig?.desktop||"",u=o?`<a href="${ke(he(o))}" target="_blank" rel="noopener noreferrer">${c}</a>`:c;return`<div ${t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:""} style="${d}">${u}</div>`})(t)),"social_link"===t.key&&(l+=Be(t)),"raw_html"===t.key&&(l+=(t=>{const e=function(t){const e=t.match(/<body[^>]*>([\s\S]*?)<\/body>/i);return e?e[1]:/<html[\s>]/i.test(t)||/<!DOCTYPE/i.test(t)?t.replace(/<!DOCTYPE[^>]*>/gi,"").replace(/<html[^>]*>/gi,"").replace(/<\/html>/gi,"").replace(/<head[\s\S]*?<\/head>/gi,"").replace(/<\/?body[^>]*>/gi,"").trim():t}(t.html??""),n=t.contentStyleConfig?.desktop??"",o=t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:"",i=t.contentStyles?.desktop??{},r=i.width,l=i.textAlign??"center";let a="";return null!=r&&"100%"!==String(r)&&"center"===l?a="margin-left:auto;margin-right:auto;":null!=r&&"100%"!==String(r)&&"right"===l?a="margin-left:auto;margin-right:0;":null==r||"100%"===String(r)||"left"!==l&&"justify"!==l||(a="margin-left:0;margin-right:auto;"),`<div ${o} style="${a}max-width:100%;${n}">${e}</div>`})(t)),"table"===t.key&&(l+=(t=>{const e=t.contentStyleConfig?.desktop||"",n=t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:"",o=t.styles?.desktop??{},i="number"==typeof t.rows?t.rows:3,r="number"==typeof t.cols?t.cols:3,l=Boolean(t.headerRow),a=Boolean(t.headerCol),s=Boolean(t.stripedRows),c=o.fontSize??14,d=o.color??"#333333",u=o.borderStyle??"solid",m=o.borderWidth??1,p=o.borderColor??"#e0e0e0",g=o.cellPadding??8,f=o.textAlign??"left",y=o.headerBg??"#f5f5f5",b=o.headerColor??"#333333",k=o.stripedBg??"#fafafa",h="none"!==u?`${m}px ${u} ${p}`:"none",$=Array.from({length:i}).map((e,n)=>`<tr>${Array.from({length:r}).map((e,o)=>{const i=l&&0===n||a&&0===o,r=i?y:s&&!i&&n%2==0?k:"transparent",u=i?b:d,m=i?"600":"400",p=`${n}-${o}`,$=t.cells?.[p],x=l&&0===n||a&&0===o?"th":"td";let v="&#8212;";return"image"===$?.type&&String($.src??"").trim()?v=`<img src="${ke($.src)}" alt="${ke($.alt||"")}" style="max-width:100%;height:auto;display:block;border:0;"/>`:String($?.text??"").trim()&&(v=be(String($.text))),`<${x} style="border:${h};padding:${g}px;font-size:${c}px;color:${u};text-align:${f};background-color:${r};font-weight:${m};vertical-align:top;">${v}</${x}>`}).join("")}</tr>`).join("");return`<div ${n} style="${e}"><table role="presentation" style="${t.styleConfig?.desktop||""};border-collapse:collapse;width:100%;table-layout:auto;"><tbody>${$}</tbody></table></div>`})(t))}),l},Ue={preHeader:"",contentWidth:600,contentWidthMode:"email_width",stackColumnsOnMobile:!0,scaleFontOnMobile:!0,styles:{backgroundColor:"#F5F5F5",contentBg:"#FFFFFF",color:"#171717",headingColor:"#171717",linkColor:"#338AF3",fontFamily:"'Overused Grotesk', ui-sans-serif, system-ui, sans-serif"}},Ne=t=>Array.isArray(t)?t.filter(t=>!(t&&"object"==typeof t&&!0===t.hidden)).map(t=>t&&"object"==typeof t&&Array.isArray(t.children)?{...t,children:Ne(t.children)}:t):t,Ee=({bodySettings:t,blockList:e,templateData:n})=>{let o="";const i=((t,e)=>{if(!Array.isArray(t))return t;const n=e?.content?.products;if(!Array.isArray(n)||0===n.length)return t;const o=e?.content?.primaryProductId,i=(o?n.find(t=>t?.id===o):n[0])??n[0]??null;if(!i)return t;const r=n.filter(t=>t?.id!==i.id),l=t=>{if(!t||"object"!=typeof t)return t;const e=Array.isArray(t.children)?t.children.map(l):t.children;if("column"!==t.key||"product"!==t.containerType)return{...t,children:e};const n="additional"===t.productRole?"additional":"main",o=Math.max(Array.isArray(e)?e.length:0,Array.isArray(t.columnProducts)?t.columnProducts.length:0,1),a=Array.from({length:o},(t,e)=>"main"===n||0===r.length?i:r[e%r.length]);return{...t,children:e,columnProducts:a}};return t.map(l)})(Ne(e??[]),n),{newBlockList:r,styles:l}=Se(i);o=Ie(r,t,n);const a=Ft(i,t,n);return`<html>\n <head>\n <meta charset="UTF-8">\n <title>email</title>\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style type="text/css">\n *{\n margin: 0;\n padding: 0;\n border: none;\n box-sizing: border-box;\n }\n\n html,body {\n height:100%;\n overflow-y:auto;\n }\n\n table {\n width: 100%;\n color:unset;\n }\n\n table, tr, td {\n vertical-align: top;\n border-collapse: collapse;\n }\n\n h1,h2,h3,h4 {\n display: block;\n margin-block-start: 0px;\n margin-block-end: 0px;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n font-weight: bold;\n ${t.styles?.headingColor?`color: ${t.styles.headingColor};`:""}\n }\n\n a {\n ${t.styles?.linkColor?`color: ${t.styles.linkColor};`:""}\n }\n\n @media(max-width:620px){\n${!1!==t.stackColumnsOnMobile?" td {\n display:inline-block;\n width:100% !important;\n }\n":""}${!1!==t.scaleFontOnMobile?" body { font-size: 16px !important; }\n":""} }\n ${a}\n ${l}\n</style>\n </head>\n <body>\n <div style="opacity:0;">${t.preHeader}</div>\n <div style="background-color:${t.styles.backgroundColor};color:${t.styles.color}; font-family:${t.styles.fontFamily};"> ${o}</div>\n </body>\n </html>`};function Me(t){let e=t;if("string"==typeof t)try{e=JSON.parse(t)}catch(t){throw new Error("exportNormalizerToHtml: invalid JSON")}if(null==e)throw new Error("exportNormalizerToHtml: input is null or undefined");let n=[],o={...Ue,styles:{...Ue.styles}};Array.isArray(e)?n=e:"object"==typeof e&&(n=Array.isArray(e.blockList)?e.blockList:[],e.bodySettings&&"object"==typeof e.bodySettings&&(o={preHeader:null!=e.bodySettings.preHeader?e.bodySettings.preHeader:Ue.preHeader,contentWidth:g(e.bodySettings.contentWidth??Ue.contentWidth),contentWidthMode:e.bodySettings.contentWidthMode??Ue.contentWidthMode,stackColumnsOnMobile:!1!==e.bodySettings.stackColumnsOnMobile,scaleFontOnMobile:!1!==e.bodySettings.scaleFontOnMobile,styles:{backgroundColor:e.bodySettings.styles?.backgroundColor??Ue.styles.backgroundColor,contentBg:e.bodySettings.styles?.contentBg??Ue.styles.contentBg,color:e.bodySettings.styles?.color??Ue.styles.color,headingColor:e.bodySettings.styles?.headingColor??Ue.styles.headingColor,linkColor:e.bodySettings.styles?.linkColor??Ue.styles.linkColor,fontFamily:e.bodySettings.styles?.fontFamily??Ue.styles.fontFamily}}));return`<!DOCTYPE html>\n${function(t){return t.replace(/\n/g," ").replace(/[ \t]{2,}/g," ").replace(/> </g,"><").trim()}(Ee({bodySettings:o,blockList:n,templateData:e.templateData}))}`}const Re=Object.freeze({keys:["content","catalogProducts","companyContext","brandContext","companyId"],description:"templateData drives placeholders, product columns, and menu/social sync. content.products + content.primaryProductId, when non-empty, override product column assignments on load. catalogProducts (optional array) is the KB/catalog list for the product picker and for newly added preset product blocks; it does not replace columnProducts in a saved template when content.products is empty. companyContext.navigation_links and companyContext.social_links sync into menu/social blocks; brandContext (including brand_color) resolves branding tokens and CTA/button fallback colors in HTML export."});const Fe=["Product","Discount"],De=["text","image","button"];function je(t,e,n,o,i,r,l){if("column"===t.key&&t.containerType){const e=function(t){const e=t.toLowerCase();return"product"===e?"Product":"discount"===e?"Discount":"None"}(t.containerType),n=t.id??null;let a=o;"Product"===e&&(l.productIndex++,a=l.productIndex);for(const o of t.children??[])je(o,e,n,a,i,r,l);return}if("content"===t.key){for(const a of t.children??[])je(a,e,n,o,i,r,l);return}const a="dynamic"===t.contentType,s=Fe.includes(e)&&De.includes(t.key);if((a||s)&&n){let l=i.find(t=>t.containerId===n);l||(l={containerId:n,containerType:e,blocks:[]},i.push(l));const c=t.id?r[t.id]:void 0,d=function(t){return"image"===t.key?t.src??"":"button"===t.key?t.linkURL??"":t.text??""}(t);let u="";"Product"===e?u=function(t,e){const n=`product ${e}`;return t.includes("{{ProductImage}}")?`This block is meant for displaying the ${n} image`:t.includes("{{ProductName}}")?`This block is meant for displaying the ${n} name`:t.includes("{{ProductOldPrice}}")||t.includes("{{ProductNewPrice}}")?`This block is meant for displaying the ${n} original and discounted price`:t.includes("{{ProductPrice}}")||t.includes("{{ProductCurrency}}")?`This block is meant for displaying the ${n} price and currency`:t.includes("{{ProductDescription}}")?`This block is meant for displaying the ${n} description`:t.includes("{{ProductLink}}")?`This block is meant for displaying the ${n} link`:`This block is meant for displaying ${n} content`}(d,o):"Discount"===e&&(u=function(t){const e=[];return t.includes("{{DiscountValue}}")&&e.push("the discount value (e.g. 20% or $10)"),t.includes("{{DiscountCode}}")&&e.push("the discount/promo code"),t.includes("{{ValidUntil}}")&&e.push("the discount expiry date"),0===e.length?"This block is meant for displaying discount/offer information":`This block is meant for displaying ${e.join(", ")}`}(d));const m=c?.prompt||u,p=s&&!a;l.blocks.push({id:t.id??"",contentType:p||"dynamic"===t.contentType?"dynamic":"static",value:p?"":d,ai:{prompt:m,selectedSampleAiContent:p?"":c?.selectedContent??d}})}if(t.children)for(const a of t.children)je(a,e,n,o,i,r,l)}const ze={text:"text",image:"src",button:"linkURL"};function We(t,e){if(0===e.size)return!0;if(t.id&&e.has(t.id)){const n=e.get(t.id),o=ze[t.key];o&&(t[o]=n,e.delete(t.id))}if(t.children)for(const n of t.children)if(We(n,e))return!0;return 0===e.size}var Oe=Object.freeze({__proto__:null,jsonToHtml:function(t){return Me(t)},normalizeJson:function(t){const e="string"==typeof t?JSON.parse(t):t,n=[],o=e.aiContentRefs||{},i={productIndex:0},r=e.blockList||[];for(const t of r)je(t,"None",null,0,n,o,i);return{groups:n}},updateJsonWithMlContent:function(t,e){const n="string"==typeof t?JSON.parse(t):t,o=structuredClone(n),i=new Map;for(const t of e)t.variations.length>0&&i.set(t.nodeId,t.variations[0].value);const r=o.blockList||[];for(const t of r)if(We(t,i))break;return o}});exports.DEFAULT_EMAIL_CONTENT_API_BASE_V2=n,exports.DEFAULT_EMAIL_TEMPLATE_ID=o,exports.DEFAULT_MARKOPOLO_API_BASE_V1=t,exports.DEFAULT_ML_GENERATION_API_BASE_V1=e,exports.TEMPLATE_DATA_SCHEMA=Re,exports.createDefaultTemplateData=function(t={}){const e={name:"",website:"",navigation_links:[],social_links:{}},n={brand_color:"#111111",logo_url:"",tagline:"",heroBanner:"",footerBanner:""},o=null;return{content:{...{products:[],primaryProductId:null},...t.content&&"object"==typeof t.content?t.content:{}},companyContext:{...e,...t.companyContext&&"object"==typeof t.companyContext?t.companyContext:{}},brandContext:{...n,..."string"==typeof t.brandColor&&t.brandColor.trim()?{brand_color:t.brandColor.trim()}:{},...t.brandContext&&"object"==typeof t.brandContext?t.brandContext:{}},companyId:null!=t.companyId?t.companyId:o}},exports.exportNormalizerToHtml=Me,exports.exportTemplateJson=function(t,e={}){const{validate:n=!0}=e,o=t?.current;if(!o||"function"!=typeof o.exportJson)throw new Error("exportTemplateJson: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const i=o.exportJson();if(!i||"object"!=typeof i)throw new Error("exportTemplateJson: exportJson() returned an invalid payload.");return{payload:i,issues:n?M({blockList:i.blockList,bodySettings:i.bodySettings,aiContentRefs:i.aiContentRefs}):[]}},exports.exportTemplateJsonAsync=async function(t,e={}){const{validate:n=!0,checkImages:o=!0,imageProbe:i}=e,r=t?.current;if(!r||"function"!=typeof r.exportJson)throw new Error("exportTemplateJsonAsync: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const l=r.exportJson();if(!l||"object"!=typeof l)throw new Error("exportTemplateJsonAsync: exportJson() returned an invalid payload.");return n?{payload:l,issues:o?await O({blockList:l.blockList,bodySettings:l.bodySettings,aiContentRefs:l.aiContentRefs},i):M({blockList:l.blockList,bodySettings:l.bodySettings,aiContentRefs:l.aiContentRefs})}:{payload:l,issues:[]}},exports.mergeMarkopoloApiConfig=function(l={}){const a=l&&"object"==typeof l?l:{},{apiBaseUrlV1:s,apiBaseV1:c,emailContentApiBaseUrlV2:d,contentApiBaseUrlV2:u,mlGenerationApiBaseUrlV1:m,mlApiBaseUrlV1:p,headers:g,mlEmailGenerateBnEndpoint:f,...y}=a,b=s||c||t,k=i(()=>process.env.REACT_APP_ML_API_BASE_V1),h=r(b,m||p||k||e),$=i(()=>process.env.REACT_APP_EMAIL_CONTENT_API_BASE_V2),x=function(t,e){if(t&&String(t).trim())return String(t).trim().replace(/\/$/,"");{const t=e.replace(/\/$/,"");if(/\/v1$/i.test(t))return t.replace(/\/v1$/i,"/v2")}return n}(d||u||$,b),v=String(i(()=>process.env.REACT_APP_EMAIL_TEMPLATE_ID)??"").trim(),S={...h,...y};S.mlEmailGenerateEndpoint&&String(S.mlEmailGenerateEndpoint).trim()||!f||(S.mlEmailGenerateEndpoint=String(f).replace(/\/generate-email\/bn\/?$/i,"/generate-email"));const w=String(S.emailTemplateId??"").trim()||v||o;return{...S,emailTemplateId:w,emailContentApiBaseUrlV2:x,headers:{...S.headers||{},...g||{}}}},exports.utils=Oe,exports.validateExportPayload=M,exports.validateExportPayloadComplete=O,exports.validateImageUrlsReachable=W,exports.validateTemplateDataShape=function(t){const e=[];if(null==t||"object"!=typeof t)return{ok:!1,warnings:["templateData must be a non-null object"]};const n=t;if(null!=n.content&&"object"!=typeof n.content)e.push("templateData.content should be an object when provided");else if(n.content&&"object"==typeof n.content){const t=n.content;null==t.products||Array.isArray(t.products)||e.push("templateData.content.products should be an array when provided")}if(null==n.catalogProducts||Array.isArray(n.catalogProducts)||e.push("templateData.catalogProducts should be an array when provided"),null!=n.companyContext&&"object"!=typeof n.companyContext&&e.push("templateData.companyContext should be an object when provided"),null!=n.brandContext&&"object"!=typeof n.brandContext&&e.push("templateData.brandContext should be an object when provided"),n.brandContext&&"object"==typeof n.brandContext){const t=n.brandContext;null!=t.brand_color&&"string"!=typeof t.brand_color&&e.push("templateData.brandContext.brand_color should be a string when provided")}return{ok:0===e.length,warnings:e}};
1
+ "use strict";const t="https://api-alpha.markopolo.ai/v1",e="https://nbq-ml-api-stg.markopolo.ai/v1",n="https://backend-api-stg.markopolo.ai/v2",o="95b48b5b-cf5e-486d-817e-9839d4c4e618";function i(t){try{return t()}catch{return}}function r(n,o){const i=null!=(r=n)&&"string"==typeof r&&r.trim()?r.replace(/\/$/,""):t;var r;const l=function(t){return null!=t&&"string"==typeof t&&t.trim()?t.replace(/\/$/,""):e}(o);return{imageUploadEndpoint:`${i}/upload-file`,imageUploadQueryParams:{show:!1},imageUploadCompanyField:"comment",productsEndpoint:`${i}/knowledge-base/products`,universalEmailBlocksEndpoint:`${i}/universal-email-blocks`,mlEmailGenerateEndpoint:`${l}/ml-service/content/generate-email`}}function l(t){const e=String(t??"").trim();return/^(?:javascript|vbscript)\s*:/i.test(e)||/^data\s*:/i.test(e)}function a(t){let e=String(t??"").trim();if(!e)return"";if(l(e))return"";for(let t=0;t<e.length;t++){const n=e.charCodeAt(t),o=e[t];if(n<32||"<"===o||">"===o||'"'===o)return""}return e}function s(t){const e=String(t??"").trim().match(/^https?:\/\/(.+)/is);return!!e&&/^https?:\/\//i.test(e[1])}function c(t,e={}){const{allowMailtoTel:n=!0}=e,o=String(t??"").trim();if(!o)return null;if(l(o))return null;if(s(o))return null;if(n&&(/^mailto:/i.test(o)||/^tel:/i.test(o)))return o;const i=/^https?:\/\//i.test(o)?o:`https://${o.replace(/^\/+/,"")}`;return d(i,!1,e)?i:null}function d(t,e=!1,n={}){return null==u(t,e,n)}function u(t,e=!1,n={}){const{allowMailtoTel:o=!0}=n;if(null==t||""===String(t).trim())return e?null:"empty";const i=String(t).trim();if(l(i))return"blocked_scheme";if(s(i))return"duplicate_protocol";let r;if(/^https?:\/\//i.test(i)){const t=i.replace(/^https?:\/\//i,"");if(/^https?:\/\//i.test(t))return"duplicate_protocol";r=i}else r=o&&/^mailto:/i.test(i)||o&&/^tel:/i.test(i)?i:`https://${i}`;try{const t=new URL(r);return"http:"===t.protocol||"https:"===t.protocol?function(t){const e=String(t??"").trim().toLowerCase();return""!==e&&"http"!==e&&"https"!==e&&("localhost"===e||!!e.includes(":")||!!/^(?:\d{1,3}\.){3}\d{1,3}$/.test(e)||e.includes("."))}(t.hostname)?null:"missing_hostname_dot":o&&"mailto:"===t.protocol||o&&"tel:"===t.protocol?null:"invalid_protocol"}catch{return"invalid_url"}}function m(t){return!1!==t?.linkEnabled}const p={EMAIL_WIDTH:"email_width",CUSTOM_PX:"custom_px",FULL_BLEED:"full_bleed"};function g(t){const e=Math.round(Number(t));return!Number.isFinite(e)||e<=0?600:Math.min(1200,Math.max(280,e))}function f(t){return function(t){const e=t?.contentWidthMode;return Object.values(p).includes(e)?e:p.EMAIL_WIDTH}(t)===p.FULL_BLEED}const y={preHeader:"",contentWidth:600,stackColumnsOnMobile:!0,scaleFontOnMobile:!0,styles:{backgroundColor:"#F5F5F5",contentBg:"#FFFFFF",color:"#171717",headingColor:"#171717",linkColor:"#338AF3",fontFamily:"'Overused Grotesk', ui-sans-serif, system-ui, sans-serif"}};function b(t){const e=String(t??"").trim();return/^\{\{[A-Za-z_]\w*\}\}$/.test(e)}const k=/^\s*\{\{[\s\S]*\}\}\s*$/;function h(t){const e=String(t??"").trim();if(!e)return!1;if("#"===e)return!1;if(e.startsWith("#")&&e.length>1)return!1;if(k.test(e))return!1;if(b(e))return!1;const n=e.toLowerCase();return!n.startsWith("http://")&&!n.startsWith("https://")&&(!n.startsWith("mailto:")&&!n.startsWith("tel:")&&!n.startsWith("//"))}function $(t,e=!1){if(null==t||""===String(t).trim())return e;const n=String(t).trim();try{return/^https?:\/\//i.test(n)?new URL(n):new URL("https://"+n),!0}catch{return!1}}const x={text:"Text",heading:"Heading",button:"Button",image:"Image",video:"Video",avatar:"Profile image",menu:"Menu",social_link:"Social links",raw_html:"HTML"};const v={none:"Container",product:"Product",discount:"Discount",header:"Header",footer:"Footer",navigation_bar:"Navigation",introduction:"Introduction",hero:"Hero",hero_product:"Hero product",body:"Body",additional_product:"Additional product"};function S(t,e,n){const o=t.containerType??"none",i=function(t){const e=t??"none";return v[e]?v[e]:String(e).replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}(o);return n<=1?i:"none"===o?`${w(e+1)} section`:`${w(e+1)} ${i} block`}function w(t){const e=t%10,n=t%100;return 1===e&&11!==n?`${t}st`:2===e&&12!==n?`${t}nd`:3===e&&13!==n?`${t}rd`:`${t}th`}function C(t,e,n){const o=function(t){return x[t]?x[t]:String(t||"block").replace(/_/g," ").replace(/\b\w/g,t=>t.toUpperCase())}(e),i=[...t],r=i.length>0?i.join(" → "):"Email body";return n?`${o} ("${n}") — ${r}`:`${o} — ${r}`}function _(t,e){const n=function(t){return null==t||"object"!=typeof t?{...y,styles:{...y.styles}}:{preHeader:null!=t.preHeader?t.preHeader:y.preHeader,contentWidth:g(null!=t.contentWidth?t.contentWidth:y.contentWidth),stackColumnsOnMobile:!1!==t.stackColumnsOnMobile,scaleFontOnMobile:!1!==t.scaleFontOnMobile,styles:{backgroundColor:null!=t.styles?.backgroundColor?t.styles.backgroundColor:y.styles.backgroundColor,contentBg:null!=t.styles?.contentBg?t.styles.contentBg:y.styles.contentBg,color:null!=t.styles?.color?t.styles.color:y.styles.color,headingColor:null!=t.styles?.headingColor?t.styles.headingColor:y.styles.headingColor,linkColor:null!=t.styles?.linkColor?t.styles.linkColor:y.styles.linkColor,fontFamily:null!=t.styles?.fontFamily?t.styles.fontFamily:y.styles.fontFamily}}}(t);("number"!=typeof n.contentWidth||!Number.isFinite(n.contentWidth)||n.contentWidth<=0)&&e.push({severity:"error",code:"body_content_width_invalid",message:"Body content width must be between 280 and 1200 px.",location:"Theme settings"});const o=n.styles;null!=o.backgroundColor&&""!==String(o.backgroundColor).trim()||e.push({severity:"error",code:"body_background_color_missing",message:"Theme background color is missing.",location:"Theme settings"}),null!=o.color&&""!==String(o.color).trim()||e.push({severity:"error",code:"body_text_color_missing",message:"Theme text color is missing.",location:"Theme settings"}),null!=o.fontFamily&&""!==String(o.fontFamily).trim()||e.push({severity:"error",code:"body_font_family_missing",message:"Theme font family is missing.",location:"Theme settings"})}function A(t,e){t.push(e)}function L(t){return null==t?"":String(t).replace(/&amp;/gi,"&").replace(/&quot;/gi,'"').replace(/&#39;/g,"'").trim()}function P(t){if(null==t||"string"!=typeof t)return[];const e=[],n=/<a\b[^>]*?\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>"']+))/gi;let o=n.exec(t);for(;o;){const i=o[1]??o[2]??o[3]??"";e.push(L(i)),o=n.exec(t)}return e}function T(t,e=!0){const n=String(t??"").trim();return n?b(n)?null:u(n,!1,{allowMailtoTel:e}):null}function B(t,e,n){const o=t.linkURL,i=()=>C(e,"button",void 0),r=t.id??null;null==o||""===String(o).trim()?A(n,{severity:"warning",code:"button_empty_link",message:'Button link URL is empty; will be saved as href="https://".',location:i(),blockId:r}):l(o)?A(n,{severity:"error",code:"button_blocked_scheme",message:"Button link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",location:i(),blockId:r}):b(o)||d(o,!1,{allowMailtoTel:!0})?!b(o)&&h(o)&&A(n,{severity:"warning",code:"button_link_missing_protocol",message:"Button link should start with https://, http://, mailto:, or tel: for reliable email clients.",location:i(),blockId:r}):A(n,{severity:"warning",code:"button_invalid_link",message:"Button link URL format is invalid.",location:i(),blockId:r}),function(t,e,n,o,{invalidCode:i,invalidMessage:r,blockedCode:a,blockedMessage:s,missingProtocolCode:c,missingProtocolMessage:u}){P(t??"").forEach((t,m)=>{const p=String(t??"").trim();""!==p&&(l(p)?A(e,{severity:"error",code:a,message:s,location:n(m),blockId:o}):d(p,!1,{allowMailtoTel:!0})?h(p)&&A(e,{severity:"warning",code:c,message:u,location:n(m),blockId:o}):A(e,{severity:"warning",code:i,message:r,location:n(m),blockId:o}))})}(t.text,n,t=>C(e,"button",`label link ${t+1}`),r,{invalidCode:"button_label_invalid_link",invalidMessage:"Button label link URL format is invalid.",blockedCode:"button_label_blocked_link_scheme",blockedMessage:"Button label link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",missingProtocolCode:"button_label_link_missing_protocol",missingProtocolMessage:"Button label link should start with https://, http://, mailto:, or tel: for reliable email clients."})}const I=["product"];function U(t,e,n,o,i){(function(...t){const e=new Set,n=[];for(const o of t)if(null!=o&&""!==String(o).trim())for(const t of P(String(o))){const o=String(t).trim();o&&!e.has(o)&&(e.add(o),n.push(t))}return n})(t.text,t.dynamicSelectedContent).forEach((i,r)=>{const a=String(i??"").trim();""!==a&&(a.startsWith("#")||k.test(a)||(l(a)?A(n,{severity:"error",code:"text_blocked_link_scheme",message:"Text link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",location:C(e,o,`link ${r+1}`),blockId:t.id??null}):d(a,!1,{allowMailtoTel:!0})?h(a)&&A(n,{severity:"warning",code:"text_link_missing_protocol",message:"Text link should start with https://, http://, mailto:, or tel: for reliable email clients.",location:C(e,o,`link ${r+1}`),blockId:t.id??null}):A(n,{severity:"warning",code:"text_invalid_link",message:"Text link URL format is invalid.",location:C(e,o,`link ${r+1}`),blockId:t.id??null})))});if("dynamic"!==(t.contentType??"static"))return;const r=t.dynamicSelectedContent,a=null!=t?.id?i?.[t.id]?.selectedContent:void 0;let s=null!=r&&""!==String(r).trim()?r:a;var c;null!=s&&""!==String(s).trim()||null==t.text||""===(null==(c=t.text)?"":String(c).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())||(s=t.text),null!=s&&""!==String(s).trim()||A(n,{severity:"warning",code:"dynamic_content_empty",message:"Dynamic content not generated; export will use static text if available.",location:C(e,o,void 0),blockId:t.id??null})}function N(t,e,n){const o=t.list||[],i=new Set;o.forEach((o,r)=>{const a=o.title||o.image||`link ${r+1}`,s=t=>C(e,"social_link",t||a),c=function(t){const e=String(t?.image||"").trim();if(e)return`img:${e}`;const n=String(t?.title||"").trim().toLowerCase();return n?`title:${n}`:null}(o);c&&(i.has(c)?A(n,{severity:"warning",code:"social_duplicate_platform",message:"Duplicate social platform in this block; only one entry per platform should be kept.",location:s(a),blockId:t.id??null}):i.add(c));const u=o.linkURL;if(null==u||""===String(u).trim()){const e=String(o?.title||"").trim()||`Item ${r+1}`;A(n,{severity:"warning",code:"social_empty_link",message:`${e} URL is empty — add https URL before sending; the icon still previews without an outbound link.`,location:s(a),blockId:t.id??null})}else l(u)?A(n,{severity:"error",code:"social_blocked_scheme",message:"Social link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s) URLs only (e.g. www.example.com or https://…).",location:s(a),blockId:t.id??null}):d(u,!1,{allowMailtoTel:!1})||A(n,{severity:"warning",code:"social_invalid_link",message:"Social link URL format is invalid.",location:s(a),blockId:t.id??null});const m=o.image;null==m||""===String(m).trim()?A(n,{severity:"warning",code:"social_empty_icon",message:"Social link icon URL is empty; icon will not display.",location:s(a),blockId:t.id??null}):$(m,!1)||A(n,{severity:"warning",code:"social_invalid_icon",message:"Social link icon URL format is invalid.",location:s(a),blockId:t.id??null})}),0===o.length&&A(n,{severity:"info",code:"social_no_links",message:"Social link block has no links.",location:C(e,"social_link",void 0),blockId:t.id??null})}function E(t,e,n,o,i){if(!Array.isArray(t))return;const r=t.length;t.forEach((t,a)=>{if(!t||"object"!=typeof t)return;if(!0===t.hidden)return;const s=t.key;if("column"===s){const l=S(t,a,r),s=[...e,l];return function(t,e,n){const o=t.containerType??"none";if(!I.includes(o))return;const i=t.children??[],r=t.columnProducts??[];i.forEach((o,l)=>{const a=r[l];if(null==a||"object"==typeof a&&!a.id){const o=i.length>1?`Column ${l+1} of ${i.length}`:"This column",r=[...e,o].join(" → ");A(n,{severity:"warning",code:"container_product_not_assigned",message:"A product is not assigned to this column; assign a product in Container settings.",location:r,blockId:t.id??null})}})}(t,s,n),void(Array.isArray(t.children)&&E(t.children,s,n,o,i))}if("content"===s){const l=r>1?`Column ${a+1} of ${r}`:null,s=l?[...e,l]:e;return void(Array.isArray(t.children)&&E(t.children,s,n,o,i))}switch(s){case"image":!function(t,e,n){const o=t.src,i=()=>C(e,"image",void 0);null!=o&&""!==String(o).trim()?($(o,!1)||A(n,{severity:"warning",code:"image_invalid_src",message:"Image URL format is invalid.",location:i(),blockId:t.id??null}),m(t)&&T(t.linkURL,!0)&&A(n,{severity:"warning",code:"image_invalid_link",message:"Image link URL format is invalid.",location:i(),blockId:t.id??null}),null!=t.alt&&""!==String(t.alt).trim()||A(n,{severity:"info",code:"image_empty_alt",message:"Image alt text is empty; consider adding for accessibility.",location:i(),blockId:t.id??null})):A(n,{severity:"error",code:"image_empty_src",message:"Image URL is empty; the image will not display.",location:i(),blockId:t.id??null})}(t,e,n);break;case"video":!function(t,e,n){const o=()=>C(e,"video",void 0),i=null!=t.videoUrl?String(t.videoUrl).trim():"";i?$(i,!1)||A(n,{severity:"warning",code:"video_invalid_url",message:"Video URL format may be invalid.",location:o(),blockId:t.id??null}):A(n,{severity:"error",code:"video_empty_url",message:"Video URL is empty; the video will not display.",location:o(),blockId:t.id??null})}(t,e,n);break;case"avatar":!function(t,e,n){const o=t.src,i=()=>C(e,"avatar",void 0);null==o||""===String(o).trim()?A(n,{severity:"warning",code:"avatar_empty_src",message:"Avatar image URL is empty; avatar will not display.",location:i(),blockId:t.id??null}):$(o,!1)||A(n,{severity:"warning",code:"avatar_invalid_src",message:"Avatar image URL format is invalid.",location:i(),blockId:t.id??null}),T(t.linkURL,!0)&&A(n,{severity:"warning",code:"avatar_invalid_link",message:"Avatar link URL format is invalid.",location:i(),blockId:t.id??null})}(t,e,n);break;case"button":B(t,e,n);break;case"menu":!function(t,e,n){const o=t.list||[];o.forEach((o,i)=>{const r=String(o.label??"").trim()||`Item ${i+1}`,a=t=>C(e,"menu",t||`Item ${i+1}`);null!=o.label&&""!==String(o.label).trim()||A(n,{severity:"info",code:"menu_empty_label",message:'Navigation link label is empty; will display as "Link".',location:a(`item ${i+1}`),blockId:t.id??null});const s=o.url;null==s||""===String(s).trim()?A(n,{severity:"warning",code:"menu_empty_url",message:`"${r}" link URL is empty; will be saved as href="#". Add a destination URL (e.g. https://example.com) before sending.`,location:a(r),blockId:t.id??null}):l(s)?A(n,{severity:"error",code:"menu_blocked_scheme",message:`"${r}" link uses a blocked URL scheme (javascript:, data:, etc.). Use https://, mailto:, or tel: only.`,location:a(r),blockId:t.id??null}):d(s,!1,{allowMailtoTel:!0})?!b(s)&&h(s)&&A(n,{severity:"warning",code:"menu_item_url_missing_protocol",message:`"${r}" link should start with https://, http://, mailto:, or tel: for reliable email client support.`,location:a(r),blockId:t.id??null}):A(n,{severity:"warning",code:"menu_invalid_url",message:`"${r}" link URL is not valid. Use a full URL starting with https://example.com.`,location:a(r),blockId:t.id??null})}),0===o.length&&A(n,{severity:"info",code:"menu_no_items",message:"Menu block has no items.",location:C(e,"menu",void 0),blockId:t.id??null})}(t,e,n);break;case"social_link":N(t,e,n);break;case"raw_html":!function(t,e,n){const o=t.html;null!=o&&""!==String(o).trim()||A(n,{severity:"info",code:"raw_html_empty",message:"HTML block has no custom markup; export will include an empty wrapper.",location:C(e,"raw_html",void 0),blockId:t.id??null})}(t,e,n);break;case"text":U(t,e,n,"text",i);break;case"heading":U(t,e,n,"heading",i)}})}function M({blockList:t,bodySettings:e,aiContentRefs:n={}}){const o=[];return _(e,o),E(Array.isArray(t)?t:[],[],o,e,n),o}function R(){const t="undefined"!=typeof window&&null!=window?window:"undefined"!=typeof global&&null!=global?global:void 0;if(!t)return;const e=t.Image;return"function"==typeof e?e:void 0}const F=/^\{\{\s*[\w.]+\s*\}\}$/;function D(t){if(null==t||""===String(t).trim())return null;const e=String(t).trim();if(function(t){return null!=t&&"string"==typeof t&&F.test(t.trim())}(e))return null;if(/^https?:\/\//i.test(e))return $(e,!1)?e:null;if(e.startsWith("//")){const t=`https:${e}`;return $(t,!1)?t:null}return null}function j(t,e=[],n=t?.length??0){const o=[];return Array.isArray(t)?(t.forEach((t,i)=>{if(!t||"object"!=typeof t)return;if(!0===t.hidden)return;const r=t.key;if("column"===r){const r=S(t,i,n),l=[...e,r],a=t.children;return void o.push(...j(a,l,a?.length??0))}if("content"===r){const r=n>1?`Column ${i+1} of ${n}`:null,l=r?[...e,r]:e,a=t.children;return void o.push(...j(a,l,a?.length??0))}if("image"===r){const n=D(t.src);n&&o.push({url:n,location:C(e,"image",void 0),blockId:t.id??null})}}),o):o}function z(t,e=12e3){const n=R();if(!n)return Promise.resolve(!1);const o=String(t).trim();return o?new Promise(t=>{const i=new n;let r=!1;const l=e=>{r||(r=!0,clearTimeout(a),i.onload=null,i.onerror=null,t(e))},a=setTimeout(()=>l(!1),e);i.onload=()=>l(!0),i.onerror=()=>l(!1);try{i.src=o}catch{l(!1)}}):Promise.resolve(!1)}async function W(t,e={}){const{timeoutMs:n=12e3,concurrent:o=6}=e;if(!R())return[];const i=j(Array.isArray(t)?t:[]);if(0===i.length)return[];const r=new Map;for(const t of i)r.has(t.url)||r.set(t.url,[]),r.get(t.url).push(t.location);const l=[...r.keys()],a=new Map;let s=0;const c=Math.max(1,Math.min(o,l.length));await Promise.all(Array.from({length:c},()=>async function(){for(;s<l.length;){const t=s++,e=l[t],o=await z(e,n);a.set(e,o)}}()));const d=[];for(const[t,e]of r)if(!0!==a.get(t))for(const n of e)d.push({severity:"warning",code:"image_url_not_loadable",message:"Image URL could not be loaded or previewed; the link may be broken, expired, or blocked.",location:n,blockId:i.find(e=>e.url===t&&e.location===n)?.blockId??null});return d}async function O(t,e){return[...M(t),...await W(t?.blockList??[],e)]}var K={global:[{key:"CustomerName",token:"{{CustomerName}}",label:"Customer Name",labelKey:"variable_customer_name",type:"text",fallback:"Customer",source:"derived"},{key:"BrandName",token:"{{BrandName}}",label:"Brand Name",labelKey:"variable_brand_name",type:"text",fallback:"Company Name",source:"companyContext.name"},{key:"Tagline",token:"{{Tagline}}",label:"Tagline",labelKey:"variable_tagline",type:"text",fallback:"Your tagline here",source:"brandContext.tagline"},{key:"LogoUrl",token:"{{LogoUrl}}",label:"BrandLogo",labelKey:"variable_image_logo",type:"image",fallback:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",source:"brandContext.logo_url"},{key:"Website",token:"{{Website}}",label:"Website",labelKey:"variable_website",type:"text",fallback:"www.example.com",source:"companyContext.website"},{key:"Address",token:"{{Address}}",label:"Address",labelKey:"variable_address",type:"text",fallback:"",source:"companyContext.address"}],product:[{key:"ProductName",token:"{{ProductName}}",label:"Product Name",labelKey:"variable_product_name",type:"text",fallback:"Product Name",source:"content.products[].name"},{key:"ProductDescription",token:"{{ProductDescription}}",label:"Product Description",labelKey:"variable_product_description",type:"text",fallback:"Product description goes here.",source:"content.products[].description"},{key:"ProductImage",token:"{{ProductImage}}",label:"Product Image URL",labelKey:"variable_product_image",type:"image",fallback:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",source:"content.products[].image"},{key:"ProductLink",token:"{{ProductLink}}",label:"Product Link",labelKey:"variable_product_link",type:"url",fallback:"https://www.example.com",source:"content.products[].link"},{key:"ProductPrice",token:"{{ProductPrice}}",label:"Product Price (Amount)",labelKey:"variable_product_price",type:"number",fallback:"0",source:"content.products[].price.amount"},{key:"ProductCurrency",token:"{{ProductCurrency}}",label:"Product Currency",labelKey:"variable_product_currency",type:"text",fallback:"USD",source:"content.products[].price.currency"},{key:"ProductOldPrice",token:"{{ProductOldPrice}}",label:"Product Old Price",labelKey:"variable_product_old_price",type:"number",fallback:"0",source:"content.products[].old_price"},{key:"ProductNewPrice",token:"{{ProductNewPrice}}",label:"Product New Price",labelKey:"variable_product_new_price",type:"number",fallback:"0",source:"content.products[].new_price"},{key:"ProductPriceDisplay",token:"{{ProductPriceDisplay}}",label:"Product Price Display",labelKey:"variable_product_price_display",type:"text",fallback:"USD 0",source:"derived"}],discount:[{key:"DiscountValue",token:"{{DiscountValue}}",label:"Discount Value",labelKey:"variable_discount_value",type:"text",fallback:"20%",source:"content.discount.value"},{key:"DiscountCode",token:"{{DiscountCode}}",label:"Discount Code",labelKey:"variable_discount_code",type:"text",fallback:"SAVE20",source:"content.discount.code"},{key:"ValidUntil",token:"{{ValidUntil}}",label:"Valid Until",labelKey:"variable_valid_until",type:"date",fallback:"12-31-2025",source:"content.discount.valid_until"}]};const H="CustomerName",V="DiscountValue",G="DiscountCode",J="ValidUntil",Z="CompanyName",Y="Address",q="Website",X="BrandName",Q="LogoUrl",tt="Tagline",et="HeroBanner",nt="FooterBanner",ot="NavLabel",it="NavUrl",rt="ProductName",lt="ProductDescription",at="ProductImage",st="ProductLink",ct="ProductPrice",dt="ProductCurrency",ut="ProductOldPrice",mt="ProductNewPrice",pt="ProductPriceDisplay",gt="CTALabel",ft="CTAUrl",yt=new Set([ut,mt]);let bt=K;function kt(t,e=bt){return e&&Array.isArray(e[t])?e[t].map(t=>{return{...t,token:t.token||(e=t.key,`{{${e}}}`)};var e}):[]}let ht=[],$t=[],xt=[];!function(){ht=kt("global",bt),$t=kt("product",bt),xt=kt("discount",bt),[...ht,...$t,...xt].reduce((t,e)=>(t[e.key]=e,t),{}),xt.map(t=>({variableKey:t.key,labelKey:t.labelKey}));const t=$t.filter(t=>!yt.has(t.key));t.map(t=>({variableKey:t.key,labelKey:t.labelKey})),ht.map(t=>({value:t.token,label:t.label,key:t.key,labelKey:t.labelKey,source:t.source,type:t.type})),xt.map(t=>({value:t.token,label:t.label,key:t.key,labelKey:t.labelKey,source:t.source,type:t.type})),t.map(t=>({value:t.token,label:t.label,key:t.key,labelKey:t.labelKey,source:t.source,type:t.type}))}();const vt={[H]:"User",[V]:"20%",[G]:"SAVE20",[J]:"12-31-2025",[Z]:"Company Name",[X]:"Company Name",[Y]:"",[q]:"www.example.com",[Q]:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",[tt]:"Your tagline here",[et]:"https://via.placeholder.com/600x200/eeeeee/666666?text=Hero",[nt]:"https://via.placeholder.com/600x100/eeeeee/666666?text=Footer",[ot]:"Link",[it]:"https://www.example.com",[rt]:"Product Name",[lt]:"Product description goes here.",[at]:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",[st]:"https://www.example.com",[ct]:"0",[dt]:"USD",[ut]:"0",[mt]:"0",[pt]:"$0.00 USD",[gt]:"Shop Now",[ft]:"www.example.com"};function St(t){return null==t||"string"!=typeof t?"":t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const wt=new Set([pt]);function Ct(t,e,n={}){if(null==t||"string"!=typeof t)return"";const o=t.replace(/\{\{(\w+)\}\}/g,(t,o)=>{const i=It(e,o,n);return wt.has(o)?i:St(i)});return null==(i=o)||"string"!=typeof i?i:i.replace(/^(<p[^>]*>\s*(?:<br\s*\/?>|&nbsp;)?\s*<\/p>\s*)+/i,"");var i}function _t(t){return vt[t]??"—"}const At=/^\{\{\s*[\w.]+\s*\}\}$/;function Lt(t,e,{allowEmpty:n=!1}={}){if(null==t)return n?"":_t(e);const o=String(t).trim();return""===o?n?"":_t(e):function(t){return"string"==typeof t&&At.test(t.trim())}(o)?_t(e):o}const Pt={USD:"en-US",CAD:"en-CA",EUR:"de-DE",GBP:"en-GB",AUD:"en-AU",NZD:"en-NZ",SGD:"en-SG",INR:"en-IN",JPY:"ja-JP",CNY:"zh-CN",BDT:"bn-BD",AED:"ar-AE",SAR:"ar-SA"};function Tt(t){return function(t){return"string"==typeof t&&/^[A-Za-z]{3}$/.test(t.trim())}(t)?String(t).trim().toUpperCase():"USD"}function Bt(t,e){const n=function(t){if(null==t)return null;const e=String(t).replace(/,/g,"").trim();if(""===e)return null;const n=Number(e);return Number.isFinite(n)?n:null}(t);if(null==n)return null;const o=Tt(e),i=function(t){return Pt[t]??null}(o);if(!i)return null;const r=function(t){if(null==t)return 0;const e=String(t).trim().replace(/,/g,"");if(!e.includes("."))return 0;const[,n=""]=e.split(".");return Math.max(0,n.length)}(t);try{return`${new Intl.NumberFormat(i,{style:"currency",currency:o,minimumFractionDigits:r,maximumFractionDigits:r}).format(n)} ${o}`}catch{return null}}function It(t,e,n={}){if(!t)return _t(e);const{columnIndex:o,columnProduct:i}=n;let r=i;switch(!r&&t.content?.products&&"number"==typeof o&&(r=t.content.products[o]||null),e){case H:return Lt(t.customer?.name,H);case V:return Lt(t.content?.discount?.value,V);case G:return Lt(t.content?.discount?.code,G);case J:return Lt(t.content?.discount?.valid_until,J);case Z:case X:return Lt(t.companyContext?.name,e);case Y:return Lt(t.companyContext?.address,Y,{allowEmpty:!0});case q:return Lt(t.companyContext?.website,q);case Q:return Lt(t.brandContext?.logo_url,Q);case tt:return Lt(t.brandContext?.tagline,tt);case et:return Lt(t.brandContext?.heroBanner,et);case nt:return Lt(t.brandContext?.footerBanner,nt);case ot:case it:return _t(e);case rt:return Lt(r?.name,rt);case lt:{const t=function(t){if(null==t)return"";const e=String(t).trim();if(!e)return"";const n=e.toLowerCase();return"none"===n||"null"===n||"undefined"===n?"":e}(r?.description);return t?Lt(t,lt,{allowEmpty:!0}):""}case at:return Lt(r?.image,at);case st:return Lt(r?.link,st);case ct:return null!=r?.price&&"number"==typeof r.price||null!=r?.price&&"string"==typeof r.price?String(r.price):null!=r?.new_price?String(r.new_price):_t(ct);case dt:return Lt(r?.currency,dt);case ut:return Lt(r?.old_price,ut);case mt:return null!=r?.new_price?Lt(r.new_price,mt):null!=r?.price?Lt(r.price,mt):_t(mt);case pt:{const t=Tt(r?.currency),e=null!=r?.price?r.price:r?.new_price,n=null!=r?.old_price||null!=r?.new_price,o=null!=r?.old_price?r.old_price:null,i=null!=r?.new_price?r.new_price:null!=r?.price?r.price:null;if(n&&(null!=o||null!=i)){const e=Bt(o,t),n=Bt(i,t),r=null!=(null!=e?e:null!=o?String(o):null)?St(null!=e?e:null!=o?String(o):""):"";return[""!==r?`<span style="text-decoration: line-through;">${r}</span>`:"",null!=(null!=n?n:null!=i?String(i):null)?St(null!=n?n:null!=i?String(i):""):""].filter(Boolean).join(" ")||_t(pt)}const l=Bt(e,t);return null!=l?St(l):null!=e?St(String(e)):_t(pt)}case gt:{const e=t.content?.cta?.text;return Lt(e,gt)}case ft:{const e=t.content?.cta?.url;return Lt(null!=e?e:t.companyContext?.website,ft)}default:return _t(e)}}function Ut(t,e,n={}){if(!t||!e)return t;const{useImportant:o=!1}=n,i=String(e).trim();if(!i)return t;const r=o?`color: ${i} !important`:`color: ${i}`;return String(t).replace(/<a\b([^>]*)>/gi,(t,e)=>{const n=e.match(/\sstyle\s*=\s*"([^"]*)"/i);if(n){const t=(n[1]||"").replace(/\s*color\s*:\s*[^;]+(!important)?\s*;?/gi,"").replace(/;\s*;/g,";").replace(/^\s*;|;\s*$/g,"").trim(),o=`${t?`${t}; `:""}${r};`;return`<a${e.replace(n[0],` style="${o}"`)}>`}const o=e.match(/\sstyle\s*=\s*'([^']*)'/i);if(o){const t=(o[1]||"").replace(/\s*color\s*:\s*[^;]+(!important)?\s*;?/gi,"").replace(/;\s*;/g,";").replace(/^\s*;|;\s*$/g,"").trim(),n=`${t?`${t}; `:""}${r};`;return`<a${e.replace(o[0],` style='${n}'`)}>`}return`<a${e} style="${r};">`})}const Nt=[{name:"Roboto",fallback:"Arial, sans-serif"},{name:"Open Sans",fallback:"Arial, sans-serif"},{name:"Lato",fallback:"Arial, sans-serif"},{name:"Montserrat",fallback:"Arial, sans-serif"},{name:"Poppins",fallback:"Arial, sans-serif"},{name:"Merriweather",fallback:"Georgia, serif"},{name:"Playfair Display",fallback:"Georgia, serif"},{name:"Cormorant Garamond",fallback:"Garamond, 'Times New Roman', serif"},{name:"Source Sans 3",fallback:"Arial, sans-serif"},{name:"Inter",fallback:"Arial, sans-serif"},{name:"Nunito",fallback:"Arial, sans-serif"},{name:"Nunito Sans",fallback:"Arial, sans-serif"},{name:"Raleway",fallback:"Arial, sans-serif"},{name:"Rubik",fallback:"Arial, sans-serif"},{name:"Work Sans",fallback:"Arial, sans-serif"},{name:"DM Sans",fallback:"Arial, sans-serif"},{name:"Manrope",fallback:"Arial, sans-serif"},{name:"Outfit",fallback:"Arial, sans-serif"},{name:"Plus Jakarta Sans",fallback:"Arial, sans-serif"},{name:"IBM Plex Sans",fallback:"Arial, sans-serif"},{name:"IBM Plex Serif",fallback:"Georgia, serif"},{name:"Noto Sans",fallback:"Arial, sans-serif"},{name:"Noto Serif",fallback:"Georgia, serif"},{name:"PT Sans",fallback:"Arial, sans-serif"},{name:"PT Serif",fallback:"Georgia, serif"},{name:"Ubuntu",fallback:"Arial, sans-serif"},{name:"Fira Sans",fallback:"Arial, sans-serif"},{name:"Barlow",fallback:"Arial, sans-serif"},{name:"Quicksand",fallback:"Arial, sans-serif"},{name:"Libre Baskerville",fallback:"Georgia, serif"},{name:"Libre Franklin",fallback:"Arial, sans-serif"},{name:"Crimson Pro",fallback:"Georgia, serif"},{name:"Lora",fallback:"Georgia, serif"},{name:"Space Grotesk",fallback:"Arial, sans-serif"},{name:"Archivo",fallback:"Arial, sans-serif"},{name:"Mulish",fallback:"Arial, sans-serif"},{name:"Figtree",fallback:"Arial, sans-serif"},{name:"Be Vietnam Pro",fallback:"Arial, sans-serif"},{name:"Sora",fallback:"Arial, sans-serif"},{name:"Josefin Sans",fallback:"Arial, sans-serif"}];function Et(t){return`https://fonts.googleapis.com/css2?family=${(t=>String(t).trim().replace(/\s+/g,"+"))(t)}:wght@400;700&display=swap`}function Mt(t){if(!t)return"";const e=String(t).split(",")[0];return String(e??"").trim().replace(/^['"]|['"]$/g,"")}function Rt(t){const e=String(t.name||"").trim(),n=String(t.url||"").trim();if(!e||!n)return"";const o=t.format?` format('${t.format}')`:"",i=t.weight?`font-weight:${t.weight};`:"",r=t.style?`font-style:${t.style};`:"";return`@font-face{font-family:${(t=>/\s/.test(String(t||""))?`'${String(t).replace(/'/g,"\\'")}'`:String(t))(e)};src:url('${n}')${o};${i}${r}}`}function Ft(t,e,n){const o=function(t,e){const n=new Set,o=t=>{null!=t&&""!==String(t).trim()&&n.add(String(t).trim())};o(e?.styles?.fontFamily);const i=t=>{Array.isArray(t)&&t.forEach(t=>{t&&"object"==typeof t&&(o(t?.styles?.desktop?.fontFamily),o(t?.styles?.mobile?.fontFamily),"image"===t.key&&Array.isArray(t.overlayItems)&&t.overlayItems.forEach(t=>{t&&"object"==typeof t&&o(t.fontFamily)}),Array.isArray(t.children)&&i(t.children))})};return i(t),[...n]}(t,e),i=new Set;o.forEach(t=>{const e=function(t){const e=Mt(t),n=Nt.find(t=>t.name.toLowerCase()===e.toLowerCase());return n?Et(n.name):null}(t);e&&i.add(e)});const r=(Array.isArray(n?.brandContext?.customFonts)?n.brandContext.customFonts:[]).map(Rt).filter(Boolean);return[...[...i].map(t=>`@import url('${t}');`),...r].join("\n")}function Dt(t){const e=String(t?.image||"").toLowerCase(),n=String(t?.title||"").toLowerCase().trim();return e.includes("/tc-x.svg")||e.includes("/brand-x.svg")||e.includes("/icons/x.svg")||e.includes("simple-icons")&&e.includes("/x.svg")||"x"===n||"twitter"===n}const jt=["default","white","black","gray"];function zt(t){if(!t||"object"!=typeof t)return{};const{padding:e,paddingTop:n,paddingRight:o,paddingBottom:i,paddingLeft:r,...l}=t;return l}const Wt={small:21,medium:24,large:32},Ot="https://unpkg.com/@tabler/icons@3.24.0/icons/outline",Kt={facebook:"brand-facebook",x:"brand-x",instagram:"brand-instagram",linkedin:"brand-linkedin",tiktok:"brand-tiktok",youtube:"brand-youtube",pinterest:"brand-pinterest"};function Ht(t){if(!t)return null;const e=Kt[t];return e?`${Ot}/${e}.svg`:null}function Vt(t){if(!t)return null;if(Dt(t))return"x";const e=String(t.image||"").toLowerCase(),n=String(t.title||"").toLowerCase();return e.includes("facebook")||n.includes("facebook")?"facebook":e.includes("instagram")||n.includes("instagram")?"instagram":e.includes("linkedin")||n.includes("linkedin")?"linkedin":e.includes("tiktok")||n.includes("tiktok")?"tiktok":e.includes("youtube")||n.includes("youtube")?"youtube":e.includes("pinterest")||n.includes("pinterest")?"pinterest":null}const Gt="https://s.magecdn.com/social";const Jt={facebook:"tc-facebook.svg",x:"tc-x.svg",instagram:"tc-instagram.svg",linkedin:"tc-linkedin.svg",tiktok:"tc-tiktok.svg",youtube:"tc-youtube.svg",pinterest:"tc-pinterest.svg"};function Zt(t){const e=String(t||"").toLowerCase();return Ht("twitter"===e?"x":e)}function Yt(t){const e=function(t){switch(t){case"white":return"brightness(0) invert(1)";case"black":return"brightness(0)";case"gray":return"brightness(0) opacity(0.55)";default:return""}}(t);return e?{filter:e}:{}}function qt(t,e,n){const o=Number(n)||Wt.medium,i={width:o,height:o,objectFit:"contain",display:"block",verticalAlign:"middle",flexShrink:0},r=e&&"default"!==e?e:"default",l=String(t?.image||"").trim(),a=function(t){return Ht(Vt(t))}(t),s=function(t){const e=Vt(t);if(!e)return null;const n=Jt[e];return n?`${Gt}/${n}`:null}(t);if(l&&!function(t){const e=String(t||"").trim().toLowerCase();return!(!e||!e.startsWith(String(Gt).toLowerCase())&&!e.startsWith(String(Ot).toLowerCase())&&!e.includes("unpkg.com/@tabler/icons"))}(l))return{src:l,style:i};if("default"===r)return s?{src:s,style:i}:{src:l,style:i};if(a){if("white"===r)return{src:a,style:{...i,filter:"brightness(0) invert(1)"}};if("gray"===r)return{src:a,style:{...i,filter:"brightness(0) opacity(0.55)"}};if("black"===r)return{src:a,style:i}}return l?{src:l,style:{...i,...Yt(r)}}:{src:"",style:i}}function Xt(t,e,n){const{src:o,style:i}=qt(t,e,n),r=Number(n)||Wt.medium,l=[`width:${r}px`,`height:${r}px`,"object-fit:contain","display:block","vertical-align:middle"];return"brightness(0) opacity(0.55)"===i.filter?l.push("opacity:0.55"):i.filter&&l.push(`filter:${i.filter}`),null!=i.opacity&&l.push(`opacity:${i.opacity}`),{src:o,styleAttr:l.join(";")}}const Qt="ee_cb";function te(t){const e=String(t??"").trim();if(!e)return e;try{const t="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(e,t);n.searchParams.delete(Qt);let o=n.toString();return o.endsWith("?")&&(o=o.slice(0,-1)),o}catch{return e.replace(new RegExp(`[?&]${Qt}=\\d+`,"g"),"").replace(/\?&/g,"?").replace(/&&+/g,"&").replace(/[?&]$/,"")}}function ee(t){const e=t??{};if(!1===e.containerBackgroundEnabled)return"";const n=te(e.containerBackgroundImage);if(!n||!String(n).trim())return"";return`background-image:url("${String(n??"").trim().replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"").replace(/\r/g,"")}");background-size:${{cover:"cover",contain:"contain",fill:"100% 100%"}[e.containerBackgroundSize||"cover"]||"cover"};background-position:${e.containerBackgroundPosition||"center center"};background-repeat:no-repeat;`}const ne=["tl","tc","tr","ml","mc","mr","bl","bc","br"],oe={tl:{top:"10%",left:"8%",transform:"translate(0, 0)",textAlign:"left"},tc:{top:"10%",left:"50%",transform:"translate(-50%, 0)",textAlign:"center"},tr:{top:"10%",right:"8%",transform:"translate(0, 0)",textAlign:"right"},ml:{top:"50%",left:"8%",transform:"translate(0, -50%)",textAlign:"left"},mc:{top:"50%",left:"50%",transform:"translate(-50%, -50%)",textAlign:"center"},mr:{top:"50%",right:"8%",transform:"translate(0, -50%)",textAlign:"right"},bl:{bottom:"10%",left:"8%",transform:"translate(0, 0)",textAlign:"left"},bc:{bottom:"10%",left:"50%",transform:"translate(-50%, 0)",textAlign:"center"},br:{bottom:"10%",right:"8%",transform:"translate(0, 0)",textAlign:"right"}};function ie(t){const e=String(t??"bc").toLowerCase();return ne.includes(e)?e:"bc"}function re(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})}const le=[{key:"facebook",image:Zt("facebook"),title:"Facebook"},{key:"twitter",image:Zt("twitter"),title:"X"},{key:"instagram",image:Zt("instagram"),title:"Instagram"},{key:"linkedin",image:Zt("linkedin"),title:"LinkedIn"},{key:"tiktok",image:Zt("tiktok"),title:"TikTok"},{key:"youtube",image:Zt("youtube"),title:"YouTube"}];function ae(t){const e=t?.socialPlatformKey;if(e&&"string"==typeof e&&le.some(t=>t.key===e))return e;if(Dt(t))return"twitter";const n=String(t?.title??"").trim().toLowerCase(),o=String(t?.image??"").trim();for(const t of le){if(n&&n===t.title.toLowerCase())return t.key;if("twitter"===t.key&&n&&("twitter"===n||"tweet"===n||"tw"===n))return"twitter";if(o&&o===t.image)return t.key}return null}function se(t,e){if(null==t||""===t)return"";const n=String(t);return e?n.replace(/\{\{(\w+)\}\}/g,(t,n)=>{const o=It(e,n,{});if(null==o)return`{{${n}}}`;const i=String(o);return i.startsWith("{{")?`{{${n}}}`:i}):n}function ce(t,e){if(null==t||""===t)return"";const n=String(t);return e?n.replace(/\{\{(\w+)\}\}/g,(t,n)=>{const o=It(e,n,{}),i=null!=o?String(o).trim():"";return!i||"—"===i||i.startsWith("{{")?t:i}):n}function de(t){return(Array.isArray(t)&&0!==t.length?t:function(t,e){const n=e&&"object"==typeof e&&!Array.isArray(e)?e:{},o=Array.isArray(t)?t:[],i=new Map,r=[];for(const t of o){const e=ae(t);e?i.set(e,t):r.push(t)}return[...le.map(t=>{const e=i.get(t.key),o=null!=n[t.key]?a(String(n[t.key]).trim()):"",r=null!=e?.linkURL?String(e.linkURL).trim():"",l=r?a(r):"",s=o||l||"";return{id:e?.id??re(),image:e?.image||t.image,title:e?.title||t.title,linkURL:s,socialPlatformKey:t.key}}),...r]}([],{})).map(t=>({id:t?.id,image:t?.image??"",title:t?.title??"",linkURL:t?.linkURL??"",socialPlatformKey:t?.socialPlatformKey}))}function ue(t){return Array.isArray(t)&&0!==t.length?t.map(t=>({id:t?.id,label:t?.label??"",url:t?.url??"",target:"_blank"===t?.target?"_blank":"_self"})):[{id:re(),label:"Privacy",url:"#",target:"_self"},{id:re(),label:"Terms",url:"#",target:"_self"}]}const me=t=>String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),pe=(t,e)=>{if(null==t||""===t)return e;if("number"==typeof t)return t;const n=parseInt(String(t).replace(/px/gi,""),10);return Number.isFinite(n)?n:e};function ge(t,e,n){const o=t,i=o.styles?.desktop??{},r=Boolean(o.showBrand??!0),l=Boolean(o.showTagline??!0),a=Boolean(o.footerShowLogo??!1),s=function(t,e){const n="string"==typeof t?t.trim():String(t??"").trim();if(!n)return"";const o=/^\{\{(\w+)\}\}$/.exec(n);if(o&&e){const t=It(e,o[1],{});if(null!=t&&""!==String(t).trim()&&!String(t).startsWith("{{"))return String(t).trim()}return n}(o.footerLogoSrc??"",n),d=se(String(o.footerLogoAlt??"Logo").trim()||"Logo",n).trim()||"Logo",u=o.footerLogoLink??"",m=pe(o.footerLogoMaxWidthPercent,30),p=pe(o.footerLogoPaddingPx,24),g=Boolean(o.showAddress??!0),f=Boolean(o.showUnsubscribe??!0),y=Boolean(o.showSocial??!1),b=Boolean(o.showSecondaryLinks??!1),k=Boolean(o.showCopyright??!0),h=se(o.brandName??"",n),$=se(o.brandTagline??"",n).trim(),x=se(o.address??"",n),v=se(o.copyrightText??"",n),S=o.unsubscribeUrl||"{{unsubscribe_url}}",w=null!=o.unsubscribeBodyText&&""!==String(o.unsubscribeBodyText).trim()?String(o.unsubscribeBodyText):"You are receiving this email because you subscribed.",{unsubscribeLinkLabel:C}=function(t){let e=null!=t?.unsubscribeLinkLabel&&""!==String(t.unsubscribeLinkLabel).trim()?String(t.unsubscribeLinkLabel).trim():"";const n=String(t?.unsubscribeText??"").trim();if(!e&&n){const t=n.split(/\s*[·•]\s*/);e=t[0]?.trim()||""}return{unsubscribeLinkLabel:e||"Unsubscribe"}}(o),_=ue(o.secondaryLinks),A=de(o.footerSocialList),L=i.color??"#737373",P=null!=i.linkColor&&""!==String(i.linkColor).trim()?String(i.linkColor).trim():L,T=pe(i.fontSize,12),B=i.textAlign??"center",I=pe(i.paddingTop,28),U=pe(i.paddingRight,24),N=pe(i.paddingBottom,28),E=pe(i.paddingLeft,24),M=function(t){const e=null!=t?String(t).trim():"";return e&&"transparent"!==e.toLowerCase()?e:"#ffffff"}(i.contentBackground),R=Boolean(o.showDivider??!1),F=me(o.dividerColor??"#374151"),D=Boolean(o.showBorderTop??!1),j=pe(o.borderTopWidth,1),z=o.borderTopStyle??"solid",W=me(o.borderTopColor??"#e5e7eb"),O=D&&j>0?`${j}px ${z} ${W}`:"",K=e?.width??"100%",H=e?.styleConfig?.mobile?` class="${e.styleConfig.className}"`:"",V=e?.styleConfig?.desktop??"",G=`margin:0;color:${me(L)};font-size:${T}px;line-height:1.5;font-family:Arial,sans-serif;text-align:${me(B)};`,J=`color:${me(P)};text-decoration:underline;`,Z=[];let Y="";if(R&&(Y+=`<div style="border-top:1px solid ${F};margin-bottom:14px;width:100%;font-size:0;line-height:0;">&nbsp;</div>`),a&&s.trim()){const t="left"===B?"left":"right"===B?"right":"center",e=`<img src="${me(s)}" alt="${me(d)}" width="570" style="max-width:${m}%;height:auto;display:inline-block;padding:${p}px;vertical-align:middle;border:0;outline:none;text-decoration:none;"/>`,o=c(ce(u,n)),i=o?`<a href="${me(o)}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;line-height:0;display:inline-block;">${e}</a>`:e;Y+=`<div style="text-align:${me(t)};margin-bottom:10px;line-height:0;">${i}</div>`}if(r&&h.trim()&&(Y+=`<p style="${G}font-weight:600;margin:0 0 10px 0;">${me(h)}</p>`),l&&$&&(Y+=`<p style="${G}margin:0 0 10px 0;opacity:0.92;">${me($)}</p>`),g&&x.trim()&&(Y+=`<p style="${G}margin:0 0 10px 0;">${me(x)}</p>`),y){const t=Array.isArray(A)?A.filter(Boolean):[];if(t.length>0){const e=Wt.medium,o=t.map(t=>{const o=c(ce(t.linkURL,n),{allowMailtoTel:!1}),{src:i,styleAttr:r}=Xt(t,"default",e),l=`<img src="${me(i)}" alt="" width="${e}" height="${e}" style="${r}" border="0"/>`,a="text-decoration:none;display:inline-block;vertical-align:middle;line-height:0;margin:0 6px;";return o?`<a href="${me(o)}" target="_blank" rel="noopener noreferrer" style="${a}">${l}</a>`:`<span style="${a}">${l}</span>`}).join(""),i="left"===B?"left":"right"===B?"right":"center";Y+=`<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;border-collapse:collapse;margin-bottom:10px;"><tr><td align="${i}" style="text-align:${i};font-size:0;line-height:0;">${o}</td></tr></table>`}}if(f){const t=me(se(w,n)),e=me(se(C,n)),o=me(c(ce(S,n)));let i=`<p style="${G}margin:0 0 10px 0;word-break:break-word;">`;t&&(i+=`${t} `),i+=`<a href="${o}" style="${J}">${e}</a>`,i+="</p>",Y+=i}if(b&&_.length>0){let t=`<p style="${G}margin:0 0 10px 0;word-break:break-word;">`;_.forEach((e,o)=>{o>0&&(t+='<span style="padding:0 6px;">·</span>');const i=me(se(e.label,n)),r=me(c(ce(e.url,n))),l="_blank"===e.target?' target="_blank" rel="noopener noreferrer"':"";t+=`<a href="${r}" style="${J}"${l}>${i||`#${o+1}`}</a>`}),t+="</p>",Y+=t}if(k&&v.trim()){const t=Math.max(10,T-1);Y+=`<p style="${G}font-size:${t}px;margin:0;opacity:0.9;">${me(v)}</p>`}var q;return Z.push(`<td${H} style="width:${K};${V}">${q=Y,`<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%" style="width:100%;"><tr><td align="${me(B)}" style="${G}text-align:${me(B)};background-color:${me(M)};padding:${I}px ${U}px ${N}px ${E}px;${O?`border-top:${O};`:""}">${q}</td></tr></table>`}</td>`),Z.join("")}function fe(t){if(null==t)return"";const e=String(t).trim().toLowerCase();return/^#[0-9a-f]{3}$/.test(e)?`#${e[1]}${e[1]}${e[2]}${e[2]}${e[3]}${e[3]}`:e}const ye=new Set(["fontWeight","opacity","zIndex"]),be=t=>String(t??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),ke=t=>be(t).replace(/"/g,"&quot;").replace(/'/g,"&#39;"),he=(t,e="#")=>{if(null==t)return e;const n=String(t).trim();if(!n)return e;const o=n.toLowerCase();return/^\s*(?:javascript|vbscript):/i.test(o)||/^\s*data:/i.test(o)?e:/^https?:\/\//i.test(n)||/^mailto:/i.test(n)||/^tel:/i.test(n)?n:n.startsWith("//")?`https:${n}`:/^[a-z][a-z\d+.-]*:/i.test(n)?n:`https://${n.replace(/^\/+/,"")}`},$e=(t,e)=>{const n=new RegExp(/[A-Z]/g),o=t=>t.replace(n,t=>`-${t.toLowerCase()}`),i={desktop:e?.desktop??{},mobile:e?.mobile??{}};let r={className:t,desktop:"",mobile:""};for(let t of Object.entries(i.desktop))if(t[1]&&"contentBackground"!==t[0]&&"horizontalAlign"!==t[0]&&"containerBackgroundImage"!==t[0]&&"containerBackgroundSize"!==t[0]&&"containerBackgroundPosition"!==t[0]){const e="number"!=typeof t[1]||ye.has(t[0])?t[1]:t[1]+"px";r.desktop+=`${o(t[0])}:${e};`}if(Object.keys(i.mobile).length){let e="";for(let t of Object.entries(i.mobile))if(t[1]&&"contentBackground"!==t[0]&&"horizontalAlign"!==t[0]&&"containerBackgroundImage"!==t[0]&&"containerBackgroundSize"!==t[0]&&"containerBackgroundPosition"!==t[0]){const n="number"!=typeof t[1]||ye.has(t[0])?t[1]:t[1]+"px";e+=`${o(t[0])}:${n} !important;`}r.mobile+=`@media(max-width:620px){\n .${t} {\n ${e}\n }\n }`}return r};function xe(t){if(!t||"object"!=typeof t)return{};const{marginLeft:e,marginTop:n,...o}=t;return o}function ve(t){const e=zt(t||{}),{linkColor:n,color:o,...i}=e,r=null!=n&&""!==String(n).trim()?String(n).trim():null,l=null!=o&&""!==String(o).trim()?String(o).trim():null,a=r??l;return null==a?i:{...i,color:a}}const Se=(t,e="",n=null)=>{const o=t.map((t,o)=>{let i={...t};const r=null!==n?`${n}-${o}`:`${o}`,l=t=>`e${r}-${t}`,a={desktop:t?.styles?.desktop??{},mobile:t?.styles?.mobile??{}},s="menu"===t.key?{desktop:ve(a.desktop),mobile:ve(a.mobile)}:"social_link"===t.key?{desktop:zt(a.desktop),mobile:zt(a.mobile)}:a;if(i.styleConfig=$e(l(t.key),s),i.contentStyles){const n={desktop:i.contentStyles?.desktop??{},mobile:i.contentStyles?.mobile??{}};let o=n;if(i.imageHostMarginStyleConfig=null,"image"===i.key){o={desktop:xe(n.desktop),mobile:xe(n.mobile)};const r={desktop:(n.desktop,{}),mobile:(n.mobile,{})};if(Object.keys(r.desktop).length||Object.keys(r.mobile).length){const n=$e(l(`${t.key}-hm`),r);i.imageHostMarginStyleConfig=n,n.mobile&&(e+=n.mobile)}}i.contentStyleConfig=$e(l(`${t.key}-c`),o),i.contentStyleConfig.mobile&&(e+=i.contentStyleConfig.mobile)}if("video"===i.key&&i.videoArea){const n={desktop:i.videoArea?.desktop??{},mobile:i.videoArea?.mobile??{}};i.videoAreaStyleConfig=$e(l(`${t.key}-va`),n),i.videoAreaStyleConfig.mobile&&(e+=i.videoAreaStyleConfig.mobile)}if(i.styleConfig.mobile&&(e+=i.styleConfig.mobile),t.hiddenOnMobile){const t=`@media(max-width:620px){.${i.styleConfig.className}{display:none !important;}}`;e+=t,i.styleConfig={...i.styleConfig,mobile:(i.styleConfig.mobile||"")+t}}if(s.desktop.contentBackground&&(i.contentStyleConfig||(i.contentStyleConfig={className:l(`${t.key}-c`),desktop:"",mobile:""}),i.contentStyleConfig.desktop+=`background-color:${s.desktop.contentBackground};`),s.mobile.contentBackground){i.contentStyleConfig||(i.contentStyleConfig={className:l(`${t.key}-c`),desktop:"",mobile:""});const n=`@media(max-width:620px){.${i.contentStyleConfig.className}{background-color:${s.mobile.contentBackground};}}`;i.contentStyleConfig.mobile=(i.contentStyleConfig.mobile||"")+n,e+=n}if("menu"===i.key){if("stack"===(t.mobileLayout??"inline")){const n=i.contentStyleConfig?.className??l(`${t.key}-c`);i.contentStyleConfig||(i.contentStyleConfig={className:n,desktop:"",mobile:""});const o=i.contentStyles?.desktop?.textAlign??i.contentStyles?.mobile?.textAlign??"center",r=String(o).toLowerCase(),a="left"===r?"flex-start":"right"===r?"flex-end":"center",s=["left","right","center","justify"].includes(r)?r:"center",c=t.linkGapPx,d=`@media(max-width:620px){\n.${n}{display:flex !important;flex-direction:column !important;align-items:${a} !important;flex-wrap:nowrap !important;}\n.${n}>span{display:none !important;}\n.${n}>a{display:block !important;width:100% !important;box-sizing:border-box !important;text-align:${s} !important;margin:0 0 ${"number"==typeof c&&Number.isFinite(c)&&c>=0?c:0}px 0 !important;}\n.${n}>a:last-child{margin-bottom:0 !important;}\n}`;i.contentStyleConfig.mobile=(i.contentStyleConfig.mobile||"")+d,e+=d}}if(t.children?.length){const{newBlockList:n,styles:o}=Se(t.children,"",r);e+=o,i.children=n}return{...i}});return{newBlockList:o,styles:e}};function we(t){const e=t.contentStyleConfig?.desktop??"",n=function(t){const e=t.contentStyles?.desktop??{},n=t.contentStyles?.mobile??{},o=null!=e.textAlign&&""!==String(e.textAlign).trim()?e.textAlign:n.textAlign,i=null!=o&&""!==String(o).trim()?String(o).trim():"center";return"start"===i?"left":"end"===i?"right":i}(t);return/\btext-align\s*:/i.test(e)?e:`${e}text-align:${n};`}const Ce=(t,e,n={},o=null)=>{let i=t.src||"";const r="string"==typeof t.src&&/^\{\{\s*[\w.]+\s*\}\}$/.test(t.src.trim())?t.src.trim():"";if(e&&r){const t=It(e,r.replace(/^\{\{\s*|\s*\}\}$/g,""),n);t&&!/^\{\{\s*[\w.]+\s*\}\}$/.test(String(t).trim())&&(i=t)}i=te(i);const l=ke(i),a=ke(t.alt||"Image"),s=null!=t.linkURL?String(t.linkURL).trim():"",c=Array.isArray(t.overlayItems)?t.overlayItems:[],d=c.some(t=>""!==String(t?.text??"").trim()),u=String(t.overlayText??"").trim(),p=Boolean(t.textOverlayEnabled)&&(d||""!==u)&&i,g=`${t.styleConfig?.desktop||""};max-width:100%;display:inline-block;vertical-align:top;`;let f=`<img src="${l}" alt="${a}" style="${g}" ${t.styleConfig?.mobile?`class="${t.styleConfig.className}"`:""}/>`;if(p){const e=function(t){const e=ie(t);return oe[e]}(ie(t.overlayPosition)),n=Object.entries({position:"absolute",...e,"z-index":"2","max-width":`${"number"==typeof t.overlayMaxWidth?t.overlayMaxWidth:100}%`,"box-sizing":"border-box","pointer-events":"none"}).map(([t,e])=>`${t}:${e};`).join(""),i="number"==typeof t.overlayPadding?t.overlayPadding:16,r=t.textShadowEnabled?"text-shadow:0 1px 3px rgba(0,0,0,0.55);":"";let s="";if(d){const e="number"==typeof t.overlayItemGap?t.overlayItemGap:8,n=c.filter(t=>String(t?.text??"").trim()).map(t=>{const e="number"==typeof t.fontSize?t.fontSize:16,n=ke(t.color||"#ffffff"),i=(t=>{switch(t){case"h1":case"h2":case"h3":return"700";case"subtitle":case"eyebrow":return"600";default:return"400"}})(t.kind),l=null!=t.fontFamily&&""!==String(t.fontFamily).trim()?String(t.fontFamily).trim():String(o?.styles?.fontFamily||"sans-serif").trim()||"sans-serif",a=ke(l),s=be(String(t.text??""));return`<div style="color:${n};font-size:${e}px;font-weight:${i};line-height:1.35;font-family:${a};${r}">${s}</div>`});s=`<div style="display:flex;flex-direction:column;gap:${e}px;width:100%;padding:${i}px;">${n.join("")}</div>`}else{s=`<div style="color:${ke(t.overlayTextColor||"#ffffff")};font-size:${"number"==typeof t.overlayFontSize?t.overlayFontSize:18}px;font-weight:600;line-height:1.35;${t.overlayBoxBackground?`background-color:${ke(t.overlayBoxBackground)};padding:8px 12px;`:`padding:${i}px;`}${r}">${be(u)}</div>`}f=`<div style="position:relative;display:inline-block;vertical-align:top;max-width:100%;overflow:hidden;line-height:0;">\n ${t.scrimEnabled?'<div style="position:absolute;left:0;top:0;width:100%;height:100%;z-index:1;pointer-events:none;background:linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0.12), transparent 55%);"></div>':""}\n <img src="${l}" alt="${a}" style="${g}position:relative;z-index:0;border-radius:0;" ${t.styleConfig?.mobile?`class="${t.styleConfig.className}"`:""}/>\n <div style="${n}">\n ${s}\n </div>\n </div>`}const y=m(t)&&""!==s?`<a href="${ke(he(s))}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;display:inline-block;max-width:100%;">${f}</a>`:f,b=t.imageHostMarginStyleConfig,k=b&&(b.desktop||b.mobile)?`<div ${b.mobile?`class="${b.className}"`:""} style="display:inline-block;vertical-align:top;max-width:100%;${b.desktop||""}">${y}</div>`:y;return`<div ${t.contentStyleConfig.mobile?`class="${t.contentStyleConfig.className}"`:""} \n style="${we(t)}">\n ${k}\n </div>`};const _e="#2faade";function Ae(t){const e=String(t??"");return null!=(n=e)&&"string"==typeof n&&/<[a-zA-Z!/?]/.test(n.trim())?function(t){if(!t||!/<a\b/i.test(t))return t;const e=(t,e,n)=>{const o=(e[1]||"").replace(/\s*text-decoration(-line)?\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),i=(o?`${o}; `:"")+"text-decoration: none;",r='"'===n?` style="${i}"`:` style='${i}'`;return`<a${t.replace(e[0],r)}>`};return String(t).replace(/<a\b([^>]*)>/gi,(t,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o)return e(n,o,'"');const i=n.match(/\sstyle\s*=\s*'([^']*)'/i);return i?e(n,i,"'"):`<a${n} style="text-decoration: none;">`})}(e):be(e);var n}function Le(t){const e=t?.dynamicSelectedContent,n=t?.text??"";if(null==e)return String(n);const o=String(e);return""===o.trim()?String(n):o}const Pe=(t,e,n={})=>{let o=Le(t);e&&o&&(o=Ct(o,e,n));const i=t?.styles?.desktop??{},r=null!=i.linkColor&&""!==String(i.linkColor).trim();return o=Ut(o,r?String(i.linkColor).trim():_e,{useImportant:r}),`<${t.type} ${t.styleConfig?.mobile?`class="${t.styleConfig.className}"`:""} \n style="${t.styleConfig?.desktop||""}">\n ${o}\n </${t.type}>`};const Te=(t,e,n={},o=null)=>{let i=t.text||"",r=t.linkURL||"";if(e){const o=i.match(/\{\{(\w+)\}\}/),l=t.labelVariable?t.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():o?o[1]:void 0;if(l){const t=It(e,l,n);null==t||String(t).startsWith("{{")||(i=String(t))}if(t.urlVariable){const o=It(e,t.urlVariable.replace(/^\{\{|\}\}$/g,""),n);o&&!o.startsWith("{{")&&(r=String(o))}else{const t=String(r||"").trim().match(/^\{\{(\w+)\}\}$/);if(t){const o=It(e,t[1],n);o&&!String(o).startsWith("{{")&&(r=String(o))}}}const l=Ae(i),a=ke(he(r)),s=function(t){if(null==t||"object"!=typeof t)return"#111111";const e=t.brandContext,n=e&&"object"==typeof e?e.brand_color??e.brandColor??null:null,o=t.brandColor,i=("string"==typeof n&&""!==n.trim()?n:"string"==typeof o&&""!==o.trim()?o:null)??"#111111",r=String(i).trim();return""!==r?r:"#111111"}(e);let c=t.styleConfig.desktop||"";var d;!function(t,e){if(!function(t){return!(!t||"column"!==t.key||"product"!==t.containerType)&&"additional"!==t.productRole&&("image_left"===t.mainProductLayout||"image_stacked"!==t.mainProductLayout&&function(t){const e=t?.children?.[0]?.children?.[0];return"column"===e?.key&&"2-3"===e?.type}(t))}(e))return!1;const n=t.styles?.desktop?.backgroundColor;return null==n||""===String(n).trim()||fe(n)===fe("#111827")}(t,o)?(d=t.styles?.desktop?.backgroundColor,fe(d)===fe("#263d2d")&&(c=c.replace(/background-color:\s*[^;]+;?/gi,""))):c=c.replace(/background-color:\s*[^;]+;?/gi,"");const u=c.includes("background-color:")?"":`background-color:${s};`,m=c.includes("box-sizing")?"":"box-sizing:border-box;";return`<div ${t.contentStyleConfig.mobile?`class="${t.contentStyleConfig.className}"`:""}\n style="${t.contentStyleConfig.desktop}">\n <a ${t.styleConfig.mobile?`class="${t.styleConfig.className}"`:""}\n style="${c}${u}${m}text-align:center;text-decoration:none;" target="_blank" rel="noopener noreferrer" href="${a}">${l}</a>\n </div>`};const Be=t=>{const e=Array.isArray(t.list)?t.list.filter(Boolean):[];if(0===e.length)return"";const n=Boolean(t.showTextLabel),o=function(t){const e=t?.iconSize;if(e&&null!=Wt[e])return Wt[e];const n=Number(t?.imageWidth);return Number.isFinite(n)&&n>0?Math.round(n):Wt.medium}(t),i=Math.max(11,Math.round(.58*o)),r=function(t){const e="string"==typeof t?t:"gray";return jt.includes(e)?e:"default"}(t.iconColor),l=t?.contentStyles?.desktop??{},a=l.textAlign||"center",s="justify"===a,d="right"===a?"right":"left"===a?"left":"center",u=l.columnGapPx,m="number"==typeof u&&Number.isFinite(u)&&u>=0?u:8,p=Math.max(0,Math.round(m/2)),g=t.styleConfig?.desktop||"",f=t.styleConfig?.mobile?` class="${t.styleConfig.className}"`:"",y=(t,e="")=>{const{title:l,linkURL:a}=t,s=c(a,{allowMailtoTel:!1}),{src:d,styleAttr:u}=Xt(t,r,o),m=n?u.replace(/display:\s*block/i,"display:inline-block"):u,p=`<img src="${ke(d)}" alt="${ke(l)}" width="${o}" height="${o}" style="${ke(m)}" border="0"${f}/>`,y=Dt(t)?"X":String(l??""),b=n?`<span style="font-size:${i}px;line-height:1.2;color:#525252;font-family:inherit;white-space:nowrap;display:inline-block;vertical-align:middle;margin-left:6px;">${be(y)}</span>`:"",k=`text-decoration:none;display:inline-block;vertical-align:middle;line-height:0;${e}${g?`;${g}`:""}`;return s?`<a target="_blank" rel="noopener noreferrer" href="${ke(s)}" style="${k}">${p}${b}</a>`:`<span style="${k}">${p}${b}</span>`},b=`${t.contentStyleConfig?.desktop||""};text-align:${d};`,k=t.contentStyleConfig?.mobile?` class="${t.contentStyleConfig.className}"`:"";let h;if(s&&e.length>1){const t=(100/e.length).toFixed(4);h=`<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;border-collapse:collapse;"><tr>${e.map((n,o)=>{const i=0===o?"left":o===e.length-1?"right":"center";return`<td width="${t}%" style="width:${t}%;text-align:${i};vertical-align:middle;line-height:0;font-size:0;padding:0;">${y(n)}</td>`}).join("")}</tr></table>`}else h=e.map(t=>y(t,`margin:0 ${p}px;`)).join("");return`<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%" style="width:100%;border-collapse:collapse;"><tr><td${k} align="${d}" style="${b}">${h}</td></tr></table>`};const Ie=(t,e,n,o,i,r)=>{let l="";const a={columnIndex:i??0,columnProduct:o?.columnProducts?.[r??0]??null};return t.forEach((t,s)=>{if("column"===t.key){const a=function(t){const e={...t?.desktop??{}},n=t?.mobile??{},o=String(e.containerBackgroundImage??"").trim(),i=String(n.containerBackgroundImage??"").trim();!o&&i&&(e.containerBackgroundImage=n.containerBackgroundImage,null!=n.containerBackgroundSize&&(e.containerBackgroundSize=n.containerBackgroundSize),null!=n.containerBackgroundPosition&&(e.containerBackgroundPosition=n.containerBackgroundPosition),void 0!==n.containerBackgroundEnabled&&(e.containerBackgroundEnabled=n.containerBackgroundEnabled));const r=e.minHeight,l=n.minHeight;return null!=r&&""!==String(r).trim()||null==l||""===String(l).trim()||(e.minHeight=l),e}(t.styles),c=t.styles?.desktop?.borderRadius,d=c?`border-radius:${"number"==typeof c?c+"px":c};`:"",u=d?"overflow:hidden;":"",m=ee(a),p=function(t){if(null==t)return"";if("number"==typeof t&&Number.isFinite(t))return`min-height:${t}px;`;const e=String(t).trim();return e?/^\d+$/.test(e)?`min-height:${e}px;`:`min-height:${e};`:""}(a.minHeight),y=String(a.contentBackground??"").trim(),b=y&&"transparent"!==y.toLowerCase()?`background-color:${y};`:"",k=void 0!==r,h=f(e)||k?"100%":`${function(t){return g(t?.contentWidth)}(e)}px`,$=t.containerType&&"none"!==t.containerType?t:o,x=t.containerType&&"none"!==t.containerType?s:i,v=t.containerType&&"none"!==t.containerType?0:r,S="footer"===t.containerType&&t.footerUnifiedLayout?ge(t,t.children?.find(t=>"content"===t.key)??t.children?.[0]??null,n):Ie(t.children,e,n,$,x,v);if("discount"===t.containerType){const e=t.styles?.desktop??{},n=t=>"number"==typeof t?`${t}px`:String(t??""),o=[e.paddingTop?`padding-top:${n(e.paddingTop)};`:"",e.paddingRight?`padding-right:${n(e.paddingRight)};`:"",e.paddingBottom?`padding-bottom:${n(e.paddingBottom)};`:"",e.paddingLeft?`padding-left:${n(e.paddingLeft)};`:""].join(""),i=t.styleConfig.desktop.replace(/padding(?:-(?:top|right|bottom|left))?:[^;]+;?\s*/gi,""),r=o?`<tr><td style="${o}"><table role="presentation" cellpadding="0" cellspacing="0" border="0" style="width:100%;border-collapse:collapse;"><tbody><tr>${S}</tr></tbody></table></td></tr>`:`<tr>${S}</tr>`;l+=`<div ${t.styleConfig.mobile?`class="${t.styleConfig.className}"`:""}\n style="${i}width:100%;display:block;${u}">\n <table ${t.contentStyleConfig.mobile?`class="${t.contentStyleConfig.className}"`:""}\n style="width:100%;max-width:${h};margin:0 auto;${d}${t.contentStyleConfig?.desktop??""}${b}${m}${p}">\n <tbody>${r}</tbody>\n </table></div>`}else l+=`<div ${t.styleConfig.mobile?`class="${t.styleConfig.className}"`:""}\n style="${t.styleConfig.desktop}width:100%;display:block;${u}">\n <table ${t.contentStyleConfig.mobile?`class="${t.contentStyleConfig.className}"`:""}\n style="width:100%;max-width:${h};margin:0 auto;${d}${t.contentStyleConfig?.desktop??""}${b}${m}${p}">\n <tbody><tr>${S}</tr></tbody>\n </table></div>`}if("content"===t.key&&(l+=`<td ${t.styleConfig.mobile?`class="${t.styleConfig.className}"`:""} \n style="width:${t.width}; ${t.styleConfig.desktop}">${Ie(t.children,e,n,o,i,s)}</td>`),"text"===t.key){const e=null!=o?{columnIndex:i??0,columnProduct:o?.columnProducts?.[r??0]??null}:a;t.type&&/^h[1-4]$/.test(t.type)?l+=Pe(t,n,e):l+=((t,e,n={},o=null)=>{let i=Le(t);e&&i&&(i=Ct(i,e,n));const r=t?.styles?.desktop??{},l=null!=r.linkColor&&""!==String(r.linkColor).trim();i=Ut(i,l?String(r.linkColor).trim():_e,{useImportant:l});const a="footer"===o?.containerType,s=null==(c=i)||"string"!=typeof c?"":c.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();var c;return!a||""!==s&&"{{Address}}"!==s&&"{{Tagline}}"!==s?`<div ${t.styleConfig?.mobile?`class="${t.styleConfig.className}"`:""} \n style="${t.styleConfig?.desktop||""}">${i}</div>`:""})(t,n,e,o)}if("heading"===t.key&&(l+=Pe(t,n,a)),"image"===t.key){l+=Ce(t,n,null!=o?{columnIndex:i??0,columnProduct:o?.columnProducts?.[r??0]??null}:a,e)}if("video"===t.key&&(l+=(t=>{const e=null!=t.videoUrl?String(t.videoUrl).trim():"",n=function(t,e){const n="string"==typeof e?e.trim():"";if(n)return n;const o=function(t){if(!t||"string"!=typeof t)return null;const e=t.trim(),n=[/(?:youtube\.com\/watch\?[^#]*[&?]v=)([a-zA-Z0-9_-]{11})/,/youtube\.com\/watch\?v=([a-zA-Z0-9_-]{11})/,/youtu\.be\/([a-zA-Z0-9_-]{11})/,/youtube\.com\/embed\/([a-zA-Z0-9_-]{11})/,/youtube\.com\/shorts\/([a-zA-Z0-9_-]{11})/,/youtube-nocookie\.com\/embed\/([a-zA-Z0-9_-]{11})/];for(const t of n){const n=e.match(t);if(n?.[1])return n[1]}return null}(t||"");return o?`https://img.youtube.com/vi/${o}/hqdefault.jpg`:""}(e,null!=t.thumbnailUrl?String(t.thumbnailUrl).trim():""),o=e?he(e):"#",i=`${t.styleConfig?.desktop||""};max-width:100%;height:auto;display:block;border:0;`,r=t.contentStyleConfig?.desktop||"",l=t.videoAreaStyleConfig?.desktop||"";return`<div ${t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:""} style="${r}">\n <div ${t.videoAreaStyleConfig?.mobile?`class="${t.videoAreaStyleConfig.className}"`:""} style="${l}">\n ${n?`<a href="${ke(o)}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;display:inline-block;max-width:100%;line-height:0;"><img src="${ke(n)}" alt="${ke("Video")}" style="${i}"/></a>`:`<a href="${ke(o)}" target="_blank" rel="noopener noreferrer" style="display:inline-block;padding:14px 18px;background:#eeeeee;color:#333333;font-family:Arial,Helvetica,sans-serif;font-size:14px;font-weight:600;text-decoration:none;border-radius:4px;">Watch video</a>`}\n </div>\n</div>`})(t)),"button"===t.key){l+=Te(t,n,null!=o?{columnIndex:i??0,columnProduct:o?.columnProducts?.[r??0]??null}:a,o)}var c,d;"divider"===t.key&&(l+=`<div ${(c=t).contentStyleConfig.mobile?`class="${c.contentStyleConfig.className}"`:""} \n style="${c.contentStyleConfig.desktop}">\n <div ${c.styleConfig.mobile?`class="${c.styleConfig.className}"`:""} \n style="${c.styleConfig.desktop}"></div>\n </div>`),"spacer"===t.key&&(l+=(d=t,`<div ${d.contentStyleConfig?.mobile?`class="${d.contentStyleConfig.className}"`:""} \n style="${d.contentStyleConfig?.desktop||""}">\n <div ${d.styleConfig?.mobile?`class="${d.styleConfig.className}"`:""} \n style="${d.styleConfig?.desktop||""}"></div>\n </div>`)),"menu"===t.key&&(l+=(t=>{const e=t.list||[],n=null!=t.separator?String(t.separator):" | ",o=t.styleConfig?.desktop||"",i=t.contentStyleConfig?.desktop||"",r=t.linkGapPx,l="number"==typeof r&&Number.isFinite(r)&&r>=0?r:0,a=Boolean(t.linkUnderline),s=t.styles?.desktop??{},c=null!=s.fontSize&&Number.isFinite(Number(s.fontSize))?`${Number(s.fontSize)}px`:"14px",d=null!=s.color&&""!==String(s.color).trim()?String(s.color):"#333333";let u="";return e.forEach((t,e)=>{e>0&&(u+=`<span style="${l>0?`display:inline-block;margin-left:${l}px;margin-right:${l}px;font-size:${c};color:${d};`:`display:inline-block;padding-left:4px;padding-right:4px;font-size:${c};color:${d};`}">${be(n)}</span>`);const i=he(t.url,"#"),r="_blank"===t.target?"_blank":"_self",s=be(t.label||"Link"),m=a?"underline":"none";u+=`<a target="${r}" href="${ke(i)}" style="${o};text-decoration:${m};display:inline-block;">${s}</a>`}),`<div ${t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:""} style="${i}">${u}</div>`})(t)),"avatar"===t.key&&(l+=(t=>{const e=t.src||"",n=t.alt||"Avatar",o=t.linkURL,i=t.styleConfig?.desktop||"",r=t.styles?.desktop?.width??64,l=`max-width:100%;width:${"number"==typeof r?r+"px":r};height:${"number"==typeof r?r+"px":r};object-fit:cover;border-radius:${t.styles?.desktop?.borderRadius??"50%"};${i}`,a=ke(e),s=ke(n),c=e?`<img src="${a}" alt="${s}" style="${l}" />`:`<div style="${l};background:#eee;display:flex;align-items:center;justify-content:center;"></div>`,d=t.contentStyleConfig?.desktop||"",u=o?`<a href="${ke(he(o))}" target="_blank" rel="noopener noreferrer">${c}</a>`:c;return`<div ${t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:""} style="${d}">${u}</div>`})(t)),"social_link"===t.key&&(l+=Be(t)),"raw_html"===t.key&&(l+=(t=>{const e=function(t){const e=t.match(/<body[^>]*>([\s\S]*?)<\/body>/i);return e?e[1]:/<html[\s>]/i.test(t)||/<!DOCTYPE/i.test(t)?t.replace(/<!DOCTYPE[^>]*>/gi,"").replace(/<html[^>]*>/gi,"").replace(/<\/html>/gi,"").replace(/<head[\s\S]*?<\/head>/gi,"").replace(/<\/?body[^>]*>/gi,"").trim():t}(t.html??""),n=t.contentStyleConfig?.desktop??"",o=t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:"",i=t.contentStyles?.desktop??{},r=i.width,l=i.textAlign??"center";let a="";return null!=r&&"100%"!==String(r)&&"center"===l?a="margin-left:auto;margin-right:auto;":null!=r&&"100%"!==String(r)&&"right"===l?a="margin-left:auto;margin-right:0;":null==r||"100%"===String(r)||"left"!==l&&"justify"!==l||(a="margin-left:0;margin-right:auto;"),`<div ${o} style="${a}max-width:100%;${n}">${e}</div>`})(t)),"table"===t.key&&(l+=(t=>{const e=t.contentStyleConfig?.desktop||"",n=t.contentStyleConfig?.mobile?`class="${t.contentStyleConfig.className}"`:"",o=t.styles?.desktop??{},i="number"==typeof t.rows?t.rows:3,r="number"==typeof t.cols?t.cols:3,l=Boolean(t.headerRow),a=Boolean(t.headerCol),s=Boolean(t.stripedRows),c=o.fontSize??14,d=o.color??"#333333",u=o.borderStyle??"solid",m=o.borderWidth??1,p=o.borderColor??"#e0e0e0",g=o.cellPadding??8,f=o.textAlign??"left",y=o.headerBg??"#f5f5f5",b=o.headerColor??"#333333",k=o.stripedBg??"#fafafa",h="none"!==u?`${m}px ${u} ${p}`:"none",$=Array.from({length:i}).map((e,n)=>`<tr>${Array.from({length:r}).map((e,o)=>{const i=l&&0===n||a&&0===o,r=i?y:s&&!i&&n%2==0?k:"transparent",u=i?b:d,m=i?"600":"400",p=`${n}-${o}`,$=t.cells?.[p],x=l&&0===n||a&&0===o?"th":"td";let v="&#8212;";return"image"===$?.type&&String($.src??"").trim()?v=`<img src="${ke($.src)}" alt="${ke($.alt||"")}" style="max-width:100%;height:auto;display:block;border:0;"/>`:String($?.text??"").trim()&&(v=be(String($.text))),`<${x} style="border:${h};padding:${g}px;font-size:${c}px;color:${u};text-align:${f};background-color:${r};font-weight:${m};vertical-align:top;">${v}</${x}>`}).join("")}</tr>`).join("");return`<div ${n} style="${e}"><table role="presentation" style="${t.styleConfig?.desktop||""};border-collapse:collapse;width:100%;table-layout:auto;"><tbody>${$}</tbody></table></div>`})(t))}),l},Ue={preHeader:"",contentWidth:600,contentWidthMode:"email_width",stackColumnsOnMobile:!0,scaleFontOnMobile:!0,styles:{backgroundColor:"#F5F5F5",contentBg:"#FFFFFF",color:"#171717",headingColor:"#171717",linkColor:"#338AF3",fontFamily:"'Overused Grotesk', ui-sans-serif, system-ui, sans-serif"}},Ne=t=>Array.isArray(t)?t.filter(t=>!(t&&"object"==typeof t&&!0===t.hidden)).map(t=>t&&"object"==typeof t&&Array.isArray(t.children)?{...t,children:Ne(t.children)}:t):t,Ee=({bodySettings:t,blockList:e,templateData:n})=>{let o="";const i=((t,e)=>{if(!Array.isArray(t))return t;const n=e?.content?.products;if(!Array.isArray(n)||0===n.length)return t;const o=e?.content?.primaryProductId,i=(o?n.find(t=>t?.id===o):n[0])??n[0]??null;if(!i)return t;const r=n.filter(t=>t?.id!==i.id),l=t=>{if(!t||"object"!=typeof t)return t;const e=Array.isArray(t.children)?t.children.map(l):t.children;if("column"!==t.key||"product"!==t.containerType)return{...t,children:e};const n="additional"===t.productRole?"additional":"main",o=Math.max(Array.isArray(e)?e.length:0,Array.isArray(t.columnProducts)?t.columnProducts.length:0,1),a=Array.from({length:o},(t,e)=>"main"===n||0===r.length?i:r[e%r.length]);return{...t,children:e,columnProducts:a}};return t.map(l)})(Ne(e??[]),n),{newBlockList:r,styles:l}=Se(i);o=Ie(r,t,n);const a=Ft(i,t,n);return`<html>\n <head>\n <meta charset="UTF-8">\n <title>email</title>\n <meta name="viewport" content="width=device-width, initial-scale=1" />\n <style type="text/css">\n *{\n margin: 0;\n padding: 0;\n border: none;\n box-sizing: border-box;\n }\n\n html,body {\n height:100%;\n overflow-y:auto;\n }\n\n table {\n width: 100%;\n color:unset;\n }\n\n table, tr, td {\n vertical-align: top;\n border-collapse: collapse;\n }\n\n h1,h2,h3,h4 {\n display: block;\n margin-block-start: 0px;\n margin-block-end: 0px;\n margin-inline-start: 0px;\n margin-inline-end: 0px;\n font-weight: bold;\n ${t.styles?.headingColor?`color: ${t.styles.headingColor};`:""}\n }\n\n a {\n ${t.styles?.linkColor?`color: ${t.styles.linkColor};`:""}\n }\n\n @media(max-width:620px){\n${!1!==t.stackColumnsOnMobile?" td {\n display:inline-block;\n width:100% !important;\n }\n":""}${!1!==t.scaleFontOnMobile?" body { font-size: 16px !important; }\n":""} }\n ${a}\n ${l}\n</style>\n </head>\n <body>\n <div style="opacity:0;">${t.preHeader}</div>\n <div style="background-color:${t.styles.backgroundColor};color:${t.styles.color}; font-family:${t.styles.fontFamily};"> ${o}</div>\n </body>\n </html>`};function Me(t){let e=t;if("string"==typeof t)try{e=JSON.parse(t)}catch(t){throw new Error("exportNormalizerToHtml: invalid JSON")}if(null==e)throw new Error("exportNormalizerToHtml: input is null or undefined");let n=[],o={...Ue,styles:{...Ue.styles}};Array.isArray(e)?n=e:"object"==typeof e&&(n=Array.isArray(e.blockList)?e.blockList:[],e.bodySettings&&"object"==typeof e.bodySettings&&(o={preHeader:null!=e.bodySettings.preHeader?e.bodySettings.preHeader:Ue.preHeader,contentWidth:g(e.bodySettings.contentWidth??Ue.contentWidth),contentWidthMode:e.bodySettings.contentWidthMode??Ue.contentWidthMode,stackColumnsOnMobile:!1!==e.bodySettings.stackColumnsOnMobile,scaleFontOnMobile:!1!==e.bodySettings.scaleFontOnMobile,styles:{backgroundColor:e.bodySettings.styles?.backgroundColor??Ue.styles.backgroundColor,contentBg:e.bodySettings.styles?.contentBg??Ue.styles.contentBg,color:e.bodySettings.styles?.color??Ue.styles.color,headingColor:e.bodySettings.styles?.headingColor??Ue.styles.headingColor,linkColor:e.bodySettings.styles?.linkColor??Ue.styles.linkColor,fontFamily:e.bodySettings.styles?.fontFamily??Ue.styles.fontFamily}}));return`<!DOCTYPE html>\n${function(t){return t.replace(/\n/g," ").replace(/[ \t]{2,}/g," ").replace(/> </g,"><").trim()}(Ee({bodySettings:o,blockList:n,templateData:e.templateData}))}`}const Re=Object.freeze({keys:["content","catalogProducts","companyContext","brandContext","companyId"],description:"templateData drives placeholders, product columns, and menu/social sync. content.products + content.primaryProductId, when non-empty, override product column assignments on load. catalogProducts (optional array) is the KB/catalog list for the product picker and for newly added preset product blocks; it does not replace columnProducts in a saved template when content.products is empty. companyContext.navigation_links and companyContext.social_links sync into menu/social blocks; brandContext (including brand_color) resolves branding tokens and CTA/button fallback colors in HTML export."});const Fe=["Product","Discount"],De=["text","image","button"];function je(t,e,n,o,i,r,l){if("column"===t.key&&t.containerType){const e=function(t){const e=t.toLowerCase();return"product"===e?"Product":"discount"===e?"Discount":"None"}(t.containerType),n=t.id??null;let a=o;"Product"===e&&(l.productIndex++,a=l.productIndex);for(const o of t.children??[])je(o,e,n,a,i,r,l);return}if("content"===t.key){for(const a of t.children??[])je(a,e,n,o,i,r,l);return}const a="dynamic"===t.contentType,s=Fe.includes(e)&&De.includes(t.key);if((a||s)&&n){let l=i.find(t=>t.containerId===n);l||(l={containerId:n,containerType:e,blocks:[]},i.push(l));const c=t.id?r[t.id]:void 0,d=function(t){return"image"===t.key?t.src??"":"button"===t.key?t.linkURL??"":t.text??""}(t);let u="";"Product"===e?u=function(t,e){const n=`product ${e}`;return t.includes("{{ProductImage}}")?`This block is meant for displaying the ${n} image`:t.includes("{{ProductName}}")?`This block is meant for displaying the ${n} name`:t.includes("{{ProductOldPrice}}")||t.includes("{{ProductNewPrice}}")?`This block is meant for displaying the ${n} original and discounted price`:t.includes("{{ProductPrice}}")||t.includes("{{ProductCurrency}}")?`This block is meant for displaying the ${n} price and currency`:t.includes("{{ProductDescription}}")?`This block is meant for displaying the ${n} description`:t.includes("{{ProductLink}}")?`This block is meant for displaying the ${n} link`:`This block is meant for displaying ${n} content`}(d,o):"Discount"===e&&(u=function(t){const e=[];return t.includes("{{DiscountValue}}")&&e.push("the discount value (e.g. 20% or $10)"),t.includes("{{DiscountCode}}")&&e.push("the discount/promo code"),t.includes("{{ValidUntil}}")&&e.push("the discount expiry date"),0===e.length?"This block is meant for displaying discount/offer information":`This block is meant for displaying ${e.join(", ")}`}(d));const m=c?.prompt||u,p=s&&!a;l.blocks.push({id:t.id??"",contentType:p||"dynamic"===t.contentType?"dynamic":"static",value:p?"":d,ai:{prompt:m,selectedSampleAiContent:p?"":c?.selectedContent??d}})}if(t.children)for(const a of t.children)je(a,e,n,o,i,r,l)}const ze={text:"text",image:"src",button:"linkURL"};function We(t,e){if(0===e.size)return!0;if(t.id&&e.has(t.id)){const n=e.get(t.id),o=ze[t.key];o&&(t[o]=n,e.delete(t.id))}if(t.children)for(const n of t.children)if(We(n,e))return!0;return 0===e.size}var Oe=Object.freeze({__proto__:null,jsonToHtml:function(t){return Me(t)},normalizeJson:function(t){const e="string"==typeof t?JSON.parse(t):t,n=[],o=e.aiContentRefs||{},i={productIndex:0},r=e.blockList||[];for(const t of r)je(t,"None",null,0,n,o,i);return{groups:n}},updateJsonWithMlContent:function(t,e){const n="string"==typeof t?JSON.parse(t):t,o=structuredClone(n),i=new Map;for(const t of e)t.variations.length>0&&i.set(t.nodeId,t.variations[0].value);const r=o.blockList||[];for(const t of r)if(We(t,i))break;return o}});exports.DEFAULT_EMAIL_CONTENT_API_BASE_V2=n,exports.DEFAULT_EMAIL_TEMPLATE_ID=o,exports.DEFAULT_MARKOPOLO_API_BASE_V1=t,exports.DEFAULT_ML_GENERATION_API_BASE_V1=e,exports.TEMPLATE_DATA_SCHEMA=Re,exports.createDefaultTemplateData=function(t={}){const e={name:"",website:"",navigation_links:[],social_links:{}},n={brand_color:"#111111",logo_url:"",tagline:"",heroBanner:"",footerBanner:""},o=null;return{content:{...{products:[],primaryProductId:null},...t.content&&"object"==typeof t.content?t.content:{}},companyContext:{...e,...t.companyContext&&"object"==typeof t.companyContext?t.companyContext:{}},brandContext:{...n,..."string"==typeof t.brandColor&&t.brandColor.trim()?{brand_color:t.brandColor.trim()}:{},...t.brandContext&&"object"==typeof t.brandContext?t.brandContext:{}},companyId:null!=t.companyId?t.companyId:o}},exports.exportNormalizerToHtml=Me,exports.exportTemplateJson=function(t,e={}){const{validate:n=!0}=e,o=t?.current;if(!o||"function"!=typeof o.exportJson)throw new Error("exportTemplateJson: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const i=o.exportJson();if(!i||"object"!=typeof i)throw new Error("exportTemplateJson: exportJson() returned an invalid payload.");return{payload:i,issues:n?M({blockList:i.blockList,bodySettings:i.bodySettings,aiContentRefs:i.aiContentRefs}):[]}},exports.exportTemplateJsonAsync=async function(t,e={}){const{validate:n=!0,checkImages:o=!0,imageProbe:i}=e,r=t?.current;if(!r||"function"!=typeof r.exportJson)throw new Error("exportTemplateJsonAsync: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const l=r.exportJson();if(!l||"object"!=typeof l)throw new Error("exportTemplateJsonAsync: exportJson() returned an invalid payload.");return n?{payload:l,issues:o?await O({blockList:l.blockList,bodySettings:l.bodySettings,aiContentRefs:l.aiContentRefs},i):M({blockList:l.blockList,bodySettings:l.bodySettings,aiContentRefs:l.aiContentRefs})}:{payload:l,issues:[]}},exports.mergeMarkopoloApiConfig=function(l={}){const a=l&&"object"==typeof l?l:{},{apiBaseUrlV1:s,apiBaseV1:c,emailContentApiBaseUrlV2:d,contentApiBaseUrlV2:u,mlGenerationApiBaseUrlV1:m,mlApiBaseUrlV1:p,headers:g,mlEmailGenerateBnEndpoint:f,...y}=a,b=s||c||t,k=i(()=>process.env.REACT_APP_ML_API_BASE_V1),h=r(b,m||p||k||e),$=i(()=>process.env.REACT_APP_EMAIL_CONTENT_API_BASE_V2),x=function(t,e){if(t&&String(t).trim())return String(t).trim().replace(/\/$/,"");{const t=e.replace(/\/$/,"");if(/\/v1$/i.test(t))return t.replace(/\/v1$/i,"/v2")}return n}(d||u||$,b),v=String(i(()=>process.env.REACT_APP_EMAIL_TEMPLATE_ID)??"").trim(),S={...h,...y};S.mlEmailGenerateEndpoint&&String(S.mlEmailGenerateEndpoint).trim()||!f||(S.mlEmailGenerateEndpoint=String(f).replace(/\/generate-email\/bn\/?$/i,"/generate-email"));const w=String(S.emailTemplateId??"").trim()||v||o;return{...S,emailTemplateId:w,emailContentApiBaseUrlV2:x,headers:{...S.headers||{},...g||{}}}},exports.utils=Oe,exports.validateExportPayload=M,exports.validateExportPayloadComplete=O,exports.validateImageUrlsReachable=W,exports.validateTemplateDataShape=function(t){const e=[];if(null==t||"object"!=typeof t)return{ok:!1,warnings:["templateData must be a non-null object"]};const n=t;if(null!=n.content&&"object"!=typeof n.content)e.push("templateData.content should be an object when provided");else if(n.content&&"object"==typeof n.content){const t=n.content;null==t.products||Array.isArray(t.products)||e.push("templateData.content.products should be an array when provided")}if(null==n.catalogProducts||Array.isArray(n.catalogProducts)||e.push("templateData.catalogProducts should be an array when provided"),null!=n.companyContext&&"object"!=typeof n.companyContext&&e.push("templateData.companyContext should be an object when provided"),null!=n.brandContext&&"object"!=typeof n.brandContext&&e.push("templateData.brandContext should be an object when provided"),n.brandContext&&"object"==typeof n.brandContext){const t=n.brandContext;null!=t.brand_color&&"string"!=typeof t.brand_color&&e.push("templateData.brandContext.brand_color should be a string when provided")}return{ok:0===e.length,warnings:e}};