Files
gustavoo-me/wp-content/plugins/fluent-crm/assets/guten-editor/index.js
T
2026-07-23 22:56:30 -03:00

1 line
196 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.plugins,n=window.wp.data,o=window.wp.hooks,r=window.wp.blocks,i=window.wp.element,a=window.ReactJSXRuntime,{InspectorControls:s,PanelColorSettings:l,MediaUpload:c,MediaUploadCheck:d}=wp.blockEditor,{__}=wp.i18n,{useState:u,useEffect:m,useRef:p}=wp.element,{PanelBody:f,PanelRow:g,ToggleControl:h,SelectControl:y,ComboboxControl:_,Spinner:I}=wp.components,b=_||wp.components.__experimentalComboboxControl,w=e=>{const{attributes:{productId:t,showDescription:n,showPrice:o,template:r,backgroundColor:i,contentColor:c,pricingColor:d},setAttributes:_}=e,[w,x]=u([]),[v,C]=u(t?t.toString():null),[S,N]=u(""),[j,M]=u(!1),[k,T]=u(!1),E=p(null),D=wp.apiFetch,{addQueryArgs:A}=wp.url;m(()=>{t&&(C(t.toString()),P(t))},[t]),m(()=>()=>{E.current&&clearTimeout(E.current)},[]);const L=e=>{M(!0),D({path:A("wc/store/products",{per_page:20,...e})}).then(e=>{x(e)}).catch(e=>{T(!0)}).finally(()=>{M(!1)})},P=e=>{e&&D({path:A("wc/store/products/"+e)}).then(e=>{N(e.name||"")}).catch(()=>{N(""),T(!0)})},B=e=>{if(!e)return;C(e);const t=w.find(t=>t.id.toString()===e);t&&N(t.name||""),_({productId:e})},R=w.map(e=>({value:e.id.toString(),label:e.name}));return v&&S&&!R.find(e=>e.value===v)&&R.unshift({value:v,label:S}),t?(0,a.jsxs)(s,{children:[(0,a.jsx)(f,{title:__("Template Settings"),initialOpen:!0,children:(0,a.jsx)(g,{children:(0,a.jsxs)("div",{className:"fluent-singleProduct-template-settings",children:[(0,a.jsxs)("div",{style:{marginBottom:"12px"},children:[b?(0,a.jsx)(b,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:__("Select Product"),value:v,options:R,onChange:B,onFilterValueChange:e=>{E.current&&clearTimeout(E.current),E.current=setTimeout(()=>{L(e?{search:e}:{})},1200)},onFocus:()=>{w.length||L()},placeholder:__("Search product"),expandOnFocus:!0}):(0,a.jsx)(y,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:__("Select Product"),value:v,options:R,onChange:B}),j&&(0,a.jsx)("div",{style:{marginTop:"8px"},children:(0,a.jsx)(I,{})})]}),(0,a.jsx)(y,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:__("Design Template"),value:r,options:[{value:"left",name:"Image Left"},{value:"top",name:"Image Top"},{value:"none",name:"No Image"}].map(e=>({value:e.value,label:e.name})),onChange:e=>_({template:e})}),(0,a.jsx)(h,{__nextHasNoMarginBottom:!0,label:__("Show Description"),checked:n,onChange:()=>_({showDescription:!n})}),(0,a.jsx)(h,{__nextHasNoMarginBottom:!0,label:__("Show Price"),checked:o,onChange:()=>_({showPrice:!o})})]})})}),(0,a.jsx)("div",{className:"fluent-singleProduct-titleAndSubtitle-settings",children:(0,a.jsx)(l,{title:__("Customization"),colorSettings:[{value:c,onChange:e=>{_({contentColor:e})},label:__("Content Color")},{value:i,onChange:e=>{_({backgroundColor:e})},label:__("Background Color")},{value:d,onChange:e=>{_({pricingColor:e})},label:__("Pricing Color")}]})})]}):null},x=window.wp.i18n,v=window.wp.blockEditor;function C(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=Array(t);n<t;n++)o[n]=e[n];return o}function S(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var o,r,i,a,s=[],l=!0,c=!1;try{if(i=(n=n.call(e)).next,0===t);else for(;!(l=(o=i.call(n)).done)&&(s.push(o.value),s.length!==t);l=!0);}catch(e){c=!0,r=e}finally{try{if(!l&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw r}}return s}}(e,t)||function(e,t){if(e){if("string"==typeof e)return C(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?C(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}const N=Object.entries,j=Object.setPrototypeOf,M=Object.isFrozen,k=Object.getPrototypeOf,T=Object.getOwnPropertyDescriptor;let E=Object.freeze,D=Object.seal,A=Object.create,L="undefined"!=typeof Reflect&&Reflect,P=L.apply,B=L.construct;E||(E=function(e){return e}),D||(D=function(e){return e}),P||(P=function(e,t){for(var n=arguments.length,o=new Array(n>2?n-2:0),r=2;r<n;r++)o[r-2]=arguments[r];return e.apply(t,o)}),B||(B=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),o=1;o<t;o++)n[o-1]=arguments[o];return new e(...n)});const R=re(Array.prototype.forEach),z=re(Array.prototype.lastIndexOf),H=re(Array.prototype.pop),O=re(Array.prototype.push),F=re(Array.prototype.splice),U=Array.isArray,G=re(String.prototype.toLowerCase),Z=re(String.prototype.toString),V=re(String.prototype.match),W=re(String.prototype.replace),Q=re(String.prototype.indexOf),Y=re(String.prototype.trim),J=re(Number.prototype.toString),$=re(Boolean.prototype.toString),q="undefined"==typeof BigInt?null:re(BigInt.prototype.toString),K="undefined"==typeof Symbol?null:re(Symbol.prototype.toString),X=re(Object.prototype.hasOwnProperty),ee=re(Object.prototype.toString),te=re(RegExp.prototype.test),ne=(oe=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return B(oe,t)});var oe;function re(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return P(e,t,o)}}function ie(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:G;if(j&&j(e,null),!U(t))return e;let o=t.length;for(;o--;){let r=t[o];if("string"==typeof r){const e=n(r);e!==r&&(M(t)||(t[o]=e),r=e)}e[r]=!0}return e}function ae(e){for(let t=0;t<e.length;t++)X(e,t)||(e[t]=null);return e}function se(e){const t=A(null);for(const o of N(e)){var n=S(o,2);const r=n[0],i=n[1];X(e,r)&&(U(i)?t[r]=ae(i):i&&"object"==typeof i&&i.constructor===Object?t[r]=se(i):t[r]=i)}return t}function le(e,t){for(;null!==e;){const n=T(e,t);if(n){if(n.get)return re(n.get);if("function"==typeof n.value)return re(n.value)}e=k(e)}return function(){return null}}const ce=E(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),de=E(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ue=E(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),me=E(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),pe=E(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),fe=E(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),ge=E(["#text"]),he=E(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),ye=E(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),_e=E(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ie=E(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),be=D(/{{[\w\W]*|^[\w\W]*}}/g),we=D(/<%[\w\W]*|^[\w\W]*%>/g),xe=D(/\${[\w\W]*/g),ve=D(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ce=D(/^aria-[\-\w]+$/),Se=D(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ne=D(/^(?:\w+script|data):/i),je=D(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Me=D(/^html$/i),ke=D(/^[a-z][.\w]*(-[.\w]+)+$/i),Te=D(/<[/\w!]/g),Ee=D(/<[/\w]/g),De=D(/<\/no(script|embed|frames)/i),Ae=D(/\/>/i),Le=function(){return"undefined"==typeof window?null:window},Pe=function(e,t,n,o){return X(e,t)&&U(e[t])?ie(o.base?se(o.base):{},e[t],o.transform):n};var Be=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Le();const n=t=>e(t);if(n.version="3.4.11",n.removed=[],!t||!t.document||9!==t.document.nodeType||!t.Element)return n.isSupported=!1,n;let o=t.document;const r=o,i=r.currentScript;t.DocumentFragment;const a=t.HTMLTemplateElement,s=t.Node,l=t.Element,c=t.NodeFilter;void 0===t.NamedNodeMap&&(t.NamedNodeMap||t.MozNamedAttrMap),t.HTMLFormElement;const d=t.DOMParser,u=t.trustedTypes,m=l.prototype,p=le(m,"cloneNode"),f=le(m,"remove"),g=le(m,"nextSibling"),h=le(m,"childNodes"),y=le(m,"parentNode"),_=le(m,"shadowRoot"),I=le(m,"attributes"),b=s&&s.prototype?le(s.prototype,"nodeType"):null,w=s&&s.prototype?le(s.prototype,"nodeName"):null;if("function"==typeof a){const e=o.createElement("template");e.content&&e.content.ownerDocument&&(o=e.content.ownerDocument)}let x,v,C="",S=!1,j=0;const M=function(){if(j>0)throw ne('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},k=function(e){M(),j++;try{return x.createHTML(e)}finally{j--}},T=o,L=T.implementation,P=T.createNodeIterator,B=T.createDocumentFragment,oe=T.getElementsByTagName,re=r.importNode;let ae={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};n.isSupported="function"==typeof N&&"function"==typeof y&&L&&void 0!==L.createHTMLDocument;const Be=be,Re=we,ze=xe,He=ve,Oe=Ce,Fe=Ne,Ue=je,Ge=ke;let Ze=Se,Ve=null;const We=ie({},[...ce,...de,...ue,...pe,...ge]);let Qe=null;const Ye=ie({},[...he,...ye,..._e,...Ie]);let Je=Object.seal(A(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),$e=null,qe=null;const Ke=Object.seal(A(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Xe=!0,et=!0,tt=!1,nt=!0,ot=!1,rt=!0,it=!1,at=!1,st=null,lt=null,ct=!1,dt=!1,ut=!1,mt=!1,pt=!0,ft=!1;const gt="user-content-";let ht=!0,yt=!1,_t={},It=null;const bt=ie({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let wt=null;const xt=ie({},["audio","video","img","source","image","track"]);let vt=null;const Ct=ie({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),St="http://www.w3.org/1998/Math/MathML",Nt="http://www.w3.org/2000/svg",jt="http://www.w3.org/1999/xhtml";let Mt=jt,kt=!1,Tt=null;const Et=ie({},[St,Nt,jt],Z),Dt=E(["mi","mo","mn","ms","mtext"]);let At=ie({},Dt);const Lt=E(["annotation-xml"]);let Pt=ie({},Lt);const Bt=ie({},["title","style","font","a","script"]);let Rt=null;const zt=["application/xhtml+xml","text/html"];let Ht=null,Ot=null;const Ft=o.createElement("form"),Ut=function(e){return e instanceof RegExp||e instanceof Function},Gt=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(Ot&&Ot===e)return;e&&"object"==typeof e||(e={}),e=se(e),Rt=-1===zt.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Ht="application/xhtml+xml"===Rt?Z:G,Ve=Pe(e,"ALLOWED_TAGS",We,{transform:Ht}),Qe=Pe(e,"ALLOWED_ATTR",Ye,{transform:Ht}),Tt=Pe(e,"ALLOWED_NAMESPACES",Et,{transform:Z}),vt=Pe(e,"ADD_URI_SAFE_ATTR",Ct,{transform:Ht,base:Ct}),wt=Pe(e,"ADD_DATA_URI_TAGS",xt,{transform:Ht,base:xt}),It=Pe(e,"FORBID_CONTENTS",bt,{transform:Ht}),$e=Pe(e,"FORBID_TAGS",se({}),{transform:Ht}),qe=Pe(e,"FORBID_ATTR",se({}),{transform:Ht}),_t=!!X(e,"USE_PROFILES")&&(e.USE_PROFILES&&"object"==typeof e.USE_PROFILES?se(e.USE_PROFILES):e.USE_PROFILES),Xe=!1!==e.ALLOW_ARIA_ATTR,et=!1!==e.ALLOW_DATA_ATTR,tt=e.ALLOW_UNKNOWN_PROTOCOLS||!1,nt=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,ot=e.SAFE_FOR_TEMPLATES||!1,rt=!1!==e.SAFE_FOR_XML,it=e.WHOLE_DOCUMENT||!1,dt=e.RETURN_DOM||!1,ut=e.RETURN_DOM_FRAGMENT||!1,mt=e.RETURN_TRUSTED_TYPE||!1,ct=e.FORCE_BODY||!1,pt=!1!==e.SANITIZE_DOM,ft=e.SANITIZE_NAMED_PROPS||!1,ht=!1!==e.KEEP_CONTENT,yt=e.IN_PLACE||!1,Ze=function(e){try{return te(e,""),!0}catch(e){return!1}}(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:Se,Mt="string"==typeof e.NAMESPACE?e.NAMESPACE:jt,At=X(e,"MATHML_TEXT_INTEGRATION_POINTS")&&e.MATHML_TEXT_INTEGRATION_POINTS&&"object"==typeof e.MATHML_TEXT_INTEGRATION_POINTS?se(e.MATHML_TEXT_INTEGRATION_POINTS):ie({},Dt),Pt=X(e,"HTML_INTEGRATION_POINTS")&&e.HTML_INTEGRATION_POINTS&&"object"==typeof e.HTML_INTEGRATION_POINTS?se(e.HTML_INTEGRATION_POINTS):ie({},Lt);const t=X(e,"CUSTOM_ELEMENT_HANDLING")&&e.CUSTOM_ELEMENT_HANDLING&&"object"==typeof e.CUSTOM_ELEMENT_HANDLING?se(e.CUSTOM_ELEMENT_HANDLING):A(null);if(Je=A(null),X(t,"tagNameCheck")&&Ut(t.tagNameCheck)&&(Je.tagNameCheck=t.tagNameCheck),X(t,"attributeNameCheck")&&Ut(t.attributeNameCheck)&&(Je.attributeNameCheck=t.attributeNameCheck),X(t,"allowCustomizedBuiltInElements")&&"boolean"==typeof t.allowCustomizedBuiltInElements&&(Je.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),D(Je),ot&&(et=!1),ut&&(dt=!0),_t&&(Ve=ie({},ge),Qe=A(null),!0===_t.html&&(ie(Ve,ce),ie(Qe,he)),!0===_t.svg&&(ie(Ve,de),ie(Qe,ye),ie(Qe,Ie)),!0===_t.svgFilters&&(ie(Ve,ue),ie(Qe,ye),ie(Qe,Ie)),!0===_t.mathMl&&(ie(Ve,pe),ie(Qe,_e),ie(Qe,Ie))),Ke.tagCheck=null,Ke.attributeCheck=null,X(e,"ADD_TAGS")&&("function"==typeof e.ADD_TAGS?Ke.tagCheck=e.ADD_TAGS:U(e.ADD_TAGS)&&(Ve===We&&(Ve=se(Ve)),ie(Ve,e.ADD_TAGS,Ht))),X(e,"ADD_ATTR")&&("function"==typeof e.ADD_ATTR?Ke.attributeCheck=e.ADD_ATTR:U(e.ADD_ATTR)&&(Qe===Ye&&(Qe=se(Qe)),ie(Qe,e.ADD_ATTR,Ht))),X(e,"ADD_URI_SAFE_ATTR")&&U(e.ADD_URI_SAFE_ATTR)&&ie(vt,e.ADD_URI_SAFE_ATTR,Ht),X(e,"FORBID_CONTENTS")&&U(e.FORBID_CONTENTS)&&(It===bt&&(It=se(It)),ie(It,e.FORBID_CONTENTS,Ht)),X(e,"ADD_FORBID_CONTENTS")&&U(e.ADD_FORBID_CONTENTS)&&(It===bt&&(It=se(It)),ie(It,e.ADD_FORBID_CONTENTS,Ht)),ht&&(Ve["#text"]=!0),it&&ie(Ve,["html","head","body"]),Ve.table&&(ie(Ve,["tbody"]),delete $e.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ne('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ne('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const t=x;x=e.TRUSTED_TYPES_POLICY;try{C=k("")}catch(e){throw x=t,e}}else null===e.TRUSTED_TYPES_POLICY?(x=void 0,C=""):(void 0===x&&(S||(v=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}}(u,i),S=!0),x=v),x&&"string"==typeof C&&(C=k("")));E&&E(e),Ot=e},Zt=ie({},[...de,...ue,...me]),Vt=ie({},[...pe,...fe]),Wt=function(e){O(n.removed,{element:e});try{y(e).removeChild(e)}catch(t){if(f(e),!y(e))throw ne("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},Qt=function(e){const t=h(e);if(t){const e=[];R(t,t=>{O(e,t)}),R(e,e=>{try{f(e)}catch(e){}})}const n=I(e);if(n)for(let t=n.length-1;t>=0;--t){const o=n[t],r=o&&o.name;if("string"==typeof r)try{e.removeAttribute(r)}catch(e){}}},Yt=function(e,t){try{O(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){O(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(dt||ut)try{Wt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},Jt=function(e){const t=I(e);if(t)for(let n=t.length-1;n>=0;--n){const o=t[n],r=o&&o.name;if("string"==typeof r&&!Qe[Ht(r)])try{e.removeAttribute(r)}catch(e){}}},$t=function(e){let t=null,n=null;if(ct)e="<remove></remove>"+e;else{const t=V(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Rt&&Mt===jt&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const r=x?k(e):e;if(Mt===jt)try{t=(new d).parseFromString(r,Rt)}catch(e){}if(!t||!t.documentElement){t=L.createDocument(Mt,"template",null);try{t.documentElement.innerHTML=kt?C:r}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(o.createTextNode(n),i.childNodes[0]||null),Mt===jt?oe.call(t,it?"html":"body")[0]:it?t.documentElement:i},qt=function(e){return P.call(e.ownerDocument||e,e,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Kt=function(e){return e=W(e,Be," "),e=W(e,Re," "),W(e,ze," ")},Xt=function(e){var t;e.normalize();const n=P.call(e.ownerDocument||e,e,c.SHOW_TEXT|c.SHOW_COMMENT|c.SHOW_CDATA_SECTION|c.SHOW_PROCESSING_INSTRUCTION,null);let o=n.nextNode();for(;o;)o.data=Kt(o.data),o=n.nextNode();const r=null===(t=e.querySelectorAll)||void 0===t?void 0:t.call(e,"template");r&&R(r,e=>{tn(e.content)&&Xt(e.content)})},en=function(e){const t=w?w(e):null;return"string"==typeof t&&"form"===Ht(t)&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||e.attributes!==I(e)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes||e.nodeType!==b(e)||e.childNodes!==h(e))},tn=function(e){if(!b||"object"!=typeof e||null===e)return!1;try{return 11===b(e)}catch(e){return!1}},nn=function(e){if(!b||"object"!=typeof e||null===e)return!1;try{return"number"==typeof b(e)}catch(e){return!1}};function on(e,t,o){0!==e.length&&R(e,e=>{e.call(n,t,o,Ot)})}const rn=function(e){if(on(ae.beforeSanitizeElements,e,null),en(e))return Wt(e),!0;const t=Ht(w?w(e):e.nodeName);if(on(ae.uponSanitizeElement,e,{tagName:t,allowedTags:Ve}),function(e,t){return!!(rt&&e.hasChildNodes()&&!nn(e.firstElementChild)&&te(Te,e.textContent)&&te(Te,e.innerHTML))||!(!rt||e.namespaceURI!==jt||"style"!==t||!nn(e.firstElementChild))||7===e.nodeType||!(!rt||8!==e.nodeType||!te(Ee,e.data))}(e,t))return Wt(e),!0;if($e[t]||!(Ke.tagCheck instanceof Function&&Ke.tagCheck(t))&&!Ve[t])return function(e,t){if(!$e[t]&&ln(t)){if(Je.tagNameCheck instanceof RegExp&&te(Je.tagNameCheck,t))return!1;if(Je.tagNameCheck instanceof Function&&Je.tagNameCheck(t))return!1}if(ht&&!It[t]){const t=y(e),n=h(e);if(n&&t)for(let o=n.length-1;o>=0;--o){const r=yt?n[o]:p(n[o],!0);t.insertBefore(r,g(e))}}return Wt(e),!0}(e,t);if(1===(b?b(e):e.nodeType)&&!function(e){let t=y(e);t&&t.tagName||(t={namespaceURI:Mt,tagName:"template"});const n=G(e.tagName),o=G(t.tagName);return!!Tt[e.namespaceURI]&&(e.namespaceURI===Nt?function(e,t,n){return t.namespaceURI===jt?"svg"===e:t.namespaceURI===St?"svg"===e&&("annotation-xml"===n||At[n]):Boolean(Zt[e])}(n,t,o):e.namespaceURI===St?function(e,t,n){return t.namespaceURI===jt?"math"===e:t.namespaceURI===Nt?"math"===e&&Pt[n]:Boolean(Vt[e])}(n,t,o):e.namespaceURI===jt?function(e,t,n){return!(t.namespaceURI===Nt&&!Pt[n])&&!(t.namespaceURI===St&&!At[n])&&!Vt[e]&&(Bt[e]||!Zt[e])}(n,t,o):!("application/xhtml+xml"!==Rt||!Tt[e.namespaceURI]))}(e))return Wt(e),!0;if(("noscript"===t||"noembed"===t||"noframes"===t)&&te(De,e.innerHTML))return Wt(e),!0;if(ot&&3===e.nodeType){const t=Kt(e.textContent);e.textContent!==t&&(O(n.removed,{element:e.cloneNode()}),e.textContent=t)}return on(ae.afterSanitizeElements,e,null),!1},an=function(e,t,n){if(qe[t])return!1;if(pt&&("id"===t||"name"===t)&&(n in o||n in Ft))return!1;const r=Qe[t]||Ke.attributeCheck instanceof Function&&Ke.attributeCheck(t,e);if(et&&te(He,t));else if(Xe&&te(Oe,t));else if(r){if(vt[t]);else if(te(Ze,W(n,Ue,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==Q(n,"data:")||!wt[e])if(tt&&!te(Fe,W(n,Ue,"")));else if(n)return!1}else if(!(ln(e)&&(Je.tagNameCheck instanceof RegExp&&te(Je.tagNameCheck,e)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(e))&&(Je.attributeNameCheck instanceof RegExp&&te(Je.attributeNameCheck,t)||Je.attributeNameCheck instanceof Function&&Je.attributeNameCheck(t,e))||"is"===t&&Je.allowCustomizedBuiltInElements&&(Je.tagNameCheck instanceof RegExp&&te(Je.tagNameCheck,n)||Je.tagNameCheck instanceof Function&&Je.tagNameCheck(n))))return!1;return!0},sn=ie({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),ln=function(e){return!sn[G(e)]&&te(Ge,e)},cn=function(e,t,n,o){if(x&&"object"==typeof u&&"function"==typeof u.getAttributeType&&!n)switch(u.getAttributeType(e,t)){case"TrustedHTML":return k(o);case"TrustedScriptURL":return function(e){M(),j++;try{return x.createScriptURL(e)}finally{j--}}(o)}return o},dn=function(e,t,o,r){try{o?e.setAttributeNS(o,t,r):e.setAttribute(t,r),en(e)?Wt(e):H(n.removed)}catch(n){Yt(t,e)}},un=function(e){on(ae.beforeSanitizeAttributes,e,null);const t=e.attributes;if(!t||en(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Qe,forceKeepAttr:void 0};let o=t.length;const r=Ht(e.nodeName);for(;o--;){const i=t[o],a=i.name,s=i.namespaceURI,l=i.value,c=Ht(a),d=l;let u="value"===a?d:Y(d);n.attrName=c,n.attrValue=u,n.keepAttr=!0,n.forceKeepAttr=void 0,on(ae.uponSanitizeAttribute,e,n),u=n.attrValue,!ft||"id"!==c&&"name"!==c||0===Q(u,gt)||(Yt(a,e),u=gt+u),rt&&te(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,u)||"attributename"===c&&V(u,"href")?Yt(a,e):n.forceKeepAttr||(!n.keepAttr||!nt&&te(Ae,u)?Yt(a,e):(ot&&(u=Kt(u)),an(r,c,u)?(u=cn(r,c,s,u),u!==d&&dn(e,a,s,u)):Yt(a,e)))}on(ae.afterSanitizeAttributes,e,null)},mn=function(e){let t=null;const n=qt(e);for(on(ae.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)if(on(ae.uponSanitizeShadowNode,t,null),rn(t),un(t),tn(t.content)&&mn(t.content),1===(b?b(t):t.nodeType)){const e=_(t);tn(e)&&(pn(e),mn(e))}on(ae.afterSanitizeShadowDOM,e,null)},pn=function(e){const t=[{node:e,shadow:null}];for(;t.length>0;){const e=t.pop();if(e.shadow){mn(e.shadow);continue}const n=e.node,o=1===(b?b(n):n.nodeType),r=h(n);if(r)for(let e=r.length-1;e>=0;--e)t.push({node:r[e],shadow:null});if(o){const e=w?w(n):null;if("string"==typeof e&&"template"===Ht(e)){const e=n.content;tn(e)&&t.push({node:e,shadow:null})}}if(o){const e=_(n);tn(e)&&t.push({node:null,shadow:e},{node:e,shadow:null})}}};return n.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=null,i=null,a=null,s=null;if(kt=!e,kt&&(e="\x3c!--\x3e"),"string"!=typeof e&&!nn(e)&&"string"!=typeof(e=function(e){switch(typeof e){case"string":return e;case"number":return J(e);case"boolean":return $(e);case"bigint":return q?q(e):"0";case"symbol":return K?K(e):"Symbol()";case"undefined":default:return ee(e);case"function":case"object":{if(null===e)return ee(e);const t=e,n=le(t,"toString");if("function"==typeof n){const e=n(t);return"string"==typeof e?e:ee(e)}return ee(e)}}}(e)))throw ne("dirty is not a string, aborting");if(!n.isSupported)return e;at?(Ve=st,Qe=lt):Gt(t),(ae.uponSanitizeElement.length>0||ae.uponSanitizeAttribute.length>0)&&(Ve=se(Ve)),ae.uponSanitizeAttribute.length>0&&(Qe=se(Qe)),n.removed=[];const l=yt&&"string"!=typeof e&&nn(e);if(l){const t=w?w(e):e.nodeName;if("string"==typeof t){const e=Ht(t);if(!Ve[e]||$e[e])throw ne("root node is forbidden and cannot be sanitized in-place")}if(en(e))throw ne("root node is clobbered and cannot be sanitized in-place");try{pn(e)}catch(t){throw Qt(e),t}}else if(nn(e))o=$t("\x3c!----\x3e"),i=o.ownerDocument.importNode(e,!0),1===i.nodeType&&"BODY"===i.nodeName||"HTML"===i.nodeName?o=i:o.appendChild(i),pn(i);else{if(!dt&&!ot&&!it&&-1===e.indexOf("<"))return x&&mt?k(e):e;if(o=$t(e),!o)return dt?null:mt?C:""}o&&ct&&Wt(o.firstChild);const c=qt(l?e:o);try{for(;a=c.nextNode();)rn(a),un(a),tn(a.content)&&mn(a.content)}catch(t){throw l&&Qt(e),t}if(l)return R(n.removed,e=>{e.element&&function(e){const t=[e];for(;t.length>0;){const e=t.pop();1===(b?b(e):e.nodeType)&&Jt(e);const n=h(e);if(n)for(let e=n.length-1;e>=0;--e)t.push(n[e])}}(e.element)}),ot&&Xt(e),e;if(dt){if(ot&&Xt(o),ut)for(s=B.call(o.ownerDocument);o.firstChild;)s.appendChild(o.firstChild);else s=o;return(Qe.shadowroot||Qe.shadowrootmode)&&(s=re.call(r,s,!0)),s}let d=it?o.outerHTML:o.innerHTML;return it&&Ve["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&te(Me,o.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+o.ownerDocument.doctype.name+">\n"+d),ot&&(d=Kt(d)),x&&mt?k(d):d},n.setConfig=function(){Gt(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),at=!0,st=Ve,lt=Qe},n.clearConfig=function(){Ot=null,at=!1,st=null,lt=null,x=v,C=""},n.isValidAttribute=function(e,t,n){Ot||Gt({});const o=Ht(e),r=Ht(t);return an(o,r,n)},n.addHook=function(e,t){"function"==typeof t&&X(ae,e)&&O(ae[e],t)},n.removeHook=function(e,t){if(X(ae,e)){if(void 0!==t){const n=z(ae[e],t);return-1===n?void 0:F(ae[e],n,1)[0]}return H(ae[e])}},n.removeHooks=function(e){X(ae,e)&&(ae[e]=[])},n.removeAllHooks=function(){ae={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},n}();const Re={ALLOWED_TAGS:["span","bdi","bdo","del","ins","small","strong","em","sup","sub"],ALLOWED_ATTR:["class","dir"],ALLOW_DATA_ATTR:!1},ze=(e,t="Free")=>{const n=Be.sanitize(e?String(e):t,Re);if("undefined"!=typeof document){const e=document.createElement("div");return e.innerHTML=n,e.querySelectorAll(".screen-reader-text").forEach(e=>e.remove()),e.querySelectorAll("del[aria-hidden], ins[aria-hidden]").forEach(e=>e.removeAttribute("aria-hidden")),e.innerHTML}return n.replace(/<span\b(?=[^>]*\bclass=(["'])[^"']*\bscreen-reader-text\b[^"']*\1)[^>]*>[\s\S]*?<\/span>/gi,"").replace(/<(del|ins)\b([^>]*)>/gi,(e,t,n)=>`<${t}${n.replace(/\saria-hidden=(["']).*?\1|\saria-hidden=[^\s>]*/gi,"")}>`)},{RadioControl:He,Spinner:Oe}=wp.components,{useState:Fe,useEffect:Ue}=wp.element,{__:Ge}=wp.i18n,Ze=e=>{const{attributes:{productId:t,showDescription:n,showPrice:o,buttonText:r,customImage:i,template:s,backgroundColor:l,contentColor:c,pricingColor:d},setAttributes:u}=e,{InnerBlocks:m}=wp.blockEditor,[p,f]=Fe([]),[g,h]=Fe(""),[y,_]=Fe(""),[I,b]=Fe({}),[w,x]=Fe(!1),[v,C]=Fe(!1),[S,N]=Fe(!1);Ue(()=>{t?T(t):k()},[t]);const j=wp.apiFetch,{addQueryArgs:M}=wp.url,k=e=>{C(!0),j({path:M("wc/store/products",{per_page:6,...e})}).then(e=>{f(e)}).catch(e=>{N(!0)}).finally(()=>{C(!1)})},T=e=>{x(!0),j({path:M("wc/store/products/"+e)}).then(e=>{b(e),u({productId:e.id}),x(!1)}).catch(e=>{N(!0)})},E={backgroundColor:l,color:c},D=["fcw_p","fcw_template_"+s,w?"fc_product_loading":""].filter(Boolean).join(" "),A=["fcw_search_box",w?"fc_product_loading":""].filter(Boolean).join(" ");return(0,a.jsxs)("div",{children:[w&&(0,a.jsxs)("div",{style:E,className:"fc_woo_loader",children:[(0,a.jsx)(Oe,{}),(0,a.jsx)("h3",{children:"Loading product"})]}),I.id&&t?(0,a.jsxs)("div",{style:E,className:D,children:["none"!=s&&(0,a.jsx)("div",{className:"fcw_image",children:(0,a.jsx)("img",{src:i||I&&I.images&&I.images.length&&I.images[0].src||""})}),(0,a.jsxs)("div",{className:"fcw_p_content",children:[(0,a.jsx)("h2",{style:{color:c},className:"fcw_p_title",dangerouslySetInnerHTML:{__html:I.name}}),n&&(0,a.jsx)("div",{style:{color:c},className:"fcw_p_desc",dangerouslySetInnerHTML:{__html:I.short_description}}),o&&(0,a.jsx)("div",{style:{color:d},className:"fcw_p_price",dangerouslySetInnerHTML:{__html:ze(I.price_html,Ge("Free"))}}),(0,a.jsx)("div",{className:"fcb_p_button",children:(0,a.jsx)(m,{template:[["core/buttons",{},[["core/button",{text:r,url:I.permalink,align:"left"}]]]],templateLock:"all"})})]})]}):(0,a.jsxs)("div",{className:A,children:[(0,a.jsx)("h4",{children:"Search and Select a Product"}),(0,a.jsx)("hr",{}),(0,a.jsxs)("div",{style:{marginBottom:"25px",display:"flex"},className:"fluent-single-product-search-bar",children:[(0,a.jsx)("div",{style:{width:"80%"},children:(0,a.jsx)("input",{placeholder:"product",style:{width:"100%",height:"30px"},value:g,onChange:e=>{h(e.target.value)},onKeyDown:e=>{"Enter"!==e.key&&""!==e.target.value||k({search:g})}})}),(0,a.jsx)("button",{style:{width:"20%",height:"30px"},onClick:()=>{k({search:g})},children:"Search"})]}),v?(0,a.jsx)("h2",{children:(0,a.jsx)(Oe,{})}):(0,a.jsx)("div",{className:"fcw_results",children:p&&p.length?(0,a.jsx)(He,{selected:y,options:p.map(e=>({value:e.id.toString(),label:e.name})),onChange:e=>{_(e)}}):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:"No products found!"})})}),(0,a.jsx)("div",{style:{marginTop:"20px"},className:"components-button is-primary",onClick:()=>{T(y)},children:"Done"})]})]})},{Fragment:Ve}=wp.element,We=e=>{const t=(0,v.useBlockProps)({className:"fluent-single-product-block"});return(0,a.jsxs)(Ve,{children:[(0,a.jsx)("div",{...t,children:(0,a.jsx)(Ze,{attributes:e.attributes,setAttributes:e.setAttributes})}),(0,a.jsx)(w,{attributes:e.attributes,setAttributes:e.setAttributes})]})},Qe=()=>{const e=v.useBlockProps.save();return(0,a.jsx)("div",{...e,children:(0,a.jsx)(v.InnerBlocks.Content,{})})},{__:Ye}=wp.i18n,Je={productId:{type:"number",default:null},showDescription:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0},buttonText:{type:"string",default:Ye("Buy Now")},customImage:{type:"string",default:""},backgroundColor:{type:"string",default:"#fffeeb"},contentColor:{type:"string",default:""},pricingColor:{type:"string",default:""},template:{type:"string",default:"left"}},$e=wp.element.createElement,{__:qe}=wp.i18n,{registerBlockType:Ke}=wp.blocks,Xe=window.fcrmBlockEditorConfig?.modules||{},et=[{attributes:Je,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],tt=$e("svg",{width:20,height:20,viewBox:"0 0 24 24"},$e("path",{fill:"#7F54B3",d:"M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8.2L7 20v-4H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"}),$e("text",{x:12,y:12.8,textAnchor:"middle",fontSize:6.5,fontFamily:"Arial, sans-serif",fontWeight:700,fill:"#fff"},"woo"));if(!1!==Xe.hasWooCommerce){const e={apiVersion:3,title:qe("Woo Product (Single)"),description:qe("Product Block For your Email"),category:"layout",icon:tt,keywords:[qe("product"),qe("woocommerce"),qe("card")],supports:{align:["wide","full"],html:!0},attributes:Je,deprecated:et,edit:We,save:Qe};Ke("fluentcrm/woo-product",e),Ke("fluent-crm/woo-product",{...e,supports:{...e.supports,inserter:!1}})}window.React;const nt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAzIiBoZWlnaHQ9IjM1NCIgdmlld0JveD0iMCAwIDQwMyAzNTQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSI0MDEiIGhlaWdodD0iMzUyIiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPHJlY3QgeD0iNDQiIHk9IjIyNSIgd2lkdGg9IjMxNCIgaGVpZ2h0PSIxNiIgcng9IjgiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjciIHk9IjI1NyIgd2lkdGg9IjM0OSIgaGVpZ2h0PSIxMCIgcng9IjUiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iNzIiIHk9IjI4MCIgd2lkdGg9IjI1OSIgaGVpZ2h0PSIxMCIgcng9IjUiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMTczIiB5PSIzMTMiIHdpZHRoPSI1NyIgaGVpZ2h0PSIxNCIgcng9IjciIGZpbGw9IiNFREVFRjQiLz4KPHBhdGggZD0iTTAgMTBDMCA0LjQ3NzE2IDQuNDc3MTUgMCAxMCAwSDM5MUMzOTYuNTIzIDAgNDAxIDQuNDc3MTUgNDAxIDEwVjIwMEgwVjEwWiIgZmlsbD0iI0VERUVGNCIvPgo8L3N2Zz4K",ot="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDE5IiBoZWlnaHQ9IjIwMSIgdmlld0JveD0iMCAwIDQxOSAyMDEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSI0MTciIGhlaWdodD0iMTk5IiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPHBhdGggZD0iTTAgMTBDMCA0LjQ3NzE1IDQuNDc3MTUgMCAxMCAwSDEzN1YyMDFIMTBDNC40NzcxNSAyMDEgMCAxOTYuNTIzIDAgMTkxVjEwWiIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxNjIiIHk9IjcyIiB3aWR0aD0iMjMwIiBoZWlnaHQ9IjE2IiByeD0iOCIgZmlsbD0iI0VERUVGNCIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTE4Mi45MjMgNTcuNDM0MkMxODAuOTI1IDYwLjIwMDEgMTc3LjY3MyA2MiAxNzQgNjJDMTcwLjMyNyA2MiAxNjcuMDc1IDYwLjIwMDEgMTY1LjA3NyA1Ny40MzQyQzE2Ni43MjcgNTQuMjEyOSAxNzAuMTAzIDUyLjAwNDMgMTc0IDUyQzE3Ny44OTcgNTIuMDA0MyAxODEuMjczIDU0LjIxMjkgMTgyLjkyMyA1Ny40MzQyWk0xODMuMzg0IDU4LjQ4MDJDMTg1LjAyMSA1Ni40Mjg4IDE4NiA1My44Mjg3IDE4NiA1MUMxODYgNDQuMzcyNiAxODAuNjI3IDM5IDE3NCAzOUMxNjcuMzczIDM5IDE2MiA0NC4zNzI2IDE2MiA1MUMxNjIgNTMuNDg1MyAxNjIuNzU2IDU1Ljc5NDEgMTY0LjA0OSA1Ny43MDkzQzE2NC4yMjggNTcuOTc0IDE2NC40MTcgNTguMjMxMSAxNjQuNjE2IDU4LjQ4MDFDMTY2LjgxNSA2MS4yMzQ5IDE3MC4yMDEgNjMgMTc0IDYzQzE3Ny43OTkgNjMgMTgxLjE4NSA2MS4yMzQ5IDE4My4zODQgNTguNDgwMlpNMTc0IDUxQzE3MS43OTEgNTEgMTcwIDQ5LjIwOTIgMTcwIDQ3QzE3MCA0NC43OTA5IDE3MS43OTEgNDMgMTc0IDQzQzE3Ni4yMDkgNDMgMTc4IDQ0Ljc5MDkgMTc4IDQ3QzE3OCA0OS4yMDkyIDE3Ni4yMDkgNTEgMTc0IDUxWiIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxOTAiIHk9IjQ5IiB3aWR0aD0iMzQiIGhlaWdodD0iNiIgcng9IjMiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjU1IiB5PSI0OSIgd2lkdGg9IjU0IiBoZWlnaHQ9IjYiIHJ4PSIzIiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjIzNCIgeT0iNTEiIHdpZHRoPSIxMSIgaGVpZ2h0PSIyIiByeD0iMSIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxNjIiIHk9IjEwMyIgd2lkdGg9IjIzMCIgaGVpZ2h0PSIxMCIgcng9IjUiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMTYyIiB5PSIxMjEiIHdpZHRoPSIxNzAiIGhlaWdodD0iMTAiIHJ4PSI1IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjE2MiIgeT0iMTQ4IiB3aWR0aD0iNTciIGhlaWdodD0iMTQiIHJ4PSI3IiBmaWxsPSIjRURFRUY0Ii8+Cjwvc3ZnPgo=",rt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDU2IiBoZWlnaHQ9IjIwMSIgdmlld0JveD0iMCAwIDQ1NiAyMDEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSI0NTQiIGhlaWdodD0iMTk5IiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPHJlY3QgeD0iMjgyIiB5PSIyNyIgd2lkdGg9IjE0NyIgaGVpZ2h0PSIxNDciIHJ4PSIxMCIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIyNyIgeT0iNzIiIHdpZHRoPSIyMzAiIGhlaWdodD0iMTYiIHJ4PSI4IiBmaWxsPSIjRURFRUY0Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNDcuOTIyOSA1Ny40MzQyQzQ1LjkyNSA2MC4yMDAxIDQyLjY3MjcgNjIgMzkgNjJDMzUuMzI3MyA2MiAzMi4wNzUgNjAuMjAwMSAzMC4wNzcxIDU3LjQzNDJDMzEuNzI3MyA1NC4yMTI5IDM1LjEwMjggNTIuMDA0MyAzOSA1MkM0Mi44OTcyIDUyLjAwNDMgNDYuMjcyNyA1NC4yMTI5IDQ3LjkyMjkgNTcuNDM0MlpNNDguMzgzOSA1OC40ODAyQzUwLjAyMTIgNTYuNDI4OCA1MSA1My44Mjg3IDUxIDUxQzUxIDQ0LjM3MjYgNDUuNjI3NCAzOSAzOSAzOUMzMi4zNzI2IDM5IDI3IDQ0LjM3MjYgMjcgNTFDMjcgNTMuNDg1MyAyNy43NTU1IDU1Ljc5NDEgMjkuMDQ5NCA1Ny43MDkzQzI5LjIyODIgNTcuOTc0IDI5LjQxNzMgNTguMjMxMSAyOS42MTYxIDU4LjQ4MDFDMzEuODE0OCA2MS4yMzQ5IDM1LjIwMTMgNjMgMzkgNjNDNDIuNzk4NyA2MyA0Ni4xODUxIDYxLjIzNDkgNDguMzgzOSA1OC40ODAyWk0zOSA1MUMzNi43OTA4IDUxIDM0Ljk5OTkgNDkuMjA5MiAzNC45OTk5IDQ3QzM0Ljk5OTkgNDQuNzkwOSAzNi43OTA4IDQzIDM5IDQzQzQxLjIwOTEgNDMgNDMgNDQuNzkwOSA0MyA0N0M0MyA0OS4yMDkyIDQxLjIwOTEgNTEgMzkgNTFaIiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjU1IiB5PSI0OSIgd2lkdGg9IjM0IiBoZWlnaHQ9IjYiIHJ4PSIzIiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjEyMCIgeT0iNDkiIHdpZHRoPSI1NCIgaGVpZ2h0PSI2IiByeD0iMyIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSI5OSIgeT0iNTEiIHdpZHRoPSIxMSIgaGVpZ2h0PSIyIiByeD0iMSIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIyNyIgeT0iMTAzIiB3aWR0aD0iMjMwIiBoZWlnaHQ9IjEwIiByeD0iNSIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIyNyIgeT0iMTIxIiB3aWR0aD0iMTcwIiBoZWlnaHQ9IjEwIiByeD0iNSIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIyNyIgeT0iMTQ4IiB3aWR0aD0iNTciIGhlaWdodD0iMTQiIHJ4PSI3IiBmaWxsPSIjRURFRUY0Ii8+Cjwvc3ZnPgo=",it="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDE5IiBoZWlnaHQ9IjIwMSIgdmlld0JveD0iMCAwIDQxOSAyMDEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSI0MTciIGhlaWdodD0iMTk5IiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPHBhdGggZD0iTTQxOSAxOTFDNDE5IDE5Ni41MjMgNDE0LjUyMyAyMDEgNDA5IDIwMUwyODIgMjAxTDI4MiAzLjI4MTg3ZS0wNkw0MDkgMS40Mzg0NmUtMDVDNDE0LjUyMyAxLjQ4Njc0ZS0wNSA0MTkgNC40NzcxNyA0MTkgMTBMNDE5IDE5MVoiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjciIHk9IjUzIiB3aWR0aD0iMjMwIiBoZWlnaHQ9IjE2IiByeD0iOCIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIyNyIgeT0iODQiIHdpZHRoPSIyMzAiIGhlaWdodD0iMTAiIHJ4PSI1IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjI3IiB5PSIxMDIiIHdpZHRoPSIxNzAiIGhlaWdodD0iMTAiIHJ4PSI1IiBmaWxsPSIjRURFRUY0Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNDcuOTIyOSAxNDIuNDM0QzQ1LjkyNSAxNDUuMiA0Mi42NzI3IDE0NyAzOSAxNDdDMzUuMzI3MyAxNDcgMzIuMDc1IDE0NS4yIDMwLjA3NzEgMTQyLjQzNEMzMS43MjczIDEzOS4yMTMgMzUuMTAyOCAxMzcuMDA0IDM5IDEzN0M0Mi44OTcyIDEzNy4wMDQgNDYuMjcyNyAxMzkuMjEzIDQ3LjkyMjkgMTQyLjQzNFpNNDguMzgzOSAxNDMuNDhDNTAuMDIxMiAxNDEuNDI5IDUxIDEzOC44MjkgNTEgMTM2QzUxIDEyOS4zNzMgNDUuNjI3NCAxMjQgMzkgMTI0QzMyLjM3MjYgMTI0IDI3IDEyOS4zNzMgMjcgMTM2QzI3IDEzOC40ODUgMjcuNzU1NSAxNDAuNzk0IDI5LjA0OTQgMTQyLjcwOUMyOS4yMjgyIDE0Mi45NzQgMjkuNDE3MyAxNDMuMjMxIDI5LjYxNjEgMTQzLjQ4QzMxLjgxNDggMTQ2LjIzNSAzNS4yMDEzIDE0OCAzOSAxNDhDNDIuNzk4NyAxNDggNDYuMTg1MSAxNDYuMjM1IDQ4LjM4MzkgMTQzLjQ4Wk0zOSAxMzZDMzYuNzkwOCAxMzYgMzQuOTk5OSAxMzQuMjA5IDM0Ljk5OTkgMTMyQzM0Ljk5OTkgMTI5Ljc5MSAzNi43OTA4IDEyOCAzOSAxMjhDNDEuMjA5MSAxMjggNDMgMTI5Ljc5MSA0MyAxMzJDNDMgMTM0LjIwOSA0MS4yMDkxIDEzNiAzOSAxMzZaIiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjU1IiB5PSIxMzQiIHdpZHRoPSIzNCIgaGVpZ2h0PSI2IiByeD0iMyIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxMjAiIHk9IjEzNCIgd2lkdGg9IjU0IiBoZWlnaHQ9IjYiIHJ4PSIzIiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9Ijk5IiB5PSIxMzYiIHdpZHRoPSIxMSIgaGVpZ2h0PSIyIiByeD0iMSIgZmlsbD0iI0VERUVGNCIvPgo8L3N2Zz4K",at="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzg4IiBoZWlnaHQ9IjE1NCIgdmlld0JveD0iMCAwIDM4OCAxNTQiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSIzODYiIGhlaWdodD0iMTUyIiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPHJlY3QgeD0iNDgiIHk9IjI3IiB3aWR0aD0iMzEzIiBoZWlnaHQ9IjE2IiByeD0iOCIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSI0OCIgeT0iMTExIiB3aWR0aD0iMzEzIiBoZWlnaHQ9IjE2IiByeD0iOCIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSI0OCIgeT0iNTUiIHdpZHRoPSIzMTMiIGhlaWdodD0iMTYiIHJ4PSI4IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjQ4IiB5PSI4MyIgd2lkdGg9IjI4MS4xNjkiIGhlaWdodD0iMTYiIHJ4PSI4IiBmaWxsPSIjRURFRUY0Ii8+CjxjaXJjbGUgY3g9IjMzIiBjeT0iMzUiIHI9IjYiIGZpbGw9IiNFREVFRjQiLz4KPGNpcmNsZSBjeD0iMzMiIGN5PSI2MyIgcj0iNiIgZmlsbD0iI0VERUVGNCIvPgo8Y2lyY2xlIGN4PSIzMyIgY3k9IjkxIiByPSI2IiBmaWxsPSIjRURFRUY0Ii8+CjxjaXJjbGUgY3g9IjMzIiBjeT0iMTE5IiByPSI2IiBmaWxsPSIjRURFRUY0Ii8+Cjwvc3ZnPgo=",st="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzg2IiBoZWlnaHQ9IjIxOCIgdmlld0JveD0iMCAwIDM4NiAyMTgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSIzODQiIGhlaWdodD0iMjE2IiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPHJlY3QgeD0iMjciIHk9IjI3IiB3aWR0aD0iNjciIGhlaWdodD0iNjciIHJ4PSI1IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjEyOSIgeT0iMzkiIHdpZHRoPSIyMzAiIGhlaWdodD0iMTYiIHJ4PSI4IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjEyOSIgeT0iNzYiIHdpZHRoPSIzNCIgaGVpZ2h0PSI2IiByeD0iMyIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxOTQiIHk9Ijc2IiB3aWR0aD0iNTQiIGhlaWdodD0iNiIgcng9IjMiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMTczIiB5PSI3OCIgd2lkdGg9IjExIiBoZWlnaHQ9IjIiIHJ4PSIxIiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjI3IiB5PSIxMjQiIHdpZHRoPSI2NyIgaGVpZ2h0PSI2NyIgcng9IjUiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMTI5IiB5PSIxMzYiIHdpZHRoPSIyMzAiIGhlaWdodD0iMTYiIHJ4PSI4IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjEyOSIgeT0iMTczIiB3aWR0aD0iMzQiIGhlaWdodD0iNiIgcng9IjMiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMTk0IiB5PSIxNzMiIHdpZHRoPSI1NCIgaGVpZ2h0PSI2IiByeD0iMyIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxNzMiIHk9IjE3NSIgd2lkdGg9IjExIiBoZWlnaHQ9IjIiIHJ4PSIxIiBmaWxsPSIjRURFRUY0Ii8+CjxsaW5lIHgxPSIyNyIgeTE9IjEwOC41IiB4Mj0iMzU5IiB5Mj0iMTA4LjUiIHN0cm9rZT0iI0VERUVGNCIvPgo8L3N2Zz4K",lt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAzIiBoZWlnaHQ9IjM3MSIgdmlld0JveD0iMCAwIDQwMyAzNzEiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSI0MDEiIGhlaWdodD0iMzY5IiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPHJlY3QgeD0iMjciIHk9IjIyNSIgd2lkdGg9IjMxNCIgaGVpZ2h0PSIxNiIgcng9IjgiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjciIHk9IjI1NyIgd2lkdGg9IjM0OSIgaGVpZ2h0PSIxMCIgcng9IjUiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjciIHk9IjI4MCIgd2lkdGg9IjI1OSIgaGVpZ2h0PSIxMCIgcng9IjUiIGZpbGw9IiNFREVFRjQiLz4KPHBhdGggZD0iTTEgMTBDMSA0LjQ3NzE2IDUuNDc3MTUgMCAxMSAwSDM5MkMzOTcuNTIzIDAgNDAyIDQuNDc3MTUgNDAyIDEwVjIwMEgxVjEwWiIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIyOCIgeT0iMzEyIiB3aWR0aD0iODAiIGhlaWdodD0iMzEiIHJ4PSI0IiBzdHJva2U9IiNFREVFRjQiIHN0cm9rZS13aWR0aD0iMiIvPgo8cmVjdCB4PSI0NCIgeT0iMzI0IiB3aWR0aD0iNDgiIGhlaWdodD0iNyIgcng9IjMuNSIgZmlsbD0iI0VERUVGNCIvPgo8L3N2Zz4K",{InspectorControls:ct,PanelColorSettings:dt}=wp.blockEditor,{__:ut}=wp.i18n,{PanelBody:mt,PanelRow:pt,SelectControl:ft,ToggleControl:gt,TextControl:ht,Dropdown:yt,Button:_t,FormTokenField:It}=wp.components,{useState:bt,useEffect:wt}=wp.element,xt=e=>{const{attributes:{selectedPostType:t,postTypes:n,selectedPostsPerPage:o,selectedLayout:r,contentColor:i,titleColor:s,backgroundColor:l,authorColor:c,commentColor:d,buttonColor:u,showImage:m,showMeta:p,showMetaAuthor:f,showMetaAuthorImg:g,showMetaComments:h,showButton:y,buttonText:_,showDescription:I,orderBy:b,order:w,taxTypes:x,catType:v,recentPostDays:C,selectedExcerptLength:S,backgroundType:N,selectedOperatorType:j,postsGap:M},setAttributes:k}=e,[T,E]=bt([]);wt(()=>{L()},[]);const D=wp.apiFetch,{addQueryArgs:A}=wp.url,L=e=>{D({path:A("fluent-crm/v2/campaigns-pro/posts/taxonomies",{...e})}).then(e=>{E(e.taxonomies)}).catch(()=>{}).finally(()=>{})},P=e=>{const t=T[e]?.terms;if(!t)return"";const n=Object.keys(t);return n.length?n[0]:""};wt(()=>{const e=P(t);e&&v!==e&&k({catType:e})},[t,T]);const B=[{value:s,onChange:e=>{k({titleColor:e})},label:ut("Title Color","fluent-crm")}];"layout-5"!==r&&B.push({value:l,onChange:e=>{k({backgroundColor:e})},label:ut("Box Background Color","fluent-crm")}),"default"!==r&&"layout-5"!==r&&"layout-7"!==r&&!0===p&&(!0===f&&B.push({value:c,onChange:e=>{k({authorColor:e})},label:ut("Author Color","fluent-crm")}),!0===h&&B.push({value:d,onChange:e=>{k({commentColor:e})},label:ut("Meta Comment Color","fluent-crm")})),"layout-6"!==r&&"layout-5"!==r&&B.push({value:i,onChange:e=>{k({contentColor:e})},label:ut("Content Color","fluent-crm")}),"layout-6"!==r&&"layout-4"!==r&&"layout-5"!==r&&B.push({value:u,onChange:e=>{k({buttonColor:e})},label:ut("Button Color","fluent-crm")});const R=[{value:"all",label:"All"}];T[t]?.terms&&T[t]?.terms[v]&&T[t]?.terms[v].map(e=>R.push(e));const z=e=>{if(!x||x.length<1)return[];const[t]=x;return t.hasOwnProperty(e)?t[e]:[]};let H=nt;"layout-2"===r?H=ot:"layout-3"===r?H=rt:"layout-4"===r?H=it:"layout-5"===r?H=at:"layout-6"===r?H=st:"layout-7"===r&&(H=lt);const O=[{value:"default",label:ut("Default","fluent-crm"),image:nt},{value:"layout-2",label:ut("Layout 2","fluent-crm"),image:ot},{value:"layout-3",label:ut("Layout 3","fluent-crm"),image:rt},{value:"layout-4",label:ut("Layout 4","fluent-crm"),image:it},{value:"layout-5",label:ut("Layout 5","fluent-crm"),image:at},{value:"layout-6",label:ut("Layout 6","fluent-crm"),image:st},{value:"layout-7",label:ut("Layout 7","fluent-crm"),image:lt}];return(0,a.jsxs)(ct,{children:[(0,a.jsx)(mt,{title:ut("General Settings","fluent-crm"),initialOpen:!0,children:(0,a.jsx)(pt,{children:(0,a.jsxs)("div",{className:"fluent-latest-posts-settings",children:[n&&n.length?(0,a.jsx)(ft,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:ut("Select Post Type","fluent-crm"),value:t,options:n.map(e=>({value:e.value,label:e.label})),onChange:e=>{const t={selectedPostType:e},n=P(e);n&&(t.catType=n),t.taxTypes=[],k(t)}}):null,T[t]?.terms?(0,a.jsx)("div",{children:Object.entries(T[t]?.terms).map(([e,t],n)=>{return(0,a.jsx)(It,{value:z(e),suggestions:t?.map(e=>e.label),label:(o=e,ut("Taxonomy","fluent-crm")+" "+o.replaceAll("_"," ")),onChange:t=>((e,t)=>{const n=[...x];n.length<1&&n.push({}),n[0][e]=t,k({taxTypes:[...n]})})(e,t)},e+n);var o})}):null,T[t]?.terms?(0,a.jsx)(ft,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,className:"fc-operator-type",label:ut("Select Operator Type","fluent-crm"),value:j,options:[{label:"AND",value:"AND"},{label:"OR",value:"OR"}],help:ut("Select the operator type for the taxonomy filter","fluent-crm"),onChange:e=>{k({selectedOperatorType:e})}}):"",(0,a.jsx)(ft,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:ut("Order by","fluent-crm"),options:[{label:ut("Newest to Oldest","fluent-crm"),value:"date/desc"},{label:ut("Oldest to Newest","fluent-crm"),value:"date/asc"},{label:ut("A → Z","fluent-crm"),value:"title/asc"},{label:ut("Z → A","fluent-crm"),value:"title/desc"}],value:`${b}/${w}`,onChange:e=>{const[t,n]=e.split("/");n!==w&&k({order:n}),t!==b&&k({orderBy:t})}}),(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",className:"fc-recent-posts-number",value:C,label:ut("Posts from last (days)","fluent-crm"),help:ut("e.g get posts in the last (7) days","fluent-crm"),onChange:e=>k({recentPostDays:e})}),(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",className:"fce-dimension-box",value:o,label:ut("Show Posts","fluent-crm"),help:ut("e.g how many posts you want to show","fluent-crm"),onChange:e=>k({selectedPostsPerPage:e})}),(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",min:0,max:500,className:"fce-dimension-box",value:M,label:ut("Posts Gap (px)","fluent-crm"),help:ut("Space between each post item","fluent-crm"),onChange:e=>k({postsGap:Math.min(500,Math.max(0,parseInt(e,10)||0))})}),(0,a.jsxs)("div",{className:"show-setting-control-box select-layout",children:[(0,a.jsx)("p",{children:ut("Select Layout","fluent-crm")}),(0,a.jsx)(yt,{className:"show-setting-dropdown",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("img",{onClick:t,"aria-expanded":e,src:H,alt:""}),(0,a.jsx)(_t,{variant:"primary",onClick:t,"aria-expanded":e,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})})]}),renderContent:({onToggle:e})=>(0,a.jsxs)("div",{className:"dropdown-render-content dropdown-render-selected-layout fc-layout-picker",children:[(0,a.jsx)("p",{children:ut("Select Layout","fluent-crm")}),(0,a.jsx)("div",{className:"fc-layout-picker-grid",role:"radiogroup","aria-label":ut("Layout","fluent-crm"),children:O.map(t=>(0,a.jsxs)("button",{type:"button",className:"fc-layout-picker-option "+(r===t.value?"is-active":""),role:"radio","aria-checked":r===t.value,onClick:()=>{k({selectedLayout:t.value}),e()},children:[(0,a.jsx)("img",{src:t.image,alt:t.label}),(0,a.jsx)("span",{children:t.label})]},t.value))})]})})]}),"layout-5"!==r?(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Image","fluent-crm"),checked:m,onChange:()=>k({showImage:!m})}):null,"layout-5"!==r&&"layout-6"!==r?(0,a.jsxs)("div",{className:"show-setting-control-box",children:[(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Excerpt","fluent-crm"),checked:I,onChange:()=>k({showDescription:!I})}),!0===I?(0,a.jsx)(yt,{className:"show-setting-dropdown",contentClassName:"my-popover-content-classname",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,a.jsx)(_t,{variant:"primary",onClick:t,"aria-expanded":e,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})}),renderContent:()=>(0,a.jsx)("div",{className:"dropdown-render-content",children:(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",max:100,className:"fce-dimension-box",value:S,label:ut("Excerpt Length","fluent-crm"),onChange:e=>k({selectedExcerptLength:e})})})}):null]}):null,"default"!==r&&"layout-5"!==r&&"layout-7"!==r?(0,a.jsxs)("div",{className:"show-setting-control-box",children:[(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Meta","fluent-crm"),checked:p,onChange:()=>k({showMeta:!p})}),!0===p?(0,a.jsx)(yt,{className:"show-setting-dropdown",contentClassName:"my-popover-content-classname",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,a.jsx)(_t,{variant:"primary",onClick:t,"aria-expanded":e,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})}),renderContent:()=>(0,a.jsxs)("div",{className:"dropdown-render-content setting-dropdown-meta",children:[(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Comments","fluent-crm"),checked:h,onChange:()=>k({showMetaComments:!h})}),(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Author","fluent-crm"),checked:f,onChange:()=>k({showMetaAuthor:!f})}),!0===f&&"layout-6"!==r?(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Author Avatar","fluent-crm"),checked:g,onChange:()=>k({showMetaAuthorImg:!g})}):null]})}):null]}):null,"layout-4"!==r&&"layout-5"!==r&&"layout-6"!==r?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(gt,{__nextHasNoMarginBottom:!0,label:ut("Show Button","fluent-crm"),checked:y,onChange:()=>k({showButton:!y})}),!0===y?(0,a.jsx)(ht,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"text",value:_,label:ut("Button Text","fluent-crm"),onChange:e=>k({buttonText:e})}):null]}):null,"layout-5"!==r?(0,a.jsx)(ft,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:ut("Post Image Type","fluent-crm"),options:[{label:ut("Cover","fluent-crm"),value:"cover"},{label:ut("Contain","fluent-crm"),value:"contain"},{label:ut("None","fluent-crm"),value:"inherit"}],value:N,onChange:e=>k({backgroundType:e})}):null]})})}),(0,a.jsx)("div",{className:"fluent-latest-posts-content-color-settings",children:(0,a.jsx)(dt,{title:ut("Customization","fluent-crm"),colorSettings:B})})]})},{Spinner:vt}=wp.components,{useState:Ct,useEffect:St}=wp.element,{__:Nt,_n}=wp.i18n,jt=e=>{const{attributes:{selectedPostType:t,selectedPostsPerPage:n,selectedLayout:o,contentColor:r,titleColor:i,backgroundColor:s,authorColor:l,commentColor:c,buttonColor:d,showImage:u,showMeta:m,showMetaAuthor:p,showMetaAuthorImg:f,showMetaComments:g,showButton:h,showDescription:y,selectedExcerptLength:_,orderBy:I,order:b,taxTypes:w,catType:x,recentPostDays:v,buttonText:C,backgroundType:S,selectedOperatorType:N,postsGap:j},setAttributes:M}=e,[k,T]=Ct([]),[E,D]=Ct(!1),[A,L]=Ct(!1);St(()=>{R()},[t,n,I,b,w,x,v,N]);const P=wp.apiFetch,{addQueryArgs:B}=wp.url,R=e=>{D(!0),P({path:B("fluent-crm/v2/campaigns-pro/posts",{per_page:n,post_type:t,orderBy:I,order:b,taxTypes:w,catType:x,days:v,excerptLength:_,operator:N,...e})}).then(e=>{T(e.posts),M({postTypes:e.post_types})}).catch(e=>{L(!0)}).finally(()=>{D(!1)})},z={color:r},H={color:i},O={background:s,marginBottom:(j??20)+"px"},F={color:l},U={color:c};let G="";G="layout-7"===o?{color:d,border:"2px solid "+d}:{color:d};const Z=e=>{const t=_,n=e.split(/\s+/);return n.length<=t?e:n.slice(0,t).join(" ")+"..."};return(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"fc_latest_blog_posts",children:E?(0,a.jsx)("h2",{children:(0,a.jsx)(vt,{})}):(0,a.jsx)("div",{className:"fc_latest_posts_items template-"+o,children:k&&k.length?k.map((e,t)=>(0,a.jsx)("div",{className:"fc_latest_post_item",style:O,children:"layout-6"===o?(0,a.jsxs)(a.Fragment,{children:[e.thumbnail&&!0===u?(0,a.jsx)("div",{className:"fc_latest_post_thumbnail",style:{backgroundImage:`url(${e.thumbnail})`,backgroundSize:S}}):null,(0,a.jsxs)("div",{className:"fc_latest_post_content",children:[(0,a.jsx)("h1",{className:"title",style:H,children:e.post_title?e.post_title:"(no title)"}),!0===m?(0,a.jsxs)("p",{className:"meta",style:F,children:[!0===p?(0,a.jsx)("span",{className:"author",children:(0,a.jsx)("span",{style:F,children:e.author})}):null,!0===p&&!0===g&&e.comment_count?"-":null,!0===g&&e.comment_count?(0,a.jsx)("span",{className:"comments",style:U,children:_n(e.comment_count+" comment",e.comment_count+" comments",e.comment_count)}):null]}):null]})]}):(0,a.jsxs)(a.Fragment,{children:[e.thumbnail&&!0===u&&"layout-5"!==o?(0,a.jsx)("div",{className:"fc_latest_post_thumbnail",style:{backgroundImage:`url(${e.thumbnail})`,backgroundSize:S}}):null,(0,a.jsxs)("div",{className:"fc_latest_post_content",children:[!0===m&&"default"!==o&&"layout-5"!==o&&"layout-7"!==o?(0,a.jsxs)("p",{className:"meta",style:F,children:[!0===p?(0,a.jsxs)("span",{className:"author",children:[!0===f?(0,a.jsx)("img",{src:e.author_avatar,alt:e.author}):null,(0,a.jsx)("span",{style:F,children:e.author})]}):null,!0===p&&!0===g&&e.comment_count?"-":null,!0===g&&e.comment_count?(0,a.jsx)("span",{className:"comments",style:U,children:_n(e.comment_count+" comment",e.comment_count+" comments",e.comment_count)}):null]}):null,(0,a.jsx)("h1",{className:"title",style:H,children:e.post_title?e.post_title:"(no title)"}),!0===y&&"layout-5"!==o&&e.post_excerpt?(0,a.jsx)("p",{className:"description",style:z,children:Z(e.post_excerpt)}):null,!0===h&&"layout-4"!==o&&"layout-5"!==o?(0,a.jsx)("span",{style:G,className:"fc_latest_post_btn",children:C}):null]})]})},t)):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:"No Posts found!"})})})})})},{Fragment:Mt}=((0,n.withSelect)((e,t)=>{const{selectedPostType:n}=t.attributes;return{selectedPostType:n}})(jt),wp.element),{__:kt}=wp.i18n,Tt={selectedPostType:{type:"string",default:"post"},selectedPostsPerPage:{type:"string",default:"3"},selectedLayout:{type:"string",default:"default"},showImage:{type:"boolean",default:!0},showMeta:{type:"boolean",default:!0},showMetaAuthor:{type:"boolean",default:!0},showMetaAuthorImg:{type:"boolean",default:!0},showMetaComments:{type:"boolean",default:!0},showButton:{type:"boolean",default:!0},showDescription:{type:"boolean",default:!0},selectedExcerptLength:{type:"string",default:"55"},contentColor:{type:"string",default:"#6b6d7c"},titleColor:{type:"string",default:"#393d57"},backgroundColor:{type:"string",default:"#ffffff"},authorColor:{type:"string",default:"#393d57"},commentColor:{type:"string",default:"#acacac"},buttonColor:{type:"string",default:"#000000"},taxTypes:{type:"array",default:[]},catType:{type:"string",default:"category"},order:{type:"string",default:"desc"},orderBy:{type:"string",default:"date"},recentPostDays:{type:"string",default:""},buttonText:{type:"string",default:"Read More"},backgroundType:{type:"string",default:"cover"},selectedOperatorType:{type:"string",default:"OR"},postsGap:{type:"number",default:20}},Et=wp.element.createElement,{__:Dt}=wp.i18n,{registerBlockType:At}=wp.blocks,Lt=window.fcrmBlockEditorConfig?.modules||{},Pt=[{attributes:Tt,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],Bt=Et("svg",{width:20,height:20},Et("path",{d:"M0 0h24v24H0V0z",fill:"none"}),Et("path",{fill:"#96588a",d:"M22 9.24l-7.19-.62L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21 12 17.27 18.18 21l-1.63-7.03L22 9.24zM12 15.4l-3.76 2.27 1-4.28-3.32-2.88 4.38-.38L12 6.1l1.71 4.04 4.38.38-3.32 2.88 1 4.28L12 15.4z"}));!1!==Lt.hasFluentCampaign&&At("fluent-crm/latest-posts",{apiVersion:3,title:Dt("Latest Posts Block"),description:Dt("Latest Posts Block For your Email"),category:"layout",icon:Bt,keywords:[Dt("card"),Dt("latest blog"),Dt("latest posts")],supports:{align:["wide","full"],html:!0},attributes:Tt,deprecated:Pt,edit:e=>{const t=(0,v.useBlockProps)({className:"fluent-latest-posts-block"});return(0,a.jsxs)(Mt,{children:[(0,a.jsx)("div",{...t,children:(0,a.jsx)(jt,{attributes:e.attributes,setAttributes:e.setAttributes})}),(0,a.jsx)(xt,{attributes:e.attributes,setAttributes:e.setAttributes})]})},save:Qe});const Rt={selectedLayout:{type:"string",default:"default"},selectedPostsPerPage:{type:"string",default:"3"},showDescription:{type:"boolean",default:!0},showImage:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0},showButton:{type:"boolean",default:!0},taxonomies:{type:"array",default:[]},taxType:{type:"string",default:"all"},order:{type:"string",default:"desc"},orderBy:{type:"string",default:"date"},buttonText:{type:"string",default:"Buy Now"},titleColor:{type:"string",default:"#2a363d"},descriptionColor:{type:"string",default:""},priceColor:{type:"string",default:"#37454e"},buttonColor:{type:"string",default:""},buttonBG:{type:"string",default:"#2a363d"}},{Fragment:zt}=wp.element,Ht=({attributes:e,setAttributes:t,LandingPage:n,InspectorSettings:o})=>{const r=(0,v.useBlockProps)({className:"fluent-latest-posts-block"});return(0,a.jsxs)(zt,{children:[(0,a.jsx)("div",{...r,children:(0,a.jsx)(n,{attributes:e,setAttributes:t})}),(0,a.jsx)(o,{attributes:e,setAttributes:t})]})},{Spinner:Ot}=wp.components,{useState:Ft,useEffect:Ut}=wp.element,{__:Gt,_n:Zt}=wp.i18n,Vt=e=>{const{attributes:{selectedLayout:t,order:n,orderBy:o,taxonomies:r,taxType:i,selectedPostsPerPage:s,showDescription:l,showImage:c,showPrice:d,showButton:u,buttonText:m,titleColor:p,priceColor:f,buttonColor:g,buttonBG:h,descriptionColor:y},setAttributes:_}=e,[I,b]=Ft([]),[w,x]=Ft(!1),v=wp.apiFetch,{addQueryArgs:C}=wp.url,[S,N]=Ft(!1),j=window.fcrmBlockEditorConfig||{},M=j.endpoints?.products||"fluent-crm/v2/campaigns-pro/products";Ut(()=>{k()},[s,n,o,i]);const k=e=>{x(!0),N(!1),v({path:C(M,{per_page:s,order:n,orderby:o,taxType:i,...e})}).then(e=>{const t=(e=>{const t={product:{terms:{product_cat:[]}}};return Array.isArray(e)?{products:e,taxonomies:t}:{products:Array.isArray(e?.products)?e.products:Array.isArray(e?.data?.products)?e.data.products:[],taxonomies:e?.taxonomies||e?.data?.taxonomies||t}})(e);b(t.products),_({taxonomies:t.taxonomies})}).catch(()=>(e=>v({path:C("wc/store/products",{per_page:s,order:n,orderby:o,...e})}).then(e=>({products:Array.isArray(e)?e:[],taxonomies:{product:{terms:{product_cat:[]}}}})))(e).then(e=>{b(e.products),_({taxonomies:e.taxonomies})})).catch(()=>{b([]),N(!0)}).finally(()=>{x(!1)})},T=e=>e?e.image?e.image:e.images&&e.images.length&&e.images[0].src||"":"",E={color:p},D={color:y},A={color:f};let L="";return"layout-3"!==t&&!0===u&&(L={color:g}),"layout-2"===t&&(L={color:g,background:h}),(0,a.jsx)("div",{children:w?(0,a.jsx)("h2",{children:(0,a.jsx)(Ot,{})}):(0,a.jsx)("div",{className:"fc_woo_products template-"+t,children:I&&I.length?I.map((e,n)=>(0,a.jsxs)("div",{className:"fc_woo_product"+(c?"":" no-image"),children:[!0===c?(0,a.jsx)("div",{className:"fc_woo_product_img",children:(0,a.jsx)("img",{src:T(e),alt:""})}):null,(0,a.jsxs)("div",{className:"fc_woo_product_info",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"title",style:E,dangerouslySetInnerHTML:{__html:e.name}}),"layout-2"===t&&!0===l?(0,a.jsx)("p",{className:"description",style:D,dangerouslySetInnerHTML:{__html:e.short_description}}):null,!0===d?(0,a.jsx)("span",{className:"price",style:A,dangerouslySetInnerHTML:{__html:ze(e.price_html,Gt("Free"))}}):null]}),"layout-3"!==t&&!0===u?(0,a.jsx)("span",{className:"add-to-cart-btn",style:L,children:m}):null]})]},n)):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:"No Products found!"})})})})},Wt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzM2IiBoZWlnaHQ9IjM2OSIgdmlld0JveD0iMCAwIDMzNiAzNjkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjI0IiB5PSIyNCIgd2lkdGg9IjI4OCIgaGVpZ2h0PSIyMTMiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjQiIHk9IjI2MyIgd2lkdGg9IjIwMyIgaGVpZ2h0PSIxNiIgcng9IjgiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMjQiIHk9IjI5NCIgd2lkdGg9IjUxIiBoZWlnaHQ9IjEyIiByeD0iNiIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIyNCIgeT0iMzI5IiB3aWR0aD0iNjIiIGhlaWdodD0iMTQiIHJ4PSI3IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSIzMzQiIGhlaWdodD0iMzY3IiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPC9zdmc+Cg==",Qt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNzExIiBoZWlnaHQ9IjUwOCIgdmlld0JveD0iMCAwIDcxMSA1MDgiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjMwIiB5PSIzMCIgd2lkdGg9IjI5OCIgaGVpZ2h0PSIyMTIiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMzY1IiB5PSI0MiIgd2lkdGg9IjIxNiIgaGVpZ2h0PSIxNiIgcng9IjgiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMzY1IiB5PSI3OCIgd2lkdGg9IjI5NiIgaGVpZ2h0PSIxMiIgcng9IjYiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMzY1IiB5PSIxMDEiIHdpZHRoPSIxNDkiIGhlaWdodD0iMTIiIHJ4PSI2IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjM2NSIgeT0iMTMzIiB3aWR0aD0iNjIiIGhlaWdodD0iMTQiIHJ4PSI3IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjM2NSIgeT0iMTczIiB3aWR0aD0iMzE2IiBoZWlnaHQ9IjU2IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjMwIiB5PSIyNjYiIHdpZHRoPSIyOTgiIGhlaWdodD0iMjEyIiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjM2NSIgeT0iMjc4IiB3aWR0aD0iMjE2IiBoZWlnaHQ9IjE2IiByeD0iOCIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIzNjUiIHk9IjMxNCIgd2lkdGg9IjI5NiIgaGVpZ2h0PSIxMiIgcng9IjYiIGZpbGw9IiNFREVFRjQiLz4KPHJlY3QgeD0iMzY1IiB5PSIzMzciIHdpZHRoPSIxNDkiIGhlaWdodD0iMTIiIHJ4PSI2IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjM2NSIgeT0iMzY5IiB3aWR0aD0iNjIiIGhlaWdodD0iMTQiIHJ4PSI3IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjM2NSIgeT0iNDA5IiB3aWR0aD0iMzE2IiBoZWlnaHQ9IjU2IiBmaWxsPSIjRURFRUY0Ii8+CjxyZWN0IHg9IjEiIHk9IjEiIHdpZHRoPSI3MDkiIGhlaWdodD0iNTA2IiByeD0iOSIgc3Ryb2tlPSIjRURFRUY0IiBzdHJva2Utd2lkdGg9IjIiLz4KPC9zdmc+Cg==",Yt="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzM2IiBoZWlnaHQ9IjMzMiIgdmlld0JveD0iMCAwIDMzNiAzMzIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxyZWN0IHg9IjI0IiB5PSIyNCIgd2lkdGg9IjI4OCIgaGVpZ2h0PSIyMTMiIHJ4PSIxMCIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSI2NiIgeT0iMjYzIiB3aWR0aD0iMjAzIiBoZWlnaHQ9IjE2IiByeD0iOCIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxNDIiIHk9IjI5NCIgd2lkdGg9IjUxIiBoZWlnaHQ9IjEyIiByeD0iNiIgZmlsbD0iI0VERUVGNCIvPgo8cmVjdCB4PSIxIiB5PSIxIiB3aWR0aD0iMzM0IiBoZWlnaHQ9IjMzMCIgcng9IjkiIHN0cm9rZT0iI0VERUVGNCIgc3Ryb2tlLXdpZHRoPSIyIi8+Cjwvc3ZnPgo=",{InspectorControls:Jt,PanelColorSettings:$t}=wp.blockEditor,{__:qt}=wp.i18n,{PanelBody:Kt,PanelRow:Xt,SelectControl:en,ToggleControl:tn,TextControl:nn,Dropdown:on,Button:rn}=wp.components,an=e=>{const{attributes:{selectedLayout:t,order:n,orderBy:o,taxonomies:r,taxType:i,selectedPostsPerPage:s,showDescription:l,showImage:c,showPrice:d,showButton:u,buttonText:m,titleColor:p,priceColor:f,buttonColor:g,buttonBG:h,descriptionColor:y},setAttributes:_}=e;let I=Wt;"layout-2"===t?I=Qt:"layout-3"===t&&(I=Yt);const b=[{value:"default",label:qt("Default","fluent-crm"),image:Wt},{value:"layout-2",label:qt("Layout 2","fluent-crm"),image:Qt},{value:"layout-3",label:qt("Layout 3","fluent-crm"),image:Yt}],w=[{value:p,onChange:e=>{_({titleColor:e})},label:qt("Title Color")}];"layout-2"===t&&!0===l&&w.push({value:y,onChange:e=>{_({descriptionColor:e})},label:qt("Description Color")}),!0===d&&w.push({value:f,onChange:e=>{_({priceColor:e})},label:qt("Price Color")}),"layout-3"!==t&&!0===u&&w.push({value:g,onChange:e=>{_({buttonColor:e})},label:qt("Button Color")}),"layout-2"===t&&!0===u&&w.push({value:h,onChange:e=>{_({buttonBG:e})},label:qt("Button Background")});const x=[{value:"all",label:"All"}];return r.product?.terms&&r.product?.terms.product_cat&&r.product?.terms.product_cat.map(e=>x.push(e)),(0,a.jsxs)(Jt,{children:[(0,a.jsx)(Kt,{title:"General Settings",initialOpen:!0,children:(0,a.jsx)(Xt,{children:(0,a.jsxs)("div",{className:"fc-latest-products-settings",children:[r.product?.terms?(0,a.jsx)(en,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,value:i,options:x,placeholder:qt("Select Taxonomy","fluent-crm"),label:qt("Select Taxonomy","fluent-crm"),clearable:!0,onChange:e=>{_({taxType:e})}}):null,(0,a.jsx)(en,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:qt("Order by","fluent-crm"),options:[{label:qt("Newest to Oldest","fluent-crm"),value:"date/desc"},{label:qt("Oldest to Newest","fluent-crm"),value:"date/asc"},{label:qt("A → Z","fluent-crm"),value:"title/asc"},{label:qt("Z → A","fluent-crm"),value:"title/desc"}],value:`${o}/${n}`,onChange:e=>{const[t,r]=e.split("/");r!==n&&_({order:r}),t!==o&&_({orderBy:t})}}),(0,a.jsx)(nn,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"number",className:"fce-dimension-box",value:s,label:qt("Show Products"),help:"e.g how many products you want to show",onChange:e=>_({selectedPostsPerPage:e})}),(0,a.jsxs)("div",{className:"show-setting-control-box select-layout",children:[(0,a.jsx)("p",{children:"Select Layout"}),(0,a.jsx)(on,{className:"show-setting-dropdown",popoverProps:{placement:"bottom-end"},renderToggle:({isOpen:e,onToggle:t})=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("img",{onClick:t,"aria-expanded":e,src:I,alt:""}),(0,a.jsx)(rn,{variant:"primary",onClick:t,"aria-expanded":e,children:(0,a.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":"true",focusable:"false",children:(0,a.jsx)("path",{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})})})]}),renderContent:({onToggle:e})=>(0,a.jsxs)("div",{className:"dropdown-render-content dropdown-render-selected-layout fc-layout-picker",children:[(0,a.jsx)("p",{children:"Select Layout"}),(0,a.jsx)("div",{className:"fc-layout-picker-grid",role:"radiogroup","aria-label":qt("Layout","fluent-crm"),children:b.map(n=>(0,a.jsxs)("button",{type:"button",className:"fc-layout-picker-option "+(t===n.value?"is-active":""),role:"radio","aria-checked":t===n.value,onClick:()=>{_({selectedLayout:n.value}),e()},children:[(0,a.jsx)("img",{src:n.image,alt:n.label}),(0,a.jsx)("span",{children:n.label})]},n.value))})]})})]}),(0,a.jsx)(tn,{__nextHasNoMarginBottom:!0,label:qt("Show Image"),checked:c,onChange:()=>_({showImage:!c})}),"layout-2"===t?(0,a.jsx)(tn,{__nextHasNoMarginBottom:!0,label:qt("Show Description"),checked:l,onChange:()=>_({showDescription:!l})}):null,(0,a.jsx)(tn,{__nextHasNoMarginBottom:!0,label:qt("Show Price"),checked:d,onChange:()=>_({showPrice:!d})}),"layout-3"!==t?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tn,{__nextHasNoMarginBottom:!0,label:qt("Show Button"),checked:u,onChange:()=>_({showButton:!u})}),!0===u?(0,a.jsx)(nn,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,type:"text",value:m,label:qt("Button Text"),onChange:e=>_({buttonText:e})}):null]}):null]})})}),(0,a.jsx)("div",{className:"fc-latest-products-content-color-settings",children:(0,a.jsx)($t,{title:qt("Customization"),colorSettings:w})})]})},sn=wp.element.createElement,{__:ln}=wp.i18n,{registerBlockType:cn}=wp.blocks,dn=window.fcrmBlockEditorConfig?.modules||{},un=[{attributes:Rt,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],mn=sn("svg",{width:20,height:20,viewBox:"0 0 24 24"},sn("path",{fill:"#7F54B3",d:"M5 4h14a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-8.2L7 20v-4H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z"}),sn("text",{x:12,y:12.8,textAnchor:"middle",fontSize:6.5,fontFamily:"Arial, sans-serif",fontWeight:700,fill:"#fff"},"woo"));!1!==dn.hasFluentCampaign&&!1!==dn.hasWooCommerce&&cn("fluent-crm/woo-products",{apiVersion:3,title:ln("WooCommerce Products"),description:ln("WooCommerce Products For your Email"),category:"layout",icon:mn,keywords:[ln("card"),ln("latest product"),ln("latest products"),ln("products")],supports:{align:["wide","full"],html:!0},attributes:Rt,deprecated:un,edit:e=>(0,a.jsx)(Ht,{attributes:e.attributes,setAttributes:e.setAttributes,LandingPage:Vt,InspectorSettings:an}),save:Qe});const pn=(e="")=>((e="")=>{const t=document.createElement("textarea");return t.innerHTML=String(e),t.value})(e).replace(/\s+/g," ").trim(),fn=()=>{const e=window.fcrmBlockEditorConfig||{};return e.endpoints?.cartProducts||"fluent-crm/v2/editor/cart-products"},gn=e=>e?e.image?e.image:e.thumbnail?e.thumbnail:e.images&&e.images.length&&e.images[0].src||"":"",hn=(e={})=>{if(e?.label)return e.label;const t=e?.id?`#${e.id}`:"",n=e?.name||e?.post_title||"";return[t?`${t} - ${n}`:n,pn(e?.price_html?ze(e.price_html).replace(/<[^>]*>/g,""):e?.price_text),Array.isArray(e?.categories)?e.categories.filter(Boolean).join(", "):""].filter(Boolean).join(" | ")},yn=(e={})=>({id:e?.id,name:e?.name||e?.post_title||`#${e?.id}`,label:hn(e),short_description:e?.short_description||e?.post_excerpt||"",price_html:ze(e?.price_html||e?.price||""),image:gn(e),permalink:e?.permalink||"#"}),In=e=>{const t=Array.isArray(e?.products)?e.products:null,n=Array.isArray(e?.data?.products)?e.data.products:null;return{products:(t||n||[]).map(yn).filter(e=>!!e.id),taxonomies:e?.taxonomies||e?.data?.taxonomies||{}}},bn=e=>{const t=e?.product||e?.data?.product;return t&&t.id?yn(t):In(e).products[0]||null},{Spinner:wn}=wp.components,{useState:xn,useEffect:vn}=wp.element,{__:Cn}=wp.i18n,Sn=e=>{const{attributes:{selectedLayout:t,order:n,orderBy:o,taxonomies:r,taxType:i,selectedPostsPerPage:s,showDescription:l,showImage:c,showPrice:d,showButton:u,buttonText:m,titleColor:p,priceColor:f,buttonColor:g,buttonBG:h,descriptionColor:y},setAttributes:_}=e,[I,b]=xn([]),[w,x]=xn(!1),v=wp.apiFetch,{addQueryArgs:C}=wp.url,[S,N]=xn(!1),j=fn();vn(()=>{M()},[s,n,o,i]);const M=e=>{x(!0),v({path:C(j,{per_page:s,order:n,orderby:o,taxType:i,...e})}).then(e=>{const t=In(e);b(t.products),_({taxonomies:t.taxonomies})}).catch(e=>{N(!0)}).finally(()=>{x(!1)})},k=e=>e?.name||e?.post_title||"",T=e=>e?.short_description||e?.post_excerpt||"",E=e=>ze(e?.price_html||e?.price||e?.detail?.formatted_min_price,Cn("Free")),D={color:p},A={color:y},L={color:f};let P="";return"layout-3"!==t&&!0===u&&(P={color:g}),"layout-2"===t&&(P={color:g,background:h}),(0,a.jsx)("div",{children:w?(0,a.jsx)("h2",{children:(0,a.jsx)(wn,{})}):(0,a.jsx)("div",{className:"fc_woo_products template-"+t,children:I&&I.length?I.map((e,n)=>(0,a.jsxs)("div",{className:"fc_woo_product"+(c?"":" no-image"),children:[!0===c?(0,a.jsx)("div",{className:"fc_woo_product_img",children:(0,a.jsx)("img",{src:gn(e),alt:""})}):null,(0,a.jsxs)("div",{className:"fc_woo_product_info",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"title",style:D,dangerouslySetInnerHTML:{__html:k(e)}}),"layout-2"===t&&!0===l?(0,a.jsx)("p",{className:"description",style:A,dangerouslySetInnerHTML:{__html:T(e)}}):null,!0===d?(0,a.jsx)("span",{className:"price",style:L,dangerouslySetInnerHTML:{__html:E(e)}}):null]}),"layout-3"!==t&&!0===u?(0,a.jsx)("span",{className:"add-to-cart-btn",style:P,children:m}):null]})]},n)):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:"No Products found!"})})})})},Nn=wp.element.createElement,{__:jn}=wp.i18n,{registerBlockType:Mn}=wp.blocks,kn=window.fcrmBlockEditorConfig?.modules||{},Tn=[{attributes:Rt,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],En=Nn("svg",{width:20,height:20,viewBox:"0 0 24 24"},Nn("rect",{x:0,y:0,width:24,height:24,rx:4,fill:"#0b4dbb"}),Nn("path",{fill:"#fff",d:"M11.2 16.4H4.2l1.1-2.5c.3-.7 1-1.2 1.8-1.2h8.3l-.6 1.3c-.6 1.5-2 2.4-3.6 2.4z"}),Nn("path",{fill:"#fff",d:"M17 11.2H7.2l.6-1.3c.6-1.5 2-2.4 3.6-2.4h8.5l-1.1 2.5c-.3.7-1 1.2-1.8 1.2z"}));!1!==kn.hasFluentCart&&Mn("fluent-crm/cart-products",{apiVersion:3,title:jn("FluentCart Products"),description:jn("FluentCart Products For your Email"),category:"layout",icon:En,keywords:[jn("card"),jn("fluentcart"),jn("products")],supports:{align:["wide","full"],html:!0},attributes:Rt,deprecated:Tn,edit:e=>(0,a.jsx)(Ht,{attributes:e.attributes,setAttributes:e.setAttributes,LandingPage:Sn,InspectorSettings:an}),save:Qe});const{InspectorControls:Dn,PanelColorSettings:An}=wp.blockEditor,{__:Ln}=wp.i18n,{useState:Pn,useEffect:Bn,useRef:Rn}=wp.element,{PanelBody:zn,PanelRow:Hn,SelectControl:On,ToggleControl:Fn,ComboboxControl:Un,Spinner:Gn}=wp.components,Zn=Un||wp.components.__experimentalComboboxControl,Vn=e=>{const{attributes:{productId:t,showImage:n,showDescription:o,showPrice:r,showButton:i,template:s,backgroundColor:l,contentColor:c,pricingColor:d},setAttributes:u}=e,[m,p]=Pn([]),[f,g]=Pn(""),[h,y]=Pn(!1),_=Rn(null),I=wp.apiFetch,{addQueryArgs:b}=wp.url,w=fn(),x=[{value:"left",label:Ln("Image Left")},{value:"top",label:Ln("Image Top")},{value:"none",label:Ln("No Image")}];Bn(()=>(t&&C(t),()=>{_.current&&clearTimeout(_.current)}),[]);const v=(e={})=>{y(!0),I({path:b(w,{per_page:25,...e})}).then(e=>{p(In(e).products)}).catch(()=>{p([])}).finally(()=>{y(!1)})},C=e=>{e&&I({path:b(w,{product_id:e})}).then(e=>{const t=bn(e);g(t?.label||t?.name||"")}).catch(()=>{g("")})},S=e=>{if(!e)return;const t=m.find(t=>String(t.id)===String(e));t&&g(t.label||t.name||""),u({productId:parseInt(e,10)})},N=m.map(e=>({value:String(e.id),label:e.label||e.name})),j=t?String(t):null;j&&f&&!N.find(e=>e.value===j)&&N.unshift({value:j,label:f});const M=[{value:c,onChange:e=>u({contentColor:e}),label:Ln("Content Color")},{value:l,onChange:e=>u({backgroundColor:e}),label:Ln("Background Color")},{value:d,onChange:e=>u({pricingColor:e}),label:Ln("Price Color")}];return t?(0,a.jsxs)(Dn,{children:[(0,a.jsx)(zn,{title:Ln("Template Settings"),initialOpen:!0,children:(0,a.jsx)(Hn,{children:(0,a.jsxs)("div",{className:"fc-latest-products-settings",children:[(0,a.jsxs)("div",{style:{marginBottom:"12px"},children:[Zn?(0,a.jsx)(Zn,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:Ln("Select Product"),value:j,options:N,onChange:S,onFilterValueChange:e=>{_.current&&clearTimeout(_.current),_.current=setTimeout(()=>{v(e?{search:e}:{})},1200)},onFocus:()=>{m.length||v()},placeholder:Ln("Search product"),expandOnFocus:!0}):(0,a.jsx)(On,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:Ln("Select Product"),value:j,options:[{value:"",label:Ln("Select a Product")},...N],onChange:S}),h&&(0,a.jsx)("div",{style:{marginTop:"8px"},children:(0,a.jsx)(Gn,{})})]}),(0,a.jsx)(On,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:Ln("Design Template"),value:s,options:x,onChange:e=>{const t={template:e};"none"===e&&(t.showImage=!1),u(t)}}),(0,a.jsx)(Fn,{__nextHasNoMarginBottom:!0,label:Ln("Show Image"),checked:n,onChange:e=>u({showImage:e})}),(0,a.jsx)(Fn,{__nextHasNoMarginBottom:!0,label:Ln("Show Description"),checked:o,onChange:e=>u({showDescription:e})}),(0,a.jsx)(Fn,{__nextHasNoMarginBottom:!0,label:Ln("Show Price"),checked:r,onChange:e=>u({showPrice:e})}),(0,a.jsx)(Fn,{__nextHasNoMarginBottom:!0,label:Ln("Show Button"),checked:i,onChange:e=>u({showButton:e})})]})})}),(0,a.jsx)("div",{className:"fc-latest-products-content-color-settings",children:(0,a.jsx)(An,{title:Ln("Customization"),colorSettings:M})})]}):null},{RadioControl:Wn,Spinner:Qn}=wp.components,{InnerBlocks:Yn}=wp.blockEditor,{useState:Jn,useEffect:$n}=wp.element,{__:qn}=wp.i18n,Kn=e=>{const{clientId:t,attributes:{productId:n,showImage:o,showDescription:r,showPrice:i,showButton:s,buttonText:l,customImage:c,template:d,backgroundColor:u,contentColor:m,pricingColor:p},setAttributes:f}=e,[g,h]=Jn([]),[y,_]=Jn(""),[I,b]=Jn(""),[w,x]=Jn({}),[v,C]=Jn(!1),[S,N]=Jn(!1),j=wp.apiFetch,{addQueryArgs:M}=wp.url,k=fn();$n(()=>{n?P(n):L()},[n]);const{useDispatch:T,useSelect:E}=wp.data,{updateBlockAttributes:D}=T("core/block-editor"),A=E(e=>e("core/block-editor").getBlocks(t),[t]);$n(()=>{w.permalink&&A.forEach(e=>{"core/buttons"===e.name&&e.innerBlocks.forEach(e=>{"core/button"===e.name&&D(e.clientId,{url:w.permalink})})})},[w.permalink]);const L=(e={})=>{N(!0),j({path:M(k,{per_page:10,...e})}).then(e=>{const t=In(e).products;h(t)}).catch(()=>{h([])}).finally(()=>{N(!1)})},P=e=>{const t=parseInt(e,10);t&&(C(!0),j({path:M(k,{product_id:t})}).then(e=>{const t=bn(e);t&&(x(t),b(String(t.id)),f({productId:t.id}))}).catch(()=>{x({})}).finally(()=>{C(!1)}))},B=c||(w&&w.image?w.image:""),R=o&&"none"!==d&&B?d:"none",z={backgroundColor:u,color:m},H=["fcw_p",`fcw_template_${R}`,v?"fc_product_loading":""].filter(Boolean).join(" "),O=["fcw_search_box",v?"fc_product_loading":""].filter(Boolean).join(" ");return(0,a.jsxs)("div",{children:[v?(0,a.jsxs)("div",{style:z,className:"fc_woo_loader",children:[(0,a.jsx)(Qn,{}),(0,a.jsx)("h3",{children:qn("Loading product")})]}):null,w.id&&n?(0,a.jsxs)("div",{style:z,className:H,children:["none"!==R?(0,a.jsx)("div",{className:"fcw_image",children:(0,a.jsx)("img",{src:B,alt:""})}):null,(0,a.jsxs)("div",{className:"fcw_p_content",children:[(0,a.jsx)("h2",{style:{color:m||void 0},className:"fcw_p_title",dangerouslySetInnerHTML:{__html:w.name||""}}),r?(0,a.jsx)("div",{style:{color:m||void 0},className:"fcw_p_desc",dangerouslySetInnerHTML:{__html:w.short_description||""}}):null,i?(0,a.jsx)("div",{style:{color:p||void 0},className:"fcw_p_price",dangerouslySetInnerHTML:{__html:ze(w.price_html,qn("Free"))}}):null,s?(0,a.jsx)("div",{className:"fcb_p_button",children:(0,a.jsx)(Yn,{template:[["core/buttons",{},[["core/button",{text:l,url:w.permalink||"#",align:"left"}]]]],templateLock:"all"})}):null]})]}):(0,a.jsxs)("div",{className:O,children:[(0,a.jsx)("h4",{children:qn("Search and Select a Product")}),(0,a.jsx)("hr",{}),(0,a.jsxs)("div",{style:{marginBottom:"25px"},className:"fluent-single-product-search-bar",children:[(0,a.jsx)("div",{children:(0,a.jsx)("input",{placeholder:qn("Product name or id:1122"),style:{height:"36px"},value:y,onChange:e=>_(e.target.value),onKeyDown:e=>{"Enter"!==e.key&&""!==e.target.value||L({search:y})}})}),(0,a.jsx)("button",{style:{height:"36px"},onClick:()=>L({search:y}),children:qn("Search")})]}),S?(0,a.jsx)("h2",{children:(0,a.jsx)(Qn,{})}):(0,a.jsx)("div",{className:"fcw_results",children:g.length?(0,a.jsx)(Wn,{selected:I,options:g.map(e=>({value:String(e.id),label:e.label||e.name})),onChange:e=>b(e)}):(0,a.jsx)("div",{className:"fcw_products_not_found",children:(0,a.jsx)("h2",{children:qn("No products found!")})})}),(0,a.jsx)("button",{type:"button",style:{marginTop:"20px"},className:"components-button is-primary",disabled:!I,onClick:()=>P(I),children:qn("Done")})]})]})},{Fragment:Xn}=wp.element,{__:eo}=wp.i18n,to={productId:{type:"number",default:null},showImage:{type:"boolean",default:!0},showDescription:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!0},showButton:{type:"boolean",default:!0},buttonText:{type:"string",default:eo("Buy Now")},customImage:{type:"string",default:""},backgroundColor:{type:"string",default:"#fffeeb"},contentColor:{type:"string",default:""},pricingColor:{type:"string",default:""},template:{type:"string",default:"left"}},no=wp.element.createElement,{__:oo}=wp.i18n,{registerBlockType:ro}=wp.blocks,io=window.fcrmBlockEditorConfig?.modules||{},ao=[{attributes:{...to,buttonColor:{type:"string",default:"#ffffff"},buttonBG:{type:"string",default:"#2a363d"}},save:Qe},{attributes:to,save:()=>(0,a.jsx)("div",{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}],so=no("svg",{width:20,height:20,viewBox:"0 0 24 24"},no("rect",{x:0,y:0,width:24,height:24,rx:4,fill:"#0b4dbb"}),no("path",{fill:"#fff",d:"M11.2 16.4H4.2l1.1-2.5c.3-.7 1-1.2 1.8-1.2h8.3l-.6 1.3c-.6 1.5-2 2.4-3.6 2.4z"}),no("path",{fill:"#fff",d:"M17 11.2H7.2l.6-1.3c.6-1.5 2-2.4 3.6-2.4h8.5l-1.1 2.5c-.3.7-1 1.2-1.8 1.2z"}));!1!==io.hasFluentCart&&ro("fluent-crm/cart-product",{apiVersion:3,title:oo("FluentCart Product (Single)"),description:oo("Single FluentCart product block for your email"),category:"layout",icon:so,keywords:[oo("fluentcart"),oo("product"),oo("single")],supports:{align:["wide","full"],html:!0},attributes:to,deprecated:ao,edit:e=>{const t=(0,v.useBlockProps)({className:"fluent-single-product-block"});return(0,a.jsxs)(Xn,{children:[(0,a.jsx)("div",{...t,children:(0,a.jsx)(Kn,{clientId:e.clientId,attributes:e.attributes,setAttributes:e.setAttributes})}),(0,a.jsx)(Vn,{attributes:e.attributes,setAttributes:e.setAttributes})]})},save:Qe});const lo=function({children:e,...t}){return(0,a.jsx)("div",{className:"fc-cond-section",...t,children:(0,a.jsx)("div",{className:"fc-cond-blocks",children:e})})},co=window.fcrmBlockEditorConfig?.endpoints?.tags||"fluent-crm/v2/reports/options?fields=tags",uo=e=>Array.isArray(e)?e.map(e=>{const t=String(e.id??e.value??"");return{id:t,title:e.title||e.label||t}}).filter(e=>!!e.id):[],mo=()=>{const e=window.fcrmEditorBoot?.available_tags||window.fcAdmin?.available_tags||window._fcrm_available_tags||[];return uo(e)},po=(e,t)=>{window.wp&&window.wp.apiFetch&&(t(!0),window.wp.apiFetch({path:co}).then(t=>{const n=uo(t?.options?.tags||[]);window._fcrm_available_tags=n,e(n)}).catch(()=>{}).finally(()=>t(!1)))},fo=()=>!1!==(window.fcrmBlockEditorConfig?.modules||{}).hasFluentCampaign,go=window.wp.components,{__:ho,_x}=wp.i18n,{registerBlockType:yo}=wp.blocks,_o=[{attributes:{condition_type:{type:"string",default:"show_if_tag_exist"},tag_ids:{type:"array",default:[]}},save:()=>(0,a.jsx)(lo,{children:(0,a.jsx)(v.InnerBlocks.Content,{})})}];yo("fluentcrm/conditional-group",{apiVersion:3,title:ho("Conditional Section"),description:ho("Add a section that shows content conditionally by subscriber tags."),category:"layout",icon:"welcome-widgets-menus",keywords:[_x("conditional"),_x("section")],supports:{align:["wide","full"],anchor:!0,html:!1},attributes:{condition_type:{type:"string",default:"show_if_tag_exist"},tag_ids:{type:"array",default:[]}},deprecated:_o,edit:e=>{const{attributes:t,setAttributes:n}=e,{condition_type:o,tag_ids:r}=t,[s,l]=(0,i.useState)(mo()),[c,d]=(0,i.useState)(!1),u=fo(),m=(0,i.useMemo)(()=>Array.isArray(r)?r.map(e=>String(e)):[],[r]);(0,i.useEffect)(()=>{s.length||po(l,d)},[]);const p=(0,i.useMemo)(()=>{const e={};return s.forEach(t=>{e[t.id]=t.title}),e},[s]),f=(0,i.useMemo)(()=>{const e={};return s.forEach(t=>{e[t.title]=t.id}),e},[s]),g=(0,i.useMemo)(()=>m.map(e=>p[e]||e),[m,p]),h=(0,i.useMemo)(()=>s.map(e=>e.title),[s]),y=ho("show_if_tag_exist"===o?"Shown to subscribers with any selected tag.":"Hidden from subscribers with any selected tag.","fluent-crm"),_=(0,v.useBlockProps)({className:"fc-cond-section"});return(0,a.jsxs)(i.Fragment,{children:[(0,a.jsx)(v.InspectorControls,{children:(0,a.jsxs)(go.PanelBody,{title:ho("Conditional Settings"),children:[(0,a.jsx)(go.SelectControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:ho("Condition Type"),value:o,onChange:e=>n({condition_type:e||"show_if_tag_exist"}),options:[{value:"show_if_tag_exist",label:ho("Show if in selected tags","fluent-crm")},{value:"show_if_tag_not_exist",label:ho("Show if not in selected tags","fluent-crm")}]}),c?(0,a.jsx)(go.Spinner,{}):(0,a.jsx)(go.FormTokenField,{label:ho("Tags","fluent-crm"),value:g,suggestions:h,onChange:e=>{if(!u)return;const t=e.map(e=>f[e]).filter(Boolean);n({tag_ids:t})},disabled:!u,__experimentalExpandOnFocus:!0,__experimentalAutoSelectFirstMatch:!0,__experimentalShowHowTo:!1,__next40pxDefaultSize:!0}),u?(0,a.jsx)("p",{className:"components-base-control__help",children:y}):(0,a.jsx)(go.Notice,{status:"warning",isDismissible:!1,children:ho("Conditional Section requires FluentCRM Pro.","fluent-crm")})]})}),(0,a.jsx)("div",{..._,children:(0,a.jsx)("div",{className:"fc-cond-blocks",children:(0,a.jsx)(v.InnerBlocks,{})})})]})},save:()=>{const e=v.useBlockProps.save({className:"fc-cond-section"});return(0,a.jsx)("div",{...e,children:(0,a.jsx)("div",{className:"fc-cond-blocks",children:(0,a.jsx)(v.InnerBlocks.Content,{})})})}});const Io=window.wp.apiFetch;var bo=e.n(Io);const{__:wo,_x:xo}=wp.i18n,{registerBlockType:vo,createBlock:Co}=wp.blocks,So=wp.element.createElement,No="fcrm_ai_writing_tone",jo="fcrm_ai_writing_length",Mo=["Professional","Casual","Friendly","Urgent","Persuasive","Formal"],ko=["Short","Medium","Long"];function To(e,t,n){try{const n=localStorage.getItem(e);if(n&&t.includes(n))return n}catch(e){}return n}const Eo=So("svg",{width:20,height:20,viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg"},So("path",{d:"M9.9991 3C10.1943 3 10.3841 3.06406 10.5397 3.18199C10.6564 3.2705 10.7492 3.38584 10.8105 3.51729L10.8616 3.65356L10.8642 3.66522L11.88 7.6072C11.9117 7.73016 11.9758 7.84279 12.0656 7.93263C12.1554 8.02249 12.268 8.08733 12.391 8.11911L16.3339 9.13486L16.3429 9.13665V9.13755C16.4845 9.17662 16.6136 9.2493 16.7194 9.34913L16.8171 9.45761L16.896 9.58043C16.9642 9.70896 17 9.85305 17 10C17 10.1959 16.9358 10.3865 16.8171 10.5424C16.6984 10.6982 16.5317 10.8104 16.3429 10.8624L16.3339 10.8651L12.391 11.8809C12.268 11.9127 12.1554 11.9775 12.0656 12.0674C11.9758 12.1572 11.9117 12.2698 11.88 12.3928L10.8633 16.3348L10.8607 16.3464C10.808 16.5344 10.6952 16.7 10.5397 16.818C10.3841 16.9361 10.1935 17 9.99821 17C9.80298 16.9999 9.61315 16.936 9.45761 16.818C9.30206 16.7 9.18933 16.5344 9.13665 16.3464L9.13307 16.3348L8.11732 12.3928L8.08773 12.3023C8.05209 12.2146 7.99908 12.1347 7.93174 12.0674C7.84184 11.9775 7.72941 11.9126 7.6063 11.8809L3.66432 10.8642C3.65986 10.8631 3.6553 10.8619 3.65087 10.8607C3.46355 10.8075 3.29852 10.695 3.1811 10.5397C3.09296 10.4231 3.035 10.2872 3.01165 10.1443L3 10L3.01165 9.85566C3.035 9.71281 3.09296 9.57693 3.1811 9.4603C3.29852 9.30496 3.46354 9.19251 3.65087 9.13934L3.66432 9.13576L7.6063 8.11821C7.7293 8.0865 7.84186 8.0224 7.93174 7.93263C8.02162 7.84281 8.0855 7.73022 8.11732 7.6072L9.13397 3.66522L9.13665 3.65356H9.13755C9.19024 3.4656 9.30297 3.29997 9.4585 3.18199L9.58133 3.104C9.7095 3.0363 9.8527 3.00001 9.9991 3ZM9.229 7.89408C9.14588 8.21551 8.9779 8.50928 8.74308 8.74398C8.50825 8.97865 8.21464 9.14607 7.89319 9.229L4.90599 9.9991L7.89319 10.7701L8.01242 10.8051C8.28729 10.896 8.53756 11.0505 8.74308 11.256C8.94862 11.4616 9.10316 11.7118 9.19403 11.9867L9.229 12.1059L9.99821 15.0931L10.7692 12.1059C10.8522 11.7844 11.0195 11.4909 11.2542 11.256C11.4891 11.0211 11.7833 10.8531 12.105 10.7701L15.0931 10L12.105 9.22989C11.7833 9.14691 11.4891 8.97888 11.2542 8.74398C11.0488 8.53848 10.895 8.2881 10.8042 8.01332L10.7692 7.89408L9.9991 4.90779L9.229 7.89408ZM4.28381 14.4978V14.4297H4.21568C3.89888 14.4297 3.64205 14.1727 3.64191 13.8559C3.64191 13.539 3.89879 13.2821 4.21568 13.2821H4.28381V13.2131C4.28381 12.8964 4.54089 12.6396 4.85758 12.6393C5.17447 12.6393 5.43135 12.8962 5.43135 13.2131V13.2821H5.50038C5.81727 13.2821 6.07415 13.539 6.07415 13.8559C6.07401 14.1727 5.81718 14.4297 5.50038 14.4297H5.43135V14.4978C5.43135 14.8147 5.17447 15.0716 4.85758 15.0716C4.54089 15.0714 4.28381 14.8146 4.28381 14.4978ZM14.566 6.78689V6.07595H13.8541C13.5375 6.07575 13.2806 5.81875 13.2804 5.50218C13.2804 5.18541 13.5374 4.9286 13.8541 4.92841H14.566V4.21657C14.566 3.89969 14.8228 3.6428 15.1397 3.6428C15.4566 3.64282 15.7135 3.8997 15.7135 4.21657V4.92841H16.4253C16.742 4.92863 16.9991 5.18543 16.9991 5.50218C16.9989 5.81873 16.7419 6.07572 16.4253 6.07595H15.7135V6.78689C15.7135 7.10376 15.4566 7.36064 15.1397 7.36066C14.8228 7.36066 14.566 7.10377 14.566 6.78689Z",fill:"currentColor"})),Do=window.fcrmEditorBoot||{};Do.ai_writing&&Do.ai_writing.enabled&&vo("fluent-crm/ai-writer",{apiVersion:3,title:wo("Write with AI","fluent-crm"),description:wo("Generate a complete email section with AI. Type a prompt and the block will be replaced with generated content.","fluent-crm"),category:"text",icon:Eo,keywords:[xo("ai"),xo("writer"),xo("generate"),xo("prompt")],supports:{html:!1,reusable:!1,multiple:!0},attributes:{prompt:{type:"string",default:""}},edit:({attributes:e,setAttributes:t,clientId:o})=>{const{prompt:s}=e,[l,c]=(0,i.useState)(!1),[d,u]=(0,i.useState)(""),[m,p]=(0,i.useState)(()=>To(No,Mo,"Professional")),[f,g]=(0,i.useState)(()=>To(jo,ko,"Medium")),h=(0,v.useBlockProps)({className:"fcrm-ai-writer-block"}),y=(0,i.useCallback)(()=>{s&&s.trim()&&(u(""),c(!0),bo()({path:"fluent-crm/v2/ai/generate-email-body",method:"POST",data:{prompt:s.trim(),tone:m.toLowerCase(),length:f.toLowerCase(),audience:"",cta:"",context:{design_template:(window.fcrmEditorBoot||{}).current_design_template||"",editor_type:"block_editor",output_format:"gutenberg_blocks",campaign_type:((window.fcrmEditorBoot||{}).entity||{}).block_type||"",has_existing_body:"yes"}}}).then(e=>{if(e&&e.email_body){const i=(t=e.email_body)?t.includes("\x3c!-- wp:")?(0,r.parse)(t):(0,r.rawHandler)({HTML:t})||(0,r.pasteHandler)({HTML:t,mode:"BLOCKS"})||(0,r.pasteHandler)({plainText:t,mode:"BLOCKS"}):[];i&&i.length?(0,n.dispatch)("core/block-editor").replaceBlocks([o],i):u(wo("Could not generate content. Try a different prompt.","fluent-crm"))}else u(wo("No content was generated. Please try again.","fluent-crm"));var t}).catch(e=>{u(e&&e.message||wo("An error occurred. Please try again.","fluent-crm"))}).finally(()=>{c(!1)}))},[s,m,f,o]),_=(0,i.useCallback)(e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),y())},[y]);return(0,i.useCallback)(()=>{(0,n.dispatch)("core/block-editor").replaceBlocks([o],[Co("core/paragraph")])},[o]),(0,a.jsx)("div",{...h,children:(0,a.jsxs)("div",{className:"fcrm-ai-writer-block__inner",children:[(0,a.jsxs)("div",{className:"fcrm-ai-writer-block__header",children:[(0,a.jsx)("span",{className:"fcrm-ai-writer-block__icon",children:Eo}),(0,a.jsx)("span",{className:"fcrm-ai-writer-block__title",children:wo("Write with AI","fluent-crm")}),(0,a.jsxs)("div",{className:"fcrm-ai-writer-block__controls",children:[(0,a.jsx)("select",{className:"fcrm-ai-writer-block__select","aria-label":wo("Tone","fluent-crm"),value:m,onChange:e=>{p(e.target.value);try{localStorage.setItem(No,e.target.value)}catch(e){}},children:Mo.map(e=>(0,a.jsx)("option",{value:e,children:e},e))}),(0,a.jsx)("select",{className:"fcrm-ai-writer-block__select","aria-label":wo("Length","fluent-crm"),value:f,onChange:e=>{g(e.target.value);try{localStorage.setItem(jo,e.target.value)}catch(e){}},children:ko.map(e=>(0,a.jsx)("option",{value:e,children:e},e))})]})]}),(0,a.jsx)("textarea",{className:"fcrm-ai-writer-block__prompt",value:s||"",onChange:e=>t({prompt:e.target.value}),onKeyDown:_,placeholder:wo("Describe the email you want to write... (Ctrl+Enter to generate)","fluent-crm"),rows:3,disabled:l}),d?(0,a.jsx)("div",{className:"fcrm-ai-writer-block__error",children:d}):null,(0,a.jsxs)("div",{className:"fcrm-ai-writer-block__footer",children:[(0,a.jsx)("span",{className:"fcrm-ai-writer-block__tip",children:wo("Tip: Be specific about your audience and goal","fluent-crm")}),l?(0,a.jsxs)("div",{className:"components-button fcrm-ai-writer-block__generate-button fcrm-ai-writer-block__loading",children:[(0,a.jsx)(go.Spinner,{}),wo("Generating...","fluent-crm")]}):(0,a.jsxs)("div",{className:"fcrm_ai_button_anim_wrapper",children:[s||s&&s.trim()?(0,a.jsx)("div",{className:"fcrm_ai_button_anim",children:(0,a.jsx)("div",{className:"fcrm_ai_button_anim_inner"})}):null,(0,a.jsxs)(go.Button,{variant:"primary",disabled:!s||!s.trim(),onClick:y,className:"fcrm_ai_button fcrm-ai-writer-block__generate-button",children:[(0,a.jsx)("span",{className:"icon",children:(0,a.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,a.jsx)("path",{d:"M9.9991 3C10.1943 3 10.3841 3.06406 10.5397 3.18199C10.6564 3.2705 10.7492 3.38584 10.8105 3.51729L10.8616 3.65356L10.8642 3.66522L11.88 7.6072C11.9117 7.73016 11.9758 7.84279 12.0656 7.93263C12.1554 8.02249 12.268 8.08733 12.391 8.11911L16.3339 9.13486L16.3429 9.13665V9.13755C16.4845 9.17662 16.6136 9.2493 16.7194 9.34913L16.8171 9.45761L16.896 9.58043C16.9642 9.70896 17 9.85305 17 10C17 10.1959 16.9358 10.3865 16.8171 10.5424C16.6984 10.6982 16.5317 10.8104 16.3429 10.8624L16.3339 10.8651L12.391 11.8809C12.268 11.9127 12.1554 11.9775 12.0656 12.0674C11.9758 12.1572 11.9117 12.2698 11.88 12.3928L10.8633 16.3348L10.8607 16.3464C10.808 16.5344 10.6952 16.7 10.5397 16.818C10.3841 16.9361 10.1935 17 9.99821 17C9.80298 16.9999 9.61315 16.936 9.45761 16.818C9.30206 16.7 9.18933 16.5344 9.13665 16.3464L9.13307 16.3348L8.11732 12.3928L8.08773 12.3023C8.05209 12.2146 7.99908 12.1347 7.93174 12.0674C7.84184 11.9775 7.72941 11.9126 7.6063 11.8809L3.66432 10.8642C3.65986 10.8631 3.6553 10.8619 3.65087 10.8607C3.46355 10.8075 3.29852 10.695 3.1811 10.5397C3.09296 10.4231 3.035 10.2872 3.01165 10.1443L3 10L3.01165 9.85566C3.035 9.71281 3.09296 9.57693 3.1811 9.4603C3.29852 9.30496 3.46354 9.19251 3.65087 9.13934L3.66432 9.13576L7.6063 8.11821C7.7293 8.0865 7.84186 8.0224 7.93174 7.93263C8.02162 7.84281 8.0855 7.73022 8.11732 7.6072L9.13397 3.66522L9.13665 3.65356H9.13755C9.19024 3.4656 9.30297 3.29997 9.4585 3.18199L9.58133 3.104C9.7095 3.0363 9.8527 3.00001 9.9991 3ZM9.229 7.89408C9.14588 8.21551 8.9779 8.50928 8.74308 8.74398C8.50825 8.97865 8.21464 9.14607 7.89319 9.229L4.90599 9.9991L7.89319 10.7701L8.01242 10.8051C8.28729 10.896 8.53756 11.0505 8.74308 11.256C8.94862 11.4616 9.10316 11.7118 9.19403 11.9867L9.229 12.1059L9.99821 15.0931L10.7692 12.1059C10.8522 11.7844 11.0195 11.4909 11.2542 11.256C11.4891 11.0211 11.7833 10.8531 12.105 10.7701L15.0931 10L12.105 9.22989C11.7833 9.14691 11.4891 8.97888 11.2542 8.74398C11.0488 8.53848 10.895 8.2881 10.8042 8.01332L10.7692 7.89408L9.9991 4.90779L9.229 7.89408ZM4.28381 14.4978V14.4297H4.21568C3.89888 14.4297 3.64205 14.1727 3.64191 13.8559C3.64191 13.539 3.89879 13.2821 4.21568 13.2821H4.28381V13.2131C4.28381 12.8964 4.54089 12.6396 4.85758 12.6393C5.17447 12.6393 5.43135 12.8962 5.43135 13.2131V13.2821H5.50038C5.81727 13.2821 6.07415 13.539 6.07415 13.8559C6.07401 14.1727 5.81718 14.4297 5.50038 14.4297H5.43135V14.4978C5.43135 14.8147 5.17447 15.0716 4.85758 15.0716C4.54089 15.0714 4.28381 14.8146 4.28381 14.4978ZM14.566 6.78689V6.07595H13.8541C13.5375 6.07575 13.2806 5.81875 13.2804 5.50218C13.2804 5.18541 13.5374 4.9286 13.8541 4.92841H14.566V4.21657C14.566 3.89969 14.8228 3.6428 15.1397 3.6428C15.4566 3.64282 15.7135 3.8997 15.7135 4.21657V4.92841H16.4253C16.742 4.92863 16.9991 5.18543 16.9991 5.50218C16.9989 5.81873 16.7419 6.07572 16.4253 6.07595H15.7135V6.78689C15.7135 7.10376 15.4566 7.36064 15.1397 7.36066C14.8228 7.36066 14.566 7.10377 14.566 6.78689Z",fill:"currentColor"})})}),wo("Generate with AI","fluent-crm")]})]})]})]})})},save:()=>null});const Ao=window.wp.editor,Lo=Object.freeze({LAYOUT_CHANGE:"EDITOR_LAYOUT_CHANGE",FULLSCREEN_TOGGLE:"EDITOR_FULLSCREEN_TOGGLE",OPEN_EMAIL_PREVIEW:"EDITOR_OPEN_EMAIL_PREVIEW",OPEN_TEMPLATES:"EDITOR_OPEN_TEMPLATES",OPEN_SAVE_TEMPLATE:"EDITOR_OPEN_SAVE_TEMPLATE",SAVE_DRAFT:"EDITOR_SAVE_DRAFT",BACK:"EDITOR_BACK",NEXT:"EDITOR_NEXT",RECOVERY_NOTICE:"EDITOR_RECOVERY_NOTICE",STYLE_CONFIG_CHANGE:"EDITOR_STYLE_CONFIG_CHANGE",FOOTER_SETTINGS_CHANGE:"EDITOR_FOOTER_SETTINGS_CHANGE"}),Po=Object.freeze({LAYOUT_SYNC:"LAYOUT_SYNC",UPDATE_EDITOR:"UPDATE_EDITOR",STYLE_CONFIG_SYNC:"STYLE_CONFIG_SYNC",FOOTER_SETTINGS_SYNC:"FOOTER_SETTINGS_SYNC",INSERT_SMARTCODE:"INSERT_SMARTCODE"}),Bo=(e,t={})=>{window.parent&&window.parent.postMessage({action:e,...t},"*")},Ro=e=>!(!e||e.action!==Po.LAYOUT_SYNC||"string"!=typeof e.design_template),zo=e=>!(!e||e.action!==Po.STYLE_CONFIG_SYNC||!e.template_config||"object"!=typeof e.template_config),Ho=(e,t)=>{if("undefined"==typeof window)return()=>{};const n=(()=>{const e=window.fcrmEditorBoot||{},t=e.parent_origin||e.parentOrigin||"";if(t)try{return new URL(String(t),window.location.origin).origin}catch(e){}try{if(document.referrer)return new URL(document.referrer).origin}catch(e){}return window.location.origin})(),o=o=>{if(!window.parent||o.source!==window.parent)return;if(!o.origin||o.origin!==n)return;const r=(e=>e&&"object"==typeof e&&e.data?e.data:null)(o);r&&("function"!=typeof e||e(r,o))&&t(r,o)};return window.addEventListener("message",o),()=>window.removeEventListener("message",o)},Oo=/%(\d*)s|%d/g;function Fo(e,...t){return function(e,t=[]){if(!t.length)return e;let n=0;return String(e).replace(Oo,(e,o)=>{if(o){const n=parseInt(o,10)-1;return n<t.length?t[n]:e}return n<t.length?t[n++]:e})}(function(e){if("string"!=typeof e)return"";const t=window.fcAdmin&&window.fcAdmin.trans?window.fcAdmin.trans:null;return t&&t[e]?t[e]:(0,x.__)(e,"fluent-crm")}(e),t)}function Uo(){try{const e=new URLSearchParams(window.location.search),t=e.get("fcrm_ui");if(t)return"compose"===t;const n=Go(e.get("compose_nav"));if(null!==n)return n}catch(e){}const e=window.fcrmEditorBoot||{};if(e.fcrm_ui)return"compose"===e.fcrm_ui;const t=e.compose_nav||e.composeNav||{},n=Go(t.enabled??t.show??e.compose_nav_enabled??e.composeNavEnabled);return null!==n&&n}function Go(e){return!0===e||1===e||"1"===e||"true"===e||"yes"===e||!1!==e&&0!==e&&"0"!==e&&"false"!==e&&"no"!==e&&null}function Zo(e){const t=window.fcrmEditorBoot||{},n=t.compose_nav||t.composeNav||{};try{const t=new URLSearchParams(window.location.search);for(const n of e){const e=Go(t.get(n));if(null!==e)return e}}catch(e){}for(const o of e){const e=Go(n[o]);if(null!==e)return e;const r=Go(t[o]);if(null!==r)return r}return!1}function Vo(){return{hideBackBtn:Zo(["hideBackBtn","hide_back_btn"]),hideNextBtn:Zo(["hideNextBtn","hide_next_btn"]),hideSaveBtn:Zo(["hideSaveBtn","hide_save_btn"])}}function Wo(){const e=document.querySelector(".editor-header__toolbar")||document.querySelector(".edit-post-header__toolbar")||document.querySelector(".edit-post-header-toolbar__left")||document.querySelector(".edit-post-header-toolbar")||document.querySelector('.editor-header [class*="toolbar"]')||document.querySelector('.edit-post-header [class*="toolbar"]');return e?e.closest(".editor-header__toolbar, .edit-post-header__toolbar, .edit-post-header-toolbar__left, .edit-post-header-toolbar")||e:null}function Qo(e){if(!e)return null;const t=e.closest(".editor-header__actions, .editor-header__settings, .edit-post-header__settings, .edit-post-header__actions, .edit-post-header-toolbar__right")||e;return t.matches('button, [role="button"], a')?t.parentElement||null:t}function Yo(){const e=[".editor-header__actions",".editor-header__settings",".edit-post-header__settings",".edit-post-header-toolbar__right",".edit-post-header__actions"];for(const t of e){const e=Qo(document.querySelector(t));if(e)return e}return null}const Jo=['<span class="fcrm-back-icon" aria-hidden="true">','<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">','<path d="M19.9999 11.2H6.7999L10.4999 7.5L9.4999 6.5L3.8999 12L9.4999 17.5L10.4999 16.5L6.7999 12.8H19.9999V11.2Z" fill="currentColor"/>',"</svg>","</span>"].join(""),$o=['<span class="fcrm-preview-icon" aria-hidden="true">','<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">','<path d="M10 3.25C14.044 3.25 17.4085 6.16 18.1143 10C17.4093 13.84 14.044 16.75 10 16.75C5.956 16.75 2.5915 13.84 1.88575 10C2.59075 6.16 5.956 3.25 10 3.25ZM10 15.25C11.5296 15.2497 13.0138 14.7301 14.2096 13.7764C15.4055 12.8226 16.2422 11.4912 16.5828 10C16.2409 8.50998 15.4037 7.18 14.208 6.22752C13.0122 5.27504 11.5287 4.7564 10 4.7564C8.47127 4.7564 6.98777 5.27504 5.79203 6.22752C4.5963 7.18 3.75908 8.50998 3.41725 10C3.75782 11.4912 4.59451 12.8226 5.79036 13.7764C6.98621 14.7301 8.4704 15.2497 10 15.25V15.25ZM10 13.375C9.10489 13.375 8.24645 13.0194 7.61351 12.3865C6.98058 11.7536 6.625 10.8951 6.625 10C6.625 9.10489 6.98058 8.24645 7.61351 7.61352C8.24645 6.98058 9.10489 6.625 10 6.625C10.8951 6.625 11.7535 6.98058 12.3865 7.61352C13.0194 8.24645 13.375 9.10489 13.375 10C13.375 10.8951 13.0194 11.7536 12.3865 12.3865C11.7535 13.0194 10.8951 13.375 10 13.375ZM10 11.875C10.4973 11.875 10.9742 11.6775 11.3258 11.3258C11.6775 10.9742 11.875 10.4973 11.875 10C11.875 9.50272 11.6775 9.02581 11.3258 8.67418C10.9742 8.32254 10.4973 8.125 10 8.125C9.50272 8.125 9.02581 8.32254 8.67417 8.67418C8.32254 9.02581 8.125 9.50272 8.125 10C8.125 10.4973 8.32254 10.9742 8.67417 11.3258C9.02581 11.6775 9.50272 11.875 10 11.875Z" fill="currentColor"/>',"</svg>","</span>"].join(""),qo=['<span class="fcrm-smartcode-icon" aria-hidden="true">','<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">','<path d="M8.75 5.25C7.36929 5.25 6.25 6.36929 6.25 7.75V8.75C6.25 9.30228 5.80228 9.75 5.25 9.75H4.5V11.25H5.25C5.80228 11.25 6.25 11.6977 6.25 12.25V13.25C6.25 14.6307 7.36929 15.75 8.75 15.75H9.5V14.25H8.75C8.19772 14.25 7.75 13.8023 7.75 13.25V12.25C7.75 11.6891 7.56406 11.1716 7.25051 10.7556C7.56406 10.3384 7.75 9.82091 7.75 9.25V7.75C7.75 7.19772 8.19772 6.75 8.75 6.75H9.5V5.25H8.75Z" fill="currentColor"/>','<path d="M11.25 6.75C11.8023 6.75 12.25 7.19772 12.25 7.75V9.25C12.25 9.82091 12.4359 10.3384 12.7495 10.7556C12.4359 11.1716 12.25 11.6891 12.25 12.25V13.25C12.25 13.8023 11.8023 14.25 11.25 14.25H10.5V15.75H11.25C12.6307 15.75 13.75 14.6307 13.75 13.25V12.25C13.75 11.6977 14.1977 11.25 14.75 11.25H15.5V9.75H14.75C14.1977 9.75 13.75 9.30228 13.75 8.75V7.75C13.75 6.36929 12.6307 5.25 11.25 5.25H10.5V6.75H11.25Z" fill="currentColor"/>',"</svg>","</span>"].join("");let Ko=null,Xo=!1;function er(e){if(!e)return;const t=window.fcrmEditorAutosaveState||{canSave:!0,dirty:!1,inFlight:!1};if(!1===t.canSave)return void(e.style.display="none");e.style.display="";const n=function(e){return e.inFlight?Fo("Saving..."):e.dirty?Fo("Save"):Fo("Saved")}(t);e.textContent=n,e.setAttribute("aria-label",n)}function tr({className:e,text:t,html:n,ariaLabel:o,title:r,stopPropagation:i=!1,onClick:a}){const s=document.createElement("button");return s.type="button",s.className=e,n?s.innerHTML=n:s.textContent=t,o&&s.setAttribute("aria-label",o),r&&s.setAttribute("title",r),s.addEventListener("click",function(e){e.preventDefault(),i&&e.stopPropagation(),"function"==typeof a&&a(e)}),s}function nr(e){if(!e)return null;const t=e.querySelector('button[aria-label*="More"], button[aria-label*="more"], button[aria-label*="options"], button[aria-label*="Options"]');return t?t.closest('[class*="dropdown"], [class*="Dropdown"], .interface-more-menu-dropdown')||t:null}function or(e,t,n){if(!e||!t)return;const o=function(e,t){if(!e||!t)return null;if(t.parentElement===e)return t;const n=t.closest(":scope > *");if(n&&n.parentElement===e)return n;let o=t;for(;o&&o.parentElement&&o.parentElement!==e;)o=o.parentElement;return o&&o.parentElement===e?o:null}(e,n);rr(e,t,o)}function rr(e,t,n){if(e&&t)try{if(n&&n.parentElement===e)return void e.insertBefore(t,n);e.appendChild(t)}catch(n){try{e.appendChild(t)}catch(e){}}}function ir(e,t){if(!e||!t)return null;let n=t;for(;n&&n.parentElement&&n.parentElement!==e;)n=n.parentElement;return n&&n.parentElement===e?n:null}const ar=['<span class="fcrm-ai-writing-icon" aria-hidden="true">','<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">','<path d="M10 2.5L11.09 6.41L15 7.5L11.09 8.59L10 12.5L8.91 8.59L5 7.5L8.91 6.41L10 2.5Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>','<path d="M15 11.25L15.545 13.205L17.5 13.75L15.545 14.295L15 16.25L14.455 14.295L12.5 13.75L14.455 13.205L15 11.25Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>','<path d="M5 12.5L5.545 14.455L7.5 15L5.545 15.545L5 17.5L4.455 15.545L2.5 15L4.455 14.455L5 12.5Z" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>',"</svg>","</span>"].join("");function sr(e){if(!e)return;const t=function(){try{return!!(window.parent&&window.parent.document&&window.parent.document.body&&window.parent.document.body.classList.contains("fcrm-editor-fullscreen"))}catch(e){return!1}}();t===e.classList.contains("is-active")&&e.innerHTML||(e.innerHTML=t?'<span class="dashicons dashicons-fullscreen-exit-alt" aria-hidden="true"></span>':'<span class="dashicons dashicons-fullscreen-alt" aria-hidden="true"></span>',e.setAttribute("aria-label",Fo(t?"Minimize":"Maximize")),e.setAttribute("title",Fo(t?"Minimize":"Maximize")),e.classList.toggle("is-active",t))}function lr(){if(!Uo())return;document.body&&!document.body.classList.contains("fcrm-compose-ui")&&document.body.classList.add("fcrm-compose-ui");const e=Wo(),t=function(){const e=Yo();if(e)return e;const t=document.querySelector(".editor-header")||document.querySelector(".edit-post-header")||document.querySelector(".interface-interface-skeleton__header")||document.querySelector('header[role="banner"]');if(!t)return null;const n=t.querySelector(".editor-header__actions, .editor-header__settings, .edit-post-header__settings, .edit-post-header__actions, .edit-post-header-toolbar__right");if(n){let e=n.querySelector(".fcrm-compose-actions");return e||(e=document.createElement("div"),e.className="fcrm-compose-actions",e.setAttribute("style","display:flex;align-items:center;gap:10px;"),n.appendChild(e),e)}let o=t.querySelector(".fcrm-compose-actions");return o||(o=document.createElement("div"),o.className="fcrm-compose-actions",o.setAttribute("style","display:flex;align-items:center;gap:10px;margin-left:auto;"),t.appendChild(o)),o}(),n=Yo()||t;(e||t)&&(function(e,t){const n=e||t,o=document.querySelector(".fcrm-compose-back"),{hideBackBtn:r}=Vo();r?o&&o.remove():n&&!o&&rr(n,tr({className:"components-button fcrm-compose-back",html:Jo,ariaLabel:Fo("Back to campaign title and layout"),onClick:()=>Bo(Lo.BACK)}),n.firstChild)}(e,t),function(e){const{hideSaveBtn:t}=Vo(),n=document.querySelector(".fcrm-compose-save");if(t)return n&&n.remove(),void(Ko=null);if(!e)return;let o=e.querySelector(".fcrm-compose-save");if(!o){o=tr({className:"components-button fcrm-compose-save fcrm_secondary_btn",text:Fo("Save"),ariaLabel:Fo("Save Draft"),onClick:()=>{"function"==typeof window.fcrmManualAutosave&&window.fcrmManualAutosave(),Bo(Lo.SAVE_DRAFT)}});const t=e.querySelector(".fcrm-compose-next")||nr(e);or(e,o,t)}Ko=o,Xo||(Xo=!0,window.addEventListener("fcrm-autosave-state",()=>{er(Ko)})),er(o)}(t),function(e){if(!e||document.querySelector(".fcrm-compose-preview"))return;const t=tr({className:"components-button fcrm-compose-preview fcrm_secondary_btn fcrm-email-preview-btn",html:$o,ariaLabel:Fo("Email Preview"),title:Fo("Email Preview"),stopPropagation:!0,onClick:()=>Bo(Lo.OPEN_EMAIL_PREVIEW)}),n=e.querySelector(".fcrm-compose-next")||nr(e);or(e,t,n)}(t),function(e){const t=document.querySelector(".fcrm-compose-smartcodes");if(!t||e&&e.contains(t)||t.remove(),!e||e.querySelector(".fcrm-compose-smartcodes"))return;const n=tr({className:"components-button fcrm-compose-smartcodes fcrm-compose-smartcodes-left",html:qo,ariaLabel:Fo("Open smartcodes"),title:Fo("Smartcodes"),onClick:()=>window.dispatchEvent(new CustomEvent("fcrm-toggle-smartcodes"))}),o=e.querySelector('.block-editor-inserter__toggle, [aria-label*="Add block"], [aria-label*="add block"]'),r=ir(e,o);r&&r.nextSibling?rr(e,n,r.nextSibling):rr(e,n,null)}(e),function(e){const t=window.fcrmEditorBoot||{};if(!t.ai_writing||!t.ai_writing.enabled){const e=document.querySelector(".fcrm-compose-ai-writing");return void(e&&e.remove())}const n=document.querySelector(".fcrm-compose-ai-writing");if(!n||e&&e.contains(n)||n.remove(),!e)return;const o=e.querySelector(".fcrm-compose-ai-writing")||tr({className:"components-button fcrm-compose-ai-writing",html:ar,ariaLabel:Fo("AI Writing Assistant"),title:Fo("AI Writing"),onClick:()=>window.dispatchEvent(new CustomEvent("fcrm-toggle-ai-writing"))});if(e.contains(o))return;const r=e.querySelector(".fcrm-compose-smartcodes");if(r&&r.nextSibling)return void rr(e,o,r.nextSibling);const i=e.querySelector('.block-editor-inserter__toggle, [aria-label*="Add block"], [aria-label*="add block"]'),a=ir(e,i);a&&a.nextSibling?rr(e,o,a.nextSibling):rr(e,o,null)}(e),function(e){if(!e)return;let t=e.querySelector(".fcrm-compose-fullscreen");if(!t){t=tr({className:"components-button fcrm-compose-fullscreen fcrm_secondary_btn",html:"",ariaLabel:Fo("Maximize"),title:Fo("Maximize"),onClick:()=>{Bo(Lo.FULLSCREEN_TOGGLE,{mode:"toggle"}),setTimeout(()=>sr(t),150)}});const n=e.querySelector(".fcrm-compose-next")||nr(e);or(e,t,n)}sr(t)}(t),function(e){e&&e.querySelectorAll("button:not(.fcrm-compose-preview):not(.fcrm-compose-next)").forEach(function(e){const t=(e.getAttribute("aria-label")||"").toLowerCase(),n=(e.textContent||"").trim();if(t.includes("preview")&&!t.includes("email")||n===Fo("Preview")){e.style.display="none";const t=e.closest('[class*="dropdown"], [class*="Dropdown"]');t&&!t.querySelector(".fcrm-compose-preview")&&(t.style.display="none")}})}(n),function(e){const t=document.querySelector(".fcrm-compose-next"),{hideNextBtn:n}=Vo();n?t&&t.remove():e&&!t&&or(e,tr({className:"components-button fcrm-compose-next fcrm_primary_btn",text:Fo("Next"),ariaLabel:Fo("Next step"),onClick:()=>Bo(Lo.NEXT)}),nr(e))}(t))}function cr(){if(Uo())return;const e=Wo();if(e){const t=e.querySelector(".components-button:first-child, button:first-child");t&&(t.style.display="none"),e.querySelectorAll('.components-button[aria-label*="WordPress"], .components-button[aria-label*="wordpress"]').forEach(e=>e.style.display="none")}const t=document.querySelector(".editor-header__actions");t&&t.querySelectorAll("button").forEach(e=>{const t=e.textContent||e.innerText||"";(t.includes("Submit for Review")||t.includes("submit for review"))&&(e.style.display="none")});const n=document.querySelector(".editor-header");n&&n.querySelectorAll("button").forEach(e=>{const t=e.textContent||e.innerText||"",n=e.getAttribute("aria-label")||"";(t.includes("Submit for Review")||t.includes("submit for review")||n.includes("Submit for Review")||n.includes("submit for review"))&&(e.style.display="none")})}const dr=({onLayoutChange:e})=>{const t=window.fcrmEditorBoot||{},n=t.email_template_designs||window.fcAdmin?.email_template_designs||{},o=()=>{const e=window._fcrmStyleConfig?.design_template;if("string"==typeof e&&e)return e;const n=document.body?.getAttribute("data-design-template");if("string"==typeof n&&n)return n;const o=t.template_config?.design_template;return"string"==typeof o&&o?o:t.current_design_template||"simple"},[r,s]=(0,i.useState)(o),l=(0,i.useMemo)(()=>Object.entries(n).filter(([,e])=>!!e),[n]),c=(0,i.useMemo)(()=>l.reduce((e,[t,n])=>(e[n?.id||t]=n,e),{}),[l]),d=(0,i.useMemo)(()=>{const e=l.find(([,e])=>e&&e.use_gutenberg);return e?e[1]?.id||e[0]:"simple"},[l]),u=(0,i.useMemo)(()=>[d,"raw_classic","raw_html","visual_builder"].filter(Boolean).map(e=>[e,c[e]]).filter(([,e])=>!!e),[d,c]),m=(0,i.useMemo)(()=>new Set(u.map(([e])=>e)),[u]),p=(0,i.useMemo)(()=>{if(m.has(r))return r;const e=c[r];return e&&e.use_gutenberg&&m.has(d)?d:r},[d,c,m,r]);return(0,i.useEffect)(()=>(s(o()),Ho(Ro,e=>{s(e.design_template)})),[]),0===u.length?(0,a.jsx)("div",{className:"fcrm-layout-selector fcrm-layout-selector-empty",children:(0,a.jsx)("p",{children:(0,x.__)("No editors available.","fluent-crm")})}):(0,a.jsxs)("div",{className:"fcrm-layout-selector",children:[(0,a.jsx)("div",{className:"fcrm-layout-selector-header",children:(0,a.jsx)("h4",{className:"fcrm-layout-selector-header-title",children:"Layout"})}),(0,a.jsx)("div",{className:"fcrm-layout-grid",role:"group","aria-label":"Email layout",children:u.map(([t,n])=>{const o=n.id||t,r=p===o,i=((e,t)=>{const n=String(e?.id||t||"");if(n===String(d||"simple"))return(0,x.__)("Default (Gutenberg)","fluent-crm");const o=e?.label||e?.title||"";if(o)return o;const r={raw_classic:"Classic Editor",raw_html:"Raw HTML",visual_builder:"Visual Builder"};return r[n]?r[n]:n.replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase())})(n,t),l=n.path&&"string"==typeof n.path?(0,a.jsx)("span",{className:"fcrm-layout-thumb fcrm-layout-thumb-svg",dangerouslySetInnerHTML:{__html:n.path}}):n.image?(0,a.jsx)("span",{className:"fcrm-layout-thumb",children:(0,a.jsx)("img",{src:n.image,alt:"Layout"})}):(0,a.jsx)("span",{className:"fcrm-layout-thumb fcrm-layout-thumb-placeholder"});return(0,a.jsxs)("button",{type:"button",className:"fcrm-layout-option"+(r?" is-selected":""),onClick:()=>(t=>{const n=c[t];n?.config&&window._fcrmApplyDesignPreset&&window._fcrmApplyDesignPreset({...n.config,design_template:t}),s(t),"function"==typeof e&&e(t),Bo(Lo.LAYOUT_CHANGE,{design_template:t})})(o),title:i,"aria-pressed":r,children:[(0,a.jsx)("span",{className:"icon",children:(0,a.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 20 20",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:(0,a.jsx)("path",{d:"M10 17.5C5.85775 17.5 2.5 14.1422 2.5 10C2.5 5.85775 5.85775 2.5 10 2.5C14.1422 2.5 17.5 5.85775 17.5 10C17.5 14.1422 14.1422 17.5 10 17.5ZM9.25225 13L14.5547 7.69675L13.4943 6.63625L9.25225 10.879L7.1305 8.75725L6.07 9.81775L9.25225 13Z",fill:"CurrentColor"})})}),l,(0,a.jsx)("span",{className:"fcrm-layout-label",children:i})]},t)})})]})};function ur(){const e=window.fcrmEditorBoot||{},t=e.more_menu||{};return{helpUrl:t.help_url||e.help_url||"https://fluentcrm.com/docs/",hideWelcomeGuide:!1!==t.hide_welcome_guide,hideManagePatterns:void 0!==t.hide_manage_patterns&&t.hide_manage_patterns,hideFullscreenMode:!0,replaceNativeHelp:!1!==t.replace_native_help}}function mr(){if(!Uo())return;const e=ur();document.querySelectorAll(['.components-dropdown-menu__menu [role="menuitem"]','.components-dropdown-menu__menu [role="menuitemcheckbox"]',".components-dropdown-menu__menu button",".components-dropdown-menu__menu a"].join(",")).forEach(t=>{if((n=t)&&(n.classList?.contains("fcrm-more-menu-item")||n.closest?.(".fcrm-more-menu-item")))return;var n;const o=(r=t.getAttribute("aria-label")||t.textContent||"",String(r||"").trim().toLowerCase());var r;const i=e.hideWelcomeGuide&&o.includes("welcome guide"),a=e.hideManagePatterns&&o.includes("pattern"),s=e.hideFullscreenMode&&o.includes("fullscreen"),l=e.replaceNativeHelp&&o.includes("help");(i||a||s||l)&&(t.style.display="none")})}(0,t.registerPlugin)("fcrm-compose-more-menu",{render:function(){const e=Uo(),t=ur(),n=(window.fcrmEditorBoot||{}).features||{},[o,r]=(0,i.useState)(!1),[s,l]=(0,i.useState)(!1),c=()=>{try{return!!(window.parent&&window.parent.document&&window.parent.document.body&&window.parent.document.body.classList.contains("fcrm-editor-fullscreen"))}catch(e){return!1}};return(0,i.useEffect)(()=>{if(!e)return()=>{};mr();const t=new MutationObserver(()=>{mr()});return t.observe(document.body||document.documentElement,{childList:!0,subtree:!0}),()=>t.disconnect()},[e]),(0,i.useEffect)(()=>{if(!e)return()=>{};l(c());let t=null;try{const e=window.parent&&window.parent.document?window.parent.document.body:null;e&&(t=new MutationObserver(()=>{l(c())}),t.observe(e,{attributes:!0,attributeFilter:["class"]}))}catch(e){}return()=>{t&&t.disconnect()}},[e]),e?(0,a.jsxs)(i.Fragment,{children:[!1!==n.save_draft&&(0,a.jsx)(Ao.PluginMoreMenuItem,{icon:"saved",className:"fcrm-more-menu-item fcrm-more-menu-item-save-draft",onClick:()=>{"function"==typeof window.fcrmManualAutosave&&window.fcrmManualAutosave(),Bo(Lo.SAVE_DRAFT)},children:(0,x.__)("Save Draft","fluent-crm")}),!1!==n.save_as_template&&(0,a.jsx)(Ao.PluginMoreMenuItem,{icon:"plus-alt2",className:"fcrm-more-menu-item fcrm-more-menu-item-save-template",onClick:()=>Bo(Lo.OPEN_SAVE_TEMPLATE),children:(0,x.__)("Save as Template","fluent-crm")}),!1!==n.browse_templates&&(0,a.jsx)(Ao.PluginMoreMenuItem,{icon:"category",className:"fcrm-more-menu-item fcrm-more-menu-item-templates",onClick:()=>Bo(Lo.OPEN_TEMPLATES),children:(0,x.__)("Browse Templates","fluent-crm")}),!1!==n.switch_editor&&(0,a.jsx)(Ao.PluginMoreMenuItem,{icon:"screenoptions",className:"fcrm-more-menu-item fcrm-more-menu-item-switch-editor",onClick:()=>r(!0),children:(0,x.__)("Switch Editor","fluent-crm")}),(0,a.jsx)(Ao.PluginMoreMenuItem,{className:"fcrm-more-menu-item fcrm-more-menu-item-fullscreen",icon:s?"fullscreen-exit-alt":"fullscreen-alt",role:"menuitemcheckbox",isSelected:s,"aria-checked":s,onClick:()=>{Bo(Lo.FULLSCREEN_TOGGLE,{mode:"toggle"}),setTimeout(()=>{l(c())},0)},children:(0,x.__)("Fullscreen mode","fluent-crm")}),(0,a.jsx)(Ao.PluginMoreMenuItem,{icon:"editor-help",className:"fcrm-more-menu-item fcrm-more-menu-item-help",onClick:()=>{var e;(e=t.helpUrl)&&window.open(e,"_blank","noopener")},children:(0,x.__)("Help","fluent-crm")}),o?(0,a.jsx)(go.Modal,{title:(0,x.__)("Switch Editor","fluent-crm"),onRequestClose:()=>r(!1),className:"fcrm-layout-settings-modal",children:(0,a.jsx)("div",{className:"fcrm-layout-settings-modal__content",children:(0,a.jsx)(dr,{onLayoutChange:()=>r(!1)})})}):null]}):null}});const pr={name:"fcrm_prefixed",className:"editor-autocompleters__fcrm",triggerPrefix:"@",options(e){const t=[],n=new Set,o=[...window.fcAdmin?.globalSmartCodes||[],...window.fcAdmin?.extendedSmartCodes||[],...window.fcrm_funnel_context_codes||[]];if(o&&Array.isArray(o)&&o.forEach(e=>{const o=e.key,r=e.shortcodes;r&&"object"==typeof r&&Object.keys(r).forEach(e=>{n.has(e)||(n.add(e),t.push({code:e,title:r[e],prefix:o}))})}),0===t.length&&t.push({code:"{{contact.first_name}}",title:"First Name",prefix:"contact"},{code:"{{contact.last_name}}",title:"Last Name",prefix:"contact"},{code:"{{contact.email}}",title:"Email",prefix:"contact"},{code:"{{contact.full_name}}",title:"Full Name",prefix:"contact"},{code:"{{contact.phone}}",title:"Phone",prefix:"contact"},{code:"{{contact.address_line_1}}",title:"Address Line 1",prefix:"contact"},{code:"{{contact.city}}",title:"City",prefix:"contact"},{code:"{{contact.state}}",title:"State",prefix:"contact"},{code:"{{contact.postal_code}}",title:"Postal Code",prefix:"contact"},{code:"{{contact.country}}",title:"Country",prefix:"contact"}),e){const n=e.toLowerCase();return t.filter(e=>e.title.toLowerCase().includes(n)||e.code.toLowerCase().includes(n)||e.prefix.toLowerCase().includes(n))}return t},isDebounced:!0,getOptionKeywords:e=>[e.title,e.code],getOptionLabel:e=>[(0,a.jsx)("span",{className:"editor-autocompleters__user-name",children:e.title},"name")],getOptionCompletion:e=>e.code},fr=window.wp.richText,gr="fcrm/smartcode",hr="fcrm-smartcode-highlight",yr=/\{\{([^}|]+)(?:\|([^}]*))?\}\}/g,_r={title:"SmartCode",tagName:"span",className:hr,edit:function({value:e,onChange:t,contentRef:n}){const[o,r]=(0,i.useState)(null),[s,l]=(0,i.useState)(""),[c,d]=(0,i.useState)(null),u=(0,i.useRef)(!1),m=(0,i.useRef)(!1);(0,i.useEffect)(()=>{if(u.current)return;if(m.current)return void(m.current=!1);const t=function(e){const{text:t,start:n,end:o}=e;if(n!==o)return null;const r=/\{\{([^}|]+)(?:\|([^}]*))?\}\}/g;let i;for(;null!==(i=r.exec(t));)if(n>=i.index&&n<=i.index+i[0].length)return{name:i[1],defaultValue:i[2]||"",start:i.index,end:i.index+i[0].length};return null}(e);if(!t)return r(null),void d(null);const o=function(e){if(!e)return null;const t=e.ownerDocument.defaultView,n=t?.getSelection();if(!n?.rangeCount)return null;const o=n.getRangeAt(0).startContainer,r=o.nodeType===Node.TEXT_NODE?o.parentElement:o;return r?.closest("."+hr)||null}(n?.current);o?(r(t),l(t.defaultValue),d(o)):(r(null),d(null))},[e.start,e.end,e.text]);const p=(0,i.useCallback)(()=>{if(!o)return;const{name:n,start:i,end:a}=o,l=s?`{{${n}|${s}}}`:`{{${n}}}`,c=(0,fr.insert)(e,(0,fr.create)({text:l}),i,a);t(c),r(null),d(null),u.current=!1,m.current=!0},[o,s,e,t]);return o&&c?(0,a.jsx)(go.Popover,{anchor:c,placement:"bottom-start",focusOnMount:!1,className:"fcrm-smartcode-popover",children:(0,a.jsxs)("div",{className:"fcrm-smartcode-popover__content",children:[(0,a.jsx)("div",{className:"fcrm-smartcode-popover__header",children:(0,a.jsx)("span",{className:"fcrm-smartcode-popover__name",children:o.name})}),(0,a.jsx)("div",{className:"fcrm-smartcode-popover__label",children:"Default value"}),(0,a.jsxs)("div",{className:"fcrm-smartcode-popover__row",children:[(0,a.jsx)(go.TextControl,{value:s,onChange:l,placeholder:"Fallback if empty...",__nextHasNoMarginBottom:!0,onFocus:()=>{u.current=!0},onBlur:()=>{u.current=!1},onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),p())}}),(0,a.jsx)(go.Button,{variant:"primary",size:"compact",onClick:p,children:"Apply"})]})]})}):null},__experimentalCreatePrepareEditableTree:()=>(e,t)=>{if(yr.lastIndex=0,!yr.test(t))return e;let n,o={formats:e,text:t};for(yr.lastIndex=0;null!==(n=yr.exec(t));)o=(0,fr.applyFormat)(o,{type:gr},n.index,n.index+n[0].length);return o.formats}};(0,fr.registerFormatType)(gr,_r);let Ir=null;async function br(e=""){if(!1===Ir)return[];const t=new URLSearchParams({per_page:"10",search:e||""});try{const e=await fetch(`${function(){if(window.wpApiSettings?.root)return window.wpApiSettings.root;const e=window.fcrmEditorBoot?.autosave?.endpoint||"",t=e.indexOf("/wp-json/");return-1!==t?e.substring(0,t+9):window.location.origin+"/wp-json/"}()}fluent-crm/v2/smart-links?${t}`,{headers:{"X-WP-Nonce":window.fcrmEditorBoot?.autosave?.nonce||window.wpApiSettings?.nonce||""},credentials:"same-origin"});if(!e.ok)return 404!==e.status&&403!==e.status||(Ir=!1),[];Ir=!0;const n=await e.json();return(n?.action_links?.data||[]).map(e=>({id:e.id,title:e.title,url:e.short_url,target_url:e.target_url}))}catch(e){return[]}}const wr=(0,i.createElement)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:24,height:24,fill:"none"},(0,i.createElement)("path",{fill:"currentColor",d:"M14.037,9.598 C14.269,9.84 14.471,10.102 14.64,10.38 C14.856,10.733 14.744,11.195 14.391,11.411 C14.037,11.627 13.576,11.515 13.36,11.162 C13.246,10.976 13.111,10.799 12.955,10.637 C11.819,9.454 9.99,9.454 8.854,10.637 L5.614,14.008 C4.462,15.208 4.462,17.164 5.614,18.363 C6.75,19.546 8.58,19.546 9.716,18.363 L10.429,17.62 C10.717,17.322 11.191,17.312 11.49,17.599 C11.789,17.886 11.798,18.361 11.511,18.66 L10.797,19.403 C9.071,21.199 6.259,21.199 4.533,19.403 C2.822,17.623 2.822,14.749 4.533,12.969 L7.772,9.598 C9.498,7.801 12.31,7.801 14.037,9.598 Z M19.468,4.598 C21.178,6.377 21.178,9.251 19.468,11.031 L16.228,14.403 C15.96,14.681 15.665,14.918 15.35,15.111 C13.648,16.158 11.418,15.916 9.963,14.403 C9.731,14.16 9.53,13.898 9.36,13.62 C9.144,13.266 9.256,12.805 9.609,12.589 C9.963,12.373 10.424,12.485 10.64,12.838 C10.754,13.024 10.889,13.201 11.045,13.363 C12.006,14.363 13.457,14.514 14.565,13.833 C14.771,13.707 14.967,13.55 15.146,13.363 L18.386,9.992 C19.538,8.792 19.538,6.836 18.386,5.637 C17.25,4.454 15.421,4.454 14.285,5.637 L13.571,6.379 C13.284,6.678 12.809,6.688 12.51,6.401 C12.212,6.114 12.202,5.639 12.489,5.34 L13.203,4.598 C14.929,2.801 17.741,2.801 19.468,4.598 Z"}),(0,i.createElement)("path",{fill:"currentColor",d:"M20.5,15.8L20.925,17.075L22.2,17.5L20.925,17.925L20.5,19.2L20.075,17.925L18.8,17.5L20.075,17.075Z M17.5,19.5L17.75,20.25L18.5,20.5L17.75,20.75L17.5,21.5L17.25,20.75L16.5,20.5L17.25,20.25Z M22,20.4L22.15,20.85L22.6,21L22.15,21.15L22,21.6L21.85,21.15L21.4,21L21.85,20.85Z"}));(0,fr.registerFormatType)("fcrm/smart-link",{title:"Smart Link",tagName:"span",className:"fcrm-smart-link",edit:function({value:e,onChange:t}){const[n,o]=(0,i.useState)(!1),[r,a]=(0,i.useState)(""),[s,l]=(0,i.useState)([]),[c,d]=(0,i.useState)(!1),[u,m]=(0,i.useState)(null);(0,i.useEffect)(()=>{if(!n)return;d(!0);const e=setTimeout(()=>{br(r).then(e=>{l(e),d(!1)})},300);return()=>clearTimeout(e)},[r,n]),(0,i.useEffect)(()=>{n||(a(""),l([]))},[n]);const p=(0,i.useCallback)(e=>{if(!n){d(!0);const t=e&&(e.currentTarget||e.target)||document.activeElement;t instanceof HTMLElement&&m(t)}o(e=>!e)},[n]),f=(0,i.useCallback)(n=>{if(e.start===e.end){const o=(0,fr.create)({text:n.title}),r=(0,fr.applyFormat)(o,{type:"core/link",attributes:{url:n.url}});t((0,fr.insert)(e,r))}else t((0,fr.applyFormat)(e,{type:"core/link",attributes:{url:n.url}}));o(!1)},[e,t]);let g;return g=c?(0,i.createElement)("div",{className:"fcrm-smart-link-popover__loading"},(0,i.createElement)(go.Spinner)):!1===Ir?(0,i.createElement)("div",{className:"fcrm-smart-link-popover__empty"},(0,x.__)("Smart Links requires FluentCRM Pro","fluent-crm")):0===s.length?(0,i.createElement)("div",{className:"fcrm-smart-link-popover__empty"},r?(0,x.__)("No smart links found","fluent-crm"):(0,x.__)("No smart links available","fluent-crm")):(0,i.createElement)("div",{className:"fcrm-smart-link-popover__list"},s.map(e=>(0,i.createElement)("button",{key:e.id,className:"fcrm-smart-link-popover__item",onClick:()=>f(e),type:"button"},(0,i.createElement)("span",{className:"fcrm-smart-link-popover__item-title"},e.title),(0,i.createElement)("span",{className:"fcrm-smart-link-popover__item-url"},e.target_url)))),(0,i.createElement)(i.Fragment,null,(0,i.createElement)(v.RichTextToolbarButton,{icon:wr,title:(0,x.__)("Smart Link","fluent-crm"),onClick:p,isActive:n,className:"fcrm-smart-link-btn",name:"link"}),n&&(0,i.createElement)(go.Popover,{anchor:u,onClose:()=>o(!1),placement:"bottom-start",className:"fcrm-smart-link-popover",focusOnMount:"firstElement"},(0,i.createElement)("div",{className:"fcrm-smart-link-popover__content"},(0,i.createElement)(go.SearchControl,{value:r,onChange:a,placeholder:(0,x.__)("Search smart links...","fluent-crm"),__nextHasNoMarginBottom:!0}),g)))}});const xr=/^\s*(##[^#\s]+##|\{\{[^{}\r\n]+\}\})\s*$/;function vr(){const e=[...window.fcAdmin?.globalSmartCodes||[],...window.fcAdmin?.extendedSmartCodes||[]],t=[];return e.forEach(e=>{Object.entries(e?.shortcodes||{}).forEach(([e,n])=>{e.startsWith("##")&&t.push({code:e,label:n})})}),t}function Cr(e){const t=(e||"").trim(),n=t.match(xr);if(n){const e=n[1],t=vr().find(t=>t.code===e);return[{id:e,title:t?`${t.label} (${e})`:e,url:e,type:"smartcode"}]}if(t.startsWith("##")&&t.length>2){const e=t.toLowerCase();return vr().filter(({code:t,label:n})=>t.toLowerCase().startsWith(e)||n.toLowerCase().includes(e.replace(/^##/,""))).map(({code:e,label:t})=>({id:e,title:`${t} (${e})`,url:e,type:"smartcode"}))}return[]}(0,n.subscribe)(()=>{const e=(0,n.select)("core/block-editor").getSettings(),t=e?.__experimentalFetchLinkSuggestions;t&&!t.__fcrmSmartLinks&&function(){const e=(0,n.select)("core/block-editor").getSettings().__experimentalFetchLinkSuggestions;if(!e||e.__fcrmSmartLinks)return;const t=async(t,n)=>{const[o,r]=await Promise.all([e(t,n),br(t)]),i=r.map(e=>({id:e.id,title:e.title,url:e.url,type:e.target_url}));return[...Cr(t),...i,...o]};t.__fcrmSmartLinks=!0,(0,n.dispatch)("core/block-editor").updateSettings({__experimentalFetchLinkSuggestions:t})}()}),document.addEventListener("keydown",e=>{if("Enter"!==e.key||e.defaultPrevented)return;const t=e.target;if(!(t instanceof HTMLInputElement&&t.closest(".block-editor-link-control__search-input")))return;const n=(t.value||"").match(xr);if(!n)return;e.preventDefault(),e.stopPropagation();const o=t.closest(".block-editor-link-control")||document,r=n[1],i=Date.now()+2e3,a=()=>{if(!t.isConnected||(t.value||"").trim()!==r)return;const e=function(e,t){const n=e.querySelectorAll(".block-editor-link-control__search-item");for(const e of n){if(e.classList.contains("block-editor-link-control__search-create"))continue;const n=e.querySelector(".components-menu-item__shortcut");if(n&&"smartcode"===n.textContent.trim())return e;if(!n&&t&&(e.textContent||"").includes(t))return e}return null}(o,r);e?e.click():Date.now()<i&&setTimeout(a,100)};a()},!0);const Sr=window.wp.compose,{__:Nr}=wp.i18n,jr=["fluentcrm/conditional-group","fluent-crm/conditional-content"];(0,o.addFilter)("blocks.registerBlockType","fluentcrm/conditional-visibility",(e,t)=>jr.includes(t)?e:{...e,attributes:{...e.attributes,fcrmConditionType:{type:"string",default:""},fcrmTagIds:{type:"array",default:[]}}});const Mr=(0,Sr.createHigherOrderComponent)(e=>t=>{if(jr.includes(t.name))return(0,a.jsx)(e,{...t});const{attributes:n,setAttributes:o}=t,{fcrmConditionType:r,fcrmTagIds:s}=n,l=!!r,c=fo(),[d,u]=(0,i.useState)(mo()),[m,p]=(0,i.useState)(!1);(0,i.useEffect)(()=>{l&&!d.length&&po(u,p)},[l]);const f=(0,i.useMemo)(()=>Array.isArray(s)?s.map(e=>String(e)):[],[s]),g=(0,i.useMemo)(()=>{const e={};return d.forEach(t=>{e[t.id]=t.title}),e},[d]),h=(0,i.useMemo)(()=>{const e={};return d.forEach(t=>{e[t.title]=t.id}),e},[d]),y=(0,i.useMemo)(()=>f.map(e=>g[e]||e),[f,g]),_=(0,i.useMemo)(()=>d.map(e=>e.title),[d]),I=Nr("show_if_tag_not_exist"===r?"Hidden from subscribers with any selected tag.":"Shown to subscribers with any selected tag.","fluent-crm");return(0,a.jsxs)(i.Fragment,{children:[(0,a.jsx)(e,{...t}),(0,a.jsx)(v.InspectorControls,{children:(0,a.jsx)(go.PanelBody,{title:Nr("Conditional Visibility","fluent-crm"),initialOpen:l,children:c?(0,a.jsxs)(i.Fragment,{children:[(0,a.jsx)(go.ToggleControl,{__nextHasNoMarginBottom:!0,label:Nr("Enable conditional visibility","fluent-crm"),checked:l,onChange:e=>{o(e?{fcrmConditionType:"show_if_tag_exist"}:{fcrmConditionType:"",fcrmTagIds:[]})}}),l&&(0,a.jsxs)(i.Fragment,{children:[(0,a.jsx)(go.SelectControl,{__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0,label:Nr("Condition Type","fluent-crm"),value:r,onChange:e=>o({fcrmConditionType:e||"show_if_tag_exist"}),options:[{value:"show_if_tag_exist",label:Nr("Show if in selected tags","fluent-crm")},{value:"show_if_tag_not_exist",label:Nr("Show if not in selected tags","fluent-crm")}]}),m?(0,a.jsx)(go.Spinner,{}):(0,a.jsx)(go.FormTokenField,{label:Nr("Tags","fluent-crm"),value:y,suggestions:_,onChange:e=>{const t=e.map(e=>h[e]).filter(Boolean);o({fcrmTagIds:t})},__experimentalExpandOnFocus:!0,__experimentalAutoSelectFirstMatch:!0,__experimentalShowHowTo:!1,__next40pxDefaultSize:!0}),(0,a.jsx)("p",{className:"components-base-control__help",children:I})]})]}):(0,a.jsx)(go.Notice,{status:"warning",isDismissible:!1,children:Nr("Conditional visibility requires FluentCRM Pro.","fluent-crm")})})})]})},"withConditionalVisibility");(0,o.addFilter)("editor.BlockEdit","fluentcrm/conditional-visibility",Mr);const kr=(0,Sr.createHigherOrderComponent)(e=>t=>{if(t.attributes?.fcrmConditionType){const n=[t.className,"fcrm-has-condition"].filter(Boolean).join(" ");return(0,a.jsx)(e,{...t,className:n})}return(0,a.jsx)(e,{...t})},"withConditionalIndicator");(0,o.addFilter)("editor.BlockListBlock","fluentcrm/conditional-visibility-indicator",kr);const Tr=/^http:\/\/(\{\{[^{}\r\n]+}})$/i;const Er=(0,Sr.createHigherOrderComponent)(e=>t=>"core/button"!==t.name?(0,a.jsx)(e,{...t}):(0,a.jsx)(e,{...t,setAttributes:(e={})=>{t.setAttributes(function(e={}){if(!Object.prototype.hasOwnProperty.call(e,"url"))return e;const t=function(e){if("string"!=typeof e)return e;const t=e.trim().match(Tr);return t?t[1]:e}(e.url);return t===e.url?e:{...e,url:t}}(e))}}),"withSmartcodeButtonUrlGuard");(0,o.addFilter)("editor.BlockEdit","fluentcrm/smartcode-button-url-guard",Er);const Dr=window.wp.primitives;var Ar=(0,a.jsxs)(Dr.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,a.jsx)(Dr.Path,{d:"m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z"}),(0,a.jsx)(Dr.Path,{d:"m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z"})]}),Lr=(0,a.jsx)(Dr.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,a.jsx)(Dr.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"})}),Pr=(0,a.jsx)(Dr.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,a.jsx)(Dr.Path,{d:"M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z"})});const Br={SystemUi:"-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'",Arial:"Arial, 'Helvetica Neue', Helvetica, sans-serif","Comic Sans":"'Comic Sans MS', 'Marker Felt-Thin', Arial, sans-serif","Courier New":"'Courier New', Courier, 'Lucida Sans Typewriter', 'Lucida Typewriter', monospace",Georgia:"Georgia, Times, 'Times New Roman', serif",Helvetica:"Helvetica , Arial, Verdana, sans-serif",Lucida:"'Lucida Sans Unicode', 'Lucida Grande', sans-serif",Tahoma:"Tahoma, Verdana, Segoe, sans-serif","Times New Roman":"'Times New Roman', Times, Baskerville, Georgia, serif","Trebuchet MS":"'Trebuchet MS', 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Tahoma, sans-serif",Verdana:"Verdana, Geneva, sans-serif",Lato:"'Lato', 'Helvetica Neue', Helvetica, Arial, sans-serif",Lora:"'Lora', Georgia, 'Times New Roman', serif",Merriweather:"'Merriweather', Georgia, 'Times New Roman', serif","Merriweather Sans":"'Merriweather Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif","Noticia Text":"'Noticia Text', Georgia, 'Times New Roman', serif","Open Sans":"'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif",Roboto:"'Roboto', 'Helvetica Neue', Helvetica, Arial, sans-serif","Source Sans Pro":"'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif'"},Rr=Object.entries(Br).map(([e,t])=>({label:e,value:t})),zr=()=>{const e=window.fcrmBlockEditorConfig?.fontSizes;return Array.isArray(e)&&e.length?e.map(e=>({...e,size:parseInt(e.size,10)||e.size})):[{name:"Small",slug:"fc-small",size:13},{name:"Regular",slug:"fc-regular",size:16},{name:"Medium",slug:"fc-medium",size:18},{name:"Large",slug:"fc-large",size:26},{name:"Extra Large",slug:"fc-x-large",size:32}]},Hr={content_width:700,content_border_radius:"0px",content_padding_top:"20px",content_padding_right:"20px",content_padding_bottom:"20px",content_padding_left:"20px",content_margin_top:"20px",content_margin_bottom:"20px",body_bg_color:"#FAFAFA",content_bg_color:"#FFFFFF",headings_font_family:Br.SystemUi,headings_color:"#202020",content_font_family:Br.SystemUi,text_color:"#202020",link_color:"#0693e3",paragraph_font_size:"",paragraph_line_height:"",design_template:""},Or=e=>{if(void 0!==e.content_padding_top)return e;const t=(parseInt(e.content_padding,10)||20)+"px";return{...e,content_padding_top:t,content_padding_right:t,content_padding_bottom:t,content_padding_left:t}},Fr=(e,t)=>{if(!e)return t;const n=(()=>{const e=window.fcrmBlockEditorConfig?.spacingPresets;if(Array.isArray(e)&&e.length){const t={};return e.forEach(e=>{t[e.slug]=e.size}),t}return{"fc-xx-small":"5px","fc-x-small":"10px","fc-small":"14px","fc-medium":"20px","fc-large":"30px","fc-x-large":"45px","fc-xx-large":"60px"}})(),o=String(e).match(/^var:preset\|spacing\|(.+)$/);return o&&n[o[1]]?n[o[1]]:String(e).match(/[a-z%]+$/i)?e:e+"px"},Ur=new WeakMap,Gr=["--fcrm-content-width","--fcrm-content-radius","--fcrm-padding-top","--fcrm-padding-right","--fcrm-padding-bottom","--fcrm-padding-left","--fcrm-margin-top","--fcrm-margin-bottom","--fcrm-body-bg","--fcrm-content-bg","--fcrm-headings-color","--theme-text-color","--fcrm-link-color","--fcrm-headings-font","--theme-font-family","--theme-font-size","--theme-line-height"],Zr=e=>{e&&e.style&&Gr.forEach(t=>{e.style.removeProperty(t)})},Vr=(e,t)=>{if(!e)return!1;const n=e.getElementById("fcrm-dynamic-email-styles");n&&n.remove();const o=e.querySelector(".editor-styles-wrapper"),r=e.querySelector(".block-editor-block-canvas")||o;if(!r)return!1;const i=Ur.get(e);i&&i!==r&&Zr(i),Zr(r);for(const[e,n]of Object.entries(t))r.style.setProperty(e,n);return o&&o!==r&&Zr(o),Ur.set(e,r),!0},Wr="fcrm:style-config-sync",Qr=(e,t)=>{e&&e.body&&e.body.setAttribute("data-design-template",t)},Yr=()=>{if(window._fcrmStyleConfig)return Or({...Hr,...window._fcrmStyleConfig});const e=window.fcrmEditorBoot||{};return Or({...Hr,...e.template_config||{}})},Jr=e=>{window._fcrmStyleConfig=e},$r=({onLayoutChange:e,showLayoutSelector:t=!0})=>{const[n,o]=(0,i.useState)(Yr),r=(0,i.useRef)(null);(0,i.useEffect)(()=>{const e=e=>{if(!e||"object"!=typeof e)return;const t=Or(e);o(e=>{const n={...e,...t};return Jr(n),n})};e(window._fcrmStyleConfig);const t=Ho(zo,t=>{e(t.template_config)}),n=t=>{e(t?.detail?.template_config)};return window.addEventListener(Wr,n),()=>{t(),window.removeEventListener(Wr,n)}},[]),(0,i.useEffect)(()=>(window._fcrmApplyDesignPreset=e=>{const t=window._fcrmStyleConfig||{},n=Or({...t,...e});o(n),Jr(n),s(n)},()=>{delete window._fcrmApplyDesignPreset}),[]),(0,i.useEffect)(()=>{const e=(e=>{const t={};return t["--fcrm-content-width"]=`${parseInt(e.content_width,10)||700}px`,t["--fcrm-content-radius"]=e.content_border_radius||"0px",t["--fcrm-padding-top"]=e.content_padding_top||"20px",t["--fcrm-padding-right"]=e.content_padding_right||"20px",t["--fcrm-padding-bottom"]=e.content_padding_bottom||"20px",t["--fcrm-padding-left"]=e.content_padding_left||"20px",t["--fcrm-margin-top"]=e.content_margin_top||"20px",t["--fcrm-margin-bottom"]=e.content_margin_bottom||"20px",e.body_bg_color&&(t["--fcrm-body-bg"]=e.body_bg_color),e.content_bg_color&&(t["--fcrm-content-bg"]=e.content_bg_color),e.headings_color&&(t["--fcrm-headings-color"]=e.headings_color),e.text_color&&(t["--theme-text-color"]=e.text_color),e.link_color&&(t["--fcrm-link-color"]=e.link_color),e.headings_font_family&&(t["--fcrm-headings-font"]=e.headings_font_family),e.content_font_family&&(t["--theme-font-family"]=e.content_font_family),e.paragraph_font_size&&(t["--theme-font-size"]=e.paragraph_font_size),e.paragraph_line_height&&(t["--theme-line-height"]=e.paragraph_line_height),t})(n),t=n.design_template||"";let o=0,r=null,i=!1;const a=document.querySelector('iframe[name="editor-canvas"]'),s=()=>{if(i)return;o+=1;const n=((e,t)=>{Vr(document,e),Qr(document,t);const n=(()=>{try{const e=document.querySelector('iframe[name="editor-canvas"]');if(e&&e.contentDocument)return e.contentDocument}catch(e){}return null})();if(!n)return!1;const o=Vr(n,e);return Qr(n,t),o})(e,t);o<30&&(o<5||!n)&&(r=setTimeout(s,150))};s();const l=()=>{r&&(clearTimeout(r),r=null),o=0,s()};return a&&a.addEventListener("load",l),()=>{i=!0,r&&clearTimeout(r),a&&a.removeEventListener("load",l)}},[n]);const s=(0,i.useCallback)(e=>{r.current&&clearTimeout(r.current),r.current=setTimeout(()=>{const t=JSON.parse(JSON.stringify(e));Bo(Lo.STYLE_CONFIG_CHANGE,{template_config:t})},200)},[]),l=(0,i.useCallback)((e,t)=>{o(n=>{const o={...n,[e]:t};return Jr(o),s(o),o})},[s]),c=(0,i.useCallback)(e=>{o(t=>{const n={...t,...e};return Jr(n),s(n),n})},[s]);return(0,a.jsxs)("div",{className:"fcrm-email-style-settings",children:[(0,a.jsxs)(go.PanelBody,{title:t?"Layout":"Style",initialOpen:!0,className:"fcrm-style-panel",children:[(0,a.jsx)(v.PanelColorSettings,{__experimentalIsRenderedInSidebar:!0,title:"Global Colors",initialOpen:!1,className:"fcrm-sub-panel",colorSettings:[{value:n.body_bg_color||void 0,onChange:e=>l("body_bg_color",e||""),label:"Body Background",clearable:!0},{value:n.content_bg_color||void 0,onChange:e=>l("content_bg_color",e||""),label:"Content Background",clearable:!0},{value:n.headings_color||void 0,onChange:e=>l("headings_color",e||""),label:"Headings",clearable:!0},{value:n.text_color||void 0,onChange:e=>l("text_color",e||""),label:"Text",clearable:!0},{value:n.link_color||void 0,onChange:e=>l("link_color",e||""),label:(0,x.__)("Links","fluent-crm"),clearable:!0}]}),(0,a.jsx)(go.RangeControl,{label:"Max Width",className:"fcrm-sub-panel",value:parseInt(n.content_width,10)||700,onChange:e=>l("content_width",e),min:400,max:900,step:10,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,a.jsx)(go.RangeControl,{label:"Content Border Radius",className:"fcrm-sub-panel",value:parseInt(n.content_border_radius,10)||0,onChange:e=>l("content_border_radius",`${parseInt(e,10)||0}px`),min:0,max:80,step:1,__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0}),(0,a.jsx)(v.__experimentalSpacingSizesControl,{label:"Content Padding",className:"fcrm-sub-panel",values:{top:n.content_padding_top||"20px",right:n.content_padding_right||"20px",bottom:n.content_padding_bottom||"20px",left:n.content_padding_left||"20px"},onChange:e=>{c({content_padding_top:Fr(e.top,"20px"),content_padding_right:Fr(e.right,"20px"),content_padding_bottom:Fr(e.bottom,"20px"),content_padding_left:Fr(e.left,"20px")})},sides:["top","right","bottom","left"]}),(0,a.jsx)(v.__experimentalSpacingSizesControl,{label:"Content Margin",className:"fcrm-sub-panel",values:{top:n.content_margin_top||"20px",bottom:n.content_margin_bottom||"20px"},onChange:e=>{c({content_margin_top:Fr(e.top,"20px"),content_margin_bottom:Fr(e.bottom,"20px")})},sides:["top","bottom"]})]}),(0,a.jsxs)(go.PanelBody,{title:"Typography",initialOpen:!1,className:"fcrm-style-panel",children:[(0,a.jsxs)(go.__experimentalVStack,{spacing:4,children:[(0,a.jsx)(go.__experimentalText,{variant:"muted",upperCase:!0,size:11,weight:500,children:"Content"}),(0,a.jsx)(go.SelectControl,{label:"Font Family",value:n.content_font_family||Br.SystemUi,options:Rr,onChange:e=>l("content_font_family",e),__nextHasNoMarginBottom:!0}),(0,a.jsx)(go.FontSizePicker,{fontSizes:zr(),value:n.paragraph_font_size?parseInt(n.paragraph_font_size,10):void 0,onChange:e=>l("paragraph_font_size",e?e+"px":""),withReset:!1,__nextHasNoMarginBottom:!0}),(0,a.jsx)(v.LineHeightControl,{value:n.paragraph_line_height||"",onChange:e=>l("paragraph_line_height",e||""),__nextHasNoMarginBottom:!0,__unstableInputWidth:"auto"})]}),(0,a.jsxs)(go.__experimentalVStack,{spacing:4,className:"fcrm-typo-section",children:[(0,a.jsx)(go.__experimentalText,{variant:"muted",upperCase:!0,size:11,weight:500,children:"Headings"}),(0,a.jsx)(go.SelectControl,{label:"Font Family",value:n.headings_font_family||Br.SystemUi,options:Rr,onChange:e=>l("headings_font_family",e),__nextHasNoMarginBottom:!0})]})]})]})},qr=({title:e,items:t=[],copied:n,onCopy:o,searchQuery:r=""})=>{const i=r.trim().toLowerCase(),s=i?t.filter(e=>(e.code||"").toLowerCase().includes(i)||(e.label||"").toLowerCase().includes(i)):t;return s.length?(0,a.jsxs)("div",{className:"fcrm-smartcode-group",children:[(0,a.jsx)("h4",{className:"fcrm-smartcode-group__title",children:e}),(0,a.jsx)("ul",{className:"fcrm-smartcode-group__list",children:s.map(e=>(0,a.jsxs)("li",{className:"fcrm-smartcode-group__item",children:[(0,a.jsxs)("div",{className:"fcrm-smartcode-group__row",children:[(0,a.jsx)("code",{className:"fcrm-smartcode-group__code",onClick:()=>o(e.code),title:"Click to copy",children:e.code}),(0,a.jsx)("button",{onClick:()=>o(e.code),className:"fcrm-smartcode-group__copy-btn"+(n===e.code?" is-copied":""),"aria-label":`Copy ${e.code}`,children:n===e.code?"Copied":"Copy"})]}),(0,a.jsx)("div",{className:"fcrm-smartcode-group__label",children:e.label})]},e.code))})]}):null},Kr=({activeDesign:e,onDesignChange:t})=>{const n=(window.fcrmBlockEditorConfig||{}).designTemplatePresets||{},o=Object.values(n);return o.length?(0,a.jsx)("div",{className:"fcrm-design-presets",children:(0,a.jsx)("div",{className:"fcrm-design-presets__grid",children:o.map(n=>(0,a.jsxs)("button",{type:"button",className:"fcrm-design-presets__item"+(e===n.id?" is-selected":""),onClick:()=>(e=>{const n=e.config.design_template||"";window._fcrmApplyDesignPreset&&window._fcrmApplyDesignPreset(e.config),n&&Bo(Lo.LAYOUT_CHANGE,{design_template:n}),t&&t(n)})(n),children:[(0,a.jsx)("span",{className:"fcrm-design-presets__thumb",children:n.image?(0,a.jsx)("img",{src:n.image,alt:n.label}):(0,a.jsx)("span",{className:"fcrm-design-presets__placeholder"})}),(0,a.jsx)("span",{className:"fcrm-design-presets__label",children:n.label})]},n.id))})}):(0,a.jsx)("p",{className:"fcrm-design-presets__empty",children:"No design presets available."})},Xr=[{key:"contact",title:"Contact",shortcodes:{"{{contact.first_name}}":"First Name","{{contact.last_name}}":"Last Name","{{contact.email}}":"Email","{{contact.full_name}}":"Full Name"}},{key:"user",title:"User",shortcodes:{"{{user.display_name|fallback}}":"User's Display Name","{{user.user_email|fallback}}":"User's Email","{{user.photo_html.50px}}":"User Photo HTML (50px)"}},{key:"wp",title:"WP",shortcodes:{"{{site.title}}":"Site Title","{{wp.url}}":"Site URL","{{crm.unsubscribe_url}}":"Unsubscribe URL","{{crm.unsubscribe_html|Unsubscribe}}":"Unsubscribe Link (HTML)","{{crm.business_name}}":"Business Name","{{crm.business_address}}":"Business Address"}}],ei=()=>{const e=[...window.fcAdmin?.globalSmartCodes||[],...window.fcAdmin?.extendedSmartCodes||[],...window.fcrm_funnel_context_codes||[]],t={};return(e.length?e:Xr).forEach((e,n)=>{const o=e?.key||`group_${n}`,r=(i=e?.title,a=o,String(i||"").trim()||String(a||"").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()));var i,a;const s=function(e){return e&&"object"==typeof e?Object.entries(e).reduce((e,[t,n])=>{const o=String(t||"").trim();return o?(e[o]=String(n||o),e):e},{}):{}}(e?.shortcodes);Object.keys(s).length&&(t[o]||(t[o]={key:o,title:r,shortcodes:{}}),t[o].shortcodes={...t[o].shortcodes,...s})}),Object.values(t).map(e=>({key:e.key,title:e.title,items:Object.entries(e.shortcodes).map(([e,t])=>({code:e,label:t}))}))},ti="fcrm-context-smartcodes-updated",ni=[{name:"styles",title:(0,a.jsx)(go.Icon,{icon:Ar,size:24}),className:"fcrm-sidebar-tab-styles"},{name:"presets",title:(0,a.jsx)(go.Icon,{icon:Lr,size:24}),className:"fcrm-sidebar-tab-presets"},{name:"smartcodes",title:(0,a.jsx)(go.Icon,{icon:Pr,size:24}),className:"fcrm-sidebar-tab-smartcodes"}],oi=()=>{const[e,t]=(0,i.useState)([]),[n,o]=(0,i.useState)(null),[r,s]=(0,i.useState)("styles"),[l,c]=(0,i.useState)(""),d=window.fcrmEditorBoot||{},[u,m]=(0,i.useState)(d.template_config?.design_template||""),p=!1!==d.enable_templates,f=!1!==d.enable_template_save;(0,i.useEffect)(()=>{t(ei());const e=()=>{t(ei())};return window.addEventListener(ti,e),()=>{window.removeEventListener(ti,e)}},[]);const g=l.trim().toLowerCase(),h=!g||e.some(e=>(e.items||[]).some(e=>(e.code||"").toLowerCase().includes(g)||(e.label||"").toLowerCase().includes(g))),y=e=>{navigator.clipboard.writeText(e).then(()=>{o(e),setTimeout(()=>o(null),1800)}).catch(()=>{})};return(0,a.jsxs)("div",{className:"fcrm-smartcode-examples-panel plugin-sidebar-content",children:[(0,a.jsxs)("div",{className:"fcrm-template-buttons",children:[p&&(0,a.jsx)(go.Button,{variant:"secondary",className:"fcrm_secondary_btn",onClick:()=>Bo(Lo.OPEN_TEMPLATES),icon:"category",children:"Import / Use templates"}),f&&(0,a.jsx)(go.Button,{variant:"secondary",className:"fcrm_secondary_btn",onClick:()=>Bo(Lo.OPEN_SAVE_TEMPLATE),icon:"plus-alt2",children:"Save as template"})]}),(0,a.jsx)(go.TabPanel,{className:"fcrm-sidebar-tabs",tabs:ni,initialTabName:"styles",onSelect:s,children:()=>null}),(0,a.jsx)("div",{style:{display:"styles"===r?"block":"none"},children:(0,a.jsx)($r,{showLayoutSelector:!1})}),"presets"===r&&(0,a.jsx)(Kr,{activeDesign:u,onDesignChange:m}),"smartcodes"===r&&(0,a.jsxs)("div",{className:"fcrm-smartcodes-tab",children:[(0,a.jsxs)("p",{className:"fcrm-smartcode-tip",children:["Tip: Type ",(0,a.jsx)("code",{children:"@"})," in the editor to open Smartcode autocomplete, then keep typing to filter and press Enter to insert.  Or copy any smartcode below and paste into your content."]}),(0,a.jsx)("input",{type:"search",className:"fcrm-smartcode-group__search",placeholder:"Search smartcodes...",value:l,onChange:e=>c(e.target.value),"aria-label":"Search smartcodes"}),e.map(e=>(0,a.jsx)(qr,{title:`${e.title} Smartcodes`,items:e.items,copied:n,onCopy:y,searchQuery:l},e.key)),!h&&(0,a.jsx)("p",{className:"fcrm-smartcode-group__empty",children:"No smartcodes found."})]})]})},ri="fcrm-context-smartcodes-updated";function ii(){const e=[...window.fcAdmin?.globalSmartCodes||[],...window.fcAdmin?.extendedSmartCodes||[],...window.fcrm_funnel_context_codes||[]],t={};return e.forEach((e,n)=>{const o=e?.key||`group_${n}`,r=(i=e?.title,a=o,String(i||"").trim()||String(a||"").replace(/[_-]+/g," ").replace(/\s+/g," ").trim().replace(/\b\w/g,e=>e.toUpperCase()));var i,a;const s=function(e){return e&&"object"==typeof e?Object.entries(e).reduce((e,[t,n])=>{const o=String(t||"").trim();return o?(e[o]=String(n||o),e):e},{}):{}}(e?.shortcodes);Object.keys(s).length&&(t[o]||(t[o]={key:o,title:r,shortcodes:{}}),t[o].shortcodes={...t[o].shortcodes,...s})}),Object.values(t)}const ai=({anchor:e,onClose:t,onSelect:n,showLearnMore:o=!0,feedbackMessage:r=""})=>{const[s,l]=(0,i.useState)(()=>ii()),[c,d]=(0,i.useState)(()=>ii()[0]?.key||""),[u,m]=(0,i.useState)("");if((0,i.useEffect)(()=>{const e=()=>{const e=ii();l(e),d(t=>t||e[0]?.key||"")};return window.addEventListener(ri,e),()=>window.removeEventListener(ri,e)},[]),(0,i.useEffect)(()=>{!c&&s[0]&&d(s[0].key)},[s,c]),!s.length)return null;const p=s.find(e=>e.key===c)||s[0],f=u.trim().toLowerCase(),g=Object.entries(p.shortcodes||{}).filter(([e,t])=>!f||e.toLowerCase().includes(f)||String(t).toLowerCase().includes(f));return(0,a.jsx)(go.Popover,{className:"fcrm-smartcode-toolbar-popover",anchor:e,placement:"bottom-end",onClose:t,focusOnMount:!1,children:(0,a.jsxs)("div",{className:"fcrm-smartcode-toolbar-popover__wrap",children:[(0,a.jsxs)("aside",{className:"fcrm-smartcode-toolbar-popover__sidebar",children:[(0,a.jsx)("div",{className:"fcrm-smartcode-toolbar-popover__tabs",children:s.map(e=>(0,a.jsx)("button",{type:"button",className:"fcrm-smartcode-toolbar-popover__tab"+(e.key===p.key?" is-active":""),onClick:()=>d(e.key),children:e.title},e.key))}),o&&(0,a.jsx)(go.Button,{variant:"secondary",className:"fcrm-smartcode-toolbar-popover__doc-btn",onClick:()=>window.open("https://fluentcrm.com/docs/merge-codes-smart-codes-usage/","_blank","noopener"),children:(0,x.__)("Learn More","fluent-crm")})]}),(0,a.jsxs)("section",{className:"fcrm-smartcode-toolbar-popover__body",children:[(0,a.jsx)("div",{className:"fcrm-smartcode-toolbar-popover__search",children:(0,a.jsx)(go.TextControl,{value:u,onChange:m,placeholder:(0,x.__)("Search shortcodes...","fluent-crm"),__next40pxDefaultSize:!0,__nextHasNoMarginBottom:!0})}),!!r&&(0,a.jsx)("div",{className:"fcrm-smartcode-toolbar-popover__feedback",children:r}),(0,a.jsxs)("div",{className:"fcrm-smartcode-toolbar-popover__items",children:[g.map(([e,t])=>(0,a.jsxs)("button",{type:"button",className:"fcrm-smartcode-toolbar-popover__item",onClick:()=>n(e),title:(0,x.__)("Click to insert shortcode","fluent-crm"),children:[(0,a.jsx)("span",{className:"fcrm-smartcode-toolbar-popover__item-label",children:t}),(0,a.jsx)("span",{className:"fcrm-smartcode-toolbar-popover__item-code",children:e})]},e)),!g.length&&(0,a.jsx)("div",{className:"fcrm-smartcode-toolbar-popover__empty",children:(0,x.__)("No shortcodes found for this search.","fluent-crm")})]})]})]})})},si=["content","text","value","caption"];function li(e){const t=(0,n.select)("core/block-editor"),o=(0,n.dispatch)("core/block-editor");if(!t||!o||"function"!=typeof t.getSelectedBlockClientId)return!1;const r=t.getSelectedBlockClientId();if(!r)return!1;const i=t.getBlock(r);if(!i||!i.attributes||"function"!=typeof o.updateBlockAttributes)return!1;const a=si.find(e=>"string"==typeof i.attributes[e]);if(!a)return!1;const s=i.attributes[a]||"";return o.updateBlockAttributes(r,{[a]:`${s}${e}`}),!0}function ci(e){return String(e||"").replace(/[-_]/g," ").replace(/\b\w/g,e=>e.toUpperCase())}function di(e,t){if(!e||"object"!=typeof e)return null;const n=String(e.name||`pattern-${t+1}`).trim(),o=n.includes("/")?n:`fluentcrm/${n}`,r=String(e.content||"").trim();if(!o||!r)return null;const i=Array.isArray(e.categories)?e.categories.filter(Boolean).map(e=>String(e)):e.category?[String(e.category)]:[];return{name:o,title:String(e.title||o),content:r,description:e.description?String(e.description):void 0,keywords:Array.isArray(e.keywords)?e.keywords:void 0,blockTypes:Array.isArray(e.blockTypes)?e.blockTypes:void 0,postTypes:Array.isArray(e.postTypes)?e.postTypes:void 0,templateTypes:Array.isArray(e.templateTypes)?e.templateTypes:void 0,viewportWidth:Number(e.viewportWidth)||void 0,categories:i}}function ui(){const e=(window.fcrmEditorBoot||{}).patterns||{};return{unregisterAll:!1!==e.unregister_all,normalizedPatterns:(Array.isArray(e.custom)?e.custom:[]).map((e,t)=>di(e,t)).filter(Boolean),normalizedCategories:(Array.isArray(e.categories)?e.categories:[]).map((e,t)=>function(e,t){if(!e||"object"!=typeof e)return null;const n=String(e.name||`fcrm-category-${t+1}`).trim();return n?{name:n,label:String(e.label||ci(n)),description:e.description?String(e.description):""}:null}(e,t)).filter(Boolean)}}function mi(e=[],t={}){const n=!1!==t.unregisterAll,o=function(e=[]){const t=new Map;return e.forEach(e=>{e&&"object"==typeof e&&e.name&&t.set(String(e.name),{label:e.label?String(e.label):"",description:e.description?String(e.description):""})}),t}(t.categories||[]);return n&&function(){try{(0,r.getBlockPatterns)().forEach(e=>{try{(0,r.unregisterBlockPattern)(e.name)}catch(e){}})}catch(e){}try{(0,r.getBlockPatternCategories)().forEach(e=>{try{(0,r.unregisterBlockPatternCategory)(e.name)}catch(e){}})}catch(e){}}(),e.forEach(e=>{(e.categories||[]).forEach(e=>function(e,t=new Map){if(!e)return;if((()=>{try{return(0,r.getBlockPatternCategories)().some(t=>t.name===e)}catch(e){return!1}})())return;const n=t.get(e)||{};try{(0,r.registerBlockPatternCategory)(e,{label:n.label||ci(e),description:n.description||""})}catch(e){}}(e,o));try{(0,r.unregisterBlockPattern)(e.name)}catch(e){}try{(0,r.registerBlockPattern)(e.name,{title:e.title,content:e.content,categories:e.categories,description:e.description,keywords:e.keywords,blockTypes:e.blockTypes,postTypes:e.postTypes,templateTypes:e.templateTypes,viewportWidth:e.viewportWidth})}catch(e){}}),e}function pi(e){return{name:e.name,title:e.title,content:e.content,description:e.description||"",viewport_width:e.viewportWidth||0,inserter:!0,categories:Array.isArray(e.categories)?e.categories:[],keywords:Array.isArray(e.keywords)?e.keywords:[],block_types:Array.isArray(e.blockTypes)?e.blockTypes:[],post_types:Array.isArray(e.postTypes)?e.postTypes:[],template_types:Array.isArray(e.templateTypes)?e.templateTypes:[],source:"plugin"}}let fi=!1;let gi=!1,hi=null,yi=null,_i=null,Ii=null,bi=new Set,wi=new Set;function xi(){const{unregisterAll:e,normalizedPatterns:t,normalizedCategories:n}=ui(),o=mi(t,{unregisterAll:e,categories:n}),i=new Set(o.map(e=>String(e.name))),a=new Set(n.map(e=>e&&e.name?String(e.name):"").filter(Boolean));o.forEach(e=>{(e.categories||[]).forEach(e=>{e&&a.add(String(e))})}),function(e=[],t=[],n=!0){if(!n)return;const o=window.wp&&window.wp.blocks;o&&(bi=new Set(Array.from(e||[]).map(e=>String(e))),wi=new Set(Array.from(t||[]).map(e=>String(e))),gi||(gi=!0,hi=o.registerBlockPattern,yi=o.registerBlockPatternCategory,o.registerBlockPattern=function(e,t){const n=String(e||"");return bi.has(n)?hi.call(this,n,t):null},o.registerBlockPatternCategory=function(e,t){const n=String(e||"");return wi.has(n)?yi.call(this,n,t):null}))}(i,a,e),function(e=[],t=[],n=!0){if(!n)return;const o=window.wp&&window.wp.blocks;if(!o)return;const r=new Set(Array.from(e||[]).map(e=>String(e))),i=new Set(Array.from(t||[]).map(e=>String(e)));_i||"function"!=typeof o.getBlockPatterns||(_i=o.getBlockPatterns),Ii||"function"!=typeof o.getBlockPatternCategories||(Ii=o.getBlockPatternCategories),_i&&(o.getBlockPatterns=function(...e){return(_i.apply(this,e)||[]).filter(e=>r.has(String(e?.name||"")))}),Ii&&(o.getBlockPatternCategories=function(...e){return(Ii.apply(this,e)||[]).filter(e=>i.has(String(e?.name||"")))})}(i,a,e),function(e=new Set,t=new Set,n=!0){if(n){try{(0,r.getBlockPatterns)().forEach(t=>{if(!e.has(String(t.name||"")))try{(0,r.unregisterBlockPattern)(t.name)}catch(e){}})}catch(e){}try{(0,r.getBlockPatternCategories)().forEach(e=>{if(!t.has(String(e.name||"")))try{(0,r.unregisterBlockPatternCategory)(e.name)}catch(e){}})}catch(e){}}}(i,a,e)}let vi=[],Ci=null,Si=!1;function Ni(){vi.forEach(e=>clearTimeout(e)),vi=[],Ci&&(clearInterval(Ci),Ci=null)}const ji=(0,Sr.createHigherOrderComponent)(e=>t=>{const n=(window.fcrmEditorBoot||{}).features||{};return"core/block"!==t.name||!1===n.create_pattern?(0,a.jsx)(e,{...t}):(0,a.jsxs)(i.Fragment,{children:[(0,a.jsx)(e,{...t}),(0,a.jsx)(v.BlockControls,{group:"other",children:(0,a.jsx)(go.ToolbarGroup,{children:(0,a.jsx)(go.ToolbarButton,{icon:"editor-unlink",label:(0,x.__)("Detach pattern","fluent-crm"),onClick:()=>{const e=t.clientId,n=wp.data.dispatch("core/reusable-blocks");if(n&&n.__experimentalConvertBlockToStatic)n.__experimentalConvertBlockToStatic(e);else{const t=wp.data.select(v.store).getBlock(e);if(!t)return;const n=t.attributes.ref,o=wp.data.select("core").getEditedEntityRecord("postType","wp_block",n);if(o&&o.content){const t="function"==typeof o.content?o.content(o):o.content,n=wp.blocks.parse(t);wp.data.dispatch(v.store).replaceBlocks(e,n)}}},children:(0,x.__)("Detach","fluent-crm")})})})]})},"withDetachToolbarButton");(0,o.addFilter)("editor.BlockEdit","fluentcrm/detach-toolbar-button",ji);const Mi="fcrm-footer-preview",ki="fcrm-footer-preview-styles",Ti=()=>window._fcrmFooterSettings||null,Ei=()=>(window.fcrmEditorBoot||{}).global_email_footer||"",Di=e=>{if(!e)return 20;const t=e.footer_padding,n=parseInt(t,10);return!Number.isNaN(n)&&n>=0?Math.min(n,80):20},Ai=e=>{if(!e)return;const t=e.getElementById(Mi);t&&t.remove();const n=e.getElementById(ki);n&&n.remove()},Li=e=>{if(!e)return;const t=Ti();if(!t)return void Ai(e);const n="yes"===t.disable_footer,o=n?"Email footer is disabled":(()=>{const e=Ti();return e?"yes"===e.custom_footer&&e.footer_content?e.footer_content:Ei():""})();if(!o&&!n)return void Ai(e);const r=e.querySelector(".editor-styles-wrapper");if(!r)return;const i=e.head||e.querySelector("head");if(i){let t=e.getElementById(ki);t||(t=e.createElement("style"),t.id=ki,i.appendChild(t)),t.textContent=(e=>{const t=Ti(),n=(t?.font_size||"14")+"px",o=t?.font_color||"#9ca3af",r=t?.background_color||"transparent",i=Di(t);return e?`\n#${Mi} {\n padding: 14px var(--fcrm-padding-right, 20px) 14px var(--fcrm-padding-left, 20px);\n cursor: pointer;\n transition: background-color 0.15s ease;\n user-select: none;\n text-align: center;\n}\n#${Mi}:hover {\n background-color: rgba(0, 0, 0, 0.02);\n}\n#${Mi} .fcrm-footer-preview__content {\n font-size: 12px;\n line-height: 1.5;\n color: #d1d5db;\n font-style: italic;\n pointer-events: none;\n font-family: var(--theme-font-family, inherit);\n}`:`\n#${Mi} {\n padding: ${i}px;\n cursor: pointer;\n transition: background-color 0.15s ease;\n position: relative;\n user-select: none;\n background-color: ${r};\n}\n#${Mi}:hover {\n box-shadow: inset 0 0 0 9999px rgba(0, 0, 0, 0.03);\n}\n#${Mi}:hover::after {\n opacity: 1;\n}\n#${Mi}::after {\n content: 'Click to edit footer';\n position: absolute;\n top: 8px;\n right: 12px;\n font-size: 10px;\n color: #9ca3af;\n opacity: 0;\n transition: opacity 0.15s ease;\n pointer-events: none;\n}\n#${Mi} .fcrm-footer-preview__content {\n font-size: ${n};\n line-height: 1.5;\n color: ${o};\n text-align: center;\n pointer-events: none;\n font-family: var(--theme-font-family, inherit);\n}\n#${Mi} .fcrm-footer-preview__content a {\n color: ${o};\n text-decoration: underline;\n pointer-events: none;\n}\n#${Mi} .fcrm-footer-preview__content p {\n margin: 0 0 4px;\n color: ${o};\n}\n#${Mi} .fcrm-footer-preview__content img {\n max-width: 100%;\n height: auto;\n display: inline-block;\n vertical-align: middle;\n pointer-events: none;\n}`})(n)}let a=e.getElementById(Mi);if(!a){a=e.createElement("div"),a.id=Mi,a.setAttribute("role","button"),a.setAttribute("tabindex","0"),a.setAttribute("title","Click to edit email footer");const t=e.createElement("div");t.className="fcrm-footer-preview__content",a.appendChild(t),a.addEventListener("click",e=>{e.stopPropagation(),"function"==typeof window._fcrmOpenFooterSettings&&window._fcrmOpenFooterSettings()}),a.addEventListener("keydown",e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),"function"==typeof window._fcrmOpenFooterSettings&&window._fcrmOpenFooterSettings())}),r.appendChild(a)}const s=a.querySelector(".fcrm-footer-preview__content");s&&s.innerHTML!==o&&(s.innerHTML=o)},Pi=()=>{try{const e=document.querySelector('iframe[name="editor-canvas"]');if(e&&e.contentDocument)return e.contentDocument}catch(e){}return null},Bi=({value:e,onChange:t})=>{const n="fcrm-footer-content-editor",o=(0,i.useRef)(t);o.current=t;const[r,s]=(0,i.useState)(!1),l=(0,i.useRef)(null),[c,d]=(0,i.useState)("visual"),[u,m]=(0,i.useState)(e||""),p=(0,i.useRef)(u);p.current=u;const f=(0,i.useRef)(null),g=(0,i.useRef)(!1),h=(0,i.useCallback)(e=>"string"==typeof e?e:"",[]),y=(0,i.useCallback)(e=>{if("visual"===c){const t=window.tinymce?.get(n);t&&t.insertContent(e)}else{const t=f.current;if(t){const n=t.selectionStart,r=t.selectionEnd,i=u.slice(0,n)+e+u.slice(r);m(i),o.current(i),setTimeout(()=>{t.focus(),t.setSelectionRange(n+e.length,n+e.length)},0)}}s(!1)},[c,u]),_=(0,i.useCallback)(()=>{const e=window.tinymce?.get(n)?.getContent()??u;m(e),o.current(e),d("text")},[u]),I=(0,i.useCallback)(()=>{g.current=!0,d("visual")},[]);(0,i.useEffect)(()=>{if("text"!==c)return;const t=h(e);if(t===u)return;const n=f.current;"text"===c&&n&&document.activeElement===n||m(t)},[e,u,c,h]),(0,i.useEffect)(()=>{if("visual"!==c||!g.current)return;g.current=!1;const e=setTimeout(()=>{const e=window.tinymce?.get(n);if(e){const t=p.current;e.setContent(t),o.current(t)}},50);return()=>clearTimeout(e)},[c]);const b=(0,i.useCallback)((e,t)=>{const n=f.current;if(!n)return;const r=n.selectionStart,i=n.selectionEnd,a=u.slice(r,i),s=e+a+t,l=u.slice(0,r)+s+u.slice(i);m(l),o.current(l),setTimeout(()=>{n.focus();const t=a?r+s.length:r+e.length;n.setSelectionRange(t,t)},0)},[u]);return(0,i.useEffect)(()=>{let e=!1,t=null;const r=(i=0)=>{if(e)return;const a=window.tinymce?.get(n);a&&a.remove(),window.tinymce?window.tinymce.init({selector:`#${n}`,toolbar:"fontselect | bold italic link unlink insertimage | alignleft aligncenter alignright",height:200,menubar:!1,branding:!1,resize:!1,plugins:"link",font_formats:'System UI=-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;Arial=Arial, "Helvetica Neue", Helvetica, sans-serif;Comic Sans=Comic Sans MS, Marker Felt-Thin, Arial, sans-serif;Courier New=Courier New, Courier, Lucida Sans Typewriter, monospace;Georgia=Georgia, Times, Times New Roman, serif;Helvetica=Helvetica, Arial, Verdana, sans-serif;Lucida=Lucida Sans Unicode, Lucida Grande, sans-serif;Tahoma=Tahoma, Verdana, Segoe, sans-serif;Times New Roman=Times New Roman, Times, Baskerville, Georgia, serif;Trebuchet MS=Trebuchet MS, Lucida Grande, Lucida Sans Unicode, Lucida Sans, Tahoma, sans-serif;Verdana=Verdana, Geneva, sans-serif;Lato=Lato, Helvetica Neue, Helvetica, Arial, sans-serif;Lora=Lora, Georgia, Times New Roman, serif;Merriweather=Merriweather, Georgia, Times New Roman, serif;Merriweather Sans=Merriweather Sans, Helvetica Neue, Helvetica, Arial, sans-serif;Noticia Text=Noticia Text, Georgia, Times New Roman, serif;Open Sans=Open Sans, Helvetica Neue, Helvetica, Arial, sans-serif;Roboto=Roboto, Helvetica Neue, Helvetica, Arial, sans-serif;Source Sans Pro=Source Sans Pro, Helvetica Neue, Helvetica, Arial, sans-serif',formats:{alignleft:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div",styles:{textAlign:"left"},defaultBlock:"p"}],aligncenter:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div",styles:{textAlign:"center"},defaultBlock:"p"}],alignright:[{selector:"p,h1,h2,h3,h4,h5,h6,td,th,div",styles:{textAlign:"right"},defaultBlock:"p"}]},content_style:'body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 13px; line-height: 1.5; text-align: center; } img { max-width: 100%; height: auto; display: inline-block; vertical-align: middle; }',setup:e=>{e.on("input change keyup NodeChange",()=>{const t=e.getContent();o.current(t),m(t)}),e.addButton("insertimage",{icon:"image",tooltip:(0,x.__)("Insert Image","fluent-crm"),onclick:()=>{if(!window.wp||!window.wp.media)return;const t=window.wp.media({title:(0,x.__)("Select or Upload Image","fluent-crm"),button:{text:(0,x.__)("Use this image","fluent-crm")},multiple:!1,library:{type:"image"}});t.on("select",()=>{const n=t.state().get("selection").first().toJSON(),o=String(n.url||"").trim(),r=/^https?:\/\//i.test(o)?o:"";if(!r)return;const i=(n.alt||n.title||"").replace(/"/g,"&quot;"),a=parseInt(n.width,10),s=parseInt(n.height,10),l=a>0?` width="${a}"`:"",c=s>0?` height="${s}"`:"";e.insertContent(`<img src="${r}" alt="${i}"${l}${c} />`)}),t.open()}})}}):i<10&&(t=setTimeout(()=>r(i+1),300))},i=setTimeout(()=>r(0),150);return()=>{e=!0,clearTimeout(i),t&&clearTimeout(t);const o=window.tinymce?.get(n);o&&o.remove()}},[]),(0,a.jsxs)("div",{className:"fcrm-footer-tinymce-wrap",children:[(0,a.jsxs)("div",{className:"fcrm-footer-tinymce__header",children:[(0,a.jsx)("span",{className:"fcrm-footer-tinymce__label",children:(0,x.__)("Footer Content","fluent-crm")}),(0,a.jsxs)("div",{className:"fcrm-footer-editor-actions",children:[(0,a.jsxs)("button",{ref:l,type:"button",className:"components-button fcrm-footer-smartcode-btn",onClick:()=>s(e=>!e),children:[(0,x.__)("Shortcode","fluent-crm")," ",(0,a.jsx)("span",{"aria-hidden":"true",children:"▾"})]}),r&&l.current&&(0,a.jsx)(ai,{anchor:l.current,onSelect:y,onClose:()=>s(!1),showLearnMore:!1}),(0,a.jsx)("div",{className:"fcrm-footer-editor-toggle",children:(0,a.jsxs)("div",{className:"fcrm-footer-toggle-switch",children:[(0,a.jsx)("button",{type:"button",className:"visual"===c?"active":"",onClick:I,children:(0,x.__)("Visual","fluent-crm")}),(0,a.jsx)("button",{type:"button",className:"text"===c?"active":"",onClick:_,children:(0,x.__)("Text","fluent-crm")})]})})]})]}),(0,a.jsx)("div",{style:{display:"visual"===c?"":"none"},children:(0,a.jsx)("textarea",{id:n,defaultValue:e})}),"text"===c&&(0,a.jsxs)("div",{className:"fcrm-footer-text-mode",children:[(0,a.jsxs)("div",{className:"fcrm-footer-text-mode__quicktags",children:[(0,a.jsx)("button",{type:"button",onClick:()=>b("<strong>","</strong>"),children:(0,x.__)("Bold","fluent-crm")}),(0,a.jsx)("button",{type:"button",onClick:()=>b("<em>","</em>"),children:(0,x.__)("Italic","fluent-crm")}),(0,a.jsx)("button",{type:"button",onClick:()=>b('<a href="">',"</a>"),children:(0,x.__)("Link","fluent-crm")}),(0,a.jsx)("button",{type:"button",onClick:()=>b("<ul>\n<li>","</li>\n</ul>"),children:(0,x.__)("UL","fluent-crm")}),(0,a.jsx)("button",{type:"button",onClick:()=>b("<ol>\n<li>","</li>\n</ol>"),children:(0,x.__)("OL","fluent-crm")}),(0,a.jsx)("button",{type:"button",onClick:()=>b("<li>","</li>"),children:(0,x.__)("LI","fluent-crm")}),(0,a.jsx)("button",{type:"button",onClick:()=>b("<code>","</code>"),children:(0,x.__)("Code","fluent-crm")})]}),(0,a.jsx)("textarea",{ref:f,value:u,onChange:e=>{m(e.target.value),o.current(e.target.value)},className:"fcrm-footer-text-mode__textarea",rows:8})]})]})},Ri=()=>{const[e,t]=(0,i.useState)(!1),[n,o]=(0,i.useState)(()=>Ti());(0,i.useEffect)(()=>{const e=e=>{const t=e.data;if("FOOTER_SETTINGS_SYNC"===t?.action){const e=t.footer_settings||null;window._fcrmFooterSettings=e,o(e?{...e}:null)}};window.addEventListener("message",e);const t=window._fcrmFooterSettings;return t&&o({...t}),()=>window.removeEventListener("message",e)},[]),(0,i.useEffect)(()=>{if(n)return window._fcrmOpenFooterSettings=()=>t(!0),()=>{delete window._fcrmOpenFooterSettings};delete window._fcrmOpenFooterSettings},[!!n]),(0,i.useEffect)(()=>{let e=null,t=null,n=null;const o=setTimeout(()=>{Li(document);const e=Pi();e&&Li(e)},1e3);return e=new MutationObserver(()=>{n||(n=setTimeout(()=>{if(n=null,!Ti())return;const e=Pi();e&&!e.getElementById(Mi)&&Li(e),document.getElementById(Mi)||Li(document)},500))}),e.observe(document.body,{childList:!0,subtree:!0}),t=setInterval(()=>{const e=Pi();e&&(Li(e),clearInterval(t),t=null)},2e3),()=>{clearTimeout(o),n&&clearTimeout(n),e&&e.disconnect(),t&&clearInterval(t)}},[]),(0,i.useEffect)(()=>{n&&(window._fcrmFooterSettings=n),(()=>{Li(document);const e=Pi();e&&Li(e)})()},[n]);const r=(0,i.useCallback)((e,t)=>{o(n=>{if(!n)return n;const o={...n,[e]:t};return"custom_footer"!==e||"yes"!==t||n.footer_content||(o.footer_content=Ei()),Bo(Lo.FOOTER_SETTINGS_CHANGE,{footer_settings:o}),o})},[]);if(!n)return null;const s="yes"===n.disable_footer,l="yes"===n.custom_footer;return e?(0,a.jsx)(go.Modal,{title:"Email Footer",onRequestClose:()=>t(!1),className:"fcrm-footer-settings-modal",children:(0,a.jsxs)(go.__experimentalVStack,{spacing:4,className:"fcrm-footer-settings-modal__content",children:[(0,a.jsx)(go.ToggleControl,{label:"Show Email Footer",checked:!s,onChange:e=>r("disable_footer",e?"no":"yes"),__nextHasNoMarginBottom:!0}),!s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"fcrm-footer-settings__divider"}),(0,a.jsx)(go.RadioControl,{selected:n.custom_footer,options:[{label:"Global Footer",value:"no"},{label:"Custom Footer",value:"yes"}],onChange:e=>r("custom_footer",e)}),!l&&(0,a.jsx)("p",{className:"fcrm-footer-settings__hint",children:"Uses your default email footer from global settings."}),l&&(0,a.jsx)(Bi,{value:n.footer_content,onChange:e=>r("footer_content",e)}),(0,a.jsx)("div",{className:"fcrm-footer-settings__divider"}),(0,a.jsxs)(go.__experimentalHStack,{alignment:"top",spacing:6,children:[(0,a.jsx)("div",{style:{flex:1},children:(0,a.jsx)(go.__experimentalNumberControl,{label:"Font Size (px)",value:parseInt(n.font_size,10)||14,onChange:e=>{const t=parseInt(e,10);r("font_size",t&&t>0?String(t):"")},min:8,max:24,__nextHasNoMarginBottom:!0})}),(0,a.jsx)("div",{style:{flex:1},children:(0,a.jsx)(go.BaseControl,{label:"Text Color",__nextHasNoMarginBottom:!0,children:(0,a.jsx)(go.Dropdown,{popoverProps:{placement:"bottom-start"},renderToggle:({isOpen:e,onToggle:t})=>(0,a.jsxs)("button",{onClick:t,"aria-expanded":e,className:"fcrm-color-toggle",type:"button",children:[(0,a.jsx)("span",{className:"fcrm-color-indicator",style:{background:n.font_color||"#9ca3af"}}),(0,a.jsx)("span",{className:"fcrm-color-hex",children:n.font_color||"#9ca3af"})]}),renderContent:()=>(0,a.jsx)(go.ColorPicker,{color:n.font_color||"#9ca3af",onChange:e=>r("font_color",e),enableAlpha:!1})})})})]}),(0,a.jsxs)(go.__experimentalHStack,{alignment:"top",spacing:6,children:[(0,a.jsx)("div",{style:{flex:1},children:(0,a.jsx)(go.BaseControl,{label:"Background Color",__nextHasNoMarginBottom:!0,children:(0,a.jsx)(go.Dropdown,{popoverProps:{placement:"bottom-start"},renderToggle:({isOpen:e,onToggle:t})=>{const o="transparent"!==(n.background_color||"transparent");return(0,a.jsxs)("div",{className:"fcrm-color-toggle-wrap",children:[(0,a.jsxs)("button",{onClick:t,"aria-expanded":e,className:"fcrm-color-toggle",type:"button",children:[(0,a.jsx)("span",{className:"fcrm-color-indicator",style:{background:n.background_color||"transparent"}}),(0,a.jsx)("span",{className:"fcrm-color-hex",children:n.background_color||"transparent"})]}),o&&(0,a.jsx)("button",{type:"button",className:"fcrm-color-toggle__clear","aria-label":"Clear background color",title:"Clear background color",onClick:()=>r("background_color","transparent"),children:(0,a.jsxs)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"none",stroke:"currentColor",children:[(0,a.jsx)("line",{x1:"368",y1:"368",x2:"144",y2:"144",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32"}),(0,a.jsx)("line",{x1:"368",y1:"144",x2:"144",y2:"368",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"32"})]})})]})},renderContent:()=>(0,a.jsx)(go.ColorPicker,{color:n.background_color&&"transparent"!==n.background_color?n.background_color:"#ffffff",onChange:e=>r("background_color",e),enableAlpha:!1})})})}),(0,a.jsx)("div",{style:{flex:1},children:(0,a.jsx)(go.__experimentalNumberControl,{label:"Footer Padding (px)",value:Di(n),onChange:e=>{const t=parseInt(e,10);r("footer_padding",!Number.isNaN(t)&&t>=0?String(t):"")},min:0,max:80,__nextHasNoMarginBottom:!0})})]})]}),s&&(0,a.jsx)("p",{className:"fcrm-footer-settings__hint",children:"Email footer is hidden for this email."}),(0,a.jsx)(go.Button,{variant:"primary",onClick:()=>t(!1),className:"fcrm-footer-settings__done",children:"Done"})]})}):null},zi=["content","text","value","caption"],Hi="fcrm_ai_writing_tone";function Oi(e){if(!e)return"";let t=e.replace(/<[^>]*>/g,"");return t=t.replace(/^### (.+)$/gm,"<h3>$1</h3>").replace(/^## (.+)$/gm,"<h2>$1</h2>").replace(/^# (.+)$/gm,"<h1>$1</h1>").replace(/\*\*(.+?)\*\*/g,"<strong>$1</strong>").replace(/(?<!\*)\*(?!\*)(.+?)(?<!\*)\*(?!\*)/g,"<em>$1</em>"),t.split(/\n{2,}/).map(e=>(e=e.trim())?/^<h[1-6]>/.test(e)?e:/^[-*] /m.test(e)?"<ul>"+e.split("\n").map(e=>e.replace(/^[-*]\s+/,"").trim()).filter(Boolean).map(e=>"<li>"+e+"</li>").join("")+"</ul>":/^\d+\.\s/m.test(e)?"<ol>"+e.split("\n").map(e=>e.replace(/^\d+\.\s+/,"").trim()).filter(Boolean).map(e=>"<li>"+e+"</li>").join("")+"</ol>":"<p>"+e.replace(/\n/g,"<br>")+"</p>":"").join("")}function Fi(e){if("string"==typeof e)return e;if(e&&"object"==typeof e){if("function"==typeof e.toHTMLString)return e.toHTMLString();if("function"==typeof e.toString&&"[object Object]"!==e.toString())return e.toString()}return null}const Ui=[{key:"rewrite",label:(0,x.__)("Rewrite","fluent-crm"),description:(0,x.__)("Rewrite while keeping the same meaning","fluent-crm")},{key:"shorten",label:(0,x.__)("Shorten","fluent-crm"),description:(0,x.__)("Make it shorter and more concise","fluent-crm")},{key:"expand",label:(0,x.__)("Expand","fluent-crm"),description:(0,x.__)("Add more detail and engagement","fluent-crm")},{key:"fix_grammar",label:(0,x.__)("Fix Grammar","fluent-crm"),description:(0,x.__)("Fix grammar, spelling, and punctuation","fluent-crm")},{key:"custom",label:(0,x.__)("Custom Prompt","fluent-crm"),description:(0,x.__)("Describe what you want","fluent-crm")}],Gi=["Professional","Casual","Friendly","Urgent","Persuasive","Formal"];function Zi(e){if(!e)return null;if("core/list"===e.name){const t=function(e){if(!e.innerBlocks||!e.innerBlocks.length)return"";const t=!(!e.attributes||!e.attributes.ordered);return e.innerBlocks.map((e,n)=>{const o=e.attributes&&Fi(e.attributes.content)||"";return t?n+1+". "+o:"- "+o}).join("\n")}(e);return t?{textKey:"__list",content:t}:null}if(!e.attributes)return null;const t=zi.find(t=>{const n=e.attributes[t];return null!=n&&null!==Fi(n)});return t?{textKey:t,content:Fi(e.attributes[t])||""}:null}(0,t.registerPlugin)("fcrm-custom-document-info",{render:()=>{const e=window.fcrmEditorBoot||{},t="fcrm-custom-document-info/fcrm-email-body-panel";if((0,i.useEffect)(()=>{const e=(0,n.select)("core/editor"),o=(0,n.dispatch)("core/editor");e&&o&&"function"==typeof e.isEditorPanelOpened&&"function"==typeof o.toggleEditorPanelOpened&&(e.isEditorPanelOpened(t)||o.toggleEditorPanelOpened(t))},[]),e.fcrm_ui&&"compose"!==e.fcrm_ui)return null;const o=e.features||{};return!1===o.email_style_settings?o.sidebar_content?(0,a.jsx)(Ao.PluginDocumentSettingPanel,{name:"fcrm-email-body-panel",title:o.sidebar_panel_title||"",icon:"info-outline",className:"fcrm-email-body-panel-wrapper fcrm-info-panel",children:(0,a.jsx)("div",{className:"fcrm-sidebar-info-content",dangerouslySetInnerHTML:{__html:o.sidebar_content}})}):null:(0,a.jsx)(Ao.PluginDocumentSettingPanel,{name:"fcrm-email-body-panel",title:"",icon:"email-alt",className:"fcrm-email-body-panel-wrapper",children:(0,a.jsx)(oi,{})})}}),(0,t.registerPlugin)("fcrm-smartcode-toolbar-popover",{render:()=>{const[e,t]=(0,i.useState)(!1),[n,o]=(0,i.useState)(null),[r,s]=(0,i.useState)(""),l=()=>{t(!1),s("")};return(0,i.useEffect)(()=>{const e=()=>document.querySelector(".fcrm-compose-smartcodes"),n=()=>{const n=e();n&&(o(n),t(!0),s(""))},r=()=>{const n=e();n&&(o(n),t(e=>(e||s(""),!e)))};return window.addEventListener("fcrm-open-smartcodes",n),window.addEventListener("fcrm-toggle-smartcodes",r),()=>{window.removeEventListener("fcrm-open-smartcodes",n),window.removeEventListener("fcrm-toggle-smartcodes",r)}},[]),(0,i.useEffect)(()=>{if(!e)return;const t=e=>{const t=e.target;if(!(t instanceof Element))return;const o=!(!n||n!==t&&!n.contains(t)),r=!!t.closest(".fcrm-smartcode-toolbar-popover");o||r||l()},o=e=>{"Escape"===e.key&&l()};return document.addEventListener("mousedown",t,!0),document.addEventListener("touchstart",t,!0),document.addEventListener("keydown",o,!0),()=>{document.removeEventListener("mousedown",t,!0),document.removeEventListener("touchstart",t,!0),document.removeEventListener("keydown",o,!0)}},[e,n]),e&&n?(0,a.jsx)(ai,{anchor:n,onClose:l,onSelect:e=>{const t=li(e);(function(e){if(navigator.clipboard&&"function"==typeof navigator.clipboard.writeText)return navigator.clipboard.writeText(e).then(()=>!0).catch(()=>!1);if(document.queryCommandSupported&&document.queryCommandSupported("copy")){const t=document.createElement("textarea");t.value=e,t.style.position="fixed",document.body.appendChild(t),t.select(),t.setSelectionRange(0,t.value.length);let n=!1;try{n=document.execCommand("copy")}catch(e){n=!1}finally{document.body.removeChild(t)}return Promise.resolve(n)}return Promise.resolve(!1)})(e).then(e=>{e||t?l():s((0,x.__)("Could not insert or copy shortcode","fluent-crm"))})},feedbackMessage:r}):null}}),(0,t.registerPlugin)("fcrm-email-footer-preview",{render:()=>!1===((window.fcrmEditorBoot||{}).features||{}).email_footer?null:(0,a.jsx)(Ri,{})}),(0,t.registerPlugin)("fcrm-ai-writing-popover",{render:()=>{const[e,t]=(0,i.useState)(!1),[o,s]=(0,i.useState)(null),[l,c]=(0,i.useState)(!1),[d,u]=(0,i.useState)(""),[m,p]=(0,i.useState)("actions"),[f,g]=(0,i.useState)(""),[h,y]=(0,i.useState)(""),[_,I]=(0,i.useState)(()=>function(){try{const e=localStorage.getItem(Hi);if(e&&Gi.includes(e))return e}catch(e){}return"Professional"}()),[b,w]=(0,i.useState)(""),[v,C]=(0,i.useState)(null),S=(0,i.useRef)(null),N=(0,i.useCallback)(e=>{I(e),function(e){try{localStorage.setItem(Hi,e)}catch(e){}}(e)},[]),j=(0,i.useCallback)(()=>{u(""),p("actions"),g(""),y(""),w(""),C(null),c(!1)},[]),M=(0,i.useCallback)(()=>{t(!1),j()},[j]),k=(0,i.useCallback)((e,t)=>{const o=function(){const e=(0,n.select)("core/block-editor");if(!e)return null;const t="function"==typeof e.getSelectedBlockClientId?e.getSelectedBlockClientId():null;if(t){const n=Zi(e.getBlock(t));return n?{clientIds:[t],textKey:n.textKey,content:n.content}:null}const o="function"==typeof e.getMultiSelectedBlockClientIds?e.getMultiSelectedBlockClientIds():[];if(!o||!o.length)return null;const r=[];let i=null;for(const t of o){const n=Zi(e.getBlock(t));n&&(i||(i=n.textKey),n.content&&r.push(n.content))}return i?{clientIds:o,textKey:i,content:r.join("\n\n")}:null}();o?o.textKey?o.content||"custom"===e?(C(o),u(""),c(!0),p("preview"),bo()({path:"fluent-crm/v2/ai/generate",method:"POST",data:{action:e,content:o.content,tone:_,custom_prompt:t||""}}).then(e=>{e&&e.content?w(e.content):(u((0,x.__)("No content was generated. Please try again.","fluent-crm")),p("actions"))}).catch(e=>{const t=e&&e.message?e.message:(0,x.__)("An error occurred. Please try again.","fluent-crm");u(t),p("actions")}).finally(()=>{c(!1)})):u((0,x.__)("The selected block is empty. Add some text first or use Custom Prompt.","fluent-crm")):u((0,x.__)("This block type is not supported for AI writing.","fluent-crm")):u((0,x.__)("Please select a text block first.","fluent-crm"))},[_]),T=(0,i.useCallback)(()=>{v&&v.clientIds&&v.clientIds.length&&v.textKey&&b&&function(e,t,o){const i=(0,n.dispatch)("core/block-editor"),a=(0,r.pasteHandler)({plainText:o,mode:"BLOCKS"});if(e.length>1||"__list"===t)return!(!a||!a.length||(i.replaceBlocks(e,a),0));if(a&&a.length>1)return i.replaceBlocks([e[0]],a),!0;let s=o;if(a&&1===a.length&&a[0].attributes)for(const e of zi){const t=a[0].attributes[e];if(null!=t){const e=Fi(t);if(null!==e){s=e;break}}}i.updateBlockAttributes(e[0],{[t]:s})}(v.clientIds,v.textKey,b),M()},[v,b,M]),E=(0,i.useCallback)(()=>{w(""),u(""),k(f,h)},[f,h,k]),D=(0,i.useCallback)(e=>{g(e),u(""),"custom"!==e?k(e,""):p("custom")},[k]);return(0,i.useEffect)(()=>{const e=window.fcrmEditorBoot||{};if(!e.ai_writing||!e.ai_writing.enabled)return;const n=e=>{const n=e.detail&&e.detail.anchor,o=document.querySelector(".fcrm-compose-ai-writing"),r=n||o;r&&s(r),t(e=>{const t=!e;return t&&j(),t})};return window.addEventListener("fcrm-toggle-ai-writing",n),()=>{window.removeEventListener("fcrm-toggle-ai-writing",n)}},[j]),(0,i.useEffect)(()=>{if(!e)return()=>{};const t=e=>{const t=e.target;if(!t)return;const n=o,r=S.current,i=!(!n||n!==t&&!n.contains(t)),a=!(!r||r!==t&&!r.contains(t));i||a||M()},n=e=>{if("Escape"===e.key){if("tone"===m)return void p("actions");M()}};return document.addEventListener("mousedown",t,!0),document.addEventListener("touchstart",t,!0),document.addEventListener("keydown",n,!0),()=>{document.removeEventListener("mousedown",t,!0),document.removeEventListener("touchstart",t,!0),document.removeEventListener("keydown",n,!0)}},[e,o,M,m]),e&&o?(0,a.jsx)(go.Popover,{className:"fcrm-ai-writing-popover",anchor:o,placement:"bottom-end",onClose:M,focusOnMount:!1,children:(0,a.jsxs)("div",{className:"fcrm-ai-writing-popover__wrap",ref:S,children:[(0,a.jsxs)("div",{className:"fcrm-ai-writing-popover__header",children:[(0,a.jsx)("span",{children:(0,x.__)("AI Writing","fluent-crm")}),(0,a.jsxs)("button",{type:"button",className:"fcrm-ai-writing-popover__tone-badge",onClick:()=>p("tone"===m?"actions":"tone"),title:(0,x.__)("Change writing tone","fluent-crm"),children:[(0,a.jsx)("span",{className:"fcrm-ai-writing-popover__tone-badge-label",children:(0,x.__)("Tone:","fluent-crm")}),(0,a.jsx)("span",{className:"fcrm-ai-writing-popover__tone-badge-value",children:_}),(0,a.jsx)("span",{className:"fcrm-ai-writing-popover__tone-badge-arrow",children:"tone"===m?"▴":"▾"})]})]}),d?(0,a.jsx)("div",{className:"fcrm-ai-writing-popover__error",children:d}):null,"actions"===m?(0,a.jsx)("div",{className:"fcrm-ai-writing-popover__actions",children:Ui.map(e=>(0,a.jsxs)("button",{type:"button",className:"fcrm-ai-writing-popover__action",onClick:()=>D(e.key),children:[(0,a.jsx)("span",{className:"fcrm-ai-writing-popover__action-label",children:e.label}),(0,a.jsx)("span",{className:"fcrm-ai-writing-popover__action-desc",children:e.description})]},e.key))}):null,"tone"===m?(0,a.jsx)("div",{className:"fcrm-ai-writing-popover__tone",children:(0,a.jsx)("div",{className:"fcrm-ai-writing-popover__tone-options",children:Gi.map(e=>(0,a.jsx)("button",{type:"button",className:"fcrm-ai-writing-popover__tone-btn"+(_===e?" is-active":""),onClick:()=>{N(e),p("actions")},children:e},e))})}):null,"custom"===m?(0,a.jsxs)("div",{className:"fcrm-ai-writing-popover__custom",children:[(0,a.jsxs)("div",{className:"fcrm-ai-writing-popover__sub-header",children:[(0,a.jsx)("button",{type:"button",className:"fcrm-ai-writing-popover__back-btn",onClick:()=>{p("actions"),u("")},children:"←"}),(0,a.jsx)("span",{children:(0,x.__)("Custom Prompt","fluent-crm")})]}),(0,a.jsx)("div",{className:"fcrm-ai-writing-popover__custom-input",children:(0,a.jsx)(go.TextareaControl,{value:h,onChange:y,placeholder:(0,x.__)("Describe what you want the AI to do with the selected text...","fluent-crm"),rows:3,__nextHasNoMarginBottom:!0})}),(0,a.jsx)("div",{className:"fcrm-ai-writing-popover__footer",children:(0,a.jsx)(go.Button,{variant:"primary",disabled:!h.trim(),onClick:()=>k("custom",h),children:(0,x.__)("Generate","fluent-crm")})})]}):null,"preview"===m?(0,a.jsx)("div",{className:"fcrm-ai-writing-popover__preview",children:l?(0,a.jsxs)("div",{className:"fcrm-ai-writing-popover__loading",children:[(0,a.jsx)(go.Spinner,{}),(0,a.jsx)("p",{children:(0,x.__)("Generating...","fluent-crm")})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"fcrm-ai-writing-popover__sub-header",children:(0,a.jsx)("span",{children:(0,x.__)("Generated Content","fluent-crm")})}),(0,a.jsx)("div",{className:"fcrm-ai-writing-popover__preview-text",dangerouslySetInnerHTML:{__html:Oi(b)}}),(0,a.jsxs)("div",{className:"fcrm-ai-writing-popover__footer",children:[(0,a.jsx)(go.Button,{variant:"secondary",onClick:()=>{j()},children:(0,x.__)("Discard","fluent-crm")}),(0,a.jsx)(go.Button,{variant:"secondary",onClick:E,children:(0,x.__)("Try Again","fluent-crm")}),(0,a.jsx)(go.Button,{variant:"primary",onClick:T,children:(0,x.__)("Accept","fluent-crm")})]})]})}):null]})}):null}}),(0,t.registerPlugin)("fcrm-reusable-block-controls",{render:function(){return null}}),window.fcrmRegisterCustomPatterns=(e=[],t={})=>function(e=[],t={}){return mi(e.map((e,t)=>di(e,t)).filter(Boolean),t)}(e,t),function(){if(fi)return;if(!window.wp||!window.wp.apiFetch||"function"!=typeof window.wp.apiFetch.use)return;fi=!0;const e="/fluent-crm/v2/editor-patterns",t="/fluent-crm/v2/editor-pattern-categories";window.wp.apiFetch.use((n,o)=>{const r=function(e={}){if("string"==typeof e.path&&e.path)return e.path;if("string"==typeof e.url&&e.url)try{const t=new URL(e.url,window.location.origin);return`${t.pathname}${t.search||""}`}catch(t){return e.url}return""}(n),i=function(e={}){return String(e.method||"GET").toUpperCase()}(n);if(function(e=""){return/\/wp\/v2\/blocks(?:\/(\d+))?(?:\?|$)/.test(String(e))}(r)){const t=function(e=""){const t=String(e).match(/\/wp\/v2\/blocks\/(\d+)/);return t?t[1]:null}(r);return o("GET"!==i||t?"POST"!==i||t?!t||"PUT"!==i&&"PATCH"!==i&&"POST"!==i?t&&"DELETE"===i?{...n,path:e+"/"+t,method:"DELETE"}:t&&"GET"===i?{...n,path:e+"/"+t}:n:{...n,path:e+"/"+t,method:"POST"}:{...n,path:e,method:"POST"}:{...n,path:e})}if(function(e=""){return String(e).includes("/wp/v2/wp_pattern_category")}(r))return o("GET"===i?{...n,path:t}:"POST"===i?{...n,path:t,method:"POST"}:n);const a=function(e=""){return String(e).includes("/wp/v2/block-patterns/patterns")}(r),s=function(e=""){return String(e).includes("/wp/v2/block-patterns/categories")}(r);if(!a&&!s)return o(n);const{unregisterAll:l,normalizedPatterns:c,normalizedCategories:d}=ui();return l?a?Promise.resolve(c.map(pi)):Promise.resolve(d):o(n)})}(),function(){if(xi(),Si)return;Si=!0,Ni(),vi=[300,1e3].map(e=>setTimeout(()=>{xi()},e));let e=0;Ci=setInterval(()=>{e+=1,xi(),e>=15&&(Ni(),Si=!1)},1e3)}(),!1===(window.fcrmEditorBoot||{}).features?.create_pattern&&document.body.classList.add("fcrm-no-pattern-features");let Vi=!1;"undefined"!=typeof document&&document.body&&Uo()&&document.body.classList.add("fcrm-compose-ui"),(0,t.registerPlugin)("fluent-com-disable-gutenberg-features",{render:()=>((0,i.useEffect)(()=>{if(Vi)return;(0,n.select)("core/edit-post").isFeatureActive("welcomeGuide")&&(0,n.dispatch)("core/edit-post").toggleFeature("welcomeGuide"),(0,n.select)("core/edit-post").isFeatureActive("fullscreenMode")&&(0,n.dispatch)("core/edit-post").toggleFeature("fullscreenMode"),"text"===(0,n.select)("core/edit-post").getEditorMode()&&(0,n.dispatch)("core/edit-post").switchEditorMode("visual"),(0,n.select)("core/edit-post").getActiveGeneralSidebarName()||(0,n.dispatch)("core/edit-post").openGeneralSidebar("edit-post/document"),Uo()||(0,n.dispatch)("core/editor").lockPostSaving(),(0,n.dispatch)("core/editor").lockPostAutosaving();let e=!1;function t(){e||(e=!0,window.requestAnimationFrame(()=>{e=!1,cr(),lr()}))}const o=[100,300,600,1e3,2e3,3500,5e3,8e3].map(e=>setTimeout(t,e)),r=window.setInterval(t,1e3),i=window.setTimeout(()=>window.clearInterval(r),3e4),a=(0,n.subscribe)(t);window.addEventListener("load",t);const s=new MutationObserver(function(){t()}),l=document.body||document.documentElement;return l&&s.observe(l,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class","style"]}),Vi=!0,()=>{o.forEach(e=>clearTimeout(e)),clearInterval(r),clearTimeout(i),"function"==typeof a&&a(),window.removeEventListener("load",t),s.disconnect()}},[]),null)}),(0,o.addFilter)("editor.DocumentBar","fluentcom-custom-document-bar",()=>null),(0,o.addFilter)("blocks.registerBlockType","fluentcrm/group-customizations",(e,t)=>"core/group"!==t?e:{...e,attributes:{...e.attributes,fcrmDisableBottomSpacing:{type:"boolean",default:!1}},supports:{...e.supports,layout:{...e.supports?.layout||{},allowedLayouts:["constrained","flow","flex"]}}}),(0,o.addFilter)("editor.Autocomplete.completers","fluent_com/add_autocmplete",function(e){return e=e.filter(e=>"users"!==e.name),[...e,pr]}),window.addEventListener("beforeunload",function(e){e.stopImmediatePropagation()}),new Promise(e=>{let t=!1;const o=()=>{if(!t){t=!0;try{r()}catch(e){}clearTimeout(i),e()}};if((0,n.select)("core/editor").isCleanNewPost()||(0,n.select)("core/block-editor").getBlockCount()>0)return void e();const r=(0,n.subscribe)(()=>{((0,n.select)("core/editor").isCleanNewPost()||(0,n.select)("core/block-editor").getBlockCount()>0)&&o()}),i=setTimeout(o,3e3)}).then(()=>{console.log("[FCRM Autosave] Editor initial stores ready");try{(0,r.unregisterBlockVariation)("core/paragraph","stretchy-paragraph"),(0,r.unregisterBlockVariation)("core/heading","stretchy-heading"),(0,r.unregisterBlockVariation)("core/group","group-grid"),(0,r.unregisterBlockVariation)("core/group","group-stack")}catch(e){}}).catch(()=>{}),console.log("[FCRM Autosave] Boot start");let Wi=!1,Qi=!1,Yi=null;const Ji=window.fcrmEditorBoot||null,$i=!!Ji?.can_save;console.log("[FCRM Autosave] Boot data:",Ji);const qi=Ji?.entity||null,Ki=Ji?.autosave?.endpoint||window.location.origin+"/wp-json/fluent-crm/v1/editor-autosave",Xi=Ji?.autosave?.nonce||"";let ea=!1,ta=!1,na=null,oa=null,ra=null,ia=0;try{qi&&qi.id&&(qi.content||""===qi.content)&&(ra=aa(qi.content||""))}catch(e){}function aa(e){let t,n=0,o=0;if(!e)return"0";for(o=0;o<e.length;o++)t=e.charCodeAt(o),n=(n<<5)-n+t,n|=0;return n.toString(36)}function sa(e={}){const t={canSave:$i,dirty:ea,inFlight:ta,...e};window.fcrmEditorAutosaveState=t,window.dispatchEvent(new CustomEvent("fcrm-autosave-state",{detail:t}))}function la(e){console.log("[FCRM Autosave]",e)}function ca(){$i&&(ea=!0,sa(),na&&clearTimeout(na),na=setTimeout(()=>ua(!1),5e3))}function da(){oa||(oa=setTimeout(()=>{ua(!0),oa=null,da()},6e4))}async function ua(e){if(!$i)return{saved:!1,status:"disabled"};if(ta)return{saved:!1,status:"in_flight"};if(!ea&&!e)return{saved:!1,status:"not_dirty"};if("template"===qi?.block_type&&!qi?.id)return console.log("[FCRM Autosave] Skip autosave: template has no ID yet"),sa(),{saved:!1,status:"missing_id"};const t=(0,n.select)("core/block-editor").getBlocks(),o=function(e){const t=aa(e||"");return{block_type:qi?.block_type||"",id:qi?.id||null,content:e||"",hash:t,prev_updated_at:qi?.updated_at||""}}((0,r.serialize)(t));if(o.hash===ra&&!e)return ea=!1,sa(),{saved:!0,status:"already_synced"};ta=!0,ea=!1,sa(),la("Saving…");try{const e=await fetch(Ki,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":Xi},body:JSON.stringify(o),credentials:"same-origin"}),t=await e.json();if("conflict"===t.status)return la("Conflict not saved"),{saved:!1,status:t.status};if("skipped"===t.status)return la("Autosave skipped"),{saved:!1,status:t.status};if(ra=o.hash,t.id&&(!qi?.id||t.created)){qi.id=t.id;try{!function(e){if(!e)return;const t=new URL(window.location.href);t.searchParams.set("bid",e),!t.searchParams.get("block_type")&&qi?.block_type&&t.searchParams.set("block_type",qi.block_type),window.history.replaceState({},document.title,t.toString())}(t.id)}catch(e){}}return t.updated_at&&(qi.updated_at=t.updated_at),la("noop"===t.status?"Up to date":"Saved"),ia=0,{saved:!0,status:t.status||"saved"}}catch(e){ia=Math.min(ia+1,5);const t=[3e3,8e3,15e3,3e4,45e3,6e4][ia];return la("Save failed retry "+Math.round(t/1e3)+"s"),ea=!0,sa(),setTimeout(()=>ua(!1),t),{saved:!1,status:"failed"}}finally{ta=!1,sa()}}function ma(e){var t=!1,n=[];return e.forEach(function(e){var o=ma(e.innerBlocks||[]);if(o.anyRecovered&&(t=!0),!1===e.isValid){var i=!1;try{var a=e.originalContent||"";if(a){var s=(0,r.rawHandler)({HTML:a});s&&s.length>0&&(t=!0,i=!0,n.push.apply(n,s))}}catch(t){console.warn('[FCRM Editor] rawHandler recovery failed for "'+e.name+'":',t.message)}if(!i)try{var l=(0,r.createBlock)(e.name,e.attributes,o.blocks);t=!0,n.push(l)}catch(t){console.warn('[FCRM Editor] Could not recover block "'+e.name+'":',t.message),n.push(Object.assign({},e,{innerBlocks:o.blocks}))}}else o.anyRecovered?n.push(Object.assign({},e,{innerBlocks:o.blocks})):n.push(e)}),{blocks:n,anyRecovered:t}}function pa(e){for(var t=0;t<e.length;t++){var n=e[t];if(n){if(!1===n.isValid)return!0;if(n.innerBlocks&&n.innerBlocks.length&&pa(n.innerBlocks))return!0}}return!1}function fa(e,t){t=t||1;var o=e;try{var i=(0,n.select)("core/block-editor").getBlocks();if((0,r.serialize)(i)===o)return;var a=(0,r.parse)(o);if(1===t){var s=ma(a);s.anyRecovered&&(a=s.blocks,setTimeout(async function(){if(Wi){const e=await ua(!0);e&&e.saved&&Bo(Lo.RECOVERY_NOTICE)}},1500))}(0,n.dispatch)("core/block-editor").resetBlocks(a),setTimeout(function(){try{var e=(0,n.select)("core/block-editor").getBlocks(),i=(0,r.serialize)(e);o&&!i.trim()&&t<8&&(console.warn("[FCRM Editor] Content verification failed (attempt "+t+"), retrying..."),setTimeout(function(){fa(o,t+1)},300*t))}catch(e){console.warn("[FCRM Editor] Content verification error:",e)}},100)}catch(e){console.warn("[FCRM Editor] resetBlocks failed (attempt "+t+"):",e.message),t<8&&setTimeout(function(){fa(o,t+1)},300*t)}}window.addEventListener("beforeunload",()=>{$i&&ea&&!ta&&ua(!0)}),Ho(e=>!(!e||e.type!==Po.UPDATE_EDITOR||!e.data||"object"!=typeof e.data),e=>{Qi=!0;const{content:t,templateConfig:o,extra_tags:r}=e.data;r&&(window.fcrm_funnel_context_codes=r,window.dispatchEvent(new CustomEvent("fcrm-context-smartcodes-updated"))),"string"==typeof t&&(setTimeout(()=>{fa(t,1)},50),Yi&&clearTimeout(Yi),Yi=setTimeout(function(){try{var e=(0,n.select)("core/block-editor").getBlocks();if(!pa(e))return;var t=ma(e);t.anyRecovered&&((0,n.dispatch)("core/block-editor").resetBlocks(t.blocks),ua(!0))}catch(e){console.warn("[FCRM Editor] Late block recovery failed:",e)}finally{Yi=null}},2500)),o&&"object"==typeof o&&(window._fcrmStyleConfig=JSON.parse(JSON.stringify(o)),window.dispatchEvent(new CustomEvent("fcrm:style-config-sync",{detail:{template_config:o}})));const i=e.data.footerSettings;void 0!==i&&(window._fcrmFooterSettings=i||null,window.postMessage({action:"FOOTER_SETTINGS_SYNC",footer_settings:i},"*")),setTimeout(()=>{Wi=!0},1e3)}),Ho(e=>!(!e||e.type!==Po.INSERT_SMARTCODE||"string"!=typeof e.shortcode),e=>{const t=String(e.shortcode||"").trim();t&&li(t)});let ga=!1;!function e(t,n=0){if(window._wpLoadBlockEditor&&"function"==typeof window._wpLoadBlockEditor.then){let e=!1;const n=()=>{e||(e=!0,t())};return window._wpLoadBlockEditor.then(n).catch(t=>{e=!0,console.error("[FCRM Editor] initializeEditor failed:",t);try{window.parent.postMessage({action:"EDITOR_INIT_FAILED",error:String(t)},"*")}catch(e){}}),void setTimeout(()=>{e||(console.warn("[FCRM Autosave] _wpLoadBlockEditor timed out, proceeding"),n())},5e3)}if(n>50)return console.warn("[FCRM Autosave] _wpLoadBlockEditor not found, proceeding anyway"),void t();setTimeout(()=>e(t,n+1),100)}(()=>{(function(){if(!ga){ga=!0;try{window.parent.postMessage({content:"ping",action:"EDITOR_READY"},"*")}catch(e){}console.log("[FCRM Editor] EDITOR_READY sent (editor booted)")}})(),setTimeout(()=>{cr()},500),Wi||(window.parent&&window.parent!==window?Qi||setTimeout(function(){Wi||(Wi=!0,console.log("[FCRM Autosave] Standalone readiness fallback (iframe, no UPDATE_EDITOR after timeout)"))},5e3):(Wi=!0,console.log("[FCRM Autosave] Standalone readiness enabled (not in iframe)")));let e="",t="",o=null;(0,n.subscribe)(()=>{if(!Wi)return;const i=(0,n.select)("core/editor").getEditedPostAttribute("title");if(i!==t){t=i;try{window.parent.postMessage({content:i,action:"TITLE_UPDATED"},"*")}catch(e){}}const a=(0,n.select)("core/editor").getEditedPostAttribute("featured_media");if(a!==o){o=a;try{window.parent.postMessage({content:a,action:"FEATURED_MEDIA_UPDATED"},"*")}catch(e){}}const s=(0,n.select)("core/block-editor").getBlocks(),l=(0,r.serialize)(s);if(e!==l){e=l;try{window.parent.postMessage({content:l,action:"EDITOR_UPDATED"},"*")}catch(e){}ca()}});let i=null;(0,n.subscribe)(()=>{if(!Wi)return;const e=(0,n.select)("core/block-editor").getBlocks(),t=e.map(e=>e.clientId);if(null===i)return void(i=t);const o=t.filter(e=>!i.includes(e));i=t,o.length&&o.forEach(t=>{const o=e.find(e=>e.clientId===t);if(!o||"core/image"!==o.name)return;const i=e.findIndex(e=>e.clientId===t);i<0||e[i+1]||(0,n.dispatch)("core/block-editor").insertBlock((0,r.createBlock)("core/paragraph"),i+1)})}),$i?(console.log("[FCRM Autosave] Enabled. Entity ID:",qi?.id,"Block Type:",qi?.block_type),da(),ca()):(la("Autosave disabled"),console.log("[FCRM Autosave] Disabled (canSave false)"))}),window.fcrmManualAutosave=()=>ua(!0),sa({canSave:$i}),console.log("[FCRM Autosave] Manual trigger available: window.fcrmManualAutosave()")})();