@emailmaker/emailmaker 1.3.4 → 1.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/README.md +20 -0
- package/emailmaker-core.091c986b.js +874 -0
- package/emailmaker-esm.js +53 -39
- package/{emailmaker-po.87ebe001.js → emailmaker-po.091c986b.js} +1 -1
- package/emailmaker.d.ts +95 -5
- package/emailmaker.js +54 -40
- package/iframe/.vite/manifest.json +4 -4
- package/iframe/css/sandbox-dark.css +2 -9
- package/iframe/css/sandbox-light.css +2 -9
- package/iframe/css/sandbox.css +13 -23
- package/iframe/{iframe-eblock.87ebe001.html → iframe-eblock.091c986b.html} +2 -2
- package/iframe/{iframe.87ebe001.html → iframe.091c986b.html} +2 -2
- package/iframe/js/elMarkupHelper.DoIAMao4.js +279 -0
- package/iframe/js/{iframe-eblock.body.87ebe001.js → iframe-eblock.body.091c986b.js} +1 -1
- package/iframe/js/iframe-eblock.js +2 -2
- package/iframe/js/iframe.body.091c986b.js +129 -0
- package/iframe/js/iframe.js +2 -2
- package/package.json +1 -1
- package/runtime/react/index.js +1 -1
- package/static/core/166a67bd.js +1 -0
- package/static/core/1a65ef0f.js +1 -0
- package/static/core/{4cdd6e6c.js → 1c67ab93.js} +1 -1
- package/static/core/{27599903.js → 1d004581.js} +1 -1
- package/static/core/{79e13595.js → 220d7d31.js} +1 -1
- package/static/core/{afb0d556.js → 2da7d310.js} +2 -2
- package/static/core/322d3e9f.js +1 -0
- package/static/core/{d8175c7f.js → 34756b09.js} +1 -1
- package/static/core/36f3f772.js +1 -0
- package/static/core/3b9931cd.js +1 -0
- package/static/core/{312fb954.js → 3bff2ae6.js} +1 -1
- package/static/core/{5afad425.js → 454350da.js} +1 -1
- package/static/core/{4797d4f7.js → 4852c0de.js} +6 -6
- package/static/core/{75a2537a.js → 5272f5b2.js} +1 -1
- package/static/core/{76163cc7.js → 5f176d0a.js} +1 -1
- package/static/core/674e22a5.js +1 -0
- package/static/core/{27986c36.js → 6ce85877.js} +1 -1
- package/static/core/7b8fbc31.js +1 -0
- package/static/core/{5ebf9f1e.js → 867b1e0a.js} +1 -1
- package/static/core/89b1052c.js +1 -0
- package/static/core/{81c0d133.js → 8b8c93f4.js} +1 -1
- package/static/core/8e97c82c.js +163 -0
- package/static/core/8eea6488.js +1 -0
- package/static/core/9a4cfb0a.js +1 -0
- package/static/core/{81a16991.js → 9d388494.js} +1 -1
- package/static/core/{2269bf04.js → 9e1370a6.js} +1 -1
- package/static/core/{9a7e933e.js → a59d579e.js} +1 -1
- package/static/core/{87c47034.js → a6abc393.js} +2 -2
- package/static/core/aa33047a.js +1 -0
- package/static/core/abde5a43.js +2 -0
- package/static/core/{d833a29f.js → b69579c4.js} +1 -1
- package/static/core/{489390a3.js → bcc4db3e.js} +1 -1
- package/static/core/{78916fed.js → c0b0ceff.js} +3 -3
- package/static/core/c5edcfc7.js +1 -0
- package/static/core/{122c5ed9.js → c9d5118c.js} +1 -1
- package/static/core/{81cc5690.js → caf9f1a6.js} +1 -1
- package/static/core/{7601732d.js → d241119a.js} +1 -1
- package/static/core/d4c10a7e.js +10 -0
- package/static/core/d517188a.js +1 -0
- package/static/core/db92581b.js +19 -0
- package/static/core/{a15ab3fe.js → de0d3c9a.js} +1 -1
- package/static/core/{8cebeef2.js → e995a70d.js} +1 -1
- package/static/core/ee26ef3d.js +1 -0
- package/static/core/f399000c.js +1 -0
- package/static/core/{67cc6cb2.js → f875f388.js} +1 -1
- package/static/esm/{9610f2de.js → 95cbf920.js} +1 -1
- package/static/umd-runtime/{runtime.BHEKxbjr.js → runtime.CV4WRxRc.js} +1 -1
- package/vendor/@emailmaker/ui-kit/package.json +1 -1
- package/emailmaker-core.87ebe001.js +0 -859
- package/iframe/js/elMarkupHelper.CO37NCd9.js +0 -278
- package/iframe/js/iframe.body.87ebe001.js +0 -129
- package/static/core/32e15918.js +0 -1
- package/static/core/b8941eda.js +0 -28
package/emailmaker-esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as
|
|
1
|
+
import{n as wc,r as Sc,t as Vd}from"./static/esm/971f1b2c.js";import{$ as Gd,A as qd,At as Ot,B as Wd,Bt as Qn,C as We,Ct as zd,D as no,Dt as H,E as Kd,Et as Ic,F as Yd,Ft as Lr,G as Xd,Gt as ke,H as Jd,Ht as Qd,I as Zd,It as ef,J as Tc,Jt as tf,K as Ac,Kt as nf,L as rf,Lt as of,M as sf,Mt as af,N as cf,Nt as gi,O as Ne,Ot as vn,P as ro,Pt as lf,Q as uf,R as Cc,Rt as Ie,S as io,St as df,T as Nr,Tt as ff,U as pf,Ut as xt,V as hf,Vt as se,W as hr,Wt as U,X as mf,Y as oo,Yt as ve,Z as Rn,_ as mr,_t as bn,a as gf,at as so,bt as ao,c as Rc,ct as _n,d as vf,dt as Xe,et as yn,f as bf,ft as Oc,g as _f,gt as Fe,h as K,ht as Y,i as yf,it as Tt,j as Zo,jt as Je,k as Ef,kt as Pe,l as wf,m as Sf,mt as ge,n as If,nt as Tf,o as Af,ot as es,p as Cf,pt as kc,q as Rf,qt as Of,r as kf,rt as Pf,s as Bt,st as Df,t as xe,tt as xf,u as Mf,ut as Pc,v as Lf,vt as co,w as Nf,wt as ts,x as Ff,xt as Ve,y as Bf,yt as we,z as jf,zt as lo}from"./static/esm/95cbf920.js";import{t as Uf}from"./static/esm/f76c9d9d.js";(function(){"use strict";var e=window.__emailmaker__=window.__emailmaker__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var h=(function(){if(typeof document<"u"&&document.querySelector)try{var N=document.querySelector('script[src*="emailmaker-esm.js"]')||document.querySelector('script[src*="emailmaker.js"]');if(N&&N.src)return N.src.substring(0,N.src.lastIndexOf("/")+1)}catch{}try{var S=import.meta.url;if(S)return S.substring(0,S.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var f=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(f)||f.indexOf("//")===0)return f.charAt(f.length-1)==="/"?f:f+"/";var p=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",b=p?new URL(f,p).href:f;return b.charAt(b.length-1)==="/"?b:b+"/"}catch{var x=String(h);return x.charAt(x.length-1)==="/"?x:x+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var f=h==null?"":String(h);f||(f="./");try{var p=String(f);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(p)||p.indexOf("//")===0)return p.charAt(p.length-1)==="/"?p:p+"/";var b=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",x=b?new URL(p,b).href:p;return x.charAt(x.length-1)==="/"?x:x+"/"}catch{var N=String(f);return N.charAt(N.length-1)==="/"?N:N+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var f="";try{if(typeof window<"u"){for(var p in window)if(!(p==="__emailmaker__"||!/^__[^_].*__$/.test(p))){var b;try{b=window[p]}catch{continue}if(b&&typeof b=="object"&&b.publicPath){f=" Another product namespace ("+p+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function f(w){try{var M=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return M?new URL(String(w||""),M).href:String(w||"")}catch{return String(w||"")}}var p=String(h||"");if(!p)return"";if(/^(?:data:|blob:)/.test(p))return p;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(p)||p.indexOf("//")===0||p.charAt(0)==="/")return f(p);var b=p.replace(/^\.\/+/,"").replace(/^\/+/,""),x="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),N=x&&b.indexOf(x+"/")!==0?x+"/"+b:b,S=e.publicPath||"./";try{return new URL(N,S).href}catch{return S.slice(-1)!=="/"&&(S+="/"),f(S+N)}}),e.version||(e.version="1.3.8");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
|
|
2
2
|
* Async AMD Loader (IIFE version for injection)
|
|
3
3
|
*
|
|
4
4
|
* This file is injected at the beginning of iframe entry points.
|
|
@@ -993,27 +993,29 @@ import{n as Ra,r as Pd}from"./static/esm/971f1b2c.js";import{$ as Dd,A as xd,At
|
|
|
993
993
|
__amdEnv.syncRequire = syncRequire;
|
|
994
994
|
__amdEnv.diagnosticsBuffer = diagBuffer;
|
|
995
995
|
})();
|
|
996
|
-
`,r=new Function("__amdEnv",n);r(e),typeof e.require=="function"&&typeof e.require.config=="function"&&e.require.config({baseUrl:"./",paths:{core:"emailmaker-core.
|
|
997
|
-
`),u="",g=0;g<f.length;g+=1){var k=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(f[g]);if(k){if(!u){u=k[1];continue}if(k[1]!==u)return k[1]}}return""},C=function(m){var f=w(new Error(m)),u=f?m+" Requested by: "+f+".":m;return e.__compatMissingReason=u,u};if(e.registerCompat=function(m){if(!(!m||typeof m!="object"))for(var f in m)Object.prototype.hasOwnProperty.call(m,f)&&(v[f]=m[f])},e.__compatPending){for(var y=0;y<e.__compatPending.length;y+=1)e.registerCompat(e.__compatPending[y]);e.__compatPending=void 0}for(var S in h)Object.prototype.hasOwnProperty.call(h,S)&&(function(m,f,u){var g=!1,k=function(){if(!(m in v))throw new Error(C(f));return v[m]};Object.defineProperty(t,m,{configurable:!0,enumerable:!0,get:function(){var M=k();return g||(g=!0),M},set:function(M){v[m]=M}}),Object.defineProperty(d,m,{configurable:!0,enumerable:!0,get:k,set:function(M){v[m]=M}})})(S,h[S],b[S]);var T=t;for(var B in d)Object.prototype.hasOwnProperty.call(d,B)&&(T===t&&(T=Object.create(t)),Object.defineProperty(T,B,Object.getOwnPropertyDescriptor(d,B)));var D=s,O=[],A=function(){for(var m=[],f=0;f<O.length;f+=1)(function(u){var g=t[u];g&&typeof g.then=="function"&&m.push(Promise.resolve(g).then(function(k){t[u]=k}))})(O[f]);return Promise.all(m)},x=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(A).then(function(){if(typeof x=="function")return x.call(e)})},typeof e.define=="function"){let m=function(f){if(!f||typeof f!="object"&&typeof f!="function"||f.__esModule)return f;if(R){var u=R.get(f);if(u)return u}var g=Object.create(null);Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var k=Reflect.ownKeys(f),M=0;M<k.length;M++){var _=k[M];if(_!=="__esModule"){var I=Object.getOwnPropertyDescriptor(f,_);I&&Object.defineProperty(g,_,I)}}return Object.prototype.hasOwnProperty.call(g,"default")||Object.defineProperty(g,"default",{enumerable:!0,value:f,writable:!1}),R&&R.set(f,g),g};var R=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var f=T.React;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.React)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.React;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/react",[],function(){var f=T.React;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.React)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.React;return m(g)})}),e.define("react-dom",[],function(){var f=T.ReactDom;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.ReactDom)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.ReactDom;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/react-dom",[],function(){var f=T.ReactDom;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.ReactDom)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.ReactDom;return m(g)})}),e.define("react-dom/client",[],function(){var f=T.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.ReactDomClient)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.ReactDomClient;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/react-dom/client",[],function(){var f=T.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.ReactDomClient)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.ReactDomClient;return m(g)})}),e.define("react/jsx-runtime",[],function(){var f=T.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.ReactJsxRuntime)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.ReactJsxRuntime;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-runtime",[],function(){var f=T.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.ReactJsxRuntime)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.ReactJsxRuntime;return m(g)})}),e.define("react/jsx-dev-runtime",[],function(){var f=T.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.ReactJsxDevRuntime)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.ReactJsxDevRuntime;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-dev-runtime",[],function(){var f=T.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.ReactJsxDevRuntime)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.ReactJsxDevRuntime;return m(g)})}),e.define("antd",[],function(){var f=T.Antd;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.Antd)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.Antd;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/antd",[],function(){var f=T.Antd;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.Antd)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.Antd;return m(g)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var f=T.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.AntDesignIconBase)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.AntDesignIconBase;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var f=T.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.AntDesignIconBase)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.AntDesignIconBase;return m(g)})}),e.define("@ant-design/icons",[],function(){var f=T.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.AntDesignIcons)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.AntDesignIcons;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons",[],function(){var f=T.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.AntDesignIcons)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.AntDesignIcons;return m(g)})}),e.define("@ant-design/cssinjs",[],function(){var f=T.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.AntDesignCssinjs)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.AntDesignCssinjs;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/cssinjs",[],function(){var f=T.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.AntDesignCssinjs)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.AntDesignCssinjs;return m(g)})}),e.define("classnames",[],function(){var f=T.Classnames;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.Classnames)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.Classnames;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/classnames",[],function(){var f=T.Classnames;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.Classnames)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.Classnames;return m(g)})}),e.define("dayjs",[],function(){var f=T.Dayjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.Dayjs)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.Dayjs;return m(g)})}),e.define("@emailmaker/emailmaker/runtime/dayjs",[],function(){var f=T.Dayjs;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.Dayjs)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.Dayjs;return m(g)})}),e.define("@emailmaker/ui-kit",[],function(){var f=T.UiKit;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.UiKit)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.UiKit;return m(g)})}),e.define("@emailmaker/emailmaker/ui-kit",[],function(){var f=T.UiKit;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.UiKit)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.UiKit;return m(g)})}),e.define("@emailmaker/emailmaker/ui-kit/icons",[],function(){var f=T.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.UiKitIcons)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.UiKitIcons;return m(g)})}),e.define("@emailmaker/ui-kit/icons",[],function(){var f=T.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(u){return u===void 0?D.then(function(g){return m(g.UiKitIcons)}):m(u)}):f!==void 0?m(f):D.then(function(u){var g=u.UiKitIcons;return m(g)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Au=new Function("url","return import(url)");function Tu(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Vo(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Fa(e){return e.type==="umd"||e.resolve==="registry"}var Ru="If the plugin is built on globals, enable the compatibility layer: the `compatGlobals` option of the bundler plugin or `import '<package>/compat-globals'` before creating the editor.";function Ou(e){const t=Array.isArray(e)?e[0]:e;return Vo(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function ku(e,t){const n=Ou(e),r=Vo(e)?e:void 0,o=t instanceof Error?t.message:String(t),i=r&&Fa(r)&&!/compat/iu.test(o)?` ${Ru}`:"",s=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${i}`);return s.cause=t,{name:n,url:r?.url,error:s}}function Pu(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var Du=class{_context;_pluginRegistry;_options;_map=new Map;_optionsMap=new Map;_readyMap=new Map;_resolveMap=new Map;_initializingPlugins=new Map;_creatingPlugins=new Set;_initializedPlugins=new Set;_creationOrder=[];_lifecycleListeners=new Set;_activated=!1;constructor(e,t,n={}){this._context=e,this._pluginRegistry=t,this._options=n}activate(){return this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}activateSync(){this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}onLifecycle(e){return this._lifecycleListeners.add(e),{dispose:()=>this._lifecycleListeners.delete(e)}}_emitLifecycle(e){for(const t of Array.from(this._lifecycleListeners))try{t(e)}catch{}}async _resolveEntry(e){if(typeof e=="string"||typeof e=="symbol"){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);return{ctor:t}}if(typeof e=="function")return e.length===0?{ctor:await e()}:{ctor:e};if(Array.isArray(e)){const[t,n]=e;if(typeof t=="function")return{ctor:t,options:n};const r=await this._pluginRegistry.getAsync(t);if(!r)throw new Error(`Plugin "${String(t)}" not registered.`);return{ctor:r,options:n}}if(Vo(e))return this._resolveDescriptor(e);throw new Error(`Unknown plugin entry format: ${JSON.stringify(e)}`)}async _resolveDescriptor(e){const t=e.resolve??(e.type==="umd"?"window":"module");if(Fa(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Au(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let o;const i=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):Pu(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},s=()=>window.removeEventListener("error",i);window.addEventListener("error",i),r.onload=()=>{if(s(),o){n(o);return}t()},r.onerror=()=>{s(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const o=await this._resolveOrSkip(r);if(!o)continue;const i=this._createOrSkip(o.ctor,o.options);i&&!n.has(i)&&(n.add(i),t.push(i))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const a=await this._resolveOrSkip(s);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((s,a)=>{t.has(a)||r.push({key:a,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:a,plugin:c}=r[s];await this._initializingPlugins.get(c),await this._disposePlugin(c,c.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(c),this._resolveMap.delete(c),this._initializingPlugins.delete(c),this._initializedPlugins.delete(c);const l=this._creationOrder.indexOf(c);l>=0&&this._creationOrder.splice(l,1)}const o=[],i=new Set;for(const{ctor:s,options:a}of n){const c=this._createOrSkip(s,a);c&&!i.has(c)&&(i.add(c),o.push(c))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let i,s=!1;const a=()=>{s||(s=!0,i&&clearTimeout(i),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(i=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,a),o(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),o=this._createPluginInstance(e,r),i=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:i}),o.required?.(),this._map.set(n,o),this._creationOrder.push(o),this._setupReadyPromise(o)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=ku(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return Tu(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const o of t){if(this._initializedPlugins.has(o))continue;const i=this._initializingPlugins.get(o);if(i){n.add(i);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const i of r)this._initializingPlugins.set(i,o);n.add(o),o.finally(()=>{for(const i of r)this._initializingPlugins.get(i)===o&&this._initializingPlugins.delete(i)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const o=this._options.openEarlyWindow?.();try{await this._callSync(n,r,"init"),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}finally{o?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await this._callSync(n,r,"afterInit"),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(o){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:o})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}_callSync(e,t,n){this._emitLifecycle({type:`${n}:enter`,plugin:e,name:t});try{return e[n]?.()}finally{this._emitLifecycle({type:`${n}:leave`,plugin:e,name:t})}}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},xu=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const o of n)try{o.callback(t)}catch{}const r=n.filter(o=>!o.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(o=>(t.ctor=o,t.loading=void 0,this._notifyListeners(e,o),o));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!1};return r.push(o),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!0};return r.push(o),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(o=>o.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Mu=class{resolveRegistry;constructor(e){this.resolveRegistry=e}target(){return this.resolveRegistry()}get(e){return this.target().get(e)}getAsync(e){return this.target().getAsync(e)}add(e,t){return this.target().add(e,t)}addAll(e){return this.target().addAll(e)}addAsync(e,t){return this.target().addAsync(e,t)}has(e){return this.target().has(e)}isLoaded(e){return this.target().isLoaded(e)}override(e,t){return this.target().override(e,t)}on(e,t){return this.target().on(e,t)}once(e,t){return this.target().once(e,t)}off(e,t){return this.target().off(e,t)}keys(){return this.target().keys()}forContext(){return this.target().forContext()}},Pi=class{capacity;items=[];constructor(e){this.capacity=e}push(e){this.items.length>=this.capacity&&this.items.shift(),this.items.push(e)}snapshot(){return this.items.slice()}size(){return this.items.length}clear(){this.items=[]}};function Lu(e,t){return t+e}function Nu(){return typeof performance>"u"?Date.now():Lu(performance.now(),performance.timeOrigin)}var Fu="emailmaker:diagnostics",Bu="diagnostics",ju="diagnostics";function Di(e,t){return t?`${e}${e.includes("?")?"&":"?"}${ju}=1`:e}var yr;function Uu(){try{const e=new URLSearchParams(window.location.search).get(Bu);return e===null?void 0:e!=="0"}catch{return}}function Hu(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function $u(){try{const e=window.localStorage.getItem(Fu);return e===null?void 0:e==="1"}catch{return}}function Gt(){return yr===void 0&&(yr=typeof window>"u"?!1:Uu()??Hu()??$u()??!1),yr}function Vu(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var ve={initStart:"loader:init:start",coreReady:"loader:core:ready",initEnd:"loader:init:end",chunksLoaded:"app:chunks:loaded",showStart:"show:start",showEnd:"show:end",canvasCreated:"canvas:created",canvasLoaded:"canvas:loaded",canvasPainted:"canvas:painted",appVisible:"app:visible",editorVisible:"editor:visible",canvasSettled:"canvas:settled"},WI=Object.values(ve),zI=[ve.canvasPainted,ve.canvasSettled,ve.appVisible,ve.editorVisible],qu=5e3,Gu=3e3,xi="diagnosticsStore",fn,kt;function Mi(){return{marks:new Pi(qu),resources:new Pi(Gu)}}function Ba(){if(kt)return kt;const e=qo();return e?(kt=e[xi]??fn??Mi(),e[xi]=kt,fn=void 0,kt):(fn??=Mi(),fn)}function ie(e,t){Gt()&&Ba().marks.push({phase:e,at:Nu(),...t})}function qo(){if(typeof window.__emailmaker__<"u"&&window.__emailmaker__)return window.__emailmaker__;if(typeof window>"u")return;const e=window[Vu()];return e!==null&&typeof e=="object"?e:void 0}function Wu(e){const t=e.length,n=Ba();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function zu(){const e=qo();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Wu(e.diagnosticsBuffer)}var Ku="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Ve(){const e=new Error(Ku);return e.name="DestroyedInstanceError",e}function Yu(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function Zr(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const i=e,s=t;return i.length===s.length&&i.every((a,c)=>Zr(a,s[c]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&Zr(e[i],t[i]))}function ja(e,t){const n={watch(r){let o,i=!1;return e.watch(s=>{const a=t(s);i&&Zr(o,a)||(o=a,i=!0,r(a))})},select(r){return ja(n,r)}};return n}function ue(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(i){t=i,n=!0;for(const s of Array.from(r))s(i)},watch(i){return r.add(i),n&&i(t),{dispose:()=>r.delete(i)}},select(i){return ja(o,i)}};return o}var Xu=class{http;constructor(e){this.http=e}app_init_create=(e,t={})=>this.http.request({path:"/app/v1/app_init",method:"POST",body:e,type:Hd.UrlEncoded,...t})},Ua=class{http;constructor(e){this.http=e}get_translations2=({file:e,...t},n={})=>this.http.request({path:`/translations/v1/${e}`,method:"GET",...n});get_translations3=({id:e,file:t,...n},r={})=>this.http.request({path:`/translations/v1/${t}/${e}`,method:"GET",...r})};function Ju(e){return String(e||"").trim()||void 0}var Qu=class extends pe{deps;_app;_baseUrl;_appInit;_restBaseUrl;_prevApp;constructor(e){super(),this.deps=e,this.addDisposable(e.options.select(t=>this._slice(t)).watch(t=>this._start(t)))}get app(){return this._app}_slice(e){return Object.prototype.hasOwnProperty.call(e,"baseUrl")&&(this._baseUrl=Ju(e.baseUrl)),Object.prototype.hasOwnProperty.call(e,"appInit")&&(this._appInit=e.appInit),{appInit:this._appInit,user:e.user,project:e.project,baseUrl:this._baseUrl,restBaseUrl:this.deps.resolveRestBaseUrl(this._baseUrl),standalone:this.deps.isStandalone()}}_start(e){if(this._restBaseUrl!==e.restBaseUrl&&(this._restBaseUrl=e.restBaseUrl,this.deps.setRestBaseUrl(e.restBaseUrl)),e.standalone)return;const t=e.appInit||this.deps.fallbackAppInit,n=Promise.resolve(t({baseUrl:e.baseUrl,user:e.user,project:e.project,prevApp:this._prevApp}));this._app=n,n.then(r=>{this._app===n&&(this._prevApp=r)},()=>{}),this.deps.publish(n)}},Go=H("AppInitService");function Zu(e){return async()=>{const t=await e();return(await new Xu(t).app_init_create({})).data}}function ef(e){e.injectFactory(Go,(t,n)=>{if(n)return n;const r=new Qu({options:e.getInstance(ye),isStandalone:()=>!!e.getInstance(Be),resolveRestBaseUrl:o=>o?ki(o):ki()||void 0,setRestBaseUrl:o=>{e.getInstance(Bd)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:Zu(()=>e.getInstanceAsync(Zd)),publish:o=>{e.inject(We,o)}});return e.getInstance(W)?.addDisposable(r),r},!0)}var Yn=H("documentSession.emailDocuments");function ht(e){return e?.getInstance(Yn)}var tf=H("RevisionServiceFlag");function Ha(e){return e.getOrCreateInstance(tf,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function $a(e){return Ha(e).isEnabled()}var Va=H("EmailRightsResolver");function nf(e,t){return e.onInject(n=>{n===Va&&t()})}function qa(e,t){const n=e.getInstance(Va);return n?n(t):!0}var Wo={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Ga=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],Wa=2e4,rf=Ga.reduce((e,t)=>e+Wo[t],0),za=Wa+rf+3e3;function of(e){return Ga.reduce((t,n)=>t+Ka(n,e),0)}function Ka(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:Wo[e]}function Ya(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:za}function Xa(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:Wa}function nn(e=za){return e+3e3}function Ja(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var sf=()=>nn();function af(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function cf(e){return t=>af(e.getOrCreateInstance($.BEFORE_SAVE_EMAIL,()=>new Ge).fire(t),sf())}var Li=Symbol.for("emailmaker.saveRefusedError"),Ni=Symbol.for("emailmaker.integratorSaveTimeoutError");function Qa(e,t,n,r){return e!==t?Function.prototype[Symbol.hasInstance].call(e,r):typeof r=="object"&&r!==null&&n in r}var qe=class Za extends Error{reason;static[Symbol.hasInstance](t){return Qa(this,Za,Li,t)}constructor(t){super(`[emailmaker] save refused: ${t}`),this.name="SaveRefusedError",this.reason=t,Object.defineProperty(this,Li,{value:!0})}},ec=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[emailmaker] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Xn=class tc extends Error{timeoutMs;static[Symbol.hasInstance](t){return Qa(this,tc,Ni,t)}constructor(t,n="handleSaveEmail",r="email"){super(`[emailmaker] ${n} did not respond within ${t}ms — the ${r} was not saved`),this.timeoutMs=t,this.name="IntegratorSaveTimeoutError",Object.defineProperty(this,Ni,{value:!0})}};function he(e){return e.getOrCreateInstance(Zt,()=>new tn)}var nc=new WeakMap,eo=new WeakMap;function we(e){return nc.get(e)??0}function xn(e,t){let n=eo.get(e);return n||(n=new Set,eo.set(e,n)),n.add(t),()=>{n?.delete(t)}}function lf(e){nc.set(e,we(e)+1),eo.get(e)?.forEach(t=>t())}function to(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var df=H("documentSession.canvasReceipts");function uf(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const o={guid:n,version:r};return e=o,()=>{e===o&&(e=void 0)}},note(n,r){const o=to(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(o,n)}},read(n){if(!e)return;const{scope:r}=t,o={guid:e.guid,rev:e.version()};return r.originId!==null?{...o,changeId:t.changeId,originId:r.originId}:{...o,changeId:r.generation===n?t.changeId:0}}}}function rc(e){return e.getOrCreateInstance(df,uf)}var ff=2e3,pf=_u+cu+ff;function hf(e,t=pf){return async()=>{const n=he(e);let r;const o=new Promise(i=>{r=setTimeout(()=>i("silent"),t)});try{const i=rc(e).read(we(n)),s=await Promise.race([n.sendAsync(z.SANDBOX_CANVAS_SYNCED,i?{applied:i}:void 0,!1),o]);if(s==="silent"||s&&!s.synced)throw s==="silent"||s?.unsent,new qe("canvas-not-synced")}finally{clearTimeout(r)}}}var mf="em_autosave_pending";function Mn(e){return`${mf}_${e}`}function no(e,t){try{return sessionStorage.setItem(Mn(e),JSON.stringify(t)),!0}catch{return!1}}function Jn(e){try{const t=sessionStorage.getItem(Mn(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(Mn(e)),null):n}catch{return null}}function tt(e){try{sessionStorage.removeItem(Mn(e))}catch{}}function zo(e){return`block:${e}`}function oc(e,t){return t?zo(e):e}function Ko(e,t){(Jn(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&tt(e)}function gf(e){return e!=null&&e!==""}function ic(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var Fi;function vf(){return ic(Kn.em_revisions_v2)??!0}function bf(){return Fi??=vf(),Fi}function Ot(e){return $a(e)&&bf()}function yf(){return!1}var sc;function Wt(e,t){return sc?.capture(e,t)}function _f(e,t){return sc?.captureMessage(e,t)}var Ef=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],wf=200;function ac(e=new Set){const t=new Set;return(n,r)=>{if(!Ef.some(([i,s])=>!e.has(i)&&s.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=wf&&t.clear(),t.add(o))}}function cc(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:ac()}}var Sf=cc();function Ke(e){return e?.getInstance(Uo)??Sf}function If(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function pn(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Oe=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${pn(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${pn(this.oldText)}")`:`(replace@${this.oldPosition} "${pn(this.oldText)}" with "${pn(this.newText)}")`}};function Bi(e,t){return e===null||e.length===0?t:new Cf(e,t).compress()}var Cf=class Me{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[c,l]=Me._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(c),o=l;continue}if(r.newPosition<o.oldPosition){const[c,l]=Me._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(c),r=l;continue}let s,a;if(o.oldEnd===r.newEnd)s=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[c,l]=Me._splitPrev(r,o.oldLength);s=c,a=o,r=l,o=this._getCurr(++n)}else{const[c,l]=Me._splitCurr(o,r.newLength);s=r,a=c,r=this._getPrev(++t),o=l}this._result[this._resultLen++]=new Oe(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const i=Me._merge(this._result);return Me._removeNoOps(i)}_acceptCurr(t){this._result[this._resultLen++]=Me._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=Me._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new Oe(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Oe(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),o=t.newText.substr(n);return[new Oe(t.oldPosition,t.oldText,t.newPosition,r),new Oe(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new Oe(t.oldPosition,r,t.newPosition,t.newText),new Oe(t.oldPosition+n,o,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,o=t[0];for(let i=1;i<t.length;i++){const s=t[i];o.oldEnd===s.oldPosition?o=new Oe(o.oldPosition,o.oldText+s.oldText,o.newPosition,o.newText+s.newText):(n[r++]=o,o=s)}return n[r++]=o,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let o=0;o<t.length;o++){const i=t[o];i.oldText!==i.newText&&(n[r++]=i)}return n}};function Af(e){return new Oe(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Tf(e){return e.map(Af)}function ji(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Rf(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const o=t[r];n=n.slice(0,o.oldPosition)+o.newText+n.slice(o.oldEnd)}return n}function Of(e,t,n){let r=0;const o=e.start===e.end;for(const i of t){const s=i.newLength-i.oldLength;if(i.oldLength===0){const a=i.oldPosition;if(o&&a===e.start)r+=n==="after"?s:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=s)}continue}if(o){if(e.start>=i.oldEnd)r+=s;else if(e.start>i.oldPosition)return null;continue}if(e.start>=i.oldEnd)r+=s;else if(e.end>i.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var at=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Ui=0,kf=Math.random().toString(36).slice(2,8);function Pf(){return Ui+=1,`doc-${kf}-${Ui}`}function Df(e){const t=e.createBuffer(),n=e.docId??Pf();let r=e.serverId??null,o=0,i=null,s=e.attributes??{};const a=new Set;let c=!1,l=!1,d;const h=new Set;let b=null;const v=()=>(b?.version!==o&&(b={version:o,value:t.read()}),b.value),w=C=>Object.entries(C).some(([y,S])=>s[y]!==S);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:i,attributes:s}),getContent:v,mutate(C,{source:y}){if(c)return o;const S=C.changes?.length?C.changes:void 0,T=S?Rf(v(),S):C.content!==void 0?C.content:void 0,B=T!==void 0&&T!==v(),D=C.attributes!==void 0&&w(C.attributes);if(!B&&!D)return o;const O=!(o>(i??-1)),A=D?Object.keys(C.attributes).filter(R=>s[R]!==C.attributes[R]):[];B&&t.write(T),D&&(s={...s,...C.attributes}),o+=1,y!=="user"&&O&&(i=o);const x={source:y,version:o,changes:S,...B?{content:!0}:{},...A.length>0?{attributes:A}:{}};return a.forEach(R=>R(x)),o},markSaved(C,y){const S={serverId:r,savedVersion:i};y!==void 0&&(r=y),(i===null||C>i)&&(i=C),(S.serverId!==r||S.savedVersion!==i)&&a.forEach(T=>T({source:"system",version:o}))},markUnsaved(){c||i===null||i<o||(i=o-1,a.forEach(C=>C({source:"system",version:o})))},markReady(){l||d!==void 0||(l=!0,h.forEach(C=>C.resolve()),h.clear(),a.forEach(C=>C({source:"system",version:o})))},isReady:()=>l,markFailed(C){l||d!==void 0||c||(d=C,h.forEach(y=>y.reject(new at(C))),h.clear(),a.forEach(y=>y({source:"system",version:o})))},failure:()=>d,whenReady(){return l?Promise.resolve():d!==void 0?Promise.reject(new at(d)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((C,y)=>{h.add({resolve:C,reject:y})})},subscribe(C){return a.add(C),()=>a.delete(C)},isNew:()=>r===null,isDirty:()=>o>(i??-1),isDisposed:()=>c,dispose(){c=!0,h.forEach(C=>C.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),h.clear(),a.clear(),t.dispose()}}}var xf=500,Mf=100,_r=0;function Hi(e,t){let n=0;for(const r of t){if(r.oldPosition>e||r.oldPosition===e&&r.oldLength>0)break;if(r.oldEnd>e)return r.newEnd;n=r.newEnd-r.oldEnd}return e+n}function Lf(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function Nf(e,t){const n=e?.after;return n?{...e,after:{start:Hi(n.start,t),end:Hi(n.end,t)}}:e}function Ff(e,t={}){const n=t.groupIntervalMs??xf,r=t.maxSteps??Mf,o=t.now??(()=>0);let i=[],s=0,a=_r+=1,c=null,l,d,h,b=!1,v=!1,w=!1,C=!1;const y=new Set,S=()=>y.forEach(u=>u()),T=(u,g)=>{if(u.length){w=!0;try{e.mutate({changes:u},{source:g})}finally{w=!1}}},B=u=>T(u,"user"),D=u=>{const g=l?.from??o();if(v&&c!==null&&b===(l!==void 0)&&g>=c&&g-c<n){const k=i[s-1];i[s-1]={changes:Bi(k.changes,u),selection:Lf(k.selection,d)}}else i=i.slice(0,s),i.push({changes:u,selection:d}),s=i.length,v=!0,i.length>r&&(i=i.slice(i.length-r),s=i.length,a=_r+=1);c=l?.to??g,b=l!==void 0,S()},O=()=>{v=!1,c=null},A=u=>{if(!u.length)return;const g=i.length>s;if(g&&(i=i.slice(0,s)),s>0){const k=i[s-1];i[s-1]={changes:Bi(k.changes,u),selection:Nf(k.selection,u)}}O(),g&&S()},x=e.subscribe(({source:u,changes:g})=>{if(!(C||w||!g?.length)){if(u==="remote"){R();return}if(u!=="user"){A(g);return}D(g)}}),R=()=>{i=[],s=0,O(),a=_r+=1,S()},m=(u,g)=>{h=g;try{B(u)}finally{h=void 0}},f=(u=!1)=>{if(s===0)return!1;const g=i[s-1],k=Tf(g.changes);return ji(e.getContent(),k)?(m(k,u?{kind:"undo",selection:g.selection?.before}:void 0),s-=1,O(),!0):(i=i.slice(0,s-1),s=i.length,O(),S(),!1)};return{recordAt(u,g,k){const M=l,_=d;l=u,d=k;try{return g()}finally{l=M,d=_}},activeMove:()=>h,canUndo:()=>s>0,canRedo:()=>s<i.length,undo(){f(!0)&&S(),O()},redo(){if(s>=i.length){O();return}const u=i[s];if(!ji(e.getContent(),u.changes)){i=i.slice(0,s),O(),S();return}m(u.changes,{kind:"redo",selection:u.selection?.after}),s+=1,O(),S()},clear:R,closeGroup:O,applyWithoutHistory(u){const g=e.get().version;if(T(u,"system"),e.get().version===g){O();return}A(u)},getPast:u=>i.slice(0,s).reverse().slice(0,u).map(g=>g.changes),getFuture:u=>i.slice(s).reverse().slice(0,u).map(g=>g.changes),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(u){if(u.stackId!==a||u.index>s)return!1;for(;s>u.index;)if(!f())return S(),!1;return S(),!0},subscribe(u){return y.add(u),()=>y.delete(u)},dispose(){C=!0,x(),y.clear(),i=[],s=0}}}var Bf=["edit","move","resize","insert"];function Er(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function jf(e){return typeof e=="string"?e:null}function Uf(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function Hf(e){return Bf.includes(e)?e:null}function $f(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:jf(t.originId),changeId:Er(t.changeId),rev:Er(t.rev),baseRev:Er(t.baseRev),expected:Uf(t.expected),intent:Hf(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var $i=Symbol.for("emailmaker.blockSaveFlight"),lc=Symbol.for("emailmaker.blockSaveSessionQueue"),ro=new WeakMap;function dc(e,t){return Object.isExtensible(e)||t in e?e[t]:ro.get(e)?.get(t)}function uc(e,t,n){if(t in e||Object.isExtensible(e)){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0});return}const r=ro.get(e)??new Map;r.set(t,n),ro.set(e,r)}function Vf(e,t){uc(e,lc,t)}function qf(e,t){const n=(dc(e,$i)??Promise.resolve()).then(t,t);return uc(e,$i,n.catch(()=>{})),n}function Gf(e,t){return dc(e,lc)?.(t)??qf(e,t)}var Pt=new Map,Vi=new Map;function Wf(e){return Pt.set(e,(Pt.get(e)??0)+1),()=>{const t=(Pt.get(e)??1)-1;if(t>0){Pt.set(e,t);return}Pt.delete(e);const n=Vi.get(e);Vi.delete(e),n?.forEach(r=>r())}}var Yo=e=>e.replace(/\r\n?/g,`
|
|
998
|
-
`),zf=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function oo(e){return typeof e=="string"&&zf.test(e)}var Kf=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function Yf(){return typeof navigator<"u"&&navigator.onLine===!1}function Xf(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const o=r.data;typeof r.data=="object"&&o.error!=null&&t.push(o.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function fc(e){if(!e)return!1;if(typeof e=="string"){const n=e.toLowerCase();return n.includes("fetch")||n.includes("network")||n.includes("timeout")||n.includes("failed to fetch")||n.includes("load failed")||n.includes("networkerror")}if(e instanceof Error)return fc(e.message);if(typeof e!="object")return!1;const t=e;return t.status==="FETCH_ERROR"||t.status==="TIMEOUT_ERROR"||t.status==="PARSING_ERROR"?!0:typeof t.status=="number"?t.status===0||t.status===408||t.status>=500:!1}function Jf(e){return Yf()?!0:Xf(e).some(fc)}var pc=new WeakSet,hc=new WeakMap;function mc(e){typeof e=="object"&&e!==null&&pc.add(e)}function Qf(e,t){typeof e=="object"&&e!==null&&hc.set(e,t)}function Zf(e){return typeof e=="object"&&e!==null?hc.get(e):void 0}function ep(e){return e instanceof Xn||e instanceof ec||typeof e=="object"&&e!==null&&pc.has(e)}function tp(e){return e instanceof qe||gc(e)||e instanceof Kf||ep(e)}function gc(e){return Xo(e)?.v2Error?.data?.code==="blocks.block_locked"}function qi(e){return Xo(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function Xo(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function np(e){if(e instanceof qe)return e.reason==="canvas-not-synced";if(tp(e))return!1;const t=Xo(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?qi(e):!0}return Jf(e)||qi(e)}var vc="draft";function ut(e){return e==null||e===""?vc:String(e)}function Ln(e){return e==null||e===""?`${io}${vc}`:`${io}${String(e)}`}var io="block:";function ne(e){return e?.startsWith(io)===!0}function mt(e){return ne(e.sessionKey())?void 0:e.current()}function rt(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return ie(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(ie(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const i=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw Lo(o)?(`${e}`,{...n}):(`${e}`,{error:Ja(o),...n},void 0),o})}var rp=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function op(e){const t=e?.trim()??"";if(!rp.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function Ut(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Jo(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function ip(e,t={}){const n=Ut((e??[]).filter(r=>r?.html?.trim()));return Jo(n,t)?n:null}function sp(e,t){const n=Date.parse(Ut(e)?.modified??""),r=ip(e),o=Date.parse(r?.modified??""),i=t===void 0||Number.isFinite(o)&&o>t,s=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:i?r:null,...s.length?{latestAt:Math.max(...s)}:{}}}function Gi(e,t,n){const r=Ut((e??[]).filter(c=>c?.html?.trim())),o=Date.parse(r?.modified??""),i=Date.parse(Ut((n??[]).filter(c=>c?.html?.trim()))?.modified??""),s=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(i>o),a=[Date.parse(Ut(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:s&&Jo(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function ap({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Wi=["recovery","plugin","rest"],cp=["subject","preheader"];function lp(e){let t={},n;for(let o=Wi.length-1;o>=0;o--){const i=e.get(Wi[o]);i&&(i.attributes&&(t={...t,...i.attributes}),i.content!==void 0&&(n=i.content))}const r=e.get("plugin")?.attributes;for(const o of cp){const i=r?.[o];typeof i=="string"&&i!==""&&(t={...t,[o]:i})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Nn(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Yo(t.content):void 0,o=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...o?{changes:[new Oe(0,n,0,r)]}:{}},{source:"remote"})}var wr=e=>typeof e=="string"?e.trim():"";function dp(e,t,n,r){const{version:o,attributes:i}=e.get(),s=i,a=r==="snapshot"||r==="anchor",c=a?s.author:void 0,l=a?s.date_gmt:void 0,d=wr(s.title)||wr(s.subject)||wr(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:d,subject:s.subject,preheader:s.preheader,description:s.description,common_styles:s.common_styles||"",meta:s.meta,utm_parameters:s.utm_parameters,parent_email:s.parent_email,is_template:s.is_template||!1,is_inited:s.is_inited,tags:s.tags,emailtags:s.emailtags,group:s.group,projectCategories:s.projectCategories,renderGuid:e.get().docId,project:t.project??s.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...c!=null&&c!==""?{author:c}:{},...l?{excerpt:l}:{}}}}var up=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function fp(e){const t={};for(const n of up)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function pp(e,t,n,r,o,i){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(o);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,o):t.saveAutosave(r,o,i==null?void 0:{wpId:i})}function je(e,t=!1){const n={};for(const r of Object.keys(e)){let o=e[r];o!==void 0&&!(typeof o=="number"&&Number.isNaN(o))&&(t&&typeof o=="object"&&o!==null&&(o=je(o)),n[r]=o)}return n}function hp(e){return typeof e=="string"&&e.includes("autosave")}var mp=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function bc(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!mp.has(t))):{}}function wt(e,t,n={}){e&&e.mutate({attributes:gp(e.get().attributes,t)},{source:n.source??"user"})}function gp(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Qo(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function vp(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function yc(e){if(!e)return null;const t=bc(e);return e.common_styles!==void 0&&(t.common_styles=vp(e.common_styles)),Qo(e.html,t)}function _c(e){return e?Qo(e.html,je(bc(e))):null}var bp=["common_styles","subject","preheader","meta"];function zi(e){if(!e?.html?.trim())return null;const t={};for(const n of bp)yp(n,e[n])&&(t[n]=e[n]);return Qo(e.html,t)}function yp(e,t){return e==="common_styles"?typeof t=="string"&&t.startsWith("{"):e==="meta"?typeof t=="object"&&t!==null&&!Array.isArray(t):typeof t=="string"}var _p=["modified","lock","wpId","secretHash"];function Ki(e){if(!e)return null;const t={};for(const n of _p)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Ep=10,wp=(e,t)=>e.key===t.key&&Sp(e.serverId,t.serverId),Sp=(e,t)=>e==null||e===t;function Ip(e){return typeof e?.then=="function"}var Yi=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Ec=e=>{e.request.serverId!=null&&!Qn(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},Cp=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),Qn=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Xi=(e,t)=>t?.content!==void 0&&ap({hasUnsavedUserEdit:Qn(e)})==="skip",Ji=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},Ap=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),Tp=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent(),e.userTouched.clear(),e.document.get().docId))},Rp=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,i])=>e.attributes[o]!==i)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Op=e=>{const t=lp(e.reports),n=Rp(e.lastMerged,t);e.lastMerged=t,e.broughtContent=Zn(t.content)??e.broughtContent,n&&(Nn(e.document,n),Ec(e))},Sr=(e,t)=>{if(!e.ready&&!Qn(e)){Op(e);return}e.broughtContent=Zn(t?.content)??e.broughtContent,Nn(e.document,t)},Zn=e=>e===void 0?void 0:Yo(e),kp=(e,t)=>t.content===void 0||Zn(t.content)!==e.broughtContent||!Qn(e)?t:{...t,content:void 0},Pp=e=>{const{attributes:t,serverId:n,docId:r}=e.document.get();return{...t,html:e.document.getContent(),id:n??void 0,isNew:n==null,renderGuid:r}};function Dp(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:i,canEdit:s,notifyBeforeSave:a,awaitCanvasSynced:c,savedEchoForm:l=p=>p,queuesOutsideWrites:d,onAdapterError:h,onTimeout:b}=e;let v,w;const C=new Set,y=new Set,S=()=>C.forEach(p=>p()),T=(p,E)=>{if(!(p.closed||p.ready)){if(p.error!==void 0){p.document.markFailed(p.error),p.document.get().docId;return}Ec(p),p.ready=!0,p.document.markReady(),p.document.get().docId,[...p.reports.keys()]}},B=(p,E,P)=>{h?.(E.id,P),!(!E.required||p.closed)&&(p.error=P,p.document.get().docId,E.id,S())},D=(p,E)=>{const P=new Set(E.map(q=>q.id));E.forEach(q=>{q.watch&&p.watchers.push(q.watch(G=>p.closed?!1:p.ready&&(Xi(p,G)||p.contentShown===!0&&G?.content!==void 0)?(p.document.get().docId,q.id,!1):(G&&p.reports.set(q.id,G),Sr(p,G),G?.content!==void 0&&(p.showFill=void 0),!0)))});const N=(q,G)=>{if(!p.closed){if(!q.required&&Xi(p,G)){p.document.get().docId,q.id,q.loaded?.(!1);return}G&&(p.reports.set(q.id,G),q.id==="plugin"&&Ji(p,G)),Sr(p,G),q.loaded?.(G!==null)}},U=()=>{P.size>0||p.closed||(Yi(p),T(p,[]))},Y=[];if(E.forEach(q=>{let G;try{G=q.load()}catch(ee){B(p,q,ee),P.delete(q.id);return}if(Ip(G)){Y.push({id:q.id,required:q.required,load:()=>G,...q.loaded?{loaded:ee=>q.loaded?.(ee)}:{}});return}N(q,G),P.delete(q.id)}),Y.length===0){U();return}p.timer=setTimeout(()=>{p.timer=void 0,b?.([...P]),p.document.get().docId,[...P],T(p,[...P])},n),p.timer.unref?.(),Y.forEach(q=>{q.load().then(G=>N(q,G)).catch(G=>{B(p,q,G)}).finally(()=>{P.delete(q.id),U()})})},O=async(p,E,P)=>{if(P==="snapshot"||P==="anchor")return;const N=i?.();if(N)return N.resolve({project:E.project??p.project,tags:(p.tags??[]).map(U=>({name:U}))})},A=p=>{if(p.lock===!0&&s?.(p)===!1)return new qe("locked");const E=p.tags?.length??0,P=p.emailtags?.length??0;if(Math.max(E,P)>Ep)return new qe("too-many-tags")},x=(p,E)=>{const P=p.document.get().serverId;P!=null&&(p.createKey=void 0),!(E||P==null)&&(p.recoveryFacts={emailId:P,historyLoaded:!0,isRecovering:!1},ne(p.request.key)||(p.request={...p.request,key:ut(P),serverId:P}))},R=(p,E,P)=>{if(p.closed||P?.id==null)return;const N=p.document.get().serverId,U=N!=null;U&&N!==String(P.id)||(p.document.markSaved(E,String(P.id)),x(p,U),p.document.get().serverId,S())},m=(p,E,P)=>{if(!(E==="materialize"||E==="publish"&&p.document.get().serverId==null))return P;const N=p.createKey,U=N&&N.project===P.project?N:{key:Ce(),project:P.project};return p.createKey=U,{...P,idempotencyKey:U.key}},f=async(p,E,P)=>{try{await p.document.whenReady()}catch(ee){return p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,!1}if(p.closed)return!1;const N=A(p.document.get().attributes);if(N)return p.saveError=N,p.saveFailures+=1,p.failedIntent=E,N.reason,S(),!1;if(a&&(await a(Pp(p)).catch(()=>{}),p.closed))return!1;if(c){try{await c()}catch(ee){return p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,S(),!1}if(p.closed)return!1}if(Cp(p))return E==="snapshot"||(p.saveError=new qe("empty-content"),p.saveFailures+=1,p.failedIntent=E,S()),!1;let U;try{U=await O(p.document.get().attributes,P,E)}catch(ee){return p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,S(),!1}if(p.closed)return!1;const{payload:Y,version:q}=dp(p.document,P,U,E),G=m(p,E,Y);p.document.get().docId;try{const ee=p.document.get().serverId!=null,L=await pp(r(),o(p.request.key),E,p.document.get().serverId,G,p.document.get().attributes.wpId);if(p.closed)return!0;let Q;if(E==="snapshot"||E==="anchor"){const oe=L?.modified!=null?Date.parse(L.modified):NaN;Q=Number.isFinite(oe)?oe:Date.now(),p.snapshotVersion=q,p.lastRevisionAt=Q}else{p.document.markSaved(q,L?.id!=null?String(L.id):void 0),p.savedContent=G.html;const oe=L;Nn(p.document,Ki(oe&&{wpId:oe.wpId,secretHash:oe.secretHash})),p.broughtContent=Zn(l(G.html))}x(p,ee),p.saveError=void 0,p.saveFailures=0,p.failedIntent=void 0,p.document.get().serverId,S();const Z={intent:E,serverId:p.document.get().serverId,created:!ee,...Q!==void 0?{revisionAt:Q}:{}};return y.forEach(oe=>oe(Z)),!0}catch(ee){return(E==="publish"||E==="materialize")&&Zf(ee)?.then(L=>R(p,q,L)),p.saveError=ee,p.saveFailures+=1,p.failedIntent=E,p.saveFailures,S(),!1}},u=p=>{p.closed=!0,p.watchers.forEach(E=>E()),p.watchers=[],Yi(p),p.history.dispose(),p.document.dispose()},g=()=>{v&&(u(v),v=void 0)},k=()=>{w&&(u(w),w=void 0)},M=(p,E,P)=>{let N=!1;E.show&&(p.show?.id!==E.show.id||p.show.token!==E.show.token)&&(p.show=E.show,N=!0,{docId:p.document.get().docId,...E.show});const U=P==="show"?_c(E.patch):null;if(U){p.reports.set("plugin",U),Ji(p,U);const Y=kp(p,U);Sr(p,Y),Tp(p,Y)}N&&S()},_=(p,E={})=>j(v,p,E),I=()=>v&&ne(v.request.key??"")?w:v,F=p=>({error:p?.saveError,failures:p?.saveFailures??0,saving:p?.saving===!0,failedIntent:p?.failedIntent}),j=(p,E,P)=>!p||p.closed||E==="materialize"&&p.document.get().serverId!=null?Promise.resolve(!1):p.saving?E==="snapshot"||E==="materialize"?Promise.resolve(!1):(p.inFlight??Promise.resolve(!1)).then(()=>j(p,E,P)):(p.saving=!0,S(),p.inFlight=f(p,E,P).finally(()=>K(p)),p.inFlight),K=p=>{p.saving=!1,p.inFlight=void 0,v===p&&!p.closed&&S()},de=(p,E)=>{if(p.closed)return E();if(p.saving)return(p.inFlight??Promise.resolve(!1)).then(()=>de(p,E));p.saving=!0,S();const P=Promise.resolve().then(E);return p.inFlight=P.then(()=>!0,()=>!1).finally(()=>K(p)),P},se=(p,E)=>{const P=p.document.get().serverId,N=P==null?void 0:Wf(P);return de(p,E).finally(N)},X=(p,E="open",P=!1)=>{if(v&&!v.closed&&E!=="new"&&wp(v.request,p))return M(v,p,E),v.document;g(),P||k();const N=Df({createBuffer:()=>If(""),serverId:p.serverId??null}),U={request:p,show:p.show,document:N,history:Ff(N,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return v=U,Vf(N,Y=>d?.(U.request.key)===!0?se(U,Y):void 0),U.watchers.push(Ap(U)),N.get().docId,p.serverId,D(U,t(p,{publishRecoveryFacts(Y){U.closed||(U.recoveryFacts=Y,S())},readShownContent:()=>U.closed?null:U.document.getContent(),readWpId:()=>U.closed?void 0:U.document.get().attributes.wpId})),S(),N},J=(p,E,P)=>({key:ne(p)?p:Ln(p),serverId:E?.id!=null?String(E.id):null,email:E,show:P});return{openWith:X,open:(p,E={})=>X({key:ut(p),serverId:p,email:E.email,patch:E.patch,show:E.show},"open"),openDraft:(p,E={})=>X({key:ut(void 0),serverId:null,email:p,patch:E.patch,show:E.show},"open"),startNewDraft:(p,E={})=>X({key:ut(void 0),serverId:null,email:p,patch:E.patch,show:E.show},"new"),reload:(p,E={})=>X({key:ut(p),serverId:p,email:E.email,patch:E.patch,show:E.show},"new"),openBlock:(p,E,P)=>X(J(p,E,P),"open"),reloadBlock:(p,E,P)=>X(J(p,E,P),"new"),openBlockOver:(p,E)=>{const P=J(p,E);return v&&!v.closed&&v.request.key===P.key?v.document:(v&&!v.closed&&!ne(v.request.key)&&(k(),w=v,v=void 0),X(P,"open",!0))},resumeSuspended:()=>{if(w)return g(),v=w,w=void 0,S(),v.document},hasSuspended:()=>!!w,suspendedDocument:()=>w?.document,show:(p,E)=>{const P=v;if(!(!P||P.closed))return X({...P.request,patch:p,show:E},"show")},current:()=>v?.document,noteServerFacts:({serverId:p,block:E},P)=>{const N=v;!N||N.closed||N.request.serverId!==p||ne(N.request.key??"")===E&&Nn(N.document,Ki(P))},save:_,saveEmail:(p,E={})=>j(I(),p,E),saveState:()=>F(v),emailSaveState:()=>F(I()),revisionFacts(){if(!v)return;const p=v.revisionFactsSnapshot;return p&&p.snapshotVersion===v.snapshotVersion&&p.lastRevisionAt===v.lastRevisionAt?p:(v.revisionFactsSnapshot={snapshotVersion:v.snapshotVersion,lastRevisionAt:v.lastRevisionAt},v.revisionFactsSnapshot)},recoveryFacts:()=>v?.recoveryFacts,history:()=>v?.history,forcedHeaders:()=>v?.forcedHeaders,beginForcedHeaders(p){v&&!v.closed&&(v.forcedHeaders=p)},endForcedHeaders(){for(const p of[v,w])p&&(p.forcedHeaders=void 0)},onSaved(p){return y.add(p),()=>y.delete(p)},showFacts:()=>v?.show,shownHeaders:()=>({...v?.shownHeaders}),showFill:()=>v?.showFill,beginShowFill(p){v&&!v.closed&&(v.showFill={showId:p,codeEdits:0})},noteCodeEdit(){v?.showFill&&(v.showFill.codeEdits+=1)},endShowFill(p){for(const E of[v,w])E?.showFill?.showId===p&&(E.showFill=void 0)},sessionKey:()=>v?.request.key,openError:()=>v?.error,subscribe(p){return C.add(p),()=>C.delete(p)},close(){!v&&!w||(g(),k(),S())}}}var Zo=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function ei(e){if(e instanceof Zo)return e.reason;if(e instanceof at)return ei(e.reason)}function xp(e){const t=e instanceof at?e.reason:e;return t instanceof Zo&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Mp(e){const t=ei(e);return t!==void 0&&t!=="unavailable"}function Lp(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Zo("not-found");return yc(n)}}}var wc=H("EmailPort");function Np(e){return e.getInstance(wc)}function Fp(e,t){e.inject(wc,t)}var Sc=H("documentSession.restEmailPortFactories");function Ic(e){return e.getInstance(Sc)!==void 0}function ct(e){const t=e.getInstance(Sc);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var Bp=H("EmailTermsResolver");function jp(e){return e.getInstance(Bp)}var Cc=H("EmailHistoryPort"),Up=H("BlockHistoryPort");function Ac(e){return e.getInstance(Up)}function Tc(e){return e.getInstance(Cc)}function Hp(e,t){e.inject(Cc,t)}var $p=2e3,Vp=5e3,qp=5,Gp=5e3,Wp=4;function zp(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function An(e,t){return e==null||t==null?!1:e.replaceAll(`\r
|
|
996
|
+
`,r=new Function("__amdEnv",n);r(e),typeof e.require=="function"&&typeof e.require.config=="function"&&e.require.config({baseUrl:"./",paths:{core:"emailmaker-core.091c986b.js",po:"emailmaker-po.091c986b.js",monaco:"static/monaco/index.CCINpETE.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(h){var f,p=function(){return f||(f=Promise.resolve().then(h))};return{then:function(b,x){return p().then(b,x)},catch:function(b){return p().catch(b)},finally:function(b){return p().finally(b)}}},o=i(function(){return e.require(["__delivery__/libs"]).then(function(h){return h[0]})});t.React=i(function(){return o.then(function(h){return h.React})}),t.ReactDom=i(function(){return o.then(function(h){return h.ReactDom})}),t.ReactDomClient=i(function(){return o.then(function(h){return h.ReactDomClient})}),t.ReactJsxRuntime=i(function(){return o.then(function(h){return h.ReactJsxRuntime})}),t.ReactJsxDevRuntime=i(function(){return o.then(function(h){return h.ReactJsxDevRuntime})}),t.AntDesignIconBase=i(function(){return o.then(function(h){return h.AntDesignIconBase})}),t.AntDesignCssinjs=i(function(){return o.then(function(h){return h.AntDesignCssinjs})}),t.Classnames=i(function(){return o.then(function(h){return h.Classnames})}),t.Dayjs=i(function(){return o.then(function(h){return h.Dayjs})});var s=i(function(){return Promise.all([o]).then(function(h){var f=h[0]||Object.create(null),p=Object.create(null);for(var b in f)Object.prototype.hasOwnProperty.call(f,b)&&(p[b]=f[b]);for(var x in p)Object.prototype.hasOwnProperty.call(p,x)&&(t[x]=p[x]);return p})}),a={Uuid:"the shared `uuid` package was removed from the editor runtime; bundle `uuid` into the plugin or use `crypto.randomUUID()`"},c=["then","toString","valueOf","constructor","inspect","$$typeof"];for(var l in a)Object.prototype.hasOwnProperty.call(a,l)&&t[l]===void 0&&(t[l]=(function(h,f){return new Proxy(Object.create(null),{get:function(p,b){if(!(typeof b=="symbol"||c.indexOf(b)!==-1))throw new Error("[shared-runtime] "+h+"."+String(b)+" is not available: "+f+".")}})})(l,a[l]));var u={},d={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",AntDesignIcons:"[runtime] `@ant-design/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKit:"[runtime] `@emailmaker/ui-kit` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKitIcons:"[runtime] `@emailmaker/ui-kit/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import '@emailmaker/emailmaker/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator."},m={Antd:"[runtime] `antd` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",AntDesignIcons:"[runtime] `@ant-design/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKit:"[runtime] `@emailmaker/ui-kit` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKitIcons:"[runtime] `@emailmaker/ui-kit/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version."},_=Object.create(null),v=function(h){for(var f=String(h&&h.stack||"").split(`
|
|
997
|
+
`),p="",b=0;b<f.length;b+=1){var x=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(f[b]);if(x){if(!p){p=x[1];continue}if(x[1]!==p)return x[1]}}return""},E=function(h){var f=v(new Error(h)),p=f?h+" Requested by: "+f+".":h;return e.__compatMissingReason=p,p};if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var f in h)Object.prototype.hasOwnProperty.call(h,f)&&(_[f]=h[f])},e.__compatPending){for(var y=0;y<e.__compatPending.length;y+=1)e.registerCompat(e.__compatPending[y]);e.__compatPending=void 0}for(var k in d)Object.prototype.hasOwnProperty.call(d,k)&&(function(h,f,p){var b=!1,x=function(){if(!(h in _))throw new Error(E(f));return _[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var N=x();return b||(b=!0),N},set:function(N){_[h]=N}}),Object.defineProperty(u,h,{configurable:!0,enumerable:!0,get:x,set:function(N){_[h]=N}})})(k,d[k],m[k]);var C=t;for(var F in u)Object.prototype.hasOwnProperty.call(u,F)&&(C===t&&(C=Object.create(t)),Object.defineProperty(C,F,Object.getOwnPropertyDescriptor(u,F)));var T=s,R=[],A=function(){for(var h=[],f=0;f<R.length;f+=1)(function(p){var b=t[p];b&&typeof b.then=="function"&&h.push(Promise.resolve(b).then(function(x){t[p]=x}))})(R[f]);return Promise.all(h)},D=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(A).then(function(){if(typeof D=="function")return D.call(e)})},typeof e.define=="function"){let h=function(f){if(!f||typeof f!="object"&&typeof f!="function"||f.__esModule)return f;if(O){var p=O.get(f);if(p)return p}var b=Object.create(null);Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var x=Reflect.ownKeys(f),N=0;N<x.length;N++){var S=x[N];if(S!=="__esModule"){var w=Object.getOwnPropertyDescriptor(f,S);w&&Object.defineProperty(b,S,w)}}return Object.prototype.hasOwnProperty.call(b,"default")||Object.defineProperty(b,"default",{enumerable:!0,value:f,writable:!1}),O&&O.set(f,b),b};var O=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var f=C.React;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.React)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.React;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/react",[],function(){var f=C.React;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.React)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.React;return h(b)})}),e.define("react-dom",[],function(){var f=C.ReactDom;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactDom)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactDom;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/react-dom",[],function(){var f=C.ReactDom;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactDom)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactDom;return h(b)})}),e.define("react-dom/client",[],function(){var f=C.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactDomClient)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactDomClient;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/react-dom/client",[],function(){var f=C.ReactDomClient;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactDomClient)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactDomClient;return h(b)})}),e.define("react/jsx-runtime",[],function(){var f=C.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactJsxRuntime)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactJsxRuntime;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-runtime",[],function(){var f=C.ReactJsxRuntime;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactJsxRuntime)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactJsxRuntime;return h(b)})}),e.define("react/jsx-dev-runtime",[],function(){var f=C.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactJsxDevRuntime)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactJsxDevRuntime;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-dev-runtime",[],function(){var f=C.ReactJsxDevRuntime;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.ReactJsxDevRuntime)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.ReactJsxDevRuntime;return h(b)})}),e.define("antd",[],function(){var f=C.Antd;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Antd)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Antd;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/antd",[],function(){var f=C.Antd;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Antd)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Antd;return h(b)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var f=C.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignIconBase)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignIconBase;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var f=C.AntDesignIconBase;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignIconBase)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignIconBase;return h(b)})}),e.define("@ant-design/icons",[],function(){var f=C.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignIcons)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignIcons;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons",[],function(){var f=C.AntDesignIcons;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignIcons)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignIcons;return h(b)})}),e.define("@ant-design/cssinjs",[],function(){var f=C.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignCssinjs)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignCssinjs;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/cssinjs",[],function(){var f=C.AntDesignCssinjs;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.AntDesignCssinjs)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.AntDesignCssinjs;return h(b)})}),e.define("classnames",[],function(){var f=C.Classnames;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Classnames)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Classnames;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/classnames",[],function(){var f=C.Classnames;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Classnames)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Classnames;return h(b)})}),e.define("dayjs",[],function(){var f=C.Dayjs;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Dayjs)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Dayjs;return h(b)})}),e.define("@emailmaker/emailmaker/runtime/dayjs",[],function(){var f=C.Dayjs;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.Dayjs)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.Dayjs;return h(b)})}),e.define("@emailmaker/ui-kit",[],function(){var f=C.UiKit;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.UiKit)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.UiKit;return h(b)})}),e.define("@emailmaker/emailmaker/ui-kit",[],function(){var f=C.UiKit;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.UiKit)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.UiKit;return h(b)})}),e.define("@emailmaker/emailmaker/ui-kit/icons",[],function(){var f=C.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.UiKitIcons)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.UiKitIcons;return h(b)})}),e.define("@emailmaker/ui-kit/icons",[],function(){var f=C.UiKitIcons;return f&&typeof f.then=="function"?f.then(function(p){return p===void 0?T.then(function(b){return h(b.UiKitIcons)}):h(p)}):f!==void 0?h(f):T.then(function(p){var b=p.UiKitIcons;return h(b)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var $f=new Function("url","return import(url)");function Hf(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function uo(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Dc(e){return e.type==="umd"||e.resolve==="registry"}var Vf="If the plugin is built on globals, enable the compatibility layer: the `compatGlobals` option of the bundler plugin or `import '<package>/compat-globals'` before creating the editor.";function Gf(e){const t=Array.isArray(e)?e[0]:e;return uo(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function qf(e,t){const n=Gf(e),r=uo(e)?e:void 0,i=t instanceof Error?t.message:String(t),o=r&&Dc(r)&&!/compat/iu.test(i)?` ${Vf}`:"",s=new Error(`Plugin "${n}" was skipped: it failed to load. ${i}${o}`);return s.cause=t,{name:n,url:r?.url,error:s}}function Wf(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var zf=class{_context;_pluginRegistry;_options;_map=new Map;_optionsMap=new Map;_readyMap=new Map;_resolveMap=new Map;_initializingPlugins=new Map;_creatingPlugins=new Set;_initializedPlugins=new Set;_creationOrder=[];_lifecycleListeners=new Set;_activated=!1;constructor(e,t,n={}){this._context=e,this._pluginRegistry=t,this._options=n}activate(){return this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}activateSync(){this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}onLifecycle(e){return this._lifecycleListeners.add(e),{dispose:()=>this._lifecycleListeners.delete(e)}}_emitLifecycle(e){for(const t of Array.from(this._lifecycleListeners))try{t(e)}catch{}}async _resolveEntry(e){if(typeof e=="string"||typeof e=="symbol"){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);return{ctor:t}}if(typeof e=="function")return e.length===0?{ctor:await e()}:{ctor:e};if(Array.isArray(e)){const[t,n]=e;if(typeof t=="function")return{ctor:t,options:n};const r=await this._pluginRegistry.getAsync(t);if(!r)throw new Error(`Plugin "${String(t)}" not registered.`);return{ctor:r,options:n}}if(uo(e))return this._resolveDescriptor(e);throw new Error(`Unknown plugin entry format: ${JSON.stringify(e)}`)}async _resolveDescriptor(e){const t=e.resolve??(e.type==="umd"?"window":"module");if(Dc(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await $f(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let i;const o=a=>{i||(a.filename===r.src?i=this._scriptExecutionError(e,a.error??a.message):Wf(a)&&(i=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},s=()=>window.removeEventListener("error",o);window.addEventListener("error",o),r.onload=()=>{if(s(),i){n(i);return}t()},r.onerror=()=>{s(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const i=await this._resolveOrSkip(r);if(!i)continue;const o=this._createOrSkip(i.ctor,i.options);o&&!n.has(o)&&(n.add(o),t.push(o))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const a=await this._resolveOrSkip(s);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((s,a)=>{t.has(a)||r.push({key:a,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:a,plugin:c}=r[s];await this._initializingPlugins.get(c),await this._disposePlugin(c,c.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(c),this._resolveMap.delete(c),this._initializingPlugins.delete(c),this._initializedPlugins.delete(c);const l=this._creationOrder.indexOf(c);l>=0&&this._creationOrder.splice(l,1)}const i=[],o=new Set;for(const{ctor:s,options:a}of n){const c=this._createOrSkip(s,a);c&&!o.has(c)&&(o.add(c),i.push(c))}this._activated&&await this._startPluginsBatch(i)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,i)=>{let o,s=!1;const a=()=>{s||(s=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(o=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,a),i(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),i=this._createPluginInstance(e,r),o=i.constructor.name;this._emitLifecycle({type:"created",plugin:i,name:o}),i.required?.(),this._map.set(n,i),this._creationOrder.push(i),this._setupReadyPromise(i)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=qf(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return Hf(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const i of t){if(this._initializedPlugins.has(i))continue;const o=this._initializingPlugins.get(i);if(o){n.add(o);continue}r.push(i)}if(r.length>0){const i=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,i);n.add(i),i.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===i&&this._initializingPlugins.delete(o)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const i=this._options.openEarlyWindow?.();try{await this._callSync(n,r,"init"),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(o){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:o})}finally{i?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await this._callSync(n,r,"afterInit"),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(i){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:i})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}_callSync(e,t,n){this._emitLifecycle({type:`${n}:enter`,plugin:e,name:t});try{return e[n]?.()}finally{this._emitLifecycle({type:`${n}:leave`,plugin:e,name:t})}}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},Kf=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const i of n)try{i.callback(t)}catch{}const r=n.filter(i=>!i.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(i=>(t.ctor=i,t.loading=void 0,this._notifyListeners(e,i),i));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!1};return r.push(i),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!0};return r.push(i),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(i=>i.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Yf=class{resolveRegistry;constructor(e){this.resolveRegistry=e}target(){return this.resolveRegistry()}get(e){return this.target().get(e)}getAsync(e){return this.target().getAsync(e)}add(e,t){return this.target().add(e,t)}addAll(e){return this.target().addAll(e)}addAsync(e,t){return this.target().addAsync(e,t)}has(e){return this.target().has(e)}isLoaded(e){return this.target().isLoaded(e)}override(e,t){return this.target().override(e,t)}on(e,t){return this.target().on(e,t)}once(e,t){return this.target().once(e,t)}off(e,t){return this.target().off(e,t)}keys(){return this.target().keys()}forContext(){return this.target().forContext()}},ns=class{capacity;items=[];constructor(e){this.capacity=e}push(e){this.items.length>=this.capacity&&this.items.shift(),this.items.push(e)}snapshot(){return this.items.slice()}size(){return this.items.length}clear(){this.items=[]}};function Xf(e,t){return t+e}function Jf(){return typeof performance>"u"?Date.now():Xf(performance.now(),performance.timeOrigin)}var Qf="emailmaker:diagnostics",Zf="diagnostics",ep="diagnostics";function rs(e,t){return t?`${e}${e.includes("?")?"&":"?"}${ep}=1`:e}var Fr;function tp(){try{const e=new URLSearchParams(window.location.search).get(Zf);return e===null?void 0:e!=="0"}catch{return}}function np(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function rp(){try{const e=window.localStorage.getItem(Qf);return e===null?void 0:e==="1"}catch{return}}function ln(){return Fr===void 0&&(Fr=typeof window>"u"?!1:tp()??np()??rp()??!1),Fr}function ip(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var Ee={initStart:"loader:init:start",coreReady:"loader:core:ready",initEnd:"loader:init:end",chunksLoaded:"app:chunks:loaded",showStart:"show:start",showEnd:"show:end",canvasCreated:"canvas:created",canvasLoaded:"canvas:loaded",canvasPainted:"canvas:painted",appVisible:"app:visible",editorVisible:"editor:visible",canvasSettled:"canvas:settled"},IC=Object.values(Ee),TC=[Ee.canvasPainted,Ee.canvasSettled,Ee.appVisible,Ee.editorVisible],op=5e3,sp=3e3,is="diagnosticsStore",On,Ht;function os(){return{marks:new ns(op),resources:new ns(sp)}}function xc(){if(Ht)return Ht;const e=fo();return e?(Ht=e[is]??On??os(),e[is]=Ht,On=void 0,Ht):(On??=os(),On)}function ae(e,t){ln()&&xc().marks.push({phase:e,at:Jf(),...t})}function fo(){if(typeof window.__emailmaker__<"u"&&window.__emailmaker__)return window.__emailmaker__;if(typeof window>"u")return;const e=window[ip()];return e!==null&&typeof e=="object"?e:void 0}function ap(e){const t=e.length,n=xc();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function cp(){const e=fo();return!e||!Array.isArray(e.diagnosticsBuffer)?0:ap(e.diagnosticsBuffer)}var lp="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Ke(){const e=new Error(lp);return e.name="DestroyedInstanceError",e}function up(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function vi(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const o=e,s=t;return o.length===s.length&&o.every((a,c)=>vi(a,s[c]))}const r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&vi(e[o],t[o]))}function Mc(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const a=t(s);o&&vi(i,a)||(i=a,o=!0,r(a))})},select(r){return Mc(n,r)}};return n}function ce(...e){let t=e[0],n=e.length>0;const r=new Set,i={get(){return n?t:void 0},set(o){t=o,n=!0;for(const s of Array.from(r))s(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return Mc(i,o)}};return i}var dp=class{http;constructor(e){this.http=e}app_init_create=(e,t={})=>this.http.request({path:"/app/v1/app_init",method:"POST",body:e,type:Rf.UrlEncoded,...t})},Lc=class{http;constructor(e){this.http=e}get_translations2=({file:e,...t},n={})=>this.http.request({path:`/translations/v1/${e}`,method:"GET",...n});get_translations3=({id:e,file:t,...n},r={})=>this.http.request({path:`/translations/v1/${t}/${e}`,method:"GET",...r})};function fp(e){return String(e||"").trim()||void 0}var pp=class extends ve{deps;_app;_baseUrl;_appInit;_restBaseUrl;_prevApp;constructor(e){super(),this.deps=e,this.addDisposable(e.options.select(t=>this._slice(t)).watch(t=>this._start(t)))}get app(){return this._app}_slice(e){return Object.prototype.hasOwnProperty.call(e,"baseUrl")&&(this._baseUrl=fp(e.baseUrl)),Object.prototype.hasOwnProperty.call(e,"appInit")&&(this._appInit=e.appInit),{appInit:this._appInit,user:e.user,project:e.project,baseUrl:this._baseUrl,restBaseUrl:this.deps.resolveRestBaseUrl(this._baseUrl),standalone:this.deps.isStandalone()}}_start(e){if(this._restBaseUrl!==e.restBaseUrl&&(this._restBaseUrl=e.restBaseUrl,this.deps.setRestBaseUrl(e.restBaseUrl)),e.standalone)return;const t=e.appInit||this.deps.fallbackAppInit,n=Promise.resolve(t({baseUrl:e.baseUrl,user:e.user,project:e.project,prevApp:this._prevApp}));this._app=n,n.then(r=>{this._app===n&&(this._prevApp=r)},()=>{}),this.deps.publish(n)}},po=U("AppInitService");function hp(e){return async()=>{const t=await e();return(await new dp(t).app_init_create({})).data}}function mp(e){e.injectFactory(po,(t,n)=>{if(n)return n;const r=new pp({options:e.getInstance(we),isStandalone:()=>!!e.getInstance(Ve),resolveRestBaseUrl:i=>i?Zo(i):Zo()||void 0,setRestBaseUrl:i=>{e.getInstance(Ef)?.setOptions(i?{baseUrl:i}:{})},fallbackAppInit:hp(()=>e.getInstanceAsync(Xd)),publish:i=>{e.inject(Xe,i)}});return e.getInstance(Y)?.addDisposable(r),r},!0)}var jt=U("documentSession.emailDocuments");function At(e){return e?.getInstance(jt)}var gp=U("RevisionServiceFlag");function Nc(e){return e.getOrCreateInstance(gp,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Fc(e){return Nc(e).isEnabled()}var Bc=U("EmailRightsResolver");function vp(e,t){return e.onInject(n=>{n===Bc&&t()})}function jc(e,t){const n=e.getInstance(Bc);return n?n(t):!0}var ho={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Uc=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],$c=2e4,bp=Uc.reduce((e,t)=>e+ho[t],0),Hc=$c+bp+3e3;function _p(e){return Uc.reduce((t,n)=>t+Vc(n,e),0)}function Vc(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:ho[e]}function Gc(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:Hc}function qc(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:$c}function En(e=Hc){return e+3e3}function Wc(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var yp=()=>En();function Ep(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function wp(e){return t=>Ep(e.getOrCreateInstance(H.BEFORE_SAVE_EMAIL,()=>new Je).fire(t),yp())}var ss=Symbol.for("emailmaker.saveRefusedError"),as=Symbol.for("emailmaker.integratorSaveTimeoutError");function zc(e,t,n,r){return e!==t?Function.prototype[Symbol.hasInstance].call(e,r):typeof r=="object"&&r!==null&&n in r}var He=class Kc extends Error{reason;detail;static[Symbol.hasInstance](t){return zc(this,Kc,ss,t)}constructor(t,n){super(n?`[emailmaker] save refused: ${t}: ${n}`:`[emailmaker] save refused: ${t}`),this.name="SaveRefusedError",this.reason=t,this.detail=n,Object.defineProperty(this,ss,{value:!0})}},Yc=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[emailmaker] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},gr=class Xc extends Error{timeoutMs;static[Symbol.hasInstance](t){return zc(this,Xc,as,t)}constructor(t,n="handleSaveEmail",r="email"){super(`[emailmaker] ${n} did not respond within ${t}ms — the ${r} was not saved`),this.timeoutMs=t,this.name="IntegratorSaveTimeoutError",Object.defineProperty(this,as,{value:!0})}};function fe(e){return e.getOrCreateInstance(yn,()=>new _n)}var Jc=new WeakMap,bi=new WeakMap;function Te(e){return Jc.get(e)??0}function un(e,t){let n=bi.get(e);return n||(n=new Set,bi.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Sp(e){Jc.set(e,Te(e)+1),bi.get(e)?.forEach(t=>t())}function _i(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var Ip=U("documentSession.canvasReceipts");function Tp(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const i={guid:n,version:r};return e=i,()=>{e===i&&(e=void 0)}},note(n,r){const i=_i(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(i,n)}},read(n){if(!e)return;const{scope:r}=t,i={guid:e.guid,rev:e.version()};return r.originId!==null?{...i,changeId:t.changeId,originId:r.originId}:{...i,changeId:r.generation===n?t.changeId:0}}}}function Qc(e){return e.getOrCreateInstance(Ip,Tp)}var Ap=2e3,Cp=Mf+vf+Ap;function Rp(e,t=Cp){return async()=>{const n=fe(e);let r;const i=new Promise(o=>{r=setTimeout(()=>o("silent"),t)});try{const o=Qc(e).read(Te(n)),s=await Promise.race([n.sendAsync(K.SANDBOX_CANVAS_SYNCED,o?{applied:o}:void 0,!1),i]);if(s==="silent"||s&&!s.synced)throw s==="silent"||s?.unsent,new He("canvas-not-synced")}finally{clearTimeout(r)}}}var Op="em_autosave_pending";function Zn(e){return`${Op}_${e}`}function yi(e,t){try{return sessionStorage.setItem(Zn(e),JSON.stringify(t)),!0}catch{return!1}}function vr(e){try{const t=sessionStorage.getItem(Zn(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(Zn(e)),null):n}catch{return null}}function st(e){try{sessionStorage.removeItem(Zn(e))}catch{}}function mo(e){return`block:${e}`}function Zc(e,t){return t?mo(e):e}function go(e,t){(vr(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&st(e)}function kp(e){return e!=null&&e!==""}function el(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var cs;function Pp(){return el(mr.em_revisions_v2)??!0}function Dp(){return cs??=Pp(),cs}function Ut(e){return Fc(e)&&Dp()}function xp(){return!1}var tl;function dn(e,t){return tl?.capture(e,t)}function Mp(e,t){return tl?.captureMessage(e,t)}var Lp=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Np=200;function nl(e=new Set){const t=new Set;return(n,r)=>{if(!Lp.some(([o,s])=>!e.has(o)&&s.test(n)))return;const i=r??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=Np&&t.clear(),t.add(i))}}function rl(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:nl()}}var Fp=rl();function Ze(e){return e?.getInstance(oo)??Fp}function Bp(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function kn(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Me=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${kn(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${kn(this.oldText)}")`:`(replace@${this.oldPosition} "${kn(this.oldText)}" with "${kn(this.newText)}")`}};function ls(e,t){return e===null||e.length===0?t:new jp(e,t).compress()}var jp=class Ue{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),i=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(i===null)break;this._acceptCurr(i),i=this._getCurr(++n);continue}if(i===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldEnd<=r.newPosition){this._acceptCurr(i),i=this._getCurr(++n);continue}if(r.newEnd<=i.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldPosition<r.newPosition){const[c,l]=Ue._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(c),i=l;continue}if(r.newPosition<i.oldPosition){const[c,l]=Ue._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(c),r=l;continue}let s,a;if(i.oldEnd===r.newEnd)s=r,a=i,r=this._getPrev(++t),i=this._getCurr(++n);else if(i.oldEnd<r.newEnd){const[c,l]=Ue._splitPrev(r,i.oldLength);s=c,a=i,r=l,i=this._getCurr(++n)}else{const[c,l]=Ue._splitCurr(i,r.newLength);s=r,a=c,r=this._getPrev(++t),i=l}this._result[this._resultLen++]=new Me(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const o=Ue._merge(this._result);return Ue._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=Ue._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=Ue._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new Me(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Me(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),i=t.newText.substr(n);return[new Me(t.oldPosition,t.oldText,t.newPosition,r),new Me(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new Me(t.oldPosition,r,t.newPosition,t.newText),new Me(t.oldPosition+n,i,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,i=t[0];for(let o=1;o<t.length;o++){const s=t[o];i.oldEnd===s.oldPosition?i=new Me(i.oldPosition,i.oldText+s.oldText,i.newPosition,i.newText+s.newText):(n[r++]=i,i=s)}return n[r++]=i,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];o.oldText!==o.newText&&(n[r++]=o)}return n}};function Up(e){return new Me(e.newPosition,e.newText,e.oldPosition,e.oldText)}function $p(e){return e.map(Up)}function us(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Hp(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const i=t[r];n=n.slice(0,i.oldPosition)+i.newText+n.slice(i.oldEnd)}return n}function il(e,t,n){let r=0;const i=e.start===e.end;for(const o of t){const s=o.newLength-o.oldLength;if(o.oldLength===0){const a=o.oldPosition;if(i&&a===e.start)r+=n==="after"?s:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=s)}continue}if(i){if(e.start>=o.oldEnd)r+=s;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=s;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}function ds(e,t,n){if(!t.length)return[...e];const r=[];let i=0;for(const o of e){const s=il({start:o.oldPosition,end:o.oldEnd},t,n);if(!s)return null;r.push(new Me(s.start,o.oldText,s.start+i,o.newText)),i+=o.newLength-o.oldLength}return r}var dt=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},fs=0,Vp=Math.random().toString(36).slice(2,8);function Gp(){return fs+=1,`doc-${Vp}-${fs}`}function qp(e){const t=e.createBuffer(),n=e.docId??Gp();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const a=new Set;let c=!1,l=!1,u;const d=new Set;let m=null;const _=()=>(m?.version!==i&&(m={version:i,value:t.read()}),m.value),v=E=>Object.entries(E).some(([y,k])=>s[y]!==k);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:_,mutate(E,{source:y}){if(c)return i;const k=E.changes?.length?E.changes:void 0,C=k?Hp(_(),k):E.content!==void 0?E.content:void 0,F=C!==void 0&&C!==_(),T=E.attributes!==void 0&&v(E.attributes);if(!F&&!T)return i;const R=!(i>(o??-1)),A=T?Object.keys(E.attributes).filter(O=>s[O]!==E.attributes[O]):[];F&&t.write(C),T&&(s={...s,...E.attributes}),i+=1,y!=="user"&&R&&(o=i);const D={source:y,version:i,changes:k,...F?{content:!0}:{},...A.length>0?{attributes:A}:{}};return a.forEach(O=>O(D)),i},markSaved(E,y){const k={serverId:r,savedVersion:o};y!==void 0&&(r=y),(o===null||E>o)&&(o=E),(k.serverId!==r||k.savedVersion!==o)&&a.forEach(C=>C({source:"system",version:i}))},markUnsaved(){c||o===null||o<i||(o=i-1,a.forEach(E=>E({source:"system",version:i})))},markReady(){l||u!==void 0||(l=!0,d.forEach(E=>E.resolve()),d.clear(),a.forEach(E=>E({source:"system",version:i})))},isReady:()=>l,markFailed(E){l||u!==void 0||c||(u=E,d.forEach(y=>y.reject(new dt(E))),d.clear(),a.forEach(y=>y({source:"system",version:i})))},failure:()=>u,whenReady(){return l?Promise.resolve():u!==void 0?Promise.reject(new dt(u)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((E,y)=>{d.add({resolve:E,reject:y})})},subscribe(E){return a.add(E),()=>a.delete(E)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>c,dispose(){c=!0,d.forEach(E=>E.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),d.clear(),a.clear(),t.dispose()}}}var Wp=500,zp=100,Br=0,ps=0;function er(e,t){let n=0;for(const r of t){if(r.oldPosition>e||r.oldPosition===e&&r.oldLength>0)break;if(r.oldEnd>e)return r.newEnd;n=r.newEnd-r.oldEnd}return e+n}function Kp(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function Yp(e,t){const n=e?.after;return n?{...e,after:{start:er(n.start,t),end:er(n.end,t)}}:e}function Xp(e,t,n){const r=(i,o)=>i&&{start:er(i.start,o),end:er(i.end,o)};return e&&{before:r(e.before,t),after:r(e.after,n)}}function Jp(e,t={}){const n=t.groupIntervalMs??Wp,r=t.maxSteps??zp,i=t.now??(()=>0);let o=[],s=0,a=Br+=1,c=null,l,u,d,m=!1,_=!1,v=!1,E=0,y=!1,k=!1;const C=new Set,F=()=>C.forEach(w=>w()),T=(w,M)=>{if(w.length){v=!0;try{e.mutate({changes:w},{source:M})}finally{v=!1}}},R=w=>T(w,"user"),A=w=>{const M=l?.from??i(),B=E>0?y:_&&c!==null&&m===(l!==void 0)&&M>=c&&M-c<n;if(E>0&&(y=!0),B){const W=o[s-1];o[s-1]={...W,changes:ls(W.changes,w),selection:Kp(W.selection,u)}}else o=o.slice(0,s),ps+=1,o.push({id:ps,below:o[s-1]?.id??0,changes:w,selection:u}),s=o.length,_=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,a=Br+=1);c=l?.to??M,m=l!==void 0,F()},D=()=>{_=!1,c=null},O=w=>{let M=w;for(let B=s;B<o.length;B+=1){const W=o[B],ie=ds(W.changes,M,"after"),re=ie&&ds(M,W.changes,"before");if(!ie||!re)return o=o.slice(0,B),!0;o[B]={...W,changes:ie,selection:Xp(W.selection,M,re)},M=re}return!1},h=w=>{if(!w.length)return;const M=O(w);if(s>0){const B=o[s-1];o[s-1]={...B,changes:ls(B.changes,w),selection:Yp(B.selection,w)}}D(),M&&F()},f=e.subscribe(({source:w,changes:M})=>{if(!(k||v||!M?.length)){if(w==="remote"){p();return}if(w!=="user"){h(M);return}A(M)}}),p=()=>{o=[],s=0,y=!1,D(),a=Br+=1,F()},b=(w,M)=>{y=!1,d=M;try{R(w)}finally{d=void 0}},x=(w=!1)=>{if(s===0)return!1;const M=o[s-1],B=$p(M.changes);return us(e.getContent(),B)?(b(B,w?{kind:"undo",selection:M.selection?.before}:void 0),s-=1,D(),!0):(o=o.slice(0,s-1),s=o.length,y=!1,D(),F(),!1)},N=()=>{const w=x(!0);return w&&F(),D(),w},S=()=>{if(s>=o.length)return D(),!1;const w=o[s];return us(e.getContent(),w.changes)?(b(w.changes,{kind:"redo",selection:w.selection?.after}),s+=1,D(),F(),!0):(o=o.slice(0,s),D(),F(),!1)};return{recordAt(w,M,B){const W=l,ie=u;l=w,u=B;try{return M()}finally{l=W,u=ie}},activeMove:()=>d,canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){N()},redo(){S()},tryUndo:N,tryRedo:S,clear:p,closeGroup:D,beginTransaction(){E===0&&(y=!1),E+=1;let w=!1;return()=>{w||(w=!0,E-=1,E===0&&(y=!1,D()))}},applyWithoutHistory(w){const M=e.get().version;if(T(w,"system"),e.get().version===M){D();return}h(w)},getPast:w=>o.slice(0,s).reverse().slice(0,w).map(M=>M.changes),getFuture:w=>o.slice(s).reverse().slice(0,w).map(M=>M.changes),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(w){if(w.stackId!==a||w.index>s)return!1;for(;s>w.index;)if(!x())return F(),!1;return F(),!0},currentStep:()=>({id:o[s-1]?.id??0,below:o[s-1]?.below??0}),subscribe(w){return C.add(w),()=>C.delete(w)},dispose(){k=!0,f(),C.clear(),o=[],s=0}}}var Qp=["edit","move","resize","insert"];function jr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Zp(e){return typeof e=="string"?e:null}function eh(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function th(e){return Qp.includes(e)?e:null}function nh(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:Zp(t.originId),changeId:jr(t.changeId),rev:jr(t.rev),baseRev:jr(t.baseRev),expected:eh(t.expected),intent:th(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}function rh(e){return e instanceof He?e.reason:void 0}var hs={"too-many-tags":"The email has more tags than allowed, so nothing was saved.","canvas-not-synced":"Not all canvas edits reached the document, so nothing was saved; try again in a moment.","plugin-refused":"A plugin refused the save, so nothing was saved."};function ih(e){const t=rh(e);if(t===void 0||t==="locked")return;const{detail:n}=e;return n?`${hs[t]} Its reason: ${n}`:hs[t]}var ms=Symbol.for("emailmaker.blockSaveFlight"),ol=Symbol.for("emailmaker.blockSaveSessionQueue"),Ei=new WeakMap;function sl(e,t){return Object.isExtensible(e)||t in e?e[t]:Ei.get(e)?.get(t)}function al(e,t,n){if(t in e||Object.isExtensible(e)){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0});return}const r=Ei.get(e)??new Map;r.set(t,n),Ei.set(e,r)}function oh(e,t){al(e,ol,t)}function sh(e,t){const n=(sl(e,ms)??Promise.resolve()).then(t,t);return al(e,ms,n.catch(()=>{})),n}function ah(e,t){return sl(e,ol)?.(t)??sh(e,t)}var Vt=new Map,gs=new Map;function ch(e){return Vt.set(e,(Vt.get(e)??0)+1),()=>{const t=(Vt.get(e)??1)-1;if(t>0){Vt.set(e,t);return}Vt.delete(e);const n=gs.get(e);gs.delete(e),n?.forEach(r=>r())}}var vo=e=>e.replace(/\r\n?/g,`
|
|
998
|
+
`),lh=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function wi(e){return typeof e=="string"&&lh.test(e)}var uh=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function dh(){return typeof navigator<"u"&&navigator.onLine===!1}function fh(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const i=r.data;typeof r.data=="object"&&i.error!=null&&t.push(i.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function cl(e){if(!e)return!1;if(typeof e=="string"){const n=e.toLowerCase();return n.includes("fetch")||n.includes("network")||n.includes("timeout")||n.includes("failed to fetch")||n.includes("load failed")||n.includes("networkerror")}if(e instanceof Error)return cl(e.message);if(typeof e!="object")return!1;const t=e;return t.status==="FETCH_ERROR"||t.status==="TIMEOUT_ERROR"||t.status==="PARSING_ERROR"?!0:typeof t.status=="number"?t.status===0||t.status===408||t.status>=500:!1}function ph(e){return dh()?!0:fh(e).some(cl)}var ll=new WeakSet,ul=new WeakMap;function dl(e){typeof e=="object"&&e!==null&&ll.add(e)}function hh(e,t){typeof e=="object"&&e!==null&&ul.set(e,t)}function mh(e){return typeof e=="object"&&e!==null?ul.get(e):void 0}function gh(e){return e instanceof gr||e instanceof Yc||typeof e=="object"&&e!==null&&ll.has(e)}function vh(e){return e instanceof He||fl(e)||e instanceof uh||gh(e)}function fl(e){return bo(e)?.v2Error?.data?.code==="blocks.block_locked"}function vs(e){return bo(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function bo(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function bh(e){if(e instanceof He)return e.reason==="canvas-not-synced";if(vh(e))return!1;const t=bo(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?vs(e):!0}return ph(e)||vs(e)}var pl="draft";function wt(e){return e==null||e===""?pl:String(e)}function tr(e){return e==null||e===""?`${Si}${pl}`:`${Si}${String(e)}`}var Si="block:";function ee(e){return e?.startsWith(Si)===!0}function Ct(e){return ee(e.sessionKey())?void 0:e.current()}function ct(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return ae(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(ae(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw lo(i)?(`${e}`,{...n}):(`${e}`,{error:Wc(i),...n},void 0),i})}var _h=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function yh(e){const t=e?.trim()??"";if(!_h.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function en(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function _o(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Eh(e,t={}){const n=en((e??[]).filter(r=>r?.html?.trim()));return _o(n,t)?n:null}function wh(e,t){const n=Date.parse(en(e)?.modified??""),r=Eh(e),i=Date.parse(r?.modified??""),o=t===void 0||Number.isFinite(i)&&i>t,s=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:o?r:null,...s.length?{latestAt:Math.max(...s)}:{}}}function bs(e,t,n){const r=en((e??[]).filter(c=>c?.html?.trim())),i=Date.parse(r?.modified??""),o=Date.parse(en((n??[]).filter(c=>c?.html?.trim()))?.modified??""),s=r&&Number.isFinite(i)&&(t===void 0||i>t)&&!(o>i),a=[Date.parse(en(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:s&&_o(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Sh({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var _s=["recovery","plugin","rest"],Ih=["subject","preheader"];function Th(e){let t={},n;for(let i=_s.length-1;i>=0;i--){const o=e.get(_s[i]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const i of Ih){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function nr(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?vo(t.content):void 0,i=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...i?{changes:[new Me(0,n,0,r)]}:{}},{source:"remote"})}var Ur=e=>typeof e=="string"?e.trim():"";function Ah(e,t,n,r){const{version:i,attributes:o}=e.get(),s=o,a=r==="snapshot"||r==="anchor",c=a?s.author:void 0,l=a?s.date_gmt:void 0,u=Ur(s.title)||Ur(s.subject)||Ur(t.fallbackTitle);return{version:i,payload:{html:e.getContent(),title:u,subject:s.subject,preheader:s.preheader,description:s.description,common_styles:s.common_styles||"",meta:s.meta,utm_parameters:s.utm_parameters,parent_email:s.parent_email,is_template:s.is_template||!1,is_inited:s.is_inited,tags:s.tags,emailtags:s.emailtags,group:s.group,projectCategories:s.projectCategories,renderGuid:e.get().docId,project:t.project??s.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...c!=null&&c!==""?{author:c}:{},...l?{excerpt:l}:{}}}}var Ch=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Rh(e){const t={};for(const n of Ch)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Oh(e,t,n,r,i,o){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(i);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,i):t.saveAutosave(r,i,o==null?void 0:{wpId:o})}function Ge(e,t=!1){const n={};for(const r of Object.keys(e)){let i=e[r];i!==void 0&&!(typeof i=="number"&&Number.isNaN(i))&&(t&&typeof i=="object"&&i!==null&&(i=Ge(i)),n[r]=i)}return n}function kh(e){return typeof e=="string"&&e.includes("autosave")}var Ph=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function hl(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Ph.has(t))):{}}function Mt(e,t,n={}){e&&e.mutate({attributes:Dh(e.get().attributes,t)},{source:n.source??"user"})}function Dh(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function yo(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function xh(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function ml(e){if(!e)return null;const t=hl(e);return e.common_styles!==void 0&&(t.common_styles=xh(e.common_styles)),yo(e.html,t)}function gl(e){return e?yo(e.html,Ge(hl(e))):null}var Mh=["common_styles","subject","preheader","meta"];function ys(e){if(!e?.html?.trim())return null;const t={};for(const n of Mh)Lh(n,e[n])&&(t[n]=e[n]);return yo(e.html,t)}function Lh(e,t){return e==="common_styles"?typeof t=="string"&&t.startsWith("{"):e==="meta"?typeof t=="object"&&t!==null&&!Array.isArray(t):typeof t=="string"}var Nh=["modified","lock","wpId","secretHash"];function Es(e){if(!e)return null;const t={};for(const n of Nh)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Fh=10,Bh=(e,t)=>e.key===t.key&&jh(e.serverId,t.serverId),jh=(e,t)=>e==null||e===t;function Uh(e){return typeof e?.then=="function"}var ws=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},vl=e=>{e.request.serverId!=null&&!br(e)&&e.document.markSaved(e.document.get().version)},br=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Ss=(e,t)=>t?.content!==void 0&&Sh({hasUnsavedUserEdit:br(e)})==="skip",Is=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},$h=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),Hh=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.userTouched.clear(),e.document.get().docId))},Vh=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([i,o])=>e.attributes[i]!==o)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Gh=e=>{const t=Th(e.reports),n=Vh(e.lastMerged,t);e.lastMerged=t,e.broughtContent=_r(t.content)??e.broughtContent,n&&(nr(e.document,n),vl(e))},$r=(e,t)=>{if(!e.ready&&!br(e)){Gh(e);return}e.broughtContent=_r(t?.content)??e.broughtContent,nr(e.document,t)},_r=e=>e===void 0?void 0:vo(e),qh=(e,t)=>t.content===void 0||_r(t.content)!==e.broughtContent||!br(e)?t:{...t,content:void 0},Ts=e=>{const{attributes:t,serverId:n,docId:r}=e.document.get();return{...t,html:e.document.getContent(),id:n??void 0,isNew:n==null,renderGuid:r}};function Wh(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:a,confirmPublish:c,awaitCanvasSynced:l,savedEchoForm:u=g=>g,queuesOutsideWrites:d,onAdapterError:m,onTimeout:_}=e;let v,E;const y=new Set,k=new Set,C=()=>y.forEach(g=>g()),F=(g,I)=>{if(!(g.closed||g.ready)){if(g.error!==void 0){g.document.markFailed(g.error),g.document.get().docId;return}vl(g),g.ready=!0,g.document.markReady(),g.document.get().docId,[...g.reports.keys()]}},T=(g,I,P)=>{m?.(I.id,P),!(!I.required||g.closed)&&(g.error=P,g.document.get().docId,I.id,C())},R=(g,I)=>{const P=new Set(I.map(G=>G.id));I.forEach(G=>{G.watch&&g.watchers.push(G.watch(z=>g.closed?!1:g.ready&&(Ss(g,z)||g.contentShown===!0&&z?.content!==void 0)?(g.document.get().docId,G.id,!1):(z&&g.reports.set(G.id,z),$r(g,z),z?.content!==void 0&&(g.showFill=void 0),!0)))});const j=(G,z)=>{if(!g.closed){if(!G.required&&Ss(g,z)){g.document.get().docId,G.id,G.loaded?.(!1);return}z&&(g.reports.set(G.id,z),G.id==="plugin"&&Is(g,z)),$r(g,z),G.loaded?.(z!==null)}},q=()=>{P.size>0||g.closed||(ws(g),F(g,[]))},Q=[];if(I.forEach(G=>{let z;try{z=G.load()}catch(L){T(g,G,L),P.delete(G.id);return}if(Uh(z)){Q.push({id:G.id,required:G.required,load:()=>z,...G.loaded?{loaded:L=>G.loaded?.(L)}:{}});return}j(G,z),P.delete(G.id)}),Q.length===0){q();return}g.timer=setTimeout(()=>{g.timer=void 0,_?.([...P]),g.document.get().docId,[...P],F(g,[...P])},n),g.timer.unref?.(),Q.forEach(G=>{G.load().then(z=>j(G,z)).catch(z=>{T(g,G,z)}).finally(()=>{P.delete(G.id),q()})})},A=async(g,I,P)=>{if(P==="snapshot"||P==="anchor")return;const j=o?.();if(j)return j.resolve({project:I.project??g.project,tags:(g.tags??[]).map(q=>({name:q}))})},D=g=>{if(g.lock===!0&&s?.(g)===!1)return new He("locked");const I=g.tags?.length??0,P=g.emailtags?.length??0;if(Math.max(I,P)>Fh)return new He("too-many-tags")},O=(g,I)=>{const P=g.document.get().serverId;P!=null&&(g.createKey=void 0),!(I||P==null)&&(g.recoveryFacts={emailId:P,historyLoaded:!0,isRecovering:!1},ee(g.request.key)||(g.request={...g.request,key:wt(P),serverId:P}))},h=(g,I,P)=>{if(g.closed||P?.id==null)return;const j=g.document.get().serverId,q=j!=null;q&&j!==String(P.id)||(g.document.markSaved(I,String(P.id)),O(g,q),g.document.get().serverId,C())},f=(g,I,P)=>{if(!(I==="materialize"||I==="publish"&&g.document.get().serverId==null))return P;const j=g.createKey,q=j&&j.project===P.project?j:{key:ke(),project:P.project};return g.createKey=q,{...P,idempotencyKey:q.key}},p=async(g,I,P)=>{try{await g.document.whenReady()}catch(L){return g.saveError=L,g.saveFailures+=1,g.failedIntent=I,g.saveFailures,!1}if(g.closed)return!1;const j=D(g.document.get().attributes);if(j)return g.saveError=j,g.saveFailures+=1,g.failedIntent=I,j.reason,C(),!1;if(a&&(await a(Ts(g)).catch(()=>{}),g.closed))return!1;if(l){try{await l()}catch(L){return g.saveError=L,g.saveFailures+=1,g.failedIntent=I,g.saveFailures,C(),!1}if(g.closed)return!1}if(c&&I==="publish"){const L=await c(Ts(g),g.request.key).catch(()=>{});if(g.closed)return!1;if(L!==void 0)return g.saveError=new He("plugin-refused",L),g.saveFailures+=1,g.failedIntent=I,C(),!1}let q;try{q=await A(g.document.get().attributes,P,I)}catch(L){return g.saveError=L,g.saveFailures+=1,g.failedIntent=I,g.saveFailures,C(),!1}if(g.closed)return!1;const{payload:Q,version:G}=Ah(g.document,P,q,I),z=f(g,I,Q);g.document.get().docId;try{const L=g.document.get().serverId!=null,J=await Oh(r(),i(g.request.key),I,g.document.get().serverId,z,g.document.get().attributes.wpId);if(g.closed)return!0;let Z;if(I==="snapshot"||I==="anchor"){const te=J?.modified!=null?Date.parse(J.modified):NaN;Z=Number.isFinite(te)?te:Date.now(),g.snapshotVersion=G,g.lastRevisionAt=Z}else{g.document.markSaved(G,J?.id!=null?String(J.id):void 0);const te=J;nr(g.document,Es(te&&{wpId:te.wpId,secretHash:te.secretHash})),g.broughtContent=_r(u(z.html))}O(g,L),g.saveError=void 0,g.saveFailures=0,g.failedIntent=void 0,g.document.get().serverId,C();const be={intent:I,serverId:g.document.get().serverId,created:!L,...Z!==void 0?{revisionAt:Z}:{}};return k.forEach(te=>te(be)),!0}catch(L){return(I==="publish"||I==="materialize")&&mh(L)?.then(J=>h(g,G,J)),g.saveError=L,g.saveFailures+=1,g.failedIntent=I,g.saveFailures,C(),!1}},b=g=>{g.closed=!0,g.watchers.forEach(I=>I()),g.watchers=[],ws(g),g.history.dispose(),g.document.dispose()},x=()=>{v&&(b(v),v=void 0)},N=()=>{E&&(b(E),E=void 0)},S=(g,I,P)=>{let j=!1;I.show&&(g.show?.id!==I.show.id||g.show.token!==I.show.token)&&(g.show=I.show,j=!0,{docId:g.document.get().docId,...I.show});const q=P==="show"?gl(I.patch):null;if(q){g.reports.set("plugin",q),Is(g,q);const Q=qh(g,q);$r(g,Q),Hh(g,Q)}j&&C()},w=(g,I={})=>W(v,g,I),M=()=>v&&ee(v.request.key??"")?E:v,B=g=>({error:g?.saveError,failures:g?.saveFailures??0,saving:g?.saving===!0,failedIntent:g?.failedIntent}),W=(g,I,P)=>!g||g.closed||I==="materialize"&&g.document.get().serverId!=null?Promise.resolve(!1):g.saving?I==="snapshot"||I==="materialize"?Promise.resolve(!1):(g.inFlight??Promise.resolve(!1)).then(()=>W(g,I,P)):(g.saving=!0,C(),g.inFlight=p(g,I,P).finally(()=>ie(g)),g.inFlight),ie=g=>{g.saving=!1,g.inFlight=void 0,v===g&&!g.closed&&C()},re=(g,I)=>{if(g.closed)return I();if(g.saving)return(g.inFlight??Promise.resolve(!1)).then(()=>re(g,I));g.saving=!0,C();const P=Promise.resolve().then(I);return g.inFlight=P.then(()=>!0,()=>!1).finally(()=>ie(g)),P},oe=(g,I)=>{const P=g.document.get().serverId,j=P==null?void 0:ch(P);return re(g,I).finally(j)},X=(g,I="open",P=!1)=>{if(v&&!v.closed&&I!=="new"&&Bh(v.request,g))return S(v,g,I),v.document;x(),P||N();const j=qp({createBuffer:()=>Bp(""),serverId:g.serverId??null}),q={request:g,show:g.show,document:j,history:Jp(j,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return v=q,oh(j,Q=>d?.(q.request.key)===!0?oe(q,Q):void 0),q.watchers.push($h(q)),j.get().docId,g.serverId,R(q,t(g,{publishRecoveryFacts(Q){q.closed||(q.recoveryFacts=Q,C())},readShownContent:()=>q.closed?null:q.document.getContent(),readWpId:()=>q.closed?void 0:q.document.get().attributes.wpId})),C(),j},$=(g,I,P)=>({key:ee(g)?g:tr(g),serverId:I?.id!=null?String(I.id):null,email:I,show:P});return{openWith:X,open:(g,I={})=>X({key:wt(g),serverId:g,email:I.email,patch:I.patch,show:I.show},"open"),openDraft:(g,I={})=>X({key:wt(void 0),serverId:null,email:g,patch:I.patch,show:I.show},"open"),startNewDraft:(g,I={})=>X({key:wt(void 0),serverId:null,email:g,patch:I.patch,show:I.show},"new"),reload:(g,I={})=>X({key:wt(g),serverId:g,email:I.email,patch:I.patch,show:I.show},"new"),openBlock:(g,I,P)=>X($(g,I,P),"open"),reloadBlock:(g,I,P)=>X($(g,I,P),"new"),openBlockOver:(g,I)=>{const P=$(g,I);return v&&!v.closed&&v.request.key===P.key?v.document:(v&&!v.closed&&!ee(v.request.key)&&(N(),E=v,v=void 0),X(P,"open",!0))},resumeSuspended:()=>{if(E)return x(),v=E,E=void 0,C(),v.document},hasSuspended:()=>!!E,suspendedDocument:()=>E?.document,show:(g,I)=>{const P=v;if(!(!P||P.closed))return X({...P.request,patch:g,show:I},"show")},current:()=>v?.document,noteServerFacts:({serverId:g,block:I},P)=>{const j=v;!j||j.closed||j.request.serverId!==g||ee(j.request.key??"")===I&&nr(j.document,Es(P))},save:w,saveEmail:(g,I={})=>W(M(),g,I),saveState:()=>B(v),emailSaveState:()=>B(M()),revisionFacts(){if(!v)return;const g=v.revisionFactsSnapshot;return g&&g.snapshotVersion===v.snapshotVersion&&g.lastRevisionAt===v.lastRevisionAt?g:(v.revisionFactsSnapshot={snapshotVersion:v.snapshotVersion,lastRevisionAt:v.lastRevisionAt},v.revisionFactsSnapshot)},recoveryFacts:()=>v?.recoveryFacts,history:()=>v?.history,forcedHeaders:()=>v?.forcedHeaders,beginForcedHeaders(g){v&&!v.closed&&(v.forcedHeaders=g)},endForcedHeaders(){for(const g of[v,E])g&&(g.forcedHeaders=void 0)},onSaved(g){return k.add(g),()=>k.delete(g)},showFacts:()=>v?.show,shownHeaders:()=>({...v?.shownHeaders}),showFill:()=>v?.showFill,beginShowFill(g){v&&!v.closed&&(v.showFill={showId:g,codeEdits:0})},noteCodeEdit(){v?.showFill&&(v.showFill.codeEdits+=1)},endShowFill(g){for(const I of[v,E])I?.showFill?.showId===g&&(I.showFill=void 0)},sessionKey:()=>v?.request.key,openError:()=>v?.error,subscribe(g){return y.add(g),()=>y.delete(g)},close(){!v&&!E||(x(),N(),C())}}}var Eo=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function wo(e){if(e instanceof Eo)return e.reason;if(e instanceof dt)return wo(e.reason)}function zh(e){const t=e instanceof dt?e.reason:e;return t instanceof Eo&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Kh(e){const t=wo(e);return t!==void 0&&t!=="unavailable"}function Yh(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Eo("not-found");return ml(n)}}}var bl=U("EmailPort");function Xh(e){return e.getInstance(bl)}function Jh(e,t){e.inject(bl,t)}var _l=U("documentSession.restEmailPortFactories");function yl(e){return e.getInstance(_l)!==void 0}function ft(e){const t=e.getInstance(_l);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var Qh=U("EmailTermsResolver");function Zh(e){return e.getInstance(Qh)}var El=U("EmailHistoryPort"),em=U("BlockHistoryPort");function wl(e){return e.getInstance(em)}function Sl(e){return e.getInstance(El)}function tm(e,t){e.inject(El,t)}var nm=2e3,rm=5e3,im=5,om=5e3,sm=4;function am(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Wn(e,t){return e==null||t==null?!1:e.replaceAll(`\r
|
|
999
999
|
`,`
|
|
1000
1000
|
`)===t.replaceAll(`\r
|
|
1001
1001
|
`,`
|
|
1002
|
-
`)}function Fn(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function Ht(e,t){return Jo(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function Kp(e,t,n){const{latest:r}=e,o=An(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(i=>An(i,r.html))?o?{revision:null,phase:"normal"}:{revision:Fn(t),phase:"timeout"}:o?{revision:Ht(e),phase:"normal"}:An(t.html,r.html)?{revision:Fn(t),phase:"found"}:{revision:Ht(e),phase:"normal"}}function Yp({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:o=!1,readShownContent:i,onFacts:s,onLate:a,onError:c,pageLoadTs:l=zp()}){const d=r??e;let h=null,b=!1,v=!1,w=0,C={emailId:e,historyLoaded:!1,isRecovering:!1},y=null;const S=new Promise(_=>{y=_}),T=_=>{C={...C,..._},s(C)};let B;const D=_=>{w+=1,T({applied:{phase:_,seq:w}})},O=()=>{h?.timer&&clearTimeout(h.timer),h=null},A=_=>{if(!v){if(y){const I=y;y=null,I(_),B=_.revision?_.phase:void 0;return}a(_)&&_.revision&&D(_.phase)}},x=()=>{if(!h||v)return;const _=h.phase==="fast",I=_?$p:Gp,F=_?qp:Wp;h.timer=setTimeout(()=>{const j=h;if(!(!j||v)){if(j.attempts+=1,u(),_&&j.attempts>=F){const{pending:K}=j;tt(d),T({isRecovering:!1}),A({revision:Fn(K),phase:"timeout"}),b=!0,j.phase="bg",j.attempts=0,x();return}if(!_&&j.attempts>=F){tt(d),O(),T({isRecovering:!1}),b=!0;return}x()}},I),h.timer.unref?.()},R=_=>{h={phase:"fast",attempts:0,pending:_,timer:null},T({isRecovering:!0}),x()},m=_=>{if(v)return;if(T({historyLoaded:!0,latestRevisionAt:_.latestAt!==void 0&&Number.isFinite(_.latestAt)?_.latestAt:void 0}),n&&h){const j=Ht(_,h.pending.sentAt);if(!j)return;const K=h.phase==="fast"?"found":"bg";tt(d),O(),T({isRecovering:!1}),b=!0,A({revision:j,phase:K});return}if(b)return;const I=n?Jn(d):null,F=I&&(I.sentAt<l||!An(I.html,i()))?I:null;if(F){if(o&&(F.baseRevisionId!==void 0||F.baseOpen)){tt(d),b=!0,A(Kp(_,F,i()));return}const j=Ht(_,F.sentAt);if(j){tt(d),b=!0,A({revision:j,phase:"found"});return}if(o){if(tt(d),b=!0,_.latestAt!==void 0&&_.latestAt>F.sentAt+5e3){A({revision:null,phase:"normal"});return}A({revision:Fn(F),phase:"timeout"});return}R(F);return}b=!0,A({revision:Ht(_),phase:"normal"})},f=_=>{v||(c?.(_),C.historyLoaded||(T({historyLoaded:!1,latestRevisionAt:void 0}),M()),!h&&A({revision:null,phase:"normal"}))},u=()=>t(e).then(m).catch(f);let g,k=!1;const M=()=>{k||h||v||(k=!0,g=setTimeout(()=>{g=void 0,!v&&!C.historyLoaded&&u()},Vp))};return u(),{verdict:()=>S,confirmVerdict(_){const I=B;B=void 0,_&&I!==void 0&&!v&&D(I)},dispose(){v=!0,g!==void 0&&(clearTimeout(g),g=void 0),O()}}}function Xp({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:o,wpId:i,readShownContent:s,onFacts:a}){let c=null;const l=Yp({emailId:o,readAutosave:d=>i?e.readAutosave(d,{wpId:i()}):e.readAutosave(d),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:s,onFacts:a,onLate:({revision:d,phase:h})=>{const b=zi(d);return c?.(b)??!1},onError:d=>{d instanceof Error&&d.message}});return{id:"recovery",load:()=>l.verdict().then(({revision:d})=>zi(d)),loaded(d){l.confirmVerdict(d)},watch(d){return c=d,()=>{c=null,l.dispose()}}}}var Jp=5e3,Qp=H("plugin.knownRevisions");function St(e){return e.getOrCreateInstance(Qp,()=>new Map)}function ti(e,t,n,r){const o=n?.get(t)??[],i=o.filter(s=>s!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...o.length>Rc?{baseOpen:!0}:i.length?{baseHtmls:i}:{}}}var Zp=H("plugin.uncertainWrites"),Rc=3;function rn(e){return e.getOrCreateInstance(Zp,()=>new Map)}function eh(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>Rc||e.set(t,[...r,n])}function Oc(e,t){no(e,t)||!t.baseHtmls||no(e,{...t,baseHtmls:void 0,baseOpen:!0})}function Bn(e,t,n,r=!1){const o=Jn(e);!n||o?.sentAt!==t||!(r||o.baseOpen||o.baseHtmls)||no(e,{...o,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function kc(e,t,n,r){(Jn(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||Oc(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var th=/(?:Z|[+-]\d{2}:?\d{2})$/i;function nh(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",o=th.test(r)?Date.parse(r):NaN;return!Number.isFinite(o)||o>=t-Jp}function Pc(e,t,{pendingKey:n=s=>s,knownRevisions:r=new Map,uncertainWrites:o,synchronousHistory:i=!1}={}){return{readRevisions:(s,a,c)=>t.readRevisions(s,a,c),readRevision:(s,a,c)=>t.readRevision?t.readRevision(s,a,c):Promise.resolve(null),readAutosave:(s,a)=>t.readAutosave(s,a),async saveAutosave(s,a,c){const l=n(s),d=Date.now();Oc(l,{sentAt:d,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...ti(r,l,o,a.html??"")});const h=await t.saveAutosave(s,a,c),b=h?.id;return nh(h,d)?Bn(l,d,b):b&&i&&(h.isAutosave===!0?Ko(l,d):Bn(l,d,b,!0)),await e.saveAutosave(s,a),h}}}function rh(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,o){const i=Date.now();n&&kc(r,o,i,ti(n.knownRevisions,r,n.uncertainWrites,o.html??""));const s=await t.updateEmail(r,o);return n&&Bn(r,i,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,o),Ko(r,i),s&&{...s,id:r}}}}var Dc=H("CurrentUser"),xc={};function ni(e){return e.getOrCreateInstance(Dc,()=>ue(xc))}function Mc(e){return e?.getInstance(Dc)?.get()??xc}var Lc=H("HeadlessMode");function ri(e){return e.getOrCreateInstance(Lc,()=>ue(!1))}function oh(e){return e?.getInstance(Lc)?.get()??!1}var ih=H("HiddenMount");function sh(e){return e.getOrCreateInstance(ih,()=>ue(!1))}function ah(e){if(!e)return!1;try{return!!Fo(e).data?.act_as}catch{return!1}}function ch(e){return ah(e?.getInstance(ka)?.get(hu.em_token))}var lh="SAVE_BUTTON",dh="AUTOSAVE",uh=Symbol.for("emailmaker.saveNotified"),fh=H("helpers.saveListeners");function ph(e,t="email"){return(e.getInstance(fh)?.[t]??0)>0}function Nc(e){return e?.getInstance(be)?.get()??{}}function er(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function hh(e,t){return t.modeDefaults(er(e,t.fallbackMode))}function Fc(e,t){const n=er(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Bc(e,t){const n=er(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function mh(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function gh(e){return Yd(e.map(t=>t?.resourceProxy))}function vh(e){return jd(e.map(t=>t?.resourceProxyPolicy))}function bh(e){return zd(e.map(t=>t?.backendProxy))}function yh(e){return Oa(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function _h(e,t){return[e.base,hh(e,t),e.profile,e.serverSide,Fc(e,t.fallbackMode),e.local,e.user,Bc(e,t.fallbackMode)]}function Ir(e,t){const n=_h(e,t),r=Oa(n),o=mh(n);o!==void 0&&(r.fileManager=o);const i=gh(n);i!==void 0&&(r.resourceProxy=i);const s=vh(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=bh(n);a!==void 0&&(r.backendProxy=a);const c=yh(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function Eh(e,t,n){const r=Fc(e,n),o=Bc(e,n);return Gd([o,e.user,r,e.serverSide],t)}var wh=1.5;function Sh(e){return e.isHeadless||!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=wh*e.autosaveTimeoutMs?"none":"revision"}var Ih=1e4;function Ch(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,i=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const c=m=>a!==void 0&&a.version===m.get().version?i()-a.failuresAtStart:0,l=m=>{const f=c(m);if(f<=0)return!1;const u=n().retryMaxAttempts??5;return!s()||f>u},d=()=>{const{autosaveTimeoutMs:m,retryIntervalMs:f}=n(),u=t();return u!==void 0&&c(u)>0&&f!==void 0&&f>0?f:u?.isNew()?Ih:m},h=m=>m.isNew()&&i()>=3,b=()=>{const m=t();if(!m||m.isDisposed()||l(m))return"none";const{latestRevisionAt:f,snapshotVersion:u,...g}=n(),k=Date.now(),M=Sh({...g,isDirty:m.isDirty(),isNew:m.isNew(),isReady:m.isReady(),latestRevisionAgeMs:f!=null&&f<=k?k-f:void 0,isSnapshotSent:u!=null&&u===m.get().version});return M==="create"&&h(m)?"none":M},v=()=>{const m=t();if(!m||m.isDisposed()||h(m)||l(m)||n().isHeadless)return!1;if(!m.isDirty())return m.isNew();const{snapshotVersion:f}=n();return!(f!=null&&f===m.get().version)};let w,C=0,y=0,S,T,B,D=!1;const O=()=>{S=void 0;const m=t();if(!m||m.isDisposed())return;if(m.get().docId!==w){A();return}const f=b();f!=="none"&&a?.version!==m.get().version&&(a={version:m.get().version,failuresAtStart:i()}),f==="create"?r():f==="revision"?o():v()&&(w=m.get().docId,C=d(),y=i(),S=setTimeout(O,C))},A=()=>{const m=t();if(D||!m)return;const f=a?.version===m.get().version&&y!==i();S!==void 0&&(C!==d()||f)&&(clearTimeout(S),S=void 0),!(S!==void 0||b()==="none"&&!v())&&(w=m.get().docId,C=d(),y=i(),S=setTimeout(O,C))},x=m=>{const f=t();m.source==="user"?a=void 0:a&&f&&(a.version=f.get().version),m.source==="user"&&S!==void 0&&(clearTimeout(S),S=void 0),A()},R=()=>{const m=t();m!==T&&(B?.(),T=m,a=void 0,B=m?.subscribe(x),S!==void 0&&(clearTimeout(S),S=void 0))};return R(),A(),{refresh:()=>{D||(R(),A())},stop:()=>{D=!0,B?.(),B=void 0,T=void 0,S!==void 0&&(clearTimeout(S),S=void 0)}}}var jc=H("documentSession.autosaveUiFacts"),Uc={isUserBusy:!1,saveContext:{}};function Ah(e){return e.getOrCreateInstance(jc,()=>ue(Uc))}function so(e){return e?.getInstance(jc)?.get()??Uc}function Hc(e){return so(e).saveContext.fallbackTitle||"Untitled email."}var Th=1e4,Rh=3e4;function Oh(e,t){const n=b=>{const v=e.getInstance(be)?.layers?.(),w=v?Eh(v,b):void 0;return typeof w=="number"&&w>=0?w:void 0};let r;const o=b=>{const{error:v,failures:w}=t.saveState();return gc(v)?(r?.failures!==w&&(r={failures:w,saved:b??null}),r.saved===(b??null)):(r=void 0,!1)},i=()=>{const b=t.current(),v=b?.get().serverId??void 0,w=ne(t.sessionKey()),C=t.recoveryFacts(),y=C?.emailId===v?C:void 0,S=t.revisionFacts(),T=y?.latestRevisionAt,B=S?.lastRevisionAt,D=Mc(e).profile;return{isInited:w||b?.get().attributes.is_inited===!0,isEnabled:!!D?.autosaves&&!ch(e)&&!o(b?.get().savedVersion),isHistoryLoaded:y?.historyLoaded===!0,isUserBusy:so(e).isUserBusy,isHeadless:oh(e),autosaveTimeoutMs:Nc(e).autosaveTimeout||Th,latestRevisionAt:T!==void 0||B!==void 0?Math.max(T??0,B??0):void 0,snapshotVersion:S?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Rh,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},s=()=>{const b=so(e).saveContext;return{...b,project:b.project??t.current()?.get().attributes.project,fallbackTitle:Hc(e)}},a=Ch({readDocument:()=>t.current(),readEnvironment:i,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>np(t.saveState().error),onCreate:()=>{ne(t.sessionKey())||t.save("materialize",{...s(),source:dh})},onRevision:()=>{t.save("snapshot",{project:s().project})}}),c=t.subscribe(()=>{o(t.current()?.get().savedVersion),a.refresh()}),l=ni(e).watch(()=>a.refresh()),d=Ah(e).watch(()=>a.refresh()),h=ri(e).watch(()=>a.refresh());return()=>{c(),l.dispose(),d.dispose(),h.dispose(),a.stop()}}var Qi=12e3;function ge(e){return e.getOrCreateInstance(Yn,()=>{const t=Dp({resolveAdapters:(r,o)=>Dh(r,e,o),resolveWritePort:()=>$c(e),resolveHistoryPort:r=>ne(r)?qc(e):Vc(e),resolveTerms:()=>jp(e),canEdit:r=>qa(e,r),notifyBeforeSave:cf(e),awaitCanvasSynced:hf(e),savedEchoForm:r=>{const o=Ke(e);return o.toEditorForm(o.toOutputForm(r))},queuesOutsideWrites:r=>ne(r)&&(yf()||Ot(e)),timeoutMs:Qi,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const i=Mp(o),s=xp(o);Wt(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(i),network_failure:String(s)},level:i||s?"warning":"error"})},onTimeout:r=>{}}),n=Oh(e,t);return e.getInstance(W)?.addDispose(n),t})}function xe(e){return e?.getInstance(Yn)}function $c(e){const t=Np(e);return t?tr(e)?rh(t,ct(e).email(e),Ot(e)?{knownRevisions:St(e),uncertainWrites:rn(e)}:void 0):t:ct(e).email(e)}function kh(e){return Tc(e)!==void 0||Ic(e)}function Vc(e){const t=Tc(e);return t?tr(e)?(ie("port:history:server-backed"),Pc(t,ct(e).history(e),{knownRevisions:St(e),uncertainWrites:rn(e),synchronousHistory:Ot(e)})):(ie("port:history:integrator"),t):(ie("port:history:rest (порт не зарегистрирован)"),ct(e).history(e))}function qc(e){const t=Ac(e);return t?tr(e)?(ie("port:block-history:server-backed"),Pc(t,ct(e).blockHistory(e),{pendingKey:zo,knownRevisions:St(e),uncertainWrites:rn(e),synchronousHistory:Ot(e)})):(ie("port:block-history:integrator"),t):(ie("port:block-history:rest (порт не зарегистрирован)"),ct(e).blockHistory(e))}function Ph(e){return Ac(e)!==void 0||Ic(e)}function tr(e){return $a(e)}function Dh({email:e,patch:t,serverId:n,key:r},o,i){const s=[];e?s.push({id:"rest",load:()=>yc(e),required:!0}):n&&s.push(Lp($c(o),n)),t&&s.push({id:"plugin",load:()=>_c(t)});const a=ne(r);return gf(n)&&(a?Ph(o):kh(o))&&s.push(Xp({port:a?qc(o):Vc(o),revisionServiceEnabled:tr(o),pendingKey:oc(n,a),historyIsSynchronous:Ot(o),emailId:n,wpId:()=>i.readWpId(),readShownContent:()=>i.readShownContent(),onFacts:c=>i.publishRecoveryFacts(c)})),s}function xh(e){const t=ge(e),n=he(e).addListener(z.APPLICATION_HAS_AMP,r=>{mt(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(W)?.addDispose(()=>n.dispose())}function Mh(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Lh(e){const t=e.fetchImpl??((i,s)=>fetch(i,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=i=>{try{const s=new URL(i,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:o,async load(i){if(!o(i))return;const s=!r.has(i);r.add(i);try{const a=await t(i,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return Mh(c)?c:void 0}catch{return}}}}var it={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Nh(e){const t={maxBytes:e.maxBytes??it.maxBytes,maxImageBytes:e.maxImageBytes??it.maxImageBytes,ttlMs:e.ttlMs??it.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,i={hits:0,loads:0,failures:0};let s=0;const a=h=>{const b=r.get(h);b&&(s-=b.bytes,r.delete(h))},c=h=>t.ttlMs<=0||n()-h.storedAt<t.ttlMs,l=()=>{if(s<=t.maxBytes)return;const h=[...r.entries()].sort((b,v)=>b[1].usedAt-v[1].usedAt);for(const[b]of h){if(s<=t.maxBytes)return;a(b)}},d=(h,b)=>{b.size>t.maxImageBytes||(r.set(h,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,l())};return{async get(h){const b=r.get(h);if(b&&c(b))return b.usedAt=n(),i.hits+=1,b.blob;b&&a(h);const v=o.get(h);if(v!==void 0)return v;i.loads+=1;const w=(async()=>{try{const C=await e.load(h);return C?d(h,C):i.failures+=1,C}catch{i.failures+=1;return}finally{o.delete(h)}})();return o.set(h,w),w},forget(h){a(h),o.delete(h)},configure(h){Object.assign(t,{maxBytes:h.maxBytes??t.maxBytes,maxImageBytes:h.maxImageBytes??t.maxImageBytes,ttlMs:h.ttlMs??t.ttlMs});for(const[b,v]of r)v.bytes>t.maxImageBytes&&a(b);l()},clear(){r.clear(),o.clear(),s=0},stats(){return{entries:r.size,bytes:s,...i}}}}var Fh=["emcdn.ru","scr.emcdn.ru"];function Bh(e){const t=String(e??"").trim();if(!t)return"";try{return new URL(t.includes("//")?t:`https://${t}`).hostname}catch{return t.split("/")[0].split(":")[0]}}function jh(e,t){const n=(r,o)=>{const i=new Set(o?t:[]);for(const s of r){const a=Bh(s);a&&i.add(a)}return[...i]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Uh(e){const t=e??{},n=t.isPlugin!==!0?Fh:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...it};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:jh(o.sourceHosts,n),maxBytes:o.maxBytes??it.maxBytes,maxImageBytes:o.maxImageBytes??it.maxImageBytes,ttlMs:o.ttlMs??it.ttlMs}}function Hh(e){const t=he(e),n=e.getInstance(be),r=()=>Uh({...n?.get(),isPlugin:!0});let o=r();const i=Lh({sourceHosts:()=>o.sourceHosts}),s=Nh({load:C=>i.load(C),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(z.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},c=t.onInit(()=>a()),l=n?.watch(()=>{const C=r(),y=JSON.stringify(C)!==JSON.stringify(o);o=C,s.configure(C),C.enabled||s.clear(),y&&t.isInited()&&a()}),d={asked:0,served:0,refused:0},h=[],b=(C,y)=>(d.refused+=1,h.push({url:C,reason:y}),h.length>20&&h.shift(),{refused:!0}),v=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...d},refusals:[...h],store:s.stats()})}),w=t.addListenerAsync(z.APPLICATION_CANVAS_IMAGE_GET,async C=>{const y=C?.url??"";if(d.asked+=1,!o.enabled||!y)return b(y,"disabled");if(!i.accepts(y))return b(y,"host");C.fresh&&s.forget(y);const S=await s.get(y);return S?(d.served+=1,{blob:S}):b(y,"load-failed")});e.getInstance(W)?.addDispose(()=>{c.dispose(),l?.dispose(),w.dispose(),s.clear(),delete v.__emmCanvasImages__})}var $h=2e3;function Vh(e){const t=he(e),n=new Map,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;clearTimeout(n.get(s));const a=new MessageChannel;let c=!1,l=!1;const d=b=>{b.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",d),l&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",d),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const h=setTimeout(()=>{n.get(s)===h&&n.delete(s),!(c||!t.hasPort(s,a.port1))&&(Wt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),l=!0,t.holdPort(s))},$h);n.set(s,h)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),i=t.onInit(()=>r());e.getInstance(W)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);i.dispose(),delete o.__emmCanvasPort__})}var qh=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Gh(e){return qh.test(e)||e.indexOf("//")===0}function hn(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Wh(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Zi(e,t){const n=e==null||e===""?"./":String(e);if(Gh(n))return hn(n);const r=t??Wh();if(!r)return hn(n);try{return hn(new URL(n,r).href)}catch{return hn(n)}}function zh(){return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.publicPath?Zi(window.__emailmaker__.publicPath):Zi("/")}var Kh=()=>"",Yh=()=>"87ebe001";function Xh(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function Gc(e){const t=e?"iframe-eblock":"iframe",n=Kh();if(n){const i=Xh(n,window.location).replace(/\/?$/,"/");return Di(`${i}${t}.html`,Gt())}const r=Yh(),o=`${zh().replace(/\/?$/,"/")}iframe/`;return Di(`${o}${t}${r?`.${r}`:""}.html`,Gt())}var es="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function ao(e){return/^file:/i.test(String(e||"").trim())}function Jh(e){return ao(e)?`${es} allow-same-origin`:es}var Qh="em:module-body-ack";function Zh(e,t,n){try{const r=new URL("./",new URL(t,n)).href,o=new URL(e,r).href;return o.startsWith(r)?o:void 0}catch{return}}function oi(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function em(e){const t=oi(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function tm(e,t){const n=oi(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function nm(e,t){const n=oi(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),i=[r],s=[];for(;i.length>0;)for(const a of e[i.shift()]??[])o.has(a)||(o.add(a),s.push(a),i.push(a));return s}var rm=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function om(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&rm.test(t[t.length-2])}async function im(e,t){const n=om(e)?{}:{cache:"no-cache"};t?.priority&&(n.priority=t.priority);try{const r=await fetch(e,n);return r.ok?await r.blob():void 0}catch{return}}function sm(e){const t=new Map,n=(r,o)=>{const i=Zh(r,e.canvasSrc,e.origin);if(!i)return;const s=t.get(i);if(s!==void 0)return s;const a=e.fetchBody(i,o);return t.set(i,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const i of r)n(i,o)},reset(){t.clear()},get size(){return t.size}}}var Le;function am(e){try{return ao(new URL(e,window.location.href).href)}catch{return ao(window.location.href)}}function Wc(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.preload?.canvasCrossOrigin===!0}var cm=()=>Promise.resolve(void 0);function zc(){const e=Gc(!1);if(!am(e)){if(!Le||Le.canvasSrc!==e){const t=Wc(e)?im:cm;Le={canvasSrc:e,store:sm({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return Le.store}}async function lm(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const o=await r.json();t(tm(o,e))}catch{}}function ii(e){const t=zc();if(!t||!Le||Le.warmed||!Wc(Le.canvasSrc))return;Le.warmed=!0;const{canvasSrc:n}=Le,r=em(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.CO37NCd9.js"],"js/iframe.js":["js/elMarkupHelper.CO37NCd9.js"],"js/darkreader.CLd5EML2.js":[],"js/elMarkupHelper.CO37NCd9.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.Mun9CrLC.js":[]};o?t.warm(nm(o,n),e):lm(n,i=>t.warm(i,e))}function dm(e){const t=zc();if(!t)return;ii();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const i=r.source;i&&(i.postMessage({operationId:Qh,for:o.result},"*"),t.take(o.data?.url??"").then(s=>{i.postMessage({operationId:o.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(W)?.addDispose(()=>{window.removeEventListener("message",n)})}var gt=/<script\b(?=[^>]*(?:\bbis_use(?:=|\s)|\bdata-bis-config(?:=|\s)|\bdata-dynamic-id(?:=|\s)|local\.adguard\.org|(?:chrome-extension|moz-extension|safari-extension):\/\/))[^>]*>[\s\S]*?<\/script>/gi,um=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,It=/<style\b[^>]*>[\s\S]*?<\/style>/gi,ts=/display:\s*none\s*!important/gi,fm=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,pm=/\s*height\s*:\s*100%\s*!important\s*;?/gi,hm=/height\s*:\s*100%\s*!important/i,mm=[".socialshare,",".advertisment,",".adHolder,",".adsbygoogle-noablate","#ab_adblock","#popmechanic-snippet","filter_ads_by_classname","clever-core-ads","--gn-ov-ad-height","pub_728x90.text-ad.textAd","html-load.com/player","content-loader.com/player",".adblock","#advblock","body { overflow: visible!important; }"];function gm(e){return ts.lastIndex=0,(e.match(ts)||[]).length}function Kc(e){const t=e.trim(),n=gm(t);if(n===0)return!1;if(t.includes(".advertisment,")&&t.includes(".adHolder,")&&(t.includes(".socialshare,")||n>=3||t.length>2e3))return!0;const r=mm.filter(o=>t.includes(o)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function vm(e){It.lastIndex=0;for(const t of e.matchAll(It))if(Kc(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function bm(e){let t=!1;return It.lastIndex=0,{html:e.replace(It,n=>Kc(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function ym(e){return gt.lastIndex=0,gt.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||vm(e)}function _m(e){if(!ym(e))return{html:e,found:!1};let t=!1,n=e;gt.lastIndex=0,gt.test(n)&&(gt.lastIndex=0,n=n.replace(gt,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(um,""),t=!0);const r=bm(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Em(e){return!e||!hm.test(e)?e:(It.lastIndex=0,e.replace(It,t=>t.replace(fm,(n,r,o,i)=>`${r}${o.replace(pm,"")}${i}`)))}function Yc(e){const t=_m(e.replaceAll(`\r
|
|
1002
|
+
`)}function rr(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function tn(e,t){return _o(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function cm(e,t,n){const{latest:r}=e,i=Wn(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(o=>Wn(o,r.html))?i?{revision:null,phase:"normal"}:{revision:rr(t),phase:"timeout"}:i?{revision:tn(e),phase:"normal"}:Wn(t.html,r.html)?{revision:rr(t),phase:"found"}:{revision:tn(e),phase:"normal"}}function lm({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:i=!1,readShownContent:o,onFacts:s,onLate:a,onError:c,pageLoadTs:l=am()}){const u=r??e;let d=null,m=!1,_=!1,v=0,E={emailId:e,historyLoaded:!1,isRecovering:!1},y=null;const k=new Promise(S=>{y=S}),C=S=>{E={...E,...S},s(E)};let F;const T=S=>{v+=1,C({applied:{phase:S,seq:v}})},R=()=>{d?.timer&&clearTimeout(d.timer),d=null},A=S=>{if(!_){if(y){const w=y;y=null,w(S),F=S.revision?S.phase:void 0;return}a(S)&&S.revision&&T(S.phase)}},D=()=>{if(!d||_)return;const S=d.phase==="fast",w=S?nm:om,M=S?im:sm;d.timer=setTimeout(()=>{const B=d;if(!(!B||_)){if(B.attempts+=1,p(),S&&B.attempts>=M){const{pending:W}=B;st(u),C({isRecovering:!1}),A({revision:rr(W),phase:"timeout"}),m=!0,B.phase="bg",B.attempts=0,D();return}if(!S&&B.attempts>=M){st(u),R(),C({isRecovering:!1}),m=!0;return}D()}},w),d.timer.unref?.()},O=S=>{d={phase:"fast",attempts:0,pending:S,timer:null},C({isRecovering:!0}),D()},h=S=>{if(_)return;if(C({historyLoaded:!0,latestRevisionAt:S.latestAt!==void 0&&Number.isFinite(S.latestAt)?S.latestAt:void 0}),n&&d){const B=tn(S,d.pending.sentAt);if(!B)return;const W=d.phase==="fast"?"found":"bg";st(u),R(),C({isRecovering:!1}),m=!0,A({revision:B,phase:W});return}if(m)return;const w=n?vr(u):null,M=w&&(w.sentAt<l||!Wn(w.html,o()))?w:null;if(M){if(i&&(M.baseRevisionId!==void 0||M.baseOpen)){st(u),m=!0,A(cm(S,M,o()));return}const B=tn(S,M.sentAt);if(B){st(u),m=!0,A({revision:B,phase:"found"});return}if(i){if(st(u),m=!0,S.latestAt!==void 0&&S.latestAt>M.sentAt+5e3){A({revision:null,phase:"normal"});return}A({revision:rr(M),phase:"timeout"});return}O(M);return}m=!0,A({revision:tn(S),phase:"normal"})},f=S=>{_||(c?.(S),E.historyLoaded||(C({historyLoaded:!1,latestRevisionAt:void 0}),N()),!d&&A({revision:null,phase:"normal"}))},p=()=>t(e).then(h).catch(f);let b,x=!1;const N=()=>{x||d||_||(x=!0,b=setTimeout(()=>{b=void 0,!_&&!E.historyLoaded&&p()},rm))};return p(),{verdict:()=>k,confirmVerdict(S){const w=F;F=void 0,S&&w!==void 0&&!_&&T(w)},dispose(){_=!0,b!==void 0&&(clearTimeout(b),b=void 0),R()}}}function um({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:i,wpId:o,readShownContent:s,onFacts:a}){let c=null;const l=lm({emailId:i,readAutosave:u=>o?e.readAutosave(u,{wpId:o()}):e.readAutosave(u),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:s,onFacts:a,onLate:({revision:u,phase:d})=>{const m=ys(u);return c?.(m)??!1},onError:u=>{u instanceof Error&&u.message}});return{id:"recovery",load:()=>l.verdict().then(({revision:u})=>ys(u)),loaded(u){l.confirmVerdict(u)},watch(u){return c=u,()=>{c=null,l.dispose()}}}}var dm=5e3,fm=U("plugin.knownRevisions");function Lt(e){return e.getOrCreateInstance(fm,()=>new Map)}function So(e,t,n,r){const i=n?.get(t)??[],o=i.filter(s=>s!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...i.length>Il?{baseOpen:!0}:o.length?{baseHtmls:o}:{}}}var pm=U("plugin.uncertainWrites"),Il=3;function wn(e){return e.getOrCreateInstance(pm,()=>new Map)}function hm(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>Il||e.set(t,[...r,n])}function Tl(e,t){yi(e,t)||!t.baseHtmls||yi(e,{...t,baseHtmls:void 0,baseOpen:!0})}function ir(e,t,n,r=!1){const i=vr(e);!n||i?.sentAt!==t||!(r||i.baseOpen||i.baseHtmls)||yi(e,{...i,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function Al(e,t,n,r){(vr(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||Tl(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var mm=/(?:Z|[+-]\d{2}:?\d{2})$/i;function gm(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",i=mm.test(r)?Date.parse(r):NaN;return!Number.isFinite(i)||i>=t-dm}function Cl(e,t,{pendingKey:n=s=>s,knownRevisions:r=new Map,uncertainWrites:i,synchronousHistory:o=!1}={}){return{readRevisions:(s,a,c)=>t.readRevisions(s,a,c),readRevision:(s,a,c)=>t.readRevision?t.readRevision(s,a,c):Promise.resolve(null),readAutosave:(s,a)=>t.readAutosave(s,a),async saveAutosave(s,a,c){const l=n(s),u=Date.now();Tl(l,{sentAt:u,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...So(r,l,i,a.html??"")});const d=await t.saveAutosave(s,a,c),m=d?.id;return gm(d,u)?ir(l,u,m):m&&o&&(d.isAutosave===!0?go(l,u):ir(l,u,m,!0)),await e.saveAutosave(s,a),d}}}function vm(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,i){const o=Date.now();n&&Al(r,i,o,So(n.knownRevisions,r,n.uncertainWrites,i.html??""));const s=await t.updateEmail(r,i);return n&&ir(r,o,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,i),go(r,o),s&&{...s,id:r}}}}var Rl=Symbol.for("emailmaker.result");function Ol(e){return Object.defineProperty(e,Rl,{value:!0})}var pt=(e=>Ol({ok:!0,value:e})),ue=((e,t="")=>Ol({ok:!1,error:{code:e,message:t}}));function kl(e){return typeof e=="object"&&e!==null&&e[Rl]===!0}var tt=e=>({optional:!1,...e}),Pn={string:()=>tt({kind:"string"}),number:()=>tt({kind:"number"}),boolean:()=>tt({kind:"boolean"}),enum:(...e)=>tt({kind:"enum",values:e}),element:(...e)=>tt({kind:"element",kinds:e}),array:e=>tt({kind:"array",item:e}),object:e=>tt({kind:"object",shape:e}),optional:e=>({...e,optional:!0})};function Pl(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function yr(e,t,n){if(t===void 0)return e.optional?void 0:`"${n}" is required`;switch(e.kind){case"string":case"number":case"boolean":return typeof t===e.kind?void 0:`"${n}" must be a ${e.kind}`;case"enum":return e.values?.includes(t)?void 0:`"${n}" must be one of: ${e.values?.join(", ")}`;case"element":return t!==null&&(typeof t=="object"||typeof t=="string")?void 0:`"${n}" must be an element reference`;case"array":if(!Array.isArray(t))return`"${n}" must be an array`;for(let r=0;r<t.length;r+=1){const i=yr(e.item,t[r],`${n}[${r}]`);if(i)return i}return;case"object":return Pl(t)?Dl(e.shape,t,n):`"${n}" must be an object`}}function Dl(e,t,n){for(const[r,i]of Object.entries(e??{})){const o=yr(i,t[r],n?`${n}.${r}`:r);if(o)return o}}function bm(e,t,n){return e?yr(e,t,n):void 0}function _m(e,t){if(!e)return;const n=e;return n.kind!=="object"?yr(n,t,"arguments"):t!==void 0&&!Pl(t)?"arguments must be an object":Dl(n.shape,t??{},"")}function xl(e){const t=e?.["~standard"];return typeof t=="object"&&t!==null&&typeof t.validate=="function"}function ym(e){return(e.path??[]).map(t=>String(typeof t=="object"?t.key:t)).join(".")}function Ml(e,t){if(!xl(e)){const n=_m(e,t);return n?{ok:!1,problem:n}:{ok:!0,value:t??{}}}try{const n=e["~standard"].validate(t??{});return n instanceof Promise?n.then(Cs,As):Cs(n)}catch(n){return As(n)}}function As(e){return{ok:!1,problem:`the arguments check failed: ${e instanceof Error?e.message:String(e)}`}}function Cs(e){if(e.issues){const[t]=e.issues,n=t?ym(t):"";return{ok:!1,problem:t?n?`"${n}": ${t.message}`:t.message:"arguments are invalid"}}return{ok:!0,value:e.value}}var Rs="Element reference returned by element.getTree, element.get or the selection.";function Ii(e){switch(e.kind){case"string":case"number":case"boolean":return{type:e.kind};case"enum":return{type:"string",enum:[...e.values??[]]};case"element":return e.kinds?.length?{type:"string",description:`${Rs} Kinds: ${e.kinds.join(", ")}.`}:{type:"string",description:Rs};case"array":return{type:"array",items:Ii(e.item)};case"object":{const t=Object.entries(e.shape??{}),n=t.filter(([,r])=>!r.optional).map(([r])=>r);return{type:"object",properties:Object.fromEntries(t.map(([r,i])=>[r,Ii(i)])),...n.length?{required:n}:{}}}}}var Em={type:"object",properties:{}};function wm(e){if(!e)return Em;if(!xl(e))return Ii(e);const t=e["~standard"].jsonSchema;if(t&&typeof t.input=="function")return t.input({target:"draft-2020-12"});const n=e.toJSONSchema;if(typeof n=="function")return n.call(e);throw new Error(`The ${e["~standard"].vendor} schema cannot export JSON Schema; use a library version with Standard JSON Schema or Arg.object({...}).`)}function Ae(e,t){try{t()}catch{}}var Sm=Symbol.for("emailmaker.platform.hostError"),or="The editor could not load the code of its commands. Trying again does not help: the user has to reload the page.";function De(e,t){return Object.defineProperty(ue(e,t),Sm,{value:!0})}function Ll(e){const t=globalThis,n=Symbol.for(`emailmaker.platform.owner.${e}`);return t[n]??=Object.freeze({name:e})}var ht=Ll("core"),Os=Ll("unknown"),Nl=Symbol.for("emailmaker.platform.builtInPlugin");function Fl(e){return Symbol.for(`emailmaker.platform.builtInKey.${e}`)}function Io(e){return Object.entries(e).forEach(([t,n])=>{typeof n=="function"&&(Object.defineProperty(n,Nl,{value:!0}),Object.defineProperty(n,Fl(t),{value:!0}))}),e}function Bl(e,t){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Fl(t))}function Im(e){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Nl)}function ks(e){return Im(e.constructor)}var Tm=class{_owners=new WeakMap;_stack=[];_listeners=new Set;current(){return this._stack[this._stack.length-1]??Os}execute(e,t){const n=e===ht?Os:e;this._stack.push(n);try{return t()}finally{this._leave(n)}}onUnload(e){return this._listeners.add(e),{dispose:()=>this._listeners.delete(e)}}handle(e){const{plugin:t}=e;if(t)switch(e.type){case"init:enter":case"afterInit:enter":ks(t)||this._stack.push(this._ownerOf(t,e.name));break;case"init:leave":case"afterInit:leave":ks(t)||this._leave(this._ownerOf(t,e.name));break;case"dispose:start":{const n=this._owners.get(t);n&&(this._leave(n),this._owners.delete(t),Array.from(this._listeners).forEach(r=>r(n)));break}}}_ownerOf(e,t){let n=this._owners.get(e);return n||(n={name:t},this._owners.set(e,n)),n}_leave(e){const t=this._stack.lastIndexOf(e);t>=0&&this._stack.splice(t,1)}};function Er(e){const t={watch:e,select:n=>Er(r=>{let i=!1,o;return t.watch(s=>{const a=n(s);i&&Object.is(o,a)||(i=!0,o=a,r(a))})})};return t}function Am(e){return Er(t=>(t(e),{dispose:()=>{}}))}function Cm(e,t){return Er(n=>{let r=!1,i=!1,o;const s=()=>{if(!r)return;const c=t();i&&Object.is(o,c)||(i=!0,o=c,n(c))},a=e.map(c=>c.watch(s));return r=!0,s(),{dispose:()=>a.forEach(c=>c.dispose())}})}function Ce(e){let t;return e.watch(n=>{t=n}).dispose(),t}function kt(e,t,n){return new Promise((r,i)=>{const o=()=>r(void 0),s=setTimeout(o,t),a=()=>{clearTimeout(s),n?.removeEventListener("abort",o)};n?.aborted&&o(),n?.addEventListener("abort",o,{once:!0}),Promise.resolve().then(e).then(c=>{a(),r(c)},c=>{a(),i(c)})})}function he(e,t){return{ok:!1,error:{code:e,message:t}}}function Gt(e){return he("documentChanged",`"${e}" was not run: another email is open now, not the one this work started on. Stop and tell the user; do not repeat the call.`)}function Rm(e){return he("aborted",`"${e}" was not run: this tool became another command while the user was asked. Read the tools again and ask the user anew with a new call.`)}function Om(e,t){return he("invalidArgs",`Call ${e} ("${t}") needs the user's consent, so its input cannot hold a "$result" reference: the consent window has to show the data. Run the earlier calls first, then send this call in a separate batch with the value written out. No call ran.`)}var nn=e=>he("aborted",`The call of "${e}" was cancelled.`),sr=e=>e instanceof Error?e.message:String(e);function km(){return Object.assign(new Error(or),{code:"unavailable"})}function Pm(){return{code:"undoConflict",message:"An agent call is still running; undo the answer when it ends."}}var Dm=64,xm=/[\w-]+(?:\.[\w-]+)+/g;function bt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,Dm)}function Dn(e,t){return(e??[]).some(n=>n.endsWith(".*")?t.startsWith(n.slice(0,-1)):n===t)}function jl(e,t){const n=new Map(t.map(([r,i])=>[i.id,r]));return e.replace(xm,r=>n.get(r)??r)}var Mm=3e3,Lm=12,Nm=e=>typeof e?.label=="string"&&typeof e.value=="string";function Fm(e){const{title:t,details:n}=e??{};if(typeof t!="string"||!t)return;const r=(Array.isArray(n)?n:[]).filter(Nm).slice(0,Lm);return r.length?{title:t,details:r.map(({label:i,value:o})=>({label:i,value:o}))}:{title:t}}async function Bm(e,t,n,r){const i=t.agent?.consent;if(i)try{return Fm(await kt(()=>e.asOwner(t.id,()=>i(n,r)),Mm))}catch(o){`${t.id}${sr(o)}`;return}}function jm(e,t,n,r,i){return{tool:e,command:t.id,title:t.title,description:t.description&&jl(t.description,i()),input:n,...r?{consent:r}:{},...t.owner===ht?{}:{fromPlugin:!0}}}async function Um({lifetime:e,ask:t,tool:n,signal:r,question:i}){if(r?.aborted||e.aborted)return nn(n);if(!t)return he("forbidden",`The tool "${n}" needs the user's consent, and there is no one to ask in this editor.`);const o=new AbortController,s=()=>o.abort();r?.addEventListener("abort",s,{once:!0}),e.addEventListener("abort",s,{once:!0});const a=new Promise(l=>{o.signal.addEventListener("abort",()=>l(!1),{once:!0})}),c=async()=>{const l=await i(o.signal);return o.signal.aborted?!1:t({...l,signal:o.signal})};try{const l=await Promise.race([c(),a]);return o.signal.aborted?nn(n):l===!0?void 0:De("declined",`The user declined "${n}". Do not repeat the call unless the user asks for it again.`)}catch(l){const u=sr(l);return`${n}${u}`,he("aborted",`The user was not asked about "${n}": ${u}`)}finally{r?.removeEventListener("abort",s),e.removeEventListener("abort",s),o.abort()}}var Ti=Symbol("bad input");function Ps(e){try{return JSON.stringify(e)}catch{return Ti}}var _t=e=>e===void 0?void 0:JSON.parse(e);function Ds(e){if(e===void 0)return null;try{return JSON.parse(JSON.stringify(e))}catch{return"[a value that cannot be serialized]"}}var St="agent.batch",$m=5e3,Hm=5e3,Vm=20,Gm=new Set(["ui.openView","ui.closeView",St]),qm=class{_deps;_confirmHost;_bound;_turnDepth=0;_turnStart;_lastTurn;constructor(e){this._deps=e}setConfirmHost(e){return this._confirmHost=e,{dispose:()=>{this._confirmHost===e&&(this._confirmHost=void 0)}}}get _config(){return Ce(this._deps.config)??{}}get enabled(){return this._config.enabled!==!1}async tools(){const e=await this._describedOpened();return e.map(([t,n])=>({name:t,description:jl(n.description??n.title,e),inputSchema:n.inputSchema??{type:"object",properties:{}},...this._needsConfirm(n)?{confirm:!0}:{}}))}invoke(e,t,n={}){return this._call(e,t,n)}async openBatch(e,t){const n=this._deps.commands.info(St),r=n!==void 0&&this._needsConfirm(n),i=this._openDocument(),o=new Map,s=new Map;for(const[a,c]of e.entries()){const l=this._find(c.tool);if(!l)continue;const[u,d]=l,m=r||this._needsConfirm(d);if(!m&&!d.agent?.precheck)continue;if(c.deferred){if(m)return{ok:!1,error:Om(a,u).error,index:a};continue}const _=Ps(c.input);if(_===Ti)continue;const v=await this._checkInput(d,_t(_),t);if(!v||v.ok===!1||!this._deps.commands.availableNow(d.id))continue;const E=await this._precheck(u,d,v.value,t);if(E)return{ok:!1,error:E.error,index:a};o.set(a,d),m&&s.set(a,{tool:u,info:d,input:v.value,frozen:_})}if(n&&s.size>0){const a=Ds(e.map(({tool:l,input:u})=>({tool:l,args:u}))),c=await this._ask(bt(St),t,async l=>{const u=Array.from(s.values()),d=await Promise.all(u.slice(0,Vm).map(async({tool:_,info:v,input:E,frozen:y})=>this._item(_,v,_t(y),await this._consentOf(v,E,l)))),m=await this._consentOf(n,void 0,l);return{...this._item(bt(St),n,{calls:a},m),batch:{items:d,more:u.length-d.length}}});if(c)return{ok:!1,error:{...c.error,message:`${c.error.message} None of the calls of the batch ran.`}};if(this._openDocument()!==i)return{ok:!1,error:Gt(bt(St)).error}}return{ok:!0,run:(a,c)=>{const l=s.get(a);return this._call(e[a].tool,l?_t(l.frozen):c,{signal:t},{consented:l?.info,prechecked:o.get(a),askAll:r})}}}async _call(e,t,n,r={}){if(!this.enabled)return he("forbidden","The agent is switched off in this editor.");const i=this._find(e);if(!i)return this._deps.commands.info(e)??(Ce(this._deps.commands.commands)??[]).find(v=>bt(v.id)===e)?he("forbidden",`The tool "${e}" is not opened to the agent here.`):he("notInstalled",`There is no tool "${e}" in this editor.`);const[o,s]=i,a=Ps(t);if(a===Ti)return he("invalidArgs",`Tool "${o}": the input must be plain JSON data.`);const c=await this._checkInput(s,_t(a),n.signal);if(!c)return n.signal?.aborted?nn(o):he("unavailable",this._deps.commands.undescribed(s.id)?or:`The input of the tool "${o}" could not be checked; try again.`);if(c.ok===!1)return he("invalidArgs",`Tool "${o}": ${c.problem}.`);const l=this._openDocument();if(this._adoptOpened(l),this._bound&&this._bound.document!==l)return Gt(o);if(!this._deps.commands.availableNow(s.id))return he("unavailable",`The tool "${o}" is not available right now.`);if(r.prechecked!==s&&s.agent?.precheck){const v=await this._precheck(o,s,c.value,n.signal);if(v)return v;if(this._openDocument()!==l)return Gt(o)}let u=r.consented;if(!u&&(r.askAll||this._needsConfirm(s))&&!(s.id===St&&s.owner===ht)){const v=await this._ask(o,n.signal,async E=>this._item(o,s,_t(a),await this._consentOf(s,c.value,E)));if(v)return v;if(this._openDocument()!==l)return Gt(o);u=s}const d=this._deps.commands.prepared(s.id,n.signal);if(d!==!0){if(!await d)return n.signal?.aborted?nn(o):he("unavailable",or);const v=this._openDocument();if(this._adoptOpened(v),l!==void 0&&v!==l)return Gt(o)}if(this._find(o)?.[1]!==(u??s))return Rm(o);const m=()=>this._deps.commands.run(s.id,_t(a),{caller:"agent",signal:n.signal}),_=await(Gm.has(s.id)||s.agent?.readOnly?m():this._deps.history.group(m));return _.ok===!1?he(_.error.code,_.error.message||`The tool "${o}" failed: ${_.error.code}.`):{ok:!0,value:Ds(_.value)}}readOnlyTool(e){return this._find(e)?.[1].agent?.readOnly===!0}get answerOpen(){return this._bound!==void 0}async holdDocument(e){const t=this._bound??={document:this._openDocument(),holders:0};t.holders+=1;try{return await e()}finally{t.holders-=1,t.holders===0&&(this._bound=void 0)}}_adoptOpened(e){this._bound&&this._bound.document===void 0&&e!==void 0&&(this._bound.document=e,this._deps.history.reopen(),this._turnDepth>0&&(this._turnStart=this._deps.history.answers?.capture()))}async turn(e){this._turnDepth===0&&(this._turnStart=this._deps.history.answers?.capture()),this._turnDepth+=1;try{return await this.holdDocument(()=>this._deps.history.group(e))}finally{this._turnDepth-=1,this._turnDepth===0&&(this._lastTurn={start:this._turnStart,end:this._deps.history.answers?.capture()})}}async undoTurn(){if(!this.enabled)return he("forbidden","The agent is switched off in this editor.");const e=this._deps.history.answers,t=e?.undoRefusal();if(t)return{ok:!1,error:t};const n=this._lastTurn;if(!e||!n)return he("nothingToUndo","There is no answer to undo.");this._lastTurn=void 0;try{const r=await e.settle()??(this._deps.history.grouping?Pm():e.undo(n.start,n.end));return r?(this._lastTurn??=n,{ok:!1,error:r}):{ok:!0,value:null}}catch(r){this._lastTurn??=n;const i=sr(r);return`${i}`,he("undoConflict",`The answer could not be undone: ${i}`)}}_needsConfirm(e){const{confirm:t}=this._config;return e.agent?.confirm===!0||Dn(t,e.id)||Dn(t,bt(e.id))}_openDocument(){return this._deps.history.answers?.document()}_find(e){return this._opened().find(([t,n])=>t===e||n.id===e)}_opened(){if(!this.enabled)return[];const e=this._config.deny,t=new Map;for(const n of Ce(this._deps.commands.commands)??[]){const r=bt(n.id);if(!n.agent||Dn(e,n.id)||Dn(e,r))continue;const i=t.get(r);if(i){`${i.id}${n.id}${r}`;continue}t.set(r,n)}return Array.from(t.entries())}async _describedOpened(){const{commands:e}=this._deps;let t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id));for(;n.length>0;){if((await Promise.all(n.map(([,r])=>e.described(r.id)))).includes(!1))throw km();t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id))}return t}async _checkInput(e,t,n){const{commands:r}=this._deps;if(r.undescribed(e.id)&&!await r.described(e.id,n))return;const i=Ml(this._deps.commands.declarationArgs(e.id),t);return i instanceof Promise?kt(()=>i,Hm,n):i}async _precheck(e,t,n,r){const i=t.agent?.precheck;if(i){try{const o=await kt(()=>this._deps.commands.asOwner(t.id,()=>i(n)),$m,r);if(kl(o)&&o.ok===!1){const{code:s,message:a}=o.error;return he(s,a||`The tool "${e}" was refused: ${s}.`)}}catch(o){`${t.id}${sr(o)}`}return r?.aborted?nn(e):void 0}}_consentOf(e,t,n){return Bm(this._deps.commands,e,t,n)}_item(e,t,n,r){return jm(e,t,n,r,()=>this._opened())}_ask(e,t,n){const r=this._config.onConfirm??(Ce(this._deps.facts)?.headless?void 0:this._confirmHost);return Um({lifetime:this._deps.commands.lifetime,ask:r,tool:e,signal:t,question:n})}},Wm={documentOpen:!1,selection:"none",codeMode:!1,readOnly:!1,headless:!1};function rn(e,t){if(!e)return!0;if("any"in e)return e.any.some(r=>rn(r,t));if("not"in e)return!rn(e.not,t);const n={...Wm,...t};return Object.entries(e).every(([r,i])=>n[r]===i)}var zm=5e3,xs=3e4;function Ul(e){const{agent:t}=e;if(!t)return;if(t===!0)return{};const{readOnly:n,consent:r,precheck:i}=t;return{confirm:t.confirm===!0,...n===!0?{readOnly:!0}:{},...typeof r=="function"?{consent:r}:{},...typeof i=="function"?{precheck:i}:{}}}function Ms(e,t,n){if(Ul(n))try{return wm(n.args)}catch(r){throw new Error(`Command "${e}" of "${t.name}" is opened to the agent, but its arguments cannot be described for the model: `+(r instanceof Error?r.message:String(r)))}}function Km(e,t,{agent:n,description:r}){n&&!(typeof r=="string"&&r.trim())&&(`${e}${t.name}`,void 0)}var Ym=class{_facts;_owners;_entries=new Map;_list=ce([]);_disposed=!1;_lifetime=new AbortController;constructor(e,t){this._facts=e,this._owners=t}get commands(){return this._list}has(e){return this._entries.has(e)}register(e,t,n,r={},i={}){if(this._disposed)return`${e.name}`,{dispose:()=>{}};const o=Object.keys(t);for(const l of o){const u=this._entries.get(l);if(u&&!u.yieldable)throw new Error(`Command "${l}" is already registered by "${u.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(typeof n[l]!="function")throw new Error(`Command "${l}" of "${e.name}" has no handler.`)}const s=new Map(o.map(l=>[l,i.details?void 0:Ms(l,e,t[l])]));i.details||o.forEach(l=>Km(l,e,t[l]));const a=o.map(l=>({id:l,owner:e,declaration:t[l],handler:n[l],enabled:r[l]??Am(!0),pending:new Set,agent:Ul(t[l]),inputSchema:s.get(l),yieldable:i.yieldable===!0,details:i.details,prepare:i.prepare}));this._detach(o.flatMap(l=>this._entries.get(l)??[])),a.forEach(l=>this._entries.set(l.id,l)),this._publish();let c=!1;return{dispose:()=>{c||(c=!0,this._remove(a))}}}disposeOwner(e){this._remove(Array.from(this._entries.values()).filter(t=>t.owner===e))}disposeAll(){this._disposed=!0,this._remove(Array.from(this._entries.values())),this._lifetime.abort()}get disposed(){return this._disposed}get lifetime(){return this._lifetime.signal}async run(e,t,n){if(this._disposed)return De("unavailable",`Command "${e}" is not available: the editor was destroyed.`);const r=this._entries.get(e);if(!r)return De("notInstalled",`Command "${e}" is not installed in this host.`);if(n.caller==="agent"&&!r.agent)return De("forbidden",`Command "${e}" is not opened to the agent.`);if(!rn(r.declaration.when,Ce(this._facts)??{})||Ce(r.enabled)===!1)return De("unavailable",`Command "${e}" is not available right now.`);const i=n.signal,o=n.nested&&i?.aborted;if(r.details&&!await this._describe(r,o?void 0:i))return i?.aborted&&!o?ue("aborted",`Command "${e}" was cancelled.`):De("unavailable",or);const s=Ml(r.declaration.args,t),a=s instanceof Promise?await kt(()=>s,zm,o?void 0:i):s;if(!a)return i?.aborted?ue("aborted",`Command "${e}" was cancelled.`):De("unavailable",`Command "${e}": the check of its arguments did not answer in time.`);if(a.ok===!1)return De("invalidArgs",`Command "${e}": ${a.problem}.`);if(this._disposed||this._entries.get(e)!==r)return De("unavailable",`Command "${e}" was removed while its arguments were checked.`);const c=new AbortController,l=new Promise(m=>{c.signal.addEventListener("abort",()=>m(ue("aborted",`Command "${e}" was cancelled.`)),{once:!0})});if(i?.aborted&&!o)return ue("aborted",`Command "${e}" was cancelled before it started.`);const u=()=>c.abort();i?.addEventListener("abort",u,{once:!0}),r.pending.add(c);const d={signal:c.signal,caller:n.caller,run:(m,_)=>this.run(m,_,{caller:"plugin",signal:c.signal,nested:!0})};try{return await Promise.race([this._execute(r,a.value,d),l])}finally{i?.removeEventListener("abort",u),r.pending.delete(c)}}visible(e){return Cm([this._list,this._facts],()=>{const t=this._entries.get(e);return t!==void 0&&rn(t.declaration.when,Ce(this._facts)??{})})}enabled(e){return Er(t=>{let n,r;const i=s=>{s!==r&&(r=s,t(s))},o=this._list.watch(()=>{n?.dispose();const s=this._entries.get(e);n=s?s.enabled.watch(i):void 0,s||i(!1)});return{dispose:()=>{o.dispose(),n?.dispose()}}})}declarationArgs(e){return this._entries.get(e)?.declaration.args}undescribed(e){return this._entries.get(e)?.details!==void 0}async described(e,t){const n=this._entries.get(e);return n?.details?this._describe(n,t):!0}prepared(e,t){const n=this._entries.get(e);return n?.prepare?this._prepare(n,n.prepare,t):!0}async _prepare(e,t,n){const r=new AbortController,i=()=>r.abort();n?.aborted&&i(),n?.addEventListener("abort",i,{once:!0}),e.pending.add(r);try{return await kt(()=>t().then(()=>!0),xs,r.signal)===!0}catch{return!1}finally{n?.removeEventListener("abort",i),e.pending.delete(r)}}availableNow(e){const t=this._entries.get(e);return!this._disposed&&t!==void 0&&rn(t.declaration.when,Ce(this._facts)??{})&&Ce(t.enabled)!==!1}info(e){const t=this._entries.get(e);return t&&Ls(t)}asOwner(e,t){const n=this._entries.get(e);return n&&this._owners?this._owners.execute(n.owner,t):t()}_describe(e,t){return kt(()=>{const{details:r}=e;return r&&(e.detailsLoading??=this._loadDetails(e,r))},xs,t).then(()=>e.details===void 0,()=>!1)}async _loadDetails(e,t){try{const n=await t(),r={...e.declaration,...n[e.id]};e.inputSchema=Ms(e.id,e.owner,r),e.declaration=r,e.details=void 0}finally{e.detailsLoading=void 0}}async _execute(e,t,n){try{const r=e.handler,i=()=>r(t,n),o=await(this._owners?this._owners.execute(e.owner,i):i());return kl(o)?o:pt(o)}catch(r){return ue("internal",r instanceof Error?r.message:String(r))}}_remove(e){this._detach(e)&&this._publish()}_detach(e){let t=!1;for(const n of e)this._entries.get(n.id)===n&&(this._entries.delete(n.id),t=!0),n.pending.forEach(r=>r.abort());return t}_publish(){this._list.set(Array.from(this._entries.values()).map(Ls))}};function Ls(e){const{title:t,icon:n}=e.declaration;return e.info??={id:e.id,owner:e.owner,title:t,get description(){return e.declaration.description},icon:n,agent:e.agent,get inputSchema(){return e.inputSchema}}}var Ns=5e3,Fs=Symbol("timedOut"),Xm=class{_willSave=[];_changes=[];_selection=ce(null);get selection(){return this._selection}onWillSave(e,t){return this._add(this._willSave,{owner:e,handler:t})}onDidChange(e,t){return this._add(this._changes,{owner:e,handler:t})}async runWillSave(e){for(const{owner:t,handler:n}of this._willSave.slice()){const r=new AbortController;let i;const o=new Promise(s=>{i=setTimeout(()=>s(Fs),Ns)});try{const s=await Promise.race([Promise.resolve().then(()=>n({...e,signal:r.signal})),o]);if(s===Fs){`${t.name}${Ns}`;continue}if(s&&typeof s=="object"&&typeof s.refuse=="string")return{owner:t.name,message:s.refuse}}catch(s){`${t.name}${s instanceof Error?s.message:String(s)}`}finally{clearTimeout(i),r.abort()}}}emitChange(e){for(const{owner:t,handler:n}of this._changes.slice())try{n(e)}catch(r){`${t.name}${r instanceof Error?r.message:String(r)}`}}disposeOwner(e){for(const t of[this._willSave,this._changes])for(let n=t.length-1;n>=0;n-=1)t[n].owner===e&&t.splice(n,1)}_add(e,t){return e.push(t),{dispose:()=>{const n=e.indexOf(t);n>=0&&e.splice(n,1)}}}},Jm=Symbol.for("emailmaker.domView");function Qm(e){return typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.$$typeof=="symbol"}function Zm(e){return typeof e=="object"&&e!==null&&typeof e[Jm]=="function"}var qt=["plugins"],eg={toolbar:{kind:"item",groups:["view","collaboration","document","plugins","primary"]},"menu:document":{kind:"item",groups:["document","plugins","access","danger"]},"menu:export":{kind:"item",groups:["formats","plugins","platforms"]},"menu:view":{kind:"item",groups:["preview","plugins","share"]},"menu:save":{kind:"item",groups:qt},statusBar:{kind:"item",groups:["selection","document","plugins","collaboration"]},notices:{kind:"item",groups:qt},sidebar:{kind:"view",groups:["content","collaboration","analysis","plugins","settings"]},dialog:{kind:"view",groups:qt},documentSettings:{kind:"view",groups:qt},inspector:{kind:"view",groups:qt}},Hr="plugins";function tg(e,t){const n=e.groups.indexOf(t);return n<0?e.groups.length:n}var ng=Symbol.for("emailmaker.viewHost"),Vr={dispose:()=>{}},rg=class{_deps;apiVersion="1.0";_locations=new Map(Object.entries(eg));_items=ce([]);_views=ce([]);_opened=ce([]);_viewById=new Map;_seq=0;_openedKey=0;_disposed=!1;constructor(e){this._deps=e,this._registerCoreCommands()}get opened(){return this._opened}registerLocation(e,t){if(this._locations.has(e))throw new Error(`Location "${e}" is already registered.`);return this._locations.set(e,t),{dispose:()=>{this._locations.get(e)===t&&this._locations.delete(e)}}}addItem(e,t){if(this._skipAfterDispose(e))return Vr;const n=this._itemLocation(t.location,"item",e);if(!n)return Vr;const r={seq:this._nextSeq(),owner:e,location:t.location,group:this._groupOf(n,t.group,t.location),order:t.order??0,item:t};return this._items.set([...this._items.get()??[],r]),{dispose:()=>this._removeItems(i=>i===r)}}addViews(e,t,n,r){if(this._skipAfterDispose(e))return Vr;const i=Object.keys(t);for(const s of i){const a=this._viewById.get(s);if(a)throw new Error(`View "${s}" is already registered by "${a.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(!Qm(n[s])&&!Zm(n[s]))throw new Error(`View "${s}" of "${e.name}" has no component; pass a React component or domView(renderer).`)}const o=[];for(const s of i){const a=t[s],c=this._itemLocation(a.location,"view",e);if(c){const l=this._groupOf(c,a.group,a.location);o.push({seq:this._nextSeq(),id:s,owner:e,location:a.location,group:l,order:a.order??0,declaration:a,renderer:n[s],editor:r})}}return o.forEach(s=>this._viewById.set(s.id,s)),this._views.set([...this._views.get()??[],...o]),{dispose:()=>this._removeViews(s=>o.includes(s))}}open(e,t){if(this._disposed)return Promise.resolve(ue("cancelled",`View "${e}" cannot open: the editor was destroyed.`));if(Ce(this._deps.facts)?.headless)return Promise.resolve(De("unavailable",`View "${e}" cannot open: the editor has no interface.`));const n=this._viewById.get(e);if(!n)return Promise.resolve(De("notInstalled",`View "${e}" is not installed in this host.`));const r=bm(n.declaration.input,t,"input");if(r)return Promise.resolve(De("invalidArgs",`View "${e}": ${r}.`));const i=n.location==="inspector"?this._inspectedElement():void 0;return n.location==="inspector"&&!i?Promise.resolve(De("unavailable",`View "${e}" cannot open: no element is selected.`)):(this.close(e),new Promise(o=>{const s=new AbortController;let a=!1;const c=m=>{if(!a){a=!0;try{this._opened.set((this._opened.get()??[]).filter(_=>_!==d))}finally{i?.dispose(),s.abort(),o(m)}}},l=m=>c(pt(m)),u={input:t,signal:s.signal,close:l};i&&Object.defineProperty(u,"element",{value:i.element,enumerable:!0}),Object.defineProperty(u,ng,{value:this._viewHost(n)});const d={key:this._openedKey+=1,view:e,owner:n.owner,location:n.location,input:t,record:n,renderer:n.renderer,signal:s.signal,context:u,close:l,cancel:()=>c(ue("cancelled",`View "${e}" was closed without a result.`))};this._opened.set([...this._opened.get()??[],d])}))}_inspectedElement(){const e=this._deps.selection,t=e?Ce(e):void 0;if(!e||t==null)return;const n=ce(t),r=e.watch(i=>{i!=null&&n.set(i)});return{element:n,dispose:()=>r.dispose()}}viewLocation(e){return this._viewById.get(e)?.location}close(e){(this._opened.get()??[]).filter(t=>t.view===e).forEach(t=>t.cancel())}items(e){return this._items.select(t=>this._sorted(t,e))}get allViews(){return this._views}views(e){return this._views.select(t=>this._sorted(t,e))}disposeOwner(e){Ae("items",()=>this._removeItems(t=>t.owner===e)),Ae("views",()=>this._removeViews(t=>t.owner===e))}disposeAll(){this._disposed=!0,Ae("items",()=>this._removeItems(()=>!0)),Ae("views",()=>this._removeViews(()=>!0))}supports(e,t){switch(e){case"service":return t==="Commands"||t==="Ui"||t==="Agent"||t==="Document";case"location":return this._locations.has(t);case"command":return this._deps.commands.has(t);case"view":return this._viewById.has(t)}}_sorted(e,t){const n=this._locations.get(t),r=i=>n?tg(n,i.group):0;return e.filter(i=>i.location===t).sort((i,o)=>r(i)-r(o)||i.order-o.order||i.seq-o.seq)}_itemLocation(e,t,n){const r=this._locations.get(e);if(!r)`${n.name}${e}`;else if(r.kind!==t){`${n.name}`,`${e}${r.kind}`;return}return r}_groupOf(e,t,n){return t===void 0?Hr:e.groups.includes(t)?t:(`${n}${t}${Hr}`,Hr)}_nextSeq(){return this._seq+=1,this._seq}_removeItems(e){const t=this._items.get()??[];t.some(e)&&this._items.set(t.filter(n=>!e(n)))}_removeViews(e){const t=this._views.get()??[],n=t.filter(e);if(n.length!==0){n.forEach(r=>this._viewById.delete(r.id));try{this._views.set(t.filter(r=>!e(r)))}finally{(this._opened.get()??[]).filter(r=>n.includes(r.record)).forEach(r=>Ae(`close ${r.view}`,()=>r.cancel()))}}}_skipAfterDispose(e){return this._disposed&&(`${e.name}`,void 0),this._disposed}_viewHost(e){return{run:(t,n)=>this._deps.commands.run(t,n,{caller:"ui"}),editor:e.editor}}_registerCoreCommands(){this._deps.commands.register(ht,{"ui.openView":{title:"Open view",description:"Opens a plugin view by id and waits for its output; a dialog resolves when the user closes it.",args:Pn.object({view:Pn.string()}),agent:!0},"ui.closeView":{title:"Close view",description:"Closes an open view by id.",args:Pn.object({view:Pn.string()}),agent:!0}},{"ui.openView":e=>this.open(e.view,e.input),"ui.closeView":e=>(this.close(e.view),pt())})}};function ig(){return ce({})}function Wt(e,t){const n=e.get()??{};Object.keys(t).some(r=>n[r]!==t[r])&&e.set({...n,...t})}var og=class{_depth=0;_host;_open;connect(e){return this._host=e,{dispose:()=>{this._host===e&&(this._host=void 0)}}}get grouping(){return this._depth>0}get answers(){return this._host?.answers}async group(e){this._enter();try{return await e()}finally{this._leave()}}reopen(){this._depth>0&&this._open?.begin()}_enter(){this._depth+=1,this._depth===1&&(this._open=this._host,this._open?.begin())}_leave(){if(this._depth-=1,this._depth===0){const e=this._open;this._open=void 0,e?.end()}}},sg=U("platform.ownerTracker"),ag=U("platform.whenFacts"),cg=U("platform.commandRegistry"),lg=U("platform.uiService"),ug=U("platform.editHistory"),dg=U("platform.agentConfig"),fg=U("platform.agentService"),pg=U("platform.documentEvents");function mt(e){return e.getOrCreateInstance(sg,()=>{const t=new Tm;return t.onUnload(n=>{Ae("commands",()=>je(e).disposeOwner(n)),Ae("ui",()=>wr(e).disposeOwner(n)),Ae("document",()=>Ye(e).disposeOwner(n))}),t})}function $t(e){return e.getOrCreateInstance(ag,ig)}function To(e){return e.getOrCreateInstance(ug,()=>new og)}function hg(e){const{isDisposed:t}=e;return typeof t=="function"&&t.call(e)}function $l(e){return e.getOrCreateInstance(cg,()=>new Ym($t(e),mt(e)))}function mg(e){return e.getOrCreateInstance(lg,()=>(mt(e),new rg({commands:$l(e),facts:$t(e),selection:Ye(e).selection})))}function Hl(e){const t=$l(e),n=mg(e);return!t.disposed&&hg(e)&&(Ae("ui",()=>n.disposeAll()),Ae("commands",()=>t.disposeAll())),{registry:t,ui:n}}function je(e){return Hl(e).registry}function wr(e){return Hl(e).ui}function Vl(e){return e.getOrCreateInstance(dg,()=>ce({}))}function xn(e){return e.getOrCreateInstance(fg,()=>new qm({commands:je(e),history:To(e),config:Vl(e),facts:$t(e)}))}function Ye(e){return e.getOrCreateInstance(pg,()=>new Xm)}function gg(e){return async(t,n)=>{const r=ee(n)?"block":"email";return(await Ye(e).runWillSave({kind:r,id:t.id==null?null:String(t.id),content:t.html??""}))?.message}}var Gl=U("CurrentUser"),ql={};function Ao(e){return e.getOrCreateInstance(Gl,()=>ce(ql))}function Wl(e){return e?.getInstance(Gl)?.get()??ql}var zl=U("HeadlessMode");function Co(e){return e.getOrCreateInstance(zl,()=>ce(!1))}function vg(e){return e?.getInstance(zl)?.get()??!1}var bg=U("HiddenMount");function _g(e){return e.getOrCreateInstance(bg,()=>ce(!1))}function yg(e){if(!e)return!1;try{return!!no(e).data?.act_as}catch{return!1}}function Eg(e){return yg(e?.getInstance(Tc)?.get(wf.em_token))}var wg="SAVE_BUTTON",Sg="AUTOSAVE",Ig=Symbol.for("emailmaker.saveNotified"),Tg=U("helpers.saveListeners");function Ag(e,t="email"){return(e.getInstance(Tg)?.[t]??0)>0}function Kl(e){return e?.getInstance(ge)?.get()??{}}function Sr(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Cg(e,t){return t.modeDefaults(Sr(e,t.fallbackMode))}function Yl(e,t){const n=Sr(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Xl(e,t){const n=Sr(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function Rg(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Og(e){return Zd(e.map(t=>t?.resourceProxy))}function kg(e){return rf(e.map(t=>t?.resourceProxyPolicy))}function Pg(e){return Yd(e.map(t=>t?.backendProxy))}function Dg(e){return Cc(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function xg(e,t){return[e.base,Cg(e,t),e.profile,e.serverSide,Yl(e,t.fallbackMode),e.local,e.user,Xl(e,t.fallbackMode)]}function Gr(e,t){const n=xg(e,t),r=Cc(n),i=Rg(n);i!==void 0&&(r.fileManager=i);const o=Og(n);o!==void 0&&(r.resourceProxy=o);const s=kg(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=Pg(n);a!==void 0&&(r.backendProxy=a);const c=Dg(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function Mg(e,t,n){const r=Yl(e,n),i=Xl(e,n);return jf([i,e.user,r,e.serverSide],t)}var Lg=1.5;function Ng(e){return e.isHeadless||!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=Lg*e.autosaveTimeoutMs?"none":"revision"}var Fg=1e4;function Bg(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const c=h=>a!==void 0&&a.version===h.get().version?o()-a.failuresAtStart:0,l=h=>{const f=c(h);if(f<=0)return!1;const p=n().retryMaxAttempts??5;return!s()||f>p},u=()=>{const{autosaveTimeoutMs:h,retryIntervalMs:f}=n(),p=t();return p!==void 0&&c(p)>0&&f!==void 0&&f>0?f:p?.isNew()?Fg:h},d=h=>h.isNew()&&o()>=3,m=()=>{const h=t();if(!h||h.isDisposed()||l(h))return"none";const{latestRevisionAt:f,snapshotVersion:p,...b}=n(),x=Date.now(),N=Ng({...b,isDirty:h.isDirty(),isNew:h.isNew(),isReady:h.isReady(),latestRevisionAgeMs:f!=null&&f<=x?x-f:void 0,isSnapshotSent:p!=null&&p===h.get().version});return N==="create"&&d(h)?"none":N},_=()=>{const h=t();if(!h||h.isDisposed()||d(h)||l(h)||n().isHeadless)return!1;if(!h.isDirty())return h.isNew();const{snapshotVersion:f}=n();return!(f!=null&&f===h.get().version)};let v,E=0,y=0,k,C,F,T=!1;const R=()=>{k=void 0;const h=t();if(!h||h.isDisposed())return;if(h.get().docId!==v){A();return}const f=m();f!=="none"&&a?.version!==h.get().version&&(a={version:h.get().version,failuresAtStart:o()}),f==="create"?r():f==="revision"?i():_()&&(v=h.get().docId,E=u(),y=o(),k=setTimeout(R,E))},A=()=>{const h=t();if(T||!h)return;const f=a?.version===h.get().version&&y!==o();k!==void 0&&(E!==u()||f)&&(clearTimeout(k),k=void 0),!(k!==void 0||m()==="none"&&!_())&&(v=h.get().docId,E=u(),y=o(),k=setTimeout(R,E))},D=h=>{const f=t();h.source==="user"?a=void 0:a&&f&&(a.version=f.get().version),h.source==="user"&&k!==void 0&&(clearTimeout(k),k=void 0),A()},O=()=>{const h=t();h!==C&&(F?.(),C=h,a=void 0,F=h?.subscribe(D),k!==void 0&&(clearTimeout(k),k=void 0))};return O(),A(),{refresh:()=>{T||(O(),A())},stop:()=>{T=!0,F?.(),F=void 0,C=void 0,k!==void 0&&(clearTimeout(k),k=void 0)}}}var Jl=U("documentSession.autosaveUiFacts"),Ql={isUserBusy:!1,saveContext:{}};function jg(e){return e.getOrCreateInstance(Jl,()=>ce(Ql))}function Ai(e){return e?.getInstance(Jl)?.get()??Ql}function Zl(e){return Ai(e).saveContext.fallbackTitle||"Untitled email."}var Ug=1e4,$g=3e4;function Hg(e,t){const n=m=>{const _=e.getInstance(ge)?.layers?.(),v=_?Mg(_,m):void 0;return typeof v=="number"&&v>=0?v:void 0};let r;const i=m=>{const{error:_,failures:v}=t.saveState();return fl(_)?(r?.failures!==v&&(r={failures:v,saved:m??null}),r.saved===(m??null)):(r=void 0,!1)},o=()=>{const m=t.current(),_=m?.get().serverId??void 0,v=ee(t.sessionKey()),E=t.recoveryFacts(),y=E?.emailId===_?E:void 0,k=t.revisionFacts(),C=y?.latestRevisionAt,F=k?.lastRevisionAt,T=Wl(e).profile;return{isInited:v||m?.get().attributes.is_inited===!0,isEnabled:!!T?.autosaves&&!Eg(e)&&!i(m?.get().savedVersion),isHistoryLoaded:y?.historyLoaded===!0,isUserBusy:Ai(e).isUserBusy,isHeadless:vg(e),autosaveTimeoutMs:Kl(e).autosaveTimeout||Ug,latestRevisionAt:C!==void 0||F!==void 0?Math.max(C??0,F??0):void 0,snapshotVersion:k?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??$g,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},s=()=>{const m=Ai(e).saveContext;return{...m,project:m.project??t.current()?.get().attributes.project,fallbackTitle:Zl(e)}},a=Bg({readDocument:()=>t.current(),readEnvironment:o,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>bh(t.saveState().error),onCreate:()=>{ee(t.sessionKey())||t.save("materialize",{...s(),source:Sg})},onRevision:()=>{t.save("snapshot",{project:s().project})}}),c=t.subscribe(()=>{i(t.current()?.get().savedVersion),a.refresh()}),l=Ao(e).watch(()=>a.refresh()),u=jg(e).watch(()=>a.refresh()),d=Co(e).watch(()=>a.refresh());return()=>{c(),l.dispose(),u.dispose(),d.dispose(),a.stop()}}var Bs=12e3;function ye(e){return e.getOrCreateInstance(jt,()=>{const t=Wh({resolveAdapters:(r,i)=>qg(r,e,i),resolveWritePort:()=>eu(e),resolveHistoryPort:r=>ee(r)?nu(e):tu(e),resolveTerms:()=>Zh(e),canEdit:r=>jc(e,r),notifyBeforeSave:wp(e),confirmPublish:gg(e),awaitCanvasSynced:Rp(e),savedEchoForm:r=>{const i=Ze(e);return i.toEditorForm(i.toOutputForm(r))},queuesOutsideWrites:r=>ee(r)&&(xp()||Ut(e)),timeoutMs:Bs,onAdapterError:(r,i)=>{i instanceof Error&&i.message;const o=Kh(i),s=zh(i);dn(i,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(o),network_failure:String(s)},level:o||s?"warning":"error"})},onTimeout:r=>{}}),n=Hg(e,t);return e.getInstance(Y)?.addDispose(n),t})}function Re(e){return e?.getInstance(jt)}function eu(e){const t=Xh(e);return t?Ir(e)?vm(t,ft(e).email(e),Ut(e)?{knownRevisions:Lt(e),uncertainWrites:wn(e)}:void 0):t:ft(e).email(e)}function Vg(e){return Sl(e)!==void 0||yl(e)}function tu(e){const t=Sl(e);return t?Ir(e)?(ae("port:history:server-backed"),Cl(t,ft(e).history(e),{knownRevisions:Lt(e),uncertainWrites:wn(e),synchronousHistory:Ut(e)})):(ae("port:history:integrator"),t):(ae("port:history:rest (порт не зарегистрирован)"),ft(e).history(e))}function nu(e){const t=wl(e);return t?Ir(e)?(ae("port:block-history:server-backed"),Cl(t,ft(e).blockHistory(e),{pendingKey:mo,knownRevisions:Lt(e),uncertainWrites:wn(e),synchronousHistory:Ut(e)})):(ae("port:block-history:integrator"),t):(ae("port:block-history:rest (порт не зарегистрирован)"),ft(e).blockHistory(e))}function Gg(e){return wl(e)!==void 0||yl(e)}function Ir(e){return Fc(e)}function qg({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>ml(e),required:!0}):n&&s.push(Yh(eu(i),n)),t&&s.push({id:"plugin",load:()=>gl(t)});const a=ee(r);return kp(n)&&(a?Gg(i):Vg(i))&&s.push(um({port:a?nu(i):tu(i),revisionServiceEnabled:Ir(i),pendingKey:Zc(n,a),historyIsSynchronous:Ut(i),emailId:n,wpId:()=>o.readWpId(),readShownContent:()=>o.readShownContent(),onFacts:c=>o.publishRecoveryFacts(c)})),s}function Wg(e){const t=ye(e),n=fe(e).addListener(K.APPLICATION_HAS_AMP,r=>{Ct(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(Y)?.addDispose(()=>n.dispose())}function zg(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Kg(e){const t=e.fetchImpl??((o,s)=>fetch(o,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,i=o=>{try{const s=new URL(o,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:i,async load(o){if(!i(o))return;const s=!r.has(o);r.add(o);try{const a=await t(o,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return zg(c)?c:void 0}catch{return}}}}var ut={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Yg(e){const t={maxBytes:e.maxBytes??ut.maxBytes,maxImageBytes:e.maxImageBytes??ut.maxImageBytes,ttlMs:e.ttlMs??ut.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const a=d=>{const m=r.get(d);m&&(s-=m.bytes,r.delete(d))},c=d=>t.ttlMs<=0||n()-d.storedAt<t.ttlMs,l=()=>{if(s<=t.maxBytes)return;const d=[...r.entries()].sort((m,_)=>m[1].usedAt-_[1].usedAt);for(const[m]of d){if(s<=t.maxBytes)return;a(m)}},u=(d,m)=>{m.size>t.maxImageBytes||(r.set(d,{blob:m,bytes:m.size,storedAt:n(),usedAt:n()}),s+=m.size,l())};return{async get(d){const m=r.get(d);if(m&&c(m))return m.usedAt=n(),o.hits+=1,m.blob;m&&a(d);const _=i.get(d);if(_!==void 0)return _;o.loads+=1;const v=(async()=>{try{const E=await e.load(d);return E?u(d,E):o.failures+=1,E}catch{o.failures+=1;return}finally{i.delete(d)}})();return i.set(d,v),v},forget(d){a(d),i.delete(d)},configure(d){Object.assign(t,{maxBytes:d.maxBytes??t.maxBytes,maxImageBytes:d.maxImageBytes??t.maxImageBytes,ttlMs:d.ttlMs??t.ttlMs});for(const[m,_]of r)_.bytes>t.maxImageBytes&&a(m);l()},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var Xg=["emcdn.ru","scr.emcdn.ru"];function Jg(e){const t=String(e??"").trim();if(!t)return"";try{return new URL(t.includes("//")?t:`https://${t}`).hostname}catch{return t.split("/")[0].split(":")[0]}}function Qg(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const a=Jg(s);a&&o.add(a)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Zg(e){const t=e??{},n=t.isPlugin!==!0?Xg:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...ut};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:Qg(i.sourceHosts,n),maxBytes:i.maxBytes??ut.maxBytes,maxImageBytes:i.maxImageBytes??ut.maxImageBytes,ttlMs:i.ttlMs??ut.ttlMs}}function ev(e){const t=fe(e),n=e.getInstance(ge),r=()=>Zg({...n?.get(),isPlugin:!0});let i=r();const o=Kg({sourceHosts:()=>i.sourceHosts}),s=Yg({load:E=>o.load(E),maxBytes:i.maxBytes,maxImageBytes:i.maxImageBytes,ttlMs:i.ttlMs}),a=()=>{t.send(K.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:i.enabled,sourceHosts:[...i.sourceHosts]})},c=t.onInit(()=>a()),l=n?.watch(()=>{const E=r(),y=JSON.stringify(E)!==JSON.stringify(i);i=E,s.configure(E),E.enabled||s.clear(),y&&t.isInited()&&a()}),u={asked:0,served:0,refused:0},d=[],m=(E,y)=>(u.refused+=1,d.push({url:E,reason:y}),d.length>20&&d.shift(),{refused:!0}),_=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:i,counters:{...u},refusals:[...d],store:s.stats()})}),v=t.addListenerAsync(K.APPLICATION_CANVAS_IMAGE_GET,async E=>{const y=E?.url??"";if(u.asked+=1,!i.enabled||!y)return m(y,"disabled");if(!o.accepts(y))return m(y,"host");E.fresh&&s.forget(y);const k=await s.get(y);return k?(u.served+=1,{blob:k}):m(y,"load-failed")});e.getInstance(Y)?.addDispose(()=>{c.dispose(),l?.dispose(),v.dispose(),s.clear(),delete _.__emmCanvasImages__})}var tv=2e3;function nv(e){const t=fe(e),n=new Map,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;clearTimeout(n.get(s));const a=new MessageChannel;let c=!1,l=!1;const u=m=>{m.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",u),l&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",u),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const d=setTimeout(()=>{n.get(s)===d&&n.delete(s),!(c||!t.hasPort(s,a.port1))&&(dn(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),l=!0,t.holdPort(s))},tv);n.set(s,d)},i=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),o=t.onInit(()=>r());e.getInstance(Y)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var rv=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function iv(e){return rv.test(e)||e.indexOf("//")===0}function Mn(e){return e&&(e.endsWith("/")?e:`${e}/`)}function ov(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function js(e,t){const n=e==null||e===""?"./":String(e);if(iv(n))return Mn(n);const r=t??ov();if(!r)return Mn(n);try{return Mn(new URL(n,r).href)}catch{return Mn(n)}}function sv(){return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.publicPath?js(window.__emailmaker__.publicPath):js("/")}var av=()=>"",cv=()=>"091c986b";function lv(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function ru(e){const t=e?"iframe-eblock":"iframe",n=av();if(n){const o=lv(n,window.location).replace(/\/?$/,"/");return rs(`${o}${t}.html`,ln())}const r=cv(),i=`${sv().replace(/\/?$/,"/")}iframe/`;return rs(`${i}${t}${r?`.${r}`:""}.html`,ln())}var Us="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function Ci(e){return/^file:/i.test(String(e||"").trim())}function uv(e){return Ci(e)?`${Us} allow-same-origin`:Us}var dv="em:module-body-ack";function fv(e,t,n){try{const r=new URL("./",new URL(t,n)).href,i=new URL(e,r).href;return i.startsWith(r)?i:void 0}catch{return}}function Ro(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function pv(e){const t=Ro(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function hv(e,t){const n=Ro(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function mv(e,t){const n=Ro(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const i=new Set([r]),o=[r],s=[];for(;o.length>0;)for(const a of e[o.shift()]??[])i.has(a)||(i.add(a),s.push(a),o.push(a));return s}var gv=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function vv(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&gv.test(t[t.length-2])}async function bv(e,t){const n=vv(e)?{}:{cache:"no-cache"};t?.priority&&(n.priority=t.priority);try{const r=await fetch(e,n);return r.ok?await r.blob():void 0}catch{return}}function _v(e){const t=new Map,n=(r,i)=>{const o=fv(r,e.canvasSrc,e.origin);if(!o)return;const s=t.get(o);if(s!==void 0)return s;const a=e.fetchBody(o,i);return t.set(o,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,i){for(const o of r)n(o,i)},reset(){t.clear()},get size(){return t.size}}}var $e;function yv(e){try{return Ci(new URL(e,window.location.href).href)}catch{return Ci(window.location.href)}}function iu(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.preload?.canvasCrossOrigin===!0}var Ev=()=>Promise.resolve(void 0);function ou(){const e=ru(!1);if(!yv(e)){if(!$e||$e.canvasSrc!==e){const t=iu(e)?bv:Ev;$e={canvasSrc:e,store:_v({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return $e.store}}async function wv(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const i=await r.json();t(hv(i,e))}catch{}}function Oo(e){const t=ou();if(!t||!$e||$e.warmed||!iu($e.canvasSrc))return;$e.warmed=!0;const{canvasSrc:n}=$e,r=pv(n);r&&t.warm([r],e);const i={"js/iframe-eblock.js":["js/elMarkupHelper.DoIAMao4.js"],"js/iframe.js":["js/elMarkupHelper.DoIAMao4.js"],"js/darkreader.CLd5EML2.js":[],"js/elMarkupHelper.DoIAMao4.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.Mun9CrLC.js":[]};i?t.warm(mv(i,n),e):wv(n,o=>t.warm(o,e))}function Sv(e){const t=ou();if(!t)return;Oo();const n=r=>{const i=r.data;if(!i||i.operationId!=="em:module-body"||!i.result)return;const o=r.source;o&&(o.postMessage({operationId:dv,for:i.result},"*"),t.take(i.data?.url??"").then(s=>{o.postMessage({operationId:i.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(Y)?.addDispose(()=>{window.removeEventListener("message",n)})}var Rt=/<script\b(?=[^>]*(?:\bbis_use(?:=|\s)|\bdata-bis-config(?:=|\s)|\bdata-dynamic-id(?:=|\s)|local\.adguard\.org|(?:chrome-extension|moz-extension|safari-extension):\/\/))[^>]*>[\s\S]*?<\/script>/gi,Iv=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Nt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,$s=/display:\s*none\s*!important/gi,Tv="data-darkreader-",Av=/<(script|style)\b[\s\S]*?<\/\1\s*>|<[a-z][^\s<>]*(?:"[^"]*"|'[^']*'|[^<>"'])*?\sdata-darkreader-(?:"[^"]*"|'[^']*'|[^<>"'])*>/gi,Cv=/\sdata-darkreader-[a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?/gi,Rv=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,Ov=/\s*height\s*:\s*100%\s*!important\s*;?/gi,kv=/height\s*:\s*100%\s*!important/i,Pv=[".socialshare,",".advertisment,",".adHolder,",".adsbygoogle-noablate","#ab_adblock","#popmechanic-snippet","filter_ads_by_classname","clever-core-ads","--gn-ov-ad-height","pub_728x90.text-ad.textAd","html-load.com/player","content-loader.com/player",".adblock","#advblock","body { overflow: visible!important; }"];function Dv(e){return $s.lastIndex=0,(e.match($s)||[]).length}function su(e){const t=e.trim(),n=Dv(t);if(n===0)return!1;if(t.includes(".advertisment,")&&t.includes(".adHolder,")&&(t.includes(".socialshare,")||n>=3||t.length>2e3))return!0;const r=Pv.filter(i=>t.includes(i)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function xv(e){Nt.lastIndex=0;for(const t of e.matchAll(Nt))if(su(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Mv(e){let t=!1;return Nt.lastIndex=0,{html:e.replace(Nt,n=>su(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Lv(e){return Rt.lastIndex=0,Rt.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||xv(e)}function Nv(e){return e.toLowerCase().includes(Tv)?e.replace(Av,(t,n)=>n?t:t.replace(Cv,"")):e}function Fv(e){const t=Nv(e);if(!Lv(t))return{html:t,found:!1};let n=!1,r=t;Rt.lastIndex=0,Rt.test(r)&&(Rt.lastIndex=0,r=r.replace(Rt,""),n=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(r)||/\sdata-bis-config\s*=/.test(r))&&(r=r.replace(Iv,""),n=!0);const i=Mv(r);return r=i.html,n=n||i.found,{html:r,found:n}}function Bv(e){return!e||!kv.test(e)?e:(Nt.lastIndex=0,e.replace(Nt,t=>t.replace(Rv,(n,r,i,o)=>`${r}${i.replace(Ov,"")}${o}`)))}function au(e){const t=Fv(e.replaceAll(`\r
|
|
1003
1003
|
`,`
|
|
1004
|
-
`));return{html:Em(t.html),hasBrowserExtensionArtifacts:t.found}}function zt(e){return e?.getContent()??""}function Xc(e,t){e?.mutate({content:Yo(t)},{source:"remote"})}function nr(e){return H(e)}function me(e,t){return e.getOrCreateInstance(t,()=>new Ge)}function te(e,t){return e.getOrCreateInstance(t,()=>new Ge).event}function jn(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var wm=class extends Error{label;timeoutMs;constructor(e){super(`[sandbox:ready] iframe handshake timed out after ${e}ms`),this.name="SandboxReadyTimeoutError",this.label="sandbox:ready",this.timeoutMs=e}};function Sm(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.isInited=="function"&&typeof t.getTarget=="function"&&typeof t.onInit=="function"}function Im(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(re(n),new Promise((r,o)=>{let i=!1,s,a;const c=d=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",l),d())},l=()=>{c(()=>o(Ee(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&c(()=>r())}),e.isInited()&&e.getTarget()){c(()=>r());return}t>0&&(s=setTimeout(()=>{c(()=>o(new wm(t)))},t)),n?.addEventListener("abort",l)}))}var Cm=class extends Error{label;timeoutMs;constructor(e,t){super(`[${e}] timed out after ${t}ms`),this.name="OperationTimeoutError",this.label=e,this.timeoutMs=t}};function Am(e,t,n){return t<=0?e:new Promise((r,o)=>{let i=!1,s;const a=c=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),c())};s=setTimeout(()=>{a(()=>o(new Cm(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>o(c))})})}var Tm=2,Lt=Symbol("sandbox:frame-replaced");function ns(e){return e===Lt}function nt(e,t,n,r,o,i,s){const a=`sandbox:${t}`,c=i?.getSandboxTimeoutMs(t)??Wo[t],l=()=>{let w=Am(e.sendAsync(n,r),c,a);return w=Dn(w,i?.signal),rt(a,w,o)};if(t==="INIT_START"&&Sm(e)){const w=i?.getSandboxReadyTimeoutMs()??2e4,C=e,y=S=>{const T=Im(C,w,i?.signal);return rt("sandbox:INIT_START:ready-wait",T,o).then(()=>{if(!s||S<=0)return l();const B=s.getGeneration();let D;const O=new Promise((x,R)=>{D=s.onChange(()=>{s.getGeneration()!==B&&R(Lt)})}),A=l();return A.catch(()=>{}),Promise.race([A,O]).finally(()=>D?.()).catch(x=>{if(x!==Lt)throw x;return{...o},y(S-1)})})};return y(Tm)}if(!s)return l();const d=s.getGeneration();let h;const b=new Promise((w,C)=>{h=s.onChange(()=>{s.getGeneration()!==d&&C(Lt)})}),v=l();return v.catch(()=>{}),Promise.race([v,b]).finally(()=>h?.()).catch(w=>{throw w===Lt&&{...o},w})}var Jc="self-init:";function Rm(e){return e.startsWith(Jc)}function si(e,t){const n=e.getActiveShowRequest();return Rm(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Om(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let i="",s;const a=w=>{s={target:e.readTarget?.(),docId:w}},c=()=>e.readDocument()?zt(e.readDocument()):i,l=()=>Ke(e.container).editorPolicy,d=()=>e.readEmail(),h=()=>{const w=d();return{...w,id:e.isTemplate()||w.isNew?void 0:w.id,html:c()}};let b=!1;const v={readContent:c,publicEmail:h,sendInitStart:()=>nt(n,"INIT_START",z.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>nt(n,"INITED",z.SANDBOX_INITED,{guid:d().renderGuid},void 0,r(),o()),async sendContent(){const w=d(),{html:C,hasBrowserExtensionArtifacts:y}=Yc(w?.html||"");y&&e.events.browserExtensionDetected(),Xc(e.readDocument(),C),i=C,a(w.renderGuid),await nt(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,jn(c(),w.renderGuid,l(),e.readDocument()?.get().version),{guid:w.renderGuid,emailId:w.id??null},r(),o())},refreshContent:()=>(a(d().renderGuid),nt(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,jn(c(),d().renderGuid,l(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const w=d();if(w.preheader!==void 0)return nt(n,"PREHEADER",z.SANDBOX_PREHEADER_UPDATE,{value:w.preheader,guid:w.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const w=d();if(w.subject!==void 0)return nt(n,"SUBJECT",z.SANDBOX_SUBJECT_UPDATE,{value:w.subject,guid:w.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:w=>e.showFilled?.(w),noteFilled:(w,C)=>e.noteFilled?.(w,C),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(h()),fireInit(w,C){if(!si(t(),w)){t().getActiveShowRequest()?.showId;return}const y=d();y.id,y.renderGuid,t().completeShow(w);const S=e.readDocument();wt(S,{is_inited:!0},{source:"system"});const T=()=>{const D=h();C&&(D.reset=!0);const O=e.events.inited(D);return C||(b&&v.fireEmailChanged(),b=!0),O};if(!S||S.isReady())return T();const{docId:B}=S.get();return S.whenReady().then(()=>e.readDocument()?.get().docId===B?T():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(h())},fireContentChanged(){e.events.contentChanged(c())}};return v}var km=class extends Error{showId;constructor(e,t){super(`[emailmaker] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},Pm=class{_activeRequest=null;_pending=new Map;_listeners=new Set;getActiveShowRequest(){return this._activeRequest}onShowRequested(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}requestShow(e,t,n){return this._rejectPending(Ee("Superseded by newer show()")),n.aborted?Promise.reject(Ee(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const i=setTimeout(()=>{this._settle(e.showId,()=>{o(new km(e.showId,t))})},t);i.unref?.();const s=()=>{this._settle(e.showId,()=>{o(Ee(n.reason))})};n.addEventListener("abort",s,{once:!0});const a=()=>{clearTimeout(i),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:i,dispose:a});for(const c of this._listeners)c(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Dm(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function xm(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Ya(e),n=Xa(e),r=of(e.sandbox);t<n+r}var Qc=class{_controller=new AbortController;_externalSignalDisposable=new pe;_sessionChangeListeners=new Set;_showRegistry=new Pm;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Ya(this._timeouts)}getSandboxTimeoutMs(e){return Ka(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return Xa(this._timeouts)}bumpGeneration(){this._generation+=1}getActiveShowRequest(){return this._showRegistry.getActiveShowRequest()}onShowRequested(e){return this._showRegistry.onShowRequested(e)}requestShow(e){return this._showRegistry.requestShow(e,this.contentReadyTimeoutMs,this._controller.signal)}completeShow(e){this._showRegistry.completeShow(e)}hasPendingShow(e){return this._showRegistry.hasPendingShow(e)}failShow(e,t){this._showRegistry.failShow(e,t)}rejectAllPendingShows(e){this._showRegistry.rejectAll(e)}onSessionReplaced(e){return this._sessionChangeListeners.add(e),()=>{this._sessionChangeListeners.delete(e)}}configure(e){e.timeouts!==void 0&&(this._timeouts=Dm(this._timeouts,e.timeouts),xm(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new pe,this._linkExternalSignal(e)}abort(e){const t=e??Ee("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new pe}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new pe,this._showRegistry.rejectAll(Ee("Init session replaced")),this._controller.signal.aborted||this._controller.abort(Ee("Init session replaced")),this._controller=new AbortController,this._emitSessionReplaced()}_emitSessionReplaced(){for(const e of this._sessionChangeListeners)e()}_linkExternalSignal(e){if(!e)return;if(e.aborted){this._controller.signal.aborted||(this._controller.abort(e.reason??Ee()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??Ee()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},ai=(()=>{const e=new Qc;return e.configure({}),e})();function lt(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function Xe(e){return!e||e==="none"}function Mm(e){const t=e.contain??"",n=e.willChange??"";return!Xe(e.transform)||!Xe(e.perspective)||!Xe(e.filter)||!Xe(e.backdropFilter)||!Xe(e.translate)||!Xe(e.rotate)||!Xe(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function rs(e){const t=/paint|strict|content/.test(e.contain??"");return{x:t||!!e.overflowX&&e.overflowX!=="visible",y:t||!!e.overflowY&&e.overflowY!=="visible"}}function Lm(e){const t=[],n=document.documentElement,r=rs(getComputedStyle(n)),o=r.x||r.y;let i="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(i=s);for(let a=lt(e);a&&a!==n;a=lt(a)){const c=getComputedStyle(a),l=i==="none"||Mm(c)||i==="absolute"&&!!c.position&&c.position!=="static",d=a===document.body&&!o;if(l){i="none";const h=d?{x:!1,y:!1}:rs(c);(h.x||h.y)&&t.push({node:a,...h})}(c.position==="absolute"||c.position==="fixed")&&(i==="none"||c.position==="fixed")&&(i=c.position==="fixed"?"fixed":"absolute")}return t}function Zc(e){const t=e.getBoundingClientRect(),n=e.offsetWidth>0&&t.width>0?t.width/e.offsetWidth:1;return{x:n,y:e.offsetHeight>0&&t.height>0?t.height/e.offsetHeight:n}}function mn(e){return Number.parseFloat(e)||0}function co(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=Zc(e),o=mn(n.borderLeftWidth),i=mn(n.borderTopWidth),s=mn(n.borderRightWidth),a=mn(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-s):0,l=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-i-a):0;return{left:t.left+o*r.x,top:t.top+i*r.y,right:t.right-(s+c)*r.x,bottom:t.bottom-(a+l)*r.y}}function Nm(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(i,s,a)=>{s&&(r.left=Math.max(r.left,i.left),r.right=Math.min(r.right,i.right)),a&&(r.top=Math.max(r.top,i.top),r.bottom=Math.min(r.bottom,i.bottom))};return t.forEach(i=>o(co(i.node),i.x,i.y)),n&&o(co(n),!0,!0),r}var lo={originX:0,originY:0,scaleX:1,scaleY:1};function Un(e,t){return{left:(e.left-t.originX)/t.scaleX,top:(e.top-t.originY)/t.scaleY,width:Math.max(0,e.right-e.left)/t.scaleX,height:Math.max(0,e.bottom-e.top)/t.scaleY}}function el(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,o=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*o,scaleX:r,scaleY:o}}function tl(e,t){return Math.abs(e.left-t.left)<=.5&&Math.abs(e.top-t.top)<=.5&&Math.abs(e.width-(t.right-t.left))<=.5&&Math.abs(e.height-(t.bottom-t.top))<=.5}var Fm=1e3;function Bm(e){const{slot:t,own:n}=e;let r,o=0,i=!1;const s=()=>{if(r=void 0,!i){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(s))}},a=()=>{!i&&r===void 0&&(r=window.requestAnimationFrame(s))},c=()=>{o=performance.now()+Fm,a()},l=[window],d=[document.documentElement];for(let y=t;y;y=lt(y)){const S=y.getRootNode();S instanceof ShadowRoot&&!l.includes(S)&&(l.push(S),d.push(S))}const h=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];l.forEach(y=>h.forEach(([S,T])=>y.addEventListener(S,T,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const b=typeof MutationObserver=="function"?new MutationObserver(y=>{y.some(S=>!n.contains(S.target))&&a()}):void 0;d.forEach(y=>b?.observe(y,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let v;try{if(typeof ResizeObserver=="function"){const y=new ResizeObserver(a);typeof y.observe=="function"&&(v=y)}}catch{v=void 0}let w=[];return{schedule:a,observe:y=>{!v||y.length===w.length&&y.every((S,T)=>S===w[T])||(v.disconnect(),w=y,y.forEach(S=>v?.observe(S)))},dispose(){i=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),l.forEach(y=>h.forEach(([S,T])=>y.removeEventListener(S,T,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),b?.disconnect(),v?.disconnect()}}}var jm="pluginZoom",Um=/^(?:ant|vscode|monaco|docs)-/;function Hm(e){return Um.test(e)}function $m(){const e="em".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var Vm=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function qm(){return Vm}var Gm=new Set;function Wm(e,t,n=Gm){return e.startsWith(`${t}-`)?!1:!Hm(e)&&!n.has(e)}function zm(e,t){return`--${t}-${e}`}function nl(e){const t=$m();return Wm(e,t,qm())?zm(e,t):`--${e}`}function Km(e,t){const n=nl(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function rl(e,t){return Km(e,t)}var ol=300,os=15e3,Ym=5e3,is="em-canvas-busy-style";function Xm(){if(document.getElementById(is))return;const e=document.createElement("style");e.id=is,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var Jm="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z";function Qm(e){const t=rl("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(nl("colorPrimary")).trim()||t}function il(e){Xm();const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg");n.setAttribute("viewBox","0 0 1024 1024"),n.setAttribute("width","48"),n.setAttribute("height","48"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");const r=document.createElementNS(t,"path");r.setAttribute("d",Jm),n.appendChild(r);const o=document.createElement("span");return o.setAttribute("role","img"),o.setAttribute("aria-label","loading"),o.setAttribute("style",`display:inline-flex;color:${Qm(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function Zm(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),i=Math.min(r.right,e.right,n.width),s=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return i<=o||a<=s?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+i)/2-e.left,y:(s+a)/2-e.top}}function eg(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const o={left:n.left,top:n.top,right:n.right,bottom:n.bottom},i=r.getBoundingClientRect();if(i.width>0&&!tl({left:i.left,top:i.top,width:i.width,height:i.height},o)){const s=Un(o,el(i,Un(o,lo),lo));Object.assign(r.style,{left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const s=Zm(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${s.x}px`,top:`${s.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(il(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Cr(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(il(e))},ol);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var tg=8e3;function ng(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function rg(e,t){for(let n=lt(e);n;n=lt(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",i=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>ft(s)>0);if(o&&i)return n;if(n===t)return null}return null}function ft(e){return Number.parseFloat(e)||0}function gn(e,t){return Math.abs(e-t)<=1}function og(e){const t=getComputedStyle(e),n=ft(t.borderTopWidth),r=ft(t.borderRightWidth),o=ft(t.borderBottomWidth),i=ft(t.borderLeftWidth),s=(a,c,l)=>Math.max(0,ft(a)-Math.max(c,l));return{...co(e),radii:[s(t.borderTopLeftRadius,n,i),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,o,r),s(t.borderBottomLeftRadius,o,i)]}}function ig(e,t){const n=gn(t.top,e.top),r=gn(t.bottom,e.bottom),o=gn(t.left,e.left),i=gn(t.right,e.right),s=[n&&o?e.radii[0]:0,n&&i?e.radii[1]:0,r&&i?e.radii[2]:0,r&&o?e.radii[3]:0];return s.every(a=>a===0)?"":s.map(a=>`${a}px`).join(" ")}function sg(e,t,n,r,o,i){const s=n.readyTimeoutMs??tg,a=document.createElement("div");a.dataset.canvasHost=e,r&&(a.dataset.canvasPlace=r),a.style.position="fixed",a.style.overflow="hidden",a.style.visibility="hidden",a.style.setProperty("zoom",rl(jm,"1"));const c=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(c)),l.setAttribute("allow","clipboard-read; clipboard-write"),l.setAttribute("title","Email content"),l.style.width="100%",l.style.border="0",l.style.display="block",l.style.minHeight="600px",l.src=c,a.appendChild(l),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(l);const d=new pe;let h=!1,b,v=!1,w,C,y,S;const T=()=>{clearTimeout(S),S=setTimeout(()=>{v||(v=!0,C?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},B=()=>h?(y=Promise.resolve(),v=!0,y):(v=!1,y=new Promise((p,E)=>{w=p,C=E}),T(),y),D=()=>{if(clearTimeout(S),h=!0,v){y=Promise.resolve();return}v=!0,n.mark?.("loaded"),w?.()};l.addEventListener("load",D),d.addDispose(()=>{clearTimeout(S),l.removeEventListener("load",D)});let O;const A=()=>{O??=n.bindResizer?.(l)},x=()=>{O?.dispose(),O=void 0};let R=null,m=null,f,u=lo,g="",k="",M=0;const _=p=>{const E=JSON.stringify(p);return E===g?!1:(g=E,a.style.visibility=p.visibility,a.style.left=`${p.css.left}px`,a.style.top=`${p.css.top}px`,a.style.width=`${p.css.width}px`,a.style.height=`${p.css.height}px`,a.style.borderRadius=p.radius,l.style.width=p.elementWidth>0?`${p.elementWidth}px`:"100%",l.style.transform=p.shiftX!==0?`translate(${p.shiftX}px, ${p.shiftY}px)`:`translateY(${p.shiftY}px)`,!0)};let I=!1;const F=()=>{if(!R)return g="",a.style.visibility="hidden",l.removeAttribute("id"),!1;n.elementId&&(l.id=n.elementId);const p=R.getBoundingClientRect(),E=Lm(R),P=m?.isConnected?m:null;f?.observe([R,l,...E.map(ce=>ce.node),...P?[P]:[]]);const N=Nm(p,E,P),U=Math.max(0,N.right-N.left),Y=Math.max(0,N.bottom-N.top),q=getComputedStyle(R).visibility==="visible",G=U<=0||Y<=0,ee=G?{left:N.left,top:N.top,right:N.left,bottom:N.top}:N,L=G?null:rg(R,P??E[0]?.node??null),Q=L?ig(og(L),ee):"",Z=ce=>_({visibility:q&&!I?"":"hidden",css:Un(ee,ce),elementWidth:p.width/ce.scaleX,shiftX:(p.left-ee.left)/ce.scaleX,shiftY:(p.top-ee.top)/ce.scaleY,radius:Q});let oe=Z(u);if(!G){const ce=a.getBoundingClientRect();ce.width>0&&!tl({left:ce.left,top:ce.top,width:ce.width,height:ce.height},ee)&&(u=el(ce,Un(ee,u),u),oe=Z(u)||oe)}return oe},j=()=>{if(!R)return!1;let p=F();const E=l.getBoundingClientRect().height;E>0&&E!==M&&(M=E,R.style.height=`${E/Zc(R).y}px`,p=!0);const P=getComputedStyle(R).pointerEvents;return P!==k&&(k=P,a.style.pointerEvents=P),p},K=()=>{f?.dispose(),f=void 0},de=p=>{f=Bm({slot:p,own:a,measure:j,onDetached:K})};let se=[];const X=(p,E)=>{if(m=E,p&&se.length>0){const P=se;se=[],P.forEach(N=>N())}if(p===R){p&&!f&&de(p),j();return}if(K(),R&&R.style.removeProperty("height"),g="",M=0,k="",R=p,!p){F(),x();return}n.onShown?.(l),de(p),j(),A()};d.addDispose(K);const J=p=>{h=!1,b=void 0,i?.(),p&&n.onReload?.(l);let E;v||y===void 0?E=B():(T(),E=y);try{l.contentWindow?.location.reload()}catch{l.src=c}return E};return{element:l,ready(){return y??B()},reload:()=>J(!0),reloadQuietly:()=>J(!1),followReload:()=>{b=void 0,i?.(),n.onReload?.(l)},moveTo(p){if(a.parentNode===p)return y??B();h=!1,b=void 0,i?.();let E;return v||y===void 0?E=B():(T(),E=y),p.appendChild(a),n.onReload?.(l),g="",f?.schedule(),E},get shown(){return R!==null},get slot(){return R},whenShown(){return R!==null?Promise.resolve():new Promise(p=>{se.push(p)})},get filled(){return b},noteFilled(p){b=p},alignTo(p,E){X(p,E??null)},hold(p){I!==p&&(I=p,F())},scrollBy(p,E){let P=p,N=E;for(let U=R?lt(R):null;U;U=lt(U)){if(Math.abs(P)<1&&Math.abs(N)<1)return;const Y=getComputedStyle(U);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&U.scrollHeight>U.clientHeight){const q=U.scrollTop,G=U.scrollLeft;U.scrollBy({left:P,top:N,behavior:"instant"}),P-=U.scrollLeft-G,N-=U.scrollTop-q}}(Math.abs(P)>=1||Math.abs(N)>=1)&&window.scrollBy({left:P,top:N,behavior:"instant"})},resize(){O?.resize()},dispose(){X(null,null),x(),d.dispose(),a.remove()}}}function ag(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(u,g)=>u==="email"?`email:${g??n}`:u,i=new Map;let s,a=[],c=!1,l,d,h=!1,b,v,w="shown",C=0,y,S,T;const B=u=>d!==void 0&&u.filled!==void 0&&u.filled!==d,D=()=>{y=void 0;const u=b;!h||!u||d===void 0||S===d||!B(u)||(S=d,e.onForeignDocument?.({wanted:d,filled:u.filled,role:w,heldMs:Date.now()-C}))},O=()=>{h=!1,b=void 0,v=void 0,clearTimeout(y),y=void 0},A=(u,g)=>{const k=i.get("email"),M=k?.slot??null;return u&&M&&B(u)?(u.alignTo(null),h||(h=!0,C=Date.now(),y=setTimeout(D,Ym)),w=g,b=u,!(s!==void 0||c)&&v!==u&&(v=u,e.onShown?.(u.element)),!l&&!s&&(l=Cr(M)),!1):(h&&(O(),l?.remove(),l=void 0),u?.alignTo(M,k?.clip??null),!0)},x=()=>{h&&!c&&A(t.get(o("email")),"shown")},R=()=>{a.forEach(u=>clearTimeout(u)),a=[],s?.remove(),s=void 0,l?.remove(),l=void 0,(c||h)&&(c=!1,A(t.get(o("email")),"shown"))},m=(u,g,k)=>{const M=o(u,g),_=t.get(M);if(_)return _;const I=e.resolveMount();if(!I)return ng();const F=sg(u,I,e,u==="email"?g??n:void 0,k,u==="email"?()=>x():void 0);return t.set(M,F),F},f={get:u=>m(u),current:u=>m(u),peek:u=>t.get(o(u)),spare:()=>t.get(o("email",r())),ensureSpare:()=>m("email",r(),!0),promote(){const u=t.get(o("email",r()));if(!u)return;const g=t.get(o("email"));n=r(),T=void 0,A(u,"spare"),g?.alignTo(null)},alignSurface(u,g,k){const M=i.get(u);if(i.set(u,{slot:g,clip:k??null}),u==="email"&&c){l?.remove(),l=g?Cr(g):void 0;return}const _=g?m(u):t.get(o(u));if(u!=="email"){_?.alignTo(g,k??null);return}if(!g){T=M?.slot&&_?.shown?{slot:M.slot,handle:_}:void 0,h&&(O(),l?.remove(),l=void 0),_?.alignTo(null);return}const I=T?.slot===g&&T.handle===_;if(T=void 0,M?.slot===g&&_?.shown||I){_?.alignTo(g,k??null);return}A(_,"shown")},want(u){d=u,u!==void 0&&x()},noteFilled(u,g){const k=f.byWindow(u);k&&(k.noteFilled(g),k===t.get(o("email"))&&x())},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const g of t.values())if(g.element.contentWindow===u)return g}},busy(u){if(R(),!u)return;if(!f.visible()){c=!0,l?.remove(),l=void 0;const M=i.get("email");M?.slot&&(l=Cr(M.slot)),a=[setTimeout(R,os)];return}const g=e.resolveMount();if(!g)return;const k=eg(g,()=>f.visible()?.element.parentElement?.getBoundingClientRect()??null);s=k,a=[setTimeout(()=>k.showSpinner(),ol),setTimeout(R,os)]},remount(u){R();const g=o("email");t.forEach((k,M)=>{if(M===g){k.moveTo(u).catch(()=>{});return}k.dispose(),t.delete(M)})},dispose(){d=void 0,c=!1,O(),T=void 0,R(),t.forEach(u=>u.dispose()),t.clear(),i.clear(),n="a",d=void 0,S=void 0}};return f}var cg=H("canvas.resizerBinder"),uo=H("canvas.service"),lg={created:ve.canvasCreated,loaded:ve.canvasLoaded},sl=new WeakMap;function fo(e){return sl.get(e)??0}function dg(e,t){if(e.getInstance(uo))return;const n=ag({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:Jh,elementId:t.elementId,bindResizer:o=>e.getInstance(cg)?.(o),onCreated:o=>$t(e,o,"fresh"),onReload:o=>{sl.set(o,fo(o)+1),$t(e,o,"fresh")},onShown:o=>{const i=n.byWindow(he(e).getTarget());i&&i.element!==o&&ss(i.element)===ss(o)||$t(e,o,"switch")},mark:o=>t.mark?.(lg[o]),onForeignDocument:o=>{({...o},_f("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:o.role},contexts:{canvasIdentity:{...o,path:window.location.pathname}}}))}}),r=he(e).addListener(z.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(uo,n),e.getInstance(W)?.addDispose(()=>{r.dispose(),n.dispose()})}function ss(e){return e.parentElement?.dataset.canvasHost}function $t(e,t,n){const r=he(e),o=t.contentWindow;if(!o)return;const i=r.getTarget()===o;i&&n==="switch"||(n==="fresh"&&(r.forget(o),i&&r.setTarget(void 0)),r.setTarget(o),lf(r))}function ug(e,t){$t(e,t,"promote")}function fg(e,t){$t(e,t,"switch")}function pg(e,t){const n=t.contentWindow;n&&he(e).greet(n)}function al(e,t){const n=t.contentWindow;n&&he(e).forget(n)}function hg(e,t){const n=fe(e)?.byWindow(t)?.element;if(!n)return;const r=fo(n);return()=>fo(n)!==r}function fe(e){return e.getInstance(uo)}function cl({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:i}){if(!r)return;const s={id:o??void 0,renderGuid:n,showId:i?.id,isNew:o==null,showToken:i?.token},a={...e,...s};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function rr(e){return{...cl({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function Tn(e){const t=ge(e),n=t.current();if(!n||!ne(t.sessionKey()))return;const r=rr(n),o=n.isDirty();me(e,$.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function mg(e){const t=ge(e);return!t.current()||!ne(t.sessionKey())?!1:(Tn(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function gg(e){const t=ge(e),n=he(e),r=()=>e.getInstance(Pe)??ai;let o,i,s=!1,a=!1,c,l;const d=k=>rr(k),h=()=>{const k=B(),M=k?.get().docId;if(!k||!M||M!==c||s)return;const _=k.get().version;_!==l&&(l=_,me(e,$.ON_BLOCK_CHANGED_ID).fire(d(k)))};let b;const v=k=>{const M=t.showFacts();!M||M.id===b||!si(k,M.id)||(b=M.id,k.completeShow(M.id))},w=async(k,M,_)=>{const I=_.generation,F=()=>_.generation!==I||_.signal.aborted||t.current()!==k||a,j=we(n);let K;const de=new Promise(X=>{K=xn(n,()=>X("regenerated"))}),se=async(...X)=>await Promise.race([nt(...X).then(()=>"sent"),de])==="sent";s=!0;try{if(!await se(n,"INIT_START",z.SANDBOX_INIT_START,{guid:M},void 0,_)||F())return;const{html:X,hasBrowserExtensionArtifacts:J}=Yc(zt(k));if(J&&me(e,$.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Xc(k,X),!await se(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,jn(zt(k),M,Ke(e).editorPolicy,k.get().version),void 0,_)||F()||!await se(n,"INITED",z.SANDBOX_INITED,{guid:M},void 0,_)||F())return;o=M,i=j,D(),l=k.get().version,c!==M&&(c=M,me(e,$.ON_BLOCK_INIT_ID).fire(d(k))),v(_)}finally{K?.(),s=!1,we(n)!==j&&x()}};let C,y,S;const T=()=>{const k=fe(e)?.peek("block");return k?.reload?(k.reload().catch(()=>{}),!0):!1},B=()=>ne(t.sessionKey())?t.current():void 0,D=()=>{const k=B()?.get().docId,M=!k||S===k||o===k&&i===we(n);fe(e)?.peek("block")?.hold(!M)},O=()=>{if(a||(D(),h(),s))return;const k=B(),M=k?.get().docId;if(!k||!M)return;if(o===M&&i===we(n)){v(r());return}if(!k.isReady())return;const _=r();_.signal.aborted||o!==void 0&&o!==M&&C!==M&&(C=M,T())||w(k,M,_).catch(()=>{if(!(a||t.current()!==k)){if(y!==M){y=M,T();return}S=M,D()}})};let A=!1;const x=()=>{A||a||(A=!0,queueMicrotask(()=>{A=!1,O()}))};let R,m;const f=()=>{const k=B(),M=k?.get().docId;M!==m&&(R?.(),m=M,R=k?.subscribe(x)),D(),x()},u=t.subscribe(f),g=xn(n,()=>{D(),x()});f(),e.getInstance(W)?.addDispose(()=>{a=!0,g(),R?.(),u()})}function vg(e){const t=ge(e);let n="email";const r=()=>{if(!t.current())return;const i=ne(t.sessionKey())?"block":"email",s=fe(e);if(i===n||!s)return;n=i;const a=s.peek(i);if(a){fg(e,a.element);return}s.get(i)},o=t.subscribe(r);e.getInstance(W)?.addDispose(o)}var bg=200;function yg({startVersion:e,limit:t=bg}){let n=[],r=e;const o=i=>{n=n.filter(s=>s.version>i),r=Math.max(r,i)};return{record(i){!i.changes?.length&&!i.contentReplaced||(n.push(i),n.length>t&&o(n[n.length-t-1].version))},rebase(i,s){if(s<r)return null;const a=n.filter(l=>l.version>s);o(s);let c=i;for(const l of a){if(l.contentReplaced||!l.changes)return null;const d=l.changes,h=[];for(const b of c){if(l.fromCanvas&&d.some(w=>b.range.start<=w.oldEnd&&b.range.end>=w.oldPosition))return null;const v=Of(b.range,d,"after");if(!v)return null;h.push({range:v,text:b.text})}c=h}return c}}}function _g(e,t){let n=0;return e.map(({start:r,end:o,text:i})=>{const s=new Oe(r,t.slice(r,o),r+n,i);return n+=i.length-(o-r),s})}function Eg(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return _g(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function wg(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Sg=32;function Ig(e=Sg){const t=new Map;return{find(n,r){const o=t.get(n);return o&&to(o.scope,r)?o.echo:void 0},remember(n,r,o){t.delete(n),t.set(n,{scope:r,echo:o}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>to(r.scope,n)).map(r=>r.echo)}}}function Cg(e,t){const n=Qd(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var ci=H("canvas.sandboxFill");function ll(e){return e.getInstance(ci)?.pipeline.isEventsLocked()===!0}var Ag=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,Tg=/<\/?[a-zA-Z]/g;function as(e){return e.match(Tg)?.length??0}function cs(e){return[...e.matchAll(Ag)].map(t=>[t.index,t.index+t[0].length])}function Ar(e,t,n){let r=0,o=0;for(const[i,s]of n){for(;o<t.length&&t[o][1]<=i;)o++;let a=i;for(let c=o;c<t.length&&t[c][0]<s;c++)r+=as(e.substring(a,Math.max(a,t[c][0]))),a=Math.max(a,t[c][1]);r+=as(e.substring(Math.min(a,s),s))}return r}function Rg(e,t){const n=[...t].sort((c,l)=>c.oldPosition-l.oldPosition||c.oldEnd-l.oldEnd),r=[],o=[],i=[];let s=0,a=0;for(const c of n){const l=e.substring(s,c.oldPosition);r.push(l,c.newText),a+=l.length,o.push([c.oldPosition,c.oldEnd]),i.push([a,a+c.newText.length]),a+=c.newText.length,s=c.oldEnd}return r.push(e.substring(s)),{next:r.join(""),removed:o,inserted:i}}function Og(e,t){if(e.reduce((s,a)=>s+a.oldLength,0)<=200)return null;const n=cs(t),r=Rg(t,e),o=Ar(t,n,r.removed)-Ar(r.next,cs(r.next),r.inserted),i=Ar(t,n,[[0,t.length]]);return o>100&&o>i*.2?{removed:o,total:i}:null}function Je(e){Wt(e,{origin:"canvas-channel"})}var kg=100;function Pg(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===z.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function Dg(e){const t=ge(e),n=he(e);let r;const o=(c,l)=>{const d=c.get().docId;let h=!1,b=null,v=null,w;const C=yg({startVersion:c.get().version});let y=c.getContent();const S=Ig(),T=rc(e),B=T.open(d,()=>c.get().version);let D=!1;const O=E=>({generation:we(n),originId:E});let A=O(null),x=!0;const R=(E,P)=>{!x||t.current()!==c||(Wt(P,{origin:"canvas-channel"}),v?.splice(0,v.length),n.sendAsync(z.SANDBOX_SET_ENTITY,jn(zt(c),d,Ke(e).editorPolicy,c.get().version)).catch(Je))},m=E=>{const P=E[E.length-1],N=[...E].reverse().find(q=>q.answer?.actionId!==void 0)?.answer?.actionId,U=P.answer?.selection,Y=N!==void 0||U?{...N!==void 0?{actionId:N}:{},...U?{selection:U}:{}}:void 0;return{edits:E.map(q=>q.edits),guid:d,rev:P.rev,...Y?{historyAnswer:Y}:{}}},f=()=>{const E=l.activeMove(),P=E&&w?.action===E.kind?w:void 0;if(P&&(w=void 0),!(!P&&!E?.selection))return{...P?{actionId:P.actionId}:{},...E?.selection?{selection:E.selection}:{}}},u=E=>{g({edits:[],rev:c.get().version,answer:{actionId:E.actionId}}).catch(Je)},g=async E=>{if(v){v.push(E);return}v=[E];try{do await n.sendAsync(z.SANDBOX_UPDATE_ENTITY,m(v.splice(0,v.length)));while(v.length)}catch(P){R("app edits failed to reach the canvas",P)}finally{v=null}},k=E=>{E.length&&n.sendAsync(z.SANDBOX_UPDATE_ENTITY,m(E)).catch(Je)},M=(E,P)=>{D=!0,k(v?.splice(0,v.length)??[]);const N={edits:[E],guid:d,rev:c.get().version,...P!==null?{changeId:P}:{}};P!==null&&S.remember(P,A,N),n.sendAsync(z.SANDBOX_UPDATE_ENTITY,N).catch(Je)},_=new Set,I=(E,P,N)=>{M([],N);const{length:U,hash:Y}=vr(JSON.stringify(P.map(ee=>[ee.oldText,ee.newText]))),q=`${U}:${Y}`;if(_.has(q))return;_.add(q);const G=new Error(`canvas service batch removes ${E.removed} of ${E.total} tags`);R("canvas service batch removes a large part of the email",G)},F=({changeId:E,baseRev:P})=>{!D&&(E!==null||P!==null)&&M([],E)},j=E=>{if(E.guid!==d)return;const P=$f(E);D=!1,A=O(P.originId);try{K(E,P)}catch(N){F(P),R("canvas batch failed to apply",N)}finally{F(P),P.changeId!==null&&T.note(P.changeId,A)}},K=(E,P)=>{const{pushUndoStop:N}=E,U=P.changeId!==null?S.find(P.changeId,A):void 0;if(U){D=!0,n.sendAsync(z.SANDBOX_UPDATE_ENTITY,U).catch(Je);return}let{edits:Y,selection:q}=E;if(P.baseRev!==null){const G=C.rebase(Y,P.baseRev);if(!G){Wt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),M([],P.changeId);return}G!==Y&&(q=void 0),Y=G}try{h=!0,b=P.changeId;const G=Eg(Y,c.getContent());if(N===!1){const ee=Og(G,c.getContent());if(ee){I(ee,G,P.changeId);return}l.applyWithoutHistory(G)}else l.recordAt(E.typedAt,()=>c.mutate({changes:G},{source:ll(e)?"system":"user"}),q),E.closesStep&&l.closeGroup()}finally{h=!1,b=null}},de=c.subscribe(({changes:E,version:P})=>{const N=c.getContent(),U=!E?.length&&N!==y;if(y=N,C.record({version:P,changes:E,contentReplaced:U,fromCanvas:h}),!E?.length)return;const Y=wg(E);h?M(Y,b):g({edits:Y,rev:P,answer:f()}).catch(Je)}),se=n.addListener(z.APPLICATION_UPDATE_ENTITY,j),X=n.addListenerAsyncPipe(su,(E,P)=>{w=Pg(E);try{return P?.(E)}finally{const N=w;w=void 0,N&&u(N)}},kg),J=(E,P,{reportId:N,dropsCovered:U})=>{const Y=v?.splice(0,v.length)??[];n.sendAsync(z.SANDBOX_UPDATE_ENTITY,{edits:[Cg(E,P)],guid:d,rev:c.get().version,resync:{textFingerprint:vr(P),reportId:N}}).catch(q=>R("canvas resync edit failed to reach the canvas",q)),U&&k(Y)},p=n.addListener(z.APPLICATION_SYNC_DRIFT,E=>{if(!((E.reason==="echo-timeout"||E.reason==="resync-failed")&&E.guid!==void 0&&E.guid!==d)){if(E.reason==="resync-failed"){R("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(E.reason==="echo-timeout"){const{textFingerprint:P}=E,N=zt(c),U=vr(N);if(P?.length===U.length&&P.hash===U.hash){S.echoes(O(E.originId??null)).forEach(q=>{n.sendAsync(z.SANDBOX_UPDATE_ENTITY,q).catch(Je)}),E.reportId!==void 0&&J(N,N,E);return}const Y=new Error(`canvas echo timeout, ${E.unsent??0} edits unsent`);if(E.canvasText===void 0){R("canvas lost the echo of its batch",Y);return}J(E.canvasText,N,E)}}});return()=>{x=!1,B(),de(),se.dispose(),X.dispose(),p.dispose()}};let i;const s=()=>{const c=t.current(),l=t.history(),d=c?.get().docId;d!==i&&(r?.(),r=void 0,i=d,c&&l&&(r=o(c,l)))},a=t.subscribe(s);s(),e.getInstance(W)?.addDispose(()=>{r?.(),a()})}function xg(e){const t=he(e),n=()=>fe(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(z.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(z.RELOAD,a=>{const c=fe(e)?.byWindow(a);c&&al(e,c.element)}),i=t.addListener(a=>{a.data?.operation===z.SANDBOX_RESIZED&&n()?.resize()}),s=te(e,$.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(W)?.addDispose(()=>{r.dispose(),o.dispose(),i.dispose(),s.dispose()})}function ls(){const e=document.createElement("div");return e.dataset.canvasOffscreen="true",e.style.position="absolute",e.style.left="-10000px",e.style.top="-10000px",e.style.width="1600px",e.style.height="1000px",document.body.appendChild(e),e}function Mg(e){const t=e.getInstance(ye);let n,r;e.getInstance(W)?.addDispose(()=>{r?.remove(),r=void 0}),dg(e,{resolveMount:()=>n,resolveSrc:i=>Gc(i==="block"),elementId:"email_iframe",mark:i=>ie(i)}),t?.watch(i=>{const s=i?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,fe(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(i!==void 0){n=r??=ls(),fe(e)?.alignSurface("email",r,r);return}else return;fe(e)?.get("email")}});let o;e.getInstance(W)?.addDispose(()=>{o?.remove(),o=void 0}),sh(e).watch(i=>{const s=fe(e);if(s){if(i){o??=ls(),s.alignSurface("email",o,o);return}o&&(s.alignSurface("email",null),o.remove(),o=void 0)}})}var li=H("canvas.headerFlow"),ds=["subject","preheader"],us=3e3,Lg=3,Ng={subject:z.SANDBOX_SUBJECT_UPDATE,preheader:z.SANDBOX_PREHEADER_UPDATE};function Fg(e){const t=ge(e),n=he(e),r=O=>O?"remote":ll(e)?"system":"user",o=(O,{guid:A,value:x,forced:R})=>{const m=mt(t);if(!m||typeof x!="string"||A&&A!==m.get().docId)return;const f=t.forcedHeaders();if(f?.[O]!==void 0&&!R&&x!==f[O])return;const u=m.get().attributes[O];if(!R&&v(O,x,u))return;const g=!R&&h.delete(O);R&&(y.delete(O),y.size===0&&t.endForcedHeaders()),c=!0;try{wt(m,{[O]:x},{source:g?"system":r(R)})}finally{c=!1}i[O]=x};let i={},s,a,c=!1,l=Promise.resolve();const d={},h=new Map,b=(O,A)=>{i[O]=A;const x={};h.set(O,x);const R=()=>{h.get(O)===x&&h.delete(O)};w(O,A,{force:!0}).then(R),setTimeout(R,us)},v=(O,A,x)=>{const R=t.showFill();if(!R||typeof x!="string")return!1;const m=d[O]?.showId===R.showId?d[O]:void 0;return A===x?(d[O]=m??{showId:R.showId,codeEdits:R.codeEdits,corrections:0},!1):m&&R.codeEdits>m.codeEdits&&A!==m.stale?!1:((!m||A===m.stale&&m.corrections<Lg)&&(d[O]={showId:R.showId,stale:A,codeEdits:R.codeEdits,corrections:(m?.corrections??0)+1},b(O,x)),!0)},w=(O,A,{force:x=!1,echo:R=!1,undoStep:m=!1})=>(l=n.sendAsync(Ng[O],{value:A,guid:mt(t)?.get().docId,...x?{force:!0}:{},...R?{echo:!0}:{},...m?{undoStep:!0}:{}}).catch(f=>{}),l);let C;const y=new Set;e.inject(li,{whenDelivered:async()=>{await l},reassert:O=>{const A=mt(t),x=ds.filter(R=>typeof O[R]=="string");if(!(!A||x.length===0)){c=!0;try{wt(A,Object.fromEntries(x.map(R=>[R,O[R]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders(Object.fromEntries(x.map(R=>[R,O[R]]))),clearTimeout(C),C=setTimeout(()=>{y.clear(),t.endForcedHeaders()},us),y.clear();for(const R of x)y.add(R);for(const R of x)i[R]=O[R],w(R,O[R],{force:!0,echo:!0})}}});const S=()=>{s?.(),s=void 0;const O=mt(t);if(O!==a&&h.clear(),a=O,!O){i={};return}const A=O.get().attributes;i={subject:A.subject,preheader:A.preheader},s=O.subscribe(({source:x})=>{if(c)return;const R=O.get().attributes,m=t.forcedHeaders();for(const f of ds){const u=R[f];if(u===i[f])continue;i[f]=u,h.delete(f);const g=x==="system"&&m?.[f]!==void 0;w(f,u??"",{force:g,echo:g,undoStep:x==="user"})}})};S();const T=t.subscribe(S),B=n.addListenerAsync(z.APPLICATION_SUBJECT_UPDATE,O=>o("subject",O)),D=n.addListenerAsync(z.APPLICATION_PREHEADER_UPDATE,O=>o("preheader",O));e.getInstance(W)?.addDispose(()=>{B.dispose(),D.dispose(),T(),s?.(),clearTimeout(C)})}function Bg(e){const t=ge(e);let n={document:void 0,seq:0};const r=()=>{const i=t.recoveryFacts(),s=mt(t);if(!i?.applied||!s||String(i.emailId)!==String(s.get().serverId)||(n.document!==s&&(n={document:s,seq:0}),i.applied.seq<=n.seq))return;n={document:s,seq:i.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(li)?.reassert(a)},o=t.subscribe(r);e.getInstance(W)?.addDispose(o)}function jg(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?du:mu}function Ug(e,t){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1}}function Hg(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function fs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function po(e,t){const n={...e};for(const r of Object.keys(t)){const o=t[r],i=e[r];fs(o)&&fs(i)?n[r]=po(i,o):o!==void 0&&(n[r]=o)}return n}function $g(e,t){const n=Bo;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const o=JSON.parse(r);if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0)return po(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?po(n,t):n}var Vg=ue(void 0),ps=Vg,dl=H("CodeMode");function ul(){let e;try{const t=window.localStorage?.getItem(Kn.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function qg(e){try{window.localStorage?.setItem(Kn.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function or(e){return e.getOrCreateInstance(dl,()=>{const t=ue(ul());return t.watch(qg),t})}function fl(e){return e?.getInstance(dl)?.get()??ul()}function ho(e,t){const n=or(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function Gg(e,t){const n=or(e);n.set({...n.get(),direction:t})}var Wg=H("DefaultCommonStyles");function pl(e){return e.getOrCreateInstance(Wg,()=>ue(void 0))}function zg(e,t){pl(e).set(t)}var Kg=H("CanvasViewport"),Yg=H("CanvasPreviewPage");function $e(e,t,n){let r,o;const i=()=>{if(!r||!e.isInited())return;const c=r.value===void 0?"undefined":JSON.stringify(r.value);c!==o&&(o=c,e.send(t,r.value))},s=n.watch(c=>{r={value:c},i()}),a=e.onInit(()=>{o=void 0,i()});return{dispose(){s.dispose(),a.dispose()}}}function vn(e){const t=ue(e());return{source:t,refresh:()=>t.set(e())}}function Xg(e){const t=he(e),n=e.getInstance(be),r=e.getInstance(ye),o=ge(e),i=or(e),s=matchMedia(ou),a=()=>n?.get()??{};let c;const l=vn(()=>jg(ps.get()??a().theme,s.matches)),d=vn(()=>Ug(a(),ne(o.sessionKey()))),h=vn(()=>a().lockEditor),b=vn(()=>$g(o.current()?.get().attributes?.common_styles,c)),v=e.getOrCreateInstance(Kg,()=>ue()),w=e.getOrCreateInstance(Yg,()=>ue()),C=[$e(t,He.theme,l.source),$e(t,He.flags,d.source),$e(t,He.lockEditor,h.source),$e(t,He.commonStyles,b.source),$e(t,He.codeMode,i.select(Hg)),$e(t,He.appName,ue("emailmaker")),$e(t,He.previewPage,w),$e(t,He.viewport,v)],y=()=>{l.refresh(),d.refresh(),h.refresh()},S=n?.watch(y),T=pl(e).watch(m=>{c=m,b.refresh()}),B=r?.watch(m=>{m&&"commonStyles"in m&&(c=m.commonStyles),b.refresh()});let D;const O=()=>{D?.(),D=o.current()?.subscribe(()=>b.refresh()),b.refresh(),d.refresh()};O();const A=o.subscribe(O),x=()=>l.refresh();s.addEventListener("change",x);const R=ps.watch(()=>l.refresh());e.getInstance(W)?.addDispose(()=>{C.forEach(m=>m.dispose()),S?.dispose(),T.dispose(),B?.dispose(),D?.(),A(),s.removeEventListener("change",x),R.dispose()})}var mo;(function(e){function t(o,i,s=(a,c)=>a===c){if(o===i)return!0;if(o.length!==i.length)return!1;for(let a=0;a<o.length;a++)if(!s(o[a],i[a]))return!1;return!0}e.isEqual=t;function n(o,i=s=>s){const s=new Set;return o.filter(a=>{const c=i(a);return s.has(c)?!1:(s.add(c),!0)})}e.unique=n;function r(o=[],i=[],s=(a,c)=>a===c){const a=[],c=[],l=[];for(const d of o){const h=i.find(b=>s(d,b));h?l.push({prev:d,next:h}):c.push(d)}for(const d of i)o.find(h=>s(d,h))||a.push(d);return{added:a,removed:c,exists:l}}e.diff=r})(mo||(mo={}));function Jg(e,t){return e.type===t.type&&e.key===t.key}function Qg(e){const t=he(e),n=()=>e.getServices(pt)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(z.SANDBOX_ADD_EXTENSIONS,r)}),i=qd(pt),s=e.onInject(a=>{if(a!==i)return;const c=n();if(!t.isInited()){r=c;return}const{added:l,removed:d}=mo.diff(r,c,Jg);if(r=c,d.length){if(d.some(h=>h.type==="script")){t.send(z.RELOAD);return}t.send(z.SANDBOX_REMOVE_EXTENSIONS,d.map(h=>h.key))}l.length&&t.send(z.SANDBOX_ADD_EXTENSIONS,l)});e.getInstance(W)?.addDispose(()=>{o.dispose(),s?.dispose()})}var Zg=new Set([...Object.values(z).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(Ho)]);function ev(e){return e.length>0&&!e.startsWith("em:")&&!Zg.has(e)}function tv(e){const t=he(e),n=new Map;let r=!1,o=-1,i=new Set;const s=l=>(l!==o&&(o=l,i=new Set),i),a=t.observeOutgoing((l,d)=>{if(!r||!ev(l))return;const h=we(t);n.set(l,{data:d,generation:h,scripts:new Set(s(h))})}),c=t.addListener(Ho,l=>{if(l.phase!=="ready"||l.status!=="success")return;r=!0;const d=we(t),h=s(d);h.add(l.key);for(const[b,v]of n)v.generation===d||![...v.scripts].every(w=>h.has(w))||(v.generation=d,t.send(xa(b),v.data))});e.getInstance(W)?.addDispose(()=>{a.dispose(),c.dispose()})}var nv=H("prewarm.editorVisible");function rv(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function ov(e={}){const t=e.paint??rv;let n=!1,r=!1,o=!1,i=!1,s=!1;const a=[],c=()=>{s||i||!n||!r||!o||(i=!0,t(()=>{s=!0,ie(ve.editorVisible);for(const l of a.splice(0))l()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){o=!0,c()},whenVisible(l){if(s){l();return}a.push(l)},contentShown:()=>o}}function iv(e){return e.getOrCreateInstance(nv,()=>ov())}var sv=500,av=500,cv=5e3;function lv(e){const t=e.quietMs??sv,n=e.floorMs??av,r=e.ceilingMs??cv;let o,i,s=0;const a=()=>{clearTimeout(o),clearTimeout(i),o=void 0,i=void 0},c=()=>{a(),e.run()},l=()=>{clearTimeout(o);const d=n-(Date.now()-s);o=setTimeout(c,Math.max(t,d))};return{start(){a(),s=Date.now(),i=setTimeout(c,r),l()},notify(){o!==void 0&&l()},cancel:a}}var dv=2;function hs(){return new Error("[sandbox] document reloaded during fill")}function uv(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Tr(e){try{e()}catch{}}function fv(e){let t;return Tr(()=>{t=e()}),{stage:n=>Tr(()=>t?.stage(n)),end:(n,r)=>Tr(()=>t?.end(n,r))}}function pv(e){const t=()=>e.initPipeline();let n=!1,r,o,i,s=0,a,c;const l=()=>{const A=e.readTarget?.(),x=e.readSandboxGeneration?.();return A===void 0||x===void 0?void 0:{target:A,generation:x}},d=()=>{const A=l();return A&&{...A,canvasReplaced:e.trackDocument?.(A.target)}},h=A=>{if(A?.canvasReplaced?.())return!0;const x=l();return A!==void 0&&x?.target===A.target&&x.generation!==A.generation},v=Om({...e,waitScope:()=>({getSandboxTimeoutMs:A=>t().getSandboxTimeoutMs(A),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const A=c;if(!(!A||!e.onSandboxGenerationChange))return{getGeneration:()=>l()?.generation??A.generation,onChange:x=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===A.target||A.canvasReplaced?.())&&x()})??(()=>{})}}});let w;const C=(A,x)=>{if(w===A)return;w=A;const R=s;setTimeout(()=>{s!==R||t().signal.aborted||B(A,x).catch(()=>{})},0)},y=()=>{a?.abort(),a=void 0};let S;const T=()=>{const A=t().signal;A!==S&&(S?.removeEventListener("abort",y),S=A,A.addEventListener("abort",y))};async function B(A,x,R=0){const m=++s;y(),a=new AbortController,c=void 0,T();const f=()=>s!==m,u=v.readTarget(),g=t().generation,k=()=>g===t().generation&&!t().signal.aborted,M=x?"init:reset-":"init:",_=fv(()=>e.observeShow?.(uv(A,x,e.readEmail())));if(!x){const X=v.publicEmail();X?.id,X?.renderGuid,X?.preheader}let I=!1,F=!1,j,K=!1;const de=()=>{if(h(j))throw hs()},se=()=>{if(f())throw Ee("Fill superseded")};try{n=!0,await v.sendInitStart(),se(),j=d(),c=j,R===0&&v.fireWillInit(),await(x||R>0?v.refreshContent():v.sendContent()),I=!0,se(),de();const X=v.contentSent();v.noteFilled(X?.target,X?.docId),_.stage("content"),x||v.publicEmail()?.id;try{await v.sendPreheader()}catch(J){if(ns(J)||f())throw J;`${M}`,String(J)}se();try{await v.sendSubject()}catch(J){if(ns(J)||f())throw J;`${M}`,String(J)}if(se(),de(),v.showFilled(u),await v.sendInited(),se(),de(),F=!0,o===A){const J=e.readSandboxGeneration?.()??i;J!==void 0&&(r=J)}_.stage("reveal"),await v.revealFilled(),de(),_.end("revealed")}catch(X){const J=!f()&&k()&&h(j),p=J?hs():void 0,E=p??X,P=J&&R<dv?O(A,x,R+1):void 0;K=J&&P===void 0;const N=f()?void 0:{showId:A,contentApplied:I,sandboxInitedAcked:F,superseded:!1,...e.describeSurface?.(),error:String(p??X)};N&&(`${M}`,void 0);const U=!f()&&e.recoverFailedFill?.(u)===!0;if(_.end(f()?"superseded":U?"recovered":Lo(E)||!k()?"aborted":"failed",N),!U&&!f()&&si(t(),A)&&t().failShow(A,E),P!==void 0)return P;throw E}finally{D(A,x,M,{superseded:f(),sessionGeneration:g,contentApplied:I,sandboxInitedAcked:F&&!K,retry:!K,commit:k()})}}function D(A,x,R,m){const{superseded:f,contentApplied:u,sandboxInitedAcked:g}=m;if(f){`${R}`;return}g&&m.commit?v.fireInit(A,x||void 0):g?(`${R}`,m.sessionGeneration,t().generation,t().signal.aborted,void 0):u?(`${R}`,void 0):(`${R}`,void 0),n=!1,a=void 0,!g&&o===A&&(o=void 0,r===i&&(r=void 0)),!g&&u&&m.retry&&C(A,x)}function O(A,x,R){return B(A,x,R)}return{channel:v,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:A=>{r=A},lastCorrelation:()=>o,markCorrelation:A=>{o=A},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:A=>{i=A},fill:A=>B(A,!1),refill:A=>B(A,!0),stop:()=>{s+=1,y(),n=!1,S?.removeEventListener("abort",y),S=void 0}}}function hv(e,t,n){if(!e?.renderGuid||!e.showId||e.showId!==t.showId)return!1;if(t.isNew)return e.id==null;const r=t.emailId??t.navId;return r!=null&&String(e.id??"")!==String(r)?!1:hl(e,n)}function hl(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function mv(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:i}=e,s=d=>{const h=n(),b=o();if(!hv(h,d,b)){d.showId,d.navId,d.emailId,h?.id,h?.showId,h?.renderGuid;return}d.showId,h?.id,h?.renderGuid,t.markFilled(i()),t.markCorrelation(d.showId),t.fill(d.showId).catch(()=>{})};return{showRequested:d=>{s(d)},showRequestIdentityChanged:()=>{const d=e.initPipeline().getActiveShowRequest();d&&s(d)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const d=i();if(t.filledGeneration()===d)return;const h=n(),b=o();if(!h?.renderGuid||!hl(h,b))return;const v=`${Jc}${h.renderGuid}`;t.markFilled(d),t.markCorrelation(v);const w=r()?.isReady()===!0;h.id,h.renderGuid,(w?C=>t.refill(C):C=>t.fill(C))(v).catch(()=>{t.lastCorrelation()===v&&t.markFilled(void 0)})},saasChanged:()=>{const d=n();d?.renderGuid,d?.showToken,d?.id,r()}}}var gv=H("canvas.health");function vv(e){return e??""}function bv(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function ms(e){return e.length>0}function yv(e){const t=ge(e),n=he(e),r=()=>ne(t.sessionKey())?void 0:t.current(),o=()=>{const L=r();return cl({attributes:L?.get().attributes??{},readContent:()=>L?.getContent(),docId:L?.get().docId,hasSession:!!L,serverId:L?.get().serverId,show:t.showFacts()})},i=()=>e.getInstance(Pe)??ai;let s={},a=!1;const c=e.getInstance(ye)?.watch(L=>{a=!!L?.element});let l=!1,d=!1,h=!1,b=0;const v=()=>{const L=fe(e);if(!L)return;const Q=++b,Z=L.spare();return Z&&al(e,Z.element),(Z?Z.reloadQuietly():L.ensureSpare()?.ready())?.then(()=>{if(Q!==b)return;l=!0;const oe=L.spare();oe&&pg(e,oe.element),h&&(h=!1,g(),J())})},w=lv({run:()=>{h||v()?.catch(()=>{})}}),C=()=>{iv(e).noteContentShown(),!l&&!h&&w.start()};let y=!1;const S=L=>{const Q=fe(e),Z=Q?.spare()?.element.contentWindow;d&&Q&&Z&&L===Z&&(d=!1,Q.promote(),Q.busy(!1),y=!0)};let T=!1;const O=pv({container:e,messageService:n,initPipeline:i,readDocument:r,readEmail:o,revealFilled:()=>{const L=fe(e);return y&&L&&(y=!1,w.start()),a?L?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:S,noteFilled:(L,Q)=>fe(e)?.noteFilled(L,Q),recoverFailedFill:L=>{const Q=fe(e),Z=Q?.spare()?.element.contentWindow;return!d||!Q||!Z||L!==Z?!1:(d=!1,l=!1,f="reload",Q.busy(!1),Q.peek("email")?.reload(),T=!0,J(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>we(n),onSandboxGenerationChange:L=>xn(n,L),trackDocument:L=>hg(e,L),observeShow:L=>e.getInstance(gv)?.begin(L),describeSurface:()=>({canvasPath:f,promoted:d,spareClean:l,handshake:n.isInited(),generation:we(n)}),events:{willInit:L=>{me(e,$.WILL_EMAIL_INIT_ID).fire(L)},inited:L=>{C(),me(e,$.ON_EMAIL_INIT_ID).fire(L)},contentChanged:L=>{me(e,$.ON_CONTENT_CHANGED_ID).fire(L)},emailChanged:L=>{me(e,$.ON_EMAIL_CHANGED_ID).fire(L)},browserExtensionDetected:()=>{me(e,$.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),A=mv({pipeline:O,initPipeline:i,readEmail:o,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>we(n)});let x="",R="",m="",f="none";const u=()=>{const L=fe(e)?.spare()?.element.contentWindow;L&&n.getTarget()===L||n.sendNow({operation:z.SANDBOX_LOCK_EDIT,data:!0})},g=()=>{const L=fe(e)?.spare();L&&(u(),l=!1,d=!0,ug(e,L.element))},k=(L,Q)=>{const Z=fe(e);if(!Z)return!0;const oe=Z.spare(),ce=oe&&l?"spare":"prepare";if(f=ce,Z.busy(!0),oe&&l)return g(),!0;w.cancel(),u();const Ye=v();if(Ye===void 0)return f="reload",Z.busy(!1),Z.peek("email")?.reload(),!0;h=!0;const Ue=b;return Ye.catch(()=>{!h||Ue!==b||(h=!1,f="reload",Z.busy(!1),Z.peek("email")?.reload())}),!1},M=()=>{if(ne(t.sessionKey()))return;Y(),O.noteSandboxGeneration(we(n));const L=o(),Q=bv(L?.renderGuid,L?.showId,L?.id,s.emailId),Z=vv(L?.renderGuid);if(Z!==R){const Ye=R;R=Z;const Ue=fe(e)?.peek("email")?.filled,kd=Ue!==void 0&&Ue!==Z;ms(Z)&&(ms(Ye)||kd)&&k(Ye||(Ue??""),Z)}if(h)return;(Q!==x||T)&&(T=!1,x=Q,A.showRequestIdentityChanged());const oe=r(),ce=`${Q}|${oe?.get().docId??""}|${we(n)}`;ce!==m&&oe?.isReady()===!0&&(m=ce,A.selfInitChanged()),A.saasChanged(),se()};let _=!1,I="",F="",j=!1,K=!1;const de=L=>{L.source==="user"?K=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(j=!0),J()},se=()=>{const L=o();if(!L?.renderGuid)return;const Q=O.channel.readContent(),Z=JSON.stringify([L.preheader,L.common_styles,L.meta,L.subject,L.utm_parameters?.utm_campaign??"",L.utm_parameters?.utm_content??"",L.utm_parameters?.utm_medium??"",L.utm_parameters?.utm_source??"",L.utm_parameters?.utm_term??""]),oe=_&&Q!==F,ce=_&&Z!==I;_=!0,F=Q,I=Z;const Ye=j&&!K;if(j=!1,K=!1,O.isEventsLocked()||Ye)return;const Ue={...L,id:s.isTemplate||L.isNew?void 0:L.id,html:Q};if(oe){me(e,$.ON_CONTENT_CHANGED_ID).fire(Q),me(e,$.ON_EMAIL_CHANGED_ID).fire(Ue);return}ce&&L.is_inited&&me(e,$.ON_EMAIL_CHANGED_ID).fire(Ue)};let X=!1;const J=()=>{X||(X=!0,queueMicrotask(()=>{X=!1,M()}))};e.inject(ci,{pipeline:O,setRoute:L=>{L.emailId===s.emailId&&!!L.isTemplate==!!s.isTemplate||(s=L,J())}});let p,E;const P=()=>{const L=r()?.get().docId;L!==E&&(p?.(),E=L,p=r()?.subscribe(de)),J()};let N,U;const Y=()=>{const L=e.getInstance(Pe);!L||L===N||(U?.(),N=L,U=L.onShowRequested(Q=>A.showRequested(Q)))},q=n.addListener(L=>{L.data?.operation===z.SANDBOX_RESIZED&&w.notify()}),G=t.subscribe(P),ee=xn(n,J);P(),e.getInstance(W)?.addDispose(()=>{c?.dispose(),U?.(),ee(),G(),p?.(),q.dispose(),w.cancel(),O.stop()})}function _v(){return Su!=="emailmaker"}var Ev={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},ml={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},gs=ml,wv=["pro"],go={};function Sv(e){go=e}var gl=e=>wv.includes(e)?gs:go[e]??go.editor??gs,vo={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},Iv={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Cv={...vo,config:{...vo.config,imageCenterFileManagerView:!1}};Sv({pro:ml,editor:Iv,simple:_v()?vo:Cv,blocks:Ev});function Av(e,t,n=e.getInstance(be)){n?.setMode(t),n?.get()?.codeEnabled===!1&&fl(e).isCodeMode&&ho(e,!1)}function Tv(e){e.getInstance(au)||e.inject(Be,void 0)}function ir(e){return String(e.standaloneKey||"").trim()||void 0}function Rv(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function di(e){return Rv(e)?!!ir(e):!1}function on(e){return!!ir(e)&&!di(e)}var Ov=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function vs(e){return e==="server"?"serverSide":e}function kv({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=ue();let i={kind:"pending"},s;const a=new Promise(b=>{s=b}),c=n===void 0?void 0:setTimeout(()=>{d({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function l(){i.kind!=="pending"&&o.set(Ir(r,e))}function d(b){if(i.kind!=="pending")return;clearTimeout(c),i=b;const v=Ir(r,e);o.set(v),s(v)}function h(b,v){r[vs(b)]=v,b==="server"&&i.kind==="pending"?d({kind:"applied"}):l()}return{watch:b=>o.watch(b),select:b=>o.select(b),get:()=>o.get(),ready:()=>a,state:()=>i,layers:()=>({...r}),bootstrap(){const b=Ir(r,e);return Object.fromEntries(Ov.map(v=>[v,b[v]]))},merge(b,v){h(v,{...r[vs(v)],...b})},replace(b,v){h(v,b)},setMode(b){r.user={...r.user,mode:b},l()},setAdvancedConfigs(b){r.advancedConfigs=b,l()},serverAbsent(b){d({kind:"absent",reason:b})},applyServerResponse(b){i.kind==="pending"&&h("server",{...r.serverSide,...b})},dispose(){clearTimeout(c)}}}var Pv=5e3;function Dv(){return{...gl("pro")?.config,mergeTags:void 0}}function xv(e,t){e.getInstance(ye)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},o=t.layers().user.mode;t.replace(r.mode===void 0&&o!==void 0?{...r,mode:o}:r,"user")})}function Mv(e,t){let n;ni(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const i={};r?.theme&&(i.theme=r.theme),r?.locale&&(i.locale=r.locale),t.replace(i,"profile")})}function Lv(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Nv(e,t){let n,r=!1,o;const i=a=>{o??=er(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&Av(e,a,t)},s=ni(e).watch(({profile:a})=>{const c=a?.email_builder_config,l=Lv(c);if(l===void 0||c===n)return;const d=n===void 0;n=c,!(d&&r)&&i(l)});e.getInstance(W)?.addDisposable(s),t.ready().then(a=>{if(!a.configSwither)return;const c=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,i(c)})}var bs="замкнутый контур: app_init не выполняется";function Fv(e,t){if(e.getInstance(Be)){t.serverAbsent(bs);return}const n=e.getInstance(ye)?.watch(r=>{on(r)&&t.serverAbsent(bs)});n&&e.getInstance(W)?.addDisposable(n)}async function Bv(e,t){if(e.getInstance(Go)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(We);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function jv(e){e.injectFactory(be,(t,n)=>{if(n)return n;const r=kv({base:Dv(),env:{modeDefaults:o=>gl(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Pv});return xv(e,r),Mv(e,r),Nv(e,r),Fv(e,r),Bv(e,r),e.getInstance(W)?.addDisposable(r),r},!0)}var bt=class extends pe{_event;_listener;_disposeEvent;constructor(e){super(),this._event=e}setListener(e){this._listener!==e&&(this._listener=e,this._disposeEvent&&this._disposeEvent(),e?this._disposeEvent=this._event(e):this._disposeEvent=void 0)}dispose(){this._disposeEvent&&this._disposeEvent(),super.dispose()}};function V(e,t,n){const r=Ud(e);return(o,i,s)=>{const a=r(async c=>{const l=t?t(c):c;s&&o.bind(s);const d=await o(l);return n?n(d):d},i,s);return()=>a.dispose()}}var Uv=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Qr;this.handleDestroy=V(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new bt(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},ui=H("DestroyableService");function Hv(e){e.injectFactory(ui,(t,n)=>{if(n)return n;const r=e.getInstance(W);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Uv({lifetime:r,options:e.getInstance(ye),getInstance:()=>e.getInstance(en),release:()=>Iu(e.getInstance(Na)??e)})},!0)}function $v(e){const t=e.getInstance(ui);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var Vv=1e3;function vl(e,t,n=Vv,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const s of o)if(!vl(e[s],t[s],n,r+1))return!1;return!0}return!1}function Vt(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const o=t[r],i=e[r];vl(o,i)||(n[r]=o)}return n}var qv=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function Gv(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function Wv({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??nn();let i;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,c)=>{i=setTimeout(()=>{const l=new Xn(o);n.value.id,Qf(l,Gv(s,r)),c(l)},o)})])}catch(s){throw mc(s),s}finally{i!==void 0&&clearTimeout(i)}}function zv(e){const{emails:t}=e,n=async(r,o)=>{const i=qv(o),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...i}:i,c=s?Vt(s,i):i,l=d=>{const h=String(d.id??r??Ce()),b=d.id===void 0?{...d,id:h}:d;return t.cache.addOrUpdate(h,()=>b)};return await l(await Wv(e,{prev:s,patch:c,value:a,source:o.source??""},l))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const o=await n(void 0,r);return o?.renderGuid?o:{...o,renderGuid:Ce()}},async updateEmail(r,o){return await n(r,o)}}}var Rr=20;function Kv(e){const t=Yv(e);return e.saveTimeoutMs?Xv(t,e.saveTimeoutMs):t}function Yv({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:i}){const s=async(a,c)=>(t.clear(),await t.get(a,{page:c}),(await e.cache.values()??[]).filter(l=>String(l?.parent)===String(a)));return{async readRevisions(a,c=1){const l=await s(a,c);return{revisions:l.slice(Rr*(c-1),Rr*c),page:c,hasMore:l.length>Rr*c}},async readAutosave(a){const c=await r?.(a)??NaN,l=Number.isFinite(c)?c:void 0,d=await n?.(a);if(!d?.asked)return sp(await s(a,1),l);if(!d.revision)return Gi([],l);const h={...d.revision,parent:a,isAutosave:!0};return Gi([h],l,await s(a,1))},async saveAutosave(a,c){const l=await o?.(a),d=i?.();return await e.create({...fp(c),...l!==void 0?{author:l}:{},...d!==void 0?{project:d}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Xv(e,t,n){return{...e,async saveAutosave(r,o){const i=t();if(i===void 0)return e.saveAutosave(r,o);let s;try{return await Promise.race([e.saveAutosave(r,o),new Promise((a,c)=>{s=setTimeout(()=>c(new ec(i,n)),i)})])}catch(a){throw mc(a),a}finally{s!==void 0&&clearTimeout(s)}}}}var Jv=class extends Md{async execute([e],t){for(const n of t){const r=await n(e);r&&(r.id===void 0&&(r.id=e.value.id),e.value=r)}return e.value}},Qv=class extends Ge{};var ys=class extends pe{_items=new Map;_onChangeEmitter=new Wd;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const o=await t(n);return Fe(n,o)||this._onChangeEmitter.fire(),o}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([o,i])=>o)),r=(await this.entries()).filter(([o,i])=>!n.has(o));for(const[o,i]of e)t.push(this.addOrUpdate(o,()=>i)),n.add(o);for(const[o]of r)t.push(this.remove(o));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function Zv(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:i=20}={}){const s=e.length;let a=e.length;if(t!==void 0){const c=Object.keys(t);e=e.filter(l=>{for(const d of c){const h=l[d],b=t[d];return d==="id"||typeof h!="string"?h===b:typeof b=="string"&&h.startsWith(b)}return!0}),a=e.length}return r&&(e=e.sort((c,l)=>(c[r]>l[r]?1:l[r]>c[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(i*(o-1),i*o)),{data:e,filteredTotal:a,total:s,totalPages:Math.ceil(a/i)}}function eb(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const o=t.get(r.id)||{};t.set(r.id,{...o,...r})}return[...t].map(([n,r])=>r)}function tb(e,t){return _s(e)&&_s(t)?String(e)===String(t):e===t}function _s(e){return typeof e=="string"||typeof e=="number"}var nb=class extends pe{_cache=new ys;_readEmitter=new Ge;_saveEmitter=this.addDisposable(new Jv);_removeEmitter=this.addDisposable(new Qv);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}async confirmedMissing(e){if(!this.hasReadHandler())return!1;const{results:t,errors:n}=await this._readEmitter.fireSettled(e);return!n.length&&!t.some(Boolean)}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new pe);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new ys),o=n.addDisposable(new Ge);t=this._foreignCache[e]={get:async(i,s={})=>{await r.getOrCreate(i,async()=>{try{const c=eb(await o.fire(i))||[];for(const l of c)l[e]=i,await this._cache.add(l.id,l);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const l=c[e];return l==null||tb(l,i)});return Zv(a,s)},first(i,s={}){return t.get(i,{...s,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:o.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=Ce()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async o=>{const i=o?{...o,...t}:t;if(!r)return t=o?Vt(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:i,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function sn(e){const t=H(e);return n=>n.getOrCreateInstance(t,()=>new nb)}function bl(e){const t=e.getInstance(W);if(!t)throw new Error("Failed");return t}function Es(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function bn(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function rb(e,t,n){return e&&!Es(t)&&Es(e)?{...n,meta:e.meta}:n}var ob=H("CurrentProject"),ib={};function an(e){return e?.getInstance(ob)?.get()??ib}function fi(e){const t=an(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var yl=sn("plugin.dataSource.emails"),_l=sn("plugin.dataSource.emailRevisions"),El=nr("plugin.readEmailAutosave"),ws=H("emailDocuments.provided");function sb(e){const t=yl(e),n=_l(e),r=n.byForeignKey("parent");if(e.getInstance(ws))return{emails:t,emailRevisions:n};e.inject(ws,!0);const o=()=>nn(e.getInstance(Pe)?.contentReadyTimeoutMs),i=zv({emails:t,saveTimeoutMs:o}),s=new Map,a=(c,l)=>d=>{const h=d?.id??l;return(typeof h=="string"||typeof h=="number")&&s.set(String(h),c),d};return Fp(e,{...i,createEmail:c=>i.createEmail(c).then(a(Date.now())),updateEmail:(c,l)=>i.updateEmail(c,l).then(a(Date.now(),c))}),Hp(e,Kv({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const l=await me(e,El).fire(c);return l.length===0?{asked:!1}:{asked:!0,revision:l[0]??null}},savedAt:async c=>{const l=op((await t.cache.getIfPresent(c))?.modified),d=s.get(String(c))??NaN;return Number.isFinite(d)&&!(l>=d)?d:l},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:o,integratorProject:()=>an(e).requested})),bl(e).addDisposable(t.onSave(({prev:c,patch:l,value:d})=>rb(c,l,d),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function Ss(e,t){return!e?.data||!t||e.id!==t.locale?!1:t.contentHash?e.hash===t.contentHash:t.updatedAt>0&&t.updatedAt<=e.time}function ab(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var cb="po",yn=null;function lb(){const e=typeof window.__emailmaker__<"u"?window.__emailmaker__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([cb],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function db(){return yn===null&&(yn=lb().catch(e=>{throw yn=null,e})),yn}async function wl(e){if(typeof e=="object")return pi(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?ub(t):fb(t)}function pi(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function ub(e){try{return pi(JSON.parse(e))}catch{return}}var Is=!1;async function fb(e){try{return pi((await db()).parsePoCatalog(e))}catch{Is||(Is=!0);return}}var pb="em_locale",hb="em_ant_locale",mb="locale",gb="ant_locale";function hi(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Sl(e,t){const n=hi(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function vb(){return hi("em_locale")??Sl(mb,"em_locale")}function Cs(e){try{localStorage.setItem(pb,JSON.stringify(e))}catch{}}function bb(){return hi("em_ant_locale")??Sl(gb,"em_ant_locale")}function yb(e,t){try{localStorage.setItem(hb,JSON.stringify({id:e,data:t}))}catch{}}var _b=8e3;function Eb(e,t){const n=e,r=t,o=Object.keys(n).filter(i=>i!=="");return o.length!==Object.keys(r).filter(i=>i!=="").length?!1:o.every(i=>JSON.stringify(n[i])===JSON.stringify(r[i]))}function wb(e){const t=vb(),n=bb();let r={ready:!1},o;const i=ue(r);let s=0;const a=y=>{r={...r,...y},i.set(r)},c=()=>{r.ready||a({ready:!0})},l=setTimeout(c,e.unlockAfterMs??_b),d=y=>y!==s;let h;async function b(y,S){if(n?.id===y&&n.data&&a({antd:n.data}),!h)return;const T=await h(y).catch(()=>{});!T||d(S)||(a({antd:T}),yb(y,T))}async function v(y,S){const T=await e.askHost(y).catch(()=>null);if(d(S))return!0;if(T==null)return!1;const B=await wl(T);return d(S)||(B&&a({catalog:B}),c()),!0}async function w(y,S){const T=await e.readList();if(d(S))return;if("error"in T){a({failure:{kind:"GET_LOCALES_ERROR",error:T.error}}),c();return}const B=T.data.find(O=>O.locale===y);if(!B){ab("em_locale")&&a({catalog:void 0}),c();return}if(Ss(t,B)&&(!o||o.catalog===t?.data)){c();return}if(o?.entry&&r.catalog===o.catalog&&Ss(o.entry,B)){Cs(o.entry),c();return}const D=await e.readCatalog(y);if(!d(S)){if("error"in D){a({failure:{kind:"GET_LOCALE_ERROR",error:D.error}}),c();return}D.data&&(o?.id===y&&r.catalog===o.catalog&&Eb(o.catalog,D.data)||a({catalog:D.data}),Cs({id:y,time:B.updatedAt||Math.floor(Date.now()/1e3),hash:B.contentHash,data:D.data})),c()}}async function C(y,S){if(!await v(y,S)){if(!d(S)&&(o?.id===y&&r.catalog===o.catalog||y==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await w(y,S)}}return{set(y){if(!y||y===r.id)return;const S=s+=1;a({id:y,failure:void 0});const T=o?.id===y&&r.catalog===o.catalog;(o&&!T&&r.catalog===o.catalog||y==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===y&&t.data&&(a({catalog:t.data}),c()),b(y,S),C(y,S)},prime(y,S,T){r.id&&r.id!==y||r.catalog||!S||(o=t?.id===y&&t.data&&(!T||t.time>=T.time)?{id:y,catalog:t.data}:{id:y,catalog:S,entry:T?{id:y,time:T.time,hash:T.hash,data:S}:void 0},a({catalog:o.catalog}))},useAntdLoader(y){h=y,r.id&&b(r.id,s)},state:i,snapshot:()=>r,dispose:()=>clearTimeout(l)}}var Sb=class{http;constructor(e){this.http=e}jsonList=({locale:e},t={})=>this.http.request({path:`/translations/${e}.json`,method:"GET",format:"json",...t});getTranslations=({locale:e},t={})=>this.http.request({path:`/translations/${e}.po`,method:"GET",...t});localesList=(e={})=>this.http.request({path:"/translations/locales",method:"GET",format:"json",...e})},As=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),Ib=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:o,format:i,baseUrl:s,cancelToken:a,...c})=>{const l=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},d=this.mergeRequestParams(c,l),h=o&&this.toQueryString(o),b=this.contentFormatters[r||"application/json"],v=i||d.format;return this.customFetch(`${s||this.baseUrl||""}${n}${h?`?${h}`:""}`,{...d,headers:{...d.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):d.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async w=>{const C=w;C.data=null,C.error=null;const y=v?w.clone():w,S=v?await y[v]().then(T=>(C.ok?C.data=T:C.error=T,C)).catch(T=>(C.error=T,C)):C;return a&&this.abortControllers.delete(a),S})}},Cb=H("rest.v2.transport"),Ts=Symbol("rest.v2.secureRequest");function Ab(e){return e.getOrCreateInstance(Cb,()=>{const t=e.getInstance(Ld)?.execute||fetch;return new Ib({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[Ts]:!0}),customFetch:(n,r={})=>{const{[Ts]:o,...i}=r;return t(n,{...i,[eu]:o!==!0})}})})}function Il(e,t){const n=Ab(e);return Object.assign({},...t.map(r=>new r(n)))}function Rs(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function sr(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Rs(n.details,"wp_code")??n.code,message:Rs(n.details,"wp_message")??n.message,details:n.details}}:t&&typeof t=="object"?{status:e.status,data:t}:{status:e.status,data:{message:e.statusText||"request failed"}}}function Cl(e){return!e.ok||!!e.error}function Al(){return ic(Kn.em_translations_v2)??!0}function Tb(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Rb(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Ob(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],o=r[0];return typeof o=="string"&&o!==""&&t.push({locale:o,updatedAt:Tb(r[1])}),t},[]):[]}function kb(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Rb(n.updated_at),contentHash:n.content_hash}),t),[])}function Tl(e){return Il(e,[Sb])}function Hn(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function bo(e){return!e.ok||e.error!=null}function yo(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Or(e){return{data:await wl(e)??null}}async function Pb(e){if(Al())try{const n=await Tl(e).localesList();return Cl(n)?{error:sr(n)}:{data:kb(n.data)}}catch(n){return Hn(n)}const t=Pa(e,[Ua]);try{const n=await t.get_translations2({file:"react_app"});return bo(n)?yo(n):{data:Ob(n.data)}}catch(n){return Hn(n)}}async function Db(e,t){if(Al())try{const r=await Tl(e).jsonList({locale:t});return Cl(r)?{error:sr(r)}:Or(r.data)}catch(r){return Hn(r)}const n=Pa(e,[Ua]);try{const r=await n.get_translations3({id:t,file:"react_app"});return bo(r)?yo(r):Or(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return bo(r)?yo(r):Or(r.data)}catch(r){return Hn(r)}}}var _n=new WeakMap;function xb(e){const t=_n.get(e);if(t!==void 0)return t;const n=Pb(e).then(r=>("error"in r&&_n.delete(e),r),r=>{throw _n.delete(e),r});return _n.set(e,n),n}var Ct=H("locale.service");function Mb(e){if(e.getInstance(Ct))return;const t=wb({readList:()=>xb(e),readCatalog:n=>Db(e,n),askHost:async n=>(await me(e,$.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(Be)});e.inject(Ct,t),e.getInstance(W)?.addDispose(()=>t.dispose())}function Lb(e){const t=e.getInstance(be);if(!t)return;const n=e.getInstance(Ct);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"ru_RU"));e.getInstance(W)?.addDisposable(r)}var Nb="user_id",Fb="project_id",Os=H("rest.identityHeadersProvided");function Bb(e){if(e.getInstance(Os))return;e.inject(Os,!0);let t;e.getInstance(ye)?.watch(n=>{t=n}),e.addService(zn,{execute(n,r){if(r?.public)return;const o=t?.user?.id??Mc(e).profile?.id;o!=null&&o!==""&&n.headers.set(Nb,String(o));const i=t?.project;i!=null&&i!==""&&n.headers.set(Fb,String(i))}})}function jb(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function Ub(e){return e.id??jb(e.catalog)}function Hb(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function $b(e){return Hb(e||"en_US")}var Vb="Accept-Language",ks=H("rest.localeHeaderProvided");function qb(e){e.getInstance(ks)||(e.inject(ks,!0),e.addService(zn,{execute(t){const n=e.getInstance(Ct)?.snapshot();t.headers.set(Vb,$b(n&&Ub(n)))}}))}function Gb(e){if(!e)return!1;try{return e.getInstance(Be)!==void 0}catch{return!1}}var Wb="Invalid standaloneKey.",KI=H("StandaloneMockGuard");function zb(){const e=new Error(Wb);return e.name="InvalidStandaloneKeyError",e}function Kb(e){e.addService(zn,{execute:()=>{if(Gb(e))throw zb()}})}function Yb(e){Kd(e),Kb(e)}function Xb(e){const t=new Qc;e.inject(Pe,t);const n=e.getInstance(ye)?.watch(o=>{if(!o)return;const i=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...i!==void 0?{signal:i}:{}})}),r=e.getInstance(W);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var Rl=sn("plugin.dataSource.blocks"),Jb=sn("plugin.dataSource.blockRevisions"),Qb=sn("plugin.dataSource.comments"),Zb=nr(),ey=nr(),Ol=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
1004
|
+
`));return{html:Bv(t.html),hasBrowserExtensionArtifacts:t.found}}function fn(e){return e?.getContent()??""}function cu(e,t){e?.mutate({content:vo(t)},{source:"remote"})}function Tr(e){return U(e)}function _e(e,t){return e.getOrCreateInstance(t,()=>new Je)}function ne(e,t){return e.getOrCreateInstance(t,()=>new Je).event}function ar(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var jv=class extends Error{label;timeoutMs;constructor(e){super(`[sandbox:ready] iframe handshake timed out after ${e}ms`),this.name="SandboxReadyTimeoutError",this.label="sandbox:ready",this.timeoutMs=e}};function Uv(e){if(!e||typeof e!="object")return!1;const t=e;return typeof t.isInited=="function"&&typeof t.getTarget=="function"&&typeof t.onInit=="function"}function $v(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(se(n),new Promise((r,i)=>{let o=!1,s,a;const c=u=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",l),u())},l=()=>{c(()=>i(Ie(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&c(()=>r())}),e.isInited()&&e.getTarget()){c(()=>r());return}t>0&&(s=setTimeout(()=>{c(()=>i(new jv(t)))},t)),n?.addEventListener("abort",l)}))}var lu=class extends Error{label;timeoutMs;constructor(e,t){super(`[${e}] timed out after ${t}ms`),this.name="OperationTimeoutError",this.label=e,this.timeoutMs=t}};function uu(e,t,n){return t<=0?e:new Promise((r,i)=>{let o=!1,s;const a=c=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),c())};s=setTimeout(()=>{a(()=>i(new lu(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>i(c))})})}var Hv=2,Yt=Symbol("sandbox:frame-replaced");function Hs(e){return e===Yt}function at(e,t,n,r,i,o,s){const a=`sandbox:${t}`,c=o?.getSandboxTimeoutMs(t)??ho[t],l=()=>{let v=uu(e.sendAsync(n,r),c,a);return v=Qn(v,o?.signal),ct(a,v,i)};if(t==="INIT_START"&&Uv(e)){const v=o?.getSandboxReadyTimeoutMs()??2e4,E=e,y=k=>{const C=$v(E,v,o?.signal);return ct("sandbox:INIT_START:ready-wait",C,i).then(()=>{if(!s||k<=0)return l();const F=s.getGeneration();let T;const R=new Promise((D,O)=>{T=s.onChange(()=>{s.getGeneration()!==F&&O(Yt)})}),A=l();return A.catch(()=>{}),Promise.race([A,R]).finally(()=>T?.()).catch(D=>{if(D!==Yt)throw D;return{...i},y(k-1)})})};return y(Hv)}if(!s)return l();const u=s.getGeneration();let d;const m=new Promise((v,E)=>{d=s.onChange(()=>{s.getGeneration()!==u&&E(Yt)})}),_=l();return _.catch(()=>{}),Promise.race([_,m]).finally(()=>d?.()).catch(v=>{throw v===Yt&&{...i},v})}var du="self-init:";function Vv(e){return e.startsWith(du)}function ko(e,t){const n=e.getActiveShowRequest();return Vv(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Gv(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),i=()=>e.frameWatch?.();let o="",s;const a=v=>{s={target:e.readTarget?.(),docId:v}},c=()=>e.readDocument()?fn(e.readDocument()):o,l=()=>Ze(e.container).editorPolicy,u=()=>e.readEmail(),d=()=>{const v=u();return{...v,id:e.isTemplate()||v.isNew?void 0:v.id,html:c()}};let m=!1;const _={readContent:c,publicEmail:d,sendInitStart:()=>at(n,"INIT_START",K.SANDBOX_INIT_START,{guid:u().renderGuid},void 0,r()),sendInited:()=>at(n,"INITED",K.SANDBOX_INITED,{guid:u().renderGuid},void 0,r(),i()),async sendContent(){const v=u(),{html:E,hasBrowserExtensionArtifacts:y}=au(v?.html||"");y&&e.events.browserExtensionDetected(),cu(e.readDocument(),E),o=E,a(v.renderGuid),await at(n,"SET_ENTITY",K.SANDBOX_SET_ENTITY,ar(c(),v.renderGuid,l(),e.readDocument()?.get().version),{guid:v.renderGuid,emailId:v.id??null},r(),i())},refreshContent:()=>(a(u().renderGuid),at(n,"SET_ENTITY",K.SANDBOX_SET_ENTITY,ar(c(),u().renderGuid,l(),e.readDocument()?.get().version),void 0,r(),i())),sendPreheader:async()=>{const v=u();if(v.preheader!==void 0)return at(n,"PREHEADER",K.SANDBOX_PREHEADER_UPDATE,{value:v.preheader,guid:v.renderGuid,force:!0},void 0,r(),i())},sendSubject:async()=>{const v=u();if(v.subject!==void 0)return at(n,"SUBJECT",K.SANDBOX_SUBJECT_UPDATE,{value:v.subject,guid:v.renderGuid,force:!0},void 0,r(),i())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:v=>e.showFilled?.(v),noteFilled:(v,E)=>e.noteFilled?.(v,E),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(d()),fireInit(v,E){if(!ko(t(),v)){t().getActiveShowRequest()?.showId;return}const y=u();y.id,y.renderGuid,t().completeShow(v);const k=e.readDocument();Mt(k,{is_inited:!0},{source:"system"});const C=()=>{const T=d();E&&(T.reset=!0);const R=e.events.inited(T);return E||(m&&_.fireEmailChanged(),m=!0),R};if(!k||k.isReady())return C();const{docId:F}=k.get();return k.whenReady().then(()=>e.readDocument()?.get().docId===F?C():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(d())},fireContentChanged(){e.events.contentChanged(c())}};return _}var qv=class extends Error{showId;constructor(e,t){super(`[emailmaker] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},Wv=class{_activeRequest=null;_pending=new Map;_listeners=new Set;getActiveShowRequest(){return this._activeRequest}onShowRequested(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}requestShow(e,t,n){return this._rejectPending(Ie("Superseded by newer show()")),n.aborted?Promise.reject(Ie(n.reason)):(this._activeRequest=e,new Promise((r,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new qv(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(Ie(n.reason))})};n.addEventListener("abort",s,{once:!0});const a=()=>{clearTimeout(o),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:i,timeoutId:o,dispose:a});for(const c of this._listeners)c(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function zv(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Kv(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Gc(e),n=qc(e),r=_p(e.sandbox);t<n+r}var fu=class{_controller=new AbortController;_externalSignalDisposable=new ve;_sessionChangeListeners=new Set;_showRegistry=new Wv;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Gc(this._timeouts)}getSandboxTimeoutMs(e){return Vc(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return qc(this._timeouts)}bumpGeneration(){this._generation+=1}getActiveShowRequest(){return this._showRegistry.getActiveShowRequest()}onShowRequested(e){return this._showRegistry.onShowRequested(e)}requestShow(e){return this._showRegistry.requestShow(e,this.contentReadyTimeoutMs,this._controller.signal)}completeShow(e){this._showRegistry.completeShow(e)}hasPendingShow(e){return this._showRegistry.hasPendingShow(e)}failShow(e,t){this._showRegistry.failShow(e,t)}rejectAllPendingShows(e){this._showRegistry.rejectAll(e)}onSessionReplaced(e){return this._sessionChangeListeners.add(e),()=>{this._sessionChangeListeners.delete(e)}}configure(e){e.timeouts!==void 0&&(this._timeouts=zv(this._timeouts,e.timeouts),Kv(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ve,this._linkExternalSignal(e)}abort(e){const t=e??Ie("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ve}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ve,this._showRegistry.rejectAll(Ie("Init session replaced")),this._controller.signal.aborted||this._controller.abort(Ie("Init session replaced")),this._controller=new AbortController,this._emitSessionReplaced()}_emitSessionReplaced(){for(const e of this._sessionChangeListeners)e()}_linkExternalSignal(e){if(!e)return;if(e.aborted){this._controller.signal.aborted||(this._controller.abort(e.reason??Ie()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??Ie()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Po=(()=>{const e=new fu;return e.configure({}),e})();function gt(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function nt(e){return!e||e==="none"}function Yv(e){const t=e.contain??"",n=e.willChange??"";return!nt(e.transform)||!nt(e.perspective)||!nt(e.filter)||!nt(e.backdropFilter)||!nt(e.translate)||!nt(e.rotate)||!nt(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Vs(e){const t=/paint|strict|content/.test(e.contain??"");return{x:t||!!e.overflowX&&e.overflowX!=="visible",y:t||!!e.overflowY&&e.overflowY!=="visible"}}function Xv(e){const t=[],n=document.documentElement,r=Vs(getComputedStyle(n)),i=r.x||r.y;let o="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(o=s);for(let a=gt(e);a&&a!==n;a=gt(a)){const c=getComputedStyle(a),l=o==="none"||Yv(c)||o==="absolute"&&!!c.position&&c.position!=="static",u=a===document.body&&!i;if(l){o="none";const d=u?{x:!1,y:!1}:Vs(c);(d.x||d.y)&&t.push({node:a,...d})}(c.position==="absolute"||c.position==="fixed")&&(o==="none"||c.position==="fixed")&&(o=c.position==="fixed"?"fixed":"absolute")}return t}function pu(e){const t=e.getBoundingClientRect(),n=e.offsetWidth>0&&t.width>0?t.width/e.offsetWidth:1;return{x:n,y:e.offsetHeight>0&&t.height>0?t.height/e.offsetHeight:n}}function Ln(e){return Number.parseFloat(e)||0}function Ri(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=pu(e),i=Ln(n.borderLeftWidth),o=Ln(n.borderTopWidth),s=Ln(n.borderRightWidth),a=Ln(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-i-s):0,l=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-o-a):0;return{left:t.left+i*r.x,top:t.top+o*r.y,right:t.right-(s+c)*r.x,bottom:t.bottom-(a+l)*r.y}}function Jv(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},i=(o,s,a)=>{s&&(r.left=Math.max(r.left,o.left),r.right=Math.min(r.right,o.right)),a&&(r.top=Math.max(r.top,o.top),r.bottom=Math.min(r.bottom,o.bottom))};return t.forEach(o=>i(Ri(o.node),o.x,o.y)),n&&i(Ri(n),!0,!0),r}var Oi={originX:0,originY:0,scaleX:1,scaleY:1};function cr(e,t){return{left:(e.left-t.originX)/t.scaleX,top:(e.top-t.originY)/t.scaleY,width:Math.max(0,e.right-e.left)/t.scaleX,height:Math.max(0,e.bottom-e.top)/t.scaleY}}function hu(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,i=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*i,scaleX:r,scaleY:i}}function mu(e,t){return Math.abs(e.left-t.left)<=.5&&Math.abs(e.top-t.top)<=.5&&Math.abs(e.width-(t.right-t.left))<=.5&&Math.abs(e.height-(t.bottom-t.top))<=.5}var Qv=1e3;function Zv(e){const{slot:t,own:n}=e;let r,i=0,o=!1;const s=()=>{if(r=void 0,!o){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<i)&&(r=window.requestAnimationFrame(s))}},a=()=>{!o&&r===void 0&&(r=window.requestAnimationFrame(s))},c=()=>{i=performance.now()+Qv,a()},l=[window],u=[document.documentElement];for(let y=t;y;y=gt(y)){const k=y.getRootNode();k instanceof ShadowRoot&&!l.includes(k)&&(l.push(k),u.push(k))}const d=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];l.forEach(y=>d.forEach(([k,C])=>y.addEventListener(k,C,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const m=typeof MutationObserver=="function"?new MutationObserver(y=>{y.some(k=>!n.contains(k.target))&&a()}):void 0;u.forEach(y=>m?.observe(y,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let _;try{if(typeof ResizeObserver=="function"){const y=new ResizeObserver(a);typeof y.observe=="function"&&(_=y)}}catch{_=void 0}let v=[];return{schedule:a,observe:y=>{!_||y.length===v.length&&y.every((k,C)=>k===v[C])||(_.disconnect(),v=y,y.forEach(k=>_?.observe(k)))},dispose(){o=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),l.forEach(y=>d.forEach(([k,C])=>y.removeEventListener(k,C,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),m?.disconnect(),_?.disconnect()}}}var eb="pluginZoom",tb=/^(?:ant|vscode|monaco|docs)-/;function nb(e){return tb.test(e)}function rb(){const e="em".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var ib=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function ob(){return ib}var sb=new Set;function ab(e,t,n=sb){return e.startsWith(`${t}-`)?!1:!nb(e)&&!n.has(e)}function cb(e,t){return`--${t}-${e}`}function gu(e){const t=rb();return ab(e,t,ob())?cb(e,t):`--${e}`}function lb(e,t){const n=gu(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function vu(e,t){return lb(e,t)}var bu=300,Gs=15e3,ub=5e3,qs="em-canvas-busy-style";function db(){if(document.getElementById(qs))return;const e=document.createElement("style");e.id=qs,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var fb="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z";function pb(e){const t=vu("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(gu("colorPrimary")).trim()||t}function _u(e){db();const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg");n.setAttribute("viewBox","0 0 1024 1024"),n.setAttribute("width","48"),n.setAttribute("height","48"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");const r=document.createElementNS(t,"path");r.setAttribute("d",fb),n.appendChild(r);const i=document.createElement("span");return i.setAttribute("role","img"),i.setAttribute("aria-label","loading"),i.setAttribute("style",`display:inline-flex;color:${pb(e)};animation:em-canvas-busy-spin 1s linear infinite`),i.appendChild(n),i}function hb(e,t,n){const r=t??e,i=Math.max(r.left,e.left,0),o=Math.min(r.right,e.right,n.width),s=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return o<=i||a<=s?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(i+o)/2-e.left,y:(s+a)/2-e.top}}function mb(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const i={left:n.left,top:n.top,right:n.right,bottom:n.bottom},o=r.getBoundingClientRect();if(o.width>0&&!mu({left:o.left,top:o.top,width:o.width,height:o.height},i)){const s=cr(i,hu(o,cr(i,Oi),Oi));Object.assign(r.style,{left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const s=hb(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${s.x}px`,top:`${s.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(_u(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function qr(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(_u(e))},bu);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var gb=8e3;function vb(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function bb(e,t){for(let n=gt(e);n;n=gt(n)){const r=getComputedStyle(n),i=r.overflowX!=="visible"||r.overflowY!=="visible",o=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>It(s)>0);if(i&&o)return n;if(n===t)return null}return null}function It(e){return Number.parseFloat(e)||0}function Nn(e,t){return Math.abs(e-t)<=1}function _b(e){const t=getComputedStyle(e),n=It(t.borderTopWidth),r=It(t.borderRightWidth),i=It(t.borderBottomWidth),o=It(t.borderLeftWidth),s=(a,c,l)=>Math.max(0,It(a)-Math.max(c,l));return{...Ri(e),radii:[s(t.borderTopLeftRadius,n,o),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,i,r),s(t.borderBottomLeftRadius,i,o)]}}function yb(e,t){const n=Nn(t.top,e.top),r=Nn(t.bottom,e.bottom),i=Nn(t.left,e.left),o=Nn(t.right,e.right),s=[n&&i?e.radii[0]:0,n&&o?e.radii[1]:0,r&&o?e.radii[2]:0,r&&i?e.radii[3]:0];return s.every(a=>a===0)?"":s.map(a=>`${a}px`).join(" ")}function Eb(e,t,n,r,i,o){const s=n.readyTimeoutMs??gb,a=document.createElement("div");a.dataset.canvasHost=e,r&&(a.dataset.canvasPlace=r),a.style.position="fixed",a.style.overflow="hidden",a.style.visibility="hidden",a.style.setProperty("zoom",vu(eb,"1"));const c=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(c)),l.setAttribute("allow","clipboard-read; clipboard-write"),l.setAttribute("title","Email content"),l.style.width="100%",l.style.border="0",l.style.display="block",l.style.minHeight="600px",l.src=c,a.appendChild(l),t.appendChild(a),n.mark?.("created"),i||n.onCreated?.(l);const u=new ve;let d=!1,m,_=!1,v,E,y,k;const C=()=>{clearTimeout(k),k=setTimeout(()=>{_||(_=!0,E?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},F=()=>d?(y=Promise.resolve(),_=!0,y):(_=!1,y=new Promise(($,g)=>{v=$,E=g}),C(),y),T=()=>{if(clearTimeout(k),d=!0,_){y=Promise.resolve();return}_=!0,n.mark?.("loaded"),v?.()};l.addEventListener("load",T),u.addDispose(()=>{clearTimeout(k),l.removeEventListener("load",T)});let R;const A=()=>{R??=n.bindResizer?.(l)},D=()=>{R?.dispose(),R=void 0};let O=null,h=null,f,p=Oi,b="",x="",N=0;const S=$=>{const g=JSON.stringify($);return g===b?!1:(b=g,a.style.visibility=$.visibility,a.style.left=`${$.css.left}px`,a.style.top=`${$.css.top}px`,a.style.width=`${$.css.width}px`,a.style.height=`${$.css.height}px`,a.style.borderRadius=$.radius,l.style.width=$.elementWidth>0?`${$.elementWidth}px`:"100%",l.style.transform=$.shiftX!==0?`translate(${$.shiftX}px, ${$.shiftY}px)`:`translateY(${$.shiftY}px)`,!0)};let w=!1;const M=()=>{if(!O)return b="",a.style.visibility="hidden",l.removeAttribute("id"),!1;n.elementId&&(l.id=n.elementId);const $=O.getBoundingClientRect(),g=Xv(O),I=h?.isConnected?h:null;f?.observe([O,l,...g.map(te=>te.node),...I?[I]:[]]);const P=Jv($,g,I),j=Math.max(0,P.right-P.left),q=Math.max(0,P.bottom-P.top),Q=getComputedStyle(O).visibility==="visible",G=j<=0||q<=0,z=G?{left:P.left,top:P.top,right:P.left,bottom:P.top}:P,L=G?null:bb(O,I??g[0]?.node??null),J=L?yb(_b(L),z):"",Z=te=>S({visibility:Q&&!w?"":"hidden",css:cr(z,te),elementWidth:$.width/te.scaleX,shiftX:($.left-z.left)/te.scaleX,shiftY:($.top-z.top)/te.scaleY,radius:J});let be=Z(p);if(!G){const te=a.getBoundingClientRect();te.width>0&&!mu({left:te.left,top:te.top,width:te.width,height:te.height},z)&&(p=hu(te,cr(z,p),p),be=Z(p)||be)}return be},B=()=>{if(!O)return!1;let $=M();const g=l.getBoundingClientRect().height;g>0&&g!==N&&(N=g,O.style.height=`${g/pu(O).y}px`,$=!0);const I=getComputedStyle(O).pointerEvents;return I!==x&&(x=I,a.style.pointerEvents=I),$},W=()=>{f?.dispose(),f=void 0},ie=$=>{f=Zv({slot:$,own:a,measure:B,onDetached:W})};let re=[];const oe=($,g)=>{if(h=g,$&&re.length>0){const I=re;re=[],I.forEach(P=>P())}if($===O){$&&!f&&ie($),B();return}if(W(),O&&O.style.removeProperty("height"),b="",N=0,x="",O=$,!$){M(),D();return}n.onShown?.(l),ie($),B(),A()};u.addDispose(W);const X=$=>{d=!1,m=void 0,o?.(),$&&n.onReload?.(l);let g;_||y===void 0?g=F():(C(),g=y);try{l.contentWindow?.location.reload()}catch{l.src=c}return g};return{element:l,ready(){return y??F()},reload:()=>X(!0),reloadQuietly:()=>X(!1),followReload:()=>{m=void 0,o?.(),n.onReload?.(l)},moveTo($){if(a.parentNode===$)return y??F();d=!1,m=void 0,o?.();let g;return _||y===void 0?g=F():(C(),g=y),$.appendChild(a),n.onReload?.(l),b="",f?.schedule(),g},get shown(){return O!==null},get slot(){return O},whenShown(){return O!==null?Promise.resolve():new Promise($=>{re.push($)})},get filled(){return m},noteFilled($){m=$},alignTo($,g){oe($,g??null)},hold($){w!==$&&(w=$,M())},scrollBy($,g){let I=$,P=g;for(let j=O?gt(O):null;j;j=gt(j)){if(Math.abs(I)<1&&Math.abs(P)<1)return;const q=getComputedStyle(j);if((q.overflowY==="auto"||q.overflowY==="scroll")&&j.scrollHeight>j.clientHeight){const Q=j.scrollTop,G=j.scrollLeft;j.scrollBy({left:I,top:P,behavior:"instant"}),I-=j.scrollLeft-G,P-=j.scrollTop-Q}}(Math.abs(I)>=1||Math.abs(P)>=1)&&window.scrollBy({left:I,top:P,behavior:"instant"})},resize(){R?.resize()},dispose(){oe(null,null),D(),u.dispose(),a.remove()}}}function wb(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(p,b)=>p==="email"?`email:${b??n}`:p,o=new Map;let s,a=[],c=!1,l,u,d=!1,m,_,v="shown",E=0,y,k,C;const F=p=>u!==void 0&&p.filled!==void 0&&p.filled!==u,T=()=>{y=void 0;const p=m;!d||!p||u===void 0||k===u||!F(p)||(k=u,e.onForeignDocument?.({wanted:u,filled:p.filled,role:v,heldMs:Date.now()-E}))},R=()=>{d=!1,m=void 0,_=void 0,clearTimeout(y),y=void 0},A=(p,b)=>{const x=o.get("email"),N=x?.slot??null;return p&&N&&F(p)?(p.alignTo(null),d||(d=!0,E=Date.now(),y=setTimeout(T,ub)),v=b,m=p,!(s!==void 0||c)&&_!==p&&(_=p,e.onShown?.(p.element)),!l&&!s&&(l=qr(N)),!1):(d&&(R(),l?.remove(),l=void 0),p?.alignTo(N,x?.clip??null),!0)},D=()=>{d&&!c&&A(t.get(i("email")),"shown")},O=()=>{a.forEach(p=>clearTimeout(p)),a=[],s?.remove(),s=void 0,l?.remove(),l=void 0,(c||d)&&(c=!1,A(t.get(i("email")),"shown"))},h=(p,b,x)=>{const N=i(p,b),S=t.get(N);if(S)return S;const w=e.resolveMount();if(!w)return vb();const M=Eb(p,w,e,p==="email"?b??n:void 0,x,p==="email"?()=>D():void 0);return t.set(N,M),M},f={get:p=>h(p),current:p=>h(p),peek:p=>t.get(i(p)),spare:()=>t.get(i("email",r())),ensureSpare:()=>h("email",r(),!0),promote(){const p=t.get(i("email",r()));if(!p)return;const b=t.get(i("email"));n=r(),C=void 0,A(p,"spare"),b?.alignTo(null)},alignSurface(p,b,x){const N=o.get(p);if(o.set(p,{slot:b,clip:x??null}),p==="email"&&c){l?.remove(),l=b?qr(b):void 0;return}const S=b?h(p):t.get(i(p));if(p!=="email"){S?.alignTo(b,x??null);return}if(!b){C=N?.slot&&S?.shown?{slot:N.slot,handle:S}:void 0,d&&(R(),l?.remove(),l=void 0),S?.alignTo(null);return}const w=C?.slot===b&&C.handle===S;if(C=void 0,N?.slot===b&&S?.shown||w){S?.alignTo(b,x??null);return}A(S,"shown")},want(p){u=p,p!==void 0&&D()},noteFilled(p,b){const x=f.byWindow(p);x&&(x.noteFilled(b),x===t.get(i("email"))&&D())},visible(){for(const p of t.values())if(p.shown)return p},byWindow(p){if(p){for(const b of t.values())if(b.element.contentWindow===p)return b}},busy(p){if(O(),!p)return;if(!f.visible()){c=!0,l?.remove(),l=void 0;const N=o.get("email");N?.slot&&(l=qr(N.slot)),a=[setTimeout(O,Gs)];return}const b=e.resolveMount();if(!b)return;const x=mb(b,()=>f.visible()?.element.parentElement?.getBoundingClientRect()??null);s=x,a=[setTimeout(()=>x.showSpinner(),bu),setTimeout(O,Gs)]},remount(p){O();const b=i("email");t.forEach((x,N)=>{if(N===b){x.moveTo(p).catch(()=>{});return}x.dispose(),t.delete(N)})},dispose(){u=void 0,c=!1,R(),C=void 0,O(),t.forEach(p=>p.dispose()),t.clear(),o.clear(),n="a",u=void 0,k=void 0}};return f}var Sb=U("canvas.resizerBinder"),ki=U("canvas.service"),Ib={created:Ee.canvasCreated,loaded:Ee.canvasLoaded},yu=new WeakMap;function Pi(e){return yu.get(e)??0}function Tb(e,t){if(e.getInstance(ki))return;const n=wb({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:uv,elementId:t.elementId,bindResizer:i=>e.getInstance(Sb)?.(i),onCreated:i=>on(e,i,"fresh"),onReload:i=>{yu.set(i,Pi(i)+1),on(e,i,"fresh")},onShown:i=>{const o=n.byWindow(fe(e).getTarget());o&&o.element!==i&&Ws(o.element)===Ws(i)||on(e,i,"switch")},mark:i=>t.mark?.(Ib[i]),onForeignDocument:i=>{({...i},Mp("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:i.role},contexts:{canvasIdentity:{...i,path:window.location.pathname}}}))}}),r=fe(e).addListener(K.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(ki,n),e.getInstance(Y)?.addDispose(()=>{r.dispose(),n.dispose()})}function Ws(e){return e.parentElement?.dataset.canvasHost}function on(e,t,n){const r=fe(e),i=t.contentWindow;if(!i)return;const o=r.getTarget()===i;o&&n==="switch"||(n==="fresh"&&(r.forget(i),o&&r.setTarget(void 0)),r.setTarget(i),Sp(r))}function Ab(e,t){on(e,t,"promote")}function Cb(e,t){on(e,t,"switch")}function Rb(e,t){const n=t.contentWindow;n&&fe(e).greet(n)}function Eu(e,t){const n=t.contentWindow;n&&fe(e).forget(n)}function Ob(e,t){const n=me(e)?.byWindow(t)?.element;if(!n)return;const r=Pi(n);return()=>Pi(n)!==r}function me(e){return e.getInstance(ki)}function wu({attributes:e,readContent:t,docId:n,hasSession:r,serverId:i,show:o}){if(!r)return;const s={id:i??void 0,renderGuid:n,showId:o?.id,isNew:i==null,showToken:o?.token},a={...e,...s};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function Ar(e){return{...wu({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function zn(e){const t=ye(e),n=t.current();if(!n||!ee(t.sessionKey()))return;const r=Ar(n),i=n.isDirty();_e(e,H.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:i})}function kb(e){const t=ye(e);return!t.current()||!ee(t.sessionKey())?!1:(zn(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function Pb(e){const t=ye(e),n=fe(e),r=()=>e.getInstance(Fe)??Po;let i,o,s=!1,a=!1,c,l;const u=x=>Ar(x),d=()=>{const x=F(),N=x?.get().docId;if(!x||!N||N!==c||s)return;const S=x.get().version;S!==l&&(l=S,_e(e,H.ON_BLOCK_CHANGED_ID).fire(u(x)))};let m;const _=x=>{const N=t.showFacts();!N||N.id===m||!ko(x,N.id)||(m=N.id,x.completeShow(N.id))},v=async(x,N,S)=>{const w=S.generation,M=()=>S.generation!==w||S.signal.aborted||t.current()!==x||a,B=Te(n);let W;const ie=new Promise(oe=>{W=un(n,()=>oe("regenerated"))}),re=async(...oe)=>await Promise.race([at(...oe).then(()=>"sent"),ie])==="sent";s=!0;try{if(!await re(n,"INIT_START",K.SANDBOX_INIT_START,{guid:N},void 0,S)||M())return;const{html:oe,hasBrowserExtensionArtifacts:X}=au(fn(x));if(X&&_e(e,H.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),cu(x,oe),!await re(n,"SET_ENTITY",K.SANDBOX_SET_ENTITY,ar(fn(x),N,Ze(e).editorPolicy,x.get().version),void 0,S)||M()||!await re(n,"INITED",K.SANDBOX_INITED,{guid:N},void 0,S)||M())return;i=N,o=B,T(),l=x.get().version,c!==N&&(c=N,_e(e,H.ON_BLOCK_INIT_ID).fire(u(x))),_(S)}finally{W?.(),s=!1,(Te(n)!==B||t.current()!==x)&&D()}};let E,y,k;const C=()=>{const x=me(e)?.peek("block");return x?.reload?(x.reload().catch(()=>{}),!0):!1},F=()=>ee(t.sessionKey())?t.current():void 0,T=()=>{const x=F()?.get().docId,N=!x||k===x||i===x&&o===Te(n);me(e)?.peek("block")?.hold(!N)},R=()=>{if(a||(T(),d(),s))return;const x=F(),N=x?.get().docId;if(!x||!N)return;if(i===N&&o===Te(n)){_(r());return}if(!x.isReady())return;const S=r();S.signal.aborted||i!==void 0&&i!==N&&E!==N&&(E=N,C())||v(x,N,S).catch(()=>{if(!(a||t.current()!==x)){if(y!==N){y=N,C();return}k=N,T()}})};let A=!1;const D=()=>{A||a||(A=!0,queueMicrotask(()=>{A=!1,R()}))};let O,h;const f=()=>{const x=F(),N=x?.get().docId;N!==h&&(O?.(),h=N,O=x?.subscribe(D)),T(),D()},p=t.subscribe(f),b=un(n,()=>{T(),D()});f(),e.getInstance(Y)?.addDispose(()=>{a=!0,b(),O?.(),p()})}function Db(e){const t=ye(e);let n="email";const r=()=>{if(!t.current())return;const o=ee(t.sessionKey())?"block":"email",s=me(e);if(o===n||!s)return;n=o;const a=s.peek(o);if(a){Cb(e,a.element);return}s.get(o)},i=t.subscribe(r);e.getInstance(Y)?.addDispose(i)}var xb=200;function Mb({startVersion:e,limit:t=xb}){let n=[],r=e;const i=o=>{n=n.filter(s=>s.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&i(n[n.length-t-1].version))},rebase(o,s){if(s<r)return null;const a=n.filter(l=>l.version>s);i(s);let c=o;for(const l of a){if(l.contentReplaced||!l.changes)return null;const u=l.changes,d=[];for(const m of c){if(l.fromCanvas&&u.some(v=>m.range.start<=v.oldEnd&&m.range.end>=v.oldPosition))return null;const _=il(m.range,u,"after");if(!_)return null;d.push({range:_,text:m.text})}c=d}return c}}}function Lb(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new Me(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function Nb(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Lb(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Fb(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Bb=32;function jb(e=Bb){const t=new Map;return{find(n,r){const i=t.get(n);return i&&_i(i.scope,r)?i.echo:void 0},remember(n,r,i){t.delete(n),t.set(n,{scope:r,echo:i}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>_i(r.scope,n)).map(r=>r.echo)}}}function Ub(e,t){const n=Nf(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var Do=U("canvas.sandboxFill");function Su(e){return e.getInstance(Do)?.pipeline.isEventsLocked()===!0}var $b=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,Hb=/<\/?[a-zA-Z]/g;function zs(e){return e.match(Hb)?.length??0}function Ks(e){return[...e.matchAll($b)].map(t=>[t.index,t.index+t[0].length])}function Wr(e,t,n){let r=0,i=0;for(const[o,s]of n){for(;i<t.length&&t[i][1]<=o;)i++;let a=o;for(let c=i;c<t.length&&t[c][0]<s;c++)r+=zs(e.substring(a,Math.max(a,t[c][0]))),a=Math.max(a,t[c][1]);r+=zs(e.substring(Math.min(a,s),s))}return r}function Iu(e,t){const n=[...t].sort((c,l)=>c.oldPosition-l.oldPosition||c.oldEnd-l.oldEnd),r=[],i=[],o=[];let s=0,a=0;for(const c of n){const l=e.substring(s,c.oldPosition);r.push(l,c.newText),a+=l.length,i.push([c.oldPosition,c.oldEnd]),o.push([a,a+c.newText.length]),a+=c.newText.length,s=c.oldEnd}return r.push(e.substring(s)),{next:r.join(""),removed:i,inserted:o}}var Vb=/<(?:!doctype|html|head|body)\b/i;function Gb(e,t){return e.reduce((n,r)=>n+r.oldLength,0)<t.trim().length?!1:Vb.test(t)&&!Iu(t,e).next.trim()}function qb(e,t){if(e.reduce((s,a)=>s+a.oldLength,0)<=200)return null;const n=Ks(t),r=Iu(t,e),i=Wr(t,n,r.removed)-Wr(r.next,Ks(r.next),r.inserted),o=Wr(t,n,[[0,t.length]]);return i>100&&i>o*.2?{removed:i,total:o}:null}function rt(e){dn(e,{origin:"canvas-channel"})}var Wb=100;function zb(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===K.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function Kb(e){const t=ye(e),n=fe(e);let r;const i=(c,l)=>{const u=c.get().docId;let d=!1,m=null,_=null,v;const E=Mb({startVersion:c.get().version});let y=c.getContent();const k=jb(),C=Qc(e),F=C.open(u,()=>c.get().version);let T=!1;const R=I=>({generation:Te(n),originId:I});let A=R(null),D=!0;const O=(I,P)=>{!D||t.current()!==c||(dn(P,{origin:"canvas-channel"}),_?.splice(0,_.length),n.sendAsync(K.SANDBOX_SET_ENTITY,ar(fn(c),u,Ze(e).editorPolicy,c.get().version)).catch(rt))},h=I=>{const P=I[I.length-1],j=[...I].reverse().find(G=>G.answer?.actionId!==void 0)?.answer?.actionId,q=P.answer?.selection,Q=j!==void 0||q?{...j!==void 0?{actionId:j}:{},...q?{selection:q}:{}}:void 0;return{edits:I.map(G=>G.edits),guid:u,rev:P.rev,...Q?{historyAnswer:Q}:{}}},f=()=>{const I=l.activeMove(),P=I&&v?.action===I.kind?v:void 0;if(P&&(v=void 0),!(!P&&!I?.selection))return{...P?{actionId:P.actionId}:{},...I?.selection?{selection:I.selection}:{}}},p=I=>{b({edits:[],rev:c.get().version,answer:{actionId:I.actionId}}).catch(rt)},b=async I=>{if(_){_.push(I);return}_=[I];try{do await n.sendAsync(K.SANDBOX_UPDATE_ENTITY,h(_.splice(0,_.length)));while(_.length)}catch(P){O("app edits failed to reach the canvas",P)}finally{_=null}},x=I=>{I.length&&n.sendAsync(K.SANDBOX_UPDATE_ENTITY,h(I)).catch(rt)},N=(I,P)=>{T=!0,x(_?.splice(0,_.length)??[]);const j={edits:[I],guid:u,rev:c.get().version,...P!==null?{changeId:P}:{}};P!==null&&k.remember(P,A,j),n.sendAsync(K.SANDBOX_UPDATE_ENTITY,j).catch(rt)},S=new Set,w=(I,P,j,q)=>{N([],q);const{length:Q,hash:G}=Nr(JSON.stringify(j.map(L=>[L.oldText,L.newText]))),z=`${Q}:${G}`;S.has(z)||(S.add(z),O(I,P))},M=(I,P,j)=>w("canvas service batch removes a large part of the email",new Error(`canvas service batch removes ${I.removed} of ${I.total} tags`),P,j),B=({changeId:I,baseRev:P})=>{!T&&(I!==null||P!==null)&&N([],I)},W=I=>{if(I.guid!==u)return;const P=nh(I);T=!1,A=R(P.originId);try{ie(I,P)}catch(j){B(P),O("canvas batch failed to apply",j)}finally{B(P),P.changeId!==null&&C.note(P.changeId,A)}},ie=(I,P)=>{const{pushUndoStop:j}=I,q=P.changeId!==null?k.find(P.changeId,A):void 0;if(q){T=!0,n.sendAsync(K.SANDBOX_UPDATE_ENTITY,q).catch(rt);return}let{edits:Q,selection:G}=I;if(P.baseRev!==null){const z=E.rebase(Q,P.baseRev);if(!z){dn(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),N([],P.changeId);return}z!==Q&&(G=void 0),Q=z}try{d=!0,m=P.changeId;const z=Nb(Q,c.getContent());if(Gb(z,c.getContent())){w("canvas batch erases the whole email",new Error("canvas batch erases the whole email"),z,P.changeId);return}if(j===!1){const L=qb(z,c.getContent());if(L){M(L,z,P.changeId);return}l.applyWithoutHistory(z)}else l.recordAt(I.typedAt,()=>c.mutate({changes:z},{source:Su(e)?"system":"user"}),G),I.closesStep&&l.closeGroup()}finally{d=!1,m=null}},re=c.subscribe(({changes:I,version:P})=>{const j=c.getContent(),q=!I?.length&&j!==y;if(y=j,E.record({version:P,changes:I,contentReplaced:q,fromCanvas:d}),!I?.length)return;const Q=Fb(I);d?N(Q,m):b({edits:Q,rev:P,answer:f()}).catch(rt)}),oe=n.addListener(K.APPLICATION_UPDATE_ENTITY,W),X=n.addListenerAsyncPipe(Df,(I,P)=>{v=zb(I);try{return P?.(I)}finally{const j=v;v=void 0,j&&p(j)}},Wb),$=(I,P,{reportId:j,dropsCovered:q})=>{const Q=_?.splice(0,_.length)??[];n.sendAsync(K.SANDBOX_UPDATE_ENTITY,{edits:[Ub(I,P)],guid:u,rev:c.get().version,resync:{textFingerprint:Nr(P),reportId:j}}).catch(G=>O("canvas resync edit failed to reach the canvas",G)),q&&x(Q)},g=n.addListener(K.APPLICATION_SYNC_DRIFT,I=>{if(!((I.reason==="echo-timeout"||I.reason==="resync-failed")&&I.guid!==void 0&&I.guid!==u)){if(I.reason==="resync-failed"){O("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(I.reason==="echo-timeout"){const{textFingerprint:P}=I,j=fn(c),q=Nr(j);if(P?.length===q.length&&P.hash===q.hash){k.echoes(R(I.originId??null)).forEach(G=>{n.sendAsync(K.SANDBOX_UPDATE_ENTITY,G).catch(rt)}),I.reportId!==void 0&&$(j,j,I);return}const Q=new Error(`canvas echo timeout, ${I.unsent??0} edits unsent`);if(I.canvasText===void 0){O("canvas lost the echo of its batch",Q);return}$(I.canvasText,j,I)}}});return()=>{D=!1,F(),re(),oe.dispose(),X.dispose(),g.dispose()}};let o;const s=()=>{const c=t.current(),l=t.history(),u=c?.get().docId;u!==o&&(r?.(),r=void 0,o=u,c&&l&&(r=i(c,l)))},a=t.subscribe(s);s(),e.getInstance(Y)?.addDispose(()=>{r?.(),a()})}function Yb(e){const t=fe(e),n=()=>me(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(K.RELOAD,()=>{n()?.followReload()}),i=t.addOffTargetListener(K.RELOAD,a=>{const c=me(e)?.byWindow(a);c&&Eu(e,c.element)}),o=t.addListener(a=>{a.data?.operation===K.SANDBOX_RESIZED&&n()?.resize()}),s=ne(e,H.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(Y)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose(),s.dispose()})}function Ys(){const e=document.createElement("div");return e.dataset.canvasOffscreen="true",e.style.position="absolute",e.style.left="-10000px",e.style.top="-10000px",e.style.width="1600px",e.style.height="1000px",document.body.appendChild(e),e}function Xb(e){const t=e.getInstance(we);let n,r;e.getInstance(Y)?.addDispose(()=>{r?.remove(),r=void 0}),Tb(e,{resolveMount:()=>n,resolveSrc:o=>ru(o==="block"),elementId:"email_iframe",mark:o=>ae(o)}),t?.watch(o=>{const s=o?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,me(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(o!==void 0){n=r??=Ys(),me(e)?.alignSurface("email",r,r);return}else return;me(e)?.get("email")}});let i;e.getInstance(Y)?.addDispose(()=>{i?.remove(),i=void 0}),_g(e).watch(o=>{const s=me(e);if(s){if(o){i??=Ys(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var xo=U("canvas.headerFlow"),Xs=["subject","preheader"],Js=3e3,Jb=3,Qb={subject:K.SANDBOX_SUBJECT_UPDATE,preheader:K.SANDBOX_PREHEADER_UPDATE};function Zb(e){const t=ye(e),n=fe(e),r=R=>R?"remote":Su(e)?"system":"user",i=(R,{guid:A,value:D,forced:O})=>{const h=Ct(t);if(!h||typeof D!="string"||A&&A!==h.get().docId)return;const f=t.forcedHeaders();if(f?.[R]!==void 0&&!O&&D!==f[R])return;const p=h.get().attributes[R];if(!O&&_(R,D,p))return;const b=!O&&d.delete(R);O&&(y.delete(R),y.size===0&&t.endForcedHeaders()),c=!0;try{Mt(h,{[R]:D},{source:b?"system":r(O)})}finally{c=!1}o[R]=D};let o={},s,a,c=!1,l=Promise.resolve();const u={},d=new Map,m=(R,A)=>{o[R]=A;const D={};d.set(R,D);const O=()=>{d.get(R)===D&&d.delete(R)};v(R,A,{force:!0}).then(O),setTimeout(O,Js)},_=(R,A,D)=>{const O=t.showFill();if(!O||typeof D!="string")return!1;const h=u[R]?.showId===O.showId?u[R]:void 0;return A===D?(u[R]=h??{showId:O.showId,codeEdits:O.codeEdits,corrections:0},!1):h&&O.codeEdits>h.codeEdits&&A!==h.stale?!1:((!h||A===h.stale&&h.corrections<Jb)&&(u[R]={showId:O.showId,stale:A,codeEdits:O.codeEdits,corrections:(h?.corrections??0)+1},m(R,D)),!0)},v=(R,A,{force:D=!1,echo:O=!1,undoStep:h=!1})=>(l=n.sendAsync(Qb[R],{value:A,guid:Ct(t)?.get().docId,...D?{force:!0}:{},...O?{echo:!0}:{},...h?{undoStep:!0}:{}}).catch(f=>{}),l);let E;const y=new Set;e.inject(xo,{whenDelivered:async()=>{await l},reassert:R=>{const A=Ct(t),D=Xs.filter(O=>typeof R[O]=="string");if(!(!A||D.length===0)){c=!0;try{Mt(A,Object.fromEntries(D.map(O=>[O,R[O]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders(Object.fromEntries(D.map(O=>[O,R[O]]))),clearTimeout(E),E=setTimeout(()=>{y.clear(),t.endForcedHeaders()},Js),y.clear();for(const O of D)y.add(O);for(const O of D)o[O]=R[O],v(O,R[O],{force:!0,echo:!0})}}});const k=()=>{s?.(),s=void 0;const R=Ct(t);if(R!==a&&d.clear(),a=R,!R){o={};return}const A=R.get().attributes;o={subject:A.subject,preheader:A.preheader},s=R.subscribe(({source:D})=>{if(c)return;const O=R.get().attributes,h=t.forcedHeaders();for(const f of Xs){const p=O[f];if(p===o[f])continue;o[f]=p,d.delete(f);const b=D==="system"&&h?.[f]!==void 0;v(f,p??"",{force:b,echo:b,undoStep:D==="user"})}})};k();const C=t.subscribe(k),F=n.addListenerAsync(K.APPLICATION_SUBJECT_UPDATE,R=>i("subject",R)),T=n.addListenerAsync(K.APPLICATION_PREHEADER_UPDATE,R=>i("preheader",R));e.getInstance(Y)?.addDispose(()=>{F.dispose(),T.dispose(),C(),s?.(),clearTimeout(E)})}function e_(e){const t=ye(e);let n={document:void 0,seq:0};const r=()=>{const o=t.recoveryFacts(),s=Ct(t);if(!o?.applied||!s||String(o.emailId)!==String(s.get().serverId)||(n.document!==s&&(n={document:s,seq:0}),o.applied.seq<=n.seq))return;n={document:s,seq:o.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(xo)?.reassert(a)},i=t.subscribe(r);e.getInstance(Y)?.addDispose(i)}function t_(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?Sf:_f}function n_(e,t){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1}}function r_(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Qs(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Di(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];Qs(i)&&Qs(o)?n[r]=Di(o,i):i!==void 0&&(n[r]=i)}return n}function i_(e,t){const n=io;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const i=JSON.parse(r);if(i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length>0)return Di(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?Di(n,t):n}var o_=ce(void 0),Zs=o_,Tu=U("CodeMode");function Au(){let e;try{const t=window.localStorage?.getItem(mr.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function s_(e){try{window.localStorage?.setItem(mr.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function Cr(e){return e.getOrCreateInstance(Tu,()=>{const t=ce(Au());return t.watch(s_),t})}function Cu(e){return e?.getInstance(Tu)?.get()??Au()}function xi(e,t){const n=Cr(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function a_(e,t){const n=Cr(e);n.set({...n.get(),direction:t})}var c_=U("DefaultCommonStyles");function Ru(e){return e.getOrCreateInstance(c_,()=>ce(void 0))}function l_(e,t){Ru(e).set(t)}var u_=U("CanvasViewport"),d_=U("CanvasPreviewPage");function ze(e,t,n){let r,i;const o=()=>{if(!r||!e.isInited())return;const c=r.value===void 0?"undefined":JSON.stringify(r.value);c!==i&&(i=c,e.send(t,r.value))},s=n.watch(c=>{r={value:c},o()}),a=e.onInit(()=>{i=void 0,o()});return{dispose(){s.dispose(),a.dispose()}}}function Fn(e){const t=ce(e());return{source:t,refresh:()=>t.set(e())}}function f_(e){const t=fe(e),n=e.getInstance(ge),r=e.getInstance(we),i=ye(e),o=Cr(e),s=matchMedia(Bf),a=()=>n?.get()??{};let c;const l=Fn(()=>t_(Zs.get()??a().theme,s.matches)),u=Fn(()=>n_(a(),ee(i.sessionKey()))),d=Fn(()=>a().lockEditor),m=Fn(()=>i_(i.current()?.get().attributes?.common_styles,c)),_=e.getOrCreateInstance(u_,()=>ce()),v=e.getOrCreateInstance(d_,()=>ce()),E=[ze(t,We.theme,l.source),ze(t,We.flags,u.source),ze(t,We.lockEditor,d.source),ze(t,We.commonStyles,m.source),ze(t,We.codeMode,o.select(r_)),ze(t,We.appName,ce("emailmaker")),ze(t,We.previewPage,v),ze(t,We.viewport,_)],y=()=>{l.refresh(),u.refresh(),d.refresh()},k=n?.watch(y),C=Ru(e).watch(h=>{c=h,m.refresh()}),F=r?.watch(h=>{h&&"commonStyles"in h&&(c=h.commonStyles),m.refresh()});let T;const R=()=>{T?.(),T=i.current()?.subscribe(()=>m.refresh()),m.refresh(),u.refresh()};R();const A=i.subscribe(R),D=()=>l.refresh();s.addEventListener("change",D);const O=Zs.watch(()=>l.refresh());e.getInstance(Y)?.addDispose(()=>{E.forEach(h=>h.dispose()),k?.dispose(),C.dispose(),F?.dispose(),T?.(),A(),s.removeEventListener("change",D),O.dispose()})}var Mi;(function(e){function t(i,o,s=(a,c)=>a===c){if(i===o)return!0;if(i.length!==o.length)return!1;for(let a=0;a<i.length;a++)if(!s(i[a],o[a]))return!1;return!0}e.isEqual=t;function n(i,o=s=>s){const s=new Set;return i.filter(a=>{const c=o(a);return s.has(c)?!1:(s.add(c),!0)})}e.unique=n;function r(i=[],o=[],s=(a,c)=>a===c){const a=[],c=[],l=[];for(const u of i){const d=o.find(m=>s(u,m));d?l.push({prev:u,next:d}):c.push(u)}for(const u of o)i.find(d=>s(u,d))||a.push(u);return{added:a,removed:c,exists:l}}e.diff=r})(Mi||(Mi={}));function p_(e,t){return e.type===t.type&&e.key===t.key}function h_(e){const t=fe(e),n=()=>e.getServices(Tt)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send(K.SANDBOX_ADD_EXTENSIONS,r)}),o=tf(Tt),s=e.onInject(a=>{if(a!==o)return;const c=n();if(!t.isInited()){r=c;return}const{added:l,removed:u}=Mi.diff(r,c,p_);if(r=c,u.length){if(u.some(d=>d.type==="script")){t.send(K.RELOAD);return}t.send(K.SANDBOX_REMOVE_EXTENSIONS,u.map(d=>d.key))}l.length&&t.send(K.SANDBOX_ADD_EXTENSIONS,l)});e.getInstance(Y)?.addDispose(()=>{i.dispose(),s?.dispose()})}var m_=new Set([...Object.values(K).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(so)]);function g_(e){return e.length>0&&!e.startsWith("em:")&&!m_.has(e)}function v_(e){const t=fe(e),n=new Map;let r=!1,i=-1,o=new Set;const s=l=>(l!==i&&(i=l,o=new Set),o),a=t.observeOutgoing((l,u)=>{if(!r||!g_(l))return;const d=Te(t);n.set(l,{data:u,generation:d,scripts:new Set(s(d))})}),c=t.addListener(so,l=>{if(l.phase!=="ready"||l.status!=="success")return;r=!0;const u=Te(t),d=s(u);d.add(l.key);for(const[m,_]of n)_.generation===u||![..._.scripts].every(v=>d.has(v))||(_.generation=u,t.send(Pc(m),_.data))});e.getInstance(Y)?.addDispose(()=>{a.dispose(),c.dispose()})}var b_=U("prewarm.editorVisible");function __(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function y_(e={}){const t=e.paint??__;let n=!1,r=!1,i=!1,o=!1,s=!1;const a=[],c=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,ae(Ee.editorVisible);for(const l of a.splice(0))l()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){i=!0,c()},whenVisible(l){if(s){l();return}a.push(l)},contentShown:()=>i}}function E_(e){return e.getOrCreateInstance(b_,()=>y_())}var w_=500,S_=500,I_=5e3;function T_(e){const t=e.quietMs??w_,n=e.floorMs??S_,r=e.ceilingMs??I_;let i,o,s=0;const a=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},c=()=>{a(),e.run()},l=()=>{clearTimeout(i);const u=n-(Date.now()-s);i=setTimeout(c,Math.max(t,u))};return{start(){a(),s=Date.now(),o=setTimeout(c,r),l()},notify(){i!==void 0&&l()},cancel:a}}var A_=2;function ea(){return new Error("[sandbox] document reloaded during fill")}function C_(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function zr(e){try{e()}catch{}}function R_(e){let t;return zr(()=>{t=e()}),{stage:n=>zr(()=>t?.stage(n)),end:(n,r)=>zr(()=>t?.end(n,r))}}function O_(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,a,c;const l=()=>{const A=e.readTarget?.(),D=e.readSandboxGeneration?.();return A===void 0||D===void 0?void 0:{target:A,generation:D}},u=()=>{const A=l();return A&&{...A,canvasReplaced:e.trackDocument?.(A.target)}},d=A=>{if(A?.canvasReplaced?.())return!0;const D=l();return A!==void 0&&D?.target===A.target&&D.generation!==A.generation},_=Gv({...e,waitScope:()=>({getSandboxTimeoutMs:A=>t().getSandboxTimeoutMs(A),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const A=c;if(!(!A||!e.onSandboxGenerationChange))return{getGeneration:()=>l()?.generation??A.generation,onChange:D=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===A.target||A.canvasReplaced?.())&&D()})??(()=>{})}}});let v;const E=(A,D)=>{if(v===A)return;v=A;const O=s;setTimeout(()=>{s!==O||t().signal.aborted||F(A,D).catch(()=>{})},0)},y=()=>{a?.abort(),a=void 0};let k;const C=()=>{const A=t().signal;A!==k&&(k?.removeEventListener("abort",y),k=A,A.addEventListener("abort",y))};async function F(A,D,O=0){const h=++s;y(),a=new AbortController,c=void 0,C();const f=()=>s!==h,p=_.readTarget(),b=t().generation,x=()=>b===t().generation&&!t().signal.aborted,N=D?"init:reset-":"init:",S=R_(()=>e.observeShow?.(C_(A,D,e.readEmail())));if(!D){const oe=_.publicEmail();oe?.id,oe?.renderGuid,oe?.preheader}let w=!1,M=!1,B,W=!1;const ie=()=>{if(d(B))throw ea()},re=()=>{if(f())throw Ie("Fill superseded")};try{n=!0,await _.sendInitStart(),re(),B=u(),c=B,O===0&&_.fireWillInit(),await(D||O>0?_.refreshContent():_.sendContent()),w=!0,re(),ie();const oe=_.contentSent();_.noteFilled(oe?.target,oe?.docId),S.stage("content"),D||_.publicEmail()?.id;try{await _.sendPreheader()}catch(X){if(Hs(X)||f())throw X;`${N}`,String(X)}re();try{await _.sendSubject()}catch(X){if(Hs(X)||f())throw X;`${N}`,String(X)}if(re(),ie(),_.showFilled(p),await _.sendInited(),re(),ie(),M=!0,i===A){const X=e.readSandboxGeneration?.()??o;X!==void 0&&(r=X)}S.stage("reveal"),await _.revealFilled(),ie(),S.end("revealed")}catch(oe){const X=!f()&&x()&&d(B),$=X?ea():void 0,g=$??oe,I=X&&O<A_?R(A,D,O+1):void 0;W=X&&I===void 0;const P=f()?void 0:{showId:A,contentApplied:w,sandboxInitedAcked:M,superseded:!1,...e.describeSurface?.(),error:String($??oe)};P&&(`${N}`,void 0);const j=!f()&&e.recoverFailedFill?.(p)===!0;if(S.end(f()?"superseded":j?"recovered":lo(g)||!x()?"aborted":"failed",P),!j&&!f()&&ko(t(),A)&&t().failShow(A,g),I!==void 0)return I;throw g}finally{T(A,D,N,{superseded:f(),sessionGeneration:b,contentApplied:w,sandboxInitedAcked:M&&!W,retry:!W,commit:x()})}}function T(A,D,O,h){const{superseded:f,contentApplied:p,sandboxInitedAcked:b}=h;if(f){`${O}`;return}b&&h.commit?_.fireInit(A,D||void 0):b?(`${O}`,h.sessionGeneration,t().generation,t().signal.aborted,void 0):p?(`${O}`,void 0):(`${O}`,void 0),n=!1,a=void 0,!b&&i===A&&(i=void 0,r===o&&(r=void 0)),!b&&p&&h.retry&&E(A,D)}function R(A,D,O){return F(A,D,O)}return{channel:_,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:A=>{r=A},lastCorrelation:()=>i,markCorrelation:A=>{i=A},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:A=>{o=A},fill:A=>F(A,!1),refill:A=>F(A,!0),stop:()=>{s+=1,y(),n=!1,k?.removeEventListener("abort",y),k=void 0}}}function k_(e,t,n){if(!e?.renderGuid||!e.showId||e.showId!==t.showId)return!1;if(t.isNew)return e.id==null;const r=t.emailId??t.navId;return r!=null&&String(e.id??"")!==String(r)?!1:Ou(e,n)}function Ou(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function P_(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=u=>{const d=n(),m=i();if(!k_(d,u,m)){u.showId,u.navId,u.emailId,d?.id,d?.showId,d?.renderGuid;return}u.showId,d?.id,d?.renderGuid,t.markFilled(o()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{s(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&s(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=o();if(t.filledGeneration()===u)return;const d=n(),m=i();if(!d?.renderGuid||!Ou(d,m))return;const _=`${du}${d.renderGuid}`;t.markFilled(u),t.markCorrelation(_);const v=r()?.isReady()===!0;d.id,d.renderGuid,(v?E=>t.refill(E):E=>t.fill(E))(_).catch(()=>{t.lastCorrelation()===_&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id,r()}}}var D_=U("canvas.health");function x_(e){return e??""}function M_(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function ta(e){return e.length>0}function L_(e){const t=ye(e),n=fe(e),r=()=>ee(t.sessionKey())?void 0:t.current(),i=()=>{const L=r();return wu({attributes:L?.get().attributes??{},readContent:()=>L?.getContent(),docId:L?.get().docId,hasSession:!!L,serverId:L?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(Fe)??Po;let s={},a=!1;const c=e.getInstance(we)?.watch(L=>{a=!!L?.element});let l=!1,u=!1,d=!1,m=0;const _=()=>{const L=me(e);if(!L)return;const J=++m,Z=L.spare();return Z&&Eu(e,Z.element),(Z?Z.reloadQuietly():L.ensureSpare()?.ready())?.then(()=>{if(J!==m)return;l=!0;const be=L.spare();be&&Rb(e,be.element),d&&(d=!1,b(),X())})},v=T_({run:()=>{d||_()?.catch(()=>{})}}),E=()=>{E_(e).noteContentShown(),!l&&!d&&v.start()};let y=!1;const k=L=>{const J=me(e),Z=J?.spare()?.element.contentWindow;u&&J&&Z&&L===Z&&(u=!1,J.promote(),J.busy(!1),y=!0)};let C=!1;const R=O_({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const L=me(e);return y&&L&&(y=!1,v.start()),a?L?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:k,noteFilled:(L,J)=>me(e)?.noteFilled(L,J),recoverFailedFill:L=>{const J=me(e),Z=J?.spare()?.element.contentWindow;return!u||!J||!Z||L!==Z?!1:(u=!1,l=!1,f="reload",J.busy(!1),J.peek("email")?.reload(),C=!0,X(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>Te(n),onSandboxGenerationChange:L=>un(n,L),trackDocument:L=>Ob(e,L),observeShow:L=>e.getInstance(D_)?.begin(L),describeSurface:()=>({canvasPath:f,promoted:u,spareClean:l,handshake:n.isInited(),generation:Te(n)}),events:{willInit:L=>{_e(e,H.WILL_EMAIL_INIT_ID).fire(L)},inited:L=>{E(),_e(e,H.ON_EMAIL_INIT_ID).fire(L)},contentChanged:L=>{_e(e,H.ON_CONTENT_CHANGED_ID).fire(L)},emailChanged:L=>{_e(e,H.ON_EMAIL_CHANGED_ID).fire(L)},browserExtensionDetected:()=>{_e(e,H.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),A=P_({pipeline:R,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>Te(n)});let D="",O="",h="",f="none";const p=()=>{const L=me(e)?.spare()?.element.contentWindow;L&&n.getTarget()===L||n.sendNow({operation:K.SANDBOX_LOCK_EDIT,data:!0})},b=()=>{const L=me(e)?.spare();L&&(p(),l=!1,u=!0,Ab(e,L.element))},x=(L,J)=>{const Z=me(e);if(!Z)return!0;const be=Z.spare(),te=be&&l?"spare":"prepare";if(f=te,Z.busy(!0),be&&l)return b(),!0;v.cancel(),p();const et=_();if(et===void 0)return f="reload",Z.busy(!1),Z.peek("email")?.reload(),!0;d=!0;const qe=m;return et.catch(()=>{!d||qe!==m||(d=!1,f="reload",Z.busy(!1),Z.peek("email")?.reload())}),!1},N=()=>{if(ee(t.sessionKey()))return;q(),R.noteSandboxGeneration(Te(n));const L=i(),J=M_(L?.renderGuid,L?.showId,L?.id,s.emailId),Z=x_(L?.renderGuid);if(Z!==O){const et=O;O=Z;const qe=me(e)?.peek("email")?.filled,Hd=qe!==void 0&&qe!==Z;ta(Z)&&(ta(et)||Hd)&&x(et||(qe??""),Z)}if(d)return;(J!==D||C)&&(C=!1,D=J,A.showRequestIdentityChanged());const be=r(),te=`${J}|${be?.get().docId??""}|${Te(n)}`;te!==h&&be?.isReady()===!0&&(h=te,A.selfInitChanged()),A.saasChanged(),re()};let S=!1,w="",M="",B=!1,W=!1;const ie=L=>{L.source==="user"?W=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(B=!0),X()},re=()=>{const L=i();if(!L?.renderGuid)return;const J=R.channel.readContent(),Z=JSON.stringify([L.preheader,L.common_styles,L.meta,L.subject,L.utm_parameters?.utm_campaign??"",L.utm_parameters?.utm_content??"",L.utm_parameters?.utm_medium??"",L.utm_parameters?.utm_source??"",L.utm_parameters?.utm_term??""]),be=S&&J!==M,te=S&&Z!==w;S=!0,M=J,w=Z;const et=B&&!W;if(B=!1,W=!1,R.isEventsLocked()||et)return;const qe={...L,id:s.isTemplate||L.isNew?void 0:L.id,html:J};if(be){_e(e,H.ON_CONTENT_CHANGED_ID).fire(J),_e(e,H.ON_EMAIL_CHANGED_ID).fire(qe);return}te&&L.is_inited&&_e(e,H.ON_EMAIL_CHANGED_ID).fire(qe)};let oe=!1;const X=()=>{oe||(oe=!0,queueMicrotask(()=>{oe=!1,N()}))};e.inject(Do,{pipeline:R,setRoute:L=>{L.emailId===s.emailId&&!!L.isTemplate==!!s.isTemplate||(s=L,X())}});let $,g;const I=()=>{const L=r()?.get().docId;L!==g&&($?.(),g=L,$=r()?.subscribe(ie)),X()};let P,j;const q=()=>{const L=e.getInstance(Fe);!L||L===P||(j?.(),P=L,j=L.onShowRequested(J=>A.showRequested(J)))},Q=n.addListener(L=>{L.data?.operation===K.SANDBOX_RESIZED&&v.notify()}),G=t.subscribe(I),z=un(n,X);I(),e.getInstance(Y)?.addDispose(()=>{c?.dispose(),j?.(),z(),G(),$?.(),Q.dispose(),v.cancel(),R.stop()})}function N_(){return Ff!=="emailmaker"}var F_={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},ku={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},na=ku,B_=["pro"],Li={};function j_(e){Li=e}var Pu=e=>B_.includes(e)?na:Li[e]??Li.editor??na,Ni={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},U_={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},$_={...Ni,config:{...Ni.config,imageCenterFileManagerView:!1}};j_({pro:ku,editor:U_,simple:N_()?Ni:$_,blocks:F_});function H_(e,t,n=e.getInstance(ge)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Cu(e).isCodeMode&&xi(e,!1)}function V_(e){e.getInstance(df)||e.inject(Ve,void 0)}function Rr(e){return String(e.standaloneKey||"").trim()||void 0}function G_(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function Mo(e){return G_(e)?!!Rr(e):!1}function Sn(e){return!!Rr(e)&&!Mo(e)}var q_=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function ra(e){return e==="server"?"serverSide":e}function W_({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=ce();let o={kind:"pending"},s;const a=new Promise(m=>{s=m}),c=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function l(){o.kind!=="pending"&&i.set(Gr(r,e))}function u(m){if(o.kind!=="pending")return;clearTimeout(c),o=m;const _=Gr(r,e);i.set(_),s(_)}function d(m,_){r[ra(m)]=_,m==="server"&&o.kind==="pending"?u({kind:"applied"}):l()}return{watch:m=>i.watch(m),select:m=>i.select(m),get:()=>i.get(),ready:()=>a,state:()=>o,layers:()=>({...r}),bootstrap(){const m=Gr(r,e);return Object.fromEntries(q_.map(_=>[_,m[_]]))},merge(m,_){d(_,{...r[ra(_)],...m})},replace(m,_){d(_,m)},setMode(m){r.user={...r.user,mode:m},l()},setAdvancedConfigs(m){r.advancedConfigs=m,l()},serverAbsent(m){u({kind:"absent",reason:m})},applyServerResponse(m){o.kind==="pending"&&d("server",{...r.serverSide,...m})},dispose(){clearTimeout(c)}}}var z_=5e3;function K_(){return{...Pu("pro")?.config,mergeTags:void 0}}function Y_(e,t){e.getInstance(we)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},i=t.layers().user.mode;t.replace(r.mode===void 0&&i!==void 0?{...r,mode:i}:r,"user")})}function X_(e,t){let n;Ao(e).watch(({profile:r})=>{const i=`${r?.theme??""}|${r?.locale??""}`;if(i===n)return;n=i;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function J_(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Q_(e,t){let n,r=!1,i;const o=a=>{i??=Sr(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&H_(e,a,t)},s=Ao(e).watch(({profile:a})=>{const c=a?.email_builder_config,l=J_(c);if(l===void 0||c===n)return;const u=n===void 0;n=c,!(u&&r)&&o(l)});e.getInstance(Y)?.addDisposable(s),t.ready().then(a=>{if(!a.configSwither)return;const c=localStorage.getItem("configSwither")||(n===void 0?a.mode:i)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,o(c)})}var ia="замкнутый контур: app_init не выполняется";function Z_(e,t){if(e.getInstance(Ve)){t.serverAbsent(ia);return}const n=e.getInstance(we)?.watch(r=>{Sn(r)&&t.serverAbsent(ia)});n&&e.getInstance(Y)?.addDisposable(n)}async function ey(e,t){if(e.getInstance(po)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Xe);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function ty(e){e.injectFactory(ge,(t,n)=>{if(n)return n;const r=W_({base:K_(),env:{modeDefaults:i=>Pu(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:z_});return Y_(e,r),X_(e,r),Q_(e,r),Z_(e,r),ey(e,r),e.getInstance(Y)?.addDisposable(r),r},!0)}var Pt=class extends ve{_event;_listener;_disposeEvent;constructor(e){super(),this._event=e}setListener(e){this._listener!==e&&(this._listener=e,this._disposeEvent&&this._disposeEvent(),e?this._disposeEvent=this._event(e):this._disposeEvent=void 0)}dispose(){this._disposeEvent&&this._disposeEvent(),super.dispose()}};function V(e,t,n){const r=of(e);return(i,o,s)=>{const a=r(async c=>{const l=t?t(c):c;s&&i.bind(s);const u=await i(l);return n?n(u):u},o,s);return()=>a.dispose()}}var ny=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new gi;this.handleDestroy=V(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Pt(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},Lo=U("DestroyableService");function ry(e){e.injectFactory(Lo,(t,n)=>{if(n)return n;const r=e.getInstance(Y);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new ny({lifetime:r,options:e.getInstance(we),getInstance:()=>e.getInstance(bn),release:()=>hf(e.getInstance(Ic)??e)})},!0)}function iy(e){const t=e.getInstance(Lo);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var oy=1e3;function Du(e,t,n=oy,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const s of i)if(!Du(e[s],t[s],n,r+1))return!1;return!0}return!1}function sn(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const i=t[r],o=e[r];Du(i,o)||(n[r]=i)}return n}var sy=({source:e,emailtags:t,group:n,tags:r,...i})=>i;async function ay(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function cy({emails:e,saveTimeoutMs:t},n,r){const i=t?.()??En();let o;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,c)=>{o=setTimeout(()=>{const l=new gr(i);n.value.id,hh(l,ay(s,r)),c(l)},i)})])}catch(s){throw dl(s),s}finally{o!==void 0&&clearTimeout(o)}}function ly(e){const{emails:t}=e,n=async(r,i)=>{const o=sy(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...o}:o,c=s?sn(s,o):o,l=u=>{const d=String(u.id??r??ke()),m=u.id===void 0?{...u,id:d}:u;return t.cache.addOrUpdate(d,()=>m)};return await l(await cy(e,{prev:s,patch:c,value:a,source:i.source??""},l))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const i=await n(void 0,r);return i?.renderGuid?i:{...i,renderGuid:ke()}},async updateEmail(r,i){return await n(r,i)}}}var Kr=20;function uy(e){const t=dy(e);return e.saveTimeoutMs?fy(t,e.saveTimeoutMs):t}function dy({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:i,integratorProject:o}){const s=async(a,c)=>(t.clear(),await t.get(a,{page:c}),(await e.cache.values()??[]).filter(l=>String(l?.parent)===String(a)));return{async readRevisions(a,c=1){const l=await s(a,c);return{revisions:l.slice(Kr*(c-1),Kr*c),page:c,hasMore:l.length>Kr*c}},async readAutosave(a){const c=await r?.(a)??NaN,l=Number.isFinite(c)?c:void 0,u=await n?.(a);if(!u?.asked)return wh(await s(a,1),l);if(!u.revision)return bs([],l);const d={...u.revision,parent:a,isAutosave:!0};return bs([d],l,await s(a,1))},async saveAutosave(a,c){const l=await i?.(a),u=o?.();return await e.create({...Rh(c),...l!==void 0?{author:l}:{},...u!==void 0?{project:u}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function fy(e,t,n){return{...e,async saveAutosave(r,i){const o=t();if(o===void 0)return e.saveAutosave(r,i);let s;try{return await Promise.race([e.saveAutosave(r,i),new Promise((a,c)=>{s=setTimeout(()=>c(new Yc(o,n)),o)})])}catch(a){throw dl(a),a}finally{s!==void 0&&clearTimeout(s)}}}}var py=class extends af{async execute([e],t){for(const n of t){const r=await n(e);r&&(r.id===void 0&&(r.id=e.value.id),e.value=r)}return e.value}},hy=class extends Je{};var oa=class extends ve{_items=new Map;_onChangeEmitter=new lf;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const i=await t(n);return Ne(n,i)||this._onChangeEmitter.fire(),i}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([i,o])=>i)),r=(await this.entries()).filter(([i,o])=>!n.has(i));for(const[i,o]of e)t.push(this.addOrUpdate(i,()=>o)),n.add(i);for(const[i]of r)t.push(this.remove(i));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function my(e,{filter:t,order:n="asc",orderBy:r,page:i,pageSize:o=20}={}){const s=e.length;let a=e.length;if(t!==void 0){const c=Object.keys(t);e=e.filter(l=>{for(const u of c){const d=l[u],m=t[u];return u==="id"||typeof d!="string"?d===m:typeof m=="string"&&d.startsWith(m)}return!0}),a=e.length}return r&&(e=e.sort((c,l)=>(c[r]>l[r]?1:l[r]>c[r]?-1:0)*(n==="asc"?1:-1))),i!==void 0&&(e=e.slice(o*(i-1),o*i)),{data:e,filteredTotal:a,total:s,totalPages:Math.ceil(a/o)}}function gy(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const i=t.get(r.id)||{};t.set(r.id,{...i,...r})}return[...t].map(([n,r])=>r)}function vy(e,t){return sa(e)&&sa(t)?String(e)===String(t):e===t}function sa(e){return typeof e=="string"||typeof e=="number"}var by=class extends ve{_cache=new oa;_readEmitter=new Je;_saveEmitter=this.addDisposable(new py);_removeEmitter=this.addDisposable(new hy);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}async confirmedMissing(e){if(!this.hasReadHandler())return!1;const{results:t,errors:n}=await this._readEmitter.fireSettled(e);return!n.length&&!t.some(Boolean)}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ve);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new oa),i=n.addDisposable(new Je);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const c=gy(await i.fire(o))||[];for(const l of c)l[e]=o,await this._cache.add(l.id,l);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const l=c[e];return l==null||vy(l,o)});return my(a,s)},first(o,s={}){return t.get(o,{...s,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:i.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=ke()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async i=>{const o=i?{...i,...t}:t;if(!r)return t=i?sn(i,t):t,await this._saveEmitter.fire({prev:i,patch:t,value:o,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function In(e){const t=U(e);return n=>n.getOrCreateInstance(t,()=>new by)}function xu(e){const t=e.getInstance(Y);if(!t)throw new Error("Failed");return t}function aa(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Bn(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function _y(e,t,n){return e&&!aa(t)&&aa(e)?{...n,meta:e.meta}:n}var yy=U("CurrentProject"),Ey={};function Tn(e){return e?.getInstance(yy)?.get()??Ey}function No(e){const t=Tn(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Mu=In("plugin.dataSource.emails"),Lu=In("plugin.dataSource.emailRevisions"),Nu=Tr("plugin.readEmailAutosave"),ca=U("emailDocuments.provided");function wy(e){const t=Mu(e),n=Lu(e),r=n.byForeignKey("parent");if(e.getInstance(ca))return{emails:t,emailRevisions:n};e.inject(ca,!0);const i=()=>En(e.getInstance(Fe)?.contentReadyTimeoutMs),o=ly({emails:t,saveTimeoutMs:i}),s=new Map,a=(c,l)=>u=>{const d=u?.id??l;return(typeof d=="string"||typeof d=="number")&&s.set(String(d),c),u};return Jh(e,{...o,createEmail:c=>o.createEmail(c).then(a(Date.now())),updateEmail:(c,l)=>o.updateEmail(c,l).then(a(Date.now(),c))}),tm(e,uy({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const l=await _e(e,Nu).fire(c);return l.length===0?{asked:!1}:{asked:!0,revision:l[0]??null}},savedAt:async c=>{const l=yh((await t.cache.getIfPresent(c))?.modified),u=s.get(String(c))??NaN;return Number.isFinite(u)&&!(l>=u)?u:l},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:i,integratorProject:()=>Tn(e).requested})),xu(e).addDisposable(t.onSave(({prev:c,patch:l,value:u})=>_y(c,l,u),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function la(e,t){return!e?.data||!t||e.id!==t.locale?!1:t.contentHash?e.hash===t.contentHash:t.updatedAt>0&&t.updatedAt<=e.time}function Sy(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Iy="po",jn=null;function Ty(){const e=typeof window.__emailmaker__<"u"?window.__emailmaker__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([Iy],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Ay(){return jn===null&&(jn=Ty().catch(e=>{throw jn=null,e})),jn}async function Fu(e){if(typeof e=="object")return Fo(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Cy(t):Ry(t)}function Fo(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Cy(e){try{return Fo(JSON.parse(e))}catch{return}}var ua=!1;async function Ry(e){try{return Fo((await Ay()).parsePoCatalog(e))}catch{ua||(ua=!0);return}}var Oy="em_locale",ky="em_ant_locale",Py="locale",Dy="ant_locale";function Bo(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Bu(e,t){const n=Bo(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function xy(){return Bo("em_locale")??Bu(Py,"em_locale")}function da(e){try{localStorage.setItem(Oy,JSON.stringify(e))}catch{}}function My(){return Bo("em_ant_locale")??Bu(Dy,"em_ant_locale")}function Ly(e,t){try{localStorage.setItem(ky,JSON.stringify({id:e,data:t}))}catch{}}var Ny=8e3;function Fy(e,t){const n=e,r=t,i=Object.keys(n).filter(o=>o!=="");return i.length!==Object.keys(r).filter(o=>o!=="").length?!1:i.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function By(e){const t=xy(),n=My();let r={ready:!1},i;const o=ce(r);let s=0;const a=y=>{r={...r,...y},o.set(r)},c=()=>{r.ready||a({ready:!0})},l=setTimeout(c,e.unlockAfterMs??Ny),u=y=>y!==s;let d;async function m(y,k){if(n?.id===y&&n.data&&a({antd:n.data}),!d)return;const C=await d(y).catch(()=>{});!C||u(k)||(a({antd:C}),Ly(y,C))}async function _(y,k){const C=await e.askHost(y).catch(()=>null);if(u(k))return!0;if(C==null)return!1;const F=await Fu(C);return u(k)||(F&&a({catalog:F}),c()),!0}async function v(y,k){const C=await e.readList();if(u(k))return;if("error"in C){a({failure:{kind:"GET_LOCALES_ERROR",error:C.error}}),c();return}const F=C.data.find(R=>R.locale===y);if(!F){Sy("em_locale")&&a({catalog:void 0}),c();return}if(la(t,F)&&(!i||i.catalog===t?.data)){c();return}if(i?.entry&&r.catalog===i.catalog&&la(i.entry,F)){da(i.entry),c();return}const T=await e.readCatalog(y);if(!u(k)){if("error"in T){a({failure:{kind:"GET_LOCALE_ERROR",error:T.error}}),c();return}T.data&&(i?.id===y&&r.catalog===i.catalog&&Fy(i.catalog,T.data)||a({catalog:T.data}),da({id:y,time:F.updatedAt||Math.floor(Date.now()/1e3),hash:F.contentHash,data:T.data})),c()}}async function E(y,k){if(!await _(y,k)){if(!u(k)&&(i?.id===y&&r.catalog===i.catalog||y==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await v(y,k)}}return{set(y){if(!y||y===r.id)return;const k=s+=1;a({id:y,failure:void 0});const C=i?.id===y&&r.catalog===i.catalog;(i&&!C&&r.catalog===i.catalog||y==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===y&&t.data&&(a({catalog:t.data}),c()),m(y,k),E(y,k)},prime(y,k,C){r.id&&r.id!==y||r.catalog||!k||(i=t?.id===y&&t.data&&(!C||t.time>=C.time)?{id:y,catalog:t.data}:{id:y,catalog:k,entry:C?{id:y,time:C.time,hash:C.hash,data:k}:void 0},a({catalog:i.catalog}))},useAntdLoader(y){d=y,r.id&&m(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(l)}}var jy=class{http;constructor(e){this.http=e}jsonList=({locale:e},t={})=>this.http.request({path:`/translations/${e}.json`,method:"GET",format:"json",...t});getTranslations=({locale:e},t={})=>this.http.request({path:`/translations/${e}.po`,method:"GET",...t});localesList=(e={})=>this.http.request({path:"/translations/locales",method:"GET",format:"json",...e})},fa=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),Uy=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:i,format:o,baseUrl:s,cancelToken:a,...c})=>{const l=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(c,l),d=i&&this.toQueryString(i),m=this.contentFormatters[r||"application/json"],_=o||u.format;return this.customFetch(`${s||this.baseUrl||""}${n}${d?`?${d}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):u.signal)||null,body:typeof e>"u"||e===null?null:m(e)}).then(async v=>{const E=v;E.data=null,E.error=null;const y=_?v.clone():v,k=_?await y[_]().then(C=>(E.ok?E.data=C:E.error=C,E)).catch(C=>(E.error=C,E)):E;return a&&this.abortControllers.delete(a),k})}},$y=U("rest.v2.transport"),pa=Symbol("rest.v2.secureRequest");function Hy(e){return e.getOrCreateInstance($y,()=>{const t=e.getInstance(Jd)?.execute||fetch;return new Uy({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[pa]:!0}),customFetch:(n,r={})=>{const{[pa]:i,...o}=r;return t(n,{...o,[pf]:i!==!0})}})})}function ju(e,t){const n=Hy(e);return Object.assign({},...t.map(r=>new r(n)))}function ha(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Or(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:ha(n.details,"wp_code")??n.code,message:ha(n.details,"wp_message")??n.message,details:n.details}}:t&&typeof t=="object"?{status:e.status,data:t}:{status:e.status,data:{message:e.statusText||"request failed"}}}function Uu(e){return!e.ok||!!e.error}function $u(){return el(mr.em_translations_v2)??!0}function Vy(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Gy(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function qy(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],i=r[0];return typeof i=="string"&&i!==""&&t.push({locale:i,updatedAt:Vy(r[1])}),t},[]):[]}function Wy(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Gy(n.updated_at),contentHash:n.content_hash}),t),[])}function Hu(e){return ju(e,[jy])}function lr(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Fi(e){return!e.ok||e.error!=null}function Bi(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Yr(e){return{data:await Fu(e)??null}}async function zy(e){if($u())try{const n=await Hu(e).localesList();return Uu(n)?{error:Or(n)}:{data:Wy(n.data)}}catch(n){return lr(n)}const t=Ac(e,[Lc]);try{const n=await t.get_translations2({file:"react_app"});return Fi(n)?Bi(n):{data:qy(n.data)}}catch(n){return lr(n)}}async function Ky(e,t){if($u())try{const r=await Hu(e).jsonList({locale:t});return Uu(r)?{error:Or(r)}:Yr(r.data)}catch(r){return lr(r)}const n=Ac(e,[Lc]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Fi(r)?Bi(r):Yr(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Fi(r)?Bi(r):Yr(r.data)}catch(r){return lr(r)}}}var Un=new WeakMap;function Yy(e){const t=Un.get(e);if(t!==void 0)return t;const n=zy(e).then(r=>("error"in r&&Un.delete(e),r),r=>{throw Un.delete(e),r});return Un.set(e,n),n}var vt=U("locale.service");function Xy(e){if(e.getInstance(vt))return;const t=By({readList:()=>Yy(e),readCatalog:n=>Ky(e,n),askHost:async n=>(await _e(e,H.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(Ve)});e.inject(vt,t),e.getInstance(Y)?.addDispose(()=>t.dispose())}function Jy(e){const t=e.getInstance(ge);if(!t)return;const n=e.getInstance(vt);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i||"ru_RU"));e.getInstance(Y)?.addDisposable(r)}var Qy="user_id",Zy="project_id",ma=U("rest.identityHeadersProvided");function eE(e){if(e.getInstance(ma))return;e.inject(ma,!0);let t;e.getInstance(we)?.watch(n=>{t=n}),e.addService(hr,{execute(n,r){if(r?.public)return;const i=t?.user?.id??Wl(e).profile?.id;i!=null&&i!==""&&n.headers.set(Qy,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(Zy,String(o))}})}function tE(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function nE(e){return e.id??tE(e.catalog)}function rE(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function iE(e){return rE(e||"en_US")}var oE="Accept-Language",ga=U("rest.localeHeaderProvided");function sE(e){e.getInstance(ga)||(e.inject(ga,!0),e.addService(hr,{execute(t){const n=e.getInstance(vt)?.snapshot();t.headers.set(oE,iE(n&&nE(n)))}}))}function aE(e){if(!e)return!1;try{return e.getInstance(Ve)!==void 0}catch{return!1}}var cE="Invalid standaloneKey.",AC=U("StandaloneMockGuard");function lE(){const e=new Error(cE);return e.name="InvalidStandaloneKeyError",e}function uE(e){e.addService(hr,{execute:()=>{if(aE(e))throw lE()}})}function dE(e){qd(e),uE(e)}function fE(e){const t=new fu;e.inject(Fe,t);const n=e.getInstance(we)?.watch(i=>{if(!i)return;const o=i.signal??t.externalSignal;t.configure({replaceSession:!0,...i.timeouts!==void 0?{timeouts:i.timeouts}:{},...o!==void 0?{signal:o}:{}})}),r=e.getInstance(Y);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var Vu=In("plugin.dataSource.blocks"),pE=In("plugin.dataSource.blockRevisions"),hE=In("plugin.dataSource.comments"),mE=Tr("plugin.readTemplateBlocks"),gE=Tr("plugin.readCommonBlocks"),vE=e=>e.replaceAll("&","&").replaceAll("<","<");function Gu(e=""){return`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
1005
1005
|
<html>
|
|
1006
|
+
|
|
1006
1007
|
<head>
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1008
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
1009
|
+
<meta name="x-apple-disable-message-reformatting">
|
|
1010
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1011
|
+
<title>${vE(e)}</title>
|
|
1012
|
+
<style type="text/css">
|
|
1013
|
+
html {
|
|
1014
|
+
-webkit-text-size-adjust: none;
|
|
1015
|
+
-ms-text-size-adjust: none;
|
|
1016
|
+
}
|
|
1017
|
+
</style>
|
|
1018
|
+
<style em="styles">
|
|
1017
1019
|
@media only screen and (max-device-width:660px),only screen and (max-width:660px) {
|
|
1018
1020
|
.em-narrow-table {
|
|
1019
1021
|
width: 100%!important;
|
|
@@ -1022,30 +1024,42 @@ import{n as Ra,r as Pd}from"./static/esm/971f1b2c.js";import{$ as Dd,A as xd,At
|
|
|
1022
1024
|
}
|
|
1023
1025
|
}
|
|
1024
1026
|
</style>
|
|
1027
|
+
<!--[if gte mso 9]>
|
|
1028
|
+
<xml>
|
|
1029
|
+
<o:OfficeDocumentSettings>
|
|
1030
|
+
<o:AllowPNG></o:AllowPNG>
|
|
1031
|
+
<o:PixelsPerInch>96</o:PixelsPerInch>
|
|
1032
|
+
</o:OfficeDocumentSettings>
|
|
1033
|
+
</xml>
|
|
1034
|
+
<![endif]-->
|
|
1025
1035
|
</head>
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1036
|
+
|
|
1037
|
+
<body style="margin: 0; padding: 0; background-color: #F8F8F8;">
|
|
1038
|
+
<span class="preheader" style="display: none !important; visibility: hidden; opacity: 0; color: #F8F8F8; height: 0; width: 0; font-size: 1px;"> </span>
|
|
1039
|
+
<!--[if !mso]><!-->
|
|
1040
|
+
<div style="font-size:0px;color:transparent;opacity:0;">
|
|
1041
|
+
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
1042
|
+
</div>
|
|
1043
|
+
<!--<![endif]-->
|
|
1044
|
+
<table cellpadding="0" cellspacing="0" border="0" width="100%" style="font-size: 1px; line-height: normal;" bgcolor="#F8F8F8">
|
|
1045
|
+
<tr em="group">
|
|
1046
|
+
<td align="center">
|
|
1047
|
+
<!--[if (gte mso 9)|(IE)]>
|
|
1048
|
+
<table cellpadding="0" cellspacing="0" border="0" width="660"><tr><td>
|
|
1049
|
+
<![endif]-->
|
|
1050
|
+
<table cellpadding="0" cellspacing="0" width="100%" border="0" style="max-width: 660px; min-width: 660px; width: 660px;" class="em-narrow-table"></table>
|
|
1051
|
+
<!--[if (gte mso 9)|(IE)]>
|
|
1052
|
+
</td></tr></table>
|
|
1053
|
+
<![endif]-->
|
|
1054
|
+
</td>
|
|
1055
|
+
</tr>
|
|
1056
|
+
</table>
|
|
1044
1057
|
</body>
|
|
1045
|
-
|
|
1058
|
+
|
|
1059
|
+
</html>`}function bE(e,t){return{isNew:!0,is_inited:!1,subject:t||void 0,preheader:void 0,description:"",html:Gu(t),project:e?.id,project_title:e?.title??"",utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}function _E(e){return e("New email")}var qu=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function yE(e){return!Object.keys(e).some(t=>qu.has(t))}function EE(e){const t={},n={};for(const[r,i]of Object.entries(e))qu.has(r)?t[r]=i:n[r]=i;return{showOptions:t,misplacedEmailFields:n}}function va(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function kr(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function wE(e){const t=typeof e.block=="string"?{code:e.block}:{...e.block},n=t.id!==void 0&&t.id!==""&&t.code===void 0,r=e.reload===!0&&t.id!==void 0&&t.id!=="";return{block:t,byId:n,blocks:e.blocks,revisions:e.revisions,reload:r}}function An(e){return{emails:Mu(e),blocks:Vu(e),emailRevisions:Lu(e),blocksRevision:pE(e),comments:hE(e)}}function SE(e){const t=Object.values(An(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function Pr(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(yE(e))return{email:va(e)};{const{showOptions:n,misplacedEmailFields:r}=EE(e),i=Object.keys(r);t&&i.length>0&&void 0;const o=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:va({...r,...o})}}}function jo(e){const t=Re(e);return t&&ee(t.sessionKey())?t.suspendedDocument():t?.current()}function Kn(e){return jo(e)?.getContent()}function Wu(e,t){const n=t??bE(),r=jo(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:Kn(e)??n.html}:n}async function Xt(e){return(await e.getInstanceAsync(Xe))?.project}async function zu(e){return No(e)??await Xt(e)}async function ba(e,t){const n=Vu(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(i=>i!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await zu(e),{filter:{id:t}})}function _a(e){if(!e)return;if(kr(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=Pr(e,!1).email.id;return t==null?void 0:String(t)}function IE(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function TE(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}async function AE(e,t,n){const r=En(e.getInstance(Fe)?.contentReadyTimeoutMs);let i;try{return await Promise.race([t,new Promise((o,s)=>{i=setTimeout(()=>{t.then(n,()=>{}),s(new gr(r,"handleSaveBlock","block"))},r)})])}finally{clearTimeout(i)}}function Ft({code:e,project:t,...n},r){const i=Ge(n),o=No(r),s=Ze(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...i,...e?{html:s.toEditorForm(e)}:{},...o===void 0?{}:{project:o},..."utm_parameters"in i?{utm_parameters:i.utm_parameters||{}}:{},_embedded:void 0}}function Oe({html:e,renderGuid:t,showToken:n,showId:r,...i},o){const{requested:s}=Tn(o),a=Kl(o);return Ge({...i,code:Ze(o).toOutputForm(e),project:s===void 0?i.project:s,utm_parameters:a.UTMEnabled?i.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0,secretHash:void 0})}function ji(e){return e==null?"":e.replaceAll(`\r
|
|
1046
1060
|
`,`
|
|
1047
|
-
`)}function Ms(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function ly(e,t,n,r){const o=dy(e,t,n,r);return o===void 0}function dy(e,t,n,r){if(ar(t))return"block";const{email:o}=cr(t,!1),i=At(o,e),s=i.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=xe(e)?.current();if(!a)return"no-session";const c=a.get(),l=c.attributes;if(c.serverId!==s)return"document-id";if(l.is_inited!==!0)return"not-inited";const d=Ms(_o(n??a.getContent()));if(i.html!==void 0&&Ms(_o(i.html))!==d)return"html";if(i.subject!==void 0&&i.subject!==l.subject)return"subject";if(i.preheader!==void 0&&i.preheader!==l.preheader)return"preheader";if(i.common_styles!==void 0&&i.common_styles!==l.common_styles)return"common_styles"}function Ls(e,t){if(ar(t))return;const{email:n}=cr(t,!1),r=At(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:_o(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function uy(e){return Array.isArray(e)?e.some(t=>oo(t)):oo(e)}function fy(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])uy(t[n])&&delete t[n];return t}function py(e,t){const n={...e};return delete n.id,{...n,...t}}function hy(e){return e.html?e:{...e,html:Ol}}function ot({code:e,project:t,...n},r,o){const i=o??fi(r);return{...n,...e?{html:Ke(r).toEditorForm(e)}:{},renderGuid:Ce(),...i===void 0?{}:{project:i}}}function _e({html:e,renderGuid:t,...n},r){const{requested:o}=an(r);return je({...n,code:Ke(r).toOutputForm(e),project:o===void 0?n.project:o,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function xl(e){return xe(e)?.current()?.get().serverId??void 0}function Eo(e,t,n){return n===void 0&&(n=e.post===void 0?xl(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function Ft(e,t){return je({...e,link:void 0,comment_status:void 0})}function On({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?xl(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||hp(n.slug),parent:o}}function wo({html:e,isAutosave:t,...n},r){return je({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:je({html:e,ampHtml:e&&""})})}function kn({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function Ns({html:e,isAutosave:t,...n}){return je({...n,autosave:t?!0:void 0,code:e,guid:void 0})}function my(e){return String(e).replace(/"/g,""")}function gy(e=new Date){const t=n=>String(n).padStart(2,"0");return String(e.getFullYear())+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function gi(e){const t=/<(table|tr|div)(\s[^>]*)>/gi;let n;for(;(n=t.exec(e))!==null;){const r=n[2]??"";if(/\bem\s*=\s*["']block["']/i.test(r))return{full:n[0],index:n.index}}return null}function Fs(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),o=my(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function Bs(e,t){return e.replace(new RegExp(`\\s+${t}\\s*=\\s*["'][^"']*["']`,"gi"),"")}function js(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function Ml(e){if(!e?.trim())return{};const t=gi(e);return t?{emBlockId:js(t.full,"em-block-id"),emBlockVersion:js(t.full,"em-block-version")}:{}}function Ll(e,t,n){if(!e?.trim()||!t)return e;const r=gi(e);if(!r)return e;const o=String(t),i=gy(n??new Date);let{full:s,index:a}=r;const c=s.length;return/\bem-block-id\s*=/.test(s)||(s=Fs(s,"em-block-id",o)),s=Fs(s,"em-block-version",i),e.slice(0,a)+s+e.slice(a+c)}function vy(e){const t=e?.trim()?gi(e):null;if(!t)return e;const{full:n,index:r}=t,o=Bs(Bs(n,"em-block-id"),"em-block-version");return e.slice(0,r)+o+e.slice(r+n.length)}function by(e,t){const{emBlockId:n,emBlockVersion:r}=Ml(e);return n&&r?e:Ll(e,t)}var yt=H("NotificationService"),yy=H("emailTemplate.reads");async function _y(e,t){try{const n=ct(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,wy(e,t,n);return}}var Ey=H("emailTemplate.notifiedFailures");function wy(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(Ey,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(yt).then(()=>{Qt(e,$.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function Sy(e,t){const n=e.getOrCreateInstance(yy,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=_y(e,t).then(i=>(i===void 0&&n.delete(t),i));return n.set(t,o),o}var Iy=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:As.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:As.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},YI=H("projects.v2IdByWpId"),XI=H("projects.wpIdByV2Id"),JI=H("emails.v2SavedAtOnOpen"),QI=H("emails.v2OpeningReads"),So=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function Cy(e,t){if(!t)throw new So(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new So(e,sr(t))}function Ay(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var Ty=/^[A-Za-z0-9_-]{1,128}$/,Ry=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),Us=new Set;function Oy(e){return Ty.test(e)?!0:(Us.has(e)||Us.add(e),!1)}function ky(e){return e&&!e.ok?String(sr(e).data.code??""):""}var Nl=()=>({isAutosave:!1});function Hs(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function Py(e,t){const n=new AbortController,r=nn(e.getInstance(Pe)?.contentReadyTimeoutMs);let o;const i=new Promise((s,a)=>{o=setTimeout(()=>{n.abort(),a(new So("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),i])}finally{clearTimeout(o)}}function Dy(e,t){return oc(t,e==="block")}async function xy(e,t,n,r,o){if(!Oy(n))return Nl();const i=St(e),s=rn(e),a=Dy(t,n);try{const c=await My(e,t,n,r,o);return c.id&&(i.set(a,c.id),s.delete(a)),c}catch(c){throw eh(s,a,r.html??""),c}}async function My(e,t,n,r,o){const i=Il(e,[Iy]),s={entityId:n,...o?{autosave:!0}:{}},a=await Py(e,c=>t==="email"?i.emailsRevisionsCreate(s,Hs(t,r),{signal:c}):i.blocksRevisionsCreate(s,Hs(t,r),{signal:c}));return Ry.has(ky(a))?Nl():(Cy("обновление",a),Ay(a.data??{}))}function Ly(e,t,n,r){return xy(e,t,n,r,!1)}async function Ny(e,t,n){if(t==null||t===""||n===void 0||!Ot(e))return $s;const r=Date.now(),o=zo(String(t));return kc(o,{html:n},r,ti(St(e),o,rn(e),n)),await Ly(e,"block",String(t),{html:n}),Bn(o,r,St(e).get(o)??void 0),()=>Ko(o,r)}function $s(){}var kr="EXTERNAL",Vs=Symbol("supersededShow");function Fy(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var By="email_id";function Pr(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var jy=class extends pe{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=Da();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=cn(t),this._eventLock=iy(t);const n=te(e,$.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(te(e,$.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(zn,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(By,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Pe)??ai}_throwIfDestroyed(){if(this.isDisposed())throw Ve()}async getTemplateEmail(e){const t=await Sy(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,fy(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Nt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,ot(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,On(o,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,Eo(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const i=this._dataSources.emails,s=i.cache,a=await Nt(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let l=At(e,this._container);const d=l.id;let h=d;if(d!==void 0){const b=await i.get(d);l={...b??{},...l,utm_parameters:l.utm_parameters??b?.utm_parameters??{},renderGuid:b?.renderGuid??Ce(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a}}else{h=n??Ce();const b=await i.get(h);l={...l,utm_parameters:l.utm_parameters??{},renderGuid:b?.renderGuid??Ce(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a},delete l.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(l=py(b,l))}return d===void 0&&(l=hy(l)),await s.setAll([[h,l]]),l}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Ls(this._container,e))return!1;const n=Rn(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Ls(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Rn(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&sy({ticket:t,emailId:xs(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,Vs;if(!e)return;const n=this._getInitPipeline();if(re(n.signal),ar(e))return this._showBlock(e,n);const r=ne(ge(this._container).sessionKey()),o=ay(e);if(!r&&!o&&ly(this._container,e,Rn(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const i=cr(e);i.email.id,this._prevCommand?.id;let s,a="",c=0,l=!1,d,h=Promise.resolve(),b,v=!1;try{this._eventLock.suspendChange();const{email:w,blocks:C,autosaves:y,comments:S,templateId:T,reload:B}=i;s=w.id;const D=At(w,this._container),O=D.id,A=O??Ce(),x=await rt("getProject",Nt(this._container));re(n.signal),a=Ce();const R={isNew:O===void 0,id:String(A),project:x},m=B===!0&&O!==void 0;m&&(await this._dataSources.emails.remove(String(O),{silent:!0}),String(O)),c=++this._showToken,String(A);const f=[];f.push(this.setBlocks(C)),w.id!==void 0&&(f.push(this.setComments(S)),f.push(this.setEmailRevisions(y,String(w.id)))),f.push(this.setEmail(w,oo(T)?T:Number(T),O===void 0?String(A):void 0,c,a)),await rt("setEmail+blocks+revisions",Promise.all(f),{emailId:O??String(A),showId:a,targetShowToken:c}),re(n.signal);const u=await this._dataSources.emails.get(String(A)),g=ge(this._container),k={id:a,token:c};if(r){Tn(this._container);const I=g.suspendedDocument()?.get().serverId;!m&&O!==void 0&&I!=null&&String(I)===String(O)&&g.resumeSuspended()}O===void 0?b=g.startNewDraft(u??D,{patch:D,show:k}):m?b=g.reload(O,{email:u??D,patch:D,show:k}):g.sessionKey()===ut(O)?b=g.show(D,k):b=g.open(O,{email:u??D,patch:D,show:k}),g.beginShowFill(a);const M=!!this._prevCommand&&Fe(this._prevCommand,R);R.id,!this._prevCommand||Fe(this._prevCommand,R),this._prevCommand?.id,this._rememberShow(R),h=n.requestShow({showId:a,navId:String(A),emailId:O,isNew:O===void 0}),v=!0;const _=()=>g.endShowFill(a);Promise.allSettled([h,b.whenReady()]).then(_),String(A),l=!0}catch(w){d=w,v&&a&&n.failShow(a,w),a&&xe(this._container)?.endShowFill(a),Lo(w)||(Ja(w),void 0)}finally{this._eventLock.resumeChange()}if(!l)throw d instanceof Error?d:new Error(`[emailmaker] show() setup failed: ${String(d??"unknown error")}`);return rt("show-init-deferred",Promise.all([h,b?.whenReady().catch(w=>{if(w instanceof at){const C=ei(w);throw C?new Error(`[emailmaker] show(): email open failed (${C})`,{cause:w}):w}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:s??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:i,reload:s}=oy(e),a=Ce();let c=!1;try{await this.setBlocks(o),re(t.signal),s&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const l=n.id!==void 0&&n.id!==""?String(n.id):void 0,d=ge(this._container);if(!s&&l!==void 0&&d.sessionKey()===Ln(l)){const T=Pr(n)?await this._storeShownBlock(n):void 0,B={id:a,token:++this._showToken},D=d.show(T,B),O=t.requestShow({showId:a,navId:l,emailId:void 0,isNew:!1});c=!0,await rt("show-block-init",Promise.all([O,D?.whenReady().catch(()=>{})]),{showId:a});return}const h=r||s?await Ds(this._container,String(n.id)):void 0,b=h&&(s||Pr(n))?await this._storeShownBlock({..._e(h,this._container),...n}):r||s?h:await this._storeShownBlock(n);if(re(t.signal),!b)throw new Error(`[emailmaker] show(): block ${String(n.id)} not found`);i!==void 0&&b.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(i.filter(T=>T.id!==void 0).map(T=>[T.id,kn(T,String(b.id))])),this._prevCommand=void 0,this._lastShow=void 0;const v=b.id!==void 0?String(b.id):Ce(),w={id:a,token:++this._showToken};Tn(this._container);const C=s?d.reloadBlock(v,b,w):d.openBlock(v,b,w);b.id;const y=t.requestShow({showId:a,navId:v,emailId:void 0,isNew:b.id===void 0});c=!0;const S=C.whenReady().catch(T=>{if(T instanceof at)throw T});await rt("show-block-init",Promise.all([y,S]),{showId:a})}catch(l){throw c&&t.failShow(a,l),l}}async _storeShownBlock(e){const t=ot(e,this._container,await Nt(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();re(e.signal);const t=ge(this._container);if(ne(t.sessionKey())&&!t.hasSuspended())throw new Error("[emailmaker] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:kr,fallbackTitle:Hc(this._container)});if(re(e.signal),!n)throw Fy(t.emailSaveState().error);return Se(Pl(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=ge(this._container),t=e.current();if(!t||!ne(e.sessionKey()))throw new Error("[emailmaker] saveBlock(): no open block");return Gf(t,async()=>{await t.whenReady();const n=rr(t),r=t.get().version,o=t.get().serverId,i=typeof n.global_block=="boolean"?n.global_block:o!=null&&Ml(n.html??"").emBlockId===String(o),s=o!=null&&i?Ll(n.html,String(o),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:s,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},c=this._dataSources.blocks,l=await Ny(this._container,t.get().serverId,a.html),d=t.get().serverId==null?c.create(a,{source:kr}):c.update(String(t.get().serverId),a,{source:kr}),h=await cy(this._container,d,b=>{b&&l(),b&&ge(this._container).current()===t&&t.get().serverId==null&&b.id!==void 0&&t.markSaved(r,String(b.id))});if(!h)throw new Error("[emailmaker] save(): block was not saved");return l(),t.markSaved(r,h.id!==void 0?String(h.id):void 0),_e(h,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=xs(e);const n=this._queuedShow(e,t).then(r=>r===Vs?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),re(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=ge(this._container);if(n!==void 0&&r.sessionKey()===Ln(n))return;const o=t.code===void 0&&n!==void 0?await Ds(this._container,n):void 0,i=o&&Pr(t)?await this._storeShownBlock({..._e(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!i)throw new Error(`[emailmaker] openBlock(): block ${String(n)} not found`);Tn(this._container);const s=r.openBlockOver(i.id!==void 0?String(i.id):Ce(),i);i.id,r.hasSuspended(),me(this._container,$.ON_BLOCK_OPEN_ID).fire({block:i}),await s.whenReady().catch(a=>{if(a instanceof at)throw r.current()===s&&(me(this._container,$.ON_BLOCK_CLOSE_ID).fire({block:i,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),mg(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function Uy(e){if(e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object")return e.meta;const t=e.catalogExtra?.meta;if(t!=null&&typeof t=="object")return t}function Hy(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),o=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:o,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Uy(e)}}function Dr(e,t){return t?Hy(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Fl=["title","slug","type","tags","blocktags","modified","author","lock","subject","description","excerpt","status","is_template","link","renderGuid","date","date_gmt","modified_gmt","comment_status","ping_status","template","related_email","project_title","project_author","isAmp","meta"],$y=[...Fl,"html","id","project","password"],ZI=new Set(["html",...Fl,"global_block","project"]);function Vy(e){if(!e||typeof e!="object")return{};const t={};e.id!=null&&e.id!==""&&(t.id=String(e.id)),e.title!=null&&e.title!==""&&(t.title=e.title),e.slug!=null&&e.slug!==""&&(t.slug=e.slug),e.type!=null&&e.type!==""&&(t.type=e.type),e.tags!=null&&(t.tags=e.tags),e.blocktags!=null&&(t.blocktags=e.blocktags),e.modified!=null&&e.modified!==""&&(t.modified=e.modified),e.author!=null&&e.author!==""&&(t.author=String(e.author)),e.lock!=null&&(t.lock=e.lock),e.subject!=null&&e.subject!==""&&(t.subject=e.subject),e.description!=null&&e.description!==""&&(t.description=e.description),e.excerpt!=null&&e.excerpt!==""&&(t.excerpt=e.excerpt),e.status!=null&&e.status!==""&&(t.status=e.status),e.is_template!=null&&(t.is_template=e.is_template),e.link!=null&&e.link!==""&&(t.link=e.link),e.renderGuid!=null&&e.renderGuid!==""&&(t.renderGuid=e.renderGuid),e.date!=null&&e.date!==""&&(t.date=e.date),e.date_gmt!=null&&e.date_gmt!==""&&(t.date_gmt=e.date_gmt),e.modified_gmt!=null&&e.modified_gmt!==""&&(t.modified_gmt=e.modified_gmt),e.comment_status!=null&&e.comment_status!==""&&(t.comment_status=e.comment_status),e.ping_status!=null&&e.ping_status!==""&&(t.ping_status=e.ping_status),e.template!=null&&e.template!==""&&(t.template=e.template),e.related_email!=null&&e.related_email!==""&&(t.related_email=e.related_email),e.project_title!=null&&e.project_title!==""&&(t.project_title=e.project_title),e.project_author!=null&&e.project_author!==""&&(t.project_author=e.project_author),e.isAmp!=null&&(t.isAmp=e.isAmp),e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object"&&(t.meta=e.meta);const n=new Set($y),r={};for(const o of Object.keys(e))n.has(o)||(r[o]=e[o]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function qy(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Vy(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var Io=new WeakMap;function Gy(e){let t=Io.get(e);return t||(t={byId:new Map,fallback:[]},Io.set(e,t)),t}function Wy(e){Io.delete(e)}function zy(e,t){const{byId:n,fallback:r}=Gy(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const i=r.indexOf(o);return i>=0&&r.splice(i,1),o}return}for(let o=r.length-1;o>=0;o--){const i=r[o],s=e.name!=null&&e.name!==""&&i.name!=null&&i.name!==""&&i.name===e.name,a=e.type!=null&&e.type!==""&&i.insertFrom===e.type;if(s&&a)return r.splice(o,1),i.id!=null&&i.id!==""&&n.delete(String(i.id)),i}}async function Ky(e,t){const{blocks:n}=cn(e);return await n.cache.getIfPresent(t)??void 0}async function Yy(e,t){if(!t.blockId)return;const n=await Ky(e,t.blockId);if(n)return qy(n,t)}async function Xy(e,t){const n=zy(e,t);if(n)return Dr(e,n);const r=await Yy(t,e);return r?Dr(e,r):Dr(e,void 0)}var Jy=xa("application_block_inserted"),Qy=-1e3,qs=new WeakSet;function Zy(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.type=="string"||typeof t.name=="string"||typeof t.blockId=="string"||typeof t.project=="string"||typeof t.project=="number"}function e_(e){if(!e||qs.has(e))return;qs.add(e);const t=new pe,n=he(e);return t.addDisposable(n.addListenerAsyncPipe(Jy,async(r,o)=>{const i=Zy(r)?await Xy(r,e):r;return o?o(i):i},Qy)),t.addDisposable({dispose:()=>{Wy(e)}}),t}var t_=nr("plugin.readBlockAutosave"),eC=H("blockDocuments.provided"),Bl=H("plugin.earlyWindow");function n_(e){return e.getOrCreateInstance(Bl,()=>({depth:0}))}function r_(e){const t=n_(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function jl(e){return(e?.getInstance(Bl)?.depth??0)>0}function Ul(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,i,s)=>{const a=e(o,i,s);if(r&&jl(t)){const c=n;queueMicrotask(()=>{o.call(s,c)})}return a}}var xr=100,o_=class extends pe{_container;_events;constructor(e){super(),this._container=e;const t=e_(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:i}=cn(e),s=te(e,$.ON_SHARE_ID),a=te(e,$.ON_SHOW_PREVIEW_ID),c=te(e,$.ON_EMAIL_CLONE_ID),l=te(e,$.ON_BLOCK_OPEN_ID),d=te(e,$.ON_BLOCK_CLOSE_ID),h=te(e,$.ON_BLOCK_CLONE_ID),b=te(e,$.ON_BLOCK_INIT_ID),v=te(e,$.ON_BLOCK_CHANGED_ID),w=te(e,$.ON_CODE_VALIDATE_ID),C=te(e,$.ON_IMPORT_VALIDATE_ID),y=te(e,$.ON_SUBJECT_CHANGED_ID),S=te(e,$.ON_EMAIL_CHANGED_ID),T=te(e,$.ON_PREHEADER_CHANGED_ID),B=te(e,$.ON_SAVEBUTTON_CLICK_ID),D=te(e,$.ON_BLOCK_SAVEBUTTON_CLICK_ID),O=te(e,$.ON_NEXTBUTTON_CLICK_ID),A=te(e,$.ON_SEND_LIVEPREVIEW_ID),x=te(e,$.ON_SEND_TESTEMAIL_ID),R=te(e,ey),m=te(e,$.ON_CONTENT_CHANGED_ID),f=te(e,Zb),u=te(e,$.ON_PREVIOUSBUTTON_CLICK_ID),g=te(e,$.ON_SEND_EMAIL_MODAL_ID),k=Xd(te(e,$.ON_EMAIL_INIT_ID),_=>!_.reset),M=te(e,$.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:V(T),handleSubjectChanged:V(y),handleValidate:V(w),handleImportValidate:V(C),handleReadEmail:V(n.handlerRead,_=>_,_=>_&&At(_,e)),handleSaveEmail:V(n.onSave,function({prev:_,patch:I,value:F,source:j}){const K=_?Se(_,e):void 0;return{prev:K,patch:Vt(K,Se(I,e)),value:Se(F,e),source:j}},_=>_?At(_,e):void 0),handleRemoveEmail:V(n.onRemove,({value:_,source:I})=>({value:Se(_,e),source:I}),()=>{}),handleReadCommonBlocks:V(R,_=>_.project,_=>_?.map(I=>ot(I,e))),handleReadTemplateBlocks:V(f,_=>_,_=>_?.map(I=>ot(I,e))),handleReadBlocks:V(t.byForeignKey("project").handleRead,_=>an(e).requested||String(_),_=>_?.map(I=>ot(I,e))),handleReadBlock:V(t.handlerRead,_=>_,_=>_?ot(_,e):void 0),handleOpenBlock:V(l,({block:_})=>({block:_e(_,e)})),handleCloseBlock:V(d,({block:_,hasUnsavedChanges:I})=>({block:_e(_,e),hasUnsavedChanges:I})),handleCloneBlock:V(h,_=>_e({..._,html:vy(_.html)},e)),handleSaveBlock:V(t.onSave,function({prev:_,patch:I,value:F,source:j}){const K=F.global_block===!0&&F.id&&typeof F.html=="string"?{...F,html:by(F.html,String(F.id))}:F,de=_?_e(_,e):void 0;return{prev:de,patch:Vt(de,_e(I,e)),value:_e(K,e),source:j}},_=>_?ot(_,e):void 0),handleRemoveBlock:V(t.onRemove,({value:_,source:I})=>({value:_e(_,e),source:I}),()=>{}),handleReadComments:V(r.byForeignKey("post").handleRead,_=>_,_=>_?.map(I=>Eo(I,e))),handleSaveComment:V(r.onSave,function({prev:_,patch:I,value:F,source:j}){const K=_?Ft(_,e):void 0;return{prev:K,patch:Vt(K,Ft(I,e)),value:Ft(F,e),source:j}},_=>_?Eo(_,e):void 0),handleRemoveComment:V(r.onRemove,({value:_,source:I})=>({value:Ft(_,e),source:I}),()=>{}),handleReadEmailRevisions:V(o.byForeignKey("parent").handleRead,_=>_,_=>_?.map(I=>On(I,e))),handleReadEmailAutosave:V(te(e,El),_=>_,_=>_?On(_,e):null),handleEmailAutosave:V(o.onSave,function({prev:_,patch:I,value:F,source:j}){return{value:wo(F,e),source:j}},_=>_?On(_,e):void 0),handleRemoveEmailAutoSave:V(o.onRemove,({value:_,source:I})=>({value:wo(_,e),source:I}),()=>{}),handleReadBlockRevisions:V(i.byForeignKey("parent").handleRead,_=>_,_=>_?.map(I=>kn(I))),handleReadBlockAutosave:V(te(e,t_),_=>_,_=>_?kn(_):null),handleBlockAutosave:V(i.onSave,({value:_,source:I})=>({value:Ns(_),source:I}),_=>_?kn(_):void 0),handleRemoveBlockAutoSave:V(i.onRemove,({value:_,source:I})=>({value:Ns(_),source:I}),()=>{}),handleBlockInit:V(b,_=>_e(_,e)),handleBlockChanged:V(br(v,xr),_=>_e(_,e)),handleEmailChanged:V(br(S,xr),_=>Se(_,e)),handleEmailInit:Ul(V(k,_=>Se(_,e)),e),handlePreviousButtonClick:V(u,_=>Se(_,e)),handleNextButtonClick:V(O,_=>Se(_,e)),handleSaveButtonClick:V(B,_=>Se(_,e)),handleSaveBlockButtonClick:V(D,_=>_e(_,e)),handleHtmlChanged:V(br(m,xr)),handleTestEmailSend:V(x,({html:_,...I})=>({...I,code:_,compiled:{html:_,ampHtml:""}})),handleTestEmailModal:V(g,_=>Se(_,e)),handleCloneEmail:V(c,_=>Se(_,e)),handleShareEmail:V(s),handlePreviewEmail:V(a),handleLivePreviewEmail:V(A),handleAnalyticsEvent:V(M)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new bt(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},i_=H("DataController"),s_=H("DataEvents");function Hl(e){return e.getOrCreateInstance(i_,()=>{const t=new jy(e);return e.getInstance(W)?.addDisposable(t),t})}function $l(e){return e.getOrCreateInstance(s_,()=>new o_(e))}var a_=H("plugin.pluginStart");function Vl(e){return e.getOrCreateInstance(a_,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(W)?.addDispose(()=>t()),{done:n,finish:t}})}function c_(e){return Vl(e).done}function l_(e){const t=Vl(e);return t.run===void 0&&(t.run=(e.getInstance($o)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var d_=H("plugin.startupShow");function u_(e){const t=Hl(e),n=$l(e),r=e.getInstance(ye),o=e.getInstance(W),i={current:Promise.resolve()};e.inject(d_,i);let s=!1;const a=r?.watch(l=>{l&&n.setOptions(l),s=(l?.plugins?.length??0)>0,i.current=i.current.catch(()=>{})}),c=r?.select(l=>l?.content).watch(l=>{if(l===void 0)return;const d=()=>(ie(ve.showStart),t.show(l).finally(()=>ie(ve.showEnd))),h=s?c_(e).then(d):d();h.catch(()=>{}),i.current=h});a&&o?.addDisposable(a),c&&o?.addDisposable(c)}function f_(e){const t=Hl(e);return{...$l(e).get(),show(n){return ie(ve.showStart),t.show(n).finally(()=>ie(ve.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return ie(ve.showStart),t.showBlock(n,r).finally(()=>ie(ve.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function ql(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function lr(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let i=t;i<e.length;i++){const s=e[i];if(o){o=!1;continue}if(s==="\\"){o=!0;continue}if(r){s===r&&(r="");continue}if(s==='"'||s==="'"){r=s;continue}if(s==="("){n++;continue}if(s===")"&&(n--,n<0))return!1}return n===0}function p_(e){return(t,n,r)=>lr(t)?e(t,n,r):!1}function h_(e){return t=>lr(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function m_(e){return(t,n,r)=>lr(t)?ql(t)?e(t,n,r):t:!1}function g_(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return lr(n)?ql(n)?e(t):t:!1}}function v_(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function vi(e,t){const n=e.length;for(let r=0;r<n;r++){const o=e.charCodeAt(r);if(o===0||t==='"'&&o===34||t==="'"&&o===39||t===""&&(o===32||o===9||o===10||o===13||o===12||o===34||o===39||o===60||o===62||o===61||o===96))return!1}return!0}function b_(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let i=0;i<e;i++){const s=r[i]%62;o+=t.charAt(s)}return o}var y_=8,__=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=b_(y_),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},dr=new __;function Gs(e,t){return t!==void 0&&!vi(e,t)?`%|{${dr.getOrCreateByKey(e)}}|%`:e}function E_(e){const t=dr.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function le(e,t,n){return t!==void 0?vi(e,t)?e:`%|{${dr.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function w_(e){return e.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function ae(e){return e.startsWith("<!--")&&e.endsWith("-->")?w_(e.slice(4,-3)):e}function S_(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const o=e.match(/\[%\s*([^%]*?)\s*%\]/);o&&(r=o[1]);const i=r.trim();return t.test(i)||n.test(i)}function I_(e,t,n){return t!==void 0?vi(e,t)?e:`%|{${dr.getOrCreateByKey(e)}}|%`:n||v_(e)||S_(e)?`<!--${e}-->`:e}var Qe=p_(le),Ze=h_(ae),C_=m_(le),A_=g_(ae),Gl=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",E_),e.escape("@{","}",le,!0).unescape("<!--@{","}-->",ae,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Gs,!0),e.escape("{{","}}",Gs,!0),e.createSyntax("brace-percent").escape("{%","%}",le).unescape("<!--{%","%}-->",ae),e.createSyntax("brace-hash").escape("{#","#}",le).unescape("<!--{#","#}-->",ae),e.createSyntax("proscript").escape("[%","%]",I_,!0).unescape("<!--[%","%]-->",ae,!0),e.createSyntax("getresponse").escape("[[IF","]]",le).escape("[[if","]]",le).escape("[[ELSE]]","",le).escape("[[else]]","",le).escape("[[ENDIF]]","",le).escape("[[endif]]","",le).unescape("<!--[[IF","]]-->",ae).unescape("<!--[[if","]]-->",ae).unescape("<!--[[ELSE]]","-->",ae).unescape("<!--[[else]]","-->",ae).unescape("<!--[[ENDIF]]","-->",ae).unescape("<!--[[endif]]","-->",ae),e.createSyntax("expert-sender").escape("<if",">",le).escape("</if",">",le).escape("<else",">",le).escape("</else",">",le).escape("<var ",">",le,!0).unescape("<!--<if ",">-->",ae).unescape("<!--</if",">-->",ae).unescape("<!--<else ",">-->",ae).unescape("<!--</else",">-->",ae).unescape("<!--<var",">-->",ae,!0),e.createSyntax("velocity").escape("#if",")",Qe).escape("#elseif",")",Qe).escape("#else","",le).escape("#foreach",")",Qe).escape("#macro",")",Qe).escape("#set",")",C_,!0).escape("#parse",")",Qe).escape("#include",")",Qe).escape("#evaluate",")",Qe).escape("#end","",le).escape("#break","",le).escape("#stop","",le).unescape("<!--#macro","-->",Ze).unescape("<!--#if","-->",Ze).unescape("<!--#elseif","-->",Ze).unescape("<!--#else","-->",ae).unescape("<!--#foreach","-->",Ze).unescape("<!--#parse","-->",Ze).unescape("<!--#include","-->",Ze).unescape("<!--#evaluate","-->",Ze).unescape("<!--#end","-->",ae).unescape("<!--#break","-->",ae).unescape("<!--#stop","-->",ae).unescape("<!--#set","-->",A_,!0),e.createSyntax("mailchimp").escape("*|","|*",le).unescape("<!--*|","|*-->",ae)},Co="bare",T_=new Map;function R_(e){return e?T_.get(e)??Co:Co}var Wl=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function Ws(e){return Wl.includes(e)}function Dt(e){return e==="bare"||e==="html-comment"}function Mr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function O_(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!Dt(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[l,d]of[["output",r.output],["editor",r.editor]])if(d!==void 0&&!Dt(d))return t(`templateDirectives.${l}: unknown form "${String(d)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!Mr(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[l,d]of Object.entries(r.syntaxes))if(!(!Ws(l)||d===void 0||Dt(d))){if(!Mr(d))return t(`templateDirectives.syntaxes.${l}: expected a form or an object, configuration ignored.`),n;for(const h of["output","editor"]){const b=d[h];if(b!==void 0&&!Dt(b))return t(`templateDirectives.syntaxes.${l}.${h}: unknown form "${String(b)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??Co;let i=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),i=void 0);const s=[];if(r.syntaxes)for(const l of Object.keys(r.syntaxes)){if(!Ws(l)){t(`templateDirectives.syntaxes: unknown syntax id "${l}", entry ignored.`);continue}s.push(l)}else s.push(...Wl);const a={},c={};for(const l of s){const d=r.syntaxes?.[l],h=Mr(d)?d:void 0,b=(Dt(d)?d:h?.output)??o;let v=h?.editor??i??b;b==="bare"&&v==="html-comment"&&(t(`templateDirectives.syntaxes.${l}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),v="bare"),a[l]=b,c[l]=v}return{output:a,editor:c}}function zl(e,t,n,r){for(let o=t;o<n;o++){const i=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?i===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(i)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):i==="<"?r.insideTag=!0:i===">"?r.insideTag=!1:r.insideTag&&(i==='"'||i==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=i,r.unquotedAttr=!1):r.insideTag&&/\S/.test(i)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(i)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function Bt(e,t){return e.start<t.end&&t.start<e.end}function zs(e,t,n,r,o=[]){if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return[];const i=t.flatMap(d=>d.match(e).flatMap(h=>!Number.isInteger(h.start)||!Number.isInteger(h.end)||h.start<0||h.end>e.length||h.start>=h.end?[]:[{range:h,mapFn:d.mapFn,overrideBuiltins:d.overrideBuiltins,syntax:d.syntax,isVariable:d.isVariable}])).sort((d,h)=>d.range.start-h.range.start||d.range.end-h.range.end),s=[],a=o.slice().sort((d,h)=>d.start-h.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(const{range:d,mapFn:h,overrideBuiltins:b,syntax:v,isVariable:w}of i){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):zl(e,l,d.start,c),l=d.end,a.some(T=>Bt(T,d)))continue;const C=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,y=e.substring(d.start,d.end),S=h(y,C,c.insideTag);S!==!1&&S!==y&&(s.push({range:d,text:S,overrideBuiltins:b,syntax:v,isVariable:w}),a.push(d))}return s.sort((d,h)=>d.range.start-h.range.start||d.range.end-h.range.end)}function k_(e,t){const n=t.reduce((a,{mapFn:c,start:l,end:d,syntax:h,isVariable:b})=>(a[l]||(a[l]=[]),a[l].push({value:d,mapFn:c,syntax:h,isVariable:b}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),i=[];let s;for(;(s=o.exec(e))!==null;){const a=s[0];i.push({start:s.index,startToken:a,endTokens:n[a]})}return i}function Lr(e,t,n,r,o=!1){const i=[];if(n&&(t=t.filter(l=>l.isVariable)),!t.length)return i;const s=k_(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let l=0;l<s.length;l++){const{start:d,startToken:h,endTokens:b}=s[l];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):zl(e,c,d,a),c=d;const v=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let w=!1;for(const{mapFn:C,value:y,syntax:S,isVariable:T}of b){let B=d+h.length,D=e.indexOf(y,B);for(;D!==-1;){let O=D,A=d+h.length,x=0;for(;O!==-1;){const g=e.indexOf(h,A);if(g!==-1&&g<O)x++,A=g+h.length,O=e.indexOf(y,A);else if(x>0)x--,A=O+y.length,O=e.indexOf(y,A);else break}if(O<0)break;const R=O+y.length,m=e.substring(d,R),f=C(m,v,a.insideTag);if(f===!1){B=D+Math.max(y.length,1),D=e.indexOf(y,B);continue}(o||f!==m)&&i.push({range:{start:d,end:R},text:o?m:f,syntax:S,isVariable:T});const u=s.findIndex(({start:g})=>g>=R);u>l?l=u-1:l=s.length,w=!0;break}if(w)break}}return i}function En(e,t){if(!t.length)return e;const n=t.slice().sort((o,i)=>i.range.start-o.range.start);let r=e;for(const{text:o,range:i}of n)r=r.slice(0,i.start)+o+r.slice(i.end);return r}var P_=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=Gl){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,i,s){return t.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this},unescape(r,o,i,s){return n.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let o=!1;const i={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(s=>s!==n),this._unescapeMatchers=this._unescapeMatchers.filter(s=>s!==r))}};return this.addDisposable(i),i}_collectMappings(e,t,n){const r=Lr(e,this._escapes,t,n),o=zs(e,this._escapeMatchers,t,n),i=o.filter(c=>c.overrideBuiltins).map(c=>c.range),s=r.filter(c=>!i.some(l=>Bt(l,c.range))),a=o.filter(c=>c.overrideBuiltins||!s.some(l=>Bt(c.range,l.range)));return[...s,...a].sort((c,l)=>c.range.start-l.range.start||c.range.end-l.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=Lr(e,this._unescapes,t),r=zs(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),i=n.filter(a=>!o.some(c=>Bt(c,a.range))),s=r.filter(a=>a.overrideBuiltins||!i.some(c=>Bt(a.range,c.range)));return[...i,...s].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>R_(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return Lr(e,this._escapes,t,n,!0)}getEscapedText(e,t){return En(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return En(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=i=>i===void 0?void 0:t[i],r=Object.values(t);let o=e;return r.includes("bare")&&(o=En(o,this._collectRevertMappings(o).filter(i=>n(i.syntax)==="bare"))),r.includes("html-comment")&&(o=En(o,this._collectMappings(o).filter(i=>!i.isVariable&&n(i.syntax)==="html-comment"&&i.text.startsWith("<!--")&&i.text.endsWith("-->")))),o}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}},Kl="em___script",jt=`<${Kl}`,Ao=`</${Kl}>`;function Ks(e){return e.replace("<script",jt).replace("<\/script>",Ao)}var Ys=new P_(e=>{e.escape("<script","<\/script>",t=>Ks(t)).unescape(jt,Ao,t=>t.replace(jt,"<script").replace(Ao,"<\/script>")),e.escape("<script","/>",t=>Ks(t)).unescape(jt,"/>",t=>t.replace(jt,"<script")),Gl(e)});function D_(e){const t=O_(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return cc();const n=new Set(Object.keys(t.output).filter(o=>t.output[o]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:o=>Ys.normalizeToPolicy(o,t.editor),toOutputForm:o=>Ys.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:ac(r)}}function x_(e){let t;e.injectFactory(Uo,()=>{const n=e.getInstance(be)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:D_(n)}),t.policy})}var M_=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function L_(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const o=t.get(r)??[];o.push(n),t.set(r,o)}return t}function N_(e,t){const n=[];for(const r of e.awaits?.services??[])for(const o of t.get(r)??[])o!==e&&n.push(o);return n}function Yl(e){const t=L_(e),n=[],r=new Set,o=[],i=new Set,s=a=>{if(!r.has(a)){if(i.has(a)){const c=o.indexOf(a);throw new M_([...o.slice(c),a].map(l=>l.name))}i.add(a),o.push(a);for(const c of N_(a,t))s(c);o.pop(),i.delete(a),r.add(a),n.push(a)}};for(const a of e)s(a);return n}var F_=[{name:"rest.client",setup:Yb},{name:"auth.oauth",setup:Eu},{name:"rest.identityHeaders",setup:Bb},{name:"rest.localeHeader",setup:qb},{name:"lifetime.destroyable",provides:[ui],setup:Hv},{name:"appInit",provides:[We,Go],setup:ef},{name:"config",provides:[be],setup:jv},{name:"templateDirectives",provides:[Uo],setup:x_},{name:"email.documents",setup:sb},{name:"show.initPipeline",provides:[Pe],setup:Xb},{name:"show",setup:u_},{name:"locale.service",provides:[Ct],setup:Mb},{name:"locale.fromConfig",awaits:{services:[be,Ct]},setup:Lb},{name:"canvas.early",setup:Mg},{name:"canvas.previewSettings",setup:Xg},{name:"canvas.sandboxExtensions",setup:Qg},{name:"canvas.sandboxScriptRelay",setup:tv},{name:"canvas.headerSync",provides:[li],setup:Fg},{name:"canvas.headersAfterRecovery",setup:Bg},{name:"canvas.ampSync",setup:xh},{name:"canvas.moduleBridge",setup:dm},{name:"canvas.port",setup:Vh},{name:"canvas.images",setup:Hh},{name:"canvas.edits",setup:Dg},{name:"canvas.surfaceFollowsSession",setup:vg},{name:"canvas.blockContent",setup:gg},{name:"canvas.sandboxFill",provides:[ci],setup:yv},{name:"canvas.reactions",setup:xg}],Xs;function bi(e){const t=e.getInstance(ye);if(t)return t;e.getInstance(W)||e.inject(W,new pe);const n=ue();e.inject(ye,n),Xs??=Yl(F_);for(const r of Xs)r.setup(e);return n}function B_(e){}var j_=[{name:"save.previewFollow",setup:B_}],Js=H("plugin.lateUnitsInstalled");function U_(e){if(!e.getInstance(Js)){e.inject(Js,!0);for(const t of Yl(j_))t.setup(e)}}function H_(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function $_(e){if(!e)return;const t=Fo(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(r=>typeof r=="string"?r.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(r=>/^project_\d+$/.test(r))?.replace(/^project_/,"")||void 0}var V_=Rt(e=>{let t,n,r;return{async setOptions(o){const i=r!==o.getAuthToken,s=!Fe(t,o.user),a=n!==o.project;if(r=o.getAuthToken,t=o.user,n=o.project,!(!e.getInstance(Be)||!o.getAuthToken)&&!(!i&&!s&&!a))try{const c=await o.getAuthToken(o.user,o.project);e.inject(wu,Promise.resolve(c||""));const l=$_(c);if(!l)return;e.inject(Fd,l);const d=e.getInstance(We),h=d?await d.catch(()=>{}):void 0;e.inject(We,Promise.resolve(H_(l,h)))}catch{}}}});function q_(e,t){if(e.getInstance(Ri))return;e.inject(Ri,!0);const n=Ie(e,$.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var G_=Rt(e=>{let t,n=!1;return{setOptions(r){const o=n;if(n=!0,!on(r)){t&&(Tv(e),di(r)),t=void 0;return}const i=ir(r);if(!i||t===i&&e.getInstance(Be))return;t=i,e.inject(Be,i);const s=e.getInstance(W);s&&q_(e,s)}}}),W_=Rt(e=>{const t=e.getInstance(W),n=Ie(e,La),r=V(n),o=t.addDisposable(new bt(r));return{setOptions({handleLoad:i}){o.setListener(i)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function Xl(e,t,n=!0){const r=e,o=t;for(const i of Object.keys(o)){const s=o[i];s!=null&&(n&&typeof s=="object"?r[i]=Xl(r[i]||{},s,!0):r[i]=s)}return e}async function z_(e){const t=(await Cu(()=>import("./static/esm/2490dab8.js").then(n=>Pd(n.default)),[],import.meta.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var Jl=H("EditorOptions"),To=uu;function K_(e){const t=typeof e.font_family=="string"?`${e.font_family}, sans-serif`:void 0,n=e.word_wrap===void 0?void 0:e.word_wrap?"on":"off";return{tabSize:e.tab_size,fontFamily:t,fontSize:e.font_size,wordWrap:n,insertSpaces:e.insert_spaces,minimap:{enabled:e.minimap}}}function Y_(e){return e.getOrCreateInstance(Jl,()=>{const t=ue(To);let n=To.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(z_(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function X_(e){return e?.getInstance(Jl)?.get()??To}function J_(e,t={}){const n=Y_(e);n.set(Xl({...n.get()},K_(t)))}function Q_(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function Z_(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var eE=H("plugin.publicConfig");function Ro(e){return e.getInstance(be)?.get()??{}}function Qs(e){return e.getInstance(be)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function Zs(e){const t=fl(e),n=Ro(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:Z_(X_(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function ea(e){return e.getInstance(be)?.get()!==void 0}function tE(e){const t=Da(),n=me(e,Ma);let r,o,i=!1;const s=async()=>{try{return e.getInstance(We)===void 0?{}:(await e.getInstanceAsync(We))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:h=!1}={})=>{await e.getInstance(be)?.ready(),Ha(e).set(Ro(e).revisionService===!0);const{codeModeDirection:b,editor:v}=Ro(e);v&&J_(e,Q_(v)),b!==void 0&&!(h&&b===o)&&(o=b,b==="none"?ho(e,!1):(ho(e,!0),Gg(e,b)))},c=async()=>{if(!ea(e))return;const h=Zs(e),b=JSON.stringify(h);b!==r&&(r=b,await n.fire(h))},l=async h=>{const b=e.getInstance(be),v={advancedConfigs:Qs(e).advancedConfigs,serverSide:await s(),user:h};b?.setAdvancedConfigs({...v.advancedConfigs,...v.user?.advancedConfigs});const w=b?.layers().user.mode;b?.replace(v.user?.mode===void 0&&w!==void 0?{...v.user,mode:w}:v.user,"user"),b?.replace(v.serverSide,"server"),await a(),await c()},d=h=>{const{commonStyles:b,...v}=h;return"commonStyles"in h&&zg(e,b===void 0?void 0:b),v};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:s,getConfig:()=>ea(e)?Zs(e):{},setConfig:t.decorate(async h=>{await l(d(h))}),updateConfig:t.decorate(async h=>{const b=d(h);await l({...Qs(e).user,...b})}),announceAssembled(){i||(i=!0,e.getInstance(be)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function Ql(e){return e.getOrCreateInstance(eE,()=>tE(e))}function nE(e){const t=Ql(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var rE=Rt(e=>{const t=e.getInstance(W),n=t.addDisposable(new Ge),r=t.addDisposable(new Ge),o=Qt(e,Ma),i=V(n.event),s=V(r.event),a=Ul(V(o.event),e),c=t.addDisposable(new bt(i)),l=t.addDisposable(new bt(s)),d=t.addDisposable(new bt(a));return{instance:{handleSetOptions:i,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(h){c.setListener(h.handleSetOptions),l.setListener(h.handleOptionsChanged),d.setListener(h.handleConfigChanged),Ql(e).announceAssembled(),await n.fire(h),await r.fire(h)},dispose(){}}}),Nr,Zl="core";function oE(){const e=window.__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Zl],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function iE(e){const t=window.__emailmaker__?.require?.warm;return typeof t!="function"?ln().then(()=>{}):t([Zl],e)}function ln(){return Nr===void 0&&(Nr=oE().then(e=>(Gt()&&e.installDiagnostics().catch(t=>{}),e))),Nr}var Fr=null,Br=null;async function sE(e){typeof e?.prefetch=="function"&&await e.prefetch()}function yi(){return Fr||(Fr=ln().then(()=>{})),Fr}function ed(e){return Br||(Br=sE(e)),Br}function aE(){return ed(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}function cE(){const e=typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function lE(e){return Promise.all([yi(),ed(e)]).then(()=>{})}function dE(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function ta(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>iE(t?{priority:t}:void 0)).then(()=>(ii(t?{priority:t}:void 0),n?yi():void 0)).catch(()=>{})}function uE(e){const t=dE(e);if(t==="eager")ta(e);else if(t==="idle"){const n=()=>ta(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var td="PluginRegistry";function fE(e=tu()){return e.getOrCreateInstance(td,()=>new xu)}var pE=new Mu(()=>fE());function Ae(e,t){try{t()}catch{}}var nd=Symbol.for("emailmaker.result");function rd(e){return Object.defineProperty(e,nd,{value:!0})}var Tt=(e=>rd({ok:!0,value:e})),ke=((e,t="")=>rd({ok:!1,error:{code:e,message:t}}));function hE(e){return typeof e=="object"&&e!==null&&e[nd]===!0}var et=e=>({optional:!1,...e}),wn={string:()=>et({kind:"string"}),number:()=>et({kind:"number"}),boolean:()=>et({kind:"boolean"}),enum:(...e)=>et({kind:"enum",values:e}),element:(...e)=>et({kind:"element",kinds:e}),array:e=>et({kind:"array",item:e}),object:e=>et({kind:"object",shape:e}),optional:e=>({...e,optional:!0})};function od(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ur(e,t,n){if(t===void 0)return e.optional?void 0:`"${n}" is required`;switch(e.kind){case"string":case"number":case"boolean":return typeof t===e.kind?void 0:`"${n}" must be a ${e.kind}`;case"enum":return e.values?.includes(t)?void 0:`"${n}" must be one of: ${e.values?.join(", ")}`;case"element":return t!==null&&(typeof t=="object"||typeof t=="string")?void 0:`"${n}" must be an element reference`;case"array":if(!Array.isArray(t))return`"${n}" must be an array`;for(let r=0;r<t.length;r+=1){const o=ur(e.item,t[r],`${n}[${r}]`);if(o)return o}return;case"object":return od(t)?id(e.shape,t,n):`"${n}" must be an object`}}function id(e,t,n){for(const[r,o]of Object.entries(e??{})){const i=ur(o,t[r],n?`${n}.${r}`:r);if(i)return i}}function mE(e,t,n){return e?ur(e,t,n):void 0}function gE(e,t){if(!e)return;const n=e;return n.kind!=="object"?ur(n,t,"arguments"):t!==void 0&&!od(t)?"arguments must be an object":id(n.shape,t??{},"")}var vE=Symbol.for("emailmaker.domView");function bE(e){return typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.$$typeof=="symbol"}function yE(e){return typeof e=="object"&&e!==null&&typeof e[vE]=="function"}function fr(e){const t={watch:e,select:n=>fr(r=>{let o=!1,i;return t.watch(s=>{const a=n(s);o&&Object.is(i,a)||(o=!0,i=a,r(a))})})};return t}function _E(e){return fr(t=>(t(e),{dispose:()=>{}}))}function EE(e,t){return fr(n=>{let r=!1,o=!1,i;const s=()=>{if(!r)return;const c=t();o&&Object.is(i,c)||(o=!0,i=c,n(c))},a=e.map(c=>c.watch(s));return r=!0,s(),{dispose:()=>a.forEach(c=>c.dispose())}})}function _t(e){let t;return e.watch(n=>{t=n}).dispose(),t}var wE=Symbol.for("emailmaker.platform.hostError");function st(e,t){return Object.defineProperty(ke(e,t),wE,{value:!0})}var SE={documentOpen:!1,selection:"none",codeMode:!1,readOnly:!1,headless:!1};function $n(e,t){if(!e)return!0;if("any"in e)return e.any.some(r=>$n(r,t));if("not"in e)return!$n(e.not,t);const n={...SE,...t};return Object.entries(e).every(([r,o])=>n[r]===o)}var IE=class{_facts;_owners;_entries=new Map;_list=ue([]);_disposed=!1;constructor(e,t){this._facts=e,this._owners=t}get commands(){return this._list}has(e){return this._entries.has(e)}register(e,t,n,r={}){if(this._disposed)return`${e.name}`,{dispose:()=>{}};const o=Object.keys(t);for(const a of o){const c=this._entries.get(a);if(c)throw new Error(`Command "${a}" is already registered by "${c.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(typeof n[a]!="function")throw new Error(`Command "${a}" of "${e.name}" has no handler.`)}const i=o.map(a=>({id:a,owner:e,declaration:t[a],handler:n[a],enabled:r[a]??_E(!0),pending:new Set}));i.forEach(a=>this._entries.set(a.id,a)),this._publish();let s=!1;return{dispose:()=>{s||(s=!0,this._remove(i))}}}disposeOwner(e){this._remove(Array.from(this._entries.values()).filter(t=>t.owner===e))}disposeAll(){this._disposed=!0,this._remove(Array.from(this._entries.values()))}get disposed(){return this._disposed}async run(e,t,n){if(this._disposed)return st("unavailable",`Command "${e}" is not available: the editor was destroyed.`);const r=this._entries.get(e);if(!r)return st("notInstalled",`Command "${e}" is not installed in this host.`);if(!$n(r.declaration.when,_t(this._facts)??{})||_t(r.enabled)===!1)return st("unavailable",`Command "${e}" is not available right now.`);const o=gE(r.declaration.args,t);if(o)return st("invalidArgs",`Command "${e}": ${o}.`);const i=new AbortController,s=new Promise(c=>{i.signal.addEventListener("abort",()=>c(ke("aborted",`Command "${e}" was cancelled.`)),{once:!0})});r.pending.add(i);const a={signal:i.signal,caller:n.caller,run:(c,l)=>this.run(c,l,{caller:"plugin"})};try{return await Promise.race([this._execute(r,t??{},a),s])}finally{r.pending.delete(i)}}visible(e){return EE([this._list,this._facts],()=>{const t=this._entries.get(e);return t!==void 0&&$n(t.declaration.when,_t(this._facts)??{})})}enabled(e){return fr(t=>{let n,r;const o=s=>{s!==r&&(r=s,t(s))},i=this._list.watch(()=>{n?.dispose();const s=this._entries.get(e);n=s?s.enabled.watch(o):void 0,s||o(!1)});return{dispose:()=>{i.dispose(),n?.dispose()}}})}info(e){const t=this._entries.get(e);return t&&na(t)}async _execute(e,t,n){try{const r=e.handler,o=()=>r(t,n),i=await(this._owners?this._owners.execute(e.owner,o):o());return hE(i)?i:Tt(i)}catch(r){return ke("internal",r instanceof Error?r.message:String(r))}}_remove(e){let t=!1;for(const n of e)this._entries.get(n.id)===n&&(this._entries.delete(n.id),t=!0),n.pending.forEach(r=>r.abort());t&&this._publish()}_publish(){this._list.set(Array.from(this._entries.values()).map(na))}};function na(e){const{title:t,description:n,icon:r}=e.declaration;return{id:e.id,owner:e.owner,title:t,description:n,icon:r}}function sd(e){const t=globalThis,n=Symbol.for(`emailmaker.platform.owner.${e}`);return t[n]??=Object.freeze({name:e})}var pr=sd("core"),ra=sd("unknown"),ad=Symbol.for("emailmaker.platform.builtInPlugin");function cd(e){return Symbol.for(`emailmaker.platform.builtInKey.${e}`)}function _i(e){return Object.entries(e).forEach(([t,n])=>{typeof n=="function"&&(Object.defineProperty(n,ad,{value:!0}),Object.defineProperty(n,cd(t),{value:!0}))}),e}function CE(e,t){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,cd(t))}function AE(e){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,ad)}function oa(e){return AE(e.constructor)}var TE=class{_owners=new WeakMap;_stack=[];_listeners=new Set;current(){return this._stack[this._stack.length-1]??ra}execute(e,t){const n=e===pr?ra:e;this._stack.push(n);try{return t()}finally{this._leave(n)}}onUnload(e){return this._listeners.add(e),{dispose:()=>this._listeners.delete(e)}}handle(e){const{plugin:t}=e;if(t)switch(e.type){case"init:enter":case"afterInit:enter":oa(t)||this._stack.push(this._ownerOf(t,e.name));break;case"init:leave":case"afterInit:leave":oa(t)||this._leave(this._ownerOf(t,e.name));break;case"dispose:start":{const n=this._owners.get(t);n&&(this._leave(n),this._owners.delete(t),Array.from(this._listeners).forEach(r=>r(n)));break}}}_ownerOf(e,t){let n=this._owners.get(e);return n||(n={name:t},this._owners.set(e,n)),n}_leave(e){const t=this._stack.lastIndexOf(e);t>=0&&this._stack.splice(t,1)}},Sn=["plugins"],RE={toolbar:{kind:"item",groups:["view","collaboration","document","plugins","primary"]},"menu:document":{kind:"item",groups:["document","plugins","access","danger"]},"menu:export":{kind:"item",groups:["formats","plugins","platforms"]},"menu:view":{kind:"item",groups:["preview","plugins","share"]},"menu:save":{kind:"item",groups:Sn},statusBar:{kind:"item",groups:["selection","document","plugins","collaboration"]},notices:{kind:"item",groups:Sn},sidebar:{kind:"view",groups:["content","collaboration","analysis","plugins","settings"]},dialog:{kind:"view",groups:Sn},documentSettings:{kind:"view",groups:Sn}},jr="plugins";function OE(e,t){const n=e.groups.indexOf(t);return n<0?e.groups.length:n}var kE=Symbol.for("emailmaker.viewHost"),Ur={dispose:()=>{}},PE=class{_deps;apiVersion="1.0";_locations=new Map(Object.entries(RE));_items=ue([]);_views=ue([]);_opened=ue([]);_viewById=new Map;_seq=0;_openedKey=0;_disposed=!1;constructor(e){this._deps=e,this._registerCoreCommands()}get opened(){return this._opened}registerLocation(e,t){if(this._locations.has(e))throw new Error(`Location "${e}" is already registered.`);return this._locations.set(e,t),{dispose:()=>{this._locations.get(e)===t&&this._locations.delete(e)}}}addItem(e,t){if(this._skipAfterDispose(e))return Ur;const n=this._itemLocation(t.location,"item",e);if(!n)return Ur;const r={seq:this._nextSeq(),owner:e,location:t.location,group:this._groupOf(n,t.group,t.location),order:t.order??0,item:t};return this._items.set([...this._items.get()??[],r]),{dispose:()=>this._removeItems(o=>o===r)}}addViews(e,t,n,r){if(this._skipAfterDispose(e))return Ur;const o=Object.keys(t);for(const s of o){const a=this._viewById.get(s);if(a)throw new Error(`View "${s}" is already registered by "${a.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(!bE(n[s])&&!yE(n[s]))throw new Error(`View "${s}" of "${e.name}" has no component; pass a React component or domView(renderer).`)}const i=[];for(const s of o){const a=t[s],c=this._itemLocation(a.location,"view",e);if(c){const l=this._groupOf(c,a.group,a.location);i.push({seq:this._nextSeq(),id:s,owner:e,location:a.location,group:l,order:a.order??0,declaration:a,renderer:n[s],editor:r})}}return i.forEach(s=>this._viewById.set(s.id,s)),this._views.set([...this._views.get()??[],...i]),{dispose:()=>this._removeViews(s=>i.includes(s))}}open(e,t){if(this._disposed)return Promise.resolve(ke("cancelled",`View "${e}" cannot open: the editor was destroyed.`));if(_t(this._deps.facts)?.headless)return Promise.resolve(st("unavailable",`View "${e}" cannot open: the editor has no interface.`));const n=this._viewById.get(e);if(!n)return Promise.resolve(st("notInstalled",`View "${e}" is not installed in this host.`));const r=mE(n.declaration.input,t,"input");return r?Promise.resolve(st("invalidArgs",`View "${e}": ${r}.`)):(this.close(e),new Promise(o=>{const i=new AbortController;let s=!1;const a=h=>{if(!s){s=!0;try{this._opened.set((this._opened.get()??[]).filter(b=>b!==d))}finally{i.abort(),o(h)}}},c=h=>a(Tt(h)),l={input:t,signal:i.signal,close:c};Object.defineProperty(l,kE,{value:this._viewHost(n)});const d={key:this._openedKey+=1,view:e,owner:n.owner,location:n.location,input:t,record:n,renderer:n.renderer,signal:i.signal,context:l,close:c,cancel:()=>a(ke("cancelled",`View "${e}" was closed without a result.`))};this._opened.set([...this._opened.get()??[],d])}))}viewLocation(e){return this._viewById.get(e)?.location}close(e){(this._opened.get()??[]).filter(t=>t.view===e).forEach(t=>t.cancel())}items(e){return this._items.select(t=>this._sorted(t,e))}get allViews(){return this._views}views(e){return this._views.select(t=>this._sorted(t,e))}disposeOwner(e){Ae("items",()=>this._removeItems(t=>t.owner===e)),Ae("views",()=>this._removeViews(t=>t.owner===e))}disposeAll(){this._disposed=!0,Ae("items",()=>this._removeItems(()=>!0)),Ae("views",()=>this._removeViews(()=>!0))}supports(e,t){switch(e){case"service":return t==="Commands"||t==="Ui";case"location":return this._locations.has(t);case"command":return this._deps.commands.has(t);case"view":return this._viewById.has(t)}}_sorted(e,t){const n=this._locations.get(t),r=o=>n?OE(n,o.group):0;return e.filter(o=>o.location===t).sort((o,i)=>r(o)-r(i)||o.order-i.order||o.seq-i.seq)}_itemLocation(e,t,n){const r=this._locations.get(e);if(!r)`${n.name}${e}`;else if(r.kind!==t){`${n.name}`,`${e}${r.kind}`;return}return r}_groupOf(e,t,n){return t===void 0?jr:e.groups.includes(t)?t:(`${n}${t}${jr}`,jr)}_nextSeq(){return this._seq+=1,this._seq}_removeItems(e){const t=this._items.get()??[];t.some(e)&&this._items.set(t.filter(n=>!e(n)))}_removeViews(e){const t=this._views.get()??[],n=t.filter(e);if(n.length!==0){n.forEach(r=>this._viewById.delete(r.id));try{this._views.set(t.filter(r=>!e(r)))}finally{(this._opened.get()??[]).filter(r=>n.includes(r.record)).forEach(r=>Ae(`close ${r.view}`,()=>r.cancel()))}}}_skipAfterDispose(e){return this._disposed&&(`${e.name}`,void 0),this._disposed}_viewHost(e){return{run:(t,n)=>this._deps.commands.run(t,n,{caller:"ui"}),editor:e.editor}}_registerCoreCommands(){this._deps.commands.register(pr,{"ui.openView":{title:"Open view",args:wn.object({view:wn.string()}),agent:!0},"ui.closeView":{title:"Close view",args:wn.object({view:wn.string()}),agent:!0}},{"ui.openView":e=>this.open(e.view,e.input),"ui.closeView":e=>(this.close(e.view),Tt())})}};function DE(){return ue({})}function xt(e,t){const n=e.get()??{};Object.keys(t).some(r=>n[r]!==t[r])&&e.set({...n,...t})}var xE=H("platform.ownerTracker"),ME=H("platform.whenFacts"),LE=H("platform.commandRegistry"),NE=H("platform.uiService");function dn(e){return e.getOrCreateInstance(xE,()=>{const t=new TE;return t.onUnload(n=>{Ae("commands",()=>Ne(e).disposeOwner(n)),Ae("ui",()=>mr(e).disposeOwner(n))}),t})}function hr(e){return e.getOrCreateInstance(ME,DE)}function FE(e){const{isDisposed:t}=e;return typeof t=="function"&&t.call(e)}function ld(e){return e.getOrCreateInstance(LE,()=>new IE(hr(e),dn(e)))}function BE(e){return e.getOrCreateInstance(NE,()=>(dn(e),new PE({commands:ld(e),facts:hr(e)})))}function dd(e){const t=ld(e),n=BE(e);return!t.disposed&&FE(e)&&(Ae("ui",()=>n.disposeAll()),Ae("commands",()=>t.disposeAll())),{registry:t,ui:n}}function Ne(e){return dd(e).registry}function mr(e){return dd(e).ui}function jE(e){const t=Ne(e),n=mr(e);return{dispose:()=>{Ae("ui",()=>n.disposeAll()),Ae("commands",()=>t.disposeAll())}}}function UE(e,t){const n=dn(e);return t.onLifecycle(r=>n.handle(r))}var HE=["Commands","Ui"];function $E(e,t){for(let n=e;typeof n=="function";n=Object.getPrototypeOf(n))if(CE(n,t))return!0;return!1}function VE(e,t){if(!$E(t,e)){const n=typeof t=="function"?t.name||"anonymous":typeof t}}function qE(e){const t=HE.map(n=>e.on(n,r=>VE(n,r)));return{dispose:()=>t.forEach(n=>n.dispose())}}var ia=new WeakMap,sa=new WeakSet;function GE(e,t,n){const r=e.getInstance(W);if(r?.isDisposed()){Ae("ui",()=>mr(e).disposeAll()),Ae("commands",()=>Ne(e).disposeAll());return}ia.get(e)?.dispose();const o=new pe([UE(e,t),qE(n)]);ia.set(e,o),r?.addDisposable(o),r&&!sa.has(e)&&(sa.add(e),r.addDisposable(jE(e)))}function WE(e){return e?.lockEditor===!0}var aa={text:"text",img:"image",a:"link",button:"button",div:"container",vindent:"spacer",video:"video",table:"table",customTable:"table",structure:"row",column:"column",td:"cell",var:"variable",countdown:"countdown",carousel:"carousel",accordion:"accordion",social:"social",floatBlock:"floatingBlock"};function zE(e){return typeof e=="string"&&Object.hasOwn(aa,e)&&aa[e]||"none"}function Hr(e,t,n){let r,o;const i=()=>{const s=e.getInstance(t);return s===void 0||r?r!==void 0:(r=n(s),!0)};return i()||(o=e.onInject(s=>{s===t&&i()&&o?.dispose()})),{dispose:()=>{o?.dispose(),r?.dispose()}}}function KE(e){const t=hr(e),n={editor:!1,document:!1},r=()=>xt(t,{readOnly:n.editor||n.document});r();const o=[ri(e).watch(i=>xt(t,{headless:i})),or(e).watch(({isCodeMode:i})=>xt(t,{codeMode:i})),Hr(e,be,i=>i.watch(s=>{n.editor=WE(s),r()})),Hr(e,Yn,i=>{let s,a;const c=()=>{const b=i.sessionKey(),v=b!==void 0&&!ne(b)?i.current()?.get().attributes:void 0;n.document=v?.lock===!0&&!qa(e,v),r()},l=()=>{const b=i.sessionKey();xt(t,{documentOpen:b!==void 0,documentKind:b===void 0?void 0:ne(b)?"block":"email"});const v=i.current();v!==s&&(a?.(),s=v,a=v?.subscribe(c)),c()};l();const d=i.subscribe(l),h=nf(e,c);return{dispose:()=>{d(),a?.(),h.dispose()}}})];return o.push(Hr(e,Na,i=>{const s=()=>{const l=i.getState(),d=_t(t)?.documentKind==="block"?l.blockSlice:l.emailSlice;xt(t,{selection:zE(d?.elementSettings?.type)})};s();const a=t.select(l=>l?.documentKind).watch(s),c=i.subscribe(s);return{dispose:()=>{c(),a.dispose()}}})),{dispose:()=>o.forEach(i=>i.dispose())}}var YE=["handleAIImageRequest","handleAITextRequest","handleAnalyticsEvent","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleImportValidate","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],XE=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],Vn=new Map([...YE.map(e=>[e,"event"]),...XE.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),JE=new Map([["use","use `useAsync()` or await `ready` first"]]);function QE(e){return JE.get(e)??"await `ready` first"}var ZE=new Set(["async","queued"]),ew=Symbol.for("emailmaker.earlyCtxPlaceholder");function ca(e){return e[ew]=!0,e}function tw(e){return new Error(`[emailmaker] ${e}() is not available in a plugin constructor: the editor core is still loading. Call it from init() or later (${QE(e)}).`)}function nw(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function rw(e){return[...Vn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function ow(e,t){for(const n of rw(e)){const r=Vn.get(n);if(r!==void 0&&ZE.has(r)){const o=async(...i)=>{await t;const s=e[n];if(typeof s!="function"||s===o)throw nw(n);return s.apply(e,i)};e[n]=ca(o);continue}e[n]=ca(()=>{throw tw(n)})}}function iw(e,t,n){e.getInstanceAsync(yt).then(()=>{Qt(e,$.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function sw(e,t){e.getInstanceAsync(yt).then(()=>{Qt(e,$.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var aw=Rt(e=>{let t;function n(){return new Promise(o=>{const i=e.getOrCreateInstance(jo,()=>new Set),s=()=>{i.delete(s),o()};i.add(s)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const i=e.getInstance(en),s=e.getInstance(td);if(!t){t=new Du(i,s,{ensureHostRuntimeReady:aE,explainScriptFailure:cE,openEarlyWindow:()=>r_(e),reportLoadFailure:l=>sw(e,l)}),e.inject($o,t),GE(e,t,s);const c=t.onLifecycle(l=>{l.type==="create:error"&&iw(e,l.name,l.error)});e.getInstance(W)?.addDisposable(c),e.getInstance(W)?.addDisposable(KE(e))}const a=o?.plugins||[];i&&(ri(e),a.length>0&&ow(i,n()),await t.setPlugins(a))},instance:{use(o){return typeof o=="function"?r().useByCtor(o):r().useByKey(o)},useAsync(o){return r().useAsync(o)},waitPlugin(o){return r().waitFor(o)}},dispose(){t?.dispose(),t=void 0}}}),ud=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const o=this._listeners.indexOf(r);o>=0&&this._listeners.splice(o,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},cw=H("ELEMENT_INSERT_HTML_PIPELINE"),lw=H("BLOCK_INSERT_HTML_PIPELINE"),dw="application_block_inserted",uw=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(lw,()=>new ud).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Zt,()=>new tn),o=n?e.bind(n):e;return r.addListener(dw,o,t)}},fw=class{_context;constructor(e){this._context=e}register(e,t){const n=this._context.container,r=dn(n).current(),o={},i={};for(const[s,a]of Object.entries(e)){const{run:c,...l}=a;if(typeof c!="function")throw new Error(`Command "${s}" of "${r.name}" has no \`run\`; declare it with defineCommand({ title, run }).`);o[s]=l,i[s]=c}return Ne(n).register(r,o,i,t)}run(e,...t){return Ne(this._context.container).run(e,t[0],{caller:"plugin"})}has(e){return Ne(this._context.container).has(e)}},Ei=H("ComponentRegistry"),pw=H("ComponentRegistryGate");function wi(){return Et.getOrCreateInstance(pw,()=>({pending:[]}))}function hw(e=Ei){return wi().factory!==void 0||Et.getInstance(e)!==void 0}function Oo(e,t,n=Ei){if(hw(n)){t(qn(e,n));return}wi().pending.push(()=>t(qn(e,n)))}function qn(e,t=Ei){const n=Et.getInstance(t);if(n)return n;const r=wi().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return Et.getOrCreateInstance(t,r)}var mw=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=i=>{if(!n){n=!0;for(const s of t)s.dispose();e(i)}};t.push(this._container.addService(un,{execute:i=>{r(i.value.map(s=>({name:s.name,html:s.html})))}}));const o=this._container.getInstance(ru)?.watch(i=>{i&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService(un,{execute:r=>{const o=qn(n),i=r.value.find(s=>s.name===e);if(i){const{icon:s,title:a,fallbackTooltip:c,...l}=t;s&&(i.icon=o.getReactNode(s)),a&&(i.title=o.getReactNode(a)),c&&(i.fallbackTooltip=o.getReactNode(c)),Object.assign(i,l)}}})}delete(e){this._container.addService(un,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container;return n.addService(un,{execute:r=>{const o=qn(n);r.value.splice(t??r.value.length,0,{...e,title:o.getReactNode(e.title),icon:o.getReactNode(e.icon),fallbackTooltip:o.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(cw,()=>new ud).add(e,t??0,n)}handleInject(e,t,n){return vt(this._container,nu).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},gw=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Zt,()=>new tn)}send(e,t,n){this._messageService.send(e,t,n)}sendAsync(e,t,n=!0){return this._messageService.sendAsync(e,t,n)}addListener(e,t,n){return this._messageService.addListener(e,t,n)}addListenerAsync(e,t,n=0){return this._messageService.addListenerAsync(e,t,n)}onInit(e,t=!0,n=0){return this._messageService.onInit(e,t,n)}isInited(){return this._messageService.isInited()}};function vw(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function la(e,t){if(!t)return;const n=r=>r===void 0?void 0:e.getReactNode(r);return{...t,footer:n(t.footer),okText:n(t.okText),cancelText:n(t.cancelText),closeIcon:n(t.closeIcon)}}var bw=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=vt(t,lu),this._closeModalEmitter=vt(t,Dd),this._updateModalEmitter=vt(t,yu)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Oo(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:la(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Oo(this._container,r=>{const o=i=>i===void 0?void 0:r.getReactNode(i);this._updateModalEmitter.fire(vw({...t,content:o(t.content),title:o(t.title),id:e,modalProps:la(r,n)}))})}};function In(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var yw=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=o=>{this._loadedSettled||(this._loadedSettled=!0,r(o))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=o=>{this._readySettled||(this._readySettled=!0,r(o))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},_w=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Zt,()=>new tn)}_createScriptHandle(e,t){const n=this._messageService.addListener(Ho,o=>{if(o.key===e){if(o.phase==="load"&&o.status==="success"){r.resolveLoaded();return}if(o.phase==="ready"&&o.status==="success"){r.resolveReady();return}if(o.phase==="load"){r.rejectLoad(new Error(o.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(o.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new yw(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(pt,{...In(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(pt,{...In(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(pt,{...In(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(pt,{...In(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},Ew=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function ko(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&Ew.has(t)}function fd(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}return`nohwcrypto-${Date.now()}`}function $r(){return`__settingsPanel:${fd()}`}function Vr(e,t){return{type:e,props:t}}function ww(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!ko(e)}function da(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(ko(t)){const r=$r();return n(e.add(r,t)),Vr(r,{})}if(typeof t=="function"){const r=$r();return n(e.add(r,t)),Vr(r,{})}if(ww(t)){const r=t.type;if(typeof r=="string")return t;if(ko(r)||typeof r=="function"){const o=$r();return n(e.add(o,r)),Vr(o,t.props)}return t}return t}var Sw=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=e.instanceKey??fd();Oo(this._container,n=>{const r=s=>this._trackRegistration(s),o=da(n,e.content,r),i=e.advancedTabs?.map(s=>({...s,content:da(n,s.content,r)}));vt(this._container,Oi).fire({...e,content:o,advancedTabs:i,instanceKey:t,type:Vd})})}closeSettingsPanel(){this._clearPanelRegistrations(),vt(this._container,Oi).fire(null)}},Iw=class{_context;constructor(e){this._context=e}get apiVersion(){return this._service().apiVersion}supports(e,t){return this._service().supports(e,t)}addViews(e,t){return this._service().addViews(this._owner(),e,t,this._context)}addItem(e){return this._service().addItem(this._owner(),e)}open(e,...t){return this._service().open(e,t[0])}_service(){return mr(this._context.container)}_owner(){return dn(this._context.container).current()}},pd=_i({SandboxScriptApi:_w,ElementsApi:mw,BlocksApi:uw,MessageService:gw,SettingsPanelApi:Sw,ModalApi:bw,Commands:fw,Ui:Iw});function qr(e,t,n,r={}){const o=Object.assign({},e);for(const[i,s]of Object.entries(t))if(s!==void 0)if(n.includes(i)&&typeof s=="object"&&s!==null){const a=o[i],c=r[i]??{};o[i]=Object.assign({},typeof a=="object"&&a!==null?a:c,s)}else o[i]=s;return o}var Re={border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},borderRadiusCards:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},padding:{all:null,top:null,right:null,bottom:null,left:null}},Cw={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},Gr={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:24,fontSizeDim:"px",lineHeight:32,lineHeightDim:"px",color:"#333333",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},ua={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},dt={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:Re.border,borderRadius:Re.borderRadius,textAlign:"center",padding:Re.padding},fa={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:Re.padding},Wr={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:Re.border,borderRadius:Re.borderRadiusCards};function Aw(e){return{...Cw,...e}}function Tw(e){return{...Gr,...e,bold:e?.bold??Gr.bold,italic:e?.italic??Gr.italic}}function Rw(e){return{...ua,...e,underline:e?.underline??ua.underline}}function Ow(e){return{...dt,...e,bold:e?.bold??dt.bold,italic:e?.italic??dt.italic,border:{...dt.border,...e?.border},borderRadius:{...dt.borderRadius,...e?.borderRadius},padding:{...dt.padding,...e?.padding}}}function kw(e){return{...fa,...e,padding:{...fa.padding,...e?.padding}}}function Pw(e){return{...Wr,...e,border:{...Wr.border,...e?.border},borderRadius:{...Wr.borderRadius,...e?.borderRadius}}}function zr(e={}){return{backgroundColor:e.backgroundColor||"",backgroundImage:(e.backgroundImage||[]).map(t=>({type:"url",value:t?.value||""})),backgroundPositionX:e.backgroundPositionX||"",backgroundPositionY:e.backgroundPositionY||"",backgroundRepeat:e.backgroundRepeat||"",backgroundSize:e.backgroundSize||"",backgroundColorContent:e.backgroundColorContent||"",textStrong:e.textStrong||!1,textItalic:e.textItalic||!1,textUnderline:e.textUnderline||!1,width:e.width,responsive:e.responsive}}function pa(e){let t={...Bo};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Kr(e){return{text:Aw(e.text),headings:Tw(e.headings),links:Rw(e.links),buttons:Ow(e.buttons),block:kw(e.block),cards:Pw(e.cards)}}var ha=H("EmailSettingsPort"),Dw=1e4,hd=class{_editor;_layoutSettingsChanged=new Qr;_contentStylesChanged=new Qr;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentLayoutSettings()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentContentStyles()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_replayToEarlyPlugin(e,t){if(!jl(this._editor.container)||!ht(this._editor.container)?.current()?.get().attributes.is_inited)return;const n=t();queueMicrotask(()=>e(n))}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(ha);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return zr(this._settings().read())}_getCurrentContentStyles(){const e=ht(this._editor.container)?.current()?.get().attributes.common_styles;return Kr(pa(e))}_getLayoutSnapshot(e){return JSON.stringify(e)}_getContentSnapshot(e){return JSON.stringify(e)}async _ensureMessageSubscription(){if(!this._messageSubscription){if(this._messageSubscriptionPromise)return this._messageSubscriptionPromise;this._messageSubscriptionPromise=(async()=>{if(await this._editor.container.getInstanceAsync(ha),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Zt,()=>new tn),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const o=r?.data,i=o?.operation;if(i===z.APPLICATION_EMAIL_SETTINGS_SET){const c=zr(o?.settings),l=this._getLayoutSnapshot(c);l!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=l,this._layoutSettingsChanged.fire(c));return}if(i!==z.APPLICATION_COMMON_STYLES_UPDATE)return;const s=Kr(r.data?.settings?.commonStyles??{...Bo}),a=this._getContentSnapshot(s);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=zr(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Dw){const t=ht(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,o=Ie(r,$.ON_EMAIL_INIT_ID);return new Promise(i=>{let s=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},l=o(()=>{s||(s=!0,c(),l.dispose(),i())});a=setTimeout(()=>{s||(s=!0,l.dispose(),i())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=ht(this._editor.container)?.current();if(!t)return;const n=pa(t.get().attributes.common_styles);e.text!==void 0&&(n.text={...n.text||{},...e.text}),e.headings!==void 0&&(n.headings={...n.headings||{},...e.headings}),e.links!==void 0&&(n.links={...n.links||{},...e.links}),e.buttons!==void 0&&(n.buttons=qr(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:Re.border,borderRadius:Re.borderRadius,padding:Re.padding})),e.block!==void 0&&(n.block=qr(n.block||{},e.block,["padding"],{padding:Re.padding})),e.cards!==void 0&&(n.cards=qr(n.cards||{},e.cards,["border","borderRadius"],{border:Re.border,borderRadius:Re.borderRadiusCards}));const r=JSON.stringify(n);wt(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=Kr(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},xw={...pd,..._i({EmailSettingsApi:hd})},Mw={...pd},tC={...Mw,..._i({EmailSettingsApi:hd})},Lw={...xw};function Nw(){pE.addAll(Lw)}var Fw=[Rt(()=>{Nw()}),W_,rE,G_,fu,V_,bu];async function Bw(){return(await ln()).asyncMixins}var jw=aw,Uw=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let o;try{o=await Bw()}catch(s){throw e.failPendingWaits(s),s}t=o(e);const i=await e.getInstanceAsync(en);Object.assign(i,t.instance||{});for(const s of e.getInstance(jo)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},Hw=vu([...Fw]);function Yr(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const i of r.values())i();r.clear()}return{event(i,s,a){const c=Symbol("subscription");return t||(n.set(c,{listener:i,priority:s,thisArg:a}),e&&r.set(c,e(i,s,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(i){o(),e=i;for(const[s,{listener:a,priority:c,thisArg:l}]of n)r.set(s,i(a,c,l))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function $w(e){const t=Yr(),n=Yr(),r=Yr();return e.getInstance(W)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(yt).then(o=>{t.attach(o.onNotify),n.attach(o.onError),r.attach(o.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(o){const i=e.getInstance(yt);if(i){i.notify(o);return}e.getInstanceAsync(yt).then(s=>s.notify(o),()=>{})}}}var md=H("CodeErrors"),Vw=[];function qw(e){return e?.getInstance(md)?.get()??Vw}function Gw(e){return e?.getInstance(md)!==void 0}var Ww="SAVE",zw="SAVE_BLOCK",nC="SET_THEME",rC="NOTIFY",oC="SET_CONFIG",iC="UPDATE_CONFIG",gd=class extends pe{_options;_listeners=[];constructor(e){super(),this._options=e}fire=e=>{if(!this.isDisposed()){let t;const n=[...this._listeners];for(const r of n){if(t===!1)return!1;t instanceof Promise?t=t.then(o=>o===!1||this.isDisposed()?!1:r(o)).catch(o=>{}):t=r(e)}return t}};addEventListener=e=>{const t=this._listeners,n=this._options;return t.push(e),t.length===1&&this._options?.onFirstListenerAdd&&this._options.onFirstListenerAdd(),{dispose:()=>{const r=t.indexOf(e);r>=0&&(t.splice(r,1),t.length||n?.onFirstListenerAdd&&n.onLastListenerRemove())}}};event=this.addEventListener},ma;(function(e){function t(o){let i;const s=new gd({onFirstListenerAdd(){i=o(s.fire)},onLastListenerRemove(){i.dispose()}});return s.event}e.snapshot=t;function n(o,i){return t(s=>o(a=>i(a)&&s(a)))}e.filter=n;function r(o,i){return t(s=>o(a=>s(i(a))))}e.map=r})(ma||(ma={}));var Kw=H("helpers.commandEmitter");function Yw(e,t,n){e instanceof $d||(e=Jd(e)),e.getOrCreateInstance(Kw,()=>new gd).fire({id:t,payload:n})}var Si="document.getSnapshot",Xw="document.save",vd=Symbol.for("emailmaker.legacyEmailSnapshot"),Po=Symbol.for("emailmaker.legacyEmailSnapshotError");function Jw(e,t){return Object.defineProperty(e,vd,{value:t})}function Qw(e){return Jw({kind:"email",id:e.id==null?null:String(e.id),content:e.code??"",subject:e.subject??"",preheader:e.preheader??""},e)}function Zw(e){return{kind:"block",id:e.id==null?null:String(e.id),content:e.code??"",subject:"",preheader:""}}function eS(e,t){const n=Ne(e),r={[Si]:{declaration:{title:"Get document snapshot",description:"Returns the open document: kind, id and content."},handler:async()=>{try{const s=xe(e),a=ne(s?.sessionKey())?await t.getBlockSnapshot():null;return Tt(a?Zw(a):Qw(await t.readEmailSnapshot()))}catch(s){return Object.defineProperty(ke("internal",s instanceof Error?s.message:String(s)),Po,{value:s})}}},[Xw]:{declaration:{title:"Save document",description:"Saves the open document and finishes when the save is done."},handler:()=>oS(e)}},o=new Map,i=n.commands.watch(()=>{n.disposed||Object.entries(r).forEach(([s,{declaration:a,handler:c}])=>{n.has(s)||o.set(s,n.register(pr,{[s]:a},{[s]:c}))})});return{dispose:()=>{i.dispose(),o.forEach(s=>s.dispose())}}}async function tS(e,t){const n=await Ne(e).run(Si,void 0,{caller:"plugin"});if(n.ok===!1){if(Po in n)throw n[Po];return t()}return n.value[vd]}function nS(e){return Ne(e).info(Si)?.owner===pr}async function rS(e,t){const n=await new Promise(i=>{Yw(e,t,{source:lh,settle:i})});if(n.ok!==!1)return Tt();if(n.reason==="unready")return;const r=n.reason==="locked"?"readOnly":n.reason==="aborted"?"aborted":"internal",o=ke(r,n.message);return n.notified?Object.defineProperty(o,uh,{value:!0}):o}async function oS(e){if(_t(hr(e))?.readOnly)return ke("readOnly","The editor is read-only.");const t=xe(e)?.sessionKey();if(t!==void 0){const r=ne(t);if(ph(e,r?"block":"email")){const o=await rS(e,r?zw:Ww);if(o)return o}}const n=e.getInstance(en);if(t===void 0||!n)return ke("unavailable","There is no open document to save.");try{return await(ne(t)?n.saveBlock():n.save()),Tt()}catch(r){return r instanceof qe&&r.reason==="locked"?ke("readOnly",r.message):ke("internal",r instanceof Error?r.message:String(r))}}var iS=class extends pe{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=cn(e),this.addDisposable(Ie(e,$.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t})),this.addDisposable(eS(e,this))}openEmail(){const e=xe(this._container);if(e&&ne(e.sessionKey())&&!e.hasSuspended())throw new Error("[emailmaker] no open email: only a block is shown");return Pl(this._container,this._currentEmail)}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>String(t.project)===String(e)).map(t=>_e(t,this._container))}async _readProjectBlocks(){const e=await Dl(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>Ft(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>wo(n,this._container))}async getEmailSnapshot(){return ne(xe(this._container)?.sessionKey())||!nS(this._container)?this.readEmailSnapshot():tS(this._container,()=>this.readEmailSnapshot())}async readEmailSnapshot(){return Se(this.openEmail(),this._container)}async getBlockSnapshot(){const e=xe(this._container),t=e?.current();return!e||!t||!ne(e.sessionKey())?null:(await t.whenReady(),_e(rr(t),this._container))}setEmailMeta(e){const t=mi(this._container);if(!t)return;const n=t.get().attributes.meta;wt(t,{meta:bn({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&bn(o,e))}setBlockMeta(e,t){const n=xe(this._container);if(n?.sessionKey()===Ln(e)){const o=n.current();o&&wt(o,{meta:bn({meta:o.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,i=>i&&bn(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return Gw(this._container)?qw(this._container):void 0}},sS=H("EmailDataController");function aS(e){return e.getOrCreateInstance(sS,()=>{const t=new iS(e);return e.getInstance(W)?.addDisposable(t),t})}function cS(e){const t=aS(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function lS(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}function dS(e){let t;const n=bl(e),r=Ie(e,$.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:i})=>{t=i}));const o=()=>t?lS(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:i=>o()?.getPast(i)??[],getFuture:i=>o()?.getFuture(i)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:i=>o()?.restoreSnapshot(i)}}}var uS=H("plugin.mountElement");function fS(e){const t=e.getInstance(ye)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function pS(e){return e.getOrCreateInstance(uS,()=>{let t=!1,n;return{get:()=>t?n:fS(e),set(r){t=!0,n=r}}})}function hS(e){const t=pS(e);return{getElement:()=>t.get()}}function mS(e){return{handleLoadImage:V(Ie(e,$.UPLOAD_EVENT_ID)),handleFileProxy:V(Ie(e,$.FILE_PROXY_EVENT_ID)),handleUrlProxy:V(Ie(e,$.PROXY_URL_EVENT_ID)),handleAITextRequest:V(Ie(e,$.AI_TEXT_REQUEST_ID)),handleAIImageRequest:V(Ie(e,$.AI_IMAGE_REQUEST_ID)),handleReadLocale:V(Ie(e,$.READ_LOCALE)),handleLimitUsage:V(Ie(e,$.ON_LIMIT_ID)),handleTranslate:V(Ie(e,$.ON_TRANSLATE_ID))}}var gS=[$v,f_,$w,nE,cS,dS,hS,mS];function vS(e,t=gS){const n=bi(e);U_(e);const r=Hw(e),o=jw(e),i=Uw(e),s={...r.instance,...o.instance,...i.instance};for(const c of t)Object.assign(s,c(e));let a=!0;return{instance:s,async setOptions(c){await r.setOptions(c);const l=a&&n.get()===c;a=!1,l||n.set(c),await o.setOptions(c),await i.setOptions(c)}}}function bS(e){return{get:t=>e.get(t),remove:(t,n)=>e.remove(t,n),set:(t,n,r)=>{if(n==null){e.get(t),e.remove(t,r);return}e.set(t,n,r)}}}var yS=class{_storage=Object.create(null);get(e){const t=this._storage[e];return t&&(!t.expires||t.expires<Date.now())?t.value:""}set(e,t,n){this._storage[e]={value:t,expires:n.expires?n.expires*1e3+Date.now():void 0}}remove(e){delete this._storage[e]}},_S="editor-runtime.react.copies",Xr=8;function Kt(e){return e&&typeof e=="object"?e:void 0}function ga(e){const t=Kt(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Kt(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function ES(e){const t=Kt(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Kt(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function wS(e,t,n){return e.package===t&&e.version===n}function SS({ourReact:e,entries:t,packageName:n,version:r}){const o=ga(e);if(!o||!Array.isArray(t))return[];const i=[],s=new Set;for(const a of t){const c=Kt(a);if(!c||!wS(c,n,r))continue;const l=ga(c.react);!l||l===o||s.has(l)||(s.add(l),i.push({package:n,version:r,reactVersion:ES(c.react),react:c.react}))}return i}function IS({packageName:e,copies:t}){const n=[`[${e}] A second copy of React is on this page (singleton invariant broken).`,`The editor runs on its own React, the plugin got another one from ${e}/runtime/react.`,`This shows up as "Cannot read properties of null (reading 'useState')" and takes down the whole`,"editor, not just the plugin panel: plugin components render inside the editor tree.","","Found:"];for(const r of t.slice(0,Xr))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Xr&&n.push(` …and ${t.length-Xr} more`),n.push("","Likely root cause: the editor is loaded from its UMD entry (a <script> on the page), while the","plugin was built as an ESM package by the host bundler. Those two never share a React.","","Fix it either way:"," • build the plugin on globals — it then takes React from the page registry, or"," • load the editor from its ESM entry and build both with the same bundler."),n.join(`
|
|
1048
|
-
`)}var
|
|
1061
|
+
`)}function ya(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function CE(e,t,n,r){const i=RE(e,t,n,r);return i===void 0}function RE(e,t,n,r){if(kr(t))return"block";const{email:i}=Pr(t,!1),o=Ft(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=Re(e)?.current();if(!a)return"no-session";const c=a.get(),l=c.attributes;if(c.serverId!==s)return"document-id";if(l.is_inited!==!0)return"not-inited";const u=ya(ji(n??a.getContent()));if(o.html!==void 0&&ya(ji(o.html))!==u)return"html";if(o.subject!==void 0&&o.subject!==l.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==l.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==l.common_styles)return"common_styles"}function Ea(e,t){if(kr(t))return;const{email:n}=Pr(t,!1),r=Ft(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:ji(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function OE(e){return Array.isArray(e)?e.some(t=>wi(t)):wi(e)}function kE(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])OE(t[n])&&delete t[n];return t}function PE(e,t){const n={...e};return delete n.id,{...n,...t}}function DE(e,t){var n=0,r,i;t=t||{};function o(){var s=r,a=arguments.length,c,l;e:for(;s;){if(s.args.length!==arguments.length){s=s.next;continue}for(l=0;l<a;l++)if(s.args[l]!==arguments[l]){s=s.next;continue e}return s!==r&&(s===i&&(i=s.prev),s.prev.next=s.next,s.next&&(s.next.prev=s.prev),s.next=r,s.prev=null,r.prev=s,r=s),s.val}for(c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];return s={args:c,val:e.apply(null,c)},r?(r.prev=s,s.next=r):i=s,n===t.maxSize?(i=i.prev,i.next=null):n++,r=s,s.val}return o.clear=function(){r=null,i=null,n=0},o}var xE=Vd((e=>{(function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function n(a){return i(s(a),arguments)}function r(a,c){return n.apply(null,[a].concat(c||[]))}function i(a,c){for(var l=1,u=a.length,d,m="",_=0,v,E,y,k,C,F,T;_<u;_++)if(typeof a[_]=="string")m+=a[_];else if(typeof a[_]=="object"){if(E=a[_],E.keys)for(d=c[l],v=0;v<E.keys.length;v++){if(d==null)throw new Error(n('[sprintf] Cannot access property "%s" of undefined value "%s"',E.keys[v],E.keys[v-1]));d=d[E.keys[v]]}else E.param_no?d=c[E.param_no]:d=c[l++];if(t.not_type.test(E.type)&&t.not_primitive.test(E.type)&&d instanceof Function&&(d=d()),t.numeric_arg.test(E.type)&&typeof d!="number"&&isNaN(d))throw new TypeError(n("[sprintf] expecting number but found %T",d));switch(t.number.test(E.type)&&(F=d>=0),E.type){case"b":d=parseInt(d,10).toString(2);break;case"c":d=String.fromCharCode(parseInt(d,10));break;case"d":case"i":d=parseInt(d,10);break;case"j":d=JSON.stringify(d,null,E.width?parseInt(E.width):0);break;case"e":d=E.precision?parseFloat(d).toExponential(E.precision):parseFloat(d).toExponential();break;case"f":d=E.precision?parseFloat(d).toFixed(E.precision):parseFloat(d);break;case"g":d=E.precision?String(Number(d.toPrecision(E.precision))):parseFloat(d);break;case"o":d=(parseInt(d,10)>>>0).toString(8);break;case"s":d=String(d),d=E.precision?d.substring(0,E.precision):d;break;case"t":d=String(!!d),d=E.precision?d.substring(0,E.precision):d;break;case"T":d=Object.prototype.toString.call(d).slice(8,-1).toLowerCase(),d=E.precision?d.substring(0,E.precision):d;break;case"u":d=parseInt(d,10)>>>0;break;case"v":d=d.valueOf(),d=E.precision?d.substring(0,E.precision):d;break;case"x":d=(parseInt(d,10)>>>0).toString(16);break;case"X":d=(parseInt(d,10)>>>0).toString(16).toUpperCase()}t.json.test(E.type)?m+=d:(t.number.test(E.type)&&(!F||E.sign)?(T=F?"+":"-",d=d.toString().replace(t.sign,"")):T="",k=E.pad_char?E.pad_char==="0"?"0":E.pad_char.charAt(1):" ",C=E.width-(T+d).length,y=E.width&&C>0?k.repeat(C):"",m+=E.align?T+d+y:k==="0"?T+y+d:y+T+d)}return m}var o=Object.create(null);function s(a){if(o[a])return o[a];for(var c=a,l,u=[],d=0;c;){if((l=t.text.exec(c))!==null)u.push(l[0]);else if((l=t.modulo.exec(c))!==null)u.push("%");else if((l=t.placeholder.exec(c))!==null){if(l[2]){d|=1;var m=[],_=l[2],v=[];if((v=t.key.exec(_))!==null)for(m.push(v[1]);(_=_.substring(v[0].length))!=="";)if((v=t.key_access.exec(_))!==null)m.push(v[1]);else if((v=t.index_access.exec(_))!==null)m.push(v[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=m}else d|=2;if(d===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");u.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");c=c.substring(l[0].length)}return o[a]=u}typeof e<"u"&&(e.sprintf=n,e.vsprintf=r),typeof window<"u"&&(window.sprintf=n,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()})),CC=Sc(xE()),RC=DE(console.error),wa={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1},ME=["(","?"],$n={")":["("],":":["?","?:"]},LE=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;function NE(e){for(var t=[],n=[],r,i,o,s;r=e.match(LE);){for(i=r[0],o=e.substr(0,r.index).trim(),o&&t.push(o);s=n.pop();){if($n[i]){if($n[i][0]===s){i=$n[i][1]||i;break}}else if(ME.indexOf(s)>=0||wa[s]<wa[i]){n.push(s);break}t.push(s)}$n[i]||n.push(i),e=e.substr(r.index+i.length)}return e=e.trim(),e&&t.push(e),t.concat(n.reverse())}var FE={"!":function(e){return!e},"*":function(e,t){return e*t},"/":function(e,t){return e/t},"%":function(e,t){return e%t},"+":function(e,t){return e+t},"-":function(e,t){return e-t},"<":function(e,t){return e<t},"<=":function(e,t){return e<=t},">":function(e,t){return e>t},">=":function(e,t){return e>=t},"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},"&&":function(e,t){return e&&t},"||":function(e,t){return e||t},"?:":function(e,t,n){if(e)throw t;return n}};function BE(e,t){for(var n=[],r=0,i,o,s,a,c;r<e.length;r++){if(a=e[r],s=FE[a],s){for(i=s.length,o=Array(i);i--;)o[i]=n.pop();try{c=s.apply(null,o)}catch(l){return l}}else t.hasOwnProperty(a)?c=t[a]:c=+a;n.push(c)}return n[0]}function jE(e){var t=NE(e);return function(n){return BE(t,n)}}function UE(e){var t=jE(e);return function(n){return+t({n})}}var Sa={contextDelimiter:"",onMissingKey:null};function $E(e){for(var t=e.split(";"),n=0,r;n<t.length;n++)if(r=t[n].trim(),r.indexOf("plural=")===0)return r.substr(7)}function Uo(e,t){var n;this.data=e,this.pluralForms={},this.options={};for(n in Sa)this.options[n]=t!==void 0&&n in t?t[n]:Sa[n]}Uo.prototype.getPluralForm=function(e,t){var n=this.pluralForms[e],r,i,o;return n||(r=this.data[e][""],o=r["Plural-Forms"]||r["plural-forms"]||r.plural_forms,typeof o!="function"&&(i=$E(r["Plural-Forms"]||r["plural-forms"]||r.plural_forms),o=UE(i)),n=this.pluralForms[e]=o),n(t)};Uo.prototype.dcnpgettext=function(e,t,n,r,i){var o,s,a;return i===void 0?o=0:o=this.getPluralForm(e,i),s=n,t&&(s=t+this.options.contextDelimiter+n),a=this.data[e][s],a&&a[o]?a[o]:(this.options.onMissingKey&&this.options.onMissingKey(n,e),o===0?n:r)};var Ia={"":{plural_forms(e){return e===1?0:1}}},HE=/^i18n\.(n?gettext|has_translation)(_|$)/,Ku=(e,t,n)=>{const r=new Uo({}),i=new Set,o=()=>{i.forEach(T=>T())},s=T=>(i.add(T),()=>i.delete(T)),a=(T="default")=>r.data[T],c=(T,R="default")=>{r.data[R]={...r.data[R],...T},r.data[R][""]={...Ia[""],...r.data[R]?.[""]},delete r.pluralForms[R]},l=(T,R)=>{c(T,R),o()},u=(T,R="default")=>{r.data[R]={...r.data[R],...T,"":{...Ia[""],...r.data[R]?.[""],...T?.[""]}},delete r.pluralForms[R],o()},d=(T,R)=>{r.data={},r.pluralForms={},l(T,R)},m=(T="default",R,A,D,O)=>(r.data[T]||c(void 0,T),r.dcnpgettext(T,R,A,D,O)),_=(T="default")=>T,v=(T,R)=>{let A=m(R,void 0,T);return n?(A=n.applyFilters("i18n.gettext",A,T,R),n.applyFilters("i18n.gettext_"+_(R),A,T,R)):A},E=(T,R,A)=>{let D=m(A,R,T);return n?(D=n.applyFilters("i18n.gettext_with_context",D,T,R,A),n.applyFilters("i18n.gettext_with_context_"+_(A),D,T,R,A)):D},y=(T,R,A,D)=>{let O=m(D,void 0,T,R,A);return n?(O=n.applyFilters("i18n.ngettext",O,T,R,A,D),n.applyFilters("i18n.ngettext_"+_(D),O,T,R,A,D)):O},k=(T,R,A,D,O)=>{let h=m(O,D,T,R,A);return n?(h=n.applyFilters("i18n.ngettext_with_context",h,T,R,A,D,O),n.applyFilters("i18n.ngettext_with_context_"+_(O),h,T,R,A,D,O)):h},C=()=>E("ltr","text direction")==="rtl",F=(T,R,A)=>{const D=R?R+""+T:T;let O=!!r.data?.[A??"default"]?.[D];return n&&(O=n.applyFilters("i18n.has_translation",O,T,R,A),O=n.applyFilters("i18n.has_translation_"+_(A),O,T,R,A)),O};if(e&&l(e,t),n){const T=R=>{HE.test(R)&&o()};n.addAction("hookAdded","core/i18n",T),n.addAction("hookRemoved","core/i18n",T)}return{getLocaleData:a,setLocaleData:l,addLocaleData:u,resetLocaleData:d,subscribe:s,__:v,_x:E,_n:y,_nx:k,isRTL:C,hasTranslation:F}};function Yu(e){return!(typeof e!="string"||e===""||!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e))}function $o(e){return!(typeof e!="string"||e===""||/^__/.test(e)||!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e))}function Ta(e,t){return function(r,i,o,s=10){const a=e[t];if(!$o(r)||!Yu(i)||typeof o!="function"||typeof s!="number")return;const c={callback:o,priority:s,namespace:i};if(a[r]){const l=a[r].handlers;let u;for(u=l.length;u>0&&!(s>=l[u-1].priority);u--);u===l.length?l[u]=c:l.splice(u,0,c),a.__current.forEach(d=>{d.name===r&&d.currentIndex>=u&&d.currentIndex++})}else a[r]={handlers:[c],runs:0};r!=="hookAdded"&&e.doAction("hookAdded",r,i,o,s)}}function Hn(e,t,n=!1){return function(i,o){const s=e[t];if(!$o(i)||!n&&!Yu(o))return;if(!s[i])return 0;let a=0;if(n)a=s[i].handlers.length,s[i]={runs:s[i].runs,handlers:[]};else{const c=s[i].handlers;for(let l=c.length-1;l>=0;l--)c[l].namespace===o&&(c.splice(l,1),a++,s.__current.forEach(u=>{u.name===i&&u.currentIndex>=l&&u.currentIndex--}))}return i!=="hookRemoved"&&e.doAction("hookRemoved",i,o),a}}function Aa(e,t){return function(r,i){const o=e[t];return typeof i<"u"?r in o&&o[r].handlers.some(s=>s.namespace===i):r in o}}function Ca(e,t,n=!1){return function(i,...o){const s=e[t];s[i]||(s[i]={handlers:[],runs:0}),s[i].runs++;const a=s[i].handlers;if(!a||!a.length)return n?o[0]:void 0;const c={name:i,currentIndex:0};for(s.__current.push(c);c.currentIndex<a.length;){const l=a[c.currentIndex].callback.apply(null,o);n&&(o[0]=l),c.currentIndex++}if(s.__current.pop(),n)return o[0]}}function Ra(e,t){return function(){var r;const i=e[t];return(r=i.__current[i.__current.length-1]?.name)!==null&&r!==void 0?r:null}}function Oa(e,t){return function(r){const i=e[t];return typeof r>"u"?typeof i.__current[0]<"u":i.__current[0]?r===i.__current[0].name:!1}}function ka(e,t){return function(r){const i=e[t];if($o(r))return i[r]&&i[r].runs?i[r].runs:0}}var VE=class{constructor(){this.actions=Object.create(null),this.actions.__current=[],this.filters=Object.create(null),this.filters.__current=[],this.addAction=Ta(this,"actions"),this.addFilter=Ta(this,"filters"),this.removeAction=Hn(this,"actions"),this.removeFilter=Hn(this,"filters"),this.hasAction=Aa(this,"actions"),this.hasFilter=Aa(this,"filters"),this.removeAllActions=Hn(this,"actions",!0),this.removeAllFilters=Hn(this,"filters",!0),this.doAction=Ca(this,"actions"),this.applyFilters=Ca(this,"filters",!0),this.currentAction=Ra(this,"actions"),this.currentFilter=Ra(this,"filters"),this.doingAction=Oa(this,"actions"),this.doingFilter=Oa(this,"filters"),this.didAction=ka(this,"actions"),this.didFilter=ka(this,"filters")}};function GE(){return new VE}var Xu=GE(),{addAction:OC,addFilter:kC,removeAction:PC,removeFilter:DC,hasAction:xC,hasFilter:MC,removeAllActions:LC,removeAllFilters:NC,doAction:FC,applyFilters:BC,currentAction:jC,currentFilter:UC,doingAction:$C,doingFilter:HC,didAction:VC,didFilter:GC,actions:qC,filters:WC}=Xu,pe=Ku(void 0,void 0,Xu),zC=pe.getLocaleData.bind(pe),KC=pe.setLocaleData.bind(pe),YC=pe.resetLocaleData.bind(pe),XC=pe.subscribe.bind(pe),JC=pe.__.bind(pe),QC=pe._x.bind(pe),ZC=pe._n.bind(pe),e0=pe._nx.bind(pe),t0=pe.isRTL.bind(pe),n0=pe.hasTranslation.bind(pe);function qE(e,t){if(e.html)return e;const n=e.subject||t;return{...e,subject:n,html:Gu(n)}}function WE(e,t){if(e.html||e.subject||!t?.subject)return e;const n={...e};return delete n.subject,n}async function zE(e){const t=e.getInstance(vt);t&&!t.snapshot().ready&&await new Promise(r=>{const i=t.state.watch(({ready:o})=>{o&&(queueMicrotask(()=>i.dispose()),r())})});const n=Ku(t?.snapshot().catalog);return _E(r=>n.__(r))}function lt({code:e,project:t,...n},r,i){const o=i??No(r);return{...n,...e?{html:Ze(r).toEditorForm(e)}:{},renderGuid:ke(),...o===void 0?{}:{project:o}}}function Se({html:e,renderGuid:t,...n},r){const{requested:i}=Tn(r);return Ge({...n,code:Ze(r).toOutputForm(e),project:i===void 0?n.project:i,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function Ju(e){return Re(e)?.current()?.get().serverId??void 0}function Ui(e,t,n){return n===void 0&&(n=e.post===void 0?Ju(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function Jt(e,t){return Ge({...e,link:void 0,comment_status:void 0})}function Yn({code:e,autosave:t,...n},r,i){return i===void 0&&(i=n.parent===void 0?Ju(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||kh(n.slug),parent:i}}function $i({html:e,isAutosave:t,...n},r){return Ge({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:Ge({html:e,ampHtml:e&&""})})}function Xn({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function Pa({html:e,isAutosave:t,...n}){return Ge({...n,autosave:t?!0:void 0,code:e,guid:void 0})}function KE(e){return String(e).replace(/"/g,""")}function YE(e=new Date){const t=n=>String(n).padStart(2,"0");return String(e.getFullYear())+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function Ho(e){const t=/<(table|tr|div)(\s[^>]*)>/gi;let n;for(;(n=t.exec(e))!==null;){const r=n[2]??"";if(/\bem\s*=\s*["']block["']/i.test(r))return{full:n[0],index:n.index}}return null}function Da(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=KE(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function xa(e,t){return e.replace(new RegExp(`\\s+${t}\\s*=\\s*["'][^"']*["']`,"gi"),"")}function Ma(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function Qu(e){if(!e?.trim())return{};const t=Ho(e);return t?{emBlockId:Ma(t.full,"em-block-id"),emBlockVersion:Ma(t.full,"em-block-version")}:{}}function Zu(e,t,n){if(!e?.trim()||!t)return e;const r=Ho(e);if(!r)return e;const i=String(t),o=YE(n??new Date);let{full:s,index:a}=r;const c=s.length;return/\bem-block-id\s*=/.test(s)||(s=Da(s,"em-block-id",i)),s=Da(s,"em-block-version",o),e.slice(0,a)+s+e.slice(a+c)}function XE(e){const t=e?.trim()?Ho(e):null;if(!t)return e;const{full:n,index:r}=t,i=xa(xa(n,"em-block-id"),"em-block-version");return e.slice(0,r)+i+e.slice(r+n.length)}function JE(e,t){const{emBlockId:n,emBlockVersion:r}=Qu(e);return n&&r?e:Zu(e,t)}var Dt=U("NotificationService"),QE=U("emailTemplate.reads");async function ZE(e,t){try{const n=ft(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,tw(e,t,n);return}}var ew=U("emailTemplate.notifiedFailures");function tw(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(ew,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(Dt).then(()=>{vn(e,H.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function nw(e,t){const n=e.getOrCreateInstance(QE,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=ZE(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var rw=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:fa.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:fa.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},r0=U("projects.v2IdByWpId"),i0=U("projects.wpIdByV2Id"),o0=U("emails.v2SavedAtOnOpen"),s0=U("emails.v2OpeningReads"),Hi=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function iw(e,t){if(!t)throw new Hi(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new Hi(e,Or(t))}function ow(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var sw=/^[A-Za-z0-9_-]{1,128}$/,aw=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),La=new Set;function cw(e){return sw.test(e)?!0:(La.has(e)||La.add(e),!1)}function lw(e){return e&&!e.ok?String(Or(e).data.code??""):""}var ed=()=>({isAutosave:!1});function Na(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function uw(e,t){const n=new AbortController,r=En(e.getInstance(Fe)?.contentReadyTimeoutMs);let i;const o=new Promise((s,a)=>{i=setTimeout(()=>{n.abort(),a(new Hi("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),o])}finally{clearTimeout(i)}}function dw(e,t){return Zc(t,e==="block")}async function fw(e,t,n,r,i){if(!cw(n))return ed();const o=Lt(e),s=wn(e),a=dw(t,n);try{const c=await pw(e,t,n,r,i);return c.id&&(o.set(a,c.id),s.delete(a)),c}catch(c){throw hm(s,a,r.html??""),c}}async function pw(e,t,n,r,i){const o=ju(e,[rw]),s={entityId:n,...i?{autosave:!0}:{}},a=await uw(e,c=>t==="email"?o.emailsRevisionsCreate(s,Na(t,r),{signal:c}):o.blocksRevisionsCreate(s,Na(t,r),{signal:c}));return aw.has(lw(a))?ed():(iw("обновление",a),ow(a.data??{}))}function hw(e,t,n,r){return fw(e,t,n,r,!1)}async function mw(e,t,n){if(t==null||t===""||n===void 0||!Ut(e))return Fa;const r=Date.now(),i=mo(String(t));return Al(i,{html:n},r,So(Lt(e),i,wn(e),n)),await hw(e,"block",String(t),{html:n}),ir(i,r,Lt(e).get(i)??void 0),()=>go(i,r)}function Fa(){}var Xr="EXTERNAL",Ba=Symbol("supersededShow");function gw(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var vw="email_id";function Jr(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var bw=class extends ve{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=Rc();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=An(t),this._eventLock=SE(t);const n=ne(e,H.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(ne(e,H.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(hr,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(vw,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Fe)??Po}_throwIfDestroyed(){if(this.isDisposed())throw Ke()}async getTemplateEmail(e){const t=await nw(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,kE(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Xt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,lt(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,Yn(i,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,Ui(i,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,i){const o=this._dataSources.emails,s=o.cache,a=await Xt(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let l=Ft(e,this._container);const u=l.id;let d=u;if(u!==void 0){const m=await o.get(u);l={...m??{},...l,utm_parameters:l.utm_parameters??m?.utm_parameters??{},renderGuid:m?.renderGuid??ke(),...c>0?{showToken:c}:{},...i?{showId:i}:{},project:a}}else{d=n??ke();const m=await o.get(d);l={...l,utm_parameters:l.utm_parameters??{},renderGuid:m?.renderGuid??ke(),...c>0?{showToken:c}:{},...i?{showId:i}:{},project:a},delete l.project}if(t){const m=await this.getTemplateEmail(String(t));m&&(l=PE(m,l))}return u===void 0&&!l.html&&(l=qE(l,await zE(this._container))),await s.setAll([[d,l]]),l}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Ea(this._container,e))return!1;const n=Kn(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Ea(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Kn(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&IE({ticket:t,emailId:_a(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,Ba;if(!e)return;const n=this._getInitPipeline();if(se(n.signal),kr(e))return this._showBlock(e,n);const r=ee(ye(this._container).sessionKey()),i=TE(e);if(!r&&!i&&CE(this._container,e,Kn(this._container),this._prevCommand?.id)||!r&&!i&&this._isRepeatOfLastShow(e))return;const o=Pr(e);o.email.id,this._prevCommand?.id;let s,a="",c=0,l=!1,u,d=Promise.resolve(),m,_=!1;try{this._eventLock.suspendChange();const{email:v,blocks:E,autosaves:y,comments:k,templateId:C,reload:F}=o;s=v.id;const T=Ft(v,this._container),R=T.id,A=R??ke(),D=await ct("getProject",Xt(this._container));se(n.signal),a=ke();const O={isNew:R===void 0,id:String(A),project:D},h=F===!0&&R!==void 0;h&&(await this._dataSources.emails.remove(String(R),{silent:!0}),String(R)),c=++this._showToken,String(A);const f=[];f.push(this.setBlocks(E)),v.id!==void 0&&(f.push(this.setComments(k)),f.push(this.setEmailRevisions(y,String(v.id)))),f.push(this.setEmail(v,wi(C)?C:Number(C),R===void 0?String(A):void 0,c,a)),await ct("setEmail+blocks+revisions",Promise.all(f),{emailId:R??String(A),showId:a,targetShowToken:c}),se(n.signal);const p=await this._dataSources.emails.get(String(A)),b=ye(this._container),x={id:a,token:c};if(r){zn(this._container);const w=b.suspendedDocument()?.get().serverId;!h&&R!==void 0&&w!=null&&String(w)===String(R)&&b.resumeSuspended()}R===void 0?m=b.startNewDraft(p??T,{patch:WE(T,p),show:x}):h?m=b.reload(R,{email:p??T,patch:T,show:x}):b.sessionKey()===wt(R)?m=b.show(T,x):m=b.open(R,{email:p??T,patch:T,show:x}),b.beginShowFill(a);const N=!!this._prevCommand&&Ne(this._prevCommand,O);O.id,!this._prevCommand||Ne(this._prevCommand,O),this._prevCommand?.id,this._rememberShow(O),d=n.requestShow({showId:a,navId:String(A),emailId:R,isNew:R===void 0}),_=!0;const S=()=>b.endShowFill(a);Promise.allSettled([d,m.whenReady()]).then(S),String(A),l=!0}catch(v){u=v,_&&a&&n.failShow(a,v),a&&Re(this._container)?.endShowFill(a),lo(v)||(Wc(v),void 0)}finally{this._eventLock.resumeChange()}if(!l)throw u instanceof Error?u:new Error(`[emailmaker] show() setup failed: ${String(u??"unknown error")}`);return ct("show-init-deferred",Promise.all([d,m?.whenReady().catch(v=>{if(v instanceof dt){const E=wo(v);throw E?new Error(`[emailmaker] show(): email open failed (${E})`,{cause:v}):v}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:s??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:i,revisions:o,reload:s}=wE(e),a=ke();let c=!1;try{await this.setBlocks(i),se(t.signal),s&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const l=n.id!==void 0&&n.id!==""?String(n.id):void 0,u=ye(this._container);if(!s&&l!==void 0&&u.sessionKey()===tr(l)){const C=Jr(n)?await this._storeShownBlock(n):void 0,F={id:a,token:++this._showToken},T=u.show(C,F),R=t.requestShow({showId:a,navId:l,emailId:void 0,isNew:!1});c=!0,await ct("show-block-init",Promise.all([R,T?.whenReady().catch(()=>{})]),{showId:a});return}const d=r||s?await ba(this._container,String(n.id)):void 0,m=d&&(s||Jr(n))?await this._storeShownBlock({...Se(d,this._container),...n}):r||s?d:await this._storeShownBlock(n);if(se(t.signal),!m)throw new Error(`[emailmaker] show(): block ${String(n.id)} not found`);o!==void 0&&m.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(o.filter(C=>C.id!==void 0).map(C=>[C.id,Xn(C,String(m.id))])),this._prevCommand=void 0,this._lastShow=void 0;const _=m.id!==void 0?String(m.id):ke(),v={id:a,token:++this._showToken};zn(this._container);const E=s?u.reloadBlock(_,m,v):u.openBlock(_,m,v);m.id;const y=t.requestShow({showId:a,navId:_,emailId:void 0,isNew:m.id===void 0});c=!0;const k=E.whenReady().catch(C=>{if(C instanceof dt)throw C});await ct("show-block-init",Promise.all([y,k]),{showId:a})}catch(l){throw c&&t.failShow(a,l),l}}async _storeShownBlock(e){const t=lt(e,this._container,await Xt(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();se(e.signal);const t=ye(this._container);if(ee(t.sessionKey())&&!t.hasSuspended())throw new Error("[emailmaker] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:Xr,fallbackTitle:Zl(this._container)});if(se(e.signal),!n)throw gw(t.emailSaveState().error);return Oe(Wu(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=ye(this._container),t=e.current();if(!t||!ee(e.sessionKey()))throw new Error("[emailmaker] saveBlock(): no open block");return ah(t,async()=>{await t.whenReady();const n=Ar(t),r=t.get().version,i=t.get().serverId,o=typeof n.global_block=="boolean"?n.global_block:i!=null&&Qu(n.html??"").emBlockId===String(i),s=i!=null&&o?Zu(n.html,String(i),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:s,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},c=this._dataSources.blocks,l=await mw(this._container,t.get().serverId,a.html),u=t.get().serverId==null?c.create(a,{source:Xr}):c.update(String(t.get().serverId),a,{source:Xr}),d=await AE(this._container,u,m=>{m&&l(),m&&ye(this._container).current()===t&&t.get().serverId==null&&m.id!==void 0&&t.markSaved(r,String(m.id))});if(!d)throw new Error("[emailmaker] save(): block was not saved");return l(),t.markSaved(r,d.id!==void 0?String(d.id):void 0),Se(d,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=_a(e);const n=this._queuedShow(e,t).then(r=>r===Ba?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),se(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=ye(this._container);if(n!==void 0&&r.sessionKey()===tr(n))return;const i=t.code===void 0&&n!==void 0?await ba(this._container,n):void 0,o=i&&Jr(t)?await this._storeShownBlock({...Se(i,this._container),...t}):t.code===void 0&&n!==void 0?i:await this._storeShownBlock(t);if(!o)throw new Error(`[emailmaker] openBlock(): block ${String(n)} not found`);zn(this._container);const s=r.openBlockOver(o.id!==void 0?String(o.id):ke(),o);o.id,r.hasSuspended(),_e(this._container,H.ON_BLOCK_OPEN_ID).fire({block:o}),await s.whenReady().catch(a=>{if(a instanceof dt)throw r.current()===s&&(_e(this._container,H.ON_BLOCK_CLOSE_ID).fire({block:o,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),kb(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function _w(e){if(e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object")return e.meta;const t=e.catalogExtra?.meta;if(t!=null&&typeof t=="object")return t}function yw(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),i=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:i,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:_w(e)}}function Qr(e,t){return t?yw(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var td=["title","slug","type","tags","blocktags","modified","author","lock","subject","description","excerpt","status","is_template","link","renderGuid","date","date_gmt","modified_gmt","comment_status","ping_status","template","related_email","project_title","project_author","isAmp","meta"],Ew=[...td,"html","id","project","password"],a0=new Set(["html",...td,"global_block","project"]);function ww(e){if(!e||typeof e!="object")return{};const t={};e.id!=null&&e.id!==""&&(t.id=String(e.id)),e.title!=null&&e.title!==""&&(t.title=e.title),e.slug!=null&&e.slug!==""&&(t.slug=e.slug),e.type!=null&&e.type!==""&&(t.type=e.type),e.tags!=null&&(t.tags=e.tags),e.blocktags!=null&&(t.blocktags=e.blocktags),e.modified!=null&&e.modified!==""&&(t.modified=e.modified),e.author!=null&&e.author!==""&&(t.author=String(e.author)),e.lock!=null&&(t.lock=e.lock),e.subject!=null&&e.subject!==""&&(t.subject=e.subject),e.description!=null&&e.description!==""&&(t.description=e.description),e.excerpt!=null&&e.excerpt!==""&&(t.excerpt=e.excerpt),e.status!=null&&e.status!==""&&(t.status=e.status),e.is_template!=null&&(t.is_template=e.is_template),e.link!=null&&e.link!==""&&(t.link=e.link),e.renderGuid!=null&&e.renderGuid!==""&&(t.renderGuid=e.renderGuid),e.date!=null&&e.date!==""&&(t.date=e.date),e.date_gmt!=null&&e.date_gmt!==""&&(t.date_gmt=e.date_gmt),e.modified_gmt!=null&&e.modified_gmt!==""&&(t.modified_gmt=e.modified_gmt),e.comment_status!=null&&e.comment_status!==""&&(t.comment_status=e.comment_status),e.ping_status!=null&&e.ping_status!==""&&(t.ping_status=e.ping_status),e.template!=null&&e.template!==""&&(t.template=e.template),e.related_email!=null&&e.related_email!==""&&(t.related_email=e.related_email),e.project_title!=null&&e.project_title!==""&&(t.project_title=e.project_title),e.project_author!=null&&e.project_author!==""&&(t.project_author=e.project_author),e.isAmp!=null&&(t.isAmp=e.isAmp),e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object"&&(t.meta=e.meta);const n=new Set(Ew),r={};for(const i of Object.keys(e))n.has(i)||(r[i]=e[i]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Sw(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...ww(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var Vi=new WeakMap;function Iw(e){let t=Vi.get(e);return t||(t={byId:new Map,fallback:[]},Vi.set(e,t)),t}function Tw(e){Vi.delete(e)}function Aw(e,t){const{byId:n,fallback:r}=Iw(t);if(e.blockId){const i=n.get(e.blockId);if(i){n.delete(e.blockId);const o=r.indexOf(i);return o>=0&&r.splice(o,1),i}return}for(let i=r.length-1;i>=0;i--){const o=r[i],s=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,a=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(s&&a)return r.splice(i,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function Cw(e,t){const{blocks:n}=An(e);return await n.cache.getIfPresent(t)??void 0}async function Rw(e,t){if(!t.blockId)return;const n=await Cw(e,t.blockId);if(n)return Sw(n,t)}async function Ow(e,t){const n=Aw(e,t);if(n)return Qr(e,n);const r=await Rw(t,e);return r?Qr(e,r):Qr(e,void 0)}var kw=Pc("application_block_inserted"),Pw=-1e3,ja=new WeakSet;function Dw(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.type=="string"||typeof t.name=="string"||typeof t.blockId=="string"||typeof t.project=="string"||typeof t.project=="number"}function xw(e){if(!e||ja.has(e))return;ja.add(e);const t=new ve,n=fe(e);return t.addDisposable(n.addListenerAsyncPipe(kw,async(r,i)=>{const o=Dw(r)?await Ow(r,e):r;return i?i(o):o},Pw)),t.addDisposable({dispose:()=>{Tw(e)}}),t}var Mw=Tr("plugin.readBlockAutosave"),c0=U("blockDocuments.provided"),nd=U("plugin.earlyWindow");function Lw(e){return e.getOrCreateInstance(nd,()=>({depth:0}))}function Nw(e){const t=Lw(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function rd(e){return(e?.getInstance(nd)?.depth??0)>0}function id(e,t){let n,r=!1;return e(i=>{n=i,r=!0}),(i,o,s)=>{const a=e(i,o,s);if(r&&rd(t)){const c=n;queueMicrotask(()=>{i.call(s,c)})}return a}}var Zr=100,Fw=class extends ve{_container;_events;constructor(e){super(),this._container=e;const t=xw(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i,blocksRevision:o}=An(e),s=ne(e,H.ON_SHARE_ID),a=ne(e,H.ON_SHOW_PREVIEW_ID),c=ne(e,H.ON_EMAIL_CLONE_ID),l=ne(e,H.ON_BLOCK_OPEN_ID),u=ne(e,H.ON_BLOCK_CLOSE_ID),d=ne(e,H.ON_BLOCK_CLONE_ID),m=ne(e,H.ON_BLOCK_INIT_ID),_=ne(e,H.ON_BLOCK_CHANGED_ID),v=ne(e,H.ON_CODE_VALIDATE_ID),E=ne(e,H.ON_IMPORT_VALIDATE_ID),y=ne(e,H.ON_SUBJECT_CHANGED_ID),k=ne(e,H.ON_EMAIL_CHANGED_ID),C=ne(e,H.ON_PREHEADER_CHANGED_ID),F=ne(e,H.ON_SAVEBUTTON_CLICK_ID),T=ne(e,H.ON_BLOCK_SAVEBUTTON_CLICK_ID),R=ne(e,H.ON_NEXTBUTTON_CLICK_ID),A=ne(e,H.ON_SEND_LIVEPREVIEW_ID),D=ne(e,H.ON_SEND_TESTEMAIL_ID),O=ne(e,gE),h=ne(e,H.ON_CONTENT_CHANGED_ID),f=ne(e,mE),p=ne(e,H.ON_PREVIOUSBUTTON_CLICK_ID),b=ne(e,H.ON_SEND_EMAIL_MODAL_ID),x=ef(ne(e,H.ON_EMAIL_INIT_ID),S=>!S.reset),N=ne(e,H.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:V(C),handleSubjectChanged:V(y),handleValidate:V(v),handleImportValidate:V(E),handleReadEmail:V(n.handlerRead,S=>S,S=>S&&Ft(S,e)),handleSaveEmail:V(n.onSave,function({prev:S,patch:w,value:M,source:B}){const W=S?Oe(S,e):void 0;return{prev:W,patch:sn(W,Oe(w,e)),value:Oe(M,e),source:B}},S=>S?Ft(S,e):void 0),handleRemoveEmail:V(n.onRemove,({value:S,source:w})=>({value:Oe(S,e),source:w}),()=>{}),handleReadCommonBlocks:V(O,S=>S.project,S=>S?.map(w=>lt(w,e))),handleReadTemplateBlocks:V(f,S=>S,S=>S?.map(w=>lt(w,e))),handleReadBlocks:V(t.byForeignKey("project").handleRead,S=>Tn(e).requested||String(S),S=>S?.map(w=>lt(w,e))),handleReadBlock:V(t.handlerRead,S=>S,S=>S?lt(S,e):void 0),handleOpenBlock:V(l,({block:S})=>({block:Se(S,e)})),handleCloseBlock:V(u,({block:S,hasUnsavedChanges:w})=>({block:Se(S,e),hasUnsavedChanges:w})),handleCloneBlock:V(d,S=>Se({...S,html:XE(S.html)},e)),handleSaveBlock:V(t.onSave,function({prev:S,patch:w,value:M,source:B}){const W=M.global_block===!0&&M.id&&typeof M.html=="string"?{...M,html:JE(M.html,String(M.id))}:M,ie=S?Se(S,e):void 0;return{prev:ie,patch:sn(ie,Se(w,e)),value:Se(W,e),source:B}},S=>S?lt(S,e):void 0),handleRemoveBlock:V(t.onRemove,({value:S,source:w})=>({value:Se(S,e),source:w}),()=>{}),handleReadComments:V(r.byForeignKey("post").handleRead,S=>S,S=>S?.map(w=>Ui(w,e))),handleSaveComment:V(r.onSave,function({prev:S,patch:w,value:M,source:B}){const W=S?Jt(S,e):void 0;return{prev:W,patch:sn(W,Jt(w,e)),value:Jt(M,e),source:B}},S=>S?Ui(S,e):void 0),handleRemoveComment:V(r.onRemove,({value:S,source:w})=>({value:Jt(S,e),source:w}),()=>{}),handleReadEmailRevisions:V(i.byForeignKey("parent").handleRead,S=>S,S=>S?.map(w=>Yn(w,e))),handleReadEmailAutosave:V(ne(e,Nu),S=>S,S=>S?Yn(S,e):null),handleEmailAutosave:V(i.onSave,function({prev:S,patch:w,value:M,source:B}){return{value:$i(M,e),source:B}},S=>S?Yn(S,e):void 0),handleRemoveEmailAutoSave:V(i.onRemove,({value:S,source:w})=>({value:$i(S,e),source:w}),()=>{}),handleReadBlockRevisions:V(o.byForeignKey("parent").handleRead,S=>S,S=>S?.map(w=>Xn(w))),handleReadBlockAutosave:V(ne(e,Mw),S=>S,S=>S?Xn(S):null),handleBlockAutosave:V(o.onSave,({value:S,source:w})=>({value:Pa(S),source:w}),S=>S?Xn(S):void 0),handleRemoveBlockAutoSave:V(o.onRemove,({value:S,source:w})=>({value:Pa(S),source:w}),()=>{}),handleBlockInit:V(m,S=>Se(S,e)),handleBlockChanged:V(Lr(_,Zr),S=>Se(S,e)),handleEmailChanged:V(Lr(k,Zr),S=>Oe(S,e)),handleEmailInit:id(V(x,S=>Oe(S,e)),e),handlePreviousButtonClick:V(p,S=>Oe(S,e)),handleNextButtonClick:V(R,S=>Oe(S,e)),handleSaveButtonClick:V(F,S=>Oe(S,e)),handleSaveBlockButtonClick:V(T,S=>Se(S,e)),handleHtmlChanged:V(Lr(h,Zr)),handleTestEmailSend:V(D,({html:S,...w})=>({...w,code:S,compiled:{html:S,ampHtml:""}})),handleTestEmailModal:V(b,S=>Oe(S,e)),handleCloneEmail:V(c,S=>Oe(S,e)),handleShareEmail:V(s),handlePreviewEmail:V(a),handleLivePreviewEmail:V(A),handleAnalyticsEvent:V(N)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new Pt(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Bw=U("DataController"),jw=U("DataEvents");function od(e){return e.getOrCreateInstance(Bw,()=>{const t=new bw(e);return e.getInstance(Y)?.addDisposable(t),t})}function sd(e){return e.getOrCreateInstance(jw,()=>new Fw(e))}var Uw=U("plugin.pluginStart");function ad(e){return e.getOrCreateInstance(Uw,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(Y)?.addDispose(()=>t()),{done:n,finish:t}})}function $w(e){return ad(e).done}function Hw(e){const t=ad(e);return t.run===void 0&&(t.run=(e.getInstance(ao)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var Vw=U("plugin.startupShow");function Gw(e){const t=od(e),n=sd(e),r=e.getInstance(we),i=e.getInstance(Y),o={current:Promise.resolve()};e.inject(Vw,o);let s=!1;const a=r?.watch(l=>{l&&n.setOptions(l),s=(l?.plugins?.length??0)>0,o.current=o.current.catch(()=>{})}),c=r?.select(l=>l?.content).watch(l=>{if(l===void 0)return;const u=()=>(ae(Ee.showStart),t.show(l).finally(()=>ae(Ee.showEnd))),d=s?$w(e).then(u):u();d.catch(()=>{}),o.current=d});a&&i?.addDisposable(a),c&&i?.addDisposable(c)}function qw(e){const t=od(e);return{...sd(e).get(),show(n){return ae(Ee.showStart),t.show(n).finally(()=>ae(Ee.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return ae(Ee.showStart),t.showBlock(n,r).finally(()=>ae(Ee.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function cd(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function Dr(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",i=!1;for(let o=t;o<e.length;o++){const s=e[o];if(i){i=!1;continue}if(s==="\\"){i=!0;continue}if(r){s===r&&(r="");continue}if(s==='"'||s==="'"){r=s;continue}if(s==="("){n++;continue}if(s===")"&&(n--,n<0))return!1}return n===0}function Ww(e){return(t,n,r)=>Dr(t)?e(t,n,r):!1}function zw(e){return t=>Dr(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Kw(e){return(t,n,r)=>Dr(t)?cd(t)?e(t,n,r):t:!1}function Yw(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return Dr(n)?cd(n)?e(t):t:!1}}function Xw(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function Vo(e,t){const n=e.length;for(let r=0;r<n;r++){const i=e.charCodeAt(r);if(i===0||t==='"'&&i===34||t==="'"&&i===39||t===""&&(i===32||i===9||i===10||i===13||i===12||i===34||i===39||i===60||i===62||i===61||i===96))return!1}return!0}function Jw(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let i="";for(let o=0;o<e;o++){const s=r[o]%62;i+=t.charAt(s)}return i}var Qw=8,Zw=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=Jw(Qw),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},xr=new Zw;function Ua(e,t){return t!==void 0&&!Vo(e,t)?`%|{${xr.getOrCreateByKey(e)}}|%`:e}function eS(e){const t=xr.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function de(e,t,n){return t!==void 0?Vo(e,t)?e:`%|{${xr.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function tS(e){return e.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function le(e){return e.startsWith("<!--")&&e.endsWith("-->")?tS(e.slice(4,-3)):e}function nS(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const i=e.match(/\[%\s*([^%]*?)\s*%\]/);i&&(r=i[1]);const o=r.trim();return t.test(o)||n.test(o)}function rS(e,t,n){return t!==void 0?Vo(e,t)?e:`%|{${xr.getOrCreateByKey(e)}}|%`:n||Xw(e)||nS(e)?`<!--${e}-->`:e}var it=Ww(de),ot=zw(le),iS=Kw(de),oS=Yw(le),ld=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",eS),e.escape("@{","}",de,!0).unescape("<!--@{","}-->",le,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Ua,!0),e.escape("{{","}}",Ua,!0),e.createSyntax("brace-percent").escape("{%","%}",de).unescape("<!--{%","%}-->",le),e.createSyntax("brace-hash").escape("{#","#}",de).unescape("<!--{#","#}-->",le),e.createSyntax("proscript").escape("[%","%]",rS,!0).unescape("<!--[%","%]-->",le,!0),e.createSyntax("getresponse").escape("[[IF","]]",de).escape("[[if","]]",de).escape("[[ELSE]]","",de).escape("[[else]]","",de).escape("[[ENDIF]]","",de).escape("[[endif]]","",de).unescape("<!--[[IF","]]-->",le).unescape("<!--[[if","]]-->",le).unescape("<!--[[ELSE]]","-->",le).unescape("<!--[[else]]","-->",le).unescape("<!--[[ENDIF]]","-->",le).unescape("<!--[[endif]]","-->",le),e.createSyntax("expert-sender").escape("<if",">",de).escape("</if",">",de).escape("<else",">",de).escape("</else",">",de).escape("<var ",">",de,!0).unescape("<!--<if ",">-->",le).unescape("<!--</if",">-->",le).unescape("<!--<else ",">-->",le).unescape("<!--</else",">-->",le).unescape("<!--<var",">-->",le,!0),e.createSyntax("velocity").escape("#if",")",it).escape("#elseif",")",it).escape("#else","",de).escape("#foreach",")",it).escape("#macro",")",it).escape("#set",")",iS,!0).escape("#parse",")",it).escape("#include",")",it).escape("#evaluate",")",it).escape("#end","",de).escape("#break","",de).escape("#stop","",de).unescape("<!--#macro","-->",ot).unescape("<!--#if","-->",ot).unescape("<!--#elseif","-->",ot).unescape("<!--#else","-->",le).unescape("<!--#foreach","-->",ot).unescape("<!--#parse","-->",ot).unescape("<!--#include","-->",ot).unescape("<!--#evaluate","-->",ot).unescape("<!--#end","-->",le).unescape("<!--#break","-->",le).unescape("<!--#stop","-->",le).unescape("<!--#set","-->",oS,!0),e.createSyntax("mailchimp").escape("*|","|*",de).unescape("<!--*|","|*-->",le)},Gi="bare",sS=new Map;function aS(e){return e?sS.get(e)??Gi:Gi}var ud=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function $a(e){return ud.includes(e)}function zt(e){return e==="bare"||e==="html-comment"}function ei(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function cS(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!zt(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[l,u]of[["output",r.output],["editor",r.editor]])if(u!==void 0&&!zt(u))return t(`templateDirectives.${l}: unknown form "${String(u)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!ei(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[l,u]of Object.entries(r.syntaxes))if(!(!$a(l)||u===void 0||zt(u))){if(!ei(u))return t(`templateDirectives.syntaxes.${l}: expected a form or an object, configuration ignored.`),n;for(const d of["output","editor"]){const m=u[d];if(m!==void 0&&!zt(m))return t(`templateDirectives.syntaxes.${l}.${d}: unknown form "${String(m)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const i=r.output??Gi;let o=r.editor;i==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),o=void 0);const s=[];if(r.syntaxes)for(const l of Object.keys(r.syntaxes)){if(!$a(l)){t(`templateDirectives.syntaxes: unknown syntax id "${l}", entry ignored.`);continue}s.push(l)}else s.push(...ud);const a={},c={};for(const l of s){const u=r.syntaxes?.[l],d=ei(u)?u:void 0,m=(zt(u)?u:d?.output)??i;let _=d?.editor??o??m;m==="bare"&&_==="html-comment"&&(t(`templateDirectives.syntaxes.${l}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),_="bare"),a[l]=m,c[l]=_}return{output:a,editor:c}}function dd(e,t,n,r){for(let i=t;i<n;i++){const o=e[i];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?o===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(o)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):o==="<"?r.insideTag=!0:o===">"?r.insideTag=!1:r.insideTag&&(o==='"'||o==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=o,r.unquotedAttr=!1):r.insideTag&&/\S/.test(o)&&r.attributeQuoteChar===void 0&&e[i-1]==="="&&!['"',"'","`"].includes(o)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function Qt(e,t){return e.start<t.end&&t.start<e.end}function Ha(e,t,n,r,i=[]){if(n&&(t=t.filter(u=>u.isVariable)),!t.length)return[];const o=t.flatMap(u=>u.match(e).flatMap(d=>!Number.isInteger(d.start)||!Number.isInteger(d.end)||d.start<0||d.end>e.length||d.start>=d.end?[]:[{range:d,mapFn:u.mapFn,overrideBuiltins:u.overrideBuiltins,syntax:u.syntax,isVariable:u.isVariable}])).sort((u,d)=>u.range.start-d.range.start||u.range.end-d.range.end),s=[],a=i.slice().sort((u,d)=>u.start-d.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(const{range:u,mapFn:d,overrideBuiltins:m,syntax:_,isVariable:v}of o){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):dd(e,l,u.start,c),l=u.end,a.some(C=>Qt(C,u)))continue;const E=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,y=e.substring(u.start,u.end),k=d(y,E,c.insideTag);k!==!1&&k!==y&&(s.push({range:u,text:k,overrideBuiltins:m,syntax:_,isVariable:v}),a.push(u))}return s.sort((u,d)=>u.range.start-d.range.start||u.range.end-d.range.end)}function lS(e,t){const n=t.reduce((a,{mapFn:c,start:l,end:u,syntax:d,isVariable:m})=>(a[l]||(a[l]=[]),a[l].push({value:u,mapFn:c,syntax:d,isVariable:m}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),i=new RegExp(r,"g"),o=[];let s;for(;(s=i.exec(e))!==null;){const a=s[0];o.push({start:s.index,startToken:a,endTokens:n[a]})}return o}function ti(e,t,n,r,i=!1){const o=[];if(n&&(t=t.filter(l=>l.isVariable)),!t.length)return o;const s=lS(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let l=0;l<s.length;l++){const{start:u,startToken:d,endTokens:m}=s[l];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):dd(e,c,u,a),c=u;const _=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let v=!1;for(const{mapFn:E,value:y,syntax:k,isVariable:C}of m){let F=u+d.length,T=e.indexOf(y,F);for(;T!==-1;){let R=T,A=u+d.length,D=0;for(;R!==-1;){const b=e.indexOf(d,A);if(b!==-1&&b<R)D++,A=b+d.length,R=e.indexOf(y,A);else if(D>0)D--,A=R+y.length,R=e.indexOf(y,A);else break}if(R<0)break;const O=R+y.length,h=e.substring(u,O),f=E(h,_,a.insideTag);if(f===!1){F=T+Math.max(y.length,1),T=e.indexOf(y,F);continue}(i||f!==h)&&o.push({range:{start:u,end:O},text:i?h:f,syntax:k,isVariable:C});const p=s.findIndex(({start:b})=>b>=O);p>l?l=p-1:l=s.length,v=!0;break}if(v)break}}return o}function Vn(e,t){if(!t.length)return e;const n=t.slice().sort((i,o)=>o.range.start-i.range.start);let r=e;for(const{text:i,range:o}of n)r=r.slice(0,o.start)+i+r.slice(o.end);return r}var uS=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=ld){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,i,o,s){return t.push({start:r,end:i,mapFn:o,isVariable:s,syntax:this.syntax||r}),this},unescape(r,i,o,s){return n.push({start:r,end:i,mapFn:o,isVariable:s,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let i=!1;const o={dispose:()=>{i||(i=!0,this._escapeMatchers=this._escapeMatchers.filter(s=>s!==n),this._unescapeMatchers=this._unescapeMatchers.filter(s=>s!==r))}};return this.addDisposable(o),o}_collectMappings(e,t,n){const r=ti(e,this._escapes,t,n),i=Ha(e,this._escapeMatchers,t,n),o=i.filter(c=>c.overrideBuiltins).map(c=>c.range),s=r.filter(c=>!o.some(l=>Qt(l,c.range))),a=i.filter(c=>c.overrideBuiltins||!s.some(l=>Qt(c.range,l.range)));return[...s,...a].sort((c,l)=>c.range.start-l.range.start||c.range.end-l.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=ti(e,this._unescapes,t),r=Ha(e,this._unescapeMatchers,t,!1),i=r.filter(a=>a.overrideBuiltins).map(a=>a.range),o=n.filter(a=>!i.some(c=>Qt(c,a.range))),s=r.filter(a=>a.overrideBuiltins||!o.some(c=>Qt(a.range,c.range)));return[...o,...s].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?i=>i!==void 0&&n.has(i):i=>aS(i)==="html-comment";return this._collectRevertMappings(e,t).filter(i=>i.isVariable||!r(i.syntax))}getDetectedMappings(e,t,n){return ti(e,this._escapes,t,n,!0)}getEscapedText(e,t){return Vn(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return Vn(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=o=>o===void 0?void 0:t[o],r=Object.values(t);let i=e;return r.includes("bare")&&(i=Vn(i,this._collectRevertMappings(i).filter(o=>n(o.syntax)==="bare"))),r.includes("html-comment")&&(i=Vn(i,this._collectMappings(i).filter(o=>!o.isVariable&&n(o.syntax)==="html-comment"&&o.text.startsWith("<!--")&&o.text.endsWith("-->")))),i}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}},fd="em___script",Zt=`<${fd}`,qi=`</${fd}>`;function Va(e){return e.replace("<script",Zt).replace("<\/script>",qi)}var Ga=new uS(e=>{e.escape("<script","<\/script>",t=>Va(t)).unescape(Zt,qi,t=>t.replace(Zt,"<script").replace(qi,"<\/script>")),e.escape("<script","/>",t=>Va(t)).unescape(Zt,"/>",t=>t.replace(Zt,"<script")),ld(e)});function dS(e){const t=cS(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return rl();const n=new Set(Object.keys(t.output).filter(i=>t.output[i]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:i=>Ga.normalizeToPolicy(i,t.editor),toOutputForm:i=>Ga.normalizeToPolicy(i,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:nl(r)}}function fS(e){let t;e.injectFactory(oo,()=>{const n=e.getInstance(ge)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:dS(n)}),t.policy})}var pS=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function hS(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function mS(e,t){const n=[];for(const r of e.awaits?.services??[])for(const i of t.get(r)??[])i!==e&&n.push(i);return n}function pd(e){const t=hS(e),n=[],r=new Set,i=[],o=new Set,s=a=>{if(!r.has(a)){if(o.has(a)){const c=i.indexOf(a);throw new pS([...i.slice(c),a].map(l=>l.name))}o.add(a),i.push(a);for(const c of mS(a,t))s(c);i.pop(),o.delete(a),r.add(a),n.push(a)}};for(const a of e)s(a);return n}var gS=[{name:"rest.client",setup:dE},{name:"auth.oauth",setup:Kd},{name:"rest.identityHeaders",setup:eE},{name:"rest.localeHeader",setup:sE},{name:"lifetime.destroyable",provides:[Lo],setup:ry},{name:"appInit",provides:[Xe,po],setup:mp},{name:"config",provides:[ge],setup:ty},{name:"templateDirectives",provides:[oo],setup:fS},{name:"email.documents",setup:wy},{name:"show.initPipeline",provides:[Fe],setup:fE},{name:"show",setup:Gw},{name:"locale.service",provides:[vt],setup:Xy},{name:"locale.fromConfig",awaits:{services:[ge,vt]},setup:Jy},{name:"canvas.early",setup:Xb},{name:"canvas.previewSettings",setup:f_},{name:"canvas.sandboxExtensions",setup:h_},{name:"canvas.sandboxScriptRelay",setup:v_},{name:"canvas.headerSync",provides:[xo],setup:Zb},{name:"canvas.headersAfterRecovery",setup:e_},{name:"canvas.ampSync",setup:Wg},{name:"canvas.moduleBridge",setup:Sv},{name:"canvas.port",setup:nv},{name:"canvas.images",setup:ev},{name:"canvas.edits",setup:Kb},{name:"canvas.surfaceFollowsSession",setup:Db},{name:"canvas.blockContent",setup:Pb},{name:"canvas.sandboxFill",provides:[Do],setup:L_},{name:"canvas.reactions",setup:Yb}],qa;function Go(e){const t=e.getInstance(we);if(t)return t;e.getInstance(Y)||e.inject(Y,new ve);const n=ce();e.inject(we,n),qa??=pd(gS);for(const r of qa)r.setup(e);return n}function vS(e){}var bS=[{name:"save.previewFollow",setup:vS}],Wa=U("plugin.lateUnitsInstalled");function _S(e){if(!e.getInstance(Wa)){e.inject(Wa,!0);for(const t of pd(bS))t.setup(e)}}function yS(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function ES(e){if(!e)return;const t=no(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(r=>typeof r=="string"?r.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(r=>/^project_\d+$/.test(r))?.replace(/^project_/,"")||void 0}var wS=Bt(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!Ne(t,i.user),a=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(Ve)||!i.getAuthToken)&&!(!o&&!s&&!a))try{const c=await i.getAuthToken(i.user,i.project);e.inject(zd,Promise.resolve(c||""));const l=ES(c);if(!l)return;e.inject(ff,l);const u=e.getInstance(Xe),d=u?await u.catch(()=>{}):void 0;e.inject(Xe,Promise.resolve(yS(l,d)))}catch{}}}});function SS(e,t){if(e.getInstance(ts))return;e.inject(ts,!0);const n=Pe(e,H.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var IS=Bt(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!Sn(r)){t&&(V_(e),Mo(r)),t=void 0;return}const o=Rr(r);if(!o||t===o&&e.getInstance(Ve))return;t=o,e.inject(Ve,o);const s=e.getInstance(Y);s&&SS(e,s)}}}),TS=Bt(e=>{const t=e.getInstance(Y),n=Pe(e,Oc),r=V(n),i=t.addDisposable(new Pt(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function hd(e,t,n=!0){const r=e,i=t;for(const o of Object.keys(i)){const s=i[o];s!=null&&(n&&typeof s=="object"?r[o]=hd(r[o]||{},s,!0):r[o]=s)}return e}async function AS(e){const t=(await Uf(()=>import("./static/esm/2490dab8.js").then(n=>Sc(n.default)),[],import.meta.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var md=U("EditorOptions"),Wi=Lf;function CS(e){const t=typeof e.font_family=="string"?`${e.font_family}, sans-serif`:void 0,n=e.word_wrap===void 0?void 0:e.word_wrap?"on":"off";return{tabSize:e.tab_size,fontFamily:t,fontSize:e.font_size,wordWrap:n,insertSpaces:e.insert_spaces,minimap:{enabled:e.minimap}}}function RS(e){return e.getOrCreateInstance(md,()=>{const t=ce(Wi);let n=Wi.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(AS(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function OS(e){return e?.getInstance(md)?.get()??Wi}function kS(e,t={}){const n=RS(e);n.set(hd({...n.get()},CS(t)))}function PS(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function DS(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var xS=U("plugin.publicConfig");function zi(e){return e.getInstance(ge)?.get()??{}}function za(e){return e.getInstance(ge)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function Ka(e){const t=Cu(e),n=zi(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:DS(OS(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Ya(e){return e.getInstance(ge)?.get()!==void 0}function MS(e){const t=Rc(),n=_e(e,kc);let r,i,o=!1;const s=async()=>{try{return e.getInstance(Xe)===void 0?{}:(await e.getInstanceAsync(Xe))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:d=!1}={})=>{await e.getInstance(ge)?.ready(),Nc(e).set(zi(e).revisionService===!0);const{codeModeDirection:m,editor:_}=zi(e);_&&kS(e,PS(_)),m!==void 0&&!(d&&m===i)&&(i=m,m==="none"?xi(e,!1):(xi(e,!0),a_(e,m)))},c=async()=>{if(!Ya(e))return;const d=Ka(e),m=JSON.stringify(d);m!==r&&(r=m,await n.fire(d))},l=async d=>{const m=e.getInstance(ge),_={advancedConfigs:za(e).advancedConfigs,serverSide:await s(),user:d};m?.setAdvancedConfigs({..._.advancedConfigs,..._.user?.advancedConfigs});const v=m?.layers().user.mode;m?.replace(_.user?.mode===void 0&&v!==void 0?{..._.user,mode:v}:_.user,"user"),m?.replace(_.serverSide,"server"),await a(),await c()},u=d=>{const{commonStyles:m,..._}=d;return"commonStyles"in d&&l_(e,m===void 0?void 0:m),_};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:s,getConfig:()=>Ya(e)?Ka(e):{},setConfig:t.decorate(async d=>{await l(u(d))}),updateConfig:t.decorate(async d=>{const m=u(d);await l({...za(e).user,...m})}),announceAssembled(){o||(o=!0,e.getInstance(ge)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function gd(e){return e.getOrCreateInstance(xS,()=>MS(e))}function LS(e){const t=gd(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var NS=Bt(e=>{const t=e.getInstance(Y),n=t.addDisposable(new Je),r=t.addDisposable(new Je),i=vn(e,kc),o=V(n.event),s=V(r.event),a=id(V(i.event),e),c=t.addDisposable(new Pt(o)),l=t.addDisposable(new Pt(s)),u=t.addDisposable(new Pt(a));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(d){c.setListener(d.handleSetOptions),l.setListener(d.handleOptionsChanged),u.setListener(d.handleConfigChanged),gd(e).announceAssembled(),await n.fire(d),await r.fire(d)},dispose(){}}}),ni,vd="core";function FS(){const e=window.__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([vd],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function BS(e){const t=window.__emailmaker__?.require?.warm;return typeof t!="function"?Cn().then(()=>{}):t([vd],e)}function Cn(){return ni===void 0&&(ni=FS().then(e=>(ln()&&e.installDiagnostics().catch(t=>{}),e))),ni}var ri=null,ii=null;async function jS(e){typeof e?.prefetch=="function"&&await e.prefetch()}function qo(){return ri||(ri=Cn().then(()=>{})),ri}function bd(e){return ii||(ii=jS(e)),ii}function US(){return bd(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}function $S(){const e=typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function HS(e){return Promise.all([qo(),bd(e)]).then(()=>{})}function VS(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Xa(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>BS(t?{priority:t}:void 0)).then(()=>(Oo(t?{priority:t}:void 0),n?qo():void 0)).catch(()=>{})}function GS(e){const t=VS(e);if(t==="eager")Xa(e);else if(t==="idle"){const n=()=>Xa(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var _d="PluginRegistry";function qS(e=nf()){return e.getOrCreateInstance(_d,()=>new Kf)}var Ki=new Yf(()=>qS());function WS(e){const t=je(e),n=wr(e);return{dispose:()=>{Ae("ui",()=>n.disposeAll()),Ae("commands",()=>t.disposeAll())}}}function zS(e,t){const n=mt(e);return t.onLifecycle(r=>n.handle(r))}var KS=["Commands","Ui","Agent","Document"],yd=new Set(["Agent","Document"]),Ja=new Map;function YS(e,t){for(let n=e;typeof n=="function";n=Object.getPrototypeOf(n))if(Bl(n,t))return!0;return!1}function XS(e,t,n){Ja.get(e)!==t&&Ja.set(e,t)}function JS(e,t){if(YS(t,e))return;const n=typeof t=="function"?t.name||"anonymous":typeof t;if(yd.has(e)){XS(e,t,n);return}}function QS(e){const t=KS.map(n=>e.on(n,r=>JS(n,r)));return{dispose:()=>t.forEach(n=>n.dispose())}}var Qa=new WeakMap,Za=new WeakSet;function ZS(e,t,n){const r=e.getInstance(Y);if(r?.isDisposed()){Ae("ui",()=>wr(e).disposeAll()),Ae("commands",()=>je(e).disposeAll());return}Qa.get(e)?.dispose();const i=new ve([zS(e,t),QS(n)]);Qa.set(e,i),r?.addDisposable(i),r&&!Za.has(e)&&(Za.add(e),r.addDisposable(WS(e)))}function eI(e){return e?.lockEditor===!0}var ec={text:"text",img:"image",a:"link",button:"button",div:"container",vindent:"spacer",video:"video",table:"table",customTable:"table",structure:"row",column:"column",td:"cell",var:"variable",countdown:"countdown",carousel:"carousel",accordion:"accordion",social:"social",floatBlock:"floatingBlock"};function tI(e){return typeof e=="string"&&Object.hasOwn(ec,e)&&ec[e]||"none"}function an(e,t,n){let r,i;const o=()=>{const s=e.getInstance(t);return s===void 0||r?r!==void 0:(r=n(s),!0)};return o()||(i=e.onInject(s=>{s===t&&o()&&i?.dispose()})),{dispose:()=>{i?.dispose(),r?.dispose()}}}function nI(e){const t=$t(e),n={editor:!1,document:!1},r=()=>Wt(t,{readOnly:n.editor||n.document});r();const i=[Co(e).watch(o=>Wt(t,{headless:o})),Cr(e).watch(({isCodeMode:o})=>Wt(t,{codeMode:o})),an(e,ge,o=>o.watch(s=>{n.editor=eI(s),r()})),an(e,jt,o=>{let s,a;const c=()=>{const m=o.sessionKey(),_=m!==void 0&&!ee(m)?o.current()?.get().attributes:void 0;n.document=_?.lock===!0&&!jc(e,_),r()},l=()=>{const m=o.sessionKey();Wt(t,{documentOpen:m!==void 0,documentKind:m===void 0?void 0:ee(m)?"block":"email"});const _=o.current();_!==s&&(a?.(),s=_,a=_?.subscribe(c)),c()};l();const u=o.subscribe(l),d=vp(e,c);return{dispose:()=>{u(),a?.(),d.dispose()}}})];return i.push(an(e,Ic,o=>{const s=()=>{const l=o.getState(),u=Ce(t)?.documentKind==="block"?l.blockSlice:l.emailSlice;Wt(t,{selection:tI(u?.elementSettings?.type)})};s();const a=t.select(l=>l?.documentKind).watch(s),c=o.subscribe(s);return{dispose:()=>{c(),a.dispose()}}})),{dispose:()=>i.forEach(o=>o.dispose())}}var rI=["handleAIImageRequest","handleAITextRequest","handleAnalyticsEvent","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleImportValidate","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],iI=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],ur=new Map([...rI.map(e=>[e,"event"]),...iI.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),oI=new Map([["use","use `useAsync()` or await `ready` first"]]);function sI(e){return oI.get(e)??"await `ready` first"}var aI=new Set(["async","queued"]),cI=Symbol.for("emailmaker.earlyCtxPlaceholder");function tc(e){return e[cI]=!0,e}function lI(e){return new Error(`[emailmaker] ${e}() is not available in a plugin constructor: the editor core is still loading. Call it from init() or later (${sI(e)}).`)}function uI(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function dI(e){return[...ur].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function fI(e,t){for(const n of dI(e)){const r=ur.get(n);if(r!==void 0&&aI.has(r)){const i=async(...o)=>{await t;const s=e[n];if(typeof s!="function"||s===i)throw uI(n);return s.apply(e,o)};e[n]=tc(i);continue}e[n]=tc(()=>{throw lI(n)})}}function pI(e,t,n){e.getInstanceAsync(Dt).then(()=>{vn(e,H.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function hI(e,t){e.getInstanceAsync(Dt).then(()=>{vn(e,H.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var mI=Bt(e=>{let t;function n(){return new Promise(i=>{const o=e.getOrCreateInstance(co,()=>new Set),s=()=>{o.delete(s),i()};o.add(s)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(i){const o=e.getInstance(bn),s=e.getInstance(_d);if(!t){t=new zf(o,s,{ensureHostRuntimeReady:US,explainScriptFailure:$S,openEarlyWindow:()=>Nw(e),reportLoadFailure:l=>hI(e,l)}),e.inject(ao,t),ZS(e,t,s);const c=t.onLifecycle(l=>{l.type==="create:error"&&pI(e,l.name,l.error)});e.getInstance(Y)?.addDisposable(c),e.getInstance(Y)?.addDisposable(nI(e))}const a=i?.plugins||[];o&&(Co(e),a.length>0&&fI(o,n()),await t.setPlugins(a))},instance:{use(i){return typeof i=="function"?r().useByCtor(i):r().useByKey(i)},useAsync(i){return r().useAsync(i)},waitPlugin(i){return r().waitFor(i)}},dispose(){t?.dispose(),t=void 0}}}),gI=class{_context;constructor(e){this._context=e}tools(){return xn(this._context.container).tools()}invoke(e,t,n){return xn(this._context.container).invoke(e,t,n)}turn(e){return xn(this._context.container).turn(e)}undoTurn(){return xn(this._context.container).undoTurn()}},Ed=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const i=this._listeners.indexOf(r);i>=0&&this._listeners.splice(i,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},vI=U("ELEMENT_INSERT_HTML_PIPELINE"),bI=U("BLOCK_INSERT_HTML_PIPELINE"),_I="application_block_inserted",yI=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(bI,()=>new Ed).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(yn,()=>new _n),i=n?e.bind(n):e;return r.addListener(_I,i,t)}},EI=class{_context;constructor(e){this._context=e}register(e,t){const n=this._context.container,r=mt(n).current(),i={},o={};for(const[s,a]of Object.entries(e)){const{run:c,...l}=a;if(typeof c!="function")throw new Error(`Command "${s}" of "${r.name}" has no \`run\`; declare it with defineCommand({ title, run }).`);i[s]=l,o[s]=c}return je(n).register(r,i,o,t)}run(e,...t){return je(this._context.container).run(e,t[0],{caller:"plugin"})}has(e){return je(this._context.container).has(e)}},wI=class{_context;constructor(e){this._context=e}onWillSave(e){const t=this._context.container;return Ye(t).onWillSave(mt(t).current(),e)}onDidChange(e){const t=this._context.container;return Ye(t).onDidChange(mt(t).current(),e)}get selection(){return Ye(this._context.container).selection}transaction(e){return To(this._context.container).group(e)}},Wo=U("ComponentRegistry"),SI=U("ComponentRegistryGate");function zo(){return xt.getOrCreateInstance(SI,()=>({pending:[]}))}function II(e=Wo){return zo().factory!==void 0||xt.getInstance(e)!==void 0}function Yi(e,t,n=Wo){if(II(n)){t(dr(e,n));return}zo().pending.push(()=>t(dr(e,n)))}function dr(e,t=Wo){const n=xt.getInstance(t);if(n)return n;const r=zo().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return xt.getOrCreateInstance(t,r)}var TI=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=o=>{if(!n){n=!0;for(const s of t)s.dispose();e(o)}};t.push(this._container.addService(Rn,{execute:o=>{r(o.value.map(s=>({name:s.name,html:s.html})))}}));const i=this._container.getInstance(Gd)?.watch(o=>{o&&r([])});i&&(n?i.dispose():t.push(i))})}update(e,t){const n=this._container;return n.addService(Rn,{execute:r=>{const i=dr(n),o=r.value.find(s=>s.name===e);if(o){const{icon:s,title:a,fallbackTooltip:c,...l}=t;s&&(o.icon=i.getReactNode(s)),a&&(o.title=i.getReactNode(a)),c&&(o.fallbackTooltip=i.getReactNode(c)),Object.assign(o,l)}}})}delete(e){this._container.addService(Rn,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container;return n.addService(Rn,{execute:r=>{const i=dr(n);r.value.splice(t??r.value.length,0,{...e,title:i.getReactNode(e.title),icon:i.getReactNode(e.icon),fallbackTooltip:i.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(vI,()=>new Ed).add(e,t??0,n)}handleInject(e,t,n){return Ot(this._container,uf).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},AI=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(yn,()=>new _n)}send(e,t,n){this._messageService.send(e,t,n)}sendAsync(e,t,n=!0){return this._messageService.sendAsync(e,t,n)}addListener(e,t,n){return this._messageService.addListener(e,t,n)}addListenerAsync(e,t,n=0){return this._messageService.addListenerAsync(e,t,n)}onInit(e,t=!0,n=0){return this._messageService.onInit(e,t,n)}isInited(){return this._messageService.isInited()}};function CI(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function nc(e,t){if(!t)return;const n=r=>r===void 0?void 0:e.getReactNode(r);return{...t,footer:n(t.footer),okText:n(t.okText),cancelText:n(t.cancelText),closeIcon:n(t.closeIcon)}}var RI=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ot(t,Tf),this._closeModalEmitter=Ot(t,xf),this._updateModalEmitter=Ot(t,Pf)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Yi(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:nc(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Yi(this._container,r=>{const i=o=>o===void 0?void 0:r.getReactNode(o);this._updateModalEmitter.fire(CI({...t,content:i(t.content),title:i(t.title),id:e,modalProps:nc(r,n)}))})}};function Gn(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var OI=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=i=>{this._loadedSettled||(this._loadedSettled=!0,r(i))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=i=>{this._readySettled||(this._readySettled=!0,r(i))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},kI=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(yn,()=>new _n)}_createScriptHandle(e,t){const n=this._messageService.addListener(so,i=>{if(i.key===e){if(i.phase==="load"&&i.status==="success"){r.resolveLoaded();return}if(i.phase==="ready"&&i.status==="success"){r.resolveReady();return}if(i.phase==="load"){r.rejectLoad(new Error(i.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(i.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new OI(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(Tt,{...Gn(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(Tt,{...Gn(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(Tt,{...Gn(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(Tt,{...Gn(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},PI=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function Xi(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&PI.has(t)}function wd(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}return`nohwcrypto-${Date.now()}`}function oi(){return`__settingsPanel:${wd()}`}function si(e,t){return{type:e,props:t}}function DI(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!Xi(e)}function rc(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(Xi(t)){const r=oi();return n(e.add(r,t)),si(r,{})}if(typeof t=="function"){const r=oi();return n(e.add(r,t)),si(r,{})}if(DI(t)){const r=t.type;if(typeof r=="string")return t;if(Xi(r)||typeof r=="function"){const i=oi();return n(e.add(i,r)),si(i,t.props)}return t}return t}var xI=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=e.instanceKey??wd();Yi(this._container,n=>{const r=s=>this._trackRegistration(s),i=rc(n,e.content,r),o=e.advancedTabs?.map(s=>({...s,content:rc(n,s.content,r)}));Ot(this._container,es).fire({...e,content:i,advancedTabs:o,instanceKey:t,type:mf})})}closeSettingsPanel(){this._clearPanelRegistrations(),Ot(this._container,es).fire(null)}},MI=class{_context;constructor(e){this._context=e}get apiVersion(){return this._service().apiVersion}supports(e,t){return this._service().supports(e,t)}addViews(e,t){return this._service().addViews(this._owner(),e,t,this._context)}addItem(e){return this._service().addItem(this._owner(),e)}open(e,...t){return this._service().open(e,t[0])}_service(){return wr(this._context.container)}_owner(){return mt(this._context.container).current()}},Sd=Io({SandboxScriptApi:kI,ElementsApi:TI,BlocksApi:yI,MessageService:AI,SettingsPanelApi:xI,ModalApi:RI,Commands:EI,Ui:MI,Agent:gI,Document:wI});function ai(e,t,n,r={}){const i=Object.assign({},e);for(const[o,s]of Object.entries(t))if(s!==void 0)if(n.includes(o)&&typeof s=="object"&&s!==null){const a=i[o],c=r[o]??{};i[o]=Object.assign({},typeof a=="object"&&a!==null?a:c,s)}else i[o]=s;return i}var Le={border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},borderRadiusCards:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},padding:{all:null,top:null,right:null,bottom:null,left:null}},LI={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},ci={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:24,fontSizeDim:"px",lineHeight:32,lineHeightDim:"px",color:"#333333",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},ic={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},yt={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:Le.border,borderRadius:Le.borderRadius,textAlign:"center",padding:Le.padding},oc={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:Le.padding},li={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:Le.border,borderRadius:Le.borderRadiusCards};function NI(e){return{...LI,...e}}function FI(e){return{...ci,...e,bold:e?.bold??ci.bold,italic:e?.italic??ci.italic}}function BI(e){return{...ic,...e,underline:e?.underline??ic.underline}}function jI(e){return{...yt,...e,bold:e?.bold??yt.bold,italic:e?.italic??yt.italic,border:{...yt.border,...e?.border},borderRadius:{...yt.borderRadius,...e?.borderRadius},padding:{...yt.padding,...e?.padding}}}function UI(e){return{...oc,...e,padding:{...oc.padding,...e?.padding}}}function $I(e){return{...li,...e,border:{...li.border,...e?.border},borderRadius:{...li.borderRadius,...e?.borderRadius}}}function ui(e={}){return{backgroundColor:e.backgroundColor||"",backgroundImage:(e.backgroundImage||[]).map(t=>({type:"url",value:t?.value||""})),backgroundPositionX:e.backgroundPositionX||"",backgroundPositionY:e.backgroundPositionY||"",backgroundRepeat:e.backgroundRepeat||"",backgroundSize:e.backgroundSize||"",backgroundColorContent:e.backgroundColorContent||"",textStrong:e.textStrong||!1,textItalic:e.textItalic||!1,textUnderline:e.textUnderline||!1,width:e.width,responsive:e.responsive}}function sc(e){let t={...io};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function di(e){return{text:NI(e.text),headings:FI(e.headings),links:BI(e.links),buttons:jI(e.buttons),block:UI(e.block),cards:$I(e.cards)}}var Ji=U("EmailSettingsPort");function HI(e){return e?.getInstance(Ji)}var VI=1e4,Id=class{_editor;_layoutSettingsChanged=new gi;_contentStylesChanged=new gi;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentLayoutSettings()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentContentStyles()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_replayToEarlyPlugin(e,t){if(!rd(this._editor.container)||!At(this._editor.container)?.current()?.get().attributes.is_inited)return;const n=t();queueMicrotask(()=>e(n))}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(Ji);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return ui(this._settings().read())}_getCurrentContentStyles(){const e=At(this._editor.container)?.current()?.get().attributes.common_styles;return di(sc(e))}_getLayoutSnapshot(e){return JSON.stringify(e)}_getContentSnapshot(e){return JSON.stringify(e)}async _ensureMessageSubscription(){if(!this._messageSubscription){if(this._messageSubscriptionPromise)return this._messageSubscriptionPromise;this._messageSubscriptionPromise=(async()=>{if(await this._editor.container.getInstanceAsync(Ji),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(yn,()=>new _n),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const i=r?.data,o=i?.operation;if(o===K.APPLICATION_EMAIL_SETTINGS_SET){const c=ui(i?.settings),l=this._getLayoutSnapshot(c);l!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=l,this._layoutSettingsChanged.fire(c));return}if(o!==K.APPLICATION_COMMON_STYLES_UPDATE)return;const s=di(r.data?.settings?.commonStyles??{...io}),a=this._getContentSnapshot(s);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=ui(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=VI){const t=At(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,i=Pe(r,H.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},l=i(()=>{s||(s=!0,c(),l.dispose(),o())});a=setTimeout(()=>{s||(s=!0,l.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=At(this._editor.container)?.current();if(!t)return;const n=sc(t.get().attributes.common_styles);e.text!==void 0&&(n.text={...n.text||{},...e.text}),e.headings!==void 0&&(n.headings={...n.headings||{},...e.headings}),e.links!==void 0&&(n.links={...n.links||{},...e.links}),e.buttons!==void 0&&(n.buttons=ai(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:Le.border,borderRadius:Le.borderRadius,padding:Le.padding})),e.block!==void 0&&(n.block=ai(n.block||{},e.block,["padding"],{padding:Le.padding})),e.cards!==void 0&&(n.cards=ai(n.cards||{},e.cards,["border","borderRadius"],{border:Le.border,borderRadius:Le.borderRadiusCards}));const r=JSON.stringify(n);Mt(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const i=di(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},GI={...Sd,...Io({EmailSettingsApi:Id})};function qI(e){const t=e;return yd.has(e)&&Ki.has(t)&&!Bl(Ki.get(t),e)}function WI(e){Ki.addAll(Object.fromEntries(Object.entries(e).filter(([t])=>!qI(t))))}var zI={...Sd},l0={...zI,...Io({EmailSettingsApi:Id})},KI={...GI};function YI(){WI(KI)}var XI=[Bt(()=>{YI()}),TS,NS,IS,yf,wS,kf];async function JI(){return(await Cn()).asyncMixins}var QI=mI,ZI=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await JI()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(bn);Object.assign(o,t.instance||{});for(const s of e.getInstance(co)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},eT=Af([...XI]);function fi(){let e,t=!1;const n=new Map,r=new Map;function i(){for(const o of r.values())o();r.clear()}return{event(o,s,a){const c=Symbol("subscription");return t||(n.set(c,{listener:o,priority:s,thisArg:a}),e&&r.set(c,e(o,s,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(o){i(),e=o;for(const[s,{listener:a,priority:c,thisArg:l}]of n)r.set(s,o(a,c,l))},dispose(){t=!0,i(),n.clear(),e=void 0}}}function tT(e){const t=fi(),n=fi(),r=fi();return e.getInstance(Y)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(Dt).then(i=>{t.attach(i.onNotify),n.attach(i.onError),r.attach(i.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(i){const o=e.getInstance(Dt);if(o){o.notify(i);return}e.getInstanceAsync(Dt).then(s=>s.notify(i),()=>{})}}}var Td=U("CodeErrors"),nT=[];function rT(e){return e?.getInstance(Td)?.get()??nT}function iT(e){return e?.getInstance(Td)!==void 0}function oT(e){const t=Vl(e);let n;const r=()=>{const o=e.getInstance(ge);return o&&!n&&(n=o.watch(s=>t.set(s?.agent??{}))),n!==void 0},i=r()?void 0:e.onInject(o=>{o===ge&&r()&&i?.dispose()});return{dispose:()=>{i?.dispose(),n?.dispose()}}}function sT(e){const t=Ye(e);return an(e,jt,n=>{let r,i;const o=()=>{const c=n.sessionKey();c!==void 0&&t.emitChange({kind:ee(c)?"block":"email"})},s=()=>{const c=n.current();c!==r&&(i?.(),r=c,i=c?.subscribe(o),c&&o())};s();const a=n.subscribe(s);return{dispose:()=>{a(),i?.()}}})}function aT(e,t){if(e===t)return!0;try{return Ne(JSON.parse(e||"{}"),JSON.parse(t||"{}"))}catch{return!1}}var u0=U("planFeatures.source");function pi(e){return Re(e)?.current()}function cT(e){return Ce($t(e))?.readOnly===!0}var lT=()=>ue("readOnly","The document is read-only.");function uT(e,t){return!1}var dT=e=>ue("lockedByPlan",e);function fT(e,t,n){return uT(e,t)?dT(`Working with ${n} is not available on the current plan.`):void 0}function pT(e){return fT(e,"undo_redo","undo and redo")}var hT=bf+Cf;function Ad(e){const t=fe(e);return t.isInited()&&!!t.getTarget()}async function mT(e,t){const n=fe(e);if(!Ad(e))return ue("unavailable","The canvas is not open.");try{const r=await uu(n.sendAsync(K.SANDBOX_ELEMENT_OPERATION,t),hT,"sandbox:element");if(!r)return ue("unavailable","The canvas does not support element commands.");if(r.ok)return pt(r.value);const i=r;return ue(i.code,i.message)}catch(r){if(r instanceof lu)return ue("unavailable","The canvas did not answer in time.");throw r}}var Cd=["subject","preheader","title","utm_parameters","common_styles","meta"],gT={id:0,below:0},ac=()=>({code:"nothingToUndo",message:"The last answer changed nothing that could be undone."}),Et=e=>({code:"undoConflict",message:e});function vT(e,t,n){return e==="common_styles"?aT(t,n??""):Ne(t,n)}function cc(e,t){return Object.fromEntries(Cd.filter(n=>!vT(n,e[n],t[n])).map(n=>[n,e[n]]))}function bT(e){const t=()=>{const n=pi(e);if(!n)return;const{docId:r,attributes:i}=n.get();return{docId:r,step:Re(e)?.history()?.currentStep()??gT,fields:Object.fromEntries(Cd.map(o=>[o,i[o]]))}};return{document:()=>pi(e)?.get().docId,capture:t,undoRefusal:()=>pT(e)?.error,settle:async()=>{if(Ad(e))return(await mT(e,{op:"settle"})).ok?void 0:Et("The canvas did not answer, so edits made after the answer cannot be ruled out.")},undo:(n,r)=>{const i=n,o=r;if(!i)return ac();if(o?.docId!==i.docId)return Et("The answer ended on another email.");const s=o.step.id!==i.step.id,a=cc(i.fields,o.fields);if(!s&&Object.keys(a).length===0)return ac();const c=pi(e),l=t();if(!c||l?.docId!==o.docId)return Et("Another email is open now, not the one the answer changed.");if(cT(e))return lT().error;if(l.step.id!==o.step.id||Object.keys(cc(l.fields,o.fields)).length>0)return Et("The email was edited after the answer.");if(s&&o.step.below!==i.step.id)return Et("The answer moved through the undo history itself and cannot be taken back as one step.");if(s&&!Re(e)?.history()?.tryUndo())return Et("The step of the answer could not be undone: the text changed under it.");Object.keys(a).length>0&&(c.mutate({attributes:a},{source:"user"}),HI(e)?.markAppearanceChanged())}}}function _T(e){let t;return To(e).connect({begin:()=>{t??=Re(e)?.history()?.beginTransaction()},end:()=>{const n=t;t=void 0,n?.()},answers:bT(e)})}function yT(e){const t=Ye(e).selection,n=fe(e),r=()=>t.set(null),i=n.addListener(a=>{const c=a?.data;c?.operation===K.APPLICATION_ELEMENT_SETTINGS_SET?t.set(c.type&&typeof c.elementRef=="string"?c.elementRef:null):c?.operation===K.APPLICATION_ELEMENT_SETTINGS_CLOSE&&r()}),o=un(n,r),s=an(e,jt,a=>{let c=a.current();return{dispose:a.subscribe(()=>{a.current()!==c&&(c=a.current(),r())})}});return{dispose:()=>{i.dispose(),o(),s.dispose()}}}function ET(e){const t=[oT(e),_T(e),sT(e),yT(e)];return{dispose:()=>t.forEach(n=>n.dispose())}}var wT="SAVE",ST="SAVE_BLOCK",d0="SET_THEME",f0="NOTIFY",p0="SET_CONFIG",h0="UPDATE_CONFIG",Rd=class extends ve{_options;_listeners=[];constructor(e){super(),this._options=e}fire=e=>{if(!this.isDisposed()){let t;const n=[...this._listeners];for(const r of n){if(t===!1)return!1;t instanceof Promise?t=t.then(i=>i===!1||this.isDisposed()?!1:r(i)).catch(i=>{}):t=r(e)}return t}};addEventListener=e=>{const t=this._listeners,n=this._options;return t.push(e),t.length===1&&this._options?.onFirstListenerAdd&&this._options.onFirstListenerAdd(),{dispose:()=>{const r=t.indexOf(e);r>=0&&(t.splice(r,1),t.length||n?.onFirstListenerAdd&&n.onLastListenerRemove())}}};event=this.addEventListener},lc;(function(e){function t(i){let o;const s=new Rd({onFirstListenerAdd(){o=i(s.fire)},onLastListenerRemove(){o.dispose()}});return s.event}e.snapshot=t;function n(i,o){return t(s=>i(a=>o(a)&&s(a)))}e.filter=n;function r(i,o){return t(s=>i(a=>s(o(a))))}e.map=r})(lc||(lc={}));var IT=U("helpers.commandEmitter");function TT(e,t,n){e instanceof Of||(e=Wd(e)),e.getOrCreateInstance(IT,()=>new Rd).fire({id:t,payload:n})}function AT(e,t,{yieldable:n=!1,details:r,prepare:i}={}){const o=je(e),s=new Map,a=new Set,c=o.commands.watch(()=>{o.disposed||Object.entries(t).forEach(([l,{declaration:u,handler:d}])=>{const m=o.info(l)?.owner;m?n&&m!==ht&&!a.has(l)&&(a.add(l),`${l}${m.name}`,void 0):(a.delete(l),s.set(l,o.register(ht,{[l]:u},{[l]:d},{},{yieldable:n,details:r,prepare:i})))})});return{dispose:()=>{c.dispose(),s.forEach(l=>l.dispose())}}}var Ko="document.getSnapshot",CT="document.save",Od=Symbol.for("emailmaker.legacyEmailSnapshot"),Qi=Symbol.for("emailmaker.legacyEmailSnapshotError");function RT(e,t){return Object.defineProperty(e,Od,{value:t})}function OT(e){return RT({kind:"email",id:e.id==null?null:String(e.id),content:e.code??"",subject:e.subject??"",preheader:e.preheader??""},e)}function kT(e){return{kind:"block",id:e.id==null?null:String(e.id),content:e.code??"",subject:"",preheader:""}}function PT(e,t){return AT(e,{[Ko]:{declaration:{title:"Get document snapshot",description:"Returns the open document: kind, id, HTML content, subject and preheader.",agent:{readOnly:!0}},handler:async()=>{try{const n=Re(e),r=ee(n?.sessionKey())?await t.getBlockSnapshot():null;return pt(r?kT(r):OT(await t.readEmailSnapshot()))}catch(n){return Object.defineProperty(ue("internal",n instanceof Error?n.message:String(n)),Qi,{value:n})}}},[CT]:{declaration:{title:"Save document",description:"Saves the open document and finishes when the save is done. A save refused by a rule (a plugin check, empty content, too many tags, edits still on their way, the host cancelled it) answers `refused`, and its message names the reason: tell the user.",agent:!0},handler:(n,r)=>NT(e,r.caller)}})}async function DT(e,t){const n=await je(e).run(Ko,void 0,{caller:"plugin"});if(n.ok===!1){if(Qi in n)throw n[Qi];return t()}return n.value[Od]}function xT(e){return je(e).info(Ko)?.owner===ht}var MT="The host cancelled this save, so nothing was saved. Tell the user; do not repeat the call unless the user asks for it again.";async function LT(e,t,n){const r=await new Promise(a=>{TT(e,t,{source:wg,settle:a})});if(r.ok!==!1)return pt();if(r.reason==="unready")return;const i=n==="agent"?r.refusal??(r.reason==="aborted"?MT:void 0):void 0,o=r.reason==="locked"?"readOnly":r.reason==="aborted"?"aborted":"internal",s=i?ue("refused",i):ue(o,r.message);return r.notified?Object.defineProperty(s,Ig,{value:!0}):s}async function NT(e,t){if(Ce($t(e))?.readOnly)return ue("readOnly","The editor is read-only.");const n=Re(e)?.sessionKey();if(n!==void 0){const i=ee(n);if(Ag(e,i?"block":"email")){const o=await LT(e,i?ST:wT,t);if(o)return o}}const r=e.getInstance(bn);if(n===void 0||!r)return ue("unavailable","There is no open document to save.");try{return await(ee(n)?r.saveBlock():r.save()),pt()}catch(i){if(i instanceof He&&i.reason==="locked")return ue("readOnly",i.message);const o=t==="agent"?ih(i):void 0;return o?ue("refused",o):ue("internal",i instanceof Error?i.message:String(i))}}var FT=class extends ve{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=An(e),this.addDisposable(Pe(e,H.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t})),this.addDisposable(PT(e,this)),this.addDisposable(ET(e))}openEmail(){const e=Re(this._container);if(e&&ee(e.sessionKey())&&!e.hasSuspended())throw new Error("[emailmaker] no open email: only a block is shown");return Wu(this._container,this._currentEmail)}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>String(t.project)===String(e)).map(t=>Se(t,this._container))}async _readProjectBlocks(){const e=await zu(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>Jt(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>$i(n,this._container))}async getEmailSnapshot(){return ee(Re(this._container)?.sessionKey())||!xT(this._container)?this.readEmailSnapshot():DT(this._container,()=>this.readEmailSnapshot())}async readEmailSnapshot(){return Oe(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Re(this._container),t=e?.current();return!e||!t||!ee(e.sessionKey())?null:(await t.whenReady(),Se(Ar(t),this._container))}setEmailMeta(e){const t=jo(this._container);if(!t)return;const n=t.get().attributes.meta;Mt(t,{meta:Bn({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,i=>i&&Bn(i,e))}setBlockMeta(e,t){const n=Re(this._container);if(n?.sessionKey()===tr(e)){const i=n.current();i&&Mt(i,{meta:Bn({meta:i.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:i}=this._dataSources.blocks;await i.getIfPresent(e)&&await i.addOrUpdate(e,o=>o&&Bn(o,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return iT(this._container)?rT(this._container):void 0}},BT=U("EmailDataController");function jT(e){return e.getOrCreateInstance(BT,()=>{const t=new FT(e);return e.getInstance(Y)?.addDisposable(t),t})}function UT(e){const t=jT(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function $T(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}function HT(e){let t;const n=xu(e),r=Pe(e,H.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:o})=>{t=o}));const i=()=>t?$T(t):void 0;return{undoRedoService:{undo:()=>i()?.undo(),redo:()=>i()?.redo(),clear:()=>i()?.clear(),getPast:o=>i()?.getPast(o)??[],getFuture:o=>i()?.getFuture(o)??[],canUndo:()=>i()?.canUndo()??!1,canRedo:()=>i()?.canRedo()??!1,createSnapshot:()=>i()?.createSnapshot(),restoreSnapshot:o=>i()?.restoreSnapshot(o)}}}var VT=U("plugin.mountElement");function GT(e){const t=e.getInstance(we)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function qT(e){return e.getOrCreateInstance(VT,()=>{let t=!1,n;return{get:()=>t?n:GT(e),set(r){t=!0,n=r}}})}function WT(e){const t=qT(e);return{getElement:()=>t.get()}}function zT(e){return{handleLoadImage:V(Pe(e,H.UPLOAD_EVENT_ID)),handleFileProxy:V(Pe(e,H.FILE_PROXY_EVENT_ID)),handleUrlProxy:V(Pe(e,H.PROXY_URL_EVENT_ID)),handleAITextRequest:V(Pe(e,H.AI_TEXT_REQUEST_ID)),handleAIImageRequest:V(Pe(e,H.AI_IMAGE_REQUEST_ID)),handleReadLocale:V(Pe(e,H.READ_LOCALE)),handleLimitUsage:V(Pe(e,H.ON_LIMIT_ID)),handleTranslate:V(Pe(e,H.ON_TRANSLATE_ID))}}var KT=[iy,qw,tT,LS,UT,HT,WT,zT];function YT(e,t=KT){const n=Go(e);_S(e);const r=eT(e),i=QI(e),o=ZI(e),s={...r.instance,...i.instance,...o.instance};for(const c of t)Object.assign(s,c(e));let a=!0;return{instance:s,async setOptions(c){await r.setOptions(c);const l=a&&n.get()===c;a=!1,l||n.set(c),await i.setOptions(c),await o.setOptions(c)}}}function XT(e){return{get:t=>e.get(t),remove:(t,n)=>e.remove(t,n),set:(t,n,r)=>{if(n==null){e.get(t),e.remove(t,r);return}e.set(t,n,r)}}}var JT=class{_storage=Object.create(null);get(e){const t=this._storage[e];return t&&(!t.expires||t.expires<Date.now())?t.value:""}set(e,t,n){this._storage[e]={value:t,expires:n.expires?n.expires*1e3+Date.now():void 0}}remove(e){delete this._storage[e]}},QT="editor-runtime.react.copies",hi=8;function pn(e){return e&&typeof e=="object"?e:void 0}function uc(e){const t=pn(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=pn(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function ZT(e){const t=pn(e),n=t&&typeof t.version=="string"?t.version:void 0,r=pn(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function eA(e,t,n){return e.package===t&&e.version===n}function tA({ourReact:e,entries:t,packageName:n,version:r}){const i=uc(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const a of t){const c=pn(a);if(!c||!eA(c,n,r))continue;const l=uc(c.react);!l||l===i||s.has(l)||(s.add(l),o.push({package:n,version:r,reactVersion:ZT(c.react),react:c.react}))}return o}function nA({packageName:e,copies:t}){const n=[`[${e}] A second copy of React is on this page (singleton invariant broken).`,`The editor runs on its own React, the plugin got another one from ${e}/runtime/react.`,`This shows up as "Cannot read properties of null (reading 'useState')" and takes down the whole`,"editor, not just the plugin panel: plugin components render inside the editor tree.","","Found:"];for(const r of t.slice(0,hi))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>hi&&n.push(` …and ${t.length-hi} more`),n.push("","Likely root cause: the editor is loaded from its UMD entry (a <script> on the page), while the","plugin was built as an ESM package by the host bundler. Those two never share a React.","","Fix it either way:"," • build the plugin on globals — it then takes React from the page registry, or"," • load the editor from its ESM entry and build both with the same bundler."),n.join(`
|
|
1062
|
+
`)}var dc=new Set;function rA({packageName:e="@emailmaker/emailmaker",version:t="1.3.8",log:n=r=>{}}={}){const r=i=>{try{const o=globalThis[Symbol.for(QT)],s=tA({ourReact:i,entries:o,packageName:e,version:t}).filter(a=>!dc.has(a.react));if(!s.length)return;s.forEach(a=>dc.add(a.react)),n(nA({packageName:e,copies:s}))}catch{}};try{const i=fo()?.modules?.React;if(i&&typeof i.then=="function"){i.then(r,()=>{});return}r(i)}catch{}}async function iA(e,t,n){se(e.signal);const r=t??xt.createChild();Go(r);const i=r.getInstance(Y);let o;async function s(){r.inject(Tc,XT(new JT)),rA();const a=YT(r),c={...a.instance,container:r,get ready(){return o??Promise.resolve(c)},async reset(l){if(se(l.signal),i.isDisposed())throw Ke();return await a.setOptions(l),c}};r.inject(bn,c);try{if(n?.onInstance?.(c),await a.setOptions(e),se(e.signal),i.isDisposed()||await Hw(r),e.devTools)try{const l=r.getInstance(ao);l&&await(await Cn()).initDevTools(r,l)}catch{}return se(e.signal),vn(r,Oc).fire(c),c}catch(l){throw i.dispose(),l}}try{return o=Qn(s(),e.signal),o.catch(()=>{}),await o}catch(a){throw i.isDisposed()||i.dispose(),a}}var hn=new WeakMap;function oA(e){return e?hn.get(e):void 0}function kd(e){try{e.getInstance(Y)?.dispose()}catch{}try{e.dispose()}catch{}}function sA(e,t){if(!e)return;const n=hn.get(e);n&&n!==t&&kd(n),hn.set(e,t)}function aA(e,t){e&&hn.get(e)===t&&hn.delete(e)}function cA(e){const t=xt.createChild();return Sn(e)&&t.inject(Ve,Rr(e)),t}var cn=new WeakMap,lA="data-emailmaker-config-styles";function uA(e){return typeof e=="string"?e.trim():""}function fc(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function dA(e,t,n){if(!e||typeof document>"u")return null;const r=uA(t),i=cn.get(e),o=n||e;if(!r)return i&&(i.remove(),cn.delete(e)),null;if(i)return i.textContent!==r&&(i.textContent=r),(i.parentNode!==o||i!==o.firstChild)&&fc(o,i),i;const s=document.createElement("style");return s.setAttribute(lA,"true"),s.textContent=r,fc(o,s),cn.set(e,s),s}function fA(e){if(!e)return;const t=cn.get(e);t&&(t.remove(),cn.delete(e))}function Pd(){return!1}var pA=`
|
|
1049
1063
|
.blocks-app-initial-spinner-wrapper {
|
|
1050
1064
|
width: 100%;
|
|
1051
1065
|
height: 100%;
|
|
@@ -1074,7 +1088,7 @@ import{n as Ra,r as Pd}from"./static/esm/971f1b2c.js";import{$ as Dd,A as xd,At
|
|
|
1074
1088
|
100% {
|
|
1075
1089
|
transform: rotate(360deg);
|
|
1076
1090
|
}
|
|
1077
|
-
}`;function NS(){return()=>{}}function FS(e,t){if(!yd()||!e||typeof document>"u")return NS();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const o=document.createElement("style");o.setAttribute(t,"true"),o.textContent=LS,document.head?.appendChild(o),e.appendChild(n);let i=!1;return()=>{i||(i=!0,n.remove(),o.remove())}}function BS(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function jS({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,i){const s=t.get(o);if(s!==void 0)return s;const a=i().catch(c=>{throw n.has(o)||(n.add(o),r(c)),BS(c)||t.delete(o),c});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var Ii=jS();function _d(){Ii.clear()}pu(()=>Ii.clear());var ya=new WeakMap;function Ci(e){return xd(e)}function US(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function HS(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function $S(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}var Ai=new WeakMap;function Jr(e,t){Ai.set(e,t)}function VS(e){return Ai.get(e)}function qS(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&Ai.get(r)||e,i=Ci(n);if(!i)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await $S(o);if(o.getAuthToken&&!a)throw HS();a&&s.set("authorization",a);const c=await iu("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},i,{attemptTimeout:di(o)||void 0});if(!c.ok)throw US(c.status,c.statusText);return await c.json()}}function GS(e){return JSON.stringify({baseUrl:Ci(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function WS(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function zS(e){return t=>Ii.run(GS(t),()=>(ie("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>ie("appInit:end",{kind:"network"}))))}function KS(e,t){if(on(e)||!e.appInit&&!Ci(e.baseUrl)||!WS(e))return e;const n=e.appInit??qS(e,t);let r=ya.get(n);return r||(r=zS(n),ya.set(n,r)),{...e,appInit:r}}var Ed=0;function YS(){return Ed}function XS(){Ed+=1,_d()}var _a=new WeakMap,Ea=new WeakMap,JS=3e4;function QS(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function ZS(e,t){try{const n=Fo(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+JS}function eI(e){const t=new Map,n=new Map;return async(r,o,i)=>{const s=QS(r,o);if(i)return n.delete(s),t.delete(s),_d(),e(r,o,i);const a=n.get(s);if(a&&!t.has(s)){if(a.expiresAtMs>Date.now())return a.token;n.delete(s)}let c=t.get(s);return c===void 0&&(ie("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,o,i)).then(l=>{const d=String(l||"").trim();return d&&n.set(s,{token:l,expiresAtMs:ZS(d,Date.now())}),l}).finally(()=>{ie("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,c)),c}}function tI(e){if(on(e))return e;const t=e.getAuthToken;if(!t)return e;let n=_a.get(t);const r=YS();return(!n||Ea.get(t)!==r)&&(n=eI(t),_a.set(t,n),Ea.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var nI="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function rI(e){const t=new Error(nI,{cause:e});return t.name="EditorStartFailedError",t}var oI={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function wa(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var wd=["handleLoad","handleDestroy"];function Sd(e,t){let n=e;for(const r of wd){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(i,...s)=>o(t,...s)})}return n}function iI(e){let t,n="pending",r,o,i,s;const a=new Set,c=[],l=new Set;let d,h;const b=new Promise((I,F)=>{d=I,h=F});b.catch(()=>{});const v={},w=I=>t?.[I],C=()=>r??Ve(),y=(I,F)=>{const j=w(I);if(typeof j!="function")throw wa(I);return j.apply(t,F)},S=(I,F)=>{try{return Promise.resolve(y(I,F))}catch(j){return Promise.reject(j)}},T=()=>{const I=t?.container?.getInstance?.(W);if(!(n!=="ready"||I?.isDisposed()||typeof w("getConfig")!="function"))try{s=y("getConfig",[])}catch{}},B=()=>n==="dead"?Promise.reject(C()):n==="ready"?Promise.resolve():b,D=()=>{for(const[I,F]of Vn)F==="field"&&(v[I]=w(I))},O=I=>{const F=w(I.name);I.dispose||typeof F!="function"||n==="dead"||(I.dispose=F.apply(t,I.args))},A=()=>a.forEach(O),x=()=>{for(const I of a){try{I.dispose?.()}catch{}I.dispose=void 0}},R=()=>{D(),A()},m=()=>{i?.delete(R),i=void 0},f=(I,F)=>{const[j,...K]=F;return!wd.includes(I)||typeof j!="function"?F:[(de,...se)=>j(v,...se),...K]},u=(I,F)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof w(I)!="function")throw wa(I);const j={name:I,args:f(I,F)};return a.add(j),O(j),()=>{a.delete(j),j.dispose?.(),j.dispose=void 0}},g=()=>t?.container?.getInstance(ye)?.get()?.content,k=()=>{const I=e.element();return I!==void 0&&typeof I!="string"?I:void 0},M=(I,F)=>{switch(F){case"event":return(...j)=>u(I,j);case"async":return(...j)=>(I==="show"&&j[0]!==void 0&&e.shown?.(j[0]),n!=="dead"&&typeof w(I)=="function"?S(I,j):B().then(()=>y(I,j)));case"queued":return(...j)=>{if(n==="dead"){if(I==="notify")return;throw C()}if(n==="pending"){c.push({name:I,args:j});return}return y(I,j)};case"sync":return(...j)=>{if(n==="dead"){if(I==="getConfig")return s;throw C()}if(typeof w(I)!="function")throw new Error(`[emailmaker] \`${I}\` is not available before the editor is ready: ${oI[I]??"await `ready` first"}`);const K=y(I,j);return I==="getConfig"&&(s=K),K};case"element":return()=>{if(typeof w(I)!="function")return k();try{return y(I,[])}catch{return k()}};case"codeErrors":return()=>n==="ready"&&typeof w(I)=="function"?y(I,[]):[];case"field":return}};for(const[I,F]of Vn)v[I]=M(I,F);v.reset=I=>(I?.content!==void 0&&e.shown?.(I.content),B().then(async()=>{const F=I?.content!==void 0&&Fe(I.content,g());await y("reset",[Sd(I,_)]),F&&await y("show",[I.content])}).then(()=>v)),v.destroy=()=>{if(n==="dead")return;const I=Ee("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),l.forEach(F=>F(I)),T(),e.destroy()},Object.defineProperty(v,"ready",{get:()=>o,enumerable:!0,configurable:!0});const _=v;return{object:_,get state(){return n},get editor(){return t},bind:I=>{n==="dead"||t===I||(x(),m(),t=I,D(),A(),n==="pending"&&(i=I.container.getOrCreateInstance(jo,()=>new Set),i.add(R)))},settle:()=>{if(n==="pending"){n="ready",m(),D(),A();for(const I of c.splice(0))try{y(I.name,I.args)}catch(F){queueMicrotask(()=>{throw F})}d()}},kill:(I,F)=>{n!=="dead"&&(T(),n="dead",r=I,c.length=0,l.forEach(j=>j(I)),m(),F?.keepSubscriptions||(x(),a.clear()),h(I))},detach:()=>{x(),a.clear()},setReady:I=>{o=I},trackCall:I=>(l.add(I),()=>l.delete(I)),hasCalls:()=>l.size>0}}var Id="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function sI(){return Ee(Id)}function aI(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Id}function cI(e,t,n){if(typeof document>"u")return;let r=!1,o;const i=()=>{r=!0,o?.disconnect(),o=void 0},s=()=>{r||(i(),t())};if(n.addDispose(i),!e.isConnected){queueMicrotask(s);return}o=new MutationObserver(()=>{e.isConnected||s()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function lI(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const i=new AbortController;return cI(n,()=>{n.id,i.abort(sI())},o),No(r,i.signal)}var Cd="Superseded by newer init() on the same mount element";function Sa(){return Ee(Cd)}function dI(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Cd}var Mt=new Map,Ia=new WeakMap,Cn=new WeakMap;function uI(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function fI(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=uI(e);(n?Mt.get(n):void 0)?.forEach(d=>{d.element!==e&&d.controller.abort(Sa())});const r=Ia.get(e)??new Set;t&&r.forEach(d=>{d.supersedable&&d.controller.abort(Sa())});const o=Cn.get(e)??Promise.resolve();let i;const s=new Promise(d=>{i=d}),a=o.then(()=>s);Cn.set(e,a),a.then(()=>{Cn.get(e)===a&&Cn.delete(e)});const c=new AbortController,l={element:e,controller:c,supersedable:t};if(r.add(l),Ia.set(e,r),n){const d=Mt.get(n)??new Set;d.add(l),Mt.set(n,d)}return{signal:c.signal,previous:o,release:()=>{i(),r.delete(l);const d=n?Mt.get(n):void 0;n&&d?.delete(l)&&d.size===0&&Mt.delete(n)}}}var Xt=new WeakMap;function Ti(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function Do(e){return Object.entries(e).filter(([t,n])=>Ti(t,n)).map(([t])=>t).sort()}function Ca(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!Ti(n,r)&&(t[n]=r);return t}function xo(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Xt.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Xt.set(e,r));const{current:o,trampolines:i}=r;o.clear();const s={...t};for(const a of Do(t)){o.set(a,t[a]);let c=i.get(a);c||(c=(...l)=>o.get(a)?.(...l),i.set(a,c)),s[a]=c}return r.lastOptions=t,s}function Ad(e,t){const n=e?Xt.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];Ti(r,o)?n.current.set(r,o):n.current.delete(r)}}function pI(e){const t=e?Xt.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,i)=>t.current.set(i,o)),t.lastOptions=r}}function hI(e,t,n){const r=e?Xt.get(e):void 0;if(!r||!n)return!1;const o=Do(t),i=Fe(o,Do(r.lastOptions)),s=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!i||!s||!Fe(Ca(t),Ca(r.lastOptions))?!1:(xo(e,t),!0)}var De=new WeakMap;function gr(e){let t=De.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},De.set(e,t)),t}var ze=e=>e!==void 0&&e.state!=="dead";function mI(e){const t=De.get(e)?.shared;return ze(t)?t:void 0}function gI(e,t){gr(e).shared=t}function vI(e,t){!(ze(e.shared)&&[...e.counted].some(ze))||e.warned||!t.devTools||(e.warned=!0)}function bI(e,t,n,r){const o=gr(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(i=>i.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(i=>i!==t&&ze(i)),t],vI(o,r),o.latestCall}function yI(e,t){return De.get(e)?.latestCall===t}function _I(e){const t=De.get(e);if(t)return t.order=t.order.filter(ze),t.order.at(-1)?.object}function Jt(e,t){const n=De.get(e);return n?ze(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&ze(r)):!1}function EI(e,t){const n=De.get(e),r=n?.order.filter(o=>o!==t&&ze(o)).at(-1);return r?n?.options.get(r):void 0}function Td(e,t){gr(e).content={value:t}}function wI(e){return De.get(e)?.content}function SI(e,t,n,r){const o=gr(e);if(o.counted.delete(t),o.options.delete(t),Jt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),Rd(e,r)}function Rd(e,t){const n=De.get(e);!n||Jt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Jt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function II(e,t){const n=De.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);De.delete(e)}}var sC=Ra({FileManagerApiError:()=>CI,IntegratorSaveTimeoutError:()=>Xn,SaveRefusedError:()=>qe}),CI=class Od extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,o){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=o,Error.captureStackTrace&&Error.captureStackTrace(this,Od)}},aC=Ra({mapHttpStatusToErrorCode:()=>Nd});function AI(e,t){return{...e,element:t}}function Mo(){return()=>{}}function TI(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Mo():(xS(t,e.config?.styles,t),()=>{MS(t)})}function RI(e){if(!yd()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Mo()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Mo()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=FS(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function OI(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function Gn(e){try{e.destroy()}catch{}}function Pn(e,...t){const n=Te.get(e);t.some(r=>r!==void 0&&r===n)&&Te.delete(e)}var cC="1.3.4";async function lC(e){ii(),await lE(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}async function dC(e){return MI(e).ready}function kI(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function PI(e){const t=Te.get(e);return t&&!(t instanceof Promise)?t:void 0}function Wn(e,t,n){const r=t??PI(e);r&&(Pn(e,r),Gn(r)),II(e,n)}function DI(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const s=t.editor;xI(s),t.kill(Ve());return}if(n==="single"){Wn(o,t.editor,Ve());return}const i=EI(o,t);SI(o,t,Ve(),()=>Wn(o,t.editor,Ve())),i&&Jt(o)&&Ad(o,i)}function xI(e){e&&Gn(e)}function MI(e){ie(ve.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=No(e.signal,n.signal),o=t==="single"?kI(e.element):void 0,i=o?mI(o):void 0;let s;if(i)s={control:i,mode:t,ref:{host:o}};else{const d={},h=iI({element:()=>d.host??e.element,destroy:()=>DI(s),shown:b=>{d.host&&Td(d.host,b)}});s={control:h,mode:t,ref:d},o&&gI(o,h)}const{control:a}=s,c=a.trackCall(d=>n.abort(d)),l=jI(Sd({...e,signal:r},a.object),s).then(()=>(c(),ie(ve.initEnd),a.settle(),a.object),d=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(d);const h=s.ref.host;throw h&&Rd(h,()=>Wn(h,void 0,Ve())),d});return a.setReady(l),a.object}function uC(e){const t=typeof e=="string"?document.querySelector(e):e;return t?_I(t):void 0}function LI(e){let t,n,r=!1;try{t=e.container.getInstance(ye)?.get(),n=e.container.getInstance(Pe)?.externalSignal;const o=ht(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:NI(e),dirty:r}}async function NI(e){try{return await e.getEmailSnapshot()}catch{return}}function FI(e){const t=ht(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function Aa(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Jt(e,n)}async function BI(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),dI(o)||aI(o))return;const i=()=>Wn(t,e,rI(o)),{options:s}=n;if(!s||!Aa(t,r)){i();return}const a=await n.email,c=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,l=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:c?{...l,email:c}:s.content}),n.dirty&&c&&FI(e),Aa(t,r)?Te.set(t,e):i()}catch{i()}}async function jI(e,t){re(e.signal);const n=new pe;let r,o,i,s,a=0;try{const c=await gu(e.element,n,e.signal);c&&(s=c,t.ref.host=c,a=bI(c,t.control,t.mode,e));const l=lI({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),d=fI(c,{supersede:t.mode==="single"});r=d.release;const h=No(l,d.signal);re(h),i=pI(c),Ad(c,e),await Dn(d.previous,h),o=UI(e,c,t,h,i);const b=await Dn(o,h);return c&&e.content!==void 0&&Td(c,e.content),b}catch(c){throw s&&i&&yI(s,a)&&i(),c}finally{const c=r;o!==void 0&&c?o.then(c,c):c?.(),n.dispose()}}async function Ta(e,t,n,r){const o=wI(t);n===void 0||r||!o||Fe(n,o.value)||await e.show(n)}async function UI(e,t,n,r,o){const{control:i}=n,s=C=>i.bind(C);re(r);let a;const c=C=>{XS();const y=tI(AI(C,t)),S=KS(y,()=>a);return{preparedOptions:S,preparedOptionsWithSignal:r!=null?{...S,signal:r}:S}};let l;if(t){const C=Te.get(t);if(C){let y;try{y=await C,re(r)}catch{re(r),Pn(t,C),y=void 0}if(y)if(y.getElement()===t){const S=TS(t);a=S;const T=y.container.getInstance(ye)?.get();if(hI(t,e,T))return s(y),r&&y.container.getInstance(Pe)?.relinkExternalSignal(r),Te.set(t,y),await Ta(y,t,e.content,!1),y;const B=!Fe(e.content,T?.content);l=c(xo(t,e));const{preparedOptions:D,preparedOptionsWithSignal:O}=l,A=S&&VS(S),x=LI(y);try{S&&Jr(S,D),s(y);const R=await y.reset(OI(e,O));return re(r),Te.set(t,y),await Ta(y,t,e.content,B),R}catch(R){if(S&&A&&Jr(S,A),!Yu(R))throw o(),await BI(y,t,x,n,R),R;Pn(t,C,y),Gn(y),re(r)}}else Pn(t,C,y),Gn(y)}}re(r),l??=c(xo(t,e,{fresh:!0}));const{preparedOptions:d}=l,h=TI(d),b=RI(d),v=r!=null?{...b.options,signal:r}:b.options;let w;try{a=kS(v),RS(t,a),Jr(a,d),bi(a).set(v),await yi(),ie(ve.coreReady),re(r),re(r),w=AS(v,a,{onInstance:s}),t&&Te.set(t,w);const C=await w;if(r?.aborted&&(C.destroy(),re(r)),t)if(Te.get(t)===w)Te.set(t,C);else throw C.destroy(),re(r),Ee(r?.reason);return C}catch(C){throw h(),b.cleanup(),a&&(bd(a),OS(t,a)),t&&w&&Te.get(t)===w&&Te.delete(t),C}}async function fC(e){return(await ln()).parseAMP(e)}typeof window<"u"&&(Gt()&&zu(),uE(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0));export{Id as ELEMENT_DETACHED_ABORT_MESSAGE,Cd as SUPERSEDED_INIT_ABORT_MESSAGE,MI as create,sC as errors,uC as getInstance,aC as helpers,dC as init,aI as isElementDetachedError,dI as isSupersededInitError,fC as parseAMP,pE as pluginRegistry,lC as preload,cC as version};
|
|
1091
|
+
}`;function hA(){return()=>{}}function mA(e,t){if(!Pd()||!e||typeof document>"u")return hA();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const i=document.createElement("style");i.setAttribute(t,"true"),i.textContent=pA,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function gA(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function vA({report:e}={}){const t=new Map,n=new Set,r=e??(i=>{});return{run(i,o){const s=t.get(i);if(s!==void 0)return s;const a=o().catch(c=>{throw n.has(i)||(n.add(i),r(c)),gA(c)||t.delete(i),c});return t.set(i,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var Yo=vA();function Dd(){Yo.clear()}cf(()=>Yo.clear());var pc=new WeakMap;function Xo(e){return sf(e)}function bA(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function _A(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function yA(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}var Jo=new WeakMap;function mi(e,t){Jo.set(e,t)}function EA(e){return Jo.get(e)}function wA(e,t){return async({baseUrl:n})=>{const r=t(),i=r&&Jo.get(r)||e,o=Xo(n);if(!o)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await yA(i);if(i.getAuthToken&&!a)throw _A();a&&s.set("authorization",a);const c=await gf("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},o,{attemptTimeout:Mo(i)||void 0});if(!c.ok)throw bA(c.status,c.statusText);return await c.json()}}function SA(e){return JSON.stringify({baseUrl:Xo(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function IA(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function TA(e){return t=>Yo.run(SA(t),()=>(ae("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>ae("appInit:end",{kind:"network"}))))}function AA(e,t){if(Sn(e)||!e.appInit&&!Xo(e.baseUrl)||!IA(e))return e;const n=e.appInit??wA(e,t);let r=pc.get(n);return r||(r=TA(n),pc.set(n,r)),{...e,appInit:r}}var xd=0;function CA(){return xd}function RA(){xd+=1,Dd()}var hc=new WeakMap,mc=new WeakMap,OA=3e4;function kA(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function PA(e,t){try{const n=no(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+OA}function DA(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=kA(r,i);if(o)return n.delete(s),t.delete(s),Dd(),e(r,i,o);const a=n.get(s);if(a&&!t.has(s)){if(a.expiresAtMs>Date.now())return a.token;n.delete(s)}let c=t.get(s);return c===void 0&&(ae("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,i,o)).then(l=>{const u=String(l||"").trim();return u&&n.set(s,{token:l,expiresAtMs:PA(u,Date.now())}),l}).finally(()=>{ae("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,c)),c}}function xA(e){if(Sn(e))return e;const t=e.getAuthToken;if(!t)return e;let n=hc.get(t);const r=CA();return(!n||mc.get(t)!==r)&&(n=DA(t),hc.set(t,n),mc.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var MA="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function LA(e){const t=new Error(MA,{cause:e});return t.name="EditorStartFailedError",t}var NA={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function gc(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var Md=["handleLoad","handleDestroy"];function Ld(e,t){let n=e;for(const r of Md){const i=e?.[r];typeof i=="function"&&(n={...n,[r]:(o,...s)=>i(t,...s)})}return n}function FA(e){let t,n="pending",r,i,o,s;const a=new Set,c=[],l=new Set;let u,d;const m=new Promise((w,M)=>{u=w,d=M});m.catch(()=>{});const _={},v=w=>t?.[w],E=()=>r??Ke(),y=(w,M)=>{const B=v(w);if(typeof B!="function")throw gc(w);return B.apply(t,M)},k=(w,M)=>{try{return Promise.resolve(y(w,M))}catch(B){return Promise.reject(B)}},C=()=>{const w=t?.container?.getInstance?.(Y);if(!(n!=="ready"||w?.isDisposed()||typeof v("getConfig")!="function"))try{s=y("getConfig",[])}catch{}},F=()=>n==="dead"?Promise.reject(E()):n==="ready"?Promise.resolve():m,T=()=>{for(const[w,M]of ur)M==="field"&&(_[w]=v(w))},R=w=>{const M=v(w.name);w.dispose||typeof M!="function"||n==="dead"||(w.dispose=M.apply(t,w.args))},A=()=>a.forEach(R),D=()=>{for(const w of a){try{w.dispose?.()}catch{}w.dispose=void 0}},O=()=>{T(),A()},h=()=>{o?.delete(O),o=void 0},f=(w,M)=>{const[B,...W]=M;return!Md.includes(w)||typeof B!="function"?M:[(ie,...re)=>B(_,...re),...W]},p=(w,M)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof v(w)!="function")throw gc(w);const B={name:w,args:f(w,M)};return a.add(B),R(B),()=>{a.delete(B),B.dispose?.(),B.dispose=void 0}},b=()=>t?.container?.getInstance(we)?.get()?.content,x=()=>{const w=e.element();return w!==void 0&&typeof w!="string"?w:void 0},N=(w,M)=>{switch(M){case"event":return(...B)=>p(w,B);case"async":return(...B)=>(w==="show"&&B[0]!==void 0&&e.shown?.(B[0]),n!=="dead"&&typeof v(w)=="function"?k(w,B):F().then(()=>y(w,B)));case"queued":return(...B)=>{if(n==="dead"){if(w==="notify")return;throw E()}if(n==="pending"){c.push({name:w,args:B});return}return y(w,B)};case"sync":return(...B)=>{if(n==="dead"){if(w==="getConfig")return s;throw E()}if(typeof v(w)!="function")throw new Error(`[emailmaker] \`${w}\` is not available before the editor is ready: ${NA[w]??"await `ready` first"}`);const W=y(w,B);return w==="getConfig"&&(s=W),W};case"element":return()=>{if(typeof v(w)!="function")return x();try{return y(w,[])}catch{return x()}};case"codeErrors":return()=>n==="ready"&&typeof v(w)=="function"?y(w,[]):[];case"field":return}};for(const[w,M]of ur)_[w]=N(w,M);_.reset=w=>(w?.content!==void 0&&e.shown?.(w.content),F().then(async()=>{const M=w?.content!==void 0&&Ne(w.content,b());await y("reset",[Ld(w,S)]),M&&await y("show",[w.content])}).then(()=>_)),_.destroy=()=>{if(n==="dead")return;const w=Ie("[emailmaker] editor was destroyed before it was ready");i?.catch(()=>{}),l.forEach(M=>M(w)),C(),e.destroy()},Object.defineProperty(_,"ready",{get:()=>i,enumerable:!0,configurable:!0});const S=_;return{object:S,get state(){return n},get editor(){return t},bind:w=>{n==="dead"||t===w||(D(),h(),t=w,T(),A(),n==="pending"&&(o=w.container.getOrCreateInstance(co,()=>new Set),o.add(O)))},settle:()=>{if(n==="pending"){n="ready",h(),T(),A();for(const w of c.splice(0))try{y(w.name,w.args)}catch(M){queueMicrotask(()=>{throw M})}u()}},kill:(w,M)=>{n!=="dead"&&(C(),n="dead",r=w,c.length=0,l.forEach(B=>B(w)),h(),M?.keepSubscriptions||(D(),a.clear()),d(w))},detach:()=>{D(),a.clear()},setReady:w=>{i=w},trackCall:w=>(l.add(w),()=>l.delete(w)),hasCalls:()=>l.size>0}}var Nd="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function BA(){return Ie(Nd)}function jA(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Nd}function UA(e,t,n){if(typeof document>"u")return;let r=!1,i;const o=()=>{r=!0,i?.disconnect(),i=void 0},s=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(s);return}i=new MutationObserver(()=>{e.isConnected||s()});let a=e.parentNode;for(;a;)i.observe(a,{childList:!0}),a=a.parentNode}function $A(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:i}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return UA(n,()=>{n.id,o.abort(BA())},i),ro(r,o.signal)}var Fd="Superseded by newer init() on the same mount element";function vc(){return Ie(Fd)}function HA(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Fd}var Kt=new Map,bc=new WeakMap,qn=new WeakMap;function VA(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function GA(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=VA(e);(n?Kt.get(n):void 0)?.forEach(u=>{u.element!==e&&u.controller.abort(vc())});const r=bc.get(e)??new Set;t&&r.forEach(u=>{u.supersedable&&u.controller.abort(vc())});const i=qn.get(e)??Promise.resolve();let o;const s=new Promise(u=>{o=u}),a=i.then(()=>s);qn.set(e,a),a.then(()=>{qn.get(e)===a&&qn.delete(e)});const c=new AbortController,l={element:e,controller:c,supersedable:t};if(r.add(l),bc.set(e,r),n){const u=Kt.get(n)??new Set;u.add(l),Kt.set(n,u)}return{signal:c.signal,previous:i,release:()=>{o(),r.delete(l);const u=n?Kt.get(n):void 0;n&&u?.delete(l)&&u.size===0&&Kt.delete(n)}}}var mn=new WeakMap;function Qo(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function Zi(e){return Object.entries(e).filter(([t,n])=>Qo(t,n)).map(([t])=>t).sort()}function _c(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!Qo(n,r)&&(t[n]=r);return t}function eo(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:mn.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},mn.set(e,r));const{current:i,trampolines:o}=r;i.clear();const s={...t};for(const a of Zi(t)){i.set(a,t[a]);let c=o.get(a);c||(c=(...l)=>i.get(a)?.(...l),o.set(a,c)),s[a]=c}return r.lastOptions=t,s}function Bd(e,t){const n=e?mn.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const i=t[r];Qo(r,i)?n.current.set(r,i):n.current.delete(r)}}function qA(e){const t=e?mn.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((i,o)=>t.current.set(o,i)),t.lastOptions=r}}function WA(e,t,n){const r=e?mn.get(e):void 0;if(!r||!n)return!1;const i=Zi(t),o=Ne(i,Zi(r.lastOptions)),s=i.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!o||!s||!Ne(_c(t),_c(r.lastOptions))?!1:(eo(e,t),!0)}var Be=new WeakMap;function Mr(e){let t=Be.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},Be.set(e,t)),t}var Qe=e=>e!==void 0&&e.state!=="dead";function zA(e){const t=Be.get(e)?.shared;return Qe(t)?t:void 0}function KA(e,t){Mr(e).shared=t}function YA(e,t){!(Qe(e.shared)&&[...e.counted].some(Qe))||e.warned||!t.devTools||(e.warned=!0)}function XA(e,t,n,r){const i=Mr(e);return i.latestCall+=1,i.releaseTimer!==void 0&&(clearTimeout(i.releaseTimer),i.releaseTimer=void 0),i.leaving.forEach(o=>o.detach()),i.leaving.clear(),n==="single"?i.shared=t:i.counted.add(t),i.options.set(t,r),i.order=[...i.order.filter(o=>o!==t&&Qe(o)),t],YA(i,r),i.latestCall}function JA(e,t){return Be.get(e)?.latestCall===t}function QA(e){const t=Be.get(e);if(t)return t.order=t.order.filter(Qe),t.order.at(-1)?.object}function gn(e,t){const n=Be.get(e);return n?Qe(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&Qe(r)):!1}function ZA(e,t){const n=Be.get(e),r=n?.order.filter(i=>i!==t&&Qe(i)).at(-1);return r?n?.options.get(r):void 0}function jd(e,t){Mr(e).content={value:t}}function eC(e){return Be.get(e)?.content}function tC(e,t,n,r){const i=Mr(e);if(i.counted.delete(t),i.options.delete(t),gn(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),i.leaving.add(t),Ud(e,r)}function Ud(e,t){const n=Be.get(e);!n||gn(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!gn(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function nC(e,t){const n=Be.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);Be.delete(e)}}var m0=wc({FileManagerApiError:()=>rC,IntegratorSaveTimeoutError:()=>gr,SaveRefusedError:()=>He}),rC=class $d extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,i){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,$d)}},g0=wc({mapHttpStatusToErrorCode:()=>Qd});function iC(e,t){return{...e,element:t}}function to(){return()=>{}}function oC(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?to():(dA(t,e.config?.styles,t),()=>{fA(t)})}function sC(e){if(!Pd()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:to()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:to()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=mA(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function aC(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function fr(e){try{e.destroy()}catch{}}function Jn(e,...t){const n=xe.get(e);t.some(r=>r!==void 0&&r===n)&&xe.delete(e)}var v0="1.3.8";async function b0(e){Oo(),await HS(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}async function _0(e){return fC(e).ready}function cC(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function lC(e){const t=xe.get(e);return t&&!(t instanceof Promise)?t:void 0}function pr(e,t,n){const r=t??lC(e);r&&(Jn(e,r),fr(r)),nC(e,n)}function uC(e){const{control:t,mode:n,ref:r}=e,i=r.host;if(!i){const s=t.editor;dC(s),t.kill(Ke());return}if(n==="single"){pr(i,t.editor,Ke());return}const o=ZA(i,t);tC(i,t,Ke(),()=>pr(i,t.editor,Ke())),o&&gn(i)&&Bd(i,o)}function dC(e){e&&fr(e)}function fC(e){ae(Ee.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=ro(e.signal,n.signal),i=t==="single"?cC(e.element):void 0,o=i?zA(i):void 0;let s;if(o)s={control:o,mode:t,ref:{host:i}};else{const u={},d=FA({element:()=>u.host??e.element,destroy:()=>uC(s),shown:m=>{u.host&&jd(u.host,m)}});s={control:d,mode:t,ref:u},i&&KA(i,d)}const{control:a}=s,c=a.trackCall(u=>n.abort(u)),l=vC(Ld({...e,signal:r},a.object),s).then(()=>(c(),ae(Ee.initEnd),a.settle(),a.object),u=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(u);const d=s.ref.host;throw d&&Ud(d,()=>pr(d,void 0,Ke())),u});return a.setReady(l),a.object}function y0(e){const t=typeof e=="string"?document.querySelector(e):e;return t?QA(t):void 0}function pC(e){let t,n,r=!1;try{t=e.container.getInstance(we)?.get(),n=e.container.getInstance(Fe)?.externalSignal;const i=At(e.container)?.current();r=i!==void 0&&i.get().savedVersion!==null&&i.isDirty()}catch{t=void 0}return{options:t,signal:n,email:hC(e),dirty:r}}async function hC(e){try{return await e.getEmailSnapshot()}catch{return}}function mC(e){const t=At(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function yc(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||gn(e,n)}async function gC(e,t,n,r,i){if(r.mode==="counted"&&r.control.detach(),HA(i)||jA(i))return;const o=()=>pr(t,e,LA(i)),{options:s}=n;if(!s||!yc(t,r)){o();return}const a=await n.email,c=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,l=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:c?{...l,email:c}:s.content}),n.dirty&&c&&mC(e),yc(t,r)?xe.set(t,e):o()}catch{o()}}async function vC(e,t){se(e.signal);const n=new ve;let r,i,o,s,a=0;try{const c=await If(e.element,n,e.signal);c&&(s=c,t.ref.host=c,a=XA(c,t.control,t.mode,e));const l=$A({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),u=GA(c,{supersede:t.mode==="single"});r=u.release;const d=ro(l,u.signal);se(d),o=qA(c),Bd(c,e),await Qn(u.previous,d),i=bC(e,c,t,d,o);const m=await Qn(i,d);return c&&e.content!==void 0&&jd(c,e.content),m}catch(c){throw s&&o&&JA(s,a)&&o(),c}finally{const c=r;i!==void 0&&c?i.then(c,c):c?.(),n.dispose()}}async function Ec(e,t,n,r){const i=eC(t);n===void 0||r||!i||Ne(n,i.value)||await e.show(n)}async function bC(e,t,n,r,i){const{control:o}=n,s=E=>o.bind(E);se(r);let a;const c=E=>{RA();const y=xA(iC(E,t)),k=AA(y,()=>a);return{preparedOptions:k,preparedOptionsWithSignal:r!=null?{...k,signal:r}:k}};let l;if(t){const E=xe.get(t);if(E){let y;try{y=await E,se(r)}catch{se(r),Jn(t,E),y=void 0}if(y)if(y.getElement()===t){const k=oA(t);a=k;const C=y.container.getInstance(we)?.get();if(WA(t,e,C))return s(y),r&&y.container.getInstance(Fe)?.relinkExternalSignal(r),xe.set(t,y),await Ec(y,t,e.content,!1),y;const F=!Ne(e.content,C?.content);l=c(eo(t,e));const{preparedOptions:T,preparedOptionsWithSignal:R}=l,A=k&&EA(k),D=pC(y);try{k&&mi(k,T),s(y);const O=await y.reset(aC(e,R));return se(r),xe.set(t,y),await Ec(y,t,e.content,F),O}catch(O){if(k&&A&&mi(k,A),!up(O))throw i(),await gC(y,t,D,n,O),O;Jn(t,E,y),fr(y),se(r)}}else Jn(t,E,y),fr(y)}}se(r),l??=c(eo(t,e,{fresh:!0}));const{preparedOptions:u}=l,d=oC(u),m=sC(u),_=r!=null?{...m.options,signal:r}:m.options;let v;try{a=cA(_),sA(t,a),mi(a,u),Go(a).set(_),await qo(),ae(Ee.coreReady),se(r),se(r),v=iA(_,a,{onInstance:s}),t&&xe.set(t,v);const E=await v;if(r?.aborted&&(E.destroy(),se(r)),t)if(xe.get(t)===v)xe.set(t,E);else throw E.destroy(),se(r),Ie(r?.reason);return E}catch(E){throw d(),m.cleanup(),a&&(kd(a),aA(t,a)),t&&v&&xe.get(t)===v&&xe.delete(t),E}}async function E0(e){return(await Cn()).parseAMP(e)}typeof window<"u"&&(ln()&&cp(),GS(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0));export{Nd as ELEMENT_DETACHED_ABORT_MESSAGE,Fd as SUPERSEDED_INIT_ABORT_MESSAGE,fC as create,m0 as errors,y0 as getInstance,g0 as helpers,_0 as init,jA as isElementDetachedError,HA as isSupersededInitError,E0 as parseAMP,Ki as pluginRegistry,b0 as preload,v0 as version};
|
|
1078
1092
|
|
|
1079
1093
|
|
|
1080
|
-
window.__emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/
|
|
1094
|
+
window.__emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/15ea858c.js":[],"static/core/166a67bd.js":["static/core/1a65ef0f.js"],"static/core/1922419a.js":[],"static/core/1a65ef0f.js":[],"static/core/1c67ab93.js":["static/core/34756b09.js","static/core/e995a70d.js","static/core/220d7d31.js"],"static/core/1d004581.js":[],"static/core/220d7d31.js":["static/core/e995a70d.js"],"static/core/2da7d310.js":["static/core/8b8c93f4.js","__delivery__/libs"],"static/core/322d3e9f.js":[],"static/core/34756b09.js":[],"static/core/36f3f772.js":["__delivery__/libs"],"static/core/370f04c3.js":[],"static/core/3b9931cd.js":["static/core/d4c10a7e.js"],"static/core/3bff2ae6.js":["static/core/8b8c93f4.js","static/core/2da7d310.js","static/core/de0d3c9a.js","static/core/c0b0ceff.js","__delivery__/libs"],"static/core/43a8b244.js":[],"static/core/454350da.js":["static/core/34756b09.js"],"static/core/4852c0de.js":[],"static/core/5272f5b2.js":["static/core/e995a70d.js"],"static/core/5f176d0a.js":["static/core/36f3f772.js","__delivery__/libs"],"static/core/674e22a5.js":[],"static/core/6933d533.js":[],"static/core/6ce85877.js":[],"static/core/7452d34b.js":[],"static/core/76d1f317.js":[],"static/core/7b8fbc31.js":[],"static/core/867b1e0a.js":["static/core/370f04c3.js","__delivery__/libs","monaco"],"static/core/89b1052c.js":["static/core/674e22a5.js"],"static/core/8a5b1c18.js":[],"static/core/8b8c93f4.js":["static/core/a8cb6e27.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/8bf56b5b.js":[],"static/core/8e97c82c.js":["static/core/f399000c.js","static/core/abde5a43.js","static/core/c5edcfc7.js"],"static/core/8eea6488.js":["static/core/322d3e9f.js"],"static/core/9a4cfb0a.js":["static/core/c5edcfc7.js"],"static/core/9d388494.js":[],"static/core/9e1370a6.js":["static/core/8b8c93f4.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/9f7f5230.js":["static/core/e6f6edff.js"],"static/core/a59d579e.js":[],"static/core/a6abc393.js":["static/core/2da7d310.js","static/core/db92581b.js","__delivery__/libs","static/core/8b8c93f4.js"],"static/core/a8cb6e27.js":[],"static/core/aa33047a.js":[],"static/core/abde5a43.js":[],"static/core/b69579c4.js":[],"static/core/bcc4db3e.js":[],"static/core/c0b0ceff.js":["static/core/674e22a5.js","static/core/db92581b.js","__delivery__/libs"],"static/core/c5edcfc7.js":["static/core/f399000c.js"],"static/core/c8c233fb.js":[],"static/core/c9d5118c.js":[],"static/core/caf9f1a6.js":[],"static/core/d0b845c8.js":[],"static/core/d241119a.js":[],"static/core/d4c10a7e.js":[],"static/core/d517188a.js":[],"static/core/db92581b.js":["static/core/674e22a5.js","static/core/d4c10a7e.js","static/core/322d3e9f.js","static/core/f399000c.js","static/core/36f3f772.js","__delivery__/libs"],"static/core/de0d3c9a.js":["static/core/8b8c93f4.js","__delivery__/libs"],"static/core/e6f6edff.js":[],"static/core/e995a70d.js":[],"static/core/ee26ef3d.js":["static/core/1a65ef0f.js","static/core/abde5a43.js","static/core/c5edcfc7.js"],"static/core/f399000c.js":[],"static/core/f875f388.js":[],"static/monaco/editor.api-DqgksfDR.js":[],"monaco":["static/monaco/editor.api-DqgksfDR.js","static/monaco/lspLanguageFeatures-BnvITcKb.js"],"static/monaco/lspLanguageFeatures-BnvITcKb.js":["static/monaco/editor.api-DqgksfDR.js"],"compat-globals.js":["static/esm/971f1b2c.js"],"emailmaker-esm.js":["static/esm/971f1b2c.js","static/esm/95cbf920.js","static/esm/f76c9d9d.js"],"static/esm/delivery-libs.js":[],"static/esm/2490dab8.js":["static/esm/971f1b2c.js"],"static/esm/95cbf920.js":[],"static/esm/971f1b2c.js":[],"static/esm/f76c9d9d.js":[]},"bundles":{"static/core/db92581b.js":["static/core/4423e721.js","static/core/2d94d780.js","static/core/652a482d.js"],"static/core/454350da.js":["static/core/a54d9b28.js"],"static/core/9e1370a6.js":["static/core/be880f91.js"],"static/core/c0b0ceff.js":["static/core/61378c9e.js"],"static/core/a6abc393.js":["static/core/7fc0ed75.js"],"core":["static/core/5dc34752.js","static/core/ee980948.js","static/core/c948c45f.js","static/core/f2be7351.js","static/core/e4c1aab3.js"]}});
|