HEX
Server: Apache
System: Linux host17.registrar-servers.com 4.18.0-513.18.1.lve.2.el8.x86_64 #1 SMP Sat Mar 30 15:36:11 UTC 2024 x86_64
User: shrsglobal (7178)
PHP: 8.0.30
Disabled: NONE
Upload Files
File: /home/shrsglobal/www/wp-content/plugins/woocommerce/assets/client/admin/email-editor/index.js
/*! For license information please see index.js.LICENSE.txt */
(()=>{"use strict";var e={24148:(e,t,o)=>{o.d(t,{A:()=>r});var n=o(86087);const r=(0,n.forwardRef)((function({icon:e,size:t=24,...o},r){return(0,n.cloneElement)(e,{width:t,height:t,...o,ref:r})}))},2071:(e,t,o)=>{o.d(t,{x:()=>g});var n=o(39793),r=o(56427),s=o(27723),i=o(86087),a=o(47143);const l=({groupedTags:e,activeCategory:t,onCategorySelect:o})=>{const a=e=>e===t?"woocommerce-personalization-tags-modal-menu-item-active":"";return(0,n.jsxs)(r.MenuGroup,{className:"woocommerce-personalization-tags-modal-menu",children:[(0,n.jsx)(r.MenuItem,{onClick:()=>o(null),className:a(null),children:(0,s.__)("All","woocommerce")}),(0,n.jsx)("div",{className:"woocommerce-personalization-tags-modal-menu-separator","aria-hidden":"true",role:"presentation","data-testid":"woocommerce-personalization-tags-modal-menu-separator"}),Object.keys(e).map(((e,t,s)=>(0,n.jsxs)(i.Fragment,{children:[(0,n.jsx)(r.MenuItem,{onClick:()=>o(e),className:a(e),children:e}),t<s.length-1&&(0,n.jsx)("div",{className:"woocommerce-personalization-tags-modal-menu-separator","aria-hidden":"true",role:"presentation","data-testid":"woocommerce-personalization-tags-modal-menu-separator"})]},e)))]})};var c=o(94715);const d=({groupedTags:e,activeCategory:t,onInsert:o,canInsertLink:i,closeCallback:l,openLinkModal:d})=>{const{updateBlockAttributes:u}=(0,a.useDispatch)(c.store),p=(0,a.useSelect)((e=>e(c.store).getSelectedBlockClientId())),m=(0,a.useSelect)((e=>e(c.store).getBlock(p))),g=["core/button"].includes(m?.name),h=null===t?Object.entries(e):[[t,e[t]||[]]];return(0,n.jsx)(n.Fragment,{children:h.map((([e,t])=>(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"woocommerce-personalization-tags-modal-category",children:e}),(0,n.jsx)("div",{className:"woocommerce-personalization-tags-modal-category-group",children:t.map((t=>{const a=/\burl\b/.test(t.token);return(0,n.jsxs)("div",{className:"woocommerce-personalization-tags-modal-category-group-item",children:[(0,n.jsxs)("div",{className:"woocommerce-personalization-tags-modal-item-text",children:[(0,n.jsx)("strong",{children:t.name}),t.valueToInsert]}),(0,n.jsxs)("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end"},children:[(0,n.jsx)(r.Button,{variant:"link",onClick:()=>{o&&o(t.valueToInsert,!1)},children:(0,s.__)("Insert","woocommerce")}),g&&a&&(0,n.jsx)(r.Button,{variant:"link",onClick:()=>{u(p,{url:t.valueToInsert}),l()},children:(0,s.__)("Set as URL","woocommerce")}),e===(0,s.__)("Link","woocommerce")&&i&&(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(r.Button,{variant:"link",onClick:()=>{l(),d(t)},children:(0,s.__)("Insert as link","woocommerce")})})]})]},t.token)}))})]},e)))})},u=({onInsert:e,isOpened:t,closeCallback:o,tag:a})=>{const[l,c]=(0,i.useState)((0,s.__)("Link","woocommerce"));return t?(0,n.jsxs)(r.Modal,{size:"small",title:(0,s.__)("Insert Link","woocommerce"),onRequestClose:o,className:"woocommerce-personalization-tags-modal",children:[(0,n.jsx)(r.TextControl,{label:(0,s.__)("Link Text","woocommerce"),value:l,onChange:c}),(0,n.jsx)(r.Button,{isPrimary:!0,onClick:()=>{e&&e(a.token,l)},children:(0,s.__)("Insert","woocommerce")})]}):null};var p=o(59191),m=o(58039);const g=({onInsert:e,isOpened:t,closeCallback:o,canInsertLink:c=!1,openedBy:g=""})=>{const[h,_]=(0,i.useState)(null),[f,y]=(0,i.useState)(""),[w,x]=(0,i.useState)(null),[b,v]=(0,i.useState)(!1),S=(0,a.useSelect)((e=>e(m.H).getPersonalizationTagsList()),[]);if(b)return(0,n.jsx)(u,{onInsert:(t,o)=>{e(t,o),v(!1)},isOpened:b,closeCallback:()=>v(!1),tag:w});if(!t)return null;(0,p.xW)("personalization_tags_modal_opened",{openedBy:g});const k=S.reduce(((e,t)=>{const{category:o,name:n,token:r}=t;return(!f||n.toLowerCase().includes(f.toLowerCase())||r.toLowerCase().includes(f.toLowerCase()))&&(e[o]||(e[o]=[]),e[o].push(t)),e}),{});return(0,n.jsxs)(r.Modal,{size:"medium",title:(0,s.__)("Personalization Tags","woocommerce"),onRequestClose:()=>{o(),(0,p.yM)("personalization_tags_modal_closed",{openedBy:g})},className:"woocommerce-personalization-tags-modal",children:[(0,n.jsxs)("p",{children:[(0,s.__)("Insert personalization tags to dynamically fill in information and personalize your emails.","woocommerce")," ",(0,n.jsx)(r.ExternalLink,{href:"https://kb.mailpoet.com/article/435-a-guide-to-personalisation-tags-for-tailored-newsletters#list",onClick:()=>(0,p.yM)("personalization_tags_modal_learn_more_link_clicked",{openedBy:g}),children:(0,s.__)("Learn more","woocommerce")})]}),(0,n.jsx)(r.SearchControl,{onChange:e=>{y(e),(0,p.xW)("personalization_tags_modal_search_control_input_updated",{openedBy:g})},value:f}),(0,n.jsx)(l,{groupedTags:k,activeCategory:h,onCategorySelect:e=>{_(e),(0,p.yM)("personalization_tags_modal_category_menu_clicked",{category:e,openedBy:g})}}),(0,n.jsx)(d,{groupedTags:k,activeCategory:h,onInsert:t=>{e(t),(0,p.yM)("personalization_tags_modal_tag_insert_button_clicked",{insertedTag:t,activeCategory:h,openedBy:g})},closeCallback:o,canInsertLink:c,openLinkModal:e=>{x(e),v(!0)}})]})}},91948:(e,t,o)=>{o.d(t,{t:()=>a});var n=o(39793),r=o(86087),s=o(56427),i=o(27723);const a=({contentRef:e,onUpdate:t})=>{const[o,a]=(0,r.useState)(!1),[l,c]=(0,r.useState)(null),[d,u]=(0,r.useState)(""),[p,m]=(0,r.useState)("");return(0,r.useEffect)((()=>{if(!e||!e.current)return;const t=e.current,o=e=>{const t=e.target.closest("span[data-rich-text-comment]");if(t){const e=t.innerText.replace(/^\[|\]$/g,"");m(e),u(e),c(t),a(!0)}};return t.addEventListener("click",o),()=>{t.removeEventListener("click",o)}}),[e]),(0,n.jsx)(n.Fragment,{children:o&&l&&(0,n.jsx)(s.Popover,{position:"bottom right",onClose:()=>a(!1),anchor:l,className:"woocommerce-personalization-tag-popover",children:(0,n.jsxs)("div",{className:"woocommerce-personalization-tag-popover-content",children:[(0,n.jsx)(s.TextControl,{label:(0,i.__)("Personalization Tag","woocommerce"),value:d,onChange:e=>u(e),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0}),(0,n.jsxs)("div",{className:"woocommerce-personalization-tag-popover-content-buttons",children:[(0,n.jsx)(s.Button,{isTertiary:!0,onClick:()=>{a(!1)},children:(0,i.__)("Cancel","woocommerce")}),(0,n.jsx)(s.Button,{isPrimary:!0,onClick:()=>{t(p,d),a(!1)},children:(0,i.__)("Update","woocommerce")})]})]})})})}},46042:(e,t,o)=>{o.d(t,{D:()=>s,E:()=>r});var n=o(50876);const r=(e,t)=>{const o=e.current.ownerDocument.defaultView.getSelection();if(!o.rangeCount)return{start:0,end:0};const r=o.getRangeAt(0);if(null===o.anchorNode.previousSibling)return{start:o.anchorOffset,end:o.anchorOffset+r.toString().length};const s=(0,n.create)({html:t});let i=o.anchorNode.previousSibling;i=function(e){let t=e;for(;t&&t?.children?.length>0;)t=t.children[0];return t}(i);const a=function(e,t){let o=null;for(const[n,r]of t.entries())if(r)for(const t of r)t?.attributes&&e.tagName.toLowerCase()===t.tagName?.toLowerCase()&&e.getAttribute("data-link-href")===t?.attributes["data-link-href"]&&(o=n);return o}(i,s.formats);if(null!==a)return{start:a+o.anchorOffset+1,end:a+o.anchorOffset+r.toString().length};const l=function(e,t){for(const[o,n]of t.entries()){if(!n)continue;const{attributes:t}=n;if(e.getAttribute("data-rich-text-comment")===t["data-rich-text-comment"])return o}return null}(i,s.replacements);return null!==l?{start:l+o.anchorOffset+1,end:l+o.anchorOffset+r.toString().length}:{start:s.text.length,end:s.text.length+r.toString().length}},s=(e,t)=>(t.forEach((t=>{if(!e.includes(t.token.slice(0,t.token.length-1)))return;const o=t.token.substring(1,t.token.length-1).replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`(?<!\x3c!--)(?<!["'])\\[(${o}(\\s[^\\]]*)?)\\](?!--\x3e)`,"g");e=e.replace(n,(e=>`\x3c!--${e}--\x3e`))})),e)},46296:(e,t,o)=>{o.d(t,{O:()=>h});var n=o(39793),r=o(56427),s=o(47143),i=o(86087),a=o(50876),l=o(94715),c=o(27723),d=o(2071),u=o(46042),p=o(58039),m=o(91948),g=o(59191);function h({label:e,labelSuffix:t,help:o,placeholder:h,attributeName:_,attributeValue:f,updateProperty:y=()=>{}}){const[w,x]=(0,i.useState)(null),[b,v]=(0,i.useState)(!1),S=(0,s.useSelect)((e=>e(p.H).getPersonalizationTagsList()),[]),k=(0,i.useRef)(null),j=(0,i.useCallback)(((e,t,o)=>{var n,r;const s=null!==(n=o?.start)&&void 0!==n?n:t.length,i=null!==(r=o?.end)&&void 0!==r?r:t.length;let l=(0,a.create)({html:t});l=(0,a.insert)(l,(0,a.create)({html:`\x3c!--${e}--\x3e`}),s,i);const c=(0,a.toHTMLString)({value:l});y(_,c),x(null)}),[_,y]),E=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("span",{children:e}),(0,n.jsx)(r.Button,{className:"woocommerce-settings-panel-personalization-tags-button",icon:"shortcode",title:(0,c.__)("Personalization Tags","woocommerce"),onClick:()=>{v(!0),(0,g.yM)("rich_text_with_button_personalization_tags_shortcode_icon_clicked",{attributeName:_,label:e})}}),t]});return _?(0,n.jsxs)(r.BaseControl,{id:"",label:E,className:`woocommerce-settings-panel-${_}-text`,help:o,__nextHasNoMarginBottom:!0,children:[(0,n.jsx)(d.x,{isOpened:b,onInsert:e=>{j(e,null!=f?f:"",w),v(!1),(0,g.yM)("rich_text_with_button_personalization_tags_inserted",{attributeName:_,value:e})},closeCallback:()=>v(!1),openedBy:"RichTextWithButton-BaseControl"}),(0,n.jsx)(m.t,{contentRef:k,onUpdate:(e,t)=>{const o=(null!=f?f:"").replace(`\x3c!--[${e}]--\x3e`,`\x3c!--[${t}]--\x3e`);y(_,o)}}),(0,n.jsx)(l.RichText,{ref:k,className:"woocommerce-settings-panel-richtext",placeholder:h,onFocus:()=>{x((0,u.E)(k,null!=f?f:""))},onKeyUp:()=>{x((0,u.E)(k,null!=f?f:""))},onClick:()=>{x((0,u.E)(k,null!=f?f:""))},onChange:e=>{var t;e=(0,u.D)(null!==(t=e)&&void 0!==t?t:"",S),y(_,e),(0,g.xW)("rich_text_with_button_input_field_updated",{attributeName:_})},value:null!=f?f:"","data-automation-id":`email_${_}`})]}):null}},30221:(e,t,o)=>{o.d(t,{P:()=>f});var n=o(39793),r=o(56427),s=o(47143),i=o(24148),a=o(5573);const l=(0,n.jsx)(a.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,n.jsx)(a.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})});var c=o(27723),d=o(86087),u=o(48558);const p=window.wp.url;var m=o(52619),g=o(58039),h=o(49851),_=o(59191);const f=(0,d.memo)((function(){const e=(0,d.useRef)(null),{requestSendingNewsletterPreview:t,togglePreviewModal:o,updateSendPreviewEmail:a}=(0,s.useDispatch)(g.H),{toEmail:f,isSendingPreviewEmail:y,sendingPreviewStatus:w,isModalOpened:x,errorMessage:b,postType:v}=(0,s.useSelect)((e=>({...e(g.H).getPreviewState(),postType:e(g.H).getEmailPostType()})),[]),S=()=>{t(f)},k=(0,d.useMemo)((()=>(0,m.applyFilters)("woocommerce_email_editor_check_sending_method_configuration_link",`https://www.mailpoet.com/blog/mailpoet-smtp-plugin/?utm_source=woocommerce_email_editor&utm_medium=plugin&utm_source_platform=${v}`)),[v]),j=()=>{(0,_.yM)("send_preview_email_modal_closed"),o(!1)};return(0,d.useEffect)((()=>{x&&(e.current?.focus(),(0,_.yM)("send_preview_email_modal_opened"))}),[x]),x?(0,n.jsxs)(r.Modal,{className:"woocommerce-send-preview-email",title:(0,c.__)("Send a test email","woocommerce"),onRequestClose:j,focusOnMount:!1,children:[w===h.T.ERROR?(0,n.jsxs)("div",{className:"woocommerce-send-preview-modal-notice-error",children:[(0,n.jsx)("p",{children:(0,c.__)("Sorry, we were unable to send this email.","woocommerce")}),(0,n.jsx)("strong",{children:b&&(0,c.sprintf)((0,c.__)("Error: %s","woocommerce"),b)}),(0,n.jsxs)("ul",{children:[(0,n.jsx)("li",{children:k&&(0,d.createInterpolateElement)((0,c.__)("Please check your <link>sending method configuration</link> with your hosting provider.","woocommerce"),{link:(0,n.jsx)("a",{href:k,target:"_blank",rel:"noopener noreferrer",onClick:()=>(0,_.yM)("send_preview_email_modal_check_sending_method_configuration_link_clicked")})})}),(0,n.jsx)("li",{children:(0,d.createInterpolateElement)((0,c.__)("Or, sign up for MailPoet Sending Service to easily send emails. <link>Sign up for free</link>","woocommerce"),{link:(0,n.jsx)("a",{href:`https://account.mailpoet.com/?s=1&g=1&utm_source=woocommerce_email_editor&utm_medium=plugin&utm_source_platform=${v}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>(0,_.yM)("send_preview_email_modal_sign_up_for_mailpoet_sending_service_link_clicked")},"sign-up-for-free")})})]})]}):null,(0,n.jsx)("p",{children:(0,c.__)("Send yourself a test email to test how your email would look like in different email apps.","woocommerce")}),(0,n.jsx)(r.TextControl,{label:(0,c.__)("Send to","woocommerce"),onChange:e=>{a(e),(0,_.xW)("send_preview_email_modal_send_to_field_updated")},onKeyDown:e=>{const{keyCode:t}=e;t===u.ENTER&&(e.preventDefault(),S(),(0,_.yM)("send_preview_email_modal_send_to_field_key_code_enter"))},className:"woocommerce-send-preview-email__send-to-field",value:f,type:"email",ref:e,required:!0,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),w===h.T.SUCCESS?(0,n.jsxs)("p",{className:"woocommerce-send-preview-modal-notice-success",children:[(0,n.jsx)(i.A,{icon:l,style:{fill:"#4AB866"}}),(0,c.__)("Test email sent successfully!","woocommerce")]}):null,(0,n.jsxs)("div",{className:"woocommerce-send-preview-modal-footer",children:[(0,n.jsx)(r.Button,{variant:"tertiary",onClick:()=>{(0,_.yM)("send_preview_email_modal_close_button_clicked"),j()},children:(0,c.__)("Cancel","woocommerce")}),(0,n.jsx)(r.Button,{variant:"primary",onClick:()=>{S(),(0,_.yM)("send_preview_email_modal_send_test_email_button_clicked")},disabled:y||!(0,p.isEmail)(f),children:y?(0,c.__)("Sending…","woocommerce"):(0,c.__)("Send test email","woocommerce")})]})]}):null}))},94723:(e,t,o)=>{o.d(t,{G:()=>s,h:()=>i});var n=o(74997);const r=new Map;function s(e,t){const o=(0,n.getBlockType)(e);if(!o)return!1;const{name:s,...i}=o;try{r.has(s)||r.set(s,{...i});const e=t(i),o={...i,...e};return(0,n.unregisterBlockType)(s),(0,n.registerBlockType)(s,o),!0}catch(t){return console.error("Failed to update block settings for",e,t),!1}}function i(){const e=[];for(const[t,o]of r.entries())try{(0,n.unregisterBlockType)(t),(0,n.registerBlockType)(t,o),e.push(t),r.delete(t)}catch(e){console.error("Failed to restore block settings for",t,e)}return e}},93524:(e,t,o)=>{o.d(t,{oj:()=>a,r8:()=>l});var n=o(74997),r=o(47143);const s=new Set,i=new Map;function a(e,t){const o=((0,r.select)("core/blocks").getBlockStyles(e)||[]).find((e=>e.name===t));if(o){const n=i.get(e)||[];n.find((e=>e.name===t))||(n.push(o),i.set(e,n))}(0,n.unregisterBlockStyle)(e,t)}function l(){for(const e of s){const[t,o]=e.split("||");(0,n.unregisterBlockStyle)(t,o)}s.clear();for(const[e,t]of i.entries())t.forEach((t=>(0,n.registerBlockStyle)(e,t))),i.delete(e)}},43583:(e,t,o)=>{o.d(t,{$:()=>i,z:()=>s});var n=o(74997);const r=new Set;function s(e,t){(0,n.registerBlockVariation)(e,t),r.add(function(e,t){return`${e}||${t}`}(e,t.name))}function i(){for(const e of r){const[t,o]=e.split("||");(0,n.unregisterBlockVariation)(t,o)}r.clear()}},56554:(e,t,o)=>{o.d(t,{HY:()=>a,hC:()=>c,tN:()=>l});var n=o(52619);const r=new Set,s=new Set;function i(e,t){return`${e}||${t}`}function a(e,t,o,s){(0,n.addFilter)(e,t,o,s),r.add(i(e,t))}function l(e,t,o,r){(0,n.addAction)(e,t,o,r),s.add(i(e,t))}function c(){!function(){for(const e of r){const[t,o]=e.split("||");(0,n.removeFilter)(t,o),r.delete(e)}}(),function(){for(const e of s){const[t,o]=e.split("||");(0,n.removeAction)(t,o),s.delete(e)}}()}},16205:(e,t,o)=>{o.d(t,{aW:()=>l,gG:()=>i,le:()=>a});var n=o(50876);const r=new Set,s=new Map;function i(e,t){(0,n.registerFormatType)(e,t),r.add(e)}function a(e){const t=(0,n.unregisterFormatType)(e);t&&s.set(e,t)}function l(){for(const e of r)(0,n.unregisterFormatType)(e);r.clear();for(const[e,t]of s.entries())(0,n.registerFormatType)(e,t),s.delete(e)}},46701:(e,t,o)=>{o.d(t,{IF:()=>l});var n=o(93524),r=o(43583),s=o(16205),i=o(56554),a=o(94723);function l(){(0,a.h)(),(0,n.r8)(),(0,r.$)(),(0,s.aW)(),(0,i.hC)()}},59191:(e,t,o)=>{o.d(t,{T7:()=>d,V1:()=>s,oh:()=>a,vD:()=>i,xW:()=>c,yM:()=>l});var n=o(66087),r=o(52619);const s=()=>(0,r.applyFilters)("woocommerce_email_editor_events_tracking_enabled",!1),i="email_editor_events",a=new EventTarget,l=(e,t={})=>{if(!s())return;const o={name:`${i}_${e}`,..."object"!=typeof t?{data:t}:t};a.dispatchEvent(new CustomEvent(i,{detail:o}))},c=function(){const e={};return(t,o={})=>{if(!s())return;const n=`${t}_${JSON.stringify(o).length}`;e[n]||(l(t,o),e[n]=!0)}}(),d=(0,n.debounce)(l,700)},14731:(e,t,o)=>{o.d(t,{b:()=>xe});var n=o(86087),r=o(47143),s=o(43656),i=o(76597),a=o.n(i),l=o(58039),c=o(71646),d=o(74997);const u=window.wp.styleEngine;function p(e,t={}){if("string"!=typeof e&&"number"!=typeof e)return null;isFinite(e)&&(e=`${e}px`);const{coerceTo:o,rootSizeValue:n,acceptableUnits:r}={coerceTo:"",rootSizeValue:16,acceptableUnits:["rem","px","em"],...t},s=r?.join("|"),i=new RegExp(`^(\\d*\\.?\\d+)(${s}){1,1}$`),a=e.toString().match(i);if(!a||a.length<3)return null;let[,l,c]=a,d=parseFloat(l);return"px"!==o||"em"!==c&&"rem"!==c||(d*=n,c=o),"px"!==c||"em"!==o&&"rem"!==o||(d/=n,c=o),"em"!==o&&"rem"!==o||"em"!==c&&"rem"!==c||(c=o),c?{value:m(d,3),unit:c}:null}function m(e,t=3){const o=Math.pow(10,t);return Math.round(e*o)/o}function g(e){const t=e?.fluid;return!0===t||t&&"object"==typeof t&&Object.keys(t).length>0}function h(e,t){const{size:o}=e;if(!o||"0"===o||!1===e?.fluid)return o;if(!g(t?.typography)&&!g(e))return o;const n=function(e){const t=e?.typography??{},o=e?.layout,n=p(o?.wideSize)?o?.wideSize:null;return g(t)&&n?{fluid:{maxViewportWidth:n,..."object"==typeof t.fluid?t.fluid:{}}}:{fluid:t?.fluid}}(t)?.fluid??{};return function({minimumFontSize:e,maximumFontSize:t,fontSize:o,minimumViewportWidth:n="320px",maximumViewportWidth:r="1600px",scaleFactor:s=1,minimumFontSizeLimit:i}){if(i=p(i)?i:"14px",o){const n=p(o);if(!n?.unit||!n?.value)return null;const r=p(i,{coerceTo:n.unit});if(r?.value&&!e&&!t&&n?.value<=r?.value)return null;if(t||(t=`${n.value}${n.unit}`),!e){const t="px"===n.unit?n.value:16*n.value,o=Math.min(Math.max(1-.075*Math.log2(t),.25),.75),s=m(n.value*o,3);e=r?.value&&s<r?.value?`${r.value}${r.unit}`:`${s}${n.unit}`}}const a=p(e),l=a?.unit||"rem",c=p(t,{coerceTo:l});if(!a||!c)return null;const d=p(e,{coerceTo:"rem"}),u=p(r,{coerceTo:l}),g=p(n,{coerceTo:l});if(!u||!g||!d)return null;const h=u.value-g.value;if(!h)return null;const _=m(g.value/100,3),f=m(_,3)+l,y=m(((c.value-a.value)/h*100||1)*s,3);return`clamp(${e}, ${d.value}${d.unit} + ((1vw - ${f}) * ${y}), ${t})`}({minimumFontSize:"boolean"==typeof e?.fluid?void 0:e?.fluid?.min,maximumFontSize:"boolean"==typeof e?.fluid?void 0:e?.fluid?.max,fontSize:o,minimumFontSizeLimit:"object"==typeof n?n?.minFontSize:void 0,maximumViewportWidth:"object"==typeof n?n?.maxViewportWidth:void 0,minimumViewportWidth:"object"==typeof n?n?.minViewportWidth:void 0})||o}function _(e,t,o){t=Array.isArray(t)?[...t]:[t],e=Array.isArray(e)?[...e]:{...e};const n=t.pop();let r=e;for(const e of t){const t=r[e];r=r[e]=Array.isArray(t)?[...t]:{...t}}return r[n]=o,e}var f=(e,t,o)=>{const n=Array.isArray(t)?t:t.split(".");let r=e;return n.forEach((e=>{r=r?.[e]})),r??o},y="body",w=":root",x=[{path:["color","palette"],valueKey:"color",cssVarInfix:"color",classes:[{classSuffix:"color",propertyName:"color"},{classSuffix:"background-color",propertyName:"background-color"},{classSuffix:"border-color",propertyName:"border-color"}]},{path:["color","gradients"],valueKey:"gradient",cssVarInfix:"gradient",classes:[{classSuffix:"gradient-background",propertyName:"background"}]},{path:["color","duotone"],valueKey:"colors",cssVarInfix:"duotone",valueFunc:({slug:e})=>`url( '#wp-duotone-${e}' )`,classes:[]},{path:["shadow","presets"],valueKey:"shadow",cssVarInfix:"shadow",classes:[]},{path:["typography","fontSizes"],valueFunc:(e,t)=>h(e,t),valueKey:"size",cssVarInfix:"font-size",classes:[{classSuffix:"font-size",propertyName:"font-size"}]},{path:["typography","fontFamilies"],valueKey:"fontFamily",cssVarInfix:"font-family",classes:[{classSuffix:"font-family",propertyName:"font-family"}]},{path:["spacing","spacingSizes"],valueKey:"size",cssVarInfix:"spacing",valueFunc:({size:e})=>e,classes:[]},{path:["border","radiusSizes"],valueKey:"size",cssVarInfix:"border-radius",classes:[]}];function b(e,t){if(!e||!t)return t;const o=e.split(","),n=t.split(","),r=[];return o.forEach((e=>{n.forEach((t=>{r.push(`${e.trim()} ${t.trim()}`)}))})),r.join(", ")}function v(e,t){if(!e||!t)return e;const o=function(e,t){if(!e||!t)return e;if("object"==typeof e&&"ref"in e&&e?.ref){const o=(0,u.getCSSValueFromRawStyle)(f(t,e.ref));if("object"==typeof o&&null!==o&&"ref"in o&&o?.ref)return;return void 0===o?e:o}return e}(e,t);return"object"==typeof o&&null!==o&&"url"in o&&o?.url&&(o.url=function(e,t){if(!e||!t||!Array.isArray(t))return e;const o=t.find((t=>t?.name===e));return o?.href?o?.href:e}(o.url,t?._links?.["wp:theme-file"])),o}function S(e,t="root",o={}){if(!t)return null;const{fallback:n=!1}=o,{name:r,selectors:s,supports:i}=e,a=s&&Object.keys(s).length>0,l=Array.isArray(t)?t.join("."):t;let c=null;if(c=a&&s.root?s?.root:i?.__experimentalSelector?i.__experimentalSelector:".wp-block-"+r.replace("core/","").replace("/","-"),"root"===l)return c;const d=Array.isArray(t)?t:t.split(".");if(1===d.length){const e=n?c:null;if(a)return f(s,`${l}.root`,null)||f(s,l,null)||e;const t=i?f(i,`${l}.__experimentalSelector`,null):void 0;return t?b(c,t):e}let u;return a&&(u=f(s,l,null)),u||(n?S(e,d[0],o):null)}var k={grad:.9,turn:360,rad:360/(2*Math.PI)},j=function(e){return"string"==typeof e?e.length>0:"number"==typeof e},E=function(e,t,o){return void 0===t&&(t=0),void 0===o&&(o=Math.pow(10,t)),Math.round(o*e)/o+0},T=function(e,t,o){return void 0===t&&(t=0),void 0===o&&(o=1),e>o?o:e>t?e:t},C=function(e){return(e=isFinite(e)?e%360:0)>0?e:e+360},M=function(e){return{r:T(e.r,0,255),g:T(e.g,0,255),b:T(e.b,0,255),a:T(e.a)}},P=function(e){return{r:E(e.r),g:E(e.g),b:E(e.b),a:E(e.a,3)}},N=/^#([0-9a-f]{3,8})$/i,I=function(e){var t=e.toString(16);return t.length<2?"0"+t:t},B=function(e){var t=e.r,o=e.g,n=e.b,r=e.a,s=Math.max(t,o,n),i=s-Math.min(t,o,n),a=i?s===t?(o-n)/i:s===o?2+(n-t)/i:4+(t-o)/i:0;return{h:60*(a<0?a+6:a),s:s?i/s*100:0,v:s/255*100,a:r}},$=function(e){var t=e.h,o=e.s,n=e.v,r=e.a;t=t/360*6,o/=100,n/=100;var s=Math.floor(t),i=n*(1-o),a=n*(1-(t-s)*o),l=n*(1-(1-t+s)*o),c=s%6;return{r:255*[n,a,i,i,l,n][c],g:255*[l,n,n,a,i,i][c],b:255*[i,i,l,n,n,a][c],a:r}},z=function(e){return{h:C(e.h),s:T(e.s,0,100),l:T(e.l,0,100),a:T(e.a)}},H=function(e){return{h:E(e.h),s:E(e.s),l:E(e.l),a:E(e.a,3)}},R=function(e){return $((o=(t=e).s,{h:t.h,s:(o*=((n=t.l)<50?n:100-n)/100)>0?2*o/(n+o)*100:0,v:n+o,a:t.a}));var t,o,n},F=function(e){return{h:(t=B(e)).h,s:(r=(200-(o=t.s))*(n=t.v)/100)>0&&r<200?o*n/100/(r<=100?r:200-r)*100:0,l:r/2,a:t.a};var t,o,n,r},L=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,A=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,O=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,V=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,D={string:[[function(e){var t=N.exec(e);return t?(e=t[1]).length<=4?{r:parseInt(e[0]+e[0],16),g:parseInt(e[1]+e[1],16),b:parseInt(e[2]+e[2],16),a:4===e.length?E(parseInt(e[3]+e[3],16)/255,2):1}:6===e.length||8===e.length?{r:parseInt(e.substr(0,2),16),g:parseInt(e.substr(2,2),16),b:parseInt(e.substr(4,2),16),a:8===e.length?E(parseInt(e.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(e){var t=O.exec(e)||V.exec(e);return t?t[2]!==t[4]||t[4]!==t[6]?null:M({r:Number(t[1])/(t[2]?100/255:1),g:Number(t[3])/(t[4]?100/255:1),b:Number(t[5])/(t[6]?100/255:1),a:void 0===t[7]?1:Number(t[7])/(t[8]?100:1)}):null},"rgb"],[function(e){var t=L.exec(e)||A.exec(e);if(!t)return null;var o,n,r=z({h:(o=t[1],n=t[2],void 0===n&&(n="deg"),Number(o)*(k[n]||1)),s:Number(t[3]),l:Number(t[4]),a:void 0===t[5]?1:Number(t[5])/(t[6]?100:1)});return R(r)},"hsl"]],object:[[function(e){var t=e.r,o=e.g,n=e.b,r=e.a,s=void 0===r?1:r;return j(t)&&j(o)&&j(n)?M({r:Number(t),g:Number(o),b:Number(n),a:Number(s)}):null},"rgb"],[function(e){var t=e.h,o=e.s,n=e.l,r=e.a,s=void 0===r?1:r;if(!j(t)||!j(o)||!j(n))return null;var i=z({h:Number(t),s:Number(o),l:Number(n),a:Number(s)});return R(i)},"hsl"],[function(e){var t=e.h,o=e.s,n=e.v,r=e.a,s=void 0===r?1:r;if(!j(t)||!j(o)||!j(n))return null;var i=function(e){return{h:C(e.h),s:T(e.s,0,100),v:T(e.v,0,100),a:T(e.a)}}({h:Number(t),s:Number(o),v:Number(n),a:Number(s)});return $(i)},"hsv"]]},G=function(e,t){for(var o=0;o<t.length;o++){var n=t[o][0](e);if(n)return[n,t[o][1]]}return[null,void 0]},W=function(e,t){var o=F(e);return{h:o.h,s:T(o.s+100*t,0,100),l:o.l,a:o.a}},U=function(e){return(299*e.r+587*e.g+114*e.b)/1e3/255},q=function(e,t){var o=F(e);return{h:o.h,s:o.s,l:T(o.l+100*t,0,100),a:o.a}},Y=function(){function e(e){this.parsed=function(e){return"string"==typeof e?G(e.trim(),D.string):"object"==typeof e&&null!==e?G(e,D.object):[null,void 0]}(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return e.prototype.isValid=function(){return null!==this.parsed},e.prototype.brightness=function(){return E(U(this.rgba),2)},e.prototype.isDark=function(){return U(this.rgba)<.5},e.prototype.isLight=function(){return U(this.rgba)>=.5},e.prototype.toHex=function(){return t=(e=P(this.rgba)).r,o=e.g,n=e.b,s=(r=e.a)<1?I(E(255*r)):"","#"+I(t)+I(o)+I(n)+s;var e,t,o,n,r,s},e.prototype.toRgb=function(){return P(this.rgba)},e.prototype.toRgbString=function(){return t=(e=P(this.rgba)).r,o=e.g,n=e.b,(r=e.a)<1?"rgba("+t+", "+o+", "+n+", "+r+")":"rgb("+t+", "+o+", "+n+")";var e,t,o,n,r},e.prototype.toHsl=function(){return H(F(this.rgba))},e.prototype.toHslString=function(){return t=(e=H(F(this.rgba))).h,o=e.s,n=e.l,(r=e.a)<1?"hsla("+t+", "+o+"%, "+n+"%, "+r+")":"hsl("+t+", "+o+"%, "+n+"%)";var e,t,o,n,r},e.prototype.toHsv=function(){return e=B(this.rgba),{h:E(e.h),s:E(e.s),v:E(e.v),a:E(e.a,3)};var e},e.prototype.invert=function(){return J({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},e.prototype.saturate=function(e){return void 0===e&&(e=.1),J(W(this.rgba,e))},e.prototype.desaturate=function(e){return void 0===e&&(e=.1),J(W(this.rgba,-e))},e.prototype.grayscale=function(){return J(W(this.rgba,-1))},e.prototype.lighten=function(e){return void 0===e&&(e=.1),J(q(this.rgba,e))},e.prototype.darken=function(e){return void 0===e&&(e=.1),J(q(this.rgba,-e))},e.prototype.rotate=function(e){return void 0===e&&(e=15),this.hue(this.hue()+e)},e.prototype.alpha=function(e){return"number"==typeof e?J({r:(t=this.rgba).r,g:t.g,b:t.b,a:e}):E(this.rgba.a,3);var t},e.prototype.hue=function(e){var t=F(this.rgba);return"number"==typeof e?J({h:e,s:t.s,l:t.l,a:t.a}):E(t.h)},e.prototype.isEqual=function(e){return this.toHex()===J(e).toHex()},e}(),J=function(e){return e instanceof Y?e:new Y(e)};function K(e){return e.replace(/([a-z])([A-Z])/g,"$1-$2").replace(/([0-9])([a-zA-Z])/g,"$1-$2").replace(/([a-zA-Z])([0-9])/g,"$1-$2").replace(/[\s_]+/g,"-").toLowerCase()}function Z(e){if(!e)return;const t=e.match(/var:preset\|spacing\|(.+)/);return t?`var(--wp--preset--spacing--${t[1]})`:e}function X(e,t="0"){const o=function(e){if(!e)return null;const t="string"==typeof e;return{top:t?e:e?.top,left:t?e:e?.left}}(e);if(!o)return null;const n=Z(o?.top)||t,r=Z(o?.left)||t;return n===r?n:`${n} ${r}`}function Q(e){if(!e||!e?.backgroundImage?.url)return;let t;return e?.backgroundSize||(t={backgroundSize:"cover"}),"contain"!==e?.backgroundSize||e?.backgroundPosition||(t={backgroundPosition:"50% 50%"}),t}var ee={default:{name:"default",slug:"flow",className:"is-layout-flow",baseStyles:[{selector:" > .alignleft",rules:{float:"left","margin-inline-start":"0","margin-inline-end":"2em"}},{selector:" > .alignright",rules:{float:"right","margin-inline-start":"2em","margin-inline-end":"0"}},{selector:" > .aligncenter",rules:{"margin-left":"auto !important","margin-right":"auto !important"}}],spacingStyles:[{selector:" > :first-child",rules:{"margin-block-start":"0"}},{selector:" > :last-child",rules:{"margin-block-end":"0"}},{selector:" > *",rules:{"margin-block-start":null,"margin-block-end":"0"}}]},constrained:{name:"constrained",slug:"constrained",className:"is-layout-constrained",baseStyles:[{selector:" > .alignleft",rules:{float:"left","margin-inline-start":"0","margin-inline-end":"2em"}},{selector:" > .alignright",rules:{float:"right","margin-inline-start":"2em","margin-inline-end":"0"}},{selector:" > .aligncenter",rules:{"margin-left":"auto !important","margin-right":"auto !important"}},{selector:" > :where(:not(.alignleft):not(.alignright):not(.alignfull))",rules:{"max-width":"var(--wp--style--global--content-size)","margin-left":"auto !important","margin-right":"auto !important"}},{selector:" > .alignwide",rules:{"max-width":"var(--wp--style--global--wide-size)"}}],spacingStyles:[{selector:" > :first-child",rules:{"margin-block-start":"0"}},{selector:" > :last-child",rules:{"margin-block-end":"0"}},{selector:" > *",rules:{"margin-block-start":null,"margin-block-end":"0"}}]},flex:{name:"flex",slug:"flex",className:"is-layout-flex",displayMode:"flex",baseStyles:[{selector:"",rules:{"flex-wrap":"wrap","align-items":"center"}},{selector:" > :is(*, div)",rules:{margin:"0"}}],spacingStyles:[{selector:"",rules:{gap:null}}]},grid:{name:"grid",slug:"grid",className:"is-layout-grid",displayMode:"grid",baseStyles:[{selector:" > :is(*, div)",rules:{margin:"0"}}],spacingStyles:[{selector:"",rules:{gap:null}}]}},te=["appearanceTools","useRootPaddingAwareAlignments","background.backgroundImage","background.backgroundRepeat","background.backgroundSize","background.backgroundPosition","border.color","border.radius","border.radiusSizes","border.style","border.width","shadow.presets","shadow.defaultPresets","color.background","color.button","color.caption","color.custom","color.customDuotone","color.customGradient","color.defaultDuotone","color.defaultGradients","color.defaultPalette","color.duotone","color.gradients","color.heading","color.link","color.palette","color.text","custom","dimensions.aspectRatio","dimensions.minHeight","dimensions.width","layout.contentSize","layout.definitions","layout.wideSize","lightbox.enabled","lightbox.allowEditing","position.fixed","position.sticky","spacing.customSpacingSize","spacing.defaultSpacingSizes","spacing.spacingSizes","spacing.spacingScale","spacing.blockGap","spacing.margin","spacing.padding","spacing.units","typography.fluid","typography.customFontSize","typography.defaultFontSizes","typography.dropCap","typography.fontFamilies","typography.fontSizes","typography.fontStyle","typography.fontWeight","typography.letterSpacing","typography.lineHeight","typography.textAlign","typography.textColumns","typography.textDecoration","typography.textTransform","typography.writingMode"],oe={button:"wp-element-button",caption:"wp-element-caption"},ne={__experimentalBorder:"border",color:"color",dimensions:"dimensions",spacing:"spacing",typography:"typography"};function re(e={},t,o){let n=[];return Object.keys(e).forEach((r=>{const s=t+K(r.replace("/","-")),i=e[r];if(i instanceof Object){const e=s+o;n=[...n,...re(i,e,o)]}else n.push(`${s}: ${i}`)})),n}var se=(e,t)=>{const o={};return Object.entries(e).forEach((([e,n])=>{if("root"===e||!t?.[e])return;const r="string"==typeof n;if(r||"object"!=typeof n||null===n||Object.entries(n).forEach((([n,r])=>{if("root"===n||!t?.[e][n])return;const s=ie({[e]:{[n]:t[e][n]}});o[r]=[...o[r]||[],...s],delete t[e][n]})),r||"object"==typeof n&&null!==n&&"root"in n){const s=r?n:n.root,i=ie({[e]:t[e]});o[s]=[...o[s]||[],...i],delete t[e]}})),o};function ie(e={},t="",o,n={},r=!1){const s=y===t,i=Object.entries(d.__EXPERIMENTAL_STYLE_PROPERTY).reduce(((t,[n,{value:r,properties:i,useEngine:a,rootOnly:l}])=>{if(l&&!s)return t;const c=r;if("elements"===c[0]||a)return t;const d=f(e,c);if("--wp--style--root--padding"===n&&("string"==typeof d||!o))return t;if(i&&"string"!=typeof d)Object.entries(i).forEach((e=>{const[o,n]=e;if(!f(d,[n],!1))return;const r=o.startsWith("--")?o:K(o);t.push(`${r}: ${(0,u.getCSSValueFromRawStyle)(f(d,[n]))}`)}));else if(f(e,c,!1)){const o=n.startsWith("--")?n:K(n);t.push(`${o}: ${(0,u.getCSSValueFromRawStyle)(f(e,c))}`)}return t}),[]);return e.background&&(e.background?.backgroundImage&&(e.background.backgroundImage=v(e.background.backgroundImage,n)),!s&&e.background?.backgroundImage?.id&&(e={...e,background:{...e.background,...Q(e.background)}})),(0,u.getCSSRules)(e).forEach((e=>{if(s&&(o||r)&&e.key.startsWith("padding"))return;const t=e.key.startsWith("--")?e.key:K(e.key);let a=v(e.value,n);"font-size"===t&&(a=h({name:"",slug:"",size:a},n?.settings)),"aspect-ratio"===t&&i.push("min-height: unset"),i.push(`${t}: ${a}`)})),i}var ae=["border","color","dimensions","spacing","typography","filter","outline","shadow","background"];function le(e){if(!e)return{};const t=Object.entries(e).filter((([e])=>ae.includes(e))).map((([e,t])=>[e,JSON.parse(JSON.stringify(t))]));return Object.fromEntries(t)}var ce=(e,t)=>{const o=[];if(!e?.settings)return o;const n=e=>{let t={};return x.forEach((({path:o})=>{const n=f(e,o,!1);!1!==n&&(t=_(t,o,n))})),t},r=n(e.settings),s=e.settings?.custom;return(Object.keys(r).length>0||s)&&o.push({presets:r,custom:s,selector:w}),Object.entries(e.settings?.blocks??{}).forEach((([e,r])=>{const s=r.custom;if("string"==typeof t||!t[e])return;const i=n(r);(Object.keys(i).length>0||s)&&o.push({presets:i,custom:s,selector:t[e]?.selector})})),o},de=(e,t)=>{const o=ce(e,t);let n="";return o.forEach((({presets:t,custom:o,selector:r})=>{const s=e?.settings?function(e={},t){return x.reduce(((o,{path:n,valueKey:r,valueFunc:s,cssVarInfix:i})=>{const a=f(e,n,[]);return["default","theme","custom"].forEach((e=>{a[e]&&a[e].forEach((e=>{r&&!s?o.push(`--wp--preset--${i}--${K(e.slug)}: ${e[r]}`):s&&"function"==typeof s&&o.push(`--wp--preset--${i}--${K(e.slug)}: ${s(e,t)}`)}))})),o}),[])}(t,e?.settings):[],i=re(o,"--wp--custom--","--");i.length>0&&s.push(...i),s.length>0&&(n+=`${r}{${s.join(";")};}`)})),n},ue=(e,t,o,n,r=!1,s=!1,i={})=>{const a={blockGap:!0,blockStyles:!0,layoutStyles:!0,marginReset:!0,presets:!0,rootPadding:!0,variationStyles:!1,...i},l=((e,t)=>{const o=[];if(!e?.styles)return o;const n=le(e.styles);return n&&o.push({styles:n,selector:y,skipSelectorWrapper:!0}),Object.entries(d.__EXPERIMENTAL_ELEMENTS).forEach((([t,n])=>{e.styles?.elements?.[t]&&o.push({styles:e.styles?.elements?.[t]??{},selector:n,skipSelectorWrapper:!oe[t]})})),Object.entries(e.styles?.blocks??{}).forEach((([e,n])=>{const r=le(n),s=n;if(s?.variations){const n={};Object.entries(s.variations).forEach((([r,s])=>{const i=s;n[r]=le(i),i?.css&&(n[r].css=i.css);const a="string"!=typeof t?t[e]?.styleVariationSelectors?.[r]:void 0;Object.entries(i?.elements??{}).forEach((([e,t])=>{t&&d.__EXPERIMENTAL_ELEMENTS[e]&&o.push({styles:t,selector:b(a,d.__EXPERIMENTAL_ELEMENTS[e])})})),Object.entries(i?.blocks??{}).forEach((([e,n])=>{const r="string"!=typeof t?b(a,t[e]?.selector):void 0,s="string"!=typeof t?b(a,t[e]?.duotoneSelector):void 0,i="string"!=typeof t?function(e,t){if(!e||!t)return;const o={};return Object.entries(t).forEach((([t,n])=>{"string"==typeof n&&(o[t]=b(e,n)),"object"==typeof n&&(o[t]={},Object.entries(n).forEach((([n,r])=>{o[t][n]=b(e,r)})))})),o}(a,t[e]?.featureSelectors??{}):void 0,l=le(n);n?.css&&(l.css=n.css),r&&"string"!=typeof t&&(o.push({selector:r,duotoneSelector:s,featureSelectors:i,fallbackGapValue:t[e]?.fallbackGapValue,hasLayoutSupport:t[e]?.hasLayoutSupport,styles:l}),Object.entries(n.elements??{}).forEach((([e,t])=>{t&&d.__EXPERIMENTAL_ELEMENTS[e]&&o.push({styles:t,selector:b(r,d.__EXPERIMENTAL_ELEMENTS[e])})})))}))})),r.variations=n}"string"!=typeof t&&t?.[e]?.selector&&o.push({duotoneSelector:t[e].duotoneSelector,fallbackGapValue:t[e].fallbackGapValue,hasLayoutSupport:t[e].hasLayoutSupport,selector:t[e].selector,styles:r,featureSelectors:t[e].featureSelectors,styleVariationSelectors:t[e].styleVariationSelectors}),Object.entries(s?.elements??{}).forEach((([n,r])=>{"string"!=typeof t&&r&&t?.[e]&&d.__EXPERIMENTAL_ELEMENTS[n]&&o.push({styles:r,selector:t[e]?.selector.split(",").map((e=>d.__EXPERIMENTAL_ELEMENTS[n].split(",").map((t=>e+" "+t)))).join(",")})}))})),o})(e,t),c=ce(e,t),u=e?.settings?.useRootPaddingAwareAlignments,{contentSize:p,wideSize:m}=e?.settings?.layout||{},g=a.marginReset||a.rootPadding||a.layoutStyles;let h="";if(a.presets&&(p||m)&&(h+=`${w} {`,h=p?h+` --wp--style--global--content-size: ${p};`:h,h=m?h+` --wp--style--global--wide-size: ${m};`:h,h+="}"),g&&(h+=":where(body) {margin: 0;",a.rootPadding&&u&&(h+="padding-right: 0; padding-left: 0; padding-top: var(--wp--style--root--padding-top); padding-bottom: var(--wp--style--root--padding-bottom) }\n\t\t\t\t.has-global-padding { padding-right: var(--wp--style--root--padding-right); padding-left: var(--wp--style--root--padding-left); }\n\t\t\t\t.has-global-padding > .alignfull { margin-right: calc(var(--wp--style--root--padding-right) * -1); margin-left: calc(var(--wp--style--root--padding-left) * -1); }\n\t\t\t\t.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) { padding-right: 0; padding-left: 0; }\n\t\t\t\t.has-global-padding :where(:not(.alignfull.is-layout-flow) > .has-global-padding:not(.wp-block-block, .alignfull)) > .alignfull { margin-left: 0; margin-right: 0;\n\t\t\t\t"),h+="}"),a.blockStyles&&l.forEach((({selector:t,duotoneSelector:i,styles:l,fallbackGapValue:c,hasLayoutSupport:d,featureSelectors:p,styleVariationSelectors:m,skipSelectorWrapper:g})=>{if(p){const e=se(p,l);Object.entries(e).forEach((([e,t])=>{if(t.length){const o=t.join(";");h+=`:root :where(${e}){${o};}`}}))}if(i){const e={};l?.filter&&(e.filter=l.filter,delete l.filter);const t=ie(e);t.length&&(h+=`${i}{${t.join(";")};}`)}r||y!==t&&!d||(h+=function({layoutDefinitions:e=ee,style:t,selector:o,hasBlockGapSupport:n,hasFallbackGapSupport:r,fallbackGapValue:s}){let i="",a=n?X(t?.spacing?.blockGap):"";if(r&&(o===y?a=a||"0.5em":!n&&s&&(a=s)),a&&e&&(Object.values(e).forEach((({className:e,name:t,spacingStyles:r})=>{(n||"flex"===t||"grid"===t)&&r?.length&&r.forEach((t=>{const r=[];if(t.rules&&Object.entries(t.rules).forEach((([e,t])=>{r.push(`${e}: ${t||a}`)})),r.length){let s="";s=n?o===y?`:root :where(.${e})${t?.selector||""}`:`:root :where(${o}-${e})${t?.selector||""}`:o===y?`:where(.${e}${t?.selector||""})`:`:where(${o}.${e}${t?.selector||""})`,i+=`${s} { ${r.join("; ")}; }`}}))})),o===y&&n&&(i+=`${w} { --wp--style--block-gap: ${a}; }`)),o===y&&e){const t=["block","flex","grid"];Object.values(e).forEach((({className:e,displayMode:n,baseStyles:r})=>{n&&t.includes(n)&&(i+=`${o} .${e} { display:${n}; }`),r?.length&&r.forEach((t=>{const o=[];t.rules&&Object.entries(t.rules).forEach((([e,t])=>{o.push(`${e}: ${t}`)})),o.length&&(i+=`.${e}${t?.selector||""} { ${o.join("; ")}; }`)}))}))}return i}({style:l,selector:t,hasBlockGapSupport:o,hasFallbackGapSupport:n,fallbackGapValue:c}));const _=ie(l,t,u,e,s);_?.length&&(h+=`${g?t:`:root :where(${t})`}{${_.join(";")};}`),l?.css&&(h+=me(l.css,`:root :where(${t})`)),a.variationStyles&&m&&Object.entries(m).forEach((([t,o])=>{const n=l?.variations?.[t];if(n){if(p){const e=se(p,n);Object.entries(e).forEach((([e,t])=>{if(t.length){const n=function(e,t){const o=e.split(","),n=[];return o.forEach((e=>{n.push(`${t.trim()}${e.trim()}`)})),n.join(", ")}(e,o),r=t.join(";");h+=`:root :where(${n}){${r};}`}}))}const t=ie(n,o,u,e);t.length&&(h+=`:root :where(${o}){${t.join(";")};}`),n?.css&&(h+=me(n.css,`:root :where(${o})`))}}));const f=Object.entries(l).filter((([e])=>e.startsWith(":")));f?.length&&f.forEach((([e,o])=>{const n=ie(o);if(!n?.length)return;const r=`:root :where(${t.split(",").map((t=>t+e)).join(",")}){${n.join(";")};}`;h+=r}))})),a.layoutStyles&&(h+=".wp-site-blocks > .alignleft { float: left; margin-right: 2em; }",h+=".wp-site-blocks > .alignright { float: right; margin-left: 2em; }",h+=".wp-site-blocks > .aligncenter { justify-content: center; margin-left: auto; margin-right: auto; }"),a.blockGap&&o){const t=X(e?.styles?.spacing?.blockGap)||"0.5em";h+=`:root :where(.wp-site-blocks) > * { margin-block-start: ${t}; margin-block-end: 0; }`,h+=":root :where(.wp-site-blocks) > :first-child { margin-block-start: 0; }",h+=":root :where(.wp-site-blocks) > :last-child { margin-block-end: 0; }"}return a.presets&&c.forEach((({selector:e,presets:t})=>{y!==e&&w!==e||(e="");const o=function(e="*",t={}){return x.reduce(((o,{path:n,cssVarInfix:r,classes:s})=>{if(!s)return o;const i=f(t,n,[]);return["default","theme","custom"].forEach((t=>{i[t]&&i[t].forEach((({slug:t})=>{s.forEach((({classSuffix:n,propertyName:s})=>{const i=`.has-${K(t)}-${n}`,a=e.split(",").map((e=>`${e}${i}`)).join(","),l=`var(--wp--preset--${r}--${K(t)})`;o+=`${a}{${s}: ${l} !important;}`}))}))})),o}),"")}(e,t);o.length>0&&(h+=o)})),h};function pe(e,t){return ce(e,t).flatMap((({presets:e})=>function(e={}){return x.filter((e=>"duotone"===e.path.at(-1))).flatMap((t=>{const o=f(e,t.path,{});return["default","theme"].filter((e=>o[e])).flatMap((e=>o[e].map((e=>function(e,t){const o=function(e=[]){const t={r:[],g:[],b:[],a:[]};return e.forEach((e=>{const o=J(e).toRgb();t.r.push(o.r/255),t.g.push(o.g/255),t.b.push(o.b/255),t.a.push(o.a)})),t}(t);return`\n<svg\n\txmlns:xlink="http://www.w3.org/1999/xlink"\n\tviewBox="0 0 0 0"\n\twidth="0"\n\theight="0"\n\tfocusable="false"\n\trole="none"\n\taria-hidden="true"\n\tstyle="visibility: hidden; position: absolute; left: -9999px; overflow: hidden;"\n>\n\t<defs>\n\t\t<filter id="${e}">\n\t\t\t\x3c!--\n\t\t\t\tUse sRGB instead of linearRGB so transparency looks correct.\n\t\t\t\tUse perceptual brightness to convert to grayscale.\n\t\t\t--\x3e\n\t\t\t<feColorMatrix color-interpolation-filters="sRGB" type="matrix" values=" .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 .299 .587 .114 0 0 "></feColorMatrix>\n\t\t\t\x3c!-- Use sRGB instead of linearRGB to be consistent with how CSS gradients work. --\x3e\n\t\t\t<feComponentTransfer color-interpolation-filters="sRGB">\n\t\t\t\t<feFuncR type="table" tableValues="${o.r.join(" ")}"></feFuncR>\n\t\t\t\t<feFuncG type="table" tableValues="${o.g.join(" ")}"></feFuncG>\n\t\t\t\t<feFuncB type="table" tableValues="${o.b.join(" ")}"></feFuncB>\n\t\t\t\t<feFuncA type="table" tableValues="${o.a.join(" ")}"></feFuncA>\n\t\t\t</feComponentTransfer>\n\t\t\t\x3c!-- Re-mask the image with the original transparency since the feColorMatrix above loses that information. --\x3e\n\t\t\t<feComposite in2="SourceGraphic" operator="in"></feComposite>\n\t\t</filter>\n\t</defs>\n</svg>`}(`wp-duotone-${e.slug}`,e.colors))))).join("")}))}(e)))}function me(e,t){let o="";return e&&""!==e.trim()?(e.split("&").forEach((e=>{var n,r;if(e&&""!==e.trim())if(e.includes("{")){const s=e.replace("}","").split("{");if(2!==s.length)return;const[i,a]=s,l=i.match(/([>+~\s]*::[a-zA-Z-]+)/),c=l?l[1]:"",d=l?i.replace(c,"").trim():i.trim();let u;u=""===d?t:i.startsWith(" ")?b(t,d):(r=d,(n=t).includes(",")?n.split(",").map((e=>e+r)).join(","):n+r),o+=`:root :where(${u})${c}{${a.trim()}}`}else o+=`:root :where(${t}){${e.trim()}}`})),o):o}function ge(e={},t=[],o={}){const{hasBlockGapSupport:n,hasFallbackGapSupport:s,disableLayoutStyles:i=!1,disableRootPadding:a=!1,styleOptions:l={}}=o,c=t.length>0?t:(0,d.getBlockTypes)(),u=function(e,t){const o=t?"."+t:"",n=`settings${o}`;if(t)return f(e,`settings${o}`)??f(e,n);let r={};return te.forEach((t=>{const o=f(e,`settings.${t}`)??f(e,`settings.${t}`);void 0!==o&&(r=_(r,t.split("."),o))})),r}(e,"spacing.blockGap"),p=n??null!==u,m=s??!p;if(!e?.styles||!e?.settings)return[[],{}];const g=function(e){const t=e.styles?.blocks,o=t?.["core/separator"];return o&&o.color?.background&&!o.color?.text&&!o.border?.color?{...e,styles:{...e.styles,blocks:{...t,"core/separator":{...o,color:{...o.color,text:o.color?.background}}}}}:e}(e),h=((e,t)=>{const{getBlockStyles:o}=(0,r.select)(d.store),n={};return e.forEach((e=>{const r=e.name,s=S(e);if(!s)return;let i=S(e,"filter.duotone");if(!i){const t=S(e),o=(0,d.getBlockSupport)(e,"color.__experimentalDuotone",!1);i=o&&t&&b(t,o)}const a=!!e?.supports?.layout||!!e?.supports?.__experimentalLayout,l=e?.supports?.spacing?.blockGap?.__experimentalDefault,c=o(r),u={};c?.forEach((e=>{const o=t?`-${t}`:"",n=`${e.name}${o}`,r=function(e,t){const o=`.is-style-${e}`;if(!t)return o;const n=/((?::\([^)]+\))?\s*)([^\s:]+)/,r=(e,t,n)=>t+n+o;return t.split(",").map((e=>e.replace(n,r))).join(",")}(n,s);u[n]=r}));const p=((e,t)=>{if(e?.selectors&&Object.keys(e.selectors).length>0)return e.selectors;const o={root:t};return Object.entries(ne).forEach((([t,n])=>{const r=S(e,t);r&&(o[n]=r)})),o})(e,s);n[r]={duotoneSelector:i??void 0,fallbackGapValue:l,featureSelectors:Object.keys(p).length?p:void 0,hasLayoutSupport:a,name:r,selector:s,styleVariationSelectors:c?.length?u:void 0}})),n})(c),y=de(g,h),w=ue(g,h,p,m,i,a,l),x=pe(g,h),v=[{css:y,isGlobalStyles:!0},{css:w,isGlobalStyles:!0},{css:g?.styles?.css??"",isGlobalStyles:!0},{assets:x,__unstableType:"svg",isGlobalStyles:!0}];return c.forEach((e=>{const t=g?.styles?.blocks?.[e.name];if(t?.css){const o=h[e.name].selector;v.push({css:me(t.css,o),isGlobalStyles:!0})}})),[v,g.settings]}const he={},_e=[],fe=(e={})=>(0,n.useMemo)((()=>e?.styles&&e?.settings?ge(e,[],{hasBlockGapSupport:!0,hasFallbackGapSupport:!1,disableLayoutStyles:!1,disableRootPadding:!1}):[_e,he]),[e]);var ye=o(5469);const we=[];function xe(){const{userTheme:e}=(0,c.u)(),{editorTheme:t,layout:o,deviceType:i,initialEditorSettingsStyles:d}=(0,r.useSelect)((e=>{const{getEditorSettings:t,getDeviceType:o}=e(s.store),n=t(),r=e(l.H).getInitialEditorSettings();return{editorTheme:e(l.H).getTheme(),layout:n?.__experimentalFeatures?.layout,deviceType:o(),initialEditorSettingsStyles:r?.styles}}),[]),u=(0,n.useMemo)((()=>a().all([{},t||{},e||{}])),[t,e]),[p]=fe(u);let m="";o&&"Mobile"!==i&&(m=`display:flow-root; width:${o?.contentSize||"660px"}; margin: 0 auto;box-sizing: border-box;max-width: 100%;`);const g=u.styles?.spacing?.padding;return g&&(m+=`padding-left:${(0,ye.DJ)(g.left)};`,m+=`padding-right:${(0,ye.DJ)(g.right)};`),[(0,n.useMemo)((()=>[...null!=p?p:[],{css:`.is-root-container{ ${m} }`},...null!=d?d:[]]),[p,d,m])||we]}},89832:(e,t,o)=>{o.d(t,{L:()=>i});var n=o(47143),r=o(43656),s=o(58039);function i(){return(0,n.useSelect)((e=>{const t=e(s.H);if(!t)return!1;const o=t.getEmailPostId(),n=t.getEmailPostType(),i=e(r.store).getCurrentPostId(),a=e(r.store).getCurrentPostType();if(String(i)===String(o)&&String(a)===String(n))return!0;if("wp_template"===a){const e=t.getCurrentTemplate();if(!e)return!1;const o=t.getEmailTemplates();return!!o&&o.some((t=>t.id===e.id&&t.post_types?.includes(n)))}return!1}),[])}},28179:(e,t,o)=>{o.d(t,{p:()=>u});var n=o(86087),r=o(74997),s=o(47143),i=o(52619),a=o(58039);const l=[];function c(e,t){return e.map((e=>"core/post-content"===e.name?{...e,name:"core/group",innerBlocks:t}:e.innerBlocks?.length?{...e,innerBlocks:c(e.innerBlocks,t)}:e))}const d={};function u(e="",t=!0){const{templates:o,patterns:u,emailPosts:p,hasEmailPosts:m}=(0,s.useSelect)((o=>{const n=t&&"swap"!==e?o(a.H).getSentEmailEditorPosts():void 0;return{templates:o(a.H).getEmailTemplates(),patterns:o(a.H).getBlockPatternsForEmailTemplate(),emailPosts:n,hasEmailPosts:!(!n||!n?.length)}}),[e,t]),g=(0,n.useMemo)((()=>{let t=[];const n=e&&(0,r.parse)(e);if(t=n?[{blocks:n}]:u,!t||!o)return l;const s=[];return o?.filter((e=>"email-general"!==e.slug))?.forEach((e=>{t?.forEach((t=>{let o=(0,r.parse)(e.content?.raw);o=c(o,t.blocks),s.push({id:e.id,slug:e.slug,previewContentParsed:o,emailParsed:t.blocks,template:e,category:t.categories?.[0],type:e.type,displayName:t.title?`${e.title.rendered} - ${t.title}`:e.title.rendered})}))})),s}),[o,u,e]),h=(0,n.useMemo)((()=>p?.map((e=>{const t=(0,i.applyFilters)("woocommerce_email_editor_preferred_template_title","",e),{postTemplateContent:o}=function(e,t=[]){const o=e.template,n={postTemplateContent:null};if(!o)return n;if(d[o])return d[o];const r=t.find((e=>e.slug===o));if(!r)return n;const s={postTemplateContent:r?.template};return d[o]=s,s}(e,g),n=(0,r.parse)(e.content?.raw);let s=n;o?.content?.raw&&(s=c((0,r.parse)(o?.content?.raw),n));const a={...e,title:{raw:e.title.raw,rendered:t||e.title.rendered}};return{id:e.id,slug:e.slug,previewContentParsed:s,emailParsed:n,category:"recent",type:e.type,displayName:a.title.rendered,template:a}}))),[p,g]);return[g||l,h||l,m]}},71646:(e,t,o)=>{o.d(t,{u:()=>a});var n=o(86087),r=o(47143),s=o(3582),i=o(58039);function a(){const{globalStylePost:e}=(0,r.useSelect)((e=>({globalStylePost:e(i.H).getGlobalEmailStylesPost()||null})),[]),t=(0,n.useCallback)((t=>{e&&(0,r.dispatch)(s.store).editEntityRecord("root","globalStyles",e.id,{styles:t.styles,settings:t.settings})}),[e]);return{userTheme:{settings:e?.settings,styles:e?.styles},updateUserTheme:t}}},58039:(e,t,o)=>{o.d(t,{H:()=>n,q:()=>r});const n="email-editor/editor",r={name:"personalization_tag",kind:"root",baseURL:"/woocommerce-email-editor/v1/personalization_tags",key:"token"}},9463:(e,t,o)=>{o.d(t,{y$:()=>oe});var n={};o.r(n),o.d(n,{requestSendingNewsletterPreview:()=>_,setContentValidation:()=>f,setEditorConfig:()=>b,setEditorSettings:()=>y,setEditorTheme:()=>w,setEditorUrls:()=>x,setEmailPost:()=>m,setEmailPostType:()=>g,setTemplateToPost:()=>h,togglePreviewModal:()=>u,updateSendPreviewEmail:()=>p});var r={};o.r(r),o.d(r,{canUserEditGlobalEmailStyles:()=>V,canUserEditTemplates:()=>R,getBlockPatternsForEmailTemplate:()=>H,getContentValidation:()=>te,getCurrentTemplate:()=>A,getCurrentTemplateContent:()=>O,getEditedEmailContent:()=>$,getEditedPostTemplate:()=>L,getEmailPostId:()=>W,getEmailPostType:()=>U,getEmailTemplates:()=>G,getGlobalEmailStylesPost:()=>D,getGlobalStylesPostId:()=>Q,getInitialEditorSettings:()=>q,getPaletteColors:()=>Y,getPersonalizationTagsList:()=>K,getPreviewState:()=>J,getSentEmailEditorPosts:()=>z,getStyles:()=>Z,getTheme:()=>X,getUrls:()=>ee,hasEdits:()=>N,hasEmptyContent:()=>I,isEmailSent:()=>B,isFeatureActive:()=>P});var s=o(47143),i=o(3582);const a=window.wp.dataControls;var l=o(58039),c=o(49851),d=o(59191);function u(e){return{type:"CHANGE_PREVIEW_STATE",state:{isModalOpened:e}}}function p(e){return{type:"CHANGE_PREVIEW_STATE",state:{toEmail:e}}}function m(e,t){if(!e||!t)throw new Error("setEmailPost requires valid postId and postType parameters");return{type:"SET_EMAIL_POST",state:{postId:e,postType:t}}}function g(e){if(!e)throw new Error("setEmailPostType requires a valid postType parameter");return{type:"SET_EMAIL_POST",state:{postType:e}}}const h=e=>async({registry:t})=>{const o=t.select(l.H).getEmailPostId(),n=t.select(l.H).getEmailPostType();t.dispatch(i.store).editEntityRecord("postType",n,o,{template:e})};function*_(e){if(!(0,s.select)(l.H).getPreviewState().isSendingPreviewEmail){yield{type:"CHANGE_PREVIEW_STATE",state:{sendingPreviewStatus:null,isSendingPreviewEmail:!0}};try{const t=(0,s.select)(l.H).getEmailPostId();yield(0,a.apiFetch)({path:"/woocommerce-email-editor/v1/send_preview_email",method:"POST",data:{email:e,postId:t}}),yield{type:"CHANGE_PREVIEW_STATE",state:{sendingPreviewStatus:c.T.SUCCESS,isSendingPreviewEmail:!1}},(0,d.yM)("sent_preview_email",{postId:t,email:e})}catch(t){(0,d.yM)("sent_preview_email_error",{email:e}),yield{type:"CHANGE_PREVIEW_STATE",state:{sendingPreviewStatus:c.T.ERROR,isSendingPreviewEmail:!1,errorMessage:JSON.stringify(t?.error)}}}}}function f(e){return{type:"SET_CONTENT_VALIDATION",validation:e}}function y(e){return{type:"SET_EDITOR_SETTINGS",editorSettings:e}}function w(e){return{type:"SET_EDITOR_THEME",theme:e}}function x(e){return{type:"SET_EDITOR_URLS",urls:e}}function b(e){return{type:"SET_EDITOR_CONFIG",config:e}}function v(e,t){var o;switch(t.type){case"CHANGE_PREVIEW_STATE":return{...e,preview:{...e.preview,...t.state}};case"SET_EMAIL_POST":return{...e,...t.state};case"SET_CONTENT_VALIDATION":return{...e,contentValidation:t.validation};case"SET_EDITOR_SETTINGS":return{...e,editorSettings:t.editorSettings};case"SET_EDITOR_THEME":return{...e,theme:t.theme};case"SET_EDITOR_URLS":return{...e,urls:{...e.urls,...t.urls}};case"SET_EDITOR_CONFIG":return{...e,editorSettings:t.config.editorSettings,theme:t.config.theme,urls:t.config.urls,preview:{...e.preview,toEmail:t.config.userEmail},styles:{...e.styles,globalStylesPostId:null!==(o=t.config.globalStylesPostId)&&void 0!==o?o:null}};default:return e}}var S=o(43656),k=o(41233),j=o(74997);function E(e){return e?.content&&"function"==typeof e.content?e.content(e):e?.blocks?(0,j.serialize)(e.blocks):e?.content?e.content:""}const T=new WeakMap;function C(e){let t=T.get(e);return t||(t={...e,get blocks(){return(0,j.parse)(e.content)}},T.set(e,t)),t}function M(e){return e?{...e,title:e?.title?.raw||e?.title||"",content:e?.content?.raw||e?.content||""}:null}const P=(0,s.createRegistrySelector)((e=>(t,o)=>!!e(k.store).get(l.H,o))),N=(0,s.createRegistrySelector)((e=>()=>{const t=e(l.H).getEmailPostId(),o=e(l.H).getEmailPostType();return!!e(i.store).hasEditsForEntityRecord("postType",o,t)})),I=(0,s.createRegistrySelector)((e=>()=>{const t=e(l.H).getEmailPostId(),o=e(l.H).getEmailPostType(),n=e(i.store).getEntityRecord("postType",o,t);if(!n)return!0;const{content:r}=n;return!r.raw})),B=(0,s.createRegistrySelector)((e=>()=>{const t=e(l.H).getEmailPostId(),o=e(l.H).getEmailPostType(),n=e(i.store).getEntityRecord("postType",o,t);return!!n&&"sent"===n.status})),$=(0,s.createRegistrySelector)((e=>()=>{const t=e(l.H).getEmailPostId(),o=e(l.H).getEmailPostType(),n=e(i.store).getEditedEntityRecord("postType",o,t);return n?E(n):""})),z=(0,s.createRegistrySelector)((e=>()=>{const t=e(l.H).getEmailPostType();return e(i.store).getEntityRecords("postType",t,{per_page:30,status:"publish,sent"})?.filter((e=>""!==e?.content?.raw))||[]})),H=(0,s.createRegistrySelector)((e=>{const t=e(l.H).getEmailPostType();return(0,s.createSelector)((()=>t?e(i.store).getBlockPatterns().filter((({templateTypes:e,postTypes:o})=>Array.isArray(e)&&e.includes("email-template")&&(void 0===o||0===o.length||o.includes(t)))).map(C):[]),(()=>[e(i.store).getBlockPatterns(),t]))})),R=(0,s.createRegistrySelector)((e=>()=>e(i.store).canUser("create",{kind:"postType",name:"wp_template"})));function F(e,t){return R()?e(i.store).getEditedEntityRecord("postType","wp_template",t):M(e(i.store).getEntityRecord("postType","wp_template",t,{context:"view"}))}const L=(0,s.createRegistrySelector)((e=>(t,o)=>{const n=o||e(S.store).getEditedPostAttribute("template");if(n){const t={context:"view",per_page:-1,_woocommerce_email_editor:"fetch-all-templates"},o=e(i.store).getEntityRecords("postType","wp_template",t)?.find((e=>e.slug===n));return o?F(e,o.id):null}const r=e(i.store).getDefaultTemplateId({slug:"email-general"});return F(e,r)})),A=(0,s.createRegistrySelector)((e=>()=>{if("wp_template"===e(S.store).getCurrentPostType()){const t=e(S.store).getCurrentPostId();return e(i.store).getEditedEntityRecord("postType","wp_template",t)}return e(l.H).getEditedPostTemplate()})),O=()=>{const e=A();return e?E(e):""},V=(0,s.createRegistrySelector)((e=>()=>{const t=e(l.H).getGlobalStylesPostId();return{postId:t,canEdit:e(i.store).canUser("update",{kind:"root",name:"globalStyles",id:t})}})),D=(0,s.createRegistrySelector)((e=>()=>{const{postId:t,canEdit:o}=V();return t&&void 0!==o&&t?o?e(i.store).getEditedEntityRecord("root","globalStyles",t):M(e(i.store).getEntityRecord("root","globalStyles",t,{context:"view"})):null})),G=(0,s.createRegistrySelector)((e=>()=>{const t=e(l.H).getEmailPostType();return e(i.store).getEntityRecords("postType","wp_template",{per_page:-1,post_type:t,context:"view"})?.filter((e=>e.post_types.includes(t)))}));function W(e){return e.postId}function U(e){return e.postType}function q(e){return e.editorSettings}function Y(e){return e.editorSettings?.__experimentalFeatures?.color?.palette}function J(e){return e.preview}const K=(0,s.createRegistrySelector)((e=>()=>{const t=e(i.store).getEntityRecords(l.q.kind,l.q.name,{context:"view",per_page:-1})||[],o=e(l.H).getEmailPostType();if(!o)return t;if("wp_template"===o){const o=e(l.H).getCurrentTemplate();return t.filter((e=>void 0===e.postTypes||0===e.postTypes.length||Array.isArray(o.post_types)&&o.post_types.some((t=>e.postTypes.includes(t)))))}return t.filter((e=>void 0===e.postTypes||0===e.postTypes.length||e.postTypes.includes(o)))}));function Z(e){return e.theme?.styles}function X(e){return e.theme}function Q(e){return e.styles.globalStylesPostId}function ee(e){return e.urls}function te(e){return e.contentValidation}const oe=()=>{if(void 0!==(0,s.select)(l.H))return(0,s.select)(l.H);const e=(0,s.createReduxStore)(l.H,{actions:n,controls:a.controls,selectors:r,resolvers:{},reducer:v,initialState:{editorSettings:void 0,theme:void 0,styles:{globalStylesPostId:null},urls:{back:"",listings:""},preview:{toEmail:"",isModalOpened:!1,isSendingPreviewEmail:!1,sendingPreviewStatus:null},contentValidation:void 0}});return(0,s.register)(e),(0,s.dispatch)(i.store).addEntities([l.q]),e}},49851:(e,t,o)=>{var n;o.d(t,{T:()=>n}),function(e){e.SUCCESS="success",e.ERROR="error"}(n||(n={}))},5469:(e,t,o)=>{function n(e){if("string"!=typeof e)return null;const t=e.match(/^var:preset\|([a-zA-Z0-9-]+)\|([a-zA-Z0-9-]+)$/);return t?`--wp--preset--${t[1]}--${t[2]}`:null}function r(e){const t=n(e);return t?`var(${t})`:e}function s(e){const t=n(e);if(!t)return e;const o=document.querySelector(":root");return o&&getComputedStyle(o).getPropertyValue(t).trim()||e}o.d(t,{DJ:()=>r,pr:()=>s})},76597:e=>{var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===o}(e)}(e)},o="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(e,t){return!1!==t.clone&&t.isMergeableObject(e)?a((o=e,Array.isArray(o)?[]:{}),e,t):e;var o}function r(e,t,o){return e.concat(t).map((function(e){return n(e,o)}))}function s(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter((function(t){return Object.propertyIsEnumerable.call(e,t)})):[]}(e))}function i(e,t){try{return t in e}catch(e){return!1}}function a(e,o,l){(l=l||{}).arrayMerge=l.arrayMerge||r,l.isMergeableObject=l.isMergeableObject||t,l.cloneUnlessOtherwiseSpecified=n;var c=Array.isArray(o);return c===Array.isArray(e)?c?l.arrayMerge(e,o,l):function(e,t,o){var r={};return o.isMergeableObject(e)&&s(e).forEach((function(t){r[t]=n(e[t],o)})),s(t).forEach((function(s){(function(e,t){return i(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,s)||(i(e,s)&&o.isMergeableObject(t[s])?r[s]=function(e,t){if(!t.customMerge)return a;var o=t.customMerge(e);return"function"==typeof o?o:a}(s,o)(e[s],t[s],o):r[s]=n(t[s],o))})),r}(e,o,l):n(o,l)}a.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce((function(e,o){return a(e,o,t)}),{})};var l=a;e.exports=l},94931:(e,t,o)=>{var n=o(51609),r=Symbol.for("react.element"),s=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,a=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,o){var n,s={},c=null,d=null;for(n in void 0!==o&&(c=""+o),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(d=t.ref),t)i.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:r,type:e,key:c,ref:d,props:s,_owner:a.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},39793:(e,t,o)=>{e.exports=o(94931)},51609:e=>{e.exports=window.React},66087:e=>{e.exports=window.lodash},94715:e=>{e.exports=window.wp.blockEditor},74997:e=>{e.exports=window.wp.blocks},56427:e=>{e.exports=window.wp.components},3582:e=>{e.exports=window.wp.coreData},47143:e=>{e.exports=window.wp.data},43656:e=>{e.exports=window.wp.editor},86087:e=>{e.exports=window.wp.element},52619:e=>{e.exports=window.wp.hooks},27723:e=>{e.exports=window.wp.i18n},48558:e=>{e.exports=window.wp.keycodes},41233:e=>{e.exports=window.wp.preferences},5573:e=>{e.exports=window.wp.primitives},50876:e=>{e.exports=window.wp.richText},4921:(e,t,o)=>{function n(e){var t,o,r="";if("string"==typeof e||"number"==typeof e)r+=e;else if("object"==typeof e)if(Array.isArray(e)){var s=e.length;for(t=0;t<s;t++)e[t]&&(o=n(e[t]))&&(r&&(r+=" "),r+=o)}else for(o in e)e[o]&&(r&&(r+=" "),r+=o);return r}o.d(t,{A:()=>r});const r=function(){for(var e,t,o=0,r="",s=arguments.length;o<s;o++)(e=arguments[o])&&(t=n(e))&&(r&&(r+=" "),r+=t);return r}}},t={};function o(n){var r=t[n];if(void 0!==r)return r.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,o),s.exports}o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};o.r(n),o.d(n,{ExperimentalEmailEditor:()=>wo,RichTextWithButton:()=>vt.O,SendPreviewEmail:()=>ft.P,createStore:()=>Ut.y$,debouncedRecordEvent:()=>C.T7,initializeEditor:()=>bo,isEventTrackingEnabled:()=>C.V1,recordEvent:()=>C.yM,recordEventOnce:()=>C.xW,storeName:()=>j.H,useEmailCss:()=>ye.b,useIsEmailEditor:()=>xo.L,usePreviewTemplates:()=>xe.p});var r=o(39793),s=o(47143),i=o(86087),a=o(52619),l=o(43656);const c=window.wp.compose;window.wp.formatLibrary;var d=o(74997);function u(){try{return(0,d.getBlockTypes)().filter((e=>!0===e.supports?.email)).map((e=>e.name))}catch(e){return console.error("Failed to get allowed block names:",e),[]}}const p=window.wp.blockLibrary;var m=o(94715),g=o(94723),h=o(56554);const _=(0,c.createHigherOrderComponent)((e=>function(t){return"core/columns"!==t.name?(0,r.jsx)(e,{...t}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e,{...t}),(0,r.jsx)(m.InspectorControls,{children:(0,r.jsx)("style",{children:"\n      .components-panel__body .components-toggle-control .components-form-toggle { opacity: 0.3; }\n      .components-panel__body .components-toggle-control .components-form-toggle__input { pointer-events: none; }\n      .components-panel__body .components-toggle-control label { pointer-events: none; }\n    "})})]})}),"columnsEditCallback"),f=["core/column","core/columns"];var y=o(27723);function w({layoutClassNames:e}){const t=(0,m.useBlockProps)({className:e});return(0,r.jsxs)("div",{...t,children:[(0,r.jsx)("p",{children:(0,y.__)("This is the Content block.","woocommerce")}),(0,r.jsx)("p",{children:(0,y.__)("It will display all the blocks in the email content, which might be only simple text paragraphs. You can enrich your message with images, incorporate data through tables, explore different layout designs with columns, or use any other block type.","woocommerce")})]})}const x=(0,c.createHigherOrderComponent)((e=>function(t){return"core/image"!==t.name?(0,r.jsx)(e,{...t}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e,{...t}),(0,r.jsx)(m.InspectorControls,{children:(0,r.jsx)("style",{children:"\n        .components-tools-panel .components-toggle-control { display: none; }\n      "})})]})}),"imageEditCallback");var b=o(50876),v=o(56427),S=o(46042),k=o(2071),j=o(58039),E=o(91948);const T=({contentRef:e,onUpdate:t})=>{const[o,n]=(0,i.useState)(!1),[a,l]=(0,i.useState)(null),[c,d]=(0,i.useState)(""),[u,p]=(0,i.useState)(""),m=(0,s.useSelect)((e=>e(j.H).getPersonalizationTagsList()),[]);return(0,i.useEffect)((()=>{if(!e||!e.current)return;const t=e.current,o=e=>{const t=e.target.closest("a[data-link-href]");t&&(l(t),p(t.getAttribute("data-link-href")||""),d(t.textContent||""),n(!0))};return t.addEventListener("click",o),()=>{t.removeEventListener("click",o)}}),[e]),(0,r.jsx)(r.Fragment,{children:o&&a&&(0,r.jsx)(v.Popover,{position:"bottom left",onClose:()=>n(!1),anchor:a,className:"woocommerce-personalization-tag-popover",children:(0,r.jsxs)("div",{className:"woocommerce-personalization-tag-popover-content",children:[(0,r.jsx)(v.TextControl,{label:(0,y.__)("Link Text","woocommerce"),value:c,onChange:e=>d(e),__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,autoComplete:"off"}),(0,r.jsx)(v.SelectControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:(0,y.__)("Link tag","woocommerce"),value:u,onChange:e=>{p(e)},options:m.filter((e=>e.category===(0,y.__)("Link","woocommerce"))).map((e=>({label:e.name,value:e.token})))}),(0,r.jsxs)("div",{className:"woocommerce-personalization-tag-popover-content-buttons",children:[(0,r.jsx)(v.Button,{isTertiary:!0,onClick:()=>{n(!1)},children:(0,y.__)("Cancel","woocommerce")}),(0,r.jsx)(v.Button,{isPrimary:!0,onClick:()=>{n(!1),t(a,u,c)},children:(0,y.__)("Update link","woocommerce")})]})]})})})};var C=o(59191),M=o(16205);function P({contentRef:e}){const[t,o]=(0,i.useState)(!1),n=(0,s.useSelect)((e=>e("core/block-editor").getSelectedBlockClientId())),{updateBlockAttributes:a}=(0,s.useDispatch)("core/block-editor"),l=(0,s.useSelect)((e=>e("core/block-editor").getBlockAttributes(n))),c="text"in l?"text":"content",d=l?.[c]?.originalHTML||l?.[c]||"",u=(0,i.useCallback)(((t,o)=>{let{start:r,end:s}=(0,S.E)(e,d),i="";if(o){let e=(0,b.create)({html:d});e=(0,b.insert)(e,o,r,s),s=r+o.length,e=(0,b.applyFormat)(e,{type:"woocommerce-email-editor/link-shortcode",attributes:{"data-link-href":t,contenteditable:"false",style:"text-decoration: underline;"}},r,s),i=(0,b.toHTMLString)({value:e})}else{let e=(0,b.create)({html:d});e=(0,b.insert)(e,(0,b.create)({html:`\x3c!--${t}--\x3e&nbsp;`}),r,s),i=(0,b.toHTMLString)({value:e})}a(n,{[c]:i})}),[d,c,e,n,a]);return(0,r.jsx)(m.BlockControls,{children:(0,r.jsxs)(v.ToolbarGroup,{children:[(0,r.jsx)(v.ToolbarButton,{icon:"shortcode",title:(0,y.__)("Personalization Tags","woocommerce"),onClick:()=>{o(!0),(0,C.yM)("block_controls_personalization_tags_button_clicked")}}),(0,r.jsx)(E.t,{contentRef:e,onUpdate:(e,t)=>{const o=d.replace(`\x3c!--[${e}]--\x3e`,`\x3c!--[${t}]--\x3e`);a(n,{[c]:o})}}),(0,r.jsx)(T,{contentRef:e,onUpdate:(e,t,o)=>{const r=e.getAttribute("data-link-href").replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),s=new RegExp(`<a([^>]*?)data-link-href="${r}"([^>]*?)>${e.textContent}</a>`,"gi"),i=d.replace(s,((e,n,r)=>`<a${n}data-link-href="${t}"${r}>${o}</a>`));a(n,{content:i})}}),(0,r.jsx)(k.x,{isOpened:t,onInsert:(e,t)=>{u(e,t),o(!1)},closeCallback:()=>o(!1),canInsertLink:!0,openedBy:"block-controls"})]})})}const N=(0,c.createHigherOrderComponent)((e=>t=>{const{attributes:o,setAttributes:n,name:a}=t,{content:l}=o,c=(0,s.useSelect)((e=>e(j.H).getPersonalizationTagsList()),[]),d=(0,i.useCallback)((()=>l?(0,S.D)(l,c):""),[l,c]),u=(0,i.useCallback)((e=>{if(void 0!==e.content){const t=(0,S.D)(e.content,c);n({...e,content:t})}else n(e)}),[c,n]);return"core/paragraph"===a||"core/heading"===a||"core/list-item"===a?(0,r.jsx)(e,{...t,attributes:{...o,content:d()},setAttributes:u}):(0,r.jsx)(e,{...t})}),"personalizationTagsLiveContentUpdate"),I=window.wp.domReady;var B=o.n(I),$=o(93524);const z=["core/social-links"];function H(){(0,d.getBlockTypes)().forEach((e=>{const t=e.name;if(z.includes(t))return;const o=(0,s.select)("core/blocks").getBlockStyles(t);Array.isArray(o)&&0!==o?.length&&o.forEach((e=>{(0,$.oj)(t,e.name)}))}))}const R=e=>t=>{const{setAttributes:o}=t,n=(0,i.useCallback)((e=>{e?.url&&e.url?.startsWith("http://[")&&(e.url=e.url.replace("http://[","[")),o(e)}),[o]);return(0,r.jsx)(e,{...t,setAttributes:n})};var F=o(43583);const L=["behance","bluesky","chain","discord","facebook","feed","github","gravatar","instagram","linkedin","mail","mastodon","medium","patreon","pinterest","reddit","spotify","telegram","threads","tiktok","tumblr","twitch","twitter","vimeo","wordpress","whatsapp","x","youtube"],A=e=>t=>{if("core/social-links"!==t.name)return(0,r.jsx)(e,{...t});const o=`\n\t\t.block-editor-tools-panel-color-gradient-settings__item:has([title="${(0,y.__)("Icon color")}"]) {\n\t\t\tdisplay: none !important;\n\t\t}\n\t\t.block-editor-tools-panel-color-gradient-settings__item:nth-child(2 of .block-editor-tools-panel-color-gradient-settings__item){\n\t\t\tborder-top:1px solid #ddd;\n\t\t\tborder-top-left-radius:2px;\n\t\t\tborder-top-right-radius:2px;\n\t\t}\n\t\t`;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(e,{...t}),(0,r.jsx)(m.InspectorControls,{group:"color",children:(0,r.jsx)("style",{children:o})})]})};const O=window.wp.privateApis,{unlock:V}=(0,O.__dangerousOptInToUnstableAPIsOnlyForCoreModules)("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.","@wordpress/edit-site"),{ColorPanel:D}=V(m.privateApis),{Editor:G,FullscreenMode:W,ViewMoreMenuGroup:U,BackButton:q}=V(l.privateApis),{registerEntityAction:Y,unregisterEntityAction:J}=V((0,s.dispatch)(l.store));var K=o(3582);const Z=window.wp.notices;var X=o(5573);const Q=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})}),ee=window.wp.htmlEntities;function te(e){return"string"==typeof e.title?(0,ee.decodeEntities)(e.title):e.title&&"rendered"in e.title?(0,ee.decodeEntities)(e.title.rendered):e.title&&"raw"in e.title?(0,ee.decodeEntities)(e.title.raw):""}function oe(e,t){return t?e.length>1?(0,y.sprintf)((0,y._n)("Are you sure you want to permanently delete %d item?","Are you sure you want to permanently delete %d items?",e.length,"woocommerce"),e.length):(0,y.sprintf)((0,y.__)('Are you sure you want to permanently delete "%s"?',"woocommerce"),(0,ee.decodeEntities)(te(e[0]))):e.length>1?(0,y.sprintf)((0,y._n)("Are you sure you want to move %d item to the trash ?","Are you sure you want to move %d items to the trash ?",e.length,"woocommerce"),e.length):(0,y.sprintf)((0,y.__)('Are you sure you want to move "%s" to the trash?',"woocommerce"),te(e[0]))}const ne=e=>{J("postType",e,"move-to-trash"),Y("postType",e,(()=>{const e=(0,a.applyFilters)("woocommerce_email_editor_trash_modal_should_permanently_delete",!1);return{id:"trash-email-post",label:e?(0,y.__)("Permanently delete","woocommerce"):(0,y.__)("Move to trash","woocommerce"),supportsBulk:!0,icon:Q,isEligible(e){if("wp_template"===e.type||"wp_template_part"===e.type||"wp_block"===e.type)return!1;const{permissions:t}=e;return t?.delete},hideModalHeader:!0,modalFocusOnMount:"firstContentElement",RenderModal:({items:t,closeModal:o,onActionPerformed:n})=>{const[a,l]=(0,i.useState)(!1),{createSuccessNotice:c,createErrorNotice:d}=(0,s.useDispatch)(Z.store),{deleteEntityRecord:u}=(0,s.useDispatch)(K.store),{urls:p}=(0,s.useSelect)((e=>({urls:e(j.H).getUrls()})),[]);return(0,r.jsxs)(v.__experimentalVStack,{spacing:"5",children:[(0,r.jsx)(v.__experimentalText,{children:oe(t,e)}),(0,r.jsxs)(v.__experimentalHStack,{justify:"right",children:[(0,r.jsx)(v.Button,{variant:"tertiary",onClick:()=>{o?.(),(0,C.yM)("trash_modal_cancel_button_clicked")},disabled:a,__next40pxDefaultSize:!0,children:(0,y.__)("Cancel","woocommerce")}),(0,r.jsx)(v.Button,{variant:"primary",onClick:async()=>{(0,C.yM)("trash_modal_move_to_trash_button_clicked"),l(!0);const r=await Promise.allSettled(t.map((t=>u("postType",t.type,t.id,{force:e},{throwOnError:!0}))));if(r.every((({status:e})=>"fulfilled"===e))){let o;o=1===r.length?e?(0,y.sprintf)((0,y.__)('"%s" permanently deleted.',"woocommerce"),te(t[0])):(0,y.sprintf)((0,y.__)('"%s" moved to the trash.',"woocommerce"),te(t[0])):e?(0,y.__)("The items were permanently deleted.","woocommerce"):(0,y.sprintf)((0,y._n)("%s item moved to the trash.","%s items moved to the trash.",t.length,"woocommerce"),t.length),c(o,{type:"snackbar",id:"trash-email-post-action"}),n?.(t),p?.listings&&(window.location.href=p.listings)}else{let e;if(1===r.length){const t=r[0];e=t.reason?.message?t.reason.message:(0,y.__)("An error occurred while performing the action.","woocommerce")}else{const t=new Set,o=r.filter((({status:e})=>"rejected"===e));for(const e of o){const o=e;o.reason?.message&&t.add(o.reason.message)}e=0===t.size?(0,y.__)("An error occurred while performing the action.","woocommerce"):1===t.size?(0,y.sprintf)((0,y.__)("An error occurred while performing the action: %s","woocommerce"),[...t][0]):(0,y.sprintf)((0,y.__)("Some errors occurred while performing the action: %s","woocommerce"),[...t].join(","))}(0,C.yM)("trash_modal_move_to_trash_error",{errorMessage:e}),d(e,{type:"snackbar"})}l(!1),o?.()},isBusy:a,disabled:a,__next40pxDefaultSize:!0,children:e?(0,y.__)("Delete permanently","woocommerce"):(0,y.__)("Move to trash","woocommerce")})]})]})}}})())};function re(){(0,d.getBlockType)("core/paragraph")||(0,p.registerCoreBlocks)(),(0,h.HY)("editor.BlockEdit","woocommerce-email-editor/filter-set-url-attribute",R),(0,h.HY)("editor.BlockEdit","woocommerce-email-editor/deactivate-stack-on-mobile",_),(0,h.HY)("editor.BlockEdit","woocommerce-email-editor/hide-expand-on-click",x),(0,g.G)("core/image",(e=>({...e,supports:{...e.supports||{},filter:{...e.supports?.filter||{},duetone:!1}}}))),["core/image","core/code","core/language"].forEach((e=>{(0,M.le)(e)})),f.forEach((e=>{(0,g.G)(e,(e=>({...e,supports:{...e.supports||{},layout:!1,background:{...e.support?.background||{},backgroundImage:!0}}})))})),(0,g.G)("core/group",(e=>{var t;const o=null!==(t=e.variations)&&void 0!==t?t:[];return{...e,variations:o.filter((e=>"group"===e.name)),supports:{...e.supports||{},layout:!1}}})),(0,g.G)("core/buttons",(e=>{var t;return{...e,supports:{...null!==(t=e.supports)&&void 0!==t?t:{},layout:!1,__experimentalEmailFlexLayout:!0}}})),(0,g.G)("core/post-content",(e=>{return{...e,edit:(t=e.edit,function(e){const{postId:o,postType:n}=e.context,{__unstableLayoutClassNames:s}=e;return o&&n?(0,r.jsx)(t,{...e}):(0,r.jsx)(w,{layoutClassNames:s})})};var t})),(0,g.G)("core/quote",(e=>({...e,styles:[],supports:{...e.supports,align:[]}}))),(0,M.gG)("woocommerce-email-editor/shortcode",{name:"woocommerce-email-editor/shortcode",title:(0,y.__)("Personalization Tags","woocommerce"),className:"woocommerce-email-editor-personalization-tags",tagName:"span",attributes:{},interactive:!0,edit:P}),(0,M.gG)("woocommerce-email-editor/link-shortcode",{name:"woocommerce-email-editor/link-shortcode",title:(0,y.__)("Personalization Tags Link","woocommerce"),className:"woocommerce-email-editor-personalization-tags-link",tagName:"a",attributes:{"data-link-href":"data-link-href",contenteditable:"contenteditable",style:"style"},interactive:!0,edit:null}),(0,h.HY)("editor.BlockEdit","woocommerce-email-editor/with-live-content-update",N),(0,d.getBlockTypes)().forEach((e=>{e.supports?.shadow&&(0,g.G)(e.name,(e=>({...e,supports:{...e.supports,shadow:!1}})))})),(0,g.G)("core/social-link",(e=>({...e,variations:(e.variations||[]).filter((e=>L.includes(e.name))),supports:{...e.supports,layout:!1}}))),(0,F.z)("core/social-links",{name:"social-links-default",title:"Social Icons",attributes:{openInNewTab:!0,showLabels:!1,align:"center",className:"is-style-logos-only"},isDefault:!0,innerBlocks:[{name:"core/social-link",attributes:{service:"wordpress",url:"https://wordpress.org"}},{name:"core/social-link",attributes:{service:"facebook",url:"https://www.facebook.com/WordPress/"}},{name:"core/social-link",attributes:{service:"x",url:"https://x.com/WordPress"}}]}),(0,h.HY)("editor.BlockEdit","woocommerce-email-editor/disable-social-links-icon-color",A),(0,h.tN)("core.registerPostTypeSchema","woocommerce-email-editor/modify-move-to-trash-action",(e=>{ne(e)})),(0,h.tN)("core.registerPostTypeActions","woocommerce-email-editor/modify-move-to-trash-action",(e=>{ne(e)})),(0,F.z)("core/site-logo",{name:"site-logo-default",title:"Site Logo",attributes:{align:"center",width:120},isDefault:!0}),B()(H)}var se=o(4921);const ie=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M9 9v6h11V9H9zM4 20h1.5V4H4v16z"})}),ae=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M12.5 15v5H11v-5H4V9h7V4h1.5v5h7v6h-7Z"})}),le=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M4 15h11V9H4v6zM18.5 4v16H20V4h-1.5z"})}),ce="__experimentalEmailFlexLayout";function de(e){return(0,d.hasBlockSupport)(e,ce)}function ue({justificationValue:e,onChange:t,isToolbar:o=!1}){const n=[{value:"left",icon:ie,label:(0,y.__)("Justify items left","woocommerce")},{value:"center",icon:ae,label:(0,y.__)("Justify items center","woocommerce")},{value:"right",icon:le,label:(0,y.__)("Justify items right","woocommerce")}];if(o){const o=n.map((e=>e.value));return(0,r.jsx)(m.JustifyContentControl,{value:e,onChange:t,allowedControls:o,popoverProps:{placement:"bottom-start"}})}return(0,r.jsx)(v.__experimentalToggleGroupControl,{__nextHasNoMarginBottom:!0,label:(0,y.__)("Justification","woocommerce"),value:e,onChange:t,className:"block-editor-hooks__flex-layout-justification-controls",children:n.map((({value:e,icon:t,label:o})=>(0,r.jsx)(v.__experimentalToggleGroupControlOptionIcon,{value:e,icon:t,label:o},e)))})}function pe({setAttributes:e,attributes:t,name:o}){if(!(0,d.getBlockSupport)(o,ce,{}))return null;const{justifyContent:n="left"}=t.layout||{},s=o=>{e({layout:{...t.layout,justifyContent:o}})},i=()=>{const{justifyContent:o,...n}=t.layout||{};e({layout:n})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(m.InspectorControls,{children:(0,r.jsx)(v.__experimentalToolsPanel,{label:(0,y.__)("Layout","woocommerce"),resetAll:i,children:(0,r.jsx)(v.__experimentalToolsPanelItem,{isShownByDefault:!0,onDeselect:i,hasValue:()=>t.layout?.justifyContent||!1,label:(0,y.__)("Justification","woocommerce"),children:(0,r.jsx)(v.Flex,{children:(0,r.jsx)(v.FlexItem,{children:(0,r.jsx)(ue,{justificationValue:n,onChange:s})})})})})}),(0,r.jsx)(m.BlockControls,{group:"block",__experimentalShareWithChildBlocks:!0,children:(0,r.jsx)(ue,{justificationValue:n,onChange:s,isToolbar:!0})})]})}const me=(0,c.createHigherOrderComponent)((e=>t=>[de(t.name)&&(0,r.jsx)(pe,{...t},"layout"),(0,r.jsx)(e,{...t},"edit")]),"withLayoutControls");function ge({block:e,props:t}){const{attributes:o}=t,{layout:n}=o,s=`is-content-justification-${n?.justifyContent||"left"}`,i=(0,se.A)(s,"is-layout-email-flex is-layout-flex");return(0,r.jsx)(e,{...t,className:i})}const he=(0,c.createHigherOrderComponent)((e=>function(t){return de(t.name)?(0,r.jsx)(ge,{block:e,props:t}):(0,r.jsx)(e,{...t})}),"withLayoutStyles");const _e=window.wp.commands,fe=window.wp.plugins;var ye=o(14731);const we=()=>{const e=".editor-preview-dropdown__button-external",t=async t=>{const o=t.target,n=o?.closest(e);if(!n)return;const r=(0,s.select)(l.store),i=r?.isEditedPostDirty();i&&(t.preventDefault(),t.stopPropagation(),t.stopImmediatePropagation(),(0,s.dispatch)(Z.store).createNotice("warning",(0,y.__)("You have unsaved changes. Please save the post before previewing.","woocommerce"),{context:"email-editor",isDismissible:!0}))},o=(0,i.useCallback)((o=>{try{const n=o.target;"Enter"!==o.key&&" "!==o.key||!n?.closest(e)||t(o)}catch(e){console.warn("Preview save message guard error:",e)}}),[e]);return(0,i.useEffect)((()=>(document.addEventListener("click",t,!0),document.addEventListener("auxclick",t,!0),document.addEventListener("keydown",o,!0),()=>{document.removeEventListener("click",t,!0),document.removeEventListener("auxclick",t,!0),document.removeEventListener("keydown",o,!0)})),[o]),null};var xe=o(28179),be=o(24148);const ve=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"})}),Se=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"})}),ke=(0,window.wp.priorityQueue.createQueue)();function je({children:e,placeholder:t}){const[o,n]=(0,i.useState)(!1);return(0,i.useEffect)((()=>{const e={};return ke.add(e,(()=>{(0,i.flushSync)((()=>{n(!0)}))})),()=>{ke.cancel(e)}}),[]),o?e:t}function Ee(){return(0,r.jsxs)("div",{className:"block-editor-inserter__no-results",children:[(0,r.jsx)(be.A,{className:"block-editor-inserter__no-results-icon",icon:ve}),(0,r.jsx)("p",{children:(0,y.__)("No recent templates.","woocommerce")}),(0,r.jsx)("p",{children:(0,y.__)("Your recent creations will appear here as soon as you begin.","woocommerce")})]})}const Te=(0,i.memo)((function({templates:e,onTemplateSelection:t,selectedCategory:o}){const{layout:n}=(0,s.useSelect)((e=>{const{getEditorSettings:t}=e(l.store),o=t();return{layout:o?.__experimentalFeatures?.layout}})),[i]=(0,ye.b)(),a=i.reduce(((e,t)=>{var o;return e+(null!==(o=t.css)&&void 0!==o?o:"")}),"")+`.is-root-container { width: ${n?.contentSize||"660px"}; margin: 0 auto; }`;return"recent"===o&&0===e.length?(0,r.jsx)(Ee,{}):(0,r.jsx)("div",{className:"block-editor-block-patterns-list",role:"listbox",children:e.map((e=>(0,r.jsx)("div",{className:"block-editor-block-patterns-list__list-item email-editor-pattern__list-item",children:(0,r.jsx)("div",{className:"block-editor-block-patterns-list__item",role:"button",tabIndex:0,onClick:()=>{t(e)},onKeyPress:o=>{"Enter"!==o.key&&" "!==o.key||t(e)},children:(0,r.jsxs)(je,{placeholder:(0,r.jsx)("p",{children:(0,y.__)("rendering template","woocommerce")}),children:[(0,r.jsx)(m.BlockPreview,{blocks:e.previewContentParsed,viewportWidth:900,minHeight:300,additionalStyles:[{css:a}]}),(0,r.jsx)(v.__experimentalHStack,{className:"block-editor-patterns__pattern-details",children:(0,r.jsx)("h4",{className:"block-editor-block-patterns-list__item-title",children:e.displayName})})]})})},`${e.slug}_${e.displayName}_${e.id}`)))})}),((e,t)=>e.templates.length===t.templates.length&&e.selectedCategory===t.selectedCategory));function Ce({templates:e,onTemplateSelection:t,selectedCategory:o}){const n=(0,i.useMemo)((()=>e.filter((e=>e.category===o))),[o,e]);return(0,r.jsxs)("div",{className:"block-editor-block-patterns-explorer__list",children:["recent"===o&&(0,r.jsx)("div",{className:"email-editor-recent-templates-info",children:(0,r.jsxs)(v.__experimentalHStack,{spacing:1,expanded:!1,justify:"start",children:[(0,r.jsx)(be.A,{icon:Se}),(0,r.jsx)("p",{children:(0,y.__)("Templates created on the legacy editor will not appear here.","woocommerce")})]})}),(0,r.jsx)(Te,{templates:n,onTemplateSelection:t,selectedCategory:o})]})}function Me({selectedCategory:e,templateCategories:t,onClickCategory:o}){const n="block-editor-block-patterns-explorer__sidebar";return(0,r.jsx)("div",{className:n,children:(0,r.jsx)("div",{className:`${n}__categories-list`,children:t.map((({name:t,label:s})=>(0,r.jsx)(v.Button,{label:s,className:`${n}__categories-list__item`,isPressed:e===t,onClick:()=>{o(t)},children:s},t)))})})}const Pe=(0,i.memo)((function({templates:e,handleTemplateSelection:t,templateSelectMode:o}){const n=(0,s.useSelect)((e=>e(K.store).getBlockPatternCategories()),[]),a="swap"===o,l=(0,i.useMemo)((()=>{const t=function(e,t){const o=new Map(t.map((e=>[e.name,e.label])));o.set("recent",(0,y.__)("Recent","woocommerce"));const n=new Set;for(const t of e)t.category&&n.add(t.category);return[...n].map((e=>{var t;return{name:e,label:null!==(t=o.get(e))&&void 0!==t?t:e}}))}(e,null!=n?n:[]);return a?t.filter((e=>"recent"!==e.name)):t.sort(((e,t)=>"recent"===e.name?-1:"recent"===t.name?1:0))}),[e,n,a]),[c,d]=(0,i.useState)(null);return(0,i.useEffect)((()=>{if(null!==c||0===l.length)return;const e=setTimeout((()=>{var e;const t=null!==(e=l.find((e=>"recent"!==e.name))?.name)&&void 0!==e?e:l[0]?.name;d(t)}),1e3);return()=>clearTimeout(e)}),[l,c]),(0,r.jsxs)("div",{className:"block-editor-block-patterns-explorer",children:[(0,r.jsx)(Me,{templateCategories:l,selectedCategory:c,onClickCategory:e=>{(0,C.yM)("template_select_modal_category_change",{category:e}),d(e)}}),(0,r.jsx)(Ce,{templates:e,onTemplateSelection:t,selectedCategory:c})]})}));function Ne({onSelectCallback:e,closeCallback:t=null,previewContent:o="",postType:n}){const i=o?"swap":"new";(0,C.xW)("template_select_modal_opened",{templateSelectMode:i});const[a,c]=(0,xe.p)(o),d=a?.length>0,u=t=>{const r=t.type===n,a=t.template;(0,C.yM)("template_select_modal_template_selected",{templateSlug:t.slug,templateSelectMode:i,templateType:t.type}),o||(0,s.dispatch)(l.store).resetEditorBlocks(t.emailParsed),(0,s.dispatch)(j.H).setTemplateToPost(r?a.template:t.slug),e()},p=()=>{var e;const t=null!==(e=a[0])&&void 0!==e?e:null;t&&((0,C.yM)("template_select_modal_handle_close_without_template_selected"),u(t))};return(0,r.jsxs)(v.Modal,{title:"new"===i?(0,y.__)("Start with an email preset","woocommerce"):(0,y.__)("Select a template","woocommerce"),onRequestClose:()=>((0,C.yM)("template_select_modal_closed",{templateSelectMode:i}),t?t():p()),isFullScreen:!0,children:[(0,r.jsx)(Pe,{templates:[...a,...c],handleTemplateSelection:u,templateSelectMode:i}),(0,r.jsx)(v.Flex,{className:"email-editor-modal-footer",justify:"flex-end",children:(0,r.jsx)(v.FlexItem,{children:(0,r.jsx)(v.Button,{variant:"tertiary",className:"email-editor-start_from_scratch_button",onClick:()=>((0,C.yM)("template_select_modal_start_from_scratch_clicked"),p()),isBusy:!d,children:(0,y.__)("Start from scratch","woocommerce")})})})]})}function Ie(){const[e,t]=(0,i.useState)(!1),{emailContentIsEmpty:o,emailHasEdits:n,postType:a}=(0,s.useSelect)((e=>({emailContentIsEmpty:e(j.H).hasEmptyContent(),emailHasEdits:e(j.H).hasEdits(),postType:e(j.H).getEmailPostType()})),[]);return!o||n||e?null:(0,r.jsx)(Ne,{onSelectCallback:()=>t(!0),postType:a})}const Be=(0,r.jsx)(X.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)(X.Path,{d:"M12 4c-4.4 0-8 3.6-8 8v.1c0 4.1 3.2 7.5 7.2 7.9h.8c4.4 0 8-3.6 8-8s-3.6-8-8-8zm0 15V5c3.9 0 7 3.1 7 7s-3.1 7-7 7z"})}),$e=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M6.9 7L3 17.8h1.7l1-2.8h4.1l1 2.8h1.7L8.6 7H6.9zm-.7 6.6l1.5-4.3 1.5 4.3h-3zM21.6 17c-.1.1-.2.2-.3.2-.1.1-.2.1-.4.1s-.3-.1-.4-.2c-.1-.1-.1-.3-.1-.6V12c0-.5 0-1-.1-1.4-.1-.4-.3-.7-.5-1-.2-.2-.5-.4-.9-.5-.4 0-.8-.1-1.3-.1s-1 .1-1.4.2c-.4.1-.7.3-1 .4-.2.2-.4.3-.6.5-.1.2-.2.4-.2.7 0 .3.1.5.2.8.2.2.4.3.8.3.3 0 .6-.1.8-.3.2-.2.3-.4.3-.7 0-.3-.1-.5-.2-.7-.2-.2-.4-.3-.6-.4.2-.2.4-.3.7-.4.3-.1.6-.1.8-.1.3 0 .6 0 .8.1.2.1.4.3.5.5.1.2.2.5.2.9v1.1c0 .3-.1.5-.3.6-.2.2-.5.3-.9.4-.3.1-.7.3-1.1.4-.4.1-.8.3-1.1.5-.3.2-.6.4-.8.7-.2.3-.3.7-.3 1.2 0 .6.2 1.1.5 1.4.3.4.9.5 1.6.5.5 0 1-.1 1.4-.3.4-.2.8-.6 1.1-1.1 0 .4.1.7.3 1 .2.3.6.4 1.2.4.4 0 .7-.1.9-.2.2-.1.5-.3.7-.4h-.3zm-3-.9c-.2.4-.5.7-.8.8-.3.2-.6.2-.8.2-.4 0-.6-.1-.9-.3-.2-.2-.3-.6-.3-1.1 0-.5.1-.9.3-1.2s.5-.5.8-.7c.3-.2.7-.3 1-.5.3-.1.6-.3.7-.6v3.4z"})}),ze=(0,r.jsx)(X.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,r.jsx)(X.Path,{d:"M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z"})}),He=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"})});var Re=o(76597),Fe=o.n(Re),Le=o(71646);const Ae={};function Oe(e){return!Object.keys(e).some((t=>Object.keys(e[t]).length>0))}function Ve(e){const t=e=>{if("object"==typeof e&&null!==e||void 0===e){if(Array.isArray(e)&&0===e.length)return;for(const o in e)if(Object.prototype.hasOwnProperty.call(e,o)){const n=t(e[o]);void 0===n||Oe(n)?delete e[o]:e[o]=n}}return e};return t(e)}const De=()=>{const{userTheme:e,updateUserTheme:t}=(0,Le.u)(),o=(0,i.useMemo)((()=>e?Ve(function(e){const t=e=>{if("object"==typeof e&&null!==e)for(const o in e)e.hasOwnProperty(o)&&(e[o]=t(e[o]));else if("string"==typeof e)return e.replace(/var\(--([a-z]+)--([a-z]+(?:--[a-z0-9]+(?:-[a-z0-9]+)*)*)--([a-z0-9-]+)\)/g,((e,t,o,n)=>`var:${o.split("--").concat(n).join("|")}`));return e};return t(e)}(e?.styles)):Ae),[e]),{styles:n}=(0,s.useSelect)((e=>({styles:e(j.H).getStyles()}))),r=(0,i.useCallback)((o=>{const n={...e,styles:Ve(o)};t(n)}),[t,e]),a=(0,i.useCallback)(((o,n)=>{const r=function(e,t,o){const n=Array.isArray(t)?[...t]:[t],r=Array.isArray(e)?[...e]:{...e},s=n.pop();let i=r;return n.forEach((e=>{const t=i[e];i[e]=Array.isArray(t)?[...t]:{...t},i=i[e]})),i[s]=o,r}(e,["styles",...o],n);t(r)}),[t,e]);return{styles:(0,i.useMemo)((()=>n?o?Fe().all([n,o]):n:Ae),[n,o]),userStyles:e?.styles,defaultStyles:n,updateStyleProp:a,updateStyles:r}};var Ge=o(5469);const We=[],Ue={start:{scale:1,opacity:1},hover:{scale:0,opacity:0}},qe={hover:{opacity:1},start:{opacity:.5}},Ye={hover:{scale:1,opacity:1},start:{scale:0,opacity:0}};function Je({label:e,isFocused:t,withHoverView:o}){const{colors:n}=(0,s.useSelect)((e=>({colors:e(j.H).getPaletteColors()})),[]),a=(0,i.useMemo)((()=>(n?.theme||We).concat(n?.default||We)),[n]),{styles:l}=De(),{backgroundColor:c,headingColor:d,highlightedColors:u}=(0,i.useMemo)((()=>{const e=(0,Ge.pr)(l?.color?.background)||"white",t=(0,Ge.pr)(l?.color?.text)||"black",o=(0,Ge.pr)(l?.elements?.h1?.color?.text)||t,n=(0,Ge.pr)(l?.elements?.link?.color?.text)||o,r=(0,Ge.pr)(l?.elements?.button?.color?.background)||n,s=a.find((({color:e})=>e.toLowerCase()===t.toLowerCase())),i=a.find((({color:e})=>e.toLowerCase()===r.toLowerCase())),c=[...s?[s]:We,...i?[i]:We,...a].filter((({color:t},o,n)=>t.toLowerCase()!==e.toLowerCase()&&o===n.findIndex((e=>e.color.toLowerCase()===t.toLowerCase())))).slice(0,2);return{backgroundColor:e,headingColor:o,highlightedColors:c}}),[l,a]),p=l?.elements?.heading?.typography?.fontWeight||"inherit",m=l?.elements?.heading?.typography?.fontFamily||"inherit",[g,h]=(0,i.useState)(!1);return(0,r.jsx)("div",{onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:(0,r.jsxs)(v.__unstableMotion.div,{style:{height:152,width:"100%",background:c,cursor:o?"pointer":void 0},initial:"start",animate:(g||t)&&e?"hover":"start",children:[(0,r.jsx)(v.__unstableMotion.div,{variants:Ue,style:{height:"100%",overflow:"hidden"},children:(0,r.jsxs)(v.__experimentalHStack,{spacing:10,justify:"center",style:{height:"100%",overflow:"hidden"},children:[(0,r.jsx)(v.__unstableMotion.div,{style:{fontFamily:m,fontSize:65,color:d,fontWeight:p},animate:{scale:1,opacity:1},initial:{scale:.1,opacity:0},transition:{delay:.3,type:"tween"},children:"Aa"}),(0,r.jsx)(v.__experimentalVStack,{spacing:4,children:u.map((({slug:e,color:t},o)=>(0,r.jsx)(v.__unstableMotion.div,{style:{height:32,width:32,background:t,borderRadius:16},animate:{scale:1,opacity:1},initial:{scale:.1,opacity:0},transition:{delay:1===o?.2:.1}},e)))})]})}),(0,r.jsx)(v.__unstableMotion.div,{variants:o&&qe,style:{height:"100%",width:"100%",position:"absolute",top:0,overflow:"hidden",filter:"blur(60px)",opacity:.1},children:(0,r.jsx)(v.__experimentalHStack,{spacing:0,justify:"flex-start",style:{height:"100%",overflow:"hidden"},children:a.slice(0,4).map((({color:e})=>(0,r.jsx)("div",{style:{height:"100%",background:e,flexGrow:1}},e)))})}),(0,r.jsx)(v.__unstableMotion.div,{variants:Ye,style:{height:"100%",width:"100%",overflow:"hidden",position:"absolute",top:0},children:(0,r.jsx)(v.__experimentalVStack,{spacing:3,justify:"center",style:{height:"100%",overflow:"hidden",padding:10,boxSizing:"border-box"},children:e&&(0,r.jsx)("div",{style:{fontSize:40,fontFamily:m,color:d,fontWeight:p,lineHeight:"1em",textAlign:"center"},children:e})})})]})})}function Ke(){return(0,r.jsx)(v.Card,{size:"small",className:"edit-site-global-styles-screen-root",variant:"primary",children:(0,r.jsx)(v.CardBody,{children:(0,r.jsxs)(v.__experimentalVStack,{spacing:4,children:[(0,r.jsx)(v.Card,{children:(0,r.jsx)(v.CardMedia,{children:(0,r.jsx)(Je,{})})}),(0,r.jsxs)(v.__experimentalItemGroup,{children:[(0,r.jsx)(v.__experimentalNavigatorButton,{path:"/typography",onClick:()=>(0,C.yM)("styles_sidebar_navigation_click",{path:"typography"}),children:(0,r.jsx)(v.__experimentalItem,{children:(0,r.jsxs)(v.__experimentalHStack,{justify:"flex-start",children:[(0,r.jsx)(v.Icon,{icon:$e,size:24}),(0,r.jsx)(v.FlexItem,{children:(0,y.__)("Typography","woocommerce")})]})})}),(0,r.jsx)(v.__experimentalNavigatorButton,{path:"/colors",onClick:()=>(0,C.yM)("styles_sidebar_navigation_click",{path:"colors"}),children:(0,r.jsx)(v.__experimentalItem,{children:(0,r.jsxs)(v.__experimentalHStack,{justify:"flex-start",children:[(0,r.jsx)(v.Icon,{icon:ze,size:24}),(0,r.jsx)(v.FlexItem,{children:(0,y.__)("Colors","woocommerce")})]})})}),(0,r.jsx)(v.__experimentalNavigatorButton,{path:"/layout",onClick:()=>(0,C.yM)("styles_sidebar_navigation_click",{path:"layout"}),children:(0,r.jsx)(v.__experimentalItem,{children:(0,r.jsxs)(v.__experimentalHStack,{justify:"flex-start",children:[(0,r.jsx)(v.Icon,{icon:He,size:24}),(0,r.jsx)(v.FlexItem,{children:(0,y.__)("Layout","woocommerce")})]})})})]})]})})})}const Ze={typography:{},color:{}},Xe=(e,t,o="heading",n=!1)=>{switch(t){case"text":return{typography:e.typography,color:e.color};case"heading":return((e,t="heading",o=!1)=>o?Fe().all([Ze,e.elements.heading||{},e.elements[t]||{}]):{...Ze,...e.elements.heading||{},...e.elements[t]||{}})(e,null!=o?o:"heading",n);default:return e.elements[t]||Ze}};function Qe({element:e,label:t}){const{styles:o}=De(),n=Xe(o,e,null,!0),{fontFamily:s,fontStyle:i,fontWeight:a,letterSpacing:l,textDecoration:c,textTransform:d}=n.typography,u=n.color?.text||"inherit",p=n.color?.background||"#f0f0f0",m=(0,y.sprintf)((0,y.__)("Typography %s styles","woocommerce"),t);return(0,r.jsx)(v.__experimentalItem,{children:(0,r.jsx)(v.__experimentalNavigatorButton,{path:`/typography/${e}`,"aria-label":m,onClick:()=>(0,C.yM)("styles_sidebar_screen_typography_button_click",{element:e,label:t,path:`typography/${e}`}),children:(0,r.jsxs)(v.__experimentalHStack,{justify:"flex-start",children:[(0,r.jsx)(v.FlexItem,{className:"edit-site-global-styles-screen-typography__indicator",style:{fontFamily:null!=s?s:"serif",background:p,color:u,fontStyle:null!=i?i:"normal",fontWeight:null!=a?a:"normal",letterSpacing:null!=l?l:"normal",textDecoration:null!=c?c:"link"===e?"underline":"none",textTransform:null!=d?d:"none"},children:"Aa"}),(0,r.jsx)(v.FlexItem,{children:t})]})})})}const et=function(){return(0,r.jsx)(v.Card,{size:"small",variant:"primary",isBorderless:!0,children:(0,r.jsx)(v.CardBody,{children:(0,r.jsxs)(v.__experimentalVStack,{spacing:3,children:[(0,r.jsx)(v.__experimentalHeading,{level:3,className:"edit-site-global-styles-subtitle",children:(0,y.__)("Elements","woocommerce")}),(0,r.jsxs)(v.__experimentalItemGroup,{isBordered:!0,isSeparated:!0,size:"small",children:[(0,r.jsx)(Qe,{element:"text",label:(0,y.__)("Text","woocommerce")}),(0,r.jsx)(Qe,{element:"link",label:(0,y.__)("Links","woocommerce")}),(0,r.jsx)(Qe,{element:"heading",label:(0,y.__)("Headings","woocommerce")}),(0,r.jsx)(Qe,{element:"button",label:(0,y.__)("Buttons","woocommerce")})]})]})})})},tt=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z"})}),ot=v.Navigator||v.__experimentalNavigatorProvider;function nt({title:e,description:t,onBack:o}){return(0,r.jsxs)(v.__experimentalVStack,{spacing:0,children:[(0,r.jsx)(v.__experimentalView,{children:(0,r.jsx)(v.__experimentalSpacer,{marginBottom:0,paddingX:4,paddingY:3,children:(0,r.jsxs)(v.__experimentalHStack,{spacing:2,children:[(0,r.jsx)(ot.BackButton,{style:{minWidth:24,padding:0},icon:tt,size:"small","aria-label":(0,y.__)("Navigate to the previous view","woocommerce"),onClick:o}),(0,r.jsx)(v.__experimentalSpacer,{children:(0,r.jsx)(v.__experimentalHeading,{className:"woocommerce-email-editor-styles-header",level:2,size:13,children:e})})]})})}),t&&(0,r.jsx)("p",{className:"woocommerce-email-editor-styles-header-description",children:t})]})}v.Navigator||(ot.Screen=v.__experimentalNavigatorScreen,ot.BackButton=v.__experimentalNavigatorBackButton);const rt=nt;function st(){return(0,C.xW)("styles_sidebar_screen_typography_opened"),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rt,{title:(0,y.__)("Typography","woocommerce"),description:(0,y.__)("Manage the typography settings for different elements.","woocommerce")}),(0,r.jsx)(et,{})]})}const it={fontFamily:!0,fontSize:!0,fontAppearance:!0,lineHeight:!0,letterSpacing:!1,textTransform:!1,textDecoration:!1,writingMode:!0,textColumns:!0},at=function({element:e,headingLevel:t,defaultControls:o=it}){const[n,s]=(0,m.useSettings)("typography.fontSizes","typography.fontFamilies"),a=s?.default||[],{styles:l,defaultStyles:c,updateStyleProp:d}=De(),u=Xe(l,e,t),p=Xe(c,e,t),{fontFamily:g,fontSize:h,fontStyle:_,fontWeight:f,lineHeight:w,letterSpacing:x,textDecoration:b,textTransform:S}=u.typography,{fontFamily:k,fontSize:j,fontStyle:E,fontWeight:T,lineHeight:M,letterSpacing:P,textDecoration:N,textTransform:I}=p.typography,B="heading"!==e||"heading"!==t,$=(0,i.useCallback)(((o,n)=>{d("heading"===e?["elements",t,...o]:"text"===e?[...o]:["elements",e,...o],n)}),[e,d,t]),z=t=>{$(["typography","letterSpacing"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_letter_spacing",{element:e,newValue:t,selectedDefaultLetterSpacing:t===P})},H=t=>{$(["typography","lineHeight"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_line_height",{element:e,newValue:t,selectedDefaultLineHeight:t===M})},R=o=>{$(["typography","fontSize"],o),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_font_size",{element:e,headingLevel:t,newValue:o,selectedDefaultFontSize:o===j})},F=t=>{$(["typography","fontFamily"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_font_family",{element:e,newValue:t,selectedDefaultFontFamily:t===k})},L=t=>{$(["typography","textDecoration"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_text_decoration",{element:e,newValue:t,selectedDefaultTextDecoration:t===N})},A=t=>{$(["typography","textTransform"],t),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_text_transform",{element:e,newValue:t,selectedDefaultTextTransform:t===I})},O=({fontStyle:t,fontWeight:o})=>{$(["typography","fontStyle"],t),$(["typography","fontWeight"],o),(0,C.T7)("styles_sidebar_screen_typography_element_panel_set_font_appearance",{element:e,newFontStyle:t,newFontWeight:o,selectedDefaultFontStyle:t===E,selectedDefaultFontWeight:o===T})};return(0,r.jsxs)(v.__experimentalToolsPanel,{label:(0,y.__)("Typography","woocommerce"),resetAll:()=>{$(["typography"],{}),(0,C.yM)("styles_sidebar_screen_typography_element_panel_reset_all_styles_selected",{element:e,headingLevel:t})},children:[(0,r.jsx)(v.__experimentalToolsPanelItem,{label:(0,y.__)("Font family","woocommerce"),hasValue:()=>g!==k,onDeselect:()=>F(void 0),isShownByDefault:o.fontFamily,children:(0,r.jsx)(m.__experimentalFontFamilyControl,{value:g,onChange:F,size:"__unstable-large",fontFamilies:a,__nextHasNoMarginBottom:!0})}),B&&(0,r.jsx)(v.__experimentalToolsPanelItem,{label:(0,y.__)("Font size","woocommerce"),hasValue:()=>h!==j,onDeselect:()=>R(void 0),isShownByDefault:o.fontSize,children:(0,r.jsx)(v.FontSizePicker,{value:h,onChange:R,fontSizes:n,disableCustomFontSizes:!1,withReset:!1,withSlider:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0})}),(0,r.jsx)(v.__experimentalToolsPanelItem,{className:"single-column",label:(0,y.__)("Appearance","woocommerce"),hasValue:()=>f!==T||_!==E,onDeselect:()=>{O({fontStyle:void 0,fontWeight:void 0})},isShownByDefault:o.fontAppearance,children:(0,r.jsx)(m.__experimentalFontAppearanceControl,{value:{fontStyle:_,fontWeight:f},onChange:O,hasFontStyles:!0,hasFontWeights:!0,size:"__unstable-large"})}),(0,r.jsx)(v.__experimentalToolsPanelItem,{className:"single-column",label:(0,y.__)("Line height","woocommerce"),hasValue:()=>w!==M,onDeselect:()=>H(void 0),isShownByDefault:o.lineHeight,children:(0,r.jsx)(m.LineHeightControl,{__nextHasNoMarginBottom:!0,__unstableInputWidth:"auto",value:w,onChange:H,size:"__unstable-large"})}),(0,r.jsx)(v.__experimentalToolsPanelItem,{className:"single-column",label:(0,y.__)("Letter spacing","woocommerce"),hasValue:()=>x!==P,onDeselect:()=>z(void 0),isShownByDefault:o.letterSpacing,children:(0,r.jsx)(m.__experimentalLetterSpacingControl,{value:x,onChange:z,size:"__unstable-large",__unstableInputWidth:"auto"})}),(0,r.jsx)(v.__experimentalToolsPanelItem,{className:"single-column",label:(0,y.__)("Text decoration","woocommerce"),hasValue:()=>b!==N,onDeselect:()=>L(void 0),isShownByDefault:o.textDecoration,children:(0,r.jsx)(m.__experimentalTextDecorationControl,{value:b,onChange:L,size:"__unstable-large",__unstableInputWidth:"auto"})}),(0,r.jsx)(v.__experimentalToolsPanelItem,{label:(0,y.__)("Letter case","woocommerce"),hasValue:()=>S!==I,onDeselect:()=>A(I),isShownByDefault:o.textTransform,children:(0,r.jsx)(m.__experimentalTextTransformControl,{value:S,onChange:A,showNone:!0,isBlock:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0})})]})};function lt({element:e,headingLevel:t}){const{styles:o}=De(),n=Xe(o,e,t,!0),{fontFamily:s,fontSize:i,fontStyle:a,fontWeight:l,lineHeight:c,letterSpacing:d,textDecoration:u,textTransform:p}=n.typography,m=n.color?.text||"inherit",g=n.color?.background||"#f0f0f0",h="link"===e?{textDecoration:null!=u?u:"underline"}:{};return(0,r.jsx)("div",{className:"edit-site-typography-preview",style:{fontFamily:null!=s?s:"serif",background:g,color:m,lineHeight:c,fontSize:i,fontStyle:a,fontWeight:l,letterSpacing:d,textDecoration:u,textTransform:p,...h},children:"Aa"})}const ct={text:{title:(0,y.__)("Text","woocommerce"),description:(0,y.__)("Manage the fonts and typography used on text.","woocommerce"),defaultControls:it},link:{title:(0,y.__)("Links","woocommerce"),description:(0,y.__)("Manage the fonts and typography used on links.","woocommerce"),defaultControls:{...it,textDecoration:!0}},heading:{title:(0,y.__)("Headings","woocommerce"),description:(0,y.__)("Manage the fonts and typography used on headings.","woocommerce"),defaultControls:{...it,textTransform:!0}},button:{title:(0,y.__)("Buttons","woocommerce"),description:(0,y.__)("Manage the fonts and typography used on buttons.","woocommerce"),defaultControls:it}};function dt({element:e}){(0,C.xW)("styles_sidebar_screen_typography_element_opened",{element:e});const[t,o]=(0,i.useState)("heading");return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rt,{title:ct[e].title,description:ct[e].description}),(0,r.jsx)(v.__experimentalSpacer,{marginX:4,children:(0,r.jsx)(lt,{element:e,headingLevel:t})}),"heading"===e&&(0,r.jsx)(v.__experimentalSpacer,{marginX:4,marginBottom:"1em",children:(0,r.jsxs)(v.__experimentalToggleGroupControl,{label:(0,y.__)("Select heading level","woocommerce"),hideLabelFromVision:!0,value:t,onChange:e=>{o(e.toString()),(0,C.yM)("styles_sidebar_screen_typography_element_heading_level_selected",{value:e})},isBlock:!0,size:"__unstable-large",__nextHasNoMarginBottom:!0,children:[(0,r.jsx)(v.__experimentalToggleGroupControlOption,{value:"heading",label:(0,y._x)("All","heading levels","woocommerce")}),(0,r.jsx)(v.__experimentalToggleGroupControlOption,{value:"h1",label:(0,y._x)("H1","Heading Level","woocommerce")}),(0,r.jsx)(v.__experimentalToggleGroupControlOption,{value:"h2",label:(0,y._x)("H2","Heading Level","woocommerce")}),(0,r.jsx)(v.__experimentalToggleGroupControlOption,{value:"h3",label:(0,y._x)("H3","Heading Level","woocommerce")}),(0,r.jsx)(v.__experimentalToggleGroupControlOption,{value:"h4",label:(0,y._x)("H4","Heading Level","woocommerce")}),(0,r.jsx)(v.__experimentalToggleGroupControlOption,{value:"h5",label:(0,y._x)("H5","Heading Level","woocommerce")}),(0,r.jsx)(v.__experimentalToggleGroupControlOption,{value:"h6",label:(0,y._x)("H6","Heading Level","woocommerce")})]})}),(0,r.jsx)(at,{element:e,headingLevel:t,defaultControls:ct[e].defaultControls})]})}function ut(){(0,C.xW)("styles_sidebar_screen_colors_opened");const{userStyles:e,styles:t,updateStyles:o}=De(),n=(0,s.useSelect)((e=>e(j.H).getTheme()),[]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(rt,{title:(0,y.__)("Colors","woocommerce"),description:(0,y.__)("Manage palettes and the default color of different global elements.","woocommerce")}),(0,r.jsx)(D,{value:e,inheritedValue:t,onChange:e=>{o(e),(0,C.yM)("styles_sidebar_screen_colors_styles_updated")},settings:n?.settings,panelId:"colors"})]})}var pt=o(66087);function mt(){const[e]=(0,m.useSettings)("spacing.units"),t=(0,v.__experimentalUseCustomUnits)({availableUnits:e}),{styles:o,defaultStyles:n,updateStyleProp:s}=De();return(0,r.jsxs)(v.__experimentalToolsPanel,{label:(0,y.__)("Dimensions","woocommerce"),resetAll:()=>{s(["spacing"],n.spacing),(0,C.yM)("styles_sidebar_screen_layout_dimensions_reset_all_selected")},children:[(0,r.jsx)(v.__experimentalToolsPanelItem,{isShownByDefault:!0,hasValue:()=>!(0,pt.isEqual)(o.spacing.padding,n.spacing.padding),label:(0,y.__)("Padding","woocommerce"),onDeselect:()=>{s(["spacing","padding"],n.spacing.padding),(0,C.yM)("styles_sidebar_screen_layout_dimensions_padding_reset_clicked")},className:"tools-panel-item-spacing",children:(0,r.jsx)(m.__experimentalSpacingSizesControl,{allowReset:!0,values:o.spacing.padding,onChange:e=>{s(["spacing","padding"],e),(0,C.T7)("styles_sidebar_screen_layout_dimensions_padding_updated",{value:e})},label:(0,y.__)("Padding","woocommerce"),sides:["horizontal","vertical","top","left","right","bottom"],units:t})}),(0,r.jsx)(v.__experimentalToolsPanelItem,{isShownByDefault:!0,label:(0,y.__)("Block spacing","woocommerce"),hasValue:()=>o.spacing.blockGap!==n.spacing.blockGap,onDeselect:()=>{s(["spacing","blockGap"],n.spacing.blockGap),(0,C.yM)("styles_sidebar_screen_layout_dimensions_block_spacing_reset_clicked")},className:"tools-panel-item-spacing",children:(0,r.jsx)(m.__experimentalSpacingSizesControl,{label:(0,y.__)("Block spacing","woocommerce"),min:0,onChange:e=>{s(["spacing","blockGap"],e.top),(0,C.T7)("styles_sidebar_screen_layout_dimensions_block_spacing_updated",{value:e})},showSideInLabel:!1,sides:["top"],values:{top:o.spacing.blockGap},allowReset:!0})})]})}function gt(){return(0,C.xW)("styles_sidebar_screen_layout_opened"),(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(nt,{title:(0,y.__)("Layout","woocommerce")}),(0,r.jsx)(mt,{})]})}const ht=(0,i.memo)((function(){const{userCanEditGlobalStyles:e}=(0,s.useSelect)((e=>{const{canEdit:t}=e(j.H).canUserEditGlobalEmailStyles();return{userCanEditGlobalStyles:t}}),[]);return e&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.PluginSidebarMoreMenuItem,{target:"email-styles-sidebar",icon:Be,children:(0,y.__)("Email styles","woocommerce")}),(0,r.jsx)(l.PluginSidebar,{name:"email-styles-sidebar",icon:Be,title:(0,y.__)("Styles","woocommerce"),className:"woocommerce-email-editor-styles-panel",header:(0,y.__)("Styles","woocommerce"),children:(0,r.jsxs)(ot,{initialPath:"/",children:[(0,r.jsx)(ot.Screen,{path:"/",children:(0,r.jsx)(Ke,{})}),(0,r.jsx)(ot.Screen,{path:"/typography",children:(0,r.jsx)(st,{})}),(0,r.jsx)(ot.Screen,{path:"/typography/text",children:(0,r.jsx)(dt,{element:"text"})}),(0,r.jsx)(ot.Screen,{path:"/typography/link",children:(0,r.jsx)(dt,{element:"link"})}),(0,r.jsx)(ot.Screen,{path:"/typography/heading",children:(0,r.jsx)(dt,{element:"heading"})}),(0,r.jsx)(ot.Screen,{path:"/typography/button",children:(0,r.jsx)(dt,{element:"button"})}),(0,r.jsx)(ot.Screen,{path:"/colors",children:(0,r.jsx)(ut,{})}),(0,r.jsx)(ot.Screen,{path:"/layout",children:(0,r.jsx)(gt,{})})]})})]})})),_t=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})});var ft=o(30221);function yt(){const{togglePreviewModal:e}=(0,s.useDispatch)(j.H);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.PluginPreviewMenuItem,{icon:_t,onClick:()=>{(0,C.yM)("header_preview_dropdown_send_test_email_selected"),e(!0)},children:(0,y.__)("Send a test email","woocommerce")}),(0,r.jsx)(ft.P,{})]})}var wt=o(48558),xt=o(41233);const bt=()=>{const e=(0,c.useViewportMatch)("large");return(0,r.jsx)(r.Fragment,{children:e&&(0,r.jsx)(U,{children:(0,r.jsx)(xt.PreferenceToggleMenuItem,{scope:j.H,name:"fullscreenMode",label:(0,y.__)("Fullscreen mode","woocommerce"),info:(0,y.__)("Show and hide the admin user interface","woocommerce"),messageActivated:(0,y.__)("Fullscreen mode activated.","woocommerce"),messageDeactivated:(0,y.__)("Fullscreen mode deactivated.","woocommerce"),shortcut:wt.displayShortcut.secondary("f")})})})};var vt=o(46296);function St({close:e}){(0,C.xW)("edit_template_modal_opened");const{onNavigateToEntityRecord:t,template:o}=(0,s.useSelect)((e=>{const{getEditorSettings:t}=e(l.store),o=t();return{onNavigateToEntityRecord:o?.onNavigateToEntityRecord,template:e(j.H).getCurrentTemplate()}}),[]);return(0,r.jsxs)(v.Modal,{size:"medium",onRequestClose:e,__experimentalHideHeader:!0,children:[(0,r.jsx)("p",{children:(0,y.__)("This template is used by multiple emails. Any changes made would affect other emails on the site. Are you sure you want to edit the template?","woocommerce")}),(0,r.jsxs)(v.Flex,{justify:"end",children:[(0,r.jsx)(v.FlexItem,{children:(0,r.jsx)(v.Button,{variant:"tertiary",onClick:()=>{(0,C.yM)("edit_template_modal_cancel_button_clicked"),e()},children:(0,y.__)("Cancel","woocommerce")})}),(0,r.jsx)(v.FlexItem,{children:(0,r.jsx)(v.Button,{variant:"primary",onClick:()=>{(0,C.yM)("edit_template_modal_continue_button_clicked",{templateId:o.id}),t?.({postId:o.id,postType:"wp_template"})},disabled:!o.id||!t,children:(0,y.__)("Edit template","woocommerce")})})]})]})}function kt(){const{template:e,currentEmailContent:t,canUpdateTemplates:o,postType:n}=(0,s.useSelect)((e=>({template:e(j.H).getCurrentTemplate(),currentEmailContent:e(j.H).getEditedEmailContent(),canUpdateTemplates:e(j.H).canUserEditTemplates(),postType:e(j.H).getEmailPostType()})),[]),[a]=(0,xe.p)("swap"),[l,c]=(0,i.useState)(!1),[d,u]=(0,i.useState)(!1);return(0,r.jsxs)(r.Fragment,{children:[e&&(0,r.jsx)(v.PanelRow,{children:(0,r.jsxs)(v.Flex,{justify:"start",children:[(0,r.jsx)(v.FlexItem,{className:"editor-post-panel__row-label",children:(0,y.__)("Template","woocommerce")}),(0,r.jsxs)(v.FlexItem,{children:[!(a?.length>1||o)&&(0,r.jsx)("b",{children:e?.title}),(a?.length>1||o)&&(0,r.jsx)(v.DropdownMenu,{icon:null,text:e?.title,toggleProps:{variant:"tertiary"},label:(0,y.__)("Template actions","woocommerce"),onToggle:t=>(0,C.yM)("sidebar_template_actions_clicked",{currentTemplate:e?.title,isOpen:t}),children:({onClose:e})=>(0,r.jsxs)(r.Fragment,{children:[o&&(0,r.jsx)(v.MenuItem,{onClick:()=>{(0,C.yM)("sidebar_template_actions_edit_template_clicked"),c(!0),e()},children:(0,y.__)("Edit template","woocommerce")}),a?.length>1&&(0,r.jsx)(v.MenuItem,{onClick:()=>{(0,C.yM)("sidebar_template_actions_swap_template_clicked"),u(!0),e()},children:(0,y.__)("Swap template","woocommerce")})]})})]})]})}),l&&(0,r.jsx)(St,{close:()=>((0,C.yM)("edit_template_modal_closed"),c(!1))}),d&&(0,r.jsx)(Ne,{onSelectCallback:()=>u(!1),closeCallback:()=>u(!1),previewContent:t,postType:n})]})}const jt={recordEvent:C.yM,recordEventOnce:C.xW,debouncedRecordEvent:C.T7};function Et(){const e=(0,i.useMemo)((()=>(0,a.applyFilters)("woocommerce_email_editor_setting_sidebar_extension_component",vt.O,jt)),[]),t=(0,i.useMemo)((()=>(0,a.applyFilters)("woocommerce_email_editor_setting_sidebar_email_status_component",(()=>null),jt)),[]);return(0,r.jsxs)(l.PluginDocumentSettingPanel,{name:"email-settings-panel",title:(0,y.__)("Settings","woocommerce"),className:"woocommerce-email-editor__settings-panel",children:[(0,r.jsx)(t,{}),(0,r.jsx)(kt,{}),(0,r.jsx)(l.ErrorBoundary,{canCopyContent:!0,children:(0,r.jsx)(e,{})})]})}const Tt={recordEvent:C.yM,recordEventOnce:C.xW,debouncedRecordEvent:C.T7};function Ct(){const e=(0,a.applyFilters)("woocommerce_email_editor_template_sections",[],Tt);return 0===e.length?null:(0,r.jsx)(l.PluginDocumentSettingPanel,{name:"template-settings-panel",title:(0,y.__)("Settings","woocommerce"),className:"woocommerce-email-editor__settings-panel",children:e.map((e=>(0,r.jsx)(l.ErrorBoundary,{children:(0,r.jsx)("div",{children:e.render()},e.id)},`error-boundary-${e.id}`)))})}function Mt(){const{isDirty:e}=(0,l.useEntitiesSavedStatesIsDirty)(),{hasEmptyContent:t,isEmailSent:o,urls:n}=(0,s.useSelect)((e=>({hasEmptyContent:e(j.H).hasEmptyContent(),isEmailSent:e(j.H).isEmailSent(),urls:e(j.H).getUrls()})),[]);function i(){n.send&&(window.location.href=n.send)}const c=t||o||e,d=(0,a.applyFilters)("woocommerce_email_editor_send_button_label",(0,y.__)("Send","woocommerce"));return(0,r.jsx)(v.Button,{variant:"primary",size:"compact",onClick:()=>{(0,C.yM)("header_send_button_clicked"),(0,a.applyFilters)("woocommerce_email_editor_send_action_callback",i)()},disabled:c,"data-automation-id":"email_editor_send_button",children:d})}function Pt({children:e}){const t=(0,i.useRef)(document.createElement("div"));return(0,i.useEffect)((()=>{const e=document.getElementsByClassName("editor-post-publish-button__button")[0];e&&e.parentNode?.insertBefore(t.current,e.nextSibling)}),[t]),(0,i.createPortal)((0,r.jsx)(r.Fragment,{children:e}),t.current)}function Nt(){const e=(0,i.useRef)(null),{hasNonPostEntityChanges:t,isEditedPostDirty:o,isEditingTemplate:n}=(0,s.useSelect)((e=>({hasNonPostEntityChanges:e(l.store).hasNonPostEntityChanges(),isEditedPostDirty:e(l.store).isEditedPostDirty(),isEditingTemplate:"wp_template"===e(l.store).getCurrentPostType()})),[]),a=n||t||o&&t,c=(0,i.useCallback)(((e,t)=>{t&&e.classList.contains("force-hidden")&&e.classList.remove("force-hidden"),t||e.classList.contains("force-hidden")||e.classList.add("force-hidden")}),[]);return(0,i.useEffect)((()=>{const t=document.getElementsByClassName("editor-post-publish-button__button")[0];return c(t,a),t?(e.current&&e.current.disconnect(),e.current=new MutationObserver((()=>{c(t,a)})),e.current.observe(t,{attributes:!0,childList:!0,subtree:!1}),()=>e.current?.disconnect()):()=>e.current?.disconnect()}),[a,c]),(0,r.jsx)(Pt,{children:!a&&(0,r.jsx)(Mt,{})})}const It=()=>{const e="email-validation",t=(0,s.useSelect)((t=>t(Z.store).getNotices(e)));return{notices:t,hasValidationNotice:(0,i.useCallback)((e=>e?void 0!==t.find((t=>t.id===e)):t?.length>0),[t]),addValidationNotice:(0,i.useCallback)(((t,o,n=[])=>{(0,s.dispatch)(Z.store).createNotice("error",o,{id:t,isDismissible:!1,actions:n,context:e})}),[e]),removeValidationNotice:(0,i.useCallback)((t=>{(0,s.dispatch)(Z.store).removeNotice(t,e)}),[e])}};function Bt(){const{notices:e}=It();return 0===e.length?null:(0,r.jsx)(v.Notice,{status:"error",className:"woocommerce-email-editor-validation-errors components-editor-notices__pinned",isDismissible:!1,children:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("strong",{children:(0,y.__)("Fix errors to continue:","woocommerce")}),(0,r.jsx)("ul",{children:e.map((({id:e,content:t,actions:o})=>(0,r.jsxs)("li",{children:[t,o.length>0?o.map((({label:e,onClick:t})=>(0,r.jsx)(v.Button,{onClick:t,variant:"link",children:e},e))):null]},e)))})]})})}function $t({context:e="email-editor"}){const{notices:t}=(0,s.useSelect)((t=>({notices:t(Z.store).getNotices(e)})),[e]),o=(0,i.useMemo)((()=>({"site-editor-save-success":{content:(0,y.__)("Email design updated.","woocommerce"),removeActions:!0},"editor-save":{content:(0,y.__)("Email saved.","woocommerce"),removeActions:!1,contentCheck:e=>e.content.includes((0,y.__)("Post updated."))}})),[]),{removeNotice:n}=(0,s.useDispatch)(Z.store),a=t.filter((({type:e})=>"snackbar"===e)).map((e=>o[e.id]?o[e.id].contentCheck&&!o[e.id].contentCheck(e)?e:{...e,content:o[e.id].content,spokenMessage:o[e.id].content,actions:o[e.id].removeActions?[]:e.actions}:e));return(0,r.jsx)(v.SnackbarList,{notices:a,className:"components-editor-notices__snackbar",onRemove:t=>n(t,e)})}function zt({children:e}){const[t]=(0,i.useState)(document.createElement("div"));return(0,i.useEffect)((()=>{const e=document.getElementsByClassName("editor-visual-editor ")[0];e&&e.parentNode?.insertBefore(t,e)}),[t]),(0,i.createPortal)((0,r.jsx)(r.Fragment,{children:e}),t)}function Ht(){const{notices:e}=(0,s.useSelect)((e=>({notices:e(Z.store).getNotices("email-editor")})),[]),{removeNotice:t}=(0,s.useDispatch)(Z.store),o=e.filter((({isDismissible:e,type:t})=>e&&"default"===t)),n=e.filter((({isDismissible:e,type:t})=>!e&&"default"===t));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(zt,{children:[(0,r.jsx)(v.NoticeList,{notices:n,className:"components-editor-notices__pinned"}),(0,r.jsx)(v.NoticeList,{notices:o,className:"components-editor-notices__dismissible",onRemove:e=>t(e,"email-editor")}),(0,r.jsx)(Bt,{})]}),(0,r.jsx)($t,{context:"global"}),(0,r.jsx)($t,{context:"email-editor"})]})}const Rt=e=>{const t=(0,d.getBlockSupport)(e,"background");return t&&!1!==t?.backgroundImage};function Ft(){const e=(0,s.useSelect)((e=>e("core/block-editor").getSelectedBlock()),[]),t=(0,d.hasBlockSupport)(e?.name,"border",!1)||(0,d.hasBlockSupport)(e?.name,"__experimentalBorder",!1);return(0,r.jsxs)(r.Fragment,{children:[t&&(0,r.jsx)(v.Fill,{name:"InspectorControlsBorder",children:(0,r.jsxs)(v.Notice,{className:"woocommerce-grid-full-width",status:"warning",isDismissible:!1,children:[(0,y.__)("Border display may vary or be unsupported in some email clients.","woocommerce"),(0,r.jsx)("br",{}),(0,y.__)("Units other than pixels (px) lack support in old email clients.","woocommerce")]})}),Rt(e?.name)&&(0,r.jsx)(v.Fill,{name:"InspectorControlsBackground",children:(0,r.jsx)(v.Notice,{className:"woocommerce-grid-full-width",status:"warning",isDismissible:!1,children:(0,y.__)("Select a background color for email clients that do not support background images.","woocommerce")})})]})}const Lt=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"-2 -2 24 24",children:(0,r.jsx)(X.Path,{d:"M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"})}),At=(0,r.jsx)(X.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,r.jsx)(X.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})}),Ot={edit:{opacity:0,scale:.2},hover:{opacity:1,scale:1,clipPath:"inset( 22% round 2px )"}},Vt={edit:{clipPath:"inset(0% round 0px)"},hover:{clipPath:"inset( 22% round 2px )"},tap:{clipPath:"inset(0% round 0px)"}},Dt=()=>{const{urls:e}=(0,s.useSelect)((e=>({urls:e(j.H).getUrls()})),[]);function t(){e.listings&&(window.location.href=e.back)}return(0,r.jsxs)(v.__unstableMotion.div,{className:"woocommerce-email-editor__view-mode-toggle",transition:{duration:.2},animate:"edit",initial:"edit",whileHover:"hover",whileTap:"tap",children:[(0,r.jsx)(v.Button,{label:(0,y.__)("Close editor","woocommerce"),showTooltip:!0,tooltipPosition:"middle right",onClick:()=>{(0,C.yM)("header_close_button_clicked"),(0,a.applyFilters)("woocommerce_email_editor_close_action_callback",t)()},children:(0,r.jsx)(v.__unstableMotion.div,{variants:Vt,children:(0,r.jsx)("div",{className:"woocommerce-email-editor__view-mode-toggle-icon",children:(0,r.jsx)(be.A,{className:"woocommerce-email-editor-icon__icon",icon:Lt,size:48})})})}),(0,r.jsx)(v.__unstableMotion.div,{className:"woocommerce-email-editor-icon",variants:Ot,children:(0,r.jsx)(be.A,{icon:At})})]})},Gt=()=>{const e=(0,a.applyFilters)("woocommerce_email_editor_close_content",Dt);return(0,r.jsx)(q,{children:({length:t})=>t<=1&&(0,r.jsx)(e,{})})};function Wt({postId:e,postType:t,settings:o,contentRef:n}){const{currentPost:a,onNavigateToEntityRecord:c,onNavigateToPreviousEntityRecord:d}=function(e,t,o){const[n,r]=(0,i.useReducer)(((e,{type:t,post:o,previousRenderingMode:n})=>"push"===t?[...e,{post:o,previousRenderingMode:n}]:"pop"===t&&e.length>1?e.slice(0,-1):e),[{post:{postId:e,postType:t}}]),{post:a,previousRenderingMode:c}=n[n.length-1],{getRenderingMode:d}=(0,s.useSelect)(l.store),{setRenderingMode:u}=(0,s.useDispatch)(l.store),p=(0,i.useCallback)((e=>{r({type:"push",post:{postId:e.postId,postType:e.postType},previousRenderingMode:d()}),u(o)}),[d,u,o]),m=(0,i.useCallback)((()=>{r({type:"pop"}),c&&u(c)}),[u,c]);return{currentPost:a,onNavigateToEntityRecord:p,onNavigateToPreviousEntityRecord:n.length>1?m:void 0}}(e,t,"post-only"),{post:u,template:p}=(0,s.useSelect)((e=>{const{getEntityRecord:t}=e(K.store),{getEditedPostTemplate:o}=e(j.H),n=t("postType",a.postType,a.postId);return{template:n&&"wp_template"!==a.postType?o(n.template):null,post:n}}),[a.postType,a.postId]),{isFullscreenEnabled:m,allCommands:g}=(0,s.useSelect)((e=>({isFullscreenEnabled:e(j.H).isFeatureActive("fullscreenMode"),allCommands:e(_e.store).getCommands()})),[]),{isFullScreenForced:h,displaySendEmailButton:_}=o,{removeEditorPanel:f}=(0,s.useDispatch)(l.store);(0,i.useEffect)((()=>{f("post-status")}),[f]);const[y]=(0,ye.b)(),w=(0,i.useMemo)((()=>({...o,onNavigateToEntityRecord:c,onNavigateToPreviousEntityRecord:d,defaultRenderingMode:"wp_template"===a.postType?"post-only":"template-locked",supportsTemplateMode:!0,styles:y})),[o,c,d,a.postType,y]);return u&&("wp_template"===a.postType||u.template===p?.slug||!u.template&&p)?((0,C.xW)("editor_layout_loaded"),(0,r.jsx)(v.SlotFillProvider,{children:(0,r.jsxs)(l.ErrorBoundary,{canCopyContent:!0,children:[(!g||0===g.length)&&(0,r.jsx)(_e.CommandMenu,{}),(0,r.jsxs)(G,{postId:a.postId,postType:a.postType,settings:w,templateId:p&&p.id,contentRef:n,styles:y,children:[(0,r.jsx)(l.AutosaveMonitor,{}),(0,r.jsx)(l.LocalAutosaveMonitor,{}),(0,r.jsx)(l.UnsavedChangesWarning,{}),(0,r.jsx)(l.EditorKeyboardShortcutsRegister,{}),(0,r.jsx)(l.PostLockedModal,{}),(0,r.jsx)(Ie,{}),(0,r.jsx)(ht,{}),(0,r.jsx)(yt,{}),(0,r.jsx)(we,{}),(0,r.jsx)(W,{isActive:h||m}),(h||m)&&(0,r.jsx)(Gt,{}),!h&&(0,r.jsx)(bt,{}),"wp_template"===a.postType?(0,r.jsx)(Ct,{}):(0,r.jsx)(Et,{}),_&&(0,r.jsx)(Nt,{}),(0,r.jsx)(Ht,{}),(0,r.jsx)(Ft,{}),(0,r.jsx)(fe.PluginArea,{scope:"woocommerce-email-editor"})]})]})})):(0,r.jsx)("div",{className:"spinner-container",children:(0,r.jsx)(v.Spinner,{style:{width:"80px",height:"80px"}})})}var Ut=o(9463);const qt=()=>{const e={"You’ve tried to select a block that is part of a template that may be used elsewhere on your site. Would you like to edit the template?":{domain:"default",replacementText:(0,y.__)("You’ve tried to select a block that is part of a template that may be used in other emails. Would you like to edit the template?","woocommerce")}};(0,h.HY)("i18n.gettext","woocommerce/email-editor/override-text",((t,o,n)=>e[o]&&e[o].domain===(n||"default")?e[o].replacementText:t))},Yt=e=>{(0,a.doAction)("woocommerce_email_editor_events",e.detail)},Jt=()=>{(0,C.V1)()&&C.oh.addEventListener(C.vD,Yt)};window.addEventListener("unload",(function(){(0,C.V1)()&&C.oh.removeEventListener(C.vD,Yt)}));const Kt=(...e)=>{const t=(0,s.select)(l.store).isInserterOpened(),o=!!document.getElementsByClassName("block-editor-inserter__quick-inserter").length;let n="other_inserter";t?n="inserter_sidebar":o&&(n="quick_inserter");const r=e[0],i=e[5];!1===Array.isArray(r)&&"object"==typeof r&&(0,C.yM)(`${n}_library_block_selected`,{blockName:r.name}),Array.isArray(r)&&i&&i.patternName&&(0,C.yM)(`${n}_library_pattern_selected`,{patternName:i.patternName})},Zt={"core/editor":{autosave:"editor_content_auto_saved",setDeviceType:e=>{(0,C.yM)(`header_preview_dropdown_${e.toLowerCase()}_selected`)},setRenderingMode:e=>{(0,s.select)(l.store).getRenderingMode()!==e&&document.querySelector(`[aria-label="${(0,y.__)("View options")}"]`)&&(0,C.yM)("preview_dropdown_rendering_mode_changed",{renderingMode:e})}},"core/block-editor":{insertBlock:Kt,insertBlocks:Kt},"core/preferences":{set:(e,t,o)=>{if((0,s.select)(xt.store).get(e,t)===o)return;const n={focusMode:"focus_mode_toggle",fullscreenMode:"full_screen_mode_toggle",distractionFree:"distraction_free_toggle",fixedToolbar:"fixed_toolbar_toggle"};n[t]&&(0,C.yM)(n[t],{isEnabled:o})}},"core/commands":{open:"command_menu_opened",close:"command_menu_closed"}},Xt={},Qt={},eo=()=>{(0,C.V1)()&&(0,s.use)((e=>({dispatch:t=>{const o="object"==typeof t?t.name:t,n=e.dispatch(o),r=Zt[o];if(!r)return n;Xt[o]||(Xt[o]={}),Qt[o]||(Qt[o]={});for(const[e,t]of Object.entries(r))Qt[o][e]||(Qt[o][e]=n[e],Xt[o][e]=(...n)=>{try{"function"==typeof t?t(...n):"string"==typeof t&&(0,C.yM)(t)}catch(e){console.error("Error tracking event",e)}return Qt[o][e](...n)}),n[e]=Xt[o][e];return n}})))};let to=[];function oo(e){to.forEach((t=>{const o=e.target?.matches?.(t.selector)?e.target:e.target?.closest?.(t.selector);o&&("function"==typeof t.track?t.track(o,e):(0,C.yM)(t.track))}))}const no=new WeakMap,ro={core:["saveEditedEntityRecord","saveEntityRecord"]},so=()=>{Object.keys(no).length>0||(0,s.use)((e=>({dispatch:t=>{const o="object"==typeof t?t.name:t;if(!ro[o])return e.dispatch(o);const n=e.dispatch(o);no[o]||(no[o]={});const r=ro[o].filter((e=>!no[o][e]));if(r.length>0)for(const t of r)no[o][t]=n[t],n[t]=async(...n)=>{const r=e.select(j.H).getContentValidation(),s=r?.validateContent;if(s){let e;try{e=s()}catch(t){e=!1}if(!e)return Promise.reject(new Error((0,y.__)("Content validation failed.","woocommerce")))}return await no[o][t](...n)};return n}})))},io=window.wp.isShallowEqual;var ao=o.n(io);function lo(e){const t=(0,i.useRef)(e);return ao()(e,t.current)||(t.current=e),t.current}const co=[],uo=()=>{const{addValidationNotice:e,hasValidationNotice:t,removeValidationNotice:o}=It(),{editedContent:n,editedTemplateContent:r}=(0,s.useSelect)((e=>({editedContent:e(j.H).getEditedEmailContent(),editedTemplateContent:e(j.H).getCurrentTemplateContent()}))),l=lo(n),c=lo(r),d=(0,i.useCallback)((()=>((e,t,{addValidationNotice:o,hasValidationNotice:n,removeValidationNotice:r})=>{const s=(0,a.applyFilters)("woocommerce_email_editor_content_validation_rules",co);let i=!0;return s.forEach((({id:s,testContent:a,message:l,actions:c})=>{a(e+t)?(o(s,l,c),i=!1):n(s)&&r(s)})),i})(l,c,{addValidationNotice:e,hasValidationNotice:t,removeValidationNotice:o})),[l,c,e,o,t]);return(0,i.useEffect)((()=>((0,s.dispatch)(j.H).setContentValidation({validateContent:d}),()=>{(0,s.dispatch)(j.H).setContentValidation(void 0)})),[d]),(0,i.useEffect)((()=>{const e=(0,s.subscribe)((()=>{t()&&d()}),K.store);return()=>e()}),[t,d]),{validateContent:d}},po=()=>{const e=(0,i.useMemo)((()=>{const e=(0,y.__)("Saving failed.");return new RegExp("^"+e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"))}),[]);(0,i.useEffect)((()=>{const t=(0,s.subscribe)((()=>{(0,s.select)(Z.store).getNotices().forEach((t=>{"string"==typeof t.content&&e.test(t.content)&&(0,s.dispatch)(Z.store).removeNotice(t.id)}))}));return()=>{t()}}),[e])},mo=()=>{const e=(0,i.useRef)(null),[t,o]=(0,i.useState)(0),n=(0,i.useCallback)((t=>{e.current=t,o((e=>++e))}),[e,o]),r=(0,s.useSelect)((e=>{var t;const{getEditorSettings:o}=e(l.store);return null!==(t=o()?.allowedIframeStyleHandles)&&void 0!==t?t:[]}));return(0,i.useEffect)((()=>{if(!e.current)return;const{ownerDocument:t}=e.current;Array.from(document.styleSheets).filter((e=>{if(!(e?.ownerNode instanceof Element))return!1;const t=e.ownerNode.getAttribute("id"),o=t&&!r.includes(t);return(0,a.applyFilters)("woocommerce_email_editor_iframe_stylesheet_should_remove",o,e)})).map((e=>e.ownerNode.getAttribute("id"))).forEach((e=>{const o=t.getElementById(e);o&&o.remove();const n=t.createElement("style");n.id=e,t.head.appendChild(n)}))}),[r,t]),n};var go=o(46701);function ho(){if(!window.WooCommerceEmailEditor)throw new Error("WooCommerceEmailEditor global object is not available. This is required for the email editor to work.");const e=window.WooCommerceEmailEditor.editor_settings,t=window.WooCommerceEmailEditor.editor_theme,o=window.WooCommerceEmailEditor.urls,n=window.WooCommerceEmailEditor.current_wp_user_email,r=window.WooCommerceEmailEditor.user_theme_post_id;if(!e)throw new Error("window.WooCommerceEmailEditor.editor_settings is required.");if(!t)throw new Error("window.WooCommerceEmailEditor.editor_theme is required.");if(!o||"string"!=typeof o.back||"string"!=typeof o.listings)throw new Error("window.WooCommerceEmailEditor.urls.back and .listings are required strings.");return{editorSettings:e,theme:t,urls:o,userEmail:n,globalStylesPostId:null!=r?r:null}}function _o({postId:e,postType:t,isPreview:o=!1,contentRef:n=null}){const[a,l]=(0,i.useState)(!1),{settings:d}=(0,s.useSelect)((e=>({settings:e(j.H).getInitialEditorSettings()})),[]);uo(),po();const{setEmailPost:p}=(0,s.useDispatch)(j.H);(0,i.useEffect)((()=>{p(e,t),l(!0)}),[e,t,p]);const m=mo(),g=(0,c.useMergeRefs)([m,n]),h=(0,i.useMemo)((()=>({...d,allowedBlockTypes:u(),isPreviewMode:o})),[d,o]);return a?(0,r.jsx)(i.StrictMode,{children:(0,r.jsx)(Wt,{postId:e,postType:t,settings:h,contentRef:g})}):null}function fo(){Jt(),eo(),(0,C.V1)()&&(to=[{track:"header_preview_dropdown_preview_in_new_tab_selected",selector:".editor-preview-dropdown__button-external"},{track:()=>{const e=document.getElementsByClassName("is-collapsed editor-collapsible-block-toolbar").length;(0,C.yM)("header_blocks_tool_button_clicked",{isBlockToolsCollapsed:e})},selector:".editor-collapsible-block-toolbar__toggle"},{track:e=>{const t=e.classList.contains("is-opened");(0,C.yM)("header_more_menu_dropdown_toggle",{isOpened:t})},selector:`.components-dropdown-menu__toggle[aria-label="${(0,y.__)("Options")}"]`},{track:e=>{(e.textContent===(0,y.__)("Save")&&"false"===e.getAttribute("aria-disabled")||e.textContent===(0,y.__)("Saving…"))&&(0,C.yM)("header_save_button_clicked")},selector:".editor-post-publish-button"},{track:"header_save_email_button_clicked",selector:".editor-post-saved-state.is-saving"},{track:"inserter_sidebar_library_close_icon_clicked",selector:".block-editor-inserter__menu .block-editor-tabbed-sidebar__close-button"},{track:e=>{const t=e.classList.contains("is-opened");(0,C.yM)("header_preview_dropdown_clicked",{isOpened:t})},selector:".editor-preview-dropdown__toggle"},{track:()=>{(0,C.yM)("sidebar_tab_selected",{tab:"document"})},selector:'[data-tab-id="edit-post/document"]'},{track:()=>{(0,C.yM)("sidebar_tab_selected",{tab:"block"})},selector:'[data-tab-id="edit-post/block"]'},{track:e=>{const t=e.classList.contains("is-pressed");(0,C.yM)("header_inserter_sidebar_clicked",{isOpened:t})},selector:".editor-document-tools__inserter-toggle"},{track:e=>{const t=e.classList.contains("is-pressed");(0,C.yM)("header_listview_sidebar_clicked",{isOpened:t})},selector:".editor-document-tools__document-overview-toggle"},{track:e=>{(0,C.yM)("command_bar_command_clicked",{command:e.dataset?.value})},selector:'.commands-command-menu__container [role="option"]'}],document.addEventListener("click",oo)),(0,Ut.y$)(),so(),re(),qt(),(0,d.getBlockTypes)().forEach((e=>{de(e.name)&&(0,g.G)(e.name,(e=>({...e,attributes:{...e.attributes,layout:{type:"object"}}})))})),(0,h.HY)("editor.BlockListBlock","woocommerce-email-editor/with-layout-styles",he),(0,h.HY)("editor.BlockEdit","woocommerce-email-editor/with-inspector-controls",me)}function yo(e){const t=document.getElementById(e);if(!t)return;const{current_post_id:o,current_post_type:n}=window.WooCommerceEmailEditor;if(null==o)throw new Error("current_post_id is required but not provided.");if(!n)throw new Error("current_post_type is required but not provided.");const l=(0,a.applyFilters)("woocommerce_email_editor_wrap_editor_component",_o);fo();const c=ho();(0,s.dispatch)(j.H).setEditorConfig(c),(0,i.createRoot)(t).render((0,r.jsx)(l,{postId:o,postType:n}))}function wo({postId:e,postType:t,isPreview:o=!1,contentRef:n=null,config:c}){const[d,u]=(0,i.useState)(!1);(0,i.useEffect)((()=>{const e=(0,s.select)(l.store).getEditorSettings(),t=c||ho();return fo(),(0,s.dispatch)(j.H).setEditorConfig(t),u(!0),()=>{try{(0,go.IF)()}finally{(0,s.dispatch)(l.store).updateEditorSettings(e)}}}),[c]);const p=(0,a.applyFilters)("woocommerce_email_editor_wrap_editor_component",_o);return d?(0,r.jsx)(p,{postId:e,postType:t,isPreview:o,contentRef:n}):null}var xo=o(89832);function bo(e){"loading"===document.readyState?window.addEventListener("DOMContentLoaded",(()=>{yo(e)}),{once:!0}):yo(e)}(window.wc=window.wc||{}).emailEditor=n})();