useblocks 1.1.108 → 1.2.0

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.
Files changed (51) hide show
  1. package/README.md +54 -0
  2. package/iframe/.vite/manifest.json +4 -4
  3. package/iframe/{iframe-eblock.facd6272.html → iframe-eblock.71aea198.html} +2 -2
  4. package/iframe/{iframe.facd6272.html → iframe.71aea198.html} +2 -2
  5. package/iframe/js/{elMarkupHelper.JLkggsgY.js → elMarkupHelper.D_gxM3uK.js} +79 -79
  6. package/iframe/js/{iframe-eblock.body.facd6272.js → iframe-eblock.body.71aea198.js} +1 -1
  7. package/iframe/js/iframe-eblock.js +2 -2
  8. package/iframe/js/{iframe.body.facd6272.js → iframe.body.71aea198.js} +1 -1
  9. package/iframe/js/iframe.js +2 -2
  10. package/package.json +1 -1
  11. package/runtime/react/index.js +1 -1
  12. package/static/core/{c6bde249.js → 12f773c1.js} +1 -1
  13. package/static/core/{feb1ffa4.js → 1516d48e.js} +1 -1
  14. package/static/core/{38ea9ef6.js → 1594df08.js} +1 -1
  15. package/static/core/{e86ffdcb.js → 1d170e32.js} +1 -1
  16. package/static/core/{83a7fff3.js → 1dc51b93.js} +1 -1
  17. package/static/core/{622a2220.js → 28d63741.js} +1 -1
  18. package/static/core/{c9cebb1a.js → 29e211b1.js} +1 -1
  19. package/static/core/{9b50835f.js → 3d3eb29f.js} +1 -1
  20. package/static/core/{da678146.js → 3f80e59d.js} +6 -6
  21. package/static/core/{4ec0aff8.js → 5278dff9.js} +1 -1
  22. package/static/core/{cc70a22f.js → 57fee71e.js} +3 -3
  23. package/static/core/{19e01848.js → 5b586fcb.js} +1 -1
  24. package/static/core/{f50ba1e0.js → 69789892.js} +1 -1
  25. package/static/core/{87e91b5e.js → 6bc1c806.js} +1 -1
  26. package/static/core/{e8a44736.js → 6dcb28a1.js} +1 -1
  27. package/static/core/{aa65675c.js → 6f7a2152.js} +1 -1
  28. package/static/core/{f89490a1.js → 91f77c2d.js} +1 -1
  29. package/static/core/{34804219.js → 9f4f4873.js} +1 -1
  30. package/static/core/{32813d7b.js → a34a72bf.js} +2 -2
  31. package/static/core/{4d698359.js → bfb25e63.js} +1 -1
  32. package/static/core/{23ecb0b0.js → c8fe849c.js} +1 -1
  33. package/static/core/{2865a0ae.js → cea06bde.js} +1 -1
  34. package/static/core/{a77f31cb.js → cf548c07.js} +1 -1
  35. package/static/core/{42ef449b.js → d6929171.js} +1 -1
  36. package/static/core/{d8e8d436.js → def48fbd.js} +1 -1
  37. package/static/core/e460bb13.js +1 -0
  38. package/static/core/{fe5390c8.js → f0c51560.js} +1 -1
  39. package/static/core/{8a452a94.js → f9749132.js} +1 -1
  40. package/static/esm/f97f84b4.js +1 -0
  41. package/static/umd-runtime/runtime.DxsFr3F4.js +1 -0
  42. package/useblocks-core.71aea198.js +859 -0
  43. package/useblocks-esm.js +11 -11
  44. package/{useblocks-po.facd6272.js → useblocks-po.71aea198.js} +1 -1
  45. package/useblocks.d.ts +220 -1
  46. package/useblocks.js +12 -12
  47. package/vendor/useblocks-ui-kit/package.json +1 -1
  48. package/static/core/ebcc0451.js +0 -1
  49. package/static/esm/1e463a71.js +0 -1
  50. package/static/umd-runtime/runtime.DeDiWiET.js +0 -1
  51. package/useblocks-core.facd6272.js +0 -859
package/useblocks-esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import{n as us,r as Hl}from"./static/esm/971f1b2c.js";import{$ as xo,A as $l,At as ve,B as ql,Bt as ue,C as Gl,Ct as Fe,D as Vl,Dt as Nn,E as zl,Et as Wl,F as Kl,Ft as ut,G as Yl,H as $r,I as Xl,It as H,J as Jl,K as Ql,L as Sn,Lt as Ee,M as fs,Mt as un,N as Zl,Nt as ee,O as qr,Ot as ec,P as tc,Pt as nc,Q as Gr,R as rc,Rt as oc,S as Re,St as lt,T as Mo,Tt as pr,U as ic,V as ps,W as Vt,X as sc,Y as ac,Z as ot,_ as lc,_t as cc,a as dc,at as hs,b as uc,bt as Ft,c as ms,ct as Pe,d as z,dt as pe,et as Bt,f as fc,ft as Vr,gt as Lo,h as pc,ht as hc,i as mc,it as gs,j as gc,jt as zr,k as vc,kt as bc,l as yc,lt as In,m as Ec,mt as _c,n as wc,nt as vs,o as Sc,ot as fe,p as Wr,pt as De,q as jt,r as Ic,rt as Be,s as gt,st as G,t as _e,u as Cc,ut as Kr,v as Yr,vt as Tc,w as Ac,wt as Rc,x as Xr,xt as ye,y as Me,yt as j,z as bs,zt as Pc}from"./static/esm/1e463a71.js";import{t as Dc}from"./static/esm/f76c9d9d.js";(function(){"use strict";var e=window.__useblocks__=window.__useblocks__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var m=(function(){if(typeof document<"u"&&document.querySelector)try{var C=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(C&&C.src)return C.src.substring(0,C.src.lastIndexOf("/")+1)}catch{}try{var x=import.meta.url;if(x)return x.substring(0,x.lastIndexOf("/")+1)}catch{}return"./"})();m||(m="./");try{var u=String(m);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0)return u.charAt(u.length-1)==="/"?u:u+"/";var f=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",g=f?new URL(u,f).href:u;return g.charAt(g.length-1)==="/"?g:g+"/"}catch{var v=String(m);return v.charAt(v.length-1)==="/"?v:v+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(m){return e.publicPath=(function(){var u=m==null?"":String(m);u||(u="./");try{var f=String(u);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(f)||f.indexOf("//")===0)return f.charAt(f.length-1)==="/"?f:f+"/";var g=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",v=g?new URL(f,g).href:f;return v.charAt(v.length-1)==="/"?v:v+"/"}catch{var C=String(u);return C.charAt(C.length-1)==="/"?C:C+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var m=String(e.publicPath||"");if(m.indexOf("file:")!==0&&!(m&&m!=="./")){var u="";try{if(typeof window<"u"){for(var f in window)if(!(f==="__useblocks__"||!/^__[^_].*__$/.test(f))){var g;try{g=window[f]}catch{continue}if(g&&typeof g=="object"&&g.publicPath){u=" Another product namespace ("+f+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(m){function u(O){try{var h=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return h?new URL(String(O||""),h).href:String(O||"")}catch{return String(O||"")}}var f=String(m||"");if(!f)return"";if(/^(?:data:|blob:)/.test(f))return f;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(f)||f.indexOf("//")===0||f.charAt(0)==="/")return u(f);var g=f.replace(/^\.\/+/,"").replace(/^\/+/,""),v="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),C=v&&g.indexOf(v+"/")!==0?v+"/"+g:g,x=e.publicPath||"./";try{return new URL(C,x).href}catch{return x.slice(-1)!=="/"&&(x+="/"),u(x+C)}}),e.version||(e.version="1.1.108");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
1
+ import{n as us,r as Hl}from"./static/esm/971f1b2c.js";import{$ as xo,A as $l,At as ve,B as ql,Bt as ue,C as Vl,Ct as Fe,D as Gl,Dt as Nn,E as zl,Et as Wl,F as Kl,Ft as ut,G as Yl,H as $r,I as Xl,It as H,J as Jl,K as Ql,L as Sn,Lt as Ee,M as fs,Mt as un,N as Zl,Nt as ee,O as qr,Ot as ec,P as tc,Pt as nc,Q as Vr,R as rc,Rt as oc,S as Re,St as lt,T as Mo,Tt as pr,U as ic,V as ps,W as Gt,X as sc,Y as ac,Z as ot,_ as lc,_t as cc,a as dc,at as hs,b as uc,bt as Ft,c as ms,ct as Pe,d as z,dt as pe,et as Bt,f as fc,ft as Gr,gt as Lo,h as pc,ht as hc,i as mc,it as gs,j as gc,jt as zr,k as vc,kt as bc,l as yc,lt as In,m as Ec,mt as _c,n as wc,nt as vs,o as Sc,ot as fe,p as Wr,pt as De,q as jt,r as Ic,rt as Be,s as gt,st as G,t as _e,u as Cc,ut as Kr,v as Yr,vt as Tc,w as Ac,wt as Rc,x as Xr,xt as ye,y as Me,yt as j,z as bs,zt as Pc}from"./static/esm/f97f84b4.js";import{t as Dc}from"./static/esm/f76c9d9d.js";(function(){"use strict";var e=window.__useblocks__=window.__useblocks__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var m=(function(){if(typeof document<"u"&&document.querySelector)try{var O=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(O&&O.src)return O.src.substring(0,O.src.lastIndexOf("/")+1)}catch{}try{var y=import.meta.url;if(y)return y.substring(0,y.lastIndexOf("/")+1)}catch{}return"./"})();m||(m="./");try{var u=String(m);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0)return u.charAt(u.length-1)==="/"?u:u+"/";var f=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",g=f?new URL(u,f).href:u;return g.charAt(g.length-1)==="/"?g:g+"/"}catch{var x=String(m);return x.charAt(x.length-1)==="/"?x:x+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(m){return e.publicPath=(function(){var u=m==null?"":String(m);u||(u="./");try{var f=String(u);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(f)||f.indexOf("//")===0)return f.charAt(f.length-1)==="/"?f:f+"/";var g=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",x=g?new URL(f,g).href:f;return x.charAt(x.length-1)==="/"?x:x+"/"}catch{var O=String(u);return O.charAt(O.length-1)==="/"?O:O+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var m=String(e.publicPath||"");if(m.indexOf("file:")!==0&&!(m&&m!=="./")){var u="";try{if(typeof window<"u"){for(var f in window)if(!(f==="__useblocks__"||!/^__[^_].*__$/.test(f))){var g;try{g=window[f]}catch{continue}if(g&&typeof g=="object"&&g.publicPath){u=" Another product namespace ("+f+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(m){function u(A){try{var h=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return h?new URL(String(A||""),h).href:String(A||"")}catch{return String(A||"")}}var f=String(m||"");if(!f)return"";if(/^(?:data:|blob:)/.test(f))return f;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(f)||f.indexOf("//")===0||f.charAt(0)==="/")return u(f);var g=f.replace(/^\.\/+/,"").replace(/^\/+/,""),x="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),O=x&&g.indexOf(x+"/")!==0?x+"/"+g:g,y=e.publicPath||"./";try{return new URL(O,y).href}catch{return y.slice(-1)!=="/"&&(y+="/"),u(y+O)}}),e.version||(e.version="1.2.0");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 us,r as Hl}from"./static/esm/971f1b2c.js";import{$ as xo,A as $l,At
993
993
  __amdEnv.syncRequire = syncRequire;
994
994
  __amdEnv.diagnosticsBuffer = diagBuffer;
995
995
  })();
996
- `,r=new Function("__amdEnv",n);r(e),typeof e.require=="function"&&typeof e.require.config=="function"&&e.require.config({baseUrl:"./",paths:{core:"useblocks-core.facd6272.js",po:"useblocks-po.facd6272.js",monaco:"static/monaco/index.CO7s5UdA.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var o=function(m){var u,f=function(){return u||(u=Promise.resolve().then(m))};return{then:function(g,v){return f().then(g,v)},catch:function(g){return f().catch(g)},finally:function(g){return f().finally(g)}}},i=o(function(){return e.require(["__delivery__/libs"]).then(function(m){return m[0]})});t.React=o(function(){return i.then(function(m){return m.React})}),t.ReactDom=o(function(){return i.then(function(m){return m.ReactDom})}),t.ReactDomClient=o(function(){return i.then(function(m){return m.ReactDomClient})}),t.ReactJsxRuntime=o(function(){return i.then(function(m){return m.ReactJsxRuntime})}),t.ReactJsxDevRuntime=o(function(){return i.then(function(m){return m.ReactJsxDevRuntime})}),t.AntDesignIconBase=o(function(){return i.then(function(m){return m.AntDesignIconBase})}),t.AntDesignCssinjs=o(function(){return i.then(function(m){return m.AntDesignCssinjs})}),t.Classnames=o(function(){return i.then(function(m){return m.Classnames})}),t.Dayjs=o(function(){return i.then(function(m){return m.Dayjs})});var s=o(function(){return Promise.all([i]).then(function(m){var u=m[0]||Object.create(null),f=Object.create(null);for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(f[g]=u[g]);for(var v in f)Object.prototype.hasOwnProperty.call(f,v)&&(t[v]=f[v]);return f})}),a={Uuid:"the shared `uuid` package was removed from the editor runtime; bundle `uuid` into the plugin or use `crypto.randomUUID()`"},l=["then","toString","valueOf","constructor","inspect","$$typeof"];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&t[c]===void 0&&(t[c]=(function(m,u){return new Proxy(Object.create(null),{get:function(f,g){if(!(typeof g=="symbol"||l.indexOf(g)!==-1))throw new Error("[shared-runtime] "+m+"."+String(g)+" is not available: "+u+".")}})})(c,a[c]));var d={},p={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/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 'useblocks/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] `useblocks-ui-kit` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/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] `useblocks-ui-kit/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/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."},b={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] `useblocks-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] `useblocks-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."},E=Object.create(null),w=function(m){for(var u=String(m&&m.stack||"").split(`
997
- `),f="",g=0;g<u.length;g+=1){var v=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(u[g]);if(v){if(!f){f=v[1];continue}if(v[1]!==f)return v[1]}}return""},I=function(m){var u=w(new Error(m)),f=u?m+" Requested by: "+u+".":m;return e.__compatMissingReason=f,f};if(e.registerCompat=function(m){if(!(!m||typeof m!="object"))for(var u in m)Object.prototype.hasOwnProperty.call(m,u)&&(E[u]=m[u])},e.__compatPending){for(var y=0;y<e.__compatPending.length;y+=1)e.registerCompat(e.__compatPending[y]);e.__compatPending=void 0}for(var R in p)Object.prototype.hasOwnProperty.call(p,R)&&(function(m,u,f){var g=!1,v=function(){if(!(m in E))throw new Error(I(u));return E[m]};Object.defineProperty(t,m,{configurable:!0,enumerable:!0,get:function(){var C=v();return g||(g=!0),C},set:function(C){E[m]=C}}),Object.defineProperty(d,m,{configurable:!0,enumerable:!0,get:v,set:function(C){E[m]=C}})})(R,p[R],b[R]);var P=t;for(var N in d)Object.prototype.hasOwnProperty.call(d,N)&&(P===t&&(P=Object.create(t)),Object.defineProperty(P,N,Object.getOwnPropertyDescriptor(d,N)));var D=s,k=[],_=function(){for(var m=[],u=0;u<k.length;u+=1)(function(f){var g=t[f];g&&typeof g.then=="function"&&m.push(Promise.resolve(g).then(function(v){t[f]=v}))})(k[u]);return Promise.all(m)},S=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(_).then(function(){if(typeof S=="function")return S.call(e)})},typeof e.define=="function"){let m=function(u){if(!u||typeof u!="object"&&typeof u!="function"||u.__esModule)return u;if(T){var f=T.get(u);if(f)return f}var g=Object.create(null);Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var v=Reflect.ownKeys(u),C=0;C<v.length;C++){var x=v[C];if(x!=="__esModule"){var O=Object.getOwnPropertyDescriptor(u,x);O&&Object.defineProperty(g,x,O)}}return Object.prototype.hasOwnProperty.call(g,"default")||Object.defineProperty(g,"default",{enumerable:!0,value:u,writable:!1}),T&&T.set(u,g),g};var T=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var u=P.React;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.React)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.React;return m(g)})}),e.define("useblocks/runtime/react",[],function(){var u=P.React;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.React)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.React;return m(g)})}),e.define("react-dom",[],function(){var u=P.ReactDom;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactDom)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactDom;return m(g)})}),e.define("useblocks/runtime/react-dom",[],function(){var u=P.ReactDom;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactDom)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactDom;return m(g)})}),e.define("react-dom/client",[],function(){var u=P.ReactDomClient;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactDomClient)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactDomClient;return m(g)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var u=P.ReactDomClient;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactDomClient)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactDomClient;return m(g)})}),e.define("react/jsx-runtime",[],function(){var u=P.ReactJsxRuntime;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactJsxRuntime)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactJsxRuntime;return m(g)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var u=P.ReactJsxRuntime;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactJsxRuntime)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactJsxRuntime;return m(g)})}),e.define("react/jsx-dev-runtime",[],function(){var u=P.ReactJsxDevRuntime;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactJsxDevRuntime)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactJsxDevRuntime;return m(g)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var u=P.ReactJsxDevRuntime;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactJsxDevRuntime)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactJsxDevRuntime;return m(g)})}),e.define("antd",[],function(){var u=P.Antd;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Antd)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Antd;return m(g)})}),e.define("useblocks/runtime/antd",[],function(){var u=P.Antd;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Antd)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Antd;return m(g)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var u=P.AntDesignIconBase;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignIconBase)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignIconBase;return m(g)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var u=P.AntDesignIconBase;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignIconBase)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignIconBase;return m(g)})}),e.define("@ant-design/icons",[],function(){var u=P.AntDesignIcons;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignIcons)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignIcons;return m(g)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var u=P.AntDesignIcons;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignIcons)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignIcons;return m(g)})}),e.define("@ant-design/cssinjs",[],function(){var u=P.AntDesignCssinjs;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignCssinjs)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignCssinjs;return m(g)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var u=P.AntDesignCssinjs;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignCssinjs)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignCssinjs;return m(g)})}),e.define("classnames",[],function(){var u=P.Classnames;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Classnames)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Classnames;return m(g)})}),e.define("useblocks/runtime/classnames",[],function(){var u=P.Classnames;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Classnames)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Classnames;return m(g)})}),e.define("dayjs",[],function(){var u=P.Dayjs;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Dayjs)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Dayjs;return m(g)})}),e.define("useblocks/runtime/dayjs",[],function(){var u=P.Dayjs;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Dayjs)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Dayjs;return m(g)})}),e.define("useblocks-ui-kit",[],function(){var u=P.UiKit;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.UiKit)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.UiKit;return m(g)})}),e.define("useblocks/ui-kit",[],function(){var u=P.UiKit;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.UiKit)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.UiKit;return m(g)})}),e.define("useblocks/ui-kit/icons",[],function(){var u=P.UiKitIcons;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.UiKitIcons)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.UiKitIcons;return m(g)})}),e.define("useblocks-ui-kit/icons",[],function(){var u=P.UiKitIcons;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.UiKitIcons)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.UiKitIcons;return m(g)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Oc=new Function("url","return import(url)");function kc(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Jr(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function ys(e){return e.type==="umd"||e.resolve==="registry"}var xc="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 Mc(e){const t=Array.isArray(e)?e[0]:e;return Jr(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function Lc(e,t){const n=Mc(e),r=Jr(e)?e:void 0,o=t instanceof Error?t.message:String(t),i=r&&ys(r)&&!/compat/iu.test(o)?` ${xc}`:"",s=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${i}`);return s.cause=t,{name:n,url:r?.url,error:s}}function Nc(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var Fc=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(Jr(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(ys(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Oc(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let o;const i=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):Nc(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},s=()=>window.removeEventListener("error",i);window.addEventListener("error",i),r.onload=()=>{if(s(),o){n(o);return}t()},r.onerror=()=>{s(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const o=await this._resolveOrSkip(r);if(!o)continue;const i=this._createOrSkip(o.ctor,o.options);i&&!n.has(i)&&(n.add(i),t.push(i))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const a=await this._resolveOrSkip(s);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((s,a)=>{t.has(a)||r.push({key:a,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:a,plugin:l}=r[s];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const c=this._creationOrder.indexOf(l);c>=0&&this._creationOrder.splice(c,1)}const o=[],i=new Set;for(const{ctor:s,options:a}of n){const l=this._createOrSkip(s,a);l&&!i.has(l)&&(i.add(l),o.push(l))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let i,s=!1;const a=()=>{s||(s=!0,i&&clearTimeout(i),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(i=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,a),o(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),o=this._createPluginInstance(e,r),i=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:i}),o.required?.(),this._map.set(n,o),this._creationOrder.push(o),this._setupReadyPromise(o)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=Lc(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 kc(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const o of t){if(this._initializedPlugins.has(o))continue;const i=this._initializingPlugins.get(o);if(i){n.add(i);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const i of r)this._initializingPlugins.set(i,o);n.add(o),o.finally(()=>{for(const i of r)this._initializingPlugins.get(i)===o&&this._initializingPlugins.delete(i)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const o=this._options.openEarlyWindow?.();try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}finally{o?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(o){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:o})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}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)}))}},Bc=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const o of n)try{o.callback(t)}catch{}const r=n.filter(o=>!o.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(o=>(t.ctor=o,t.loading=void 0,this._notifyListeners(e,o),o));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!1};return r.push(o),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!0};return r.push(o),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(o=>o.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},jc=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()}},No=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 Uc(e,t){return t+e}function Hc(){return typeof performance>"u"?Date.now():Uc(performance.now(),performance.timeOrigin)}var $c="emailmaker:diagnostics",qc="diagnostics",Gc="diagnostics";function Fo(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Gc}=1`:e}var Fn;function Vc(){try{const e=new URLSearchParams(window.location.search).get(qc);return e===null?void 0:e!=="0"}catch{return}}function zc(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Wc(){try{const e=window.localStorage.getItem($c);return e===null?void 0:e==="1"}catch{return}}function Ot(){return Fn===void 0&&(Fn=typeof window>"u"?!1:Vc()??zc()??Wc()??!1),Fn}function Kc(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var ce={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"},u_=Object.values(ce),f_=[ce.canvasPainted,ce.canvasSettled,ce.appVisible,ce.editorVisible],Yc=5e3,Xc=3e3,Bo="diagnosticsStore",zt,bt;function jo(){return{marks:new No(Yc),resources:new No(Xc)}}function Es(){if(bt)return bt;const e=Qr();return e?(bt=e[Bo]??zt??jo(),e[Bo]=bt,zt=void 0,bt):(zt??=jo(),zt)}function ne(e,t){Ot()&&Es().marks.push({phase:e,at:Hc(),...t})}function Qr(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[Kc()];return e!==null&&typeof e=="object"?e:void 0}function Jc(e){const t=e.length,n=Es();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Qc(){const e=Qr();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Jc(e.diagnosticsBuffer)}var Zc="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Ne(){const e=new Error(Zc);return e.name="DestroyedInstanceError",e}function ed(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function hr(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const i=e,s=t;return i.length===s.length&&i.every((a,l)=>hr(a,s[l]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&hr(e[i],t[i]))}function _s(e,t){const n={watch(r){let o,i=!1;return e.watch(s=>{const a=t(s);i&&hr(o,a)||(o=a,i=!0,r(a))})},select(r){return _s(n,r)}};return n}function ge(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(i){t=i,n=!0;for(const s of Array.from(r))s(i)},watch(i){return r.add(i),n&&i(t),{dispose:()=>r.delete(i)}},select(i){return _s(o,i)}};return o}var td=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:ql.UrlEncoded,...t})},ws=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 nd(e){return String(e||"").trim()||void 0}var rd=class extends ue{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=nd(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)}},Zr=H("AppInitService");function od(e){return async()=>{const t=await e();return(await new td(t).app_init_create({})).data}}function id(e){e.injectFactory(Zr,(t,n)=>{if(n)return n;const r=new rd({options:e.getInstance(pe),isStandalone:()=>!!e.getInstance(De),resolveRestBaseUrl:o=>o?Mo(o):Mo()||void 0,setRestBaseUrl:o=>{e.getInstance(Gl)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:od(()=>e.getInstanceAsync(rc)),publish:o=>{e.inject(Be,o)}});return e.getInstance(G)?.addDisposable(r),r},!0)}var eo=H("documentSession.emailDocuments");function it(e){return e?.getInstance(eo)}var sd=H("RevisionServiceFlag");function Ss(e){return e.getOrCreateInstance(sd,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Is(e){return Ss(e).isEnabled()}var ad=H("EmailRightsResolver");function ld(e,t){const n=e.getInstance(ad);return n?n(t):!0}var Cs=H("EmailHistoryAvailabilityResolver");function cd(e){return e.getInstance(Cs)!==void 0}async function dd(e){const t=e.getInstance(Cs);if(!t)return!0;try{return await t()}catch{return!1}}var to={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Ts=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],As=2e4,ud=Ts.reduce((e,t)=>e+to[t],0),Rs=As+ud+3e3;function fd(e){return Ts.reduce((t,n)=>t+Ps(n,e),0)}function Ps(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:to[e]}function Ds(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:Rs}function Os(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:As}function Cn(e=Rs){return e+3e3}function ks(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var pd=()=>Cn();function hd(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function md(e){return t=>hd(e.getOrCreateInstance(j.BEFORE_SAVE_EMAIL,()=>new Fe).fire(t),pd())}function gd(e){return e!=null&&e!==""}var xs;function kt(e,t){return xs?.capture(e,t)}function vd(e,t){return xs?.captureMessage(e,t)}function bd(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Wt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Ie=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} "${Wt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Wt(this.oldText)}")`:`(replace@${this.oldPosition} "${Wt(this.oldText)}" with "${Wt(this.newText)}")`}};function Uo(e,t){return e===null||e.length===0?t:new yd(e,t).compress()}var yd=class Te{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[l,c]=Te._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(l),o=c;continue}if(r.newPosition<o.oldPosition){const[l,c]=Te._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(l),r=c;continue}let s,a;if(o.oldEnd===r.newEnd)s=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[l,c]=Te._splitPrev(r,o.oldLength);s=l,a=o,r=c,o=this._getCurr(++n)}else{const[l,c]=Te._splitCurr(o,r.newLength);s=r,a=l,r=this._getPrev(++t),o=c}this._result[this._resultLen++]=new Ie(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const i=Te._merge(this._result);return Te._removeNoOps(i)}_acceptCurr(t){this._result[this._resultLen++]=Te._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++]=Te._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 Ie(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Ie(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),o=t.newText.substr(n);return[new Ie(t.oldPosition,t.oldText,t.newPosition,r),new Ie(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new Ie(t.oldPosition,r,t.newPosition,t.newText),new Ie(t.oldPosition+n,o,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,o=t[0];for(let i=1;i<t.length;i++){const s=t[i];o.oldEnd===s.oldPosition?o=new Ie(o.oldPosition,o.oldText+s.oldText,o.newPosition,o.newText+s.newText):(n[r++]=o,o=s)}return n[r++]=o,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let o=0;o<t.length;o++){const i=t[o];i.oldText!==i.newText&&(n[r++]=i)}return n}};function Ed(e){return new Ie(e.newPosition,e.newText,e.oldPosition,e.oldText)}function _d(e){return e.map(Ed)}function Ho(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function wd(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const o=t[r];n=n.slice(0,o.oldPosition)+o.newText+n.slice(o.oldEnd)}return n}function Sd(e,t,n){let r=0;const o=e.start===e.end;for(const i of t){const s=i.newLength-i.oldLength;if(i.oldLength===0){const a=i.oldPosition;if(o&&a===e.start)r+=n==="after"?s:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=s)}continue}if(o){if(e.start>=i.oldEnd)r+=s;else if(e.start>i.oldPosition)return null;continue}if(e.start>=i.oldEnd)r+=s;else if(e.end>i.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var Ye=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},$o=0,Id=Math.random().toString(36).slice(2,8);function Cd(){return $o+=1,`doc-${Id}-${$o}`}function Td(e){const t=e.createBuffer(),n=e.docId??Cd();let r=e.serverId??null,o=0,i=null,s=e.attributes??{};const a=new Set;let l=!1,c=!1,d;const p=new Set;let b=null;const E=()=>(b?.version!==o&&(b={version:o,value:t.read()}),b.value),w=I=>Object.entries(I).some(([y,R])=>s[y]!==R);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:i,attributes:s}),getContent:E,mutate(I,{source:y}){if(l)return o;const R=I.changes?.length?I.changes:void 0,P=R?wd(E(),R):I.content!==void 0?I.content:void 0,N=P!==void 0&&P!==E(),D=I.attributes!==void 0&&w(I.attributes);if(!N&&!D)return o;const k=!(o>(i??-1)),_=D?Object.keys(I.attributes).filter(T=>s[T]!==I.attributes[T]):[];N&&t.write(P),D&&(s={...s,...I.attributes}),o+=1,y!=="user"&&k&&(i=o);const S={source:y,version:o,changes:R,...N?{content:!0}:{},..._.length>0?{attributes:_}:{}};return a.forEach(T=>T(S)),o},markSaved(I,y){const R={serverId:r,savedVersion:i};y!==void 0&&(r=y),(i===null||I>i)&&(i=I),(R.serverId!==r||R.savedVersion!==i)&&a.forEach(P=>P({source:"system",version:o}))},markUnsaved(){l||i===null||i<o||(i=o-1,a.forEach(I=>I({source:"system",version:o})))},markReady(){c||d!==void 0||(c=!0,p.forEach(I=>I.resolve()),p.clear(),a.forEach(I=>I({source:"system",version:o})))},isReady:()=>c,markFailed(I){c||d!==void 0||l||(d=I,p.forEach(y=>y.reject(new Ye(I))),p.clear(),a.forEach(y=>y({source:"system",version:o})))},failure:()=>d,whenReady(){return c?Promise.resolve():d!==void 0?Promise.reject(new Ye(d)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((I,y)=>{p.add({resolve:I,reject:y})})},subscribe(I){return a.add(I),()=>a.delete(I)},isNew:()=>r===null,isDirty:()=>o>(i??-1),isDisposed:()=>l,dispose(){l=!0,p.forEach(I=>I.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),p.clear(),a.clear(),t.dispose()}}}var Ad=500,Rd=100,Bn=0;function Pd(e,t={}){const n=t.groupIntervalMs??Ad,r=t.maxSteps??Rd,o=t.now??(()=>0);let i=[],s=0,a=Bn+=1,l=null,c=!1,d=!1,p=!1;const b=new Set,E=()=>b.forEach(_=>_()),w=(_,S)=>{if(_.length){d=!0;try{e.mutate({changes:_},{source:S})}finally{d=!1}}},I=_=>w(_,"user"),y=_=>{const S=o();c&&l!==null&&S-l<n?i[s-1]=Uo(i[s-1],_):(i=i.slice(0,s),i.push(_),s=i.length,c=!0,i.length>r&&(i=i.slice(i.length-r),s=i.length,a=Bn+=1)),l=S,E()},R=()=>{c=!1,l=null},P=_=>{if(!_.length)return;const S=i.length>s;S&&(i=i.slice(0,s)),s>0&&(i[s-1]=Uo(i[s-1],_)),R(),S&&E()},N=e.subscribe(({source:_,changes:S})=>{if(!(p||d||!S?.length)){if(_==="remote"){D();return}if(_!=="user"){P(S);return}y(S)}}),D=()=>{i=[],s=0,R(),a=Bn+=1,E()},k=()=>{if(s===0)return!1;const _=_d(i[s-1]);return Ho(e.getContent(),_)?(I(_),s-=1,R(),!0):(i=i.slice(0,s-1),s=i.length,R(),E(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<i.length,undo(){k()&&E()},redo(){if(!(s>=i.length)){if(!Ho(e.getContent(),i[s])){i=i.slice(0,s),R(),E();return}I(i[s]),s+=1,R(),E()}},clear:D,applyWithoutHistory(_){const S=e.get().version;if(w(_,"system"),e.get().version===S){R();return}P(_)},getPast:_=>i.slice(0,s).reverse().slice(0,_),getFuture:_=>i.slice(s).reverse().slice(0,_),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(_){if(_.stackId!==a||_.index>s)return!1;for(;s>_.index;)if(!k())return E(),!1;return E(),!0},subscribe(_){return b.add(_),()=>b.delete(_)},dispose(){p=!0,N(),b.clear(),i=[],s=0}}}var Dd=["edit","move","resize","insert"];function jn(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Od(e){return typeof e=="string"?e:null}function kd(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function xd(e){return Dd.includes(e)?e:null}function Md(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:Od(t.originId),changeId:jn(t.changeId),rev:jn(t.rev),baseRev:jn(t.baseRev),expected:kd(t.expected),intent:xd(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var Tt=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},Ms=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleEmailAutosave did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Tn=class extends Error{timeoutMs;constructor(e,t="handleSaveEmail",n="email"){super(`[useblocks] ${t} did not respond within ${e}ms — the ${n} was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function Ld(){return typeof navigator<"u"&&navigator.onLine===!1}function Nd(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const o=r.data;typeof r.data=="object"&&o.error!=null&&t.push(o.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function Ls(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 Ls(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 Fd(e){return Ld()?!0:Nd(e).some(Ls)}var Ns=new WeakSet,Fs=new WeakMap;function Bs(e){typeof e=="object"&&e!==null&&Ns.add(e)}function Bd(e,t){typeof e=="object"&&e!==null&&Fs.set(e,t)}function jd(e){return typeof e=="object"&&e!==null?Fs.get(e):void 0}function Ud(e){return e instanceof Tn||e instanceof Ms||typeof e=="object"&&e!==null&&Ns.has(e)}function Hd(e){return e instanceof Tt||Ud(e)}function $d(e){return!Hd(e)&&Fd(e)}var js="draft";function nt(e){return e==null||e===""?js:String(e)}function fn(e){return e==null||e===""?`${mr}${js}`:`${mr}${String(e)}`}var mr="block:";function te(e){return e?.startsWith(mr)===!0}function st(e){return te(e.sessionKey())?void 0:e.current()}function ze(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return ne(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(ne(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const i=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw zr(o)?(`${e}`,{...n}):(`${e}`,{error:ks(o),...n},void 0),o})}var qd=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function Gd(e){const t=e?.trim()??"";if(!qd.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function At(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function no(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Vd(e,t={}){const n=At((e??[]).filter(r=>r?.html?.trim()));return no(n,t)?n:null}function zd(e,t){const n=Date.parse(At(e)?.modified??""),r=Vd(e),o=Date.parse(r?.modified??""),i=t===void 0||Number.isFinite(o)&&o>t,s=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:i?r:null,...s.length?{latestAt:Math.max(...s)}:{}}}function qo(e,t,n){const r=At((e??[]).filter(l=>l?.html?.trim())),o=Date.parse(r?.modified??""),i=Date.parse(At((n??[]).filter(l=>l?.html?.trim()))?.modified??""),s=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(i>o),a=[Date.parse(At(e??[])?.modified??""),t??NaN].filter(l=>Number.isFinite(l));return{autosave:s&&no(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Wd({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Us=e=>e.replace(/\r\n?/g,`
998
- `),Go=["recovery","plugin","rest"],Kd=["subject","preheader"];function Yd(e){let t={},n;for(let o=Go.length-1;o>=0;o--){const i=e.get(Go[o]);i&&(i.attributes&&(t={...t,...i.attributes}),i.content!==void 0&&(n=i.content))}const r=e.get("plugin")?.attributes;for(const o of Kd){const i=r?.[o];typeof i=="string"&&i!==""&&(t={...t,[o]:i})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function ro(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Us(t.content):void 0,o=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...o?{changes:[new Ie(0,n,0,r)]}:{}},{source:"remote"})}var Un=e=>typeof e=="string"?e.trim():"";function Xd(e,t,n,r){const{version:o,attributes:i}=e.get(),s=i,a=r==="snapshot"||r==="anchor",l=a?s.author:void 0,c=a?s.date_gmt:void 0,d=Un(s.title)||Un(s.subject)||Un(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:d,subject:s.subject,preheader:s.preheader,description:s.description,common_styles:s.common_styles||"",meta:s.meta,utm_parameters:s.utm_parameters,parent_email:s.parent_email,is_template:s.is_template||!1,is_inited:s.is_inited,tags:s.tags,emailtags:s.emailtags,group:s.group,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,...l!=null&&l!==""?{author:l}:{},...c?{excerpt:c}:{}}}}var Jd=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Qd(e){const t={};for(const n of Jd)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Zd(e,t,n,r,o){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(o);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,o):t.saveAutosave(r,o)}function Oe(e,t=!1){const n={};for(const r of Object.keys(e)){let o=e[r];o!==void 0&&!(typeof o=="number"&&Number.isNaN(o))&&(t&&typeof o=="object"&&o!==null&&(o=Oe(o)),n[r]=o)}return n}function eu(e){return typeof e=="string"&&e.includes("autosave")}var tu=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Hs(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!tu.has(t))):{}}function ft(e,t,n={}){e&&e.mutate({attributes:nu(e.get().attributes,t)},{source:n.source??"user"})}function nu(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function oo(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function ru(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function $s(e){if(!e)return null;const t=Hs(e);return e.common_styles!==void 0&&(t.common_styles=ru(e.common_styles)),oo(e.html,t)}function qs(e){return e?oo(e.html,Oe(Hs(e))):null}var ou=["common_styles","subject","preheader","meta"];function Vo(e){if(!e?.html?.trim())return null;const t={};for(const n of ou)iu(n,e[n])&&(t[n]=e[n]);return oo(e.html,t)}function iu(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 su=["modified","lock"];function au(e){if(!e)return null;const t={};for(const n of su)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var lu=10,cu=(e,t)=>e.key===t.key&&du(e.serverId,t.serverId),du=(e,t)=>e==null||e===t;function uu(e){return typeof e?.then=="function"}var zo=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Gs=e=>{e.request.serverId!=null&&!io(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},fu=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),io=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Wo=(e,t)=>t?.content!==void 0&&Wd({hasUnsavedUserEdit:io(e)})==="skip",Ko=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},pu=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()}),hu=(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))},mu=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,i])=>e.attributes[o]!==i)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},gu=e=>{const t=Yd(e.reports),n=mu(e.lastMerged,t);e.lastMerged=t,n&&(ro(e.document,n),Gs(e))},Hn=(e,t)=>{if(!e.ready&&!io(e)){gu(e);return}ro(e.document,t)},vu=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 bu(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:i,canEdit:s,notifyBeforeSave:a,onAdapterError:l,onTimeout:c}=e;let d,p;const b=new Set,E=new Set,w=()=>b.forEach(h=>h()),I=(h,A)=>{if(!(h.closed||h.ready)){if(h.error!==void 0){h.document.markFailed(h.error),h.document.get().docId;return}Gs(h),h.ready=!0,h.document.markReady(),h.document.get().docId,[...h.reports.keys()]}},y=(h,A,F)=>{l?.(A.id,F),!(!A.required||h.closed)&&(h.error=F,h.document.get().docId,A.id,w())},R=(h,A)=>{const F=new Set(A.map(B=>B.id));A.forEach(B=>{B.watch&&h.watchers.push(B.watch(M=>h.closed?!1:h.ready&&(Wo(h,M)||h.contentShown===!0&&M?.content!==void 0)?(h.document.get().docId,B.id,!1):(M&&h.reports.set(B.id,M),Hn(h,M),M?.content!==void 0&&(h.showFill=void 0),!0)))});const V=(B,M)=>{if(!h.closed){if(!B.required&&Wo(h,M)){h.document.get().docId,B.id,B.loaded?.(!1);return}M&&(h.reports.set(B.id,M),B.id==="plugin"&&Ko(h,M)),Hn(h,M),B.loaded?.(M!==null)}},q=()=>{F.size>0||h.closed||(zo(h),I(h,[]))},W=[];if(A.forEach(B=>{let M;try{M=B.load()}catch($){y(h,B,$),F.delete(B.id);return}if(uu(M)){W.push({id:B.id,required:B.required,load:()=>M,...B.loaded?{loaded:$=>B.loaded?.($)}:{}});return}V(B,M),F.delete(B.id)}),W.length===0){q();return}h.timer=setTimeout(()=>{h.timer=void 0,c?.([...F]),h.document.get().docId,[...F],I(h,[...F])},n),h.timer.unref?.(),W.forEach(B=>{B.load().then(M=>V(B,M)).catch(M=>{y(h,B,M)}).finally(()=>{F.delete(B.id),q()})})},P=async(h,A,F)=>{if(F==="snapshot"||F==="anchor")return;const V=i?.();if(V)return V.resolve({project:A.project??h.project,tags:(h.tags??[]).map(q=>({name:q}))})},N=h=>{if(h.lock===!0&&s?.(h)===!1)return new Tt("locked");const A=h.tags?.length??0,F=h.emailtags?.length??0;if(Math.max(A,F)>lu)return new Tt("too-many-tags")},D=(h,A)=>{const F=h.document.get().serverId;A||F==null||(h.recoveryFacts={emailId:F,historyLoaded:!0,isRecovering:!1},te(h.request.key)||(h.request={...h.request,key:nt(F),serverId:F}))},k=(h,A,F)=>{if(h.closed||F?.id==null)return;const V=h.document.get().serverId,q=V!=null;q&&V!==String(F.id)||(h.document.markSaved(A,String(F.id)),D(h,q),h.document.get().serverId,w())},_=async(h,A,F)=>{try{await h.document.whenReady()}catch(M){return h.saveError=M,h.saveFailures+=1,h.failedIntent=A,h.saveFailures,!1}if(h.closed)return!1;const V=N(h.document.get().attributes);if(V)return h.saveError=V,h.saveFailures+=1,h.failedIntent=A,V.reason,w(),!1;if(a&&(await a(vu(h)).catch(()=>{}),h.closed))return!1;if(fu(h))return A==="snapshot"||(h.saveError=new Tt("empty-content"),h.saveFailures+=1,h.failedIntent=A,w()),!1;let q;try{q=await P(h.document.get().attributes,F,A)}catch(M){return h.saveError=M,h.saveFailures+=1,h.failedIntent=A,h.saveFailures,w(),!1}if(h.closed)return!1;const{payload:W,version:B}=Xd(h.document,F,q,A);h.document.get().docId;try{const M=h.document.get().serverId!=null,$=await Zd(r(),o(h.request.key),A,h.document.get().serverId,W);if(h.closed)return!0;let Y;if(A==="snapshot"||A==="anchor"){const Z=$?.modified!=null?Date.parse($.modified):NaN;Y=Number.isFinite(Z)?Z:Date.now(),h.snapshotVersion=B,h.lastRevisionAt=Y}else h.document.markSaved(B,$?.id!=null?String($.id):void 0),h.savedContent=W.html;D(h,M),h.saveError=void 0,h.saveFailures=0,h.failedIntent=void 0,h.document.get().serverId,w();const Q={intent:A,serverId:h.document.get().serverId,created:!M,...Y!==void 0?{revisionAt:Y}:{}};return E.forEach(Z=>Z(Q)),!0}catch(M){return(A==="publish"||A==="materialize")&&jd(M)?.then($=>k(h,B,$)),h.saveError=M,h.saveFailures+=1,h.failedIntent=A,h.saveFailures,w(),!1}},S=h=>{h.closed=!0,h.watchers.forEach(A=>A()),h.watchers=[],zo(h),h.history.dispose(),h.document.dispose()},T=()=>{d&&(S(d),d=void 0)},m=()=>{p&&(S(p),p=void 0)},u=(h,A,F)=>{let V=!1;A.show&&(h.show?.id!==A.show.id||h.show.token!==A.show.token)&&(h.show=A.show,V=!0,{docId:h.document.get().docId,...A.show});const q=F==="show"?qs(A.patch):null;q&&(h.reports.set("plugin",q),Ko(h,q),Hn(h,q),hu(h,q)),V&&w()},f=(h,A={})=>C(d,h,A),g=()=>d&&te(d.request.key??"")?p:d,v=h=>({error:h?.saveError,failures:h?.saveFailures??0,saving:h?.saving===!0,failedIntent:h?.failedIntent}),C=(h,A,F)=>!h||h.closed||A==="materialize"&&h.document.get().serverId!=null?Promise.resolve(!1):h.saving?A==="snapshot"||A==="materialize"?Promise.resolve(!1):(h.inFlight??Promise.resolve(!1)).then(()=>C(h,A,F)):(h.saving=!0,w(),h.inFlight=_(h,A,F).finally(()=>{h.saving=!1,h.inFlight=void 0,d===h&&!h.closed&&w()}),h.inFlight),x=(h,A="open",F=!1)=>{if(d&&!d.closed&&A!=="new"&&cu(d.request,h))return u(d,h,A),d.document;T(),F||m();const V=Td({createBuffer:()=>bd(""),serverId:h.serverId??null}),q={request:h,show:h.show,document:V,history:Pd(V,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return d=q,q.watchers.push(pu(q)),V.get().docId,h.serverId,R(q,t(h,{publishRecoveryFacts(W){q.closed||(q.recoveryFacts=W,w())},readShownContent:()=>q.closed?null:q.document.getContent()})),w(),V},O=(h,A,F)=>({key:te(h)?h:fn(h),serverId:A?.id!=null?String(A.id):null,email:A,show:F});return{openWith:x,open:(h,A={})=>x({key:nt(h),serverId:h,email:A.email,patch:A.patch,show:A.show},"open"),openDraft:(h,A={})=>x({key:nt(void 0),serverId:null,email:h,patch:A.patch,show:A.show},"open"),startNewDraft:(h,A={})=>x({key:nt(void 0),serverId:null,email:h,patch:A.patch,show:A.show},"new"),reload:(h,A={})=>x({key:nt(h),serverId:h,email:A.email,patch:A.patch,show:A.show},"new"),openBlock:(h,A,F)=>x(O(h,A,F),"open"),reloadBlock:(h,A,F)=>x(O(h,A,F),"new"),openBlockOver:(h,A)=>{const F=O(h,A);return d&&!d.closed&&d.request.key===F.key?d.document:(d&&!d.closed&&!te(d.request.key)&&(m(),p=d,d=void 0),x(F,"open",!0))},resumeSuspended:()=>{if(p)return T(),d=p,p=void 0,w(),d.document},hasSuspended:()=>!!p,suspendedDocument:()=>p?.document,show:(h,A)=>{const F=d;if(!(!F||F.closed))return x({...F.request,patch:h,show:A},"show")},current:()=>d?.document,noteServerFacts:({serverId:h,block:A},F)=>{const V=d;!V||V.closed||V.request.serverId!==h||te(V.request.key??"")===A&&ro(V.document,au(F))},save:f,saveEmail:(h,A={})=>C(g(),h,A),saveState:()=>v(d),emailSaveState:()=>v(g()),revisionFacts(){if(!d)return;const h=d.revisionFactsSnapshot;return h&&h.snapshotVersion===d.snapshotVersion&&h.lastRevisionAt===d.lastRevisionAt?h:(d.revisionFactsSnapshot={snapshotVersion:d.snapshotVersion,lastRevisionAt:d.lastRevisionAt},d.revisionFactsSnapshot)},recoveryFacts:()=>d?.recoveryFacts,history:()=>d?.history,forcedHeaders:()=>d?.forcedHeaders,beginForcedHeaders(h){d&&!d.closed&&(d.forcedHeaders=h)},endForcedHeaders(){for(const h of[d,p])h&&(h.forcedHeaders=void 0)},onSaved(h){return E.add(h),()=>E.delete(h)},showFacts:()=>d?.show,shownHeaders:()=>({...d?.shownHeaders}),showFill:()=>d?.showFill,beginShowFill(h){d&&!d.closed&&(d.showFill={showId:h,codeEdits:0})},noteCodeEdit(){d?.showFill&&(d.showFill.codeEdits+=1)},endShowFill(h){for(const A of[d,p])A?.showFill?.showId===h&&(A.showFill=void 0)},sessionKey:()=>d?.request.key,openError:()=>d?.error,subscribe(h){return b.add(h),()=>b.delete(h)},close(){!d&&!p||(T(),m(),w())}}}var so=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function ao(e){if(e instanceof so)return e.reason;if(e instanceof Ye)return ao(e.reason)}function yu(e){const t=e instanceof Ye?e.reason:e;return t instanceof so&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Eu(e){const t=ao(e);return t==="forbidden"||t==="not-found"}function _u(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new so("not-found");return $s(n)}}}var Vs=H("EmailPort");function wu(e){return e.getInstance(Vs)}function Su(e,t){e.inject(Vs,t)}var zs=H("documentSession.restEmailPortFactories");function Ws(e){return e.getInstance(zs)!==void 0}function Je(e){const t=e.getInstance(zs);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var Iu=H("EmailTermsResolver");function Cu(e){return e.getInstance(Iu)}var Ks=H("EmailHistoryPort"),Tu=H("BlockHistoryPort");function Ys(e){return e.getInstance(Tu)}function Xs(e){return e.getInstance(Ks)}function Au(e,t){e.inject(Ks,t)}var Ru="em_autosave_pending";function pn(e){return`${Ru}_${e}`}function Pu(e,t){try{sessionStorage.setItem(pn(e),JSON.stringify(t))}catch{}}function Js(e){try{const t=sessionStorage.getItem(pn(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(pn(e)),null):n}catch{return null}}function _t(e){try{sessionStorage.removeItem(pn(e))}catch{}}var Du=2e3,Ou=5e3,ku=5,xu=5e3,Mu=4;function Lu(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Nu(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:"useblocks-core.71aea198.js",po:"useblocks-po.71aea198.js",monaco:"static/monaco/index.CO7s5UdA.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var o=function(m){var u,f=function(){return u||(u=Promise.resolve().then(m))};return{then:function(g,x){return f().then(g,x)},catch:function(g){return f().catch(g)},finally:function(g){return f().finally(g)}}},i=o(function(){return e.require(["__delivery__/libs"]).then(function(m){return m[0]})});t.React=o(function(){return i.then(function(m){return m.React})}),t.ReactDom=o(function(){return i.then(function(m){return m.ReactDom})}),t.ReactDomClient=o(function(){return i.then(function(m){return m.ReactDomClient})}),t.ReactJsxRuntime=o(function(){return i.then(function(m){return m.ReactJsxRuntime})}),t.ReactJsxDevRuntime=o(function(){return i.then(function(m){return m.ReactJsxDevRuntime})}),t.AntDesignIconBase=o(function(){return i.then(function(m){return m.AntDesignIconBase})}),t.AntDesignCssinjs=o(function(){return i.then(function(m){return m.AntDesignCssinjs})}),t.Classnames=o(function(){return i.then(function(m){return m.Classnames})}),t.Dayjs=o(function(){return i.then(function(m){return m.Dayjs})});var s=o(function(){return Promise.all([i]).then(function(m){var u=m[0]||Object.create(null),f=Object.create(null);for(var g in u)Object.prototype.hasOwnProperty.call(u,g)&&(f[g]=u[g]);for(var x in f)Object.prototype.hasOwnProperty.call(f,x)&&(t[x]=f[x]);return f})}),a={Uuid:"the shared `uuid` package was removed from the editor runtime; bundle `uuid` into the plugin or use `crypto.randomUUID()`"},l=["then","toString","valueOf","constructor","inspect","$$typeof"];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&t[c]===void 0&&(t[c]=(function(m,u){return new Proxy(Object.create(null),{get:function(f,g){if(!(typeof g=="symbol"||l.indexOf(g)!==-1))throw new Error("[shared-runtime] "+m+"."+String(g)+" is not available: "+u+".")}})})(c,a[c]));var d={},p={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/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 'useblocks/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] `useblocks-ui-kit` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/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] `useblocks-ui-kit/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/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."},v={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] `useblocks-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] `useblocks-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."},E=Object.create(null),w=function(m){for(var u=String(m&&m.stack||"").split(`
997
+ `),f="",g=0;g<u.length;g+=1){var x=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(u[g]);if(x){if(!f){f=x[1];continue}if(x[1]!==f)return x[1]}}return""},I=function(m){var u=w(new Error(m)),f=u?m+" Requested by: "+u+".":m;return e.__compatMissingReason=f,f};if(e.registerCompat=function(m){if(!(!m||typeof m!="object"))for(var u in m)Object.prototype.hasOwnProperty.call(m,u)&&(E[u]=m[u])},e.__compatPending){for(var b=0;b<e.__compatPending.length;b+=1)e.registerCompat(e.__compatPending[b]);e.__compatPending=void 0}for(var R in p)Object.prototype.hasOwnProperty.call(p,R)&&(function(m,u,f){var g=!1,x=function(){if(!(m in E))throw new Error(I(u));return E[m]};Object.defineProperty(t,m,{configurable:!0,enumerable:!0,get:function(){var O=x();return g||(g=!0),O},set:function(O){E[m]=O}}),Object.defineProperty(d,m,{configurable:!0,enumerable:!0,get:x,set:function(O){E[m]=O}})})(R,p[R],v[R]);var P=t;for(var F in d)Object.prototype.hasOwnProperty.call(d,F)&&(P===t&&(P=Object.create(t)),Object.defineProperty(P,F,Object.getOwnPropertyDescriptor(d,F)));var D=s,k=[],_=function(){for(var m=[],u=0;u<k.length;u+=1)(function(f){var g=t[f];g&&typeof g.then=="function"&&m.push(Promise.resolve(g).then(function(x){t[f]=x}))})(k[u]);return Promise.all(m)},S=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(_).then(function(){if(typeof S=="function")return S.call(e)})},typeof e.define=="function"){let m=function(u){if(!u||typeof u!="object"&&typeof u!="function"||u.__esModule)return u;if(T){var f=T.get(u);if(f)return f}var g=Object.create(null);Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var x=Reflect.ownKeys(u),O=0;O<x.length;O++){var y=x[O];if(y!=="__esModule"){var A=Object.getOwnPropertyDescriptor(u,y);A&&Object.defineProperty(g,y,A)}}return Object.prototype.hasOwnProperty.call(g,"default")||Object.defineProperty(g,"default",{enumerable:!0,value:u,writable:!1}),T&&T.set(u,g),g};var T=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var u=P.React;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.React)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.React;return m(g)})}),e.define("useblocks/runtime/react",[],function(){var u=P.React;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.React)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.React;return m(g)})}),e.define("react-dom",[],function(){var u=P.ReactDom;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactDom)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactDom;return m(g)})}),e.define("useblocks/runtime/react-dom",[],function(){var u=P.ReactDom;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactDom)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactDom;return m(g)})}),e.define("react-dom/client",[],function(){var u=P.ReactDomClient;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactDomClient)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactDomClient;return m(g)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var u=P.ReactDomClient;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactDomClient)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactDomClient;return m(g)})}),e.define("react/jsx-runtime",[],function(){var u=P.ReactJsxRuntime;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactJsxRuntime)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactJsxRuntime;return m(g)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var u=P.ReactJsxRuntime;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactJsxRuntime)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactJsxRuntime;return m(g)})}),e.define("react/jsx-dev-runtime",[],function(){var u=P.ReactJsxDevRuntime;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactJsxDevRuntime)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactJsxDevRuntime;return m(g)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var u=P.ReactJsxDevRuntime;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.ReactJsxDevRuntime)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.ReactJsxDevRuntime;return m(g)})}),e.define("antd",[],function(){var u=P.Antd;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Antd)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Antd;return m(g)})}),e.define("useblocks/runtime/antd",[],function(){var u=P.Antd;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Antd)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Antd;return m(g)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var u=P.AntDesignIconBase;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignIconBase)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignIconBase;return m(g)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var u=P.AntDesignIconBase;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignIconBase)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignIconBase;return m(g)})}),e.define("@ant-design/icons",[],function(){var u=P.AntDesignIcons;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignIcons)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignIcons;return m(g)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var u=P.AntDesignIcons;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignIcons)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignIcons;return m(g)})}),e.define("@ant-design/cssinjs",[],function(){var u=P.AntDesignCssinjs;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignCssinjs)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignCssinjs;return m(g)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var u=P.AntDesignCssinjs;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.AntDesignCssinjs)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.AntDesignCssinjs;return m(g)})}),e.define("classnames",[],function(){var u=P.Classnames;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Classnames)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Classnames;return m(g)})}),e.define("useblocks/runtime/classnames",[],function(){var u=P.Classnames;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Classnames)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Classnames;return m(g)})}),e.define("dayjs",[],function(){var u=P.Dayjs;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Dayjs)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Dayjs;return m(g)})}),e.define("useblocks/runtime/dayjs",[],function(){var u=P.Dayjs;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.Dayjs)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.Dayjs;return m(g)})}),e.define("useblocks-ui-kit",[],function(){var u=P.UiKit;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.UiKit)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.UiKit;return m(g)})}),e.define("useblocks/ui-kit",[],function(){var u=P.UiKit;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.UiKit)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.UiKit;return m(g)})}),e.define("useblocks/ui-kit/icons",[],function(){var u=P.UiKitIcons;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.UiKitIcons)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.UiKitIcons;return m(g)})}),e.define("useblocks-ui-kit/icons",[],function(){var u=P.UiKitIcons;return u&&typeof u.then=="function"?u.then(function(f){return f===void 0?D.then(function(g){return m(g.UiKitIcons)}):m(f)}):u!==void 0?m(u):D.then(function(f){var g=f.UiKitIcons;return m(g)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var Oc=new Function("url","return import(url)");function kc(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Jr(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function ys(e){return e.type==="umd"||e.resolve==="registry"}var xc="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 Mc(e){const t=Array.isArray(e)?e[0]:e;return Jr(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function Lc(e,t){const n=Mc(e),r=Jr(e)?e:void 0,o=t instanceof Error?t.message:String(t),i=r&&ys(r)&&!/compat/iu.test(o)?` ${xc}`:"",s=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${i}`);return s.cause=t,{name:n,url:r?.url,error:s}}function Nc(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var Fc=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(Jr(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(ys(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Oc(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let o;const i=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):Nc(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},s=()=>window.removeEventListener("error",i);window.addEventListener("error",i),r.onload=()=>{if(s(),o){n(o);return}t()},r.onerror=()=>{s(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const o=await this._resolveOrSkip(r);if(!o)continue;const i=this._createOrSkip(o.ctor,o.options);i&&!n.has(i)&&(n.add(i),t.push(i))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const a=await this._resolveOrSkip(s);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((s,a)=>{t.has(a)||r.push({key:a,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:a,plugin:l}=r[s];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const c=this._creationOrder.indexOf(l);c>=0&&this._creationOrder.splice(c,1)}const o=[],i=new Set;for(const{ctor:s,options:a}of n){const l=this._createOrSkip(s,a);l&&!i.has(l)&&(i.add(l),o.push(l))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let i,s=!1;const a=()=>{s||(s=!0,i&&clearTimeout(i),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(i=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,a),o(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),o=this._createPluginInstance(e,r),i=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:i}),o.required?.(),this._map.set(n,o),this._creationOrder.push(o),this._setupReadyPromise(o)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=Lc(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 kc(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const o of t){if(this._initializedPlugins.has(o))continue;const i=this._initializingPlugins.get(o);if(i){n.add(i);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const i of r)this._initializingPlugins.set(i,o);n.add(o),o.finally(()=>{for(const i of r)this._initializingPlugins.get(i)===o&&this._initializingPlugins.delete(i)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const o=this._options.openEarlyWindow?.();try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}finally{o?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(o){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:o})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}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)}))}},Bc=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const o of n)try{o.callback(t)}catch{}const r=n.filter(o=>!o.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(o=>(t.ctor=o,t.loading=void 0,this._notifyListeners(e,o),o));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!1};return r.push(o),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const o={callback:t,once:!0};return r.push(o),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(o=>o.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},jc=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()}},No=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 Uc(e,t){return t+e}function Hc(){return typeof performance>"u"?Date.now():Uc(performance.now(),performance.timeOrigin)}var $c="emailmaker:diagnostics",qc="diagnostics",Vc="diagnostics";function Fo(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Vc}=1`:e}var Fn;function Gc(){try{const e=new URLSearchParams(window.location.search).get(qc);return e===null?void 0:e!=="0"}catch{return}}function zc(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Wc(){try{const e=window.localStorage.getItem($c);return e===null?void 0:e==="1"}catch{return}}function Ot(){return Fn===void 0&&(Fn=typeof window>"u"?!1:Gc()??zc()??Wc()??!1),Fn}function Kc(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var ce={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"},u_=Object.values(ce),f_=[ce.canvasPainted,ce.canvasSettled,ce.appVisible,ce.editorVisible],Yc=5e3,Xc=3e3,Bo="diagnosticsStore",zt,bt;function jo(){return{marks:new No(Yc),resources:new No(Xc)}}function Es(){if(bt)return bt;const e=Qr();return e?(bt=e[Bo]??zt??jo(),e[Bo]=bt,zt=void 0,bt):(zt??=jo(),zt)}function ne(e,t){Ot()&&Es().marks.push({phase:e,at:Hc(),...t})}function Qr(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[Kc()];return e!==null&&typeof e=="object"?e:void 0}function Jc(e){const t=e.length,n=Es();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Qc(){const e=Qr();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Jc(e.diagnosticsBuffer)}var Zc="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Ne(){const e=new Error(Zc);return e.name="DestroyedInstanceError",e}function ed(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function hr(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const i=e,s=t;return i.length===s.length&&i.every((a,l)=>hr(a,s[l]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(i=>Object.prototype.hasOwnProperty.call(t,i)&&hr(e[i],t[i]))}function _s(e,t){const n={watch(r){let o,i=!1;return e.watch(s=>{const a=t(s);i&&hr(o,a)||(o=a,i=!0,r(a))})},select(r){return _s(n,r)}};return n}function ge(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(i){t=i,n=!0;for(const s of Array.from(r))s(i)},watch(i){return r.add(i),n&&i(t),{dispose:()=>r.delete(i)}},select(i){return _s(o,i)}};return o}var td=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:ql.UrlEncoded,...t})},ws=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 nd(e){return String(e||"").trim()||void 0}var rd=class extends ue{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=nd(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)}},Zr=H("AppInitService");function od(e){return async()=>{const t=await e();return(await new td(t).app_init_create({})).data}}function id(e){e.injectFactory(Zr,(t,n)=>{if(n)return n;const r=new rd({options:e.getInstance(pe),isStandalone:()=>!!e.getInstance(De),resolveRestBaseUrl:o=>o?Mo(o):Mo()||void 0,setRestBaseUrl:o=>{e.getInstance(Vl)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:od(()=>e.getInstanceAsync(rc)),publish:o=>{e.inject(Be,o)}});return e.getInstance(G)?.addDisposable(r),r},!0)}var eo=H("documentSession.emailDocuments");function it(e){return e?.getInstance(eo)}var sd=H("RevisionServiceFlag");function Ss(e){return e.getOrCreateInstance(sd,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Is(e){return Ss(e).isEnabled()}var ad=H("EmailRightsResolver");function ld(e,t){const n=e.getInstance(ad);return n?n(t):!0}var Cs=H("EmailHistoryAvailabilityResolver");function cd(e){return e.getInstance(Cs)!==void 0}async function dd(e){const t=e.getInstance(Cs);if(!t)return!0;try{return await t()}catch{return!1}}var to={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Ts=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],As=2e4,ud=Ts.reduce((e,t)=>e+to[t],0),Rs=As+ud+3e3;function fd(e){return Ts.reduce((t,n)=>t+Ps(n,e),0)}function Ps(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:to[e]}function Ds(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:Rs}function Os(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:As}function Cn(e=Rs){return e+3e3}function ks(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var pd=()=>Cn();function hd(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function md(e){return t=>hd(e.getOrCreateInstance(j.BEFORE_SAVE_EMAIL,()=>new Fe).fire(t),pd())}function gd(e){return e!=null&&e!==""}var xs;function kt(e,t){return xs?.capture(e,t)}function vd(e,t){return xs?.captureMessage(e,t)}function bd(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Wt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Ie=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} "${Wt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Wt(this.oldText)}")`:`(replace@${this.oldPosition} "${Wt(this.oldText)}" with "${Wt(this.newText)}")`}};function Uo(e,t){return e===null||e.length===0?t:new yd(e,t).compress()}var yd=class Te{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[l,c]=Te._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(l),o=c;continue}if(r.newPosition<o.oldPosition){const[l,c]=Te._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(l),r=c;continue}let s,a;if(o.oldEnd===r.newEnd)s=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[l,c]=Te._splitPrev(r,o.oldLength);s=l,a=o,r=c,o=this._getCurr(++n)}else{const[l,c]=Te._splitCurr(o,r.newLength);s=r,a=l,r=this._getPrev(++t),o=c}this._result[this._resultLen++]=new Ie(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const i=Te._merge(this._result);return Te._removeNoOps(i)}_acceptCurr(t){this._result[this._resultLen++]=Te._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++]=Te._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 Ie(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Ie(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),o=t.newText.substr(n);return[new Ie(t.oldPosition,t.oldText,t.newPosition,r),new Ie(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new Ie(t.oldPosition,r,t.newPosition,t.newText),new Ie(t.oldPosition+n,o,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,o=t[0];for(let i=1;i<t.length;i++){const s=t[i];o.oldEnd===s.oldPosition?o=new Ie(o.oldPosition,o.oldText+s.oldText,o.newPosition,o.newText+s.newText):(n[r++]=o,o=s)}return n[r++]=o,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let o=0;o<t.length;o++){const i=t[o];i.oldText!==i.newText&&(n[r++]=i)}return n}};function Ed(e){return new Ie(e.newPosition,e.newText,e.oldPosition,e.oldText)}function _d(e){return e.map(Ed)}function Ho(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function wd(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const o=t[r];n=n.slice(0,o.oldPosition)+o.newText+n.slice(o.oldEnd)}return n}function Sd(e,t,n){let r=0;const o=e.start===e.end;for(const i of t){const s=i.newLength-i.oldLength;if(i.oldLength===0){const a=i.oldPosition;if(o&&a===e.start)r+=n==="after"?s:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=s)}continue}if(o){if(e.start>=i.oldEnd)r+=s;else if(e.start>i.oldPosition)return null;continue}if(e.start>=i.oldEnd)r+=s;else if(e.end>i.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var Ye=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},$o=0,Id=Math.random().toString(36).slice(2,8);function Cd(){return $o+=1,`doc-${Id}-${$o}`}function Td(e){const t=e.createBuffer(),n=e.docId??Cd();let r=e.serverId??null,o=0,i=null,s=e.attributes??{};const a=new Set;let l=!1,c=!1,d;const p=new Set;let v=null;const E=()=>(v?.version!==o&&(v={version:o,value:t.read()}),v.value),w=I=>Object.entries(I).some(([b,R])=>s[b]!==R);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:i,attributes:s}),getContent:E,mutate(I,{source:b}){if(l)return o;const R=I.changes?.length?I.changes:void 0,P=R?wd(E(),R):I.content!==void 0?I.content:void 0,F=P!==void 0&&P!==E(),D=I.attributes!==void 0&&w(I.attributes);if(!F&&!D)return o;const k=!(o>(i??-1)),_=D?Object.keys(I.attributes).filter(T=>s[T]!==I.attributes[T]):[];F&&t.write(P),D&&(s={...s,...I.attributes}),o+=1,b!=="user"&&k&&(i=o);const S={source:b,version:o,changes:R,...F?{content:!0}:{},..._.length>0?{attributes:_}:{}};return a.forEach(T=>T(S)),o},markSaved(I,b){const R={serverId:r,savedVersion:i};b!==void 0&&(r=b),(i===null||I>i)&&(i=I),(R.serverId!==r||R.savedVersion!==i)&&a.forEach(P=>P({source:"system",version:o}))},markUnsaved(){l||i===null||i<o||(i=o-1,a.forEach(I=>I({source:"system",version:o})))},markReady(){c||d!==void 0||(c=!0,p.forEach(I=>I.resolve()),p.clear(),a.forEach(I=>I({source:"system",version:o})))},isReady:()=>c,markFailed(I){c||d!==void 0||l||(d=I,p.forEach(b=>b.reject(new Ye(I))),p.clear(),a.forEach(b=>b({source:"system",version:o})))},failure:()=>d,whenReady(){return c?Promise.resolve():d!==void 0?Promise.reject(new Ye(d)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((I,b)=>{p.add({resolve:I,reject:b})})},subscribe(I){return a.add(I),()=>a.delete(I)},isNew:()=>r===null,isDirty:()=>o>(i??-1),isDisposed:()=>l,dispose(){l=!0,p.forEach(I=>I.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),p.clear(),a.clear(),t.dispose()}}}var Ad=500,Rd=100,Bn=0;function Pd(e,t={}){const n=t.groupIntervalMs??Ad,r=t.maxSteps??Rd,o=t.now??(()=>0);let i=[],s=0,a=Bn+=1,l=null,c=!1,d=!1,p=!1;const v=new Set,E=()=>v.forEach(_=>_()),w=(_,S)=>{if(_.length){d=!0;try{e.mutate({changes:_},{source:S})}finally{d=!1}}},I=_=>w(_,"user"),b=_=>{const S=o();c&&l!==null&&S-l<n?i[s-1]=Uo(i[s-1],_):(i=i.slice(0,s),i.push(_),s=i.length,c=!0,i.length>r&&(i=i.slice(i.length-r),s=i.length,a=Bn+=1)),l=S,E()},R=()=>{c=!1,l=null},P=_=>{if(!_.length)return;const S=i.length>s;S&&(i=i.slice(0,s)),s>0&&(i[s-1]=Uo(i[s-1],_)),R(),S&&E()},F=e.subscribe(({source:_,changes:S})=>{if(!(p||d||!S?.length)){if(_==="remote"){D();return}if(_!=="user"){P(S);return}b(S)}}),D=()=>{i=[],s=0,R(),a=Bn+=1,E()},k=()=>{if(s===0)return!1;const _=_d(i[s-1]);return Ho(e.getContent(),_)?(I(_),s-=1,R(),!0):(i=i.slice(0,s-1),s=i.length,R(),E(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<i.length,undo(){k()&&E()},redo(){if(!(s>=i.length)){if(!Ho(e.getContent(),i[s])){i=i.slice(0,s),R(),E();return}I(i[s]),s+=1,R(),E()}},clear:D,applyWithoutHistory(_){const S=e.get().version;if(w(_,"system"),e.get().version===S){R();return}P(_)},getPast:_=>i.slice(0,s).reverse().slice(0,_),getFuture:_=>i.slice(s).reverse().slice(0,_),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(_){if(_.stackId!==a||_.index>s)return!1;for(;s>_.index;)if(!k())return E(),!1;return E(),!0},subscribe(_){return v.add(_),()=>v.delete(_)},dispose(){p=!0,F(),v.clear(),i=[],s=0}}}var Dd=["edit","move","resize","insert"];function jn(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Od(e){return typeof e=="string"?e:null}function kd(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function xd(e){return Dd.includes(e)?e:null}function Md(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:Od(t.originId),changeId:jn(t.changeId),rev:jn(t.rev),baseRev:jn(t.baseRev),expected:kd(t.expected),intent:xd(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var Tt=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},Ms=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleEmailAutosave did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Tn=class extends Error{timeoutMs;constructor(e,t="handleSaveEmail",n="email"){super(`[useblocks] ${t} did not respond within ${e}ms — the ${n} was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function Ld(){return typeof navigator<"u"&&navigator.onLine===!1}function Nd(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;if(r.data!=null){t.push(r.data);const o=r.data;typeof r.data=="object"&&o.error!=null&&t.push(o.error)}r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function Ls(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 Ls(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 Fd(e){return Ld()?!0:Nd(e).some(Ls)}var Ns=new WeakSet,Fs=new WeakMap;function Bs(e){typeof e=="object"&&e!==null&&Ns.add(e)}function Bd(e,t){typeof e=="object"&&e!==null&&Fs.set(e,t)}function jd(e){return typeof e=="object"&&e!==null?Fs.get(e):void 0}function Ud(e){return e instanceof Tn||e instanceof Ms||typeof e=="object"&&e!==null&&Ns.has(e)}function Hd(e){return e instanceof Tt||Ud(e)}function $d(e){return!Hd(e)&&Fd(e)}var js="draft";function nt(e){return e==null||e===""?js:String(e)}function fn(e){return e==null||e===""?`${mr}${js}`:`${mr}${String(e)}`}var mr="block:";function te(e){return e?.startsWith(mr)===!0}function st(e){return te(e.sessionKey())?void 0:e.current()}function ze(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return ne(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(ne(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const i=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw zr(o)?(`${e}`,{...n}):(`${e}`,{error:ks(o),...n},void 0),o})}var qd=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function Vd(e){const t=e?.trim()??"";if(!qd.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function At(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function no(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Gd(e,t={}){const n=At((e??[]).filter(r=>r?.html?.trim()));return no(n,t)?n:null}function zd(e,t){const n=Date.parse(At(e)?.modified??""),r=Gd(e),o=Date.parse(r?.modified??""),i=t===void 0||Number.isFinite(o)&&o>t,s=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:i?r:null,...s.length?{latestAt:Math.max(...s)}:{}}}function qo(e,t,n){const r=At((e??[]).filter(l=>l?.html?.trim())),o=Date.parse(r?.modified??""),i=Date.parse(At((n??[]).filter(l=>l?.html?.trim()))?.modified??""),s=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(i>o),a=[Date.parse(At(e??[])?.modified??""),t??NaN].filter(l=>Number.isFinite(l));return{autosave:s&&no(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Wd({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Us=e=>e.replace(/\r\n?/g,`
998
+ `),Vo=["recovery","plugin","rest"],Kd=["subject","preheader"];function Yd(e){let t={},n;for(let o=Vo.length-1;o>=0;o--){const i=e.get(Vo[o]);i&&(i.attributes&&(t={...t,...i.attributes}),i.content!==void 0&&(n=i.content))}const r=e.get("plugin")?.attributes;for(const o of Kd){const i=r?.[o];typeof i=="string"&&i!==""&&(t={...t,[o]:i})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function ro(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Us(t.content):void 0,o=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...o?{changes:[new Ie(0,n,0,r)]}:{}},{source:"remote"})}var Un=e=>typeof e=="string"?e.trim():"";function Xd(e,t,n,r){const{version:o,attributes:i}=e.get(),s=i,a=r==="snapshot"||r==="anchor",l=a?s.author:void 0,c=a?s.date_gmt:void 0,d=Un(s.title)||Un(s.subject)||Un(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:d,subject:s.subject,preheader:s.preheader,description:s.description,common_styles:s.common_styles||"",meta:s.meta,utm_parameters:s.utm_parameters,parent_email:s.parent_email,is_template:s.is_template||!1,is_inited:s.is_inited,tags:s.tags,emailtags:s.emailtags,group:s.group,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,...l!=null&&l!==""?{author:l}:{},...c?{excerpt:c}:{}}}}var Jd=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Qd(e){const t={};for(const n of Jd)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Zd(e,t,n,r,o){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(o);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,o):t.saveAutosave(r,o)}function Oe(e,t=!1){const n={};for(const r of Object.keys(e)){let o=e[r];o!==void 0&&!(typeof o=="number"&&Number.isNaN(o))&&(t&&typeof o=="object"&&o!==null&&(o=Oe(o)),n[r]=o)}return n}function eu(e){return typeof e=="string"&&e.includes("autosave")}var tu=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Hs(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!tu.has(t))):{}}function ft(e,t,n={}){e&&e.mutate({attributes:nu(e.get().attributes,t)},{source:n.source??"user"})}function nu(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function oo(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function ru(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function $s(e){if(!e)return null;const t=Hs(e);return e.common_styles!==void 0&&(t.common_styles=ru(e.common_styles)),oo(e.html,t)}function qs(e){return e?oo(e.html,Oe(Hs(e))):null}var ou=["common_styles","subject","preheader","meta"];function Go(e){if(!e?.html?.trim())return null;const t={};for(const n of ou)iu(n,e[n])&&(t[n]=e[n]);return oo(e.html,t)}function iu(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 su=["modified","lock"];function au(e){if(!e)return null;const t={};for(const n of su)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var lu=10,cu=(e,t)=>e.key===t.key&&du(e.serverId,t.serverId),du=(e,t)=>e==null||e===t;function uu(e){return typeof e?.then=="function"}var zo=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Vs=e=>{e.request.serverId!=null&&!io(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},fu=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),io=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Wo=(e,t)=>t?.content!==void 0&&Wd({hasUnsavedUserEdit:io(e)})==="skip",Ko=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},pu=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()}),hu=(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))},mu=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,i])=>e.attributes[o]!==i)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},gu=e=>{const t=Yd(e.reports),n=mu(e.lastMerged,t);e.lastMerged=t,n&&(ro(e.document,n),Vs(e))},Hn=(e,t)=>{if(!e.ready&&!io(e)){gu(e);return}ro(e.document,t)},vu=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 bu(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:i,canEdit:s,notifyBeforeSave:a,onAdapterError:l,onTimeout:c}=e;let d,p;const v=new Set,E=new Set,w=()=>v.forEach(h=>h()),I=(h,C)=>{if(!(h.closed||h.ready)){if(h.error!==void 0){h.document.markFailed(h.error),h.document.get().docId;return}Vs(h),h.ready=!0,h.document.markReady(),h.document.get().docId,[...h.reports.keys()]}},b=(h,C,N)=>{l?.(C.id,N),!(!C.required||h.closed)&&(h.error=N,h.document.get().docId,C.id,w())},R=(h,C)=>{const N=new Set(C.map(B=>B.id));C.forEach(B=>{B.watch&&h.watchers.push(B.watch(M=>h.closed?!1:h.ready&&(Wo(h,M)||h.contentShown===!0&&M?.content!==void 0)?(h.document.get().docId,B.id,!1):(M&&h.reports.set(B.id,M),Hn(h,M),M?.content!==void 0&&(h.showFill=void 0),!0)))});const V=(B,M)=>{if(!h.closed){if(!B.required&&Wo(h,M)){h.document.get().docId,B.id,B.loaded?.(!1);return}M&&(h.reports.set(B.id,M),B.id==="plugin"&&Ko(h,M)),Hn(h,M),B.loaded?.(M!==null)}},q=()=>{N.size>0||h.closed||(zo(h),I(h,[]))},W=[];if(C.forEach(B=>{let M;try{M=B.load()}catch($){b(h,B,$),N.delete(B.id);return}if(uu(M)){W.push({id:B.id,required:B.required,load:()=>M,...B.loaded?{loaded:$=>B.loaded?.($)}:{}});return}V(B,M),N.delete(B.id)}),W.length===0){q();return}h.timer=setTimeout(()=>{h.timer=void 0,c?.([...N]),h.document.get().docId,[...N],I(h,[...N])},n),h.timer.unref?.(),W.forEach(B=>{B.load().then(M=>V(B,M)).catch(M=>{b(h,B,M)}).finally(()=>{N.delete(B.id),q()})})},P=async(h,C,N)=>{if(N==="snapshot"||N==="anchor")return;const V=i?.();if(V)return V.resolve({project:C.project??h.project,tags:(h.tags??[]).map(q=>({name:q}))})},F=h=>{if(h.lock===!0&&s?.(h)===!1)return new Tt("locked");const C=h.tags?.length??0,N=h.emailtags?.length??0;if(Math.max(C,N)>lu)return new Tt("too-many-tags")},D=(h,C)=>{const N=h.document.get().serverId;C||N==null||(h.recoveryFacts={emailId:N,historyLoaded:!0,isRecovering:!1},te(h.request.key)||(h.request={...h.request,key:nt(N),serverId:N}))},k=(h,C,N)=>{if(h.closed||N?.id==null)return;const V=h.document.get().serverId,q=V!=null;q&&V!==String(N.id)||(h.document.markSaved(C,String(N.id)),D(h,q),h.document.get().serverId,w())},_=async(h,C,N)=>{try{await h.document.whenReady()}catch(M){return h.saveError=M,h.saveFailures+=1,h.failedIntent=C,h.saveFailures,!1}if(h.closed)return!1;const V=F(h.document.get().attributes);if(V)return h.saveError=V,h.saveFailures+=1,h.failedIntent=C,V.reason,w(),!1;if(a&&(await a(vu(h)).catch(()=>{}),h.closed))return!1;if(fu(h))return C==="snapshot"||(h.saveError=new Tt("empty-content"),h.saveFailures+=1,h.failedIntent=C,w()),!1;let q;try{q=await P(h.document.get().attributes,N,C)}catch(M){return h.saveError=M,h.saveFailures+=1,h.failedIntent=C,h.saveFailures,w(),!1}if(h.closed)return!1;const{payload:W,version:B}=Xd(h.document,N,q,C);h.document.get().docId;try{const M=h.document.get().serverId!=null,$=await Zd(r(),o(h.request.key),C,h.document.get().serverId,W);if(h.closed)return!0;let X;if(C==="snapshot"||C==="anchor"){const Z=$?.modified!=null?Date.parse($.modified):NaN;X=Number.isFinite(Z)?Z:Date.now(),h.snapshotVersion=B,h.lastRevisionAt=X}else h.document.markSaved(B,$?.id!=null?String($.id):void 0),h.savedContent=W.html;D(h,M),h.saveError=void 0,h.saveFailures=0,h.failedIntent=void 0,h.document.get().serverId,w();const Q={intent:C,serverId:h.document.get().serverId,created:!M,...X!==void 0?{revisionAt:X}:{}};return E.forEach(Z=>Z(Q)),!0}catch(M){return(C==="publish"||C==="materialize")&&jd(M)?.then($=>k(h,B,$)),h.saveError=M,h.saveFailures+=1,h.failedIntent=C,h.saveFailures,w(),!1}},S=h=>{h.closed=!0,h.watchers.forEach(C=>C()),h.watchers=[],zo(h),h.history.dispose(),h.document.dispose()},T=()=>{d&&(S(d),d=void 0)},m=()=>{p&&(S(p),p=void 0)},u=(h,C,N)=>{let V=!1;C.show&&(h.show?.id!==C.show.id||h.show.token!==C.show.token)&&(h.show=C.show,V=!0,{docId:h.document.get().docId,...C.show});const q=N==="show"?qs(C.patch):null;q&&(h.reports.set("plugin",q),Ko(h,q),Hn(h,q),hu(h,q)),V&&w()},f=(h,C={})=>O(d,h,C),g=()=>d&&te(d.request.key??"")?p:d,x=h=>({error:h?.saveError,failures:h?.saveFailures??0,saving:h?.saving===!0,failedIntent:h?.failedIntent}),O=(h,C,N)=>!h||h.closed||C==="materialize"&&h.document.get().serverId!=null?Promise.resolve(!1):h.saving?C==="snapshot"||C==="materialize"?Promise.resolve(!1):(h.inFlight??Promise.resolve(!1)).then(()=>O(h,C,N)):(h.saving=!0,w(),h.inFlight=_(h,C,N).finally(()=>{h.saving=!1,h.inFlight=void 0,d===h&&!h.closed&&w()}),h.inFlight),y=(h,C="open",N=!1)=>{if(d&&!d.closed&&C!=="new"&&cu(d.request,h))return u(d,h,C),d.document;T(),N||m();const V=Td({createBuffer:()=>bd(""),serverId:h.serverId??null}),q={request:h,show:h.show,document:V,history:Pd(V,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return d=q,q.watchers.push(pu(q)),V.get().docId,h.serverId,R(q,t(h,{publishRecoveryFacts(W){q.closed||(q.recoveryFacts=W,w())},readShownContent:()=>q.closed?null:q.document.getContent()})),w(),V},A=(h,C,N)=>({key:te(h)?h:fn(h),serverId:C?.id!=null?String(C.id):null,email:C,show:N});return{openWith:y,open:(h,C={})=>y({key:nt(h),serverId:h,email:C.email,patch:C.patch,show:C.show},"open"),openDraft:(h,C={})=>y({key:nt(void 0),serverId:null,email:h,patch:C.patch,show:C.show},"open"),startNewDraft:(h,C={})=>y({key:nt(void 0),serverId:null,email:h,patch:C.patch,show:C.show},"new"),reload:(h,C={})=>y({key:nt(h),serverId:h,email:C.email,patch:C.patch,show:C.show},"new"),openBlock:(h,C,N)=>y(A(h,C,N),"open"),reloadBlock:(h,C,N)=>y(A(h,C,N),"new"),openBlockOver:(h,C)=>{const N=A(h,C);return d&&!d.closed&&d.request.key===N.key?d.document:(d&&!d.closed&&!te(d.request.key)&&(m(),p=d,d=void 0),y(N,"open",!0))},resumeSuspended:()=>{if(p)return T(),d=p,p=void 0,w(),d.document},hasSuspended:()=>!!p,suspendedDocument:()=>p?.document,show:(h,C)=>{const N=d;if(!(!N||N.closed))return y({...N.request,patch:h,show:C},"show")},current:()=>d?.document,noteServerFacts:({serverId:h,block:C},N)=>{const V=d;!V||V.closed||V.request.serverId!==h||te(V.request.key??"")===C&&ro(V.document,au(N))},save:f,saveEmail:(h,C={})=>O(g(),h,C),saveState:()=>x(d),emailSaveState:()=>x(g()),revisionFacts(){if(!d)return;const h=d.revisionFactsSnapshot;return h&&h.snapshotVersion===d.snapshotVersion&&h.lastRevisionAt===d.lastRevisionAt?h:(d.revisionFactsSnapshot={snapshotVersion:d.snapshotVersion,lastRevisionAt:d.lastRevisionAt},d.revisionFactsSnapshot)},recoveryFacts:()=>d?.recoveryFacts,history:()=>d?.history,forcedHeaders:()=>d?.forcedHeaders,beginForcedHeaders(h){d&&!d.closed&&(d.forcedHeaders=h)},endForcedHeaders(){for(const h of[d,p])h&&(h.forcedHeaders=void 0)},onSaved(h){return E.add(h),()=>E.delete(h)},showFacts:()=>d?.show,shownHeaders:()=>({...d?.shownHeaders}),showFill:()=>d?.showFill,beginShowFill(h){d&&!d.closed&&(d.showFill={showId:h,codeEdits:0})},noteCodeEdit(){d?.showFill&&(d.showFill.codeEdits+=1)},endShowFill(h){for(const C of[d,p])C?.showFill?.showId===h&&(C.showFill=void 0)},sessionKey:()=>d?.request.key,openError:()=>d?.error,subscribe(h){return v.add(h),()=>v.delete(h)},close(){!d&&!p||(T(),m(),w())}}}var so=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function ao(e){if(e instanceof so)return e.reason;if(e instanceof Ye)return ao(e.reason)}function yu(e){const t=e instanceof Ye?e.reason:e;return t instanceof so&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Eu(e){const t=ao(e);return t==="forbidden"||t==="not-found"}function _u(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new so("not-found");return $s(n)}}}var Gs=H("EmailPort");function wu(e){return e.getInstance(Gs)}function Su(e,t){e.inject(Gs,t)}var zs=H("documentSession.restEmailPortFactories");function Ws(e){return e.getInstance(zs)!==void 0}function Je(e){const t=e.getInstance(zs);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var Iu=H("EmailTermsResolver");function Cu(e){return e.getInstance(Iu)}var Ks=H("EmailHistoryPort"),Tu=H("BlockHistoryPort");function Ys(e){return e.getInstance(Tu)}function Xs(e){return e.getInstance(Ks)}function Au(e,t){e.inject(Ks,t)}var Ru="em_autosave_pending";function pn(e){return`${Ru}_${e}`}function Pu(e,t){try{sessionStorage.setItem(pn(e),JSON.stringify(t))}catch{}}function Js(e){try{const t=sessionStorage.getItem(pn(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(pn(e)),null):n}catch{return null}}function _t(e){try{sessionStorage.removeItem(pn(e))}catch{}}var Du=2e3,Ou=5e3,ku=5,xu=5e3,Mu=4;function Lu(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Nu(e,t){return e==null||t==null?!1:e.replaceAll(`\r
999
999
  `,`
1000
1000
  `)===t.replaceAll(`\r
1001
1001
  `,`
1002
- `)}function $n(e,t){return no(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function Fu({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:o,onFacts:i,onLate:s,onError:a,pageLoadTs:l=Lu()}){let c=null,d=!1,p=!1,b=0,E={emailId:e,historyLoaded:!1,isRecovering:!1},w=null;const I=new Promise(C=>{w=C}),y=C=>{E={...E,...C},i(E)};let R;const P=C=>{b+=1,y({applied:{phase:C,seq:b}})},N=()=>{c?.timer&&clearTimeout(c.timer),c=null},D=C=>{if(!p){if(w){const x=w;w=null,x(C),R=C.revision?C.phase:void 0;return}s(C)&&C.revision&&P(C.phase)}},k=()=>{if(!c||p)return;const C=c.phase==="fast",x=C?Du:xu,O=C?ku:Mu;c.timer=setTimeout(()=>{const h=c;if(!(!h||p)){if(h.attempts+=1,m(),C&&h.attempts>=O){const{pending:A}=h;_t(e),y({isRecovering:!1}),D({revision:{html:A.html,common_styles:A.common_styles,subject:A.subject,preheader:A.preheader},phase:"timeout"}),d=!0,h.phase="bg",h.attempts=0,k();return}if(!C&&h.attempts>=O){_t(e),N(),y({isRecovering:!1}),d=!0;return}k()}},x),c.timer.unref?.()},_=C=>{c={phase:"fast",attempts:0,pending:C,timer:null},y({isRecovering:!0}),k()},S=C=>{if(p)return;if(y({historyLoaded:!0,latestRevisionAt:C.latestAt!==void 0&&Number.isFinite(C.latestAt)?C.latestAt:void 0}),n&&c){const h=$n(C,c.pending.sentAt);if(!h)return;const A=c.phase==="fast"?"found":"bg";_t(e),N(),y({isRecovering:!1}),d=!0,D({revision:h,phase:A});return}if(d)return;const x=n?Js(e):null,O=x&&(x.sentAt<l||!Nu(x.html,o()))?x:null;if(O){const h=$n(C,O.sentAt);if(h){_t(e),d=!0,D({revision:h,phase:"found"});return}_(O);return}d=!0,D({revision:$n(C),phase:"normal"})},T=C=>{p||(a?.(C),E.historyLoaded||(y({historyLoaded:!1,latestRevisionAt:void 0}),g()),!c&&D({revision:null,phase:"normal"}))},m=()=>t(e).then(S).catch(T);let u,f=!1;const g=()=>{f||c||p||(f=!0,u=setTimeout(()=>{u=void 0,!p&&!E.historyLoaded&&m()},Ou))},v=()=>{p||(y({historyLoaded:!1,latestRevisionAt:void 0}),D({revision:null,phase:"normal"}))};return r?r().then(C=>C?m():v()):m(),{verdict:()=>I,confirmVerdict(C){const x=R;R=void 0,C&&x!==void 0&&!p&&P(x)},dispose(){p=!0,u!==void 0&&(clearTimeout(u),u=void 0),N()}}}function Bu({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:o,onFacts:i}){let s=null;const a=Fu({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:o,onFacts:i,onLate:({revision:l,phase:c})=>{const d=Vo(l);return s?.(d)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>a.verdict().then(({revision:l})=>Vo(l)),loaded(l){a.confirmVerdict(l)},watch(l){return s=l,()=>{s=null,a.dispose()}}}}function Qs(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){Pu(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const o=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),o}}}function ju(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const o=Date.now(),i=await t.updateEmail(n,r);return await e.updateEmail(n,r),(Js(n)?.sentAt??Number.POSITIVE_INFINITY)<=o&&_t(n),i}}}var Zs=H("CurrentUser"),ea={};function lo(e){return e.getOrCreateInstance(Zs,()=>ge(ea))}function ta(e){return e?.getInstance(Zs)?.get()??ea}var na=H("HeadlessMode");function ra(e){return e.getOrCreateInstance(na,()=>ge(!1))}function Uu(e){return e?.getInstance(na)?.get()??!1}var Hu=H("HiddenMount");function $u(e){return e.getOrCreateInstance(Hu,()=>ge(!1))}function qu(e){if(!e)return!1;try{return!!Xr(e).data?.act_as}catch{return!1}}function Gu(e){return qu(e?.getInstance(ps)?.get(yc.em_token))}function oa(e){return e?.getInstance(fe)?.get()??{}}function An(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Vu(e,t){return t.modeDefaults(An(e,t.fallbackMode))}function ia(e,t){const n=An(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function sa(e,t){const n=An(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function zu(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Wu(e){return $l(e.map(t=>t?.resourceProxy))}function Ku(e){return gc(e.map(t=>t?.resourceProxyPolicy))}function Yu(e){return vc(e.map(t=>t?.backendProxy))}function Xu(e){return fs(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Ju(e,t){return[e.base,Vu(e,t),e.profile,e.serverSide,ia(e,t.fallbackMode),e.local,e.user,sa(e,t.fallbackMode)]}function qn(e,t){const n=Ju(e,t),r=fs(n),o=zu(n);o!==void 0&&(r.fileManager=o);const i=Wu(n);i!==void 0&&(r.resourceProxy=i);const s=Ku(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=Yu(n);a!==void 0&&(r.backendProxy=a);const l=Xu(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}function Qu(e,t,n){const r=ia(e,n),o=sa(e,n);return Zl([o,e.user,r,e.serverSide],t)}var Zu=1.5;function ef(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<=Zu*e.autosaveTimeoutMs?"none":"revision"}function tf(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,i=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const l=S=>a!==void 0&&a.version===S.get().version?i()-a.failuresAtStart:0,c=S=>{const T=l(S);if(T<=0)return!1;const m=n().retryMaxAttempts??5;return!s()||T>m},d=()=>{const{autosaveTimeoutMs:S,retryIntervalMs:T}=n(),m=t();return m!==void 0&&l(m)>0&&T!==void 0&&T>0?T:S},p=S=>S.isNew()&&i()>=3,b=()=>{const S=t();if(!S||S.isDisposed()||c(S))return"none";const{latestRevisionAt:T,snapshotVersion:m,...u}=n(),f=Date.now(),g=ef({...u,isDirty:S.isDirty(),isNew:S.isNew(),isReady:S.isReady(),latestRevisionAgeMs:T!=null&&T<=f?f-T:void 0,isSnapshotSent:m!=null&&m===S.get().version});return g==="create"&&p(S)?"none":g},E=()=>{const S=t();if(!S||S.isDisposed()||p(S)||c(S)||n().isHeadless)return!1;if(!S.isDirty())return S.isNew();const{snapshotVersion:T}=n();return!(T!=null&&T===S.get().version)};let w,I,y,R,P=!1;const N=()=>{I=void 0;const S=t();if(!S||S.isDisposed())return;if(S.get().docId!==w){D();return}const T=b();T!=="none"&&a?.version!==S.get().version&&(a={version:S.get().version,failuresAtStart:i()}),T==="create"?r():T==="revision"?o():E()&&(w=S.get().docId,I=setTimeout(N,d()))},D=()=>{const S=t();P||!S||I!==void 0||b()==="none"&&!E()||(w=S.get().docId,I=setTimeout(N,d()))},k=S=>{S.source==="user"&&I!==void 0&&(clearTimeout(I),I=void 0),D()},_=()=>{const S=t();S!==y&&(R?.(),y=S,a=void 0,R=S?.subscribe(k),I!==void 0&&(clearTimeout(I),I=void 0))};return _(),D(),{refresh:()=>{P||(_(),D())},stop:()=>{P=!0,R?.(),R=void 0,y=void 0,I!==void 0&&(clearTimeout(I),I=void 0)}}}var aa=H("documentSession.autosaveUiFacts"),la={isUserBusy:!1,saveContext:{}};function nf(e){return e.getOrCreateInstance(aa,()=>ge(la))}function gr(e){return e?.getInstance(aa)?.get()??la}function ca(e){return gr(e).saveContext.fallbackTitle||"Untitled email."}var rf=1e4,of=3e4;function sf(e,t){const n=d=>{const p=e.getInstance(fe)?.layers?.(),b=p?Qu(p,d):void 0;return typeof b=="number"&&b>=0?b:void 0},r=()=>{const d=t.current(),p=d?.get().serverId??void 0,b=te(t.sessionKey()),E=t.recoveryFacts(),w=E?.emailId===p?E:void 0,I=t.revisionFacts(),y=w?.latestRevisionAt,R=I?.lastRevisionAt,P=ta(e).profile;return{isInited:b||d?.get().attributes.is_inited===!0,isEnabled:!!P?.autosaves&&!Gu(e),isHistoryLoaded:w?.historyLoaded===!0,isUserBusy:gr(e).isUserBusy,isHeadless:Uu(e),autosaveTimeoutMs:oa(e).autosaveTimeout||rf,latestRevisionAt:y!==void 0||R!==void 0?Math.max(y??0,R??0):void 0,snapshotVersion:I?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??of,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},o=()=>{const d=gr(e).saveContext;return{...d,project:d.project??t.current()?.get().attributes.project,fallbackTitle:ca(e)}},i=tf({readDocument:()=>t.current(),readEnvironment:r,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>$d(t.saveState().error),onCreate:()=>{te(t.sessionKey())||t.save("materialize",o())},onRevision:()=>{t.save("snapshot",{project:o().project})}}),s=t.subscribe(i.refresh),a=lo(e).watch(()=>i.refresh()),l=nf(e).watch(()=>i.refresh()),c=ra(e).watch(()=>i.refresh());return()=>{s(),a.dispose(),l.dispose(),c.dispose(),i.stop()}}var Yo=12e3;function le(e){return e.getOrCreateInstance(eo,()=>{const t=bu({resolveAdapters:(r,o)=>cf(r,e,o),resolveWritePort:()=>da(e),resolveHistoryPort:r=>te(r)?fa(e):ua(e),resolveTerms:()=>Cu(e),canEdit:r=>ld(e,r),notifyBeforeSave:md(e),timeoutMs:Yo,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const i=Eu(o),s=yu(o);kt(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(i),network_failure:String(s)},level:i||s?"warning":"error"})},onTimeout:r=>{}}),n=sf(e,t);return e.getInstance(G)?.addDispose(n),t})}function Xe(e){return e?.getInstance(eo)}function da(e){const t=wu(e);return t?co(e)?ju(t,Je(e).email(e)):t:Je(e).email(e)}function af(e){return Xs(e)!==void 0||Ws(e)}function ua(e){const t=Xs(e);return t?co(e)?(ne("port:history:server-backed"),Qs(t,Je(e).history(e))):(ne("port:history:integrator"),t):(ne("port:history:rest (порт не зарегистрирован)"),Je(e).history(e))}function fa(e){const t=Ys(e);return t?co(e)?(ne("port:block-history:server-backed"),Qs(t,Je(e).blockHistory(e))):(ne("port:block-history:integrator"),t):(ne("port:block-history:rest (порт не зарегистрирован)"),Je(e).blockHistory(e))}function lf(e){return Ys(e)!==void 0||Ws(e)}function co(e){return Is(e)}function cf({email:e,patch:t,serverId:n,key:r},o,i){const s=[];e?s.push({id:"rest",load:()=>$s(e),required:!0}):n&&s.push(_u(da(o),n)),t&&s.push({id:"plugin",load:()=>qs(t)});const a=te(r);return gd(n)&&(a?lf(o):af(o))&&s.push(Bu({port:a?fa(o):ua(o),revisionServiceEnabled:Is(o),...!a&&cd(o)?{isHistoryAvailable:()=>dd(o)}:{},emailId:n,readShownContent:()=>i.readShownContent(),onFacts:l=>i.publishRecoveryFacts(l)})),s}function de(e){return e.getOrCreateInstance(jt,()=>new Bt)}var pa=new WeakMap,vr=new WeakMap;function Se(e){return pa.get(e)??0}function hn(e,t){let n=vr.get(e);return n||(n=new Set,vr.set(e,n)),n.add(t),()=>{n?.delete(t)}}function df(e){pa.set(e,Se(e)+1),vr.get(e)?.forEach(t=>t())}function uf(e){const t=le(e),n=de(e).addListener(z.APPLICATION_HAS_AMP,r=>{st(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(G)?.addDispose(()=>n.dispose())}function ff(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function pf(e){const t=e.fetchImpl??((i,s)=>fetch(i,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=i=>{try{const s=new URL(i,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:o,async load(i){if(!o(i))return;const s=!r.has(i);r.add(i);try{const a=await t(i,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!a.ok)return;const l=await a.blob();return ff(l)?l:void 0}catch{return}}}}var Ke={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function hf(e){const t={maxBytes:e.maxBytes??Ke.maxBytes,maxImageBytes:e.maxImageBytes??Ke.maxImageBytes,ttlMs:e.ttlMs??Ke.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,i={hits:0,loads:0,failures:0};let s=0;const a=p=>{const b=r.get(p);b&&(s-=b.bytes,r.delete(p))},l=p=>t.ttlMs<=0||n()-p.storedAt<t.ttlMs,c=()=>{if(s<=t.maxBytes)return;const p=[...r.entries()].sort((b,E)=>b[1].usedAt-E[1].usedAt);for(const[b]of p){if(s<=t.maxBytes)return;a(b)}},d=(p,b)=>{b.size>t.maxImageBytes||(r.set(p,{blob:b,bytes:b.size,storedAt:n(),usedAt:n()}),s+=b.size,c())};return{async get(p){const b=r.get(p);if(b&&l(b))return b.usedAt=n(),i.hits+=1,b.blob;b&&a(p);const E=o.get(p);if(E!==void 0)return E;i.loads+=1;const w=(async()=>{try{const I=await e.load(p);return I?d(p,I):i.failures+=1,I}catch{i.failures+=1;return}finally{o.delete(p)}})();return o.set(p,w),w},forget(p){a(p),o.delete(p)},configure(p){Object.assign(t,{maxBytes:p.maxBytes??t.maxBytes,maxImageBytes:p.maxImageBytes??t.maxImageBytes,ttlMs:p.ttlMs??t.ttlMs});for(const[b,E]of r)E.bytes>t.maxImageBytes&&a(b);c()},clear(){r.clear(),o.clear(),s=0},stats(){return{entries:r.size,bytes:s,...i}}}}var mf=["emcdn.ru","scr.emcdn.ru"];function gf(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 vf(e,t){const n=(r,o)=>{const i=new Set(o?t:[]);for(const s of r){const a=gf(s);a&&i.add(a)}return[...i]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function bf(e){const t=e??{},n=t.isPlugin!==!0?mf:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Ke};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:vf(o.sourceHosts,n),maxBytes:o.maxBytes??Ke.maxBytes,maxImageBytes:o.maxImageBytes??Ke.maxImageBytes,ttlMs:o.ttlMs??Ke.ttlMs}}function yf(e){const t=de(e),n=e.getInstance(fe),r=()=>bf({...n?.get(),isPlugin:!0});let o=r();const i=pf({sourceHosts:()=>o.sourceHosts}),s=hf({load:I=>i.load(I),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(z.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},l=t.onInit(()=>a()),c=n?.watch(()=>{const I=r(),y=JSON.stringify(I)!==JSON.stringify(o);o=I,s.configure(I),I.enabled||s.clear(),y&&t.isInited()&&a()}),d={asked:0,served:0,refused:0},p=[],b=(I,y)=>(d.refused+=1,p.push({url:I,reason:y}),p.length>20&&p.shift(),{refused:!0}),E=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...d},refusals:[...p],store:s.stats()})}),w=t.addListenerAsync(z.APPLICATION_CANVAS_IMAGE_GET,async I=>{const y=I?.url??"";if(d.asked+=1,!o.enabled||!y)return b(y,"disabled");if(!i.accepts(y))return b(y,"host");I.fresh&&s.forget(y);const R=await s.get(y);return R?(d.served+=1,{blob:R}):b(y,"load-failed")});e.getInstance(G)?.addDispose(()=>{l.dispose(),c?.dispose(),w.dispose(),s.clear(),delete E.__emmCanvasImages__})}var Ef=2e3;function _f(e){const t=de(e),n=new Map,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;clearTimeout(n.get(s));const a=new MessageChannel;let l=!1,c=!1;const d=b=>{b.data?.operationId==="em:port-ready"&&(l=!0,a.port1.removeEventListener("message",d),c&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",d),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const p=setTimeout(()=>{n.get(s)===p&&n.delete(s),!(l||!t.hasPort(s,a.port1))&&(kt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),c=!0,t.holdPort(s))},Ef);n.set(s,p)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),i=t.onInit(()=>r());e.getInstance(G)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);i.dispose(),delete o.__emmCanvasPort__})}var wf=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Sf(e){return wf.test(e)||e.indexOf("//")===0}function Kt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function If(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Xo(e,t){const n=e==null||e===""?"./":String(e);if(Sf(n))return Kt(n);const r=t??If();if(!r)return Kt(n);try{return Kt(new URL(n,r).href)}catch{return Kt(n)}}function Cf(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?Xo(window.__useblocks__.publicPath):Xo("/")}var Tf=()=>"",Af=()=>"facd6272";function Rf(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function ha(e){const t=e?"iframe-eblock":"iframe",n=Tf();if(n){const i=Rf(n,window.location).replace(/\/?$/,"/");return Fo(`${i}${t}.html`,Ot())}const r=Af(),o=`${Cf().replace(/\/?$/,"/")}iframe/`;return Fo(`${o}${t}${r?`.${r}`:""}.html`,Ot())}var Jo="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function br(e){return/^file:/i.test(String(e||"").trim())}function Pf(e){return br(e)?`${Jo} allow-same-origin`:Jo}var Df="em:module-body-ack";function Of(e,t,n){try{const r=new URL("./",new URL(t,n)).href,o=new URL(e,r).href;return o.startsWith(r)?o:void 0}catch{return}}function uo(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 kf(e){const t=uo(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function xf(e,t){const n=uo(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function Mf(e,t){const n=uo(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),i=[r],s=[];for(;i.length>0;)for(const a of e[i.shift()]??[])o.has(a)||(o.add(a),s.push(a),i.push(a));return s}var Lf=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function Nf(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&Lf.test(t[t.length-2])}async function Ff(e,t){const n=Nf(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 Bf(e){const t=new Map,n=(r,o)=>{const i=Of(r,e.canvasSrc,e.origin);if(!i)return;const s=t.get(i);if(s!==void 0)return s;const a=e.fetchBody(i,o);return t.set(i,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const i of r)n(i,o)},reset(){t.clear()},get size(){return t.size}}}var Ae;function jf(e){try{return br(new URL(e,window.location.href).href)}catch{return br(window.location.href)}}function ma(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof window.__useblocks__<"u"&&window.__useblocks__?.preload?.canvasCrossOrigin===!0}var Uf=()=>Promise.resolve(void 0);function ga(){const e=ha(!1);if(!jf(e)){if(!Ae||Ae.canvasSrc!==e){const t=ma(e)?Ff:Uf;Ae={canvasSrc:e,store:Bf({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return Ae.store}}async function Hf(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const o=await r.json();t(xf(o,e))}catch{}}function fo(e){const t=ga();if(!t||!Ae||Ae.warmed||!ma(Ae.canvasSrc))return;Ae.warmed=!0;const{canvasSrc:n}=Ae,r=kf(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.JLkggsgY.js"],"js/iframe.js":["js/elMarkupHelper.JLkggsgY.js"],"js/darkreader.CyLMh7_H.js":[],"js/elMarkupHelper.JLkggsgY.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.CGEpDoct.js":[]};o?t.warm(Mf(o,n),e):Hf(n,i=>t.warm(i,e))}function $f(e){const t=ga();if(!t)return;fo();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const i=r.source;i&&(i.postMessage({operationId:Df,for:o.result},"*"),t.take(o.data?.url??"").then(s=>{i.postMessage({operationId:o.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(G)?.addDispose(()=>{window.removeEventListener("message",n)})}var at=/<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,qf=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,pt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Qo=/display:\s*none\s*!important/gi,Gf=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,Vf=/\s*height\s*:\s*100%\s*!important\s*;?/gi,zf=/height\s*:\s*100%\s*!important/i,Wf=[".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 Kf(e){return Qo.lastIndex=0,(e.match(Qo)||[]).length}function va(e){const t=e.trim(),n=Kf(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=Wf.filter(o=>t.includes(o)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function Yf(e){pt.lastIndex=0;for(const t of e.matchAll(pt))if(va(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Xf(e){let t=!1;return pt.lastIndex=0,{html:e.replace(pt,n=>va(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Jf(e){return at.lastIndex=0,at.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Yf(e)}function Qf(e){if(!Jf(e))return{html:e,found:!1};let t=!1,n=e;at.lastIndex=0,at.test(n)&&(at.lastIndex=0,n=n.replace(at,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(qf,""),t=!0);const r=Xf(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Zf(e){return!e||!zf.test(e)?e:(pt.lastIndex=0,e.replace(pt,t=>t.replace(Gf,(n,r,o,i)=>`${r}${o.replace(Vf,"")}${i}`)))}function ba(e){const t=Qf(e.replaceAll(`\r
1002
+ `)}function $n(e,t){return no(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function Fu({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:o,onFacts:i,onLate:s,onError:a,pageLoadTs:l=Lu()}){let c=null,d=!1,p=!1,v=0,E={emailId:e,historyLoaded:!1,isRecovering:!1},w=null;const I=new Promise(O=>{w=O}),b=O=>{E={...E,...O},i(E)};let R;const P=O=>{v+=1,b({applied:{phase:O,seq:v}})},F=()=>{c?.timer&&clearTimeout(c.timer),c=null},D=O=>{if(!p){if(w){const y=w;w=null,y(O),R=O.revision?O.phase:void 0;return}s(O)&&O.revision&&P(O.phase)}},k=()=>{if(!c||p)return;const O=c.phase==="fast",y=O?Du:xu,A=O?ku:Mu;c.timer=setTimeout(()=>{const h=c;if(!(!h||p)){if(h.attempts+=1,m(),O&&h.attempts>=A){const{pending:C}=h;_t(e),b({isRecovering:!1}),D({revision:{html:C.html,common_styles:C.common_styles,subject:C.subject,preheader:C.preheader},phase:"timeout"}),d=!0,h.phase="bg",h.attempts=0,k();return}if(!O&&h.attempts>=A){_t(e),F(),b({isRecovering:!1}),d=!0;return}k()}},y),c.timer.unref?.()},_=O=>{c={phase:"fast",attempts:0,pending:O,timer:null},b({isRecovering:!0}),k()},S=O=>{if(p)return;if(b({historyLoaded:!0,latestRevisionAt:O.latestAt!==void 0&&Number.isFinite(O.latestAt)?O.latestAt:void 0}),n&&c){const h=$n(O,c.pending.sentAt);if(!h)return;const C=c.phase==="fast"?"found":"bg";_t(e),F(),b({isRecovering:!1}),d=!0,D({revision:h,phase:C});return}if(d)return;const y=n?Js(e):null,A=y&&(y.sentAt<l||!Nu(y.html,o()))?y:null;if(A){const h=$n(O,A.sentAt);if(h){_t(e),d=!0,D({revision:h,phase:"found"});return}_(A);return}d=!0,D({revision:$n(O),phase:"normal"})},T=O=>{p||(a?.(O),E.historyLoaded||(b({historyLoaded:!1,latestRevisionAt:void 0}),g()),!c&&D({revision:null,phase:"normal"}))},m=()=>t(e).then(S).catch(T);let u,f=!1;const g=()=>{f||c||p||(f=!0,u=setTimeout(()=>{u=void 0,!p&&!E.historyLoaded&&m()},Ou))},x=()=>{p||(b({historyLoaded:!1,latestRevisionAt:void 0}),D({revision:null,phase:"normal"}))};return r?r().then(O=>O?m():x()):m(),{verdict:()=>I,confirmVerdict(O){const y=R;R=void 0,O&&y!==void 0&&!p&&P(y)},dispose(){p=!0,u!==void 0&&(clearTimeout(u),u=void 0),F()}}}function Bu({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:o,onFacts:i}){let s=null;const a=Fu({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:o,onFacts:i,onLate:({revision:l,phase:c})=>{const d=Go(l);return s?.(d)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>a.verdict().then(({revision:l})=>Go(l)),loaded(l){a.confirmVerdict(l)},watch(l){return s=l,()=>{s=null,a.dispose()}}}}function Qs(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){Pu(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const o=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),o}}}function ju(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const o=Date.now(),i=await t.updateEmail(n,r);return await e.updateEmail(n,r),(Js(n)?.sentAt??Number.POSITIVE_INFINITY)<=o&&_t(n),i}}}var Zs=H("CurrentUser"),ea={};function lo(e){return e.getOrCreateInstance(Zs,()=>ge(ea))}function ta(e){return e?.getInstance(Zs)?.get()??ea}var na=H("HeadlessMode");function ra(e){return e.getOrCreateInstance(na,()=>ge(!1))}function Uu(e){return e?.getInstance(na)?.get()??!1}var Hu=H("HiddenMount");function $u(e){return e.getOrCreateInstance(Hu,()=>ge(!1))}function qu(e){if(!e)return!1;try{return!!Xr(e).data?.act_as}catch{return!1}}function Vu(e){return qu(e?.getInstance(ps)?.get(yc.em_token))}function oa(e){return e?.getInstance(fe)?.get()??{}}function An(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Gu(e,t){return t.modeDefaults(An(e,t.fallbackMode))}function ia(e,t){const n=An(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function sa(e,t){const n=An(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function zu(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Wu(e){return $l(e.map(t=>t?.resourceProxy))}function Ku(e){return gc(e.map(t=>t?.resourceProxyPolicy))}function Yu(e){return vc(e.map(t=>t?.backendProxy))}function Xu(e){return fs(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Ju(e,t){return[e.base,Gu(e,t),e.profile,e.serverSide,ia(e,t.fallbackMode),e.local,e.user,sa(e,t.fallbackMode)]}function qn(e,t){const n=Ju(e,t),r=fs(n),o=zu(n);o!==void 0&&(r.fileManager=o);const i=Wu(n);i!==void 0&&(r.resourceProxy=i);const s=Ku(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=Yu(n);a!==void 0&&(r.backendProxy=a);const l=Xu(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}function Qu(e,t,n){const r=ia(e,n),o=sa(e,n);return Zl([o,e.user,r,e.serverSide],t)}var Zu=1.5;function ef(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<=Zu*e.autosaveTimeoutMs?"none":"revision"}function tf(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,i=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const l=S=>a!==void 0&&a.version===S.get().version?i()-a.failuresAtStart:0,c=S=>{const T=l(S);if(T<=0)return!1;const m=n().retryMaxAttempts??5;return!s()||T>m},d=()=>{const{autosaveTimeoutMs:S,retryIntervalMs:T}=n(),m=t();return m!==void 0&&l(m)>0&&T!==void 0&&T>0?T:S},p=S=>S.isNew()&&i()>=3,v=()=>{const S=t();if(!S||S.isDisposed()||c(S))return"none";const{latestRevisionAt:T,snapshotVersion:m,...u}=n(),f=Date.now(),g=ef({...u,isDirty:S.isDirty(),isNew:S.isNew(),isReady:S.isReady(),latestRevisionAgeMs:T!=null&&T<=f?f-T:void 0,isSnapshotSent:m!=null&&m===S.get().version});return g==="create"&&p(S)?"none":g},E=()=>{const S=t();if(!S||S.isDisposed()||p(S)||c(S)||n().isHeadless)return!1;if(!S.isDirty())return S.isNew();const{snapshotVersion:T}=n();return!(T!=null&&T===S.get().version)};let w,I,b,R,P=!1;const F=()=>{I=void 0;const S=t();if(!S||S.isDisposed())return;if(S.get().docId!==w){D();return}const T=v();T!=="none"&&a?.version!==S.get().version&&(a={version:S.get().version,failuresAtStart:i()}),T==="create"?r():T==="revision"?o():E()&&(w=S.get().docId,I=setTimeout(F,d()))},D=()=>{const S=t();P||!S||I!==void 0||v()==="none"&&!E()||(w=S.get().docId,I=setTimeout(F,d()))},k=S=>{S.source==="user"&&I!==void 0&&(clearTimeout(I),I=void 0),D()},_=()=>{const S=t();S!==b&&(R?.(),b=S,a=void 0,R=S?.subscribe(k),I!==void 0&&(clearTimeout(I),I=void 0))};return _(),D(),{refresh:()=>{P||(_(),D())},stop:()=>{P=!0,R?.(),R=void 0,b=void 0,I!==void 0&&(clearTimeout(I),I=void 0)}}}var aa=H("documentSession.autosaveUiFacts"),la={isUserBusy:!1,saveContext:{}};function nf(e){return e.getOrCreateInstance(aa,()=>ge(la))}function gr(e){return e?.getInstance(aa)?.get()??la}function ca(e){return gr(e).saveContext.fallbackTitle||"Untitled email."}var rf=1e4,of=3e4;function sf(e,t){const n=d=>{const p=e.getInstance(fe)?.layers?.(),v=p?Qu(p,d):void 0;return typeof v=="number"&&v>=0?v:void 0},r=()=>{const d=t.current(),p=d?.get().serverId??void 0,v=te(t.sessionKey()),E=t.recoveryFacts(),w=E?.emailId===p?E:void 0,I=t.revisionFacts(),b=w?.latestRevisionAt,R=I?.lastRevisionAt,P=ta(e).profile;return{isInited:v||d?.get().attributes.is_inited===!0,isEnabled:!!P?.autosaves&&!Vu(e),isHistoryLoaded:w?.historyLoaded===!0,isUserBusy:gr(e).isUserBusy,isHeadless:Uu(e),autosaveTimeoutMs:oa(e).autosaveTimeout||rf,latestRevisionAt:b!==void 0||R!==void 0?Math.max(b??0,R??0):void 0,snapshotVersion:I?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??of,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},o=()=>{const d=gr(e).saveContext;return{...d,project:d.project??t.current()?.get().attributes.project,fallbackTitle:ca(e)}},i=tf({readDocument:()=>t.current(),readEnvironment:r,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>$d(t.saveState().error),onCreate:()=>{te(t.sessionKey())||t.save("materialize",o())},onRevision:()=>{t.save("snapshot",{project:o().project})}}),s=t.subscribe(i.refresh),a=lo(e).watch(()=>i.refresh()),l=nf(e).watch(()=>i.refresh()),c=ra(e).watch(()=>i.refresh());return()=>{s(),a.dispose(),l.dispose(),c.dispose(),i.stop()}}var Yo=12e3;function le(e){return e.getOrCreateInstance(eo,()=>{const t=bu({resolveAdapters:(r,o)=>cf(r,e,o),resolveWritePort:()=>da(e),resolveHistoryPort:r=>te(r)?fa(e):ua(e),resolveTerms:()=>Cu(e),canEdit:r=>ld(e,r),notifyBeforeSave:md(e),timeoutMs:Yo,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const i=Eu(o),s=yu(o);kt(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(i),network_failure:String(s)},level:i||s?"warning":"error"})},onTimeout:r=>{}}),n=sf(e,t);return e.getInstance(G)?.addDispose(n),t})}function Xe(e){return e?.getInstance(eo)}function da(e){const t=wu(e);return t?co(e)?ju(t,Je(e).email(e)):t:Je(e).email(e)}function af(e){return Xs(e)!==void 0||Ws(e)}function ua(e){const t=Xs(e);return t?co(e)?(ne("port:history:server-backed"),Qs(t,Je(e).history(e))):(ne("port:history:integrator"),t):(ne("port:history:rest (порт не зарегистрирован)"),Je(e).history(e))}function fa(e){const t=Ys(e);return t?co(e)?(ne("port:block-history:server-backed"),Qs(t,Je(e).blockHistory(e))):(ne("port:block-history:integrator"),t):(ne("port:block-history:rest (порт не зарегистрирован)"),Je(e).blockHistory(e))}function lf(e){return Ys(e)!==void 0||Ws(e)}function co(e){return Is(e)}function cf({email:e,patch:t,serverId:n,key:r},o,i){const s=[];e?s.push({id:"rest",load:()=>$s(e),required:!0}):n&&s.push(_u(da(o),n)),t&&s.push({id:"plugin",load:()=>qs(t)});const a=te(r);return gd(n)&&(a?lf(o):af(o))&&s.push(Bu({port:a?fa(o):ua(o),revisionServiceEnabled:Is(o),...!a&&cd(o)?{isHistoryAvailable:()=>dd(o)}:{},emailId:n,readShownContent:()=>i.readShownContent(),onFacts:l=>i.publishRecoveryFacts(l)})),s}function de(e){return e.getOrCreateInstance(jt,()=>new Bt)}var pa=new WeakMap,vr=new WeakMap;function Se(e){return pa.get(e)??0}function hn(e,t){let n=vr.get(e);return n||(n=new Set,vr.set(e,n)),n.add(t),()=>{n?.delete(t)}}function df(e){pa.set(e,Se(e)+1),vr.get(e)?.forEach(t=>t())}function uf(e){const t=le(e),n=de(e).addListener(z.APPLICATION_HAS_AMP,r=>{st(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(G)?.addDispose(()=>n.dispose())}function ff(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function pf(e){const t=e.fetchImpl??((i,s)=>fetch(i,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=i=>{try{const s=new URL(i,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:o,async load(i){if(!o(i))return;const s=!r.has(i);r.add(i);try{const a=await t(i,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!a.ok)return;const l=await a.blob();return ff(l)?l:void 0}catch{return}}}}var Ke={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function hf(e){const t={maxBytes:e.maxBytes??Ke.maxBytes,maxImageBytes:e.maxImageBytes??Ke.maxImageBytes,ttlMs:e.ttlMs??Ke.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,i={hits:0,loads:0,failures:0};let s=0;const a=p=>{const v=r.get(p);v&&(s-=v.bytes,r.delete(p))},l=p=>t.ttlMs<=0||n()-p.storedAt<t.ttlMs,c=()=>{if(s<=t.maxBytes)return;const p=[...r.entries()].sort((v,E)=>v[1].usedAt-E[1].usedAt);for(const[v]of p){if(s<=t.maxBytes)return;a(v)}},d=(p,v)=>{v.size>t.maxImageBytes||(r.set(p,{blob:v,bytes:v.size,storedAt:n(),usedAt:n()}),s+=v.size,c())};return{async get(p){const v=r.get(p);if(v&&l(v))return v.usedAt=n(),i.hits+=1,v.blob;v&&a(p);const E=o.get(p);if(E!==void 0)return E;i.loads+=1;const w=(async()=>{try{const I=await e.load(p);return I?d(p,I):i.failures+=1,I}catch{i.failures+=1;return}finally{o.delete(p)}})();return o.set(p,w),w},forget(p){a(p),o.delete(p)},configure(p){Object.assign(t,{maxBytes:p.maxBytes??t.maxBytes,maxImageBytes:p.maxImageBytes??t.maxImageBytes,ttlMs:p.ttlMs??t.ttlMs});for(const[v,E]of r)E.bytes>t.maxImageBytes&&a(v);c()},clear(){r.clear(),o.clear(),s=0},stats(){return{entries:r.size,bytes:s,...i}}}}var mf=["emcdn.ru","scr.emcdn.ru"];function gf(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 vf(e,t){const n=(r,o)=>{const i=new Set(o?t:[]);for(const s of r){const a=gf(s);a&&i.add(a)}return[...i]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function bf(e){const t=e??{},n=t.isPlugin!==!0?mf:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Ke};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:vf(o.sourceHosts,n),maxBytes:o.maxBytes??Ke.maxBytes,maxImageBytes:o.maxImageBytes??Ke.maxImageBytes,ttlMs:o.ttlMs??Ke.ttlMs}}function yf(e){const t=de(e),n=e.getInstance(fe),r=()=>bf({...n?.get(),isPlugin:!0});let o=r();const i=pf({sourceHosts:()=>o.sourceHosts}),s=hf({load:I=>i.load(I),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(z.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},l=t.onInit(()=>a()),c=n?.watch(()=>{const I=r(),b=JSON.stringify(I)!==JSON.stringify(o);o=I,s.configure(I),I.enabled||s.clear(),b&&t.isInited()&&a()}),d={asked:0,served:0,refused:0},p=[],v=(I,b)=>(d.refused+=1,p.push({url:I,reason:b}),p.length>20&&p.shift(),{refused:!0}),E=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...d},refusals:[...p],store:s.stats()})}),w=t.addListenerAsync(z.APPLICATION_CANVAS_IMAGE_GET,async I=>{const b=I?.url??"";if(d.asked+=1,!o.enabled||!b)return v(b,"disabled");if(!i.accepts(b))return v(b,"host");I.fresh&&s.forget(b);const R=await s.get(b);return R?(d.served+=1,{blob:R}):v(b,"load-failed")});e.getInstance(G)?.addDispose(()=>{l.dispose(),c?.dispose(),w.dispose(),s.clear(),delete E.__emmCanvasImages__})}var Ef=2e3;function _f(e){const t=de(e),n=new Map,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;clearTimeout(n.get(s));const a=new MessageChannel;let l=!1,c=!1;const d=v=>{v.data?.operationId==="em:port-ready"&&(l=!0,a.port1.removeEventListener("message",d),c&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",d),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const p=setTimeout(()=>{n.get(s)===p&&n.delete(s),!(l||!t.hasPort(s,a.port1))&&(kt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),c=!0,t.holdPort(s))},Ef);n.set(s,p)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),i=t.onInit(()=>r());e.getInstance(G)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);i.dispose(),delete o.__emmCanvasPort__})}var wf=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Sf(e){return wf.test(e)||e.indexOf("//")===0}function Kt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function If(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Xo(e,t){const n=e==null||e===""?"./":String(e);if(Sf(n))return Kt(n);const r=t??If();if(!r)return Kt(n);try{return Kt(new URL(n,r).href)}catch{return Kt(n)}}function Cf(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?Xo(window.__useblocks__.publicPath):Xo("/")}var Tf=()=>"",Af=()=>"71aea198";function Rf(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function ha(e){const t=e?"iframe-eblock":"iframe",n=Tf();if(n){const i=Rf(n,window.location).replace(/\/?$/,"/");return Fo(`${i}${t}.html`,Ot())}const r=Af(),o=`${Cf().replace(/\/?$/,"/")}iframe/`;return Fo(`${o}${t}${r?`.${r}`:""}.html`,Ot())}var Jo="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function br(e){return/^file:/i.test(String(e||"").trim())}function Pf(e){return br(e)?`${Jo} allow-same-origin`:Jo}var Df="em:module-body-ack";function Of(e,t,n){try{const r=new URL("./",new URL(t,n)).href,o=new URL(e,r).href;return o.startsWith(r)?o:void 0}catch{return}}function uo(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 kf(e){const t=uo(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function xf(e,t){const n=uo(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function Mf(e,t){const n=uo(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),i=[r],s=[];for(;i.length>0;)for(const a of e[i.shift()]??[])o.has(a)||(o.add(a),s.push(a),i.push(a));return s}var Lf=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function Nf(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&Lf.test(t[t.length-2])}async function Ff(e,t){const n=Nf(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 Bf(e){const t=new Map,n=(r,o)=>{const i=Of(r,e.canvasSrc,e.origin);if(!i)return;const s=t.get(i);if(s!==void 0)return s;const a=e.fetchBody(i,o);return t.set(i,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const i of r)n(i,o)},reset(){t.clear()},get size(){return t.size}}}var Ae;function jf(e){try{return br(new URL(e,window.location.href).href)}catch{return br(window.location.href)}}function ma(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof window.__useblocks__<"u"&&window.__useblocks__?.preload?.canvasCrossOrigin===!0}var Uf=()=>Promise.resolve(void 0);function ga(){const e=ha(!1);if(!jf(e)){if(!Ae||Ae.canvasSrc!==e){const t=ma(e)?Ff:Uf;Ae={canvasSrc:e,store:Bf({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return Ae.store}}async function Hf(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const o=await r.json();t(xf(o,e))}catch{}}function fo(e){const t=ga();if(!t||!Ae||Ae.warmed||!ma(Ae.canvasSrc))return;Ae.warmed=!0;const{canvasSrc:n}=Ae,r=kf(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.D_gxM3uK.js"],"js/iframe.js":["js/elMarkupHelper.D_gxM3uK.js"],"js/darkreader.CyLMh7_H.js":[],"js/elMarkupHelper.D_gxM3uK.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.CGEpDoct.js":[]};o?t.warm(Mf(o,n),e):Hf(n,i=>t.warm(i,e))}function $f(e){const t=ga();if(!t)return;fo();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const i=r.source;i&&(i.postMessage({operationId:Df,for:o.result},"*"),t.take(o.data?.url??"").then(s=>{i.postMessage({operationId:o.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(G)?.addDispose(()=>{window.removeEventListener("message",n)})}var at=/<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,qf=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,pt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Qo=/display:\s*none\s*!important/gi,Vf=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,Gf=/\s*height\s*:\s*100%\s*!important\s*;?/gi,zf=/height\s*:\s*100%\s*!important/i,Wf=[".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 Kf(e){return Qo.lastIndex=0,(e.match(Qo)||[]).length}function va(e){const t=e.trim(),n=Kf(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=Wf.filter(o=>t.includes(o)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function Yf(e){pt.lastIndex=0;for(const t of e.matchAll(pt))if(va(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Xf(e){let t=!1;return pt.lastIndex=0,{html:e.replace(pt,n=>va(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Jf(e){return at.lastIndex=0,at.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Yf(e)}function Qf(e){if(!Jf(e))return{html:e,found:!1};let t=!1,n=e;at.lastIndex=0,at.test(n)&&(at.lastIndex=0,n=n.replace(at,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(qf,""),t=!0);const r=Xf(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Zf(e){return!e||!zf.test(e)?e:(pt.lastIndex=0,e.replace(pt,t=>t.replace(Vf,(n,r,o,i)=>`${r}${o.replace(Gf,"")}${i}`)))}function ba(e){const t=Qf(e.replaceAll(`\r
1003
1003
  `,`
1004
- `));return{html:Zf(t.html),hasBrowserExtensionArtifacts:t.found}}function mn(e){return e?.getContent()??""}function ya(e,t){e?.mutate({content:Us(t)},{source:"remote"})}function Rn(e){return H(e)}function ae(e,t){return e.getOrCreateInstance(t,()=>new Fe)}function J(e,t){return e.getOrCreateInstance(t,()=>new Fe).event}function gn(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var ep=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 tp(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 np(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(ee(n),new Promise((r,o)=>{let i=!1,s,a;const l=d=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",c),d())},c=()=>{l(()=>o(ve(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>o(new ep(t)))},t)),n?.addEventListener("abort",c)}))}var rp=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 op(e,t,n){return t<=0?e:new Promise((r,o)=>{let i=!1,s;const a=l=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),l())};s=setTimeout(()=>{a(()=>o(new rp(n,t)))},t),e.then(l=>{a(()=>r(l))},l=>{a(()=>o(l))})})}var ip=2,wt=Symbol("sandbox:frame-replaced");function Zo(e){return e===wt}function Ve(e,t,n,r,o,i,s){const a=`sandbox:${t}`,l=i?.getSandboxTimeoutMs(t)??to[t],c=()=>{let w=op(e.sendAsync(n,r),l,a);return w=un(w,i?.signal),ze(a,w,o)};if(t==="INIT_START"&&tp(e)){const w=i?.getSandboxReadyTimeoutMs()??2e4,I=e,y=R=>{const P=np(I,w,i?.signal);return ze("sandbox:INIT_START:ready-wait",P,o).then(()=>{if(!s||R<=0)return c();const N=s.getGeneration();let D;const k=new Promise((S,T)=>{D=s.onChange(()=>{s.getGeneration()!==N&&T(wt)})}),_=c();return _.catch(()=>{}),Promise.race([_,k]).finally(()=>D?.()).catch(S=>{if(S!==wt)throw S;return{...o},y(R-1)})})};return y(ip)}if(!s)return c();const d=s.getGeneration();let p;const b=new Promise((w,I)=>{p=s.onChange(()=>{s.getGeneration()!==d&&I(wt)})}),E=c();return E.catch(()=>{}),Promise.race([E,b]).finally(()=>p?.()).catch(w=>{throw w===wt&&{...o},w})}var sp=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],ap=200;function Ea(e=new Set){const t=new Set;return(n,r)=>{if(!sp.some(([i,s])=>!e.has(i)&&s.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=ap&&t.clear(),t.add(o))}}function _a(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Ea()}}var lp=_a();function Ze(e){return e?.getInstance($r)??lp}var wa="self-init:";function cp(e){return e.startsWith(wa)}function po(e,t){const n=e.getActiveShowRequest();return cp(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function dp(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let i="",s;const a=w=>{s={target:e.readTarget?.(),docId:w}},l=()=>e.readDocument()?mn(e.readDocument()):i,c=()=>Ze(e.container).editorPolicy,d=()=>e.readEmail(),p=()=>{const w=d();return{...w,id:e.isTemplate()||w.isNew?void 0:w.id,html:l()}};let b=!1;const E={readContent:l,publicEmail:p,sendInitStart:()=>Ve(n,"INIT_START",z.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>Ve(n,"INITED",z.SANDBOX_INITED,{guid:d().renderGuid},void 0,r(),o()),async sendContent(){const w=d(),{html:I,hasBrowserExtensionArtifacts:y}=ba(w?.html||"");y&&e.events.browserExtensionDetected(),ya(e.readDocument(),I),i=I,a(w.renderGuid),await Ve(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,gn(l(),w.renderGuid,c(),e.readDocument()?.get().version),{guid:w.renderGuid,emailId:w.id??null},r(),o())},refreshContent:()=>(a(d().renderGuid),Ve(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,gn(l(),d().renderGuid,c(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const w=d();if(w.preheader!==void 0)return Ve(n,"PREHEADER",z.SANDBOX_PREHEADER_UPDATE,{value:w.preheader,guid:w.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const w=d();if(w.subject!==void 0)return Ve(n,"SUBJECT",z.SANDBOX_SUBJECT_UPDATE,{value:w.subject,guid:w.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:w=>e.showFilled?.(w),noteFilled:(w,I)=>e.noteFilled?.(w,I),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(p()),fireInit(w,I){if(!po(t(),w)){t().getActiveShowRequest()?.showId;return}const y=d();y.id,y.renderGuid,t().completeShow(w);const R=e.readDocument();ft(R,{is_inited:!0},{source:"system"});const P=()=>{const D=p();I&&(D.reset=!0);const k=e.events.inited(D);return I||(b&&E.fireEmailChanged(),b=!0),k};if(!R||R.isReady())return P();const{docId:N}=R.get();return R.whenReady().then(()=>e.readDocument()?.get().docId===N?P():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(p())},fireContentChanged(){e.events.contentChanged(l())}};return E}var up=class extends Error{showId;constructor(e,t){super(`[useblocks] 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}},fp=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(ve("Superseded by newer show()")),n.aborted?Promise.reject(ve(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const i=setTimeout(()=>{this._settle(e.showId,()=>{o(new up(e.showId,t))})},t);i.unref?.();const s=()=>{this._settle(e.showId,()=>{o(ve(n.reason))})};n.addEventListener("abort",s,{once:!0});const a=()=>{clearTimeout(i),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:i,dispose:a});for(const l of this._listeners)l(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 pp(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function hp(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Ds(e),n=Os(e),r=fd(e.sandbox);t<n+r}var Sa=class{_controller=new AbortController;_externalSignalDisposable=new ue;_sessionChangeListeners=new Set;_showRegistry=new fp;_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 Ds(this._timeouts)}getSandboxTimeoutMs(e){return Ps(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return Os(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=pp(this._timeouts,e.timeouts),hp(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 ue,this._linkExternalSignal(e)}abort(e){const t=e??ve("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ue}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ue,this._showRegistry.rejectAll(ve("Init session replaced")),this._controller.signal.aborted||this._controller.abort(ve("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??ve()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??ve()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},ho=(()=>{const e=new Sa;return e.configure({}),e})();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 $e(e){return!e||e==="none"}function mp(e){const t=e.contain??"",n=e.willChange??"";return!$e(e.transform)||!$e(e.perspective)||!$e(e.filter)||!$e(e.backdropFilter)||!$e(e.translate)||!$e(e.rotate)||!$e(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function ei(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 gp(e){const t=[],n=document.documentElement,r=ei(getComputedStyle(n)),o=r.x||r.y;let i="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(i=s);for(let a=Qe(e);a&&a!==n;a=Qe(a)){const l=getComputedStyle(a),c=i==="none"||mp(l)||i==="absolute"&&!!l.position&&l.position!=="static",d=a===document.body&&!o;if(c){i="none";const p=d?{x:!1,y:!1}:ei(l);(p.x||p.y)&&t.push({node:a,...p})}(l.position==="absolute"||l.position==="fixed")&&(i==="none"||l.position==="fixed")&&(i=l.position==="fixed"?"fixed":"absolute")}return t}function Ia(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 Yt(e){return Number.parseFloat(e)||0}function yr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=Ia(e),o=Yt(n.borderLeftWidth),i=Yt(n.borderTopWidth),s=Yt(n.borderRightWidth),a=Yt(n.borderBottomWidth),l=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-s):0,c=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-i-a):0;return{left:t.left+o*r.x,top:t.top+i*r.y,right:t.right-(s+l)*r.x,bottom:t.bottom-(a+c)*r.y}}function vp(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(i,s,a)=>{s&&(r.left=Math.max(r.left,i.left),r.right=Math.min(r.right,i.right)),a&&(r.top=Math.max(r.top,i.top),r.bottom=Math.min(r.bottom,i.bottom))};return t.forEach(i=>o(yr(i.node),i.x,i.y)),n&&o(yr(n),!0,!0),r}var Er={originX:0,originY:0,scaleX:1,scaleY:1};function vn(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 Ca(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,o=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*o,scaleX:r,scaleY:o}}function Ta(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 bp=1e3;function yp(e){const{slot:t,own:n}=e;let r,o=0,i=!1;const s=()=>{if(r=void 0,!i){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(s))}},a=()=>{!i&&r===void 0&&(r=window.requestAnimationFrame(s))},l=()=>{o=performance.now()+bp,a()},c=[window],d=[document.documentElement];for(let y=t;y;y=Qe(y)){const R=y.getRootNode();R instanceof ShadowRoot&&!c.includes(R)&&(c.push(R),d.push(R))}const p=[["scroll",a],["load",a],["transitionrun",l],["transitionend",a],["transitioncancel",a],["animationstart",l],["animationend",a],["animationcancel",a]];c.forEach(y=>p.forEach(([R,P])=>y.addEventListener(R,P,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const b=typeof MutationObserver=="function"?new MutationObserver(y=>{y.some(R=>!n.contains(R.target))&&a()}):void 0;d.forEach(y=>b?.observe(y,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let E;try{if(typeof ResizeObserver=="function"){const y=new ResizeObserver(a);typeof y.observe=="function"&&(E=y)}}catch{E=void 0}let w=[];return{schedule:a,observe:y=>{!E||y.length===w.length&&y.every((R,P)=>R===w[P])||(E.disconnect(),w=y,y.forEach(R=>E?.observe(R)))},dispose(){i=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),c.forEach(y=>p.forEach(([R,P])=>y.removeEventListener(R,P,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),b?.disconnect(),E?.disconnect()}}}var Ep="pluginZoom",_p=/^(?:ant|vscode|monaco|docs)-/;function wp(e){return _p.test(e)}function Sp(){const e="ub".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 Ip=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function Cp(){return Ip}var Tp=new Set;function Ap(e,t,n=Tp){return e.startsWith(`${t}-`)?!1:!wp(e)&&!n.has(e)}function Rp(e,t){return`--${t}-${e}`}function Aa(e){const t=Sp();return Ap(e,t,Cp())?Rp(e,t):`--${e}`}function Pp(e,t){const n=Aa(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function Ra(e,t){return Pp(e,t)}var Pa=300,ti=15e3,Dp=5e3,ni="em-canvas-busy-style";function Op(){if(document.getElementById(ni))return;const e=document.createElement("style");e.id=ni,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var kp="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 xp(e){const t=Ra("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(Aa("colorPrimary")).trim()||t}function Da(e){Op();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",kp),n.appendChild(r);const o=document.createElement("span");return o.setAttribute("role","img"),o.setAttribute("aria-label","loading"),o.setAttribute("style",`display:inline-flex;color:${xp(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function Mp(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),i=Math.min(r.right,e.right,n.width),s=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return i<=o||a<=s?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+i)/2-e.left,y:(s+a)/2-e.top}}function Lp(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const o={left:n.left,top:n.top,right:n.right,bottom:n.bottom},i=r.getBoundingClientRect();if(i.width>0&&!Ta({left:i.left,top:i.top,width:i.width,height:i.height},o)){const s=vn(o,Ca(i,vn(o,Er),Er));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=Mp(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(Da(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Gn(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(Da(e))},Pa);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var Np=8e3;function Fp(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function Bp(e,t){for(let n=Qe(e);n;n=Qe(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",i=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>rt(s)>0);if(o&&i)return n;if(n===t)return null}return null}function rt(e){return Number.parseFloat(e)||0}function Xt(e,t){return Math.abs(e-t)<=1}function jp(e){const t=getComputedStyle(e),n=rt(t.borderTopWidth),r=rt(t.borderRightWidth),o=rt(t.borderBottomWidth),i=rt(t.borderLeftWidth),s=(a,l,c)=>Math.max(0,rt(a)-Math.max(l,c));return{...yr(e),radii:[s(t.borderTopLeftRadius,n,i),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,o,r),s(t.borderBottomLeftRadius,o,i)]}}function Up(e,t){const n=Xt(t.top,e.top),r=Xt(t.bottom,e.bottom),o=Xt(t.left,e.left),i=Xt(t.right,e.right),s=[n&&o?e.radii[0]:0,n&&i?e.radii[1]:0,r&&i?e.radii[2]:0,r&&o?e.radii[3]:0];return s.every(a=>a===0)?"":s.map(a=>`${a}px`).join(" ")}function Hp(e,t,n,r,o,i){const s=n.readyTimeoutMs??Np,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",Ra(Ep,"1"));const l=n.resolveSrc(e),c=document.createElement("iframe");c.setAttribute("sandbox",n.resolveSandbox(l)),c.setAttribute("allow","clipboard-read; clipboard-write"),c.setAttribute("title","Email content"),c.style.width="100%",c.style.border="0",c.style.display="block",c.style.minHeight="600px",c.src=l,a.appendChild(c),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(c);const d=new ue;let p=!1,b,E=!1,w,I,y,R;const P=()=>{clearTimeout(R),R=setTimeout(()=>{E||(E=!0,I?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},N=()=>p?(y=Promise.resolve(),E=!0,y):(E=!1,y=new Promise((M,$)=>{w=M,I=$}),P(),y),D=()=>{if(clearTimeout(R),p=!0,E){y=Promise.resolve();return}E=!0,n.mark?.("loaded"),w?.()};c.addEventListener("load",D),d.addDispose(()=>{clearTimeout(R),c.removeEventListener("load",D)});let k;const _=()=>{k??=n.bindResizer?.(c)},S=()=>{k?.dispose(),k=void 0};let T=null,m=null,u,f=Er,g="",v="",C=0;const x=M=>{const $=JSON.stringify(M);return $===g?!1:(g=$,a.style.visibility=M.visibility,a.style.left=`${M.css.left}px`,a.style.top=`${M.css.top}px`,a.style.width=`${M.css.width}px`,a.style.height=`${M.css.height}px`,a.style.borderRadius=M.radius,c.style.width=M.elementWidth>0?`${M.elementWidth}px`:"100%",c.style.transform=M.shiftX!==0?`translate(${M.shiftX}px, ${M.shiftY}px)`:`translateY(${M.shiftY}px)`,!0)};let O=!1;const h=()=>{if(!T)return g="",a.style.visibility="hidden",c.removeAttribute("id"),!1;n.elementId&&(c.id=n.elementId);const M=T.getBoundingClientRect(),$=gp(T),Y=m?.isConnected?m:null;u?.observe([T,c,...$.map(oe=>oe.node),...Y?[Y]:[]]);const Q=vp(M,$,Y),Z=Math.max(0,Q.right-Q.left),et=Math.max(0,Q.bottom-Q.top),vt=getComputedStyle(T).visibility==="visible",Ue=Z<=0||et<=0,ke=Ue?{left:Q.left,top:Q.top,right:Q.left,bottom:Q.top}:Q,L=Ue?null:Bp(T,Y??$[0]?.node??null),X=L?Up(jp(L),ke):"",K=oe=>x({visibility:vt&&!O?"":"hidden",css:vn(ke,oe),elementWidth:M.width/oe.scaleX,shiftX:(M.left-ke.left)/oe.scaleX,shiftY:(M.top-ke.top)/oe.scaleY,radius:X});let he=K(f);if(!Ue){const oe=a.getBoundingClientRect();oe.width>0&&!Ta({left:oe.left,top:oe.top,width:oe.width,height:oe.height},ke)&&(f=Ca(oe,vn(ke,f),f),he=K(f)||he)}return he},A=()=>{if(!T)return!1;let M=h();const $=c.getBoundingClientRect().height;$>0&&$!==C&&(C=$,T.style.height=`${$/Ia(T).y}px`,M=!0);const Y=getComputedStyle(T).pointerEvents;return Y!==v&&(v=Y,a.style.pointerEvents=Y),M},F=()=>{u?.dispose(),u=void 0},V=M=>{u=yp({slot:M,own:a,measure:A,onDetached:F})};let q=[];const W=(M,$)=>{if(m=$,M&&q.length>0){const Y=q;q=[],Y.forEach(Q=>Q())}if(M===T){M&&!u&&V(M),A();return}if(F(),T&&T.style.removeProperty("height"),g="",C=0,v="",T=M,!M){h(),S();return}n.onShown?.(c),V(M),A(),_()};d.addDispose(F);const B=M=>{p=!1,b=void 0,i?.(),M&&n.onReload?.(c);let $;E||y===void 0?$=N():(P(),$=y);try{c.contentWindow?.location.reload()}catch{c.src=l}return $};return{element:c,ready(){return y??N()},reload:()=>B(!0),reloadQuietly:()=>B(!1),followReload:()=>{b=void 0,i?.(),n.onReload?.(c)},moveTo(M){if(a.parentNode===M)return y??N();p=!1,b=void 0,i?.();let $;return E||y===void 0?$=N():(P(),$=y),M.appendChild(a),n.onReload?.(c),g="",u?.schedule(),$},get shown(){return T!==null},get slot(){return T},whenShown(){return T!==null?Promise.resolve():new Promise(M=>{q.push(M)})},get filled(){return b},noteFilled(M){b=M},alignTo(M,$){W(M,$??null)},hold(M){O!==M&&(O=M,h())},scrollBy(M,$){let Y=M,Q=$;for(let Z=T?Qe(T):null;Z;Z=Qe(Z)){if(Math.abs(Y)<1&&Math.abs(Q)<1)return;const et=getComputedStyle(Z);if((et.overflowY==="auto"||et.overflowY==="scroll")&&Z.scrollHeight>Z.clientHeight){const vt=Z.scrollTop,Ue=Z.scrollLeft;Z.scrollBy({left:Y,top:Q,behavior:"instant"}),Y-=Z.scrollLeft-Ue,Q-=Z.scrollTop-vt}}(Math.abs(Y)>=1||Math.abs(Q)>=1)&&window.scrollBy({left:Y,top:Q,behavior:"instant"})},resize(){k?.resize()},dispose(){W(null,null),S(),d.dispose(),a.remove()}}}function $p(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(f,g)=>f==="email"?`email:${g??n}`:f,i=new Map;let s,a=[],l=!1,c,d,p=!1,b,E,w="shown",I=0,y,R,P;const N=f=>d!==void 0&&f.filled!==void 0&&f.filled!==d,D=()=>{y=void 0;const f=b;!p||!f||d===void 0||R===d||!N(f)||(R=d,e.onForeignDocument?.({wanted:d,filled:f.filled,role:w,heldMs:Date.now()-I}))},k=()=>{p=!1,b=void 0,E=void 0,clearTimeout(y),y=void 0},_=(f,g)=>{const v=i.get("email"),C=v?.slot??null;return f&&C&&N(f)?(f.alignTo(null),p||(p=!0,I=Date.now(),y=setTimeout(D,Dp)),w=g,b=f,!(s!==void 0||l)&&E!==f&&(E=f,e.onShown?.(f.element)),!c&&!s&&(c=Gn(C)),!1):(p&&(k(),c?.remove(),c=void 0),f?.alignTo(C,v?.clip??null),!0)},S=()=>{p&&!l&&_(t.get(o("email")),"shown")},T=()=>{a.forEach(f=>clearTimeout(f)),a=[],s?.remove(),s=void 0,c?.remove(),c=void 0,(l||p)&&(l=!1,_(t.get(o("email")),"shown"))},m=(f,g,v)=>{const C=o(f,g),x=t.get(C);if(x)return x;const O=e.resolveMount();if(!O)return Fp();const h=Hp(f,O,e,f==="email"?g??n:void 0,v,f==="email"?()=>S():void 0);return t.set(C,h),h},u={get:f=>m(f),current:f=>m(f),peek:f=>t.get(o(f)),spare:()=>t.get(o("email",r())),ensureSpare:()=>m("email",r(),!0),promote(){const f=t.get(o("email",r()));if(!f)return;const g=t.get(o("email"));n=r(),P=void 0,_(f,"spare"),g?.alignTo(null)},alignSurface(f,g,v){const C=i.get(f);if(i.set(f,{slot:g,clip:v??null}),f==="email"&&l){c?.remove(),c=g?Gn(g):void 0;return}const x=g?m(f):t.get(o(f));if(f!=="email"){x?.alignTo(g,v??null);return}if(!g){P=C?.slot&&x?.shown?{slot:C.slot,handle:x}:void 0,p&&(k(),c?.remove(),c=void 0),x?.alignTo(null);return}const O=P?.slot===g&&P.handle===x;if(P=void 0,C?.slot===g&&x?.shown||O){x?.alignTo(g,v??null);return}_(x,"shown")},want(f){d=f,f!==void 0&&S()},noteFilled(f,g){const v=u.byWindow(f);v&&(v.noteFilled(g),v===t.get(o("email"))&&S())},visible(){for(const f of t.values())if(f.shown)return f},byWindow(f){if(f){for(const g of t.values())if(g.element.contentWindow===f)return g}},busy(f){if(T(),!f)return;if(!u.visible()){l=!0,c?.remove(),c=void 0;const C=i.get("email");C?.slot&&(c=Gn(C.slot)),a=[setTimeout(T,ti)];return}const g=e.resolveMount();if(!g)return;const v=Lp(g,()=>u.visible()?.element.parentElement?.getBoundingClientRect()??null);s=v,a=[setTimeout(()=>v.showSpinner(),Pa),setTimeout(T,ti)]},remount(f){T();const g=o("email");t.forEach((v,C)=>{if(C===g){v.moveTo(f).catch(()=>{});return}v.dispose(),t.delete(C)})},dispose(){d=void 0,l=!1,k(),P=void 0,T(),t.forEach(f=>f.dispose()),t.clear(),i.clear(),n="a",d=void 0,R=void 0}};return u}var qp=H("canvas.resizerBinder"),_r=H("canvas.service"),Gp={created:ce.canvasCreated,loaded:ce.canvasLoaded},Oa=new WeakMap;function wr(e){return Oa.get(e)??0}function Vp(e,t){if(e.getInstance(_r))return;const n=$p({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:Pf,elementId:t.elementId,bindResizer:o=>e.getInstance(qp)?.(o),onCreated:o=>Rt(e,o,"fresh"),onReload:o=>{Oa.set(o,wr(o)+1),Rt(e,o,"fresh")},onShown:o=>{const i=n.byWindow(de(e).getTarget());i&&i.element!==o&&ri(i.element)===ri(o)||Rt(e,o,"switch")},mark:o=>t.mark?.(Gp[o]),onForeignDocument:o=>{({...o},vd("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:o.role},contexts:{canvasIdentity:{...o,path:window.location.pathname}}}))}}),r=de(e).addListener(z.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(_r,n),e.getInstance(G)?.addDispose(()=>{r.dispose(),n.dispose()})}function ri(e){return e.parentElement?.dataset.canvasHost}function Rt(e,t,n){const r=de(e),o=t.contentWindow;if(!o)return;const i=r.getTarget()===o;i&&n==="switch"||(n==="fresh"&&(r.forget(o),i&&r.setTarget(void 0)),r.setTarget(o),df(r))}function zp(e,t){Rt(e,t,"promote")}function Wp(e,t){Rt(e,t,"switch")}function Kp(e,t){const n=t.contentWindow;n&&de(e).greet(n)}function ka(e,t){const n=t.contentWindow;n&&de(e).forget(n)}function Yp(e,t){const n=se(e)?.byWindow(t)?.element;if(!n)return;const r=wr(n);return()=>wr(n)!==r}function se(e){return e.getInstance(_r)}function xa({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:i}){if(!r)return;const s={id:o??void 0,renderGuid:n,showId:i?.id,isNew:o==null,showToken:i?.token},a={...e,...s};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function Pn(e){return{...xa({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function sn(e){const t=le(e),n=t.current();if(!n||!te(t.sessionKey()))return;const r=Pn(n),o=n.isDirty();ae(e,j.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function Xp(e){const t=le(e);return!t.current()||!te(t.sessionKey())?!1:(sn(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function Jp(e){const t=le(e),n=de(e),r=()=>e.getInstance(Pe)??ho;let o,i,s=!1,a=!1,l,c;const d=v=>Pn(v),p=()=>{const v=N(),C=v?.get().docId;if(!v||!C||C!==l||s)return;const x=v.get().version;x!==c&&(c=x,ae(e,j.ON_BLOCK_CHANGED_ID).fire(d(v)))};let b;const E=v=>{const C=t.showFacts();!C||C.id===b||!po(v,C.id)||(b=C.id,v.completeShow(C.id))},w=async(v,C,x)=>{const O=x.generation,h=()=>x.generation!==O||x.signal.aborted||t.current()!==v||a,A=Se(n);let F;const V=new Promise(W=>{F=hn(n,()=>W("regenerated"))}),q=async(...W)=>await Promise.race([Ve(...W).then(()=>"sent"),V])==="sent";s=!0;try{if(!await q(n,"INIT_START",z.SANDBOX_INIT_START,{guid:C},void 0,x)||h())return;const{html:W,hasBrowserExtensionArtifacts:B}=ba(mn(v));if(B&&ae(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),ya(v,W),!await q(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,gn(mn(v),C,Ze(e).editorPolicy,v.get().version),void 0,x)||h()||!await q(n,"INITED",z.SANDBOX_INITED,{guid:C},void 0,x)||h())return;o=C,i=A,D(),c=v.get().version,l!==C&&(l=C,ae(e,j.ON_BLOCK_INIT_ID).fire(d(v))),E(x)}finally{F?.(),s=!1,Se(n)!==A&&S()}};let I,y,R;const P=()=>{const v=se(e)?.peek("block");return v?.reload?(v.reload().catch(()=>{}),!0):!1},N=()=>te(t.sessionKey())?t.current():void 0,D=()=>{const v=N()?.get().docId,C=!v||R===v||o===v&&i===Se(n);se(e)?.peek("block")?.hold(!C)},k=()=>{if(a||(D(),p(),s))return;const v=N(),C=v?.get().docId;if(!v||!C)return;if(o===C&&i===Se(n)){E(r());return}if(!v.isReady())return;const x=r();x.signal.aborted||o!==void 0&&o!==C&&I!==C&&(I=C,P())||w(v,C,x).catch(()=>{if(!(a||t.current()!==v)){if(y!==C){y=C,P();return}R=C,D()}})};let _=!1;const S=()=>{_||a||(_=!0,queueMicrotask(()=>{_=!1,k()}))};let T,m;const u=()=>{const v=N(),C=v?.get().docId;C!==m&&(T?.(),m=C,T=v?.subscribe(S)),D(),S()},f=t.subscribe(u),g=hn(n,()=>{D(),S()});u(),e.getInstance(G)?.addDispose(()=>{a=!0,g(),T?.(),f()})}function Qp(e){const t=le(e);let n="email";const r=()=>{if(!t.current())return;const i=te(t.sessionKey())?"block":"email",s=se(e);if(i===n||!s)return;n=i;const a=s.peek(i);if(a){Wp(e,a.element);return}s.get(i)},o=t.subscribe(r);e.getInstance(G)?.addDispose(o)}var Zp=200;function eh({startVersion:e,limit:t=Zp}){let n=[],r=e;const o=i=>{n=n.filter(s=>s.version>i),r=Math.max(r,i)};return{record(i){!i.changes?.length&&!i.contentReplaced||(n.push(i),n.length>t&&o(n[n.length-t-1].version))},rebase(i,s){if(s<r)return null;const a=n.filter(c=>c.version>s);o(s);let l=i;for(const c of a){if(c.contentReplaced||!c.changes)return null;const d=c.changes,p=[];for(const b of l){if(c.fromCanvas&&d.some(w=>b.range.start<=w.oldEnd&&b.range.end>=w.oldPosition))return null;const E=Sd(b.range,d,"after");if(!E)return null;p.push({range:E,text:b.text})}l=p}return l}}}function th(e,t){let n=0;return e.map(({start:r,end:o,text:i})=>{const s=new Ie(r,t.slice(r,o),r+n,i);return n+=i.length-(o-r),s})}function nh(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return th(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function rh(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var mo=H("canvas.sandboxFill");function Ma(e){return e.getInstance(mo)?.pipeline.isEventsLocked()===!0}function Jt(e){kt(e,{origin:"canvas-channel"})}function oh(e){const t=le(e),n=de(e);let r;const o=(l,c)=>{const d=l.get().docId;let p=!1,b=null,E=null;const w=eh({startVersion:l.get().version});let I=l.getContent(),y=!0;const R=(S,T)=>{!y||t.current()!==l||(kt(T,{origin:"canvas-channel"}),n.sendAsync(z.SANDBOX_SET_ENTITY,gn(mn(l),d,Ze(e).editorPolicy,l.get().version)).catch(Jt))},P=async(S,T)=>{if(E){E.push({edits:S,rev:T});return}E=[{edits:S,rev:T}];try{do{const m=E.splice(0,E.length);await n.sendAsync(z.SANDBOX_UPDATE_ENTITY,{edits:m.map(u=>u.edits),guid:d,rev:m[m.length-1].rev})}while(E.length)}catch(m){R("app edits failed to reach the canvas",m)}finally{E=null}},N=(S,T)=>{const m=E?.splice(0,E.length)??[];m.length&&n.sendAsync(z.SANDBOX_UPDATE_ENTITY,{edits:m.map(u=>u.edits),guid:d,rev:m[m.length-1].rev}).catch(Jt),n.sendAsync(z.SANDBOX_UPDATE_ENTITY,{edits:[S],guid:d,rev:l.get().version,...T!==null?{changeId:T}:{}}).catch(Jt)},D=S=>{const{guid:T,pushUndoStop:m}=S;if(T!==d)return;const u=Md(S);let{edits:f}=S;if(u.baseRev!==null){const v=w.rebase(f,u.baseRev);if(!v){kt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),N([],u.changeId);return}f=v}const g=l.get().version;try{p=!0,b=u.changeId;const v=nh(f,l.getContent());m===!1?c.applyWithoutHistory(v):l.mutate({changes:v},{source:Ma(e)?"system":"user"})}catch(v){R("canvas batch failed to apply",v);return}finally{p=!1,b=null}l.get().version===g&&u.baseRev!==null&&N([],u.changeId)},k=l.subscribe(({changes:S,version:T})=>{const m=l.getContent(),u=!S?.length&&m!==I;if(I=m,w.record({version:T,changes:S,contentReplaced:u,fromCanvas:p}),!S?.length)return;const f=rh(S);p?N(f,b):P(f,T).catch(Jt)}),_=n.addListener(z.APPLICATION_UPDATE_ENTITY,D);return()=>{y=!1,k(),_.dispose()}};let i;const s=()=>{const l=t.current(),c=t.history(),d=l?.get().docId;d!==i&&(r?.(),r=void 0,i=d,l&&c&&(r=o(l,c)))},a=t.subscribe(s);s(),e.getInstance(G)?.addDispose(()=>{r?.(),a()})}function ih(e){const t=de(e),n=()=>se(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(z.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(z.RELOAD,a=>{const l=se(e)?.byWindow(a);l&&ka(e,l.element)}),i=t.addListener(a=>{a.data?.operation===z.SANDBOX_RESIZED&&n()?.resize()}),s=J(e,j.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(G)?.addDispose(()=>{r.dispose(),o.dispose(),i.dispose(),s.dispose()})}function oi(){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 sh(e){const t=e.getInstance(pe);let n,r;e.getInstance(G)?.addDispose(()=>{r?.remove(),r=void 0}),Vp(e,{resolveMount:()=>n,resolveSrc:i=>ha(i==="block"),elementId:"email_iframe",mark:i=>ne(i)}),t?.watch(i=>{const s=i?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,se(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(i!==void 0){n=r??=oi(),se(e)?.alignSurface("email",r,r);return}else return;se(e)?.get("email")}});let o;e.getInstance(G)?.addDispose(()=>{o?.remove(),o=void 0}),$u(e).watch(i=>{const s=se(e);if(s){if(i){o??=oi(),s.alignSurface("email",o,o);return}o&&(s.alignSurface("email",null),o.remove(),o=void 0)}})}var go=H("canvas.headerFlow"),ii=["subject","preheader"],si=3e3,ah=3,lh={subject:z.SANDBOX_SUBJECT_UPDATE,preheader:z.SANDBOX_PREHEADER_UPDATE};function ch(e){const t=le(e),n=de(e),r=k=>k?"remote":Ma(e)?"system":"user",o=(k,{guid:_,value:S,forced:T})=>{const m=st(t);if(!m||typeof S!="string"||_&&_!==m.get().docId)return;const u=t.forcedHeaders();if(u?.[k]!==void 0&&!T&&S!==u[k])return;const f=m.get().attributes[k];if(!T&&E(k,S,f))return;const g=!T&&p.delete(k);T&&(y.delete(k),y.size===0&&t.endForcedHeaders());const v=f??"";l=!0;try{ft(m,{[k]:S},{source:g?"system":r(T)})}finally{l=!1}i[k]=S,ae(e,j.ON_HEADER_APPLIED_ID).fire({field:k,value:S,forced:!!T,isGenerated:S!==v&&!!S})};let i={},s,a,l=!1,c=Promise.resolve();const d={},p=new Map,b=(k,_)=>{i[k]=_;const S={};p.set(k,S);const T=()=>{p.get(k)===S&&p.delete(k)};w(k,_,{force:!0}).then(T),setTimeout(T,si)},E=(k,_,S)=>{const T=t.showFill();if(!T||typeof S!="string")return!1;const m=d[k]?.showId===T.showId?d[k]:void 0;return _===S?(d[k]=m??{showId:T.showId,codeEdits:T.codeEdits,corrections:0},!1):m&&T.codeEdits>m.codeEdits&&_!==m.stale?!1:((!m||_===m.stale&&m.corrections<ah)&&(d[k]={showId:T.showId,stale:_,codeEdits:T.codeEdits,corrections:(m?.corrections??0)+1},b(k,S)),!0)},w=(k,_,{force:S=!1,echo:T=!1,undoStep:m=!1})=>(c=n.sendAsync(lh[k],{value:_,guid:st(t)?.get().docId,...S?{force:!0}:{},...T?{echo:!0}:{},...m?{undoStep:!0}:{}}).catch(u=>{}),c);let I;const y=new Set;e.inject(go,{whenDelivered:async()=>{await c},reassert:k=>{const _=st(t),S=ii.filter(T=>typeof k[T]=="string");if(!(!_||S.length===0)){l=!0;try{ft(_,Object.fromEntries(S.map(T=>[T,k[T]])),{source:"system"})}finally{l=!1}t.beginForcedHeaders(Object.fromEntries(S.map(T=>[T,k[T]]))),clearTimeout(I),I=setTimeout(()=>{y.clear(),t.endForcedHeaders()},si),y.clear();for(const T of S)y.add(T);for(const T of S)i[T]=k[T],w(T,k[T],{force:!0,echo:!0})}}});const R=()=>{s?.(),s=void 0;const k=st(t);if(k!==a&&p.clear(),a=k,!k){i={};return}const _=k.get().attributes;i={subject:_.subject,preheader:_.preheader},s=k.subscribe(({source:S})=>{if(l)return;const T=k.get().attributes,m=t.forcedHeaders();for(const u of ii){const f=T[u];if(f===i[u])continue;i[u]=f,p.delete(u);const g=S==="system"&&m?.[u]!==void 0;w(u,f??"",{force:g,echo:g,undoStep:S==="user"})}})};R();const P=t.subscribe(R),N=n.addListenerAsync(z.APPLICATION_SUBJECT_UPDATE,k=>o("subject",k)),D=n.addListenerAsync(z.APPLICATION_PREHEADER_UPDATE,k=>o("preheader",k));e.getInstance(G)?.addDispose(()=>{N.dispose(),D.dispose(),P(),s?.(),clearTimeout(I)})}function dh(e){const t=le(e);let n={document:void 0,seq:0};const r=()=>{const i=t.recoveryFacts(),s=st(t);if(!i?.applied||!s||String(i.emailId)!==String(s.get().serverId)||(n.document!==s&&(n={document:s,seq:0}),i.applied.seq<=n.seq))return;n={document:s,seq:i.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(go)?.reassert(a)},o=t.subscribe(r);e.getInstance(G)?.addDispose(o)}function uh(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?Cc:fc}function fh(e,t){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1}}function ph(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function ai(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 o=t[r],i=e[r];ai(o)&&ai(i)?n[r]=Sr(i,o):o!==void 0&&(n[r]=o)}return n}function hh(e,t){const n=Yr;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const o=JSON.parse(r);if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0)return Sr(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?Sr(n,t):n}var mh=ge(void 0),li=mh,La=H("CodeMode");function Na(){let e;try{const t=window.localStorage?.getItem(Wr.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 gh(e){try{window.localStorage?.setItem(Wr.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function vo(e){return e.getOrCreateInstance(La,()=>{const t=ge(Na());return t.watch(gh),t})}function Fa(e){return e?.getInstance(La)?.get()??Na()}function Ir(e,t){const n=vo(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function vh(e,t){const n=vo(e);n.set({...n.get(),direction:t})}var bh=H("DefaultCommonStyles");function Ba(e){return e.getOrCreateInstance(bh,()=>ge(void 0))}function yh(e,t){Ba(e).set(t)}var Eh=H("CanvasViewport"),_h=H("CanvasPreviewPage");function Le(e,t,n){let r,o;const i=()=>{if(!r||!e.isInited())return;const l=r.value===void 0?"undefined":JSON.stringify(r.value);l!==o&&(o=l,e.send(t,r.value))},s=n.watch(l=>{r={value:l},i()}),a=e.onInit(()=>{o=void 0,i()});return{dispose(){s.dispose(),a.dispose()}}}function Qt(e){const t=ge(e());return{source:t,refresh:()=>t.set(e())}}function wh(e){const t=de(e),n=e.getInstance(fe),r=e.getInstance(pe),o=le(e),i=vo(e),s=matchMedia(pc),a=()=>n?.get()??{};let l;const c=Qt(()=>uh(li.get()??a().theme,s.matches)),d=Qt(()=>fh(a(),te(o.sessionKey()))),p=Qt(()=>a().lockEditor),b=Qt(()=>hh(o.current()?.get().attributes?.common_styles,l)),E=e.getOrCreateInstance(Eh,()=>ge()),w=e.getOrCreateInstance(_h,()=>ge()),I=[Le(t,Me.theme,c.source),Le(t,Me.flags,d.source),Le(t,Me.lockEditor,p.source),Le(t,Me.commonStyles,b.source),Le(t,Me.codeMode,i.select(ph)),Le(t,Me.appName,ge("useblocks")),Le(t,Me.previewPage,w),Le(t,Me.viewport,E)],y=()=>{c.refresh(),d.refresh(),p.refresh()},R=n?.watch(y),P=Ba(e).watch(m=>{l=m,b.refresh()}),N=r?.watch(m=>{m&&"commonStyles"in m&&(l=m.commonStyles),b.refresh()});let D;const k=()=>{D?.(),D=o.current()?.subscribe(()=>b.refresh()),b.refresh(),d.refresh()};k();const _=o.subscribe(k),S=()=>c.refresh();s.addEventListener("change",S);const T=li.watch(()=>c.refresh());e.getInstance(G)?.addDispose(()=>{I.forEach(m=>m.dispose()),R?.dispose(),P.dispose(),N?.dispose(),D?.(),_(),s.removeEventListener("change",S),T.dispose()})}var Cr;(function(e){function t(o,i,s=(a,l)=>a===l){if(o===i)return!0;if(o.length!==i.length)return!1;for(let a=0;a<o.length;a++)if(!s(o[a],i[a]))return!1;return!0}e.isEqual=t;function n(o,i=s=>s){const s=new Set;return o.filter(a=>{const l=i(a);return s.has(l)?!1:(s.add(l),!0)})}e.unique=n;function r(o=[],i=[],s=(a,l)=>a===l){const a=[],l=[],c=[];for(const d of o){const p=i.find(b=>s(d,b));p?c.push({prev:d,next:p}):l.push(d)}for(const d of i)o.find(p=>s(d,p))||a.push(d);return{added:a,removed:l,exists:c}}e.diff=r})(Cr||(Cr={}));function Sh(e,t){return e.type===t.type&&e.key===t.key}function Ih(e){const t=de(e),n=()=>e.getServices(ot)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(z.SANDBOX_ADD_EXTENSIONS,r)}),i=Pc(ot),s=e.onInject(a=>{if(a!==i)return;const l=n();if(!t.isInited()){r=l;return}const{added:c,removed:d}=Cr.diff(r,l,Sh);if(r=l,d.length){if(d.some(p=>p.type==="script")){t.send(z.RELOAD);return}t.send(z.SANDBOX_REMOVE_EXTENSIONS,d.map(p=>p.key))}c.length&&t.send(z.SANDBOX_ADD_EXTENSIONS,c)});e.getInstance(G)?.addDispose(()=>{o.dispose(),s?.dispose()})}var Ch=new Set([...Object.values(z).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(Gr)]);function Th(e){return e.length>0&&!e.startsWith("em:")&&!Ch.has(e)}function Ah(e){const t=de(e),n=new Map;let r=!1,o=-1,i=new Set;const s=c=>(c!==o&&(o=c,i=new Set),i),a=t.observeOutgoing((c,d)=>{if(!r||!Th(c))return;const p=Se(t);n.set(c,{data:d,generation:p,scripts:new Set(s(p))})}),l=t.addListener(Gr,c=>{if(c.phase!=="ready"||c.status!=="success")return;r=!0;const d=Se(t),p=s(d);p.add(c.key);for(const[b,E]of n)E.generation===d||![...E.scripts].every(w=>p.has(w))||(E.generation=d,t.send(vs(b),E.data))});e.getInstance(G)?.addDispose(()=>{a.dispose(),l.dispose()})}var Rh=H("prewarm.editorVisible");function Ph(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Dh(e={}){const t=e.paint??Ph;let n=!1,r=!1,o=!1,i=!1,s=!1;const a=[],l=()=>{s||i||!n||!r||!o||(i=!0,t(()=>{s=!0,ne(ce.editorVisible);for(const c of a.splice(0))c()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){o=!0,l()},whenVisible(c){if(s){c();return}a.push(c)},contentShown:()=>o}}function Oh(e){return e.getOrCreateInstance(Rh,()=>Dh())}var kh=500,xh=500,Mh=5e3;function Lh(e){const t=e.quietMs??kh,n=e.floorMs??xh,r=e.ceilingMs??Mh;let o,i,s=0;const a=()=>{clearTimeout(o),clearTimeout(i),o=void 0,i=void 0},l=()=>{a(),e.run()},c=()=>{clearTimeout(o);const d=n-(Date.now()-s);o=setTimeout(l,Math.max(t,d))};return{start(){a(),s=Date.now(),i=setTimeout(l,r),c()},notify(){o!==void 0&&c()},cancel:a}}var Nh=2;function ci(){return new Error("[sandbox] document reloaded during fill")}function Fh(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Vn(e){try{e()}catch{}}function Bh(e){let t;return Vn(()=>{t=e()}),{stage:n=>Vn(()=>t?.stage(n)),end:(n,r)=>Vn(()=>t?.end(n,r))}}function jh(e){const t=()=>e.initPipeline();let n=!1,r,o,i,s=0,a,l;const c=()=>{const _=e.readTarget?.(),S=e.readSandboxGeneration?.();return _===void 0||S===void 0?void 0:{target:_,generation:S}},d=()=>{const _=c();return _&&{..._,canvasReplaced:e.trackDocument?.(_.target)}},p=_=>{if(_?.canvasReplaced?.())return!0;const S=c();return _!==void 0&&S?.target===_.target&&S.generation!==_.generation},E=dp({...e,waitScope:()=>({getSandboxTimeoutMs:_=>t().getSandboxTimeoutMs(_),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const _=l;if(!(!_||!e.onSandboxGenerationChange))return{getGeneration:()=>c()?.generation??_.generation,onChange:S=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===_.target||_.canvasReplaced?.())&&S()})??(()=>{})}}});let w;const I=(_,S)=>{if(w===_)return;w=_;const T=s;setTimeout(()=>{s!==T||t().signal.aborted||N(_,S).catch(()=>{})},0)},y=()=>{a?.abort(),a=void 0};let R;const P=()=>{const _=t().signal;_!==R&&(R?.removeEventListener("abort",y),R=_,_.addEventListener("abort",y))};async function N(_,S,T=0){const m=++s;y(),a=new AbortController,l=void 0,P();const u=()=>s!==m,f=E.readTarget(),g=t().generation,v=()=>g===t().generation&&!t().signal.aborted,C=S?"init:reset-":"init:",x=Bh(()=>e.observeShow?.(Fh(_,S,e.readEmail())));if(!S){const W=E.publicEmail();W?.id,W?.renderGuid,W?.preheader}let O=!1,h=!1,A,F=!1;const V=()=>{if(p(A))throw ci()},q=()=>{if(u())throw ve("Fill superseded")};try{n=!0,await E.sendInitStart(),q(),A=d(),l=A,T===0&&E.fireWillInit(),await(S||T>0?E.refreshContent():E.sendContent()),O=!0,q(),V();const W=E.contentSent();E.noteFilled(W?.target,W?.docId),x.stage("content"),S||E.publicEmail()?.id;try{await E.sendPreheader()}catch(B){if(Zo(B)||u())throw B;`${C}`,String(B)}q();try{await E.sendSubject()}catch(B){if(Zo(B)||u())throw B;`${C}`,String(B)}if(q(),V(),E.showFilled(f),await E.sendInited(),q(),V(),h=!0,o===_){const B=e.readSandboxGeneration?.()??i;B!==void 0&&(r=B)}x.stage("reveal"),await E.revealFilled(),V(),x.end("revealed")}catch(W){const B=!u()&&v()&&p(A),M=B?ci():void 0,$=M??W,Y=B&&T<Nh?k(_,S,T+1):void 0;F=B&&Y===void 0;const Q=u()?void 0:{showId:_,contentApplied:O,sandboxInitedAcked:h,superseded:!1,...e.describeSurface?.(),error:String(M??W)};Q&&(`${C}`,void 0);const Z=!u()&&e.recoverFailedFill?.(f)===!0;if(x.end(u()?"superseded":Z?"recovered":zr($)||!v()?"aborted":"failed",Q),!Z&&!u()&&po(t(),_)&&t().failShow(_,$),Y!==void 0)return Y;throw $}finally{D(_,S,C,{superseded:u(),sessionGeneration:g,contentApplied:O,sandboxInitedAcked:h&&!F,retry:!F,commit:v()})}}function D(_,S,T,m){const{superseded:u,contentApplied:f,sandboxInitedAcked:g}=m;if(u){`${T}`;return}g&&m.commit?E.fireInit(_,S||void 0):g?(`${T}`,m.sessionGeneration,t().generation,t().signal.aborted,void 0):f?(`${T}`,void 0):(`${T}`,void 0),n=!1,a=void 0,!g&&o===_&&(o=void 0,r===i&&(r=void 0)),!g&&f&&m.retry&&I(_,S)}function k(_,S,T){return N(_,S,T)}return{channel:E,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:_=>{r=_},lastCorrelation:()=>o,markCorrelation:_=>{o=_},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:_=>{i=_},fill:_=>N(_,!1),refill:_=>N(_,!0),stop:()=>{s+=1,y(),n=!1,R?.removeEventListener("abort",y),R=void 0}}}function Uh(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:ja(e,n)}function ja(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Hh(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:i}=e,s=d=>{const p=n(),b=o();if(!Uh(p,d,b)){d.showId,d.navId,d.emailId,p?.id,p?.showId,p?.renderGuid;return}d.showId,p?.id,p?.renderGuid,t.markFilled(i()),t.markCorrelation(d.showId),t.fill(d.showId).catch(()=>{})};return{showRequested:d=>{s(d)},showRequestIdentityChanged:()=>{const d=e.initPipeline().getActiveShowRequest();d&&s(d)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const d=i();if(t.filledGeneration()===d)return;const p=n(),b=o();if(!p?.renderGuid||!ja(p,b))return;const E=`${wa}${p.renderGuid}`;t.markFilled(d),t.markCorrelation(E);const w=r()?.isReady()===!0;p.id,p.renderGuid,(w?I=>t.refill(I):I=>t.fill(I))(E).catch(()=>{t.lastCorrelation()===E&&t.markFilled(void 0)})},saasChanged:()=>{const d=n();d?.renderGuid,d?.showToken,d?.id,r()}}}var $h=H("canvas.health");function qh(e){return e??""}function Gh(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function di(e){return e.length>0}function Vh(e){const t=le(e),n=de(e),r=()=>te(t.sessionKey())?void 0:t.current(),o=()=>{const L=r();return xa({attributes:L?.get().attributes??{},readContent:()=>L?.getContent(),docId:L?.get().docId,hasSession:!!L,serverId:L?.get().serverId,show:t.showFacts()})},i=()=>e.getInstance(Pe)??ho;let s={},a=!1;const l=e.getInstance(pe)?.watch(L=>{a=!!L?.element});let c=!1,d=!1,p=!1,b=0;const E=()=>{const L=se(e);if(!L)return;const X=++b,K=L.spare();return K&&ka(e,K.element),(K?K.reloadQuietly():L.ensureSpare()?.ready())?.then(()=>{if(X!==b)return;c=!0;const he=L.spare();he&&Kp(e,he.element),p&&(p=!1,g(),B())})},w=Lh({run:()=>{p||E()?.catch(()=>{})}}),I=()=>{Oh(e).noteContentShown(),!c&&!p&&w.start()};let y=!1;const R=L=>{const X=se(e),K=X?.spare()?.element.contentWindow;d&&X&&K&&L===K&&(d=!1,X.promote(),X.busy(!1),y=!0)};let P=!1;const k=jh({container:e,messageService:n,initPipeline:i,readDocument:r,readEmail:o,revealFilled:()=>{const L=se(e);return y&&L&&(y=!1,w.start()),a?L?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:R,noteFilled:(L,X)=>se(e)?.noteFilled(L,X),recoverFailedFill:L=>{const X=se(e),K=X?.spare()?.element.contentWindow;return!d||!X||!K||L!==K?!1:(d=!1,c=!1,u="reload",X.busy(!1),X.peek("email")?.reload(),P=!0,B(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>Se(n),onSandboxGenerationChange:L=>hn(n,L),trackDocument:L=>Yp(e,L),observeShow:L=>e.getInstance($h)?.begin(L),describeSurface:()=>({canvasPath:u,promoted:d,spareClean:c,handshake:n.isInited(),generation:Se(n)}),events:{willInit:L=>{ae(e,j.WILL_EMAIL_INIT_ID).fire(L)},inited:L=>{I(),ae(e,j.ON_EMAIL_INIT_ID).fire(L)},contentChanged:L=>{ae(e,j.ON_CONTENT_CHANGED_ID).fire(L)},emailChanged:L=>{ae(e,j.ON_EMAIL_CHANGED_ID).fire(L)},browserExtensionDetected:()=>{ae(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),_=Hh({pipeline:k,initPipeline:i,readEmail:o,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>Se(n)});let S="",T="",m="",u="none";const f=()=>{const L=se(e)?.spare()?.element.contentWindow;L&&n.getTarget()===L||n.sendNow({operation:z.SANDBOX_LOCK_EDIT,data:!0})},g=()=>{const L=se(e)?.spare();L&&(f(),c=!1,d=!0,zp(e,L.element))},v=(L,X)=>{const K=se(e);if(!K)return!0;const he=K.spare(),oe=he&&c?"spare":"prepare";if(u=oe,K.busy(!0),he&&c)return g(),!0;w.cancel(),f();const He=E();if(He===void 0)return u="reload",K.busy(!1),K.peek("email")?.reload(),!0;p=!0;const xe=b;return He.catch(()=>{!p||xe!==b||(p=!1,u="reload",K.busy(!1),K.peek("email")?.reload())}),!1},C=()=>{if(te(t.sessionKey()))return;et(),k.noteSandboxGeneration(Se(n));const L=o(),X=Gh(L?.renderGuid,L?.showId,L?.id,s.emailId),K=qh(L?.renderGuid);if(K!==T){const He=T;T=K;const xe=se(e)?.peek("email")?.filled,Ul=xe!==void 0&&xe!==K;di(K)&&(di(He)||Ul)&&v(He||(xe??""),K)}if(p)return;(X!==S||P)&&(P=!1,S=X,_.showRequestIdentityChanged());const he=r(),oe=`${X}|${he?.get().docId??""}|${Se(n)}`;oe!==m&&he?.isReady()===!0&&(m=oe,_.selfInitChanged()),_.saasChanged(),q()};let x=!1,O="",h="",A=!1,F=!1;const V=L=>{L.source==="user"?F=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(A=!0),B()},q=()=>{const L=o();if(!L?.renderGuid)return;const X=k.channel.readContent(),K=JSON.stringify([L.preheader,L.common_styles,L.meta,L.subject,L.utm_parameters?.utm_campaign??"",L.utm_parameters?.utm_content??"",L.utm_parameters?.utm_medium??"",L.utm_parameters?.utm_source??"",L.utm_parameters?.utm_term??""]),he=x&&X!==h,oe=x&&K!==O;x=!0,h=X,O=K;const He=A&&!F;if(A=!1,F=!1,k.isEventsLocked()||He)return;const xe={...L,id:s.isTemplate||L.isNew?void 0:L.id,html:X};if(he){ae(e,j.ON_CONTENT_CHANGED_ID).fire(X),ae(e,j.ON_EMAIL_CHANGED_ID).fire(xe);return}oe&&L.is_inited&&ae(e,j.ON_EMAIL_CHANGED_ID).fire(xe)};let W=!1;const B=()=>{W||(W=!0,queueMicrotask(()=>{W=!1,C()}))};e.inject(mo,{pipeline:k,setRoute:L=>{L.emailId===s.emailId&&!!L.isTemplate==!!s.isTemplate||(s=L,B())}});let M,$;const Y=()=>{const L=r()?.get().docId;L!==$&&(M?.(),$=L,M=r()?.subscribe(V)),B()};let Q,Z;const et=()=>{const L=e.getInstance(Pe);!L||L===Q||(Z?.(),Q=L,Z=L.onShowRequested(X=>_.showRequested(X)))},vt=n.addListener(L=>{L.data?.operation===z.SANDBOX_RESIZED&&w.notify()}),Ue=t.subscribe(Y),ke=hn(n,B);Y(),e.getInstance(G)?.addDispose(()=>{l?.dispose(),Z?.(),ke(),Ue(),M?.(),vt.dispose(),w.cancel(),k.stop()})}function zh(){return lc!=="useblocks"}var Ua={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},Wh={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}},ui=Ua,Kh=["freeUserBlocks","blocks"],Tr={};function Yh(e){Tr=e}var Ha=e=>Kh.includes(e)?ui:Tr[e]??Tr.editor??ui,Ar={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},Xh={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},Jh={...Ar,config:{...Ar.config,imageCenterFileManagerView:!1}};Yh({pro:Wh,editor:Xh,simple:zh()?Ar:Jh,blocks:Ua});function Qh(e,t,n=e.getInstance(fe)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Fa(e).isCodeMode&&Ir(e,!1)}function Zh(e){e.getInstance(_c)||e.inject(De,void 0)}function Dn(e){return String(e.standaloneKey||"").trim()||void 0}function em(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function bo(e){return em(e)?!!Dn(e):!1}function Ut(e){return!!Dn(e)&&!bo(e)}var tm=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function fi(e){return e==="server"?"serverSide":e}function nm({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=ge();let i={kind:"pending"},s;const a=new Promise(b=>{s=b}),l=n===void 0?void 0:setTimeout(()=>{d({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function c(){i.kind!=="pending"&&o.set(qn(r,e))}function d(b){if(i.kind!=="pending")return;clearTimeout(l),i=b;const E=qn(r,e);o.set(E),s(E)}function p(b,E){r[fi(b)]=E,b==="server"&&i.kind==="pending"?d({kind:"applied"}):c()}return{watch:b=>o.watch(b),select:b=>o.select(b),get:()=>o.get(),ready:()=>a,state:()=>i,layers:()=>({...r}),bootstrap(){const b=qn(r,e);return Object.fromEntries(tm.map(E=>[E,b[E]]))},merge(b,E){p(E,{...r[fi(E)],...b})},replace(b,E){p(E,b)},setMode(b){r.user={...r.user,mode:b},c()},setAdvancedConfigs(b){r.advancedConfigs=b,c()},serverAbsent(b){d({kind:"absent",reason:b})},applyServerResponse(b){i.kind==="pending"&&p("server",{...r.serverSide,...b})},dispose(){clearTimeout(l)}}}var rm=5e3,om="blocks";function im(){return{...Ha(om)?.config,mergeTags:void 0}}function sm(e,t){e.getInstance(pe)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},o=t.layers().user.mode;t.replace(r.mode===void 0&&o!==void 0?{...r,mode:o}:r,"user")})}function am(e,t){let n;lo(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const i={};r?.theme&&(i.theme=r.theme),r?.locale&&(i.locale=r.locale),t.replace(i,"profile")})}function lm(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function cm(e,t){let n,r=!1,o;const i=a=>{o??=An(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&Qh(e,a,t)},s=lo(e).watch(({profile:a})=>{const l=a?.email_builder_config,c=lm(l);if(c===void 0||l===n)return;const d=n===void 0;n=l,!(d&&r)&&i(c)});e.getInstance(G)?.addDisposable(s),t.ready().then(a=>{if(!a.configSwither)return;const l=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",l),r=n===void 0,i(l)})}var pi="замкнутый контур: app_init не выполняется";function dm(e,t){if(e.getInstance(De)){t.serverAbsent(pi);return}const n=e.getInstance(pe)?.watch(r=>{Ut(r)&&t.serverAbsent(pi)});n&&e.getInstance(G)?.addDisposable(n)}async function um(e,t){if(e.getInstance(Zr)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Be);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function fm(e){e.injectFactory(fe,(t,n)=>{if(n)return n;const r=nm({base:im(),env:{modeDefaults:o=>Ha(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:rm});return sm(e,r),am(e,r),cm(e,r),dm(e,r),um(e,r),e.getInstance(G)?.addDisposable(r),r},!0)}var ct=class extends ue{_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 U(e,t,n){const r=bc(e);return(o,i,s)=>{const a=r(async l=>{const c=t?t(l):l;s&&o.bind(s);const d=await o(c);return n?n(d):d},i,s);return()=>a.dispose()}}var pm=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new pr;this.handleDestroy=U(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new ct(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{}}},yo=H("DestroyableService");function hm(e){e.injectFactory(yo,(t,n)=>{if(n)return n;const r=e.getInstance(G);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new pm({lifetime:r,options:e.getInstance(pe),getInstance:()=>e.getInstance(In),release:()=>tc(e.getInstance(Tc)??e)})},!0)}function mm(e){const t=e.getInstance(yo);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var gm=1e3;function $a(e,t,n=gm,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const s of o)if(!$a(e[s],t[s],n,r+1))return!1;return!0}return!1}function Pt(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const o=t[r],i=e[r];$a(o,i)||(n[r]=o)}return n}var vm=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function bm(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function ym({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??Cn();let i;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,l)=>{i=setTimeout(()=>{const c=new Tn(o);n.value.id,Bd(c,bm(s,r)),l(c)},o)})])}catch(s){throw Bs(s),s}finally{i!==void 0&&clearTimeout(i)}}function Em(e){const{emails:t}=e,n=async(r,o)=>{const i=vm(o),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...i}:i,l=s?Pt(s,i):i,c=d=>{const p=String(d.id??r??Ee()),b=d.id===void 0?{...d,id:p}:d;return t.cache.addOrUpdate(p,()=>b)};return await c(await ym(e,{prev:s,patch:l,value:a,source:o.source??""},c))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const o=await n(void 0,r);return o?.renderGuid?o:{...o,renderGuid:Ee()}},async updateEmail(r,o){return await n(r,o)}}}var zn=20;function _m(e){const t=wm(e);return e.saveTimeoutMs?Sm(t,e.saveTimeoutMs):t}function wm({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:i}){const s=async(a,l)=>(t.clear(),await t.get(a,{page:l}),(await e.cache.values()??[]).filter(c=>String(c?.parent)===String(a)));return{async readRevisions(a,l=1){const c=await s(a,l);return{revisions:c.slice(zn*(l-1),zn*l),page:l,hasMore:c.length>zn*l}},async readAutosave(a){const l=await r?.(a)??NaN,c=Number.isFinite(l)?l:void 0,d=await n?.(a);if(!d?.asked)return zd(await s(a,1),c);if(!d.revision)return qo([],c);const p={...d.revision,parent:a,isAutosave:!0};return qo([p],c,await s(a,1))},async saveAutosave(a,l){const c=await o?.(a),d=i?.();return await e.create({...Qd(l),...c!==void 0?{author:c}:{},...d!==void 0?{project:d}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Sm(e,t){return{...e,async saveAutosave(n,r){const o=t();let i;try{return await Promise.race([e.saveAutosave(n,r),new Promise((s,a)=>{i=setTimeout(()=>a(new Ms(o)),o)})])}catch(s){throw Bs(s),s}finally{i!==void 0&&clearTimeout(i)}}}}var Im=class extends Rc{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}},Cm=class extends Fe{};var hi=class extends ue{_items=new Map;_onChangeEmitter=new Wl;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const o=await t(n);return Re(n,o)||this._onChangeEmitter.fire(),o}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([o,i])=>o)),r=(await this.entries()).filter(([o,i])=>!n.has(o));for(const[o,i]of e)t.push(this.addOrUpdate(o,()=>i)),n.add(o);for(const[o]of r)t.push(this.remove(o));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function Tm(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:i=20}={}){const s=e.length;let a=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(c=>{for(const d of l){const p=c[d],b=t[d];return d==="id"||typeof p!="string"?p===b:typeof b=="string"&&p.startsWith(b)}return!0}),a=e.length}return r&&(e=e.sort((l,c)=>(l[r]>c[r]?1:c[r]>l[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(i*(o-1),i*o)),{data:e,filteredTotal:a,total:s,totalPages:Math.ceil(a/i)}}function Am(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const o=t.get(r.id)||{};t.set(r.id,{...o,...r})}return[...t].map(([n,r])=>r)}function Rm(e,t){return mi(e)&&mi(t)?String(e)===String(t):e===t}function mi(e){return typeof e=="string"||typeof e=="number"}var Pm=class extends ue{_cache=new hi;_readEmitter=new Fe;_saveEmitter=this.addDisposable(new Im);_removeEmitter=this.addDisposable(new Cm);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ue);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new hi),o=n.addDisposable(new Fe);t=this._foreignCache[e]={get:async(i,s={})=>{await r.getOrCreate(i,async()=>{try{const l=Am(await o.fire(i))||[];for(const c of l)c[e]=i,await this._cache.add(c.id,c);return l}catch{return[]}});const a=(await this._cache.values()||[]).filter(l=>{const c=l[e];return c==null||Rm(c,i)});return Tm(a,s)},first(i,s={}){return t.get(i,{...s,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:o.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=Ee()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async o=>{const i=o?{...o,...t}:t;if(!r)return t=o?Pt(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:i,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function Ht(e){const t=H(e);return n=>n.getOrCreateInstance(t,()=>new Pm)}function qa(e){const t=e.getInstance(G);if(!t)throw new Error("Failed");return t}function gi(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Zt(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function Dm(e,t,n){return e&&!gi(t)&&gi(e)?{...n,meta:e.meta}:n}var Om=H("CurrentProject"),km={};function $t(e){return e?.getInstance(Om)?.get()??km}function Eo(e){const t=$t(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Ga=Ht("plugin.dataSource.emails"),Va=Ht("plugin.dataSource.emailRevisions"),za=Rn("plugin.readEmailAutosave"),vi=H("emailDocuments.provided");function xm(e){const t=Ga(e),n=Va(e),r=n.byForeignKey("parent");if(e.getInstance(vi))return{emails:t,emailRevisions:n};e.inject(vi,!0);const o=()=>Cn(e.getInstance(Pe)?.contentReadyTimeoutMs),i=Em({emails:t,saveTimeoutMs:o}),s=new Map,a=(l,c)=>d=>{const p=d?.id??c;return(typeof p=="string"||typeof p=="number")&&s.set(String(p),l),d};return Su(e,{...i,createEmail:l=>i.createEmail(l).then(a(Date.now())),updateEmail:(l,c)=>i.updateEmail(l,c).then(a(Date.now(),l))}),Au(e,_m({revisions:n,revisionsByEmail:r,readAutosave:async l=>{const c=await ae(e,za).fire(l);return c.length===0?{asked:!1}:{asked:!0,revision:c[0]??null}},savedAt:async l=>{const c=Gd((await t.cache.getIfPresent(l))?.modified),d=s.get(String(l))??NaN;return Number.isFinite(d)&&!(c>=d)?d:c},emailAuthor:async l=>(await t.cache.getIfPresent(l))?.author,saveTimeoutMs:o,integratorProject:()=>$t(e).requested})),qa(e).addDisposable(t.onSave(({prev:l,patch:c,value:d})=>Dm(l,c,d),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function bi(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 Mm(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Lm="po",en=null;function Nm(){const e=typeof window.__useblocks__<"u"?window.__useblocks__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([Lm],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Fm(){return en===null&&(en=Nm().catch(e=>{throw en=null,e})),en}async function Wa(e){if(typeof e=="object")return _o(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Bm(t):jm(t)}function _o(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Bm(e){try{return _o(JSON.parse(e))}catch{return}}var yi=!1;async function jm(e){try{return _o((await Fm()).parsePoCatalog(e))}catch{yi||(yi=!0);return}}var Um="em_locale",Hm="em_ant_locale",$m="locale",qm="ant_locale";function wo(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Ka(e,t){const n=wo(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function Gm(){return wo("em_locale")??Ka($m,"em_locale")}function Ei(e){try{localStorage.setItem(Um,JSON.stringify(e))}catch{}}function Vm(){return wo("em_ant_locale")??Ka(qm,"em_ant_locale")}function zm(e,t){try{localStorage.setItem(Hm,JSON.stringify({id:e,data:t}))}catch{}}var Wm=8e3;function Km(e,t){const n=e,r=t,o=Object.keys(n).filter(i=>i!=="");return o.length!==Object.keys(r).filter(i=>i!=="").length?!1:o.every(i=>JSON.stringify(n[i])===JSON.stringify(r[i]))}function Ym(e){const t=Gm(),n=Vm();let r={ready:!1},o;const i=ge(r);let s=0;const a=y=>{r={...r,...y},i.set(r)},l=()=>{r.ready||a({ready:!0})},c=setTimeout(l,e.unlockAfterMs??Wm),d=y=>y!==s;let p;async function b(y,R){if(n?.id===y&&n.data&&a({antd:n.data}),!p)return;const P=await p(y).catch(()=>{});!P||d(R)||(a({antd:P}),zm(y,P))}async function E(y,R){const P=await e.askHost(y).catch(()=>null);if(d(R))return!0;if(P==null)return!1;const N=await Wa(P);return d(R)||(N&&a({catalog:N}),l()),!0}async function w(y,R){const P=await e.readList();if(d(R))return;if("error"in P){a({failure:{kind:"GET_LOCALES_ERROR",error:P.error}}),l();return}const N=P.data.find(k=>k.locale===y);if(!N){Mm("em_locale")&&a({catalog:void 0}),l();return}if(bi(t,N)&&(!o||o.catalog===t?.data)){l();return}if(o?.entry&&r.catalog===o.catalog&&bi(o.entry,N)){Ei(o.entry),l();return}const D=await e.readCatalog(y);if(!d(R)){if("error"in D){a({failure:{kind:"GET_LOCALE_ERROR",error:D.error}}),l();return}D.data&&(o?.id===y&&r.catalog===o.catalog&&Km(o.catalog,D.data)||a({catalog:D.data}),Ei({id:y,time:N.updatedAt||Math.floor(Date.now()/1e3),hash:N.contentHash,data:D.data})),l()}}async function I(y,R){if(!await E(y,R)){if(!d(R)&&(o?.id===y&&r.catalog===o.catalog||y==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await w(y,R)}}return{set(y){if(!y||y===r.id)return;const R=s+=1;a({id:y,failure:void 0});const P=o?.id===y&&r.catalog===o.catalog;(o&&!P&&r.catalog===o.catalog||y==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===y&&t.data&&(a({catalog:t.data}),l()),b(y,R),I(y,R)},prime(y,R,P){r.id&&r.id!==y||r.catalog||!R||(o=t?.id===y&&t.data&&(!P||t.time>=P.time)?{id:y,catalog:t.data}:{id:y,catalog:R,entry:P?{id:y,time:P.time,hash:P.hash,data:R}:void 0},a({catalog:o.catalog}))},useAntdLoader(y){p=y,r.id&&b(r.id,s)},state:i,snapshot:()=>r,dispose:()=>clearTimeout(c)}}var Xm=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})},Jm=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:o,format:i,baseUrl:s,cancelToken:a,...l})=>{const c=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},d=this.mergeRequestParams(l,c),p=o&&this.toQueryString(o),b=this.contentFormatters[r||"application/json"],E=i||d.format;return this.customFetch(`${s||this.baseUrl||""}${n}${p?`?${p}`:""}`,{...d,headers:{...d.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):d.signal)||null,body:typeof e>"u"||e===null?null:b(e)}).then(async w=>{const I=w;I.data=null,I.error=null;const y=E?w.clone():w,R=E?await y[E]().then(P=>(I.ok?I.data=P:I.error=P,I)).catch(P=>(I.error=P,I)):I;return a&&this.abortControllers.delete(a),R})}},Qm=H("rest.v2.transport"),_i=Symbol("rest.v2.secureRequest");function Zm(e){return e.getOrCreateInstance(Qm,()=>{const t=e.getInstance(Kl)?.execute||fetch;return new Jm({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[_i]:!0}),customFetch:(n,r={})=>{const{[_i]:o,...i}=r;return t(n,{...i,[Xl]:o!==!0})}})})}function eg(e,t){const n=Zm(e);return Object.assign({},...t.map(r=>new r(n)))}function wi(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Ya(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:wi(n.details,"wp_code")??n.code,message:wi(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 Xa(e){return!e.ok||!!e.error}function tg(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Ja(){return tg(Wr.em_translations_v2)??!0}function ng(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function rg(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function og(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],o=r[0];return typeof o=="string"&&o!==""&&t.push({locale:o,updatedAt:ng(r[1])}),t},[]):[]}function ig(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:rg(n.updated_at),contentHash:n.content_hash}),t),[])}function Qa(e){return eg(e,[Xm])}function bn(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Rr(e){return!e.ok||e.error!=null}function Pr(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Wn(e){return{data:await Wa(e)??null}}async function sg(e){if(Ja())try{const n=await Qa(e).localesList();return Xa(n)?{error:Ya(n)}:{data:ig(n.data)}}catch(n){return bn(n)}const t=bs(e,[ws]);try{const n=await t.get_translations2({file:"react_app"});return Rr(n)?Pr(n):{data:og(n.data)}}catch(n){return bn(n)}}async function ag(e,t){if(Ja())try{const r=await Qa(e).jsonList({locale:t});return Xa(r)?{error:Ya(r)}:Wn(r.data)}catch(r){return bn(r)}const n=bs(e,[ws]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Rr(r)?Pr(r):Wn(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Rr(r)?Pr(r):Wn(r.data)}catch(r){return bn(r)}}}var tn=new WeakMap;function lg(e){const t=tn.get(e);if(t!==void 0)return t;const n=sg(e).then(r=>("error"in r&&tn.delete(e),r),r=>{throw tn.delete(e),r});return tn.set(e,n),n}var ht=H("locale.service");function cg(e){if(e.getInstance(ht))return;const t=Ym({readList:()=>lg(e),readCatalog:n=>ag(e,n),askHost:async n=>(await ae(e,j.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(De)});e.inject(ht,t),e.getInstance(G)?.addDispose(()=>t.dispose())}function dg(e){const t=e.getInstance(fe);if(!t)return;const n=e.getInstance(ht);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"en_US"));e.getInstance(G)?.addDisposable(r)}var ug="user_id",fg="project_id",Si=H("rest.identityHeadersProvided");function pg(e){if(e.getInstance(Si))return;e.inject(Si,!0);let t;e.getInstance(pe)?.watch(n=>{t=n}),e.addService(Sn,{execute(n,r){if(r?.public)return;const o=t?.user?.id??ta(e).profile?.id;o!=null&&o!==""&&n.headers.set(ug,String(o));const i=t?.project;i!=null&&i!==""&&n.headers.set(fg,String(i))}})}function hg(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function mg(e){return e.id??hg(e.catalog)}function gg(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function vg(e){return gg(e||"en_US")}var bg="Accept-Language",Ii=H("rest.localeHeaderProvided");function yg(e){e.getInstance(Ii)||(e.inject(Ii,!0),e.addService(Sn,{execute(t){const n=e.getInstance(ht)?.snapshot();t.headers.set(bg,vg(n&&mg(n)))}}))}function Eg(e){if(!e)return!1;try{return e.getInstance(De)!==void 0}catch{return!1}}var _g="Invalid standaloneKey.",p_=H("StandaloneMockGuard");function wg(){const e=new Error(_g);return e.name="InvalidStandaloneKeyError",e}function Sg(e){e.addService(Sn,{execute:()=>{if(Eg(e))throw wg()}})}function Ig(e){Ac(e),Sg(e)}function Cg(e){const t=new Sa;e.inject(Pe,t);const n=e.getInstance(pe)?.watch(o=>{if(!o)return;const i=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...i!==void 0?{signal:i}:{}})}),r=e.getInstance(G);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var Za=Ht("plugin.dataSource.blocks"),Tg=Ht("plugin.dataSource.blockRevisions"),Ag=Ht("plugin.dataSource.comments"),Rg=Rn(),Pg=Rn(),el=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
1004
+ `));return{html:Zf(t.html),hasBrowserExtensionArtifacts:t.found}}function mn(e){return e?.getContent()??""}function ya(e,t){e?.mutate({content:Us(t)},{source:"remote"})}function Rn(e){return H(e)}function ae(e,t){return e.getOrCreateInstance(t,()=>new Fe)}function Y(e,t){return e.getOrCreateInstance(t,()=>new Fe).event}function gn(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var ep=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 tp(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 np(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(ee(n),new Promise((r,o)=>{let i=!1,s,a;const l=d=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",c),d())},c=()=>{l(()=>o(ve(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>o(new ep(t)))},t)),n?.addEventListener("abort",c)}))}var rp=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 op(e,t,n){return t<=0?e:new Promise((r,o)=>{let i=!1,s;const a=l=>{i||(i=!0,s!==void 0&&(clearTimeout(s),s=void 0),l())};s=setTimeout(()=>{a(()=>o(new rp(n,t)))},t),e.then(l=>{a(()=>r(l))},l=>{a(()=>o(l))})})}var ip=2,wt=Symbol("sandbox:frame-replaced");function Zo(e){return e===wt}function Ge(e,t,n,r,o,i,s){const a=`sandbox:${t}`,l=i?.getSandboxTimeoutMs(t)??to[t],c=()=>{let w=op(e.sendAsync(n,r),l,a);return w=un(w,i?.signal),ze(a,w,o)};if(t==="INIT_START"&&tp(e)){const w=i?.getSandboxReadyTimeoutMs()??2e4,I=e,b=R=>{const P=np(I,w,i?.signal);return ze("sandbox:INIT_START:ready-wait",P,o).then(()=>{if(!s||R<=0)return c();const F=s.getGeneration();let D;const k=new Promise((S,T)=>{D=s.onChange(()=>{s.getGeneration()!==F&&T(wt)})}),_=c();return _.catch(()=>{}),Promise.race([_,k]).finally(()=>D?.()).catch(S=>{if(S!==wt)throw S;return{...o},b(R-1)})})};return b(ip)}if(!s)return c();const d=s.getGeneration();let p;const v=new Promise((w,I)=>{p=s.onChange(()=>{s.getGeneration()!==d&&I(wt)})}),E=c();return E.catch(()=>{}),Promise.race([E,v]).finally(()=>p?.()).catch(w=>{throw w===wt&&{...o},w})}var sp=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],ap=200;function Ea(e=new Set){const t=new Set;return(n,r)=>{if(!sp.some(([i,s])=>!e.has(i)&&s.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=ap&&t.clear(),t.add(o))}}function _a(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Ea()}}var lp=_a();function Ze(e){return e?.getInstance($r)??lp}var wa="self-init:";function cp(e){return e.startsWith(wa)}function po(e,t){const n=e.getActiveShowRequest();return cp(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function dp(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let i="",s;const a=w=>{s={target:e.readTarget?.(),docId:w}},l=()=>e.readDocument()?mn(e.readDocument()):i,c=()=>Ze(e.container).editorPolicy,d=()=>e.readEmail(),p=()=>{const w=d();return{...w,id:e.isTemplate()||w.isNew?void 0:w.id,html:l()}};let v=!1;const E={readContent:l,publicEmail:p,sendInitStart:()=>Ge(n,"INIT_START",z.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,r()),sendInited:()=>Ge(n,"INITED",z.SANDBOX_INITED,{guid:d().renderGuid},void 0,r(),o()),async sendContent(){const w=d(),{html:I,hasBrowserExtensionArtifacts:b}=ba(w?.html||"");b&&e.events.browserExtensionDetected(),ya(e.readDocument(),I),i=I,a(w.renderGuid),await Ge(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,gn(l(),w.renderGuid,c(),e.readDocument()?.get().version),{guid:w.renderGuid,emailId:w.id??null},r(),o())},refreshContent:()=>(a(d().renderGuid),Ge(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,gn(l(),d().renderGuid,c(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const w=d();if(w.preheader!==void 0)return Ge(n,"PREHEADER",z.SANDBOX_PREHEADER_UPDATE,{value:w.preheader,guid:w.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const w=d();if(w.subject!==void 0)return Ge(n,"SUBJECT",z.SANDBOX_SUBJECT_UPDATE,{value:w.subject,guid:w.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:w=>e.showFilled?.(w),noteFilled:(w,I)=>e.noteFilled?.(w,I),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(p()),fireInit(w,I){if(!po(t(),w)){t().getActiveShowRequest()?.showId;return}const b=d();b.id,b.renderGuid,t().completeShow(w);const R=e.readDocument();ft(R,{is_inited:!0},{source:"system"});const P=()=>{const D=p();I&&(D.reset=!0);const k=e.events.inited(D);return I||(v&&E.fireEmailChanged(),v=!0),k};if(!R||R.isReady())return P();const{docId:F}=R.get();return R.whenReady().then(()=>e.readDocument()?.get().docId===F?P():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(p())},fireContentChanged(){e.events.contentChanged(l())}};return E}var up=class extends Error{showId;constructor(e,t){super(`[useblocks] 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}},fp=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(ve("Superseded by newer show()")),n.aborted?Promise.reject(ve(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const i=setTimeout(()=>{this._settle(e.showId,()=>{o(new up(e.showId,t))})},t);i.unref?.();const s=()=>{this._settle(e.showId,()=>{o(ve(n.reason))})};n.addEventListener("abort",s,{once:!0});const a=()=>{clearTimeout(i),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:i,dispose:a});for(const l of this._listeners)l(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 pp(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function hp(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Ds(e),n=Os(e),r=fd(e.sandbox);t<n+r}var Sa=class{_controller=new AbortController;_externalSignalDisposable=new ue;_sessionChangeListeners=new Set;_showRegistry=new fp;_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 Ds(this._timeouts)}getSandboxTimeoutMs(e){return Ps(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return Os(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=pp(this._timeouts,e.timeouts),hp(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 ue,this._linkExternalSignal(e)}abort(e){const t=e??ve("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ue}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ue,this._showRegistry.rejectAll(ve("Init session replaced")),this._controller.signal.aborted||this._controller.abort(ve("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??ve()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??ve()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},ho=(()=>{const e=new Sa;return e.configure({}),e})();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 $e(e){return!e||e==="none"}function mp(e){const t=e.contain??"",n=e.willChange??"";return!$e(e.transform)||!$e(e.perspective)||!$e(e.filter)||!$e(e.backdropFilter)||!$e(e.translate)||!$e(e.rotate)||!$e(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function ei(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 gp(e){const t=[],n=document.documentElement,r=ei(getComputedStyle(n)),o=r.x||r.y;let i="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(i=s);for(let a=Qe(e);a&&a!==n;a=Qe(a)){const l=getComputedStyle(a),c=i==="none"||mp(l)||i==="absolute"&&!!l.position&&l.position!=="static",d=a===document.body&&!o;if(c){i="none";const p=d?{x:!1,y:!1}:ei(l);(p.x||p.y)&&t.push({node:a,...p})}(l.position==="absolute"||l.position==="fixed")&&(i==="none"||l.position==="fixed")&&(i=l.position==="fixed"?"fixed":"absolute")}return t}function Ia(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 Yt(e){return Number.parseFloat(e)||0}function yr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=Ia(e),o=Yt(n.borderLeftWidth),i=Yt(n.borderTopWidth),s=Yt(n.borderRightWidth),a=Yt(n.borderBottomWidth),l=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-s):0,c=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-i-a):0;return{left:t.left+o*r.x,top:t.top+i*r.y,right:t.right-(s+l)*r.x,bottom:t.bottom-(a+c)*r.y}}function vp(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(i,s,a)=>{s&&(r.left=Math.max(r.left,i.left),r.right=Math.min(r.right,i.right)),a&&(r.top=Math.max(r.top,i.top),r.bottom=Math.min(r.bottom,i.bottom))};return t.forEach(i=>o(yr(i.node),i.x,i.y)),n&&o(yr(n),!0,!0),r}var Er={originX:0,originY:0,scaleX:1,scaleY:1};function vn(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 Ca(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,o=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*o,scaleX:r,scaleY:o}}function Ta(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 bp=1e3;function yp(e){const{slot:t,own:n}=e;let r,o=0,i=!1;const s=()=>{if(r=void 0,!i){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(s))}},a=()=>{!i&&r===void 0&&(r=window.requestAnimationFrame(s))},l=()=>{o=performance.now()+bp,a()},c=[window],d=[document.documentElement];for(let b=t;b;b=Qe(b)){const R=b.getRootNode();R instanceof ShadowRoot&&!c.includes(R)&&(c.push(R),d.push(R))}const p=[["scroll",a],["load",a],["transitionrun",l],["transitionend",a],["transitioncancel",a],["animationstart",l],["animationend",a],["animationcancel",a]];c.forEach(b=>p.forEach(([R,P])=>b.addEventListener(R,P,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const v=typeof MutationObserver=="function"?new MutationObserver(b=>{b.some(R=>!n.contains(R.target))&&a()}):void 0;d.forEach(b=>v?.observe(b,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let E;try{if(typeof ResizeObserver=="function"){const b=new ResizeObserver(a);typeof b.observe=="function"&&(E=b)}}catch{E=void 0}let w=[];return{schedule:a,observe:b=>{!E||b.length===w.length&&b.every((R,P)=>R===w[P])||(E.disconnect(),w=b,b.forEach(R=>E?.observe(R)))},dispose(){i=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),c.forEach(b=>p.forEach(([R,P])=>b.removeEventListener(R,P,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),v?.disconnect(),E?.disconnect()}}}var Ep="pluginZoom",_p=/^(?:ant|vscode|monaco|docs)-/;function wp(e){return _p.test(e)}function Sp(){const e="ub".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 Ip=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function Cp(){return Ip}var Tp=new Set;function Ap(e,t,n=Tp){return e.startsWith(`${t}-`)?!1:!wp(e)&&!n.has(e)}function Rp(e,t){return`--${t}-${e}`}function Aa(e){const t=Sp();return Ap(e,t,Cp())?Rp(e,t):`--${e}`}function Pp(e,t){const n=Aa(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function Ra(e,t){return Pp(e,t)}var Pa=300,ti=15e3,Dp=5e3,ni="em-canvas-busy-style";function Op(){if(document.getElementById(ni))return;const e=document.createElement("style");e.id=ni,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var kp="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 xp(e){const t=Ra("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(Aa("colorPrimary")).trim()||t}function Da(e){Op();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",kp),n.appendChild(r);const o=document.createElement("span");return o.setAttribute("role","img"),o.setAttribute("aria-label","loading"),o.setAttribute("style",`display:inline-flex;color:${xp(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function Mp(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),i=Math.min(r.right,e.right,n.width),s=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return i<=o||a<=s?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+i)/2-e.left,y:(s+a)/2-e.top}}function Lp(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const o={left:n.left,top:n.top,right:n.right,bottom:n.bottom},i=r.getBoundingClientRect();if(i.width>0&&!Ta({left:i.left,top:i.top,width:i.width,height:i.height},o)){const s=vn(o,Ca(i,vn(o,Er),Er));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=Mp(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(Da(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Vn(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(Da(e))},Pa);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var Np=8e3;function Fp(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},hold:()=>{},dispose:()=>{}}}function Bp(e,t){for(let n=Qe(e);n;n=Qe(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",i=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>rt(s)>0);if(o&&i)return n;if(n===t)return null}return null}function rt(e){return Number.parseFloat(e)||0}function Xt(e,t){return Math.abs(e-t)<=1}function jp(e){const t=getComputedStyle(e),n=rt(t.borderTopWidth),r=rt(t.borderRightWidth),o=rt(t.borderBottomWidth),i=rt(t.borderLeftWidth),s=(a,l,c)=>Math.max(0,rt(a)-Math.max(l,c));return{...yr(e),radii:[s(t.borderTopLeftRadius,n,i),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,o,r),s(t.borderBottomLeftRadius,o,i)]}}function Up(e,t){const n=Xt(t.top,e.top),r=Xt(t.bottom,e.bottom),o=Xt(t.left,e.left),i=Xt(t.right,e.right),s=[n&&o?e.radii[0]:0,n&&i?e.radii[1]:0,r&&i?e.radii[2]:0,r&&o?e.radii[3]:0];return s.every(a=>a===0)?"":s.map(a=>`${a}px`).join(" ")}function Hp(e,t,n,r,o,i){const s=n.readyTimeoutMs??Np,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",Ra(Ep,"1"));const l=n.resolveSrc(e),c=document.createElement("iframe");c.setAttribute("sandbox",n.resolveSandbox(l)),c.setAttribute("allow","clipboard-read; clipboard-write"),c.setAttribute("title","Email content"),c.style.width="100%",c.style.border="0",c.style.display="block",c.style.minHeight="600px",c.src=l,a.appendChild(c),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(c);const d=new ue;let p=!1,v,E=!1,w,I,b,R;const P=()=>{clearTimeout(R),R=setTimeout(()=>{E||(E=!0,I?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},F=()=>p?(b=Promise.resolve(),E=!0,b):(E=!1,b=new Promise((M,$)=>{w=M,I=$}),P(),b),D=()=>{if(clearTimeout(R),p=!0,E){b=Promise.resolve();return}E=!0,n.mark?.("loaded"),w?.()};c.addEventListener("load",D),d.addDispose(()=>{clearTimeout(R),c.removeEventListener("load",D)});let k;const _=()=>{k??=n.bindResizer?.(c)},S=()=>{k?.dispose(),k=void 0};let T=null,m=null,u,f=Er,g="",x="",O=0;const y=M=>{const $=JSON.stringify(M);return $===g?!1:(g=$,a.style.visibility=M.visibility,a.style.left=`${M.css.left}px`,a.style.top=`${M.css.top}px`,a.style.width=`${M.css.width}px`,a.style.height=`${M.css.height}px`,a.style.borderRadius=M.radius,c.style.width=M.elementWidth>0?`${M.elementWidth}px`:"100%",c.style.transform=M.shiftX!==0?`translate(${M.shiftX}px, ${M.shiftY}px)`:`translateY(${M.shiftY}px)`,!0)};let A=!1;const h=()=>{if(!T)return g="",a.style.visibility="hidden",c.removeAttribute("id"),!1;n.elementId&&(c.id=n.elementId);const M=T.getBoundingClientRect(),$=gp(T),X=m?.isConnected?m:null;u?.observe([T,c,...$.map(oe=>oe.node),...X?[X]:[]]);const Q=vp(M,$,X),Z=Math.max(0,Q.right-Q.left),et=Math.max(0,Q.bottom-Q.top),vt=getComputedStyle(T).visibility==="visible",Ue=Z<=0||et<=0,ke=Ue?{left:Q.left,top:Q.top,right:Q.left,bottom:Q.top}:Q,L=Ue?null:Bp(T,X??$[0]?.node??null),J=L?Up(jp(L),ke):"",K=oe=>y({visibility:vt&&!A?"":"hidden",css:vn(ke,oe),elementWidth:M.width/oe.scaleX,shiftX:(M.left-ke.left)/oe.scaleX,shiftY:(M.top-ke.top)/oe.scaleY,radius:J});let he=K(f);if(!Ue){const oe=a.getBoundingClientRect();oe.width>0&&!Ta({left:oe.left,top:oe.top,width:oe.width,height:oe.height},ke)&&(f=Ca(oe,vn(ke,f),f),he=K(f)||he)}return he},C=()=>{if(!T)return!1;let M=h();const $=c.getBoundingClientRect().height;$>0&&$!==O&&(O=$,T.style.height=`${$/Ia(T).y}px`,M=!0);const X=getComputedStyle(T).pointerEvents;return X!==x&&(x=X,a.style.pointerEvents=X),M},N=()=>{u?.dispose(),u=void 0},V=M=>{u=yp({slot:M,own:a,measure:C,onDetached:N})};let q=[];const W=(M,$)=>{if(m=$,M&&q.length>0){const X=q;q=[],X.forEach(Q=>Q())}if(M===T){M&&!u&&V(M),C();return}if(N(),T&&T.style.removeProperty("height"),g="",O=0,x="",T=M,!M){h(),S();return}n.onShown?.(c),V(M),C(),_()};d.addDispose(N);const B=M=>{p=!1,v=void 0,i?.(),M&&n.onReload?.(c);let $;E||b===void 0?$=F():(P(),$=b);try{c.contentWindow?.location.reload()}catch{c.src=l}return $};return{element:c,ready(){return b??F()},reload:()=>B(!0),reloadQuietly:()=>B(!1),followReload:()=>{v=void 0,i?.(),n.onReload?.(c)},moveTo(M){if(a.parentNode===M)return b??F();p=!1,v=void 0,i?.();let $;return E||b===void 0?$=F():(P(),$=b),M.appendChild(a),n.onReload?.(c),g="",u?.schedule(),$},get shown(){return T!==null},get slot(){return T},whenShown(){return T!==null?Promise.resolve():new Promise(M=>{q.push(M)})},get filled(){return v},noteFilled(M){v=M},alignTo(M,$){W(M,$??null)},hold(M){A!==M&&(A=M,h())},scrollBy(M,$){let X=M,Q=$;for(let Z=T?Qe(T):null;Z;Z=Qe(Z)){if(Math.abs(X)<1&&Math.abs(Q)<1)return;const et=getComputedStyle(Z);if((et.overflowY==="auto"||et.overflowY==="scroll")&&Z.scrollHeight>Z.clientHeight){const vt=Z.scrollTop,Ue=Z.scrollLeft;Z.scrollBy({left:X,top:Q,behavior:"instant"}),X-=Z.scrollLeft-Ue,Q-=Z.scrollTop-vt}}(Math.abs(X)>=1||Math.abs(Q)>=1)&&window.scrollBy({left:X,top:Q,behavior:"instant"})},resize(){k?.resize()},dispose(){W(null,null),S(),d.dispose(),a.remove()}}}function $p(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(f,g)=>f==="email"?`email:${g??n}`:f,i=new Map;let s,a=[],l=!1,c,d,p=!1,v,E,w="shown",I=0,b,R,P;const F=f=>d!==void 0&&f.filled!==void 0&&f.filled!==d,D=()=>{b=void 0;const f=v;!p||!f||d===void 0||R===d||!F(f)||(R=d,e.onForeignDocument?.({wanted:d,filled:f.filled,role:w,heldMs:Date.now()-I}))},k=()=>{p=!1,v=void 0,E=void 0,clearTimeout(b),b=void 0},_=(f,g)=>{const x=i.get("email"),O=x?.slot??null;return f&&O&&F(f)?(f.alignTo(null),p||(p=!0,I=Date.now(),b=setTimeout(D,Dp)),w=g,v=f,!(s!==void 0||l)&&E!==f&&(E=f,e.onShown?.(f.element)),!c&&!s&&(c=Vn(O)),!1):(p&&(k(),c?.remove(),c=void 0),f?.alignTo(O,x?.clip??null),!0)},S=()=>{p&&!l&&_(t.get(o("email")),"shown")},T=()=>{a.forEach(f=>clearTimeout(f)),a=[],s?.remove(),s=void 0,c?.remove(),c=void 0,(l||p)&&(l=!1,_(t.get(o("email")),"shown"))},m=(f,g,x)=>{const O=o(f,g),y=t.get(O);if(y)return y;const A=e.resolveMount();if(!A)return Fp();const h=Hp(f,A,e,f==="email"?g??n:void 0,x,f==="email"?()=>S():void 0);return t.set(O,h),h},u={get:f=>m(f),current:f=>m(f),peek:f=>t.get(o(f)),spare:()=>t.get(o("email",r())),ensureSpare:()=>m("email",r(),!0),promote(){const f=t.get(o("email",r()));if(!f)return;const g=t.get(o("email"));n=r(),P=void 0,_(f,"spare"),g?.alignTo(null)},alignSurface(f,g,x){const O=i.get(f);if(i.set(f,{slot:g,clip:x??null}),f==="email"&&l){c?.remove(),c=g?Vn(g):void 0;return}const y=g?m(f):t.get(o(f));if(f!=="email"){y?.alignTo(g,x??null);return}if(!g){P=O?.slot&&y?.shown?{slot:O.slot,handle:y}:void 0,p&&(k(),c?.remove(),c=void 0),y?.alignTo(null);return}const A=P?.slot===g&&P.handle===y;if(P=void 0,O?.slot===g&&y?.shown||A){y?.alignTo(g,x??null);return}_(y,"shown")},want(f){d=f,f!==void 0&&S()},noteFilled(f,g){const x=u.byWindow(f);x&&(x.noteFilled(g),x===t.get(o("email"))&&S())},visible(){for(const f of t.values())if(f.shown)return f},byWindow(f){if(f){for(const g of t.values())if(g.element.contentWindow===f)return g}},busy(f){if(T(),!f)return;if(!u.visible()){l=!0,c?.remove(),c=void 0;const O=i.get("email");O?.slot&&(c=Vn(O.slot)),a=[setTimeout(T,ti)];return}const g=e.resolveMount();if(!g)return;const x=Lp(g,()=>u.visible()?.element.parentElement?.getBoundingClientRect()??null);s=x,a=[setTimeout(()=>x.showSpinner(),Pa),setTimeout(T,ti)]},remount(f){T();const g=o("email");t.forEach((x,O)=>{if(O===g){x.moveTo(f).catch(()=>{});return}x.dispose(),t.delete(O)})},dispose(){d=void 0,l=!1,k(),P=void 0,T(),t.forEach(f=>f.dispose()),t.clear(),i.clear(),n="a",d=void 0,R=void 0}};return u}var qp=H("canvas.resizerBinder"),_r=H("canvas.service"),Vp={created:ce.canvasCreated,loaded:ce.canvasLoaded},Oa=new WeakMap;function wr(e){return Oa.get(e)??0}function Gp(e,t){if(e.getInstance(_r))return;const n=$p({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:Pf,elementId:t.elementId,bindResizer:o=>e.getInstance(qp)?.(o),onCreated:o=>Rt(e,o,"fresh"),onReload:o=>{Oa.set(o,wr(o)+1),Rt(e,o,"fresh")},onShown:o=>{const i=n.byWindow(de(e).getTarget());i&&i.element!==o&&ri(i.element)===ri(o)||Rt(e,o,"switch")},mark:o=>t.mark?.(Vp[o]),onForeignDocument:o=>{({...o},vd("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:o.role},contexts:{canvasIdentity:{...o,path:window.location.pathname}}}))}}),r=de(e).addListener(z.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(_r,n),e.getInstance(G)?.addDispose(()=>{r.dispose(),n.dispose()})}function ri(e){return e.parentElement?.dataset.canvasHost}function Rt(e,t,n){const r=de(e),o=t.contentWindow;if(!o)return;const i=r.getTarget()===o;i&&n==="switch"||(n==="fresh"&&(r.forget(o),i&&r.setTarget(void 0)),r.setTarget(o),df(r))}function zp(e,t){Rt(e,t,"promote")}function Wp(e,t){Rt(e,t,"switch")}function Kp(e,t){const n=t.contentWindow;n&&de(e).greet(n)}function ka(e,t){const n=t.contentWindow;n&&de(e).forget(n)}function Yp(e,t){const n=se(e)?.byWindow(t)?.element;if(!n)return;const r=wr(n);return()=>wr(n)!==r}function se(e){return e.getInstance(_r)}function xa({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:i}){if(!r)return;const s={id:o??void 0,renderGuid:n,showId:i?.id,isNew:o==null,showToken:i?.token},a={...e,...s};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function Pn(e){return{...xa({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function sn(e){const t=le(e),n=t.current();if(!n||!te(t.sessionKey()))return;const r=Pn(n),o=n.isDirty();ae(e,j.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function Xp(e){const t=le(e);return!t.current()||!te(t.sessionKey())?!1:(sn(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function Jp(e){const t=le(e),n=de(e),r=()=>e.getInstance(Pe)??ho;let o,i,s=!1,a=!1,l,c;const d=x=>Pn(x),p=()=>{const x=F(),O=x?.get().docId;if(!x||!O||O!==l||s)return;const y=x.get().version;y!==c&&(c=y,ae(e,j.ON_BLOCK_CHANGED_ID).fire(d(x)))};let v;const E=x=>{const O=t.showFacts();!O||O.id===v||!po(x,O.id)||(v=O.id,x.completeShow(O.id))},w=async(x,O,y)=>{const A=y.generation,h=()=>y.generation!==A||y.signal.aborted||t.current()!==x||a,C=Se(n);let N;const V=new Promise(W=>{N=hn(n,()=>W("regenerated"))}),q=async(...W)=>await Promise.race([Ge(...W).then(()=>"sent"),V])==="sent";s=!0;try{if(!await q(n,"INIT_START",z.SANDBOX_INIT_START,{guid:O},void 0,y)||h())return;const{html:W,hasBrowserExtensionArtifacts:B}=ba(mn(x));if(B&&ae(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),ya(x,W),!await q(n,"SET_ENTITY",z.SANDBOX_SET_ENTITY,gn(mn(x),O,Ze(e).editorPolicy,x.get().version),void 0,y)||h()||!await q(n,"INITED",z.SANDBOX_INITED,{guid:O},void 0,y)||h())return;o=O,i=C,D(),c=x.get().version,l!==O&&(l=O,ae(e,j.ON_BLOCK_INIT_ID).fire(d(x))),E(y)}finally{N?.(),s=!1,Se(n)!==C&&S()}};let I,b,R;const P=()=>{const x=se(e)?.peek("block");return x?.reload?(x.reload().catch(()=>{}),!0):!1},F=()=>te(t.sessionKey())?t.current():void 0,D=()=>{const x=F()?.get().docId,O=!x||R===x||o===x&&i===Se(n);se(e)?.peek("block")?.hold(!O)},k=()=>{if(a||(D(),p(),s))return;const x=F(),O=x?.get().docId;if(!x||!O)return;if(o===O&&i===Se(n)){E(r());return}if(!x.isReady())return;const y=r();y.signal.aborted||o!==void 0&&o!==O&&I!==O&&(I=O,P())||w(x,O,y).catch(()=>{if(!(a||t.current()!==x)){if(b!==O){b=O,P();return}R=O,D()}})};let _=!1;const S=()=>{_||a||(_=!0,queueMicrotask(()=>{_=!1,k()}))};let T,m;const u=()=>{const x=F(),O=x?.get().docId;O!==m&&(T?.(),m=O,T=x?.subscribe(S)),D(),S()},f=t.subscribe(u),g=hn(n,()=>{D(),S()});u(),e.getInstance(G)?.addDispose(()=>{a=!0,g(),T?.(),f()})}function Qp(e){const t=le(e);let n="email";const r=()=>{if(!t.current())return;const i=te(t.sessionKey())?"block":"email",s=se(e);if(i===n||!s)return;n=i;const a=s.peek(i);if(a){Wp(e,a.element);return}s.get(i)},o=t.subscribe(r);e.getInstance(G)?.addDispose(o)}var Zp=200;function eh({startVersion:e,limit:t=Zp}){let n=[],r=e;const o=i=>{n=n.filter(s=>s.version>i),r=Math.max(r,i)};return{record(i){!i.changes?.length&&!i.contentReplaced||(n.push(i),n.length>t&&o(n[n.length-t-1].version))},rebase(i,s){if(s<r)return null;const a=n.filter(c=>c.version>s);o(s);let l=i;for(const c of a){if(c.contentReplaced||!c.changes)return null;const d=c.changes,p=[];for(const v of l){if(c.fromCanvas&&d.some(w=>v.range.start<=w.oldEnd&&v.range.end>=w.oldPosition))return null;const E=Sd(v.range,d,"after");if(!E)return null;p.push({range:E,text:v.text})}l=p}return l}}}function th(e,t){let n=0;return e.map(({start:r,end:o,text:i})=>{const s=new Ie(r,t.slice(r,o),r+n,i);return n+=i.length-(o-r),s})}function nh(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return th(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function rh(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var mo=H("canvas.sandboxFill");function Ma(e){return e.getInstance(mo)?.pipeline.isEventsLocked()===!0}function Jt(e){kt(e,{origin:"canvas-channel"})}function oh(e){const t=le(e),n=de(e);let r;const o=(l,c)=>{const d=l.get().docId;let p=!1,v=null,E=null;const w=eh({startVersion:l.get().version});let I=l.getContent(),b=!0;const R=(S,T)=>{!b||t.current()!==l||(kt(T,{origin:"canvas-channel"}),n.sendAsync(z.SANDBOX_SET_ENTITY,gn(mn(l),d,Ze(e).editorPolicy,l.get().version)).catch(Jt))},P=async(S,T)=>{if(E){E.push({edits:S,rev:T});return}E=[{edits:S,rev:T}];try{do{const m=E.splice(0,E.length);await n.sendAsync(z.SANDBOX_UPDATE_ENTITY,{edits:m.map(u=>u.edits),guid:d,rev:m[m.length-1].rev})}while(E.length)}catch(m){R("app edits failed to reach the canvas",m)}finally{E=null}},F=(S,T)=>{const m=E?.splice(0,E.length)??[];m.length&&n.sendAsync(z.SANDBOX_UPDATE_ENTITY,{edits:m.map(u=>u.edits),guid:d,rev:m[m.length-1].rev}).catch(Jt),n.sendAsync(z.SANDBOX_UPDATE_ENTITY,{edits:[S],guid:d,rev:l.get().version,...T!==null?{changeId:T}:{}}).catch(Jt)},D=S=>{const{guid:T,pushUndoStop:m}=S;if(T!==d)return;const u=Md(S);let{edits:f}=S;if(u.baseRev!==null){const x=w.rebase(f,u.baseRev);if(!x){kt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),F([],u.changeId);return}f=x}const g=l.get().version;try{p=!0,v=u.changeId;const x=nh(f,l.getContent());m===!1?c.applyWithoutHistory(x):l.mutate({changes:x},{source:Ma(e)?"system":"user"})}catch(x){R("canvas batch failed to apply",x);return}finally{p=!1,v=null}l.get().version===g&&u.baseRev!==null&&F([],u.changeId)},k=l.subscribe(({changes:S,version:T})=>{const m=l.getContent(),u=!S?.length&&m!==I;if(I=m,w.record({version:T,changes:S,contentReplaced:u,fromCanvas:p}),!S?.length)return;const f=rh(S);p?F(f,v):P(f,T).catch(Jt)}),_=n.addListener(z.APPLICATION_UPDATE_ENTITY,D);return()=>{b=!1,k(),_.dispose()}};let i;const s=()=>{const l=t.current(),c=t.history(),d=l?.get().docId;d!==i&&(r?.(),r=void 0,i=d,l&&c&&(r=o(l,c)))},a=t.subscribe(s);s(),e.getInstance(G)?.addDispose(()=>{r?.(),a()})}function ih(e){const t=de(e),n=()=>se(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(z.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(z.RELOAD,a=>{const l=se(e)?.byWindow(a);l&&ka(e,l.element)}),i=t.addListener(a=>{a.data?.operation===z.SANDBOX_RESIZED&&n()?.resize()}),s=Y(e,j.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(G)?.addDispose(()=>{r.dispose(),o.dispose(),i.dispose(),s.dispose()})}function oi(){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 sh(e){const t=e.getInstance(pe);let n,r;e.getInstance(G)?.addDispose(()=>{r?.remove(),r=void 0}),Gp(e,{resolveMount:()=>n,resolveSrc:i=>ha(i==="block"),elementId:"email_iframe",mark:i=>ne(i)}),t?.watch(i=>{const s=i?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,se(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(i!==void 0){n=r??=oi(),se(e)?.alignSurface("email",r,r);return}else return;se(e)?.get("email")}});let o;e.getInstance(G)?.addDispose(()=>{o?.remove(),o=void 0}),$u(e).watch(i=>{const s=se(e);if(s){if(i){o??=oi(),s.alignSurface("email",o,o);return}o&&(s.alignSurface("email",null),o.remove(),o=void 0)}})}var go=H("canvas.headerFlow"),ii=["subject","preheader"],si=3e3,ah=3,lh={subject:z.SANDBOX_SUBJECT_UPDATE,preheader:z.SANDBOX_PREHEADER_UPDATE};function ch(e){const t=le(e),n=de(e),r=k=>k?"remote":Ma(e)?"system":"user",o=(k,{guid:_,value:S,forced:T})=>{const m=st(t);if(!m||typeof S!="string"||_&&_!==m.get().docId)return;const u=t.forcedHeaders();if(u?.[k]!==void 0&&!T&&S!==u[k])return;const f=m.get().attributes[k];if(!T&&E(k,S,f))return;const g=!T&&p.delete(k);T&&(b.delete(k),b.size===0&&t.endForcedHeaders());const x=f??"";l=!0;try{ft(m,{[k]:S},{source:g?"system":r(T)})}finally{l=!1}i[k]=S,ae(e,j.ON_HEADER_APPLIED_ID).fire({field:k,value:S,forced:!!T,isGenerated:S!==x&&!!S})};let i={},s,a,l=!1,c=Promise.resolve();const d={},p=new Map,v=(k,_)=>{i[k]=_;const S={};p.set(k,S);const T=()=>{p.get(k)===S&&p.delete(k)};w(k,_,{force:!0}).then(T),setTimeout(T,si)},E=(k,_,S)=>{const T=t.showFill();if(!T||typeof S!="string")return!1;const m=d[k]?.showId===T.showId?d[k]:void 0;return _===S?(d[k]=m??{showId:T.showId,codeEdits:T.codeEdits,corrections:0},!1):m&&T.codeEdits>m.codeEdits&&_!==m.stale?!1:((!m||_===m.stale&&m.corrections<ah)&&(d[k]={showId:T.showId,stale:_,codeEdits:T.codeEdits,corrections:(m?.corrections??0)+1},v(k,S)),!0)},w=(k,_,{force:S=!1,echo:T=!1,undoStep:m=!1})=>(c=n.sendAsync(lh[k],{value:_,guid:st(t)?.get().docId,...S?{force:!0}:{},...T?{echo:!0}:{},...m?{undoStep:!0}:{}}).catch(u=>{}),c);let I;const b=new Set;e.inject(go,{whenDelivered:async()=>{await c},reassert:k=>{const _=st(t),S=ii.filter(T=>typeof k[T]=="string");if(!(!_||S.length===0)){l=!0;try{ft(_,Object.fromEntries(S.map(T=>[T,k[T]])),{source:"system"})}finally{l=!1}t.beginForcedHeaders(Object.fromEntries(S.map(T=>[T,k[T]]))),clearTimeout(I),I=setTimeout(()=>{b.clear(),t.endForcedHeaders()},si),b.clear();for(const T of S)b.add(T);for(const T of S)i[T]=k[T],w(T,k[T],{force:!0,echo:!0})}}});const R=()=>{s?.(),s=void 0;const k=st(t);if(k!==a&&p.clear(),a=k,!k){i={};return}const _=k.get().attributes;i={subject:_.subject,preheader:_.preheader},s=k.subscribe(({source:S})=>{if(l)return;const T=k.get().attributes,m=t.forcedHeaders();for(const u of ii){const f=T[u];if(f===i[u])continue;i[u]=f,p.delete(u);const g=S==="system"&&m?.[u]!==void 0;w(u,f??"",{force:g,echo:g,undoStep:S==="user"})}})};R();const P=t.subscribe(R),F=n.addListenerAsync(z.APPLICATION_SUBJECT_UPDATE,k=>o("subject",k)),D=n.addListenerAsync(z.APPLICATION_PREHEADER_UPDATE,k=>o("preheader",k));e.getInstance(G)?.addDispose(()=>{F.dispose(),D.dispose(),P(),s?.(),clearTimeout(I)})}function dh(e){const t=le(e);let n={document:void 0,seq:0};const r=()=>{const i=t.recoveryFacts(),s=st(t);if(!i?.applied||!s||String(i.emailId)!==String(s.get().serverId)||(n.document!==s&&(n={document:s,seq:0}),i.applied.seq<=n.seq))return;n={document:s,seq:i.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(go)?.reassert(a)},o=t.subscribe(r);e.getInstance(G)?.addDispose(o)}function uh(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?Cc:fc}function fh(e,t){return{copyPasteEnabled:e.copyPasteEnabled,saveBlockEnabled:t?!1:e.saveBlockEnabled,editImageControlEnabled:e.editImageControlEnabled,elementAIimageEnabled:e.elementAIimageEnabled,imageCenterStockEnabled:e.imageCenterStockEnabled,imageCenterGifEnabled:e.imageCenterGifEnabled,imageCenterEditorEnabled:e.imageCenterEditorEnabled,blocksAddPanelEnabled:e.blocksAddPanelEnabled!==!1&&e.blocksSectionsShow!==!1}}function ph(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function ai(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 o=t[r],i=e[r];ai(o)&&ai(i)?n[r]=Sr(i,o):o!==void 0&&(n[r]=o)}return n}function hh(e,t){const n=Yr;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const o=JSON.parse(r);if(o&&typeof o=="object"&&!Array.isArray(o)&&Object.keys(o).length>0)return Sr(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?Sr(n,t):n}var mh=ge(void 0),li=mh,La=H("CodeMode");function Na(){let e;try{const t=window.localStorage?.getItem(Wr.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 gh(e){try{window.localStorage?.setItem(Wr.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function vo(e){return e.getOrCreateInstance(La,()=>{const t=ge(Na());return t.watch(gh),t})}function Fa(e){return e?.getInstance(La)?.get()??Na()}function Ir(e,t){const n=vo(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function vh(e,t){const n=vo(e);n.set({...n.get(),direction:t})}var bh=H("DefaultCommonStyles");function Ba(e){return e.getOrCreateInstance(bh,()=>ge(void 0))}function yh(e,t){Ba(e).set(t)}var Eh=H("CanvasViewport"),_h=H("CanvasPreviewPage");function Le(e,t,n){let r,o;const i=()=>{if(!r||!e.isInited())return;const l=r.value===void 0?"undefined":JSON.stringify(r.value);l!==o&&(o=l,e.send(t,r.value))},s=n.watch(l=>{r={value:l},i()}),a=e.onInit(()=>{o=void 0,i()});return{dispose(){s.dispose(),a.dispose()}}}function Qt(e){const t=ge(e());return{source:t,refresh:()=>t.set(e())}}function wh(e){const t=de(e),n=e.getInstance(fe),r=e.getInstance(pe),o=le(e),i=vo(e),s=matchMedia(pc),a=()=>n?.get()??{};let l;const c=Qt(()=>uh(li.get()??a().theme,s.matches)),d=Qt(()=>fh(a(),te(o.sessionKey()))),p=Qt(()=>a().lockEditor),v=Qt(()=>hh(o.current()?.get().attributes?.common_styles,l)),E=e.getOrCreateInstance(Eh,()=>ge()),w=e.getOrCreateInstance(_h,()=>ge()),I=[Le(t,Me.theme,c.source),Le(t,Me.flags,d.source),Le(t,Me.lockEditor,p.source),Le(t,Me.commonStyles,v.source),Le(t,Me.codeMode,i.select(ph)),Le(t,Me.appName,ge("useblocks")),Le(t,Me.previewPage,w),Le(t,Me.viewport,E)],b=()=>{c.refresh(),d.refresh(),p.refresh()},R=n?.watch(b),P=Ba(e).watch(m=>{l=m,v.refresh()}),F=r?.watch(m=>{m&&"commonStyles"in m&&(l=m.commonStyles),v.refresh()});let D;const k=()=>{D?.(),D=o.current()?.subscribe(()=>v.refresh()),v.refresh(),d.refresh()};k();const _=o.subscribe(k),S=()=>c.refresh();s.addEventListener("change",S);const T=li.watch(()=>c.refresh());e.getInstance(G)?.addDispose(()=>{I.forEach(m=>m.dispose()),R?.dispose(),P.dispose(),F?.dispose(),D?.(),_(),s.removeEventListener("change",S),T.dispose()})}var Cr;(function(e){function t(o,i,s=(a,l)=>a===l){if(o===i)return!0;if(o.length!==i.length)return!1;for(let a=0;a<o.length;a++)if(!s(o[a],i[a]))return!1;return!0}e.isEqual=t;function n(o,i=s=>s){const s=new Set;return o.filter(a=>{const l=i(a);return s.has(l)?!1:(s.add(l),!0)})}e.unique=n;function r(o=[],i=[],s=(a,l)=>a===l){const a=[],l=[],c=[];for(const d of o){const p=i.find(v=>s(d,v));p?c.push({prev:d,next:p}):l.push(d)}for(const d of i)o.find(p=>s(d,p))||a.push(d);return{added:a,removed:l,exists:c}}e.diff=r})(Cr||(Cr={}));function Sh(e,t){return e.type===t.type&&e.key===t.key}function Ih(e){const t=de(e),n=()=>e.getServices(ot)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(z.SANDBOX_ADD_EXTENSIONS,r)}),i=Pc(ot),s=e.onInject(a=>{if(a!==i)return;const l=n();if(!t.isInited()){r=l;return}const{added:c,removed:d}=Cr.diff(r,l,Sh);if(r=l,d.length){if(d.some(p=>p.type==="script")){t.send(z.RELOAD);return}t.send(z.SANDBOX_REMOVE_EXTENSIONS,d.map(p=>p.key))}c.length&&t.send(z.SANDBOX_ADD_EXTENSIONS,c)});e.getInstance(G)?.addDispose(()=>{o.dispose(),s?.dispose()})}var Ch=new Set([...Object.values(z).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(Vr)]);function Th(e){return e.length>0&&!e.startsWith("em:")&&!Ch.has(e)}function Ah(e){const t=de(e),n=new Map;let r=!1,o=-1,i=new Set;const s=c=>(c!==o&&(o=c,i=new Set),i),a=t.observeOutgoing((c,d)=>{if(!r||!Th(c))return;const p=Se(t);n.set(c,{data:d,generation:p,scripts:new Set(s(p))})}),l=t.addListener(Vr,c=>{if(c.phase!=="ready"||c.status!=="success")return;r=!0;const d=Se(t),p=s(d);p.add(c.key);for(const[v,E]of n)E.generation===d||![...E.scripts].every(w=>p.has(w))||(E.generation=d,t.send(vs(v),E.data))});e.getInstance(G)?.addDispose(()=>{a.dispose(),l.dispose()})}var Rh=H("prewarm.editorVisible");function Ph(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Dh(e={}){const t=e.paint??Ph;let n=!1,r=!1,o=!1,i=!1,s=!1;const a=[],l=()=>{s||i||!n||!r||!o||(i=!0,t(()=>{s=!0,ne(ce.editorVisible);for(const c of a.splice(0))c()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){o=!0,l()},whenVisible(c){if(s){c();return}a.push(c)},contentShown:()=>o}}function Oh(e){return e.getOrCreateInstance(Rh,()=>Dh())}var kh=500,xh=500,Mh=5e3;function Lh(e){const t=e.quietMs??kh,n=e.floorMs??xh,r=e.ceilingMs??Mh;let o,i,s=0;const a=()=>{clearTimeout(o),clearTimeout(i),o=void 0,i=void 0},l=()=>{a(),e.run()},c=()=>{clearTimeout(o);const d=n-(Date.now()-s);o=setTimeout(l,Math.max(t,d))};return{start(){a(),s=Date.now(),i=setTimeout(l,r),c()},notify(){o!==void 0&&c()},cancel:a}}var Nh=2;function ci(){return new Error("[sandbox] document reloaded during fill")}function Fh(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Gn(e){try{e()}catch{}}function Bh(e){let t;return Gn(()=>{t=e()}),{stage:n=>Gn(()=>t?.stage(n)),end:(n,r)=>Gn(()=>t?.end(n,r))}}function jh(e){const t=()=>e.initPipeline();let n=!1,r,o,i,s=0,a,l;const c=()=>{const _=e.readTarget?.(),S=e.readSandboxGeneration?.();return _===void 0||S===void 0?void 0:{target:_,generation:S}},d=()=>{const _=c();return _&&{..._,canvasReplaced:e.trackDocument?.(_.target)}},p=_=>{if(_?.canvasReplaced?.())return!0;const S=c();return _!==void 0&&S?.target===_.target&&S.generation!==_.generation},E=dp({...e,waitScope:()=>({getSandboxTimeoutMs:_=>t().getSandboxTimeoutMs(_),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const _=l;if(!(!_||!e.onSandboxGenerationChange))return{getGeneration:()=>c()?.generation??_.generation,onChange:S=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===_.target||_.canvasReplaced?.())&&S()})??(()=>{})}}});let w;const I=(_,S)=>{if(w===_)return;w=_;const T=s;setTimeout(()=>{s!==T||t().signal.aborted||F(_,S).catch(()=>{})},0)},b=()=>{a?.abort(),a=void 0};let R;const P=()=>{const _=t().signal;_!==R&&(R?.removeEventListener("abort",b),R=_,_.addEventListener("abort",b))};async function F(_,S,T=0){const m=++s;b(),a=new AbortController,l=void 0,P();const u=()=>s!==m,f=E.readTarget(),g=t().generation,x=()=>g===t().generation&&!t().signal.aborted,O=S?"init:reset-":"init:",y=Bh(()=>e.observeShow?.(Fh(_,S,e.readEmail())));if(!S){const W=E.publicEmail();W?.id,W?.renderGuid,W?.preheader}let A=!1,h=!1,C,N=!1;const V=()=>{if(p(C))throw ci()},q=()=>{if(u())throw ve("Fill superseded")};try{n=!0,await E.sendInitStart(),q(),C=d(),l=C,T===0&&E.fireWillInit(),await(S||T>0?E.refreshContent():E.sendContent()),A=!0,q(),V();const W=E.contentSent();E.noteFilled(W?.target,W?.docId),y.stage("content"),S||E.publicEmail()?.id;try{await E.sendPreheader()}catch(B){if(Zo(B)||u())throw B;`${O}`,String(B)}q();try{await E.sendSubject()}catch(B){if(Zo(B)||u())throw B;`${O}`,String(B)}if(q(),V(),E.showFilled(f),await E.sendInited(),q(),V(),h=!0,o===_){const B=e.readSandboxGeneration?.()??i;B!==void 0&&(r=B)}y.stage("reveal"),await E.revealFilled(),V(),y.end("revealed")}catch(W){const B=!u()&&x()&&p(C),M=B?ci():void 0,$=M??W,X=B&&T<Nh?k(_,S,T+1):void 0;N=B&&X===void 0;const Q=u()?void 0:{showId:_,contentApplied:A,sandboxInitedAcked:h,superseded:!1,...e.describeSurface?.(),error:String(M??W)};Q&&(`${O}`,void 0);const Z=!u()&&e.recoverFailedFill?.(f)===!0;if(y.end(u()?"superseded":Z?"recovered":zr($)||!x()?"aborted":"failed",Q),!Z&&!u()&&po(t(),_)&&t().failShow(_,$),X!==void 0)return X;throw $}finally{D(_,S,O,{superseded:u(),sessionGeneration:g,contentApplied:A,sandboxInitedAcked:h&&!N,retry:!N,commit:x()})}}function D(_,S,T,m){const{superseded:u,contentApplied:f,sandboxInitedAcked:g}=m;if(u){`${T}`;return}g&&m.commit?E.fireInit(_,S||void 0):g?(`${T}`,m.sessionGeneration,t().generation,t().signal.aborted,void 0):f?(`${T}`,void 0):(`${T}`,void 0),n=!1,a=void 0,!g&&o===_&&(o=void 0,r===i&&(r=void 0)),!g&&f&&m.retry&&I(_,S)}function k(_,S,T){return F(_,S,T)}return{channel:E,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:_=>{r=_},lastCorrelation:()=>o,markCorrelation:_=>{o=_},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:_=>{i=_},fill:_=>F(_,!1),refill:_=>F(_,!0),stop:()=>{s+=1,b(),n=!1,R?.removeEventListener("abort",b),R=void 0}}}function Uh(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:ja(e,n)}function ja(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Hh(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:i}=e,s=d=>{const p=n(),v=o();if(!Uh(p,d,v)){d.showId,d.navId,d.emailId,p?.id,p?.showId,p?.renderGuid;return}d.showId,p?.id,p?.renderGuid,t.markFilled(i()),t.markCorrelation(d.showId),t.fill(d.showId).catch(()=>{})};return{showRequested:d=>{s(d)},showRequestIdentityChanged:()=>{const d=e.initPipeline().getActiveShowRequest();d&&s(d)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const d=i();if(t.filledGeneration()===d)return;const p=n(),v=o();if(!p?.renderGuid||!ja(p,v))return;const E=`${wa}${p.renderGuid}`;t.markFilled(d),t.markCorrelation(E);const w=r()?.isReady()===!0;p.id,p.renderGuid,(w?I=>t.refill(I):I=>t.fill(I))(E).catch(()=>{t.lastCorrelation()===E&&t.markFilled(void 0)})},saasChanged:()=>{const d=n();d?.renderGuid,d?.showToken,d?.id,r()}}}var $h=H("canvas.health");function qh(e){return e??""}function Vh(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function di(e){return e.length>0}function Gh(e){const t=le(e),n=de(e),r=()=>te(t.sessionKey())?void 0:t.current(),o=()=>{const L=r();return xa({attributes:L?.get().attributes??{},readContent:()=>L?.getContent(),docId:L?.get().docId,hasSession:!!L,serverId:L?.get().serverId,show:t.showFacts()})},i=()=>e.getInstance(Pe)??ho;let s={},a=!1;const l=e.getInstance(pe)?.watch(L=>{a=!!L?.element});let c=!1,d=!1,p=!1,v=0;const E=()=>{const L=se(e);if(!L)return;const J=++v,K=L.spare();return K&&ka(e,K.element),(K?K.reloadQuietly():L.ensureSpare()?.ready())?.then(()=>{if(J!==v)return;c=!0;const he=L.spare();he&&Kp(e,he.element),p&&(p=!1,g(),B())})},w=Lh({run:()=>{p||E()?.catch(()=>{})}}),I=()=>{Oh(e).noteContentShown(),!c&&!p&&w.start()};let b=!1;const R=L=>{const J=se(e),K=J?.spare()?.element.contentWindow;d&&J&&K&&L===K&&(d=!1,J.promote(),J.busy(!1),b=!0)};let P=!1;const k=jh({container:e,messageService:n,initPipeline:i,readDocument:r,readEmail:o,revealFilled:()=>{const L=se(e);return b&&L&&(b=!1,w.start()),a?L?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:R,noteFilled:(L,J)=>se(e)?.noteFilled(L,J),recoverFailedFill:L=>{const J=se(e),K=J?.spare()?.element.contentWindow;return!d||!J||!K||L!==K?!1:(d=!1,c=!1,u="reload",J.busy(!1),J.peek("email")?.reload(),P=!0,B(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>Se(n),onSandboxGenerationChange:L=>hn(n,L),trackDocument:L=>Yp(e,L),observeShow:L=>e.getInstance($h)?.begin(L),describeSurface:()=>({canvasPath:u,promoted:d,spareClean:c,handshake:n.isInited(),generation:Se(n)}),events:{willInit:L=>{ae(e,j.WILL_EMAIL_INIT_ID).fire(L)},inited:L=>{I(),ae(e,j.ON_EMAIL_INIT_ID).fire(L)},contentChanged:L=>{ae(e,j.ON_CONTENT_CHANGED_ID).fire(L)},emailChanged:L=>{ae(e,j.ON_EMAIL_CHANGED_ID).fire(L)},browserExtensionDetected:()=>{ae(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),_=Hh({pipeline:k,initPipeline:i,readEmail:o,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>Se(n)});let S="",T="",m="",u="none";const f=()=>{const L=se(e)?.spare()?.element.contentWindow;L&&n.getTarget()===L||n.sendNow({operation:z.SANDBOX_LOCK_EDIT,data:!0})},g=()=>{const L=se(e)?.spare();L&&(f(),c=!1,d=!0,zp(e,L.element))},x=(L,J)=>{const K=se(e);if(!K)return!0;const he=K.spare(),oe=he&&c?"spare":"prepare";if(u=oe,K.busy(!0),he&&c)return g(),!0;w.cancel(),f();const He=E();if(He===void 0)return u="reload",K.busy(!1),K.peek("email")?.reload(),!0;p=!0;const xe=v;return He.catch(()=>{!p||xe!==v||(p=!1,u="reload",K.busy(!1),K.peek("email")?.reload())}),!1},O=()=>{if(te(t.sessionKey()))return;et(),k.noteSandboxGeneration(Se(n));const L=o(),J=Vh(L?.renderGuid,L?.showId,L?.id,s.emailId),K=qh(L?.renderGuid);if(K!==T){const He=T;T=K;const xe=se(e)?.peek("email")?.filled,Ul=xe!==void 0&&xe!==K;di(K)&&(di(He)||Ul)&&x(He||(xe??""),K)}if(p)return;(J!==S||P)&&(P=!1,S=J,_.showRequestIdentityChanged());const he=r(),oe=`${J}|${he?.get().docId??""}|${Se(n)}`;oe!==m&&he?.isReady()===!0&&(m=oe,_.selfInitChanged()),_.saasChanged(),q()};let y=!1,A="",h="",C=!1,N=!1;const V=L=>{L.source==="user"?N=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(C=!0),B()},q=()=>{const L=o();if(!L?.renderGuid)return;const J=k.channel.readContent(),K=JSON.stringify([L.preheader,L.common_styles,L.meta,L.subject,L.utm_parameters?.utm_campaign??"",L.utm_parameters?.utm_content??"",L.utm_parameters?.utm_medium??"",L.utm_parameters?.utm_source??"",L.utm_parameters?.utm_term??""]),he=y&&J!==h,oe=y&&K!==A;y=!0,h=J,A=K;const He=C&&!N;if(C=!1,N=!1,k.isEventsLocked()||He)return;const xe={...L,id:s.isTemplate||L.isNew?void 0:L.id,html:J};if(he){ae(e,j.ON_CONTENT_CHANGED_ID).fire(J),ae(e,j.ON_EMAIL_CHANGED_ID).fire(xe);return}oe&&L.is_inited&&ae(e,j.ON_EMAIL_CHANGED_ID).fire(xe)};let W=!1;const B=()=>{W||(W=!0,queueMicrotask(()=>{W=!1,O()}))};e.inject(mo,{pipeline:k,setRoute:L=>{L.emailId===s.emailId&&!!L.isTemplate==!!s.isTemplate||(s=L,B())}});let M,$;const X=()=>{const L=r()?.get().docId;L!==$&&(M?.(),$=L,M=r()?.subscribe(V)),B()};let Q,Z;const et=()=>{const L=e.getInstance(Pe);!L||L===Q||(Z?.(),Q=L,Z=L.onShowRequested(J=>_.showRequested(J)))},vt=n.addListener(L=>{L.data?.operation===z.SANDBOX_RESIZED&&w.notify()}),Ue=t.subscribe(X),ke=hn(n,B);X(),e.getInstance(G)?.addDispose(()=>{l?.dispose(),Z?.(),ke(),Ue(),M?.(),vt.dispose(),w.cancel(),k.stop()})}function zh(){return lc!=="useblocks"}var Ua={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Wh={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},ui=Ua,Kh=["freeUserBlocks","blocks"],Tr={};function Yh(e){Tr=e}var Ha=e=>Kh.includes(e)?ui:Tr[e]??Tr.editor??ui,Ar={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},Xh={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",saveHotkeyEnabled:!0,commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Jh={...Ar,config:{...Ar.config,imageCenterFileManagerView:!1}};Yh({pro:Wh,editor:Xh,simple:zh()?Ar:Jh,blocks:Ua});function Qh(e,t,n=e.getInstance(fe)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Fa(e).isCodeMode&&Ir(e,!1)}function Zh(e){e.getInstance(_c)||e.inject(De,void 0)}function Dn(e){return String(e.standaloneKey||"").trim()||void 0}function em(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function bo(e){return em(e)?!!Dn(e):!1}function Ut(e){return!!Dn(e)&&!bo(e)}var tm=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function fi(e){return e==="server"?"serverSide":e}function nm({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=ge();let i={kind:"pending"},s;const a=new Promise(v=>{s=v}),l=n===void 0?void 0:setTimeout(()=>{d({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function c(){i.kind!=="pending"&&o.set(qn(r,e))}function d(v){if(i.kind!=="pending")return;clearTimeout(l),i=v;const E=qn(r,e);o.set(E),s(E)}function p(v,E){r[fi(v)]=E,v==="server"&&i.kind==="pending"?d({kind:"applied"}):c()}return{watch:v=>o.watch(v),select:v=>o.select(v),get:()=>o.get(),ready:()=>a,state:()=>i,layers:()=>({...r}),bootstrap(){const v=qn(r,e);return Object.fromEntries(tm.map(E=>[E,v[E]]))},merge(v,E){p(E,{...r[fi(E)],...v})},replace(v,E){p(E,v)},setMode(v){r.user={...r.user,mode:v},c()},setAdvancedConfigs(v){r.advancedConfigs=v,c()},serverAbsent(v){d({kind:"absent",reason:v})},applyServerResponse(v){i.kind==="pending"&&p("server",{...r.serverSide,...v})},dispose(){clearTimeout(l)}}}var rm=5e3,om="blocks";function im(){return{...Ha(om)?.config,mergeTags:void 0}}function sm(e,t){e.getInstance(pe)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},o=t.layers().user.mode;t.replace(r.mode===void 0&&o!==void 0?{...r,mode:o}:r,"user")})}function am(e,t){let n;lo(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const i={};r?.theme&&(i.theme=r.theme),r?.locale&&(i.locale=r.locale),t.replace(i,"profile")})}function lm(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function cm(e,t){let n,r=!1,o;const i=a=>{o??=An(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&Qh(e,a,t)},s=lo(e).watch(({profile:a})=>{const l=a?.email_builder_config,c=lm(l);if(c===void 0||l===n)return;const d=n===void 0;n=l,!(d&&r)&&i(c)});e.getInstance(G)?.addDisposable(s),t.ready().then(a=>{if(!a.configSwither)return;const l=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",l),r=n===void 0,i(l)})}var pi="замкнутый контур: app_init не выполняется";function dm(e,t){if(e.getInstance(De)){t.serverAbsent(pi);return}const n=e.getInstance(pe)?.watch(r=>{Ut(r)&&t.serverAbsent(pi)});n&&e.getInstance(G)?.addDisposable(n)}async function um(e,t){if(e.getInstance(Zr)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Be);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function fm(e){e.injectFactory(fe,(t,n)=>{if(n)return n;const r=nm({base:im(),env:{modeDefaults:o=>Ha(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:rm});return sm(e,r),am(e,r),cm(e,r),dm(e,r),um(e,r),e.getInstance(G)?.addDisposable(r),r},!0)}var ct=class extends ue{_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 U(e,t,n){const r=bc(e);return(o,i,s)=>{const a=r(async l=>{const c=t?t(l):l;s&&o.bind(s);const d=await o(c);return n?n(d):d},i,s);return()=>a.dispose()}}var pm=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new pr;this.handleDestroy=U(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new ct(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{}}},yo=H("DestroyableService");function hm(e){e.injectFactory(yo,(t,n)=>{if(n)return n;const r=e.getInstance(G);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new pm({lifetime:r,options:e.getInstance(pe),getInstance:()=>e.getInstance(In),release:()=>tc(e.getInstance(Tc)??e)})},!0)}function mm(e){const t=e.getInstance(yo);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var gm=1e3;function $a(e,t,n=gm,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const o=Object.keys(e),i=Object.keys(t);if(o.length!==i.length)return!1;for(const s of o)if(!$a(e[s],t[s],n,r+1))return!1;return!0}return!1}function Pt(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const o=t[r],i=e[r];$a(o,i)||(n[r]=o)}return n}var vm=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function bm(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function ym({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??Cn();let i;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,l)=>{i=setTimeout(()=>{const c=new Tn(o);n.value.id,Bd(c,bm(s,r)),l(c)},o)})])}catch(s){throw Bs(s),s}finally{i!==void 0&&clearTimeout(i)}}function Em(e){const{emails:t}=e,n=async(r,o)=>{const i=vm(o),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...i}:i,l=s?Pt(s,i):i,c=d=>{const p=String(d.id??r??Ee()),v=d.id===void 0?{...d,id:p}:d;return t.cache.addOrUpdate(p,()=>v)};return await c(await ym(e,{prev:s,patch:l,value:a,source:o.source??""},c))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const o=await n(void 0,r);return o?.renderGuid?o:{...o,renderGuid:Ee()}},async updateEmail(r,o){return await n(r,o)}}}var zn=20;function _m(e){const t=wm(e);return e.saveTimeoutMs?Sm(t,e.saveTimeoutMs):t}function wm({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:i}){const s=async(a,l)=>(t.clear(),await t.get(a,{page:l}),(await e.cache.values()??[]).filter(c=>String(c?.parent)===String(a)));return{async readRevisions(a,l=1){const c=await s(a,l);return{revisions:c.slice(zn*(l-1),zn*l),page:l,hasMore:c.length>zn*l}},async readAutosave(a){const l=await r?.(a)??NaN,c=Number.isFinite(l)?l:void 0,d=await n?.(a);if(!d?.asked)return zd(await s(a,1),c);if(!d.revision)return qo([],c);const p={...d.revision,parent:a,isAutosave:!0};return qo([p],c,await s(a,1))},async saveAutosave(a,l){const c=await o?.(a),d=i?.();return await e.create({...Qd(l),...c!==void 0?{author:c}:{},...d!==void 0?{project:d}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Sm(e,t){return{...e,async saveAutosave(n,r){const o=t();let i;try{return await Promise.race([e.saveAutosave(n,r),new Promise((s,a)=>{i=setTimeout(()=>a(new Ms(o)),o)})])}catch(s){throw Bs(s),s}finally{i!==void 0&&clearTimeout(i)}}}}var Im=class extends Rc{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}},Cm=class extends Fe{};var hi=class extends ue{_items=new Map;_onChangeEmitter=new Wl;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const o=await t(n);return Re(n,o)||this._onChangeEmitter.fire(),o}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([o,i])=>o)),r=(await this.entries()).filter(([o,i])=>!n.has(o));for(const[o,i]of e)t.push(this.addOrUpdate(o,()=>i)),n.add(o);for(const[o]of r)t.push(this.remove(o));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function Tm(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:i=20}={}){const s=e.length;let a=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(c=>{for(const d of l){const p=c[d],v=t[d];return d==="id"||typeof p!="string"?p===v:typeof v=="string"&&p.startsWith(v)}return!0}),a=e.length}return r&&(e=e.sort((l,c)=>(l[r]>c[r]?1:c[r]>l[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(i*(o-1),i*o)),{data:e,filteredTotal:a,total:s,totalPages:Math.ceil(a/i)}}function Am(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const o=t.get(r.id)||{};t.set(r.id,{...o,...r})}return[...t].map(([n,r])=>r)}function Rm(e,t){return mi(e)&&mi(t)?String(e)===String(t):e===t}function mi(e){return typeof e=="string"||typeof e=="number"}var Pm=class extends ue{_cache=new hi;_readEmitter=new Fe;_saveEmitter=this.addDisposable(new Im);_removeEmitter=this.addDisposable(new Cm);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ue);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new hi),o=n.addDisposable(new Fe);t=this._foreignCache[e]={get:async(i,s={})=>{await r.getOrCreate(i,async()=>{try{const l=Am(await o.fire(i))||[];for(const c of l)c[e]=i,await this._cache.add(c.id,c);return l}catch{return[]}});const a=(await this._cache.values()||[]).filter(l=>{const c=l[e];return c==null||Rm(c,i)});return Tm(a,s)},first(i,s={}){return t.get(i,{...s,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:o.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=Ee()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async o=>{const i=o?{...o,...t}:t;if(!r)return t=o?Pt(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:i,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function Ht(e){const t=H(e);return n=>n.getOrCreateInstance(t,()=>new Pm)}function qa(e){const t=e.getInstance(G);if(!t)throw new Error("Failed");return t}function gi(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Zt(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function Dm(e,t,n){return e&&!gi(t)&&gi(e)?{...n,meta:e.meta}:n}var Om=H("CurrentProject"),km={};function $t(e){return e?.getInstance(Om)?.get()??km}function Eo(e){const t=$t(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Va=Ht("plugin.dataSource.emails"),Ga=Ht("plugin.dataSource.emailRevisions"),za=Rn("plugin.readEmailAutosave"),vi=H("emailDocuments.provided");function xm(e){const t=Va(e),n=Ga(e),r=n.byForeignKey("parent");if(e.getInstance(vi))return{emails:t,emailRevisions:n};e.inject(vi,!0);const o=()=>Cn(e.getInstance(Pe)?.contentReadyTimeoutMs),i=Em({emails:t,saveTimeoutMs:o}),s=new Map,a=(l,c)=>d=>{const p=d?.id??c;return(typeof p=="string"||typeof p=="number")&&s.set(String(p),l),d};return Su(e,{...i,createEmail:l=>i.createEmail(l).then(a(Date.now())),updateEmail:(l,c)=>i.updateEmail(l,c).then(a(Date.now(),l))}),Au(e,_m({revisions:n,revisionsByEmail:r,readAutosave:async l=>{const c=await ae(e,za).fire(l);return c.length===0?{asked:!1}:{asked:!0,revision:c[0]??null}},savedAt:async l=>{const c=Vd((await t.cache.getIfPresent(l))?.modified),d=s.get(String(l))??NaN;return Number.isFinite(d)&&!(c>=d)?d:c},emailAuthor:async l=>(await t.cache.getIfPresent(l))?.author,saveTimeoutMs:o,integratorProject:()=>$t(e).requested})),qa(e).addDisposable(t.onSave(({prev:l,patch:c,value:d})=>Dm(l,c,d),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function bi(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 Mm(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Lm="po",en=null;function Nm(){const e=typeof window.__useblocks__<"u"?window.__useblocks__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([Lm],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Fm(){return en===null&&(en=Nm().catch(e=>{throw en=null,e})),en}async function Wa(e){if(typeof e=="object")return _o(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Bm(t):jm(t)}function _o(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Bm(e){try{return _o(JSON.parse(e))}catch{return}}var yi=!1;async function jm(e){try{return _o((await Fm()).parsePoCatalog(e))}catch{yi||(yi=!0);return}}var Um="em_locale",Hm="em_ant_locale",$m="locale",qm="ant_locale";function wo(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Ka(e,t){const n=wo(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function Vm(){return wo("em_locale")??Ka($m,"em_locale")}function Ei(e){try{localStorage.setItem(Um,JSON.stringify(e))}catch{}}function Gm(){return wo("em_ant_locale")??Ka(qm,"em_ant_locale")}function zm(e,t){try{localStorage.setItem(Hm,JSON.stringify({id:e,data:t}))}catch{}}var Wm=8e3;function Km(e,t){const n=e,r=t,o=Object.keys(n).filter(i=>i!=="");return o.length!==Object.keys(r).filter(i=>i!=="").length?!1:o.every(i=>JSON.stringify(n[i])===JSON.stringify(r[i]))}function Ym(e){const t=Vm(),n=Gm();let r={ready:!1},o;const i=ge(r);let s=0;const a=b=>{r={...r,...b},i.set(r)},l=()=>{r.ready||a({ready:!0})},c=setTimeout(l,e.unlockAfterMs??Wm),d=b=>b!==s;let p;async function v(b,R){if(n?.id===b&&n.data&&a({antd:n.data}),!p)return;const P=await p(b).catch(()=>{});!P||d(R)||(a({antd:P}),zm(b,P))}async function E(b,R){const P=await e.askHost(b).catch(()=>null);if(d(R))return!0;if(P==null)return!1;const F=await Wa(P);return d(R)||(F&&a({catalog:F}),l()),!0}async function w(b,R){const P=await e.readList();if(d(R))return;if("error"in P){a({failure:{kind:"GET_LOCALES_ERROR",error:P.error}}),l();return}const F=P.data.find(k=>k.locale===b);if(!F){Mm("em_locale")&&a({catalog:void 0}),l();return}if(bi(t,F)&&(!o||o.catalog===t?.data)){l();return}if(o?.entry&&r.catalog===o.catalog&&bi(o.entry,F)){Ei(o.entry),l();return}const D=await e.readCatalog(b);if(!d(R)){if("error"in D){a({failure:{kind:"GET_LOCALE_ERROR",error:D.error}}),l();return}D.data&&(o?.id===b&&r.catalog===o.catalog&&Km(o.catalog,D.data)||a({catalog:D.data}),Ei({id:b,time:F.updatedAt||Math.floor(Date.now()/1e3),hash:F.contentHash,data:D.data})),l()}}async function I(b,R){if(!await E(b,R)){if(!d(R)&&(o?.id===b&&r.catalog===o.catalog||b==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await w(b,R)}}return{set(b){if(!b||b===r.id)return;const R=s+=1;a({id:b,failure:void 0});const P=o?.id===b&&r.catalog===o.catalog;(o&&!P&&r.catalog===o.catalog||b==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===b&&t.data&&(a({catalog:t.data}),l()),v(b,R),I(b,R)},prime(b,R,P){r.id&&r.id!==b||r.catalog||!R||(o=t?.id===b&&t.data&&(!P||t.time>=P.time)?{id:b,catalog:t.data}:{id:b,catalog:R,entry:P?{id:b,time:P.time,hash:P.hash,data:R}:void 0},a({catalog:o.catalog}))},useAntdLoader(b){p=b,r.id&&v(r.id,s)},state:i,snapshot:()=>r,dispose:()=>clearTimeout(c)}}var Xm=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})},Jm=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:o,format:i,baseUrl:s,cancelToken:a,...l})=>{const c=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},d=this.mergeRequestParams(l,c),p=o&&this.toQueryString(o),v=this.contentFormatters[r||"application/json"],E=i||d.format;return this.customFetch(`${s||this.baseUrl||""}${n}${p?`?${p}`:""}`,{...d,headers:{...d.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):d.signal)||null,body:typeof e>"u"||e===null?null:v(e)}).then(async w=>{const I=w;I.data=null,I.error=null;const b=E?w.clone():w,R=E?await b[E]().then(P=>(I.ok?I.data=P:I.error=P,I)).catch(P=>(I.error=P,I)):I;return a&&this.abortControllers.delete(a),R})}},Qm=H("rest.v2.transport"),_i=Symbol("rest.v2.secureRequest");function Zm(e){return e.getOrCreateInstance(Qm,()=>{const t=e.getInstance(Kl)?.execute||fetch;return new Jm({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[_i]:!0}),customFetch:(n,r={})=>{const{[_i]:o,...i}=r;return t(n,{...i,[Xl]:o!==!0})}})})}function eg(e,t){const n=Zm(e);return Object.assign({},...t.map(r=>new r(n)))}function wi(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Ya(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:wi(n.details,"wp_code")??n.code,message:wi(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 Xa(e){return!e.ok||!!e.error}function tg(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Ja(){return tg(Wr.em_translations_v2)??!0}function ng(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function rg(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function og(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],o=r[0];return typeof o=="string"&&o!==""&&t.push({locale:o,updatedAt:ng(r[1])}),t},[]):[]}function ig(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:rg(n.updated_at),contentHash:n.content_hash}),t),[])}function Qa(e){return eg(e,[Xm])}function bn(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Rr(e){return!e.ok||e.error!=null}function Pr(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Wn(e){return{data:await Wa(e)??null}}async function sg(e){if(Ja())try{const n=await Qa(e).localesList();return Xa(n)?{error:Ya(n)}:{data:ig(n.data)}}catch(n){return bn(n)}const t=bs(e,[ws]);try{const n=await t.get_translations2({file:"react_app"});return Rr(n)?Pr(n):{data:og(n.data)}}catch(n){return bn(n)}}async function ag(e,t){if(Ja())try{const r=await Qa(e).jsonList({locale:t});return Xa(r)?{error:Ya(r)}:Wn(r.data)}catch(r){return bn(r)}const n=bs(e,[ws]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Rr(r)?Pr(r):Wn(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Rr(r)?Pr(r):Wn(r.data)}catch(r){return bn(r)}}}var tn=new WeakMap;function lg(e){const t=tn.get(e);if(t!==void 0)return t;const n=sg(e).then(r=>("error"in r&&tn.delete(e),r),r=>{throw tn.delete(e),r});return tn.set(e,n),n}var ht=H("locale.service");function cg(e){if(e.getInstance(ht))return;const t=Ym({readList:()=>lg(e),readCatalog:n=>ag(e,n),askHost:async n=>(await ae(e,j.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(De)});e.inject(ht,t),e.getInstance(G)?.addDispose(()=>t.dispose())}function dg(e){const t=e.getInstance(fe);if(!t)return;const n=e.getInstance(ht);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"en_US"));e.getInstance(G)?.addDisposable(r)}var ug="user_id",fg="project_id",Si=H("rest.identityHeadersProvided");function pg(e){if(e.getInstance(Si))return;e.inject(Si,!0);let t;e.getInstance(pe)?.watch(n=>{t=n}),e.addService(Sn,{execute(n,r){if(r?.public)return;const o=t?.user?.id??ta(e).profile?.id;o!=null&&o!==""&&n.headers.set(ug,String(o));const i=t?.project;i!=null&&i!==""&&n.headers.set(fg,String(i))}})}function hg(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function mg(e){return e.id??hg(e.catalog)}function gg(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function vg(e){return gg(e||"en_US")}var bg="Accept-Language",Ii=H("rest.localeHeaderProvided");function yg(e){e.getInstance(Ii)||(e.inject(Ii,!0),e.addService(Sn,{execute(t){const n=e.getInstance(ht)?.snapshot();t.headers.set(bg,vg(n&&mg(n)))}}))}function Eg(e){if(!e)return!1;try{return e.getInstance(De)!==void 0}catch{return!1}}var _g="Invalid standaloneKey.",p_=H("StandaloneMockGuard");function wg(){const e=new Error(_g);return e.name="InvalidStandaloneKeyError",e}function Sg(e){e.addService(Sn,{execute:()=>{if(Eg(e))throw wg()}})}function Ig(e){Ac(e),Sg(e)}function Cg(e){const t=new Sa;e.inject(Pe,t);const n=e.getInstance(pe)?.watch(o=>{if(!o)return;const i=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...i!==void 0?{signal:i}:{}})}),r=e.getInstance(G);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var Za=Ht("plugin.dataSource.blocks"),Tg=Ht("plugin.dataSource.blockRevisions"),Ag=Ht("plugin.dataSource.comments"),Rg=Rn(),Pg=Rn(),el=`<!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 us,r as Hl}from"./static/esm/971f1b2c.js";import{$ as xo,A as $l,At
1042
1042
  </tr>
1043
1043
  </table>
1044
1044
  </body>
1045
- </html>`;function Dg(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:el,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 tl=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Og(e){return!Object.keys(e).some(t=>tl.has(t))}function kg(e){const t={},n={};for(const[r,o]of Object.entries(e))tl.has(r)?t[r]=o:n[r]=o;return{showOptions:t,misplacedEmailFields:n}}function Ci(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function On(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function xg(e){const t=typeof e.block=="string"?{code:e.block}:{...e.block},n=t.id!==void 0&&t.id!==""&&t.code===void 0,r=e.reload===!0&&t.id!==void 0&&t.id!=="";return{block:t,byId:n,blocks:e.blocks,revisions:e.revisions,reload:r}}function qt(e){return{emails:Ga(e),blocks:Za(e),emailRevisions:Va(e),blocksRevision:Tg(e),comments:Ag(e)}}function Mg(e){const t=Object.values(qt(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function kn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Og(e))return{email:Ci(e)};{const{showOptions:n,misplacedEmailFields:r}=kg(e),o=Object.keys(r);t&&o.length>0&&void 0;const i=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:Ci({...r,...i})}}}function So(e){const t=Xe(e);return t&&te(t.sessionKey())?t.suspendedDocument():t?.current()}function an(e){return So(e)?.getContent()}function nl(e,t){const n=t??Dg(),r=So(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:an(e)??n.html}:n}async function St(e){return(await e.getInstanceAsync(Be))?.project}async function rl(e){return Eo(e)??await St(e)}async function Ti(e,t){const n=Za(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(o=>o!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await rl(e),{filter:{id:t}})}function Ai(e){if(!e)return;if(On(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=kn(e,!1).email.id;return t==null?void 0:String(t)}function Lg(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function Ng(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}var Ri=new WeakMap;function Fg(e,t){const n=(Ri.get(e)??Promise.resolve()).then(t,t);return Ri.set(e,n.catch(()=>{})),n}function mt({code:e,project:t,...n},r){const o=Oe(n),i=Eo(r),s=Ze(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...o,...e?{html:s.toEditorForm(e)}:{},...i===void 0?{}:{project:i},..."utm_parameters"in o?{utm_parameters:o.utm_parameters||{}}:{},_embedded:void 0}}function be({html:e,renderGuid:t,showToken:n,showId:r,...o},i){const{requested:s}=$t(i),a=oa(i);return Oe({...o,code:Ze(i).toOutputForm(e),project:s===void 0?o.project:s,utm_parameters:a.UTMEnabled?o.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 Dr(e){return e==null?"":e.replaceAll(`\r
1045
+ </html>`;function Dg(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:el,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 tl=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Og(e){return!Object.keys(e).some(t=>tl.has(t))}function kg(e){const t={},n={};for(const[r,o]of Object.entries(e))tl.has(r)?t[r]=o:n[r]=o;return{showOptions:t,misplacedEmailFields:n}}function Ci(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function On(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function xg(e){const t=typeof e.block=="string"?{code:e.block}:{...e.block},n=t.id!==void 0&&t.id!==""&&t.code===void 0,r=e.reload===!0&&t.id!==void 0&&t.id!=="";return{block:t,byId:n,blocks:e.blocks,revisions:e.revisions,reload:r}}function qt(e){return{emails:Va(e),blocks:Za(e),emailRevisions:Ga(e),blocksRevision:Tg(e),comments:Ag(e)}}function Mg(e){const t=Object.values(qt(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function kn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Og(e))return{email:Ci(e)};{const{showOptions:n,misplacedEmailFields:r}=kg(e),o=Object.keys(r);t&&o.length>0&&void 0;const i=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:Ci({...r,...i})}}}function So(e){const t=Xe(e);return t&&te(t.sessionKey())?t.suspendedDocument():t?.current()}function an(e){return So(e)?.getContent()}function nl(e,t){const n=t??Dg(),r=So(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:an(e)??n.html}:n}async function St(e){return(await e.getInstanceAsync(Be))?.project}async function rl(e){return Eo(e)??await St(e)}async function Ti(e,t){const n=Za(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(o=>o!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await rl(e),{filter:{id:t}})}function Ai(e){if(!e)return;if(On(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=kn(e,!1).email.id;return t==null?void 0:String(t)}function Lg(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function Ng(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}var Ri=new WeakMap;function Fg(e,t){const n=(Ri.get(e)??Promise.resolve()).then(t,t);return Ri.set(e,n.catch(()=>{})),n}function mt({code:e,project:t,...n},r){const o=Oe(n),i=Eo(r),s=Ze(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...o,...e?{html:s.toEditorForm(e)}:{},...i===void 0?{}:{project:i},..."utm_parameters"in o?{utm_parameters:o.utm_parameters||{}}:{},_embedded:void 0}}function be({html:e,renderGuid:t,showToken:n,showId:r,...o},i){const{requested:s}=$t(i),a=oa(i);return Oe({...o,code:Ze(i).toOutputForm(e),project:s===void 0?o.project:s,utm_parameters:a.UTMEnabled?o.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 Dr(e){return e==null?"":e.replaceAll(`\r
1046
1046
  `,`
1047
- `)}function Pi(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function Bg(e,t,n,r){const o=jg(e,t,n,r);return o===void 0}function jg(e,t,n,r){if(On(t))return"block";const{email:o}=kn(t,!1),i=mt(o,e),s=i.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=Xe(e)?.current();if(!a)return"no-session";const l=a.get(),c=l.attributes;if(l.serverId!==s)return"document-id";if(c.is_inited!==!0)return"not-inited";const d=Pi(Dr(n??a.getContent()));if(i.html!==void 0&&Pi(Dr(i.html))!==d)return"html";if(i.subject!==void 0&&i.subject!==c.subject)return"subject";if(i.preheader!==void 0&&i.preheader!==c.preheader)return"preheader";if(i.common_styles!==void 0&&i.common_styles!==c.common_styles)return"common_styles"}function Di(e,t){if(On(t))return;const{email:n}=kn(t,!1),r=mt(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:Dr(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function Ug(e,t){const n={...e};return delete n.id,{...n,...t}}function Hg(e){return e.html?e:{...e,html:el}}function We({code:e,project:t,...n},r,o){const i=o??Eo(r);return{...n,...e?{html:Ze(r).toEditorForm(e)}:{},renderGuid:Ee(),...i===void 0?{}:{project:i}}}function me({html:e,renderGuid:t,...n},r){const{requested:o}=$t(r);return Oe({...n,code:Ze(r).toOutputForm(e),project:o===void 0?n.project:o,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function ol(e){return Xe(e)?.current()?.get().serverId??void 0}function Or(e,t,n){return n===void 0&&(n=e.post===void 0?ol(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function It(e,t){return Oe({...e,link:void 0,comment_status:void 0})}function ln({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?ol(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||eu(n.slug),parent:o}}function kr({html:e,isAutosave:t,...n},r){return Oe({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:Oe({html:e,ampHtml:e&&""})})}function cn({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function Oi({html:e,isAutosave:t,...n}){return Oe({...n,autosave:t?!0:void 0,code:e,guid:void 0})}var dt=H("NotificationService"),$g=H("emailTemplate.reads");async function qg(e,t){try{return await Je(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,Vg(e,t,n);return}}var Gg=H("emailTemplate.notifiedFailures");function Vg(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(Gg,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(dt).then(()=>{Ft(e,j.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function zg(e,t){const n=e.getOrCreateInstance($g,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=qg(e,t).then(i=>(i===void 0&&n.delete(t),i));return n.set(t,o),o}var Kn="EXTERNAL",ki=Symbol("supersededShow");function Wg(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var Kg="email_id";function Yn(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}async function Yg(e,t){const n=Cn();let r;try{return await Promise.race([e,new Promise((o,i)=>{r=setTimeout(()=>{e.then(t,()=>{}),i(new Tn(n,"handleSaveBlock","block"))},n)})])}finally{clearTimeout(r)}}var Xg=class extends ue{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=ms();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=qt(t),this._eventLock=Mg(t);const n=J(e,j.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(J(e,j.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(Sn,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Kg,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Pe)??ho}_throwIfDestroyed(){if(this.isDisposed())throw Ne()}async getTemplateEmail(e){const t=await zg(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 St(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,We(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,ln(o,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,Or(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const i=this._dataSources.emails,s=i.cache,a=await St(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let c=mt(e,this._container);const d=c.id;let p=d;if(d!==void 0){const b=await i.get(d);c={...b??{},...c,utm_parameters:c.utm_parameters??b?.utm_parameters??{},renderGuid:b?.renderGuid??Ee(),...l>0?{showToken:l}:{},...o?{showId:o}:{},project:a}}else{p=n??Ee();const b=await i.get(p);c={...c,utm_parameters:c.utm_parameters??{},renderGuid:b?.renderGuid??Ee(),...l>0?{showToken:l}:{},...o?{showId:o}:{},project:a},delete c.project}if(t){const b=await this.getTemplateEmail(String(t));b&&(c=Ug(b,c))}return d===void 0&&(c=Hg(c)),await s.setAll([[p,c]]),c}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Di(this._container,e))return!1;const n=an(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Di(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:an(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&Lg({ticket:t,emailId:Ai(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,ki;if(!e)return;const n=this._getInitPipeline();if(ee(n.signal),On(e))return this._showBlock(e,n);const r=te(le(this._container).sessionKey()),o=Ng(e);if(!r&&!o&&Bg(this._container,e,an(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const i=kn(e);i.email.id,this._prevCommand?.id;let s,a="",l=0,c=!1,d,p=Promise.resolve(),b,E=!1;try{this._eventLock.suspendChange();const{email:w,blocks:I,autosaves:y,comments:R,templateId:P,reload:N}=i;s=w.id;const D=mt(w,this._container),k=D.id,_=k??Ee(),S=await ze("getProject",St(this._container));ee(n.signal),a=Ee();const T={isNew:k===void 0,id:String(_),project:S},m=N===!0&&k!==void 0;m&&(await this._dataSources.emails.remove(String(k),{silent:!0}),String(k)),l=++this._showToken,String(_);const u=[];u.push(this.setBlocks(I)),w.id!==void 0&&(u.push(this.setComments(R)),u.push(this.setEmailRevisions(y,String(w.id)))),u.push(this.setEmail(w,Number(P),k===void 0?String(_):void 0,l,a)),await ze("setEmail+blocks+revisions",Promise.all(u),{emailId:k??String(_),showId:a,targetShowToken:l}),ee(n.signal);const f=await this._dataSources.emails.get(String(_)),g=le(this._container),v={id:a,token:l};if(r){sn(this._container);const O=g.suspendedDocument()?.get().serverId;!m&&k!==void 0&&O!=null&&String(O)===String(k)&&g.resumeSuspended()}k===void 0?b=g.startNewDraft(f??D,{patch:D,show:v}):m?b=g.reload(k,{email:f??D,patch:D,show:v}):g.sessionKey()===nt(k)?b=g.show(D,v):b=g.open(k,{email:f??D,patch:D,show:v}),g.beginShowFill(a);const C=!!this._prevCommand&&Re(this._prevCommand,T);T.id,!this._prevCommand||Re(this._prevCommand,T),this._prevCommand?.id,this._rememberShow(T),p=n.requestShow({showId:a,navId:String(_),emailId:k,isNew:k===void 0}),E=!0;const x=()=>g.endShowFill(a);Promise.allSettled([p,b.whenReady()]).then(x),String(_),c=!0}catch(w){d=w,E&&a&&n.failShow(a,w),a&&Xe(this._container)?.endShowFill(a),zr(w)||(ks(w),void 0)}finally{this._eventLock.resumeChange()}if(!c)throw d instanceof Error?d:new Error(`[useblocks] show() setup failed: ${String(d??"unknown error")}`);return ze("show-init-deferred",Promise.all([p,b?.whenReady().catch(w=>{if(w instanceof Ye){const I=ao(w);throw I?new Error(`[useblocks] show(): email open failed (${I})`,{cause:w}):w}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:s??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:i,reload:s}=xg(e),a=Ee();let l=!1;try{await this.setBlocks(o),ee(t.signal),s&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const c=n.id!==void 0&&n.id!==""?String(n.id):void 0,d=le(this._container);if(!s&&c!==void 0&&d.sessionKey()===fn(c)){const P=Yn(n)?await this._storeShownBlock(n):void 0,N={id:a,token:++this._showToken},D=d.show(P,N),k=t.requestShow({showId:a,navId:c,emailId:void 0,isNew:!1});l=!0,await ze("show-block-init",Promise.all([k,D?.whenReady().catch(()=>{})]),{showId:a});return}const p=r||s?await Ti(this._container,String(n.id)):void 0,b=p&&(s||Yn(n))?await this._storeShownBlock({...me(p,this._container),...n}):r||s?p:await this._storeShownBlock(n);if(ee(t.signal),!b)throw new Error(`[useblocks] show(): block ${String(n.id)} not found`);i!==void 0&&b.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(i.filter(P=>P.id!==void 0).map(P=>[P.id,cn(P,String(b.id))])),this._prevCommand=void 0,this._lastShow=void 0;const E=b.id!==void 0?String(b.id):Ee(),w={id:a,token:++this._showToken};sn(this._container);const I=s?d.reloadBlock(E,b,w):d.openBlock(E,b,w);b.id;const y=t.requestShow({showId:a,navId:E,emailId:void 0,isNew:b.id===void 0});l=!0;const R=I.whenReady().catch(P=>{if(P instanceof Ye)throw P});await ze("show-block-init",Promise.all([y,R]),{showId:a})}catch(c){throw l&&t.failShow(a,c),c}}async _storeShownBlock(e){const t=We(e,this._container,await St(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();ee(e.signal);const t=le(this._container);if(te(t.sessionKey())&&!t.hasSuspended())throw new Error("[useblocks] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:Kn,fallbackTitle:ca(this._container)});if(ee(e.signal),!n)throw Wg(t.emailSaveState().error);return be(nl(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=le(this._container),t=e.current();if(!t||!te(e.sessionKey()))throw new Error("[useblocks] saveBlock(): no open block");return Fg(t,async()=>{await t.whenReady();const n=Pn(t),r=t.get().version,o={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:n.html,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},i=this._dataSources.blocks,s=await Yg(t.get().serverId==null?i.create(o,{source:Kn}):i.update(String(t.get().serverId),o,{source:Kn}),a=>{a&&le(this._container).current()===t&&t.get().serverId==null&&a.id!==void 0&&t.markSaved(r,String(a.id))});if(!s)throw new Error("[useblocks] save(): block was not saved");return t.markSaved(r,s.id!==void 0?String(s.id):void 0),me(s,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=Ai(e);const n=this._queuedShow(e,t).then(r=>r===ki?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),ee(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=le(this._container);if(n!==void 0&&r.sessionKey()===fn(n))return;const o=t.code===void 0&&n!==void 0?await Ti(this._container,n):void 0,i=o&&Yn(t)?await this._storeShownBlock({...me(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!i)throw new Error(`[useblocks] openBlock(): block ${String(n)} not found`);sn(this._container);const s=r.openBlockOver(i.id!==void 0?String(i.id):Ee(),i);i.id,r.hasSuspended(),ae(this._container,j.ON_BLOCK_OPEN_ID).fire({block:i}),await s.whenReady().catch(a=>{if(a instanceof Ye)throw r.current()===s&&(ae(this._container,j.ON_BLOCK_CLOSE_ID).fire({block:i,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),Xp(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function Jg(e){return String(e).replace(/"/g,"&quot;")}function Qg(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 Zg(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 xi(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),o=Jg(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function ev(e,t,n){if(!e?.trim()||!t)return e;const r=Zg(e);if(!r)return e;const o=String(t),i=Qg(n??new Date);let{full:s,index:a}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=xi(s,"em-block-id",o)),s=xi(s,"em-block-version",i),e.slice(0,a)+s+e.slice(a+l)}function tv(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 nv(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),o=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:o,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:tv(e)}}function Xn(e,t){return t?nv(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var il=["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"],rv=[...il,"html","id","project","password"],h_=new Set(["html",...il,"global_block","project"]);function ov(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(rv),r={};for(const o of Object.keys(e))n.has(o)||(r[o]=e[o]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function iv(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...ov(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 xr=new WeakMap;function sv(e){let t=xr.get(e);return t||(t={byId:new Map,fallback:[]},xr.set(e,t)),t}function av(e){xr.delete(e)}function lv(e,t){const{byId:n,fallback:r}=sv(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const i=r.indexOf(o);return i>=0&&r.splice(i,1),o}return}for(let o=r.length-1;o>=0;o--){const i=r[o],s=e.name!=null&&e.name!==""&&i.name!=null&&i.name!==""&&i.name===e.name,a=e.type!=null&&e.type!==""&&i.insertFrom===e.type;if(s&&a)return r.splice(o,1),i.id!=null&&i.id!==""&&n.delete(String(i.id)),i}}async function cv(e,t){const{blocks:n}=qt(e);return await n.cache.getIfPresent(t)??void 0}async function dv(e,t){if(!t.blockId)return;const n=await cv(e,t.blockId);if(n)return iv(n,t)}async function uv(e,t){const n=lv(e,t);if(n)return Xn(e,n);const r=await dv(t,e);return r?Xn(e,r):Xn(e,void 0)}var fv=vs("application_block_inserted"),pv=-1e3,Mi=new WeakSet;function hv(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 mv(e){if(!e||Mi.has(e))return;Mi.add(e);const t=new ue,n=de(e);return t.addDisposable(n.addListenerAsyncPipe(fv,async(r,o)=>{const i=hv(r)?await uv(r,e):r;return o?o(i):i},pv)),t.addDisposable({dispose:()=>{av(e)}}),t}var gv=Rn("plugin.readBlockAutosave"),m_=H("blockDocuments.provided"),sl=H("plugin.earlyWindow");function vv(e){return e.getOrCreateInstance(sl,()=>({depth:0}))}function bv(e){const t=vv(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function al(e){return(e?.getInstance(sl)?.depth??0)>0}function ll(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,i,s)=>{const a=e(o,i,s);if(r&&al(t)){const l=n;queueMicrotask(()=>{o.call(s,l)})}return a}}var Jn=100,yv=class extends ue{_container;_events;constructor(e){super(),this._container=e;const t=mv(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:i}=qt(e),s=J(e,j.ON_SHARE_ID),a=J(e,j.ON_SHOW_PREVIEW_ID),l=J(e,j.ON_EMAIL_CLONE_ID),c=J(e,j.ON_BLOCK_OPEN_ID),d=J(e,j.ON_BLOCK_CLOSE_ID),p=J(e,j.ON_BLOCK_CLONE_ID),b=J(e,j.ON_BLOCK_INIT_ID),E=J(e,j.ON_BLOCK_CHANGED_ID),w=J(e,j.ON_CODE_VALIDATE_ID),I=J(e,j.ON_SUBJECT_CHANGED_ID),y=J(e,j.ON_EMAIL_CHANGED_ID),R=J(e,j.ON_PREHEADER_CHANGED_ID),P=J(e,j.ON_SAVEBUTTON_CLICK_ID),N=J(e,j.ON_BLOCK_SAVEBUTTON_CLICK_ID),D=J(e,j.ON_NEXTBUTTON_CLICK_ID),k=J(e,j.ON_SEND_LIVEPREVIEW_ID),_=J(e,j.ON_SEND_TESTEMAIL_ID),S=J(e,Pg),T=J(e,j.ON_CONTENT_CHANGED_ID),m=J(e,Rg),u=J(e,j.ON_PREVIOUSBUTTON_CLICK_ID),f=J(e,j.ON_SEND_EMAIL_MODAL_ID),g=ec(J(e,j.ON_EMAIL_INIT_ID),v=>!v.reset);return{handlePreheaderChanged:U(R),handleSubjectChanged:U(I),handleValidate:U(w),handleReadEmail:U(n.handlerRead,v=>v,v=>v&&mt(v,e)),handleSaveEmail:U(n.onSave,function({prev:v,patch:C,value:x,source:O}){const h=v?be(v,e):void 0;return{prev:h,patch:Pt(h,be(C,e)),value:be(x,e),source:O}},v=>v?mt(v,e):void 0),handleRemoveEmail:U(n.onRemove,({value:v,source:C})=>({value:be(v,e),source:C}),()=>{}),handleReadCommonBlocks:U(S,v=>v.project,v=>v?.map(C=>We(C,e))),handleReadTemplateBlocks:U(m,v=>v,v=>v?.map(C=>We(C,e))),handleReadBlocks:U(t.byForeignKey("project").handleRead,v=>$t(e).requested||String(v),v=>v?.map(C=>We(C,e))),handleReadBlock:U(t.handlerRead,v=>v,v=>v?We(v,e):void 0),handleOpenBlock:U(c,({block:v})=>({block:me(v,e)})),handleCloseBlock:U(d,({block:v,hasUnsavedChanges:C})=>({block:me(v,e),hasUnsavedChanges:C})),handleCloneBlock:U(p,v=>me(v,e)),handleSaveBlock:U(t.onSave,function({prev:v,patch:C,value:x,source:O}){const h=x.global_block===!0&&x.id&&typeof x.html=="string"?{...x,html:ev(x.html,String(x.id))}:x,A=v?me(v,e):void 0;return{prev:A,patch:Pt(A,me(C,e)),value:me(h,e),source:O}},v=>v?We(v,e):void 0),handleRemoveBlock:U(t.onRemove,({value:v,source:C})=>({value:me(v,e),source:C}),()=>{}),handleReadComments:U(r.byForeignKey("post").handleRead,v=>v,v=>v?.map(C=>Or(C,e))),handleSaveComment:U(r.onSave,function({prev:v,patch:C,value:x,source:O}){const h=v?It(v,e):void 0;return{prev:h,patch:Pt(h,It(C,e)),value:It(x,e),source:O}},v=>v?Or(v,e):void 0),handleRemoveComment:U(r.onRemove,({value:v,source:C})=>({value:It(v,e),source:C}),()=>{}),handleReadEmailRevisions:U(o.byForeignKey("parent").handleRead,v=>v,v=>v?.map(C=>ln(C,e))),handleReadEmailAutosave:U(J(e,za),v=>v,v=>v?ln(v,e):null),handleEmailAutosave:U(o.onSave,function({prev:v,patch:C,value:x,source:O}){return{value:kr(x,e),source:O}},v=>v?ln(v,e):void 0),handleRemoveEmailAutoSave:U(o.onRemove,({value:v,source:C})=>({value:kr(v,e),source:C}),()=>{}),handleReadBlockRevisions:U(i.byForeignKey("parent").handleRead,v=>v,v=>v?.map(C=>cn(C))),handleReadBlockAutosave:U(J(e,gv),v=>v,v=>v?cn(v):null),handleBlockAutosave:U(i.onSave,({value:v,source:C})=>({value:Oi(v),source:C}),v=>v?cn(v):void 0),handleRemoveBlockAutoSave:U(i.onRemove,({value:v,source:C})=>({value:Oi(v),source:C}),()=>{}),handleBlockInit:U(b,v=>me(v,e)),handleBlockChanged:U(Nn(E,Jn),v=>me(v,e)),handleEmailChanged:U(Nn(y,Jn),v=>be(v,e)),handleEmailInit:ll(U(g,v=>be(v,e)),e),handlePreviousButtonClick:U(u,v=>be(v,e)),handleNextButtonClick:U(D,v=>be(v,e)),handleSaveButtonClick:U(P,v=>be(v,e)),handleSaveBlockButtonClick:U(N,v=>me(v,e)),handleHtmlChanged:U(Nn(T,Jn)),handleTestEmailSend:U(_,({html:v,...C})=>({...C,code:v,compiled:{html:v,ampHtml:""}})),handleTestEmailModal:U(f,v=>be(v,e)),handleCloneEmail:U(l,v=>be(v,e)),handleShareEmail:U(s),handlePreviewEmail:U(a),handleLivePreviewEmail:U(k)}}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 ct(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Ev=H("DataController"),_v=H("DataEvents");function cl(e){return e.getOrCreateInstance(Ev,()=>{const t=new Xg(e);return e.getInstance(G)?.addDisposable(t),t})}function dl(e){return e.getOrCreateInstance(_v,()=>new yv(e))}var wv=H("plugin.pluginStart");function ul(e){return e.getOrCreateInstance(wv,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(G)?.addDispose(()=>t()),{done:n,finish:t}})}function Sv(e){return ul(e).done}function Iv(e){const t=ul(e);return t.run===void 0&&(t.run=(e.getInstance(Vr)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var Cv=H("plugin.startupShow");function Tv(e){const t=cl(e),n=dl(e),r=e.getInstance(pe),o=e.getInstance(G),i={current:Promise.resolve()};e.inject(Cv,i);let s=!1;const a=r?.watch(c=>{c&&n.setOptions(c),s=(c?.plugins?.length??0)>0,i.current=i.current.catch(()=>{})}),l=r?.select(c=>c?.content).watch(c=>{if(c===void 0)return;const d=()=>(ne(ce.showStart),t.show(c).finally(()=>ne(ce.showEnd))),p=s?Sv(e).then(d):d();p.catch(()=>{}),i.current=p});a&&o?.addDisposable(a),l&&o?.addDisposable(l)}function Av(e){const t=cl(e);return{...dl(e).get(),show(n){return ne(ce.showStart),t.show(n).finally(()=>ne(ce.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return ne(ce.showStart),t.showBlock(n,r).finally(()=>ne(ce.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function fl(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function xn(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let i=t;i<e.length;i++){const s=e[i];if(o){o=!1;continue}if(s==="\\"){o=!0;continue}if(r){s===r&&(r="");continue}if(s==='"'||s==="'"){r=s;continue}if(s==="("){n++;continue}if(s===")"&&(n--,n<0))return!1}return n===0}function Rv(e){return(t,n,r)=>xn(t)?e(t,n,r):!1}function Pv(e){return t=>xn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Dv(e){return(t,n,r)=>xn(t)?fl(t)?e(t,n,r):t:!1}function Ov(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return xn(n)?fl(n)?e(t):t:!1}}function kv(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function Io(e,t){const n=e.length;for(let r=0;r<n;r++){const o=e.charCodeAt(r);if(o===0||t==='"'&&o===34||t==="'"&&o===39||t===""&&(o===32||o===9||o===10||o===13||o===12||o===34||o===39||o===60||o===62||o===61||o===96))return!1}return!0}function xv(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let i=0;i<e;i++){const s=r[i]%62;o+=t.charAt(s)}return o}var Mv=8,Lv=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=xv(Mv),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Mn=new Lv;function Li(e,t){return t!==void 0&&!Io(e,t)?`%|{${Mn.getOrCreateByKey(e)}}|%`:e}function Nv(e){const t=Mn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function ie(e,t,n){return t!==void 0?Io(e,t)?e:`%|{${Mn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function Fv(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function re(e){return e.startsWith("<!--")&&e.endsWith("-->")?Fv(e.slice(4,-3)):e}function Bv(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const o=e.match(/\[%\s*([^%]*?)\s*%\]/);o&&(r=o[1]);const i=r.trim();return t.test(i)||n.test(i)}function jv(e,t,n){return t!==void 0?Io(e,t)?e:`%|{${Mn.getOrCreateByKey(e)}}|%`:n||kv(e)||Bv(e)?`<!--${e}-->`:e}var qe=Rv(ie),Ge=Pv(re),Uv=Dv(ie),Hv=Ov(re),pl=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",Nv),e.escape("@{","}",ie,!0).unescape("<!--@{","}-->",re,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Li,!0),e.escape("{{","}}",Li,!0),e.createSyntax("brace-percent").escape("{%","%}",ie).unescape("<!--{%","%}-->",re),e.createSyntax("brace-hash").escape("{#","#}",ie).unescape("<!--{#","#}-->",re),e.createSyntax("proscript").escape("[%","%]",jv,!0).unescape("<!--[%","%]-->",re,!0),e.createSyntax("getresponse").escape("[[IF","]]",ie).escape("[[if","]]",ie).escape("[[ELSE]]","",ie).escape("[[else]]","",ie).escape("[[ENDIF]]","",ie).escape("[[endif]]","",ie).unescape("<!--[[IF","]]-->",re).unescape("<!--[[if","]]-->",re).unescape("<!--[[ELSE]]","-->",re).unescape("<!--[[else]]","-->",re).unescape("<!--[[ENDIF]]","-->",re).unescape("<!--[[endif]]","-->",re),e.createSyntax("expert-sender").escape("<if",">",ie).escape("</if",">",ie).escape("<else",">",ie).escape("</else",">",ie).escape("<var ",">",ie,!0).unescape("<!--<if ",">-->",re).unescape("<!--</if",">-->",re).unescape("<!--<else ",">-->",re).unescape("<!--</else",">-->",re).unescape("<!--<var",">-->",re,!0),e.createSyntax("velocity").escape("#if",")",qe).escape("#elseif",")",qe).escape("#else","",ie).escape("#foreach",")",qe).escape("#macro",")",qe).escape("#set",")",Uv,!0).escape("#parse",")",qe).escape("#include",")",qe).escape("#evaluate",")",qe).escape("#end","",ie).escape("#break","",ie).escape("#stop","",ie).unescape("<!--#macro","-->",Ge).unescape("<!--#if","-->",Ge).unescape("<!--#elseif","-->",Ge).unescape("<!--#else","-->",re).unescape("<!--#foreach","-->",Ge).unescape("<!--#parse","-->",Ge).unescape("<!--#include","-->",Ge).unescape("<!--#evaluate","-->",Ge).unescape("<!--#end","-->",re).unescape("<!--#break","-->",re).unescape("<!--#stop","-->",re).unescape("<!--#set","-->",Hv,!0),e.createSyntax("mailchimp").escape("*|","|*",ie).unescape("<!--*|","|*-->",re)},Mr="bare",$v=new Map;function qv(e){return e?$v.get(e)??Mr:Mr}var hl=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function Ni(e){return hl.includes(e)}function yt(e){return e==="bare"||e==="html-comment"}function Qn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Gv(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!yt(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[c,d]of[["output",r.output],["editor",r.editor]])if(d!==void 0&&!yt(d))return t(`templateDirectives.${c}: unknown form "${String(d)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!Qn(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[c,d]of Object.entries(r.syntaxes))if(!(!Ni(c)||d===void 0||yt(d))){if(!Qn(d))return t(`templateDirectives.syntaxes.${c}: expected a form or an object, configuration ignored.`),n;for(const p of["output","editor"]){const b=d[p];if(b!==void 0&&!yt(b))return t(`templateDirectives.syntaxes.${c}.${p}: unknown form "${String(b)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??Mr;let i=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),i=void 0);const s=[];if(r.syntaxes)for(const c of Object.keys(r.syntaxes)){if(!Ni(c)){t(`templateDirectives.syntaxes: unknown syntax id "${c}", entry ignored.`);continue}s.push(c)}else s.push(...hl);const a={},l={};for(const c of s){const d=r.syntaxes?.[c],p=Qn(d)?d:void 0,b=(yt(d)?d:p?.output)??o;let E=p?.editor??i??b;b==="bare"&&E==="html-comment"&&(t(`templateDirectives.syntaxes.${c}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),E="bare"),a[c]=b,l[c]=E}return{output:a,editor:l}}function ml(e,t,n,r){for(let o=t;o<n;o++){const i=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?i===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(i)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):i==="<"?r.insideTag=!0:i===">"?r.insideTag=!1:r.insideTag&&(i==='"'||i==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=i,r.unquotedAttr=!1):r.insideTag&&/\S/.test(i)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(i)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function Ct(e,t){return e.start<t.end&&t.start<e.end}function Fi(e,t,n,r,o=[]){if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return[];const i=t.flatMap(d=>d.match(e).flatMap(p=>!Number.isInteger(p.start)||!Number.isInteger(p.end)||p.start<0||p.end>e.length||p.start>=p.end?[]:[{range:p,mapFn:d.mapFn,overrideBuiltins:d.overrideBuiltins,syntax:d.syntax,isVariable:d.isVariable}])).sort((d,p)=>d.range.start-p.range.start||d.range.end-p.range.end),s=[],a=o.slice().sort((d,p)=>d.start-p.start),l={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(const{range:d,mapFn:p,overrideBuiltins:b,syntax:E,isVariable:w}of i){if(r?(l.insideAttributeValue=!0,l.attributeQuoteChar='"'):ml(e,c,d.start,l),c=d.end,a.some(P=>Ct(P,d)))continue;const I=l.insideAttributeValue?l.attributeQuoteChar??"":void 0,y=e.substring(d.start,d.end),R=p(y,I,l.insideTag);R!==!1&&R!==y&&(s.push({range:d,text:R,overrideBuiltins:b,syntax:E,isVariable:w}),a.push(d))}return s.sort((d,p)=>d.range.start-p.range.start||d.range.end-p.range.end)}function Vv(e,t){const n=t.reduce((a,{mapFn:l,start:c,end:d,syntax:p,isVariable:b})=>(a[c]||(a[c]=[]),a[c].push({value:d,mapFn:l,syntax:p,isVariable:b}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),i=[];let s;for(;(s=o.exec(e))!==null;){const a=s[0];i.push({start:s.index,startToken:a,endTokens:n[a]})}return i}function Zn(e,t,n,r,o=!1){const i=[];if(n&&(t=t.filter(c=>c.isVariable)),!t.length)return i;const s=Vv(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(let c=0;c<s.length;c++){const{start:d,startToken:p,endTokens:b}=s[c];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):ml(e,l,d,a),l=d;const E=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let w=!1;for(const{mapFn:I,value:y,syntax:R,isVariable:P}of b){let N=d+p.length,D=e.indexOf(y,N);for(;D!==-1;){let k=D,_=d+p.length,S=0;for(;k!==-1;){const g=e.indexOf(p,_);if(g!==-1&&g<k)S++,_=g+p.length,k=e.indexOf(y,_);else if(S>0)S--,_=k+y.length,k=e.indexOf(y,_);else break}if(k<0)break;const T=k+y.length,m=e.substring(d,T),u=I(m,E,a.insideTag);if(u===!1){N=D+Math.max(y.length,1),D=e.indexOf(y,N);continue}(o||u!==m)&&i.push({range:{start:d,end:T},text:o?m:u,syntax:R,isVariable:P});const f=s.findIndex(({start:g})=>g>=T);f>c?c=f-1:c=s.length,w=!0;break}if(w)break}}return i}function nn(e,t){if(!t.length)return e;const n=t.slice().sort((o,i)=>i.range.start-o.range.start);let r=e;for(const{text:o,range:i}of n)r=r.slice(0,i.start)+o+r.slice(i.end);return r}var zv=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=pl){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,i,s){return t.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this},unescape(r,o,i,s){return n.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let o=!1;const i={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(s=>s!==n),this._unescapeMatchers=this._unescapeMatchers.filter(s=>s!==r))}};return this.addDisposable(i),i}_collectMappings(e,t,n){const r=Zn(e,this._escapes,t,n),o=Fi(e,this._escapeMatchers,t,n),i=o.filter(l=>l.overrideBuiltins).map(l=>l.range),s=r.filter(l=>!i.some(c=>Ct(c,l.range))),a=o.filter(l=>l.overrideBuiltins||!s.some(c=>Ct(l.range,c.range)));return[...s,...a].sort((l,c)=>l.range.start-c.range.start||l.range.end-c.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=Zn(e,this._unescapes,t),r=Fi(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),i=n.filter(a=>!o.some(l=>Ct(l,a.range))),s=r.filter(a=>a.overrideBuiltins||!i.some(l=>Ct(a.range,l.range)));return[...i,...s].sort((a,l)=>a.range.start-l.range.start||a.range.end-l.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>qv(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return Zn(e,this._escapes,t,n,!0)}getEscapedText(e,t){return nn(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return nn(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=i=>i===void 0?void 0:t[i],r=Object.values(t);let o=e;return r.includes("bare")&&(o=nn(o,this._collectRevertMappings(o).filter(i=>n(i.syntax)==="bare"))),r.includes("html-comment")&&(o=nn(o,this._collectMappings(o).filter(i=>!i.isVariable&&n(i.syntax)==="html-comment"&&i.text.startsWith("<!--")&&i.text.endsWith("-->")))),o}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}};function Bi(e){return e.replace("<script","<___script").replace("<\/script>","</___script>")}var ji=new zv(e=>{e.escape("<script","<\/script>",t=>Bi(t)).unescape("<___script","</___script>",t=>t.replace("<___script","<script").replace("</___script>","<\/script>")),e.escape("<script","/>",t=>Bi(t)).unescape("<___script","/>",t=>t.replace("<___script","<script")),pl(e)});function Wv(e){const t=Gv(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return _a();const n=new Set(Object.keys(t.output).filter(o=>t.output[o]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:o=>ji.normalizeToPolicy(o,t.editor),toOutputForm:o=>ji.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:Ea(r)}}function Kv(e){let t;e.injectFactory($r,()=>{const n=e.getInstance(fe)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:Wv(n)}),t.policy})}var Yv=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function Xv(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const o=t.get(r)??[];o.push(n),t.set(r,o)}return t}function Jv(e,t){const n=[];for(const r of e.awaits?.services??[])for(const o of t.get(r)??[])o!==e&&n.push(o);return n}function gl(e){const t=Xv(e),n=[],r=new Set,o=[],i=new Set,s=a=>{if(!r.has(a)){if(i.has(a)){const l=o.indexOf(a);throw new Yv([...o.slice(l),a].map(c=>c.name))}i.add(a),o.push(a);for(const l of Jv(a,t))s(l);o.pop(),i.delete(a),r.add(a),n.push(a)}};for(const a of e)s(a);return n}var Qv=[{name:"rest.client",setup:Ig},{name:"auth.oauth",setup:uc},{name:"rest.identityHeaders",setup:pg},{name:"rest.localeHeader",setup:yg},{name:"lifetime.destroyable",provides:[yo],setup:hm},{name:"appInit",provides:[Be,Zr],setup:id},{name:"config",provides:[fe],setup:fm},{name:"templateDirectives",provides:[$r],setup:Kv},{name:"email.documents",setup:xm},{name:"show.initPipeline",provides:[Pe],setup:Cg},{name:"show",setup:Tv},{name:"locale.service",provides:[ht],setup:cg},{name:"locale.fromConfig",awaits:{services:[fe,ht]},setup:dg},{name:"canvas.early",setup:sh},{name:"canvas.previewSettings",setup:wh},{name:"canvas.sandboxExtensions",setup:Ih},{name:"canvas.sandboxScriptRelay",setup:Ah},{name:"canvas.headerSync",provides:[go],setup:ch},{name:"canvas.headersAfterRecovery",setup:dh},{name:"canvas.ampSync",setup:uf},{name:"canvas.moduleBridge",setup:$f},{name:"canvas.port",setup:_f},{name:"canvas.images",setup:yf},{name:"canvas.edits",setup:oh},{name:"canvas.surfaceFollowsSession",setup:Qp},{name:"canvas.blockContent",setup:Jp},{name:"canvas.sandboxFill",provides:[mo],setup:Vh},{name:"canvas.reactions",setup:ih}],Ui;function Co(e){const t=e.getInstance(pe);if(t)return t;e.getInstance(G)||e.inject(G,new ue);const n=ge();e.inject(pe,n),Ui??=gl(Qv);for(const r of Ui)r.setup(e);return n}function Zv(e){}var eb=[{name:"save.previewFollow",setup:Zv}],Hi=H("plugin.lateUnitsInstalled");function tb(e){if(!e.getInstance(Hi)){e.inject(Hi,!0);for(const t of gl(eb))t.setup(e)}}function nb(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function rb(e){if(!e)return;const t=Xr(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 ob=gt(e=>{let t,n,r;return{async setOptions(o){const i=r!==o.getAuthToken,s=!Re(t,o.user),a=n!==o.project;if(r=o.getAuthToken,t=o.user,n=o.project,!(!e.getInstance(De)||!o.getAuthToken)&&!(!i&&!s&&!a))try{const l=await o.getAuthToken(o.user,o.project);e.inject(hc,Promise.resolve(l||""));const c=rb(l);if(!c)return;e.inject(cc,c);const d=e.getInstance(Be),p=d?await d.catch(()=>{}):void 0;e.inject(Be,Promise.resolve(nb(c,p)))}catch{}}}});function ib(e,t){if(e.getInstance(Lo))return;e.inject(Lo,!0);const n=ye(e,j.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var sb=gt(e=>{let t,n=!1;return{setOptions(r){const o=n;if(n=!0,!Ut(r)){t&&(Zh(e),bo(r)),t=void 0;return}const i=Dn(r);if(!i||t===i&&e.getInstance(De))return;t=i,e.inject(De,i);const s=e.getInstance(G);s&&ib(e,s)}}}),ab=gt(e=>{const t=e.getInstance(G),n=ye(e,gs),r=U(n),o=t.addDisposable(new ct(r));return{setOptions({handleLoad:i}){o.setListener(i)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function vl(e,t,n=!0){const r=e,o=t;for(const i of Object.keys(o)){const s=o[i];s!=null&&(n&&typeof s=="object"?r[i]=vl(r[i]||{},s,!0):r[i]=s)}return e}async function lb(e){const t=(await Dc(()=>import("./static/esm/2490dab8.js").then(n=>Hl(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 bl=H("EditorOptions"),Lr=Ec;function cb(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 db(e){return e.getOrCreateInstance(bl,()=>{const t=ge(Lr);let n=Lr.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(lb(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function ub(e){return e?.getInstance(bl)?.get()??Lr}function fb(e,t={}){const n=db(e);n.set(vl({...n.get()},cb(t)))}function pb(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 hb(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var mb=H("plugin.publicConfig");function Nr(e){return e.getInstance(fe)?.get()??{}}function $i(e){return e.getInstance(fe)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function qi(e){const t=Fa(e),n=Nr(e);return{...n,locale:n.locale||"en_US",theme:n.theme||"light",editor:hb(ub(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Gi(e){return e.getInstance(fe)?.get()!==void 0}function gb(e){const t=ms(),n=ae(e,hs);let r,o,i=!1;const s=async()=>{try{return e.getInstance(Be)===void 0?{}:(await e.getInstanceAsync(Be))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:p=!1}={})=>{await e.getInstance(fe)?.ready(),Ss(e).set(Nr(e).revisionService===!0);const{codeModeDirection:b,editor:E}=Nr(e);E&&fb(e,pb(E)),b!==void 0&&!(p&&b===o)&&(o=b,b==="none"?Ir(e,!1):(Ir(e,!0),vh(e,b)))},l=async()=>{if(!Gi(e))return;const p=qi(e),b=JSON.stringify(p);b!==r&&(r=b,await n.fire(p))},c=async p=>{const b=e.getInstance(fe),E={advancedConfigs:$i(e).advancedConfigs,serverSide:await s(),user:p};b?.setAdvancedConfigs({...E.advancedConfigs,...E.user?.advancedConfigs});const w=b?.layers().user.mode;b?.replace(E.user?.mode===void 0&&w!==void 0?{...E.user,mode:w}:E.user,"user"),b?.replace(E.serverSide,"server"),await a(),await l()},d=p=>{const{commonStyles:b,...E}=p;return"commonStyles"in p&&yh(e,b===void 0?void 0:b),E};return{queue:t,reactToConfig:a,emitConfigChanged:l,resolveServerSideConfig:s,getConfig:()=>Gi(e)?qi(e):{},setConfig:t.decorate(async p=>{await c(d(p))}),updateConfig:t.decorate(async p=>{const b=d(p);await c({...$i(e).user,...b})}),announceAssembled(){i||(i=!0,e.getInstance(fe)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await l()})))}}}function yl(e){return e.getOrCreateInstance(mb,()=>gb(e))}function vb(e){const t=yl(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var bb=gt(e=>{const t=e.getInstance(G),n=t.addDisposable(new Fe),r=t.addDisposable(new Fe),o=Ft(e,hs),i=U(n.event),s=U(r.event),a=ll(U(o.event),e),l=t.addDisposable(new ct(i)),c=t.addDisposable(new ct(s)),d=t.addDisposable(new ct(a));return{instance:{handleSetOptions:i,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(p){l.setListener(p.handleSetOptions),c.setListener(p.handleOptionsChanged),d.setListener(p.handleConfigChanged),yl(e).announceAssembled(),await n.fire(p),await r.fire(p)},dispose(){}}}),er,El="core";function yb(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([El],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Eb(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Gt().then(()=>{}):t([El],e)}function Gt(){return er===void 0&&(er=yb().then(e=>(Ot()&&e.installDiagnostics().catch(t=>{}),e))),er}var tr=null,nr=null;async function _b(e){typeof e?.prefetch=="function"&&await e.prefetch()}function To(){return tr||(tr=Gt().then(()=>{})),tr}function _l(e){return nr||(nr=_b(e)),nr}function wb(){return _l(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function Sb(){const e=typeof window.__useblocks__<"u"?window.__useblocks__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function Ib(e){return Promise.all([To(),_l(e)]).then(()=>{})}function Cb(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Vi(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Eb(t?{priority:t}:void 0)).then(()=>(fo(t?{priority:t}:void 0),n?To():void 0)).catch(()=>{})}function Tb(e){const t=Cb(e);if(t==="eager")Vi(e);else if(t==="idle"){const n=()=>Vi(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var wl="PluginRegistry";function Ab(e=oc()){return e.getOrCreateInstance(wl,()=>new Bc)}var Rb=new jc(()=>Ab()),Pb=["handleAIImageRequest","handleAITextRequest","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],Db=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],yn=new Map([...Pb.map(e=>[e,"event"]),...Db.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),Ob=new Map([["use","use `useAsync()` or await `ready` first"]]);function kb(e){return Ob.get(e)??"await `ready` first"}var xb=new Set(["async","queued"]),Mb=Symbol.for("emailmaker.earlyCtxPlaceholder");function zi(e){return e[Mb]=!0,e}function Lb(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 (${kb(e)}).`)}function Nb(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function Fb(e){return[...yn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function Bb(e,t){for(const n of Fb(e)){const r=yn.get(n);if(r!==void 0&&xb.has(r)){const o=async(...i)=>{await t;const s=e[n];if(typeof s!="function"||s===o)throw Nb(n);return s.apply(e,i)};e[n]=zi(o);continue}e[n]=zi(()=>{throw Lb(n)})}}function jb(e,t,n){e.getInstanceAsync(dt).then(()=>{Ft(e,j.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function Ub(e,t){e.getInstanceAsync(dt).then(()=>{Ft(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 Hb=gt(e=>{let t;function n(){return new Promise(o=>{const i=e.getOrCreateInstance(Kr,()=>new Set),s=()=>{i.delete(s),o()};i.add(s)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const i=e.getInstance(In),s=e.getInstance(wl);if(!t){t=new Fc(i,s,{ensureHostRuntimeReady:wb,explainScriptFailure:Sb,openEarlyWindow:()=>bv(e),reportLoadFailure:c=>Ub(e,c)}),e.inject(Vr,t);const l=t.onLifecycle(c=>{c.type==="create:error"&&jb(e,c.name,c.error)});e.getInstance(G)?.addDisposable(l)}const a=o?.plugins||[];i&&(ra(e),a.length>0&&Bb(i,n()),await t.setPlugins(a))},instance:{use(o){return typeof o=="function"?r().useByCtor(o):r().useByKey(o)},useAsync(o){return r().useAsync(o)},waitPlugin(o){return r().waitFor(o)}},dispose(){t?.dispose(),t=void 0}}}),Sl=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const o=this._listeners.indexOf(r);o>=0&&this._listeners.splice(o,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},$b=H("ELEMENT_INSERT_HTML_PIPELINE"),qb=H("BLOCK_INSERT_HTML_PIPELINE"),Gb="application_block_inserted",Vb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(qb,()=>new Sl).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(jt,()=>new Bt),o=n?e.bind(n):e;return r.addListener(Gb,o,t)}},Ao=H("ComponentRegistry"),zb=H("ComponentRegistryGate");function Ro(){return ut.getOrCreateInstance(zb,()=>({pending:[]}))}function Wb(e=Ao){return Ro().factory!==void 0||ut.getInstance(e)!==void 0}function Fr(e,t,n=Ao){if(Wb(n)){t(En(e,n));return}Ro().pending.push(()=>t(En(e,n)))}function En(e,t=Ao){const n=ut.getInstance(t);if(n)return n;const r=Ro().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return ut.getOrCreateInstance(t,r)}var Kb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=i=>{if(!n){n=!0;for(const s of t)s.dispose();e(i)}};t.push(this._container.addService(Vt,{execute:i=>{r(i.value.map(s=>({name:s.name,html:s.html})))}}));const o=this._container.getInstance(Ql)?.watch(i=>{i&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService(Vt,{execute:r=>{const o=En(n),i=r.value.find(s=>s.name===e);if(i){const{icon:s,title:a,fallbackTooltip:l,...c}=t;s&&(i.icon=o.getReactNode(s)),a&&(i.title=o.getReactNode(a)),l&&(i.fallbackTooltip=o.getReactNode(l)),Object.assign(i,c)}}})}delete(e){this._container.addService(Vt,{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(Vt,{execute:r=>{const o=En(n);r.value.splice(t??r.value.length,0,{...e,title:o.getReactNode(e.title),icon:o.getReactNode(e.icon),fallbackTooltip:o.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance($b,()=>new Sl).add(e,t??0,n)}handleInject(e,t,n){return lt(this._container,Yl).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Yb=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(jt,()=>new Bt)}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 Xb(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Wi(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 Jb=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=lt(t,ac),this._closeModalEmitter=lt(t,Jl),this._updateModalEmitter=lt(t,sc)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Fr(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Wi(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Fr(this._container,r=>{this._updateModalEmitter.fire(Xb({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:Wi(r,n)}))})}};function rn(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var Qb=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=o=>{this._loadedSettled||(this._loadedSettled=!0,r(o))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=o=>{this._readySettled||(this._readySettled=!0,r(o))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},Zb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(jt,()=>new Bt)}_createScriptHandle(e,t){const n=this._messageService.addListener(Gr,o=>{if(o.key===e){if(o.phase==="load"&&o.status==="success"){r.resolveLoaded();return}if(o.phase==="ready"&&o.status==="success"){r.resolveReady();return}if(o.phase==="load"){r.rejectLoad(new Error(o.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(o.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new Qb(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(ot,{...rn(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(ot,{...rn(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(ot,{...rn(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(ot,{...rn(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},ey=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function Br(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&ey.has(t)}function Il(){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 rr(){return`__settingsPanel:${Il()}`}function or(e,t){return{type:e,props:t}}function ty(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!Br(e)}function Ki(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(Br(t)){const r=rr();return n(e.add(r,t)),or(r,{})}if(typeof t=="function"){const r=rr();return n(e.add(r,t)),or(r,{})}if(ty(t)){const r=t.type;if(typeof r=="string")return t;if(Br(r)||typeof r=="function"){const o=rr();return n(e.add(o,r)),or(o,t.props)}return t}return t}var ny=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??Il();Fr(this._container,n=>{const r=s=>this._trackRegistration(s),o=Ki(n,e.content,r),i=e.advancedTabs?.map(s=>({...s,content:Ki(n,s.content,r)}));lt(this._container,xo).fire({...e,content:o,advancedTabs:i,instanceKey:t,type:ic})})}closeSettingsPanel(){this._clearPanelRegistrations(),lt(this._container,xo).fire(null)}},Cl={SandboxScriptApi:Zb,ElementsApi:Kb,BlocksApi:Vb,MessageService:Yb,SettingsPanelApi:ny,ModalApi:Jb};function ir(e,t,n,r={}){const o=Object.assign({},e);for(const[i,s]of Object.entries(t))if(s!==void 0)if(n.includes(i)&&typeof s=="object"&&s!==null){const a=o[i],l=r[i]??{};o[i]=Object.assign({},typeof a=="object"&&a!==null?a:l,s)}else o[i]=s;return o}var we={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}},ry={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"},sr={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},Yi={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},tt={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:we.border,borderRadius:we.borderRadius,textAlign:"center",padding:we.padding},Xi={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:we.padding},ar={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:we.border,borderRadius:we.borderRadiusCards};function oy(e){return{...ry,...e}}function iy(e){return{...sr,...e,bold:e?.bold??sr.bold,italic:e?.italic??sr.italic}}function sy(e){return{...Yi,...e,underline:e?.underline??Yi.underline}}function ay(e){return{...tt,...e,bold:e?.bold??tt.bold,italic:e?.italic??tt.italic,border:{...tt.border,...e?.border},borderRadius:{...tt.borderRadius,...e?.borderRadius},padding:{...tt.padding,...e?.padding}}}function ly(e){return{...Xi,...e,padding:{...Xi.padding,...e?.padding}}}function cy(e){return{...ar,...e,border:{...ar.border,...e?.border},borderRadius:{...ar.borderRadius,...e?.borderRadius}}}function lr(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 Ji(e){let t={...Yr};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function cr(e){return{text:oy(e.text),headings:iy(e.headings),links:sy(e.links),buttons:ay(e.buttons),block:ly(e.block),cards:cy(e.cards)}}var Qi=H("EmailSettingsPort"),dy=1e4,Tl=class{_editor;_layoutSettingsChanged=new pr;_contentStylesChanged=new pr;_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(!al(this._editor.container)||!it(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(Qi);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return lr(this._settings().read())}_getCurrentContentStyles(){const e=it(this._editor.container)?.current()?.get().attributes.common_styles;return cr(Ji(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(Qi),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(jt,()=>new Bt),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const o=r?.data,i=o?.operation;if(i===z.APPLICATION_EMAIL_SETTINGS_SET){const l=lr(o?.settings),c=this._getLayoutSnapshot(l);c!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=c,this._layoutSettingsChanged.fire(l));return}if(i!==z.APPLICATION_COMMON_STYLES_UPDATE)return;const s=cr(r.data?.settings?.commonStyles??{...Yr}),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=lr(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=dy){const t=it(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,o=ye(r,j.ON_EMAIL_INIT_ID);return new Promise(i=>{let s=!1,a;const l=()=>{a&&(clearTimeout(a),a=void 0)},c=o(()=>{s||(s=!0,l(),c.dispose(),i())});a=setTimeout(()=>{s||(s=!0,c.dispose(),i())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=it(this._editor.container)?.current();if(!t)return;const n=Ji(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=ir(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:we.border,borderRadius:we.borderRadius,padding:we.padding})),e.block!==void 0&&(n.block=ir(n.block||{},e.block,["padding"],{padding:we.padding})),e.cards!==void 0&&(n.cards=ir(n.cards||{},e.cards,["border","borderRadius"],{border:we.border,borderRadius:we.borderRadiusCards}));const r=JSON.stringify(n);ft(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=cr(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},uy={...Cl,EmailSettingsApi:Tl},fy={...Cl},g_={...fy,EmailSettingsApi:Tl},py={...uy};function hy(){Rb.addAll(py)}var my=[gt(()=>{hy()}),ab,bb,sb,mc,ob,Ic];async function gy(){return(await Gt()).asyncMixins}var vy=Hb,by=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let o;try{o=await gy()}catch(s){throw e.failPendingWaits(s),s}t=o(e);const i=await e.getInstanceAsync(In);Object.assign(i,t.instance||{});for(const s of e.getInstance(Kr)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},yy=Sc([...my]);function dr(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const i of r.values())i();r.clear()}return{event(i,s,a){const l=Symbol("subscription");return t||(n.set(l,{listener:i,priority:s,thisArg:a}),e&&r.set(l,e(i,s,a))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(i){o(),e=i;for(const[s,{listener:a,priority:l,thisArg:c}]of n)r.set(s,i(a,l,c))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function Ey(e){const t=dr(),n=dr(),r=dr();return e.getInstance(G)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(dt).then(o=>{t.attach(o.onNotify),n.attach(o.onError),r.attach(o.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(o){const i=e.getInstance(dt);if(i){i.notify(o);return}e.getInstanceAsync(dt).then(s=>s.notify(o),()=>{})}}}var Al=H("CodeErrors"),_y=[];function wy(e){return e?.getInstance(Al)?.get()??_y}function Sy(e){return e?.getInstance(Al)!==void 0}var Iy=class extends ue{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=qt(e),this.addDisposable(ye(e,j.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){const e=Xe(this._container);if(e&&te(e.sessionKey())&&!e.hasSuspended())throw new Error("[useblocks] no open email: only a block is shown");return nl(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=>me(t,this._container))}async _readProjectBlocks(){const e=await rl(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=>It(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=>kr(n,this._container))}async getEmailSnapshot(){return be(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Xe(this._container),t=e?.current();return!e||!t||!te(e.sessionKey())?null:(await t.whenReady(),me(Pn(t),this._container))}setEmailMeta(e){const t=So(this._container);if(!t)return;const n=t.get().attributes.meta;ft(t,{meta:Zt({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&Zt(o,e))}setBlockMeta(e,t){const n=Xe(this._container);if(n?.sessionKey()===fn(e)){const o=n.current();o&&ft(o,{meta:Zt({meta:o.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,i=>i&&Zt(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return Sy(this._container)?wy(this._container):void 0}},Cy=H("EmailDataController");function Ty(e){return e.getOrCreateInstance(Cy,()=>{const t=new Iy(e);return e.getInstance(G)?.addDisposable(t),t})}function Ay(e){const t=Ty(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function Ry(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 Py(e){let t;const n=qa(e),r=ye(e,j.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:i})=>{t=i}));const o=()=>t?Ry(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:i=>o()?.getPast(i)??[],getFuture:i=>o()?.getFuture(i)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:i=>o()?.restoreSnapshot(i)}}}var Dy=H("plugin.mountElement");function Oy(e){const t=e.getInstance(pe)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function ky(e){return e.getOrCreateInstance(Dy,()=>{let t=!1,n;return{get:()=>t?n:Oy(e),set(r){t=!0,n=r}}})}function xy(e){const t=ky(e);return{getElement:()=>t.get()}}function My(e){return{handleLoadImage:U(ye(e,j.UPLOAD_EVENT_ID)),handleFileProxy:U(ye(e,j.FILE_PROXY_EVENT_ID)),handleUrlProxy:U(ye(e,j.PROXY_URL_EVENT_ID)),handleAITextRequest:U(ye(e,j.AI_TEXT_REQUEST_ID)),handleAIImageRequest:U(ye(e,j.AI_IMAGE_REQUEST_ID)),handleReadLocale:U(ye(e,j.READ_LOCALE)),handleLimitUsage:U(ye(e,j.ON_LIMIT_ID)),handleTranslate:U(ye(e,j.ON_TRANSLATE_ID))}}var Ly=[mm,Av,Ey,vb,Ay,Py,xy,My];function Ny(e,t=Ly){const n=Co(e);tb(e);const r=yy(e),o=vy(e),i=by(e),s={...r.instance,...o.instance,...i.instance};for(const l of t)Object.assign(s,l(e));let a=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const c=a&&n.get()===l;a=!1,c||n.set(l),await o.setOptions(l),await i.setOptions(l)}}}function Fy(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 By=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]}},jy="editor-runtime.react.copies",ur=8;function xt(e){return e&&typeof e=="object"?e:void 0}function Zi(e){const t=xt(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=xt(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function Uy(e){const t=xt(e),n=t&&typeof t.version=="string"?t.version:void 0,r=xt(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function Hy(e,t,n){return e.package===t&&e.version===n}function $y({ourReact:e,entries:t,packageName:n,version:r}){const o=Zi(e);if(!o||!Array.isArray(t))return[];const i=[],s=new Set;for(const a of t){const l=xt(a);if(!l||!Hy(l,n,r))continue;const c=Zi(l.react);!c||c===o||s.has(c)||(s.add(c),i.push({package:n,version:r,reactVersion:Uy(l.react),react:l.react}))}return i}function qy({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,ur))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>ur&&n.push(` …and ${t.length-ur} 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 es=new Set;function Gy({packageName:e="useblocks",version:t="1.1.108",log:n=r=>{}}={}){const r=o=>{try{const i=globalThis[Symbol.for(jy)],s=$y({ourReact:o,entries:i,packageName:e,version:t}).filter(a=>!es.has(a.react));if(!s.length)return;s.forEach(a=>es.add(a.react)),n(qy({packageName:e,copies:s}))}catch{}};try{const o=Qr()?.modules?.React;if(o&&typeof o.then=="function"){o.then(r,()=>{});return}r(o)}catch{}}async function Vy(e,t,n){ee(e.signal);const r=t??ut.createChild();Co(r);const o=r.getInstance(G);let i;async function s(){r.inject(ps,Fy(new By)),Gy();const a=Ny(r),l={...a.instance,container:r,get ready(){return i??Promise.resolve(l)},async reset(c){if(ee(c.signal),o.isDisposed())throw Ne();return await a.setOptions(c),l}};r.inject(In,l);try{if(n?.onInstance?.(l),await a.setOptions(e),ee(e.signal),o.isDisposed()||await Iv(r),e.devTools)try{const c=r.getInstance(Vr);c&&await(await Gt()).initDevTools(r,c)}catch{}return ee(e.signal),Ft(r,gs).fire(l),l}catch(c){throw o.dispose(),c}}try{return i=un(s(),e.signal),i.catch(()=>{}),await i}catch(a){throw o.isDisposed()||o.dispose(),a}}var Mt=new WeakMap;function zy(e){return e?Mt.get(e):void 0}function Rl(e){try{e.getInstance(G)?.dispose()}catch{}try{e.dispose()}catch{}}function Wy(e,t){if(!e)return;const n=Mt.get(e);n&&n!==t&&Rl(n),Mt.set(e,t)}function Ky(e,t){e&&Mt.get(e)===t&&Mt.delete(e)}function Yy(e){const t=ut.createChild();return Ut(e)&&t.inject(De,Dn(e)),t}var Dt=new WeakMap,Xy="data-useblocks-config-styles";function Jy(e){return typeof e=="string"?e.trim():""}function ts(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function Qy(e,t,n){if(!e||typeof document>"u")return null;const r=Jy(t),o=Dt.get(e),i=n||e;if(!r)return o&&(o.remove(),Dt.delete(e)),null;if(o)return o.textContent!==r&&(o.textContent=r),(o.parentNode!==i||o!==i.firstChild)&&ts(i,o),o;const s=document.createElement("style");return s.setAttribute(Xy,"true"),s.textContent=r,ts(i,s),Dt.set(e,s),s}function Zy(e){if(!e)return;const t=Dt.get(e);t&&(t.remove(),Dt.delete(e))}function Pl(){return!1}var eE=`
1047
+ `)}function Pi(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function Bg(e,t,n,r){const o=jg(e,t,n,r);return o===void 0}function jg(e,t,n,r){if(On(t))return"block";const{email:o}=kn(t,!1),i=mt(o,e),s=i.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=Xe(e)?.current();if(!a)return"no-session";const l=a.get(),c=l.attributes;if(l.serverId!==s)return"document-id";if(c.is_inited!==!0)return"not-inited";const d=Pi(Dr(n??a.getContent()));if(i.html!==void 0&&Pi(Dr(i.html))!==d)return"html";if(i.subject!==void 0&&i.subject!==c.subject)return"subject";if(i.preheader!==void 0&&i.preheader!==c.preheader)return"preheader";if(i.common_styles!==void 0&&i.common_styles!==c.common_styles)return"common_styles"}function Di(e,t){if(On(t))return;const{email:n}=kn(t,!1),r=mt(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:Dr(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function Ug(e,t){const n={...e};return delete n.id,{...n,...t}}function Hg(e){return e.html?e:{...e,html:el}}function We({code:e,project:t,...n},r,o){const i=o??Eo(r);return{...n,...e?{html:Ze(r).toEditorForm(e)}:{},renderGuid:Ee(),...i===void 0?{}:{project:i}}}function me({html:e,renderGuid:t,...n},r){const{requested:o}=$t(r);return Oe({...n,code:Ze(r).toOutputForm(e),project:o===void 0?n.project:o,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function ol(e){return Xe(e)?.current()?.get().serverId??void 0}function Or(e,t,n){return n===void 0&&(n=e.post===void 0?ol(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function It(e,t){return Oe({...e,link:void 0,comment_status:void 0})}function ln({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?ol(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||eu(n.slug),parent:o}}function kr({html:e,isAutosave:t,...n},r){return Oe({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:Oe({html:e,ampHtml:e&&""})})}function cn({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function Oi({html:e,isAutosave:t,...n}){return Oe({...n,autosave:t?!0:void 0,code:e,guid:void 0})}var dt=H("NotificationService"),$g=H("emailTemplate.reads");async function qg(e,t){try{return await Je(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,Gg(e,t,n);return}}var Vg=H("emailTemplate.notifiedFailures");function Gg(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(Vg,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(dt).then(()=>{Ft(e,j.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function zg(e,t){const n=e.getOrCreateInstance($g,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=qg(e,t).then(i=>(i===void 0&&n.delete(t),i));return n.set(t,o),o}var Kn="EXTERNAL",ki=Symbol("supersededShow");function Wg(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var Kg="email_id";function Yn(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}async function Yg(e,t){const n=Cn();let r;try{return await Promise.race([e,new Promise((o,i)=>{r=setTimeout(()=>{e.then(t,()=>{}),i(new Tn(n,"handleSaveBlock","block"))},n)})])}finally{clearTimeout(r)}}var Xg=class extends ue{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=ms();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=qt(t),this._eventLock=Mg(t);const n=Y(e,j.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(Y(e,j.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(Sn,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Kg,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Pe)??ho}_throwIfDestroyed(){if(this.isDisposed())throw Ne()}async getTemplateEmail(e){const t=await zg(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 St(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,We(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,ln(o,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(o=>o.id!==void 0).map(o=>[o.id,Or(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const i=this._dataSources.emails,s=i.cache,a=await St(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let c=mt(e,this._container);const d=c.id;let p=d;if(d!==void 0){const v=await i.get(d);c={...v??{},...c,utm_parameters:c.utm_parameters??v?.utm_parameters??{},renderGuid:v?.renderGuid??Ee(),...l>0?{showToken:l}:{},...o?{showId:o}:{},project:a}}else{p=n??Ee();const v=await i.get(p);c={...c,utm_parameters:c.utm_parameters??{},renderGuid:v?.renderGuid??Ee(),...l>0?{showToken:l}:{},...o?{showId:o}:{},project:a},delete c.project}if(t){const v=await this.getTemplateEmail(String(t));v&&(c=Ug(v,c))}return d===void 0&&(c=Hg(c)),await s.setAll([[p,c]]),c}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Di(this._container,e))return!1;const n=an(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Di(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:an(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&Lg({ticket:t,emailId:Ai(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,ki;if(!e)return;const n=this._getInitPipeline();if(ee(n.signal),On(e))return this._showBlock(e,n);const r=te(le(this._container).sessionKey()),o=Ng(e);if(!r&&!o&&Bg(this._container,e,an(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const i=kn(e);i.email.id,this._prevCommand?.id;let s,a="",l=0,c=!1,d,p=Promise.resolve(),v,E=!1;try{this._eventLock.suspendChange();const{email:w,blocks:I,autosaves:b,comments:R,templateId:P,reload:F}=i;s=w.id;const D=mt(w,this._container),k=D.id,_=k??Ee(),S=await ze("getProject",St(this._container));ee(n.signal),a=Ee();const T={isNew:k===void 0,id:String(_),project:S},m=F===!0&&k!==void 0;m&&(await this._dataSources.emails.remove(String(k),{silent:!0}),String(k)),l=++this._showToken,String(_);const u=[];u.push(this.setBlocks(I)),w.id!==void 0&&(u.push(this.setComments(R)),u.push(this.setEmailRevisions(b,String(w.id)))),u.push(this.setEmail(w,Number(P),k===void 0?String(_):void 0,l,a)),await ze("setEmail+blocks+revisions",Promise.all(u),{emailId:k??String(_),showId:a,targetShowToken:l}),ee(n.signal);const f=await this._dataSources.emails.get(String(_)),g=le(this._container),x={id:a,token:l};if(r){sn(this._container);const A=g.suspendedDocument()?.get().serverId;!m&&k!==void 0&&A!=null&&String(A)===String(k)&&g.resumeSuspended()}k===void 0?v=g.startNewDraft(f??D,{patch:D,show:x}):m?v=g.reload(k,{email:f??D,patch:D,show:x}):g.sessionKey()===nt(k)?v=g.show(D,x):v=g.open(k,{email:f??D,patch:D,show:x}),g.beginShowFill(a);const O=!!this._prevCommand&&Re(this._prevCommand,T);T.id,!this._prevCommand||Re(this._prevCommand,T),this._prevCommand?.id,this._rememberShow(T),p=n.requestShow({showId:a,navId:String(_),emailId:k,isNew:k===void 0}),E=!0;const y=()=>g.endShowFill(a);Promise.allSettled([p,v.whenReady()]).then(y),String(_),c=!0}catch(w){d=w,E&&a&&n.failShow(a,w),a&&Xe(this._container)?.endShowFill(a),zr(w)||(ks(w),void 0)}finally{this._eventLock.resumeChange()}if(!c)throw d instanceof Error?d:new Error(`[useblocks] show() setup failed: ${String(d??"unknown error")}`);return ze("show-init-deferred",Promise.all([p,v?.whenReady().catch(w=>{if(w instanceof Ye){const I=ao(w);throw I?new Error(`[useblocks] show(): email open failed (${I})`,{cause:w}):w}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:s??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:i,reload:s}=xg(e),a=Ee();let l=!1;try{await this.setBlocks(o),ee(t.signal),s&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const c=n.id!==void 0&&n.id!==""?String(n.id):void 0,d=le(this._container);if(!s&&c!==void 0&&d.sessionKey()===fn(c)){const P=Yn(n)?await this._storeShownBlock(n):void 0,F={id:a,token:++this._showToken},D=d.show(P,F),k=t.requestShow({showId:a,navId:c,emailId:void 0,isNew:!1});l=!0,await ze("show-block-init",Promise.all([k,D?.whenReady().catch(()=>{})]),{showId:a});return}const p=r||s?await Ti(this._container,String(n.id)):void 0,v=p&&(s||Yn(n))?await this._storeShownBlock({...me(p,this._container),...n}):r||s?p:await this._storeShownBlock(n);if(ee(t.signal),!v)throw new Error(`[useblocks] show(): block ${String(n.id)} not found`);i!==void 0&&v.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(i.filter(P=>P.id!==void 0).map(P=>[P.id,cn(P,String(v.id))])),this._prevCommand=void 0,this._lastShow=void 0;const E=v.id!==void 0?String(v.id):Ee(),w={id:a,token:++this._showToken};sn(this._container);const I=s?d.reloadBlock(E,v,w):d.openBlock(E,v,w);v.id;const b=t.requestShow({showId:a,navId:E,emailId:void 0,isNew:v.id===void 0});l=!0;const R=I.whenReady().catch(P=>{if(P instanceof Ye)throw P});await ze("show-block-init",Promise.all([b,R]),{showId:a})}catch(c){throw l&&t.failShow(a,c),c}}async _storeShownBlock(e){const t=We(e,this._container,await St(this._container));return t.id!==void 0&&await this._dataSources.blocks.cache.add(t.id,t),t}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();ee(e.signal);const t=le(this._container);if(te(t.sessionKey())&&!t.hasSuspended())throw new Error("[useblocks] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:Kn,fallbackTitle:ca(this._container)});if(ee(e.signal),!n)throw Wg(t.emailSaveState().error);return be(nl(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=le(this._container),t=e.current();if(!t||!te(e.sessionKey()))throw new Error("[useblocks] saveBlock(): no open block");return Fg(t,async()=>{await t.whenReady();const n=Pn(t),r=t.get().version,o={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:n.html,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},i=this._dataSources.blocks,s=await Yg(t.get().serverId==null?i.create(o,{source:Kn}):i.update(String(t.get().serverId),o,{source:Kn}),a=>{a&&le(this._container).current()===t&&t.get().serverId==null&&a.id!==void 0&&t.markSaved(r,String(a.id))});if(!s)throw new Error("[useblocks] save(): block was not saved");return t.markSaved(r,s.id!==void 0?String(s.id):void 0),me(s,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=Ai(e);const n=this._queuedShow(e,t).then(r=>r===ki?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};_queuedSave=this._queue.decorate(()=>this._save(),this);save=()=>this._queuedSave();_queuedSaveBlock=this._queue.decorate(()=>this._saveBlock(),this);saveBlock=()=>this._queuedSaveBlock();showBlock=(e,t={})=>this.show({...t,block:e});async _openBlock(e){this._throwIfDestroyed(),ee(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=le(this._container);if(n!==void 0&&r.sessionKey()===fn(n))return;const o=t.code===void 0&&n!==void 0?await Ti(this._container,n):void 0,i=o&&Yn(t)?await this._storeShownBlock({...me(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!i)throw new Error(`[useblocks] openBlock(): block ${String(n)} not found`);sn(this._container);const s=r.openBlockOver(i.id!==void 0?String(i.id):Ee(),i);i.id,r.hasSuspended(),ae(this._container,j.ON_BLOCK_OPEN_ID).fire({block:i}),await s.whenReady().catch(a=>{if(a instanceof Ye)throw r.current()===s&&(ae(this._container,j.ON_BLOCK_CLOSE_ID).fire({block:i,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),Xp(this._container)}_queuedOpenBlock=this._queue.decorate(e=>this._openBlock(e),this);_queuedCloseBlock=this._queue.decorate(()=>this._closeBlock(),this);openBlock=e=>this._queuedOpenBlock(e);closeBlock=()=>this._queuedCloseBlock()};function Jg(e){return String(e).replace(/"/g,"&quot;")}function Qg(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 Zg(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 xi(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),o=Jg(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function ev(e,t,n){if(!e?.trim()||!t)return e;const r=Zg(e);if(!r)return e;const o=String(t),i=Qg(n??new Date);let{full:s,index:a}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=xi(s,"em-block-id",o)),s=xi(s,"em-block-version",i),e.slice(0,a)+s+e.slice(a+l)}function tv(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 nv(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),o=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:o,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:tv(e)}}function Xn(e,t){return t?nv(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var il=["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"],rv=[...il,"html","id","project","password"],h_=new Set(["html",...il,"global_block","project"]);function ov(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(rv),r={};for(const o of Object.keys(e))n.has(o)||(r[o]=e[o]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function iv(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...ov(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 xr=new WeakMap;function sv(e){let t=xr.get(e);return t||(t={byId:new Map,fallback:[]},xr.set(e,t)),t}function av(e){xr.delete(e)}function lv(e,t){const{byId:n,fallback:r}=sv(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const i=r.indexOf(o);return i>=0&&r.splice(i,1),o}return}for(let o=r.length-1;o>=0;o--){const i=r[o],s=e.name!=null&&e.name!==""&&i.name!=null&&i.name!==""&&i.name===e.name,a=e.type!=null&&e.type!==""&&i.insertFrom===e.type;if(s&&a)return r.splice(o,1),i.id!=null&&i.id!==""&&n.delete(String(i.id)),i}}async function cv(e,t){const{blocks:n}=qt(e);return await n.cache.getIfPresent(t)??void 0}async function dv(e,t){if(!t.blockId)return;const n=await cv(e,t.blockId);if(n)return iv(n,t)}async function uv(e,t){const n=lv(e,t);if(n)return Xn(e,n);const r=await dv(t,e);return r?Xn(e,r):Xn(e,void 0)}var fv=vs("application_block_inserted"),pv=-1e3,Mi=new WeakSet;function hv(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 mv(e){if(!e||Mi.has(e))return;Mi.add(e);const t=new ue,n=de(e);return t.addDisposable(n.addListenerAsyncPipe(fv,async(r,o)=>{const i=hv(r)?await uv(r,e):r;return o?o(i):i},pv)),t.addDisposable({dispose:()=>{av(e)}}),t}var gv=Rn("plugin.readBlockAutosave"),m_=H("blockDocuments.provided"),sl=H("plugin.earlyWindow");function vv(e){return e.getOrCreateInstance(sl,()=>({depth:0}))}function bv(e){const t=vv(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function al(e){return(e?.getInstance(sl)?.depth??0)>0}function ll(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,i,s)=>{const a=e(o,i,s);if(r&&al(t)){const l=n;queueMicrotask(()=>{o.call(s,l)})}return a}}var Jn=100,yv=class extends ue{_container;_events;constructor(e){super(),this._container=e;const t=mv(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:i}=qt(e),s=Y(e,j.ON_SHARE_ID),a=Y(e,j.ON_SHOW_PREVIEW_ID),l=Y(e,j.ON_EMAIL_CLONE_ID),c=Y(e,j.ON_BLOCK_OPEN_ID),d=Y(e,j.ON_BLOCK_CLOSE_ID),p=Y(e,j.ON_BLOCK_CLONE_ID),v=Y(e,j.ON_BLOCK_INIT_ID),E=Y(e,j.ON_BLOCK_CHANGED_ID),w=Y(e,j.ON_CODE_VALIDATE_ID),I=Y(e,j.ON_IMPORT_VALIDATE_ID),b=Y(e,j.ON_SUBJECT_CHANGED_ID),R=Y(e,j.ON_EMAIL_CHANGED_ID),P=Y(e,j.ON_PREHEADER_CHANGED_ID),F=Y(e,j.ON_SAVEBUTTON_CLICK_ID),D=Y(e,j.ON_BLOCK_SAVEBUTTON_CLICK_ID),k=Y(e,j.ON_NEXTBUTTON_CLICK_ID),_=Y(e,j.ON_SEND_LIVEPREVIEW_ID),S=Y(e,j.ON_SEND_TESTEMAIL_ID),T=Y(e,Pg),m=Y(e,j.ON_CONTENT_CHANGED_ID),u=Y(e,Rg),f=Y(e,j.ON_PREVIOUSBUTTON_CLICK_ID),g=Y(e,j.ON_SEND_EMAIL_MODAL_ID),x=ec(Y(e,j.ON_EMAIL_INIT_ID),y=>!y.reset),O=Y(e,j.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:U(P),handleSubjectChanged:U(b),handleValidate:U(w),handleImportValidate:U(I),handleReadEmail:U(n.handlerRead,y=>y,y=>y&&mt(y,e)),handleSaveEmail:U(n.onSave,function({prev:y,patch:A,value:h,source:C}){const N=y?be(y,e):void 0;return{prev:N,patch:Pt(N,be(A,e)),value:be(h,e),source:C}},y=>y?mt(y,e):void 0),handleRemoveEmail:U(n.onRemove,({value:y,source:A})=>({value:be(y,e),source:A}),()=>{}),handleReadCommonBlocks:U(T,y=>y.project,y=>y?.map(A=>We(A,e))),handleReadTemplateBlocks:U(u,y=>y,y=>y?.map(A=>We(A,e))),handleReadBlocks:U(t.byForeignKey("project").handleRead,y=>$t(e).requested||String(y),y=>y?.map(A=>We(A,e))),handleReadBlock:U(t.handlerRead,y=>y,y=>y?We(y,e):void 0),handleOpenBlock:U(c,({block:y})=>({block:me(y,e)})),handleCloseBlock:U(d,({block:y,hasUnsavedChanges:A})=>({block:me(y,e),hasUnsavedChanges:A})),handleCloneBlock:U(p,y=>me(y,e)),handleSaveBlock:U(t.onSave,function({prev:y,patch:A,value:h,source:C}){const N=h.global_block===!0&&h.id&&typeof h.html=="string"?{...h,html:ev(h.html,String(h.id))}:h,V=y?me(y,e):void 0;return{prev:V,patch:Pt(V,me(A,e)),value:me(N,e),source:C}},y=>y?We(y,e):void 0),handleRemoveBlock:U(t.onRemove,({value:y,source:A})=>({value:me(y,e),source:A}),()=>{}),handleReadComments:U(r.byForeignKey("post").handleRead,y=>y,y=>y?.map(A=>Or(A,e))),handleSaveComment:U(r.onSave,function({prev:y,patch:A,value:h,source:C}){const N=y?It(y,e):void 0;return{prev:N,patch:Pt(N,It(A,e)),value:It(h,e),source:C}},y=>y?Or(y,e):void 0),handleRemoveComment:U(r.onRemove,({value:y,source:A})=>({value:It(y,e),source:A}),()=>{}),handleReadEmailRevisions:U(o.byForeignKey("parent").handleRead,y=>y,y=>y?.map(A=>ln(A,e))),handleReadEmailAutosave:U(Y(e,za),y=>y,y=>y?ln(y,e):null),handleEmailAutosave:U(o.onSave,function({prev:y,patch:A,value:h,source:C}){return{value:kr(h,e),source:C}},y=>y?ln(y,e):void 0),handleRemoveEmailAutoSave:U(o.onRemove,({value:y,source:A})=>({value:kr(y,e),source:A}),()=>{}),handleReadBlockRevisions:U(i.byForeignKey("parent").handleRead,y=>y,y=>y?.map(A=>cn(A))),handleReadBlockAutosave:U(Y(e,gv),y=>y,y=>y?cn(y):null),handleBlockAutosave:U(i.onSave,({value:y,source:A})=>({value:Oi(y),source:A}),y=>y?cn(y):void 0),handleRemoveBlockAutoSave:U(i.onRemove,({value:y,source:A})=>({value:Oi(y),source:A}),()=>{}),handleBlockInit:U(v,y=>me(y,e)),handleBlockChanged:U(Nn(E,Jn),y=>me(y,e)),handleEmailChanged:U(Nn(R,Jn),y=>be(y,e)),handleEmailInit:ll(U(x,y=>be(y,e)),e),handlePreviousButtonClick:U(f,y=>be(y,e)),handleNextButtonClick:U(k,y=>be(y,e)),handleSaveButtonClick:U(F,y=>be(y,e)),handleSaveBlockButtonClick:U(D,y=>me(y,e)),handleHtmlChanged:U(Nn(m,Jn)),handleTestEmailSend:U(S,({html:y,...A})=>({...A,code:y,compiled:{html:y,ampHtml:""}})),handleTestEmailModal:U(g,y=>be(y,e)),handleCloneEmail:U(l,y=>be(y,e)),handleShareEmail:U(s),handlePreviewEmail:U(a),handleLivePreviewEmail:U(_),handleAnalyticsEvent:U(O)}}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 ct(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Ev=H("DataController"),_v=H("DataEvents");function cl(e){return e.getOrCreateInstance(Ev,()=>{const t=new Xg(e);return e.getInstance(G)?.addDisposable(t),t})}function dl(e){return e.getOrCreateInstance(_v,()=>new yv(e))}var wv=H("plugin.pluginStart");function ul(e){return e.getOrCreateInstance(wv,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(G)?.addDispose(()=>t()),{done:n,finish:t}})}function Sv(e){return ul(e).done}function Iv(e){const t=ul(e);return t.run===void 0&&(t.run=(e.getInstance(Gr)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var Cv=H("plugin.startupShow");function Tv(e){const t=cl(e),n=dl(e),r=e.getInstance(pe),o=e.getInstance(G),i={current:Promise.resolve()};e.inject(Cv,i);let s=!1;const a=r?.watch(c=>{c&&n.setOptions(c),s=(c?.plugins?.length??0)>0,i.current=i.current.catch(()=>{})}),l=r?.select(c=>c?.content).watch(c=>{if(c===void 0)return;const d=()=>(ne(ce.showStart),t.show(c).finally(()=>ne(ce.showEnd))),p=s?Sv(e).then(d):d();p.catch(()=>{}),i.current=p});a&&o?.addDisposable(a),l&&o?.addDisposable(l)}function Av(e){const t=cl(e);return{...dl(e).get(),show(n){return ne(ce.showStart),t.show(n).finally(()=>ne(ce.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return ne(ce.showStart),t.showBlock(n,r).finally(()=>ne(ce.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function fl(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function xn(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let i=t;i<e.length;i++){const s=e[i];if(o){o=!1;continue}if(s==="\\"){o=!0;continue}if(r){s===r&&(r="");continue}if(s==='"'||s==="'"){r=s;continue}if(s==="("){n++;continue}if(s===")"&&(n--,n<0))return!1}return n===0}function Rv(e){return(t,n,r)=>xn(t)?e(t,n,r):!1}function Pv(e){return t=>xn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Dv(e){return(t,n,r)=>xn(t)?fl(t)?e(t,n,r):t:!1}function Ov(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return xn(n)?fl(n)?e(t):t:!1}}function kv(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function Io(e,t){const n=e.length;for(let r=0;r<n;r++){const o=e.charCodeAt(r);if(o===0||t==='"'&&o===34||t==="'"&&o===39||t===""&&(o===32||o===9||o===10||o===13||o===12||o===34||o===39||o===60||o===62||o===61||o===96))return!1}return!0}function xv(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let i=0;i<e;i++){const s=r[i]%62;o+=t.charAt(s)}return o}var Mv=8,Lv=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=xv(Mv),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Mn=new Lv;function Li(e,t){return t!==void 0&&!Io(e,t)?`%|{${Mn.getOrCreateByKey(e)}}|%`:e}function Nv(e){const t=Mn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function ie(e,t,n){return t!==void 0?Io(e,t)?e:`%|{${Mn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function Fv(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function re(e){return e.startsWith("<!--")&&e.endsWith("-->")?Fv(e.slice(4,-3)):e}function Bv(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const o=e.match(/\[%\s*([^%]*?)\s*%\]/);o&&(r=o[1]);const i=r.trim();return t.test(i)||n.test(i)}function jv(e,t,n){return t!==void 0?Io(e,t)?e:`%|{${Mn.getOrCreateByKey(e)}}|%`:n||kv(e)||Bv(e)?`<!--${e}-->`:e}var qe=Rv(ie),Ve=Pv(re),Uv=Dv(ie),Hv=Ov(re),pl=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",Nv),e.escape("@{","}",ie,!0).unescape("<!--@{","}-->",re,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Li,!0),e.escape("{{","}}",Li,!0),e.createSyntax("brace-percent").escape("{%","%}",ie).unescape("<!--{%","%}-->",re),e.createSyntax("brace-hash").escape("{#","#}",ie).unescape("<!--{#","#}-->",re),e.createSyntax("proscript").escape("[%","%]",jv,!0).unescape("<!--[%","%]-->",re,!0),e.createSyntax("getresponse").escape("[[IF","]]",ie).escape("[[if","]]",ie).escape("[[ELSE]]","",ie).escape("[[else]]","",ie).escape("[[ENDIF]]","",ie).escape("[[endif]]","",ie).unescape("<!--[[IF","]]-->",re).unescape("<!--[[if","]]-->",re).unescape("<!--[[ELSE]]","-->",re).unescape("<!--[[else]]","-->",re).unescape("<!--[[ENDIF]]","-->",re).unescape("<!--[[endif]]","-->",re),e.createSyntax("expert-sender").escape("<if",">",ie).escape("</if",">",ie).escape("<else",">",ie).escape("</else",">",ie).escape("<var ",">",ie,!0).unescape("<!--<if ",">-->",re).unescape("<!--</if",">-->",re).unescape("<!--<else ",">-->",re).unescape("<!--</else",">-->",re).unescape("<!--<var",">-->",re,!0),e.createSyntax("velocity").escape("#if",")",qe).escape("#elseif",")",qe).escape("#else","",ie).escape("#foreach",")",qe).escape("#macro",")",qe).escape("#set",")",Uv,!0).escape("#parse",")",qe).escape("#include",")",qe).escape("#evaluate",")",qe).escape("#end","",ie).escape("#break","",ie).escape("#stop","",ie).unescape("<!--#macro","-->",Ve).unescape("<!--#if","-->",Ve).unescape("<!--#elseif","-->",Ve).unescape("<!--#else","-->",re).unescape("<!--#foreach","-->",Ve).unescape("<!--#parse","-->",Ve).unescape("<!--#include","-->",Ve).unescape("<!--#evaluate","-->",Ve).unescape("<!--#end","-->",re).unescape("<!--#break","-->",re).unescape("<!--#stop","-->",re).unescape("<!--#set","-->",Hv,!0),e.createSyntax("mailchimp").escape("*|","|*",ie).unescape("<!--*|","|*-->",re)},Mr="bare",$v=new Map;function qv(e){return e?$v.get(e)??Mr:Mr}var hl=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function Ni(e){return hl.includes(e)}function yt(e){return e==="bare"||e==="html-comment"}function Qn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Vv(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!yt(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[c,d]of[["output",r.output],["editor",r.editor]])if(d!==void 0&&!yt(d))return t(`templateDirectives.${c}: unknown form "${String(d)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!Qn(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[c,d]of Object.entries(r.syntaxes))if(!(!Ni(c)||d===void 0||yt(d))){if(!Qn(d))return t(`templateDirectives.syntaxes.${c}: expected a form or an object, configuration ignored.`),n;for(const p of["output","editor"]){const v=d[p];if(v!==void 0&&!yt(v))return t(`templateDirectives.syntaxes.${c}.${p}: unknown form "${String(v)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??Mr;let i=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),i=void 0);const s=[];if(r.syntaxes)for(const c of Object.keys(r.syntaxes)){if(!Ni(c)){t(`templateDirectives.syntaxes: unknown syntax id "${c}", entry ignored.`);continue}s.push(c)}else s.push(...hl);const a={},l={};for(const c of s){const d=r.syntaxes?.[c],p=Qn(d)?d:void 0,v=(yt(d)?d:p?.output)??o;let E=p?.editor??i??v;v==="bare"&&E==="html-comment"&&(t(`templateDirectives.syntaxes.${c}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),E="bare"),a[c]=v,l[c]=E}return{output:a,editor:l}}function ml(e,t,n,r){for(let o=t;o<n;o++){const i=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?i===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(i)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):i==="<"?r.insideTag=!0:i===">"?r.insideTag=!1:r.insideTag&&(i==='"'||i==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=i,r.unquotedAttr=!1):r.insideTag&&/\S/.test(i)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(i)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function Ct(e,t){return e.start<t.end&&t.start<e.end}function Fi(e,t,n,r,o=[]){if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return[];const i=t.flatMap(d=>d.match(e).flatMap(p=>!Number.isInteger(p.start)||!Number.isInteger(p.end)||p.start<0||p.end>e.length||p.start>=p.end?[]:[{range:p,mapFn:d.mapFn,overrideBuiltins:d.overrideBuiltins,syntax:d.syntax,isVariable:d.isVariable}])).sort((d,p)=>d.range.start-p.range.start||d.range.end-p.range.end),s=[],a=o.slice().sort((d,p)=>d.start-p.start),l={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(const{range:d,mapFn:p,overrideBuiltins:v,syntax:E,isVariable:w}of i){if(r?(l.insideAttributeValue=!0,l.attributeQuoteChar='"'):ml(e,c,d.start,l),c=d.end,a.some(P=>Ct(P,d)))continue;const I=l.insideAttributeValue?l.attributeQuoteChar??"":void 0,b=e.substring(d.start,d.end),R=p(b,I,l.insideTag);R!==!1&&R!==b&&(s.push({range:d,text:R,overrideBuiltins:v,syntax:E,isVariable:w}),a.push(d))}return s.sort((d,p)=>d.range.start-p.range.start||d.range.end-p.range.end)}function Gv(e,t){const n=t.reduce((a,{mapFn:l,start:c,end:d,syntax:p,isVariable:v})=>(a[c]||(a[c]=[]),a[c].push({value:d,mapFn:l,syntax:p,isVariable:v}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),i=[];let s;for(;(s=o.exec(e))!==null;){const a=s[0];i.push({start:s.index,startToken:a,endTokens:n[a]})}return i}function Zn(e,t,n,r,o=!1){const i=[];if(n&&(t=t.filter(c=>c.isVariable)),!t.length)return i;const s=Gv(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(let c=0;c<s.length;c++){const{start:d,startToken:p,endTokens:v}=s[c];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):ml(e,l,d,a),l=d;const E=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let w=!1;for(const{mapFn:I,value:b,syntax:R,isVariable:P}of v){let F=d+p.length,D=e.indexOf(b,F);for(;D!==-1;){let k=D,_=d+p.length,S=0;for(;k!==-1;){const g=e.indexOf(p,_);if(g!==-1&&g<k)S++,_=g+p.length,k=e.indexOf(b,_);else if(S>0)S--,_=k+b.length,k=e.indexOf(b,_);else break}if(k<0)break;const T=k+b.length,m=e.substring(d,T),u=I(m,E,a.insideTag);if(u===!1){F=D+Math.max(b.length,1),D=e.indexOf(b,F);continue}(o||u!==m)&&i.push({range:{start:d,end:T},text:o?m:u,syntax:R,isVariable:P});const f=s.findIndex(({start:g})=>g>=T);f>c?c=f-1:c=s.length,w=!0;break}if(w)break}}return i}function nn(e,t){if(!t.length)return e;const n=t.slice().sort((o,i)=>i.range.start-o.range.start);let r=e;for(const{text:o,range:i}of n)r=r.slice(0,i.start)+o+r.slice(i.end);return r}var zv=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=pl){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,i,s){return t.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this},unescape(r,o,i,s){return n.push({start:r,end:o,mapFn:i,isVariable:s,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let o=!1;const i={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(s=>s!==n),this._unescapeMatchers=this._unescapeMatchers.filter(s=>s!==r))}};return this.addDisposable(i),i}_collectMappings(e,t,n){const r=Zn(e,this._escapes,t,n),o=Fi(e,this._escapeMatchers,t,n),i=o.filter(l=>l.overrideBuiltins).map(l=>l.range),s=r.filter(l=>!i.some(c=>Ct(c,l.range))),a=o.filter(l=>l.overrideBuiltins||!s.some(c=>Ct(l.range,c.range)));return[...s,...a].sort((l,c)=>l.range.start-c.range.start||l.range.end-c.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=Zn(e,this._unescapes,t),r=Fi(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),i=n.filter(a=>!o.some(l=>Ct(l,a.range))),s=r.filter(a=>a.overrideBuiltins||!i.some(l=>Ct(a.range,l.range)));return[...i,...s].sort((a,l)=>a.range.start-l.range.start||a.range.end-l.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>qv(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return Zn(e,this._escapes,t,n,!0)}getEscapedText(e,t){return nn(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return nn(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=i=>i===void 0?void 0:t[i],r=Object.values(t);let o=e;return r.includes("bare")&&(o=nn(o,this._collectRevertMappings(o).filter(i=>n(i.syntax)==="bare"))),r.includes("html-comment")&&(o=nn(o,this._collectMappings(o).filter(i=>!i.isVariable&&n(i.syntax)==="html-comment"&&i.text.startsWith("<!--")&&i.text.endsWith("-->")))),o}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}};function Bi(e){return e.replace("<script","<___script").replace("<\/script>","</___script>")}var ji=new zv(e=>{e.escape("<script","<\/script>",t=>Bi(t)).unescape("<___script","</___script>",t=>t.replace("<___script","<script").replace("</___script>","<\/script>")),e.escape("<script","/>",t=>Bi(t)).unescape("<___script","/>",t=>t.replace("<___script","<script")),pl(e)});function Wv(e){const t=Vv(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return _a();const n=new Set(Object.keys(t.output).filter(o=>t.output[o]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:o=>ji.normalizeToPolicy(o,t.editor),toOutputForm:o=>ji.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:Ea(r)}}function Kv(e){let t;e.injectFactory($r,()=>{const n=e.getInstance(fe)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:Wv(n)}),t.policy})}var Yv=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function Xv(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const o=t.get(r)??[];o.push(n),t.set(r,o)}return t}function Jv(e,t){const n=[];for(const r of e.awaits?.services??[])for(const o of t.get(r)??[])o!==e&&n.push(o);return n}function gl(e){const t=Xv(e),n=[],r=new Set,o=[],i=new Set,s=a=>{if(!r.has(a)){if(i.has(a)){const l=o.indexOf(a);throw new Yv([...o.slice(l),a].map(c=>c.name))}i.add(a),o.push(a);for(const l of Jv(a,t))s(l);o.pop(),i.delete(a),r.add(a),n.push(a)}};for(const a of e)s(a);return n}var Qv=[{name:"rest.client",setup:Ig},{name:"auth.oauth",setup:uc},{name:"rest.identityHeaders",setup:pg},{name:"rest.localeHeader",setup:yg},{name:"lifetime.destroyable",provides:[yo],setup:hm},{name:"appInit",provides:[Be,Zr],setup:id},{name:"config",provides:[fe],setup:fm},{name:"templateDirectives",provides:[$r],setup:Kv},{name:"email.documents",setup:xm},{name:"show.initPipeline",provides:[Pe],setup:Cg},{name:"show",setup:Tv},{name:"locale.service",provides:[ht],setup:cg},{name:"locale.fromConfig",awaits:{services:[fe,ht]},setup:dg},{name:"canvas.early",setup:sh},{name:"canvas.previewSettings",setup:wh},{name:"canvas.sandboxExtensions",setup:Ih},{name:"canvas.sandboxScriptRelay",setup:Ah},{name:"canvas.headerSync",provides:[go],setup:ch},{name:"canvas.headersAfterRecovery",setup:dh},{name:"canvas.ampSync",setup:uf},{name:"canvas.moduleBridge",setup:$f},{name:"canvas.port",setup:_f},{name:"canvas.images",setup:yf},{name:"canvas.edits",setup:oh},{name:"canvas.surfaceFollowsSession",setup:Qp},{name:"canvas.blockContent",setup:Jp},{name:"canvas.sandboxFill",provides:[mo],setup:Gh},{name:"canvas.reactions",setup:ih}],Ui;function Co(e){const t=e.getInstance(pe);if(t)return t;e.getInstance(G)||e.inject(G,new ue);const n=ge();e.inject(pe,n),Ui??=gl(Qv);for(const r of Ui)r.setup(e);return n}function Zv(e){}var eb=[{name:"save.previewFollow",setup:Zv}],Hi=H("plugin.lateUnitsInstalled");function tb(e){if(!e.getInstance(Hi)){e.inject(Hi,!0);for(const t of gl(eb))t.setup(e)}}function nb(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function rb(e){if(!e)return;const t=Xr(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 ob=gt(e=>{let t,n,r;return{async setOptions(o){const i=r!==o.getAuthToken,s=!Re(t,o.user),a=n!==o.project;if(r=o.getAuthToken,t=o.user,n=o.project,!(!e.getInstance(De)||!o.getAuthToken)&&!(!i&&!s&&!a))try{const l=await o.getAuthToken(o.user,o.project);e.inject(hc,Promise.resolve(l||""));const c=rb(l);if(!c)return;e.inject(cc,c);const d=e.getInstance(Be),p=d?await d.catch(()=>{}):void 0;e.inject(Be,Promise.resolve(nb(c,p)))}catch{}}}});function ib(e,t){if(e.getInstance(Lo))return;e.inject(Lo,!0);const n=ye(e,j.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var sb=gt(e=>{let t,n=!1;return{setOptions(r){const o=n;if(n=!0,!Ut(r)){t&&(Zh(e),bo(r)),t=void 0;return}const i=Dn(r);if(!i||t===i&&e.getInstance(De))return;t=i,e.inject(De,i);const s=e.getInstance(G);s&&ib(e,s)}}}),ab=gt(e=>{const t=e.getInstance(G),n=ye(e,gs),r=U(n),o=t.addDisposable(new ct(r));return{setOptions({handleLoad:i}){o.setListener(i)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function vl(e,t,n=!0){const r=e,o=t;for(const i of Object.keys(o)){const s=o[i];s!=null&&(n&&typeof s=="object"?r[i]=vl(r[i]||{},s,!0):r[i]=s)}return e}async function lb(e){const t=(await Dc(()=>import("./static/esm/2490dab8.js").then(n=>Hl(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 bl=H("EditorOptions"),Lr=Ec;function cb(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 db(e){return e.getOrCreateInstance(bl,()=>{const t=ge(Lr);let n=Lr.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(lb(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function ub(e){return e?.getInstance(bl)?.get()??Lr}function fb(e,t={}){const n=db(e);n.set(vl({...n.get()},cb(t)))}function pb(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 hb(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var mb=H("plugin.publicConfig");function Nr(e){return e.getInstance(fe)?.get()??{}}function $i(e){return e.getInstance(fe)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function qi(e){const t=Fa(e),n=Nr(e);return{...n,locale:n.locale||"en_US",theme:n.theme||"light",editor:hb(ub(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Vi(e){return e.getInstance(fe)?.get()!==void 0}function gb(e){const t=ms(),n=ae(e,hs);let r,o,i=!1;const s=async()=>{try{return e.getInstance(Be)===void 0?{}:(await e.getInstanceAsync(Be))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:p=!1}={})=>{await e.getInstance(fe)?.ready(),Ss(e).set(Nr(e).revisionService===!0);const{codeModeDirection:v,editor:E}=Nr(e);E&&fb(e,pb(E)),v!==void 0&&!(p&&v===o)&&(o=v,v==="none"?Ir(e,!1):(Ir(e,!0),vh(e,v)))},l=async()=>{if(!Vi(e))return;const p=qi(e),v=JSON.stringify(p);v!==r&&(r=v,await n.fire(p))},c=async p=>{const v=e.getInstance(fe),E={advancedConfigs:$i(e).advancedConfigs,serverSide:await s(),user:p};v?.setAdvancedConfigs({...E.advancedConfigs,...E.user?.advancedConfigs});const w=v?.layers().user.mode;v?.replace(E.user?.mode===void 0&&w!==void 0?{...E.user,mode:w}:E.user,"user"),v?.replace(E.serverSide,"server"),await a(),await l()},d=p=>{const{commonStyles:v,...E}=p;return"commonStyles"in p&&yh(e,v===void 0?void 0:v),E};return{queue:t,reactToConfig:a,emitConfigChanged:l,resolveServerSideConfig:s,getConfig:()=>Vi(e)?qi(e):{},setConfig:t.decorate(async p=>{await c(d(p))}),updateConfig:t.decorate(async p=>{const v=d(p);await c({...$i(e).user,...v})}),announceAssembled(){i||(i=!0,e.getInstance(fe)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await l()})))}}}function yl(e){return e.getOrCreateInstance(mb,()=>gb(e))}function vb(e){const t=yl(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var bb=gt(e=>{const t=e.getInstance(G),n=t.addDisposable(new Fe),r=t.addDisposable(new Fe),o=Ft(e,hs),i=U(n.event),s=U(r.event),a=ll(U(o.event),e),l=t.addDisposable(new ct(i)),c=t.addDisposable(new ct(s)),d=t.addDisposable(new ct(a));return{instance:{handleSetOptions:i,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(p){l.setListener(p.handleSetOptions),c.setListener(p.handleOptionsChanged),d.setListener(p.handleConfigChanged),yl(e).announceAssembled(),await n.fire(p),await r.fire(p)},dispose(){}}}),er,El="core";function yb(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([El],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Eb(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Vt().then(()=>{}):t([El],e)}function Vt(){return er===void 0&&(er=yb().then(e=>(Ot()&&e.installDiagnostics().catch(t=>{}),e))),er}var tr=null,nr=null;async function _b(e){typeof e?.prefetch=="function"&&await e.prefetch()}function To(){return tr||(tr=Vt().then(()=>{})),tr}function _l(e){return nr||(nr=_b(e)),nr}function wb(){return _l(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function Sb(){const e=typeof window.__useblocks__<"u"?window.__useblocks__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function Ib(e){return Promise.all([To(),_l(e)]).then(()=>{})}function Cb(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Gi(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Eb(t?{priority:t}:void 0)).then(()=>(fo(t?{priority:t}:void 0),n?To():void 0)).catch(()=>{})}function Tb(e){const t=Cb(e);if(t==="eager")Gi(e);else if(t==="idle"){const n=()=>Gi(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var wl="PluginRegistry";function Ab(e=oc()){return e.getOrCreateInstance(wl,()=>new Bc)}var Rb=new jc(()=>Ab()),Pb=["handleAIImageRequest","handleAITextRequest","handleAnalyticsEvent","handleBlockAutosave","handleBlockChanged","handleBlockInit","handleCloneBlock","handleCloneEmail","handleCloseBlock","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleImportValidate","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOpenBlock","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlock","handleReadBlockAutosave","handleReadBlockRevisions","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveBlockAutoSave","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveBlockButtonClick","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],Db=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],yn=new Map([...Pb.map(e=>[e,"event"]),...Db.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),Ob=new Map([["use","use `useAsync()` or await `ready` first"]]);function kb(e){return Ob.get(e)??"await `ready` first"}var xb=new Set(["async","queued"]),Mb=Symbol.for("emailmaker.earlyCtxPlaceholder");function zi(e){return e[Mb]=!0,e}function Lb(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 (${kb(e)}).`)}function Nb(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function Fb(e){return[...yn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function Bb(e,t){for(const n of Fb(e)){const r=yn.get(n);if(r!==void 0&&xb.has(r)){const o=async(...i)=>{await t;const s=e[n];if(typeof s!="function"||s===o)throw Nb(n);return s.apply(e,i)};e[n]=zi(o);continue}e[n]=zi(()=>{throw Lb(n)})}}function jb(e,t,n){e.getInstanceAsync(dt).then(()=>{Ft(e,j.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function Ub(e,t){e.getInstanceAsync(dt).then(()=>{Ft(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 Hb=gt(e=>{let t;function n(){return new Promise(o=>{const i=e.getOrCreateInstance(Kr,()=>new Set),s=()=>{i.delete(s),o()};i.add(s)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const i=e.getInstance(In),s=e.getInstance(wl);if(!t){t=new Fc(i,s,{ensureHostRuntimeReady:wb,explainScriptFailure:Sb,openEarlyWindow:()=>bv(e),reportLoadFailure:c=>Ub(e,c)}),e.inject(Gr,t);const l=t.onLifecycle(c=>{c.type==="create:error"&&jb(e,c.name,c.error)});e.getInstance(G)?.addDisposable(l)}const a=o?.plugins||[];i&&(ra(e),a.length>0&&Bb(i,n()),await t.setPlugins(a))},instance:{use(o){return typeof o=="function"?r().useByCtor(o):r().useByKey(o)},useAsync(o){return r().useAsync(o)},waitPlugin(o){return r().waitFor(o)}},dispose(){t?.dispose(),t=void 0}}}),Sl=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const o=this._listeners.indexOf(r);o>=0&&this._listeners.splice(o,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},$b=H("ELEMENT_INSERT_HTML_PIPELINE"),qb=H("BLOCK_INSERT_HTML_PIPELINE"),Vb="application_block_inserted",Gb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(qb,()=>new Sl).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(jt,()=>new Bt),o=n?e.bind(n):e;return r.addListener(Vb,o,t)}},Ao=H("ComponentRegistry"),zb=H("ComponentRegistryGate");function Ro(){return ut.getOrCreateInstance(zb,()=>({pending:[]}))}function Wb(e=Ao){return Ro().factory!==void 0||ut.getInstance(e)!==void 0}function Fr(e,t,n=Ao){if(Wb(n)){t(En(e,n));return}Ro().pending.push(()=>t(En(e,n)))}function En(e,t=Ao){const n=ut.getInstance(t);if(n)return n;const r=Ro().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return ut.getOrCreateInstance(t,r)}var Kb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=i=>{if(!n){n=!0;for(const s of t)s.dispose();e(i)}};t.push(this._container.addService(Gt,{execute:i=>{r(i.value.map(s=>({name:s.name,html:s.html})))}}));const o=this._container.getInstance(Ql)?.watch(i=>{i&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService(Gt,{execute:r=>{const o=En(n),i=r.value.find(s=>s.name===e);if(i){const{icon:s,title:a,fallbackTooltip:l,...c}=t;s&&(i.icon=o.getReactNode(s)),a&&(i.title=o.getReactNode(a)),l&&(i.fallbackTooltip=o.getReactNode(l)),Object.assign(i,c)}}})}delete(e){this._container.addService(Gt,{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(Gt,{execute:r=>{const o=En(n);r.value.splice(t??r.value.length,0,{...e,title:o.getReactNode(e.title),icon:o.getReactNode(e.icon),fallbackTooltip:o.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance($b,()=>new Sl).add(e,t??0,n)}handleInject(e,t,n){return lt(this._container,Yl).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Yb=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(jt,()=>new Bt)}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 Xb(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Wi(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 Jb=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=lt(t,ac),this._closeModalEmitter=lt(t,Jl),this._updateModalEmitter=lt(t,sc)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Fr(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Wi(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Fr(this._container,r=>{this._updateModalEmitter.fire(Xb({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:Wi(r,n)}))})}};function rn(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var Qb=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=o=>{this._loadedSettled||(this._loadedSettled=!0,r(o))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=o=>{this._readySettled||(this._readySettled=!0,r(o))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},Zb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(jt,()=>new Bt)}_createScriptHandle(e,t){const n=this._messageService.addListener(Vr,o=>{if(o.key===e){if(o.phase==="load"&&o.status==="success"){r.resolveLoaded();return}if(o.phase==="ready"&&o.status==="success"){r.resolveReady();return}if(o.phase==="load"){r.rejectLoad(new Error(o.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(o.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new Qb(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(ot,{...rn(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(ot,{...rn(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(ot,{...rn(t),type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,n)}registerSandboxScriptCode(e,t,n){const r=this._container.addService(ot,{...rn(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},ey=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function Br(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&ey.has(t)}function Il(){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 rr(){return`__settingsPanel:${Il()}`}function or(e,t){return{type:e,props:t}}function ty(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!Br(e)}function Ki(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(Br(t)){const r=rr();return n(e.add(r,t)),or(r,{})}if(typeof t=="function"){const r=rr();return n(e.add(r,t)),or(r,{})}if(ty(t)){const r=t.type;if(typeof r=="string")return t;if(Br(r)||typeof r=="function"){const o=rr();return n(e.add(o,r)),or(o,t.props)}return t}return t}var ny=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??Il();Fr(this._container,n=>{const r=s=>this._trackRegistration(s),o=Ki(n,e.content,r),i=e.advancedTabs?.map(s=>({...s,content:Ki(n,s.content,r)}));lt(this._container,xo).fire({...e,content:o,advancedTabs:i,instanceKey:t,type:ic})})}closeSettingsPanel(){this._clearPanelRegistrations(),lt(this._container,xo).fire(null)}},Cl={SandboxScriptApi:Zb,ElementsApi:Kb,BlocksApi:Gb,MessageService:Yb,SettingsPanelApi:ny,ModalApi:Jb};function ir(e,t,n,r={}){const o=Object.assign({},e);for(const[i,s]of Object.entries(t))if(s!==void 0)if(n.includes(i)&&typeof s=="object"&&s!==null){const a=o[i],l=r[i]??{};o[i]=Object.assign({},typeof a=="object"&&a!==null?a:l,s)}else o[i]=s;return o}var we={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}},ry={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"},sr={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},Yi={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},tt={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:we.border,borderRadius:we.borderRadius,textAlign:"center",padding:we.padding},Xi={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:we.padding},ar={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:we.border,borderRadius:we.borderRadiusCards};function oy(e){return{...ry,...e}}function iy(e){return{...sr,...e,bold:e?.bold??sr.bold,italic:e?.italic??sr.italic}}function sy(e){return{...Yi,...e,underline:e?.underline??Yi.underline}}function ay(e){return{...tt,...e,bold:e?.bold??tt.bold,italic:e?.italic??tt.italic,border:{...tt.border,...e?.border},borderRadius:{...tt.borderRadius,...e?.borderRadius},padding:{...tt.padding,...e?.padding}}}function ly(e){return{...Xi,...e,padding:{...Xi.padding,...e?.padding}}}function cy(e){return{...ar,...e,border:{...ar.border,...e?.border},borderRadius:{...ar.borderRadius,...e?.borderRadius}}}function lr(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 Ji(e){let t={...Yr};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function cr(e){return{text:oy(e.text),headings:iy(e.headings),links:sy(e.links),buttons:ay(e.buttons),block:ly(e.block),cards:cy(e.cards)}}var Qi=H("EmailSettingsPort"),dy=1e4,Tl=class{_editor;_layoutSettingsChanged=new pr;_contentStylesChanged=new pr;_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(!al(this._editor.container)||!it(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(Qi);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return lr(this._settings().read())}_getCurrentContentStyles(){const e=it(this._editor.container)?.current()?.get().attributes.common_styles;return cr(Ji(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(Qi),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(jt,()=>new Bt),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const o=r?.data,i=o?.operation;if(i===z.APPLICATION_EMAIL_SETTINGS_SET){const l=lr(o?.settings),c=this._getLayoutSnapshot(l);c!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=c,this._layoutSettingsChanged.fire(l));return}if(i!==z.APPLICATION_COMMON_STYLES_UPDATE)return;const s=cr(r.data?.settings?.commonStyles??{...Yr}),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=lr(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=dy){const t=it(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,o=ye(r,j.ON_EMAIL_INIT_ID);return new Promise(i=>{let s=!1,a;const l=()=>{a&&(clearTimeout(a),a=void 0)},c=o(()=>{s||(s=!0,l(),c.dispose(),i())});a=setTimeout(()=>{s||(s=!0,c.dispose(),i())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=it(this._editor.container)?.current();if(!t)return;const n=Ji(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=ir(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:we.border,borderRadius:we.borderRadius,padding:we.padding})),e.block!==void 0&&(n.block=ir(n.block||{},e.block,["padding"],{padding:we.padding})),e.cards!==void 0&&(n.cards=ir(n.cards||{},e.cards,["border","borderRadius"],{border:we.border,borderRadius:we.borderRadiusCards}));const r=JSON.stringify(n);ft(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=cr(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},uy={...Cl,EmailSettingsApi:Tl},fy={...Cl},g_={...fy,EmailSettingsApi:Tl},py={...uy};function hy(){Rb.addAll(py)}var my=[gt(()=>{hy()}),ab,bb,sb,mc,ob,Ic];async function gy(){return(await Vt()).asyncMixins}var vy=Hb,by=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let o;try{o=await gy()}catch(s){throw e.failPendingWaits(s),s}t=o(e);const i=await e.getInstanceAsync(In);Object.assign(i,t.instance||{});for(const s of e.getInstance(Kr)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},yy=Sc([...my]);function dr(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const i of r.values())i();r.clear()}return{event(i,s,a){const l=Symbol("subscription");return t||(n.set(l,{listener:i,priority:s,thisArg:a}),e&&r.set(l,e(i,s,a))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(i){o(),e=i;for(const[s,{listener:a,priority:l,thisArg:c}]of n)r.set(s,i(a,l,c))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function Ey(e){const t=dr(),n=dr(),r=dr();return e.getInstance(G)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(dt).then(o=>{t.attach(o.onNotify),n.attach(o.onError),r.attach(o.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(o){const i=e.getInstance(dt);if(i){i.notify(o);return}e.getInstanceAsync(dt).then(s=>s.notify(o),()=>{})}}}var Al=H("CodeErrors"),_y=[];function wy(e){return e?.getInstance(Al)?.get()??_y}function Sy(e){return e?.getInstance(Al)!==void 0}var Iy=class extends ue{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=qt(e),this.addDisposable(ye(e,j.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){const e=Xe(this._container);if(e&&te(e.sessionKey())&&!e.hasSuspended())throw new Error("[useblocks] no open email: only a block is shown");return nl(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=>me(t,this._container))}async _readProjectBlocks(){const e=await rl(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=>It(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=>kr(n,this._container))}async getEmailSnapshot(){return be(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Xe(this._container),t=e?.current();return!e||!t||!te(e.sessionKey())?null:(await t.whenReady(),me(Pn(t),this._container))}setEmailMeta(e){const t=So(this._container);if(!t)return;const n=t.get().attributes.meta;ft(t,{meta:Zt({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&Zt(o,e))}setBlockMeta(e,t){const n=Xe(this._container);if(n?.sessionKey()===fn(e)){const o=n.current();o&&ft(o,{meta:Zt({meta:o.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,i=>i&&Zt(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return Sy(this._container)?wy(this._container):void 0}},Cy=H("EmailDataController");function Ty(e){return e.getOrCreateInstance(Cy,()=>{const t=new Iy(e);return e.getInstance(G)?.addDisposable(t),t})}function Ay(e){const t=Ty(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getBlockSnapshot:()=>t.getBlockSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function Ry(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 Py(e){let t;const n=qa(e),r=ye(e,j.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:i})=>{t=i}));const o=()=>t?Ry(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:i=>o()?.getPast(i)??[],getFuture:i=>o()?.getFuture(i)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:i=>o()?.restoreSnapshot(i)}}}var Dy=H("plugin.mountElement");function Oy(e){const t=e.getInstance(pe)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function ky(e){return e.getOrCreateInstance(Dy,()=>{let t=!1,n;return{get:()=>t?n:Oy(e),set(r){t=!0,n=r}}})}function xy(e){const t=ky(e);return{getElement:()=>t.get()}}function My(e){return{handleLoadImage:U(ye(e,j.UPLOAD_EVENT_ID)),handleFileProxy:U(ye(e,j.FILE_PROXY_EVENT_ID)),handleUrlProxy:U(ye(e,j.PROXY_URL_EVENT_ID)),handleAITextRequest:U(ye(e,j.AI_TEXT_REQUEST_ID)),handleAIImageRequest:U(ye(e,j.AI_IMAGE_REQUEST_ID)),handleReadLocale:U(ye(e,j.READ_LOCALE)),handleLimitUsage:U(ye(e,j.ON_LIMIT_ID)),handleTranslate:U(ye(e,j.ON_TRANSLATE_ID))}}var Ly=[mm,Av,Ey,vb,Ay,Py,xy,My];function Ny(e,t=Ly){const n=Co(e);tb(e);const r=yy(e),o=vy(e),i=by(e),s={...r.instance,...o.instance,...i.instance};for(const l of t)Object.assign(s,l(e));let a=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const c=a&&n.get()===l;a=!1,c||n.set(l),await o.setOptions(l),await i.setOptions(l)}}}function Fy(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 By=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]}},jy="editor-runtime.react.copies",ur=8;function xt(e){return e&&typeof e=="object"?e:void 0}function Zi(e){const t=xt(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=xt(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function Uy(e){const t=xt(e),n=t&&typeof t.version=="string"?t.version:void 0,r=xt(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function Hy(e,t,n){return e.package===t&&e.version===n}function $y({ourReact:e,entries:t,packageName:n,version:r}){const o=Zi(e);if(!o||!Array.isArray(t))return[];const i=[],s=new Set;for(const a of t){const l=xt(a);if(!l||!Hy(l,n,r))continue;const c=Zi(l.react);!c||c===o||s.has(c)||(s.add(c),i.push({package:n,version:r,reactVersion:Uy(l.react),react:l.react}))}return i}function qy({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,ur))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>ur&&n.push(` …and ${t.length-ur} 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 es=new Set;function Vy({packageName:e="useblocks",version:t="1.2.0",log:n=r=>{}}={}){const r=o=>{try{const i=globalThis[Symbol.for(jy)],s=$y({ourReact:o,entries:i,packageName:e,version:t}).filter(a=>!es.has(a.react));if(!s.length)return;s.forEach(a=>es.add(a.react)),n(qy({packageName:e,copies:s}))}catch{}};try{const o=Qr()?.modules?.React;if(o&&typeof o.then=="function"){o.then(r,()=>{});return}r(o)}catch{}}async function Gy(e,t,n){ee(e.signal);const r=t??ut.createChild();Co(r);const o=r.getInstance(G);let i;async function s(){r.inject(ps,Fy(new By)),Vy();const a=Ny(r),l={...a.instance,container:r,get ready(){return i??Promise.resolve(l)},async reset(c){if(ee(c.signal),o.isDisposed())throw Ne();return await a.setOptions(c),l}};r.inject(In,l);try{if(n?.onInstance?.(l),await a.setOptions(e),ee(e.signal),o.isDisposed()||await Iv(r),e.devTools)try{const c=r.getInstance(Gr);c&&await(await Vt()).initDevTools(r,c)}catch{}return ee(e.signal),Ft(r,gs).fire(l),l}catch(c){throw o.dispose(),c}}try{return i=un(s(),e.signal),i.catch(()=>{}),await i}catch(a){throw o.isDisposed()||o.dispose(),a}}var Mt=new WeakMap;function zy(e){return e?Mt.get(e):void 0}function Rl(e){try{e.getInstance(G)?.dispose()}catch{}try{e.dispose()}catch{}}function Wy(e,t){if(!e)return;const n=Mt.get(e);n&&n!==t&&Rl(n),Mt.set(e,t)}function Ky(e,t){e&&Mt.get(e)===t&&Mt.delete(e)}function Yy(e){const t=ut.createChild();return Ut(e)&&t.inject(De,Dn(e)),t}var Dt=new WeakMap,Xy="data-useblocks-config-styles";function Jy(e){return typeof e=="string"?e.trim():""}function ts(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function Qy(e,t,n){if(!e||typeof document>"u")return null;const r=Jy(t),o=Dt.get(e),i=n||e;if(!r)return o&&(o.remove(),Dt.delete(e)),null;if(o)return o.textContent!==r&&(o.textContent=r),(o.parentNode!==i||o!==i.firstChild)&&ts(i,o),o;const s=document.createElement("style");return s.setAttribute(Xy,"true"),s.textContent=r,ts(i,s),Dt.set(e,s),s}function Zy(e){if(!e)return;const t=Dt.get(e);t&&(t.remove(),Dt.delete(e))}function Pl(){return!1}var eE=`
1049
1049
  .blocks-app-initial-spinner-wrapper {
1050
1050
  width: 100%;
1051
1051
  height: 100%;
@@ -1074,7 +1074,7 @@ import{n as us,r as Hl}from"./static/esm/971f1b2c.js";import{$ as xo,A as $l,At
1074
1074
  100% {
1075
1075
  transform: rotate(360deg);
1076
1076
  }
1077
- }`;function tE(){return()=>{}}function nE(e,t){if(!Pl()||!e||typeof document>"u")return tE();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const o=document.createElement("style");o.setAttribute(t,"true"),o.textContent=eE,document.head?.appendChild(o),e.appendChild(n);let i=!1;return()=>{i||(i=!0,n.remove(),o.remove())}}function rE(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function oE({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,i){const s=t.get(o);if(s!==void 0)return s;const a=i().catch(l=>{throw n.has(o)||(n.add(o),r(l)),rE(l)||t.delete(o),l});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var Po=oE();function Dl(){Po.clear()}Vl(()=>Po.clear());var ns=new WeakMap;function Do(e){return zl(e)}function iE(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function sE(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function aE(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 Oo=new WeakMap;function fr(e,t){Oo.set(e,t)}function lE(e){return Oo.get(e)}function cE(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&Oo.get(r)||e,i=Do(n);if(!i)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await aE(o);if(o.getAuthToken&&!a)throw sE();a&&s.set("authorization",a);const l=await dc("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},i,{attemptTimeout:bo(o)||void 0});if(!l.ok)throw iE(l.status,l.statusText);return await l.json()}}function dE(e){return JSON.stringify({baseUrl:Do(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function uE(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function fE(e){return t=>Po.run(dE(t),()=>(ne("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>ne("appInit:end",{kind:"network"}))))}function pE(e,t){if(Ut(e)||!e.appInit&&!Do(e.baseUrl)||!uE(e))return e;const n=e.appInit??cE(e,t);let r=ns.get(n);return r||(r=fE(n),ns.set(n,r)),{...e,appInit:r}}var Ol=0;function hE(){return Ol}function mE(){Ol+=1,Dl()}var rs=new WeakMap,os=new WeakMap,gE=3e4;function vE(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function bE(e,t){try{const n=Xr(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+gE}function yE(e){const t=new Map,n=new Map;return async(r,o,i)=>{const s=vE(r,o);if(i)return n.delete(s),t.delete(s),Dl(),e(r,o,i);const a=n.get(s);if(a&&!t.has(s)){if(a.expiresAtMs>Date.now())return a.token;n.delete(s)}let l=t.get(s);return l===void 0&&(ne("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,o,i)).then(c=>{const d=String(c||"").trim();return d&&n.set(s,{token:c,expiresAtMs:bE(d,Date.now())}),c}).finally(()=>{ne("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function EE(e){if(Ut(e))return e;const t=e.getAuthToken;if(!t)return e;let n=rs.get(t);const r=hE();return(!n||os.get(t)!==r)&&(n=yE(t),rs.set(t,n),os.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var _E="[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 wE(e){const t=new Error(_E,{cause:e});return t.name="EditorStartFailedError",t}var SE={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function is(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var kl=["handleLoad","handleDestroy"];function xl(e,t){let n=e;for(const r of kl){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(i,...s)=>o(t,...s)})}return n}function IE(e){let t,n="pending",r,o,i,s;const a=new Set,l=[],c=new Set;let d,p;const b=new Promise((O,h)=>{d=O,p=h});b.catch(()=>{});const E={},w=O=>t?.[O],I=()=>r??Ne(),y=(O,h)=>{const A=w(O);if(typeof A!="function")throw is(O);return A.apply(t,h)},R=(O,h)=>{try{return Promise.resolve(y(O,h))}catch(A){return Promise.reject(A)}},P=()=>{const O=t?.container?.getInstance?.(G);if(!(n!=="ready"||O?.isDisposed()||typeof w("getConfig")!="function"))try{s=y("getConfig",[])}catch{}},N=()=>n==="dead"?Promise.reject(I()):n==="ready"?Promise.resolve():b,D=()=>{for(const[O,h]of yn)h==="field"&&(E[O]=w(O))},k=O=>{const h=w(O.name);O.dispose||typeof h!="function"||n==="dead"||(O.dispose=h.apply(t,O.args))},_=()=>a.forEach(k),S=()=>{for(const O of a){try{O.dispose?.()}catch{}O.dispose=void 0}},T=()=>{D(),_()},m=()=>{i?.delete(T),i=void 0},u=(O,h)=>{const[A,...F]=h;return!kl.includes(O)||typeof A!="function"?h:[(V,...q)=>A(E,...q),...F]},f=(O,h)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof w(O)!="function")throw is(O);const A={name:O,args:u(O,h)};return a.add(A),k(A),()=>{a.delete(A),A.dispose?.(),A.dispose=void 0}},g=()=>t?.container?.getInstance(pe)?.get()?.content,v=()=>{const O=e.element();return O!==void 0&&typeof O!="string"?O:void 0},C=(O,h)=>{switch(h){case"event":return(...A)=>f(O,A);case"async":return(...A)=>(O==="show"&&A[0]!==void 0&&e.shown?.(A[0]),n!=="dead"&&typeof w(O)=="function"?R(O,A):N().then(()=>y(O,A)));case"queued":return(...A)=>{if(n==="dead"){if(O==="notify")return;throw I()}if(n==="pending"){l.push({name:O,args:A});return}return y(O,A)};case"sync":return(...A)=>{if(n==="dead"){if(O==="getConfig")return s;throw I()}if(typeof w(O)!="function")throw new Error(`[emailmaker] \`${O}\` is not available before the editor is ready: ${SE[O]??"await `ready` first"}`);const F=y(O,A);return O==="getConfig"&&(s=F),F};case"element":return()=>{if(typeof w(O)!="function")return v();try{return y(O,[])}catch{return v()}};case"codeErrors":return()=>n==="ready"&&typeof w(O)=="function"?y(O,[]):[];case"field":return}};for(const[O,h]of yn)E[O]=C(O,h);E.reset=O=>(O?.content!==void 0&&e.shown?.(O.content),N().then(async()=>{const h=O?.content!==void 0&&Re(O.content,g());await y("reset",[xl(O,x)]),h&&await y("show",[O.content])}).then(()=>E)),E.destroy=()=>{if(n==="dead")return;const O=ve("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),c.forEach(h=>h(O)),P(),e.destroy()},Object.defineProperty(E,"ready",{get:()=>o,enumerable:!0,configurable:!0});const x=E;return{object:x,get state(){return n},get editor(){return t},bind:O=>{n==="dead"||t===O||(S(),m(),t=O,D(),_(),n==="pending"&&(i=O.container.getOrCreateInstance(Kr,()=>new Set),i.add(T)))},settle:()=>{if(n==="pending"){n="ready",m(),D(),_();for(const O of l.splice(0))try{y(O.name,O.args)}catch(h){queueMicrotask(()=>{throw h})}d()}},kill:(O,h)=>{n!=="dead"&&(P(),n="dead",r=O,l.length=0,c.forEach(A=>A(O)),m(),h?.keepSubscriptions||(S(),a.clear()),p(O))},detach:()=>{S(),a.clear()},setReady:O=>{o=O},trackCall:O=>(c.add(O),()=>c.delete(O)),hasCalls:()=>c.size>0}}var Ml="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function CE(){return ve(Ml)}function TE(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ml}function AE(e,t,n){if(typeof document>"u")return;let r=!1,o;const i=()=>{r=!0,o?.disconnect(),o=void 0},s=()=>{r||(i(),t())};if(n.addDispose(i),!e.isConnected){queueMicrotask(s);return}o=new MutationObserver(()=>{e.isConnected||s()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function RE(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const i=new AbortController;return AE(n,()=>{n.id,i.abort(CE())},o),qr(r,i.signal)}var Ll="Superseded by newer init() on the same mount element";function ss(){return ve(Ll)}function PE(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ll}var Et=new Map,as=new WeakMap,on=new WeakMap;function DE(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function OE(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=DE(e);(n?Et.get(n):void 0)?.forEach(d=>{d.element!==e&&d.controller.abort(ss())});const r=as.get(e)??new Set;t&&r.forEach(d=>{d.supersedable&&d.controller.abort(ss())});const o=on.get(e)??Promise.resolve();let i;const s=new Promise(d=>{i=d}),a=o.then(()=>s);on.set(e,a),a.then(()=>{on.get(e)===a&&on.delete(e)});const l=new AbortController,c={element:e,controller:l,supersedable:t};if(r.add(c),as.set(e,r),n){const d=Et.get(n)??new Set;d.add(c),Et.set(n,d)}return{signal:l.signal,previous:o,release:()=>{i(),r.delete(c);const d=n?Et.get(n):void 0;n&&d?.delete(c)&&d.size===0&&Et.delete(n)}}}var Lt=new WeakMap;function ko(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function jr(e){return Object.entries(e).filter(([t,n])=>ko(t,n)).map(([t])=>t).sort()}function ls(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!ko(n,r)&&(t[n]=r);return t}function Ur(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Lt.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Lt.set(e,r));const{current:o,trampolines:i}=r;o.clear();const s={...t};for(const a of jr(t)){o.set(a,t[a]);let l=i.get(a);l||(l=(...c)=>o.get(a)?.(...c),i.set(a,l)),s[a]=l}return r.lastOptions=t,s}function Nl(e,t){const n=e?Lt.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];ko(r,o)?n.current.set(r,o):n.current.delete(r)}}function kE(e){const t=e?Lt.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,i)=>t.current.set(i,o)),t.lastOptions=r}}function xE(e,t,n){const r=e?Lt.get(e):void 0;if(!r||!n)return!1;const o=jr(t),i=Re(o,jr(r.lastOptions)),s=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!i||!s||!Re(ls(t),ls(r.lastOptions))?!1:(Ur(e,t),!0)}var Ce=new WeakMap;function Ln(e){let t=Ce.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},Ce.set(e,t)),t}var je=e=>e!==void 0&&e.state!=="dead";function ME(e){const t=Ce.get(e)?.shared;return je(t)?t:void 0}function LE(e,t){Ln(e).shared=t}function NE(e,t){!(je(e.shared)&&[...e.counted].some(je))||e.warned||!t.devTools||(e.warned=!0)}function FE(e,t,n,r){const o=Ln(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(i=>i.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(i=>i!==t&&je(i)),t],NE(o,r),o.latestCall}function BE(e,t){return Ce.get(e)?.latestCall===t}function jE(e){const t=Ce.get(e);if(t)return t.order=t.order.filter(je),t.order.at(-1)?.object}function Nt(e,t){const n=Ce.get(e);return n?je(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&je(r)):!1}function UE(e,t){const n=Ce.get(e),r=n?.order.filter(o=>o!==t&&je(o)).at(-1);return r?n?.options.get(r):void 0}function Fl(e,t){Ln(e).content={value:t}}function HE(e){return Ce.get(e)?.content}function $E(e,t,n,r){const o=Ln(e);if(o.counted.delete(t),o.options.delete(t),Nt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),Bl(e,r)}function Bl(e,t){const n=Ce.get(e);!n||Nt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Nt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function qE(e,t){const n=Ce.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);Ce.delete(e)}}var v_=us({FileManagerApiError:()=>GE,IntegratorSaveTimeoutError:()=>Tn,SaveRefusedError:()=>Tt}),GE=class jl extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,o){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=o,Error.captureStackTrace&&Error.captureStackTrace(this,jl)}},b_=us({mapHttpStatusToErrorCode:()=>nc});function VE(e,t){return{...e,element:t}}function Hr(){return()=>{}}function zE(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Hr():(Qy(t,e.config?.styles,t),()=>{Zy(t)})}function WE(e){if(!Pl()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Hr()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Hr()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=nE(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function KE(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function _n(e){try{e.destroy()}catch{}}function dn(e,...t){const n=_e.get(e);t.some(r=>r!==void 0&&r===n)&&_e.delete(e)}var y_="1.1.108";async function E_(e){fo(),await Ib(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function __(e){return ZE(e).ready}function YE(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function XE(e){const t=_e.get(e);return t&&!(t instanceof Promise)?t:void 0}function wn(e,t,n){const r=t??XE(e);r&&(dn(e,r),_n(r)),qE(e,n)}function JE(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const s=t.editor;QE(s),t.kill(Ne());return}if(n==="single"){wn(o,t.editor,Ne());return}const i=UE(o,t);$E(o,t,Ne(),()=>wn(o,t.editor,Ne())),i&&Nt(o)&&Nl(o,i)}function QE(e){e&&_n(e)}function ZE(e){ne(ce.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=qr(e.signal,n.signal),o=t==="single"?YE(e.element):void 0,i=o?ME(o):void 0;let s;if(i)s={control:i,mode:t,ref:{host:o}};else{const d={},p=IE({element:()=>d.host??e.element,destroy:()=>JE(s),shown:b=>{d.host&&Fl(d.host,b)}});s={control:p,mode:t,ref:d},o&&LE(o,p)}const{control:a}=s,l=a.trackCall(d=>n.abort(d)),c=o_(xl({...e,signal:r},a.object),s).then(()=>(l(),ne(ce.initEnd),a.settle(),a.object),d=>{l(),a.state==="pending"&&!a.hasCalls()&&a.kill(d);const p=s.ref.host;throw p&&Bl(p,()=>wn(p,void 0,Ne())),d});return a.setReady(c),a.object}function w_(e){const t=typeof e=="string"?document.querySelector(e):e;return t?jE(t):void 0}function e_(e){let t,n,r=!1;try{t=e.container.getInstance(pe)?.get(),n=e.container.getInstance(Pe)?.externalSignal;const o=it(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:t_(e),dirty:r}}async function t_(e){try{return await e.getEmailSnapshot()}catch{return}}function n_(e){const t=it(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function cs(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Nt(e,n)}async function r_(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),PE(o)||TE(o))return;const i=()=>wn(t,e,wE(o)),{options:s}=n;if(!s||!cs(t,r)){i();return}const a=await n.email,l=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,c=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:l?{...c,email:l}:s.content}),n.dirty&&l&&n_(e),cs(t,r)?_e.set(t,e):i()}catch{i()}}async function o_(e,t){ee(e.signal);const n=new ue;let r,o,i,s,a=0;try{const l=await wc(e.element,n,e.signal);l&&(s=l,t.ref.host=l,a=FE(l,t.control,t.mode,e));const c=RE({hostElementOption:e.element,resolvedElement:l,externalSignal:e.signal,disposable:n}),d=OE(l,{supersede:t.mode==="single"});r=d.release;const p=qr(c,d.signal);ee(p),i=kE(l),Nl(l,e),await un(d.previous,p),o=i_(e,l,t,p,i);const b=await un(o,p);return l&&e.content!==void 0&&Fl(l,e.content),b}catch(l){throw s&&i&&BE(s,a)&&i(),l}finally{const l=r;o!==void 0&&l?o.then(l,l):l?.(),n.dispose()}}async function ds(e,t,n,r){const o=HE(t);n===void 0||r||!o||Re(n,o.value)||await e.show(n)}async function i_(e,t,n,r,o){const{control:i}=n,s=I=>i.bind(I);ee(r);let a;const l=I=>{mE();const y=EE(VE(I,t)),R=pE(y,()=>a);return{preparedOptions:R,preparedOptionsWithSignal:r!=null?{...R,signal:r}:R}};let c;if(t){const I=_e.get(t);if(I){let y;try{y=await I,ee(r)}catch{ee(r),dn(t,I),y=void 0}if(y)if(y.getElement()===t){const R=zy(t);a=R;const P=y.container.getInstance(pe)?.get();if(xE(t,e,P))return s(y),r&&y.container.getInstance(Pe)?.relinkExternalSignal(r),_e.set(t,y),await ds(y,t,e.content,!1),y;const N=!Re(e.content,P?.content);c=l(Ur(t,e));const{preparedOptions:D,preparedOptionsWithSignal:k}=c,_=R&&lE(R),S=e_(y);try{R&&fr(R,D),s(y);const T=await y.reset(KE(e,k));return ee(r),_e.set(t,y),await ds(y,t,e.content,N),T}catch(T){if(R&&_&&fr(R,_),!ed(T))throw o(),await r_(y,t,S,n,T),T;dn(t,I,y),_n(y),ee(r)}}else dn(t,I,y),_n(y)}}ee(r),c??=l(Ur(t,e,{fresh:!0}));const{preparedOptions:d}=c,p=zE(d),b=WE(d),E=r!=null?{...b.options,signal:r}:b.options;let w;try{a=Yy(E),Wy(t,a),fr(a,d),Co(a).set(E),await To(),ne(ce.coreReady),ee(r),ee(r),w=Vy(E,a,{onInstance:s}),t&&_e.set(t,w);const I=await w;if(r?.aborted&&(I.destroy(),ee(r)),t)if(_e.get(t)===w)_e.set(t,I);else throw I.destroy(),ee(r),ve(r?.reason);return I}catch(I){throw p(),b.cleanup(),a&&(Rl(a),Ky(t,a)),t&&w&&_e.get(t)===w&&_e.delete(t),I}}async function S_(e){return(await Gt()).parseAMP(e)}typeof window<"u"&&(Ot()&&Qc(),Tb(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{Ml as ELEMENT_DETACHED_ABORT_MESSAGE,Ll as SUPERSEDED_INIT_ABORT_MESSAGE,ZE as create,v_ as errors,w_ as getInstance,b_ as helpers,__ as init,TE as isElementDetachedError,PE as isSupersededInitError,S_ as parseAMP,Rb as pluginRegistry,E_ as preload,y_ as version};
1077
+ }`;function tE(){return()=>{}}function nE(e,t){if(!Pl()||!e||typeof document>"u")return tE();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const o=document.createElement("style");o.setAttribute(t,"true"),o.textContent=eE,document.head?.appendChild(o),e.appendChild(n);let i=!1;return()=>{i||(i=!0,n.remove(),o.remove())}}function rE(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function oE({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,i){const s=t.get(o);if(s!==void 0)return s;const a=i().catch(l=>{throw n.has(o)||(n.add(o),r(l)),rE(l)||t.delete(o),l});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var Po=oE();function Dl(){Po.clear()}Gl(()=>Po.clear());var ns=new WeakMap;function Do(e){return zl(e)}function iE(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function sE(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function aE(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 Oo=new WeakMap;function fr(e,t){Oo.set(e,t)}function lE(e){return Oo.get(e)}function cE(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&Oo.get(r)||e,i=Do(n);if(!i)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await aE(o);if(o.getAuthToken&&!a)throw sE();a&&s.set("authorization",a);const l=await dc("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},i,{attemptTimeout:bo(o)||void 0});if(!l.ok)throw iE(l.status,l.statusText);return await l.json()}}function dE(e){return JSON.stringify({baseUrl:Do(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function uE(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function fE(e){return t=>Po.run(dE(t),()=>(ne("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>ne("appInit:end",{kind:"network"}))))}function pE(e,t){if(Ut(e)||!e.appInit&&!Do(e.baseUrl)||!uE(e))return e;const n=e.appInit??cE(e,t);let r=ns.get(n);return r||(r=fE(n),ns.set(n,r)),{...e,appInit:r}}var Ol=0;function hE(){return Ol}function mE(){Ol+=1,Dl()}var rs=new WeakMap,os=new WeakMap,gE=3e4;function vE(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function bE(e,t){try{const n=Xr(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+gE}function yE(e){const t=new Map,n=new Map;return async(r,o,i)=>{const s=vE(r,o);if(i)return n.delete(s),t.delete(s),Dl(),e(r,o,i);const a=n.get(s);if(a&&!t.has(s)){if(a.expiresAtMs>Date.now())return a.token;n.delete(s)}let l=t.get(s);return l===void 0&&(ne("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,o,i)).then(c=>{const d=String(c||"").trim();return d&&n.set(s,{token:c,expiresAtMs:bE(d,Date.now())}),c}).finally(()=>{ne("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function EE(e){if(Ut(e))return e;const t=e.getAuthToken;if(!t)return e;let n=rs.get(t);const r=hE();return(!n||os.get(t)!==r)&&(n=yE(t),rs.set(t,n),os.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var _E="[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 wE(e){const t=new Error(_E,{cause:e});return t.name="EditorStartFailedError",t}var SE={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function is(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var kl=["handleLoad","handleDestroy"];function xl(e,t){let n=e;for(const r of kl){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(i,...s)=>o(t,...s)})}return n}function IE(e){let t,n="pending",r,o,i,s;const a=new Set,l=[],c=new Set;let d,p;const v=new Promise((A,h)=>{d=A,p=h});v.catch(()=>{});const E={},w=A=>t?.[A],I=()=>r??Ne(),b=(A,h)=>{const C=w(A);if(typeof C!="function")throw is(A);return C.apply(t,h)},R=(A,h)=>{try{return Promise.resolve(b(A,h))}catch(C){return Promise.reject(C)}},P=()=>{const A=t?.container?.getInstance?.(G);if(!(n!=="ready"||A?.isDisposed()||typeof w("getConfig")!="function"))try{s=b("getConfig",[])}catch{}},F=()=>n==="dead"?Promise.reject(I()):n==="ready"?Promise.resolve():v,D=()=>{for(const[A,h]of yn)h==="field"&&(E[A]=w(A))},k=A=>{const h=w(A.name);A.dispose||typeof h!="function"||n==="dead"||(A.dispose=h.apply(t,A.args))},_=()=>a.forEach(k),S=()=>{for(const A of a){try{A.dispose?.()}catch{}A.dispose=void 0}},T=()=>{D(),_()},m=()=>{i?.delete(T),i=void 0},u=(A,h)=>{const[C,...N]=h;return!kl.includes(A)||typeof C!="function"?h:[(V,...q)=>C(E,...q),...N]},f=(A,h)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof w(A)!="function")throw is(A);const C={name:A,args:u(A,h)};return a.add(C),k(C),()=>{a.delete(C),C.dispose?.(),C.dispose=void 0}},g=()=>t?.container?.getInstance(pe)?.get()?.content,x=()=>{const A=e.element();return A!==void 0&&typeof A!="string"?A:void 0},O=(A,h)=>{switch(h){case"event":return(...C)=>f(A,C);case"async":return(...C)=>(A==="show"&&C[0]!==void 0&&e.shown?.(C[0]),n!=="dead"&&typeof w(A)=="function"?R(A,C):F().then(()=>b(A,C)));case"queued":return(...C)=>{if(n==="dead"){if(A==="notify")return;throw I()}if(n==="pending"){l.push({name:A,args:C});return}return b(A,C)};case"sync":return(...C)=>{if(n==="dead"){if(A==="getConfig")return s;throw I()}if(typeof w(A)!="function")throw new Error(`[emailmaker] \`${A}\` is not available before the editor is ready: ${SE[A]??"await `ready` first"}`);const N=b(A,C);return A==="getConfig"&&(s=N),N};case"element":return()=>{if(typeof w(A)!="function")return x();try{return b(A,[])}catch{return x()}};case"codeErrors":return()=>n==="ready"&&typeof w(A)=="function"?b(A,[]):[];case"field":return}};for(const[A,h]of yn)E[A]=O(A,h);E.reset=A=>(A?.content!==void 0&&e.shown?.(A.content),F().then(async()=>{const h=A?.content!==void 0&&Re(A.content,g());await b("reset",[xl(A,y)]),h&&await b("show",[A.content])}).then(()=>E)),E.destroy=()=>{if(n==="dead")return;const A=ve("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),c.forEach(h=>h(A)),P(),e.destroy()},Object.defineProperty(E,"ready",{get:()=>o,enumerable:!0,configurable:!0});const y=E;return{object:y,get state(){return n},get editor(){return t},bind:A=>{n==="dead"||t===A||(S(),m(),t=A,D(),_(),n==="pending"&&(i=A.container.getOrCreateInstance(Kr,()=>new Set),i.add(T)))},settle:()=>{if(n==="pending"){n="ready",m(),D(),_();for(const A of l.splice(0))try{b(A.name,A.args)}catch(h){queueMicrotask(()=>{throw h})}d()}},kill:(A,h)=>{n!=="dead"&&(P(),n="dead",r=A,l.length=0,c.forEach(C=>C(A)),m(),h?.keepSubscriptions||(S(),a.clear()),p(A))},detach:()=>{S(),a.clear()},setReady:A=>{o=A},trackCall:A=>(c.add(A),()=>c.delete(A)),hasCalls:()=>c.size>0}}var Ml="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function CE(){return ve(Ml)}function TE(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ml}function AE(e,t,n){if(typeof document>"u")return;let r=!1,o;const i=()=>{r=!0,o?.disconnect(),o=void 0},s=()=>{r||(i(),t())};if(n.addDispose(i),!e.isConnected){queueMicrotask(s);return}o=new MutationObserver(()=>{e.isConnected||s()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function RE(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const i=new AbortController;return AE(n,()=>{n.id,i.abort(CE())},o),qr(r,i.signal)}var Ll="Superseded by newer init() on the same mount element";function ss(){return ve(Ll)}function PE(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ll}var Et=new Map,as=new WeakMap,on=new WeakMap;function DE(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function OE(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=DE(e);(n?Et.get(n):void 0)?.forEach(d=>{d.element!==e&&d.controller.abort(ss())});const r=as.get(e)??new Set;t&&r.forEach(d=>{d.supersedable&&d.controller.abort(ss())});const o=on.get(e)??Promise.resolve();let i;const s=new Promise(d=>{i=d}),a=o.then(()=>s);on.set(e,a),a.then(()=>{on.get(e)===a&&on.delete(e)});const l=new AbortController,c={element:e,controller:l,supersedable:t};if(r.add(c),as.set(e,r),n){const d=Et.get(n)??new Set;d.add(c),Et.set(n,d)}return{signal:l.signal,previous:o,release:()=>{i(),r.delete(c);const d=n?Et.get(n):void 0;n&&d?.delete(c)&&d.size===0&&Et.delete(n)}}}var Lt=new WeakMap;function ko(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function jr(e){return Object.entries(e).filter(([t,n])=>ko(t,n)).map(([t])=>t).sort()}function ls(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!ko(n,r)&&(t[n]=r);return t}function Ur(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Lt.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Lt.set(e,r));const{current:o,trampolines:i}=r;o.clear();const s={...t};for(const a of jr(t)){o.set(a,t[a]);let l=i.get(a);l||(l=(...c)=>o.get(a)?.(...c),i.set(a,l)),s[a]=l}return r.lastOptions=t,s}function Nl(e,t){const n=e?Lt.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];ko(r,o)?n.current.set(r,o):n.current.delete(r)}}function kE(e){const t=e?Lt.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,i)=>t.current.set(i,o)),t.lastOptions=r}}function xE(e,t,n){const r=e?Lt.get(e):void 0;if(!r||!n)return!1;const o=jr(t),i=Re(o,jr(r.lastOptions)),s=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!i||!s||!Re(ls(t),ls(r.lastOptions))?!1:(Ur(e,t),!0)}var Ce=new WeakMap;function Ln(e){let t=Ce.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},Ce.set(e,t)),t}var je=e=>e!==void 0&&e.state!=="dead";function ME(e){const t=Ce.get(e)?.shared;return je(t)?t:void 0}function LE(e,t){Ln(e).shared=t}function NE(e,t){!(je(e.shared)&&[...e.counted].some(je))||e.warned||!t.devTools||(e.warned=!0)}function FE(e,t,n,r){const o=Ln(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(i=>i.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(i=>i!==t&&je(i)),t],NE(o,r),o.latestCall}function BE(e,t){return Ce.get(e)?.latestCall===t}function jE(e){const t=Ce.get(e);if(t)return t.order=t.order.filter(je),t.order.at(-1)?.object}function Nt(e,t){const n=Ce.get(e);return n?je(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&je(r)):!1}function UE(e,t){const n=Ce.get(e),r=n?.order.filter(o=>o!==t&&je(o)).at(-1);return r?n?.options.get(r):void 0}function Fl(e,t){Ln(e).content={value:t}}function HE(e){return Ce.get(e)?.content}function $E(e,t,n,r){const o=Ln(e);if(o.counted.delete(t),o.options.delete(t),Nt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),Bl(e,r)}function Bl(e,t){const n=Ce.get(e);!n||Nt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Nt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function qE(e,t){const n=Ce.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);Ce.delete(e)}}var v_=us({FileManagerApiError:()=>VE,IntegratorSaveTimeoutError:()=>Tn,SaveRefusedError:()=>Tt}),VE=class jl extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,o){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=o,Error.captureStackTrace&&Error.captureStackTrace(this,jl)}},b_=us({mapHttpStatusToErrorCode:()=>nc});function GE(e,t){return{...e,element:t}}function Hr(){return()=>{}}function zE(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Hr():(Qy(t,e.config?.styles,t),()=>{Zy(t)})}function WE(e){if(!Pl()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Hr()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Hr()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=nE(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function KE(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function _n(e){try{e.destroy()}catch{}}function dn(e,...t){const n=_e.get(e);t.some(r=>r!==void 0&&r===n)&&_e.delete(e)}var y_="1.2.0";async function E_(e){fo(),await Ib(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function __(e){return ZE(e).ready}function YE(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function XE(e){const t=_e.get(e);return t&&!(t instanceof Promise)?t:void 0}function wn(e,t,n){const r=t??XE(e);r&&(dn(e,r),_n(r)),qE(e,n)}function JE(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const s=t.editor;QE(s),t.kill(Ne());return}if(n==="single"){wn(o,t.editor,Ne());return}const i=UE(o,t);$E(o,t,Ne(),()=>wn(o,t.editor,Ne())),i&&Nt(o)&&Nl(o,i)}function QE(e){e&&_n(e)}function ZE(e){ne(ce.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=qr(e.signal,n.signal),o=t==="single"?YE(e.element):void 0,i=o?ME(o):void 0;let s;if(i)s={control:i,mode:t,ref:{host:o}};else{const d={},p=IE({element:()=>d.host??e.element,destroy:()=>JE(s),shown:v=>{d.host&&Fl(d.host,v)}});s={control:p,mode:t,ref:d},o&&LE(o,p)}const{control:a}=s,l=a.trackCall(d=>n.abort(d)),c=o_(xl({...e,signal:r},a.object),s).then(()=>(l(),ne(ce.initEnd),a.settle(),a.object),d=>{l(),a.state==="pending"&&!a.hasCalls()&&a.kill(d);const p=s.ref.host;throw p&&Bl(p,()=>wn(p,void 0,Ne())),d});return a.setReady(c),a.object}function w_(e){const t=typeof e=="string"?document.querySelector(e):e;return t?jE(t):void 0}function e_(e){let t,n,r=!1;try{t=e.container.getInstance(pe)?.get(),n=e.container.getInstance(Pe)?.externalSignal;const o=it(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:t_(e),dirty:r}}async function t_(e){try{return await e.getEmailSnapshot()}catch{return}}function n_(e){const t=it(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function cs(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Nt(e,n)}async function r_(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),PE(o)||TE(o))return;const i=()=>wn(t,e,wE(o)),{options:s}=n;if(!s||!cs(t,r)){i();return}const a=await n.email,l=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,c=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:l?{...c,email:l}:s.content}),n.dirty&&l&&n_(e),cs(t,r)?_e.set(t,e):i()}catch{i()}}async function o_(e,t){ee(e.signal);const n=new ue;let r,o,i,s,a=0;try{const l=await wc(e.element,n,e.signal);l&&(s=l,t.ref.host=l,a=FE(l,t.control,t.mode,e));const c=RE({hostElementOption:e.element,resolvedElement:l,externalSignal:e.signal,disposable:n}),d=OE(l,{supersede:t.mode==="single"});r=d.release;const p=qr(c,d.signal);ee(p),i=kE(l),Nl(l,e),await un(d.previous,p),o=i_(e,l,t,p,i);const v=await un(o,p);return l&&e.content!==void 0&&Fl(l,e.content),v}catch(l){throw s&&i&&BE(s,a)&&i(),l}finally{const l=r;o!==void 0&&l?o.then(l,l):l?.(),n.dispose()}}async function ds(e,t,n,r){const o=HE(t);n===void 0||r||!o||Re(n,o.value)||await e.show(n)}async function i_(e,t,n,r,o){const{control:i}=n,s=I=>i.bind(I);ee(r);let a;const l=I=>{mE();const b=EE(GE(I,t)),R=pE(b,()=>a);return{preparedOptions:R,preparedOptionsWithSignal:r!=null?{...R,signal:r}:R}};let c;if(t){const I=_e.get(t);if(I){let b;try{b=await I,ee(r)}catch{ee(r),dn(t,I),b=void 0}if(b)if(b.getElement()===t){const R=zy(t);a=R;const P=b.container.getInstance(pe)?.get();if(xE(t,e,P))return s(b),r&&b.container.getInstance(Pe)?.relinkExternalSignal(r),_e.set(t,b),await ds(b,t,e.content,!1),b;const F=!Re(e.content,P?.content);c=l(Ur(t,e));const{preparedOptions:D,preparedOptionsWithSignal:k}=c,_=R&&lE(R),S=e_(b);try{R&&fr(R,D),s(b);const T=await b.reset(KE(e,k));return ee(r),_e.set(t,b),await ds(b,t,e.content,F),T}catch(T){if(R&&_&&fr(R,_),!ed(T))throw o(),await r_(b,t,S,n,T),T;dn(t,I,b),_n(b),ee(r)}}else dn(t,I,b),_n(b)}}ee(r),c??=l(Ur(t,e,{fresh:!0}));const{preparedOptions:d}=c,p=zE(d),v=WE(d),E=r!=null?{...v.options,signal:r}:v.options;let w;try{a=Yy(E),Wy(t,a),fr(a,d),Co(a).set(E),await To(),ne(ce.coreReady),ee(r),ee(r),w=Gy(E,a,{onInstance:s}),t&&_e.set(t,w);const I=await w;if(r?.aborted&&(I.destroy(),ee(r)),t)if(_e.get(t)===w)_e.set(t,I);else throw I.destroy(),ee(r),ve(r?.reason);return I}catch(I){throw p(),v.cleanup(),a&&(Rl(a),Ky(t,a)),t&&w&&_e.get(t)===w&&_e.delete(t),I}}async function S_(e){return(await Vt()).parseAMP(e)}typeof window<"u"&&(Ot()&&Qc(),Tb(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{Ml as ELEMENT_DETACHED_ABORT_MESSAGE,Ll as SUPERSEDED_INIT_ABORT_MESSAGE,ZE as create,v_ as errors,w_ as getInstance,b_ as helpers,__ as init,TE as isElementDetachedError,PE as isSupersededInitError,S_ as parseAMP,Rb as pluginRegistry,E_ as preload,y_ as version};
1078
1078
 
1079
1079
 
1080
- window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/160bf060.js":[],"static/core/19e01848.js":[],"static/core/1ed86ed3.js":[],"static/core/23ecb0b0.js":[],"static/core/2865a0ae.js":[],"static/core/32813d7b.js":["static/core/cc70a22f.js","static/core/da678146.js","__delivery__/libs","static/core/feb1ffa4.js"],"static/core/34804219.js":[],"static/core/38ea9ef6.js":["static/core/42ef449b.js"],"static/core/3fd50a29.js":[],"static/core/42ef449b.js":[],"static/core/48da14fd.js":[],"static/core/49be45c4.js":[],"static/core/4d698359.js":[],"static/core/4ec0aff8.js":[],"static/core/501559e1.js":["static/core/49be45c4.js"],"static/core/622a2220.js":["static/core/ebcc0451.js","__delivery__/libs"],"static/core/6561b34a.js":[],"static/core/66619f08.js":[],"static/core/83a7fff3.js":[],"static/core/87e91b5e.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/8a452a94.js":["static/core/feb1ffa4.js","static/core/49be45c4.js","__delivery__/libs"],"static/core/9b50835f.js":["static/core/42ef449b.js"],"static/core/a77f31cb.js":[],"static/core/aa65675c.js":["static/core/4d698359.js"],"static/core/c6bde249.js":[],"static/core/c9cebb1a.js":["static/core/feb1ffa4.js","__delivery__/libs"],"static/core/cc70a22f.js":["static/core/feb1ffa4.js","__delivery__/libs"],"static/core/d8e8d436.js":["static/core/feb1ffa4.js","static/core/cc70a22f.js","static/core/c9cebb1a.js","static/core/f89490a1.js","__delivery__/libs"],"static/core/da678146.js":["static/core/ebcc0451.js","__delivery__/libs"],"static/core/dcc37768.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/e7620593.js":[],"static/core/e86ffdcb.js":[],"static/core/e8a44736.js":[],"static/core/ebcc0451.js":["__delivery__/libs"],"static/core/f369973d.js":[],"static/core/f50ba1e0.js":["static/core/4d698359.js","static/core/42ef449b.js","static/core/38ea9ef6.js"],"static/core/f89490a1.js":["static/core/da678146.js","__delivery__/libs"],"static/core/fb2fe2db.js":[],"static/core/fe5390c8.js":[],"static/core/feb1ffa4.js":["static/core/e7620593.js","static/core/49be45c4.js","__delivery__/libs"],"static/monaco/editor.api-C9c1WLns.js":[],"monaco":["static/monaco/editor.api-C9c1WLns.js","static/monaco/lspLanguageFeatures-DY3n8M13.js"],"static/monaco/lspLanguageFeatures-DY3n8M13.js":["static/monaco/editor.api-C9c1WLns.js"],"compat-globals.js":["static/esm/971f1b2c.js"],"static/esm/delivery-libs.js":[],"useblocks-esm.js":["static/esm/971f1b2c.js","static/esm/1e463a71.js","static/esm/f76c9d9d.js"],"static/esm/1e463a71.js":[],"static/esm/2490dab8.js":["static/esm/971f1b2c.js"],"static/esm/971f1b2c.js":[],"static/esm/f76c9d9d.js":[]},"bundles":{"static/core/da678146.js":["static/core/dfa33293.js","static/core/3f2ea324.js","static/core/f8a9d63c.js"],"static/core/aa65675c.js":["static/core/a71c4cd8.js"],"static/core/8a452a94.js":["static/core/f74fd241.js"],"static/core/f89490a1.js":["static/core/a73da823.js"],"static/core/32813d7b.js":["static/core/c322ff06.js"],"core":["static/core/2ff39ddf.js","static/core/648f17a7.js","static/core/15891cd6.js","static/core/cc3952af.js","static/core/e08230b6.js"]}});
1080
+ window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/12f773c1.js":[],"static/core/1516d48e.js":["static/core/e7620593.js","static/core/49be45c4.js","__delivery__/libs"],"static/core/1594df08.js":["static/core/d6929171.js"],"static/core/160bf060.js":[],"static/core/1d170e32.js":[],"static/core/1dc51b93.js":[],"static/core/1ed86ed3.js":[],"static/core/28d63741.js":["static/core/e460bb13.js","__delivery__/libs"],"static/core/29e211b1.js":["static/core/1516d48e.js","__delivery__/libs"],"static/core/3d3eb29f.js":["static/core/d6929171.js"],"static/core/3f80e59d.js":["static/core/e460bb13.js","__delivery__/libs"],"static/core/3fd50a29.js":[],"static/core/48da14fd.js":[],"static/core/49be45c4.js":[],"static/core/501559e1.js":["static/core/49be45c4.js"],"static/core/5278dff9.js":[],"static/core/57fee71e.js":["static/core/1516d48e.js","__delivery__/libs"],"static/core/5b586fcb.js":[],"static/core/6561b34a.js":[],"static/core/66619f08.js":[],"static/core/69789892.js":["static/core/bfb25e63.js","static/core/d6929171.js","static/core/1594df08.js"],"static/core/6bc1c806.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/6dcb28a1.js":[],"static/core/6f7a2152.js":["static/core/bfb25e63.js"],"static/core/91f77c2d.js":["static/core/3f80e59d.js","__delivery__/libs"],"static/core/9f4f4873.js":[],"static/core/a34a72bf.js":["static/core/57fee71e.js","static/core/3f80e59d.js","__delivery__/libs","static/core/1516d48e.js"],"static/core/bfb25e63.js":[],"static/core/c8fe849c.js":[],"static/core/cea06bde.js":[],"static/core/cf548c07.js":[],"static/core/d6929171.js":[],"static/core/dcc37768.js":[],"static/core/def48fbd.js":["static/core/1516d48e.js","static/core/57fee71e.js","static/core/29e211b1.js","static/core/91f77c2d.js","__delivery__/libs"],"static/core/e460bb13.js":["__delivery__/libs"],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/e7620593.js":[],"static/core/f0c51560.js":[],"static/core/f369973d.js":[],"static/core/f9749132.js":["static/core/1516d48e.js","static/core/49be45c4.js","__delivery__/libs"],"static/core/fb2fe2db.js":[],"static/monaco/editor.api-C9c1WLns.js":[],"monaco":["static/monaco/editor.api-C9c1WLns.js","static/monaco/lspLanguageFeatures-DY3n8M13.js"],"static/monaco/lspLanguageFeatures-DY3n8M13.js":["static/monaco/editor.api-C9c1WLns.js"],"compat-globals.js":["static/esm/971f1b2c.js"],"static/esm/delivery-libs.js":[],"useblocks-esm.js":["static/esm/971f1b2c.js","static/esm/f97f84b4.js","static/esm/f76c9d9d.js"],"static/esm/2490dab8.js":["static/esm/971f1b2c.js"],"static/esm/971f1b2c.js":[],"static/esm/f76c9d9d.js":[],"static/esm/f97f84b4.js":[]},"bundles":{"static/core/3f80e59d.js":["static/core/4e2a8577.js","static/core/93400c34.js","static/core/cac0a15e.js"],"static/core/6f7a2152.js":["static/core/a71c4cd8.js"],"static/core/f9749132.js":["static/core/f74fd241.js"],"static/core/91f77c2d.js":["static/core/a73da823.js"],"static/core/a34a72bf.js":["static/core/1c32f16d.js"],"core":["static/core/2ff39ddf.js","static/core/1ad5ec50.js","static/core/a73793d3.js","static/core/3acf6b43.js","static/core/8ec16126.js"]}});