@emailmaker/emailmaker 1.1.103 → 1.1.104
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 +34 -0
- package/README.md +1 -0
- package/emailmaker-core.d92031f0.js +859 -0
- package/emailmaker-esm.js +11 -11
- package/{emailmaker-po.3529b1de.js → emailmaker-po.d92031f0.js} +1 -1
- package/emailmaker.d.ts +7 -0
- package/emailmaker.js +11 -11
- package/iframe/.vite/manifest.json +4 -4
- package/iframe/css/sandbox.css +2 -1
- package/iframe/{iframe-eblock.3529b1de.html → iframe-eblock.d92031f0.html} +2 -2
- package/iframe/{iframe.3529b1de.html → iframe.d92031f0.html} +2 -2
- package/iframe/js/discussHandlers.cyZrdU7c.js +88 -0
- package/iframe/js/{iframe-eblock.body.3529b1de.js → iframe-eblock.body.d92031f0.js} +1 -1
- package/iframe/js/iframe-eblock.js +2 -2
- package/iframe/js/{iframe.body.3529b1de.js → iframe.body.d92031f0.js} +71 -71
- package/iframe/js/iframe.js +2 -2
- package/package.json +1 -1
- package/runtime/react/index.js +1 -1
- package/static/core/{c9a013a6.js → 123fc796.js} +2 -2
- package/static/core/{a4d1fdc5.js → 1cdd0eaa.js} +1 -1
- package/static/core/{82f5152d.js → 20fae5cb.js} +1 -1
- package/static/core/{fbd1b42a.js → 25095aa6.js} +1 -1
- package/static/core/{6efc4a78.js → 2d570b04.js} +1 -1
- package/static/core/{9ca4cda3.js → 360afb24.js} +1 -1
- package/static/core/{73291b7c.js → 36f15937.js} +1 -1
- package/static/core/{682a8e2c.js → 432ad49d.js} +1 -1
- package/static/core/{3b315cf0.js → 448f5a93.js} +1 -1
- package/static/core/{9909de51.js → 4b7442c5.js} +1 -1
- package/static/core/5dc1b7fa.js +7 -0
- package/static/core/{71d7c710.js → 62b7892b.js} +1 -1
- package/static/core/{b3d5871e.js → 9596ee39.js} +1 -1
- package/static/core/{6dd152e5.js → a866296c.js} +3 -3
- package/static/core/{e420456c.js → ba4d44b4.js} +1 -1
- package/static/core/{c1460335.js → bd852c3b.js} +1 -1
- package/static/core/{91e9b542.js → c100433a.js} +1 -1
- package/static/core/{7fd8d843.js → c67adee2.js} +1 -1
- package/static/core/cd6c8848.js +28 -0
- package/static/core/{8fe408ef.js → d3f1d83d.js} +1 -1
- package/static/core/{5eaa42ac.js → dc45a033.js} +1 -1
- package/static/core/{b99c36c9.js → e76ed3bd.js} +1 -1
- package/static/core/{5de7475e.js → eee25d75.js} +1 -1
- package/static/core/{48387a41.js → f173fdc6.js} +1 -1
- package/static/core/{66be8204.js → fff40495.js} +1 -1
- package/static/umd-runtime/{runtime.D9PiY8Jx.js → runtime.Wy6_YzQx.js} +1 -1
- package/vendor/@emailmaker/ui-kit/package.json +1 -1
- package/emailmaker-core.3529b1de.js +0 -859
- package/iframe/js/discussHandlers.BrvInbT7.js +0 -88
- package/static/core/90715222.js +0 -28
- package/static/core/d4619860.js +0 -7
package/emailmaker-esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{n as Go,r as
|
|
1
|
+
import{n as Go,r as yl}from"./static/esm/971f1b2c.js";import{A as Vo,At as rn,B as Cr,C as gi,Ct as Yn,D as El,Dt as _l,E as Tr,Et as wl,F as Ar,Ft as Ie,G as Ot,H as Ht,I as Sl,It as Il,J as Cl,K as Tl,L as qo,Lt as Al,M as Rl,Mt as Pl,N as Dl,Nt as nt,O as Ol,Ot as de,P as xl,Pt as F,Q as xt,R as Ml,Rt as ie,S as kl,St as Ll,T as Nl,Tt as vi,U as Fl,V as jl,W as Bl,X as Rr,Y as Xe,Z as bi,_ as Pr,_t as j,a as Ul,at as U,b as Te,bt as Ze,c as zo,ct as Dr,d as H,dt as Ae,et as Wo,f as Hl,ft as $l,g as Gl,gt as Vl,h as ql,ht as zl,i as Wl,it as oe,j as Kl,jt as Y,k as Yl,kt as Or,l as Xl,lt as se,m as Jl,mt as yi,n as Ql,nt as Ko,o as Zl,ot as Re,p as Mt,pt as ec,q as tc,r as nc,rt as Yo,s as ot,st as mn,t as me,tt as xe,u as rc,ut as xr,v as ic,vt as kt,w as oc,wt as sc,x as ac,xt as Me,y as Mr,yt as fe,z as Xo}from"./static/esm/d4338c39.js";import{t as lc}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 D=document.querySelector('script[src*="emailmaker-esm.js"]')||document.querySelector('script[src*="emailmaker.js"]');if(D&&D.src)return D.src.substring(0,D.src.lastIndexOf("/")+1)}catch{}try{var N=import.meta.url;if(N)return N.substring(0,N.lastIndexOf("/")+1)}catch{}return"./"})();h||(h="./");try{var l=String(h);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(l)||l.indexOf("//")===0)return l.charAt(l.length-1)==="/"?l:l+"/";var u=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",p=u?new URL(l,u).href:l;return p.charAt(p.length-1)==="/"?p:p+"/"}catch{var R=String(h);return R.charAt(R.length-1)==="/"?R:R+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(h){return e.publicPath=(function(){var l=h==null?"":String(h);l||(l="./");try{var u=String(l);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0)return u.charAt(u.length-1)==="/"?u:u+"/";var p=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",R=p?new URL(u,p).href:u;return R.charAt(R.length-1)==="/"?R:R+"/"}catch{var D=String(l);return D.charAt(D.length-1)==="/"?D:D+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var h=String(e.publicPath||"");if(h.indexOf("file:")!==0&&!(h&&h!=="./")){var l="";try{if(typeof window<"u"){for(var u in window)if(!(u==="__emailmaker__"||!/^__[^_].*__$/.test(u))){var p;try{p=window[u]}catch{continue}if(p&&typeof p=="object"&&p.publicPath){l=" Another product namespace ("+u+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(h){function l(I){try{var O=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return O?new URL(String(I||""),O).href:String(I||"")}catch{return String(I||"")}}var u=String(h||"");if(!u)return"";if(/^(?:data:|blob:)/.test(u))return u;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0||u.charAt(0)==="/")return l(u);var p=u.replace(/^\.\/+/,"").replace(/^\/+/,""),R="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),D=R&&p.indexOf(R+"/")!==0?R+"/"+p:p,N=e.publicPath||"./";try{return new URL(D,N).href}catch{return N.slice(-1)!=="/"&&(N+="/"),l(N+D)}}),e.version||(e.version="1.1.104");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,15 +993,15 @@ import{n as Go,r as bl}from"./static/esm/971f1b2c.js";import{A as Vo,At as rn,B
|
|
|
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="",p=0;p<l.length;p+=1){var R=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(l[p]);if(R){if(!u){u=R[1];continue}if(R[1]!==u)return R[1]}}return""},w=function(h){var l=T(new Error(h)),u=l?h+" Requested by: "+l+".":h;return e.__compatMissingReason=u,u};if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var l in h)Object.prototype.hasOwnProperty.call(h,l)&&(b[l]=h[l])},e.__compatPending){for(var g=0;g<e.__compatPending.length;g+=1)e.registerCompat(e.__compatPending[g]);e.__compatPending=void 0}for(var C in m)Object.prototype.hasOwnProperty.call(m,C)&&(function(h,l,u){var p=!1,R=function(){if(!(h in b))throw new Error(w(l));return b[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var D=R();return p||(p=!0),D},set:function(D){b[h]=D}}),Object.defineProperty(f,h,{configurable:!0,enumerable:!0,get:R,set:function(D){b[h]=D}})})(C,m[C],y[C]);var _=t;for(var P in f)Object.prototype.hasOwnProperty.call(f,P)&&(_===t&&(_=Object.create(t)),Object.defineProperty(_,P,Object.getOwnPropertyDescriptor(f,P)));var S=s,M=[],v=function(){for(var h=[],l=0;l<M.length;l+=1)(function(u){var p=t[u];p&&typeof p.then=="function"&&h.push(Promise.resolve(p).then(function(R){t[u]=R}))})(M[l]);return Promise.all(h)},E=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(v).then(function(){if(typeof E=="function")return E.call(e)})},typeof e.define=="function"){let h=function(l){if(!l||typeof l!="object"&&typeof l!="function"||l.__esModule)return l;if(A){var u=A.get(l);if(u)return u}var p=Object.create(null);Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var R=Reflect.ownKeys(l),D=0;D<R.length;D++){var L=R[D];if(L!=="__esModule"){var I=Object.getOwnPropertyDescriptor(l,L);I&&Object.defineProperty(p,L,I)}}return Object.prototype.hasOwnProperty.call(p,"default")||Object.defineProperty(p,"default",{enumerable:!0,value:l,writable:!1}),A&&A.set(l,p),p};var A=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var l=_.React;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.React)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.React;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react",[],function(){var l=_.React;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.React)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.React;return h(p)})}),e.define("react-dom",[],function(){var l=_.ReactDom;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactDom)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactDom;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react-dom",[],function(){var l=_.ReactDom;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactDom)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactDom;return h(p)})}),e.define("react-dom/client",[],function(){var l=_.ReactDomClient;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactDomClient)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactDomClient;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react-dom/client",[],function(){var l=_.ReactDomClient;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactDomClient)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactDomClient;return h(p)})}),e.define("react/jsx-runtime",[],function(){var l=_.ReactJsxRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactJsxRuntime)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactJsxRuntime;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-runtime",[],function(){var l=_.ReactJsxRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactJsxRuntime)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactJsxRuntime;return h(p)})}),e.define("react/jsx-dev-runtime",[],function(){var l=_.ReactJsxDevRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactJsxDevRuntime)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactJsxDevRuntime;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-dev-runtime",[],function(){var l=_.ReactJsxDevRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactJsxDevRuntime)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactJsxDevRuntime;return h(p)})}),e.define("antd",[],function(){var l=_.Antd;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Antd)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Antd;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/antd",[],function(){var l=_.Antd;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Antd)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Antd;return h(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var l=_.AntDesignIconBase;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignIconBase)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignIconBase;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var l=_.AntDesignIconBase;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignIconBase)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignIconBase;return h(p)})}),e.define("@ant-design/icons",[],function(){var l=_.AntDesignIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignIcons)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignIcons;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons",[],function(){var l=_.AntDesignIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignIcons)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignIcons;return h(p)})}),e.define("@ant-design/cssinjs",[],function(){var l=_.AntDesignCssinjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignCssinjs)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignCssinjs;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/cssinjs",[],function(){var l=_.AntDesignCssinjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignCssinjs)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignCssinjs;return h(p)})}),e.define("classnames",[],function(){var l=_.Classnames;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Classnames)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Classnames;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/classnames",[],function(){var l=_.Classnames;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Classnames)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Classnames;return h(p)})}),e.define("dayjs",[],function(){var l=_.Dayjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Dayjs)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Dayjs;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/dayjs",[],function(){var l=_.Dayjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Dayjs)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Dayjs;return h(p)})}),e.define("@emailmaker/ui-kit",[],function(){var l=_.UiKit;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.UiKit)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.UiKit;return h(p)})}),e.define("@emailmaker/emailmaker/ui-kit",[],function(){var l=_.UiKit;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.UiKit)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.UiKit;return h(p)})}),e.define("@emailmaker/emailmaker/ui-kit/icons",[],function(){var l=_.UiKitIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.UiKitIcons)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.UiKitIcons;return h(p)})}),e.define("@emailmaker/ui-kit/icons",[],function(){var l=_.UiKitIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.UiKitIcons)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.UiKitIcons;return h(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var lc=new Function("url","return import(url)");function cc(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function kr(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Jo(e){return e.type==="umd"||e.resolve==="registry"}var dc="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 uc(e){const t=Array.isArray(e)?e[0]:e;return kr(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function fc(e,t){const n=uc(e),r=kr(e)?e:void 0,i=t instanceof Error?t.message:String(t),o=r&&Jo(r)&&!/compat/iu.test(i)?` ${dc}`:"",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 pc(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var mc=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(kr(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(Jo(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await lc(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):pc(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 d=this._creationOrder.indexOf(c);d>=0&&this._creationOrder.splice(d,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=fc(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 cc(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 n.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 n.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)}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)}))}},hc=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)}}}},gc=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()}},Ei=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 vc(e,t){return t+e}function bc(){return typeof performance>"u"?Date.now():vc(performance.now(),performance.timeOrigin)}var yc="emailmaker:diagnostics",Ec="diagnostics",_c="diagnostics";function _i(e,t){return t?`${e}${e.includes("?")?"&":"?"}${_c}=1`:e}var _n;function wc(){try{const e=new URLSearchParams(window.location.search).get(Ec);return e===null?void 0:e!=="0"}catch{return}}function Sc(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Ic(){try{const e=window.localStorage.getItem(yc);return e===null?void 0:e==="1"}catch{return}}function wt(){return _n===void 0&&(_n=typeof window>"u"?!1:wc()??Sc()??Ic()??!1),_n}function Cc(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var le={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"},AE=Object.values(le),RE=[le.canvasPainted,le.canvasSettled,le.appVisible,le.editorVisible],Tc=5e3,Ac=3e3,wi="diagnosticsStore",$t,at;function Si(){return{marks:new Ei(Tc),resources:new Ei(Ac)}}function Qo(){if(at)return at;const e=Lr();return e?(at=e[wi]??$t??Si(),e[wi]=at,$t=void 0,at):($t??=Si(),$t)}function Z(e,t){wt()&&Qo().marks.push({phase:e,at:bc(),...t})}function Lr(){if(typeof window.__emailmaker__<"u"&&window.__emailmaker__)return window.__emailmaker__;if(typeof window>"u")return;const e=window[Cc()];return e!==null&&typeof e=="object"?e:void 0}function Rc(e){const t=e.length,n=Qo();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Pc(){const e=Lr();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Rc(e.diagnosticsBuffer)}var Dc="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Oe(){const e=new Error(Dc);return e.name="DestroyedInstanceError",e}function Oc(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function Xn(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)=>Xn(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)&&Xn(e[o],t[o]))}function Zo(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const a=t(s);o&&Xn(i,a)||(i=a,o=!0,r(a))})},select(r){return Zo(n,r)}};return n}function Ee(...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 Zo(i,o)}};return i}var xc=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:xl.UrlEncoded,...t})},es=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 Mc(e){return String(e||"").trim()||void 0}var kc=class extends ie{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=Mc(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)}},Nr=F("AppInitService");function Lc(e){return async()=>{const t=await e();return(await new xc(t).app_init_create({})).data}}function Nc(e){e.injectFactory(Nr,(t,n)=>{if(n)return n;const r=new kc({options:e.getInstance(se),isStandalone:()=>!!e.getInstance(Te),resolveRestBaseUrl:i=>i?gi(i):gi()||void 0,setRestBaseUrl:i=>{e.getInstance(sc)?.setOptions(i?{baseUrl:i}:{})},fallbackAppInit:Lc(()=>e.getInstanceAsync(wl)),publish:i=>{e.inject(xe,i)}});return e.getInstance(U)?.addDisposable(r),r},!0)}var Fr=F("documentSession.emailDocuments");function Je(e){return e?.getInstance(Fr)}var Fc=F("RevisionServiceFlag");function ts(e){return e.getOrCreateInstance(Fc,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function ns(e){return ts(e).isEnabled()}var jc=F("EmailRightsResolver");function Bc(e,t){const n=e.getInstance(jc);return n?n(t):!0}var rs=F("EmailHistoryAvailabilityResolver");function Uc(e){return e.getInstance(rs)!==void 0}async function Hc(e){const t=e.getInstance(rs);if(!t)return!0;try{return await t()}catch{return!1}}var jr={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},is=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],os=2e4,$c=is.reduce((e,t)=>e+jr[t],0),ss=os+$c+3e3;function Gc(e){return is.reduce((t,n)=>t+as(n,e),0)}function as(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:jr[e]}function ls(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:ss}function cs(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:os}function Br(e=ss){return e+3e3}function ds(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var Vc=()=>Br();function qc(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function zc(e){return t=>qc(e.getOrCreateInstance(j.BEFORE_SAVE_EMAIL,()=>new Me).fire(t),Vc())}function Wc(e){return e!=null&&e!==""}var us;function St(e,t){return us?.capture(e,t)}function Kc(e,t){return us?.captureMessage(e,t)}function Yc(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Gt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var ge=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} "${Gt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Gt(this.oldText)}")`:`(replace@${this.oldPosition} "${Gt(this.oldText)}" with "${Gt(this.newText)}")`}};function Ii(e,t){return e===null||e.length===0?t:new Xc(e,t).compress()}var Xc=class _e{_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,d]=_e._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(c),i=d;continue}if(r.newPosition<i.oldPosition){const[c,d]=_e._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(c),r=d;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,d]=_e._splitPrev(r,i.oldLength);s=c,a=i,r=d,i=this._getCurr(++n)}else{const[c,d]=_e._splitCurr(i,r.newLength);s=r,a=c,r=this._getPrev(++t),i=d}this._result[this._resultLen++]=new ge(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const o=_e._merge(this._result);return _e._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=_e._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++]=_e._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 ge(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new ge(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 ge(t.oldPosition,t.oldText,t.newPosition,r),new ge(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new ge(t.oldPosition,r,t.newPosition,t.newText),new ge(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 ge(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 Jc(e){return new ge(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Qc(e){return e.map(Jc)}function Ci(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Zc(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 ed(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}}var It=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Ti=0,td=Math.random().toString(36).slice(2,8);function nd(){return Ti+=1,`doc-${td}-${Ti}`}function rd(e){const t=e.createBuffer(),n=e.docId??nd();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const a=new Set;let c=!1,d=!1,f;const m=new Set;let y=null;const b=()=>(y?.version!==i&&(y={version:i,value:t.read()}),y.value),T=w=>Object.entries(w).some(([g,C])=>s[g]!==C);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:b,mutate(w,{source:g}){if(c)return i;const C=w.changes?.length?w.changes:void 0,_=C?Zc(b(),C):w.content!==void 0?w.content:void 0,P=_!==void 0&&_!==b(),S=w.attributes!==void 0&&T(w.attributes);if(!P&&!S)return i;const M=!(i>(o??-1)),v=S?Object.keys(w.attributes).filter(A=>s[A]!==w.attributes[A]):[];P&&t.write(_),S&&(s={...s,...w.attributes}),i+=1,g!=="user"&&M&&(o=i);const E={source:g,version:i,changes:C,...P?{content:!0}:{},...v.length>0?{attributes:v}:{}};return a.forEach(A=>A(E)),i},markSaved(w,g){const C={serverId:r,savedVersion:o};g!==void 0&&(r=g),(o===null||w>o)&&(o=w),(C.serverId!==r||C.savedVersion!==o)&&a.forEach(_=>_({source:"system",version:i}))},markUnsaved(){c||o===null||o<i||(o=i-1,a.forEach(w=>w({source:"system",version:i})))},markReady(){d||f!==void 0||(d=!0,m.forEach(w=>w.resolve()),m.clear(),a.forEach(w=>w({source:"system",version:i})))},isReady:()=>d,markFailed(w){d||f!==void 0||c||(f=w,m.forEach(g=>g.reject(new It(w))),m.clear(),a.forEach(g=>g({source:"system",version:i})))},failure:()=>f,whenReady(){return d?Promise.resolve():f!==void 0?Promise.reject(new It(f)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((w,g)=>{m.add({resolve:w,reject:g})})},subscribe(w){return a.add(w),()=>a.delete(w)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>c,dispose(){c=!0,m.forEach(w=>w.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),m.clear(),a.clear(),t.dispose()}}}var id=500,od=100,wn=0;function sd(e,t={}){const n=t.groupIntervalMs??id,r=t.maxSteps??od,i=t.now??(()=>0);let o=[],s=0,a=wn+=1,c=null,d=!1,f=!1,m=!1;const y=new Set,b=()=>y.forEach(v=>v()),T=(v,E)=>{if(v.length){f=!0;try{e.mutate({changes:v},{source:E})}finally{f=!1}}},w=v=>T(v,"user"),g=v=>{const E=i();d&&c!==null&&E-c<n?o[s-1]=Ii(o[s-1],v):(o=o.slice(0,s),o.push(v),s=o.length,d=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,a=wn+=1)),c=E,b()},C=()=>{d=!1,c=null},_=v=>{if(!v.length)return;const E=o.length>s;E&&(o=o.slice(0,s)),s>0&&(o[s-1]=Ii(o[s-1],v)),C(),E&&b()},P=e.subscribe(({source:v,changes:E})=>{if(!(m||f||!E?.length)){if(v==="remote"){S();return}if(v!=="user"){_(E);return}g(E)}}),S=()=>{o=[],s=0,C(),a=wn+=1,b()},M=()=>{if(s===0)return!1;const v=Qc(o[s-1]);return Ci(e.getContent(),v)?(w(v),s-=1,C(),!0):(o=o.slice(0,s-1),s=o.length,C(),b(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){M()&&b()},redo(){if(!(s>=o.length)){if(!Ci(e.getContent(),o[s])){o=o.slice(0,s),C(),b();return}w(o[s]),s+=1,C(),b()}},clear:S,applyWithoutHistory(v){const E=e.get().version;if(T(v,"system"),e.get().version===E){C();return}_(v)},getPast:v=>o.slice(0,s).reverse().slice(0,v),getFuture:v=>o.slice(s).reverse().slice(0,v),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(v){if(v.stackId!==a||v.index>s)return!1;for(;s>v.index;)if(!M())return b(),!1;return b(),!0},subscribe(v){return y.add(v),()=>y.delete(v)},dispose(){m=!0,P(),y.clear(),o=[],s=0}}}var ad=["edit","move","resize","insert"];function Sn(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ld(e){return typeof e=="string"?e:null}function cd(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function dd(e){return ad.includes(e)?e:null}function ud(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:ld(t.originId),changeId:Sn(t.changeId),rev:Sn(t.rev),baseRev:Sn(t.baseRev),expected:cd(t.expected),intent:dd(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var vt=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},fs=class extends Error{timeoutMs;constructor(e){super(`[emailmaker] handleEmailAutosave did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Ur=class extends Error{timeoutMs;constructor(e){super(`[emailmaker] handleSaveEmail did not respond within ${e}ms — the email was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function fd(){return typeof navigator<"u"&&navigator.onLine===!1}function pd(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;r.data!=null&&t.push(r.data),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 ps(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 ps(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 md(e){return fd()?!0:pd(e).some(ps)}var ms=new WeakSet,hs=new WeakMap;function gs(e){typeof e=="object"&&e!==null&&ms.add(e)}function hd(e,t){typeof e=="object"&&e!==null&&hs.set(e,t)}function gd(e){return typeof e=="object"&&e!==null?hs.get(e):void 0}function vd(e){return e instanceof Ur||e instanceof fs||typeof e=="object"&&e!==null&&ms.has(e)}function bd(e){return e instanceof vt||vd(e)}function yd(e){return!bd(e)&&md(e)}var vs="draft";function Ke(e){return e==null||e===""?vs:String(e)}function Ed(e){return e==null||e===""?`${Jn}${vs}`:`${Jn}${String(e)}`}var Jn="block:";function ye(e){return e?.startsWith(Jn)===!0}function dt(e){return ye(e.sessionKey())?void 0:e.current()}function bt(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return Z(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(Z(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw Or(i)?(`${e}`,{...n}):(`${e}`,{error:ds(i),...n},void 0),i})}var _d=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function wd(e){const t=e?.trim()??"";if(!_d.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function yt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Hr(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Sd(e,t={}){const n=yt((e??[]).filter(r=>r?.html?.trim()));return Hr(n,t)?n:null}function Id(e,t){const n=Date.parse(yt(e)?.modified??""),r=Sd(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 Ai(e,t,n){const r=yt((e??[]).filter(c=>c?.html?.trim())),i=Date.parse(r?.modified??""),o=Date.parse(yt((n??[]).filter(c=>c?.html?.trim()))?.modified??""),s=r&&Number.isFinite(i)&&(t===void 0||i>t)&&!(o>i),a=[Date.parse(yt(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:s&&Hr(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Cd({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var bs=e=>e.replace(/\r\n?/g,`
|
|
998
|
-
`),Ri=["recovery","plugin","rest"],Td=["subject","preheader"];function Ad(e){let t={},n;for(let i=Ri.length-1;i>=0;i--){const o=e.get(Ri[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 Td){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function $r(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?bs(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 ge(0,n,0,r)]}:{}},{source:"remote"})}var In=e=>typeof e=="string"?e.trim():"";function Rd(e,t,n,r){const{version:i,attributes:o}=e.get(),s=o,a=r==="snapshot"||r==="anchor",c=a?s.author:void 0,d=a?s.date_gmt:void 0,f=In(s.title)||In(s.subject)||In(t.fallbackTitle);return{version:i,payload:{html:e.getContent(),title:f,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,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}:{},...d?{excerpt:d}:{}}}}var Pd=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Dd(e){const t={};for(const n of Pd)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Od(e,t,n,r,i){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)}function ke(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=ke(i)),n[r]=i)}return n}function xd(e){return typeof e=="string"&&e.includes("autosave")}var Md=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function ys(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Md.has(t))):{}}function Ct(e,t,n={}){e&&e.mutate({attributes:kd(e.get().attributes,t)},{source:n.source??"user"})}function kd(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Gr(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Ld(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Es(e){if(!e)return null;const t=ys(e);return e.common_styles!==void 0&&(t.common_styles=Ld(e.common_styles)),Gr(e.html,t)}function _s(e){return e?Gr(e.html,ke(ys(e))):null}var Nd=["common_styles","subject","preheader","meta"];function Pi(e){if(!e?.html?.trim())return null;const t={};for(const n of Nd)Fd(n,e[n])&&(t[n]=e[n]);return Gr(e.html,t)}function Fd(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 jd=["modified","lock"];function Bd(e){if(!e)return null;const t={};for(const n of jd)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Ud=10,Hd=(e,t)=>e.key===t.key&&$d(e.serverId,t.serverId),$d=(e,t)=>e==null||e===t;function Gd(e){return typeof e?.then=="function"}var Di=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},ws=e=>{e.request.serverId!=null&&!Vr(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},Vd=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),Vr=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Oi=(e,t)=>t?.content!==void 0&&Cd({hasUnsavedUserEdit:Vr(e)})==="skip",qd=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()}),zd=(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))},Wd=(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}},Kd=e=>{const t=Ad(e.reports),n=Wd(e.lastMerged,t);e.lastMerged=t,n&&($r(e.document,n),ws(e))},Cn=(e,t)=>{if(!e.ready&&!Vr(e)){Kd(e);return}$r(e.document,t)},Yd=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 Xd(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:a,onAdapterError:c,onTimeout:d}=e;let f;const m=new Set,y=new Set,b=()=>m.forEach(l=>l()),T=(l,u)=>{if(!(l.closed||l.ready)){if(l.error!==void 0){l.document.markFailed(l.error),l.document.get().docId;return}ws(l),l.ready=!0,l.document.markReady(),l.document.get().docId,[...l.reports.keys()]}},w=(l,u,p)=>{c?.(u.id,p),!(!u.required||l.closed)&&(l.error=p,l.document.get().docId,u.id,b())},g=(l,u)=>{const p=new Set(u.map(I=>I.id));u.forEach(I=>{I.watch&&l.watchers.push(I.watch(O=>l.closed?!1:l.ready&&(Oi(l,O)||l.contentShown===!0&&O?.content!==void 0)?(l.document.get().docId,I.id,!1):(O&&l.reports.set(I.id,O),Cn(l,O),!0)))});const R=(I,O)=>{if(!l.closed){if(!I.required&&Oi(l,O)){l.document.get().docId,I.id,I.loaded?.(!1);return}O&&l.reports.set(I.id,O),Cn(l,O),I.loaded?.(O!==null)}},D=()=>{p.size>0||l.closed||(Di(l),T(l,[]))},L=[];if(u.forEach(I=>{let O;try{O=I.load()}catch(k){w(l,I,k),p.delete(I.id);return}if(Gd(O)){L.push({id:I.id,required:I.required,load:()=>O,...I.loaded?{loaded:k=>I.loaded?.(k)}:{}});return}R(I,O),p.delete(I.id)}),L.length===0){D();return}l.timer=setTimeout(()=>{l.timer=void 0,d?.([...p]),l.document.get().docId,[...p],T(l,[...p])},n),l.timer.unref?.(),L.forEach(I=>{I.load().then(O=>R(I,O)).catch(O=>{w(l,I,O)}).finally(()=>{p.delete(I.id),D()})})},C=async(l,u,p)=>{if(p==="snapshot"||p==="anchor")return;const R=o?.();if(R)return R.resolve({project:u.project??l.project,tags:(l.tags??[]).map(D=>({name:D}))})},_=l=>{if(l.lock===!0&&s?.(l)===!1)return new vt("locked");const u=l.tags?.length??0,p=l.emailtags?.length??0;if(Math.max(u,p)>Ud)return new vt("too-many-tags")},P=(l,u)=>{const p=l.document.get().serverId;u||p==null||(l.recoveryFacts={emailId:p,historyLoaded:!0,isRecovering:!1},ye(l.request.key)||(l.request={...l.request,key:Ke(p),serverId:p}))},S=(l,u,p)=>{if(l.closed||p?.id==null)return;const R=l.document.get().serverId,D=R!=null;D&&R!==String(p.id)||(l.document.markSaved(u,String(p.id)),P(l,D),l.document.get().serverId,b())},M=async(l,u,p)=>{try{await l.document.whenReady()}catch(O){return l.saveError=O,l.saveFailures+=1,l.failedIntent=u,l.saveFailures,!1}if(l.closed)return!1;const R=_(l.document.get().attributes);if(R)return l.saveError=R,l.saveFailures+=1,l.failedIntent=u,R.reason,b(),!1;if(a&&(await a(Yd(l)).catch(()=>{}),l.closed))return!1;if(Vd(l))return u==="snapshot"||(l.saveError=new vt("empty-content"),l.saveFailures+=1,l.failedIntent=u,b()),!1;let D;try{D=await C(l.document.get().attributes,p,u)}catch(O){return l.saveError=O,l.saveFailures+=1,l.failedIntent=u,l.saveFailures,b(),!1}if(l.closed)return!1;const{payload:L,version:I}=Rd(l.document,p,D,u);l.document.get().docId;try{const O=l.document.get().serverId!=null,k=await Od(r(),i(l.request.key),u,l.document.get().serverId,L);if(l.closed)return!0;let ee;if(u==="snapshot"||u==="anchor"){const X=k?.modified!=null?Date.parse(k.modified):NaN;ee=Number.isFinite(X)?X:Date.now(),l.snapshotVersion=I,l.lastRevisionAt=ee}else l.document.markSaved(I,k?.id!=null?String(k.id):void 0),l.savedContent=L.html;P(l,O),l.saveError=void 0,l.saveFailures=0,l.failedIntent=void 0,l.document.get().serverId,b();const ce={intent:u,serverId:l.document.get().serverId,created:!O,...ee!==void 0?{revisionAt:ee}:{}};return y.forEach(X=>X(ce)),!0}catch(O){return(u==="publish"||u==="materialize")&&gd(O)?.then(k=>S(l,I,k)),l.saveError=O,l.saveFailures+=1,l.failedIntent=u,l.saveFailures,b(),!1}},v=()=>{f&&(f.closed=!0,f.watchers.forEach(l=>l()),f.watchers=[],Di(f),f.history.dispose(),f.document.dispose(),f=void 0)},E=(l,u,p)=>{let R=!1;u.show&&(l.show?.id!==u.show.id||l.show.token!==u.show.token)&&(l.show=u.show,R=!0,{docId:l.document.get().docId,...u.show});const D=p==="show"?_s(u.patch):null;D&&(l.reports.set("plugin",D),Cn(l,D),zd(l,D)),R&&b()},A=(l,u={})=>{const p=f;return!p||p.closed||l==="materialize"&&p.document.get().serverId!=null?Promise.resolve(!1):p.saving?l==="snapshot"||l==="materialize"?Promise.resolve(!1):(p.inFlight??Promise.resolve(!1)).then(()=>A(l,u)):(p.saving=!0,b(),p.inFlight=M(p,l,u).finally(()=>{p.saving=!1,p.inFlight=void 0,f===p&&!p.closed&&b()}),p.inFlight)},h=(l,u="open")=>{if(f&&!f.closed&&u!=="new"&&Hd(f.request,l))return E(f,l,u),f.document;v();const p=rd({createBuffer:()=>Yc(""),serverId:l.serverId??null}),R={request:l,show:l.show,document:p,history:sd(p,{now:Date.now}),watchers:[],userTouched:new Set,saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return f=R,R.watchers.push(qd(R)),p.get().docId,l.serverId,g(R,t(l,{publishRecoveryFacts(D){R.closed||(R.recoveryFacts=D,b())},readShownContent:()=>R.closed?null:R.document.getContent()})),b(),p};return{openWith:h,open:(l,u={})=>h({key:Ke(l),serverId:l,email:u.email,patch:u.patch,show:u.show},"open"),openDraft:(l,u={})=>h({key:Ke(void 0),serverId:null,email:l,patch:u.patch,show:u.show},"open"),startNewDraft:(l,u={})=>h({key:Ke(void 0),serverId:null,email:l,patch:u.patch,show:u.show},"new"),reload:(l,u={})=>h({key:Ke(l),serverId:l,email:u.email,patch:u.patch,show:u.show},"new"),openBlock:(l,u)=>h({key:ye(l)?l:Ed(l),serverId:u?.id!=null?String(u.id):null,email:u},"open"),show:(l,u)=>{const p=f;if(!(!p||p.closed))return h({...p.request,patch:l,show:u},"show")},current:()=>f?.document,noteServerFacts:({serverId:l,block:u},p)=>{const R=f;!R||R.closed||R.request.serverId!==l||ye(R.request.key??"")===u&&$r(R.document,Bd(p))},save:A,saveState:()=>({error:f?.saveError,failures:f?.saveFailures??0,saving:f?.saving===!0,failedIntent:f?.failedIntent}),revisionFacts(){if(!f)return;const l=f.revisionFactsSnapshot;return l&&l.snapshotVersion===f.snapshotVersion&&l.lastRevisionAt===f.lastRevisionAt?l:(f.revisionFactsSnapshot={snapshotVersion:f.snapshotVersion,lastRevisionAt:f.lastRevisionAt},f.revisionFactsSnapshot)},recoveryFacts:()=>f?.recoveryFacts,history:()=>f?.history,forcedHeaders:()=>f?.forcedHeaders,beginForcedHeaders(l){f&&!f.closed&&(f.forcedHeaders=l)},endForcedHeaders(){f&&(f.forcedHeaders=void 0)},onSaved(l){return y.add(l),()=>y.delete(l)},showFacts:()=>f?.show,sessionKey:()=>f?.request.key,openError:()=>f?.error,subscribe(l){return m.add(l),()=>m.delete(l)},close(){f&&(v(),b())}}}var qr=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function zr(e){if(e instanceof qr)return e.reason;if(e instanceof It)return zr(e.reason)}function Jd(e){const t=e instanceof It?e.reason:e;return t instanceof qr&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Qd(e){const t=zr(e);return t==="forbidden"||t==="not-found"}function Zd(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new qr("not-found");return Es(n)}}}var Ss=F("EmailPort");function eu(e){return e.getInstance(Ss)}function tu(e,t){e.inject(Ss,t)}var Is=F("documentSession.restEmailPortFactories");function Cs(e){return e.getInstance(Is)!==void 0}function Ve(e){const t=e.getInstance(Is);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var nu=F("EmailTermsResolver");function ru(e){return e.getInstance(nu)}var Ts=F("EmailHistoryPort"),iu=F("BlockHistoryPort");function As(e){return e.getInstance(iu)}function Rs(e){return e.getInstance(Ts)}function ou(e,t){e.inject(Ts,t)}var su="em_autosave_pending";function on(e){return`${su}_${e}`}function au(e,t){try{sessionStorage.setItem(on(e),JSON.stringify(t))}catch{}}function Ps(e){try{const t=sessionStorage.getItem(on(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(on(e)),null):n}catch{return null}}function ut(e){try{sessionStorage.removeItem(on(e))}catch{}}var lu=2e3,cu=5e3,du=5,uu=5e3,fu=4;function pu(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function mu(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.d92031f0.js",po:"emailmaker-po.d92031f0.js",monaco:"static/monaco/index.CCINpETE.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(h){var l,u=function(){return l||(l=Promise.resolve().then(h))};return{then:function(p,R){return u().then(p,R)},catch:function(p){return u().catch(p)},finally:function(p){return u().finally(p)}}},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 l=h[0]||Object.create(null),u=Object.create(null);for(var p in l)Object.prototype.hasOwnProperty.call(l,p)&&(u[p]=l[p]);for(var R in u)Object.prototype.hasOwnProperty.call(u,R)&&(t[R]=u[R]);return u})}),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 d in a)Object.prototype.hasOwnProperty.call(a,d)&&t[d]===void 0&&(t[d]=(function(h,l){return new Proxy(Object.create(null),{get:function(u,p){if(!(typeof p=="symbol"||c.indexOf(p)!==-1))throw new Error("[shared-runtime] "+h+"."+String(p)+" is not available: "+l+".")}})})(d,a[d]));var f={},m={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."},y={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."},b=Object.create(null),T=function(h){for(var l=String(h&&h.stack||"").split(`
|
|
997
|
+
`),u="",p=0;p<l.length;p+=1){var R=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(l[p]);if(R){if(!u){u=R[1];continue}if(R[1]!==u)return R[1]}}return""},w=function(h){var l=T(new Error(h)),u=l?h+" Requested by: "+l+".":h;return e.__compatMissingReason=u,u};if(e.registerCompat=function(h){if(!(!h||typeof h!="object"))for(var l in h)Object.prototype.hasOwnProperty.call(h,l)&&(b[l]=h[l])},e.__compatPending){for(var g=0;g<e.__compatPending.length;g+=1)e.registerCompat(e.__compatPending[g]);e.__compatPending=void 0}for(var C in m)Object.prototype.hasOwnProperty.call(m,C)&&(function(h,l,u){var p=!1,R=function(){if(!(h in b))throw new Error(w(l));return b[h]};Object.defineProperty(t,h,{configurable:!0,enumerable:!0,get:function(){var D=R();return p||(p=!0),D},set:function(D){b[h]=D}}),Object.defineProperty(f,h,{configurable:!0,enumerable:!0,get:R,set:function(D){b[h]=D}})})(C,m[C],y[C]);var _=t;for(var P in f)Object.prototype.hasOwnProperty.call(f,P)&&(_===t&&(_=Object.create(t)),Object.defineProperty(_,P,Object.getOwnPropertyDescriptor(f,P)));var S=s,M=[],v=function(){for(var h=[],l=0;l<M.length;l+=1)(function(u){var p=t[u];p&&typeof p.then=="function"&&h.push(Promise.resolve(p).then(function(R){t[u]=R}))})(M[l]);return Promise.all(h)},E=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(v).then(function(){if(typeof E=="function")return E.call(e)})},typeof e.define=="function"){let h=function(l){if(!l||typeof l!="object"&&typeof l!="function"||l.__esModule)return l;if(A){var u=A.get(l);if(u)return u}var p=Object.create(null);Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var R=Reflect.ownKeys(l),D=0;D<R.length;D++){var N=R[D];if(N!=="__esModule"){var I=Object.getOwnPropertyDescriptor(l,N);I&&Object.defineProperty(p,N,I)}}return Object.prototype.hasOwnProperty.call(p,"default")||Object.defineProperty(p,"default",{enumerable:!0,value:l,writable:!1}),A&&A.set(l,p),p};var A=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var l=_.React;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.React)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.React;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react",[],function(){var l=_.React;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.React)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.React;return h(p)})}),e.define("react-dom",[],function(){var l=_.ReactDom;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactDom)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactDom;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react-dom",[],function(){var l=_.ReactDom;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactDom)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactDom;return h(p)})}),e.define("react-dom/client",[],function(){var l=_.ReactDomClient;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactDomClient)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactDomClient;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react-dom/client",[],function(){var l=_.ReactDomClient;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactDomClient)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactDomClient;return h(p)})}),e.define("react/jsx-runtime",[],function(){var l=_.ReactJsxRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactJsxRuntime)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactJsxRuntime;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-runtime",[],function(){var l=_.ReactJsxRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactJsxRuntime)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactJsxRuntime;return h(p)})}),e.define("react/jsx-dev-runtime",[],function(){var l=_.ReactJsxDevRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactJsxDevRuntime)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactJsxDevRuntime;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/react/jsx-dev-runtime",[],function(){var l=_.ReactJsxDevRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.ReactJsxDevRuntime)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.ReactJsxDevRuntime;return h(p)})}),e.define("antd",[],function(){var l=_.Antd;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Antd)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Antd;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/antd",[],function(){var l=_.Antd;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Antd)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Antd;return h(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var l=_.AntDesignIconBase;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignIconBase)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignIconBase;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var l=_.AntDesignIconBase;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignIconBase)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignIconBase;return h(p)})}),e.define("@ant-design/icons",[],function(){var l=_.AntDesignIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignIcons)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignIcons;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/icons",[],function(){var l=_.AntDesignIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignIcons)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignIcons;return h(p)})}),e.define("@ant-design/cssinjs",[],function(){var l=_.AntDesignCssinjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignCssinjs)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignCssinjs;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/@ant-design/cssinjs",[],function(){var l=_.AntDesignCssinjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.AntDesignCssinjs)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.AntDesignCssinjs;return h(p)})}),e.define("classnames",[],function(){var l=_.Classnames;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Classnames)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Classnames;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/classnames",[],function(){var l=_.Classnames;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Classnames)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Classnames;return h(p)})}),e.define("dayjs",[],function(){var l=_.Dayjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Dayjs)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Dayjs;return h(p)})}),e.define("@emailmaker/emailmaker/runtime/dayjs",[],function(){var l=_.Dayjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.Dayjs)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.Dayjs;return h(p)})}),e.define("@emailmaker/ui-kit",[],function(){var l=_.UiKit;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.UiKit)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.UiKit;return h(p)})}),e.define("@emailmaker/emailmaker/ui-kit",[],function(){var l=_.UiKit;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.UiKit)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.UiKit;return h(p)})}),e.define("@emailmaker/emailmaker/ui-kit/icons",[],function(){var l=_.UiKitIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.UiKitIcons)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.UiKitIcons;return h(p)})}),e.define("@emailmaker/ui-kit/icons",[],function(){var l=_.UiKitIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return h(p.UiKitIcons)}):h(u)}):l!==void 0?h(l):S.then(function(u){var p=u.UiKitIcons;return h(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var cc=new Function("url","return import(url)");function dc(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function kr(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Jo(e){return e.type==="umd"||e.resolve==="registry"}var uc="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 fc(e){const t=Array.isArray(e)?e[0]:e;return kr(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function pc(e,t){const n=fc(e),r=kr(e)?e:void 0,i=t instanceof Error?t.message:String(t),o=r&&Jo(r)&&!/compat/iu.test(i)?` ${uc}`:"",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 mc(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var hc=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(kr(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(Jo(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await cc(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):mc(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 d=this._creationOrder.indexOf(c);d>=0&&this._creationOrder.splice(d,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=pc(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 dc(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 n.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 n.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)}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)}))}},gc=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)}}}},vc=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()}},Ei=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 bc(e,t){return t+e}function yc(){return typeof performance>"u"?Date.now():bc(performance.now(),performance.timeOrigin)}var Ec="emailmaker:diagnostics",_c="diagnostics",wc="diagnostics";function _i(e,t){return t?`${e}${e.includes("?")?"&":"?"}${wc}=1`:e}var _n;function Sc(){try{const e=new URLSearchParams(window.location.search).get(_c);return e===null?void 0:e!=="0"}catch{return}}function Ic(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Cc(){try{const e=window.localStorage.getItem(Ec);return e===null?void 0:e==="1"}catch{return}}function wt(){return _n===void 0&&(_n=typeof window>"u"?!1:Sc()??Ic()??Cc()??!1),_n}function Tc(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var le={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"},PE=Object.values(le),DE=[le.canvasPainted,le.canvasSettled,le.appVisible,le.editorVisible],Ac=5e3,Rc=3e3,wi="diagnosticsStore",$t,at;function Si(){return{marks:new Ei(Ac),resources:new Ei(Rc)}}function Qo(){if(at)return at;const e=Lr();return e?(at=e[wi]??$t??Si(),e[wi]=at,$t=void 0,at):($t??=Si(),$t)}function J(e,t){wt()&&Qo().marks.push({phase:e,at:yc(),...t})}function Lr(){if(typeof window.__emailmaker__<"u"&&window.__emailmaker__)return window.__emailmaker__;if(typeof window>"u")return;const e=window[Tc()];return e!==null&&typeof e=="object"?e:void 0}function Pc(e){const t=e.length,n=Qo();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Dc(){const e=Lr();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Pc(e.diagnosticsBuffer)}var Oc="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Oe(){const e=new Error(Oc);return e.name="DestroyedInstanceError",e}function xc(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function Xn(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)=>Xn(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)&&Xn(e[o],t[o]))}function Zo(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const a=t(s);o&&Xn(i,a)||(i=a,o=!0,r(a))})},select(r){return Zo(n,r)}};return n}function _e(...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 Zo(i,o)}};return i}var Mc=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:Ml.UrlEncoded,...t})},es=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 kc(e){return String(e||"").trim()||void 0}var Lc=class extends ie{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=kc(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)}},Nr=F("AppInitService");function Nc(e){return async()=>{const t=await e();return(await new Mc(t).app_init_create({})).data}}function Fc(e){e.injectFactory(Nr,(t,n)=>{if(n)return n;const r=new Lc({options:e.getInstance(se),isStandalone:()=>!!e.getInstance(Ae),resolveRestBaseUrl:i=>i?gi(i):gi()||void 0,setRestBaseUrl:i=>{e.getInstance(ac)?.setOptions(i?{baseUrl:i}:{})},fallbackAppInit:Nc(()=>e.getInstanceAsync(Sl)),publish:i=>{e.inject(xe,i)}});return e.getInstance(U)?.addDisposable(r),r},!0)}var Fr=F("documentSession.emailDocuments");function Je(e){return e?.getInstance(Fr)}var jc=F("RevisionServiceFlag");function ts(e){return e.getOrCreateInstance(jc,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function ns(e){return ts(e).isEnabled()}var Bc=F("EmailRightsResolver");function Uc(e,t){const n=e.getInstance(Bc);return n?n(t):!0}var rs=F("EmailHistoryAvailabilityResolver");function Hc(e){return e.getInstance(rs)!==void 0}async function $c(e){const t=e.getInstance(rs);if(!t)return!0;try{return await t()}catch{return!1}}var jr={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},is=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],os=2e4,Gc=is.reduce((e,t)=>e+jr[t],0),ss=os+Gc+3e3;function Vc(e){return is.reduce((t,n)=>t+as(n,e),0)}function as(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:jr[e]}function ls(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:ss}function cs(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:os}function Br(e=ss){return e+3e3}function ds(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var qc=()=>Br();function zc(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function Wc(e){return t=>zc(e.getOrCreateInstance(j.BEFORE_SAVE_EMAIL,()=>new Me).fire(t),qc())}function Kc(e){return e!=null&&e!==""}var us;function St(e,t){return us?.capture(e,t)}function Yc(e,t){return us?.captureMessage(e,t)}function Xc(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Gt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var ve=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} "${Gt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Gt(this.oldText)}")`:`(replace@${this.oldPosition} "${Gt(this.oldText)}" with "${Gt(this.newText)}")`}};function Ii(e,t){return e===null||e.length===0?t:new Jc(e,t).compress()}var Jc=class we{_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,d]=we._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(c),i=d;continue}if(r.newPosition<i.oldPosition){const[c,d]=we._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(c),r=d;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,d]=we._splitPrev(r,i.oldLength);s=c,a=i,r=d,i=this._getCurr(++n)}else{const[c,d]=we._splitCurr(i,r.newLength);s=r,a=c,r=this._getPrev(++t),i=d}this._result[this._resultLen++]=new ve(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const o=we._merge(this._result);return we._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=we._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++]=we._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 ve(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new ve(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 ve(t.oldPosition,t.oldText,t.newPosition,r),new ve(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new ve(t.oldPosition,r,t.newPosition,t.newText),new ve(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 ve(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 Qc(e){return new ve(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Zc(e){return e.map(Qc)}function Ci(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function ed(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 td(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}}var It=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Ti=0,nd=Math.random().toString(36).slice(2,8);function rd(){return Ti+=1,`doc-${nd}-${Ti}`}function id(e){const t=e.createBuffer(),n=e.docId??rd();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const a=new Set;let c=!1,d=!1,f;const m=new Set;let y=null;const b=()=>(y?.version!==i&&(y={version:i,value:t.read()}),y.value),T=w=>Object.entries(w).some(([g,C])=>s[g]!==C);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:b,mutate(w,{source:g}){if(c)return i;const C=w.changes?.length?w.changes:void 0,_=C?ed(b(),C):w.content!==void 0?w.content:void 0,P=_!==void 0&&_!==b(),S=w.attributes!==void 0&&T(w.attributes);if(!P&&!S)return i;const M=!(i>(o??-1)),v=S?Object.keys(w.attributes).filter(A=>s[A]!==w.attributes[A]):[];P&&t.write(_),S&&(s={...s,...w.attributes}),i+=1,g!=="user"&&M&&(o=i);const E={source:g,version:i,changes:C,...P?{content:!0}:{},...v.length>0?{attributes:v}:{}};return a.forEach(A=>A(E)),i},markSaved(w,g){const C={serverId:r,savedVersion:o};g!==void 0&&(r=g),(o===null||w>o)&&(o=w),(C.serverId!==r||C.savedVersion!==o)&&a.forEach(_=>_({source:"system",version:i}))},markUnsaved(){c||o===null||o<i||(o=i-1,a.forEach(w=>w({source:"system",version:i})))},markReady(){d||f!==void 0||(d=!0,m.forEach(w=>w.resolve()),m.clear(),a.forEach(w=>w({source:"system",version:i})))},isReady:()=>d,markFailed(w){d||f!==void 0||c||(f=w,m.forEach(g=>g.reject(new It(w))),m.clear(),a.forEach(g=>g({source:"system",version:i})))},failure:()=>f,whenReady(){return d?Promise.resolve():f!==void 0?Promise.reject(new It(f)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((w,g)=>{m.add({resolve:w,reject:g})})},subscribe(w){return a.add(w),()=>a.delete(w)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>c,dispose(){c=!0,m.forEach(w=>w.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),m.clear(),a.clear(),t.dispose()}}}var od=500,sd=100,wn=0;function ad(e,t={}){const n=t.groupIntervalMs??od,r=t.maxSteps??sd,i=t.now??(()=>0);let o=[],s=0,a=wn+=1,c=null,d=!1,f=!1,m=!1;const y=new Set,b=()=>y.forEach(v=>v()),T=(v,E)=>{if(v.length){f=!0;try{e.mutate({changes:v},{source:E})}finally{f=!1}}},w=v=>T(v,"user"),g=v=>{const E=i();d&&c!==null&&E-c<n?o[s-1]=Ii(o[s-1],v):(o=o.slice(0,s),o.push(v),s=o.length,d=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,a=wn+=1)),c=E,b()},C=()=>{d=!1,c=null},_=v=>{if(!v.length)return;const E=o.length>s;E&&(o=o.slice(0,s)),s>0&&(o[s-1]=Ii(o[s-1],v)),C(),E&&b()},P=e.subscribe(({source:v,changes:E})=>{if(!(m||f||!E?.length)){if(v==="remote"){S();return}if(v!=="user"){_(E);return}g(E)}}),S=()=>{o=[],s=0,C(),a=wn+=1,b()},M=()=>{if(s===0)return!1;const v=Zc(o[s-1]);return Ci(e.getContent(),v)?(w(v),s-=1,C(),!0):(o=o.slice(0,s-1),s=o.length,C(),b(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){M()&&b()},redo(){if(!(s>=o.length)){if(!Ci(e.getContent(),o[s])){o=o.slice(0,s),C(),b();return}w(o[s]),s+=1,C(),b()}},clear:S,applyWithoutHistory(v){const E=e.get().version;if(T(v,"system"),e.get().version===E){C();return}_(v)},getPast:v=>o.slice(0,s).reverse().slice(0,v),getFuture:v=>o.slice(s).reverse().slice(0,v),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(v){if(v.stackId!==a||v.index>s)return!1;for(;s>v.index;)if(!M())return b(),!1;return b(),!0},subscribe(v){return y.add(v),()=>y.delete(v)},dispose(){m=!0,P(),y.clear(),o=[],s=0}}}var ld=["edit","move","resize","insert"];function Sn(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function cd(e){return typeof e=="string"?e:null}function dd(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function ud(e){return ld.includes(e)?e:null}function fd(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:cd(t.originId),changeId:Sn(t.changeId),rev:Sn(t.rev),baseRev:Sn(t.baseRev),expected:dd(t.expected),intent:ud(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var vt=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},fs=class extends Error{timeoutMs;constructor(e){super(`[emailmaker] handleEmailAutosave did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Ur=class extends Error{timeoutMs;constructor(e){super(`[emailmaker] handleSaveEmail did not respond within ${e}ms — the email was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function pd(){return typeof navigator<"u"&&navigator.onLine===!1}function md(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;r.data!=null&&t.push(r.data),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 ps(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 ps(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 hd(e){return pd()?!0:md(e).some(ps)}var ms=new WeakSet,hs=new WeakMap;function gs(e){typeof e=="object"&&e!==null&&ms.add(e)}function gd(e,t){typeof e=="object"&&e!==null&&hs.set(e,t)}function vd(e){return typeof e=="object"&&e!==null?hs.get(e):void 0}function bd(e){return e instanceof Ur||e instanceof fs||typeof e=="object"&&e!==null&&ms.has(e)}function yd(e){return e instanceof vt||bd(e)}function Ed(e){return!yd(e)&&hd(e)}var vs="draft";function Ke(e){return e==null||e===""?vs:String(e)}function _d(e){return e==null||e===""?`${Jn}${vs}`:`${Jn}${String(e)}`}var Jn="block:";function Ee(e){return e?.startsWith(Jn)===!0}function dt(e){return Ee(e.sessionKey())?void 0:e.current()}function bt(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return J(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(J(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw Or(i)?(`${e}`,{...n}):(`${e}`,{error:ds(i),...n},void 0),i})}var wd=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function Sd(e){const t=e?.trim()??"";if(!wd.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function yt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Hr(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Id(e,t={}){const n=yt((e??[]).filter(r=>r?.html?.trim()));return Hr(n,t)?n:null}function Cd(e,t){const n=Date.parse(yt(e)?.modified??""),r=Id(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 Ai(e,t,n){const r=yt((e??[]).filter(c=>c?.html?.trim())),i=Date.parse(r?.modified??""),o=Date.parse(yt((n??[]).filter(c=>c?.html?.trim()))?.modified??""),s=r&&Number.isFinite(i)&&(t===void 0||i>t)&&!(o>i),a=[Date.parse(yt(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:s&&Hr(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Td({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var bs=e=>e.replace(/\r\n?/g,`
|
|
998
|
+
`),Ri=["recovery","plugin","rest"],Ad=["subject","preheader"];function Rd(e){let t={},n;for(let i=Ri.length-1;i>=0;i--){const o=e.get(Ri[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 Ad){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function $r(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?bs(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 ve(0,n,0,r)]}:{}},{source:"remote"})}var In=e=>typeof e=="string"?e.trim():"";function Pd(e,t,n,r){const{version:i,attributes:o}=e.get(),s=o,a=r==="snapshot"||r==="anchor",c=a?s.author:void 0,d=a?s.date_gmt:void 0,f=In(s.title)||In(s.subject)||In(t.fallbackTitle);return{version:i,payload:{html:e.getContent(),title:f,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,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}:{},...d?{excerpt:d}:{}}}}var Dd=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Od(e){const t={};for(const n of Dd)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function xd(e,t,n,r,i){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)}function ke(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=ke(i)),n[r]=i)}return n}function Md(e){return typeof e=="string"&&e.includes("autosave")}var kd=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function ys(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!kd.has(t))):{}}function Ct(e,t,n={}){e&&e.mutate({attributes:Ld(e.get().attributes,t)},{source:n.source??"user"})}function Ld(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Gr(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Nd(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Es(e){if(!e)return null;const t=ys(e);return e.common_styles!==void 0&&(t.common_styles=Nd(e.common_styles)),Gr(e.html,t)}function _s(e){return e?Gr(e.html,ke(ys(e))):null}var Fd=["common_styles","subject","preheader","meta"];function Pi(e){if(!e?.html?.trim())return null;const t={};for(const n of Fd)jd(n,e[n])&&(t[n]=e[n]);return Gr(e.html,t)}function jd(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 Bd=["modified","lock"];function Ud(e){if(!e)return null;const t={};for(const n of Bd)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Hd=10,$d=(e,t)=>e.key===t.key&&Gd(e.serverId,t.serverId),Gd=(e,t)=>e==null||e===t;function Vd(e){return typeof e?.then=="function"}var Di=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},ws=e=>{e.request.serverId!=null&&!Vr(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},qd=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),Vr=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Oi=(e,t)=>t?.content!==void 0&&Td({hasUnsavedUserEdit:Vr(e)})==="skip",zd=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()}),Wd=(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))},Kd=(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}},Yd=e=>{const t=Rd(e.reports),n=Kd(e.lastMerged,t);e.lastMerged=t,n&&($r(e.document,n),ws(e))},Cn=(e,t)=>{if(!e.ready&&!Vr(e)){Yd(e);return}$r(e.document,t)},Xd=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 Jd(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:a,onAdapterError:c,onTimeout:d}=e;let f;const m=new Set,y=new Set,b=()=>m.forEach(l=>l()),T=(l,u)=>{if(!(l.closed||l.ready)){if(l.error!==void 0){l.document.markFailed(l.error),l.document.get().docId;return}ws(l),l.ready=!0,l.document.markReady(),l.document.get().docId,[...l.reports.keys()]}},w=(l,u,p)=>{c?.(u.id,p),!(!u.required||l.closed)&&(l.error=p,l.document.get().docId,u.id,b())},g=(l,u)=>{const p=new Set(u.map(I=>I.id));u.forEach(I=>{I.watch&&l.watchers.push(I.watch(O=>l.closed?!1:l.ready&&(Oi(l,O)||l.contentShown===!0&&O?.content!==void 0)?(l.document.get().docId,I.id,!1):(O&&l.reports.set(I.id,O),Cn(l,O),!0)))});const R=(I,O)=>{if(!l.closed){if(!I.required&&Oi(l,O)){l.document.get().docId,I.id,I.loaded?.(!1);return}O&&l.reports.set(I.id,O),Cn(l,O),I.loaded?.(O!==null)}},D=()=>{p.size>0||l.closed||(Di(l),T(l,[]))},N=[];if(u.forEach(I=>{let O;try{O=I.load()}catch(L){w(l,I,L),p.delete(I.id);return}if(Vd(O)){N.push({id:I.id,required:I.required,load:()=>O,...I.loaded?{loaded:L=>I.loaded?.(L)}:{}});return}R(I,O),p.delete(I.id)}),N.length===0){D();return}l.timer=setTimeout(()=>{l.timer=void 0,d?.([...p]),l.document.get().docId,[...p],T(l,[...p])},n),l.timer.unref?.(),N.forEach(I=>{I.load().then(O=>R(I,O)).catch(O=>{w(l,I,O)}).finally(()=>{p.delete(I.id),D()})})},C=async(l,u,p)=>{if(p==="snapshot"||p==="anchor")return;const R=o?.();if(R)return R.resolve({project:u.project??l.project,tags:(l.tags??[]).map(D=>({name:D}))})},_=l=>{if(l.lock===!0&&s?.(l)===!1)return new vt("locked");const u=l.tags?.length??0,p=l.emailtags?.length??0;if(Math.max(u,p)>Hd)return new vt("too-many-tags")},P=(l,u)=>{const p=l.document.get().serverId;u||p==null||(l.recoveryFacts={emailId:p,historyLoaded:!0,isRecovering:!1},Ee(l.request.key)||(l.request={...l.request,key:Ke(p),serverId:p}))},S=(l,u,p)=>{if(l.closed||p?.id==null)return;const R=l.document.get().serverId,D=R!=null;D&&R!==String(p.id)||(l.document.markSaved(u,String(p.id)),P(l,D),l.document.get().serverId,b())},M=async(l,u,p)=>{try{await l.document.whenReady()}catch(O){return l.saveError=O,l.saveFailures+=1,l.failedIntent=u,l.saveFailures,!1}if(l.closed)return!1;const R=_(l.document.get().attributes);if(R)return l.saveError=R,l.saveFailures+=1,l.failedIntent=u,R.reason,b(),!1;if(a&&(await a(Xd(l)).catch(()=>{}),l.closed))return!1;if(qd(l))return u==="snapshot"||(l.saveError=new vt("empty-content"),l.saveFailures+=1,l.failedIntent=u,b()),!1;let D;try{D=await C(l.document.get().attributes,p,u)}catch(O){return l.saveError=O,l.saveFailures+=1,l.failedIntent=u,l.saveFailures,b(),!1}if(l.closed)return!1;const{payload:N,version:I}=Pd(l.document,p,D,u);l.document.get().docId;try{const O=l.document.get().serverId!=null,L=await xd(r(),i(l.request.key),u,l.document.get().serverId,N);if(l.closed)return!0;let Q;if(u==="snapshot"||u==="anchor"){const te=L?.modified!=null?Date.parse(L.modified):NaN;Q=Number.isFinite(te)?te:Date.now(),l.snapshotVersion=I,l.lastRevisionAt=Q}else l.document.markSaved(I,L?.id!=null?String(L.id):void 0),l.savedContent=N.html;P(l,O),l.saveError=void 0,l.saveFailures=0,l.failedIntent=void 0,l.document.get().serverId,b();const ce={intent:u,serverId:l.document.get().serverId,created:!O,...Q!==void 0?{revisionAt:Q}:{}};return y.forEach(te=>te(ce)),!0}catch(O){return(u==="publish"||u==="materialize")&&vd(O)?.then(L=>S(l,I,L)),l.saveError=O,l.saveFailures+=1,l.failedIntent=u,l.saveFailures,b(),!1}},v=()=>{f&&(f.closed=!0,f.watchers.forEach(l=>l()),f.watchers=[],Di(f),f.history.dispose(),f.document.dispose(),f=void 0)},E=(l,u,p)=>{let R=!1;u.show&&(l.show?.id!==u.show.id||l.show.token!==u.show.token)&&(l.show=u.show,R=!0,{docId:l.document.get().docId,...u.show});const D=p==="show"?_s(u.patch):null;D&&(l.reports.set("plugin",D),Cn(l,D),Wd(l,D)),R&&b()},A=(l,u={})=>{const p=f;return!p||p.closed||l==="materialize"&&p.document.get().serverId!=null?Promise.resolve(!1):p.saving?l==="snapshot"||l==="materialize"?Promise.resolve(!1):(p.inFlight??Promise.resolve(!1)).then(()=>A(l,u)):(p.saving=!0,b(),p.inFlight=M(p,l,u).finally(()=>{p.saving=!1,p.inFlight=void 0,f===p&&!p.closed&&b()}),p.inFlight)},h=(l,u="open")=>{if(f&&!f.closed&&u!=="new"&&$d(f.request,l))return E(f,l,u),f.document;v();const p=id({createBuffer:()=>Xc(""),serverId:l.serverId??null}),R={request:l,show:l.show,document:p,history:ad(p,{now:Date.now}),watchers:[],userTouched:new Set,saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return f=R,R.watchers.push(zd(R)),p.get().docId,l.serverId,g(R,t(l,{publishRecoveryFacts(D){R.closed||(R.recoveryFacts=D,b())},readShownContent:()=>R.closed?null:R.document.getContent()})),b(),p};return{openWith:h,open:(l,u={})=>h({key:Ke(l),serverId:l,email:u.email,patch:u.patch,show:u.show},"open"),openDraft:(l,u={})=>h({key:Ke(void 0),serverId:null,email:l,patch:u.patch,show:u.show},"open"),startNewDraft:(l,u={})=>h({key:Ke(void 0),serverId:null,email:l,patch:u.patch,show:u.show},"new"),reload:(l,u={})=>h({key:Ke(l),serverId:l,email:u.email,patch:u.patch,show:u.show},"new"),openBlock:(l,u)=>h({key:Ee(l)?l:_d(l),serverId:u?.id!=null?String(u.id):null,email:u},"open"),show:(l,u)=>{const p=f;if(!(!p||p.closed))return h({...p.request,patch:l,show:u},"show")},current:()=>f?.document,noteServerFacts:({serverId:l,block:u},p)=>{const R=f;!R||R.closed||R.request.serverId!==l||Ee(R.request.key??"")===u&&$r(R.document,Ud(p))},save:A,saveState:()=>({error:f?.saveError,failures:f?.saveFailures??0,saving:f?.saving===!0,failedIntent:f?.failedIntent}),revisionFacts(){if(!f)return;const l=f.revisionFactsSnapshot;return l&&l.snapshotVersion===f.snapshotVersion&&l.lastRevisionAt===f.lastRevisionAt?l:(f.revisionFactsSnapshot={snapshotVersion:f.snapshotVersion,lastRevisionAt:f.lastRevisionAt},f.revisionFactsSnapshot)},recoveryFacts:()=>f?.recoveryFacts,history:()=>f?.history,forcedHeaders:()=>f?.forcedHeaders,beginForcedHeaders(l){f&&!f.closed&&(f.forcedHeaders=l)},endForcedHeaders(){f&&(f.forcedHeaders=void 0)},onSaved(l){return y.add(l),()=>y.delete(l)},showFacts:()=>f?.show,sessionKey:()=>f?.request.key,openError:()=>f?.error,subscribe(l){return m.add(l),()=>m.delete(l)},close(){f&&(v(),b())}}}var qr=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function zr(e){if(e instanceof qr)return e.reason;if(e instanceof It)return zr(e.reason)}function Qd(e){const t=e instanceof It?e.reason:e;return t instanceof qr&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Zd(e){const t=zr(e);return t==="forbidden"||t==="not-found"}function eu(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new qr("not-found");return Es(n)}}}var Ss=F("EmailPort");function tu(e){return e.getInstance(Ss)}function nu(e,t){e.inject(Ss,t)}var Is=F("documentSession.restEmailPortFactories");function Cs(e){return e.getInstance(Is)!==void 0}function Ve(e){const t=e.getInstance(Is);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var ru=F("EmailTermsResolver");function iu(e){return e.getInstance(ru)}var Ts=F("EmailHistoryPort"),ou=F("BlockHistoryPort");function As(e){return e.getInstance(ou)}function Rs(e){return e.getInstance(Ts)}function su(e,t){e.inject(Ts,t)}var au="em_autosave_pending";function on(e){return`${au}_${e}`}function lu(e,t){try{sessionStorage.setItem(on(e),JSON.stringify(t))}catch{}}function Ps(e){try{const t=sessionStorage.getItem(on(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(on(e)),null):n}catch{return null}}function ut(e){try{sessionStorage.removeItem(on(e))}catch{}}var cu=2e3,du=5e3,uu=5,fu=5e3,pu=4;function mu(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function hu(e,t){return e==null||t==null?!1:e.replaceAll(`\r
|
|
999
999
|
`,`
|
|
1000
1000
|
`)===t.replaceAll(`\r
|
|
1001
1001
|
`,`
|
|
1002
|
-
`)}function Tn(e,t){return Hr(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function hu({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:a,pageLoadTs:c=pu()}){let d=null,f=!1,m=!1,y=0,b={emailId:e,historyLoaded:!1,isRecovering:!1},T=null;const w=new Promise(D=>{T=D}),g=D=>{b={...b,...D},o(b)};let C;const _=D=>{y+=1,g({applied:{phase:D,seq:y}})},P=()=>{d?.timer&&clearTimeout(d.timer),d=null},S=D=>{if(!m){if(T){const L=T;T=null,L(D),C=D.revision?D.phase:void 0;return}s(D)&&D.revision&&_(D.phase)}},M=()=>{if(!d||m)return;const D=d.phase==="fast",L=D?lu:uu,I=D?du:fu;d.timer=setTimeout(()=>{const O=d;if(!(!O||m)){if(O.attempts+=1,h(),D&&O.attempts>=I){const{pending:k}=O;ut(e),g({isRecovering:!1}),S({revision:{html:k.html,common_styles:k.common_styles,subject:k.subject,preheader:k.preheader},phase:"timeout"}),f=!0,O.phase="bg",O.attempts=0,M();return}if(!D&&O.attempts>=I){ut(e),P(),g({isRecovering:!1}),f=!0;return}M()}},L),d.timer.unref?.()},v=D=>{d={phase:"fast",attempts:0,pending:D,timer:null},g({isRecovering:!0}),M()},E=D=>{if(m)return;if(g({historyLoaded:!0,latestRevisionAt:D.latestAt!==void 0&&Number.isFinite(D.latestAt)?D.latestAt:void 0}),n&&d){const O=Tn(D,d.pending.sentAt);if(!O)return;const k=d.phase==="fast"?"found":"bg";ut(e),P(),g({isRecovering:!1}),f=!0,S({revision:O,phase:k});return}if(f)return;const L=n?Ps(e):null,I=L&&(L.sentAt<c||!mu(L.html,i()))?L:null;if(I){const O=Tn(D,I.sentAt);if(O){ut(e),f=!0,S({revision:O,phase:"found"});return}v(I);return}f=!0,S({revision:Tn(D),phase:"normal"})},A=D=>{m||(a?.(D),b.historyLoaded||(g({historyLoaded:!1,latestRevisionAt:void 0}),p()),!d&&S({revision:null,phase:"normal"}))},h=()=>t(e).then(E).catch(A);let l,u=!1;const p=()=>{u||d||m||(u=!0,l=setTimeout(()=>{l=void 0,!m&&!b.historyLoaded&&h()},cu))},R=()=>{m||(g({historyLoaded:!1,latestRevisionAt:void 0}),S({revision:null,phase:"normal"}))};return r?r().then(D=>D?h():R()):h(),{verdict:()=>w,confirmVerdict(D){const L=C;C=void 0,D&&L!==void 0&&!m&&_(L)},dispose(){m=!0,l!==void 0&&(clearTimeout(l),l=void 0),P()}}}function gu({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const a=hu({emailId:r,readAutosave:c=>e.readAutosave(c),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:c,phase:d})=>{const f=Pi(c);return s?.(f)??!1},onError:c=>{c instanceof Error&&c.message}});return{id:"recovery",load:()=>a.verdict().then(({revision:c})=>Pi(c)),loaded(c){a.confirmVerdict(c)},watch(c){return s=c,()=>{s=null,a.dispose()}}}}function Ds(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){au(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const i=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),i}}}function vu(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const i=Date.now(),o=await t.updateEmail(n,r);return await e.updateEmail(n,r),(Ps(n)?.sentAt??Number.POSITIVE_INFINITY)<=i&&ut(n),o}}}var Os=F("CurrentUser"),xs={};function Wr(e){return e.getOrCreateInstance(Os,()=>Ee(xs))}function Ms(e){return e?.getInstance(Os)?.get()??xs}var ks=F("HeadlessMode");function Ls(e){return e.getOrCreateInstance(ks,()=>Ee(!1))}function bu(e){return e?.getInstance(ks)?.get()??!1}var yu=F("HiddenMount");function Eu(e){return e.getOrCreateInstance(yu,()=>Ee(!1))}function _u(e){if(!e)return!1;try{return!!Mr(e).data?.act_as}catch{return!1}}function wu(e){return _u(e?.getInstance(Xo)?.get(Yl.em_token))}function Ns(e){return e?.getInstance(oe)?.get()??{}}function hn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Su(e,t){return t.modeDefaults(hn(e,t.fallbackMode))}function Fs(e,t){const n=hn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function js(e,t){const n=hn(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function Iu(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Cu(e){return Dl(e.map(t=>t?.resourceProxy))}function Tu(e){return Kl(e.map(t=>t?.resourceProxyPolicy))}function Au(e){return yl(e.map(t=>t?.backendProxy))}function Ru(e){return Vo(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Pu(e,t){return[e.base,Su(e,t),e.profile,e.serverSide,Fs(e,t.fallbackMode),e.local,e.user,js(e,t.fallbackMode)]}function An(e,t){const n=Pu(e,t),r=Vo(n),i=Iu(n);i!==void 0&&(r.fileManager=i);const o=Cu(n);o!==void 0&&(r.resourceProxy=o);const s=Tu(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=Au(n);a!==void 0&&(r.backendProxy=a);const c=Ru(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function Du(e,t,n){const r=Fs(e,n),i=js(e,n);return Wl([i,e.user,r,e.serverSide],t)}var Ou=1.5;function xu(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<=Ou*e.autosaveTimeoutMs?"none":"revision"}function Mu(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const c=E=>a!==void 0&&a.version===E.get().version?o()-a.failuresAtStart:0,d=E=>{const A=c(E);if(A<=0)return!1;const h=n().retryMaxAttempts??5;return!s()||A>h},f=()=>{const{autosaveTimeoutMs:E,retryIntervalMs:A}=n(),h=t();return h!==void 0&&c(h)>0&&A!==void 0&&A>0?A:E},m=E=>E.isNew()&&o()>=3,y=()=>{const E=t();if(!E||E.isDisposed()||d(E))return"none";const{latestRevisionAt:A,snapshotVersion:h,...l}=n(),u=Date.now(),p=xu({...l,isDirty:E.isDirty(),isNew:E.isNew(),isReady:E.isReady(),latestRevisionAgeMs:A!=null&&A<=u?u-A:void 0,isSnapshotSent:h!=null&&h===E.get().version});return p==="create"&&m(E)?"none":p},b=()=>{const E=t();if(!E||E.isDisposed()||m(E)||d(E)||n().isHeadless)return!1;if(!E.isDirty())return E.isNew();const{snapshotVersion:A}=n();return!(A!=null&&A===E.get().version)};let T,w,g,C,_=!1;const P=()=>{w=void 0;const E=t();if(!E||E.isDisposed())return;if(E.get().docId!==T){S();return}const A=y();A!=="none"&&a?.version!==E.get().version&&(a={version:E.get().version,failuresAtStart:o()}),A==="create"?r():A==="revision"?i():b()&&(T=E.get().docId,w=setTimeout(P,f()))},S=()=>{const E=t();_||!E||w!==void 0||y()==="none"&&!b()||(T=E.get().docId,w=setTimeout(P,f()))},M=E=>{E.source==="user"&&w!==void 0&&(clearTimeout(w),w=void 0),S()},v=()=>{const E=t();E!==g&&(C?.(),g=E,a=void 0,C=E?.subscribe(M),w!==void 0&&(clearTimeout(w),w=void 0))};return v(),S(),{refresh:()=>{_||(v(),S())},stop:()=>{_=!0,C?.(),C=void 0,g=void 0,w!==void 0&&(clearTimeout(w),w=void 0)}}}var Bs=F("documentSession.autosaveUiFacts"),Us={isUserBusy:!1,saveContext:{}};function ku(e){return e.getOrCreateInstance(Bs,()=>Ee(Us))}function Qn(e){return e?.getInstance(Bs)?.get()??Us}function Hs(e){return Qn(e).saveContext.fallbackTitle||"Untitled email."}var Lu=1e4,Nu=3e4;function Fu(e,t){const n=f=>{const m=e.getInstance(oe)?.layers?.(),y=m?Du(m,f):void 0;return typeof y=="number"&&y>=0?y:void 0},r=()=>{const f=t.current(),m=f?.get().serverId??void 0,y=ye(t.sessionKey()),b=t.recoveryFacts(),T=b?.emailId===m?b:void 0,w=t.revisionFacts(),g=T?.latestRevisionAt,C=w?.lastRevisionAt,_=Ms(e).profile;return{isInited:y||f?.get().attributes.is_inited===!0,isEnabled:!!_?.autosaves&&!wu(e),isHistoryLoaded:T?.historyLoaded===!0,isUserBusy:Qn(e).isUserBusy,isHeadless:bu(e),autosaveTimeoutMs:Ns(e).autosaveTimeout||Lu,latestRevisionAt:g!==void 0||C!==void 0?Math.max(g??0,C??0):void 0,snapshotVersion:w?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Nu,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},i=()=>{const f=Qn(e).saveContext;return{...f,project:f.project??t.current()?.get().attributes.project,fallbackTitle:Hs(e)}},o=Mu({readDocument:()=>t.current(),readEnvironment:r,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>yd(t.saveState().error),onCreate:()=>{ye(t.sessionKey())||t.save("materialize",i())},onRevision:()=>{t.save("snapshot",{project:i().project})}}),s=t.subscribe(o.refresh),a=Wr(e).watch(()=>o.refresh()),c=ku(e).watch(()=>o.refresh()),d=Ls(e).watch(()=>o.refresh());return()=>{s(),a.dispose(),c.dispose(),d.dispose(),o.stop()}}var xi=12e3;function Le(e){return e.getOrCreateInstance(Fr,()=>{const t=Xd({resolveAdapters:(r,i)=>Uu(r,e,i),resolveWritePort:()=>$s(e),resolveHistoryPort:r=>ye(r)?Vs(e):Gs(e),resolveTerms:()=>ru(e),canEdit:r=>Bc(e,r),notifyBeforeSave:zc(e),timeoutMs:xi,onAdapterError:(r,i)=>{i instanceof Error&&i.message;const o=Qd(i),s=Jd(i);St(i,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(o),network_failure:String(s)},level:o||s?"warning":"error"})},onTimeout:r=>{}}),n=Fu(e,t);return e.getInstance(U)?.addDispose(n),t})}function Kr(e){return e?.getInstance(Fr)}function $s(e){const t=eu(e);return t?Yr(e)?vu(t,Ve(e).email(e)):t:Ve(e).email(e)}function ju(e){return Rs(e)!==void 0||Cs(e)}function Gs(e){const t=Rs(e);return t?Yr(e)?(Z("port:history:server-backed"),Ds(t,Ve(e).history(e))):(Z("port:history:integrator"),t):(Z("port:history:rest (порт не зарегистрирован)"),Ve(e).history(e))}function Vs(e){const t=As(e);return t?Yr(e)?(Z("port:block-history:server-backed"),Ds(t,Ve(e).blockHistory(e))):(Z("port:block-history:integrator"),t):(Z("port:block-history:rest (порт не зарегистрирован)"),Ve(e).blockHistory(e))}function Bu(e){return As(e)!==void 0||Cs(e)}function Yr(e){return ns(e)}function Uu({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>Es(e),required:!0}):n&&s.push(Zd($s(i),n)),t&&s.push({id:"plugin",load:()=>_s(t)});const a=ye(r);return Wc(n)&&(a?Bu(i):ju(i))&&s.push(gu({port:a?Vs(i):Gs(i),revisionServiceEnabled:ns(i),...!a&&Uc(i)?{isHistoryAvailable:()=>Hc(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:c=>o.publishRecoveryFacts(c)})),s}function ae(e){return e.getOrCreateInstance(Ot,()=>new xt)}var qs=new WeakMap,Zn=new WeakMap;function be(e){return qs.get(e)??0}function er(e,t){let n=Zn.get(e);return n||(n=new Set,Zn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Hu(e){qs.set(e,be(e)+1),Zn.get(e)?.forEach(t=>t())}function $u(e){const t=Le(e),n=ae(e).addListener($.APPLICATION_HAS_AMP,r=>{dt(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(U)?.addDispose(()=>n.dispose())}function Gu(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Vu(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 Gu(c)?c:void 0}catch{return}}}}var Ge={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function qu(e){const t={maxBytes:e.maxBytes??Ge.maxBytes,maxImageBytes:e.maxImageBytes??Ge.maxImageBytes,ttlMs:e.ttlMs??Ge.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const a=m=>{const y=r.get(m);y&&(s-=y.bytes,r.delete(m))},c=m=>t.ttlMs<=0||n()-m.storedAt<t.ttlMs,d=()=>{if(s<=t.maxBytes)return;const m=[...r.entries()].sort((y,b)=>y[1].usedAt-b[1].usedAt);for(const[y]of m){if(s<=t.maxBytes)return;a(y)}},f=(m,y)=>{y.size>t.maxImageBytes||(r.set(m,{blob:y,bytes:y.size,storedAt:n(),usedAt:n()}),s+=y.size,d())};return{async get(m){const y=r.get(m);if(y&&c(y))return y.usedAt=n(),o.hits+=1,y.blob;y&&a(m);const b=i.get(m);if(b!==void 0)return b;o.loads+=1;const T=(async()=>{try{const w=await e.load(m);return w?f(m,w):o.failures+=1,w}catch{o.failures+=1;return}finally{i.delete(m)}})();return i.set(m,T),T},forget(m){a(m),i.delete(m)},configure(m){Object.assign(t,{maxBytes:m.maxBytes??t.maxBytes,maxImageBytes:m.maxImageBytes??t.maxImageBytes,ttlMs:m.ttlMs??t.ttlMs});for(const[y,b]of r)b.bytes>t.maxImageBytes&&a(y);d()},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var zu=["emcdn.ru","scr.emcdn.ru"];function Wu(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 Ku(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const a=Wu(s);a&&o.add(a)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Yu(e){const t=e??{},n=t.isPlugin!==!0?zu:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Ge};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:Ku(i.sourceHosts,n),maxBytes:i.maxBytes??Ge.maxBytes,maxImageBytes:i.maxImageBytes??Ge.maxImageBytes,ttlMs:i.ttlMs??Ge.ttlMs}}function Xu(e){const t=ae(e),n=e.getInstance(oe),r=()=>Yu({...n?.get(),isPlugin:!0});let i=r();const o=Vu({sourceHosts:()=>i.sourceHosts}),s=qu({load:w=>o.load(w),maxBytes:i.maxBytes,maxImageBytes:i.maxImageBytes,ttlMs:i.ttlMs}),a=()=>{t.send($.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:i.enabled,sourceHosts:[...i.sourceHosts]})},c=t.onInit(()=>a()),d=n?.watch(()=>{const w=r(),g=JSON.stringify(w)!==JSON.stringify(i);i=w,s.configure(w),w.enabled||s.clear(),g&&t.isInited()&&a()}),f={asked:0,served:0,refused:0},m=[],y=(w,g)=>(f.refused+=1,m.push({url:w,reason:g}),m.length>20&&m.shift(),{refused:!0}),b=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:i,counters:{...f},refusals:[...m],store:s.stats()})}),T=t.addListenerAsync($.APPLICATION_CANVAS_IMAGE_GET,async w=>{const g=w?.url??"";if(f.asked+=1,!i.enabled||!g)return y(g,"disabled");if(!o.accepts(g))return y(g,"host");w.fresh&&s.forget(g);const C=await s.get(g);return C?(f.served+=1,{blob:C}):y(g,"load-failed")});e.getInstance(U)?.addDispose(()=>{c.dispose(),d?.dispose(),T.dispose(),s.clear(),delete b.__emmCanvasImages__})}var Ju=2e3;function Qu(e){const t=ae(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,d=!1;const f=y=>{y.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",f),d&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",f),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const m=setTimeout(()=>{n.get(s)===m&&n.delete(s),!(c||!t.hasPort(s,a.port1))&&(St(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d=!0,t.holdPort(s))},Ju);n.set(s,m)},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(U)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var Zu=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function ef(e){return Zu.test(e)||e.indexOf("//")===0}function Vt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function tf(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Mi(e,t){const n=e==null||e===""?"./":String(e);if(ef(n))return Vt(n);const r=t??tf();if(!r)return Vt(n);try{return Vt(new URL(n,r).href)}catch{return Vt(n)}}function nf(){return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.publicPath?Mi(window.__emailmaker__.publicPath):Mi("/")}var rf=()=>"",of=()=>"3529b1de";function zs(e){const t=e?"iframe-eblock":"iframe",n=rf();if(n){const o=n.replace(/\/?$/,"/");return _i(`${o}${t}.html`,wt())}const r=of(),i=`${nf().replace(/\/?$/,"/")}iframe/`;return _i(`${i}${t}${r?`.${r}`:""}.html`,wt())}var ki="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function tr(e){return/^file:/i.test(String(e||"").trim())}function sf(e){return tr(e)?`${ki} allow-same-origin`:ki}var af="em:module-body-ack";function lf(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 Xr(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 cf(e){const t=Xr(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function df(e,t){const n=Xr(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function uf(e,t){const n=Xr(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 ff=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function pf(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&ff.test(t[t.length-2])}async function mf(e,t){const n=pf(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 hf(e){const t=new Map,n=(r,i)=>{const o=lf(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 Ie;function gf(e){try{return tr(new URL(e,window.location.href).href)}catch{return tr(window.location.href)}}function Ws(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 vf=()=>Promise.resolve(void 0);function Ks(){const e=zs(!1);if(!gf(e)){if(!Ie||Ie.canvasSrc!==e){const t=Ws(e)?mf:vf;Ie={canvasSrc:e,store:hf({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return Ie.store}}async function bf(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(df(i,e))}catch{}}function Jr(e){const t=Ks();if(!t||!Ie||Ie.warmed||!Ws(Ie.canvasSrc))return;Ie.warmed=!0;const{canvasSrc:n}=Ie,r=cf(n);r&&t.warm([r],e);const i={"js/iframe-eblock.js":["js/discussHandlers.BrvInbT7.js","js/typograf.all.B0pVhMV_.js"],"js/iframe.js":["js/rolldown-runtime.qcwTIabA.js","js/discussHandlers.BrvInbT7.js"],"js/darkreader.CLd5EML2.js":[],"js/discussHandlers.BrvInbT7.js":["js/rolldown-runtime.qcwTIabA.js"],"js/rolldown-runtime.qcwTIabA.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.B0pVhMV_.js":["js/rolldown-runtime.qcwTIabA.js"]};i?t.warm(uf(i,n),e):bf(n,o=>t.warm(o,e))}function yf(e){const t=Ks();if(!t)return;Jr();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:af,for:i.result},"*"),t.take(i.data?.url??"").then(s=>{o.postMessage({operationId:i.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(U)?.addDispose(()=>{window.removeEventListener("message",n)})}var Qe=/<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,Ef=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,rt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Li=/display:\s*none\s*!important/gi,_f=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,wf=/\s*height\s*:\s*100%\s*!important\s*;?/gi,Sf=/height\s*:\s*100%\s*!important/i,If=[".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 Cf(e){return Li.lastIndex=0,(e.match(Li)||[]).length}function Ys(e){const t=e.trim(),n=Cf(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=If.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 Tf(e){rt.lastIndex=0;for(const t of e.matchAll(rt))if(Ys(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Af(e){let t=!1;return rt.lastIndex=0,{html:e.replace(rt,n=>Ys(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Rf(e){return Qe.lastIndex=0,Qe.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Tf(e)}function Pf(e){if(!Rf(e))return{html:e,found:!1};let t=!1,n=e;Qe.lastIndex=0,Qe.test(n)&&(Qe.lastIndex=0,n=n.replace(Qe,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(Ef,""),t=!0);const r=Af(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Df(e){return!e||!Sf.test(e)?e:(rt.lastIndex=0,e.replace(rt,t=>t.replace(_f,(n,r,i,o)=>`${r}${i.replace(wf,"")}${o}`)))}function Xs(e){const t=Pf(e.replaceAll(`\r
|
|
1002
|
+
`)}function Tn(e,t){return Hr(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function gu({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:a,pageLoadTs:c=mu()}){let d=null,f=!1,m=!1,y=0,b={emailId:e,historyLoaded:!1,isRecovering:!1},T=null;const w=new Promise(D=>{T=D}),g=D=>{b={...b,...D},o(b)};let C;const _=D=>{y+=1,g({applied:{phase:D,seq:y}})},P=()=>{d?.timer&&clearTimeout(d.timer),d=null},S=D=>{if(!m){if(T){const N=T;T=null,N(D),C=D.revision?D.phase:void 0;return}s(D)&&D.revision&&_(D.phase)}},M=()=>{if(!d||m)return;const D=d.phase==="fast",N=D?cu:fu,I=D?uu:pu;d.timer=setTimeout(()=>{const O=d;if(!(!O||m)){if(O.attempts+=1,h(),D&&O.attempts>=I){const{pending:L}=O;ut(e),g({isRecovering:!1}),S({revision:{html:L.html,common_styles:L.common_styles,subject:L.subject,preheader:L.preheader},phase:"timeout"}),f=!0,O.phase="bg",O.attempts=0,M();return}if(!D&&O.attempts>=I){ut(e),P(),g({isRecovering:!1}),f=!0;return}M()}},N),d.timer.unref?.()},v=D=>{d={phase:"fast",attempts:0,pending:D,timer:null},g({isRecovering:!0}),M()},E=D=>{if(m)return;if(g({historyLoaded:!0,latestRevisionAt:D.latestAt!==void 0&&Number.isFinite(D.latestAt)?D.latestAt:void 0}),n&&d){const O=Tn(D,d.pending.sentAt);if(!O)return;const L=d.phase==="fast"?"found":"bg";ut(e),P(),g({isRecovering:!1}),f=!0,S({revision:O,phase:L});return}if(f)return;const N=n?Ps(e):null,I=N&&(N.sentAt<c||!hu(N.html,i()))?N:null;if(I){const O=Tn(D,I.sentAt);if(O){ut(e),f=!0,S({revision:O,phase:"found"});return}v(I);return}f=!0,S({revision:Tn(D),phase:"normal"})},A=D=>{m||(a?.(D),b.historyLoaded||(g({historyLoaded:!1,latestRevisionAt:void 0}),p()),!d&&S({revision:null,phase:"normal"}))},h=()=>t(e).then(E).catch(A);let l,u=!1;const p=()=>{u||d||m||(u=!0,l=setTimeout(()=>{l=void 0,!m&&!b.historyLoaded&&h()},du))},R=()=>{m||(g({historyLoaded:!1,latestRevisionAt:void 0}),S({revision:null,phase:"normal"}))};return r?r().then(D=>D?h():R()):h(),{verdict:()=>w,confirmVerdict(D){const N=C;C=void 0,D&&N!==void 0&&!m&&_(N)},dispose(){m=!0,l!==void 0&&(clearTimeout(l),l=void 0),P()}}}function vu({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const a=gu({emailId:r,readAutosave:c=>e.readAutosave(c),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:c,phase:d})=>{const f=Pi(c);return s?.(f)??!1},onError:c=>{c instanceof Error&&c.message}});return{id:"recovery",load:()=>a.verdict().then(({revision:c})=>Pi(c)),loaded(c){a.confirmVerdict(c)},watch(c){return s=c,()=>{s=null,a.dispose()}}}}function Ds(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){lu(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const i=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),i}}}function bu(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const i=Date.now(),o=await t.updateEmail(n,r);return await e.updateEmail(n,r),(Ps(n)?.sentAt??Number.POSITIVE_INFINITY)<=i&&ut(n),o}}}var Os=F("CurrentUser"),xs={};function Wr(e){return e.getOrCreateInstance(Os,()=>_e(xs))}function Ms(e){return e?.getInstance(Os)?.get()??xs}var ks=F("HeadlessMode");function Ls(e){return e.getOrCreateInstance(ks,()=>_e(!1))}function yu(e){return e?.getInstance(ks)?.get()??!1}var Eu=F("HiddenMount");function _u(e){return e.getOrCreateInstance(Eu,()=>_e(!1))}function wu(e){if(!e)return!1;try{return!!Mr(e).data?.act_as}catch{return!1}}function Su(e){return wu(e?.getInstance(Xo)?.get(Xl.em_token))}function Ns(e){return e?.getInstance(oe)?.get()??{}}function hn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Iu(e,t){return t.modeDefaults(hn(e,t.fallbackMode))}function Fs(e,t){const n=hn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function js(e,t){const n=hn(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function Cu(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Tu(e){return Ol(e.map(t=>t?.resourceProxy))}function Au(e){return Yl(e.map(t=>t?.resourceProxyPolicy))}function Ru(e){return El(e.map(t=>t?.backendProxy))}function Pu(e){return Vo(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Du(e,t){return[e.base,Iu(e,t),e.profile,e.serverSide,Fs(e,t.fallbackMode),e.local,e.user,js(e,t.fallbackMode)]}function An(e,t){const n=Du(e,t),r=Vo(n),i=Cu(n);i!==void 0&&(r.fileManager=i);const o=Tu(n);o!==void 0&&(r.resourceProxy=o);const s=Au(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=Ru(n);a!==void 0&&(r.backendProxy=a);const c=Pu(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function Ou(e,t,n){const r=Fs(e,n),i=js(e,n);return Kl([i,e.user,r,e.serverSide],t)}var xu=1.5;function Mu(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<=xu*e.autosaveTimeoutMs?"none":"revision"}function ku(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const c=E=>a!==void 0&&a.version===E.get().version?o()-a.failuresAtStart:0,d=E=>{const A=c(E);if(A<=0)return!1;const h=n().retryMaxAttempts??5;return!s()||A>h},f=()=>{const{autosaveTimeoutMs:E,retryIntervalMs:A}=n(),h=t();return h!==void 0&&c(h)>0&&A!==void 0&&A>0?A:E},m=E=>E.isNew()&&o()>=3,y=()=>{const E=t();if(!E||E.isDisposed()||d(E))return"none";const{latestRevisionAt:A,snapshotVersion:h,...l}=n(),u=Date.now(),p=Mu({...l,isDirty:E.isDirty(),isNew:E.isNew(),isReady:E.isReady(),latestRevisionAgeMs:A!=null&&A<=u?u-A:void 0,isSnapshotSent:h!=null&&h===E.get().version});return p==="create"&&m(E)?"none":p},b=()=>{const E=t();if(!E||E.isDisposed()||m(E)||d(E)||n().isHeadless)return!1;if(!E.isDirty())return E.isNew();const{snapshotVersion:A}=n();return!(A!=null&&A===E.get().version)};let T,w,g,C,_=!1;const P=()=>{w=void 0;const E=t();if(!E||E.isDisposed())return;if(E.get().docId!==T){S();return}const A=y();A!=="none"&&a?.version!==E.get().version&&(a={version:E.get().version,failuresAtStart:o()}),A==="create"?r():A==="revision"?i():b()&&(T=E.get().docId,w=setTimeout(P,f()))},S=()=>{const E=t();_||!E||w!==void 0||y()==="none"&&!b()||(T=E.get().docId,w=setTimeout(P,f()))},M=E=>{E.source==="user"&&w!==void 0&&(clearTimeout(w),w=void 0),S()},v=()=>{const E=t();E!==g&&(C?.(),g=E,a=void 0,C=E?.subscribe(M),w!==void 0&&(clearTimeout(w),w=void 0))};return v(),S(),{refresh:()=>{_||(v(),S())},stop:()=>{_=!0,C?.(),C=void 0,g=void 0,w!==void 0&&(clearTimeout(w),w=void 0)}}}var Bs=F("documentSession.autosaveUiFacts"),Us={isUserBusy:!1,saveContext:{}};function Lu(e){return e.getOrCreateInstance(Bs,()=>_e(Us))}function Qn(e){return e?.getInstance(Bs)?.get()??Us}function Hs(e){return Qn(e).saveContext.fallbackTitle||"Untitled email."}var Nu=1e4,Fu=3e4;function ju(e,t){const n=f=>{const m=e.getInstance(oe)?.layers?.(),y=m?Ou(m,f):void 0;return typeof y=="number"&&y>=0?y:void 0},r=()=>{const f=t.current(),m=f?.get().serverId??void 0,y=Ee(t.sessionKey()),b=t.recoveryFacts(),T=b?.emailId===m?b:void 0,w=t.revisionFacts(),g=T?.latestRevisionAt,C=w?.lastRevisionAt,_=Ms(e).profile;return{isInited:y||f?.get().attributes.is_inited===!0,isEnabled:!!_?.autosaves&&!Su(e),isHistoryLoaded:T?.historyLoaded===!0,isUserBusy:Qn(e).isUserBusy,isHeadless:yu(e),autosaveTimeoutMs:Ns(e).autosaveTimeout||Nu,latestRevisionAt:g!==void 0||C!==void 0?Math.max(g??0,C??0):void 0,snapshotVersion:w?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Fu,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},i=()=>{const f=Qn(e).saveContext;return{...f,project:f.project??t.current()?.get().attributes.project,fallbackTitle:Hs(e)}},o=ku({readDocument:()=>t.current(),readEnvironment:r,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>Ed(t.saveState().error),onCreate:()=>{Ee(t.sessionKey())||t.save("materialize",i())},onRevision:()=>{t.save("snapshot",{project:i().project})}}),s=t.subscribe(o.refresh),a=Wr(e).watch(()=>o.refresh()),c=Lu(e).watch(()=>o.refresh()),d=Ls(e).watch(()=>o.refresh());return()=>{s(),a.dispose(),c.dispose(),d.dispose(),o.stop()}}var xi=12e3;function Le(e){return e.getOrCreateInstance(Fr,()=>{const t=Jd({resolveAdapters:(r,i)=>Hu(r,e,i),resolveWritePort:()=>$s(e),resolveHistoryPort:r=>Ee(r)?Vs(e):Gs(e),resolveTerms:()=>iu(e),canEdit:r=>Uc(e,r),notifyBeforeSave:Wc(e),timeoutMs:xi,onAdapterError:(r,i)=>{i instanceof Error&&i.message;const o=Zd(i),s=Qd(i);St(i,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(o),network_failure:String(s)},level:o||s?"warning":"error"})},onTimeout:r=>{}}),n=ju(e,t);return e.getInstance(U)?.addDispose(n),t})}function Kr(e){return e?.getInstance(Fr)}function $s(e){const t=tu(e);return t?Yr(e)?bu(t,Ve(e).email(e)):t:Ve(e).email(e)}function Bu(e){return Rs(e)!==void 0||Cs(e)}function Gs(e){const t=Rs(e);return t?Yr(e)?(J("port:history:server-backed"),Ds(t,Ve(e).history(e))):(J("port:history:integrator"),t):(J("port:history:rest (порт не зарегистрирован)"),Ve(e).history(e))}function Vs(e){const t=As(e);return t?Yr(e)?(J("port:block-history:server-backed"),Ds(t,Ve(e).blockHistory(e))):(J("port:block-history:integrator"),t):(J("port:block-history:rest (порт не зарегистрирован)"),Ve(e).blockHistory(e))}function Uu(e){return As(e)!==void 0||Cs(e)}function Yr(e){return ns(e)}function Hu({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>Es(e),required:!0}):n&&s.push(eu($s(i),n)),t&&s.push({id:"plugin",load:()=>_s(t)});const a=Ee(r);return Kc(n)&&(a?Uu(i):Bu(i))&&s.push(vu({port:a?Vs(i):Gs(i),revisionServiceEnabled:ns(i),...!a&&Hc(i)?{isHistoryAvailable:()=>$c(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:c=>o.publishRecoveryFacts(c)})),s}function ae(e){return e.getOrCreateInstance(Ot,()=>new xt)}var qs=new WeakMap,Zn=new WeakMap;function ye(e){return qs.get(e)??0}function er(e,t){let n=Zn.get(e);return n||(n=new Set,Zn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function $u(e){qs.set(e,ye(e)+1),Zn.get(e)?.forEach(t=>t())}function Gu(e){const t=Le(e),n=ae(e).addListener(H.APPLICATION_HAS_AMP,r=>{dt(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(U)?.addDispose(()=>n.dispose())}function Vu(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function qu(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 Vu(c)?c:void 0}catch{return}}}}var Ge={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function zu(e){const t={maxBytes:e.maxBytes??Ge.maxBytes,maxImageBytes:e.maxImageBytes??Ge.maxImageBytes,ttlMs:e.ttlMs??Ge.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const a=m=>{const y=r.get(m);y&&(s-=y.bytes,r.delete(m))},c=m=>t.ttlMs<=0||n()-m.storedAt<t.ttlMs,d=()=>{if(s<=t.maxBytes)return;const m=[...r.entries()].sort((y,b)=>y[1].usedAt-b[1].usedAt);for(const[y]of m){if(s<=t.maxBytes)return;a(y)}},f=(m,y)=>{y.size>t.maxImageBytes||(r.set(m,{blob:y,bytes:y.size,storedAt:n(),usedAt:n()}),s+=y.size,d())};return{async get(m){const y=r.get(m);if(y&&c(y))return y.usedAt=n(),o.hits+=1,y.blob;y&&a(m);const b=i.get(m);if(b!==void 0)return b;o.loads+=1;const T=(async()=>{try{const w=await e.load(m);return w?f(m,w):o.failures+=1,w}catch{o.failures+=1;return}finally{i.delete(m)}})();return i.set(m,T),T},forget(m){a(m),i.delete(m)},configure(m){Object.assign(t,{maxBytes:m.maxBytes??t.maxBytes,maxImageBytes:m.maxImageBytes??t.maxImageBytes,ttlMs:m.ttlMs??t.ttlMs});for(const[y,b]of r)b.bytes>t.maxImageBytes&&a(y);d()},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var Wu=["emcdn.ru","scr.emcdn.ru"];function Ku(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 Yu(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const a=Ku(s);a&&o.add(a)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Xu(e){const t=e??{},n=t.isPlugin!==!0?Wu:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Ge};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:Yu(i.sourceHosts,n),maxBytes:i.maxBytes??Ge.maxBytes,maxImageBytes:i.maxImageBytes??Ge.maxImageBytes,ttlMs:i.ttlMs??Ge.ttlMs}}function Ju(e){const t=ae(e),n=e.getInstance(oe),r=()=>Xu({...n?.get(),isPlugin:!0});let i=r();const o=qu({sourceHosts:()=>i.sourceHosts}),s=zu({load:w=>o.load(w),maxBytes:i.maxBytes,maxImageBytes:i.maxImageBytes,ttlMs:i.ttlMs}),a=()=>{t.send(H.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:i.enabled,sourceHosts:[...i.sourceHosts]})},c=t.onInit(()=>a()),d=n?.watch(()=>{const w=r(),g=JSON.stringify(w)!==JSON.stringify(i);i=w,s.configure(w),w.enabled||s.clear(),g&&t.isInited()&&a()}),f={asked:0,served:0,refused:0},m=[],y=(w,g)=>(f.refused+=1,m.push({url:w,reason:g}),m.length>20&&m.shift(),{refused:!0}),b=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:i,counters:{...f},refusals:[...m],store:s.stats()})}),T=t.addListenerAsync(H.APPLICATION_CANVAS_IMAGE_GET,async w=>{const g=w?.url??"";if(f.asked+=1,!i.enabled||!g)return y(g,"disabled");if(!o.accepts(g))return y(g,"host");w.fresh&&s.forget(g);const C=await s.get(g);return C?(f.served+=1,{blob:C}):y(g,"load-failed")});e.getInstance(U)?.addDispose(()=>{c.dispose(),d?.dispose(),T.dispose(),s.clear(),delete b.__emmCanvasImages__})}var Qu=2e3;function Zu(e){const t=ae(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,d=!1;const f=y=>{y.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",f),d&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",f),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const m=setTimeout(()=>{n.get(s)===m&&n.delete(s),!(c||!t.hasPort(s,a.port1))&&(St(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d=!0,t.holdPort(s))},Qu);n.set(s,m)},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(U)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var ef=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function tf(e){return ef.test(e)||e.indexOf("//")===0}function Vt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function nf(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Mi(e,t){const n=e==null||e===""?"./":String(e);if(tf(n))return Vt(n);const r=t??nf();if(!r)return Vt(n);try{return Vt(new URL(n,r).href)}catch{return Vt(n)}}function rf(){return typeof window.__emailmaker__<"u"&&window.__emailmaker__?.publicPath?Mi(window.__emailmaker__.publicPath):Mi("/")}var of=()=>"",sf=()=>"d92031f0";function af(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function zs(e){const t=e?"iframe-eblock":"iframe",n=of();if(n){const o=af(n,window.location).replace(/\/?$/,"/");return _i(`${o}${t}.html`,wt())}const r=sf(),i=`${rf().replace(/\/?$/,"/")}iframe/`;return _i(`${i}${t}${r?`.${r}`:""}.html`,wt())}var ki="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function tr(e){return/^file:/i.test(String(e||"").trim())}function lf(e){return tr(e)?`${ki} allow-same-origin`:ki}var cf="em:module-body-ack";function df(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 Xr(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 uf(e){const t=Xr(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function ff(e,t){const n=Xr(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function pf(e,t){const n=Xr(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 mf=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function hf(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&mf.test(t[t.length-2])}async function gf(e,t){const n=hf(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 vf(e){const t=new Map,n=(r,i)=>{const o=df(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 Ce;function bf(e){try{return tr(new URL(e,window.location.href).href)}catch{return tr(window.location.href)}}function Ws(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 yf=()=>Promise.resolve(void 0);function Ks(){const e=zs(!1);if(!bf(e)){if(!Ce||Ce.canvasSrc!==e){const t=Ws(e)?gf:yf;Ce={canvasSrc:e,store:vf({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return Ce.store}}async function Ef(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(ff(i,e))}catch{}}function Jr(e){const t=Ks();if(!t||!Ce||Ce.warmed||!Ws(Ce.canvasSrc))return;Ce.warmed=!0;const{canvasSrc:n}=Ce,r=uf(n);r&&t.warm([r],e);const i={"js/iframe-eblock.js":["js/discussHandlers.cyZrdU7c.js","js/typograf.all.B0pVhMV_.js"],"js/iframe.js":["js/rolldown-runtime.qcwTIabA.js","js/discussHandlers.cyZrdU7c.js"],"js/darkreader.CLd5EML2.js":[],"js/discussHandlers.cyZrdU7c.js":["js/rolldown-runtime.qcwTIabA.js"],"js/rolldown-runtime.qcwTIabA.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.B0pVhMV_.js":["js/rolldown-runtime.qcwTIabA.js"]};i?t.warm(pf(i,n),e):Ef(n,o=>t.warm(o,e))}function _f(e){const t=Ks();if(!t)return;Jr();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:cf,for:i.result},"*"),t.take(i.data?.url??"").then(s=>{o.postMessage({operationId:i.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(U)?.addDispose(()=>{window.removeEventListener("message",n)})}var Qe=/<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,wf=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,rt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Li=/display:\s*none\s*!important/gi,Sf=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,If=/\s*height\s*:\s*100%\s*!important\s*;?/gi,Cf=/height\s*:\s*100%\s*!important/i,Tf=[".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 Af(e){return Li.lastIndex=0,(e.match(Li)||[]).length}function Ys(e){const t=e.trim(),n=Af(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=Tf.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 Rf(e){rt.lastIndex=0;for(const t of e.matchAll(rt))if(Ys(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Pf(e){let t=!1;return rt.lastIndex=0,{html:e.replace(rt,n=>Ys(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Df(e){return Qe.lastIndex=0,Qe.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Rf(e)}function Of(e){if(!Df(e))return{html:e,found:!1};let t=!1,n=e;Qe.lastIndex=0,Qe.test(n)&&(Qe.lastIndex=0,n=n.replace(Qe,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(wf,""),t=!0);const r=Pf(n);return n=r.html,t=t||r.found,{html:n,found:t}}function xf(e){return!e||!Cf.test(e)?e:(rt.lastIndex=0,e.replace(rt,t=>t.replace(Sf,(n,r,i,o)=>`${r}${i.replace(If,"")}${o}`)))}function Xs(e){const t=Of(e.replaceAll(`\r
|
|
1003
1003
|
`,`
|
|
1004
|
-
`));return{html:Df(t.html),hasBrowserExtensionArtifacts:t.found}}function sn(e){return e?.getContent()??""}function Js(e,t){e?.mutate({content:bs(t)},{source:"remote"})}function Qr(e){return F(e)}function fe(e,t){return e.getOrCreateInstance(t,()=>new Me)}function te(e,t){return e.getOrCreateInstance(t,()=>new Me).event}function an(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var Of=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}},xf=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(pe("Superseded by newer show()")),n.aborted?Promise.reject(pe(n.reason)):(this._activeRequest=e,new Promise((r,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new Of(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(pe(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 Mf(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function kf(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=ls(e),n=cs(e),r=Gc(e.sandbox);t<n+r}var Qs=class{_controller=new AbortController;_externalSignalDisposable=new ie;_sessionChangeListeners=new Set;_showRegistry=new xf;_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 ls(this._timeouts)}getSandboxTimeoutMs(e){return as(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return cs(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=Mf(this._timeouts,e.timeouts),kf(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 ie,this._linkExternalSignal(e)}abort(e){const t=e??pe("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ie}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ie,this._showRegistry.rejectAll(pe("Init session replaced")),this._controller.signal.aborted||this._controller.abort(pe("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??pe()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??pe()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Zr=(()=>{const e=new Qs;return e.configure({}),e})(),Lf=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 Nf(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 Ff(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(Y(n),new Promise((r,i)=>{let o=!1,s,a;const c=f=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",d),f())},d=()=>{c(()=>i(pe(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 Lf(t)))},t)),n?.addEventListener("abort",d)}))}var jf=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 Bf(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 jf(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>i(c))})})}var Uf=2,ft=Symbol("sandbox:frame-replaced");function Ni(e){return e===ft}function we(e,t,n,r,i,o,s){const a=`sandbox:${t}`,c=o?.getSandboxTimeoutMs(t)??jr[t],d=()=>{let T=Bf(e.sendAsync(n,r),c,a);return T=rn(T,o?.signal),bt(a,T,i)};if(t==="INIT_START"&&Nf(e)){const T=o?.getSandboxReadyTimeoutMs()??2e4,w=e,g=C=>{const _=Ff(w,T,o?.signal);return bt("sandbox:INIT_START:ready-wait",_,i).then(()=>{if(!s||C<=0)return d();const P=s.getGeneration();let S;const M=new Promise((E,A)=>{S=s.onChange(()=>{s.getGeneration()!==P&&A(ft)})}),v=d();return v.catch(()=>{}),Promise.race([v,M]).finally(()=>S?.()).catch(E=>{if(E!==ft)throw E;return{...i},g(C-1)})})};return g(Uf)}if(!s)return d();const f=s.getGeneration();let m;const y=new Promise((T,w)=>{m=s.onChange(()=>{s.getGeneration()!==f&&w(ft)})}),b=d();return b.catch(()=>{}),Promise.race([b,y]).finally(()=>m?.()).catch(T=>{throw T===ft&&{...i},T})}var Hf=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],$f=200;function Zs(e=new Set){const t=new Set;return(n,r)=>{if(!Hf.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>=$f&&t.clear(),t.add(i))}}function ea(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Zs()}}var Gf=ea();function ze(e){return e?.getInstance(Cr)??Gf}function Vf(e){const t=Le(e),n=ae(e),r=()=>e.getInstance(Ae)??Zr;let i,o,s=!1,a=!1;const c=async(_,P,S)=>{const M=S.generation,v=()=>S.generation!==M||S.signal.aborted||t.current()!==_||a,E=be(n);s=!0;try{if(await we(n,"INIT_START",$.SANDBOX_INIT_START,{guid:P},void 0,S),v())return;const{html:A,hasBrowserExtensionArtifacts:h}=Xs(sn(_));if(h&&fe(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Js(_,A),await we(n,"SET_ENTITY",$.SANDBOX_SET_ENTITY,an(sn(_),P,ze(e).editorPolicy,_.get().version),void 0,S),v())return;await we(n,"INITED",$.SANDBOX_INITED,{guid:P},void 0,S),i=P,o=E}finally{s=!1}},d=()=>ye(t.sessionKey())?t.current():void 0,f=()=>{if(a||s)return;const _=d(),P=_?.get().docId;if(!_||!P||i===P&&o===be(n)||!_.isReady())return;const S=r();S.signal.aborted||c(_,P,S).catch(()=>{})};let m=!1;const y=()=>{m||a||(m=!0,queueMicrotask(()=>{m=!1,f()}))};let b,T;const w=()=>{const _=d(),P=_?.get().docId;P!==T&&(b?.(),T=P,b=_?.subscribe(y)),y()},g=t.subscribe(w),C=er(n,y);w(),e.getInstance(U)?.addDispose(()=>{a=!0,C(),b?.(),g()})}var qf=200;function zf({startVersion:e,limit:t=qf}){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(d=>d.version>s);i(s);let c=o;for(const d of a){if(d.contentReplaced||!d.changes)return null;const f=d.changes,m=[];for(const y of c){if(d.fromCanvas&&f.some(T=>y.range.start<=T.oldEnd&&y.range.end>=T.oldPosition))return null;const b=ed(y.range,f,"after");if(!b)return null;m.push({range:b,text:y.text})}c=m}return c}}}function Wf(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new ge(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function Kf(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Wf(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Yf(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var ei=F("canvas.sandboxFill");function ta(e){return e.getInstance(ei)?.pipeline.isEventsLocked()===!0}function qt(e){St(e,{origin:"canvas-channel"})}function Xf(e){const t=Le(e),n=ae(e);let r;const i=(c,d)=>{const f=c.get().docId;let m=!1,y=null,b=null;const T=zf({startVersion:c.get().version});let w=c.getContent(),g=!0;const C=(E,A)=>{!g||t.current()!==c||(St(A,{origin:"canvas-channel"}),n.sendAsync($.SANDBOX_SET_ENTITY,an(sn(c),f,ze(e).editorPolicy,c.get().version)).catch(qt))},_=async(E,A)=>{if(b){b.push({edits:E,rev:A});return}b=[{edits:E,rev:A}];try{do{const h=b.splice(0,b.length);await n.sendAsync($.SANDBOX_UPDATE_ENTITY,{edits:h.map(l=>l.edits),guid:f,rev:h[h.length-1].rev})}while(b.length)}catch(h){C("app edits failed to reach the canvas",h)}finally{b=null}},P=(E,A)=>{const h=b?.splice(0,b.length)??[];h.length&&n.sendAsync($.SANDBOX_UPDATE_ENTITY,{edits:h.map(l=>l.edits),guid:f,rev:h[h.length-1].rev}).catch(qt),n.sendAsync($.SANDBOX_UPDATE_ENTITY,{edits:[E],guid:f,rev:c.get().version,...A!==null?{changeId:A}:{}}).catch(qt)},S=E=>{const{guid:A,pushUndoStop:h}=E;if(A!==f)return;const l=ud(E);let{edits:u}=E;if(l.baseRev!==null){const R=T.rebase(u,l.baseRev);if(!R){St(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),P([],l.changeId);return}u=R}const p=c.get().version;try{m=!0,y=l.changeId;const R=Kf(u,c.getContent());h===!1?d.applyWithoutHistory(R):c.mutate({changes:R},{source:ta(e)?"system":"user"})}catch(R){C("canvas batch failed to apply",R);return}finally{m=!1,y=null}c.get().version===p&&l.baseRev!==null&&P([],l.changeId)},M=c.subscribe(({changes:E,version:A})=>{const h=c.getContent(),l=!E?.length&&h!==w;if(w=h,T.record({version:A,changes:E,contentReplaced:l,fromCanvas:m}),!E?.length)return;const u=Yf(E);m?P(u,y):_(u,A).catch(qt)}),v=n.addListener($.APPLICATION_UPDATE_ENTITY,S);return()=>{g=!1,M(),v.dispose()}};let o;const s=()=>{const c=t.current(),d=t.history(),f=c?.get().docId;f!==o&&(r?.(),r=void 0,o=f,c&&d&&(r=i(c,d)))},a=t.subscribe(s);s(),e.getInstance(U)?.addDispose(()=>{r?.(),a()})}var Jf=/^(?:ant|vscode|monaco|docs)-/;function Qf(e){return Jf.test(e)}function Zf(){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 ep=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function tp(){return ep}var np=new Set;function rp(e,t,n=np){return e.startsWith(`${t}-`)?!1:!Qf(e)&&!n.has(e)}function ip(e,t){return`--${t}-${e}`}function na(e){const t=Zf();return rp(e,t,tp())?ip(e,t):`--${e}`}function op(e,t){const n=na(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function sp(e,t){return op(e,t)}function qe(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 Ue(e){return!e||e==="none"}function ap(e){const t=e.contain??"",n=e.willChange??"";return!Ue(e.transform)||!Ue(e.perspective)||!Ue(e.filter)||!Ue(e.backdropFilter)||!Ue(e.translate)||!Ue(e.rotate)||!Ue(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Fi(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 lp(e){const t=[],n=document.documentElement,r=Fi(getComputedStyle(n)),i=r.x||r.y;let o="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(o=s);for(let a=qe(e);a&&a!==n;a=qe(a)){const c=getComputedStyle(a),d=o==="none"||ap(c)||o==="absolute"&&!!c.position&&c.position!=="static",f=a===document.body&&!i;if(d){o="none";const m=f?{x:!1,y:!1}:Fi(c);(m.x||m.y)&&t.push({node:a,...m})}(c.position==="absolute"||c.position==="fixed")&&(o==="none"||c.position==="fixed")&&(o=c.position==="fixed"?"fixed":"absolute")}return t}function ra(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 zt(e){return Number.parseFloat(e)||0}function nr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=ra(e),i=zt(n.borderLeftWidth),o=zt(n.borderTopWidth),s=zt(n.borderRightWidth),a=zt(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-i-s):0,d=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+d)*r.y}}function cp(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(nr(o.node),o.x,o.y)),n&&i(nr(n),!0,!0),r}var rr={originX:0,originY:0,scaleX:1,scaleY:1};function ln(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 ia(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 oa(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 dp=1e3;function up(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()+dp,a()},d=[window],f=[document.documentElement];for(let g=t;g;g=qe(g)){const C=g.getRootNode();C instanceof ShadowRoot&&!d.includes(C)&&(d.push(C),f.push(C))}const m=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];d.forEach(g=>m.forEach(([C,_])=>g.addEventListener(C,_,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const y=typeof MutationObserver=="function"?new MutationObserver(g=>{g.some(C=>!n.contains(C.target))&&a()}):void 0;f.forEach(g=>y?.observe(g,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let b;try{if(typeof ResizeObserver=="function"){const g=new ResizeObserver(a);typeof g.observe=="function"&&(b=g)}}catch{b=void 0}let T=[];return{schedule:a,observe:g=>{!b||g.length===T.length&&g.every((C,_)=>C===T[_])||(b.disconnect(),T=g,g.forEach(C=>b?.observe(C)))},dispose(){o=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),d.forEach(g=>m.forEach(([C,_])=>g.removeEventListener(C,_,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),y?.disconnect(),b?.disconnect()}}}var sa=300,ji=15e3,fp=5e3,Bi="em-canvas-busy-style";function pp(){if(document.getElementById(Bi))return;const e=document.createElement("style");e.id=Bi,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var mp="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 hp(e){const t=sp("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(na("colorPrimary")).trim()||t}function aa(e){pp();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",mp),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:${hp(e)};animation:em-canvas-busy-spin 1s linear infinite`),i.appendChild(n),i}function gp(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 vp(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&&!oa({left:o.left,top:o.top,width:o.width,height:o.height},i)){const s=ln(i,ia(o,ln(i,rr),rr));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=gp(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(aa(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Rn(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(aa(e))},sa);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var bp=8e3;function yp(){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:()=>{},dispose:()=>{}}}function Ep(e,t){for(let n=qe(e);n;n=qe(n)){const r=getComputedStyle(n),i=r.overflowX!=="visible"||r.overflowY!=="visible",o=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>Ye(s)>0);if(i&&o)return n;if(n===t)return null}return null}function Ye(e){return Number.parseFloat(e)||0}function Wt(e,t){return Math.abs(e-t)<=1}function _p(e){const t=getComputedStyle(e),n=Ye(t.borderTopWidth),r=Ye(t.borderRightWidth),i=Ye(t.borderBottomWidth),o=Ye(t.borderLeftWidth),s=(a,c,d)=>Math.max(0,Ye(a)-Math.max(c,d));return{...nr(e),radii:[s(t.borderTopLeftRadius,n,o),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,i,r),s(t.borderBottomLeftRadius,i,o)]}}function wp(e,t){const n=Wt(t.top,e.top),r=Wt(t.bottom,e.bottom),i=Wt(t.left,e.left),o=Wt(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 Sp(e,t,n,r,i,o){const s=n.readyTimeoutMs??bp,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";const c=n.resolveSrc(e),d=document.createElement("iframe");d.setAttribute("sandbox",n.resolveSandbox(c)),d.setAttribute("allow","clipboard-read; clipboard-write"),d.setAttribute("title","Email content"),d.style.width="100%",d.style.border="0",d.style.display="block",d.style.minHeight="600px",d.src=c,a.appendChild(d),t.appendChild(a),n.mark?.("created"),i||n.onCreated?.(d);const f=new ie;let m=!1,y,b=!1,T,w,g,C;const _=()=>{clearTimeout(C),C=setTimeout(()=>{b||(b=!0,w?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},P=()=>m?(g=Promise.resolve(),b=!0,g):(b=!1,g=new Promise((N,H)=>{T=N,w=H}),_(),g),S=()=>{if(clearTimeout(C),m=!0,b){g=Promise.resolve();return}b=!0,n.mark?.("loaded"),T?.()};d.addEventListener("load",S),f.addDispose(()=>{clearTimeout(C),d.removeEventListener("load",S)});let M;const v=()=>{M??=n.bindResizer?.(d)},E=()=>{M?.dispose(),M=void 0};let A=null,h=null,l,u=rr,p="",R="",D=0;const L=N=>{const H=JSON.stringify(N);return H===p?!1:(p=H,a.style.visibility=N.visibility,a.style.left=`${N.css.left}px`,a.style.top=`${N.css.top}px`,a.style.width=`${N.css.width}px`,a.style.height=`${N.css.height}px`,a.style.borderRadius=N.radius,d.style.width=N.elementWidth>0?`${N.elementWidth}px`:"100%",d.style.transform=N.shiftX!==0?`translate(${N.shiftX}px, ${N.shiftY}px)`:`translateY(${N.shiftY}px)`,!0)},I=()=>{if(!A)return p="",a.style.visibility="hidden",d.removeAttribute("id"),!1;n.elementId&&(d.id=n.elementId);const N=A.getBoundingClientRect(),H=lp(A),W=h?.isConnected?h:null;l?.observe([A,d,...H.map(q=>q.node),...W?[W]:[]]);const z=cp(N,H,W),ne=Math.max(0,z.right-z.left),Re=Math.max(0,z.bottom-z.top),st=getComputedStyle(A).visibility==="visible",Fe=ne<=0||Re<=0,Pe=Fe?{left:z.left,top:z.top,right:z.left,bottom:z.top}:z,Ut=Fe?null:Ep(A,W??H[0]?.node??null),x=Ut?wp(_p(Ut),Pe):"",V=q=>L({visibility:st?"":"hidden",css:ln(Pe,q),elementWidth:N.width/q.scaleX,shiftX:(N.left-Pe.left)/q.scaleX,shiftY:(N.top-Pe.top)/q.scaleY,radius:x});let G=V(u);if(!Fe){const q=a.getBoundingClientRect();q.width>0&&!oa({left:q.left,top:q.top,width:q.width,height:q.height},Pe)&&(u=ia(q,ln(Pe,u),u),G=V(u)||G)}return G},O=()=>{if(!A)return!1;let N=I();const H=d.getBoundingClientRect().height;H>0&&H!==D&&(D=H,A.style.height=`${H/ra(A).y}px`,N=!0);const W=getComputedStyle(A).pointerEvents;return W!==R&&(R=W,a.style.pointerEvents=W),N},k=()=>{l?.dispose(),l=void 0},ee=N=>{l=up({slot:N,own:a,measure:O,onDetached:k})};let ce=[];const X=(N,H)=>{if(h=H,N&&ce.length>0){const W=ce;ce=[],W.forEach(z=>z())}if(N===A){N&&!l&&ee(N),O();return}if(k(),A&&A.style.removeProperty("height"),p="",D=0,R="",A=N,!N){I(),E();return}n.onShown?.(d),ee(N),O(),v()};f.addDispose(k);const J=N=>{m=!1,y=void 0,o?.(),N&&n.onReload?.(d);let H;b||g===void 0?H=P():(_(),H=g);try{d.contentWindow?.location.reload()}catch{d.src=c}return H};return{element:d,ready(){return g??P()},reload:()=>J(!0),reloadQuietly:()=>J(!1),followReload:()=>{y=void 0,o?.(),n.onReload?.(d)},moveTo(N){if(a.parentNode===N)return g??P();m=!1,y=void 0,o?.();let H;return b||g===void 0?H=P():(_(),H=g),N.appendChild(a),n.onReload?.(d),p="",l?.schedule(),H},get shown(){return A!==null},get slot(){return A},whenShown(){return A!==null?Promise.resolve():new Promise(N=>{ce.push(N)})},get filled(){return y},noteFilled(N){y=N},alignTo(N,H){X(N,H??null)},scrollBy(N,H){let W=N,z=H;for(let ne=A?qe(A):null;ne;ne=qe(ne)){if(Math.abs(W)<1&&Math.abs(z)<1)return;const Re=getComputedStyle(ne);if((Re.overflowY==="auto"||Re.overflowY==="scroll")&&ne.scrollHeight>ne.clientHeight){const st=ne.scrollTop,Fe=ne.scrollLeft;ne.scrollBy({left:W,top:z,behavior:"instant"}),W-=ne.scrollLeft-Fe,z-=ne.scrollTop-st}}(Math.abs(W)>=1||Math.abs(z)>=1)&&window.scrollBy({left:W,top:z,behavior:"instant"})},resize(){M?.resize()},dispose(){X(null,null),E(),f.dispose(),a.remove()}}}function Ip(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(u,p)=>u==="email"?`email:${p??n}`:u,o=new Map;let s,a=[],c=!1,d,f,m=!1,y,b,T="shown",w=0,g,C,_;const P=u=>f!==void 0&&u.filled!==void 0&&u.filled!==f,S=()=>{g=void 0;const u=y;!m||!u||f===void 0||C===f||!P(u)||(C=f,e.onForeignDocument?.({wanted:f,filled:u.filled,role:T,heldMs:Date.now()-w}))},M=()=>{m=!1,y=void 0,b=void 0,clearTimeout(g),g=void 0},v=(u,p)=>{const R=o.get("email"),D=R?.slot??null;return u&&D&&P(u)?(u.alignTo(null),m||(m=!0,w=Date.now(),g=setTimeout(S,fp)),T=p,y=u,!(s!==void 0||c)&&b!==u&&(b=u,e.onShown?.(u.element)),!d&&!s&&(d=Rn(D)),!1):(m&&(M(),d?.remove(),d=void 0),u?.alignTo(D,R?.clip??null),!0)},E=()=>{m&&!c&&v(t.get(i("email")),"shown")},A=()=>{a.forEach(u=>clearTimeout(u)),a=[],s?.remove(),s=void 0,d?.remove(),d=void 0,(c||m)&&(c=!1,v(t.get(i("email")),"shown"))},h=(u,p,R)=>{const D=i(u,p),L=t.get(D);if(L)return L;const I=e.resolveMount();if(!I)return yp();const O=Sp(u,I,e,u==="email"?p??n:void 0,R,u==="email"?()=>E():void 0);return t.set(D,O),O},l={get:u=>h(u),current:u=>h(u),peek:u=>t.get(i(u)),spare:()=>t.get(i("email",r())),ensureSpare:()=>h("email",r(),!0),promote(){const u=t.get(i("email",r()));if(!u)return;const p=t.get(i("email"));n=r(),_=void 0,v(u,"spare"),p?.alignTo(null)},alignSurface(u,p,R){const D=o.get(u);if(o.set(u,{slot:p,clip:R??null}),u==="email"&&c){d?.remove(),d=p?Rn(p):void 0;return}const L=p?h(u):t.get(i(u));if(u!=="email"){L?.alignTo(p,R??null);return}if(!p){_=D?.slot&&L?.shown?{slot:D.slot,handle:L}:void 0,m&&(M(),d?.remove(),d=void 0),L?.alignTo(null);return}const I=_?.slot===p&&_.handle===L;if(_=void 0,D?.slot===p&&L?.shown||I){L?.alignTo(p,R??null);return}v(L,"shown")},want(u){f=u,u!==void 0&&E()},noteFilled(u,p){const R=l.byWindow(u);R&&(R.noteFilled(p),R===t.get(i("email"))&&E())},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const p of t.values())if(p.element.contentWindow===u)return p}},busy(u){if(A(),!u)return;if(!l.visible()){c=!0,d?.remove(),d=void 0;const D=o.get("email");D?.slot&&(d=Rn(D.slot)),a=[setTimeout(A,ji)];return}const p=e.resolveMount();if(!p)return;const R=vp(p,()=>l.visible()?.element.parentElement?.getBoundingClientRect()??null);s=R,a=[setTimeout(()=>R.showSpinner(),sa),setTimeout(A,ji)]},remount(u){A();const p=i("email");t.forEach((R,D)=>{if(D===p){R.moveTo(u).catch(()=>{});return}R.dispose(),t.delete(D)})},dispose(){f=void 0,c=!1,M(),_=void 0,A(),t.forEach(u=>u.dispose()),t.clear(),o.clear(),n="a",f=void 0,C=void 0}};return l}var Cp=F("canvas.resizerBinder"),ir=F("canvas.service"),Tp={created:le.canvasCreated,loaded:le.canvasLoaded},la=new WeakMap;function or(e){return la.get(e)??0}function Ap(e,t){if(e.getInstance(ir))return;const n=Ip({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:sf,elementId:t.elementId,bindResizer:i=>e.getInstance(Cp)?.(i),onCreated:i=>Qt(e,i,"fresh"),onReload:i=>{la.set(i,or(i)+1),Qt(e,i,"fresh")},onShown:i=>Qt(e,i,"switch"),mark:i=>t.mark?.(Tp[i]),onForeignDocument:i=>{({...i},Kc("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=ae(e).addListener($.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(ir,n),e.getInstance(U)?.addDispose(()=>{r.dispose(),n.dispose()})}function Qt(e,t,n){const r=ae(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),Hu(r))}function Rp(e,t){Qt(e,t,"promote")}function Pp(e,t){const n=t.contentWindow;n&&ae(e).greet(n)}function ca(e,t){const n=t.contentWindow;n&&ae(e).forget(n)}function Dp(e,t){const n=re(e)?.byWindow(t)?.element;if(!n)return;const r=or(n);return()=>or(n)!==r}function re(e){return e.getInstance(ir)}function Op(e){const t=ae(e),n=()=>re(e)?.byWindow(t.getTarget()),r=t.addListenerAsync($.RELOAD,()=>{n()?.followReload()}),i=t.addOffTargetListener($.RELOAD,a=>{const c=re(e)?.byWindow(a);c&&ca(e,c.element)}),o=t.addListener(a=>{a.data?.operation===$.SANDBOX_RESIZED&&n()?.resize()}),s=te(e,j.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(U)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose(),s.dispose()})}function Ui(){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 xp(e){const t=e.getInstance(se);let n,r;e.getInstance(U)?.addDispose(()=>{r?.remove(),r=void 0}),Ap(e,{resolveMount:()=>n,resolveSrc:o=>zs(o==="block"),elementId:"email_iframe",mark:o=>Z(o)}),t?.watch(o=>{const s=o?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,re(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(o!==void 0){n=r??=Ui(),re(e)?.alignSurface("email",r,r);return}else return;re(e)?.get("email")}});let i;e.getInstance(U)?.addDispose(()=>{i?.remove(),i=void 0}),Eu(e).watch(o=>{const s=re(e);if(s){if(o){i??=Ui(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var da=F("canvas.headerFlow"),Hi=["subject","preheader"],Mp=3e3,kp={subject:$.SANDBOX_SUBJECT_UPDATE,preheader:$.SANDBOX_PREHEADER_UPDATE};function Lp(e){const t=Le(e),n=ae(e),r=g=>g?"remote":ta(e)?"system":"user",i=(g,{guid:C,value:_,forced:P})=>{const S=dt(t);if(!S||typeof _!="string"||C&&C!==S.get().docId)return;const M=t.forcedHeaders();if(M?.[g]&&!P&&_!==M[g])return;P&&(m.delete(g),m.size===0&&t.endForcedHeaders());const v=S.get().attributes[g]??"";a=!0;try{Ct(S,{[g]:_},{source:r(P)})}finally{a=!1}o[g]=_,fe(e,j.ON_HEADER_APPLIED_ID).fire({field:g,value:_,forced:!!P,isGenerated:_!==v&&!!_})};let o={},s,a=!1,c=Promise.resolve();const d=(g,C,_,P=!1)=>{c=n.sendAsync(kp[g],{value:C,guid:dt(t)?.get().docId,..._?{force:!0,echo:!0}:{},...P?{undoStep:!0}:{}}).catch(S=>{})};let f;const m=new Set;e.inject(da,{whenDelivered:async()=>{await c},reassert:g=>{const C=dt(t),_=Hi.filter(P=>g[P]);if(!(!C||_.length===0)){a=!0;try{Ct(C,Object.fromEntries(_.map(P=>[P,g[P]])),{source:"system"})}finally{a=!1}t.beginForcedHeaders({subject:g.subject??"",preheader:g.preheader??""}),clearTimeout(f),f=setTimeout(()=>{m.clear(),t.endForcedHeaders()},Mp),m.clear();for(const P of _)m.add(P);for(const P of _)o[P]=g[P],d(P,g[P],!0)}}});const y=()=>{s?.(),s=void 0;const g=dt(t);if(!g){o={};return}const C=g.get().attributes;o={subject:C.subject,preheader:C.preheader},s=g.subscribe(({source:_})=>{if(a)return;const P=g.get().attributes,S=t.forcedHeaders();for(const M of Hi){const v=P[M];v!==o[M]&&(o[M]=v,d(M,v??"",_==="system"&&S?.[M]!==void 0,_==="user"))}})};y();const b=t.subscribe(y),T=n.addListenerAsync($.APPLICATION_SUBJECT_UPDATE,g=>i("subject",g)),w=n.addListenerAsync($.APPLICATION_PREHEADER_UPDATE,g=>i("preheader",g));e.getInstance(U)?.addDispose(()=>{T.dispose(),w.dispose(),b(),s?.(),clearTimeout(f)})}function $i(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function sr(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];$i(i)&&$i(o)?n[r]=sr(o,i):i!==void 0&&(n[r]=i)}return n}function Np(e,t){const n=Pr;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 sr(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?sr(n,t):n}function Fp(){const e=window.localStorage.getItem(Mt.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?nc:Ul;return e&&e!=="system"?e:t}function jp(){const e=window.localStorage.getItem(Mt.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function Bp(e){const{config:t}=e;return{operation:$.UPDATE_PREVIEW,theme:e.theme,commonStyles:Np(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}var Up=F("DefaultCommonStyles");function ua(e){return e.getOrCreateInstance(Up,()=>Ee(void 0))}function Hp(e,t){ua(e).set(t)}function $p(e){const t=ae(e),n=e.getInstance(oe),r=e.getInstance(se),i=Le(e);let o,s="";const a=()=>{const _=n?.get()??{},P=Bp({config:_,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:Fp(),codeMode:jp(),appName:"emailmaker"}),S=JSON.stringify(P);S!==s&&(s=S,t.send(P))},c=t.onInit(()=>{s="",a()}),d=()=>{t.isInited()&&a()},f=n?.watch(d),m=ua(e).watch(_=>{o=_,d()}),y=r?.watch(_=>{_&&"commonStyles"in _&&(o=_.commonStyles),d()});let b;const T=()=>{b?.(),b=i.current()?.subscribe(d),d()};T();const w=i.subscribe(T),g=matchMedia(Vl),C=()=>d();g.addEventListener("change",C),e.getInstance(U)?.addDispose(()=>{c.dispose(),f?.dispose(),m.dispose(),y?.dispose(),b?.(),w(),g.removeEventListener("change",C)})}var ar;(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=[],d=[];for(const f of i){const m=o.find(y=>s(f,y));m?d.push({prev:f,next:m}):c.push(f)}for(const f of o)i.find(m=>s(f,m))||a.push(f);return{added:a,removed:c,exists:d}}e.diff=r})(ar||(ar={}));function Gp(e,t){return e.type===t.type&&e.key===t.key}function Vp(e){const t=ae(e),n=()=>e.getServices(Xe)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send($.SANDBOX_ADD_EXTENSIONS,r)}),o=Tl(Xe),s=e.onInject(a=>{if(a!==o)return;const c=n();if(!t.isInited()){r=c;return}const{added:d,removed:f}=ar.diff(r,c,Gp);if(r=c,f.length){if(f.some(m=>m.type==="script")){t.send($.RELOAD);return}t.send($.SANDBOX_REMOVE_EXTENSIONS,f.map(m=>m.key))}d.length&&t.send($.SANDBOX_ADD_EXTENSIONS,d)});e.getInstance(U)?.addDispose(()=>{i.dispose(),s?.dispose()})}var qp=new Set([...Object.values($).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(Rr)]);function zp(e){return e.length>0&&!e.startsWith("em:")&&!qp.has(e)}function Wp(e){const t=ae(e),n=new Map;let r=!1,i=-1,o=new Set;const s=d=>(d!==i&&(i=d,o=new Set),o),a=t.observeOutgoing((d,f)=>{if(!r||!zp(d))return;const m=be(t);n.set(d,{data:f,generation:m,scripts:new Set(s(m))})}),c=t.addListener(Rr,d=>{if(d.phase!=="ready"||d.status!=="success")return;r=!0;const f=be(t),m=s(f);m.add(d.key);for(const[y,b]of n)b.generation===f||![...b.scripts].every(T=>m.has(T))||(b.generation=f,t.send(Wo(y),b.data))});e.getInstance(U)?.addDispose(()=>{a.dispose(),c.dispose()})}var Kp=F("prewarm.editorVisible");function Yp(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Xp(e={}){const t=e.paint??Yp;let n=!1,r=!1,i=!1,o=!1,s=!1;const a=[],c=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,Z(le.editorVisible);for(const d of a.splice(0))d()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){i=!0,c()},whenVisible(d){if(s){d();return}a.push(d)},contentShown:()=>i}}function Jp(e){return e.getOrCreateInstance(Kp,()=>Xp())}var Qp=500,Zp=500,em=5e3;function tm(e){const t=e.quietMs??Qp,n=e.floorMs??Zp,r=e.ceilingMs??em;let i,o,s=0;const a=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},c=()=>{a(),e.run()},d=()=>{clearTimeout(i);const f=n-(Date.now()-s);i=setTimeout(c,Math.max(t,f))};return{start(){a(),s=Date.now(),o=setTimeout(c,r),d()},notify(){i!==void 0&&d()},cancel:a}}function nm({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}var fa="self-init:";function rm(e){return e.startsWith(fa)}function pa(e,t){const n=e.getActiveShowRequest();return rm(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function im(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),i=()=>e.frameWatch?.();let o="",s;const a=T=>{s={target:e.readTarget?.(),docId:T}},c=()=>e.readDocument()?sn(e.readDocument()):o,d=()=>ze(e.container).editorPolicy,f=()=>e.readEmail(),m=()=>{const T=f();return{...T,id:e.isTemplate()||T.isNew?void 0:T.id,html:c()}};let y=!1;const b={readContent:c,publicEmail:m,sendInitStart:()=>we(n,"INIT_START",$.SANDBOX_INIT_START,{guid:f().renderGuid},void 0,r()),sendInited:()=>we(n,"INITED",$.SANDBOX_INITED,{guid:f().renderGuid},void 0,r(),i()),async sendContent(){const T=f(),{html:w,hasBrowserExtensionArtifacts:g}=Xs(T?.html||"");g&&e.events.browserExtensionDetected(),Js(e.readDocument(),w),o=w,a(T.renderGuid),await we(n,"SET_ENTITY",$.SANDBOX_SET_ENTITY,an(c(),T.renderGuid,d(),e.readDocument()?.get().version),{guid:T.renderGuid,emailId:T.id??null},r(),i())},refreshContent:()=>(a(f().renderGuid),we(n,"SET_ENTITY",$.SANDBOX_SET_ENTITY,an(c(),f().renderGuid,d(),e.readDocument()?.get().version),void 0,r(),i())),sendPreheader:async()=>{const T=f();if(T.preheader!==void 0)return we(n,"PREHEADER",$.SANDBOX_PREHEADER_UPDATE,{value:T.preheader,guid:T.renderGuid,force:!0},void 0,r(),i())},sendSubject:async()=>{const T=f();if(T.subject!==void 0)return we(n,"SUBJECT",$.SANDBOX_SUBJECT_UPDATE,{value:T.subject,guid:T.renderGuid,force:!0},void 0,r(),i())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:T=>e.showFilled?.(T),noteFilled:(T,w)=>e.noteFilled?.(T,w),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(m()),fireInit(T,w){if(!pa(t(),T)){t().getActiveShowRequest()?.showId;return}const g=f();g.id,g.renderGuid,t().completeShow(T);const C=e.readDocument();Ct(C,{is_inited:!0},{source:"system"});const _=()=>{const S=m();w&&(S.reset=!0);const M=e.events.inited(S);return w||(y&&b.fireEmailChanged(),y=!0),M};if(!C||C.isReady())return _();const{docId:P}=C.get();return C.whenReady().then(()=>e.readDocument()?.get().docId===P?_():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(m())},fireContentChanged(){e.events.contentChanged(c())}};return b}var om=2;function Gi(){return new Error("[sandbox] document reloaded during fill")}function sm(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Pn(e){try{e()}catch{}}function am(e){let t;return Pn(()=>{t=e()}),{stage:n=>Pn(()=>t?.stage(n)),end:(n,r)=>Pn(()=>t?.end(n,r))}}function lm(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,a,c;const d=()=>{const v=e.readTarget?.(),E=e.readSandboxGeneration?.();return v===void 0||E===void 0?void 0:{target:v,generation:E}},f=()=>{const v=d();return v&&{...v,canvasReplaced:e.trackDocument?.(v.target)}},m=v=>{if(v?.canvasReplaced?.())return!0;const E=d();return v!==void 0&&E?.target===v.target&&E.generation!==v.generation},b=im({...e,waitScope:()=>({getSandboxTimeoutMs:v=>t().getSandboxTimeoutMs(v),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const v=c;if(!(!v||!e.onSandboxGenerationChange))return{getGeneration:()=>d()?.generation??v.generation,onChange:E=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===v.target||v.canvasReplaced?.())&&E()})??(()=>{})}}});let T;const w=(v,E)=>{if(T===v)return;T=v;const A=s;setTimeout(()=>{s!==A||t().signal.aborted||P(v,E).catch(()=>{})},0)},g=()=>{a?.abort(),a=void 0};let C;const _=()=>{const v=t().signal;v!==C&&(C?.removeEventListener("abort",g),C=v,v.addEventListener("abort",g))};async function P(v,E,A=0){const h=++s;g(),a=new AbortController,c=void 0,_();const l=()=>s!==h,u=b.readTarget(),p=t().generation,R=()=>p===t().generation&&!t().signal.aborted,D=E?"init:reset-":"init:",L=am(()=>e.observeShow?.(sm(v,E,e.readEmail())));if(!E){const X=b.publicEmail();X?.id,X?.renderGuid,X?.preheader}let I=!1,O=!1,k,ee=!1;const ce=()=>{if(m(k))throw Gi()};try{n=!0,await b.sendInitStart(),l()||(k=f(),c=k),A===0&&b.fireWillInit(),await(E||A>0?b.refreshContent():b.sendContent()),I=!0,ce();const X=b.contentSent();b.noteFilled(X?.target,X?.docId),L.stage("content"),E||b.publicEmail()?.id;try{await b.sendPreheader()}catch(J){if(Ni(J))throw J;`${D}`,String(J)}try{await b.sendSubject()}catch(J){if(Ni(J))throw J;`${D}`,String(J)}if(ce(),l()||b.showFilled(u),await b.sendInited(),ce(),O=!0,i===v){const J=e.readSandboxGeneration?.()??o;J!==void 0&&(r=J)}L.stage("reveal"),await b.revealFilled(),ce(),L.end("revealed")}catch(X){const J=!l()&&R()&&m(k),N=J?Gi():void 0,H=N??X,W=J&&A<om?M(v,E,A+1):void 0;ee=J&&W===void 0;const z=l()?void 0:{showId:v,contentApplied:I,sandboxInitedAcked:O,superseded:!1,...e.describeSurface?.(),error:String(N??X)};z&&(`${D}`,void 0);const ne=!l()&&e.recoverFailedFill?.(u)===!0;if(L.end(l()?"superseded":ne?"recovered":Or(H)||!R()?"aborted":"failed",z),!ne&&!l()&&pa(t(),v)&&t().failShow(v,H),W!==void 0)return W;throw H}finally{S(v,E,D,{superseded:l(),sessionGeneration:p,contentApplied:I,sandboxInitedAcked:O&&!ee,retry:!ee,commit:R()})}}function S(v,E,A,h){const{superseded:l,contentApplied:u,sandboxInitedAcked:p}=h;if(l){`${A}`;return}p&&h.commit?b.fireInit(v,E||void 0):p?(`${A}`,h.sessionGeneration,t().generation,t().signal.aborted,void 0):u?(`${A}`,void 0):(`${A}`,void 0),n=!1,a=void 0,!p&&i===v&&(i=void 0,r===o&&(r=void 0)),!p&&u&&h.retry&&w(v,E)}function M(v,E,A){return P(v,E,A)}return{channel:b,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:v=>{r=v},lastCorrelation:()=>i,markCorrelation:v=>{i=v},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:v=>{o=v},fill:v=>P(v,!1),refill:v=>P(v,!0),stop:()=>{s+=1,g(),n=!1,C?.removeEventListener("abort",g),C=void 0}}}function cm(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:ma(e,n)}function ma(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function dm(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=f=>{const m=n(),y=i();if(!cm(m,f,y)){f.showId,f.navId,f.emailId,m?.id,m?.showId,m?.renderGuid;return}f.showId,m?.id,m?.renderGuid,t.markFilled(o()),t.markCorrelation(f.showId),t.fill(f.showId).catch(()=>{})};return{showRequested:f=>{s(f)},showRequestIdentityChanged:()=>{const f=e.initPipeline().getActiveShowRequest();f&&s(f)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const f=o();if(t.filledGeneration()===f)return;const m=n(),y=i();if(!m?.renderGuid||!ma(m,y))return;const b=`${fa}${m.renderGuid}`;t.markFilled(f),t.markCorrelation(b);const T=r()?.isReady()===!0;m.id,m.renderGuid,(T?w=>t.refill(w):w=>t.fill(w))(b).catch(()=>{t.lastCorrelation()===b&&t.markFilled(void 0)})},saasChanged:()=>{const f=n();f?.renderGuid,f?.showToken,f?.id,r()}}}var um=F("canvas.health");function fm(e){return e??""}function pm(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Vi(e){return e.length>0}function mm(e){const t=Le(e),n=ae(e),r=()=>ye(t.sessionKey())?void 0:t.current(),i=()=>{const x=r();return nm({attributes:x?.get().attributes??{},readContent:()=>x?.getContent(),docId:x?.get().docId,hasSession:!!x,serverId:x?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(Ae)??Zr;let s={},a=!1;const c=e.getInstance(se)?.watch(x=>{a=!!x?.element});let d=!1,f=!1,m=!1,y=0;const b=()=>{const x=re(e);if(!x)return;const V=++y,G=x.spare();return G&&ca(e,G.element),(G?G.reloadQuietly():x.ensureSpare()?.ready())?.then(()=>{if(V!==y)return;d=!0;const q=x.spare();q&&Pp(e,q.element),m&&(m=!1,p(),N())})},T=tm({run:()=>{m||b()?.catch(()=>{})}}),w=()=>{Jp(e).noteContentShown(),!d&&!m&&T.start()};let g=!1;const C=x=>{const V=re(e),G=V?.spare()?.element.contentWindow;f&&V&&G&&x===G&&(f=!1,V.promote(),V.busy(!1),g=!0)};let _=!1;const M=lm({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const x=re(e);return g&&x&&(g=!1,T.start()),a?x?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:C,noteFilled:(x,V)=>re(e)?.noteFilled(x,V),recoverFailedFill:x=>{const V=re(e),G=V?.spare()?.element.contentWindow;return!f||!V||!G||x!==G?!1:(f=!1,d=!1,l="reload",V.busy(!1),V.peek("email")?.reload(),_=!0,N(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>be(n),onSandboxGenerationChange:x=>er(n,x),trackDocument:x=>Dp(e,x),observeShow:x=>e.getInstance(um)?.begin(x),describeSurface:()=>({canvasPath:l,promoted:f,spareClean:d,handshake:n.isInited(),generation:be(n)}),events:{willInit:x=>{fe(e,j.WILL_EMAIL_INIT_ID).fire(x)},inited:x=>{w(),fe(e,j.ON_EMAIL_INIT_ID).fire(x)},contentChanged:x=>{fe(e,j.ON_CONTENT_CHANGED_ID).fire(x)},emailChanged:x=>{fe(e,j.ON_EMAIL_CHANGED_ID).fire(x)},browserExtensionDetected:()=>{fe(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),v=dm({pipeline:M,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>be(n)});let E="",A="",h="",l="none";const u=()=>{const x=re(e)?.spare()?.element.contentWindow;x&&n.getTarget()===x||n.sendNow({operation:$.SANDBOX_LOCK_EDIT,data:!0})},p=()=>{const x=re(e)?.spare();x&&(u(),d=!1,f=!0,Rp(e,x.element))},R=(x,V)=>{const G=re(e);if(!G)return!0;const q=G.spare(),je=q&&d?"spare":"prepare";if(l=je,G.busy(!0),q&&d)return p(),!0;T.cancel(),u();const Be=b();if(Be===void 0)return l="reload",G.busy(!1),G.peek("email")?.reload(),!0;m=!0;const De=y;return Be.catch(()=>{!m||De!==y||(m=!1,l="reload",G.busy(!1),G.peek("email")?.reload())}),!1},D=()=>{st(),M.noteSandboxGeneration(be(n));const x=i(),V=pm(x?.renderGuid,x?.showId,x?.id,s.emailId),G=fm(x?.renderGuid);if(G!==A){const Be=A;A=G;const De=re(e)?.peek("email")?.filled,vl=De!==void 0&&De!==G;Vi(G)&&(Vi(Be)||vl)&&R(Be||(De??""),G)}if(m)return;(V!==E||_)&&(_=!1,E=V,v.showRequestIdentityChanged());const q=r(),je=`${V}|${q?.get().docId??""}|${be(n)}`;je!==h&&q?.isReady()===!0&&(h=je,v.selfInitChanged()),v.saasChanged(),X()};let L=!1,I="",O="",k=!1,ee=!1;const ce=x=>{x.source==="user"?ee=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(k=!0),N()},X=()=>{const x=i();if(!x?.renderGuid)return;const V=M.channel.readContent(),G=JSON.stringify([x.preheader,x.common_styles,x.meta,x.subject,x.utm_parameters?.utm_campaign??"",x.utm_parameters?.utm_content??"",x.utm_parameters?.utm_medium??"",x.utm_parameters?.utm_source??"",x.utm_parameters?.utm_term??""]),q=L&&V!==O,je=L&&G!==I;L=!0,O=V,I=G;const Be=k&&!ee;if(k=!1,ee=!1,M.isEventsLocked()||Be)return;const De={...x,id:s.isTemplate||x.isNew?void 0:x.id,html:V};if(q){fe(e,j.ON_CONTENT_CHANGED_ID).fire(V),fe(e,j.ON_EMAIL_CHANGED_ID).fire(De);return}je&&x.is_inited&&fe(e,j.ON_EMAIL_CHANGED_ID).fire(De)};let J=!1;const N=()=>{J||(J=!0,queueMicrotask(()=>{J=!1,D()}))};e.inject(ei,{pipeline:M,setRoute:x=>{x.emailId===s.emailId&&!!x.isTemplate==!!s.isTemplate||(s=x,N())}});let H,W;const z=()=>{const x=r()?.get().docId;x!==W&&(H?.(),W=x,H=r()?.subscribe(ce)),N()};let ne,Re;const st=()=>{const x=e.getInstance(Ae);!x||x===ne||(Re?.(),ne=x,Re=x.onShowRequested(V=>v.showRequested(V)))},Fe=n.addListener(x=>{x.data?.operation===$.SANDBOX_RESIZED&&T.notify()}),Pe=t.subscribe(z),Ut=er(n,N);z(),e.getInstance(U)?.addDispose(()=>{c?.dispose(),Re?.(),Ut(),Pe(),H?.(),Fe.dispose(),T.cancel(),M.stop()})}function hm(){return $l!=="emailmaker"}var gm={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:"",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},ha={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:"",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}},qi=ha,vm=["pro"],lr={};function bm(e){lr=e}var ga=e=>vm.includes(e)?qi:lr[e]??lr.editor??qi,cr={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:"",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},ym={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:"",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},Em={...cr,config:{...cr.config,imageCenterFileManagerView:!1}};bm({pro:ha,editor:ym,simple:hm()?cr:Em,blocks:gm});var va=F("CodeMode");function ba(){let e;try{const t=window.localStorage?.getItem(Mt.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 _m(e){try{window.localStorage?.setItem(Mt.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function ya(e){return e.getOrCreateInstance(va,()=>{const t=Ee(ba());return t.watch(_m),t})}function Ea(e){return e?.getInstance(va)?.get()??ba()}function dr(e,t){const n=ya(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function wm(e,t){const n=ya(e);n.set({...n.get(),direction:t})}function Sm(e,t,n=e.getInstance(oe)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Ea(e).isCodeMode&&dr(e,!1)}function Im(e){e.getInstance(Hl)||e.inject(Te,void 0)}function gn(e){return String(e.standaloneKey||"").trim()||void 0}function Cm(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function ti(e){return Cm(e)?!!gn(e):!1}function Lt(e){return!!gn(e)&&!ti(e)}var Tm=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function zi(e){return e==="server"?"serverSide":e}function Am({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=Ee();let o={kind:"pending"},s;const a=new Promise(y=>{s=y}),c=n===void 0?void 0:setTimeout(()=>{f({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function d(){o.kind!=="pending"&&i.set(An(r,e))}function f(y){if(o.kind!=="pending")return;clearTimeout(c),o=y;const b=An(r,e);i.set(b),s(b)}function m(y,b){r[zi(y)]=b,y==="server"&&o.kind==="pending"?f({kind:"applied"}):d()}return{watch:y=>i.watch(y),select:y=>i.select(y),get:()=>i.get(),ready:()=>a,state:()=>o,layers:()=>({...r}),bootstrap(){const y=An(r,e);return Object.fromEntries(Tm.map(b=>[b,y[b]]))},merge(y,b){m(b,{...r[zi(b)],...y})},replace(y,b){m(b,y)},setMode(y){r.user={...r.user,mode:y},d()},setAdvancedConfigs(y){r.advancedConfigs=y,d()},serverAbsent(y){f({kind:"absent",reason:y})},applyServerResponse(y){o.kind==="pending"&&m("server",{...r.serverSide,...y})},dispose(){clearTimeout(c)}}}var Rm=5e3;function Pm(){return{...ga("pro")?.config,mergeTags:void 0}}function Dm(e,t){e.getInstance(se)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function Om(e,t){let n;Wr(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 xm(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Mm(e,t){let n,r=!1,i;const o=a=>{i??=hn(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&Sm(e,a,t)},s=Wr(e).watch(({profile:a})=>{const c=a?.email_builder_config,d=xm(c);if(d===void 0||c===n)return;const f=n===void 0;n=c,!(f&&r)&&o(d)});e.getInstance(U)?.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 Wi="замкнутый контур: app_init не выполняется";function km(e,t){if(e.getInstance(Te)){t.serverAbsent(Wi);return}const n=e.getInstance(se)?.watch(r=>{Lt(r)&&t.serverAbsent(Wi)});n&&e.getInstance(U)?.addDisposable(n)}async function Lm(e,t){if(e.getInstance(Nr)===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 Nm(e){e.injectFactory(oe,(t,n)=>{if(n)return n;const r=Am({base:Pm(),env:{modeDefaults:i=>ga(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Rm});return Dm(e,r),Om(e,r),Mm(e,r),km(e,r),Lm(e,r),e.getInstance(U)?.addDisposable(r),r},!0)}var et=class extends ie{_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 B(e,t,n){const r=El(e);return(i,o,s)=>{const a=r(async c=>{const d=t?t(c):c;s&&i.bind(s);const f=await i(d);return n?n(f):f},o,s);return()=>a.dispose()}}var Fm=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Yn;this.handleDestroy=B(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new et(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{}}},ni=F("DestroyableService");function jm(e){e.injectFactory(ni,(t,n)=>{if(n)return n;const r=e.getInstance(U);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Fm({lifetime:r,options:e.getInstance(se),getInstance:()=>e.getInstance(mn),release:()=>Al(e.getInstance(Gl)??e)})},!0)}function Bm(e){const t=e.getInstance(ni);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var Um=1e3;function _a(e,t,n=Um,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(!_a(e[s],t[s],n,r+1))return!1;return!0}return!1}function Et(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];_a(i,o)||(n[r]=i)}return n}var Hm=({source:e,emailtags:t,group:n,tags:r,...i})=>i;async function $m(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function Gm({emails:e,saveTimeoutMs:t},n,r){const i=t?.()??Br();let o;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,c)=>{o=setTimeout(()=>{const d=new Ur(i);n.value.id,hd(d,$m(s,r)),c(d)},i)})])}catch(s){throw gs(s),s}finally{o!==void 0&&clearTimeout(o)}}function Vm(e){const{emails:t}=e,n=async(r,i)=>{const o=Hm(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...o}:o,c=s?Et(s,o):o,d=f=>{const m=String(f.id??r??Se()),y=f.id===void 0?{...f,id:m}:f;return t.cache.addOrUpdate(m,()=>y)};return await d(await Gm(e,{prev:s,patch:c,value:a,source:i.source??""},d))};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:Se()}},async updateEmail(r,i){return await n(r,i)}}}var Dn=20;function qm(e){const t=zm(e);return e.saveTimeoutMs?Wm(t,e.saveTimeoutMs):t}function zm({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(d=>String(d?.parent)===String(a)));return{async readRevisions(a,c=1){const d=await s(a,c);return{revisions:d.slice(Dn*(c-1),Dn*c),page:c,hasMore:d.length>Dn*c}},async readAutosave(a){const c=await r?.(a)??NaN,d=Number.isFinite(c)?c:void 0,f=await n?.(a);if(!f?.asked)return Id(await s(a,1),d);if(!f.revision)return Ai([],d);const m={...f.revision,parent:a,isAutosave:!0};return Ai([m],d,await s(a,1))},async saveAutosave(a,c){const d=await i?.(a),f=o?.();return await e.create({...Dd(c),...d!==void 0?{author:d}:{},...f!==void 0?{project:f}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Wm(e,t){return{...e,async saveAutosave(n,r){const i=t();let o;try{return await Promise.race([e.saveAutosave(n,r),new Promise((s,a)=>{o=setTimeout(()=>a(new fs(i)),i)})])}catch(s){throw gs(s),s}finally{o!==void 0&&clearTimeout(o)}}}}var Km=class extends kl{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}},Ym=class extends Me{};var Ki=class extends ie{_items=new Map;_onChangeEmitter=new oc;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 Ce(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 Xm(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(d=>{for(const f of c){const m=d[f],y=t[f];return f==="id"||typeof m!="string"?m===y:typeof y=="string"&&m.startsWith(y)}return!0}),a=e.length}return r&&(e=e.sort((c,d)=>(c[r]>d[r]?1:d[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 Jm(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 Qm(e,t){return Yi(e)&&Yi(t)?String(e)===String(t):e===t}function Yi(e){return typeof e=="string"||typeof e=="number"}var Zm=class extends ie{_cache=new Ki;_readEmitter=new Me;_saveEmitter=this.addDisposable(new Km);_removeEmitter=this.addDisposable(new Ym);_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)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ie);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Ki),i=n.addDisposable(new Me);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const c=Jm(await i.fire(o))||[];for(const d of c)d[e]=o,await this._cache.add(d.id,d);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const d=c[e];return d==null||Qm(d,o)});return Xm(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=Se()),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?Et(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 Nt(e){const t=F(e);return n=>n.getOrCreateInstance(t,()=>new Zm)}function wa(e){const t=e.getInstance(U);if(!t)throw new Error("Failed");return t}function Xi(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function On(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function eh(e,t,n){return e&&!Xi(t)&&Xi(e)?{...n,meta:e.meta}:n}var th=F("CurrentProject"),nh={};function Ft(e){return e?.getInstance(th)?.get()??nh}function ri(e){const t=Ft(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Sa=Nt("plugin.dataSource.emails"),Ia=Nt("plugin.dataSource.emailRevisions"),Ca=Qr("plugin.readEmailAutosave"),Ji=F("emailDocuments.provided");function rh(e){const t=Sa(e),n=Ia(e),r=n.byForeignKey("parent");if(e.getInstance(Ji))return{emails:t,emailRevisions:n};e.inject(Ji,!0);const i=()=>Br(e.getInstance(Ae)?.contentReadyTimeoutMs),o=Vm({emails:t,saveTimeoutMs:i}),s=new Map,a=(c,d)=>f=>{const m=f?.id??d;return(typeof m=="string"||typeof m=="number")&&s.set(String(m),c),f};return tu(e,{...o,createEmail:c=>o.createEmail(c).then(a(Date.now())),updateEmail:(c,d)=>o.updateEmail(c,d).then(a(Date.now(),c))}),ou(e,qm({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const d=await fe(e,Ca).fire(c);return d.length===0?{asked:!1}:{asked:!0,revision:d[0]??null}},savedAt:async c=>{const d=wd((await t.cache.getIfPresent(c))?.modified),f=s.get(String(c))??NaN;return Number.isFinite(f)&&!(d>=f)?f:d},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:i,integratorProject:()=>Ft(e).requested})),wa(e).addDisposable(t.onSave(({prev:c,patch:d,value:f})=>eh(c,d,f),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function Qi(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 ih(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var oh="po",Kt=null;function sh(){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([oh],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function ah(){return Kt===null&&(Kt=sh().catch(e=>{throw Kt=null,e})),Kt}async function Ta(e){if(typeof e=="object")return ii(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?lh(t):ch(t)}function ii(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function lh(e){try{return ii(JSON.parse(e))}catch{return}}var Zi=!1;async function ch(e){try{return ii((await ah()).parsePoCatalog(e))}catch{Zi||(Zi=!0);return}}var dh="em_locale",uh="em_ant_locale",fh="locale",ph="ant_locale";function oi(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Aa(e,t){const n=oi(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function mh(){return oi("em_locale")??Aa(fh,"em_locale")}function eo(e){try{localStorage.setItem(dh,JSON.stringify(e))}catch{}}function hh(){return oi("em_ant_locale")??Aa(ph,"em_ant_locale")}function gh(e,t){try{localStorage.setItem(uh,JSON.stringify({id:e,data:t}))}catch{}}var vh=8e3;function bh(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 yh(e){const t=mh(),n=hh();let r={ready:!1},i;const o=Ee(r);let s=0;const a=g=>{r={...r,...g},o.set(r)},c=()=>{r.ready||a({ready:!0})},d=setTimeout(c,e.unlockAfterMs??vh),f=g=>g!==s;let m;async function y(g,C){if(n?.id===g&&n.data&&a({antd:n.data}),!m)return;const _=await m(g).catch(()=>{});!_||f(C)||(a({antd:_}),gh(g,_))}async function b(g,C){const _=await e.askHost(g).catch(()=>null);if(f(C))return!0;if(_==null)return!1;const P=await Ta(_);return f(C)||(P&&a({catalog:P}),c()),!0}async function T(g,C){const _=await e.readList();if(f(C))return;if("error"in _){a({failure:{kind:"GET_LOCALES_ERROR",error:_.error}}),c();return}const P=_.data.find(M=>M.locale===g);if(!P){ih("em_locale")&&a({catalog:void 0}),c();return}if(Qi(t,P)&&(!i||i.catalog===t?.data)){c();return}if(i?.entry&&r.catalog===i.catalog&&Qi(i.entry,P)){eo(i.entry),c();return}const S=await e.readCatalog(g);if(!f(C)){if("error"in S){a({failure:{kind:"GET_LOCALE_ERROR",error:S.error}}),c();return}S.data&&(i?.id===g&&r.catalog===i.catalog&&bh(i.catalog,S.data)||a({catalog:S.data}),eo({id:g,time:P.updatedAt||Math.floor(Date.now()/1e3),hash:P.contentHash,data:S.data})),c()}}async function w(g,C){if(!await b(g,C)){if(!f(C)&&(i?.id===g&&r.catalog===i.catalog||g==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await T(g,C)}}return{set(g){if(!g||g===r.id)return;const C=s+=1;a({id:g,failure:void 0});const _=i?.id===g&&r.catalog===i.catalog;(i&&!_&&r.catalog===i.catalog||g==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===g&&t.data&&(a({catalog:t.data}),c()),y(g,C),w(g,C)},prime(g,C,_){r.id&&r.id!==g||r.catalog||!C||(i=t?.id===g&&t.data&&(!_||t.time>=_.time)?{id:g,catalog:t.data}:{id:g,catalog:C,entry:_?{id:g,time:_.time,hash:_.hash,data:C}:void 0},a({catalog:i.catalog}))},useAntdLoader(g){m=g,r.id&&y(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(d)}}var Eh=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})},_h=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 d=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},f=this.mergeRequestParams(c,d),m=i&&this.toQueryString(i),y=this.contentFormatters[r||"application/json"],b=o||f.format;return this.customFetch(`${s||this.baseUrl||""}${n}${m?`?${m}`:""}`,{...f,headers:{...f.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):f.signal)||null,body:typeof e>"u"||e===null?null:y(e)}).then(async T=>{const w=T;w.data=null,w.error=null;const g=b?T.clone():T,C=b?await g[b]().then(_=>(w.ok?w.data=_:w.error=_,w)).catch(_=>(w.error=_,w)):w;return a&&this.abortControllers.delete(a),C})}},wh=F("rest.v2.transport"),to=Symbol("rest.v2.secureRequest");function Sh(e){return e.getOrCreateInstance(wh,()=>{const t=e.getInstance(Pl)?.execute||fetch;return new _h({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[to]:!0}),customFetch:(n,r={})=>{const{[to]:i,...o}=r;return t(n,{...o,[Ol]:i!==!0})}})})}function Ih(e,t){const n=Sh(e);return Object.assign({},...t.map(r=>new r(n)))}function no(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Ra(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:no(n.details,"wp_code")??n.code,message:no(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 Pa(e){return!e.ok||!!e.error}function Ch(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Da(){return Ch(Mt.em_translations_v2)??!0}function Th(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Ah(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Rh(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:Th(r[1])}),t},[]):[]}function Ph(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Ah(n.updated_at),contentHash:n.content_hash}),t),[])}function Oa(e){return Ih(e,[Eh])}function cn(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function ur(e){return!e.ok||e.error!=null}function fr(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function xn(e){return{data:await Ta(e)??null}}async function Dh(e){if(Da())try{const n=await Oa(e).localesList();return Pa(n)?{error:Ra(n)}:{data:Ph(n.data)}}catch(n){return cn(n)}const t=qo(e,[es]);try{const n=await t.get_translations2({file:"react_app"});return ur(n)?fr(n):{data:Rh(n.data)}}catch(n){return cn(n)}}async function Oh(e,t){if(Da())try{const r=await Oa(e).jsonList({locale:t});return Pa(r)?{error:Ra(r)}:xn(r.data)}catch(r){return cn(r)}const n=qo(e,[es]);try{const r=await n.get_translations3({id:t,file:"react_app"});return ur(r)?fr(r):xn(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return ur(r)?fr(r):xn(r.data)}catch(r){return cn(r)}}}var Yt=new WeakMap;function xh(e){const t=Yt.get(e);if(t!==void 0)return t;const n=Dh(e).then(r=>("error"in r&&Yt.delete(e),r),r=>{throw Yt.delete(e),r});return Yt.set(e,n),n}var Tt=F("locale.service");function Mh(e){if(e.getInstance(Tt))return;const t=yh({readList:()=>xh(e),readCatalog:n=>Oh(e,n),askHost:async n=>(await fe(e,j.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(Te)});e.inject(Tt,t),e.getInstance(U)?.addDispose(()=>t.dispose())}function kh(e){const t=e.getInstance(oe);if(!t)return;const n=e.getInstance(Tt);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i||"ru_RU"));e.getInstance(U)?.addDisposable(r)}var Lh="user_id",Nh="project_id",ro=F("rest.identityHeadersProvided");function Fh(e){if(e.getInstance(ro))return;e.inject(ro,!0);let t;e.getInstance(se)?.watch(n=>{t=n}),e.addService(Ar,{execute(n,r){if(r?.public)return;const i=t?.user?.id??Ms(e).profile?.id;i!=null&&i!==""&&n.headers.set(Lh,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(Nh,String(o))}})}function jh(e){if(!e)return!1;try{return e.getInstance(Te)!==void 0}catch{return!1}}var Bh="Invalid standaloneKey.",PE=F("StandaloneMockGuard");function Uh(){const e=new Error(Bh);return e.name="InvalidStandaloneKeyError",e}function Hh(e){e.addService(Ar,{execute:()=>{if(jh(e))throw Uh()}})}function $h(e){Ml(e),Hh(e)}function Gh(e){const t=new Qs;e.inject(Ae,t);const n=e.getInstance(se)?.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(U);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var Vh=Nt("plugin.dataSource.blocks"),qh=Nt("plugin.dataSource.blockRevisions"),zh=Nt("plugin.dataSource.comments"),Wh=Qr(),Kh=Qr(),xa=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
1004
|
+
`));return{html:xf(t.html),hasBrowserExtensionArtifacts:t.found}}function sn(e){return e?.getContent()??""}function Js(e,t){e?.mutate({content:bs(t)},{source:"remote"})}function Qr(e){return F(e)}function pe(e,t){return e.getOrCreateInstance(t,()=>new Me)}function ee(e,t){return e.getOrCreateInstance(t,()=>new Me).event}function an(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var Mf=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}},kf=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(de("Superseded by newer show()")),n.aborted?Promise.reject(de(n.reason)):(this._activeRequest=e,new Promise((r,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new Mf(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(de(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 Lf(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Nf(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=ls(e),n=cs(e),r=Vc(e.sandbox);t<n+r}var Qs=class{_controller=new AbortController;_externalSignalDisposable=new ie;_sessionChangeListeners=new Set;_showRegistry=new kf;_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 ls(this._timeouts)}getSandboxTimeoutMs(e){return as(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return cs(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=Lf(this._timeouts,e.timeouts),Nf(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 ie,this._linkExternalSignal(e)}abort(e){const t=e??de("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ie}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ie,this._showRegistry.rejectAll(de("Init session replaced")),this._controller.signal.aborted||this._controller.abort(de("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??de()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??de()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Zr=(()=>{const e=new Qs;return e.configure({}),e})(),Ff=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 jf(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 Bf(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(Y(n),new Promise((r,i)=>{let o=!1,s,a;const c=f=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",d),f())},d=()=>{c(()=>i(de(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 Ff(t)))},t)),n?.addEventListener("abort",d)}))}var Uf=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 Hf(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 Uf(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>i(c))})})}var $f=2,ft=Symbol("sandbox:frame-replaced");function Ni(e){return e===ft}function Se(e,t,n,r,i,o,s){const a=`sandbox:${t}`,c=o?.getSandboxTimeoutMs(t)??jr[t],d=()=>{let T=Hf(e.sendAsync(n,r),c,a);return T=rn(T,o?.signal),bt(a,T,i)};if(t==="INIT_START"&&jf(e)){const T=o?.getSandboxReadyTimeoutMs()??2e4,w=e,g=C=>{const _=Bf(w,T,o?.signal);return bt("sandbox:INIT_START:ready-wait",_,i).then(()=>{if(!s||C<=0)return d();const P=s.getGeneration();let S;const M=new Promise((E,A)=>{S=s.onChange(()=>{s.getGeneration()!==P&&A(ft)})}),v=d();return v.catch(()=>{}),Promise.race([v,M]).finally(()=>S?.()).catch(E=>{if(E!==ft)throw E;return{...i},g(C-1)})})};return g($f)}if(!s)return d();const f=s.getGeneration();let m;const y=new Promise((T,w)=>{m=s.onChange(()=>{s.getGeneration()!==f&&w(ft)})}),b=d();return b.catch(()=>{}),Promise.race([b,y]).finally(()=>m?.()).catch(T=>{throw T===ft&&{...i},T})}var Gf=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Vf=200;function Zs(e=new Set){const t=new Set;return(n,r)=>{if(!Gf.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>=Vf&&t.clear(),t.add(i))}}function ea(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Zs()}}var qf=ea();function ze(e){return e?.getInstance(Cr)??qf}function zf(e){const t=Le(e),n=ae(e),r=()=>e.getInstance(Re)??Zr;let i,o,s=!1,a=!1;const c=async(_,P,S)=>{const M=S.generation,v=()=>S.generation!==M||S.signal.aborted||t.current()!==_||a,E=ye(n);s=!0;try{if(await Se(n,"INIT_START",H.SANDBOX_INIT_START,{guid:P},void 0,S),v())return;const{html:A,hasBrowserExtensionArtifacts:h}=Xs(sn(_));if(h&&pe(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Js(_,A),await Se(n,"SET_ENTITY",H.SANDBOX_SET_ENTITY,an(sn(_),P,ze(e).editorPolicy,_.get().version),void 0,S),v())return;await Se(n,"INITED",H.SANDBOX_INITED,{guid:P},void 0,S),i=P,o=E}finally{s=!1}},d=()=>Ee(t.sessionKey())?t.current():void 0,f=()=>{if(a||s)return;const _=d(),P=_?.get().docId;if(!_||!P||i===P&&o===ye(n)||!_.isReady())return;const S=r();S.signal.aborted||c(_,P,S).catch(()=>{})};let m=!1;const y=()=>{m||a||(m=!0,queueMicrotask(()=>{m=!1,f()}))};let b,T;const w=()=>{const _=d(),P=_?.get().docId;P!==T&&(b?.(),T=P,b=_?.subscribe(y)),y()},g=t.subscribe(w),C=er(n,y);w(),e.getInstance(U)?.addDispose(()=>{a=!0,C(),b?.(),g()})}var Wf=200;function Kf({startVersion:e,limit:t=Wf}){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(d=>d.version>s);i(s);let c=o;for(const d of a){if(d.contentReplaced||!d.changes)return null;const f=d.changes,m=[];for(const y of c){if(d.fromCanvas&&f.some(T=>y.range.start<=T.oldEnd&&y.range.end>=T.oldPosition))return null;const b=td(y.range,f,"after");if(!b)return null;m.push({range:b,text:y.text})}c=m}return c}}}function Yf(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new ve(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function Xf(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Yf(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Jf(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var ei=F("canvas.sandboxFill");function ta(e){return e.getInstance(ei)?.pipeline.isEventsLocked()===!0}function qt(e){St(e,{origin:"canvas-channel"})}function Qf(e){const t=Le(e),n=ae(e);let r;const i=(c,d)=>{const f=c.get().docId;let m=!1,y=null,b=null;const T=Kf({startVersion:c.get().version});let w=c.getContent(),g=!0;const C=(E,A)=>{!g||t.current()!==c||(St(A,{origin:"canvas-channel"}),n.sendAsync(H.SANDBOX_SET_ENTITY,an(sn(c),f,ze(e).editorPolicy,c.get().version)).catch(qt))},_=async(E,A)=>{if(b){b.push({edits:E,rev:A});return}b=[{edits:E,rev:A}];try{do{const h=b.splice(0,b.length);await n.sendAsync(H.SANDBOX_UPDATE_ENTITY,{edits:h.map(l=>l.edits),guid:f,rev:h[h.length-1].rev})}while(b.length)}catch(h){C("app edits failed to reach the canvas",h)}finally{b=null}},P=(E,A)=>{const h=b?.splice(0,b.length)??[];h.length&&n.sendAsync(H.SANDBOX_UPDATE_ENTITY,{edits:h.map(l=>l.edits),guid:f,rev:h[h.length-1].rev}).catch(qt),n.sendAsync(H.SANDBOX_UPDATE_ENTITY,{edits:[E],guid:f,rev:c.get().version,...A!==null?{changeId:A}:{}}).catch(qt)},S=E=>{const{guid:A,pushUndoStop:h}=E;if(A!==f)return;const l=fd(E);let{edits:u}=E;if(l.baseRev!==null){const R=T.rebase(u,l.baseRev);if(!R){St(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),P([],l.changeId);return}u=R}const p=c.get().version;try{m=!0,y=l.changeId;const R=Xf(u,c.getContent());h===!1?d.applyWithoutHistory(R):c.mutate({changes:R},{source:ta(e)?"system":"user"})}catch(R){C("canvas batch failed to apply",R);return}finally{m=!1,y=null}c.get().version===p&&l.baseRev!==null&&P([],l.changeId)},M=c.subscribe(({changes:E,version:A})=>{const h=c.getContent(),l=!E?.length&&h!==w;if(w=h,T.record({version:A,changes:E,contentReplaced:l,fromCanvas:m}),!E?.length)return;const u=Jf(E);m?P(u,y):_(u,A).catch(qt)}),v=n.addListener(H.APPLICATION_UPDATE_ENTITY,S);return()=>{g=!1,M(),v.dispose()}};let o;const s=()=>{const c=t.current(),d=t.history(),f=c?.get().docId;f!==o&&(r?.(),r=void 0,o=f,c&&d&&(r=i(c,d)))},a=t.subscribe(s);s(),e.getInstance(U)?.addDispose(()=>{r?.(),a()})}function qe(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 Ue(e){return!e||e==="none"}function Zf(e){const t=e.contain??"",n=e.willChange??"";return!Ue(e.transform)||!Ue(e.perspective)||!Ue(e.filter)||!Ue(e.backdropFilter)||!Ue(e.translate)||!Ue(e.rotate)||!Ue(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Fi(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 ep(e){const t=[],n=document.documentElement,r=Fi(getComputedStyle(n)),i=r.x||r.y;let o="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(o=s);for(let a=qe(e);a&&a!==n;a=qe(a)){const c=getComputedStyle(a),d=o==="none"||Zf(c)||o==="absolute"&&!!c.position&&c.position!=="static",f=a===document.body&&!i;if(d){o="none";const m=f?{x:!1,y:!1}:Fi(c);(m.x||m.y)&&t.push({node:a,...m})}(c.position==="absolute"||c.position==="fixed")&&(o==="none"||c.position==="fixed")&&(o=c.position==="fixed"?"fixed":"absolute")}return t}function na(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 zt(e){return Number.parseFloat(e)||0}function nr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=na(e),i=zt(n.borderLeftWidth),o=zt(n.borderTopWidth),s=zt(n.borderRightWidth),a=zt(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-i-s):0,d=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+d)*r.y}}function tp(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(nr(o.node),o.x,o.y)),n&&i(nr(n),!0,!0),r}var rr={originX:0,originY:0,scaleX:1,scaleY:1};function ln(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 ra(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 ia(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 np=1e3;function rp(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()+np,a()},d=[window],f=[document.documentElement];for(let g=t;g;g=qe(g)){const C=g.getRootNode();C instanceof ShadowRoot&&!d.includes(C)&&(d.push(C),f.push(C))}const m=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];d.forEach(g=>m.forEach(([C,_])=>g.addEventListener(C,_,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const y=typeof MutationObserver=="function"?new MutationObserver(g=>{g.some(C=>!n.contains(C.target))&&a()}):void 0;f.forEach(g=>y?.observe(g,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let b;try{if(typeof ResizeObserver=="function"){const g=new ResizeObserver(a);typeof g.observe=="function"&&(b=g)}}catch{b=void 0}let T=[];return{schedule:a,observe:g=>{!b||g.length===T.length&&g.every((C,_)=>C===T[_])||(b.disconnect(),T=g,g.forEach(C=>b?.observe(C)))},dispose(){o=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),d.forEach(g=>m.forEach(([C,_])=>g.removeEventListener(C,_,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),y?.disconnect(),b?.disconnect()}}}var ip="pluginZoom",op=/^(?:ant|vscode|monaco|docs)-/;function sp(e){return op.test(e)}function ap(){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 lp=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function cp(){return lp}var dp=new Set;function up(e,t,n=dp){return e.startsWith(`${t}-`)?!1:!sp(e)&&!n.has(e)}function fp(e,t){return`--${t}-${e}`}function oa(e){const t=ap();return up(e,t,cp())?fp(e,t):`--${e}`}function pp(e,t){const n=oa(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function sa(e,t){return pp(e,t)}var aa=300,ji=15e3,mp=5e3,Bi="em-canvas-busy-style";function hp(){if(document.getElementById(Bi))return;const e=document.createElement("style");e.id=Bi,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var gp="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 vp(e){const t=sa("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(oa("colorPrimary")).trim()||t}function la(e){hp();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",gp),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:${vp(e)};animation:em-canvas-busy-spin 1s linear infinite`),i.appendChild(n),i}function bp(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 yp(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&&!ia({left:o.left,top:o.top,width:o.width,height:o.height},i)){const s=ln(i,ra(o,ln(i,rr),rr));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=bp(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(la(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Rn(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(la(e))},aa);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var Ep=8e3;function _p(){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:()=>{},dispose:()=>{}}}function wp(e,t){for(let n=qe(e);n;n=qe(n)){const r=getComputedStyle(n),i=r.overflowX!=="visible"||r.overflowY!=="visible",o=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>Ye(s)>0);if(i&&o)return n;if(n===t)return null}return null}function Ye(e){return Number.parseFloat(e)||0}function Wt(e,t){return Math.abs(e-t)<=1}function Sp(e){const t=getComputedStyle(e),n=Ye(t.borderTopWidth),r=Ye(t.borderRightWidth),i=Ye(t.borderBottomWidth),o=Ye(t.borderLeftWidth),s=(a,c,d)=>Math.max(0,Ye(a)-Math.max(c,d));return{...nr(e),radii:[s(t.borderTopLeftRadius,n,o),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,i,r),s(t.borderBottomLeftRadius,i,o)]}}function Ip(e,t){const n=Wt(t.top,e.top),r=Wt(t.bottom,e.bottom),i=Wt(t.left,e.left),o=Wt(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 Cp(e,t,n,r,i,o){const s=n.readyTimeoutMs??Ep,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",sa(ip,"1"));const c=n.resolveSrc(e),d=document.createElement("iframe");d.setAttribute("sandbox",n.resolveSandbox(c)),d.setAttribute("allow","clipboard-read; clipboard-write"),d.setAttribute("title","Email content"),d.style.width="100%",d.style.border="0",d.style.display="block",d.style.minHeight="600px",d.src=c,a.appendChild(d),t.appendChild(a),n.mark?.("created"),i||n.onCreated?.(d);const f=new ie;let m=!1,y,b=!1,T,w,g,C;const _=()=>{clearTimeout(C),C=setTimeout(()=>{b||(b=!0,w?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},P=()=>m?(g=Promise.resolve(),b=!0,g):(b=!1,g=new Promise((k,$)=>{T=k,w=$}),_(),g),S=()=>{if(clearTimeout(C),m=!0,b){g=Promise.resolve();return}b=!0,n.mark?.("loaded"),T?.()};d.addEventListener("load",S),f.addDispose(()=>{clearTimeout(C),d.removeEventListener("load",S)});let M;const v=()=>{M??=n.bindResizer?.(d)},E=()=>{M?.dispose(),M=void 0};let A=null,h=null,l,u=rr,p="",R="",D=0;const N=k=>{const $=JSON.stringify(k);return $===p?!1:(p=$,a.style.visibility=k.visibility,a.style.left=`${k.css.left}px`,a.style.top=`${k.css.top}px`,a.style.width=`${k.css.width}px`,a.style.height=`${k.css.height}px`,a.style.borderRadius=k.radius,d.style.width=k.elementWidth>0?`${k.elementWidth}px`:"100%",d.style.transform=k.shiftX!==0?`translate(${k.shiftX}px, ${k.shiftY}px)`:`translateY(${k.shiftY}px)`,!0)},I=()=>{if(!A)return p="",a.style.visibility="hidden",d.removeAttribute("id"),!1;n.elementId&&(d.id=n.elementId);const k=A.getBoundingClientRect(),$=ep(A),W=h?.isConnected?h:null;l?.observe([A,d,...$.map(q=>q.node),...W?[W]:[]]);const z=tp(k,$,W),Z=Math.max(0,z.right-z.left),ge=Math.max(0,z.bottom-z.top),st=getComputedStyle(A).visibility==="visible",Fe=Z<=0||ge<=0,Pe=Fe?{left:z.left,top:z.top,right:z.left,bottom:z.top}:z,Ut=Fe?null:wp(A,W??$[0]?.node??null),x=Ut?Ip(Sp(Ut),Pe):"",V=q=>N({visibility:st?"":"hidden",css:ln(Pe,q),elementWidth:k.width/q.scaleX,shiftX:(k.left-Pe.left)/q.scaleX,shiftY:(k.top-Pe.top)/q.scaleY,radius:x});let G=V(u);if(!Fe){const q=a.getBoundingClientRect();q.width>0&&!ia({left:q.left,top:q.top,width:q.width,height:q.height},Pe)&&(u=ra(q,ln(Pe,u),u),G=V(u)||G)}return G},O=()=>{if(!A)return!1;let k=I();const $=d.getBoundingClientRect().height;$>0&&$!==D&&(D=$,A.style.height=`${$/na(A).y}px`,k=!0);const W=getComputedStyle(A).pointerEvents;return W!==R&&(R=W,a.style.pointerEvents=W),k},L=()=>{l?.dispose(),l=void 0},Q=k=>{l=rp({slot:k,own:a,measure:O,onDetached:L})};let ce=[];const te=(k,$)=>{if(h=$,k&&ce.length>0){const W=ce;ce=[],W.forEach(z=>z())}if(k===A){k&&!l&&Q(k),O();return}if(L(),A&&A.style.removeProperty("height"),p="",D=0,R="",A=k,!k){I(),E();return}n.onShown?.(d),Q(k),O(),v()};f.addDispose(L);const ne=k=>{m=!1,y=void 0,o?.(),k&&n.onReload?.(d);let $;b||g===void 0?$=P():(_(),$=g);try{d.contentWindow?.location.reload()}catch{d.src=c}return $};return{element:d,ready(){return g??P()},reload:()=>ne(!0),reloadQuietly:()=>ne(!1),followReload:()=>{y=void 0,o?.(),n.onReload?.(d)},moveTo(k){if(a.parentNode===k)return g??P();m=!1,y=void 0,o?.();let $;return b||g===void 0?$=P():(_(),$=g),k.appendChild(a),n.onReload?.(d),p="",l?.schedule(),$},get shown(){return A!==null},get slot(){return A},whenShown(){return A!==null?Promise.resolve():new Promise(k=>{ce.push(k)})},get filled(){return y},noteFilled(k){y=k},alignTo(k,$){te(k,$??null)},scrollBy(k,$){let W=k,z=$;for(let Z=A?qe(A):null;Z;Z=qe(Z)){if(Math.abs(W)<1&&Math.abs(z)<1)return;const ge=getComputedStyle(Z);if((ge.overflowY==="auto"||ge.overflowY==="scroll")&&Z.scrollHeight>Z.clientHeight){const st=Z.scrollTop,Fe=Z.scrollLeft;Z.scrollBy({left:W,top:z,behavior:"instant"}),W-=Z.scrollLeft-Fe,z-=Z.scrollTop-st}}(Math.abs(W)>=1||Math.abs(z)>=1)&&window.scrollBy({left:W,top:z,behavior:"instant"})},resize(){M?.resize()},dispose(){te(null,null),E(),f.dispose(),a.remove()}}}function Tp(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(u,p)=>u==="email"?`email:${p??n}`:u,o=new Map;let s,a=[],c=!1,d,f,m=!1,y,b,T="shown",w=0,g,C,_;const P=u=>f!==void 0&&u.filled!==void 0&&u.filled!==f,S=()=>{g=void 0;const u=y;!m||!u||f===void 0||C===f||!P(u)||(C=f,e.onForeignDocument?.({wanted:f,filled:u.filled,role:T,heldMs:Date.now()-w}))},M=()=>{m=!1,y=void 0,b=void 0,clearTimeout(g),g=void 0},v=(u,p)=>{const R=o.get("email"),D=R?.slot??null;return u&&D&&P(u)?(u.alignTo(null),m||(m=!0,w=Date.now(),g=setTimeout(S,mp)),T=p,y=u,!(s!==void 0||c)&&b!==u&&(b=u,e.onShown?.(u.element)),!d&&!s&&(d=Rn(D)),!1):(m&&(M(),d?.remove(),d=void 0),u?.alignTo(D,R?.clip??null),!0)},E=()=>{m&&!c&&v(t.get(i("email")),"shown")},A=()=>{a.forEach(u=>clearTimeout(u)),a=[],s?.remove(),s=void 0,d?.remove(),d=void 0,(c||m)&&(c=!1,v(t.get(i("email")),"shown"))},h=(u,p,R)=>{const D=i(u,p),N=t.get(D);if(N)return N;const I=e.resolveMount();if(!I)return _p();const O=Cp(u,I,e,u==="email"?p??n:void 0,R,u==="email"?()=>E():void 0);return t.set(D,O),O},l={get:u=>h(u),current:u=>h(u),peek:u=>t.get(i(u)),spare:()=>t.get(i("email",r())),ensureSpare:()=>h("email",r(),!0),promote(){const u=t.get(i("email",r()));if(!u)return;const p=t.get(i("email"));n=r(),_=void 0,v(u,"spare"),p?.alignTo(null)},alignSurface(u,p,R){const D=o.get(u);if(o.set(u,{slot:p,clip:R??null}),u==="email"&&c){d?.remove(),d=p?Rn(p):void 0;return}const N=p?h(u):t.get(i(u));if(u!=="email"){N?.alignTo(p,R??null);return}if(!p){_=D?.slot&&N?.shown?{slot:D.slot,handle:N}:void 0,m&&(M(),d?.remove(),d=void 0),N?.alignTo(null);return}const I=_?.slot===p&&_.handle===N;if(_=void 0,D?.slot===p&&N?.shown||I){N?.alignTo(p,R??null);return}v(N,"shown")},want(u){f=u,u!==void 0&&E()},noteFilled(u,p){const R=l.byWindow(u);R&&(R.noteFilled(p),R===t.get(i("email"))&&E())},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const p of t.values())if(p.element.contentWindow===u)return p}},busy(u){if(A(),!u)return;if(!l.visible()){c=!0,d?.remove(),d=void 0;const D=o.get("email");D?.slot&&(d=Rn(D.slot)),a=[setTimeout(A,ji)];return}const p=e.resolveMount();if(!p)return;const R=yp(p,()=>l.visible()?.element.parentElement?.getBoundingClientRect()??null);s=R,a=[setTimeout(()=>R.showSpinner(),aa),setTimeout(A,ji)]},remount(u){A();const p=i("email");t.forEach((R,D)=>{if(D===p){R.moveTo(u).catch(()=>{});return}R.dispose(),t.delete(D)})},dispose(){f=void 0,c=!1,M(),_=void 0,A(),t.forEach(u=>u.dispose()),t.clear(),o.clear(),n="a",f=void 0,C=void 0}};return l}var Ap=F("canvas.resizerBinder"),ir=F("canvas.service"),Rp={created:le.canvasCreated,loaded:le.canvasLoaded},ca=new WeakMap;function or(e){return ca.get(e)??0}function Pp(e,t){if(e.getInstance(ir))return;const n=Tp({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:lf,elementId:t.elementId,bindResizer:i=>e.getInstance(Ap)?.(i),onCreated:i=>Qt(e,i,"fresh"),onReload:i=>{ca.set(i,or(i)+1),Qt(e,i,"fresh")},onShown:i=>Qt(e,i,"switch"),mark:i=>t.mark?.(Rp[i]),onForeignDocument:i=>{({...i},Yc("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=ae(e).addListener(H.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(ir,n),e.getInstance(U)?.addDispose(()=>{r.dispose(),n.dispose()})}function Qt(e,t,n){const r=ae(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),$u(r))}function Dp(e,t){Qt(e,t,"promote")}function Op(e,t){const n=t.contentWindow;n&&ae(e).greet(n)}function da(e,t){const n=t.contentWindow;n&&ae(e).forget(n)}function xp(e,t){const n=re(e)?.byWindow(t)?.element;if(!n)return;const r=or(n);return()=>or(n)!==r}function re(e){return e.getInstance(ir)}function Mp(e){const t=ae(e),n=()=>re(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(H.RELOAD,()=>{n()?.followReload()}),i=t.addOffTargetListener(H.RELOAD,a=>{const c=re(e)?.byWindow(a);c&&da(e,c.element)}),o=t.addListener(a=>{a.data?.operation===H.SANDBOX_RESIZED&&n()?.resize()}),s=ee(e,j.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(U)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose(),s.dispose()})}function Ui(){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 kp(e){const t=e.getInstance(se);let n,r;e.getInstance(U)?.addDispose(()=>{r?.remove(),r=void 0}),Pp(e,{resolveMount:()=>n,resolveSrc:o=>zs(o==="block"),elementId:"email_iframe",mark:o=>J(o)}),t?.watch(o=>{const s=o?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,re(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(o!==void 0){n=r??=Ui(),re(e)?.alignSurface("email",r,r);return}else return;re(e)?.get("email")}});let i;e.getInstance(U)?.addDispose(()=>{i?.remove(),i=void 0}),_u(e).watch(o=>{const s=re(e);if(s){if(o){i??=Ui(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var ua=F("canvas.headerFlow"),Hi=["subject","preheader"],Lp=3e3,Np={subject:H.SANDBOX_SUBJECT_UPDATE,preheader:H.SANDBOX_PREHEADER_UPDATE};function Fp(e){const t=Le(e),n=ae(e),r=g=>g?"remote":ta(e)?"system":"user",i=(g,{guid:C,value:_,forced:P})=>{const S=dt(t);if(!S||typeof _!="string"||C&&C!==S.get().docId)return;const M=t.forcedHeaders();if(M?.[g]&&!P&&_!==M[g])return;P&&(m.delete(g),m.size===0&&t.endForcedHeaders());const v=S.get().attributes[g]??"";a=!0;try{Ct(S,{[g]:_},{source:r(P)})}finally{a=!1}o[g]=_,pe(e,j.ON_HEADER_APPLIED_ID).fire({field:g,value:_,forced:!!P,isGenerated:_!==v&&!!_})};let o={},s,a=!1,c=Promise.resolve();const d=(g,C,_,P=!1)=>{c=n.sendAsync(Np[g],{value:C,guid:dt(t)?.get().docId,..._?{force:!0,echo:!0}:{},...P?{undoStep:!0}:{}}).catch(S=>{})};let f;const m=new Set;e.inject(ua,{whenDelivered:async()=>{await c},reassert:g=>{const C=dt(t),_=Hi.filter(P=>g[P]);if(!(!C||_.length===0)){a=!0;try{Ct(C,Object.fromEntries(_.map(P=>[P,g[P]])),{source:"system"})}finally{a=!1}t.beginForcedHeaders({subject:g.subject??"",preheader:g.preheader??""}),clearTimeout(f),f=setTimeout(()=>{m.clear(),t.endForcedHeaders()},Lp),m.clear();for(const P of _)m.add(P);for(const P of _)o[P]=g[P],d(P,g[P],!0)}}});const y=()=>{s?.(),s=void 0;const g=dt(t);if(!g){o={};return}const C=g.get().attributes;o={subject:C.subject,preheader:C.preheader},s=g.subscribe(({source:_})=>{if(a)return;const P=g.get().attributes,S=t.forcedHeaders();for(const M of Hi){const v=P[M];v!==o[M]&&(o[M]=v,d(M,v??"",_==="system"&&S?.[M]!==void 0,_==="user"))}})};y();const b=t.subscribe(y),T=n.addListenerAsync(H.APPLICATION_SUBJECT_UPDATE,g=>i("subject",g)),w=n.addListenerAsync(H.APPLICATION_PREHEADER_UPDATE,g=>i("preheader",g));e.getInstance(U)?.addDispose(()=>{T.dispose(),w.dispose(),b(),s?.(),clearTimeout(f)})}function $i(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function sr(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];$i(i)&&$i(o)?n[r]=sr(o,i):i!==void 0&&(n[r]=i)}return n}function jp(e,t){const n=Pr;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 sr(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?sr(n,t):n}function Bp(){const e=window.localStorage.getItem(Mt.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?rc:Hl;return e&&e!=="system"?e:t}function Up(){const e=window.localStorage.getItem(Mt.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function Hp(e){const{config:t}=e;return{operation:H.UPDATE_PREVIEW,theme:e.theme,commonStyles:jp(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}var $p=F("DefaultCommonStyles");function fa(e){return e.getOrCreateInstance($p,()=>_e(void 0))}function Gp(e,t){fa(e).set(t)}function Vp(e){const t=ae(e),n=e.getInstance(oe),r=e.getInstance(se),i=Le(e);let o,s="";const a=()=>{const _=n?.get()??{},P=Hp({config:_,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:Bp(),codeMode:Up(),appName:"emailmaker"}),S=JSON.stringify(P);S!==s&&(s=S,t.send(P))},c=t.onInit(()=>{s="",a()}),d=()=>{t.isInited()&&a()},f=n?.watch(d),m=fa(e).watch(_=>{o=_,d()}),y=r?.watch(_=>{_&&"commonStyles"in _&&(o=_.commonStyles),d()});let b;const T=()=>{b?.(),b=i.current()?.subscribe(d),d()};T();const w=i.subscribe(T),g=matchMedia(ql),C=()=>d();g.addEventListener("change",C),e.getInstance(U)?.addDispose(()=>{c.dispose(),f?.dispose(),m.dispose(),y?.dispose(),b?.(),w(),g.removeEventListener("change",C)})}var ar;(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=[],d=[];for(const f of i){const m=o.find(y=>s(f,y));m?d.push({prev:f,next:m}):c.push(f)}for(const f of o)i.find(m=>s(f,m))||a.push(f);return{added:a,removed:c,exists:d}}e.diff=r})(ar||(ar={}));function qp(e,t){return e.type===t.type&&e.key===t.key}function zp(e){const t=ae(e),n=()=>e.getServices(Xe)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send(H.SANDBOX_ADD_EXTENSIONS,r)}),o=Al(Xe),s=e.onInject(a=>{if(a!==o)return;const c=n();if(!t.isInited()){r=c;return}const{added:d,removed:f}=ar.diff(r,c,qp);if(r=c,f.length){if(f.some(m=>m.type==="script")){t.send(H.RELOAD);return}t.send(H.SANDBOX_REMOVE_EXTENSIONS,f.map(m=>m.key))}d.length&&t.send(H.SANDBOX_ADD_EXTENSIONS,d)});e.getInstance(U)?.addDispose(()=>{i.dispose(),s?.dispose()})}var Wp=new Set([...Object.values(H).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(Rr)]);function Kp(e){return e.length>0&&!e.startsWith("em:")&&!Wp.has(e)}function Yp(e){const t=ae(e),n=new Map;let r=!1,i=-1,o=new Set;const s=d=>(d!==i&&(i=d,o=new Set),o),a=t.observeOutgoing((d,f)=>{if(!r||!Kp(d))return;const m=ye(t);n.set(d,{data:f,generation:m,scripts:new Set(s(m))})}),c=t.addListener(Rr,d=>{if(d.phase!=="ready"||d.status!=="success")return;r=!0;const f=ye(t),m=s(f);m.add(d.key);for(const[y,b]of n)b.generation===f||![...b.scripts].every(T=>m.has(T))||(b.generation=f,t.send(Wo(y),b.data))});e.getInstance(U)?.addDispose(()=>{a.dispose(),c.dispose()})}var Xp=F("prewarm.editorVisible");function Jp(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Qp(e={}){const t=e.paint??Jp;let n=!1,r=!1,i=!1,o=!1,s=!1;const a=[],c=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,J(le.editorVisible);for(const d of a.splice(0))d()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){i=!0,c()},whenVisible(d){if(s){d();return}a.push(d)},contentShown:()=>i}}function Zp(e){return e.getOrCreateInstance(Xp,()=>Qp())}var em=500,tm=500,nm=5e3;function rm(e){const t=e.quietMs??em,n=e.floorMs??tm,r=e.ceilingMs??nm;let i,o,s=0;const a=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},c=()=>{a(),e.run()},d=()=>{clearTimeout(i);const f=n-(Date.now()-s);i=setTimeout(c,Math.max(t,f))};return{start(){a(),s=Date.now(),o=setTimeout(c,r),d()},notify(){i!==void 0&&d()},cancel:a}}function im({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}var pa="self-init:";function om(e){return e.startsWith(pa)}function ma(e,t){const n=e.getActiveShowRequest();return om(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function sm(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),i=()=>e.frameWatch?.();let o="",s;const a=T=>{s={target:e.readTarget?.(),docId:T}},c=()=>e.readDocument()?sn(e.readDocument()):o,d=()=>ze(e.container).editorPolicy,f=()=>e.readEmail(),m=()=>{const T=f();return{...T,id:e.isTemplate()||T.isNew?void 0:T.id,html:c()}};let y=!1;const b={readContent:c,publicEmail:m,sendInitStart:()=>Se(n,"INIT_START",H.SANDBOX_INIT_START,{guid:f().renderGuid},void 0,r()),sendInited:()=>Se(n,"INITED",H.SANDBOX_INITED,{guid:f().renderGuid},void 0,r(),i()),async sendContent(){const T=f(),{html:w,hasBrowserExtensionArtifacts:g}=Xs(T?.html||"");g&&e.events.browserExtensionDetected(),Js(e.readDocument(),w),o=w,a(T.renderGuid),await Se(n,"SET_ENTITY",H.SANDBOX_SET_ENTITY,an(c(),T.renderGuid,d(),e.readDocument()?.get().version),{guid:T.renderGuid,emailId:T.id??null},r(),i())},refreshContent:()=>(a(f().renderGuid),Se(n,"SET_ENTITY",H.SANDBOX_SET_ENTITY,an(c(),f().renderGuid,d(),e.readDocument()?.get().version),void 0,r(),i())),sendPreheader:async()=>{const T=f();if(T.preheader!==void 0)return Se(n,"PREHEADER",H.SANDBOX_PREHEADER_UPDATE,{value:T.preheader,guid:T.renderGuid,force:!0},void 0,r(),i())},sendSubject:async()=>{const T=f();if(T.subject!==void 0)return Se(n,"SUBJECT",H.SANDBOX_SUBJECT_UPDATE,{value:T.subject,guid:T.renderGuid,force:!0},void 0,r(),i())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:T=>e.showFilled?.(T),noteFilled:(T,w)=>e.noteFilled?.(T,w),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(m()),fireInit(T,w){if(!ma(t(),T)){t().getActiveShowRequest()?.showId;return}const g=f();g.id,g.renderGuid,t().completeShow(T);const C=e.readDocument();Ct(C,{is_inited:!0},{source:"system"});const _=()=>{const S=m();w&&(S.reset=!0);const M=e.events.inited(S);return w||(y&&b.fireEmailChanged(),y=!0),M};if(!C||C.isReady())return _();const{docId:P}=C.get();return C.whenReady().then(()=>e.readDocument()?.get().docId===P?_():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(m())},fireContentChanged(){e.events.contentChanged(c())}};return b}var am=2;function Gi(){return new Error("[sandbox] document reloaded during fill")}function lm(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Pn(e){try{e()}catch{}}function cm(e){let t;return Pn(()=>{t=e()}),{stage:n=>Pn(()=>t?.stage(n)),end:(n,r)=>Pn(()=>t?.end(n,r))}}function dm(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,a,c;const d=()=>{const v=e.readTarget?.(),E=e.readSandboxGeneration?.();return v===void 0||E===void 0?void 0:{target:v,generation:E}},f=()=>{const v=d();return v&&{...v,canvasReplaced:e.trackDocument?.(v.target)}},m=v=>{if(v?.canvasReplaced?.())return!0;const E=d();return v!==void 0&&E?.target===v.target&&E.generation!==v.generation},b=sm({...e,waitScope:()=>({getSandboxTimeoutMs:v=>t().getSandboxTimeoutMs(v),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const v=c;if(!(!v||!e.onSandboxGenerationChange))return{getGeneration:()=>d()?.generation??v.generation,onChange:E=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===v.target||v.canvasReplaced?.())&&E()})??(()=>{})}}});let T;const w=(v,E)=>{if(T===v)return;T=v;const A=s;setTimeout(()=>{s!==A||t().signal.aborted||P(v,E).catch(()=>{})},0)},g=()=>{a?.abort(),a=void 0};let C;const _=()=>{const v=t().signal;v!==C&&(C?.removeEventListener("abort",g),C=v,v.addEventListener("abort",g))};async function P(v,E,A=0){const h=++s;g(),a=new AbortController,c=void 0,_();const l=()=>s!==h,u=b.readTarget(),p=t().generation,R=()=>p===t().generation&&!t().signal.aborted,D=E?"init:reset-":"init:",N=cm(()=>e.observeShow?.(lm(v,E,e.readEmail())));if(!E){const ne=b.publicEmail();ne?.id,ne?.renderGuid,ne?.preheader}let I=!1,O=!1,L,Q=!1;const ce=()=>{if(m(L))throw Gi()},te=()=>{if(l())throw de("Fill superseded")};try{n=!0,await b.sendInitStart(),te(),L=f(),c=L,A===0&&b.fireWillInit(),await(E||A>0?b.refreshContent():b.sendContent()),I=!0,te(),ce();const ne=b.contentSent();b.noteFilled(ne?.target,ne?.docId),N.stage("content"),E||b.publicEmail()?.id;try{await b.sendPreheader()}catch(k){if(Ni(k)||l())throw k;`${D}`,String(k)}te();try{await b.sendSubject()}catch(k){if(Ni(k)||l())throw k;`${D}`,String(k)}if(te(),ce(),b.showFilled(u),await b.sendInited(),te(),ce(),O=!0,i===v){const k=e.readSandboxGeneration?.()??o;k!==void 0&&(r=k)}N.stage("reveal"),await b.revealFilled(),ce(),N.end("revealed")}catch(ne){const k=!l()&&R()&&m(L),$=k?Gi():void 0,W=$??ne,z=k&&A<am?M(v,E,A+1):void 0;Q=k&&z===void 0;const Z=l()?void 0:{showId:v,contentApplied:I,sandboxInitedAcked:O,superseded:!1,...e.describeSurface?.(),error:String($??ne)};Z&&(`${D}`,void 0);const ge=!l()&&e.recoverFailedFill?.(u)===!0;if(N.end(l()?"superseded":ge?"recovered":Or(W)||!R()?"aborted":"failed",Z),!ge&&!l()&&ma(t(),v)&&t().failShow(v,W),z!==void 0)return z;throw W}finally{S(v,E,D,{superseded:l(),sessionGeneration:p,contentApplied:I,sandboxInitedAcked:O&&!Q,retry:!Q,commit:R()})}}function S(v,E,A,h){const{superseded:l,contentApplied:u,sandboxInitedAcked:p}=h;if(l){`${A}`;return}p&&h.commit?b.fireInit(v,E||void 0):p?(`${A}`,h.sessionGeneration,t().generation,t().signal.aborted,void 0):u?(`${A}`,void 0):(`${A}`,void 0),n=!1,a=void 0,!p&&i===v&&(i=void 0,r===o&&(r=void 0)),!p&&u&&h.retry&&w(v,E)}function M(v,E,A){return P(v,E,A)}return{channel:b,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:v=>{r=v},lastCorrelation:()=>i,markCorrelation:v=>{i=v},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:v=>{o=v},fill:v=>P(v,!1),refill:v=>P(v,!0),stop:()=>{s+=1,g(),n=!1,C?.removeEventListener("abort",g),C=void 0}}}function um(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:ha(e,n)}function ha(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function fm(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=f=>{const m=n(),y=i();if(!um(m,f,y)){f.showId,f.navId,f.emailId,m?.id,m?.showId,m?.renderGuid;return}f.showId,m?.id,m?.renderGuid,t.markFilled(o()),t.markCorrelation(f.showId),t.fill(f.showId).catch(()=>{})};return{showRequested:f=>{s(f)},showRequestIdentityChanged:()=>{const f=e.initPipeline().getActiveShowRequest();f&&s(f)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const f=o();if(t.filledGeneration()===f)return;const m=n(),y=i();if(!m?.renderGuid||!ha(m,y))return;const b=`${pa}${m.renderGuid}`;t.markFilled(f),t.markCorrelation(b);const T=r()?.isReady()===!0;m.id,m.renderGuid,(T?w=>t.refill(w):w=>t.fill(w))(b).catch(()=>{t.lastCorrelation()===b&&t.markFilled(void 0)})},saasChanged:()=>{const f=n();f?.renderGuid,f?.showToken,f?.id,r()}}}var pm=F("canvas.health");function mm(e){return e??""}function hm(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Vi(e){return e.length>0}function gm(e){const t=Le(e),n=ae(e),r=()=>Ee(t.sessionKey())?void 0:t.current(),i=()=>{const x=r();return im({attributes:x?.get().attributes??{},readContent:()=>x?.getContent(),docId:x?.get().docId,hasSession:!!x,serverId:x?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(Re)??Zr;let s={},a=!1;const c=e.getInstance(se)?.watch(x=>{a=!!x?.element});let d=!1,f=!1,m=!1,y=0;const b=()=>{const x=re(e);if(!x)return;const V=++y,G=x.spare();return G&&da(e,G.element),(G?G.reloadQuietly():x.ensureSpare()?.ready())?.then(()=>{if(V!==y)return;d=!0;const q=x.spare();q&&Op(e,q.element),m&&(m=!1,p(),k())})},T=rm({run:()=>{m||b()?.catch(()=>{})}}),w=()=>{Zp(e).noteContentShown(),!d&&!m&&T.start()};let g=!1;const C=x=>{const V=re(e),G=V?.spare()?.element.contentWindow;f&&V&&G&&x===G&&(f=!1,V.promote(),V.busy(!1),g=!0)};let _=!1;const M=dm({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const x=re(e);return g&&x&&(g=!1,T.start()),a?x?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:C,noteFilled:(x,V)=>re(e)?.noteFilled(x,V),recoverFailedFill:x=>{const V=re(e),G=V?.spare()?.element.contentWindow;return!f||!V||!G||x!==G?!1:(f=!1,d=!1,l="reload",V.busy(!1),V.peek("email")?.reload(),_=!0,k(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>ye(n),onSandboxGenerationChange:x=>er(n,x),trackDocument:x=>xp(e,x),observeShow:x=>e.getInstance(pm)?.begin(x),describeSurface:()=>({canvasPath:l,promoted:f,spareClean:d,handshake:n.isInited(),generation:ye(n)}),events:{willInit:x=>{pe(e,j.WILL_EMAIL_INIT_ID).fire(x)},inited:x=>{w(),pe(e,j.ON_EMAIL_INIT_ID).fire(x)},contentChanged:x=>{pe(e,j.ON_CONTENT_CHANGED_ID).fire(x)},emailChanged:x=>{pe(e,j.ON_EMAIL_CHANGED_ID).fire(x)},browserExtensionDetected:()=>{pe(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),v=fm({pipeline:M,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>ye(n)});let E="",A="",h="",l="none";const u=()=>{const x=re(e)?.spare()?.element.contentWindow;x&&n.getTarget()===x||n.sendNow({operation:H.SANDBOX_LOCK_EDIT,data:!0})},p=()=>{const x=re(e)?.spare();x&&(u(),d=!1,f=!0,Dp(e,x.element))},R=(x,V)=>{const G=re(e);if(!G)return!0;const q=G.spare(),je=q&&d?"spare":"prepare";if(l=je,G.busy(!0),q&&d)return p(),!0;T.cancel(),u();const Be=b();if(Be===void 0)return l="reload",G.busy(!1),G.peek("email")?.reload(),!0;m=!0;const De=y;return Be.catch(()=>{!m||De!==y||(m=!1,l="reload",G.busy(!1),G.peek("email")?.reload())}),!1},D=()=>{st(),M.noteSandboxGeneration(ye(n));const x=i(),V=hm(x?.renderGuid,x?.showId,x?.id,s.emailId),G=mm(x?.renderGuid);if(G!==A){const Be=A;A=G;const De=re(e)?.peek("email")?.filled,bl=De!==void 0&&De!==G;Vi(G)&&(Vi(Be)||bl)&&R(Be||(De??""),G)}if(m)return;(V!==E||_)&&(_=!1,E=V,v.showRequestIdentityChanged());const q=r(),je=`${V}|${q?.get().docId??""}|${ye(n)}`;je!==h&&q?.isReady()===!0&&(h=je,v.selfInitChanged()),v.saasChanged(),te()};let N=!1,I="",O="",L=!1,Q=!1;const ce=x=>{x.source==="user"?Q=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(L=!0),k()},te=()=>{const x=i();if(!x?.renderGuid)return;const V=M.channel.readContent(),G=JSON.stringify([x.preheader,x.common_styles,x.meta,x.subject,x.utm_parameters?.utm_campaign??"",x.utm_parameters?.utm_content??"",x.utm_parameters?.utm_medium??"",x.utm_parameters?.utm_source??"",x.utm_parameters?.utm_term??""]),q=N&&V!==O,je=N&&G!==I;N=!0,O=V,I=G;const Be=L&&!Q;if(L=!1,Q=!1,M.isEventsLocked()||Be)return;const De={...x,id:s.isTemplate||x.isNew?void 0:x.id,html:V};if(q){pe(e,j.ON_CONTENT_CHANGED_ID).fire(V),pe(e,j.ON_EMAIL_CHANGED_ID).fire(De);return}je&&x.is_inited&&pe(e,j.ON_EMAIL_CHANGED_ID).fire(De)};let ne=!1;const k=()=>{ne||(ne=!0,queueMicrotask(()=>{ne=!1,D()}))};e.inject(ei,{pipeline:M,setRoute:x=>{x.emailId===s.emailId&&!!x.isTemplate==!!s.isTemplate||(s=x,k())}});let $,W;const z=()=>{const x=r()?.get().docId;x!==W&&($?.(),W=x,$=r()?.subscribe(ce)),k()};let Z,ge;const st=()=>{const x=e.getInstance(Re);!x||x===Z||(ge?.(),Z=x,ge=x.onShowRequested(V=>v.showRequested(V)))},Fe=n.addListener(x=>{x.data?.operation===H.SANDBOX_RESIZED&&T.notify()}),Pe=t.subscribe(z),Ut=er(n,k);z(),e.getInstance(U)?.addDispose(()=>{c?.dispose(),ge?.(),Ut(),Pe(),$?.(),Fe.dispose(),T.cancel(),M.stop()})}function vm(){return Gl!=="emailmaker"}var bm={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:"",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},ga={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:"",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}},qi=ga,ym=["pro"],lr={};function Em(e){lr=e}var va=e=>ym.includes(e)?qi:lr[e]??lr.editor??qi,cr={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:"",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},_m={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:"",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},wm={...cr,config:{...cr.config,imageCenterFileManagerView:!1}};Em({pro:ga,editor:_m,simple:vm()?cr:wm,blocks:bm});var ba=F("CodeMode");function ya(){let e;try{const t=window.localStorage?.getItem(Mt.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 Sm(e){try{window.localStorage?.setItem(Mt.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function Ea(e){return e.getOrCreateInstance(ba,()=>{const t=_e(ya());return t.watch(Sm),t})}function _a(e){return e?.getInstance(ba)?.get()??ya()}function dr(e,t){const n=Ea(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function Im(e,t){const n=Ea(e);n.set({...n.get(),direction:t})}function Cm(e,t,n=e.getInstance(oe)){n?.setMode(t),n?.get()?.codeEnabled===!1&&_a(e).isCodeMode&&dr(e,!1)}function Tm(e){e.getInstance($l)||e.inject(Ae,void 0)}function gn(e){return String(e.standaloneKey||"").trim()||void 0}function Am(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function ti(e){return Am(e)?!!gn(e):!1}function Lt(e){return!!gn(e)&&!ti(e)}var Rm=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function zi(e){return e==="server"?"serverSide":e}function Pm({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=_e();let o={kind:"pending"},s;const a=new Promise(y=>{s=y}),c=n===void 0?void 0:setTimeout(()=>{f({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function d(){o.kind!=="pending"&&i.set(An(r,e))}function f(y){if(o.kind!=="pending")return;clearTimeout(c),o=y;const b=An(r,e);i.set(b),s(b)}function m(y,b){r[zi(y)]=b,y==="server"&&o.kind==="pending"?f({kind:"applied"}):d()}return{watch:y=>i.watch(y),select:y=>i.select(y),get:()=>i.get(),ready:()=>a,state:()=>o,layers:()=>({...r}),bootstrap(){const y=An(r,e);return Object.fromEntries(Rm.map(b=>[b,y[b]]))},merge(y,b){m(b,{...r[zi(b)],...y})},replace(y,b){m(b,y)},setMode(y){r.user={...r.user,mode:y},d()},setAdvancedConfigs(y){r.advancedConfigs=y,d()},serverAbsent(y){f({kind:"absent",reason:y})},applyServerResponse(y){o.kind==="pending"&&m("server",{...r.serverSide,...y})},dispose(){clearTimeout(c)}}}var Dm=5e3;function Om(){return{...va("pro")?.config,mergeTags:void 0}}function xm(e,t){e.getInstance(se)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function Mm(e,t){let n;Wr(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 km(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Lm(e,t){let n,r=!1,i;const o=a=>{i??=hn(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&Cm(e,a,t)},s=Wr(e).watch(({profile:a})=>{const c=a?.email_builder_config,d=km(c);if(d===void 0||c===n)return;const f=n===void 0;n=c,!(f&&r)&&o(d)});e.getInstance(U)?.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 Wi="замкнутый контур: app_init не выполняется";function Nm(e,t){if(e.getInstance(Ae)){t.serverAbsent(Wi);return}const n=e.getInstance(se)?.watch(r=>{Lt(r)&&t.serverAbsent(Wi)});n&&e.getInstance(U)?.addDisposable(n)}async function Fm(e,t){if(e.getInstance(Nr)===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 jm(e){e.injectFactory(oe,(t,n)=>{if(n)return n;const r=Pm({base:Om(),env:{modeDefaults:i=>va(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Dm});return xm(e,r),Mm(e,r),Lm(e,r),Nm(e,r),Fm(e,r),e.getInstance(U)?.addDisposable(r),r},!0)}var et=class extends ie{_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 B(e,t,n){const r=_l(e);return(i,o,s)=>{const a=r(async c=>{const d=t?t(c):c;s&&i.bind(s);const f=await i(d);return n?n(f):f},o,s);return()=>a.dispose()}}var Bm=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Yn;this.handleDestroy=B(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new et(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{}}},ni=F("DestroyableService");function Um(e){e.injectFactory(ni,(t,n)=>{if(n)return n;const r=e.getInstance(U);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Bm({lifetime:r,options:e.getInstance(se),getInstance:()=>e.getInstance(mn),release:()=>Rl(e.getInstance(Vl)??e)})},!0)}function Hm(e){const t=e.getInstance(ni);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var $m=1e3;function wa(e,t,n=$m,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(!wa(e[s],t[s],n,r+1))return!1;return!0}return!1}function Et(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];wa(i,o)||(n[r]=i)}return n}var Gm=({source:e,emailtags:t,group:n,tags:r,...i})=>i;async function Vm(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function qm({emails:e,saveTimeoutMs:t},n,r){const i=t?.()??Br();let o;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,c)=>{o=setTimeout(()=>{const d=new Ur(i);n.value.id,gd(d,Vm(s,r)),c(d)},i)})])}catch(s){throw gs(s),s}finally{o!==void 0&&clearTimeout(o)}}function zm(e){const{emails:t}=e,n=async(r,i)=>{const o=Gm(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...o}:o,c=s?Et(s,o):o,d=f=>{const m=String(f.id??r??Ie()),y=f.id===void 0?{...f,id:m}:f;return t.cache.addOrUpdate(m,()=>y)};return await d(await qm(e,{prev:s,patch:c,value:a,source:i.source??""},d))};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:Ie()}},async updateEmail(r,i){return await n(r,i)}}}var Dn=20;function Wm(e){const t=Km(e);return e.saveTimeoutMs?Ym(t,e.saveTimeoutMs):t}function Km({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(d=>String(d?.parent)===String(a)));return{async readRevisions(a,c=1){const d=await s(a,c);return{revisions:d.slice(Dn*(c-1),Dn*c),page:c,hasMore:d.length>Dn*c}},async readAutosave(a){const c=await r?.(a)??NaN,d=Number.isFinite(c)?c:void 0,f=await n?.(a);if(!f?.asked)return Cd(await s(a,1),d);if(!f.revision)return Ai([],d);const m={...f.revision,parent:a,isAutosave:!0};return Ai([m],d,await s(a,1))},async saveAutosave(a,c){const d=await i?.(a),f=o?.();return await e.create({...Od(c),...d!==void 0?{author:d}:{},...f!==void 0?{project:f}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Ym(e,t){return{...e,async saveAutosave(n,r){const i=t();let o;try{return await Promise.race([e.saveAutosave(n,r),new Promise((s,a)=>{o=setTimeout(()=>a(new fs(i)),i)})])}catch(s){throw gs(s),s}finally{o!==void 0&&clearTimeout(o)}}}}var Xm=class extends Ll{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}},Jm=class extends Me{};var Ki=class extends ie{_items=new Map;_onChangeEmitter=new sc;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 Te(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 Qm(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(d=>{for(const f of c){const m=d[f],y=t[f];return f==="id"||typeof m!="string"?m===y:typeof y=="string"&&m.startsWith(y)}return!0}),a=e.length}return r&&(e=e.sort((c,d)=>(c[r]>d[r]?1:d[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 Zm(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 eh(e,t){return Yi(e)&&Yi(t)?String(e)===String(t):e===t}function Yi(e){return typeof e=="string"||typeof e=="number"}var th=class extends ie{_cache=new Ki;_readEmitter=new Me;_saveEmitter=this.addDisposable(new Xm);_removeEmitter=this.addDisposable(new Jm);_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)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ie);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Ki),i=n.addDisposable(new Me);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const c=Zm(await i.fire(o))||[];for(const d of c)d[e]=o,await this._cache.add(d.id,d);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const d=c[e];return d==null||eh(d,o)});return Qm(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=Ie()),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?Et(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 Nt(e){const t=F(e);return n=>n.getOrCreateInstance(t,()=>new th)}function Sa(e){const t=e.getInstance(U);if(!t)throw new Error("Failed");return t}function Xi(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function On(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function nh(e,t,n){return e&&!Xi(t)&&Xi(e)?{...n,meta:e.meta}:n}var rh=F("CurrentProject"),ih={};function Ft(e){return e?.getInstance(rh)?.get()??ih}function ri(e){const t=Ft(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Ia=Nt("plugin.dataSource.emails"),Ca=Nt("plugin.dataSource.emailRevisions"),Ta=Qr("plugin.readEmailAutosave"),Ji=F("emailDocuments.provided");function oh(e){const t=Ia(e),n=Ca(e),r=n.byForeignKey("parent");if(e.getInstance(Ji))return{emails:t,emailRevisions:n};e.inject(Ji,!0);const i=()=>Br(e.getInstance(Re)?.contentReadyTimeoutMs),o=zm({emails:t,saveTimeoutMs:i}),s=new Map,a=(c,d)=>f=>{const m=f?.id??d;return(typeof m=="string"||typeof m=="number")&&s.set(String(m),c),f};return nu(e,{...o,createEmail:c=>o.createEmail(c).then(a(Date.now())),updateEmail:(c,d)=>o.updateEmail(c,d).then(a(Date.now(),c))}),su(e,Wm({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const d=await pe(e,Ta).fire(c);return d.length===0?{asked:!1}:{asked:!0,revision:d[0]??null}},savedAt:async c=>{const d=Sd((await t.cache.getIfPresent(c))?.modified),f=s.get(String(c))??NaN;return Number.isFinite(f)&&!(d>=f)?f:d},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:i,integratorProject:()=>Ft(e).requested})),Sa(e).addDisposable(t.onSave(({prev:c,patch:d,value:f})=>nh(c,d,f),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function Qi(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 sh(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var ah="po",Kt=null;function lh(){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([ah],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function ch(){return Kt===null&&(Kt=lh().catch(e=>{throw Kt=null,e})),Kt}async function Aa(e){if(typeof e=="object")return ii(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?dh(t):uh(t)}function ii(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function dh(e){try{return ii(JSON.parse(e))}catch{return}}var Zi=!1;async function uh(e){try{return ii((await ch()).parsePoCatalog(e))}catch{Zi||(Zi=!0);return}}var fh="em_locale",ph="em_ant_locale",mh="locale",hh="ant_locale";function oi(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Ra(e,t){const n=oi(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function gh(){return oi("em_locale")??Ra(mh,"em_locale")}function eo(e){try{localStorage.setItem(fh,JSON.stringify(e))}catch{}}function vh(){return oi("em_ant_locale")??Ra(hh,"em_ant_locale")}function bh(e,t){try{localStorage.setItem(ph,JSON.stringify({id:e,data:t}))}catch{}}var yh=8e3;function Eh(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 _h(e){const t=gh(),n=vh();let r={ready:!1},i;const o=_e(r);let s=0;const a=g=>{r={...r,...g},o.set(r)},c=()=>{r.ready||a({ready:!0})},d=setTimeout(c,e.unlockAfterMs??yh),f=g=>g!==s;let m;async function y(g,C){if(n?.id===g&&n.data&&a({antd:n.data}),!m)return;const _=await m(g).catch(()=>{});!_||f(C)||(a({antd:_}),bh(g,_))}async function b(g,C){const _=await e.askHost(g).catch(()=>null);if(f(C))return!0;if(_==null)return!1;const P=await Aa(_);return f(C)||(P&&a({catalog:P}),c()),!0}async function T(g,C){const _=await e.readList();if(f(C))return;if("error"in _){a({failure:{kind:"GET_LOCALES_ERROR",error:_.error}}),c();return}const P=_.data.find(M=>M.locale===g);if(!P){sh("em_locale")&&a({catalog:void 0}),c();return}if(Qi(t,P)&&(!i||i.catalog===t?.data)){c();return}if(i?.entry&&r.catalog===i.catalog&&Qi(i.entry,P)){eo(i.entry),c();return}const S=await e.readCatalog(g);if(!f(C)){if("error"in S){a({failure:{kind:"GET_LOCALE_ERROR",error:S.error}}),c();return}S.data&&(i?.id===g&&r.catalog===i.catalog&&Eh(i.catalog,S.data)||a({catalog:S.data}),eo({id:g,time:P.updatedAt||Math.floor(Date.now()/1e3),hash:P.contentHash,data:S.data})),c()}}async function w(g,C){if(!await b(g,C)){if(!f(C)&&(i?.id===g&&r.catalog===i.catalog||g==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await T(g,C)}}return{set(g){if(!g||g===r.id)return;const C=s+=1;a({id:g,failure:void 0});const _=i?.id===g&&r.catalog===i.catalog;(i&&!_&&r.catalog===i.catalog||g==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===g&&t.data&&(a({catalog:t.data}),c()),y(g,C),w(g,C)},prime(g,C,_){r.id&&r.id!==g||r.catalog||!C||(i=t?.id===g&&t.data&&(!_||t.time>=_.time)?{id:g,catalog:t.data}:{id:g,catalog:C,entry:_?{id:g,time:_.time,hash:_.hash,data:C}:void 0},a({catalog:i.catalog}))},useAntdLoader(g){m=g,r.id&&y(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(d)}}var wh=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})},Sh=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 d=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},f=this.mergeRequestParams(c,d),m=i&&this.toQueryString(i),y=this.contentFormatters[r||"application/json"],b=o||f.format;return this.customFetch(`${s||this.baseUrl||""}${n}${m?`?${m}`:""}`,{...f,headers:{...f.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):f.signal)||null,body:typeof e>"u"||e===null?null:y(e)}).then(async T=>{const w=T;w.data=null,w.error=null;const g=b?T.clone():T,C=b?await g[b]().then(_=>(w.ok?w.data=_:w.error=_,w)).catch(_=>(w.error=_,w)):w;return a&&this.abortControllers.delete(a),C})}},Ih=F("rest.v2.transport"),to=Symbol("rest.v2.secureRequest");function Ch(e){return e.getOrCreateInstance(Ih,()=>{const t=e.getInstance(Dl)?.execute||fetch;return new Sh({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[to]:!0}),customFetch:(n,r={})=>{const{[to]:i,...o}=r;return t(n,{...o,[xl]:i!==!0})}})})}function Th(e,t){const n=Ch(e);return Object.assign({},...t.map(r=>new r(n)))}function no(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Pa(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:no(n.details,"wp_code")??n.code,message:no(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 Da(e){return!e.ok||!!e.error}function Ah(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Oa(){return Ah(Mt.em_translations_v2)??!0}function Rh(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Ph(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Dh(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:Rh(r[1])}),t},[]):[]}function Oh(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Ph(n.updated_at),contentHash:n.content_hash}),t),[])}function xa(e){return Th(e,[wh])}function cn(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function ur(e){return!e.ok||e.error!=null}function fr(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function xn(e){return{data:await Aa(e)??null}}async function xh(e){if(Oa())try{const n=await xa(e).localesList();return Da(n)?{error:Pa(n)}:{data:Oh(n.data)}}catch(n){return cn(n)}const t=qo(e,[es]);try{const n=await t.get_translations2({file:"react_app"});return ur(n)?fr(n):{data:Dh(n.data)}}catch(n){return cn(n)}}async function Mh(e,t){if(Oa())try{const r=await xa(e).jsonList({locale:t});return Da(r)?{error:Pa(r)}:xn(r.data)}catch(r){return cn(r)}const n=qo(e,[es]);try{const r=await n.get_translations3({id:t,file:"react_app"});return ur(r)?fr(r):xn(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return ur(r)?fr(r):xn(r.data)}catch(r){return cn(r)}}}var Yt=new WeakMap;function kh(e){const t=Yt.get(e);if(t!==void 0)return t;const n=xh(e).then(r=>("error"in r&&Yt.delete(e),r),r=>{throw Yt.delete(e),r});return Yt.set(e,n),n}var Tt=F("locale.service");function Lh(e){if(e.getInstance(Tt))return;const t=_h({readList:()=>kh(e),readCatalog:n=>Mh(e,n),askHost:async n=>(await pe(e,j.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(Ae)});e.inject(Tt,t),e.getInstance(U)?.addDispose(()=>t.dispose())}function Nh(e){const t=e.getInstance(oe);if(!t)return;const n=e.getInstance(Tt);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i||"ru_RU"));e.getInstance(U)?.addDisposable(r)}var Fh="user_id",jh="project_id",ro=F("rest.identityHeadersProvided");function Bh(e){if(e.getInstance(ro))return;e.inject(ro,!0);let t;e.getInstance(se)?.watch(n=>{t=n}),e.addService(Ar,{execute(n,r){if(r?.public)return;const i=t?.user?.id??Ms(e).profile?.id;i!=null&&i!==""&&n.headers.set(Fh,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(jh,String(o))}})}function Uh(e){if(!e)return!1;try{return e.getInstance(Ae)!==void 0}catch{return!1}}var Hh="Invalid standaloneKey.",OE=F("StandaloneMockGuard");function $h(){const e=new Error(Hh);return e.name="InvalidStandaloneKeyError",e}function Gh(e){e.addService(Ar,{execute:()=>{if(Uh(e))throw $h()}})}function Vh(e){kl(e),Gh(e)}function qh(e){const t=new Qs;e.inject(Re,t);const n=e.getInstance(se)?.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(U);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var zh=Nt("plugin.dataSource.blocks"),Wh=Nt("plugin.dataSource.blockRevisions"),Kh=Nt("plugin.dataSource.comments"),Yh=Qr(),Xh=Qr(),Ma=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
1005
1005
|
<html>
|
|
1006
1006
|
<head>
|
|
1007
1007
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
@@ -1042,10 +1042,10 @@ import{n as Go,r as bl}from"./static/esm/971f1b2c.js";import{A as Vo,At as rn,B
|
|
|
1042
1042
|
</tr>
|
|
1043
1043
|
</table>
|
|
1044
1044
|
</body>
|
|
1045
|
-
</html>`;function
|
|
1045
|
+
</html>`;function Jh(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:Ma,project:e?.id,project_title:e?.title??"",tags:[],utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var ka=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Qh(e){return!Object.keys(e).some(t=>ka.has(t))}function Zh(e){const t={},n={};for(const[r,i]of Object.entries(e))ka.has(r)?t[r]=i:n[r]=i;return{showOptions:t,misplacedEmailFields:n}}function io(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function jt(e){return{emails:Ia(e),blocks:zh(e),emailRevisions:Ca(e),blocksRevision:Wh(e),comments:Kh(e)}}function eg(e){const t=Object.values(jt(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function vn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Qh(e))return{email:io(e)};{const{showOptions:n,misplacedEmailFields:r}=Zh(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:io({...r,...o})}}}function si(e){return Kr(e)?.current()}function Zt(e){return si(e)?.getContent()}function La(e,t){const n=t??Jh(),r=si(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:Zt(e)??n.html}:n}async function en(e){return(await e.getInstanceAsync(xe))?.project}async function tg(e){return ri(e)??await en(e)}function oo(e){if(!e)return;const t=vn(e,!1).email.id;return t==null?void 0:String(t)}function ng(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function rg(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}function it({code:e,project:t,...n},r){const i=ke(n),o=ri(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 ue({html:e,renderGuid:t,showToken:n,showId:r,...i},o){const{requested:s}=Ft(o),a=Ns(o);return ke({...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})}function pr(e){return e==null?"":e.replaceAll(`\r
|
|
1046
1046
|
`,`
|
|
1047
|
-
`)}function so(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function ng(e,t,n,r){const i=rg(e,t,n,r);return i===void 0}function rg(e,t,n,r){const{email:i}=vn(t,!1),o=it(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=Kr(e)?.current();if(!a)return"no-session";const c=a.get(),d=c.attributes;if(c.serverId!==s)return"document-id";if(d.is_inited!==!0)return"not-inited";const f=so(pr(n??a.getContent()));if(o.html!==void 0&&so(pr(o.html))!==f)return"html";if(o.subject!==void 0&&o.subject!==d.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==d.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==d.common_styles)return"common_styles"}function ao(e,t){const{email:n}=vn(t,!1),r=it(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:pr(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function ig(e,t){const n={...e};return delete n.id,{...n,...t}}function og(e){return e.html?e:{...e,html:xa}}function pt({code:e,project:t,...n},r,i){const o=i??ri(r);return{...n,...e?{html:ze(r).toEditorForm(e)}:{},renderGuid:Se(),...o===void 0?{}:{project:o}}}function mt({html:e,renderGuid:t,...n},r){const{requested:i}=Ft(r);return ke({...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 La(e){return Kr(e)?.current()?.get().serverId??void 0}function mr(e,t,n){return n===void 0&&(n=e.post===void 0?La(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function ht(e,t){return ke({...e,link:void 0,comment_status:void 0})}function tn({code:e,autosave:t,...n},r,i){return i===void 0&&(i=n.parent===void 0?La(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||xd(n.slug),parent:i}}function hr({html:e,isAutosave:t,...n},r){return ke({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:ke({html:e,ampHtml:e&&""})})}var tt=F("NotificationService"),sg=F("emailTemplate.reads");async function ag(e,t){try{return await Ve(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,cg(e,t,n);return}}var lg=F("emailTemplate.notifiedFailures");function cg(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(lg,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(tt).then(()=>{kt(e,j.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function dg(e,t){const n=e.getOrCreateInstance(sg,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=ag(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var ug="EXTERNAL",lo=Symbol("supersededShow");function fg(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var pg="email_id",mg=class extends ie{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=zo();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=jt(t),this._eventLock=Qh(t);const n=te(e,j.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(Ar,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(pg,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Ae)??Zr}_throwIfDestroyed(){if(this.isDisposed())throw Oe()}async getTemplateEmail(e){const t=await dg(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await en(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,pt(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,tn(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,mr(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 en(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let d=it(e,this._container);const f=d.id;let m=f;if(f!==void 0){const y=await o.get(f);d={...y??{},...d,utm_parameters:d.utm_parameters??y?.utm_parameters??{},renderGuid:y?.renderGuid??Se(),...c>0?{showToken:c}:{},...i?{showId:i}:{},project:a}}else{m=n??Se();const y=await o.get(m);d={...d,utm_parameters:d.utm_parameters??{},renderGuid:y?.renderGuid??Se(),...c>0?{showToken:c}:{},...i?{showId:i}:{},project:a},delete d.project}if(t){const y=await this.getTemplateEmail(String(t));y&&(d=ig(y,d))}return f===void 0&&(d=og(d)),await s.setAll([[m,d]]),d}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==ao(this._container,e))return!1;const n=Zt(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=ao(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Zt(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&eg({ticket:t,emailId:oo(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,lo;if(!e)return;const n=this._getInitPipeline();Y(n.signal);const r=tg(e);if(!r&&ng(this._container,e,Zt(this._container),this._prevCommand?.id)||!r&&this._isRepeatOfLastShow(e))return;const i=vn(e);i.email.id,this._prevCommand?.id;let o,s="",a=0,c=!1,d,f=Promise.resolve(),m,y=!1;try{this._eventLock.suspendChange();const{email:b,blocks:T,autosaves:w,comments:g,templateId:C,reload:_}=i;o=b.id;const P=it(b,this._container),S=P.id,M=S??Se(),v=await bt("getProject",en(this._container));Y(n.signal),s=Se();const E={isNew:S===void 0,id:String(M),project:v},A=_===!0&&S!==void 0;A&&(await this._dataSources.emails.remove(String(S),{silent:!0}),String(S)),a=++this._showToken,String(M);const h=[];h.push(this.setBlocks(T)),b.id!==void 0&&(h.push(this.setComments(g)),h.push(this.setEmailRevisions(w,String(b.id)))),h.push(this.setEmail(b,Number(C),S===void 0?String(M):void 0,a,s)),await bt("setEmail+blocks+revisions",Promise.all(h),{emailId:S??String(M),showId:s,targetShowToken:a}),Y(n.signal);const l=await this._dataSources.emails.get(String(M)),u=Le(this._container),p={id:s,token:a};S===void 0?m=u.startNewDraft(l??P,{patch:P,show:p}):A?m=u.reload(S,{email:l??P,patch:P,show:p}):u.sessionKey()===Ke(S)?m=u.show(P,p):m=u.open(S,{email:l??P,patch:P,show:p});const R=!!this._prevCommand&&Ce(this._prevCommand,E);E.id,!this._prevCommand||Ce(this._prevCommand,E),this._prevCommand?.id,this._rememberShow(E),f=n.requestShow({showId:s,navId:String(M),emailId:S,isNew:S===void 0}),y=!0,String(M),c=!0}catch(b){d=b,y&&s&&n.failShow(s,b),Or(b)||(ds(b),void 0)}finally{this._eventLock.resumeChange()}if(!c)throw d instanceof Error?d:new Error(`[emailmaker] show() setup failed: ${String(d??"unknown error")}`);return bt("show-init-deferred",Promise.all([f,m?.whenReady().catch(b=>{if(b instanceof It){const T=zr(b);throw T?new Error(`[emailmaker] show(): email open failed (${T})`,{cause:b}):b}})??Promise.resolve()]).then(()=>{}),{showId:s,emailId:o??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();Y(e.signal);const t=Le(this._container),n=await t.save("publish",{source:ug,fallbackTitle:Hs(this._container)});if(Y(e.signal),!n)throw fg(t.saveState().error);return de(ka(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=oo(e);const n=this._queuedShow(e,t).then(r=>r===lo?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};save=this._queue.decorate(this._save,this)};function hg(e){return String(e).replace(/"/g,""")}function gg(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 vg(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 co(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=hg(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function bg(e,t,n){if(!e?.trim()||!t)return e;const r=vg(e);if(!r)return e;const i=String(t),o=gg(n??new Date);let{full:s,index:a}=r;const c=s.length;return/\bem-block-id\s*=/.test(s)||(s=co(s,"em-block-id",i)),s=co(s,"em-block-version",o),e.slice(0,a)+s+e.slice(a+c)}function yg(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 Eg(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:yg(e)}}function Mn(e,t){return t?Eg(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Na=["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"],_g=[...Na,"html","id","project","password"],DE=new Set(["html",...Na,"global_block","project"]);function wg(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(_g),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 Sg(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...wg(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 gr=new WeakMap;function Ig(e){let t=gr.get(e);return t||(t={byId:new Map,fallback:[]},gr.set(e,t)),t}function Cg(e){gr.delete(e)}function Tg(e,t){const{byId:n,fallback:r}=Ig(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 Ag(e,t){const{blocks:n}=jt(e);return await n.cache.getIfPresent(t)??void 0}async function Rg(e,t){if(!t.blockId)return;const n=await Ag(e,t.blockId);if(n)return Sg(n,t)}async function Pg(e,t){const n=Tg(e,t);if(n)return Mn(e,n);const r=await Rg(t,e);return r?Mn(e,r):Mn(e,void 0)}var Dg=Wo("application_block_inserted"),Og=-1e3,uo=new WeakSet;function xg(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 Mg(e){if(!e||uo.has(e))return;uo.add(e);const t=new ie,n=ae(e);return t.addDisposable(n.addListenerAsyncPipe(Dg,async(r,i)=>{const o=xg(r)?await Pg(r,e):r;return i?i(o):o},Og)),t.addDisposable({dispose:()=>{Cg(e)}}),t}var Fa=F("plugin.earlyWindow");function kg(e){return e.getOrCreateInstance(Fa,()=>({depth:0}))}function Lg(e){const t=kg(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function ja(e){return(e?.getInstance(Fa)?.depth??0)>0}function Ba(e,t){let n,r=!1;return e(i=>{n=i,r=!0}),(i,o,s)=>{const a=e(i,o,s);if(r&&ja(t)){const c=n;queueMicrotask(()=>{i.call(s,c)})}return a}}var fo=100,Ng=class extends ie{_container;_events;constructor(e){super(),this._container=e;const t=Mg(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=jt(e),o=te(e,j.ON_SHARE_ID),s=te(e,j.ON_SHOW_PREVIEW_ID),a=te(e,j.ON_EMAIL_CLONE_ID),c=te(e,j.ON_CODE_VALIDATE_ID),d=te(e,j.ON_SUBJECT_CHANGED_ID),f=te(e,j.ON_EMAIL_CHANGED_ID),m=te(e,j.ON_PREHEADER_CHANGED_ID),y=te(e,j.ON_SAVEBUTTON_CLICK_ID),b=te(e,j.ON_NEXTBUTTON_CLICK_ID),T=te(e,j.ON_SEND_LIVEPREVIEW_ID),w=te(e,j.ON_SEND_TESTEMAIL_ID),g=te(e,Kh),C=te(e,j.ON_CONTENT_CHANGED_ID),_=te(e,Wh),P=te(e,j.ON_PREVIOUSBUTTON_CLICK_ID),S=te(e,j.ON_SEND_EMAIL_MODAL_ID),M=_l(te(e,j.ON_EMAIL_INIT_ID),v=>!v.reset);return{handlePreheaderChanged:B(m),handleSubjectChanged:B(d),handleValidate:B(c),handleReadEmail:B(n.handlerRead,v=>v,v=>v&&it(v,e)),handleSaveEmail:B(n.onSave,function({prev:v,patch:E,value:A,source:h}){const l=v?de(v,e):void 0;return{prev:l,patch:Et(l,de(E,e)),value:de(A,e),source:h}},v=>v?it(v,e):void 0),handleRemoveEmail:B(n.onRemove,({value:v,source:E})=>({value:de(v,e),source:E}),()=>{}),handleReadCommonBlocks:B(g,v=>v.project,v=>v?.map(E=>pt(E,e))),handleReadTemplateBlocks:B(_,v=>v,v=>v?.map(E=>pt(E,e))),handleReadBlocks:B(t.byForeignKey("project").handleRead,v=>Ft(e).requested||String(v),v=>v?.map(E=>pt(E,e))),handleSaveBlock:B(t.onSave,function({prev:v,patch:E,value:A,source:h}){const l=A.global_block===!0&&A.id&&typeof A.html=="string"?{...A,html:bg(A.html,String(A.id))}:A,u=v?mt(v,e):void 0;return{prev:u,patch:Et(u,mt(E,e)),value:mt(l,e),source:h}},v=>v?pt(v,e):void 0),handleRemoveBlock:B(t.onRemove,({value:v,source:E})=>({value:mt(v,e),source:E}),()=>{}),handleReadComments:B(r.byForeignKey("post").handleRead,v=>v,v=>v?.map(E=>mr(E,e))),handleSaveComment:B(r.onSave,function({prev:v,patch:E,value:A,source:h}){const l=v?ht(v,e):void 0;return{prev:l,patch:Et(l,ht(E,e)),value:ht(A,e),source:h}},v=>v?mr(v,e):void 0),handleRemoveComment:B(r.onRemove,({value:v,source:E})=>({value:ht(v,e),source:E}),()=>{}),handleReadEmailRevisions:B(i.byForeignKey("parent").handleRead,v=>v,v=>v?.map(E=>tn(E,e))),handleReadEmailAutosave:B(te(e,Ca),v=>v,v=>v?tn(v,e):null),handleEmailAutosave:B(i.onSave,function({prev:v,patch:E,value:A,source:h}){return{value:hr(A,e),source:h}},v=>v?tn(v,e):void 0),handleRemoveEmailAutoSave:B(i.onRemove,({value:v,source:E})=>({value:hr(v,e),source:E}),()=>{}),handleEmailChanged:B(vi(f,fo),v=>de(v,e)),handleEmailInit:Ba(B(M,v=>de(v,e)),e),handlePreviousButtonClick:B(P,v=>de(v,e)),handleNextButtonClick:B(b,v=>de(v,e)),handleSaveButtonClick:B(y,v=>de(v,e)),handleHtmlChanged:B(vi(C,fo)),handleTestEmailSend:B(w,({html:v,...E})=>({...E,code:v,compiled:{html:v,ampHtml:""}})),handleTestEmailModal:B(S,v=>de(v,e)),handleCloneEmail:B(a,v=>de(v,e)),handleShareEmail:B(o),handlePreviewEmail:B(s),handleLivePreviewEmail:B(T)}}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 et(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Fg=F("DataController"),jg=F("DataEvents");function Ua(e){return e.getOrCreateInstance(Fg,()=>{const t=new mg(e);return e.getInstance(U)?.addDisposable(t),t})}function Ha(e){return e.getOrCreateInstance(jg,()=>new Ng(e))}var Bg=F("plugin.pluginStart");function $a(e){return e.getOrCreateInstance(Bg,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(U)?.addDispose(()=>t()),{done:n,finish:t}})}function Ug(e){return $a(e).done}function Hg(e){const t=$a(e);return t.run===void 0&&(t.run=(e.getInstance(xr)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var $g=F("plugin.startupShow");function Gg(e){const t=Ua(e),n=Ha(e),r=e.getInstance(se),i=e.getInstance(U),o={current:Promise.resolve()};e.inject($g,o);let s=!1;const a=r?.watch(d=>{d&&n.setOptions(d),s=(d?.plugins?.length??0)>0,o.current=o.current.catch(()=>{})}),c=r?.select(d=>d?.content).watch(d=>{if(d===void 0)return;const f=()=>(Z(le.showStart),t.show(d).finally(()=>Z(le.showEnd))),m=s?Ug(e).then(f):f();m.catch(()=>{}),o.current=m});a&&i?.addDisposable(a),c&&i?.addDisposable(c)}function Vg(e){const t=Ua(e);return{...Ha(e).get(),show(n){return Z(le.showStart),t.show(n).finally(()=>Z(le.showEnd))},save(){return t.save()}}}function Ga(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function bn(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 qg(e){return(t,n,r)=>bn(t)?e(t,n,r):!1}function zg(e){return t=>bn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Wg(e){return(t,n,r)=>bn(t)?Ga(t)?e(t,n,r):t:!1}function Kg(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return bn(n)?Ga(n)?e(t):t:!1}}function Yg(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function ai(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 Xg(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 Jg=8,Qg=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=Xg(Jg),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},yn=new Qg;function po(e,t){return t!==void 0&&!ai(e,t)?`%|{${yn.getOrCreateByKey(e)}}|%`:e}function Zg(e){const t=yn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function Q(e,t,n){return t!==void 0?ai(e,t)?e:`%|{${yn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function ev(e){return e.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function K(e){return e.startsWith("<!--")&&e.endsWith("-->")?ev(e.slice(4,-3)):e}function tv(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 nv(e,t,n){return t!==void 0?ai(e,t)?e:`%|{${yn.getOrCreateByKey(e)}}|%`:n||Yg(e)||tv(e)?`<!--${e}-->`:e}var He=qg(Q),$e=zg(K),rv=Wg(Q),iv=Kg(K),Va=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",Zg),e.escape("@{","}",Q,!0).unescape("<!--@{","}-->",K,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",po,!0),e.escape("{{","}}",po,!0),e.createSyntax("brace-percent").escape("{%","%}",Q).unescape("<!--{%","%}-->",K),e.createSyntax("brace-hash").escape("{#","#}",Q).unescape("<!--{#","#}-->",K),e.createSyntax("proscript").escape("[%","%]",nv,!0).unescape("<!--[%","%]-->",K,!0),e.createSyntax("getresponse").escape("[[IF","]]",Q).escape("[[if","]]",Q).escape("[[ELSE]]","",Q).escape("[[else]]","",Q).escape("[[ENDIF]]","",Q).escape("[[endif]]","",Q).unescape("<!--[[IF","]]-->",K).unescape("<!--[[if","]]-->",K).unescape("<!--[[ELSE]]","-->",K).unescape("<!--[[else]]","-->",K).unescape("<!--[[ENDIF]]","-->",K).unescape("<!--[[endif]]","-->",K),e.createSyntax("expert-sender").escape("<if",">",Q).escape("</if",">",Q).escape("<else",">",Q).escape("</else",">",Q).escape("<var ",">",Q,!0).unescape("<!--<if ",">-->",K).unescape("<!--</if",">-->",K).unescape("<!--<else ",">-->",K).unescape("<!--</else",">-->",K).unescape("<!--<var",">-->",K,!0),e.createSyntax("velocity").escape("#if",")",He).escape("#elseif",")",He).escape("#else","",Q).escape("#foreach",")",He).escape("#macro",")",He).escape("#set",")",rv,!0).escape("#parse",")",He).escape("#include",")",He).escape("#evaluate",")",He).escape("#end","",Q).escape("#break","",Q).escape("#stop","",Q).unescape("<!--#macro","-->",$e).unescape("<!--#if","-->",$e).unescape("<!--#elseif","-->",$e).unescape("<!--#else","-->",K).unescape("<!--#foreach","-->",$e).unescape("<!--#parse","-->",$e).unescape("<!--#include","-->",$e).unescape("<!--#evaluate","-->",$e).unescape("<!--#end","-->",K).unescape("<!--#break","-->",K).unescape("<!--#stop","-->",K).unescape("<!--#set","-->",iv,!0),e.createSyntax("mailchimp").escape("*|","|*",Q).unescape("<!--*|","|*-->",K)},vr="bare",ov=new Map;function sv(e){return e?ov.get(e)??vr:vr}var qa=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function mo(e){return qa.includes(e)}function lt(e){return e==="bare"||e==="html-comment"}function kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function av(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!lt(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[d,f]of[["output",r.output],["editor",r.editor]])if(f!==void 0&&!lt(f))return t(`templateDirectives.${d}: unknown form "${String(f)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!kn(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[d,f]of Object.entries(r.syntaxes))if(!(!mo(d)||f===void 0||lt(f))){if(!kn(f))return t(`templateDirectives.syntaxes.${d}: expected a form or an object, configuration ignored.`),n;for(const m of["output","editor"]){const y=f[m];if(y!==void 0&&!lt(y))return t(`templateDirectives.syntaxes.${d}.${m}: unknown form "${String(y)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const i=r.output??vr;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 d of Object.keys(r.syntaxes)){if(!mo(d)){t(`templateDirectives.syntaxes: unknown syntax id "${d}", entry ignored.`);continue}s.push(d)}else s.push(...qa);const a={},c={};for(const d of s){const f=r.syntaxes?.[d],m=kn(f)?f:void 0,y=(lt(f)?f:m?.output)??i;let b=m?.editor??o??y;y==="bare"&&b==="html-comment"&&(t(`templateDirectives.syntaxes.${d}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),b="bare"),a[d]=y,c[d]=b}return{output:a,editor:c}}function za(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 gt(e,t){return e.start<t.end&&t.start<e.end}function ho(e,t,n,r,i=[]){if(n&&(t=t.filter(f=>f.isVariable)),!t.length)return[];const o=t.flatMap(f=>f.match(e).flatMap(m=>!Number.isInteger(m.start)||!Number.isInteger(m.end)||m.start<0||m.end>e.length||m.start>=m.end?[]:[{range:m,mapFn:f.mapFn,overrideBuiltins:f.overrideBuiltins,syntax:f.syntax,isVariable:f.isVariable}])).sort((f,m)=>f.range.start-m.range.start||f.range.end-m.range.end),s=[],a=i.slice().sort((f,m)=>f.start-m.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let d=0;for(const{range:f,mapFn:m,overrideBuiltins:y,syntax:b,isVariable:T}of o){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):za(e,d,f.start,c),d=f.end,a.some(_=>gt(_,f)))continue;const w=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,g=e.substring(f.start,f.end),C=m(g,w,c.insideTag);C!==!1&&C!==g&&(s.push({range:f,text:C,overrideBuiltins:y,syntax:b,isVariable:T}),a.push(f))}return s.sort((f,m)=>f.range.start-m.range.start||f.range.end-m.range.end)}function lv(e,t){const n=t.reduce((a,{mapFn:c,start:d,end:f,syntax:m,isVariable:y})=>(a[d]||(a[d]=[]),a[d].push({value:f,mapFn:c,syntax:m,isVariable:y}),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 Ln(e,t,n,r,i=!1){const o=[];if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return o;const s=lv(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let d=0;d<s.length;d++){const{start:f,startToken:m,endTokens:y}=s[d];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):za(e,c,f,a),c=f;const b=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let T=!1;for(const{mapFn:w,value:g,syntax:C,isVariable:_}of y){let P=f+m.length,S=e.indexOf(g,P);for(;S!==-1;){let M=S,v=f+m.length,E=0;for(;M!==-1;){const p=e.indexOf(m,v);if(p!==-1&&p<M)E++,v=p+m.length,M=e.indexOf(g,v);else if(E>0)E--,v=M+g.length,M=e.indexOf(g,v);else break}if(M<0)break;const A=M+g.length,h=e.substring(f,A),l=w(h,b,a.insideTag);if(l===!1){P=S+Math.max(g.length,1),S=e.indexOf(g,P);continue}(i||l!==h)&&o.push({range:{start:f,end:A},text:i?h:l,syntax:C,isVariable:_});const u=s.findIndex(({start:p})=>p>=A);u>d?d=u-1:d=s.length,T=!0;break}if(T)break}}return o}function Xt(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 cv=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=Va){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=Ln(e,this._escapes,t,n),i=ho(e,this._escapeMatchers,t,n),o=i.filter(c=>c.overrideBuiltins).map(c=>c.range),s=r.filter(c=>!o.some(d=>gt(d,c.range))),a=i.filter(c=>c.overrideBuiltins||!s.some(d=>gt(c.range,d.range)));return[...s,...a].sort((c,d)=>c.range.start-d.range.start||c.range.end-d.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=Ln(e,this._unescapes,t),r=ho(e,this._unescapeMatchers,t,!1),i=r.filter(a=>a.overrideBuiltins).map(a=>a.range),o=n.filter(a=>!i.some(c=>gt(c,a.range))),s=r.filter(a=>a.overrideBuiltins||!o.some(c=>gt(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=>sv(i)==="html-comment";return this._collectRevertMappings(e,t).filter(i=>i.isVariable||!r(i.syntax))}getDetectedMappings(e,t,n){return Ln(e,this._escapes,t,n,!0)}getEscapedText(e,t){return Xt(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return Xt(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=Xt(i,this._collectRevertMappings(i).filter(o=>n(o.syntax)==="bare"))),r.includes("html-comment")&&(i=Xt(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()}};function go(e){return e.replace("<script","<___script").replace("<\/script>","</___script>")}var vo=new cv(e=>{e.escape("<script","<\/script>",t=>go(t)).unescape("<___script","</___script>",t=>t.replace("<___script","<script").replace("</___script>","<\/script>")),e.escape("<script","/>",t=>go(t)).unescape("<___script","/>",t=>t.replace("<___script","<script")),Va(e)});function dv(e){const t=av(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return ea();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=>vo.normalizeToPolicy(i,t.editor),toOutputForm:i=>vo.normalizeToPolicy(i,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:Zs(r)}}function uv(e){let t;e.injectFactory(Cr,()=>{const n=e.getInstance(oe)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:dv(n)}),t.policy})}var fv=[{name:"rest.client",setup:$h},{name:"auth.oauth",setup:rc},{name:"rest.identityHeaders",setup:Fh},{name:"lifetime.destroyable",provides:[ni],setup:jm},{name:"appInit",provides:[xe,Nr],setup:Nc},{name:"config",provides:[oe],setup:Nm},{name:"templateDirectives",provides:[Cr],setup:uv},{name:"email.documents",setup:rh},{name:"show.initPipeline",provides:[Ae],setup:Gh},{name:"show",setup:Gg},{name:"locale.service",provides:[Tt],setup:Mh},{name:"locale.fromConfig",awaits:{services:[oe,Tt]},setup:kh},{name:"canvas.early",setup:xp},{name:"canvas.previewSettings",setup:$p},{name:"canvas.sandboxExtensions",setup:Vp},{name:"canvas.sandboxScriptRelay",setup:Wp},{name:"canvas.headerSync",provides:[da],setup:Lp},{name:"canvas.ampSync",setup:$u},{name:"canvas.moduleBridge",setup:yf},{name:"canvas.port",setup:Qu},{name:"canvas.images",setup:Xu},{name:"canvas.edits",setup:Xf},{name:"canvas.blockContent",setup:Vf},{name:"canvas.sandboxFill",provides:[ei],setup:mm},{name:"canvas.reactions",setup:Op}],pv=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function mv(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 hv(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 Wa(e){const t=mv(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 pv([...i.slice(c),a].map(d=>d.name))}o.add(a),i.push(a);for(const c of hv(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 bo;function li(e){const t=e.getInstance(se);if(t)return t;e.getInstance(U)||e.inject(U,new ie);const n=Ee();e.inject(se,n),bo??=Wa(fv);for(const r of bo)r.setup(e);return n}function gv(e){}var vv=[{name:"save.previewFollow",setup:gv}],yo=F("plugin.lateUnitsInstalled");function bv(e){if(!e.getInstance(yo)){e.inject(yo,!0);for(const t of Wa(vv))t.setup(e)}}function yv(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function Ev(e){if(!e)return;const t=Mr(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=ot(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!Ce(t,i.user),a=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(Te)||!i.getAuthToken)&&!(!o&&!s&&!a))try{const c=await i.getAuthToken(i.user,i.project);e.inject(Zl,Promise.resolve(c||""));const d=Ev(c);if(!d)return;e.inject(ql,d);const f=e.getInstance(xe),m=f?await f.catch(()=>{}):void 0;e.inject(xe,Promise.resolve(yv(d,m)))}catch{}}}});function wv(e,t){if(e.getInstance(yi))return;e.inject(yi,!0);const n=ue(e,j.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var Sv=ot(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!Lt(r)){t&&(Im(e),ti(r)),t=void 0;return}const o=gn(r);if(!o||t===o&&e.getInstance(Te))return;t=o,e.inject(Te,o);const s=e.getInstance(U);s&&wv(e,s)}}}),Iv=ot(e=>{const t=e.getInstance(U),n=ue(e,Ko),r=B(n),i=t.addDisposable(new et(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function Ka(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]=Ka(r[o]||{},s,!0):r[o]=s)}return e}async function Cv(e){const t=(await ac(()=>import("./static/esm/2490dab8.js").then(n=>bl(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 Ya=F("EditorOptions"),br=Xl;function Tv(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 Av(e){return e.getOrCreateInstance(Ya,()=>{const t=Ee(br);let n=br.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(Cv(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function Rv(e){return e?.getInstance(Ya)?.get()??br}function Pv(e,t={}){const n=Av(e);n.set(Ka({...n.get()},Tv(t)))}function Dv(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 Ov(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var xv=F("plugin.publicConfig");function yr(e){return e.getInstance(oe)?.get()??{}}function Eo(e){return e.getInstance(oe)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function _o(e){const t=Ea(e),n=yr(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:Ov(Rv(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function wo(e){return e.getInstance(oe)?.get()!==void 0}function Mv(e){const t=zo(),n=fe(e,Yo);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:m=!1}={})=>{await e.getInstance(oe)?.ready(),ts(e).set(yr(e).revisionService===!0);const{codeModeDirection:y,editor:b}=yr(e);b&&Pv(e,Dv(b)),y!==void 0&&!(m&&y===i)&&(i=y,y==="none"?dr(e,!1):(dr(e,!0),wm(e,y)))},c=async()=>{if(!wo(e))return;const m=_o(e),y=JSON.stringify(m);y!==r&&(r=y,await n.fire(m))},d=async m=>{const y=e.getInstance(oe),b={advancedConfigs:Eo(e).advancedConfigs,serverSide:await s(),user:m};y?.setAdvancedConfigs({...b.advancedConfigs,...b.user?.advancedConfigs}),y?.replace(b.user,"user"),y?.replace(b.serverSide,"server"),await a(),await c()},f=m=>{const{commonStyles:y,...b}=m;return"commonStyles"in m&&Hp(e,y===void 0?void 0:y),b};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:s,getConfig:()=>wo(e)?_o(e):{},setConfig:t.decorate(async m=>{await d(f(m))}),updateConfig:t.decorate(async m=>{const y=f(m);await d({...Eo(e).user,...y})}),announceAssembled(){o||(o=!0,e.getInstance(oe)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function Xa(e){return e.getOrCreateInstance(xv,()=>Mv(e))}function kv(e){const t=Xa(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var Lv=ot(e=>{const t=e.getInstance(U),n=t.addDisposable(new Me),r=t.addDisposable(new Me),i=kt(e,Yo),o=B(n.event),s=B(r.event),a=Ba(B(i.event),e),c=t.addDisposable(new et(o)),d=t.addDisposable(new et(s)),f=t.addDisposable(new et(a));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(m){c.setListener(m.handleSetOptions),d.setListener(m.handleOptionsChanged),f.setListener(m.handleConfigChanged),Xa(e).announceAssembled(),await n.fire(m),await r.fire(m)},dispose(){}}}),Nn,Ja="core";function Nv(){const e=window.__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Ja],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Fv(e){const t=window.__emailmaker__?.require?.warm;return typeof t!="function"?Bt().then(()=>{}):t([Ja],e)}function Bt(){return Nn===void 0&&(Nn=Nv().then(e=>(wt()&&e.installDiagnostics().catch(t=>{}),e))),Nn}var Fn=null,jn=null;async function jv(e){typeof e?.prefetch=="function"&&await e.prefetch()}function ci(){return Fn||(Fn=Bt().then(()=>{})),Fn}function Qa(e){return jn||(jn=jv(e)),jn}function Bv(){return Qa(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}function Uv(){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 Hv(e){return Promise.all([ci(),Qa(e)]).then(()=>{})}function $v(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function So(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Fv(t?{priority:t}:void 0)).then(()=>(Jr(t?{priority:t}:void 0),n?ci():void 0)).catch(()=>{})}function Gv(e){const t=$v(e);if(t==="eager")So(e);else if(t==="idle"){const n=()=>So(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var Za="PluginRegistry";function Vv(e=Sl()){return e.getOrCreateInstance(Za,()=>new hc)}var qv=new gc(()=>Vv()),zv=["handleAIImageRequest","handleAITextRequest","handleCloneEmail","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],Wv=["compileEmail","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","save","setConfig","show","updateConfig","useAsync","validateCode","waitPlugin"],dn=new Map([...zv.map(e=>[e,"event"]),...Wv.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),Kv=new Map([["use","use `useAsync()` or await `ready` first"]]);function Yv(e){return Kv.get(e)??"await `ready` first"}var Xv=new Set(["async","queued"]),Jv=Symbol.for("emailmaker.earlyCtxPlaceholder");function Io(e){return e[Jv]=!0,e}function Qv(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 (${Yv(e)}).`)}function Zv(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function eb(e){return[...dn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function tb(e,t){for(const n of eb(e)){const r=dn.get(n);if(r!==void 0&&Xv.has(r)){const i=async(...o)=>{await t;const s=e[n];if(typeof s!="function"||s===i)throw Zv(n);return s.apply(e,o)};e[n]=Io(i);continue}e[n]=Io(()=>{throw Qv(n)})}}function nb(e,t,n){e.getInstanceAsync(tt).then(()=>{kt(e,j.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function rb(e,t){e.getInstanceAsync(tt).then(()=>{kt(e,j.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var ib=ot(e=>{let t;function n(){return new Promise(i=>{const o=e.getOrCreateInstance(Dr,()=>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(mn),s=e.getInstance(Za);if(!t){t=new mc(o,s,{ensureHostRuntimeReady:Bv,explainScriptFailure:Uv,openEarlyWindow:()=>Lg(e),reportLoadFailure:d=>rb(e,d)}),e.inject(xr,t);const c=t.onLifecycle(d=>{d.type==="create:error"&&nb(e,d.name,d.error)});e.getInstance(U)?.addDisposable(c)}const a=i?.plugins||[];o&&(Ls(e),a.length>0&&tb(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}}}),el=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}},ob=F("ELEMENT_INSERT_HTML_PIPELINE"),sb=F("BLOCK_INSERT_HTML_PIPELINE"),ab="application_block_inserted",lb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(sb,()=>new el).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Ot,()=>new xt),i=n?e.bind(n):e;return r.addListener(ab,i,t)}},di=F("ComponentRegistry"),cb=F("ComponentRegistryGate");function ui(){return nt.getOrCreateInstance(cb,()=>({pending:[]}))}function db(e=di){return ui().factory!==void 0||nt.getInstance(e)!==void 0}function Er(e,t,n=di){if(db(n)){t(un(e,n));return}ui().pending.push(()=>t(un(e,n)))}function un(e,t=di){const n=nt.getInstance(t);if(n)return n;const r=ui().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return nt.getOrCreateInstance(t,r)}var ub=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(Ht,{execute:o=>{r(o.value.map(s=>({name:s.name,html:s.html})))}}));const i=this._container.getInstance(jl)?.watch(o=>{o&&r([])});i&&(n?i.dispose():t.push(i))})}update(e,t){const n=this._container;return n.addService(Ht,{execute:r=>{const i=un(n),o=r.value.find(s=>s.name===e);if(o){const{icon:s,title:a,fallbackTooltip:c,...d}=t;s&&(o.icon=i.getReactNode(s)),a&&(o.title=i.getReactNode(a)),c&&(o.fallbackTooltip=i.getReactNode(c)),Object.assign(o,d)}}})}delete(e){this._container.addService(Ht,{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(Ht,{execute:r=>{const i=un(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(ob,()=>new el).add(e,t??0,n)}handleInject(e,t,n){return Ze(this._container,Nl).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},fb=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Ot,()=>new xt)}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 pb(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Co(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 mb=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ze(t,ec),this._closeModalEmitter=Ze(t,Cl),this._updateModalEmitter=Ze(t,Il)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Er(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Co(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Er(this._container,r=>{this._updateModalEmitter.fire(pb({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:Co(r,n)}))})}},hb=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)}},gb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Ot,()=>new xt)}_createScriptHandle(e,t){const n=this._messageService.addListener(Rr,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 hb(t,n);return r}registerSandboxCSS(e){return this._container.addService(Xe,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Xe,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Xe,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Xe,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},vb=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function _r(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&vb.has(t)}function tl(){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 Bn(){return`__settingsPanel:${tl()}`}function Un(e,t){return{type:e,props:t}}function bb(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!_r(e)}function To(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(_r(t)){const r=Bn();return n(e.add(r,t)),Un(r,{})}if(typeof t=="function"){const r=Bn();return n(e.add(r,t)),Un(r,{})}if(bb(t)){const r=t.type;if(typeof r=="string")return t;if(_r(r)||typeof r=="function"){const i=Bn();return n(e.add(i,r)),Un(i,t.props)}return t}return t}var yb=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??tl();Er(this._container,n=>{const r=s=>this._trackRegistration(s),i=To(n,e.content,r),o=e.advancedTabs?.map(s=>({...s,content:To(n,s.content,r)}));Ze(this._container,bi).fire({...e,content:i,advancedTabs:o,instanceKey:t,type:Fl})})}closeSettingsPanel(){this._clearPanelRegistrations(),Ze(this._container,bi).fire(null)}},nl={SandboxScriptApi:gb,ElementsApi:ub,BlocksApi:lb,MessageService:fb,SettingsPanelApi:yb,ModalApi:mb};function Hn(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 he={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}},Eb={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"},$n={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},Ao={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},We={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:he.border,borderRadius:he.borderRadius,textAlign:"center",padding:he.padding},Ro={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:he.padding},Gn={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:he.border,borderRadius:he.borderRadiusCards};function _b(e){return{...Eb,...e}}function wb(e){return{...$n,...e,bold:e?.bold??$n.bold,italic:e?.italic??$n.italic}}function Sb(e){return{...Ao,...e,underline:e?.underline??Ao.underline}}function Ib(e){return{...We,...e,bold:e?.bold??We.bold,italic:e?.italic??We.italic,border:{...We.border,...e?.border},borderRadius:{...We.borderRadius,...e?.borderRadius},padding:{...We.padding,...e?.padding}}}function Cb(e){return{...Ro,...e,padding:{...Ro.padding,...e?.padding}}}function Tb(e){return{...Gn,...e,border:{...Gn.border,...e?.border},borderRadius:{...Gn.borderRadius,...e?.borderRadius}}}function Vn(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 Po(e){let t={...Pr};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function qn(e){return{text:_b(e.text),headings:wb(e.headings),links:Sb(e.links),buttons:Ib(e.buttons),block:Cb(e.block),cards:Tb(e.cards)}}var Do=F("EmailSettingsPort"),Ab=1e4,rl=class{_editor;_layoutSettingsChanged=new Yn;_contentStylesChanged=new Yn;_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(!ja(this._editor.container)||!Je(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(Do);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Vn(this._settings().read())}_getCurrentContentStyles(){const e=Je(this._editor.container)?.current()?.get().attributes.common_styles;return qn(Po(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(Do),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Ot,()=>new xt),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===$.APPLICATION_EMAIL_SETTINGS_SET){const c=Vn(i?.settings),d=this._getLayoutSnapshot(c);d!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=d,this._layoutSettingsChanged.fire(c));return}if(o!==$.APPLICATION_COMMON_STYLES_UPDATE)return;const s=qn(r.data?.settings?.commonStyles??{...Pr}),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=Vn(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Ab){const t=Je(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=ue(r,j.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},d=i(()=>{s||(s=!0,c(),d.dispose(),o())});a=setTimeout(()=>{s||(s=!0,d.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Je(this._editor.container)?.current();if(!t)return;const n=Po(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=Hn(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:he.border,borderRadius:he.borderRadius,padding:he.padding})),e.block!==void 0&&(n.block=Hn(n.block||{},e.block,["padding"],{padding:he.padding})),e.cards!==void 0&&(n.cards=Hn(n.cards||{},e.cards,["border","borderRadius"],{border:he.border,borderRadius:he.borderRadiusCards}));const r=JSON.stringify(n);Ct(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const i=qn(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},Rb={...nl,EmailSettingsApi:rl},Pb={...nl},OE={...Pb,EmailSettingsApi:rl},Db={...Rb};function Ob(){qv.addAll(Db)}var xb=[ot(()=>{Ob()}),Iv,Lv,Sv,zl,_v,tc];async function Mb(){return(await Bt()).asyncMixins}var kb=ib,Lb=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await Mb()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(mn);Object.assign(o,t.instance||{});for(const s of e.getInstance(Dr)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},Nb=Ql([...xb]);function zn(){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:d}]of n)r.set(s,o(a,c,d))},dispose(){t=!0,i(),n.clear(),e=void 0}}}function Fb(e){const t=zn(),n=zn(),r=zn();return e.getInstance(U)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(tt).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(tt);if(o){o.notify(i);return}e.getInstanceAsync(tt).then(s=>s.notify(i),()=>{})}}}var il=F("CodeErrors"),jb=[];function Bb(e){return e?.getInstance(il)?.get()??jb}function Ub(e){return e?.getInstance(il)!==void 0}var Hb=class extends ie{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=jt(e),this.addDisposable(ue(e,j.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){return ka(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=>mt(t,this._container))}async _readProjectBlocks(){const e=await Zh(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>ht(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>hr(n,this._container))}async getEmailSnapshot(){return de(this.openEmail(),this._container)}setEmailMeta(e){const t=si(this._container);if(!t)return;const n=t.get().attributes.meta;Ct(t,{meta:On({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,i=>i&&On(i,e))}setBlockMeta(e,t){const n=async()=>{await this._readProjectBlocks();const{cache:r}=this._dataSources.blocks;await r.getIfPresent(e)&&await r.addOrUpdate(e,i=>i&&On(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(n).catch(()=>{})}getCodeErrors(){return Ub(this._container)?Bb(this._container):void 0}},$b=F("EmailDataController");function Gb(e){return e.getOrCreateInstance($b,()=>{const t=new Hb(e);return e.getInstance(U)?.addDisposable(t),t})}function Vb(e){const t=Gb(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),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 qb(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 zb(e){let t;const n=wa(e),r=ue(e,j.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:o})=>{t=o}));const i=()=>t?qb(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 Wb=F("plugin.mountElement");function Kb(e){const t=e.getInstance(se)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function Yb(e){return e.getOrCreateInstance(Wb,()=>{let t=!1,n;return{get:()=>t?n:Kb(e),set(r){t=!0,n=r}}})}function Xb(e){const t=Yb(e);return{getElement:()=>t.get()}}function Jb(e){return{handleLoadImage:B(ue(e,j.UPLOAD_EVENT_ID)),handleFileProxy:B(ue(e,j.FILE_PROXY_EVENT_ID)),handleUrlProxy:B(ue(e,j.PROXY_URL_EVENT_ID)),handleAITextRequest:B(ue(e,j.AI_TEXT_REQUEST_ID)),handleAIImageRequest:B(ue(e,j.AI_IMAGE_REQUEST_ID)),handleReadLocale:B(ue(e,j.READ_LOCALE)),handleLimitUsage:B(ue(e,j.ON_LIMIT_ID)),handleTranslate:B(ue(e,j.ON_TRANSLATE_ID))}}var Qb=[Bm,Vg,Fb,kv,Vb,zb,Xb,Jb];function Zb(e,t=Qb){const n=li(e);bv(e);const r=Nb(e),i=kb(e),o=Lb(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 d=a&&n.get()===c;a=!1,d||n.set(c),await i.setOptions(c),await o.setOptions(c)}}}function ey(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 ty=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]}},ny="editor-runtime.react.copies",Wn=8;function At(e){return e&&typeof e=="object"?e:void 0}function Oo(e){const t=At(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=At(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function ry(e){const t=At(e),n=t&&typeof t.version=="string"?t.version:void 0,r=At(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function iy(e,t,n){return e.package===t&&e.version===n}function oy({ourReact:e,entries:t,packageName:n,version:r}){const i=Oo(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const a of t){const c=At(a);if(!c||!iy(c,n,r))continue;const d=Oo(c.react);!d||d===i||s.has(d)||(s.add(d),o.push({package:n,version:r,reactVersion:ry(c.react),react:c.react}))}return o}function sy({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,Wn))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Wn&&n.push(` …and ${t.length-Wn} 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 xo=new Set;function
|
|
1047
|
+
`)}function so(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function ig(e,t,n,r){const i=og(e,t,n,r);return i===void 0}function og(e,t,n,r){const{email:i}=vn(t,!1),o=it(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=Kr(e)?.current();if(!a)return"no-session";const c=a.get(),d=c.attributes;if(c.serverId!==s)return"document-id";if(d.is_inited!==!0)return"not-inited";const f=so(pr(n??a.getContent()));if(o.html!==void 0&&so(pr(o.html))!==f)return"html";if(o.subject!==void 0&&o.subject!==d.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==d.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==d.common_styles)return"common_styles"}function ao(e,t){const{email:n}=vn(t,!1),r=it(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:pr(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function sg(e,t){const n={...e};return delete n.id,{...n,...t}}function ag(e){return e.html?e:{...e,html:Ma}}function pt({code:e,project:t,...n},r,i){const o=i??ri(r);return{...n,...e?{html:ze(r).toEditorForm(e)}:{},renderGuid:Ie(),...o===void 0?{}:{project:o}}}function mt({html:e,renderGuid:t,...n},r){const{requested:i}=Ft(r);return ke({...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 Na(e){return Kr(e)?.current()?.get().serverId??void 0}function mr(e,t,n){return n===void 0&&(n=e.post===void 0?Na(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function ht(e,t){return ke({...e,link:void 0,comment_status:void 0})}function tn({code:e,autosave:t,...n},r,i){return i===void 0&&(i=n.parent===void 0?Na(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||Md(n.slug),parent:i}}function hr({html:e,isAutosave:t,...n},r){return ke({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:ke({html:e,ampHtml:e&&""})})}var tt=F("NotificationService"),lg=F("emailTemplate.reads");async function cg(e,t){try{return await Ve(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,ug(e,t,n);return}}var dg=F("emailTemplate.notifiedFailures");function ug(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(dg,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(tt).then(()=>{kt(e,j.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function fg(e,t){const n=e.getOrCreateInstance(lg,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=cg(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var pg="EXTERNAL",lo=Symbol("supersededShow");function mg(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var hg="email_id",gg=class extends ie{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=zo();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=jt(t),this._eventLock=eg(t);const n=ee(e,j.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(Ar,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(hg,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Re)??Zr}_throwIfDestroyed(){if(this.isDisposed())throw Oe()}async getTemplateEmail(e){const t=await fg(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await en(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,pt(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,tn(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,mr(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 en(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let d=it(e,this._container);const f=d.id;let m=f;if(f!==void 0){const y=await o.get(f);d={...y??{},...d,utm_parameters:d.utm_parameters??y?.utm_parameters??{},renderGuid:y?.renderGuid??Ie(),...c>0?{showToken:c}:{},...i?{showId:i}:{},project:a}}else{m=n??Ie();const y=await o.get(m);d={...d,utm_parameters:d.utm_parameters??{},renderGuid:y?.renderGuid??Ie(),...c>0?{showToken:c}:{},...i?{showId:i}:{},project:a},delete d.project}if(t){const y=await this.getTemplateEmail(String(t));y&&(d=sg(y,d))}return f===void 0&&(d=ag(d)),await s.setAll([[m,d]]),d}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==ao(this._container,e))return!1;const n=Zt(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=ao(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Zt(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&ng({ticket:t,emailId:oo(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,lo;if(!e)return;const n=this._getInitPipeline();Y(n.signal);const r=rg(e);if(!r&&ig(this._container,e,Zt(this._container),this._prevCommand?.id)||!r&&this._isRepeatOfLastShow(e))return;const i=vn(e);i.email.id,this._prevCommand?.id;let o,s="",a=0,c=!1,d,f=Promise.resolve(),m,y=!1;try{this._eventLock.suspendChange();const{email:b,blocks:T,autosaves:w,comments:g,templateId:C,reload:_}=i;o=b.id;const P=it(b,this._container),S=P.id,M=S??Ie(),v=await bt("getProject",en(this._container));Y(n.signal),s=Ie();const E={isNew:S===void 0,id:String(M),project:v},A=_===!0&&S!==void 0;A&&(await this._dataSources.emails.remove(String(S),{silent:!0}),String(S)),a=++this._showToken,String(M);const h=[];h.push(this.setBlocks(T)),b.id!==void 0&&(h.push(this.setComments(g)),h.push(this.setEmailRevisions(w,String(b.id)))),h.push(this.setEmail(b,Number(C),S===void 0?String(M):void 0,a,s)),await bt("setEmail+blocks+revisions",Promise.all(h),{emailId:S??String(M),showId:s,targetShowToken:a}),Y(n.signal);const l=await this._dataSources.emails.get(String(M)),u=Le(this._container),p={id:s,token:a};S===void 0?m=u.startNewDraft(l??P,{patch:P,show:p}):A?m=u.reload(S,{email:l??P,patch:P,show:p}):u.sessionKey()===Ke(S)?m=u.show(P,p):m=u.open(S,{email:l??P,patch:P,show:p});const R=!!this._prevCommand&&Te(this._prevCommand,E);E.id,!this._prevCommand||Te(this._prevCommand,E),this._prevCommand?.id,this._rememberShow(E),f=n.requestShow({showId:s,navId:String(M),emailId:S,isNew:S===void 0}),y=!0,String(M),c=!0}catch(b){d=b,y&&s&&n.failShow(s,b),Or(b)||(ds(b),void 0)}finally{this._eventLock.resumeChange()}if(!c)throw d instanceof Error?d:new Error(`[emailmaker] show() setup failed: ${String(d??"unknown error")}`);return bt("show-init-deferred",Promise.all([f,m?.whenReady().catch(b=>{if(b instanceof It){const T=zr(b);throw T?new Error(`[emailmaker] show(): email open failed (${T})`,{cause:b}):b}})??Promise.resolve()]).then(()=>{}),{showId:s,emailId:o??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();Y(e.signal);const t=Le(this._container),n=await t.save("publish",{source:pg,fallbackTitle:Hs(this._container)});if(Y(e.signal),!n)throw mg(t.saveState().error);return ue(La(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=oo(e);const n=this._queuedShow(e,t).then(r=>r===lo?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};save=this._queue.decorate(this._save,this)};function vg(e){return String(e).replace(/"/g,""")}function bg(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 yg(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 co(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=vg(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function Eg(e,t,n){if(!e?.trim()||!t)return e;const r=yg(e);if(!r)return e;const i=String(t),o=bg(n??new Date);let{full:s,index:a}=r;const c=s.length;return/\bem-block-id\s*=/.test(s)||(s=co(s,"em-block-id",i)),s=co(s,"em-block-version",o),e.slice(0,a)+s+e.slice(a+c)}function _g(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 wg(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:_g(e)}}function Mn(e,t){return t?wg(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Fa=["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"],Sg=[...Fa,"html","id","project","password"],xE=new Set(["html",...Fa,"global_block","project"]);function Ig(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(Sg),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 Cg(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Ig(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 gr=new WeakMap;function Tg(e){let t=gr.get(e);return t||(t={byId:new Map,fallback:[]},gr.set(e,t)),t}function Ag(e){gr.delete(e)}function Rg(e,t){const{byId:n,fallback:r}=Tg(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 Pg(e,t){const{blocks:n}=jt(e);return await n.cache.getIfPresent(t)??void 0}async function Dg(e,t){if(!t.blockId)return;const n=await Pg(e,t.blockId);if(n)return Cg(n,t)}async function Og(e,t){const n=Rg(e,t);if(n)return Mn(e,n);const r=await Dg(t,e);return r?Mn(e,r):Mn(e,void 0)}var xg=Wo("application_block_inserted"),Mg=-1e3,uo=new WeakSet;function kg(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 Lg(e){if(!e||uo.has(e))return;uo.add(e);const t=new ie,n=ae(e);return t.addDisposable(n.addListenerAsyncPipe(xg,async(r,i)=>{const o=kg(r)?await Og(r,e):r;return i?i(o):o},Mg)),t.addDisposable({dispose:()=>{Ag(e)}}),t}var ja=F("plugin.earlyWindow");function Ng(e){return e.getOrCreateInstance(ja,()=>({depth:0}))}function Fg(e){const t=Ng(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function Ba(e){return(e?.getInstance(ja)?.depth??0)>0}function Ua(e,t){let n,r=!1;return e(i=>{n=i,r=!0}),(i,o,s)=>{const a=e(i,o,s);if(r&&Ba(t)){const c=n;queueMicrotask(()=>{i.call(s,c)})}return a}}var fo=100,jg=class extends ie{_container;_events;constructor(e){super(),this._container=e;const t=Lg(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=jt(e),o=ee(e,j.ON_SHARE_ID),s=ee(e,j.ON_SHOW_PREVIEW_ID),a=ee(e,j.ON_EMAIL_CLONE_ID),c=ee(e,j.ON_CODE_VALIDATE_ID),d=ee(e,j.ON_SUBJECT_CHANGED_ID),f=ee(e,j.ON_EMAIL_CHANGED_ID),m=ee(e,j.ON_PREHEADER_CHANGED_ID),y=ee(e,j.ON_SAVEBUTTON_CLICK_ID),b=ee(e,j.ON_NEXTBUTTON_CLICK_ID),T=ee(e,j.ON_SEND_LIVEPREVIEW_ID),w=ee(e,j.ON_SEND_TESTEMAIL_ID),g=ee(e,Xh),C=ee(e,j.ON_CONTENT_CHANGED_ID),_=ee(e,Yh),P=ee(e,j.ON_PREVIOUSBUTTON_CLICK_ID),S=ee(e,j.ON_SEND_EMAIL_MODAL_ID),M=wl(ee(e,j.ON_EMAIL_INIT_ID),v=>!v.reset);return{handlePreheaderChanged:B(m),handleSubjectChanged:B(d),handleValidate:B(c),handleReadEmail:B(n.handlerRead,v=>v,v=>v&&it(v,e)),handleSaveEmail:B(n.onSave,function({prev:v,patch:E,value:A,source:h}){const l=v?ue(v,e):void 0;return{prev:l,patch:Et(l,ue(E,e)),value:ue(A,e),source:h}},v=>v?it(v,e):void 0),handleRemoveEmail:B(n.onRemove,({value:v,source:E})=>({value:ue(v,e),source:E}),()=>{}),handleReadCommonBlocks:B(g,v=>v.project,v=>v?.map(E=>pt(E,e))),handleReadTemplateBlocks:B(_,v=>v,v=>v?.map(E=>pt(E,e))),handleReadBlocks:B(t.byForeignKey("project").handleRead,v=>Ft(e).requested||String(v),v=>v?.map(E=>pt(E,e))),handleSaveBlock:B(t.onSave,function({prev:v,patch:E,value:A,source:h}){const l=A.global_block===!0&&A.id&&typeof A.html=="string"?{...A,html:Eg(A.html,String(A.id))}:A,u=v?mt(v,e):void 0;return{prev:u,patch:Et(u,mt(E,e)),value:mt(l,e),source:h}},v=>v?pt(v,e):void 0),handleRemoveBlock:B(t.onRemove,({value:v,source:E})=>({value:mt(v,e),source:E}),()=>{}),handleReadComments:B(r.byForeignKey("post").handleRead,v=>v,v=>v?.map(E=>mr(E,e))),handleSaveComment:B(r.onSave,function({prev:v,patch:E,value:A,source:h}){const l=v?ht(v,e):void 0;return{prev:l,patch:Et(l,ht(E,e)),value:ht(A,e),source:h}},v=>v?mr(v,e):void 0),handleRemoveComment:B(r.onRemove,({value:v,source:E})=>({value:ht(v,e),source:E}),()=>{}),handleReadEmailRevisions:B(i.byForeignKey("parent").handleRead,v=>v,v=>v?.map(E=>tn(E,e))),handleReadEmailAutosave:B(ee(e,Ta),v=>v,v=>v?tn(v,e):null),handleEmailAutosave:B(i.onSave,function({prev:v,patch:E,value:A,source:h}){return{value:hr(A,e),source:h}},v=>v?tn(v,e):void 0),handleRemoveEmailAutoSave:B(i.onRemove,({value:v,source:E})=>({value:hr(v,e),source:E}),()=>{}),handleEmailChanged:B(vi(f,fo),v=>ue(v,e)),handleEmailInit:Ua(B(M,v=>ue(v,e)),e),handlePreviousButtonClick:B(P,v=>ue(v,e)),handleNextButtonClick:B(b,v=>ue(v,e)),handleSaveButtonClick:B(y,v=>ue(v,e)),handleHtmlChanged:B(vi(C,fo)),handleTestEmailSend:B(w,({html:v,...E})=>({...E,code:v,compiled:{html:v,ampHtml:""}})),handleTestEmailModal:B(S,v=>ue(v,e)),handleCloneEmail:B(a,v=>ue(v,e)),handleShareEmail:B(o),handlePreviewEmail:B(s),handleLivePreviewEmail:B(T)}}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 et(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Bg=F("DataController"),Ug=F("DataEvents");function Ha(e){return e.getOrCreateInstance(Bg,()=>{const t=new gg(e);return e.getInstance(U)?.addDisposable(t),t})}function $a(e){return e.getOrCreateInstance(Ug,()=>new jg(e))}var Hg=F("plugin.pluginStart");function Ga(e){return e.getOrCreateInstance(Hg,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(U)?.addDispose(()=>t()),{done:n,finish:t}})}function $g(e){return Ga(e).done}function Gg(e){const t=Ga(e);return t.run===void 0&&(t.run=(e.getInstance(xr)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var Vg=F("plugin.startupShow");function qg(e){const t=Ha(e),n=$a(e),r=e.getInstance(se),i=e.getInstance(U),o={current:Promise.resolve()};e.inject(Vg,o);let s=!1;const a=r?.watch(d=>{d&&n.setOptions(d),s=(d?.plugins?.length??0)>0,o.current=o.current.catch(()=>{})}),c=r?.select(d=>d?.content).watch(d=>{if(d===void 0)return;const f=()=>(J(le.showStart),t.show(d).finally(()=>J(le.showEnd))),m=s?$g(e).then(f):f();m.catch(()=>{}),o.current=m});a&&i?.addDisposable(a),c&&i?.addDisposable(c)}function zg(e){const t=Ha(e);return{...$a(e).get(),show(n){return J(le.showStart),t.show(n).finally(()=>J(le.showEnd))},save(){return t.save()}}}function Va(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function bn(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 Wg(e){return(t,n,r)=>bn(t)?e(t,n,r):!1}function Kg(e){return t=>bn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Yg(e){return(t,n,r)=>bn(t)?Va(t)?e(t,n,r):t:!1}function Xg(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return bn(n)?Va(n)?e(t):t:!1}}function Jg(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function ai(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 Qg(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 Zg=8,ev=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=Qg(Zg),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},yn=new ev;function po(e,t){return t!==void 0&&!ai(e,t)?`%|{${yn.getOrCreateByKey(e)}}|%`:e}function tv(e){const t=yn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function X(e,t,n){return t!==void 0?ai(e,t)?e:`%|{${yn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function nv(e){return e.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function K(e){return e.startsWith("<!--")&&e.endsWith("-->")?nv(e.slice(4,-3)):e}function rv(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 iv(e,t,n){return t!==void 0?ai(e,t)?e:`%|{${yn.getOrCreateByKey(e)}}|%`:n||Jg(e)||rv(e)?`<!--${e}-->`:e}var He=Wg(X),$e=Kg(K),ov=Yg(X),sv=Xg(K),qa=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",tv),e.escape("@{","}",X,!0).unescape("<!--@{","}-->",K,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",po,!0),e.escape("{{","}}",po,!0),e.createSyntax("brace-percent").escape("{%","%}",X).unescape("<!--{%","%}-->",K),e.createSyntax("brace-hash").escape("{#","#}",X).unescape("<!--{#","#}-->",K),e.createSyntax("proscript").escape("[%","%]",iv,!0).unescape("<!--[%","%]-->",K,!0),e.createSyntax("getresponse").escape("[[IF","]]",X).escape("[[if","]]",X).escape("[[ELSE]]","",X).escape("[[else]]","",X).escape("[[ENDIF]]","",X).escape("[[endif]]","",X).unescape("<!--[[IF","]]-->",K).unescape("<!--[[if","]]-->",K).unescape("<!--[[ELSE]]","-->",K).unescape("<!--[[else]]","-->",K).unescape("<!--[[ENDIF]]","-->",K).unescape("<!--[[endif]]","-->",K),e.createSyntax("expert-sender").escape("<if",">",X).escape("</if",">",X).escape("<else",">",X).escape("</else",">",X).escape("<var ",">",X,!0).unescape("<!--<if ",">-->",K).unescape("<!--</if",">-->",K).unescape("<!--<else ",">-->",K).unescape("<!--</else",">-->",K).unescape("<!--<var",">-->",K,!0),e.createSyntax("velocity").escape("#if",")",He).escape("#elseif",")",He).escape("#else","",X).escape("#foreach",")",He).escape("#macro",")",He).escape("#set",")",ov,!0).escape("#parse",")",He).escape("#include",")",He).escape("#evaluate",")",He).escape("#end","",X).escape("#break","",X).escape("#stop","",X).unescape("<!--#macro","-->",$e).unescape("<!--#if","-->",$e).unescape("<!--#elseif","-->",$e).unescape("<!--#else","-->",K).unescape("<!--#foreach","-->",$e).unescape("<!--#parse","-->",$e).unescape("<!--#include","-->",$e).unescape("<!--#evaluate","-->",$e).unescape("<!--#end","-->",K).unescape("<!--#break","-->",K).unescape("<!--#stop","-->",K).unescape("<!--#set","-->",sv,!0),e.createSyntax("mailchimp").escape("*|","|*",X).unescape("<!--*|","|*-->",K)},vr="bare",av=new Map;function lv(e){return e?av.get(e)??vr:vr}var za=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function mo(e){return za.includes(e)}function lt(e){return e==="bare"||e==="html-comment"}function kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function cv(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!lt(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[d,f]of[["output",r.output],["editor",r.editor]])if(f!==void 0&&!lt(f))return t(`templateDirectives.${d}: unknown form "${String(f)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!kn(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[d,f]of Object.entries(r.syntaxes))if(!(!mo(d)||f===void 0||lt(f))){if(!kn(f))return t(`templateDirectives.syntaxes.${d}: expected a form or an object, configuration ignored.`),n;for(const m of["output","editor"]){const y=f[m];if(y!==void 0&&!lt(y))return t(`templateDirectives.syntaxes.${d}.${m}: unknown form "${String(y)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const i=r.output??vr;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 d of Object.keys(r.syntaxes)){if(!mo(d)){t(`templateDirectives.syntaxes: unknown syntax id "${d}", entry ignored.`);continue}s.push(d)}else s.push(...za);const a={},c={};for(const d of s){const f=r.syntaxes?.[d],m=kn(f)?f:void 0,y=(lt(f)?f:m?.output)??i;let b=m?.editor??o??y;y==="bare"&&b==="html-comment"&&(t(`templateDirectives.syntaxes.${d}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),b="bare"),a[d]=y,c[d]=b}return{output:a,editor:c}}function Wa(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 gt(e,t){return e.start<t.end&&t.start<e.end}function ho(e,t,n,r,i=[]){if(n&&(t=t.filter(f=>f.isVariable)),!t.length)return[];const o=t.flatMap(f=>f.match(e).flatMap(m=>!Number.isInteger(m.start)||!Number.isInteger(m.end)||m.start<0||m.end>e.length||m.start>=m.end?[]:[{range:m,mapFn:f.mapFn,overrideBuiltins:f.overrideBuiltins,syntax:f.syntax,isVariable:f.isVariable}])).sort((f,m)=>f.range.start-m.range.start||f.range.end-m.range.end),s=[],a=i.slice().sort((f,m)=>f.start-m.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let d=0;for(const{range:f,mapFn:m,overrideBuiltins:y,syntax:b,isVariable:T}of o){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):Wa(e,d,f.start,c),d=f.end,a.some(_=>gt(_,f)))continue;const w=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,g=e.substring(f.start,f.end),C=m(g,w,c.insideTag);C!==!1&&C!==g&&(s.push({range:f,text:C,overrideBuiltins:y,syntax:b,isVariable:T}),a.push(f))}return s.sort((f,m)=>f.range.start-m.range.start||f.range.end-m.range.end)}function dv(e,t){const n=t.reduce((a,{mapFn:c,start:d,end:f,syntax:m,isVariable:y})=>(a[d]||(a[d]=[]),a[d].push({value:f,mapFn:c,syntax:m,isVariable:y}),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 Ln(e,t,n,r,i=!1){const o=[];if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return o;const s=dv(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let d=0;d<s.length;d++){const{start:f,startToken:m,endTokens:y}=s[d];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):Wa(e,c,f,a),c=f;const b=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let T=!1;for(const{mapFn:w,value:g,syntax:C,isVariable:_}of y){let P=f+m.length,S=e.indexOf(g,P);for(;S!==-1;){let M=S,v=f+m.length,E=0;for(;M!==-1;){const p=e.indexOf(m,v);if(p!==-1&&p<M)E++,v=p+m.length,M=e.indexOf(g,v);else if(E>0)E--,v=M+g.length,M=e.indexOf(g,v);else break}if(M<0)break;const A=M+g.length,h=e.substring(f,A),l=w(h,b,a.insideTag);if(l===!1){P=S+Math.max(g.length,1),S=e.indexOf(g,P);continue}(i||l!==h)&&o.push({range:{start:f,end:A},text:i?h:l,syntax:C,isVariable:_});const u=s.findIndex(({start:p})=>p>=A);u>d?d=u-1:d=s.length,T=!0;break}if(T)break}}return o}function Xt(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 uv=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=qa){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=Ln(e,this._escapes,t,n),i=ho(e,this._escapeMatchers,t,n),o=i.filter(c=>c.overrideBuiltins).map(c=>c.range),s=r.filter(c=>!o.some(d=>gt(d,c.range))),a=i.filter(c=>c.overrideBuiltins||!s.some(d=>gt(c.range,d.range)));return[...s,...a].sort((c,d)=>c.range.start-d.range.start||c.range.end-d.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=Ln(e,this._unescapes,t),r=ho(e,this._unescapeMatchers,t,!1),i=r.filter(a=>a.overrideBuiltins).map(a=>a.range),o=n.filter(a=>!i.some(c=>gt(c,a.range))),s=r.filter(a=>a.overrideBuiltins||!o.some(c=>gt(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=>lv(i)==="html-comment";return this._collectRevertMappings(e,t).filter(i=>i.isVariable||!r(i.syntax))}getDetectedMappings(e,t,n){return Ln(e,this._escapes,t,n,!0)}getEscapedText(e,t){return Xt(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return Xt(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=Xt(i,this._collectRevertMappings(i).filter(o=>n(o.syntax)==="bare"))),r.includes("html-comment")&&(i=Xt(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()}};function go(e){return e.replace("<script","<___script").replace("<\/script>","</___script>")}var vo=new uv(e=>{e.escape("<script","<\/script>",t=>go(t)).unescape("<___script","</___script>",t=>t.replace("<___script","<script").replace("</___script>","<\/script>")),e.escape("<script","/>",t=>go(t)).unescape("<___script","/>",t=>t.replace("<___script","<script")),qa(e)});function fv(e){const t=cv(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return ea();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=>vo.normalizeToPolicy(i,t.editor),toOutputForm:i=>vo.normalizeToPolicy(i,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:Zs(r)}}function pv(e){let t;e.injectFactory(Cr,()=>{const n=e.getInstance(oe)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:fv(n)}),t.policy})}var mv=[{name:"rest.client",setup:Vh},{name:"auth.oauth",setup:ic},{name:"rest.identityHeaders",setup:Bh},{name:"lifetime.destroyable",provides:[ni],setup:Um},{name:"appInit",provides:[xe,Nr],setup:Fc},{name:"config",provides:[oe],setup:jm},{name:"templateDirectives",provides:[Cr],setup:pv},{name:"email.documents",setup:oh},{name:"show.initPipeline",provides:[Re],setup:qh},{name:"show",setup:qg},{name:"locale.service",provides:[Tt],setup:Lh},{name:"locale.fromConfig",awaits:{services:[oe,Tt]},setup:Nh},{name:"canvas.early",setup:kp},{name:"canvas.previewSettings",setup:Vp},{name:"canvas.sandboxExtensions",setup:zp},{name:"canvas.sandboxScriptRelay",setup:Yp},{name:"canvas.headerSync",provides:[ua],setup:Fp},{name:"canvas.ampSync",setup:Gu},{name:"canvas.moduleBridge",setup:_f},{name:"canvas.port",setup:Zu},{name:"canvas.images",setup:Ju},{name:"canvas.edits",setup:Qf},{name:"canvas.blockContent",setup:zf},{name:"canvas.sandboxFill",provides:[ei],setup:gm},{name:"canvas.reactions",setup:Mp}],hv=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function gv(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 vv(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 Ka(e){const t=gv(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 hv([...i.slice(c),a].map(d=>d.name))}o.add(a),i.push(a);for(const c of vv(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 bo;function li(e){const t=e.getInstance(se);if(t)return t;e.getInstance(U)||e.inject(U,new ie);const n=_e();e.inject(se,n),bo??=Ka(mv);for(const r of bo)r.setup(e);return n}function bv(e){}var yv=[{name:"save.previewFollow",setup:bv}],yo=F("plugin.lateUnitsInstalled");function Ev(e){if(!e.getInstance(yo)){e.inject(yo,!0);for(const t of Ka(yv))t.setup(e)}}function _v(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function wv(e){if(!e)return;const t=Mr(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 Sv=ot(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!Te(t,i.user),a=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(Ae)||!i.getAuthToken)&&!(!o&&!s&&!a))try{const c=await i.getAuthToken(i.user,i.project);e.inject(ec,Promise.resolve(c||""));const d=wv(c);if(!d)return;e.inject(zl,d);const f=e.getInstance(xe),m=f?await f.catch(()=>{}):void 0;e.inject(xe,Promise.resolve(_v(d,m)))}catch{}}}});function Iv(e,t){if(e.getInstance(yi))return;e.inject(yi,!0);const n=fe(e,j.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var Cv=ot(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!Lt(r)){t&&(Tm(e),ti(r)),t=void 0;return}const o=gn(r);if(!o||t===o&&e.getInstance(Ae))return;t=o,e.inject(Ae,o);const s=e.getInstance(U);s&&Iv(e,s)}}}),Tv=ot(e=>{const t=e.getInstance(U),n=fe(e,Ko),r=B(n),i=t.addDisposable(new et(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function Ya(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]=Ya(r[o]||{},s,!0):r[o]=s)}return e}async function Av(e){const t=(await lc(()=>import("./static/esm/2490dab8.js").then(n=>yl(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 Xa=F("EditorOptions"),br=Jl;function Rv(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 Pv(e){return e.getOrCreateInstance(Xa,()=>{const t=_e(br);let n=br.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(Av(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function Dv(e){return e?.getInstance(Xa)?.get()??br}function Ov(e,t={}){const n=Pv(e);n.set(Ya({...n.get()},Rv(t)))}function xv(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 Mv(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var kv=F("plugin.publicConfig");function yr(e){return e.getInstance(oe)?.get()??{}}function Eo(e){return e.getInstance(oe)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function _o(e){const t=_a(e),n=yr(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:Mv(Dv(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function wo(e){return e.getInstance(oe)?.get()!==void 0}function Lv(e){const t=zo(),n=pe(e,Yo);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:m=!1}={})=>{await e.getInstance(oe)?.ready(),ts(e).set(yr(e).revisionService===!0);const{codeModeDirection:y,editor:b}=yr(e);b&&Ov(e,xv(b)),y!==void 0&&!(m&&y===i)&&(i=y,y==="none"?dr(e,!1):(dr(e,!0),Im(e,y)))},c=async()=>{if(!wo(e))return;const m=_o(e),y=JSON.stringify(m);y!==r&&(r=y,await n.fire(m))},d=async m=>{const y=e.getInstance(oe),b={advancedConfigs:Eo(e).advancedConfigs,serverSide:await s(),user:m};y?.setAdvancedConfigs({...b.advancedConfigs,...b.user?.advancedConfigs}),y?.replace(b.user,"user"),y?.replace(b.serverSide,"server"),await a(),await c()},f=m=>{const{commonStyles:y,...b}=m;return"commonStyles"in m&&Gp(e,y===void 0?void 0:y),b};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:s,getConfig:()=>wo(e)?_o(e):{},setConfig:t.decorate(async m=>{await d(f(m))}),updateConfig:t.decorate(async m=>{const y=f(m);await d({...Eo(e).user,...y})}),announceAssembled(){o||(o=!0,e.getInstance(oe)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function Ja(e){return e.getOrCreateInstance(kv,()=>Lv(e))}function Nv(e){const t=Ja(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var Fv=ot(e=>{const t=e.getInstance(U),n=t.addDisposable(new Me),r=t.addDisposable(new Me),i=kt(e,Yo),o=B(n.event),s=B(r.event),a=Ua(B(i.event),e),c=t.addDisposable(new et(o)),d=t.addDisposable(new et(s)),f=t.addDisposable(new et(a));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(m){c.setListener(m.handleSetOptions),d.setListener(m.handleOptionsChanged),f.setListener(m.handleConfigChanged),Ja(e).announceAssembled(),await n.fire(m),await r.fire(m)},dispose(){}}}),Nn,Qa="core";function jv(){const e=window.__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Qa],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Bv(e){const t=window.__emailmaker__?.require?.warm;return typeof t!="function"?Bt().then(()=>{}):t([Qa],e)}function Bt(){return Nn===void 0&&(Nn=jv().then(e=>(wt()&&e.installDiagnostics().catch(t=>{}),e))),Nn}var Fn=null,jn=null;async function Uv(e){typeof e?.prefetch=="function"&&await e.prefetch()}function ci(){return Fn||(Fn=Bt().then(()=>{})),Fn}function Za(e){return jn||(jn=Uv(e)),jn}function Hv(){return Za(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}function $v(){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 Gv(e){return Promise.all([ci(),Za(e)]).then(()=>{})}function Vv(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function So(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Bv(t?{priority:t}:void 0)).then(()=>(Jr(t?{priority:t}:void 0),n?ci():void 0)).catch(()=>{})}function qv(e){const t=Vv(e);if(t==="eager")So(e);else if(t==="idle"){const n=()=>So(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var el="PluginRegistry";function zv(e=Il()){return e.getOrCreateInstance(el,()=>new gc)}var Wv=new vc(()=>zv()),Kv=["handleAIImageRequest","handleAITextRequest","handleCloneEmail","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],Yv=["compileEmail","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","save","setConfig","show","updateConfig","useAsync","validateCode","waitPlugin"],dn=new Map([...Kv.map(e=>[e,"event"]),...Yv.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),Xv=new Map([["use","use `useAsync()` or await `ready` first"]]);function Jv(e){return Xv.get(e)??"await `ready` first"}var Qv=new Set(["async","queued"]),Zv=Symbol.for("emailmaker.earlyCtxPlaceholder");function Io(e){return e[Zv]=!0,e}function eb(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 (${Jv(e)}).`)}function tb(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function nb(e){return[...dn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function rb(e,t){for(const n of nb(e)){const r=dn.get(n);if(r!==void 0&&Qv.has(r)){const i=async(...o)=>{await t;const s=e[n];if(typeof s!="function"||s===i)throw tb(n);return s.apply(e,o)};e[n]=Io(i);continue}e[n]=Io(()=>{throw eb(n)})}}function ib(e,t,n){e.getInstanceAsync(tt).then(()=>{kt(e,j.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function ob(e,t){e.getInstanceAsync(tt).then(()=>{kt(e,j.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var sb=ot(e=>{let t;function n(){return new Promise(i=>{const o=e.getOrCreateInstance(Dr,()=>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(mn),s=e.getInstance(el);if(!t){t=new hc(o,s,{ensureHostRuntimeReady:Hv,explainScriptFailure:$v,openEarlyWindow:()=>Fg(e),reportLoadFailure:d=>ob(e,d)}),e.inject(xr,t);const c=t.onLifecycle(d=>{d.type==="create:error"&&ib(e,d.name,d.error)});e.getInstance(U)?.addDisposable(c)}const a=i?.plugins||[];o&&(Ls(e),a.length>0&&rb(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}}}),tl=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}},ab=F("ELEMENT_INSERT_HTML_PIPELINE"),lb=F("BLOCK_INSERT_HTML_PIPELINE"),cb="application_block_inserted",db=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(lb,()=>new tl).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Ot,()=>new xt),i=n?e.bind(n):e;return r.addListener(cb,i,t)}},di=F("ComponentRegistry"),ub=F("ComponentRegistryGate");function ui(){return nt.getOrCreateInstance(ub,()=>({pending:[]}))}function fb(e=di){return ui().factory!==void 0||nt.getInstance(e)!==void 0}function Er(e,t,n=di){if(fb(n)){t(un(e,n));return}ui().pending.push(()=>t(un(e,n)))}function un(e,t=di){const n=nt.getInstance(t);if(n)return n;const r=ui().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return nt.getOrCreateInstance(t,r)}var pb=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(Ht,{execute:o=>{r(o.value.map(s=>({name:s.name,html:s.html})))}}));const i=this._container.getInstance(Bl)?.watch(o=>{o&&r([])});i&&(n?i.dispose():t.push(i))})}update(e,t){const n=this._container;return n.addService(Ht,{execute:r=>{const i=un(n),o=r.value.find(s=>s.name===e);if(o){const{icon:s,title:a,fallbackTooltip:c,...d}=t;s&&(o.icon=i.getReactNode(s)),a&&(o.title=i.getReactNode(a)),c&&(o.fallbackTooltip=i.getReactNode(c)),Object.assign(o,d)}}})}delete(e){this._container.addService(Ht,{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(Ht,{execute:r=>{const i=un(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(ab,()=>new tl).add(e,t??0,n)}handleInject(e,t,n){return Ze(this._container,Fl).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},mb=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Ot,()=>new xt)}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 hb(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Co(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 gb=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ze(t,tc),this._closeModalEmitter=Ze(t,Tl),this._updateModalEmitter=Ze(t,Cl)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Er(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Co(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Er(this._container,r=>{this._updateModalEmitter.fire(hb({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:Co(r,n)}))})}},vb=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)}},bb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Ot,()=>new xt)}_createScriptHandle(e,t){const n=this._messageService.addListener(Rr,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 vb(t,n);return r}registerSandboxCSS(e){return this._container.addService(Xe,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Xe,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Xe,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Xe,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},yb=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function _r(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&yb.has(t)}function nl(){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 Bn(){return`__settingsPanel:${nl()}`}function Un(e,t){return{type:e,props:t}}function Eb(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!_r(e)}function To(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(_r(t)){const r=Bn();return n(e.add(r,t)),Un(r,{})}if(typeof t=="function"){const r=Bn();return n(e.add(r,t)),Un(r,{})}if(Eb(t)){const r=t.type;if(typeof r=="string")return t;if(_r(r)||typeof r=="function"){const i=Bn();return n(e.add(i,r)),Un(i,t.props)}return t}return t}var _b=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??nl();Er(this._container,n=>{const r=s=>this._trackRegistration(s),i=To(n,e.content,r),o=e.advancedTabs?.map(s=>({...s,content:To(n,s.content,r)}));Ze(this._container,bi).fire({...e,content:i,advancedTabs:o,instanceKey:t,type:jl})})}closeSettingsPanel(){this._clearPanelRegistrations(),Ze(this._container,bi).fire(null)}},rl={SandboxScriptApi:bb,ElementsApi:pb,BlocksApi:db,MessageService:mb,SettingsPanelApi:_b,ModalApi:gb};function Hn(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 he={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}},wb={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"},$n={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},Ao={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},We={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:he.border,borderRadius:he.borderRadius,textAlign:"center",padding:he.padding},Ro={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:he.padding},Gn={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:he.border,borderRadius:he.borderRadiusCards};function Sb(e){return{...wb,...e}}function Ib(e){return{...$n,...e,bold:e?.bold??$n.bold,italic:e?.italic??$n.italic}}function Cb(e){return{...Ao,...e,underline:e?.underline??Ao.underline}}function Tb(e){return{...We,...e,bold:e?.bold??We.bold,italic:e?.italic??We.italic,border:{...We.border,...e?.border},borderRadius:{...We.borderRadius,...e?.borderRadius},padding:{...We.padding,...e?.padding}}}function Ab(e){return{...Ro,...e,padding:{...Ro.padding,...e?.padding}}}function Rb(e){return{...Gn,...e,border:{...Gn.border,...e?.border},borderRadius:{...Gn.borderRadius,...e?.borderRadius}}}function Vn(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 Po(e){let t={...Pr};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function qn(e){return{text:Sb(e.text),headings:Ib(e.headings),links:Cb(e.links),buttons:Tb(e.buttons),block:Ab(e.block),cards:Rb(e.cards)}}var Do=F("EmailSettingsPort"),Pb=1e4,il=class{_editor;_layoutSettingsChanged=new Yn;_contentStylesChanged=new Yn;_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(!Ba(this._editor.container)||!Je(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(Do);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Vn(this._settings().read())}_getCurrentContentStyles(){const e=Je(this._editor.container)?.current()?.get().attributes.common_styles;return qn(Po(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(Do),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Ot,()=>new xt),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===H.APPLICATION_EMAIL_SETTINGS_SET){const c=Vn(i?.settings),d=this._getLayoutSnapshot(c);d!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=d,this._layoutSettingsChanged.fire(c));return}if(o!==H.APPLICATION_COMMON_STYLES_UPDATE)return;const s=qn(r.data?.settings?.commonStyles??{...Pr}),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=Vn(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Pb){const t=Je(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=fe(r,j.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},d=i(()=>{s||(s=!0,c(),d.dispose(),o())});a=setTimeout(()=>{s||(s=!0,d.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Je(this._editor.container)?.current();if(!t)return;const n=Po(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=Hn(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:he.border,borderRadius:he.borderRadius,padding:he.padding})),e.block!==void 0&&(n.block=Hn(n.block||{},e.block,["padding"],{padding:he.padding})),e.cards!==void 0&&(n.cards=Hn(n.cards||{},e.cards,["border","borderRadius"],{border:he.border,borderRadius:he.borderRadiusCards}));const r=JSON.stringify(n);Ct(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const i=qn(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},Db={...rl,EmailSettingsApi:il},Ob={...rl},ME={...Ob,EmailSettingsApi:il},xb={...Db};function Mb(){Wv.addAll(xb)}var kb=[ot(()=>{Mb()}),Tv,Fv,Cv,Wl,Sv,nc];async function Lb(){return(await Bt()).asyncMixins}var Nb=sb,Fb=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await Lb()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(mn);Object.assign(o,t.instance||{});for(const s of e.getInstance(Dr)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},jb=Zl([...kb]);function zn(){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:d}]of n)r.set(s,o(a,c,d))},dispose(){t=!0,i(),n.clear(),e=void 0}}}function Bb(e){const t=zn(),n=zn(),r=zn();return e.getInstance(U)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(tt).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(tt);if(o){o.notify(i);return}e.getInstanceAsync(tt).then(s=>s.notify(i),()=>{})}}}var ol=F("CodeErrors"),Ub=[];function Hb(e){return e?.getInstance(ol)?.get()??Ub}function $b(e){return e?.getInstance(ol)!==void 0}var Gb=class extends ie{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=jt(e),this.addDisposable(fe(e,j.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){return La(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=>mt(t,this._container))}async _readProjectBlocks(){const e=await tg(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>ht(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>hr(n,this._container))}async getEmailSnapshot(){return ue(this.openEmail(),this._container)}setEmailMeta(e){const t=si(this._container);if(!t)return;const n=t.get().attributes.meta;Ct(t,{meta:On({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,i=>i&&On(i,e))}setBlockMeta(e,t){const n=async()=>{await this._readProjectBlocks();const{cache:r}=this._dataSources.blocks;await r.getIfPresent(e)&&await r.addOrUpdate(e,i=>i&&On(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(n).catch(()=>{})}getCodeErrors(){return $b(this._container)?Hb(this._container):void 0}},Vb=F("EmailDataController");function qb(e){return e.getOrCreateInstance(Vb,()=>{const t=new Gb(e);return e.getInstance(U)?.addDisposable(t),t})}function zb(e){const t=qb(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),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 Wb(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 Kb(e){let t;const n=Sa(e),r=fe(e,j.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:o})=>{t=o}));const i=()=>t?Wb(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 Yb=F("plugin.mountElement");function Xb(e){const t=e.getInstance(se)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function Jb(e){return e.getOrCreateInstance(Yb,()=>{let t=!1,n;return{get:()=>t?n:Xb(e),set(r){t=!0,n=r}}})}function Qb(e){const t=Jb(e);return{getElement:()=>t.get()}}function Zb(e){return{handleLoadImage:B(fe(e,j.UPLOAD_EVENT_ID)),handleFileProxy:B(fe(e,j.FILE_PROXY_EVENT_ID)),handleUrlProxy:B(fe(e,j.PROXY_URL_EVENT_ID)),handleAITextRequest:B(fe(e,j.AI_TEXT_REQUEST_ID)),handleAIImageRequest:B(fe(e,j.AI_IMAGE_REQUEST_ID)),handleReadLocale:B(fe(e,j.READ_LOCALE)),handleLimitUsage:B(fe(e,j.ON_LIMIT_ID)),handleTranslate:B(fe(e,j.ON_TRANSLATE_ID))}}var ey=[Hm,zg,Bb,Nv,zb,Kb,Qb,Zb];function ty(e,t=ey){const n=li(e);Ev(e);const r=jb(e),i=Nb(e),o=Fb(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 d=a&&n.get()===c;a=!1,d||n.set(c),await i.setOptions(c),await o.setOptions(c)}}}function ny(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 ry=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]}},iy="editor-runtime.react.copies",Wn=8;function At(e){return e&&typeof e=="object"?e:void 0}function Oo(e){const t=At(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=At(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function oy(e){const t=At(e),n=t&&typeof t.version=="string"?t.version:void 0,r=At(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function sy(e,t,n){return e.package===t&&e.version===n}function ay({ourReact:e,entries:t,packageName:n,version:r}){const i=Oo(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const a of t){const c=At(a);if(!c||!sy(c,n,r))continue;const d=Oo(c.react);!d||d===i||s.has(d)||(s.add(d),o.push({package:n,version:r,reactVersion:oy(c.react),react:c.react}))}return o}function ly({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,Wn))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Wn&&n.push(` …and ${t.length-Wn} 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 xo=new Set;function cy({packageName:e="@emailmaker/emailmaker",version:t="1.1.104",log:n=r=>{}}={}){const r=i=>{try{const o=globalThis[Symbol.for(iy)],s=ay({ourReact:i,entries:o,packageName:e,version:t}).filter(a=>!xo.has(a.react));if(!s.length)return;s.forEach(a=>xo.add(a.react)),n(ly({packageName:e,copies:s}))}catch{}};try{const i=Lr()?.modules?.React;if(i&&typeof i.then=="function"){i.then(r,()=>{});return}r(i)}catch{}}async function dy(e,t,n){Y(e.signal);const r=t??nt.createChild();li(r);const i=r.getInstance(U);let o;async function s(){r.inject(Xo,ny(new ry)),cy();const a=ty(r),c={...a.instance,container:r,get ready(){return o??Promise.resolve(c)},async reset(d){if(Y(d.signal),i.isDisposed())throw Oe();return await a.setOptions(d),c}};r.inject(mn,c);try{if(n?.onInstance?.(c),await a.setOptions(e),Y(e.signal),i.isDisposed()||await Gg(r),e.devTools)try{const d=r.getInstance(xr);d&&await(await Bt()).initDevTools(r,d)}catch{}return Y(e.signal),kt(r,Ko).fire(c),c}catch(d){throw i.dispose(),d}}try{return o=rn(s(),e.signal),o.catch(()=>{}),await o}catch(a){throw i.isDisposed()||i.dispose(),a}}var Rt=new WeakMap;function uy(e){return e?Rt.get(e):void 0}function sl(e){try{e.getInstance(U)?.dispose()}catch{}try{e.dispose()}catch{}}function fy(e,t){if(!e)return;const n=Rt.get(e);n&&n!==t&&sl(n),Rt.set(e,t)}function py(e,t){e&&Rt.get(e)===t&&Rt.delete(e)}function my(e){const t=nt.createChild();return Lt(e)&&t.inject(Ae,gn(e)),t}var _t=new WeakMap,hy="data-emailmaker-config-styles";function gy(e){return typeof e=="string"?e.trim():""}function Mo(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function vy(e,t,n){if(!e||typeof document>"u")return null;const r=gy(t),i=_t.get(e),o=n||e;if(!r)return i&&(i.remove(),_t.delete(e)),null;if(i)return i.textContent!==r&&(i.textContent=r),(i.parentNode!==o||i!==o.firstChild)&&Mo(o,i),i;const s=document.createElement("style");return s.setAttribute(hy,"true"),s.textContent=r,Mo(o,s),_t.set(e,s),s}function by(e){if(!e)return;const t=_t.get(e);t&&(t.remove(),_t.delete(e))}function al(){return!1}var yy=`
|
|
1049
1049
|
.blocks-app-initial-spinner-wrapper {
|
|
1050
1050
|
width: 100%;
|
|
1051
1051
|
height: 100%;
|
|
@@ -1074,7 +1074,7 @@ import{n as Go,r as bl}from"./static/esm/971f1b2c.js";import{A as Vo,At as rn,B
|
|
|
1074
1074
|
100% {
|
|
1075
1075
|
transform: rotate(360deg);
|
|
1076
1076
|
}
|
|
1077
|
-
}`;function by(){return()=>{}}function yy(e,t){if(!sl()||!e||typeof document>"u")return by();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=vy,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function Ey(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function _y({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)),Ey(c)||t.delete(i),c});return t.set(i,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var fi=_y();function al(){fi.clear()}Ll(()=>fi.clear());var ko=new WeakMap;function pi(e){return ic(e)}function wy(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function Sy(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function Iy(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 mi=new WeakMap;function Kn(e,t){mi.set(e,t)}function Cy(e){return mi.get(e)}function Ty(e,t){return async({baseUrl:n})=>{const r=t(),i=r&&mi.get(r)||e,o=pi(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 Iy(i);if(i.getAuthToken&&!a)throw Sy();a&&s.set("authorization",a);const c=await Bl("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},o,{attemptTimeout:ti(i)||void 0});if(!c.ok)throw wy(c.status,c.statusText);return await c.json()}}function Ay(e){return JSON.stringify({baseUrl:pi(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function Ry(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function Py(e){return t=>fi.run(Ay(t),()=>(Z("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>Z("appInit:end",{kind:"network"}))))}function Dy(e,t){if(Lt(e)||!e.appInit&&!pi(e.baseUrl)||!Ry(e))return e;const n=e.appInit??Ty(e,t);let r=ko.get(n);return r||(r=Py(n),ko.set(n,r)),{...e,appInit:r}}var ll=0;function Oy(){return ll}function xy(){ll+=1,al()}var Lo=new WeakMap,No=new WeakMap,My=3e4;function ky(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function Ly(e,t){try{const n=Mr(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+My}function Ny(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=ky(r,i);if(o)return n.delete(s),t.delete(s),al(),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&&(Z("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,i,o)).then(d=>{const f=String(d||"").trim();return f&&n.set(s,{token:d,expiresAtMs:Ly(f,Date.now())}),d}).finally(()=>{Z("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,c)),c}}function Fy(e){if(Lt(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Lo.get(t);const r=Oy();return(!n||No.get(t)!==r)&&(n=Ny(t),Lo.set(t,n),No.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var jy="[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 By(e){const t=new Error(jy,{cause:e});return t.name="EditorStartFailedError",t}var Uy={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function Fo(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var cl=["handleLoad","handleDestroy"];function dl(e,t){let n=e;for(const r of cl){const i=e?.[r];typeof i=="function"&&(n={...n,[r]:(o,...s)=>i(t,...s)})}return n}function Hy(e){let t,n="pending",r,i,o,s;const a=new Set,c=[],d=new Set;let f,m;const y=new Promise((I,O)=>{f=I,m=O});y.catch(()=>{});const b={},T=I=>t?.[I],w=()=>r??Oe(),g=(I,O)=>{const k=T(I);if(typeof k!="function")throw Fo(I);return k.apply(t,O)},C=(I,O)=>{try{return Promise.resolve(g(I,O))}catch(k){return Promise.reject(k)}},_=()=>{const I=t?.container?.getInstance?.(U);if(!(n!=="ready"||I?.isDisposed()||typeof T("getConfig")!="function"))try{s=g("getConfig",[])}catch{}},P=()=>n==="dead"?Promise.reject(w()):n==="ready"?Promise.resolve():y,S=()=>{for(const[I,O]of dn)O==="field"&&(b[I]=T(I))},M=I=>{const O=T(I.name);I.dispose||typeof O!="function"||n==="dead"||(I.dispose=O.apply(t,I.args))},v=()=>a.forEach(M),E=()=>{for(const I of a){try{I.dispose?.()}catch{}I.dispose=void 0}},A=()=>{S(),v()},h=()=>{o?.delete(A),o=void 0},l=(I,O)=>{const[k,...ee]=O;return!cl.includes(I)||typeof k!="function"?O:[(ce,...X)=>k(b,...X),...ee]},u=(I,O)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof T(I)!="function")throw Fo(I);const k={name:I,args:l(I,O)};return a.add(k),M(k),()=>{a.delete(k),k.dispose?.(),k.dispose=void 0}},p=()=>t?.container?.getInstance(se)?.get()?.content,R=()=>{const I=e.element();return I!==void 0&&typeof I!="string"?I:void 0},D=(I,O)=>{switch(O){case"event":return(...k)=>u(I,k);case"async":return(...k)=>(I==="show"&&k[0]!==void 0&&e.shown?.(k[0]),n!=="dead"&&typeof T(I)=="function"?C(I,k):P().then(()=>g(I,k)));case"queued":return(...k)=>{if(n==="dead"){if(I==="notify")return;throw w()}if(n==="pending"){c.push({name:I,args:k});return}return g(I,k)};case"sync":return(...k)=>{if(n==="dead"){if(I==="getConfig")return s;throw w()}if(typeof T(I)!="function")throw new Error(`[emailmaker] \`${I}\` is not available before the editor is ready: ${Uy[I]??"await `ready` first"}`);const ee=g(I,k);return I==="getConfig"&&(s=ee),ee};case"element":return()=>{if(typeof T(I)!="function")return R();try{return g(I,[])}catch{return R()}};case"codeErrors":return()=>n==="ready"&&typeof T(I)=="function"?g(I,[]):[];case"field":return}};for(const[I,O]of dn)b[I]=D(I,O);b.reset=I=>(I?.content!==void 0&&e.shown?.(I.content),P().then(async()=>{const O=I?.content!==void 0&&Ce(I.content,p());await g("reset",[dl(I,L)]),O&&await g("show",[I.content])}).then(()=>b)),b.destroy=()=>{if(n==="dead")return;const I=pe("[emailmaker] editor was destroyed before it was ready");i?.catch(()=>{}),d.forEach(O=>O(I)),_(),e.destroy()},Object.defineProperty(b,"ready",{get:()=>i,enumerable:!0,configurable:!0});const L=b;return{object:L,get state(){return n},get editor(){return t},bind:I=>{n==="dead"||t===I||(E(),h(),t=I,S(),v(),n==="pending"&&(o=I.container.getOrCreateInstance(Dr,()=>new Set),o.add(A)))},settle:()=>{if(n==="pending"){n="ready",h(),S(),v();for(const I of c.splice(0))try{g(I.name,I.args)}catch(O){queueMicrotask(()=>{throw O})}f()}},kill:(I,O)=>{n!=="dead"&&(_(),n="dead",r=I,c.length=0,d.forEach(k=>k(I)),h(),O?.keepSubscriptions||(E(),a.clear()),m(I))},detach:()=>{E(),a.clear()},setReady:I=>{i=I},trackCall:I=>(d.add(I),()=>d.delete(I)),hasCalls:()=>d.size>0}}var ul="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function $y(){return pe(ul)}function Gy(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===ul}function Vy(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 qy(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 Vy(n,()=>{n.id,o.abort($y())},i),Tr(r,o.signal)}var fl="Superseded by newer init() on the same mount element";function jo(){return pe(fl)}function zy(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===fl}var ct=new Map,Bo=new WeakMap,Jt=new WeakMap;function Wy(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function Ky(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=Wy(e);(n?ct.get(n):void 0)?.forEach(f=>{f.element!==e&&f.controller.abort(jo())});const r=Bo.get(e)??new Set;t&&r.forEach(f=>{f.supersedable&&f.controller.abort(jo())});const i=Jt.get(e)??Promise.resolve();let o;const s=new Promise(f=>{o=f}),a=i.then(()=>s);Jt.set(e,a),a.then(()=>{Jt.get(e)===a&&Jt.delete(e)});const c=new AbortController,d={element:e,controller:c,supersedable:t};if(r.add(d),Bo.set(e,r),n){const f=ct.get(n)??new Set;f.add(d),ct.set(n,f)}return{signal:c.signal,previous:i,release:()=>{o(),r.delete(d);const f=n?ct.get(n):void 0;n&&f?.delete(d)&&f.size===0&&ct.delete(n)}}}var Pt=new WeakMap;function hi(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function wr(e){return Object.entries(e).filter(([t,n])=>hi(t,n)).map(([t])=>t).sort()}function Uo(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!hi(n,r)&&(t[n]=r);return t}function Sr(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Pt.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Pt.set(e,r));const{current:i,trampolines:o}=r;i.clear();const s={...t};for(const a of wr(t)){i.set(a,t[a]);let c=o.get(a);c||(c=(...d)=>i.get(a)?.(...d),o.set(a,c)),s[a]=c}return r.lastOptions=t,s}function pl(e,t){const n=e?Pt.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const i=t[r];hi(r,i)?n.current.set(r,i):n.current.delete(r)}}function Yy(e){const t=e?Pt.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 Xy(e,t,n){const r=e?Pt.get(e):void 0;if(!r||!n)return!1;const i=wr(t),o=Ce(i,wr(r.lastOptions)),s=i.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!o||!s||!Ce(Uo(t),Uo(r.lastOptions))?!1:(Sr(e,t),!0)}var ve=new WeakMap;function En(e){let t=ve.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},ve.set(e,t)),t}var Ne=e=>e!==void 0&&e.state!=="dead";function Jy(e){const t=ve.get(e)?.shared;return Ne(t)?t:void 0}function Qy(e,t){En(e).shared=t}function Zy(e,t){!(Ne(e.shared)&&[...e.counted].some(Ne))||e.warned||!t.devTools||(e.warned=!0)}function eE(e,t,n,r){const i=En(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&&Ne(o)),t],Zy(i,r),i.latestCall}function tE(e,t){return ve.get(e)?.latestCall===t}function nE(e){const t=ve.get(e);if(t)return t.order=t.order.filter(Ne),t.order.at(-1)?.object}function Dt(e,t){const n=ve.get(e);return n?Ne(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&Ne(r)):!1}function rE(e,t){const n=ve.get(e),r=n?.order.filter(i=>i!==t&&Ne(i)).at(-1);return r?n?.options.get(r):void 0}function ml(e,t){En(e).content={value:t}}function iE(e){return ve.get(e)?.content}function oE(e,t,n,r){const i=En(e);if(i.counted.delete(t),i.options.delete(t),Dt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),i.leaving.add(t),hl(e,r)}function hl(e,t){const n=ve.get(e);!n||Dt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Dt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function sE(e,t){const n=ve.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);ve.delete(e)}}var xE=Go({FileManagerApiError:()=>aE,IntegratorSaveTimeoutError:()=>Ur,SaveRefusedError:()=>vt}),aE=class gl 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,gl)}},ME=Go({mapHttpStatusToErrorCode:()=>Rl});function lE(e,t){return{...e,element:t}}function Ir(){return()=>{}}function cE(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Ir():(hy(t,e.config?.styles,t),()=>{gy(t)})}function dE(e){if(!sl()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Ir()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Ir()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=yy(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function uE(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function fn(e){try{e.destroy()}catch{}}function nn(e,...t){const n=me.get(e);t.some(r=>r!==void 0&&r===n)&&me.delete(e)}var kE="1.1.103";async function LE(e){Jr(),await Hv(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}async function NE(e){return gE(e).ready}function fE(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function pE(e){const t=me.get(e);return t&&!(t instanceof Promise)?t:void 0}function pn(e,t,n){const r=t??pE(e);r&&(nn(e,r),fn(r)),sE(e,n)}function mE(e){const{control:t,mode:n,ref:r}=e,i=r.host;if(!i){const s=t.editor;hE(s),t.kill(Oe());return}if(n==="single"){pn(i,t.editor,Oe());return}const o=rE(i,t);oE(i,t,Oe(),()=>pn(i,t.editor,Oe())),o&&Dt(i)&&pl(i,o)}function hE(e){e&&fn(e)}function gE(e){Z(le.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=Tr(e.signal,n.signal),i=t==="single"?fE(e.element):void 0,o=i?Jy(i):void 0;let s;if(o)s={control:o,mode:t,ref:{host:i}};else{const f={},m=Hy({element:()=>f.host??e.element,destroy:()=>mE(s),shown:y=>{f.host&&ml(f.host,y)}});s={control:m,mode:t,ref:f},i&&Qy(i,m)}const{control:a}=s,c=a.trackCall(f=>n.abort(f)),d=_E(dl({...e,signal:r},a.object),s).then(()=>(c(),Z(le.initEnd),a.settle(),a.object),f=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(f);const m=s.ref.host;throw m&&hl(m,()=>pn(m,void 0,Oe())),f});return a.setReady(d),a.object}function FE(e){const t=typeof e=="string"?document.querySelector(e):e;return t?nE(t):void 0}function vE(e){let t,n,r=!1;try{t=e.container.getInstance(se)?.get(),n=e.container.getInstance(Ae)?.externalSignal;const i=Je(e.container)?.current();r=i!==void 0&&i.get().savedVersion!==null&&i.isDirty()}catch{t=void 0}return{options:t,signal:n,email:bE(e),dirty:r}}async function bE(e){try{return await e.getEmailSnapshot()}catch{return}}function yE(e){const t=Je(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function Ho(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Dt(e,n)}async function EE(e,t,n,r,i){if(r.mode==="counted"&&r.control.detach(),zy(i)||Gy(i))return;const o=()=>pn(t,e,By(i)),{options:s}=n;if(!s||!Ho(t,r)){o();return}const a=await n.email,c=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,d=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:c?{...d,email:c}:s.content}),n.dirty&&c&&yE(e),Ho(t,r)?me.set(t,e):o()}catch{o()}}async function _E(e,t){Y(e.signal);const n=new ie;let r,i,o,s,a=0;try{const c=await Jl(e.element,n,e.signal);c&&(s=c,t.ref.host=c,a=eE(c,t.control,t.mode,e));const d=qy({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),f=Ky(c,{supersede:t.mode==="single"});r=f.release;const m=Tr(d,f.signal);Y(m),o=Yy(c),pl(c,e),await rn(f.previous,m),i=wE(e,c,t,m,o);const y=await rn(i,m);return c&&e.content!==void 0&&ml(c,e.content),y}catch(c){throw s&&o&&tE(s,a)&&o(),c}finally{const c=r;i!==void 0&&c?i.then(c,c):c?.(),n.dispose()}}async function $o(e,t,n,r){const i=iE(t);n===void 0||r||!i||Ce(n,i.value)||await e.show(n)}async function wE(e,t,n,r,i){const{control:o}=n,s=w=>o.bind(w);Y(r);let a;const c=w=>{xy();const g=Fy(lE(w,t)),C=Dy(g,()=>a);return{preparedOptions:C,preparedOptionsWithSignal:r!=null?{...C,signal:r}:C}};let d;if(t){const w=me.get(t);if(w){let g;try{g=await w,Y(r)}catch{Y(r),nn(t,w),g=void 0}if(g)if(g.getElement()===t){const C=cy(t);a=C;const _=g.container.getInstance(se)?.get();if(Xy(t,e,_))return s(g),r&&g.container.getInstance(Ae)?.relinkExternalSignal(r),me.set(t,g),await $o(g,t,e.content,!1),g;const P=!Ce(e.content,_?.content);d=c(Sr(t,e));const{preparedOptions:S,preparedOptionsWithSignal:M}=d,v=C&&Cy(C),E=vE(g);try{C&&Kn(C,S),s(g);const A=await g.reset(uE(e,M));return Y(r),me.set(t,g),await $o(g,t,e.content,P),A}catch(A){if(C&&v&&Kn(C,v),!Oc(A))throw i(),await EE(g,t,E,n,A),A;nn(t,w,g),fn(g),Y(r)}}else nn(t,w,g),fn(g)}}Y(r),d??=c(Sr(t,e,{fresh:!0}));const{preparedOptions:f}=d,m=cE(f),y=dE(f),b=r!=null?{...y.options,signal:r}:y.options;let T;try{a=fy(b),dy(t,a),Kn(a,f),li(a).set(b),await ci(),Z(le.coreReady),Y(r),Y(r),T=ly(b,a,{onInstance:s}),t&&me.set(t,T);const w=await T;if(r?.aborted&&(w.destroy(),Y(r)),t)if(me.get(t)===T)me.set(t,w);else throw w.destroy(),Y(r),pe(r?.reason);return w}catch(w){throw m(),y.cleanup(),a&&(ol(a),uy(t,a)),t&&T&&me.get(t)===T&&me.delete(t),w}}async function jE(e){return(await Bt()).parseAMP(e)}typeof window<"u"&&(wt()&&Pc(),Gv(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0));export{ul as ELEMENT_DETACHED_ABORT_MESSAGE,fl as SUPERSEDED_INIT_ABORT_MESSAGE,gE as create,xE as errors,FE as getInstance,ME as helpers,NE as init,Gy as isElementDetachedError,zy as isSupersededInitError,jE as parseAMP,qv as pluginRegistry,LE as preload,kE as version};
|
|
1077
|
+
}`;function Ey(){return()=>{}}function _y(e,t){if(!al()||!e||typeof document>"u")return Ey();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=yy,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function wy(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function Sy({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)),wy(c)||t.delete(i),c});return t.set(i,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var fi=Sy();function ll(){fi.clear()}Nl(()=>fi.clear());var ko=new WeakMap;function pi(e){return oc(e)}function Iy(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function Cy(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function Ty(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 mi=new WeakMap;function Kn(e,t){mi.set(e,t)}function Ay(e){return mi.get(e)}function Ry(e,t){return async({baseUrl:n})=>{const r=t(),i=r&&mi.get(r)||e,o=pi(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 Ty(i);if(i.getAuthToken&&!a)throw Cy();a&&s.set("authorization",a);const c=await Ul("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},o,{attemptTimeout:ti(i)||void 0});if(!c.ok)throw Iy(c.status,c.statusText);return await c.json()}}function Py(e){return JSON.stringify({baseUrl:pi(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function Dy(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function Oy(e){return t=>fi.run(Py(t),()=>(J("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>J("appInit:end",{kind:"network"}))))}function xy(e,t){if(Lt(e)||!e.appInit&&!pi(e.baseUrl)||!Dy(e))return e;const n=e.appInit??Ry(e,t);let r=ko.get(n);return r||(r=Oy(n),ko.set(n,r)),{...e,appInit:r}}var cl=0;function My(){return cl}function ky(){cl+=1,ll()}var Lo=new WeakMap,No=new WeakMap,Ly=3e4;function Ny(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function Fy(e,t){try{const n=Mr(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+Ly}function jy(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=Ny(r,i);if(o)return n.delete(s),t.delete(s),ll(),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&&(J("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,i,o)).then(d=>{const f=String(d||"").trim();return f&&n.set(s,{token:d,expiresAtMs:Fy(f,Date.now())}),d}).finally(()=>{J("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,c)),c}}function By(e){if(Lt(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Lo.get(t);const r=My();return(!n||No.get(t)!==r)&&(n=jy(t),Lo.set(t,n),No.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var Uy="[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 Hy(e){const t=new Error(Uy,{cause:e});return t.name="EditorStartFailedError",t}var $y={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function Fo(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var dl=["handleLoad","handleDestroy"];function ul(e,t){let n=e;for(const r of dl){const i=e?.[r];typeof i=="function"&&(n={...n,[r]:(o,...s)=>i(t,...s)})}return n}function Gy(e){let t,n="pending",r,i,o,s;const a=new Set,c=[],d=new Set;let f,m;const y=new Promise((I,O)=>{f=I,m=O});y.catch(()=>{});const b={},T=I=>t?.[I],w=()=>r??Oe(),g=(I,O)=>{const L=T(I);if(typeof L!="function")throw Fo(I);return L.apply(t,O)},C=(I,O)=>{try{return Promise.resolve(g(I,O))}catch(L){return Promise.reject(L)}},_=()=>{const I=t?.container?.getInstance?.(U);if(!(n!=="ready"||I?.isDisposed()||typeof T("getConfig")!="function"))try{s=g("getConfig",[])}catch{}},P=()=>n==="dead"?Promise.reject(w()):n==="ready"?Promise.resolve():y,S=()=>{for(const[I,O]of dn)O==="field"&&(b[I]=T(I))},M=I=>{const O=T(I.name);I.dispose||typeof O!="function"||n==="dead"||(I.dispose=O.apply(t,I.args))},v=()=>a.forEach(M),E=()=>{for(const I of a){try{I.dispose?.()}catch{}I.dispose=void 0}},A=()=>{S(),v()},h=()=>{o?.delete(A),o=void 0},l=(I,O)=>{const[L,...Q]=O;return!dl.includes(I)||typeof L!="function"?O:[(ce,...te)=>L(b,...te),...Q]},u=(I,O)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof T(I)!="function")throw Fo(I);const L={name:I,args:l(I,O)};return a.add(L),M(L),()=>{a.delete(L),L.dispose?.(),L.dispose=void 0}},p=()=>t?.container?.getInstance(se)?.get()?.content,R=()=>{const I=e.element();return I!==void 0&&typeof I!="string"?I:void 0},D=(I,O)=>{switch(O){case"event":return(...L)=>u(I,L);case"async":return(...L)=>(I==="show"&&L[0]!==void 0&&e.shown?.(L[0]),n!=="dead"&&typeof T(I)=="function"?C(I,L):P().then(()=>g(I,L)));case"queued":return(...L)=>{if(n==="dead"){if(I==="notify")return;throw w()}if(n==="pending"){c.push({name:I,args:L});return}return g(I,L)};case"sync":return(...L)=>{if(n==="dead"){if(I==="getConfig")return s;throw w()}if(typeof T(I)!="function")throw new Error(`[emailmaker] \`${I}\` is not available before the editor is ready: ${$y[I]??"await `ready` first"}`);const Q=g(I,L);return I==="getConfig"&&(s=Q),Q};case"element":return()=>{if(typeof T(I)!="function")return R();try{return g(I,[])}catch{return R()}};case"codeErrors":return()=>n==="ready"&&typeof T(I)=="function"?g(I,[]):[];case"field":return}};for(const[I,O]of dn)b[I]=D(I,O);b.reset=I=>(I?.content!==void 0&&e.shown?.(I.content),P().then(async()=>{const O=I?.content!==void 0&&Te(I.content,p());await g("reset",[ul(I,N)]),O&&await g("show",[I.content])}).then(()=>b)),b.destroy=()=>{if(n==="dead")return;const I=de("[emailmaker] editor was destroyed before it was ready");i?.catch(()=>{}),d.forEach(O=>O(I)),_(),e.destroy()},Object.defineProperty(b,"ready",{get:()=>i,enumerable:!0,configurable:!0});const N=b;return{object:N,get state(){return n},get editor(){return t},bind:I=>{n==="dead"||t===I||(E(),h(),t=I,S(),v(),n==="pending"&&(o=I.container.getOrCreateInstance(Dr,()=>new Set),o.add(A)))},settle:()=>{if(n==="pending"){n="ready",h(),S(),v();for(const I of c.splice(0))try{g(I.name,I.args)}catch(O){queueMicrotask(()=>{throw O})}f()}},kill:(I,O)=>{n!=="dead"&&(_(),n="dead",r=I,c.length=0,d.forEach(L=>L(I)),h(),O?.keepSubscriptions||(E(),a.clear()),m(I))},detach:()=>{E(),a.clear()},setReady:I=>{i=I},trackCall:I=>(d.add(I),()=>d.delete(I)),hasCalls:()=>d.size>0}}var fl="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function Vy(){return de(fl)}function qy(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===fl}function zy(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 Wy(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 zy(n,()=>{n.id,o.abort(Vy())},i),Tr(r,o.signal)}var pl="Superseded by newer init() on the same mount element";function jo(){return de(pl)}function Ky(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===pl}var ct=new Map,Bo=new WeakMap,Jt=new WeakMap;function Yy(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function Xy(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=Yy(e);(n?ct.get(n):void 0)?.forEach(f=>{f.element!==e&&f.controller.abort(jo())});const r=Bo.get(e)??new Set;t&&r.forEach(f=>{f.supersedable&&f.controller.abort(jo())});const i=Jt.get(e)??Promise.resolve();let o;const s=new Promise(f=>{o=f}),a=i.then(()=>s);Jt.set(e,a),a.then(()=>{Jt.get(e)===a&&Jt.delete(e)});const c=new AbortController,d={element:e,controller:c,supersedable:t};if(r.add(d),Bo.set(e,r),n){const f=ct.get(n)??new Set;f.add(d),ct.set(n,f)}return{signal:c.signal,previous:i,release:()=>{o(),r.delete(d);const f=n?ct.get(n):void 0;n&&f?.delete(d)&&f.size===0&&ct.delete(n)}}}var Pt=new WeakMap;function hi(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function wr(e){return Object.entries(e).filter(([t,n])=>hi(t,n)).map(([t])=>t).sort()}function Uo(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!hi(n,r)&&(t[n]=r);return t}function Sr(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Pt.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Pt.set(e,r));const{current:i,trampolines:o}=r;i.clear();const s={...t};for(const a of wr(t)){i.set(a,t[a]);let c=o.get(a);c||(c=(...d)=>i.get(a)?.(...d),o.set(a,c)),s[a]=c}return r.lastOptions=t,s}function ml(e,t){const n=e?Pt.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const i=t[r];hi(r,i)?n.current.set(r,i):n.current.delete(r)}}function Jy(e){const t=e?Pt.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 Qy(e,t,n){const r=e?Pt.get(e):void 0;if(!r||!n)return!1;const i=wr(t),o=Te(i,wr(r.lastOptions)),s=i.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!o||!s||!Te(Uo(t),Uo(r.lastOptions))?!1:(Sr(e,t),!0)}var be=new WeakMap;function En(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 Ne=e=>e!==void 0&&e.state!=="dead";function Zy(e){const t=be.get(e)?.shared;return Ne(t)?t:void 0}function eE(e,t){En(e).shared=t}function tE(e,t){!(Ne(e.shared)&&[...e.counted].some(Ne))||e.warned||!t.devTools||(e.warned=!0)}function nE(e,t,n,r){const i=En(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&&Ne(o)),t],tE(i,r),i.latestCall}function rE(e,t){return be.get(e)?.latestCall===t}function iE(e){const t=be.get(e);if(t)return t.order=t.order.filter(Ne),t.order.at(-1)?.object}function Dt(e,t){const n=be.get(e);return n?Ne(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&Ne(r)):!1}function oE(e,t){const n=be.get(e),r=n?.order.filter(i=>i!==t&&Ne(i)).at(-1);return r?n?.options.get(r):void 0}function hl(e,t){En(e).content={value:t}}function sE(e){return be.get(e)?.content}function aE(e,t,n,r){const i=En(e);if(i.counted.delete(t),i.options.delete(t),Dt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),i.leaving.add(t),gl(e,r)}function gl(e,t){const n=be.get(e);!n||Dt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Dt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function lE(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 kE=Go({FileManagerApiError:()=>cE,IntegratorSaveTimeoutError:()=>Ur,SaveRefusedError:()=>vt}),cE=class vl 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,vl)}},LE=Go({mapHttpStatusToErrorCode:()=>Pl});function dE(e,t){return{...e,element:t}}function Ir(){return()=>{}}function uE(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Ir():(vy(t,e.config?.styles,t),()=>{by(t)})}function fE(e){if(!al()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Ir()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Ir()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=_y(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function pE(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function fn(e){try{e.destroy()}catch{}}function nn(e,...t){const n=me.get(e);t.some(r=>r!==void 0&&r===n)&&me.delete(e)}var NE="1.1.104";async function FE(e){Jr(),await Gv(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0)}async function jE(e){return bE(e).ready}function mE(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function hE(e){const t=me.get(e);return t&&!(t instanceof Promise)?t:void 0}function pn(e,t,n){const r=t??hE(e);r&&(nn(e,r),fn(r)),lE(e,n)}function gE(e){const{control:t,mode:n,ref:r}=e,i=r.host;if(!i){const s=t.editor;vE(s),t.kill(Oe());return}if(n==="single"){pn(i,t.editor,Oe());return}const o=oE(i,t);aE(i,t,Oe(),()=>pn(i,t.editor,Oe())),o&&Dt(i)&&ml(i,o)}function vE(e){e&&fn(e)}function bE(e){J(le.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=Tr(e.signal,n.signal),i=t==="single"?mE(e.element):void 0,o=i?Zy(i):void 0;let s;if(o)s={control:o,mode:t,ref:{host:i}};else{const f={},m=Gy({element:()=>f.host??e.element,destroy:()=>gE(s),shown:y=>{f.host&&hl(f.host,y)}});s={control:m,mode:t,ref:f},i&&eE(i,m)}const{control:a}=s,c=a.trackCall(f=>n.abort(f)),d=SE(ul({...e,signal:r},a.object),s).then(()=>(c(),J(le.initEnd),a.settle(),a.object),f=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(f);const m=s.ref.host;throw m&&gl(m,()=>pn(m,void 0,Oe())),f});return a.setReady(d),a.object}function BE(e){const t=typeof e=="string"?document.querySelector(e):e;return t?iE(t):void 0}function yE(e){let t,n,r=!1;try{t=e.container.getInstance(se)?.get(),n=e.container.getInstance(Re)?.externalSignal;const i=Je(e.container)?.current();r=i!==void 0&&i.get().savedVersion!==null&&i.isDirty()}catch{t=void 0}return{options:t,signal:n,email:EE(e),dirty:r}}async function EE(e){try{return await e.getEmailSnapshot()}catch{return}}function _E(e){const t=Je(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function Ho(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Dt(e,n)}async function wE(e,t,n,r,i){if(r.mode==="counted"&&r.control.detach(),Ky(i)||qy(i))return;const o=()=>pn(t,e,Hy(i)),{options:s}=n;if(!s||!Ho(t,r)){o();return}const a=await n.email,c=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,d=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:c?{...d,email:c}:s.content}),n.dirty&&c&&_E(e),Ho(t,r)?me.set(t,e):o()}catch{o()}}async function SE(e,t){Y(e.signal);const n=new ie;let r,i,o,s,a=0;try{const c=await Ql(e.element,n,e.signal);c&&(s=c,t.ref.host=c,a=nE(c,t.control,t.mode,e));const d=Wy({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),f=Xy(c,{supersede:t.mode==="single"});r=f.release;const m=Tr(d,f.signal);Y(m),o=Jy(c),ml(c,e),await rn(f.previous,m),i=IE(e,c,t,m,o);const y=await rn(i,m);return c&&e.content!==void 0&&hl(c,e.content),y}catch(c){throw s&&o&&rE(s,a)&&o(),c}finally{const c=r;i!==void 0&&c?i.then(c,c):c?.(),n.dispose()}}async function $o(e,t,n,r){const i=sE(t);n===void 0||r||!i||Te(n,i.value)||await e.show(n)}async function IE(e,t,n,r,i){const{control:o}=n,s=w=>o.bind(w);Y(r);let a;const c=w=>{ky();const g=By(dE(w,t)),C=xy(g,()=>a);return{preparedOptions:C,preparedOptionsWithSignal:r!=null?{...C,signal:r}:C}};let d;if(t){const w=me.get(t);if(w){let g;try{g=await w,Y(r)}catch{Y(r),nn(t,w),g=void 0}if(g)if(g.getElement()===t){const C=uy(t);a=C;const _=g.container.getInstance(se)?.get();if(Qy(t,e,_))return s(g),r&&g.container.getInstance(Re)?.relinkExternalSignal(r),me.set(t,g),await $o(g,t,e.content,!1),g;const P=!Te(e.content,_?.content);d=c(Sr(t,e));const{preparedOptions:S,preparedOptionsWithSignal:M}=d,v=C&&Ay(C),E=yE(g);try{C&&Kn(C,S),s(g);const A=await g.reset(pE(e,M));return Y(r),me.set(t,g),await $o(g,t,e.content,P),A}catch(A){if(C&&v&&Kn(C,v),!xc(A))throw i(),await wE(g,t,E,n,A),A;nn(t,w,g),fn(g),Y(r)}}else nn(t,w,g),fn(g)}}Y(r),d??=c(Sr(t,e,{fresh:!0}));const{preparedOptions:f}=d,m=uE(f),y=fE(f),b=r!=null?{...y.options,signal:r}:y.options;let T;try{a=my(b),fy(t,a),Kn(a,f),li(a).set(b),await ci(),J(le.coreReady),Y(r),Y(r),T=dy(b,a,{onInstance:s}),t&&me.set(t,T);const w=await T;if(r?.aborted&&(w.destroy(),Y(r)),t)if(me.get(t)===T)me.set(t,w);else throw w.destroy(),Y(r),de(r?.reason);return w}catch(w){throw m(),y.cleanup(),a&&(sl(a),py(t,a)),t&&T&&me.get(t)===T&&me.delete(t),w}}async function UE(e){return(await Bt()).parseAMP(e)}typeof window<"u"&&(wt()&&Dc(),qv(typeof window.__emailmaker__<"u"?window.__emailmaker__:void 0));export{fl as ELEMENT_DETACHED_ABORT_MESSAGE,pl as SUPERSEDED_INIT_ABORT_MESSAGE,bE as create,kE as errors,BE as getInstance,LE as helpers,jE as init,qy as isElementDetachedError,Ky as isSupersededInitError,UE as parseAMP,Wv as pluginRegistry,FE as preload,NE as version};
|
|
1078
1078
|
|
|
1079
1079
|
|
|
1080
|
-
window.__emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/0cb54b92.js":[],"static/core/
|
|
1080
|
+
window.__emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/0cb54b92.js":[],"static/core/123fc796.js":["static/core/448f5a93.js","__delivery__/libs"],"static/core/15ea858c.js":[],"static/core/1922419a.js":[],"static/core/1cdd0eaa.js":[],"static/core/20fae5cb.js":["static/core/448f5a93.js","__delivery__/libs"],"static/core/25095aa6.js":["static/core/448f5a93.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/2a6bfcb1.js":[],"static/core/2d570b04.js":["static/core/4b7442c5.js"],"static/core/360afb24.js":["static/core/448f5a93.js","static/core/123fc796.js","static/core/20fae5cb.js","static/core/5dc1b7fa.js","__delivery__/libs"],"static/core/36f15937.js":["static/core/bd852c3b.js"],"static/core/370f04c3.js":[],"static/core/432ad49d.js":["static/core/370f04c3.js","__delivery__/libs","monaco"],"static/core/43a8b244.js":[],"static/core/448f5a93.js":["static/core/a8cb6e27.js","static/core/e6f6edff.js","__delivery__/libs"],"static/core/4b7442c5.js":[],"static/core/5dc1b7fa.js":["static/core/cd6c8848.js","__delivery__/libs"],"static/core/62b7892b.js":[],"static/core/6933d533.js":[],"static/core/7452d34b.js":[],"static/core/76d1f317.js":[],"static/core/8a5b1c18.js":[],"static/core/8bf56b5b.js":[],"static/core/9596ee39.js":["static/core/bd852c3b.js"],"static/core/9f7f5230.js":["static/core/e6f6edff.js"],"static/core/a866296c.js":["static/core/123fc796.js","static/core/cd6c8848.js","__delivery__/libs","static/core/448f5a93.js"],"static/core/a8cb6e27.js":[],"static/core/ba4d44b4.js":[],"static/core/bd852c3b.js":[],"static/core/c100433a.js":[],"static/core/c67adee2.js":[],"static/core/cd6c8848.js":["__delivery__/libs"],"static/core/d0b845c8.js":[],"static/core/d3f1d83d.js":[],"static/core/dc45a033.js":[],"static/core/e6f6edff.js":[],"static/core/e76ed3bd.js":[],"static/core/eee25d75.js":[],"static/core/f173fdc6.js":["static/core/4b7442c5.js","static/core/bd852c3b.js","static/core/36f15937.js"],"static/core/fff40495.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/d4338c39.js","static/esm/f76c9d9d.js"],"static/esm/delivery-libs.js":[],"static/esm/2490dab8.js":["static/esm/971f1b2c.js"],"static/esm/971f1b2c.js":[],"static/esm/d4338c39.js":[],"static/esm/f76c9d9d.js":[]},"bundles":{"static/core/cd6c8848.js":["static/core/25353f1f.js","static/core/105205da.js","static/core/4b026c3d.js"],"static/core/2d570b04.js":["static/core/a54d9b28.js"],"static/core/25095aa6.js":["static/core/be880f91.js"],"static/core/5dc1b7fa.js":["static/core/61378c9e.js"],"static/core/a866296c.js":["static/core/feaa9bed.js"],"core":["static/core/5dc34752.js","static/core/a68428d8.js","static/core/1245487b.js","static/core/9b2943a1.js","static/core/f29f2ebc.js"]}});
|