@markopolo_ai_inc/markopolo-email-editor 1.0.41 → 1.0.42

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/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("antd"),n=require("@fortawesome/react-fontawesome"),o=require("@fortawesome/free-solid-svg-icons"),a=require("framer-motion"),l=require("react/jsx-runtime"),i=require("react-dom"),r=require("react-color"),s=require("classnames");function c(e){const t=String(e??"").trim();return/^(?:javascript|vbscript)\s*:/i.test(t)||/^data\s*:/i.test(t)}function d(e){let t=String(e??"").trim();if(!t)return"";if(c(t))return"";for(let e=0;e<t.length;e++){const n=t.charCodeAt(e),o=t[e];if(n<32||"<"===o||">"===o||'"'===o)return""}return t}function u(e){const t=String(e??"").trim().match(/^https?:\/\/(.+)/is);return!!t&&/^https?:\/\//i.test(t[1])}function m(e,t={}){const{allowMailtoTel:n=!0}=t,o=String(e??"").trim();if(!o)return null;if(c(o))return null;if(u(o))return null;if(n&&(/^mailto:/i.test(o)||/^tel:/i.test(o)))return o;const a=/^https?:\/\//i.test(o)?o:`https://${o.replace(/^\/+/,"")}`;return p(a,!1,t)?a:null}function p(e,t=!1,n={}){return null==g(e,t,n)}function g(e,t=!1,n={}){const{allowMailtoTel:o=!0}=n;if(null==e||""===String(e).trim())return t?null:"empty";const a=String(e).trim();if(c(a))return"blocked_scheme";if(u(a))return"duplicate_protocol";let l;if(/^https?:\/\//i.test(a)){const e=a.replace(/^https?:\/\//i,"");if(/^https?:\/\//i.test(e))return"duplicate_protocol";l=a}else l=o&&/^mailto:/i.test(a)||o&&/^tel:/i.test(a)?a:`https://${a}`;try{const e=new URL(l);return"http:"===e.protocol||"https:"===e.protocol?function(e){const t=String(e??"").trim().toLowerCase();return""!==t&&"http"!==t&&"https"!==t&&("localhost"===t||!!t.includes(":")||!!/^(?:\d{1,3}\.){3}\d{1,3}$/.test(t)||t.includes("."))}(e.hostname)?null:"missing_hostname_dot":o&&"mailto:"===e.protocol||o&&"tel:"===e.protocol?null:"invalid_protocol"}catch{return"invalid_url"}}const h="https://s.magecdn.com/social",b=[{key:"facebook",image:`${h}/tc-facebook.svg`,title:"Facebook"},{key:"twitter",image:`${h}/tc-x.svg`,title:"X"},{key:"instagram",image:`${h}/tc-instagram.svg`,title:"Instagram"},{key:"linkedin",image:`${h}/tc-linkedin.svg`,title:"LinkedIn"},{key:"tiktok",image:`${h}/tc-tiktok.svg`,title:"TikTok"},{key:"youtube",image:`${h}/tc-youtube.svg`,title:"YouTube"}];function y(e){return Array.isArray(e)?e.filter(e=>e&&null!=e.linkURL&&""!==String(e.linkURL).trim()):[]}function _(e,t){if(!e||!t)return e;const n=t?.companyContext?.navigation_links,o=Array.isArray(n)&&n.length>0,a=t?.companyContext?.social_links,l=!(!a||"object"!=typeof a)&&function(e){return!(!e||"object"!=typeof e)&&Object.values(e).some(e=>null!=e&&""!==String(e).trim())}(a),i=Object.values(e).some(e=>e&&"social_link"===e.key&&e.useCompanySocialLinks);if(!o&&!i)return e;const r={...e};let s=!1;return Object.keys(e).forEach(t=>{const i=e[t];if(i){if("menu"===i.key&&!1!==i.useNavigationLinks&&o){const e=n.map(e=>function(e){if(!e||"object"!=typeof e)return{label:"Link",url:"#",target:"_self"};const t=e.label??e.name??e.title??"Link",n="string"==typeof t?t:null!=t?String(t):"Link",o=e.url??e.href??e.link??e.uri??"";return{label:n||"Link",url:("string"==typeof o?o.trim():null!=o?String(o).trim():"")||"#",target:"_blank"===e.target||"_self"===e.target?e.target:"_self"}}(e));r[t]={...i,list:e},s=!0}if("social_link"===i.key&&i.useCompanySocialLinks){const e=l?function(e){if(!e||"object"!=typeof e)return[];const t=[];for(const n of b){const o=e[n.key],a=null!=o?String(o).trim():"";a&&t.push({image:n.image,title:n.title,linkURL:d(a)})}return t}(a):[];r[t]={...i,list:e},s=!0}}}),s?r:e}const f=280,x=1200,k={EMAIL_WIDTH:"email_width",CUSTOM_PX:"custom_px",FULL_BLEED:"full_bleed"};function v(e){const t=Math.round(Number(e));return!Number.isFinite(t)||t<=0?600:Math.min(x,Math.max(f,t))}function w(e){const t=e?.contentWidthMode;return Object.values(k).includes(t)?t:k.EMAIL_WIDTH}function j(e){return v(e?.contentWidth)}function S(e){return w(e)===k.FULL_BLEED}const C=e=>{const t=e.constructor===Array?[]:{};for(let n in e)e.hasOwnProperty(n)&&(e[n]&&"object"==typeof e[n]?(t[n]=e[n].constructor===Array?[]:{},t[n]=C(e[n])):t[n]=e[n]);return t},N=(e,t)=>{let n=null;return function(){n||(n=setTimeout(()=>{e.apply(this,arguments),n=null},t))}};function I(e,t={}){if(null==e||"string"!=typeof e)return e;const n=null!=t.fontSize?Number(t.fontSize):14,o=null!=t.fontFamily?String(t.fontFamily):"sans-serif",a=null!=t.color?String(t.color):"",l=["direction: ltr",`font-size: ${n}px`,`font-family: ${o}`];a&&l.push(`color: ${a}`);const i=t.fontWeight;null!=i&&""!==String(i).trim()&&l.push(`font-weight: ${i}`);const r=t.fontStretch;null!=r&&""!==String(r).trim()&&"normal"!==String(r).toLowerCase()&&l.push(`font-stretch: ${r}`);const s=t.textTransform;null!=s&&""!==String(s).trim()&&"none"!==String(s).toLowerCase()&&l.push(`text-transform: ${s}`);const c=l.join("; ");let d=function(e){if(null==e||"string"!=typeof e)return e;let t=e.replace(/\sstyle\s*=\s*["']([^"']*)["']/gi,(e,t)=>{const n=t.replace(/\s*font-size\s*:[^;]+;?/gi,"").replace(/\s*font-family\s*:[^;]+;?/gi,"").replace(/\s*color\s*:[^;]+;?/gi,"").replace(/^;\s*|;\s*$/g,"").trim();return n?` style="${n}"`:""}),n="";for(let e=0;e<20&&n!==t;e++)n=t,t=t.replace(/<font(\s[^>]*)?>([\s\S]*?)<\/font>/gi,"$2");return t}(e.trim());const u=/^<span(?:\s[^>]*)?>([\s\S]*)<\/span>$/i.exec(d.trim()),m=/^<div(?:\s[^>]*)?>([\s\S]*)<\/div>$/i.exec(d.trim());return u?d=u[1]:m&&(d=m[1]),`<span style="${c}">${d}</span>`}function A(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function T(e){if(!e||"object"!=typeof e)return;e.id||(e.id=A());const t=e.children;Array.isArray(t)&&t.forEach(T)}function L(e){if(!e||"object"!=typeof e)return;e.id=A();const t=e.children;Array.isArray(t)&&t.forEach(L)}function B(e){if(!e||"object"!=typeof e)return e;const t=C(e);return L(t),t}function $(e="Drag block here",t){return{id:t||A(),name:e,key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}}function R(e){const t={},n=[];function o(e){if(e&&"object"==typeof e)if(e.id||(e.id=A()),"column"===e.key){const n=(e.children||[]).map(e=>{e.id||(e.id=A());const t=[];return(e.children||[]).forEach(e=>{e.id||(e.id=A()),o(e),t.push(e.id)}),{id:e.id,width:e.width,styles:e.styles,childrenIds:t}}),{children:a,...l}=e;t[e.id]={...l,cells:n}}else t[e.id]=e}return(e||[]).forEach(e=>{e.id||(e.id=A()),o(e),n.push(e.id)}),{blockMap:t,rootOrder:n}}function M(e,t){function n(t){const o=e[t];if(!o)return null;if("column"===o.key){const e=(o.cells||[]).map(e=>({id:e.id,name:"Content",key:"content",width:e.width,styles:e.styles,children:(e.childrenIds||[]).map(e=>n(e)).filter(Boolean)})),{cells:t,...a}=o;return{...a,children:e}}return{...o}}return(t||[]).map(e=>n(e)).filter(Boolean)}function P(e,t){const n=t[e];if(!n)return null;if("column"!==n.key)return n;const o=(n.cells||[]).map(e=>({id:e.id,name:"Content",key:"content",width:e.width,styles:e.styles,children:(e.childrenIds||[]).map(e=>{const n=t[e];return n?"column"===n.key?P(e,t):n:null}).filter(Boolean)})),{cells:a,...l}=n;return{...l,children:o}}function F(e,t,n){function o(t){const a=e[t];if(!a||"column"!==a.key)return null;for(let l=0;l<(a.cells||[]).length;l++){const i=a.cells[l];for(let a=0;a<(i.childrenIds||[]).length;a++){if(i.childrenIds[a]===n)return{containerId:t,cellIndex:l,itemIndex:a};const r=e[i.childrenIds[a]];if(r&&"column"===r.key){const e=o(i.childrenIds[a]);if(e)return e}}}return null}for(const e of t||[]){const t=o(e);if(t)return t}return null}function E(e,t,n){const o=(t||[]).indexOf(n);if(-1!==o){const t=e[n];return[{containerBlock:t??null,containerType:t?.containerType??"none",cellIndex:0,isRoot:!0,rootIndex:o}]}function a(t,o=[]){const l=e[t];if(!l||"column"!==l.key)return null;for(let t=0;t<(l.cells||[]).length;t++){const i=l.cells[t];for(let r=0;r<(i.childrenIds||[]).length;r++){const s=i.childrenIds[r];if(s===n)return[{containerBlock:l,containerType:l?.containerType??"none",cellIndex:t,isRoot:!1},...o];const c=e[s];if(c&&"column"===c.key){const e=a(s,[{containerBlock:l,containerType:l?.containerType??"none",cellIndex:t,isRoot:!1},...o]);if(e)return e}}}return null}for(const e of t||[]){const t=a(e,[]);if(t)return t}return[]}function D(e,t,n){const o=E(e,t,n),a=o.find(e=>e?.containerType&&"none"!==e.containerType)||o[0]||null,l=a?.cellIndex??0,i=a?.containerBlock??null,r=i?.columnProducts?.[l]??null,s=Array.isArray(i?.columnProducts)?i.columnProducts.find(e=>null!=e)??null:null;return{containerType:a?.containerType??"none",columnIndex:l,columnProduct:r??s,containerBlock:i,lineage:o}}function U(e,t,n,o,a){const l=e[t];if(!l)return e;const i=l.cells.map((e,t)=>{if(t!==n)return e;const l=[...e.childrenIds];return l[o]=a,{...e,childrenIds:l}});return{...e,[t]:{...l,cells:i}}}function z(e,t,n,o){const a=e[t];if(!a)return{blockMap:e,removedId:null};const l=a.cells[n];if(!l)return{blockMap:e,removedId:null};const i=l.childrenIds[o],r=[...l.childrenIds];r.splice(o,1);const s=a.cells.map((e,t)=>t===n?{...e,childrenIds:r}:e);return{blockMap:{...e,[t]:{...a,cells:s}},removedId:i}}function O(e,t,n,o,a){const l=e[t];if(!l)return e;const i=l.cells[n];if(!i)return e;const r=[...i.childrenIds];r.splice(o,0,a);const s=l.cells.map((e,t)=>t===n?{...e,childrenIds:r}:e);return{...e,[t]:{...l,cells:s}}}function W(e,t,n,o){if(!n||!e[n]||0===o)return null;const a=t.indexOf(n);if(-1!==a){const n=a+o;if(n<0||n>=t.length)return null;const l=[...t],[i]=l.splice(a,1);return l.splice(n,0,i),{nextMap:e,nextRootOrder:l}}const l=F(e,t,n);if(!l)return null;const{containerId:i,cellIndex:r,itemIndex:s}=l,c=e[i],d=[...c.cells[r].childrenIds],u=s+o;if(u<0||u>=d.length)return null;const[m]=d.splice(s,1);d.splice(u,0,m);const p=c.cells.map((e,t)=>t===r?{...e,childrenIds:d}:e);return{nextMap:{...e,[i]:{...c,cells:p}},nextRootOrder:t}}function H(e,t){const n={...e};return function e(t){const o=n[t];o&&("column"===o.key&&(o.cells||[]).forEach(t=>(t.childrenIds||[]).forEach(t=>e(t))),delete n[t])}(t),n}function V(e,t={}){if(!e||"column"!==e.key||!Array.isArray(e.cells))return null;const n=(o=t)&&"object"==typeof o?Array.isArray(o)?o.reduce((e,t)=>(t&&"object"==typeof t&&t.id&&(e[t.id]=t),e),{}):{...o}:{};var o;const a=C(e);delete a.children,delete a.blockMap,delete a.blockSnapshotMap;const l={...n,[a.id]:a};function i(e){e&&!l[e]&&(l[e]=$("…",e))}return function e(t){if(t&&"column"===t.key&&Array.isArray(t.cells))for(const n of t.cells)for(const t of n.childrenIds||[]){i(t);const n=l[t];n&&"column"===n.key&&e(n)}}(a),{blockMap:l,rootId:a.id}}function K(e,t){if(!t)return{newBlockMap:e,rootId:null};if("column"===t.key){const n=Array.isArray(t.children)&&t.children.length>0;if(Array.isArray(t.cells)&&t.cells.length>0&&!n){const n=V(t,t.blockMap||t.blockSnapshotMap||{});if(n?.blockMap&&n.rootId){const t=M(n.blockMap,[n.rootId])[0];if(t){const{blockMap:n,rootOrder:o}=R([t]);return{newBlockMap:{...e,...n},rootId:o[0]??null}}}}const{blockMap:o,rootOrder:a}=R([t]);return{newBlockMap:{...e,...o},rootId:a[0]??null}}return{newBlockMap:{...e,[t.id]:t},rootId:t.id}}const G="SET_BLOCK_LIST",q="SET_BLOCKS",J="SET_IS_DRAG_START",Y="SET_ACTION_TYPE",X="SET_PREVIEW_MODE",Z="SET_CURRENT_ITEM",Q="SET_BODY_SETTINGS",ee="SET_SELECTION_RANGE",te="SET_TEXT_RANGE",ne="SET_LANGUAGE",oe="SET_LANGUAGE_LIBRARIES",ae="SET_TEMPLATE_VARIABLES",le="UNDO",ie="REDO",re=e=>({type:Y,actionType:e}),se=e=>({type:Z,currentItem:e}),ce=(e,t={})=>({type:ae,templateData:e,skipUndo:Boolean(t.skipUndo)}),de={},ue=[],me={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"}},pe={blockMap:de,rootOrder:ue,blockList:[],isDragStart:!1,actionType:"firstRender",previewMode:"desktop",currentItem:null,bodySettings:me,selectionRange:null,textRange:null,language:"en",languageLibraries:{},templateData:null,undoStack:[],redoStack:[]},ge=e.createContext();function he(e,t,n){const o=_(t,e.templateData),a=M(o,n);let{currentItem:l}=e;if(l?.id&&o[l.id]){const e=P(l.id,o);e&&e!==l.data&&(l={...l,data:e})}return{...e,blockMap:o,rootOrder:n,blockList:a,currentItem:l}}function be(e){return e?{...e,data:e.data&&"object"==typeof e.data?C(e.data):e.data}:null}function ye(e){return{blockMap:C(e.blockMap||de),rootOrder:[...e.rootOrder||ue],bodySettings:C(e.bodySettings||me),currentItem:be(e.currentItem),templateData:null==e.templateData?null:C(e.templateData)}}function _e(e,t){return t?e:{...e,undoStack:[...e.undoStack,ye(e)].slice(-50),redoStack:[]}}function fe(e,t){const n=t.templateData,o=_(C(t.blockMap||de),n),a=[...t.rootOrder||ue],l=M(o,a);let i=be(t.currentItem);if(i?.id&&o[i.id]){const e=P(i.id,o);e&&(i={...i,data:e})}const r=C(t.bodySettings||me);return{...e,blockMap:o,rootOrder:a,blockList:l,bodySettings:{...r,contentWidth:v(r.contentWidth)},currentItem:i,templateData:n}}function xe(e,t){switch(t.type){case q:return he(_e(e,t.skipUndo),t.blockMap,t.rootOrder);case G:{const n=_e(e,t.skipUndo),{blockMap:o,rootOrder:a}=R(t.blockList);return he(n,o,a)}case J:return{...e,isDragStart:t.isDragStart};case Y:return{...e,actionType:t.actionType};case X:return{...e,previewMode:t.previewMode};case Z:{let n=t.currentItem;if(n?.id&&e.blockMap[n.id]){const t=P(n.id,e.blockMap);t&&(n={...n,data:t})}return{...e,currentItem:n}}case Q:{const n=_e(e,t.skipUndo),o={...n.bodySettings,...t.bodySettings};return{...n,bodySettings:{...o,contentWidth:v(o.contentWidth)}}}case ee:return{...e,selectionRange:t.selectionRange};case te:return{...e,textRange:t.textRange};case ne:return{...e,language:t.language};case oe:return{...e,languageLibraries:t.languageLibraries};case ae:{const n=_e(e,t.skipUndo),o=t.templateData,a=_(n.blockMap,o),l=M(a,n.rootOrder);let{currentItem:i}=n;if(i?.id&&a[i.id]){const e=P(i.id,a);e&&(i={...i,data:e})}return{...n,templateData:o,blockMap:a,blockList:l,currentItem:i}}case le:{if(!e.undoStack.length)return e;const t=e.undoStack[e.undoStack.length-1],n=e.undoStack.slice(0,-1),o=ye(e),a=[...e.redoStack,o].slice(-50);return{...fe(e,t),undoStack:n,redoStack:a,actionType:"undo"}}case ie:{if(!e.redoStack.length)return e;const t=e.redoStack[e.redoStack.length-1],n=e.redoStack.slice(0,-1),o=ye(e),a=[...e.undoStack,o].slice(-50);return{...fe(e,t),undoStack:a,redoStack:n,actionType:"redo"}}default:return e}}function ke(e){if(null==e)return"";const t=String(e).trim();if(!t)return"";const n=t.toLowerCase();return"none"===n||"null"===n||"undefined"===n?"":t}var ve={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 we="CustomerName",je="DiscountValue",Se="DiscountCode",Ce="ValidUntil",Ne="CompanyName",Ie="Address",Ae="Website",Te="BrandName",Le="LogoUrl",Be="Tagline",$e="HeroBanner",Re="FooterBanner",Me="NavLabel",Pe="NavUrl",Fe="ProductName",Ee="ProductDescription",De="ProductImage",Ue="ProductLink",ze="ProductPrice",Oe="ProductCurrency",We="ProductOldPrice",He="ProductNewPrice",Ve="ProductPriceDisplay",Ke="CTALabel",Ge="CTAUrl",qe=new Set([We,He]);function Je(e){return`{{${e}}}`}const Ye=ve;let Xe=Ye;function Ze(e,t=Xe){return t&&Array.isArray(t[e])?t[e].map(e=>({...e,token:e.token||Je(e.key)})):[]}let Qe=[],et=[],tt=[],nt={},ot=[],at=[],lt=[];function it(){Qe=Ze("global",Xe),et=Ze("product",Xe),tt=Ze("discount",Xe),nt=[...Qe,...et,...tt].reduce((e,t)=>(e[t.key]=t,e),{}),ot=tt.map(e=>({variableKey:e.key,labelKey:e.labelKey}));const e=et.filter(e=>!qe.has(e.key));at=e.map(e=>({variableKey:e.key,labelKey:e.labelKey})),lt=Qe.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type})),tt.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type})),e.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type}))}it();const rt={[we]:"User",[je]:"20%",[Se]:"SAVE20",[Ce]:"12-31-2025",[Ne]:"Company Name",[Te]:"Company Name",[Ie]:"",[Ae]:"www.example.com",[Le]:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",[Be]:"Your tagline here",[$e]:"https://via.placeholder.com/600x200/eeeeee/666666?text=Hero",[Re]:"https://via.placeholder.com/600x100/eeeeee/666666?text=Footer",[Me]:"Link",[Pe]:"https://www.example.com",[Fe]:"Product Name",[Ee]:"Product description goes here.",[De]:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",[Ue]:"https://www.example.com",[ze]:"0",[Oe]:"USD",[We]:"0",[He]:"0",[Ve]:"$0.00 USD",[Ke]:"Shop Now",[Ge]:"www.example.com"};function st(e){return null==e||"string"!=typeof e?"":e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const ct=new Set([Ve]);function dt(e,t,n={}){if(null==e||"string"!=typeof e)return"";const o=e.replace(/\{\{(\w+)\}\}/g,(e,o)=>{const a=yt(t,o,n);return ct.has(o)?a:st(a)});return null==(a=o)||"string"!=typeof a?a:a.replace(/^(<p[^>]*>\s*(?:<br\s*\/?>|&nbsp;)?\s*<\/p>\s*)+/i,"");var a}function ut(e){return rt[e]??"—"}const mt=/^\{\{\s*[\w.]+\s*\}\}$/;function pt(e,t,{allowEmpty:n=!1}={}){if(null==e)return n?"":ut(t);const o=String(e).trim();return""===o?n?"":ut(t):function(e){return"string"==typeof e&&mt.test(e.trim())}(o)?ut(t):o}const gt={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 ht(e){return function(e){return"string"==typeof e&&/^[A-Za-z]{3}$/.test(e.trim())}(e)?String(e).trim().toUpperCase():"USD"}function bt(e,t){const n=function(e){if(null==e)return null;const t=String(e).replace(/,/g,"").trim();if(""===t)return null;const n=Number(t);return Number.isFinite(n)?n:null}(e);if(null==n)return null;const o=ht(t),a=function(e){return gt[e]??null}(o);if(!a)return null;const l=function(e){if(null==e)return 0;const t=String(e).trim().replace(/,/g,"");if(!t.includes("."))return 0;const[,n=""]=t.split(".");return Math.max(0,n.length)}(e);try{return`${new Intl.NumberFormat(a,{style:"currency",currency:o,minimumFractionDigits:l,maximumFractionDigits:l}).format(n)} ${o}`}catch{return null}}function yt(e,t,n={}){if(!e)return ut(t);const{columnIndex:o,columnProduct:a}=n;let l=a;switch(!l&&e.content?.products&&"number"==typeof o&&(l=e.content.products[o]||null),t){case we:return ut(we);case je:return pt(e.content?.discount?.value,je);case Se:return pt(e.content?.discount?.code,Se);case Ce:return pt(e.content?.discount?.valid_until,Ce);case Ne:case Te:return pt(e.companyContext?.name,t);case Ie:return pt(e.companyContext?.address,Ie,{allowEmpty:!0});case Ae:return pt(e.companyContext?.website,Ae);case Le:return pt(e.brandContext?.logo_url,Le);case Be:return pt(e.brandContext?.tagline,Be);case $e:return pt(e.brandContext?.heroBanner,$e);case Re:return pt(e.brandContext?.footerBanner,Re);case Me:case Pe:return ut(t);case Fe:return pt(l?.name,Fe);case Ee:{const e=ke(l?.description);return e?pt(e,Ee,{allowEmpty:!0}):""}case De:return pt(l?.image,De);case Ue:return pt(l?.link,Ue);case ze:return null!=l?.price&&"number"==typeof l.price||null!=l?.price&&"string"==typeof l.price?String(l.price):null!=l?.new_price?String(l.new_price):ut(ze);case Oe:return pt(l?.currency,Oe);case We:return pt(l?.old_price,We);case He:return null!=l?.new_price?pt(l.new_price,He):null!=l?.price?pt(l.price,He):ut(He);case Ve:{const e=ht(l?.currency),t=null!=l?.price?l.price:l?.new_price,n=null!=l?.old_price||null!=l?.new_price,o=null!=l?.old_price?l.old_price:null,a=null!=l?.new_price?l.new_price:null!=l?.price?l.price:null;if(n&&(null!=o||null!=a)){const t=bt(o,e),n=bt(a,e),l=null!=(null!=t?t:null!=o?String(o):null)?st(null!=t?t:null!=o?String(o):""):"";return[""!==l?`<span style="text-decoration: line-through;">${l}</span>`:"",null!=(null!=n?n:null!=a?String(a):null)?st(null!=n?n:null!=a?String(a):""):""].filter(Boolean).join(" ")||ut(Ve)}const i=bt(t,e);return null!=i?st(i):null!=t?st(String(t)):ut(Ve)}case Ke:{const t=e.content?.cta?.text;return pt(t,Ke)}case Ge:{const t=e.content?.cta?.url;return pt(null!=t?t:e.companyContext?.website,Ge)}default:return ut(t)}}const _t=[{variableKey:Le,labelKey:"variable_image_logo"},{variableKey:$e,labelKey:"variable_image_hero_banner"},{variableKey:Re,labelKey:"variable_image_footer_banner"}],ft=[{variableKey:De,labelKey:"variable_image_product_image"}],xt=[{variableKey:Ke,labelKey:"variable_cta_label"}],kt=[{variableKey:Ge,labelKey:"variable_cta_url"}],vt=[{variableKey:Ue,labelKey:"variable_product_link"},{variableKey:Ae,labelKey:"variable_website"}];function wt(e,t,n,o={}){let a=[];return"discount"===t?a=[...ot]:"product"===t&&(a=[...at]),a.map(({variableKey:e,labelKey:t})=>({...nt[e]||{},variableKey:e,labelKey:t,value:Je(e),pasteValue:yt(n,e,o)}))}function jt(e,t,n,o={},a=[]){const l="none"===t?lt.map(e=>({...e,pasteValue:yt(n,e.key,o)})):wt(0,t,n,o),i=(a||[]).filter(e=>e&&e.containerType&&"none"!==e.containerType).flatMap(e=>wt(0,e.containerType,n,e.context||{})),r=new Set,s=[];return[...l,...i].forEach(e=>{const t=e.variableKey||e.key||e.value;t&&!r.has(t)&&(r.add(t),s.push(e))}),s}const St={display_text:"DisplayText",introduction:"Introduction",heading:"Heading",subheading:"Subheading",products_description:"ProductDescription"};function Ct(e,t,n,o){return{value:Je(e),labelKey:t,variableKey:e,key:e,type:"image",pasteValue:yt(n,e,o)}}function Nt(e,t,n={}){const o=_t.map(({variableKey:e,labelKey:o})=>Ct(e,o,t,n));if("product"===e){const e=ft.map(({variableKey:e,labelKey:o})=>Ct(e,o,t,n));return[...o,...e]}return o}function It(e){return!1!==e?.linkEnabled}function At(e,t,n={}){if(!e||!t)return e;const{useImportant:o=!1}=n,a=String(t).trim();if(!a)return e;const l=o?`color: ${a} !important`:`color: ${a}`;return String(e).replace(/<a\b([^>]*)>/gi,(e,t)=>{const n=t.match(/\sstyle\s*=\s*"([^"]*)"/i);if(n){const e=(n[1]||"").replace(/\s*color\s*:\s*[^;]+(!important)?\s*;?/gi,"").replace(/;\s*;/g,";").replace(/^\s*;|;\s*$/g,"").trim(),o=`${e?`${e}; `:""}${l};`;return`<a${t.replace(n[0],` style="${o}"`)}>`}const o=t.match(/\sstyle\s*=\s*'([^']*)'/i);if(o){const e=(o[1]||"").replace(/\s*color\s*:\s*[^;]+(!important)?\s*;?/gi,"").replace(/;\s*;/g,";").replace(/^\s*;|;\s*$/g,"").trim(),n=`${e?`${e}; `:""}${l};`;return`<a${t.replace(o[0],` style='${n}'`)}>`}return`<a${t} style="${l};">`})}const Tt=[{name:"Sans Serif (Generic)",stack:"sans-serif"},{name:"Overused Grotesk",stack:"'Overused Grotesk', ui-sans-serif, system-ui, sans-serif"},{name:"Arial",stack:"Arial, Helvetica, sans-serif"},{name:"Helvetica",stack:"Helvetica, Arial, sans-serif"},{name:"Georgia",stack:"Georgia, Times New Roman, serif"},{name:"Times New Roman",stack:"'Times New Roman', Times, serif"},{name:"Verdana",stack:"Verdana, Geneva, sans-serif"},{name:"Tahoma",stack:"Tahoma, Geneva, sans-serif"},{name:"Trebuchet MS",stack:"'Trebuchet MS', Helvetica, Arial, sans-serif"},{name:"Courier New",stack:"'Courier New', Courier, monospace"},{name:"Palatino",stack:"'Palatino Linotype', Palatino, serif"},{name:"Garamond",stack:"Garamond, 'Times New Roman', serif"},{name:"Lucida",stack:"'Lucida Sans Unicode', 'Lucida Grande', sans-serif"}],Lt=[{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"}],Bt=e=>/\s/.test(String(e||""))?`'${String(e).replace(/'/g,"\\'")}'`:String(e);function $t(e){return`https://fonts.googleapis.com/css2?family=${(e=>String(e).trim().replace(/\s+/g,"+"))(e)}:wght@400;700&display=swap`}function Rt(e){const t=e?.brandContext?.customFonts;return Array.isArray(t)?t.filter(e=>e&&"object"==typeof e&&e.name&&e.url).map(e=>({label:`${e.name} (Brand Kit)`,value:`${Bt(e.name)}, Arial, sans-serif`,primaryName:String(e.name),source:"custom",url:String(e.url),format:e.format?String(e.format):void 0,weight:null!=e.weight?String(e.weight):void 0,style:e.style?String(e.style):void 0})):[]}function Mt(e){return[...Tt.map(e=>({label:e.name,value:e.stack,primaryName:e.name,source:"system"})),...Lt.map(e=>({label:`${e.name} (Google)`,value:`${Bt(e.name)}, ${e.fallback}`,primaryName:e.name,source:"google"})),...Rt(e)]}function Pt(e){if(!e)return"";const t=String(e).split(",")[0];return String(t??"").trim().replace(/^['"]|['"]$/g,"")}function Ft(e,t){const n=Mt(t),o=Pt(e).toLowerCase(),a=n.find(e=>e.primaryName.toLowerCase()===o);return a?a.value:e}function Et(e,t){const n=Mt(t),o=Ft(e,t),a=Pt(o).toLowerCase(),l=n.find(e=>e.primaryName.toLowerCase()===a||e.value===o);return l?l.label:"sans-serif"===a?"Sans Serif (Generic)":o}function Dt(e){const t=String(e.name||"").trim(),n=String(e.url||"").trim();if(!t||!n)return"";const o=e.format?` format('${e.format}')`:"",a=e.weight?`font-weight:${e.weight};`:"",l=e.style?`font-style:${e.style};`:"";return`@font-face{font-family:${Bt(t)};src:url('${n}')${o};${a}${l}}`}function Ut(e,t,n){const o=function(e,t){const n=new Set,o=e=>{null!=e&&""!==String(e).trim()&&n.add(String(e).trim())};o(t?.styles?.fontFamily);const a=e=>{Array.isArray(e)&&e.forEach(e=>{e&&"object"==typeof e&&(o(e?.styles?.desktop?.fontFamily),o(e?.styles?.mobile?.fontFamily),"image"===e.key&&Array.isArray(e.overlayItems)&&e.overlayItems.forEach(e=>{e&&"object"==typeof e&&o(e.fontFamily)}),Array.isArray(e.children)&&a(e.children))})};return a(e),[...n]}(e,t),a=new Set;o.forEach(e=>{const t=function(e){const t=Pt(e),n=Lt.find(e=>e.name.toLowerCase()===t.toLowerCase());return n?$t(n.name):null}(e);t&&a.add(t)});const l=(Array.isArray(n?.brandContext?.customFonts)?n.brandContext.customFonts:[]).map(Dt).filter(Boolean);return[...[...a].map(e=>`@import url('${e}');`),...l].join("\n")}function zt(e){const t=String(e?.image||"").toLowerCase(),n=String(e?.title||"").toLowerCase().trim();return t.includes("/tc-x.svg")||t.includes("/icons/x.svg")||t.includes("simple-icons")&&t.includes("/x.svg")||"x"===n||"twitter"===n}const Ot=["default","white","black","gray"];function Wt(e){const t="string"==typeof e?e:"default";return Ot.includes(t)?t:"default"}function Ht(e){if(!e||"object"!=typeof e)return{};const{padding:t,paddingTop:n,paddingRight:o,paddingBottom:a,paddingLeft:l,...i}=e;return i}const Vt={small:18,medium:24,large:32},Kt={left:"flex-start",center:"center",right:"flex-end",justify:"space-between"};function Gt(e){const t=e&&"object"==typeof e?{...e}:{},n=t.columnGapPx,o="number"==typeof n&&Number.isFinite(n)&&n>=0?n:8;delete t.columnGapPx;const a=t.textAlign||"left";delete t.textAlign;const l=Kt[a]||Kt.left;return{...t,display:"flex",width:"100%",maxWidth:"100%",boxSizing:"border-box",flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:l,columnGap:o,rowGap:0}}function qt(e){const t=e?.iconSize;if(t&&null!=Vt[t])return Vt[t];const n=Number(e?.imageWidth);return Number.isFinite(n)&&n>0?Math.round(n):Vt.medium}function Jt(e){const t=function(e){switch(e){case"white":return"brightness(0) invert(1)";case"black":return"brightness(0)";case"gray":return"brightness(0) opacity(0.55)";default:return""}}(e);return t?{filter:t}:{}}function Yt(e,t,n){const o=Number(n)||Vt.medium,a={width:o,height:o,objectFit:"contain",display:"block",verticalAlign:"middle",flexShrink:0},l=t&&"default"!==t?t:"default",i=String(e?.image||"");if("default"===l||!i)return{src:i,style:a};const r=function(e){if(!e)return null;if(zt(e))return"x";const t=String(e.image||"").toLowerCase(),n=String(e.title||"").toLowerCase();return t.includes("facebook")||n.includes("facebook")?"facebook":t.includes("instagram")||n.includes("instagram")?"instagram":t.includes("linkedin")||n.includes("linkedin")?"linkedin":t.includes("tiktok")||n.includes("tiktok")?"tiktok":t.includes("youtube")||n.includes("youtube")?"youtube":null}(e);if(r){const e=`https://cdn.jsdelivr.net/npm/simple-icons@11.10.0/icons/${r}.svg`;if("white"===l)return{src:e,style:{...a,filter:"brightness(0) invert(1)"}};if("gray"===l)return{src:e,style:{...a,opacity:.55}};if("black"===l)return{src:e,style:a}}return{src:i,style:{...a,...Jt(l)}}}const Xt="ee_cb";function Zt(e){const t=String(e??"").trim();if(!t)return t;if(/^\{\{/u.test(t)||/^data:/iu.test(t))return t;try{const e="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(t,e);return n.searchParams.set(Xt,String(Date.now())),n.toString()}catch{const e=t.includes("?")?"&":"?";return`${t}${e}${Xt}=${Date.now()}`}}function Qt(e){const t=String(e??"").trim();if(!t)return t;try{const e="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(t,e);n.searchParams.delete(Xt);let o=n.toString();return o.endsWith("?")&&(o=o.slice(0,-1)),o}catch{return t.replace(new RegExp(`[?&]${Xt}=\\d+`,"g"),"").replace(/\?&/g,"?").replace(/&&+/g,"&").replace(/[?&]$/,"")}}const en=[{value:"cover",labelKey:"container_bg_size_cover"},{value:"contain",labelKey:"container_bg_size_contain"},{value:"fill",labelKey:"container_bg_size_fill"}],tn=["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"];function nn(e){return String(e??"").trim().replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"").replace(/\r/g,"")}function on(e,t){const n=e?.containerBackgroundEnabled,o=e?.containerBackgroundImage,a=o&&String(o).trim();if(!1===n||!a)return{background:t};const l={cover:"cover",contain:"contain",fill:"100% 100%"}[e?.containerBackgroundSize||"cover"]||"cover",i=e?.containerBackgroundPosition||"center center";return{backgroundColor:t,backgroundImage:`url("${nn(a)}")`,backgroundSize:l,backgroundPosition:i,backgroundRepeat:"no-repeat"}}const an=["tl","tc","tr","ml","mc","mr","bl","bc","br"],ln={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 rn(e){const t=String(e??"bc").toLowerCase();return an.includes(t)?t:"bc"}function sn(e){const t=rn(e);return ln[t]}function cn(e,t){const n="string"==typeof t?t.trim():"";if(n)return n;const o=function(e){if(!e||"string"!=typeof e)return null;const t=e.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 e of n){const n=t.match(e);if(n?.[1])return n[1]}return null}(e||"");return o?`https://img.youtube.com/vi/${o}/hqdefault.jpg`:""}const dn=new Set(["fontWeight","opacity","zIndex"]),un=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),mn=e=>un(e).replace(/"/g,"&quot;").replace(/'/g,"&#39;"),pn=(e,t="#")=>{if(null==e)return t;const n=String(e).trim();if(!n)return t;const o=n.toLowerCase();return/^\s*(?:javascript|vbscript):/i.test(o)||/^\s*data:/i.test(o)?t:/^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(/^\/+/,"")}`},gn=(e,t)=>{const n=new RegExp(/[A-Z]/g),o=e=>e.replace(n,e=>`-${e.toLowerCase()}`),a={desktop:t?.desktop??{},mobile:t?.mobile??{}};let l={className:e,desktop:"",mobile:""};for(let e of Object.entries(a.desktop))if(e[1]&&"contentBackground"!==e[0]&&"horizontalAlign"!==e[0]&&"containerBackgroundImage"!==e[0]&&"containerBackgroundSize"!==e[0]&&"containerBackgroundPosition"!==e[0]){const t="number"!=typeof e[1]||dn.has(e[0])?e[1]:e[1]+"px";l.desktop+=`${o(e[0])}:${t};`}if(Object.keys(a.mobile).length){let t="";for(let e of Object.entries(a.mobile))if(e[1]&&"contentBackground"!==e[0]&&"horizontalAlign"!==e[0]&&"containerBackgroundImage"!==e[0]&&"containerBackgroundSize"!==e[0]&&"containerBackgroundPosition"!==e[0]){const n="number"!=typeof e[1]||dn.has(e[0])?e[1]:e[1]+"px";t+=`${o(e[0])}:${n} !important;`}l.mobile+=`@media(max-width:620px){\n .${e} {\n ${t}\n }\n }`}return l},hn=(e,t="",n)=>{const o=e.map((e,o)=>{let a={...e};const l={desktop:e?.styles?.desktop??{},mobile:e?.styles?.mobile??{}},i="social_link"===e.key||"menu"===e.key?{desktop:Ht(l.desktop),mobile:Ht(l.mobile)}:l;if(a.styleConfig=gn(n?`${n}-${e.key}-${o}`:`${e.key}-${o}`,i),a.contentStyles){const n={desktop:a.contentStyles?.desktop??{},mobile:a.contentStyles?.mobile??{}};a.contentStyleConfig=gn(`${e.key}-content-${o}`,n),a.contentStyleConfig.mobile&&(t+=a.contentStyleConfig.mobile)}if("video"===a.key&&a.videoArea){const l={desktop:a.videoArea?.desktop??{},mobile:a.videoArea?.mobile??{}},i=null!=n?`${n}-${e.key}-video-area-${o}`:`${e.key}-video-area-${o}`;a.videoAreaStyleConfig=gn(i,l),a.videoAreaStyleConfig.mobile&&(t+=a.videoAreaStyleConfig.mobile)}if(a.styleConfig.mobile&&(t+=a.styleConfig.mobile),i.desktop.contentBackground&&(a.contentStyleConfig={className:`${e.key}-content-${o}`,desktop:`background-color:${i.desktop.contentBackground};`,mobile:""}),i.mobile.contentBackground&&(a.contentStyleConfig||(a.contentStyleConfig={className:`${e.key}-content-${o}`,desktop:"",mobile:""}),a.contentStyleConfig.mobile=` @media(max-width:620px){\n .${a.contentStyleConfig.className} {background-color:${i.mobile.contentBackground};}\n }`,t+=a.contentStyleConfig.mobile),e.children?.length){const{newBlockList:n,styles:l}=hn(e.children,t,o);t+=l,a.children=n}return{...a}});return{newBlockList:o,styles:t}};function bn(e){const t=e.contentStyleConfig?.desktop??"",n=function(e){const t=e.contentStyles?.desktop??{},n=e.contentStyles?.mobile??{},o=null!=t.textAlign&&""!==String(t.textAlign).trim()?t.textAlign:n.textAlign,a=null!=o&&""!==String(o).trim()?String(o).trim():"center";return"start"===a?"left":"end"===a?"right":a}(e);return/\btext-align\s*:/i.test(t)?t:`${t}text-align:${n};`}const yn="#2faade";function _n(e){const t=String(e??"");return null!=(n=t)&&"string"==typeof n&&/<[a-zA-Z!/?]/.test(n.trim())?function(e){if(!e||!/<a\b/i.test(e))return e;const t=(e,t,n)=>{const o=(t[1]||"").replace(/\s*text-decoration(-line)?\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),a=(o?`${o}; `:"")+"text-decoration: none;",l='"'===n?` style="${a}"`:` style='${a}'`;return`<a${e.replace(t[0],l)}>`};return String(e).replace(/<a\b([^>]*)>/gi,(e,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o)return t(n,o,'"');const a=n.match(/\sstyle\s*=\s*'([^']*)'/i);return a?t(n,a,"'"):`<a${n} style="text-decoration: none;">`})}(t):un(t);var n}function fn(e){const t=e?.dynamicSelectedContent,n=e?.text??"";if(null==t)return String(n);const o=String(t);return""===o.trim()?String(n):o}const xn=(e,t,n={})=>{let o=fn(e);t&&o&&(o=dt(o,t,n));const a=e?.styles?.desktop??{},l=null!=a.linkColor&&""!==String(a.linkColor).trim();return o=At(o,l?String(a.linkColor).trim():yn,{useImportant:l}),`<${e.type} ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig?.desktop||""}">\n ${o}\n </${e.type}>`},kn=e=>{const t=y(e.list||[]);if(0===t.length)return"";const n=Boolean(e.showTextLabel),o=`${e.styleConfig.desktop};display:inline-flex;vertical-align:middle;margin:0;align-items:center;${n?"gap:8px;":""}`,a=qt(e),l=Math.max(11,Math.round(.58*a)),i=Wt(e.iconColor),r=t.map(t=>{const{title:r,linkURL:s}=t,c=m(s,{allowMailtoTel:!1}),{src:d,styleAttr:u}=function(e,t,n){const{src:o,style:a}=Yt(e,t,n),l=Number(n)||Vt.medium,i=[`width:${l}px`,`height:${l}px`,"object-fit:contain","display:block","vertical-align:middle"];return a.filter&&i.push(`filter:${a.filter}`),null!=a.opacity&&i.push(`opacity:${a.opacity}`),{src:o,styleAttr:i.join(";")}}(t,i,a),p=`<img src="${mn(d)}" alt="${mn(r)}" style="${mn(u)}" \n ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""}/>`,g=zt(t)?"X":String(r??""),h=n?`<span style="font-size:${l}px;line-height:1.2;color:#525252;font-family:inherit;white-space:nowrap;">${un(g)}</span>`:"";return`<a target="_blank" rel="noopener noreferrer" href="${mn(c)}" style="${o};text-decoration:none;">${p}${h}</a>`}).join(""),s=function(e){const t=e?.contentStyles?.desktop??{},n=t.textAlign||"left",o=t.columnGapPx;return`width:100%;max-width:100%;box-sizing:border-box;display:flex;flex-wrap:wrap;align-items:center;justify-content:${"justify"===n?"space-between":"center"===n?"center":"right"===n?"flex-end":"flex-start"};column-gap:${"number"==typeof o&&Number.isFinite(o)&&o>=0?o:8}px;row-gap:0`}(e),c=`${e.contentStyleConfig.desktop};${s}`;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${c}">\n ${r}\n </div>`};const vn=(e,t,n,o,a,l)=>{let i="";const r={columnIndex:a??0,columnProduct:o?.columnProducts?.[l??0]??null};return e.forEach((e,s)=>{if("column"===e.key){const r=function(e){const t={...e?.desktop??{}},n=e?.mobile??{},o=String(t.containerBackgroundImage??"").trim(),a=String(n.containerBackgroundImage??"").trim();!o&&a&&(t.containerBackgroundImage=n.containerBackgroundImage,null!=n.containerBackgroundSize&&(t.containerBackgroundSize=n.containerBackgroundSize),null!=n.containerBackgroundPosition&&(t.containerBackgroundPosition=n.containerBackgroundPosition),void 0!==n.containerBackgroundEnabled&&(t.containerBackgroundEnabled=n.containerBackgroundEnabled));const l=t.minHeight,i=n.minHeight;return null!=l&&""!==String(l).trim()||null==i||""===String(i).trim()||(t.minHeight=i),t}(e.styles),c=e.styles?.desktop?.borderRadius,d=c?`border-radius:${"number"==typeof c?c+"px":c};`:"",u=d?"overflow:hidden;":"",m=function(e){const t=e??{};if(!1===t.containerBackgroundEnabled)return"";const n=Qt(t.containerBackgroundImage);return n&&String(n).trim()?`background-image:url("${nn(n)}");background-size:${{cover:"cover",contain:"contain",fill:"100% 100%"}[t.containerBackgroundSize||"cover"]||"cover"};background-position:${t.containerBackgroundPosition||"center center"};background-repeat:no-repeat;`:""}(r),p=function(e){if(null==e)return"";if("number"==typeof e&&Number.isFinite(e))return`min-height:${e}px;`;const t=String(e).trim();return t?/^\d+$/.test(t)?`min-height:${t}px;`:`min-height:${t};`:""}(r.minHeight),g=e.containerType&&"none"!==e.containerType?e:o,h=e.containerType&&"none"!==e.containerType?s:a,b=e.containerType&&"none"!==e.containerType?0:l;i+=`<div ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig.desktop};width:100%;display:block;${u}">\n <table ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="width:100%;max-width:${S(t)?"100%":`${j(t)}px`};margin:0 auto;${d}${e.contentStyleConfig?.desktop??""}${m}${p}">\n <tbody><tr>${vn(e.children,t,n,g,h,b)}</tr></tbody>\n </table></div>`}if("content"===e.key&&(i+=`<td ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="width:${e.width}; ${e.styleConfig.desktop}">${vn(e.children,t,n,o,a,s)}</td>`),"text"===e.key){const t=null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[l??0]??null}:r;e.type&&/^h[1-4]$/.test(e.type)?i+=xn(e,n,t):i+=((e,t,n={},o=null)=>{let a=fn(e);t&&a&&(a=dt(a,t,n));const l=e?.styles?.desktop??{},i=null!=l.linkColor&&""!==String(l.linkColor).trim();a=At(a,i?String(l.linkColor).trim():yn,{useImportant:i});const r="footer"===o?.containerType,s=null==(c=a)||"string"!=typeof c?"":c.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();var c;return!r||""!==s&&"{{Address}}"!==s&&"{{Tagline}}"!==s?`<div ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig?.desktop||""}">${a}</div>`:""})(e,n,t,o)}if("heading"===e.key&&(i+=xn(e,n,r)),"image"===e.key){i+=((e,t,n={},o=null)=>{let a=e.src||"";const l="string"==typeof e.src&&/^\{\{\s*[\w.]+\s*\}\}$/.test(e.src.trim())?e.src.trim():"";if(t&&l){const e=yt(t,l.replace(/^\{\{\s*|\s*\}\}$/g,""),n);e&&!/^\{\{\s*[\w.]+\s*\}\}$/.test(String(e).trim())&&(a=e)}a=Qt(a);const i=mn(a),r=mn(e.alt||"Image"),s=null!=e.linkURL?String(e.linkURL).trim():"",c=Array.isArray(e.overlayItems)?e.overlayItems:[],d=c.some(e=>""!==String(e?.text??"").trim()),u=String(e.overlayText??"").trim(),m=Boolean(e.textOverlayEnabled)&&(d||""!==u)&&a,p=`${e.styleConfig?.desktop||""};max-width:100%;display:inline-block;vertical-align:top;`;let g=`<img src="${i}" alt="${r}" style="${p}" ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""}/>`;if(m){const t=sn(rn(e.overlayPosition)),n=Object.entries({position:"absolute",...t,"z-index":"2","max-width":`${"number"==typeof e.overlayMaxWidth?e.overlayMaxWidth:100}%`,"box-sizing":"border-box","pointer-events":"none"}).map(([e,t])=>`${e}:${t};`).join(""),a="number"==typeof e.overlayPadding?e.overlayPadding:16,l=e.textShadowEnabled?"text-shadow:0 1px 3px rgba(0,0,0,0.55);":"";let s="";if(d){const t="number"==typeof e.overlayItemGap?e.overlayItemGap:8,n=c.filter(e=>String(e?.text??"").trim()).map(e=>{const t="number"==typeof e.fontSize?e.fontSize:16,n=mn(e.color||"#ffffff"),a=(e=>{switch(e){case"h1":case"h2":case"h3":return"700";case"subtitle":case"eyebrow":return"600";default:return"400"}})(e.kind),i=null!=e.fontFamily&&""!==String(e.fontFamily).trim()?String(e.fontFamily).trim():String(o?.styles?.fontFamily||"sans-serif").trim()||"sans-serif",r=mn(i),s=un(String(e.text??""));return`<div style="color:${n};font-size:${t}px;font-weight:${a};line-height:1.35;font-family:${r};${l}">${s}</div>`});s=`<div style="display:flex;flex-direction:column;gap:${t}px;width:100%;padding:${a}px;">${n.join("")}</div>`}else s=`<div style="color:${mn(e.overlayTextColor||"#ffffff")};font-size:${"number"==typeof e.overlayFontSize?e.overlayFontSize:18}px;font-weight:600;line-height:1.35;${e.overlayBoxBackground?`background-color:${mn(e.overlayBoxBackground)};padding:8px 12px;`:`padding:${a}px;`}${l}">${un(u)}</div>`;g=`<div style="position:relative;display:inline-block;vertical-align:top;max-width:100%;overflow:hidden;line-height:0;">\n ${e.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="${i}" alt="${r}" style="${p}position:relative;z-index:0;border-radius:0;" ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""}/>\n <div style="${n}">\n ${s}\n </div>\n </div>`}const h=It(e)&&""!==s?`<a href="${mn(pn(s))}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;display:inline-block;max-width:100%;">${g}</a>`:g;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${bn(e)}">\n ${h}\n </div>`})(e,n,null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[l??0]??null}:r,t)}if("video"===e.key&&(i+=(e=>{const t=null!=e.videoUrl?String(e.videoUrl).trim():"",n=cn(t,null!=e.thumbnailUrl?String(e.thumbnailUrl).trim():""),o=t?pn(t):"#",a=`${e.styleConfig?.desktop||""};max-width:100%;height:auto;display:block;border:0;`,l=e.contentStyleConfig?.desktop||"",i=e.videoAreaStyleConfig?.desktop||"";return`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${l}">\n <div ${e.videoAreaStyleConfig?.mobile?`class="${e.videoAreaStyleConfig.className}"`:""} style="${i}">\n ${n?`<a href="${mn(o)}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;display:inline-block;max-width:100%;line-height:0;"><img src="${mn(n)}" alt="${mn("Video")}" style="${a}"/></a>`:`<a href="${mn(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>`})(e)),"button"===e.key){i+=((e,t,n={})=>{let o=e.text||"",a=e.linkURL||"";if(t){const l=o.match(/\{\{(\w+)\}\}/),i=e.labelVariable?e.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():l?l[1]:void 0;if(i){const e=yt(t,i,n);null==e||String(e).startsWith("{{")||(o=String(e))}if(e.urlVariable){const o=yt(t,e.urlVariable.replace(/^\{\{|\}\}$/g,""),n);o&&!o.startsWith("{{")&&(a=String(o))}else{const e=String(a||"").trim().match(/^\{\{(\w+)\}\}$/);if(e){const o=yt(t,e[1],n);o&&!String(o).startsWith("{{")&&(a=String(o))}}}const l=_n(o),i=mn(pn(a)),r=e.styleConfig.desktop||"",s=r.includes("background-color:")?"":`background-color:${(e=>e?.brandContext?.brand_color??"#111111")(t)};`;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${e.contentStyleConfig.desktop}">\n <a ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="${r}${s}text-align:center;text-decoration:none;" target="_blank" rel="noopener noreferrer" href="${i}">${l}</a>\n </div>`})(e,n,null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[l??0]??null}:r)}var c,d;"divider"===e.key&&(i+=`<div ${(c=e).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"===e.key&&(i+=(d=e,`<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"===e.key&&(i+=(e=>{const t=e.list||[],n=null!=e.separator?String(e.separator):" | ",o=e.styleConfig?.desktop||"",a=e.contentStyleConfig?.desktop||"",l=e.linkGapPx,i="number"==typeof l&&Number.isFinite(l)&&l>=0?l:0,r=Boolean(e.linkUnderline),s=e.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 t.forEach((e,t)=>{t>0&&(u+=`<span style="${i>0?`display:inline-block;margin-left:${i}px;margin-right:${i}px;font-size:${c};color:${d};`:`display:inline-block;padding-left:4px;padding-right:4px;font-size:${c};color:${d};`}">${un(n)}</span>`);const a=pn(e.url,"#"),l="_blank"===e.target?"_blank":"_self",s=un(e.label||"Link"),m=r?"underline":"none";u+=`<a target="${l}" href="${mn(a)}" style="${o};text-decoration:${m};display:inline-block;">${s}</a>`}),`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${a}">${u}</div>`})(e)),"avatar"===e.key&&(i+=(e=>{const t=e.src||"",n=e.alt||"Avatar",o=e.linkURL,a=e.styleConfig?.desktop||"",l=e.styles?.desktop?.width??64,i=`max-width:100%;width:${"number"==typeof l?l+"px":l};height:${"number"==typeof l?l+"px":l};object-fit:cover;border-radius:${e.styles?.desktop?.borderRadius??"50%"};${a}`,r=mn(t),s=mn(n),c=t?`<img src="${r}" alt="${s}" style="${i}" />`:`<div style="${i};background:#eee;display:flex;align-items:center;justify-content:center;"></div>`,d=e.contentStyleConfig?.desktop||"",u=o?`<a href="${mn(pn(o))}" target="_blank" rel="noopener noreferrer">${c}</a>`:c;return`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${d}">${u}</div>`})(e)),"social_link"===e.key&&(i+=kn(e)),"raw_html"===e.key&&(i+=(e=>{const t=e.html??"",n=e.contentStyleConfig?.desktop??"",o=e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:"",a=e.contentStyles?.desktop??{},l=a.width,i=a.textAlign??"center";let r="";return null!=l&&"100%"!==String(l)&&"center"===i?r="margin-left:auto;margin-right:auto;":null!=l&&"100%"!==String(l)&&"right"===i?r="margin-left:auto;margin-right:0;":null==l||"100%"===String(l)||"left"!==i&&"justify"!==i||(r="margin-left:0;margin-right:auto;"),`<div ${o} style="${r}max-width:100%;${n}">${t}</div>`})(e)),"table"===e.key&&(i+=(e=>{const t=e.contentStyleConfig?.desktop||"",n=e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:"",o=e.styles?.desktop??{},a="number"==typeof e.rows?e.rows:3,l="number"==typeof e.cols?e.cols:3,i=Boolean(e.headerRow),r=Boolean(e.headerCol),s=Boolean(e.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,h=o.textAlign??"left",b=o.headerBg??"#f5f5f5",y=o.headerColor??"#333333",_=o.stripedBg??"#fafafa",f="none"!==u?`${m}px ${u} ${p}`:"none",x=Array.from({length:a}).map((t,n)=>`<tr>${Array.from({length:l}).map((t,o)=>{const a=i&&0===n||r&&0===o,l=a?b:s&&!a&&n%2==0?_:"transparent",u=a?y:d,m=a?"600":"400",p=`${n}-${o}`,x=e.cells?.[p],k=i&&0===n||r&&0===o?"th":"td";let v="&#8212;";return"image"===x?.type&&String(x.src??"").trim()?v=`<img src="${mn(x.src)}" alt="${mn(x.alt||"")}" style="max-width:100%;height:auto;display:block;border:0;"/>`:String(x?.text??"").trim()&&(v=un(String(x.text))),`<${k} style="border:${f};padding:${g}px;font-size:${c}px;color:${u};text-align:${h};background-color:${l};font-weight:${m};vertical-align:top;">${v}</${k}>`}).join("")}</tr>`).join("");return`<div ${n} style="${t}"><table role="presentation" style="${e.styleConfig?.desktop||""};border-collapse:collapse;width:100%;table-layout:auto;"><tbody>${x}</tbody></table></div>`})(e))}),i},wn={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"}},jn=e=>Array.isArray(e)?e.filter(e=>!(e&&"object"==typeof e&&!0===e.hidden)).map(e=>e&&"object"==typeof e&&Array.isArray(e.children)?{...e,children:jn(e.children)}:e):e,Sn=({bodySettings:e,blockList:t,templateData:n})=>{let o="";const a=((e,t)=>{if(!Array.isArray(e))return e;const n=t?.content?.products;if(!Array.isArray(n)||0===n.length)return e;const o=t?.content?.primaryProductId,a=(o?n.find(e=>e?.id===o):n[0])??n[0]??null;if(!a)return e;const l=n.filter(e=>e?.id!==a.id),i=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(i):e.children;if("column"!==e.key||"product"!==e.containerType)return{...e,children:t};const n="additional"===e.productRole?"additional":"main",o=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),r=Array.from({length:o},(e,t)=>"main"===n||0===l.length?a:l[t%l.length]);return{...e,children:t,columnProducts:r}};return e.map(i)})(jn(t??[]),n),{newBlockList:l,styles:i}=hn(a);o=vn(l,e,n);const r=Ut(a,e,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 ${e.styles?.headingColor?`color: ${e.styles.headingColor};`:""}\n }\n\n a {\n ${e.styles?.linkColor?`color: ${e.styles.linkColor};`:""}\n }\n\n @media(max-width:620px){\n${!1!==e.stackColumnsOnMobile?" td {\n display:inline-block;\n width:100% !important;\n }\n":""}${!1!==e.scaleFontOnMobile?" body { font-size: 16px !important; }\n":""} }\n ${r}\n ${i}\n</style>\n </head>\n <body>\n <div style="opacity:0;">${e.preHeader}</div>\n <div style="background-color:${e.styles.backgroundColor};color:${e.styles.color}; font-family:${e.styles.fontFamily};"> ${o}</div>\n </body>\n </html>`};function Cn(e){let t=e;if("string"==typeof e)try{t=JSON.parse(e)}catch(e){throw new Error("exportNormalizerToHtml: invalid JSON")}if(null==t)throw new Error("exportNormalizerToHtml: input is null or undefined");let n=[],o={...wn,styles:{...wn.styles}};Array.isArray(t)?n=t:"object"==typeof t&&(n=Array.isArray(t.blockList)?t.blockList:[],t.bodySettings&&"object"==typeof t.bodySettings&&(o={preHeader:null!=t.bodySettings.preHeader?t.bodySettings.preHeader:wn.preHeader,contentWidth:v(t.bodySettings.contentWidth??wn.contentWidth),contentWidthMode:t.bodySettings.contentWidthMode??wn.contentWidthMode,stackColumnsOnMobile:!1!==t.bodySettings.stackColumnsOnMobile,scaleFontOnMobile:!1!==t.bodySettings.scaleFontOnMobile,styles:{backgroundColor:t.bodySettings.styles?.backgroundColor??wn.styles.backgroundColor,contentBg:t.bodySettings.styles?.contentBg??wn.styles.contentBg,color:t.bodySettings.styles?.color??wn.styles.color,headingColor:t.bodySettings.styles?.headingColor??wn.styles.headingColor,linkColor:t.bodySettings.styles?.linkColor??wn.styles.linkColor,fontFamily:t.bodySettings.styles?.fontFamily??wn.styles.fontFamily}}));return`<!DOCTYPE html>\n${Sn({bodySettings:o,blockList:n,templateData:t.templateData})}`}function Nn(e,t){if("section"===e.layoutRole||"columns"===e.layoutRole)return e.layoutRole;if(!0===e.columnLayoutOnly)return"columns";return t.length>1||e.type&&"full"!==e.type?"columns":"section"}const In=["product"];function An(e){return Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):[]}function Tn(e,t={}){if(!e||"object"!=typeof e)return e;if("image"===e.key){const n="string"==typeof e.imageVariable&&/^\{\{\w+\}\}$/.test(e.imageVariable.trim())?e.imageVariable.trim():"",o="string"==typeof e.src&&/^\{\{\w+\}\}$/.test(e.src.trim())?e.src.trim():"",{imageVariable:a,...l}=e;return{...l,src:o||n||e.src,textOverlayEnabled:Boolean(e.textOverlayEnabled),overlayText:e.overlayText??"",overlayPosition:e.overlayPosition??"bc",overlayTextColor:e.overlayTextColor??"#ffffff",overlayFontSize:(()=>{const t=Number(e.overlayFontSize);return Number.isFinite(t)&&t>0?t:18})(),overlayBoxBackground:e.overlayBoxBackground??"",overlayPadding:(()=>{const t=Number(e.overlayPadding);return Number.isFinite(t)&&t>=0?t:16})(),scrimEnabled:Boolean(e.scrimEnabled),textShadowEnabled:Boolean(e.textShadowEnabled),children:An(e.children).map(e=>Tn(e,t))}}if("video"===e.key){const t=e.videoArea||{},n=t.desktop||{};return{...e,videoUrl:"string"==typeof e.videoUrl?e.videoUrl:"",thumbnailUrl:"string"==typeof e.thumbnailUrl?e.thumbnailUrl:"",videoArea:{desktop:{paddingTop:n.paddingTop??0,paddingBottom:n.paddingBottom??0,paddingLeft:n.paddingLeft??0,paddingRight:n.paddingRight??0,backgroundColor:n.backgroundColor??"transparent",borderWidth:n.borderWidth??0,borderStyle:n.borderStyle??"solid",borderColor:n.borderColor??"#cccccc",borderRadius:n.borderRadius??0},mobile:t.mobile??{}},styles:{desktop:{width:"auto",height:"auto",fillColumn:!1,fillColumnMobile:!1,display:"inline-block",...e.styles?.desktop||{}},mobile:{...e.styles?.mobile||{}}},contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center",backgroundColor:"transparent",...e.contentStyles?.desktop||{}},mobile:{...e.contentStyles?.mobile||{}}}}}if("column"===e.key){const{ctaText:n,...o}=e,a=e.containerType,l=function(e){return null==e||"none"===e?"none":"discount"===e?"discount":"product"===e||"hero_product"===e||"additional_product"===e?"product":"none"}(a),i="product"===l?e.productRole??("additional_product"===a?"additional":"main"):void 0,r=An(e.children);let s=e.columnProducts;if(In.includes(l)){const e=r.length;Array.isArray(s)||(s=[]),s=Array.from({length:e},(e,t)=>s[t]??null)}else s=[];return{...o,containerType:l,productRole:i,columnProducts:s,layoutRole:Nn(e,r),children:(r||[]).map(e=>Tn(e,t))}}if("heading"===e.key){const n=e.id?t?.[e.id]:null,o={...e,key:"text",name:e.name,type:e.type||"h1",contentType:e.contentType??"static",text:e.text,styles:e.styles,contentStyles:e.contentStyles,selectedVariableKey:e.selectedVariableKey,dynamicVariable:n?.variable??e.dynamicVariable,dynamicPrompt:n?.prompt??e.dynamicPrompt,dynamicSelectedContent:n?.selectedContent??e.dynamicSelectedContent,dynamicOptions:Array.isArray(n?.options)?n.options:n?.selectedContent?[n.selectedContent]:e.dynamicOptions};return"dynamic"===o.contentType&&(o.dynamicVariable=o.dynamicVariable??"",o.dynamicPrompt=o.dynamicPrompt??"",o.dynamicSelectedContent=o.dynamicSelectedContent??"",o.dynamicOptions=Array.isArray(o.dynamicOptions)?o.dynamicOptions:[],o.dynamicAiLanguage="bn-BD"===n?.language||"bn-BD"===o.dynamicAiLanguage?"bn-BD":"en"),{...o,children:An(e.children).map(e=>Tn(e,t))}}if("text"===e.key){const n=e.id?t?.[e.id]:null,o=e.contentType??"static",a={...e,type:e.type||"p",contentType:o};return"dynamic"===o&&(a.dynamicVariable=n?.variable??e.dynamicVariable??"",a.dynamicPrompt=n?.prompt??e.dynamicPrompt??"",a.dynamicSelectedContent=n?.selectedContent??e.dynamicSelectedContent??"",a.dynamicOptions=Array.isArray(n?.options)?n.options:n?.selectedContent?[n.selectedContent]:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[],a.dynamicAiLanguage="bn-BD"===n?.language||"bn-BD"===e.dynamicAiLanguage?"bn-BD":"en"),{...a,children:An(e.children).map(e=>Tn(e,t))}}return{...e,children:An(e.children).map(e=>Tn(e,t))}}function Ln(e,t={}){const n=Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):null;if(!Array.isArray(n))return e;const o=n.map(e=>Tn(e,t));return o.forEach(T),o}const Bn="https://api-alpha.markopolo.ai/v1",$n="https://nbq-ml-api-stg.markopolo.ai/v1",Rn="95b48b5b-cf5e-486d-817e-9839d4c4e618";function Mn(e,t){const n=null!=(o=e)&&"string"==typeof o&&o.trim()?o.replace(/\/$/,""):Bn;var o;const a=function(e){return null!=e&&"string"==typeof e&&e.trim()?e.replace(/\/$/,""):$n}(t);return{imageUploadEndpoint:`${n}/upload-file`,imageUploadQueryParams:{show:!1},imageUploadCompanyField:"comment",productsEndpoint:`${n}/knowledge-base/products`,universalEmailBlocksEndpoint:`${n}/universal-email-blocks`,mlEmailNodesEndpoint:`${a}/ml-service/content/generate-email-nodes`,mlEmailGenerateEndpoint:`${a}/ml-service/content/generate-email`}}function Pn(e={}){const t=e&&"object"==typeof e?e:{},{apiBaseUrlV1:n,apiBaseV1:o,mlGenerationApiBaseUrlV1:a,mlApiBaseUrlV1:l,headers:i,mlEmailGenerateBnEndpoint:r,...s}=t,c=n||o||Bn,d="undefined"!=typeof process&&process.env?.REACT_APP_ML_API_BASE_V1,u=Mn(c,a||l||d||$n),m="undefined"!=typeof process?String(process.env?.REACT_APP_EMAIL_TEMPLATE_ID??"").trim():"",p={...u,...s};p.mlEmailGenerateEndpoint&&String(p.mlEmailGenerateEndpoint).trim()||!r||(p.mlEmailGenerateEndpoint=String(r).replace(/\/generate-email\/bn\/?$/i,"/generate-email"));const g=String(p.emailTemplateId??"").trim()||m||Rn;return{...p,emailTemplateId:g,headers:{...p.headers||{},...i||{}}}}function Fn(e,t,n){const o=String(e??"").trim(),a=t&&"object"==typeof t?JSON.parse(JSON.stringify(t)):{name:"Block",key:"column"};a.name||(a.name="column"===a.key?"Container":o||"Block"),a.key||(a.key="column"),"column"===a.key&&Array.isArray(a.children)&&a.children.length>0&&delete a.cells;const l="column"===a.key?String(a.containerType??"none"):"none",i=function(e){if(!e||"object"!=typeof e)return"content";const t=String(e.key??"").toLowerCase();if("column"===t){const t=String(e.containerType??"none").toLowerCase();return"header"===t?"header":"footer"===t?"footer":"none"===t||""===t?"column":"content"}return"image"===t?"image":"menu"===t?"menu":"content"}(a),r="undefined"!=typeof performance&&performance.now?Math.floor(performance.now()):Date.now(),s=String(a.id??r).replace(/-/g,"").slice(0,12),c=`preset_${d=o,String(d??"").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"").slice(0,48)||"block"}_${s}`;var d;return{companyId:String(n),blockName:o,blockType:i,presetId:c,presetName:o,nameKey:c,containerType:l,block:a}}function En(e,t){if(!e||"object"!=typeof e)return null!=t?`Request failed (${t})`:"Request failed";const n=e.error;if(n&&"object"==typeof n&&null!=n.message){const e=String(n.message).trim();if(e){const t=null!=n.code?String(n.code).trim():"";return t&&t!==e&&!e.toLowerCase().includes(t.toLowerCase())?`${t}: ${e}`:e}}return"string"==typeof n&&n.trim()?n.trim():"string"==typeof e.message&&e.message.trim()?e.message.trim():null!=t?`Request failed (${t})`:"Request failed"}function Dn(e){const t=e?.universalEmailBlocksEndpoint;if(t&&String(t).trim())return String(t).replace(/\/$/,"");const n=String(e?.apiBaseUrlV1||e?.apiBaseV1||"").replace(/\/$/,"");return n?`${n}/universal-email-blocks`:""}function Un(e){return{"Content-Type":"application/json",...e?.headers||{}}}function zn(e){if(!e||"object"!=typeof e)return null;const t=e.resourceId??e.id;if(!t)return null;let n=e.block;if("string"==typeof n)try{n=JSON.parse(n)}catch{n=null}n&&"object"==typeof n||(n={});const o=e.blockMap??e.blocks??e.blockSnapshotMap;if("column"===n.key&&o&&"object"==typeof o){const e=Array.isArray(o)?o.reduce((e,t)=>(t&&"object"==typeof t&&t.id&&(e[t.id]=t),e),{}):{...o};Object.keys(e).length>0&&(n={...n,blockMap:e})}return{id:t,name:e.blockName??e.name??"Saved block",block:n,resourceId:e.resourceId??t,blockType:e.blockType}}const On={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 Wn(e){const t=String(e??"").trim();return/^\{\{[A-Za-z_]\w*\}\}$/.test(t)}function Hn(e){if(!e||"object"!=typeof e)return"";return`${e.severity??"unknown"}:${e.code??"issue"}:${e.blockId??"global"}:${e.location??""}`}function Vn(e){let t=!1;const n=e=>{if(Array.isArray(e))for(const o of e)o&&"object"==typeof o&&("text"===o.key&&"dynamic"===o.contentType&&"bn-BD"===o.dynamicAiLanguage&&(t=!0),Array.isArray(o.children)&&n(o.children))};return n(Array.isArray(e)?e:[]),t?"bn-BD":"en"}function Kn(e,t=!1){if(null==e||""===String(e).trim())return t;const n=String(e).trim();try{return/^https?:\/\//i.test(n)?new URL(n):new URL("https://"+n),!0}catch{return!1}}const Gn={text:"Text",heading:"Heading",button:"Button",image:"Image",video:"Video",avatar:"Profile image",menu:"Menu",social_link:"Social links",raw_html:"HTML"};const qn={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 Jn(e,t,n){const o=e.containerType??"none",a=function(e){const t=e??"none";return qn[t]?qn[t]:String(t).replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}(o);return n<=1?a:"none"===o?`${Yn(t+1)} section`:`${Yn(t+1)} ${a} block`}function Yn(e){const t=e%10,n=e%100;return 1===t&&11!==n?`${e}st`:2===t&&12!==n?`${e}nd`:3===t&&13!==n?`${e}rd`:`${e}th`}function Xn(e,t){return t<=1?null:`${Yn(e+1)} of ${t} stacked blocks`}function Zn(e,t,n,o){const a=function(e){return Gn[e]?Gn[e]:String(e||"block").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}(t),l=[...e];o&&l.push(o);const i=l.length>0?l.join(" → "):"Email body";return n?`${a} ("${n}") — ${i}`:`${a} — ${i}`}function Qn(e,t){const n=function(e){return null==e||"object"!=typeof e?{...On,styles:{...On.styles}}:{preHeader:null!=e.preHeader?e.preHeader:On.preHeader,contentWidth:v(null!=e.contentWidth?e.contentWidth:On.contentWidth),stackColumnsOnMobile:!1!==e.stackColumnsOnMobile,scaleFontOnMobile:!1!==e.scaleFontOnMobile,styles:{backgroundColor:null!=e.styles?.backgroundColor?e.styles.backgroundColor:On.styles.backgroundColor,contentBg:null!=e.styles?.contentBg?e.styles.contentBg:On.styles.contentBg,color:null!=e.styles?.color?e.styles.color:On.styles.color,headingColor:null!=e.styles?.headingColor?e.styles.headingColor:On.styles.headingColor,linkColor:null!=e.styles?.linkColor?e.styles.linkColor:On.styles.linkColor,fontFamily:null!=e.styles?.fontFamily?e.styles.fontFamily:On.styles.fontFamily}}}(e);("number"!=typeof n.contentWidth||!Number.isFinite(n.contentWidth)||n.contentWidth<=0)&&t.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()||t.push({severity:"error",code:"body_background_color_missing",message:"Theme background color is missing.",location:"Theme settings"}),null!=o.color&&""!==String(o.color).trim()||t.push({severity:"error",code:"body_text_color_missing",message:"Theme text color is missing.",location:"Theme settings"}),null!=o.fontFamily&&""!==String(o.fontFamily).trim()||t.push({severity:"error",code:"body_font_family_missing",message:"Theme font family is missing.",location:"Theme settings"})}function eo(e,t){e.push(t)}function to(e){return null==e?"":String(e).replace(/&amp;/gi,"&").replace(/&quot;/gi,'"').replace(/&#39;/g,"'").trim()}function no(e){if(null==e||"string"!=typeof e)return[];const t=[],n=/<a\b[^>]*?\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>"']+))/gi;let o=n.exec(e);for(;o;){const a=o[1]??o[2]??o[3]??"";t.push(to(a)),o=n.exec(e)}return t}function oo(e,t=!0){const n=String(e??"").trim();return n?Wn(n)?null:g(n,!1,{allowMailtoTel:t}):null}function ao(e,t,n,o){const a=e.linkURL,l=()=>Zn(t,"button",void 0,o),i=e.id??null;null==a||""===String(a).trim()?eo(n,{severity:"warning",code:"button_empty_link",message:'Button link URL is empty; will be saved as href="https://".',location:l(),blockId:i}):c(a)?eo(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:l(),blockId:i}):Wn(a)||p(a,!1,{allowMailtoTel:!0})||eo(n,{severity:"warning",code:"button_invalid_link",message:"Button link URL format is invalid.",location:l(),blockId:i}),function(e,t,n,o,{invalidCode:a,invalidMessage:l,blockedCode:i,blockedMessage:r}){no(e??"").forEach((e,s)=>{const d=String(e??"").trim();""!==d&&(c(d)?eo(t,{severity:"error",code:i,message:r,location:n(s),blockId:o}):p(d,!1,{allowMailtoTel:!0})||eo(t,{severity:"warning",code:a,message:l,location:n(s),blockId:o}))})}(e.text,n,e=>Zn(t,"button",`label link ${e+1}`,o),i,{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."})}const lo=["product"];const io=/^\s*\{\{[\s\S]*\}\}\s*$/;function ro(e,t,n,o,a,l){(function(...e){const t=new Set,n=[];for(const o of e)if(null!=o&&""!==String(o).trim())for(const e of no(String(o))){const o=String(e).trim();o&&!t.has(o)&&(t.add(o),n.push(e))}return n})(e.text,e.dynamicSelectedContent).forEach((l,i)=>{const r=String(l??"").trim();""!==r&&(r.startsWith("#")||io.test(r)||(c(r)?eo(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:Zn(t,o,`link ${i+1}`,a),blockId:e.id??null}):p(r,!1,{allowMailtoTel:!0})||eo(n,{severity:"warning",code:"text_invalid_link",message:"Text link URL format is invalid.",location:Zn(t,o,`link ${i+1}`,a),blockId:e.id??null})))});if("dynamic"!==(e.contentType??"static"))return;const i=e.dynamicSelectedContent,r=null!=e?.id?l?.[e.id]?.selectedContent:void 0;let s=null!=i&&""!==String(i).trim()?i:r;var d;null!=s&&""!==String(s).trim()||null==e.text||""===(null==(d=e.text)?"":String(d).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())||(s=e.text),null!=s&&""!==String(s).trim()||eo(n,{severity:"warning",code:"dynamic_content_empty",message:"Dynamic content not generated; export will use static text if available.",location:Zn(t,o,void 0,a),blockId:e.id??null})}function so(e,t,n,o){const a=e.list||[],l=new Set;a.forEach((a,i)=>{const r=a.title||a.image||`link ${i+1}`,s=e=>Zn(t,"social_link",e||r,o),d=function(e){const t=String(e?.image||"").trim();if(t)return`img:${t}`;const n=String(e?.title||"").trim().toLowerCase();return n?`title:${n}`:null}(a);d&&(l.has(d)?eo(n,{severity:"warning",code:"social_duplicate_platform",message:"Duplicate social platform in this block; only one entry per platform should be kept.",location:s(r),blockId:e.id??null}):l.add(d));const u=a.linkURL;if(null==u||""===String(u).trim()){const t=String(a?.title||"").trim()||`Item ${i+1}`;eo(n,{severity:"warning",code:"social_empty_link",message:`${t} URL is empty — this icon will be hidden in sent emails.`,location:s(r),blockId:e.id??null})}else c(u)?eo(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(r),blockId:e.id??null}):p(u,!1,{allowMailtoTel:!1})||eo(n,{severity:"warning",code:"social_invalid_link",message:"Social link URL format is invalid.",location:s(r),blockId:e.id??null});const m=a.image;null==m||""===String(m).trim()?eo(n,{severity:"warning",code:"social_empty_icon",message:"Social link icon URL is empty; icon will not display.",location:s(r),blockId:e.id??null}):Kn(m,!1)||eo(n,{severity:"warning",code:"social_invalid_icon",message:"Social link icon URL format is invalid.",location:s(r),blockId:e.id??null})}),0===a.length&&eo(n,{severity:"info",code:"social_no_links",message:"Social link block has no links.",location:Zn(t,"social_link",void 0,o),blockId:e.id??null})}function co(e,t,n,o,a){if(!Array.isArray(e))return;const l=e.length;e.forEach((e,i)=>{if(!e||"object"!=typeof e)return;const r=e.key;if("column"===r){const r=Jn(e,i,l),s=[...t,r];return function(e,t,n){const o=e.containerType??"none";if(!lo.includes(o))return;const a=e.children??[],l=e.columnProducts??[];a.forEach((o,i)=>{const r=l[i];if(null==r||"object"==typeof r&&!r.id){const o=a.length>1?`Column ${i+1} of ${a.length}`:"This column",l=[...t,o].join(" → ");eo(n,{severity:"warning",code:"container_product_not_assigned",message:"A product is not assigned to this column; assign a product in Container settings.",location:l,blockId:e.id??null})}})}(e,s,n),void(Array.isArray(e.children)&&co(e.children,s,n,o,a))}if("content"===r){const r=l>1?`Column ${i+1} of ${l}`:null,s=r?[...t,r]:t;return void(Array.isArray(e.children)&&co(e.children,s,n,o,a))}const s=Xn(i,l);switch(r){case"image":!function(e,t,n,o){const a=e.src,l=()=>Zn(t,"image",void 0,o);null!=a&&""!==String(a).trim()?(Kn(a,!1)||eo(n,{severity:"warning",code:"image_invalid_src",message:"Image URL format is invalid.",location:l(),blockId:e.id??null}),It(e)&&oo(e.linkURL,!0)&&eo(n,{severity:"warning",code:"image_invalid_link",message:"Image link URL format is invalid.",location:l(),blockId:e.id??null}),null!=e.alt&&""!==String(e.alt).trim()||eo(n,{severity:"info",code:"image_empty_alt",message:"Image alt text is empty; consider adding for accessibility.",location:l(),blockId:e.id??null})):eo(n,{severity:"error",code:"image_empty_src",message:"Image URL is empty; the image will not display.",location:l(),blockId:e.id??null})}(e,t,n,s);break;case"video":!function(e,t,n,o){const a=()=>Zn(t,"video",void 0,o),l=null!=e.videoUrl?String(e.videoUrl).trim():"";l?Kn(l,!1)||eo(n,{severity:"warning",code:"video_invalid_url",message:"Video URL format may be invalid.",location:a(),blockId:e.id??null}):eo(n,{severity:"error",code:"video_empty_url",message:"Video URL is empty; the video will not display.",location:a(),blockId:e.id??null})}(e,t,n,s);break;case"avatar":!function(e,t,n,o){const a=e.src,l=()=>Zn(t,"avatar",void 0,o);null==a||""===String(a).trim()?eo(n,{severity:"warning",code:"avatar_empty_src",message:"Avatar image URL is empty; avatar will not display.",location:l(),blockId:e.id??null}):Kn(a,!1)||eo(n,{severity:"warning",code:"avatar_invalid_src",message:"Avatar image URL format is invalid.",location:l(),blockId:e.id??null}),oo(e.linkURL,!0)&&eo(n,{severity:"warning",code:"avatar_invalid_link",message:"Avatar link URL format is invalid.",location:l(),blockId:e.id??null})}(e,t,n,s);break;case"button":ao(e,t,n,s);break;case"menu":!function(e,t,n,o){const a=e.list||[];a.forEach((a,l)=>{const i=e=>Zn(t,"menu",e||`Item ${l+1}`,o);null!=a.label&&""!==String(a.label).trim()||eo(n,{severity:"info",code:"menu_empty_label",message:'Menu item label is empty; will show as "Link".',location:i(`item ${l+1}`),blockId:e.id??null});const r=a.url;null==r||""===String(r).trim()?eo(n,{severity:"warning",code:"menu_empty_url",message:'Menu item URL is empty; will be saved as href="#".',location:i(a.label||`item ${l+1}`),blockId:e.id??null}):c(r)?eo(n,{severity:"error",code:"menu_blocked_scheme",message:"Menu item URL uses a blocked scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",location:i(a.label||`item ${l+1}`),blockId:e.id??null}):p(r,!1,{allowMailtoTel:!0})||eo(n,{severity:"warning",code:"menu_invalid_url",message:"Menu item URL format is invalid.",location:i(a.label||`item ${l+1}`),blockId:e.id??null})}),0===a.length&&eo(n,{severity:"info",code:"menu_no_items",message:"Menu block has no items.",location:Zn(t,"menu",void 0,o),blockId:e.id??null})}(e,t,n,s);break;case"social_link":so(e,t,n,s);break;case"raw_html":!function(e,t,n,o){const a=e.html;null!=a&&""!==String(a).trim()||eo(n,{severity:"info",code:"raw_html_empty",message:"HTML block has no custom markup; export will include an empty wrapper.",location:Zn(t,"raw_html",void 0,o),blockId:e.id??null})}(e,t,n,s);break;case"text":ro(e,t,n,"text",s,a);break;case"heading":ro(e,t,n,"heading",s,a)}})}function uo({blockList:e,bodySettings:t,aiContentRefs:n={}}){const o=[];return Qn(t,o),co(Array.isArray(e)?e:[],[],o,t,n),o}function mo(){const e="undefined"!=typeof window&&null!=window?window:"undefined"!=typeof global&&null!=global?global:void 0;if(!e)return;const t=e.Image;return"function"==typeof t?t:void 0}const po=/^\{\{\s*[\w.]+\s*\}\}$/;function go(e){if(null==e||""===String(e).trim())return null;const t=String(e).trim();if(function(e){return null!=e&&"string"==typeof e&&po.test(e.trim())}(t))return null;if(/^https?:\/\//i.test(t))return Kn(t,!1)?t:null;if(t.startsWith("//")){const e=`https:${t}`;return Kn(e,!1)?e:null}return null}function ho(e,t=[],n=e?.length??0){const o=[];return Array.isArray(e)?(e.forEach((e,a)=>{if(!e||"object"!=typeof e)return;const l=e.key;if("column"===l){const l=Jn(e,a,n),i=[...t,l],r=e.children;return void o.push(...ho(r,i,r?.length??0))}if("content"===l){const l=n>1?`Column ${a+1} of ${n}`:null,i=l?[...t,l]:t,r=e.children;return void o.push(...ho(r,i,r?.length??0))}const i=Xn(a,n);if("image"===l){const n=go(e.src);n&&o.push({url:n,location:Zn(t,"image",void 0,i),blockId:e.id??null})}}),o):o}function bo(e,t=12e3){const n=mo();if(!n)return Promise.resolve(!1);const o=String(e).trim();return o?new Promise(e=>{const a=new n;let l=!1;const i=t=>{l||(l=!0,clearTimeout(r),a.onload=null,a.onerror=null,e(t))},r=setTimeout(()=>i(!1),t);a.onload=()=>i(!0),a.onerror=()=>i(!1);try{a.src=o}catch{i(!1)}}):Promise.resolve(!1)}async function yo(e,t={}){const{timeoutMs:n=12e3,concurrent:o=6}=t;if(!mo())return[];const a=ho(Array.isArray(e)?e:[]);if(0===a.length)return[];const l=new Map;for(const e of a)l.has(e.url)||l.set(e.url,[]),l.get(e.url).push(e.location);const i=[...l.keys()],r=new Map;let s=0;const c=Math.max(1,Math.min(o,i.length));await Promise.all(Array.from({length:c},()=>async function(){for(;s<i.length;){const e=s++,t=i[e],o=await bo(t,n);r.set(t,o)}}()));const d=[];for(const[e,t]of l)if(!0!==r.get(e))for(const n of t)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:a.find(t=>t.url===e&&t.location===n)?.blockId??null});return d}async function _o(e,t){return[...uo(e),...await yo(e?.blockList??[],t)]}const fo=(...e)=>e.filter(Boolean).join(" ");function xo(e){return"string"!=typeof e?e:e.replace(/\u202E/g,"").replace(/\u202D/g,"").replace(/\u202A/g,"").replace(/\u202B/g,"").replace(/\u202C/g,"").replace(/\sdir\s*=\s*["']rtl["']/gi,' dir="ltr"').replace(/\sstyle\s*=\s*["']([^"']*)["']/gi,(e,t)=>{const n=String(t||"").replace(/\s*direction\s*:\s*rtl\s*;?/gi,"").trim();return n?` style="${n}"`:""})}function ko(e){if("string"!=typeof e||!e)return{masked:e||"",tokens:[]};const t=[];return{masked:e.replace(/\{\{[^{}]+\}\}/g,e=>(t.push(e),`${t.length-1}`)),tokens:t}}function vo(e,t){if("string"!=typeof e||!t.length)return e;let n=e;for(let e=t.length-1;e>=0;e--){const o=`${e}`;n=n.split(o).join(t[e])}return n}const wo={drag_block_here:"请将模块拖放到此处",drop_content_here:"将内容拖放到此处",drop_content_hint:"从左侧拖拽模块到此处,或单击插入。",drag_section_here:"将版块拖放到此处",blocks:"模块",photos:"图片",powered_by_pexels:"图片由Pexels提供",loading:"加载中...",content:"内容",typography:"排版",compliance_approx_kb:"约 {{n}} KB",styles:"样式",ai_powered:"AI 驱动",layout:"布局",components:"组件",presets:"预设",body_settings:"邮件主题设置",global:"全局",text_and_headings:"文本与标题",pre_header:"预标题",pre_header_description:"预标题是在收件箱中查看电子邮件时跟随主题行的简短摘要文本。",confirm:"确认",cancel:"取消",add_blocks:"请添加块",block_product:"产品",block_product_single:"单个",block_product_multi:"多个",block_discount:"折扣",block_introduction:"引言",block_body:"正文",block_header:"页眉",block_footer:"页脚",no_product_found:"未找到产品",no_products_matching_search:"没有符合搜索条件的产品。清空搜索可查看完整列表。",load_more_products:"加载更多",add_products:"添加产品",add_products_in_store:"请在店铺中添加产品。",column:"列",columns:"列排版",column_settings:"列设置",column_cells_section:"列单元格",column_wrapper_style:"外层样式",column_styles:"列样式",size_px:"尺寸",column_delete:"删除列",column_delete_desc:"您确定删除多余的{{count}}列吗?",block_palette_section:"版块",block_palette_columns:"分栏",settings_title_column_layout:"栏位设置",container:"版块",select_parent_section_tooltip:"父级版块设置 — 布局、间距与背景",container_settings:"版块设置",layers_panel:"图层",email_styles_section:"邮件样式",document_section:"文档",body_bg_color_short:"背景色",body_content_bg_short:"正文背景",body_width_label:"宽度",body_font_short:"字体",body_text_short:"正文",body_heading_short:"标题",body_link_short:"链接",type_styles_section:"文字",container_type:"版块类型",container_type_help:"决定该版块可用的变量和产品映射。",container_type_none:"默认",container_type_header:"页眉",container_type_discount:"折扣",container_type_introduction:"引言",container_type_body:"正文",container_type_product:"产品",container_type_hero_product:"主推产品",container_type_additional_product:"附加产品",container_type_footer:"页脚",product_role:"产品角色",product_role_main_hero:"主推产品",product_role_additional:"附加产品",assign_product_to_column:"为列分配产品",text:"文本",text_content:"这是一个文本,点击修改文本",text_settings:"文本设置",text_styles:"文本样式",text_align:"文本对齐方式",heading:"标题",heading_content:"这是一个标题,点击修改标题",heading_settings:"标题设置",heading_type:"标题类型",button:"按钮",button_settings:"按钮设置",button_action:"点击按钮触发",button_styles:"按钮样式",button_padding:"按钮内边距",spacer:"间距",spacer_block:"间距块",spacer_settings:"间距设置",divider:"分割线",divider_settings:"分割线设置",divider_type:"分割线类型",divider_styles:"分割线样式",image:"图片",image_settings:"图片设置",image_crop_soon:"图片裁剪功能尚未开放。",crop:"裁剪",replace:"替换",delete:"删除",image_max_upload_size:"最大 10 MB",video:"视频",video_settings:"视频",video_tab_styles:"样式",video_tab_display:"显示",video_url:"视频地址",video_thumbnail_url:"自定义封面图 URL",video_thumbnail_url_placeholder:"留空则使用 YouTube 默认封面",video_export_note:"邮件客户端通常显示封面图链接,而不是内嵌播放器。",video_thumbnail_layout:"封面布局",video_width:"宽度 (W)",video_height:"高度 (H)",video_fill_column:"铺满列宽",video_fill_column_mobile:"移动端铺满列宽",alignment:"对齐",video_area_section:"视频区域",video_block_section:"区块",video_border_none:"无",image_action:"点击图片跳转",image_url:"图片URL",image_alt:"图片alt",image_alt_placeholder:"为屏幕阅读用户描述图片",image_styles:"图片样式",image_source:"图片来源",image_source_url:"输入URL",image_source_upload:"上传图片",image_upload:"上传",image_upload_click:"点击上传",image_upload_not_configured:"未配置图片上传。请在 apiConfig 中设置 imageUploadEndpoint,或传入 null 关闭;默认使用内置 API 根地址。",image_uploaded:"图片上传成功",image_upload_failed:"图片上传失败",image_upload_error:"上传图片时出错",image_upload_file_hint:"PNG、JPEG、GIF、SVG、WebP,最大 10 MB",image_upload_invalid_type:"请使用 PNG、JPEG、GIF、SVG 或 WebP 格式。",uploading:"上传中…",image_source_variable:"使用变量",menu:"导航栏",menu_settings:"导航栏设置",menu_items:"菜单项",menu_item:"菜单项",menu_styles:"菜单样式",add_new_item:"添加新项",label:"标签",page:"页面",url:"链接地址",target:"打开方式",same_tab:"当前窗口",new_tab:"新窗口",separator:"分隔符",menu_separator_placeholder:'例如 " | " 或 " • "',menu_separator_allowed_hint:"仅可使用:| • — / · 以及空格。",menu_link_gap:"链接间距",menu_underline_links:"链接下划线",logo_text_placeholder:"品牌名称",letter_spacing:"字间距",link_color:"链接颜色",menu_layout:"菜单布局",layout_mode:"布局模式",nav_only:"仅导航",stacked:"堆叠排列",logo_left:"Logo 在左",logo_right:"Logo 在右",logo_only:"仅 Logo",mobile_layout:"移动端布局",stack:"纵向堆叠",inline:"行内排列",logo_section:"Logo 区域",show_logo:"显示 Logo",logo_url:"Logo 地址",logo_text:"Logo 文字",logo_alt:"Logo 替代文字",logo_link:"Logo 链接",logo_max_width:"Logo 最大宽度",border_bottom:"底边框",show_border_bottom:"显示底边框",font_weight:"字重",font_weight_light:"细",font_weight_regular:"常规",font_weight_semibold:"半粗",font_weight_bold:"粗",text_transform:"字母大小写与样式",avatar:"头像",avatar_settings:"头像设置",avatar_image:"头像图片",avatar_border_radius:"圆角",social_link:"社交链接",add_social_link:"添加社交链接",social_link_size:"社交链接大小",icon_styles:"图标样式",icon_size:"图标大小",icon_size_small:"小",icon_size_medium:"中",icon_size_large:"大",icon_color:"图标颜色",icon_color_default:"默认",icon_color_white:"白色",icon_color_black:"黑色",icon_color_gray:"灰色",social_icon_spacing:"图标间距",social_links:"社交链接",social_link_settings:"社交链接设置",social_platform_x:"X",social_platform_formerly_twitter:"原 Twitter",social_platform_x_alt:"X(原 Twitter)",social_link_placeholder_facebook:"https://www.facebook.com/yourpage",social_link_placeholder_linkedin:"https://www.linkedin.com/company/yourcompany",social_link_placeholder_instagram:"https://www.instagram.com/yourhandle",social_link_placeholder_tiktok:"https://www.tiktok.com/@yourhandle",social_link_placeholder_x:"https://x.com/yourhandle",social_link_placeholder_youtube:"https://www.youtube.com/yourchannel",social_link_placeholder_pinterest:"https://www.pinterest.com/yourprofile",social_link_placeholder_generic:"https://example.com",raw_html:"HTML",raw_html_block:"自定义 HTML",raw_html_settings:"HTML 设置",raw_html_code_label:"代码",raw_html_code_hint:"导出邮件时将原样插入。为兼容各邮件客户端,建议使用表格布局与内联样式。",raw_html_default_content:'<p style="text-align:center;color:#A3A3A3;font-size:12px">在此添加自定义 HTML</p>',raw_html_appearance:"布局",raw_html_clear_background:"清除背景",raw_html_email_client_warning:"自定义 HTML 在不同邮件客户端中的表现可能不一致,请充分测试。",raw_html_info_tooltip_aria:"了解自定义 HTML",content_background_color:"内容背景颜色",container_background_image_title:"版块背景图",container_background_image_section_title:"版块背景图",container_background_image_section_toggle:"显示版块背景图设置",container_background_image_layout_group:"图片布局",container_background_image_row_label:"背景图",container_background_image_intro:"拖入该版块的文本、按钮、图片等会叠在背景图之上。请从左侧组件栏拖入画布中的该版块。",container_background_image_tooltip_p1:"背景图应用在版块的表格层上,兼容常见邮件客户端(不使用 position:absolute)。",container_background_image_tooltip_p2:"可用「内容背景颜色」为区块加蒙层或衬色,或设为透明以只显示照片。",container_background_image_enable:"启用背景图",container_background_image_url:"图片地址",container_background_image_upload:"上传图片",container_background_image_upload_click:"拖拽或选择图片",container_background_image_file_hint:"支持 .png、.jpg、.jpeg、.gif、.webp。单文件最大 10 MB。",container_background_image_select_button:"选择图片",container_background_image_clear:"移除背景图",container_background_image_size:"图片适配",container_background_image_position:"焦点位置",container_bg_size_cover:"覆盖(裁切)",container_bg_size_contain:"包含(完整)",container_bg_size_fill:"填充",image_file_too_large:"图片大小不能超过 10 MB。",container_bg_image_url_error_blocked_scheme:"该地址使用了不允许的协议。图片请仅使用 http:// 或 https://。",container_bg_image_url_error_duplicate_protocol:"地址中重复了协议前缀,请只保留一个,例如 https://。",container_bg_image_url_error_hostname:"请填写带有效域名的完整地址(例如 https://cdn.example.com/photo.jpg)。",container_bg_image_url_error_invalid_protocol:"不支持的协议。图片地址请使用 http:// 或 https://。",container_bg_image_url_error_generic:"图片地址格式无效。",container_bg_image_preview_failed:"无法加载预览:该地址可能不是图片,或服务器不允许嵌入显示。",image_text_overlay:"文字叠层",overlay_multi_item:"多段文本叠放",add_overlay_item:"添加叠层项",drag_to_move:"拖动排序",overlay_max_width:"叠层最大宽度",item_gap:"项间距",scrim:"背景蒙层",text_shadow:"文字阴影",fill_column:"填满列宽",image_text_overlay_tip:"可选:在图片上显示简短说明。若要在照片上排版多块内容,请使用版块背景图。",image_text_overlay_container_tip:"选中版块 → 样式 → 版块背景图,再将文字、按钮等拖入该版块。",image_text_overlay_enable:"启用文字叠层",image_overlay_caption:"说明文字",image_overlay_caption_placeholder:"一行简短文字…",image_overlay_position:"说明位置",image_overlay_pos_tl:"左上",image_overlay_pos_tc:"上中",image_overlay_pos_tr:"右上",image_overlay_pos_ml:"左中",image_overlay_pos_mc:"正中",image_overlay_pos_mr:"右中",image_overlay_pos_bl:"左下",image_overlay_pos_bc:"下中",image_overlay_pos_br:"右下",image_overlay_box_bg:"说明框背景(CSS)",image_overlay_padding:"说明内边距",background_color:"背景颜色",text_color:"文本颜色",email_theme_background_color:"邮件主题色",heading_color:"标题颜色",content_background:"内容区背景",font_color:"字体颜色",button_color:"按钮颜色",divider_color:"分割线颜色",action_type:"按钮类型",top:"上",right:"右",left:"左",bottom:"下",line_height:"行高",link:"超链接",link_url:"超链接URL",link_url_placeholder:"example.com",padding_settings:"内边距设置",width_auto:"宽度自适应",auto_width:"自动宽度",width:"宽度",height:"高度",font_size:"字体大小",font_family:"字体",align:"对齐方式",solid:"实线",dotted:"虚线(点)",dashed:"虚线(破折号)",spacing:"间距",border_radius:"圆角",link_all_sides:"联动四边",padding_link_sides_label:"四边使用相同内边距",padding_link_sides_tooltip:"开启后只需输入一个数值,将同时应用到上、右、下、左四面。关闭后可分别设置每一侧。",email_width_mode:"宽度",email_width_default:"邮件宽度(默认)",custom_px:"自定义像素",custom_width_px:"自定义宽度",full_bleed:"全幅铺满",full_bleed_tooltip:"在支持的客户端中可延展到边缘;不支持时会限制在邮件宽度内。",export_html:"导出html",export_json:"导出JSON",export_checking_images:"正在检查图片…",language_zh:"中文",export_validation_title:"导出前校验",export_validation_issues_found:"导出前发现以下问题",export_validation_errors:"错误",export_validation_warnings:"警告",export_validation_info:"提示",export_anyway:"仍要导出",ignore:"忽略",validation_body_content_width_invalid:"邮件内容宽度须在 280–1200 px 之间。",validation_body_background_color_missing:"主题背景色未设置。",validation_body_text_color_missing:"主题文字颜色未设置。",validation_body_font_family_missing:"主题字体未设置。",validation_image_empty_src:"图片地址为空,图片将无法显示。",validation_image_invalid_src:"图片地址格式无效。",validation_image_invalid_link:"图片链接地址格式无效。",validation_image_url_not_loadable:"图片地址无法加载或预览;链接可能已失效、过期或被拦截。",validation_image_empty_alt:"图片未设置 alt 文本,建议添加以提升可访问性。",validation_avatar_empty_src:"头像图片地址为空,头像将无法显示。",validation_avatar_invalid_src:"头像图片地址格式无效。",validation_avatar_invalid_link:"头像链接地址格式无效。",validation_button_empty_link:'按钮链接为空,将被保存为 href="https://"。',validation_button_invalid_link:"按钮链接格式无效。",validation_button_blocked_scheme:"按钮链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",validation_button_label_invalid_link:"按钮文案中的链接地址格式无效。",validation_button_label_blocked_link_scheme:"按钮文案中的链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",validation_rich_text_link_invalid:"富文本超链接地址格式无效。",validation_rich_text_link_blocked_scheme:"富文本链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",validation_menu_empty_label:"菜单项标签为空,将显示为「链接」。",validation_menu_empty_url:'菜单项链接为空,将被保存为 href="#"。',validation_menu_invalid_url:"菜单项链接格式无效。",validation_menu_blocked_scheme:"菜单项链接使用了被禁止的协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",validation_menu_no_items:"菜单块没有任何项。",validation_raw_html_empty:"HTML 块没有自定义代码;导出将只有空的外层容器。",validation_social_empty_link:'社交链接地址为空,将被保存为 href="https://"。',validation_social_invalid_link:"社交链接地址格式无效。",validation_social_blocked_scheme:"社交链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s) 地址(例如 www.example.com 或 https://…)。",validation_social_empty_icon:"社交链接图标地址为空,图标将无法显示。",validation_social_invalid_icon:"社交链接图标地址格式无效。",validation_social_no_links:"社交链接块没有任何链接。",validation_social_duplicate_platform:"社交链接块中存在重复平台,每个平台仅应保留一条。",section_nest_not_allowed:"版块不能嵌套在另一版块内,请在版块之间的堆叠区域释放。",validation_container_product_not_assigned:"该列未分配产品;请在版块设置中分配产品。",validation_dynamic_content_empty:"未生成动态内容;导出将使用静态文本(如有)。",validation_text_invalid_link:"文本链接地址格式无效。",validation_text_blocked_link_scheme:"文本链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",tooltip_bold:"加粗",tooltip_italic:"斜体",tooltip_underline:"下划线",tooltip_strikethrough:"删除线",tooltip_align_left:"居左",tooltip_align_center:"居中",tooltip_align_right:"居右",tooltip_ordered_list:"有序列表",tooltip_unordered_list:"无序列表",tooltip_link:"超链接",tooltip_remove_link:"删除超链接",add_link_modal_title:"添加超链接",content_type:"内容类型",content_type_static:"静态",content_type_dynamic:"动态",ai_enabled:"使用 AI 撰写",text_and_content_type:"内容类型",heading_or_body:"标题",body_paragraph:"正文",heading_h1:"H1",heading_h2:"H2",heading_h3:"H3",heading_h4:"H4",variables:"变量",insert_merge_field:"选择或输入变量...",dynamic_prompt_help:"写下你的提示",ai_output_language:"AI 输出语言",ai_output_language_en:"英语",ai_output_language_bn:"孟加拉语",generate:"生成",ml_generation_failed:"无法生成 AI 内容",ml_ai_unavailable:"AI 生成需要分栏布局、公司 ID、模板 ID 和 ML 接口。请将文本放在栏目内并检查 apiConfig。",ml_no_variations:"未返回任何建议。请更换提示词或确认服务器上存在该模板。",ml_generation_unexpected_error:"生成内容时发生意外错误。",sample_ai_content:"示例 AI 内容",select_content:"选择内容",variable_dynamic_placeholder:"无(可选)",variable_display_text:"展示文案",variable_introduction:"引言",variable_heading:"标题",variable_subheading:"副标题",variable_products_description:"产品描述",variable_customer_name:"客户姓名",variable_introduction_title:"引言标题",variable_introduction_subtitle:"引言副标题",variable_body_title:"正文标题",variable_body_subtitle:"正文副标题",variable_discount_value:"折扣力度",variable_discount_code:"折扣码",variable_valid_until:"有效期至",variable_company_name:"公司名称",variable_brand_name:"品牌名称",variable_address:"地址",variable_website:"网站",variable_logo_url:"Logo URL",variable_tagline:"标语",variable_nav_label:"导航文案",variable_nav_url:"导航链接",variable_product_name:"产品名称",variable_product_description:"产品描述",variable_product_image:"产品图片 URL",variable_product_link:"产品链接",variable_product_price:"产品价格",variable_product_currency:"货币",variable_product_old_price:"原价",variable_product_new_price:"现价",variable_product_price_display:"产品价格展示",variable_image_logo:"Logo",variable_image_hero_banner:"主图横幅",variable_image_footer_banner:"页脚横幅",variable_image_product_image:"产品图片",variable_cta_label:"CTA 文案",variable_cta_url:"CTA 链接",button_label_variable:"按钮文案(变量)",button_url_variable:"使用变量",button_text:"按钮文案",button_label_manual:"输入文案",button_url_manual:"输入链接",use_company_social_links:"使用公司社交链接",use_navigation_links:"使用导航链接",tooltip_container_type:"决定该版块可用的变量和产品映射。",tooltip_variables_static:"将合并字段插入内容,发送邮件时将被替换。",tooltip_dynamic_prompt:"描述语气或意图,我们将推荐示例内容。(预览模式 — 连接 AI API 后可生成真实内容。)",tooltip_write_using_ai:"开启后,可选择输出语言并输入提示生成多种示例。需配置 ML/API。",tooltip_write_using_ai_unavailable:"当前编辑器未开启 AI 写作。请在宿主应用或 API 中启用后再使用「使用 AI 撰写」。",label_align:"对齐",label_padding:"内边距",section_background_group:"区块背景",section_bg_mode:"类型",section_bg_color:"颜色",section_bg_image:"图片",section_bg_none:"无",section_content_area_group:"内容区",content_area_color:"内容底色",content_color_auto:"自动",content_color_custom:"自定义",shortcuts_modal_title:"键盘快捷键",shortcuts_modal_footnote:"在右侧设置面板的文本框中输入时快捷键会暂时停用,以便正常编辑链接和复制粘贴。",shortcut_save:"保存(由宿主页面接入时触发)",shortcut_undo:"撤销",shortcut_redo:"重做",shortcut_duplicate:"复制选中模块",shortcut_copy_block:"复制模块",shortcut_paste_block:"粘贴模块",shortcut_delete_block:"删除选中模块",shortcut_escape:"取消选中",shortcut_cheat_sheet:"打开此帮助",shortcut_delete_confirm_title:"删除此版块?",shortcut_delete_confirm_desc:"版块内仍有内容模块,确定要删除吗?",context_duplicate:"复制",context_copy:"复制到剪贴板",context_cut:"剪切",context_paste:"粘贴",context_delete:"删除",context_move_up:"上移",context_move_down:"下移",context_save_global:"保存为全局组件",context_reset_styles:"重置样式",topbar_back_to_templates:"模板",topbar_breadcrumb_email:"邮件",topbar_rename_template:"重命名模板",topbar_untitled_template:"未命名模板",send_test:"发送测试",preview:"预览",html_email_preview:"HTML 预览",html_email_preview_title:"HTML 邮件预览",html_email_preview_device_aria:"HTML 预览设备宽度",html_email_preview_error:"无法生成 HTML 预览,请查看控制台。",save_template:"保存模板",more_actions:"更多操作",keyboard_shortcuts:"键盘快捷键",high_contrast_on:"高对比度开",high_contrast_off:"高对比度关",desktop:"桌面",mobile:"移动",undo:"撤销",redo:"重做",save_state_saved:"已保存",save_state_saving:"保存中…",save_state_unsaved:"未保存",save_state_error:"保存失败",export_validation_open_block:"打开此区块",save:"保存",template_name:"模板名称",save_template_title:"保存模板",save_template_category:"分类",save_template_category_placeholder:"选择或输入分类…",category_promotional:"促销",category_transactional:"事务通知",category_newsletter:"Newsletter",category_onboarding:"Onboarding",category_announcement:"公告",category_other:"其他",send_test_title:"发送测试邮件",send_test_send:"发送测试",send_test_recipients:"收件人",send_test_recipients_placeholder:"name@example.com, another@example.com",send_test_recipients_hint:"按 Enter 或逗号可添加地址。",send_test_payload:"数据上下文",send_test_payload_none:"不附带数据",send_test_payload_profile:"用户资料数据",send_test_payload_event:"事件数据",send_test_prefix_label:"[TEST] 前缀",send_test_prefix_hint:"在邮件主题前添加 [TEST]。",universal:"通用",layers:"图层",document:"文档",layer_one:"个区块",layer_many:"个区块",layer_move_up:"上移",layer_move_down:"下移",layer_duplicate:"复制",layer_delete:"删除",universal_saved_blocks:"已保存区块",universal_empty_state_line_1:"还没有通用内容。点击",universal_empty_state_line_2:"可将区块保存以在其他模板中复用。",universal_used_in_count:"已使用 {{count}}",compliance:"合规",compliance_preflight:"发送前检查",compliance_all_clear_title:"准备就绪",compliance_all_clear_desc:"所有合规检查均已通过。",compliance_severity_error:"错误",compliance_severity_warning:"警告",compliance_severity_info:"信息",compliance_tab_badge_label:"未解决问题:{{count}}",compliance_email_size:"邮件大小(估算)",compliance_above_clip:"已超过 Gmail 约 102 KB 折叠阈值,收件箱中可能会被截断显示。",compliance_below_clip:"低于 Gmail 折叠阈值",right_panel_empty_hint:"点击画布中的任意区块以编辑其特定设置。从左侧栏拖动区块以添加新内容。",right_panel_back:"返回",layer_show:"显示",layer_hide:"隐藏",save_as_universal:"保存为通用区块",universal_save_modal_title:"保存为通用区块",universal_save_modal_subtitle:"可在多个模板中复用。编辑不会影响已发送的邮件。",universal_save_modal_placeholder:"例如:Beantown 页脚",universal_save_modal_confirm:"保存区块",universal_save_success:"已保存为通用区块:{{name}}",universal_save_error:"保存失败,请检查网络后重试。",universal_delete:"删除",universal_delete_confirm_title:"移除已保存区块?",universal_delete_confirm_body:"将从素材库中移除,已发送邮件不受影响。",universal_delete_confirm_ok:"移除",configure_columns_title:"配置分栏",configure_columns_subtitle:"选择一种布局。每一列初始为空,可拖入区块。",configure_columns_insert:"插入版块",configure_columns_hint:"点击配置布局",configure_columns_row_count:"插入行数:",standard_layout:"标准布局",grid_layout:"6/12 栅格",grid_settings:"网格",grid_rows_locked_hint:"邮件分栏为单行布局,行数固定为 1。",columns_layout:"分栏布局",column_sizes:"列宽 (%)",show_more:"展开",show_less:"收起",col:"列",gaps:"间距",column_gap:"列间距",button_variant:"样式变体",full_width:"全宽",hover_bg_color:"悬停背景色",hover_text_color:"悬停文字颜色",text_decoration:"文本装饰",shadow:"阴影",shadow_preset:"预设",table:"表格",table_settings:"表格设置",footer_settings:"页脚设置",cell_content:"单元格内容",add_link_url:"链接地址",add_link_display_text:"显示文本",add_link_display_text_placeholder:"留空则保留当前选中文本",add_link_display_text_empty_badge:"未填写 — 将使用选中的文字作为链接文字",add_link_open_new_tab:"在新标签页打开",align_left:"左对齐",align_center:"居中对齐",align_right:"右对齐",minimize_toolbar:"收起",close_text_editor:"退出文本编辑",unlink_universal:"解除当前副本关联",unlink_modal_title:"编辑通用区块",unlink_modal_keep:"保持关联",unlink_modal_unlink:"仅解绑当前副本",unlink_modal_body:"该区块当前关联到通用内容。直接编辑会影响所有使用该通用区块的位置。",unlink_modal_body2:"选择“仅解绑当前副本”可只在当前模板独立编辑;选择“保持关联”则继续联动所有实例。",custom:"自定义",custom_color:"自定义颜色",show_text_label:"显示文字标签",mobile_optimization:"移动端优化",stack_columns_on_mobile:"移动端堆叠栏目",scale_font_on_mobile:"移动端缩小字体",section_layout:"版块布局",content_max_width:"内容最大宽度",min_height:"最小高度",border:"边框",border_style:"边框样式",border_width:"边框宽度",border_color:"边框颜色",visibility:"可见性",hidden_on_mobile:"在移动端隐藏",table_structure:"表格结构",rows:"行",header_row:"标题行",header_column:"标题列",cell_selector:"单元格选择器",cell_content_type:"单元格内容类型",table_style:"表格样式",cell_padding:"单元格内边距",header_style:"标题样式",header_background:"标题背景",header_text_color:"标题文字颜色",striped_rows:"斑马纹行",stripe_color:"斑马纹颜色",table_structure_mode:"模式",table_mode_static:"静态",table_mode_dynamic:"动态",table_dynamic_structure_hint:"导出仍为静态 HTML;数据驱动表格或将在后续版本接入。",table_add_row:"添加行",table_add_column:"添加列",table_decrease_rows:"减少行数",table_increase_rows:"增加行数",table_decrease_cols:"减少列数",table_increase_cols:"增加列数",table_selected_cell:"已选:第 {{row}} 行,第 {{col}} 列",table_select_cell_hint:"在网格中点击单元格以编辑内容。",table_cell_grid_truncated:"仅显示前 {{rows}} × {{cols}} 格",table_cell_text_placeholder:"单元格文字…",table_align_left:"左对齐",table_align_center:"居中",table_align_right:"右对齐",footer_sections:"页脚区块",show_brand:"品牌信息",brand_name:"品牌名称",brand_tagline:"品牌标语",show_address:"地址",address:"地址文本",show_unsubscribe:"退订链接",unsubscribe_text:"链接文案",unsubscribe_url:"退订链接 URL",show_social:"社交图标",social_icons_hint:"请在该区块的内容设置里配置社交图标。",show_secondary_links:"次级链接",show_copyright:"版权信息",copyright_text:"版权文本",footer_style:"页脚样式",padding_top:"顶部内边距",padding_bottom:"底部内边距",show_divider:"显示分割线"},jo={drag_block_here:"Drag block here",drop_content_here:"Drop content here",drop_content_hint:"Drag blocks from the left, or click to insert.",drag_section_here:"Drag section here",blocks:"Blocks",photos:"Photos",powered_by_pexels:"Powered by Pexels",loading:"Loading...",content:"Content",typography:"Typography",styles:"Styles",ai_powered:"AI powered",layout:"Layout",components:"Components",presets:"Presets",body_settings:"Theme Settings",global:"Global",text_and_headings:"Text and headings",pre_header:"Pre-header",pre_header_description:"The pre-header is a short summary text that follows the subject line when viewing an email in the inbox.",confirm:"Confirm",cancel:"Cancel",add_blocks:"Add blocks",block_product:"Product",block_product_single:"Single",block_product_multi:"Multi",block_discount:"Discount",block_introduction:"Introduction",block_body:"Body",block_header:"Header",block_footer:"Footer",no_product_found:"No product found",no_products_matching_search:"No products match your search. Clear the search to see the full list.",load_more_products:"Load more",add_products:"Add products",add_products_in_store:"Add products in your store.",column:"Column",columns:"Columns",column_settings:"Column Settings",column_cells_section:"Column cells",column_wrapper_style:"Wrapper style",column_styles:"Column Styles",size_px:"Size",column_delete:"Delete Column",column_delete_desc:"Are you sure you want to delete {{count}} extra columns? ",block_palette_section:"Section",block_palette_columns:"Column",settings_title_column_layout:"Column settings",container:"Section",select_parent_section_tooltip:"Parent section settings — layout, spacing, and background",container_settings:"Section settings",layers_panel:"Layers",email_styles_section:"Email styles",document_section:"Document",body_bg_color_short:"Bg color",body_content_bg_short:"Content bg",body_width_label:"Width",body_font_short:"Font",body_text_short:"Text",body_heading_short:"Heading",body_link_short:"Link",type_styles_section:"Type",container_type:"Section type",container_type_help:"Determines which variables and product mappings are available for this section.",container_type_none:"Default",container_type_header:"Header",container_type_discount:"Discount",container_type_introduction:"Introduction",container_type_body:"Body",container_type_product:"Product",container_type_hero_product:"Hero Product",container_type_additional_product:"Additional Product",container_type_footer:"Footer",product_role:"Product Role",product_role_main_hero:"Primary",product_role_additional:"Secondary",assign_product_to_column:"Assign product to column",text:"Text",text_content:"This is a text, click to edit text",text_settings:"Text Settings",text_styles:"Text Styles",text_align:"Text Align",heading:"Heading",heading_content:"This is a heading, click to edit heading",heading_settings:"Heading Settings",heading_type:"Heading Type",button:"Button",button_settings:"Button Settings",button_action:"Button Action",button_styles:"Button Styles",button_padding:"Button Padding",spacer:"Spacer",spacer_block:"SPACER BLOCK",spacer_settings:"Spacer Settings",divider:"Divider",divider_settings:"Divider Settings",divider_type:"Divider Type",divider_styles:"Divider Styles",image:"Image",image_action:"Image Action",image_url:"Image URL",image_alt:"Image Alt",image_alt_placeholder:"Describe for screen readers",image_styles:"Image Styles",image_settings:"Image Settings",image_crop_soon:"Image cropping is not available yet.",crop:"Crop",replace:"Replace",delete:"Delete",image_max_upload_size:"max 10 MB",video:"Video",video_settings:"Video",video_tab_styles:"Styles",video_tab_display:"Display",video_url:"Video URL",video_thumbnail_url:"Custom thumbnail URL",video_thumbnail_url_placeholder:"Leave empty to use YouTube thumbnail",video_export_note:"Email clients typically show a linked thumbnail, not embedded playback.",video_thumbnail_layout:"Thumbnail layout",video_width:"Width (W)",video_height:"Height (H)",video_fill_column:"Fill column",video_fill_column_mobile:"Fill column on mobile",alignment:"Alignment",video_area_section:"Video area",video_block_section:"Block",video_border_none:"None",image_source:"Image source",image_source_url:"Enter URL",image_source_upload:"Upload image",image_upload:"Upload",image_upload_click:"Click to upload",image_upload_not_configured:"Image upload is not configured. Set imageUploadEndpoint in apiConfig or pass null to disable; defaults use the built-in API base.",image_uploaded:"Image uploaded successfully",image_upload_failed:"Failed to upload image",image_upload_error:"Error uploading image",image_upload_file_hint:"PNG, JPEG, GIF, SVG, WebP · max 10 MB",image_upload_invalid_type:"Use PNG, JPEG, GIF, SVG, or WebP.",uploading:"Uploading…",image_source_variable:"Use variable",menu:"Navigation bar",menu_settings:"Navigation bar Settings",menu_layout:"Menu layout",layout_mode:"Layout mode",nav_only:"Navigation only",stacked:"Stacked",logo_left:"Logo left",logo_right:"Logo right",logo_only:"Logo only",mobile_layout:"Mobile layout",stack:"Stack",inline:"Inline",logo_section:"Logo section",show_logo:"Show logo",logo_url:"Logo URL",logo_text:"Logo text",logo_alt:"Logo alt",logo_link:"Logo link",logo_max_width:"Logo max width",border_bottom:"Border bottom",show_border_bottom:"Show border bottom",font_weight:"Font weight",font_weight_light:"Light",font_weight_regular:"Regular",font_weight_semibold:"Semi-bold",font_weight_bold:"Bold",text_transform:"Text transform",menu_items:"Menu Items",menu_item:"Menu Item",menu_styles:"Menu Styles",add_new_item:"Add New Item",label:"Label",page:"Page",url:"URL",target:"Target",same_tab:"Same Tab",new_tab:"New Tab",separator:"Separator",menu_separator_placeholder:'e.g. " | " or " • "',menu_separator_allowed_hint:"Only these symbols: | • — / · You may add spaces.",menu_link_gap:"Link spacing",menu_underline_links:"Underline links",logo_text_placeholder:"Brand",letter_spacing:"Letter Spacing",link_color:"Link Color",avatar:"Avatar",avatar_settings:"Avatar Settings",avatar_image:"Avatar image",avatar_border_radius:"Border radius",social_link:"Social Link",social_link_settings:"Social Link Settings",add_social_link:"Add Social Link",social_link_size:"Social Link Size",icon_styles:"Icon styles",icon_size:"Icon size",icon_size_small:"Small",icon_size_medium:"Medium",icon_size_large:"Large",icon_color:"Icon color",icon_color_default:"Default",icon_color_white:"White",icon_color_black:"Black",icon_color_gray:"Gray",social_icon_spacing:"Icon spacing",social_links:"Social Links",social_platform_x:"X",social_platform_formerly_twitter:"Formerly Twitter",social_platform_x_alt:"X, formerly Twitter",social_link_placeholder_facebook:"https://www.facebook.com/yourpage",social_link_placeholder_linkedin:"https://www.linkedin.com/company/yourcompany",social_link_placeholder_instagram:"https://www.instagram.com/yourhandle",social_link_placeholder_tiktok:"https://www.tiktok.com/@yourhandle",social_link_placeholder_x:"https://x.com/yourhandle",social_link_placeholder_youtube:"https://www.youtube.com/yourchannel",social_link_placeholder_pinterest:"https://www.pinterest.com/yourprofile",social_link_placeholder_generic:"https://example.com",raw_html:"HTML",raw_html_block:"RAW HTML",raw_html_settings:"HTML Settings",raw_html_code_label:"Code",raw_html_code_hint:"Inserted as-is in the exported email. Prefer table-based layouts and inline CSS for client compatibility.",raw_html_default_content:'<p style="text-align:center;color:#A3A3A3;font-size:12px">Add custom HTML here</p>',raw_html_appearance:"Layout",raw_html_clear_background:"Clear",raw_html_email_client_warning:"Custom HTML may render inconsistently across email clients. Test thoroughly.",raw_html_info_tooltip_aria:"More about raw HTML",content_background_color:"Content Background Color",container_background_image_title:"Section background image",container_background_image_section_title:"Section background image",container_background_image_section_toggle:"Show section background image",container_background_image_layout_group:"Image layout",container_background_image_row_label:"Background image",container_background_image_intro:"Blocks you add to this section (text, buttons, images, etc.) appear on top of the image. Drag components from the palette into the section on the canvas.",container_background_image_tooltip_p1:"Uses a background image on the section table (email-client friendly — not CSS position:absolute).",container_background_image_tooltip_p2:"Use “Content background color” for a tint behind blocks, or set it transparent so only the photo shows through.",container_background_image_enable:"Enable background image",container_background_image_url:"Image URL",container_background_image_upload:"Upload image",container_background_image_upload_click:"Drag and drop or select image",container_background_image_file_hint:"Accepts .png, .jpg, .jpeg, .gif, and .webp. Maximum file size 10 MB.",container_background_image_select_button:"Select image",container_background_image_clear:"Remove background image",container_background_image_size:"Image fit",container_background_image_position:"Focal point",container_bg_size_cover:"Cover",container_bg_size_contain:"Contain",container_bg_size_fill:"Fill",image_file_too_large:"Image must be 10 MB or smaller.",container_bg_image_url_error_blocked_scheme:"This URL uses a blocked protocol. Use only http:// or https:// for images.",container_bg_image_url_error_duplicate_protocol:"The URL repeats the protocol. Use a single https:// prefix.",container_bg_image_url_error_hostname:"Use a full URL with a valid hostname (e.g. https://cdn.example.com/photo.jpg).",container_bg_image_url_error_invalid_protocol:"Unsupported protocol. Use http:// or https:// for image URLs.",container_bg_image_url_error_generic:"Invalid image URL format.",container_bg_image_preview_failed:"Could not load a preview for this URL. It may not be an image, or the host blocked the request.",image_text_overlay:"Text overlay",overlay_multi_item:"Multi-item stack",add_overlay_item:"Add overlay item",drag_to_move:"Drag to move",overlay_max_width:"Overlay max width",item_gap:"Item gap",scrim:"Scrim",text_shadow:"Text shadow",fill_column:"Fill column",image_text_overlay_tip:"Optional caption drawn on top of the image in the editor. For full layouts over a photo, use a section background image instead.",image_text_overlay_container_tip:"Select the section → Styles → Section background image, then drag text and buttons into that section.",image_text_overlay_enable:"Enable text overlay",image_overlay_caption:"Caption",image_overlay_caption_placeholder:"Short line of text…",image_overlay_position:"Caption position",image_overlay_pos_tl:"Top left",image_overlay_pos_tc:"Top center",image_overlay_pos_tr:"Top right",image_overlay_pos_ml:"Middle left",image_overlay_pos_mc:"Middle center",image_overlay_pos_mr:"Middle right",image_overlay_pos_bl:"Bottom left",image_overlay_pos_bc:"Bottom center",image_overlay_pos_br:"Bottom right",image_overlay_box_bg:"Caption box background (CSS)",image_overlay_padding:"Caption padding",background_color:"Background Color",text_color:"Text Color",email_theme_background_color:"Email Theme Background Color",font_color:"Font Color",button_color:"Button Color",divider_color:"Divider Color",action_type:"Action Type",content_background:"Content background",heading_color:"Heading color",top:"Top",right:"Right",left:"Left",bottom:"Bottom",line_height:"Line Height",link:"Link",link_url:"Link URL",link_url_placeholder:"example.com",padding_settings:"Padding Settings",width:"Width",height:"Height",width_auto:"Width Auto",auto_width:"Auto Width",font_size:"Font Size",font_family:"Font Family",solid:"Solid",dotted:"Dotted",dashed:"Dashed",align:"Align",spacing:"Spacing",border_radius:"Border radius",link_all_sides:"Link all sides",padding_link_sides_label:"Same padding on all sides",padding_link_sides_tooltip:"When on, one value updates top, right, bottom, and left together. Turn off to set each side separately.",email_width_mode:"Width",email_width_default:"Email-width (default)",custom_px:"Custom px",custom_width_px:"Custom width",full_bleed:"Full bleed",full_bleed_tooltip:"Extends edge-to-edge in clients that support it; clipped to email-width otherwise.",export_html:"Export HTML",export_json:"Export JSON",export_checking_images:"Checking images…",language_zh:"中文",export_validation_title:"Export validation",export_validation_issues_found:"Issues found before export",export_validation_errors:"Errors",export_validation_warnings:"Warnings",export_validation_info:"Info",export_anyway:"Export anyway",ignore:"Ignore",validation_body_content_width_invalid:"Body content width must be between 280 and 1200 px.",validation_body_background_color_missing:"Theme background color is missing.",validation_body_text_color_missing:"Theme text color is missing.",validation_body_font_family_missing:"Theme font family is missing.",validation_image_empty_src:"Image URL is empty; the image will not display.",validation_image_invalid_src:"Image URL format is invalid.",validation_image_invalid_link:"Image link URL format is invalid.",validation_image_url_not_loadable:"Image URL could not be loaded or previewed; the link may be broken, expired, or blocked.",validation_image_empty_alt:"Image alt text is empty; consider adding for accessibility.",validation_avatar_empty_src:"Avatar image URL is empty; avatar will not display.",validation_avatar_invalid_src:"Avatar image URL format is invalid.",validation_avatar_invalid_link:"Avatar link URL format is invalid.",validation_button_empty_link:'Button link URL is empty; will be saved as href="https://".',validation_button_invalid_link:"Button link URL format is invalid.",validation_button_blocked_scheme:"Button link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",validation_button_label_invalid_link:"Button label link URL format is invalid.",validation_button_label_blocked_link_scheme:"Button label link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",validation_rich_text_link_invalid:"Rich text hyperlink URL format is invalid.",validation_rich_text_link_blocked_scheme:"Rich text link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",validation_menu_empty_label:'Menu item label is empty; will show as "Link".',validation_menu_empty_url:'Menu item URL is empty; will be saved as href="#".',validation_menu_invalid_url:"Menu item URL format is invalid.",validation_menu_blocked_scheme:"Menu item URL uses a blocked scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",validation_menu_no_items:"Menu block has no items.",validation_raw_html_empty:"HTML block has no custom markup; export will include an empty wrapper.",validation_social_empty_link:'Social link URL is empty; will be saved as href="https://".',validation_social_invalid_link:"Social link URL format is invalid.",validation_social_blocked_scheme:"Social link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s) only (e.g. www.example.com or https://…).",validation_social_empty_icon:"Social link icon URL is empty; icon will not display.",validation_social_invalid_icon:"Social link icon URL format is invalid.",validation_social_no_links:"Social link block has no links.",validation_social_duplicate_platform:"Duplicate social platform in this block; only one entry per platform should be kept.",validation_container_product_not_assigned:"A product is not assigned to this column; assign a product in Section settings.",validation_dynamic_content_empty:"Dynamic content not generated; export will use static text if available.",validation_text_invalid_link:"Text link URL format is invalid.",validation_text_blocked_link_scheme:"Text link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",tooltip_bold:"Bold",tooltip_italic:"Italic",tooltip_underline:"Underline",tooltip_strikethrough:"Strikethrough",tooltip_align_left:"Align left",tooltip_align_center:"Align center",tooltip_align_right:"Align right",tooltip_ordered_list:"Ordered list",tooltip_unordered_list:"Unordered list",tooltip_link:"Link",tooltip_remove_link:"Remove link",add_link_modal_title:"Add link",content_type:"Content type",content_type_static:"Static",content_type_dynamic:"Dynamic",ai_enabled:"Write using AI",text_and_content_type:"Content type",heading_or_body:"Heading",body_paragraph:"Body",heading_h1:"H1",heading_h2:"H2",heading_h3:"H3",heading_h4:"H4",variables:"Variables",insert_merge_field:"Select or type variable...",dynamic_prompt_help:"Write your prompt",ai_output_language:"AI output language",ai_output_language_en:"English",ai_output_language_bn:"Bengali",generate:"Generate",ml_generation_failed:"Could not generate AI content",ml_ai_unavailable:"AI generation needs a column layout, company ID, template ID, and ML endpoint. Open this text inside a section column and check apiConfig.",ml_no_variations:"No suggestions were returned. Try another prompt or verify the template exists on the server.",ml_generation_unexpected_error:"Something went wrong while generating content.",sample_ai_content:"Sample AI content",select_content:"Select content",variable_dynamic_placeholder:"None (optional)",variable_display_text:"Display text",variable_introduction:"Introduction",variable_heading:"Heading",variable_subheading:"Subheading",variable_products_description:"Products description",variable_customer_name:"Customer Name",variable_introduction_title:"Introduction Title",variable_introduction_subtitle:"Introduction Subtitle",variable_body_title:"Body Title",variable_body_subtitle:"Body Subtitle",variable_discount_value:"Discount value",variable_discount_code:"Discount code",variable_valid_until:"Valid until",variable_company_name:"Company name",variable_brand_name:"Brand name",variable_address:"Address",variable_website:"Website",variable_logo_url:"Logo URL",variable_tagline:"Tagline",variable_nav_label:"Nav link label",variable_nav_url:"Nav link URL",variable_product_name:"Product name",variable_product_description:"Product description",variable_product_image:"Product image URL",variable_product_link:"Product link",variable_product_price:"Product price",variable_product_currency:"Product currency",variable_product_old_price:"Product old price",variable_product_new_price:"Product new price",variable_product_price_display:"Product price display",variable_image_logo:"Logo",variable_image_hero_banner:"Hero banner",variable_image_footer_banner:"Footer banner",variable_image_product_image:"Product image",variable_cta_label:"CTA label",variable_cta_url:"CTA URL",button_label_variable:"Button label (variable)",button_url_variable:"Use variable",button_text:"Button text",button_label_manual:"Enter label",button_url_manual:"Enter URL",use_company_social_links:"Use company social links",use_navigation_links:"Use navigation links",tooltip_container_type:"Determines which variables and product mappings are available for this section.",tooltip_variables_static:"Insert a merge field into your content. It will be replaced when the email is sent.",tooltip_dynamic_prompt:"Describe the tone or intent; we'll suggest sample content. (Preview mode — connect an AI API for real generation.)",tooltip_write_using_ai:"When on, choose output language and write a prompt to generate variants. Requires ML/API when connected.",tooltip_write_using_ai_unavailable:"AI authoring is disabled for this editor. Enable it from the host app or API options to use Write using AI.",label_align:"Align",label_padding:"Padding",section_background_group:"SECTION BACKGROUND",section_bg_mode:"Type",section_bg_color:"Color",section_bg_image:"Image",section_bg_none:"None",section_content_area_group:"CONTENT AREA",content_area_color:"Content color",content_color_auto:"Auto",content_color_custom:"Custom",shortcuts_modal_title:"Keyboard shortcuts",shortcuts_modal_footnote:"Shortcuts are disabled while typing in text fields inside the settings panel, so you can edit URLs and copy/paste normally.",shortcut_save:"Save (handled by the host page when connected)",shortcut_undo:"Undo",shortcut_redo:"Redo",shortcut_duplicate:"Duplicate selected block",shortcut_copy_block:"Copy selected block",shortcut_paste_block:"Paste block",shortcut_delete_block:"Delete selected block",shortcut_escape:"Deselect block",shortcut_cheat_sheet:"Open this help",shortcut_delete_confirm_title:"Delete this section?",shortcut_delete_confirm_desc:"This section has content blocks inside. Delete it anyway?",section_nest_not_allowed:"Sections cannot be placed inside another section. Drop between sections in the stack.",context_duplicate:"Duplicate",context_copy:"Copy",context_cut:"Cut",context_paste:"Paste",context_delete:"Delete",context_move_up:"Move up",context_move_down:"Move down",context_save_global:"Save as Global Element",context_reset_styles:"Reset styles",topbar_back_to_templates:"Templates",topbar_exit:"Exit",topbar_breadcrumb_email:"Email",topbar_rename_template:"Rename template",topbar_untitled_template:"Untitled template",send_test:"Send test",preview:"Preview",html_email_preview:"HTML preview",html_email_preview_title:"HTML Email Preview",html_email_preview_device_aria:"HTML preview device width",html_email_preview_error:"Could not generate the HTML preview. Check the console for details.",save_template:"Save template",more_actions:"More actions",keyboard_shortcuts:"Keyboard shortcuts",high_contrast_on:"High contrast on",high_contrast_off:"High contrast off",desktop:"Desktop",mobile:"Mobile",undo:"Undo",redo:"Redo",save_state_saved:"Saved",save_state_saving:"Saving…",save_state_unsaved:"Unsaved",save_state_error:"Save failed",export_validation_open_block:"Open block",save:"Save",template_name:"Template name",save_template_title:"Save template",save_template_category:"Category",save_template_category_placeholder:"Select or type a category…",category_promotional:"Promotional",category_transactional:"Transactional",category_newsletter:"Newsletter",category_onboarding:"Onboarding",category_announcement:"Announcement",category_other:"Other",send_test_title:"Send test email",send_test_send:"Send test",send_test_recipients:"Recipients",send_test_recipients_placeholder:"name@example.com, another@example.com",send_test_recipients_hint:"Press Enter or comma to add each address.",send_test_payload:"Payload context",send_test_payload_none:"No payload",send_test_payload_profile:"Profile data",send_test_payload_event:"Event data",send_test_prefix_label:"[TEST] prefix",send_test_prefix_hint:"Prepends [TEST] to the subject line.",universal:"Universal",layers:"Layers",document:"Document",layer_one:"block",layer_many:"blocks",layer_move_up:"Move up",layer_move_down:"Move down",layer_duplicate:"Duplicate",layer_delete:"Delete",universal_saved_blocks:"Saved blocks",universal_empty_state_line_1:"No universal content yet. Click",universal_empty_state_line_2:"on any block to save it for reuse across templates.",universal_used_in_count:"used in {{count}}",compliance:"Compliance",compliance_preflight:"Pre-flight",compliance_all_clear_title:"Ready to send",compliance_all_clear_desc:"All compliance checks pass.",compliance_severity_error:"Error",compliance_severity_warning:"Warning",compliance_severity_info:"Info",compliance_tab_badge_label:"Unresolved issues: {{count}}",compliance_email_size:"Email size (approx.)",compliance_above_clip:"Above Gmail’s ~102 KB clip threshold — heavy templates may be clipped in the inbox.",compliance_below_clip:"Below Gmail clip threshold",right_panel_empty_hint:"Click any block in the canvas to edit its specific settings. Drag blocks from the left rail to add new content.",right_panel_back:"Back",layer_show:"Show",layer_hide:"Hide",save_as_universal:"Save as universal",universal_save_modal_title:"Save as universal block",universal_save_modal_subtitle:"Reusable across templates. Edits won't affect already-sent emails.",universal_save_modal_placeholder:"e.g. Beantown footer",universal_save_modal_confirm:"Save block",universal_save_success:'Saved "{{name}}" as universal block',universal_save_error:"Could not save the universal block. Check your connection and try again.",universal_delete:"Remove",universal_delete_confirm_title:"Remove saved block?",universal_delete_confirm_body:"This removes the block from your saved library. Existing emails are not changed.",universal_delete_confirm_ok:"Remove",configure_columns_title:"Configure columns",configure_columns_subtitle:"Pick a layout. Each column starts empty so you can drag blocks into it.",configure_columns_insert:"Insert section",configure_columns_hint:"click to configure layout",configure_columns_row_count:"Rows to insert:",standard_layout:"Standard",grid_layout:"6/12 Grid",grid_settings:"Grid",grid_rows_locked_hint:"Email layouts use one row of columns.",columns_layout:"Columns layout",column_sizes:"Column widths (%)",show_more:"Show more",show_less:"Show less",col:"Col",gaps:"Gaps",column_gap:"Column gap",button_variant:"Variant",full_width:"Full width",hover_bg_color:"Hover background",hover_text_color:"Hover text",text_decoration:"Decoration",shadow:"Shadow",shadow_preset:"Preset",table:"Table",table_settings:"Table settings",footer_settings:"Footer settings",compliance_approx_kb:"Approx {{n}} KB",cell_content:"Cell content",add_link_url:"URL",add_link_display_text:"Display text",add_link_display_text_placeholder:"Leave blank to keep selected text",add_link_display_text_empty_badge:"No text — link will use selected text",add_link_open_new_tab:"Open in new tab",align_left:"Align left",align_center:"Align center",align_right:"Align right",minimize_toolbar:"Collapse",close_text_editor:"Exit text editing",unlink_universal:"Unlink this copy",unlink_modal_title:"Edit universal block",unlink_modal_keep:"Keep linked",unlink_modal_unlink:"Unlink this copy",unlink_modal_body:"This block is linked to a universal snippet. Editing it here will affect all uses of this block everywhere.",unlink_modal_body2:"Choose “Unlink this copy” to make an independent copy that only affects this template, or “Keep linked” to edit all instances together.",custom:"Custom",custom_color:"Custom color",show_text_label:"Show label",mobile_optimization:"Mobile optimization",stack_columns_on_mobile:"Stack columns on mobile",scale_font_on_mobile:"Scale font on mobile",section_layout:"Section Layout",content_max_width:"Content max-width",min_height:"Min height",border:"Border",border_style:"Border style",border_width:"Border width",border_color:"Border color",visibility:"Visibility",hidden_on_mobile:"Hide on mobile",table_structure:"Table Structure",rows:"Rows",header_row:"Header row",header_column:"Header column",cell_selector:"Cell selector",cell_content_type:"Cell content type",table_style:"Table style",cell_padding:"Cell padding",header_style:"Header style",header_background:"Header background",header_text_color:"Header text color",striped_rows:"Striped rows",stripe_color:"Stripe color",table_structure_mode:"Mode",table_mode_static:"Static",table_mode_dynamic:"Dynamic",table_dynamic_structure_hint:"Export still uses static HTML; data-driven tables may be wired in a future update.",table_add_row:"Add row",table_add_column:"Add column",table_decrease_rows:"Decrease row count",table_increase_rows:"Increase row count",table_decrease_cols:"Decrease column count",table_increase_cols:"Increase column count",table_selected_cell:"Selected: row {{row}}, col {{col}}",table_select_cell_hint:"Select a cell in the grid to edit its content.",table_cell_grid_truncated:"Showing first {{rows}} × {{cols}} cells",table_cell_text_placeholder:"Cell text…",table_align_left:"Left",table_align_center:"Center",table_align_right:"Right",footer_sections:"Footer sections",show_brand:"Brand",brand_name:"Brand name",brand_tagline:"Tagline",show_address:"Address",address:"Address text",show_unsubscribe:"Unsubscribe link",unsubscribe_text:"Link text",unsubscribe_url:"Unsubscribe URL",show_social:"Social icons",social_icons_hint:"Configure social icons in the block's content settings.",show_secondary_links:"Secondary links",show_copyright:"Copyright",copyright_text:"Copyright text",footer_style:"Footer style",padding_top:"Top padding",padding_bottom:"Bottom padding",show_divider:"Show divider"},So=()=>{const{language:t,languageLibraries:n}=e.useContext(ge);let o={zh:wo,en:jo};n&&(o={...o,...n,zh:{...wo,...o.zh||{}},en:{...jo,...o.en||{}}});return{t:(e,n)=>{let a=(o[t]||{})[e];return n&&n instanceof Object&&Object.keys(n).forEach(e=>{a=a.replace(`{{${e}}}`,n[e])}),a||e}}},Co=/\{\{(\w+)\}\}/g;function No(e,t){if(null!=e)if("string"!=typeof e){if(Array.isArray(e))e.forEach(e=>No(e,t));else if("object"==typeof e){if(void 0!==e.$$typeof)return;Object.values(e).forEach(e=>No(e,t))}}else(function(e){if("string"!=typeof e||0===e.length)return[];const t=[];let n;for(;null!==(n=Co.exec(e));){const e=n[1];e&&t.push(e)}return Co.lastIndex=0,t})(e).forEach(e=>t.add(e))}function Io(e,t,n){e&&"object"==typeof e&&(e.id&&n.has(e.id)||(e.id&&n.add(e.id),"column"!==e.key?No(e,t):(e.children||[]).forEach(e=>{(e?.children||[]).forEach(e=>Io(e,t,n))})))}function Ao(e,t,n,o){if(!e||o.has(e))return;o.add(e);const a=t[e];a&&"object"==typeof a&&("column"===a.key?(a.cells||[]).forEach(e=>{(e.childrenIds||[]).forEach(e=>Ao(e,t,n,o))}):No(a,n))}function To(e,t){const n=new Set;if(!e||"object"!=typeof e)return n;if(Array.isArray(e.children)){const t=new Set;return Io(e,n,t),n}if(!t||"object"!=typeof t)return n;const o=new Set;return(e.cells||[]).forEach(e=>{(e.childrenIds||[]).forEach(e=>Ao(e,t,n,o))}),n}const Lo=()=>{const t=(e,n)=>e?e.classList?.contains("text-content_editable")?null:e&&e.tagName?.toLocaleLowerCase()===n?e:t(e.parentNode,n):null,n=e.useCallback((e,t)=>e?e.classList?.contains("text-content_editable")?null:e&&e.style?.[t]?e.style[t]:n(e.parentNode,t):null,[]);return{getSelectionNode:t,getSectionStyle:n}},Bo=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"b"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_bold"),onClick:()=>{t("bold",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faBold,className:"rich-text-tools-button-icon"})})};function $o(e,t){if(!e)return!1;const n=e.commonAncestorContainer;if(!function(e){let t=e;for(t&&3===t.nodeType&&(t=t.parentElement);t;){if(t.classList?.contains("text-content_editable"))return!0;t=t.parentNode}return!1}(n))return!1;try{if(document.queryCommandState("italic"))return!0}catch{}return!("function"!=typeof t||!t(n,"i")&&!t(n,"em"))||function(e){let t=e;for(t&&3===t.nodeType&&(t=t.parentElement);t&&!t.classList?.contains("text-content_editable");){if(1===t.nodeType){const e=t.tagName?.toLowerCase();if("i"===e||"em"===e)return!0;const n=t.style?.fontStyle;if("italic"===n||"oblique"===n)return!0;try{if("undefined"!=typeof window&&window.getComputedStyle){const e=window.getComputedStyle(t).fontStyle;if("italic"===e||"oblique"===e)return!0}}catch{}}t=t.parentNode}return!1}(n)}const Ro=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=$o(i,r);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_italic"),onClick:()=>{try{document.execCommand("styleWithCSS",!1,!0)}catch{}t("italic",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faItalic,className:"rich-text-tools-button-icon"})})},Mo=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"u"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_underline"),onClick:()=>{t("underline",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faUnderline,className:"rich-text-tools-button-icon"})})},Po=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"strike"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_strikethrough"),onClick:()=>{t("strikethrough",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faStrikethrough,className:"rich-text-tools-button-icon"})})},Fo=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"ol"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_ordered_list"),onClick:()=>{t("insertOrderedList",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faListOl,className:"rich-text-tools-button-icon"})})},Eo=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"ul"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_unordered_list"),onClick:()=>{t("insertUnorderedList",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faListUl,className:"rich-text-tools-button-icon"})})},Do=({modifyText:a,setTextContent:i})=>{const{selectionRange:r}=e.useContext(ge),{t:s}=So(),{getSelectionNode:c}=Lo(),[d,u]=e.useState(!1),[m,p]=e.useState({value:"",range:null}),[g,h]=e.useState(""),[b,y]=e.useState(!0),_=e.useRef(null),f=e.useMemo(()=>r?c(r.commonAncestorContainer,"a"):null,[r,c]),x=()=>{u(!1),p({value:"",range:null}),h(""),y(!0)};return l.jsxs(l.Fragment,{children:[l.jsx("button",{className:fo("rich-text-tools-button ",f&&"rich-text-tools-button-active"),title:s("tooltip_link"),onClick:e=>{let t=window.getSelection(),n=t.getRangeAt(0);const o=n.commonAncestorContainer.parentNode,a="A"===o.nodeName,l={...m,range:n};let r="",s=!0;if(a){l.rangeIsLink=!0;const e=o.getAttribute("href"),t=null!=e?String(e).trim():"";l.value=""!==t?t:String(o.href||"").trim(),r=o.textContent||"",s="_self"!==o.target}else{r=t.toString()}const c=e?.currentTarget?.closest?.(".email-editor");c&&(_.current=c),p(l),h(r),y(s),u(!0),i()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faLink,className:"rich-text-tools-button-icon"})}),l.jsx("button",{className:fo("rich-text-tools-button"),title:s("tooltip_remove_link"),onClick:()=>{a("unlink",!1,null),i()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faUnlink,className:"rich-text-tools-button-icon"})}),l.jsx(t.Modal,{title:s("add_link_modal_title"),open:d,zIndex:1100,getContainer:()=>"undefined"==typeof document?null:_.current||document.querySelector(".email-editor")||document.body,onOk:()=>{const{range:e,value:t,rangeIsLink:n}=m;if(e){if(n){const n=e.commonAncestorContainer,o=1===n.nodeType&&"A"===n.nodeName?n:n.parentNode&&"A"===n.parentNode.nodeName?n.parentNode:null;o&&(o.setAttribute("href",t),o.target=b?"_blank":"_self",g.trim()&&(o.textContent=g.trim()))}else{const n=document.createElement("a");if(n.target=b?"_blank":"_self",n.setAttribute("href",t),g.trim())n.textContent=g.trim(),e.deleteContents(),e.insertNode(n);else try{e.surroundContents(n)}catch{return void x()}}i(),x()}else x()},onCancel:x,okText:s("confirm"),cancelText:s("cancel"),wrapClassName:"ee-modal-dark",children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:4,fontSize:12,fontWeight:500},children:s("add_link_url")||"URL"}),l.jsx(t.Input,{value:m.value??"",placeholder:s("link_url_placeholder"),onChange:e=>p({...m,value:e.target.value})})]}),l.jsxs("div",{children:[l.jsxs("div",{style:{marginBottom:4,display:"flex",alignItems:"center",flexWrap:"wrap",gap:8},children:[l.jsx("span",{style:{fontSize:12,fontWeight:500},children:s("add_link_display_text")||"Display text"}),g.trim()?null:l.jsx(t.Badge,{status:"warning",text:s("add_link_display_text_empty_badge"),className:"ee-link-modal-display-text-badge"})]}),l.jsx(t.Input,{value:g,placeholder:s("add_link_display_text_placeholder")||"Leave blank to keep selected text",onChange:e=>h(e.target.value)})]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[l.jsx("span",{style:{fontSize:13},children:s("add_link_open_new_tab")||"Open in new tab"}),l.jsx(t.Switch,{className:"ee-settings-switch",checked:b,onChange:y})]})]})})]})},Uo=({id:i,textBlock:r,syncTextFromDom:s})=>{const{blockMap:c,rootOrder:d,templateData:u}=e.useContext(ge),{t:m}=So(),p=e.useRef(null),[g,h]=e.useState(!1),[b,y]=e.useState(!1),_=e.useMemo(()=>{const e=E(c,d,i),t=e?.[0]??null;return{containerBlock:t?.containerBlock??null,containerType:t?.containerType??"none",cellIndex:t?.cellIndex??0,lineage:e}},[c,d,i]),f=e.useMemo(()=>{const e=_?.cellIndex??0,t=_?.containerBlock;return{columnIndex:e,columnProduct:t?.columnProducts?.[e]??null}},[_]),x=e.useMemo(()=>(_?.lineage??[]).slice(1).filter(e=>e?.containerType&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[_?.lineage]),k=e.useMemo(()=>jt(0,_?.containerType??"none",u,f,x),[_?.containerType,u,f,x]),v=e.useMemo(()=>To(_?.containerBlock,c),[_?.containerBlock,c]),w=e.useMemo(()=>k.filter(e=>"image"!==e.type&&!v.has(e.variableKey??e.key)),[k,v]),j=e.useCallback(()=>{if(!p.current)return;const e=p.current.parentNode?.getBoundingClientRect(),t=document.querySelector("#preview");if(!e||!t)return;const n=t.getBoundingClientRect();e.top-190<0?(p.current.style.bottom="auto",p.current.style.top="110%"):(p.current.style.bottom="110%",p.current.style.top="auto"),e.left+420>n.left+n.width?(p.current.style.left="auto",p.current.style.right="0"):(p.current.style.left="0",p.current.style.right="auto")},[]);e.useEffect(()=>{j()},[j]),e.useEffect(()=>{const e=()=>{const e="undefined"!=typeof window&&window.getSelection(),t=p.current;if(!e||0===e.rangeCount||!t)return void j();const n=e.getRangeAt(0),o=r?.current;if(!o||!o.contains(n.commonAncestorContainer)||e.isCollapsed)return void j();const a=n.getBoundingClientRect();if(!a||0===a.width&&0===a.height)return void j();const l=t.parentNode;if(!l)return;const i=l.getBoundingClientRect(),s=document.querySelector("#preview"),c=s?s.getBoundingClientRect():null;let d=a.top-i.top-46-8;a.top-60<0&&(d=a.bottom-i.top+8);let u=a.left-i.left+a.width/2-210;if(c){const e=c.left-i.left+8,t=c.right-i.left-8-420;u=Math.max(e,Math.min(u,t))}t.style.top=`${d}px`,t.style.bottom="auto",t.style.left=`${u}px`,t.style.right="auto"};return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[j,r]);const S=(e,t,n)=>{document.execCommand(e,t,n)},C=()=>{"function"!=typeof s?r?.current&&("undefined"!=typeof InputEvent&&InputEvent?r.current.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0})):r.current.dispatchEvent(new Event("input",{bubbles:!0}))):s()};return l.jsx("div",{className:"rich-text",ref:p,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:l.jsx(a.motion.div,{className:"rich-text-tools",initial:{scale:0,x:0},animate:{scale:1,x:0},style:{width:g?"auto":"max-content",maxWidth:"min(100%, 520px)"},children:l.jsxs("div",{className:"rich-text-tools-body items-center",children:[!g&&l.jsxs(l.Fragment,{children:[l.jsx(Bo,{modifyText:S,setTextContent:C}),l.jsx(Ro,{modifyText:S,setTextContent:C}),l.jsx(Mo,{modifyText:S,setTextContent:C}),l.jsx(Po,{modifyText:S,setTextContent:C}),l.jsx(Fo,{modifyText:S,setTextContent:C}),l.jsx(Eo,{modifyText:S,setTextContent:C}),l.jsx(Do,{modifyText:S,setTextContent:C}),l.jsx(t.Popover,{zIndex:540,trigger:"click",open:b,onOpenChange:y,overlayClassName:"ee-rich-text-variables-popover",getPopupContainer:()=>document.querySelector("#preview")||document.body,content:l.jsxs("div",{className:"ee-rich-text-variables-menu",children:[l.jsx("div",{className:"ee-rich-text-variables-header",children:m("variables")}),w.map(e=>l.jsx("div",{className:"ee-rich-text-variables-item",onMouseDown:t=>{t.preventDefault(),(e=>{if(!r?.current||!e)return;const t=window.getSelection();let n=null;if(t?.rangeCount){const e=t.getRangeAt(0);r.current.contains(e.commonAncestorContainer)&&(n=e)}n||(n=document.createRange(),n.selectNodeContents(r.current),n.collapse(!1)),n.deleteContents();const o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t&&(t.removeAllRanges(),t.addRange(n)),C(),y(!1)})(e.value)},children:e.labelKey?m(e.labelKey):e.label||e.value},`variables-${e.value}`))]}),children:l.jsx("button",{className:"rich-text-tools-button",title:m("insert_merge_field"),onMouseDown:e=>e.preventDefault(),children:l.jsx("span",{className:"rich-text-tools-button-icon",style:{color:"#fff",fontFamily:"monospace",fontWeight:700,fontSize:13,lineHeight:1},children:"{}"})})})]}),l.jsx("button",{className:"rich-text-tools-button",title:m("minimize_toolbar")||"Collapse",onClick:()=>h(!g),children:l.jsx(n.FontAwesomeIcon,{icon:g?o.faExpandAlt:o.faCompressAlt,className:"rich-text-tools-button-icon"})})]})})})},zo=({id:t,blockItem:n,displayContent:o})=>{const{currentItem:a,previewMode:i,blockMap:r,rootOrder:s,setBlocks:c,setCurrentItem:d,isDragStart:u,templateData:m,registerRichTextFlush:p}=e.useContext(ge),g=e.useRef(null),h=a&&a.id===(t??n?.id)&&!("text"===n?.key&&"dynamic"===n?.contentType),b="desktop"===i?n.styles?.desktop??{}:{...n.styles?.desktop??{},...n.styles?.mobile??{}},y=b.linkColor||"#2faade",{linkColor:_,...f}=b,x={...f,direction:"ltr",unicodeBidi:"isolate","--ee-rich-text-link-color":y},k=e.useRef(!1),v=null!=o?o:n.text||"",w=e.useMemo(()=>{const e=E(r,s,t??n?.id),o=e?.[0]??null;return{containerBlock:o?.containerBlock??null,containerType:o?.containerType??"none",cellIndex:o?.cellIndex??0,lineage:e}},[r,s,t,n?.id]),j=e.useMemo(()=>{const e=w?.cellIndex??0,t=w?.containerBlock;return{columnIndex:e,columnProduct:t?.columnProducts?.[e]??null}},[w]),S=e.useMemo(()=>(w?.lineage??[]).slice(1).filter(e=>e?.containerType&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[w?.lineage]),C=e.useMemo(()=>jt(0,w?.containerType??"none",m,j,S).map(e=>{return t=e.value,n=e.pasteValue,{token:t,pasteValue:String(n||"")};var t,n}).filter(e=>e.token&&e.pasteValue&&""!==e.pasteValue.trim()&&!e.pasteValue.includes("{{")&&e.pasteValue!==e.token).sort((e,t)=>t.pasteValue.length-e.pasteValue.length),[m,j,w?.containerType,S]),N=e.useCallback(e=>{if(!e||!C.length||"undefined"==typeof document)return e;const t=document.createElement("div");t.innerHTML=e;const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let o=n.nextNode();for(;o;){const e=o.nodeValue||"",{masked:t,tokens:a}=ko(e);let l=t;C.forEach(({token:e,pasteValue:t})=>{t&&l.includes(t)&&(l=l.split(t).join(e))}),o.nodeValue=vo(l,a),o=n.nextNode()}return t.innerHTML},[C]);e.useEffect(()=>{if(h&&g.current){const e=xo(v);if(k.current){e!==xo(g.current.innerHTML||"")&&(g.current.innerHTML=e)}else g.current.innerHTML=e,g.current.focus();k.current=!0}else k.current=!1},[h,t,v]);const I=e.useCallback(e=>{if(!e)return;const l=t??n?.id,i=r[l]||{},{textToStore:u,unchangedFromResolved:m}=function({rawHtml:e,displayContent:t,blockItemText:n,oldBlockKey:o,blockItemKey:a,restoreVariableTokensInHtml:l}){const i=xo(e),r=null!=t?xo(String(t)):null,s=!/<\s*a\b/i.test(i)&&null!=r&&i===r;let c=s?n:i;return"text"===(o??a)&&"function"==typeof l&&(c=l(c)),{textToStore:c,unchangedFromResolved:s}}({rawHtml:e.innerHTML,displayContent:o,blockItemText:n.text,oldBlockKey:i.key,blockItemKey:n.key,restoreVariableTokensInHtml:N}),p={...i,text:u,selectedVariableKey:m?i.selectedVariableKey:void 0},g={...r,[l]:p};c(g,s,`edit_${Date.now()}`),d({...a,data:p})},[t,n?.id,n?.key,n?.text,r,s,c,d,a,o,N]),A=e.useCallback(()=>{I(g.current)},[I]);e.useEffect(()=>{if(h&&"function"==typeof p)return p(A)},[h,p,A]);const T=xo(v),L=t??n?.id;return l.jsxs("div",{className:"relative",dir:"ltr",style:{direction:"ltr",unicodeBidi:"isolate"},children:[h&&n&&!u&&l.jsx(Uo,{textBlock:g,id:L,syncTextFromDom:A}),l.jsx("div",{className:fo(h&&"text-block","text-content_editable"),onClick:e=>{e.preventDefault(),e.stopPropagation()},onBlur:A,onCompositionEnd:A,style:x,dir:"ltr",contentEditable:h,suppressContentEditableWarning:!0,ref:g,dangerouslySetInnerHTML:h?void 0:{__html:T}})]})},Oo=t=>{const{id:n,blockItem:o}=t,{currentItem:a,previewMode:i,templateData:r,blockMap:s,rootOrder:c}=e.useContext(ge),d="desktop"===i?o.styles?.desktop??{}:{...o.styles?.desktop??{},...o.styles?.mobile??{}},u=a&&a.id===n,m=e.useMemo(()=>D(s,c,n),[s,c,n]),p=e.useMemo(()=>dt(o.text,r,m),[o.text,r,m]),g=u?o.text||"":p,h=null!=d.linkColor&&""!==String(d.linkColor).trim()?String(d.linkColor).trim():"#2faade",b=e.useMemo(()=>At(g,h,{useImportant:!1}),[g,h]),y=m?.containerBlock,_="footer"===y?.containerType,f=(p||"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(_&&(""===f||"{{Address}}"===f||"{{Tagline}}"===f))return null;const x=o.type&&/^h[1-4]$/.test(o.type)?o.type:"div";return u?l.jsx(zo,{...t,blockItem:o}):e.createElement(x,{style:{...d,direction:"ltr",unicodeBidi:"isolate"},dir:"ltr",dangerouslySetInnerHTML:{__html:b}})},Wo=e=>e?.brandContext?.brand_color??"#111111",Ho=t=>{const{blockItem:n,id:o}=t,{currentItem:a,previewMode:i,templateData:r,blockMap:s,rootOrder:c}=e.useContext(ge),d=e.useMemo(()=>D(s,c,o),[o,s,c]),u=e.useMemo(()=>{const e=n.text??"",t=e.match(/\{\{(\w+)\}\}/),o=n.labelVariable?n.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():t?t[1]:void 0;if(!r||!o)return e;const a=yt(r,o,d);return null==a||String(a).startsWith("{{")?e:String(a)},[n.text,n.labelVariable,r,d]),m=a&&a.id===o,p="desktop"===i?n.styles?.desktop??{}:{...n.styles?.desktop??{},...n.styles?.mobile??{}},g={...p,backgroundColor:p.backgroundColor??Wo(r)},h="desktop"===i?n.contentStyles?.desktop:{...n.contentStyles?.desktop,...n.contentStyles?.mobile},b=e.useMemo(()=>l.jsx(zo,{...t,blockItem:{...n,styles:{...n.styles,desktop:{...n.styles?.desktop,backgroundColor:g.backgroundColor}}},displayContent:u}),[n,u,g.backgroundColor]);return l.jsx("div",{style:{...h},children:m?b:l.jsx("div",{style:{...g,textAlign:"center"},dangerouslySetInnerHTML:{__html:u}})})},Vo=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),o="desktop"===n?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},a="desktop"===n?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile};return l.jsx("div",{className:"relative",children:l.jsx("div",{style:{...a},children:l.jsx("div",{style:{...o}})})})},Ko=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),o="desktop"===n?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},a="desktop"===n?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile};return l.jsx("div",{className:"relative",style:{...a},children:l.jsx("div",{style:{width:"100%",height:"number"==typeof o.height?`${o.height}px`:o.height||"16px",display:o.display||"block"}})})},Go={left:"flex-start",center:"center",right:"flex-end",justify:"space-between"},qo=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),{list:o=[],separator:a=" | "}=t,i=o,r=Ht("desktop"===n?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}}),s="desktop"===n?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},c=s&&"object"==typeof s?{...s}:{},d=c.textAlign??"center",u=Go[d]??Go.center;delete c.textAlign;const m=t.linkGapPx,p="number"==typeof m&&Number.isFinite(m)&&m>=0?m:0,g=Boolean(t.linkUnderline),h=r.fontWeight,b="normal"===h||"bold"===h?h:null!=h?String(h):"400",y={fontSize:null!=r.fontSize?`${r.fontSize}px`:"14px",fontFamily:r.fontFamily||"sans-serif",color:r.linkColor||r.color||"#2faade",fontWeight:b,letterSpacing:null!=r.letterSpacing?`${r.letterSpacing}px`:"0px",textDecoration:g?"underline":"none",textTransform:r.textTransform??"none",paddingLeft:"8px",paddingRight:"8px",paddingTop:"4px",paddingBottom:"4px"},_={fontSize:null!=r.fontSize?`${r.fontSize}px`:"14px",color:r.color||"#333",display:"inline-flex",alignItems:"center",whiteSpace:"pre"},f=p>0?{..._,marginLeft:p,marginRight:p}:{..._,paddingLeft:4,paddingRight:4};return l.jsx("div",{className:"relative",children:l.jsx("div",{style:{...c,display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:u},children:i.map((t,n)=>l.jsxs(e.Fragment,{children:[n>0?l.jsx("span",{style:f,children:a}):null,l.jsx("a",{href:t.url?t.url.startsWith("http")?t.url:`https://${t.url}`:"#",target:"_blank"===t.target?"_blank":"_self",rel:"_blank"===t.target?"noopener noreferrer":void 0,style:y,children:t.label||"Link"})]},n))})})};function Jo(e){return null!=e&&"string"==typeof e&&/<[a-zA-Z!/?]/.test(e.trim())}function Yo(e){switch(e){case"h1":case"h2":case"h3":return 700;case"subtitle":case"eyebrow":return 600;default:return 400}}const Xo=({blockItem:t,id:a})=>{const{src:i,alt:r,linkURL:s}=t,{previewMode:c,templateData:d,blockMap:u,rootOrder:p,bodySettings:g}=e.useContext(ge),h="desktop"===c?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},b="desktop"===c?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},y=e.useMemo(()=>{const e="string"==typeof i&&/^\{\{\w+\}\}$/.test(i.trim())?i.trim():"";if(i&&!e)return i;if(!d||!e)return i||"";const t=D(u,p,a),n=e.replace(/^\{\{|\}\}$/g,"").trim(),o=yt(d,n,t);return o&&!o.startsWith("{{")?o:i||""},[i,d,u,p,a]),_="string"==typeof i&&/^\{\{\w+\}\}$/.test(i.trim())?i.trim():"",f=!y||y.startsWith("{{"),x=r||"Image",k=h.width,v=k&&"auto"!==k,w="string"==typeof s?s.trim():"",j=""===w?"":m(w,{allowMailtoTel:!0})??"",S=Boolean(t.textOverlayEnabled)&&function(e){const t=Array.isArray(e.overlayItems)?e.overlayItems:[];return t.length>0?t.some(e=>""!==String(e?.text??"").trim()):""!==String(e.overlayText??"").trim()}(t)&&y&&!f,C=()=>{const e=String(t.overlayText??"").replace(/<script\b[\s\S]*?<\/script>/gi,"");return Jo(e)?l.jsx("span",{className:"ee-image-overlay-caption-html",dangerouslySetInnerHTML:{__html:e}}):l.jsx("span",{className:"ee-image-overlay-caption-plain",style:{whiteSpace:"pre-wrap"},children:e})},N=()=>{const e=Array.isArray(t.overlayItems)?t.overlayItems:[],n="number"==typeof t.overlayItemGap?t.overlayItemGap:8,o="number"==typeof t.overlayMaxWidth?t.overlayMaxWidth:100,a="number"==typeof t.overlayPadding?t.overlayPadding:16,i=t.textShadowEnabled?"0 1px 3px rgba(0,0,0,0.55)":"none",r=g?.styles?.fontFamily??"sans-serif";return l.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:n,width:`${o}%`,maxWidth:"100%",padding:a,boxSizing:"border-box"},children:e.map((e,t)=>{const n=String(e?.text??"").replace(/<script\b[\s\S]*?<\/script>/gi,""),o="number"==typeof e?.fontSize?e.fontSize:16,a=e?.color||"#ffffff",s=null!=e?.fontFamily&&""!==String(e.fontFamily).trim()?String(e.fontFamily).trim():r;return l.jsx("div",{style:{color:a,fontSize:o,fontFamily:s,fontWeight:Yo(e?.kind),lineHeight:1.35,textShadow:i,wordBreak:"break-word"},children:Jo(n)?l.jsx("span",{className:"ee-image-overlay-caption-html",dangerouslySetInnerHTML:{__html:n}}):l.jsx("span",{style:{whiteSpace:"pre-wrap"},children:n})},t)})})},I=S?(()=>{const e=sn(rn(t.overlayPosition)),n=h.borderRadius,o="number"==typeof t.overlayMaxWidth?t.overlayMaxWidth:100,a="number"==typeof t.overlayPadding?t.overlayPadding:16,i={position:"relative",display:v?"inline-block":"block",width:v?k:"100%",maxWidth:"100%",borderRadius:n,overflow:"hidden",lineHeight:0,verticalAlign:"top"},r=Array.isArray(t.overlayItems)?t.overlayItems:[],s=r.length>0&&r.some(e=>""!==String(e?.text??"").trim()),c={...e,position:"absolute",pointerEvents:"none",zIndex:2,maxWidth:`${o}%`,boxSizing:"border-box",...s?{}:{color:t.overlayTextColor||"#ffffff",fontSize:"number"==typeof t.overlayFontSize?t.overlayFontSize:18,fontWeight:600,lineHeight:1.35,padding:a,textShadow:t.textShadowEnabled?"0 1px 3px rgba(0,0,0,0.55)":void 0,...t.overlayBoxBackground?{backgroundColor:t.overlayBoxBackground,padding:`${Math.max(8,a/2)}px 12px`}:{}}},d=l.jsx("img",{src:y,style:{...h,width:"100%",maxWidth:"100%",display:"block",borderRadius:0,verticalAlign:"top"},alt:x});return l.jsxs("div",{className:"ee-image-overlay-host",style:i,children:[t.scrimEnabled?l.jsx("div",{style:{position:"absolute",left:0,right:0,top:0,bottom:0,pointerEvents:"none",zIndex:1,background:"linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0.12), transparent 55%)"},"aria-hidden":!0}):null,l.jsx("div",{style:{position:"relative",zIndex:0},children:d}),l.jsx("div",{className:"ee-image-overlay-caption",style:c,children:s?N():C()})]})})():y&&!f?v?l.jsx("div",{style:{width:k,display:"inline-block"},children:l.jsx("img",{src:y,style:{...h,width:"100%",maxWidth:"100%"},alt:x,className:"inline-block"})}):l.jsx("img",{src:y,style:h,alt:x,className:"inline-block"}):l.jsx("div",{className:"empty-image",style:{...h,width:"auto"===h.width?"100%":h.width},title:f&&_?_:void 0,children:f&&_?l.jsx("span",{className:"empty-image-variable-label",children:_}):l.jsx(n.FontAwesomeIcon,{icon:o.faImage,className:"empty-image-icon"})}),A=It(t)&&j&&y&&!f?l.jsx("a",{href:j,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none",display:"inline-block",maxWidth:"100%"},onClick:e=>e.stopPropagation(),children:I}):I;return l.jsx("div",{className:"relative",children:l.jsx("div",{style:{...b||{}},children:A})})},Zo=({blockItem:t})=>{const{src:a,alt:i,linkURL:r}=t,{previewMode:s}=e.useContext(ge),c="desktop"===s?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},d="desktop"===s?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},u=a?l.jsx("img",{src:a,style:{...c,width:c.width??64,height:c.width??64,objectFit:"cover",borderRadius:c.borderRadius??"50%"},alt:i||"Avatar",className:"inline-block"}):l.jsx("div",{className:"empty-avatar",style:{width:c.width??64,height:c.width??64,borderRadius:c.borderRadius??"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--ee-border, #eee)"},children:l.jsx(n.FontAwesomeIcon,{icon:o.faUser,style:{fontSize:"24px",color:"#999"}})}),p={...d,width:"100%"},g=null!=r&&String(r).trim()?m(r,{allowMailtoTel:!0}):null;return l.jsx("div",{className:"relative",children:l.jsx("div",{style:p,children:g?l.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block"},children:u}):u})})},Qo=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),{t:o}=So(),{list:a=[]}=t,i=qt(t),r=Wt(t?.iconColor),s="desktop"===n?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},c=Ht(s),d="desktop"===n?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},u=Boolean(t.showTextLabel),p=s.color||"#525252",g=Math.max(11,Math.round(.58*i)),h=y(a);return 0===h.length?null:l.jsx("div",{className:"relative",children:l.jsx("div",{style:Gt(d),children:h.map((e,t)=>{const{image:n,title:a,linkURL:s}=e,d=zt(e)?o("social_platform_x_alt"):a,h=zt(e)?o("social_platform_x"):a,{src:b,style:y}=Yt(e,r,i),_=l.jsx("img",{src:b||n,alt:d,style:y}),f=m(s,{allowMailtoTel:!1});return l.jsx("div",{style:{...c,display:"inline-flex",alignItems:"center"},children:l.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:u?8:0,textDecoration:"none",color:p},children:[_,u?l.jsx("span",{style:{fontSize:g,lineHeight:1.2,color:p,whiteSpace:"nowrap"},children:h}):null]})},t)})})})};const ea=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),o="desktop"===n?{...t.contentStyles?.desktop??{}}:{...t.contentStyles?.desktop??{},...t.contentStyles?.mobile??{}},{outer:a,inner:i}=function(e){if(!e||"object"!=typeof e)return{outer:{width:"100%",textAlign:"center",boxSizing:"border-box"},inner:{width:"100%",maxWidth:"100%",display:"inline-block",verticalAlign:"top",boxSizing:"border-box"}};const{textAlign:t="center",width:n="100%",paddingTop:o,paddingRight:a,paddingBottom:l,paddingLeft:i,backgroundColor:r,...s}=e;return{outer:{width:"100%",textAlign:t,boxSizing:"border-box"},inner:{width:n,maxWidth:"100%",display:"inline-block",verticalAlign:"top",boxSizing:"border-box",paddingTop:o,paddingRight:a,paddingBottom:l,paddingLeft:i,backgroundColor:r,...s}}}(o),r=e.useCallback(e=>{const t=e.target?.closest?.("a[href]");if(!t)return;e.preventDefault(),e.stopPropagation();const n=(t.getAttribute("href")||"").trim();if(n&&!/^javascript:/i.test(n)&&!/^data:/i.test(n))if(/^https?:\/\//i.test(n)||n.startsWith("//")){const e=n.startsWith("//")?`https:${n}`:n;window.open(e,"_blank","noopener,noreferrer")}else(/^mailto:/i.test(n)||/^tel:/i.test(n))&&window.open(n,"_blank","noopener,noreferrer")},[]);return l.jsx("div",{className:"relative ee-raw-html-block",children:l.jsx("div",{className:"ee-raw-html-outer",style:a,children:l.jsx("div",{className:"ee-raw-html-inner",style:i,children:l.jsx("div",{className:"ee-raw-html-content",role:"region","aria-label":"Custom HTML preview",onClick:r,dangerouslySetInnerHTML:{__html:t.html??""}})})})})},ta=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),o="desktop"===n?{...t.styles?.desktop??{}}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},a="number"==typeof t.rows?t.rows:3,i="number"==typeof t.cols?t.cols:3,r=Boolean(t.headerRow),s=Boolean(t.headerCol),c=Boolean(t.stripedRows),d=o.fontSize??14,u=o.color??"#333333",m=o.borderStyle??"solid",p=o.borderWidth??1,g=o.borderColor??"#e0e0e0",h=o.cellPadding??8,b=o.textAlign??"left",y=o.headerBg??"#f5f5f5",_=o.headerColor??"#333333",f=o.stripedBg??"#fafafa",x="none"!==m?`${p}px ${m} ${g}`:"none",k=(e,t)=>{const n=r&&0===e||s&&0===t;return{border:x,padding:h,fontSize:d,color:n?_:u,textAlign:b,backgroundColor:n?y:c&&!n&&e%2==0?f:"transparent",fontWeight:n?600:400,verticalAlign:"top"}},v={...t.contentStyles?.desktop??{},..."desktop"!==n?t.contentStyles?.mobile??{}:{}},w=(e,n)=>{const o=`${e}-${n}`,a=t.cells?.[o];if("image"===a?.type&&String(a.src??"").trim())return l.jsx("img",{src:a.src,alt:a.alt||"",style:{maxWidth:"100%",height:"auto",display:"block"}});const i=a?.text??"";return i?l.jsx("span",{style:{whiteSpace:"pre-wrap"},children:i}):l.jsx("span",{style:{color:"rgba(0,0,0,0.35)",fontStyle:"italic",fontWeight:400},children:"—"})};return l.jsx("div",{style:{width:"100%",boxSizing:"border-box",paddingTop:v.paddingTop??0,paddingBottom:v.paddingBottom??0,paddingLeft:v.paddingLeft??0,paddingRight:v.paddingRight??0,textAlign:v.textAlign??"left",overflowX:"auto"},children:l.jsx("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"auto"},children:l.jsx("tbody",{children:Array.from({length:a}).map((e,t)=>l.jsx("tr",{children:Array.from({length:i}).map((e,n)=>{const o=r&&0===t||s&&0===n?"th":"td";return l.jsx(o,{style:k(t,n),children:w(t,n)},`${t}-${n}`)})},t))})})})},na=({blockItem:t})=>{const{previewMode:a}=e.useContext(ge),i=e.useMemo(()=>"desktop"===a?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},[t.styles,a]),r=e.useMemo(()=>"desktop"===a?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},[t.contentStyles,a]),s=e.useMemo(()=>"desktop"===a?t.videoArea?.desktop??{}:{...t.videoArea?.desktop??{},...t.videoArea?.mobile??{}},[t.videoArea,a]),c="string"==typeof t.videoUrl?t.videoUrl.trim():"",d=Boolean(i.fillColumn),u=Boolean(i.fillColumnMobile),m="desktop"===a?d:u||d,p=e.useMemo(()=>cn(c,t.thumbnailUrl),[c,t.thumbnailUrl]),g=e.useMemo(()=>{let e=i.width,t=i.height;null!=e&&""!==e||(e="auto"),null!=t&&""!==t||(t="auto"),m&&(e="100%");const n=r?.textAlign||"center";let o="0 auto";return"left"===n?o="0":"right"===n&&(o="0 0 0 auto"),{width:"number"==typeof e?`${e}px`:e,height:"number"==typeof t?`${t}px`:t,display:"block",margin:o,maxWidth:"100%"}},[i,m,r?.textAlign]),h=e.useMemo(()=>{const e=s||{},t=null!=e.borderWidth?Number(e.borderWidth):0;let n="none";return t>0&&e.borderStyle&&"none"!==e.borderStyle&&(n=`${t}px ${e.borderStyle} ${e.borderColor??"#cccccc"}`),{paddingTop:e.paddingTop??0,paddingBottom:e.paddingBottom??0,paddingLeft:e.paddingLeft??0,paddingRight:e.paddingRight??0,backgroundColor:e.backgroundColor||"transparent",border:n,borderRadius:e.borderRadius??0,boxSizing:"border-box"}},[s]),b=e.useMemo(()=>{let e=i.width;m&&(e="100%"),null!=e&&""!==e||(e="auto");const t="auto"===e?"100%":"number"==typeof e?`${e}px`:e,n=s?.borderRadius;return{width:t,maxWidth:"100%",boxSizing:"border-box",...null!=n&&""!==n?{borderRadius:n}:{}}},[i.width,m,s?.borderRadius]),y=!p,_=c.startsWith("http://")||c.startsWith("https://")||c.startsWith("//")?c.startsWith("//")?`https:${c}`:c:c?`https://${c.replace(/^\/+/,"")}`:"",f=y?l.jsx("div",{className:"empty-image ee-video-inner",style:b,children:l.jsx(n.FontAwesomeIcon,{icon:o.faVideo,className:"empty-image-icon"})}):l.jsx("div",{className:"ee-video-inner",style:h,children:_?l.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",style:{display:"block",lineHeight:0,textDecoration:"none"},onClick:e=>e.stopPropagation(),children:l.jsx("img",{src:p,alt:"Video thumbnail",className:"ee-video-thumb",style:g})}):l.jsx("img",{src:p,alt:"Video thumbnail",className:"ee-video-thumb",style:g})});return l.jsx("div",{className:"relative ee-video-block",children:l.jsx("div",{style:{...r||{}},children:f})})},oa=({blockItem:e,id:t})=>{if(!e)return null;const n={blockItem:e,id:t};switch(e.key){case"text":return l.jsx(Oo,{...n});case"button":return l.jsx(Ho,{...n});case"divider":return l.jsx(Vo,{...n});case"spacer":return l.jsx(Ko,{...n});case"menu":return l.jsx(qo,{...n});case"image":return l.jsx(Xo,{...n});case"video":return l.jsx(na,{...n});case"avatar":return l.jsx(Zo,{...n});case"social_link":return l.jsx(Qo,{...n});case"raw_html":return l.jsx(ea,{...n});case"table":return l.jsx(ta,{...n});default:return null}},aa={tree:null};function la(e,t,n){if(!n||!e[n])return null;if(t.includes(n))return P(n,e);const o=e[n];return"column"===o.key?P(n,e):C(o)}function ia(e,t,n){const o=la(e,t,n);return o?ra(e,t,o,n):null}function ra(e,t,n,o){if(!n||!o||!e[o])return null;const a=B(n),l=t.indexOf(o);if(-1!==l){const{newBlockMap:n,rootId:o}=K(e,a);if(!o)return null;const i=[...t];i.splice(l+1,0,o);const r=n[o];return{nextMap:n,nextRootOrder:i,newId:o,selectionData:"column"===r?.key?P(o,n):r}}const i=F(e,t,o);if(!i)return null;const{newBlockMap:r,rootId:s}=K(e,a);if(!s)return null;const c=O(r,i.containerId,i.cellIndex,i.itemIndex+1,s),d=c[s];return{nextMap:c,nextRootOrder:t,newId:s,selectionData:"column"===d?.key?P(s,c):d}}function sa(e,t,n,o){if(!n)return null;if(o&&e[o])return ra(e,t,n,o);const a=B(n),{newBlockMap:l,rootId:i}=K(e,a);if(!i)return null;const r=l[i],s="column"===r?.key?P(i,l):r;return{nextMap:l,nextRootOrder:[...t,i],newId:i,selectionData:s}}function ca(e,t){const n=e[t];if(!n||"column"!==n.key)return!1;for(const t of n.cells||[])for(const n of t.childrenIds||[]){const t=e[n];if(t&&"empty"!==t.key)return!0}return!1}function da(e,t,n,o){if(!n||!e[n])return null;if(-1!==t.indexOf(n)){return{nextMap:H(e,n),nextRootOrder:t.filter(e=>e!==n)}}const a=F(e,t,n);if(!a)return null;const{blockMap:l,removedId:i}=z(e,a.containerId,a.cellIndex,a.itemIndex);let r=l;const s=l[a.containerId];if(s&&0===s.cells[a.cellIndex].childrenIds.length){const e=$(o("drag_block_here"));r={...l,[e.id]:e,[a.containerId]:{...s,cells:s.cells.map((t,n)=>n===a.cellIndex?{...t,childrenIds:[e.id]}:t)}}}return i&&(r=H(r,i)),{nextMap:r,nextRootOrder:t}}function ua(e){return e&&"column"===e.key?"section"===e.layoutRole||"columns"===e.layoutRole?e.layoutRole:!0===e.columnLayoutOnly?"columns":"section":null}const ma="section",pa="columns",ga="ee:open-configure-columns";function ha(e){"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(ga,{detail:null!=e&&String(e).length>0?{rootId:e}:{}}))}const ba=o.faCog;function ya(e,t){if(!t?.key)return{icon:o.faSquare,label:""};const{key:n,containerType:a}=t;if("column"===n)return"product"===a?{icon:o.faCube,label:e("block_product")}:"discount"===a?{icon:o.faTag,label:e("block_discount")}:ua(t)===pa?{icon:o.faColumns,label:e("block_palette_columns")}:{icon:o.faSquare,label:e("block_palette_section")};switch(n){case"text":return{icon:o.faFont,label:e("text")};case"button":return{icon:o.faLink,label:e("button")};case"image":return{icon:o.faImage,label:e("image")};case"video":return{icon:o.faVideo,label:e("video")};case"divider":return{icon:o.faGripLines,label:e("divider")};case"spacer":return{icon:o.faArrowsAltV,label:e("spacer")};case"menu":return{icon:o.faBars,label:e("menu")};case"avatar":return{icon:o.faUser,label:e("avatar")};case"social_link":return{icon:o.faShareAlt,label:e("social_link")};case"raw_html":return{icon:o.faCode,label:e("raw_html")};case"table":return{icon:o.faTable,label:e("table")};case"empty":return{icon:o.faSquare,label:""};default:return{icon:o.faSquare,label:n||""}}}const _a=a=>{const{block:i,blockIndex:r,clearStyles:s}=a,{t:c}=So(),{previewMode:d,blockMap:u,rootOrder:m,validationMarkers:p,ignoreValidationIssue:g,setBlocks:h,currentItem:b,setCurrentItem:y,setIsDragStart:_,isDragStart:f,bodySettings:x,setActionType:k,onSaveBlockAsGlobal:v}=e.useContext(ge),w="desktop"===d?i.styles?.desktop??{}:{...i.styles?.desktop??{},...i.styles?.mobile??{}},{contentBackground:C,containerBackgroundImage:N,containerBackgroundSize:I,containerBackgroundPosition:A,...T}=w,L="undefined"!=typeof window?window.__eeDragItemData:null,B=L?.key??(b?.id?u[b.id]?.key:null)??b?.data?.key,R=f&&"column"!==B,M=e=>t=>{t.preventDefault(),t.stopPropagation(),y({id:e.id,data:e,type:"edit"}),k("edit")},P=e=>t=>{t.preventDefault(),t.stopPropagation();const n=u[e];n&&(y({id:n.id,data:n,type:"edit"}),k("edit"))},F=(e,t,n)=>o=>{o.preventDefault(),o.stopPropagation();const{blockMap:a,removedId:l}=z(u,e,t,n);let i=a;const r=a[e];if(r&&0===r.cells[t].childrenIds.length){const n=$(c("drag_block_here"));i={...a,[n.id]:n,[e]:{...r,cells:r.cells.map((e,o)=>o===t?{...e,childrenIds:[n.id]}:e)}}}l&&(i=H(i,l)),h(i,m,"delete"),y(null)},E=e=>()=>{_(!0),y({id:e.id,data:e,type:"move"}),k("move")},D=e=>{e.preventDefault(),e.stopPropagation(),setTimeout(()=>{e.target.style.border="",e.target.children[0]&&e.target.children[0].classList.remove("sidebar-block-move"),_(!1),s&&s()},50)},U=e=>e.preventDefault(),O=e=>{e.preventDefault(),e.stopPropagation()},V=(e,t)=>n=>{O(n);const o=W(u,m,e,t);o&&h(o.nextMap,o.nextRootOrder,"move")},K=e=>t=>{O(t);const n=ia(u,m,e);n&&(h(n.nextMap,n.nextRootOrder,"add"),y({id:n.newId,data:n.selectionData,type:"edit"}))},G=e=>"desktop"===d?e.styles?.desktop||{}:{...e.styles?.desktop||{},...e.styles?.mobile||{}},q=j(x),J=S(x),Y=e=>{const n=p?.[e];if(!n)return null;const o="error"===n.severity?`${n.errorCount} error${1===n.errorCount?"":"s"}`:`${n.warningCount} warning${1===n.warningCount?"":"s"}`,a=l.jsx("div",{className:"block-validation-popover",children:n.issues.map((e,n)=>l.jsxs("div",{className:"block-validation-popover-item",children:[l.jsx("div",{className:"block-validation-popover-message",children:e.message}),l.jsx(t.Button,{size:"small",type:"text",className:"block-validation-popover-ignore",onClick:t=>{t.preventDefault(),t.stopPropagation(),g(e)},children:c("ignore")})]},`${e.code}-${n}`))});return l.jsx(t.Popover,{trigger:["hover","click"],placement:"topRight",overlayClassName:"block-validation-popover-overlay",content:a,getPopupContainer:()=>document.querySelector("#preview")||document.body,children:l.jsxs("button",{type:"button",className:fo("block-validation-indicator","error"===n.severity?"block-validation-indicator-error":"block-validation-indicator-warning"),"aria-label":o,onClick:e=>{e.preventDefault(),e.stopPropagation()},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},children:[l.jsx("span",{className:"block-validation-indicator-dot"}),l.jsx("span",{className:"block-validation-indicator-count",children:n.totalCount})]})})},X=(t,a,i,r,s,m,p=1)=>{const g=G({styles:t.styles}),{contentBackground:h,containerBackgroundImage:y,containerBackgroundSize:_,containerBackgroundPosition:f,...k}=g,v=b?.id===t.id,w=((e=1)=>({"--nested-level":Math.max(1,e),"--nested-width":"100%"}))(p);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative block-content-drag-label-content","data-drop-key":s,children:[l.jsx("div",{className:"absolute block-move-top",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})}),R&&l.jsx("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":a,"data-cell-index":i,"data-item-index":r,"data-drop-key":s,"data-type":"block-item-move"})]}),l.jsx("div",{className:fo("block-item block-item-container",v&&"block-item-focus"),style:w,"data-block-id":t.id,onMouseEnter:e=>{e.currentTarget.dataset.hovered="true"},onMouseLeave:e=>{delete e.currentTarget.dataset.hovered},children:l.jsxs("div",{className:"relative",children:[Y(t.id),l.jsx("div",{className:"block-item-tools",onDragOver:U,onClick:M(t),children:R&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":a,"data-cell-index":i,"data-item-index":r,"data-drop-key":s,"data-type":"block-item-move"}),l.jsx("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":a,"data-cell-index":i,"data-item-index":r+1,"data-drop-key":m,"data-type":"block-item-move"})]})}),(()=>{const e=u[a]?.cells?.[i],s=r>0,d=r<(e?.childrenIds?.length??0)-1,m=ya(c,t);return l.jsxs("div",{className:"block-chrome-overlay",children:[l.jsxs("span",{className:"block-chrome-badge",children:[l.jsx(n.FontAwesomeIcon,{icon:m.icon}),l.jsx("span",{children:m.label})]}),l.jsxs("div",{className:"block-chrome-toolbar",children:[l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:P(a),title:c("select_parent_section_tooltip"),children:l.jsx(n.FontAwesomeIcon,{icon:ba})}),l.jsx("span",{className:fo("block-chrome-action",!s&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(t.id,-1),title:c("context_move_up"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronUp})}),l.jsx("span",{className:fo("block-chrome-action",!d&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(t.id,1),title:c("context_move_down"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronDown})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:K(t.id),title:c("context_duplicate"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faCopy})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action block-chrome-action-danger",onMouseDown:O,onClick:F(a,i,r),title:c("layer_delete"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash})}),l.jsx("span",{className:"block-chrome-action block-chrome-action-disabled ee-section-nested-no-drag",draggable:!1,onMouseDown:e=>e.stopPropagation(),title:c("section_nest_not_allowed"),style:{cursor:"not-allowed"},children:l.jsx(n.FontAwesomeIcon,{icon:o.faArrowsAlt})})]})]})})(),l.jsx("div",{style:{...k,overflow:k.borderRadius?"hidden":void 0},children:l.jsx("div",{className:"block-content block-item-container-body",style:{...on(g,h),borderRadius:k.borderRadius,overflow:k.borderRadius?"hidden":void 0,...null!=k.minHeight&&""!==k.minHeight&&""!==String(k.minHeight).trim()?{minHeight:k.minHeight}:{}},children:(t.children||[]).map((n,o)=>{const a=G(n);return l.jsx("div",{style:{...a,width:"mobile"===d&&!1!==x.stackColumnsOnMobile?"100%":n.width},children:(n.children||[]).map((a,i)=>{const r=`${t.id}:${o}:${i}`,s=`${t.id}:${o}:${i+1}`,d=i===n.children.length-1&&"empty"!==a.key&&"column"!==a.key;return l.jsxs(e.Fragment,{children:[Z(a,t.id,o,i,r,s,p),d&&l.jsx("div",{className:"relative block-content-drag-label-content","data-drop-key":s,children:l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})})})]},`${t.id}:${o}:${a.id||i}`)})},`${t.id}:${n.id||"cell"}:${o}`)})})})]})}),l.jsxs("div",{className:"relative block-content-drag-label-content","data-drop-key":m,children:[l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})}),R&&l.jsx("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":a,"data-cell-index":i,"data-item-index":r+1,"data-drop-key":m,"data-type":"block-item-move"})]})]})},Z=(t,a,i,r,s,d,m=0)=>"empty"===t.key?l.jsx("div",{className:"relative width-full",children:l.jsx("div",{className:"block-empty-content ee-empty-drop-slot",onDragOver:R?U:void 0,...R?{"data-container-id":a,"data-cell-index":i,"data-item-index":r,"data-type":"empty-block-item"}:{},"aria-label":t.name||c("drag_block_here"),children:l.jsx("span",{className:"ee-empty-drop-slot__label",children:c("drag_block_here")})})},t.id||r):"column"===t.key?l.jsx(e.Fragment,{children:X(t,a,i,r,s,d,m+1)},`${a}:${i}:${t.id||r}`):l.jsxs(e.Fragment,{children:[l.jsx("div",{className:"relative block-content-drag-label-content","data-drop-key":s,children:l.jsx("div",{className:"absolute block-move-top",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})})}),l.jsx("div",{className:fo("block-item",b?.id===t.id&&"block-item-focus",t.hidden&&"block-hidden-dim"),"data-block-id":t.id,children:l.jsxs("div",{className:"relative",children:[Y(t.id),l.jsx("div",{className:"block-item-tools",onDragOver:U,onClick:e=>{e.preventDefault(),e.stopPropagation(),y({id:t.id,data:t,type:"edit"}),k("edit")},children:R&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":a,"data-cell-index":i,"data-item-index":r,"data-drop-key":s,"data-type":"block-item-move"}),l.jsx("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":a,"data-cell-index":i,"data-item-index":r+1,"data-drop-key":d,"data-type":"block-item-move"})]})}),(()=>{const e=u[a]?.cells?.[i],s=r>0,d=r<(e?.childrenIds?.length??0)-1,m=ya(c,t);return l.jsxs("div",{className:"block-chrome-overlay",children:[l.jsxs("span",{className:"block-chrome-badge",children:[l.jsx(n.FontAwesomeIcon,{icon:m.icon}),l.jsx("span",{children:m.label})]}),l.jsxs("div",{className:"block-chrome-toolbar",children:[l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:P(a),title:c("select_parent_section_tooltip"),children:l.jsx(n.FontAwesomeIcon,{icon:ba})}),l.jsx("span",{className:fo("block-chrome-action",!s&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(t.id,-1),title:c("context_move_up"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronUp})}),l.jsx("span",{className:fo("block-chrome-action",!d&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(t.id,1),title:c("context_move_down"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronDown})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:K(t.id),title:c("context_duplicate"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faCopy})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action block-chrome-action-danger",onMouseDown:O,onClick:F(a,i,r),title:c("layer_delete"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash})}),l.jsx("span",{className:"block-chrome-action block-chrome-drag",draggable:"true",onMouseDown:e=>e.stopPropagation(),onDragEnd:D,onDragStart:E(t),title:c("drag_to_move")||"Drag to move",children:l.jsx(n.FontAwesomeIcon,{icon:o.faArrowsAlt})})]})]})})(),l.jsx(oa,{blockItem:t,id:t.id})]})})]},`${a}:${i}:${t.id||r}`),Q=ya(c,i),ee="column"===b?.data?.key&&ua(b.data)===pa?c("block_palette_columns"):c("container");return l.jsx(l.Fragment,{children:l.jsxs("div",{className:fo("relative block-drag-label-content",f&&"column"===B&&"ee-section-drop-preview"),"data-index":r,"data-position":"top",children:[f&&"column"===B?l.jsxs("div",{className:"ee-section-drop-slot-outline","aria-hidden":!0,children:[l.jsx("span",{className:"ee-section-drop-badge",children:ee}),l.jsx("span",{className:"ee-section-drop-hint",children:c("drag_section_here")})]}):null,l.jsx("div",{className:"absolute block-move-top",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})}),l.jsxs("div",{className:fo("relative block",b?.id===i.id&&"block-focus","mobile"===d&&"mobile-block-focus",i.hidden&&"block-hidden-dim"),"data-block-id":i.id,onClick:M(i),children:[l.jsxs("div",{className:"hover-visible",children:[Y(i.id),l.jsxs("div",{className:"block-chrome-overlay",children:[l.jsxs("span",{className:"block-chrome-badge",children:[l.jsx(n.FontAwesomeIcon,{icon:Q.icon}),l.jsx("span",{children:Q.label})]}),l.jsxs("div",{className:"block-chrome-toolbar",children:[l.jsx("span",{className:fo("block-chrome-action",r<=0&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(i.id,-1),title:c("context_move_up"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronUp})}),l.jsx("span",{className:fo("block-chrome-action",r>=m.length-1&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(i.id,1),title:c("context_move_down"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronDown})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:K(i.id),title:c("context_duplicate"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faCopy})}),"function"==typeof v&&l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:(te=i,e=>{O(e),window.dispatchEvent(new CustomEvent("ee:canvas-save-universal",{detail:{block:te}}))}),title:c("save_as_universal"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faStar})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action block-chrome-action-danger",onMouseDown:O,onClick:e=>{e.preventDefault(),e.stopPropagation();const t=H(u,i.id),n=m.filter(e=>e!==i.id);h(t,n,"delete"),y(null)},title:c("layer_delete"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash})}),l.jsx("span",{className:"block-chrome-action block-chrome-drag",draggable:"true",onMouseDown:e=>e.stopPropagation(),onDragEnd:D,onDragStart:()=>{_(!0),y({id:i.id,data:i,type:"move"}),k("move")},title:c("drag_to_move")||"Drag to move",children:l.jsx(n.FontAwesomeIcon,{icon:o.faArrowsAlt})})]})]})]}),l.jsx("div",{className:"width-full height-full absolute",onDragOver:U,style:{pointerEvents:f&&"column"===B?"auto":"none"},children:f&&"column"===B&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"block-move-content-top","data-name":"dragTools","data-type":"drag-over-column","data-position":"top","data-index":r}),l.jsx("div",{className:"block-move-content-bottom","data-name":"dragTools","data-type":"drag-over-column","data-position":"bottom","data-index":r+1})]})}),l.jsx("div",{className:"column margin-auto",style:{...T,width:"100%",maxWidth:"100%",overflow:T.borderRadius?"hidden":void 0},children:l.jsx("div",{className:"block-content",style:{...on(w,C),borderRadius:T.borderRadius,overflow:T.borderRadius?"hidden":void 0,width:J?"100%":q,maxWidth:J?"100%":q,...null!=T.minHeight&&""!==T.minHeight&&""!==String(T.minHeight).trim()?{minHeight:T.minHeight}:{}},"data-index":r,children:i.children.map((t,n)=>{const o="desktop"===d?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}};return l.jsx(e.Fragment,{children:l.jsx("div",{id:`block-content-${r}-${n}`,style:{...o,width:"mobile"===d&&!1!==x.stackColumnsOnMobile?"100%":t.width},children:t.children.map((o,a)=>{const r=`${i.id}:${n}:${a}`,s=`${i.id}:${n}:${a+1}`,d=a===t.children.length-1&&"empty"!==o.key&&"column"!==o.key;return l.jsxs(e.Fragment,{children:[Z(o,i.id,n,a,r,s,0),d&&l.jsx("div",{className:"relative block-content-drag-label-content","data-drop-key":s,children:l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})})})]},`${i.id}:${n}:${o.id||a}`)})})},`${i.id}:${t.id||"content"}:${n}`)})})})]})]})});var te};function fa(e){return{id:A(),name:e("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}}function xa(e,t){return{id:A(),name:e("content"),key:"content",width:t,styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[fa(e)]}}function ka(e,{layoutRole:t,columnLayoutOnly:n,name:o}){const a=n?[xa(e,"50%"),xa(e,"50%")]:[xa(e,"100%")];return{id:A(),name:o,key:"column",type:n?"1-1":"full",containerType:"none",layoutRole:t,columnLayoutOnly:n,styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},children:a}}const va=e=>[ka(e,{layoutRole:ma,columnLayoutOnly:!1,name:e("block_palette_section")}),ka(e,{layoutRole:pa,columnLayoutOnly:!0,name:e("block_palette_columns")}),{id:A(),name:e("text"),key:"text",text:e("text_content"),type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",color:void 0,lineHeight:"20px",paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16,textAlign:"left"},mobile:{}}},{id:A(),name:e("button"),key:"button",text:e("button"),type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"auto",fontSize:12,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:20,paddingRight:20,backgroundColor:void 0,color:"#fff",display:"inline-block"},mobile:{}}},{id:A(),name:e("spacer"),key:"spacer",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{height:16,width:"100%",display:"block"},mobile:{}}},{id:A(),name:e("divider"),key:"divider",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}},{id:A(),name:e("raw_html"),key:"raw_html",html:e("raw_html_default_content"),contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center",width:"100%"},mobile:{}},styles:{desktop:{},mobile:{}}},{id:A(),name:e("image"),key:"image",src:"",alt:"Image",type:"link",linkEnabled:!1,linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{id:A(),name:e("video"),key:"video",videoUrl:"",thumbnailUrl:"",styles:{desktop:{width:"auto",height:"auto",fillColumn:!1,fillColumnMobile:!1,display:"inline-block"},mobile:{}},videoArea:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,backgroundColor:"transparent",borderWidth:0,borderStyle:"solid",borderColor:"#cccccc",borderRadius:0},mobile:{}},contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center",backgroundColor:"transparent"},mobile:{}}},{id:A(),name:e("menu"),key:"menu",layoutMode:"nav-only",showLogo:!1,mobileLayout:"stack",linkGapPx:0,linkUnderline:!1,list:[{label:"Page",url:"",target:"_self"},{label:"Page",url:"",target:"_self"}],separator:" | ",contentStyles:{desktop:{paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16,textAlign:"center"},mobile:{}},styles:{desktop:{fontSize:14,fontFamily:"sans-serif",color:"#333333",linkColor:"#2faade",letterSpacing:0,fontWeight:"400",textTransform:"none"},mobile:{}}},{id:A(),name:e("table")||"Table",key:"table",rows:3,cols:3,structureMode:"static",headerRow:!0,headerCol:!1,stripedRows:!1,cells:{},contentStyles:{desktop:{paddingTop:8,paddingBottom:8,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}},styles:{desktop:{fontSize:14,color:"#333333",borderStyle:"solid",borderWidth:1,borderColor:"#e0e0e0",cellPadding:8,textAlign:"left",headerBg:"#f5f5f5",headerColor:"#333333",stripedRows:!1,stripedBg:"#fafafa"},mobile:{}}},{id:A(),name:e("social_link"),key:"social_link",useCompanySocialLinks:!0,list:[],imageWidth:32,iconSize:"medium",iconColor:"default",contentStyles:{desktop:{paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16,textAlign:"left"},mobile:{}},styles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}}}];const wa="ee-block-context-menu";function ja(e,t,n){return{label:e,onSelect:t,disabled:n}}const Sa=()=>{const{t:n}=So(),{blockMap:o,rootOrder:a,setBlocks:r,setCurrentItem:s,onSaveBlockAsGlobal:c}=e.useContext(ge),[d,u]=e.useState(null),m=e.useCallback(()=>u(null),[]);e.useEffect(()=>{const e=e=>{const t=e.target.closest?.(".email-editor");if(!t)return;const n=e.target.closest?.("[data-block-id]");if(!n||!t.contains(n))return;const a=n.getAttribute("data-block-id");a&&o[a]&&(e.preventDefault(),e.stopPropagation(),u({x:e.clientX,y:e.clientY,blockId:a}))},t=e=>{e.target.closest?.(`.${wa}`)||u(null)};return document.addEventListener("contextmenu",e,!0),document.addEventListener("click",t,!0),document.addEventListener("scroll",t,!0),()=>{document.removeEventListener("contextmenu",e,!0),document.removeEventListener("click",t,!0),document.removeEventListener("scroll",t,!0)}},[o]);const p=e.useCallback((e,t)=>{const n=W(o,a,e,t);n&&(r(n.nextMap,n.nextRootOrder,"move"),m())},[o,a,r,m]),g=e.useCallback(e=>Boolean(W(o,a,e,-1)),[o,a]),h=e.useCallback(e=>Boolean(W(o,a,e,1)),[o,a]),b=e.useCallback(e=>{const l=o[e];if(!l)return[];const i=()=>{const t=la(o,a,e);t&&(aa.tree=t)};return[ja(n("context_duplicate"),()=>{const t=ia(o,a,e);t&&(r(t.nextMap,t.nextRootOrder,"add"),s({id:t.newId,data:t.selectionData,type:"edit"}),m())},!1),ja(n("context_copy"),()=>{i(),m()},!1),ja(n("context_cut"),()=>{i();const c=()=>{const t=da(o,a,e,n);t&&(r(t.nextMap,t.nextRootOrder,"delete"),s(null),m())};if("column"===l.key&&ca(o,e))return m(),void t.Modal.confirm({title:n("shortcut_delete_confirm_title"),content:n("shortcut_delete_confirm_desc"),okText:n("confirm"),cancelText:n("cancel"),wrapClassName:"ee-modal-dark",onOk:c});c()},!1),ja(n("context_paste"),()=>{if(!aa.tree)return;const t=sa(o,a,aa.tree,e);t&&(r(t.nextMap,t.nextRootOrder,"add"),s({id:t.newId,data:t.selectionData,type:"edit"}),m())},!aa.tree),ja(n("context_delete"),()=>{const i=()=>{const t=da(o,a,e,n);t&&(r(t.nextMap,t.nextRootOrder,"delete"),s(null),m())};if("column"===l.key&&ca(o,e))return m(),void t.Modal.confirm({title:n("shortcut_delete_confirm_title"),content:n("shortcut_delete_confirm_desc"),okText:n("confirm"),cancelText:n("cancel"),wrapClassName:"ee-modal-dark",onOk:i});i()},!1),ja(n("context_move_up"),()=>p(e,-1),!g(e)),ja(n("context_move_down"),()=>p(e,1),!h(e)),ja(n("context_save_global"),()=>{"function"==typeof c&&c(e),m()},"function"!=typeof c),ja(n("context_reset_styles"),()=>{const t=function(e,t,n){const o=e[t];if(!o||!o.key)return null;const a=va(n).find(e=>e.key===o.key);if(!a)return null;const l={...o};return null!=a.styles&&(l.styles=C(a.styles)),null!=a.contentStyles&&(l.contentStyles=C(a.contentStyles)),{...e,[t]:l}}(o,e,n);if(!t)return;r(t,a,`edit_${Date.now()}`);const l=t[e];l&&s({id:e,data:"column"===l.key?P(e,t):l,type:"edit"}),m()},"empty"===l.key||!va(n).some(e=>e.key===l.key))]},[o,a,r,s,n,m,g,h,p,c]);if(!d)return null;const y=b(d.blockId),_="undefined"!=typeof window?window.innerWidth:9999,f="undefined"!=typeof window?window.innerHeight:9999,x=Math.min(d.x,_-220-8),k=Math.min(d.y,f-360-8);return i.createPortal(l.jsx("div",{className:wa,style:{position:"fixed",left:x,top:k,zIndex:10050,minWidth:220,background:"#1a1a1a",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,boxShadow:"0 12px 40px rgba(0,0,0,0.45)",padding:"6px 0"},role:"menu",onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:y.map(e=>l.jsx("button",{type:"button",role:"menuitem",disabled:e.disabled,className:"ee-block-context-menu-item",style:{display:"block",width:"100%",textAlign:"left",padding:"8px 14px",border:"none",background:"transparent",color:e.disabled?"rgba(255,255,255,0.35)":"#f5f5f5",fontSize:13,cursor:e.disabled?"not-allowed":"pointer"},onMouseEnter:t=>{e.disabled||(t.currentTarget.style.background="rgba(255,255,255,0.08)")},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},onClick:()=>{e.disabled||e.onSelect()},children:e.label},e.label))}),document.body)},Ca=t=>{const{clearStyles:n}=t,{t:o}=So(),{previewMode:a,bodySettings:i,blockList:r,currentItem:s,blockMap:c,isDragStart:d,setSelectionRange:u}=e.useContext(ge),m=e.useRef(null),p="undefined"!=typeof window?window.__eeDragItemData:null,g="undefined"!=typeof window?window.__eeDragSource:null,h=p?.key??(s?.id?c[s.id]?.key:null)??s?.data?.key,b="add"===s?.type||Boolean(p),y=r.length>0&&d&&"product-variables"!==g&&("column"===h||b);e.useEffect(()=>{const e=N(()=>{try{const n=window.getSelection();if(!n||0===n.rangeCount)return;const o=n.getRangeAt(0),a=document.getElementById("preview");if(!(!!a&&(a.contains(o.commonAncestorContainer)||a===o.commonAncestorContainer)))return;const l=(e=>e?{startContainer:e.startContainer,startOffset:e.startOffset,endContainer:e.endContainer,endOffset:e.endOffset,collapsed:e.collapsed}:null)(o);if(e=m.current,t=l,e&&t&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset&&e.collapsed===t.collapsed)return;m.current=l,u(o.cloneRange())}catch(e){console.warn(e)}var e,t},100);return document.addEventListener("selectionchange",e),()=>{document.removeEventListener("selectionchange",e)}},[u]);const _=e=>{e.preventDefault()},f=j(i),x=S(i),k=i?.styles||{},v={width:"desktop"===a?"100%":364,backgroundColor:k.backgroundColor,color:k.color,fontFamily:k.fontFamily},w={maxWidth:"100%",width:"100%",backgroundColor:"transparent",..."mobile"===a&&!1!==i.scaleFontOnMobile?{fontSize:16}:{}};return l.jsxs("div",{className:"preview-main",children:[l.jsx(Sa,{}),l.jsx("div",{className:"default-scrollbar",id:"preview",children:l.jsx("div",{className:"preview-content",style:v,children:l.jsx("div",{className:"margin-auto",style:w,children:r.length?l.jsxs("div",{className:"preview-column-stack",children:[y&&l.jsxs("div",{className:fo("block-drag-label-content preview-edge-drop-zone preview-edge-drop-zone-top","column"===h&&"ee-section-drop-preview"),"data-index":0,"data-position":"top",children:["column"===h?l.jsxs("div",{className:"ee-section-drop-slot-outline ee-section-drop-slot-outline-edge","aria-hidden":!0,children:[l.jsx("span",{className:"ee-section-drop-badge",children:o("container")}),l.jsx("span",{className:"ee-section-drop-hint",children:o("drag_section_here")})]}):null,l.jsx("div",{className:"absolute block-move-top",children:l.jsx("span",{className:"block-tools-drag_here",children:o("drag_block_here")})}),l.jsx("div",{className:"preview-edge-drop-hit","data-name":"dragTools","data-type":"drag-over-column","data-position":"top","data-index":0,onDragOver:_})]}),r.map((t,o)=>l.jsx(e.Fragment,{children:l.jsx(_a,{block:t,blockIndex:o,clearStyles:n})},`${t?.id||"block"}-${o}`)),l.jsxs("div",{className:fo("relative block-drag-label-content","ee-bottom-stack-drop-slot",d&&!y&&"ee-bottom-stack-drop-slot--active"),"data-index":r.length,"data-position":"bottom",style:{minHeight:d&&!y?52:0},children:[d&&!y?l.jsx("div",{className:"ee-bottom-drop-slot-outline","aria-hidden":!0,children:l.jsx("span",{className:"ee-bottom-drop-slot-label",children:o("drag_block_here")})}):null,l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:o("drag_block_here")})}),d&&!y&&l.jsx("div",{"data-name":"dragTools","data-type":"drag-over-column","data-position":"bottom","data-index":r.length,onDragOver:_,style:{position:"absolute",inset:0,zIndex:106,pointerEvents:"auto"}})]}),y&&l.jsxs("div",{className:fo("block-drag-label-content preview-edge-drop-zone preview-edge-drop-zone-bottom","column"===h&&"ee-section-drop-preview"),"data-index":r.length,"data-position":"bottom",children:["column"===h?l.jsxs("div",{className:"ee-section-drop-slot-outline ee-section-drop-slot-outline-edge","aria-hidden":!0,children:[l.jsx("span",{className:"ee-section-drop-badge",children:o("container")}),l.jsx("span",{className:"ee-section-drop-hint",children:o("drag_section_here")})]}):null,l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:o("drag_block_here")})}),l.jsx("div",{className:"preview-edge-drop-hit","data-name":"dragTools","data-type":"drag-over-column","data-position":"bottom","data-index":r.length,onDragOver:_})]})]}):l.jsx("div",{"data-name":"dragEmpty",className:"start-to-add ee-empty-document",style:{width:x?"100%":f,maxWidth:"100%"},"data-type":"empty-block",onDragOver:_,children:l.jsxs("div",{className:"ee-empty-document-inner",children:[l.jsxs("svg",{className:"ee-empty-document__icon",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,children:[l.jsx("rect",{x:"6",y:"22",width:"14",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("rect",{x:"24",y:"22",width:"14",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("rect",{x:"6",y:"6",width:"14",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("rect",{x:"28",y:"4",width:"14",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"})]}),l.jsx("p",{className:"ee-empty-document__title",children:o("drop_content_here")}),l.jsx("p",{className:"ee-empty-document__hint",children:o("drop_content_hint")})]})})})})})]})},Na=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,Ia=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*([0-9.]+))?\s*\)$/i,Aa=e=>(e=>Math.max(0,Math.min(255,Number.isFinite(e)?Math.round(e):0)))(e).toString(16).padStart(2,"0"),Ta=(e,t="#000000")=>{const n=String(e??"").trim();if(!n)return t;if("transparent"===n.toLowerCase())return t;if(/^[0-9a-f]{3}$/i.test(n)){return`#${n.toLowerCase().split("").map(e=>e+e).join("")}`}if(/^[0-9a-f]{6}$/i.test(n))return`#${n.toLowerCase()}`;if(Na.test(n)){if(4===n.length){const[,e,t,o]=n;return`#${e}${e}${t}${t}${o}${o}`.toLowerCase()}return n.toLowerCase()}const o=n.match(Ia);if(o){const e=Number(o[1]),t=Number(o[2]),n=Number(o[3]);return`#${Aa(e)}${Aa(t)}${Aa(n)}`.toLowerCase()}const a=(e=>{if("undefined"==typeof document)return null;const t=document.createElement("span");if(t.style.color="",t.style.color=String(e??"").trim(),!t.style.color)return null;const n=t.style.color.match(Ia);if(!n)return null;const o=Number(n[1]),a=Number(n[2]),l=Number(n[3]);return`#${Aa(o)}${Aa(a)}${Aa(l)}`.toLowerCase()})(n);return a||t},La={backgroundImage:"linear-gradient(45deg, #1f1f1f 25%, transparent 25%), linear-gradient(-45deg, #1f1f1f 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #1f1f1f 75%), linear-gradient(-45deg, transparent 75%, #1f1f1f 75%)",backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px"},Ba=({color:n,setColor:o,fallbackColor:a="#ffffff",variant:i="field"})=>{const[s,c]=e.useState(!1),d=Ta(n,a),u=d,m=l.jsx("div",{className:"select-none ee-color-picker-popover",children:l.jsx(r.ChromePicker,{disableAlpha:!0,color:d,style:{boxShadow:"none"},onChange:e=>o({hex:Ta(e?.hex,a)})})});return l.jsx(t.Popover,{zIndex:1070,getPopupContainer:()=>document.querySelector(".right-settings")||document.body,content:m,trigger:"click",open:s,onOpenChange:c,children:"field"===i?l.jsxs("button",{type:"button",className:"ee-color-picker-field-trigger","aria-label":"Open color picker",children:[l.jsx("span",{className:"ee-color-picker-field-swatch",style:{background:"transparent"===u?void 0:u,..."transparent"===u?La:{}}}),l.jsx("span",{className:"ee-color-picker-field-hex","aria-hidden":!0,children:d.toUpperCase()}),l.jsx("span",{className:"ee-color-picker-field-chevron","aria-hidden":!0})]}):l.jsx("button",{type:"button",className:"color-picker-button","aria-label":"Open color picker",style:{background:u,backgroundImage:"transparent"===u?La.backgroundImage:void 0,backgroundSize:"transparent"===u?La.backgroundSize:void 0,backgroundPosition:"transparent"===u?La.backgroundPosition:void 0}})})},$a=[{key:"paddingTop",suffix:"T"},{key:"paddingRight",suffix:"R"},{key:"paddingBottom",suffix:"B"},{key:"paddingLeft",suffix:"L"}],Ra=({padding:e,onChange:n,min:o=0,disabled:a})=>{const{t:i}=So(),r=t=>o=>{const a="number"==typeof o?o:null==o||""===o?0:Number(o);Number.isNaN(a)||n({...e,[t]:a})};return l.jsx("div",{className:"ee-settings-padding-grid",role:"group","aria-label":i("padding_settings"),children:$a.map(({key:n,suffix:i})=>l.jsx(t.InputNumber,{min:o,step:1,value:e?.[n]??0,onChange:r(n),disabled:a,addonAfter:l.jsx("span",{className:"ee-settings-padding-addon-side","aria-hidden":!0,children:i}),className:"input-width ee-settings-input-affix ee-padding-side-input-num",onFocus:e=>e?.target?.select?.()},n))})},Ma=e=>l.jsx(t.Switch,{...e,className:`ee-settings-switch ${e.className||""}`.trim()}),Pa=({padding:a,setPadding:i,showLinkSides:r=!0})=>{const{t:s}=So(),[c,d]=e.useState(!1);return r?l.jsxs("div",{className:"padding-settings ee-padding-settings-v2",children:[c?l.jsx(t.InputNumber,{min:0,step:1,addonAfter:"px",className:"input-width ee-settings-input-affix ee-padding-linked-input-num",value:a?.paddingTop??0,onChange:e=>{const t="number"==typeof e?e:0;i({...a,paddingTop:t,paddingRight:t,paddingBottom:t,paddingLeft:t})},onFocus:e=>e?.target?.select?.()}):l.jsx(Ra,{padding:a,onChange:i,min:0}),l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row padding-settings-link-row",children:[l.jsxs("span",{className:"ee-padding-link-sides-label",children:[s("padding_link_sides_label"),l.jsx(t.Tooltip,{title:s("padding_link_sides_tooltip"),children:l.jsx("span",{className:"ee-help-icon ee-padding-link-sides-help","aria-label":s("padding_link_sides_tooltip"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),l.jsx(Ma,{checked:c,onChange:d})]})]}):l.jsx("div",{className:"padding-settings ee-padding-settings-v2 ee-padding-settings-plain",children:l.jsx(Ra,{padding:a,onChange:i,min:0})})},Fa=()=>{const{t:e}=So(),t=va(e),n=(e=>{const t={desktop:{textAlign:"center",paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}},n={key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},o=o=>({name:e("content"),key:"content",width:o,styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]});return{full:{columns:1,type:"full",children:[{name:e("content"),key:"content",width:"100%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}]},"1-1":{columns:2,type:"1-1",children:Array.from({length:2}).map(()=>({name:e("content"),key:"content",width:"50%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-1-1":{columns:3,type:"1-1-1",children:Array.from({length:3}).map(()=>({name:e("content"),key:"content",width:"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-2-1":{columns:3,type:"1-2-1",children:Array.from({length:3}).map((e,t)=>o(1===t?"50%":"25%"))},"2-1-1":{columns:3,type:"2-1-1",children:Array.from({length:3}).map((e,t)=>o(0===t?"50%":"25%"))},"1-1-2":{columns:3,type:"1-1-2",children:Array.from({length:3}).map((e,t)=>o(2===t?"50%":"25%"))},"1-1-1-1":{columns:4,type:"1-1-1-1",children:Array.from({length:4}).map(()=>({name:e("content"),key:"content",width:"25%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-2":{columns:2,type:"1-2",children:Array.from({length:2}).map((e,t)=>o(0===t?"33.3%":"66.6%"))},"2-1":{columns:2,type:"2-1",children:Array.from({length:2}).map((e,t)=>o(0===t?"66.6%":"33.3%"))},"1-3":{columns:2,type:"1-3",children:Array.from({length:2}).map((e,t)=>o(0===t?"25%":"75%"))},"3-1":{columns:2,type:"3-1",children:Array.from({length:2}).map((e,t)=>o(0===t?"75%":"25%"))},"2-3":{columns:2,type:"2-3",children:Array.from({length:2}).map((e,t)=>o(0===t?"40%":"60%"))},"3-2":{columns:2,type:"3-2",children:Array.from({length:2}).map((e,t)=>o(0===t?"60%":"40%"))},"2-4-2-4":{columns:4,type:"2-4-2-4",children:Array.from({length:4}).map((o,a)=>({name:e("content"),key:"content",width:a%2==0?"16.6%":"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"4-2-4-2":{columns:4,type:"4-2-4-2",children:Array.from({length:4}).map((o,a)=>({name:e("content"),key:"content",width:a%2==0?"33.3%":"16.6%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))}}})(e),o=(e=>t=>{const n={id:A(),name:e("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}};return{id:A(),name:e("container"),key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},children:[{id:A(),name:e("content"),key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[t||n]}]}})(e);return{blockConfigsList:t,columnsSetting:n,getColumnConfig:o}},Ea=({children:e,className:t=""})=>l.jsx("h3",{className:`ee-settings-section-title ${t}`.trim(),children:e}),Da=e=>e?l.jsx("span",{style:{color:"var(--ee-text-tertiary)",fontWeight:400,fontSize:11,marginLeft:6},children:"optional"}):null,Ua=({label:e,hint:t,optional:n,children:o,className:a="",layout:i="stack"})=>l.jsxs("div",{className:`ee-settings-field ${"toggle"===i?"ee-settings-field--toggle":""} ${a}`.trim(),children:["toggle"===i&&e?l.jsxs("div",{className:"ee-settings-row ee-settings-field-toggle-inner",children:[l.jsxs("span",{className:"ee-settings-row-label",children:[e,Da(n)]}),o]}):l.jsxs(l.Fragment,{children:[e?l.jsxs("div",{className:"ee-settings-field-label",children:[e,Da(n)]}):null,o]}),t?l.jsx("div",{style:{fontSize:11,color:"var(--ee-text-tertiary)",lineHeight:1.5},children:t}):null]}),za=({widths:e})=>{const t=e.reduce((e,t)=>e+parseFloat(t),0)||1;return l.jsx("div",{style:{display:"flex",height:18,gap:2,borderRadius:2,overflow:"hidden",width:36,flexShrink:0},children:e.map((e,n)=>l.jsx("div",{style:{flex:parseFloat(e)/t,background:"rgba(216, 254, 145, 0.5)",borderRadius:1}},n))})},Oa=[{key:"full",label:"1 col",widths:["100%"]},{key:"1-1",label:"Equal 2",widths:["50%","50%"]},{key:"1-1-1",label:"Equal 3",widths:["33.3%","33.3%","33.3%"]},{key:"1-1-1-1",label:"Equal 4",widths:["25%","25%","25%","25%"]},{key:"1-2",label:"1 / 2",widths:["33.3%","66.6%"]},{key:"2-1",label:"2 / 1",widths:["66.6%","33.3%"]},{key:"1-3",label:"1 / 3",widths:["25%","75%"]},{key:"3-1",label:"3 / 1",widths:["75%","25%"]},{key:"2-3",label:"2 : 3",widths:["40%","60%"]},{key:"3-2",label:"3 : 2",widths:["60%","40%"]},{key:"1-2-1",label:"1 / 2 / 1",widths:["25%","50%","25%"]},{key:"2-1-1",label:"2 / 1 / 1",widths:["50%","25%","25%"]},{key:"1-1-2",label:"1 / 1 / 2",widths:["25%","25%","50%"]},{key:"2-4-2-4",label:"2-4 · 2-4",widths:["16.6%","33.3%","16.6%","33.3%"]},{key:"4-2-4-2",label:"4-2 · 4-2",widths:["33.3%","16.6%","33.3%","16.6%"]}],Wa=()=>{const{blockMap:a,rootOrder:i,setBlocks:r,currentItem:c,setCurrentItem:d,previewMode:u}=e.useContext(ge),{t:m}=So(),{columnsSetting:p}=Fa();if(!c?.data||"column"!==c.data.key)return null;if(ua(c.data)!==pa)return null;const g=c.data.children||[],h=g.length,b=e=>{const{blockMap:t}=R([e]),n={...a,...t};r(n,i,`edit_${Date.now()}`),d({...c,data:e})},y=e=>{const t=p[e.key]||p.full;if(!t)return;const n=c.data.children||[],o=(t.children||[]).map((e,t)=>{const o=n[t];if(o)return{...o,key:e.key,name:e.name,width:e.width,styles:C(e.styles??o.styles),children:o.children};const a=A();return{...e,id:a}}),a=C(c.data);a.children=o,b(a)},_=(()=>{const e="desktop"===u?c.data.styles?.desktop:{...c.data.styles?.desktop,...c.data.styles?.mobile},t=e?.columnGap??e?.column_gap??0;return"number"==typeof t?t:parseInt(String(t).replace("px",""),10)||0})(),f=g.reduce((e,t)=>e+parseFloat(t.width||"100"),0)||1,x=Oa.filter(e=>p[e.key]);return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:m("grid_settings")}),l.jsxs("div",{className:"ee-settings-row ee-columns-count-row",children:[l.jsx("span",{className:"ee-padding-link-sides-label",children:m("columns")}),l.jsxs("div",{className:"ee-columns-stepper",children:[l.jsx("button",{type:"button",className:"ee-col-stepper-btn",disabled:h<=1,onClick:()=>{const e=Math.max(1,h-1),t=Oa.find(t=>t.widths.length===e);t&&y(t)},"aria-label":m("columns"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faMinus,style:{fontSize:10}})}),l.jsx("span",{className:"ee-columns-stepper-value",children:h}),l.jsx("button",{type:"button",className:"ee-col-stepper-btn",disabled:h>=4,onClick:()=>{const e=Math.min(4,h+1),t=Oa.find(t=>t.widths.length===e&&t.key.startsWith("1-1"));if(t)y(t);else{const t=Oa.find(t=>t.widths.length===e);t&&y(t)}},"aria-label":m("columns"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faPlus,style:{fontSize:10}})})]})]}),l.jsx(Ea,{children:m("presets")}),l.jsx("div",{className:"ee-columns-preset-grid",children:x.map(e=>{const t=h===e.widths.length&&g.every((t,n)=>{const o=parseFloat(t.width||"0"),a=parseFloat(e.widths[n]||"0");return Math.abs(o-a)<1});return l.jsxs("button",{type:"button",className:s("ee-columns-preset-btn",t&&"ee-columns-preset-btn--active"),onClick:()=>y(e),children:[l.jsx(za,{widths:e.widths}),l.jsx("span",{children:e.label})]},e.key)})}),h>1&&l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:m("column_sizes")}),l.jsx("div",{className:"ee-columns-width-sliders",children:g.map((e,t)=>{const n=(e=>{if("string"!=typeof e)return 1;const t=parseFloat(e.replace("%",""));return isNaN(t)?1:t})(e.width)/f*100;return l.jsxs("div",{className:"ee-columns-width-slider-row",children:[l.jsxs("span",{className:"ee-columns-width-col-label",children:[m("col")," ",t+1]}),l.jsx("input",{type:"range",min:10,max:90,step:1,value:Math.round(n),onChange:e=>{const n=parseInt(e.target.value,10),o=t===h-1?0:h-1,a=100-n-g.reduce((e,n,a)=>a===t||a===o?e:e+Math.round(parseFloat(n.width||"0")/f*100),0),l=C(c.data);l.children=l.children.map((e,l)=>l===t?{...e,width:`${n}%`}:l===o?{...e,width:`${Math.max(10,a)}%`}:e),b(l)},className:"ee-columns-width-range"}),l.jsxs("span",{className:"ee-columns-width-pct",children:[Math.round(n),"%"]})]},e.id||t)})})]}),l.jsx(Ea,{children:m("gaps")}),l.jsx(Ua,{label:m("column_gap"),children:l.jsx(t.InputNumber,{min:0,max:60,className:"input-width ee-settings-input-affix",addonAfter:"px",value:_,onChange:e=>(e=>{const t=C(c.data);t.styles||(t.styles={desktop:{},mobile:{}}),t.styles[u]||(t.styles[u]={}),Object.assign(t.styles[u],e),b(t)})({columnGap:e??0})})})]})},Ha=({items:e,value:t,onChange:n,size:o="md",className:a="","aria-label":i})=>l.jsx("div",{className:`ee-settings-segmented ${"sm"===o?"ee-settings-segmented--sm":""} ${a}`.trim(),role:"group","aria-label":i,children:e.map(e=>{const o="string"==typeof e?e:e.value,a="string"==typeof e?e:e.label,i="object"==typeof e&&e.icon?e.icon:null,r=o===t,s="object"==typeof e&&e.iconOnly;return l.jsxs("button",{type:"button",title:"string"==typeof a?a:void 0,className:`ee-settings-segmented-btn${r?" ee-settings-segmented-btn--active":""}${s?" ee-settings-segmented-btn--icon-only":""}`,onClick:()=>n&&n(o),children:[i,a]},String(o))})}),Va=e=>{if(!e||"string"!=typeof e)return!1;try{const t=new URL(e);return/\/knowledge-base\/products$/i.test(t.pathname.replace(/\/$/,""))}catch{return/knowledge-base\/products\/?$/i.test(String(e).trim().replace(/\/$/,""))}},Ka=e=>{if(!e||"object"!=typeof e)return null;const t=null!=e.id?String(e.id):null!=e.resourceId?String(e.resourceId):"";if(!t)return null;const n=e.price,o="number"==typeof n?n:parseFloat(String(n??"").replace(/,/g,""));return{id:t,name:e.name??"",description:ke(e.description),image:e.image_url??e.image??"",link:e.url??"",price:Number.isFinite(o)?o:0,currency:e.currency??"USD",old_price:null!=e.old_price?e.old_price:null,new_price:null!=e.new_price?e.new_price:null,resourceId:e.resourceId,source:e.source}},Ga=async(e,t,n={},{page:o=1,limit:a=20,search:l=""}={})=>{if(!e)return null;try{if(Va(e)){if(!t)return null;const i=e.replace(/\/$/,""),r=new URL(`${i}/${encodeURIComponent(t)}`);r.searchParams.set("page",String(o)),r.searchParams.set("limit",String(a)),r.searchParams.set("search",l??"");const s=await fetch(r.toString(),{method:"GET",headers:{"Content-Type":"application/json",...n}});if(!s.ok)return console.error("[API Service] KB products fetch failed:",s.status,s.statusText),null;const c=await s.json(),d=Array.isArray(c.data)?c.data:[];return{products:d.map(Ka).filter(Boolean),meta:c.meta&&"object"==typeof c.meta?c.meta:{}}}const i=new URL(e);t&&i.searchParams.append("companyId",t);const r=await fetch(i.toString(),{method:"GET",headers:{"Content-Type":"application/json",...n}});if(!r.ok)return console.error("[API Service] Products fetch failed:",r.status,r.statusText),null;const s=await r.json();if(!1===s.success)return console.error("[API Service] Products API returned error:",s.error),null;const c=s.data?.products??[],d=Array.isArray(c)?c.map(e=>e&&"object"==typeof e?{...e,description:ke(e.description)}:e):[];return Array.isArray(d)&&0!==d.length?{products:d,meta:{hasMore:!1,hasProducts:!0}}:{products:[],meta:{hasMore:!1,hasProducts:!1}}}catch(e){return console.error("[API Service] Error fetching products:",e),null}},qa={};function Ja(){return"undefined"!=typeof document?document.body:null}function Ya(e){if(!e)return"";const t=e.currency??"",n=e.price?.amount??e.price??"";return`${e.name} — ${t} ${n}`.trim()}function Xa(e,t){const n=new Map;return[...e,...t].forEach(e=>{e&&e.id&&n.set(e.id,e)}),Array.from(n.values())}function Za({apiConfig:n,templateData:o,value:a,selectedProduct:i,onChange:r,placeholder:s,staticProductList:c=[],getPopupContainer:d}){const{t:u}=So(),m=n?.productsEndpoint,p=n?.companyId??o?.companyId,g=e.useMemo(()=>{const e=n?.headers;return e&&"object"==typeof e?e:qa},[n?.headers]),h=Boolean(m&&p)&&Va(m),[b,y]=e.useState([]),[_,f]=e.useState({}),[x,k]=e.useState(!1),[v,w]=e.useState(""),[j,S]=e.useState(""),C=e.useRef(null),N=e.useRef(0),I=e.useRef(1),A=e.useRef(""),T=e.useRef(!1),L=e.useRef(""),B=e.useCallback(async(e,t,n)=>{if(!h)return;const o=(t??"").trim();if(n){const t=`${o}::${e}`;if(T.current&&L.current===t)return;T.current=!0,L.current=t}const a=++N.current;k(!0);try{const l=await Ga(m,p,g,{page:e,limit:20,search:o});if(a!==N.current)return;if(!l)return n||(y([]),S((t??"").trim())),void f({});f(l.meta||{}),y(e=>n?Xa(e,l.products):l.products),I.current=e}finally{n&&(T.current=!1,L.current=""),a===N.current&&k(!1)}},[h,m,p,g]),$=e.useCallback(async e=>{if(!h)return;const t=(e??"").trim();T.current=!1,L.current="";const n=++N.current;k(!0);try{if(""!==t){const e=await Ga(m,p,g,{page:1,limit:20,search:t});if(n!==N.current)return;return e?(f(e.meta||{}),y(e.products),S(t),void(I.current=1)):(y([]),f({}),S(t),void(I.current=1))}let e=1,o=[],a={};for(;o.length<10&&e<=15;){const t=await Ga(m,p,g,{page:e,limit:20,search:""});if(n!==N.current)return;if(!t?.products?.length)break;if(o=Xa(o,t.products),a=t.meta||{},I.current=e,!a.hasMore)break;e+=1}f(a),y(o),S("")}finally{n===N.current&&k(!1)}},[h,m,p,g]),R=e.useCallback(()=>{if(!h||x||!_?.hasMore)return;const e=I.current+1;B(e,A.current,!0)},[h,x,_?.hasMore,B]),M=d??Ja,P=e.useCallback(e=>l.jsxs("div",{children:[e,x&&b.length>0&&l.jsxs("div",{className:"ee-kb-product-select-footer",children:[l.jsx(t.Spin,{size:"small"})," ",l.jsx("span",{children:u("loading")})]}),!x&&_?.hasMore&&l.jsx("div",{className:"ee-kb-product-select-footer",children:l.jsx("button",{type:"button",className:"ee-kb-product-select-load-more",onClick:R,children:u("load_more_products")})})]}),[x,b.length,_?.hasMore,R,u]),F=e.useMemo(()=>{const e=h?b:c;return Xa(i?.id?[i]:[],e)},[h,b,c,i]),E=e.useMemo(()=>F.map(e=>({value:e.id,label:Ya(e)})),[F]),D=e=>{if(!e)return r(null),void(h&&(clearTimeout(C.current),w(""),A.current="",I.current=1,S(""),$("")));const t=F.find(t=>t.id===e)||c.find(t=>t.id===e);r(t||null)},U="ee-kb-product-select-dropdown";return h?l.jsx(t.Select,{className:"ee-stack-control ee-kb-product-select",value:a??void 0,placeholder:s,style:{width:"100%"},virtual:!0,dropdownMatchSelectWidth:!0,listHeight:320,listItemHeight:32,dropdownClassName:U,getPopupContainer:M,onChange:D,allowClear:!0,showSearch:!0,filterOption:!1,searchValue:v,onSearch:e=>{if(!h)return;const t=e??"";w(t);const n=t.trim();if(clearTimeout(C.current),""===n)return A.current="",I.current=1,void $("");C.current=setTimeout(()=>{A.current=n,I.current=1,$(n)},400)},onOpenChange:e=>{clearTimeout(C.current),e?(T.current=!1,L.current="",w(""),A.current="",I.current=1,$("")):(T.current=!1,L.current="",w(""),A.current="")},notFoundContent:x?l.jsxs("span",{className:"ee-kb-product-select-loading",children:[l.jsx(t.Spin,{size:"small"})," ",u("loading")]}):E.length>0?null:l.jsx("span",{className:"ee-kb-product-select-empty",children:""!==j.trim()?u("no_products_matching_search"):u("no_product_found")}),options:E,dropdownRender:P}):l.jsx(t.Select,{className:"ee-stack-control",value:a??void 0,placeholder:s,style:{width:"100%"},virtual:!0,dropdownMatchSelectWidth:!0,listHeight:320,listItemHeight:32,dropdownClassName:U,getPopupContainer:M,onChange:D,allowClear:!0,showSearch:!0,optionFilterProp:"label",options:c.map(e=>({value:e.id,label:Ya(e)}))})}const Qa=()=>{const{previewMode:t,currentItem:n,blockMap:o,rootOrder:a,setBlocks:i,setCurrentItem:r}=e.useContext(ge),s=e=>{let t;if("column"===e.key){const{blockMap:n}=R([e]);t={...o,...n}}else t={...o,[n.id]:e};i(t,a,`edit_${(new Date).getTime()}`),r({...n,data:e})};return{findStyleItem:(e,n)=>{let o=e[t][n];return o||(o=e.desktop[n]),o},cardItemElement:(e,t)=>l.jsxs("div",{className:"card-item",children:[l.jsx("div",{className:"card-item-title",children:e}),l.jsx("div",{children:t})]}),updateItemStyles:s,colorChange:e=>({hex:o})=>{const a=C(n.data);a.styles[t][e]=o,s(a)},paddingChange:e=>{const o=C(n.data);o.styles[t]={...o.styles[t],...e},s(o)},otherStylesChange:(e,o)=>{const a=C(n.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles[t]||(a.styles[t]={}),a.styles[t][e]=o,"desktop"!==t&&(a.styles.desktop[e]=o),s(a)},inputChange:e=>o=>{const a=C(n.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles[t]||(a.styles[t]={}),a.styles[t][e]=o,"desktop"!==t&&(a.styles.desktop[e]=o),s(a)}}},el=[{id:"dolor-sit-amet",name:"Dolor Sit Amet",description:"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",image:"https://plus.unsplash.com/premium_photo-1681711647066-ef84575c0d95?fm=jpg&q=30&w=300&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8cHJvZHVjdCUyMHBob3RvZ3JhcGh5fGVufDB8fDB8fHww",link:"https://loremipsum.com/checkout/cart/12345",price:2e3,currency:"USD",old_price:2500,new_price:2e3},{id:"sample-2",name:"Sample Pearl Necklace",description:"Classic strand of lustrous freshwater pearls with a sterling silver clasp. Timeless elegance for any outfit.",image:"https://picsum.photos/seed/necklace2/200/200",link:"https://www.example.com/products/sample-2",price:750,currency:"USD",old_price:null,new_price:null},{id:"sample-3",name:"Sample Gold Bracelet",description:"Handcrafted 14K yellow gold link bracelet. Lightweight and comfortable for everyday wear.",image:"https://picsum.photos/seed/bracelet3/200/200",link:"https://www.example.com/products/sample-3",price:450,currency:"USD",old_price:500,new_price:450},{id:"sample-4",name:"Sample Silver Earrings",description:"Delicate sterling silver drop earrings with subtle sparkle. A versatile addition to your jewelry collection.",image:"https://picsum.photos/seed/earrings4/200/200",link:"https://www.example.com/products/sample-4",price:199,currency:"USD",old_price:null,new_price:null},{id:"sample-5",name:"Sample Gemstone Pendant",description:"Stunning pendant with a natural gemstone centerpiece on a fine silver chain. Makes a memorable gift.",image:"https://picsum.photos/seed/pendant5/200/200",link:"https://www.example.com/products/sample-5",price:320,currency:"USD",old_price:400,new_price:320}],tl=new Set(["image/png","image/jpeg","image/jpg","image/gif","image/svg+xml","image/webp"]),nl={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",webp:"image/webp"},ol=Array.from(tl).join(",");function al(e){return e?function(e){if(!e)return!1;const t=String(e.type||"").toLowerCase().trim();if(t)return tl.has(t);const n=String(e.name||"").toLowerCase(),o=n.lastIndexOf(".");if(-1===o)return!1;const a=n.slice(o+1);return Object.prototype.hasOwnProperty.call(nl,a)}(e)?e.size>10485760?"size":null:"type":null}const ll=({imageUploadEndpoint:t,headers:n={},companyId:o,imageUploadQueryParams:a,imageUploadCompanyField:l="companyId"}={})=>{const i=!!t;return{uploadImageFile:e.useCallback(async e=>{if(!i)return console.error("[useImageUpload] No image upload endpoint configured"),null;if(!e)return console.error("[useImageUpload] No file provided"),null;const r=al(e);if("type"===r)return console.error("[useImageUpload] File type not allowed:",e.type),null;if("size"===r)return console.error("[useImageUpload] File too large:",e.size,"bytes"),null;const s=await(async(e,t,n,o={},a={})=>{if(!e)return console.error("[API Service] No image upload endpoint configured"),null;if(!t)return console.error("[API Service] No file provided for upload"),null;const{queryParams:l={},companyField:i="companyId"}=a;try{const a=new FormData;a.append("file",t),n&&("comment"===i?a.append("comment",n):a.append("companyId",n));let r=e;if(l&&Object.keys(l).length>0){const t="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(e,t);Object.entries(l).forEach(([e,t])=>{null!=t&&n.searchParams.set(e,String(t))}),r=n.toString()}const s={...o};Object.keys(s).forEach(e=>{"content-type"===e.toLowerCase()&&delete s[e]});const c=await fetch(r,{method:"POST",headers:{...s},body:a}),d=await c.text();let u={};try{u=d?JSON.parse(d):{}}catch{u=d?{message:d.slice(0,500)}:{}}if(!c.ok){const e=En(u,c.status);throw console.error("[API Service] Image upload failed:",c.status,e),new Error(e)}if(u&&!1===u.success){const e=En(u,c.status);throw console.error("[API Service] Upload API returned error:",e),new Error(e)}if(u&&"string"==typeof u.url&&u.url.trim())return u.url.trim();const m=u?.data?.url;if(m&&"string"==typeof m)return m.trim();throw new Error("Upload succeeded but no image URL was returned.")}catch(e){if(console.error("[API Service] Error uploading image:",e),e instanceof Error&&e.message)throw e;throw new Error(e&&"object"==typeof e&&"message"in e?String(e.message):"Unable to upload image. Check your network and try again.")}})(t,e,o,n,{queryParams:a,companyField:l});return s},[i,t,n,o,a,l]),isConfigured:i}},il=[{value:"100%",label:"Full"},{value:"720px",label:"720"},{value:"600px",label:"600"},{value:"540px",label:"540"}],rl=[{value:"none",label:"None"},{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"}];function sl(e){if(null==e)return!0;const t=String(e).trim().toLowerCase();return""===t||"transparent"===t}const cl=({t:n,findStyleItem:o,colorChange:a,inputChange:i,paddingChange:r,patchContainerBackground:s,commitColumnUpdate:c,currentItem:d,children:u})=>{const m=o(d.data.styles,"backgroundColor"),p=o(d.data.styles,"contentBackground"),g=o(d.data.styles,"containerBackgroundImage")??"",h=""!==String(g).trim(),b=e.useMemo(()=>function(e,t){return e?"image":sl(t)?"none":"color"}(h,m),[h,m]),[y,_]=e.useState(null),f=y??b;e.useEffect(()=>{_(null)},[d?.data?.id]),e.useEffect(()=>{h&&_(null)},[h]);const x=o(d.data.styles,"contentMaxWidth")??"100%",k=il.some(e=>e.value===x)?x:"100%",v=o(d.data.styles,"minHeight")??"",w="string"==typeof v?parseInt(v.replace("px",""),10)||"":v||"",j=o(d.data.styles,"borderStyle")??"none",S=o(d.data.styles,"borderWidth")??1,N="string"==typeof S?parseInt(S.replace("px",""),10)||1:S||1,I=o(d.data.styles,"borderColor")??"#e0e0e0",A=o(d.data.styles,"borderRadius")??0,T="string"==typeof A?parseInt(String(A).replace("px",""),10)||0:A||0,L="none"!==j,B=Boolean(d.data.hiddenOnMobile),$=sl(p)?"auto":"custom";return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:n("section_background_group")}),l.jsx(Ua,{label:n("section_bg_mode"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:f,onChange:e=>(e=>{if("image"===e)return _("image"),void s({containerBackgroundEnabled:!0});if(_(null),"color"===e){s({containerBackgroundImage:"",containerBackgroundEnabled:!1});const e=sl(m)?"#ffffff":m;return void a("backgroundColor")({hex:e})}"none"===e&&(s({containerBackgroundImage:"",containerBackgroundEnabled:!1}),a("backgroundColor")({hex:"transparent"}))})(e),"aria-label":n("section_bg_mode"),items:[{value:"color",label:n("section_bg_color")},{value:"image",label:n("section_bg_image")},{value:"none",label:n("section_bg_none")}]})}),("color"===f||"image"===f)&&l.jsx(Ua,{label:n("background_color"),children:l.jsx(Ba,{color:sl(m)?"#ffffff":m,setColor:({hex:e})=>a("backgroundColor")({hex:e})})}),"image"===f?u:null,l.jsx(Ea,{children:n("section_content_area_group")}),l.jsx(Ua,{label:n("content_area_color"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:$,onChange:e=>{"auto"!==e?i("contentBackground")("#ffffff"):i("contentBackground")("transparent")},"aria-label":n("content_area_color"),items:[{value:"auto",label:n("content_color_auto")},{value:"custom",label:n("content_color_custom")}]})}),"custom"===$?l.jsx(Ua,{label:n("content_background_color"),children:l.jsx(Ba,{color:sl(p)?"#ffffff":p,setColor:({hex:e})=>a("contentBackground")({hex:e})})}):null,l.jsx(Ua,{label:n("content_max_width"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:k,onChange:e=>i("contentMaxWidth")(e),"aria-label":n("content_max_width"),items:il})}),l.jsx(Ua,{label:n("min_height"),children:l.jsx(t.InputNumber,{min:0,max:2e3,className:"input-width ee-settings-input-affix",addonAfter:"px",value:w,onFocus:e=>e?.target?.select?.(),onChange:e=>i("minHeight")(e?`${e}px`:"")})}),l.jsx(Ea,{children:n("border")}),l.jsx(Ua,{label:n("border_style"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:j,onChange:e=>i("borderStyle")(e),"aria-label":n("border_style"),items:rl})}),L?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:n("border_width"),children:l.jsx(t.InputNumber,{min:0,max:20,className:"input-width ee-settings-input-affix",addonAfter:"px",value:N,onFocus:e=>e?.target?.select?.(),onChange:e=>i("borderWidth")(e??1)})}),l.jsx(Ua,{label:n("border_color"),children:l.jsx(Ba,{color:I,setColor:({hex:e})=>a("borderColor")({hex:e})})})]}):null,l.jsx(Ua,{label:n("border_radius"),children:l.jsx(t.InputNumber,{min:0,max:64,className:"input-width ee-settings-input-affix",addonAfter:"px",value:T,onFocus:e=>e?.target?.select?.(),onChange:e=>i("borderRadius")(e??0)})}),l.jsx(Ea,{children:n("spacing")}),l.jsx(Ua,{label:n("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:o(d.data.styles,"paddingTop"),paddingRight:o(d.data.styles,"paddingRight"),paddingLeft:o(d.data.styles,"paddingLeft"),paddingBottom:o(d.data.styles,"paddingBottom")},setPadding:r})}),l.jsx(Ea,{children:n("visibility")}),l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row ee-visibility-hide-mobile-row",children:[l.jsx("span",{className:"ee-padding-link-sides-label",children:n("hidden_on_mobile")}),l.jsx(Ma,{checked:B,onChange:e=>{const t=C(d.data);t.hiddenOnMobile=e,c(t)}})]})]})},dl=["product"],ul=e=>"additional"===e?"additional":"main";function ml(e){const t=String(e??"").trim();return t?/^\{\{\w+\}\}$/.test(t)?null:g(t,!1,{allowMailtoTel:!1})||null:null}const pl=()=>{const{blockMap:a,rootOrder:i,setBlocks:r,currentItem:s,setCurrentItem:c,previewMode:d,templateData:u,setIsDragStart:p,setActionType:g,apiConfig:h}=e.useContext(ge),{t:b}=So(),[y,_]=e.useState(!1),f=e.useRef(null),[x,k]=e.useState(!1),[v,w]=e.useState(""),[j,S]=e.useState(""),{uploadImageFile:N,isConfigured:I}=ll({imageUploadEndpoint:h?.imageUploadEndpoint,headers:h?.headers||{},companyId:h?.companyId,imageUploadQueryParams:h?.imageUploadQueryParams,imageUploadCompanyField:h?.imageUploadCompanyField}),{findStyleItem:A,colorChange:T,inputChange:L,paddingChange:B}=Qa(),{blockConfigsList:$}=Fa(),M=ua(s?.data),P=s?.data?.children??[],[F,D]=e.useState(0);e.useEffect(()=>{D(0)},[s?.data?.id]),e.useEffect(()=>{const e=P.length;0!==e&&D(t=>t>=e?Math.max(0,e-1):t)},[P.length]);const[U,z]=e.useState(!1);e.useEffect(()=>{z(!1)},[s?.data?.id]);const O="discount"===(W=s.data.containerType??"none")||"none"===W?W:"product";var W;const H=s.data.productRole??"main",V=s.data.columnProducts,K=e.useMemo(()=>Array.isArray(V)?V:[],[V]),G=e.useMemo(()=>({columnIndex:0,columnProduct:K[0]??null}),[K]),q=A(s.data.styles,"containerBackgroundImage")??"";e.useEffect(()=>{S("")},[q]);const J=u?.content?.products?.length>0?u.content.products:u?.catalogProducts?.length>0?u.catalogProducts:el,Y=u?.content?.primaryProductId,X=e=>{const{blockMap:t}=R([e]);let n={...a,...t};const o=ul(e.productRole);"product"===e.containerType&&"main"===o&&Object.keys(n).forEach(t=>{if(t===e.id)return;const o=n[t];if(!o||"column"!==o.key)return;if("product"!==o.containerType)return;"main"===ul(o.productRole)&&(n[t]={...o,productRole:"additional"})}),r(n,i,`edit_${(new Date).getTime()}`),c({...s,data:e})},Z=e=>{const t=C(s.data);t.styles||(t.styles={desktop:{},mobile:{}}),t.styles[d]||(t.styles[d]={}),Object.assign(t.styles[d],e),"desktop"!==d&&(t.styles.desktop||(t.styles.desktop={}),Object.assign(t.styles.desktop,e)),X(t)},Q=async e=>{if(!e)return;const n=al(e);if("type"!==n)if("size"!==n)if(I){k(!0);try{const n=await N(e);n?(Z({containerBackgroundImage:Zt(n),containerBackgroundEnabled:!0}),w(""),S(""),t.message.success(b("image_uploaded"))):t.message.error(b("image_upload_failed"))}catch(n){console.error(n);const e="string"==typeof n?.message&&n.message.trim()?n.message.trim():null;t.message.error(e||b("image_upload_error"))}finally{k(!1)}}else t.message.error(b("image_upload_not_configured"));else t.message.error(b("image_file_too_large"));else t.message.error(b("image_upload_invalid_type"))},ee=e=>{const t=ml(e);var n;w(t?b("blocked_scheme"===(n=t)?"container_bg_image_url_error_blocked_scheme":"duplicate_protocol"===n?"container_bg_image_url_error_duplicate_protocol":"missing_hostname_dot"===n?"container_bg_image_url_error_hostname":"invalid_protocol"===n?"container_bg_image_url_error_invalid_protocol":"container_bg_image_url_error_generic"):""),S("")},te=e=>{const t=C(s.data);t.productRole=ul(e);const n=t.children?.length??0;let o=Array.from({length:n},(e,n)=>t.columnProducts?.[n]??null);if(n>0&&J.length>0){const e=Y?J.find(e=>e.id===Y):J[0];e&&!o[0]&&(o[0]=e)}t.columnProducts=o,X(t)},ne=dl.includes(O),oe=e.useMemo(()=>To(s.data,a),[s.data,a]),ae=e.useMemo(()=>E(a,i,s.data?.id),[a,i,s.data?.id]),le=e.useMemo(()=>(ae||[]).filter(e=>e?.containerBlock&&e.containerBlock.id!==s.data?.id&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[ae,s.data?.id]),ie=jt(0,O,u,{},le).filter(({variableKey:e,key:t})=>!("product"===O)||(e??t)!==Ve).filter(({variableKey:e,key:t})=>!oe.has(e??t)),re=e.useMemo(()=>{const e={columnIndex:0,columnProduct:K[0]??null};return Nt(O,u,e).filter(e=>e.variableKey&&!oe.has(e.variableKey))},[O,u,K,oe]),se=e.useMemo(()=>{const e=new Set(ie.map(e=>e.variableKey??e.key)),t=re.filter(t=>{const n=t.variableKey;return!(!n||e.has(n))&&(e.add(n),!0)});return[...ie,...t]},[ie,re]),ce=e=>t=>{const n=(e=>{const{value:t,type:n}=e;if("image"===n){const e=C($.find(e=>"image"===e.key));return e?(e.src=t,e):{name:b("image"),key:"image",src:t,alt:"Image",type:"link",linkEnabled:!1,linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}}}const o=C($.find(e=>"text"===e.key));return o?(o.text=`<p>${t}</p>`,o.type="p",o.contentType="static",o):{name:b("text"),key:"text",text:`<p>${t}</p>`,type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"20px",paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16,textAlign:"left"},mobile:{}}}})(e);"undefined"!=typeof window&&(window.__eeDragItemData=n,window.__eeDragSource="product-variables"),p(!0),g("add"),t.target.classList.add("ee-product-variable-item-dragging"),t.dataTransfer&&(t.dataTransfer.effectAllowed="copy")},de=e=>{e.target.classList.remove("ee-product-variable-item-dragging"),"undefined"!=typeof window&&(window.__eeDragItemData=null,window.__eeDragSource=null),setTimeout(()=>{p(!1)},50)},ue=e=>t=>{const n=C(s.data);n.children[e].styles[d]={...n.children[e].styles[d],...t},X(n)},me=(e=!1)=>{const a=A(s.data.styles,"containerBackgroundImage")??"",i=function(e,t,n){const o=String(e??"").trim();if(!o)return"";if(ml(o))return"";if(/^\{\{\w+\}\}$/.test(o)){const e=o.replace(/\{\{|\}\}/g,"").trim(),a=t&&e?yt(t,e,n):null;return null==a||String(a).startsWith("{{")?"":m(String(a).trim(),{allowMailtoTel:!1})||""}return m(o,{allowMailtoTel:!1})||""}(a,u,G),r=l.jsxs("span",{className:"ee-container-bg-heading-inline",children:[b("container_background_image_section_title"),l.jsx(t.Tooltip,{title:l.jsxs("div",{className:"ee-container-bg-tooltip",children:[l.jsx("p",{className:"ee-container-bg-tooltip-p",children:b("container_background_image_tooltip_p1")}),l.jsx("p",{className:"ee-container-bg-tooltip-p",children:b("container_background_image_tooltip_p2")}),l.jsx("p",{className:"ee-container-bg-tooltip-p",children:b("container_background_image_intro")})]}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:l.jsx("span",{className:"ee-container-bg-section-help",tabIndex:0,"aria-label":b("container_background_image_title"),onClick:e=>e.stopPropagation(),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),c=!e||U;return l.jsxs("div",{className:fo("ee-container-bg-section",e&&"ee-container-bg-section--disclosure"),children:[e?l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row ee-container-bg-disclosure-switch-row",children:[l.jsx("div",{className:"ee-container-bg-disclosure-heading-left",children:l.jsx("span",{className:"ee-settings-section-title ee-container-bg-section-heading",children:r})}),l.jsx(Ma,{checked:U,onChange:z,"aria-label":b("container_background_image_section_toggle")})]}):l.jsx(Ea,{className:"ee-container-bg-section-heading",children:r}),c?l.jsxs("div",{className:"ee-container-bg-section-body",children:[l.jsx("input",{ref:f,type:"file",accept:ol,className:"ee-image-upload-input-hidden",onChange:async e=>{const t=e.target.files?.[0];await Q(t),e.target.value=""},disabled:x}),l.jsxs(Ua,{label:b("container_background_image_upload"),children:[l.jsx(t.Spin,{spinning:x,children:l.jsxs("div",{role:"button",tabIndex:0,className:"ee-image-upload-trigger",onClick:()=>!x&&f.current?.click(),onDrop:async e=>{e.preventDefault(),e.stopPropagation();const t=e.dataTransfer?.files?.[0];await Q(t)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},style:{opacity:x?.6:1,cursor:x?"not-allowed":"pointer"},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCloudUploadAlt,className:"ee-image-upload-icon"}),l.jsx("span",{children:b(x?"uploading":"image_upload_click")})]})}),l.jsxs("div",{className:"ee-image-toolbar",children:[l.jsxs("button",{type:"button",className:"ee-image-toolbar-btn",onClick:()=>f.current?.click(),disabled:x,children:[l.jsx(n.FontAwesomeIcon,{icon:o.faSyncAlt}),l.jsx("span",{children:b("replace")||"Replace"})]}),l.jsxs("button",{type:"button",className:"ee-image-toolbar-btn ee-image-toolbar-btn--danger",onClick:()=>{w(""),S(""),Z({containerBackgroundImage:"",containerBackgroundEnabled:!1})},disabled:x||!String(a).trim(),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faTrash}),l.jsx("span",{children:b("delete")||"Delete"})]})]}),l.jsx("div",{className:"ee-image-upload-hint",children:b("image_upload_file_hint")||"PNG, JPEG, GIF, SVG, WebP · max 10 MB"})]}),l.jsxs("div",{className:"ee-container-bg-url-block",children:[l.jsx("div",{className:"ee-stack-label ee-container-bg-url-label",children:b("container_background_image_url")}),l.jsx(t.Input,{className:"width-full",value:a,onChange:e=>{const t=e.target.value,n=""!==String(t).trim();S(""),v&&ee(t),Z({containerBackgroundImage:t,containerBackgroundEnabled:n})},onBlur:e=>ee(e.target.value),status:v||j?"error":"",placeholder:"https://"}),v?l.jsx("div",{className:"ee-field-error",role:"alert",children:v}):null,j&&!v?l.jsx("div",{className:"ee-field-error",role:"alert",children:j}):null,i&&!v?l.jsx("div",{className:"ee-container-bg-url-preview",children:l.jsx("img",{src:i,alt:"",className:"ee-container-bg-url-preview-img",onLoad:()=>S(""),onError:()=>S(b("container_bg_image_preview_failed"))})}):null]}),l.jsxs("div",{className:"ee-container-bg-format-bar",children:[l.jsx("div",{className:"ee-container-bg-format-bar-caption",children:b("container_background_image_layout_group")}),l.jsxs("div",{className:"ee-container-bg-format-bar-inner",children:[l.jsxs("div",{className:"ee-container-bg-format-bar-field ee-container-bg-format-bar-field-size",children:[l.jsx("div",{className:"ee-container-bg-format-bar-label",children:b("container_background_image_size")}),l.jsx(t.Select,{className:"ee-container-bg-size-select ee-container-bg-size-select-half",value:A(s.data.styles,"containerBackgroundSize")||"cover",onChange:e=>Z({containerBackgroundSize:e}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:en.map(e=>l.jsx(t.Select.Option,{value:e.value,children:b(e.labelKey)},e.value))})]}),l.jsxs("div",{className:"ee-container-bg-format-bar-field ee-container-bg-format-bar-field-grid",children:[l.jsx("div",{className:"ee-container-bg-format-bar-label",children:b("container_background_image_position")}),l.jsx("div",{className:"ee-container-bg-position-grid",role:"group","aria-label":b("container_background_image_position"),children:tn.map(e=>{const t=A(s.data.styles,"containerBackgroundPosition")||"center center";return l.jsx("button",{type:"button",className:fo("ee-container-bg-position-cell",t===e&&"ee-container-bg-position-cell-active"),title:e,"aria-pressed":t===e,onClick:()=>Z({containerBackgroundPosition:e}),children:l.jsx("span",{className:"ee-container-bg-dot","aria-hidden":!0})},e)})})]})]})]})]}):null]})};return l.jsx(l.Fragment,{children:l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsxs(l.Fragment,{children:[l.jsx(Ea,{className:"ee-settings-section-title--flush",children:b("container_settings")}),l.jsxs("div",{className:"ee-right-panel-stack",children:[ne&&l.jsxs("div",{className:"ee-product-assign-section margin-top-12",children:[l.jsx("span",{className:"ee-stack-label",children:b("product_role")}),l.jsx(t.Select,{className:"ee-stack-control",value:H,style:{width:"100%"},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,onChange:te,options:[{value:"main",label:b("product_role_main_hero")},{value:"additional",label:b("product_role_additional")}]})]}),ne&&l.jsxs("div",{className:"ee-product-assign-section margin-top-12",children:[l.jsx("span",{className:"ee-stack-label",children:b("assign_product_to_column")}),l.jsx(Za,{apiConfig:h,templateData:u,value:K[0]?.id??void 0,selectedProduct:K[0],onChange:e=>((e,t)=>{const n=C(s.data),o=[...n.columnProducts??[]];o[e]=t,n.columnProducts=o,X(n)})(0,e),placeholder:b("assign_product_to_column"),staticProductList:J})]}),l.jsxs("div",{className:"ee-product-variables-section margin-top-12",children:[l.jsxs("button",{type:"button",className:"ee-product-variables-toggle",onClick:()=>_(e=>!e),children:[l.jsx("span",{children:b("variables")}),l.jsx("span",{className:"ee-product-variables-toggle-icon",children:y?"▴":"▾"})]}),y&&l.jsx("div",{className:"ee-product-variables-dropdown",children:se.length>0?se.map(e=>l.jsxs("div",{className:"ee-product-variable-item",draggable:!0,onDragStart:ce(e),onDragEnd:de,title:e.value,children:[l.jsx("span",{className:"ee-product-variable-item-label",children:e.labelKey?b(e.labelKey):e.label}),l.jsx("span",{className:"ee-product-variable-item-token",children:e.value})]},e.value)):l.jsx("div",{className:"ee-stack-help",children:"No variables available for this container type."})})]})]})]}),M===pa&&l.jsx(Wa,{}),M!==ma&&(()=>{const e=s.data.children||[],t=Math.min(Math.max(0,F),Math.max(0,e.length-1)),n=e[t],o=n?A(n.styles,"backgroundColor"):void 0,a=b(M===pa?"column_cells_section":"column_settings");return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:a}),e.length>1?l.jsx(Ua,{label:b("column"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:String(t),"aria-label":b("column_settings"),onChange:e=>D(Number(e)),items:e.map((e,t)=>({value:String(t),label:`${b("column")} ${t+1}`}))})}):null,n?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:b("content_background_color"),children:l.jsx(Ba,{color:o,setColor:({hex:e})=>((e,t)=>n=>{const o=C(s.data);o.children[t].styles[d][e]=n,X(o)})("backgroundColor",t)(e)})}),l.jsx(Ua,{label:b("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:A(n.styles,"paddingTop"),paddingRight:A(n.styles,"paddingRight"),paddingLeft:A(n.styles,"paddingLeft"),paddingBottom:A(n.styles,"paddingBottom")},setPadding:ue(t)})})]}):null]})})(),(()=>{if(M===ma)return l.jsx(cl,{t:b,findStyleItem:A,colorChange:T,inputChange:L,paddingChange:B,patchContainerBackground:Z,commitColumnUpdate:X,currentItem:s,children:me()});const e=A(s.data.styles,"backgroundColor"),n=A(s.data.styles,"contentBackground"),o=A(s.data.styles,"borderRadius"),a="number"==typeof o?o:parseInt(String(o||"").replace("px",""),10)||0,i=Boolean(s.data.hiddenOnMobile);return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:b(M===pa?"column_wrapper_style":"column_styles")}),l.jsx(Ua,{label:b("background_color"),children:l.jsx(Ba,{color:e,setColor:T("backgroundColor")})}),l.jsx(Ua,{label:b("content_background_color"),children:l.jsx(Ba,{color:n,setColor:T("contentBackground")})}),l.jsx(Ua,{label:b("border_radius"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:a,onFocus:e=>e?.target?.select?.(),onChange:e=>L("borderRadius")(Number(e)||0)})}),l.jsx(Ua,{label:b("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:A(s.data.styles,"paddingTop"),paddingRight:A(s.data.styles,"paddingRight"),paddingLeft:A(s.data.styles,"paddingLeft"),paddingBottom:A(s.data.styles,"paddingBottom")},setPadding:B})}),me(M===pa),M===pa?l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:b("visibility")}),l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row ee-visibility-hide-mobile-row",children:[l.jsx("span",{className:"ee-padding-link-sides-label",children:b("hidden_on_mobile")}),l.jsx(Ma,{checked:i,onChange:e=>{const t=C(s.data);t.hiddenOnMobile=e,X(t)}})]})]}):null]})})()]})})},gl=({mlEmailNodesEndpoint:t,mlGenerationEndpoint:n,headers:o={},templateData:a,blockId:l,containerType:i,containerId:r,productId:s,blockName:c="Text",blockElementType:d="p",emailTemplateId:u,companyId:m,aiContentLanguage:p="en"}={})=>{const g=!!(t&&String(u??"").trim()&&String(m??"").trim()&&l&&r),h=!!n,b=g||h;return{generateOptions:e.useCallback(async(e,b,y={})=>{const{previousPrompt:_="",previousSelectedAiContent:f=""}=y,x=function(e,t={}){const{containerType:n}=t,o=String(e??"").trim();let a;return a=St[o]?St[o]:o?o.split(/[-_]/).map(e=>e.length?e[0].toUpperCase()+e.slice(1).toLowerCase():"").join(""):"DisplayText",a||(a="DisplayText"),"product"===n&&"DisplayText"===a?"ProductDescription":a}(e,{containerType:i});if(g){const e={containerType:i||"none",id:r};if("product"===(i||"")&&null!=s){const t=String(s).trim();t&&(e.productId=t)}const n=t,a={blockContext:{blockId:l,name:c,type:d||"p"},companyId:m,containerContext:e,emailTemplateId:u,language:"bn-BD"===p?"bn-BD":"en",promptContext:{newPrompt:b||"",previousPrompt:_||"",previousSelectedAiContent:f||""},type:x},g=await(async(e,t,n={})=>{if(!e)return console.error("[API Service] generate-email-nodes: no endpoint"),{success:!1,error:"ML endpoint is not configured."};try{const o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)});let a={};try{a=await o.json()}catch{a={}}if(!o.ok||!1===a.success){let e="";const t=a.error;if(t&&"object"==typeof t){const n=null!=t.code?String(t.code):"",o=null!=t.message?String(t.message):"";e=[n,o].filter(Boolean).join(" — ")||o||n}return e||(e=null!=a.message?String(a.message):`${o.status} ${o.statusText}`),console.error("[API Service] generate-email-nodes failed:",e),{success:!1,error:String(e),errorCode:t&&"object"==typeof t&&null!=t.code?String(t.code):void 0}}const l=Array.isArray(a.variations)?a.variations:[],i=l.map(e=>e&&"string"==typeof e.value?e.value.trim():"").filter(Boolean);return 0===i.length?(console.error("[API Service] generate-email-nodes: empty variations"),{success:!1,error:"No variations were returned for this request."}):{success:!0,options:i,variations:l,emailJson:"string"==typeof a.emailJson?a.emailJson:void 0,blockId:a.blockId,emailTemplateId:a.emailTemplateId}}catch(e){return console.error("[API Service] Error calling generate-email-nodes:",e),{success:!1,error:e&&"object"==typeof e&&"message"in e?String(e.message):"Unable to reach the ML service. Check your network and try again."}}})(n,a,o);if(g&&g.success&&g.options?.length)return g.options;return{error:g&&"object"==typeof g&&g.error?String(g.error):"No response from the ML service."}}if(h){const e={variable:x,prompt:b,context:{templateData:a,blockId:l,containerType:i}},t=await(async(e,t,n={})=>{if(!e)return console.error("[API Service] ML endpoint not configured"),null;try{const o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)});if(!o.ok)return console.error("[API Service] ML endpoint failed:",o.status,o.statusText),null;const a=await o.json();if(!a.success)return console.error("[API Service] ML API returned error:",a.error),null;const l=a.data?.options??[];return Array.isArray(l)&&0!==l.length?l:(console.error("[API Service] ML API returned empty options"),null)}catch(e){return console.error("[API Service] Error calling ML endpoint:",e),null}})(n,e,o);return t&&t.length?t:{error:"The legacy ML endpoint did not return any options. Check the API response."}}return{i18nKey:"ml_ai_unavailable"}},[g,h,t,n,o,a,l,i,r,s,c,d,u,m,p]),isConfigured:b}};function hl(){const{blockMap:t,rootOrder:n,currentItem:o}=e.useContext(ge);return e.useMemo(()=>{if(!t||!o?.id)return{containerBlock:null,containerType:"none",columnIndex:0,cellIndex:0};const{containerBlock:e,containerType:a,cellIndex:l,isRoot:i,rootIndex:r}=function(e,t,n){const o=(t||[]).indexOf(n);if(-1!==o){const t=e[n];return{containerBlock:t??null,containerType:t?.containerType??"none",cellIndex:0,isRoot:!0,rootIndex:o}}const a=F(e,t,n);if(!a)return{containerBlock:null,containerType:"none",cellIndex:0,isRoot:!1};const l=e[a.containerId];return{containerBlock:l??null,containerType:l?.containerType??"none",cellIndex:a.cellIndex,isRoot:!1}}(t,n,o.id);let s=0;if(i)s=r??0;else if(e){const t=n.indexOf(e.id);s=t>=0?t:0}const c=l??0;return{containerBlock:e??null,containerType:a??"none",columnIndex:s,cellIndex:c,contentIndex:c}},[t,n,o?.id])}const{TextArea:bl}=t.Input,yl=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,64],_l="staticTextBeforeAi";function fl(e,t,n,o){const a=Number.parseInt(String(e??""),10);return Number.isNaN(a)?o:Math.min(n,Math.max(t,a))}function xl(e){return null==e||"string"!=typeof e?"":e.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}const kl=()=>{const{currentItem:a,previewMode:i,templateData:r,apiConfig:s,bodySettings:c,aiEnabled:d=!0}=e.useContext(ge),{t:u}=So(),{findStyleItem:m,paddingChange:p,otherStylesChange:g,inputChange:h,updateItemStyles:b}=Qa(),{containerBlock:y,containerType:_,cellIndex:f}=hl(),x="product"===_?y?.columnProducts?.[f??0]?.id:void 0,k="bn-BD"===a?.data?.dynamicAiLanguage?"bn-BD":"en",{generateOptions:v}=gl({mlEmailNodesEndpoint:s?.mlEmailNodesEndpoint,mlGenerationEndpoint:s?.mlGenerationEndpoint,headers:s?.headers||{},templateData:r,blockId:a?.id,containerType:_,containerId:y?.id,productId:x,blockName:a?.data?.name||"Text",blockElementType:a?.data?.type||"p",emailTemplateId:s?.emailTemplateId,companyId:s?.companyId??r?.companyId,aiContentLanguage:k}),[w,j]=e.useState(""),S=m(a.data.styles,"fontSize"),N=null!=S&&""!==S?Number(S):14,[A,T]=e.useState(String(N)),[L,B]=e.useState(""),$=(e,t)=>{const n=C(a.data);n.styles||(n.styles={desktop:{},mobile:{}}),n.styles.desktop||(n.styles.desktop={}),n.styles.mobile||(n.styles.mobile={}),n.styles.desktop[e]=t,n.styles[i][e]=t,n.text=I(n.text,n.styles.desktop),b(n)},R=e=>{const t=fl(e,1,999,14);T(String(t)),$("fontSize",t)},M=()=>{const e=String(L??"").trim();if(""===e){const e=C(a.data);return e.styles||(e.styles={desktop:{},mobile:{}}),e.styles.desktop||(e.styles.desktop={}),e.styles.mobile||(e.styles.mobile={}),delete e.styles.desktop.lineHeight,delete e.styles.mobile.lineHeight,void b(e)}const t=fl(e,1,999,24);B(String(t)),h("lineHeight")(`${t}px`)};e.useEffect(()=>{T(String(N))},[a?.id,N]);const P=m(a.data.styles,"lineHeight");e.useEffect(()=>{B(null==P||""===P?"":String(function(e,t=14){if(null==e||""===e)return Math.max(1,Math.round(1.4*Number(t)));const n=String(e).trim(),o=n.match(/^(-?\d*\.?\d+)\s*%$/);if(o){const e=Number(o[1]);if(!Number.isNaN(e))return Math.max(1,Math.round(t*e/100))}const a=n.match(/^(-?\d*\.?\d+)\s*px$/i);if(a){const e=Number(a[1]);if(!Number.isNaN(e))return Math.max(1,Math.round(e))}const l=Number(n);return Number.isNaN(l)?24:l>0&&l<=10?Math.max(1,Math.round(t*l)):Math.max(1,Math.round(l))}(P,N)))},[a?.id,P,N]);const[F,E]=e.useState([]),[D,U]=e.useState(!1),[z,O]=e.useState(""),W=a.data.contentType??"static",H=a.data.type??"p",V=String(H).toLowerCase(),K="p"===V||""===H?"p":/^h[1-6]$/.test(V)?V:"p",G=e=>{if(!d)return;const t=e?"dynamic":"static",n=C(a.data),o=n.styles?.desktop??{};if(n.contentType=t,"dynamic"===t){if("static"===(a.data.contentType??"static")){const e=a.data.text??"",t=I(u("text_content"),o),l=I(u("ai_enabled"),o);xl(e).length>0&&e!==t&&e!==l?n[_l]=e:delete n[_l]}n.selectedVariableKey=void 0,n.dynamicVariable=n.dynamicVariable??"",n.dynamicPrompt=n.dynamicPrompt??"",n.dynamicSelectedContent=n.dynamicSelectedContent??"",n.dynamicOptions=Array.isArray(n.dynamicOptions)?n.dynamicOptions:[],n.dynamicAiLanguage="bn-BD"===n.dynamicAiLanguage?"bn-BD":"en",n.text=I(u("ai_enabled"),o)}else{const e=n[_l];"string"==typeof e&&xl(e).length>0?n.text=I(e,o):n.text=I(u("text_content"),o),delete n[_l]}b(n)},q=async()=>{const e=a.data.dynamicVariable??"",t=a.data.dynamicPrompt??w??"";U(!0),O("");try{const n=await v(e,t,{previousPrompt:a.data.dynamicPreviousPrompt??"",previousSelectedAiContent:xl(a.data.dynamicSelectedContent||a.data.text)});if(n&&"object"==typeof n&&!Array.isArray(n))return n.i18nKey?O(u(n.i18nKey)):n.error?O(String(n.error)):O(u("ml_no_variations")),void E([]);if(Array.isArray(n)&&n.length>0){O(""),E(n);const e=C(a.data);e.dynamicOptions=n,e.dynamicPrompt=t,e.dynamicPreviousPrompt=t,b(e)}else O(u("ml_no_variations")),E([])}catch(e){console.error("[TextStyleSettings] Error during content generation:",e),O(e&&"object"==typeof e&&"message"in e?String(e.message):u("ml_generation_unexpected_error")),E([])}finally{U(!1)}},J=e=>{const t=e.target.value;j(t),O("");const n=C(a.data);n.dynamicPrompt=t,b(n)},Y=e=>{const t=C(a.data);t.dynamicAiLanguage="bn-BD"===e?"bn-BD":"en",b(t)};return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[(()=>{const e=l.jsxs("div",{className:fo("ee-text-ai-usp-row","ee-settings-row","ee-text-ai-toggle-row",!d&&"ee-text-ai-usp-row--disabled"),children:[l.jsxs("span",{className:"ee-text-ai-label-with-help",children:[u("ai_enabled"),l.jsx(t.Tooltip,{title:u("tooltip_write_using_ai"),children:l.jsx("span",{className:"ee-help-icon ee-text-ai-help-trigger","aria-label":u("tooltip_write_using_ai"),onClick:e=>e.stopPropagation(),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),l.jsx(Ma,{checked:"dynamic"===W,onChange:G,disabled:!d})]});return l.jsx(l.Fragment,{children:l.jsxs("div",{className:"ee-text-settings-content-wrap",children:[l.jsx(Ea,{children:u("content")}),l.jsxs("div",{className:"ee-text-settings-content-gap",children:[l.jsx(Ua,{label:u("heading_type"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:K,onChange:e=>{return(t=e,()=>{const e=String(t??"p").toLowerCase(),n=a.data.styles?.desktop??{},o="p"!==e&&/^h[1-6]$/.test(e)?e:"p";let l,i,r;if("p"===o)l=14,i=20,r="400";else{switch(l=n.fontSize,o){case"h1":l=22;break;case"h2":l=20;break;case"h3":l=18;break;case"h4":l=16;break;case"h5":l=15;break;case"h6":l=14;break;default:l=null!=l&&""!==l&&Number(l)||14}i=Math.max(1,Math.round(1.4*Number(l))),r="bold"}const s=C(a.data);s.type=o;const c="p"===o?{textTransform:"none",letterSpacing:"0em"}:{},d={...n,...c,fontSize:l,lineHeight:`${i}px`,fontWeight:r},u={...a.data.styles?.mobile??{},...c,fontSize:l,lineHeight:`${i}px`,fontWeight:r};s.styles={...s.styles??{},desktop:d,mobile:u},s.text=I(s.text,d),b(s)})();var t},items:[{value:"p",label:u("body_paragraph")},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"}],"aria-label":u("heading_type")})}),l.jsx("div",{className:"ee-text-ai-slot",children:d?e:l.jsx(t.Tooltip,{title:u("tooltip_write_using_ai_unavailable"),children:e})}),d&&"dynamic"===W?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"ee-dynamic-prompt-block ee-dynamic-prompt-block--with-heading",children:[l.jsxs("div",{className:"ee-dynamic-language-row",children:[l.jsx("span",{className:"ee-prompt-label",children:u("ai_output_language")}),l.jsxs(t.Select,{className:"input-width ee-dynamic-language-select",value:k,onChange:Y,getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:[l.jsx(t.Select.Option,{value:"en",children:u("ai_output_language_en")}),l.jsx(t.Select.Option,{value:"bn-BD",children:u("ai_output_language_bn")})]})]}),l.jsxs("span",{className:"ee-prompt-label",children:[u("dynamic_prompt_help"),l.jsx(t.Tooltip,{title:u("tooltip_dynamic_prompt"),children:l.jsx("span",{className:"ee-help-icon","aria-label":"Help",children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),l.jsx(bl,{rows:3,value:a.data.dynamicPrompt??w,onChange:J,placeholder:u("dynamic_prompt_help")}),l.jsx(t.Button,{type:"primary",size:"small",block:!0,loading:D,disabled:!(a.data.dynamicPrompt??w??"").trim(),onClick:q,children:u("generate")}),z?l.jsx("div",{className:"ee-ml-generation-error",role:"alert",children:z}):null]}),(a.data.dynamicOptions?.length>0||F.length>0)&&l.jsxs("div",{className:"ee-sample-content-block",children:[l.jsx("div",{className:"card-item-title",children:u("select_content")}),(a.data.dynamicOptions||F).map((e,t)=>{const n="string"==typeof e?e:String(e),o=(a.data.text||a.data.dynamicSelectedContent||"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim(),i=n.replace(/\s+/g," ").trim(),r=o.length>0&&o===i;return l.jsx("div",{className:fo("ee-sample-content-item",r&&"ee-sample-content-item-selected"),onClick:()=>(e=>{const t=C(a.data);t.dynamicSelectedContent=e,t.text=e,b(t),E([]),O("")})(e),children:e},t)})]})]}):null]})]})})})(),(()=>{const e=m(a.data.styles,"color"),s=null!=e&&""!==String(e).trim()?e:c?.styles?.color??"#171717",d=m(a.data.styles,"linkColor"),p=m(a.data.styles,"textAlign"),y=m(a.data.styles,"fontFamily"),_=function(e){if(null==e||""===e)return"400";const t=String(e).trim().toLowerCase();if("bold"===t||"bolder"===t)return"700";if("normal"===t||"lighter"===t)return"400";const n=Number(t);return Number.isNaN(n)||n<=450?"400":n<=550?"500":n<=650?"600":"700"}(m(a.data.styles,"fontWeight")),f=m(a.data.styles,"textTransform"),x=null!=f&&""!==String(f).trim()?String(f):"none",k=function(e,t){if(null==e||""===e)return t;const n=String(e).trim().replace(/[a-z%]+$/i,""),o=Number(n);return Number.isNaN(o)?t:o}(m(a.data.styles,"letterSpacing"),0),v=Mt(r),w=Ft(y,r);return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:u("typography")}),l.jsx(Ua,{label:u("font_color"),children:l.jsx(Ba,{color:s,fallbackColor:c?.styles?.color??"#171717",setColor:({hex:e})=>$("color",e)})}),l.jsx(Ua,{label:u("link_color"),children:l.jsx(Ba,{color:null!=d&&""!==String(d).trim()?d:"#2faade",setColor:({hex:e})=>((e,t)=>{const n=C(a.data);n.styles||(n.styles={desktop:{},mobile:{}}),n.styles.desktop||(n.styles.desktop={}),n.styles.mobile||(n.styles.mobile={}),n.styles.desktop[e]=t,n.styles[i][e]=t,b(n)})("linkColor",e)})}),l.jsx(Ua,{label:u("label_align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:p||"left",onChange:e=>g("textAlign",e),"aria-label":u("text_align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ua,{label:u("font_weight"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:_,onChange:e=>$("fontWeight",e),"aria-label":u("font_weight"),items:[{value:"400",label:"Reg"},{value:"500",label:"Med"},{value:"600",label:"SBd"},{value:"700",label:"Bd"}]})}),l.jsx(Ua,{label:u("text_transform"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:x,onChange:e=>$("textTransform",e),"aria-label":u("text_transform"),items:[{value:"none",label:"Aa"},{value:"uppercase",label:"AA"},{value:"capitalize",label:"Cp"}]})}),l.jsx(Ua,{label:u("font_family"),children:l.jsx(t.Select,{className:"input-width ee-font-family-select",value:w,showSearch:!0,optionFilterProp:"label",labelRender:({value:e})=>l.jsx("span",{children:Et(e,r)}),onChange:e=>$("fontFamily",Ft(e,r)),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:v})}),l.jsx(Ua,{label:u("font_size"),children:l.jsx(t.AutoComplete,{className:"input-width ee-settings-input-affix",value:A,options:yl.map(e=>({value:String(e),label:`${e}px`})),onChange:e=>T(String(e??"")),onSelect:e=>R(e),filterOption:!1,getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:l.jsx(t.Input,{addonAfter:"px",onFocus:e=>e?.target?.select?.(),onBlur:()=>R(A),onPressEnter:e=>{R(A),e.currentTarget.blur()},onKeyDown:e=>{if("ArrowUp"!==e.key&&"ArrowDown"!==e.key)return;e.preventDefault();const t="ArrowUp"===e.key?1:-1,n=fl(A,1,999,14)+t;R(n)}})})}),l.jsx(Ua,{label:u("line_height"),children:l.jsx(t.Input,{className:"input-width ee-settings-input-affix",addonAfter:"px",value:L,onChange:e=>B(e.target.value.replace(/[^\d]/g,"")),onFocus:e=>e?.target?.select?.(),onBlur:M,onPressEnter:e=>{M(),e.currentTarget.blur()}})}),l.jsx(Ua,{label:u("letter_spacing"),children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix",addonAfter:"px",min:-20,max:100,step:.1,value:k,onFocus:e=>e?.target?.select?.(),onChange:e=>{const t=null==e||Number.isNaN(Number(e))?0:Number(e);h("letterSpacing")(`${t}px`)}})})]})})(),l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:u("spacing")||"Spacing"}),l.jsx(Ua,{label:u("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:m(a.data.styles,"paddingTop"),paddingRight:m(a.data.styles,"paddingRight"),paddingLeft:m(a.data.styles,"paddingLeft"),paddingBottom:m(a.data.styles,"paddingBottom")},setPadding:p})})]})]})};function vl(e){if(null==e)return!0;const t=String(e).trim().toLowerCase();return""===t||"transparent"===t||"rgba(0, 0, 0, 0)"===t}function wl(e,t){const n=(e=>e?.brandContext?.brand_color??"#111111")(t);if(!e||"object"!=typeof e)return n;for(const t of["desktop","mobile"]){const n=e[t]?.backgroundColor;if(!vl(n))return n}for(const t of["desktop","mobile"]){const n=e[t]?.borderColor;if(!vl(n))return n}return n}function jl(e,t,n){"solid"===t?(e.borderWidth=0,e.borderStyle="solid",e.borderColor=n,e.backgroundColor=n,e.color=function(e){const t=String(e??"").trim().replace(/^#/,"");if(3!==t.length&&6!==t.length)return"#ffffff";const n=(e=>3===e.length?e.split("").map(e=>e+e).join(""):e)(t),o=parseInt(n.slice(0,2),16),a=parseInt(n.slice(2,4),16),l=parseInt(n.slice(4,6),16);return[o,a,l].every(e=>Number.isFinite(e))&&(.299*o+.587*a+.114*l)/255>.62?"#171717":"#ffffff"}(n),e.textDecoration="none"):"outline"===t?(e.borderWidth=2,e.borderStyle="solid",e.borderColor=n,e.backgroundColor="transparent",e.color=n,e.textDecoration="none"):"ghost"===t?(e.borderWidth=0,e.borderStyle="none",e.borderColor="transparent",e.backgroundColor="transparent",e.color=n,e.textDecoration="none"):"underline"===t&&(e.borderWidth=0,e.borderStyle="none",e.borderColor="transparent",e.backgroundColor="transparent",e.color=n,e.textDecoration="underline")}const Sl=()=>{const{currentItem:a,previewMode:i,templateData:r}=e.useContext(ge),[s,c]=e.useState(""),{t:d}=So(),{containerBlock:u,containerType:m,contentIndex:p}=hl(),h=u?.columnProducts?.[p]??null,b=e.useMemo(()=>({columnIndex:p,columnProduct:h}),[p,h]),y=e.useMemo(()=>Mt(r),[r]),_=["header","footer","discount","product"].includes(m),{findStyleItem:f,colorChange:x,paddingChange:k,inputChange:v,updateItemStyles:w}=Qa(),{urlOptions:j}=e.useMemo(()=>function(e,t,n={}){const o="product"===e?vt:kt;return{labelOptions:xt.map(({variableKey:e,labelKey:o})=>({value:Je(e),labelKey:o,pasteValue:yt(t,e,n)})),urlOptions:o.map(({variableKey:e,labelKey:o})=>({value:Je(e),labelKey:o,pasteValue:yt(t,e,n)}))}}(m,r,b),[m,r,b]);return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[(()=>{const{linkURL:e,text:n,labelVariable:o,urlVariable:i}=a.data,u=n?.replace(/<[^>]+>/g,"").trim()??"",m=o||u&&/\{\{\w+\}\}/.test(u),p=o?o.replace(/^\{\{|\}\}$/g,"").trim():u.match(/\{\{(\w+)\}\}/)?.[1]||"CTALabel",h=r&&m?yt(r,p,b):null,y=null==h||String(h).startsWith("{{")?u:h,f=i?i.replace(/^\{\{|\}\}$/g,"").trim():"",x=null!=e?String(e).trim():"",k=x.match(/^\{\{(\w+)\}\}$/),v=i||(!i&&k?x:null)||void 0,S=k&&r?yt(r,k[1],b):null,N=null==S||"string"!=typeof S||String(S).startsWith("{{")?"":String(S).trim(),I=!x&&f&&r?yt(r,f,b):null,A=null==I||"string"!=typeof I||I.startsWith("{{")?"":String(I).trim(),T=N||A||x||"",L=e=>{c((e=>{const t=String(e??"").trim(),n=g(t,!1,{allowMailtoTel:!0});return n?"empty"===n?"Button -> Link URL is empty. Add a destination like 'https://example.com' or 'mailto:support@example.com'.":"blocked_scheme"===n?`Button -> Link URL ('${t}') uses a blocked protocol. Use https://, http://, mailto:, or tel:.`:"duplicate_protocol"===n?`Button -> Link URL ('${t}') repeats the protocol. Keep only one, e.g. 'https://example.com'.`:"missing_hostname_dot"===n?`Button -> Link URL ('${t}') is missing a valid hostname. Use a full domain like 'https://example.com'.`:"invalid_protocol"===n?`Button -> Link URL ('${t}') has an unsupported protocol. Use https://, http://, mailto:, or tel:.`:`Button -> Link URL ('${t}') is invalid. Fix the URL format, for example 'https://example.com'.`:""})(e))};return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("button_action")}),l.jsx(Ua,{label:d("button_text"),children:l.jsx(t.Input,{className:"width-full",value:y,onChange:e=>{const t=e.target.value,n=C(a.data);n.text=t,t&&t.startsWith("{{")||(n.labelVariable=""),w(n)},placeholder:d("button_label_manual")})}),_&&j.length>0?l.jsx(Ua,{label:d("button_url_variable"),children:l.jsx(t.Select,{className:"ee-variable-select width-full",placeholder:d("button_url_manual"),allowClear:!0,value:v,onChange:e=>{const t=C(a.data);if(!e){t.urlVariable="";const e=String(t.linkURL??"").trim();return/^\{\{\w+\}\}$/.test(e)?t.linkURL="":t.linkURL=t.linkURL||"",void w(t)}const n=j.find(t=>t.value===e);t.urlVariable=e;const o=n?n.pasteValue:e;t.linkURL="string"==typeof o?o.replace(/^https?:\/\//,""):"",w(t)},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:[{value:"",label:d("button_url_manual")},...j.map(e=>({value:e.value,label:d(e.labelKey)}))]})}):null,l.jsx(Ua,{label:d("link_url"),children:l.jsxs(l.Fragment,{children:[l.jsx(t.Input,{className:"width-full",value:T,onChange:e=>{const t=e.target.value,n=C(a.data);n.linkURL=t,t&&t.startsWith("{{")||(n.urlVariable=""),w(n),s&&L(t)},onBlur:e=>L(e.target.value),status:s?"error":"",placeholder:d("link_url_placeholder")}),s?l.jsx("div",{className:"ee-field-error",role:"alert",children:s}):null]})})]})})(),(()=>{const e=f(a.data.styles,"width"),s=f(a.data.styles,"borderRadius"),c="number"==typeof s?s:parseInt(String(s||"").replace("px",""),10)||0,u=a.data.contentStyles?.[i]?.textAlign??"center",m="left"===u||"center"===u||"right"===u?u:"center",p=f(a.data.styles,"color"),g=f(a.data.styles,"fontFamily"),h=f(a.data.styles,"fontSize"),b=f(a.data.styles,"lineHeight"),_=function(e,t){const n=e?.buttonAccentColor;return null==n||vl(n)?wl(e?.styles,t):n}(a.data,r),j=a.data.buttonVariant??"solid",S=a.data.hoverBg??"",N=a.data.hoverColor??"",I=f(a.data.styles,"letterSpacing")??"0em",A=f(a.data.styles,"textTransform")??"none",T=f(a.data.styles,"textDecoration")??"none",L=f(a.data.styles,"borderWidth"),B=f(a.data.styles,"borderStyle")??"solid",$=f(a.data.styles,"borderColor")??"#000000",R=a.data.shadowPreset??"none",M=e=>t=>{const n=C(a.data);n[e]=t,w(n)},P={none:"",sm:"0 1px 2px rgba(0,0,0,0.12)",md:"0 4px 6px rgba(0,0,0,0.18)",lg:"0 10px 20px rgba(0,0,0,0.22)"},F=()=>document.querySelector(".right-settings")||document.body;return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("button_styles")}),l.jsx(Ua,{label:d("button_variant")||"Variant",children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:j,onChange:e=>(e=>{const t=C(a.data);t.buttonVariant=e,t.styles=t.styles??{desktop:{},mobile:{}},t.styles.desktop={...t.styles.desktop??{}},t.styles.mobile={...t.styles.mobile??{}};const n=null==t.buttonAccentColor||vl(t.buttonAccentColor)?wl(t.styles,r):t.buttonAccentColor;t.buttonAccentColor=n,jl(t.styles.desktop,e,n),jl(t.styles.mobile,e,n),w(t)})(e),"aria-label":d("button_variant")||"Variant",items:[{value:"solid",label:"Solid"},{value:"outline",label:"Outline"},{value:"ghost",label:"Ghost"},{value:"underline",label:"Underline"}]})}),l.jsx(Ua,{layout:"toggle",label:d("full_width")||"Full width",children:l.jsx(Ma,{checked:"auto"!==e,onChange:()=>{const t="auto"===e?"100%":"auto";v("width")(t)}})}),"auto"!==e?l.jsx(Ua,{label:d("width"),children:l.jsx(t.Slider,{value:Number(String(e).replace("%","")),onChange:e=>v("width")(e+"%")})}):null,"auto"!==e?l.jsx(Ua,{label:d("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:m,onChange:e=>(e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]||{},textAlign:e},w(t)})(e),"aria-label":d("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0}]})}):null,l.jsx(Ua,{label:d("font_color"),children:l.jsx(Ba,{color:p,setColor:x("color")})}),l.jsx(Ua,{label:d("button_color"),children:l.jsx(Ba,{color:_,setColor:({hex:e})=>{const t=C(a.data);t.styles=t.styles??{desktop:{},mobile:{}},t.styles.desktop={...t.styles.desktop??{}},t.styles.mobile={...t.styles.mobile??{}},t.buttonAccentColor=e;const n=t.buttonVariant??"solid";jl(t.styles.desktop,n,e),jl(t.styles.mobile,n,e),w(t)}})}),l.jsx(Ua,{label:d("hover_bg_color")||"Hover bg",children:l.jsx(Ba,{color:S||_,setColor:e=>M("hoverBg")(e.hex)})}),l.jsx(Ua,{label:d("hover_text_color")||"Hover text",children:l.jsx(Ba,{color:N||p,setColor:e=>M("hoverColor")(e.hex)})}),l.jsx(Ua,{label:d("font_family"),children:l.jsx(t.Select,{className:"width-full",showSearch:!0,optionFilterProp:"label",value:Ft(g??"sans-serif",r),onChange:e=>v("fontFamily")(Ft(e,r)),labelRender:({value:e})=>l.jsx("span",{children:Et(e,r)}),getPopupContainer:F,options:y})}),l.jsx(Ua,{label:d("font_size"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:h,onFocus:e=>e?.target?.select?.(),onChange:v("fontSize")})}),l.jsx(Ua,{label:d("line_height"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"%",value:Number(String(b||"100").replace("%","")),onFocus:e=>e?.target?.select?.(),onChange:e=>v("lineHeight")(`${e??0}%`)})}),l.jsx(Ua,{label:d("letter_spacing")||"Letter spacing",children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix",addonAfter:"em",step:.01,value:parseFloat(String(I).replace("em",""))||0,onFocus:e=>e?.target?.select?.(),onChange:e=>v("letterSpacing")(`${e??0}em`)})}),l.jsx(Ua,{label:d("text_transform")||"Transform",children:l.jsx(t.Select,{className:"width-full",value:A,onChange:v("textTransform"),getPopupContainer:F,options:[{value:"none",label:"None"},{value:"uppercase",label:"UPPERCASE"},{value:"lowercase",label:"lowercase"},{value:"capitalize",label:"Capitalize"}]})}),l.jsx(Ua,{label:d("text_decoration")||"Decoration",children:l.jsx(t.Select,{className:"width-full",value:T,onChange:v("textDecoration"),getPopupContainer:F,options:[{value:"none",label:"None"},{value:"underline",label:"Underline"},{value:"line-through",label:"Strikethrough"}]})}),l.jsx(Ea,{children:d("border")||"Border"}),l.jsx(Ua,{label:d("border_width")||"Width",children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof L?L:parseInt(String(L||"0"),10)||0,onFocus:e=>e?.target?.select?.(),onChange:e=>v("borderWidth")(Number(e)||0)})}),l.jsx(Ua,{label:d("border_style")||"Style",children:l.jsx(t.Select,{className:"width-full",value:B,onChange:v("borderStyle"),getPopupContainer:F,options:[{value:"solid",label:d("solid")},{value:"dashed",label:d("dashed")},{value:"dotted",label:d("dotted")},{value:"none",label:d("video_border_none")}]})}),l.jsx(Ua,{label:d("border_color"),children:l.jsx(Ba,{color:$,setColor:e=>v("borderColor")(e.hex)})}),l.jsx(Ua,{label:d("border_radius"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:c,onFocus:e=>e?.target?.select?.(),onChange:e=>v("borderRadius")(Number(e)||0)})}),l.jsx(Ea,{children:d("shadow")||"Shadow"}),l.jsx(Ua,{label:d("shadow_preset")||"Preset",children:l.jsx(t.Select,{className:"width-full",value:R,onChange:e=>{const t=C(a.data);t.shadowPreset=e,t.styles=t.styles??{},t.styles[i]=t.styles[i]??{},t.styles[i].boxShadow=P[e]??"",w(t)},getPopupContainer:F,options:[{value:"none",label:"None"},{value:"sm",label:"Small"},{value:"md",label:"Medium"},{value:"lg",label:"Large"}]})}),l.jsx(Ea,{children:d("button_padding")}),l.jsx(Ua,{label:d("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:f(a.data.styles,"paddingTop"),paddingRight:f(a.data.styles,"paddingRight"),paddingLeft:f(a.data.styles,"paddingLeft"),paddingBottom:f(a.data.styles,"paddingBottom")},setPadding:k})})]})})(),l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("spacing")}),l.jsx(Ua,{label:d("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:f(a.data.contentStyles,"paddingTop"),paddingRight:f(a.data.contentStyles,"paddingRight"),paddingLeft:f(a.data.contentStyles,"paddingLeft"),paddingBottom:f(a.data.contentStyles,"paddingBottom")},setPadding:e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],...e},w(t)}})})]})]})},Cl=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,colorChange:c,updateItemStyles:d,inputChange:u}=Qa(),m=e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],...e},d(t)};return l.jsx("div",{className:"margin-y-30 ee-settings-block-form",children:(()=>{const e=s(a.data.contentStyles,"textAlign"),p=["left","center","right","justify"].includes(e)?e:"center",g=(e=>{if(null==e)return 100;if("number"==typeof e&&Number.isFinite(e))return Math.min(100,Math.max(0,e));const t=String(e).trim();if(/%$/.test(t)){const e=Number(t.replace(/%/,""));return Number.isFinite(e)?Math.min(100,Math.max(0,e)):100}const n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(100,Math.max(0,n)):100})(s(a.data.styles,"width")),h=s(a.data.styles,"borderTopColor"),b=s(a.data.styles,"borderTopWidth"),y=s(a.data.styles,"borderTopStyle"),_=[{label:r("solid"),value:"solid"},{label:r("dotted"),value:"dotted"},{label:r("dashed"),value:"dashed"}];return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:r("divider")}),l.jsx(Ua,{label:r("divider_type"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:y||"solid",onChange:e=>u("borderTopStyle")(e),"aria-label":r("divider_type"),items:_.map(e=>({value:e.value,label:e.label}))})}),l.jsx(Ua,{label:r("height"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof b?b:0,onFocus:e=>e?.target?.select?.(),onChange:e=>u("borderTopWidth")("number"==typeof e?e:0)})}),l.jsx(Ua,{label:r("divider_color"),children:l.jsx(Ba,{color:h,setColor:c("borderTopColor")})}),l.jsx(Ua,{label:r("width"),children:l.jsx(t.Slider,{min:0,max:100,value:g,tooltip:{formatter:e=>`${e}%`},onChange:e=>u("width")(`${e}%`)})}),l.jsx(Ua,{label:r("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:p,onChange:e=>(e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],textAlign:e},d(t)})(e),"aria-label":r("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ea,{children:r("spacing")}),l.jsx(Ua,{label:r("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop"),paddingRight:s(a.data.contentStyles,"paddingRight"),paddingLeft:s(a.data.contentStyles,"paddingLeft"),paddingBottom:s(a.data.contentStyles,"paddingBottom")},setPadding:m})})]})})()})};function Nl(e,t,n,o){const a=Number.parseInt(String(e??""),10);return Number.isNaN(a)?o:Math.min(n,Math.max(t,a))}const Il=()=>{const{currentItem:a}=e.useContext(ge),{t:i}=So(),{findStyleItem:r,inputChange:s}=Qa(),c=r(a.data.styles,"height"),d="number"==typeof c?c:parseInt(c,10)||16;return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx(Ea,{children:i("spacer")}),l.jsx(Ua,{label:l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faArrowsAltV,className:"tag-style-size"}),i("height")]}),children:l.jsx(t.InputNumber,{min:0,max:200,step:1,className:"input-width ee-settings-input-affix",addonAfter:"px",value:d,onFocus:e=>e?.target?.select?.(),onChange:e=>s("height")(Nl(e,0,200,0)),onBlur:e=>s("height")(Nl(e?.target?.value,0,200,0)),onKeyDown:e=>{if("ArrowUp"!==e.key&&"ArrowDown"!==e.key)return;e.preventDefault();const t="ArrowUp"===e.key?1:-1;s("height")(Nl(d+t,0,200,0))}})})]})};function Al(e){if(null==e||""===e)return"400";const t=String(e).trim().toLowerCase();if("normal"===t||"regular"===t)return"400";if("bold"===t)return"700";if("bolder"===t)return"700";if("lighter"===t)return"300";if("light"===t)return"300";const n=Number(t);return Number.isNaN(n)?"400":n<=350?"300":n<=500?"400":n<=650?"600":"700"}const Tl=new Set(["|","•","—","/","·"," "]);function Ll(e){return[...String(e??"")].filter(e=>Tl.has(e)).join("")}const Bl=()=>{const{currentItem:a,previewMode:i,templateData:r}=e.useContext(ge),{t:s}=So(),{findStyleItem:c,updateItemStyles:d,colorChange:u,inputChange:m}=Qa(),{list:p=[],separator:h=" | "}=a.data;e.useLayoutEffect(()=>{const e=a?.data?.separator,t=Ll(String(e??""));if(String(e??"")!==t){const e=C(a.data);e.separator=t,d(e)}},[a?.id,a?.data?.separator]);const[b,y]=e.useState(!1),[_,f]=e.useState(null),[x,k]=e.useState({}),v=e.useRef(null),w=()=>document.querySelector(".right-settings")||document.body,j=(e,t)=>{const n=C(a.data);n[e]=t,"list"===e&&(n.useNavigationLinks=!1),d(n)},S=(e,t,n)=>{const o=((e,t,n)=>{const o=String(e??"").trim(),a=`Menu item ${t+1}${n?` (${n})`:""} -> URL`,l=g(o,!1,{allowMailtoTel:!0});return l?"empty"===l?`${a} is empty. Add a destination like 'https://example.com'.`:"blocked_scheme"===l?`${a} ('${o}') uses a blocked protocol. Use https://, http://, mailto:, or tel:.`:"duplicate_protocol"===l?`${a} ('${o}') repeats the protocol. Keep one protocol, e.g. 'https://example.com'.`:"missing_hostname_dot"===l?`${a} ('${o}') is missing a valid hostname. Use a full domain like 'https://example.com'.`:"invalid_protocol"===l?`${a} ('${o}') has an unsupported protocol. Use https://, http://, mailto:, or tel:.`:`${a} ('${o}') is invalid. Fix it to a valid URL like 'https://example.com'.`:""})(e,t,n);k(e=>{if(!o&&!e[t])return e;const n={...e};return o?n[t]=o:delete n[t],n})},I=e.useCallback(N(e=>{e.preventDefault();const t=v.current,n=e.target?.closest?.(".social-link-item[data-index]");if(!n||!t?.contains(n))return;const o=Array.from(t.querySelectorAll(".social-link-item[data-index]")).indexOf(n);if(-1===o)return;const a=_,l=C(p);null==a||a===o||l.length<2||([l[o],l[a]]=[l[a],l[o]],f(o),j("list",l))},50),[_]),A=Mt(r),T=Ft(c(a.data.styles,"fontFamily"),r),L=[{label:s("same_tab"),value:"_self"},{label:s("new_tab"),value:"_blank"}],B=a.data.layoutMode??"nav-only",$=Boolean(a.data.showLogo),R=Boolean(a.data.borderBottom),M=a.data.borderBottomColor??"#e5e7eb",P=a.data.borderBottomWidth??1,F=a.data.mobileLayout??"stack",E=a.data.linkGapPx,D="number"==typeof E&&Number.isFinite(E)?E:0,U=Boolean(a.data.linkUnderline),z=[{value:"nav-only",label:s("nav_only")||"Navigation only"},{value:"logo-left",label:s("logo_left")||"Logo left"},{value:"logo-right",label:s("logo_right")||"Logo right"},{value:"stacked",label:s("stacked")||"Stacked"},{value:"logo-only",label:s("logo_only")||"Logo only"}],O=c(a.data.contentStyles,"textAlign"),W=["left","center","right"].includes(O)?O:"center";return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx(Ea,{children:s("menu_layout")||"Menu layout"}),l.jsx(Ua,{label:s("layout_mode")||"Layout mode",children:l.jsx(t.Select,{className:"width-full",value:B,onChange:e=>j("layoutMode",e),getPopupContainer:w,options:z})}),l.jsx(Ua,{label:s("mobile_layout")||"Mobile layout",children:l.jsx(t.Select,{className:"width-full",value:F,onChange:e=>j("mobileLayout",e),getPopupContainer:w,options:[{value:"stack",label:s("stack")||"Stack"},{value:"inline",label:s("inline")||"Inline"}]})}),["logo-left","logo-right","stacked","logo-only"].includes(B)&&l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:s("logo_section")}),l.jsx(Ua,{layout:"toggle",label:s("show_logo"),children:l.jsx(Ma,{checked:$,onChange:e=>j("showLogo",e)})}),$?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:s("logo_url")||"Logo URL",children:l.jsx(t.Input,{className:"width-full",placeholder:"https://...",value:a.data.logoSrc??"",onChange:e=>j("logoSrc",e.target.value)})}),l.jsx(Ua,{label:s("logo_text")||"Logo text",children:l.jsx(t.Input,{className:"width-full",placeholder:s("logo_text_placeholder")||"Brand",value:a.data.logoText??"",onChange:e=>j("logoText",e.target.value)})}),l.jsx(Ua,{label:s("logo_alt")||"Alt text",children:l.jsx(t.Input,{className:"width-full",placeholder:"Logo",value:a.data.logoAlt??"",onChange:e=>j("logoAlt",e.target.value)})}),l.jsx(Ua,{label:s("logo_link")||"Logo link",children:l.jsx(t.Input,{className:"width-full",value:a.data.logoHref??"",onChange:e=>j("logoHref",e.target.value),placeholder:s("link_url_placeholder")||"example.com"})}),l.jsx(Ua,{label:s("logo_max_width"),children:l.jsx(t.InputNumber,{min:20,max:400,className:"input-width ee-settings-input-affix",addonAfter:"px",value:a.data.logoMaxWidth??120,onFocus:e=>e?.target?.select?.(),onChange:e=>j("logoMaxWidth",e??120)})})]}):null]}),l.jsx(Ea,{children:s("menu_items")}),l.jsx("div",{ref:v,onDragOver:I,className:"margin-top-12",children:p.map((e,a)=>l.jsx("div",{"data-index":a,draggable:!0,onDragStart:()=>{y(!0),f(a)},onDragEnd:e=>{e.currentTarget?.classList?.remove("social-link-item-current"),y(!1),f(null)},className:fo("social-link-item","cursor-grab",b&&"social-link-item-drag_start",_===a?"social-link-item-current":"border-transparent"),children:l.jsxs("div",{className:"social-link-item-content ee-menu-item-content",children:[l.jsxs("div",{className:"ee-menu-item-header flex items-center justify-between margin-bottom-8",children:[l.jsxs("div",{className:"flex items-center ee-menu-item-drag-row",children:[l.jsx("span",{className:"social-link-item-drag-handle ee-menu-item-drag-handle","aria-hidden":!0,children:l.jsx(n.FontAwesomeIcon,{icon:o.faGripVertical,className:"social-link-item-drag-handle-icon"})}),l.jsxs("span",{className:"font-semibold",children:[s("menu_item")," ",a+1]})]}),l.jsx("div",{className:"social-link-item-icon social-link-item-icon-slate ee-menu-item-delete",role:"button",tabIndex:0,onClick:()=>j("list",p.filter((e,t)=>t!==a)),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),j("list",p.filter((e,t)=>t!==a)))},children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash,className:"social-link-item-icon-svg social-link-item-icon-svg-deep"})})]}),l.jsxs("div",{className:"ee-menu-item-fields ee-settings-stack-flat",children:[l.jsx(Ua,{label:s("label"),children:l.jsx(t.Input,{className:"width-full ee-menu-item-input",value:e.label||"",onChange:e=>j("list",p.map((t,n)=>n===a?{...t,label:e.target.value}:t)),placeholder:s("page")||"Page"})}),l.jsxs(Ua,{label:s("url"),children:[l.jsx(t.Input,{className:"width-full ee-menu-item-input",value:e.url||"",status:x[a]?"error":"",onChange:t=>{const n=t.target.value;j("list",p.map((e,t)=>t===a?{...e,url:n}:e)),x[a]&&S(n,a,e.label)},onBlur:t=>S(t.target.value,a,e.label),placeholder:s("link_url_placeholder")||"example.com"}),x[a]?l.jsx("div",{className:"ee-field-error",role:"alert",children:x[a]}):null]}),l.jsx(Ua,{label:s("target"),children:l.jsx(t.Select,{className:"width-full ee-menu-item-input",value:e.target||"_self",onChange:e=>j("list",p.map((t,n)=>n===a?{...t,target:e}:t)),getPopupContainer:w,children:L.map(e=>l.jsx(t.Select.Option,{value:e.value,children:e.label},e.value))})})]})]})},a))}),l.jsxs("button",{type:"button",className:"menu-add-new-item margin-top-12",onClick:()=>j("list",p.concat({label:s("page")||"Page",url:"",target:"_self"})),children:[l.jsx("span",{className:"menu-add-new-item-icon",children:"+"})," ",s("add_new_item")]}),l.jsx(Ea,{className:"margin-top-18",children:s("menu_styles")}),l.jsx(Ua,{label:s("font_family"),children:l.jsx(t.Select,{className:"width-full ee-font-family-select",value:T,showSearch:!0,optionFilterProp:"label",labelRender:({value:e})=>l.jsx("span",{children:Et(e,r)}),onChange:e=>m("fontFamily")(Ft(e,r)),getPopupContainer:w,options:A})}),l.jsx(Ua,{label:s("font_size"),children:l.jsx(t.InputNumber,{min:8,max:72,className:"input-width ee-settings-input-affix",addonAfter:"px",value:c(a.data.styles,"fontSize"),onFocus:e=>e?.target?.select?.(),onChange:m("fontSize")})}),l.jsx(Ua,{label:s("letter_spacing"),children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix",addonAfter:"px",value:c(a.data.styles,"letterSpacing"),onFocus:e=>e?.target?.select?.(),onChange:m("letterSpacing")})}),l.jsx(Ua,{label:s("text_color"),children:l.jsx(Ba,{color:c(a.data.styles,"color"),setColor:u("color")})}),l.jsx(Ua,{label:s("link_color"),children:l.jsx(Ba,{color:c(a.data.styles,"linkColor"),setColor:u("linkColor")})}),l.jsx(Ua,{label:s("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:W,onChange:e=>(e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]??{},textAlign:e},d(t)})(e),"aria-label":s("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ua,{label:s("separator"),hint:s("menu_separator_allowed_hint"),children:l.jsx(t.Input,{className:"width-full ee-menu-separator-input",value:Ll(h),onChange:e=>j("separator",Ll(e.target.value)),placeholder:s("menu_separator_placeholder")})}),l.jsx(Ua,{label:s("menu_link_gap")||"Link spacing",children:l.jsx(t.InputNumber,{min:0,max:96,className:"input-width ee-settings-input-affix",addonAfter:"px",value:D,onFocus:e=>e?.target?.select?.(),onChange:e=>(e=>{const t="number"==typeof e&&Number.isFinite(e)&&e>=0?Math.min(96,e):0,n=C(a.data);n.linkGapPx=t,d(n)})("number"==typeof e?e:0)})}),l.jsx(Ua,{layout:"toggle",label:s("menu_underline_links")||"Underline links",children:l.jsx(Ma,{checked:U,onChange:e=>{const t=C(a.data);t.linkUnderline=!!e,d(t)}})}),l.jsx(Ua,{label:s("font_weight")||"Font weight",children:l.jsx(t.Select,{className:"width-full",value:Al(c(a.data.styles,"fontWeight")),onChange:m("fontWeight"),getPopupContainer:w,options:[{value:"300",label:s("font_weight_light")||"Light"},{value:"400",label:s("font_weight_regular")||"Regular"},{value:"600",label:s("font_weight_semibold")||"Semi-bold"},{value:"700",label:s("font_weight_bold")||"Bold"}]})}),l.jsx(Ua,{label:s("text_transform")||"Text transform",children:l.jsx(t.Select,{className:"width-full",value:c(a.data.styles,"textTransform")??"none",onChange:m("textTransform"),getPopupContainer:w,options:[{value:"none",label:"None"},{value:"uppercase",label:"UPPERCASE"},{value:"capitalize",label:"Capitalize"}]})}),l.jsx(Ea,{children:s("border_bottom")||"Border bottom"}),l.jsx(Ua,{layout:"toggle",label:s("show_border_bottom"),children:l.jsx(Ma,{checked:R,onChange:e=>j("borderBottom",e)})}),R?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:s("border_color")||"Color",children:l.jsx(Ba,{color:M,setColor:({hex:e})=>j("borderBottomColor",e)})}),l.jsx(Ua,{label:s("border_width")||"Width",children:l.jsx(t.InputNumber,{min:1,max:8,className:"input-width ee-settings-input-affix",addonAfter:"px",value:P,onFocus:e=>e?.target?.select?.(),onChange:e=>j("borderBottomWidth",e??1)})})]}):null,l.jsx(Ea,{className:"ee-menu-settings-padding-heading",children:s("padding_settings")}),l.jsx(Ua,{children:l.jsx(Pa,{padding:{paddingTop:c(a.data.contentStyles,"paddingTop"),paddingRight:c(a.data.contentStyles,"paddingRight"),paddingLeft:c(a.data.contentStyles,"paddingLeft"),paddingBottom:c(a.data.contentStyles,"paddingBottom")},setPadding:e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]??{},...e},d(t)}})})]})},$l=()=>{const{currentItem:a,previewMode:i,templateData:r,apiConfig:s,bodySettings:c}=e.useContext(ge),{t:d}=So(),{containerBlock:u,containerType:m,contentIndex:p}=hl(),h=u?.columnProducts?.[p]??null,{findStyleItem:b,inputChange:y,updateItemStyles:_}=Qa(),f=e=>{const t=C(a.data);Object.assign(t,e),_(t)},x=e.useRef(null),[k,v]=e.useState(!1),[w,j]=e.useState(""),[S,N]=e.useState(""),I=e.useMemo(()=>({columnIndex:p,columnProduct:h}),[p,h]),A=e.useMemo(()=>Nt(m,r,I),[m,r,I]),{uploadImageFile:T,isConfigured:L}=ll({imageUploadEndpoint:s?.imageUploadEndpoint,headers:s?.headers||{},companyId:s?.companyId,imageUploadQueryParams:s?.imageUploadQueryParams,imageUploadCompanyField:s?.imageUploadCompanyField}),B=e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],...e},_(t)};return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[(()=>{const{linkURL:e}=a.data,n=It(a.data),o=e=>{N((e=>{const t=String(e??"").trim(),n=g(t,!1,{allowMailtoTel:!0});return n?"empty"===n?"Image -> Link URL is empty. Add a destination like 'https://example.com' or disable link action.":"blocked_scheme"===n?`Image -> Link URL ('${t}') uses a blocked protocol. Use https://, http://, mailto:, or tel:.`:"duplicate_protocol"===n?`Image -> Link URL ('${t}') repeats the protocol. Keep only one protocol, e.g. 'https://example.com'.`:"missing_hostname_dot"===n?`Image -> Link URL ('${t}') is missing a valid hostname. Use a full URL like 'https://example.com'.`:"invalid_protocol"===n?`Image -> Link URL ('${t}') has an unsupported protocol. Use https://, http://, mailto:, or tel:.`:`Image -> Link URL ('${t}') is invalid. Fix the URL format, for example 'https://example.com'.`:""})(e))};return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("image_action")}),l.jsx(Ua,{label:d("action_type"),children:l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row",children:[l.jsx("span",{className:fo("link-tag",!n&&"ee-image-link-tag-inactive"),children:d("link")}),l.jsx(Ma,{checked:n,onChange:e=>{const t=C(a);t.data.linkEnabled=Boolean(e),_(t.data)}})]})}),n?l.jsx(Ua,{label:d("link_url"),children:l.jsxs(l.Fragment,{children:[l.jsx(t.Input,{value:e??"",onChange:e=>{const t=e.target.value??"",n=C(a);n.data.linkURL=t,_(n.data),S&&o(t)},onBlur:e=>o(e.target.value),status:S?"error":"",placeholder:d("link_url_placeholder"),className:"width-full"}),S?l.jsx("div",{className:"ee-field-error",role:"alert",children:S}):null]})}):null]})})(),(()=>{const{src:e,alt:i}=a.data,s="string"==typeof e&&/^\{\{\w+\}\}$/.test(e.trim())?String(e).replace(/\{\{|\}\}/g,"").trim():"",c=r&&s?yt(r,s,I):null,u=null==c||String(c).startsWith("{{")?e||"":c,m=e=>{j((e=>{const t=String(e??"").trim();if(/^\{\{\w+\}\}$/.test(t))return"";const n=g(t,!1,{allowMailtoTel:!1});return n?"empty"===n?"Image -> Image URL is empty. Add an image URL like 'https://example.com/image.jpg' or choose a variable.":"blocked_scheme"===n?`Image -> Image URL ('${t}') uses a blocked protocol. Use only http:// or https:// image URLs.`:"duplicate_protocol"===n?`Image -> Image URL ('${t}') repeats the protocol. Keep only one protocol, e.g. 'https://example.com/image.jpg'.`:"missing_hostname_dot"===n?`Image -> Image URL ('${t}') is missing a valid hostname. Use a full URL like 'https://example.com/image.jpg'.`:"invalid_protocol"===n?`Image -> Image URL ('${t}') has an unsupported protocol. Use only http:// or https:// image URLs.`:`Image -> Image URL ('${t}') is invalid. Fix the URL format, for example 'https://example.com/image.jpg'.`:""})(e))},p=e=>t=>{const n=C(a),o=t.target.value;n.data[e]=o,_(n.data),"src"===e&&w&&m(o)},h=e=>{const t=C(a);t.data.src=e,_(t.data)},b=()=>{x.current?.click()};return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("image")}),l.jsx(Ua,{label:d("image_upload"),children:l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:x,type:"file",accept:ol,className:"ee-image-upload-input-hidden",onChange:async e=>{const n=e.target.files?.[0];if(!n)return;const o=al(n);if("type"===o)return t.message.error(d("image_upload_invalid_type")||"Use PNG, JPEG, GIF, SVG, or WebP."),void(e.target.value="");if("size"===o)return t.message.error(d("image_file_too_large")),void(e.target.value="");if(!L)return t.message.error(d("image_upload_not_configured")||"Image upload not configured"),console.warn("[ImageStyleSettings] Image upload endpoint not configured"),void(e.target.value="");v(!0);try{const e=await T(n);e?(h(Zt(e)),t.message.success(d("image_uploaded")||"Image uploaded successfully")):t.message.error(d("image_upload_failed")||"Failed to upload image")}catch(e){console.error("[ImageStyleSettings] Upload error:",e);const n="string"==typeof e?.message&&e.message.trim()?e.message.trim():null;t.message.error(n||d("image_upload_error")||"Error uploading image")}finally{v(!1),e.target.value=""}},disabled:k}),l.jsx(t.Spin,{spinning:k,children:l.jsxs("div",{role:"button",tabIndex:0,className:"ee-image-upload-trigger",onClick:b,onDrop:async e=>{e.preventDefault(),e.stopPropagation();const n=e.dataTransfer?.files?.[0];if(!n)return;const o=al(n);if("type"!==o)if("size"!==o){if(!L)return t.message.error(d("image_upload_not_configured")||"Image upload not configured"),void console.warn("[ImageStyleSettings] Image upload endpoint not configured");v(!0);try{const e=await T(n);e?(h(Zt(e)),t.message.success(d("image_uploaded")||"Image uploaded successfully")):t.message.error(d("image_upload_failed")||"Failed to upload image")}catch(e){console.error("[ImageStyleSettings] Upload error:",e);const n="string"==typeof e?.message&&e.message.trim()?e.message.trim():null;t.message.error(n||d("image_upload_error")||"Error uploading image")}finally{v(!1),x.current.value=""}}else t.message.error(d("image_file_too_large"));else t.message.error(d("image_upload_invalid_type")||"Use PNG, JPEG, GIF, SVG, or WebP.")},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},style:{opacity:k?.6:1,cursor:k?"not-allowed":"pointer"},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCloudUploadAlt,className:"ee-image-upload-icon"}),l.jsx("span",{children:k?d("uploading")||"Uploading...":d("image_upload_click")})]})}),l.jsxs("div",{className:"ee-image-toolbar",children:[l.jsxs("button",{type:"button",className:"ee-image-toolbar-btn",onClick:b,disabled:k,children:[l.jsx(n.FontAwesomeIcon,{icon:o.faSyncAlt}),l.jsx("span",{children:d("replace")||"Replace"})]}),l.jsxs("button",{type:"button",className:"ee-image-toolbar-btn ee-image-toolbar-btn--danger",onClick:()=>f({src:""}),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faTrash}),l.jsx("span",{children:d("delete")||"Delete"})]})]}),l.jsx("div",{className:"ee-image-upload-hint",children:d("image_upload_file_hint")||"PNG, JPEG, GIF, SVG, WebP · max 10 MB"})]})}),A.length>0?l.jsx(Ua,{label:d("image_source_variable"),children:l.jsx(t.Select,{className:"ee-variable-select width-full",placeholder:d("image_source_variable"),allowClear:!0,value:"string"==typeof e&&/^\{\{\w+\}\}$/.test(String(e).trim())?String(e).trim():void 0,onChange:e=>h(e??""),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:A.map(e=>({value:e.value,label:d(e.labelKey)}))})}):null,l.jsx(Ua,{label:d("image_url"),children:l.jsxs(l.Fragment,{children:[l.jsx(t.Input,{className:"width-full",value:u,onChange:p("src"),onBlur:e=>m(e.target.value),status:w?"error":"",placeholder:"https://..."}),w?l.jsx("div",{className:"ee-field-error",role:"alert",children:w}):null]})}),l.jsx(Ua,{label:d("image_alt"),children:l.jsx(t.Input,{className:"width-full",value:i||"",onChange:p("alt"),placeholder:d("image_alt_placeholder")})})]})})(),(()=>{const e=a.data,i=c?.styles?.fontFamily??"sans-serif",s=Boolean(e.textOverlayEnabled),u=e.overlayPosition??"bc",m=Boolean(e.scrimEnabled),p=Boolean(e.textShadowEnabled),g=e.overlayMaxWidth??100,h=e.overlayItemGap??8,b=Array.isArray(e.overlayItems)?e.overlayItems:[],y=[{value:"eyebrow",label:"Eyebrow",defaultSize:11},{value:"h1",label:"H1",defaultSize:32},{value:"h2",label:"H2",defaultSize:24},{value:"h3",label:"H3",defaultSize:18},{value:"subtitle",label:"Subtitle",defaultSize:16},{value:"body",label:"Body",defaultSize:14}],_=(e,t)=>{const n=[...b];n[e]={...n[e],...t},f({overlayItems:n})},x=(e,t)=>{const n=[...b],o="up"===t?e-1:e+1;o<0||o>=n.length||([n[e],n[o]]=[n[o],n[e]],f({overlayItems:n}))},k=(e,t,o,a)=>l.jsx("button",{type:"button",disabled:t,onClick:e,style:{width:22,height:22,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"1px solid rgba(255,255,255,0.12)",borderRadius:3,cursor:t?"not-allowed":"pointer",color:a?"#f87070":"var(--ee-muted-foreground)",opacity:t?.35:1,padding:0,flexShrink:0},children:l.jsx(n.FontAwesomeIcon,{icon:o,style:{fontSize:9}})});return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:l.jsxs("span",{className:"ee-container-bg-heading-inline",children:[d("image_text_overlay"),l.jsx(t.Tooltip,{title:l.jsxs("div",{children:[l.jsx("p",{style:{marginBottom:8},children:d("image_text_overlay_tip")}),l.jsx("p",{style:{margin:0,opacity:.85},children:d("image_text_overlay_container_tip")})]}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:l.jsx("span",{className:"ee-help-icon ee-container-bg-section-help",tabIndex:0,"aria-label":d("image_text_overlay"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]})}),l.jsx(Ua,{layout:"toggle",label:d("image_text_overlay_enable"),children:l.jsx(Ma,{checked:s,onChange:t=>{if(t&&!e.textOverlayEnabled){const e=b.length>0?b:[{kind:"eyebrow",text:"EYEBROW TEXT",color:"#d8fe91",fontSize:11,fontFamily:i},{kind:"h1",text:"Heading Text",color:"#ffffff",fontSize:32,fontFamily:i},{kind:"body",text:"Body copy goes here.",color:"#ffffff",fontSize:14,fontFamily:i}];f({textOverlayEnabled:!0,overlayItems:e})}else f({textOverlayEnabled:t})}})}),s?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:d("add_overlay_item")||"Add element",children:l.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:y.map(e=>l.jsxs("button",{type:"button",onClick:()=>(e=>{const t=y.find(t=>t.value===e)||y[5],n=[...b,{kind:e,text:"",color:"#ffffff",fontSize:t.defaultSize,fontFamily:i}];f({overlayItems:n})})(e.value),style:{padding:"4px 10px",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,color:"var(--ee-foreground)",cursor:"pointer",fontSize:11,fontFamily:"inherit"},children:["+ ",e.label]},e.value))})}),b.length>0&&l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:12},children:b.map((e,n)=>l.jsxs("div",{style:{background:"rgba(255,255,255,0.04)",border:"1px solid var(--ee-border)",borderRadius:6,padding:"10px 12px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:8},children:[k(()=>x(n,"up"),0===n,o.faChevronUp,!1),k(()=>x(n,"down"),n===b.length-1,o.faChevronDown,!1),l.jsx(t.Select,{size:"small",style:{flex:1},value:e.kind||"body",onChange:e=>_(n,{kind:e}),options:y.map(e=>({value:e.value,label:e.label})),getPopupContainer:()=>document.querySelector(".right-settings")||document.body}),k(()=>(e=>{f({overlayItems:b.filter((t,n)=>n!==e)})})(n),!1,o.faTrash,!0)]}),l.jsx(t.Input,{size:"small",value:e.text||"",placeholder:"Text content...",onChange:e=>_(n,{text:e.target.value}),style:{marginBottom:8}}),l.jsxs("div",{style:{marginBottom:8},children:[l.jsx("div",{style:{fontSize:11,color:"var(--ee-muted-foreground)",marginBottom:4},children:d("font_family")}),l.jsx(t.Select,{size:"small",className:"width-full ee-font-family-select",showSearch:!0,optionFilterProp:"label",value:Ft(null!=e.fontFamily&&""!==String(e.fontFamily).trim()?e.fontFamily:i,r),onChange:e=>_(n,{fontFamily:Ft(e,r)}),labelRender:({value:e})=>l.jsx("span",{children:Et(e,r)}),options:Mt(r),getPopupContainer:()=>document.querySelector(".right-settings")||document.body})]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[l.jsx(Ba,{color:e.color||"#ffffff",setColor:({hex:e})=>_(n,{color:e}),fallbackColor:"#ffffff"}),l.jsx(t.InputNumber,{size:"small",min:8,max:96,addonAfter:"px",value:e.fontSize||16,style:{flex:1},onChange:e=>_(n,{fontSize:"number"==typeof e?e:16})})]})]},n))}),l.jsx(Ua,{label:d("item_gap")||"Item gap",children:l.jsx(t.InputNumber,{min:0,max:48,className:"input-width ee-settings-input-affix",addonAfter:"px",value:h,onChange:e=>f({overlayItemGap:"number"==typeof e?e:8})})}),l.jsx(Ua,{label:d("image_overlay_position"),children:l.jsx("div",{className:"ee-image-overlay-position-grid",role:"group","aria-label":d("image_overlay_position"),children:an.map(e=>l.jsx("button",{type:"button",className:fo("ee-image-overlay-position-cell",u===e&&"ee-image-overlay-position-cell-active"),title:d(`image_overlay_pos_${e}`),"aria-pressed":u===e,onClick:()=>f({overlayPosition:e}),children:l.jsx("span",{className:"ee-image-overlay-dot","aria-hidden":!0})},e))})}),l.jsx(Ua,{label:d("overlay_max_width")||"Max width",children:l.jsx(t.InputNumber,{min:20,max:100,className:"input-width ee-settings-input-affix",addonAfter:"%",value:g,onChange:e=>f({overlayMaxWidth:"number"==typeof e?e:100})})}),l.jsx(Ua,{label:d("image_overlay_box_bg"),children:l.jsx(t.Input,{className:"width-full",placeholder:"rgba(0,0,0,0.35)",value:e.overlayBoxBackground??"",onChange:e=>f({overlayBoxBackground:e.target.value})})}),l.jsx(Ua,{label:d("image_overlay_padding"),children:l.jsx(t.InputNumber,{min:0,max:120,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof e.overlayPadding?e.overlayPadding:16,onChange:e=>f({overlayPadding:"number"==typeof e?e:16})})}),l.jsx(Ua,{layout:"toggle",label:d("scrim")||"Scrim",children:l.jsx(Ma,{checked:m,onChange:e=>f({scrimEnabled:e})})}),l.jsx(Ua,{layout:"toggle",label:d("text_shadow")||"Text shadow",children:l.jsx(Ma,{checked:p,onChange:e=>f({textShadowEnabled:e})})})]}):null]})})(),(()=>{const e=b(a.data.styles,"width"),r=b(a.data.styles,"height"),s=b(a.data.styles,"borderRadius"),c="number"==typeof s?s:parseInt(String(s||"").replace("px",""),10)||0,u=b(a.data.contentStyles,"textAlign"),m=Boolean(a.data.fillColumn);return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("layout")}),l.jsx(Ua,{layout:"toggle",label:d("fill_column")||"Fill column",children:l.jsx(Ma,{checked:m,onChange:e=>f({fillColumn:e})})}),l.jsx(Ua,{layout:"toggle",label:d("auto_width"),children:l.jsx(Ma,{checked:"auto"===e,onChange:()=>{const t="auto"===e?"100%":"auto";y("width")(t)}})}),"auto"!==e?l.jsx(Ua,{label:d("width"),children:l.jsx(t.Slider,{value:Number(String(e).replace("%","")),onChange:e=>y("width")(e+"%")})}):null,l.jsx(Ua,{label:d("height")||"Height",children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",placeholder:"auto",value:r&&parseInt(String(r).replace("px",""),10)||void 0,onChange:e=>y("height")(e?`${e}px`:"auto")})}),l.jsx(Ua,{label:d("border_radius"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:c,onFocus:e=>e?.target?.select?.(),onChange:e=>y("borderRadius")(Number(e)||0)})}),l.jsx(Ua,{label:d("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:u||"center",onChange:e=>(e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]||(t.contentStyles[i]={}),t.contentStyles[i]={...t.contentStyles[i],textAlign:e},"desktop"!==i&&(t.contentStyles.desktop||(t.contentStyles.desktop={}),t.contentStyles.desktop={...t.contentStyles.desktop,textAlign:e}),_(t)})(e),"aria-label":d("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ea,{children:d("spacing")}),l.jsx(Ua,{label:d("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:b(a.data.contentStyles,"paddingTop"),paddingRight:b(a.data.contentStyles,"paddingRight"),paddingLeft:b(a.data.contentStyles,"paddingLeft"),paddingBottom:b(a.data.contentStyles,"paddingBottom")},setPadding:B})})]})})()]})},Rl=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,updateItemStyles:c}=Qa(),d=e=>{const t=C(a.data);e(t),c(t)},u=e=>{const t=a.data.videoArea||{},n="desktop"===i?{}:t.desktop||{};return t[i]?.[e]??n[e]},m=e=>d(t=>{t.videoArea||(t.videoArea={desktop:{},mobile:{}}),t.videoArea[i]={...t.videoArea[i]||{},...e}}),p=s(a.data.contentStyles,"textAlign"),g=["left","center","right"].includes(p)?p:"center",h=l.jsxs("span",{className:"ee-container-bg-heading-inline",children:[r("video_url"),l.jsx(t.Tooltip,{title:r("video_export_note"),children:l.jsx("span",{className:"ee-help-icon ee-container-bg-section-help",tabIndex:0,"aria-label":r("video_export_note"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]});return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx(Ea,{children:r("video_tab_display")}),l.jsx(Ua,{label:h,children:l.jsx(t.Input,{className:"width-full",value:a.data.videoUrl??"",onChange:e=>d(t=>{t.videoUrl=e.target.value}),placeholder:"https://www.youtube.com/watch?v=..."})}),l.jsx(Ua,{label:r("video_thumbnail_url"),children:l.jsx(t.Input,{className:"width-full",value:a.data.thumbnailUrl??"",onChange:e=>d(t=>{t.thumbnailUrl=e.target.value}),placeholder:r("video_thumbnail_url_placeholder")})}),l.jsx(Ea,{children:r("video_thumbnail_layout")}),l.jsx(Ua,{label:r("video_width"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix ee-video-dim-field width-full",placeholder:"auto",addonAfter:"px",value:"number"==typeof s(a.data.styles,"width")?s(a.data.styles,"width"):void 0,onChange:e=>d(t=>{t.styles=t.styles||{desktop:{},mobile:{}},t.styles[i]={...t.styles[i]||{},width:null==e||""===e?"auto":e}})})}),l.jsx(Ua,{label:r("video_height"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix ee-video-dim-field width-full",placeholder:"auto",addonAfter:"px",value:"number"==typeof s(a.data.styles,"height")?s(a.data.styles,"height"):void 0,onChange:e=>d(t=>{t.styles=t.styles||{desktop:{},mobile:{}},t.styles[i]={...t.styles[i]||{},height:null==e||""===e?"auto":e}})})}),l.jsx(Ua,{label:r("alignment"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:g,onChange:e=>d(t=>{t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]||{},textAlign:e}}),"aria-label":r("alignment"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ua,{layout:"toggle",label:r("video_fill_column"),children:l.jsx(Ma,{checked:Boolean(s(a.data.styles,"fillColumn")),onChange:e=>d(t=>{t.styles=t.styles||{desktop:{},mobile:{}},t.styles[i]={...t.styles[i]||{},fillColumn:e}})})}),l.jsx(Ua,{layout:"toggle",label:r("video_fill_column_mobile"),children:l.jsx(Ma,{checked:Boolean(s(a.data.styles,"fillColumnMobile")),onChange:e=>d(t=>{t.styles=t.styles||{desktop:{},mobile:{}},t.styles[i]={...t.styles[i]||{},fillColumnMobile:e}})})}),l.jsx(Ea,{children:r("video_area_section")}),l.jsx(Ua,{label:r("label_padding"),children:l.jsx(Pa,{setPadding:e=>d(t=>{t.videoArea||(t.videoArea={desktop:{},mobile:{}}),t.videoArea[i]={...t.videoArea[i]||{},...e}}),padding:{paddingTop:u("paddingTop")??0,paddingBottom:u("paddingBottom")??0,paddingLeft:u("paddingLeft")??0,paddingRight:u("paddingRight")??0}})}),l.jsx(Ua,{label:r("background_color"),children:l.jsx(Ba,{color:"string"==typeof u("backgroundColor")&&u("backgroundColor").replace(/^#/,"")||"transparent",setColor:({hex:e})=>m({backgroundColor:e})})}),l.jsx(Ua,{label:r("divider_type"),children:l.jsxs(t.Select,{className:"width-full",value:u("borderStyle")||"solid",onChange:e=>m({borderStyle:e}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:[l.jsx(t.Select.Option,{value:"none",children:r("video_border_none")}),l.jsx(t.Select.Option,{value:"solid",children:r("solid")}),l.jsx(t.Select.Option,{value:"dashed",children:r("dashed")})]})}),l.jsx(Ua,{label:r("border_width"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:u("borderWidth")??0,onFocus:e=>e?.target?.select?.(),onChange:e=>m({borderWidth:null==e?0:e})})}),l.jsx(Ua,{label:r("border_color"),children:l.jsx(Ba,{color:(u("borderColor")||"#cccccc").replace(/^#/,""),setColor:({hex:e})=>m({borderColor:e})})}),l.jsx(Ea,{children:r("video_block_section")}),l.jsx(Ua,{label:r("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop")??0,paddingBottom:s(a.data.contentStyles,"paddingBottom")??0,paddingLeft:s(a.data.contentStyles,"paddingLeft")??0,paddingRight:s(a.data.contentStyles,"paddingRight")??0},setPadding:e=>d(t=>{t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]||{},...e}})})}),l.jsx(Ua,{label:r("background_color"),children:l.jsx(Ba,{color:(s(a.data.contentStyles,"backgroundColor")||"").replace(/^#/,"")||"transparent",setColor:({hex:e})=>d(t=>{t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]||{},backgroundColor:e}})})})]})},Ml=()=>{const{currentItem:n}=e.useContext(ge),{t:o}=So(),{findStyleItem:a,cardItemElement:i,updateItemStyles:r}=Qa(),{src:s,alt:c,linkURL:d}=n.data,u=a(n.data.styles,"width")??64,m=a(n.data.styles,"borderRadius"),p="50%"===m?50:parseInt(String(m).replace("px",""),10)||0;return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx("div",{className:"right-setting-block-item-title",children:o("avatar_image")}),i(o("image_url"),l.jsx(t.Input,{value:s,onChange:e=>{const t=C(n.data);t.src=e.target.value??"",r(t)}})),i(o("image_alt"),l.jsx(t.Input,{value:c,onChange:e=>{const t=C(n.data);t.alt=e.target.value??"",r(t)},placeholder:"Avatar"})),i(o("link_url"),l.jsx(t.Input,{value:d,onChange:e=>{const t=C(n.data);t.linkURL=e.target.value??"",r(t)},placeholder:o("link_url_placeholder")})),l.jsx("div",{className:"right-setting-block-item-title margin-top-18",children:o("image_styles")}),i(o("width"),l.jsx(t.InputNumber,{min:16,max:256,value:"number"==typeof u?u:64,onChange:e=>{const t=C(n.data);t.styles.desktop||(t.styles.desktop={}),t.styles.desktop.width=e,r(t)},addonAfter:"px"})),i(o("avatar_border_radius"),l.jsx(t.InputNumber,{min:0,max:50,value:p,onChange:e=>{const t=C(n.data);t.styles.desktop||(t.styles.desktop={}),t.styles.desktop.borderRadius=50===e?"50%":`${e}px`,r(t)},addonAfter:50===p?"%":"px"})),l.jsx("div",{className:"right-setting-block-item-title margin-top-18",children:o("padding_settings")}),l.jsx(Pa,{padding:{paddingTop:a(n.data.contentStyles,"paddingTop"),paddingRight:a(n.data.contentStyles,"paddingRight"),paddingLeft:a(n.data.contentStyles,"paddingLeft"),paddingBottom:a(n.data.contentStyles,"paddingBottom")},setPadding:e=>{const t=C(n.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles.desktop={...t.contentStyles.desktop,...e},r(t)}})]})},Pl="https://s.magecdn.com/social";function Fl(e,t){const n=String(e?.image||"").trim(),o=String(t?.image||"").trim();if(n&&o&&n===o)return!0;const a=String(e?.title||"").trim().toLowerCase(),l=String(t?.title||"").trim().toLowerCase();return Boolean(a&&l&&a===l)}const El={facebook:"social_link_placeholder_facebook",linkedin:"social_link_placeholder_linkedin",instagram:"social_link_placeholder_instagram",tiktok:"social_link_placeholder_tiktok",youtube:"social_link_placeholder_youtube",pinterest:"social_link_placeholder_pinterest"};function Dl(e,t){if(zt(e))return t("social_link_placeholder_x");const n=String(e?.title||"").trim().toLowerCase(),o=El[n];return t(o||"social_link_placeholder_generic")}const Ul=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,updateItemStyles:c}=Qa(),d=a.data.list??[],[u,m]=e.useState(!1),[p,h]=e.useState(null),[b,y]=e.useState({}),_=e.useRef(null),f=[{image:`${Pl}/tc-facebook.svg`,title:"Facebook",linkURL:""},{image:`${Pl}/tc-linkedin.svg`,title:"LinkedIn",linkURL:""},{image:`${Pl}/tc-instagram.svg`,title:"Instagram",linkURL:""},{image:`${Pl}/tc-tiktok.svg`,title:"TikTok",linkURL:""},{image:`${Pl}/tc-x.svg`,title:"X",linkURL:""},{image:`${Pl}/tc-youtube.svg`,title:"YouTube",linkURL:""},{image:`${Pl}/tc-pinterest.svg`,title:"Pinterest",linkURL:""}],x=(e,t)=>{const n=C(a),o=function(e){if(!Array.isArray(e))return e;const t=[];for(const n of e)t.some(e=>Fl(e,n))||t.push(n);return t}(t);n.data={...n.data,[e]:o},n.data.useCompanySocialLinks=!1,c(n.data)},k=(e,t,n)=>{const o=((e,t,n)=>{const o=String(e??"").trim(),a=`Social links -> ${n||`Item ${t+1}`} URL`,l=g(o,!1,{allowMailtoTel:!1});return l?"empty"===l?`${a} is empty. Add a profile URL like 'https://example.com'.`:"blocked_scheme"===l?`${a} ('${o}') uses a blocked protocol. Use only http:// or https:// URLs.`:"duplicate_protocol"===l?`${a} ('${o}') repeats the protocol. Keep one protocol, e.g. 'https://example.com'.`:"missing_hostname_dot"===l?`${a} ('${o}') is missing a valid hostname. Use a full domain like 'https://example.com'.`:"invalid_protocol"===l?`${a} ('${o}') has an unsupported protocol. Use only http:// or https:// URLs.`:`${a} ('${o}') is invalid. Fix it to a valid URL like 'https://example.com'.`:""})(e,t,n);y(e=>{if(!o&&!e[t])return e;const n={...e};return o?n[t]=o:delete n[t],n})},v=e.useCallback(N(e=>{e.preventDefault();const t=_.current,n=e.target?.closest?.(".social-link-item[data-index]");if(!n||!t?.contains(n))return;const o=Array.from(t.querySelectorAll(".social-link-item[data-index]")).indexOf(n);if(-1===o)return;const a=p,l=C(d);a!==o&&([l[o],l[a]]=[l[a],l[o]],h(o),x("list",l))},50),[p]),w=()=>document.querySelector(".right-settings")||document.body,j=s(a.data.contentStyles,"textAlign"),S=["left","center","right","justify"].includes(j)?j:"left",I=s(a.data.contentStyles,"columnGapPx"),A="number"==typeof I&&Number.isFinite(I)&&I>=0?I:8,T=function(e){if(e?.iconSize&&null!=Vt[e.iconSize])return e.iconSize;const t=Number(e?.imageWidth);if(!Number.isFinite(t)||t<=0)return"medium";let n="medium",o=1/0;for(const[e,a]of Object.entries(Vt)){const l=Math.abs(t-a);l<o&&(o=l,n=e)}return n}(a.data),L=Wt(a.data.iconColor??"default"),B=Boolean(a.data.showTextLabel),$=f.filter(e=>!d.some(t=>Fl(t,e)));return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx(Ea,{children:r("icon_styles")}),l.jsx(Ua,{label:r("icon_size"),children:l.jsx(t.Select,{className:"width-full",value:T,onChange:e=>{const t=C(a.data);t.iconSize=e,t.imageWidth=Vt[e]??32,t.iconSizePx=null,c(t)},getPopupContainer:w,options:[{value:"small",label:r("icon_size_small")},{value:"medium",label:r("icon_size_medium")},{value:"large",label:r("icon_size_large")}]})}),l.jsx(Ua,{label:r("icon_color"),children:l.jsx(t.Select,{className:"width-full",value:L,onChange:e=>{const t=Wt(e),n=C(a.data);n.iconColor=t,n.iconColorHex=null,c(n)},getPopupContainer:w,options:[{value:"default",label:r("icon_color_default")},{value:"white",label:r("icon_color_white")},{value:"black",label:r("icon_color_black")},{value:"gray",label:r("icon_color_gray")}]})}),l.jsx(Ua,{layout:"toggle",label:r("show_text_label")||"Show label",children:l.jsx(Ma,{checked:B,onChange:e=>{const t=C(a.data);t.showTextLabel=e,c(t)}})}),l.jsx(Ua,{label:r("social_icon_spacing"),children:l.jsx(t.InputNumber,{min:0,max:96,className:"input-width ee-settings-input-affix",addonAfter:"px",value:A,onFocus:e=>e?.target?.select?.(),onChange:e=>(e=>{const t="number"==typeof e&&Number.isFinite(e)&&e>=0?Math.min(96,e):8,n=C(a.data);n.contentStyles||(n.contentStyles={desktop:{},mobile:{}}),n.contentStyles[i]={...n.contentStyles[i]||{},columnGapPx:t},c(n)})(e)})}),l.jsx(Ua,{label:r("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:S,onChange:e=>(e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],textAlign:e},c(t)})(e),"aria-label":r("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ea,{children:r("social_links")}),l.jsx("div",{ref:_,onDragOver:v,className:"margin-top-12",children:d.map((e,a)=>{const{image:i,title:s,linkURL:c}=e,g=zt(e),y=g?r("social_platform_x"):s,_=g?r("social_platform_x_alt"):s;return l.jsx("div",{"data-index":a,draggable:!0,onDragStart:()=>{m(!0),h(a)},onDragEnd:e=>{e.currentTarget?.classList?.remove("social-link-item-current"),m(!1),h(null)},className:fo("social-link-item","cursor-grab",u&&"social-link-item-drag_start",p===a?"social-link-item-current":"border-transparent"),children:l.jsxs("div",{className:"social-link-item-content",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("img",{src:i,alt:_,className:"social-link-item-img"}),l.jsxs("div",{className:"social-link-platform-title-wrap",children:[l.jsx("div",{className:"font-semibold",children:y}),g?l.jsx("div",{className:"social-link-platform-former-name",children:r("social_platform_formerly_twitter")}):null]})]}),l.jsxs("div",{className:"flex items-center ee-social-link-item-actions",children:[l.jsx("span",{className:"social-link-item-drag-handle","aria-hidden":!0,children:l.jsx(n.FontAwesomeIcon,{icon:o.faGripVertical,className:"social-link-item-drag-handle-icon"})}),l.jsx("div",{className:"social-link-item-icon social-link-item-icon-slate",role:"button",tabIndex:0,onClick:()=>{x("list",d.filter((e,t)=>t!==a))},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),x("list",d.filter((e,t)=>t!==a)))},children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash,className:"social-link-item-icon-svg social-link-item-icon-svg-deep"})})]})]}),l.jsxs("div",{className:"margin-top-12 relative",children:[l.jsx(t.Input,{className:"width-full",placeholder:Dl(e,r),value:c||"",status:b[a]?"error":"",onChange:e=>{const t=e.target.value;x("list",d.map((e,n)=>n===a?{...e,linkURL:t}:e)),b[a]&&k(t,a,y)},onBlur:e=>k(e.target.value,a,y)}),b[a]?l.jsx("div",{className:"ee-field-error",role:"alert",children:b[a]}):null]})]})},a)})}),$.length>0?l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:r("add_social_link")}),l.jsx("div",{className:"social-link-add margin-top-12",children:$.map(e=>{const{image:t,title:n}=e,o=zt(e)?r("social_platform_x_alt"):n,a=()=>x("list",d.concat(e));return l.jsx("img",{src:t,alt:o,className:"social-link-add-img",role:"button",tabIndex:0,onClick:a,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),a())}},t)})})]}):null,l.jsx(Ea,{className:"ee-social-settings-padding-heading",children:r("padding_settings")}),l.jsx(Ua,{children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop"),paddingRight:s(a.data.contentStyles,"paddingRight"),paddingLeft:s(a.data.contentStyles,"paddingLeft"),paddingBottom:s(a.data.contentStyles,"paddingBottom")},setPadding:e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],...e},c(t)}})})]})},{TextArea:zl}=t.Input;const Ol=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,updateItemStyles:c}=Qa(),d=e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]??{},...e},c(t)},u=s(a.data.contentStyles,"textAlign"),m=["left","center","right","justify"].includes(u)?u:"center",p=function(e){if(null==e||""===e)return 100;if("number"==typeof e)return Math.min(100,Math.max(10,Math.round(e)));const t=String(e).trim().match(/^(\d+(?:\.\d+)?)%$/);return t?Math.min(100,Math.max(10,Math.round(Number(t[1])))):100}(s(a.data.contentStyles,"width")),g=s(a.data.contentStyles,"backgroundColor"),h=function(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e))return Math.min(48,Math.max(0,Math.round(e)));const t=String(e).trim().replace(/px$/i,""),n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(48,Math.max(0,Math.round(n))):0}(s(a.data.contentStyles,"borderRadius"));return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form ee-raw-html-settings",children:[l.jsx(Ea,{className:"ee-raw-html-heading-row",children:l.jsxs("span",{className:"ee-raw-html-title-left",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCode,className:"ee-raw-html-title-icon","aria-hidden":!0}),l.jsx("span",{children:r("raw_html_block")}),l.jsx(t.Tooltip,{title:r("raw_html_code_hint"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:l.jsx("span",{className:"ee-help-icon ee-raw-html-title-help",tabIndex:0,"aria-label":r("raw_html_info_tooltip_aria"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]})}),l.jsx(Ua,{label:r("raw_html_code_label"),children:l.jsx(zl,{className:"ee-raw-html-code-textarea",value:a.data.html??"",onChange:e=>(e=>{const t=C(a.data);t.html=e,c(t)})(e.target.value),autoSize:{minRows:10,maxRows:28},spellCheck:!1})}),l.jsx(Ea,{children:r("raw_html_appearance")}),l.jsx(Ua,{label:r("width"),children:l.jsx(t.Slider,{min:10,max:100,value:p,tooltip:{formatter:e=>`${e}%`},onChange:e=>{d({width:`${e}%`})}})}),l.jsx(Ua,{label:r("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:m,onChange:e=>(e=>{d({textAlign:e})})(e),"aria-label":r("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ua,{label:r("border_radius"),children:l.jsx(t.InputNumber,{min:0,max:48,className:"input-width ee-settings-input-affix",addonAfter:"px",value:h,onFocus:e=>e?.target?.select?.(),onChange:e=>(e=>{const t="number"==typeof e&&Number.isFinite(e)?Math.min(48,Math.max(0,Math.round(e))):0;if(0===t){const e=C(a.data);e.contentStyles||(e.contentStyles={desktop:{},mobile:{}});const t={...e.contentStyles[i]??{}};return delete t.borderRadius,e.contentStyles[i]=t,void c(e)}d({borderRadius:t})})("number"==typeof e?e:0)})}),l.jsx(Ua,{label:r("background_color"),children:l.jsxs("div",{className:"ee-raw-html-bg-row",children:[l.jsx(Ba,{color:g,setColor:({hex:e})=>{d({backgroundColor:e})},fallbackColor:"#ffffff"}),null!=g&&""!==String(g).trim()&&"transparent"!==String(g).toLowerCase()?l.jsx(t.Button,{type:"link",size:"small",onClick:()=>{const e=C(a.data),t=e.contentStyles[i]||{},{backgroundColor:n,...o}=t;e.contentStyles[i]=o,c(e)},children:r("raw_html_clear_background")}):null]})}),l.jsx(Ea,{className:"ee-raw-html-settings-padding-heading",children:r("padding_settings")}),l.jsx(Ua,{children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop"),paddingRight:s(a.data.contentStyles,"paddingRight"),paddingLeft:s(a.data.contentStyles,"paddingLeft"),paddingBottom:s(a.data.contentStyles,"paddingBottom")},setPadding:e=>{d(e)}})}),l.jsxs("div",{className:"ee-raw-html-email-warning",role:"note",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faExclamationTriangle,className:"ee-raw-html-email-warning-icon","aria-hidden":!0}),l.jsx("span",{children:r("raw_html_email_client_warning")})]})]})},Wl=[{value:"none",label:"None"},{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"}],Hl=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,updateItemStyles:c}=Qa(),d=()=>document.querySelector(".right-settings")||document.body,u=e=>{const t=C(a.data);Object.assign(t,e),c(t)},m=e=>{const t=C(a.data);t.styles||(t.styles={desktop:{},mobile:{}}),t.styles.desktop||(t.styles.desktop={}),Object.assign(t.styles.desktop,e),"desktop"!==i&&(t.styles.mobile||(t.styles.mobile={}),Object.assign(t.styles.mobile,e)),c(t)},p=a.data.rows??3,g=a.data.cols??3,h=Boolean(a.data.headerRow),b=Boolean(a.data.headerCol),y=a.data.selectedCell??null,_=a.data.structureMode??"static",f=s(a.data.styles,"fontSize")??14,x=s(a.data.styles,"color")??"#333333",k=s(a.data.styles,"borderColor")??"#e0e0e0",v=s(a.data.styles,"borderStyle")??"solid",w=s(a.data.styles,"borderWidth")??1,j=s(a.data.styles,"cellPadding")??8,S=s(a.data.styles,"textAlign")??"left",N=s(a.data.styles,"headerBg")??"#f5f5f5",I=s(a.data.styles,"headerColor")??"#333333",A=Boolean(a.data.stripedRows),T=s(a.data.styles,"stripedBg")??"#fafafa",L="number"==typeof g?g:3,B="number"==typeof p?p:3,$=e.useMemo(()=>y&&a.data.cells?a.data.cells[y]??null:null,[y,a.data.cells]),R="image"===$?.type?"image":"text",M=e=>{if(!y)return;const t={...a.data.cells||{}};t[y]={...t[y]||{},...e},u({cells:t})},P=Math.min(B,8),F=Math.min(L,8),E=e.useMemo(()=>{if("string"!=typeof y)return null;const e=y.match(/^(\d+)-(\d+)$/);return e?{row:Number(e[1])+1,col:Number(e[2])+1}:null},[y]),D=e.useMemo(()=>[{value:"left",label:r("table_align_left")},{value:"center",label:r("table_align_center")},{value:"right",label:r("table_align_right")}],[r]);return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form ee-table-settings",children:[l.jsx(Ea,{children:r("table_structure")}),l.jsx(Ua,{label:r("table_structure_mode"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:_,onChange:e=>u({structureMode:e}),"aria-label":r("table_structure_mode"),items:[{value:"static",label:r("table_mode_static")},{value:"dynamic",label:r("table_mode_dynamic")}]})}),"dynamic"===_?l.jsx("div",{className:"ee-table-dynamic-hint",role:"note",children:r("table_dynamic_structure_hint")}):null,l.jsx(Ua,{label:r("rows"),children:l.jsx(t.InputNumber,{min:1,max:20,className:"width-full ee-settings-input-affix ee-table-dimension-input",value:B,onFocus:e=>e?.target?.select?.(),onChange:e=>{const t="number"==typeof e&&Number.isFinite(e)?Math.round(e):null;null!=t&&u({rows:Math.min(20,Math.max(1,t))})}})}),l.jsx(Ua,{label:r("columns"),children:l.jsx(t.InputNumber,{min:1,max:12,className:"width-full ee-settings-input-affix ee-table-dimension-input",value:L,onFocus:e=>e?.target?.select?.(),onChange:e=>{const t="number"==typeof e&&Number.isFinite(e)?Math.round(e):null;null!=t&&u({cols:Math.min(12,Math.max(1,t))})}})}),l.jsxs("div",{className:"ee-table-add-actions",children:[l.jsxs("button",{type:"button",className:"ee-table-add-btn menu-add-new-item",onClick:()=>u({rows:Math.min(20,B+1)}),disabled:B>=20,children:[l.jsx("span",{className:"menu-add-new-item-icon",children:"+"})," ",r("table_add_row")]}),l.jsxs("button",{type:"button",className:"ee-table-add-btn menu-add-new-item",onClick:()=>u({cols:Math.min(12,L+1)}),disabled:L>=12,children:[l.jsx("span",{className:"menu-add-new-item-icon",children:"+"})," ",r("table_add_column")]})]}),l.jsx(Ua,{layout:"toggle",label:r("header_row"),children:l.jsx(Ma,{checked:h,onChange:e=>u({headerRow:e})})}),l.jsx(Ua,{layout:"toggle",label:r("header_column"),children:l.jsx(Ma,{checked:b,onChange:e=>u({headerCol:e})})}),l.jsx(Ea,{className:"margin-top-12",children:r("cell_selector")}),l.jsxs("div",{className:"ee-table-cell-picker-wrap",children:[l.jsx("div",{className:"ee-table-cell-picker-grid",style:{gridTemplateColumns:`repeat(${F}, minmax(0, 1fr))`},children:Array.from({length:P*F}).map((e,t)=>{const n=Math.floor(t/F),o=t%F,i=`${n}-${o}`,r=y===i,s=h&&0===n||b&&0===o;return l.jsxs("button",{type:"button",className:`ee-table-cell-picker-btn${r?" ee-table-cell-picker-btn--selected":""}${s?" ee-table-cell-picker-btn--header":""}`,onClick:()=>{if(r)return void u({selectedCell:null});const e={...a.data.cells||{}};e[i]||(e[i]={type:"text",text:""}),u({selectedCell:i,cells:e})},children:[n+1,",",o+1]},i)})}),B>P||L>F?l.jsx("div",{className:"ee-table-cell-picker-caption",children:r("table_cell_grid_truncated",{rows:P,cols:F})}):null,y&&E?l.jsx("div",{className:"ee-table-selected-label",children:r("table_selected_cell",{row:E.row,col:E.col})}):l.jsx("div",{className:"ee-table-selected-label ee-table-selected-label--muted",children:r("table_select_cell_hint")})]}),y?l.jsxs(l.Fragment,{children:[l.jsx(Ea,{className:"margin-top-12",children:r("cell_content")}),l.jsx(Ua,{label:r("cell_content_type"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:R,onChange:e=>{M("image"===e?{type:"image",src:"",alt:""}:{type:"text",text:$?.text??""})},"aria-label":r("cell_content_type"),items:[{value:"text",icon:l.jsx(n.FontAwesomeIcon,{icon:o.faFont,className:"tag-style-size"}),label:r("text")},{value:"image",icon:l.jsx(n.FontAwesomeIcon,{icon:o.faImage,className:"tag-style-size"}),label:r("image")}]})}),"text"===R?l.jsx(Ua,{label:r("content"),children:l.jsx(t.Input.TextArea,{className:"ee-table-cell-textarea",rows:4,value:$?.text??"",placeholder:r("table_cell_text_placeholder"),onChange:e=>M({text:e.target.value})})}):l.jsx(Ua,{label:r("image"),children:l.jsx(t.Input,{className:"width-full",value:$?.src??"",placeholder:"https://...",onChange:e=>M({src:e.target.value})})})]}):null,l.jsx(Ea,{className:"margin-top-12",children:r("table_style")}),l.jsx(Ua,{label:r("font_size"),children:l.jsx(t.InputNumber,{min:8,max:48,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof f?f:parseInt(String(f||"14"),10),onFocus:e=>e?.target?.select?.(),onChange:e=>m({fontSize:e??14})})}),l.jsx(Ua,{label:r("text_color"),children:l.jsx(Ba,{color:x,setColor:({hex:e})=>m({color:e})})}),l.jsx(Ua,{label:r("text_align"),children:l.jsx(t.Select,{className:"width-full",value:S,onChange:e=>m({textAlign:e}),getPopupContainer:d,options:D})}),l.jsx(Ua,{label:r("cell_padding"),children:l.jsx(t.InputNumber,{min:0,max:40,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof j?j:parseInt(String(j||"8"),10),onFocus:e=>e?.target?.select?.(),onChange:e=>m({cellPadding:e??8})})}),l.jsx(Ea,{className:"margin-top-12",children:r("border")}),l.jsx(Ua,{label:r("border_style"),children:l.jsx(t.Select,{className:"width-full",value:v,onChange:e=>m({borderStyle:e}),getPopupContainer:d,options:Wl})}),"none"!==v?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:r("border_width"),children:l.jsx(t.InputNumber,{min:0,max:10,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof w?w:parseInt(String(w||"1"),10),onFocus:e=>e?.target?.select?.(),onChange:e=>m({borderWidth:e??1})})}),l.jsx(Ua,{label:r("border_color"),children:l.jsx(Ba,{color:k,setColor:({hex:e})=>m({borderColor:e})})})]}):null,l.jsx(Ea,{className:"margin-top-12",children:r("header_style")}),l.jsx(Ua,{label:r("header_background"),children:l.jsx(Ba,{color:N,setColor:({hex:e})=>m({headerBg:e})})}),l.jsx(Ua,{label:r("header_text_color"),children:l.jsx(Ba,{color:I,setColor:({hex:e})=>m({headerColor:e})})}),l.jsx(Ua,{layout:"toggle",label:r("striped_rows"),children:l.jsx(Ma,{checked:A,onChange:e=>u({stripedRows:e})})}),A?l.jsx(Ua,{label:r("stripe_color"),children:l.jsx(Ba,{color:T,setColor:({hex:e})=>m({stripedBg:e})})}):null,l.jsx(Ea,{className:"ee-table-settings-padding-heading",children:r("padding_settings")}),l.jsx(Ua,{children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop"),paddingRight:s(a.data.contentStyles,"paddingRight"),paddingLeft:s(a.data.contentStyles,"paddingLeft"),paddingBottom:s(a.data.contentStyles,"paddingBottom")},setPadding:e=>(e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]??{},...e},c(t)})(e)})})]})},Vl=[{value:10,label:"10px"},{value:11,label:"11px"},{value:12,label:"12px"},{value:13,label:"13px"},{value:14,label:"14px"},{value:16,label:"16px"}],Kl=[{value:"left",label:"Left"},{value:"center",label:"Center"},{value:"right",label:"Right"}],Gl=()=>{const{currentItem:n,setCurrentItem:o}=e.useContext(ge),{t:a}=So(),{cardItemElement:i,findStyleItem:r}=Qa(),s=e=>{const t=C(n.data);Object.assign(t,e),o({...n,data:t})},c=e=>{const t=C(n.data);t.styles||(t.styles={desktop:{},mobile:{}}),t.styles.desktop||(t.styles.desktop={}),Object.assign(t.styles.desktop,e),o({...n,data:t})},d=Boolean(n.data.showBrand??!0),u=Boolean(n.data.showAddress??!0),m=Boolean(n.data.showUnsubscribe??!0),p=Boolean(n.data.showSocial??!1),g=Boolean(n.data.showSecondaryLinks??!1),h=Boolean(n.data.showCopyright??!0),b=n.data.brandName??"",y=n.data.brandTagline??"",_=n.data.address??"",f=n.data.unsubscribeText??"Unsubscribe",x=n.data.unsubscribeUrl??"",k=n.data.copyrightText??"",v=r(n.data.styles,"color")??"#9ca3af",w=r(n.data.styles,"backgroundColor")??"transparent",j=r(n.data.styles,"fontSize")??12,S=r(n.data.styles,"textAlign")??"center",N=r(n.data.styles,"paddingTop")??16,I=r(n.data.styles,"paddingBottom")??16,A=Boolean(n.data.showDivider??!1),T=n.data.dividerColor??"#374151";return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx("div",{className:"right-setting-block-item-title",children:a("footer_sections")||"Footer Sections"}),i(a("show_brand")||"Brand",l.jsx(Ma,{checked:d,onChange:e=>s({showBrand:e})})),d&&l.jsxs(l.Fragment,{children:[i(a("brand_name")||"Brand name",l.jsx(t.Input,{className:"width-full",value:b,placeholder:"Your brand",onChange:e=>s({brandName:e.target.value})})),i(a("brand_tagline")||"Tagline",l.jsx(t.Input,{className:"width-full",value:y,placeholder:"Your tagline",onChange:e=>s({brandTagline:e.target.value})}))]}),i(a("show_address")||"Address",l.jsx(Ma,{checked:u,onChange:e=>s({showAddress:e})})),u&&i(a("address")||"Address text",l.jsx(t.Input.TextArea,{className:"width-full",value:_,rows:2,placeholder:"123 Main St, City, Country",onChange:e=>s({address:e.target.value})})),i(a("show_unsubscribe")||"Unsubscribe link",l.jsx(Ma,{checked:m,onChange:e=>s({showUnsubscribe:e})})),m&&l.jsxs(l.Fragment,{children:[i(a("unsubscribe_text")||"Link text",l.jsx(t.Input,{className:"width-full",value:f,onChange:e=>s({unsubscribeText:e.target.value})})),i(a("unsubscribe_url")||"Unsubscribe URL",l.jsx(t.Input,{className:"width-full",value:x,placeholder:"{{unsubscribe_url}}",onChange:e=>s({unsubscribeUrl:e.target.value})}))]}),i(a("show_social")||"Social icons",l.jsx(Ma,{checked:p,onChange:e=>s({showSocial:e})})),p&&l.jsx("div",{style:{fontSize:12,color:"var(--ee-muted-foreground)",padding:"4px 0 8px"},children:a("social_icons_hint")||"Configure social icons in the block's content settings."}),i(a("show_secondary_links")||"Secondary links",l.jsx(Ma,{checked:g,onChange:e=>s({showSecondaryLinks:e})})),i(a("show_copyright")||"Copyright",l.jsx(Ma,{checked:h,onChange:e=>s({showCopyright:e})})),h&&i(a("copyright_text")||"Copyright text",l.jsx(t.Input,{className:"width-full",value:k,placeholder:`© ${(new Date).getFullYear()} Your Company`,onChange:e=>s({copyrightText:e.target.value})})),l.jsx("div",{className:"right-setting-block-item-title margin-top-12",children:a("footer_style")||"Footer Style"}),i(a("background_color")||"Background",l.jsx(Ba,{color:w,setColor:({hex:e})=>c({backgroundColor:e})})),i(a("text_color")||"Text color",l.jsx(Ba,{color:v,setColor:({hex:e})=>c({color:e})})),i(a("font_size")||"Font size",l.jsx(t.Select,{className:"ee-stack-control",value:"number"==typeof j?j:parseInt(String(j||"12"),10),style:{width:"100%"},onChange:e=>c({fontSize:e}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:Vl})),i(a("text_align")||"Alignment",l.jsx(t.Select,{className:"ee-stack-control",value:S,style:{width:"100%"},onChange:e=>c({textAlign:e}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:Kl})),i(a("padding_top")||"Top padding",l.jsx(t.InputNumber,{min:0,max:80,className:"input-width",addonAfter:"px",value:"number"==typeof N?N:parseInt(String(N||"16"),10),onChange:e=>c({paddingTop:e??16})})),i(a("padding_bottom")||"Bottom padding",l.jsx(t.InputNumber,{min:0,max:80,className:"input-width",addonAfter:"px",value:"number"==typeof I?I:parseInt(String(I||"16"),10),onChange:e=>c({paddingBottom:e??16})})),l.jsx("div",{className:"right-setting-block-item-title margin-top-12",children:a("divider")||"Divider"}),i(a("show_divider")||"Show divider",l.jsx(Ma,{checked:A,onChange:e=>s({showDivider:e})})),A&&i(a("divider_color")||"Divider color",l.jsx(Ba,{color:T,setColor:({hex:e})=>s({dividerColor:e})}))]})},ql=()=>{const{currentItem:t}=e.useContext(ge);return l.jsxs(l.Fragment,{children:["column"===t?.data.key&&l.jsx(pl,{}),"text"===t?.data.key&&l.jsx(kl,{}),"button"===t?.data.key&&l.jsx(Sl,{}),"divider"===t?.data.key&&l.jsx(Cl,{}),"spacer"===t?.data.key&&l.jsx(Il,{}),"menu"===t?.data.key&&l.jsx(Bl,{}),"image"===t?.data.key&&l.jsx($l,{}),"video"===t?.data.key&&l.jsx(Rl,{}),"avatar"===t?.data.key&&l.jsx(Ml,{}),"social_link"===t?.data.key&&l.jsx(Ul,{}),"raw_html"===t?.data.key&&l.jsx(Ol,{}),"table"===t?.data.key&&l.jsx(Hl,{}),"footer"===t?.data.key&&l.jsx(Gl,{})]})},Jl={error:{icon:o.faExclamationCircle,color:"#F87171",bg:"rgba(127, 29, 29, 0.35)",border:"rgba(248, 113, 113, 0.45)"},warning:{icon:o.faExclamationTriangle,color:"#fbbf24",bg:"rgba(251, 191, 36, 0.08)",border:"rgba(251, 191, 36, 0.25)"},info:{icon:o.faInfoCircle,color:"#60a5fa",bg:"rgba(96, 165, 250, 0.08)",border:"rgba(96, 165, 250, 0.25)"}},Yl=e=>{const t={},n=e=>{Array.isArray(e)&&e.forEach(e=>{e&&"object"==typeof e&&("text"===e.key&&"dynamic"===e.contentType&&(e.dynamicPrompt||e.dynamicSelectedContent)&&(t[e.id]={blockId:e.id,key:e.key,type:e.type||"p",prompt:e.dynamicPrompt??"",selectedContent:e.dynamicSelectedContent??"",options:e.dynamicOptions??[],variable:e.dynamicVariable??"",language:"bn-BD"===e.dynamicAiLanguage?"bn-BD":"en"}),Array.isArray(e.children)&&n(e.children))})};return n(e),t},Xl=()=>{const{blockList:t,bodySettings:a,blockMap:i,setCurrentItem:r,setActionType:s,validationMarkers:c,ignoreValidationIssue:d,filterIgnoredValidationIssues:u}=e.useContext(ge),{t:m}=So(),p=e.useMemo(()=>{const e=uo({blockList:t??[],bodySettings:a??null,aiContentRefs:Yl(t??[])});return"function"==typeof u?u(e):e},[t,a,u]),g=p.filter(e=>"error"===e.severity),h=p.filter(e=>"warning"===e.severity),b=p.filter(e=>"info"===e.severity),y=(e,t)=>{const o=Jl[e.severity]||Jl.info,a=`validation_${e.code}`,c=m(a),u=c&&c!==a?c:e.message,p=Boolean(e.blockId&&i?.[e.blockId]);return l.jsxs("div",{style:{padding:10,background:o.bg,border:`1px solid ${o.border}`,borderRadius:4,display:"flex",gap:10,marginBottom:8},children:[l.jsx(n.FontAwesomeIcon,{icon:o.icon,style:{width:14,height:14,color:o.color,flexShrink:0,marginTop:2}}),l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700,color:o.color,textTransform:"none"},children:e.location||e.code||m(`compliance_severity_${e.severity}`)||e.severity}),l.jsx("div",{style:{fontSize:11,color:"var(--ee-foreground)",marginTop:2,lineHeight:1.5},children:u}),(p||"function"==typeof d)&&l.jsxs("div",{style:{marginTop:6,display:"flex",gap:8},children:[p&&l.jsx("button",{type:"button",onClick:()=>{var t;(t=e.blockId)&&i?.[t]&&(r({id:t,data:i[t],type:"edit"}),s("edit"),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const e="function"==typeof window.CSS?.escape?window.CSS.escape(String(t)):String(t).replace(/([ #;?%&,.+*~':"!^$[\]()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${e}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}))},style:{background:"transparent",border:"1px solid rgba(255,255,255,0.18)",color:"var(--ee-foreground)",padding:"3px 8px",borderRadius:999,fontSize:11,cursor:"pointer",fontFamily:"inherit"},children:m("export_validation_open_block")||"Open block"}),"function"==typeof d&&l.jsx("button",{type:"button",onClick:()=>d(e),style:{background:"transparent",border:"1px solid rgba(255,255,255,0.12)",color:"var(--ee-muted-foreground)",padding:"3px 8px",borderRadius:999,fontSize:11,cursor:"pointer",fontFamily:"inherit"},title:Hn(e),children:m("ignore")})]})]})]},t)},_=0===p.length,f=e.useMemo(()=>{try{return JSON.stringify({blockList:t??[],bodySettings:a??{}}).length}catch{return 0}},[t,a]),x=Math.max(1,Math.round(2*f/1024)),k=Math.min(100,x/200*100),v=x>=102,w=l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:m("compliance_email_size")||"Email size"}),l.jsxs("div",{style:{padding:"10px 12px",background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:6},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[l.jsx("span",{style:{fontSize:12,color:"#A3A3A3",fontVariantNumeric:"tabular-nums"},children:m("compliance_approx_kb",{n:String(x)})}),l.jsx("span",{style:{fontSize:11,fontWeight:600,color:v?"#f87070":"#C6F065",fontVariantNumeric:"tabular-nums"},children:v?m("compliance_above_clip")||"Above clip threshold":m("compliance_below_clip")||"Below clip threshold"})]}),l.jsxs("div",{style:{position:"relative",height:6,background:"rgba(255,255,255,0.08)",borderRadius:99},children:[l.jsx("div",{style:{position:"absolute",left:0,top:0,height:"100%",width:`${k}%`,background:v?"#f87070":"var(--ee-primary)",borderRadius:99,transition:"width 0.3s ease"}}),l.jsx("div",{style:{position:"absolute",left:"51%",top:-3,bottom:-3,width:1.5,background:"rgba(251,191,36,0.7)",borderRadius:1}})]}),l.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:6},children:l.jsxs("span",{style:{fontSize:10,color:"rgba(251,191,36,0.85)"},children:[102," KB clip"]})})]})]});return l.jsxs("div",{style:{padding:"14px 14px 18px 14px"},children:[l.jsx(Ea,{className:"ee-settings-section-title--flush",children:m("compliance_preflight")||"Pre-flight"}),_?l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:12,background:"rgba(216, 254, 145, 0.08)",border:"1px solid rgba(216, 254, 145, 0.25)",borderRadius:4},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCheckCircle,style:{width:16,height:16,color:"var(--ee-primary)"}}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:13,fontWeight:500},children:m("compliance_all_clear_title")}),l.jsx("div",{style:{fontSize:11,color:"var(--ee-muted-foreground)",marginTop:2},children:m("compliance_all_clear_desc")})]})]}):l.jsxs(l.Fragment,{children:[g.length>0&&l.jsxs("div",{style:{marginBottom:12},children:[l.jsxs("div",{className:"export-validation-errors-heading",style:{fontWeight:600,marginBottom:6,fontSize:12},children:[m("export_validation_errors")," (",g.length,")"]}),g.map((e,t)=>y(e,`e-${t}`))]}),h.length>0&&l.jsxs("div",{style:{marginBottom:12},children:[l.jsxs("div",{className:"export-validation-warnings-heading",style:{fontWeight:600,marginBottom:6,fontSize:12},children:[m("export_validation_warnings")," (",h.length,")"]}),h.map((e,t)=>y(e,`w-${t}`))]}),b.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"export-validation-info-heading",style:{fontWeight:600,marginBottom:6,fontSize:12},children:[m("export_validation_info")," (",b.length,")"]}),b.map((e,t)=>y(e,`i-${t}`))]})]}),w]})},Zl=({open:e,onUnlinkInstance:n,onKeepLinked:o,onClose:a})=>{const{t:i}=So(),r=()=>{o?.(),a?.()};return l.jsxs(t.Modal,{className:"ee-modal-dark",title:i("unlink_modal_title")||"Edit universal block",open:e,onCancel:r,footer:[l.jsx(t.Button,{onClick:r,children:i("unlink_modal_keep")||"Keep linked"},"keep"),l.jsx(t.Button,{type:"primary",danger:!0,onClick:()=>{n?.(),a?.()},children:i("unlink_modal_unlink")||"Unlink this copy"},"unlink")],width:440,destroyOnClose:!0,children:[l.jsx("p",{style:{color:"var(--ee-muted-foreground)",marginBottom:8},children:i("unlink_modal_body")||"This block is linked to a universal snippet. Editing it here will affect all uses of this block everywhere."}),l.jsx("p",{style:{color:"var(--ee-muted-foreground)"},children:i("unlink_modal_body2")||"Choose “Unlink this copy” to make an independent copy that only affects this template, or “Keep linked” to edit all instances together."})]})},Ql=({onSaveAsUniversal:a})=>{const{blockMap:i,rootOrder:r,setBlocks:s,currentItem:c,setCurrentItem:d,onSaveBlockAsGlobal:u}=e.useContext(ge),{t:m}=So(),[p,g]=e.useState(!1),[h,b]=e.useState(!1),y=e.useRef(null);e.useEffect(()=>{if(!p)return;const e=e=>{y.current&&!y.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const _=c?.id,f=_?i[_]:null;if(!_||!f)return null;const x=()=>g(!1),k="function"==typeof a||"function"==typeof u,v=Boolean(f?.universalBlockId);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{ref:y,className:"ee-block-actions-menu-wrap",onClick:e=>e.stopPropagation(),children:[l.jsx("button",{type:"button",className:"ee-block-actions-trigger",onClick:()=>g(e=>!e),"aria-haspopup":"true","aria-expanded":p,"aria-label":m("more_actions"),title:m("more_actions"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faEllipsisV})}),p&&l.jsxs("div",{className:"ee-block-actions-menu",role:"menu",children:[l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item",onClick:()=>{x();const e=ia(i,r,_);e&&(s(e.nextMap,e.nextRootOrder,"add"),d({id:e.newId,data:e.selectionData,type:"edit"}))},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCopy}),l.jsx("span",{children:m("layer_duplicate")})]}),k&&l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item",onClick:()=>{x(),"function"==typeof a&&a(f)},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faStar}),l.jsx("span",{children:m("save_as_universal")})]}),v&&l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item",onClick:()=>{x(),b(!0)},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faUnlink}),l.jsx("span",{children:m("unlink_universal")||"Unlink this copy"})]}),l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item",onClick:()=>{x();const e={...f,hidden:!f.hidden};s({...i,[_]:e},r,"edit")},children:[l.jsx(n.FontAwesomeIcon,{icon:f.hidden?o.faEye:o.faEyeSlash}),l.jsx("span",{children:f.hidden?m("layer_show"):m("layer_hide")})]}),l.jsx("div",{className:"ee-block-actions-divider","aria-hidden":!0}),l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item ee-block-actions-item-danger",onClick:()=>{x();const e=()=>{const e=da(i,r,_,m);e&&(s(e.nextMap,e.nextRootOrder,"delete"),d(null))};"column"===f.key&&ca(i,_)?t.Modal.confirm({title:m("shortcut_delete_confirm_title"),content:m("shortcut_delete_confirm_desc"),okText:m("confirm"),cancelText:m("cancel"),wrapClassName:"ee-modal-dark",onOk:e}):e()},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faTrash}),l.jsx("span",{children:m("layer_delete")})]})]})]}),l.jsx(Zl,{open:h,onUnlinkInstance:()=>{const e={...f};delete e.universalBlockId,s({...i,[_]:e},r,`edit_${Date.now()}`),d({...c,data:e})},onKeepLinked:()=>{},onClose:()=>b(!1)})]})},ei=({open:n,block:o,onCreate:a,onClose:i})=>{const{t:r}=So(),[s,c]=e.useState("");e.useEffect(()=>{n&&c("")},[n]);const d=()=>{s.trim()&&o&&a({name:s.trim(),block:o})};return l.jsxs(t.Modal,{className:"ee-modal-dark",title:r("universal_save_modal_title"),open:n,onCancel:i,footer:[l.jsx(t.Button,{onClick:i,children:r("cancel")},"cancel"),l.jsx(t.Button,{type:"primary",onClick:d,disabled:!s.trim(),children:r("universal_save_modal_confirm")},"save")],width:420,destroyOnClose:!0,children:[l.jsx("p",{style:{color:"var(--ee-muted-foreground)",marginBottom:12},children:r("universal_save_modal_subtitle")}),l.jsx(t.Input,{autoFocus:!0,value:s,placeholder:r("universal_save_modal_placeholder"),onChange:e=>c(e.target.value),onPressEnter:d})]})},ti="content",ni="styles",oi="compliance",ai=()=>{const{currentItem:a,isDragStart:i,bodySettings:r,setBodySettings:s,setCurrentItem:c,setActionType:d,blockMap:u,rootOrder:m,validationMarkers:p,onSaveBlockAsGlobal:g,templateData:h}=e.useContext(ge),[b,y]=e.useState(null),{t:_}=So(),v=e.useCallback(e=>e&&"object"==typeof e&&"column"===e.key&&e.id&&u[e.id]?P(e.id,u)??e:e,[u]),S=e.useCallback(e=>{y(v(e))},[v]),C=e.useCallback(async({name:e,block:n})=>{try{"function"==typeof g&&await Promise.resolve(g({name:e,block:n})),t.message.success(String(_("universal_save_success")||"").replace("{{name}}",e)||`Saved "${e}" as universal`),y(null)}catch(e){console.error("[EmailEditor] onSaveBlockAsGlobal:",e);const n=_("universal_save_error")||"Could not save universal block",o="string"==typeof e?.message&&e.message.trim()?e.message.trim():"string"==typeof e?e:n;t.message.error(o||n)}},[g,_]);e.useEffect(()=>{const e=e=>{e.detail&&e.detail.block&&y(v(e.detail.block))};return window.addEventListener("ee:canvas-save-universal",e),()=>window.removeEventListener("ee:canvas-save-universal",e)},[v]);const N=e.useMemo(()=>Mt(h),[h]),[I,A]=e.useState(ti),T=e.useRef(null),L=p?Object.values(p).reduce((e,t)=>e+(t?.totalCount||0),0):0,B=e=>{if(!e)return o.faSquare;switch(e.key){case"column":{const t=e.containerType;return"product"===t?o.faCube:"discount"===t?o.faTag:ua(e)===ma?o.faSquare:o.faColumns}case"text":{const t=(e.type||"p").toLowerCase();return/^h[1-6]$/.test(t)?o.faHeading:o.faFont}case"button":return o.faLink;case"image":return o.faImage;case"video":return o.faVideo;case"divider":return o.faGripLines;case"spacer":return o.faArrowsAltV;case"menu":return o.faBars;case"avatar":return o.faUser;case"social_link":return o.faShareAlt;case"raw_html":return o.faCode;case"table":return o.faTable;case"footer":return o.faEnvelopeOpenText;default:return o.faSquare}},$=()=>{if(!a?.id||!u[a.id])return[];const e=[a.id],t=new Set(e);let n=a.id;for(;;){const o=F(u,m,n);if(!o||t.has(o.containerId))break;e.unshift(o.containerId),t.add(o.containerId),n=o.containerId}return e.map(e=>({id:e,data:u[e]})).filter(e=>Boolean(e.data))},R=()=>{let e="Block";const t=a?.data.key;switch(t){case"text":{const t=(a?.data?.type||"p").toLowerCase();e=/^h[1-6]$/.test(t)?_("heading_settings"):_("text_settings");break}case"column":{const t=a?.data?.containerType;if("product"===t){e=_("block_product");break}e=ua(a?.data)===pa?_("settings_title_column_layout"):_("container_settings");break}case"button":e=_("button_settings");break;case"divider":e=_("divider_settings");break;case"spacer":e=_("spacer_settings");break;case"menu":e=_("menu_settings");break;case"image":e=_("image_settings");break;case"video":e=_("video_settings");break;case"avatar":e=_("avatar_settings");break;case"social_link":e=_("social_link_settings");break;case"raw_html":e=_("raw_html_settings");break;case"table":e=_("table_settings");break;case"footer":e=_("footer_settings")}return e},M=e=>t=>{s({...r,styles:{...r.styles,[e]:t.hex}},"set_body_settings")},E=(e,t,n,o)=>l.jsx(Ua,{label:e,children:l.jsx(Ba,{color:t,setColor:n,fallbackColor:o})}),D=()=>{const e=r.styles||{},n=e.headingColor||e.color||"#171717";return l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("type_styles_section")}),l.jsxs("div",{className:"right-panel-styles-section-body ee-settings-stack-flat",children:[l.jsx(Ua,{label:_("body_font_short"),children:l.jsx(t.Select,{className:"input-width",showSearch:!0,optionFilterProp:"label",value:Ft(e.fontFamily,h),onChange:e=>{return t=Ft(e,h),void s({...r,styles:{...r.styles,fontFamily:t}},"set_body_settings");var t},labelRender:({value:e})=>l.jsx("span",{children:Et(e,h)}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:N.map(e=>({label:e.label,value:e.value}))})}),E(_("body_text_short"),e.color,M("color"),"#171717"),E(_("body_heading_short"),n,M("headingColor"),"#171717"),E(_("body_link_short"),e.linkColor||"#338AF3",M("linkColor"),"#338AF3")]})]})},U=()=>{const e=r.styles||{},n=j(r);return l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("document_section")}),l.jsxs("div",{className:"right-panel-styles-section-body ee-settings-stack-flat",children:[E(_("body_bg_color_short"),e.backgroundColor,M("backgroundColor"),"#F5F5F5"),E(_("body_content_bg_short"),e.contentBg??"#FFFFFF",M("contentBg"),"#FFFFFF"),l.jsx(Ua,{label:_("body_width_label"),children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix ee-body-width-number",addonAfter:"px",min:f,max:x,value:n,onChange:e=>s({...r,contentWidth:e,contentWidthMode:k.CUSTOM_PX},"set_body_settings")})})]})]})},z=()=>{const e=w(r),a=j(r),i=r.styles||{};return l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("email_styles_section")}),l.jsxs("div",{className:"right-panel-styles-section-body ee-settings-stack-flat",children:[E(_("body_bg_color_short"),i.backgroundColor,M("backgroundColor"),"#F5F5F5"),E(_("body_content_bg_short"),i.contentBg??"#FFFFFF",M("contentBg"),"#FFFFFF"),l.jsx(Ua,{label:l.jsxs("span",{children:[_("email_width_mode"),l.jsx(t.Tooltip,{title:_("full_bleed_tooltip"),children:l.jsx("span",{className:"ee-help-icon","aria-label":"Help",children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),children:l.jsx(t.Select,{className:"input-width ee-width-mode-select",value:e,onChange:e=>s({...r,contentWidthMode:e},"set_body_settings"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:[{value:k.EMAIL_WIDTH,label:_("email_width_default")},{value:k.CUSTOM_PX,label:_("custom_px")},{value:k.FULL_BLEED,label:_("full_bleed")}]})}),l.jsx(Ua,{label:_("custom_width_px"),children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix ee-body-width-number",addonAfter:"px",min:f,max:x,value:a,disabled:e===k.FULL_BLEED,onChange:e=>s({...r,contentWidth:e,contentWidthMode:k.CUSTOM_PX},"set_body_settings")})})]})]}),D(),l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("text_and_headings")}),l.jsx("div",{className:"right-panel-styles-section-body",children:l.jsx(Ua,{label:_("pre_header"),hint:_("pre_header_description"),children:l.jsx(t.Input,{value:r.preHeader,onChange:e=>s({...r,preHeader:e.target.value},"set_body_settings")})})})]}),l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("mobile_optimization")||"Mobile optimization"}),l.jsxs("div",{className:"right-panel-styles-section-body ee-settings-stack-flat",children:[l.jsxs("div",{className:"ee-settings-row",children:[l.jsx("span",{className:"ee-settings-row-label",children:_("stack_columns_on_mobile")||"Stack columns on mobile"}),l.jsx(Ma,{checked:!1!==r.stackColumnsOnMobile,onChange:e=>s({...r,stackColumnsOnMobile:e},"set_body_settings")})]}),l.jsxs("div",{className:"ee-settings-row",children:[l.jsx("span",{className:"ee-settings-row-label",children:_("scale_font_on_mobile")||"Scale font on mobile"}),l.jsx(Ma,{checked:!1!==r.scaleFontOnMobile,onChange:e=>s({...r,scaleFontOnMobile:e},"set_body_settings")})]})]})]})]})},O="undefined"!=typeof window&&"product-variables"===window.__eeDragSource,W=a&&"edit"===a.type&&(!i||O);e.useLayoutEffect(()=>{if(!W)return;A(ti);const e=T.current;e&&(e.scrollTop=0)},[W,a?.id]);const H=()=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"right-panel-block-settings-header",children:[l.jsx("button",{type:"button",className:"right-panel-back-btn",onClick:()=>c(null),"aria-label":_("right_panel_back"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronLeft})}),l.jsx("span",{className:"ee-block-settings-header-icon","aria-hidden":!0,children:l.jsx(n.FontAwesomeIcon,{icon:B(a?.data)})}),l.jsx("h2",{className:"right-setting-block-title right-panel-block-title-inline",children:R()}),l.jsx(Ql,{onSaveAsUniversal:S})]}),l.jsxs("div",{className:"right-panel-layers-bar",children:[l.jsx("div",{className:"right-panel-layers-header",children:_("layers_panel")}),l.jsx("nav",{className:"right-panel-breadcrumbs-shell","aria-label":_("layers_panel"),children:l.jsx("ol",{className:"right-panel-breadcrumbs-trail",children:$().map((e,t,a)=>{const i=t===a.length-1,r=(e=>{if(!e)return"";switch(e.key){case"column":{const t=e.containerType;if("product"===t)return _("block_product");if("discount"===t)return _("block_discount");const n=ua(e);return _(n===ma?"block_palette_section":n===pa?"block_palette_columns":"container")}case"text":{const t=(e.type||"p").toLowerCase();return/^h[1-6]$/.test(t)?_("heading"):_("text")}case"button":return _("button");case"image":return _("image");case"video":return _("video");case"divider":return _("divider");case"spacer":return _("spacer");case"menu":return _("menu");case"avatar":return _("avatar");case"social_link":return _("social_link");case"raw_html":return _("raw_html");case"table":return _("table");case"footer":return _("block_footer");case"empty":return _("drag_block_here");default:return e.name||"Block"}})(e.data),s=B(e.data);return l.jsxs("li",{className:"right-panel-breadcrumb-item right-panel-breadcrumb-crumb-slot",children:[t>0?l.jsx("span",{className:"right-panel-breadcrumb-sep","aria-hidden":!0,children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronRight})}):null,i?l.jsxs("span",{className:"right-panel-breadcrumb-segment right-panel-breadcrumb-current","aria-current":"page",children:[l.jsx("span",{className:"right-panel-breadcrumb-ancestor-icon right-panel-breadcrumb-current-icon",children:l.jsx(n.FontAwesomeIcon,{icon:s})}),l.jsx("span",{className:"right-panel-breadcrumb-label",children:r})]}):l.jsxs("button",{type:"button",className:"right-panel-breadcrumb-segment right-panel-breadcrumb-ancestor",onClick:(m=e.id,e=>{e.preventDefault(),e.stopPropagation();const t=u[m];t&&(c({id:m,data:t,type:"edit"}),d("edit"))}),children:[l.jsx("span",{className:"right-panel-breadcrumb-ancestor-icon",children:l.jsx(n.FontAwesomeIcon,{icon:s})}),l.jsx("span",{className:"right-panel-breadcrumb-label",children:r})]})]},`${e.id||"layer"}-${t}`);var m})})})]}),l.jsx("div",{className:"right-panel-block-settings-form",children:l.jsx(ql,{})})]});return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"right-settings",onClick:e=>{e.stopPropagation()},children:l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"right-panel-tabs",children:[l.jsx("button",{type:"button",className:"right-panel-tab "+(I===ti?"right-panel-tab-active":""),onClick:()=>A(ti),children:_("content")}),l.jsx("button",{type:"button",className:"right-panel-tab "+(I===ni?"right-panel-tab-active":""),onClick:()=>A(ni),children:_("styles")}),l.jsxs("button",{type:"button",className:"right-panel-tab "+(I===oi?"right-panel-tab-active":""),onClick:()=>A(oi),children:[_("compliance"),L>0&&l.jsx("span",{className:"right-panel-tab-badge","aria-label":_("compliance_tab_badge_label",{count:L>99?"99+":String(L)}),children:L>99?"99+":L})]})]}),l.jsxs("div",{ref:T,className:"right-panel-tab-content default-scrollbar"+(I===ti&&W?" right-panel-tab-content--block-settings":""),children:[I===ti&&(W?H():l.jsxs(l.Fragment,{children:[U(),D(),l.jsx("div",{className:"ee-content-empty-hint",children:_("right_panel_empty_hint")})]})),I===ni&&z(),I===oi&&l.jsx(Xl,{})]})]})}),l.jsx(ei,{open:Boolean(b),block:b,onCreate:C,onClose:()=>y(null)})]})};var li={presets:[{id:"preset_header",presetName:"Header",nameKey:"preset_header",containerType:"none",block:{name:"Container",key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{LogoUrl}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"50%"},mobile:{}}},{name:"Container",key:"column",type:"full",containerType:"none",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Menu",key:"menu",useNavigationLinks:!0,list:[{label:"Link 1",url:"#",target:"_blank"},{label:"Link 2",url:"#",target:"_blank"},{label:"Link 3",url:"#",target:"_blank"}],separator:" | ",contentStyles:{desktop:{paddingTop:25,paddingBottom:15,paddingLeft:5,paddingRight:5,textAlign:"center"},mobile:{}},styles:{desktop:{fontSize:14,fontFamily:"Verdana",color:"#333333",linkColor:"#333333",paddingTop:5,paddingBottom:5,paddingLeft:8,paddingRight:8,letterSpacing:0,fontWeight:"normal"},mobile:{}},isPreset:!0},{name:"Image",key:"image",src:"{{HeroBanner}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}}]}]}]}]}},{id:"navigation_bar",presetName:"Navigation Bar",nameKey:"preset_navigation_bar",containerType:"none",block:{name:"Menu",key:"menu",useNavigationLinks:!0,list:[{label:"Link 1",url:"#",target:"_blank"},{label:"Link 2",url:"#",target:"_blank"},{label:"Link 3",url:"#",target:"_blank"}],separator:" | ",contentStyles:{desktop:{paddingTop:25,paddingBottom:15,paddingLeft:5,paddingRight:5,textAlign:"center"},mobile:{}},styles:{desktop:{fontSize:14,fontFamily:"Verdana",color:"#333333",linkColor:"#333333",paddingTop:5,paddingBottom:5,paddingLeft:8,paddingRight:8,letterSpacing:0,fontWeight:"normal"},mobile:{}},isPreset:!0}},{id:"product_single",nameKey:"preset_product_single",containerType:"product",presetName:"Hero Product",block:{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"main",columnProducts:[{id:"product-1",name:"Abundance Butterfly Diamond Ring",description:"The Maia Diamond Ring features round diamonds set along a delicate gold band, creating a refined and minimalistic look. Its versatile design makes it perfect for everyday wear or for layering with other rings.",image:"https://www.psylish.com/cdn/shop/files/IMG_4632.jpg?v=1773123202&width=1220",link:"https://www.psylish.com",price:2e3,currency:"USD",old_price:null,new_price:null}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:null,paddingBottom:null,paddingLeft:null,paddingRight:null,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: sans-serif"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:null,paddingLeft:12,paddingRight:12,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: sans-serif">{{ProductPriceDisplay}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:null,paddingBottom:6,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Shop Now",type:"link",linkURL:"{{ProductLink}}",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:null,paddingRight:null},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:null,paddingRight:null,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}},{name:"Divider",key:"divider",contentStyles:{desktop:{paddingTop:2,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}}]}]}},{id:"product_two_column",presetName:"Additional Products",nameKey:"preset_product_two_column",containerType:"product",block:{name:"Container",key:"column",type:"1-1",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"#fff"},mobile:{}},isPreset:!0,columns:2,columnProducts:[null,null],children:[{name:"Content",key:"content",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:6,paddingRight:3,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"additional",columnProducts:[{id:"product-2",name:"Heartline Diamond Ring",description:"The Sariah Diamond Earrings feature round diamonds in a classic hoop design that curves elegantly around the lobe. Their minimalist silhouette makes them perfect for everyday wear or adding a touch of sparkle to layered look.",image:"https://www.psylish.com/cdn/shop/files/Psylish3.0_15.png?v=1770880382&width=1220",link:"https://www.psylish.com/",price:1e3,currency:"USD",old_price:1200,new_price:1e3}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: Arial"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"Arial",lineHeight:"140%",paddingTop:12,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: Arial">{{ProductPriceDisplay}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"Arial",lineHeight:"140%",paddingTop:2,paddingBottom:2,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Add to Cart",type:"link",linkURL:"{{ProductLink}}",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:0,paddingRight:0,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}}]}]}]},{name:"Content",key:"content",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:3,paddingRight:6,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"additional",columnProducts:[{id:"product-3",name:"Lynx Heart Diamond Ring",description:"The Sariah Diamond Earrings feature round diamonds in a classic hoop design that curves elegantly around the lobe. Their minimalist silhouette makes them perfect for everyday wear or adding a touch of sparkle to layered look.",image:"https://www.psylish.com/cdn/shop/files/Psylish3.0_48.png?v=1770881768&width=1220",link:"https://www.psylish.com/",price:900,currency:"USD",old_price:1200,new_price:900}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: Arial"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"Arial",lineHeight:"140%",paddingTop:12,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: Arial">{{ProductPriceDisplay}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"Arial",lineHeight:"140%",paddingTop:2,paddingBottom:2,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Add to Cart",type:"link",linkURL:"{{ProductLink}}",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:20,paddingRight:20,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}}]}]}]}]}},{id:"preset_discount",presetName:"Discount",nameKey:"preset_discount",containerType:"discount",block:{name:"Container",key:"column",type:"full",containerType:"discount",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#ffa7aa"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Text",key:"text",text:'<div style="text-align: center;"><font face="Arial">Use <b>{{DiscountCode}}</b> for <b>{{DiscountValue}}</b> OFF. Expires on {{ValidUntil}}</font></div>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}}]}]}},{id:"preset_footer",presetName:"Footer",nameKey:"preset_footer",containerType:"none",block:{name:"Container",key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{FooterBanner}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Image",key:"image",src:"{{LogoUrl}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"35%"},mobile:{}}},{name:"Text",key:"text",text:"<p><i><b>{{Tagline}}</b></i></p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}},{name:"Social Link",key:"social_link",list:[{image:"https://s.magecdn.com/social/tc-facebook.svg",title:"Facebook",linkURL:"facebook.com/psylish"},{image:"https://s.magecdn.com/social/tc-x.svg",title:"X",linkURL:"twitter.com/psylish"},{image:"https://s.magecdn.com/social/tc-instagram.svg",title:"Instagram",linkURL:"instagram.com/psylish"},{image:"https://s.magecdn.com/social/tc-linkedin.svg",title:"LinkedIn",linkURL:"linkedin.com/company/psylish"},{image:"https://s.magecdn.com/social/tc-tiktok.svg",title:"TikTok",linkURL:"www.tiktok.com/@psylish"},{image:"https://s.magecdn.com/social/tc-youtube.svg",title:"YouTube",linkURL:"www.youtube.com/@psylish"}],imageWidth:32,contentStyles:{desktop:{paddingTop:2,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{paddingTop:4,paddingBottom:4,paddingLeft:6,paddingRight:6},mobile:{}},useCompanySocialLinks:!0},{name:"Divider",key:"divider",contentStyles:{desktop:{paddingTop:12,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}},{name:"Text",key:"text",text:'<p><a href="{{Website}}" style="color:#263d2d;text-decoration:underline">{{Website}}</a></p>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center",color:"#263d2d",textDecoration:"underline"},mobile:{}}}]}]}}]};function ii(e){if(!e||"object"!=typeof e)return e;const t={...e,id:A()};return Array.isArray(t.children)&&(t.children=t.children.map(ii)),Array.isArray(t.columnProducts)&&(t.columnProducts=t.columnProducts.map(e=>e&&"object"==typeof e?{...e}:e)),t}const ri={column:o.faColumns,text:o.faFont,button:o.faMinusSquare,divider:o.faGripLines,spacer:o.faArrowsAltV,menu:o.faBars,image:o.faImage,social_link:o.faShareAltSquare,raw_html:o.faCode,table:o.faTable,video:o.faVideo,product:o.faCube,header:o.faWindowMaximize,footer:o.faWindowMinimize,discount:o.faTag},si={Header:"header",Footer:"footer",Discount:"discount","Navigation Bar":"menu"};function ci(e){const t=si[e];return t&&ri[t]?ri[t]:ri.product}const di=["text","image","button","divider","spacer","social_link","menu","table","video","raw_html"],ui={[ma]:o.faSquare,[pa]:o.faColumns};const mi=({clearStyles:t,openConfigureColumnsModal:a})=>{const{setCurrentItem:i,setIsDragStart:r,setActionType:s,templateData:c,aiEnabled:d=!0}=e.useContext(ge),{blockConfigsList:u}=Fa(),{t:m}=So(),{blockItems:p,layoutItems:g}=function(e,t){const n=[];di.forEach(o=>{const a=e.find(e=>e.key===o);a&&("text"===o&&t?n.push({...a,ai:!0,contentType:"static",dynamicPrompt:"",dynamicSelectedContent:"",dynamicOptions:[],dynamicVariable:"",isPreset:!1}):n.push({...a,isPreset:!1}))});const o=[],a=e.find(e=>"column"===e.key&&e.layoutRole===ma),l=e.find(e=>"column"===e.key&&e.layoutRole===pa);return a&&o.push({...a,isPreset:!1,paletteIcon:ui[ma],opensConfigureModal:!1}),l&&o.push({...l,isPreset:!1,paletteIcon:ui[pa],opensConfigureModal:!0}),{blockItems:n,layoutItems:o}}(u,d),h=li.presets.map(e=>({key:e.id,name:e.presetName,icon:ci(e.presetName),isPreset:!0,getColumn:()=>function(e){const t=li.presets.find(t=>t.id===e);return t?ii(JSON.parse(JSON.stringify(t.block))):null}(e.id)})),b=e=>{e.target.style.outline="",setTimeout(()=>{r(!1),t&&t()},50)},y=e=>t=>{const n=e.isPreset?C(e.getColumn(m,c)):C(e);i({id:null,data:n,type:"add"}),r(!0),t.target.style.outline="1px dashed var(--ee-primary)",s("add")},_=e=>{const t="boolean"==typeof e.opensConfigureModal?e.opensConfigureModal:ua(e)===pa;return l.jsxs("div",{className:"ee-blocks-palette-card",draggable:!0,onDragStart:y(e),onDragEnd:b,onClick:()=>{t&&a()},title:t?`${e.name} — ${m("configure_columns_hint")}`:e.name,children:[l.jsx(n.FontAwesomeIcon,{icon:e.paletteIcon||e.icon||ri[e.key]||o.faFont,className:"ee-blocks-palette-card-icon"}),l.jsx("span",{className:"ee-blocks-palette-card-label",children:e.name}),e.ai&&l.jsxs("span",{className:"ee-blocks-palette-card-ai",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faStar,className:"ee-blocks-palette-card-ai-icon","aria-hidden":!0}),"AI"]})]},`palette-card-${e.key}-${e.layoutRole??"base"}`)};return l.jsxs("div",{className:"ee-blocks-palette",children:[l.jsx("div",{className:"ee-left-rail-section-title",children:m("blocks")}),l.jsx("div",{className:"ee-blocks-palette-grid",children:p.map(_)}),g.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ee-left-rail-section-title",style:{paddingTop:16},children:m("layout")}),l.jsx("div",{className:"ee-blocks-palette-grid",children:g.map(_)})]}),h.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ee-left-rail-section-title",style:{paddingTop:16},children:m("presets")}),l.jsx("div",{className:"ee-blocks-palette-rows",children:h.map(e=>l.jsxs("div",{className:"ee-blocks-palette-row",draggable:!0,onDragStart:y(e),onDragEnd:b,title:e.name,children:[l.jsx(n.FontAwesomeIcon,{icon:o.faGripVertical,className:"ee-blocks-palette-row-grip"}),l.jsx(n.FontAwesomeIcon,{icon:e.icon,className:"ee-blocks-palette-row-icon"}),l.jsx("span",{className:"ee-blocks-palette-row-label",children:e.name})]},e.key))})]})]})},pi=({clearStyles:a})=>{const{universals:i=[],universalsLoading:r,setCurrentItem:s,setIsDragStart:c,setActionType:d,deleteUniversalEmailBlock:u}=e.useContext(ge),{t:m}=So(),p=e=>t=>{const n=JSON.parse(JSON.stringify(e.block||{}));n&&"object"==typeof n&&(s({id:null,data:n,type:"add"}),c(!0),t.currentTarget.style.outline="1px dashed var(--ee-primary)",d("add"))},g=e=>{e.currentTarget.style.outline="",setTimeout(()=>{c(!1),a&&a()},50)};return l.jsxs("div",{className:"ee-universal-panel",children:[l.jsxs("div",{className:"ee-left-rail-section-title",children:[m("universal_saved_blocks"),r?l.jsx("span",{className:"ee-universal-loading",children:" · …"}):null]}),0===i.length?l.jsxs("div",{className:"ee-universal-empty",children:[m("universal_empty_state_line_1")," ",l.jsx(n.FontAwesomeIcon,{icon:o.faStar,style:{width:10,height:10,color:"var(--ee-primary)",verticalAlign:"middle"}})," ",m("universal_empty_state_line_2")]}):l.jsx("div",{className:"ee-universal-list",children:i.map(e=>{const a=String(e?.block?.containerType||e?.block?.key||"block").replace(/[-_]/g," "),i="none"===a.trim().toLowerCase()?m("block_palette_section"):a;return l.jsxs("div",{className:"ee-universal-item",draggable:!0,onDragStart:p(e),onDragEnd:g,title:e.name,children:[l.jsx(n.FontAwesomeIcon,{icon:o.faGripVertical,className:"ee-blocks-palette-row-grip"}),l.jsx(n.FontAwesomeIcon,{icon:o.faStar,className:"ee-universal-item-icon"}),l.jsxs("div",{className:"ee-universal-item-body",children:[l.jsx("div",{className:"ee-universal-item-name",children:e.name}),l.jsxs("div",{className:"ee-universal-item-meta",children:[i,null!=e.usedIn?` · ${m("universal_used_in_count").replace("{{count}}",String(e.usedIn))}`:""]})]}),"function"==typeof u?l.jsx("button",{type:"button",className:"ee-universal-item-delete","aria-label":m("universal_delete"),title:m("universal_delete"),onMouseDown:e=>e.stopPropagation(),onClick:n=>{n.preventDefault(),n.stopPropagation(),t.Modal.confirm({title:m("universal_delete_confirm_title"),content:m("universal_delete_confirm_body"),okButtonProps:{danger:!0},okText:m("universal_delete_confirm_ok"),cancelText:m("cancel"),wrapClassName:"ee-modal-dark",onOk:async()=>{try{await u(e.resourceId??e.id)}catch(e){throw t.message.error(e?.message||m("universal_save_error")||"Could not delete"),e}}})},children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash,className:"ee-universal-item-delete-icon"})}):null]},e.id)})})]})},gi={column:o.faColumns,text:o.faFont,button:o.faMinusSquare,divider:o.faGripLines,spacer:o.faArrowsAltV,menu:o.faBars,image:o.faImage,video:o.faVideo,social_link:o.faShareAltSquare,raw_html:o.faCode,table:o.faTable,avatar:o.faUser,empty:o.faSquare};function hi(e){return e?"column"===e.key?"product"===e.containerType?o.faCube:"discount"===e.containerType?o.faTag:ua(e)===ma?o.faSquare:o.faColumns:gi[e.key]||o.faSquare:o.faSquare}const bi=()=>{const{blockMap:a,rootOrder:i,setBlocks:r,setCurrentItem:s,setActionType:c,currentItem:d,onSaveBlockAsGlobal:u}=e.useContext(ge),{t:m}=So(),[p,g]=e.useState(null),[h,b]=e.useState(null),y=d?.id||null,_=e=>{e&&a[e]&&(s({id:e,data:a[e],type:"edit"}),c("edit"),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const t="function"==typeof window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/([ #;?%&,.+*~':"!^$[\]()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${t}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}))},f=(e,t)=>{const n=i.indexOf(e);if(-1===n)return;const o=[...i],l="up"===t?n-1:n+1;l<0||l>=o.length||([o[n],o[l]]=[o[l],o[n]],r(a,o,"move"))},x=(e,t)=>{const n=i.indexOf(e);if(-1===n)return;const o=[...i];o.splice(n,1);const l=t>n?t-1:t;o.splice(Math.max(0,Math.min(l,o.length)),0,e),r(a,o,"move")},k=(e,c,d,v,w)=>{if(!e)return null;const j=y===e.id,S=function(e){if(!e)return null;const t=e.text||e.title||e.list&&e.list[0]?.label||e.alt||e.html||"",n=String(t).replace(/<[^>]+>/g,"").trim();return n?n.length>24?`${n.slice(0,24)}…`:n:null}(e),C=function(e,t){if(!e)return"";switch(e.key){case"column":{const n=e.containerType;if("product"===n)return t("block_product");if("discount"===n)return t("block_discount");if("header"===n)return t("block_header");if("footer"===n)return t("block_footer");if("introduction"===n)return t("block_introduction");if("body"===n)return t("block_body");const o=ua(e);return t(o===ma?"block_palette_section":o===pa?"block_palette_columns":"container")}case"text":return t("text");case"button":return t("button");case"image":return t("image");case"video":return t("video");case"divider":return t("divider");case"spacer":return t("spacer");case"menu":return t("menu");case"avatar":return t("avatar");case"social_link":return t("social_link");case"raw_html":return t("raw_html");case"table":return t("table")||"Table";case"empty":return t("drag_block_here");default:return e.name||"Block"}}(e,m),N=!!e.hidden,I=d&&p&&p!==e.id&&h===v;return l.jsxs("div",{children:[I&&l.jsx("div",{className:"ee-layer-drop-indicator","aria-hidden":!0}),l.jsxs("div",{className:fo("ee-layer-row",j&&"ee-layer-row-selected",N&&"ee-layer-row-hidden"),style:{paddingLeft:6+14*c},onClick:t=>{t.stopPropagation(),_(e.id)},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),_(e.id))},role:"button",tabIndex:0,draggable:d,onDragStart:t=>{if(d){t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",e.id)}catch{}g(e.id)}},onDragOver:t=>{if(!d||!p||p===e.id)return;t.preventDefault();const n=t.currentTarget.getBoundingClientRect(),o=t.clientY-n.top<n.height/2;b(o?v:v+1)},onDrop:e=>{if(!d||!p)return;e.preventDefault();x(p,h??v),g(null),b(null)},onDragEnd:()=>{g(null),b(null)},children:[l.jsx(n.FontAwesomeIcon,{icon:hi(e),className:"ee-layer-row-icon"}),l.jsxs("span",{className:"ee-layer-row-label",children:[C,S&&l.jsxs("span",{className:"ee-layer-row-sub",children:["· ",S]})]}),l.jsxs("div",{className:"ee-layer-row-actions",onClick:e=>e.stopPropagation(),children:[d&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"ee-layer-mini-btn",title:m("layer_move_up"),disabled:0===v,onClick:()=>f(e.id,"up"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronUp})}),l.jsx("button",{type:"button",className:"ee-layer-mini-btn",title:m("layer_move_down"),disabled:v===w-1,onClick:()=>f(e.id,"down"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronDown})})]}),l.jsx("button",{type:"button",className:"ee-layer-mini-btn",title:m("layer_duplicate"),onClick:()=>(e=>{const t=ia(a,i,e);t&&(r(t.nextMap,t.nextRootOrder,"add"),s({id:t.newId,data:t.selectionData,type:"edit"}))})(e.id),children:l.jsx(n.FontAwesomeIcon,{icon:o.faCopy})}),d&&"column"===e.key&&"function"==typeof u?l.jsx("button",{type:"button",className:"ee-layer-mini-btn ee-layer-save-universal",title:m("save_as_universal"),"aria-label":m("save_as_universal"),onClick:t=>{t.stopPropagation(),window.dispatchEvent(new CustomEvent("ee:canvas-save-universal",{detail:{block:e}}))},children:l.jsx(n.FontAwesomeIcon,{icon:o.faStar})}):null,l.jsx("button",{type:"button",className:"ee-layer-mini-btn ee-layer-mini-btn-danger",title:m("layer_delete"),onClick:()=>(e=>{const n=a[e];if(!n)return;const o=()=>{const t=da(a,i,e,m);t&&(r(t.nextMap,t.nextRootOrder,"delete"),s(null))};"column"===n.key&&ca(a,e)?t.Modal.confirm({title:m("shortcut_delete_confirm_title"),content:m("shortcut_delete_confirm_desc"),okText:m("confirm"),cancelText:m("cancel"),wrapClassName:"ee-modal-dark",onOk:o}):o()})(e.id),children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash})})]}),l.jsx("button",{type:"button",className:"ee-layer-mini-btn ee-layer-row-vis",title:m(N?"layer_show":"layer_hide"),onClick:t=>{t.stopPropagation(),(e=>{const t=a[e];if(!t)return;const n={...a,[e]:{...t,hidden:!t.hidden}};r(n,i,"edit")})(e.id)},children:l.jsx(n.FontAwesomeIcon,{icon:N?o.faEyeSlash:o.faEye})})]}),"column"===e.key&&Array.isArray(e.cells)&&e.cells.map((t,n)=>{const o=t.childrenIds||[],i=e.cells.length>1;return l.jsxs("div",{children:[i&&l.jsx("div",{className:"ee-layer-cell-label",style:{paddingLeft:12+14*(c+1)},children:`${m("column")} ${n+1}`}),o.map(e=>{const t=a[e];return t&&"empty"!==t.key?k(t,c+2,!1,0,0):null})]},t.id||n)})]},e.id)};return l.jsxs("div",{className:"ee-layers-panel",onDragOver:e=>{p&&e.preventDefault()},onDrop:e=>{if(!p)return;e.preventDefault();const t=h??i.length;x(p,t),g(null),b(null)},children:[l.jsxs("div",{className:"ee-layers-header",children:[l.jsx("span",{children:m("layers")}),l.jsxs("span",{className:"ee-layers-header-count",children:[i.length," ",1===i.length?m("layer_one"):m("layer_many")]})]}),l.jsxs("button",{type:"button",className:fo("ee-layers-document",!y&&"ee-layers-document-active"),onClick:()=>s(null),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faFile}),l.jsx("span",{children:m("document")})]}),i.map((e,t)=>{const n=a[e];return k(n,1,!0,t,i.length)}),p&&h===i.length&&l.jsx("div",{className:"ee-layer-drop-indicator","aria-hidden":!0})]})},yi=[{key:"full",label:"1 column",desc:"Full-width section"},{key:"1-1",label:"2 columns",desc:"Equal halves"},{key:"1-1-1",label:"3 columns",desc:"Equal thirds"},{key:"1-1-1-1",label:"4 columns",desc:"Equal quarters"},{key:"1-2",label:"1 : 2",desc:"Narrow + wide"},{key:"2-1",label:"2 : 1",desc:"Wide + narrow"},{key:"1-3",label:"1 : 3",desc:"Sidebar + body"},{key:"3-1",label:"3 : 1",desc:"Body + sidebar"},{key:"2-3",label:"2 : 3",desc:"Off-center"},{key:"3-2",label:"3 : 2",desc:"Off-center"},{key:"1-2-1",label:"1 : 2 : 1",desc:"Hero + edges"},{key:"2-1-1",label:"2 : 1 : 1",desc:"Lead + two"},{key:"1-1-2",label:"1 : 1 : 2",desc:"Two + lead"}],_i=[{key:"6-col-equal",label:"6 cols equal",cols:6,parts:[1,1,1,1,1,1]},{key:"12-col-equal",label:"12 cols equal",cols:12,parts:[1,1,1,1,1,1,1,1,1,1,1,1]}],fi=["A","B","C","D"],xi=["A","B","C","D","E","F","G","H","I","J","K","L"],ki=({parts:e,rowCount:t})=>{const n=e.slice(0,Math.min(e.length,12)),o=Math.min(t,4);return l.jsxs("div",{className:"ee-grid-preview-wrap",children:[l.jsx("div",{className:"ee-grid-preview-heading",children:"Live preview"}),Array.from({length:o}).map((e,t)=>l.jsxs("div",{className:"ee-grid-preview-row",children:[l.jsx("div",{className:"ee-grid-preview-row-label",children:fi[t]}),n.map((e,n)=>l.jsxs("div",{className:"ee-grid-preview-cell",style:{flex:e},children:[xi[n],fi[t]]},n))]},t))]})},vi=e=>{const t="full"===e?[1]:e.split("-").map(e=>parseInt(e,10)),n=t.reduce((e,t)=>e+t,0);return l.jsx("div",{className:"ee-layout-preview",children:t.map((e,t)=>l.jsx("span",{className:"ee-layout-preview-cell",style:{flex:e/n}},t))})};function wi(e,t,n){const o=e[t]||e.full,a=e=>e&&"object"==typeof e?{...e,id:A(),...Array.isArray(e.children)?{children:e.children.map(a)}:{}}:e;return{id:A(),name:n("block_palette_columns"),key:"column",type:o.type,containerType:"none",layoutRole:pa,columnLayoutOnly:!0,styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},children:(o.children||[]).map(a)}}const ji=({open:a,onClose:i,columnRootId:r})=>{const{t:s}=So(),{columnsSetting:c}=Fa(),{blockMap:d,rootOrder:u,setBlocks:m,setCurrentItem:p}=e.useContext(ge),[g,h]=e.useState("1-1"),[b,y]=e.useState(1),[_,f]=e.useState(!1),[x,k]=e.useState("6-col-equal");e.useEffect(()=>{a&&(h("1-1"),y(1),f(!1))},[a]);const v=(()=>{if(_){const e=_i.find(e=>e.key===x);return e?e.parts:[1]}return"full"===g?[1]:g.split("-").map(e=>parseInt(e,10))})();return l.jsxs(t.Modal,{className:"ee-modal-dark ee-configure-columns-modal",title:s("configure_columns_title"),open:a,onCancel:i,footer:[l.jsx(t.Button,{onClick:i,children:s("cancel")},"cancel"),l.jsx(t.Button,{type:"primary",onClick:()=>{const e=_?"full":g;let t=d,n=[...u];const o=r&&"column"===t[r]?.key?r:null;let a=null;for(let l=0;l<b;l++){const i=wi(c,e,s);if(_){const e=_i.find(e=>e.key===x);if(e){i.type=e.key;const t=e.cols,n=`${(100/t).toFixed(4)}%`;i.children=Array.from({length:t},(e,t)=>({id:A(),name:s("content"),key:"content",width:n,styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{id:A(),name:s("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}]}))}}if(o&&0===l&&"column"===t[o]?.key){i.id=o,t=H(t,o);const{blockMap:e}=R([i]);t={...t,...e},a=o;continue}const{newBlockMap:r,rootId:d}=K(t,i);d&&(t=r,n=[...n,d],a=d)}m(t,n,"add"),null!=a&&t[a]&&p({id:a,data:t[a],type:"edit"}),i()},children:s("configure_columns_insert")},"insert")],width:660,destroyOnClose:!0,children:[l.jsx("p",{style:{color:"var(--ee-muted-foreground)",marginBottom:14},children:s("configure_columns_subtitle")}),l.jsxs("div",{className:"ee-layout-tab-group",role:"tablist","aria-label":"Layout type",children:[l.jsx("button",{type:"button",role:"tab","aria-selected":!_,className:fo("ee-layout-tab",!_&&"ee-layout-tab-active"),onClick:()=>f(!1),children:s("standard_layout")||"Standard"}),l.jsx("button",{type:"button",role:"tab","aria-selected":_,className:fo("ee-layout-tab",_&&"ee-layout-tab-active"),onClick:()=>f(!0),children:s("grid_layout")||"6/12 Grid"})]}),_?l.jsx("div",{style:{display:"flex",gap:8},children:_i.map(e=>l.jsxs("button",{type:"button",className:fo("ee-layout-card",x===e.key&&"ee-layout-card-active"),onClick:()=>k(e.key),style:{flex:1},children:[l.jsx("div",{className:"ee-layout-grid-mini-bar",children:e.parts.slice(0,6).map((e,t)=>l.jsx("span",{className:"ee-layout-grid-mini-cell"},t))}),l.jsx("div",{className:"ee-layout-card-label",children:e.label})]},e.key))}):l.jsx("div",{className:"ee-layout-grid",children:yi.filter(e=>c[e.key]).map(e=>l.jsxs("button",{type:"button",className:fo("ee-layout-card",g===e.key&&"ee-layout-card-active"),onClick:()=>h(e.key),children:[vi(e.key),l.jsx("div",{className:"ee-layout-card-label",children:e.label}),l.jsx("div",{className:"ee-layout-card-desc",children:e.desc})]},e.key))}),l.jsx(ki,{parts:v,rowCount:b}),l.jsxs("div",{className:"ee-row-count-row",children:[l.jsx("span",{children:s("configure_columns_row_count")||"Rows to insert:"}),l.jsx(t.Button,{className:"ee-configure-stepper-btn",type:"default",size:"small",icon:l.jsx(n.FontAwesomeIcon,{icon:o.faMinus}),onClick:()=>y(e=>Math.max(1,e-1)),disabled:b<=1}),l.jsx("span",{className:"ee-row-count-value",children:b}),l.jsx(t.Button,{className:"ee-configure-stepper-btn",type:"default",size:"small",icon:l.jsx(n.FontAwesomeIcon,{icon:o.faPlus}),onClick:()=>y(e=>Math.min(4,e+1)),disabled:b>=4})]})]})},Si="blocks",Ci="universal",Ni="layers",Ii=({clearStyles:t})=>{const{t:a}=So(),[i,r]=e.useState(Si),[s,c]=e.useState(!1),[d,u]=e.useState(null);e.useEffect(()=>{const e=e=>{u(e?.detail?.rootId??null),c(!0)};return window.addEventListener(ga,e),()=>window.removeEventListener(ga,e)},[]);const m=[{id:Si,label:a("blocks"),icon:o.faTh},{id:Ci,label:a("universal"),icon:o.faStar},{id:Ni,label:a("layers"),icon:o.faLayerGroup}];return l.jsxs("aside",{className:"ee-left-rail","aria-label":"Editor sidebar",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[l.jsx("div",{className:"ee-left-rail-tabs",role:"tablist",children:m.map(e=>l.jsxs("button",{type:"button",role:"tab","aria-selected":i===e.id,className:fo("ee-left-rail-tab",i===e.id&&"ee-left-rail-tab-active"),onClick:()=>r(e.id),children:[l.jsx(n.FontAwesomeIcon,{icon:e.icon}),l.jsx("span",{children:e.label})]},e.id))}),l.jsxs("div",{className:"ee-left-rail-body",children:[i===Si&&l.jsx(mi,{clearStyles:t,openConfigureColumnsModal:()=>{u(null),c(!0)}}),i===Ci&&l.jsx(pi,{clearStyles:t}),i===Ni&&l.jsx(bi,{})]}),l.jsx(ji,{open:s,columnRootId:d,onClose:()=>{c(!1),u(null)}})]})},Ai=({open:n,issues:o,onClose:a,onExportAnyway:i})=>{const{setCurrentItem:r,setActionType:s,blockMap:c}=e.useContext(ge),{t:d}=So(),u=e=>{var t;e?.blockId&&((t=e.blockId)&&c?.[t]&&(r({id:t,data:c[t],type:"edit"}),s("edit"),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const e="function"==typeof window.CSS?.escape?window.CSS.escape(String(t)):String(t).replace(/([ #;?%&,.+*~':"!^$[\]()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${e}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),1)&&a())},m=(e,t)=>{const n=Boolean(e?.blockId),o=`validation_${e.code}`,a=d(o),i=a&&a!==o?a:e.message;return l.jsx("li",{className:"export-validation-issue-item",children:l.jsxs("button",{type:"button",className:"export-validation-issue-btn "+(n?"is-clickable":""),onClick:()=>u(e),disabled:!n,children:[l.jsx("span",{className:"export-validation-issue-copy",children:i}),n&&l.jsx("span",{className:"export-validation-issue-action",children:d("export_validation_open_block")||"Open block"})]})},t)},p=(o||[]).filter(e=>"error"===e.severity),g=(o||[]).filter(e=>"warning"===e.severity),h=(o||[]).filter(e=>"info"===e.severity);return l.jsxs(t.Modal,{className:"ee-modal-dark",title:d("export_validation_title"),open:n,onCancel:a,footer:[l.jsx(t.Button,{onClick:a,children:d("cancel")},"cancel"),l.jsx(t.Button,{type:"primary",onClick:i,children:d("export_anyway")},"export")],width:520,destroyOnClose:!0,children:[l.jsx("p",{style:{marginBottom:12},children:d("export_validation_issues_found")}),l.jsxs("div",{style:{maxHeight:360,overflowY:"auto"},children:[p.length>0&&l.jsxs("div",{style:{marginBottom:12},children:[l.jsxs("div",{className:"export-validation-errors-heading",style:{fontWeight:600,marginBottom:6},children:[d("export_validation_errors")," (",p.length,")"]}),l.jsx("ul",{className:"export-validation-issue-list",children:p.map((e,t)=>m(e,`e-${t}`))})]}),g.length>0&&l.jsxs("div",{style:{marginBottom:12},children:[l.jsxs("div",{className:"export-validation-warnings-heading",style:{fontWeight:600,marginBottom:6},children:[d("export_validation_warnings")," (",g.length,")"]}),l.jsx("ul",{className:"export-validation-issue-list",children:g.map((e,t)=>m(e,`w-${t}`))})]}),h.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"export-validation-info-heading",style:{fontWeight:600,marginBottom:6},children:[d("export_validation_info")," (",h.length,")"]}),l.jsx("ul",{className:"export-validation-issue-list",children:h.map((e,t)=>m(e,`i-${t}`))})]})]})]})},{Option:Ti}=t.Select,Li=[{value:"none",label:"No payload"},{value:"profile",label:"Profile data"},{value:"event",label:"Event data"}],Bi=({open:n,onClose:o,onSend:a,templateName:i})=>{const{t:r}=So(),[s,c]=e.useState([]),[d,u]=e.useState(""),[m,p]=e.useState("none"),[g,h]=e.useState(!0),[b,y]=e.useState(!1),_=e=>{const t=String(e||"").trim();if(!t)return;const n=t.split(/[\s,;]+/).filter(Boolean);c(e=>{const t=new Set(e);return n.forEach(e=>t.add(e)),Array.from(t)}),u("")},f=e=>{c(t=>t.filter(t=>t!==e))},x=()=>{c([]),u(""),p("none"),h(!0),y(!1),o?.()};return l.jsx(t.Modal,{className:"ee-modal-dark",title:r("send_test_title")||"Send test email",open:n,onCancel:x,footer:[l.jsx(t.Button,{onClick:x,disabled:b,children:r("cancel")},"cancel"),l.jsx(t.Button,{type:"primary",onClick:async()=>{if(0!==s.length){y(!0);try{await Promise.resolve(a?.({recipients:s,payloadType:m,testPrefix:g,subjectPrefix:g?"[TEST] ":"",name:i||"Untitled template"})),x()}finally{y(!1)}}},loading:b,disabled:0===s.length,children:r("send_test_send")||"Send test"},"send")],width:480,destroyOnClose:!0,children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:6,fontSize:13,fontWeight:500},children:r("send_test_recipients")||"Recipients"}),l.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,minHeight:36,padding:"4px 8px",border:"1px solid var(--ee-border, #374151)",borderRadius:6,backgroundColor:"var(--ee-surface, #1a1a1a)",cursor:"text"},onClick:()=>document.getElementById("ee-send-test-input")?.focus(),children:[s.map(e=>l.jsx(t.Tag,{closable:!0,onClose:()=>f(e),style:{margin:2},children:e},e)),l.jsx(t.Input,{id:"ee-send-test-input",bordered:!1,value:d,style:{flex:1,minWidth:160,padding:0},placeholder:0===s.length?r("send_test_recipients_placeholder")||"name@example.com, another@example.com":"",onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key&&","!==e.key&&" "!==e.key&&"Tab"!==e.key||(e.preventDefault(),_(d)),"Backspace"===e.key&&!d&&s.length>0&&f(s[s.length-1])},onBlur:()=>{d.trim()&&_(d)}})]}),l.jsx("div",{style:{fontSize:11,color:"var(--ee-muted-foreground)",marginTop:4},children:r("send_test_recipients_hint")||"Press Enter or comma to add each address."})]}),l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:6,fontSize:13,fontWeight:500},children:r("send_test_payload")||"Payload context"}),l.jsx(t.Select,{style:{width:"100%"},value:m,onChange:p,getPopupContainer:()=>document.querySelector(".email-editor")||document.body,children:Li.map(e=>l.jsx(Ti,{value:e.value,children:r(`send_test_payload_${e.value}`)||e.label},e.value))})]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderRadius:6,backgroundColor:"var(--ee-surface, #1a1a1a)",border:"1px solid var(--ee-border, #374151)"},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:13,fontWeight:500},children:r("send_test_prefix_label")||"[TEST] prefix"}),l.jsx("div",{style:{fontSize:12,color:"var(--ee-muted-foreground)"},children:r("send_test_prefix_hint")||"Prepends [TEST] to the subject line."})]}),l.jsx(t.Switch,{checked:g,onChange:h})]})]})})},$i=({templateName:a,onTemplateNameChange:i,onBack:r,onPreview:s,onSendTest:c,onSaveTemplate:d,onShowShortcuts:u,onSendTestIntent:m,onSaveTemplateIntent:p,saveStatusDetail:g,onExit:h,hideOverflowExportActions:b=!1})=>{const{previewMode:y,setPreviewMode:_,canUndo:f,canRedo:x,undo:k,redo:v,blockList:w,bodySettings:j,templateData:S,saveState:C,highContrastEditor:N,setHighContrastEditor:I,filterIgnoredValidationIssues:A}=e.useContext(ge),{t:T}=So(),[L,B]=e.useState(!1),[$,R]=e.useState(a||""),[M,P]=e.useState(!1),[F,E]=e.useState(!1),[D,U]=e.useState([]),[z,O]=e.useState(null),[W,H]=e.useState(!1),[V,K]=e.useState(!1),[G,q]=e.useState(!1),[J,Y]=e.useState(""),[X,Z]=e.useState(!1),[Q,ee]=e.useState("desktop"),te=e.useRef(null);e.useEffect(()=>{X&&ee("desktop")},[X]);const ne=e.useMemo(()=>{if(!X)return{html:"",error:null};try{return{html:Sn({bodySettings:j,blockList:w,templateData:S??void 0})??"",error:null}}catch(e){return console.error("[EmailEditor] HTML preview generation failed:",e),{html:"",error:T("html_email_preview_error")}}},[X,j,w,S,T]);e.useEffect(()=>{R(a||"")},[a]),e.useEffect(()=>{if(!M)return;const e=e=>{te.current&&!te.current.contains(e.target)&&P(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[M]);const oe=()=>{B(!1),"function"==typeof i&&$!==a&&i($)},ae=e.useCallback(e=>{const t={},n=(e,o=[])=>{Array.isArray(e)&&e.forEach(e=>{if(!e||"object"!=typeof e)return;const a={blockId:e.id??null,key:e.key??null,containerType:"column"===e.key?e.containerType??"none":null},l=[...o,a];if("text"===e.key&&"dynamic"===e.contentType){const n="string"==typeof e.dynamicPrompt?e.dynamicPrompt.trim():"",o="string"==typeof e.dynamicSelectedContent?e.dynamicSelectedContent.trim():"";if(!n&&!o)return;t[e.id]={blockId:e.id,path:l,key:e.key,type:e.type||"p",selectedContent:o,options:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[],prompt:n,variable:e.dynamicVariable??"",language:"bn-BD"===e.dynamicAiLanguage?"bn-BD":"en"}}Array.isArray(e.children)&&n(e.children,l)})};return n(e,[]),t},[]),le=e.useCallback(e=>Array.isArray(e)?e.map(e=>{if(!e||"object"!=typeof e)return e;const{dynamicPrompt:t,dynamicOptions:n,dynamicSelectedContent:o,dynamicVariable:a,dynamicAiLanguage:l,staticTextBeforeAi:i,children:r,...s}=e;return{...s,children:le(r)}}):e,[]),ie=e.useCallback(()=>({blockList:le(w??[]),bodySettings:j??null,aiContentRefs:ae(w??[]),language:Vn(w??[])}),[w,j,ae,le]),re=()=>{const e=ie(),t=JSON.stringify(e,null,2),n=new Blob([t],{type:"application/json"}),o=document.createElement("a");o.download=`${a||"email-template"}.json`,o.href=URL.createObjectURL(n),o.click()},se=()=>{const e=Sn({bodySettings:j,blockList:w,templateData:S});if(null==e)return;const t=new Blob([e],{type:"text/html"}),n=document.createElement("a");n.download=`${a||"email-template"}.html`,n.href=URL.createObjectURL(t),n.click()},ce=async e=>{H(!0);try{const t=ie();let n=uo({blockList:t.blockList??[],bodySettings:t.bodySettings??null,aiContentRefs:t.aiContentRefs??{}});const o=await yo(t.blockList??[]);if(n=[...n,...o],"function"==typeof A&&(n=A(n)),0===n.length)return void("html"===e?se():re());U(n),O(e),E(!0)}finally{H(!1)}},de=()=>{E(!1),U([]),O(null)},ue="function"==typeof m||"function"==typeof c,me="function"==typeof p||"function"==typeof d,pe="function"==typeof m,he="function"==typeof p;return l.jsxs("header",{className:"ee-topbar",children:["function"==typeof r&&"function"!=typeof h&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:"ee-topbar-back",onClick:r,"aria-label":T("topbar_back_to_templates"),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faChevronLeft}),l.jsx("span",{children:T("topbar_back_to_templates")})]}),l.jsx("div",{className:"ee-topbar-divider","aria-hidden":!0})]}),l.jsxs("div",{className:"ee-topbar-breadcrumb",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faEnvelope}),l.jsx("span",{children:T("topbar_breadcrumb_email")}),l.jsx(n.FontAwesomeIcon,{icon:o.faChevronRight,className:"ee-topbar-breadcrumb-sep"}),L?l.jsx("input",{autoFocus:!0,className:"ee-topbar-name-input",value:$,onChange:e=>R(e.target.value),onBlur:oe,onKeyDown:e=>{"Enter"===e.key?oe():"Escape"===e.key&&(R(a||""),B(!1))},"aria-label":T("topbar_rename_template")}):l.jsx("button",{type:"button",className:"ee-topbar-name-btn",onClick:()=>{"function"==typeof i&&B(!0)},title:"function"==typeof i?T("topbar_rename_template"):void 0,children:a||T("topbar_untitled_template")})]}),l.jsxs("div",{className:"ee-topbar-spacer",children:[(g||C)&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"ee-topbar-status-cluster ee-topbar-status-cluster--lead",children:[l.jsx("span",{className:fo("header-save-state","saved"===C&&"header-save-state_saved","saving"===C&&"header-save-state_saving","unsaved"===C&&"header-save-state_unsaved","error"===C&&"header-save-state_error"),"aria-label":`save-state-${C}`,children:g||C&&(T(`save_state_${C}`)||C)}),"saved"===C&&l.jsx(n.FontAwesomeIcon,{icon:o.faCheckCircle,className:"ee-topbar-saved-check","aria-hidden":!0}),"saving"===C&&l.jsx(n.FontAwesomeIcon,{icon:o.faSpinner,spin:!0,className:"ee-topbar-saving-spinner","aria-hidden":!0})]}),l.jsx("div",{className:"ee-topbar-divider","aria-hidden":!0})]}),l.jsx("button",{type:"button",className:"ee-topbar-icon-btn",onClick:k,disabled:!f,title:T("undo"),"aria-label":T("undo"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faUndo})}),l.jsx("button",{type:"button",className:"ee-topbar-icon-btn",onClick:v,disabled:!x,title:T("redo"),"aria-label":T("redo"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faRedo})}),l.jsx("div",{className:"ee-topbar-divider","aria-hidden":!0}),l.jsxs("div",{className:"ee-topbar-segment",role:"tablist","aria-label":"Device preview",children:[l.jsx("button",{type:"button",role:"tab","aria-selected":"desktop"===y,className:fo("ee-topbar-segment-btn","desktop"===y&&"ee-topbar-segment-btn-active"),onClick:()=>_("desktop"),title:T("desktop"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faDesktop})}),l.jsx("button",{type:"button",role:"tab","aria-selected":"mobile"===y,className:fo("ee-topbar-segment-btn","mobile"===y&&"ee-topbar-segment-btn-active"),onClick:()=>_("mobile"),title:T("mobile"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faMobileAlt})})]}),l.jsx("button",{type:"button",className:"ee-topbar-icon-btn",onClick:()=>Z(!0),title:T("html_email_preview"),"aria-label":T("html_email_preview"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faEye})}),l.jsx("div",{className:"ee-topbar-divider","aria-hidden":!0}),ue&&l.jsxs("button",{type:"button",className:"ee-topbar-btn ee-topbar-btn-ghost ee-topbar-btn-send-test",onClick:()=>{"function"!=typeof m?"function"==typeof c&&K(!0):m()},title:T("send_test"),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faPaperPlane}),l.jsx("span",{className:"ee-topbar-btn-label",children:T("send_test")})]}),"function"==typeof s&&l.jsxs("button",{type:"button",className:"ee-topbar-btn ee-topbar-btn-outline",onClick:()=>{"function"==typeof s&&s()},title:T("preview"),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faExternalLinkAlt}),l.jsx("span",{className:"ee-topbar-btn-label",children:T("preview")})]}),me&&l.jsxs("button",{type:"button",className:"ee-topbar-btn ee-topbar-btn-primary",onClick:()=>{"function"!=typeof p?"function"==typeof d&&q(!0):p()},title:T("save_template"),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faSave}),l.jsx("span",{className:"ee-topbar-btn-label",children:T("save_template")})]}),l.jsxs("div",{className:"ee-topbar-overflow-wrap",ref:te,children:[l.jsx("button",{type:"button",className:"ee-topbar-icon-btn",onClick:()=>P(e=>!e),"aria-haspopup":"true","aria-expanded":M,"aria-label":T("more_actions"),title:T("more_actions"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faEllipsisV})}),M&&l.jsxs("div",{className:"ee-topbar-overflow-menu",role:"menu",children:[!b&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",role:"menuitem",className:"ee-topbar-overflow-item",disabled:W,onClick:()=>{P(!1),ce("json")},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faFileExport}),l.jsx("span",{children:T("export_json")})]}),l.jsxs("button",{type:"button",role:"menuitem",className:"ee-topbar-overflow-item",disabled:W,onClick:()=>{P(!1),ce("html")},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faFileCode}),l.jsx("span",{children:T("export_html")})]})]}),"function"==typeof u&&l.jsxs(l.Fragment,{children:[!b&&l.jsx("div",{className:"ee-topbar-overflow-divider","aria-hidden":!0}),l.jsxs("button",{type:"button",role:"menuitem",className:"ee-topbar-overflow-item",onClick:()=>{P(!1),u()},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faKeyboard}),l.jsx("span",{children:T("keyboard_shortcuts")})]})]}),"function"==typeof I&&l.jsxs("button",{type:"button",role:"menuitem",className:"ee-topbar-overflow-item",onClick:()=>{I(e=>!e),P(!1)},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faAdjust}),l.jsx("span",{children:T(N?"high_contrast_off":"high_contrast_on")})]})]})]}),"function"==typeof h&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ee-topbar-divider ee-topbar-divider-exit","aria-hidden":!0}),l.jsx("button",{type:"button",className:"ee-topbar-exit-btn",onClick:h,children:T("topbar_exit")||"Exit"})]})]}),l.jsx(t.Modal,{className:"ee-modal-dark ee-html-preview-modal",title:l.jsxs("div",{className:"ee-html-preview-modal-header-inner",children:[l.jsx("span",{className:"ee-html-preview-modal-title-text",children:T("html_email_preview_title")}),l.jsxs("div",{className:"ee-topbar-segment ee-html-preview-modal-segment",role:"tablist","aria-label":T("html_email_preview_device_aria"),onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:[l.jsx("button",{type:"button",role:"tab","aria-selected":"desktop"===Q,className:fo("ee-topbar-segment-btn","desktop"===Q&&"ee-topbar-segment-btn-active"),onClick:()=>ee("desktop"),title:T("desktop"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faDesktop})}),l.jsx("button",{type:"button",role:"tab","aria-selected":"mobile"===Q,className:fo("ee-topbar-segment-btn","mobile"===Q&&"ee-topbar-segment-btn-active"),onClick:()=>ee("mobile"),title:T("mobile"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faMobileAlt})})]})]}),open:X,onCancel:()=>Z(!1),footer:null,width:"min(960px, 96vw)",centered:!0,destroyOnClose:!0,children:ne.error?l.jsx("p",{className:"ee-html-preview-error",children:ne.error}):l.jsx("div",{className:fo("ee-html-preview-viewport","mobile"===Q&&"ee-html-preview-viewport--mobile"),children:l.jsx("iframe",{title:T("html_email_preview_title"),className:"ee-html-preview-iframe",sandbox:"allow-same-origin allow-popups allow-popups-to-escape-sandbox",srcDoc:ne.html})})}),l.jsx(Ai,{open:F,issues:D,onClose:de,onExportAnyway:()=>{"html"===z?se():"json"===z&&re(),de()}}),!pe&&"function"==typeof c&&l.jsx(Bi,{open:V,templateName:a,onClose:()=>K(!1),onSend:e=>{if("function"!=typeof c)return;const t=ie();c({...t,name:a||"Untitled template",recipients:e.recipients,payloadType:e.payloadType,subjectPrefix:e.subjectPrefix})}}),!he&&"function"==typeof d&&l.jsx(t.Modal,{className:"ee-modal-dark",title:T("save_template_title")||"Save template",open:G,onCancel:()=>{q(!1),Y("")},onOk:()=>{if("function"!=typeof d)return;const e=ie();d({...e,name:a||"Untitled template",category:J}),q(!1),Y("")},okText:T("save")||"Save",cancelText:T("cancel"),width:420,destroyOnClose:!0,children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:6,fontSize:13,fontWeight:500},children:T("template_name")||"Template name"}),l.jsx(t.Input,{value:a||T("topbar_untitled_template"),readOnly:!0})]}),l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:6,fontSize:13,fontWeight:500},children:T("save_template_category")||"Category"}),l.jsx(t.Select,{style:{width:"100%"},value:J||void 0,placeholder:T("save_template_category_placeholder")||"Select or type a category…",allowClear:!0,showSearch:!0,onChange:e=>Y(e||""),getPopupContainer:()=>document.querySelector(".email-editor")||document.body,options:[{value:"promotional",label:T("category_promotional")||"Promotional"},{value:"transactional",label:T("category_transactional")||"Transactional"},{value:"newsletter",label:T("category_newsletter")||"Newsletter"},{value:"onboarding",label:T("category_onboarding")||"Onboarding"},{value:"announcement",label:T("category_announcement")||"Announcement"},{value:"other",label:T("category_other")||"Other"}]})]})]})})]})},Ri=({keys:e,desc:t})=>l.jsxs("div",{className:"ee-shortcuts-row",children:[l.jsx("span",{className:"ee-shortcuts-row-desc",children:t}),l.jsx("kbd",{className:"ee-shortcuts-kbd",children:e})]}),Mi=({open:e,onClose:n})=>{const{t:o}=So(),a=/Mac|iPhone|iPod|iPad/i.test("undefined"!=typeof navigator&&navigator.platform||"")?"⌘":"Ctrl";return l.jsxs(t.Modal,{wrapClassName:"ee-modal-dark ee-shortcuts-modal",title:o("shortcuts_modal_title"),open:e,onCancel:n,footer:null,width:520,destroyOnClose:!0,children:[l.jsx(Ri,{keys:`${a} + S`,desc:o("shortcut_save")}),l.jsx(Ri,{keys:`${a} + Z`,desc:o("shortcut_undo")}),l.jsx(Ri,{keys:`${a} + Shift + Z / ${a} + Y`,desc:o("shortcut_redo")}),l.jsx(Ri,{keys:`${a} + D`,desc:o("shortcut_duplicate")}),l.jsx(Ri,{keys:`${a} + C`,desc:o("shortcut_copy_block")}),l.jsx(Ri,{keys:`${a} + V`,desc:o("shortcut_paste_block")}),l.jsx(Ri,{keys:"Delete / Backspace",desc:o("shortcut_delete_block")}),l.jsx(Ri,{keys:"Esc",desc:o("shortcut_escape")}),l.jsx(Ri,{keys:"?",desc:o("shortcut_cheat_sheet")}),l.jsx("p",{className:"ee-shortcuts-footnote",children:o("shortcuts_modal_footnote")})]})},Pi=({language:n})=>{const{blockMap:o,rootOrder:a,setBlocks:i,currentItem:r,setCurrentItem:s,setIsDragStart:c,setLanguage:d,templateData:u,highContrastEditor:m,canUndo:p,canRedo:g,undo:h,redo:b,flushPendingRichText:y,onShortcutSave:_,templateName:f,onTemplateNameChange:x,onBack:k,onSaveTemplate:v,onSaveTemplateIntent:w,onSendTest:j,onSendTestIntent:S,saveStatusDetail:C,onExit:N,onPreview:I,hideOverflowExportActions:A}=e.useContext(ge),{t:T}=So(),{getColumnConfig:L}=Fa(),[R,P]=e.useState(!1),E=e=>{if(!e||"object"!=typeof e)return e;const t=u?.content?.products,n=u?.catalogProducts,o=u?.content?.primaryProductId,a=Array.isArray(t)&&t.length>0?t:Array.isArray(n)&&n.length>0?n:el,l=o?a.find(e=>e.id===o):a[0],i=l?a.filter(e=>e?.id!==l.id):a,r=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(r):e.children;if("column"!==e.key||"product"!==e.containerType||!l)return{...e,children:t};const n=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),o="additional"===e.productRole?"additional":"main",a=Array.from({length:n},(e,t)=>"main"===o||0===i.length?l:i[t%i.length]);return{...e,children:t,columnProducts:a}};return r(e)};e.useEffect(()=>{d(n)},[n,d]),e.useEffect(()=>{const e=e=>{if(n=e.target,!Boolean(n&&n.closest&&n.closest(".email-editor")))return;var n;const l=e.metaKey||e.ctrlKey,c=e.key,d=(u=e.target,Boolean(u?.closest?.(".text-content_editable[contenteditable='true']")));var u;const m=(e=>{if(!e)return!1;const t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||"SELECT"===t||Boolean(e.closest?.(".ant-input, .ant-input-number, textarea.ant-input, .ant-select-selection-search-input"))})(e.target);if(l&&"s"===String(c).toLowerCase())"function"==typeof _&&(e.preventDefault(),e.stopPropagation(),_());else if(d){if(l&&"z"===String(c).toLowerCase()&&!e.shiftKey){if(!p)return;return e.preventDefault(),e.stopPropagation(),y(),void h()}if(l&&("z"===String(c).toLowerCase()&&e.shiftKey||"y"===String(c).toLowerCase())){if(!g)return;return e.preventDefault(),e.stopPropagation(),y(),void b()}}else if(!m){if(l&&"z"===String(c).toLowerCase()&&!e.shiftKey){if(!p)return;return e.preventDefault(),y(),void h()}if(l&&("z"===String(c).toLowerCase()&&e.shiftKey||"y"===String(c).toLowerCase())){if(!g)return;return e.preventDefault(),y(),void b()}if(l&&"d"===String(c).toLowerCase()){if(!r?.id||"add"===r.type)return;e.preventDefault();const t=ia(o,a,r.id);if(!t)return;return i(t.nextMap,t.nextRootOrder,"add"),void s({id:t.newId,data:t.selectionData,type:"edit"})}if(l&&"c"===String(c).toLowerCase()){if(!r?.id||"add"===r.type)return;e.preventDefault();const t=la(o,a,r.id);return void(t&&(aa.tree=t))}if(l&&"v"===String(c).toLowerCase()){if(!aa.tree)return;e.preventDefault();const t=r?.id&&o[r.id]?r.id:null,n=sa(o,a,aa.tree,t);if(!n)return;return i(n.nextMap,n.nextRootOrder,"add"),void s({id:n.newId,data:n.selectionData,type:"edit"})}if("Escape"===c)return e.preventDefault(),P(!1),void s(null);if("?"===c||e.shiftKey&&"Slash"===e.code)return e.preventDefault(),void P(!0);if("Backspace"===c||"Delete"===c){if(!r?.id||"add"===r.type)return;const n=r.id,l=o[n];if(!l)return;const c=()=>{const e=da(o,a,n,T);e&&(i(e.nextMap,e.nextRootOrder,"delete"),s(null))};if("column"===l.key&&ca(o,n))return e.preventDefault(),void t.Modal.confirm({title:T("shortcut_delete_confirm_title"),content:T("shortcut_delete_confirm_desc"),okText:T("confirm"),cancelText:T("cancel"),wrapClassName:"ee-modal-dark",onOk:c});e.preventDefault(),c()}}};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[o,a,r,i,s,p,g,h,b,y,_,T]);const D=()=>{const e=document.getElementsByClassName("block-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},W=()=>{const e=document.getElementsByClassName("block-content-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},H=()=>{document.querySelectorAll(".block-empty-content").forEach(e=>{e.style.border=""})},G=()=>{document.querySelectorAll('[data-type="empty-block"]').forEach(e=>{e.style.border=""})},q=()=>{document.querySelectorAll('[data-drag-hovered="true"]').forEach(e=>{delete e.dataset.dragHovered})},J=e=>{const t=e?.closest?.(".block-item[data-block-id], .block[data-block-id]")||null;document.querySelectorAll('[data-drag-hovered="true"]').forEach(e=>{e!==t&&delete e.dataset.dragHovered}),t&&(t.dataset.dragHovered="true")},Y=()=>{D(),W(),H(),G(),q()},X=e.useCallback(e=>{e.preventDefault(),e.stopPropagation();const t=e.target,{type:n}=t.dataset||{};switch(n){case"empty-block":D(),W(),q(),t.style.border="2px dashed var(--ee-drop-target-outline)";break;case"drag-over-column":{W(),J(t);const e=t.dataset.index,n=document.getElementsByClassName("block-drag-label-content");Array.from(n).forEach(t=>{const n=Number(t.dataset.index)===Number(e),o=t.querySelector(".block-move-top"),a=t.querySelector(".block-move-bottom");o&&(o.style.visibility=n?"visible":"hidden"),a&&(a.style.visibility=n?"visible":"hidden")});break}case"block-item-move":{D(),J(t);const e=t.dataset.dropKey,n=document.getElementsByClassName("block-content-drag-label-content");Array.from(n).forEach(t=>{t.dataset.dropKey===e?t.children[0].style.visibility="visible":t.children[0].style.visibility="hidden"});break}case"empty-block-item":D(),W(),J(t),t.classList?.contains("block-empty-content")&&(t.style.border="2px dashed var(--ee-drop-target-outline)");break;default:D(),W(),q()}},[]),Z=(e,t)=>{const{blockMap:n,removedId:o}=z(e,t.containerId,t.cellIndex,t.itemIndex);return{result:n,removedId:o}},Q=(e,t,n,o)=>{const a=e[t];if(!a||a.cells[n].childrenIds.length>0)return e;const l=$(o("drag_block_here"));return{...e,[l.id]:l,[t]:{...a,cells:a.cells.map((e,t)=>t===n?{...e,childrenIds:[l.id]}:e)}}},ee=(e,t,n)=>{if(!t||!n)return!1;if(t===n)return!0;const o=t=>{const a=e[t];if(!a||"column"!==a.key)return!1;for(const e of a.cells||[])for(const t of e.childrenIds||[]){if(t===n)return!0;if(o(t))return!0}return!1};return o(t)};return l.jsxs(l.Fragment,{children:[l.jsx(Mi,{open:R,onClose:()=>P(!1)}),l.jsxs("div",{className:"email-editor"+(m?" ee-high-contrast":""),onDragOver:X,onDrop:e=>{e.preventDefault(),e.stopPropagation();const{type:n}=e.target.dataset;q(),H(),G(),c(!1);const l="undefined"!=typeof window?window.__eeDragItemData:null,d=()=>{"undefined"!=typeof window&&(window.__eeDragItemData=null,window.__eeDragSource=null)},u="add"===r?.type&&null!=r?.data,m=u||l?"add":r?.type,p=u?function(e){if(!e||"object"!=typeof e)return e;const t="column"===e.key&&Array.isArray(e.children)&&e.children.length>0;if("column"===e.key&&Array.isArray(e.cells)&&e.cells.length>0&&!t){const t=V(e,e.blockMap||e.blockSnapshotMap||{});if(t?.blockMap&&t.rootId){const e=M(t.blockMap,[t.rootId])[0];if(e)return B(e)}}return B(e)}(r.data):l?B(l):r?.data??null;if(p){switch(n){case"empty-block":{const e="column"===p.key?p:L(p),t=E(e),{newBlockMap:n,rootId:a}=K(o,t);if(!a)return void d();i(n,[a],"add"),s({id:a,data:n[a],type:"edit"}),"add"===m&&"column"===n[a]?.key&&ua(n[a])===pa&&ha(a);break}case"empty-block-item":{H();const n=e.target.dataset.containerId,l=Number(e.target.dataset.cellIndex),c=Number(e.target.dataset.itemIndex);if(!n)return void d();if("column"===p.key||"add"!==m&&r?.id&&"column"===o[r.id]?.key)return t.message.warning(T("section_nest_not_allowed")),d(),void Y();let u={...o};if("add"===m){const e=B(p),t=E(e),{newBlockMap:o,rootId:r}=K(u,t);if(!r)return void d();u=U(o,n,l,c,r),i(u,a,"add"),s({id:r,data:u[r],type:"edit"})}else{const e=r.id;if(ee(u,e,n))return d(),void Y();const t=F(u,a,e);if(!t)return void d();{const{result:e,removedId:o}=Z(u,t);u=e?Q(e,t.containerId,t.cellIndex,T):u,o&&(u=U(u,n,l,c,o))}i(u,a,"move"),s({...r,data:u[e]??r.data,type:"edit"})}break}case"drag-over-column":{const t=Number(e.target.dataset.index);let n,l=[...a],c={...o};if("add"===m){const e=B(p);if("column"===e.key){const o=E(e),{newBlockMap:a,rootId:i}=K(c,o);if(!i)return void d();c=a,l.splice(t,0,i),n={id:i,data:c[i],type:"edit"}}else{const o=t>=l.length?l[l.length-1]:l[t],a=c[o];if(!a||"column"!==a.key)return void d();const{newBlockMap:i,rootId:r}=K(c,e);if(!r)return void d();c=i;const s=0,u=c[o]?.cells?.[s],m=u?.childrenIds?.[0],p=m?c[m]:null;if("empty"===p?.key)c=U(c,o,s,0,r);else{c=O(c,o,s,u?.childrenIds?.length??0,r)}n={id:r,data:c[r],type:"edit"}}}else{const e=r.id,o=a.indexOf(e);if(-1===o)return void d();l.splice(o,1),l.splice(t>o?t-1:t,0,e),n={...r,type:"edit"}}i(c,l,"move"),s(n),"add"===m&&"column"===n?.data?.key&&ua(n.data)===pa&&ha(n.id),setTimeout(()=>{const e=document.getElementsByClassName("block-drag-label-content");Array.from(e).forEach(e=>{const t=e.querySelector(".block-move-top");t&&(t.style.visibility="hidden")})},30);break}case"block-item-move":{const n=e.target.dataset.dropKey;if(!n)return void d();const[l,c,u]=n.split(":"),g=Number(c),h=Number(u);let b,y={...o};if("add"===m){if("column"===p.key)return t.message.warning(T("section_nest_not_allowed")),d(),void Y();const e=B(p),n=E(e),{newBlockMap:o,rootId:a}=K(y,n);if(!a)return void d();y=O(o,l,g,h,a),b={id:a,data:y[a],type:"edit"}}else{const e=r.id;if("column"===y[e]?.key)return t.message.warning(T("section_nest_not_allowed")),d(),void Y();if(ee(y,e,l))return d(),void Y();const n=F(y,a,e);if(!n)return void d();const{blockMap:o,removedId:i}=z(y,n.containerId,n.cellIndex,n.itemIndex);y=o;const s=y[n.containerId];if(s&&0===s.cells[n.cellIndex].childrenIds.length){const e=$(T("drag_block_here"));y={...y,[e.id]:e,[n.containerId]:{...s,cells:s.cells.map((t,o)=>o===n.cellIndex?{...t,childrenIds:[e.id]}:t)}}}let c=h;n.containerId===l&&n.cellIndex===g&&n.itemIndex<h&&(c=h-1),y=O(y,l,g,c,i),b={...r,type:"edit"}}i(y,a,"move"),s(b),setTimeout(()=>{const e=document.getElementsByClassName("block-content-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},30);break}}d()}else d()},onDragLeave:e=>{const t=e.currentTarget,n=e.relatedTarget,o=e.target;setTimeout(()=>{if(t&&t.contains(n))switch(o?.dataset?.type){case"empty-block":o.style.border="";break;case"empty-block-item":o?.classList?.contains("block-empty-content")&&(o.style.border="")}else Y()},50)},children:[l.jsx($i,{templateName:f,onTemplateNameChange:x,onBack:k,onSaveTemplate:v,onSaveTemplateIntent:w,onSendTest:j,onSendTestIntent:S,saveStatusDetail:C,onExit:N,onPreview:I,hideOverflowExportActions:A,onShowShortcuts:()=>P(!0)}),l.jsxs("div",{className:"email-editor-main",onClick:e=>{e.preventDefault(),e.stopPropagation(),s(null)},children:[l.jsx(Ii,{clearStyles:Y}),l.jsx(Ca,{clearStyles:Y}),l.jsx(ai,{clearStyles:Y})]})]})]})},Fi="markopolo-email-editor:undo:";const Ei=e=>Array.isArray(e)?e.map(e=>e&&"object"==typeof e?{...e,children:Ei(e.children)}:e):e&&"object"==typeof e?Object.values(e).map(e=>e&&"object"==typeof e?{...e,children:Ei(e.children)}:e):[],Di=e=>{const t={},n=(e,o=[])=>{Array.isArray(e)&&e.forEach(e=>{if(!e||"object"!=typeof e)return;const a={blockId:e.id??null,key:e.key??null,containerType:"column"===e.key?e.containerType??"none":null},l=[...o,a];if("text"===e.key&&"dynamic"===e.contentType){const n="string"==typeof e.dynamicPrompt?e.dynamicPrompt.trim():"",o="string"==typeof e.dynamicSelectedContent?e.dynamicSelectedContent.trim():"";if(!n&&!o)return;t[e.id]={blockId:e.id,path:l,key:e.key,type:e.type||"p",selectedContent:o,options:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[],prompt:n,variable:e.dynamicVariable??"",language:"bn-BD"===e.dynamicAiLanguage?"bn-BD":"en"}}Array.isArray(e.children)&&n(e.children,l)})};return n(e,[]),t},Ui=e=>Array.isArray(e)?e.map(e=>{if(!e||"object"!=typeof e)return e;const{dynamicPrompt:t,dynamicOptions:n,dynamicSelectedContent:o,dynamicVariable:a,dynamicAiLanguage:l,staticTextBeforeAi:i,children:r,...s}=e;return{...s,children:Ui(r)}}):e,zi=e.forwardRef(({defaultBlockList:t,defaultBodySettings:n,aiContentRefs:o,language:a="en",customLanguageLibraries:i,templateData:r,variableDefinitions:s,apiConfig:c={},aiEnabled:d=!0,saveState:u="saved",onChange:m,undoPersistenceKey:p=null,onShortcutSave:g,onSaveBlockAsGlobal:h,templateName:b="",onTemplateNameChange:y,onBack:f,onSaveTemplate:x,onSaveTemplateIntent:k,onSendTest:w,onSendTestIntent:j,saveStatusDetail:S,onExit:C,onPreview:N,hideOverflowExportActions:I=!1,universals:A=[]},T)=>{const[L,B]=e.useState(()=>{if("undefined"==typeof window)return!1;try{return"1"===window.localStorage.getItem("ee_high_contrast_editor")}catch{return!1}});e.useEffect(()=>{if("undefined"!=typeof window)try{window.localStorage.setItem("ee_high_contrast_editor",L?"1":"0")}catch{}},[L]),e.useEffect(()=>{var e;Xe=(e=s)&&"object"==typeof e?e:Ye,it()},[s]);const $=e.useMemo(()=>Pn(c),[c]),[M,F]=e.useState([]),[E,D]=e.useState(!1),U=e.useCallback(async()=>{if($?.companyId){D(!0);try{const e=await async function(e,t={}){const n=Dn(e),o=e?.companyId;if(!n||!o)return[];const a=new URLSearchParams({companyId:String(o),page:String(t.page??1),limit:String(t.limit??100)});null!=t.blockType&&String(t.blockType).trim()&&a.set("blockType",String(t.blockType)),"boolean"==typeof t.isActive&&a.set("isActive",String(t.isActive));const l=await fetch(`${n}?${a.toString()}`,{method:"GET",headers:{...e?.headers||{}}}),i=await l.text();let r;try{r=i?JSON.parse(i):{}}catch{return[]}if(!l.ok)return console.warn("[universal-email-blocks]",l.status,r),[];const s=r?.data;return Array.isArray(s)?s.map(zn).filter(Boolean):[]}($,{limit:100});F(Array.isArray(e)?e:[])}catch(e){console.warn("[EmailEditor] universal email blocks fetch",e)}finally{D(!1)}}else F([])},[$]);e.useEffect(()=>{U()},[U]);const z=e.useMemo(()=>{const e=M??[],t=A??[];if(!$?.companyId)return t;const n=new Set;return e.filter(e=>{const t=String(e?.resourceId??e?.id??"");return!(!t||n.has(t))&&(n.add(t),!0)})},[$?.companyId,M,A]),O=e.useCallback(async e=>{$?.companyId&&(await async function(e,{name:t,block:n}){const o=Dn(e),a=e?.companyId;if(!o||!a)throw new Error("Universal blocks API: missing endpoint or companyId");const l=Fn(t,n,a),i=await fetch(o,{method:"POST",headers:Un(e),body:JSON.stringify(l)}),r=await i.text();let s;try{s=r?JSON.parse(r):{}}catch{s={message:r}}if(!i.ok)throw new Error(En(s,i.status));return s?.data??s}($,e),await U()),"function"==typeof h&&await Promise.resolve(h(e))},[$,h,U]),W=e.useCallback(async e=>{$?.companyId&&(await async function(e,t){const n=Dn(e),o=e?.companyId;if(!n||!o||!t)throw new Error("Universal blocks API: missing endpoint, companyId, or id");const a=new URLSearchParams({companyId:String(o)}),l=`${n}/${encodeURIComponent(String(t))}?${a}`,i=await fetch(l,{method:"DELETE",headers:{...e?.headers||{}}});if(204===i.status)return!0;if(!i.ok){const e=await i.text();let t;try{t=e?JSON.parse(e):{}}catch{t={message:e}}throw new Error(En(t,i.status))}return!0}($,e),await U())},[$,U]),H=t&&!Array.isArray(t)&&"object"==typeof t?t:null,V=H?H.blocks??H.blockList??[]:t,K=(Y=V,Array.isArray(Y)?Y.map(e=>e&&"object"==typeof e?{...e,children:Ei(e.children)}:e):Y&&"object"==typeof Y?Object.values(Y).map(e=>e&&"object"==typeof e?{...e,children:Ei(e.children)}:e):[]);var Y;const Z=o??H?.aiContentRefs??{},ae=n??H?.bodySettings??pe.bodySettings,de=r??pe.templateData,ue=((e,t)=>{if(!Array.isArray(e))return e;const n=t?.content?.products;if(!Array.isArray(n)||0===n.length)return e;const o=t?.content?.primaryProductId,a=(o?n.find(e=>e?.id===o):n[0])??n[0]??el[0]??null;if(!a)return e;const l=n.filter(e=>e?.id!==a.id),i=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(i):e.children;if("column"!==e.key||"product"!==e.containerType)return{...e,children:t};const n="additional"===e.productRole?"additional":"main",o=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),r=Array.from({length:o},(e,t)=>"main"===n||0===l.length?a:l[t%l.length]);return{...e,children:t,columnProducts:r}};return e.map(i)})(K,de),me=Ln(ue,Z),{blockMap:he,rootOrder:be}=R(me),ye=_(he,de),_e=e.useMemo(()=>function(e){if("undefined"==typeof sessionStorage||!e)return null;try{const t=sessionStorage.getItem(Fi+e);if(!t)return null;const n=JSON.parse(t);return n&&"object"==typeof n?{undoStack:Array.isArray(n.undoStack)?n.undoStack:[],redoStack:Array.isArray(n.redoStack)?n.redoStack:[]}:null}catch{return null}}(p),[p]),[fe,ke]=e.useReducer(xe,{...pe,blockMap:ye,rootOrder:be,blockList:me,bodySettings:{...ae,contentWidth:v(ae?.contentWidth)},languageLibraries:i,templateData:de,undoStack:_e?.undoStack??[],redoStack:_e?.redoStack??[]}),ve=e.useRef(null);e.useEffect(()=>{p&&function(e,t,n){if("undefined"!=typeof sessionStorage&&e)try{sessionStorage.setItem(Fi+e,JSON.stringify({undoStack:t,redoStack:n}))}catch{}}(p,fe.undoStack,fe.redoStack)},[p,fe.undoStack,fe.redoStack]),e.useEffect(()=>{ke(ce(r??null,{skipUndo:!0}))},[r]);const[we,je]=e.useState([]);e.useEffect(()=>{if("undefined"==typeof document)return;const e=fe.blockList??[],t="ee-font-runtime-imports",n=document.getElementById(t)||Object.assign(document.createElement("style"),{id:t}),o=Ut(e,fe.bodySettings,fe.templateData);n.textContent=o||"",n.parentNode||document.head.appendChild(n)},[fe.blockList,fe.bodySettings,fe.templateData]);const Se=e.useMemo(()=>new Set(we),[we]),Ce=e.useCallback(e=>(Array.isArray(e)?e:[]).filter(e=>!Se.has(Hn(e))),[Se]),Ne=e.useCallback(e=>{const t=Hn(e);t&&je(e=>e.includes(t)?e:[...e,t])},[]),Ie=e.useCallback(()=>{const e=fe.blockList??[];return{blockList:Ui(e),bodySettings:fe.bodySettings??null,aiContentRefs:Di(e),language:Vn(e)}},[fe.blockList,fe.bodySettings]),Ae=e.useMemo(()=>Ce(uo({blockList:fe.blockList??[],bodySettings:fe.bodySettings??null,aiContentRefs:Di(fe.blockList??[])})).filter(e=>e?.blockId&&("warning"===e.severity||"error"===e.severity)).reduce((e,t)=>{const n=t.blockId,o=e[n]??{severity:t.severity,warningCount:0,errorCount:0,totalCount:0,messages:[],issues:[]};return"error"===t.severity&&(o.errorCount+=1),"warning"===t.severity&&(o.warningCount+=1),o.totalCount+=1,o.severity=o.errorCount>0?"error":"warning",o.messages.push(t.message),o.issues.push(t),e[n]=o,e},{}),[fe.blockList,fe.bodySettings,Ce]);e.useImperativeHandle(T,()=>({blockList:Ui(fe.blockList??[]),bodySettings:fe.bodySettings,aiContentRefs:Di(fe.blockList??[]),actionType:fe.actionType,exportJson:Ie,filterIgnoredValidationIssues:Ce,ignoreValidationIssue:Ne,focusBlock:e=>{if(!e||!fe.blockMap?.[e])return!1;const t=fe.blockMap[e],n="column"===t?.key?P(e,fe.blockMap)??t:t;return ke(se({id:e,data:n,type:"edit"})),ke(re("edit")),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const t="function"==typeof window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/([ #;?%&,.+*~':\x22!^$\x5b\x5d()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${t}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),!0},exportHtml:()=>Sn({bodySettings:fe.bodySettings,blockList:fe.blockList,templateData:fe.templateData})}),[fe.blockList,fe.blockMap,fe.bodySettings,fe.actionType,fe.templateData,Ie,Ce,Ne]),e.useEffect(()=>{"function"==typeof m&&"firstRender"!==fe.actionType&&m({blockList:Ui(fe.blockList??[]),bodySettings:fe.bodySettings??null,aiContentRefs:Di(fe.blockList??[]),actionType:fe.actionType})},[fe.blockList,fe.bodySettings,fe.actionType,m]);const Te=e.useCallback(e=>{ke((e=>({type:J,isDragStart:e}))(e))},[]),Le=e.useCallback((e,t,n)=>{t&&ke(re(t)),ke(((e,t={})=>({type:Q,bodySettings:e,skipUndo:Boolean(t.skipUndo)}))(e,n||{}))},[]),Be=e.useCallback((e,t,n,o)=>{n&&ke(re(n)),ke(((e,t,n={})=>({type:q,blockMap:e,rootOrder:t,skipUndo:Boolean(n.skipUndo)}))(e,t,o||{}))},[]),$e=e.useCallback((e,t,n)=>{t&&ke(re(t)),ke(((e,t={})=>({type:G,blockList:e,skipUndo:Boolean(t.skipUndo)}))(e,n||{}))},[]),Re=e.useCallback(e=>{ke((e=>({type:X,previewMode:e}))(e))},[]),Me=e.useCallback(e=>{ke(se(e))},[]),Pe=e.useCallback(e=>{ke((e=>({type:ee,selectionRange:e}))(e))},[]),Fe=e.useCallback(e=>{ke((e=>({type:te,textRange:e}))(e))},[]),Ee=e.useCallback(e=>{ke(re(e))},[]),De=e.useCallback(e=>{ke((e=>({type:ne,language:e}))(e))},[]),Ue=e.useCallback(e=>{ke((e=>({type:oe,languageLibraries:e}))(e))},[]),ze=e.useCallback((e,t)=>{ke(ce(e,t||{}))},[]),Oe=e.useCallback(()=>{try{ve.current?.()}catch{}},[]),We=e.useCallback(e=>(ve.current=e,()=>{ve.current===e&&(ve.current=null)}),[]),He=e.useCallback(()=>{Oe(),ke({type:le})},[Oe]),Ve=e.useCallback(()=>{Oe(),ke({type:ie})},[Oe]),Ke=e.useMemo(()=>({blockMap:fe.blockMap,rootOrder:fe.rootOrder,blockList:fe.blockList,actionType:fe.actionType,previewMode:fe.previewMode,currentItem:fe.currentItem,bodySettings:fe.bodySettings,isDragStart:fe.isDragStart,selectionRange:fe.selectionRange,textRange:fe.textRange,language:fe.language,languageLibraries:fe.languageLibraries,templateData:fe.templateData,apiConfig:$,validationMarkers:Ae,ignoreValidationIssue:Ne,aiEnabled:d,saveState:u,highContrastEditor:L,canUndo:fe.undoStack.length>0,canRedo:fe.redoStack.length>0,undo:He,redo:Ve,flushPendingRichText:Oe,registerRichTextFlush:We,onShortcutSave:g,onSaveBlockAsGlobal:O,templateName:b,onTemplateNameChange:y,onBack:f,onSaveTemplate:x,onSaveTemplateIntent:k,onSendTest:w,onSendTestIntent:j,saveStatusDetail:S,onExit:C,onPreview:N,hideOverflowExportActions:I,universals:z,universalsLoading:E,deleteUniversalEmailBlock:$?.companyId?W:void 0,setIsDragStart:Te,setBodySettings:Le,setBlocks:Be,setBlockList:$e,setPreviewMode:Re,setCurrentItem:Me,setSelectionRange:Pe,setTextRange:Fe,setActionType:Ee,setLanguage:De,setLanguageLibraries:Ue,setTemplateData:ze,setHighContrastEditor:B}),[fe.blockMap,fe.rootOrder,fe.blockList,fe.actionType,fe.previewMode,fe.currentItem,fe.bodySettings,fe.isDragStart,fe.selectionRange,fe.textRange,fe.language,fe.languageLibraries,fe.templateData,fe.undoStack.length,fe.redoStack.length,$,Ae,Ne,d,u,L,He,Ve,Oe,We,g,O,b,y,f,x,k,w,j,S,C,N,I,z,E,W,Te,Le,Be,$e,Re,Me,Pe,Fe,Ee,De,Ue,ze,B]);return l.jsx(ge.Provider,{value:Ke,children:l.jsx(Pi,{language:a})})});const Oi=["Product","Discount"],Wi=["text","image","button"];function Hi(e,t,n,o,a,l,i){if("column"===e.key&&e.containerType){const t=function(e){const t=e.toLowerCase();return"product"===t?"Product":"discount"===t?"Discount":"None"}(e.containerType),n=e.id??null;let r=o;"Product"===t&&(i.productIndex++,r=i.productIndex);for(const o of e.children??[])Hi(o,t,n,r,a,l,i);return}if("content"===e.key){for(const r of e.children??[])Hi(r,t,n,o,a,l,i);return}const r="dynamic"===e.contentType,s=Oi.includes(t)&&Wi.includes(e.key);if((r||s)&&n){let i=a.find(e=>e.containerId===n);i||(i={containerId:n,containerType:t,blocks:[]},a.push(i));const c=e.id?l[e.id]:void 0,d=function(e){return"image"===e.key?e.src??"":"button"===e.key?e.linkURL??"":e.text??""}(e);let u="";"Product"===t?u=function(e,t){const n=`product ${t}`;return e.includes("{{ProductImage}}")?`This block is meant for displaying the ${n} image`:e.includes("{{ProductName}}")?`This block is meant for displaying the ${n} name`:e.includes("{{ProductOldPrice}}")||e.includes("{{ProductNewPrice}}")?`This block is meant for displaying the ${n} original and discounted price`:e.includes("{{ProductPrice}}")||e.includes("{{ProductCurrency}}")?`This block is meant for displaying the ${n} price and currency`:e.includes("{{ProductDescription}}")?`This block is meant for displaying the ${n} description`:e.includes("{{ProductLink}}")?`This block is meant for displaying the ${n} link`:`This block is meant for displaying ${n} content`}(d,o):"Discount"===t&&(u=function(e){const t=[];return e.includes("{{DiscountValue}}")&&t.push("the discount value (e.g. 20% or $10)"),e.includes("{{DiscountCode}}")&&t.push("the discount/promo code"),e.includes("{{ValidUntil}}")&&t.push("the discount expiry date"),0===t.length?"This block is meant for displaying discount/offer information":`This block is meant for displaying ${t.join(", ")}`}(d));const m=c?.prompt||u,p=s&&!r;i.blocks.push({id:e.id??"",contentType:p||"dynamic"===e.contentType?"dynamic":"static",value:p?"":d,ai:{prompt:m,selectedSampleAiContent:p?"":c?.selectedContent??d}})}if(e.children)for(const r of e.children)Hi(r,t,n,o,a,l,i)}const Vi={text:"text",image:"src",button:"linkURL"};function Ki(e,t){if(0===t.size)return!0;if(e.id&&t.has(e.id)){const n=t.get(e.id),o=Vi[e.key];o&&(e[o]=n,t.delete(e.id))}if(e.children)for(const n of e.children)if(Ki(n,t))return!0;return 0===t.size}var Gi=Object.freeze({__proto__:null,jsonToHtml:function(e){return Cn(e)},normalizeJson:function(e){const t="string"==typeof e?JSON.parse(e):e,n=[],o=t.aiContentRefs||{},a={productIndex:0},l=t.blockList||[];for(const e of l)Hi(e,"None",null,0,n,o,a);return{groups:n}},updateJsonWithMlContent:function(e,t){const n="string"==typeof e?JSON.parse(e):e,o=structuredClone(n),a=new Map;for(const e of t)e.variations.length>0&&a.set(e.nodeId,e.variations[0].value);const l=o.blockList||[];for(const e of l)if(Ki(e,a))break;return o}});const qi=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."});exports.DEFAULT_EMAIL_TEMPLATE_ID=Rn,exports.DEFAULT_MARKOPOLO_API_BASE_V1=Bn,exports.DEFAULT_ML_GENERATION_API_BASE_V1=$n,exports.EmailEditor=zi,exports.TEMPLATE_DATA_SCHEMA=qi,exports.createDefaultTemplateData=function(e={}){const t={name:"",website:"",navigation_links:[],social_links:{}},n={brand_color:"#111111",logo_url:"",tagline:"",heroBanner:"",footerBanner:""},o=null;return{content:{...{products:[],primaryProductId:null},...e.content&&"object"==typeof e.content?e.content:{}},companyContext:{...t,...e.companyContext&&"object"==typeof e.companyContext?e.companyContext:{}},brandContext:{...n,..."string"==typeof e.brandColor&&e.brandColor.trim()?{brand_color:e.brandColor.trim()}:{},...e.brandContext&&"object"==typeof e.brandContext?e.brandContext:{}},companyId:null!=e.companyId?e.companyId:o}},exports.default=zi,exports.exportNormalizerToHtml=Cn,exports.exportTemplateJson=function(e,t={}){const{validate:n=!0}=t,o=e?.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 a=o.exportJson();if(!a||"object"!=typeof a)throw new Error("exportTemplateJson: exportJson() returned an invalid payload.");return{payload:a,issues:n?uo({blockList:a.blockList,bodySettings:a.bodySettings,aiContentRefs:a.aiContentRefs}):[]}},exports.exportTemplateJsonAsync=async function(e,t={}){const{validate:n=!0,checkImages:o=!0,imageProbe:a}=t,l=e?.current;if(!l||"function"!=typeof l.exportJson)throw new Error("exportTemplateJsonAsync: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const i=l.exportJson();if(!i||"object"!=typeof i)throw new Error("exportTemplateJsonAsync: exportJson() returned an invalid payload.");return n?{payload:i,issues:o?await _o({blockList:i.blockList,bodySettings:i.bodySettings,aiContentRefs:i.aiContentRefs},a):uo({blockList:i.blockList,bodySettings:i.bodySettings,aiContentRefs:i.aiContentRefs})}:{payload:i,issues:[]}},exports.mergeMarkopoloApiConfig=Pn,exports.utils=Gi,exports.validateExportPayload=uo,exports.validateExportPayloadComplete=_o,exports.validateImageUrlsReachable=yo,exports.validateTemplateDataShape=function(e){const t=[];if(null==e||"object"!=typeof e)return{ok:!1,warnings:["templateData must be a non-null object"]};const n=e;if(null!=n.content&&"object"!=typeof n.content)t.push("templateData.content should be an object when provided");else if(n.content&&"object"==typeof n.content){const e=n.content;null==e.products||Array.isArray(e.products)||t.push("templateData.content.products should be an array when provided")}if(null==n.catalogProducts||Array.isArray(n.catalogProducts)||t.push("templateData.catalogProducts should be an array when provided"),null!=n.companyContext&&"object"!=typeof n.companyContext&&t.push("templateData.companyContext should be an object when provided"),null!=n.brandContext&&"object"!=typeof n.brandContext&&t.push("templateData.brandContext should be an object when provided"),n.brandContext&&"object"==typeof n.brandContext){const e=n.brandContext;null!=e.brand_color&&"string"!=typeof e.brand_color&&t.push("templateData.brandContext.brand_color should be a string when provided")}return{ok:0===t.length,warnings:t}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("antd"),n=require("@fortawesome/react-fontawesome"),o=require("@fortawesome/free-solid-svg-icons"),a=require("framer-motion"),l=require("react/jsx-runtime"),i=require("react-dom"),r=require("react-color"),s=require("classnames");function c(e){const t=String(e??"").trim();return/^(?:javascript|vbscript)\s*:/i.test(t)||/^data\s*:/i.test(t)}function d(e){let t=String(e??"").trim();if(!t)return"";if(c(t))return"";for(let e=0;e<t.length;e++){const n=t.charCodeAt(e),o=t[e];if(n<32||"<"===o||">"===o||'"'===o)return""}return t}function u(e){const t=String(e??"").trim().match(/^https?:\/\/(.+)/is);return!!t&&/^https?:\/\//i.test(t[1])}function m(e,t={}){const{allowMailtoTel:n=!0}=t,o=String(e??"").trim();if(!o)return null;if(c(o))return null;if(u(o))return null;if(n&&(/^mailto:/i.test(o)||/^tel:/i.test(o)))return o;const a=/^https?:\/\//i.test(o)?o:`https://${o.replace(/^\/+/,"")}`;return p(a,!1,t)?a:null}function p(e,t=!1,n={}){return null==g(e,t,n)}function g(e,t=!1,n={}){const{allowMailtoTel:o=!0}=n;if(null==e||""===String(e).trim())return t?null:"empty";const a=String(e).trim();if(c(a))return"blocked_scheme";if(u(a))return"duplicate_protocol";let l;if(/^https?:\/\//i.test(a)){const e=a.replace(/^https?:\/\//i,"");if(/^https?:\/\//i.test(e))return"duplicate_protocol";l=a}else l=o&&/^mailto:/i.test(a)||o&&/^tel:/i.test(a)?a:`https://${a}`;try{const e=new URL(l);return"http:"===e.protocol||"https:"===e.protocol?function(e){const t=String(e??"").trim().toLowerCase();return""!==t&&"http"!==t&&"https"!==t&&("localhost"===t||!!t.includes(":")||!!/^(?:\d{1,3}\.){3}\d{1,3}$/.test(t)||t.includes("."))}(e.hostname)?null:"missing_hostname_dot":o&&"mailto:"===e.protocol||o&&"tel:"===e.protocol?null:"invalid_protocol"}catch{return"invalid_url"}}const h="https://s.magecdn.com/social",b=[{key:"facebook",image:`${h}/tc-facebook.svg`,title:"Facebook"},{key:"twitter",image:`${h}/tc-x.svg`,title:"X"},{key:"instagram",image:`${h}/tc-instagram.svg`,title:"Instagram"},{key:"linkedin",image:`${h}/tc-linkedin.svg`,title:"LinkedIn"},{key:"tiktok",image:`${h}/tc-tiktok.svg`,title:"TikTok"},{key:"youtube",image:`${h}/tc-youtube.svg`,title:"YouTube"}];function y(e){return Array.isArray(e)?e.filter(e=>e&&null!=e.linkURL&&""!==String(e.linkURL).trim()):[]}function _(e,t){if(!e||!t)return e;const n=t?.companyContext?.navigation_links,o=Array.isArray(n)&&n.length>0,a=t?.companyContext?.social_links,l=!(!a||"object"!=typeof a)&&function(e){return!(!e||"object"!=typeof e)&&Object.values(e).some(e=>null!=e&&""!==String(e).trim())}(a),i=Object.values(e).some(e=>e&&"social_link"===e.key&&e.useCompanySocialLinks);if(!o&&!i)return e;const r={...e};let s=!1;return Object.keys(e).forEach(t=>{const i=e[t];if(i){if("menu"===i.key&&!1!==i.useNavigationLinks&&o){const e=n.map(e=>function(e){if(!e||"object"!=typeof e)return{label:"Link",url:"#",target:"_self"};const t=e.label??e.name??e.title??"Link",n="string"==typeof t?t:null!=t?String(t):"Link",o=e.url??e.href??e.link??e.uri??"";return{label:n||"Link",url:("string"==typeof o?o.trim():null!=o?String(o).trim():"")||"#",target:"_blank"===e.target||"_self"===e.target?e.target:"_self"}}(e));r[t]={...i,list:e},s=!0}if("social_link"===i.key&&i.useCompanySocialLinks){const e=l?function(e){if(!e||"object"!=typeof e)return[];const t=[];for(const n of b){const o=e[n.key],a=null!=o?String(o).trim():"";a&&t.push({image:n.image,title:n.title,linkURL:d(a)})}return t}(a):[];r[t]={...i,list:e},s=!0}}}),s?r:e}const f=280,x=1200,k={EMAIL_WIDTH:"email_width",CUSTOM_PX:"custom_px",FULL_BLEED:"full_bleed"};function v(e){const t=Math.round(Number(e));return!Number.isFinite(t)||t<=0?600:Math.min(x,Math.max(f,t))}function w(e){const t=e?.contentWidthMode;return Object.values(k).includes(t)?t:k.EMAIL_WIDTH}function j(e){return v(e?.contentWidth)}function S(e){return w(e)===k.FULL_BLEED}const C=e=>{const t=e.constructor===Array?[]:{};for(let n in e)e.hasOwnProperty(n)&&(e[n]&&"object"==typeof e[n]?(t[n]=e[n].constructor===Array?[]:{},t[n]=C(e[n])):t[n]=e[n]);return t},N=(e,t)=>{let n=null;return function(){n||(n=setTimeout(()=>{e.apply(this,arguments),n=null},t))}};function I(e,t={}){if(null==e||"string"!=typeof e)return e;const n=null!=t.fontSize?Number(t.fontSize):14,o=null!=t.fontFamily?String(t.fontFamily):"sans-serif",a=null!=t.color?String(t.color):"",l=["direction: ltr",`font-size: ${n}px`,`font-family: ${o}`];a&&l.push(`color: ${a}`);const i=t.fontWeight;null!=i&&""!==String(i).trim()&&l.push(`font-weight: ${i}`);const r=t.fontStretch;null!=r&&""!==String(r).trim()&&"normal"!==String(r).toLowerCase()&&l.push(`font-stretch: ${r}`);const s=t.textTransform;null!=s&&""!==String(s).trim()&&"none"!==String(s).toLowerCase()&&l.push(`text-transform: ${s}`);const c=l.join("; ");let d=function(e){if(null==e||"string"!=typeof e)return e;let t=e.replace(/\sstyle\s*=\s*["']([^"']*)["']/gi,(e,t)=>{const n=t.replace(/\s*font-size\s*:[^;]+;?/gi,"").replace(/\s*font-family\s*:[^;]+;?/gi,"").replace(/\s*color\s*:[^;]+;?/gi,"").replace(/^;\s*|;\s*$/g,"").trim();return n?` style="${n}"`:""}),n="";for(let e=0;e<20&&n!==t;e++)n=t,t=t.replace(/<font(\s[^>]*)?>([\s\S]*?)<\/font>/gi,"$2");return t}(e.trim());const u=/^<span(?:\s[^>]*)?>([\s\S]*)<\/span>$/i.exec(d.trim()),m=/^<div(?:\s[^>]*)?>([\s\S]*)<\/div>$/i.exec(d.trim());return u?d=u[1]:m&&(d=m[1]),`<span style="${c}">${d}</span>`}function A(){return"undefined"!=typeof crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function T(e){if(!e||"object"!=typeof e)return;e.id||(e.id=A());const t=e.children;Array.isArray(t)&&t.forEach(T)}function L(e){if(!e||"object"!=typeof e)return;e.id=A();const t=e.children;Array.isArray(t)&&t.forEach(L)}function B(e){if(!e||"object"!=typeof e)return e;const t=C(e);return L(t),t}function $(e="Drag block here",t){return{id:t||A(),name:e,key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}}function R(e){const t={},n=[];function o(e){if(e&&"object"==typeof e)if(e.id||(e.id=A()),"column"===e.key){const n=(e.children||[]).map(e=>{e.id||(e.id=A());const t=[];return(e.children||[]).forEach(e=>{e.id||(e.id=A()),o(e),t.push(e.id)}),{id:e.id,width:e.width,styles:e.styles,childrenIds:t}}),{children:a,...l}=e;t[e.id]={...l,cells:n}}else t[e.id]=e}return(e||[]).forEach(e=>{e.id||(e.id=A()),o(e),n.push(e.id)}),{blockMap:t,rootOrder:n}}function M(e,t){function n(t){const o=e[t];if(!o)return null;if("column"===o.key){const e=(o.cells||[]).map(e=>({id:e.id,name:"Content",key:"content",width:e.width,styles:e.styles,children:(e.childrenIds||[]).map(e=>n(e)).filter(Boolean)})),{cells:t,...a}=o;return{...a,children:e}}return{...o}}return(t||[]).map(e=>n(e)).filter(Boolean)}function P(e,t){const n=t[e];if(!n)return null;if("column"!==n.key)return n;const o=(n.cells||[]).map(e=>({id:e.id,name:"Content",key:"content",width:e.width,styles:e.styles,children:(e.childrenIds||[]).map(e=>{const n=t[e];return n?"column"===n.key?P(e,t):n:null}).filter(Boolean)})),{cells:a,...l}=n;return{...l,children:o}}function F(e,t,n){function o(t){const a=e[t];if(!a||"column"!==a.key)return null;for(let l=0;l<(a.cells||[]).length;l++){const i=a.cells[l];for(let a=0;a<(i.childrenIds||[]).length;a++){if(i.childrenIds[a]===n)return{containerId:t,cellIndex:l,itemIndex:a};const r=e[i.childrenIds[a]];if(r&&"column"===r.key){const e=o(i.childrenIds[a]);if(e)return e}}}return null}for(const e of t||[]){const t=o(e);if(t)return t}return null}function E(e,t,n){const o=(t||[]).indexOf(n);if(-1!==o){const t=e[n];return[{containerBlock:t??null,containerType:t?.containerType??"none",cellIndex:0,isRoot:!0,rootIndex:o}]}function a(t,o=[]){const l=e[t];if(!l||"column"!==l.key)return null;for(let t=0;t<(l.cells||[]).length;t++){const i=l.cells[t];for(let r=0;r<(i.childrenIds||[]).length;r++){const s=i.childrenIds[r];if(s===n)return[{containerBlock:l,containerType:l?.containerType??"none",cellIndex:t,isRoot:!1},...o];const c=e[s];if(c&&"column"===c.key){const e=a(s,[{containerBlock:l,containerType:l?.containerType??"none",cellIndex:t,isRoot:!1},...o]);if(e)return e}}}return null}for(const e of t||[]){const t=a(e,[]);if(t)return t}return[]}function D(e,t,n){const o=E(e,t,n),a=o.find(e=>e?.containerType&&"none"!==e.containerType)||o[0]||null,l=a?.cellIndex??0,i=a?.containerBlock??null,r=i?.columnProducts?.[l]??null,s=Array.isArray(i?.columnProducts)?i.columnProducts.find(e=>null!=e)??null:null;return{containerType:a?.containerType??"none",columnIndex:l,columnProduct:r??s,containerBlock:i,lineage:o}}function U(e,t,n,o,a){const l=e[t];if(!l)return e;const i=l.cells.map((e,t)=>{if(t!==n)return e;const l=[...e.childrenIds];return l[o]=a,{...e,childrenIds:l}});return{...e,[t]:{...l,cells:i}}}function z(e,t,n,o){const a=e[t];if(!a)return{blockMap:e,removedId:null};const l=a.cells[n];if(!l)return{blockMap:e,removedId:null};const i=l.childrenIds[o],r=[...l.childrenIds];r.splice(o,1);const s=a.cells.map((e,t)=>t===n?{...e,childrenIds:r}:e);return{blockMap:{...e,[t]:{...a,cells:s}},removedId:i}}function O(e,t,n,o,a){const l=e[t];if(!l)return e;const i=l.cells[n];if(!i)return e;const r=[...i.childrenIds];r.splice(o,0,a);const s=l.cells.map((e,t)=>t===n?{...e,childrenIds:r}:e);return{...e,[t]:{...l,cells:s}}}function W(e,t,n,o){if(!n||!e[n]||0===o)return null;const a=t.indexOf(n);if(-1!==a){const n=a+o;if(n<0||n>=t.length)return null;const l=[...t],[i]=l.splice(a,1);return l.splice(n,0,i),{nextMap:e,nextRootOrder:l}}const l=F(e,t,n);if(!l)return null;const{containerId:i,cellIndex:r,itemIndex:s}=l,c=e[i],d=[...c.cells[r].childrenIds],u=s+o;if(u<0||u>=d.length)return null;const[m]=d.splice(s,1);d.splice(u,0,m);const p=c.cells.map((e,t)=>t===r?{...e,childrenIds:d}:e);return{nextMap:{...e,[i]:{...c,cells:p}},nextRootOrder:t}}function H(e,t){const n={...e};return function e(t){const o=n[t];o&&("column"===o.key&&(o.cells||[]).forEach(t=>(t.childrenIds||[]).forEach(t=>e(t))),delete n[t])}(t),n}function V(e,t={}){if(!e||"column"!==e.key||!Array.isArray(e.cells))return null;const n=(o=t)&&"object"==typeof o?Array.isArray(o)?o.reduce((e,t)=>(t&&"object"==typeof t&&t.id&&(e[t.id]=t),e),{}):{...o}:{};var o;const a=C(e);delete a.children,delete a.blockMap,delete a.blockSnapshotMap;const l={...n,[a.id]:a};function i(e){e&&!l[e]&&(l[e]=$("…",e))}return function e(t){if(t&&"column"===t.key&&Array.isArray(t.cells))for(const n of t.cells)for(const t of n.childrenIds||[]){i(t);const n=l[t];n&&"column"===n.key&&e(n)}}(a),{blockMap:l,rootId:a.id}}function K(e,t){if(!t)return{newBlockMap:e,rootId:null};if("column"===t.key){const n=Array.isArray(t.children)&&t.children.length>0;if(Array.isArray(t.cells)&&t.cells.length>0&&!n){const n=V(t,t.blockMap||t.blockSnapshotMap||{});if(n?.blockMap&&n.rootId){const t=M(n.blockMap,[n.rootId])[0];if(t){const{blockMap:n,rootOrder:o}=R([t]);return{newBlockMap:{...e,...n},rootId:o[0]??null}}}}const{blockMap:o,rootOrder:a}=R([t]);return{newBlockMap:{...e,...o},rootId:a[0]??null}}return{newBlockMap:{...e,[t.id]:t},rootId:t.id}}const G="SET_BLOCK_LIST",q="SET_BLOCKS",J="SET_IS_DRAG_START",Y="SET_ACTION_TYPE",X="SET_PREVIEW_MODE",Z="SET_CURRENT_ITEM",Q="SET_BODY_SETTINGS",ee="SET_SELECTION_RANGE",te="SET_TEXT_RANGE",ne="SET_LANGUAGE",oe="SET_LANGUAGE_LIBRARIES",ae="SET_TEMPLATE_VARIABLES",le="UNDO",ie="REDO",re=e=>({type:Y,actionType:e}),se=e=>({type:Z,currentItem:e}),ce=(e,t={})=>({type:ae,templateData:e,skipUndo:Boolean(t.skipUndo)}),de={},ue=[],me={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"}},pe={blockMap:de,rootOrder:ue,blockList:[],isDragStart:!1,actionType:"firstRender",previewMode:"desktop",currentItem:null,bodySettings:me,selectionRange:null,textRange:null,language:"en",languageLibraries:{},templateData:null,undoStack:[],redoStack:[]},ge=e.createContext();function he(e,t,n){const o=_(t,e.templateData),a=M(o,n);let{currentItem:l}=e;if(l?.id&&o[l.id]){const e=P(l.id,o);e&&e!==l.data&&(l={...l,data:e})}return{...e,blockMap:o,rootOrder:n,blockList:a,currentItem:l}}function be(e){return e?{...e,data:e.data&&"object"==typeof e.data?C(e.data):e.data}:null}function ye(e){return{blockMap:C(e.blockMap||de),rootOrder:[...e.rootOrder||ue],bodySettings:C(e.bodySettings||me),currentItem:be(e.currentItem),templateData:null==e.templateData?null:C(e.templateData)}}function _e(e,t){return t?e:{...e,undoStack:[...e.undoStack,ye(e)].slice(-50),redoStack:[]}}function fe(e,t){const n=t.templateData,o=_(C(t.blockMap||de),n),a=[...t.rootOrder||ue],l=M(o,a);let i=be(t.currentItem);if(i?.id&&o[i.id]){const e=P(i.id,o);e&&(i={...i,data:e})}const r=C(t.bodySettings||me);return{...e,blockMap:o,rootOrder:a,blockList:l,bodySettings:{...r,contentWidth:v(r.contentWidth)},currentItem:i,templateData:n}}function xe(e,t){switch(t.type){case q:return he(_e(e,t.skipUndo),t.blockMap,t.rootOrder);case G:{const n=_e(e,t.skipUndo),{blockMap:o,rootOrder:a}=R(t.blockList);return he(n,o,a)}case J:return{...e,isDragStart:t.isDragStart};case Y:return{...e,actionType:t.actionType};case X:return{...e,previewMode:t.previewMode};case Z:{let n=t.currentItem;if(n?.id&&e.blockMap[n.id]){const t=P(n.id,e.blockMap);t&&(n={...n,data:t})}return{...e,currentItem:n}}case Q:{const n=_e(e,t.skipUndo),o={...n.bodySettings,...t.bodySettings};return{...n,bodySettings:{...o,contentWidth:v(o.contentWidth)}}}case ee:return{...e,selectionRange:t.selectionRange};case te:return{...e,textRange:t.textRange};case ne:return{...e,language:t.language};case oe:return{...e,languageLibraries:t.languageLibraries};case ae:{const n=_e(e,t.skipUndo),o=t.templateData,a=_(n.blockMap,o),l=M(a,n.rootOrder);let{currentItem:i}=n;if(i?.id&&a[i.id]){const e=P(i.id,a);e&&(i={...i,data:e})}return{...n,templateData:o,blockMap:a,blockList:l,currentItem:i}}case le:{if(!e.undoStack.length)return e;const t=e.undoStack[e.undoStack.length-1],n=e.undoStack.slice(0,-1),o=ye(e),a=[...e.redoStack,o].slice(-50);return{...fe(e,t),undoStack:n,redoStack:a,actionType:"undo"}}case ie:{if(!e.redoStack.length)return e;const t=e.redoStack[e.redoStack.length-1],n=e.redoStack.slice(0,-1),o=ye(e),a=[...e.undoStack,o].slice(-50);return{...fe(e,t),undoStack:a,redoStack:n,actionType:"redo"}}default:return e}}function ke(e){if(null==e)return"";const t=String(e).trim();if(!t)return"";const n=t.toLowerCase();return"none"===n||"null"===n||"undefined"===n?"":t}var ve={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 we="CustomerName",je="DiscountValue",Se="DiscountCode",Ce="ValidUntil",Ne="CompanyName",Ie="Address",Ae="Website",Te="BrandName",Le="LogoUrl",Be="Tagline",$e="HeroBanner",Re="FooterBanner",Me="NavLabel",Pe="NavUrl",Fe="ProductName",Ee="ProductDescription",De="ProductImage",Ue="ProductLink",ze="ProductPrice",Oe="ProductCurrency",We="ProductOldPrice",He="ProductNewPrice",Ve="ProductPriceDisplay",Ke="CTALabel",Ge="CTAUrl",qe=new Set([We,He]);function Je(e){return`{{${e}}}`}const Ye=ve;let Xe=Ye;function Ze(e,t=Xe){return t&&Array.isArray(t[e])?t[e].map(e=>({...e,token:e.token||Je(e.key)})):[]}let Qe=[],et=[],tt=[],nt={},ot=[],at=[],lt=[];function it(){Qe=Ze("global",Xe),et=Ze("product",Xe),tt=Ze("discount",Xe),nt=[...Qe,...et,...tt].reduce((e,t)=>(e[t.key]=t,e),{}),ot=tt.map(e=>({variableKey:e.key,labelKey:e.labelKey}));const e=et.filter(e=>!qe.has(e.key));at=e.map(e=>({variableKey:e.key,labelKey:e.labelKey})),lt=Qe.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type})),tt.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type})),e.map(e=>({value:e.token,label:e.label,key:e.key,labelKey:e.labelKey,source:e.source,type:e.type}))}it();const rt={[we]:"User",[je]:"20%",[Se]:"SAVE20",[Ce]:"12-31-2025",[Ne]:"Company Name",[Te]:"Company Name",[Ie]:"",[Ae]:"www.example.com",[Le]:"https://via.placeholder.com/150x50/ffffff/333333?text=Logo",[Be]:"Your tagline here",[$e]:"https://via.placeholder.com/600x200/eeeeee/666666?text=Hero",[Re]:"https://via.placeholder.com/600x100/eeeeee/666666?text=Footer",[Me]:"Link",[Pe]:"https://www.example.com",[Fe]:"Product Name",[Ee]:"Product description goes here.",[De]:"https://via.placeholder.com/300x300/eeeeee/666666?text=Product",[Ue]:"https://www.example.com",[ze]:"0",[Oe]:"USD",[We]:"0",[He]:"0",[Ve]:"$0.00 USD",[Ke]:"Shop Now",[Ge]:"www.example.com"};function st(e){return null==e||"string"!=typeof e?"":e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}const ct=new Set([Ve]);function dt(e,t,n={}){if(null==e||"string"!=typeof e)return"";const o=e.replace(/\{\{(\w+)\}\}/g,(e,o)=>{const a=yt(t,o,n);return ct.has(o)?a:st(a)});return null==(a=o)||"string"!=typeof a?a:a.replace(/^(<p[^>]*>\s*(?:<br\s*\/?>|&nbsp;)?\s*<\/p>\s*)+/i,"");var a}function ut(e){return rt[e]??"—"}const mt=/^\{\{\s*[\w.]+\s*\}\}$/;function pt(e,t,{allowEmpty:n=!1}={}){if(null==e)return n?"":ut(t);const o=String(e).trim();return""===o?n?"":ut(t):function(e){return"string"==typeof e&&mt.test(e.trim())}(o)?ut(t):o}const gt={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 ht(e){return function(e){return"string"==typeof e&&/^[A-Za-z]{3}$/.test(e.trim())}(e)?String(e).trim().toUpperCase():"USD"}function bt(e,t){const n=function(e){if(null==e)return null;const t=String(e).replace(/,/g,"").trim();if(""===t)return null;const n=Number(t);return Number.isFinite(n)?n:null}(e);if(null==n)return null;const o=ht(t),a=function(e){return gt[e]??null}(o);if(!a)return null;const l=function(e){if(null==e)return 0;const t=String(e).trim().replace(/,/g,"");if(!t.includes("."))return 0;const[,n=""]=t.split(".");return Math.max(0,n.length)}(e);try{return`${new Intl.NumberFormat(a,{style:"currency",currency:o,minimumFractionDigits:l,maximumFractionDigits:l}).format(n)} ${o}`}catch{return null}}function yt(e,t,n={}){if(!e)return ut(t);const{columnIndex:o,columnProduct:a}=n;let l=a;switch(!l&&e.content?.products&&"number"==typeof o&&(l=e.content.products[o]||null),t){case we:return ut(we);case je:return pt(e.content?.discount?.value,je);case Se:return pt(e.content?.discount?.code,Se);case Ce:return pt(e.content?.discount?.valid_until,Ce);case Ne:case Te:return pt(e.companyContext?.name,t);case Ie:return pt(e.companyContext?.address,Ie,{allowEmpty:!0});case Ae:return pt(e.companyContext?.website,Ae);case Le:return pt(e.brandContext?.logo_url,Le);case Be:return pt(e.brandContext?.tagline,Be);case $e:return pt(e.brandContext?.heroBanner,$e);case Re:return pt(e.brandContext?.footerBanner,Re);case Me:case Pe:return ut(t);case Fe:return pt(l?.name,Fe);case Ee:{const e=ke(l?.description);return e?pt(e,Ee,{allowEmpty:!0}):""}case De:return pt(l?.image,De);case Ue:return pt(l?.link,Ue);case ze:return null!=l?.price&&"number"==typeof l.price||null!=l?.price&&"string"==typeof l.price?String(l.price):null!=l?.new_price?String(l.new_price):ut(ze);case Oe:return pt(l?.currency,Oe);case We:return pt(l?.old_price,We);case He:return null!=l?.new_price?pt(l.new_price,He):null!=l?.price?pt(l.price,He):ut(He);case Ve:{const e=ht(l?.currency),t=null!=l?.price?l.price:l?.new_price,n=null!=l?.old_price||null!=l?.new_price,o=null!=l?.old_price?l.old_price:null,a=null!=l?.new_price?l.new_price:null!=l?.price?l.price:null;if(n&&(null!=o||null!=a)){const t=bt(o,e),n=bt(a,e),l=null!=(null!=t?t:null!=o?String(o):null)?st(null!=t?t:null!=o?String(o):""):"";return[""!==l?`<span style="text-decoration: line-through;">${l}</span>`:"",null!=(null!=n?n:null!=a?String(a):null)?st(null!=n?n:null!=a?String(a):""):""].filter(Boolean).join(" ")||ut(Ve)}const i=bt(t,e);return null!=i?st(i):null!=t?st(String(t)):ut(Ve)}case Ke:{const t=e.content?.cta?.text;return pt(t,Ke)}case Ge:{const t=e.content?.cta?.url;return pt(null!=t?t:e.companyContext?.website,Ge)}default:return ut(t)}}const _t=[{variableKey:Le,labelKey:"variable_image_logo"},{variableKey:$e,labelKey:"variable_image_hero_banner"},{variableKey:Re,labelKey:"variable_image_footer_banner"}],ft=[{variableKey:De,labelKey:"variable_image_product_image"}],xt=[{variableKey:Ke,labelKey:"variable_cta_label"}],kt=[{variableKey:Ge,labelKey:"variable_cta_url"}],vt=[{variableKey:Ue,labelKey:"variable_product_link"},{variableKey:Ae,labelKey:"variable_website"}];function wt(e,t,n,o={}){let a=[];return"discount"===t?a=[...ot]:"product"===t&&(a=[...at]),a.map(({variableKey:e,labelKey:t})=>({...nt[e]||{},variableKey:e,labelKey:t,value:Je(e),pasteValue:yt(n,e,o)}))}function jt(e,t,n,o={},a=[]){const l="none"===t?lt.map(e=>({...e,pasteValue:yt(n,e.key,o)})):wt(0,t,n,o),i=(a||[]).filter(e=>e&&e.containerType&&"none"!==e.containerType).flatMap(e=>wt(0,e.containerType,n,e.context||{})),r=new Set,s=[];return[...l,...i].forEach(e=>{const t=e.variableKey||e.key||e.value;t&&!r.has(t)&&(r.add(t),s.push(e))}),s}const St={display_text:"DisplayText",introduction:"Introduction",heading:"Heading",subheading:"Subheading",products_description:"ProductDescription"};function Ct(e,t,n,o){return{value:Je(e),labelKey:t,variableKey:e,key:e,type:"image",pasteValue:yt(n,e,o)}}function Nt(e,t,n={}){const o=_t.map(({variableKey:e,labelKey:o})=>Ct(e,o,t,n));if("product"===e){const e=ft.map(({variableKey:e,labelKey:o})=>Ct(e,o,t,n));return[...o,...e]}return o}function It(e){return!1!==e?.linkEnabled}function At(e,t,n={}){if(!e||!t)return e;const{useImportant:o=!1}=n,a=String(t).trim();if(!a)return e;const l=o?`color: ${a} !important`:`color: ${a}`;return String(e).replace(/<a\b([^>]*)>/gi,(e,t)=>{const n=t.match(/\sstyle\s*=\s*"([^"]*)"/i);if(n){const e=(n[1]||"").replace(/\s*color\s*:\s*[^;]+(!important)?\s*;?/gi,"").replace(/;\s*;/g,";").replace(/^\s*;|;\s*$/g,"").trim(),o=`${e?`${e}; `:""}${l};`;return`<a${t.replace(n[0],` style="${o}"`)}>`}const o=t.match(/\sstyle\s*=\s*'([^']*)'/i);if(o){const e=(o[1]||"").replace(/\s*color\s*:\s*[^;]+(!important)?\s*;?/gi,"").replace(/;\s*;/g,";").replace(/^\s*;|;\s*$/g,"").trim(),n=`${e?`${e}; `:""}${l};`;return`<a${t.replace(o[0],` style='${n}'`)}>`}return`<a${t} style="${l};">`})}const Tt=[{name:"Sans Serif (Generic)",stack:"sans-serif"},{name:"Overused Grotesk",stack:"'Overused Grotesk', ui-sans-serif, system-ui, sans-serif"},{name:"Arial",stack:"Arial, Helvetica, sans-serif"},{name:"Helvetica",stack:"Helvetica, Arial, sans-serif"},{name:"Georgia",stack:"Georgia, Times New Roman, serif"},{name:"Times New Roman",stack:"'Times New Roman', Times, serif"},{name:"Verdana",stack:"Verdana, Geneva, sans-serif"},{name:"Tahoma",stack:"Tahoma, Geneva, sans-serif"},{name:"Trebuchet MS",stack:"'Trebuchet MS', Helvetica, Arial, sans-serif"},{name:"Courier New",stack:"'Courier New', Courier, monospace"},{name:"Palatino",stack:"'Palatino Linotype', Palatino, serif"},{name:"Garamond",stack:"Garamond, 'Times New Roman', serif"},{name:"Lucida",stack:"'Lucida Sans Unicode', 'Lucida Grande', sans-serif"}],Lt=[{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"}],Bt=e=>/\s/.test(String(e||""))?`'${String(e).replace(/'/g,"\\'")}'`:String(e);function $t(e){return`https://fonts.googleapis.com/css2?family=${(e=>String(e).trim().replace(/\s+/g,"+"))(e)}:wght@400;700&display=swap`}function Rt(e){const t=e?.brandContext?.customFonts;return Array.isArray(t)?t.filter(e=>e&&"object"==typeof e&&e.name&&e.url).map(e=>({label:`${e.name} (Brand Kit)`,value:`${Bt(e.name)}, Arial, sans-serif`,primaryName:String(e.name),source:"custom",url:String(e.url),format:e.format?String(e.format):void 0,weight:null!=e.weight?String(e.weight):void 0,style:e.style?String(e.style):void 0})):[]}function Mt(e){return[...Tt.map(e=>({label:e.name,value:e.stack,primaryName:e.name,source:"system"})),...Lt.map(e=>({label:`${e.name} (Google)`,value:`${Bt(e.name)}, ${e.fallback}`,primaryName:e.name,source:"google"})),...Rt(e)]}function Pt(e){if(!e)return"";const t=String(e).split(",")[0];return String(t??"").trim().replace(/^['"]|['"]$/g,"")}function Ft(e,t){const n=Mt(t),o=Pt(e).toLowerCase(),a=n.find(e=>e.primaryName.toLowerCase()===o);return a?a.value:e}function Et(e,t){const n=Mt(t),o=Ft(e,t),a=Pt(o).toLowerCase(),l=n.find(e=>e.primaryName.toLowerCase()===a||e.value===o);return l?l.label:"sans-serif"===a?"Sans Serif (Generic)":o}function Dt(e){const t=String(e.name||"").trim(),n=String(e.url||"").trim();if(!t||!n)return"";const o=e.format?` format('${e.format}')`:"",a=e.weight?`font-weight:${e.weight};`:"",l=e.style?`font-style:${e.style};`:"";return`@font-face{font-family:${Bt(t)};src:url('${n}')${o};${a}${l}}`}function Ut(e,t,n){const o=function(e,t){const n=new Set,o=e=>{null!=e&&""!==String(e).trim()&&n.add(String(e).trim())};o(t?.styles?.fontFamily);const a=e=>{Array.isArray(e)&&e.forEach(e=>{e&&"object"==typeof e&&(o(e?.styles?.desktop?.fontFamily),o(e?.styles?.mobile?.fontFamily),"image"===e.key&&Array.isArray(e.overlayItems)&&e.overlayItems.forEach(e=>{e&&"object"==typeof e&&o(e.fontFamily)}),Array.isArray(e.children)&&a(e.children))})};return a(e),[...n]}(e,t),a=new Set;o.forEach(e=>{const t=function(e){const t=Pt(e),n=Lt.find(e=>e.name.toLowerCase()===t.toLowerCase());return n?$t(n.name):null}(e);t&&a.add(t)});const l=(Array.isArray(n?.brandContext?.customFonts)?n.brandContext.customFonts:[]).map(Dt).filter(Boolean);return[...[...a].map(e=>`@import url('${e}');`),...l].join("\n")}function zt(e){const t=String(e?.image||"").toLowerCase(),n=String(e?.title||"").toLowerCase().trim();return t.includes("/tc-x.svg")||t.includes("/icons/x.svg")||t.includes("simple-icons")&&t.includes("/x.svg")||"x"===n||"twitter"===n}const Ot=["default","white","black","gray"];function Wt(e){const t="string"==typeof e?e:"default";return Ot.includes(t)?t:"default"}function Ht(e){if(!e||"object"!=typeof e)return{};const{padding:t,paddingTop:n,paddingRight:o,paddingBottom:a,paddingLeft:l,...i}=e;return i}const Vt={small:18,medium:24,large:32},Kt={left:"flex-start",center:"center",right:"flex-end",justify:"space-between"};function Gt(e){const t=e&&"object"==typeof e?{...e}:{},n=t.columnGapPx,o="number"==typeof n&&Number.isFinite(n)&&n>=0?n:8;delete t.columnGapPx;const a=t.textAlign||"left";delete t.textAlign;const l=Kt[a]||Kt.left;return{...t,display:"flex",width:"100%",maxWidth:"100%",boxSizing:"border-box",flexDirection:"row",flexWrap:"wrap",alignItems:"center",justifyContent:l,columnGap:o,rowGap:0}}function qt(e){const t=e?.iconSize;if(t&&null!=Vt[t])return Vt[t];const n=Number(e?.imageWidth);return Number.isFinite(n)&&n>0?Math.round(n):Vt.medium}function Jt(e){const t=function(e){switch(e){case"white":return"brightness(0) invert(1)";case"black":return"brightness(0)";case"gray":return"brightness(0) opacity(0.55)";default:return""}}(e);return t?{filter:t}:{}}function Yt(e,t,n){const o=Number(n)||Vt.medium,a={width:o,height:o,objectFit:"contain",display:"block",verticalAlign:"middle",flexShrink:0},l=t&&"default"!==t?t:"default",i=String(e?.image||"");if("default"===l||!i)return{src:i,style:a};const r=function(e){if(!e)return null;if(zt(e))return"x";const t=String(e.image||"").toLowerCase(),n=String(e.title||"").toLowerCase();return t.includes("facebook")||n.includes("facebook")?"facebook":t.includes("instagram")||n.includes("instagram")?"instagram":t.includes("linkedin")||n.includes("linkedin")?"linkedin":t.includes("tiktok")||n.includes("tiktok")?"tiktok":t.includes("youtube")||n.includes("youtube")?"youtube":null}(e);if(r){const e=`https://cdn.jsdelivr.net/npm/simple-icons@11.10.0/icons/${r}.svg`;if("white"===l)return{src:e,style:{...a,filter:"brightness(0) invert(1)"}};if("gray"===l)return{src:e,style:{...a,opacity:.55}};if("black"===l)return{src:e,style:a}}return{src:i,style:{...a,...Jt(l)}}}const Xt="ee_cb";function Zt(e){const t=String(e??"").trim();if(!t)return t;if(/^\{\{/u.test(t)||/^data:/iu.test(t))return t;try{const e="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(t,e);return n.searchParams.set(Xt,String(Date.now())),n.toString()}catch{const e=t.includes("?")?"&":"?";return`${t}${e}${Xt}=${Date.now()}`}}function Qt(e){const t=String(e??"").trim();if(!t)return t;try{const e="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(t,e);n.searchParams.delete(Xt);let o=n.toString();return o.endsWith("?")&&(o=o.slice(0,-1)),o}catch{return t.replace(new RegExp(`[?&]${Xt}=\\d+`,"g"),"").replace(/\?&/g,"?").replace(/&&+/g,"&").replace(/[?&]$/,"")}}const en=[{value:"cover",labelKey:"container_bg_size_cover"},{value:"contain",labelKey:"container_bg_size_contain"},{value:"fill",labelKey:"container_bg_size_fill"}],tn=["left top","center top","right top","left center","center center","right center","left bottom","center bottom","right bottom"];function nn(e){return String(e??"").trim().replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"").replace(/\r/g,"")}function on(e,t){const n=e?.containerBackgroundEnabled,o=e?.containerBackgroundImage,a=o&&String(o).trim();if(!1===n||!a)return{background:t};const l={cover:"cover",contain:"contain",fill:"100% 100%"}[e?.containerBackgroundSize||"cover"]||"cover",i=e?.containerBackgroundPosition||"center center";return{backgroundColor:t,backgroundImage:`url("${nn(a)}")`,backgroundSize:l,backgroundPosition:i,backgroundRepeat:"no-repeat"}}const an=["tl","tc","tr","ml","mc","mr","bl","bc","br"],ln={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 rn(e){const t=String(e??"bc").toLowerCase();return an.includes(t)?t:"bc"}function sn(e){const t=rn(e);return ln[t]}function cn(e,t){const n="string"==typeof t?t.trim():"";if(n)return n;const o=function(e){if(!e||"string"!=typeof e)return null;const t=e.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 e of n){const n=t.match(e);if(n?.[1])return n[1]}return null}(e||"");return o?`https://img.youtube.com/vi/${o}/hqdefault.jpg`:""}const dn=new Set(["fontWeight","opacity","zIndex"]),un=e=>String(e??"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;"),mn=e=>un(e).replace(/"/g,"&quot;").replace(/'/g,"&#39;"),pn=(e,t="#")=>{if(null==e)return t;const n=String(e).trim();if(!n)return t;const o=n.toLowerCase();return/^\s*(?:javascript|vbscript):/i.test(o)||/^\s*data:/i.test(o)?t:/^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(/^\/+/,"")}`},gn=(e,t)=>{const n=new RegExp(/[A-Z]/g),o=e=>e.replace(n,e=>`-${e.toLowerCase()}`),a={desktop:t?.desktop??{},mobile:t?.mobile??{}};let l={className:e,desktop:"",mobile:""};for(let e of Object.entries(a.desktop))if(e[1]&&"contentBackground"!==e[0]&&"horizontalAlign"!==e[0]&&"containerBackgroundImage"!==e[0]&&"containerBackgroundSize"!==e[0]&&"containerBackgroundPosition"!==e[0]){const t="number"!=typeof e[1]||dn.has(e[0])?e[1]:e[1]+"px";l.desktop+=`${o(e[0])}:${t};`}if(Object.keys(a.mobile).length){let t="";for(let e of Object.entries(a.mobile))if(e[1]&&"contentBackground"!==e[0]&&"horizontalAlign"!==e[0]&&"containerBackgroundImage"!==e[0]&&"containerBackgroundSize"!==e[0]&&"containerBackgroundPosition"!==e[0]){const n="number"!=typeof e[1]||dn.has(e[0])?e[1]:e[1]+"px";t+=`${o(e[0])}:${n} !important;`}l.mobile+=`@media(max-width:620px){\n .${e} {\n ${t}\n }\n }`}return l},hn=(e,t="",n)=>{const o=e.map((e,o)=>{let a={...e};const l={desktop:e?.styles?.desktop??{},mobile:e?.styles?.mobile??{}},i="social_link"===e.key||"menu"===e.key?{desktop:Ht(l.desktop),mobile:Ht(l.mobile)}:l;if(a.styleConfig=gn(n?`${n}-${e.key}-${o}`:`${e.key}-${o}`,i),a.contentStyles){const n={desktop:a.contentStyles?.desktop??{},mobile:a.contentStyles?.mobile??{}};a.contentStyleConfig=gn(`${e.key}-content-${o}`,n),a.contentStyleConfig.mobile&&(t+=a.contentStyleConfig.mobile)}if("video"===a.key&&a.videoArea){const l={desktop:a.videoArea?.desktop??{},mobile:a.videoArea?.mobile??{}},i=null!=n?`${n}-${e.key}-video-area-${o}`:`${e.key}-video-area-${o}`;a.videoAreaStyleConfig=gn(i,l),a.videoAreaStyleConfig.mobile&&(t+=a.videoAreaStyleConfig.mobile)}if(a.styleConfig.mobile&&(t+=a.styleConfig.mobile),i.desktop.contentBackground&&(a.contentStyleConfig={className:`${e.key}-content-${o}`,desktop:`background-color:${i.desktop.contentBackground};`,mobile:""}),i.mobile.contentBackground&&(a.contentStyleConfig||(a.contentStyleConfig={className:`${e.key}-content-${o}`,desktop:"",mobile:""}),a.contentStyleConfig.mobile=` @media(max-width:620px){\n .${a.contentStyleConfig.className} {background-color:${i.mobile.contentBackground};}\n }`,t+=a.contentStyleConfig.mobile),e.children?.length){const{newBlockList:n,styles:l}=hn(e.children,t,o);t+=l,a.children=n}return{...a}});return{newBlockList:o,styles:t}};function bn(e){const t=e.contentStyleConfig?.desktop??"",n=function(e){const t=e.contentStyles?.desktop??{},n=e.contentStyles?.mobile??{},o=null!=t.textAlign&&""!==String(t.textAlign).trim()?t.textAlign:n.textAlign,a=null!=o&&""!==String(o).trim()?String(o).trim():"center";return"start"===a?"left":"end"===a?"right":a}(e);return/\btext-align\s*:/i.test(t)?t:`${t}text-align:${n};`}const yn="#2faade";function _n(e){const t=String(e??"");return null!=(n=t)&&"string"==typeof n&&/<[a-zA-Z!/?]/.test(n.trim())?function(e){if(!e||!/<a\b/i.test(e))return e;const t=(e,t,n)=>{const o=(t[1]||"").replace(/\s*text-decoration(-line)?\s*:[^;]+;?/gi,"").replace(/^\s*;|;\s*$/g,"").trim(),a=(o?`${o}; `:"")+"text-decoration: none;",l='"'===n?` style="${a}"`:` style='${a}'`;return`<a${e.replace(t[0],l)}>`};return String(e).replace(/<a\b([^>]*)>/gi,(e,n)=>{const o=n.match(/\sstyle\s*=\s*"([^"]*)"/i);if(o)return t(n,o,'"');const a=n.match(/\sstyle\s*=\s*'([^']*)'/i);return a?t(n,a,"'"):`<a${n} style="text-decoration: none;">`})}(t):un(t);var n}function fn(e){const t=e?.dynamicSelectedContent,n=e?.text??"";if(null==t)return String(n);const o=String(t);return""===o.trim()?String(n):o}const xn=(e,t,n={})=>{let o=fn(e);t&&o&&(o=dt(o,t,n));const a=e?.styles?.desktop??{},l=null!=a.linkColor&&""!==String(a.linkColor).trim();return o=At(o,l?String(a.linkColor).trim():yn,{useImportant:l}),`<${e.type} ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig?.desktop||""}">\n ${o}\n </${e.type}>`},kn=e=>{const t=y(e.list||[]);if(0===t.length)return"";const n=Boolean(e.showTextLabel),o=`${e.styleConfig.desktop};display:inline-flex;vertical-align:middle;margin:0;align-items:center;${n?"gap:8px;":""}`,a=qt(e),l=Math.max(11,Math.round(.58*a)),i=Wt(e.iconColor),r=t.map(t=>{const{title:r,linkURL:s}=t,c=m(s,{allowMailtoTel:!1}),{src:d,styleAttr:u}=function(e,t,n){const{src:o,style:a}=Yt(e,t,n),l=Number(n)||Vt.medium,i=[`width:${l}px`,`height:${l}px`,"object-fit:contain","display:block","vertical-align:middle"];return a.filter&&i.push(`filter:${a.filter}`),null!=a.opacity&&i.push(`opacity:${a.opacity}`),{src:o,styleAttr:i.join(";")}}(t,i,a),p=`<img src="${mn(d)}" alt="${mn(r)}" style="${mn(u)}" \n ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""}/>`,g=zt(t)?"X":String(r??""),h=n?`<span style="font-size:${l}px;line-height:1.2;color:#525252;font-family:inherit;white-space:nowrap;">${un(g)}</span>`:"";return`<a target="_blank" rel="noopener noreferrer" href="${mn(c)}" style="${o};text-decoration:none;">${p}${h}</a>`}).join(""),s=function(e){const t=e?.contentStyles?.desktop??{},n=t.textAlign||"left",o=t.columnGapPx;return`width:100%;max-width:100%;box-sizing:border-box;display:flex;flex-wrap:wrap;align-items:center;justify-content:${"justify"===n?"space-between":"center"===n?"center":"right"===n?"flex-end":"flex-start"};column-gap:${"number"==typeof o&&Number.isFinite(o)&&o>=0?o:8}px;row-gap:0`}(e),c=`${e.contentStyleConfig.desktop};${s}`;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${c}">\n ${r}\n </div>`};const vn=(e,t,n,o,a,l)=>{let i="";const r={columnIndex:a??0,columnProduct:o?.columnProducts?.[l??0]??null};return e.forEach((e,s)=>{if("column"===e.key){const r=function(e){const t={...e?.desktop??{}},n=e?.mobile??{},o=String(t.containerBackgroundImage??"").trim(),a=String(n.containerBackgroundImage??"").trim();!o&&a&&(t.containerBackgroundImage=n.containerBackgroundImage,null!=n.containerBackgroundSize&&(t.containerBackgroundSize=n.containerBackgroundSize),null!=n.containerBackgroundPosition&&(t.containerBackgroundPosition=n.containerBackgroundPosition),void 0!==n.containerBackgroundEnabled&&(t.containerBackgroundEnabled=n.containerBackgroundEnabled));const l=t.minHeight,i=n.minHeight;return null!=l&&""!==String(l).trim()||null==i||""===String(i).trim()||(t.minHeight=i),t}(e.styles),c=e.styles?.desktop?.borderRadius,d=c?`border-radius:${"number"==typeof c?c+"px":c};`:"",u=d?"overflow:hidden;":"",m=function(e){const t=e??{};if(!1===t.containerBackgroundEnabled)return"";const n=Qt(t.containerBackgroundImage);return n&&String(n).trim()?`background-image:url("${nn(n)}");background-size:${{cover:"cover",contain:"contain",fill:"100% 100%"}[t.containerBackgroundSize||"cover"]||"cover"};background-position:${t.containerBackgroundPosition||"center center"};background-repeat:no-repeat;`:""}(r),p=function(e){if(null==e)return"";if("number"==typeof e&&Number.isFinite(e))return`min-height:${e}px;`;const t=String(e).trim();return t?/^\d+$/.test(t)?`min-height:${t}px;`:`min-height:${t};`:""}(r.minHeight),g=e.containerType&&"none"!==e.containerType?e:o,h=e.containerType&&"none"!==e.containerType?s:a,b=e.containerType&&"none"!==e.containerType?0:l;i+=`<div ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig.desktop};width:100%;display:block;${u}">\n <table ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="width:100%;max-width:${S(t)?"100%":`${j(t)}px`};margin:0 auto;${d}${e.contentStyleConfig?.desktop??""}${m}${p}">\n <tbody><tr>${vn(e.children,t,n,g,h,b)}</tr></tbody>\n </table></div>`}if("content"===e.key&&(i+=`<td ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="width:${e.width}; ${e.styleConfig.desktop}">${vn(e.children,t,n,o,a,s)}</td>`),"text"===e.key){const t=null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[l??0]??null}:r;e.type&&/^h[1-4]$/.test(e.type)?i+=xn(e,n,t):i+=((e,t,n={},o=null)=>{let a=fn(e);t&&a&&(a=dt(a,t,n));const l=e?.styles?.desktop??{},i=null!=l.linkColor&&""!==String(l.linkColor).trim();a=At(a,i?String(l.linkColor).trim():yn,{useImportant:i});const r="footer"===o?.containerType,s=null==(c=a)||"string"!=typeof c?"":c.replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();var c;return!r||""!==s&&"{{Address}}"!==s&&"{{Tagline}}"!==s?`<div ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""} \n style="${e.styleConfig?.desktop||""}">${a}</div>`:""})(e,n,t,o)}if("heading"===e.key&&(i+=xn(e,n,r)),"image"===e.key){i+=((e,t,n={},o=null)=>{let a=e.src||"";const l="string"==typeof e.src&&/^\{\{\s*[\w.]+\s*\}\}$/.test(e.src.trim())?e.src.trim():"";if(t&&l){const e=yt(t,l.replace(/^\{\{\s*|\s*\}\}$/g,""),n);e&&!/^\{\{\s*[\w.]+\s*\}\}$/.test(String(e).trim())&&(a=e)}a=Qt(a);const i=mn(a),r=mn(e.alt||"Image"),s=null!=e.linkURL?String(e.linkURL).trim():"",c=Array.isArray(e.overlayItems)?e.overlayItems:[],d=c.some(e=>""!==String(e?.text??"").trim()),u=String(e.overlayText??"").trim(),m=Boolean(e.textOverlayEnabled)&&(d||""!==u)&&a,p=`${e.styleConfig?.desktop||""};max-width:100%;display:inline-block;vertical-align:top;`;let g=`<img src="${i}" alt="${r}" style="${p}" ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""}/>`;if(m){const t=sn(rn(e.overlayPosition)),n=Object.entries({position:"absolute",...t,"z-index":"2","max-width":`${"number"==typeof e.overlayMaxWidth?e.overlayMaxWidth:100}%`,"box-sizing":"border-box","pointer-events":"none"}).map(([e,t])=>`${e}:${t};`).join(""),a="number"==typeof e.overlayPadding?e.overlayPadding:16,l=e.textShadowEnabled?"text-shadow:0 1px 3px rgba(0,0,0,0.55);":"";let s="";if(d){const t="number"==typeof e.overlayItemGap?e.overlayItemGap:8,n=c.filter(e=>String(e?.text??"").trim()).map(e=>{const t="number"==typeof e.fontSize?e.fontSize:16,n=mn(e.color||"#ffffff"),a=(e=>{switch(e){case"h1":case"h2":case"h3":return"700";case"subtitle":case"eyebrow":return"600";default:return"400"}})(e.kind),i=null!=e.fontFamily&&""!==String(e.fontFamily).trim()?String(e.fontFamily).trim():String(o?.styles?.fontFamily||"sans-serif").trim()||"sans-serif",r=mn(i),s=un(String(e.text??""));return`<div style="color:${n};font-size:${t}px;font-weight:${a};line-height:1.35;font-family:${r};${l}">${s}</div>`});s=`<div style="display:flex;flex-direction:column;gap:${t}px;width:100%;padding:${a}px;">${n.join("")}</div>`}else s=`<div style="color:${mn(e.overlayTextColor||"#ffffff")};font-size:${"number"==typeof e.overlayFontSize?e.overlayFontSize:18}px;font-weight:600;line-height:1.35;${e.overlayBoxBackground?`background-color:${mn(e.overlayBoxBackground)};padding:8px 12px;`:`padding:${a}px;`}${l}">${un(u)}</div>`;g=`<div style="position:relative;display:inline-block;vertical-align:top;max-width:100%;overflow:hidden;line-height:0;">\n ${e.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="${i}" alt="${r}" style="${p}position:relative;z-index:0;border-radius:0;" ${e.styleConfig?.mobile?`class="${e.styleConfig.className}"`:""}/>\n <div style="${n}">\n ${s}\n </div>\n </div>`}const h=It(e)&&""!==s?`<a href="${mn(pn(s))}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;display:inline-block;max-width:100%;">${g}</a>`:g;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${bn(e)}">\n ${h}\n </div>`})(e,n,null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[l??0]??null}:r,t)}if("video"===e.key&&(i+=(e=>{const t=null!=e.videoUrl?String(e.videoUrl).trim():"",n=cn(t,null!=e.thumbnailUrl?String(e.thumbnailUrl).trim():""),o=t?pn(t):"#",a=`${e.styleConfig?.desktop||""};max-width:100%;height:auto;display:block;border:0;`,l=e.contentStyleConfig?.desktop||"",i=e.videoAreaStyleConfig?.desktop||"";return`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${l}">\n <div ${e.videoAreaStyleConfig?.mobile?`class="${e.videoAreaStyleConfig.className}"`:""} style="${i}">\n ${n?`<a href="${mn(o)}" target="_blank" rel="noopener noreferrer" style="text-decoration:none;display:inline-block;max-width:100%;line-height:0;"><img src="${mn(n)}" alt="${mn("Video")}" style="${a}"/></a>`:`<a href="${mn(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>`})(e)),"button"===e.key){i+=((e,t,n={})=>{let o=e.text||"",a=e.linkURL||"";if(t){const l=o.match(/\{\{(\w+)\}\}/),i=e.labelVariable?e.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():l?l[1]:void 0;if(i){const e=yt(t,i,n);null==e||String(e).startsWith("{{")||(o=String(e))}if(e.urlVariable){const o=yt(t,e.urlVariable.replace(/^\{\{|\}\}$/g,""),n);o&&!o.startsWith("{{")&&(a=String(o))}else{const e=String(a||"").trim().match(/^\{\{(\w+)\}\}$/);if(e){const o=yt(t,e[1],n);o&&!String(o).startsWith("{{")&&(a=String(o))}}}const l=_n(o),i=mn(pn(a)),r=e.styleConfig.desktop||"",s=r.includes("background-color:")?"":`background-color:${(e=>e?.brandContext?.brand_color??"#111111")(t)};`;return`<div ${e.contentStyleConfig.mobile?`class="${e.contentStyleConfig.className}"`:""} \n style="${e.contentStyleConfig.desktop}">\n <a ${e.styleConfig.mobile?`class="${e.styleConfig.className}"`:""} \n style="${r}${s}text-align:center;text-decoration:none;" target="_blank" rel="noopener noreferrer" href="${i}">${l}</a>\n </div>`})(e,n,null!=o?{columnIndex:a??0,columnProduct:o?.columnProducts?.[l??0]??null}:r)}var c,d;"divider"===e.key&&(i+=`<div ${(c=e).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"===e.key&&(i+=(d=e,`<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"===e.key&&(i+=(e=>{const t=e.list||[],n=null!=e.separator?String(e.separator):" | ",o=e.styleConfig?.desktop||"",a=e.contentStyleConfig?.desktop||"",l=e.linkGapPx,i="number"==typeof l&&Number.isFinite(l)&&l>=0?l:0,r=Boolean(e.linkUnderline),s=e.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 t.forEach((e,t)=>{t>0&&(u+=`<span style="${i>0?`display:inline-block;margin-left:${i}px;margin-right:${i}px;font-size:${c};color:${d};`:`display:inline-block;padding-left:4px;padding-right:4px;font-size:${c};color:${d};`}">${un(n)}</span>`);const a=pn(e.url,"#"),l="_blank"===e.target?"_blank":"_self",s=un(e.label||"Link"),m=r?"underline":"none";u+=`<a target="${l}" href="${mn(a)}" style="${o};text-decoration:${m};display:inline-block;">${s}</a>`}),`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${a}">${u}</div>`})(e)),"avatar"===e.key&&(i+=(e=>{const t=e.src||"",n=e.alt||"Avatar",o=e.linkURL,a=e.styleConfig?.desktop||"",l=e.styles?.desktop?.width??64,i=`max-width:100%;width:${"number"==typeof l?l+"px":l};height:${"number"==typeof l?l+"px":l};object-fit:cover;border-radius:${e.styles?.desktop?.borderRadius??"50%"};${a}`,r=mn(t),s=mn(n),c=t?`<img src="${r}" alt="${s}" style="${i}" />`:`<div style="${i};background:#eee;display:flex;align-items:center;justify-content:center;"></div>`,d=e.contentStyleConfig?.desktop||"",u=o?`<a href="${mn(pn(o))}" target="_blank" rel="noopener noreferrer">${c}</a>`:c;return`<div ${e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:""} style="${d}">${u}</div>`})(e)),"social_link"===e.key&&(i+=kn(e)),"raw_html"===e.key&&(i+=(e=>{const t=e.html??"",n=e.contentStyleConfig?.desktop??"",o=e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:"",a=e.contentStyles?.desktop??{},l=a.width,i=a.textAlign??"center";let r="";return null!=l&&"100%"!==String(l)&&"center"===i?r="margin-left:auto;margin-right:auto;":null!=l&&"100%"!==String(l)&&"right"===i?r="margin-left:auto;margin-right:0;":null==l||"100%"===String(l)||"left"!==i&&"justify"!==i||(r="margin-left:0;margin-right:auto;"),`<div ${o} style="${r}max-width:100%;${n}">${t}</div>`})(e)),"table"===e.key&&(i+=(e=>{const t=e.contentStyleConfig?.desktop||"",n=e.contentStyleConfig?.mobile?`class="${e.contentStyleConfig.className}"`:"",o=e.styles?.desktop??{},a="number"==typeof e.rows?e.rows:3,l="number"==typeof e.cols?e.cols:3,i=Boolean(e.headerRow),r=Boolean(e.headerCol),s=Boolean(e.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,h=o.textAlign??"left",b=o.headerBg??"#f5f5f5",y=o.headerColor??"#333333",_=o.stripedBg??"#fafafa",f="none"!==u?`${m}px ${u} ${p}`:"none",x=Array.from({length:a}).map((t,n)=>`<tr>${Array.from({length:l}).map((t,o)=>{const a=i&&0===n||r&&0===o,l=a?b:s&&!a&&n%2==0?_:"transparent",u=a?y:d,m=a?"600":"400",p=`${n}-${o}`,x=e.cells?.[p],k=i&&0===n||r&&0===o?"th":"td";let v="&#8212;";return"image"===x?.type&&String(x.src??"").trim()?v=`<img src="${mn(x.src)}" alt="${mn(x.alt||"")}" style="max-width:100%;height:auto;display:block;border:0;"/>`:String(x?.text??"").trim()&&(v=un(String(x.text))),`<${k} style="border:${f};padding:${g}px;font-size:${c}px;color:${u};text-align:${h};background-color:${l};font-weight:${m};vertical-align:top;">${v}</${k}>`}).join("")}</tr>`).join("");return`<div ${n} style="${t}"><table role="presentation" style="${e.styleConfig?.desktop||""};border-collapse:collapse;width:100%;table-layout:auto;"><tbody>${x}</tbody></table></div>`})(e))}),i},wn={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"}},jn=e=>Array.isArray(e)?e.filter(e=>!(e&&"object"==typeof e&&!0===e.hidden)).map(e=>e&&"object"==typeof e&&Array.isArray(e.children)?{...e,children:jn(e.children)}:e):e,Sn=({bodySettings:e,blockList:t,templateData:n})=>{let o="";const a=((e,t)=>{if(!Array.isArray(e))return e;const n=t?.content?.products;if(!Array.isArray(n)||0===n.length)return e;const o=t?.content?.primaryProductId,a=(o?n.find(e=>e?.id===o):n[0])??n[0]??null;if(!a)return e;const l=n.filter(e=>e?.id!==a.id),i=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(i):e.children;if("column"!==e.key||"product"!==e.containerType)return{...e,children:t};const n="additional"===e.productRole?"additional":"main",o=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),r=Array.from({length:o},(e,t)=>"main"===n||0===l.length?a:l[t%l.length]);return{...e,children:t,columnProducts:r}};return e.map(i)})(jn(t??[]),n),{newBlockList:l,styles:i}=hn(a);o=vn(l,e,n);const r=Ut(a,e,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 ${e.styles?.headingColor?`color: ${e.styles.headingColor};`:""}\n }\n\n a {\n ${e.styles?.linkColor?`color: ${e.styles.linkColor};`:""}\n }\n\n @media(max-width:620px){\n${!1!==e.stackColumnsOnMobile?" td {\n display:inline-block;\n width:100% !important;\n }\n":""}${!1!==e.scaleFontOnMobile?" body { font-size: 16px !important; }\n":""} }\n ${r}\n ${i}\n</style>\n </head>\n <body>\n <div style="opacity:0;">${e.preHeader}</div>\n <div style="background-color:${e.styles.backgroundColor};color:${e.styles.color}; font-family:${e.styles.fontFamily};"> ${o}</div>\n </body>\n </html>`};function Cn(e){let t=e;if("string"==typeof e)try{t=JSON.parse(e)}catch(e){throw new Error("exportNormalizerToHtml: invalid JSON")}if(null==t)throw new Error("exportNormalizerToHtml: input is null or undefined");let n=[],o={...wn,styles:{...wn.styles}};Array.isArray(t)?n=t:"object"==typeof t&&(n=Array.isArray(t.blockList)?t.blockList:[],t.bodySettings&&"object"==typeof t.bodySettings&&(o={preHeader:null!=t.bodySettings.preHeader?t.bodySettings.preHeader:wn.preHeader,contentWidth:v(t.bodySettings.contentWidth??wn.contentWidth),contentWidthMode:t.bodySettings.contentWidthMode??wn.contentWidthMode,stackColumnsOnMobile:!1!==t.bodySettings.stackColumnsOnMobile,scaleFontOnMobile:!1!==t.bodySettings.scaleFontOnMobile,styles:{backgroundColor:t.bodySettings.styles?.backgroundColor??wn.styles.backgroundColor,contentBg:t.bodySettings.styles?.contentBg??wn.styles.contentBg,color:t.bodySettings.styles?.color??wn.styles.color,headingColor:t.bodySettings.styles?.headingColor??wn.styles.headingColor,linkColor:t.bodySettings.styles?.linkColor??wn.styles.linkColor,fontFamily:t.bodySettings.styles?.fontFamily??wn.styles.fontFamily}}));return`<!DOCTYPE html>\n${Sn({bodySettings:o,blockList:n,templateData:t.templateData})}`}function Nn(e,t){if("section"===e.layoutRole||"columns"===e.layoutRole)return e.layoutRole;if(!0===e.columnLayoutOnly)return"columns";return t.length>1||e.type&&"full"!==e.type?"columns":"section"}const In=["product"];function An(e){return Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):[]}function Tn(e,t={}){if(!e||"object"!=typeof e)return e;if("image"===e.key){const n="string"==typeof e.imageVariable&&/^\{\{\w+\}\}$/.test(e.imageVariable.trim())?e.imageVariable.trim():"",o="string"==typeof e.src&&/^\{\{\w+\}\}$/.test(e.src.trim())?e.src.trim():"",{imageVariable:a,...l}=e;return{...l,src:o||n||e.src,textOverlayEnabled:Boolean(e.textOverlayEnabled),overlayText:e.overlayText??"",overlayPosition:e.overlayPosition??"bc",overlayTextColor:e.overlayTextColor??"#ffffff",overlayFontSize:(()=>{const t=Number(e.overlayFontSize);return Number.isFinite(t)&&t>0?t:18})(),overlayBoxBackground:e.overlayBoxBackground??"",overlayPadding:(()=>{const t=Number(e.overlayPadding);return Number.isFinite(t)&&t>=0?t:16})(),scrimEnabled:Boolean(e.scrimEnabled),textShadowEnabled:Boolean(e.textShadowEnabled),children:An(e.children).map(e=>Tn(e,t))}}if("video"===e.key){const t=e.videoArea||{},n=t.desktop||{};return{...e,videoUrl:"string"==typeof e.videoUrl?e.videoUrl:"",thumbnailUrl:"string"==typeof e.thumbnailUrl?e.thumbnailUrl:"",videoArea:{desktop:{paddingTop:n.paddingTop??0,paddingBottom:n.paddingBottom??0,paddingLeft:n.paddingLeft??0,paddingRight:n.paddingRight??0,backgroundColor:n.backgroundColor??"transparent",borderWidth:n.borderWidth??0,borderStyle:n.borderStyle??"solid",borderColor:n.borderColor??"#cccccc",borderRadius:n.borderRadius??0},mobile:t.mobile??{}},styles:{desktop:{width:"auto",height:"auto",fillColumn:!1,fillColumnMobile:!1,display:"inline-block",...e.styles?.desktop||{}},mobile:{...e.styles?.mobile||{}}},contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center",backgroundColor:"transparent",...e.contentStyles?.desktop||{}},mobile:{...e.contentStyles?.mobile||{}}}}}if("column"===e.key){const{ctaText:n,...o}=e,a=e.containerType,l=function(e){return null==e||"none"===e?"none":"discount"===e?"discount":"product"===e||"hero_product"===e||"additional_product"===e?"product":"none"}(a),i="product"===l?e.productRole??("additional_product"===a?"additional":"main"):void 0,r=An(e.children);let s=e.columnProducts;if(In.includes(l)){const e=r.length;Array.isArray(s)||(s=[]),s=Array.from({length:e},(e,t)=>s[t]??null)}else s=[];return{...o,containerType:l,productRole:i,columnProducts:s,layoutRole:Nn(e,r),children:(r||[]).map(e=>Tn(e,t))}}if("heading"===e.key){const n=e.id?t?.[e.id]:null,o={...e,key:"text",name:e.name,type:e.type||"h1",contentType:e.contentType??"static",text:e.text,styles:e.styles,contentStyles:e.contentStyles,selectedVariableKey:e.selectedVariableKey,dynamicVariable:n?.variable??e.dynamicVariable,dynamicPrompt:n?.prompt??e.dynamicPrompt,dynamicSelectedContent:n?.selectedContent??e.dynamicSelectedContent,dynamicOptions:Array.isArray(n?.options)?n.options:n?.selectedContent?[n.selectedContent]:e.dynamicOptions};return"dynamic"===o.contentType&&(o.dynamicVariable=o.dynamicVariable??"",o.dynamicPrompt=o.dynamicPrompt??"",o.dynamicSelectedContent=o.dynamicSelectedContent??"",o.dynamicOptions=Array.isArray(o.dynamicOptions)?o.dynamicOptions:[],o.dynamicAiLanguage="bn-BD"===n?.language||"bn-BD"===o.dynamicAiLanguage?"bn-BD":"en"),{...o,children:An(e.children).map(e=>Tn(e,t))}}if("text"===e.key){const n=e.id?t?.[e.id]:null,o=e.contentType??"static",a={...e,type:e.type||"p",contentType:o};return"dynamic"===o&&(a.dynamicVariable=n?.variable??e.dynamicVariable??"",a.dynamicPrompt=n?.prompt??e.dynamicPrompt??"",a.dynamicSelectedContent=n?.selectedContent??e.dynamicSelectedContent??"",a.dynamicOptions=Array.isArray(n?.options)?n.options:n?.selectedContent?[n.selectedContent]:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[],a.dynamicAiLanguage="bn-BD"===n?.language||"bn-BD"===e.dynamicAiLanguage?"bn-BD":"en"),{...a,children:An(e.children).map(e=>Tn(e,t))}}return{...e,children:An(e.children).map(e=>Tn(e,t))}}function Ln(e,t={}){const n=Array.isArray(e)?e:e&&"object"==typeof e?Object.values(e):null;if(!Array.isArray(n))return e;const o=n.map(e=>Tn(e,t));return o.forEach(T),o}const Bn="https://api-alpha.markopolo.ai/v1",$n="https://nbq-ml-api-stg.markopolo.ai/v1",Rn="95b48b5b-cf5e-486d-817e-9839d4c4e618";function Mn(e,t){const n=null!=(o=e)&&"string"==typeof o&&o.trim()?o.replace(/\/$/,""):Bn;var o;const a=function(e){return null!=e&&"string"==typeof e&&e.trim()?e.replace(/\/$/,""):$n}(t);return{imageUploadEndpoint:`${n}/upload-file`,imageUploadQueryParams:{show:!1},imageUploadCompanyField:"comment",productsEndpoint:`${n}/knowledge-base/products`,universalEmailBlocksEndpoint:`${n}/universal-email-blocks`,mlEmailNodesEndpoint:`${a}/ml-service/content/generate-email-nodes`,mlEmailGenerateEndpoint:`${a}/ml-service/content/generate-email`}}function Pn(e={}){const t=e&&"object"==typeof e?e:{},{apiBaseUrlV1:n,apiBaseV1:o,mlGenerationApiBaseUrlV1:a,mlApiBaseUrlV1:l,headers:i,mlEmailGenerateBnEndpoint:r,...s}=t,c=n||o||Bn,d="undefined"!=typeof process&&process.env?.REACT_APP_ML_API_BASE_V1,u=Mn(c,a||l||d||$n),m="undefined"!=typeof process?String(process.env?.REACT_APP_EMAIL_TEMPLATE_ID??"").trim():"",p={...u,...s};p.mlEmailGenerateEndpoint&&String(p.mlEmailGenerateEndpoint).trim()||!r||(p.mlEmailGenerateEndpoint=String(r).replace(/\/generate-email\/bn\/?$/i,"/generate-email"));const g=String(p.emailTemplateId??"").trim()||m||Rn;return{...p,emailTemplateId:g,headers:{...p.headers||{},...i||{}}}}function Fn(e,t,n){const o=String(e??"").trim(),a=t&&"object"==typeof t?JSON.parse(JSON.stringify(t)):{name:"Block",key:"column"};a.name||(a.name="column"===a.key?"Container":o||"Block"),a.key||(a.key="column"),"column"===a.key&&Array.isArray(a.children)&&a.children.length>0&&delete a.cells;const l="column"===a.key?String(a.containerType??"none"):"none",i=function(e){if(!e||"object"!=typeof e)return"content";const t=String(e.key??"").toLowerCase();if("column"===t){const t=String(e.containerType??"none").toLowerCase();return"header"===t?"header":"footer"===t?"footer":"none"===t||""===t?"column":"content"}return"image"===t?"image":"menu"===t?"menu":"content"}(a),r="undefined"!=typeof performance&&performance.now?Math.floor(performance.now()):Date.now(),s=String(a.id??r).replace(/-/g,"").slice(0,12),c=`preset_${d=o,String(d??"").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_|_$/g,"").slice(0,48)||"block"}_${s}`;var d;return{companyId:String(n),blockName:o,blockType:i,presetId:c,presetName:o,nameKey:c,containerType:l,block:a}}function En(e,t){if(!e||"object"!=typeof e)return null!=t?`Request failed (${t})`:"Request failed";const n=e.error;if(n&&"object"==typeof n&&null!=n.message){const e=String(n.message).trim();if(e){const t=null!=n.code?String(n.code).trim():"";return t&&t!==e&&!e.toLowerCase().includes(t.toLowerCase())?`${t}: ${e}`:e}}return"string"==typeof n&&n.trim()?n.trim():"string"==typeof e.message&&e.message.trim()?e.message.trim():null!=t?`Request failed (${t})`:"Request failed"}function Dn(e){const t=e?.universalEmailBlocksEndpoint;if(t&&String(t).trim())return String(t).replace(/\/$/,"");const n=String(e?.apiBaseUrlV1||e?.apiBaseV1||"").replace(/\/$/,"");return n?`${n}/universal-email-blocks`:""}function Un(e){return{"Content-Type":"application/json",...e?.headers||{}}}function zn(e){if(!e||"object"!=typeof e)return null;const t=e.resourceId??e.id;if(!t)return null;let n=e.block;if("string"==typeof n)try{n=JSON.parse(n)}catch{n=null}n&&"object"==typeof n||(n={});const o=e.blockMap??e.blocks??e.blockSnapshotMap;if("column"===n.key&&o&&"object"==typeof o){const e=Array.isArray(o)?o.reduce((e,t)=>(t&&"object"==typeof t&&t.id&&(e[t.id]=t),e),{}):{...o};Object.keys(e).length>0&&(n={...n,blockMap:e})}return{id:t,name:e.blockName??e.name??"Saved block",block:n,resourceId:e.resourceId??t,blockType:e.blockType}}const On={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 Wn(e){const t=String(e??"").trim();return/^\{\{[A-Za-z_]\w*\}\}$/.test(t)}function Hn(e){if(!e||"object"!=typeof e)return"";return`${e.severity??"unknown"}:${e.code??"issue"}:${e.blockId??"global"}:${e.location??""}`}function Vn(e){let t=!1;const n=e=>{if(Array.isArray(e))for(const o of e)o&&"object"==typeof o&&("text"===o.key&&"dynamic"===o.contentType&&"bn-BD"===o.dynamicAiLanguage&&(t=!0),Array.isArray(o.children)&&n(o.children))};return n(Array.isArray(e)?e:[]),t?"bn-BD":"en"}function Kn(e,t=!1){if(null==e||""===String(e).trim())return t;const n=String(e).trim();try{return/^https?:\/\//i.test(n)?new URL(n):new URL("https://"+n),!0}catch{return!1}}const Gn={text:"Text",heading:"Heading",button:"Button",image:"Image",video:"Video",avatar:"Profile image",menu:"Menu",social_link:"Social links",raw_html:"HTML"};const qn={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 Jn(e,t,n){const o=e.containerType??"none",a=function(e){const t=e??"none";return qn[t]?qn[t]:String(t).replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}(o);return n<=1?a:"none"===o?`${Yn(t+1)} section`:`${Yn(t+1)} ${a} block`}function Yn(e){const t=e%10,n=e%100;return 1===t&&11!==n?`${e}st`:2===t&&12!==n?`${e}nd`:3===t&&13!==n?`${e}rd`:`${e}th`}function Xn(e,t){return t<=1?null:`${Yn(e+1)} of ${t} stacked blocks`}function Zn(e,t,n,o){const a=function(e){return Gn[e]?Gn[e]:String(e||"block").replace(/_/g," ").replace(/\b\w/g,e=>e.toUpperCase())}(t),l=[...e];o&&l.push(o);const i=l.length>0?l.join(" → "):"Email body";return n?`${a} ("${n}") — ${i}`:`${a} — ${i}`}function Qn(e,t){const n=function(e){return null==e||"object"!=typeof e?{...On,styles:{...On.styles}}:{preHeader:null!=e.preHeader?e.preHeader:On.preHeader,contentWidth:v(null!=e.contentWidth?e.contentWidth:On.contentWidth),stackColumnsOnMobile:!1!==e.stackColumnsOnMobile,scaleFontOnMobile:!1!==e.scaleFontOnMobile,styles:{backgroundColor:null!=e.styles?.backgroundColor?e.styles.backgroundColor:On.styles.backgroundColor,contentBg:null!=e.styles?.contentBg?e.styles.contentBg:On.styles.contentBg,color:null!=e.styles?.color?e.styles.color:On.styles.color,headingColor:null!=e.styles?.headingColor?e.styles.headingColor:On.styles.headingColor,linkColor:null!=e.styles?.linkColor?e.styles.linkColor:On.styles.linkColor,fontFamily:null!=e.styles?.fontFamily?e.styles.fontFamily:On.styles.fontFamily}}}(e);("number"!=typeof n.contentWidth||!Number.isFinite(n.contentWidth)||n.contentWidth<=0)&&t.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()||t.push({severity:"error",code:"body_background_color_missing",message:"Theme background color is missing.",location:"Theme settings"}),null!=o.color&&""!==String(o.color).trim()||t.push({severity:"error",code:"body_text_color_missing",message:"Theme text color is missing.",location:"Theme settings"}),null!=o.fontFamily&&""!==String(o.fontFamily).trim()||t.push({severity:"error",code:"body_font_family_missing",message:"Theme font family is missing.",location:"Theme settings"})}function eo(e,t){e.push(t)}function to(e){return null==e?"":String(e).replace(/&amp;/gi,"&").replace(/&quot;/gi,'"').replace(/&#39;/g,"'").trim()}function no(e){if(null==e||"string"!=typeof e)return[];const t=[],n=/<a\b[^>]*?\bhref\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>"']+))/gi;let o=n.exec(e);for(;o;){const a=o[1]??o[2]??o[3]??"";t.push(to(a)),o=n.exec(e)}return t}function oo(e,t=!0){const n=String(e??"").trim();return n?Wn(n)?null:g(n,!1,{allowMailtoTel:t}):null}function ao(e,t,n,o){const a=e.linkURL,l=()=>Zn(t,"button",void 0,o),i=e.id??null;null==a||""===String(a).trim()?eo(n,{severity:"warning",code:"button_empty_link",message:'Button link URL is empty; will be saved as href="https://".',location:l(),blockId:i}):c(a)?eo(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:l(),blockId:i}):Wn(a)||p(a,!1,{allowMailtoTel:!0})||eo(n,{severity:"warning",code:"button_invalid_link",message:"Button link URL format is invalid.",location:l(),blockId:i}),function(e,t,n,o,{invalidCode:a,invalidMessage:l,blockedCode:i,blockedMessage:r}){no(e??"").forEach((e,s)=>{const d=String(e??"").trim();""!==d&&(c(d)?eo(t,{severity:"error",code:i,message:r,location:n(s),blockId:o}):p(d,!1,{allowMailtoTel:!0})||eo(t,{severity:"warning",code:a,message:l,location:n(s),blockId:o}))})}(e.text,n,e=>Zn(t,"button",`label link ${e+1}`,o),i,{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."})}const lo=["product"];const io=/^\s*\{\{[\s\S]*\}\}\s*$/;function ro(e,t,n,o,a,l){(function(...e){const t=new Set,n=[];for(const o of e)if(null!=o&&""!==String(o).trim())for(const e of no(String(o))){const o=String(e).trim();o&&!t.has(o)&&(t.add(o),n.push(e))}return n})(e.text,e.dynamicSelectedContent).forEach((l,i)=>{const r=String(l??"").trim();""!==r&&(r.startsWith("#")||io.test(r)||(c(r)?eo(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:Zn(t,o,`link ${i+1}`,a),blockId:e.id??null}):p(r,!1,{allowMailtoTel:!0})||eo(n,{severity:"warning",code:"text_invalid_link",message:"Text link URL format is invalid.",location:Zn(t,o,`link ${i+1}`,a),blockId:e.id??null})))});if("dynamic"!==(e.contentType??"static"))return;const i=e.dynamicSelectedContent,r=null!=e?.id?l?.[e.id]?.selectedContent:void 0;let s=null!=i&&""!==String(i).trim()?i:r;var d;null!=s&&""!==String(s).trim()||null==e.text||""===(null==(d=e.text)?"":String(d).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim())||(s=e.text),null!=s&&""!==String(s).trim()||eo(n,{severity:"warning",code:"dynamic_content_empty",message:"Dynamic content not generated; export will use static text if available.",location:Zn(t,o,void 0,a),blockId:e.id??null})}function so(e,t,n,o){const a=e.list||[],l=new Set;a.forEach((a,i)=>{const r=a.title||a.image||`link ${i+1}`,s=e=>Zn(t,"social_link",e||r,o),d=function(e){const t=String(e?.image||"").trim();if(t)return`img:${t}`;const n=String(e?.title||"").trim().toLowerCase();return n?`title:${n}`:null}(a);d&&(l.has(d)?eo(n,{severity:"warning",code:"social_duplicate_platform",message:"Duplicate social platform in this block; only one entry per platform should be kept.",location:s(r),blockId:e.id??null}):l.add(d));const u=a.linkURL;if(null==u||""===String(u).trim()){const t=String(a?.title||"").trim()||`Item ${i+1}`;eo(n,{severity:"warning",code:"social_empty_link",message:`${t} URL is empty — this icon will be hidden in sent emails.`,location:s(r),blockId:e.id??null})}else c(u)?eo(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(r),blockId:e.id??null}):p(u,!1,{allowMailtoTel:!1})||eo(n,{severity:"warning",code:"social_invalid_link",message:"Social link URL format is invalid.",location:s(r),blockId:e.id??null});const m=a.image;null==m||""===String(m).trim()?eo(n,{severity:"warning",code:"social_empty_icon",message:"Social link icon URL is empty; icon will not display.",location:s(r),blockId:e.id??null}):Kn(m,!1)||eo(n,{severity:"warning",code:"social_invalid_icon",message:"Social link icon URL format is invalid.",location:s(r),blockId:e.id??null})}),0===a.length&&eo(n,{severity:"info",code:"social_no_links",message:"Social link block has no links.",location:Zn(t,"social_link",void 0,o),blockId:e.id??null})}function co(e,t,n,o,a){if(!Array.isArray(e))return;const l=e.length;e.forEach((e,i)=>{if(!e||"object"!=typeof e)return;const r=e.key;if("column"===r){const r=Jn(e,i,l),s=[...t,r];return function(e,t,n){const o=e.containerType??"none";if(!lo.includes(o))return;const a=e.children??[],l=e.columnProducts??[];a.forEach((o,i)=>{const r=l[i];if(null==r||"object"==typeof r&&!r.id){const o=a.length>1?`Column ${i+1} of ${a.length}`:"This column",l=[...t,o].join(" → ");eo(n,{severity:"warning",code:"container_product_not_assigned",message:"A product is not assigned to this column; assign a product in Container settings.",location:l,blockId:e.id??null})}})}(e,s,n),void(Array.isArray(e.children)&&co(e.children,s,n,o,a))}if("content"===r){const r=l>1?`Column ${i+1} of ${l}`:null,s=r?[...t,r]:t;return void(Array.isArray(e.children)&&co(e.children,s,n,o,a))}const s=Xn(i,l);switch(r){case"image":!function(e,t,n,o){const a=e.src,l=()=>Zn(t,"image",void 0,o);null!=a&&""!==String(a).trim()?(Kn(a,!1)||eo(n,{severity:"warning",code:"image_invalid_src",message:"Image URL format is invalid.",location:l(),blockId:e.id??null}),It(e)&&oo(e.linkURL,!0)&&eo(n,{severity:"warning",code:"image_invalid_link",message:"Image link URL format is invalid.",location:l(),blockId:e.id??null}),null!=e.alt&&""!==String(e.alt).trim()||eo(n,{severity:"info",code:"image_empty_alt",message:"Image alt text is empty; consider adding for accessibility.",location:l(),blockId:e.id??null})):eo(n,{severity:"error",code:"image_empty_src",message:"Image URL is empty; the image will not display.",location:l(),blockId:e.id??null})}(e,t,n,s);break;case"video":!function(e,t,n,o){const a=()=>Zn(t,"video",void 0,o),l=null!=e.videoUrl?String(e.videoUrl).trim():"";l?Kn(l,!1)||eo(n,{severity:"warning",code:"video_invalid_url",message:"Video URL format may be invalid.",location:a(),blockId:e.id??null}):eo(n,{severity:"error",code:"video_empty_url",message:"Video URL is empty; the video will not display.",location:a(),blockId:e.id??null})}(e,t,n,s);break;case"avatar":!function(e,t,n,o){const a=e.src,l=()=>Zn(t,"avatar",void 0,o);null==a||""===String(a).trim()?eo(n,{severity:"warning",code:"avatar_empty_src",message:"Avatar image URL is empty; avatar will not display.",location:l(),blockId:e.id??null}):Kn(a,!1)||eo(n,{severity:"warning",code:"avatar_invalid_src",message:"Avatar image URL format is invalid.",location:l(),blockId:e.id??null}),oo(e.linkURL,!0)&&eo(n,{severity:"warning",code:"avatar_invalid_link",message:"Avatar link URL format is invalid.",location:l(),blockId:e.id??null})}(e,t,n,s);break;case"button":ao(e,t,n,s);break;case"menu":!function(e,t,n,o){const a=e.list||[];a.forEach((a,l)=>{const i=e=>Zn(t,"menu",e||`Item ${l+1}`,o);null!=a.label&&""!==String(a.label).trim()||eo(n,{severity:"info",code:"menu_empty_label",message:'Menu item label is empty; will show as "Link".',location:i(`item ${l+1}`),blockId:e.id??null});const r=a.url;null==r||""===String(r).trim()?eo(n,{severity:"warning",code:"menu_empty_url",message:'Menu item URL is empty; will be saved as href="#".',location:i(a.label||`item ${l+1}`),blockId:e.id??null}):c(r)?eo(n,{severity:"error",code:"menu_blocked_scheme",message:"Menu item URL uses a blocked scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",location:i(a.label||`item ${l+1}`),blockId:e.id??null}):p(r,!1,{allowMailtoTel:!0})||eo(n,{severity:"warning",code:"menu_invalid_url",message:"Menu item URL format is invalid.",location:i(a.label||`item ${l+1}`),blockId:e.id??null})}),0===a.length&&eo(n,{severity:"info",code:"menu_no_items",message:"Menu block has no items.",location:Zn(t,"menu",void 0,o),blockId:e.id??null})}(e,t,n,s);break;case"social_link":so(e,t,n,s);break;case"raw_html":!function(e,t,n,o){const a=e.html;null!=a&&""!==String(a).trim()||eo(n,{severity:"info",code:"raw_html_empty",message:"HTML block has no custom markup; export will include an empty wrapper.",location:Zn(t,"raw_html",void 0,o),blockId:e.id??null})}(e,t,n,s);break;case"text":ro(e,t,n,"text",s,a);break;case"heading":ro(e,t,n,"heading",s,a)}})}function uo({blockList:e,bodySettings:t,aiContentRefs:n={}}){const o=[];return Qn(t,o),co(Array.isArray(e)?e:[],[],o,t,n),o}function mo(){const e="undefined"!=typeof window&&null!=window?window:"undefined"!=typeof global&&null!=global?global:void 0;if(!e)return;const t=e.Image;return"function"==typeof t?t:void 0}const po=/^\{\{\s*[\w.]+\s*\}\}$/;function go(e){if(null==e||""===String(e).trim())return null;const t=String(e).trim();if(function(e){return null!=e&&"string"==typeof e&&po.test(e.trim())}(t))return null;if(/^https?:\/\//i.test(t))return Kn(t,!1)?t:null;if(t.startsWith("//")){const e=`https:${t}`;return Kn(e,!1)?e:null}return null}function ho(e,t=[],n=e?.length??0){const o=[];return Array.isArray(e)?(e.forEach((e,a)=>{if(!e||"object"!=typeof e)return;const l=e.key;if("column"===l){const l=Jn(e,a,n),i=[...t,l],r=e.children;return void o.push(...ho(r,i,r?.length??0))}if("content"===l){const l=n>1?`Column ${a+1} of ${n}`:null,i=l?[...t,l]:t,r=e.children;return void o.push(...ho(r,i,r?.length??0))}const i=Xn(a,n);if("image"===l){const n=go(e.src);n&&o.push({url:n,location:Zn(t,"image",void 0,i),blockId:e.id??null})}}),o):o}function bo(e,t=12e3){const n=mo();if(!n)return Promise.resolve(!1);const o=String(e).trim();return o?new Promise(e=>{const a=new n;let l=!1;const i=t=>{l||(l=!0,clearTimeout(r),a.onload=null,a.onerror=null,e(t))},r=setTimeout(()=>i(!1),t);a.onload=()=>i(!0),a.onerror=()=>i(!1);try{a.src=o}catch{i(!1)}}):Promise.resolve(!1)}async function yo(e,t={}){const{timeoutMs:n=12e3,concurrent:o=6}=t;if(!mo())return[];const a=ho(Array.isArray(e)?e:[]);if(0===a.length)return[];const l=new Map;for(const e of a)l.has(e.url)||l.set(e.url,[]),l.get(e.url).push(e.location);const i=[...l.keys()],r=new Map;let s=0;const c=Math.max(1,Math.min(o,i.length));await Promise.all(Array.from({length:c},()=>async function(){for(;s<i.length;){const e=s++,t=i[e],o=await bo(t,n);r.set(t,o)}}()));const d=[];for(const[e,t]of l)if(!0!==r.get(e))for(const n of t)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:a.find(t=>t.url===e&&t.location===n)?.blockId??null});return d}async function _o(e,t){return[...uo(e),...await yo(e?.blockList??[],t)]}const fo=(...e)=>e.filter(Boolean).join(" ");function xo(e){return"string"!=typeof e?e:e.replace(/\u202E/g,"").replace(/\u202D/g,"").replace(/\u202A/g,"").replace(/\u202B/g,"").replace(/\u202C/g,"").replace(/\sdir\s*=\s*["']rtl["']/gi,' dir="ltr"').replace(/\sstyle\s*=\s*["']([^"']*)["']/gi,(e,t)=>{const n=String(t||"").replace(/\s*direction\s*:\s*rtl\s*;?/gi,"").trim();return n?` style="${n}"`:""})}function ko(e){if("string"!=typeof e||!e)return{masked:e||"",tokens:[]};const t=[];return{masked:e.replace(/\{\{[^{}]+\}\}/g,e=>(t.push(e),`${t.length-1}`)),tokens:t}}function vo(e,t){if("string"!=typeof e||!t.length)return e;let n=e;for(let e=t.length-1;e>=0;e--){const o=`${e}`;n=n.split(o).join(t[e])}return n}const wo={drag_block_here:"请将模块拖放到此处",drop_content_here:"将内容拖放到此处",drop_content_hint:"从左侧拖拽模块到此处,或单击插入。",drag_section_here:"将版块拖放到此处",blocks:"模块",photos:"图片",powered_by_pexels:"图片由Pexels提供",loading:"加载中...",content:"内容",typography:"排版",compliance_approx_kb:"约 {{n}} KB",styles:"样式",ai_powered:"AI 驱动",layout:"布局",components:"组件",presets:"预设",body_settings:"邮件主题设置",global:"全局",text_and_headings:"文本与标题",pre_header:"预标题",pre_header_description:"预标题是在收件箱中查看电子邮件时跟随主题行的简短摘要文本。",confirm:"确认",cancel:"取消",add_blocks:"请添加块",block_product:"产品",block_product_single:"单个",block_product_multi:"多个",block_discount:"折扣",block_introduction:"引言",block_body:"正文",block_header:"页眉",block_footer:"页脚",no_product_found:"未找到产品",no_products_matching_search:"没有符合搜索条件的产品。清空搜索可查看完整列表。",load_more_products:"加载更多",add_products:"添加产品",add_products_in_store:"请在店铺中添加产品。",column:"列",columns:"列排版",column_settings:"列设置",column_cells_section:"列单元格",column_wrapper_style:"外层样式",column_styles:"列样式",size_px:"尺寸",column_delete:"删除列",column_delete_desc:"您确定删除多余的{{count}}列吗?",block_palette_section:"版块",block_palette_columns:"分栏",settings_title_column_layout:"栏位设置",container:"版块",select_parent_section_tooltip:"父级版块设置 — 布局、间距与背景",container_settings:"版块设置",layers_panel:"图层",email_styles_section:"邮件样式",document_section:"文档",body_bg_color_short:"背景色",body_content_bg_short:"正文背景",body_width_label:"宽度",body_font_short:"字体",body_text_short:"正文",body_heading_short:"标题",body_link_short:"链接",type_styles_section:"文字",container_type:"版块类型",container_type_help:"决定该版块可用的变量和产品映射。",container_type_none:"默认",container_type_header:"页眉",container_type_discount:"折扣",container_type_introduction:"引言",container_type_body:"正文",container_type_product:"产品",container_type_hero_product:"主推产品",container_type_additional_product:"附加产品",container_type_footer:"页脚",product_role:"产品角色",product_role_main_hero:"主推产品",product_role_additional:"附加产品",assign_product_to_column:"为列分配产品",text:"文本",text_content:"这是一个文本,点击修改文本",text_settings:"文本设置",text_styles:"文本样式",text_align:"文本对齐方式",heading:"标题",heading_content:"这是一个标题,点击修改标题",heading_settings:"标题设置",heading_type:"标题类型",button:"按钮",button_settings:"按钮设置",button_action:"点击按钮触发",button_styles:"按钮样式",button_padding:"按钮内边距",spacer:"间距",spacer_block:"间距块",spacer_settings:"间距设置",divider:"分割线",divider_settings:"分割线设置",divider_type:"分割线类型",divider_styles:"分割线样式",image:"图片",image_settings:"图片设置",image_crop_soon:"图片裁剪功能尚未开放。",crop:"裁剪",replace:"替换",delete:"删除",image_max_upload_size:"最大 10 MB",video:"视频",video_settings:"视频",video_tab_styles:"样式",video_tab_display:"显示",video_url:"视频地址",video_thumbnail_url:"自定义封面图 URL",video_thumbnail_url_placeholder:"留空则使用 YouTube 默认封面",video_export_note:"邮件客户端通常显示封面图链接,而不是内嵌播放器。",video_thumbnail_layout:"封面布局",video_width:"宽度 (W)",video_height:"高度 (H)",video_fill_column:"铺满列宽",video_fill_column_mobile:"移动端铺满列宽",alignment:"对齐",video_area_section:"视频区域",video_block_section:"区块",video_border_none:"无",image_action:"点击图片跳转",image_url:"图片URL",image_alt:"图片alt",image_alt_placeholder:"为屏幕阅读用户描述图片",image_styles:"图片样式",image_source:"图片来源",image_source_url:"输入URL",image_source_upload:"上传图片",image_upload:"上传",image_upload_click:"点击上传",image_upload_not_configured:"未配置图片上传。请在 apiConfig 中设置 imageUploadEndpoint,或传入 null 关闭;默认使用内置 API 根地址。",image_uploaded:"图片上传成功",image_upload_failed:"图片上传失败",image_upload_error:"上传图片时出错",image_upload_file_hint:"PNG、JPEG、GIF、SVG、WebP,最大 10 MB",image_upload_invalid_type:"请使用 PNG、JPEG、GIF、SVG 或 WebP 格式。",uploading:"上传中…",image_source_variable:"使用变量",menu:"导航栏",menu_settings:"导航栏设置",menu_items:"菜单项",menu_item:"菜单项",menu_styles:"菜单样式",add_new_item:"添加新项",label:"标签",page:"页面",url:"链接地址",target:"打开方式",same_tab:"当前窗口",new_tab:"新窗口",separator:"分隔符",menu_separator_placeholder:'例如 " | " 或 " • "',menu_separator_allowed_hint:"仅可使用:| • — / · 以及空格。",menu_link_gap:"链接间距",menu_underline_links:"链接下划线",logo_text_placeholder:"品牌名称",letter_spacing:"字间距",link_color:"链接颜色",menu_layout:"菜单布局",layout_mode:"布局模式",nav_only:"仅导航",stacked:"堆叠排列",logo_left:"Logo 在左",logo_right:"Logo 在右",logo_only:"仅 Logo",mobile_layout:"移动端布局",stack:"纵向堆叠",inline:"行内排列",logo_section:"Logo 区域",show_logo:"显示 Logo",logo_url:"Logo 地址",logo_text:"Logo 文字",logo_alt:"Logo 替代文字",logo_link:"Logo 链接",logo_max_width:"Logo 最大宽度",border_bottom:"底边框",show_border_bottom:"显示底边框",font_weight:"字重",font_weight_light:"细",font_weight_regular:"常规",font_weight_semibold:"半粗",font_weight_bold:"粗",text_transform:"字母大小写与样式",avatar:"头像",avatar_settings:"头像设置",avatar_image:"头像图片",avatar_border_radius:"圆角",social_link:"社交链接",add_social_link:"添加社交链接",social_link_size:"社交链接大小",icon_styles:"图标样式",icon_size:"图标大小",icon_size_small:"小",icon_size_medium:"中",icon_size_large:"大",icon_color:"图标颜色",icon_color_default:"默认",icon_color_white:"白色",icon_color_black:"黑色",icon_color_gray:"灰色",social_icon_spacing:"图标间距",social_links:"社交链接",social_link_settings:"社交链接设置",social_platform_x:"X",social_platform_formerly_twitter:"原 Twitter",social_platform_x_alt:"X(原 Twitter)",social_link_placeholder_facebook:"https://www.facebook.com/yourpage",social_link_placeholder_linkedin:"https://www.linkedin.com/company/yourcompany",social_link_placeholder_instagram:"https://www.instagram.com/yourhandle",social_link_placeholder_tiktok:"https://www.tiktok.com/@yourhandle",social_link_placeholder_x:"https://x.com/yourhandle",social_link_placeholder_youtube:"https://www.youtube.com/yourchannel",social_link_placeholder_pinterest:"https://www.pinterest.com/yourprofile",social_link_placeholder_generic:"https://example.com",raw_html:"HTML",raw_html_block:"自定义 HTML",raw_html_settings:"HTML 设置",raw_html_code_label:"代码",raw_html_code_hint:"导出邮件时将原样插入。为兼容各邮件客户端,建议使用表格布局与内联样式。",raw_html_default_content:'<p style="text-align:center;color:#A3A3A3;font-size:12px">在此添加自定义 HTML</p>',raw_html_appearance:"布局",raw_html_clear_background:"清除背景",raw_html_email_client_warning:"自定义 HTML 在不同邮件客户端中的表现可能不一致,请充分测试。",raw_html_info_tooltip_aria:"了解自定义 HTML",content_background_color:"内容背景颜色",container_background_image_title:"版块背景图",container_background_image_section_title:"版块背景图",container_background_image_section_toggle:"显示版块背景图设置",container_background_image_layout_group:"图片布局",container_background_image_row_label:"背景图",container_background_image_intro:"拖入该版块的文本、按钮、图片等会叠在背景图之上。请从左侧组件栏拖入画布中的该版块。",container_background_image_tooltip_p1:"背景图应用在版块的表格层上,兼容常见邮件客户端(不使用 position:absolute)。",container_background_image_tooltip_p2:"可用「内容背景颜色」为区块加蒙层或衬色,或设为透明以只显示照片。",container_background_image_enable:"启用背景图",container_background_image_url:"图片地址",container_background_image_upload:"上传图片",container_background_image_upload_click:"拖拽或选择图片",container_background_image_file_hint:"支持 .png、.jpg、.jpeg、.gif、.webp。单文件最大 10 MB。",container_background_image_select_button:"选择图片",container_background_image_clear:"移除背景图",container_background_image_size:"图片适配",container_background_image_position:"焦点位置",container_bg_size_cover:"覆盖(裁切)",container_bg_size_contain:"包含(完整)",container_bg_size_fill:"填充",image_file_too_large:"图片大小不能超过 10 MB。",container_bg_image_url_error_blocked_scheme:"该地址使用了不允许的协议。图片请仅使用 http:// 或 https://。",container_bg_image_url_error_duplicate_protocol:"地址中重复了协议前缀,请只保留一个,例如 https://。",container_bg_image_url_error_hostname:"请填写带有效域名的完整地址(例如 https://cdn.example.com/photo.jpg)。",container_bg_image_url_error_invalid_protocol:"不支持的协议。图片地址请使用 http:// 或 https://。",container_bg_image_url_error_generic:"图片地址格式无效。",container_bg_image_preview_failed:"无法加载预览:该地址可能不是图片,或服务器不允许嵌入显示。",image_text_overlay:"文字叠层",overlay_multi_item:"多段文本叠放",add_overlay_item:"添加叠层项",drag_to_move:"拖动排序",overlay_max_width:"叠层最大宽度",item_gap:"项间距",scrim:"背景蒙层",text_shadow:"文字阴影",fill_column:"填满列宽",image_text_overlay_tip:"可选:在图片上显示简短说明。若要在照片上排版多块内容,请使用版块背景图。",image_text_overlay_container_tip:"选中版块 → 样式 → 版块背景图,再将文字、按钮等拖入该版块。",image_text_overlay_enable:"启用文字叠层",image_overlay_caption:"说明文字",image_overlay_caption_placeholder:"一行简短文字…",image_overlay_position:"说明位置",image_overlay_pos_tl:"左上",image_overlay_pos_tc:"上中",image_overlay_pos_tr:"右上",image_overlay_pos_ml:"左中",image_overlay_pos_mc:"正中",image_overlay_pos_mr:"右中",image_overlay_pos_bl:"左下",image_overlay_pos_bc:"下中",image_overlay_pos_br:"右下",image_overlay_box_bg:"说明框背景(CSS)",image_overlay_padding:"说明内边距",background_color:"背景颜色",text_color:"文本颜色",email_theme_background_color:"邮件主题色",heading_color:"标题颜色",content_background:"内容区背景",font_color:"字体颜色",button_color:"按钮颜色",divider_color:"分割线颜色",action_type:"按钮类型",top:"上",right:"右",left:"左",bottom:"下",line_height:"行高",link:"超链接",link_url:"超链接URL",link_url_placeholder:"example.com",padding_settings:"内边距设置",width_auto:"宽度自适应",auto_width:"自动宽度",width:"宽度",height:"高度",font_size:"字体大小",font_family:"字体",align:"对齐方式",solid:"实线",dotted:"虚线(点)",dashed:"虚线(破折号)",spacing:"间距",border_radius:"圆角",link_all_sides:"联动四边",padding_link_sides_label:"四边使用相同内边距",padding_link_sides_tooltip:"开启后只需输入一个数值,将同时应用到上、右、下、左四面。关闭后可分别设置每一侧。",email_width_mode:"宽度",email_width_default:"邮件宽度(默认)",custom_px:"自定义像素",custom_width_px:"自定义宽度",full_bleed:"全幅铺满",full_bleed_tooltip:"在支持的客户端中可延展到边缘;不支持时会限制在邮件宽度内。",export_html:"导出html",export_json:"导出JSON",export_checking_images:"正在检查图片…",language_zh:"中文",export_validation_title:"导出前校验",export_validation_issues_found:"导出前发现以下问题",export_validation_errors:"错误",export_validation_warnings:"警告",export_validation_info:"提示",export_anyway:"仍要导出",ignore:"忽略",validation_body_content_width_invalid:"邮件内容宽度须在 280–1200 px 之间。",validation_body_background_color_missing:"主题背景色未设置。",validation_body_text_color_missing:"主题文字颜色未设置。",validation_body_font_family_missing:"主题字体未设置。",validation_image_empty_src:"图片地址为空,图片将无法显示。",validation_image_invalid_src:"图片地址格式无效。",validation_image_invalid_link:"图片链接地址格式无效。",validation_image_url_not_loadable:"图片地址无法加载或预览;链接可能已失效、过期或被拦截。",validation_image_empty_alt:"图片未设置 alt 文本,建议添加以提升可访问性。",validation_avatar_empty_src:"头像图片地址为空,头像将无法显示。",validation_avatar_invalid_src:"头像图片地址格式无效。",validation_avatar_invalid_link:"头像链接地址格式无效。",validation_button_empty_link:'按钮链接为空,将被保存为 href="https://"。',validation_button_invalid_link:"按钮链接格式无效。",validation_button_blocked_scheme:"按钮链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",validation_button_label_invalid_link:"按钮文案中的链接地址格式无效。",validation_button_label_blocked_link_scheme:"按钮文案中的链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",validation_rich_text_link_invalid:"富文本超链接地址格式无效。",validation_rich_text_link_blocked_scheme:"富文本链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",validation_menu_empty_label:"菜单项标签为空,将显示为「链接」。",validation_menu_empty_url:'菜单项链接为空,将被保存为 href="#"。',validation_menu_invalid_url:"菜单项链接格式无效。",validation_menu_blocked_scheme:"菜单项链接使用了被禁止的协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",validation_menu_no_items:"菜单块没有任何项。",validation_raw_html_empty:"HTML 块没有自定义代码;导出将只有空的外层容器。",validation_social_empty_link:'社交链接地址为空,将被保存为 href="https://"。',validation_social_invalid_link:"社交链接地址格式无效。",validation_social_blocked_scheme:"社交链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s) 地址(例如 www.example.com 或 https://…)。",validation_social_empty_icon:"社交链接图标地址为空,图标将无法显示。",validation_social_invalid_icon:"社交链接图标地址格式无效。",validation_social_no_links:"社交链接块没有任何链接。",validation_social_duplicate_platform:"社交链接块中存在重复平台,每个平台仅应保留一条。",section_nest_not_allowed:"版块不能嵌套在另一版块内,请在版块之间的堆叠区域释放。",validation_container_product_not_assigned:"该列未分配产品;请在版块设置中分配产品。",validation_dynamic_content_empty:"未生成动态内容;导出将使用静态文本(如有)。",validation_text_invalid_link:"文本链接地址格式无效。",validation_text_blocked_link_scheme:"文本链接使用了被禁止的 URL 协议(如 javascript:、data: 等)。请仅使用 http(s)、mailto: 或 tel:。",tooltip_bold:"加粗",tooltip_italic:"斜体",tooltip_underline:"下划线",tooltip_strikethrough:"删除线",tooltip_align_left:"居左",tooltip_align_center:"居中",tooltip_align_right:"居右",tooltip_ordered_list:"有序列表",tooltip_unordered_list:"无序列表",tooltip_link:"超链接",tooltip_remove_link:"删除超链接",add_link_modal_title:"添加超链接",content_type:"内容类型",content_type_static:"静态",content_type_dynamic:"动态",ai_enabled:"使用 AI 撰写",text_and_content_type:"内容类型",heading_or_body:"标题",body_paragraph:"正文",heading_h1:"H1",heading_h2:"H2",heading_h3:"H3",heading_h4:"H4",variables:"变量",insert_merge_field:"选择或输入变量...",dynamic_prompt_help:"写下你的提示",ai_output_language:"AI 输出语言",ai_output_language_en:"英语",ai_output_language_bn:"孟加拉语",generate:"生成",ml_generation_failed:"无法生成 AI 内容",ml_ai_unavailable:"AI 生成需要分栏布局、公司 ID、模板 ID 和 ML 接口。请将文本放在栏目内并检查 apiConfig。",ml_no_variations:"未返回任何建议。请更换提示词或确认服务器上存在该模板。",ml_generation_unexpected_error:"生成内容时发生意外错误。",sample_ai_content:"示例 AI 内容",select_content:"选择内容",variable_dynamic_placeholder:"无(可选)",variable_display_text:"展示文案",variable_introduction:"引言",variable_heading:"标题",variable_subheading:"副标题",variable_products_description:"产品描述",variable_customer_name:"客户姓名",variable_introduction_title:"引言标题",variable_introduction_subtitle:"引言副标题",variable_body_title:"正文标题",variable_body_subtitle:"正文副标题",variable_discount_value:"折扣力度",variable_discount_code:"折扣码",variable_valid_until:"有效期至",variable_company_name:"公司名称",variable_brand_name:"品牌名称",variable_address:"地址",variable_website:"网站",variable_logo_url:"Logo URL",variable_tagline:"标语",variable_nav_label:"导航文案",variable_nav_url:"导航链接",variable_product_name:"产品名称",variable_product_description:"产品描述",variable_product_image:"产品图片 URL",variable_product_link:"产品链接",variable_product_price:"产品价格",variable_product_currency:"货币",variable_product_old_price:"原价",variable_product_new_price:"现价",variable_product_price_display:"产品价格展示",variable_image_logo:"Logo",variable_image_hero_banner:"主图横幅",variable_image_footer_banner:"页脚横幅",variable_image_product_image:"产品图片",variable_cta_label:"CTA 文案",variable_cta_url:"CTA 链接",button_label_variable:"按钮文案(变量)",button_url_variable:"使用变量",button_text:"按钮文案",button_label_manual:"输入文案",button_url_manual:"输入链接",use_company_social_links:"使用公司社交链接",use_navigation_links:"使用导航链接",tooltip_container_type:"决定该版块可用的变量和产品映射。",tooltip_variables_static:"将合并字段插入内容,发送邮件时将被替换。",tooltip_dynamic_prompt:"描述语气或意图,我们将推荐示例内容。(预览模式 — 连接 AI API 后可生成真实内容。)",tooltip_write_using_ai:"开启后,可选择输出语言并输入提示生成多种示例。需配置 ML/API。",tooltip_write_using_ai_unavailable:"当前编辑器未开启 AI 写作。请在宿主应用或 API 中启用后再使用「使用 AI 撰写」。",label_align:"对齐",label_padding:"内边距",section_background_group:"区块背景",section_bg_mode:"类型",section_bg_color:"颜色",section_bg_image:"图片",section_bg_none:"无",section_content_area_group:"内容区",content_area_color:"内容底色",content_color_auto:"自动",content_color_custom:"自定义",shortcuts_modal_title:"键盘快捷键",shortcuts_modal_footnote:"在右侧设置面板的文本框中输入时快捷键会暂时停用,以便正常编辑链接和复制粘贴。",shortcut_save:"保存(由宿主页面接入时触发)",shortcut_undo:"撤销",shortcut_redo:"重做",shortcut_duplicate:"复制选中模块",shortcut_copy_block:"复制模块",shortcut_paste_block:"粘贴模块",shortcut_delete_block:"删除选中模块",shortcut_escape:"取消选中",shortcut_cheat_sheet:"打开此帮助",shortcut_delete_confirm_title:"删除此版块?",shortcut_delete_confirm_desc:"版块内仍有内容模块,确定要删除吗?",context_duplicate:"复制",context_copy:"复制到剪贴板",context_cut:"剪切",context_paste:"粘贴",context_delete:"删除",context_move_up:"上移",context_move_down:"下移",context_save_global:"保存为全局组件",context_reset_styles:"重置样式",topbar_back_to_templates:"模板",topbar_breadcrumb_email:"邮件",topbar_rename_template:"重命名模板",topbar_untitled_template:"未命名模板",send_test:"发送测试",preview:"预览",html_email_preview:"HTML 预览",html_email_preview_title:"HTML 邮件预览",html_email_preview_device_aria:"HTML 预览设备宽度",html_email_preview_error:"无法生成 HTML 预览,请查看控制台。",save_template:"保存模板",more_actions:"更多操作",keyboard_shortcuts:"键盘快捷键",high_contrast_on:"高对比度开",high_contrast_off:"高对比度关",desktop:"桌面",mobile:"移动",undo:"撤销",redo:"重做",save_state_saved:"已保存",save_state_saving:"保存中…",save_state_unsaved:"未保存",save_state_error:"保存失败",export_validation_open_block:"打开此区块",save:"保存",template_name:"模板名称",save_template_title:"保存模板",save_template_category:"分类",save_template_category_placeholder:"选择或输入分类…",category_promotional:"促销",category_transactional:"事务通知",category_newsletter:"Newsletter",category_onboarding:"Onboarding",category_announcement:"公告",category_other:"其他",send_test_title:"发送测试邮件",send_test_send:"发送测试",send_test_recipients:"收件人",send_test_recipients_placeholder:"name@example.com, another@example.com",send_test_recipients_hint:"按 Enter 或逗号可添加地址。",send_test_payload:"数据上下文",send_test_payload_none:"不附带数据",send_test_payload_profile:"用户资料数据",send_test_payload_event:"事件数据",send_test_prefix_label:"[TEST] 前缀",send_test_prefix_hint:"在邮件主题前添加 [TEST]。",universal:"通用",layers:"图层",document:"文档",layer_one:"个区块",layer_many:"个区块",layer_move_up:"上移",layer_move_down:"下移",layer_duplicate:"复制",layer_delete:"删除",universal_saved_blocks:"已保存区块",universal_empty_state_line_1:"还没有通用内容。点击",universal_empty_state_line_2:"可将区块保存以在其他模板中复用。",universal_used_in_count:"已使用 {{count}}",compliance:"合规",compliance_preflight:"发送前检查",compliance_all_clear_title:"准备就绪",compliance_all_clear_desc:"所有合规检查均已通过。",compliance_severity_error:"错误",compliance_severity_warning:"警告",compliance_severity_info:"信息",compliance_tab_badge_label:"未解决问题:{{count}}",compliance_email_size:"邮件大小(估算)",compliance_above_clip:"已超过 Gmail 约 102 KB 折叠阈值,收件箱中可能会被截断显示。",compliance_below_clip:"低于 Gmail 折叠阈值",right_panel_empty_hint:"点击画布中的任意区块以编辑其特定设置。从左侧栏拖动区块以添加新内容。",right_panel_back:"返回",layer_show:"显示",layer_hide:"隐藏",save_as_universal:"保存为通用区块",universal_save_modal_title:"保存为通用区块",universal_save_modal_subtitle:"可在多个模板中复用。编辑不会影响已发送的邮件。",universal_save_modal_placeholder:"例如:Beantown 页脚",universal_save_modal_confirm:"保存区块",universal_save_success:"已保存为通用区块:{{name}}",universal_save_error:"保存失败,请检查网络后重试。",universal_delete:"删除",universal_delete_confirm_title:"移除已保存区块?",universal_delete_confirm_body:"将从素材库中移除,已发送邮件不受影响。",universal_delete_confirm_ok:"移除",configure_columns_title:"配置分栏",configure_columns_subtitle:"选择一种布局。每一列初始为空,可拖入区块。",configure_columns_insert:"插入版块",configure_columns_hint:"点击配置布局",configure_columns_row_count:"插入行数:",standard_layout:"标准布局",grid_layout:"6/12 栅格",grid_settings:"网格",grid_rows_locked_hint:"邮件分栏为单行布局,行数固定为 1。",columns_layout:"分栏布局",column_sizes:"列宽 (%)",show_more:"展开",show_less:"收起",col:"列",gaps:"间距",column_gap:"列间距",button_variant:"样式变体",full_width:"全宽",hover_bg_color:"悬停背景色",hover_text_color:"悬停文字颜色",text_decoration:"文本装饰",shadow:"阴影",shadow_preset:"预设",table:"表格",table_settings:"表格设置",footer_settings:"页脚设置",cell_content:"单元格内容",add_link_url:"链接地址",add_link_display_text:"显示文本",add_link_display_text_placeholder:"留空则保留当前选中文本",add_link_display_text_empty_badge:"未填写 — 将使用选中的文字作为链接文字",add_link_open_new_tab:"在新标签页打开",align_left:"左对齐",align_center:"居中对齐",align_right:"右对齐",minimize_toolbar:"收起",close_text_editor:"退出文本编辑",unlink_universal:"解除当前副本关联",unlink_modal_title:"编辑通用区块",unlink_modal_keep:"保持关联",unlink_modal_unlink:"仅解绑当前副本",unlink_modal_body:"该区块当前关联到通用内容。直接编辑会影响所有使用该通用区块的位置。",unlink_modal_body2:"选择“仅解绑当前副本”可只在当前模板独立编辑;选择“保持关联”则继续联动所有实例。",custom:"自定义",custom_color:"自定义颜色",show_text_label:"显示文字标签",mobile_optimization:"移动端优化",stack_columns_on_mobile:"移动端堆叠栏目",scale_font_on_mobile:"移动端缩小字体",section_layout:"版块布局",content_max_width:"内容最大宽度",min_height:"最小高度",border:"边框",border_style:"边框样式",border_width:"边框宽度",border_color:"边框颜色",visibility:"可见性",hidden_on_mobile:"在移动端隐藏",table_structure:"表格结构",rows:"行",header_row:"标题行",header_column:"标题列",cell_selector:"单元格选择器",cell_content_type:"单元格内容类型",table_style:"表格样式",cell_padding:"单元格内边距",header_style:"标题样式",header_background:"标题背景",header_text_color:"标题文字颜色",striped_rows:"斑马纹行",stripe_color:"斑马纹颜色",table_structure_mode:"模式",table_mode_static:"静态",table_mode_dynamic:"动态",table_dynamic_structure_hint:"导出仍为静态 HTML;数据驱动表格或将在后续版本接入。",table_add_row:"添加行",table_add_column:"添加列",table_decrease_rows:"减少行数",table_increase_rows:"增加行数",table_decrease_cols:"减少列数",table_increase_cols:"增加列数",table_selected_cell:"已选:第 {{row}} 行,第 {{col}} 列",table_select_cell_hint:"在网格中点击单元格以编辑内容。",table_cell_grid_truncated:"仅显示前 {{rows}} × {{cols}} 格",table_cell_text_placeholder:"单元格文字…",table_align_left:"左对齐",table_align_center:"居中",table_align_right:"右对齐",footer_sections:"页脚区块",show_brand:"品牌信息",brand_name:"品牌名称",brand_tagline:"品牌标语",show_address:"地址",address:"地址文本",show_unsubscribe:"退订链接",unsubscribe_text:"链接文案",unsubscribe_url:"退订链接 URL",show_social:"社交图标",social_icons_hint:"请在该区块的内容设置里配置社交图标。",show_secondary_links:"次级链接",show_copyright:"版权信息",copyright_text:"版权文本",footer_style:"页脚样式",padding_top:"顶部内边距",padding_bottom:"底部内边距",show_divider:"显示分割线"},jo={drag_block_here:"Drag block here",drop_content_here:"Drop content here",drop_content_hint:"Drag blocks from the left, or click to insert.",drag_section_here:"Drag section here",blocks:"Blocks",photos:"Photos",powered_by_pexels:"Powered by Pexels",loading:"Loading...",content:"Content",typography:"Typography",styles:"Styles",ai_powered:"AI powered",layout:"Layout",components:"Components",presets:"Presets",body_settings:"Theme Settings",global:"Global",text_and_headings:"Text and headings",pre_header:"Pre-header",pre_header_description:"The pre-header is a short summary text that follows the subject line when viewing an email in the inbox.",confirm:"Confirm",cancel:"Cancel",add_blocks:"Add blocks",block_product:"Product",block_product_single:"Single",block_product_multi:"Multi",block_discount:"Discount",block_introduction:"Introduction",block_body:"Body",block_header:"Header",block_footer:"Footer",no_product_found:"No product found",no_products_matching_search:"No products match your search. Clear the search to see the full list.",load_more_products:"Load more",add_products:"Add products",add_products_in_store:"Add products in your store.",column:"Column",columns:"Columns",column_settings:"Column Settings",column_cells_section:"Column cells",column_wrapper_style:"Wrapper style",column_styles:"Column Styles",size_px:"Size",column_delete:"Delete Column",column_delete_desc:"Are you sure you want to delete {{count}} extra columns? ",block_palette_section:"Section",block_palette_columns:"Column",settings_title_column_layout:"Column settings",container:"Section",select_parent_section_tooltip:"Parent section settings — layout, spacing, and background",container_settings:"Section settings",layers_panel:"Layers",email_styles_section:"Email styles",document_section:"Document",body_bg_color_short:"Bg color",body_content_bg_short:"Content bg",body_width_label:"Width",body_font_short:"Font",body_text_short:"Text",body_heading_short:"Heading",body_link_short:"Link",type_styles_section:"Type",container_type:"Section type",container_type_help:"Determines which variables and product mappings are available for this section.",container_type_none:"Default",container_type_header:"Header",container_type_discount:"Discount",container_type_introduction:"Introduction",container_type_body:"Body",container_type_product:"Product",container_type_hero_product:"Hero Product",container_type_additional_product:"Additional Product",container_type_footer:"Footer",product_role:"Product Role",product_role_main_hero:"Primary",product_role_additional:"Secondary",assign_product_to_column:"Assign product to column",text:"Text",text_content:"This is a text, click to edit text",text_settings:"Text Settings",text_styles:"Text Styles",text_align:"Text Align",heading:"Heading",heading_content:"This is a heading, click to edit heading",heading_settings:"Heading Settings",heading_type:"Heading Type",button:"Button",button_settings:"Button Settings",button_action:"Button Action",button_styles:"Button Styles",button_padding:"Button Padding",spacer:"Spacer",spacer_block:"SPACER BLOCK",spacer_settings:"Spacer Settings",divider:"Divider",divider_settings:"Divider Settings",divider_type:"Divider Type",divider_styles:"Divider Styles",image:"Image",image_action:"Image Action",image_url:"Image URL",image_alt:"Image Alt",image_alt_placeholder:"Describe for screen readers",image_styles:"Image Styles",image_settings:"Image Settings",image_crop_soon:"Image cropping is not available yet.",crop:"Crop",replace:"Replace",delete:"Delete",image_max_upload_size:"max 10 MB",video:"Video",video_settings:"Video",video_tab_styles:"Styles",video_tab_display:"Display",video_url:"Video URL",video_thumbnail_url:"Custom thumbnail URL",video_thumbnail_url_placeholder:"Leave empty to use YouTube thumbnail",video_export_note:"Email clients typically show a linked thumbnail, not embedded playback.",video_thumbnail_layout:"Thumbnail layout",video_width:"Width (W)",video_height:"Height (H)",video_fill_column:"Fill column",video_fill_column_mobile:"Fill column on mobile",alignment:"Alignment",video_area_section:"Video area",video_block_section:"Block",video_border_none:"None",image_source:"Image source",image_source_url:"Enter URL",image_source_upload:"Upload image",image_upload:"Upload",image_upload_click:"Click to upload",image_upload_not_configured:"Image upload is not configured. Set imageUploadEndpoint in apiConfig or pass null to disable; defaults use the built-in API base.",image_uploaded:"Image uploaded successfully",image_upload_failed:"Failed to upload image",image_upload_error:"Error uploading image",image_upload_file_hint:"PNG, JPEG, GIF, SVG, WebP · max 10 MB",image_upload_invalid_type:"Use PNG, JPEG, GIF, SVG, or WebP.",uploading:"Uploading…",image_source_variable:"Use variable",menu:"Navigation bar",menu_settings:"Navigation bar Settings",menu_layout:"Menu layout",layout_mode:"Layout mode",nav_only:"Navigation only",stacked:"Stacked",logo_left:"Logo left",logo_right:"Logo right",logo_only:"Logo only",mobile_layout:"Mobile layout",stack:"Stack",inline:"Inline",logo_section:"Logo section",show_logo:"Show logo",logo_url:"Logo URL",logo_text:"Logo text",logo_alt:"Logo alt",logo_link:"Logo link",logo_max_width:"Logo max width",border_bottom:"Border bottom",show_border_bottom:"Show border bottom",font_weight:"Font weight",font_weight_light:"Light",font_weight_regular:"Regular",font_weight_semibold:"Semi-bold",font_weight_bold:"Bold",text_transform:"Text transform",menu_items:"Menu Items",menu_item:"Menu Item",menu_styles:"Menu Styles",add_new_item:"Add New Item",label:"Label",page:"Page",url:"URL",target:"Target",same_tab:"Same Tab",new_tab:"New Tab",separator:"Separator",menu_separator_placeholder:'e.g. " | " or " • "',menu_separator_allowed_hint:"Only these symbols: | • — / · You may add spaces.",menu_link_gap:"Link spacing",menu_underline_links:"Underline links",logo_text_placeholder:"Brand",letter_spacing:"Letter Spacing",link_color:"Link Color",avatar:"Avatar",avatar_settings:"Avatar Settings",avatar_image:"Avatar image",avatar_border_radius:"Border radius",social_link:"Social Link",social_link_settings:"Social Link Settings",add_social_link:"Add Social Link",social_link_size:"Social Link Size",icon_styles:"Icon styles",icon_size:"Icon size",icon_size_small:"Small",icon_size_medium:"Medium",icon_size_large:"Large",icon_color:"Icon color",icon_color_default:"Default",icon_color_white:"White",icon_color_black:"Black",icon_color_gray:"Gray",social_icon_spacing:"Icon spacing",social_links:"Social Links",social_platform_x:"X",social_platform_formerly_twitter:"Formerly Twitter",social_platform_x_alt:"X, formerly Twitter",social_link_placeholder_facebook:"https://www.facebook.com/yourpage",social_link_placeholder_linkedin:"https://www.linkedin.com/company/yourcompany",social_link_placeholder_instagram:"https://www.instagram.com/yourhandle",social_link_placeholder_tiktok:"https://www.tiktok.com/@yourhandle",social_link_placeholder_x:"https://x.com/yourhandle",social_link_placeholder_youtube:"https://www.youtube.com/yourchannel",social_link_placeholder_pinterest:"https://www.pinterest.com/yourprofile",social_link_placeholder_generic:"https://example.com",raw_html:"HTML",raw_html_block:"RAW HTML",raw_html_settings:"HTML Settings",raw_html_code_label:"Code",raw_html_code_hint:"Inserted as-is in the exported email. Prefer table-based layouts and inline CSS for client compatibility.",raw_html_default_content:'<p style="text-align:center;color:#A3A3A3;font-size:12px">Add custom HTML here</p>',raw_html_appearance:"Layout",raw_html_clear_background:"Clear",raw_html_email_client_warning:"Custom HTML may render inconsistently across email clients. Test thoroughly.",raw_html_info_tooltip_aria:"More about raw HTML",content_background_color:"Content Background Color",container_background_image_title:"Section background image",container_background_image_section_title:"Section background image",container_background_image_section_toggle:"Show section background image",container_background_image_layout_group:"Image layout",container_background_image_row_label:"Background image",container_background_image_intro:"Blocks you add to this section (text, buttons, images, etc.) appear on top of the image. Drag components from the palette into the section on the canvas.",container_background_image_tooltip_p1:"Uses a background image on the section table (email-client friendly — not CSS position:absolute).",container_background_image_tooltip_p2:"Use “Content background color” for a tint behind blocks, or set it transparent so only the photo shows through.",container_background_image_enable:"Enable background image",container_background_image_url:"Image URL",container_background_image_upload:"Upload image",container_background_image_upload_click:"Drag and drop or select image",container_background_image_file_hint:"Accepts .png, .jpg, .jpeg, .gif, and .webp. Maximum file size 10 MB.",container_background_image_select_button:"Select image",container_background_image_clear:"Remove background image",container_background_image_size:"Image fit",container_background_image_position:"Focal point",container_bg_size_cover:"Cover",container_bg_size_contain:"Contain",container_bg_size_fill:"Fill",image_file_too_large:"Image must be 10 MB or smaller.",container_bg_image_url_error_blocked_scheme:"This URL uses a blocked protocol. Use only http:// or https:// for images.",container_bg_image_url_error_duplicate_protocol:"The URL repeats the protocol. Use a single https:// prefix.",container_bg_image_url_error_hostname:"Use a full URL with a valid hostname (e.g. https://cdn.example.com/photo.jpg).",container_bg_image_url_error_invalid_protocol:"Unsupported protocol. Use http:// or https:// for image URLs.",container_bg_image_url_error_generic:"Invalid image URL format.",container_bg_image_preview_failed:"Could not load a preview for this URL. It may not be an image, or the host blocked the request.",image_text_overlay:"Text overlay",overlay_multi_item:"Multi-item stack",add_overlay_item:"Add overlay item",drag_to_move:"Drag to move",overlay_max_width:"Overlay max width",item_gap:"Item gap",scrim:"Scrim",text_shadow:"Text shadow",fill_column:"Fill column",image_text_overlay_tip:"Optional caption drawn on top of the image in the editor. For full layouts over a photo, use a section background image instead.",image_text_overlay_container_tip:"Select the section → Styles → Section background image, then drag text and buttons into that section.",image_text_overlay_enable:"Enable text overlay",image_overlay_caption:"Caption",image_overlay_caption_placeholder:"Short line of text…",image_overlay_position:"Caption position",image_overlay_pos_tl:"Top left",image_overlay_pos_tc:"Top center",image_overlay_pos_tr:"Top right",image_overlay_pos_ml:"Middle left",image_overlay_pos_mc:"Middle center",image_overlay_pos_mr:"Middle right",image_overlay_pos_bl:"Bottom left",image_overlay_pos_bc:"Bottom center",image_overlay_pos_br:"Bottom right",image_overlay_box_bg:"Caption box background (CSS)",image_overlay_padding:"Caption padding",background_color:"Background Color",text_color:"Text Color",email_theme_background_color:"Email Theme Background Color",font_color:"Font Color",button_color:"Button Color",divider_color:"Divider Color",action_type:"Action Type",content_background:"Content background",heading_color:"Heading color",top:"Top",right:"Right",left:"Left",bottom:"Bottom",line_height:"Line Height",link:"Link",link_url:"Link URL",link_url_placeholder:"example.com",padding_settings:"Padding Settings",width:"Width",height:"Height",width_auto:"Width Auto",auto_width:"Auto Width",font_size:"Font Size",font_family:"Font Family",solid:"Solid",dotted:"Dotted",dashed:"Dashed",align:"Align",spacing:"Spacing",border_radius:"Border radius",link_all_sides:"Link all sides",padding_link_sides_label:"Same padding on all sides",padding_link_sides_tooltip:"When on, one value updates top, right, bottom, and left together. Turn off to set each side separately.",email_width_mode:"Width",email_width_default:"Email-width (default)",custom_px:"Custom px",custom_width_px:"Custom width",full_bleed:"Full bleed",full_bleed_tooltip:"Extends edge-to-edge in clients that support it; clipped to email-width otherwise.",export_html:"Export HTML",export_json:"Export JSON",export_checking_images:"Checking images…",language_zh:"中文",export_validation_title:"Export validation",export_validation_issues_found:"Issues found before export",export_validation_errors:"Errors",export_validation_warnings:"Warnings",export_validation_info:"Info",export_anyway:"Export anyway",ignore:"Ignore",validation_body_content_width_invalid:"Body content width must be between 280 and 1200 px.",validation_body_background_color_missing:"Theme background color is missing.",validation_body_text_color_missing:"Theme text color is missing.",validation_body_font_family_missing:"Theme font family is missing.",validation_image_empty_src:"Image URL is empty; the image will not display.",validation_image_invalid_src:"Image URL format is invalid.",validation_image_invalid_link:"Image link URL format is invalid.",validation_image_url_not_loadable:"Image URL could not be loaded or previewed; the link may be broken, expired, or blocked.",validation_image_empty_alt:"Image alt text is empty; consider adding for accessibility.",validation_avatar_empty_src:"Avatar image URL is empty; avatar will not display.",validation_avatar_invalid_src:"Avatar image URL format is invalid.",validation_avatar_invalid_link:"Avatar link URL format is invalid.",validation_button_empty_link:'Button link URL is empty; will be saved as href="https://".',validation_button_invalid_link:"Button link URL format is invalid.",validation_button_blocked_scheme:"Button link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",validation_button_label_invalid_link:"Button label link URL format is invalid.",validation_button_label_blocked_link_scheme:"Button label link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",validation_rich_text_link_invalid:"Rich text hyperlink URL format is invalid.",validation_rich_text_link_blocked_scheme:"Rich text link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",validation_menu_empty_label:'Menu item label is empty; will show as "Link".',validation_menu_empty_url:'Menu item URL is empty; will be saved as href="#".',validation_menu_invalid_url:"Menu item URL format is invalid.",validation_menu_blocked_scheme:"Menu item URL uses a blocked scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",validation_menu_no_items:"Menu block has no items.",validation_raw_html_empty:"HTML block has no custom markup; export will include an empty wrapper.",validation_social_empty_link:'Social link URL is empty; will be saved as href="https://".',validation_social_invalid_link:"Social link URL format is invalid.",validation_social_blocked_scheme:"Social link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s) only (e.g. www.example.com or https://…).",validation_social_empty_icon:"Social link icon URL is empty; icon will not display.",validation_social_invalid_icon:"Social link icon URL format is invalid.",validation_social_no_links:"Social link block has no links.",validation_social_duplicate_platform:"Duplicate social platform in this block; only one entry per platform should be kept.",validation_container_product_not_assigned:"A product is not assigned to this column; assign a product in Section settings.",validation_dynamic_content_empty:"Dynamic content not generated; export will use static text if available.",validation_text_invalid_link:"Text link URL format is invalid.",validation_text_blocked_link_scheme:"Text link uses a blocked URL scheme (javascript:, data:, etc.). Use http(s), mailto:, or tel: only.",tooltip_bold:"Bold",tooltip_italic:"Italic",tooltip_underline:"Underline",tooltip_strikethrough:"Strikethrough",tooltip_align_left:"Align left",tooltip_align_center:"Align center",tooltip_align_right:"Align right",tooltip_ordered_list:"Ordered list",tooltip_unordered_list:"Unordered list",tooltip_link:"Link",tooltip_remove_link:"Remove link",add_link_modal_title:"Add link",content_type:"Content type",content_type_static:"Static",content_type_dynamic:"Dynamic",ai_enabled:"Write using AI",text_and_content_type:"Content type",heading_or_body:"Heading",body_paragraph:"Body",heading_h1:"H1",heading_h2:"H2",heading_h3:"H3",heading_h4:"H4",variables:"Variables",insert_merge_field:"Select or type variable...",dynamic_prompt_help:"Write your prompt",ai_output_language:"AI output language",ai_output_language_en:"English",ai_output_language_bn:"Bengali",generate:"Generate",ml_generation_failed:"Could not generate AI content",ml_ai_unavailable:"AI generation needs a column layout, company ID, template ID, and ML endpoint. Open this text inside a section column and check apiConfig.",ml_no_variations:"No suggestions were returned. Try another prompt or verify the template exists on the server.",ml_generation_unexpected_error:"Something went wrong while generating content.",sample_ai_content:"Sample AI content",select_content:"Select content",variable_dynamic_placeholder:"None (optional)",variable_display_text:"Display text",variable_introduction:"Introduction",variable_heading:"Heading",variable_subheading:"Subheading",variable_products_description:"Products description",variable_customer_name:"Customer Name",variable_introduction_title:"Introduction Title",variable_introduction_subtitle:"Introduction Subtitle",variable_body_title:"Body Title",variable_body_subtitle:"Body Subtitle",variable_discount_value:"Discount value",variable_discount_code:"Discount code",variable_valid_until:"Valid until",variable_company_name:"Company name",variable_brand_name:"Brand name",variable_address:"Address",variable_website:"Website",variable_logo_url:"Logo URL",variable_tagline:"Tagline",variable_nav_label:"Nav link label",variable_nav_url:"Nav link URL",variable_product_name:"Product name",variable_product_description:"Product description",variable_product_image:"Product image URL",variable_product_link:"Product link",variable_product_price:"Product price",variable_product_currency:"Product currency",variable_product_old_price:"Product old price",variable_product_new_price:"Product new price",variable_product_price_display:"Product price display",variable_image_logo:"Logo",variable_image_hero_banner:"Hero banner",variable_image_footer_banner:"Footer banner",variable_image_product_image:"Product image",variable_cta_label:"CTA label",variable_cta_url:"CTA URL",button_label_variable:"Button label (variable)",button_url_variable:"Use variable",button_text:"Button text",button_label_manual:"Enter label",button_url_manual:"Enter URL",use_company_social_links:"Use company social links",use_navigation_links:"Use navigation links",tooltip_container_type:"Determines which variables and product mappings are available for this section.",tooltip_variables_static:"Insert a merge field into your content. It will be replaced when the email is sent.",tooltip_dynamic_prompt:"Describe the tone or intent; we'll suggest sample content. (Preview mode — connect an AI API for real generation.)",tooltip_write_using_ai:"When on, choose output language and write a prompt to generate variants. Requires ML/API when connected.",tooltip_write_using_ai_unavailable:"AI authoring is disabled for this editor. Enable it from the host app or API options to use Write using AI.",label_align:"Align",label_padding:"Padding",section_background_group:"SECTION BACKGROUND",section_bg_mode:"Type",section_bg_color:"Color",section_bg_image:"Image",section_bg_none:"None",section_content_area_group:"CONTENT AREA",content_area_color:"Content color",content_color_auto:"Auto",content_color_custom:"Custom",shortcuts_modal_title:"Keyboard shortcuts",shortcuts_modal_footnote:"Shortcuts are disabled while typing in text fields inside the settings panel, so you can edit URLs and copy/paste normally.",shortcut_save:"Save (handled by the host page when connected)",shortcut_undo:"Undo",shortcut_redo:"Redo",shortcut_duplicate:"Duplicate selected block",shortcut_copy_block:"Copy selected block",shortcut_paste_block:"Paste block",shortcut_delete_block:"Delete selected block",shortcut_escape:"Deselect block",shortcut_cheat_sheet:"Open this help",shortcut_delete_confirm_title:"Delete this section?",shortcut_delete_confirm_desc:"This section has content blocks inside. Delete it anyway?",section_nest_not_allowed:"Sections cannot be placed inside another section. Drop between sections in the stack.",context_duplicate:"Duplicate",context_copy:"Copy",context_cut:"Cut",context_paste:"Paste",context_delete:"Delete",context_move_up:"Move up",context_move_down:"Move down",context_save_global:"Save as Global Element",context_reset_styles:"Reset styles",topbar_back_to_templates:"Templates",topbar_exit:"Exit",topbar_breadcrumb_email:"Email",topbar_rename_template:"Rename template",topbar_untitled_template:"Untitled template",send_test:"Send test",preview:"Preview",html_email_preview:"HTML preview",html_email_preview_title:"HTML Email Preview",html_email_preview_device_aria:"HTML preview device width",html_email_preview_error:"Could not generate the HTML preview. Check the console for details.",save_template:"Save template",more_actions:"More actions",keyboard_shortcuts:"Keyboard shortcuts",high_contrast_on:"High contrast on",high_contrast_off:"High contrast off",desktop:"Desktop",mobile:"Mobile",undo:"Undo",redo:"Redo",save_state_saved:"Saved",save_state_saving:"Saving…",save_state_unsaved:"Unsaved",save_state_error:"Save failed",export_validation_open_block:"Open block",save:"Save",template_name:"Template name",save_template_title:"Save template",save_template_category:"Category",save_template_category_placeholder:"Select or type a category…",category_promotional:"Promotional",category_transactional:"Transactional",category_newsletter:"Newsletter",category_onboarding:"Onboarding",category_announcement:"Announcement",category_other:"Other",send_test_title:"Send test email",send_test_send:"Send test",send_test_recipients:"Recipients",send_test_recipients_placeholder:"name@example.com, another@example.com",send_test_recipients_hint:"Press Enter or comma to add each address.",send_test_payload:"Payload context",send_test_payload_none:"No payload",send_test_payload_profile:"Profile data",send_test_payload_event:"Event data",send_test_prefix_label:"[TEST] prefix",send_test_prefix_hint:"Prepends [TEST] to the subject line.",universal:"Universal",layers:"Layers",document:"Document",layer_one:"block",layer_many:"blocks",layer_move_up:"Move up",layer_move_down:"Move down",layer_duplicate:"Duplicate",layer_delete:"Delete",universal_saved_blocks:"Saved blocks",universal_empty_state_line_1:"No universal content yet. Click",universal_empty_state_line_2:"on any block to save it for reuse across templates.",universal_used_in_count:"used in {{count}}",compliance:"Compliance",compliance_preflight:"Pre-flight",compliance_all_clear_title:"Ready to send",compliance_all_clear_desc:"All compliance checks pass.",compliance_severity_error:"Error",compliance_severity_warning:"Warning",compliance_severity_info:"Info",compliance_tab_badge_label:"Unresolved issues: {{count}}",compliance_email_size:"Email size (approx.)",compliance_above_clip:"Above Gmail’s ~102 KB clip threshold — heavy templates may be clipped in the inbox.",compliance_below_clip:"Below Gmail clip threshold",right_panel_empty_hint:"Click any block in the canvas to edit its specific settings. Drag blocks from the left rail to add new content.",right_panel_back:"Back",layer_show:"Show",layer_hide:"Hide",save_as_universal:"Save as universal",universal_save_modal_title:"Save as universal block",universal_save_modal_subtitle:"Reusable across templates. Edits won't affect already-sent emails.",universal_save_modal_placeholder:"e.g. Beantown footer",universal_save_modal_confirm:"Save block",universal_save_success:'Saved "{{name}}" as universal block',universal_save_error:"Could not save the universal block. Check your connection and try again.",universal_delete:"Remove",universal_delete_confirm_title:"Remove saved block?",universal_delete_confirm_body:"This removes the block from your saved library. Existing emails are not changed.",universal_delete_confirm_ok:"Remove",configure_columns_title:"Configure columns",configure_columns_subtitle:"Pick a layout. Each column starts empty so you can drag blocks into it.",configure_columns_insert:"Insert section",configure_columns_hint:"click to configure layout",configure_columns_row_count:"Rows to insert:",standard_layout:"Standard",grid_layout:"6/12 Grid",grid_settings:"Grid",grid_rows_locked_hint:"Email layouts use one row of columns.",columns_layout:"Columns layout",column_sizes:"Column widths (%)",show_more:"Show more",show_less:"Show less",col:"Col",gaps:"Gaps",column_gap:"Column gap",button_variant:"Variant",full_width:"Full width",hover_bg_color:"Hover background",hover_text_color:"Hover text",text_decoration:"Decoration",shadow:"Shadow",shadow_preset:"Preset",table:"Table",table_settings:"Table settings",footer_settings:"Footer settings",compliance_approx_kb:"Approx {{n}} KB",cell_content:"Cell content",add_link_url:"URL",add_link_display_text:"Display text",add_link_display_text_placeholder:"Leave blank to keep selected text",add_link_display_text_empty_badge:"No text — link will use selected text",add_link_open_new_tab:"Open in new tab",align_left:"Align left",align_center:"Align center",align_right:"Align right",minimize_toolbar:"Collapse",close_text_editor:"Exit text editing",unlink_universal:"Unlink this copy",unlink_modal_title:"Edit universal block",unlink_modal_keep:"Keep linked",unlink_modal_unlink:"Unlink this copy",unlink_modal_body:"This block is linked to a universal snippet. Editing it here will affect all uses of this block everywhere.",unlink_modal_body2:"Choose “Unlink this copy” to make an independent copy that only affects this template, or “Keep linked” to edit all instances together.",custom:"Custom",custom_color:"Custom color",show_text_label:"Show label",mobile_optimization:"Mobile optimization",stack_columns_on_mobile:"Stack columns on mobile",scale_font_on_mobile:"Scale font on mobile",section_layout:"Section Layout",content_max_width:"Content max-width",min_height:"Min height",border:"Border",border_style:"Border style",border_width:"Border width",border_color:"Border color",visibility:"Visibility",hidden_on_mobile:"Hide on mobile",table_structure:"Table Structure",rows:"Rows",header_row:"Header row",header_column:"Header column",cell_selector:"Cell selector",cell_content_type:"Cell content type",table_style:"Table style",cell_padding:"Cell padding",header_style:"Header style",header_background:"Header background",header_text_color:"Header text color",striped_rows:"Striped rows",stripe_color:"Stripe color",table_structure_mode:"Mode",table_mode_static:"Static",table_mode_dynamic:"Dynamic",table_dynamic_structure_hint:"Export still uses static HTML; data-driven tables may be wired in a future update.",table_add_row:"Add row",table_add_column:"Add column",table_decrease_rows:"Decrease row count",table_increase_rows:"Increase row count",table_decrease_cols:"Decrease column count",table_increase_cols:"Increase column count",table_selected_cell:"Selected: row {{row}}, col {{col}}",table_select_cell_hint:"Select a cell in the grid to edit its content.",table_cell_grid_truncated:"Showing first {{rows}} × {{cols}} cells",table_cell_text_placeholder:"Cell text…",table_align_left:"Left",table_align_center:"Center",table_align_right:"Right",footer_sections:"Footer sections",show_brand:"Brand",brand_name:"Brand name",brand_tagline:"Tagline",show_address:"Address",address:"Address text",show_unsubscribe:"Unsubscribe link",unsubscribe_text:"Link text",unsubscribe_url:"Unsubscribe URL",show_social:"Social icons",social_icons_hint:"Configure social icons in the block's content settings.",show_secondary_links:"Secondary links",show_copyright:"Copyright",copyright_text:"Copyright text",footer_style:"Footer style",padding_top:"Top padding",padding_bottom:"Bottom padding",show_divider:"Show divider"},So=()=>{const{language:t,languageLibraries:n}=e.useContext(ge);let o={zh:wo,en:jo};n&&(o={...o,...n,zh:{...wo,...o.zh||{}},en:{...jo,...o.en||{}}});return{t:(e,n)=>{let a=(o[t]||{})[e];return n&&n instanceof Object&&Object.keys(n).forEach(e=>{a=a.replace(`{{${e}}}`,n[e])}),a||e}}},Co=/\{\{(\w+)\}\}/g;function No(e,t){if(null!=e)if("string"!=typeof e){if(Array.isArray(e))e.forEach(e=>No(e,t));else if("object"==typeof e){if(void 0!==e.$$typeof)return;Object.values(e).forEach(e=>No(e,t))}}else(function(e){if("string"!=typeof e||0===e.length)return[];const t=[];let n;for(;null!==(n=Co.exec(e));){const e=n[1];e&&t.push(e)}return Co.lastIndex=0,t})(e).forEach(e=>t.add(e))}function Io(e,t,n){e&&"object"==typeof e&&(e.id&&n.has(e.id)||(e.id&&n.add(e.id),"column"!==e.key?No(e,t):(e.children||[]).forEach(e=>{(e?.children||[]).forEach(e=>Io(e,t,n))})))}function Ao(e,t,n,o){if(!e||o.has(e))return;o.add(e);const a=t[e];a&&"object"==typeof a&&("column"===a.key?(a.cells||[]).forEach(e=>{(e.childrenIds||[]).forEach(e=>Ao(e,t,n,o))}):No(a,n))}function To(e,t){const n=new Set;if(!e||"object"!=typeof e)return n;if(Array.isArray(e.children)){const t=new Set;return Io(e,n,t),n}if(!t||"object"!=typeof t)return n;const o=new Set;return(e.cells||[]).forEach(e=>{(e.childrenIds||[]).forEach(e=>Ao(e,t,n,o))}),n}const Lo=()=>{const t=(e,n)=>e?e.classList?.contains("text-content_editable")?null:e&&e.tagName?.toLocaleLowerCase()===n?e:t(e.parentNode,n):null,n=e.useCallback((e,t)=>e?e.classList?.contains("text-content_editable")?null:e&&e.style?.[t]?e.style[t]:n(e.parentNode,t):null,[]);return{getSelectionNode:t,getSectionStyle:n}},Bo=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"b"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_bold"),onClick:()=>{t("bold",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faBold,className:"rich-text-tools-button-icon"})})};function $o(e,t){if(!e)return!1;const n=e.commonAncestorContainer;if(!function(e){let t=e;for(t&&3===t.nodeType&&(t=t.parentElement);t;){if(t.classList?.contains("text-content_editable"))return!0;t=t.parentNode}return!1}(n))return!1;try{if(document.queryCommandState("italic"))return!0}catch{}return!("function"!=typeof t||!t(n,"i")&&!t(n,"em"))||function(e){let t=e;for(t&&3===t.nodeType&&(t=t.parentElement);t&&!t.classList?.contains("text-content_editable");){if(1===t.nodeType){const e=t.tagName?.toLowerCase();if("i"===e||"em"===e)return!0;const n=t.style?.fontStyle;if("italic"===n||"oblique"===n)return!0;try{if("undefined"!=typeof window&&window.getComputedStyle){const e=window.getComputedStyle(t).fontStyle;if("italic"===e||"oblique"===e)return!0}}catch{}}t=t.parentNode}return!1}(n)}const Ro=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=$o(i,r);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_italic"),onClick:()=>{try{document.execCommand("styleWithCSS",!1,!0)}catch{}t("italic",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faItalic,className:"rich-text-tools-button-icon"})})},Mo=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"u"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_underline"),onClick:()=>{t("underline",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faUnderline,className:"rich-text-tools-button-icon"})})},Po=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"strike"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_strikethrough"),onClick:()=>{t("strikethrough",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faStrikethrough,className:"rich-text-tools-button-icon"})})},Fo=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"ol"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_ordered_list"),onClick:()=>{t("insertOrderedList",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faListOl,className:"rich-text-tools-button-icon"})})},Eo=({modifyText:t,setTextContent:a})=>{const{selectionRange:i}=e.useContext(ge),{getSelectionNode:r}=Lo(),{t:s}=So(),c=e.useMemo(()=>i?r(i.commonAncestorContainer,"ul"):null,[i,r]);return l.jsx("button",{className:fo("rich-text-tools-button ",c&&"rich-text-tools-button-active"),title:s("tooltip_unordered_list"),onClick:()=>{t("insertUnorderedList",!1,null),a()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faListUl,className:"rich-text-tools-button-icon"})})},Do=({modifyText:a,setTextContent:i})=>{const{selectionRange:r}=e.useContext(ge),{t:s}=So(),{getSelectionNode:c}=Lo(),[d,u]=e.useState(!1),[m,p]=e.useState({value:"",range:null}),[g,h]=e.useState(""),[b,y]=e.useState(!0),_=e.useRef(null),f=e.useMemo(()=>r?c(r.commonAncestorContainer,"a"):null,[r,c]),x=()=>{u(!1),p({value:"",range:null}),h(""),y(!0)};return l.jsxs(l.Fragment,{children:[l.jsx("button",{className:fo("rich-text-tools-button ",f&&"rich-text-tools-button-active"),title:s("tooltip_link"),onClick:e=>{let t=window.getSelection(),n=t.getRangeAt(0);const o=n.commonAncestorContainer.parentNode,a="A"===o.nodeName,l={...m,range:n};let r="",s=!0;if(a){l.rangeIsLink=!0;const e=o.getAttribute("href"),t=null!=e?String(e).trim():"";l.value=""!==t?t:String(o.href||"").trim(),r=o.textContent||"",s="_self"!==o.target}else{r=t.toString()}const c=e?.currentTarget?.closest?.(".email-editor");c&&(_.current=c),p(l),h(r),y(s),u(!0),i()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faLink,className:"rich-text-tools-button-icon"})}),l.jsx("button",{className:fo("rich-text-tools-button"),title:s("tooltip_remove_link"),onClick:()=>{a("unlink",!1,null),i()},children:l.jsx(n.FontAwesomeIcon,{icon:o.faUnlink,className:"rich-text-tools-button-icon"})}),l.jsx(t.Modal,{title:s("add_link_modal_title"),open:d,zIndex:1100,getContainer:()=>"undefined"==typeof document?null:_.current||document.querySelector(".email-editor")||document.body,onOk:()=>{const{range:e,value:t,rangeIsLink:n}=m;if(e){if(n){const n=e.commonAncestorContainer,o=1===n.nodeType&&"A"===n.nodeName?n:n.parentNode&&"A"===n.parentNode.nodeName?n.parentNode:null;o&&(o.setAttribute("href",t),o.target=b?"_blank":"_self",g.trim()&&(o.textContent=g.trim()))}else{const n=document.createElement("a");if(n.target=b?"_blank":"_self",n.setAttribute("href",t),g.trim())n.textContent=g.trim(),e.deleteContents(),e.insertNode(n);else try{e.surroundContents(n)}catch{return void x()}}i(),x()}else x()},onCancel:x,okText:s("confirm"),cancelText:s("cancel"),wrapClassName:"ee-modal-dark",children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:4,fontSize:12,fontWeight:500},children:s("add_link_url")||"URL"}),l.jsx(t.Input,{value:m.value??"",placeholder:s("link_url_placeholder"),onChange:e=>p({...m,value:e.target.value})})]}),l.jsxs("div",{children:[l.jsxs("div",{style:{marginBottom:4,display:"flex",alignItems:"center",flexWrap:"wrap",gap:8},children:[l.jsx("span",{style:{fontSize:12,fontWeight:500},children:s("add_link_display_text")||"Display text"}),g.trim()?null:l.jsx(t.Badge,{status:"warning",text:s("add_link_display_text_empty_badge"),className:"ee-link-modal-display-text-badge"})]}),l.jsx(t.Input,{value:g,placeholder:s("add_link_display_text_placeholder")||"Leave blank to keep selected text",onChange:e=>h(e.target.value)})]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[l.jsx("span",{style:{fontSize:13},children:s("add_link_open_new_tab")||"Open in new tab"}),l.jsx(t.Switch,{className:"ee-settings-switch",checked:b,onChange:y})]})]})})]})},Uo=({id:i,textBlock:r,syncTextFromDom:s})=>{const{blockMap:c,rootOrder:d,templateData:u}=e.useContext(ge),{t:m}=So(),p=e.useRef(null),[g,h]=e.useState(!1),[b,y]=e.useState(!1),_=e.useMemo(()=>{const e=E(c,d,i),t=e?.[0]??null;return{containerBlock:t?.containerBlock??null,containerType:t?.containerType??"none",cellIndex:t?.cellIndex??0,lineage:e}},[c,d,i]),f=e.useMemo(()=>{const e=_?.cellIndex??0,t=_?.containerBlock;return{columnIndex:e,columnProduct:t?.columnProducts?.[e]??null}},[_]),x=e.useMemo(()=>(_?.lineage??[]).slice(1).filter(e=>e?.containerType&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[_?.lineage]),k=e.useMemo(()=>jt(0,_?.containerType??"none",u,f,x),[_?.containerType,u,f,x]),v=e.useMemo(()=>To(_?.containerBlock,c),[_?.containerBlock,c]),w=e.useMemo(()=>k.filter(e=>"image"!==e.type&&!v.has(e.variableKey??e.key)),[k,v]),j=e.useCallback(()=>{if(!p.current)return;const e=p.current.parentNode?.getBoundingClientRect(),t=document.querySelector("#preview");if(!e||!t)return;const n=t.getBoundingClientRect();e.top-190<0?(p.current.style.bottom="auto",p.current.style.top="110%"):(p.current.style.bottom="110%",p.current.style.top="auto"),e.left+420>n.left+n.width?(p.current.style.left="auto",p.current.style.right="0"):(p.current.style.left="0",p.current.style.right="auto")},[]);e.useEffect(()=>{j()},[j]),e.useEffect(()=>{const e=()=>{const e="undefined"!=typeof window&&window.getSelection(),t=p.current;if(!e||0===e.rangeCount||!t)return void j();const n=e.getRangeAt(0),o=r?.current;if(!o||!o.contains(n.commonAncestorContainer)||e.isCollapsed)return void j();const a=n.getBoundingClientRect();if(!a||0===a.width&&0===a.height)return void j();const l=t.parentNode;if(!l)return;const i=l.getBoundingClientRect(),s=document.querySelector("#preview"),c=s?s.getBoundingClientRect():null;let d=a.top-i.top-46-8;a.top-60<0&&(d=a.bottom-i.top+8);let u=a.left-i.left+a.width/2-210;if(c){const e=c.left-i.left+8,t=c.right-i.left-8-420;u=Math.max(e,Math.min(u,t))}t.style.top=`${d}px`,t.style.bottom="auto",t.style.left=`${u}px`,t.style.right="auto"};return document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e)},[j,r]);const S=(e,t,n)=>{document.execCommand(e,t,n)},C=()=>{"function"!=typeof s?r?.current&&("undefined"!=typeof InputEvent&&InputEvent?r.current.dispatchEvent(new InputEvent("input",{bubbles:!0,cancelable:!0})):r.current.dispatchEvent(new Event("input",{bubbles:!0}))):s()};return l.jsx("div",{className:"rich-text",ref:p,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:l.jsx(a.motion.div,{className:"rich-text-tools",initial:{scale:0,x:0},animate:{scale:1,x:0},style:{width:g?"auto":"max-content",maxWidth:"min(100%, 520px)"},children:l.jsxs("div",{className:"rich-text-tools-body items-center",children:[!g&&l.jsxs(l.Fragment,{children:[l.jsx(Bo,{modifyText:S,setTextContent:C}),l.jsx(Ro,{modifyText:S,setTextContent:C}),l.jsx(Mo,{modifyText:S,setTextContent:C}),l.jsx(Po,{modifyText:S,setTextContent:C}),l.jsx(Fo,{modifyText:S,setTextContent:C}),l.jsx(Eo,{modifyText:S,setTextContent:C}),l.jsx(Do,{modifyText:S,setTextContent:C}),l.jsx(t.Popover,{zIndex:540,trigger:"click",open:b,onOpenChange:y,overlayClassName:"ee-rich-text-variables-popover",getPopupContainer:()=>document.querySelector("#preview")||document.body,content:l.jsxs("div",{className:"ee-rich-text-variables-menu",children:[l.jsx("div",{className:"ee-rich-text-variables-header",children:m("variables")}),w.map(e=>l.jsx("div",{className:"ee-rich-text-variables-item",onMouseDown:t=>{t.preventDefault(),(e=>{if(!r?.current||!e)return;const t=window.getSelection();let n=null;if(t?.rangeCount){const e=t.getRangeAt(0);r.current.contains(e.commonAncestorContainer)&&(n=e)}n||(n=document.createRange(),n.selectNodeContents(r.current),n.collapse(!1)),n.deleteContents();const o=document.createTextNode(e);n.insertNode(o),n.setStartAfter(o),n.collapse(!0),t&&(t.removeAllRanges(),t.addRange(n)),C(),y(!1)})(e.value)},children:e.labelKey?m(e.labelKey):e.label||e.value},`variables-${e.value}`))]}),children:l.jsx("button",{className:"rich-text-tools-button",title:m("insert_merge_field"),onMouseDown:e=>e.preventDefault(),children:l.jsx("span",{className:"rich-text-tools-button-icon",style:{color:"#fff",fontFamily:"monospace",fontWeight:700,fontSize:13,lineHeight:1},children:"{}"})})})]}),l.jsx("button",{className:"rich-text-tools-button",title:m("minimize_toolbar")||"Collapse",onClick:()=>h(!g),children:l.jsx(n.FontAwesomeIcon,{icon:g?o.faExpandAlt:o.faCompressAlt,className:"rich-text-tools-button-icon"})})]})})})},zo=({id:t,blockItem:n,displayContent:o})=>{const{currentItem:a,previewMode:i,blockMap:r,rootOrder:s,setBlocks:c,setCurrentItem:d,isDragStart:u,templateData:m,registerRichTextFlush:p}=e.useContext(ge),g=e.useRef(null),h=a&&a.id===(t??n?.id)&&!("text"===n?.key&&"dynamic"===n?.contentType),b="desktop"===i?n.styles?.desktop??{}:{...n.styles?.desktop??{},...n.styles?.mobile??{}},y=b.linkColor||"#2faade",{linkColor:_,...f}=b,x={...f,direction:"ltr",unicodeBidi:"isolate","--ee-rich-text-link-color":y},k=e.useRef(!1),v=null!=o?o:n.text||"",w=e.useMemo(()=>{const e=E(r,s,t??n?.id),o=e?.[0]??null;return{containerBlock:o?.containerBlock??null,containerType:o?.containerType??"none",cellIndex:o?.cellIndex??0,lineage:e}},[r,s,t,n?.id]),j=e.useMemo(()=>{const e=w?.cellIndex??0,t=w?.containerBlock;return{columnIndex:e,columnProduct:t?.columnProducts?.[e]??null}},[w]),S=e.useMemo(()=>(w?.lineage??[]).slice(1).filter(e=>e?.containerType&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[w?.lineage]),C=e.useMemo(()=>jt(0,w?.containerType??"none",m,j,S).map(e=>{return t=e.value,n=e.pasteValue,{token:t,pasteValue:String(n||"")};var t,n}).filter(e=>e.token&&e.pasteValue&&""!==e.pasteValue.trim()&&!e.pasteValue.includes("{{")&&e.pasteValue!==e.token).sort((e,t)=>t.pasteValue.length-e.pasteValue.length),[m,j,w?.containerType,S]),N=e.useCallback(e=>{if(!e||!C.length||"undefined"==typeof document)return e;const t=document.createElement("div");t.innerHTML=e;const n=document.createTreeWalker(t,NodeFilter.SHOW_TEXT);let o=n.nextNode();for(;o;){const e=o.nodeValue||"",{masked:t,tokens:a}=ko(e);let l=t;C.forEach(({token:e,pasteValue:t})=>{t&&l.includes(t)&&(l=l.split(t).join(e))}),o.nodeValue=vo(l,a),o=n.nextNode()}return t.innerHTML},[C]);e.useEffect(()=>{if(h&&g.current){const e=xo(v);if(k.current){e!==xo(g.current.innerHTML||"")&&(g.current.innerHTML=e)}else g.current.innerHTML=e,g.current.focus();k.current=!0}else k.current=!1},[h,t,v]);const I=e.useCallback(e=>{if(!e)return;const l=t??n?.id,i=r[l]||{},{textToStore:u,unchangedFromResolved:m}=function({rawHtml:e,displayContent:t,blockItemText:n,oldBlockKey:o,blockItemKey:a,restoreVariableTokensInHtml:l}){const i=xo(e),r=null!=t?xo(String(t)):null,s=!/<\s*a\b/i.test(i)&&null!=r&&i===r;let c=s?n:i;return"text"===(o??a)&&"function"==typeof l&&(c=l(c)),{textToStore:c,unchangedFromResolved:s}}({rawHtml:e.innerHTML,displayContent:o,blockItemText:n.text,oldBlockKey:i.key,blockItemKey:n.key,restoreVariableTokensInHtml:N}),p={...i,text:u,selectedVariableKey:m?i.selectedVariableKey:void 0},g={...r,[l]:p};c(g,s,`edit_${Date.now()}`),d({...a,data:p})},[t,n?.id,n?.key,n?.text,r,s,c,d,a,o,N]),A=e.useCallback(()=>{I(g.current)},[I]);e.useEffect(()=>{if(h&&"function"==typeof p)return p(A)},[h,p,A]);const T=xo(v),L=t??n?.id;return l.jsxs("div",{className:"relative",dir:"ltr",style:{direction:"ltr",unicodeBidi:"isolate"},children:[h&&n&&!u&&l.jsx(Uo,{textBlock:g,id:L,syncTextFromDom:A}),l.jsx("div",{className:fo(h&&"text-block","text-content_editable"),onClick:e=>{e.preventDefault(),e.stopPropagation()},onBlur:A,onCompositionEnd:A,style:x,dir:"ltr",contentEditable:h,suppressContentEditableWarning:!0,ref:g,dangerouslySetInnerHTML:h?void 0:{__html:T}})]})},Oo=t=>{const{id:n,blockItem:o}=t,{currentItem:a,previewMode:i,templateData:r,blockMap:s,rootOrder:c}=e.useContext(ge),d="desktop"===i?o.styles?.desktop??{}:{...o.styles?.desktop??{},...o.styles?.mobile??{}},u=a&&a.id===n,m=e.useMemo(()=>D(s,c,n),[s,c,n]),p=e.useMemo(()=>dt(o.text,r,m),[o.text,r,m]),g=u?o.text||"":p,h=null!=d.linkColor&&""!==String(d.linkColor).trim()?String(d.linkColor).trim():"#2faade",b=e.useMemo(()=>At(g,h,{useImportant:!1}),[g,h]),y=m?.containerBlock,_="footer"===y?.containerType,f=(p||"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim();if(_&&(""===f||"{{Address}}"===f||"{{Tagline}}"===f))return null;const x=o.type&&/^h[1-4]$/.test(o.type)?o.type:"div";return u?l.jsx(zo,{...t,blockItem:o}):e.createElement(x,{style:{...d,direction:"ltr",unicodeBidi:"isolate"},dir:"ltr",dangerouslySetInnerHTML:{__html:b}})},Wo=e=>e?.brandContext?.brand_color??"#111111",Ho=t=>{const{blockItem:n,id:o}=t,{currentItem:a,previewMode:i,templateData:r,blockMap:s,rootOrder:c}=e.useContext(ge),d=e.useMemo(()=>D(s,c,o),[o,s,c]),u=e.useMemo(()=>{const e=n.text??"",t=e.match(/\{\{(\w+)\}\}/),o=n.labelVariable?n.labelVariable.replace(/^\{\{|\}\}$/g,"").trim():t?t[1]:void 0;if(!r||!o)return e;const a=yt(r,o,d);return null==a||String(a).startsWith("{{")?e:String(a)},[n.text,n.labelVariable,r,d]),m=a&&a.id===o,p="desktop"===i?n.styles?.desktop??{}:{...n.styles?.desktop??{},...n.styles?.mobile??{}},g={...p,backgroundColor:p.backgroundColor??Wo(r)},h="desktop"===i?n.contentStyles?.desktop:{...n.contentStyles?.desktop,...n.contentStyles?.mobile},b=e.useMemo(()=>l.jsx(zo,{...t,blockItem:{...n,styles:{...n.styles,desktop:{...n.styles?.desktop,backgroundColor:g.backgroundColor}}},displayContent:u}),[n,u,g.backgroundColor]);return l.jsx("div",{style:{...h},children:m?b:l.jsx("div",{style:{...g,textAlign:"center"},dangerouslySetInnerHTML:{__html:u}})})},Vo=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),o="desktop"===n?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},a="desktop"===n?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile};return l.jsx("div",{className:"relative",children:l.jsx("div",{style:{...a},children:l.jsx("div",{style:{...o}})})})},Ko=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),o="desktop"===n?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},a="desktop"===n?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile};return l.jsx("div",{className:"relative",style:{...a},children:l.jsx("div",{style:{width:"100%",height:"number"==typeof o.height?`${o.height}px`:o.height||"16px",display:o.display||"block"}})})},Go={left:"flex-start",center:"center",right:"flex-end",justify:"space-between"},qo=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),{list:o=[],separator:a=" | "}=t,i=o,r=Ht("desktop"===n?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}}),s="desktop"===n?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},c=s&&"object"==typeof s?{...s}:{},d=c.textAlign??"center",u=Go[d]??Go.center;delete c.textAlign;const m=t.linkGapPx,p="number"==typeof m&&Number.isFinite(m)&&m>=0?m:0,g=Boolean(t.linkUnderline),h=r.fontWeight,b="normal"===h||"bold"===h?h:null!=h?String(h):"400",y={fontSize:null!=r.fontSize?`${r.fontSize}px`:"14px",fontFamily:r.fontFamily||"sans-serif",color:r.linkColor||r.color||"#2faade",fontWeight:b,letterSpacing:null!=r.letterSpacing?`${r.letterSpacing}px`:"0px",textDecoration:g?"underline":"none",textTransform:r.textTransform??"none",paddingLeft:"8px",paddingRight:"8px",paddingTop:"4px",paddingBottom:"4px"},_={fontSize:null!=r.fontSize?`${r.fontSize}px`:"14px",color:r.color||"#333",display:"inline-flex",alignItems:"center",whiteSpace:"pre"},f=p>0?{..._,marginLeft:p,marginRight:p}:{..._,paddingLeft:4,paddingRight:4};return l.jsx("div",{className:"relative",children:l.jsx("div",{style:{...c,display:"flex",flexWrap:"wrap",alignItems:"center",justifyContent:u},children:i.map((t,n)=>l.jsxs(e.Fragment,{children:[n>0?l.jsx("span",{style:f,children:a}):null,l.jsx("a",{href:t.url?t.url.startsWith("http")?t.url:`https://${t.url}`:"#",target:"_blank"===t.target?"_blank":"_self",rel:"_blank"===t.target?"noopener noreferrer":void 0,style:y,children:t.label||"Link"})]},n))})})};function Jo(e){return null!=e&&"string"==typeof e&&/<[a-zA-Z!/?]/.test(e.trim())}function Yo(e){switch(e){case"h1":case"h2":case"h3":return 700;case"subtitle":case"eyebrow":return 600;default:return 400}}const Xo=({blockItem:t,id:a})=>{const{src:i,alt:r,linkURL:s}=t,{previewMode:c,templateData:d,blockMap:u,rootOrder:p,bodySettings:g}=e.useContext(ge),h="desktop"===c?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},b="desktop"===c?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},y=e.useMemo(()=>{const e="string"==typeof i&&/^\{\{\w+\}\}$/.test(i.trim())?i.trim():"";if(i&&!e)return i;if(!d||!e)return i||"";const t=D(u,p,a),n=e.replace(/^\{\{|\}\}$/g,"").trim(),o=yt(d,n,t);return o&&!o.startsWith("{{")?o:i||""},[i,d,u,p,a]),_="string"==typeof i&&/^\{\{\w+\}\}$/.test(i.trim())?i.trim():"",f=!y||y.startsWith("{{"),x=r||"Image",k=h.width,v=k&&"auto"!==k,w="string"==typeof s?s.trim():"",j=""===w?"":m(w,{allowMailtoTel:!0})??"",S=Boolean(t.textOverlayEnabled)&&function(e){const t=Array.isArray(e.overlayItems)?e.overlayItems:[];return t.length>0?t.some(e=>""!==String(e?.text??"").trim()):""!==String(e.overlayText??"").trim()}(t)&&y&&!f,C=()=>{const e=String(t.overlayText??"").replace(/<script\b[\s\S]*?<\/script>/gi,"");return Jo(e)?l.jsx("span",{className:"ee-image-overlay-caption-html",dangerouslySetInnerHTML:{__html:e}}):l.jsx("span",{className:"ee-image-overlay-caption-plain",style:{whiteSpace:"pre-wrap"},children:e})},N=()=>{const e=Array.isArray(t.overlayItems)?t.overlayItems:[],n="number"==typeof t.overlayItemGap?t.overlayItemGap:8,o="number"==typeof t.overlayMaxWidth?t.overlayMaxWidth:100,a="number"==typeof t.overlayPadding?t.overlayPadding:16,i=t.textShadowEnabled?"0 1px 3px rgba(0,0,0,0.55)":"none",r=g?.styles?.fontFamily??"sans-serif";return l.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"stretch",gap:n,width:`${o}%`,maxWidth:"100%",padding:a,boxSizing:"border-box"},children:e.map((e,t)=>{const n=String(e?.text??"").replace(/<script\b[\s\S]*?<\/script>/gi,""),o="number"==typeof e?.fontSize?e.fontSize:16,a=e?.color||"#ffffff",s=null!=e?.fontFamily&&""!==String(e.fontFamily).trim()?String(e.fontFamily).trim():r;return l.jsx("div",{style:{color:a,fontSize:o,fontFamily:s,fontWeight:Yo(e?.kind),lineHeight:1.35,textShadow:i,wordBreak:"break-word"},children:Jo(n)?l.jsx("span",{className:"ee-image-overlay-caption-html",dangerouslySetInnerHTML:{__html:n}}):l.jsx("span",{style:{whiteSpace:"pre-wrap"},children:n})},t)})})},I=S?(()=>{const e=sn(rn(t.overlayPosition)),n=h.borderRadius,o="number"==typeof t.overlayMaxWidth?t.overlayMaxWidth:100,a="number"==typeof t.overlayPadding?t.overlayPadding:16,i={position:"relative",display:v?"inline-block":"block",width:v?k:"100%",maxWidth:"100%",borderRadius:n,overflow:"hidden",lineHeight:0,verticalAlign:"top"},r=Array.isArray(t.overlayItems)?t.overlayItems:[],s=r.length>0&&r.some(e=>""!==String(e?.text??"").trim()),c={...e,position:"absolute",pointerEvents:"none",zIndex:2,maxWidth:`${o}%`,boxSizing:"border-box",...s?{}:{color:t.overlayTextColor||"#ffffff",fontSize:"number"==typeof t.overlayFontSize?t.overlayFontSize:18,fontWeight:600,lineHeight:1.35,padding:a,textShadow:t.textShadowEnabled?"0 1px 3px rgba(0,0,0,0.55)":void 0,...t.overlayBoxBackground?{backgroundColor:t.overlayBoxBackground,padding:`${Math.max(8,a/2)}px 12px`}:{}}},d=l.jsx("img",{src:y,style:{...h,width:"100%",maxWidth:"100%",display:"block",borderRadius:0,verticalAlign:"top"},alt:x});return l.jsxs("div",{className:"ee-image-overlay-host",style:i,children:[t.scrimEnabled?l.jsx("div",{style:{position:"absolute",left:0,right:0,top:0,bottom:0,pointerEvents:"none",zIndex:1,background:"linear-gradient(to top, rgba(0,0,0,0.65), rgba(0,0,0,0.12), transparent 55%)"},"aria-hidden":!0}):null,l.jsx("div",{style:{position:"relative",zIndex:0},children:d}),l.jsx("div",{className:"ee-image-overlay-caption",style:c,children:s?N():C()})]})})():y&&!f?v?l.jsx("div",{style:{width:k,display:"inline-block"},children:l.jsx("img",{src:y,style:{...h,width:"100%",maxWidth:"100%"},alt:x,className:"inline-block"})}):l.jsx("img",{src:y,style:h,alt:x,className:"inline-block"}):l.jsx("div",{className:"empty-image",style:{...h,width:"auto"===h.width?"100%":h.width},title:f&&_?_:void 0,children:f&&_?l.jsx("span",{className:"empty-image-variable-label",children:_}):l.jsx(n.FontAwesomeIcon,{icon:o.faImage,className:"empty-image-icon"})}),A=It(t)&&j&&y&&!f?l.jsx("a",{href:j,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none",display:"inline-block",maxWidth:"100%"},onClick:e=>e.stopPropagation(),children:I}):I;return l.jsx("div",{className:"relative",children:l.jsx("div",{style:{...b||{}},children:A})})},Zo=({blockItem:t})=>{const{src:a,alt:i,linkURL:r}=t,{previewMode:s}=e.useContext(ge),c="desktop"===s?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},d="desktop"===s?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},u=a?l.jsx("img",{src:a,style:{...c,width:c.width??64,height:c.width??64,objectFit:"cover",borderRadius:c.borderRadius??"50%"},alt:i||"Avatar",className:"inline-block"}):l.jsx("div",{className:"empty-avatar",style:{width:c.width??64,height:c.width??64,borderRadius:c.borderRadius??"50%",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"var(--ee-border, #eee)"},children:l.jsx(n.FontAwesomeIcon,{icon:o.faUser,style:{fontSize:"24px",color:"#999"}})}),p={...d,width:"100%"},g=null!=r&&String(r).trim()?m(r,{allowMailtoTel:!0}):null;return l.jsx("div",{className:"relative",children:l.jsx("div",{style:p,children:g?l.jsx("a",{href:g,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-block"},children:u}):u})})},Qo=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),{t:o}=So(),{list:a=[]}=t,i=qt(t),r=Wt(t?.iconColor),s="desktop"===n?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},c=Ht(s),d="desktop"===n?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},u=Boolean(t.showTextLabel),p=s.color||"#525252",g=Math.max(11,Math.round(.58*i)),h=y(a);return 0===h.length?null:l.jsx("div",{className:"relative",children:l.jsx("div",{style:Gt(d),children:h.map((e,t)=>{const{image:n,title:a,linkURL:s}=e,d=zt(e)?o("social_platform_x_alt"):a,h=zt(e)?o("social_platform_x"):a,{src:b,style:y}=Yt(e,r,i),_=l.jsx("img",{src:b||n,alt:d,style:y}),f=m(s,{allowMailtoTel:!1});return l.jsx("div",{style:{...c,display:"inline-flex",alignItems:"center"},children:l.jsxs("a",{href:f,target:"_blank",rel:"noopener noreferrer",style:{display:"inline-flex",alignItems:"center",gap:u?8:0,textDecoration:"none",color:p},children:[_,u?l.jsx("span",{style:{fontSize:g,lineHeight:1.2,color:p,whiteSpace:"nowrap"},children:h}):null]})},t)})})})};const ea=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),o="desktop"===n?{...t.contentStyles?.desktop??{}}:{...t.contentStyles?.desktop??{},...t.contentStyles?.mobile??{}},{outer:a,inner:i}=function(e){if(!e||"object"!=typeof e)return{outer:{width:"100%",textAlign:"center",boxSizing:"border-box"},inner:{width:"100%",maxWidth:"100%",display:"inline-block",verticalAlign:"top",boxSizing:"border-box"}};const{textAlign:t="center",width:n="100%",paddingTop:o,paddingRight:a,paddingBottom:l,paddingLeft:i,backgroundColor:r,...s}=e;return{outer:{width:"100%",textAlign:t,boxSizing:"border-box"},inner:{width:n,maxWidth:"100%",display:"inline-block",verticalAlign:"top",boxSizing:"border-box",paddingTop:o,paddingRight:a,paddingBottom:l,paddingLeft:i,backgroundColor:r,...s}}}(o),r=e.useCallback(e=>{const t=e.target?.closest?.("a[href]");if(!t)return;e.preventDefault(),e.stopPropagation();const n=(t.getAttribute("href")||"").trim();if(n&&!/^javascript:/i.test(n)&&!/^data:/i.test(n))if(/^https?:\/\//i.test(n)||n.startsWith("//")){const e=n.startsWith("//")?`https:${n}`:n;window.open(e,"_blank","noopener,noreferrer")}else(/^mailto:/i.test(n)||/^tel:/i.test(n))&&window.open(n,"_blank","noopener,noreferrer")},[]);return l.jsx("div",{className:"relative ee-raw-html-block",children:l.jsx("div",{className:"ee-raw-html-outer",style:a,children:l.jsx("div",{className:"ee-raw-html-inner",style:i,children:l.jsx("div",{className:"ee-raw-html-content",role:"region","aria-label":"Custom HTML preview",onClick:r,dangerouslySetInnerHTML:{__html:t.html??""}})})})})},ta=({blockItem:t})=>{const{previewMode:n}=e.useContext(ge),o="desktop"===n?{...t.styles?.desktop??{}}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},a="number"==typeof t.rows?t.rows:3,i="number"==typeof t.cols?t.cols:3,r=Boolean(t.headerRow),s=Boolean(t.headerCol),c=Boolean(t.stripedRows),d=o.fontSize??14,u=o.color??"#333333",m=o.borderStyle??"solid",p=o.borderWidth??1,g=o.borderColor??"#e0e0e0",h=o.cellPadding??8,b=o.textAlign??"left",y=o.headerBg??"#f5f5f5",_=o.headerColor??"#333333",f=o.stripedBg??"#fafafa",x="none"!==m?`${p}px ${m} ${g}`:"none",k=(e,t)=>{const n=r&&0===e||s&&0===t;return{border:x,padding:h,fontSize:d,color:n?_:u,textAlign:b,backgroundColor:n?y:c&&!n&&e%2==0?f:"transparent",fontWeight:n?600:400,verticalAlign:"top"}},v={...t.contentStyles?.desktop??{},..."desktop"!==n?t.contentStyles?.mobile??{}:{}},w=(e,n)=>{const o=`${e}-${n}`,a=t.cells?.[o];if("image"===a?.type&&String(a.src??"").trim())return l.jsx("img",{src:a.src,alt:a.alt||"",style:{maxWidth:"100%",height:"auto",display:"block"}});const i=a?.text??"";return i?l.jsx("span",{style:{whiteSpace:"pre-wrap"},children:i}):l.jsx("span",{style:{color:"rgba(0,0,0,0.35)",fontStyle:"italic",fontWeight:400},children:"—"})};return l.jsx("div",{style:{width:"100%",boxSizing:"border-box",paddingTop:v.paddingTop??0,paddingBottom:v.paddingBottom??0,paddingLeft:v.paddingLeft??0,paddingRight:v.paddingRight??0,textAlign:v.textAlign??"left",overflowX:"auto"},children:l.jsx("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"auto"},children:l.jsx("tbody",{children:Array.from({length:a}).map((e,t)=>l.jsx("tr",{children:Array.from({length:i}).map((e,n)=>{const o=r&&0===t||s&&0===n?"th":"td";return l.jsx(o,{style:k(t,n),children:w(t,n)},`${t}-${n}`)})},t))})})})},na=({blockItem:t})=>{const{previewMode:a}=e.useContext(ge),i=e.useMemo(()=>"desktop"===a?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}},[t.styles,a]),r=e.useMemo(()=>"desktop"===a?t.contentStyles?.desktop:{...t.contentStyles?.desktop,...t.contentStyles?.mobile},[t.contentStyles,a]),s=e.useMemo(()=>"desktop"===a?t.videoArea?.desktop??{}:{...t.videoArea?.desktop??{},...t.videoArea?.mobile??{}},[t.videoArea,a]),c="string"==typeof t.videoUrl?t.videoUrl.trim():"",d=Boolean(i.fillColumn),u=Boolean(i.fillColumnMobile),m="desktop"===a?d:u||d,p=e.useMemo(()=>cn(c,t.thumbnailUrl),[c,t.thumbnailUrl]),g=e.useMemo(()=>{let e=i.width,t=i.height;null!=e&&""!==e||(e="auto"),null!=t&&""!==t||(t="auto"),m&&(e="100%");const n=r?.textAlign||"center";let o="0 auto";return"left"===n?o="0":"right"===n&&(o="0 0 0 auto"),{width:"number"==typeof e?`${e}px`:e,height:"number"==typeof t?`${t}px`:t,display:"block",margin:o,maxWidth:"100%"}},[i,m,r?.textAlign]),h=e.useMemo(()=>{const e=s||{},t=null!=e.borderWidth?Number(e.borderWidth):0;let n="none";return t>0&&e.borderStyle&&"none"!==e.borderStyle&&(n=`${t}px ${e.borderStyle} ${e.borderColor??"#cccccc"}`),{paddingTop:e.paddingTop??0,paddingBottom:e.paddingBottom??0,paddingLeft:e.paddingLeft??0,paddingRight:e.paddingRight??0,backgroundColor:e.backgroundColor||"transparent",border:n,borderRadius:e.borderRadius??0,boxSizing:"border-box"}},[s]),b=e.useMemo(()=>{let e=i.width;m&&(e="100%"),null!=e&&""!==e||(e="auto");const t="auto"===e?"100%":"number"==typeof e?`${e}px`:e,n=s?.borderRadius;return{width:t,maxWidth:"100%",boxSizing:"border-box",...null!=n&&""!==n?{borderRadius:n}:{}}},[i.width,m,s?.borderRadius]),y=!p,_=c.startsWith("http://")||c.startsWith("https://")||c.startsWith("//")?c.startsWith("//")?`https:${c}`:c:c?`https://${c.replace(/^\/+/,"")}`:"",f=y?l.jsx("div",{className:"empty-image ee-video-inner",style:b,children:l.jsx(n.FontAwesomeIcon,{icon:o.faVideo,className:"empty-image-icon"})}):l.jsx("div",{className:"ee-video-inner",style:h,children:_?l.jsx("a",{href:_,target:"_blank",rel:"noopener noreferrer",style:{display:"block",lineHeight:0,textDecoration:"none"},onClick:e=>e.stopPropagation(),children:l.jsx("img",{src:p,alt:"Video thumbnail",className:"ee-video-thumb",style:g})}):l.jsx("img",{src:p,alt:"Video thumbnail",className:"ee-video-thumb",style:g})});return l.jsx("div",{className:"relative ee-video-block",children:l.jsx("div",{style:{...r||{}},children:f})})},oa=({blockItem:e,id:t})=>{if(!e)return null;const n={blockItem:e,id:t};switch(e.key){case"text":return l.jsx(Oo,{...n});case"button":return l.jsx(Ho,{...n});case"divider":return l.jsx(Vo,{...n});case"spacer":return l.jsx(Ko,{...n});case"menu":return l.jsx(qo,{...n});case"image":return l.jsx(Xo,{...n});case"video":return l.jsx(na,{...n});case"avatar":return l.jsx(Zo,{...n});case"social_link":return l.jsx(Qo,{...n});case"raw_html":return l.jsx(ea,{...n});case"table":return l.jsx(ta,{...n});default:return null}},aa={tree:null};function la(e,t,n){if(!n||!e[n])return null;if(t.includes(n))return P(n,e);const o=e[n];return"column"===o.key?P(n,e):C(o)}function ia(e,t,n){const o=la(e,t,n);return o?ra(e,t,o,n):null}function ra(e,t,n,o){if(!n||!o||!e[o])return null;const a=B(n),l=t.indexOf(o);if(-1!==l){const{newBlockMap:n,rootId:o}=K(e,a);if(!o)return null;const i=[...t];i.splice(l+1,0,o);const r=n[o];return{nextMap:n,nextRootOrder:i,newId:o,selectionData:"column"===r?.key?P(o,n):r}}const i=F(e,t,o);if(!i)return null;const{newBlockMap:r,rootId:s}=K(e,a);if(!s)return null;const c=O(r,i.containerId,i.cellIndex,i.itemIndex+1,s),d=c[s];return{nextMap:c,nextRootOrder:t,newId:s,selectionData:"column"===d?.key?P(s,c):d}}function sa(e,t,n,o){if(!n)return null;if(o&&e[o])return ra(e,t,n,o);const a=B(n),{newBlockMap:l,rootId:i}=K(e,a);if(!i)return null;const r=l[i],s="column"===r?.key?P(i,l):r;return{nextMap:l,nextRootOrder:[...t,i],newId:i,selectionData:s}}function ca(e,t){const n=e[t];if(!n||"column"!==n.key)return!1;for(const t of n.cells||[])for(const n of t.childrenIds||[]){const t=e[n];if(t&&"empty"!==t.key)return!0}return!1}function da(e,t,n,o){if(!n||!e[n])return null;if(-1!==t.indexOf(n)){return{nextMap:H(e,n),nextRootOrder:t.filter(e=>e!==n)}}const a=F(e,t,n);if(!a)return null;const{blockMap:l,removedId:i}=z(e,a.containerId,a.cellIndex,a.itemIndex);let r=l;const s=l[a.containerId];if(s&&0===s.cells[a.cellIndex].childrenIds.length){const e=$(o("drag_block_here"));r={...l,[e.id]:e,[a.containerId]:{...s,cells:s.cells.map((t,n)=>n===a.cellIndex?{...t,childrenIds:[e.id]}:t)}}}return i&&(r=H(r,i)),{nextMap:r,nextRootOrder:t}}function ua(e){return e&&"column"===e.key?"section"===e.layoutRole||"columns"===e.layoutRole?e.layoutRole:!0===e.columnLayoutOnly?"columns":"section":null}const ma="section",pa="columns",ga="ee:open-configure-columns";function ha(e){"undefined"!=typeof window&&window.dispatchEvent(new CustomEvent(ga,{detail:null!=e&&String(e).length>0?{rootId:e}:{}}))}const ba=o.faCog;function ya(e,t){if(!t?.key)return{icon:o.faSquare,label:""};const{key:n,containerType:a}=t;if("column"===n)return"product"===a?{icon:o.faCube,label:e("block_product")}:"discount"===a?{icon:o.faTag,label:e("block_discount")}:ua(t)===pa?{icon:o.faColumns,label:e("block_palette_columns")}:{icon:o.faSquare,label:e("block_palette_section")};switch(n){case"text":return{icon:o.faFont,label:e("text")};case"button":return{icon:o.faLink,label:e("button")};case"image":return{icon:o.faImage,label:e("image")};case"video":return{icon:o.faVideo,label:e("video")};case"divider":return{icon:o.faGripLines,label:e("divider")};case"spacer":return{icon:o.faArrowsAltV,label:e("spacer")};case"menu":return{icon:o.faBars,label:e("menu")};case"avatar":return{icon:o.faUser,label:e("avatar")};case"social_link":return{icon:o.faShareAlt,label:e("social_link")};case"raw_html":return{icon:o.faCode,label:e("raw_html")};case"table":return{icon:o.faTable,label:e("table")};case"empty":return{icon:o.faSquare,label:""};default:return{icon:o.faSquare,label:n||""}}}const _a=a=>{const{block:i,blockIndex:r,clearStyles:s}=a,{t:c}=So(),{previewMode:d,blockMap:u,rootOrder:m,validationMarkers:p,ignoreValidationIssue:g,setBlocks:h,currentItem:b,setCurrentItem:y,setIsDragStart:_,isDragStart:f,bodySettings:x,setActionType:k,onSaveBlockAsGlobal:v}=e.useContext(ge),w="desktop"===d?i.styles?.desktop??{}:{...i.styles?.desktop??{},...i.styles?.mobile??{}},{contentBackground:C,containerBackgroundImage:N,containerBackgroundSize:I,containerBackgroundPosition:A,...T}=w,L="undefined"!=typeof window?window.__eeDragItemData:null,B=L?.key??(b?.id?u[b.id]?.key:null)??b?.data?.key,R=f&&"column"!==B,M=e=>t=>{t.preventDefault(),t.stopPropagation(),y({id:e.id,data:e,type:"edit"}),k("edit")},P=e=>t=>{t.preventDefault(),t.stopPropagation();const n=u[e];n&&(y({id:n.id,data:n,type:"edit"}),k("edit"))},F=(e,t,n)=>o=>{o.preventDefault(),o.stopPropagation();const{blockMap:a,removedId:l}=z(u,e,t,n);let i=a;const r=a[e];if(r&&0===r.cells[t].childrenIds.length){const n=$(c("drag_block_here"));i={...a,[n.id]:n,[e]:{...r,cells:r.cells.map((e,o)=>o===t?{...e,childrenIds:[n.id]}:e)}}}l&&(i=H(i,l)),h(i,m,"delete"),y(null)},E=e=>()=>{_(!0),y({id:e.id,data:e,type:"move"}),k("move")},D=e=>{e.preventDefault(),e.stopPropagation(),setTimeout(()=>{e.target.style.border="",e.target.children[0]&&e.target.children[0].classList.remove("sidebar-block-move"),_(!1),s&&s()},50)},U=e=>e.preventDefault(),O=e=>{e.preventDefault(),e.stopPropagation()},V=(e,t)=>n=>{O(n);const o=W(u,m,e,t);o&&h(o.nextMap,o.nextRootOrder,"move")},K=e=>t=>{O(t);const n=ia(u,m,e);n&&(h(n.nextMap,n.nextRootOrder,"add"),y({id:n.newId,data:n.selectionData,type:"edit"}))},G=e=>"desktop"===d?e.styles?.desktop||{}:{...e.styles?.desktop||{},...e.styles?.mobile||{}},q=j(x),J=S(x),Y=e=>{const n=p?.[e];if(!n)return null;const o="error"===n.severity?`${n.errorCount} error${1===n.errorCount?"":"s"}`:`${n.warningCount} warning${1===n.warningCount?"":"s"}`,a=l.jsx("div",{className:"block-validation-popover",children:n.issues.map((e,n)=>l.jsxs("div",{className:"block-validation-popover-item",children:[l.jsx("div",{className:"block-validation-popover-message",children:e.message}),l.jsx(t.Button,{size:"small",type:"text",className:"block-validation-popover-ignore",onClick:t=>{t.preventDefault(),t.stopPropagation(),g(e)},children:c("ignore")})]},`${e.code}-${n}`))});return l.jsx(t.Popover,{trigger:["hover","click"],placement:"topRight",overlayClassName:"block-validation-popover-overlay",content:a,getPopupContainer:()=>document.querySelector("#preview")||document.body,children:l.jsxs("button",{type:"button",className:fo("block-validation-indicator","error"===n.severity?"block-validation-indicator-error":"block-validation-indicator-warning"),"aria-label":o,onClick:e=>{e.preventDefault(),e.stopPropagation()},onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},children:[l.jsx("span",{className:"block-validation-indicator-dot"}),l.jsx("span",{className:"block-validation-indicator-count",children:n.totalCount})]})})},X=(t,a,i,r,s,m,p=1)=>{const g=G({styles:t.styles}),{contentBackground:h,containerBackgroundImage:y,containerBackgroundSize:_,containerBackgroundPosition:f,...k}=g,v=b?.id===t.id,w=((e=1)=>({"--nested-level":Math.max(1,e),"--nested-width":"100%"}))(p);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"relative block-content-drag-label-content","data-drop-key":s,children:[l.jsx("div",{className:"absolute block-move-top",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})}),R&&l.jsx("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":a,"data-cell-index":i,"data-item-index":r,"data-drop-key":s,"data-type":"block-item-move"})]}),l.jsx("div",{className:fo("block-item block-item-container",v&&"block-item-focus"),style:w,"data-block-id":t.id,onMouseEnter:e=>{e.currentTarget.dataset.hovered="true"},onMouseLeave:e=>{delete e.currentTarget.dataset.hovered},children:l.jsxs("div",{className:"relative",children:[Y(t.id),l.jsx("div",{className:"block-item-tools",onDragOver:U,onClick:M(t),children:R&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":a,"data-cell-index":i,"data-item-index":r,"data-drop-key":s,"data-type":"block-item-move"}),l.jsx("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":a,"data-cell-index":i,"data-item-index":r+1,"data-drop-key":m,"data-type":"block-item-move"})]})}),(()=>{const e=u[a]?.cells?.[i],s=r>0,d=r<(e?.childrenIds?.length??0)-1,m=ya(c,t);return l.jsxs("div",{className:"block-chrome-overlay",children:[l.jsxs("span",{className:"block-chrome-badge",children:[l.jsx(n.FontAwesomeIcon,{icon:m.icon}),l.jsx("span",{children:m.label})]}),l.jsxs("div",{className:"block-chrome-toolbar",children:[l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:P(a),title:c("select_parent_section_tooltip"),children:l.jsx(n.FontAwesomeIcon,{icon:ba})}),l.jsx("span",{className:fo("block-chrome-action",!s&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(t.id,-1),title:c("context_move_up"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronUp})}),l.jsx("span",{className:fo("block-chrome-action",!d&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(t.id,1),title:c("context_move_down"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronDown})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:K(t.id),title:c("context_duplicate"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faCopy})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action block-chrome-action-danger",onMouseDown:O,onClick:F(a,i,r),title:c("layer_delete"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash})}),l.jsx("span",{className:"block-chrome-action block-chrome-action-disabled ee-section-nested-no-drag",draggable:!1,onMouseDown:e=>e.stopPropagation(),title:c("section_nest_not_allowed"),style:{cursor:"not-allowed"},children:l.jsx(n.FontAwesomeIcon,{icon:o.faArrowsAlt})})]})]})})(),l.jsx("div",{style:{...k,overflow:k.borderRadius?"hidden":void 0},children:l.jsx("div",{className:"block-content block-item-container-body",style:{...on(g,h),borderRadius:k.borderRadius,overflow:k.borderRadius?"hidden":void 0,...null!=k.minHeight&&""!==k.minHeight&&""!==String(k.minHeight).trim()?{minHeight:k.minHeight}:{}},children:(t.children||[]).map((n,o)=>{const a=G(n);return l.jsx("div",{style:{...a,width:"mobile"===d&&!1!==x.stackColumnsOnMobile?"100%":n.width},children:(n.children||[]).map((a,i)=>{const r=`${t.id}:${o}:${i}`,s=`${t.id}:${o}:${i+1}`,d=i===n.children.length-1&&"empty"!==a.key&&"column"!==a.key;return l.jsxs(e.Fragment,{children:[Z(a,t.id,o,i,r,s,p),d&&l.jsx("div",{className:"relative block-content-drag-label-content","data-drop-key":s,children:l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})})})]},`${t.id}:${o}:${a.id||i}`)})},`${t.id}:${n.id||"cell"}:${o}`)})})})]})}),l.jsxs("div",{className:"relative block-content-drag-label-content","data-drop-key":m,children:[l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})}),R&&l.jsx("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":a,"data-cell-index":i,"data-item-index":r+1,"data-drop-key":m,"data-type":"block-item-move"})]})]})},Z=(t,a,i,r,s,d,m=0)=>"empty"===t.key?l.jsx("div",{className:"relative width-full",children:l.jsx("div",{className:"block-empty-content ee-empty-drop-slot",onDragOver:R?U:void 0,...R?{"data-container-id":a,"data-cell-index":i,"data-item-index":r,"data-type":"empty-block-item"}:{},"aria-label":t.name||c("drag_block_here"),children:l.jsx("span",{className:"ee-empty-drop-slot__label",children:c("drag_block_here")})})},t.id||r):"column"===t.key?l.jsx(e.Fragment,{children:X(t,a,i,r,s,d,m+1)},`${a}:${i}:${t.id||r}`):l.jsxs(e.Fragment,{children:[l.jsx("div",{className:"relative block-content-drag-label-content","data-drop-key":s,children:l.jsx("div",{className:"absolute block-move-top",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})})}),l.jsx("div",{className:fo("block-item",b?.id===t.id&&"block-item-focus",t.hidden&&"block-hidden-dim"),"data-block-id":t.id,children:l.jsxs("div",{className:"relative",children:[Y(t.id),l.jsx("div",{className:"block-item-tools",onDragOver:U,onClick:e=>{e.preventDefault(),e.stopPropagation(),y({id:t.id,data:t,type:"edit"}),k("edit")},children:R&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"block-move-content-top","data-name":"dragTools","data-position":"top","data-container-id":a,"data-cell-index":i,"data-item-index":r,"data-drop-key":s,"data-type":"block-item-move"}),l.jsx("div",{className:"block-move-content-bottom","data-name":"dragTools","data-position":"bottom","data-container-id":a,"data-cell-index":i,"data-item-index":r+1,"data-drop-key":d,"data-type":"block-item-move"})]})}),(()=>{const e=u[a]?.cells?.[i],s=r>0,d=r<(e?.childrenIds?.length??0)-1,m=ya(c,t);return l.jsxs("div",{className:"block-chrome-overlay",children:[l.jsxs("span",{className:"block-chrome-badge",children:[l.jsx(n.FontAwesomeIcon,{icon:m.icon}),l.jsx("span",{children:m.label})]}),l.jsxs("div",{className:"block-chrome-toolbar",children:[l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:P(a),title:c("select_parent_section_tooltip"),children:l.jsx(n.FontAwesomeIcon,{icon:ba})}),l.jsx("span",{className:fo("block-chrome-action",!s&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(t.id,-1),title:c("context_move_up"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronUp})}),l.jsx("span",{className:fo("block-chrome-action",!d&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(t.id,1),title:c("context_move_down"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronDown})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:K(t.id),title:c("context_duplicate"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faCopy})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action block-chrome-action-danger",onMouseDown:O,onClick:F(a,i,r),title:c("layer_delete"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash})}),l.jsx("span",{className:"block-chrome-action block-chrome-drag",draggable:"true",onMouseDown:e=>e.stopPropagation(),onDragEnd:D,onDragStart:E(t),title:c("drag_to_move")||"Drag to move",children:l.jsx(n.FontAwesomeIcon,{icon:o.faArrowsAlt})})]})]})})(),l.jsx(oa,{blockItem:t,id:t.id})]})})]},`${a}:${i}:${t.id||r}`),Q=ya(c,i),ee="column"===b?.data?.key&&ua(b.data)===pa?c("block_palette_columns"):c("container");return l.jsx(l.Fragment,{children:l.jsxs("div",{className:fo("relative block-drag-label-content",f&&"column"===B&&"ee-section-drop-preview"),"data-index":r,"data-position":"top",children:[f&&"column"===B?l.jsxs("div",{className:"ee-section-drop-slot-outline","aria-hidden":!0,children:[l.jsx("span",{className:"ee-section-drop-badge",children:ee}),l.jsx("span",{className:"ee-section-drop-hint",children:c("drag_section_here")})]}):null,l.jsx("div",{className:"absolute block-move-top",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})}),l.jsxs("div",{className:fo("relative block",b?.id===i.id&&"block-focus","mobile"===d&&"mobile-block-focus",i.hidden&&"block-hidden-dim"),"data-block-id":i.id,onClick:M(i),children:[l.jsxs("div",{className:"hover-visible",children:[Y(i.id),l.jsxs("div",{className:"block-chrome-overlay",children:[l.jsxs("span",{className:"block-chrome-badge",children:[l.jsx(n.FontAwesomeIcon,{icon:Q.icon}),l.jsx("span",{children:Q.label})]}),l.jsxs("div",{className:"block-chrome-toolbar",children:[l.jsx("span",{className:fo("block-chrome-action",r<=0&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(i.id,-1),title:c("context_move_up"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronUp})}),l.jsx("span",{className:fo("block-chrome-action",r>=m.length-1&&"block-chrome-action-disabled"),onMouseDown:O,onClick:V(i.id,1),title:c("context_move_down"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronDown})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:K(i.id),title:c("context_duplicate"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faCopy})}),"function"==typeof v&&l.jsx("span",{className:"block-chrome-action",onMouseDown:O,onClick:(te=i,e=>{O(e),window.dispatchEvent(new CustomEvent("ee:canvas-save-universal",{detail:{block:te}}))}),title:c("save_as_universal"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faStar})}),l.jsx("span",{className:"block-chrome-divider","aria-hidden":!0}),l.jsx("span",{className:"block-chrome-action block-chrome-action-danger",onMouseDown:O,onClick:e=>{e.preventDefault(),e.stopPropagation();const t=H(u,i.id),n=m.filter(e=>e!==i.id);h(t,n,"delete"),y(null)},title:c("layer_delete"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash})}),l.jsx("span",{className:"block-chrome-action block-chrome-drag",draggable:"true",onMouseDown:e=>e.stopPropagation(),onDragEnd:D,onDragStart:()=>{_(!0),y({id:i.id,data:i,type:"move"}),k("move")},title:c("drag_to_move")||"Drag to move",children:l.jsx(n.FontAwesomeIcon,{icon:o.faArrowsAlt})})]})]})]}),l.jsx("div",{className:"width-full height-full absolute",onDragOver:U,style:{pointerEvents:f&&"column"===B?"auto":"none"},children:f&&"column"===B&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"block-move-content-top","data-name":"dragTools","data-type":"drag-over-column","data-position":"top","data-index":r}),l.jsx("div",{className:"block-move-content-bottom","data-name":"dragTools","data-type":"drag-over-column","data-position":"bottom","data-index":r+1})]})}),l.jsx("div",{className:"column margin-auto",style:{...T,width:"100%",maxWidth:"100%",overflow:T.borderRadius?"hidden":void 0},children:l.jsx("div",{className:"block-content",style:{...on(w,C),borderRadius:T.borderRadius,overflow:T.borderRadius?"hidden":void 0,width:J?"100%":q,maxWidth:J?"100%":q,...null!=T.minHeight&&""!==T.minHeight&&""!==String(T.minHeight).trim()?{minHeight:T.minHeight}:{}},"data-index":r,children:i.children.map((t,n)=>{const o="desktop"===d?t.styles?.desktop??{}:{...t.styles?.desktop??{},...t.styles?.mobile??{}};return l.jsx(e.Fragment,{children:l.jsx("div",{id:`block-content-${r}-${n}`,style:{...o,width:"mobile"===d&&!1!==x.stackColumnsOnMobile?"100%":t.width},children:t.children.map((o,a)=>{const r=`${i.id}:${n}:${a}`,s=`${i.id}:${n}:${a+1}`,d=a===t.children.length-1&&"empty"!==o.key&&"column"!==o.key;return l.jsxs(e.Fragment,{children:[Z(o,i.id,n,a,r,s,0),d&&l.jsx("div",{className:"relative block-content-drag-label-content","data-drop-key":s,children:l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:c("drag_block_here")})})})]},`${i.id}:${n}:${o.id||a}`)})})},`${i.id}:${t.id||"content"}:${n}`)})})})]})]})});var te};function fa(e){return{id:A(),name:e("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}}function xa(e,t){return{id:A(),name:e("content"),key:"content",width:t,styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[fa(e)]}}function ka(e,{layoutRole:t,columnLayoutOnly:n,name:o}){const a=n?[xa(e,"50%"),xa(e,"50%")]:[xa(e,"100%")];return{id:A(),name:o,key:"column",type:n?"1-1":"full",containerType:"none",layoutRole:t,columnLayoutOnly:n,styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},children:a}}const va=e=>[ka(e,{layoutRole:ma,columnLayoutOnly:!1,name:e("block_palette_section")}),ka(e,{layoutRole:pa,columnLayoutOnly:!0,name:e("block_palette_columns")}),{id:A(),name:e("text"),key:"text",text:e("text_content"),type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",color:void 0,lineHeight:"20px",paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16,textAlign:"left"},mobile:{}}},{id:A(),name:e("button"),key:"button",text:e("button"),type:"link",linkURL:"",contentStyles:{desktop:{textAlign:"center",paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"auto",fontSize:12,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:20,paddingRight:20,backgroundColor:void 0,color:"#fff",display:"inline-block"},mobile:{}}},{id:A(),name:e("spacer"),key:"spacer",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{height:16,width:"100%",display:"block"},mobile:{}}},{id:A(),name:e("divider"),key:"divider",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}},{id:A(),name:e("raw_html"),key:"raw_html",html:e("raw_html_default_content"),contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center",width:"100%"},mobile:{}},styles:{desktop:{},mobile:{}}},{id:A(),name:e("image"),key:"image",src:"",alt:"Image",type:"link",linkEnabled:!1,linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{id:A(),name:e("video"),key:"video",videoUrl:"",thumbnailUrl:"",styles:{desktop:{width:"auto",height:"auto",fillColumn:!1,fillColumnMobile:!1,display:"inline-block"},mobile:{}},videoArea:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,backgroundColor:"transparent",borderWidth:0,borderStyle:"solid",borderColor:"#cccccc",borderRadius:0},mobile:{}},contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center",backgroundColor:"transparent"},mobile:{}}},{id:A(),name:e("menu"),key:"menu",layoutMode:"nav-only",showLogo:!1,mobileLayout:"stack",linkGapPx:0,linkUnderline:!1,list:[{label:"Page",url:"",target:"_self"},{label:"Page",url:"",target:"_self"}],separator:" | ",contentStyles:{desktop:{paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16,textAlign:"center"},mobile:{}},styles:{desktop:{fontSize:14,fontFamily:"sans-serif",color:"#333333",linkColor:"#2faade",letterSpacing:0,fontWeight:"400",textTransform:"none"},mobile:{}}},{id:A(),name:e("table")||"Table",key:"table",rows:3,cols:3,structureMode:"static",headerRow:!0,headerCol:!1,stripedRows:!1,cells:{},contentStyles:{desktop:{paddingTop:8,paddingBottom:8,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}},styles:{desktop:{fontSize:14,color:"#333333",borderStyle:"solid",borderWidth:1,borderColor:"#e0e0e0",cellPadding:8,textAlign:"left",headerBg:"#f5f5f5",headerColor:"#333333",stripedRows:!1,stripedBg:"#fafafa"},mobile:{}}},{id:A(),name:e("social_link"),key:"social_link",useCompanySocialLinks:!0,list:[],imageWidth:32,iconSize:"medium",iconColor:"default",contentStyles:{desktop:{paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16,textAlign:"left"},mobile:{}},styles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}}}];const wa="ee-block-context-menu";function ja(e,t,n){return{label:e,onSelect:t,disabled:n}}const Sa=()=>{const{t:n}=So(),{blockMap:o,rootOrder:a,setBlocks:r,setCurrentItem:s,onSaveBlockAsGlobal:c}=e.useContext(ge),[d,u]=e.useState(null),m=e.useCallback(()=>u(null),[]);e.useEffect(()=>{const e=e=>{const t=e.target.closest?.(".email-editor");if(!t)return;const n=e.target.closest?.("[data-block-id]");if(!n||!t.contains(n))return;const a=n.getAttribute("data-block-id");a&&o[a]&&(e.preventDefault(),e.stopPropagation(),u({x:e.clientX,y:e.clientY,blockId:a}))},t=e=>{e.target.closest?.(`.${wa}`)||u(null)};return document.addEventListener("contextmenu",e,!0),document.addEventListener("click",t,!0),document.addEventListener("scroll",t,!0),()=>{document.removeEventListener("contextmenu",e,!0),document.removeEventListener("click",t,!0),document.removeEventListener("scroll",t,!0)}},[o]);const p=e.useCallback((e,t)=>{const n=W(o,a,e,t);n&&(r(n.nextMap,n.nextRootOrder,"move"),m())},[o,a,r,m]),g=e.useCallback(e=>Boolean(W(o,a,e,-1)),[o,a]),h=e.useCallback(e=>Boolean(W(o,a,e,1)),[o,a]),b=e.useCallback(e=>{const l=o[e];if(!l)return[];const i=()=>{const t=la(o,a,e);t&&(aa.tree=t)};return[ja(n("context_duplicate"),()=>{const t=ia(o,a,e);t&&(r(t.nextMap,t.nextRootOrder,"add"),s({id:t.newId,data:t.selectionData,type:"edit"}),m())},!1),ja(n("context_copy"),()=>{i(),m()},!1),ja(n("context_cut"),()=>{i();const c=()=>{const t=da(o,a,e,n);t&&(r(t.nextMap,t.nextRootOrder,"delete"),s(null),m())};if("column"===l.key&&ca(o,e))return m(),void t.Modal.confirm({title:n("shortcut_delete_confirm_title"),content:n("shortcut_delete_confirm_desc"),okText:n("confirm"),cancelText:n("cancel"),wrapClassName:"ee-modal-dark",onOk:c});c()},!1),ja(n("context_paste"),()=>{if(!aa.tree)return;const t=sa(o,a,aa.tree,e);t&&(r(t.nextMap,t.nextRootOrder,"add"),s({id:t.newId,data:t.selectionData,type:"edit"}),m())},!aa.tree),ja(n("context_delete"),()=>{const i=()=>{const t=da(o,a,e,n);t&&(r(t.nextMap,t.nextRootOrder,"delete"),s(null),m())};if("column"===l.key&&ca(o,e))return m(),void t.Modal.confirm({title:n("shortcut_delete_confirm_title"),content:n("shortcut_delete_confirm_desc"),okText:n("confirm"),cancelText:n("cancel"),wrapClassName:"ee-modal-dark",onOk:i});i()},!1),ja(n("context_move_up"),()=>p(e,-1),!g(e)),ja(n("context_move_down"),()=>p(e,1),!h(e)),ja(n("context_save_global"),()=>{"function"==typeof c&&c(e),m()},"function"!=typeof c),ja(n("context_reset_styles"),()=>{const t=function(e,t,n){const o=e[t];if(!o||!o.key)return null;const a=va(n).find(e=>e.key===o.key);if(!a)return null;const l={...o};return null!=a.styles&&(l.styles=C(a.styles)),null!=a.contentStyles&&(l.contentStyles=C(a.contentStyles)),{...e,[t]:l}}(o,e,n);if(!t)return;r(t,a,`edit_${Date.now()}`);const l=t[e];l&&s({id:e,data:"column"===l.key?P(e,t):l,type:"edit"}),m()},"empty"===l.key||!va(n).some(e=>e.key===l.key))]},[o,a,r,s,n,m,g,h,p,c]);if(!d)return null;const y=b(d.blockId),_="undefined"!=typeof window?window.innerWidth:9999,f="undefined"!=typeof window?window.innerHeight:9999,x=Math.min(d.x,_-220-8),k=Math.min(d.y,f-360-8);return i.createPortal(l.jsx("div",{className:wa,style:{position:"fixed",left:x,top:k,zIndex:10050,minWidth:220,background:"#1a1a1a",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,boxShadow:"0 12px 40px rgba(0,0,0,0.45)",padding:"6px 0"},role:"menu",onMouseDown:e=>e.stopPropagation(),onClick:e=>e.stopPropagation(),children:y.map(e=>l.jsx("button",{type:"button",role:"menuitem",disabled:e.disabled,className:"ee-block-context-menu-item",style:{display:"block",width:"100%",textAlign:"left",padding:"8px 14px",border:"none",background:"transparent",color:e.disabled?"rgba(255,255,255,0.35)":"#f5f5f5",fontSize:13,cursor:e.disabled?"not-allowed":"pointer"},onMouseEnter:t=>{e.disabled||(t.currentTarget.style.background="rgba(255,255,255,0.08)")},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},onClick:()=>{e.disabled||e.onSelect()},children:e.label},e.label))}),document.body)},Ca=t=>{const{clearStyles:n}=t,{t:o}=So(),{previewMode:a,bodySettings:i,blockList:r,currentItem:s,blockMap:c,isDragStart:d,setSelectionRange:u}=e.useContext(ge),m=e.useRef(null),p="undefined"!=typeof window?window.__eeDragItemData:null,g="undefined"!=typeof window?window.__eeDragSource:null,h=p?.key??(s?.id?c[s.id]?.key:null)??s?.data?.key,b="add"===s?.type||Boolean(p),y=r.length>0&&d&&"product-variables"!==g&&("column"===h||b);e.useEffect(()=>{const e=N(()=>{try{const n=window.getSelection();if(!n||0===n.rangeCount)return;const o=n.getRangeAt(0),a=document.getElementById("preview");if(!(!!a&&(a.contains(o.commonAncestorContainer)||a===o.commonAncestorContainer)))return;const l=(e=>e?{startContainer:e.startContainer,startOffset:e.startOffset,endContainer:e.endContainer,endOffset:e.endOffset,collapsed:e.collapsed}:null)(o);if(e=m.current,t=l,e&&t&&e.startContainer===t.startContainer&&e.startOffset===t.startOffset&&e.endContainer===t.endContainer&&e.endOffset===t.endOffset&&e.collapsed===t.collapsed)return;m.current=l,u(o.cloneRange())}catch(e){console.warn(e)}var e,t},100);return document.addEventListener("selectionchange",e),()=>{document.removeEventListener("selectionchange",e)}},[u]);const _=e=>{e.preventDefault()},f=j(i),x=S(i),k=i?.styles||{},v={width:"desktop"===a?"100%":364,backgroundColor:k.backgroundColor,color:k.color,fontFamily:k.fontFamily},w={maxWidth:"100%",width:"100%",backgroundColor:"transparent",..."mobile"===a&&!1!==i.scaleFontOnMobile?{fontSize:16}:{}};return l.jsxs("div",{className:"preview-main",children:[l.jsx(Sa,{}),l.jsx("div",{className:"default-scrollbar",id:"preview",children:l.jsx("div",{className:"preview-content",style:v,children:l.jsx("div",{className:"margin-auto",style:w,children:r.length?l.jsxs("div",{className:"preview-column-stack",children:[y&&l.jsxs("div",{className:fo("block-drag-label-content preview-edge-drop-zone preview-edge-drop-zone-top","column"===h&&"ee-section-drop-preview"),"data-index":0,"data-position":"top",children:["column"===h?l.jsxs("div",{className:"ee-section-drop-slot-outline ee-section-drop-slot-outline-edge","aria-hidden":!0,children:[l.jsx("span",{className:"ee-section-drop-badge",children:o("container")}),l.jsx("span",{className:"ee-section-drop-hint",children:o("drag_section_here")})]}):null,l.jsx("div",{className:"absolute block-move-top",children:l.jsx("span",{className:"block-tools-drag_here",children:o("drag_block_here")})}),l.jsx("div",{className:"preview-edge-drop-hit","data-name":"dragTools","data-type":"drag-over-column","data-position":"top","data-index":0,onDragOver:_})]}),r.map((t,o)=>l.jsx(e.Fragment,{children:l.jsx(_a,{block:t,blockIndex:o,clearStyles:n})},`${t?.id||"block"}-${o}`)),l.jsxs("div",{className:fo("relative block-drag-label-content","ee-bottom-stack-drop-slot",d&&!y&&"ee-bottom-stack-drop-slot--active"),"data-index":r.length,"data-position":"bottom",style:{minHeight:d&&!y?52:0},children:[d&&!y?l.jsx("div",{className:"ee-bottom-drop-slot-outline","aria-hidden":!0,children:l.jsx("span",{className:"ee-bottom-drop-slot-label",children:o("drag_block_here")})}):null,l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:o("drag_block_here")})}),d&&!y&&l.jsx("div",{"data-name":"dragTools","data-type":"drag-over-column","data-position":"bottom","data-index":r.length,onDragOver:_,style:{position:"absolute",inset:0,zIndex:106,pointerEvents:"auto"}})]}),y&&l.jsxs("div",{className:fo("block-drag-label-content preview-edge-drop-zone preview-edge-drop-zone-bottom","column"===h&&"ee-section-drop-preview"),"data-index":r.length,"data-position":"bottom",children:["column"===h?l.jsxs("div",{className:"ee-section-drop-slot-outline ee-section-drop-slot-outline-edge","aria-hidden":!0,children:[l.jsx("span",{className:"ee-section-drop-badge",children:o("container")}),l.jsx("span",{className:"ee-section-drop-hint",children:o("drag_section_here")})]}):null,l.jsx("div",{className:"absolute block-move-bottom",children:l.jsx("span",{className:"block-tools-drag_here",children:o("drag_block_here")})}),l.jsx("div",{className:"preview-edge-drop-hit","data-name":"dragTools","data-type":"drag-over-column","data-position":"bottom","data-index":r.length,onDragOver:_})]})]}):l.jsx("div",{"data-name":"dragEmpty",className:"start-to-add ee-empty-document",style:{width:x?"100%":f,maxWidth:"100%"},"data-type":"empty-block",onDragOver:_,children:l.jsxs("div",{className:"ee-empty-document-inner",children:[l.jsxs("svg",{className:"ee-empty-document__icon",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":!0,children:[l.jsx("rect",{x:"6",y:"22",width:"14",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("rect",{x:"24",y:"22",width:"14",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("rect",{x:"6",y:"6",width:"14",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"}),l.jsx("rect",{x:"28",y:"4",width:"14",height:"14",rx:"2",stroke:"currentColor",strokeWidth:"1.5"})]}),l.jsx("p",{className:"ee-empty-document__title",children:o("drop_content_here")}),l.jsx("p",{className:"ee-empty-document__hint",children:o("drop_content_hint")})]})})})})})]})},Na=/^#([0-9a-f]{3}|[0-9a-f]{6})$/i,Ia=/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})(?:\s*[,/]\s*([0-9.]+))?\s*\)$/i,Aa=e=>(e=>Math.max(0,Math.min(255,Number.isFinite(e)?Math.round(e):0)))(e).toString(16).padStart(2,"0"),Ta=(e,t="#000000")=>{const n=String(e??"").trim();if(!n)return t;if("transparent"===n.toLowerCase())return t;if(/^[0-9a-f]{3}$/i.test(n)){return`#${n.toLowerCase().split("").map(e=>e+e).join("")}`}if(/^[0-9a-f]{6}$/i.test(n))return`#${n.toLowerCase()}`;if(Na.test(n)){if(4===n.length){const[,e,t,o]=n;return`#${e}${e}${t}${t}${o}${o}`.toLowerCase()}return n.toLowerCase()}const o=n.match(Ia);if(o){const e=Number(o[1]),t=Number(o[2]),n=Number(o[3]);return`#${Aa(e)}${Aa(t)}${Aa(n)}`.toLowerCase()}const a=(e=>{if("undefined"==typeof document)return null;const t=document.createElement("span");if(t.style.color="",t.style.color=String(e??"").trim(),!t.style.color)return null;const n=t.style.color.match(Ia);if(!n)return null;const o=Number(n[1]),a=Number(n[2]),l=Number(n[3]);return`#${Aa(o)}${Aa(a)}${Aa(l)}`.toLowerCase()})(n);return a||t},La={backgroundImage:"linear-gradient(45deg, #1f1f1f 25%, transparent 25%), linear-gradient(-45deg, #1f1f1f 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #1f1f1f 75%), linear-gradient(-45deg, transparent 75%, #1f1f1f 75%)",backgroundSize:"8px 8px",backgroundPosition:"0 0, 0 4px, 4px -4px, -4px 0px"},Ba=({color:n,setColor:o,fallbackColor:a="#ffffff",variant:i="field"})=>{const[s,c]=e.useState(!1),d=Ta(n,a),u=d,m=l.jsx("div",{className:"select-none ee-color-picker-popover",children:l.jsx(r.ChromePicker,{disableAlpha:!0,color:d,style:{boxShadow:"none"},onChange:e=>o({hex:Ta(e?.hex,a)})})});return l.jsx(t.Popover,{zIndex:1070,getPopupContainer:()=>document.querySelector(".right-settings")||document.body,content:m,trigger:"click",open:s,onOpenChange:c,children:"field"===i?l.jsxs("button",{type:"button",className:"ee-color-picker-field-trigger","aria-label":"Open color picker",children:[l.jsx("span",{className:"ee-color-picker-field-swatch",style:{background:"transparent"===u?void 0:u,..."transparent"===u?La:{}}}),l.jsx("span",{className:"ee-color-picker-field-hex","aria-hidden":!0,children:d.toUpperCase()}),l.jsx("span",{className:"ee-color-picker-field-chevron","aria-hidden":!0})]}):l.jsx("button",{type:"button",className:"color-picker-button","aria-label":"Open color picker",style:{background:u,backgroundImage:"transparent"===u?La.backgroundImage:void 0,backgroundSize:"transparent"===u?La.backgroundSize:void 0,backgroundPosition:"transparent"===u?La.backgroundPosition:void 0}})})},$a=[{key:"paddingTop",suffix:"T"},{key:"paddingRight",suffix:"R"},{key:"paddingBottom",suffix:"B"},{key:"paddingLeft",suffix:"L"}],Ra=({padding:e,onChange:n,min:o=0,disabled:a})=>{const{t:i}=So(),r=t=>o=>{const a="number"==typeof o?o:null==o||""===o?0:Number(o);Number.isNaN(a)||n({...e,[t]:a})};return l.jsx("div",{className:"ee-settings-padding-grid",role:"group","aria-label":i("padding_settings"),children:$a.map(({key:n,suffix:i})=>l.jsx(t.InputNumber,{min:o,step:1,value:e?.[n]??0,onChange:r(n),disabled:a,addonAfter:l.jsx("span",{className:"ee-settings-padding-addon-side","aria-hidden":!0,children:i}),className:"input-width ee-settings-input-affix ee-padding-side-input-num",onFocus:e=>e?.target?.select?.()},n))})},Ma=e=>l.jsx(t.Switch,{...e,className:`ee-settings-switch ${e.className||""}`.trim()}),Pa=({padding:a,setPadding:i,showLinkSides:r=!0})=>{const{t:s}=So(),[c,d]=e.useState(!1);return r?l.jsxs("div",{className:"padding-settings ee-padding-settings-v2",children:[c?l.jsx(t.InputNumber,{min:0,step:1,addonAfter:"px",className:"input-width ee-settings-input-affix ee-padding-linked-input-num",value:a?.paddingTop??0,onChange:e=>{const t="number"==typeof e?e:0;i({...a,paddingTop:t,paddingRight:t,paddingBottom:t,paddingLeft:t})},onFocus:e=>e?.target?.select?.()}):l.jsx(Ra,{padding:a,onChange:i,min:0}),l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row padding-settings-link-row",children:[l.jsxs("span",{className:"ee-padding-link-sides-label",children:[s("padding_link_sides_label"),l.jsx(t.Tooltip,{title:s("padding_link_sides_tooltip"),children:l.jsx("span",{className:"ee-help-icon ee-padding-link-sides-help","aria-label":s("padding_link_sides_tooltip"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),l.jsx(Ma,{checked:c,onChange:d})]})]}):l.jsx("div",{className:"padding-settings ee-padding-settings-v2 ee-padding-settings-plain",children:l.jsx(Ra,{padding:a,onChange:i,min:0})})},Fa=()=>{const{t:e}=So(),t=va(e),n=(e=>{const t={desktop:{textAlign:"center",paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0},mobile:{}},n={key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},o=o=>({name:e("content"),key:"content",width:o,styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]});return{full:{columns:1,type:"full",children:[{name:e("content"),key:"content",width:"100%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}]},"1-1":{columns:2,type:"1-1",children:Array.from({length:2}).map(()=>({name:e("content"),key:"content",width:"50%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-1-1":{columns:3,type:"1-1-1",children:Array.from({length:3}).map(()=>({name:e("content"),key:"content",width:"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-2-1":{columns:3,type:"1-2-1",children:Array.from({length:3}).map((e,t)=>o(1===t?"50%":"25%"))},"2-1-1":{columns:3,type:"2-1-1",children:Array.from({length:3}).map((e,t)=>o(0===t?"50%":"25%"))},"1-1-2":{columns:3,type:"1-1-2",children:Array.from({length:3}).map((e,t)=>o(2===t?"50%":"25%"))},"1-1-1-1":{columns:4,type:"1-1-1-1",children:Array.from({length:4}).map(()=>({name:e("content"),key:"content",width:"25%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"1-2":{columns:2,type:"1-2",children:Array.from({length:2}).map((e,t)=>o(0===t?"33.3%":"66.6%"))},"2-1":{columns:2,type:"2-1",children:Array.from({length:2}).map((e,t)=>o(0===t?"66.6%":"33.3%"))},"1-3":{columns:2,type:"1-3",children:Array.from({length:2}).map((e,t)=>o(0===t?"25%":"75%"))},"3-1":{columns:2,type:"3-1",children:Array.from({length:2}).map((e,t)=>o(0===t?"75%":"25%"))},"2-3":{columns:2,type:"2-3",children:Array.from({length:2}).map((e,t)=>o(0===t?"40%":"60%"))},"3-2":{columns:2,type:"3-2",children:Array.from({length:2}).map((e,t)=>o(0===t?"60%":"40%"))},"2-4-2-4":{columns:4,type:"2-4-2-4",children:Array.from({length:4}).map((o,a)=>({name:e("content"),key:"content",width:a%2==0?"16.6%":"33.3%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))},"4-2-4-2":{columns:4,type:"4-2-4-2",children:Array.from({length:4}).map((o,a)=>({name:e("content"),key:"content",width:a%2==0?"33.3%":"16.6%",styles:n,children:[{name:e("drag_block_here"),key:"empty",width:"100%",styles:t}]}))}}})(e),o=(e=>t=>{const n={id:A(),name:e("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}};return{id:A(),name:e("container"),key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},children:[{id:A(),name:e("content"),key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[t||n]}]}})(e);return{blockConfigsList:t,columnsSetting:n,getColumnConfig:o}},Ea=({children:e,className:t=""})=>l.jsx("h3",{className:`ee-settings-section-title ${t}`.trim(),children:e}),Da=e=>e?l.jsx("span",{style:{color:"var(--ee-text-tertiary)",fontWeight:400,fontSize:11,marginLeft:6},children:"optional"}):null,Ua=({label:e,hint:t,optional:n,children:o,className:a="",layout:i="stack"})=>l.jsxs("div",{className:`ee-settings-field ${"toggle"===i?"ee-settings-field--toggle":""} ${a}`.trim(),children:["toggle"===i&&e?l.jsxs("div",{className:"ee-settings-row ee-settings-field-toggle-inner",children:[l.jsxs("span",{className:"ee-settings-row-label",children:[e,Da(n)]}),o]}):l.jsxs(l.Fragment,{children:[e?l.jsxs("div",{className:"ee-settings-field-label",children:[e,Da(n)]}):null,o]}),t?l.jsx("div",{style:{fontSize:11,color:"var(--ee-text-tertiary)",lineHeight:1.5},children:t}):null]}),za=({widths:e})=>{const t=e.reduce((e,t)=>e+parseFloat(t),0)||1;return l.jsx("div",{style:{display:"flex",height:18,gap:2,borderRadius:2,overflow:"hidden",width:36,flexShrink:0},children:e.map((e,n)=>l.jsx("div",{style:{flex:parseFloat(e)/t,background:"rgba(216, 254, 145, 0.5)",borderRadius:1}},n))})},Oa=[{key:"full",label:"1 col",widths:["100%"]},{key:"1-1",label:"Equal 2",widths:["50%","50%"]},{key:"1-1-1",label:"Equal 3",widths:["33.3%","33.3%","33.3%"]},{key:"1-1-1-1",label:"Equal 4",widths:["25%","25%","25%","25%"]},{key:"1-2",label:"1 / 2",widths:["33.3%","66.6%"]},{key:"2-1",label:"2 / 1",widths:["66.6%","33.3%"]},{key:"1-3",label:"1 / 3",widths:["25%","75%"]},{key:"3-1",label:"3 / 1",widths:["75%","25%"]},{key:"2-3",label:"2 : 3",widths:["40%","60%"]},{key:"3-2",label:"3 : 2",widths:["60%","40%"]},{key:"1-2-1",label:"1 / 2 / 1",widths:["25%","50%","25%"]},{key:"2-1-1",label:"2 / 1 / 1",widths:["50%","25%","25%"]},{key:"1-1-2",label:"1 / 1 / 2",widths:["25%","25%","50%"]},{key:"2-4-2-4",label:"2-4 · 2-4",widths:["16.6%","33.3%","16.6%","33.3%"]},{key:"4-2-4-2",label:"4-2 · 4-2",widths:["33.3%","16.6%","33.3%","16.6%"]}],Wa=()=>{const{blockMap:a,rootOrder:i,setBlocks:r,currentItem:c,setCurrentItem:d,previewMode:u}=e.useContext(ge),{t:m}=So(),{columnsSetting:p}=Fa();if(!c?.data||"column"!==c.data.key)return null;if(ua(c.data)!==pa)return null;const g=c.data.children||[],h=g.length,b=e=>{const{blockMap:t}=R([e]),n={...a,...t};r(n,i,`edit_${Date.now()}`),d({...c,data:e})},y=e=>{const t=p[e.key]||p.full;if(!t)return;const n=c.data.children||[],o=(t.children||[]).map((e,t)=>{const o=n[t];if(o)return{...o,key:e.key,name:e.name,width:e.width,styles:C(e.styles??o.styles),children:o.children};const a=A();return{...e,id:a}}),a=C(c.data);a.children=o,b(a)},_=(()=>{const e="desktop"===u?c.data.styles?.desktop:{...c.data.styles?.desktop,...c.data.styles?.mobile},t=e?.columnGap??e?.column_gap??0;return"number"==typeof t?t:parseInt(String(t).replace("px",""),10)||0})(),f=g.reduce((e,t)=>e+parseFloat(t.width||"100"),0)||1,x=Oa.filter(e=>p[e.key]);return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:m("grid_settings")}),l.jsxs("div",{className:"ee-settings-row ee-columns-count-row",children:[l.jsx("span",{className:"ee-padding-link-sides-label",children:m("columns")}),l.jsxs("div",{className:"ee-columns-stepper",children:[l.jsx("button",{type:"button",className:"ee-col-stepper-btn",disabled:h<=1,onClick:()=>{const e=Math.max(1,h-1),t=Oa.find(t=>t.widths.length===e);t&&y(t)},"aria-label":m("columns"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faMinus,style:{fontSize:10}})}),l.jsx("span",{className:"ee-columns-stepper-value",children:h}),l.jsx("button",{type:"button",className:"ee-col-stepper-btn",disabled:h>=4,onClick:()=>{const e=Math.min(4,h+1),t=Oa.find(t=>t.widths.length===e&&t.key.startsWith("1-1"));if(t)y(t);else{const t=Oa.find(t=>t.widths.length===e);t&&y(t)}},"aria-label":m("columns"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faPlus,style:{fontSize:10}})})]})]}),l.jsx(Ea,{children:m("presets")}),l.jsx("div",{className:"ee-columns-preset-grid",children:x.map(e=>{const t=h===e.widths.length&&g.every((t,n)=>{const o=parseFloat(t.width||"0"),a=parseFloat(e.widths[n]||"0");return Math.abs(o-a)<1});return l.jsxs("button",{type:"button",className:s("ee-columns-preset-btn",t&&"ee-columns-preset-btn--active"),onClick:()=>y(e),children:[l.jsx(za,{widths:e.widths}),l.jsx("span",{children:e.label})]},e.key)})}),h>1&&l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:m("column_sizes")}),l.jsx("div",{className:"ee-columns-width-sliders",children:g.map((e,t)=>{const n=(e=>{if("string"!=typeof e)return 1;const t=parseFloat(e.replace("%",""));return isNaN(t)?1:t})(e.width)/f*100;return l.jsxs("div",{className:"ee-columns-width-slider-row",children:[l.jsxs("span",{className:"ee-columns-width-col-label",children:[m("col")," ",t+1]}),l.jsx("input",{type:"range",min:10,max:90,step:1,value:Math.round(n),onChange:e=>{const n=parseInt(e.target.value,10),o=t===h-1?0:h-1,a=100-n-g.reduce((e,n,a)=>a===t||a===o?e:e+Math.round(parseFloat(n.width||"0")/f*100),0),l=C(c.data);l.children=l.children.map((e,l)=>l===t?{...e,width:`${n}%`}:l===o?{...e,width:`${Math.max(10,a)}%`}:e),b(l)},className:"ee-columns-width-range"}),l.jsxs("span",{className:"ee-columns-width-pct",children:[Math.round(n),"%"]})]},e.id||t)})})]}),l.jsx(Ea,{children:m("gaps")}),l.jsx(Ua,{label:m("column_gap"),children:l.jsx(t.InputNumber,{min:0,max:60,className:"input-width ee-settings-input-affix",addonAfter:"px",value:_,onChange:e=>(e=>{const t=C(c.data);t.styles||(t.styles={desktop:{},mobile:{}}),t.styles[u]||(t.styles[u]={}),Object.assign(t.styles[u],e),b(t)})({columnGap:e??0})})})]})},Ha=({items:e,value:t,onChange:n,size:o="md",className:a="","aria-label":i})=>l.jsx("div",{className:`ee-settings-segmented ${"sm"===o?"ee-settings-segmented--sm":""} ${a}`.trim(),role:"group","aria-label":i,children:e.map(e=>{const o="string"==typeof e?e:e.value,a="string"==typeof e?e:e.label,i="object"==typeof e&&e.icon?e.icon:null,r=o===t,s="object"==typeof e&&e.iconOnly;return l.jsxs("button",{type:"button",title:"string"==typeof a?a:void 0,className:`ee-settings-segmented-btn${r?" ee-settings-segmented-btn--active":""}${s?" ee-settings-segmented-btn--icon-only":""}`,onClick:()=>n&&n(o),children:[i,a]},String(o))})}),Va=e=>{if(!e||"string"!=typeof e)return!1;try{const t=new URL(e);return/\/knowledge-base\/products$/i.test(t.pathname.replace(/\/$/,""))}catch{return/knowledge-base\/products\/?$/i.test(String(e).trim().replace(/\/$/,""))}},Ka=e=>{if(!e||"object"!=typeof e)return null;const t=null!=e.id?String(e.id):null!=e.resourceId?String(e.resourceId):"";if(!t)return null;const n=e.price,o="number"==typeof n?n:parseFloat(String(n??"").replace(/,/g,""));return{id:t,name:e.name??"",description:ke(e.description),image:e.image_url??e.image??"",link:e.url??"",price:Number.isFinite(o)?o:0,currency:e.currency??"USD",old_price:null!=e.old_price?e.old_price:null,new_price:null!=e.new_price?e.new_price:null,resourceId:e.resourceId,source:e.source}},Ga=async(e,t,n={},{page:o=1,limit:a=20,search:l=""}={})=>{if(!e)return null;try{if(Va(e)){if(!t)return null;const i=e.replace(/\/$/,""),r=new URL(`${i}/${encodeURIComponent(t)}`);r.searchParams.set("page",String(o)),r.searchParams.set("limit",String(a)),r.searchParams.set("search",l??"");const s=await fetch(r.toString(),{method:"GET",headers:{"Content-Type":"application/json",...n}});if(!s.ok)return console.error("[API Service] KB products fetch failed:",s.status,s.statusText),null;const c=await s.json(),d=Array.isArray(c.data)?c.data:[];return{products:d.map(Ka).filter(Boolean),meta:c.meta&&"object"==typeof c.meta?c.meta:{}}}const i=new URL(e);t&&i.searchParams.append("companyId",t);const r=await fetch(i.toString(),{method:"GET",headers:{"Content-Type":"application/json",...n}});if(!r.ok)return console.error("[API Service] Products fetch failed:",r.status,r.statusText),null;const s=await r.json();if(!1===s.success)return console.error("[API Service] Products API returned error:",s.error),null;const c=s.data?.products??[],d=Array.isArray(c)?c.map(e=>e&&"object"==typeof e?{...e,description:ke(e.description)}:e):[];return Array.isArray(d)&&0!==d.length?{products:d,meta:{hasMore:!1,hasProducts:!0}}:{products:[],meta:{hasMore:!1,hasProducts:!1}}}catch(e){return console.error("[API Service] Error fetching products:",e),null}},qa={};function Ja(){return"undefined"!=typeof document?document.body:null}function Ya(e){if(!e)return"";const t=e.currency??"",n=e.price?.amount??e.price??"";return`${e.name} — ${t} ${n}`.trim()}function Xa(e,t){const n=new Map;return[...e,...t].forEach(e=>{e&&e.id&&n.set(e.id,e)}),Array.from(n.values())}function Za({apiConfig:n,templateData:o,value:a,selectedProduct:i,onChange:r,placeholder:s,staticProductList:c=[],getPopupContainer:d}){const{t:u}=So(),m=n?.productsEndpoint,p=n?.companyId??o?.companyId,g=e.useMemo(()=>{const e=n?.headers;return e&&"object"==typeof e?e:qa},[n?.headers]),h=Boolean(m&&p)&&Va(m),[b,y]=e.useState([]),[_,f]=e.useState({}),[x,k]=e.useState(!1),[v,w]=e.useState(""),[j,S]=e.useState(""),C=e.useRef(null),N=e.useRef(0),I=e.useRef(1),A=e.useRef(""),T=e.useRef(!1),L=e.useRef(""),B=e.useCallback(async(e,t,n)=>{if(!h)return;const o=(t??"").trim();if(n){const t=`${o}::${e}`;if(T.current&&L.current===t)return;T.current=!0,L.current=t}const a=++N.current;k(!0);try{const l=await Ga(m,p,g,{page:e,limit:20,search:o});if(a!==N.current)return;if(!l)return n||(y([]),S((t??"").trim())),void f({});f(l.meta||{}),y(e=>n?Xa(e,l.products):l.products),I.current=e}finally{n&&(T.current=!1,L.current=""),a===N.current&&k(!1)}},[h,m,p,g]),$=e.useCallback(async e=>{if(!h)return;const t=(e??"").trim();T.current=!1,L.current="";const n=++N.current;k(!0);try{if(""!==t){const e=await Ga(m,p,g,{page:1,limit:20,search:t});if(n!==N.current)return;return e?(f(e.meta||{}),y(e.products),S(t),void(I.current=1)):(y([]),f({}),S(t),void(I.current=1))}let e=1,o=[],a={};for(;o.length<10&&e<=15;){const t=await Ga(m,p,g,{page:e,limit:20,search:""});if(n!==N.current)return;if(!t?.products?.length)break;if(o=Xa(o,t.products),a=t.meta||{},I.current=e,!a.hasMore)break;e+=1}f(a),y(o),S("")}finally{n===N.current&&k(!1)}},[h,m,p,g]),R=e.useCallback(()=>{if(!h||x||!_?.hasMore)return;const e=I.current+1;B(e,A.current,!0)},[h,x,_?.hasMore,B]),M=d??Ja,P=e.useCallback(e=>l.jsxs("div",{children:[e,x&&b.length>0&&l.jsxs("div",{className:"ee-kb-product-select-footer",children:[l.jsx(t.Spin,{size:"small"})," ",l.jsx("span",{children:u("loading")})]}),!x&&_?.hasMore&&l.jsx("div",{className:"ee-kb-product-select-footer",children:l.jsx("button",{type:"button",className:"ee-kb-product-select-load-more",onClick:R,children:u("load_more_products")})})]}),[x,b.length,_?.hasMore,R,u]),F=e.useMemo(()=>{const e=h?b:c;return Xa(i?.id?[i]:[],e)},[h,b,c,i]),E=e.useMemo(()=>F.map(e=>({value:e.id,label:Ya(e)})),[F]),D=e=>{if(!e)return r(null),void(h&&(clearTimeout(C.current),w(""),A.current="",I.current=1,S(""),$("")));const t=F.find(t=>t.id===e)||c.find(t=>t.id===e);r(t||null)},U="ee-kb-product-select-dropdown";return h?l.jsx(t.Select,{className:"ee-stack-control ee-kb-product-select",value:a??void 0,placeholder:s,style:{width:"100%"},virtual:!0,dropdownMatchSelectWidth:!0,listHeight:320,listItemHeight:32,dropdownClassName:U,getPopupContainer:M,onChange:D,allowClear:!0,showSearch:!0,filterOption:!1,searchValue:v,onSearch:e=>{if(!h)return;const t=e??"";w(t);const n=t.trim();if(clearTimeout(C.current),""===n)return A.current="",I.current=1,void $("");C.current=setTimeout(()=>{A.current=n,I.current=1,$(n)},400)},onOpenChange:e=>{clearTimeout(C.current),e?(T.current=!1,L.current="",w(""),A.current="",I.current=1,$("")):(T.current=!1,L.current="",w(""),A.current="")},notFoundContent:x?l.jsxs("span",{className:"ee-kb-product-select-loading",children:[l.jsx(t.Spin,{size:"small"})," ",u("loading")]}):E.length>0?null:l.jsx("span",{className:"ee-kb-product-select-empty",children:""!==j.trim()?u("no_products_matching_search"):u("no_product_found")}),options:E,dropdownRender:P}):l.jsx(t.Select,{className:"ee-stack-control",value:a??void 0,placeholder:s,style:{width:"100%"},virtual:!0,dropdownMatchSelectWidth:!0,listHeight:320,listItemHeight:32,dropdownClassName:U,getPopupContainer:M,onChange:D,allowClear:!0,showSearch:!0,optionFilterProp:"label",options:c.map(e=>({value:e.id,label:Ya(e)}))})}const Qa=()=>{const{previewMode:t,currentItem:n,blockMap:o,rootOrder:a,setBlocks:i,setCurrentItem:r}=e.useContext(ge),s=e=>{let t;if("column"===e.key){const{blockMap:n}=R([e]);t={...o,...n}}else t={...o,[n.id]:e};i(t,a,`edit_${(new Date).getTime()}`),r({...n,data:e})};return{findStyleItem:(e,n)=>{let o=e[t][n];return o||(o=e.desktop[n]),o},cardItemElement:(e,t)=>l.jsxs("div",{className:"card-item",children:[l.jsx("div",{className:"card-item-title",children:e}),l.jsx("div",{children:t})]}),updateItemStyles:s,colorChange:e=>({hex:o})=>{const a=C(n.data);a.styles[t][e]=o,s(a)},paddingChange:e=>{const o=C(n.data);o.styles[t]={...o.styles[t],...e},s(o)},otherStylesChange:(e,o)=>{const a=C(n.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles[t]||(a.styles[t]={}),a.styles[t][e]=o,"desktop"!==t&&(a.styles.desktop[e]=o),s(a)},inputChange:e=>o=>{const a=C(n.data);a.styles||(a.styles={desktop:{},mobile:{}}),a.styles[t]||(a.styles[t]={}),a.styles[t][e]=o,"desktop"!==t&&(a.styles.desktop[e]=o),s(a)}}},el=[{id:"dolor-sit-amet",name:"Dolor Sit Amet",description:"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.",image:"https://plus.unsplash.com/premium_photo-1681711647066-ef84575c0d95?fm=jpg&q=30&w=300&auto=format&fit=crop&ixlib=rb-4.1.0&ixid=M3wxMjA3fDB8MHxzZWFyY2h8MXx8cHJvZHVjdCUyMHBob3RvZ3JhcGh5fGVufDB8fDB8fHww",link:"https://loremipsum.com/checkout/cart/12345",price:2e3,currency:"USD",old_price:2500,new_price:2e3},{id:"sample-2",name:"Sample Pearl Necklace",description:"Classic strand of lustrous freshwater pearls with a sterling silver clasp. Timeless elegance for any outfit.",image:"https://picsum.photos/seed/necklace2/200/200",link:"https://www.example.com/products/sample-2",price:750,currency:"USD",old_price:null,new_price:null},{id:"sample-3",name:"Sample Gold Bracelet",description:"Handcrafted 14K yellow gold link bracelet. Lightweight and comfortable for everyday wear.",image:"https://picsum.photos/seed/bracelet3/200/200",link:"https://www.example.com/products/sample-3",price:450,currency:"USD",old_price:500,new_price:450},{id:"sample-4",name:"Sample Silver Earrings",description:"Delicate sterling silver drop earrings with subtle sparkle. A versatile addition to your jewelry collection.",image:"https://picsum.photos/seed/earrings4/200/200",link:"https://www.example.com/products/sample-4",price:199,currency:"USD",old_price:null,new_price:null},{id:"sample-5",name:"Sample Gemstone Pendant",description:"Stunning pendant with a natural gemstone centerpiece on a fine silver chain. Makes a memorable gift.",image:"https://picsum.photos/seed/pendant5/200/200",link:"https://www.example.com/products/sample-5",price:320,currency:"USD",old_price:400,new_price:320}],tl=new Set(["image/png","image/jpeg","image/jpg","image/gif","image/svg+xml","image/webp"]),nl={png:"image/png",jpeg:"image/jpeg",jpg:"image/jpeg",gif:"image/gif",svg:"image/svg+xml",webp:"image/webp"},ol=Array.from(tl).join(",");function al(e){return e?function(e){if(!e)return!1;const t=String(e.type||"").toLowerCase().trim();if(t)return tl.has(t);const n=String(e.name||"").toLowerCase(),o=n.lastIndexOf(".");if(-1===o)return!1;const a=n.slice(o+1);return Object.prototype.hasOwnProperty.call(nl,a)}(e)?e.size>10485760?"size":null:"type":null}const ll=({imageUploadEndpoint:t,headers:n={},companyId:o,imageUploadQueryParams:a,imageUploadCompanyField:l="companyId"}={})=>{const i=!!t;return{uploadImageFile:e.useCallback(async e=>{if(!i)return console.error("[useImageUpload] No image upload endpoint configured"),null;if(!e)return console.error("[useImageUpload] No file provided"),null;const r=al(e);if("type"===r)return console.error("[useImageUpload] File type not allowed:",e.type),null;if("size"===r)return console.error("[useImageUpload] File too large:",e.size,"bytes"),null;const s=await(async(e,t,n,o={},a={})=>{if(!e)return console.error("[API Service] No image upload endpoint configured"),null;if(!t)return console.error("[API Service] No file provided for upload"),null;const{queryParams:l={},companyField:i="companyId"}=a;try{const a=new FormData;a.append("file",t),n&&("comment"===i?a.append("comment",n):a.append("companyId",n));let r=e;if(l&&Object.keys(l).length>0){const t="undefined"!=typeof window&&window.location?.origin?window.location.origin:"http://localhost",n=new URL(e,t);Object.entries(l).forEach(([e,t])=>{null!=t&&n.searchParams.set(e,String(t))}),r=n.toString()}const s={...o};Object.keys(s).forEach(e=>{"content-type"===e.toLowerCase()&&delete s[e]});const c=await fetch(r,{method:"POST",headers:{...s},body:a}),d=await c.text();let u={};try{u=d?JSON.parse(d):{}}catch{u=d?{message:d.slice(0,500)}:{}}if(!c.ok){const e=En(u,c.status);throw console.error("[API Service] Image upload failed:",c.status,e),new Error(e)}if(u&&!1===u.success){const e=En(u,c.status);throw console.error("[API Service] Upload API returned error:",e),new Error(e)}if(u&&"string"==typeof u.url&&u.url.trim())return u.url.trim();const m=u?.data?.url;if(m&&"string"==typeof m)return m.trim();throw new Error("Upload succeeded but no image URL was returned.")}catch(e){if(console.error("[API Service] Error uploading image:",e),e instanceof Error&&e.message)throw e;throw new Error(e&&"object"==typeof e&&"message"in e?String(e.message):"Unable to upload image. Check your network and try again.")}})(t,e,o,n,{queryParams:a,companyField:l});return s},[i,t,n,o,a,l]),isConfigured:i}},il=[{value:"100%",label:"Full"},{value:"720px",label:"720"},{value:"600px",label:"600"},{value:"540px",label:"540"}],rl=[{value:"none",label:"None"},{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"}];function sl(e){if(null==e)return!0;const t=String(e).trim().toLowerCase();return""===t||"transparent"===t}const cl=({t:n,findStyleItem:o,colorChange:a,inputChange:i,paddingChange:r,patchContainerBackground:s,commitColumnUpdate:c,currentItem:d,children:u})=>{const m=o(d.data.styles,"backgroundColor"),p=o(d.data.styles,"contentBackground"),g=o(d.data.styles,"containerBackgroundImage")??"",h=""!==String(g).trim(),b=e.useMemo(()=>function(e,t){return e?"image":sl(t)?"none":"color"}(h,m),[h,m]),[y,_]=e.useState(null),f=y??b;e.useEffect(()=>{_(null)},[d?.data?.id]),e.useEffect(()=>{h&&_(null)},[h]);const x=o(d.data.styles,"contentMaxWidth")??"100%",k=il.some(e=>e.value===x)?x:"100%",v=o(d.data.styles,"minHeight")??"",w="string"==typeof v?parseInt(v.replace("px",""),10)||"":v||"",j=o(d.data.styles,"borderStyle")??"none",S=o(d.data.styles,"borderWidth")??1,N="string"==typeof S?parseInt(S.replace("px",""),10)||1:S||1,I=o(d.data.styles,"borderColor")??"#e0e0e0",A=o(d.data.styles,"borderRadius")??0,T="string"==typeof A?parseInt(String(A).replace("px",""),10)||0:A||0,L="none"!==j,B=Boolean(d.data.hiddenOnMobile),$=sl(p)?"auto":"custom";return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:n("section_background_group")}),l.jsx(Ua,{label:n("section_bg_mode"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:f,onChange:e=>(e=>{if("image"===e)return _("image"),void s({containerBackgroundEnabled:!0});if(_(null),"color"===e){s({containerBackgroundImage:"",containerBackgroundEnabled:!1});const e=sl(m)?"#ffffff":m;return void a("backgroundColor")({hex:e})}"none"===e&&(s({containerBackgroundImage:"",containerBackgroundEnabled:!1}),a("backgroundColor")({hex:"transparent"}))})(e),"aria-label":n("section_bg_mode"),items:[{value:"color",label:n("section_bg_color")},{value:"image",label:n("section_bg_image")},{value:"none",label:n("section_bg_none")}]})}),("color"===f||"image"===f)&&l.jsx(Ua,{label:n("background_color"),children:l.jsx(Ba,{color:sl(m)?"#ffffff":m,setColor:({hex:e})=>a("backgroundColor")({hex:e})})}),"image"===f?u:null,l.jsx(Ea,{children:n("section_content_area_group")}),l.jsx(Ua,{label:n("content_area_color"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:$,onChange:e=>{"auto"!==e?i("contentBackground")("#ffffff"):i("contentBackground")("transparent")},"aria-label":n("content_area_color"),items:[{value:"auto",label:n("content_color_auto")},{value:"custom",label:n("content_color_custom")}]})}),"custom"===$?l.jsx(Ua,{label:n("content_background_color"),children:l.jsx(Ba,{color:sl(p)?"#ffffff":p,setColor:({hex:e})=>a("contentBackground")({hex:e})})}):null,l.jsx(Ua,{label:n("content_max_width"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:k,onChange:e=>i("contentMaxWidth")(e),"aria-label":n("content_max_width"),items:il})}),l.jsx(Ua,{label:n("min_height"),children:l.jsx(t.InputNumber,{min:0,max:2e3,className:"input-width ee-settings-input-affix",addonAfter:"px",value:w,onFocus:e=>e?.target?.select?.(),onChange:e=>i("minHeight")(e?`${e}px`:"")})}),l.jsx(Ea,{children:n("border")}),l.jsx(Ua,{label:n("border_style"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:j,onChange:e=>i("borderStyle")(e),"aria-label":n("border_style"),items:rl})}),L?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:n("border_width"),children:l.jsx(t.InputNumber,{min:0,max:20,className:"input-width ee-settings-input-affix",addonAfter:"px",value:N,onFocus:e=>e?.target?.select?.(),onChange:e=>i("borderWidth")(e??1)})}),l.jsx(Ua,{label:n("border_color"),children:l.jsx(Ba,{color:I,setColor:({hex:e})=>a("borderColor")({hex:e})})})]}):null,l.jsx(Ua,{label:n("border_radius"),children:l.jsx(t.InputNumber,{min:0,max:64,className:"input-width ee-settings-input-affix",addonAfter:"px",value:T,onFocus:e=>e?.target?.select?.(),onChange:e=>i("borderRadius")(e??0)})}),l.jsx(Ea,{children:n("spacing")}),l.jsx(Ua,{label:n("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:o(d.data.styles,"paddingTop"),paddingRight:o(d.data.styles,"paddingRight"),paddingLeft:o(d.data.styles,"paddingLeft"),paddingBottom:o(d.data.styles,"paddingBottom")},setPadding:r})}),l.jsx(Ea,{children:n("visibility")}),l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row ee-visibility-hide-mobile-row",children:[l.jsx("span",{className:"ee-padding-link-sides-label",children:n("hidden_on_mobile")}),l.jsx(Ma,{checked:B,onChange:e=>{const t=C(d.data);t.hiddenOnMobile=e,c(t)}})]})]})},dl=["product"],ul=e=>"additional"===e?"additional":"main";function ml(e){const t=String(e??"").trim();return t?/^\{\{\w+\}\}$/.test(t)?null:g(t,!1,{allowMailtoTel:!1})||null:null}const pl=()=>{const{blockMap:a,rootOrder:i,setBlocks:r,currentItem:s,setCurrentItem:c,previewMode:d,templateData:u,setIsDragStart:p,setActionType:g,apiConfig:h}=e.useContext(ge),{t:b}=So(),[y,_]=e.useState(!1),f=e.useRef(null),[x,k]=e.useState(!1),[v,w]=e.useState(""),[j,S]=e.useState(""),{uploadImageFile:N,isConfigured:I}=ll({imageUploadEndpoint:h?.imageUploadEndpoint,headers:h?.headers||{},companyId:h?.companyId,imageUploadQueryParams:h?.imageUploadQueryParams,imageUploadCompanyField:h?.imageUploadCompanyField}),{findStyleItem:A,colorChange:T,inputChange:L,paddingChange:B}=Qa(),{blockConfigsList:$}=Fa(),M=ua(s?.data),P=s?.data?.children??[],[F,D]=e.useState(0);e.useEffect(()=>{D(0)},[s?.data?.id]),e.useEffect(()=>{const e=P.length;0!==e&&D(t=>t>=e?Math.max(0,e-1):t)},[P.length]);const[U,z]=e.useState(!1);e.useEffect(()=>{z(!1)},[s?.data?.id]);const O="discount"===(W=s.data.containerType??"none")||"none"===W?W:"product";var W;const H=s.data.productRole??"main",V=s.data.columnProducts,K=e.useMemo(()=>Array.isArray(V)?V:[],[V]),G=e.useMemo(()=>({columnIndex:0,columnProduct:K[0]??null}),[K]),q=A(s.data.styles,"containerBackgroundImage")??"";e.useEffect(()=>{S("")},[q]);const J=u?.content?.products?.length>0?u.content.products:u?.catalogProducts?.length>0?u.catalogProducts:el,Y=u?.content?.primaryProductId,X=e=>{const{blockMap:t}=R([e]);let n={...a,...t};const o=ul(e.productRole);"product"===e.containerType&&"main"===o&&Object.keys(n).forEach(t=>{if(t===e.id)return;const o=n[t];if(!o||"column"!==o.key)return;if("product"!==o.containerType)return;"main"===ul(o.productRole)&&(n[t]={...o,productRole:"additional"})}),r(n,i,`edit_${(new Date).getTime()}`),c({...s,data:e})},Z=e=>{const t=C(s.data);t.styles||(t.styles={desktop:{},mobile:{}}),t.styles[d]||(t.styles[d]={}),Object.assign(t.styles[d],e),"desktop"!==d&&(t.styles.desktop||(t.styles.desktop={}),Object.assign(t.styles.desktop,e)),X(t)},Q=async e=>{if(!e)return;const n=al(e);if("type"!==n)if("size"!==n)if(I){k(!0);try{const n=await N(e);n?(Z({containerBackgroundImage:Zt(n),containerBackgroundEnabled:!0}),w(""),S(""),t.message.success(b("image_uploaded"))):t.message.error(b("image_upload_failed"))}catch(n){console.error(n);const e="string"==typeof n?.message&&n.message.trim()?n.message.trim():null;t.message.error(e||b("image_upload_error"))}finally{k(!1)}}else t.message.error(b("image_upload_not_configured"));else t.message.error(b("image_file_too_large"));else t.message.error(b("image_upload_invalid_type"))},ee=e=>{const t=ml(e);var n;w(t?b("blocked_scheme"===(n=t)?"container_bg_image_url_error_blocked_scheme":"duplicate_protocol"===n?"container_bg_image_url_error_duplicate_protocol":"missing_hostname_dot"===n?"container_bg_image_url_error_hostname":"invalid_protocol"===n?"container_bg_image_url_error_invalid_protocol":"container_bg_image_url_error_generic"):""),S("")},te=e=>{const t=C(s.data);t.productRole=ul(e);const n=t.children?.length??0;let o=Array.from({length:n},(e,n)=>t.columnProducts?.[n]??null);if(n>0&&J.length>0){const e=Y?J.find(e=>e.id===Y):J[0];e&&!o[0]&&(o[0]=e)}t.columnProducts=o,X(t)},ne=dl.includes(O),oe=e.useMemo(()=>To(s.data,a),[s.data,a]),ae=e.useMemo(()=>E(a,i,s.data?.id),[a,i,s.data?.id]),le=e.useMemo(()=>(ae||[]).filter(e=>e?.containerBlock&&e.containerBlock.id!==s.data?.id&&"none"!==e.containerType).map(e=>{const t=e.cellIndex??0;return{containerType:e.containerType,context:{columnIndex:t,columnProduct:e.containerBlock?.columnProducts?.[t]??null}}}),[ae,s.data?.id]),ie=jt(0,O,u,{},le).filter(({variableKey:e,key:t})=>!("product"===O)||(e??t)!==Ve).filter(({variableKey:e,key:t})=>!oe.has(e??t)),re=e.useMemo(()=>{const e={columnIndex:0,columnProduct:K[0]??null};return Nt(O,u,e).filter(e=>e.variableKey&&!oe.has(e.variableKey))},[O,u,K,oe]),se=e.useMemo(()=>{const e=new Set(ie.map(e=>e.variableKey??e.key)),t=re.filter(t=>{const n=t.variableKey;return!(!n||e.has(n))&&(e.add(n),!0)});return[...ie,...t]},[ie,re]),ce=e=>t=>{const n=(e=>{const{value:t,type:n}=e;if("image"===n){const e=C($.find(e=>"image"===e.key));return e?(e.src=t,e):{name:b("image"),key:"image",src:t,alt:"Image",type:"link",linkEnabled:!1,linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}}}const o=C($.find(e=>"text"===e.key));return o?(o.text=`<p>${t}</p>`,o.type="p",o.contentType="static",o):{name:b("text"),key:"text",text:`<p>${t}</p>`,type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"20px",paddingTop:16,paddingBottom:16,paddingLeft:16,paddingRight:16,textAlign:"left"},mobile:{}}}})(e);"undefined"!=typeof window&&(window.__eeDragItemData=n,window.__eeDragSource="product-variables"),p(!0),g("add"),t.target.classList.add("ee-product-variable-item-dragging"),t.dataTransfer&&(t.dataTransfer.effectAllowed="copy")},de=e=>{e.target.classList.remove("ee-product-variable-item-dragging"),"undefined"!=typeof window&&(window.__eeDragItemData=null,window.__eeDragSource=null),setTimeout(()=>{p(!1)},50)},ue=e=>t=>{const n=C(s.data);n.children[e].styles[d]={...n.children[e].styles[d],...t},X(n)},me=(e=!1)=>{const a=A(s.data.styles,"containerBackgroundImage")??"",i=function(e,t,n){const o=String(e??"").trim();if(!o)return"";if(ml(o))return"";if(/^\{\{\w+\}\}$/.test(o)){const e=o.replace(/\{\{|\}\}/g,"").trim(),a=t&&e?yt(t,e,n):null;return null==a||String(a).startsWith("{{")?"":m(String(a).trim(),{allowMailtoTel:!1})||""}return m(o,{allowMailtoTel:!1})||""}(a,u,G),r=l.jsxs("span",{className:"ee-container-bg-heading-inline",children:[b("container_background_image_section_title"),l.jsx(t.Tooltip,{title:l.jsxs("div",{className:"ee-container-bg-tooltip",children:[l.jsx("p",{className:"ee-container-bg-tooltip-p",children:b("container_background_image_tooltip_p1")}),l.jsx("p",{className:"ee-container-bg-tooltip-p",children:b("container_background_image_tooltip_p2")}),l.jsx("p",{className:"ee-container-bg-tooltip-p",children:b("container_background_image_intro")})]}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:l.jsx("span",{className:"ee-container-bg-section-help",tabIndex:0,"aria-label":b("container_background_image_title"),onClick:e=>e.stopPropagation(),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),c=!e||U;return l.jsxs("div",{className:fo("ee-container-bg-section",e&&"ee-container-bg-section--disclosure"),children:[e?l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row ee-container-bg-disclosure-switch-row",children:[l.jsx("div",{className:"ee-container-bg-disclosure-heading-left",children:l.jsx("span",{className:"ee-settings-section-title ee-container-bg-section-heading",children:r})}),l.jsx(Ma,{checked:U,onChange:z,"aria-label":b("container_background_image_section_toggle")})]}):l.jsx(Ea,{className:"ee-container-bg-section-heading",children:r}),c?l.jsxs("div",{className:"ee-container-bg-section-body",children:[l.jsx("input",{ref:f,type:"file",accept:ol,className:"ee-image-upload-input-hidden",onChange:async e=>{const t=e.target.files?.[0];await Q(t),e.target.value=""},disabled:x}),l.jsxs(Ua,{label:b("container_background_image_upload"),children:[l.jsx(t.Spin,{spinning:x,children:l.jsxs("div",{role:"button",tabIndex:0,className:"ee-image-upload-trigger",onClick:()=>!x&&f.current?.click(),onDrop:async e=>{e.preventDefault(),e.stopPropagation();const t=e.dataTransfer?.files?.[0];await Q(t)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},style:{opacity:x?.6:1,cursor:x?"not-allowed":"pointer"},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCloudUploadAlt,className:"ee-image-upload-icon"}),l.jsx("span",{children:b(x?"uploading":"image_upload_click")})]})}),l.jsxs("div",{className:"ee-image-toolbar",children:[l.jsxs("button",{type:"button",className:"ee-image-toolbar-btn",onClick:()=>f.current?.click(),disabled:x,children:[l.jsx(n.FontAwesomeIcon,{icon:o.faSyncAlt}),l.jsx("span",{children:b("replace")||"Replace"})]}),l.jsxs("button",{type:"button",className:"ee-image-toolbar-btn ee-image-toolbar-btn--danger",onClick:()=>{w(""),S(""),Z({containerBackgroundImage:"",containerBackgroundEnabled:!1})},disabled:x||!String(a).trim(),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faTrash}),l.jsx("span",{children:b("delete")||"Delete"})]})]}),l.jsx("div",{className:"ee-image-upload-hint",children:b("image_upload_file_hint")||"PNG, JPEG, GIF, SVG, WebP · max 10 MB"})]}),l.jsxs("div",{className:"ee-container-bg-url-block",children:[l.jsx("div",{className:"ee-stack-label ee-container-bg-url-label",children:b("container_background_image_url")}),l.jsx(t.Input,{className:"width-full",value:a,onChange:e=>{const t=e.target.value,n=""!==String(t).trim();S(""),v&&ee(t),Z({containerBackgroundImage:t,containerBackgroundEnabled:n})},onBlur:e=>ee(e.target.value),status:v||j?"error":"",placeholder:"https://"}),v?l.jsx("div",{className:"ee-field-error",role:"alert",children:v}):null,j&&!v?l.jsx("div",{className:"ee-field-error",role:"alert",children:j}):null,i&&!v?l.jsx("div",{className:"ee-container-bg-url-preview",children:l.jsx("img",{src:i,alt:"",className:"ee-container-bg-url-preview-img",onLoad:()=>S(""),onError:()=>S(b("container_bg_image_preview_failed"))})}):null]}),l.jsxs("div",{className:"ee-container-bg-format-bar",children:[l.jsx("div",{className:"ee-container-bg-format-bar-caption",children:b("container_background_image_layout_group")}),l.jsxs("div",{className:"ee-container-bg-format-bar-inner",children:[l.jsxs("div",{className:"ee-container-bg-format-bar-field ee-container-bg-format-bar-field-size",children:[l.jsx("div",{className:"ee-container-bg-format-bar-label",children:b("container_background_image_size")}),l.jsx(t.Select,{className:"ee-container-bg-size-select ee-container-bg-size-select-half",value:A(s.data.styles,"containerBackgroundSize")||"cover",onChange:e=>Z({containerBackgroundSize:e}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:en.map(e=>l.jsx(t.Select.Option,{value:e.value,children:b(e.labelKey)},e.value))})]}),l.jsxs("div",{className:"ee-container-bg-format-bar-field ee-container-bg-format-bar-field-grid",children:[l.jsx("div",{className:"ee-container-bg-format-bar-label",children:b("container_background_image_position")}),l.jsx("div",{className:"ee-container-bg-position-grid",role:"group","aria-label":b("container_background_image_position"),children:tn.map(e=>{const t=A(s.data.styles,"containerBackgroundPosition")||"center center";return l.jsx("button",{type:"button",className:fo("ee-container-bg-position-cell",t===e&&"ee-container-bg-position-cell-active"),title:e,"aria-pressed":t===e,onClick:()=>Z({containerBackgroundPosition:e}),children:l.jsx("span",{className:"ee-container-bg-dot","aria-hidden":!0})},e)})})]})]})]})]}):null]})};return l.jsx(l.Fragment,{children:l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsxs(l.Fragment,{children:[l.jsx(Ea,{className:"ee-settings-section-title--flush",children:b("container_settings")}),l.jsxs("div",{className:"ee-right-panel-stack",children:[ne&&l.jsxs("div",{className:"ee-product-assign-section margin-top-12",children:[l.jsx("span",{className:"ee-stack-label",children:b("product_role")}),l.jsx(t.Select,{className:"ee-stack-control",value:H,style:{width:"100%"},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,onChange:te,options:[{value:"main",label:b("product_role_main_hero")},{value:"additional",label:b("product_role_additional")}]})]}),ne&&l.jsxs("div",{className:"ee-product-assign-section margin-top-12",children:[l.jsx("span",{className:"ee-stack-label",children:b("assign_product_to_column")}),l.jsx(Za,{apiConfig:h,templateData:u,value:K[0]?.id??void 0,selectedProduct:K[0],onChange:e=>((e,t)=>{const n=C(s.data),o=[...n.columnProducts??[]];o[e]=t,n.columnProducts=o,X(n)})(0,e),placeholder:b("assign_product_to_column"),staticProductList:J})]}),l.jsxs("div",{className:"ee-product-variables-section margin-top-12",children:[l.jsxs("button",{type:"button",className:"ee-product-variables-toggle",onClick:()=>_(e=>!e),children:[l.jsx("span",{children:b("variables")}),l.jsx("span",{className:"ee-product-variables-toggle-icon",children:y?"▴":"▾"})]}),y&&l.jsx("div",{className:"ee-product-variables-dropdown",children:se.length>0?se.map(e=>l.jsxs("div",{className:"ee-product-variable-item",draggable:!0,onDragStart:ce(e),onDragEnd:de,title:e.value,children:[l.jsx("span",{className:"ee-product-variable-item-label",children:e.labelKey?b(e.labelKey):e.label}),l.jsx("span",{className:"ee-product-variable-item-token",children:e.value})]},e.value)):l.jsx("div",{className:"ee-stack-help",children:"No variables available for this container type."})})]})]})]}),M===pa&&l.jsx(Wa,{}),M!==ma&&(()=>{const e=s.data.children||[],t=Math.min(Math.max(0,F),Math.max(0,e.length-1)),n=e[t],o=n?A(n.styles,"backgroundColor"):void 0,a=b(M===pa?"column_cells_section":"column_settings");return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:a}),e.length>1?l.jsx(Ua,{label:b("column"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:String(t),"aria-label":b("column_settings"),onChange:e=>D(Number(e)),items:e.map((e,t)=>({value:String(t),label:`${b("column")} ${t+1}`}))})}):null,n?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:b("content_background_color"),children:l.jsx(Ba,{color:o,setColor:({hex:e})=>((e,t)=>n=>{const o=C(s.data);o.children[t].styles[d][e]=n,X(o)})("backgroundColor",t)(e)})}),l.jsx(Ua,{label:b("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:A(n.styles,"paddingTop"),paddingRight:A(n.styles,"paddingRight"),paddingLeft:A(n.styles,"paddingLeft"),paddingBottom:A(n.styles,"paddingBottom")},setPadding:ue(t)})})]}):null]})})(),(()=>{if(M===ma)return l.jsx(cl,{t:b,findStyleItem:A,colorChange:T,inputChange:L,paddingChange:B,patchContainerBackground:Z,commitColumnUpdate:X,currentItem:s,children:me()});const e=A(s.data.styles,"backgroundColor"),n=A(s.data.styles,"contentBackground"),o=A(s.data.styles,"borderRadius"),a="number"==typeof o?o:parseInt(String(o||"").replace("px",""),10)||0,i=Boolean(s.data.hiddenOnMobile);return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:b(M===pa?"column_wrapper_style":"column_styles")}),l.jsx(Ua,{label:b("background_color"),children:l.jsx(Ba,{color:e,setColor:T("backgroundColor")})}),l.jsx(Ua,{label:b("content_background_color"),children:l.jsx(Ba,{color:n,setColor:T("contentBackground")})}),l.jsx(Ua,{label:b("border_radius"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:a,onFocus:e=>e?.target?.select?.(),onChange:e=>L("borderRadius")(Number(e)||0)})}),l.jsx(Ua,{label:b("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:A(s.data.styles,"paddingTop"),paddingRight:A(s.data.styles,"paddingRight"),paddingLeft:A(s.data.styles,"paddingLeft"),paddingBottom:A(s.data.styles,"paddingBottom")},setPadding:B})}),me(M===pa),M===pa?l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:b("visibility")}),l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row ee-visibility-hide-mobile-row",children:[l.jsx("span",{className:"ee-padding-link-sides-label",children:b("hidden_on_mobile")}),l.jsx(Ma,{checked:i,onChange:e=>{const t=C(s.data);t.hiddenOnMobile=e,X(t)}})]})]}):null]})})()]})})},gl=({mlEmailNodesEndpoint:t,mlGenerationEndpoint:n,headers:o={},templateData:a,blockId:l,containerType:i,containerId:r,productId:s,blockName:c="Text",blockElementType:d="p",emailTemplateId:u,companyId:m,aiContentLanguage:p="en"}={})=>{const g=!!(t&&String(u??"").trim()&&String(m??"").trim()&&l&&r),h=!!n,b=g||h;return{generateOptions:e.useCallback(async(e,b,y={})=>{const{previousPrompt:_="",previousSelectedAiContent:f=""}=y,x=function(e,t={}){const{containerType:n}=t,o=String(e??"").trim();let a;return a=St[o]?St[o]:o?o.split(/[-_]/).map(e=>e.length?e[0].toUpperCase()+e.slice(1).toLowerCase():"").join(""):"DisplayText",a||(a="DisplayText"),"product"===n&&"DisplayText"===a?"ProductDescription":a}(e,{containerType:i});if(g){const e={containerType:i||"none",id:r};if("product"===(i||"")&&null!=s){const t=String(s).trim();t&&(e.productId=t)}const n=t,a={blockContext:{blockId:l,name:c,type:d||"p"},companyId:m,containerContext:e,emailTemplateId:u,language:"bn-BD"===p?"bn-BD":"en",promptContext:{newPrompt:b||"",previousPrompt:_||"",previousSelectedAiContent:f||""},type:x},g=await(async(e,t,n={})=>{if(!e)return console.error("[API Service] generate-email-nodes: no endpoint"),{success:!1,error:"ML endpoint is not configured."};try{const o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)});let a={};try{a=await o.json()}catch{a={}}if(!o.ok||!1===a.success){let e="";const t=a.error;if(t&&"object"==typeof t){const n=null!=t.code?String(t.code):"",o=null!=t.message?String(t.message):"";e=[n,o].filter(Boolean).join(" — ")||o||n}return e||(e=null!=a.message?String(a.message):`${o.status} ${o.statusText}`),console.error("[API Service] generate-email-nodes failed:",e),{success:!1,error:String(e),errorCode:t&&"object"==typeof t&&null!=t.code?String(t.code):void 0}}const l=Array.isArray(a.variations)?a.variations:[],i=l.map(e=>e&&"string"==typeof e.value?e.value.trim():"").filter(Boolean);return 0===i.length?(console.error("[API Service] generate-email-nodes: empty variations"),{success:!1,error:"No variations were returned for this request."}):{success:!0,options:i,variations:l,emailJson:"string"==typeof a.emailJson?a.emailJson:void 0,blockId:a.blockId,emailTemplateId:a.emailTemplateId}}catch(e){return console.error("[API Service] Error calling generate-email-nodes:",e),{success:!1,error:e&&"object"==typeof e&&"message"in e?String(e.message):"Unable to reach the ML service. Check your network and try again."}}})(n,a,o);if(g&&g.success&&g.options?.length)return g.options;return{error:g&&"object"==typeof g&&g.error?String(g.error):"No response from the ML service."}}if(h){const e={variable:x,prompt:b,context:{templateData:a,blockId:l,containerType:i}},t=await(async(e,t,n={})=>{if(!e)return console.error("[API Service] ML endpoint not configured"),null;try{const o=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",...n},body:JSON.stringify(t)});if(!o.ok)return console.error("[API Service] ML endpoint failed:",o.status,o.statusText),null;const a=await o.json();if(!a.success)return console.error("[API Service] ML API returned error:",a.error),null;const l=a.data?.options??[];return Array.isArray(l)&&0!==l.length?l:(console.error("[API Service] ML API returned empty options"),null)}catch(e){return console.error("[API Service] Error calling ML endpoint:",e),null}})(n,e,o);return t&&t.length?t:{error:"The legacy ML endpoint did not return any options. Check the API response."}}return{i18nKey:"ml_ai_unavailable"}},[g,h,t,n,o,a,l,i,r,s,c,d,u,m,p]),isConfigured:b}};function hl(){const{blockMap:t,rootOrder:n,currentItem:o}=e.useContext(ge);return e.useMemo(()=>{if(!t||!o?.id)return{containerBlock:null,containerType:"none",columnIndex:0,cellIndex:0};const{containerBlock:e,containerType:a,cellIndex:l,isRoot:i,rootIndex:r}=function(e,t,n){const o=(t||[]).indexOf(n);if(-1!==o){const t=e[n];return{containerBlock:t??null,containerType:t?.containerType??"none",cellIndex:0,isRoot:!0,rootIndex:o}}const a=F(e,t,n);if(!a)return{containerBlock:null,containerType:"none",cellIndex:0,isRoot:!1};const l=e[a.containerId];return{containerBlock:l??null,containerType:l?.containerType??"none",cellIndex:a.cellIndex,isRoot:!1}}(t,n,o.id);let s=0;if(i)s=r??0;else if(e){const t=n.indexOf(e.id);s=t>=0?t:0}const c=l??0;return{containerBlock:e??null,containerType:a??"none",columnIndex:s,cellIndex:c,contentIndex:c}},[t,n,o?.id])}const{TextArea:bl}=t.Input,yl=[8,9,10,11,12,14,16,18,20,24,28,32,36,48,64],_l="staticTextBeforeAi";function fl(e,t,n,o){const a=Number.parseInt(String(e??""),10);return Number.isNaN(a)?o:Math.min(n,Math.max(t,a))}function xl(e){return null==e||"string"!=typeof e?"":e.replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim()}const kl=()=>{const{currentItem:a,previewMode:i,templateData:r,apiConfig:s,bodySettings:c,aiEnabled:d=!0}=e.useContext(ge),{t:u}=So(),{findStyleItem:m,paddingChange:p,otherStylesChange:g,inputChange:h,updateItemStyles:b}=Qa(),{containerBlock:y,containerType:_,cellIndex:f}=hl(),x="product"===_?y?.columnProducts?.[f??0]?.id:void 0,k="bn-BD"===a?.data?.dynamicAiLanguage?"bn-BD":"en",{generateOptions:v}=gl({mlEmailNodesEndpoint:s?.mlEmailNodesEndpoint,mlGenerationEndpoint:s?.mlGenerationEndpoint,headers:s?.headers||{},templateData:r,blockId:a?.id,containerType:_,containerId:y?.id,productId:x,blockName:a?.data?.name||"Text",blockElementType:a?.data?.type||"p",emailTemplateId:s?.emailTemplateId,companyId:s?.companyId??r?.companyId,aiContentLanguage:k}),[w,j]=e.useState(""),S=m(a.data.styles,"fontSize"),N=null!=S&&""!==S?Number(S):14,[A,T]=e.useState(String(N)),[L,B]=e.useState(""),$=(e,t)=>{const n=C(a.data);n.styles||(n.styles={desktop:{},mobile:{}}),n.styles.desktop||(n.styles.desktop={}),n.styles.mobile||(n.styles.mobile={}),n.styles.desktop[e]=t,n.styles[i][e]=t,n.text=I(n.text,n.styles.desktop),b(n)},R=e=>{const t=fl(e,1,999,14);T(String(t)),$("fontSize",t)},M=()=>{const e=String(L??"").trim();if(""===e){const e=C(a.data);return e.styles||(e.styles={desktop:{},mobile:{}}),e.styles.desktop||(e.styles.desktop={}),e.styles.mobile||(e.styles.mobile={}),delete e.styles.desktop.lineHeight,delete e.styles.mobile.lineHeight,void b(e)}const t=fl(e,1,999,24);B(String(t)),h("lineHeight")(`${t}px`)};e.useEffect(()=>{T(String(N))},[a?.id,N]);const P=m(a.data.styles,"lineHeight");e.useEffect(()=>{B(null==P||""===P?"":String(function(e,t=14){if(null==e||""===e)return Math.max(1,Math.round(1.4*Number(t)));const n=String(e).trim(),o=n.match(/^(-?\d*\.?\d+)\s*%$/);if(o){const e=Number(o[1]);if(!Number.isNaN(e))return Math.max(1,Math.round(t*e/100))}const a=n.match(/^(-?\d*\.?\d+)\s*px$/i);if(a){const e=Number(a[1]);if(!Number.isNaN(e))return Math.max(1,Math.round(e))}const l=Number(n);return Number.isNaN(l)?24:l>0&&l<=10?Math.max(1,Math.round(t*l)):Math.max(1,Math.round(l))}(P,N)))},[a?.id,P,N]);const[F,E]=e.useState([]),[D,U]=e.useState(!1),[z,O]=e.useState(""),W=a.data.contentType??"static",H=a.data.type??"p",V=String(H).toLowerCase(),K="p"===V||""===H?"p":/^h[1-6]$/.test(V)?V:"p",G=e=>{if(!d)return;const t=e?"dynamic":"static",n=C(a.data),o=n.styles?.desktop??{};if(n.contentType=t,"dynamic"===t){if("static"===(a.data.contentType??"static")){const e=a.data.text??"",t=I(u("text_content"),o),l=I(u("ai_enabled"),o);xl(e).length>0&&e!==t&&e!==l?n[_l]=e:delete n[_l]}n.selectedVariableKey=void 0,n.dynamicVariable=n.dynamicVariable??"",n.dynamicPrompt=n.dynamicPrompt??"",n.dynamicSelectedContent=n.dynamicSelectedContent??"",n.dynamicOptions=Array.isArray(n.dynamicOptions)?n.dynamicOptions:[],n.dynamicAiLanguage="bn-BD"===n.dynamicAiLanguage?"bn-BD":"en",n.text=I(u("ai_enabled"),o)}else{const e=n[_l];"string"==typeof e&&xl(e).length>0?n.text=I(e,o):n.text=I(u("text_content"),o),delete n[_l]}b(n)},q=async()=>{const e=a.data.dynamicVariable??"",t=a.data.dynamicPrompt??w??"";U(!0),O("");try{const n=await v(e,t,{previousPrompt:a.data.dynamicPreviousPrompt??"",previousSelectedAiContent:xl(a.data.dynamicSelectedContent||a.data.text)});if(n&&"object"==typeof n&&!Array.isArray(n))return n.i18nKey?O(u(n.i18nKey)):n.error?O(String(n.error)):O(u("ml_no_variations")),void E([]);if(Array.isArray(n)&&n.length>0){O(""),E(n);const e=C(a.data);e.dynamicOptions=n,e.dynamicPrompt=t,e.dynamicPreviousPrompt=t,b(e)}else O(u("ml_no_variations")),E([])}catch(e){console.error("[TextStyleSettings] Error during content generation:",e),O(e&&"object"==typeof e&&"message"in e?String(e.message):u("ml_generation_unexpected_error")),E([])}finally{U(!1)}},J=e=>{const t=e.target.value;j(t),O("");const n=C(a.data);n.dynamicPrompt=t,b(n)},Y=e=>{const t=C(a.data);t.dynamicAiLanguage="bn-BD"===e?"bn-BD":"en",b(t)};return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[(()=>{const e=l.jsxs("div",{className:fo("ee-text-ai-usp-row","ee-settings-row","ee-text-ai-toggle-row",!d&&"ee-text-ai-usp-row--disabled"),children:[l.jsxs("span",{className:"ee-text-ai-label-with-help",children:[u("ai_enabled"),l.jsx(t.Tooltip,{title:u("tooltip_write_using_ai"),children:l.jsx("span",{className:"ee-help-icon ee-text-ai-help-trigger","aria-label":u("tooltip_write_using_ai"),onClick:e=>e.stopPropagation(),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),l.jsx(Ma,{checked:"dynamic"===W,onChange:G,disabled:!d})]});return l.jsx(l.Fragment,{children:l.jsxs("div",{className:"ee-text-settings-content-wrap",children:[l.jsx(Ea,{children:u("content")}),l.jsxs("div",{className:"ee-text-settings-content-gap",children:[l.jsx(Ua,{label:u("heading_type"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:K,onChange:e=>{return(t=e,()=>{const e=String(t??"p").toLowerCase(),n=a.data.styles?.desktop??{},o="p"!==e&&/^h[1-6]$/.test(e)?e:"p";let l,i,r;if("p"===o)l=14,i=20,r="400";else{switch(l=n.fontSize,o){case"h1":l=22;break;case"h2":l=20;break;case"h3":l=18;break;case"h4":l=16;break;case"h5":l=15;break;case"h6":l=14;break;default:l=null!=l&&""!==l&&Number(l)||14}i=Math.max(1,Math.round(1.4*Number(l))),r="bold"}const s=C(a.data);s.type=o;const c="p"===o?{textTransform:"none",letterSpacing:"0em"}:{},d={...n,...c,fontSize:l,lineHeight:`${i}px`,fontWeight:r},u={...a.data.styles?.mobile??{},...c,fontSize:l,lineHeight:`${i}px`,fontWeight:r};s.styles={...s.styles??{},desktop:d,mobile:u},s.text=I(s.text,d),b(s)})();var t},items:[{value:"p",label:u("body_paragraph")},{value:"h1",label:"H1"},{value:"h2",label:"H2"},{value:"h3",label:"H3"},{value:"h4",label:"H4"}],"aria-label":u("heading_type")})}),l.jsx("div",{className:"ee-text-ai-slot",children:d?e:l.jsx(t.Tooltip,{title:u("tooltip_write_using_ai_unavailable"),children:e})}),d&&"dynamic"===W?l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"ee-dynamic-prompt-block ee-dynamic-prompt-block--with-heading",children:[l.jsxs("div",{className:"ee-dynamic-language-row",children:[l.jsx("span",{className:"ee-prompt-label",children:u("ai_output_language")}),l.jsxs(t.Select,{className:"input-width ee-dynamic-language-select",value:k,onChange:Y,getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:[l.jsx(t.Select.Option,{value:"en",children:u("ai_output_language_en")}),l.jsx(t.Select.Option,{value:"bn-BD",children:u("ai_output_language_bn")})]})]}),l.jsxs("span",{className:"ee-prompt-label",children:[u("dynamic_prompt_help"),l.jsx(t.Tooltip,{title:u("tooltip_dynamic_prompt"),children:l.jsx("span",{className:"ee-help-icon","aria-label":"Help",children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),l.jsx(bl,{rows:3,value:a.data.dynamicPrompt??w,onChange:J,placeholder:u("dynamic_prompt_help")}),l.jsx(t.Button,{type:"primary",size:"small",block:!0,loading:D,disabled:!(a.data.dynamicPrompt??w??"").trim(),onClick:q,children:u("generate")}),z?l.jsx("div",{className:"ee-ml-generation-error",role:"alert",children:z}):null]}),(a.data.dynamicOptions?.length>0||F.length>0)&&l.jsxs("div",{className:"ee-sample-content-block",children:[l.jsx("div",{className:"card-item-title",children:u("select_content")}),(a.data.dynamicOptions||F).map((e,t)=>{const n="string"==typeof e?e:String(e),o=(a.data.text||a.data.dynamicSelectedContent||"").replace(/<[^>]+>/g,"").replace(/\s+/g," ").trim(),i=n.replace(/\s+/g," ").trim(),r=o.length>0&&o===i;return l.jsx("div",{className:fo("ee-sample-content-item",r&&"ee-sample-content-item-selected"),onClick:()=>(e=>{const t=C(a.data);t.dynamicSelectedContent=e,t.text=e,b(t),E([]),O("")})(e),children:e},t)})]})]}):null]})]})})})(),(()=>{const e=m(a.data.styles,"color"),s=null!=e&&""!==String(e).trim()?e:c?.styles?.color??"#171717",d=m(a.data.styles,"linkColor"),p=m(a.data.styles,"textAlign"),y=m(a.data.styles,"fontFamily"),_=function(e){if(null==e||""===e)return"400";const t=String(e).trim().toLowerCase();if("bold"===t||"bolder"===t)return"700";if("normal"===t||"lighter"===t)return"400";const n=Number(t);return Number.isNaN(n)||n<=450?"400":n<=550?"500":n<=650?"600":"700"}(m(a.data.styles,"fontWeight")),f=m(a.data.styles,"textTransform"),x=null!=f&&""!==String(f).trim()?String(f):"none",k=function(e,t){if(null==e||""===e)return t;const n=String(e).trim().replace(/[a-z%]+$/i,""),o=Number(n);return Number.isNaN(o)?t:o}(m(a.data.styles,"letterSpacing"),0),v=Mt(r),w=Ft(y,r);return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:u("typography")}),l.jsx(Ua,{label:u("font_color"),children:l.jsx(Ba,{color:s,fallbackColor:c?.styles?.color??"#171717",setColor:({hex:e})=>$("color",e)})}),l.jsx(Ua,{label:u("link_color"),children:l.jsx(Ba,{color:null!=d&&""!==String(d).trim()?d:"#2faade",setColor:({hex:e})=>((e,t)=>{const n=C(a.data);n.styles||(n.styles={desktop:{},mobile:{}}),n.styles.desktop||(n.styles.desktop={}),n.styles.mobile||(n.styles.mobile={}),n.styles.desktop[e]=t,n.styles[i][e]=t,b(n)})("linkColor",e)})}),l.jsx(Ua,{label:u("label_align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:p||"left",onChange:e=>g("textAlign",e),"aria-label":u("text_align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ua,{label:u("font_weight"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:_,onChange:e=>$("fontWeight",e),"aria-label":u("font_weight"),items:[{value:"400",label:"Reg"},{value:"500",label:"Med"},{value:"600",label:"SBd"},{value:"700",label:"Bd"}]})}),l.jsx(Ua,{label:u("text_transform"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:x,onChange:e=>$("textTransform",e),"aria-label":u("text_transform"),items:[{value:"none",label:"Aa"},{value:"uppercase",label:"AA"},{value:"capitalize",label:"Cp"}]})}),l.jsx(Ua,{label:u("font_family"),children:l.jsx(t.Select,{className:"input-width ee-font-family-select",value:w,showSearch:!0,optionFilterProp:"label",labelRender:({value:e})=>l.jsx("span",{children:Et(e,r)}),onChange:e=>$("fontFamily",Ft(e,r)),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:v})}),l.jsx(Ua,{label:u("font_size"),children:l.jsx(t.AutoComplete,{className:"input-width ee-settings-input-affix",value:A,options:yl.map(e=>({value:String(e),label:`${e}px`})),onChange:e=>T(String(e??"")),onSelect:e=>R(e),filterOption:!1,getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:l.jsx(t.Input,{addonAfter:"px",onFocus:e=>e?.target?.select?.(),onBlur:()=>R(A),onPressEnter:e=>{R(A),e.currentTarget.blur()},onKeyDown:e=>{if("ArrowUp"!==e.key&&"ArrowDown"!==e.key)return;e.preventDefault();const t="ArrowUp"===e.key?1:-1,n=fl(A,1,999,14)+t;R(n)}})})}),l.jsx(Ua,{label:u("line_height"),children:l.jsx(t.Input,{className:"input-width ee-settings-input-affix",addonAfter:"px",value:L,onChange:e=>B(e.target.value.replace(/[^\d]/g,"")),onFocus:e=>e?.target?.select?.(),onBlur:M,onPressEnter:e=>{M(),e.currentTarget.blur()}})}),l.jsx(Ua,{label:u("letter_spacing"),children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix",addonAfter:"px",min:-20,max:100,step:.1,value:k,onFocus:e=>e?.target?.select?.(),onChange:e=>{const t=null==e||Number.isNaN(Number(e))?0:Number(e);h("letterSpacing")(`${t}px`)}})})]})})(),l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:u("spacing")||"Spacing"}),l.jsx(Ua,{label:u("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:m(a.data.styles,"paddingTop"),paddingRight:m(a.data.styles,"paddingRight"),paddingLeft:m(a.data.styles,"paddingLeft"),paddingBottom:m(a.data.styles,"paddingBottom")},setPadding:p})})]})]})};function vl(e){if(null==e)return!0;const t=String(e).trim().toLowerCase();return""===t||"transparent"===t||"rgba(0, 0, 0, 0)"===t}function wl(e,t){const n=(e=>e?.brandContext?.brand_color??"#111111")(t);if(!e||"object"!=typeof e)return n;for(const t of["desktop","mobile"]){const n=e[t]?.backgroundColor;if(!vl(n))return n}for(const t of["desktop","mobile"]){const n=e[t]?.borderColor;if(!vl(n))return n}return n}function jl(e,t,n){"solid"===t?(e.borderWidth=0,e.borderStyle="solid",e.borderColor=n,e.backgroundColor=n,e.color=function(e){const t=String(e??"").trim().replace(/^#/,"");if(3!==t.length&&6!==t.length)return"#ffffff";const n=(e=>3===e.length?e.split("").map(e=>e+e).join(""):e)(t),o=parseInt(n.slice(0,2),16),a=parseInt(n.slice(2,4),16),l=parseInt(n.slice(4,6),16);return[o,a,l].every(e=>Number.isFinite(e))&&(.299*o+.587*a+.114*l)/255>.62?"#171717":"#ffffff"}(n),e.textDecoration="none"):"outline"===t?(e.borderWidth=2,e.borderStyle="solid",e.borderColor=n,e.backgroundColor="transparent",e.color=n,e.textDecoration="none"):"ghost"===t?(e.borderWidth=0,e.borderStyle="none",e.borderColor="transparent",e.backgroundColor="transparent",e.color=n,e.textDecoration="none"):"underline"===t&&(e.borderWidth=0,e.borderStyle="none",e.borderColor="transparent",e.backgroundColor="transparent",e.color=n,e.textDecoration="underline")}const Sl=()=>{const{currentItem:a,previewMode:i,templateData:r}=e.useContext(ge),[s,c]=e.useState(""),{t:d}=So(),{containerBlock:u,containerType:m,contentIndex:p}=hl(),h=u?.columnProducts?.[p]??null,b=e.useMemo(()=>({columnIndex:p,columnProduct:h}),[p,h]),y=e.useMemo(()=>Mt(r),[r]),_=["header","footer","discount","product"].includes(m),{findStyleItem:f,colorChange:x,paddingChange:k,inputChange:v,updateItemStyles:w}=Qa(),{urlOptions:j}=e.useMemo(()=>function(e,t,n={}){const o="product"===e?vt:kt;return{labelOptions:xt.map(({variableKey:e,labelKey:o})=>({value:Je(e),labelKey:o,pasteValue:yt(t,e,n)})),urlOptions:o.map(({variableKey:e,labelKey:o})=>({value:Je(e),labelKey:o,pasteValue:yt(t,e,n)}))}}(m,r,b),[m,r,b]);return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[(()=>{const{linkURL:e,text:n,labelVariable:o,urlVariable:i}=a.data,u=n?.replace(/<[^>]+>/g,"").trim()??"",m=o||u&&/\{\{\w+\}\}/.test(u),p=o?o.replace(/^\{\{|\}\}$/g,"").trim():u.match(/\{\{(\w+)\}\}/)?.[1]||"CTALabel",h=r&&m?yt(r,p,b):null,y=null==h||String(h).startsWith("{{")?u:h,f=i?i.replace(/^\{\{|\}\}$/g,"").trim():"",x=null!=e?String(e).trim():"",k=x.match(/^\{\{(\w+)\}\}$/),v=i||(!i&&k?x:null)||void 0,S=k&&r?yt(r,k[1],b):null,N=null==S||"string"!=typeof S||String(S).startsWith("{{")?"":String(S).trim(),I=!x&&f&&r?yt(r,f,b):null,A=null==I||"string"!=typeof I||I.startsWith("{{")?"":String(I).trim(),T=N||A||x||"",L=e=>{c((e=>{const t=String(e??"").trim(),n=g(t,!1,{allowMailtoTel:!0});return n?"empty"===n?"Button -> Link URL is empty. Add a destination like 'https://example.com' or 'mailto:support@example.com'.":"blocked_scheme"===n?`Button -> Link URL ('${t}') uses a blocked protocol. Use https://, http://, mailto:, or tel:.`:"duplicate_protocol"===n?`Button -> Link URL ('${t}') repeats the protocol. Keep only one, e.g. 'https://example.com'.`:"missing_hostname_dot"===n?`Button -> Link URL ('${t}') is missing a valid hostname. Use a full domain like 'https://example.com'.`:"invalid_protocol"===n?`Button -> Link URL ('${t}') has an unsupported protocol. Use https://, http://, mailto:, or tel:.`:`Button -> Link URL ('${t}') is invalid. Fix the URL format, for example 'https://example.com'.`:""})(e))};return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("button_action")}),l.jsx(Ua,{label:d("button_text"),children:l.jsx(t.Input,{className:"width-full",value:y,onChange:e=>{const t=e.target.value,n=C(a.data);n.text=t,t&&t.startsWith("{{")||(n.labelVariable=""),w(n)},placeholder:d("button_label_manual")})}),_&&j.length>0?l.jsx(Ua,{label:d("button_url_variable"),children:l.jsx(t.Select,{className:"ee-variable-select width-full",placeholder:d("button_url_manual"),allowClear:!0,value:v,onChange:e=>{const t=C(a.data);if(!e){t.urlVariable="";const e=String(t.linkURL??"").trim();return/^\{\{\w+\}\}$/.test(e)?t.linkURL="":t.linkURL=t.linkURL||"",void w(t)}const n=j.find(t=>t.value===e);t.urlVariable=e;const o=n?n.pasteValue:e;t.linkURL="string"==typeof o?o.replace(/^https?:\/\//,""):"",w(t)},getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:[{value:"",label:d("button_url_manual")},...j.map(e=>({value:e.value,label:d(e.labelKey)}))]})}):null,l.jsx(Ua,{label:d("link_url"),children:l.jsxs(l.Fragment,{children:[l.jsx(t.Input,{className:"width-full",value:T,onChange:e=>{const t=e.target.value,n=C(a.data);n.linkURL=t,t&&t.startsWith("{{")||(n.urlVariable=""),w(n),s&&L(t)},onBlur:e=>L(e.target.value),status:s?"error":"",placeholder:d("link_url_placeholder")}),s?l.jsx("div",{className:"ee-field-error",role:"alert",children:s}):null]})})]})})(),(()=>{const e=f(a.data.styles,"width"),s=f(a.data.styles,"borderRadius"),c="number"==typeof s?s:parseInt(String(s||"").replace("px",""),10)||0,u=a.data.contentStyles?.[i]?.textAlign??"center",m="left"===u||"center"===u||"right"===u?u:"center",p=f(a.data.styles,"color"),g=f(a.data.styles,"fontFamily"),h=f(a.data.styles,"fontSize"),b=f(a.data.styles,"lineHeight"),_=function(e,t){const n=e?.buttonAccentColor;return null==n||vl(n)?wl(e?.styles,t):n}(a.data,r),j=a.data.buttonVariant??"solid",S=a.data.hoverBg??"",N=a.data.hoverColor??"",I=f(a.data.styles,"letterSpacing")??"0em",A=f(a.data.styles,"textTransform")??"none",T=f(a.data.styles,"textDecoration")??"none",L=f(a.data.styles,"borderWidth"),B=f(a.data.styles,"borderStyle")??"solid",$=f(a.data.styles,"borderColor")??"#000000",R=a.data.shadowPreset??"none",M=e=>t=>{const n=C(a.data);n[e]=t,w(n)},P={none:"",sm:"0 1px 2px rgba(0,0,0,0.12)",md:"0 4px 6px rgba(0,0,0,0.18)",lg:"0 10px 20px rgba(0,0,0,0.22)"},F=()=>document.querySelector(".right-settings")||document.body;return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("button_styles")}),l.jsx(Ua,{label:d("button_variant")||"Variant",children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:j,onChange:e=>(e=>{const t=C(a.data);t.buttonVariant=e,t.styles=t.styles??{desktop:{},mobile:{}},t.styles.desktop={...t.styles.desktop??{}},t.styles.mobile={...t.styles.mobile??{}};const n=null==t.buttonAccentColor||vl(t.buttonAccentColor)?wl(t.styles,r):t.buttonAccentColor;t.buttonAccentColor=n,jl(t.styles.desktop,e,n),jl(t.styles.mobile,e,n),w(t)})(e),"aria-label":d("button_variant")||"Variant",items:[{value:"solid",label:"Solid"},{value:"outline",label:"Outline"},{value:"ghost",label:"Ghost"},{value:"underline",label:"Underline"}]})}),l.jsx(Ua,{layout:"toggle",label:d("full_width")||"Full width",children:l.jsx(Ma,{checked:"auto"!==e,onChange:()=>{const t="auto"===e?"100%":"auto";v("width")(t)}})}),"auto"!==e?l.jsx(Ua,{label:d("width"),children:l.jsx(t.Slider,{value:Number(String(e).replace("%","")),onChange:e=>v("width")(e+"%")})}):null,"auto"!==e?l.jsx(Ua,{label:d("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:m,onChange:e=>(e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]||{},textAlign:e},w(t)})(e),"aria-label":d("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0}]})}):null,l.jsx(Ua,{label:d("font_color"),children:l.jsx(Ba,{color:p,setColor:x("color")})}),l.jsx(Ua,{label:d("button_color"),children:l.jsx(Ba,{color:_,setColor:({hex:e})=>{const t=C(a.data);t.styles=t.styles??{desktop:{},mobile:{}},t.styles.desktop={...t.styles.desktop??{}},t.styles.mobile={...t.styles.mobile??{}},t.buttonAccentColor=e;const n=t.buttonVariant??"solid";jl(t.styles.desktop,n,e),jl(t.styles.mobile,n,e),w(t)}})}),l.jsx(Ua,{label:d("hover_bg_color")||"Hover bg",children:l.jsx(Ba,{color:S||_,setColor:e=>M("hoverBg")(e.hex)})}),l.jsx(Ua,{label:d("hover_text_color")||"Hover text",children:l.jsx(Ba,{color:N||p,setColor:e=>M("hoverColor")(e.hex)})}),l.jsx(Ua,{label:d("font_family"),children:l.jsx(t.Select,{className:"width-full",showSearch:!0,optionFilterProp:"label",value:Ft(g??"sans-serif",r),onChange:e=>v("fontFamily")(Ft(e,r)),labelRender:({value:e})=>l.jsx("span",{children:Et(e,r)}),getPopupContainer:F,options:y})}),l.jsx(Ua,{label:d("font_size"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:h,onFocus:e=>e?.target?.select?.(),onChange:v("fontSize")})}),l.jsx(Ua,{label:d("line_height"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"%",value:Number(String(b||"100").replace("%","")),onFocus:e=>e?.target?.select?.(),onChange:e=>v("lineHeight")(`${e??0}%`)})}),l.jsx(Ua,{label:d("letter_spacing")||"Letter spacing",children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix",addonAfter:"em",step:.01,value:parseFloat(String(I).replace("em",""))||0,onFocus:e=>e?.target?.select?.(),onChange:e=>v("letterSpacing")(`${e??0}em`)})}),l.jsx(Ua,{label:d("text_transform")||"Transform",children:l.jsx(t.Select,{className:"width-full",value:A,onChange:v("textTransform"),getPopupContainer:F,options:[{value:"none",label:"None"},{value:"uppercase",label:"UPPERCASE"},{value:"lowercase",label:"lowercase"},{value:"capitalize",label:"Capitalize"}]})}),l.jsx(Ua,{label:d("text_decoration")||"Decoration",children:l.jsx(t.Select,{className:"width-full",value:T,onChange:v("textDecoration"),getPopupContainer:F,options:[{value:"none",label:"None"},{value:"underline",label:"Underline"},{value:"line-through",label:"Strikethrough"}]})}),l.jsx(Ea,{children:d("border")||"Border"}),l.jsx(Ua,{label:d("border_width")||"Width",children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof L?L:parseInt(String(L||"0"),10)||0,onFocus:e=>e?.target?.select?.(),onChange:e=>v("borderWidth")(Number(e)||0)})}),l.jsx(Ua,{label:d("border_style")||"Style",children:l.jsx(t.Select,{className:"width-full",value:B,onChange:v("borderStyle"),getPopupContainer:F,options:[{value:"solid",label:d("solid")},{value:"dashed",label:d("dashed")},{value:"dotted",label:d("dotted")},{value:"none",label:d("video_border_none")}]})}),l.jsx(Ua,{label:d("border_color"),children:l.jsx(Ba,{color:$,setColor:e=>v("borderColor")(e.hex)})}),l.jsx(Ua,{label:d("border_radius"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:c,onFocus:e=>e?.target?.select?.(),onChange:e=>v("borderRadius")(Number(e)||0)})}),l.jsx(Ea,{children:d("shadow")||"Shadow"}),l.jsx(Ua,{label:d("shadow_preset")||"Preset",children:l.jsx(t.Select,{className:"width-full",value:R,onChange:e=>{const t=C(a.data);t.shadowPreset=e,t.styles=t.styles??{},t.styles[i]=t.styles[i]??{},t.styles[i].boxShadow=P[e]??"",w(t)},getPopupContainer:F,options:[{value:"none",label:"None"},{value:"sm",label:"Small"},{value:"md",label:"Medium"},{value:"lg",label:"Large"}]})}),l.jsx(Ea,{children:d("button_padding")}),l.jsx(Ua,{label:d("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:f(a.data.styles,"paddingTop"),paddingRight:f(a.data.styles,"paddingRight"),paddingLeft:f(a.data.styles,"paddingLeft"),paddingBottom:f(a.data.styles,"paddingBottom")},setPadding:k})})]})})(),l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("spacing")}),l.jsx(Ua,{label:d("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:f(a.data.contentStyles,"paddingTop"),paddingRight:f(a.data.contentStyles,"paddingRight"),paddingLeft:f(a.data.contentStyles,"paddingLeft"),paddingBottom:f(a.data.contentStyles,"paddingBottom")},setPadding:e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],...e},w(t)}})})]})]})},Cl=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,colorChange:c,updateItemStyles:d,inputChange:u}=Qa(),m=e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],...e},d(t)};return l.jsx("div",{className:"margin-y-30 ee-settings-block-form",children:(()=>{const e=s(a.data.contentStyles,"textAlign"),p=["left","center","right","justify"].includes(e)?e:"center",g=(e=>{if(null==e)return 100;if("number"==typeof e&&Number.isFinite(e))return Math.min(100,Math.max(0,e));const t=String(e).trim();if(/%$/.test(t)){const e=Number(t.replace(/%/,""));return Number.isFinite(e)?Math.min(100,Math.max(0,e)):100}const n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(100,Math.max(0,n)):100})(s(a.data.styles,"width")),h=s(a.data.styles,"borderTopColor"),b=s(a.data.styles,"borderTopWidth"),y=s(a.data.styles,"borderTopStyle"),_=[{label:r("solid"),value:"solid"},{label:r("dotted"),value:"dotted"},{label:r("dashed"),value:"dashed"}];return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:r("divider")}),l.jsx(Ua,{label:r("divider_type"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:y||"solid",onChange:e=>u("borderTopStyle")(e),"aria-label":r("divider_type"),items:_.map(e=>({value:e.value,label:e.label}))})}),l.jsx(Ua,{label:r("height"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof b?b:0,onFocus:e=>e?.target?.select?.(),onChange:e=>u("borderTopWidth")("number"==typeof e?e:0)})}),l.jsx(Ua,{label:r("divider_color"),children:l.jsx(Ba,{color:h,setColor:c("borderTopColor")})}),l.jsx(Ua,{label:r("width"),children:l.jsx(t.Slider,{min:0,max:100,value:g,tooltip:{formatter:e=>`${e}%`},onChange:e=>u("width")(`${e}%`)})}),l.jsx(Ua,{label:r("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:p,onChange:e=>(e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],textAlign:e},d(t)})(e),"aria-label":r("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ea,{children:r("spacing")}),l.jsx(Ua,{label:r("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop"),paddingRight:s(a.data.contentStyles,"paddingRight"),paddingLeft:s(a.data.contentStyles,"paddingLeft"),paddingBottom:s(a.data.contentStyles,"paddingBottom")},setPadding:m})})]})})()})};function Nl(e,t,n,o){const a=Number.parseInt(String(e??""),10);return Number.isNaN(a)?o:Math.min(n,Math.max(t,a))}const Il=()=>{const{currentItem:a}=e.useContext(ge),{t:i}=So(),{findStyleItem:r,inputChange:s}=Qa(),c=r(a.data.styles,"height"),d="number"==typeof c?c:parseInt(c,10)||16;return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx(Ea,{children:i("spacer")}),l.jsx(Ua,{label:l.jsxs("span",{className:"flex items-center gap-2",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faArrowsAltV,className:"tag-style-size"}),i("height")]}),children:l.jsx(t.InputNumber,{min:0,max:200,step:1,className:"input-width ee-settings-input-affix",addonAfter:"px",value:d,onFocus:e=>e?.target?.select?.(),onChange:e=>s("height")(Nl(e,0,200,0)),onBlur:e=>s("height")(Nl(e?.target?.value,0,200,0)),onKeyDown:e=>{if("ArrowUp"!==e.key&&"ArrowDown"!==e.key)return;e.preventDefault();const t="ArrowUp"===e.key?1:-1;s("height")(Nl(d+t,0,200,0))}})})]})};function Al(e){if(null==e||""===e)return"400";const t=String(e).trim().toLowerCase();if("normal"===t||"regular"===t)return"400";if("bold"===t)return"700";if("bolder"===t)return"700";if("lighter"===t)return"300";if("light"===t)return"300";const n=Number(t);return Number.isNaN(n)?"400":n<=350?"300":n<=500?"400":n<=650?"600":"700"}const Tl=new Set(["|","•","—","/","·"," "]);function Ll(e){return[...String(e??"")].filter(e=>Tl.has(e)).join("")}const Bl=()=>{const{currentItem:a,previewMode:i,templateData:r}=e.useContext(ge),{t:s}=So(),{findStyleItem:c,updateItemStyles:d,colorChange:u,inputChange:m}=Qa(),{list:p=[],separator:h=" | "}=a.data;e.useLayoutEffect(()=>{const e=a?.data?.separator,t=Ll(String(e??""));if(String(e??"")!==t){const e=C(a.data);e.separator=t,d(e)}},[a?.id,a?.data,d]);const[b,y]=e.useState(!1),[_,f]=e.useState(null),[x,k]=e.useState({}),v=e.useRef(null),w=()=>document.querySelector(".right-settings")||document.body,j=(e,t)=>{const n=C(a.data);n[e]=t,"list"===e&&(n.useNavigationLinks=!1),d(n)},S=(e,t,n)=>{const o=((e,t,n)=>{const o=String(e??"").trim(),a=`Menu item ${t+1}${n?` (${n})`:""} -> URL`,l=g(o,!1,{allowMailtoTel:!0});return l?"empty"===l?`${a} is empty. Add a destination like 'https://example.com'.`:"blocked_scheme"===l?`${a} ('${o}') uses a blocked protocol. Use https://, http://, mailto:, or tel:.`:"duplicate_protocol"===l?`${a} ('${o}') repeats the protocol. Keep one protocol, e.g. 'https://example.com'.`:"missing_hostname_dot"===l?`${a} ('${o}') is missing a valid hostname. Use a full domain like 'https://example.com'.`:"invalid_protocol"===l?`${a} ('${o}') has an unsupported protocol. Use https://, http://, mailto:, or tel:.`:`${a} ('${o}') is invalid. Fix it to a valid URL like 'https://example.com'.`:""})(e,t,n);k(e=>{if(!o&&!e[t])return e;const n={...e};return o?n[t]=o:delete n[t],n})},I=e.useCallback(N(e=>{e.preventDefault();const t=v.current,n=e.target?.closest?.(".social-link-item[data-index]");if(!n||!t?.contains(n))return;const o=Array.from(t.querySelectorAll(".social-link-item[data-index]")).indexOf(n);if(-1===o)return;const a=_,l=C(p);null==a||a===o||l.length<2||([l[o],l[a]]=[l[a],l[o]],f(o),j("list",l))},50),[_]),A=Mt(r),T=Ft(c(a.data.styles,"fontFamily"),r),L=[{label:s("same_tab"),value:"_self"},{label:s("new_tab"),value:"_blank"}],B=a.data.layoutMode??"nav-only",$=Boolean(a.data.showLogo),R=Boolean(a.data.borderBottom),M=a.data.borderBottomColor??"#e5e7eb",P=a.data.borderBottomWidth??1,F=a.data.mobileLayout??"stack",E=a.data.linkGapPx,D="number"==typeof E&&Number.isFinite(E)?E:0,U=Boolean(a.data.linkUnderline),z=[{value:"nav-only",label:s("nav_only")||"Navigation only"},{value:"logo-left",label:s("logo_left")||"Logo left"},{value:"logo-right",label:s("logo_right")||"Logo right"},{value:"stacked",label:s("stacked")||"Stacked"},{value:"logo-only",label:s("logo_only")||"Logo only"}],O=c(a.data.contentStyles,"textAlign"),W=["left","center","right"].includes(O)?O:"center";return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx(Ea,{children:s("menu_layout")||"Menu layout"}),l.jsx(Ua,{label:s("layout_mode")||"Layout mode",children:l.jsx(t.Select,{className:"width-full",value:B,onChange:e=>j("layoutMode",e),getPopupContainer:w,options:z})}),l.jsx(Ua,{label:s("mobile_layout")||"Mobile layout",children:l.jsx(t.Select,{className:"width-full",value:F,onChange:e=>j("mobileLayout",e),getPopupContainer:w,options:[{value:"stack",label:s("stack")||"Stack"},{value:"inline",label:s("inline")||"Inline"}]})}),["logo-left","logo-right","stacked","logo-only"].includes(B)&&l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:s("logo_section")}),l.jsx(Ua,{layout:"toggle",label:s("show_logo"),children:l.jsx(Ma,{checked:$,onChange:e=>j("showLogo",e)})}),$?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:s("logo_url")||"Logo URL",children:l.jsx(t.Input,{className:"width-full",placeholder:"https://...",value:a.data.logoSrc??"",onChange:e=>j("logoSrc",e.target.value)})}),l.jsx(Ua,{label:s("logo_text")||"Logo text",children:l.jsx(t.Input,{className:"width-full",placeholder:s("logo_text_placeholder")||"Brand",value:a.data.logoText??"",onChange:e=>j("logoText",e.target.value)})}),l.jsx(Ua,{label:s("logo_alt")||"Alt text",children:l.jsx(t.Input,{className:"width-full",placeholder:"Logo",value:a.data.logoAlt??"",onChange:e=>j("logoAlt",e.target.value)})}),l.jsx(Ua,{label:s("logo_link")||"Logo link",children:l.jsx(t.Input,{className:"width-full",value:a.data.logoHref??"",onChange:e=>j("logoHref",e.target.value),placeholder:s("link_url_placeholder")||"example.com"})}),l.jsx(Ua,{label:s("logo_max_width"),children:l.jsx(t.InputNumber,{min:20,max:400,className:"input-width ee-settings-input-affix",addonAfter:"px",value:a.data.logoMaxWidth??120,onFocus:e=>e?.target?.select?.(),onChange:e=>j("logoMaxWidth",e??120)})})]}):null]}),l.jsx(Ea,{children:s("menu_items")}),l.jsx("div",{ref:v,onDragOver:I,className:"margin-top-12",children:p.map((e,a)=>l.jsx("div",{"data-index":a,draggable:!0,onDragStart:()=>{y(!0),f(a)},onDragEnd:e=>{e.currentTarget?.classList?.remove("social-link-item-current"),y(!1),f(null)},className:fo("social-link-item","cursor-grab",b&&"social-link-item-drag_start",_===a?"social-link-item-current":"border-transparent"),children:l.jsxs("div",{className:"social-link-item-content ee-menu-item-content",children:[l.jsxs("div",{className:"ee-menu-item-header flex items-center justify-between margin-bottom-8",children:[l.jsxs("div",{className:"flex items-center ee-menu-item-drag-row",children:[l.jsx("span",{className:"social-link-item-drag-handle ee-menu-item-drag-handle","aria-hidden":!0,children:l.jsx(n.FontAwesomeIcon,{icon:o.faGripVertical,className:"social-link-item-drag-handle-icon"})}),l.jsxs("span",{className:"font-semibold",children:[s("menu_item")," ",a+1]})]}),l.jsx("div",{className:"social-link-item-icon social-link-item-icon-slate ee-menu-item-delete",role:"button",tabIndex:0,onClick:()=>j("list",p.filter((e,t)=>t!==a)),onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),j("list",p.filter((e,t)=>t!==a)))},children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash,className:"social-link-item-icon-svg social-link-item-icon-svg-deep"})})]}),l.jsxs("div",{className:"ee-menu-item-fields ee-settings-stack-flat",children:[l.jsx(Ua,{label:s("label"),children:l.jsx(t.Input,{className:"width-full ee-menu-item-input",value:e.label||"",onChange:e=>j("list",p.map((t,n)=>n===a?{...t,label:e.target.value}:t)),placeholder:s("page")||"Page"})}),l.jsxs(Ua,{label:s("url"),children:[l.jsx(t.Input,{className:"width-full ee-menu-item-input",value:e.url||"",status:x[a]?"error":"",onChange:t=>{const n=t.target.value;j("list",p.map((e,t)=>t===a?{...e,url:n}:e)),x[a]&&S(n,a,e.label)},onBlur:t=>S(t.target.value,a,e.label),placeholder:s("link_url_placeholder")||"example.com"}),x[a]?l.jsx("div",{className:"ee-field-error",role:"alert",children:x[a]}):null]}),l.jsx(Ua,{label:s("target"),children:l.jsx(t.Select,{className:"width-full ee-menu-item-input",value:e.target||"_self",onChange:e=>j("list",p.map((t,n)=>n===a?{...t,target:e}:t)),getPopupContainer:w,children:L.map(e=>l.jsx(t.Select.Option,{value:e.value,children:e.label},e.value))})})]})]})},a))}),l.jsxs("button",{type:"button",className:"menu-add-new-item margin-top-12",onClick:()=>j("list",p.concat({label:s("page")||"Page",url:"",target:"_self"})),children:[l.jsx("span",{className:"menu-add-new-item-icon",children:"+"})," ",s("add_new_item")]}),l.jsx(Ea,{className:"margin-top-18",children:s("menu_styles")}),l.jsx(Ua,{label:s("font_family"),children:l.jsx(t.Select,{className:"width-full ee-font-family-select",value:T,showSearch:!0,optionFilterProp:"label",labelRender:({value:e})=>l.jsx("span",{children:Et(e,r)}),onChange:e=>m("fontFamily")(Ft(e,r)),getPopupContainer:w,options:A})}),l.jsx(Ua,{label:s("font_size"),children:l.jsx(t.InputNumber,{min:8,max:72,className:"input-width ee-settings-input-affix",addonAfter:"px",value:c(a.data.styles,"fontSize"),onFocus:e=>e?.target?.select?.(),onChange:m("fontSize")})}),l.jsx(Ua,{label:s("letter_spacing"),children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix",addonAfter:"px",value:c(a.data.styles,"letterSpacing"),onFocus:e=>e?.target?.select?.(),onChange:m("letterSpacing")})}),l.jsx(Ua,{label:s("text_color"),children:l.jsx(Ba,{color:c(a.data.styles,"color"),setColor:u("color")})}),l.jsx(Ua,{label:s("link_color"),children:l.jsx(Ba,{color:c(a.data.styles,"linkColor"),setColor:u("linkColor")})}),l.jsx(Ua,{label:s("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:W,onChange:e=>(e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]??{},textAlign:e},d(t)})(e),"aria-label":s("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ua,{label:s("separator"),hint:s("menu_separator_allowed_hint"),children:l.jsx(t.Input,{className:"width-full ee-menu-separator-input",value:Ll(h),onChange:e=>j("separator",Ll(e.target.value)),placeholder:s("menu_separator_placeholder")})}),l.jsx(Ua,{label:s("menu_link_gap")||"Link spacing",children:l.jsx(t.InputNumber,{min:0,max:96,className:"input-width ee-settings-input-affix",addonAfter:"px",value:D,onFocus:e=>e?.target?.select?.(),onChange:e=>(e=>{const t="number"==typeof e&&Number.isFinite(e)&&e>=0?Math.min(96,e):0,n=C(a.data);n.linkGapPx=t,d(n)})("number"==typeof e?e:0)})}),l.jsx(Ua,{layout:"toggle",label:s("menu_underline_links")||"Underline links",children:l.jsx(Ma,{checked:U,onChange:e=>{const t=C(a.data);t.linkUnderline=!!e,d(t)}})}),l.jsx(Ua,{label:s("font_weight")||"Font weight",children:l.jsx(t.Select,{className:"width-full",value:Al(c(a.data.styles,"fontWeight")),onChange:m("fontWeight"),getPopupContainer:w,options:[{value:"300",label:s("font_weight_light")||"Light"},{value:"400",label:s("font_weight_regular")||"Regular"},{value:"600",label:s("font_weight_semibold")||"Semi-bold"},{value:"700",label:s("font_weight_bold")||"Bold"}]})}),l.jsx(Ua,{label:s("text_transform")||"Text transform",children:l.jsx(t.Select,{className:"width-full",value:c(a.data.styles,"textTransform")??"none",onChange:m("textTransform"),getPopupContainer:w,options:[{value:"none",label:"None"},{value:"uppercase",label:"UPPERCASE"},{value:"capitalize",label:"Capitalize"}]})}),l.jsx(Ea,{children:s("border_bottom")||"Border bottom"}),l.jsx(Ua,{layout:"toggle",label:s("show_border_bottom"),children:l.jsx(Ma,{checked:R,onChange:e=>j("borderBottom",e)})}),R?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:s("border_color")||"Color",children:l.jsx(Ba,{color:M,setColor:({hex:e})=>j("borderBottomColor",e)})}),l.jsx(Ua,{label:s("border_width")||"Width",children:l.jsx(t.InputNumber,{min:1,max:8,className:"input-width ee-settings-input-affix",addonAfter:"px",value:P,onFocus:e=>e?.target?.select?.(),onChange:e=>j("borderBottomWidth",e??1)})})]}):null,l.jsx(Ea,{className:"ee-menu-settings-padding-heading",children:s("padding_settings")}),l.jsx(Ua,{children:l.jsx(Pa,{padding:{paddingTop:c(a.data.contentStyles,"paddingTop"),paddingRight:c(a.data.contentStyles,"paddingRight"),paddingLeft:c(a.data.contentStyles,"paddingLeft"),paddingBottom:c(a.data.contentStyles,"paddingBottom")},setPadding:e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]??{},...e},d(t)}})})]})},$l=()=>{const{currentItem:a,previewMode:i,templateData:r,apiConfig:s,bodySettings:c}=e.useContext(ge),{t:d}=So(),{containerBlock:u,containerType:m,contentIndex:p}=hl(),h=u?.columnProducts?.[p]??null,{findStyleItem:b,inputChange:y,updateItemStyles:_}=Qa(),f=e=>{const t=C(a.data);Object.assign(t,e),_(t)},x=e.useRef(null),[k,v]=e.useState(!1),[w,j]=e.useState(""),[S,N]=e.useState(""),I=e.useMemo(()=>({columnIndex:p,columnProduct:h}),[p,h]),A=e.useMemo(()=>Nt(m,r,I),[m,r,I]),{uploadImageFile:T,isConfigured:L}=ll({imageUploadEndpoint:s?.imageUploadEndpoint,headers:s?.headers||{},companyId:s?.companyId,imageUploadQueryParams:s?.imageUploadQueryParams,imageUploadCompanyField:s?.imageUploadCompanyField}),B=e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],...e},_(t)};return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[(()=>{const{linkURL:e}=a.data,n=It(a.data),o=e=>{N((e=>{const t=String(e??"").trim(),n=g(t,!1,{allowMailtoTel:!0});return n?"empty"===n?"Image -> Link URL is empty. Add a destination like 'https://example.com' or disable link action.":"blocked_scheme"===n?`Image -> Link URL ('${t}') uses a blocked protocol. Use https://, http://, mailto:, or tel:.`:"duplicate_protocol"===n?`Image -> Link URL ('${t}') repeats the protocol. Keep only one protocol, e.g. 'https://example.com'.`:"missing_hostname_dot"===n?`Image -> Link URL ('${t}') is missing a valid hostname. Use a full URL like 'https://example.com'.`:"invalid_protocol"===n?`Image -> Link URL ('${t}') has an unsupported protocol. Use https://, http://, mailto:, or tel:.`:`Image -> Link URL ('${t}') is invalid. Fix the URL format, for example 'https://example.com'.`:""})(e))};return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("image_action")}),l.jsx(Ua,{label:d("action_type"),children:l.jsxs("div",{className:"ee-settings-row ee-padding-link-sides-row",children:[l.jsx("span",{className:fo("link-tag",!n&&"ee-image-link-tag-inactive"),children:d("link")}),l.jsx(Ma,{checked:n,onChange:e=>{const t=C(a);t.data.linkEnabled=Boolean(e),_(t.data)}})]})}),n?l.jsx(Ua,{label:d("link_url"),children:l.jsxs(l.Fragment,{children:[l.jsx(t.Input,{value:e??"",onChange:e=>{const t=e.target.value??"",n=C(a);n.data.linkURL=t,_(n.data),S&&o(t)},onBlur:e=>o(e.target.value),status:S?"error":"",placeholder:d("link_url_placeholder"),className:"width-full"}),S?l.jsx("div",{className:"ee-field-error",role:"alert",children:S}):null]})}):null]})})(),(()=>{const{src:e,alt:i}=a.data,s="string"==typeof e&&/^\{\{\w+\}\}$/.test(e.trim())?String(e).replace(/\{\{|\}\}/g,"").trim():"",c=r&&s?yt(r,s,I):null,u=null==c||String(c).startsWith("{{")?e||"":c,m=e=>{j((e=>{const t=String(e??"").trim();if(/^\{\{\w+\}\}$/.test(t))return"";const n=g(t,!1,{allowMailtoTel:!1});return n?"empty"===n?"Image -> Image URL is empty. Add an image URL like 'https://example.com/image.jpg' or choose a variable.":"blocked_scheme"===n?`Image -> Image URL ('${t}') uses a blocked protocol. Use only http:// or https:// image URLs.`:"duplicate_protocol"===n?`Image -> Image URL ('${t}') repeats the protocol. Keep only one protocol, e.g. 'https://example.com/image.jpg'.`:"missing_hostname_dot"===n?`Image -> Image URL ('${t}') is missing a valid hostname. Use a full URL like 'https://example.com/image.jpg'.`:"invalid_protocol"===n?`Image -> Image URL ('${t}') has an unsupported protocol. Use only http:// or https:// image URLs.`:`Image -> Image URL ('${t}') is invalid. Fix the URL format, for example 'https://example.com/image.jpg'.`:""})(e))},p=e=>t=>{const n=C(a),o=t.target.value;n.data[e]=o,_(n.data),"src"===e&&w&&m(o)},h=e=>{const t=C(a);t.data.src=e,_(t.data)},b=()=>{x.current?.click()};return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("image")}),l.jsx(Ua,{label:d("image_upload"),children:l.jsxs(l.Fragment,{children:[l.jsx("input",{ref:x,type:"file",accept:ol,className:"ee-image-upload-input-hidden",onChange:async e=>{const n=e.target.files?.[0];if(!n)return;const o=al(n);if("type"===o)return t.message.error(d("image_upload_invalid_type")||"Use PNG, JPEG, GIF, SVG, or WebP."),void(e.target.value="");if("size"===o)return t.message.error(d("image_file_too_large")),void(e.target.value="");if(!L)return t.message.error(d("image_upload_not_configured")||"Image upload not configured"),console.warn("[ImageStyleSettings] Image upload endpoint not configured"),void(e.target.value="");v(!0);try{const e=await T(n);e?(h(Zt(e)),t.message.success(d("image_uploaded")||"Image uploaded successfully")):t.message.error(d("image_upload_failed")||"Failed to upload image")}catch(e){console.error("[ImageStyleSettings] Upload error:",e);const n="string"==typeof e?.message&&e.message.trim()?e.message.trim():null;t.message.error(n||d("image_upload_error")||"Error uploading image")}finally{v(!1),e.target.value=""}},disabled:k}),l.jsx(t.Spin,{spinning:k,children:l.jsxs("div",{role:"button",tabIndex:0,className:"ee-image-upload-trigger",onClick:b,onDrop:async e=>{e.preventDefault(),e.stopPropagation();const n=e.dataTransfer?.files?.[0];if(!n)return;const o=al(n);if("type"!==o)if("size"!==o){if(!L)return t.message.error(d("image_upload_not_configured")||"Image upload not configured"),void console.warn("[ImageStyleSettings] Image upload endpoint not configured");v(!0);try{const e=await T(n);e?(h(Zt(e)),t.message.success(d("image_uploaded")||"Image uploaded successfully")):t.message.error(d("image_upload_failed")||"Failed to upload image")}catch(e){console.error("[ImageStyleSettings] Upload error:",e);const n="string"==typeof e?.message&&e.message.trim()?e.message.trim():null;t.message.error(n||d("image_upload_error")||"Error uploading image")}finally{v(!1),x.current.value=""}}else t.message.error(d("image_file_too_large"));else t.message.error(d("image_upload_invalid_type")||"Use PNG, JPEG, GIF, SVG, or WebP.")},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},style:{opacity:k?.6:1,cursor:k?"not-allowed":"pointer"},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCloudUploadAlt,className:"ee-image-upload-icon"}),l.jsx("span",{children:k?d("uploading")||"Uploading...":d("image_upload_click")})]})}),l.jsxs("div",{className:"ee-image-toolbar",children:[l.jsxs("button",{type:"button",className:"ee-image-toolbar-btn",onClick:b,disabled:k,children:[l.jsx(n.FontAwesomeIcon,{icon:o.faSyncAlt}),l.jsx("span",{children:d("replace")||"Replace"})]}),l.jsxs("button",{type:"button",className:"ee-image-toolbar-btn ee-image-toolbar-btn--danger",onClick:()=>f({src:""}),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faTrash}),l.jsx("span",{children:d("delete")||"Delete"})]})]}),l.jsx("div",{className:"ee-image-upload-hint",children:d("image_upload_file_hint")||"PNG, JPEG, GIF, SVG, WebP · max 10 MB"})]})}),A.length>0?l.jsx(Ua,{label:d("image_source_variable"),children:l.jsx(t.Select,{className:"ee-variable-select width-full",placeholder:d("image_source_variable"),allowClear:!0,value:"string"==typeof e&&/^\{\{\w+\}\}$/.test(String(e).trim())?String(e).trim():void 0,onChange:e=>h(e??""),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:A.map(e=>({value:e.value,label:d(e.labelKey)}))})}):null,l.jsx(Ua,{label:d("image_url"),children:l.jsxs(l.Fragment,{children:[l.jsx(t.Input,{className:"width-full",value:u,onChange:p("src"),onBlur:e=>m(e.target.value),status:w?"error":"",placeholder:"https://..."}),w?l.jsx("div",{className:"ee-field-error",role:"alert",children:w}):null]})}),l.jsx(Ua,{label:d("image_alt"),children:l.jsx(t.Input,{className:"width-full",value:i||"",onChange:p("alt"),placeholder:d("image_alt_placeholder")})})]})})(),(()=>{const e=a.data,i=c?.styles?.fontFamily??"sans-serif",s=Boolean(e.textOverlayEnabled),u=e.overlayPosition??"bc",m=Boolean(e.scrimEnabled),p=Boolean(e.textShadowEnabled),g=e.overlayMaxWidth??100,h=e.overlayItemGap??8,b=Array.isArray(e.overlayItems)?e.overlayItems:[],y=[{value:"eyebrow",label:"Eyebrow",defaultSize:11},{value:"h1",label:"H1",defaultSize:32},{value:"h2",label:"H2",defaultSize:24},{value:"h3",label:"H3",defaultSize:18},{value:"subtitle",label:"Subtitle",defaultSize:16},{value:"body",label:"Body",defaultSize:14}],_=(e,t)=>{const n=[...b];n[e]={...n[e],...t},f({overlayItems:n})},x=(e,t)=>{const n=[...b],o="up"===t?e-1:e+1;o<0||o>=n.length||([n[e],n[o]]=[n[o],n[e]],f({overlayItems:n}))},k=(e,t,o,a)=>l.jsx("button",{type:"button",disabled:t,onClick:e,style:{width:22,height:22,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"transparent",border:"1px solid rgba(255,255,255,0.12)",borderRadius:3,cursor:t?"not-allowed":"pointer",color:a?"#f87070":"var(--ee-muted-foreground)",opacity:t?.35:1,padding:0,flexShrink:0},children:l.jsx(n.FontAwesomeIcon,{icon:o,style:{fontSize:9}})});return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:l.jsxs("span",{className:"ee-container-bg-heading-inline",children:[d("image_text_overlay"),l.jsx(t.Tooltip,{title:l.jsxs("div",{children:[l.jsx("p",{style:{marginBottom:8},children:d("image_text_overlay_tip")}),l.jsx("p",{style:{margin:0,opacity:.85},children:d("image_text_overlay_container_tip")})]}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:l.jsx("span",{className:"ee-help-icon ee-container-bg-section-help",tabIndex:0,"aria-label":d("image_text_overlay"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]})}),l.jsx(Ua,{layout:"toggle",label:d("image_text_overlay_enable"),children:l.jsx(Ma,{checked:s,onChange:t=>{if(t&&!e.textOverlayEnabled){const e=b.length>0?b:[{kind:"eyebrow",text:"EYEBROW TEXT",color:"#d8fe91",fontSize:11,fontFamily:i},{kind:"h1",text:"Heading Text",color:"#ffffff",fontSize:32,fontFamily:i},{kind:"body",text:"Body copy goes here.",color:"#ffffff",fontSize:14,fontFamily:i}];f({textOverlayEnabled:!0,overlayItems:e})}else f({textOverlayEnabled:t})}})}),s?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:d("add_overlay_item")||"Add element",children:l.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:y.map(e=>l.jsxs("button",{type:"button",onClick:()=>(e=>{const t=y.find(t=>t.value===e)||y[5],n=[...b,{kind:e,text:"",color:"#ffffff",fontSize:t.defaultSize,fontFamily:i}];f({overlayItems:n})})(e.value),style:{padding:"4px 10px",background:"rgba(255,255,255,0.05)",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,color:"var(--ee-foreground)",cursor:"pointer",fontSize:11,fontFamily:"inherit"},children:["+ ",e.label]},e.value))})}),b.length>0&&l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginBottom:12},children:b.map((e,n)=>l.jsxs("div",{style:{background:"rgba(255,255,255,0.04)",border:"1px solid var(--ee-border)",borderRadius:6,padding:"10px 12px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginBottom:8},children:[k(()=>x(n,"up"),0===n,o.faChevronUp,!1),k(()=>x(n,"down"),n===b.length-1,o.faChevronDown,!1),l.jsx(t.Select,{size:"small",style:{flex:1},value:e.kind||"body",onChange:e=>_(n,{kind:e}),options:y.map(e=>({value:e.value,label:e.label})),getPopupContainer:()=>document.querySelector(".right-settings")||document.body}),k(()=>(e=>{f({overlayItems:b.filter((t,n)=>n!==e)})})(n),!1,o.faTrash,!0)]}),l.jsx(t.Input,{size:"small",value:e.text||"",placeholder:"Text content...",onChange:e=>_(n,{text:e.target.value}),style:{marginBottom:8}}),l.jsxs("div",{style:{marginBottom:8},children:[l.jsx("div",{style:{fontSize:11,color:"var(--ee-muted-foreground)",marginBottom:4},children:d("font_family")}),l.jsx(t.Select,{size:"small",className:"width-full ee-font-family-select",showSearch:!0,optionFilterProp:"label",value:Ft(null!=e.fontFamily&&""!==String(e.fontFamily).trim()?e.fontFamily:i,r),onChange:e=>_(n,{fontFamily:Ft(e,r)}),labelRender:({value:e})=>l.jsx("span",{children:Et(e,r)}),options:Mt(r),getPopupContainer:()=>document.querySelector(".right-settings")||document.body})]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[l.jsx(Ba,{color:e.color||"#ffffff",setColor:({hex:e})=>_(n,{color:e}),fallbackColor:"#ffffff"}),l.jsx(t.InputNumber,{size:"small",min:8,max:96,addonAfter:"px",value:e.fontSize||16,style:{flex:1},onChange:e=>_(n,{fontSize:"number"==typeof e?e:16})})]})]},n))}),l.jsx(Ua,{label:d("item_gap")||"Item gap",children:l.jsx(t.InputNumber,{min:0,max:48,className:"input-width ee-settings-input-affix",addonAfter:"px",value:h,onChange:e=>f({overlayItemGap:"number"==typeof e?e:8})})}),l.jsx(Ua,{label:d("image_overlay_position"),children:l.jsx("div",{className:"ee-image-overlay-position-grid",role:"group","aria-label":d("image_overlay_position"),children:an.map(e=>l.jsx("button",{type:"button",className:fo("ee-image-overlay-position-cell",u===e&&"ee-image-overlay-position-cell-active"),title:d(`image_overlay_pos_${e}`),"aria-pressed":u===e,onClick:()=>f({overlayPosition:e}),children:l.jsx("span",{className:"ee-image-overlay-dot","aria-hidden":!0})},e))})}),l.jsx(Ua,{label:d("overlay_max_width")||"Max width",children:l.jsx(t.InputNumber,{min:20,max:100,className:"input-width ee-settings-input-affix",addonAfter:"%",value:g,onChange:e=>f({overlayMaxWidth:"number"==typeof e?e:100})})}),l.jsx(Ua,{label:d("image_overlay_box_bg"),children:l.jsx(t.Input,{className:"width-full",placeholder:"rgba(0,0,0,0.35)",value:e.overlayBoxBackground??"",onChange:e=>f({overlayBoxBackground:e.target.value})})}),l.jsx(Ua,{label:d("image_overlay_padding"),children:l.jsx(t.InputNumber,{min:0,max:120,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof e.overlayPadding?e.overlayPadding:16,onChange:e=>f({overlayPadding:"number"==typeof e?e:16})})}),l.jsx(Ua,{layout:"toggle",label:d("scrim")||"Scrim",children:l.jsx(Ma,{checked:m,onChange:e=>f({scrimEnabled:e})})}),l.jsx(Ua,{layout:"toggle",label:d("text_shadow")||"Text shadow",children:l.jsx(Ma,{checked:p,onChange:e=>f({textShadowEnabled:e})})})]}):null]})})(),(()=>{const e=b(a.data.styles,"width"),r=b(a.data.styles,"height"),s=b(a.data.styles,"borderRadius"),c="number"==typeof s?s:parseInt(String(s||"").replace("px",""),10)||0,u=b(a.data.contentStyles,"textAlign"),m=Boolean(a.data.fillColumn);return l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:d("layout")}),l.jsx(Ua,{layout:"toggle",label:d("fill_column")||"Fill column",children:l.jsx(Ma,{checked:m,onChange:e=>f({fillColumn:e})})}),l.jsx(Ua,{layout:"toggle",label:d("auto_width"),children:l.jsx(Ma,{checked:"auto"===e,onChange:()=>{const t="auto"===e?"100%":"auto";y("width")(t)}})}),"auto"!==e?l.jsx(Ua,{label:d("width"),children:l.jsx(t.Slider,{value:Number(String(e).replace("%","")),onChange:e=>y("width")(e+"%")})}):null,l.jsx(Ua,{label:d("height")||"Height",children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",placeholder:"auto",value:r&&parseInt(String(r).replace("px",""),10)||void 0,onChange:e=>y("height")(e?`${e}px`:"auto")})}),l.jsx(Ua,{label:d("border_radius"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:c,onFocus:e=>e?.target?.select?.(),onChange:e=>y("borderRadius")(Number(e)||0)})}),l.jsx(Ua,{label:d("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:u||"center",onChange:e=>(e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]||(t.contentStyles[i]={}),t.contentStyles[i]={...t.contentStyles[i],textAlign:e},"desktop"!==i&&(t.contentStyles.desktop||(t.contentStyles.desktop={}),t.contentStyles.desktop={...t.contentStyles.desktop,textAlign:e}),_(t)})(e),"aria-label":d("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ea,{children:d("spacing")}),l.jsx(Ua,{label:d("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:b(a.data.contentStyles,"paddingTop"),paddingRight:b(a.data.contentStyles,"paddingRight"),paddingLeft:b(a.data.contentStyles,"paddingLeft"),paddingBottom:b(a.data.contentStyles,"paddingBottom")},setPadding:B})})]})})()]})},Rl=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,updateItemStyles:c}=Qa(),d=e=>{const t=C(a.data);e(t),c(t)},u=e=>{const t=a.data.videoArea||{},n="desktop"===i?{}:t.desktop||{};return t[i]?.[e]??n[e]},m=e=>d(t=>{t.videoArea||(t.videoArea={desktop:{},mobile:{}}),t.videoArea[i]={...t.videoArea[i]||{},...e}}),p=s(a.data.contentStyles,"textAlign"),g=["left","center","right"].includes(p)?p:"center",h=l.jsxs("span",{className:"ee-container-bg-heading-inline",children:[r("video_url"),l.jsx(t.Tooltip,{title:r("video_export_note"),children:l.jsx("span",{className:"ee-help-icon ee-container-bg-section-help",tabIndex:0,"aria-label":r("video_export_note"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]});return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx(Ea,{children:r("video_tab_display")}),l.jsx(Ua,{label:h,children:l.jsx(t.Input,{className:"width-full",value:a.data.videoUrl??"",onChange:e=>d(t=>{t.videoUrl=e.target.value}),placeholder:"https://www.youtube.com/watch?v=..."})}),l.jsx(Ua,{label:r("video_thumbnail_url"),children:l.jsx(t.Input,{className:"width-full",value:a.data.thumbnailUrl??"",onChange:e=>d(t=>{t.thumbnailUrl=e.target.value}),placeholder:r("video_thumbnail_url_placeholder")})}),l.jsx(Ea,{children:r("video_thumbnail_layout")}),l.jsx(Ua,{label:r("video_width"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix ee-video-dim-field width-full",placeholder:"auto",addonAfter:"px",value:"number"==typeof s(a.data.styles,"width")?s(a.data.styles,"width"):void 0,onChange:e=>d(t=>{t.styles=t.styles||{desktop:{},mobile:{}},t.styles[i]={...t.styles[i]||{},width:null==e||""===e?"auto":e}})})}),l.jsx(Ua,{label:r("video_height"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix ee-video-dim-field width-full",placeholder:"auto",addonAfter:"px",value:"number"==typeof s(a.data.styles,"height")?s(a.data.styles,"height"):void 0,onChange:e=>d(t=>{t.styles=t.styles||{desktop:{},mobile:{}},t.styles[i]={...t.styles[i]||{},height:null==e||""===e?"auto":e}})})}),l.jsx(Ua,{label:r("alignment"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:g,onChange:e=>d(t=>{t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]||{},textAlign:e}}),"aria-label":r("alignment"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ua,{layout:"toggle",label:r("video_fill_column"),children:l.jsx(Ma,{checked:Boolean(s(a.data.styles,"fillColumn")),onChange:e=>d(t=>{t.styles=t.styles||{desktop:{},mobile:{}},t.styles[i]={...t.styles[i]||{},fillColumn:e}})})}),l.jsx(Ua,{layout:"toggle",label:r("video_fill_column_mobile"),children:l.jsx(Ma,{checked:Boolean(s(a.data.styles,"fillColumnMobile")),onChange:e=>d(t=>{t.styles=t.styles||{desktop:{},mobile:{}},t.styles[i]={...t.styles[i]||{},fillColumnMobile:e}})})}),l.jsx(Ea,{children:r("video_area_section")}),l.jsx(Ua,{label:r("label_padding"),children:l.jsx(Pa,{setPadding:e=>d(t=>{t.videoArea||(t.videoArea={desktop:{},mobile:{}}),t.videoArea[i]={...t.videoArea[i]||{},...e}}),padding:{paddingTop:u("paddingTop")??0,paddingBottom:u("paddingBottom")??0,paddingLeft:u("paddingLeft")??0,paddingRight:u("paddingRight")??0}})}),l.jsx(Ua,{label:r("background_color"),children:l.jsx(Ba,{color:"string"==typeof u("backgroundColor")&&u("backgroundColor").replace(/^#/,"")||"transparent",setColor:({hex:e})=>m({backgroundColor:e})})}),l.jsx(Ua,{label:r("divider_type"),children:l.jsxs(t.Select,{className:"width-full",value:u("borderStyle")||"solid",onChange:e=>m({borderStyle:e}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:[l.jsx(t.Select.Option,{value:"none",children:r("video_border_none")}),l.jsx(t.Select.Option,{value:"solid",children:r("solid")}),l.jsx(t.Select.Option,{value:"dashed",children:r("dashed")})]})}),l.jsx(Ua,{label:r("border_width"),children:l.jsx(t.InputNumber,{min:0,className:"input-width ee-settings-input-affix",addonAfter:"px",value:u("borderWidth")??0,onFocus:e=>e?.target?.select?.(),onChange:e=>m({borderWidth:null==e?0:e})})}),l.jsx(Ua,{label:r("border_color"),children:l.jsx(Ba,{color:(u("borderColor")||"#cccccc").replace(/^#/,""),setColor:({hex:e})=>m({borderColor:e})})}),l.jsx(Ea,{children:r("video_block_section")}),l.jsx(Ua,{label:r("label_padding"),children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop")??0,paddingBottom:s(a.data.contentStyles,"paddingBottom")??0,paddingLeft:s(a.data.contentStyles,"paddingLeft")??0,paddingRight:s(a.data.contentStyles,"paddingRight")??0},setPadding:e=>d(t=>{t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]||{},...e}})})}),l.jsx(Ua,{label:r("background_color"),children:l.jsx(Ba,{color:(s(a.data.contentStyles,"backgroundColor")||"").replace(/^#/,"")||"transparent",setColor:({hex:e})=>d(t=>{t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]||{},backgroundColor:e}})})})]})},Ml=()=>{const{currentItem:n}=e.useContext(ge),{t:o}=So(),{findStyleItem:a,cardItemElement:i,updateItemStyles:r}=Qa(),{src:s,alt:c,linkURL:d}=n.data,u=a(n.data.styles,"width")??64,m=a(n.data.styles,"borderRadius"),p="50%"===m?50:parseInt(String(m).replace("px",""),10)||0;return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx("div",{className:"right-setting-block-item-title",children:o("avatar_image")}),i(o("image_url"),l.jsx(t.Input,{value:s,onChange:e=>{const t=C(n.data);t.src=e.target.value??"",r(t)}})),i(o("image_alt"),l.jsx(t.Input,{value:c,onChange:e=>{const t=C(n.data);t.alt=e.target.value??"",r(t)},placeholder:"Avatar"})),i(o("link_url"),l.jsx(t.Input,{value:d,onChange:e=>{const t=C(n.data);t.linkURL=e.target.value??"",r(t)},placeholder:o("link_url_placeholder")})),l.jsx("div",{className:"right-setting-block-item-title margin-top-18",children:o("image_styles")}),i(o("width"),l.jsx(t.InputNumber,{min:16,max:256,value:"number"==typeof u?u:64,onChange:e=>{const t=C(n.data);t.styles.desktop||(t.styles.desktop={}),t.styles.desktop.width=e,r(t)},addonAfter:"px"})),i(o("avatar_border_radius"),l.jsx(t.InputNumber,{min:0,max:50,value:p,onChange:e=>{const t=C(n.data);t.styles.desktop||(t.styles.desktop={}),t.styles.desktop.borderRadius=50===e?"50%":`${e}px`,r(t)},addonAfter:50===p?"%":"px"})),l.jsx("div",{className:"right-setting-block-item-title margin-top-18",children:o("padding_settings")}),l.jsx(Pa,{padding:{paddingTop:a(n.data.contentStyles,"paddingTop"),paddingRight:a(n.data.contentStyles,"paddingRight"),paddingLeft:a(n.data.contentStyles,"paddingLeft"),paddingBottom:a(n.data.contentStyles,"paddingBottom")},setPadding:e=>{const t=C(n.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles.desktop={...t.contentStyles.desktop,...e},r(t)}})]})},Pl="https://s.magecdn.com/social";function Fl(e,t){const n=String(e?.image||"").trim(),o=String(t?.image||"").trim();if(n&&o&&n===o)return!0;const a=String(e?.title||"").trim().toLowerCase(),l=String(t?.title||"").trim().toLowerCase();return Boolean(a&&l&&a===l)}const El={facebook:"social_link_placeholder_facebook",linkedin:"social_link_placeholder_linkedin",instagram:"social_link_placeholder_instagram",tiktok:"social_link_placeholder_tiktok",youtube:"social_link_placeholder_youtube",pinterest:"social_link_placeholder_pinterest"};function Dl(e,t){if(zt(e))return t("social_link_placeholder_x");const n=String(e?.title||"").trim().toLowerCase(),o=El[n];return t(o||"social_link_placeholder_generic")}const Ul=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,updateItemStyles:c}=Qa(),d=a.data.list??[],[u,m]=e.useState(!1),[p,h]=e.useState(null),[b,y]=e.useState({}),_=e.useRef(null),f=[{image:`${Pl}/tc-facebook.svg`,title:"Facebook",linkURL:""},{image:`${Pl}/tc-linkedin.svg`,title:"LinkedIn",linkURL:""},{image:`${Pl}/tc-instagram.svg`,title:"Instagram",linkURL:""},{image:`${Pl}/tc-tiktok.svg`,title:"TikTok",linkURL:""},{image:`${Pl}/tc-x.svg`,title:"X",linkURL:""},{image:`${Pl}/tc-youtube.svg`,title:"YouTube",linkURL:""},{image:`${Pl}/tc-pinterest.svg`,title:"Pinterest",linkURL:""}],x=(e,t)=>{const n=C(a),o=function(e){if(!Array.isArray(e))return e;const t=[];for(const n of e)t.some(e=>Fl(e,n))||t.push(n);return t}(t);n.data={...n.data,[e]:o},n.data.useCompanySocialLinks=!1,c(n.data)},k=(e,t,n)=>{const o=((e,t,n)=>{const o=String(e??"").trim(),a=`Social links -> ${n||`Item ${t+1}`} URL`,l=g(o,!1,{allowMailtoTel:!1});return l?"empty"===l?`${a} is empty. Add a profile URL like 'https://example.com'.`:"blocked_scheme"===l?`${a} ('${o}') uses a blocked protocol. Use only http:// or https:// URLs.`:"duplicate_protocol"===l?`${a} ('${o}') repeats the protocol. Keep one protocol, e.g. 'https://example.com'.`:"missing_hostname_dot"===l?`${a} ('${o}') is missing a valid hostname. Use a full domain like 'https://example.com'.`:"invalid_protocol"===l?`${a} ('${o}') has an unsupported protocol. Use only http:// or https:// URLs.`:`${a} ('${o}') is invalid. Fix it to a valid URL like 'https://example.com'.`:""})(e,t,n);y(e=>{if(!o&&!e[t])return e;const n={...e};return o?n[t]=o:delete n[t],n})},v=e.useCallback(N(e=>{e.preventDefault();const t=_.current,n=e.target?.closest?.(".social-link-item[data-index]");if(!n||!t?.contains(n))return;const o=Array.from(t.querySelectorAll(".social-link-item[data-index]")).indexOf(n);if(-1===o)return;const a=p,l=C(d);a!==o&&([l[o],l[a]]=[l[a],l[o]],h(o),x("list",l))},50),[p]),w=()=>document.querySelector(".right-settings")||document.body,j=s(a.data.contentStyles,"textAlign"),S=["left","center","right","justify"].includes(j)?j:"left",I=s(a.data.contentStyles,"columnGapPx"),A="number"==typeof I&&Number.isFinite(I)&&I>=0?I:8,T=function(e){if(e?.iconSize&&null!=Vt[e.iconSize])return e.iconSize;const t=Number(e?.imageWidth);if(!Number.isFinite(t)||t<=0)return"medium";let n="medium",o=1/0;for(const[e,a]of Object.entries(Vt)){const l=Math.abs(t-a);l<o&&(o=l,n=e)}return n}(a.data),L=Wt(a.data.iconColor??"default"),B=Boolean(a.data.showTextLabel),$=f.filter(e=>!d.some(t=>Fl(t,e)));return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx(Ea,{children:r("icon_styles")}),l.jsx(Ua,{label:r("icon_size"),children:l.jsx(t.Select,{className:"width-full",value:T,onChange:e=>{const t=C(a.data);t.iconSize=e,t.imageWidth=Vt[e]??32,t.iconSizePx=null,c(t)},getPopupContainer:w,options:[{value:"small",label:r("icon_size_small")},{value:"medium",label:r("icon_size_medium")},{value:"large",label:r("icon_size_large")}]})}),l.jsx(Ua,{label:r("icon_color"),children:l.jsx(t.Select,{className:"width-full",value:L,onChange:e=>{const t=Wt(e),n=C(a.data);n.iconColor=t,n.iconColorHex=null,c(n)},getPopupContainer:w,options:[{value:"default",label:r("icon_color_default")},{value:"white",label:r("icon_color_white")},{value:"black",label:r("icon_color_black")},{value:"gray",label:r("icon_color_gray")}]})}),l.jsx(Ua,{layout:"toggle",label:r("show_text_label")||"Show label",children:l.jsx(Ma,{checked:B,onChange:e=>{const t=C(a.data);t.showTextLabel=e,c(t)}})}),l.jsx(Ua,{label:r("social_icon_spacing"),children:l.jsx(t.InputNumber,{min:0,max:96,className:"input-width ee-settings-input-affix",addonAfter:"px",value:A,onFocus:e=>e?.target?.select?.(),onChange:e=>(e=>{const t="number"==typeof e&&Number.isFinite(e)&&e>=0?Math.min(96,e):8,n=C(a.data);n.contentStyles||(n.contentStyles={desktop:{},mobile:{}}),n.contentStyles[i]={...n.contentStyles[i]||{},columnGapPx:t},c(n)})(e)})}),l.jsx(Ua,{label:r("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:S,onChange:e=>(e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],textAlign:e},c(t)})(e),"aria-label":r("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ea,{children:r("social_links")}),l.jsx("div",{ref:_,onDragOver:v,className:"margin-top-12",children:d.map((e,a)=>{const{image:i,title:s,linkURL:c}=e,g=zt(e),y=g?r("social_platform_x"):s,_=g?r("social_platform_x_alt"):s;return l.jsx("div",{"data-index":a,draggable:!0,onDragStart:()=>{m(!0),h(a)},onDragEnd:e=>{e.currentTarget?.classList?.remove("social-link-item-current"),m(!1),h(null)},className:fo("social-link-item","cursor-grab",u&&"social-link-item-drag_start",p===a?"social-link-item-current":"border-transparent"),children:l.jsxs("div",{className:"social-link-item-content",children:[l.jsxs("div",{className:"flex items-center justify-between",children:[l.jsxs("div",{className:"flex items-center",children:[l.jsx("img",{src:i,alt:_,className:"social-link-item-img"}),l.jsxs("div",{className:"social-link-platform-title-wrap",children:[l.jsx("div",{className:"font-semibold",children:y}),g?l.jsx("div",{className:"social-link-platform-former-name",children:r("social_platform_formerly_twitter")}):null]})]}),l.jsxs("div",{className:"flex items-center ee-social-link-item-actions",children:[l.jsx("span",{className:"social-link-item-drag-handle","aria-hidden":!0,children:l.jsx(n.FontAwesomeIcon,{icon:o.faGripVertical,className:"social-link-item-drag-handle-icon"})}),l.jsx("div",{className:"social-link-item-icon social-link-item-icon-slate",role:"button",tabIndex:0,onClick:()=>{x("list",d.filter((e,t)=>t!==a))},onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),x("list",d.filter((e,t)=>t!==a)))},children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash,className:"social-link-item-icon-svg social-link-item-icon-svg-deep"})})]})]}),l.jsxs("div",{className:"margin-top-12 relative",children:[l.jsx(t.Input,{className:"width-full",placeholder:Dl(e,r),value:c||"",status:b[a]?"error":"",onChange:e=>{const t=e.target.value;x("list",d.map((e,n)=>n===a?{...e,linkURL:t}:e)),b[a]&&k(t,a,y)},onBlur:e=>k(e.target.value,a,y)}),b[a]?l.jsx("div",{className:"ee-field-error",role:"alert",children:b[a]}):null]})]})},a)})}),$.length>0?l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:r("add_social_link")}),l.jsx("div",{className:"social-link-add margin-top-12",children:$.map(e=>{const{image:t,title:n}=e,o=zt(e)?r("social_platform_x_alt"):n,a=()=>x("list",d.concat(e));return l.jsx("img",{src:t,alt:o,className:"social-link-add-img",role:"button",tabIndex:0,onClick:a,onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),a())}},t)})})]}):null,l.jsx(Ea,{className:"ee-social-settings-padding-heading",children:r("padding_settings")}),l.jsx(Ua,{children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop"),paddingRight:s(a.data.contentStyles,"paddingRight"),paddingLeft:s(a.data.contentStyles,"paddingLeft"),paddingBottom:s(a.data.contentStyles,"paddingBottom")},setPadding:e=>{const t=C(a.data);t.contentStyles[i]={...t.contentStyles[i],...e},c(t)}})})]})},{TextArea:zl}=t.Input;const Ol=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,updateItemStyles:c}=Qa(),d=e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]??{},...e},c(t)},u=s(a.data.contentStyles,"textAlign"),m=["left","center","right","justify"].includes(u)?u:"center",p=function(e){if(null==e||""===e)return 100;if("number"==typeof e)return Math.min(100,Math.max(10,Math.round(e)));const t=String(e).trim().match(/^(\d+(?:\.\d+)?)%$/);return t?Math.min(100,Math.max(10,Math.round(Number(t[1])))):100}(s(a.data.contentStyles,"width")),g=s(a.data.contentStyles,"backgroundColor"),h=function(e){if(null==e)return 0;if("number"==typeof e&&Number.isFinite(e))return Math.min(48,Math.max(0,Math.round(e)));const t=String(e).trim().replace(/px$/i,""),n=Number.parseFloat(t);return Number.isFinite(n)?Math.min(48,Math.max(0,Math.round(n))):0}(s(a.data.contentStyles,"borderRadius"));return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form ee-raw-html-settings",children:[l.jsx(Ea,{className:"ee-raw-html-heading-row",children:l.jsxs("span",{className:"ee-raw-html-title-left",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCode,className:"ee-raw-html-title-icon","aria-hidden":!0}),l.jsx("span",{children:r("raw_html_block")}),l.jsx(t.Tooltip,{title:r("raw_html_code_hint"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,children:l.jsx("span",{className:"ee-help-icon ee-raw-html-title-help",tabIndex:0,"aria-label":r("raw_html_info_tooltip_aria"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]})}),l.jsx(Ua,{label:r("raw_html_code_label"),children:l.jsx(zl,{className:"ee-raw-html-code-textarea",value:a.data.html??"",onChange:e=>(e=>{const t=C(a.data);t.html=e,c(t)})(e.target.value),autoSize:{minRows:10,maxRows:28},spellCheck:!1})}),l.jsx(Ea,{children:r("raw_html_appearance")}),l.jsx(Ua,{label:r("width"),children:l.jsx(t.Slider,{min:10,max:100,value:p,tooltip:{formatter:e=>`${e}%`},onChange:e=>{d({width:`${e}%`})}})}),l.jsx(Ua,{label:r("align"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:m,onChange:e=>(e=>{d({textAlign:e})})(e),"aria-label":r("align"),items:[{value:"left",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignLeft,className:"tag-style-size"}),iconOnly:!0},{value:"center",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignCenter,className:"tag-style-size"}),iconOnly:!0},{value:"right",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignRight,className:"tag-style-size"}),iconOnly:!0},{value:"justify",label:l.jsx(n.FontAwesomeIcon,{icon:o.faAlignJustify,className:"tag-style-size"}),iconOnly:!0}]})}),l.jsx(Ua,{label:r("border_radius"),children:l.jsx(t.InputNumber,{min:0,max:48,className:"input-width ee-settings-input-affix",addonAfter:"px",value:h,onFocus:e=>e?.target?.select?.(),onChange:e=>(e=>{const t="number"==typeof e&&Number.isFinite(e)?Math.min(48,Math.max(0,Math.round(e))):0;if(0===t){const e=C(a.data);e.contentStyles||(e.contentStyles={desktop:{},mobile:{}});const t={...e.contentStyles[i]??{}};return delete t.borderRadius,e.contentStyles[i]=t,void c(e)}d({borderRadius:t})})("number"==typeof e?e:0)})}),l.jsx(Ua,{label:r("background_color"),children:l.jsxs("div",{className:"ee-raw-html-bg-row",children:[l.jsx(Ba,{color:g,setColor:({hex:e})=>{d({backgroundColor:e})},fallbackColor:"#ffffff"}),null!=g&&""!==String(g).trim()&&"transparent"!==String(g).toLowerCase()?l.jsx(t.Button,{type:"link",size:"small",onClick:()=>{const e=C(a.data),t=e.contentStyles[i]||{},{backgroundColor:n,...o}=t;e.contentStyles[i]=o,c(e)},children:r("raw_html_clear_background")}):null]})}),l.jsx(Ea,{className:"ee-raw-html-settings-padding-heading",children:r("padding_settings")}),l.jsx(Ua,{children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop"),paddingRight:s(a.data.contentStyles,"paddingRight"),paddingLeft:s(a.data.contentStyles,"paddingLeft"),paddingBottom:s(a.data.contentStyles,"paddingBottom")},setPadding:e=>{d(e)}})}),l.jsxs("div",{className:"ee-raw-html-email-warning",role:"note",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faExclamationTriangle,className:"ee-raw-html-email-warning-icon","aria-hidden":!0}),l.jsx("span",{children:r("raw_html_email_client_warning")})]})]})},Wl=[{value:"none",label:"None"},{value:"solid",label:"Solid"},{value:"dashed",label:"Dashed"},{value:"dotted",label:"Dotted"}],Hl=()=>{const{currentItem:a,previewMode:i}=e.useContext(ge),{t:r}=So(),{findStyleItem:s,updateItemStyles:c}=Qa(),d=()=>document.querySelector(".right-settings")||document.body,u=e=>{const t=C(a.data);Object.assign(t,e),c(t)},m=e=>{const t=C(a.data);t.styles||(t.styles={desktop:{},mobile:{}}),t.styles.desktop||(t.styles.desktop={}),Object.assign(t.styles.desktop,e),"desktop"!==i&&(t.styles.mobile||(t.styles.mobile={}),Object.assign(t.styles.mobile,e)),c(t)},p=a.data.rows??3,g=a.data.cols??3,h=Boolean(a.data.headerRow),b=Boolean(a.data.headerCol),y=a.data.selectedCell??null,_=a.data.structureMode??"static",f=s(a.data.styles,"fontSize")??14,x=s(a.data.styles,"color")??"#333333",k=s(a.data.styles,"borderColor")??"#e0e0e0",v=s(a.data.styles,"borderStyle")??"solid",w=s(a.data.styles,"borderWidth")??1,j=s(a.data.styles,"cellPadding")??8,S=s(a.data.styles,"textAlign")??"left",N=s(a.data.styles,"headerBg")??"#f5f5f5",I=s(a.data.styles,"headerColor")??"#333333",A=Boolean(a.data.stripedRows),T=s(a.data.styles,"stripedBg")??"#fafafa",L="number"==typeof g?g:3,B="number"==typeof p?p:3,$=e.useMemo(()=>y&&a.data.cells?a.data.cells[y]??null:null,[y,a.data.cells]),R="image"===$?.type?"image":"text",M=e=>{if(!y)return;const t={...a.data.cells||{}};t[y]={...t[y]||{},...e},u({cells:t})},P=Math.min(B,8),F=Math.min(L,8),E=e.useMemo(()=>{if("string"!=typeof y)return null;const e=y.match(/^(\d+)-(\d+)$/);return e?{row:Number(e[1])+1,col:Number(e[2])+1}:null},[y]),D=e.useMemo(()=>[{value:"left",label:r("table_align_left")},{value:"center",label:r("table_align_center")},{value:"right",label:r("table_align_right")}],[r]);return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form ee-table-settings",children:[l.jsx(Ea,{children:r("table_structure")}),l.jsx(Ua,{label:r("table_structure_mode"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:_,onChange:e=>u({structureMode:e}),"aria-label":r("table_structure_mode"),items:[{value:"static",label:r("table_mode_static")},{value:"dynamic",label:r("table_mode_dynamic")}]})}),"dynamic"===_?l.jsx("div",{className:"ee-table-dynamic-hint",role:"note",children:r("table_dynamic_structure_hint")}):null,l.jsx(Ua,{label:r("rows"),children:l.jsx(t.InputNumber,{min:1,max:20,className:"width-full ee-settings-input-affix ee-table-dimension-input",value:B,onFocus:e=>e?.target?.select?.(),onChange:e=>{const t="number"==typeof e&&Number.isFinite(e)?Math.round(e):null;null!=t&&u({rows:Math.min(20,Math.max(1,t))})}})}),l.jsx(Ua,{label:r("columns"),children:l.jsx(t.InputNumber,{min:1,max:12,className:"width-full ee-settings-input-affix ee-table-dimension-input",value:L,onFocus:e=>e?.target?.select?.(),onChange:e=>{const t="number"==typeof e&&Number.isFinite(e)?Math.round(e):null;null!=t&&u({cols:Math.min(12,Math.max(1,t))})}})}),l.jsxs("div",{className:"ee-table-add-actions",children:[l.jsxs("button",{type:"button",className:"ee-table-add-btn menu-add-new-item",onClick:()=>u({rows:Math.min(20,B+1)}),disabled:B>=20,children:[l.jsx("span",{className:"menu-add-new-item-icon",children:"+"})," ",r("table_add_row")]}),l.jsxs("button",{type:"button",className:"ee-table-add-btn menu-add-new-item",onClick:()=>u({cols:Math.min(12,L+1)}),disabled:L>=12,children:[l.jsx("span",{className:"menu-add-new-item-icon",children:"+"})," ",r("table_add_column")]})]}),l.jsx(Ua,{layout:"toggle",label:r("header_row"),children:l.jsx(Ma,{checked:h,onChange:e=>u({headerRow:e})})}),l.jsx(Ua,{layout:"toggle",label:r("header_column"),children:l.jsx(Ma,{checked:b,onChange:e=>u({headerCol:e})})}),l.jsx(Ea,{className:"margin-top-12",children:r("cell_selector")}),l.jsxs("div",{className:"ee-table-cell-picker-wrap",children:[l.jsx("div",{className:"ee-table-cell-picker-grid",style:{gridTemplateColumns:`repeat(${F}, minmax(0, 1fr))`},children:Array.from({length:P*F}).map((e,t)=>{const n=Math.floor(t/F),o=t%F,i=`${n}-${o}`,r=y===i,s=h&&0===n||b&&0===o;return l.jsxs("button",{type:"button",className:`ee-table-cell-picker-btn${r?" ee-table-cell-picker-btn--selected":""}${s?" ee-table-cell-picker-btn--header":""}`,onClick:()=>{if(r)return void u({selectedCell:null});const e={...a.data.cells||{}};e[i]||(e[i]={type:"text",text:""}),u({selectedCell:i,cells:e})},children:[n+1,",",o+1]},i)})}),B>P||L>F?l.jsx("div",{className:"ee-table-cell-picker-caption",children:r("table_cell_grid_truncated",{rows:P,cols:F})}):null,y&&E?l.jsx("div",{className:"ee-table-selected-label",children:r("table_selected_cell",{row:E.row,col:E.col})}):l.jsx("div",{className:"ee-table-selected-label ee-table-selected-label--muted",children:r("table_select_cell_hint")})]}),y?l.jsxs(l.Fragment,{children:[l.jsx(Ea,{className:"margin-top-12",children:r("cell_content")}),l.jsx(Ua,{label:r("cell_content_type"),children:l.jsx(Ha,{size:"sm",className:"ee-settings-segmented--stretch",value:R,onChange:e=>{M("image"===e?{type:"image",src:"",alt:""}:{type:"text",text:$?.text??""})},"aria-label":r("cell_content_type"),items:[{value:"text",icon:l.jsx(n.FontAwesomeIcon,{icon:o.faFont,className:"tag-style-size"}),label:r("text")},{value:"image",icon:l.jsx(n.FontAwesomeIcon,{icon:o.faImage,className:"tag-style-size"}),label:r("image")}]})}),"text"===R?l.jsx(Ua,{label:r("content"),children:l.jsx(t.Input.TextArea,{className:"ee-table-cell-textarea",rows:4,value:$?.text??"",placeholder:r("table_cell_text_placeholder"),onChange:e=>M({text:e.target.value})})}):l.jsx(Ua,{label:r("image"),children:l.jsx(t.Input,{className:"width-full",value:$?.src??"",placeholder:"https://...",onChange:e=>M({src:e.target.value})})})]}):null,l.jsx(Ea,{className:"margin-top-12",children:r("table_style")}),l.jsx(Ua,{label:r("font_size"),children:l.jsx(t.InputNumber,{min:8,max:48,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof f?f:parseInt(String(f||"14"),10),onFocus:e=>e?.target?.select?.(),onChange:e=>m({fontSize:e??14})})}),l.jsx(Ua,{label:r("text_color"),children:l.jsx(Ba,{color:x,setColor:({hex:e})=>m({color:e})})}),l.jsx(Ua,{label:r("text_align"),children:l.jsx(t.Select,{className:"width-full",value:S,onChange:e=>m({textAlign:e}),getPopupContainer:d,options:D})}),l.jsx(Ua,{label:r("cell_padding"),children:l.jsx(t.InputNumber,{min:0,max:40,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof j?j:parseInt(String(j||"8"),10),onFocus:e=>e?.target?.select?.(),onChange:e=>m({cellPadding:e??8})})}),l.jsx(Ea,{className:"margin-top-12",children:r("border")}),l.jsx(Ua,{label:r("border_style"),children:l.jsx(t.Select,{className:"width-full",value:v,onChange:e=>m({borderStyle:e}),getPopupContainer:d,options:Wl})}),"none"!==v?l.jsxs(l.Fragment,{children:[l.jsx(Ua,{label:r("border_width"),children:l.jsx(t.InputNumber,{min:0,max:10,className:"input-width ee-settings-input-affix",addonAfter:"px",value:"number"==typeof w?w:parseInt(String(w||"1"),10),onFocus:e=>e?.target?.select?.(),onChange:e=>m({borderWidth:e??1})})}),l.jsx(Ua,{label:r("border_color"),children:l.jsx(Ba,{color:k,setColor:({hex:e})=>m({borderColor:e})})})]}):null,l.jsx(Ea,{className:"margin-top-12",children:r("header_style")}),l.jsx(Ua,{label:r("header_background"),children:l.jsx(Ba,{color:N,setColor:({hex:e})=>m({headerBg:e})})}),l.jsx(Ua,{label:r("header_text_color"),children:l.jsx(Ba,{color:I,setColor:({hex:e})=>m({headerColor:e})})}),l.jsx(Ua,{layout:"toggle",label:r("striped_rows"),children:l.jsx(Ma,{checked:A,onChange:e=>u({stripedRows:e})})}),A?l.jsx(Ua,{label:r("stripe_color"),children:l.jsx(Ba,{color:T,setColor:({hex:e})=>m({stripedBg:e})})}):null,l.jsx(Ea,{className:"ee-table-settings-padding-heading",children:r("padding_settings")}),l.jsx(Ua,{children:l.jsx(Pa,{padding:{paddingTop:s(a.data.contentStyles,"paddingTop"),paddingRight:s(a.data.contentStyles,"paddingRight"),paddingLeft:s(a.data.contentStyles,"paddingLeft"),paddingBottom:s(a.data.contentStyles,"paddingBottom")},setPadding:e=>(e=>{const t=C(a.data);t.contentStyles||(t.contentStyles={desktop:{},mobile:{}}),t.contentStyles[i]={...t.contentStyles[i]??{},...e},c(t)})(e)})})]})},Vl=[{value:10,label:"10px"},{value:11,label:"11px"},{value:12,label:"12px"},{value:13,label:"13px"},{value:14,label:"14px"},{value:16,label:"16px"}],Kl=[{value:"left",label:"Left"},{value:"center",label:"Center"},{value:"right",label:"Right"}],Gl=()=>{const{currentItem:n,setCurrentItem:o}=e.useContext(ge),{t:a}=So(),{cardItemElement:i,findStyleItem:r}=Qa(),s=e=>{const t=C(n.data);Object.assign(t,e),o({...n,data:t})},c=e=>{const t=C(n.data);t.styles||(t.styles={desktop:{},mobile:{}}),t.styles.desktop||(t.styles.desktop={}),Object.assign(t.styles.desktop,e),o({...n,data:t})},d=Boolean(n.data.showBrand??!0),u=Boolean(n.data.showAddress??!0),m=Boolean(n.data.showUnsubscribe??!0),p=Boolean(n.data.showSocial??!1),g=Boolean(n.data.showSecondaryLinks??!1),h=Boolean(n.data.showCopyright??!0),b=n.data.brandName??"",y=n.data.brandTagline??"",_=n.data.address??"",f=n.data.unsubscribeText??"Unsubscribe",x=n.data.unsubscribeUrl??"",k=n.data.copyrightText??"",v=r(n.data.styles,"color")??"#9ca3af",w=r(n.data.styles,"backgroundColor")??"transparent",j=r(n.data.styles,"fontSize")??12,S=r(n.data.styles,"textAlign")??"center",N=r(n.data.styles,"paddingTop")??16,I=r(n.data.styles,"paddingBottom")??16,A=Boolean(n.data.showDivider??!1),T=n.data.dividerColor??"#374151";return l.jsxs("div",{className:"margin-y-30 ee-settings-block-form",children:[l.jsx("div",{className:"right-setting-block-item-title",children:a("footer_sections")||"Footer Sections"}),i(a("show_brand")||"Brand",l.jsx(Ma,{checked:d,onChange:e=>s({showBrand:e})})),d&&l.jsxs(l.Fragment,{children:[i(a("brand_name")||"Brand name",l.jsx(t.Input,{className:"width-full",value:b,placeholder:"Your brand",onChange:e=>s({brandName:e.target.value})})),i(a("brand_tagline")||"Tagline",l.jsx(t.Input,{className:"width-full",value:y,placeholder:"Your tagline",onChange:e=>s({brandTagline:e.target.value})}))]}),i(a("show_address")||"Address",l.jsx(Ma,{checked:u,onChange:e=>s({showAddress:e})})),u&&i(a("address")||"Address text",l.jsx(t.Input.TextArea,{className:"width-full",value:_,rows:2,placeholder:"123 Main St, City, Country",onChange:e=>s({address:e.target.value})})),i(a("show_unsubscribe")||"Unsubscribe link",l.jsx(Ma,{checked:m,onChange:e=>s({showUnsubscribe:e})})),m&&l.jsxs(l.Fragment,{children:[i(a("unsubscribe_text")||"Link text",l.jsx(t.Input,{className:"width-full",value:f,onChange:e=>s({unsubscribeText:e.target.value})})),i(a("unsubscribe_url")||"Unsubscribe URL",l.jsx(t.Input,{className:"width-full",value:x,placeholder:"{{unsubscribe_url}}",onChange:e=>s({unsubscribeUrl:e.target.value})}))]}),i(a("show_social")||"Social icons",l.jsx(Ma,{checked:p,onChange:e=>s({showSocial:e})})),p&&l.jsx("div",{style:{fontSize:12,color:"var(--ee-muted-foreground)",padding:"4px 0 8px"},children:a("social_icons_hint")||"Configure social icons in the block's content settings."}),i(a("show_secondary_links")||"Secondary links",l.jsx(Ma,{checked:g,onChange:e=>s({showSecondaryLinks:e})})),i(a("show_copyright")||"Copyright",l.jsx(Ma,{checked:h,onChange:e=>s({showCopyright:e})})),h&&i(a("copyright_text")||"Copyright text",l.jsx(t.Input,{className:"width-full",value:k,placeholder:`© ${(new Date).getFullYear()} Your Company`,onChange:e=>s({copyrightText:e.target.value})})),l.jsx("div",{className:"right-setting-block-item-title margin-top-12",children:a("footer_style")||"Footer Style"}),i(a("background_color")||"Background",l.jsx(Ba,{color:w,setColor:({hex:e})=>c({backgroundColor:e})})),i(a("text_color")||"Text color",l.jsx(Ba,{color:v,setColor:({hex:e})=>c({color:e})})),i(a("font_size")||"Font size",l.jsx(t.Select,{className:"ee-stack-control",value:"number"==typeof j?j:parseInt(String(j||"12"),10),style:{width:"100%"},onChange:e=>c({fontSize:e}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:Vl})),i(a("text_align")||"Alignment",l.jsx(t.Select,{className:"ee-stack-control",value:S,style:{width:"100%"},onChange:e=>c({textAlign:e}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:Kl})),i(a("padding_top")||"Top padding",l.jsx(t.InputNumber,{min:0,max:80,className:"input-width",addonAfter:"px",value:"number"==typeof N?N:parseInt(String(N||"16"),10),onChange:e=>c({paddingTop:e??16})})),i(a("padding_bottom")||"Bottom padding",l.jsx(t.InputNumber,{min:0,max:80,className:"input-width",addonAfter:"px",value:"number"==typeof I?I:parseInt(String(I||"16"),10),onChange:e=>c({paddingBottom:e??16})})),l.jsx("div",{className:"right-setting-block-item-title margin-top-12",children:a("divider")||"Divider"}),i(a("show_divider")||"Show divider",l.jsx(Ma,{checked:A,onChange:e=>s({showDivider:e})})),A&&i(a("divider_color")||"Divider color",l.jsx(Ba,{color:T,setColor:({hex:e})=>s({dividerColor:e})}))]})},ql=()=>{const{currentItem:t}=e.useContext(ge);return l.jsxs(l.Fragment,{children:["column"===t?.data.key&&l.jsx(pl,{}),"text"===t?.data.key&&l.jsx(kl,{}),"button"===t?.data.key&&l.jsx(Sl,{}),"divider"===t?.data.key&&l.jsx(Cl,{}),"spacer"===t?.data.key&&l.jsx(Il,{}),"menu"===t?.data.key&&l.jsx(Bl,{}),"image"===t?.data.key&&l.jsx($l,{}),"video"===t?.data.key&&l.jsx(Rl,{}),"avatar"===t?.data.key&&l.jsx(Ml,{}),"social_link"===t?.data.key&&l.jsx(Ul,{}),"raw_html"===t?.data.key&&l.jsx(Ol,{}),"table"===t?.data.key&&l.jsx(Hl,{}),"footer"===t?.data.key&&l.jsx(Gl,{})]})},Jl={error:{icon:o.faExclamationCircle,color:"#F87171",bg:"rgba(127, 29, 29, 0.35)",border:"rgba(248, 113, 113, 0.45)"},warning:{icon:o.faExclamationTriangle,color:"#fbbf24",bg:"rgba(251, 191, 36, 0.08)",border:"rgba(251, 191, 36, 0.25)"},info:{icon:o.faInfoCircle,color:"#60a5fa",bg:"rgba(96, 165, 250, 0.08)",border:"rgba(96, 165, 250, 0.25)"}},Yl=e=>{const t={},n=e=>{Array.isArray(e)&&e.forEach(e=>{e&&"object"==typeof e&&("text"===e.key&&"dynamic"===e.contentType&&(e.dynamicPrompt||e.dynamicSelectedContent)&&(t[e.id]={blockId:e.id,key:e.key,type:e.type||"p",prompt:e.dynamicPrompt??"",selectedContent:e.dynamicSelectedContent??"",options:e.dynamicOptions??[],variable:e.dynamicVariable??"",language:"bn-BD"===e.dynamicAiLanguage?"bn-BD":"en"}),Array.isArray(e.children)&&n(e.children))})};return n(e),t},Xl=()=>{const{blockList:t,bodySettings:a,blockMap:i,setCurrentItem:r,setActionType:s,validationMarkers:c,ignoreValidationIssue:d,filterIgnoredValidationIssues:u}=e.useContext(ge),{t:m}=So(),p=e.useMemo(()=>{const e=uo({blockList:t??[],bodySettings:a??null,aiContentRefs:Yl(t??[])});return"function"==typeof u?u(e):e},[t,a,u]),g=p.filter(e=>"error"===e.severity),h=p.filter(e=>"warning"===e.severity),b=p.filter(e=>"info"===e.severity),y=(e,t)=>{const o=Jl[e.severity]||Jl.info,a=`validation_${e.code}`,c=m(a),u=c&&c!==a?c:e.message,p=Boolean(e.blockId&&i?.[e.blockId]);return l.jsxs("div",{style:{padding:10,background:o.bg,border:`1px solid ${o.border}`,borderRadius:4,display:"flex",gap:10,marginBottom:8},children:[l.jsx(n.FontAwesomeIcon,{icon:o.icon,style:{width:14,height:14,color:o.color,flexShrink:0,marginTop:2}}),l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsx("div",{style:{fontSize:12,fontWeight:700,color:o.color,textTransform:"none"},children:e.location||e.code||m(`compliance_severity_${e.severity}`)||e.severity}),l.jsx("div",{style:{fontSize:11,color:"var(--ee-foreground)",marginTop:2,lineHeight:1.5},children:u}),(p||"function"==typeof d)&&l.jsxs("div",{style:{marginTop:6,display:"flex",gap:8},children:[p&&l.jsx("button",{type:"button",onClick:()=>{var t;(t=e.blockId)&&i?.[t]&&(r({id:t,data:i[t],type:"edit"}),s("edit"),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const e="function"==typeof window.CSS?.escape?window.CSS.escape(String(t)):String(t).replace(/([ #;?%&,.+*~':"!^$[\]()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${e}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}))},style:{background:"transparent",border:"1px solid rgba(255,255,255,0.18)",color:"var(--ee-foreground)",padding:"3px 8px",borderRadius:999,fontSize:11,cursor:"pointer",fontFamily:"inherit"},children:m("export_validation_open_block")||"Open block"}),"function"==typeof d&&l.jsx("button",{type:"button",onClick:()=>d(e),style:{background:"transparent",border:"1px solid rgba(255,255,255,0.12)",color:"var(--ee-muted-foreground)",padding:"3px 8px",borderRadius:999,fontSize:11,cursor:"pointer",fontFamily:"inherit"},title:Hn(e),children:m("ignore")})]})]})]},t)},_=0===p.length,f=e.useMemo(()=>{try{return JSON.stringify({blockList:t??[],bodySettings:a??{}}).length}catch{return 0}},[t,a]),x=Math.max(1,Math.round(2*f/1024)),k=Math.min(100,x/200*100),v=x>=102,w=l.jsxs(l.Fragment,{children:[l.jsx(Ea,{children:m("compliance_email_size")||"Email size"}),l.jsxs("div",{style:{padding:"10px 12px",background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.08)",borderRadius:6},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[l.jsx("span",{style:{fontSize:12,color:"#A3A3A3",fontVariantNumeric:"tabular-nums"},children:m("compliance_approx_kb",{n:String(x)})}),l.jsx("span",{style:{fontSize:11,fontWeight:600,color:v?"#f87070":"#C6F065",fontVariantNumeric:"tabular-nums"},children:v?m("compliance_above_clip")||"Above clip threshold":m("compliance_below_clip")||"Below clip threshold"})]}),l.jsxs("div",{style:{position:"relative",height:6,background:"rgba(255,255,255,0.08)",borderRadius:99},children:[l.jsx("div",{style:{position:"absolute",left:0,top:0,height:"100%",width:`${k}%`,background:v?"#f87070":"var(--ee-primary)",borderRadius:99,transition:"width 0.3s ease"}}),l.jsx("div",{style:{position:"absolute",left:"51%",top:-3,bottom:-3,width:1.5,background:"rgba(251,191,36,0.7)",borderRadius:1}})]}),l.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:6},children:l.jsxs("span",{style:{fontSize:10,color:"rgba(251,191,36,0.85)"},children:[102," KB clip"]})})]})]});return l.jsxs("div",{style:{padding:"14px 14px 18px 14px"},children:[l.jsx(Ea,{className:"ee-settings-section-title--flush",children:m("compliance_preflight")||"Pre-flight"}),_?l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:12,background:"rgba(216, 254, 145, 0.08)",border:"1px solid rgba(216, 254, 145, 0.25)",borderRadius:4},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCheckCircle,style:{width:16,height:16,color:"var(--ee-primary)"}}),l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:13,fontWeight:500},children:m("compliance_all_clear_title")}),l.jsx("div",{style:{fontSize:11,color:"var(--ee-muted-foreground)",marginTop:2},children:m("compliance_all_clear_desc")})]})]}):l.jsxs(l.Fragment,{children:[g.length>0&&l.jsxs("div",{style:{marginBottom:12},children:[l.jsxs("div",{className:"export-validation-errors-heading",style:{fontWeight:600,marginBottom:6,fontSize:12},children:[m("export_validation_errors")," (",g.length,")"]}),g.map((e,t)=>y(e,`e-${t}`))]}),h.length>0&&l.jsxs("div",{style:{marginBottom:12},children:[l.jsxs("div",{className:"export-validation-warnings-heading",style:{fontWeight:600,marginBottom:6,fontSize:12},children:[m("export_validation_warnings")," (",h.length,")"]}),h.map((e,t)=>y(e,`w-${t}`))]}),b.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"export-validation-info-heading",style:{fontWeight:600,marginBottom:6,fontSize:12},children:[m("export_validation_info")," (",b.length,")"]}),b.map((e,t)=>y(e,`i-${t}`))]})]}),w]})},Zl=({open:e,onUnlinkInstance:n,onKeepLinked:o,onClose:a})=>{const{t:i}=So(),r=()=>{o?.(),a?.()};return l.jsxs(t.Modal,{className:"ee-modal-dark",title:i("unlink_modal_title")||"Edit universal block",open:e,onCancel:r,footer:[l.jsx(t.Button,{onClick:r,children:i("unlink_modal_keep")||"Keep linked"},"keep"),l.jsx(t.Button,{type:"primary",danger:!0,onClick:()=>{n?.(),a?.()},children:i("unlink_modal_unlink")||"Unlink this copy"},"unlink")],width:440,destroyOnClose:!0,children:[l.jsx("p",{style:{color:"var(--ee-muted-foreground)",marginBottom:8},children:i("unlink_modal_body")||"This block is linked to a universal snippet. Editing it here will affect all uses of this block everywhere."}),l.jsx("p",{style:{color:"var(--ee-muted-foreground)"},children:i("unlink_modal_body2")||"Choose “Unlink this copy” to make an independent copy that only affects this template, or “Keep linked” to edit all instances together."})]})},Ql=({onSaveAsUniversal:a})=>{const{blockMap:i,rootOrder:r,setBlocks:s,currentItem:c,setCurrentItem:d,onSaveBlockAsGlobal:u}=e.useContext(ge),{t:m}=So(),[p,g]=e.useState(!1),[h,b]=e.useState(!1),y=e.useRef(null);e.useEffect(()=>{if(!p)return;const e=e=>{y.current&&!y.current.contains(e.target)&&g(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[p]);const _=c?.id,f=_?i[_]:null;if(!_||!f)return null;const x=()=>g(!1),k="function"==typeof a||"function"==typeof u,v=Boolean(f?.universalBlockId);return l.jsxs(l.Fragment,{children:[l.jsxs("div",{ref:y,className:"ee-block-actions-menu-wrap",onClick:e=>e.stopPropagation(),children:[l.jsx("button",{type:"button",className:"ee-block-actions-trigger",onClick:()=>g(e=>!e),"aria-haspopup":"true","aria-expanded":p,"aria-label":m("more_actions"),title:m("more_actions"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faEllipsisV})}),p&&l.jsxs("div",{className:"ee-block-actions-menu",role:"menu",children:[l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item",onClick:()=>{x();const e=ia(i,r,_);e&&(s(e.nextMap,e.nextRootOrder,"add"),d({id:e.newId,data:e.selectionData,type:"edit"}))},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faCopy}),l.jsx("span",{children:m("layer_duplicate")})]}),k&&l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item",onClick:()=>{x(),"function"==typeof a&&a(f)},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faStar}),l.jsx("span",{children:m("save_as_universal")})]}),v&&l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item",onClick:()=>{x(),b(!0)},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faUnlink}),l.jsx("span",{children:m("unlink_universal")||"Unlink this copy"})]}),l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item",onClick:()=>{x();const e={...f,hidden:!f.hidden};s({...i,[_]:e},r,"edit")},children:[l.jsx(n.FontAwesomeIcon,{icon:f.hidden?o.faEye:o.faEyeSlash}),l.jsx("span",{children:f.hidden?m("layer_show"):m("layer_hide")})]}),l.jsx("div",{className:"ee-block-actions-divider","aria-hidden":!0}),l.jsxs("button",{type:"button",role:"menuitem",className:"ee-block-actions-item ee-block-actions-item-danger",onClick:()=>{x();const e=()=>{const e=da(i,r,_,m);e&&(s(e.nextMap,e.nextRootOrder,"delete"),d(null))};"column"===f.key&&ca(i,_)?t.Modal.confirm({title:m("shortcut_delete_confirm_title"),content:m("shortcut_delete_confirm_desc"),okText:m("confirm"),cancelText:m("cancel"),wrapClassName:"ee-modal-dark",onOk:e}):e()},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faTrash}),l.jsx("span",{children:m("layer_delete")})]})]})]}),l.jsx(Zl,{open:h,onUnlinkInstance:()=>{const e={...f};delete e.universalBlockId,s({...i,[_]:e},r,`edit_${Date.now()}`),d({...c,data:e})},onKeepLinked:()=>{},onClose:()=>b(!1)})]})},ei=({open:n,block:o,onCreate:a,onClose:i})=>{const{t:r}=So(),[s,c]=e.useState("");e.useEffect(()=>{n&&c("")},[n]);const d=()=>{s.trim()&&o&&a({name:s.trim(),block:o})};return l.jsxs(t.Modal,{className:"ee-modal-dark",title:r("universal_save_modal_title"),open:n,onCancel:i,footer:[l.jsx(t.Button,{onClick:i,children:r("cancel")},"cancel"),l.jsx(t.Button,{type:"primary",onClick:d,disabled:!s.trim(),children:r("universal_save_modal_confirm")},"save")],width:420,destroyOnClose:!0,children:[l.jsx("p",{style:{color:"var(--ee-muted-foreground)",marginBottom:12},children:r("universal_save_modal_subtitle")}),l.jsx(t.Input,{autoFocus:!0,value:s,placeholder:r("universal_save_modal_placeholder"),onChange:e=>c(e.target.value),onPressEnter:d})]})},ti="content",ni="styles",oi="compliance",ai=()=>{const{currentItem:a,isDragStart:i,bodySettings:r,setBodySettings:s,setCurrentItem:c,setActionType:d,blockMap:u,rootOrder:m,validationMarkers:p,onSaveBlockAsGlobal:g,templateData:h}=e.useContext(ge),[b,y]=e.useState(null),{t:_}=So(),v=e.useCallback(e=>e&&"object"==typeof e&&"column"===e.key&&e.id&&u[e.id]?P(e.id,u)??e:e,[u]),S=e.useCallback(e=>{y(v(e))},[v]),C=e.useCallback(async({name:e,block:n})=>{try{"function"==typeof g&&await Promise.resolve(g({name:e,block:n})),t.message.success(String(_("universal_save_success")||"").replace("{{name}}",e)||`Saved "${e}" as universal`),y(null)}catch(e){console.error("[EmailEditor] onSaveBlockAsGlobal:",e);const n=_("universal_save_error")||"Could not save universal block",o="string"==typeof e?.message&&e.message.trim()?e.message.trim():"string"==typeof e?e:n;t.message.error(o||n)}},[g,_]);e.useEffect(()=>{const e=e=>{e.detail&&e.detail.block&&y(v(e.detail.block))};return window.addEventListener("ee:canvas-save-universal",e),()=>window.removeEventListener("ee:canvas-save-universal",e)},[v]);const N=e.useMemo(()=>Mt(h),[h]),[I,A]=e.useState(ti),T=e.useRef(null),L=p?Object.values(p).reduce((e,t)=>e+(t?.totalCount||0),0):0,B=e=>{if(!e)return o.faSquare;switch(e.key){case"column":{const t=e.containerType;return"product"===t?o.faCube:"discount"===t?o.faTag:ua(e)===ma?o.faSquare:o.faColumns}case"text":{const t=(e.type||"p").toLowerCase();return/^h[1-6]$/.test(t)?o.faHeading:o.faFont}case"button":return o.faLink;case"image":return o.faImage;case"video":return o.faVideo;case"divider":return o.faGripLines;case"spacer":return o.faArrowsAltV;case"menu":return o.faBars;case"avatar":return o.faUser;case"social_link":return o.faShareAlt;case"raw_html":return o.faCode;case"table":return o.faTable;case"footer":return o.faEnvelopeOpenText;default:return o.faSquare}},$=()=>{if(!a?.id||!u[a.id])return[];const e=[a.id],t=new Set(e);let n=a.id;for(;;){const o=F(u,m,n);if(!o||t.has(o.containerId))break;e.unshift(o.containerId),t.add(o.containerId),n=o.containerId}return e.map(e=>({id:e,data:u[e]})).filter(e=>Boolean(e.data))},R=()=>{let e="Block";const t=a?.data.key;switch(t){case"text":{const t=(a?.data?.type||"p").toLowerCase();e=/^h[1-6]$/.test(t)?_("heading_settings"):_("text_settings");break}case"column":{const t=a?.data?.containerType;if("product"===t){e=_("block_product");break}e=ua(a?.data)===pa?_("settings_title_column_layout"):_("container_settings");break}case"button":e=_("button_settings");break;case"divider":e=_("divider_settings");break;case"spacer":e=_("spacer_settings");break;case"menu":e=_("menu_settings");break;case"image":e=_("image_settings");break;case"video":e=_("video_settings");break;case"avatar":e=_("avatar_settings");break;case"social_link":e=_("social_link_settings");break;case"raw_html":e=_("raw_html_settings");break;case"table":e=_("table_settings");break;case"footer":e=_("footer_settings")}return e},M=e=>t=>{s({...r,styles:{...r.styles,[e]:t.hex}},"set_body_settings")},E=(e,t,n,o)=>l.jsx(Ua,{label:e,children:l.jsx(Ba,{color:t,setColor:n,fallbackColor:o})}),D=()=>{const e=r.styles||{},n=e.headingColor||e.color||"#171717";return l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("type_styles_section")}),l.jsxs("div",{className:"right-panel-styles-section-body ee-settings-stack-flat",children:[l.jsx(Ua,{label:_("body_font_short"),children:l.jsx(t.Select,{className:"input-width",showSearch:!0,optionFilterProp:"label",value:Ft(e.fontFamily,h),onChange:e=>{return t=Ft(e,h),void s({...r,styles:{...r.styles,fontFamily:t}},"set_body_settings");var t},labelRender:({value:e})=>l.jsx("span",{children:Et(e,h)}),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:N.map(e=>({label:e.label,value:e.value}))})}),E(_("body_text_short"),e.color,M("color"),"#171717"),E(_("body_heading_short"),n,M("headingColor"),"#171717"),E(_("body_link_short"),e.linkColor||"#338AF3",M("linkColor"),"#338AF3")]})]})},U=()=>{const e=r.styles||{},n=j(r);return l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("document_section")}),l.jsxs("div",{className:"right-panel-styles-section-body ee-settings-stack-flat",children:[E(_("body_bg_color_short"),e.backgroundColor,M("backgroundColor"),"#F5F5F5"),E(_("body_content_bg_short"),e.contentBg??"#FFFFFF",M("contentBg"),"#FFFFFF"),l.jsx(Ua,{label:_("body_width_label"),children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix ee-body-width-number",addonAfter:"px",min:f,max:x,value:n,onChange:e=>s({...r,contentWidth:e,contentWidthMode:k.CUSTOM_PX},"set_body_settings")})})]})]})},z=()=>{const e=w(r),a=j(r),i=r.styles||{};return l.jsxs(l.Fragment,{children:[l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("email_styles_section")}),l.jsxs("div",{className:"right-panel-styles-section-body ee-settings-stack-flat",children:[E(_("body_bg_color_short"),i.backgroundColor,M("backgroundColor"),"#F5F5F5"),E(_("body_content_bg_short"),i.contentBg??"#FFFFFF",M("contentBg"),"#FFFFFF"),l.jsx(Ua,{label:l.jsxs("span",{children:[_("email_width_mode"),l.jsx(t.Tooltip,{title:_("full_bleed_tooltip"),children:l.jsx("span",{className:"ee-help-icon","aria-label":"Help",children:l.jsx(n.FontAwesomeIcon,{icon:o.faInfoCircle})})})]}),children:l.jsx(t.Select,{className:"input-width ee-width-mode-select",value:e,onChange:e=>s({...r,contentWidthMode:e},"set_body_settings"),getPopupContainer:()=>document.querySelector(".right-settings")||document.body,options:[{value:k.EMAIL_WIDTH,label:_("email_width_default")},{value:k.CUSTOM_PX,label:_("custom_px")},{value:k.FULL_BLEED,label:_("full_bleed")}]})}),l.jsx(Ua,{label:_("custom_width_px"),children:l.jsx(t.InputNumber,{className:"input-width ee-settings-input-affix ee-body-width-number",addonAfter:"px",min:f,max:x,value:a,disabled:e===k.FULL_BLEED,onChange:e=>s({...r,contentWidth:e,contentWidthMode:k.CUSTOM_PX},"set_body_settings")})})]})]}),D(),l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("text_and_headings")}),l.jsx("div",{className:"right-panel-styles-section-body",children:l.jsx(Ua,{label:_("pre_header"),hint:_("pre_header_description"),children:l.jsx(t.Input,{value:r.preHeader,onChange:e=>s({...r,preHeader:e.target.value},"set_body_settings")})})})]}),l.jsxs("section",{className:"right-panel-styles-section",children:[l.jsx("h3",{className:"right-panel-styles-section-title",children:_("mobile_optimization")||"Mobile optimization"}),l.jsxs("div",{className:"right-panel-styles-section-body ee-settings-stack-flat",children:[l.jsxs("div",{className:"ee-settings-row",children:[l.jsx("span",{className:"ee-settings-row-label",children:_("stack_columns_on_mobile")||"Stack columns on mobile"}),l.jsx(Ma,{checked:!1!==r.stackColumnsOnMobile,onChange:e=>s({...r,stackColumnsOnMobile:e},"set_body_settings")})]}),l.jsxs("div",{className:"ee-settings-row",children:[l.jsx("span",{className:"ee-settings-row-label",children:_("scale_font_on_mobile")||"Scale font on mobile"}),l.jsx(Ma,{checked:!1!==r.scaleFontOnMobile,onChange:e=>s({...r,scaleFontOnMobile:e},"set_body_settings")})]})]})]})]})},O="undefined"!=typeof window&&"product-variables"===window.__eeDragSource,W=a&&"edit"===a.type&&(!i||O);e.useLayoutEffect(()=>{if(!W)return;A(ti);const e=T.current;e&&(e.scrollTop=0)},[W,a?.id]);const H=()=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"right-panel-block-settings-header",children:[l.jsx("button",{type:"button",className:"right-panel-back-btn",onClick:()=>c(null),"aria-label":_("right_panel_back"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronLeft})}),l.jsx("span",{className:"ee-block-settings-header-icon","aria-hidden":!0,children:l.jsx(n.FontAwesomeIcon,{icon:B(a?.data)})}),l.jsx("h2",{className:"right-setting-block-title right-panel-block-title-inline",children:R()}),l.jsx(Ql,{onSaveAsUniversal:S})]}),l.jsxs("div",{className:"right-panel-layers-bar",children:[l.jsx("div",{className:"right-panel-layers-header",children:_("layers_panel")}),l.jsx("nav",{className:"right-panel-breadcrumbs-shell","aria-label":_("layers_panel"),children:l.jsx("ol",{className:"right-panel-breadcrumbs-trail",children:$().map((e,t,a)=>{const i=t===a.length-1,r=(e=>{if(!e)return"";switch(e.key){case"column":{const t=e.containerType;if("product"===t)return _("block_product");if("discount"===t)return _("block_discount");const n=ua(e);return _(n===ma?"block_palette_section":n===pa?"block_palette_columns":"container")}case"text":{const t=(e.type||"p").toLowerCase();return/^h[1-6]$/.test(t)?_("heading"):_("text")}case"button":return _("button");case"image":return _("image");case"video":return _("video");case"divider":return _("divider");case"spacer":return _("spacer");case"menu":return _("menu");case"avatar":return _("avatar");case"social_link":return _("social_link");case"raw_html":return _("raw_html");case"table":return _("table");case"footer":return _("block_footer");case"empty":return _("drag_block_here");default:return e.name||"Block"}})(e.data),s=B(e.data);return l.jsxs("li",{className:"right-panel-breadcrumb-item right-panel-breadcrumb-crumb-slot",children:[t>0?l.jsx("span",{className:"right-panel-breadcrumb-sep","aria-hidden":!0,children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronRight})}):null,i?l.jsxs("span",{className:"right-panel-breadcrumb-segment right-panel-breadcrumb-current","aria-current":"page",children:[l.jsx("span",{className:"right-panel-breadcrumb-ancestor-icon right-panel-breadcrumb-current-icon",children:l.jsx(n.FontAwesomeIcon,{icon:s})}),l.jsx("span",{className:"right-panel-breadcrumb-label",children:r})]}):l.jsxs("button",{type:"button",className:"right-panel-breadcrumb-segment right-panel-breadcrumb-ancestor",onClick:(m=e.id,e=>{e.preventDefault(),e.stopPropagation();const t=u[m];t&&(c({id:m,data:t,type:"edit"}),d("edit"))}),children:[l.jsx("span",{className:"right-panel-breadcrumb-ancestor-icon",children:l.jsx(n.FontAwesomeIcon,{icon:s})}),l.jsx("span",{className:"right-panel-breadcrumb-label",children:r})]})]},`${e.id||"layer"}-${t}`);var m})})})]}),l.jsx("div",{className:"right-panel-block-settings-form",children:l.jsx(ql,{})})]});return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"right-settings",onClick:e=>{e.stopPropagation()},children:l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"right-panel-tabs",children:[l.jsx("button",{type:"button",className:"right-panel-tab "+(I===ti?"right-panel-tab-active":""),onClick:()=>A(ti),children:_("content")}),l.jsx("button",{type:"button",className:"right-panel-tab "+(I===ni?"right-panel-tab-active":""),onClick:()=>A(ni),children:_("styles")}),l.jsxs("button",{type:"button",className:"right-panel-tab "+(I===oi?"right-panel-tab-active":""),onClick:()=>A(oi),children:[_("compliance"),L>0&&l.jsx("span",{className:"right-panel-tab-badge","aria-label":_("compliance_tab_badge_label",{count:L>99?"99+":String(L)}),children:L>99?"99+":L})]})]}),l.jsxs("div",{ref:T,className:"right-panel-tab-content default-scrollbar"+(I===ti&&W?" right-panel-tab-content--block-settings":""),children:[I===ti&&(W?H():l.jsxs(l.Fragment,{children:[U(),D(),l.jsx("div",{className:"ee-content-empty-hint",children:_("right_panel_empty_hint")})]})),I===ni&&z(),I===oi&&l.jsx(Xl,{})]})]})}),l.jsx(ei,{open:Boolean(b),block:b,onCreate:C,onClose:()=>y(null)})]})};var li={presets:[{id:"preset_header",presetName:"Header",nameKey:"preset_header",containerType:"none",block:{name:"Container",key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{LogoUrl}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"50%"},mobile:{}}},{name:"Container",key:"column",type:"full",containerType:"none",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Menu",key:"menu",useNavigationLinks:!0,list:[{label:"Link 1",url:"#",target:"_blank"},{label:"Link 2",url:"#",target:"_blank"},{label:"Link 3",url:"#",target:"_blank"}],separator:" | ",contentStyles:{desktop:{paddingTop:25,paddingBottom:15,paddingLeft:5,paddingRight:5,textAlign:"center"},mobile:{}},styles:{desktop:{fontSize:14,fontFamily:"Verdana",color:"#333333",linkColor:"#333333",paddingTop:5,paddingBottom:5,paddingLeft:8,paddingRight:8,letterSpacing:0,fontWeight:"normal"},mobile:{}},isPreset:!0},{name:"Image",key:"image",src:"{{HeroBanner}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}}]}]}]}]}},{id:"navigation_bar",presetName:"Navigation Bar",nameKey:"preset_navigation_bar",containerType:"none",block:{name:"Menu",key:"menu",useNavigationLinks:!0,list:[{label:"Link 1",url:"#",target:"_blank"},{label:"Link 2",url:"#",target:"_blank"},{label:"Link 3",url:"#",target:"_blank"}],separator:" | ",contentStyles:{desktop:{paddingTop:25,paddingBottom:15,paddingLeft:5,paddingRight:5,textAlign:"center"},mobile:{}},styles:{desktop:{fontSize:14,fontFamily:"Verdana",color:"#333333",linkColor:"#333333",paddingTop:5,paddingBottom:5,paddingLeft:8,paddingRight:8,letterSpacing:0,fontWeight:"normal"},mobile:{}},isPreset:!0}},{id:"product_single",nameKey:"preset_product_single",containerType:"product",presetName:"Hero Product",block:{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"main",columnProducts:[{id:"product-1",name:"Abundance Butterfly Diamond Ring",description:"The Maia Diamond Ring features round diamonds set along a delicate gold band, creating a refined and minimalistic look. Its versatile design makes it perfect for everyday wear or for layering with other rings.",image:"https://www.psylish.com/cdn/shop/files/IMG_4632.jpg?v=1773123202&width=1220",link:"https://www.psylish.com",price:2e3,currency:"USD",old_price:null,new_price:null}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:null,paddingBottom:null,paddingLeft:null,paddingRight:null,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: sans-serif"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:null,paddingLeft:12,paddingRight:12,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: sans-serif">{{ProductPriceDisplay}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:null,paddingBottom:6,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Shop Now",type:"link",linkURL:"{{ProductLink}}",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:null,paddingRight:null},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:null,paddingRight:null,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}},{name:"Divider",key:"divider",contentStyles:{desktop:{paddingTop:2,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}}]}]}},{id:"product_two_column",presetName:"Additional Products",nameKey:"preset_product_two_column",containerType:"product",block:{name:"Container",key:"column",type:"1-1",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:12,paddingLeft:6,paddingRight:6,paddingBottom:12,contentBackground:"#fff"},mobile:{}},isPreset:!0,columns:2,columnProducts:[null,null],children:[{name:"Content",key:"content",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:6,paddingRight:3,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"additional",columnProducts:[{id:"product-2",name:"Heartline Diamond Ring",description:"The Sariah Diamond Earrings feature round diamonds in a classic hoop design that curves elegantly around the lobe. Their minimalist silhouette makes them perfect for everyday wear or adding a touch of sparkle to layered look.",image:"https://www.psylish.com/cdn/shop/files/Psylish3.0_15.png?v=1770880382&width=1220",link:"https://www.psylish.com/",price:1e3,currency:"USD",old_price:1200,new_price:1e3}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: Arial"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"Arial",lineHeight:"140%",paddingTop:12,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: Arial">{{ProductPriceDisplay}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"Arial",lineHeight:"140%",paddingTop:2,paddingBottom:2,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Add to Cart",type:"link",linkURL:"{{ProductLink}}",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:0,paddingRight:0,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}}]}]}]},{name:"Content",key:"content",width:"50%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:3,paddingRight:6,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Container",key:"column",type:"full",containerType:"product",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"#fff"},mobile:{}},isPreset:!0,productRole:"additional",columnProducts:[{id:"product-3",name:"Lynx Heart Diamond Ring",description:"The Sariah Diamond Earrings feature round diamonds in a classic hoop design that curves elegantly around the lobe. Their minimalist silhouette makes them perfect for everyday wear or adding a touch of sparkle to layered look.",image:"https://www.psylish.com/cdn/shop/files/Psylish3.0_48.png?v=1770881768&width=1220",link:"https://www.psylish.com/",price:900,currency:"USD",old_price:1200,new_price:900}],children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:null,paddingLeft:null,paddingRight:null,paddingBottom:null,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{ProductImage}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:0,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 20px; font-family: Arial"><p>{{ProductName}}</p></span>',type:"h2",contentType:"static",styles:{desktop:{fontSize:20,fontFamily:"Arial",lineHeight:"140%",paddingTop:12,paddingBottom:0,paddingLeft:0,paddingRight:0,textAlign:"left",fontWeight:"bold"},mobile:{}}},{name:"Text",key:"text",text:'<span style="direction: ltr; font-size: 16px; font-family: Arial">{{ProductPriceDisplay}}<br></span>',type:"p",contentType:"static",styles:{desktop:{fontSize:16,fontFamily:"Arial",lineHeight:"140%",paddingTop:2,paddingBottom:2,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Text",key:"text",text:"<p>{{ProductDescription}}</p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"140%",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0,textAlign:"left"},mobile:{}}},{name:"Button",key:"button",text:"Add to Cart",type:"link",linkURL:"{{ProductLink}}",contentStyles:{desktop:{textAlign:"center",paddingTop:12,paddingBottom:12,paddingLeft:0,paddingRight:0},mobile:{}},styles:{desktop:{width:"100%",fontSize:16,lineHeight:"140%",borderRadius:4,fontFamily:"sans-serif",paddingTop:10,paddingBottom:10,paddingLeft:20,paddingRight:20,backgroundColor:"#263d2d",color:"#fff",display:"inline-block"},mobile:{}}}]}]}]}]}},{id:"preset_discount",presetName:"Discount",nameKey:"preset_discount",containerType:"discount",block:{name:"Container",key:"column",type:"full",containerType:"discount",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#ffa7aa"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Text",key:"text",text:'<div style="text-align: center;"><font face="Arial">Use <b>{{DiscountCode}}</b> for <b>{{DiscountValue}}</b> OFF. Expires on {{ValidUntil}}</font></div>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"sans-serif",lineHeight:"120%",paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}}]}]}},{id:"preset_footer",presetName:"Footer",nameKey:"preset_footer",containerType:"none",block:{name:"Container",key:"column",type:"full",containerType:"none",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},isPreset:!0,children:[{name:"Content",key:"content",width:"100%",styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{name:"Image",key:"image",src:"{{FooterBanner}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"auto"},mobile:{}}},{name:"Image",key:"image",src:"{{LogoUrl}}",alt:"Image",type:"link",linkURL:"",contentStyles:{desktop:{paddingTop:12,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"35%"},mobile:{}}},{name:"Text",key:"text",text:"<p><i><b>{{Tagline}}</b></i></p>",type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}}},{name:"Social Link",key:"social_link",list:[{image:"https://s.magecdn.com/social/tc-facebook.svg",title:"Facebook",linkURL:"facebook.com/psylish"},{image:"https://s.magecdn.com/social/tc-x.svg",title:"X",linkURL:"twitter.com/psylish"},{image:"https://s.magecdn.com/social/tc-instagram.svg",title:"Instagram",linkURL:"instagram.com/psylish"},{image:"https://s.magecdn.com/social/tc-linkedin.svg",title:"LinkedIn",linkURL:"linkedin.com/company/psylish"},{image:"https://s.magecdn.com/social/tc-tiktok.svg",title:"TikTok",linkURL:"www.tiktok.com/@psylish"},{image:"https://s.magecdn.com/social/tc-youtube.svg",title:"YouTube",linkURL:"www.youtube.com/@psylish"}],imageWidth:32,contentStyles:{desktop:{paddingTop:2,paddingBottom:12,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{paddingTop:4,paddingBottom:4,paddingLeft:6,paddingRight:6},mobile:{}},useCompanySocialLinks:!0},{name:"Divider",key:"divider",contentStyles:{desktop:{paddingTop:12,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center"},mobile:{}},styles:{desktop:{width:"100%",borderTopStyle:"solid",borderTopColor:"#ccc",borderTopWidth:1,display:"inline-block",verticalAlign:"middle"},mobile:{}}},{name:"Text",key:"text",text:'<p><a href="{{Website}}" style="color:#263d2d;text-decoration:underline">{{Website}}</a></p>',type:"p",contentType:"static",styles:{desktop:{fontSize:14,fontFamily:"Arial",lineHeight:"120%",paddingTop:2,paddingBottom:2,paddingLeft:12,paddingRight:12,textAlign:"center",color:"#263d2d",textDecoration:"underline"},mobile:{}}}]}]}}]};function ii(e){if(!e||"object"!=typeof e)return e;const t={...e,id:A()};return Array.isArray(t.children)&&(t.children=t.children.map(ii)),Array.isArray(t.columnProducts)&&(t.columnProducts=t.columnProducts.map(e=>e&&"object"==typeof e?{...e}:e)),t}const ri={column:o.faColumns,text:o.faFont,button:o.faMinusSquare,divider:o.faGripLines,spacer:o.faArrowsAltV,menu:o.faBars,image:o.faImage,social_link:o.faShareAltSquare,raw_html:o.faCode,table:o.faTable,video:o.faVideo,product:o.faCube,header:o.faWindowMaximize,footer:o.faWindowMinimize,discount:o.faTag},si={Header:"header",Footer:"footer",Discount:"discount","Navigation Bar":"menu"};function ci(e){const t=si[e];return t&&ri[t]?ri[t]:ri.product}const di=["text","image","button","divider","spacer","social_link","menu","table","video","raw_html"],ui={[ma]:o.faSquare,[pa]:o.faColumns};const mi=({clearStyles:t,openConfigureColumnsModal:a})=>{const{setCurrentItem:i,setIsDragStart:r,setActionType:s,templateData:c,aiEnabled:d=!0}=e.useContext(ge),{blockConfigsList:u}=Fa(),{t:m}=So(),{blockItems:p,layoutItems:g}=function(e,t){const n=[];di.forEach(o=>{const a=e.find(e=>e.key===o);a&&("text"===o&&t?n.push({...a,ai:!0,contentType:"static",dynamicPrompt:"",dynamicSelectedContent:"",dynamicOptions:[],dynamicVariable:"",isPreset:!1}):n.push({...a,isPreset:!1}))});const o=[],a=e.find(e=>"column"===e.key&&e.layoutRole===ma),l=e.find(e=>"column"===e.key&&e.layoutRole===pa);return a&&o.push({...a,isPreset:!1,paletteIcon:ui[ma],opensConfigureModal:!1}),l&&o.push({...l,isPreset:!1,paletteIcon:ui[pa],opensConfigureModal:!0}),{blockItems:n,layoutItems:o}}(u,d),h=li.presets.map(e=>({key:e.id,name:e.presetName,icon:ci(e.presetName),isPreset:!0,getColumn:()=>function(e){const t=li.presets.find(t=>t.id===e);return t?ii(JSON.parse(JSON.stringify(t.block))):null}(e.id)})),b=e=>{e.target.style.outline="",setTimeout(()=>{r(!1),t&&t()},50)},y=e=>t=>{const n=e.isPreset?C(e.getColumn(m,c)):C(e);i({id:null,data:n,type:"add"}),r(!0),t.target.style.outline="1px dashed var(--ee-primary)",s("add")},_=e=>{const t="boolean"==typeof e.opensConfigureModal?e.opensConfigureModal:ua(e)===pa;return l.jsxs("div",{className:"ee-blocks-palette-card",draggable:!0,onDragStart:y(e),onDragEnd:b,onClick:()=>{t&&a()},title:t?`${e.name} — ${m("configure_columns_hint")}`:e.name,children:[l.jsx(n.FontAwesomeIcon,{icon:e.paletteIcon||e.icon||ri[e.key]||o.faFont,className:"ee-blocks-palette-card-icon"}),l.jsx("span",{className:"ee-blocks-palette-card-label",children:e.name}),e.ai&&l.jsxs("span",{className:"ee-blocks-palette-card-ai",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faStar,className:"ee-blocks-palette-card-ai-icon","aria-hidden":!0}),"AI"]})]},`palette-card-${e.key}-${e.layoutRole??"base"}`)};return l.jsxs("div",{className:"ee-blocks-palette",children:[l.jsx("div",{className:"ee-left-rail-section-title",children:m("blocks")}),l.jsx("div",{className:"ee-blocks-palette-grid",children:p.map(_)}),g.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ee-left-rail-section-title",style:{paddingTop:16},children:m("layout")}),l.jsx("div",{className:"ee-blocks-palette-grid",children:g.map(_)})]}),h.length>0&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ee-left-rail-section-title",style:{paddingTop:16},children:m("presets")}),l.jsx("div",{className:"ee-blocks-palette-rows",children:h.map(e=>l.jsxs("div",{className:"ee-blocks-palette-row",draggable:!0,onDragStart:y(e),onDragEnd:b,title:e.name,children:[l.jsx(n.FontAwesomeIcon,{icon:o.faGripVertical,className:"ee-blocks-palette-row-grip"}),l.jsx(n.FontAwesomeIcon,{icon:e.icon,className:"ee-blocks-palette-row-icon"}),l.jsx("span",{className:"ee-blocks-palette-row-label",children:e.name})]},e.key))})]})]})},pi=({clearStyles:a})=>{const{universals:i=[],universalsLoading:r,setCurrentItem:s,setIsDragStart:c,setActionType:d,deleteUniversalEmailBlock:u}=e.useContext(ge),{t:m}=So(),p=e=>t=>{const n=JSON.parse(JSON.stringify(e.block||{}));n&&"object"==typeof n&&(s({id:null,data:n,type:"add"}),c(!0),t.currentTarget.style.outline="1px dashed var(--ee-primary)",d("add"))},g=e=>{e.currentTarget.style.outline="",setTimeout(()=>{c(!1),a&&a()},50)};return l.jsxs("div",{className:"ee-universal-panel",children:[l.jsxs("div",{className:"ee-left-rail-section-title",children:[m("universal_saved_blocks"),r?l.jsx("span",{className:"ee-universal-loading",children:" · …"}):null]}),0===i.length?l.jsxs("div",{className:"ee-universal-empty",children:[m("universal_empty_state_line_1")," ",l.jsx(n.FontAwesomeIcon,{icon:o.faStar,style:{width:10,height:10,color:"var(--ee-primary)",verticalAlign:"middle"}})," ",m("universal_empty_state_line_2")]}):l.jsx("div",{className:"ee-universal-list",children:i.map(e=>{const a=String(e?.block?.containerType||e?.block?.key||"block").replace(/[-_]/g," "),i="none"===a.trim().toLowerCase()?m("block_palette_section"):a;return l.jsxs("div",{className:"ee-universal-item",draggable:!0,onDragStart:p(e),onDragEnd:g,title:e.name,children:[l.jsx(n.FontAwesomeIcon,{icon:o.faGripVertical,className:"ee-blocks-palette-row-grip"}),l.jsx(n.FontAwesomeIcon,{icon:o.faStar,className:"ee-universal-item-icon"}),l.jsxs("div",{className:"ee-universal-item-body",children:[l.jsx("div",{className:"ee-universal-item-name",children:e.name}),l.jsxs("div",{className:"ee-universal-item-meta",children:[i,null!=e.usedIn?` · ${m("universal_used_in_count").replace("{{count}}",String(e.usedIn))}`:""]})]}),"function"==typeof u?l.jsx("button",{type:"button",className:"ee-universal-item-delete","aria-label":m("universal_delete"),title:m("universal_delete"),onMouseDown:e=>e.stopPropagation(),onClick:n=>{n.preventDefault(),n.stopPropagation(),t.Modal.confirm({title:m("universal_delete_confirm_title"),content:m("universal_delete_confirm_body"),okButtonProps:{danger:!0},okText:m("universal_delete_confirm_ok"),cancelText:m("cancel"),wrapClassName:"ee-modal-dark",onOk:async()=>{try{await u(e.resourceId??e.id)}catch(e){throw t.message.error(e?.message||m("universal_save_error")||"Could not delete"),e}}})},children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash,className:"ee-universal-item-delete-icon"})}):null]},e.id)})})]})},gi={column:o.faColumns,text:o.faFont,button:o.faMinusSquare,divider:o.faGripLines,spacer:o.faArrowsAltV,menu:o.faBars,image:o.faImage,video:o.faVideo,social_link:o.faShareAltSquare,raw_html:o.faCode,table:o.faTable,avatar:o.faUser,empty:o.faSquare};function hi(e){return e?"column"===e.key?"product"===e.containerType?o.faCube:"discount"===e.containerType?o.faTag:ua(e)===ma?o.faSquare:o.faColumns:gi[e.key]||o.faSquare:o.faSquare}const bi=()=>{const{blockMap:a,rootOrder:i,setBlocks:r,setCurrentItem:s,setActionType:c,currentItem:d,onSaveBlockAsGlobal:u}=e.useContext(ge),{t:m}=So(),[p,g]=e.useState(null),[h,b]=e.useState(null),y=d?.id||null,_=e=>{e&&a[e]&&(s({id:e,data:a[e],type:"edit"}),c("edit"),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const t="function"==typeof window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/([ #;?%&,.+*~':"!^$[\]()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${t}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}))},f=(e,t)=>{const n=i.indexOf(e);if(-1===n)return;const o=[...i],l="up"===t?n-1:n+1;l<0||l>=o.length||([o[n],o[l]]=[o[l],o[n]],r(a,o,"move"))},x=(e,t)=>{const n=i.indexOf(e);if(-1===n)return;const o=[...i];o.splice(n,1);const l=t>n?t-1:t;o.splice(Math.max(0,Math.min(l,o.length)),0,e),r(a,o,"move")},k=(e,c,d,v,w)=>{if(!e)return null;const j=y===e.id,S=function(e){if(!e)return null;const t=e.text||e.title||e.list&&e.list[0]?.label||e.alt||e.html||"",n=String(t).replace(/<[^>]+>/g,"").trim();return n?n.length>24?`${n.slice(0,24)}…`:n:null}(e),C=function(e,t){if(!e)return"";switch(e.key){case"column":{const n=e.containerType;if("product"===n)return t("block_product");if("discount"===n)return t("block_discount");if("header"===n)return t("block_header");if("footer"===n)return t("block_footer");if("introduction"===n)return t("block_introduction");if("body"===n)return t("block_body");const o=ua(e);return t(o===ma?"block_palette_section":o===pa?"block_palette_columns":"container")}case"text":return t("text");case"button":return t("button");case"image":return t("image");case"video":return t("video");case"divider":return t("divider");case"spacer":return t("spacer");case"menu":return t("menu");case"avatar":return t("avatar");case"social_link":return t("social_link");case"raw_html":return t("raw_html");case"table":return t("table")||"Table";case"empty":return t("drag_block_here");default:return e.name||"Block"}}(e,m),N=!!e.hidden,I=d&&p&&p!==e.id&&h===v;return l.jsxs("div",{children:[I&&l.jsx("div",{className:"ee-layer-drop-indicator","aria-hidden":!0}),l.jsxs("div",{className:fo("ee-layer-row",j&&"ee-layer-row-selected",N&&"ee-layer-row-hidden"),style:{paddingLeft:6+14*c},onClick:t=>{t.stopPropagation(),_(e.id)},onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),t.stopPropagation(),_(e.id))},role:"button",tabIndex:0,draggable:d,onDragStart:t=>{if(d){t.dataTransfer.effectAllowed="move";try{t.dataTransfer.setData("text/plain",e.id)}catch{}g(e.id)}},onDragOver:t=>{if(!d||!p||p===e.id)return;t.preventDefault();const n=t.currentTarget.getBoundingClientRect(),o=t.clientY-n.top<n.height/2;b(o?v:v+1)},onDrop:e=>{if(!d||!p)return;e.preventDefault();x(p,h??v),g(null),b(null)},onDragEnd:()=>{g(null),b(null)},children:[l.jsx(n.FontAwesomeIcon,{icon:hi(e),className:"ee-layer-row-icon"}),l.jsxs("span",{className:"ee-layer-row-label",children:[C,S&&l.jsxs("span",{className:"ee-layer-row-sub",children:["· ",S]})]}),l.jsxs("div",{className:"ee-layer-row-actions",onClick:e=>e.stopPropagation(),children:[d&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"ee-layer-mini-btn",title:m("layer_move_up"),disabled:0===v,onClick:()=>f(e.id,"up"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronUp})}),l.jsx("button",{type:"button",className:"ee-layer-mini-btn",title:m("layer_move_down"),disabled:v===w-1,onClick:()=>f(e.id,"down"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faChevronDown})})]}),l.jsx("button",{type:"button",className:"ee-layer-mini-btn",title:m("layer_duplicate"),onClick:()=>(e=>{const t=ia(a,i,e);t&&(r(t.nextMap,t.nextRootOrder,"add"),s({id:t.newId,data:t.selectionData,type:"edit"}))})(e.id),children:l.jsx(n.FontAwesomeIcon,{icon:o.faCopy})}),d&&"column"===e.key&&"function"==typeof u?l.jsx("button",{type:"button",className:"ee-layer-mini-btn ee-layer-save-universal",title:m("save_as_universal"),"aria-label":m("save_as_universal"),onClick:t=>{t.stopPropagation(),window.dispatchEvent(new CustomEvent("ee:canvas-save-universal",{detail:{block:e}}))},children:l.jsx(n.FontAwesomeIcon,{icon:o.faStar})}):null,l.jsx("button",{type:"button",className:"ee-layer-mini-btn ee-layer-mini-btn-danger",title:m("layer_delete"),onClick:()=>(e=>{const n=a[e];if(!n)return;const o=()=>{const t=da(a,i,e,m);t&&(r(t.nextMap,t.nextRootOrder,"delete"),s(null))};"column"===n.key&&ca(a,e)?t.Modal.confirm({title:m("shortcut_delete_confirm_title"),content:m("shortcut_delete_confirm_desc"),okText:m("confirm"),cancelText:m("cancel"),wrapClassName:"ee-modal-dark",onOk:o}):o()})(e.id),children:l.jsx(n.FontAwesomeIcon,{icon:o.faTrash})})]}),l.jsx("button",{type:"button",className:"ee-layer-mini-btn ee-layer-row-vis",title:m(N?"layer_show":"layer_hide"),onClick:t=>{t.stopPropagation(),(e=>{const t=a[e];if(!t)return;const n={...a,[e]:{...t,hidden:!t.hidden}};r(n,i,"edit")})(e.id)},children:l.jsx(n.FontAwesomeIcon,{icon:N?o.faEyeSlash:o.faEye})})]}),"column"===e.key&&Array.isArray(e.cells)&&e.cells.map((t,n)=>{const o=t.childrenIds||[],i=e.cells.length>1;return l.jsxs("div",{children:[i&&l.jsx("div",{className:"ee-layer-cell-label",style:{paddingLeft:12+14*(c+1)},children:`${m("column")} ${n+1}`}),o.map(e=>{const t=a[e];return t&&"empty"!==t.key?k(t,c+2,!1,0,0):null})]},t.id||n)})]},e.id)};return l.jsxs("div",{className:"ee-layers-panel",onDragOver:e=>{p&&e.preventDefault()},onDrop:e=>{if(!p)return;e.preventDefault();const t=h??i.length;x(p,t),g(null),b(null)},children:[l.jsxs("div",{className:"ee-layers-header",children:[l.jsx("span",{children:m("layers")}),l.jsxs("span",{className:"ee-layers-header-count",children:[i.length," ",1===i.length?m("layer_one"):m("layer_many")]})]}),l.jsxs("button",{type:"button",className:fo("ee-layers-document",!y&&"ee-layers-document-active"),onClick:()=>s(null),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faFile}),l.jsx("span",{children:m("document")})]}),i.map((e,t)=>{const n=a[e];return k(n,1,!0,t,i.length)}),p&&h===i.length&&l.jsx("div",{className:"ee-layer-drop-indicator","aria-hidden":!0})]})},yi=[{key:"full",label:"1 column",desc:"Full-width section"},{key:"1-1",label:"2 columns",desc:"Equal halves"},{key:"1-1-1",label:"3 columns",desc:"Equal thirds"},{key:"1-1-1-1",label:"4 columns",desc:"Equal quarters"},{key:"1-2",label:"1 : 2",desc:"Narrow + wide"},{key:"2-1",label:"2 : 1",desc:"Wide + narrow"},{key:"1-3",label:"1 : 3",desc:"Sidebar + body"},{key:"3-1",label:"3 : 1",desc:"Body + sidebar"},{key:"2-3",label:"2 : 3",desc:"Off-center"},{key:"3-2",label:"3 : 2",desc:"Off-center"},{key:"1-2-1",label:"1 : 2 : 1",desc:"Hero + edges"},{key:"2-1-1",label:"2 : 1 : 1",desc:"Lead + two"},{key:"1-1-2",label:"1 : 1 : 2",desc:"Two + lead"}],_i=[{key:"6-col-equal",label:"6 cols equal",cols:6,parts:[1,1,1,1,1,1]},{key:"12-col-equal",label:"12 cols equal",cols:12,parts:[1,1,1,1,1,1,1,1,1,1,1,1]}],fi=["A","B","C","D"],xi=["A","B","C","D","E","F","G","H","I","J","K","L"],ki=({parts:e,rowCount:t})=>{const n=e.slice(0,Math.min(e.length,12)),o=Math.min(t,4);return l.jsxs("div",{className:"ee-grid-preview-wrap",children:[l.jsx("div",{className:"ee-grid-preview-heading",children:"Live preview"}),Array.from({length:o}).map((e,t)=>l.jsxs("div",{className:"ee-grid-preview-row",children:[l.jsx("div",{className:"ee-grid-preview-row-label",children:fi[t]}),n.map((e,n)=>l.jsxs("div",{className:"ee-grid-preview-cell",style:{flex:e},children:[xi[n],fi[t]]},n))]},t))]})},vi=e=>{const t="full"===e?[1]:e.split("-").map(e=>parseInt(e,10)),n=t.reduce((e,t)=>e+t,0);return l.jsx("div",{className:"ee-layout-preview",children:t.map((e,t)=>l.jsx("span",{className:"ee-layout-preview-cell",style:{flex:e/n}},t))})};function wi(e,t,n){const o=e[t]||e.full,a=e=>e&&"object"==typeof e?{...e,id:A(),...Array.isArray(e.children)?{children:e.children.map(a)}:{}}:e;return{id:A(),name:n("block_palette_columns"),key:"column",type:o.type,containerType:"none",layoutRole:pa,columnLayoutOnly:!0,styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"#fff"},mobile:{}},children:(o.children||[]).map(a)}}const ji=({open:a,onClose:i,columnRootId:r})=>{const{t:s}=So(),{columnsSetting:c}=Fa(),{blockMap:d,rootOrder:u,setBlocks:m,setCurrentItem:p}=e.useContext(ge),[g,h]=e.useState("1-1"),[b,y]=e.useState(1),[_,f]=e.useState(!1),[x,k]=e.useState("6-col-equal");e.useEffect(()=>{a&&(h("1-1"),y(1),f(!1))},[a]);const v=(()=>{if(_){const e=_i.find(e=>e.key===x);return e?e.parts:[1]}return"full"===g?[1]:g.split("-").map(e=>parseInt(e,10))})();return l.jsxs(t.Modal,{className:"ee-modal-dark ee-configure-columns-modal",title:s("configure_columns_title"),open:a,onCancel:i,footer:[l.jsx(t.Button,{onClick:i,children:s("cancel")},"cancel"),l.jsx(t.Button,{type:"primary",onClick:()=>{const e=_?"full":g;let t=d,n=[...u];const o=r&&"column"===t[r]?.key?r:null;let a=null;for(let l=0;l<b;l++){const i=wi(c,e,s);if(_){const e=_i.find(e=>e.key===x);if(e){i.type=e.key;const t=e.cols,n=`${(100/t).toFixed(4)}%`;i.children=Array.from({length:t},(e,t)=>({id:A(),name:s("content"),key:"content",width:n,styles:{key:"column",desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0,contentBackground:"transparent"},mobile:{}},children:[{id:A(),name:s("drag_block_here"),key:"empty",width:"100%",styles:{desktop:{backgroundColor:"transparent",paddingTop:0,paddingLeft:0,paddingRight:0,paddingBottom:0},mobile:{}}}]}))}}if(o&&0===l&&"column"===t[o]?.key){i.id=o,t=H(t,o);const{blockMap:e}=R([i]);t={...t,...e},a=o;continue}const{newBlockMap:r,rootId:d}=K(t,i);d&&(t=r,n=[...n,d],a=d)}m(t,n,"add"),null!=a&&t[a]&&p({id:a,data:t[a],type:"edit"}),i()},children:s("configure_columns_insert")},"insert")],width:660,destroyOnClose:!0,children:[l.jsx("p",{style:{color:"var(--ee-muted-foreground)",marginBottom:14},children:s("configure_columns_subtitle")}),l.jsxs("div",{className:"ee-layout-tab-group",role:"tablist","aria-label":"Layout type",children:[l.jsx("button",{type:"button",role:"tab","aria-selected":!_,className:fo("ee-layout-tab",!_&&"ee-layout-tab-active"),onClick:()=>f(!1),children:s("standard_layout")||"Standard"}),l.jsx("button",{type:"button",role:"tab","aria-selected":_,className:fo("ee-layout-tab",_&&"ee-layout-tab-active"),onClick:()=>f(!0),children:s("grid_layout")||"6/12 Grid"})]}),_?l.jsx("div",{style:{display:"flex",gap:8},children:_i.map(e=>l.jsxs("button",{type:"button",className:fo("ee-layout-card",x===e.key&&"ee-layout-card-active"),onClick:()=>k(e.key),style:{flex:1},children:[l.jsx("div",{className:"ee-layout-grid-mini-bar",children:e.parts.slice(0,6).map((e,t)=>l.jsx("span",{className:"ee-layout-grid-mini-cell"},t))}),l.jsx("div",{className:"ee-layout-card-label",children:e.label})]},e.key))}):l.jsx("div",{className:"ee-layout-grid",children:yi.filter(e=>c[e.key]).map(e=>l.jsxs("button",{type:"button",className:fo("ee-layout-card",g===e.key&&"ee-layout-card-active"),onClick:()=>h(e.key),children:[vi(e.key),l.jsx("div",{className:"ee-layout-card-label",children:e.label}),l.jsx("div",{className:"ee-layout-card-desc",children:e.desc})]},e.key))}),l.jsx(ki,{parts:v,rowCount:b}),l.jsxs("div",{className:"ee-row-count-row",children:[l.jsx("span",{children:s("configure_columns_row_count")||"Rows to insert:"}),l.jsx(t.Button,{className:"ee-configure-stepper-btn",type:"default",size:"small",icon:l.jsx(n.FontAwesomeIcon,{icon:o.faMinus}),onClick:()=>y(e=>Math.max(1,e-1)),disabled:b<=1}),l.jsx("span",{className:"ee-row-count-value",children:b}),l.jsx(t.Button,{className:"ee-configure-stepper-btn",type:"default",size:"small",icon:l.jsx(n.FontAwesomeIcon,{icon:o.faPlus}),onClick:()=>y(e=>Math.min(4,e+1)),disabled:b>=4})]})]})},Si="blocks",Ci="universal",Ni="layers",Ii=({clearStyles:t})=>{const{t:a}=So(),[i,r]=e.useState(Si),[s,c]=e.useState(!1),[d,u]=e.useState(null);e.useEffect(()=>{const e=e=>{u(e?.detail?.rootId??null),c(!0)};return window.addEventListener(ga,e),()=>window.removeEventListener(ga,e)},[]);const m=[{id:Si,label:a("blocks"),icon:o.faTh},{id:Ci,label:a("universal"),icon:o.faStar},{id:Ni,label:a("layers"),icon:o.faLayerGroup}];return l.jsxs("aside",{className:"ee-left-rail","aria-label":"Editor sidebar",onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[l.jsx("div",{className:"ee-left-rail-tabs",role:"tablist",children:m.map(e=>l.jsxs("button",{type:"button",role:"tab","aria-selected":i===e.id,className:fo("ee-left-rail-tab",i===e.id&&"ee-left-rail-tab-active"),onClick:()=>r(e.id),children:[l.jsx(n.FontAwesomeIcon,{icon:e.icon}),l.jsx("span",{children:e.label})]},e.id))}),l.jsxs("div",{className:"ee-left-rail-body",children:[i===Si&&l.jsx(mi,{clearStyles:t,openConfigureColumnsModal:()=>{u(null),c(!0)}}),i===Ci&&l.jsx(pi,{clearStyles:t}),i===Ni&&l.jsx(bi,{})]}),l.jsx(ji,{open:s,columnRootId:d,onClose:()=>{c(!1),u(null)}})]})},Ai=({open:n,issues:o,onClose:a,onExportAnyway:i})=>{const{setCurrentItem:r,setActionType:s,blockMap:c}=e.useContext(ge),{t:d}=So(),u=e=>{var t;e?.blockId&&((t=e.blockId)&&c?.[t]&&(r({id:t,data:c[t],type:"edit"}),s("edit"),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const e="function"==typeof window.CSS?.escape?window.CSS.escape(String(t)):String(t).replace(/([ #;?%&,.+*~':"!^$[\]()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${e}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),1)&&a())},m=(e,t)=>{const n=Boolean(e?.blockId),o=`validation_${e.code}`,a=d(o),i=a&&a!==o?a:e.message;return l.jsx("li",{className:"export-validation-issue-item",children:l.jsxs("button",{type:"button",className:"export-validation-issue-btn "+(n?"is-clickable":""),onClick:()=>u(e),disabled:!n,children:[l.jsx("span",{className:"export-validation-issue-copy",children:i}),n&&l.jsx("span",{className:"export-validation-issue-action",children:d("export_validation_open_block")||"Open block"})]})},t)},p=(o||[]).filter(e=>"error"===e.severity),g=(o||[]).filter(e=>"warning"===e.severity),h=(o||[]).filter(e=>"info"===e.severity);return l.jsxs(t.Modal,{className:"ee-modal-dark",title:d("export_validation_title"),open:n,onCancel:a,footer:[l.jsx(t.Button,{onClick:a,children:d("cancel")},"cancel"),l.jsx(t.Button,{type:"primary",onClick:i,children:d("export_anyway")},"export")],width:520,destroyOnClose:!0,children:[l.jsx("p",{style:{marginBottom:12},children:d("export_validation_issues_found")}),l.jsxs("div",{style:{maxHeight:360,overflowY:"auto"},children:[p.length>0&&l.jsxs("div",{style:{marginBottom:12},children:[l.jsxs("div",{className:"export-validation-errors-heading",style:{fontWeight:600,marginBottom:6},children:[d("export_validation_errors")," (",p.length,")"]}),l.jsx("ul",{className:"export-validation-issue-list",children:p.map((e,t)=>m(e,`e-${t}`))})]}),g.length>0&&l.jsxs("div",{style:{marginBottom:12},children:[l.jsxs("div",{className:"export-validation-warnings-heading",style:{fontWeight:600,marginBottom:6},children:[d("export_validation_warnings")," (",g.length,")"]}),l.jsx("ul",{className:"export-validation-issue-list",children:g.map((e,t)=>m(e,`w-${t}`))})]}),h.length>0&&l.jsxs("div",{children:[l.jsxs("div",{className:"export-validation-info-heading",style:{fontWeight:600,marginBottom:6},children:[d("export_validation_info")," (",h.length,")"]}),l.jsx("ul",{className:"export-validation-issue-list",children:h.map((e,t)=>m(e,`i-${t}`))})]})]})]})},{Option:Ti}=t.Select,Li=[{value:"none",label:"No payload"},{value:"profile",label:"Profile data"},{value:"event",label:"Event data"}],Bi=({open:n,onClose:o,onSend:a,templateName:i})=>{const{t:r}=So(),[s,c]=e.useState([]),[d,u]=e.useState(""),[m,p]=e.useState("none"),[g,h]=e.useState(!0),[b,y]=e.useState(!1),_=e=>{const t=String(e||"").trim();if(!t)return;const n=t.split(/[\s,;]+/).filter(Boolean);c(e=>{const t=new Set(e);return n.forEach(e=>t.add(e)),Array.from(t)}),u("")},f=e=>{c(t=>t.filter(t=>t!==e))},x=()=>{c([]),u(""),p("none"),h(!0),y(!1),o?.()};return l.jsx(t.Modal,{className:"ee-modal-dark",title:r("send_test_title")||"Send test email",open:n,onCancel:x,footer:[l.jsx(t.Button,{onClick:x,disabled:b,children:r("cancel")},"cancel"),l.jsx(t.Button,{type:"primary",onClick:async()=>{if(0!==s.length){y(!0);try{await Promise.resolve(a?.({recipients:s,payloadType:m,testPrefix:g,subjectPrefix:g?"[TEST] ":"",name:i||"Untitled template"})),x()}finally{y(!1)}}},loading:b,disabled:0===s.length,children:r("send_test_send")||"Send test"},"send")],width:480,destroyOnClose:!0,children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:6,fontSize:13,fontWeight:500},children:r("send_test_recipients")||"Recipients"}),l.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,minHeight:36,padding:"4px 8px",border:"1px solid var(--ee-border, #374151)",borderRadius:6,backgroundColor:"var(--ee-surface, #1a1a1a)",cursor:"text"},onClick:()=>document.getElementById("ee-send-test-input")?.focus(),children:[s.map(e=>l.jsx(t.Tag,{closable:!0,onClose:()=>f(e),style:{margin:2},children:e},e)),l.jsx(t.Input,{id:"ee-send-test-input",bordered:!1,value:d,style:{flex:1,minWidth:160,padding:0},placeholder:0===s.length?r("send_test_recipients_placeholder")||"name@example.com, another@example.com":"",onChange:e=>u(e.target.value),onKeyDown:e=>{"Enter"!==e.key&&","!==e.key&&" "!==e.key&&"Tab"!==e.key||(e.preventDefault(),_(d)),"Backspace"===e.key&&!d&&s.length>0&&f(s[s.length-1])},onBlur:()=>{d.trim()&&_(d)}})]}),l.jsx("div",{style:{fontSize:11,color:"var(--ee-muted-foreground)",marginTop:4},children:r("send_test_recipients_hint")||"Press Enter or comma to add each address."})]}),l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:6,fontSize:13,fontWeight:500},children:r("send_test_payload")||"Payload context"}),l.jsx(t.Select,{style:{width:"100%"},value:m,onChange:p,getPopupContainer:()=>document.querySelector(".email-editor")||document.body,children:Li.map(e=>l.jsx(Ti,{value:e.value,children:r(`send_test_payload_${e.value}`)||e.label},e.value))})]}),l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"10px 12px",borderRadius:6,backgroundColor:"var(--ee-surface, #1a1a1a)",border:"1px solid var(--ee-border, #374151)"},children:[l.jsxs("div",{children:[l.jsx("div",{style:{fontSize:13,fontWeight:500},children:r("send_test_prefix_label")||"[TEST] prefix"}),l.jsx("div",{style:{fontSize:12,color:"var(--ee-muted-foreground)"},children:r("send_test_prefix_hint")||"Prepends [TEST] to the subject line."})]}),l.jsx(t.Switch,{checked:g,onChange:h})]})]})})},$i=({templateName:a,onTemplateNameChange:i,onBack:r,onPreview:s,onSendTest:c,onSaveTemplate:d,onShowShortcuts:u,onSendTestIntent:m,onSaveTemplateIntent:p,saveStatusDetail:g,onExit:h,hideOverflowExportActions:b=!1})=>{const{previewMode:y,setPreviewMode:_,canUndo:f,canRedo:x,undo:k,redo:v,blockList:w,bodySettings:j,templateData:S,saveState:C,highContrastEditor:N,setHighContrastEditor:I,filterIgnoredValidationIssues:A}=e.useContext(ge),{t:T}=So(),[L,B]=e.useState(!1),[$,R]=e.useState(a||""),[M,P]=e.useState(!1),[F,E]=e.useState(!1),[D,U]=e.useState([]),[z,O]=e.useState(null),[W,H]=e.useState(!1),[V,K]=e.useState(!1),[G,q]=e.useState(!1),[J,Y]=e.useState(""),[X,Z]=e.useState(!1),[Q,ee]=e.useState("desktop"),te=e.useRef(null);e.useEffect(()=>{X&&ee("desktop")},[X]);const ne=e.useMemo(()=>{if(!X)return{html:"",error:null};try{return{html:Sn({bodySettings:j,blockList:w,templateData:S??void 0})??"",error:null}}catch(e){return console.error("[EmailEditor] HTML preview generation failed:",e),{html:"",error:T("html_email_preview_error")}}},[X,j,w,S,T]);e.useEffect(()=>{R(a||"")},[a]),e.useEffect(()=>{if(!M)return;const e=e=>{te.current&&!te.current.contains(e.target)&&P(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[M]);const oe=()=>{B(!1),"function"==typeof i&&$!==a&&i($)},ae=e.useCallback(e=>{const t={},n=(e,o=[])=>{Array.isArray(e)&&e.forEach(e=>{if(!e||"object"!=typeof e)return;const a={blockId:e.id??null,key:e.key??null,containerType:"column"===e.key?e.containerType??"none":null},l=[...o,a];if("text"===e.key&&"dynamic"===e.contentType){const n="string"==typeof e.dynamicPrompt?e.dynamicPrompt.trim():"",o="string"==typeof e.dynamicSelectedContent?e.dynamicSelectedContent.trim():"";if(!n&&!o)return;t[e.id]={blockId:e.id,path:l,key:e.key,type:e.type||"p",selectedContent:o,options:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[],prompt:n,variable:e.dynamicVariable??"",language:"bn-BD"===e.dynamicAiLanguage?"bn-BD":"en"}}Array.isArray(e.children)&&n(e.children,l)})};return n(e,[]),t},[]),le=e.useCallback(e=>Array.isArray(e)?e.map(e=>{if(!e||"object"!=typeof e)return e;const{dynamicPrompt:t,dynamicOptions:n,dynamicSelectedContent:o,dynamicVariable:a,dynamicAiLanguage:l,staticTextBeforeAi:i,children:r,...s}=e;return{...s,children:le(r)}}):e,[]),ie=e.useCallback(()=>({blockList:le(w??[]),bodySettings:j??null,aiContentRefs:ae(w??[]),language:Vn(w??[])}),[w,j,ae,le]),re=()=>{const e=ie(),t=JSON.stringify(e,null,2),n=new Blob([t],{type:"application/json"}),o=document.createElement("a");o.download=`${a||"email-template"}.json`,o.href=URL.createObjectURL(n),o.click()},se=()=>{const e=Sn({bodySettings:j,blockList:w,templateData:S});if(null==e)return;const t=new Blob([e],{type:"text/html"}),n=document.createElement("a");n.download=`${a||"email-template"}.html`,n.href=URL.createObjectURL(t),n.click()},ce=async e=>{H(!0);try{const t=ie();let n=uo({blockList:t.blockList??[],bodySettings:t.bodySettings??null,aiContentRefs:t.aiContentRefs??{}});const o=await yo(t.blockList??[]);if(n=[...n,...o],"function"==typeof A&&(n=A(n)),0===n.length)return void("html"===e?se():re());U(n),O(e),E(!0)}finally{H(!1)}},de=()=>{E(!1),U([]),O(null)},ue="function"==typeof m||"function"==typeof c,me="function"==typeof p||"function"==typeof d,pe="function"==typeof m,he="function"==typeof p;return l.jsxs("header",{className:"ee-topbar",children:["function"==typeof r&&"function"!=typeof h&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:"ee-topbar-back",onClick:r,"aria-label":T("topbar_back_to_templates"),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faChevronLeft}),l.jsx("span",{children:T("topbar_back_to_templates")})]}),l.jsx("div",{className:"ee-topbar-divider","aria-hidden":!0})]}),l.jsxs("div",{className:"ee-topbar-breadcrumb",children:[l.jsx(n.FontAwesomeIcon,{icon:o.faEnvelope}),l.jsx("span",{children:T("topbar_breadcrumb_email")}),l.jsx(n.FontAwesomeIcon,{icon:o.faChevronRight,className:"ee-topbar-breadcrumb-sep"}),L?l.jsx("input",{autoFocus:!0,className:"ee-topbar-name-input",value:$,onChange:e=>R(e.target.value),onBlur:oe,onKeyDown:e=>{"Enter"===e.key?oe():"Escape"===e.key&&(R(a||""),B(!1))},"aria-label":T("topbar_rename_template")}):l.jsx("button",{type:"button",className:"ee-topbar-name-btn",onClick:()=>{"function"==typeof i&&B(!0)},title:"function"==typeof i?T("topbar_rename_template"):void 0,children:a||T("topbar_untitled_template")})]}),l.jsxs("div",{className:"ee-topbar-spacer",children:[(g||C)&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"ee-topbar-status-cluster ee-topbar-status-cluster--lead",children:[l.jsx("span",{className:fo("header-save-state","saved"===C&&"header-save-state_saved","saving"===C&&"header-save-state_saving","unsaved"===C&&"header-save-state_unsaved","error"===C&&"header-save-state_error"),"aria-label":`save-state-${C}`,children:g||C&&(T(`save_state_${C}`)||C)}),"saved"===C&&l.jsx(n.FontAwesomeIcon,{icon:o.faCheckCircle,className:"ee-topbar-saved-check","aria-hidden":!0}),"saving"===C&&l.jsx(n.FontAwesomeIcon,{icon:o.faSpinner,spin:!0,className:"ee-topbar-saving-spinner","aria-hidden":!0})]}),l.jsx("div",{className:"ee-topbar-divider","aria-hidden":!0})]}),l.jsx("button",{type:"button",className:"ee-topbar-icon-btn",onClick:k,disabled:!f,title:T("undo"),"aria-label":T("undo"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faUndo})}),l.jsx("button",{type:"button",className:"ee-topbar-icon-btn",onClick:v,disabled:!x,title:T("redo"),"aria-label":T("redo"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faRedo})}),l.jsx("div",{className:"ee-topbar-divider","aria-hidden":!0}),l.jsxs("div",{className:"ee-topbar-segment",role:"tablist","aria-label":"Device preview",children:[l.jsx("button",{type:"button",role:"tab","aria-selected":"desktop"===y,className:fo("ee-topbar-segment-btn","desktop"===y&&"ee-topbar-segment-btn-active"),onClick:()=>_("desktop"),title:T("desktop"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faDesktop})}),l.jsx("button",{type:"button",role:"tab","aria-selected":"mobile"===y,className:fo("ee-topbar-segment-btn","mobile"===y&&"ee-topbar-segment-btn-active"),onClick:()=>_("mobile"),title:T("mobile"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faMobileAlt})})]}),l.jsx("button",{type:"button",className:"ee-topbar-icon-btn",onClick:()=>Z(!0),title:T("html_email_preview"),"aria-label":T("html_email_preview"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faEye})}),l.jsx("div",{className:"ee-topbar-divider","aria-hidden":!0}),ue&&l.jsxs("button",{type:"button",className:"ee-topbar-btn ee-topbar-btn-ghost ee-topbar-btn-send-test",onClick:()=>{"function"!=typeof m?"function"==typeof c&&K(!0):m()},title:T("send_test"),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faPaperPlane}),l.jsx("span",{className:"ee-topbar-btn-label",children:T("send_test")})]}),"function"==typeof s&&l.jsxs("button",{type:"button",className:"ee-topbar-btn ee-topbar-btn-outline",onClick:()=>{"function"==typeof s&&s()},title:T("preview"),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faExternalLinkAlt}),l.jsx("span",{className:"ee-topbar-btn-label",children:T("preview")})]}),me&&l.jsxs("button",{type:"button",className:"ee-topbar-btn ee-topbar-btn-primary",onClick:()=>{"function"!=typeof p?"function"==typeof d&&q(!0):p()},title:T("save_template"),children:[l.jsx(n.FontAwesomeIcon,{icon:o.faSave}),l.jsx("span",{className:"ee-topbar-btn-label",children:T("save_template")})]}),l.jsxs("div",{className:"ee-topbar-overflow-wrap",ref:te,children:[l.jsx("button",{type:"button",className:"ee-topbar-icon-btn",onClick:()=>P(e=>!e),"aria-haspopup":"true","aria-expanded":M,"aria-label":T("more_actions"),title:T("more_actions"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faEllipsisV})}),M&&l.jsxs("div",{className:"ee-topbar-overflow-menu",role:"menu",children:[!b&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",role:"menuitem",className:"ee-topbar-overflow-item",disabled:W,onClick:()=>{P(!1),ce("json")},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faFileExport}),l.jsx("span",{children:T("export_json")})]}),l.jsxs("button",{type:"button",role:"menuitem",className:"ee-topbar-overflow-item",disabled:W,onClick:()=>{P(!1),ce("html")},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faFileCode}),l.jsx("span",{children:T("export_html")})]})]}),"function"==typeof u&&l.jsxs(l.Fragment,{children:[!b&&l.jsx("div",{className:"ee-topbar-overflow-divider","aria-hidden":!0}),l.jsxs("button",{type:"button",role:"menuitem",className:"ee-topbar-overflow-item",onClick:()=>{P(!1),u()},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faKeyboard}),l.jsx("span",{children:T("keyboard_shortcuts")})]})]}),"function"==typeof I&&l.jsxs("button",{type:"button",role:"menuitem",className:"ee-topbar-overflow-item",onClick:()=>{I(e=>!e),P(!1)},children:[l.jsx(n.FontAwesomeIcon,{icon:o.faAdjust}),l.jsx("span",{children:T(N?"high_contrast_off":"high_contrast_on")})]})]})]}),"function"==typeof h&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"ee-topbar-divider ee-topbar-divider-exit","aria-hidden":!0}),l.jsx("button",{type:"button",className:"ee-topbar-exit-btn",onClick:h,children:T("topbar_exit")||"Exit"})]})]}),l.jsx(t.Modal,{className:"ee-modal-dark ee-html-preview-modal",title:l.jsxs("div",{className:"ee-html-preview-modal-header-inner",children:[l.jsx("span",{className:"ee-html-preview-modal-title-text",children:T("html_email_preview_title")}),l.jsxs("div",{className:"ee-topbar-segment ee-html-preview-modal-segment",role:"tablist","aria-label":T("html_email_preview_device_aria"),onClick:e=>e.stopPropagation(),onMouseDown:e=>e.stopPropagation(),children:[l.jsx("button",{type:"button",role:"tab","aria-selected":"desktop"===Q,className:fo("ee-topbar-segment-btn","desktop"===Q&&"ee-topbar-segment-btn-active"),onClick:()=>ee("desktop"),title:T("desktop"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faDesktop})}),l.jsx("button",{type:"button",role:"tab","aria-selected":"mobile"===Q,className:fo("ee-topbar-segment-btn","mobile"===Q&&"ee-topbar-segment-btn-active"),onClick:()=>ee("mobile"),title:T("mobile"),children:l.jsx(n.FontAwesomeIcon,{icon:o.faMobileAlt})})]})]}),open:X,onCancel:()=>Z(!1),footer:null,width:"min(960px, 96vw)",centered:!0,destroyOnClose:!0,children:ne.error?l.jsx("p",{className:"ee-html-preview-error",children:ne.error}):l.jsx("div",{className:fo("ee-html-preview-viewport","mobile"===Q&&"ee-html-preview-viewport--mobile"),children:l.jsx("iframe",{title:T("html_email_preview_title"),className:"ee-html-preview-iframe",sandbox:"allow-same-origin allow-popups allow-popups-to-escape-sandbox",srcDoc:ne.html})})}),l.jsx(Ai,{open:F,issues:D,onClose:de,onExportAnyway:()=>{"html"===z?se():"json"===z&&re(),de()}}),!pe&&"function"==typeof c&&l.jsx(Bi,{open:V,templateName:a,onClose:()=>K(!1),onSend:e=>{if("function"!=typeof c)return;const t=ie();c({...t,name:a||"Untitled template",recipients:e.recipients,payloadType:e.payloadType,subjectPrefix:e.subjectPrefix})}}),!he&&"function"==typeof d&&l.jsx(t.Modal,{className:"ee-modal-dark",title:T("save_template_title")||"Save template",open:G,onCancel:()=>{q(!1),Y("")},onOk:()=>{if("function"!=typeof d)return;const e=ie();d({...e,name:a||"Untitled template",category:J}),q(!1),Y("")},okText:T("save")||"Save",cancelText:T("cancel"),width:420,destroyOnClose:!0,children:l.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:14},children:[l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:6,fontSize:13,fontWeight:500},children:T("template_name")||"Template name"}),l.jsx(t.Input,{value:a||T("topbar_untitled_template"),readOnly:!0})]}),l.jsxs("div",{children:[l.jsx("div",{style:{marginBottom:6,fontSize:13,fontWeight:500},children:T("save_template_category")||"Category"}),l.jsx(t.Select,{style:{width:"100%"},value:J||void 0,placeholder:T("save_template_category_placeholder")||"Select or type a category…",allowClear:!0,showSearch:!0,onChange:e=>Y(e||""),getPopupContainer:()=>document.querySelector(".email-editor")||document.body,options:[{value:"promotional",label:T("category_promotional")||"Promotional"},{value:"transactional",label:T("category_transactional")||"Transactional"},{value:"newsletter",label:T("category_newsletter")||"Newsletter"},{value:"onboarding",label:T("category_onboarding")||"Onboarding"},{value:"announcement",label:T("category_announcement")||"Announcement"},{value:"other",label:T("category_other")||"Other"}]})]})]})})]})},Ri=({keys:e,desc:t})=>l.jsxs("div",{className:"ee-shortcuts-row",children:[l.jsx("span",{className:"ee-shortcuts-row-desc",children:t}),l.jsx("kbd",{className:"ee-shortcuts-kbd",children:e})]}),Mi=({open:e,onClose:n})=>{const{t:o}=So(),a=/Mac|iPhone|iPod|iPad/i.test("undefined"!=typeof navigator&&navigator.platform||"")?"⌘":"Ctrl";return l.jsxs(t.Modal,{wrapClassName:"ee-modal-dark ee-shortcuts-modal",title:o("shortcuts_modal_title"),open:e,onCancel:n,footer:null,width:520,destroyOnClose:!0,children:[l.jsx(Ri,{keys:`${a} + S`,desc:o("shortcut_save")}),l.jsx(Ri,{keys:`${a} + Z`,desc:o("shortcut_undo")}),l.jsx(Ri,{keys:`${a} + Shift + Z / ${a} + Y`,desc:o("shortcut_redo")}),l.jsx(Ri,{keys:`${a} + D`,desc:o("shortcut_duplicate")}),l.jsx(Ri,{keys:`${a} + C`,desc:o("shortcut_copy_block")}),l.jsx(Ri,{keys:`${a} + V`,desc:o("shortcut_paste_block")}),l.jsx(Ri,{keys:"Delete / Backspace",desc:o("shortcut_delete_block")}),l.jsx(Ri,{keys:"Esc",desc:o("shortcut_escape")}),l.jsx(Ri,{keys:"?",desc:o("shortcut_cheat_sheet")}),l.jsx("p",{className:"ee-shortcuts-footnote",children:o("shortcuts_modal_footnote")})]})},Pi=({language:n})=>{const{blockMap:o,rootOrder:a,setBlocks:i,currentItem:r,setCurrentItem:s,setIsDragStart:c,setLanguage:d,templateData:u,highContrastEditor:m,canUndo:p,canRedo:g,undo:h,redo:b,flushPendingRichText:y,onShortcutSave:_,templateName:f,onTemplateNameChange:x,onBack:k,onSaveTemplate:v,onSaveTemplateIntent:w,onSendTest:j,onSendTestIntent:S,saveStatusDetail:C,onExit:N,onPreview:I,hideOverflowExportActions:A}=e.useContext(ge),{t:T}=So(),{getColumnConfig:L}=Fa(),[R,P]=e.useState(!1),E=e=>{if(!e||"object"!=typeof e)return e;const t=u?.content?.products,n=u?.catalogProducts,o=u?.content?.primaryProductId,a=Array.isArray(t)&&t.length>0?t:Array.isArray(n)&&n.length>0?n:el,l=o?a.find(e=>e.id===o):a[0],i=l?a.filter(e=>e?.id!==l.id):a,r=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(r):e.children;if("column"!==e.key||"product"!==e.containerType||!l)return{...e,children:t};const n=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),o="additional"===e.productRole?"additional":"main",a=Array.from({length:n},(e,t)=>"main"===o||0===i.length?l:i[t%i.length]);return{...e,children:t,columnProducts:a}};return r(e)};e.useEffect(()=>{d(n)},[n,d]),e.useEffect(()=>{const e=e=>{if(n=e.target,!Boolean(n&&n.closest&&n.closest(".email-editor")))return;var n;const l=e.metaKey||e.ctrlKey,c=e.key,d=(u=e.target,Boolean(u?.closest?.(".text-content_editable[contenteditable='true']")));var u;const m=(e=>{if(!e)return!1;const t=e.tagName;return"INPUT"===t||"TEXTAREA"===t||"SELECT"===t||Boolean(e.closest?.(".ant-input, .ant-input-number, textarea.ant-input, .ant-select-selection-search-input"))})(e.target);if(l&&"s"===String(c).toLowerCase())"function"==typeof _&&(e.preventDefault(),e.stopPropagation(),_());else if(d){if(l&&"z"===String(c).toLowerCase()&&!e.shiftKey){if(!p)return;return e.preventDefault(),e.stopPropagation(),y(),void h()}if(l&&("z"===String(c).toLowerCase()&&e.shiftKey||"y"===String(c).toLowerCase())){if(!g)return;return e.preventDefault(),e.stopPropagation(),y(),void b()}}else if(!m){if(l&&"z"===String(c).toLowerCase()&&!e.shiftKey){if(!p)return;return e.preventDefault(),y(),void h()}if(l&&("z"===String(c).toLowerCase()&&e.shiftKey||"y"===String(c).toLowerCase())){if(!g)return;return e.preventDefault(),y(),void b()}if(l&&"d"===String(c).toLowerCase()){if(!r?.id||"add"===r.type)return;e.preventDefault();const t=ia(o,a,r.id);if(!t)return;return i(t.nextMap,t.nextRootOrder,"add"),void s({id:t.newId,data:t.selectionData,type:"edit"})}if(l&&"c"===String(c).toLowerCase()){if(!r?.id||"add"===r.type)return;e.preventDefault();const t=la(o,a,r.id);return void(t&&(aa.tree=t))}if(l&&"v"===String(c).toLowerCase()){if(!aa.tree)return;e.preventDefault();const t=r?.id&&o[r.id]?r.id:null,n=sa(o,a,aa.tree,t);if(!n)return;return i(n.nextMap,n.nextRootOrder,"add"),void s({id:n.newId,data:n.selectionData,type:"edit"})}if("Escape"===c)return e.preventDefault(),P(!1),void s(null);if("?"===c||e.shiftKey&&"Slash"===e.code)return e.preventDefault(),void P(!0);if("Backspace"===c||"Delete"===c){if(!r?.id||"add"===r.type)return;const n=r.id,l=o[n];if(!l)return;const c=()=>{const e=da(o,a,n,T);e&&(i(e.nextMap,e.nextRootOrder,"delete"),s(null))};if("column"===l.key&&ca(o,n))return e.preventDefault(),void t.Modal.confirm({title:T("shortcut_delete_confirm_title"),content:T("shortcut_delete_confirm_desc"),okText:T("confirm"),cancelText:T("cancel"),wrapClassName:"ee-modal-dark",onOk:c});e.preventDefault(),c()}}};return document.addEventListener("keydown",e,!0),()=>document.removeEventListener("keydown",e,!0)},[o,a,r,i,s,p,g,h,b,y,_,T]);const D=()=>{const e=document.getElementsByClassName("block-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},W=()=>{const e=document.getElementsByClassName("block-content-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},H=()=>{document.querySelectorAll(".block-empty-content").forEach(e=>{e.style.border=""})},G=()=>{document.querySelectorAll('[data-type="empty-block"]').forEach(e=>{e.style.border=""})},q=()=>{document.querySelectorAll('[data-drag-hovered="true"]').forEach(e=>{delete e.dataset.dragHovered})},J=e=>{const t=e?.closest?.(".block-item[data-block-id], .block[data-block-id]")||null;document.querySelectorAll('[data-drag-hovered="true"]').forEach(e=>{e!==t&&delete e.dataset.dragHovered}),t&&(t.dataset.dragHovered="true")},Y=()=>{D(),W(),H(),G(),q()},X=e.useCallback(e=>{e.preventDefault(),e.stopPropagation();const t=e.target,{type:n}=t.dataset||{};switch(n){case"empty-block":D(),W(),q(),t.style.border="2px dashed var(--ee-drop-target-outline)";break;case"drag-over-column":{W(),J(t);const e=t.dataset.index,n=document.getElementsByClassName("block-drag-label-content");Array.from(n).forEach(t=>{const n=Number(t.dataset.index)===Number(e),o=t.querySelector(".block-move-top"),a=t.querySelector(".block-move-bottom");o&&(o.style.visibility=n?"visible":"hidden"),a&&(a.style.visibility=n?"visible":"hidden")});break}case"block-item-move":{D(),J(t);const e=t.dataset.dropKey,n=document.getElementsByClassName("block-content-drag-label-content");Array.from(n).forEach(t=>{t.dataset.dropKey===e?t.children[0].style.visibility="visible":t.children[0].style.visibility="hidden"});break}case"empty-block-item":D(),W(),J(t),t.classList?.contains("block-empty-content")&&(t.style.border="2px dashed var(--ee-drop-target-outline)");break;default:D(),W(),q()}},[]),Z=(e,t)=>{const{blockMap:n,removedId:o}=z(e,t.containerId,t.cellIndex,t.itemIndex);return{result:n,removedId:o}},Q=(e,t,n,o)=>{const a=e[t];if(!a||a.cells[n].childrenIds.length>0)return e;const l=$(o("drag_block_here"));return{...e,[l.id]:l,[t]:{...a,cells:a.cells.map((e,t)=>t===n?{...e,childrenIds:[l.id]}:e)}}},ee=(e,t,n)=>{if(!t||!n)return!1;if(t===n)return!0;const o=t=>{const a=e[t];if(!a||"column"!==a.key)return!1;for(const e of a.cells||[])for(const t of e.childrenIds||[]){if(t===n)return!0;if(o(t))return!0}return!1};return o(t)};return l.jsxs(l.Fragment,{children:[l.jsx(Mi,{open:R,onClose:()=>P(!1)}),l.jsxs("div",{className:"email-editor"+(m?" ee-high-contrast":""),onDragOver:X,onDrop:e=>{e.preventDefault(),e.stopPropagation();const{type:n}=e.target.dataset;q(),H(),G(),c(!1);const l="undefined"!=typeof window?window.__eeDragItemData:null,d=()=>{"undefined"!=typeof window&&(window.__eeDragItemData=null,window.__eeDragSource=null)},u="add"===r?.type&&null!=r?.data,m=u||l?"add":r?.type,p=u?function(e){if(!e||"object"!=typeof e)return e;const t="column"===e.key&&Array.isArray(e.children)&&e.children.length>0;if("column"===e.key&&Array.isArray(e.cells)&&e.cells.length>0&&!t){const t=V(e,e.blockMap||e.blockSnapshotMap||{});if(t?.blockMap&&t.rootId){const e=M(t.blockMap,[t.rootId])[0];if(e)return B(e)}}return B(e)}(r.data):l?B(l):r?.data??null;if(p){switch(n){case"empty-block":{const e="column"===p.key?p:L(p),t=E(e),{newBlockMap:n,rootId:a}=K(o,t);if(!a)return void d();i(n,[a],"add"),s({id:a,data:n[a],type:"edit"}),"add"===m&&"column"===n[a]?.key&&ua(n[a])===pa&&ha(a);break}case"empty-block-item":{H();const n=e.target.dataset.containerId,l=Number(e.target.dataset.cellIndex),c=Number(e.target.dataset.itemIndex);if(!n)return void d();if("column"===p.key||"add"!==m&&r?.id&&"column"===o[r.id]?.key)return t.message.warning(T("section_nest_not_allowed")),d(),void Y();let u={...o};if("add"===m){const e=B(p),t=E(e),{newBlockMap:o,rootId:r}=K(u,t);if(!r)return void d();u=U(o,n,l,c,r),i(u,a,"add"),s({id:r,data:u[r],type:"edit"})}else{const e=r.id;if(ee(u,e,n))return d(),void Y();const t=F(u,a,e);if(!t)return void d();{const{result:e,removedId:o}=Z(u,t);u=e?Q(e,t.containerId,t.cellIndex,T):u,o&&(u=U(u,n,l,c,o))}i(u,a,"move"),s({...r,data:u[e]??r.data,type:"edit"})}break}case"drag-over-column":{const t=Number(e.target.dataset.index);let n,l=[...a],c={...o};if("add"===m){const e=B(p);if("column"===e.key){const o=E(e),{newBlockMap:a,rootId:i}=K(c,o);if(!i)return void d();c=a,l.splice(t,0,i),n={id:i,data:c[i],type:"edit"}}else{const o=t>=l.length?l[l.length-1]:l[t],a=c[o];if(!a||"column"!==a.key)return void d();const{newBlockMap:i,rootId:r}=K(c,e);if(!r)return void d();c=i;const s=0,u=c[o]?.cells?.[s],m=u?.childrenIds?.[0],p=m?c[m]:null;if("empty"===p?.key)c=U(c,o,s,0,r);else{c=O(c,o,s,u?.childrenIds?.length??0,r)}n={id:r,data:c[r],type:"edit"}}}else{const e=r.id,o=a.indexOf(e);if(-1===o)return void d();l.splice(o,1),l.splice(t>o?t-1:t,0,e),n={...r,type:"edit"}}i(c,l,"move"),s(n),"add"===m&&"column"===n?.data?.key&&ua(n.data)===pa&&ha(n.id),setTimeout(()=>{const e=document.getElementsByClassName("block-drag-label-content");Array.from(e).forEach(e=>{const t=e.querySelector(".block-move-top");t&&(t.style.visibility="hidden")})},30);break}case"block-item-move":{const n=e.target.dataset.dropKey;if(!n)return void d();const[l,c,u]=n.split(":"),g=Number(c),h=Number(u);let b,y={...o};if("add"===m){if("column"===p.key)return t.message.warning(T("section_nest_not_allowed")),d(),void Y();const e=B(p),n=E(e),{newBlockMap:o,rootId:a}=K(y,n);if(!a)return void d();y=O(o,l,g,h,a),b={id:a,data:y[a],type:"edit"}}else{const e=r.id;if("column"===y[e]?.key)return t.message.warning(T("section_nest_not_allowed")),d(),void Y();if(ee(y,e,l))return d(),void Y();const n=F(y,a,e);if(!n)return void d();const{blockMap:o,removedId:i}=z(y,n.containerId,n.cellIndex,n.itemIndex);y=o;const s=y[n.containerId];if(s&&0===s.cells[n.cellIndex].childrenIds.length){const e=$(T("drag_block_here"));y={...y,[e.id]:e,[n.containerId]:{...s,cells:s.cells.map((t,o)=>o===n.cellIndex?{...t,childrenIds:[e.id]}:t)}}}let c=h;n.containerId===l&&n.cellIndex===g&&n.itemIndex<h&&(c=h-1),y=O(y,l,g,c,i),b={...r,type:"edit"}}i(y,a,"move"),s(b),setTimeout(()=>{const e=document.getElementsByClassName("block-content-drag-label-content");Array.from(e).forEach(e=>{e.children[0]&&(e.children[0].style.visibility="hidden")})},30);break}}d()}else d()},onDragLeave:e=>{const t=e.currentTarget,n=e.relatedTarget,o=e.target;setTimeout(()=>{if(t&&t.contains(n))switch(o?.dataset?.type){case"empty-block":o.style.border="";break;case"empty-block-item":o?.classList?.contains("block-empty-content")&&(o.style.border="")}else Y()},50)},children:[l.jsx($i,{templateName:f,onTemplateNameChange:x,onBack:k,onSaveTemplate:v,onSaveTemplateIntent:w,onSendTest:j,onSendTestIntent:S,saveStatusDetail:C,onExit:N,onPreview:I,hideOverflowExportActions:A,onShowShortcuts:()=>P(!0)}),l.jsxs("div",{className:"email-editor-main",onClick:e=>{e.preventDefault(),e.stopPropagation(),s(null)},children:[l.jsx(Ii,{clearStyles:Y}),l.jsx(Ca,{clearStyles:Y}),l.jsx(ai,{clearStyles:Y})]})]})]})},Fi="markopolo-email-editor:undo:";const Ei=e=>Array.isArray(e)?e.map(e=>e&&"object"==typeof e?{...e,children:Ei(e.children)}:e):e&&"object"==typeof e?Object.values(e).map(e=>e&&"object"==typeof e?{...e,children:Ei(e.children)}:e):[],Di=e=>{const t={},n=(e,o=[])=>{Array.isArray(e)&&e.forEach(e=>{if(!e||"object"!=typeof e)return;const a={blockId:e.id??null,key:e.key??null,containerType:"column"===e.key?e.containerType??"none":null},l=[...o,a];if("text"===e.key&&"dynamic"===e.contentType){const n="string"==typeof e.dynamicPrompt?e.dynamicPrompt.trim():"",o="string"==typeof e.dynamicSelectedContent?e.dynamicSelectedContent.trim():"";if(!n&&!o)return;t[e.id]={blockId:e.id,path:l,key:e.key,type:e.type||"p",selectedContent:o,options:Array.isArray(e.dynamicOptions)?e.dynamicOptions:[],prompt:n,variable:e.dynamicVariable??"",language:"bn-BD"===e.dynamicAiLanguage?"bn-BD":"en"}}Array.isArray(e.children)&&n(e.children,l)})};return n(e,[]),t},Ui=e=>Array.isArray(e)?e.map(e=>{if(!e||"object"!=typeof e)return e;const{dynamicPrompt:t,dynamicOptions:n,dynamicSelectedContent:o,dynamicVariable:a,dynamicAiLanguage:l,staticTextBeforeAi:i,children:r,...s}=e;return{...s,children:Ui(r)}}):e,zi=e.forwardRef(({defaultBlockList:t,defaultBodySettings:n,aiContentRefs:o,language:a="en",customLanguageLibraries:i,templateData:r,variableDefinitions:s,apiConfig:c={},aiEnabled:d=!0,saveState:u="saved",onChange:m,undoPersistenceKey:p=null,onShortcutSave:g,onSaveBlockAsGlobal:h,templateName:b="",onTemplateNameChange:y,onBack:f,onSaveTemplate:x,onSaveTemplateIntent:k,onSendTest:w,onSendTestIntent:j,saveStatusDetail:S,onExit:C,onPreview:N,hideOverflowExportActions:I=!1,universals:A=[]},T)=>{const[L,B]=e.useState(()=>{if("undefined"==typeof window)return!1;try{return"1"===window.localStorage.getItem("ee_high_contrast_editor")}catch{return!1}});e.useEffect(()=>{if("undefined"!=typeof window)try{window.localStorage.setItem("ee_high_contrast_editor",L?"1":"0")}catch{}},[L]),e.useEffect(()=>{var e;Xe=(e=s)&&"object"==typeof e?e:Ye,it()},[s]);const $=e.useMemo(()=>Pn(c),[c]),[M,F]=e.useState([]),[E,D]=e.useState(!1),U=e.useCallback(async()=>{if($?.companyId){D(!0);try{const e=await async function(e,t={}){const n=Dn(e),o=e?.companyId;if(!n||!o)return[];const a=new URLSearchParams({companyId:String(o),page:String(t.page??1),limit:String(t.limit??100)});null!=t.blockType&&String(t.blockType).trim()&&a.set("blockType",String(t.blockType)),"boolean"==typeof t.isActive&&a.set("isActive",String(t.isActive));const l=await fetch(`${n}?${a.toString()}`,{method:"GET",headers:{...e?.headers||{}}}),i=await l.text();let r;try{r=i?JSON.parse(i):{}}catch{return[]}if(!l.ok)return console.warn("[universal-email-blocks]",l.status,r),[];const s=r?.data;return Array.isArray(s)?s.map(zn).filter(Boolean):[]}($,{limit:100});F(Array.isArray(e)?e:[])}catch(e){console.warn("[EmailEditor] universal email blocks fetch",e)}finally{D(!1)}}else F([])},[$]);e.useEffect(()=>{U()},[U]);const z=e.useMemo(()=>{const e=M??[],t=A??[];if(!$?.companyId)return t;const n=new Set;return e.filter(e=>{const t=String(e?.resourceId??e?.id??"");return!(!t||n.has(t))&&(n.add(t),!0)})},[$?.companyId,M,A]),O=e.useCallback(async e=>{$?.companyId&&(await async function(e,{name:t,block:n}){const o=Dn(e),a=e?.companyId;if(!o||!a)throw new Error("Universal blocks API: missing endpoint or companyId");const l=Fn(t,n,a),i=await fetch(o,{method:"POST",headers:Un(e),body:JSON.stringify(l)}),r=await i.text();let s;try{s=r?JSON.parse(r):{}}catch{s={message:r}}if(!i.ok)throw new Error(En(s,i.status));return s?.data??s}($,e),await U()),"function"==typeof h&&await Promise.resolve(h(e))},[$,h,U]),W=e.useCallback(async e=>{$?.companyId&&(await async function(e,t){const n=Dn(e),o=e?.companyId;if(!n||!o||!t)throw new Error("Universal blocks API: missing endpoint, companyId, or id");const a=new URLSearchParams({companyId:String(o)}),l=`${n}/${encodeURIComponent(String(t))}?${a}`,i=await fetch(l,{method:"DELETE",headers:{...e?.headers||{}}});if(204===i.status)return!0;if(!i.ok){const e=await i.text();let t;try{t=e?JSON.parse(e):{}}catch{t={message:e}}throw new Error(En(t,i.status))}return!0}($,e),await U())},[$,U]),H=t&&!Array.isArray(t)&&"object"==typeof t?t:null,V=H?H.blocks??H.blockList??[]:t,K=(Y=V,Array.isArray(Y)?Y.map(e=>e&&"object"==typeof e?{...e,children:Ei(e.children)}:e):Y&&"object"==typeof Y?Object.values(Y).map(e=>e&&"object"==typeof e?{...e,children:Ei(e.children)}:e):[]);var Y;const Z=o??H?.aiContentRefs??{},ae=n??H?.bodySettings??pe.bodySettings,de=r??pe.templateData,ue=((e,t)=>{if(!Array.isArray(e))return e;const n=t?.content?.products;if(!Array.isArray(n)||0===n.length)return e;const o=t?.content?.primaryProductId,a=(o?n.find(e=>e?.id===o):n[0])??n[0]??el[0]??null;if(!a)return e;const l=n.filter(e=>e?.id!==a.id),i=e=>{if(!e||"object"!=typeof e)return e;const t=Array.isArray(e.children)?e.children.map(i):e.children;if("column"!==e.key||"product"!==e.containerType)return{...e,children:t};const n="additional"===e.productRole?"additional":"main",o=Math.max(Array.isArray(t)?t.length:0,Array.isArray(e.columnProducts)?e.columnProducts.length:0,1),r=Array.from({length:o},(e,t)=>"main"===n||0===l.length?a:l[t%l.length]);return{...e,children:t,columnProducts:r}};return e.map(i)})(K,de),me=Ln(ue,Z),{blockMap:he,rootOrder:be}=R(me),ye=_(he,de),_e=e.useMemo(()=>function(e){if("undefined"==typeof sessionStorage||!e)return null;try{const t=sessionStorage.getItem(Fi+e);if(!t)return null;const n=JSON.parse(t);return n&&"object"==typeof n?{undoStack:Array.isArray(n.undoStack)?n.undoStack:[],redoStack:Array.isArray(n.redoStack)?n.redoStack:[]}:null}catch{return null}}(p),[p]),[fe,ke]=e.useReducer(xe,{...pe,blockMap:ye,rootOrder:be,blockList:me,bodySettings:{...ae,contentWidth:v(ae?.contentWidth)},languageLibraries:i,templateData:de,undoStack:_e?.undoStack??[],redoStack:_e?.redoStack??[]}),ve=e.useRef(null);e.useEffect(()=>{p&&function(e,t,n){if("undefined"!=typeof sessionStorage&&e)try{sessionStorage.setItem(Fi+e,JSON.stringify({undoStack:t,redoStack:n}))}catch{}}(p,fe.undoStack,fe.redoStack)},[p,fe.undoStack,fe.redoStack]),e.useEffect(()=>{ke(ce(r??null,{skipUndo:!0}))},[r]);const[we,je]=e.useState([]);e.useEffect(()=>{if("undefined"==typeof document)return;const e=fe.blockList??[],t="ee-font-runtime-imports",n=document.getElementById(t)||Object.assign(document.createElement("style"),{id:t}),o=Ut(e,fe.bodySettings,fe.templateData);n.textContent=o||"",n.parentNode||document.head.appendChild(n)},[fe.blockList,fe.bodySettings,fe.templateData]);const Se=e.useMemo(()=>new Set(we),[we]),Ce=e.useCallback(e=>(Array.isArray(e)?e:[]).filter(e=>!Se.has(Hn(e))),[Se]),Ne=e.useCallback(e=>{const t=Hn(e);t&&je(e=>e.includes(t)?e:[...e,t])},[]),Ie=e.useCallback(()=>{const e=fe.blockList??[];return{blockList:Ui(e),bodySettings:fe.bodySettings??null,aiContentRefs:Di(e),language:Vn(e)}},[fe.blockList,fe.bodySettings]),Ae=e.useMemo(()=>Ce(uo({blockList:fe.blockList??[],bodySettings:fe.bodySettings??null,aiContentRefs:Di(fe.blockList??[])})).filter(e=>e?.blockId&&("warning"===e.severity||"error"===e.severity)).reduce((e,t)=>{const n=t.blockId,o=e[n]??{severity:t.severity,warningCount:0,errorCount:0,totalCount:0,messages:[],issues:[]};return"error"===t.severity&&(o.errorCount+=1),"warning"===t.severity&&(o.warningCount+=1),o.totalCount+=1,o.severity=o.errorCount>0?"error":"warning",o.messages.push(t.message),o.issues.push(t),e[n]=o,e},{}),[fe.blockList,fe.bodySettings,Ce]);e.useImperativeHandle(T,()=>({blockList:Ui(fe.blockList??[]),bodySettings:fe.bodySettings,aiContentRefs:Di(fe.blockList??[]),actionType:fe.actionType,exportJson:Ie,filterIgnoredValidationIssues:Ce,ignoreValidationIssue:Ne,focusBlock:e=>{if(!e||!fe.blockMap?.[e])return!1;const t=fe.blockMap[e],n="column"===t?.key?P(e,fe.blockMap)??t:t;return ke(se({id:e,data:n,type:"edit"})),ke(re("edit")),"undefined"!=typeof window&&window.requestAnimationFrame(()=>{const t="function"==typeof window.CSS?.escape?window.CSS.escape(String(e)):String(e).replace(/([ #;?%&,.+*~':\x22!^$\x5b\x5d()=>|/@])/g,"\\$1"),n=document.querySelector(`[data-block-id="${t}"]`);n&&"function"==typeof n.scrollIntoView&&n.scrollIntoView({behavior:"smooth",block:"center",inline:"nearest"})}),!0},exportHtml:()=>Sn({bodySettings:fe.bodySettings,blockList:fe.blockList,templateData:fe.templateData})}),[fe.blockList,fe.blockMap,fe.bodySettings,fe.actionType,fe.templateData,Ie,Ce,Ne]),e.useEffect(()=>{"function"==typeof m&&"firstRender"!==fe.actionType&&m({blockList:Ui(fe.blockList??[]),bodySettings:fe.bodySettings??null,aiContentRefs:Di(fe.blockList??[]),actionType:fe.actionType})},[fe.blockList,fe.bodySettings,fe.actionType,m]);const Te=e.useCallback(e=>{ke((e=>({type:J,isDragStart:e}))(e))},[]),Le=e.useCallback((e,t,n)=>{t&&ke(re(t)),ke(((e,t={})=>({type:Q,bodySettings:e,skipUndo:Boolean(t.skipUndo)}))(e,n||{}))},[]),Be=e.useCallback((e,t,n,o)=>{n&&ke(re(n)),ke(((e,t,n={})=>({type:q,blockMap:e,rootOrder:t,skipUndo:Boolean(n.skipUndo)}))(e,t,o||{}))},[]),$e=e.useCallback((e,t,n)=>{t&&ke(re(t)),ke(((e,t={})=>({type:G,blockList:e,skipUndo:Boolean(t.skipUndo)}))(e,n||{}))},[]),Re=e.useCallback(e=>{ke((e=>({type:X,previewMode:e}))(e))},[]),Me=e.useCallback(e=>{ke(se(e))},[]),Pe=e.useCallback(e=>{ke((e=>({type:ee,selectionRange:e}))(e))},[]),Fe=e.useCallback(e=>{ke((e=>({type:te,textRange:e}))(e))},[]),Ee=e.useCallback(e=>{ke(re(e))},[]),De=e.useCallback(e=>{ke((e=>({type:ne,language:e}))(e))},[]),Ue=e.useCallback(e=>{ke((e=>({type:oe,languageLibraries:e}))(e))},[]),ze=e.useCallback((e,t)=>{ke(ce(e,t||{}))},[]),Oe=e.useCallback(()=>{try{ve.current?.()}catch{}},[]),We=e.useCallback(e=>(ve.current=e,()=>{ve.current===e&&(ve.current=null)}),[]),He=e.useCallback(()=>{Oe(),ke({type:le})},[Oe]),Ve=e.useCallback(()=>{Oe(),ke({type:ie})},[Oe]),Ke=e.useMemo(()=>({blockMap:fe.blockMap,rootOrder:fe.rootOrder,blockList:fe.blockList,actionType:fe.actionType,previewMode:fe.previewMode,currentItem:fe.currentItem,bodySettings:fe.bodySettings,isDragStart:fe.isDragStart,selectionRange:fe.selectionRange,textRange:fe.textRange,language:fe.language,languageLibraries:fe.languageLibraries,templateData:fe.templateData,apiConfig:$,validationMarkers:Ae,ignoreValidationIssue:Ne,aiEnabled:d,saveState:u,highContrastEditor:L,canUndo:fe.undoStack.length>0,canRedo:fe.redoStack.length>0,undo:He,redo:Ve,flushPendingRichText:Oe,registerRichTextFlush:We,onShortcutSave:g,onSaveBlockAsGlobal:O,templateName:b,onTemplateNameChange:y,onBack:f,onSaveTemplate:x,onSaveTemplateIntent:k,onSendTest:w,onSendTestIntent:j,saveStatusDetail:S,onExit:C,onPreview:N,hideOverflowExportActions:I,universals:z,universalsLoading:E,deleteUniversalEmailBlock:$?.companyId?W:void 0,setIsDragStart:Te,setBodySettings:Le,setBlocks:Be,setBlockList:$e,setPreviewMode:Re,setCurrentItem:Me,setSelectionRange:Pe,setTextRange:Fe,setActionType:Ee,setLanguage:De,setLanguageLibraries:Ue,setTemplateData:ze,setHighContrastEditor:B}),[fe.blockMap,fe.rootOrder,fe.blockList,fe.actionType,fe.previewMode,fe.currentItem,fe.bodySettings,fe.isDragStart,fe.selectionRange,fe.textRange,fe.language,fe.languageLibraries,fe.templateData,fe.undoStack.length,fe.redoStack.length,$,Ae,Ne,d,u,L,He,Ve,Oe,We,g,O,b,y,f,x,k,w,j,S,C,N,I,z,E,W,Te,Le,Be,$e,Re,Me,Pe,Fe,Ee,De,Ue,ze,B]);return l.jsx(ge.Provider,{value:Ke,children:l.jsx(Pi,{language:a})})});const Oi=["Product","Discount"],Wi=["text","image","button"];function Hi(e,t,n,o,a,l,i){if("column"===e.key&&e.containerType){const t=function(e){const t=e.toLowerCase();return"product"===t?"Product":"discount"===t?"Discount":"None"}(e.containerType),n=e.id??null;let r=o;"Product"===t&&(i.productIndex++,r=i.productIndex);for(const o of e.children??[])Hi(o,t,n,r,a,l,i);return}if("content"===e.key){for(const r of e.children??[])Hi(r,t,n,o,a,l,i);return}const r="dynamic"===e.contentType,s=Oi.includes(t)&&Wi.includes(e.key);if((r||s)&&n){let i=a.find(e=>e.containerId===n);i||(i={containerId:n,containerType:t,blocks:[]},a.push(i));const c=e.id?l[e.id]:void 0,d=function(e){return"image"===e.key?e.src??"":"button"===e.key?e.linkURL??"":e.text??""}(e);let u="";"Product"===t?u=function(e,t){const n=`product ${t}`;return e.includes("{{ProductImage}}")?`This block is meant for displaying the ${n} image`:e.includes("{{ProductName}}")?`This block is meant for displaying the ${n} name`:e.includes("{{ProductOldPrice}}")||e.includes("{{ProductNewPrice}}")?`This block is meant for displaying the ${n} original and discounted price`:e.includes("{{ProductPrice}}")||e.includes("{{ProductCurrency}}")?`This block is meant for displaying the ${n} price and currency`:e.includes("{{ProductDescription}}")?`This block is meant for displaying the ${n} description`:e.includes("{{ProductLink}}")?`This block is meant for displaying the ${n} link`:`This block is meant for displaying ${n} content`}(d,o):"Discount"===t&&(u=function(e){const t=[];return e.includes("{{DiscountValue}}")&&t.push("the discount value (e.g. 20% or $10)"),e.includes("{{DiscountCode}}")&&t.push("the discount/promo code"),e.includes("{{ValidUntil}}")&&t.push("the discount expiry date"),0===t.length?"This block is meant for displaying discount/offer information":`This block is meant for displaying ${t.join(", ")}`}(d));const m=c?.prompt||u,p=s&&!r;i.blocks.push({id:e.id??"",contentType:p||"dynamic"===e.contentType?"dynamic":"static",value:p?"":d,ai:{prompt:m,selectedSampleAiContent:p?"":c?.selectedContent??d}})}if(e.children)for(const r of e.children)Hi(r,t,n,o,a,l,i)}const Vi={text:"text",image:"src",button:"linkURL"};function Ki(e,t){if(0===t.size)return!0;if(e.id&&t.has(e.id)){const n=t.get(e.id),o=Vi[e.key];o&&(e[o]=n,t.delete(e.id))}if(e.children)for(const n of e.children)if(Ki(n,t))return!0;return 0===t.size}var Gi=Object.freeze({__proto__:null,jsonToHtml:function(e){return Cn(e)},normalizeJson:function(e){const t="string"==typeof e?JSON.parse(e):e,n=[],o=t.aiContentRefs||{},a={productIndex:0},l=t.blockList||[];for(const e of l)Hi(e,"None",null,0,n,o,a);return{groups:n}},updateJsonWithMlContent:function(e,t){const n="string"==typeof e?JSON.parse(e):e,o=structuredClone(n),a=new Map;for(const e of t)e.variations.length>0&&a.set(e.nodeId,e.variations[0].value);const l=o.blockList||[];for(const e of l)if(Ki(e,a))break;return o}});const qi=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."});exports.DEFAULT_EMAIL_TEMPLATE_ID=Rn,exports.DEFAULT_MARKOPOLO_API_BASE_V1=Bn,exports.DEFAULT_ML_GENERATION_API_BASE_V1=$n,exports.EmailEditor=zi,exports.TEMPLATE_DATA_SCHEMA=qi,exports.createDefaultTemplateData=function(e={}){const t={name:"",website:"",navigation_links:[],social_links:{}},n={brand_color:"#111111",logo_url:"",tagline:"",heroBanner:"",footerBanner:""},o=null;return{content:{...{products:[],primaryProductId:null},...e.content&&"object"==typeof e.content?e.content:{}},companyContext:{...t,...e.companyContext&&"object"==typeof e.companyContext?e.companyContext:{}},brandContext:{...n,..."string"==typeof e.brandColor&&e.brandColor.trim()?{brand_color:e.brandColor.trim()}:{},...e.brandContext&&"object"==typeof e.brandContext?e.brandContext:{}},companyId:null!=e.companyId?e.companyId:o}},exports.default=zi,exports.exportNormalizerToHtml=Cn,exports.exportTemplateJson=function(e,t={}){const{validate:n=!0}=t,o=e?.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 a=o.exportJson();if(!a||"object"!=typeof a)throw new Error("exportTemplateJson: exportJson() returned an invalid payload.");return{payload:a,issues:n?uo({blockList:a.blockList,bodySettings:a.bodySettings,aiContentRefs:a.aiContentRefs}):[]}},exports.exportTemplateJsonAsync=async function(e,t={}){const{validate:n=!0,checkImages:o=!0,imageProbe:a}=t,l=e?.current;if(!l||"function"!=typeof l.exportJson)throw new Error("exportTemplateJsonAsync: ref must be attached to EmailEditor (expected ref.current.exportJson to be a function).");const i=l.exportJson();if(!i||"object"!=typeof i)throw new Error("exportTemplateJsonAsync: exportJson() returned an invalid payload.");return n?{payload:i,issues:o?await _o({blockList:i.blockList,bodySettings:i.bodySettings,aiContentRefs:i.aiContentRefs},a):uo({blockList:i.blockList,bodySettings:i.bodySettings,aiContentRefs:i.aiContentRefs})}:{payload:i,issues:[]}},exports.mergeMarkopoloApiConfig=Pn,exports.utils=Gi,exports.validateExportPayload=uo,exports.validateExportPayloadComplete=_o,exports.validateImageUrlsReachable=yo,exports.validateTemplateDataShape=function(e){const t=[];if(null==e||"object"!=typeof e)return{ok:!1,warnings:["templateData must be a non-null object"]};const n=e;if(null!=n.content&&"object"!=typeof n.content)t.push("templateData.content should be an object when provided");else if(n.content&&"object"==typeof n.content){const e=n.content;null==e.products||Array.isArray(e.products)||t.push("templateData.content.products should be an array when provided")}if(null==n.catalogProducts||Array.isArray(n.catalogProducts)||t.push("templateData.catalogProducts should be an array when provided"),null!=n.companyContext&&"object"!=typeof n.companyContext&&t.push("templateData.companyContext should be an object when provided"),null!=n.brandContext&&"object"!=typeof n.brandContext&&t.push("templateData.brandContext should be an object when provided"),n.brandContext&&"object"==typeof n.brandContext){const e=n.brandContext;null!=e.brand_color&&"string"!=typeof e.brand_color&&t.push("templateData.brandContext.brand_color should be a string when provided")}return{ok:0===t.length,warnings:t}};