@emailmaker/emailmaker 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 -1
  2. package/emailmaker-core.fec11667.js +859 -0
  3. package/emailmaker-esm.js +11 -11
  4. package/{emailmaker-po.d5e4bde1.js → emailmaker-po.fec11667.js} +1 -1
  5. package/emailmaker.d.ts +220 -1
  6. package/emailmaker.js +12 -12
  7. package/iframe/.vite/manifest.json +4 -4
  8. package/iframe/{iframe-eblock.d5e4bde1.html → iframe-eblock.fec11667.html} +2 -2
  9. package/iframe/{iframe.d5e4bde1.html → iframe.fec11667.html} +2 -2
  10. package/iframe/js/{elMarkupHelper.C66zL1zp.js → elMarkupHelper.Dv3AYDYP.js} +79 -79
  11. package/iframe/js/{iframe-eblock.body.d5e4bde1.js → iframe-eblock.body.fec11667.js} +1 -1
  12. package/iframe/js/iframe-eblock.js +2 -2
  13. package/iframe/js/{iframe.body.d5e4bde1.js → iframe.body.fec11667.js} +1 -1
  14. package/iframe/js/iframe.js +2 -2
  15. package/package.json +1 -1
  16. package/runtime/react/index.js +1 -1
  17. package/static/core/{6ba8aedc.js → 29b3ccef.js} +1 -1
  18. package/static/core/{edf49656.js → 2e70fae0.js} +3 -3
  19. package/static/core/{e1f8b6ea.js → 44fac8d4.js} +1 -1
  20. package/static/core/{6f6a92e3.js → 5c4239d8.js} +1 -1
  21. package/static/core/{7e51da74.js → 64c27f91.js} +1 -1
  22. package/static/core/{b916e437.js → 727a165f.js} +1 -1
  23. package/static/core/{dbc12df7.js → 790366d3.js} +1 -1
  24. package/static/core/{2734fa96.js → 7be64bf5.js} +1 -1
  25. package/static/core/{22140fa1.js → 7d006e7b.js} +1 -1
  26. package/static/core/{7985de17.js → 83d2ca5d.js} +6 -6
  27. package/static/core/{d8800deb.js → 8b89090c.js} +1 -1
  28. package/static/core/{8a621181.js → 8da91a53.js} +1 -1
  29. package/static/core/{13b2a363.js → 99c15a5d.js} +1 -1
  30. package/static/core/{ecaf7c36.js → 9f7e0f94.js} +1 -1
  31. package/static/core/a2c7aeb0.js +1 -0
  32. package/static/core/{d74c1e57.js → a9235d9e.js} +1 -1
  33. package/static/core/{566e8ce8.js → b27aec0b.js} +1 -1
  34. package/static/core/{6e8d008d.js → b74171bd.js} +1 -1
  35. package/static/core/{8889dbc6.js → b7dee12b.js} +1 -1
  36. package/static/core/{b43852b9.js → bbb87124.js} +1 -1
  37. package/static/core/{756e184f.js → c5713f94.js} +1 -1
  38. package/static/core/{f37da79c.js → ccb090eb.js} +1 -1
  39. package/static/core/{6c52be40.js → db685f4e.js} +1 -1
  40. package/static/core/{d5cd2a7b.js → e15ab856.js} +1 -1
  41. package/static/core/{3a6dbf2b.js → e7bbe544.js} +1 -1
  42. package/static/core/{7e69b03c.js → ec5f739e.js} +1 -1
  43. package/static/core/{f20ffa90.js → f2ced98d.js} +2 -2
  44. package/static/core/{2455e45e.js → f54ef492.js} +1 -1
  45. package/static/esm/ae0fe329.js +1 -0
  46. package/static/umd-runtime/runtime.CunK0nEC.js +1 -0
  47. package/vendor/@emailmaker/ui-kit/package.json +1 -1
  48. package/emailmaker-core.d5e4bde1.js +0 -859
  49. package/static/core/a22823f9.js +0 -1
  50. package/static/esm/73c89921.js +0 -1
  51. package/static/umd-runtime/runtime.BZcjM8iG.js +0 -1
package/emailmaker.js CHANGED
@@ -1014,7 +1014,7 @@ var __amdEnv = window.__emailmaker__ || (window.__emailmaker__ = {});
1014
1014
 
1015
1015
 
1016
1016
  // Configure AMD loader
1017
- __amdEnv.require.config({ baseUrl: "./", paths: {"core":"emailmaker-core.d5e4bde1.js","monaco":"static/monaco/index.CCINpETE.js","po":"emailmaker-po.d5e4bde1.js","static/umd-runtime/delivery-libs.js":"static/umd-runtime/delivery-libs.eFZaeVgo.js","static/umd-runtime/runtime.js":"static/umd-runtime/runtime.BZcjM8iG.js","static/umd-runtime/ui-kit-icons.js":"static/umd-runtime/ui-kit-icons.CSCUi7bp.js","static/umd-runtime/ui-kit.js":"static/umd-runtime/ui-kit.nmR1Bl60.js"} });
1017
+ __amdEnv.require.config({ baseUrl: "./", paths: {"core":"emailmaker-core.fec11667.js","monaco":"static/monaco/index.CCINpETE.js","po":"emailmaker-po.fec11667.js","static/umd-runtime/delivery-libs.js":"static/umd-runtime/delivery-libs.eFZaeVgo.js","static/umd-runtime/runtime.js":"static/umd-runtime/runtime.CunK0nEC.js","static/umd-runtime/ui-kit-icons.js":"static/umd-runtime/ui-kit-icons.CSCUi7bp.js","static/umd-runtime/ui-kit.js":"static/umd-runtime/ui-kit.nmR1Bl60.js"} });
1018
1018
 
1019
1019
  // PublicPath (script detection: entry script lookup → document.currentScript)
1020
1020
  if (!__emailmaker__.publicPath) {
@@ -1362,7 +1362,7 @@ if (!ns.assetUrl) {
1362
1362
  }
1363
1363
 
1364
1364
  if (!ns.version) {
1365
- ns.version = "1.1.108";
1365
+ ns.version = "1.2.0";
1366
1366
  }
1367
1367
 
1368
1368
  var modules = ns.modules = Object.create(null);
@@ -2093,20 +2093,20 @@ if (typeof ns.define === 'function') {
2093
2093
  __emailmaker__.define("static/umd/790cf6cb.js",["require","exports","module"],function(y,_,w){var p=Object.create,a=Object.defineProperty,i=Object.getOwnPropertyDescriptor,b=Object.getOwnPropertyNames,f=Object.getPrototypeOf,o=Object.prototype.hasOwnProperty,O=(e,r)=>()=>(r||(e((r={exports:{}}).exports,r),e=null),r.exports),v=(e,r)=>{let t={};for(var u in e)a(t,u,{get:e[u],enumerable:!0});return r||a(t,Symbol.toStringTag,{value:"Module"}),t},P=(e,r,t,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(var c=b(r),l=0,j=c.length,n;l<j;l++)n=c[l],!o.call(e,n)&&n!==t&&a(e,n,{get:(s=>r[s]).bind(null,n),enumerable:!(u=i(r,n))||u.enumerable});return e},g=(e,r,t)=>(t=e!=null?p(f(e)):{},P(r||!e||!e.__esModule||!o.call(e,"default")?a(t,"default",{value:e,enumerable:!0}):t,e));Object.defineProperty(_,"__commonJSMin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(_,"__exportAll",{enumerable:!0,get:function(){return v}}),Object.defineProperty(_,"__toESM",{enumerable:!0,get:function(){return g}})});
2094
2094
 
2095
2095
 
2096
- __emailmaker__.define("static/umd/312a9b80.js",["require","exports","module"],function(Rn,c,wn){var A=class ct{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof ct&&t.addDispose(()=>{this.removeDisposable(t)}),t}addDispose(t){this.addDisposable({dispose:t})}removeDisposable(t){const r=this._inner.indexOf(t);r>=0&&this._inner.splice(r,1)}isDisposed(){return this._isDisposed}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(const t of[...this._inner])t.dispose()}}};function M(e){return`service_container_${e}`}var P=new Set,X;function ut(){if(!X)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,se.prototype.getInstanceAsync),e.stack}function V(e){P.delete(e)&&X?.end(e)}var se=class oe extends A{_parent;_injectCallbacks=[];_injections=Object.create(null);_runCallbacks(t){[...this._injectCallbacks].forEach(r=>r(t))}constructor(t=null){super(),this._parent=t,t&&this.addDisposable(t.onInject(r=>this._runCallbacks(r)))}onInject=t=>(this._injectCallbacks.push(t),{dispose:()=>{const r=this._injectCallbacks.indexOf(t);r>=0&&this._injectCallbacks.splice(r,1)}});inject(t,r){this._injections[t]=()=>r,this._runCallbacks(t)}injectFactory(t,r,n){const i=this._injections[t];let o=typeof i=="function"?i():i;const s=this._injections[t]=()=>(o=r(this,o),o);n&&s(),this._runCallbacks(t)}_find(t,r=!0){return this._injections[t]||r&&this._parent?._find(t)}_onInject(t,r,n=new A){return n.addDisposable(this.onInject(i=>{t===i&&!n.isDisposed()&&(n.dispose(),r(this.getInstance(i)))})),this._parent&&n.addDisposable(this._parent._onInject(t,r,n)),this.addDisposable(n),n}getInstance(t,r=!0){const n=this._find(t,r);if(typeof n=="function")return n()}getOrCreateInstance(t,r){const n=this._find(t);if(typeof n=="function")return n();const i=r(this);return this.inject(t,i),i}getInstanceAsync(t){const r=this._find(t);if(typeof r=="function")return Promise.resolve(r());const n=ut();return new Promise((i,o)=>{const s={id:String(t),startedAt:Date.now(),origin:n,container:this,reject:o};P.add(s),X?.start(s),this._onInject(t,()=>{V(s),i(this.getInstance(t))})})}failPendingWaits(t){for(const r of Array.from(P))r.container===this&&(V(r),r.reject(t))}pendingWaits(){return[...P].filter(t=>t.container===this)}addService(t,r){const n=M(t);this.injectFactory(n,(o,s=[])=>s.indexOf(r)<0?[...s,r]:s);const i=new A;return i.addDispose(()=>{this.injectFactory(n,(o,s=[])=>s.filter(a=>a!==r))}),i}addServiceFactory(t,r,n){const i=M(t);let o;this.injectFactory(i,(a,u=[])=>(o=r(a,o),o===void 0?u:u.indexOf(o)<0?[...u,o]:u),n);const s=new A;return s.addDispose(()=>{this.injectFactory(i,(a,u=[])=>o===void 0?u:u.filter(_=>_!==o))}),s}getServices(t){const r=M(t);return[...this.getInstance(r,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new oe(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const r=this._parent?.getOrCreateIsolatedContainer(t);return new oe(r)})}remove(t){const r=this._injections;delete r[String(t)]}injectListenerCount(){return this._injectCallbacks.length}dispose(){for(const t of Array.from(P))t.container===this&&V(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function $(e){return e.startsWith("__")?e:`__${e}__`}function _t(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=$(e),r=globalThis;return r[t]??={}}function lt(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function dt(e){if(e)return $(e);const t="emailmaker".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return $(t)}function ae(e){const t=dt(e),r=_t(t);if(lt(r.container))return r.container;const n=new se(null);return r.container=n,n}function ft(e){return ae(e)}function pt(){let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let n=Math.random()*16;return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),(r==="x"?n:n&3|8).toString(16)})}function ce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():pt()}function f(e=ce()){return e}function ue(){return"umd".trim()||"unknown"}function Et(e){if(typeof globalThis>"u")return;const t=ue(),r=globalThis[e]??{};globalThis[e]=r;const n=r.__diagnostics??={},i=n.diModuleEval??={evalCount:0,records:[]};i.records.push({buildSource:t,timestamp:Date.now(),stack:new Error().stack}),i.evalCount+=1}function ht(){const e="emailmaker".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function Ot(e,t){if(Et(t),typeof globalThis>"u")return e;const r=ue(),n=globalThis,i=n[t]=n[t]||{},o=i.__diagnostics=i.__diagnostics||{},s=o.dependencyResolver=o.dependencyResolver||{entries:[]},a={container:e,source:"packages/runtime-core/di/index.ts",buildSource:r,timestamp:Date.now(),stack:new Error().stack};return s.entries.push(a),e}var B;function mt(){if(B)return B;const e=ht();return B=Ot(ae(e),e),B}var W=new Proxy({},{get(e,t,r){const n=mt(),i=Reflect.get(n,t,r);return typeof i=="function"?i.bind(n):i}});function gt(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}function S(e){if(e instanceof DOMException&&e.name==="AbortError")return e;const t=e===void 0?"The operation was aborted.":typeof e=="string"?e:e instanceof Error?e.message:String(e);return new DOMException(t,"AbortError")}function At(e){return e instanceof DOMException&&e.name==="AbortError"}function K(e){if(e?.aborted)throw S(e.reason)}function It(e,t){return t?(t.aborted&&e.catch(()=>{}),K(t),new Promise((r,n)=>{const i=()=>{o(),n(S(t.reason))},o=()=>{t.removeEventListener("abort",i)};t.addEventListener("abort",i),e.then(s=>{o(),r(s)},s=>{o(),n(s)})})):e}var _e=class extends A{_options;_listeners=[];constructor(e={}){super(),this._options=e}getListeners(e){return this._listeners.flatMap(([t])=>typeof t=="function"?t:t.getListeners(e))}hasListeners(){for(const[e]of this._listeners){if(typeof e=="function")return!0;const t=e;if(typeof t.hasListeners=="function"){if(t.hasListeners())return!0;continue}return!0}return!1}_addListener(e,t=0,r){if(this.isDisposed())return{dispose:()=>{}};const n=this._listeners,i=this._options;r&&typeof e=="function"&&(e=e.bind(r));const o=n.findIndex(([,a])=>a<t),s=[e,t];return n.splice(o>=0?o:n.length,0,s),n.length===1&&i.onFirstListenerAdd&&i.onFirstListenerAdd(),{dispose:()=>{const a=n.indexOf(s);a>=0&&(n.splice(a,1),!n.length&&i.onLastListenerRemove&&i.onLastListenerRemove())}}}on=this._addListener.bind(this);event=this._addListener.bind(this);once=(e,t=0,r)=>{const n=this._addListener((...i)=>(n?.dispose(),r?e.call(r,...i):e(...i)),t);return n};un=e=>{const t=this._listeners.findIndex(([r])=>r===e);t>=0&&(this._listeners.splice(t,1),this._listeners.length===0&&this._options.onLastListenerRemove&&this._options.onLastListenerRemove())};dispose(){this._listeners.splice(0,this._listeners.length),this._options.onLastListenerRemove&&this._options.onLastListenerRemove(),super.dispose()}},b=class extends _e{execute(e,t){for(const r of t)try{r(...e)}catch{}}fire(...e){if(!this.isDisposed()){const t=this.execute(e,this.getListeners(e));return t===void 0?void 0:t}}},Tt=class extends b{execute([e],t){for(const r of t)try{r(e)}catch{}}},St=class extends b{_suspendCounter=0;_wasFired=!1;execute([e],t){if(this._suspendCounter)this._wasFired=!0;else for(const r of t)try{r(e)}catch{}}suspend(){this._suspendCounter++}resume(){--this._suspendCounter===0&&this._wasFired&&(this.fire(),this._wasFired=!1)}},j=class extends b{async execute([e],t){const r=[];for(const n of t)try{r.push(await n(e))}catch{}return r}async fireSettled(e){const t={results:[],errors:[]};if(this.isDisposed())return t;for(const r of this.getListeners([e]))try{t.results.push(await r(e))}catch(n){t.errors.push(n)}return t}};function bt(e,t=0){const r=new _e,n=e(r,t);return n&&r.addDisposable(n),r.event}function Dt(e,t,r=0){const n=new b,i=e((...o)=>{if(t(...o))return n.fire(...o)},r);return i&&n.addDisposable(i),n.event}function Nt(e,t=0,r=0){const n=new b;let i,o;const s=e((...a)=>{o=a,i||(i=setTimeout(()=>{o&&n.fire(...o),i=void 0},t))},r);return s&&n.addDisposable(s),n.event}function yt(e,t){return e.getOrCreateInstance(t,()=>new j)}function d(e){return f(e)}var q;(function(e){e.BEFORE_SAVE_EMAIL=d("events.BEFORE_SAVE_EMAIL"),e.ON_SAVEBUTTON_CLICK_ID=d("events.ON_SAVEBUTTON_CLICK_ID"),e.ON_NEXTBUTTON_CLICK_ID=d("events.ON_NEXTBUTTON_CLICK_ID"),e.ON_PREVIOUSBUTTON_CLICK_ID=d("events.ON_PREVIOUSBUTTON_CLICK_ID"),e.ON_DOCUMENT_SESSION_CHANGE=d("events.ON_DOCUMENT_SESSION_CHANGE"),e.WILL_EMAIL_INIT_ID=d("events.WILL_EMAIL_INIT_ID"),e.ON_EMAIL_INIT_ID=d("events.ON_EMAIL_INIT_ID"),e.ON_BLOCK_INIT_ID=d("events.ON_BLOCK_INIT_ID"),e.ON_CONTENT_CHANGED_ID=d("events.ON_CONTENT_CHANGED_ID"),e.ON_PREHEADER_CHANGED_ID=d("events.ON_PREHEADER_CHANGED_ID"),e.ON_SUBJECT_CHANGED_ID=d("events.ON_SUBJECT_CHANGED_ID"),e.ON_EMAIL_CHANGED_ID=d("events.ON_EMAIL_CHANGED_ID"),e.ON_HEADER_APPLIED_ID=d("events.ON_HEADER_APPLIED_ID"),e.ON_BLOCK_CHANGED_ID=d("events.ON_BLOCK_CHANGED_ID"),e.ON_BLOCK_OPEN_ID=d("events.ON_BLOCK_OPEN_ID"),e.ON_BLOCK_CLOSE_ID=d("events.ON_BLOCK_CLOSE_ID"),e.OPEN_BLOCK_REQUEST_ID=d("events.OPEN_BLOCK_REQUEST_ID"),e.ON_BLOCK_SAVEBUTTON_CLICK_ID=d("events.ON_BLOCK_SAVEBUTTON_CLICK_ID"),e.ON_BLOCK_CLONE_ID=d("events.ON_BLOCK_CLONE_ID"),e.ON_CHUNKS_LOADED=d("events.ON_CHUNKS_LOADED"),e.ON_SEND_TESTEMAIL_ID=d("events.ON_SEND_TESTEMAIL_ID"),e.ON_SEND_LIVEPREVIEW_ID=d("events.ON_SEND_LIVEPREVIEW_ID"),e.ON_SHARE_ID=d("events.ON_SHARE_ID"),e.ON_SHOW_PREVIEW_ID=d("events.ON_SHOW_PREVIEW_ID"),e.ON_EMAIL_CLONE_ID=d("events.ON_EMAIL_CLONE_ID"),e.ON_SEND_EMAIL_MODAL_ID=d("events.ON_SEND_EMAIL_MODAL_ID"),e.ON_NOTIFICATION=d("events.ON_NOTIFICATION"),e.READ_LOCALE=d("events.READ_LOCALE"),e.ON_TRANSLATE_ID=d("events.ON_TRANSLATE_ID"),e.ON_CODE_VALIDATE_ID=d("events.ON_CODE_VALIDATE_ID"),e.UPLOAD_EVENT_ID=d("events.UPLOAD_EVENT_ID"),e.PROXY_URL_EVENT_ID=d("events.PROXY_URL_EVENT_ID"),e.FILE_PROXY_EVENT_ID=d("events.FILE_PROXY_EVENT_ID"),e.ON_LIMIT_ID=d("events.ON_LIMIT_ID"),e.ON_BROWSER_EXTENSION_DETECTED_ID=d("events.ON_BROWSER_EXTENSION_DETECTED_ID"),e.ON_LAYOUT_CONVERT_REQUEST_ID=d("events.ON_LAYOUT_CONVERT_REQUEST_ID"),e.ON_BROWSER_TRANSLATE_DETECTED_ID=d("events.ON_BROWSER_TRANSLATE_DETECTED_ID"),e.AI_TEXT_REQUEST_ID=d("events.AI_TEXT_REQUEST_ID"),e.AI_IMAGE_REQUEST_ID=d("events.AI_IMAGE_REQUEST_ID"),e.AI_TEXT_PROGRESS_ID=d("events.AI_TEXT_PROGRESS_ID"),e.AI_IMAGE_PROGRESS_ID=d("events.AI_IMAGE_PROGRESS_ID"),e.AI_TEXT_STREAM_ID=d("events.AI_TEXT_STREAM_ID")})(q||(q={}));function Pt(e,t){return e.getOrCreateInstance(t,()=>new j).event}function Ct(e,t){return e.getOrCreateInstance(t,()=>new j)}var Lt=f("plugin.app"),vt=f("plugin.disposable"),Rt=f("InitPipelineContext"),wt=f("plugin.instance"),Mt=f("plugin.lateSurfaceListeners"),le=f("plugin.optionsSource"),Bt=f("plugin.store"),de=f("ConfigSource"),jt=f("plugin.standalone.project"),fe=f("plugin.standalone.bootstrapToken"),Mn=f("plugin.element"),pe=f("plugin.securityModule"),Ft=f("plugin.standalone.activated"),xt=f("plugin.standalone.fileProxyRegistered"),z=f("plugin.jwt.token"),C=f("plugin.jwt.error"),kt=f("PluginCollection"),Ut=d("APP_LOAD_EVENT"),Ht=d("CONFIG_CHANGED_EVENT");function Gt(e,t=window){return{peer:e,send(r){e.postMessage(r,"*")},subscribe(r){const n=i=>{r({data:i.data,source:i.source,ports:i.ports})};return t.addEventListener("message",n),{dispose:()=>t.removeEventListener("message",n)}},close(){}}}function Xt(e){let t=!1;return{peer:e,send(r){e.postMessage(r)},subscribe(r){const n=i=>{r({data:i.data,source:e})};return e.addEventListener("message",n),t||(t=!0,e.start()),{dispose:()=>e.removeEventListener("message",n)}},close(){e.close()}}}function Vt(e){return e}function $t(e){return e&&typeof e=="object"}function Ee(e,t){return e&&typeof e=="object"&&e.operationId===t}var T="INIT_MESSAGE",he="em:port-ready",Wt="em:window-drained",Y="";function Oe(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var Kt=class extends A{_listeners=Object.create(null);addListenerAsync=(e,t,r=0,n)=>{const i=this._listeners[e]||(this._listeners[e]=[]);n&&typeof t=="function"&&(t=t.bind(n));const o=i.findIndex(([a,u])=>r<=u),s=[t,r];return this.isDisposed()||i.splice(o>=0?o:i.length,0,s),{dispose(){const a=i.indexOf(s);a>=0&&i.splice(a,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const r=this._listeners[e]||(this._listeners[e]=[]);let n;for(let i=0;i<r.length;i++){const o=r[i][0],s=n;n=a=>o(a,s)}if(n)return n(t)}};addListener=(e,t,r=0)=>this.addListenerAsync(e,(n,i)=>{try{t(n)}catch{}return i&&i(n)},r)},qt=class extends A{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_portSendHeld=new WeakSet;_inited=!1;_emitter=this.addDisposable(new Kt);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;_outgoingObservers=new Set;_offTargetListeners=new Map;constructor(e,t){super(),this._singleton=t,this._transport=Gt({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(T,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(T))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,r=t.data,n=t.source,i=r?.port===!0?t.ports?.[0]:void 0,o=!this._isPortSource(t.source);if(o&&n&&r?.operationId==="em:window-drained"){this._ports.has(n)&&this._drained.add(n);return}if(o&&n&&this._drained.has(n))return;if(n&&n!==this._target&&this._greeted.has(n)&&Ee(r,T)){this._greeted.delete(n),this._handshaken.add(n),this._postMessage(n,{operationId:T,data:{}}),i&&this.usePort(i,!0,n);return}const s=t.source===this.target||this._isCurrentPort(t.source);if(s||this._notifyOffTarget(r?.operationId,t.source),$t(r)&&s||this._singleton&&Ee(r,T)){if(i&&s){const l=this._target;Promise.resolve().then(()=>this.usePort(i,!0,l))}const a=this._emitter.fireAsync(r.operationId||Y,r.operationId===void 0?t:r.data),u=r.result,_=r.error;u&&_&&Promise.resolve(a).then(l=>this._sendMessage(u,l),l=>this._sendMessage(_,l))}};setTarget(e){if(this._target!==e){if(this._target=e,!e){this._inited=!1;return}if(this._handshaken.has(e)){this._inited=!0,this._emitter.fireAsync(T,void 0);return}this._inited=!1,this._postMessage(e,{operationId:T,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:T,data:{},port:!0},[t])}observeOutgoing(e){return this._outgoingObservers.add(e),{dispose:()=>{this._outgoingObservers.delete(e)}}}_notifyOutgoing(e,t){for(const r of Array.from(this._outgoingObservers))try{r(e,t)}catch{}}addOffTargetListener(e,t){let r=this._offTargetListeners.get(e);return r||(r=new Set,this._offTargetListeners.set(e,r)),r.add(t),{dispose:()=>{r.delete(t)}}}_notifyOffTarget(e,t){const r=typeof e=="string"?this._offTargetListeners.get(e):void 0,n=r?.size?this._knownPeer(t):void 0;if(!(!r||!n))for(const i of Array.from(r))try{i(n)}catch{}}_knownPeer(e){for(const[r,n]of this._ports)if(n.transport.peer===e)return r;const t=e;return typeof e=="object"&&e!==null&&(this._handshaken.has(t)||this._greeted.has(t))?t:void 0}setOutgoingFilter(e){return this._outgoingFilter=e,()=>{this._outgoingFilter===e&&(this._outgoingFilter=void 0)}}sendNow(e){const t=this._target;return!this._inited||!t?!1:(this._postMessage(t,e),!0)}greet(e){this._handshaken.has(e)||this._greeted.has(e)||this._target===e||(this._greeted.add(e),this._postMessage(e,{operationId:T,data:{}}))}forget(e){this._handshaken.delete(e),this._greeted.delete(e),this._closePort(e),this._drained.delete(e),this._target===e&&(this._inited=!1)}usePort(e,t=!1,r=this._target){if(!r||this._ports.has(r))return;const n=Xt(e),i=n.subscribe(this._onTransportMessage);this._ports.set(r,{transport:n,subscription:i}),t&&(n.send({operationId:he,data:{}}),this.drainWindow(r))}holdPort(e=this._target){!e||!this._ports.has(e)||(this._portSendHeld.add(e),this._drained.delete(e))}resumePort(e=this._target){e&&this._portSendHeld.delete(e)}useWindow(e=this._target){e&&(this._closePort(e),this._drained.delete(e))}get usesPort(){return this._target!==void 0&&this._ports.has(this._target)&&!this._portSendHeld.has(this._target)}hasPort(e,t){const r=this._ports.get(e);return r!==void 0&&(t===void 0||r.transport.peer===t)}_closePort(e){const t=this._ports.get(e);t&&(t.subscription.dispose(),t.transport.close(),this._ports.delete(e),this._portSendHeld.delete(e))}drainWindow(e){this._ports.has(e)&&e.postMessage({operationId:Wt,data:{}},"*")}isWindowDrained(e){return this._drained.has(e)}_isPortSource(e){for(const t of this._ports.values())if(t.transport.peer===e)return!0;return!1}_isCurrentPort(e){return this._target!==void 0&&this._ports.get(this._target)?.transport.peer===e}getTarget(){return this._target}get target(){return this._target}_postMessage(e,t,r){let n=t;this._outgoingFilter&&!r?.length&&(n="data"in t?{...t,data:this._outgoingFilter(t.data)}:this._outgoingFilter(t));try{const i=this._ports.get(e);if(i&&!this._portSendHeld.has(e)){i.transport.send(n);return}if(r?.length){e.postMessage(n,"*",r);return}e.postMessage(n,"*")}catch(i){if(i?.name==="DataCloneError"){const o=typeof n?.data=="object"&&n?.data!==null?n.data:void 0}throw i}}_sendMessage(e,t,r=!0){if(!r&&!this.isInited())return;e&&this._notifyOutgoing(e,t);const n=this.addDisposable(this.onInit(i=>{const o=e?{operationId:e,data:t}:t;try{this._postMessage(i,{...o})}finally{n.dispose()}}))}send(e,t,r){return typeof e=="string"?this._sendMessage(e,t,r):this._sendMessage(Y,e,t)}sendAsync(e,t,r=!0){if(!r&&!this.isInited())return Promise.resolve();this._notifyOutgoing(e,t);const n=Oe(),i=Oe();return new Promise((o,s)=>{const a=this.addDisposable(new A);a.addDisposable(this.onInit(u=>{try{this._postMessage(u,{operationId:e,data:t,result:n,error:i})}catch(_){a.dispose(),s(_);return}a.addDisposable(this._onMessage(n,_=>{o(_),a.dispose()})),a.addDisposable(this._onMessage(i,_=>{s(_),a.dispose()}))}))})}_onMessage(e,t,r=0){return this._emitter.addListener(e,t,r)}addListener(e,t,r){return t?this._onMessage(e,t,r):this._onMessage(Y,e)}addListenerAsyncPipe(e,t,r=0){return this._emitter.addListenerAsync(e,t,r)}addListenerAsync(e,t,r=0){return this._emitter.addListenerAsync(e,async(n,i)=>{const o=await t(n);return i?i(n):o},r)}isInited(){return this._inited}get inited(){return this._inited}onInit(e,t=!0,r=0){const n=this.addDisposable(new A);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?n.addDisposable(this.onInit(e,t,r)):e(this._target)}):n.addDisposable(this._onMessage(T,()=>{e(this._target)},r)),n}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function L(e){return f(e)}var zt=f("extensions.atomsHandlers"),Yt=L("HANDLE_ATOM_INSERT"),Jt=f("HeadlessMode"),Qt=f("extensions.sandboxExtensions"),Zt="SANDBOX_EXTENSION_SCRIPT_STATUS",er=f("MESSAGE_SERVICE"),tr=L("SETTINGS_PANEL_EVENT"),rr="advanced",nr=L("MODAL_SHOW_EVENT"),ir=L("MODAL_CLOSE_EVENT"),or=L("MODAL_UPDATE_EVENT"),Bn=f("client"),jn=f("v2_client"),Fn=f("ai_client"),sr=f("app.cookieManager"),xn=f("app.storageProvider"),kn=f("image-blob-resolver"),ar=f("template-directives"),cr=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),ur=class{baseUrl="https://api.emailmaker.ru/wp-json";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(r=>this.encodeQueryParam(t,r)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(r=>typeof t[r]<"u").map(r=>Array.isArray(t[r])?this.addArrayQueryParam(t,r):this.addQueryParam(t,r)).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,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce((t,r)=>{const n=e[r];return t.append(r,n instanceof Blob?n:typeof n=="object"&&n!==null?JSON.stringify(n):`${n}`),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 r=this.abortControllers.get(e);return r?r.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))};async request({body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:a,extraQuery:u,proxyHandler:_,...l}){const p=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},h=this.mergeRequestParams(l,p);u&&(i=i?{...i,...u}:u);const E=i&&this.toQueryString(i),g=this.contentFormatters[n||"application/json"],O=o||h.format,H=`${s||this.baseUrl||""}${r}${E?`?${E}`:""}`,Ln=_?_(H,{body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:a,extraQuery:u,proxyHandler:_,...l}):H,st=new Request(Ln,{...h,headers:{...h.headers||{},...n&&n!=="multipart/form-data"?{"Content-Type":n}:{}},signal:(a?this.createAbortSignal(a):h.signal)||null,body:typeof e>"u"||e===null?null:g(e)});return this.customFetch(st).then(async at=>{const I=at;I.data=null,I.error=null,I.meta={request:st,response:I};const vn=O?await at[O]().then(G=>(I.ok?I.data=G:I.error={data:G},I)).catch(G=>(I.error=G,I)):I;return a&&this.abortControllers.delete(a),vn})}},_r=f("prewarm.networkActivity");function lr(){let e=0;const t=new Set,r=()=>{t.forEach(n=>n())};return{begin(){e+=1,r();let n=!1;return()=>{n||(n=!0,e-=1,r())}},inFlight:()=>e,watch(n){return t.add(n),()=>t.delete(n)}}}function dr(e){return e.getOrCreateInstance(_r,()=>lr())}var me=Symbol("rest.publicRequest"),F=f("rest.requestHandler"),fr=f("rest.responseHandler"),J=f("rest.customFetch"),pr=(e,t)=>fetch(e,t),Q=f("rest_transport"),Er=e=>{e.inject(J,{execute:async(t,r={})=>{const n=e.getServices(F),i={public:r[me]===!0},o=dr(e).begin();try{let s=t instanceof Request?t:new Request(t,r);for(const _ of n){const l=await _.execute(s,i);l instanceof Request&&(s=l)}let a=await fetch(s);const u=e.getServices(fr);for(const _ of u)a=await _.execute(a,s);return a}finally{o()}}})};function hr(e,t){const r=e.getInstance(Q);if(!r)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(n=>new n(r)))}var Or="INJECTION";function mr(e){return e.getState}function gr(e){if(!mr(e)){e.dispose();return}const t=e.getState()[Or];t&&(W.getInstance(t)?.dispose(),W.remove(t))}function Ar(e,t){for(const r of e)if(r&&t in r)return r[t]}function ge(e){return Object.assign({},...e)}var Ae=["generic","stockImages","emFiles","cdn"];function Z(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ie(e){return!Z(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>Ae.includes(t))}function Te(e){return e.length===0?[]:e.length===1?e[0]:e}function Se(e){let t=!1,r=[];for(const n of e)if(n!==void 0){if(t=!0,Array.isArray(n)){r=[...n,...r];continue}r=[n,...r]}if(t)return Te(r)}function Ir(e){return Z(e)&&("value"in e||"replace"in e)}function be(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function Tr(e){let t=!1,r=[],n=!1;for(const o of e)if(o!==void 0){if(Ir(o)){t=!0,o.replace&&(r=[],n=!0),o.value!==void 0&&(r=be(r,o.value),n=!0);continue}r=be(r,o),n=!0}const i=n?Te(r):void 0;if(!t)return i;if(i!==void 0)return{value:i}}function Sr(e){const t=e.filter(n=>n!==void 0);if(t.length===0)return;if(!t.some(n=>Ie(n)))return Se(t);const r={};for(const n of Ae){const i=Tr(e.map(o=>{if(o!==void 0)return Ie(o)?o[n]:n==="generic"?o:void 0}));i!==void 0&&(r[n]=i)}return Object.keys(r).length>0?r:void 0}function br(e){return Se(e)}function Dr(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(Z(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function Nr(e,t){const r=[...e],n=new Set(r.map(i=>i.toLowerCase()));for(const i of t){const o=i.trim().replace(/:\d+$/,"");if(!o)continue;const s=o.toLowerCase();n.has(s)||(n.add(s),r.push(o))}return r}function yr(e){let t=[],r=!1;for(const n of e){const i=Dr(n);i&&(r=!0,i.replace&&(t=[]),t=Nr(t,i.hosts))}return r?t:void 0}function Pr(e){const t=e.filter(i=>i!==void 0);if(t.length===0)return;const r=ge(t.map(({directHosts:i,...o})=>o)),n=yr(t.map(i=>i?.directHosts));return n!==void 0&&(r.directHosts=n),r}function ee(e){return e?.backendProxy}function v(e){return e.replace(/\/$/,"")}function De(e){return/^https?:\/\//i.test(e)}function Ne(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Cr(e){const t=new Set;return e.filter(r=>!r.url||t.has(r.url)?!1:(t.add(r.url),!0))}function Lr(e){const t=ee(e);return t?[t]:[]}function vr(e){return{proxyEmFiles:!0,proxyAi:!1}}function Rr(e,t){const r=vr(t),n=t?.backendProxyPolicy;switch(e){case"emFiles":return n?.proxyEmFiles??r.proxyEmFiles;case"ai":return n?.proxyAi??r.proxyAi;default:return!0}}var wr={url:".+",url_encoded:".+",origin:"https?:\\/\\/[^\\/?#]+",origin_encoded:".+",proxy_url:"https?:\\/\\/[^\\/?#]+",proxy_url_encoded:".+",path:"[^?#]*",pathname:"[^?#]*",path_with_slash:"\\/[^?#]*",pathname_with_slash:"\\/[^?#]*",query:"[^#]*",search:"\\?[^#]*",hash:"#.*",fragment:".*",pathname_after_wp_json:"[^?#]*",pathname_after_wp_json_with_slash:"\\/[^?#]*",rest_namespace:"[^/?#]*",rest_version:"[^/?#]*",rest_route:"[^?#]*",rest_route_with_slash:"\\/[^?#]*"};function Mr(e){const t=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(n,i)=>(t.push(i),`(${wr[i]||".+"})`));return{regex:new RegExp(`^${r}$`,"i"),tokens:t}}function Br(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function jr(e,t){if(Br(t))return e;try{const r=new URL(e);return`${r.origin}${r.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function Fr(e,t,r){if(r.endsWith("_encoded"))return!0;const n=e.slice(0,t),i=n.lastIndexOf("#"),o=n.lastIndexOf("?"),s=n.lastIndexOf("&"),a=n.lastIndexOf("=");return a>Math.max(o,s)&&a>i}function xr(e){try{const t=new URL(e),r=t.pathname.replace(/^\/+/,""),n=t.search.replace(/^\?/,""),i=t.hash.replace(/^#/,""),o=r.replace(/^wp-json\/?/i,""),s=o?`/${o}`:"/",a=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),u=a?.[1]||"",_=a?.[2]||"",l=a?.[3]||"";return{url:e,url_encoded:encodeURIComponent(e),origin:t.origin,origin_encoded:encodeURIComponent(t.origin),proxy_url:t.origin,proxy_url_encoded:encodeURIComponent(t.origin),path:r,pathname:r,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:n,search:t.search,hash:t.hash,fragment:i,pathname_after_wp_json:o,pathname_after_wp_json_with_slash:s,rest_namespace:u,rest_version:_,rest_route:l,rest_route_with_slash:l?`/${l}`:"/"}}catch{return}}function te(e,t){if(!e)return{};if(Array.isArray(e)){for(const a of e){const u=te(a,t);if(u!==void 0)return u}return}if(e==="*")return{};const r=jr(t,e),{regex:n,tokens:i}=Mr(e),o=n.exec(r);if(!o)return;const s={};return i.forEach((a,u)=>{s[`matched_${a}`]=o[u+1]||""}),s}function x(e,t,r={}){const n=xr(t);if(!n)return t;const i={...n,...r};let o="",s=0;const a=/\{([a-z_]+)\}/gi;let u;for(;u=a.exec(e);){o+=e.slice(s,u.index);const _=i[u[1]]??"",l=Fr(e,u.index,u[1])?encodeURIComponent(_):_;o+=l,s=u.index+u[0].length}o+=e.slice(s);try{const _=new URL(o),l=new URL(t);return!o.includes("{search}")&&!o.includes("{query}")&&l.search&&l.searchParams.forEach((p,h)=>{_.searchParams.has(h)||_.searchParams.append(h,p)}),!o.includes("{hash}")&&!o.includes("{fragment}")&&l.hash&&!_.hash&&(_.hash=l.hash),_.toString()}catch{return o}}function ye(e,t){try{const r=new URL(t);return`${v(e)}/${r.pathname.replace(/^\//,"")}${r.search}${r.hash}`}catch{return t}}function Pe(e,t){const r=v(e);return t?De(t)?t:t.startsWith("?")||t.startsWith("#")?`${r}${t}`:`${r}${t.startsWith("/")?"":"/"}${t}`:r}function Ce(e,t,r,n){const i=e.match;return i?Array.isArray(i)?i.some(o=>Ce({...e,match:o},t,r,n)):typeof i=="function"?!!i({url:t,method:n,requestType:r}):i==="*"?!0:te(i,t)!==void 0:!0}function kr(e,t,r,n="generic"){if(e==null)return[];const i=Array.isArray(e)?e:[e],o=[];return i.forEach((s,a)=>{if(!s)return;if(typeof s=="string"){const p=s.includes("{")&&s.includes("}")?x(s,t):ye(s,t);o.push({key:`backend:${a}`,url:p,source:"resource"});return}if(!Ne(s)||!("rewrite"in s))return;const u=s;if(!Ce(u,t,n,r))return;const _=typeof u.match=="string"||Array.isArray(u.match)?te(u.match,t)||{}:{},l=typeof u.proxyBase=="string"&&u.proxyBase.trim()?u.proxyBase.trim():void 0;(Array.isArray(u.rewrite)?u.rewrite:[u.rewrite]).filter(Boolean).forEach((p,h)=>{const E=typeof p=="function"?(()=>{const g=p({url:t,proxyBase:l,method:r,requestType:n,..._}),O=l&&!De(g)?Pe(l,g):g;return O.includes("{")&&O.includes("}")?x(O,t,_):O})():l?x(Pe(l,p),t,_):p.includes("{")&&p.includes("}")?x(p,t,_):ye(p,t);o.push({key:`backend:${u.id||"rule"}:${a}:${h}`,url:E,source:"resource"})})}),Cr(o)}function Ur(e){try{const t=new URL(e);return/(?:^|\/)wp-json\/em-files\/v\d+(?:\/|$)/i.test(t.pathname)?"emFiles":/(?:^|\/)wp-json\/ai-generator\/v\d+(?:\/|$)/i.test(t.pathname)?"ai":"generic"}catch{return"generic"}}function Hr(e,t=[]){return e==null||(Array.isArray(e)?e:[e]).forEach(r=>{if(r){if(typeof r=="string"){const n=r.split("{")[0]?.trim();n&&t.push(v(n));return}!Ne(r)||!("rewrite"in r)||(typeof r.proxyBase=="string"&&r.proxyBase.trim()&&t.push(v(r.proxyBase.trim())),(Array.isArray(r.rewrite)?r.rewrite:[r.rewrite]).forEach(n=>{if(typeof n!="string")return;const i=n.split("{")[0]?.trim();i&&t.push(v(i))}))}}),t}function Gr(e,t){return Lr(t).flatMap(r=>Hr(r)).filter(Boolean).some(r=>r&&e.startsWith(r))}function Xr(e,t){return!!ee(t)&&Rr(e,t)}function Vr(e,t={}){const r=t.requestType||Ur(e);return Xr(r,t.config)?kr(ee(t.config),e,t.method,r):[]}function $r(e,t={}){return Gr(e,t.config)?[e]:Vr(e,t).map(r=>r.url)}function D(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function Le(...e){const t=e.filter(o=>o!=null);if(t.length===0)return;if(t.length===1)return t[0];const r=t.find(o=>o.aborted);if(r)return r;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const n=new AbortController,i=o=>{n.signal.aborted||n.abort(o.reason)};for(const o of t)o.addEventListener("abort",()=>i(o),{once:!0});return n.signal}var ve=3e5,Re=15e3,m=null,we=!1;function Wr(){return!0}function Kr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return ve;const t=Number(e);return Number.isFinite(t)&&t>0?t:ve}function qr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return Re;const t=Number(e);return Number.isFinite(t)&&t>0?t:Re}function zr(){const e="https://app.emailmaker.ru/api/".trim();return e?D(e):void 0}function Yr(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const r=JSON.parse(t);if(!Array.isArray(r))throw new Error("expected JSON array");return r.map(n=>String(n).trim()).filter(Boolean)}catch{return we||(we=!0),[]}return t.split(",").map(r=>r.trim()).filter(Boolean)}function Jr(e){const t=new Set,r=[];for(const n of e){const i=D(n);t.has(i)||(t.add(i),r.push(i))}return r}function Me(e){const t=String(e||"").trim();return t?D(t):zr()}function Be(e,t=[]){return e?Jr([e,...t]).slice(0,3):[]}function je(){return Yr(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function Qr(e=Date.now()){return m?e-m.switchedAt>=Kr():!0}function Fe(e=Date.now()){m&&Qr(e)&&(m=null)}function N(e){if(!Wr())return!1;const t=Me(e);if(!t)return!1;const r=je();return r.length===0?!1:Be(t,r).length>1}function R(e){const t=Me(e);if(!t)return[];const r=je();return r.length===0?[t]:Be(t,r)}function k(e){const t=R(e);if(t.length===0)return"";if(Fe(),m){const r=t.indexOf(m.activeUrl);if(r>=0)return t[r]}return t[0]}function xe(e){const t=R(e);if(t.length<=1||(Fe(),!m||!t.includes(m.activeUrl)))return t;const r=m.activeUrl;return[r,...t.filter(n=>n!==r)]}function ke(e){return k(e)||void 0}function Ue(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const r=qr(),n=new AbortController;let i;const o=setTimeout(()=>{i=Zr(r),n.abort(i)},r);return{signal:Le(t,n.signal),timeoutError:()=>i,done:()=>clearTimeout(o)}}function Zr(e){const t=`[apiOriginFailover] origin attempt timed out after ${e}ms`;if(typeof DOMException=="function")return new DOMException(t,"TimeoutError");const r=new Error(t);return r.name="TimeoutError",r}function He(e){return e===502||e===503||e===504}function Ge(e){return!(e instanceof Error)&&!(e instanceof DOMException)?!1:e.name==="TimeoutError"?!0:e instanceof TypeError}var Xe;function en(e){Xe=e}function U(e,t){if(!N(t))return;const r=R(t);if(r.length<=1)return;const n=r.indexOf(D(e));if(n<0)return;const i=n+1;if(i>=r.length)return;const o=r[i],s=m?.activeUrl;m={activeUrl:o,switchedAt:Date.now()},s!==o&&Xe?.()}function Ve(e,t){if(!N(t))return;const r=D(e),n=R(t);if(n.includes(r)){if(r===n[0]){m=null;return}m?.activeUrl!==r&&(m={activeUrl:r,switchedAt:Date.now()})}}function $e(){m=null}var tn=e=>{const t=new FormData,r=(n,i,o)=>{if(i!=null){if(i instanceof Blob){n.append(o,i);return}if(Array.isArray(i)){i.forEach((s,a)=>{const u=o?`${o}[${a}]`:`${a}`;r(n,s,u)});return}if(typeof i=="object"){Object.keys(i).forEach(s=>{const a=i[s],u=o?`${o}[${s}]`:s;r(n,a,u)});return}n.append(o,String(i))}};return r(t,e),t},rn={baseUrl:D("https://app.emailmaker.ru/api/"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},y=new Map;function nn(e){const t=e?.getInstance(de);return t?t.get()??t.bootstrap():void 0}var on=class extends ur{container;constructor(e={},t){super(e),this.container=t}buildRequestUrl(e){const{path:t,baseUrl:r,extraQuery:n}=e;let{query:i}=e;n&&(i=i?{...i,...n}:n);const o=i&&this.toQueryString(i);return`${r||this.baseUrl||""}${t}${o?`?${o}`:""}`}buildRequestKey(e,t){return`${t.toUpperCase()} ${e}`}getBackendProxyCandidates(e,t){const r=nn(this.container),n=this.container?.getInstance(pe)!==void 0,i=$r(e,{config:r,method:t,standalone:n}),o=i.length>0?i:[e],s=this.buildRequestKey(e,t),a=y.get(s);return!a||!o.includes(a)?o:[a,...o.filter(u=>u!==a)]}shouldRetryResponse(e){return e.status===502||e.status===503||e.status===504}resolveFailoverBaseUrl(){return String(this.baseUrl||"").trim()||void 0}async requestOnOrigin(e,t,r=!1){const n={...e,baseUrl:t},i=this.buildRequestUrl(n),o=n.method||"GET",s=this.buildRequestKey(i,o),a=this.getBackendProxyCandidates(i,o);let u,_;for(const l of a){const p=E=>E===i?l:E,h=r?Ue(e.signal):void 0;try{const E=await super.request({...n,proxyHandler:p,...h?{signal:h.signal}:{}});if(!E.ok&&this.shouldRetryResponse(E)&&l!==a[a.length-1]){_=E,y.get(s)===l&&y.delete(s);continue}return y.set(s,l),E}catch(E){y.get(s)===l&&y.delete(s);const g=h?.timeoutError();if(g)throw g;if(u=E,(E instanceof DOMException||E instanceof Error)&&E.name==="AbortError")throw E}finally{h?.done()}}if(_)return _;throw u instanceof Error?u:new Error("Backend proxy chain failed")}async request(e){const t=String(e.baseUrl||"").trim();if(t)return this.requestOnOrigin(e,t);const r=this.resolveFailoverBaseUrl(),n=N(r),i=e.failoverAttemptTimeout??n,o=n?xe(r):r?[k(r)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let s,a;for(let u=0;u<o.length;u++){const _=o[u],l=u===o.length-1;try{const p=await this.requestOnOrigin(e,_,i);if(!p.ok&&He(p.status)){if(a=p,!l){U(_,r);continue}break}return p.ok&&Ve(_,r),p}catch(p){if(!Ge(p))throw p;s=p,l||U(_,r)}}if(n&&$e(),a)return a;throw s instanceof Error?s:new Error("API origin failover chain failed")}};function sn(e={},t){const r=new on({...rn,...e},t);return r.contentFormatters["multipart/form-data"]=tn,r}var We=f("rest.clientFactory"),an=e=>{Er(e);const t=sn({customFetch:e.getInstance(J)?.execute??pr},e);e.inject(Q,t)},Ke;(function(e){const t="https://racs.emcdn.ru/v3";function r(i,o){const s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(o)};return fetch(`${t}?resource=${i}&dataset=${document.location.hostname}`,s)}e.post=r;async function n(i,o=0){const s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:`{"filter":{},"limit":${o}}`};return await(await fetch(`${t}/get?resource=${i}&dataset=${document.location.hostname}`,s)).json()}e.getAll=n})(Ke||(Ke={}));function w(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const r=Array.isArray(e),n=Array.isArray(t);if(r){if(!n)return!1;const a=e.length;if(t.length!==a)return!1;for(let u=0;u<a;u++)if(!w(e[u],t[u]))return!1}else if(n)return!1;const i=Object.keys(e),o=Object.keys(t),s=i.length;if(s!==o.length)return!1;for(let a=0;a<s;a++){const u=i[a];if(!t.hasOwnProperty(u)||!w(e[u],t[u]))return!1}}return!0}function cn(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),r=atob(t),n=new Uint8Array(r.length);for(let i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return new TextDecoder().decode(n)}function qe(e){const[t,r,n]=e.split("."),i=JSON.parse(cn(r));return{exp:i.exp,createdAt:i.iat,data:i}}var re=f("plugin.auth.token"),ze=new WeakMap,un=3e4;function _n(e){let t;try{t=qe(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+un}function ln(e,t,r,n){const i=ze.get(e);i&&(i.stale=!0);const o={stale:!1};ze.set(e,o),e.injectFactory(re,async(s,a)=>{if(o.stale)return"";try{let u=await a||void 0;if(!u){const _=e.getInstance(fe);_&&(u=await _)}return t?!u||_n(u)?await t(r,n,u):u:""}catch{return""}},!0)}var Ye=f("auth.oauthProvided"),Je=new WeakMap;function Qe(e,t){const r=Je.get(e)??{applied:!1};(!r.applied||r.getAuthToken!==t.getAuthToken||!w(r.user,t.user)||r.project!==t.project)&&(Je.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),ln(e,t.getAuthToken,t.user,t.project))}function Ze(e){if(e.getInstance(Ye))return;e.inject(Ye,!0);let t;e.getInstance(le)?.watch(r=>{t=r}),e.addService(F,{execute:async(r,n)=>{if(n?.public||!t?.getAuthToken)return;e.getInstance(re)===void 0&&Qe(e,t);const i=await e.getInstanceAsync(re);i&&r.headers.set("authorization",`Bearer ${i}`)}})}var dn={theme:"canvas_fact_theme",flags:"canvas_fact_flags",commonStyles:"canvas_fact_common_styles",lockEditor:"canvas_fact_lock_editor",codeMode:"canvas_fact_code_mode",appName:"canvas_fact_app_name",previewPage:"canvas_fact_preview_page",viewport:"canvas_fact_viewport"},fn={text:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},headings:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, 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},links:{color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},buttons:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, 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:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},textAlign:"center",padding:{all:null,top:null,right:null,bottom:null,left:null}},block:{backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:{all:null,top:null,right:null,bottom:null,left:null}},cards:{contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null}}},et="ERROR",pn="useblocks",En={em_token:"em_access_token",em_refresh_token:"em_refresh_token",em_admin_token:"em_admin_access_token",em_admin_refresh_token:"em_admin_refresh_token",em_impersonation:"em_impersonation",em_elements_view:"em_elements_view",em_new_block:"em_new_block",em_new_email:"em_new_email",em_id:"em_id",em_name:"em_name",em_email:"em_email",em_locale:"em_locale",em_carrotquest_hash:"em_carrotquest_hash",em_ducalis_hash:"em_ducalis_hash",em_email_subscription_consent:"em_email_subscription_consent",em_folder:"em_folder",promocode:"promocode",em_active_tab:"em_active_tab"},hn={em_color_scheme:"em_color_scheme",em_code_mode_pane_sizes:"em_code_mode_pane_sizes",em_preview_pane_sizes:"em_preview_pane_sizes",em_default_sizes:"em_default_sizes",em_pane_sizes:"em_pane_sizes",em_test_emails:"em_test_emails",em_menu_is_locked:"em_menu_is_locked",em_code_mode_settings:"em_code_mode_settings",em_folder_is_open:"em_folder_is_open",em_active_tab:"em_active_tab",em_ai_settings:"em_ai_settings",em_last_active_page:"em_last_active_page",em_layout_convert_never_suggest:"em_layout_convert_never_suggest",em_filemanager_v2:"em_filemanager_v2",em_projects_v2:"em_projects_v2",em_translations_v2:"em_translations_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_guest_locale:"em_guest_locale"},On="light",mn="dark",gn="system",An="(prefers-color-scheme: dark)",In={MESSAGE:"message",INIT_PREVIEW:"init_preview",UPDATE_EDITOR:"update_editor",UPDATE_EDITOR_POSITION:"update_editor_position",UPDATE_SIDE_MENU_EDITOR:"update_side_menu_editor",SAVE_EMAIL:"saveEmail",SANDBOX_ELEMENT_SETTINGS_SET:"sandbox_element_settings_set",SANDBOX_IMAGE_RESET:"sandbox_image_reset",SANDBOX_NATIVE_IMAGE_DROP_CLEAR:"sandbox_native-image-drop-clear",SANDBOX_EMAIL_SETTINGS_SET:"sandbox_email_settings_set",SANDBOX_BLOCK_SETTINGS_SET:"sandbox_block_settings_set",SANDBOX_ELEMENT_PARENT_GET:"sandbox_element_parent_get",SANDBOX_ELEMENT_PARENT_TABLE_GET:"sandbox_element_parent_table_get",SANDBOX_ELEMENT_PREV_GET:"sandbox_element_prev_get",SANDBOX_ELEMENT_NEXT_GET:"sandbox_element_next_get",SANDBOX_ELEMENT_REMOVE:"sandbox_element_remove",SANDBOX_ELEMENT_ACTIVE_RESET:"sandbox_element_active_reset",SANDBOX_ELEMENT_ACTIVE_SET:"sandbox_element_active_set",SANDBOX_ELEMENT_HOVER_SET:"sandbox_element_hover_set",SANDBOX_ELEMENT_IMG_LINK:"sandbox_element_img_link",SANDBOX_ELEMENT_TEXT:"sandbox_element_text",SANDBOX_EMAIL_CONTENT_GET:"sandbox_email_content_get",SANDBOX_SET_POSITION_TO_IMG:"sandbox_set_position_to_img",SANDBOX_SET_POSITION_TO_LINK:"sandbox_set_position_to_link",SANDBOX_ACCORDION_ADD_SECTION:"sandbox_accordion_add_section",SANDBOX_ACCORDION_REMOVE_SECTION:"sandbox_accordion_remove_section",APPLICATION_FOCUS_IN_IFRAME:"application_focus_in_iframe",APPLICATION_EMAIL_SETTINGS_SET:"application_email_settings_set",APPLICATION_BLOCK_SETTINGS_SET:"application_block_settings_set",APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",_APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",APPLICATION_ELEMENT_SETTINGS_CLOSE:"application_element_settings_close",APPLICATION_ACTION:"application_action",APPLICATION_EBLOCK_ADD:"application_eblock_add",SANDBOX_EBLOCK_SET_EM_BLOCK_ID:"sandbox_eblock_set_em_block_id",SANDBOX_GLOBAL_BLOCK_REPLACE:"sandbox_global_block_replace",APPLICATION_SCROLL_TO:"application_scroll-to",APPLICATION_SCROLL_BLOCK_SHOW:"application_scroll-block-show",APPLICATION_SCROLL_BLOCK_HIDE:"application_scroll-block-hide",APPLICATION_DISCUSS_SET_ID:"application_discuss_set_id",APPLICATION_DISCUSS_GET_COMMENT:"application_discuss_get_comment",APPLICATION_DISCUSS_NO_COMMENT:"application_discuss_no_comment",APPLICATION_DISCUSS_SAVE_TARGET:"application_discuss_save_target",APPLICATION_IFRAME_SET_HEIGHT:"application_iframe_set_height",APPLICATION_COMMON_STYLES_UPDATE:"application_commonStyles_update",APPLICATION_EMAIL_CONTENT_GET:"application_email_content_get",APPLICATION_OPEN_IMAGE_AI_POPUP:"application_open-image-ai-popup",APPLICATION_OPEN_IMAGE_UPLOAD_POPUP:"application_open-image-upload-popup",APPLICATION_OPEN_IMAGE_EDIT_POPUP:"application_open-image-edit-popup",APPLICATION_OPEN_IMAGE_GIF_POPUP:"application_open-image-gif-popup",APPLICATION_OPEN_IMAGE_STOCK_POPUP:"application_open-image-stock-popup",APPLICATION_CLOSE_IMAGE_EDIT_POPUP:"application_close-image-edit-popup",APPLICATION_NATIVE_IMAGE_DROP:"application_native-image-drop",APPLICATION_SUBJECT_UPDATE:"application_subject_update",APPLICATION_PREHEADER_UPDATE:"application_preheader_update",APPLICATION_DOMPARSER_ERROR:"application_domparser_error",APPLICATION_SYNC_DRIFT:"application_sync_drift",APPLICATION_UPDATE_ENTITY:"application_update_entity",APPLICATION_IFRAME_DRAG_EVENT:"application_iframe_drag_event",APPLICATION_HAS_AMP:"application_has_amp",APPLICATION_CANVAS_IMAGE_GET:"application_canvas_image_get",APPLICATION_PREVIEW_ALERT_SHOW:"application_preview_alert_show",APPLICATION_ATOM_INSERTED:"application_atom_inserted",APPLICATION_TEMPLATE_NOT_EM_ALERT_SHOW:"application_template_not_em_alert_show",SANDBOX_IFRAME_SETSIZE:"sandbox_iframe-setsize",SANDBOX_BLOCK_INSERT:"sandbox_block-insert",SANDBOX_ATOM_INSERT:"sandbox_atom-insert",SANDBOX_DRAG_CANCEL:"sandbox_drag-cancel",UPDATE_EDITOR_POSITION_FROM_EDITOR:"update_position_from_editor",UPDATE_EDITOR_POSITION_FROM_IFRAME:"update_position_from_iframe",SANDBOX_CHANGE_PREVIEW:"sandbox_change_preview",APPLICATION_CHANGE_PREVIEW:"application_change_preview",SANDBOX_LOCK_EDIT:"sandbox_lock_edit",SANDBOX_FLOATBLOCK_ADD:"sandbox_floatBlock_add",SANDBOX_FLOATBLOCK_REMOVE:"sandbox_floatBlock_remove",SANDBOX_FLOATBLOCK_COPY:"sandbox_floatBlock_copy",SANDBOX_FLOATBLOCK_SWAP:"sandbox_floatBlock_swap",EDITOR_CHANGE_FOCUS:"editor_change_focus",SANDBOX_RESIZED:"sandbox_resized",SANDBOX_LOCK_DISCUSS:"sandbox_lock_discuss",SANDBOX_DISCUSS_SET_TARGET:"sandbox_discuss_set_target",SANDBOX_DISCUSS_REMOVE_TARGET:"sandbox_discuss_remove_target",SANDBOX_DISCUSS_RESET:"sandbox_discuss_reset",SANDBOX_DISCUSS_GET_TARGET:"sandbox_discuss_get_target",SANDBOX_READY:"SANDBOX_READY",SANDBOX_FLOATBLOCK_WRAP:"sandbox_floatblock_wrap",SANDBOX_FLOATBLOCK_DIR:"sandbox_floatblock_dir",SANDBOX_SUBJECT_UPDATE:"sandbox_subject_update",SANDBOX_PREHEADER_UPDATE:"sandbox_preheader_update",SANDBOX_DRAG_EVENT:"sandbox_drag_event",SANDBOX_WHEEL:"sandbox_wheel",SANDBOX_TRANSLATIONS:"sandbox_send_translations",SANDBOX_SET_THEME_VARIABLES:"sandbox_send_theme_variables",SANDBOX_SET_PROJECT_FONTS:"sandbox_set_project_fonts",SANDBOX_CANVAS_IMAGE_CACHE_SETUP:"sandbox_canvas_image_cache_setup",SANDBOX_SET_ENTITY:"sandbox_set_entity",SANDBOX_INIT_START:"sandbox_init_start",SANDBOX_INITED:"sandbox_inited",SANDBOX_UPDATE_ENTITY:"sandbox_update_entity",RELOAD:"reload",SANDBOX_ADD_EXTENSIONS:"sandbox_add_extensions",SANDBOX_REMOVE_EXTENSIONS:"sandbox_remove_extensions",SANDBOX_ADD_SCRIPT:"sandbox_add_script",SANDBOX_IS_EMAIL_EMPTY:"sandbox_is_email_empty",SANDBOX_SWITCH_THEME:"sandbox_switch_theme",SANDBOX_CANVAS_HEALTH:"sandbox_canvas_health"},Tn={language:"html",detectIndentation:!1,wordWrap:"on",wrappingIndent:"same",smoothScrolling:!0,automaticLayout:!0,tabSize:2,indentSize:2},tt=e=>{const t={current:Promise.resolve(),state:e,decorate:(r,n)=>(n&&(r=r.bind(n)),function(...i){const o=t.current.then(()=>r(...i));return t.current=o.then(s=>{t.state=s},s=>{}),o})};return t};function ne(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function Sn(e){return t=>{const r={},n=[];for(const s of e)n.push(s(t));for(const s of n)Object.assign(r,s.instance);return{instance:r,setOptions:async s=>{for(const a of n)await a.setOptions(s)},dispose:()=>{for(const s of n)s.dispose()}}}}function bn(e=et){const t=new Error(e);return t.name="AuthPipelineError",t}async function rt(e,t,r,n){const i=n?.attemptTimeout??N(r),o=N(r)?xe(r):R(r).length>0?[k(r)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const s=e.startsWith("/")?e:`/${e}`;let a,u;for(let _=0;_<o.length;_++){const l=o[_],p=_===o.length-1,h=i?Ue(t.signal):void 0;try{const E=await fetch(`${l}${s}`,{...t,...h?{signal:h.signal}:{}});if(!E.ok&&He(E.status)){if(a=E,!p){U(l,r);continue}break}return E.ok&&Ve(l,r),E}catch(E){const g=h?.timeoutError();if(!g&&!Ge(E))throw E;u=g||E,p||U(l,r)}finally{h?.done()}}if(N(r)&&$e(),a)return a;throw u instanceof Error?u:new Error("[apiOriginFailover] fetch chain failed")}function nt(e){e.inject(C,void 0),e.inject(z,void 0)}var Dn=ne(e=>{let t,r;const n=tt();return e.addService(F,{execute:n.decorate(async(i,o)=>{if(o?.public||!t)return;const s=String(e.getInstance(z)||"").trim();if(s){i.headers.append("authorization",`Bearer ${s}`);return}if(!e.getInstance(C))try{const a=e.getInstance(We),u=String(a?.getOptions()?.baseUrl||"").trim(),_=ke(r||u||void 0);if(!_)throw new Error("JWT auth requires baseUrl");const l=await rt("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},_);if(!l.ok)throw new Error(`JWT auth failed: ${l.status}`);const p=await l.json(),h=String(p.token||"").trim();if(!h)throw new Error("JWT auth failed: empty token");e.inject(C,void 0),e.inject(z,h),i.headers.append("authorization",`Bearer ${h}`)}catch{throw e.inject(C,et),bn()}})}),{setOptions(i){const o=i.jwtAuth,s=String(i.baseUrl||"").trim()||void 0,a=!w(o,t),u=s!==r;if(t=o,r=s,!o){nt(e);return}a||u?nt(e):e.inject(C,void 0)}}}),Nn=ne(e=>(Ze(e),{setOptions(t){Qe(e,t)}}));function yn(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function ie(e,t=document){try{const n=t.querySelector(e);if(n)return n}catch{return null}const r=t.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;if(!i)continue;const o=ie(e,i);if(o)return o}return null}function it(e,t=[]){const r=e.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;i&&(t.push(i),it(i,t))}return t}function Pn(e,t,r){if(e.isConnected)return e;const n=e.id?.trim();return n?ot(`#${yn(n)}`,t,r):Promise.reject(S("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function ot(e,t,r){if(K(r),typeof e<"u"){if(typeof e=="string"){const n=e,i=ie(n);if(i)return i;const o=t.addDisposable(new A);return new Promise((s,a)=>{const u=O=>{o.dispose(),O()},_=()=>{u(()=>a(S(r?.reason)))};if(r?.aborted){_();return}r?.addEventListener("abort",_),o.addDispose(()=>r?.removeEventListener("abort",_));const l=document.body??document.documentElement;if(!l){u(()=>a(S("Document is not ready to observe mount element")));return}const p=new Set,h=new MutationObserver(()=>{const O=ie(n);if(O){u(()=>s(O));return}g()}),E=O=>{p.has(O)||(p.add(O),h.observe(O,{attributes:!0,childList:!0,subtree:!0}))},g=()=>{const O=document.documentElement;if(O)for(const H of it(O))E(H)};E(l),g(),o.addDispose(()=>h.disconnect())})}return e instanceof Element?Pn(e,t,r):e}return e}var Cn=new Map;Object.defineProperty(c,"ADVANCED_SETTINGS_PANEL",{enumerable:!0,get:function(){return rr}}),Object.defineProperty(c,"APP_COOKIES",{enumerable:!0,get:function(){return En}}),Object.defineProperty(c,"APP_ID",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(c,"APP_LOAD_EVENT_ID",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(c,"ATOMS_HANDLERS_ID",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(c,"AsyncEmitter",{enumerable:!0,get:function(){return j}}),Object.defineProperty(c,"BaseEmitter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(c,"CANVAS_FACTS",{enumerable:!0,get:function(){return dn}}),Object.defineProperty(c,"COMMON_STYLES",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(c,"CONFIG_CHANGED_EVENT_ID",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(c,"CONFIG_SOURCE_ID",{enumerable:!0,get:function(){return de}}),Object.defineProperty(c,"COOKIE_MANAGER_ID",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(c,"CUSTOM_FETCH_ID",{enumerable:!0,get:function(){return J}}),Object.defineProperty(c,"ContentType",{enumerable:!0,get:function(){return cr}}),Object.defineProperty(c,"DARK",{enumerable:!0,get:function(){return mn}}),Object.defineProperty(c,"DISPOSABLE_ID",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(c,"DependencyResolver",{enumerable:!0,get:function(){return W}}),Object.defineProperty(c,"Disposable",{enumerable:!0,get:function(){return A}}),Object.defineProperty(c,"ELEMENT_MAP",{enumerable:!0,get:function(){return Cn}}),Object.defineProperty(c,"EVENT_TYPES",{enumerable:!0,get:function(){return In}}),Object.defineProperty(c,"Emitter",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(c,"HANDLE_ATOM_INSERT_ID",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(c,"HEADLESS_MODE_ID",{enumerable:!0,get:function(){return Jt}}),Object.defineProperty(c,"INIT_PIPELINE_ID",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(c,"INSTANCE_ID",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(c,"JWTMixin",{enumerable:!0,get:function(){return Dn}}),Object.defineProperty(c,"LATE_SURFACE_LISTENERS_ID",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(c,"LIGHT",{enumerable:!0,get:function(){return On}}),Object.defineProperty(c,"LOCAL_STORAGE_ITEMS",{enumerable:!0,get:function(){return hn}}),Object.defineProperty(c,"MESSAGE_SERVICE_ID",{enumerable:!0,get:function(){return er}}),Object.defineProperty(c,"MODAL_CLOSE_EVENT",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(c,"MODAL_SHOW_EVENT",{enumerable:!0,get:function(){return nr}}),Object.defineProperty(c,"MODAL_UPDATE_EVENT",{enumerable:!0,get:function(){return or}}),Object.defineProperty(c,"MONACO_EDITOR_OPTIONS",{enumerable:!0,get:function(){return Tn}}),Object.defineProperty(c,"MessageService",{enumerable:!0,get:function(){return qt}}),Object.defineProperty(c,"OAuthMixin",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(c,"OPTIONS_SOURCE_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(c,"PLUGIN_COLLECTION_ID",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(c,"PORT_READY",{enumerable:!0,get:function(){return he}}),Object.defineProperty(c,"PREFERS_COLOR_SCHEME_DARK",{enumerable:!0,get:function(){return An}}),Object.defineProperty(c,"PUBLIC_REQUEST",{enumerable:!0,get:function(){return me}}),Object.defineProperty(c,"REQUEST_HANDLER_ID",{enumerable:!0,get:function(){return F}}),Object.defineProperty(c,"REST_CLIENT_FACTORY_ID",{enumerable:!0,get:function(){return We}}),Object.defineProperty(c,"REST_TRANSPORT_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(c,"SANDBOX_EXTENSIONS_ID",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(c,"SANDBOX_EXTENSION_SCRIPT_STATUS_ID",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(c,"SECURITY_MODULE_ID",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(c,"SETTINGS_PANEL_EVENT",{enumerable:!0,get:function(){return tr}}),Object.defineProperty(c,"STANDALONE_ACTIVATED_ID",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(c,"STANDALONE_BOOTSTRAP_TOKEN_ID",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(c,"STANDALONE_FILE_PROXY_REGISTERED_ID",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(c,"STANDALONE_PROJECT_ID",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(c,"STORE_ID",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(c,"SYSTEM",{enumerable:!0,get:function(){return gn}}),Object.defineProperty(c,"Signal",{enumerable:!0,get:function(){return St}}),Object.defineProperty(c,"TEMPLATE_DIRECTIVES_ID",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(c,"USEBLOCKS",{enumerable:!0,get:function(){return pn}}),Object.defineProperty(c,"combineMixins",{enumerable:!0,get:function(){return Sn}}),Object.defineProperty(c,"composeAbortSignals",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(c,"createAbortError",{enumerable:!0,get:function(){return S}}),Object.defineProperty(c,"createIdentifier",{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(c,"createIdentifier$1",{enumerable:!0,get:function(){return f}}),Object.defineProperty(c,"createQueue",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(c,"debounce",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(c,"decodeJwt",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(c,"deepEqual",{enumerable:!0,get:function(){return w}}),Object.defineProperty(c,"defineMixin",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(c,"events",{enumerable:!0,get:function(){return q}}),Object.defineProperty(c,"fetchWithApiOriginFailover",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(c,"filter",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(c,"generateUUID",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(c,"getActiveBaseUrl",{enumerable:!0,get:function(){return k}}),Object.defineProperty(c,"getApi",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(c,"getEmitter",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(c,"getEmitter$1",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(c,"getEvent",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(c,"getServiceContainerId",{enumerable:!0,get:function(){return M}}),Object.defineProperty(c,"isAbortError",{enumerable:!0,get:function(){return At}}),Object.defineProperty(c,"mapHttpStatusToErrorCode",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(c,"mergeBackendProxyLayers",{enumerable:!0,get:function(){return br}}),Object.defineProperty(c,"mergeResourceProxyLayers",{enumerable:!0,get:function(){return Sr}}),Object.defineProperty(c,"mergeResourceProxyPolicyLayers",{enumerable:!0,get:function(){return Pr}}),Object.defineProperty(c,"mergeShallowConfigLayers",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(c,"pickKey",{enumerable:!0,get:function(){return Ar}}),Object.defineProperty(c,"provideOAuth",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(c,"raceWithAbortSignal",{enumerable:!0,get:function(){return It}}),Object.defineProperty(c,"registerRestTransport",{enumerable:!0,get:function(){return an}}),Object.defineProperty(c,"releaseContainer",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(c,"resolveContainer",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(c,"resolveExplicitApiBaseUrl",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(c,"setApiOriginFailoverHook",{enumerable:!0,get:function(){return en}}),Object.defineProperty(c,"snapshot",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(c,"throwIfAborted",{enumerable:!0,get:function(){return K}}),Object.defineProperty(c,"waitForElement",{enumerable:!0,get:function(){return ot}})});
2096
+ __emailmaker__.define("static/umd/3a37cbb5.js",["require","exports","module"],function(Rn,c,wn){var g=class ct{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof ct&&t.addDispose(()=>{this.removeDisposable(t)}),t}addDispose(t){this.addDisposable({dispose:t})}removeDisposable(t){const r=this._inner.indexOf(t);r>=0&&this._inner.splice(r,1)}isDisposed(){return this._isDisposed}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(const t of[...this._inner])t.dispose()}}};function M(e){return`service_container_${e}`}var y=new Set,V;function ut(){if(!V)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,se.prototype.getInstanceAsync),e.stack}function X(e){y.delete(e)&&V?.end(e)}var se=class oe extends g{_parent;_injectCallbacks=[];_injections=Object.create(null);_runCallbacks(t){[...this._injectCallbacks].forEach(r=>r(t))}constructor(t=null){super(),this._parent=t,t&&this.addDisposable(t.onInject(r=>this._runCallbacks(r)))}onInject=t=>(this._injectCallbacks.push(t),{dispose:()=>{const r=this._injectCallbacks.indexOf(t);r>=0&&this._injectCallbacks.splice(r,1)}});inject(t,r){this._injections[t]=()=>r,this._runCallbacks(t)}injectFactory(t,r,n){const i=this._injections[t];let o=typeof i=="function"?i():i;const s=this._injections[t]=()=>(o=r(this,o),o);n&&s(),this._runCallbacks(t)}_find(t,r=!0){return this._injections[t]||r&&this._parent?._find(t)}_onInject(t,r,n=new g){return n.addDisposable(this.onInject(i=>{t===i&&!n.isDisposed()&&(n.dispose(),r(this.getInstance(i)))})),this._parent&&n.addDisposable(this._parent._onInject(t,r,n)),this.addDisposable(n),n}getInstance(t,r=!0){const n=this._find(t,r);if(typeof n=="function")return n()}getOrCreateInstance(t,r){const n=this._find(t);if(typeof n=="function")return n();const i=r(this);return this.inject(t,i),i}getInstanceAsync(t){const r=this._find(t);if(typeof r=="function")return Promise.resolve(r());const n=ut();return new Promise((i,o)=>{const s={id:String(t),startedAt:Date.now(),origin:n,container:this,reject:o};y.add(s),V?.start(s),this._onInject(t,()=>{X(s),i(this.getInstance(t))})})}failPendingWaits(t){for(const r of Array.from(y))r.container===this&&(X(r),r.reject(t))}pendingWaits(){return[...y].filter(t=>t.container===this)}addService(t,r){const n=M(t);this.injectFactory(n,(o,s=[])=>s.indexOf(r)<0?[...s,r]:s);const i=new g;return i.addDispose(()=>{this.injectFactory(n,(o,s=[])=>s.filter(a=>a!==r))}),i}addServiceFactory(t,r,n){const i=M(t);let o;this.injectFactory(i,(a,u=[])=>(o=r(a,o),o===void 0?u:u.indexOf(o)<0?[...u,o]:u),n);const s=new g;return s.addDispose(()=>{this.injectFactory(i,(a,u=[])=>o===void 0?u:u.filter(_=>_!==o))}),s}getServices(t){const r=M(t);return[...this.getInstance(r,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new oe(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const r=this._parent?.getOrCreateIsolatedContainer(t);return new oe(r)})}remove(t){const r=this._injections;delete r[String(t)]}injectListenerCount(){return this._injectCallbacks.length}dispose(){for(const t of Array.from(y))t.container===this&&X(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function $(e){return e.startsWith("__")?e:`__${e}__`}function _t(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=$(e),r=globalThis;return r[t]??={}}function lt(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function dt(e){if(e)return $(e);const t="emailmaker".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return $(t)}function ae(e){const t=dt(e),r=_t(t);if(lt(r.container))return r.container;const n=new se(null);return r.container=n,n}function ft(e){return ae(e)}function Et(){let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let n=Math.random()*16;return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),(r==="x"?n:n&3|8).toString(16)})}function ce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Et()}function f(e=ce()){return e}function ue(){return"umd".trim()||"unknown"}function pt(e){if(typeof globalThis>"u")return;const t=ue(),r=globalThis[e]??{};globalThis[e]=r;const n=r.__diagnostics??={},i=n.diModuleEval??={evalCount:0,records:[]};i.records.push({buildSource:t,timestamp:Date.now(),stack:new Error().stack}),i.evalCount+=1}function ht(){const e="emailmaker".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function Ot(e,t){if(pt(t),typeof globalThis>"u")return e;const r=ue(),n=globalThis,i=n[t]=n[t]||{},o=i.__diagnostics=i.__diagnostics||{},s=o.dependencyResolver=o.dependencyResolver||{entries:[]},a={container:e,source:"packages/runtime-core/di/index.ts",buildSource:r,timestamp:Date.now(),stack:new Error().stack};return s.entries.push(a),e}var B;function mt(){if(B)return B;const e=ht();return B=Ot(ae(e),e),B}var W=new Proxy({},{get(e,t,r){const n=mt(),i=Reflect.get(n,t,r);return typeof i=="function"?i.bind(n):i}});function At(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}function S(e){if(e instanceof DOMException&&e.name==="AbortError")return e;const t=e===void 0?"The operation was aborted.":typeof e=="string"?e:e instanceof Error?e.message:String(e);return new DOMException(t,"AbortError")}function gt(e){return e instanceof DOMException&&e.name==="AbortError"}function K(e){if(e?.aborted)throw S(e.reason)}function It(e,t){return t?(t.aborted&&e.catch(()=>{}),K(t),new Promise((r,n)=>{const i=()=>{o(),n(S(t.reason))},o=()=>{t.removeEventListener("abort",i)};t.addEventListener("abort",i),e.then(s=>{o(),r(s)},s=>{o(),n(s)})})):e}var _e=class extends g{_options;_listeners=[];constructor(e={}){super(),this._options=e}getListeners(e){return this._listeners.flatMap(([t])=>typeof t=="function"?t:t.getListeners(e))}hasListeners(){for(const[e]of this._listeners){if(typeof e=="function")return!0;const t=e;if(typeof t.hasListeners=="function"){if(t.hasListeners())return!0;continue}return!0}return!1}_addListener(e,t=0,r){if(this.isDisposed())return{dispose:()=>{}};const n=this._listeners,i=this._options;r&&typeof e=="function"&&(e=e.bind(r));const o=n.findIndex(([,a])=>a<t),s=[e,t];return n.splice(o>=0?o:n.length,0,s),n.length===1&&i.onFirstListenerAdd&&i.onFirstListenerAdd(),{dispose:()=>{const a=n.indexOf(s);a>=0&&(n.splice(a,1),!n.length&&i.onLastListenerRemove&&i.onLastListenerRemove())}}}on=this._addListener.bind(this);event=this._addListener.bind(this);once=(e,t=0,r)=>{const n=this._addListener((...i)=>(n?.dispose(),r?e.call(r,...i):e(...i)),t);return n};un=e=>{const t=this._listeners.findIndex(([r])=>r===e);t>=0&&(this._listeners.splice(t,1),this._listeners.length===0&&this._options.onLastListenerRemove&&this._options.onLastListenerRemove())};dispose(){this._listeners.splice(0,this._listeners.length),this._options.onLastListenerRemove&&this._options.onLastListenerRemove(),super.dispose()}},b=class extends _e{execute(e,t){for(const r of t)try{r(...e)}catch{}}fire(...e){if(!this.isDisposed()){const t=this.execute(e,this.getListeners(e));return t===void 0?void 0:t}}},Tt=class extends b{execute([e],t){for(const r of t)try{r(e)}catch{}}},St=class extends b{_suspendCounter=0;_wasFired=!1;execute([e],t){if(this._suspendCounter)this._wasFired=!0;else for(const r of t)try{r(e)}catch{}}suspend(){this._suspendCounter++}resume(){--this._suspendCounter===0&&this._wasFired&&(this.fire(),this._wasFired=!1)}},j=class extends b{async execute([e],t){const r=[];for(const n of t)try{r.push(await n(e))}catch{}return r}async fireSettled(e){const t={results:[],errors:[]};if(this.isDisposed())return t;for(const r of this.getListeners([e]))try{t.results.push(await r(e))}catch(n){t.errors.push(n)}return t}};function bt(e,t=0){const r=new _e,n=e(r,t);return n&&r.addDisposable(n),r.event}function Dt(e,t,r=0){const n=new b,i=e((...o)=>{if(t(...o))return n.fire(...o)},r);return i&&n.addDisposable(i),n.event}function Nt(e,t=0,r=0){const n=new b;let i,o;const s=e((...a)=>{o=a,i||(i=setTimeout(()=>{o&&n.fire(...o),i=void 0},t))},r);return s&&n.addDisposable(s),n.event}function Pt(e,t){return e.getOrCreateInstance(t,()=>new j)}function d(e){return f(e)}var q;(function(e){e.BEFORE_SAVE_EMAIL=d("events.BEFORE_SAVE_EMAIL"),e.ON_SAVEBUTTON_CLICK_ID=d("events.ON_SAVEBUTTON_CLICK_ID"),e.ON_NEXTBUTTON_CLICK_ID=d("events.ON_NEXTBUTTON_CLICK_ID"),e.ON_PREVIOUSBUTTON_CLICK_ID=d("events.ON_PREVIOUSBUTTON_CLICK_ID"),e.ON_DOCUMENT_SESSION_CHANGE=d("events.ON_DOCUMENT_SESSION_CHANGE"),e.WILL_EMAIL_INIT_ID=d("events.WILL_EMAIL_INIT_ID"),e.ON_EMAIL_INIT_ID=d("events.ON_EMAIL_INIT_ID"),e.ON_BLOCK_INIT_ID=d("events.ON_BLOCK_INIT_ID"),e.ON_CONTENT_CHANGED_ID=d("events.ON_CONTENT_CHANGED_ID"),e.ON_PREHEADER_CHANGED_ID=d("events.ON_PREHEADER_CHANGED_ID"),e.ON_SUBJECT_CHANGED_ID=d("events.ON_SUBJECT_CHANGED_ID"),e.ON_EMAIL_CHANGED_ID=d("events.ON_EMAIL_CHANGED_ID"),e.ON_HEADER_APPLIED_ID=d("events.ON_HEADER_APPLIED_ID"),e.ON_BLOCK_CHANGED_ID=d("events.ON_BLOCK_CHANGED_ID"),e.ON_BLOCK_OPEN_ID=d("events.ON_BLOCK_OPEN_ID"),e.ON_BLOCK_CLOSE_ID=d("events.ON_BLOCK_CLOSE_ID"),e.OPEN_BLOCK_REQUEST_ID=d("events.OPEN_BLOCK_REQUEST_ID"),e.ON_BLOCK_SAVEBUTTON_CLICK_ID=d("events.ON_BLOCK_SAVEBUTTON_CLICK_ID"),e.ON_BLOCK_CLONE_ID=d("events.ON_BLOCK_CLONE_ID"),e.ON_CHUNKS_LOADED=d("events.ON_CHUNKS_LOADED"),e.ON_SEND_TESTEMAIL_ID=d("events.ON_SEND_TESTEMAIL_ID"),e.ON_SEND_LIVEPREVIEW_ID=d("events.ON_SEND_LIVEPREVIEW_ID"),e.ON_SHARE_ID=d("events.ON_SHARE_ID"),e.ON_SHOW_PREVIEW_ID=d("events.ON_SHOW_PREVIEW_ID"),e.ON_EMAIL_CLONE_ID=d("events.ON_EMAIL_CLONE_ID"),e.ON_SEND_EMAIL_MODAL_ID=d("events.ON_SEND_EMAIL_MODAL_ID"),e.ON_ANALYTICS_EVENT=d("events.ON_ANALYTICS_EVENT"),e.ON_NOTIFICATION=d("events.ON_NOTIFICATION"),e.READ_LOCALE=d("events.READ_LOCALE"),e.ON_TRANSLATE_ID=d("events.ON_TRANSLATE_ID"),e.ON_CODE_VALIDATE_ID=d("events.ON_CODE_VALIDATE_ID"),e.ON_IMPORT_VALIDATE_ID=d("events.ON_IMPORT_VALIDATE_ID"),e.UPLOAD_EVENT_ID=d("events.UPLOAD_EVENT_ID"),e.PROXY_URL_EVENT_ID=d("events.PROXY_URL_EVENT_ID"),e.FILE_PROXY_EVENT_ID=d("events.FILE_PROXY_EVENT_ID"),e.ON_LIMIT_ID=d("events.ON_LIMIT_ID"),e.ON_BROWSER_EXTENSION_DETECTED_ID=d("events.ON_BROWSER_EXTENSION_DETECTED_ID"),e.ON_LAYOUT_CONVERT_REQUEST_ID=d("events.ON_LAYOUT_CONVERT_REQUEST_ID"),e.ON_BROWSER_TRANSLATE_DETECTED_ID=d("events.ON_BROWSER_TRANSLATE_DETECTED_ID"),e.AI_TEXT_REQUEST_ID=d("events.AI_TEXT_REQUEST_ID"),e.AI_IMAGE_REQUEST_ID=d("events.AI_IMAGE_REQUEST_ID"),e.AI_TEXT_PROGRESS_ID=d("events.AI_TEXT_PROGRESS_ID"),e.AI_IMAGE_PROGRESS_ID=d("events.AI_IMAGE_PROGRESS_ID"),e.AI_TEXT_STREAM_ID=d("events.AI_TEXT_STREAM_ID")})(q||(q={}));function yt(e,t){return e.getOrCreateInstance(t,()=>new j).event}function Ct(e,t){return e.getOrCreateInstance(t,()=>new j)}var Lt=f("plugin.app"),vt=f("plugin.disposable"),Rt=f("InitPipelineContext"),wt=f("plugin.instance"),Mt=f("plugin.lateSurfaceListeners"),le=f("plugin.optionsSource"),Bt=f("plugin.store"),de=f("ConfigSource"),jt=f("plugin.standalone.project"),fe=f("plugin.standalone.bootstrapToken"),Mn=f("plugin.element"),Ee=f("plugin.securityModule"),Ft=f("plugin.standalone.activated"),xt=f("plugin.standalone.fileProxyRegistered"),z=f("plugin.jwt.token"),C=f("plugin.jwt.error"),kt=f("PluginCollection"),Ut=d("APP_LOAD_EVENT"),Ht=d("CONFIG_CHANGED_EVENT");function Gt(e,t=window){return{peer:e,send(r){e.postMessage(r,"*")},subscribe(r){const n=i=>{r({data:i.data,source:i.source,ports:i.ports})};return t.addEventListener("message",n),{dispose:()=>t.removeEventListener("message",n)}},close(){}}}function Vt(e){let t=!1;return{peer:e,send(r){e.postMessage(r)},subscribe(r){const n=i=>{r({data:i.data,source:e})};return e.addEventListener("message",n),t||(t=!0,e.start()),{dispose:()=>e.removeEventListener("message",n)}},close(){e.close()}}}function Xt(e){return e}function $t(e){return e&&typeof e=="object"}function pe(e,t){return e&&typeof e=="object"&&e.operationId===t}var T="INIT_MESSAGE",he="em:port-ready",Wt="em:window-drained",Y="";function Oe(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var Kt=class extends g{_listeners=Object.create(null);addListenerAsync=(e,t,r=0,n)=>{const i=this._listeners[e]||(this._listeners[e]=[]);n&&typeof t=="function"&&(t=t.bind(n));const o=i.findIndex(([a,u])=>r<=u),s=[t,r];return this.isDisposed()||i.splice(o>=0?o:i.length,0,s),{dispose(){const a=i.indexOf(s);a>=0&&i.splice(a,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const r=this._listeners[e]||(this._listeners[e]=[]);let n;for(let i=0;i<r.length;i++){const o=r[i][0],s=n;n=a=>o(a,s)}if(n)return n(t)}};addListener=(e,t,r=0)=>this.addListenerAsync(e,(n,i)=>{try{t(n)}catch{}return i&&i(n)},r)},qt=class extends g{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_portSendHeld=new WeakSet;_inited=!1;_emitter=this.addDisposable(new Kt);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;_outgoingObservers=new Set;_offTargetListeners=new Map;constructor(e,t){super(),this._singleton=t,this._transport=Gt({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(T,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(T))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,r=t.data,n=t.source,i=r?.port===!0?t.ports?.[0]:void 0,o=!this._isPortSource(t.source);if(o&&n&&r?.operationId==="em:window-drained"){this._ports.has(n)&&this._drained.add(n);return}if(o&&n&&this._drained.has(n))return;if(n&&n!==this._target&&this._greeted.has(n)&&pe(r,T)){this._greeted.delete(n),this._handshaken.add(n),this._postMessage(n,{operationId:T,data:{}}),i&&this.usePort(i,!0,n);return}const s=t.source===this.target||this._isCurrentPort(t.source);if(s||this._notifyOffTarget(r?.operationId,t.source),$t(r)&&s||this._singleton&&pe(r,T)){if(i&&s){const l=this._target;Promise.resolve().then(()=>this.usePort(i,!0,l))}const a=this._emitter.fireAsync(r.operationId||Y,r.operationId===void 0?t:r.data),u=r.result,_=r.error;u&&_&&Promise.resolve(a).then(l=>this._sendMessage(u,l),l=>this._sendMessage(_,l))}};setTarget(e){if(this._target!==e){if(this._target=e,!e){this._inited=!1;return}if(this._handshaken.has(e)){this._inited=!0,this._emitter.fireAsync(T,void 0);return}this._inited=!1,this._postMessage(e,{operationId:T,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:T,data:{},port:!0},[t])}observeOutgoing(e){return this._outgoingObservers.add(e),{dispose:()=>{this._outgoingObservers.delete(e)}}}_notifyOutgoing(e,t){for(const r of Array.from(this._outgoingObservers))try{r(e,t)}catch{}}addOffTargetListener(e,t){let r=this._offTargetListeners.get(e);return r||(r=new Set,this._offTargetListeners.set(e,r)),r.add(t),{dispose:()=>{r.delete(t)}}}_notifyOffTarget(e,t){const r=typeof e=="string"?this._offTargetListeners.get(e):void 0,n=r?.size?this._knownPeer(t):void 0;if(!(!r||!n))for(const i of Array.from(r))try{i(n)}catch{}}_knownPeer(e){for(const[r,n]of this._ports)if(n.transport.peer===e)return r;const t=e;return typeof e=="object"&&e!==null&&(this._handshaken.has(t)||this._greeted.has(t))?t:void 0}setOutgoingFilter(e){return this._outgoingFilter=e,()=>{this._outgoingFilter===e&&(this._outgoingFilter=void 0)}}sendNow(e){const t=this._target;return!this._inited||!t?!1:(this._postMessage(t,e),!0)}greet(e){this._handshaken.has(e)||this._greeted.has(e)||this._target===e||(this._greeted.add(e),this._postMessage(e,{operationId:T,data:{}}))}forget(e){this._handshaken.delete(e),this._greeted.delete(e),this._closePort(e),this._drained.delete(e),this._target===e&&(this._inited=!1)}usePort(e,t=!1,r=this._target){if(!r||this._ports.has(r))return;const n=Vt(e),i=n.subscribe(this._onTransportMessage);this._ports.set(r,{transport:n,subscription:i}),t&&(n.send({operationId:he,data:{}}),this.drainWindow(r))}holdPort(e=this._target){!e||!this._ports.has(e)||(this._portSendHeld.add(e),this._drained.delete(e))}resumePort(e=this._target){e&&this._portSendHeld.delete(e)}useWindow(e=this._target){e&&(this._closePort(e),this._drained.delete(e))}get usesPort(){return this._target!==void 0&&this._ports.has(this._target)&&!this._portSendHeld.has(this._target)}hasPort(e,t){const r=this._ports.get(e);return r!==void 0&&(t===void 0||r.transport.peer===t)}_closePort(e){const t=this._ports.get(e);t&&(t.subscription.dispose(),t.transport.close(),this._ports.delete(e),this._portSendHeld.delete(e))}drainWindow(e){this._ports.has(e)&&e.postMessage({operationId:Wt,data:{}},"*")}isWindowDrained(e){return this._drained.has(e)}_isPortSource(e){for(const t of this._ports.values())if(t.transport.peer===e)return!0;return!1}_isCurrentPort(e){return this._target!==void 0&&this._ports.get(this._target)?.transport.peer===e}getTarget(){return this._target}get target(){return this._target}_postMessage(e,t,r){let n=t;this._outgoingFilter&&!r?.length&&(n="data"in t?{...t,data:this._outgoingFilter(t.data)}:this._outgoingFilter(t));try{const i=this._ports.get(e);if(i&&!this._portSendHeld.has(e)){i.transport.send(n);return}if(r?.length){e.postMessage(n,"*",r);return}e.postMessage(n,"*")}catch(i){if(i?.name==="DataCloneError"){const o=typeof n?.data=="object"&&n?.data!==null?n.data:void 0}throw i}}_sendMessage(e,t,r=!0){if(!r&&!this.isInited())return;e&&this._notifyOutgoing(e,t);const n=this.addDisposable(this.onInit(i=>{const o=e?{operationId:e,data:t}:t;try{this._postMessage(i,{...o})}finally{n.dispose()}}))}send(e,t,r){return typeof e=="string"?this._sendMessage(e,t,r):this._sendMessage(Y,e,t)}sendAsync(e,t,r=!0){if(!r&&!this.isInited())return Promise.resolve();this._notifyOutgoing(e,t);const n=Oe(),i=Oe();return new Promise((o,s)=>{const a=this.addDisposable(new g);a.addDisposable(this.onInit(u=>{try{this._postMessage(u,{operationId:e,data:t,result:n,error:i})}catch(_){a.dispose(),s(_);return}a.addDisposable(this._onMessage(n,_=>{o(_),a.dispose()})),a.addDisposable(this._onMessage(i,_=>{s(_),a.dispose()}))}))})}_onMessage(e,t,r=0){return this._emitter.addListener(e,t,r)}addListener(e,t,r){return t?this._onMessage(e,t,r):this._onMessage(Y,e)}addListenerAsyncPipe(e,t,r=0){return this._emitter.addListenerAsync(e,t,r)}addListenerAsync(e,t,r=0){return this._emitter.addListenerAsync(e,async(n,i)=>{const o=await t(n);return i?i(n):o},r)}isInited(){return this._inited}get inited(){return this._inited}onInit(e,t=!0,r=0){const n=this.addDisposable(new g);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?n.addDisposable(this.onInit(e,t,r)):e(this._target)}):n.addDisposable(this._onMessage(T,()=>{e(this._target)},r)),n}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function L(e){return f(e)}var zt=f("extensions.atomsHandlers"),Yt=L("HANDLE_ATOM_INSERT"),Jt=f("HeadlessMode"),Qt=f("extensions.sandboxExtensions"),Zt="SANDBOX_EXTENSION_SCRIPT_STATUS",er=f("MESSAGE_SERVICE"),tr=L("SETTINGS_PANEL_EVENT"),rr="advanced",nr=L("MODAL_SHOW_EVENT"),ir=L("MODAL_CLOSE_EVENT"),or=L("MODAL_UPDATE_EVENT"),Bn=f("client"),jn=f("v2_client"),Fn=f("ai_client"),sr=f("app.cookieManager"),xn=f("app.storageProvider"),kn=f("image-blob-resolver"),ar=f("template-directives"),cr=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),ur=class{baseUrl="https://api.emailmaker.ru/wp-json";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(r=>this.encodeQueryParam(t,r)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(r=>typeof t[r]<"u").map(r=>Array.isArray(t[r])?this.addArrayQueryParam(t,r):this.addQueryParam(t,r)).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,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce((t,r)=>{const n=e[r];return t.append(r,n instanceof Blob?n:typeof n=="object"&&n!==null?JSON.stringify(n):`${n}`),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 r=this.abortControllers.get(e);return r?r.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))};async request({body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:a,extraQuery:u,proxyHandler:_,...l}){const E=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},h=this.mergeRequestParams(l,E);u&&(i=i?{...i,...u}:u);const p=i&&this.toQueryString(i),A=this.contentFormatters[n||"application/json"],O=o||h.format,H=`${s||this.baseUrl||""}${r}${p?`?${p}`:""}`,Ln=_?_(H,{body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:a,extraQuery:u,proxyHandler:_,...l}):H,st=new Request(Ln,{...h,headers:{...h.headers||{},...n&&n!=="multipart/form-data"?{"Content-Type":n}:{}},signal:(a?this.createAbortSignal(a):h.signal)||null,body:typeof e>"u"||e===null?null:A(e)});return this.customFetch(st).then(async at=>{const I=at;I.data=null,I.error=null,I.meta={request:st,response:I};const vn=O?await at[O]().then(G=>(I.ok?I.data=G:I.error={data:G},I)).catch(G=>(I.error=G,I)):I;return a&&this.abortControllers.delete(a),vn})}},_r=f("prewarm.networkActivity");function lr(){let e=0;const t=new Set,r=()=>{t.forEach(n=>n())};return{begin(){e+=1,r();let n=!1;return()=>{n||(n=!0,e-=1,r())}},inFlight:()=>e,watch(n){return t.add(n),()=>t.delete(n)}}}function dr(e){return e.getOrCreateInstance(_r,()=>lr())}var me=Symbol("rest.publicRequest"),F=f("rest.requestHandler"),fr=f("rest.responseHandler"),J=f("rest.customFetch"),Er=(e,t)=>fetch(e,t),Q=f("rest_transport"),pr=e=>{e.inject(J,{execute:async(t,r={})=>{const n=e.getServices(F),i={public:r[me]===!0},o=dr(e).begin();try{let s=t instanceof Request?t:new Request(t,r);for(const _ of n){const l=await _.execute(s,i);l instanceof Request&&(s=l)}let a=await fetch(s);const u=e.getServices(fr);for(const _ of u)a=await _.execute(a,s);return a}finally{o()}}})};function hr(e,t){const r=e.getInstance(Q);if(!r)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(n=>new n(r)))}var Or="INJECTION";function mr(e){return e.getState}function Ar(e){if(!mr(e)){e.dispose();return}const t=e.getState()[Or];t&&(W.getInstance(t)?.dispose(),W.remove(t))}function gr(e,t){for(const r of e)if(r&&t in r)return r[t]}function Ae(e){return Object.assign({},...e)}var ge=["generic","stockImages","emFiles","cdn"];function Z(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ie(e){return!Z(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>ge.includes(t))}function Te(e){return e.length===0?[]:e.length===1?e[0]:e}function Se(e){let t=!1,r=[];for(const n of e)if(n!==void 0){if(t=!0,Array.isArray(n)){r=[...n,...r];continue}r=[n,...r]}if(t)return Te(r)}function Ir(e){return Z(e)&&("value"in e||"replace"in e)}function be(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function Tr(e){let t=!1,r=[],n=!1;for(const o of e)if(o!==void 0){if(Ir(o)){t=!0,o.replace&&(r=[],n=!0),o.value!==void 0&&(r=be(r,o.value),n=!0);continue}r=be(r,o),n=!0}const i=n?Te(r):void 0;if(!t)return i;if(i!==void 0)return{value:i}}function Sr(e){const t=e.filter(n=>n!==void 0);if(t.length===0)return;if(!t.some(n=>Ie(n)))return Se(t);const r={};for(const n of ge){const i=Tr(e.map(o=>{if(o!==void 0)return Ie(o)?o[n]:n==="generic"?o:void 0}));i!==void 0&&(r[n]=i)}return Object.keys(r).length>0?r:void 0}function br(e){return Se(e)}function Dr(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(Z(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function Nr(e,t){const r=[...e],n=new Set(r.map(i=>i.toLowerCase()));for(const i of t){const o=i.trim().replace(/:\d+$/,"");if(!o)continue;const s=o.toLowerCase();n.has(s)||(n.add(s),r.push(o))}return r}function Pr(e){let t=[],r=!1;for(const n of e){const i=Dr(n);i&&(r=!0,i.replace&&(t=[]),t=Nr(t,i.hosts))}return r?t:void 0}function yr(e){const t=e.filter(i=>i!==void 0);if(t.length===0)return;const r=Ae(t.map(({directHosts:i,...o})=>o)),n=Pr(t.map(i=>i?.directHosts));return n!==void 0&&(r.directHosts=n),r}function ee(e){return e?.backendProxy}function v(e){return e.replace(/\/$/,"")}function De(e){return/^https?:\/\//i.test(e)}function Ne(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Cr(e){const t=new Set;return e.filter(r=>!r.url||t.has(r.url)?!1:(t.add(r.url),!0))}function Lr(e){const t=ee(e);return t?[t]:[]}function vr(e){return{proxyEmFiles:!0,proxyAi:!1}}function Rr(e,t){const r=vr(t),n=t?.backendProxyPolicy;switch(e){case"emFiles":return n?.proxyEmFiles??r.proxyEmFiles;case"ai":return n?.proxyAi??r.proxyAi;default:return!0}}var wr={url:".+",url_encoded:".+",origin:"https?:\\/\\/[^\\/?#]+",origin_encoded:".+",proxy_url:"https?:\\/\\/[^\\/?#]+",proxy_url_encoded:".+",path:"[^?#]*",pathname:"[^?#]*",path_with_slash:"\\/[^?#]*",pathname_with_slash:"\\/[^?#]*",query:"[^#]*",search:"\\?[^#]*",hash:"#.*",fragment:".*",pathname_after_wp_json:"[^?#]*",pathname_after_wp_json_with_slash:"\\/[^?#]*",rest_namespace:"[^/?#]*",rest_version:"[^/?#]*",rest_route:"[^?#]*",rest_route_with_slash:"\\/[^?#]*"};function Mr(e){const t=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(n,i)=>(t.push(i),`(${wr[i]||".+"})`));return{regex:new RegExp(`^${r}$`,"i"),tokens:t}}function Br(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function jr(e,t){if(Br(t))return e;try{const r=new URL(e);return`${r.origin}${r.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function Fr(e,t,r){if(r.endsWith("_encoded"))return!0;const n=e.slice(0,t),i=n.lastIndexOf("#"),o=n.lastIndexOf("?"),s=n.lastIndexOf("&"),a=n.lastIndexOf("=");return a>Math.max(o,s)&&a>i}function xr(e){try{const t=new URL(e),r=t.pathname.replace(/^\/+/,""),n=t.search.replace(/^\?/,""),i=t.hash.replace(/^#/,""),o=r.replace(/^wp-json\/?/i,""),s=o?`/${o}`:"/",a=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),u=a?.[1]||"",_=a?.[2]||"",l=a?.[3]||"";return{url:e,url_encoded:encodeURIComponent(e),origin:t.origin,origin_encoded:encodeURIComponent(t.origin),proxy_url:t.origin,proxy_url_encoded:encodeURIComponent(t.origin),path:r,pathname:r,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:n,search:t.search,hash:t.hash,fragment:i,pathname_after_wp_json:o,pathname_after_wp_json_with_slash:s,rest_namespace:u,rest_version:_,rest_route:l,rest_route_with_slash:l?`/${l}`:"/"}}catch{return}}function te(e,t){if(!e)return{};if(Array.isArray(e)){for(const a of e){const u=te(a,t);if(u!==void 0)return u}return}if(e==="*")return{};const r=jr(t,e),{regex:n,tokens:i}=Mr(e),o=n.exec(r);if(!o)return;const s={};return i.forEach((a,u)=>{s[`matched_${a}`]=o[u+1]||""}),s}function x(e,t,r={}){const n=xr(t);if(!n)return t;const i={...n,...r};let o="",s=0;const a=/\{([a-z_]+)\}/gi;let u;for(;u=a.exec(e);){o+=e.slice(s,u.index);const _=i[u[1]]??"",l=Fr(e,u.index,u[1])?encodeURIComponent(_):_;o+=l,s=u.index+u[0].length}o+=e.slice(s);try{const _=new URL(o),l=new URL(t);return!o.includes("{search}")&&!o.includes("{query}")&&l.search&&l.searchParams.forEach((E,h)=>{_.searchParams.has(h)||_.searchParams.append(h,E)}),!o.includes("{hash}")&&!o.includes("{fragment}")&&l.hash&&!_.hash&&(_.hash=l.hash),_.toString()}catch{return o}}function Pe(e,t){try{const r=new URL(t);return`${v(e)}/${r.pathname.replace(/^\//,"")}${r.search}${r.hash}`}catch{return t}}function ye(e,t){const r=v(e);return t?De(t)?t:t.startsWith("?")||t.startsWith("#")?`${r}${t}`:`${r}${t.startsWith("/")?"":"/"}${t}`:r}function Ce(e,t,r,n){const i=e.match;return i?Array.isArray(i)?i.some(o=>Ce({...e,match:o},t,r,n)):typeof i=="function"?!!i({url:t,method:n,requestType:r}):i==="*"?!0:te(i,t)!==void 0:!0}function kr(e,t,r,n="generic"){if(e==null)return[];const i=Array.isArray(e)?e:[e],o=[];return i.forEach((s,a)=>{if(!s)return;if(typeof s=="string"){const E=s.includes("{")&&s.includes("}")?x(s,t):Pe(s,t);o.push({key:`backend:${a}`,url:E,source:"resource"});return}if(!Ne(s)||!("rewrite"in s))return;const u=s;if(!Ce(u,t,n,r))return;const _=typeof u.match=="string"||Array.isArray(u.match)?te(u.match,t)||{}:{},l=typeof u.proxyBase=="string"&&u.proxyBase.trim()?u.proxyBase.trim():void 0;(Array.isArray(u.rewrite)?u.rewrite:[u.rewrite]).filter(Boolean).forEach((E,h)=>{const p=typeof E=="function"?(()=>{const A=E({url:t,proxyBase:l,method:r,requestType:n,..._}),O=l&&!De(A)?ye(l,A):A;return O.includes("{")&&O.includes("}")?x(O,t,_):O})():l?x(ye(l,E),t,_):E.includes("{")&&E.includes("}")?x(E,t,_):Pe(E,t);o.push({key:`backend:${u.id||"rule"}:${a}:${h}`,url:p,source:"resource"})})}),Cr(o)}function Ur(e){try{const t=new URL(e);return/(?:^|\/)wp-json\/em-files\/v\d+(?:\/|$)/i.test(t.pathname)?"emFiles":/(?:^|\/)wp-json\/ai-generator\/v\d+(?:\/|$)/i.test(t.pathname)?"ai":"generic"}catch{return"generic"}}function Hr(e,t=[]){return e==null||(Array.isArray(e)?e:[e]).forEach(r=>{if(r){if(typeof r=="string"){const n=r.split("{")[0]?.trim();n&&t.push(v(n));return}!Ne(r)||!("rewrite"in r)||(typeof r.proxyBase=="string"&&r.proxyBase.trim()&&t.push(v(r.proxyBase.trim())),(Array.isArray(r.rewrite)?r.rewrite:[r.rewrite]).forEach(n=>{if(typeof n!="string")return;const i=n.split("{")[0]?.trim();i&&t.push(v(i))}))}}),t}function Gr(e,t){return Lr(t).flatMap(r=>Hr(r)).filter(Boolean).some(r=>r&&e.startsWith(r))}function Vr(e,t){return!!ee(t)&&Rr(e,t)}function Xr(e,t={}){const r=t.requestType||Ur(e);return Vr(r,t.config)?kr(ee(t.config),e,t.method,r):[]}function $r(e,t={}){return Gr(e,t.config)?[e]:Xr(e,t).map(r=>r.url)}function D(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function Le(...e){const t=e.filter(o=>o!=null);if(t.length===0)return;if(t.length===1)return t[0];const r=t.find(o=>o.aborted);if(r)return r;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const n=new AbortController,i=o=>{n.signal.aborted||n.abort(o.reason)};for(const o of t)o.addEventListener("abort",()=>i(o),{once:!0});return n.signal}var ve=3e5,Re=15e3,m=null,we=!1;function Wr(){return!0}function Kr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return ve;const t=Number(e);return Number.isFinite(t)&&t>0?t:ve}function qr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return Re;const t=Number(e);return Number.isFinite(t)&&t>0?t:Re}function zr(){const e="https://app.emailmaker.ru/api/".trim();return e?D(e):void 0}function Yr(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const r=JSON.parse(t);if(!Array.isArray(r))throw new Error("expected JSON array");return r.map(n=>String(n).trim()).filter(Boolean)}catch{return we||(we=!0),[]}return t.split(",").map(r=>r.trim()).filter(Boolean)}function Jr(e){const t=new Set,r=[];for(const n of e){const i=D(n);t.has(i)||(t.add(i),r.push(i))}return r}function Me(e){const t=String(e||"").trim();return t?D(t):zr()}function Be(e,t=[]){return e?Jr([e,...t]).slice(0,3):[]}function je(){return Yr(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function Qr(e=Date.now()){return m?e-m.switchedAt>=Kr():!0}function Fe(e=Date.now()){m&&Qr(e)&&(m=null)}function N(e){if(!Wr())return!1;const t=Me(e);if(!t)return!1;const r=je();return r.length===0?!1:Be(t,r).length>1}function R(e){const t=Me(e);if(!t)return[];const r=je();return r.length===0?[t]:Be(t,r)}function k(e){const t=R(e);if(t.length===0)return"";if(Fe(),m){const r=t.indexOf(m.activeUrl);if(r>=0)return t[r]}return t[0]}function xe(e){const t=R(e);if(t.length<=1||(Fe(),!m||!t.includes(m.activeUrl)))return t;const r=m.activeUrl;return[r,...t.filter(n=>n!==r)]}function ke(e){return k(e)||void 0}function Ue(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const r=qr(),n=new AbortController;let i;const o=setTimeout(()=>{i=Zr(r),n.abort(i)},r);return{signal:Le(t,n.signal),timeoutError:()=>i,done:()=>clearTimeout(o)}}function Zr(e){const t=`[apiOriginFailover] origin attempt timed out after ${e}ms`;if(typeof DOMException=="function")return new DOMException(t,"TimeoutError");const r=new Error(t);return r.name="TimeoutError",r}function He(e){return e===502||e===503||e===504}function Ge(e){return!(e instanceof Error)&&!(e instanceof DOMException)?!1:e.name==="TimeoutError"?!0:e instanceof TypeError}var Ve;function en(e){Ve=e}function U(e,t){if(!N(t))return;const r=R(t);if(r.length<=1)return;const n=r.indexOf(D(e));if(n<0)return;const i=n+1;if(i>=r.length)return;const o=r[i],s=m?.activeUrl;m={activeUrl:o,switchedAt:Date.now()},s!==o&&Ve?.()}function Xe(e,t){if(!N(t))return;const r=D(e),n=R(t);if(n.includes(r)){if(r===n[0]){m=null;return}m?.activeUrl!==r&&(m={activeUrl:r,switchedAt:Date.now()})}}function $e(){m=null}var tn=e=>{const t=new FormData,r=(n,i,o)=>{if(i!=null){if(i instanceof Blob){n.append(o,i);return}if(Array.isArray(i)){i.forEach((s,a)=>{const u=o?`${o}[${a}]`:`${a}`;r(n,s,u)});return}if(typeof i=="object"){Object.keys(i).forEach(s=>{const a=i[s],u=o?`${o}[${s}]`:s;r(n,a,u)});return}n.append(o,String(i))}};return r(t,e),t},rn={baseUrl:D("https://app.emailmaker.ru/api/"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},P=new Map;function nn(e){const t=e?.getInstance(de);return t?t.get()??t.bootstrap():void 0}var on=class extends ur{container;constructor(e={},t){super(e),this.container=t}buildRequestUrl(e){const{path:t,baseUrl:r,extraQuery:n}=e;let{query:i}=e;n&&(i=i?{...i,...n}:n);const o=i&&this.toQueryString(i);return`${r||this.baseUrl||""}${t}${o?`?${o}`:""}`}buildRequestKey(e,t){return`${t.toUpperCase()} ${e}`}getBackendProxyCandidates(e,t){const r=nn(this.container),n=this.container?.getInstance(Ee)!==void 0,i=$r(e,{config:r,method:t,standalone:n}),o=i.length>0?i:[e],s=this.buildRequestKey(e,t),a=P.get(s);return!a||!o.includes(a)?o:[a,...o.filter(u=>u!==a)]}shouldRetryResponse(e){return e.status===502||e.status===503||e.status===504}resolveFailoverBaseUrl(){return String(this.baseUrl||"").trim()||void 0}async requestOnOrigin(e,t,r=!1){const n={...e,baseUrl:t},i=this.buildRequestUrl(n),o=n.method||"GET",s=this.buildRequestKey(i,o),a=this.getBackendProxyCandidates(i,o);let u,_;for(const l of a){const E=p=>p===i?l:p,h=r?Ue(e.signal):void 0;try{const p=await super.request({...n,proxyHandler:E,...h?{signal:h.signal}:{}});if(!p.ok&&this.shouldRetryResponse(p)&&l!==a[a.length-1]){_=p,P.get(s)===l&&P.delete(s);continue}return P.set(s,l),p}catch(p){P.get(s)===l&&P.delete(s);const A=h?.timeoutError();if(A)throw A;if(u=p,(p instanceof DOMException||p instanceof Error)&&p.name==="AbortError")throw p}finally{h?.done()}}if(_)return _;throw u instanceof Error?u:new Error("Backend proxy chain failed")}async request(e){const t=String(e.baseUrl||"").trim();if(t)return this.requestOnOrigin(e,t);const r=this.resolveFailoverBaseUrl(),n=N(r),i=e.failoverAttemptTimeout??n,o=n?xe(r):r?[k(r)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let s,a;for(let u=0;u<o.length;u++){const _=o[u],l=u===o.length-1;try{const E=await this.requestOnOrigin(e,_,i);if(!E.ok&&He(E.status)){if(a=E,!l){U(_,r);continue}break}return E.ok&&Xe(_,r),E}catch(E){if(!Ge(E))throw E;s=E,l||U(_,r)}}if(n&&$e(),a)return a;throw s instanceof Error?s:new Error("API origin failover chain failed")}};function sn(e={},t){const r=new on({...rn,...e},t);return r.contentFormatters["multipart/form-data"]=tn,r}var We=f("rest.clientFactory"),an=e=>{pr(e);const t=sn({customFetch:e.getInstance(J)?.execute??Er},e);e.inject(Q,t)},Ke;(function(e){const t="https://racs.emcdn.ru/v3";function r(i,o){const s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(o)};return fetch(`${t}?resource=${i}&dataset=${document.location.hostname}`,s)}e.post=r;async function n(i,o=0){const s={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:`{"filter":{},"limit":${o}}`};return await(await fetch(`${t}/get?resource=${i}&dataset=${document.location.hostname}`,s)).json()}e.getAll=n})(Ke||(Ke={}));function w(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const r=Array.isArray(e),n=Array.isArray(t);if(r){if(!n)return!1;const a=e.length;if(t.length!==a)return!1;for(let u=0;u<a;u++)if(!w(e[u],t[u]))return!1}else if(n)return!1;const i=Object.keys(e),o=Object.keys(t),s=i.length;if(s!==o.length)return!1;for(let a=0;a<s;a++){const u=i[a];if(!t.hasOwnProperty(u)||!w(e[u],t[u]))return!1}}return!0}function cn(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),r=atob(t),n=new Uint8Array(r.length);for(let i=0;i<r.length;i++)n[i]=r.charCodeAt(i);return new TextDecoder().decode(n)}function qe(e){const[t,r,n]=e.split("."),i=JSON.parse(cn(r));return{exp:i.exp,createdAt:i.iat,data:i}}var re=f("plugin.auth.token"),ze=new WeakMap,un=3e4;function _n(e){let t;try{t=qe(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+un}function ln(e,t,r,n){const i=ze.get(e);i&&(i.stale=!0);const o={stale:!1};ze.set(e,o),e.injectFactory(re,async(s,a)=>{if(o.stale)return"";try{let u=await a||void 0;if(!u){const _=e.getInstance(fe);_&&(u=await _)}return t?!u||_n(u)?await t(r,n,u):u:""}catch{return""}},!0)}var Ye=f("auth.oauthProvided"),Je=new WeakMap;function Qe(e,t){const r=Je.get(e)??{applied:!1};(!r.applied||r.getAuthToken!==t.getAuthToken||!w(r.user,t.user)||r.project!==t.project)&&(Je.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),ln(e,t.getAuthToken,t.user,t.project))}function Ze(e){if(e.getInstance(Ye))return;e.inject(Ye,!0);let t;e.getInstance(le)?.watch(r=>{t=r}),e.addService(F,{execute:async(r,n)=>{if(n?.public||!t?.getAuthToken)return;e.getInstance(re)===void 0&&Qe(e,t);const i=await e.getInstanceAsync(re);i&&r.headers.set("authorization",`Bearer ${i}`)}})}var dn={theme:"canvas_fact_theme",flags:"canvas_fact_flags",commonStyles:"canvas_fact_common_styles",lockEditor:"canvas_fact_lock_editor",codeMode:"canvas_fact_code_mode",appName:"canvas_fact_app_name",previewPage:"canvas_fact_preview_page",viewport:"canvas_fact_viewport"},fn={text:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},headings:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, 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},links:{color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},buttons:{fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, 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:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},textAlign:"center",padding:{all:null,top:null,right:null,bottom:null,left:null}},block:{backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:{all:null,top:null,right:null,bottom:null,left:null}},cards:{contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null}}},et="ERROR",En="useblocks",pn={em_token:"em_access_token",em_refresh_token:"em_refresh_token",em_admin_token:"em_admin_access_token",em_admin_refresh_token:"em_admin_refresh_token",em_impersonation:"em_impersonation",em_elements_view:"em_elements_view",em_new_block:"em_new_block",em_new_email:"em_new_email",em_id:"em_id",em_name:"em_name",em_email:"em_email",em_locale:"em_locale",em_carrotquest_hash:"em_carrotquest_hash",em_ducalis_hash:"em_ducalis_hash",em_email_subscription_consent:"em_email_subscription_consent",em_folder:"em_folder",promocode:"promocode",em_active_tab:"em_active_tab"},hn={em_color_scheme:"em_color_scheme",em_code_mode_pane_sizes:"em_code_mode_pane_sizes",em_preview_pane_sizes:"em_preview_pane_sizes",em_default_sizes:"em_default_sizes",em_pane_sizes:"em_pane_sizes",em_test_emails:"em_test_emails",em_menu_is_locked:"em_menu_is_locked",em_code_mode_settings:"em_code_mode_settings",em_folder_is_open:"em_folder_is_open",em_active_tab:"em_active_tab",em_ai_settings:"em_ai_settings",em_last_active_page:"em_last_active_page",em_layout_convert_never_suggest:"em_layout_convert_never_suggest",em_filemanager_v2:"em_filemanager_v2",em_projects_v2:"em_projects_v2",em_translations_v2:"em_translations_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_guest_locale:"em_guest_locale"},On="light",mn="dark",An="system",gn="(prefers-color-scheme: dark)",In={MESSAGE:"message",INIT_PREVIEW:"init_preview",UPDATE_EDITOR:"update_editor",UPDATE_EDITOR_POSITION:"update_editor_position",UPDATE_SIDE_MENU_EDITOR:"update_side_menu_editor",SAVE_EMAIL:"saveEmail",SANDBOX_ELEMENT_SETTINGS_SET:"sandbox_element_settings_set",SANDBOX_IMAGE_RESET:"sandbox_image_reset",SANDBOX_NATIVE_IMAGE_DROP_CLEAR:"sandbox_native-image-drop-clear",SANDBOX_EMAIL_SETTINGS_SET:"sandbox_email_settings_set",SANDBOX_BLOCK_SETTINGS_SET:"sandbox_block_settings_set",SANDBOX_ELEMENT_PARENT_GET:"sandbox_element_parent_get",SANDBOX_ELEMENT_PARENT_TABLE_GET:"sandbox_element_parent_table_get",SANDBOX_ELEMENT_PREV_GET:"sandbox_element_prev_get",SANDBOX_ELEMENT_NEXT_GET:"sandbox_element_next_get",SANDBOX_ELEMENT_REMOVE:"sandbox_element_remove",SANDBOX_ELEMENT_ACTIVE_RESET:"sandbox_element_active_reset",SANDBOX_ELEMENT_ACTIVE_SET:"sandbox_element_active_set",SANDBOX_ELEMENT_HOVER_SET:"sandbox_element_hover_set",SANDBOX_ELEMENT_IMG_LINK:"sandbox_element_img_link",SANDBOX_ELEMENT_TEXT:"sandbox_element_text",SANDBOX_EMAIL_CONTENT_GET:"sandbox_email_content_get",SANDBOX_SET_POSITION_TO_IMG:"sandbox_set_position_to_img",SANDBOX_SET_POSITION_TO_LINK:"sandbox_set_position_to_link",SANDBOX_ACCORDION_ADD_SECTION:"sandbox_accordion_add_section",SANDBOX_ACCORDION_REMOVE_SECTION:"sandbox_accordion_remove_section",APPLICATION_FOCUS_IN_IFRAME:"application_focus_in_iframe",APPLICATION_EMAIL_SETTINGS_SET:"application_email_settings_set",APPLICATION_BLOCK_SETTINGS_SET:"application_block_settings_set",APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",_APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",APPLICATION_ELEMENT_SETTINGS_CLOSE:"application_element_settings_close",APPLICATION_ACTION:"application_action",APPLICATION_EBLOCK_ADD:"application_eblock_add",SANDBOX_EBLOCK_SET_EM_BLOCK_ID:"sandbox_eblock_set_em_block_id",SANDBOX_GLOBAL_BLOCK_REPLACE:"sandbox_global_block_replace",APPLICATION_SCROLL_TO:"application_scroll-to",APPLICATION_SCROLL_BLOCK_SHOW:"application_scroll-block-show",APPLICATION_SCROLL_BLOCK_HIDE:"application_scroll-block-hide",APPLICATION_DISCUSS_SET_ID:"application_discuss_set_id",APPLICATION_DISCUSS_GET_COMMENT:"application_discuss_get_comment",APPLICATION_DISCUSS_NO_COMMENT:"application_discuss_no_comment",APPLICATION_DISCUSS_SAVE_TARGET:"application_discuss_save_target",APPLICATION_IFRAME_SET_HEIGHT:"application_iframe_set_height",APPLICATION_COMMON_STYLES_UPDATE:"application_commonStyles_update",APPLICATION_EMAIL_CONTENT_GET:"application_email_content_get",APPLICATION_OPEN_IMAGE_AI_POPUP:"application_open-image-ai-popup",APPLICATION_OPEN_IMAGE_UPLOAD_POPUP:"application_open-image-upload-popup",APPLICATION_OPEN_IMAGE_EDIT_POPUP:"application_open-image-edit-popup",APPLICATION_OPEN_IMAGE_GIF_POPUP:"application_open-image-gif-popup",APPLICATION_OPEN_IMAGE_STOCK_POPUP:"application_open-image-stock-popup",APPLICATION_CLOSE_IMAGE_EDIT_POPUP:"application_close-image-edit-popup",APPLICATION_NATIVE_IMAGE_DROP:"application_native-image-drop",APPLICATION_SUBJECT_UPDATE:"application_subject_update",APPLICATION_PREHEADER_UPDATE:"application_preheader_update",APPLICATION_DOMPARSER_ERROR:"application_domparser_error",APPLICATION_SYNC_DRIFT:"application_sync_drift",APPLICATION_UPDATE_ENTITY:"application_update_entity",APPLICATION_IFRAME_DRAG_EVENT:"application_iframe_drag_event",APPLICATION_HAS_AMP:"application_has_amp",APPLICATION_CANVAS_IMAGE_GET:"application_canvas_image_get",APPLICATION_PREVIEW_ALERT_SHOW:"application_preview_alert_show",APPLICATION_ATOM_INSERTED:"application_atom_inserted",APPLICATION_TEMPLATE_NOT_EM_ALERT_SHOW:"application_template_not_em_alert_show",SANDBOX_IFRAME_SETSIZE:"sandbox_iframe-setsize",SANDBOX_BLOCK_INSERT:"sandbox_block-insert",SANDBOX_ATOM_INSERT:"sandbox_atom-insert",SANDBOX_DRAG_CANCEL:"sandbox_drag-cancel",UPDATE_EDITOR_POSITION_FROM_EDITOR:"update_position_from_editor",UPDATE_EDITOR_POSITION_FROM_IFRAME:"update_position_from_iframe",SANDBOX_CHANGE_PREVIEW:"sandbox_change_preview",APPLICATION_CHANGE_PREVIEW:"application_change_preview",SANDBOX_LOCK_EDIT:"sandbox_lock_edit",SANDBOX_FLOATBLOCK_ADD:"sandbox_floatBlock_add",SANDBOX_FLOATBLOCK_REMOVE:"sandbox_floatBlock_remove",SANDBOX_FLOATBLOCK_COPY:"sandbox_floatBlock_copy",SANDBOX_FLOATBLOCK_SWAP:"sandbox_floatBlock_swap",EDITOR_CHANGE_FOCUS:"editor_change_focus",SANDBOX_RESIZED:"sandbox_resized",SANDBOX_LOCK_DISCUSS:"sandbox_lock_discuss",SANDBOX_DISCUSS_SET_TARGET:"sandbox_discuss_set_target",SANDBOX_DISCUSS_REMOVE_TARGET:"sandbox_discuss_remove_target",SANDBOX_DISCUSS_RESET:"sandbox_discuss_reset",SANDBOX_DISCUSS_GET_TARGET:"sandbox_discuss_get_target",SANDBOX_READY:"SANDBOX_READY",SANDBOX_FLOATBLOCK_WRAP:"sandbox_floatblock_wrap",SANDBOX_FLOATBLOCK_DIR:"sandbox_floatblock_dir",SANDBOX_SUBJECT_UPDATE:"sandbox_subject_update",SANDBOX_PREHEADER_UPDATE:"sandbox_preheader_update",SANDBOX_DRAG_EVENT:"sandbox_drag_event",SANDBOX_WHEEL:"sandbox_wheel",SANDBOX_TRANSLATIONS:"sandbox_send_translations",SANDBOX_SET_THEME_VARIABLES:"sandbox_send_theme_variables",SANDBOX_SET_PROJECT_FONTS:"sandbox_set_project_fonts",SANDBOX_CANVAS_IMAGE_CACHE_SETUP:"sandbox_canvas_image_cache_setup",SANDBOX_SET_ENTITY:"sandbox_set_entity",SANDBOX_INIT_START:"sandbox_init_start",SANDBOX_INITED:"sandbox_inited",SANDBOX_UPDATE_ENTITY:"sandbox_update_entity",RELOAD:"reload",SANDBOX_ADD_EXTENSIONS:"sandbox_add_extensions",SANDBOX_REMOVE_EXTENSIONS:"sandbox_remove_extensions",SANDBOX_ADD_SCRIPT:"sandbox_add_script",SANDBOX_IS_EMAIL_EMPTY:"sandbox_is_email_empty",SANDBOX_SWITCH_THEME:"sandbox_switch_theme",SANDBOX_CANVAS_HEALTH:"sandbox_canvas_health"},Tn={language:"html",detectIndentation:!1,wordWrap:"on",wrappingIndent:"same",smoothScrolling:!0,automaticLayout:!0,tabSize:2,indentSize:2},tt=e=>{const t={current:Promise.resolve(),state:e,decorate:(r,n)=>(n&&(r=r.bind(n)),function(...i){const o=t.current.then(()=>r(...i));return t.current=o.then(s=>{t.state=s},s=>{}),o})};return t};function ne(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function Sn(e){return t=>{const r={},n=[];for(const s of e)n.push(s(t));for(const s of n)Object.assign(r,s.instance);return{instance:r,setOptions:async s=>{for(const a of n)await a.setOptions(s)},dispose:()=>{for(const s of n)s.dispose()}}}}function bn(e=et){const t=new Error(e);return t.name="AuthPipelineError",t}async function rt(e,t,r,n){const i=n?.attemptTimeout??N(r),o=N(r)?xe(r):R(r).length>0?[k(r)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const s=e.startsWith("/")?e:`/${e}`;let a,u;for(let _=0;_<o.length;_++){const l=o[_],E=_===o.length-1,h=i?Ue(t.signal):void 0;try{const p=await fetch(`${l}${s}`,{...t,...h?{signal:h.signal}:{}});if(!p.ok&&He(p.status)){if(a=p,!E){U(l,r);continue}break}return p.ok&&Xe(l,r),p}catch(p){const A=h?.timeoutError();if(!A&&!Ge(p))throw p;u=A||p,E||U(l,r)}finally{h?.done()}}if(N(r)&&$e(),a)return a;throw u instanceof Error?u:new Error("[apiOriginFailover] fetch chain failed")}function nt(e){e.inject(C,void 0),e.inject(z,void 0)}var Dn=ne(e=>{let t,r;const n=tt();return e.addService(F,{execute:n.decorate(async(i,o)=>{if(o?.public||!t)return;const s=String(e.getInstance(z)||"").trim();if(s){i.headers.append("authorization",`Bearer ${s}`);return}if(!e.getInstance(C))try{const a=e.getInstance(We),u=String(a?.getOptions()?.baseUrl||"").trim(),_=ke(r||u||void 0);if(!_)throw new Error("JWT auth requires baseUrl");const l=await rt("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},_);if(!l.ok)throw new Error(`JWT auth failed: ${l.status}`);const E=await l.json(),h=String(E.token||"").trim();if(!h)throw new Error("JWT auth failed: empty token");e.inject(C,void 0),e.inject(z,h),i.headers.append("authorization",`Bearer ${h}`)}catch{throw e.inject(C,et),bn()}})}),{setOptions(i){const o=i.jwtAuth,s=String(i.baseUrl||"").trim()||void 0,a=!w(o,t),u=s!==r;if(t=o,r=s,!o){nt(e);return}a||u?nt(e):e.inject(C,void 0)}}}),Nn=ne(e=>(Ze(e),{setOptions(t){Qe(e,t)}}));function Pn(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function ie(e,t=document){try{const n=t.querySelector(e);if(n)return n}catch{return null}const r=t.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;if(!i)continue;const o=ie(e,i);if(o)return o}return null}function it(e,t=[]){const r=e.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;i&&(t.push(i),it(i,t))}return t}function yn(e,t,r){if(e.isConnected)return e;const n=e.id?.trim();return n?ot(`#${Pn(n)}`,t,r):Promise.reject(S("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function ot(e,t,r){if(K(r),typeof e<"u"){if(typeof e=="string"){const n=e,i=ie(n);if(i)return i;const o=t.addDisposable(new g);return new Promise((s,a)=>{const u=O=>{o.dispose(),O()},_=()=>{u(()=>a(S(r?.reason)))};if(r?.aborted){_();return}r?.addEventListener("abort",_),o.addDispose(()=>r?.removeEventListener("abort",_));const l=document.body??document.documentElement;if(!l){u(()=>a(S("Document is not ready to observe mount element")));return}const E=new Set,h=new MutationObserver(()=>{const O=ie(n);if(O){u(()=>s(O));return}A()}),p=O=>{E.has(O)||(E.add(O),h.observe(O,{attributes:!0,childList:!0,subtree:!0}))},A=()=>{const O=document.documentElement;if(O)for(const H of it(O))p(H)};p(l),A(),o.addDispose(()=>h.disconnect())})}return e instanceof Element?yn(e,t,r):e}return e}var Cn=new Map;Object.defineProperty(c,"ADVANCED_SETTINGS_PANEL",{enumerable:!0,get:function(){return rr}}),Object.defineProperty(c,"APP_COOKIES",{enumerable:!0,get:function(){return pn}}),Object.defineProperty(c,"APP_ID",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(c,"APP_LOAD_EVENT_ID",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(c,"ATOMS_HANDLERS_ID",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(c,"AsyncEmitter",{enumerable:!0,get:function(){return j}}),Object.defineProperty(c,"BaseEmitter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(c,"CANVAS_FACTS",{enumerable:!0,get:function(){return dn}}),Object.defineProperty(c,"COMMON_STYLES",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(c,"CONFIG_CHANGED_EVENT_ID",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(c,"CONFIG_SOURCE_ID",{enumerable:!0,get:function(){return de}}),Object.defineProperty(c,"COOKIE_MANAGER_ID",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(c,"CUSTOM_FETCH_ID",{enumerable:!0,get:function(){return J}}),Object.defineProperty(c,"ContentType",{enumerable:!0,get:function(){return cr}}),Object.defineProperty(c,"DARK",{enumerable:!0,get:function(){return mn}}),Object.defineProperty(c,"DISPOSABLE_ID",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(c,"DependencyResolver",{enumerable:!0,get:function(){return W}}),Object.defineProperty(c,"Disposable",{enumerable:!0,get:function(){return g}}),Object.defineProperty(c,"ELEMENT_MAP",{enumerable:!0,get:function(){return Cn}}),Object.defineProperty(c,"EVENT_TYPES",{enumerable:!0,get:function(){return In}}),Object.defineProperty(c,"Emitter",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(c,"HANDLE_ATOM_INSERT_ID",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(c,"HEADLESS_MODE_ID",{enumerable:!0,get:function(){return Jt}}),Object.defineProperty(c,"INIT_PIPELINE_ID",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(c,"INSTANCE_ID",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(c,"JWTMixin",{enumerable:!0,get:function(){return Dn}}),Object.defineProperty(c,"LATE_SURFACE_LISTENERS_ID",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(c,"LIGHT",{enumerable:!0,get:function(){return On}}),Object.defineProperty(c,"LOCAL_STORAGE_ITEMS",{enumerable:!0,get:function(){return hn}}),Object.defineProperty(c,"MESSAGE_SERVICE_ID",{enumerable:!0,get:function(){return er}}),Object.defineProperty(c,"MODAL_CLOSE_EVENT",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(c,"MODAL_SHOW_EVENT",{enumerable:!0,get:function(){return nr}}),Object.defineProperty(c,"MODAL_UPDATE_EVENT",{enumerable:!0,get:function(){return or}}),Object.defineProperty(c,"MONACO_EDITOR_OPTIONS",{enumerable:!0,get:function(){return Tn}}),Object.defineProperty(c,"MessageService",{enumerable:!0,get:function(){return qt}}),Object.defineProperty(c,"OAuthMixin",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(c,"OPTIONS_SOURCE_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(c,"PLUGIN_COLLECTION_ID",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(c,"PORT_READY",{enumerable:!0,get:function(){return he}}),Object.defineProperty(c,"PREFERS_COLOR_SCHEME_DARK",{enumerable:!0,get:function(){return gn}}),Object.defineProperty(c,"PUBLIC_REQUEST",{enumerable:!0,get:function(){return me}}),Object.defineProperty(c,"REQUEST_HANDLER_ID",{enumerable:!0,get:function(){return F}}),Object.defineProperty(c,"REST_CLIENT_FACTORY_ID",{enumerable:!0,get:function(){return We}}),Object.defineProperty(c,"REST_TRANSPORT_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(c,"SANDBOX_EXTENSIONS_ID",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(c,"SANDBOX_EXTENSION_SCRIPT_STATUS_ID",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(c,"SECURITY_MODULE_ID",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(c,"SETTINGS_PANEL_EVENT",{enumerable:!0,get:function(){return tr}}),Object.defineProperty(c,"STANDALONE_ACTIVATED_ID",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(c,"STANDALONE_BOOTSTRAP_TOKEN_ID",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(c,"STANDALONE_FILE_PROXY_REGISTERED_ID",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(c,"STANDALONE_PROJECT_ID",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(c,"STORE_ID",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(c,"SYSTEM",{enumerable:!0,get:function(){return An}}),Object.defineProperty(c,"Signal",{enumerable:!0,get:function(){return St}}),Object.defineProperty(c,"TEMPLATE_DIRECTIVES_ID",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(c,"USEBLOCKS",{enumerable:!0,get:function(){return En}}),Object.defineProperty(c,"combineMixins",{enumerable:!0,get:function(){return Sn}}),Object.defineProperty(c,"composeAbortSignals",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(c,"createAbortError",{enumerable:!0,get:function(){return S}}),Object.defineProperty(c,"createIdentifier",{enumerable:!0,get:function(){return Xt}}),Object.defineProperty(c,"createIdentifier$1",{enumerable:!0,get:function(){return f}}),Object.defineProperty(c,"createQueue",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(c,"debounce",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(c,"decodeJwt",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(c,"deepEqual",{enumerable:!0,get:function(){return w}}),Object.defineProperty(c,"defineMixin",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(c,"events",{enumerable:!0,get:function(){return q}}),Object.defineProperty(c,"fetchWithApiOriginFailover",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(c,"filter",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(c,"generateUUID",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(c,"getActiveBaseUrl",{enumerable:!0,get:function(){return k}}),Object.defineProperty(c,"getApi",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(c,"getEmitter",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(c,"getEmitter$1",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(c,"getEvent",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(c,"getServiceContainerId",{enumerable:!0,get:function(){return M}}),Object.defineProperty(c,"isAbortError",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(c,"mapHttpStatusToErrorCode",{enumerable:!0,get:function(){return At}}),Object.defineProperty(c,"mergeBackendProxyLayers",{enumerable:!0,get:function(){return br}}),Object.defineProperty(c,"mergeResourceProxyLayers",{enumerable:!0,get:function(){return Sr}}),Object.defineProperty(c,"mergeResourceProxyPolicyLayers",{enumerable:!0,get:function(){return yr}}),Object.defineProperty(c,"mergeShallowConfigLayers",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(c,"pickKey",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(c,"provideOAuth",{enumerable:!0,get:function(){return Ze}}),Object.defineProperty(c,"raceWithAbortSignal",{enumerable:!0,get:function(){return It}}),Object.defineProperty(c,"registerRestTransport",{enumerable:!0,get:function(){return an}}),Object.defineProperty(c,"releaseContainer",{enumerable:!0,get:function(){return Ar}}),Object.defineProperty(c,"resolveContainer",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(c,"resolveExplicitApiBaseUrl",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(c,"setApiOriginFailoverHook",{enumerable:!0,get:function(){return en}}),Object.defineProperty(c,"snapshot",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(c,"throwIfAborted",{enumerable:!0,get:function(){return K}}),Object.defineProperty(c,"waitForElement",{enumerable:!0,get:function(){return ot}})});
2097
2097
 
2098
2098
 
2099
2099
  __emailmaker__.define("static/umd/b3ebeaee.js",["require","exports","module"],function(f,l,m){var v=(function(){const e=typeof document<"u"&&document.createElement("link").relList;return e&&e.supports&&e.supports("modulepreload")?"modulepreload":"preload"})(),k=function(n,e){return new URL(n,e).href},h={},c=function(e,E,P){let p=Promise.resolve();if(0)var R,w;function i(r){const t=new Event("vite:preloadError",{cancelable:!0});if(t.payload=r,window.dispatchEvent(t),!t.defaultPrevented)throw r}return p.then(r=>{for(const t of r||[])t.status==="rejected"&&i(t.reason);return e().catch(i)})};Object.defineProperty(l,"__vitePreload",{enumerable:!0,get:function(){return c}})});
2100
2100
 
2101
2101
 
2102
- __emailmaker__.define("emailmaker.js",["require","exports","module","static/umd/790cf6cb.js","static/umd/312a9b80.js","static/umd/b3ebeaee.js"],function(St,de,O_){Object.defineProperties(de,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const dn=St("./static/umd/790cf6cb.js"),l=St("./static/umd/312a9b80.js"),Ja=St("./static/umd/b3ebeaee.js");var Qa=new Function("url","return import(url)");function Za(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function un(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Qr(e){return e.type==="umd"||e.resolve==="registry"}var el="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 tl(e){const t=Array.isArray(e)?e[0]:e;return un(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function nl(e,t){const n=tl(e),r=un(e)?e:void 0,o=t instanceof Error?t.message:String(t),s=r&&Qr(r)&&!/compat/iu.test(o)?` ${el}`:"",i=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${s}`);return i.cause=t,{name:n,url:r?.url,error:i}}function rl(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}function R_(e){return e}var ol=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(un(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(Qr(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Qa(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 s=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):rl(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},i=()=>window.removeEventListener("error",s);window.addEventListener("error",s),r.onload=()=>{if(i(),o){n(o);return}t()},r.onerror=()=>{i(),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 s=this._createOrSkip(o.ctor,o.options);s&&!n.has(s)&&(n.add(s),t.push(s))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const i of e){const a=await this._resolveOrSkip(i);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((i,a)=>{t.has(a)||r.push({key:a,plugin:i})});for(let i=r.length-1;i>=0;i--){const{key:a,plugin:c}=r[i];await this._initializingPlugins.get(c),await this._disposePlugin(c,c.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(c),this._resolveMap.delete(c),this._initializingPlugins.delete(c),this._initializedPlugins.delete(c);const d=this._creationOrder.indexOf(c);d>=0&&this._creationOrder.splice(d,1)}const o=[],s=new Set;for(const{ctor:i,options:a}of n){const c=this._createOrSkip(i,a);c&&!s.has(c)&&(s.add(c),o.push(c))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let s,i=!1;const a=()=>{i||(i=!0,s&&clearTimeout(s),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(s=setTimeout(()=>{i||(i=!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),s=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:s}),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=nl(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 Za(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 s=this._initializingPlugins.get(o);if(s){n.add(s);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const s of r)this._initializingPlugins.set(s,o);n.add(o),o.finally(()=>{for(const s of r)this._initializingPlugins.get(s)===o&&this._initializingPlugins.delete(s)})}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(s){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:s})}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)}))}},sl=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)}}}},il=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()}},Zr=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 al(e,t){return t+e}function ll(){return typeof performance>"u"?Date.now():al(performance.now(),performance.timeOrigin)}var cl="emailmaker:diagnostics",dl="diagnostics",ul="diagnostics";function eo(e,t){return t?`${e}${e.includes("?")?"&":"?"}${ul}=1`:e}var fn;function fl(){try{const e=new URLSearchParams(window.location.search).get(dl);return e===null?void 0:e!=="0"}catch{return}}function pl(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function hl(){try{const e=window.localStorage.getItem(cl);return e===null?void 0:e==="1"}catch{return}}function Je(){return fn===void 0&&(fn=typeof window>"u"?!1:fl()??pl()??hl()??!1),fn}function ml(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var oe={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"},k_=Object.values(oe),L_=[oe.canvasPainted,oe.canvasSettled,oe.appVisible,oe.editorVisible],gl=5e3,vl=3e3,to="diagnosticsStore",wt,Qe;function no(){return{marks:new Zr(gl),resources:new Zr(vl)}}function ro(){if(Qe)return Qe;const e=pn();return e?(Qe=e[to]??wt??no(),e[to]=Qe,wt=void 0,Qe):(wt??=no(),wt)}function J(e,t){Je()&&ro().marks.push({phase:e,at:ll(),...t})}function pn(){if(typeof __emailmaker__<"u"&&__emailmaker__)return __emailmaker__;if(typeof window>"u")return;const e=window[ml()];return e!==null&&typeof e=="object"?e:void 0}function El(e){const t=e.length,n=ro();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function _l(){const e=pn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:El(e.diagnosticsBuffer)}var bl="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function _e(){const e=new Error(bl);return e.name="DestroyedInstanceError",e}function yl(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function hn(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 s=e,i=t;return s.length===i.length&&s.every((a,c)=>hn(a,i[c]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&hn(e[s],t[s]))}function oo(e,t){const n={watch(r){let o,s=!1;return e.watch(i=>{const a=t(i);s&&hn(o,a)||(o=a,s=!0,r(a))})},select(r){return oo(n,r)}};return n}function ae(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(s){t=s,n=!0;for(const i of Array.from(r))i(s)},watch(s){return r.add(s),n&&s(t),{dispose:()=>r.delete(s)}},select(s){return oo(o,s)}};return o}var Sl=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:l.ContentType.UrlEncoded,...t})},so=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 wl(e){return String(e||"").trim()||void 0}var Il=class extends l.Disposable{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=wl(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)}},mn=l.createIdentifier$1("AppInitService");function Tl(e){return async()=>{const t=await e();return(await new Sl(t).app_init_create({})).data}}function Cl(e){e.injectFactory(mn,(t,n)=>{if(n)return n;const r=new Il({options:e.getInstance(l.OPTIONS_SOURCE_ID),isStandalone:()=>!!e.getInstance(l.SECURITY_MODULE_ID),resolveRestBaseUrl:o=>o?l.getActiveBaseUrl(o):l.getActiveBaseUrl()||void 0,setRestBaseUrl:o=>{e.getInstance(l.REST_CLIENT_FACTORY_ID)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:Tl(()=>e.getInstanceAsync(l.REST_TRANSPORT_ID)),publish:o=>{e.inject(l.APP_ID,o)}});return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var gn=l.createIdentifier$1("documentSession.emailDocuments");function Be(e){return e?.getInstance(gn)}var Al=l.createIdentifier$1("RevisionServiceFlag");function io(e){return e.getOrCreateInstance(Al,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function ao(e){return io(e).isEnabled()}var Dl=l.createIdentifier$1("EmailRightsResolver");function Pl(e,t){const n=e.getInstance(Dl);return n?n(t):!0}var lo=l.createIdentifier$1("EmailHistoryAvailabilityResolver");function Ol(e){return e.getInstance(lo)!==void 0}async function Rl(e){const t=e.getInstance(lo);if(!t)return!0;try{return await t()}catch{return!1}}var vn={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},co=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],uo=2e4,kl=co.reduce((e,t)=>e+vn[t],0),fo=uo+kl+3e3;function Ll(e){return co.reduce((t,n)=>t+po(n,e),0)}function po(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:vn[e]}function ho(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:fo}function mo(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:uo}function It(e=fo){return e+3e3}var N_="[show-pipeline]";function go(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}function M_(e,t){}var Nl=()=>It();function Ml(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function xl(e){return t=>Ml(e.getOrCreateInstance(l.events.BEFORE_SAVE_EMAIL,()=>new l.AsyncEmitter).fire(t),Nl())}function Fl(e){return e!=null&&e!==""}var vo;function Ze(e,t){return vo?.capture(e,t)}function Bl(e,t){return vo?.captureMessage(e,t)}function jl(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Tt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var he=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} "${Tt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Tt(this.oldText)}")`:`(replace@${this.oldPosition} "${Tt(this.oldText)}" with "${Tt(this.newText)}")`}};function Eo(e,t){return e===null||e.length===0?t:new Ul(e,t).compress()}var Ul=class Ee{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[c,d]=Ee._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(c),o=d;continue}if(r.newPosition<o.oldPosition){const[c,d]=Ee._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(c),r=d;continue}let i,a;if(o.oldEnd===r.newEnd)i=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[c,d]=Ee._splitPrev(r,o.oldLength);i=c,a=o,r=d,o=this._getCurr(++n)}else{const[c,d]=Ee._splitCurr(o,r.newLength);i=r,a=c,r=this._getPrev(++t),o=d}this._result[this._resultLen++]=new he(i.oldPosition,i.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=i.newLength-i.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const s=Ee._merge(this._result);return Ee._removeNoOps(s)}_acceptCurr(t){this._result[this._resultLen++]=Ee._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++]=Ee._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 he(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new he(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 he(t.oldPosition,t.oldText,t.newPosition,r),new he(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new he(t.oldPosition,r,t.newPosition,t.newText),new he(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 s=1;s<t.length;s++){const i=t[s];o.oldEnd===i.oldPosition?o=new he(o.oldPosition,o.oldText+i.oldText,o.newPosition,o.newText+i.newText):(n[r++]=o,o=i)}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 s=t[o];s.oldText!==s.newText&&(n[r++]=s)}return n}};function Hl(e){return new he(e.newPosition,e.newText,e.oldPosition,e.oldText)}function $l(e){return e.map(Hl)}function _o(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Vl(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 Gl(e,t,n){let r=0;const o=e.start===e.end;for(const s of t){const i=s.newLength-s.oldLength;if(s.oldLength===0){const a=s.oldPosition;if(o&&a===e.start)r+=n==="after"?i:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=i)}continue}if(o){if(e.start>=s.oldEnd)r+=i;else if(e.start>s.oldPosition)return null;continue}if(e.start>=s.oldEnd)r+=i;else if(e.end>s.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var Ie=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},bo=0,Wl=Math.random().toString(36).slice(2,8);function Yl(){return bo+=1,`doc-${Wl}-${bo}`}function ql(e){const t=e.createBuffer(),n=e.docId??Yl();let r=e.serverId??null,o=0,s=null,i=e.attributes??{};const a=new Set;let c=!1,d=!1,u;const f=new Set;let h=null;const v=()=>(h?.version!==o&&(h={version:o,value:t.read()}),h.value),_=y=>Object.entries(y).some(([m,T])=>i[m]!==T);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:s,attributes:i}),getContent:v,mutate(y,{source:m}){if(c)return o;const T=y.changes?.length?y.changes:void 0,P=T?Vl(v(),T):y.content!==void 0?y.content:void 0,F=P!==void 0&&P!==v(),N=y.attributes!==void 0&&_(y.attributes);if(!F&&!N)return o;const C=!(o>(s??-1)),E=N?Object.keys(y.attributes).filter(w=>i[w]!==y.attributes[w]):[];F&&t.write(P),N&&(i={...i,...y.attributes}),o+=1,m!=="user"&&C&&(s=o);const b={source:m,version:o,changes:T,...F?{content:!0}:{},...E.length>0?{attributes:E}:{}};return a.forEach(w=>w(b)),o},markSaved(y,m){const T={serverId:r,savedVersion:s};m!==void 0&&(r=m),(s===null||y>s)&&(s=y),(T.serverId!==r||T.savedVersion!==s)&&a.forEach(P=>P({source:"system",version:o}))},markUnsaved(){c||s===null||s<o||(s=o-1,a.forEach(y=>y({source:"system",version:o})))},markReady(){d||u!==void 0||(d=!0,f.forEach(y=>y.resolve()),f.clear(),a.forEach(y=>y({source:"system",version:o})))},isReady:()=>d,markFailed(y){d||u!==void 0||c||(u=y,f.forEach(m=>m.reject(new Ie(y))),f.clear(),a.forEach(m=>m({source:"system",version:o})))},failure:()=>u,whenReady(){return d?Promise.resolve():u!==void 0?Promise.reject(new Ie(u)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((y,m)=>{f.add({resolve:y,reject:m})})},subscribe(y){return a.add(y),()=>a.delete(y)},isNew:()=>r===null,isDirty:()=>o>(s??-1),isDisposed:()=>c,dispose(){c=!0,f.forEach(y=>y.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),f.clear(),a.clear(),t.dispose()}}}var zl=500,Kl=100,En=0;function Xl(e,t={}){const n=t.groupIntervalMs??zl,r=t.maxSteps??Kl,o=t.now??(()=>0);let s=[],i=0,a=En+=1,c=null,d=!1,u=!1,f=!1;const h=new Set,v=()=>h.forEach(E=>E()),_=(E,b)=>{if(E.length){u=!0;try{e.mutate({changes:E},{source:b})}finally{u=!1}}},y=E=>_(E,"user"),m=E=>{const b=o();d&&c!==null&&b-c<n?s[i-1]=Eo(s[i-1],E):(s=s.slice(0,i),s.push(E),i=s.length,d=!0,s.length>r&&(s=s.slice(s.length-r),i=s.length,a=En+=1)),c=b,v()},T=()=>{d=!1,c=null},P=E=>{if(!E.length)return;const b=s.length>i;b&&(s=s.slice(0,i)),i>0&&(s[i-1]=Eo(s[i-1],E)),T(),b&&v()},F=e.subscribe(({source:E,changes:b})=>{if(!(f||u||!b?.length)){if(E==="remote"){N();return}if(E!=="user"){P(b);return}m(b)}}),N=()=>{s=[],i=0,T(),a=En+=1,v()},C=()=>{if(i===0)return!1;const E=$l(s[i-1]);return _o(e.getContent(),E)?(y(E),i-=1,T(),!0):(s=s.slice(0,i-1),i=s.length,T(),v(),!1)};return{canUndo:()=>i>0,canRedo:()=>i<s.length,undo(){C()&&v()},redo(){if(!(i>=s.length)){if(!_o(e.getContent(),s[i])){s=s.slice(0,i),T(),v();return}y(s[i]),i+=1,T(),v()}},clear:N,applyWithoutHistory(E){const b=e.get().version;if(_(E,"system"),e.get().version===b){T();return}P(E)},getPast:E=>s.slice(0,i).reverse().slice(0,E),getFuture:E=>s.slice(i).reverse().slice(0,E),createSnapshot:()=>({stackId:a,index:i}),restoreSnapshot(E){if(E.stackId!==a||E.index>i)return!1;for(;i>E.index;)if(!C())return v(),!1;return v(),!0},subscribe(E){return h.add(E),()=>h.delete(E)},dispose(){f=!0,F(),h.clear(),s=[],i=0}}}var Jl=["edit","move","resize","insert"];function _n(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Ql(e){return typeof e=="string"?e:null}function Zl(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function ec(e){return Jl.includes(e)?e:null}function tc(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:Ql(t.originId),changeId:_n(t.changeId),rev:_n(t.rev),baseRev:_n(t.baseRev),expected:Zl(t.expected),intent:ec(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var et=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},yo=class extends Error{timeoutMs;constructor(e){super(`[emailmaker] handleEmailAutosave did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Ct=class extends Error{timeoutMs;constructor(e,t="handleSaveEmail",n="email"){super(`[emailmaker] ${t} did not respond within ${e}ms — the ${n} was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function nc(){return typeof navigator<"u"&&navigator.onLine===!1}function rc(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 So(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 So(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 oc(e){return nc()?!0:rc(e).some(So)}var wo=new WeakSet,Io=new WeakMap;function To(e){typeof e=="object"&&e!==null&&wo.add(e)}function sc(e,t){typeof e=="object"&&e!==null&&Io.set(e,t)}function ic(e){return typeof e=="object"&&e!==null?Io.get(e):void 0}function ac(e){return e instanceof Ct||e instanceof yo||typeof e=="object"&&e!==null&&wo.has(e)}function lc(e){return e instanceof et||ac(e)}function cc(e){return!lc(e)&&oc(e)}var Co="draft";function je(e){return e==null||e===""?Co:String(e)}function At(e){return e==null||e===""?`${bn}${Co}`:`${bn}${String(e)}`}var bn="block:";function Q(e){return e?.startsWith(bn)===!0}function Ue(e){return Q(e.sessionKey())?void 0:e.current()}function x_(e,t){}function Te(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return J(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(J(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const s=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw l.isAbortError(o)?(`${e}`,{...n}):(`${e}`,{error:go(o),...n},void 0),o})}var F_=5e3,dc=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function uc(e){const t=e?.trim()??"";if(!dc.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function tt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function yn(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function fc(e,t={}){const n=tt((e??[]).filter(r=>r?.html?.trim()));return yn(n,t)?n:null}function pc(e,t){const n=Date.parse(tt(e)?.modified??""),r=fc(e),o=Date.parse(r?.modified??""),s=t===void 0||Number.isFinite(o)&&o>t,i=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:s?r:null,...i.length?{latestAt:Math.max(...i)}:{}}}function Ao(e,t,n){const r=tt((e??[]).filter(c=>c?.html?.trim())),o=Date.parse(r?.modified??""),s=Date.parse(tt((n??[]).filter(c=>c?.html?.trim()))?.modified??""),i=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(s>o),a=[Date.parse(tt(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:i&&yn(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function hc({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Do=e=>e.replace(/\r\n?/g,`
2103
- `),Po=["recovery","plugin","rest"],mc=["subject","preheader"];function gc(e){let t={},n;for(let o=Po.length-1;o>=0;o--){const s=e.get(Po[o]);s&&(s.attributes&&(t={...t,...s.attributes}),s.content!==void 0&&(n=s.content))}const r=e.get("plugin")?.attributes;for(const o of mc){const s=r?.[o];typeof s=="string"&&s!==""&&(t={...t,[o]:s})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Sn(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Do(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 he(0,n,0,r)]}:{}},{source:"remote"})}var wn=e=>typeof e=="string"?e.trim():"";function vc(e,t,n,r){const{version:o,attributes:s}=e.get(),i=s,a=r==="snapshot"||r==="anchor",c=a?i.author:void 0,d=a?i.date_gmt:void 0,u=wn(i.title)||wn(i.subject)||wn(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:u,subject:i.subject,preheader:i.preheader,description:i.description,common_styles:i.common_styles||"",meta:i.meta,utm_parameters:i.utm_parameters,parent_email:i.parent_email,is_template:i.is_template||!1,is_inited:i.is_inited,tags:i.tags,emailtags:i.emailtags,group:i.group,renderGuid:e.get().docId,project:t.project??i.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...c!=null&&c!==""?{author:c}:{},...d?{excerpt:d}:{}}}}var Ec=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function _c(e){const t={};for(const n of Ec)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function bc(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 ge(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=ge(o)),n[r]=o)}return n}function yc(e){return typeof e=="string"&&e.includes("autosave")}var Sc=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Oo(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Sc.has(t))):{}}function He(e,t,n={}){e&&e.mutate({attributes:wc(e.get().attributes,t)},{source:n.source??"user"})}function wc(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function In(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Ic(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Ro(e){if(!e)return null;const t=Oo(e);return e.common_styles!==void 0&&(t.common_styles=Ic(e.common_styles)),In(e.html,t)}function ko(e){return e?In(e.html,ge(Oo(e))):null}var Tc=["common_styles","subject","preheader","meta"];function Lo(e){if(!e?.html?.trim())return null;const t={};for(const n of Tc)Cc(n,e[n])&&(t[n]=e[n]);return In(e.html,t)}function Cc(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 Ac=["modified","lock"];function Dc(e){if(!e)return null;const t={};for(const n of Ac)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Pc=10,Oc=(e,t)=>e.key===t.key&&Rc(e.serverId,t.serverId),Rc=(e,t)=>e==null||e===t;function kc(e){return typeof e?.then=="function"}var No=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Mo=e=>{e.request.serverId!=null&&!Tn(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},Lc=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),Tn=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),xo=(e,t)=>t?.content!==void 0&&hc({hasUnsavedUserEdit:Tn(e)})==="skip",Fo=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},Nc=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()}),Mc=(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))},xc=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,s])=>e.attributes[o]!==s)),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}},Fc=e=>{const t=gc(e.reports),n=xc(e.lastMerged,t);e.lastMerged=t,n&&(Sn(e.document,n),Mo(e))},Cn=(e,t)=>{if(!e.ready&&!Tn(e)){Fc(e);return}Sn(e.document,t)},Bc=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 jc(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:s,canEdit:i,notifyBeforeSave:a,onAdapterError:c,onTimeout:d}=e;let u,f;const h=new Set,v=new Set,_=()=>h.forEach(p=>p()),y=(p,S)=>{if(!(p.closed||p.ready)){if(p.error!==void 0){p.document.markFailed(p.error),p.document.get().docId;return}Mo(p),p.ready=!0,p.document.markReady(),p.document.get().docId,[...p.reports.keys()]}},m=(p,S,B)=>{c?.(S.id,B),!(!S.required||p.closed)&&(p.error=B,p.document.get().docId,S.id,_())},T=(p,S)=>{const B=new Set(S.map(j=>j.id));S.forEach(j=>{j.watch&&p.watchers.push(j.watch(R=>p.closed?!1:p.ready&&(xo(p,R)||p.contentShown===!0&&R?.content!==void 0)?(p.document.get().docId,j.id,!1):(R&&p.reports.set(j.id,R),Cn(p,R),R?.content!==void 0&&(p.showFill=void 0),!0)))});const V=(j,R)=>{if(!p.closed){if(!j.required&&xo(p,R)){p.document.get().docId,j.id,j.loaded?.(!1);return}R&&(p.reports.set(j.id,R),j.id==="plugin"&&Fo(p,R)),Cn(p,R),j.loaded?.(R!==null)}},$=()=>{B.size>0||p.closed||(No(p),y(p,[]))},G=[];if(S.forEach(j=>{let R;try{R=j.load()}catch(H){m(p,j,H),B.delete(j.id);return}if(kc(R)){G.push({id:j.id,required:j.required,load:()=>R,...j.loaded?{loaded:H=>j.loaded?.(H)}:{}});return}V(j,R),B.delete(j.id)}),G.length===0){$();return}p.timer=setTimeout(()=>{p.timer=void 0,d?.([...B]),p.document.get().docId,[...B],y(p,[...B])},n),p.timer.unref?.(),G.forEach(j=>{j.load().then(R=>V(j,R)).catch(R=>{m(p,j,R)}).finally(()=>{B.delete(j.id),$()})})},P=async(p,S,B)=>{if(B==="snapshot"||B==="anchor")return;const V=s?.();if(V)return V.resolve({project:S.project??p.project,tags:(p.tags??[]).map($=>({name:$}))})},F=p=>{if(p.lock===!0&&i?.(p)===!1)return new et("locked");const S=p.tags?.length??0,B=p.emailtags?.length??0;if(Math.max(S,B)>Pc)return new et("too-many-tags")},N=(p,S)=>{const B=p.document.get().serverId;S||B==null||(p.recoveryFacts={emailId:B,historyLoaded:!0,isRecovering:!1},Q(p.request.key)||(p.request={...p.request,key:je(B),serverId:B}))},C=(p,S,B)=>{if(p.closed||B?.id==null)return;const V=p.document.get().serverId,$=V!=null;$&&V!==String(B.id)||(p.document.markSaved(S,String(B.id)),N(p,$),p.document.get().serverId,_())},E=async(p,S,B)=>{try{await p.document.whenReady()}catch(R){return p.saveError=R,p.saveFailures+=1,p.failedIntent=S,p.saveFailures,!1}if(p.closed)return!1;const V=F(p.document.get().attributes);if(V)return p.saveError=V,p.saveFailures+=1,p.failedIntent=S,V.reason,_(),!1;if(a&&(await a(Bc(p)).catch(()=>{}),p.closed))return!1;if(Lc(p))return S==="snapshot"||(p.saveError=new et("empty-content"),p.saveFailures+=1,p.failedIntent=S,_()),!1;let $;try{$=await P(p.document.get().attributes,B,S)}catch(R){return p.saveError=R,p.saveFailures+=1,p.failedIntent=S,p.saveFailures,_(),!1}if(p.closed)return!1;const{payload:G,version:j}=vc(p.document,B,$,S);p.document.get().docId;try{const R=p.document.get().serverId!=null,H=await bc(r(),o(p.request.key),S,p.document.get().serverId,G);if(p.closed)return!0;let q;if(S==="snapshot"||S==="anchor"){const X=H?.modified!=null?Date.parse(H.modified):NaN;q=Number.isFinite(X)?X:Date.now(),p.snapshotVersion=j,p.lastRevisionAt=q}else p.document.markSaved(j,H?.id!=null?String(H.id):void 0),p.savedContent=G.html;N(p,R),p.saveError=void 0,p.saveFailures=0,p.failedIntent=void 0,p.document.get().serverId,_();const K={intent:S,serverId:p.document.get().serverId,created:!R,...q!==void 0?{revisionAt:q}:{}};return v.forEach(X=>X(K)),!0}catch(R){return(S==="publish"||S==="materialize")&&ic(R)?.then(H=>C(p,j,H)),p.saveError=R,p.saveFailures+=1,p.failedIntent=S,p.saveFailures,_(),!1}},b=p=>{p.closed=!0,p.watchers.forEach(S=>S()),p.watchers=[],No(p),p.history.dispose(),p.document.dispose()},w=()=>{u&&(b(u),u=void 0)},O=()=>{f&&(b(f),f=void 0)},M=(p,S,B)=>{let V=!1;S.show&&(p.show?.id!==S.show.id||p.show.token!==S.show.token)&&(p.show=S.show,V=!0,{docId:p.document.get().docId,...S.show});const $=B==="show"?ko(S.patch):null;$&&(p.reports.set("plugin",$),Fo(p,$),Cn(p,$),Mc(p,$)),V&&_()},D=(p,S={})=>I(u,p,S),k=()=>u&&Q(u.request.key??"")?f:u,g=p=>({error:p?.saveError,failures:p?.saveFailures??0,saving:p?.saving===!0,failedIntent:p?.failedIntent}),I=(p,S,B)=>!p||p.closed||S==="materialize"&&p.document.get().serverId!=null?Promise.resolve(!1):p.saving?S==="snapshot"||S==="materialize"?Promise.resolve(!1):(p.inFlight??Promise.resolve(!1)).then(()=>I(p,S,B)):(p.saving=!0,_(),p.inFlight=E(p,S,B).finally(()=>{p.saving=!1,p.inFlight=void 0,u===p&&!p.closed&&_()}),p.inFlight),x=(p,S="open",B=!1)=>{if(u&&!u.closed&&S!=="new"&&Oc(u.request,p))return M(u,p,S),u.document;w(),B||O();const V=ql({createBuffer:()=>jl(""),serverId:p.serverId??null}),$={request:p,show:p.show,document:V,history:Xl(V,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return u=$,$.watchers.push(Nc($)),V.get().docId,p.serverId,T($,t(p,{publishRecoveryFacts(G){$.closed||($.recoveryFacts=G,_())},readShownContent:()=>$.closed?null:$.document.getContent()})),_(),V},A=(p,S,B)=>({key:Q(p)?p:At(p),serverId:S?.id!=null?String(S.id):null,email:S,show:B});return{openWith:x,open:(p,S={})=>x({key:je(p),serverId:p,email:S.email,patch:S.patch,show:S.show},"open"),openDraft:(p,S={})=>x({key:je(void 0),serverId:null,email:p,patch:S.patch,show:S.show},"open"),startNewDraft:(p,S={})=>x({key:je(void 0),serverId:null,email:p,patch:S.patch,show:S.show},"new"),reload:(p,S={})=>x({key:je(p),serverId:p,email:S.email,patch:S.patch,show:S.show},"new"),openBlock:(p,S,B)=>x(A(p,S,B),"open"),reloadBlock:(p,S,B)=>x(A(p,S,B),"new"),openBlockOver:(p,S)=>{const B=A(p,S);return u&&!u.closed&&u.request.key===B.key?u.document:(u&&!u.closed&&!Q(u.request.key)&&(O(),f=u,u=void 0),x(B,"open",!0))},resumeSuspended:()=>{if(f)return w(),u=f,f=void 0,_(),u.document},hasSuspended:()=>!!f,suspendedDocument:()=>f?.document,show:(p,S)=>{const B=u;if(!(!B||B.closed))return x({...B.request,patch:p,show:S},"show")},current:()=>u?.document,noteServerFacts:({serverId:p,block:S},B)=>{const V=u;!V||V.closed||V.request.serverId!==p||Q(V.request.key??"")===S&&Sn(V.document,Dc(B))},save:D,saveEmail:(p,S={})=>I(k(),p,S),saveState:()=>g(u),emailSaveState:()=>g(k()),revisionFacts(){if(!u)return;const p=u.revisionFactsSnapshot;return p&&p.snapshotVersion===u.snapshotVersion&&p.lastRevisionAt===u.lastRevisionAt?p:(u.revisionFactsSnapshot={snapshotVersion:u.snapshotVersion,lastRevisionAt:u.lastRevisionAt},u.revisionFactsSnapshot)},recoveryFacts:()=>u?.recoveryFacts,history:()=>u?.history,forcedHeaders:()=>u?.forcedHeaders,beginForcedHeaders(p){u&&!u.closed&&(u.forcedHeaders=p)},endForcedHeaders(){for(const p of[u,f])p&&(p.forcedHeaders=void 0)},onSaved(p){return v.add(p),()=>v.delete(p)},showFacts:()=>u?.show,shownHeaders:()=>({...u?.shownHeaders}),showFill:()=>u?.showFill,beginShowFill(p){u&&!u.closed&&(u.showFill={showId:p,codeEdits:0})},noteCodeEdit(){u?.showFill&&(u.showFill.codeEdits+=1)},endShowFill(p){for(const S of[u,f])S?.showFill?.showId===p&&(S.showFill=void 0)},sessionKey:()=>u?.request.key,openError:()=>u?.error,subscribe(p){return h.add(p),()=>h.delete(p)},close(){!u&&!f||(w(),O(),_())}}}var An=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function Dn(e){if(e instanceof An)return e.reason;if(e instanceof Ie)return Dn(e.reason)}function Uc(e){const t=e instanceof Ie?e.reason:e;return t instanceof An&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Hc(e){const t=Dn(e);return t==="forbidden"||t==="not-found"}function $c(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new An("not-found");return Ro(n)}}}var Bo=l.createIdentifier$1("EmailPort");function Vc(e){return e.getInstance(Bo)}function Gc(e,t){e.inject(Bo,t)}var jo=l.createIdentifier$1("documentSession.restEmailPortFactories");function Uo(e){return e.getInstance(jo)!==void 0}function Ce(e){const t=e.getInstance(jo);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var Wc=l.createIdentifier$1("EmailTermsResolver");function Yc(e){return e.getInstance(Wc)}var Ho=l.createIdentifier$1("EmailHistoryPort"),qc=l.createIdentifier$1("BlockHistoryPort");function $o(e){return e.getInstance(qc)}function Vo(e){return e.getInstance(Ho)}function zc(e,t){e.inject(Ho,t)}var Kc="em_autosave_pending",B_=6e4;function Dt(e){return`${Kc}_${e}`}function Xc(e,t){try{sessionStorage.setItem(Dt(e),JSON.stringify(t))}catch{}}function Go(e){try{const t=sessionStorage.getItem(Dt(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(Dt(e)),null):n}catch{return null}}function nt(e){try{sessionStorage.removeItem(Dt(e))}catch{}}var Jc=2e3,Qc=5e3,Zc=5,ed=5e3,td=4;function nd(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function rd(e,t){return e==null||t==null?!1:e.replaceAll(`\r
2102
+ __emailmaker__.define("emailmaker.js",["require","exports","module","static/umd/790cf6cb.js","static/umd/3a37cbb5.js","static/umd/b3ebeaee.js"],function(St,de,O_){Object.defineProperties(de,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const dn=St("./static/umd/790cf6cb.js"),l=St("./static/umd/3a37cbb5.js"),Ja=St("./static/umd/b3ebeaee.js");var Qa=new Function("url","return import(url)");function Za(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function un(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Qr(e){return e.type==="umd"||e.resolve==="registry"}var el="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 tl(e){const t=Array.isArray(e)?e[0]:e;return un(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function nl(e,t){const n=tl(e),r=un(e)?e:void 0,o=t instanceof Error?t.message:String(t),s=r&&Qr(r)&&!/compat/iu.test(o)?` ${el}`:"",i=new Error(`Plugin "${n}" was skipped: it failed to load. ${o}${s}`);return i.cause=t,{name:n,url:r?.url,error:i}}function rl(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}function R_(e){return e}var ol=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(un(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(Qr(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Qa(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 s=a=>{o||(a.filename===r.src?o=this._scriptExecutionError(e,a.error??a.message):rl(a)&&(o=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},i=()=>window.removeEventListener("error",s);window.addEventListener("error",s),r.onload=()=>{if(i(),o){n(o);return}t()},r.onerror=()=>{i(),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 s=this._createOrSkip(o.ctor,o.options);s&&!n.has(s)&&(n.add(s),t.push(s))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const i of e){const a=await this._resolveOrSkip(i);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((i,a)=>{t.has(a)||r.push({key:a,plugin:i})});for(let i=r.length-1;i>=0;i--){const{key:a,plugin:c}=r[i];await this._initializingPlugins.get(c),await this._disposePlugin(c,c.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(c),this._resolveMap.delete(c),this._initializingPlugins.delete(c),this._initializedPlugins.delete(c);const d=this._creationOrder.indexOf(c);d>=0&&this._creationOrder.splice(d,1)}const o=[],s=new Set;for(const{ctor:i,options:a}of n){const c=this._createOrSkip(i,a);c&&!s.has(c)&&(s.add(c),o.push(c))}this._activated&&await this._startPluginsBatch(o)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,o)=>{let s,i=!1;const a=()=>{i||(i=!0,s&&clearTimeout(s),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(s=setTimeout(()=>{i||(i=!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),s=o.constructor.name;this._emitLifecycle({type:"created",plugin:o,name:s}),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=nl(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 Za(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 s=this._initializingPlugins.get(o);if(s){n.add(s);continue}r.push(o)}if(r.length>0){const o=this._runBatchLifecycle(r);for(const s of r)this._initializingPlugins.set(s,o);n.add(o),o.finally(()=>{for(const s of r)this._initializingPlugins.get(s)===o&&this._initializingPlugins.delete(s)})}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(s){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:s})}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)}))}},sl=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)}}}},il=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()}},Zr=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 al(e,t){return t+e}function ll(){return typeof performance>"u"?Date.now():al(performance.now(),performance.timeOrigin)}var cl="emailmaker:diagnostics",dl="diagnostics",ul="diagnostics";function eo(e,t){return t?`${e}${e.includes("?")?"&":"?"}${ul}=1`:e}var fn;function fl(){try{const e=new URLSearchParams(window.location.search).get(dl);return e===null?void 0:e!=="0"}catch{return}}function pl(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function hl(){try{const e=window.localStorage.getItem(cl);return e===null?void 0:e==="1"}catch{return}}function Je(){return fn===void 0&&(fn=typeof window>"u"?!1:fl()??pl()??hl()??!1),fn}function ml(e){return`__${(e||"emailmaker").toLowerCase().replaceAll("-","")}__`}var oe={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"},k_=Object.values(oe),N_=[oe.canvasPainted,oe.canvasSettled,oe.appVisible,oe.editorVisible],gl=5e3,vl=3e3,to="diagnosticsStore",wt,Qe;function no(){return{marks:new Zr(gl),resources:new Zr(vl)}}function ro(){if(Qe)return Qe;const e=pn();return e?(Qe=e[to]??wt??no(),e[to]=Qe,wt=void 0,Qe):(wt??=no(),wt)}function J(e,t){Je()&&ro().marks.push({phase:e,at:ll(),...t})}function pn(){if(typeof __emailmaker__<"u"&&__emailmaker__)return __emailmaker__;if(typeof window>"u")return;const e=window[ml()];return e!==null&&typeof e=="object"?e:void 0}function El(e){const t=e.length,n=ro();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function _l(){const e=pn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:El(e.diagnosticsBuffer)}var bl="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function _e(){const e=new Error(bl);return e.name="DestroyedInstanceError",e}function yl(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function hn(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 s=e,i=t;return s.length===i.length&&s.every((a,c)=>hn(a,i[c]))}const r=Object.keys(e),o=Object.keys(t);return r.length!==o.length?!1:r.every(s=>Object.prototype.hasOwnProperty.call(t,s)&&hn(e[s],t[s]))}function oo(e,t){const n={watch(r){let o,s=!1;return e.watch(i=>{const a=t(i);s&&hn(o,a)||(o=a,s=!0,r(a))})},select(r){return oo(n,r)}};return n}function ae(...e){let t=e[0],n=e.length>0;const r=new Set,o={get(){return n?t:void 0},set(s){t=s,n=!0;for(const i of Array.from(r))i(s)},watch(s){return r.add(s),n&&s(t),{dispose:()=>r.delete(s)}},select(s){return oo(o,s)}};return o}var Sl=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:l.ContentType.UrlEncoded,...t})},so=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 wl(e){return String(e||"").trim()||void 0}var Il=class extends l.Disposable{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=wl(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)}},mn=l.createIdentifier$1("AppInitService");function Tl(e){return async()=>{const t=await e();return(await new Sl(t).app_init_create({})).data}}function Cl(e){e.injectFactory(mn,(t,n)=>{if(n)return n;const r=new Il({options:e.getInstance(l.OPTIONS_SOURCE_ID),isStandalone:()=>!!e.getInstance(l.SECURITY_MODULE_ID),resolveRestBaseUrl:o=>o?l.getActiveBaseUrl(o):l.getActiveBaseUrl()||void 0,setRestBaseUrl:o=>{e.getInstance(l.REST_CLIENT_FACTORY_ID)?.setOptions(o?{baseUrl:o}:{})},fallbackAppInit:Tl(()=>e.getInstanceAsync(l.REST_TRANSPORT_ID)),publish:o=>{e.inject(l.APP_ID,o)}});return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var gn=l.createIdentifier$1("documentSession.emailDocuments");function Be(e){return e?.getInstance(gn)}var Al=l.createIdentifier$1("RevisionServiceFlag");function io(e){return e.getOrCreateInstance(Al,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function ao(e){return io(e).isEnabled()}var Dl=l.createIdentifier$1("EmailRightsResolver");function Pl(e,t){const n=e.getInstance(Dl);return n?n(t):!0}var lo=l.createIdentifier$1("EmailHistoryAvailabilityResolver");function Ol(e){return e.getInstance(lo)!==void 0}async function Rl(e){const t=e.getInstance(lo);if(!t)return!0;try{return await t()}catch{return!1}}var vn={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},co=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],uo=2e4,kl=co.reduce((e,t)=>e+vn[t],0),fo=uo+kl+3e3;function Nl(e){return co.reduce((t,n)=>t+po(n,e),0)}function po(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:vn[e]}function ho(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:fo}function mo(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:uo}function It(e=fo){return e+3e3}var L_="[show-pipeline]";function go(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}function M_(e,t){}var Ll=()=>It();function Ml(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function xl(e){return t=>Ml(e.getOrCreateInstance(l.events.BEFORE_SAVE_EMAIL,()=>new l.AsyncEmitter).fire(t),Ll())}function Fl(e){return e!=null&&e!==""}var vo;function Ze(e,t){return vo?.capture(e,t)}function Bl(e,t){return vo?.captureMessage(e,t)}function jl(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Tt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var he=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} "${Tt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Tt(this.oldText)}")`:`(replace@${this.oldPosition} "${Tt(this.oldText)}" with "${Tt(this.newText)}")`}};function Eo(e,t){return e===null||e.length===0?t:new Ul(e,t).compress()}var Ul=class Ee{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),o=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(o===null)break;this._acceptCurr(o),o=this._getCurr(++n);continue}if(o===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldEnd<=r.newPosition){this._acceptCurr(o),o=this._getCurr(++n);continue}if(r.newEnd<=o.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(o.oldPosition<r.newPosition){const[c,d]=Ee._splitCurr(o,r.newPosition-o.oldPosition);this._acceptCurr(c),o=d;continue}if(r.newPosition<o.oldPosition){const[c,d]=Ee._splitPrev(r,o.oldPosition-r.newPosition);this._acceptPrev(c),r=d;continue}let i,a;if(o.oldEnd===r.newEnd)i=r,a=o,r=this._getPrev(++t),o=this._getCurr(++n);else if(o.oldEnd<r.newEnd){const[c,d]=Ee._splitPrev(r,o.oldLength);i=c,a=o,r=d,o=this._getCurr(++n)}else{const[c,d]=Ee._splitCurr(o,r.newLength);i=r,a=c,r=this._getPrev(++t),o=d}this._result[this._resultLen++]=new he(i.oldPosition,i.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=i.newLength-i.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const s=Ee._merge(this._result);return Ee._removeNoOps(s)}_acceptCurr(t){this._result[this._resultLen++]=Ee._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++]=Ee._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 he(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new he(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 he(t.oldPosition,t.oldText,t.newPosition,r),new he(t.oldEnd,"",t.newPosition+n,o)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),o=t.oldText.substr(n);return[new he(t.oldPosition,r,t.newPosition,t.newText),new he(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 s=1;s<t.length;s++){const i=t[s];o.oldEnd===i.oldPosition?o=new he(o.oldPosition,o.oldText+i.oldText,o.newPosition,o.newText+i.newText):(n[r++]=o,o=i)}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 s=t[o];s.oldText!==s.newText&&(n[r++]=s)}return n}};function Hl(e){return new he(e.newPosition,e.newText,e.oldPosition,e.oldText)}function $l(e){return e.map(Hl)}function _o(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Vl(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 Gl(e,t,n){let r=0;const o=e.start===e.end;for(const s of t){const i=s.newLength-s.oldLength;if(s.oldLength===0){const a=s.oldPosition;if(o&&a===e.start)r+=n==="after"?i:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=i)}continue}if(o){if(e.start>=s.oldEnd)r+=i;else if(e.start>s.oldPosition)return null;continue}if(e.start>=s.oldEnd)r+=i;else if(e.end>s.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var Ie=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},bo=0,Yl=Math.random().toString(36).slice(2,8);function Wl(){return bo+=1,`doc-${Yl}-${bo}`}function ql(e){const t=e.createBuffer(),n=e.docId??Wl();let r=e.serverId??null,o=0,s=null,i=e.attributes??{};const a=new Set;let c=!1,d=!1,u;const f=new Set;let h=null;const g=()=>(h?.version!==o&&(h={version:o,value:t.read()}),h.value),_=y=>Object.entries(y).some(([m,T])=>i[m]!==T);return{get:()=>({docId:n,serverId:r,version:o,savedVersion:s,attributes:i}),getContent:g,mutate(y,{source:m}){if(c)return o;const T=y.changes?.length?y.changes:void 0,D=T?Vl(g(),T):y.content!==void 0?y.content:void 0,B=D!==void 0&&D!==g(),M=y.attributes!==void 0&&_(y.attributes);if(!B&&!M)return o;const C=!(o>(s??-1)),E=M?Object.keys(y.attributes).filter(w=>i[w]!==y.attributes[w]):[];B&&t.write(D),M&&(i={...i,...y.attributes}),o+=1,m!=="user"&&C&&(s=o);const b={source:m,version:o,changes:T,...B?{content:!0}:{},...E.length>0?{attributes:E}:{}};return a.forEach(w=>w(b)),o},markSaved(y,m){const T={serverId:r,savedVersion:s};m!==void 0&&(r=m),(s===null||y>s)&&(s=y),(T.serverId!==r||T.savedVersion!==s)&&a.forEach(D=>D({source:"system",version:o}))},markUnsaved(){c||s===null||s<o||(s=o-1,a.forEach(y=>y({source:"system",version:o})))},markReady(){d||u!==void 0||(d=!0,f.forEach(y=>y.resolve()),f.clear(),a.forEach(y=>y({source:"system",version:o})))},isReady:()=>d,markFailed(y){d||u!==void 0||c||(u=y,f.forEach(m=>m.reject(new Ie(y))),f.clear(),a.forEach(m=>m({source:"system",version:o})))},failure:()=>u,whenReady(){return d?Promise.resolve():u!==void 0?Promise.reject(new Ie(u)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((y,m)=>{f.add({resolve:y,reject:m})})},subscribe(y){return a.add(y),()=>a.delete(y)},isNew:()=>r===null,isDirty:()=>o>(s??-1),isDisposed:()=>c,dispose(){c=!0,f.forEach(y=>y.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),f.clear(),a.clear(),t.dispose()}}}var Kl=500,zl=100,En=0;function Xl(e,t={}){const n=t.groupIntervalMs??Kl,r=t.maxSteps??zl,o=t.now??(()=>0);let s=[],i=0,a=En+=1,c=null,d=!1,u=!1,f=!1;const h=new Set,g=()=>h.forEach(E=>E()),_=(E,b)=>{if(E.length){u=!0;try{e.mutate({changes:E},{source:b})}finally{u=!1}}},y=E=>_(E,"user"),m=E=>{const b=o();d&&c!==null&&b-c<n?s[i-1]=Eo(s[i-1],E):(s=s.slice(0,i),s.push(E),i=s.length,d=!0,s.length>r&&(s=s.slice(s.length-r),i=s.length,a=En+=1)),c=b,g()},T=()=>{d=!1,c=null},D=E=>{if(!E.length)return;const b=s.length>i;b&&(s=s.slice(0,i)),i>0&&(s[i-1]=Eo(s[i-1],E)),T(),b&&g()},B=e.subscribe(({source:E,changes:b})=>{if(!(f||u||!b?.length)){if(E==="remote"){M();return}if(E!=="user"){D(b);return}m(b)}}),M=()=>{s=[],i=0,T(),a=En+=1,g()},C=()=>{if(i===0)return!1;const E=$l(s[i-1]);return _o(e.getContent(),E)?(y(E),i-=1,T(),!0):(s=s.slice(0,i-1),i=s.length,T(),g(),!1)};return{canUndo:()=>i>0,canRedo:()=>i<s.length,undo(){C()&&g()},redo(){if(!(i>=s.length)){if(!_o(e.getContent(),s[i])){s=s.slice(0,i),T(),g();return}y(s[i]),i+=1,T(),g()}},clear:M,applyWithoutHistory(E){const b=e.get().version;if(_(E,"system"),e.get().version===b){T();return}D(E)},getPast:E=>s.slice(0,i).reverse().slice(0,E),getFuture:E=>s.slice(i).reverse().slice(0,E),createSnapshot:()=>({stackId:a,index:i}),restoreSnapshot(E){if(E.stackId!==a||E.index>i)return!1;for(;i>E.index;)if(!C())return g(),!1;return g(),!0},subscribe(E){return h.add(E),()=>h.delete(E)},dispose(){f=!0,B(),h.clear(),s=[],i=0}}}var Jl=["edit","move","resize","insert"];function _n(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function Ql(e){return typeof e=="string"?e:null}function Zl(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function ec(e){return Jl.includes(e)?e:null}function tc(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:Ql(t.originId),changeId:_n(t.changeId),rev:_n(t.rev),baseRev:_n(t.baseRev),expected:Zl(t.expected),intent:ec(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var et=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},yo=class extends Error{timeoutMs;constructor(e){super(`[emailmaker] handleEmailAutosave did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Ct=class extends Error{timeoutMs;constructor(e,t="handleSaveEmail",n="email"){super(`[emailmaker] ${t} did not respond within ${e}ms — the ${n} was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function nc(){return typeof navigator<"u"&&navigator.onLine===!1}function rc(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 So(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 So(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 oc(e){return nc()?!0:rc(e).some(So)}var wo=new WeakSet,Io=new WeakMap;function To(e){typeof e=="object"&&e!==null&&wo.add(e)}function sc(e,t){typeof e=="object"&&e!==null&&Io.set(e,t)}function ic(e){return typeof e=="object"&&e!==null?Io.get(e):void 0}function ac(e){return e instanceof Ct||e instanceof yo||typeof e=="object"&&e!==null&&wo.has(e)}function lc(e){return e instanceof et||ac(e)}function cc(e){return!lc(e)&&oc(e)}var Co="draft";function je(e){return e==null||e===""?Co:String(e)}function At(e){return e==null||e===""?`${bn}${Co}`:`${bn}${String(e)}`}var bn="block:";function Q(e){return e?.startsWith(bn)===!0}function Ue(e){return Q(e.sessionKey())?void 0:e.current()}function x_(e,t){}function Te(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return J(`show:gate:${e}`,{kind:"wait"}),t.then(o=>(J(`show:gate:${e}:end`,{kind:"wait"}),o),o=>{const s=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw l.isAbortError(o)?(`${e}`,{...n}):(`${e}`,{error:go(o),...n},void 0),o})}var F_=5e3,dc=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function uc(e){const t=e?.trim()??"";if(!dc.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function tt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function yn(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function fc(e,t={}){const n=tt((e??[]).filter(r=>r?.html?.trim()));return yn(n,t)?n:null}function pc(e,t){const n=Date.parse(tt(e)?.modified??""),r=fc(e),o=Date.parse(r?.modified??""),s=t===void 0||Number.isFinite(o)&&o>t,i=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:s?r:null,...i.length?{latestAt:Math.max(...i)}:{}}}function Ao(e,t,n){const r=tt((e??[]).filter(c=>c?.html?.trim())),o=Date.parse(r?.modified??""),s=Date.parse(tt((n??[]).filter(c=>c?.html?.trim()))?.modified??""),i=r&&Number.isFinite(o)&&(t===void 0||o>t)&&!(s>o),a=[Date.parse(tt(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:i&&yn(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function hc({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Do=e=>e.replace(/\r\n?/g,`
2103
+ `),Po=["recovery","plugin","rest"],mc=["subject","preheader"];function gc(e){let t={},n;for(let o=Po.length-1;o>=0;o--){const s=e.get(Po[o]);s&&(s.attributes&&(t={...t,...s.attributes}),s.content!==void 0&&(n=s.content))}const r=e.get("plugin")?.attributes;for(const o of mc){const s=r?.[o];typeof s=="string"&&s!==""&&(t={...t,[o]:s})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Sn(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Do(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 he(0,n,0,r)]}:{}},{source:"remote"})}var wn=e=>typeof e=="string"?e.trim():"";function vc(e,t,n,r){const{version:o,attributes:s}=e.get(),i=s,a=r==="snapshot"||r==="anchor",c=a?i.author:void 0,d=a?i.date_gmt:void 0,u=wn(i.title)||wn(i.subject)||wn(t.fallbackTitle);return{version:o,payload:{html:e.getContent(),title:u,subject:i.subject,preheader:i.preheader,description:i.description,common_styles:i.common_styles||"",meta:i.meta,utm_parameters:i.utm_parameters,parent_email:i.parent_email,is_template:i.is_template||!1,is_inited:i.is_inited,tags:i.tags,emailtags:i.emailtags,group:i.group,renderGuid:e.get().docId,project:t.project??i.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...c!=null&&c!==""?{author:c}:{},...d?{excerpt:d}:{}}}}var Ec=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function _c(e){const t={};for(const n of Ec)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function bc(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 ge(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=ge(o)),n[r]=o)}return n}function yc(e){return typeof e=="string"&&e.includes("autosave")}var Sc=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Oo(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Sc.has(t))):{}}function He(e,t,n={}){e&&e.mutate({attributes:wc(e.get().attributes,t)},{source:n.source??"user"})}function wc(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function In(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Ic(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Ro(e){if(!e)return null;const t=Oo(e);return e.common_styles!==void 0&&(t.common_styles=Ic(e.common_styles)),In(e.html,t)}function ko(e){return e?In(e.html,ge(Oo(e))):null}var Tc=["common_styles","subject","preheader","meta"];function No(e){if(!e?.html?.trim())return null;const t={};for(const n of Tc)Cc(n,e[n])&&(t[n]=e[n]);return In(e.html,t)}function Cc(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 Ac=["modified","lock"];function Dc(e){if(!e)return null;const t={};for(const n of Ac)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Pc=10,Oc=(e,t)=>e.key===t.key&&Rc(e.serverId,t.serverId),Rc=(e,t)=>e==null||e===t;function kc(e){return typeof e?.then=="function"}var Lo=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Mo=e=>{e.request.serverId!=null&&!Tn(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},Nc=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),Tn=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),xo=(e,t)=>t?.content!==void 0&&hc({hasUnsavedUserEdit:Tn(e)})==="skip",Fo=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},Lc=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()}),Mc=(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))},xc=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([o,s])=>e.attributes[o]!==s)),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}},Fc=e=>{const t=gc(e.reports),n=xc(e.lastMerged,t);e.lastMerged=t,n&&(Sn(e.document,n),Mo(e))},Cn=(e,t)=>{if(!e.ready&&!Tn(e)){Fc(e);return}Sn(e.document,t)},Bc=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 jc(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:o,resolveTerms:s,canEdit:i,notifyBeforeSave:a,onAdapterError:c,onTimeout:d}=e;let u,f;const h=new Set,g=new Set,_=()=>h.forEach(p=>p()),y=(p,S)=>{if(!(p.closed||p.ready)){if(p.error!==void 0){p.document.markFailed(p.error),p.document.get().docId;return}Mo(p),p.ready=!0,p.document.markReady(),p.document.get().docId,[...p.reports.keys()]}},m=(p,S,F)=>{c?.(S.id,F),!(!S.required||p.closed)&&(p.error=F,p.document.get().docId,S.id,_())},T=(p,S)=>{const F=new Set(S.map(j=>j.id));S.forEach(j=>{j.watch&&p.watchers.push(j.watch(R=>p.closed?!1:p.ready&&(xo(p,R)||p.contentShown===!0&&R?.content!==void 0)?(p.document.get().docId,j.id,!1):(R&&p.reports.set(j.id,R),Cn(p,R),R?.content!==void 0&&(p.showFill=void 0),!0)))});const V=(j,R)=>{if(!p.closed){if(!j.required&&xo(p,R)){p.document.get().docId,j.id,j.loaded?.(!1);return}R&&(p.reports.set(j.id,R),j.id==="plugin"&&Fo(p,R)),Cn(p,R),j.loaded?.(R!==null)}},$=()=>{F.size>0||p.closed||(Lo(p),y(p,[]))},G=[];if(S.forEach(j=>{let R;try{R=j.load()}catch(H){m(p,j,H),F.delete(j.id);return}if(kc(R)){G.push({id:j.id,required:j.required,load:()=>R,...j.loaded?{loaded:H=>j.loaded?.(H)}:{}});return}V(j,R),F.delete(j.id)}),G.length===0){$();return}p.timer=setTimeout(()=>{p.timer=void 0,d?.([...F]),p.document.get().docId,[...F],y(p,[...F])},n),p.timer.unref?.(),G.forEach(j=>{j.load().then(R=>V(j,R)).catch(R=>{m(p,j,R)}).finally(()=>{F.delete(j.id),$()})})},D=async(p,S,F)=>{if(F==="snapshot"||F==="anchor")return;const V=s?.();if(V)return V.resolve({project:S.project??p.project,tags:(p.tags??[]).map($=>({name:$}))})},B=p=>{if(p.lock===!0&&i?.(p)===!1)return new et("locked");const S=p.tags?.length??0,F=p.emailtags?.length??0;if(Math.max(S,F)>Pc)return new et("too-many-tags")},M=(p,S)=>{const F=p.document.get().serverId;S||F==null||(p.recoveryFacts={emailId:F,historyLoaded:!0,isRecovering:!1},Q(p.request.key)||(p.request={...p.request,key:je(F),serverId:F}))},C=(p,S,F)=>{if(p.closed||F?.id==null)return;const V=p.document.get().serverId,$=V!=null;$&&V!==String(F.id)||(p.document.markSaved(S,String(F.id)),M(p,$),p.document.get().serverId,_())},E=async(p,S,F)=>{try{await p.document.whenReady()}catch(R){return p.saveError=R,p.saveFailures+=1,p.failedIntent=S,p.saveFailures,!1}if(p.closed)return!1;const V=B(p.document.get().attributes);if(V)return p.saveError=V,p.saveFailures+=1,p.failedIntent=S,V.reason,_(),!1;if(a&&(await a(Bc(p)).catch(()=>{}),p.closed))return!1;if(Nc(p))return S==="snapshot"||(p.saveError=new et("empty-content"),p.saveFailures+=1,p.failedIntent=S,_()),!1;let $;try{$=await D(p.document.get().attributes,F,S)}catch(R){return p.saveError=R,p.saveFailures+=1,p.failedIntent=S,p.saveFailures,_(),!1}if(p.closed)return!1;const{payload:G,version:j}=vc(p.document,F,$,S);p.document.get().docId;try{const R=p.document.get().serverId!=null,H=await bc(r(),o(p.request.key),S,p.document.get().serverId,G);if(p.closed)return!0;let q;if(S==="snapshot"||S==="anchor"){const X=H?.modified!=null?Date.parse(H.modified):NaN;q=Number.isFinite(X)?X:Date.now(),p.snapshotVersion=j,p.lastRevisionAt=q}else p.document.markSaved(j,H?.id!=null?String(H.id):void 0),p.savedContent=G.html;M(p,R),p.saveError=void 0,p.saveFailures=0,p.failedIntent=void 0,p.document.get().serverId,_();const z={intent:S,serverId:p.document.get().serverId,created:!R,...q!==void 0?{revisionAt:q}:{}};return g.forEach(X=>X(z)),!0}catch(R){return(S==="publish"||S==="materialize")&&ic(R)?.then(H=>C(p,j,H)),p.saveError=R,p.saveFailures+=1,p.failedIntent=S,p.saveFailures,_(),!1}},b=p=>{p.closed=!0,p.watchers.forEach(S=>S()),p.watchers=[],Lo(p),p.history.dispose(),p.document.dispose()},w=()=>{u&&(b(u),u=void 0)},O=()=>{f&&(b(f),f=void 0)},x=(p,S,F)=>{let V=!1;S.show&&(p.show?.id!==S.show.id||p.show.token!==S.show.token)&&(p.show=S.show,V=!0,{docId:p.document.get().docId,...S.show});const $=F==="show"?ko(S.patch):null;$&&(p.reports.set("plugin",$),Fo(p,$),Cn(p,$),Mc(p,$)),V&&_()},A=(p,S={})=>P(u,p,S),N=()=>u&&Q(u.request.key??"")?f:u,k=p=>({error:p?.saveError,failures:p?.saveFailures??0,saving:p?.saving===!0,failedIntent:p?.failedIntent}),P=(p,S,F)=>!p||p.closed||S==="materialize"&&p.document.get().serverId!=null?Promise.resolve(!1):p.saving?S==="snapshot"||S==="materialize"?Promise.resolve(!1):(p.inFlight??Promise.resolve(!1)).then(()=>P(p,S,F)):(p.saving=!0,_(),p.inFlight=E(p,S,F).finally(()=>{p.saving=!1,p.inFlight=void 0,u===p&&!p.closed&&_()}),p.inFlight),v=(p,S="open",F=!1)=>{if(u&&!u.closed&&S!=="new"&&Oc(u.request,p))return x(u,p,S),u.document;w(),F||O();const V=ql({createBuffer:()=>jl(""),serverId:p.serverId??null}),$={request:p,show:p.show,document:V,history:Xl(V,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return u=$,$.watchers.push(Lc($)),V.get().docId,p.serverId,T($,t(p,{publishRecoveryFacts(G){$.closed||($.recoveryFacts=G,_())},readShownContent:()=>$.closed?null:$.document.getContent()})),_(),V},I=(p,S,F)=>({key:Q(p)?p:At(p),serverId:S?.id!=null?String(S.id):null,email:S,show:F});return{openWith:v,open:(p,S={})=>v({key:je(p),serverId:p,email:S.email,patch:S.patch,show:S.show},"open"),openDraft:(p,S={})=>v({key:je(void 0),serverId:null,email:p,patch:S.patch,show:S.show},"open"),startNewDraft:(p,S={})=>v({key:je(void 0),serverId:null,email:p,patch:S.patch,show:S.show},"new"),reload:(p,S={})=>v({key:je(p),serverId:p,email:S.email,patch:S.patch,show:S.show},"new"),openBlock:(p,S,F)=>v(I(p,S,F),"open"),reloadBlock:(p,S,F)=>v(I(p,S,F),"new"),openBlockOver:(p,S)=>{const F=I(p,S);return u&&!u.closed&&u.request.key===F.key?u.document:(u&&!u.closed&&!Q(u.request.key)&&(O(),f=u,u=void 0),v(F,"open",!0))},resumeSuspended:()=>{if(f)return w(),u=f,f=void 0,_(),u.document},hasSuspended:()=>!!f,suspendedDocument:()=>f?.document,show:(p,S)=>{const F=u;if(!(!F||F.closed))return v({...F.request,patch:p,show:S},"show")},current:()=>u?.document,noteServerFacts:({serverId:p,block:S},F)=>{const V=u;!V||V.closed||V.request.serverId!==p||Q(V.request.key??"")===S&&Sn(V.document,Dc(F))},save:A,saveEmail:(p,S={})=>P(N(),p,S),saveState:()=>k(u),emailSaveState:()=>k(N()),revisionFacts(){if(!u)return;const p=u.revisionFactsSnapshot;return p&&p.snapshotVersion===u.snapshotVersion&&p.lastRevisionAt===u.lastRevisionAt?p:(u.revisionFactsSnapshot={snapshotVersion:u.snapshotVersion,lastRevisionAt:u.lastRevisionAt},u.revisionFactsSnapshot)},recoveryFacts:()=>u?.recoveryFacts,history:()=>u?.history,forcedHeaders:()=>u?.forcedHeaders,beginForcedHeaders(p){u&&!u.closed&&(u.forcedHeaders=p)},endForcedHeaders(){for(const p of[u,f])p&&(p.forcedHeaders=void 0)},onSaved(p){return g.add(p),()=>g.delete(p)},showFacts:()=>u?.show,shownHeaders:()=>({...u?.shownHeaders}),showFill:()=>u?.showFill,beginShowFill(p){u&&!u.closed&&(u.showFill={showId:p,codeEdits:0})},noteCodeEdit(){u?.showFill&&(u.showFill.codeEdits+=1)},endShowFill(p){for(const S of[u,f])S?.showFill?.showId===p&&(S.showFill=void 0)},sessionKey:()=>u?.request.key,openError:()=>u?.error,subscribe(p){return h.add(p),()=>h.delete(p)},close(){!u&&!f||(w(),O(),_())}}}var An=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function Dn(e){if(e instanceof An)return e.reason;if(e instanceof Ie)return Dn(e.reason)}function Uc(e){const t=e instanceof Ie?e.reason:e;return t instanceof An&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Hc(e){const t=Dn(e);return t==="forbidden"||t==="not-found"}function $c(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new An("not-found");return Ro(n)}}}var Bo=l.createIdentifier$1("EmailPort");function Vc(e){return e.getInstance(Bo)}function Gc(e,t){e.inject(Bo,t)}var jo=l.createIdentifier$1("documentSession.restEmailPortFactories");function Uo(e){return e.getInstance(jo)!==void 0}function Ce(e){const t=e.getInstance(jo);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var Yc=l.createIdentifier$1("EmailTermsResolver");function Wc(e){return e.getInstance(Yc)}var Ho=l.createIdentifier$1("EmailHistoryPort"),qc=l.createIdentifier$1("BlockHistoryPort");function $o(e){return e.getInstance(qc)}function Vo(e){return e.getInstance(Ho)}function Kc(e,t){e.inject(Ho,t)}var zc="em_autosave_pending",B_=6e4;function Dt(e){return`${zc}_${e}`}function Xc(e,t){try{sessionStorage.setItem(Dt(e),JSON.stringify(t))}catch{}}function Go(e){try{const t=sessionStorage.getItem(Dt(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(Dt(e)),null):n}catch{return null}}function nt(e){try{sessionStorage.removeItem(Dt(e))}catch{}}var Jc=2e3,Qc=5e3,Zc=5,ed=5e3,td=4;function nd(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function rd(e,t){return e==null||t==null?!1:e.replaceAll(`\r
2104
2104
  `,`
2105
2105
  `)===t.replaceAll(`\r
2106
2106
  `,`
2107
- `)}function Pn(e,t){return yn(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function od({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:o,onFacts:s,onLate:i,onError:a,pageLoadTs:c=nd()}){let d=null,u=!1,f=!1,h=0,v={emailId:e,historyLoaded:!1,isRecovering:!1},_=null;const y=new Promise(I=>{_=I}),m=I=>{v={...v,...I},s(v)};let T;const P=I=>{h+=1,m({applied:{phase:I,seq:h}})},F=()=>{d?.timer&&clearTimeout(d.timer),d=null},N=I=>{if(!f){if(_){const x=_;_=null,x(I),T=I.revision?I.phase:void 0;return}i(I)&&I.revision&&P(I.phase)}},C=()=>{if(!d||f)return;const I=d.phase==="fast",x=I?Jc:ed,A=I?Zc:td;d.timer=setTimeout(()=>{const p=d;if(!(!p||f)){if(p.attempts+=1,O(),I&&p.attempts>=A){const{pending:S}=p;nt(e),m({isRecovering:!1}),N({revision:{html:S.html,common_styles:S.common_styles,subject:S.subject,preheader:S.preheader},phase:"timeout"}),u=!0,p.phase="bg",p.attempts=0,C();return}if(!I&&p.attempts>=A){nt(e),F(),m({isRecovering:!1}),u=!0;return}C()}},x),d.timer.unref?.()},E=I=>{d={phase:"fast",attempts:0,pending:I,timer:null},m({isRecovering:!0}),C()},b=I=>{if(f)return;if(m({historyLoaded:!0,latestRevisionAt:I.latestAt!==void 0&&Number.isFinite(I.latestAt)?I.latestAt:void 0}),n&&d){const p=Pn(I,d.pending.sentAt);if(!p)return;const S=d.phase==="fast"?"found":"bg";nt(e),F(),m({isRecovering:!1}),u=!0,N({revision:p,phase:S});return}if(u)return;const x=n?Go(e):null,A=x&&(x.sentAt<c||!rd(x.html,o()))?x:null;if(A){const p=Pn(I,A.sentAt);if(p){nt(e),u=!0,N({revision:p,phase:"found"});return}E(A);return}u=!0,N({revision:Pn(I),phase:"normal"})},w=I=>{f||(a?.(I),v.historyLoaded||(m({historyLoaded:!1,latestRevisionAt:void 0}),k()),!d&&N({revision:null,phase:"normal"}))},O=()=>t(e).then(b).catch(w);let M,D=!1;const k=()=>{D||d||f||(D=!0,M=setTimeout(()=>{M=void 0,!f&&!v.historyLoaded&&O()},Qc))},g=()=>{f||(m({historyLoaded:!1,latestRevisionAt:void 0}),N({revision:null,phase:"normal"}))};return r?r().then(I=>I?O():g()):O(),{verdict:()=>y,confirmVerdict(I){const x=T;T=void 0,I&&x!==void 0&&!f&&P(x)},dispose(){f=!0,M!==void 0&&(clearTimeout(M),M=void 0),F()}}}function sd({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:o,onFacts:s}){let i=null;const a=od({emailId:r,readAutosave:c=>e.readAutosave(c),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:o,onFacts:s,onLate:({revision:c,phase:d})=>{const u=Lo(c);return i?.(u)??!1},onError:c=>{c instanceof Error&&c.message}});return{id:"recovery",load:()=>a.verdict().then(({revision:c})=>Lo(c)),loaded(c){a.confirmVerdict(c)},watch(c){return i=c,()=>{i=null,a.dispose()}}}}function Wo(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){Xc(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 id(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const o=Date.now(),s=await t.updateEmail(n,r);return await e.updateEmail(n,r),(Go(n)?.sentAt??Number.POSITIVE_INFINITY)<=o&&nt(n),s}}}var Yo=l.createIdentifier$1("CurrentUser"),qo={};function On(e){return e.getOrCreateInstance(Yo,()=>ae(qo))}function zo(e){return e?.getInstance(Yo)?.get()??qo}var Ko=l.createIdentifier$1("HeadlessMode");function Xo(e){return e.getOrCreateInstance(Ko,()=>ae(!1))}function ad(e){return e?.getInstance(Ko)?.get()??!1}var ld=l.createIdentifier$1("HiddenMount");function cd(e){return e.getOrCreateInstance(ld,()=>ae(!1))}function dd(e){if(!e)return!1;try{return!!l.decodeJwt(e).data?.act_as}catch{return!1}}function ud(e){return dd(e?.getInstance(l.COOKIE_MANAGER_ID)?.get(l.APP_COOKIES.em_token))}function Jo(e){return e?.getInstance(l.CONFIG_SOURCE_ID)?.get()??{}}function Pt(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function fd(e,t){return t.modeDefaults(Pt(e,t.fallbackMode))}function Qo(e,t){const n=Pt(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Zo(e,t){const n=Pt(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function pd(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function hd(e){return l.mergeResourceProxyLayers(e.map(t=>t?.resourceProxy))}function md(e){return l.mergeResourceProxyPolicyLayers(e.map(t=>t?.resourceProxyPolicy))}function gd(e){return l.mergeBackendProxyLayers(e.map(t=>t?.backendProxy))}function vd(e){return l.mergeShallowConfigLayers(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Ed(e,t){return[e.base,fd(e,t),e.profile,e.serverSide,Qo(e,t.fallbackMode),e.local,e.user,Zo(e,t.fallbackMode)]}function Rn(e,t){const n=Ed(e,t),r=l.mergeShallowConfigLayers(n),o=pd(n);o!==void 0&&(r.fileManager=o);const s=hd(n);s!==void 0&&(r.resourceProxy=s);const i=md(n);i&&Object.keys(i).length>0&&(r.resourceProxyPolicy=i);const a=gd(n);a!==void 0&&(r.backendProxy=a);const c=vd(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function _d(e,t,n){const r=Qo(e,n),o=Zo(e,n);return l.pickKey([o,e.user,r,e.serverSide],t)}var bd=1.5;function yd(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<=bd*e.autosaveTimeoutMs?"none":"revision"}var j_=5,U_=3;function Sd(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,s=e.readFailures??(()=>0),i=e.readFailureRetryable??(()=>!0);let a;const c=b=>a!==void 0&&a.version===b.get().version?s()-a.failuresAtStart:0,d=b=>{const w=c(b);if(w<=0)return!1;const O=n().retryMaxAttempts??5;return!i()||w>O},u=()=>{const{autosaveTimeoutMs:b,retryIntervalMs:w}=n(),O=t();return O!==void 0&&c(O)>0&&w!==void 0&&w>0?w:b},f=b=>b.isNew()&&s()>=3,h=()=>{const b=t();if(!b||b.isDisposed()||d(b))return"none";const{latestRevisionAt:w,snapshotVersion:O,...M}=n(),D=Date.now(),k=yd({...M,isDirty:b.isDirty(),isNew:b.isNew(),isReady:b.isReady(),latestRevisionAgeMs:w!=null&&w<=D?D-w:void 0,isSnapshotSent:O!=null&&O===b.get().version});return k==="create"&&f(b)?"none":k},v=()=>{const b=t();if(!b||b.isDisposed()||f(b)||d(b)||n().isHeadless)return!1;if(!b.isDirty())return b.isNew();const{snapshotVersion:w}=n();return!(w!=null&&w===b.get().version)};let _,y,m,T,P=!1;const F=()=>{y=void 0;const b=t();if(!b||b.isDisposed())return;if(b.get().docId!==_){N();return}const w=h();w!=="none"&&a?.version!==b.get().version&&(a={version:b.get().version,failuresAtStart:s()}),w==="create"?r():w==="revision"?o():v()&&(_=b.get().docId,y=setTimeout(F,u()))},N=()=>{const b=t();P||!b||y!==void 0||h()==="none"&&!v()||(_=b.get().docId,y=setTimeout(F,u()))},C=b=>{b.source==="user"&&y!==void 0&&(clearTimeout(y),y=void 0),N()},E=()=>{const b=t();b!==m&&(T?.(),m=b,a=void 0,T=b?.subscribe(C),y!==void 0&&(clearTimeout(y),y=void 0))};return E(),N(),{refresh:()=>{P||(E(),N())},stop:()=>{P=!0,T?.(),T=void 0,m=void 0,y!==void 0&&(clearTimeout(y),y=void 0)}}}var es=l.createIdentifier$1("documentSession.autosaveUiFacts"),ts={isUserBusy:!1,saveContext:{}};function wd(e){return e.getOrCreateInstance(es,()=>ae(ts))}function kn(e){return e?.getInstance(es)?.get()??ts}function ns(e){return kn(e).saveContext.fallbackTitle||"Untitled email."}var Id=1e4,Td=3e4;function Cd(e,t){const n=u=>{const f=e.getInstance(l.CONFIG_SOURCE_ID)?.layers?.(),h=f?_d(f,u):void 0;return typeof h=="number"&&h>=0?h:void 0},r=()=>{const u=t.current(),f=u?.get().serverId??void 0,h=Q(t.sessionKey()),v=t.recoveryFacts(),_=v?.emailId===f?v:void 0,y=t.revisionFacts(),m=_?.latestRevisionAt,T=y?.lastRevisionAt,P=zo(e).profile;return{isInited:h||u?.get().attributes.is_inited===!0,isEnabled:!!P?.autosaves&&!ud(e),isHistoryLoaded:_?.historyLoaded===!0,isUserBusy:kn(e).isUserBusy,isHeadless:ad(e),autosaveTimeoutMs:Jo(e).autosaveTimeout||Id,latestRevisionAt:m!==void 0||T!==void 0?Math.max(m??0,T??0):void 0,snapshotVersion:y?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Td,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},o=()=>{const u=kn(e).saveContext;return{...u,project:u.project??t.current()?.get().attributes.project,fallbackTitle:ns(e)}},s=Sd({readDocument:()=>t.current(),readEnvironment:r,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>cc(t.saveState().error),onCreate:()=>{Q(t.sessionKey())||t.save("materialize",o())},onRevision:()=>{t.save("snapshot",{project:o().project})}}),i=t.subscribe(s.refresh),a=On(e).watch(()=>s.refresh()),c=wd(e).watch(()=>s.refresh()),d=Xo(e).watch(()=>s.refresh());return()=>{i(),a.dispose(),c.dispose(),d.dispose(),s.stop()}}var rs=12e3;function se(e){return e.getOrCreateInstance(gn,()=>{const t=jc({resolveAdapters:(r,o)=>Pd(r,e,o),resolveWritePort:()=>os(e),resolveHistoryPort:r=>Q(r)?is(e):ss(e),resolveTerms:()=>Yc(e),canEdit:r=>Pl(e,r),notifyBeforeSave:xl(e),timeoutMs:rs,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const s=Hc(o),i=Uc(o);Ze(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(s),network_failure:String(i)},level:s||i?"warning":"error"})},onTimeout:r=>{}}),n=Cd(e,t);return e.getInstance(l.DISPOSABLE_ID)?.addDispose(n),t})}function Ae(e){return e?.getInstance(gn)}function os(e){const t=Vc(e);return t?Ln(e)?id(t,Ce(e).email(e)):t:Ce(e).email(e)}function Ad(e){return Vo(e)!==void 0||Uo(e)}function ss(e){const t=Vo(e);return t?Ln(e)?(J("port:history:server-backed"),Wo(t,Ce(e).history(e))):(J("port:history:integrator"),t):(J("port:history:rest (порт не зарегистрирован)"),Ce(e).history(e))}function is(e){const t=$o(e);return t?Ln(e)?(J("port:block-history:server-backed"),Wo(t,Ce(e).blockHistory(e))):(J("port:block-history:integrator"),t):(J("port:block-history:rest (порт не зарегистрирован)"),Ce(e).blockHistory(e))}function Dd(e){return $o(e)!==void 0||Uo(e)}function Ln(e){return ao(e)}function Pd({email:e,patch:t,serverId:n,key:r},o,s){const i=[];e?i.push({id:"rest",load:()=>Ro(e),required:!0}):n&&i.push($c(os(o),n)),t&&i.push({id:"plugin",load:()=>ko(t)});const a=Q(r);return Fl(n)&&(a?Dd(o):Ad(o))&&i.push(sd({port:a?is(o):ss(o),revisionServiceEnabled:ao(o),...!a&&Ol(o)?{isHistoryAvailable:()=>Rl(o)}:{},emailId:n,readShownContent:()=>s.readShownContent(),onFacts:c=>s.publishRecoveryFacts(c)})),i}function ie(e){return e.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}var as=new WeakMap,Nn=new WeakMap;function fe(e){return as.get(e)??0}function Ot(e,t){let n=Nn.get(e);return n||(n=new Set,Nn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Od(e){as.set(e,fe(e)+1),Nn.get(e)?.forEach(t=>t())}function Rd(e){const t=se(e),n=ie(e).addListener(l.EVENT_TYPES.APPLICATION_HAS_AMP,r=>{Ue(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>n.dispose())}function kd(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Ld(e){const t=e.fetchImpl??((s,i)=>fetch(s,i)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=s=>{try{const i=new URL(s,window.location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?!1:i.hostname===n()||e.sourceHosts().includes(i.hostname)}catch{return!1}};return{accepts:o,async load(s){if(!o(s))return;const i=!r.has(s);r.add(s);try{const a=await t(s,{mode:"cors",credentials:"omit",cache:i?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return kd(c)?c:void 0}catch{return}}}}var De={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Nd(e){const t={maxBytes:e.maxBytes??De.maxBytes,maxImageBytes:e.maxImageBytes??De.maxImageBytes,ttlMs:e.ttlMs??De.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,s={hits:0,loads:0,failures:0};let i=0;const a=f=>{const h=r.get(f);h&&(i-=h.bytes,r.delete(f))},c=f=>t.ttlMs<=0||n()-f.storedAt<t.ttlMs,d=()=>{if(i<=t.maxBytes)return;const f=[...r.entries()].sort((h,v)=>h[1].usedAt-v[1].usedAt);for(const[h]of f){if(i<=t.maxBytes)return;a(h)}},u=(f,h)=>{h.size>t.maxImageBytes||(r.set(f,{blob:h,bytes:h.size,storedAt:n(),usedAt:n()}),i+=h.size,d())};return{async get(f){const h=r.get(f);if(h&&c(h))return h.usedAt=n(),s.hits+=1,h.blob;h&&a(f);const v=o.get(f);if(v!==void 0)return v;s.loads+=1;const _=(async()=>{try{const y=await e.load(f);return y?u(f,y):s.failures+=1,y}catch{s.failures+=1;return}finally{o.delete(f)}})();return o.set(f,_),_},forget(f){a(f),o.delete(f)},configure(f){Object.assign(t,{maxBytes:f.maxBytes??t.maxBytes,maxImageBytes:f.maxImageBytes??t.maxImageBytes,ttlMs:f.ttlMs??t.ttlMs});for(const[h,v]of r)v.bytes>t.maxImageBytes&&a(h);d()},clear(){r.clear(),o.clear(),i=0},stats(){return{entries:r.size,bytes:i,...s}}}}var Md=["emcdn.ru","scr.emcdn.ru"];function xd(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 Fd(e,t){const n=(r,o)=>{const s=new Set(o?t:[]);for(const i of r){const a=xd(i);a&&s.add(a)}return[...s]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Bd(e){const t=e??{},n=t.isPlugin!==!0?Md:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...De};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:Fd(o.sourceHosts,n),maxBytes:o.maxBytes??De.maxBytes,maxImageBytes:o.maxImageBytes??De.maxImageBytes,ttlMs:o.ttlMs??De.ttlMs}}function jd(e){const t=ie(e),n=e.getInstance(l.CONFIG_SOURCE_ID),r=()=>Bd({...n?.get(),isPlugin:!0});let o=r();const s=Ld({sourceHosts:()=>o.sourceHosts}),i=Nd({load:y=>s.load(y),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(l.EVENT_TYPES.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},c=t.onInit(()=>a()),d=n?.watch(()=>{const y=r(),m=JSON.stringify(y)!==JSON.stringify(o);o=y,i.configure(y),y.enabled||i.clear(),m&&t.isInited()&&a()}),u={asked:0,served:0,refused:0},f=[],h=(y,m)=>(u.refused+=1,f.push({url:y,reason:m}),f.length>20&&f.shift(),{refused:!0}),v=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...u},refusals:[...f],store:i.stats()})}),_=t.addListenerAsync(l.EVENT_TYPES.APPLICATION_CANVAS_IMAGE_GET,async y=>{const m=y?.url??"";if(u.asked+=1,!o.enabled||!m)return h(m,"disabled");if(!s.accepts(m))return h(m,"host");y.fresh&&i.forget(m);const T=await i.get(m);return T?(u.served+=1,{blob:T}):h(m,"load-failed")});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{c.dispose(),d?.dispose(),_.dispose(),i.clear(),delete v.__emmCanvasImages__})}var Ud=2e3;function Hd(e){const t=ie(e),n=new Map,r=()=>{const i=t.getTarget();if(!i||t.hasPort(i))return;clearTimeout(n.get(i));const a=new MessageChannel;let c=!1,d=!1;const u=h=>{h.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",u),d&&t.resumePort(i),t.drainWindow(i))};a.port1.addEventListener("message",u),t.sendPort(i,a.port2),t.usePort(a.port1,!1,i);const f=setTimeout(()=>{n.get(i)===f&&n.delete(i),!(c||!t.hasPort(i,a.port1))&&(Ze(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d=!0,t.holdPort(i))},Ud);n.set(i,f)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const i=t.getTarget();return{usesPort:t.usesPort,windowDrained:i?t.isWindowDrained(i):!1}}}),s=t.onInit(()=>r());e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{for(const i of n.values())clearTimeout(i);s.dispose(),delete o.__emmCanvasPort__})}var $d=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Vd(e){return $d.test(e)||e.indexOf("//")===0}function Rt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Gd(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function ls(e,t){const n=e==null||e===""?"./":String(e);if(Vd(n))return Rt(n);const r=t??Gd();if(!r)return Rt(n);try{return Rt(new URL(n,r).href)}catch{return Rt(n)}}function Wd(){return typeof __emailmaker__<"u"&&__emailmaker__?.publicPath?ls(__emailmaker__.publicPath):ls("/")}var Yd=()=>"",qd=()=>"d5e4bde1";function zd(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function cs(e){const t=e?"iframe-eblock":"iframe",n=Yd();if(n){const s=zd(n,window.location).replace(/\/?$/,"/");return eo(`${s}${t}.html`,Je())}const r=qd(),o=`${Wd().replace(/\/?$/,"/")}iframe/`;return eo(`${o}${t}${r?`.${r}`:""}.html`,Je())}var ds="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function Mn(e){return/^file:/i.test(String(e||"").trim())}function Kd(e){return Mn(e)?`${ds} allow-same-origin`:ds}var H_="em:module-body",Xd="em:module-body-ack";function Jd(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 xn(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 Qd(e){const t=xn(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function Zd(e,t){const n=xn(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function eu(e,t){const n=xn(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),s=[r],i=[];for(;s.length>0;)for(const a of e[s.shift()]??[])o.has(a)||(o.add(a),i.push(a),s.push(a));return i}var tu=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function nu(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&tu.test(t[t.length-2])}async function ru(e,t){const n=nu(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 ou(e){const t=new Map,n=(r,o)=>{const s=Jd(r,e.canvasSrc,e.origin);if(!s)return;const i=t.get(s);if(i!==void 0)return i;const a=e.fetchBody(s,o);return t.set(s,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const s of r)n(s,o)},reset(){t.clear()},get size(){return t.size}}}var ve;function su(e){try{return Mn(new URL(e,window.location.href).href)}catch{return Mn(window.location.href)}}function us(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof __emailmaker__<"u"&&__emailmaker__?.preload?.canvasCrossOrigin===!0}var iu=()=>Promise.resolve(void 0);function fs(){const e=cs(!1);if(!su(e)){if(!ve||ve.canvasSrc!==e){const t=us(e)?ru:iu;ve={canvasSrc:e,store:ou({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return ve.store}}async function au(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(Zd(o,e))}catch{}}function Fn(e){const t=fs();if(!t||!ve||ve.warmed||!us(ve.canvasSrc))return;ve.warmed=!0;const{canvasSrc:n}=ve,r=Qd(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.C66zL1zp.js"],"js/iframe.js":["js/elMarkupHelper.C66zL1zp.js"],"js/darkreader.CLd5EML2.js":[],"js/elMarkupHelper.C66zL1zp.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.Mun9CrLC.js":[]};o?t.warm(eu(o,n),e):au(n,s=>t.warm(s,e))}function lu(e){const t=fs();if(!t)return;Fn();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const s=r.source;s&&(s.postMessage({operationId:Xd,for:o.result},"*"),t.take(o.data?.url??"").then(i=>{s.postMessage({operationId:o.result,data:i??null},"*")}))};window.addEventListener("message",n),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{window.removeEventListener("message",n)})}var $e=/<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,cu=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Ve=/<style\b[^>]*>[\s\S]*?<\/style>/gi,ps=/display:\s*none\s*!important/gi,du=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,uu=/\s*height\s*:\s*100%\s*!important\s*;?/gi,fu=/height\s*:\s*100%\s*!important/i,pu=[".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 hu(e){return ps.lastIndex=0,(e.match(ps)||[]).length}function hs(e){const t=e.trim(),n=hu(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=pu.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 mu(e){Ve.lastIndex=0;for(const t of e.matchAll(Ve))if(hs(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function gu(e){let t=!1;return Ve.lastIndex=0,{html:e.replace(Ve,n=>hs(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function vu(e){return $e.lastIndex=0,$e.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||mu(e)}function Eu(e){if(!vu(e))return{html:e,found:!1};let t=!1,n=e;$e.lastIndex=0,$e.test(n)&&($e.lastIndex=0,n=n.replace($e,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(cu,""),t=!0);const r=gu(n);return n=r.html,t=t||r.found,{html:n,found:t}}function _u(e){return!e||!fu.test(e)?e:(Ve.lastIndex=0,e.replace(Ve,t=>t.replace(du,(n,r,o,s)=>`${r}${o.replace(uu,"")}${s}`)))}function ms(e){const t=Eu(e.replaceAll(`\r
2107
+ `)}function Pn(e,t){return yn(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function od({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:o,onFacts:s,onLate:i,onError:a,pageLoadTs:c=nd()}){let d=null,u=!1,f=!1,h=0,g={emailId:e,historyLoaded:!1,isRecovering:!1},_=null;const y=new Promise(P=>{_=P}),m=P=>{g={...g,...P},s(g)};let T;const D=P=>{h+=1,m({applied:{phase:P,seq:h}})},B=()=>{d?.timer&&clearTimeout(d.timer),d=null},M=P=>{if(!f){if(_){const v=_;_=null,v(P),T=P.revision?P.phase:void 0;return}i(P)&&P.revision&&D(P.phase)}},C=()=>{if(!d||f)return;const P=d.phase==="fast",v=P?Jc:ed,I=P?Zc:td;d.timer=setTimeout(()=>{const p=d;if(!(!p||f)){if(p.attempts+=1,O(),P&&p.attempts>=I){const{pending:S}=p;nt(e),m({isRecovering:!1}),M({revision:{html:S.html,common_styles:S.common_styles,subject:S.subject,preheader:S.preheader},phase:"timeout"}),u=!0,p.phase="bg",p.attempts=0,C();return}if(!P&&p.attempts>=I){nt(e),B(),m({isRecovering:!1}),u=!0;return}C()}},v),d.timer.unref?.()},E=P=>{d={phase:"fast",attempts:0,pending:P,timer:null},m({isRecovering:!0}),C()},b=P=>{if(f)return;if(m({historyLoaded:!0,latestRevisionAt:P.latestAt!==void 0&&Number.isFinite(P.latestAt)?P.latestAt:void 0}),n&&d){const p=Pn(P,d.pending.sentAt);if(!p)return;const S=d.phase==="fast"?"found":"bg";nt(e),B(),m({isRecovering:!1}),u=!0,M({revision:p,phase:S});return}if(u)return;const v=n?Go(e):null,I=v&&(v.sentAt<c||!rd(v.html,o()))?v:null;if(I){const p=Pn(P,I.sentAt);if(p){nt(e),u=!0,M({revision:p,phase:"found"});return}E(I);return}u=!0,M({revision:Pn(P),phase:"normal"})},w=P=>{f||(a?.(P),g.historyLoaded||(m({historyLoaded:!1,latestRevisionAt:void 0}),N()),!d&&M({revision:null,phase:"normal"}))},O=()=>t(e).then(b).catch(w);let x,A=!1;const N=()=>{A||d||f||(A=!0,x=setTimeout(()=>{x=void 0,!f&&!g.historyLoaded&&O()},Qc))},k=()=>{f||(m({historyLoaded:!1,latestRevisionAt:void 0}),M({revision:null,phase:"normal"}))};return r?r().then(P=>P?O():k()):O(),{verdict:()=>y,confirmVerdict(P){const v=T;T=void 0,P&&v!==void 0&&!f&&D(v)},dispose(){f=!0,x!==void 0&&(clearTimeout(x),x=void 0),B()}}}function sd({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:o,onFacts:s}){let i=null;const a=od({emailId:r,readAutosave:c=>e.readAutosave(c),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:o,onFacts:s,onLate:({revision:c,phase:d})=>{const u=No(c);return i?.(u)??!1},onError:c=>{c instanceof Error&&c.message}});return{id:"recovery",load:()=>a.verdict().then(({revision:c})=>No(c)),loaded(c){a.confirmVerdict(c)},watch(c){return i=c,()=>{i=null,a.dispose()}}}}function Yo(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){Xc(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 id(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const o=Date.now(),s=await t.updateEmail(n,r);return await e.updateEmail(n,r),(Go(n)?.sentAt??Number.POSITIVE_INFINITY)<=o&&nt(n),s}}}var Wo=l.createIdentifier$1("CurrentUser"),qo={};function On(e){return e.getOrCreateInstance(Wo,()=>ae(qo))}function Ko(e){return e?.getInstance(Wo)?.get()??qo}var zo=l.createIdentifier$1("HeadlessMode");function Xo(e){return e.getOrCreateInstance(zo,()=>ae(!1))}function ad(e){return e?.getInstance(zo)?.get()??!1}var ld=l.createIdentifier$1("HiddenMount");function cd(e){return e.getOrCreateInstance(ld,()=>ae(!1))}function dd(e){if(!e)return!1;try{return!!l.decodeJwt(e).data?.act_as}catch{return!1}}function ud(e){return dd(e?.getInstance(l.COOKIE_MANAGER_ID)?.get(l.APP_COOKIES.em_token))}function Jo(e){return e?.getInstance(l.CONFIG_SOURCE_ID)?.get()??{}}function Pt(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function fd(e,t){return t.modeDefaults(Pt(e,t.fallbackMode))}function Qo(e,t){const n=Pt(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Zo(e,t){const n=Pt(e,t),r=e.user?.advancedConfigs?.[n],o=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...o}}function pd(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function hd(e){return l.mergeResourceProxyLayers(e.map(t=>t?.resourceProxy))}function md(e){return l.mergeResourceProxyPolicyLayers(e.map(t=>t?.resourceProxyPolicy))}function gd(e){return l.mergeBackendProxyLayers(e.map(t=>t?.backendProxy))}function vd(e){return l.mergeShallowConfigLayers(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Ed(e,t){return[e.base,fd(e,t),e.profile,e.serverSide,Qo(e,t.fallbackMode),e.local,e.user,Zo(e,t.fallbackMode)]}function Rn(e,t){const n=Ed(e,t),r=l.mergeShallowConfigLayers(n),o=pd(n);o!==void 0&&(r.fileManager=o);const s=hd(n);s!==void 0&&(r.resourceProxy=s);const i=md(n);i&&Object.keys(i).length>0&&(r.resourceProxyPolicy=i);const a=gd(n);a!==void 0&&(r.backendProxy=a);const c=vd(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function _d(e,t,n){const r=Qo(e,n),o=Zo(e,n);return l.pickKey([o,e.user,r,e.serverSide],t)}var bd=1.5;function yd(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<=bd*e.autosaveTimeoutMs?"none":"revision"}var j_=5,U_=3;function Sd(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:o}=e,s=e.readFailures??(()=>0),i=e.readFailureRetryable??(()=>!0);let a;const c=b=>a!==void 0&&a.version===b.get().version?s()-a.failuresAtStart:0,d=b=>{const w=c(b);if(w<=0)return!1;const O=n().retryMaxAttempts??5;return!i()||w>O},u=()=>{const{autosaveTimeoutMs:b,retryIntervalMs:w}=n(),O=t();return O!==void 0&&c(O)>0&&w!==void 0&&w>0?w:b},f=b=>b.isNew()&&s()>=3,h=()=>{const b=t();if(!b||b.isDisposed()||d(b))return"none";const{latestRevisionAt:w,snapshotVersion:O,...x}=n(),A=Date.now(),N=yd({...x,isDirty:b.isDirty(),isNew:b.isNew(),isReady:b.isReady(),latestRevisionAgeMs:w!=null&&w<=A?A-w:void 0,isSnapshotSent:O!=null&&O===b.get().version});return N==="create"&&f(b)?"none":N},g=()=>{const b=t();if(!b||b.isDisposed()||f(b)||d(b)||n().isHeadless)return!1;if(!b.isDirty())return b.isNew();const{snapshotVersion:w}=n();return!(w!=null&&w===b.get().version)};let _,y,m,T,D=!1;const B=()=>{y=void 0;const b=t();if(!b||b.isDisposed())return;if(b.get().docId!==_){M();return}const w=h();w!=="none"&&a?.version!==b.get().version&&(a={version:b.get().version,failuresAtStart:s()}),w==="create"?r():w==="revision"?o():g()&&(_=b.get().docId,y=setTimeout(B,u()))},M=()=>{const b=t();D||!b||y!==void 0||h()==="none"&&!g()||(_=b.get().docId,y=setTimeout(B,u()))},C=b=>{b.source==="user"&&y!==void 0&&(clearTimeout(y),y=void 0),M()},E=()=>{const b=t();b!==m&&(T?.(),m=b,a=void 0,T=b?.subscribe(C),y!==void 0&&(clearTimeout(y),y=void 0))};return E(),M(),{refresh:()=>{D||(E(),M())},stop:()=>{D=!0,T?.(),T=void 0,m=void 0,y!==void 0&&(clearTimeout(y),y=void 0)}}}var es=l.createIdentifier$1("documentSession.autosaveUiFacts"),ts={isUserBusy:!1,saveContext:{}};function wd(e){return e.getOrCreateInstance(es,()=>ae(ts))}function kn(e){return e?.getInstance(es)?.get()??ts}function ns(e){return kn(e).saveContext.fallbackTitle||"Untitled email."}var Id=1e4,Td=3e4;function Cd(e,t){const n=u=>{const f=e.getInstance(l.CONFIG_SOURCE_ID)?.layers?.(),h=f?_d(f,u):void 0;return typeof h=="number"&&h>=0?h:void 0},r=()=>{const u=t.current(),f=u?.get().serverId??void 0,h=Q(t.sessionKey()),g=t.recoveryFacts(),_=g?.emailId===f?g:void 0,y=t.revisionFacts(),m=_?.latestRevisionAt,T=y?.lastRevisionAt,D=Ko(e).profile;return{isInited:h||u?.get().attributes.is_inited===!0,isEnabled:!!D?.autosaves&&!ud(e),isHistoryLoaded:_?.historyLoaded===!0,isUserBusy:kn(e).isUserBusy,isHeadless:ad(e),autosaveTimeoutMs:Jo(e).autosaveTimeout||Id,latestRevisionAt:m!==void 0||T!==void 0?Math.max(m??0,T??0):void 0,snapshotVersion:y?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Td,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},o=()=>{const u=kn(e).saveContext;return{...u,project:u.project??t.current()?.get().attributes.project,fallbackTitle:ns(e)}},s=Sd({readDocument:()=>t.current(),readEnvironment:r,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>cc(t.saveState().error),onCreate:()=>{Q(t.sessionKey())||t.save("materialize",o())},onRevision:()=>{t.save("snapshot",{project:o().project})}}),i=t.subscribe(s.refresh),a=On(e).watch(()=>s.refresh()),c=wd(e).watch(()=>s.refresh()),d=Xo(e).watch(()=>s.refresh());return()=>{i(),a.dispose(),c.dispose(),d.dispose(),s.stop()}}var rs=12e3;function se(e){return e.getOrCreateInstance(gn,()=>{const t=jc({resolveAdapters:(r,o)=>Pd(r,e,o),resolveWritePort:()=>os(e),resolveHistoryPort:r=>Q(r)?is(e):ss(e),resolveTerms:()=>Wc(e),canEdit:r=>Pl(e,r),notifyBeforeSave:xl(e),timeoutMs:rs,onAdapterError:(r,o)=>{o instanceof Error&&o.message;const s=Hc(o),i=Uc(o);Ze(o,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(s),network_failure:String(i)},level:s||i?"warning":"error"})},onTimeout:r=>{}}),n=Cd(e,t);return e.getInstance(l.DISPOSABLE_ID)?.addDispose(n),t})}function Ae(e){return e?.getInstance(gn)}function os(e){const t=Vc(e);return t?Nn(e)?id(t,Ce(e).email(e)):t:Ce(e).email(e)}function Ad(e){return Vo(e)!==void 0||Uo(e)}function ss(e){const t=Vo(e);return t?Nn(e)?(J("port:history:server-backed"),Yo(t,Ce(e).history(e))):(J("port:history:integrator"),t):(J("port:history:rest (порт не зарегистрирован)"),Ce(e).history(e))}function is(e){const t=$o(e);return t?Nn(e)?(J("port:block-history:server-backed"),Yo(t,Ce(e).blockHistory(e))):(J("port:block-history:integrator"),t):(J("port:block-history:rest (порт не зарегистрирован)"),Ce(e).blockHistory(e))}function Dd(e){return $o(e)!==void 0||Uo(e)}function Nn(e){return ao(e)}function Pd({email:e,patch:t,serverId:n,key:r},o,s){const i=[];e?i.push({id:"rest",load:()=>Ro(e),required:!0}):n&&i.push($c(os(o),n)),t&&i.push({id:"plugin",load:()=>ko(t)});const a=Q(r);return Fl(n)&&(a?Dd(o):Ad(o))&&i.push(sd({port:a?is(o):ss(o),revisionServiceEnabled:ao(o),...!a&&Ol(o)?{isHistoryAvailable:()=>Rl(o)}:{},emailId:n,readShownContent:()=>s.readShownContent(),onFacts:c=>s.publishRecoveryFacts(c)})),i}function ie(e){return e.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}var as=new WeakMap,Ln=new WeakMap;function fe(e){return as.get(e)??0}function Ot(e,t){let n=Ln.get(e);return n||(n=new Set,Ln.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Od(e){as.set(e,fe(e)+1),Ln.get(e)?.forEach(t=>t())}function Rd(e){const t=se(e),n=ie(e).addListener(l.EVENT_TYPES.APPLICATION_HAS_AMP,r=>{Ue(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>n.dispose())}function kd(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Nd(e){const t=e.fetchImpl??((s,i)=>fetch(s,i)),n=e.pageHost??(()=>window.location.hostname),r=new Set,o=s=>{try{const i=new URL(s,window.location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?!1:i.hostname===n()||e.sourceHosts().includes(i.hostname)}catch{return!1}};return{accepts:o,async load(s){if(!o(s))return;const i=!r.has(s);r.add(s);try{const a=await t(s,{mode:"cors",credentials:"omit",cache:i?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return kd(c)?c:void 0}catch{return}}}}var De={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Ld(e){const t={maxBytes:e.maxBytes??De.maxBytes,maxImageBytes:e.maxImageBytes??De.maxImageBytes,ttlMs:e.ttlMs??De.ttlMs},n=e.now??(()=>Date.now()),r=new Map,o=new Map,s={hits:0,loads:0,failures:0};let i=0;const a=f=>{const h=r.get(f);h&&(i-=h.bytes,r.delete(f))},c=f=>t.ttlMs<=0||n()-f.storedAt<t.ttlMs,d=()=>{if(i<=t.maxBytes)return;const f=[...r.entries()].sort((h,g)=>h[1].usedAt-g[1].usedAt);for(const[h]of f){if(i<=t.maxBytes)return;a(h)}},u=(f,h)=>{h.size>t.maxImageBytes||(r.set(f,{blob:h,bytes:h.size,storedAt:n(),usedAt:n()}),i+=h.size,d())};return{async get(f){const h=r.get(f);if(h&&c(h))return h.usedAt=n(),s.hits+=1,h.blob;h&&a(f);const g=o.get(f);if(g!==void 0)return g;s.loads+=1;const _=(async()=>{try{const y=await e.load(f);return y?u(f,y):s.failures+=1,y}catch{s.failures+=1;return}finally{o.delete(f)}})();return o.set(f,_),_},forget(f){a(f),o.delete(f)},configure(f){Object.assign(t,{maxBytes:f.maxBytes??t.maxBytes,maxImageBytes:f.maxImageBytes??t.maxImageBytes,ttlMs:f.ttlMs??t.ttlMs});for(const[h,g]of r)g.bytes>t.maxImageBytes&&a(h);d()},clear(){r.clear(),o.clear(),i=0},stats(){return{entries:r.size,bytes:i,...s}}}}var Md=["emcdn.ru","scr.emcdn.ru"];function xd(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 Fd(e,t){const n=(r,o)=>{const s=new Set(o?t:[]);for(const i of r){const a=xd(i);a&&s.add(a)}return[...s]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Bd(e){const t=e??{},n=t.isPlugin!==!0?Md:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...De};const o=r===!0||r===void 0?{}:r;return{enabled:o.enabled!==!1,sourceHosts:Fd(o.sourceHosts,n),maxBytes:o.maxBytes??De.maxBytes,maxImageBytes:o.maxImageBytes??De.maxImageBytes,ttlMs:o.ttlMs??De.ttlMs}}function jd(e){const t=ie(e),n=e.getInstance(l.CONFIG_SOURCE_ID),r=()=>Bd({...n?.get(),isPlugin:!0});let o=r();const s=Nd({sourceHosts:()=>o.sourceHosts}),i=Ld({load:y=>s.load(y),maxBytes:o.maxBytes,maxImageBytes:o.maxImageBytes,ttlMs:o.ttlMs}),a=()=>{t.send(l.EVENT_TYPES.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:o.enabled,sourceHosts:[...o.sourceHosts]})},c=t.onInit(()=>a()),d=n?.watch(()=>{const y=r(),m=JSON.stringify(y)!==JSON.stringify(o);o=y,i.configure(y),y.enabled||i.clear(),m&&t.isInited()&&a()}),u={asked:0,served:0,refused:0},f=[],h=(y,m)=>(u.refused+=1,f.push({url:y,reason:m}),f.length>20&&f.shift(),{refused:!0}),g=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:o,counters:{...u},refusals:[...f],store:i.stats()})}),_=t.addListenerAsync(l.EVENT_TYPES.APPLICATION_CANVAS_IMAGE_GET,async y=>{const m=y?.url??"";if(u.asked+=1,!o.enabled||!m)return h(m,"disabled");if(!s.accepts(m))return h(m,"host");y.fresh&&i.forget(m);const T=await i.get(m);return T?(u.served+=1,{blob:T}):h(m,"load-failed")});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{c.dispose(),d?.dispose(),_.dispose(),i.clear(),delete g.__emmCanvasImages__})}var Ud=2e3;function Hd(e){const t=ie(e),n=new Map,r=()=>{const i=t.getTarget();if(!i||t.hasPort(i))return;clearTimeout(n.get(i));const a=new MessageChannel;let c=!1,d=!1;const u=h=>{h.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",u),d&&t.resumePort(i),t.drainWindow(i))};a.port1.addEventListener("message",u),t.sendPort(i,a.port2),t.usePort(a.port1,!1,i);const f=setTimeout(()=>{n.get(i)===f&&n.delete(i),!(c||!t.hasPort(i,a.port1))&&(Ze(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d=!0,t.holdPort(i))},Ud);n.set(i,f)},o=Object.assign(globalThis,{__emmCanvasPort__:()=>{const i=t.getTarget();return{usesPort:t.usesPort,windowDrained:i?t.isWindowDrained(i):!1}}}),s=t.onInit(()=>r());e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{for(const i of n.values())clearTimeout(i);s.dispose(),delete o.__emmCanvasPort__})}var $d=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Vd(e){return $d.test(e)||e.indexOf("//")===0}function Rt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Gd(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function ls(e,t){const n=e==null||e===""?"./":String(e);if(Vd(n))return Rt(n);const r=t??Gd();if(!r)return Rt(n);try{return Rt(new URL(n,r).href)}catch{return Rt(n)}}function Yd(){return typeof __emailmaker__<"u"&&__emailmaker__?.publicPath?ls(__emailmaker__.publicPath):ls("/")}var Wd=()=>"",qd=()=>"fec11667";function Kd(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function cs(e){const t=e?"iframe-eblock":"iframe",n=Wd();if(n){const s=Kd(n,window.location).replace(/\/?$/,"/");return eo(`${s}${t}.html`,Je())}const r=qd(),o=`${Yd().replace(/\/?$/,"/")}iframe/`;return eo(`${o}${t}${r?`.${r}`:""}.html`,Je())}var ds="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function Mn(e){return/^file:/i.test(String(e||"").trim())}function zd(e){return Mn(e)?`${ds} allow-same-origin`:ds}var H_="em:module-body",Xd="em:module-body-ack";function Jd(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 xn(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 Qd(e){const t=xn(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function Zd(e,t){const n=xn(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(o=>e[o]?.file).filter(o=>!!o):[]}function eu(e,t){const n=xn(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const o=new Set([r]),s=[r],i=[];for(;s.length>0;)for(const a of e[s.shift()]??[])o.has(a)||(o.add(a),i.push(a),s.push(a));return i}var tu=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function nu(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&tu.test(t[t.length-2])}async function ru(e,t){const n=nu(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 ou(e){const t=new Map,n=(r,o)=>{const s=Jd(r,e.canvasSrc,e.origin);if(!s)return;const i=t.get(s);if(i!==void 0)return i;const a=e.fetchBody(s,o);return t.set(s,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,o){for(const s of r)n(s,o)},reset(){t.clear()},get size(){return t.size}}}var ve;function su(e){try{return Mn(new URL(e,window.location.href).href)}catch{return Mn(window.location.href)}}function us(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof __emailmaker__<"u"&&__emailmaker__?.preload?.canvasCrossOrigin===!0}var iu=()=>Promise.resolve(void 0);function fs(){const e=cs(!1);if(!su(e)){if(!ve||ve.canvasSrc!==e){const t=us(e)?ru:iu;ve={canvasSrc:e,store:ou({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return ve.store}}async function au(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(Zd(o,e))}catch{}}function Fn(e){const t=fs();if(!t||!ve||ve.warmed||!us(ve.canvasSrc))return;ve.warmed=!0;const{canvasSrc:n}=ve,r=Qd(n);r&&t.warm([r],e);const o={"js/iframe-eblock.js":["js/elMarkupHelper.Dv3AYDYP.js"],"js/iframe.js":["js/elMarkupHelper.Dv3AYDYP.js"],"js/darkreader.CLd5EML2.js":[],"js/elMarkupHelper.Dv3AYDYP.js":[],"js/rules.CnnzdMsj.js":[],"js/typograf.all.Mun9CrLC.js":[]};o?t.warm(eu(o,n),e):au(n,s=>t.warm(s,e))}function lu(e){const t=fs();if(!t)return;Fn();const n=r=>{const o=r.data;if(!o||o.operationId!=="em:module-body"||!o.result)return;const s=r.source;s&&(s.postMessage({operationId:Xd,for:o.result},"*"),t.take(o.data?.url??"").then(i=>{s.postMessage({operationId:o.result,data:i??null},"*")}))};window.addEventListener("message",n),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{window.removeEventListener("message",n)})}var $e=/<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,cu=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Ve=/<style\b[^>]*>[\s\S]*?<\/style>/gi,ps=/display:\s*none\s*!important/gi,du=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,uu=/\s*height\s*:\s*100%\s*!important\s*;?/gi,fu=/height\s*:\s*100%\s*!important/i,pu=[".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 hu(e){return ps.lastIndex=0,(e.match(ps)||[]).length}function hs(e){const t=e.trim(),n=hu(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=pu.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 mu(e){Ve.lastIndex=0;for(const t of e.matchAll(Ve))if(hs(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function gu(e){let t=!1;return Ve.lastIndex=0,{html:e.replace(Ve,n=>hs(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function vu(e){return $e.lastIndex=0,$e.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||mu(e)}function Eu(e){if(!vu(e))return{html:e,found:!1};let t=!1,n=e;$e.lastIndex=0,$e.test(n)&&($e.lastIndex=0,n=n.replace($e,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(cu,""),t=!0);const r=gu(n);return n=r.html,t=t||r.found,{html:n,found:t}}function _u(e){return!e||!fu.test(e)?e:(Ve.lastIndex=0,e.replace(Ve,t=>t.replace(du,(n,r,o,s)=>`${r}${o.replace(uu,"")}${s}`)))}function ms(e){const t=Eu(e.replaceAll(`\r
2108
2108
  `,`
2109
- `));return{html:_u(t.html),hasBrowserExtensionArtifacts:t.found}}function kt(e){return e?.getContent()??""}function gs(e,t){e?.mutate({content:Do(t)},{source:"remote"})}function Lt(e){return l.createIdentifier$1(e)}function re(e,t){return e.getOrCreateInstance(t,()=>new l.AsyncEmitter)}function Y(e,t){return e.getOrCreateInstance(t,()=>new l.AsyncEmitter).event}function Nt(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var bu=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 yu(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 Su(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(l.throwIfAborted(n),new Promise((r,o)=>{let s=!1,i,a;const c=u=>{s||(s=!0,i!==void 0&&(clearTimeout(i),i=void 0),a?.dispose(),n?.removeEventListener("abort",d),u())},d=()=>{c(()=>o(l.createAbortError(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&c(()=>r())}),e.isInited()&&e.getTarget()){c(()=>r());return}t>0&&(i=setTimeout(()=>{c(()=>o(new bu(t)))},t)),n?.addEventListener("abort",d)}))}var wu=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 Iu(e,t,n){return t<=0?e:new Promise((r,o)=>{let s=!1,i;const a=c=>{s||(s=!0,i!==void 0&&(clearTimeout(i),i=void 0),c())};i=setTimeout(()=>{a(()=>o(new wu(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>o(c))})})}var Tu=2,rt=Symbol("sandbox:frame-replaced");function vs(e){return e===rt}function Pe(e,t,n,r,o,s,i){const a=`sandbox:${t}`,c=s?.getSandboxTimeoutMs(t)??vn[t],d=()=>{let _=Iu(e.sendAsync(n,r),c,a);return _=l.raceWithAbortSignal(_,s?.signal),Te(a,_,o)};if(t==="INIT_START"&&yu(e)){const _=s?.getSandboxReadyTimeoutMs()??2e4,y=e,m=T=>{const P=Su(y,_,s?.signal);return Te("sandbox:INIT_START:ready-wait",P,o).then(()=>{if(!i||T<=0)return d();const F=i.getGeneration();let N;const C=new Promise((b,w)=>{N=i.onChange(()=>{i.getGeneration()!==F&&w(rt)})}),E=d();return E.catch(()=>{}),Promise.race([E,C]).finally(()=>N?.()).catch(b=>{if(b!==rt)throw b;return{...o},m(T-1)})})};return m(Tu)}if(!i)return d();const u=i.getGeneration();let f;const h=new Promise((_,y)=>{f=i.onChange(()=>{i.getGeneration()!==u&&y(rt)})}),v=d();return v.catch(()=>{}),Promise.race([v,h]).finally(()=>f?.()).catch(_=>{throw _===rt&&{...o},_})}var Cu=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Au=200;function Es(e=new Set){const t=new Set;return(n,r)=>{if(!Cu.some(([s,i])=>!e.has(s)&&i.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=Au&&t.clear(),t.add(o))}}function _s(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Es()}}var Du=_s();function Oe(e){return e?.getInstance(l.TEMPLATE_DIRECTIVES_ID)??Du}var bs="self-init:";function Pu(e){return e.startsWith(bs)}function Bn(e,t){const n=e.getActiveShowRequest();return Pu(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Ou(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let s="",i;const a=_=>{i={target:e.readTarget?.(),docId:_}},c=()=>e.readDocument()?kt(e.readDocument()):s,d=()=>Oe(e.container).editorPolicy,u=()=>e.readEmail(),f=()=>{const _=u();return{..._,id:e.isTemplate()||_.isNew?void 0:_.id,html:c()}};let h=!1;const v={readContent:c,publicEmail:f,sendInitStart:()=>Pe(n,"INIT_START",l.EVENT_TYPES.SANDBOX_INIT_START,{guid:u().renderGuid},void 0,r()),sendInited:()=>Pe(n,"INITED",l.EVENT_TYPES.SANDBOX_INITED,{guid:u().renderGuid},void 0,r(),o()),async sendContent(){const _=u(),{html:y,hasBrowserExtensionArtifacts:m}=ms(_?.html||"");m&&e.events.browserExtensionDetected(),gs(e.readDocument(),y),s=y,a(_.renderGuid),await Pe(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,Nt(c(),_.renderGuid,d(),e.readDocument()?.get().version),{guid:_.renderGuid,emailId:_.id??null},r(),o())},refreshContent:()=>(a(u().renderGuid),Pe(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,Nt(c(),u().renderGuid,d(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const _=u();if(_.preheader!==void 0)return Pe(n,"PREHEADER",l.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE,{value:_.preheader,guid:_.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const _=u();if(_.subject!==void 0)return Pe(n,"SUBJECT",l.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,{value:_.subject,guid:_.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:_=>e.showFilled?.(_),noteFilled:(_,y)=>e.noteFilled?.(_,y),contentSent:()=>i,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(f()),fireInit(_,y){if(!Bn(t(),_)){t().getActiveShowRequest()?.showId;return}const m=u();m.id,m.renderGuid,t().completeShow(_);const T=e.readDocument();He(T,{is_inited:!0},{source:"system"});const P=()=>{const N=f();y&&(N.reset=!0);const C=e.events.inited(N);return y||(h&&v.fireEmailChanged(),h=!0),C};if(!T||T.isReady())return P();const{docId:F}=T.get();return T.whenReady().then(()=>e.readDocument()?.get().docId===F?P():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(f())},fireContentChanged(){e.events.contentChanged(c())}};return v}var Ru=class extends Error{showId;constructor(e,t){super(`[emailmaker] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},ku=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(l.createAbortError("Superseded by newer show()")),n.aborted?Promise.reject(l.createAbortError(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const s=setTimeout(()=>{this._settle(e.showId,()=>{o(new Ru(e.showId,t))})},t);s.unref?.();const i=()=>{this._settle(e.showId,()=>{o(l.createAbortError(n.reason))})};n.addEventListener("abort",i,{once:!0});const a=()=>{clearTimeout(s),n.removeEventListener("abort",i)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:s,dispose:a});for(const c of this._listeners)c(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Lu(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Nu(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=ho(e),n=mo(e),r=Ll(e.sandbox);t<n+r}var ys=class{_controller=new AbortController;_externalSignalDisposable=new l.Disposable;_sessionChangeListeners=new Set;_showRegistry=new ku;_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 ho(this._timeouts)}getSandboxTimeoutMs(e){return po(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return mo(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=Lu(this._timeouts,e.timeouts),Nu(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 l.Disposable,this._linkExternalSignal(e)}abort(e){const t=e??l.createAbortError("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new l.Disposable}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new l.Disposable,this._showRegistry.rejectAll(l.createAbortError("Init session replaced")),this._controller.signal.aborted||this._controller.abort(l.createAbortError("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??l.createAbortError()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??l.createAbortError()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},jn=(()=>{const e=new ys;return e.configure({}),e})();function Re(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 ke(e){return!e||e==="none"}function Mu(e){const t=e.contain??"",n=e.willChange??"";return!ke(e.transform)||!ke(e.perspective)||!ke(e.filter)||!ke(e.backdropFilter)||!ke(e.translate)||!ke(e.rotate)||!ke(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Ss(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 xu(e){const t=[],n=document.documentElement,r=Ss(getComputedStyle(n)),o=r.x||r.y;let s="none";const i=getComputedStyle(e).position;(i==="absolute"||i==="fixed")&&(s=i);for(let a=Re(e);a&&a!==n;a=Re(a)){const c=getComputedStyle(a),d=s==="none"||Mu(c)||s==="absolute"&&!!c.position&&c.position!=="static",u=a===document.body&&!o;if(d){s="none";const f=u?{x:!1,y:!1}:Ss(c);(f.x||f.y)&&t.push({node:a,...f})}(c.position==="absolute"||c.position==="fixed")&&(s==="none"||c.position==="fixed")&&(s=c.position==="fixed"?"fixed":"absolute")}return t}function ws(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 Mt(e){return Number.parseFloat(e)||0}function Un(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=ws(e),o=Mt(n.borderLeftWidth),s=Mt(n.borderTopWidth),i=Mt(n.borderRightWidth),a=Mt(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-i):0,d=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-s-a):0;return{left:t.left+o*r.x,top:t.top+s*r.y,right:t.right-(i+c)*r.x,bottom:t.bottom-(a+d)*r.y}}function Fu(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(s,i,a)=>{i&&(r.left=Math.max(r.left,s.left),r.right=Math.min(r.right,s.right)),a&&(r.top=Math.max(r.top,s.top),r.bottom=Math.min(r.bottom,s.bottom))};return t.forEach(s=>o(Un(s.node),s.x,s.y)),n&&o(Un(n),!0,!0),r}var Hn={originX:0,originY:0,scaleX:1,scaleY:1};function xt(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 Is(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 Ts(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 Bu=1e3;function ju(e){const{slot:t,own:n}=e;let r,o=0,s=!1;const i=()=>{if(r=void 0,!s){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(i))}},a=()=>{!s&&r===void 0&&(r=window.requestAnimationFrame(i))},c=()=>{o=performance.now()+Bu,a()},d=[window],u=[document.documentElement];for(let m=t;m;m=Re(m)){const T=m.getRootNode();T instanceof ShadowRoot&&!d.includes(T)&&(d.push(T),u.push(T))}const f=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];d.forEach(m=>f.forEach(([T,P])=>m.addEventListener(T,P,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const h=typeof MutationObserver=="function"?new MutationObserver(m=>{m.some(T=>!n.contains(T.target))&&a()}):void 0;u.forEach(m=>h?.observe(m,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let v;try{if(typeof ResizeObserver=="function"){const m=new ResizeObserver(a);typeof m.observe=="function"&&(v=m)}}catch{v=void 0}let _=[];return{schedule:a,observe:m=>{!v||m.length===_.length&&m.every((T,P)=>T===_[P])||(v.disconnect(),_=m,m.forEach(T=>v?.observe(T)))},dispose(){s=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),d.forEach(m=>f.forEach(([T,P])=>m.removeEventListener(T,P,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),h?.disconnect(),v?.disconnect()}}}var Uu="pluginZoom",Hu=/^(?:ant|vscode|monaco|docs)-/;function $u(e){return Hu.test(e)}function Vu(){const e="em".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var Gu=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function Wu(){return Gu}var Yu=new Set;function qu(e,t,n=Yu){return e.startsWith(`${t}-`)?!1:!$u(e)&&!n.has(e)}function zu(e,t){return`--${t}-${e}`}function Cs(e){const t=Vu();return qu(e,t,Wu())?zu(e,t):`--${e}`}function Ku(e,t){const n=Cs(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function As(e,t){return Ku(e,t)}var Ds=300,Ps=15e3,Xu=5e3,Os="em-canvas-busy-style";function Ju(){if(document.getElementById(Os))return;const e=document.createElement("style");e.id=Os,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var Qu="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 Zu(e){const t=As("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(Cs("colorPrimary")).trim()||t}function Rs(e){Ju();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",Qu),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:${Zu(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function ef(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),s=Math.min(r.right,e.right,n.width),i=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return s<=o||a<=i?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+s)/2-e.left,y:(i+a)/2-e.top}}function tf(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},s=r.getBoundingClientRect();if(s.width>0&&!Ts({left:s.left,top:s.top,width:s.width,height:s.height},o)){const i=xt(o,Is(s,xt(o,Hn),Hn));Object.assign(r.style,{left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const i=ef(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${i.x}px`,top:`${i.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(Rs(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function $n(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(Rs(e))},Ds);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var nf=8e3;function rf(){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 of(e,t){for(let n=Re(e);n;n=Re(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",s=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(i=>Ge(i)>0);if(o&&s)return n;if(n===t)return null}return null}function Ge(e){return Number.parseFloat(e)||0}function Ft(e,t){return Math.abs(e-t)<=1}function sf(e){const t=getComputedStyle(e),n=Ge(t.borderTopWidth),r=Ge(t.borderRightWidth),o=Ge(t.borderBottomWidth),s=Ge(t.borderLeftWidth),i=(a,c,d)=>Math.max(0,Ge(a)-Math.max(c,d));return{...Un(e),radii:[i(t.borderTopLeftRadius,n,s),i(t.borderTopRightRadius,n,r),i(t.borderBottomRightRadius,o,r),i(t.borderBottomLeftRadius,o,s)]}}function af(e,t){const n=Ft(t.top,e.top),r=Ft(t.bottom,e.bottom),o=Ft(t.left,e.left),s=Ft(t.right,e.right),i=[n&&o?e.radii[0]:0,n&&s?e.radii[1]:0,r&&s?e.radii[2]:0,r&&o?e.radii[3]:0];return i.every(a=>a===0)?"":i.map(a=>`${a}px`).join(" ")}function lf(e,t,n,r,o,s){const i=n.readyTimeoutMs??nf,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",As(Uu,"1"));const c=n.resolveSrc(e),d=document.createElement("iframe");d.setAttribute("sandbox",n.resolveSandbox(c)),d.setAttribute("allow","clipboard-read; clipboard-write"),d.setAttribute("title","Email content"),d.style.width="100%",d.style.border="0",d.style.display="block",d.style.minHeight="600px",d.src=c,a.appendChild(d),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(d);const u=new l.Disposable;let f=!1,h,v=!1,_,y,m,T;const P=()=>{clearTimeout(T),T=setTimeout(()=>{v||(v=!0,y?.(new Error(`[canvas] ${e}: документ не загрузился за ${i} мс`)))},i)},F=()=>f?(m=Promise.resolve(),v=!0,m):(v=!1,m=new Promise((R,H)=>{_=R,y=H}),P(),m),N=()=>{if(clearTimeout(T),f=!0,v){m=Promise.resolve();return}v=!0,n.mark?.("loaded"),_?.()};d.addEventListener("load",N),u.addDispose(()=>{clearTimeout(T),d.removeEventListener("load",N)});let C;const E=()=>{C??=n.bindResizer?.(d)},b=()=>{C?.dispose(),C=void 0};let w=null,O=null,M,D=Hn,k="",g="",I=0;const x=R=>{const H=JSON.stringify(R);return H===k?!1:(k=H,a.style.visibility=R.visibility,a.style.left=`${R.css.left}px`,a.style.top=`${R.css.top}px`,a.style.width=`${R.css.width}px`,a.style.height=`${R.css.height}px`,a.style.borderRadius=R.radius,d.style.width=R.elementWidth>0?`${R.elementWidth}px`:"100%",d.style.transform=R.shiftX!==0?`translate(${R.shiftX}px, ${R.shiftY}px)`:`translateY(${R.shiftY}px)`,!0)};let A=!1;const p=()=>{if(!w)return k="",a.style.visibility="hidden",d.removeAttribute("id"),!1;n.elementId&&(d.id=n.elementId);const R=w.getBoundingClientRect(),H=xu(w),q=O?.isConnected?O:null;M?.observe([w,d,...H.map(te=>te.node),...q?[q]:[]]);const K=Fu(R,H,q),X=Math.max(0,K.right-K.left),Xe=Math.max(0,K.bottom-K.top),yt=getComputedStyle(w).visibility==="visible",xe=X<=0||Xe<=0,Se=xe?{left:K.left,top:K.top,right:K.left,bottom:K.top}:K,L=xe?null:of(w,q??H[0]?.node??null),z=L?af(sf(L),Se):"",W=te=>x({visibility:yt&&!A?"":"hidden",css:xt(Se,te),elementWidth:R.width/te.scaleX,shiftX:(R.left-Se.left)/te.scaleX,shiftY:(R.top-Se.top)/te.scaleY,radius:z});let ce=W(D);if(!xe){const te=a.getBoundingClientRect();te.width>0&&!Ts({left:te.left,top:te.top,width:te.width,height:te.height},Se)&&(D=Is(te,xt(Se,D),D),ce=W(D)||ce)}return ce},S=()=>{if(!w)return!1;let R=p();const H=d.getBoundingClientRect().height;H>0&&H!==I&&(I=H,w.style.height=`${H/ws(w).y}px`,R=!0);const q=getComputedStyle(w).pointerEvents;return q!==g&&(g=q,a.style.pointerEvents=q),R},B=()=>{M?.dispose(),M=void 0},V=R=>{M=ju({slot:R,own:a,measure:S,onDetached:B})};let $=[];const G=(R,H)=>{if(O=H,R&&$.length>0){const q=$;$=[],q.forEach(K=>K())}if(R===w){R&&!M&&V(R),S();return}if(B(),w&&w.style.removeProperty("height"),k="",I=0,g="",w=R,!R){p(),b();return}n.onShown?.(d),V(R),S(),E()};u.addDispose(B);const j=R=>{f=!1,h=void 0,s?.(),R&&n.onReload?.(d);let H;v||m===void 0?H=F():(P(),H=m);try{d.contentWindow?.location.reload()}catch{d.src=c}return H};return{element:d,ready(){return m??F()},reload:()=>j(!0),reloadQuietly:()=>j(!1),followReload:()=>{h=void 0,s?.(),n.onReload?.(d)},moveTo(R){if(a.parentNode===R)return m??F();f=!1,h=void 0,s?.();let H;return v||m===void 0?H=F():(P(),H=m),R.appendChild(a),n.onReload?.(d),k="",M?.schedule(),H},get shown(){return w!==null},get slot(){return w},whenShown(){return w!==null?Promise.resolve():new Promise(R=>{$.push(R)})},get filled(){return h},noteFilled(R){h=R},alignTo(R,H){G(R,H??null)},hold(R){A!==R&&(A=R,p())},scrollBy(R,H){let q=R,K=H;for(let X=w?Re(w):null;X;X=Re(X)){if(Math.abs(q)<1&&Math.abs(K)<1)return;const Xe=getComputedStyle(X);if((Xe.overflowY==="auto"||Xe.overflowY==="scroll")&&X.scrollHeight>X.clientHeight){const yt=X.scrollTop,xe=X.scrollLeft;X.scrollBy({left:q,top:K,behavior:"instant"}),q-=X.scrollLeft-xe,K-=X.scrollTop-yt}}(Math.abs(q)>=1||Math.abs(K)>=1)&&window.scrollBy({left:q,top:K,behavior:"instant"})},resize(){C?.resize()},dispose(){G(null,null),b(),u.dispose(),a.remove()}}}function cf(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(D,k)=>D==="email"?`email:${k??n}`:D,s=new Map;let i,a=[],c=!1,d,u,f=!1,h,v,_="shown",y=0,m,T,P;const F=D=>u!==void 0&&D.filled!==void 0&&D.filled!==u,N=()=>{m=void 0;const D=h;!f||!D||u===void 0||T===u||!F(D)||(T=u,e.onForeignDocument?.({wanted:u,filled:D.filled,role:_,heldMs:Date.now()-y}))},C=()=>{f=!1,h=void 0,v=void 0,clearTimeout(m),m=void 0},E=(D,k)=>{const g=s.get("email"),I=g?.slot??null;return D&&I&&F(D)?(D.alignTo(null),f||(f=!0,y=Date.now(),m=setTimeout(N,Xu)),_=k,h=D,!(i!==void 0||c)&&v!==D&&(v=D,e.onShown?.(D.element)),!d&&!i&&(d=$n(I)),!1):(f&&(C(),d?.remove(),d=void 0),D?.alignTo(I,g?.clip??null),!0)},b=()=>{f&&!c&&E(t.get(o("email")),"shown")},w=()=>{a.forEach(D=>clearTimeout(D)),a=[],i?.remove(),i=void 0,d?.remove(),d=void 0,(c||f)&&(c=!1,E(t.get(o("email")),"shown"))},O=(D,k,g)=>{const I=o(D,k),x=t.get(I);if(x)return x;const A=e.resolveMount();if(!A)return rf();const p=lf(D,A,e,D==="email"?k??n:void 0,g,D==="email"?()=>b():void 0);return t.set(I,p),p},M={get:D=>O(D),current:D=>O(D),peek:D=>t.get(o(D)),spare:()=>t.get(o("email",r())),ensureSpare:()=>O("email",r(),!0),promote(){const D=t.get(o("email",r()));if(!D)return;const k=t.get(o("email"));n=r(),P=void 0,E(D,"spare"),k?.alignTo(null)},alignSurface(D,k,g){const I=s.get(D);if(s.set(D,{slot:k,clip:g??null}),D==="email"&&c){d?.remove(),d=k?$n(k):void 0;return}const x=k?O(D):t.get(o(D));if(D!=="email"){x?.alignTo(k,g??null);return}if(!k){P=I?.slot&&x?.shown?{slot:I.slot,handle:x}:void 0,f&&(C(),d?.remove(),d=void 0),x?.alignTo(null);return}const A=P?.slot===k&&P.handle===x;if(P=void 0,I?.slot===k&&x?.shown||A){x?.alignTo(k,g??null);return}E(x,"shown")},want(D){u=D,D!==void 0&&b()},noteFilled(D,k){const g=M.byWindow(D);g&&(g.noteFilled(k),g===t.get(o("email"))&&b())},visible(){for(const D of t.values())if(D.shown)return D},byWindow(D){if(D){for(const k of t.values())if(k.element.contentWindow===D)return k}},busy(D){if(w(),!D)return;if(!M.visible()){c=!0,d?.remove(),d=void 0;const I=s.get("email");I?.slot&&(d=$n(I.slot)),a=[setTimeout(w,Ps)];return}const k=e.resolveMount();if(!k)return;const g=tf(k,()=>M.visible()?.element.parentElement?.getBoundingClientRect()??null);i=g,a=[setTimeout(()=>g.showSpinner(),Ds),setTimeout(w,Ps)]},remount(D){w();const k=o("email");t.forEach((g,I)=>{if(I===k){g.moveTo(D).catch(()=>{});return}g.dispose(),t.delete(I)})},dispose(){u=void 0,c=!1,C(),P=void 0,w(),t.forEach(D=>D.dispose()),t.clear(),s.clear(),n="a",u=void 0,T=void 0}};return M}var df=l.createIdentifier$1("canvas.resizerBinder"),Vn=l.createIdentifier$1("canvas.service"),uf={created:oe.canvasCreated,loaded:oe.canvasLoaded},ks=new WeakMap;function Gn(e){return ks.get(e)??0}function ff(e,t){if(e.getInstance(Vn))return;const n=cf({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:Kd,elementId:t.elementId,bindResizer:o=>e.getInstance(df)?.(o),onCreated:o=>ot(e,o,"fresh"),onReload:o=>{ks.set(o,Gn(o)+1),ot(e,o,"fresh")},onShown:o=>{const s=n.byWindow(ie(e).getTarget());s&&s.element!==o&&Ls(s.element)===Ls(o)||ot(e,o,"switch")},mark:o=>t.mark?.(uf[o]),onForeignDocument:o=>{({...o},Bl("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=ie(e).addListener(l.EVENT_TYPES.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(Vn,n),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),n.dispose()})}function Ls(e){return e.parentElement?.dataset.canvasHost}function ot(e,t,n){const r=ie(e),o=t.contentWindow;if(!o)return;const s=r.getTarget()===o;s&&n==="switch"||(n==="fresh"&&(r.forget(o),s&&r.setTarget(void 0)),r.setTarget(o),Od(r))}function pf(e,t){ot(e,t,"promote")}function hf(e,t){ot(e,t,"switch")}function mf(e,t){const n=t.contentWindow;n&&ie(e).greet(n)}function Ns(e,t){const n=t.contentWindow;n&&ie(e).forget(n)}function gf(e,t){const n=ne(e)?.byWindow(t)?.element;if(!n)return;const r=Gn(n);return()=>Gn(n)!==r}function ne(e){return e.getInstance(Vn)}function Ms({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:s}){if(!r)return;const i={id:o??void 0,renderGuid:n,showId:s?.id,isNew:o==null,showToken:s?.token},a={...e,...i};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function Bt(e){return{...Ms({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function jt(e){const t=se(e),n=t.current();if(!n||!Q(t.sessionKey()))return;const r=Bt(n),o=n.isDirty();re(e,l.events.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function vf(e){const t=se(e);return!t.current()||!Q(t.sessionKey())?!1:(jt(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function Ef(e){const t=se(e),n=ie(e),r=()=>e.getInstance(l.INIT_PIPELINE_ID)??jn;let o,s,i=!1,a=!1,c,d;const u=g=>Bt(g),f=()=>{const g=F(),I=g?.get().docId;if(!g||!I||I!==c||i)return;const x=g.get().version;x!==d&&(d=x,re(e,l.events.ON_BLOCK_CHANGED_ID).fire(u(g)))};let h;const v=g=>{const I=t.showFacts();!I||I.id===h||!Bn(g,I.id)||(h=I.id,g.completeShow(I.id))},_=async(g,I,x)=>{const A=x.generation,p=()=>x.generation!==A||x.signal.aborted||t.current()!==g||a,S=fe(n);let B;const V=new Promise(G=>{B=Ot(n,()=>G("regenerated"))}),$=async(...G)=>await Promise.race([Pe(...G).then(()=>"sent"),V])==="sent";i=!0;try{if(!await $(n,"INIT_START",l.EVENT_TYPES.SANDBOX_INIT_START,{guid:I},void 0,x)||p())return;const{html:G,hasBrowserExtensionArtifacts:j}=ms(kt(g));if(j&&re(e,l.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),gs(g,G),!await $(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,Nt(kt(g),I,Oe(e).editorPolicy,g.get().version),void 0,x)||p()||!await $(n,"INITED",l.EVENT_TYPES.SANDBOX_INITED,{guid:I},void 0,x)||p())return;o=I,s=S,N(),d=g.get().version,c!==I&&(c=I,re(e,l.events.ON_BLOCK_INIT_ID).fire(u(g))),v(x)}finally{B?.(),i=!1,fe(n)!==S&&b()}};let y,m,T;const P=()=>{const g=ne(e)?.peek("block");return g?.reload?(g.reload().catch(()=>{}),!0):!1},F=()=>Q(t.sessionKey())?t.current():void 0,N=()=>{const g=F()?.get().docId,I=!g||T===g||o===g&&s===fe(n);ne(e)?.peek("block")?.hold(!I)},C=()=>{if(a||(N(),f(),i))return;const g=F(),I=g?.get().docId;if(!g||!I)return;if(o===I&&s===fe(n)){v(r());return}if(!g.isReady())return;const x=r();x.signal.aborted||o!==void 0&&o!==I&&y!==I&&(y=I,P())||_(g,I,x).catch(()=>{if(!(a||t.current()!==g)){if(m!==I){m=I,P();return}T=I,N()}})};let E=!1;const b=()=>{E||a||(E=!0,queueMicrotask(()=>{E=!1,C()}))};let w,O;const M=()=>{const g=F(),I=g?.get().docId;I!==O&&(w?.(),O=I,w=g?.subscribe(b)),N(),b()},D=t.subscribe(M),k=Ot(n,()=>{N(),b()});M(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{a=!0,k(),w?.(),D()})}function _f(e){const t=se(e);let n="email";const r=()=>{if(!t.current())return;const s=Q(t.sessionKey())?"block":"email",i=ne(e);if(s===n||!i)return;n=s;const a=i.peek(s);if(a){hf(e,a.element);return}i.get(s)},o=t.subscribe(r);e.getInstance(l.DISPOSABLE_ID)?.addDispose(o)}var bf=200;function yf({startVersion:e,limit:t=bf}){let n=[],r=e;const o=s=>{n=n.filter(i=>i.version>s),r=Math.max(r,s)};return{record(s){!s.changes?.length&&!s.contentReplaced||(n.push(s),n.length>t&&o(n[n.length-t-1].version))},rebase(s,i){if(i<r)return null;const a=n.filter(d=>d.version>i);o(i);let c=s;for(const d of a){if(d.contentReplaced||!d.changes)return null;const u=d.changes,f=[];for(const h of c){if(d.fromCanvas&&u.some(_=>h.range.start<=_.oldEnd&&h.range.end>=_.oldPosition))return null;const v=Gl(h.range,u,"after");if(!v)return null;f.push({range:v,text:h.text})}c=f}return c}}}function Sf(e,t){let n=0;return e.map(({start:r,end:o,text:s})=>{const i=new he(r,t.slice(r,o),r+n,s);return n+=s.length-(o-r),i})}function wf(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return Sf(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function If(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Wn=l.createIdentifier$1("canvas.sandboxFill");function xs(e){return e.getInstance(Wn)?.pipeline.isEventsLocked()===!0}function Ut(e){Ze(e,{origin:"canvas-channel"})}function Tf(e){const t=se(e),n=ie(e);let r;const o=(c,d)=>{const u=c.get().docId;let f=!1,h=null,v=null;const _=yf({startVersion:c.get().version});let y=c.getContent(),m=!0;const T=(b,w)=>{!m||t.current()!==c||(Ze(w,{origin:"canvas-channel"}),n.sendAsync(l.EVENT_TYPES.SANDBOX_SET_ENTITY,Nt(kt(c),u,Oe(e).editorPolicy,c.get().version)).catch(Ut))},P=async(b,w)=>{if(v){v.push({edits:b,rev:w});return}v=[{edits:b,rev:w}];try{do{const O=v.splice(0,v.length);await n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:O.map(M=>M.edits),guid:u,rev:O[O.length-1].rev})}while(v.length)}catch(O){T("app edits failed to reach the canvas",O)}finally{v=null}},F=(b,w)=>{const O=v?.splice(0,v.length)??[];O.length&&n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:O.map(M=>M.edits),guid:u,rev:O[O.length-1].rev}).catch(Ut),n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:[b],guid:u,rev:c.get().version,...w!==null?{changeId:w}:{}}).catch(Ut)},N=b=>{const{guid:w,pushUndoStop:O}=b;if(w!==u)return;const M=tc(b);let{edits:D}=b;if(M.baseRev!==null){const g=_.rebase(D,M.baseRev);if(!g){Ze(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),F([],M.changeId);return}D=g}const k=c.get().version;try{f=!0,h=M.changeId;const g=wf(D,c.getContent());O===!1?d.applyWithoutHistory(g):c.mutate({changes:g},{source:xs(e)?"system":"user"})}catch(g){T("canvas batch failed to apply",g);return}finally{f=!1,h=null}c.get().version===k&&M.baseRev!==null&&F([],M.changeId)},C=c.subscribe(({changes:b,version:w})=>{const O=c.getContent(),M=!b?.length&&O!==y;if(y=O,_.record({version:w,changes:b,contentReplaced:M,fromCanvas:f}),!b?.length)return;const D=If(b);f?F(D,h):P(D,w).catch(Ut)}),E=n.addListener(l.EVENT_TYPES.APPLICATION_UPDATE_ENTITY,N);return()=>{m=!1,C(),E.dispose()}};let s;const i=()=>{const c=t.current(),d=t.history(),u=c?.get().docId;u!==s&&(r?.(),r=void 0,s=u,c&&d&&(r=o(c,d)))},a=t.subscribe(i);i(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r?.(),a()})}function Cf(e){const t=ie(e),n=()=>ne(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(l.EVENT_TYPES.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(l.EVENT_TYPES.RELOAD,a=>{const c=ne(e)?.byWindow(a);c&&Ns(e,c.element)}),s=t.addListener(a=>{a.data?.operation===l.EVENT_TYPES.SANDBOX_RESIZED&&n()?.resize()}),i=Y(e,l.events.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),o.dispose(),s.dispose(),i.dispose()})}function Fs(){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 Af(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID);let n,r;e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r?.remove(),r=void 0}),ff(e,{resolveMount:()=>n,resolveSrc:s=>cs(s==="block"),elementId:"email_iframe",mark:s=>J(s)}),t?.watch(s=>{const i=s?.element;if(n&&i instanceof HTMLElement&&i!==n){n=i,ne(e)?.remount(i),r?.remove(),r=void 0;return}if(!n){if(i instanceof HTMLElement)n=i;else if(s!==void 0){n=r??=Fs(),ne(e)?.alignSurface("email",r,r);return}else return;ne(e)?.get("email")}});let o;e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{o?.remove(),o=void 0}),cd(e).watch(s=>{const i=ne(e);if(i){if(s){o??=Fs(),i.alignSurface("email",o,o);return}o&&(i.alignSurface("email",null),o.remove(),o=void 0)}})}var Yn=l.createIdentifier$1("canvas.headerFlow"),Bs=["subject","preheader"],js=3e3,Df=3,Pf={subject:l.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,preheader:l.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE};function Of(e){const t=se(e),n=ie(e),r=C=>C?"remote":xs(e)?"system":"user",o=(C,{guid:E,value:b,forced:w})=>{const O=Ue(t);if(!O||typeof b!="string"||E&&E!==O.get().docId)return;const M=t.forcedHeaders();if(M?.[C]!==void 0&&!w&&b!==M[C])return;const D=O.get().attributes[C];if(!w&&v(C,b,D))return;const k=!w&&f.delete(C);w&&(m.delete(C),m.size===0&&t.endForcedHeaders());const g=D??"";c=!0;try{He(O,{[C]:b},{source:k?"system":r(w)})}finally{c=!1}s[C]=b,re(e,l.events.ON_HEADER_APPLIED_ID).fire({field:C,value:b,forced:!!w,isGenerated:b!==g&&!!b})};let s={},i,a,c=!1,d=Promise.resolve();const u={},f=new Map,h=(C,E)=>{s[C]=E;const b={};f.set(C,b);const w=()=>{f.get(C)===b&&f.delete(C)};_(C,E,{force:!0}).then(w),setTimeout(w,js)},v=(C,E,b)=>{const w=t.showFill();if(!w||typeof b!="string")return!1;const O=u[C]?.showId===w.showId?u[C]:void 0;return E===b?(u[C]=O??{showId:w.showId,codeEdits:w.codeEdits,corrections:0},!1):O&&w.codeEdits>O.codeEdits&&E!==O.stale?!1:((!O||E===O.stale&&O.corrections<Df)&&(u[C]={showId:w.showId,stale:E,codeEdits:w.codeEdits,corrections:(O?.corrections??0)+1},h(C,b)),!0)},_=(C,E,{force:b=!1,echo:w=!1,undoStep:O=!1})=>(d=n.sendAsync(Pf[C],{value:E,guid:Ue(t)?.get().docId,...b?{force:!0}:{},...w?{echo:!0}:{},...O?{undoStep:!0}:{}}).catch(M=>{}),d);let y;const m=new Set;e.inject(Yn,{whenDelivered:async()=>{await d},reassert:C=>{const E=Ue(t),b=Bs.filter(w=>typeof C[w]=="string");if(!(!E||b.length===0)){c=!0;try{He(E,Object.fromEntries(b.map(w=>[w,C[w]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders(Object.fromEntries(b.map(w=>[w,C[w]]))),clearTimeout(y),y=setTimeout(()=>{m.clear(),t.endForcedHeaders()},js),m.clear();for(const w of b)m.add(w);for(const w of b)s[w]=C[w],_(w,C[w],{force:!0,echo:!0})}}});const T=()=>{i?.(),i=void 0;const C=Ue(t);if(C!==a&&f.clear(),a=C,!C){s={};return}const E=C.get().attributes;s={subject:E.subject,preheader:E.preheader},i=C.subscribe(({source:b})=>{if(c)return;const w=C.get().attributes,O=t.forcedHeaders();for(const M of Bs){const D=w[M];if(D===s[M])continue;s[M]=D,f.delete(M);const k=b==="system"&&O?.[M]!==void 0;_(M,D??"",{force:k,echo:k,undoStep:b==="user"})}})};T();const P=t.subscribe(T),F=n.addListenerAsync(l.EVENT_TYPES.APPLICATION_SUBJECT_UPDATE,C=>o("subject",C)),N=n.addListenerAsync(l.EVENT_TYPES.APPLICATION_PREHEADER_UPDATE,C=>o("preheader",C));e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{F.dispose(),N.dispose(),P(),i?.(),clearTimeout(y)})}function Rf(e){const t=se(e);let n={document:void 0,seq:0};const r=()=>{const s=t.recoveryFacts(),i=Ue(t);if(!s?.applied||!i||String(s.emailId)!==String(i.get().serverId)||(n.document!==i&&(n={document:i,seq:0}),s.applied.seq<=n.seq))return;n={document:i,seq:s.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(Yn)?.reassert(a)},o=t.subscribe(r);e.getInstance(l.DISPOSABLE_ID)?.addDispose(o)}function kf(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?l.DARK:l.LIGHT}function Lf(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 Nf(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Us(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function qn(e,t){const n={...e};for(const r of Object.keys(t)){const o=t[r],s=e[r];Us(o)&&Us(s)?n[r]=qn(s,o):o!==void 0&&(n[r]=o)}return n}function Mf(e,t){const n=l.COMMON_STYLES;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 qn(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?qn(n,t):n}var xf=ae(void 0),Hs=xf,$s=l.createIdentifier$1("CodeMode");function Vs(){let e;try{const t=window.localStorage?.getItem(l.LOCAL_STORAGE_ITEMS.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 Ff(e){try{window.localStorage?.setItem(l.LOCAL_STORAGE_ITEMS.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function zn(e){return e.getOrCreateInstance($s,()=>{const t=ae(Vs());return t.watch(Ff),t})}function Gs(e){return e?.getInstance($s)?.get()??Vs()}function Kn(e,t){const n=zn(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function Bf(e,t){const n=zn(e);n.set({...n.get(),direction:t})}var jf=l.createIdentifier$1("DefaultCommonStyles");function Ws(e){return e.getOrCreateInstance(jf,()=>ae(void 0))}function Uf(e,t){Ws(e).set(t)}var Hf=l.createIdentifier$1("CanvasViewport"),$f=l.createIdentifier$1("CanvasPreviewPage");function be(e,t,n){let r,o;const s=()=>{if(!r||!e.isInited())return;const c=r.value===void 0?"undefined":JSON.stringify(r.value);c!==o&&(o=c,e.send(t,r.value))},i=n.watch(c=>{r={value:c},s()}),a=e.onInit(()=>{o=void 0,s()});return{dispose(){i.dispose(),a.dispose()}}}function Ht(e){const t=ae(e());return{source:t,refresh:()=>t.set(e())}}function Vf(e){const t=ie(e),n=e.getInstance(l.CONFIG_SOURCE_ID),r=e.getInstance(l.OPTIONS_SOURCE_ID),o=se(e),s=zn(e),i=matchMedia(l.PREFERS_COLOR_SCHEME_DARK),a=()=>n?.get()??{};let c;const d=Ht(()=>kf(Hs.get()??a().theme,i.matches)),u=Ht(()=>Lf(a(),Q(o.sessionKey()))),f=Ht(()=>a().lockEditor),h=Ht(()=>Mf(o.current()?.get().attributes?.common_styles,c)),v=e.getOrCreateInstance(Hf,()=>ae()),_=e.getOrCreateInstance($f,()=>ae()),y=[be(t,l.CANVAS_FACTS.theme,d.source),be(t,l.CANVAS_FACTS.flags,u.source),be(t,l.CANVAS_FACTS.lockEditor,f.source),be(t,l.CANVAS_FACTS.commonStyles,h.source),be(t,l.CANVAS_FACTS.codeMode,s.select(Nf)),be(t,l.CANVAS_FACTS.appName,ae("emailmaker")),be(t,l.CANVAS_FACTS.previewPage,_),be(t,l.CANVAS_FACTS.viewport,v)],m=()=>{d.refresh(),u.refresh(),f.refresh()},T=n?.watch(m),P=Ws(e).watch(O=>{c=O,h.refresh()}),F=r?.watch(O=>{O&&"commonStyles"in O&&(c=O.commonStyles),h.refresh()});let N;const C=()=>{N?.(),N=o.current()?.subscribe(()=>h.refresh()),h.refresh(),u.refresh()};C();const E=o.subscribe(C),b=()=>d.refresh();i.addEventListener("change",b);const w=Hs.watch(()=>d.refresh());e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{y.forEach(O=>O.dispose()),T?.dispose(),P.dispose(),F?.dispose(),N?.(),E(),i.removeEventListener("change",b),w.dispose()})}var Xn;(function(e){function t(o,s,i=(a,c)=>a===c){if(o===s)return!0;if(o.length!==s.length)return!1;for(let a=0;a<o.length;a++)if(!i(o[a],s[a]))return!1;return!0}e.isEqual=t;function n(o,s=i=>i){const i=new Set;return o.filter(a=>{const c=s(a);return i.has(c)?!1:(i.add(c),!0)})}e.unique=n;function r(o=[],s=[],i=(a,c)=>a===c){const a=[],c=[],d=[];for(const u of o){const f=s.find(h=>i(u,h));f?d.push({prev:u,next:f}):c.push(u)}for(const u of s)o.find(f=>i(u,f))||a.push(u);return{added:a,removed:c,exists:d}}e.diff=r})(Xn||(Xn={}));function Gf(e,t){return e.type===t.type&&e.key===t.key}function Wf(e){const t=ie(e),n=()=>e.getServices(l.SANDBOX_EXTENSIONS_ID)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(l.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,r)}),s=l.getServiceContainerId(l.SANDBOX_EXTENSIONS_ID),i=e.onInject(a=>{if(a!==s)return;const c=n();if(!t.isInited()){r=c;return}const{added:d,removed:u}=Xn.diff(r,c,Gf);if(r=c,u.length){if(u.some(f=>f.type==="script")){t.send(l.EVENT_TYPES.RELOAD);return}t.send(l.EVENT_TYPES.SANDBOX_REMOVE_EXTENSIONS,u.map(f=>f.key))}d.length&&t.send(l.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,d)});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{o.dispose(),i?.dispose()})}var Yf=new Set([...Object.values(l.EVENT_TYPES).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(l.SANDBOX_EXTENSION_SCRIPT_STATUS_ID)]);function qf(e){return e.length>0&&!e.startsWith("em:")&&!Yf.has(e)}function zf(e){const t=ie(e),n=new Map;let r=!1,o=-1,s=new Set;const i=d=>(d!==o&&(o=d,s=new Set),s),a=t.observeOutgoing((d,u)=>{if(!r||!qf(d))return;const f=fe(t);n.set(d,{data:u,generation:f,scripts:new Set(i(f))})}),c=t.addListener(l.SANDBOX_EXTENSION_SCRIPT_STATUS_ID,d=>{if(d.phase!=="ready"||d.status!=="success")return;r=!0;const u=fe(t),f=i(u);f.add(d.key);for(const[h,v]of n)v.generation===u||![...v.scripts].every(_=>f.has(_))||(v.generation=u,t.send(l.createIdentifier(h),v.data))});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{a.dispose(),c.dispose()})}var Kf=l.createIdentifier$1("prewarm.editorVisible");function Xf(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Jf(e={}){const t=e.paint??Xf;let n=!1,r=!1,o=!1,s=!1,i=!1;const a=[],c=()=>{i||s||!n||!r||!o||(s=!0,t(()=>{i=!0,J(oe.editorVisible);for(const d of a.splice(0))d()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){o=!0,c()},whenVisible(d){if(i){d();return}a.push(d)},contentShown:()=>o}}function Qf(e){return e.getOrCreateInstance(Kf,()=>Jf())}var Zf=500,ep=500,tp=5e3;function np(e){const t=e.quietMs??Zf,n=e.floorMs??ep,r=e.ceilingMs??tp;let o,s,i=0;const a=()=>{clearTimeout(o),clearTimeout(s),o=void 0,s=void 0},c=()=>{a(),e.run()},d=()=>{clearTimeout(o);const u=n-(Date.now()-i);o=setTimeout(c,Math.max(t,u))};return{start(){a(),i=Date.now(),s=setTimeout(c,r),d()},notify(){o!==void 0&&d()},cancel:a}}var rp=2;function Ys(){return new Error("[sandbox] document reloaded during fill")}function op(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Jn(e){try{e()}catch{}}function sp(e){let t;return Jn(()=>{t=e()}),{stage:n=>Jn(()=>t?.stage(n)),end:(n,r)=>Jn(()=>t?.end(n,r))}}function ip(e){const t=()=>e.initPipeline();let n=!1,r,o,s,i=0,a,c;const d=()=>{const E=e.readTarget?.(),b=e.readSandboxGeneration?.();return E===void 0||b===void 0?void 0:{target:E,generation:b}},u=()=>{const E=d();return E&&{...E,canvasReplaced:e.trackDocument?.(E.target)}},f=E=>{if(E?.canvasReplaced?.())return!0;const b=d();return E!==void 0&&b?.target===E.target&&b.generation!==E.generation},v=Ou({...e,waitScope:()=>({getSandboxTimeoutMs:E=>t().getSandboxTimeoutMs(E),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const E=c;if(!(!E||!e.onSandboxGenerationChange))return{getGeneration:()=>d()?.generation??E.generation,onChange:b=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===E.target||E.canvasReplaced?.())&&b()})??(()=>{})}}});let _;const y=(E,b)=>{if(_===E)return;_=E;const w=i;setTimeout(()=>{i!==w||t().signal.aborted||F(E,b).catch(()=>{})},0)},m=()=>{a?.abort(),a=void 0};let T;const P=()=>{const E=t().signal;E!==T&&(T?.removeEventListener("abort",m),T=E,E.addEventListener("abort",m))};async function F(E,b,w=0){const O=++i;m(),a=new AbortController,c=void 0,P();const M=()=>i!==O,D=v.readTarget(),k=t().generation,g=()=>k===t().generation&&!t().signal.aborted,I=b?"init:reset-":"init:",x=sp(()=>e.observeShow?.(op(E,b,e.readEmail())));if(!b){const G=v.publicEmail();G?.id,G?.renderGuid,G?.preheader}let A=!1,p=!1,S,B=!1;const V=()=>{if(f(S))throw Ys()},$=()=>{if(M())throw l.createAbortError("Fill superseded")};try{n=!0,await v.sendInitStart(),$(),S=u(),c=S,w===0&&v.fireWillInit(),await(b||w>0?v.refreshContent():v.sendContent()),A=!0,$(),V();const G=v.contentSent();v.noteFilled(G?.target,G?.docId),x.stage("content"),b||v.publicEmail()?.id;try{await v.sendPreheader()}catch(j){if(vs(j)||M())throw j;`${I}`,String(j)}$();try{await v.sendSubject()}catch(j){if(vs(j)||M())throw j;`${I}`,String(j)}if($(),V(),v.showFilled(D),await v.sendInited(),$(),V(),p=!0,o===E){const j=e.readSandboxGeneration?.()??s;j!==void 0&&(r=j)}x.stage("reveal"),await v.revealFilled(),V(),x.end("revealed")}catch(G){const j=!M()&&g()&&f(S),R=j?Ys():void 0,H=R??G,q=j&&w<rp?C(E,b,w+1):void 0;B=j&&q===void 0;const K=M()?void 0:{showId:E,contentApplied:A,sandboxInitedAcked:p,superseded:!1,...e.describeSurface?.(),error:String(R??G)};K&&(`${I}`,void 0);const X=!M()&&e.recoverFailedFill?.(D)===!0;if(x.end(M()?"superseded":X?"recovered":l.isAbortError(H)||!g()?"aborted":"failed",K),!X&&!M()&&Bn(t(),E)&&t().failShow(E,H),q!==void 0)return q;throw H}finally{N(E,b,I,{superseded:M(),sessionGeneration:k,contentApplied:A,sandboxInitedAcked:p&&!B,retry:!B,commit:g()})}}function N(E,b,w,O){const{superseded:M,contentApplied:D,sandboxInitedAcked:k}=O;if(M){`${w}`;return}k&&O.commit?v.fireInit(E,b||void 0):k?(`${w}`,O.sessionGeneration,t().generation,t().signal.aborted,void 0):D?(`${w}`,void 0):(`${w}`,void 0),n=!1,a=void 0,!k&&o===E&&(o=void 0,r===s&&(r=void 0)),!k&&D&&O.retry&&y(E,b)}function C(E,b,w){return F(E,b,w)}return{channel:v,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:E=>{r=E},lastCorrelation:()=>o,markCorrelation:E=>{o=E},bumpRunSeq:()=>{i+=1},noteSandboxGeneration:E=>{s=E},fill:E=>F(E,!1),refill:E=>F(E,!0),stop:()=>{i+=1,m(),n=!1,T?.removeEventListener("abort",m),T=void 0}}}function ap(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:qs(e,n)}function qs(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function lp(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:s}=e,i=u=>{const f=n(),h=o();if(!ap(f,u,h)){u.showId,u.navId,u.emailId,f?.id,f?.showId,f?.renderGuid;return}u.showId,f?.id,f?.renderGuid,t.markFilled(s()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{i(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&i(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=s();if(t.filledGeneration()===u)return;const f=n(),h=o();if(!f?.renderGuid||!qs(f,h))return;const v=`${bs}${f.renderGuid}`;t.markFilled(u),t.markCorrelation(v);const _=r()?.isReady()===!0;f.id,f.renderGuid,(_?y=>t.refill(y):y=>t.fill(y))(v).catch(()=>{t.lastCorrelation()===v&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id,r()}}}var cp=l.createIdentifier$1("canvas.health");function dp(e){return e??""}function up(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function zs(e){return e.length>0}function fp(e){const t=se(e),n=ie(e),r=()=>Q(t.sessionKey())?void 0:t.current(),o=()=>{const L=r();return Ms({attributes:L?.get().attributes??{},readContent:()=>L?.getContent(),docId:L?.get().docId,hasSession:!!L,serverId:L?.get().serverId,show:t.showFacts()})},s=()=>e.getInstance(l.INIT_PIPELINE_ID)??jn;let i={},a=!1;const c=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(L=>{a=!!L?.element});let d=!1,u=!1,f=!1,h=0;const v=()=>{const L=ne(e);if(!L)return;const z=++h,W=L.spare();return W&&Ns(e,W.element),(W?W.reloadQuietly():L.ensureSpare()?.ready())?.then(()=>{if(z!==h)return;d=!0;const ce=L.spare();ce&&mf(e,ce.element),f&&(f=!1,k(),j())})},_=np({run:()=>{f||v()?.catch(()=>{})}}),y=()=>{Qf(e).noteContentShown(),!d&&!f&&_.start()};let m=!1;const T=L=>{const z=ne(e),W=z?.spare()?.element.contentWindow;u&&z&&W&&L===W&&(u=!1,z.promote(),z.busy(!1),m=!0)};let P=!1;const C=ip({container:e,messageService:n,initPipeline:s,readDocument:r,readEmail:o,revealFilled:()=>{const L=ne(e);return m&&L&&(m=!1,_.start()),a?L?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:T,noteFilled:(L,z)=>ne(e)?.noteFilled(L,z),recoverFailedFill:L=>{const z=ne(e),W=z?.spare()?.element.contentWindow;return!u||!z||!W||L!==W?!1:(u=!1,d=!1,M="reload",z.busy(!1),z.peek("email")?.reload(),P=!0,j(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!i.isTemplate,readSandboxGeneration:()=>fe(n),onSandboxGenerationChange:L=>Ot(n,L),trackDocument:L=>gf(e,L),observeShow:L=>e.getInstance(cp)?.begin(L),describeSurface:()=>({canvasPath:M,promoted:u,spareClean:d,handshake:n.isInited(),generation:fe(n)}),events:{willInit:L=>{re(e,l.events.WILL_EMAIL_INIT_ID).fire(L)},inited:L=>{y(),re(e,l.events.ON_EMAIL_INIT_ID).fire(L)},contentChanged:L=>{re(e,l.events.ON_CONTENT_CHANGED_ID).fire(L)},emailChanged:L=>{re(e,l.events.ON_EMAIL_CHANGED_ID).fire(L)},browserExtensionDetected:()=>{re(e,l.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),E=lp({pipeline:C,initPipeline:s,readEmail:o,readDocument:r,readRouteEmailId:()=>i.emailId,readSandboxGeneration:()=>fe(n)});let b="",w="",O="",M="none";const D=()=>{const L=ne(e)?.spare()?.element.contentWindow;L&&n.getTarget()===L||n.sendNow({operation:l.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!0})},k=()=>{const L=ne(e)?.spare();L&&(D(),d=!1,u=!0,pf(e,L.element))},g=(L,z)=>{const W=ne(e);if(!W)return!0;const ce=W.spare(),te=ce&&d?"spare":"prepare";if(M=te,W.busy(!0),ce&&d)return k(),!0;_.cancel(),D();const Fe=v();if(Fe===void 0)return M="reload",W.busy(!1),W.peek("email")?.reload(),!0;f=!0;const we=h;return Fe.catch(()=>{!f||we!==h||(f=!1,M="reload",W.busy(!1),W.peek("email")?.reload())}),!1},I=()=>{if(Q(t.sessionKey()))return;Xe(),C.noteSandboxGeneration(fe(n));const L=o(),z=up(L?.renderGuid,L?.showId,L?.id,i.emailId),W=dp(L?.renderGuid);if(W!==w){const Fe=w;w=W;const we=ne(e)?.peek("email")?.filled,P_=we!==void 0&&we!==W;zs(W)&&(zs(Fe)||P_)&&g(Fe||(we??""),W)}if(f)return;(z!==b||P)&&(P=!1,b=z,E.showRequestIdentityChanged());const ce=r(),te=`${z}|${ce?.get().docId??""}|${fe(n)}`;te!==O&&ce?.isReady()===!0&&(O=te,E.selfInitChanged()),E.saasChanged(),$()};let x=!1,A="",p="",S=!1,B=!1;const V=L=>{L.source==="user"?B=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(S=!0),j()},$=()=>{const L=o();if(!L?.renderGuid)return;const z=C.channel.readContent(),W=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??""]),ce=x&&z!==p,te=x&&W!==A;x=!0,p=z,A=W;const Fe=S&&!B;if(S=!1,B=!1,C.isEventsLocked()||Fe)return;const we={...L,id:i.isTemplate||L.isNew?void 0:L.id,html:z};if(ce){re(e,l.events.ON_CONTENT_CHANGED_ID).fire(z),re(e,l.events.ON_EMAIL_CHANGED_ID).fire(we);return}te&&L.is_inited&&re(e,l.events.ON_EMAIL_CHANGED_ID).fire(we)};let G=!1;const j=()=>{G||(G=!0,queueMicrotask(()=>{G=!1,I()}))};e.inject(Wn,{pipeline:C,setRoute:L=>{L.emailId===i.emailId&&!!L.isTemplate==!!i.isTemplate||(i=L,j())}});let R,H;const q=()=>{const L=r()?.get().docId;L!==H&&(R?.(),H=L,R=r()?.subscribe(V)),j()};let K,X;const Xe=()=>{const L=e.getInstance(l.INIT_PIPELINE_ID);!L||L===K||(X?.(),K=L,X=L.onShowRequested(z=>E.showRequested(z)))},yt=n.addListener(L=>{L.data?.operation===l.EVENT_TYPES.SANDBOX_RESIZED&&_.notify()}),xe=t.subscribe(q),Se=Ot(n,j);q(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{c?.dispose(),X?.(),Se(),xe(),R?.(),yt.dispose(),_.cancel(),C.stop()})}function pp(){return l.USEBLOCKS!=="emailmaker"}var hp={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},Ks={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}},Xs=Ks,mp=["pro"],Qn={};function gp(e){Qn=e}var Js=e=>mp.includes(e)?Xs:Qn[e]??Qn.editor??Xs,Zn={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},vp={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},Ep={...Zn,config:{...Zn.config,imageCenterFileManagerView:!1}};gp({pro:Ks,editor:vp,simple:pp()?Zn:Ep,blocks:hp});function _p(e,t,n=e.getInstance(l.CONFIG_SOURCE_ID)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Gs(e).isCodeMode&&Kn(e,!1)}function bp(e){e.getInstance(l.STANDALONE_ACTIVATED_ID)||e.inject(l.SECURITY_MODULE_ID,void 0)}function $t(e){return String(e.standaloneKey||"").trim()||void 0}function yp(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function er(e){return yp(e)?!!$t(e):!1}function st(e){return!!$t(e)&&!er(e)}var Sp=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Qs(e){return e==="server"?"serverSide":e}function wp({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=ae();let s={kind:"pending"},i;const a=new Promise(h=>{i=h}),c=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function d(){s.kind!=="pending"&&o.set(Rn(r,e))}function u(h){if(s.kind!=="pending")return;clearTimeout(c),s=h;const v=Rn(r,e);o.set(v),i(v)}function f(h,v){r[Qs(h)]=v,h==="server"&&s.kind==="pending"?u({kind:"applied"}):d()}return{watch:h=>o.watch(h),select:h=>o.select(h),get:()=>o.get(),ready:()=>a,state:()=>s,layers:()=>({...r}),bootstrap(){const h=Rn(r,e);return Object.fromEntries(Sp.map(v=>[v,h[v]]))},merge(h,v){f(v,{...r[Qs(v)],...h})},replace(h,v){f(v,h)},setMode(h){r.user={...r.user,mode:h},d()},setAdvancedConfigs(h){r.advancedConfigs=h,d()},serverAbsent(h){u({kind:"absent",reason:h})},applyServerResponse(h){s.kind==="pending"&&f("server",{...r.serverSide,...h})},dispose(){clearTimeout(c)}}}var Ip=5e3,$_="pro";function Tp(){return{...Js("pro")?.config,mergeTags:void 0}}function Cp(e,t){e.getInstance(l.OPTIONS_SOURCE_ID)?.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 Ap(e,t){let n;On(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const s={};r?.theme&&(s.theme=r.theme),r?.locale&&(s.locale=r.locale),t.replace(s,"profile")})}function Dp(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Pp(e,t){let n,r=!1,o;const s=a=>{o??=Pt(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&_p(e,a,t)},i=On(e).watch(({profile:a})=>{const c=a?.email_builder_config,d=Dp(c);if(d===void 0||c===n)return;const u=n===void 0;n=c,!(u&&r)&&s(d)});e.getInstance(l.DISPOSABLE_ID)?.addDisposable(i),t.ready().then(a=>{if(!a.configSwither)return;const c=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,s(c)})}var Zs="замкнутый контур: app_init не выполняется";function Op(e,t){if(e.getInstance(l.SECURITY_MODULE_ID)){t.serverAbsent(Zs);return}const n=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(r=>{st(r)&&t.serverAbsent(Zs)});n&&e.getInstance(l.DISPOSABLE_ID)?.addDisposable(n)}async function Rp(e,t){if(e.getInstance(mn)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(l.APP_ID);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function kp(e){e.injectFactory(l.CONFIG_SOURCE_ID,(t,n)=>{if(n)return n;const r=wp({base:Tp(),env:{modeDefaults:o=>Js(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Ip});return Cp(e,r),Ap(e,r),Pp(e,r),Op(e,r),Rp(e,r),e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var We=class extends l.Disposable{_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=l.snapshot(e);return(o,s,i)=>{const a=r(async c=>{const d=t?t(c):c;i&&o.bind(i);const u=await o(d);return n?n(u):u},s,i);return()=>a.dispose()}}var Lp=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new l.Emitter;this.handleDestroy=U(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new We(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{}}},tr=l.createIdentifier$1("DestroyableService");function Np(e){e.injectFactory(tr,(t,n)=>{if(n)return n;const r=e.getInstance(l.DISPOSABLE_ID);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Lp({lifetime:r,options:e.getInstance(l.OPTIONS_SOURCE_ID),getInstance:()=>e.getInstance(l.INSTANCE_ID),release:()=>l.releaseContainer(e.getInstance(l.STORE_ID)??e)})},!0)}function Mp(e){const t=e.getInstance(tr);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var xp=1e3;function ei(e,t,n=xp,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),s=Object.keys(t);if(o.length!==s.length)return!1;for(const i of o)if(!ei(e[i],t[i],n,r+1))return!1;return!0}return!1}function it(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],s=e[r];ei(o,s)||(n[r]=o)}return n}var Fp=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function Bp(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function jp({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??It();let s;try{const i=e.notifySave(n);return await Promise.race([i,new Promise((a,c)=>{s=setTimeout(()=>{const d=new Ct(o);n.value.id,sc(d,Bp(i,r)),c(d)},o)})])}catch(i){throw To(i),i}finally{s!==void 0&&clearTimeout(s)}}function Up(e){const{emails:t}=e,n=async(r,o)=>{const s=Fp(o),i=r===void 0?void 0:await t.cache.getIfPresent(r),a=i?{...i,...s}:s,c=i?it(i,s):s,d=u=>{const f=String(u.id??r??l.generateUUID()),h=u.id===void 0?{...u,id:f}:u;return t.cache.addOrUpdate(f,()=>h)};return await d(await jp(e,{prev:i,patch:c,value:a,source:o.source??""},d))};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:l.generateUUID()}},async updateEmail(r,o){return await n(r,o)}}}var nr=20;function Hp(e){const t=$p(e);return e.saveTimeoutMs?Vp(t,e.saveTimeoutMs):t}function $p({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:s}){const i=async(a,c)=>(t.clear(),await t.get(a,{page:c}),(await e.cache.values()??[]).filter(d=>String(d?.parent)===String(a)));return{async readRevisions(a,c=1){const d=await i(a,c);return{revisions:d.slice(nr*(c-1),nr*c),page:c,hasMore:d.length>nr*c}},async readAutosave(a){const c=await r?.(a)??NaN,d=Number.isFinite(c)?c:void 0,u=await n?.(a);if(!u?.asked)return pc(await i(a,1),d);if(!u.revision)return Ao([],d);const f={...u.revision,parent:a,isAutosave:!0};return Ao([f],d,await i(a,1))},async saveAutosave(a,c){const d=await o?.(a),u=s?.();return await e.create({..._c(c),...d!==void 0?{author:d}:{},...u!==void 0?{project:u}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Vp(e,t){return{...e,async saveAutosave(n,r){const o=t();let s;try{return await Promise.race([e.saveAutosave(n,r),new Promise((i,a)=>{s=setTimeout(()=>a(new yo(o)),o)})])}catch(i){throw To(i),i}finally{s!==void 0&&clearTimeout(s)}}}}var Gp=class extends l.BaseEmitter{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}},Wp=class extends l.AsyncEmitter{};function V_(e){return e}var ti=class extends l.Disposable{_items=new Map;_onChangeEmitter=new l.Signal;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 l.deepEqual(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,s])=>o)),r=(await this.entries()).filter(([o,s])=>!n.has(o));for(const[o,s]of e)t.push(this.addOrUpdate(o,()=>s)),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 Yp(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:s=20}={}){const i=e.length;let a=e.length;if(t!==void 0){const c=Object.keys(t);e=e.filter(d=>{for(const u of c){const f=d[u],h=t[u];return u==="id"||typeof f!="string"?f===h:typeof h=="string"&&f.startsWith(h)}return!0}),a=e.length}return r&&(e=e.sort((c,d)=>(c[r]>d[r]?1:d[r]>c[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(s*(o-1),s*o)),{data:e,filteredTotal:a,total:i,totalPages:Math.ceil(a/s)}}function qp(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 zp(e,t){return ni(e)&&ni(t)?String(e)===String(t):e===t}function ni(e){return typeof e=="string"||typeof e=="number"}var Kp=class extends l.Disposable{_cache=new ti;_readEmitter=new l.AsyncEmitter;_saveEmitter=this.addDisposable(new Gp);_removeEmitter=this.addDisposable(new Wp);_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 l.Disposable);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new ti),o=n.addDisposable(new l.AsyncEmitter);t=this._foreignCache[e]={get:async(s,i={})=>{await r.getOrCreate(s,async()=>{try{const c=qp(await o.fire(s))||[];for(const d of c)d[e]=s,await this._cache.add(d.id,d);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const d=c[e];return d==null||zp(d,s)});return Yp(a,i)},first(s,i={}){return t.get(s,{...i,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=l.generateUUID()),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 s=o?{...o,...t}:t;if(!r)return t=o?it(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:s,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 at(e){const t=l.createIdentifier$1(e);return n=>n.getOrCreateInstance(t,()=>new Kp)}function ri(e){const t=e.getInstance(l.DISPOSABLE_ID);if(!t)throw new Error("Failed");return t}function oi(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Vt(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function Xp(e,t,n){return e&&!oi(t)&&oi(e)?{...n,meta:e.meta}:n}var Jp=l.createIdentifier$1("CurrentProject"),Qp={};function lt(e){return e?.getInstance(Jp)?.get()??Qp}function rr(e){const t=lt(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var si=at("plugin.dataSource.emails"),ii=at("plugin.dataSource.emailRevisions"),ai=Lt("plugin.readEmailAutosave"),li=l.createIdentifier$1("emailDocuments.provided");function Zp(e){const t=si(e),n=ii(e),r=n.byForeignKey("parent");if(e.getInstance(li))return{emails:t,emailRevisions:n};e.inject(li,!0);const o=()=>It(e.getInstance(l.INIT_PIPELINE_ID)?.contentReadyTimeoutMs),s=Up({emails:t,saveTimeoutMs:o}),i=new Map,a=(c,d)=>u=>{const f=u?.id??d;return(typeof f=="string"||typeof f=="number")&&i.set(String(f),c),u};return Gc(e,{...s,createEmail:c=>s.createEmail(c).then(a(Date.now())),updateEmail:(c,d)=>s.updateEmail(c,d).then(a(Date.now(),c))}),zc(e,Hp({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const d=await re(e,ai).fire(c);return d.length===0?{asked:!1}:{asked:!0,revision:d[0]??null}},savedAt:async c=>{const d=uc((await t.cache.getIfPresent(c))?.modified),u=i.get(String(c))??NaN;return Number.isFinite(u)&&!(d>=u)?u:d},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:o,integratorProject:()=>lt(e).requested})),ri(e).addDisposable(t.onSave(({prev:c,patch:d,value:u})=>Xp(c,d,u),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function ci(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 eh(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var th="po",Gt=null;function nh(){const e=typeof __emailmaker__<"u"?__emailmaker__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([th],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function rh(){return Gt===null&&(Gt=nh().catch(e=>{throw Gt=null,e})),Gt}async function di(e){if(typeof e=="object")return or(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?oh(t):sh(t)}function or(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function oh(e){try{return or(JSON.parse(e))}catch{return}}var ui=!1;async function sh(e){try{return or((await rh()).parsePoCatalog(e))}catch{ui||(ui=!0);return}}var ih="em_locale",ah="em_ant_locale",lh="locale",ch="ant_locale";function sr(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function fi(e,t){const n=sr(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function dh(){return sr("em_locale")??fi(lh,"em_locale")}function pi(e){try{localStorage.setItem(ih,JSON.stringify(e))}catch{}}function uh(){return sr("em_ant_locale")??fi(ch,"em_ant_locale")}function fh(e,t){try{localStorage.setItem(ah,JSON.stringify({id:e,data:t}))}catch{}}var G_="en_US",ph=8e3;function hh(e,t){const n=e,r=t,o=Object.keys(n).filter(s=>s!=="");return o.length!==Object.keys(r).filter(s=>s!=="").length?!1:o.every(s=>JSON.stringify(n[s])===JSON.stringify(r[s]))}function mh(e){const t=dh(),n=uh();let r={ready:!1},o;const s=ae(r);let i=0;const a=m=>{r={...r,...m},s.set(r)},c=()=>{r.ready||a({ready:!0})},d=setTimeout(c,e.unlockAfterMs??ph),u=m=>m!==i;let f;async function h(m,T){if(n?.id===m&&n.data&&a({antd:n.data}),!f)return;const P=await f(m).catch(()=>{});!P||u(T)||(a({antd:P}),fh(m,P))}async function v(m,T){const P=await e.askHost(m).catch(()=>null);if(u(T))return!0;if(P==null)return!1;const F=await di(P);return u(T)||(F&&a({catalog:F}),c()),!0}async function _(m,T){const P=await e.readList();if(u(T))return;if("error"in P){a({failure:{kind:"GET_LOCALES_ERROR",error:P.error}}),c();return}const F=P.data.find(C=>C.locale===m);if(!F){eh("em_locale")&&a({catalog:void 0}),c();return}if(ci(t,F)&&(!o||o.catalog===t?.data)){c();return}if(o?.entry&&r.catalog===o.catalog&&ci(o.entry,F)){pi(o.entry),c();return}const N=await e.readCatalog(m);if(!u(T)){if("error"in N){a({failure:{kind:"GET_LOCALE_ERROR",error:N.error}}),c();return}N.data&&(o?.id===m&&r.catalog===o.catalog&&hh(o.catalog,N.data)||a({catalog:N.data}),pi({id:m,time:F.updatedAt||Math.floor(Date.now()/1e3),hash:F.contentHash,data:N.data})),c()}}async function y(m,T){if(!await v(m,T)){if(!u(T)&&(o?.id===m&&r.catalog===o.catalog||m==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await _(m,T)}}return{set(m){if(!m||m===r.id)return;const T=i+=1;a({id:m,failure:void 0});const P=o?.id===m&&r.catalog===o.catalog;(o&&!P&&r.catalog===o.catalog||m==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===m&&t.data&&(a({catalog:t.data}),c()),h(m,T),y(m,T)},prime(m,T,P){r.id&&r.id!==m||r.catalog||!T||(o=t?.id===m&&t.data&&(!P||t.time>=P.time)?{id:m,catalog:t.data}:{id:m,catalog:T,entry:P?{id:m,time:P.time,hash:P.hash,data:T}:void 0},a({catalog:o.catalog}))},useAntdLoader(m){f=m,r.id&&h(r.id,i)},state:s,snapshot:()=>r,dispose:()=>clearTimeout(d)}}var gh=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})},vh=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:s,baseUrl:i,cancelToken:a,...c})=>{const d=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(c,d),f=o&&this.toQueryString(o),h=this.contentFormatters[r||"application/json"],v=s||u.format;return this.customFetch(`${i||this.baseUrl||""}${n}${f?`?${f}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):u.signal)||null,body:typeof e>"u"||e===null?null:h(e)}).then(async _=>{const y=_;y.data=null,y.error=null;const m=v?_.clone():_,T=v?await m[v]().then(P=>(y.ok?y.data=P:y.error=P,y)).catch(P=>(y.error=P,y)):y;return a&&this.abortControllers.delete(a),T})}},Eh=l.createIdentifier$1("rest.v2.transport"),hi=Symbol("rest.v2.secureRequest");function _h(e){return e.getOrCreateInstance(Eh,()=>{const t=e.getInstance(l.CUSTOM_FETCH_ID)?.execute||fetch;return new vh({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[hi]:!0}),customFetch:(n,r={})=>{const{[hi]:o,...s}=r;return t(n,{...s,[l.PUBLIC_REQUEST]:o!==!0})}})})}function bh(e,t){const n=_h(e);return Object.assign({},...t.map(r=>new r(n)))}function mi(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function gi(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:mi(n.details,"wp_code")??n.code,message:mi(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 vi(e){return!e.ok||!!e.error}function yh(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Ei(){return yh(l.LOCAL_STORAGE_ITEMS.em_translations_v2)??!0}function Sh(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function wh(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Ih(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:Sh(r[1])}),t},[]):[]}function Th(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:wh(n.updated_at),contentHash:n.content_hash}),t),[])}function _i(e){return bh(e,[gh])}function Wt(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function ir(e){return!e.ok||e.error!=null}function ar(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function lr(e){return{data:await di(e)??null}}async function Ch(e){if(Ei())try{const n=await _i(e).localesList();return vi(n)?{error:gi(n)}:{data:Th(n.data)}}catch(n){return Wt(n)}const t=l.getApi(e,[so]);try{const n=await t.get_translations2({file:"react_app"});return ir(n)?ar(n):{data:Ih(n.data)}}catch(n){return Wt(n)}}async function Ah(e,t){if(Ei())try{const r=await _i(e).jsonList({locale:t});return vi(r)?{error:gi(r)}:lr(r.data)}catch(r){return Wt(r)}const n=l.getApi(e,[so]);try{const r=await n.get_translations3({id:t,file:"react_app"});return ir(r)?ar(r):lr(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return ir(r)?ar(r):lr(r.data)}catch(r){return Wt(r)}}}var Yt=new WeakMap;function Dh(e){const t=Yt.get(e);if(t!==void 0)return t;const n=Ch(e).then(r=>("error"in r&&Yt.delete(e),r),r=>{throw Yt.delete(e),r});return Yt.set(e,n),n}var Ye=l.createIdentifier$1("locale.service");function Ph(e){if(e.getInstance(Ye))return;const t=mh({readList:()=>Dh(e),readCatalog:n=>Ah(e,n),askHost:async n=>(await re(e,l.events.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(l.SECURITY_MODULE_ID)});e.inject(Ye,t),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>t.dispose())}function Oh(e){const t=e.getInstance(l.CONFIG_SOURCE_ID);if(!t)return;const n=e.getInstance(Ye);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"ru_RU"));e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r)}var Rh="user_id",kh="project_id",bi=l.createIdentifier$1("rest.identityHeadersProvided");function Lh(e){if(e.getInstance(bi))return;e.inject(bi,!0);let t;e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(n=>{t=n}),e.addService(l.REQUEST_HANDLER_ID,{execute(n,r){if(r?.public)return;const o=t?.user?.id??zo(e).profile?.id;o!=null&&o!==""&&n.headers.set(Rh,String(o));const s=t?.project;s!=null&&s!==""&&n.headers.set(kh,String(s))}})}function Nh(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function Mh(e){return e.id??Nh(e.catalog)}function xh(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function Fh(e){return xh(e||"en_US")}var Bh="Accept-Language",yi=l.createIdentifier$1("rest.localeHeaderProvided");function jh(e){e.getInstance(yi)||(e.inject(yi,!0),e.addService(l.REQUEST_HANDLER_ID,{execute(t){const n=e.getInstance(Ye)?.snapshot();t.headers.set(Bh,Fh(n&&Mh(n)))}}))}function Uh(e){if(!e)return!1;try{return e.getInstance(l.SECURITY_MODULE_ID)!==void 0}catch{return!1}}var Hh="Invalid standaloneKey.",W_=l.createIdentifier$1("StandaloneMockGuard");function $h(){const e=new Error(Hh);return e.name="InvalidStandaloneKeyError",e}function Vh(e){e.addService(l.REQUEST_HANDLER_ID,{execute:()=>{if(Uh(e))throw $h()}})}function Gh(e){l.registerRestTransport(e),Vh(e)}function Wh(e){const t=new ys;e.inject(l.INIT_PIPELINE_ID,t);const n=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(o=>{if(!o)return;const s=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...s!==void 0?{signal:s}:{}})}),r=e.getInstance(l.DISPOSABLE_ID);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var Si=at("plugin.dataSource.blocks"),Yh=at("plugin.dataSource.blockRevisions"),qh=at("plugin.dataSource.comments"),zh=Lt(),Kh=Lt(),wi=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2109
+ `));return{html:_u(t.html),hasBrowserExtensionArtifacts:t.found}}function kt(e){return e?.getContent()??""}function gs(e,t){e?.mutate({content:Do(t)},{source:"remote"})}function Nt(e){return l.createIdentifier$1(e)}function re(e,t){return e.getOrCreateInstance(t,()=>new l.AsyncEmitter)}function Y(e,t){return e.getOrCreateInstance(t,()=>new l.AsyncEmitter).event}function Lt(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var bu=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 yu(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 Su(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(l.throwIfAborted(n),new Promise((r,o)=>{let s=!1,i,a;const c=u=>{s||(s=!0,i!==void 0&&(clearTimeout(i),i=void 0),a?.dispose(),n?.removeEventListener("abort",d),u())},d=()=>{c(()=>o(l.createAbortError(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&c(()=>r())}),e.isInited()&&e.getTarget()){c(()=>r());return}t>0&&(i=setTimeout(()=>{c(()=>o(new bu(t)))},t)),n?.addEventListener("abort",d)}))}var wu=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 Iu(e,t,n){return t<=0?e:new Promise((r,o)=>{let s=!1,i;const a=c=>{s||(s=!0,i!==void 0&&(clearTimeout(i),i=void 0),c())};i=setTimeout(()=>{a(()=>o(new wu(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>o(c))})})}var Tu=2,rt=Symbol("sandbox:frame-replaced");function vs(e){return e===rt}function Pe(e,t,n,r,o,s,i){const a=`sandbox:${t}`,c=s?.getSandboxTimeoutMs(t)??vn[t],d=()=>{let _=Iu(e.sendAsync(n,r),c,a);return _=l.raceWithAbortSignal(_,s?.signal),Te(a,_,o)};if(t==="INIT_START"&&yu(e)){const _=s?.getSandboxReadyTimeoutMs()??2e4,y=e,m=T=>{const D=Su(y,_,s?.signal);return Te("sandbox:INIT_START:ready-wait",D,o).then(()=>{if(!i||T<=0)return d();const B=i.getGeneration();let M;const C=new Promise((b,w)=>{M=i.onChange(()=>{i.getGeneration()!==B&&w(rt)})}),E=d();return E.catch(()=>{}),Promise.race([E,C]).finally(()=>M?.()).catch(b=>{if(b!==rt)throw b;return{...o},m(T-1)})})};return m(Tu)}if(!i)return d();const u=i.getGeneration();let f;const h=new Promise((_,y)=>{f=i.onChange(()=>{i.getGeneration()!==u&&y(rt)})}),g=d();return g.catch(()=>{}),Promise.race([g,h]).finally(()=>f?.()).catch(_=>{throw _===rt&&{...o},_})}var Cu=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Au=200;function Es(e=new Set){const t=new Set;return(n,r)=>{if(!Cu.some(([s,i])=>!e.has(s)&&i.test(n)))return;const o=r??`new:${n.length}:${n.slice(0,200)}`;t.has(o)||(t.size>=Au&&t.clear(),t.add(o))}}function _s(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Es()}}var Du=_s();function Oe(e){return e?.getInstance(l.TEMPLATE_DIRECTIVES_ID)??Du}var bs="self-init:";function Pu(e){return e.startsWith(bs)}function Bn(e,t){const n=e.getActiveShowRequest();return Pu(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Ou(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),o=()=>e.frameWatch?.();let s="",i;const a=_=>{i={target:e.readTarget?.(),docId:_}},c=()=>e.readDocument()?kt(e.readDocument()):s,d=()=>Oe(e.container).editorPolicy,u=()=>e.readEmail(),f=()=>{const _=u();return{..._,id:e.isTemplate()||_.isNew?void 0:_.id,html:c()}};let h=!1;const g={readContent:c,publicEmail:f,sendInitStart:()=>Pe(n,"INIT_START",l.EVENT_TYPES.SANDBOX_INIT_START,{guid:u().renderGuid},void 0,r()),sendInited:()=>Pe(n,"INITED",l.EVENT_TYPES.SANDBOX_INITED,{guid:u().renderGuid},void 0,r(),o()),async sendContent(){const _=u(),{html:y,hasBrowserExtensionArtifacts:m}=ms(_?.html||"");m&&e.events.browserExtensionDetected(),gs(e.readDocument(),y),s=y,a(_.renderGuid),await Pe(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,Lt(c(),_.renderGuid,d(),e.readDocument()?.get().version),{guid:_.renderGuid,emailId:_.id??null},r(),o())},refreshContent:()=>(a(u().renderGuid),Pe(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,Lt(c(),u().renderGuid,d(),e.readDocument()?.get().version),void 0,r(),o())),sendPreheader:async()=>{const _=u();if(_.preheader!==void 0)return Pe(n,"PREHEADER",l.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE,{value:_.preheader,guid:_.renderGuid,force:!0},void 0,r(),o())},sendSubject:async()=>{const _=u();if(_.subject!==void 0)return Pe(n,"SUBJECT",l.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,{value:_.subject,guid:_.renderGuid,force:!0},void 0,r(),o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:_=>e.showFilled?.(_),noteFilled:(_,y)=>e.noteFilled?.(_,y),contentSent:()=>i,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(f()),fireInit(_,y){if(!Bn(t(),_)){t().getActiveShowRequest()?.showId;return}const m=u();m.id,m.renderGuid,t().completeShow(_);const T=e.readDocument();He(T,{is_inited:!0},{source:"system"});const D=()=>{const M=f();y&&(M.reset=!0);const C=e.events.inited(M);return y||(h&&g.fireEmailChanged(),h=!0),C};if(!T||T.isReady())return D();const{docId:B}=T.get();return T.whenReady().then(()=>e.readDocument()?.get().docId===B?D():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(f())},fireContentChanged(){e.events.contentChanged(c())}};return g}var Ru=class extends Error{showId;constructor(e,t){super(`[emailmaker] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},ku=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(l.createAbortError("Superseded by newer show()")),n.aborted?Promise.reject(l.createAbortError(n.reason)):(this._activeRequest=e,new Promise((r,o)=>{const s=setTimeout(()=>{this._settle(e.showId,()=>{o(new Ru(e.showId,t))})},t);s.unref?.();const i=()=>{this._settle(e.showId,()=>{o(l.createAbortError(n.reason))})};n.addEventListener("abort",i,{once:!0});const a=()=>{clearTimeout(s),n.removeEventListener("abort",i)};this._pending.set(e.showId,{request:e,resolve:r,reject:o,timeoutId:s,dispose:a});for(const c of this._listeners)c(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Nu(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Lu(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=ho(e),n=mo(e),r=Nl(e.sandbox);t<n+r}var ys=class{_controller=new AbortController;_externalSignalDisposable=new l.Disposable;_sessionChangeListeners=new Set;_showRegistry=new ku;_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 ho(this._timeouts)}getSandboxTimeoutMs(e){return po(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return mo(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=Nu(this._timeouts,e.timeouts),Lu(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 l.Disposable,this._linkExternalSignal(e)}abort(e){const t=e??l.createAbortError("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new l.Disposable}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new l.Disposable,this._showRegistry.rejectAll(l.createAbortError("Init session replaced")),this._controller.signal.aborted||this._controller.abort(l.createAbortError("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??l.createAbortError()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??l.createAbortError()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},jn=(()=>{const e=new ys;return e.configure({}),e})();function Re(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 ke(e){return!e||e==="none"}function Mu(e){const t=e.contain??"",n=e.willChange??"";return!ke(e.transform)||!ke(e.perspective)||!ke(e.filter)||!ke(e.backdropFilter)||!ke(e.translate)||!ke(e.rotate)||!ke(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Ss(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 xu(e){const t=[],n=document.documentElement,r=Ss(getComputedStyle(n)),o=r.x||r.y;let s="none";const i=getComputedStyle(e).position;(i==="absolute"||i==="fixed")&&(s=i);for(let a=Re(e);a&&a!==n;a=Re(a)){const c=getComputedStyle(a),d=s==="none"||Mu(c)||s==="absolute"&&!!c.position&&c.position!=="static",u=a===document.body&&!o;if(d){s="none";const f=u?{x:!1,y:!1}:Ss(c);(f.x||f.y)&&t.push({node:a,...f})}(c.position==="absolute"||c.position==="fixed")&&(s==="none"||c.position==="fixed")&&(s=c.position==="fixed"?"fixed":"absolute")}return t}function ws(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 Mt(e){return Number.parseFloat(e)||0}function Un(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=ws(e),o=Mt(n.borderLeftWidth),s=Mt(n.borderTopWidth),i=Mt(n.borderRightWidth),a=Mt(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-o-i):0,d=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-s-a):0;return{left:t.left+o*r.x,top:t.top+s*r.y,right:t.right-(i+c)*r.x,bottom:t.bottom-(a+d)*r.y}}function Fu(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},o=(s,i,a)=>{i&&(r.left=Math.max(r.left,s.left),r.right=Math.min(r.right,s.right)),a&&(r.top=Math.max(r.top,s.top),r.bottom=Math.min(r.bottom,s.bottom))};return t.forEach(s=>o(Un(s.node),s.x,s.y)),n&&o(Un(n),!0,!0),r}var Hn={originX:0,originY:0,scaleX:1,scaleY:1};function xt(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 Is(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 Ts(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 Bu=1e3;function ju(e){const{slot:t,own:n}=e;let r,o=0,s=!1;const i=()=>{if(r=void 0,!s){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<o)&&(r=window.requestAnimationFrame(i))}},a=()=>{!s&&r===void 0&&(r=window.requestAnimationFrame(i))},c=()=>{o=performance.now()+Bu,a()},d=[window],u=[document.documentElement];for(let m=t;m;m=Re(m)){const T=m.getRootNode();T instanceof ShadowRoot&&!d.includes(T)&&(d.push(T),u.push(T))}const f=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];d.forEach(m=>f.forEach(([T,D])=>m.addEventListener(T,D,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const h=typeof MutationObserver=="function"?new MutationObserver(m=>{m.some(T=>!n.contains(T.target))&&a()}):void 0;u.forEach(m=>h?.observe(m,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let g;try{if(typeof ResizeObserver=="function"){const m=new ResizeObserver(a);typeof m.observe=="function"&&(g=m)}}catch{g=void 0}let _=[];return{schedule:a,observe:m=>{!g||m.length===_.length&&m.every((T,D)=>T===_[D])||(g.disconnect(),_=m,m.forEach(T=>g?.observe(T)))},dispose(){s=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),d.forEach(m=>f.forEach(([T,D])=>m.removeEventListener(T,D,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),h?.disconnect(),g?.disconnect()}}}var Uu="pluginZoom",Hu=/^(?:ant|vscode|monaco|docs)-/;function $u(e){return Hu.test(e)}function Vu(){const e="em".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var Gu=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function Yu(){return Gu}var Wu=new Set;function qu(e,t,n=Wu){return e.startsWith(`${t}-`)?!1:!$u(e)&&!n.has(e)}function Ku(e,t){return`--${t}-${e}`}function Cs(e){const t=Vu();return qu(e,t,Yu())?Ku(e,t):`--${e}`}function zu(e,t){const n=Cs(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function As(e,t){return zu(e,t)}var Ds=300,Ps=15e3,Xu=5e3,Os="em-canvas-busy-style";function Ju(){if(document.getElementById(Os))return;const e=document.createElement("style");e.id=Os,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var Qu="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 Zu(e){const t=As("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(Cs("colorPrimary")).trim()||t}function Rs(e){Ju();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",Qu),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:${Zu(e)};animation:em-canvas-busy-spin 1s linear infinite`),o.appendChild(n),o}function ef(e,t,n){const r=t??e,o=Math.max(r.left,e.left,0),s=Math.min(r.right,e.right,n.width),i=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return s<=o||a<=i?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(o+s)/2-e.left,y:(i+a)/2-e.top}}function tf(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},s=r.getBoundingClientRect();if(s.width>0&&!Ts({left:s.left,top:s.top,width:s.width,height:s.height},o)){const i=xt(o,Is(s,xt(o,Hn),Hn));Object.assign(r.style,{left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const i=ef(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${i.x}px`,top:`${i.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(Rs(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function $n(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(Rs(e))},Ds);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var nf=8e3;function rf(){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 of(e,t){for(let n=Re(e);n;n=Re(n)){const r=getComputedStyle(n),o=r.overflowX!=="visible"||r.overflowY!=="visible",s=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(i=>Ge(i)>0);if(o&&s)return n;if(n===t)return null}return null}function Ge(e){return Number.parseFloat(e)||0}function Ft(e,t){return Math.abs(e-t)<=1}function sf(e){const t=getComputedStyle(e),n=Ge(t.borderTopWidth),r=Ge(t.borderRightWidth),o=Ge(t.borderBottomWidth),s=Ge(t.borderLeftWidth),i=(a,c,d)=>Math.max(0,Ge(a)-Math.max(c,d));return{...Un(e),radii:[i(t.borderTopLeftRadius,n,s),i(t.borderTopRightRadius,n,r),i(t.borderBottomRightRadius,o,r),i(t.borderBottomLeftRadius,o,s)]}}function af(e,t){const n=Ft(t.top,e.top),r=Ft(t.bottom,e.bottom),o=Ft(t.left,e.left),s=Ft(t.right,e.right),i=[n&&o?e.radii[0]:0,n&&s?e.radii[1]:0,r&&s?e.radii[2]:0,r&&o?e.radii[3]:0];return i.every(a=>a===0)?"":i.map(a=>`${a}px`).join(" ")}function lf(e,t,n,r,o,s){const i=n.readyTimeoutMs??nf,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",As(Uu,"1"));const c=n.resolveSrc(e),d=document.createElement("iframe");d.setAttribute("sandbox",n.resolveSandbox(c)),d.setAttribute("allow","clipboard-read; clipboard-write"),d.setAttribute("title","Email content"),d.style.width="100%",d.style.border="0",d.style.display="block",d.style.minHeight="600px",d.src=c,a.appendChild(d),t.appendChild(a),n.mark?.("created"),o||n.onCreated?.(d);const u=new l.Disposable;let f=!1,h,g=!1,_,y,m,T;const D=()=>{clearTimeout(T),T=setTimeout(()=>{g||(g=!0,y?.(new Error(`[canvas] ${e}: документ не загрузился за ${i} мс`)))},i)},B=()=>f?(m=Promise.resolve(),g=!0,m):(g=!1,m=new Promise((R,H)=>{_=R,y=H}),D(),m),M=()=>{if(clearTimeout(T),f=!0,g){m=Promise.resolve();return}g=!0,n.mark?.("loaded"),_?.()};d.addEventListener("load",M),u.addDispose(()=>{clearTimeout(T),d.removeEventListener("load",M)});let C;const E=()=>{C??=n.bindResizer?.(d)},b=()=>{C?.dispose(),C=void 0};let w=null,O=null,x,A=Hn,N="",k="",P=0;const v=R=>{const H=JSON.stringify(R);return H===N?!1:(N=H,a.style.visibility=R.visibility,a.style.left=`${R.css.left}px`,a.style.top=`${R.css.top}px`,a.style.width=`${R.css.width}px`,a.style.height=`${R.css.height}px`,a.style.borderRadius=R.radius,d.style.width=R.elementWidth>0?`${R.elementWidth}px`:"100%",d.style.transform=R.shiftX!==0?`translate(${R.shiftX}px, ${R.shiftY}px)`:`translateY(${R.shiftY}px)`,!0)};let I=!1;const p=()=>{if(!w)return N="",a.style.visibility="hidden",d.removeAttribute("id"),!1;n.elementId&&(d.id=n.elementId);const R=w.getBoundingClientRect(),H=xu(w),q=O?.isConnected?O:null;x?.observe([w,d,...H.map(te=>te.node),...q?[q]:[]]);const z=Fu(R,H,q),X=Math.max(0,z.right-z.left),Xe=Math.max(0,z.bottom-z.top),yt=getComputedStyle(w).visibility==="visible",xe=X<=0||Xe<=0,Se=xe?{left:z.left,top:z.top,right:z.left,bottom:z.top}:z,L=xe?null:of(w,q??H[0]?.node??null),K=L?af(sf(L),Se):"",W=te=>v({visibility:yt&&!I?"":"hidden",css:xt(Se,te),elementWidth:R.width/te.scaleX,shiftX:(R.left-Se.left)/te.scaleX,shiftY:(R.top-Se.top)/te.scaleY,radius:K});let ce=W(A);if(!xe){const te=a.getBoundingClientRect();te.width>0&&!Ts({left:te.left,top:te.top,width:te.width,height:te.height},Se)&&(A=Is(te,xt(Se,A),A),ce=W(A)||ce)}return ce},S=()=>{if(!w)return!1;let R=p();const H=d.getBoundingClientRect().height;H>0&&H!==P&&(P=H,w.style.height=`${H/ws(w).y}px`,R=!0);const q=getComputedStyle(w).pointerEvents;return q!==k&&(k=q,a.style.pointerEvents=q),R},F=()=>{x?.dispose(),x=void 0},V=R=>{x=ju({slot:R,own:a,measure:S,onDetached:F})};let $=[];const G=(R,H)=>{if(O=H,R&&$.length>0){const q=$;$=[],q.forEach(z=>z())}if(R===w){R&&!x&&V(R),S();return}if(F(),w&&w.style.removeProperty("height"),N="",P=0,k="",w=R,!R){p(),b();return}n.onShown?.(d),V(R),S(),E()};u.addDispose(F);const j=R=>{f=!1,h=void 0,s?.(),R&&n.onReload?.(d);let H;g||m===void 0?H=B():(D(),H=m);try{d.contentWindow?.location.reload()}catch{d.src=c}return H};return{element:d,ready(){return m??B()},reload:()=>j(!0),reloadQuietly:()=>j(!1),followReload:()=>{h=void 0,s?.(),n.onReload?.(d)},moveTo(R){if(a.parentNode===R)return m??B();f=!1,h=void 0,s?.();let H;return g||m===void 0?H=B():(D(),H=m),R.appendChild(a),n.onReload?.(d),N="",x?.schedule(),H},get shown(){return w!==null},get slot(){return w},whenShown(){return w!==null?Promise.resolve():new Promise(R=>{$.push(R)})},get filled(){return h},noteFilled(R){h=R},alignTo(R,H){G(R,H??null)},hold(R){I!==R&&(I=R,p())},scrollBy(R,H){let q=R,z=H;for(let X=w?Re(w):null;X;X=Re(X)){if(Math.abs(q)<1&&Math.abs(z)<1)return;const Xe=getComputedStyle(X);if((Xe.overflowY==="auto"||Xe.overflowY==="scroll")&&X.scrollHeight>X.clientHeight){const yt=X.scrollTop,xe=X.scrollLeft;X.scrollBy({left:q,top:z,behavior:"instant"}),q-=X.scrollLeft-xe,z-=X.scrollTop-yt}}(Math.abs(q)>=1||Math.abs(z)>=1)&&window.scrollBy({left:q,top:z,behavior:"instant"})},resize(){C?.resize()},dispose(){G(null,null),b(),u.dispose(),a.remove()}}}function cf(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",o=(A,N)=>A==="email"?`email:${N??n}`:A,s=new Map;let i,a=[],c=!1,d,u,f=!1,h,g,_="shown",y=0,m,T,D;const B=A=>u!==void 0&&A.filled!==void 0&&A.filled!==u,M=()=>{m=void 0;const A=h;!f||!A||u===void 0||T===u||!B(A)||(T=u,e.onForeignDocument?.({wanted:u,filled:A.filled,role:_,heldMs:Date.now()-y}))},C=()=>{f=!1,h=void 0,g=void 0,clearTimeout(m),m=void 0},E=(A,N)=>{const k=s.get("email"),P=k?.slot??null;return A&&P&&B(A)?(A.alignTo(null),f||(f=!0,y=Date.now(),m=setTimeout(M,Xu)),_=N,h=A,!(i!==void 0||c)&&g!==A&&(g=A,e.onShown?.(A.element)),!d&&!i&&(d=$n(P)),!1):(f&&(C(),d?.remove(),d=void 0),A?.alignTo(P,k?.clip??null),!0)},b=()=>{f&&!c&&E(t.get(o("email")),"shown")},w=()=>{a.forEach(A=>clearTimeout(A)),a=[],i?.remove(),i=void 0,d?.remove(),d=void 0,(c||f)&&(c=!1,E(t.get(o("email")),"shown"))},O=(A,N,k)=>{const P=o(A,N),v=t.get(P);if(v)return v;const I=e.resolveMount();if(!I)return rf();const p=lf(A,I,e,A==="email"?N??n:void 0,k,A==="email"?()=>b():void 0);return t.set(P,p),p},x={get:A=>O(A),current:A=>O(A),peek:A=>t.get(o(A)),spare:()=>t.get(o("email",r())),ensureSpare:()=>O("email",r(),!0),promote(){const A=t.get(o("email",r()));if(!A)return;const N=t.get(o("email"));n=r(),D=void 0,E(A,"spare"),N?.alignTo(null)},alignSurface(A,N,k){const P=s.get(A);if(s.set(A,{slot:N,clip:k??null}),A==="email"&&c){d?.remove(),d=N?$n(N):void 0;return}const v=N?O(A):t.get(o(A));if(A!=="email"){v?.alignTo(N,k??null);return}if(!N){D=P?.slot&&v?.shown?{slot:P.slot,handle:v}:void 0,f&&(C(),d?.remove(),d=void 0),v?.alignTo(null);return}const I=D?.slot===N&&D.handle===v;if(D=void 0,P?.slot===N&&v?.shown||I){v?.alignTo(N,k??null);return}E(v,"shown")},want(A){u=A,A!==void 0&&b()},noteFilled(A,N){const k=x.byWindow(A);k&&(k.noteFilled(N),k===t.get(o("email"))&&b())},visible(){for(const A of t.values())if(A.shown)return A},byWindow(A){if(A){for(const N of t.values())if(N.element.contentWindow===A)return N}},busy(A){if(w(),!A)return;if(!x.visible()){c=!0,d?.remove(),d=void 0;const P=s.get("email");P?.slot&&(d=$n(P.slot)),a=[setTimeout(w,Ps)];return}const N=e.resolveMount();if(!N)return;const k=tf(N,()=>x.visible()?.element.parentElement?.getBoundingClientRect()??null);i=k,a=[setTimeout(()=>k.showSpinner(),Ds),setTimeout(w,Ps)]},remount(A){w();const N=o("email");t.forEach((k,P)=>{if(P===N){k.moveTo(A).catch(()=>{});return}k.dispose(),t.delete(P)})},dispose(){u=void 0,c=!1,C(),D=void 0,w(),t.forEach(A=>A.dispose()),t.clear(),s.clear(),n="a",u=void 0,T=void 0}};return x}var df=l.createIdentifier$1("canvas.resizerBinder"),Vn=l.createIdentifier$1("canvas.service"),uf={created:oe.canvasCreated,loaded:oe.canvasLoaded},ks=new WeakMap;function Gn(e){return ks.get(e)??0}function ff(e,t){if(e.getInstance(Vn))return;const n=cf({resolveMount:()=>t.resolveMount(),resolveSrc:o=>t.resolveSrc(o),resolveSandbox:zd,elementId:t.elementId,bindResizer:o=>e.getInstance(df)?.(o),onCreated:o=>ot(e,o,"fresh"),onReload:o=>{ks.set(o,Gn(o)+1),ot(e,o,"fresh")},onShown:o=>{const s=n.byWindow(ie(e).getTarget());s&&s.element!==o&&Ns(s.element)===Ns(o)||ot(e,o,"switch")},mark:o=>t.mark?.(uf[o]),onForeignDocument:o=>{({...o},Bl("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=ie(e).addListener(l.EVENT_TYPES.SANDBOX_WHEEL,o=>{n.visible()?.scrollBy(o?.deltaX??0,o?.deltaY??0)});e.inject(Vn,n),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),n.dispose()})}function Ns(e){return e.parentElement?.dataset.canvasHost}function ot(e,t,n){const r=ie(e),o=t.contentWindow;if(!o)return;const s=r.getTarget()===o;s&&n==="switch"||(n==="fresh"&&(r.forget(o),s&&r.setTarget(void 0)),r.setTarget(o),Od(r))}function pf(e,t){ot(e,t,"promote")}function hf(e,t){ot(e,t,"switch")}function mf(e,t){const n=t.contentWindow;n&&ie(e).greet(n)}function Ls(e,t){const n=t.contentWindow;n&&ie(e).forget(n)}function gf(e,t){const n=ne(e)?.byWindow(t)?.element;if(!n)return;const r=Gn(n);return()=>Gn(n)!==r}function ne(e){return e.getInstance(Vn)}function Ms({attributes:e,readContent:t,docId:n,hasSession:r,serverId:o,show:s}){if(!r)return;const i={id:o??void 0,renderGuid:n,showId:s?.id,isNew:o==null,showToken:s?.token},a={...e,...i};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function Bt(e){return{...Ms({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function jt(e){const t=se(e),n=t.current();if(!n||!Q(t.sessionKey()))return;const r=Bt(n),o=n.isDirty();re(e,l.events.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:o})}function vf(e){const t=se(e);return!t.current()||!Q(t.sessionKey())?!1:(jt(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function Ef(e){const t=se(e),n=ie(e),r=()=>e.getInstance(l.INIT_PIPELINE_ID)??jn;let o,s,i=!1,a=!1,c,d;const u=k=>Bt(k),f=()=>{const k=B(),P=k?.get().docId;if(!k||!P||P!==c||i)return;const v=k.get().version;v!==d&&(d=v,re(e,l.events.ON_BLOCK_CHANGED_ID).fire(u(k)))};let h;const g=k=>{const P=t.showFacts();!P||P.id===h||!Bn(k,P.id)||(h=P.id,k.completeShow(P.id))},_=async(k,P,v)=>{const I=v.generation,p=()=>v.generation!==I||v.signal.aborted||t.current()!==k||a,S=fe(n);let F;const V=new Promise(G=>{F=Ot(n,()=>G("regenerated"))}),$=async(...G)=>await Promise.race([Pe(...G).then(()=>"sent"),V])==="sent";i=!0;try{if(!await $(n,"INIT_START",l.EVENT_TYPES.SANDBOX_INIT_START,{guid:P},void 0,v)||p())return;const{html:G,hasBrowserExtensionArtifacts:j}=ms(kt(k));if(j&&re(e,l.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),gs(k,G),!await $(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,Lt(kt(k),P,Oe(e).editorPolicy,k.get().version),void 0,v)||p()||!await $(n,"INITED",l.EVENT_TYPES.SANDBOX_INITED,{guid:P},void 0,v)||p())return;o=P,s=S,M(),d=k.get().version,c!==P&&(c=P,re(e,l.events.ON_BLOCK_INIT_ID).fire(u(k))),g(v)}finally{F?.(),i=!1,fe(n)!==S&&b()}};let y,m,T;const D=()=>{const k=ne(e)?.peek("block");return k?.reload?(k.reload().catch(()=>{}),!0):!1},B=()=>Q(t.sessionKey())?t.current():void 0,M=()=>{const k=B()?.get().docId,P=!k||T===k||o===k&&s===fe(n);ne(e)?.peek("block")?.hold(!P)},C=()=>{if(a||(M(),f(),i))return;const k=B(),P=k?.get().docId;if(!k||!P)return;if(o===P&&s===fe(n)){g(r());return}if(!k.isReady())return;const v=r();v.signal.aborted||o!==void 0&&o!==P&&y!==P&&(y=P,D())||_(k,P,v).catch(()=>{if(!(a||t.current()!==k)){if(m!==P){m=P,D();return}T=P,M()}})};let E=!1;const b=()=>{E||a||(E=!0,queueMicrotask(()=>{E=!1,C()}))};let w,O;const x=()=>{const k=B(),P=k?.get().docId;P!==O&&(w?.(),O=P,w=k?.subscribe(b)),M(),b()},A=t.subscribe(x),N=Ot(n,()=>{M(),b()});x(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{a=!0,N(),w?.(),A()})}function _f(e){const t=se(e);let n="email";const r=()=>{if(!t.current())return;const s=Q(t.sessionKey())?"block":"email",i=ne(e);if(s===n||!i)return;n=s;const a=i.peek(s);if(a){hf(e,a.element);return}i.get(s)},o=t.subscribe(r);e.getInstance(l.DISPOSABLE_ID)?.addDispose(o)}var bf=200;function yf({startVersion:e,limit:t=bf}){let n=[],r=e;const o=s=>{n=n.filter(i=>i.version>s),r=Math.max(r,s)};return{record(s){!s.changes?.length&&!s.contentReplaced||(n.push(s),n.length>t&&o(n[n.length-t-1].version))},rebase(s,i){if(i<r)return null;const a=n.filter(d=>d.version>i);o(i);let c=s;for(const d of a){if(d.contentReplaced||!d.changes)return null;const u=d.changes,f=[];for(const h of c){if(d.fromCanvas&&u.some(_=>h.range.start<=_.oldEnd&&h.range.end>=_.oldPosition))return null;const g=Gl(h.range,u,"after");if(!g)return null;f.push({range:g,text:h.text})}c=f}return c}}}function Sf(e,t){let n=0;return e.map(({start:r,end:o,text:s})=>{const i=new he(r,t.slice(r,o),r+n,s);return n+=s.length-(o-r),i})}function wf(e,t){const n=[...e].sort((r,o)=>r.range.start-o.range.start);return Sf(n.map(({range:r,text:o})=>({start:r.start,end:r.end,text:o})),t)}function If(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Yn=l.createIdentifier$1("canvas.sandboxFill");function xs(e){return e.getInstance(Yn)?.pipeline.isEventsLocked()===!0}function Ut(e){Ze(e,{origin:"canvas-channel"})}function Tf(e){const t=se(e),n=ie(e);let r;const o=(c,d)=>{const u=c.get().docId;let f=!1,h=null,g=null;const _=yf({startVersion:c.get().version});let y=c.getContent(),m=!0;const T=(b,w)=>{!m||t.current()!==c||(Ze(w,{origin:"canvas-channel"}),n.sendAsync(l.EVENT_TYPES.SANDBOX_SET_ENTITY,Lt(kt(c),u,Oe(e).editorPolicy,c.get().version)).catch(Ut))},D=async(b,w)=>{if(g){g.push({edits:b,rev:w});return}g=[{edits:b,rev:w}];try{do{const O=g.splice(0,g.length);await n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:O.map(x=>x.edits),guid:u,rev:O[O.length-1].rev})}while(g.length)}catch(O){T("app edits failed to reach the canvas",O)}finally{g=null}},B=(b,w)=>{const O=g?.splice(0,g.length)??[];O.length&&n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:O.map(x=>x.edits),guid:u,rev:O[O.length-1].rev}).catch(Ut),n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:[b],guid:u,rev:c.get().version,...w!==null?{changeId:w}:{}}).catch(Ut)},M=b=>{const{guid:w,pushUndoStop:O}=b;if(w!==u)return;const x=tc(b);let{edits:A}=b;if(x.baseRev!==null){const k=_.rebase(A,x.baseRev);if(!k){Ze(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),B([],x.changeId);return}A=k}const N=c.get().version;try{f=!0,h=x.changeId;const k=wf(A,c.getContent());O===!1?d.applyWithoutHistory(k):c.mutate({changes:k},{source:xs(e)?"system":"user"})}catch(k){T("canvas batch failed to apply",k);return}finally{f=!1,h=null}c.get().version===N&&x.baseRev!==null&&B([],x.changeId)},C=c.subscribe(({changes:b,version:w})=>{const O=c.getContent(),x=!b?.length&&O!==y;if(y=O,_.record({version:w,changes:b,contentReplaced:x,fromCanvas:f}),!b?.length)return;const A=If(b);f?B(A,h):D(A,w).catch(Ut)}),E=n.addListener(l.EVENT_TYPES.APPLICATION_UPDATE_ENTITY,M);return()=>{m=!1,C(),E.dispose()}};let s;const i=()=>{const c=t.current(),d=t.history(),u=c?.get().docId;u!==s&&(r?.(),r=void 0,s=u,c&&d&&(r=o(c,d)))},a=t.subscribe(i);i(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r?.(),a()})}function Cf(e){const t=ie(e),n=()=>ne(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(l.EVENT_TYPES.RELOAD,()=>{n()?.followReload()}),o=t.addOffTargetListener(l.EVENT_TYPES.RELOAD,a=>{const c=ne(e)?.byWindow(a);c&&Ls(e,c.element)}),s=t.addListener(a=>{a.data?.operation===l.EVENT_TYPES.SANDBOX_RESIZED&&n()?.resize()}),i=Y(e,l.events.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),o.dispose(),s.dispose(),i.dispose()})}function Fs(){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 Af(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID);let n,r;e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r?.remove(),r=void 0}),ff(e,{resolveMount:()=>n,resolveSrc:s=>cs(s==="block"),elementId:"email_iframe",mark:s=>J(s)}),t?.watch(s=>{const i=s?.element;if(n&&i instanceof HTMLElement&&i!==n){n=i,ne(e)?.remount(i),r?.remove(),r=void 0;return}if(!n){if(i instanceof HTMLElement)n=i;else if(s!==void 0){n=r??=Fs(),ne(e)?.alignSurface("email",r,r);return}else return;ne(e)?.get("email")}});let o;e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{o?.remove(),o=void 0}),cd(e).watch(s=>{const i=ne(e);if(i){if(s){o??=Fs(),i.alignSurface("email",o,o);return}o&&(i.alignSurface("email",null),o.remove(),o=void 0)}})}var Wn=l.createIdentifier$1("canvas.headerFlow"),Bs=["subject","preheader"],js=3e3,Df=3,Pf={subject:l.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,preheader:l.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE};function Of(e){const t=se(e),n=ie(e),r=C=>C?"remote":xs(e)?"system":"user",o=(C,{guid:E,value:b,forced:w})=>{const O=Ue(t);if(!O||typeof b!="string"||E&&E!==O.get().docId)return;const x=t.forcedHeaders();if(x?.[C]!==void 0&&!w&&b!==x[C])return;const A=O.get().attributes[C];if(!w&&g(C,b,A))return;const N=!w&&f.delete(C);w&&(m.delete(C),m.size===0&&t.endForcedHeaders());const k=A??"";c=!0;try{He(O,{[C]:b},{source:N?"system":r(w)})}finally{c=!1}s[C]=b,re(e,l.events.ON_HEADER_APPLIED_ID).fire({field:C,value:b,forced:!!w,isGenerated:b!==k&&!!b})};let s={},i,a,c=!1,d=Promise.resolve();const u={},f=new Map,h=(C,E)=>{s[C]=E;const b={};f.set(C,b);const w=()=>{f.get(C)===b&&f.delete(C)};_(C,E,{force:!0}).then(w),setTimeout(w,js)},g=(C,E,b)=>{const w=t.showFill();if(!w||typeof b!="string")return!1;const O=u[C]?.showId===w.showId?u[C]:void 0;return E===b?(u[C]=O??{showId:w.showId,codeEdits:w.codeEdits,corrections:0},!1):O&&w.codeEdits>O.codeEdits&&E!==O.stale?!1:((!O||E===O.stale&&O.corrections<Df)&&(u[C]={showId:w.showId,stale:E,codeEdits:w.codeEdits,corrections:(O?.corrections??0)+1},h(C,b)),!0)},_=(C,E,{force:b=!1,echo:w=!1,undoStep:O=!1})=>(d=n.sendAsync(Pf[C],{value:E,guid:Ue(t)?.get().docId,...b?{force:!0}:{},...w?{echo:!0}:{},...O?{undoStep:!0}:{}}).catch(x=>{}),d);let y;const m=new Set;e.inject(Wn,{whenDelivered:async()=>{await d},reassert:C=>{const E=Ue(t),b=Bs.filter(w=>typeof C[w]=="string");if(!(!E||b.length===0)){c=!0;try{He(E,Object.fromEntries(b.map(w=>[w,C[w]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders(Object.fromEntries(b.map(w=>[w,C[w]]))),clearTimeout(y),y=setTimeout(()=>{m.clear(),t.endForcedHeaders()},js),m.clear();for(const w of b)m.add(w);for(const w of b)s[w]=C[w],_(w,C[w],{force:!0,echo:!0})}}});const T=()=>{i?.(),i=void 0;const C=Ue(t);if(C!==a&&f.clear(),a=C,!C){s={};return}const E=C.get().attributes;s={subject:E.subject,preheader:E.preheader},i=C.subscribe(({source:b})=>{if(c)return;const w=C.get().attributes,O=t.forcedHeaders();for(const x of Bs){const A=w[x];if(A===s[x])continue;s[x]=A,f.delete(x);const N=b==="system"&&O?.[x]!==void 0;_(x,A??"",{force:N,echo:N,undoStep:b==="user"})}})};T();const D=t.subscribe(T),B=n.addListenerAsync(l.EVENT_TYPES.APPLICATION_SUBJECT_UPDATE,C=>o("subject",C)),M=n.addListenerAsync(l.EVENT_TYPES.APPLICATION_PREHEADER_UPDATE,C=>o("preheader",C));e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{B.dispose(),M.dispose(),D(),i?.(),clearTimeout(y)})}function Rf(e){const t=se(e);let n={document:void 0,seq:0};const r=()=>{const s=t.recoveryFacts(),i=Ue(t);if(!s?.applied||!i||String(s.emailId)!==String(i.get().serverId)||(n.document!==i&&(n={document:i,seq:0}),s.applied.seq<=n.seq))return;n={document:i,seq:s.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(Wn)?.reassert(a)},o=t.subscribe(r);e.getInstance(l.DISPOSABLE_ID)?.addDispose(o)}function kf(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?l.DARK:l.LIGHT}function Nf(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 Lf(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Us(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function qn(e,t){const n={...e};for(const r of Object.keys(t)){const o=t[r],s=e[r];Us(o)&&Us(s)?n[r]=qn(s,o):o!==void 0&&(n[r]=o)}return n}function Mf(e,t){const n=l.COMMON_STYLES;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 qn(n,o)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?qn(n,t):n}var xf=ae(void 0),Hs=xf,$s=l.createIdentifier$1("CodeMode");function Vs(){let e;try{const t=window.localStorage?.getItem(l.LOCAL_STORAGE_ITEMS.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 Ff(e){try{window.localStorage?.setItem(l.LOCAL_STORAGE_ITEMS.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function Kn(e){return e.getOrCreateInstance($s,()=>{const t=ae(Vs());return t.watch(Ff),t})}function Gs(e){return e?.getInstance($s)?.get()??Vs()}function zn(e,t){const n=Kn(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function Bf(e,t){const n=Kn(e);n.set({...n.get(),direction:t})}var jf=l.createIdentifier$1("DefaultCommonStyles");function Ys(e){return e.getOrCreateInstance(jf,()=>ae(void 0))}function Uf(e,t){Ys(e).set(t)}var Hf=l.createIdentifier$1("CanvasViewport"),$f=l.createIdentifier$1("CanvasPreviewPage");function be(e,t,n){let r,o;const s=()=>{if(!r||!e.isInited())return;const c=r.value===void 0?"undefined":JSON.stringify(r.value);c!==o&&(o=c,e.send(t,r.value))},i=n.watch(c=>{r={value:c},s()}),a=e.onInit(()=>{o=void 0,s()});return{dispose(){i.dispose(),a.dispose()}}}function Ht(e){const t=ae(e());return{source:t,refresh:()=>t.set(e())}}function Vf(e){const t=ie(e),n=e.getInstance(l.CONFIG_SOURCE_ID),r=e.getInstance(l.OPTIONS_SOURCE_ID),o=se(e),s=Kn(e),i=matchMedia(l.PREFERS_COLOR_SCHEME_DARK),a=()=>n?.get()??{};let c;const d=Ht(()=>kf(Hs.get()??a().theme,i.matches)),u=Ht(()=>Nf(a(),Q(o.sessionKey()))),f=Ht(()=>a().lockEditor),h=Ht(()=>Mf(o.current()?.get().attributes?.common_styles,c)),g=e.getOrCreateInstance(Hf,()=>ae()),_=e.getOrCreateInstance($f,()=>ae()),y=[be(t,l.CANVAS_FACTS.theme,d.source),be(t,l.CANVAS_FACTS.flags,u.source),be(t,l.CANVAS_FACTS.lockEditor,f.source),be(t,l.CANVAS_FACTS.commonStyles,h.source),be(t,l.CANVAS_FACTS.codeMode,s.select(Lf)),be(t,l.CANVAS_FACTS.appName,ae("emailmaker")),be(t,l.CANVAS_FACTS.previewPage,_),be(t,l.CANVAS_FACTS.viewport,g)],m=()=>{d.refresh(),u.refresh(),f.refresh()},T=n?.watch(m),D=Ys(e).watch(O=>{c=O,h.refresh()}),B=r?.watch(O=>{O&&"commonStyles"in O&&(c=O.commonStyles),h.refresh()});let M;const C=()=>{M?.(),M=o.current()?.subscribe(()=>h.refresh()),h.refresh(),u.refresh()};C();const E=o.subscribe(C),b=()=>d.refresh();i.addEventListener("change",b);const w=Hs.watch(()=>d.refresh());e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{y.forEach(O=>O.dispose()),T?.dispose(),D.dispose(),B?.dispose(),M?.(),E(),i.removeEventListener("change",b),w.dispose()})}var Xn;(function(e){function t(o,s,i=(a,c)=>a===c){if(o===s)return!0;if(o.length!==s.length)return!1;for(let a=0;a<o.length;a++)if(!i(o[a],s[a]))return!1;return!0}e.isEqual=t;function n(o,s=i=>i){const i=new Set;return o.filter(a=>{const c=s(a);return i.has(c)?!1:(i.add(c),!0)})}e.unique=n;function r(o=[],s=[],i=(a,c)=>a===c){const a=[],c=[],d=[];for(const u of o){const f=s.find(h=>i(u,h));f?d.push({prev:u,next:f}):c.push(u)}for(const u of s)o.find(f=>i(u,f))||a.push(u);return{added:a,removed:c,exists:d}}e.diff=r})(Xn||(Xn={}));function Gf(e,t){return e.type===t.type&&e.key===t.key}function Yf(e){const t=ie(e),n=()=>e.getServices(l.SANDBOX_EXTENSIONS_ID)??[];let r=[];const o=t.onInit(()=>{r=n(),t.send(l.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,r)}),s=l.getServiceContainerId(l.SANDBOX_EXTENSIONS_ID),i=e.onInject(a=>{if(a!==s)return;const c=n();if(!t.isInited()){r=c;return}const{added:d,removed:u}=Xn.diff(r,c,Gf);if(r=c,u.length){if(u.some(f=>f.type==="script")){t.send(l.EVENT_TYPES.RELOAD);return}t.send(l.EVENT_TYPES.SANDBOX_REMOVE_EXTENSIONS,u.map(f=>f.key))}d.length&&t.send(l.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,d)});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{o.dispose(),i?.dispose()})}var Wf=new Set([...Object.values(l.EVENT_TYPES).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(l.SANDBOX_EXTENSION_SCRIPT_STATUS_ID)]);function qf(e){return e.length>0&&!e.startsWith("em:")&&!Wf.has(e)}function Kf(e){const t=ie(e),n=new Map;let r=!1,o=-1,s=new Set;const i=d=>(d!==o&&(o=d,s=new Set),s),a=t.observeOutgoing((d,u)=>{if(!r||!qf(d))return;const f=fe(t);n.set(d,{data:u,generation:f,scripts:new Set(i(f))})}),c=t.addListener(l.SANDBOX_EXTENSION_SCRIPT_STATUS_ID,d=>{if(d.phase!=="ready"||d.status!=="success")return;r=!0;const u=fe(t),f=i(u);f.add(d.key);for(const[h,g]of n)g.generation===u||![...g.scripts].every(_=>f.has(_))||(g.generation=u,t.send(l.createIdentifier(h),g.data))});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{a.dispose(),c.dispose()})}var zf=l.createIdentifier$1("prewarm.editorVisible");function Xf(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Jf(e={}){const t=e.paint??Xf;let n=!1,r=!1,o=!1,s=!1,i=!1;const a=[],c=()=>{i||s||!n||!r||!o||(s=!0,t(()=>{i=!0,J(oe.editorVisible);for(const d of a.splice(0))d()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){o=!0,c()},whenVisible(d){if(i){d();return}a.push(d)},contentShown:()=>o}}function Qf(e){return e.getOrCreateInstance(zf,()=>Jf())}var Zf=500,ep=500,tp=5e3;function np(e){const t=e.quietMs??Zf,n=e.floorMs??ep,r=e.ceilingMs??tp;let o,s,i=0;const a=()=>{clearTimeout(o),clearTimeout(s),o=void 0,s=void 0},c=()=>{a(),e.run()},d=()=>{clearTimeout(o);const u=n-(Date.now()-i);o=setTimeout(c,Math.max(t,u))};return{start(){a(),i=Date.now(),s=setTimeout(c,r),d()},notify(){o!==void 0&&d()},cancel:a}}var rp=2;function Ws(){return new Error("[sandbox] document reloaded during fill")}function op(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Jn(e){try{e()}catch{}}function sp(e){let t;return Jn(()=>{t=e()}),{stage:n=>Jn(()=>t?.stage(n)),end:(n,r)=>Jn(()=>t?.end(n,r))}}function ip(e){const t=()=>e.initPipeline();let n=!1,r,o,s,i=0,a,c;const d=()=>{const E=e.readTarget?.(),b=e.readSandboxGeneration?.();return E===void 0||b===void 0?void 0:{target:E,generation:b}},u=()=>{const E=d();return E&&{...E,canvasReplaced:e.trackDocument?.(E.target)}},f=E=>{if(E?.canvasReplaced?.())return!0;const b=d();return E!==void 0&&b?.target===E.target&&b.generation!==E.generation},g=Ou({...e,waitScope:()=>({getSandboxTimeoutMs:E=>t().getSandboxTimeoutMs(E),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const E=c;if(!(!E||!e.onSandboxGenerationChange))return{getGeneration:()=>d()?.generation??E.generation,onChange:b=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===E.target||E.canvasReplaced?.())&&b()})??(()=>{})}}});let _;const y=(E,b)=>{if(_===E)return;_=E;const w=i;setTimeout(()=>{i!==w||t().signal.aborted||B(E,b).catch(()=>{})},0)},m=()=>{a?.abort(),a=void 0};let T;const D=()=>{const E=t().signal;E!==T&&(T?.removeEventListener("abort",m),T=E,E.addEventListener("abort",m))};async function B(E,b,w=0){const O=++i;m(),a=new AbortController,c=void 0,D();const x=()=>i!==O,A=g.readTarget(),N=t().generation,k=()=>N===t().generation&&!t().signal.aborted,P=b?"init:reset-":"init:",v=sp(()=>e.observeShow?.(op(E,b,e.readEmail())));if(!b){const G=g.publicEmail();G?.id,G?.renderGuid,G?.preheader}let I=!1,p=!1,S,F=!1;const V=()=>{if(f(S))throw Ws()},$=()=>{if(x())throw l.createAbortError("Fill superseded")};try{n=!0,await g.sendInitStart(),$(),S=u(),c=S,w===0&&g.fireWillInit(),await(b||w>0?g.refreshContent():g.sendContent()),I=!0,$(),V();const G=g.contentSent();g.noteFilled(G?.target,G?.docId),v.stage("content"),b||g.publicEmail()?.id;try{await g.sendPreheader()}catch(j){if(vs(j)||x())throw j;`${P}`,String(j)}$();try{await g.sendSubject()}catch(j){if(vs(j)||x())throw j;`${P}`,String(j)}if($(),V(),g.showFilled(A),await g.sendInited(),$(),V(),p=!0,o===E){const j=e.readSandboxGeneration?.()??s;j!==void 0&&(r=j)}v.stage("reveal"),await g.revealFilled(),V(),v.end("revealed")}catch(G){const j=!x()&&k()&&f(S),R=j?Ws():void 0,H=R??G,q=j&&w<rp?C(E,b,w+1):void 0;F=j&&q===void 0;const z=x()?void 0:{showId:E,contentApplied:I,sandboxInitedAcked:p,superseded:!1,...e.describeSurface?.(),error:String(R??G)};z&&(`${P}`,void 0);const X=!x()&&e.recoverFailedFill?.(A)===!0;if(v.end(x()?"superseded":X?"recovered":l.isAbortError(H)||!k()?"aborted":"failed",z),!X&&!x()&&Bn(t(),E)&&t().failShow(E,H),q!==void 0)return q;throw H}finally{M(E,b,P,{superseded:x(),sessionGeneration:N,contentApplied:I,sandboxInitedAcked:p&&!F,retry:!F,commit:k()})}}function M(E,b,w,O){const{superseded:x,contentApplied:A,sandboxInitedAcked:N}=O;if(x){`${w}`;return}N&&O.commit?g.fireInit(E,b||void 0):N?(`${w}`,O.sessionGeneration,t().generation,t().signal.aborted,void 0):A?(`${w}`,void 0):(`${w}`,void 0),n=!1,a=void 0,!N&&o===E&&(o=void 0,r===s&&(r=void 0)),!N&&A&&O.retry&&y(E,b)}function C(E,b,w){return B(E,b,w)}return{channel:g,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:E=>{r=E},lastCorrelation:()=>o,markCorrelation:E=>{o=E},bumpRunSeq:()=>{i+=1},noteSandboxGeneration:E=>{s=E},fill:E=>B(E,!1),refill:E=>B(E,!0),stop:()=>{i+=1,m(),n=!1,T?.removeEventListener("abort",m),T=void 0}}}function ap(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:qs(e,n)}function qs(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function lp(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:o,readSandboxGeneration:s}=e,i=u=>{const f=n(),h=o();if(!ap(f,u,h)){u.showId,u.navId,u.emailId,f?.id,f?.showId,f?.renderGuid;return}u.showId,f?.id,f?.renderGuid,t.markFilled(s()),t.markCorrelation(u.showId),t.fill(u.showId).catch(()=>{})};return{showRequested:u=>{i(u)},showRequestIdentityChanged:()=>{const u=e.initPipeline().getActiveShowRequest();u&&i(u)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const u=s();if(t.filledGeneration()===u)return;const f=n(),h=o();if(!f?.renderGuid||!qs(f,h))return;const g=`${bs}${f.renderGuid}`;t.markFilled(u),t.markCorrelation(g);const _=r()?.isReady()===!0;f.id,f.renderGuid,(_?y=>t.refill(y):y=>t.fill(y))(g).catch(()=>{t.lastCorrelation()===g&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id,r()}}}var cp=l.createIdentifier$1("canvas.health");function dp(e){return e??""}function up(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Ks(e){return e.length>0}function fp(e){const t=se(e),n=ie(e),r=()=>Q(t.sessionKey())?void 0:t.current(),o=()=>{const L=r();return Ms({attributes:L?.get().attributes??{},readContent:()=>L?.getContent(),docId:L?.get().docId,hasSession:!!L,serverId:L?.get().serverId,show:t.showFacts()})},s=()=>e.getInstance(l.INIT_PIPELINE_ID)??jn;let i={},a=!1;const c=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(L=>{a=!!L?.element});let d=!1,u=!1,f=!1,h=0;const g=()=>{const L=ne(e);if(!L)return;const K=++h,W=L.spare();return W&&Ls(e,W.element),(W?W.reloadQuietly():L.ensureSpare()?.ready())?.then(()=>{if(K!==h)return;d=!0;const ce=L.spare();ce&&mf(e,ce.element),f&&(f=!1,N(),j())})},_=np({run:()=>{f||g()?.catch(()=>{})}}),y=()=>{Qf(e).noteContentShown(),!d&&!f&&_.start()};let m=!1;const T=L=>{const K=ne(e),W=K?.spare()?.element.contentWindow;u&&K&&W&&L===W&&(u=!1,K.promote(),K.busy(!1),m=!0)};let D=!1;const C=ip({container:e,messageService:n,initPipeline:s,readDocument:r,readEmail:o,revealFilled:()=>{const L=ne(e);return m&&L&&(m=!1,_.start()),a?L?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:T,noteFilled:(L,K)=>ne(e)?.noteFilled(L,K),recoverFailedFill:L=>{const K=ne(e),W=K?.spare()?.element.contentWindow;return!u||!K||!W||L!==W?!1:(u=!1,d=!1,x="reload",K.busy(!1),K.peek("email")?.reload(),D=!0,j(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!i.isTemplate,readSandboxGeneration:()=>fe(n),onSandboxGenerationChange:L=>Ot(n,L),trackDocument:L=>gf(e,L),observeShow:L=>e.getInstance(cp)?.begin(L),describeSurface:()=>({canvasPath:x,promoted:u,spareClean:d,handshake:n.isInited(),generation:fe(n)}),events:{willInit:L=>{re(e,l.events.WILL_EMAIL_INIT_ID).fire(L)},inited:L=>{y(),re(e,l.events.ON_EMAIL_INIT_ID).fire(L)},contentChanged:L=>{re(e,l.events.ON_CONTENT_CHANGED_ID).fire(L)},emailChanged:L=>{re(e,l.events.ON_EMAIL_CHANGED_ID).fire(L)},browserExtensionDetected:()=>{re(e,l.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),E=lp({pipeline:C,initPipeline:s,readEmail:o,readDocument:r,readRouteEmailId:()=>i.emailId,readSandboxGeneration:()=>fe(n)});let b="",w="",O="",x="none";const A=()=>{const L=ne(e)?.spare()?.element.contentWindow;L&&n.getTarget()===L||n.sendNow({operation:l.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!0})},N=()=>{const L=ne(e)?.spare();L&&(A(),d=!1,u=!0,pf(e,L.element))},k=(L,K)=>{const W=ne(e);if(!W)return!0;const ce=W.spare(),te=ce&&d?"spare":"prepare";if(x=te,W.busy(!0),ce&&d)return N(),!0;_.cancel(),A();const Fe=g();if(Fe===void 0)return x="reload",W.busy(!1),W.peek("email")?.reload(),!0;f=!0;const we=h;return Fe.catch(()=>{!f||we!==h||(f=!1,x="reload",W.busy(!1),W.peek("email")?.reload())}),!1},P=()=>{if(Q(t.sessionKey()))return;Xe(),C.noteSandboxGeneration(fe(n));const L=o(),K=up(L?.renderGuid,L?.showId,L?.id,i.emailId),W=dp(L?.renderGuid);if(W!==w){const Fe=w;w=W;const we=ne(e)?.peek("email")?.filled,P_=we!==void 0&&we!==W;Ks(W)&&(Ks(Fe)||P_)&&k(Fe||(we??""),W)}if(f)return;(K!==b||D)&&(D=!1,b=K,E.showRequestIdentityChanged());const ce=r(),te=`${K}|${ce?.get().docId??""}|${fe(n)}`;te!==O&&ce?.isReady()===!0&&(O=te,E.selfInitChanged()),E.saasChanged(),$()};let v=!1,I="",p="",S=!1,F=!1;const V=L=>{L.source==="user"?F=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(S=!0),j()},$=()=>{const L=o();if(!L?.renderGuid)return;const K=C.channel.readContent(),W=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??""]),ce=v&&K!==p,te=v&&W!==I;v=!0,p=K,I=W;const Fe=S&&!F;if(S=!1,F=!1,C.isEventsLocked()||Fe)return;const we={...L,id:i.isTemplate||L.isNew?void 0:L.id,html:K};if(ce){re(e,l.events.ON_CONTENT_CHANGED_ID).fire(K),re(e,l.events.ON_EMAIL_CHANGED_ID).fire(we);return}te&&L.is_inited&&re(e,l.events.ON_EMAIL_CHANGED_ID).fire(we)};let G=!1;const j=()=>{G||(G=!0,queueMicrotask(()=>{G=!1,P()}))};e.inject(Yn,{pipeline:C,setRoute:L=>{L.emailId===i.emailId&&!!L.isTemplate==!!i.isTemplate||(i=L,j())}});let R,H;const q=()=>{const L=r()?.get().docId;L!==H&&(R?.(),H=L,R=r()?.subscribe(V)),j()};let z,X;const Xe=()=>{const L=e.getInstance(l.INIT_PIPELINE_ID);!L||L===z||(X?.(),z=L,X=L.onShowRequested(K=>E.showRequested(K)))},yt=n.addListener(L=>{L.data?.operation===l.EVENT_TYPES.SANDBOX_RESIZED&&_.notify()}),xe=t.subscribe(q),Se=Ot(n,j);q(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{c?.dispose(),X?.(),Se(),xe(),R?.(),yt.dispose(),_.cancel(),C.stop()})}function pp(){return l.USEBLOCKS!=="emailmaker"}var hp={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},zs={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}},Xs=zs,mp=["pro"],Qn={};function gp(e){Qn=e}var Js=e=>mp.includes(e)?Xs:Qn[e]??Qn.editor??Xs,Zn={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},vp={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},Ep={...Zn,config:{...Zn.config,imageCenterFileManagerView:!1}};gp({pro:zs,editor:vp,simple:pp()?Zn:Ep,blocks:hp});function _p(e,t,n=e.getInstance(l.CONFIG_SOURCE_ID)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Gs(e).isCodeMode&&zn(e,!1)}function bp(e){e.getInstance(l.STANDALONE_ACTIVATED_ID)||e.inject(l.SECURITY_MODULE_ID,void 0)}function $t(e){return String(e.standaloneKey||"").trim()||void 0}function yp(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function er(e){return yp(e)?!!$t(e):!1}function st(e){return!!$t(e)&&!er(e)}var Sp=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Qs(e){return e==="server"?"serverSide":e}function wp({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},o=ae();let s={kind:"pending"},i;const a=new Promise(h=>{i=h}),c=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function d(){s.kind!=="pending"&&o.set(Rn(r,e))}function u(h){if(s.kind!=="pending")return;clearTimeout(c),s=h;const g=Rn(r,e);o.set(g),i(g)}function f(h,g){r[Qs(h)]=g,h==="server"&&s.kind==="pending"?u({kind:"applied"}):d()}return{watch:h=>o.watch(h),select:h=>o.select(h),get:()=>o.get(),ready:()=>a,state:()=>s,layers:()=>({...r}),bootstrap(){const h=Rn(r,e);return Object.fromEntries(Sp.map(g=>[g,h[g]]))},merge(h,g){f(g,{...r[Qs(g)],...h})},replace(h,g){f(g,h)},setMode(h){r.user={...r.user,mode:h},d()},setAdvancedConfigs(h){r.advancedConfigs=h,d()},serverAbsent(h){u({kind:"absent",reason:h})},applyServerResponse(h){s.kind==="pending"&&f("server",{...r.serverSide,...h})},dispose(){clearTimeout(c)}}}var Ip=5e3,$_="pro";function Tp(){return{...Js("pro")?.config,mergeTags:void 0}}function Cp(e,t){e.getInstance(l.OPTIONS_SOURCE_ID)?.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 Ap(e,t){let n;On(e).watch(({profile:r})=>{const o=`${r?.theme??""}|${r?.locale??""}`;if(o===n)return;n=o;const s={};r?.theme&&(s.theme=r.theme),r?.locale&&(s.locale=r.locale),t.replace(s,"profile")})}function Dp(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Pp(e,t){let n,r=!1,o;const s=a=>{o??=Pt(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&_p(e,a,t)},i=On(e).watch(({profile:a})=>{const c=a?.email_builder_config,d=Dp(c);if(d===void 0||c===n)return;const u=n===void 0;n=c,!(u&&r)&&s(d)});e.getInstance(l.DISPOSABLE_ID)?.addDisposable(i),t.ready().then(a=>{if(!a.configSwither)return;const c=localStorage.getItem("configSwither")||(n===void 0?a.mode:o)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,s(c)})}var Zs="замкнутый контур: app_init не выполняется";function Op(e,t){if(e.getInstance(l.SECURITY_MODULE_ID)){t.serverAbsent(Zs);return}const n=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(r=>{st(r)&&t.serverAbsent(Zs)});n&&e.getInstance(l.DISPOSABLE_ID)?.addDisposable(n)}async function Rp(e,t){if(e.getInstance(mn)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(l.APP_ID);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function kp(e){e.injectFactory(l.CONFIG_SOURCE_ID,(t,n)=>{if(n)return n;const r=wp({base:Tp(),env:{modeDefaults:o=>Js(o)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Ip});return Cp(e,r),Ap(e,r),Pp(e,r),Op(e,r),Rp(e,r),e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var Ye=class extends l.Disposable{_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=l.snapshot(e);return(o,s,i)=>{const a=r(async c=>{const d=t?t(c):c;i&&o.bind(i);const u=await o(d);return n?n(u):u},s,i);return()=>a.dispose()}}var Np=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new l.Emitter;this.handleDestroy=U(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Ye(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{}}},tr=l.createIdentifier$1("DestroyableService");function Lp(e){e.injectFactory(tr,(t,n)=>{if(n)return n;const r=e.getInstance(l.DISPOSABLE_ID);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Np({lifetime:r,options:e.getInstance(l.OPTIONS_SOURCE_ID),getInstance:()=>e.getInstance(l.INSTANCE_ID),release:()=>l.releaseContainer(e.getInstance(l.STORE_ID)??e)})},!0)}function Mp(e){const t=e.getInstance(tr);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var xp=1e3;function ei(e,t,n=xp,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),s=Object.keys(t);if(o.length!==s.length)return!1;for(const i of o)if(!ei(e[i],t[i],n,r+1))return!1;return!0}return!1}function it(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],s=e[r];ei(o,s)||(n[r]=o)}return n}var Fp=({source:e,emailtags:t,group:n,tags:r,...o})=>o;async function Bp(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function jp({emails:e,saveTimeoutMs:t},n,r){const o=t?.()??It();let s;try{const i=e.notifySave(n);return await Promise.race([i,new Promise((a,c)=>{s=setTimeout(()=>{const d=new Ct(o);n.value.id,sc(d,Bp(i,r)),c(d)},o)})])}catch(i){throw To(i),i}finally{s!==void 0&&clearTimeout(s)}}function Up(e){const{emails:t}=e,n=async(r,o)=>{const s=Fp(o),i=r===void 0?void 0:await t.cache.getIfPresent(r),a=i?{...i,...s}:s,c=i?it(i,s):s,d=u=>{const f=String(u.id??r??l.generateUUID()),h=u.id===void 0?{...u,id:f}:u;return t.cache.addOrUpdate(f,()=>h)};return await d(await jp(e,{prev:i,patch:c,value:a,source:o.source??""},d))};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:l.generateUUID()}},async updateEmail(r,o){return await n(r,o)}}}var nr=20;function Hp(e){const t=$p(e);return e.saveTimeoutMs?Vp(t,e.saveTimeoutMs):t}function $p({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:o,integratorProject:s}){const i=async(a,c)=>(t.clear(),await t.get(a,{page:c}),(await e.cache.values()??[]).filter(d=>String(d?.parent)===String(a)));return{async readRevisions(a,c=1){const d=await i(a,c);return{revisions:d.slice(nr*(c-1),nr*c),page:c,hasMore:d.length>nr*c}},async readAutosave(a){const c=await r?.(a)??NaN,d=Number.isFinite(c)?c:void 0,u=await n?.(a);if(!u?.asked)return pc(await i(a,1),d);if(!u.revision)return Ao([],d);const f={...u.revision,parent:a,isAutosave:!0};return Ao([f],d,await i(a,1))},async saveAutosave(a,c){const d=await o?.(a),u=s?.();return await e.create({..._c(c),...d!==void 0?{author:d}:{},...u!==void 0?{project:u}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Vp(e,t){return{...e,async saveAutosave(n,r){const o=t();let s;try{return await Promise.race([e.saveAutosave(n,r),new Promise((i,a)=>{s=setTimeout(()=>a(new yo(o)),o)})])}catch(i){throw To(i),i}finally{s!==void 0&&clearTimeout(s)}}}}var Gp=class extends l.BaseEmitter{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}},Yp=class extends l.AsyncEmitter{};function V_(e){return e}var ti=class extends l.Disposable{_items=new Map;_onChangeEmitter=new l.Signal;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 l.deepEqual(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,s])=>o)),r=(await this.entries()).filter(([o,s])=>!n.has(o));for(const[o,s]of e)t.push(this.addOrUpdate(o,()=>s)),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 Wp(e,{filter:t,order:n="asc",orderBy:r,page:o,pageSize:s=20}={}){const i=e.length;let a=e.length;if(t!==void 0){const c=Object.keys(t);e=e.filter(d=>{for(const u of c){const f=d[u],h=t[u];return u==="id"||typeof f!="string"?f===h:typeof h=="string"&&f.startsWith(h)}return!0}),a=e.length}return r&&(e=e.sort((c,d)=>(c[r]>d[r]?1:d[r]>c[r]?-1:0)*(n==="asc"?1:-1))),o!==void 0&&(e=e.slice(s*(o-1),s*o)),{data:e,filteredTotal:a,total:i,totalPages:Math.ceil(a/s)}}function qp(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 Kp(e,t){return ni(e)&&ni(t)?String(e)===String(t):e===t}function ni(e){return typeof e=="string"||typeof e=="number"}var zp=class extends l.Disposable{_cache=new ti;_readEmitter=new l.AsyncEmitter;_saveEmitter=this.addDisposable(new Gp);_removeEmitter=this.addDisposable(new Yp);_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 l.Disposable);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new ti),o=n.addDisposable(new l.AsyncEmitter);t=this._foreignCache[e]={get:async(s,i={})=>{await r.getOrCreate(s,async()=>{try{const c=qp(await o.fire(s))||[];for(const d of c)d[e]=s,await this._cache.add(d.id,d);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const d=c[e];return d==null||Kp(d,s)});return Wp(a,i)},first(s,i={}){return t.get(s,{...i,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=l.generateUUID()),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 s=o?{...o,...t}:t;if(!r)return t=o?it(o,t):t,await this._saveEmitter.fire({prev:o,patch:t,value:s,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 at(e){const t=l.createIdentifier$1(e);return n=>n.getOrCreateInstance(t,()=>new zp)}function ri(e){const t=e.getInstance(l.DISPOSABLE_ID);if(!t)throw new Error("Failed");return t}function oi(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function Vt(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function Xp(e,t,n){return e&&!oi(t)&&oi(e)?{...n,meta:e.meta}:n}var Jp=l.createIdentifier$1("CurrentProject"),Qp={};function lt(e){return e?.getInstance(Jp)?.get()??Qp}function rr(e){const t=lt(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var si=at("plugin.dataSource.emails"),ii=at("plugin.dataSource.emailRevisions"),ai=Nt("plugin.readEmailAutosave"),li=l.createIdentifier$1("emailDocuments.provided");function Zp(e){const t=si(e),n=ii(e),r=n.byForeignKey("parent");if(e.getInstance(li))return{emails:t,emailRevisions:n};e.inject(li,!0);const o=()=>It(e.getInstance(l.INIT_PIPELINE_ID)?.contentReadyTimeoutMs),s=Up({emails:t,saveTimeoutMs:o}),i=new Map,a=(c,d)=>u=>{const f=u?.id??d;return(typeof f=="string"||typeof f=="number")&&i.set(String(f),c),u};return Gc(e,{...s,createEmail:c=>s.createEmail(c).then(a(Date.now())),updateEmail:(c,d)=>s.updateEmail(c,d).then(a(Date.now(),c))}),Kc(e,Hp({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const d=await re(e,ai).fire(c);return d.length===0?{asked:!1}:{asked:!0,revision:d[0]??null}},savedAt:async c=>{const d=uc((await t.cache.getIfPresent(c))?.modified),u=i.get(String(c))??NaN;return Number.isFinite(u)&&!(d>=u)?u:d},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:o,integratorProject:()=>lt(e).requested})),ri(e).addDisposable(t.onSave(({prev:c,patch:d,value:u})=>Xp(c,d,u),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function ci(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 eh(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var th="po",Gt=null;function nh(){const e=typeof __emailmaker__<"u"?__emailmaker__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([th],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function rh(){return Gt===null&&(Gt=nh().catch(e=>{throw Gt=null,e})),Gt}async function di(e){if(typeof e=="object")return or(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?oh(t):sh(t)}function or(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function oh(e){try{return or(JSON.parse(e))}catch{return}}var ui=!1;async function sh(e){try{return or((await rh()).parsePoCatalog(e))}catch{ui||(ui=!0);return}}var ih="em_locale",ah="em_ant_locale",lh="locale",ch="ant_locale";function sr(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function fi(e,t){const n=sr(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function dh(){return sr("em_locale")??fi(lh,"em_locale")}function pi(e){try{localStorage.setItem(ih,JSON.stringify(e))}catch{}}function uh(){return sr("em_ant_locale")??fi(ch,"em_ant_locale")}function fh(e,t){try{localStorage.setItem(ah,JSON.stringify({id:e,data:t}))}catch{}}var G_="en_US",ph=8e3;function hh(e,t){const n=e,r=t,o=Object.keys(n).filter(s=>s!=="");return o.length!==Object.keys(r).filter(s=>s!=="").length?!1:o.every(s=>JSON.stringify(n[s])===JSON.stringify(r[s]))}function mh(e){const t=dh(),n=uh();let r={ready:!1},o;const s=ae(r);let i=0;const a=m=>{r={...r,...m},s.set(r)},c=()=>{r.ready||a({ready:!0})},d=setTimeout(c,e.unlockAfterMs??ph),u=m=>m!==i;let f;async function h(m,T){if(n?.id===m&&n.data&&a({antd:n.data}),!f)return;const D=await f(m).catch(()=>{});!D||u(T)||(a({antd:D}),fh(m,D))}async function g(m,T){const D=await e.askHost(m).catch(()=>null);if(u(T))return!0;if(D==null)return!1;const B=await di(D);return u(T)||(B&&a({catalog:B}),c()),!0}async function _(m,T){const D=await e.readList();if(u(T))return;if("error"in D){a({failure:{kind:"GET_LOCALES_ERROR",error:D.error}}),c();return}const B=D.data.find(C=>C.locale===m);if(!B){eh("em_locale")&&a({catalog:void 0}),c();return}if(ci(t,B)&&(!o||o.catalog===t?.data)){c();return}if(o?.entry&&r.catalog===o.catalog&&ci(o.entry,B)){pi(o.entry),c();return}const M=await e.readCatalog(m);if(!u(T)){if("error"in M){a({failure:{kind:"GET_LOCALE_ERROR",error:M.error}}),c();return}M.data&&(o?.id===m&&r.catalog===o.catalog&&hh(o.catalog,M.data)||a({catalog:M.data}),pi({id:m,time:B.updatedAt||Math.floor(Date.now()/1e3),hash:B.contentHash,data:M.data})),c()}}async function y(m,T){if(!await g(m,T)){if(!u(T)&&(o?.id===m&&r.catalog===o.catalog||m==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await _(m,T)}}return{set(m){if(!m||m===r.id)return;const T=i+=1;a({id:m,failure:void 0});const D=o?.id===m&&r.catalog===o.catalog;(o&&!D&&r.catalog===o.catalog||m==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===m&&t.data&&(a({catalog:t.data}),c()),h(m,T),y(m,T)},prime(m,T,D){r.id&&r.id!==m||r.catalog||!T||(o=t?.id===m&&t.data&&(!D||t.time>=D.time)?{id:m,catalog:t.data}:{id:m,catalog:T,entry:D?{id:m,time:D.time,hash:D.hash,data:T}:void 0},a({catalog:o.catalog}))},useAntdLoader(m){f=m,r.id&&h(r.id,i)},state:s,snapshot:()=>r,dispose:()=>clearTimeout(d)}}var gh=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})},vh=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:s,baseUrl:i,cancelToken:a,...c})=>{const d=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(c,d),f=o&&this.toQueryString(o),h=this.contentFormatters[r||"application/json"],g=s||u.format;return this.customFetch(`${i||this.baseUrl||""}${n}${f?`?${f}`:""}`,{...u,headers:{...u.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):u.signal)||null,body:typeof e>"u"||e===null?null:h(e)}).then(async _=>{const y=_;y.data=null,y.error=null;const m=g?_.clone():_,T=g?await m[g]().then(D=>(y.ok?y.data=D:y.error=D,y)).catch(D=>(y.error=D,y)):y;return a&&this.abortControllers.delete(a),T})}},Eh=l.createIdentifier$1("rest.v2.transport"),hi=Symbol("rest.v2.secureRequest");function _h(e){return e.getOrCreateInstance(Eh,()=>{const t=e.getInstance(l.CUSTOM_FETCH_ID)?.execute||fetch;return new vh({baseUrl:"https://app.emailmaker.ru/api/v2",securityWorker:()=>({[hi]:!0}),customFetch:(n,r={})=>{const{[hi]:o,...s}=r;return t(n,{...s,[l.PUBLIC_REQUEST]:o!==!0})}})})}function bh(e,t){const n=_h(e);return Object.assign({},...t.map(r=>new r(n)))}function mi(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function gi(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:mi(n.details,"wp_code")??n.code,message:mi(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 vi(e){return!e.ok||!!e.error}function yh(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Ei(){return yh(l.LOCAL_STORAGE_ITEMS.em_translations_v2)??!0}function Sh(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function wh(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Ih(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:Sh(r[1])}),t},[]):[]}function Th(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:wh(n.updated_at),contentHash:n.content_hash}),t),[])}function _i(e){return bh(e,[gh])}function Yt(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function ir(e){return!e.ok||e.error!=null}function ar(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function lr(e){return{data:await di(e)??null}}async function Ch(e){if(Ei())try{const n=await _i(e).localesList();return vi(n)?{error:gi(n)}:{data:Th(n.data)}}catch(n){return Yt(n)}const t=l.getApi(e,[so]);try{const n=await t.get_translations2({file:"react_app"});return ir(n)?ar(n):{data:Ih(n.data)}}catch(n){return Yt(n)}}async function Ah(e,t){if(Ei())try{const r=await _i(e).jsonList({locale:t});return vi(r)?{error:gi(r)}:lr(r.data)}catch(r){return Yt(r)}const n=l.getApi(e,[so]);try{const r=await n.get_translations3({id:t,file:"react_app"});return ir(r)?ar(r):lr(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return ir(r)?ar(r):lr(r.data)}catch(r){return Yt(r)}}}var Wt=new WeakMap;function Dh(e){const t=Wt.get(e);if(t!==void 0)return t;const n=Ch(e).then(r=>("error"in r&&Wt.delete(e),r),r=>{throw Wt.delete(e),r});return Wt.set(e,n),n}var We=l.createIdentifier$1("locale.service");function Ph(e){if(e.getInstance(We))return;const t=mh({readList:()=>Dh(e),readCatalog:n=>Ah(e,n),askHost:async n=>(await re(e,l.events.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(l.SECURITY_MODULE_ID)});e.inject(We,t),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>t.dispose())}function Oh(e){const t=e.getInstance(l.CONFIG_SOURCE_ID);if(!t)return;const n=e.getInstance(We);if(!n)return;const r=t.select(o=>o.locale).watch(o=>n.set(o||"ru_RU"));e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r)}var Rh="user_id",kh="project_id",bi=l.createIdentifier$1("rest.identityHeadersProvided");function Nh(e){if(e.getInstance(bi))return;e.inject(bi,!0);let t;e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(n=>{t=n}),e.addService(l.REQUEST_HANDLER_ID,{execute(n,r){if(r?.public)return;const o=t?.user?.id??Ko(e).profile?.id;o!=null&&o!==""&&n.headers.set(Rh,String(o));const s=t?.project;s!=null&&s!==""&&n.headers.set(kh,String(s))}})}function Lh(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function Mh(e){return e.id??Lh(e.catalog)}function xh(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function Fh(e){return xh(e||"en_US")}var Bh="Accept-Language",yi=l.createIdentifier$1("rest.localeHeaderProvided");function jh(e){e.getInstance(yi)||(e.inject(yi,!0),e.addService(l.REQUEST_HANDLER_ID,{execute(t){const n=e.getInstance(We)?.snapshot();t.headers.set(Bh,Fh(n&&Mh(n)))}}))}function Uh(e){if(!e)return!1;try{return e.getInstance(l.SECURITY_MODULE_ID)!==void 0}catch{return!1}}var Hh="Invalid standaloneKey.",Y_=l.createIdentifier$1("StandaloneMockGuard");function $h(){const e=new Error(Hh);return e.name="InvalidStandaloneKeyError",e}function Vh(e){e.addService(l.REQUEST_HANDLER_ID,{execute:()=>{if(Uh(e))throw $h()}})}function Gh(e){l.registerRestTransport(e),Vh(e)}function Yh(e){const t=new ys;e.inject(l.INIT_PIPELINE_ID,t);const n=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(o=>{if(!o)return;const s=o.signal??t.externalSignal;t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...s!==void 0?{signal:s}:{}})}),r=e.getInstance(l.DISPOSABLE_ID);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var Si=at("plugin.dataSource.blocks"),Wh=at("plugin.dataSource.blockRevisions"),qh=at("plugin.dataSource.comments"),Kh=Nt(),zh=Nt(),wi=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2110
2110
  <html>
2111
2111
  <head>
2112
2112
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -2147,10 +2147,10 @@ __emailmaker__.define("emailmaker.js",["require","exports","module","static/umd/
2147
2147
  </tr>
2148
2148
  </table>
2149
2149
  </body>
2150
- </html>`;function Xh(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:wi,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 Ii=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Jh(e){return!Object.keys(e).some(t=>Ii.has(t))}function Qh(e){const t={},n={};for(const[r,o]of Object.entries(e))Ii.has(r)?t[r]=o:n[r]=o;return{showOptions:t,misplacedEmailFields:n}}function Ti(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function Y_(e){}function qt(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function Zh(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 ct(e){return{emails:si(e),blocks:Si(e),emailRevisions:ii(e),blocksRevision:Yh(e),comments:qh(e)}}function em(e){const t=Object.values(ct(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function zt(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Jh(e))return{email:Ti(e)};{const{showOptions:n,misplacedEmailFields:r}=Qh(e),o=Object.keys(r);t&&o.length>0&&void 0;const s=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:Ti({...r,...s})}}}function cr(e){const t=Ae(e);return t&&Q(t.sessionKey())?t.suspendedDocument():t?.current()}function Kt(e){return cr(e)?.getContent()}function Ci(e,t){const n=t??Xh(),r=cr(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:Kt(e)??n.html}:n}async function dt(e){return(await e.getInstanceAsync(l.APP_ID))?.project}async function Ai(e){return rr(e)??await dt(e)}async function Di(e,t){const n=Si(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 Ai(e),{filter:{id:t}})}function Pi(e){if(!e)return;if(qt(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=zt(e,!1).email.id;return t==null?void 0:String(t)}function tm(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function nm(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}var Oi=new WeakMap;function rm(e,t){const n=(Oi.get(e)??Promise.resolve()).then(t,t);return Oi.set(e,n.catch(()=>{})),n}function qe({code:e,project:t,...n},r){const o=ge(n),s=rr(r),i=Oe(r);return e&&i.warnAboutUnconfiguredInput(e,n.id),{...o,...e?{html:i.toEditorForm(e)}:{},...s===void 0?{}:{project:s},..."utm_parameters"in o?{utm_parameters:o.utm_parameters||{}}:{},_embedded:void 0}}function ue({html:e,renderGuid:t,showToken:n,showId:r,...o},s){const{requested:i}=lt(s),a=Jo(s);return ge({...o,code:Oe(s).toOutputForm(e),project:i===void 0?o.project:i,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
2150
+ </html>`;function Xh(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:wi,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 Ii=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Jh(e){return!Object.keys(e).some(t=>Ii.has(t))}function Qh(e){const t={},n={};for(const[r,o]of Object.entries(e))Ii.has(r)?t[r]=o:n[r]=o;return{showOptions:t,misplacedEmailFields:n}}function Ti(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function W_(e){}function qt(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function Zh(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 ct(e){return{emails:si(e),blocks:Si(e),emailRevisions:ii(e),blocksRevision:Wh(e),comments:qh(e)}}function em(e){const t=Object.values(ct(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function Kt(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Jh(e))return{email:Ti(e)};{const{showOptions:n,misplacedEmailFields:r}=Qh(e),o=Object.keys(r);t&&o.length>0&&void 0;const s=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:Ti({...r,...s})}}}function cr(e){const t=Ae(e);return t&&Q(t.sessionKey())?t.suspendedDocument():t?.current()}function zt(e){return cr(e)?.getContent()}function Ci(e,t){const n=t??Xh(),r=cr(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:zt(e)??n.html}:n}async function dt(e){return(await e.getInstanceAsync(l.APP_ID))?.project}async function Ai(e){return rr(e)??await dt(e)}async function Di(e,t){const n=Si(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 Ai(e),{filter:{id:t}})}function Pi(e){if(!e)return;if(qt(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=Kt(e,!1).email.id;return t==null?void 0:String(t)}function tm(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function nm(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}var Oi=new WeakMap;function rm(e,t){const n=(Oi.get(e)??Promise.resolve()).then(t,t);return Oi.set(e,n.catch(()=>{})),n}function qe({code:e,project:t,...n},r){const o=ge(n),s=rr(r),i=Oe(r);return e&&i.warnAboutUnconfiguredInput(e,n.id),{...o,...e?{html:i.toEditorForm(e)}:{},...s===void 0?{}:{project:s},..."utm_parameters"in o?{utm_parameters:o.utm_parameters||{}}:{},_embedded:void 0}}function ue({html:e,renderGuid:t,showToken:n,showId:r,...o},s){const{requested:i}=lt(s),a=Jo(s);return ge({...o,code:Oe(s).toOutputForm(e),project:i===void 0?o.project:i,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
2151
2151
  `,`
2152
- `)}function Ri(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function om(e,t,n,r){const o=sm(e,t,n,r);return o===void 0}function sm(e,t,n,r){if(qt(t))return"block";const{email:o}=zt(t,!1),s=qe(o,e),i=s.id;if(i===void 0)return"no-id";if(r!==void 0&&r!==i)return"other-id-shown";const a=Ae(e)?.current();if(!a)return"no-session";const c=a.get(),d=c.attributes;if(c.serverId!==i)return"document-id";if(d.is_inited!==!0)return"not-inited";const u=Ri(dr(n??a.getContent()));if(s.html!==void 0&&Ri(dr(s.html))!==u)return"html";if(s.subject!==void 0&&s.subject!==d.subject)return"subject";if(s.preheader!==void 0&&s.preheader!==d.preheader)return"preheader";if(s.common_styles!==void 0&&s.common_styles!==d.common_styles)return"common_styles"}function ki(e,t){if(qt(t))return;const{email:n}=zt(t,!1),r=qe(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 im(e,t){const n={...e};return delete n.id,{...n,...t}}function am(e){return e.html?e:{...e,html:wi}}function Le({code:e,project:t,...n},r,o){const s=o??rr(r);return{...n,...e?{html:Oe(r).toEditorForm(e)}:{},renderGuid:l.generateUUID(),...s===void 0?{}:{project:s}}}function le({html:e,renderGuid:t,...n},r){const{requested:o}=lt(r);return ge({...n,code:Oe(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 Li(e){return Ae(e)?.current()?.get().serverId??void 0}function ur(e,t,n){return n===void 0&&(n=e.post===void 0?Li(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function ut(e,t){return ge({...e,link:void 0,comment_status:void 0})}function Xt({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?Li(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||yc(n.slug),parent:o}}function fr({html:e,isAutosave:t,...n},r){return ge({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:ge({html:e,ampHtml:e&&""})})}function Jt({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function Ni({html:e,isAutosave:t,...n}){return ge({...n,autosave:t?!0:void 0,code:e,guid:void 0})}var ze=l.createIdentifier$1("NotificationService"),lm=l.createIdentifier$1("emailTemplate.reads");async function cm(e,t){try{return await Ce(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,um(e,t,n);return}}var dm=l.createIdentifier$1("emailTemplate.notifiedFailures");function um(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(dm,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(ze).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function fm(e,t){const n=e.getOrCreateInstance(lm,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=cm(e,t).then(s=>(s===void 0&&n.delete(t),s));return n.set(t,o),o}var pr="EXTERNAL",Mi=Symbol("supersededShow");function pm(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var hm="email_id";function hr(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}async function mm(e,t){const n=It();let r;try{return await Promise.race([e,new Promise((o,s)=>{r=setTimeout(()=>{e.then(t,()=>{}),s(new Ct(n,"handleSaveBlock","block"))},n)})])}finally{clearTimeout(r)}}var gm=class extends l.Disposable{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=l.createQueue();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=ct(t),this._eventLock=em(t);const n=Y(e,l.events.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(Y(e,l.events.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(l.REQUEST_HANDLER_ID,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(hm,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(l.INIT_PIPELINE_ID)??jn}_throwIfDestroyed(){if(this.isDisposed())throw _e()}async getTemplateEmail(e){const t=await fm(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 dt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Le(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,Xt(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,ur(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const s=this._dataSources.emails,i=s.cache,a=await dt(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let d=qe(e,this._container);const u=d.id;let f=u;if(u!==void 0){const h=await s.get(u);d={...h??{},...d,utm_parameters:d.utm_parameters??h?.utm_parameters??{},renderGuid:h?.renderGuid??l.generateUUID(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a}}else{f=n??l.generateUUID();const h=await s.get(f);d={...d,utm_parameters:d.utm_parameters??{},renderGuid:h?.renderGuid??l.generateUUID(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a},delete d.project}if(t){const h=await this.getTemplateEmail(String(t));h&&(d=im(h,d))}return u===void 0&&(d=am(d)),await i.setAll([[f,d]]),d}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==ki(this._container,e))return!1;const n=Kt(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=ki(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Kt(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&tm({ticket:t,emailId:Pi(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,Mi;if(!e)return;const n=this._getInitPipeline();if(l.throwIfAborted(n.signal),qt(e))return this._showBlock(e,n);const r=Q(se(this._container).sessionKey()),o=nm(e);if(!r&&!o&&om(this._container,e,Kt(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const s=zt(e);s.email.id,this._prevCommand?.id;let i,a="",c=0,d=!1,u,f=Promise.resolve(),h,v=!1;try{this._eventLock.suspendChange();const{email:_,blocks:y,autosaves:m,comments:T,templateId:P,reload:F}=s;i=_.id;const N=qe(_,this._container),C=N.id,E=C??l.generateUUID(),b=await Te("getProject",dt(this._container));l.throwIfAborted(n.signal),a=l.generateUUID();const w={isNew:C===void 0,id:String(E),project:b},O=F===!0&&C!==void 0;O&&(await this._dataSources.emails.remove(String(C),{silent:!0}),String(C)),c=++this._showToken,String(E);const M=[];M.push(this.setBlocks(y)),_.id!==void 0&&(M.push(this.setComments(T)),M.push(this.setEmailRevisions(m,String(_.id)))),M.push(this.setEmail(_,Number(P),C===void 0?String(E):void 0,c,a)),await Te("setEmail+blocks+revisions",Promise.all(M),{emailId:C??String(E),showId:a,targetShowToken:c}),l.throwIfAborted(n.signal);const D=await this._dataSources.emails.get(String(E)),k=se(this._container),g={id:a,token:c};if(r){jt(this._container);const A=k.suspendedDocument()?.get().serverId;!O&&C!==void 0&&A!=null&&String(A)===String(C)&&k.resumeSuspended()}C===void 0?h=k.startNewDraft(D??N,{patch:N,show:g}):O?h=k.reload(C,{email:D??N,patch:N,show:g}):k.sessionKey()===je(C)?h=k.show(N,g):h=k.open(C,{email:D??N,patch:N,show:g}),k.beginShowFill(a);const I=!!this._prevCommand&&l.deepEqual(this._prevCommand,w);w.id,!this._prevCommand||l.deepEqual(this._prevCommand,w),this._prevCommand?.id,this._rememberShow(w),f=n.requestShow({showId:a,navId:String(E),emailId:C,isNew:C===void 0}),v=!0;const x=()=>k.endShowFill(a);Promise.allSettled([f,h.whenReady()]).then(x),String(E),d=!0}catch(_){u=_,v&&a&&n.failShow(a,_),a&&Ae(this._container)?.endShowFill(a),l.isAbortError(_)||(go(_),void 0)}finally{this._eventLock.resumeChange()}if(!d)throw u instanceof Error?u:new Error(`[emailmaker] show() setup failed: ${String(u??"unknown error")}`);return Te("show-init-deferred",Promise.all([f,h?.whenReady().catch(_=>{if(_ instanceof Ie){const y=Dn(_);throw y?new Error(`[emailmaker] show(): email open failed (${y})`,{cause:_}):_}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:s,reload:i}=Zh(e),a=l.generateUUID();let c=!1;try{await this.setBlocks(o),l.throwIfAborted(t.signal),i&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const d=n.id!==void 0&&n.id!==""?String(n.id):void 0,u=se(this._container);if(!i&&d!==void 0&&u.sessionKey()===At(d)){const P=hr(n)?await this._storeShownBlock(n):void 0,F={id:a,token:++this._showToken},N=u.show(P,F),C=t.requestShow({showId:a,navId:d,emailId:void 0,isNew:!1});c=!0,await Te("show-block-init",Promise.all([C,N?.whenReady().catch(()=>{})]),{showId:a});return}const f=r||i?await Di(this._container,String(n.id)):void 0,h=f&&(i||hr(n))?await this._storeShownBlock({...le(f,this._container),...n}):r||i?f:await this._storeShownBlock(n);if(l.throwIfAborted(t.signal),!h)throw new Error(`[emailmaker] show(): block ${String(n.id)} not found`);s!==void 0&&h.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(s.filter(P=>P.id!==void 0).map(P=>[P.id,Jt(P,String(h.id))])),this._prevCommand=void 0,this._lastShow=void 0;const v=h.id!==void 0?String(h.id):l.generateUUID(),_={id:a,token:++this._showToken};jt(this._container);const y=i?u.reloadBlock(v,h,_):u.openBlock(v,h,_);h.id;const m=t.requestShow({showId:a,navId:v,emailId:void 0,isNew:h.id===void 0});c=!0;const T=y.whenReady().catch(P=>{if(P instanceof Ie)throw P});await Te("show-block-init",Promise.all([m,T]),{showId:a})}catch(d){throw c&&t.failShow(a,d),d}}async _storeShownBlock(e){const t=Le(e,this._container,await dt(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();l.throwIfAborted(e.signal);const t=se(this._container);if(Q(t.sessionKey())&&!t.hasSuspended())throw new Error("[emailmaker] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:pr,fallbackTitle:ns(this._container)});if(l.throwIfAborted(e.signal),!n)throw pm(t.emailSaveState().error);return ue(Ci(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=se(this._container),t=e.current();if(!t||!Q(e.sessionKey()))throw new Error("[emailmaker] saveBlock(): no open block");return rm(t,async()=>{await t.whenReady();const n=Bt(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}:{}},s=this._dataSources.blocks,i=await mm(t.get().serverId==null?s.create(o,{source:pr}):s.update(String(t.get().serverId),o,{source:pr}),a=>{a&&se(this._container).current()===t&&t.get().serverId==null&&a.id!==void 0&&t.markSaved(r,String(a.id))});if(!i)throw new Error("[emailmaker] save(): block was not saved");return t.markSaved(r,i.id!==void 0?String(i.id):void 0),le(i,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=Pi(e);const n=this._queuedShow(e,t).then(r=>r===Mi?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(),l.throwIfAborted(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=se(this._container);if(n!==void 0&&r.sessionKey()===At(n))return;const o=t.code===void 0&&n!==void 0?await Di(this._container,n):void 0,s=o&&hr(t)?await this._storeShownBlock({...le(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!s)throw new Error(`[emailmaker] openBlock(): block ${String(n)} not found`);jt(this._container);const i=r.openBlockOver(s.id!==void 0?String(s.id):l.generateUUID(),s);s.id,r.hasSuspended(),re(this._container,l.events.ON_BLOCK_OPEN_ID).fire({block:s}),await i.whenReady().catch(a=>{if(a instanceof Ie)throw r.current()===i&&(re(this._container,l.events.ON_BLOCK_CLOSE_ID).fire({block:s,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),vf(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 vm(e){return String(e).replace(/"/g,"&quot;")}function Em(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 _m(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=vm(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function bm(e,t,n){if(!e?.trim()||!t)return e;const r=_m(e);if(!r)return e;const o=String(t),s=Em(n??new Date);let{full:i,index:a}=r;const c=i.length;return/\bem-block-id\s*=/.test(i)||(i=xi(i,"em-block-id",o)),i=xi(i,"em-block-version",s),e.slice(0,a)+i+e.slice(a+c)}function ym(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 Sm(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:ym(e)}}function mr(e,t){return t?Sm(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Fi=["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"],wm=[...Fi,"html","id","project","password"],q_=new Set(["html",...Fi,"global_block","project"]);function Im(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(wm),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 Tm(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Im(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var gr=new WeakMap;function Cm(e){let t=gr.get(e);return t||(t={byId:new Map,fallback:[]},gr.set(e,t)),t}function Am(e){gr.delete(e)}function Dm(e,t){const{byId:n,fallback:r}=Cm(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const s=r.indexOf(o);return s>=0&&r.splice(s,1),o}return}for(let o=r.length-1;o>=0;o--){const s=r[o],i=e.name!=null&&e.name!==""&&s.name!=null&&s.name!==""&&s.name===e.name,a=e.type!=null&&e.type!==""&&s.insertFrom===e.type;if(i&&a)return r.splice(o,1),s.id!=null&&s.id!==""&&n.delete(String(s.id)),s}}async function Pm(e,t){const{blocks:n}=ct(e);return await n.cache.getIfPresent(t)??void 0}async function Om(e,t){if(!t.blockId)return;const n=await Pm(e,t.blockId);if(n)return Tm(n,t)}async function Rm(e,t){const n=Dm(e,t);if(n)return mr(e,n);const r=await Om(t,e);return r?mr(e,r):mr(e,void 0)}var km=l.createIdentifier("application_block_inserted"),Lm=-1e3,Bi=new WeakSet;function Nm(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 Mm(e){if(!e||Bi.has(e))return;Bi.add(e);const t=new l.Disposable,n=ie(e);return t.addDisposable(n.addListenerAsyncPipe(km,async(r,o)=>{const s=Nm(r)?await Rm(r,e):r;return o?o(s):s},Lm)),t.addDisposable({dispose:()=>{Am(e)}}),t}var xm=Lt("plugin.readBlockAutosave"),z_=l.createIdentifier$1("blockDocuments.provided"),ji=l.createIdentifier$1("plugin.earlyWindow");function Fm(e){return e.getOrCreateInstance(ji,()=>({depth:0}))}function Bm(e){const t=Fm(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function Ui(e){return(e?.getInstance(ji)?.depth??0)>0}function Hi(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,s,i)=>{const a=e(o,s,i);if(r&&Ui(t)){const c=n;queueMicrotask(()=>{o.call(i,c)})}return a}}var vr=100,jm=class extends l.Disposable{_container;_events;constructor(e){super(),this._container=e;const t=Mm(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:s}=ct(e),i=Y(e,l.events.ON_SHARE_ID),a=Y(e,l.events.ON_SHOW_PREVIEW_ID),c=Y(e,l.events.ON_EMAIL_CLONE_ID),d=Y(e,l.events.ON_BLOCK_OPEN_ID),u=Y(e,l.events.ON_BLOCK_CLOSE_ID),f=Y(e,l.events.ON_BLOCK_CLONE_ID),h=Y(e,l.events.ON_BLOCK_INIT_ID),v=Y(e,l.events.ON_BLOCK_CHANGED_ID),_=Y(e,l.events.ON_CODE_VALIDATE_ID),y=Y(e,l.events.ON_SUBJECT_CHANGED_ID),m=Y(e,l.events.ON_EMAIL_CHANGED_ID),T=Y(e,l.events.ON_PREHEADER_CHANGED_ID),P=Y(e,l.events.ON_SAVEBUTTON_CLICK_ID),F=Y(e,l.events.ON_BLOCK_SAVEBUTTON_CLICK_ID),N=Y(e,l.events.ON_NEXTBUTTON_CLICK_ID),C=Y(e,l.events.ON_SEND_LIVEPREVIEW_ID),E=Y(e,l.events.ON_SEND_TESTEMAIL_ID),b=Y(e,Kh),w=Y(e,l.events.ON_CONTENT_CHANGED_ID),O=Y(e,zh),M=Y(e,l.events.ON_PREVIOUSBUTTON_CLICK_ID),D=Y(e,l.events.ON_SEND_EMAIL_MODAL_ID),k=l.filter(Y(e,l.events.ON_EMAIL_INIT_ID),g=>!g.reset);return{handlePreheaderChanged:U(T),handleSubjectChanged:U(y),handleValidate:U(_),handleReadEmail:U(n.handlerRead,g=>g,g=>g&&qe(g,e)),handleSaveEmail:U(n.onSave,function({prev:g,patch:I,value:x,source:A}){const p=g?ue(g,e):void 0;return{prev:p,patch:it(p,ue(I,e)),value:ue(x,e),source:A}},g=>g?qe(g,e):void 0),handleRemoveEmail:U(n.onRemove,({value:g,source:I})=>({value:ue(g,e),source:I}),()=>{}),handleReadCommonBlocks:U(b,g=>g.project,g=>g?.map(I=>Le(I,e))),handleReadTemplateBlocks:U(O,g=>g,g=>g?.map(I=>Le(I,e))),handleReadBlocks:U(t.byForeignKey("project").handleRead,g=>lt(e).requested||String(g),g=>g?.map(I=>Le(I,e))),handleReadBlock:U(t.handlerRead,g=>g,g=>g?Le(g,e):void 0),handleOpenBlock:U(d,({block:g})=>({block:le(g,e)})),handleCloseBlock:U(u,({block:g,hasUnsavedChanges:I})=>({block:le(g,e),hasUnsavedChanges:I})),handleCloneBlock:U(f,g=>le(g,e)),handleSaveBlock:U(t.onSave,function({prev:g,patch:I,value:x,source:A}){const p=x.global_block===!0&&x.id&&typeof x.html=="string"?{...x,html:bm(x.html,String(x.id))}:x,S=g?le(g,e):void 0;return{prev:S,patch:it(S,le(I,e)),value:le(p,e),source:A}},g=>g?Le(g,e):void 0),handleRemoveBlock:U(t.onRemove,({value:g,source:I})=>({value:le(g,e),source:I}),()=>{}),handleReadComments:U(r.byForeignKey("post").handleRead,g=>g,g=>g?.map(I=>ur(I,e))),handleSaveComment:U(r.onSave,function({prev:g,patch:I,value:x,source:A}){const p=g?ut(g,e):void 0;return{prev:p,patch:it(p,ut(I,e)),value:ut(x,e),source:A}},g=>g?ur(g,e):void 0),handleRemoveComment:U(r.onRemove,({value:g,source:I})=>({value:ut(g,e),source:I}),()=>{}),handleReadEmailRevisions:U(o.byForeignKey("parent").handleRead,g=>g,g=>g?.map(I=>Xt(I,e))),handleReadEmailAutosave:U(Y(e,ai),g=>g,g=>g?Xt(g,e):null),handleEmailAutosave:U(o.onSave,function({prev:g,patch:I,value:x,source:A}){return{value:fr(x,e),source:A}},g=>g?Xt(g,e):void 0),handleRemoveEmailAutoSave:U(o.onRemove,({value:g,source:I})=>({value:fr(g,e),source:I}),()=>{}),handleReadBlockRevisions:U(s.byForeignKey("parent").handleRead,g=>g,g=>g?.map(I=>Jt(I))),handleReadBlockAutosave:U(Y(e,xm),g=>g,g=>g?Jt(g):null),handleBlockAutosave:U(s.onSave,({value:g,source:I})=>({value:Ni(g),source:I}),g=>g?Jt(g):void 0),handleRemoveBlockAutoSave:U(s.onRemove,({value:g,source:I})=>({value:Ni(g),source:I}),()=>{}),handleBlockInit:U(h,g=>le(g,e)),handleBlockChanged:U(l.debounce(v,vr),g=>le(g,e)),handleEmailChanged:U(l.debounce(m,vr),g=>ue(g,e)),handleEmailInit:Hi(U(k,g=>ue(g,e)),e),handlePreviousButtonClick:U(M,g=>ue(g,e)),handleNextButtonClick:U(N,g=>ue(g,e)),handleSaveButtonClick:U(P,g=>ue(g,e)),handleSaveBlockButtonClick:U(F,g=>le(g,e)),handleHtmlChanged:U(l.debounce(w,vr)),handleTestEmailSend:U(E,({html:g,...I})=>({...I,code:g,compiled:{html:g,ampHtml:""}})),handleTestEmailModal:U(D,g=>ue(g,e)),handleCloneEmail:U(c,g=>ue(g,e)),handleShareEmail:U(i),handlePreviewEmail:U(a),handleLivePreviewEmail:U(C)}}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 We(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Um=l.createIdentifier$1("DataController"),Hm=l.createIdentifier$1("DataEvents");function $i(e){return e.getOrCreateInstance(Um,()=>{const t=new gm(e);return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(t),t})}function Vi(e){return e.getOrCreateInstance(Hm,()=>new jm(e))}var $m=l.createIdentifier$1("plugin.pluginStart");function Gi(e){return e.getOrCreateInstance($m,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>t()),{done:n,finish:t}})}function Vm(e){return Gi(e).done}function Gm(e){const t=Gi(e);return t.run===void 0&&(t.run=(e.getInstance(l.PLUGIN_COLLECTION_ID)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var Wm=l.createIdentifier$1("plugin.startupShow");function Ym(e){const t=$i(e),n=Vi(e),r=e.getInstance(l.OPTIONS_SOURCE_ID),o=e.getInstance(l.DISPOSABLE_ID),s={current:Promise.resolve()};e.inject(Wm,s);let i=!1;const a=r?.watch(d=>{d&&n.setOptions(d),i=(d?.plugins?.length??0)>0,s.current=s.current.catch(()=>{})}),c=r?.select(d=>d?.content).watch(d=>{if(d===void 0)return;const u=()=>(J(oe.showStart),t.show(d).finally(()=>J(oe.showEnd))),f=i?Vm(e).then(u):u();f.catch(()=>{}),s.current=f});a&&o?.addDisposable(a),c&&o?.addDisposable(c)}function qm(e){const t=$i(e);return{...Vi(e).get(),show(n){return J(oe.showStart),t.show(n).finally(()=>J(oe.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return J(oe.showStart),t.showBlock(n,r).finally(()=>J(oe.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function Wi(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function Qt(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let s=t;s<e.length;s++){const i=e[s];if(o){o=!1;continue}if(i==="\\"){o=!0;continue}if(r){i===r&&(r="");continue}if(i==='"'||i==="'"){r=i;continue}if(i==="("){n++;continue}if(i===")"&&(n--,n<0))return!1}return n===0}function zm(e){return(t,n,r)=>Qt(t)?e(t,n,r):!1}function Km(e){return t=>Qt(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Xm(e){return(t,n,r)=>Qt(t)?Wi(t)?e(t,n,r):t:!1}function Jm(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return Qt(n)?Wi(n)?e(t):t:!1}}function Qm(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function Er(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 Zm(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let s=0;s<e;s++){const i=r[s]%62;o+=t.charAt(i)}return o}var eg=8,tg=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=Zm(eg),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Zt=new tg;function Yi(e,t){return t!==void 0&&!Er(e,t)?`%|{${Zt.getOrCreateByKey(e)}}|%`:e}function ng(e){const t=Zt.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function ee(e,t,n){return t!==void 0?Er(e,t)?e:`%|{${Zt.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function rg(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function Z(e){return e.startsWith("<!--")&&e.endsWith("-->")?rg(e.slice(4,-3)):e}function og(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 s=r.trim();return t.test(s)||n.test(s)}function sg(e,t,n){return t!==void 0?Er(e,t)?e:`%|{${Zt.getOrCreateByKey(e)}}|%`:n||Qm(e)||og(e)?`<!--${e}-->`:e}var Ne=zm(ee),Me=Km(Z),ig=Xm(ee),ag=Jm(Z),qi=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",ng),e.escape("@{","}",ee,!0).unescape("<!--@{","}-->",Z,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Yi,!0),e.escape("{{","}}",Yi,!0),e.createSyntax("brace-percent").escape("{%","%}",ee).unescape("<!--{%","%}-->",Z),e.createSyntax("brace-hash").escape("{#","#}",ee).unescape("<!--{#","#}-->",Z),e.createSyntax("proscript").escape("[%","%]",sg,!0).unescape("<!--[%","%]-->",Z,!0),e.createSyntax("getresponse").escape("[[IF","]]",ee).escape("[[if","]]",ee).escape("[[ELSE]]","",ee).escape("[[else]]","",ee).escape("[[ENDIF]]","",ee).escape("[[endif]]","",ee).unescape("<!--[[IF","]]-->",Z).unescape("<!--[[if","]]-->",Z).unescape("<!--[[ELSE]]","-->",Z).unescape("<!--[[else]]","-->",Z).unescape("<!--[[ENDIF]]","-->",Z).unescape("<!--[[endif]]","-->",Z),e.createSyntax("expert-sender").escape("<if",">",ee).escape("</if",">",ee).escape("<else",">",ee).escape("</else",">",ee).escape("<var ",">",ee,!0).unescape("<!--<if ",">-->",Z).unescape("<!--</if",">-->",Z).unescape("<!--<else ",">-->",Z).unescape("<!--</else",">-->",Z).unescape("<!--<var",">-->",Z,!0),e.createSyntax("velocity").escape("#if",")",Ne).escape("#elseif",")",Ne).escape("#else","",ee).escape("#foreach",")",Ne).escape("#macro",")",Ne).escape("#set",")",ig,!0).escape("#parse",")",Ne).escape("#include",")",Ne).escape("#evaluate",")",Ne).escape("#end","",ee).escape("#break","",ee).escape("#stop","",ee).unescape("<!--#macro","-->",Me).unescape("<!--#if","-->",Me).unescape("<!--#elseif","-->",Me).unescape("<!--#else","-->",Z).unescape("<!--#foreach","-->",Me).unescape("<!--#parse","-->",Me).unescape("<!--#include","-->",Me).unescape("<!--#evaluate","-->",Me).unescape("<!--#end","-->",Z).unescape("<!--#break","-->",Z).unescape("<!--#stop","-->",Z).unescape("<!--#set","-->",ag,!0),e.createSyntax("mailchimp").escape("*|","|*",ee).unescape("<!--*|","|*-->",Z)},_r="bare",lg=new Map;function cg(e){return e?lg.get(e)??_r:_r}var zi=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function Ki(e){return zi.includes(e)}function ft(e){return e==="bare"||e==="html-comment"}function br(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function dg(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!ft(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[d,u]of[["output",r.output],["editor",r.editor]])if(u!==void 0&&!ft(u))return t(`templateDirectives.${d}: unknown form "${String(u)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!br(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[d,u]of Object.entries(r.syntaxes))if(!(!Ki(d)||u===void 0||ft(u))){if(!br(u))return t(`templateDirectives.syntaxes.${d}: expected a form or an object, configuration ignored.`),n;for(const f of["output","editor"]){const h=u[f];if(h!==void 0&&!ft(h))return t(`templateDirectives.syntaxes.${d}.${f}: unknown form "${String(h)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??_r;let s=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),s=void 0);const i=[];if(r.syntaxes)for(const d of Object.keys(r.syntaxes)){if(!Ki(d)){t(`templateDirectives.syntaxes: unknown syntax id "${d}", entry ignored.`);continue}i.push(d)}else i.push(...zi);const a={},c={};for(const d of i){const u=r.syntaxes?.[d],f=br(u)?u:void 0,h=(ft(u)?u:f?.output)??o;let v=f?.editor??s??h;h==="bare"&&v==="html-comment"&&(t(`templateDirectives.syntaxes.${d}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),v="bare"),a[d]=h,c[d]=v}return{output:a,editor:c}}function Xi(e,t,n,r){for(let o=t;o<n;o++){const s=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?s===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(s)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):s==="<"?r.insideTag=!0:s===">"?r.insideTag=!1:r.insideTag&&(s==='"'||s==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=s,r.unquotedAttr=!1):r.insideTag&&/\S/.test(s)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(s)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function pt(e,t){return e.start<t.end&&t.start<e.end}function Ji(e,t,n,r,o=[]){if(n&&(t=t.filter(u=>u.isVariable)),!t.length)return[];const s=t.flatMap(u=>u.match(e).flatMap(f=>!Number.isInteger(f.start)||!Number.isInteger(f.end)||f.start<0||f.end>e.length||f.start>=f.end?[]:[{range:f,mapFn:u.mapFn,overrideBuiltins:u.overrideBuiltins,syntax:u.syntax,isVariable:u.isVariable}])).sort((u,f)=>u.range.start-f.range.start||u.range.end-f.range.end),i=[],a=o.slice().sort((u,f)=>u.start-f.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let d=0;for(const{range:u,mapFn:f,overrideBuiltins:h,syntax:v,isVariable:_}of s){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):Xi(e,d,u.start,c),d=u.end,a.some(P=>pt(P,u)))continue;const y=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,m=e.substring(u.start,u.end),T=f(m,y,c.insideTag);T!==!1&&T!==m&&(i.push({range:u,text:T,overrideBuiltins:h,syntax:v,isVariable:_}),a.push(u))}return i.sort((u,f)=>u.range.start-f.range.start||u.range.end-f.range.end)}function ug(e,t){const n=t.reduce((a,{mapFn:c,start:d,end:u,syntax:f,isVariable:h})=>(a[d]||(a[d]=[]),a[d].push({value:u,mapFn:c,syntax:f,isVariable:h}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),s=[];let i;for(;(i=o.exec(e))!==null;){const a=i[0];s.push({start:i.index,startToken:a,endTokens:n[a]})}return s}function yr(e,t,n,r,o=!1){const s=[];if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return s;const i=ug(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let d=0;d<i.length;d++){const{start:u,startToken:f,endTokens:h}=i[d];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):Xi(e,c,u,a),c=u;const v=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let _=!1;for(const{mapFn:y,value:m,syntax:T,isVariable:P}of h){let F=u+f.length,N=e.indexOf(m,F);for(;N!==-1;){let C=N,E=u+f.length,b=0;for(;C!==-1;){const k=e.indexOf(f,E);if(k!==-1&&k<C)b++,E=k+f.length,C=e.indexOf(m,E);else if(b>0)b--,E=C+m.length,C=e.indexOf(m,E);else break}if(C<0)break;const w=C+m.length,O=e.substring(u,w),M=y(O,v,a.insideTag);if(M===!1){F=N+Math.max(m.length,1),N=e.indexOf(m,F);continue}(o||M!==O)&&s.push({range:{start:u,end:w},text:o?O:M,syntax:T,isVariable:P});const D=i.findIndex(({start:k})=>k>=w);D>d?d=D-1:d=i.length,_=!0;break}if(_)break}}return s}function en(e,t){if(!t.length)return e;const n=t.slice().sort((o,s)=>s.range.start-o.range.start);let r=e;for(const{text:o,range:s}of n)r=r.slice(0,s.start)+o+r.slice(s.end);return r}var fg=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=qi){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,s,i){return t.push({start:r,end:o,mapFn:s,isVariable:i,syntax:this.syntax||r}),this},unescape(r,o,s,i){return n.push({start:r,end:o,mapFn:s,isVariable:i,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 s={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(i=>i!==n),this._unescapeMatchers=this._unescapeMatchers.filter(i=>i!==r))}};return this.addDisposable(s),s}_collectMappings(e,t,n){const r=yr(e,this._escapes,t,n),o=Ji(e,this._escapeMatchers,t,n),s=o.filter(c=>c.overrideBuiltins).map(c=>c.range),i=r.filter(c=>!s.some(d=>pt(d,c.range))),a=o.filter(c=>c.overrideBuiltins||!i.some(d=>pt(c.range,d.range)));return[...i,...a].sort((c,d)=>c.range.start-d.range.start||c.range.end-d.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=yr(e,this._unescapes,t),r=Ji(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),s=n.filter(a=>!o.some(c=>pt(c,a.range))),i=r.filter(a=>a.overrideBuiltins||!s.some(c=>pt(a.range,c.range)));return[...s,...i].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>cg(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return yr(e,this._escapes,t,n,!0)}getEscapedText(e,t){return en(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return en(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=s=>s===void 0?void 0:t[s],r=Object.values(t);let o=e;return r.includes("bare")&&(o=en(o,this._collectRevertMappings(o).filter(s=>n(s.syntax)==="bare"))),r.includes("html-comment")&&(o=en(o,this._collectMappings(o).filter(s=>!s.isVariable&&n(s.syntax)==="html-comment"&&s.text.startsWith("<!--")&&s.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 Qi(e){return e.replace("<script","<___script").replace("<\/script>","</___script>")}var Zi=new fg(e=>{e.escape("<script","<\/script>",t=>Qi(t)).unescape("<___script","</___script>",t=>t.replace("<___script","<script").replace("</___script>","<\/script>")),e.escape("<script","/>",t=>Qi(t)).unescape("<___script","/>",t=>t.replace("<___script","<script")),qi(e)});function pg(e){const t=dg(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return _s();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=>Zi.normalizeToPolicy(o,t.editor),toOutputForm:o=>Zi.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:Es(r)}}function hg(e){let t;e.injectFactory(l.TEMPLATE_DIRECTIVES_ID,()=>{const n=e.getInstance(l.CONFIG_SOURCE_ID)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:pg(n)}),t.policy})}function K_(e){return e}var mg=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function gg(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 vg(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 ea(e){const t=gg(e),n=[],r=new Set,o=[],s=new Set,i=a=>{if(!r.has(a)){if(s.has(a)){const c=o.indexOf(a);throw new mg([...o.slice(c),a].map(d=>d.name))}s.add(a),o.push(a);for(const c of vg(a,t))i(c);o.pop(),s.delete(a),r.add(a),n.push(a)}};for(const a of e)i(a);return n}var Eg=[{name:"rest.client",setup:Gh},{name:"auth.oauth",setup:l.provideOAuth},{name:"rest.identityHeaders",setup:Lh},{name:"rest.localeHeader",setup:jh},{name:"lifetime.destroyable",provides:[tr],setup:Np},{name:"appInit",provides:[l.APP_ID,mn],setup:Cl},{name:"config",provides:[l.CONFIG_SOURCE_ID],setup:kp},{name:"templateDirectives",provides:[l.TEMPLATE_DIRECTIVES_ID],setup:hg},{name:"email.documents",setup:Zp},{name:"show.initPipeline",provides:[l.INIT_PIPELINE_ID],setup:Wh},{name:"show",setup:Ym},{name:"locale.service",provides:[Ye],setup:Ph},{name:"locale.fromConfig",awaits:{services:[l.CONFIG_SOURCE_ID,Ye]},setup:Oh},{name:"canvas.early",setup:Af},{name:"canvas.previewSettings",setup:Vf},{name:"canvas.sandboxExtensions",setup:Wf},{name:"canvas.sandboxScriptRelay",setup:zf},{name:"canvas.headerSync",provides:[Yn],setup:Of},{name:"canvas.headersAfterRecovery",setup:Rf},{name:"canvas.ampSync",setup:Rd},{name:"canvas.moduleBridge",setup:lu},{name:"canvas.port",setup:Hd},{name:"canvas.images",setup:jd},{name:"canvas.edits",setup:Tf},{name:"canvas.surfaceFollowsSession",setup:_f},{name:"canvas.blockContent",setup:Ef},{name:"canvas.sandboxFill",provides:[Wn],setup:fp},{name:"canvas.reactions",setup:Cf}],ta;function Sr(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID);if(t)return t;e.getInstance(l.DISPOSABLE_ID)||e.inject(l.DISPOSABLE_ID,new l.Disposable);const n=ae();e.inject(l.OPTIONS_SOURCE_ID,n),ta??=ea(Eg);for(const r of ta)r.setup(e);return n}function _g(e){}var bg=[{name:"save.previewFollow",setup:_g}],na=l.createIdentifier$1("plugin.lateUnitsInstalled");function yg(e){if(!e.getInstance(na)){e.inject(na,!0);for(const t of ea(bg))t.setup(e)}}function Sg(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function wg(e){if(!e)return;const t=l.decodeJwt(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 Ig=l.defineMixin(e=>{let t,n,r;return{async setOptions(o){const s=r!==o.getAuthToken,i=!l.deepEqual(t,o.user),a=n!==o.project;if(r=o.getAuthToken,t=o.user,n=o.project,!(!e.getInstance(l.SECURITY_MODULE_ID)||!o.getAuthToken)&&!(!s&&!i&&!a))try{const c=await o.getAuthToken(o.user,o.project);e.inject(l.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(c||""));const d=wg(c);if(!d)return;e.inject(l.STANDALONE_PROJECT_ID,d);const u=e.getInstance(l.APP_ID),f=u?await u.catch(()=>{}):void 0;e.inject(l.APP_ID,Promise.resolve(Sg(d,f)))}catch{}}}});function Tg(e,t){if(e.getInstance(l.STANDALONE_FILE_PROXY_REGISTERED_ID))return;e.inject(l.STANDALONE_FILE_PROXY_REGISTERED_ID,!0);const n=l.getEvent(e,l.events.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var Cg=l.defineMixin(e=>{let t,n=!1;return{setOptions(r){const o=n;if(n=!0,!st(r)){t&&(bp(e),er(r)),t=void 0;return}const s=$t(r);if(!s||t===s&&e.getInstance(l.SECURITY_MODULE_ID))return;t=s,e.inject(l.SECURITY_MODULE_ID,s);const i=e.getInstance(l.DISPOSABLE_ID);i&&Tg(e,i)}}}),Ag=l.defineMixin(e=>{const t=e.getInstance(l.DISPOSABLE_ID),n=l.getEvent(e,l.APP_LOAD_EVENT_ID),r=U(n),o=t.addDisposable(new We(r));return{setOptions({handleLoad:s}){o.setListener(s)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function ra(e,t,n=!0){const r=e,o=t;for(const s of Object.keys(o)){const i=o[s];i!=null&&(n&&typeof i=="object"?r[s]=ra(r[s]||{},i,!0):r[s]=i)}return e}async function Dg(e){const t=(await Ja.__vitePreload(()=>Promise.resolve().then(()=>Promise.resolve(St("./static/umd/3f12d6ff.js")).then(n=>dn.__toESM(n.default))),void 0,{}.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var oa=l.createIdentifier$1("EditorOptions"),wr=l.MONACO_EDITOR_OPTIONS;function Pg(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 Og(e){return e.getOrCreateInstance(oa,()=>{const t=ae(wr);let n=wr.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(Dg(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function Rg(e){return e?.getInstance(oa)?.get()??wr}function kg(e,t={}){const n=Og(e);n.set(ra({...n.get()},Pg(t)))}function Lg(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 Ng(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var Mg=l.createIdentifier$1("plugin.publicConfig");function Ir(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.get()??{}}function sa(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function ia(e){const t=Gs(e),n=Ir(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:Ng(Rg(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function aa(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.get()!==void 0}function xg(e){const t=l.createQueue(),n=re(e,l.CONFIG_CHANGED_EVENT_ID);let r,o,s=!1;const i=async()=>{try{return e.getInstance(l.APP_ID)===void 0?{}:(await e.getInstanceAsync(l.APP_ID))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:f=!1}={})=>{await e.getInstance(l.CONFIG_SOURCE_ID)?.ready(),io(e).set(Ir(e).revisionService===!0);const{codeModeDirection:h,editor:v}=Ir(e);v&&kg(e,Lg(v)),h!==void 0&&!(f&&h===o)&&(o=h,h==="none"?Kn(e,!1):(Kn(e,!0),Bf(e,h)))},c=async()=>{if(!aa(e))return;const f=ia(e),h=JSON.stringify(f);h!==r&&(r=h,await n.fire(f))},d=async f=>{const h=e.getInstance(l.CONFIG_SOURCE_ID),v={advancedConfigs:sa(e).advancedConfigs,serverSide:await i(),user:f};h?.setAdvancedConfigs({...v.advancedConfigs,...v.user?.advancedConfigs});const _=h?.layers().user.mode;h?.replace(v.user?.mode===void 0&&_!==void 0?{...v.user,mode:_}:v.user,"user"),h?.replace(v.serverSide,"server"),await a(),await c()},u=f=>{const{commonStyles:h,...v}=f;return"commonStyles"in f&&Uf(e,h===void 0?void 0:h),v};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:i,getConfig:()=>aa(e)?ia(e):{},setConfig:t.decorate(async f=>{await d(u(f))}),updateConfig:t.decorate(async f=>{const h=u(f);await d({...sa(e).user,...h})}),announceAssembled(){s||(s=!0,e.getInstance(l.CONFIG_SOURCE_ID)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function la(e){return e.getOrCreateInstance(Mg,()=>xg(e))}function Fg(e){const t=la(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var Bg=l.defineMixin(e=>{const t=e.getInstance(l.DISPOSABLE_ID),n=t.addDisposable(new l.AsyncEmitter),r=t.addDisposable(new l.AsyncEmitter),o=l.getEmitter(e,l.CONFIG_CHANGED_EVENT_ID),s=U(n.event),i=U(r.event),a=Hi(U(o.event),e),c=t.addDisposable(new We(s)),d=t.addDisposable(new We(i)),u=t.addDisposable(new We(a));return{instance:{handleSetOptions:s,handleOptionsChanged:i,handleConfigChanged:a},async setOptions(f){c.setListener(f.handleSetOptions),d.setListener(f.handleOptionsChanged),u.setListener(f.handleConfigChanged),la(e).announceAssembled(),await n.fire(f),await r.fire(f)},dispose(){}}}),Tr,ca="core";function jg(){const e=__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([ca],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Ug(e){const t=__emailmaker__?.require?.warm;return typeof t!="function"?ht().then(()=>{}):t([ca],e)}function ht(){return Tr===void 0&&(Tr=jg().then(e=>(Je()&&e.installDiagnostics().catch(t=>{}),e))),Tr}var Cr=null,Ar=null;async function Hg(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Dr(){return Cr||(Cr=ht().then(()=>{})),Cr}function da(e){return Ar||(Ar=Hg(e)),Ar}function $g(){return da(typeof __emailmaker__<"u"?__emailmaker__:void 0)}function Vg(){const e=typeof __emailmaker__<"u"?__emailmaker__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function Gg(e){return Promise.all([Dr(),da(e)]).then(()=>{})}function Wg(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function ua(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Ug(t?{priority:t}:void 0)).then(()=>(Fn(t?{priority:t}:void 0),n?Dr():void 0)).catch(()=>{})}function Yg(e){const t=Wg(e);if(t==="eager")ua(e);else if(t==="idle"){const n=()=>ua(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var fa="PluginRegistry";function qg(e=l.resolveContainer()){return e.getOrCreateInstance(fa,()=>new sl)}var pa=new il(()=>qg()),zg=["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"],Kg=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],tn=new Map([...zg.map(e=>[e,"event"]),...Kg.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),Xg=new Map([["use","use `useAsync()` or await `ready` first"]]);function Jg(e){return Xg.get(e)??"await `ready` first"}var Qg=new Set(["async","queued"]),Zg=Symbol.for("emailmaker.earlyCtxPlaceholder");function ha(e){return e[Zg]=!0,e}function ev(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 (${Jg(e)}).`)}function tv(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function nv(e){return[...tn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function rv(e,t){for(const n of nv(e)){const r=tn.get(n);if(r!==void 0&&Qg.has(r)){const o=async(...s)=>{await t;const i=e[n];if(typeof i!="function"||i===o)throw tv(n);return i.apply(e,s)};e[n]=ha(o);continue}e[n]=ha(()=>{throw ev(n)})}}function ov(e,t,n){e.getInstanceAsync(ze).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function sv(e,t){e.getInstanceAsync(ze).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var iv=l.defineMixin(e=>{let t;function n(){return new Promise(o=>{const s=e.getOrCreateInstance(l.LATE_SURFACE_LISTENERS_ID,()=>new Set),i=()=>{s.delete(i),o()};s.add(i)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const s=e.getInstance(l.INSTANCE_ID),i=e.getInstance(fa);if(!t){t=new ol(s,i,{ensureHostRuntimeReady:$g,explainScriptFailure:Vg,openEarlyWindow:()=>Bm(e),reportLoadFailure:d=>sv(e,d)}),e.inject(l.PLUGIN_COLLECTION_ID,t);const c=t.onLifecycle(d=>{d.type==="create:error"&&ov(e,d.name,d.error)});e.getInstance(l.DISPOSABLE_ID)?.addDisposable(c)}const a=o?.plugins||[];s&&(Xo(e),a.length>0&&rv(s,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}}}),ma=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}},av=l.createIdentifier$1("ELEMENT_INSERT_HTML_PIPELINE"),lv=l.createIdentifier$1("BLOCK_INSERT_HTML_PIPELINE"),cv="application_block_inserted",dv=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(lv,()=>new ma).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService),o=n?e.bind(n):e;return r.addListener(cv,o,t)}},Pr=l.createIdentifier$1("ComponentRegistry"),uv=l.createIdentifier$1("ComponentRegistryGate");function Or(){return l.DependencyResolver.getOrCreateInstance(uv,()=>({pending:[]}))}function fv(e=Pr){return Or().factory!==void 0||l.DependencyResolver.getInstance(e)!==void 0}function Rr(e,t,n=Pr){if(fv(n)){t(nn(e,n));return}Or().pending.push(()=>t(nn(e,n)))}function nn(e,t=Pr){const n=l.DependencyResolver.getInstance(t);if(n)return n;const r=Or().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return l.DependencyResolver.getOrCreateInstance(t,r)}var pv=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=s=>{if(!n){n=!0;for(const i of t)i.dispose();e(s)}};t.push(this._container.addService(l.ATOMS_HANDLERS_ID,{execute:s=>{r(s.value.map(i=>({name:i.name,html:i.html})))}}));const o=this._container.getInstance(l.HEADLESS_MODE_ID)?.watch(s=>{s&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService(l.ATOMS_HANDLERS_ID,{execute:r=>{const o=nn(n),s=r.value.find(i=>i.name===e);if(s){const{icon:i,title:a,fallbackTooltip:c,...d}=t;i&&(s.icon=o.getReactNode(i)),a&&(s.title=o.getReactNode(a)),c&&(s.fallbackTooltip=o.getReactNode(c)),Object.assign(s,d)}}})}delete(e){this._container.addService(l.ATOMS_HANDLERS_ID,{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(l.ATOMS_HANDLERS_ID,{execute:r=>{const o=nn(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(av,()=>new ma).add(e,t??0,n)}handleInject(e,t,n){return l.getEmitter$1(this._container,l.HANDLE_ATOM_INSERT_ID).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},hv=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}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 mv(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function ga(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 gv=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=l.getEmitter$1(t,l.MODAL_SHOW_EVENT),this._closeModalEmitter=l.getEmitter$1(t,l.MODAL_CLOSE_EVENT),this._updateModalEmitter=l.getEmitter$1(t,l.MODAL_UPDATE_EVENT)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Rr(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:ga(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Rr(this._container,r=>{this._updateModalEmitter.fire(mv({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:ga(r,n)}))})}};function rn(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var vv=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)}},Ev=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}_createScriptHandle(e,t){const n=this._messageService.addListener(l.SANDBOX_EXTENSION_SCRIPT_STATUS_ID,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 vv(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(l.SANDBOX_EXTENSIONS_ID,{...rn(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(l.SANDBOX_EXTENSIONS_ID,{...rn(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(l.SANDBOX_EXTENSIONS_ID,{...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(l.SANDBOX_EXTENSIONS_ID,{...rn(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},_v=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function kr(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&_v.has(t)}function va(){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 Lr(){return`__settingsPanel:${va()}`}function Nr(e,t){return{type:e,props:t}}function bv(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!kr(e)}function Ea(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(kr(t)){const r=Lr();return n(e.add(r,t)),Nr(r,{})}if(typeof t=="function"){const r=Lr();return n(e.add(r,t)),Nr(r,{})}if(bv(t)){const r=t.type;if(typeof r=="string")return t;if(kr(r)||typeof r=="function"){const o=Lr();return n(e.add(o,r)),Nr(o,t.props)}return t}return t}var yv=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??va();Rr(this._container,n=>{const r=i=>this._trackRegistration(i),o=Ea(n,e.content,r),s=e.advancedTabs?.map(i=>({...i,content:Ea(n,i.content,r)}));l.getEmitter$1(this._container,l.SETTINGS_PANEL_EVENT).fire({...e,content:o,advancedTabs:s,instanceKey:t,type:l.ADVANCED_SETTINGS_PANEL})})}closeSettingsPanel(){this._clearPanelRegistrations(),l.getEmitter$1(this._container,l.SETTINGS_PANEL_EVENT).fire(null)}},_a={SandboxScriptApi:Ev,ElementsApi:pv,BlocksApi:dv,MessageService:hv,SettingsPanelApi:yv,ModalApi:gv};function Mr(e,t,n,r={}){const o=Object.assign({},e);for(const[s,i]of Object.entries(t))if(i!==void 0)if(n.includes(s)&&typeof i=="object"&&i!==null){const a=o[s],c=r[s]??{};o[s]=Object.assign({},typeof a=="object"&&a!==null?a:c,i)}else o[s]=i;return o}var pe={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}},Sv={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"},xr={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},ba={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},Ke={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:pe.border,borderRadius:pe.borderRadius,textAlign:"center",padding:pe.padding},ya={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:pe.padding},Fr={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:pe.border,borderRadius:pe.borderRadiusCards};function wv(e){return{...Sv,...e}}function Iv(e){return{...xr,...e,bold:e?.bold??xr.bold,italic:e?.italic??xr.italic}}function Tv(e){return{...ba,...e,underline:e?.underline??ba.underline}}function Cv(e){return{...Ke,...e,bold:e?.bold??Ke.bold,italic:e?.italic??Ke.italic,border:{...Ke.border,...e?.border},borderRadius:{...Ke.borderRadius,...e?.borderRadius},padding:{...Ke.padding,...e?.padding}}}function Av(e){return{...ya,...e,padding:{...ya.padding,...e?.padding}}}function Dv(e){return{...Fr,...e,border:{...Fr.border,...e?.border},borderRadius:{...Fr.borderRadius,...e?.borderRadius}}}function Br(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 Sa(e){let t={...l.COMMON_STYLES};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function jr(e){return{text:wv(e.text),headings:Iv(e.headings),links:Tv(e.links),buttons:Cv(e.buttons),block:Av(e.block),cards:Dv(e.cards)}}var wa=l.createIdentifier$1("EmailSettingsPort"),Pv=1e4,Ia=class{_editor;_layoutSettingsChanged=new l.Emitter;_contentStylesChanged=new l.Emitter;_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(!Ui(this._editor.container)||!Be(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(wa);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Br(this._settings().read())}_getCurrentContentStyles(){const e=Be(this._editor.container)?.current()?.get().attributes.common_styles;return jr(Sa(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(wa),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService),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,s=o?.operation;if(s===l.EVENT_TYPES.APPLICATION_EMAIL_SETTINGS_SET){const c=Br(o?.settings),d=this._getLayoutSnapshot(c);d!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=d,this._layoutSettingsChanged.fire(c));return}if(s!==l.EVENT_TYPES.APPLICATION_COMMON_STYLES_UPDATE)return;const i=jr(r.data?.settings?.commonStyles??{...l.COMMON_STYLES}),a=this._getContentSnapshot(i);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(i))})})();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=Br(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Pv){const t=Be(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=l.getEvent(r,l.events.ON_EMAIL_INIT_ID);return new Promise(s=>{let i=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},d=o(()=>{i||(i=!0,c(),d.dispose(),s())});a=setTimeout(()=>{i||(i=!0,d.dispose(),s())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Be(this._editor.container)?.current();if(!t)return;const n=Sa(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=Mr(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:pe.border,borderRadius:pe.borderRadius,padding:pe.padding})),e.block!==void 0&&(n.block=Mr(n.block||{},e.block,["padding"],{padding:pe.padding})),e.cards!==void 0&&(n.cards=Mr(n.cards||{},e.cards,["border","borderRadius"],{border:pe.border,borderRadius:pe.borderRadiusCards}));const r=JSON.stringify(n);He(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=jr(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},Ov={..._a,EmailSettingsApi:Ia},Rv={..._a},X_={...Rv,EmailSettingsApi:Ia},kv={...Ov};function Lv(){pa.addAll(kv)}var Nv=[l.defineMixin(()=>{Lv()}),Ag,Bg,Cg,l.JWTMixin,Ig,l.OAuthMixin];async function Mv(){return(await ht()).asyncMixins}var xv=iv,Fv=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let o;try{o=await Mv()}catch(i){throw e.failPendingWaits(i),i}t=o(e);const s=await e.getInstanceAsync(l.INSTANCE_ID);Object.assign(s,t.instance||{});for(const i of e.getInstance(l.LATE_SURFACE_LISTENERS_ID)??[])i()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},Bv=l.combineMixins([...Nv]);function Ur(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const s of r.values())s();r.clear()}return{event(s,i,a){const c=Symbol("subscription");return t||(n.set(c,{listener:s,priority:i,thisArg:a}),e&&r.set(c,e(s,i,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(s){o(),e=s;for(const[i,{listener:a,priority:c,thisArg:d}]of n)r.set(i,s(a,c,d))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function jv(e){const t=Ur(),n=Ur(),r=Ur();return e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(ze).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 s=e.getInstance(ze);if(s){s.notify(o);return}e.getInstanceAsync(ze).then(i=>i.notify(o),()=>{})}}}var Ta=l.createIdentifier$1("CodeErrors"),Uv=[];function Hv(e){return e?.getInstance(Ta)?.get()??Uv}function $v(e){return e?.getInstance(Ta)!==void 0}var Vv=class extends l.Disposable{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=ct(e),this.addDisposable(l.getEvent(e,l.events.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){const e=Ae(this._container);if(e&&Q(e.sessionKey())&&!e.hasSuspended())throw new Error("[emailmaker] no open email: only a block is shown");return Ci(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=>le(t,this._container))}async _readProjectBlocks(){const e=await Ai(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=>ut(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=>fr(n,this._container))}async getEmailSnapshot(){return ue(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Ae(this._container),t=e?.current();return!e||!t||!Q(e.sessionKey())?null:(await t.whenReady(),le(Bt(t),this._container))}setEmailMeta(e){const t=cr(this._container);if(!t)return;const n=t.get().attributes.meta;He(t,{meta:Vt({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&Vt(o,e))}setBlockMeta(e,t){const n=Ae(this._container);if(n?.sessionKey()===At(e)){const o=n.current();o&&He(o,{meta:Vt({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,s=>s&&Vt(s,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return $v(this._container)?Hv(this._container):void 0}},Gv=l.createIdentifier$1("EmailDataController");function Wv(e){return e.getOrCreateInstance(Gv,()=>{const t=new Vv(e);return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(t),t})}function Yv(e){const t=Wv(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 qv(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 zv(e){let t;const n=ri(e),r=l.getEvent(e,l.events.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:s})=>{t=s}));const o=()=>t?qv(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:s=>o()?.getPast(s)??[],getFuture:s=>o()?.getFuture(s)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:s=>o()?.restoreSnapshot(s)}}}var Kv=l.createIdentifier$1("plugin.mountElement");function Xv(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function Jv(e){return e.getOrCreateInstance(Kv,()=>{let t=!1,n;return{get:()=>t?n:Xv(e),set(r){t=!0,n=r}}})}function Qv(e){const t=Jv(e);return{getElement:()=>t.get()}}function Zv(e){return{handleLoadImage:U(l.getEvent(e,l.events.UPLOAD_EVENT_ID)),handleFileProxy:U(l.getEvent(e,l.events.FILE_PROXY_EVENT_ID)),handleUrlProxy:U(l.getEvent(e,l.events.PROXY_URL_EVENT_ID)),handleAITextRequest:U(l.getEvent(e,l.events.AI_TEXT_REQUEST_ID)),handleAIImageRequest:U(l.getEvent(e,l.events.AI_IMAGE_REQUEST_ID)),handleReadLocale:U(l.getEvent(e,l.events.READ_LOCALE)),handleLimitUsage:U(l.getEvent(e,l.events.ON_LIMIT_ID)),handleTranslate:U(l.getEvent(e,l.events.ON_TRANSLATE_ID))}}var eE=[Mp,qm,jv,Fg,Yv,zv,Qv,Zv];function tE(e,t=eE){const n=Sr(e);yg(e);const r=Bv(e),o=xv(e),s=Fv(e),i={...r.instance,...o.instance,...s.instance};for(const c of t)Object.assign(i,c(e));let a=!0;return{instance:i,async setOptions(c){await r.setOptions(c);const d=a&&n.get()===c;a=!1,d||n.set(c),await o.setOptions(c),await s.setOptions(c)}}}function nE(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 rE=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]}},oE="editor-runtime.react.copies",Hr=8;function mt(e){return e&&typeof e=="object"?e:void 0}function Ca(e){const t=mt(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=mt(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function sE(e){const t=mt(e),n=t&&typeof t.version=="string"?t.version:void 0,r=mt(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function iE(e,t,n){return e.package===t&&e.version===n}function aE({ourReact:e,entries:t,packageName:n,version:r}){const o=Ca(e);if(!o||!Array.isArray(t))return[];const s=[],i=new Set;for(const a of t){const c=mt(a);if(!c||!iE(c,n,r))continue;const d=Ca(c.react);!d||d===o||i.has(d)||(i.add(d),s.push({package:n,version:r,reactVersion:sE(c.react),react:c.react}))}return s}function lE({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,Hr))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Hr&&n.push(` …and ${t.length-Hr} 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(`
2153
- `)}var Aa=new Set;function cE({packageName:e="@emailmaker/emailmaker",version:t="1.1.108",log:n=r=>{}}={}){const r=o=>{try{const s=globalThis[Symbol.for(oE)],i=aE({ourReact:o,entries:s,packageName:e,version:t}).filter(a=>!Aa.has(a.react));if(!i.length)return;i.forEach(a=>Aa.add(a.react)),n(lE({packageName:e,copies:i}))}catch{}};try{const o=pn()?.modules?.React;if(o&&typeof o.then=="function"){o.then(r,()=>{});return}r(o)}catch{}}async function dE(e,t,n){l.throwIfAborted(e.signal);const r=t??l.DependencyResolver.createChild();Sr(r);const o=r.getInstance(l.DISPOSABLE_ID);let s;async function i(){r.inject(l.COOKIE_MANAGER_ID,nE(new rE)),cE();const a=tE(r),c={...a.instance,container:r,get ready(){return s??Promise.resolve(c)},async reset(d){if(l.throwIfAborted(d.signal),o.isDisposed())throw _e();return await a.setOptions(d),c}};r.inject(l.INSTANCE_ID,c);try{if(n?.onInstance?.(c),await a.setOptions(e),l.throwIfAborted(e.signal),o.isDisposed()||await Gm(r),e.devTools)try{const d=r.getInstance(l.PLUGIN_COLLECTION_ID);d&&await(await ht()).initDevTools(r,d)}catch{}return l.throwIfAborted(e.signal),l.getEmitter(r,l.APP_LOAD_EVENT_ID).fire(c),c}catch(d){throw o.dispose(),d}}try{return s=l.raceWithAbortSignal(i(),e.signal),s.catch(()=>{}),await s}catch(a){throw o.isDisposed()||o.dispose(),a}}var gt=new WeakMap;function uE(e){return e?gt.get(e):void 0}function Da(e){try{e.getInstance(l.DISPOSABLE_ID)?.dispose()}catch{}try{e.dispose()}catch{}}function fE(e,t){if(!e)return;const n=gt.get(e);n&&n!==t&&Da(n),gt.set(e,t)}function pE(e,t){e&&gt.get(e)===t&&gt.delete(e)}function hE(e){const t=l.DependencyResolver.createChild();return st(e)&&t.inject(l.SECURITY_MODULE_ID,$t(e)),t}var vt=new WeakMap,mE="data-emailmaker-config-styles";function gE(e){return typeof e=="string"?e.trim():""}function Pa(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function vE(e,t,n){if(!e||typeof document>"u")return null;const r=gE(t),o=vt.get(e),s=n||e;if(!r)return o&&(o.remove(),vt.delete(e)),null;if(o)return o.textContent!==r&&(o.textContent=r),(o.parentNode!==s||o!==s.firstChild)&&Pa(s,o),o;const i=document.createElement("style");return i.setAttribute(mE,"true"),i.textContent=r,Pa(s,i),vt.set(e,i),i}function EE(e){if(!e)return;const t=vt.get(e);t&&(t.remove(),vt.delete(e))}var J_=!1;function Oa(){return!1}var Q_=28,_E=`
2152
+ `)}function Ri(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function om(e,t,n,r){const o=sm(e,t,n,r);return o===void 0}function sm(e,t,n,r){if(qt(t))return"block";const{email:o}=Kt(t,!1),s=qe(o,e),i=s.id;if(i===void 0)return"no-id";if(r!==void 0&&r!==i)return"other-id-shown";const a=Ae(e)?.current();if(!a)return"no-session";const c=a.get(),d=c.attributes;if(c.serverId!==i)return"document-id";if(d.is_inited!==!0)return"not-inited";const u=Ri(dr(n??a.getContent()));if(s.html!==void 0&&Ri(dr(s.html))!==u)return"html";if(s.subject!==void 0&&s.subject!==d.subject)return"subject";if(s.preheader!==void 0&&s.preheader!==d.preheader)return"preheader";if(s.common_styles!==void 0&&s.common_styles!==d.common_styles)return"common_styles"}function ki(e,t){if(qt(t))return;const{email:n}=Kt(t,!1),r=qe(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 im(e,t){const n={...e};return delete n.id,{...n,...t}}function am(e){return e.html?e:{...e,html:wi}}function Ne({code:e,project:t,...n},r,o){const s=o??rr(r);return{...n,...e?{html:Oe(r).toEditorForm(e)}:{},renderGuid:l.generateUUID(),...s===void 0?{}:{project:s}}}function le({html:e,renderGuid:t,...n},r){const{requested:o}=lt(r);return ge({...n,code:Oe(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 Ni(e){return Ae(e)?.current()?.get().serverId??void 0}function ur(e,t,n){return n===void 0&&(n=e.post===void 0?Ni(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function ut(e,t){return ge({...e,link:void 0,comment_status:void 0})}function Xt({code:e,autosave:t,...n},r,o){return o===void 0&&(o=n.parent===void 0?Ni(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||yc(n.slug),parent:o}}function fr({html:e,isAutosave:t,...n},r){return ge({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:ge({html:e,ampHtml:e&&""})})}function Jt({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function Li({html:e,isAutosave:t,...n}){return ge({...n,autosave:t?!0:void 0,code:e,guid:void 0})}var Ke=l.createIdentifier$1("NotificationService"),lm=l.createIdentifier$1("emailTemplate.reads");async function cm(e,t){try{return await Ce(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,um(e,t,n);return}}var dm=l.createIdentifier$1("emailTemplate.notifiedFailures");function um(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(dm,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(Ke).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function fm(e,t){const n=e.getOrCreateInstance(lm,()=>new Map),r=n.get(t);if(r!==void 0)return r;const o=cm(e,t).then(s=>(s===void 0&&n.delete(t),s));return n.set(t,o),o}var pr="EXTERNAL",Mi=Symbol("supersededShow");function pm(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var hm="email_id";function hr(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}async function mm(e,t){const n=It();let r;try{return await Promise.race([e,new Promise((o,s)=>{r=setTimeout(()=>{e.then(t,()=>{}),s(new Ct(n,"handleSaveBlock","block"))},n)})])}finally{clearTimeout(r)}}var gm=class extends l.Disposable{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=l.createQueue();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=ct(t),this._eventLock=em(t);const n=Y(e,l.events.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(Y(e,l.events.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(l.REQUEST_HANDLER_ID,{execute:(r,o)=>{!o?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(hm,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(l.INIT_PIPELINE_ID)??jn}_throwIfDestroyed(){if(this.isDisposed())throw _e()}async getTemplateEmail(e){const t=await fm(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 dt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Ne(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,Xt(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,ur(o,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,o){const s=this._dataSources.emails,i=s.cache,a=await dt(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let d=qe(e,this._container);const u=d.id;let f=u;if(u!==void 0){const h=await s.get(u);d={...h??{},...d,utm_parameters:d.utm_parameters??h?.utm_parameters??{},renderGuid:h?.renderGuid??l.generateUUID(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a}}else{f=n??l.generateUUID();const h=await s.get(f);d={...d,utm_parameters:d.utm_parameters??{},renderGuid:h?.renderGuid??l.generateUUID(),...c>0?{showToken:c}:{},...o?{showId:o}:{},project:a},delete d.project}if(t){const h=await this.getTemplateEmail(String(t));h&&(d=im(h,d))}return u===void 0&&(d=am(d)),await i.setAll([[f,d]]),d}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==ki(this._container,e))return!1;const n=zt(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=ki(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:zt(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&tm({ticket:t,emailId:Pi(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,Mi;if(!e)return;const n=this._getInitPipeline();if(l.throwIfAborted(n.signal),qt(e))return this._showBlock(e,n);const r=Q(se(this._container).sessionKey()),o=nm(e);if(!r&&!o&&om(this._container,e,zt(this._container),this._prevCommand?.id)||!r&&!o&&this._isRepeatOfLastShow(e))return;const s=Kt(e);s.email.id,this._prevCommand?.id;let i,a="",c=0,d=!1,u,f=Promise.resolve(),h,g=!1;try{this._eventLock.suspendChange();const{email:_,blocks:y,autosaves:m,comments:T,templateId:D,reload:B}=s;i=_.id;const M=qe(_,this._container),C=M.id,E=C??l.generateUUID(),b=await Te("getProject",dt(this._container));l.throwIfAborted(n.signal),a=l.generateUUID();const w={isNew:C===void 0,id:String(E),project:b},O=B===!0&&C!==void 0;O&&(await this._dataSources.emails.remove(String(C),{silent:!0}),String(C)),c=++this._showToken,String(E);const x=[];x.push(this.setBlocks(y)),_.id!==void 0&&(x.push(this.setComments(T)),x.push(this.setEmailRevisions(m,String(_.id)))),x.push(this.setEmail(_,Number(D),C===void 0?String(E):void 0,c,a)),await Te("setEmail+blocks+revisions",Promise.all(x),{emailId:C??String(E),showId:a,targetShowToken:c}),l.throwIfAborted(n.signal);const A=await this._dataSources.emails.get(String(E)),N=se(this._container),k={id:a,token:c};if(r){jt(this._container);const I=N.suspendedDocument()?.get().serverId;!O&&C!==void 0&&I!=null&&String(I)===String(C)&&N.resumeSuspended()}C===void 0?h=N.startNewDraft(A??M,{patch:M,show:k}):O?h=N.reload(C,{email:A??M,patch:M,show:k}):N.sessionKey()===je(C)?h=N.show(M,k):h=N.open(C,{email:A??M,patch:M,show:k}),N.beginShowFill(a);const P=!!this._prevCommand&&l.deepEqual(this._prevCommand,w);w.id,!this._prevCommand||l.deepEqual(this._prevCommand,w),this._prevCommand?.id,this._rememberShow(w),f=n.requestShow({showId:a,navId:String(E),emailId:C,isNew:C===void 0}),g=!0;const v=()=>N.endShowFill(a);Promise.allSettled([f,h.whenReady()]).then(v),String(E),d=!0}catch(_){u=_,g&&a&&n.failShow(a,_),a&&Ae(this._container)?.endShowFill(a),l.isAbortError(_)||(go(_),void 0)}finally{this._eventLock.resumeChange()}if(!d)throw u instanceof Error?u:new Error(`[emailmaker] show() setup failed: ${String(u??"unknown error")}`);return Te("show-init-deferred",Promise.all([f,h?.whenReady().catch(_=>{if(_ instanceof Ie){const y=Dn(_);throw y?new Error(`[emailmaker] show(): email open failed (${y})`,{cause:_}):_}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:o,revisions:s,reload:i}=Zh(e),a=l.generateUUID();let c=!1;try{await this.setBlocks(o),l.throwIfAborted(t.signal),i&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const d=n.id!==void 0&&n.id!==""?String(n.id):void 0,u=se(this._container);if(!i&&d!==void 0&&u.sessionKey()===At(d)){const D=hr(n)?await this._storeShownBlock(n):void 0,B={id:a,token:++this._showToken},M=u.show(D,B),C=t.requestShow({showId:a,navId:d,emailId:void 0,isNew:!1});c=!0,await Te("show-block-init",Promise.all([C,M?.whenReady().catch(()=>{})]),{showId:a});return}const f=r||i?await Di(this._container,String(n.id)):void 0,h=f&&(i||hr(n))?await this._storeShownBlock({...le(f,this._container),...n}):r||i?f:await this._storeShownBlock(n);if(l.throwIfAborted(t.signal),!h)throw new Error(`[emailmaker] show(): block ${String(n.id)} not found`);s!==void 0&&h.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(s.filter(D=>D.id!==void 0).map(D=>[D.id,Jt(D,String(h.id))])),this._prevCommand=void 0,this._lastShow=void 0;const g=h.id!==void 0?String(h.id):l.generateUUID(),_={id:a,token:++this._showToken};jt(this._container);const y=i?u.reloadBlock(g,h,_):u.openBlock(g,h,_);h.id;const m=t.requestShow({showId:a,navId:g,emailId:void 0,isNew:h.id===void 0});c=!0;const T=y.whenReady().catch(D=>{if(D instanceof Ie)throw D});await Te("show-block-init",Promise.all([m,T]),{showId:a})}catch(d){throw c&&t.failShow(a,d),d}}async _storeShownBlock(e){const t=Ne(e,this._container,await dt(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();l.throwIfAborted(e.signal);const t=se(this._container);if(Q(t.sessionKey())&&!t.hasSuspended())throw new Error("[emailmaker] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:pr,fallbackTitle:ns(this._container)});if(l.throwIfAborted(e.signal),!n)throw pm(t.emailSaveState().error);return ue(Ci(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=se(this._container),t=e.current();if(!t||!Q(e.sessionKey()))throw new Error("[emailmaker] saveBlock(): no open block");return rm(t,async()=>{await t.whenReady();const n=Bt(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}:{}},s=this._dataSources.blocks,i=await mm(t.get().serverId==null?s.create(o,{source:pr}):s.update(String(t.get().serverId),o,{source:pr}),a=>{a&&se(this._container).current()===t&&t.get().serverId==null&&a.id!==void 0&&t.markSaved(r,String(a.id))});if(!i)throw new Error("[emailmaker] save(): block was not saved");return t.markSaved(r,i.id!==void 0?String(i.id):void 0),le(i,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=Pi(e);const n=this._queuedShow(e,t).then(r=>r===Mi?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(),l.throwIfAborted(this._getInitPipeline().signal);const t=typeof e=="string"?{id:e}:e,n=t.id!==void 0&&t.id!==""?String(t.id):void 0,r=se(this._container);if(n!==void 0&&r.sessionKey()===At(n))return;const o=t.code===void 0&&n!==void 0?await Di(this._container,n):void 0,s=o&&hr(t)?await this._storeShownBlock({...le(o,this._container),...t}):t.code===void 0&&n!==void 0?o:await this._storeShownBlock(t);if(!s)throw new Error(`[emailmaker] openBlock(): block ${String(n)} not found`);jt(this._container);const i=r.openBlockOver(s.id!==void 0?String(s.id):l.generateUUID(),s);s.id,r.hasSuspended(),re(this._container,l.events.ON_BLOCK_OPEN_ID).fire({block:s}),await i.whenReady().catch(a=>{if(a instanceof Ie)throw r.current()===i&&(re(this._container,l.events.ON_BLOCK_CLOSE_ID).fire({block:s,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),vf(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 vm(e){return String(e).replace(/"/g,"&quot;")}function Em(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 _m(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=vm(n);return r.test(e)?e.replace(r,`${t}="${o}"`):e.replace(/>$/,` ${t}="${o}">`)}function bm(e,t,n){if(!e?.trim()||!t)return e;const r=_m(e);if(!r)return e;const o=String(t),s=Em(n??new Date);let{full:i,index:a}=r;const c=i.length;return/\bem-block-id\s*=/.test(i)||(i=xi(i,"em-block-id",o)),i=xi(i,"em-block-version",s),e.slice(0,a)+i+e.slice(a+c)}function ym(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 Sm(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:ym(e)}}function mr(e,t){return t?Sm(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Fi=["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"],wm=[...Fi,"html","id","project","password"],q_=new Set(["html",...Fi,"global_block","project"]);function Im(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(wm),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 Tm(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Im(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var gr=new WeakMap;function Cm(e){let t=gr.get(e);return t||(t={byId:new Map,fallback:[]},gr.set(e,t)),t}function Am(e){gr.delete(e)}function Dm(e,t){const{byId:n,fallback:r}=Cm(t);if(e.blockId){const o=n.get(e.blockId);if(o){n.delete(e.blockId);const s=r.indexOf(o);return s>=0&&r.splice(s,1),o}return}for(let o=r.length-1;o>=0;o--){const s=r[o],i=e.name!=null&&e.name!==""&&s.name!=null&&s.name!==""&&s.name===e.name,a=e.type!=null&&e.type!==""&&s.insertFrom===e.type;if(i&&a)return r.splice(o,1),s.id!=null&&s.id!==""&&n.delete(String(s.id)),s}}async function Pm(e,t){const{blocks:n}=ct(e);return await n.cache.getIfPresent(t)??void 0}async function Om(e,t){if(!t.blockId)return;const n=await Pm(e,t.blockId);if(n)return Tm(n,t)}async function Rm(e,t){const n=Dm(e,t);if(n)return mr(e,n);const r=await Om(t,e);return r?mr(e,r):mr(e,void 0)}var km=l.createIdentifier("application_block_inserted"),Nm=-1e3,Bi=new WeakSet;function Lm(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 Mm(e){if(!e||Bi.has(e))return;Bi.add(e);const t=new l.Disposable,n=ie(e);return t.addDisposable(n.addListenerAsyncPipe(km,async(r,o)=>{const s=Lm(r)?await Rm(r,e):r;return o?o(s):s},Nm)),t.addDisposable({dispose:()=>{Am(e)}}),t}var xm=Nt("plugin.readBlockAutosave"),K_=l.createIdentifier$1("blockDocuments.provided"),ji=l.createIdentifier$1("plugin.earlyWindow");function Fm(e){return e.getOrCreateInstance(ji,()=>({depth:0}))}function Bm(e){const t=Fm(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function Ui(e){return(e?.getInstance(ji)?.depth??0)>0}function Hi(e,t){let n,r=!1;return e(o=>{n=o,r=!0}),(o,s,i)=>{const a=e(o,s,i);if(r&&Ui(t)){const c=n;queueMicrotask(()=>{o.call(i,c)})}return a}}var vr=100,jm=class extends l.Disposable{_container;_events;constructor(e){super(),this._container=e;const t=Mm(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:o,blocksRevision:s}=ct(e),i=Y(e,l.events.ON_SHARE_ID),a=Y(e,l.events.ON_SHOW_PREVIEW_ID),c=Y(e,l.events.ON_EMAIL_CLONE_ID),d=Y(e,l.events.ON_BLOCK_OPEN_ID),u=Y(e,l.events.ON_BLOCK_CLOSE_ID),f=Y(e,l.events.ON_BLOCK_CLONE_ID),h=Y(e,l.events.ON_BLOCK_INIT_ID),g=Y(e,l.events.ON_BLOCK_CHANGED_ID),_=Y(e,l.events.ON_CODE_VALIDATE_ID),y=Y(e,l.events.ON_IMPORT_VALIDATE_ID),m=Y(e,l.events.ON_SUBJECT_CHANGED_ID),T=Y(e,l.events.ON_EMAIL_CHANGED_ID),D=Y(e,l.events.ON_PREHEADER_CHANGED_ID),B=Y(e,l.events.ON_SAVEBUTTON_CLICK_ID),M=Y(e,l.events.ON_BLOCK_SAVEBUTTON_CLICK_ID),C=Y(e,l.events.ON_NEXTBUTTON_CLICK_ID),E=Y(e,l.events.ON_SEND_LIVEPREVIEW_ID),b=Y(e,l.events.ON_SEND_TESTEMAIL_ID),w=Y(e,zh),O=Y(e,l.events.ON_CONTENT_CHANGED_ID),x=Y(e,Kh),A=Y(e,l.events.ON_PREVIOUSBUTTON_CLICK_ID),N=Y(e,l.events.ON_SEND_EMAIL_MODAL_ID),k=l.filter(Y(e,l.events.ON_EMAIL_INIT_ID),v=>!v.reset),P=Y(e,l.events.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:U(D),handleSubjectChanged:U(m),handleValidate:U(_),handleImportValidate:U(y),handleReadEmail:U(n.handlerRead,v=>v,v=>v&&qe(v,e)),handleSaveEmail:U(n.onSave,function({prev:v,patch:I,value:p,source:S}){const F=v?ue(v,e):void 0;return{prev:F,patch:it(F,ue(I,e)),value:ue(p,e),source:S}},v=>v?qe(v,e):void 0),handleRemoveEmail:U(n.onRemove,({value:v,source:I})=>({value:ue(v,e),source:I}),()=>{}),handleReadCommonBlocks:U(w,v=>v.project,v=>v?.map(I=>Ne(I,e))),handleReadTemplateBlocks:U(x,v=>v,v=>v?.map(I=>Ne(I,e))),handleReadBlocks:U(t.byForeignKey("project").handleRead,v=>lt(e).requested||String(v),v=>v?.map(I=>Ne(I,e))),handleReadBlock:U(t.handlerRead,v=>v,v=>v?Ne(v,e):void 0),handleOpenBlock:U(d,({block:v})=>({block:le(v,e)})),handleCloseBlock:U(u,({block:v,hasUnsavedChanges:I})=>({block:le(v,e),hasUnsavedChanges:I})),handleCloneBlock:U(f,v=>le(v,e)),handleSaveBlock:U(t.onSave,function({prev:v,patch:I,value:p,source:S}){const F=p.global_block===!0&&p.id&&typeof p.html=="string"?{...p,html:bm(p.html,String(p.id))}:p,V=v?le(v,e):void 0;return{prev:V,patch:it(V,le(I,e)),value:le(F,e),source:S}},v=>v?Ne(v,e):void 0),handleRemoveBlock:U(t.onRemove,({value:v,source:I})=>({value:le(v,e),source:I}),()=>{}),handleReadComments:U(r.byForeignKey("post").handleRead,v=>v,v=>v?.map(I=>ur(I,e))),handleSaveComment:U(r.onSave,function({prev:v,patch:I,value:p,source:S}){const F=v?ut(v,e):void 0;return{prev:F,patch:it(F,ut(I,e)),value:ut(p,e),source:S}},v=>v?ur(v,e):void 0),handleRemoveComment:U(r.onRemove,({value:v,source:I})=>({value:ut(v,e),source:I}),()=>{}),handleReadEmailRevisions:U(o.byForeignKey("parent").handleRead,v=>v,v=>v?.map(I=>Xt(I,e))),handleReadEmailAutosave:U(Y(e,ai),v=>v,v=>v?Xt(v,e):null),handleEmailAutosave:U(o.onSave,function({prev:v,patch:I,value:p,source:S}){return{value:fr(p,e),source:S}},v=>v?Xt(v,e):void 0),handleRemoveEmailAutoSave:U(o.onRemove,({value:v,source:I})=>({value:fr(v,e),source:I}),()=>{}),handleReadBlockRevisions:U(s.byForeignKey("parent").handleRead,v=>v,v=>v?.map(I=>Jt(I))),handleReadBlockAutosave:U(Y(e,xm),v=>v,v=>v?Jt(v):null),handleBlockAutosave:U(s.onSave,({value:v,source:I})=>({value:Li(v),source:I}),v=>v?Jt(v):void 0),handleRemoveBlockAutoSave:U(s.onRemove,({value:v,source:I})=>({value:Li(v),source:I}),()=>{}),handleBlockInit:U(h,v=>le(v,e)),handleBlockChanged:U(l.debounce(g,vr),v=>le(v,e)),handleEmailChanged:U(l.debounce(T,vr),v=>ue(v,e)),handleEmailInit:Hi(U(k,v=>ue(v,e)),e),handlePreviousButtonClick:U(A,v=>ue(v,e)),handleNextButtonClick:U(C,v=>ue(v,e)),handleSaveButtonClick:U(B,v=>ue(v,e)),handleSaveBlockButtonClick:U(M,v=>le(v,e)),handleHtmlChanged:U(l.debounce(O,vr)),handleTestEmailSend:U(b,({html:v,...I})=>({...I,code:v,compiled:{html:v,ampHtml:""}})),handleTestEmailModal:U(N,v=>ue(v,e)),handleCloneEmail:U(c,v=>ue(v,e)),handleShareEmail:U(i),handlePreviewEmail:U(a),handleLivePreviewEmail:U(E),handleAnalyticsEvent:U(P)}}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 Ye(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Um=l.createIdentifier$1("DataController"),Hm=l.createIdentifier$1("DataEvents");function $i(e){return e.getOrCreateInstance(Um,()=>{const t=new gm(e);return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(t),t})}function Vi(e){return e.getOrCreateInstance(Hm,()=>new jm(e))}var $m=l.createIdentifier$1("plugin.pluginStart");function Gi(e){return e.getOrCreateInstance($m,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>t()),{done:n,finish:t}})}function Vm(e){return Gi(e).done}function Gm(e){const t=Gi(e);return t.run===void 0&&(t.run=(e.getInstance(l.PLUGIN_COLLECTION_ID)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var Ym=l.createIdentifier$1("plugin.startupShow");function Wm(e){const t=$i(e),n=Vi(e),r=e.getInstance(l.OPTIONS_SOURCE_ID),o=e.getInstance(l.DISPOSABLE_ID),s={current:Promise.resolve()};e.inject(Ym,s);let i=!1;const a=r?.watch(d=>{d&&n.setOptions(d),i=(d?.plugins?.length??0)>0,s.current=s.current.catch(()=>{})}),c=r?.select(d=>d?.content).watch(d=>{if(d===void 0)return;const u=()=>(J(oe.showStart),t.show(d).finally(()=>J(oe.showEnd))),f=i?Vm(e).then(u):u();f.catch(()=>{}),s.current=f});a&&o?.addDisposable(a),c&&o?.addDisposable(c)}function qm(e){const t=$i(e);return{...Vi(e).get(),show(n){return J(oe.showStart),t.show(n).finally(()=>J(oe.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return J(oe.showStart),t.showBlock(n,r).finally(()=>J(oe.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function Yi(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function Qt(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",o=!1;for(let s=t;s<e.length;s++){const i=e[s];if(o){o=!1;continue}if(i==="\\"){o=!0;continue}if(r){i===r&&(r="");continue}if(i==='"'||i==="'"){r=i;continue}if(i==="("){n++;continue}if(i===")"&&(n--,n<0))return!1}return n===0}function Km(e){return(t,n,r)=>Qt(t)?e(t,n,r):!1}function zm(e){return t=>Qt(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Xm(e){return(t,n,r)=>Qt(t)?Yi(t)?e(t,n,r):t:!1}function Jm(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return Qt(n)?Yi(n)?e(t):t:!1}}function Qm(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function Er(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 Zm(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let o="";for(let s=0;s<e;s++){const i=r[s]%62;o+=t.charAt(i)}return o}var eg=8,tg=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=Zm(eg),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Zt=new tg;function Wi(e,t){return t!==void 0&&!Er(e,t)?`%|{${Zt.getOrCreateByKey(e)}}|%`:e}function ng(e){const t=Zt.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function ee(e,t,n){return t!==void 0?Er(e,t)?e:`%|{${Zt.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function rg(e){return e.replace(/&gt;/g,">").replace(/&lt;/g,"<").replace(/&amp;/g,"&")}function Z(e){return e.startsWith("<!--")&&e.endsWith("-->")?rg(e.slice(4,-3)):e}function og(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 s=r.trim();return t.test(s)||n.test(s)}function sg(e,t,n){return t!==void 0?Er(e,t)?e:`%|{${Zt.getOrCreateByKey(e)}}|%`:n||Qm(e)||og(e)?`<!--${e}-->`:e}var Le=Km(ee),Me=zm(Z),ig=Xm(ee),ag=Jm(Z),qi=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",ng),e.escape("@{","}",ee,!0).unescape("<!--@{","}-->",Z,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Wi,!0),e.escape("{{","}}",Wi,!0),e.createSyntax("brace-percent").escape("{%","%}",ee).unescape("<!--{%","%}-->",Z),e.createSyntax("brace-hash").escape("{#","#}",ee).unescape("<!--{#","#}-->",Z),e.createSyntax("proscript").escape("[%","%]",sg,!0).unescape("<!--[%","%]-->",Z,!0),e.createSyntax("getresponse").escape("[[IF","]]",ee).escape("[[if","]]",ee).escape("[[ELSE]]","",ee).escape("[[else]]","",ee).escape("[[ENDIF]]","",ee).escape("[[endif]]","",ee).unescape("<!--[[IF","]]-->",Z).unescape("<!--[[if","]]-->",Z).unescape("<!--[[ELSE]]","-->",Z).unescape("<!--[[else]]","-->",Z).unescape("<!--[[ENDIF]]","-->",Z).unescape("<!--[[endif]]","-->",Z),e.createSyntax("expert-sender").escape("<if",">",ee).escape("</if",">",ee).escape("<else",">",ee).escape("</else",">",ee).escape("<var ",">",ee,!0).unescape("<!--<if ",">-->",Z).unescape("<!--</if",">-->",Z).unescape("<!--<else ",">-->",Z).unescape("<!--</else",">-->",Z).unescape("<!--<var",">-->",Z,!0),e.createSyntax("velocity").escape("#if",")",Le).escape("#elseif",")",Le).escape("#else","",ee).escape("#foreach",")",Le).escape("#macro",")",Le).escape("#set",")",ig,!0).escape("#parse",")",Le).escape("#include",")",Le).escape("#evaluate",")",Le).escape("#end","",ee).escape("#break","",ee).escape("#stop","",ee).unescape("<!--#macro","-->",Me).unescape("<!--#if","-->",Me).unescape("<!--#elseif","-->",Me).unescape("<!--#else","-->",Z).unescape("<!--#foreach","-->",Me).unescape("<!--#parse","-->",Me).unescape("<!--#include","-->",Me).unescape("<!--#evaluate","-->",Me).unescape("<!--#end","-->",Z).unescape("<!--#break","-->",Z).unescape("<!--#stop","-->",Z).unescape("<!--#set","-->",ag,!0),e.createSyntax("mailchimp").escape("*|","|*",ee).unescape("<!--*|","|*-->",Z)},_r="bare",lg=new Map;function cg(e){return e?lg.get(e)??_r:_r}var Ki=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function zi(e){return Ki.includes(e)}function ft(e){return e==="bare"||e==="html-comment"}function br(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function dg(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!ft(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[d,u]of[["output",r.output],["editor",r.editor]])if(u!==void 0&&!ft(u))return t(`templateDirectives.${d}: unknown form "${String(u)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!br(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[d,u]of Object.entries(r.syntaxes))if(!(!zi(d)||u===void 0||ft(u))){if(!br(u))return t(`templateDirectives.syntaxes.${d}: expected a form or an object, configuration ignored.`),n;for(const f of["output","editor"]){const h=u[f];if(h!==void 0&&!ft(h))return t(`templateDirectives.syntaxes.${d}.${f}: unknown form "${String(h)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const o=r.output??_r;let s=r.editor;o==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),s=void 0);const i=[];if(r.syntaxes)for(const d of Object.keys(r.syntaxes)){if(!zi(d)){t(`templateDirectives.syntaxes: unknown syntax id "${d}", entry ignored.`);continue}i.push(d)}else i.push(...Ki);const a={},c={};for(const d of i){const u=r.syntaxes?.[d],f=br(u)?u:void 0,h=(ft(u)?u:f?.output)??o;let g=f?.editor??s??h;h==="bare"&&g==="html-comment"&&(t(`templateDirectives.syntaxes.${d}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),g="bare"),a[d]=h,c[d]=g}return{output:a,editor:c}}function Xi(e,t,n,r){for(let o=t;o<n;o++){const s=e[o];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?s===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(s)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):s==="<"?r.insideTag=!0:s===">"?r.insideTag=!1:r.insideTag&&(s==='"'||s==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=s,r.unquotedAttr=!1):r.insideTag&&/\S/.test(s)&&r.attributeQuoteChar===void 0&&e[o-1]==="="&&!['"',"'","`"].includes(s)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function pt(e,t){return e.start<t.end&&t.start<e.end}function Ji(e,t,n,r,o=[]){if(n&&(t=t.filter(u=>u.isVariable)),!t.length)return[];const s=t.flatMap(u=>u.match(e).flatMap(f=>!Number.isInteger(f.start)||!Number.isInteger(f.end)||f.start<0||f.end>e.length||f.start>=f.end?[]:[{range:f,mapFn:u.mapFn,overrideBuiltins:u.overrideBuiltins,syntax:u.syntax,isVariable:u.isVariable}])).sort((u,f)=>u.range.start-f.range.start||u.range.end-f.range.end),i=[],a=o.slice().sort((u,f)=>u.start-f.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let d=0;for(const{range:u,mapFn:f,overrideBuiltins:h,syntax:g,isVariable:_}of s){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):Xi(e,d,u.start,c),d=u.end,a.some(D=>pt(D,u)))continue;const y=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,m=e.substring(u.start,u.end),T=f(m,y,c.insideTag);T!==!1&&T!==m&&(i.push({range:u,text:T,overrideBuiltins:h,syntax:g,isVariable:_}),a.push(u))}return i.sort((u,f)=>u.range.start-f.range.start||u.range.end-f.range.end)}function ug(e,t){const n=t.reduce((a,{mapFn:c,start:d,end:u,syntax:f,isVariable:h})=>(a[d]||(a[d]=[]),a[d].push({value:u,mapFn:c,syntax:f,isVariable:h}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),o=new RegExp(r,"g"),s=[];let i;for(;(i=o.exec(e))!==null;){const a=i[0];s.push({start:i.index,startToken:a,endTokens:n[a]})}return s}function yr(e,t,n,r,o=!1){const s=[];if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return s;const i=ug(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let d=0;d<i.length;d++){const{start:u,startToken:f,endTokens:h}=i[d];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):Xi(e,c,u,a),c=u;const g=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let _=!1;for(const{mapFn:y,value:m,syntax:T,isVariable:D}of h){let B=u+f.length,M=e.indexOf(m,B);for(;M!==-1;){let C=M,E=u+f.length,b=0;for(;C!==-1;){const N=e.indexOf(f,E);if(N!==-1&&N<C)b++,E=N+f.length,C=e.indexOf(m,E);else if(b>0)b--,E=C+m.length,C=e.indexOf(m,E);else break}if(C<0)break;const w=C+m.length,O=e.substring(u,w),x=y(O,g,a.insideTag);if(x===!1){B=M+Math.max(m.length,1),M=e.indexOf(m,B);continue}(o||x!==O)&&s.push({range:{start:u,end:w},text:o?O:x,syntax:T,isVariable:D});const A=i.findIndex(({start:N})=>N>=w);A>d?d=A-1:d=i.length,_=!0;break}if(_)break}}return s}function en(e,t){if(!t.length)return e;const n=t.slice().sort((o,s)=>s.range.start-o.range.start);let r=e;for(const{text:o,range:s}of n)r=r.slice(0,s.start)+o+r.slice(s.end);return r}var fg=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=qi){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,o,s,i){return t.push({start:r,end:o,mapFn:s,isVariable:i,syntax:this.syntax||r}),this},unescape(r,o,s,i){return n.push({start:r,end:o,mapFn:s,isVariable:i,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 s={dispose:()=>{o||(o=!0,this._escapeMatchers=this._escapeMatchers.filter(i=>i!==n),this._unescapeMatchers=this._unescapeMatchers.filter(i=>i!==r))}};return this.addDisposable(s),s}_collectMappings(e,t,n){const r=yr(e,this._escapes,t,n),o=Ji(e,this._escapeMatchers,t,n),s=o.filter(c=>c.overrideBuiltins).map(c=>c.range),i=r.filter(c=>!s.some(d=>pt(d,c.range))),a=o.filter(c=>c.overrideBuiltins||!i.some(d=>pt(c.range,d.range)));return[...i,...a].sort((c,d)=>c.range.start-d.range.start||c.range.end-d.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=yr(e,this._unescapes,t),r=Ji(e,this._unescapeMatchers,t,!1),o=r.filter(a=>a.overrideBuiltins).map(a=>a.range),s=n.filter(a=>!o.some(c=>pt(c,a.range))),i=r.filter(a=>a.overrideBuiltins||!s.some(c=>pt(a.range,c.range)));return[...s,...i].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?o=>o!==void 0&&n.has(o):o=>cg(o)==="html-comment";return this._collectRevertMappings(e,t).filter(o=>o.isVariable||!r(o.syntax))}getDetectedMappings(e,t,n){return yr(e,this._escapes,t,n,!0)}getEscapedText(e,t){return en(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return en(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=s=>s===void 0?void 0:t[s],r=Object.values(t);let o=e;return r.includes("bare")&&(o=en(o,this._collectRevertMappings(o).filter(s=>n(s.syntax)==="bare"))),r.includes("html-comment")&&(o=en(o,this._collectMappings(o).filter(s=>!s.isVariable&&n(s.syntax)==="html-comment"&&s.text.startsWith("<!--")&&s.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 Qi(e){return e.replace("<script","<___script").replace("<\/script>","</___script>")}var Zi=new fg(e=>{e.escape("<script","<\/script>",t=>Qi(t)).unescape("<___script","</___script>",t=>t.replace("<___script","<script").replace("</___script>","<\/script>")),e.escape("<script","/>",t=>Qi(t)).unescape("<___script","/>",t=>t.replace("<___script","<script")),qi(e)});function pg(e){const t=dg(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return _s();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=>Zi.normalizeToPolicy(o,t.editor),toOutputForm:o=>Zi.normalizeToPolicy(o,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:Es(r)}}function hg(e){let t;e.injectFactory(l.TEMPLATE_DIRECTIVES_ID,()=>{const n=e.getInstance(l.CONFIG_SOURCE_ID)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:pg(n)}),t.policy})}function z_(e){return e}var mg=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function gg(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 vg(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 ea(e){const t=gg(e),n=[],r=new Set,o=[],s=new Set,i=a=>{if(!r.has(a)){if(s.has(a)){const c=o.indexOf(a);throw new mg([...o.slice(c),a].map(d=>d.name))}s.add(a),o.push(a);for(const c of vg(a,t))i(c);o.pop(),s.delete(a),r.add(a),n.push(a)}};for(const a of e)i(a);return n}var Eg=[{name:"rest.client",setup:Gh},{name:"auth.oauth",setup:l.provideOAuth},{name:"rest.identityHeaders",setup:Nh},{name:"rest.localeHeader",setup:jh},{name:"lifetime.destroyable",provides:[tr],setup:Lp},{name:"appInit",provides:[l.APP_ID,mn],setup:Cl},{name:"config",provides:[l.CONFIG_SOURCE_ID],setup:kp},{name:"templateDirectives",provides:[l.TEMPLATE_DIRECTIVES_ID],setup:hg},{name:"email.documents",setup:Zp},{name:"show.initPipeline",provides:[l.INIT_PIPELINE_ID],setup:Yh},{name:"show",setup:Wm},{name:"locale.service",provides:[We],setup:Ph},{name:"locale.fromConfig",awaits:{services:[l.CONFIG_SOURCE_ID,We]},setup:Oh},{name:"canvas.early",setup:Af},{name:"canvas.previewSettings",setup:Vf},{name:"canvas.sandboxExtensions",setup:Yf},{name:"canvas.sandboxScriptRelay",setup:Kf},{name:"canvas.headerSync",provides:[Wn],setup:Of},{name:"canvas.headersAfterRecovery",setup:Rf},{name:"canvas.ampSync",setup:Rd},{name:"canvas.moduleBridge",setup:lu},{name:"canvas.port",setup:Hd},{name:"canvas.images",setup:jd},{name:"canvas.edits",setup:Tf},{name:"canvas.surfaceFollowsSession",setup:_f},{name:"canvas.blockContent",setup:Ef},{name:"canvas.sandboxFill",provides:[Yn],setup:fp},{name:"canvas.reactions",setup:Cf}],ta;function Sr(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID);if(t)return t;e.getInstance(l.DISPOSABLE_ID)||e.inject(l.DISPOSABLE_ID,new l.Disposable);const n=ae();e.inject(l.OPTIONS_SOURCE_ID,n),ta??=ea(Eg);for(const r of ta)r.setup(e);return n}function _g(e){}var bg=[{name:"save.previewFollow",setup:_g}],na=l.createIdentifier$1("plugin.lateUnitsInstalled");function yg(e){if(!e.getInstance(na)){e.inject(na,!0);for(const t of ea(bg))t.setup(e)}}function Sg(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function wg(e){if(!e)return;const t=l.decodeJwt(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 Ig=l.defineMixin(e=>{let t,n,r;return{async setOptions(o){const s=r!==o.getAuthToken,i=!l.deepEqual(t,o.user),a=n!==o.project;if(r=o.getAuthToken,t=o.user,n=o.project,!(!e.getInstance(l.SECURITY_MODULE_ID)||!o.getAuthToken)&&!(!s&&!i&&!a))try{const c=await o.getAuthToken(o.user,o.project);e.inject(l.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(c||""));const d=wg(c);if(!d)return;e.inject(l.STANDALONE_PROJECT_ID,d);const u=e.getInstance(l.APP_ID),f=u?await u.catch(()=>{}):void 0;e.inject(l.APP_ID,Promise.resolve(Sg(d,f)))}catch{}}}});function Tg(e,t){if(e.getInstance(l.STANDALONE_FILE_PROXY_REGISTERED_ID))return;e.inject(l.STANDALONE_FILE_PROXY_REGISTERED_ID,!0);const n=l.getEvent(e,l.events.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var Cg=l.defineMixin(e=>{let t,n=!1;return{setOptions(r){const o=n;if(n=!0,!st(r)){t&&(bp(e),er(r)),t=void 0;return}const s=$t(r);if(!s||t===s&&e.getInstance(l.SECURITY_MODULE_ID))return;t=s,e.inject(l.SECURITY_MODULE_ID,s);const i=e.getInstance(l.DISPOSABLE_ID);i&&Tg(e,i)}}}),Ag=l.defineMixin(e=>{const t=e.getInstance(l.DISPOSABLE_ID),n=l.getEvent(e,l.APP_LOAD_EVENT_ID),r=U(n),o=t.addDisposable(new Ye(r));return{setOptions({handleLoad:s}){o.setListener(s)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function ra(e,t,n=!0){const r=e,o=t;for(const s of Object.keys(o)){const i=o[s];i!=null&&(n&&typeof i=="object"?r[s]=ra(r[s]||{},i,!0):r[s]=i)}return e}async function Dg(e){const t=(await Ja.__vitePreload(()=>Promise.resolve().then(()=>Promise.resolve(St("./static/umd/3f12d6ff.js")).then(n=>dn.__toESM(n.default))),void 0,{}.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var oa=l.createIdentifier$1("EditorOptions"),wr=l.MONACO_EDITOR_OPTIONS;function Pg(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 Og(e){return e.getOrCreateInstance(oa,()=>{const t=ae(wr);let n=wr.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(Dg(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function Rg(e){return e?.getInstance(oa)?.get()??wr}function kg(e,t={}){const n=Og(e);n.set(ra({...n.get()},Pg(t)))}function Ng(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 Lg(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var Mg=l.createIdentifier$1("plugin.publicConfig");function Ir(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.get()??{}}function sa(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function ia(e){const t=Gs(e),n=Ir(e);return{...n,locale:n.locale||"ru_RU",theme:n.theme||"light",editor:Lg(Rg(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function aa(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.get()!==void 0}function xg(e){const t=l.createQueue(),n=re(e,l.CONFIG_CHANGED_EVENT_ID);let r,o,s=!1;const i=async()=>{try{return e.getInstance(l.APP_ID)===void 0?{}:(await e.getInstanceAsync(l.APP_ID))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:f=!1}={})=>{await e.getInstance(l.CONFIG_SOURCE_ID)?.ready(),io(e).set(Ir(e).revisionService===!0);const{codeModeDirection:h,editor:g}=Ir(e);g&&kg(e,Ng(g)),h!==void 0&&!(f&&h===o)&&(o=h,h==="none"?zn(e,!1):(zn(e,!0),Bf(e,h)))},c=async()=>{if(!aa(e))return;const f=ia(e),h=JSON.stringify(f);h!==r&&(r=h,await n.fire(f))},d=async f=>{const h=e.getInstance(l.CONFIG_SOURCE_ID),g={advancedConfigs:sa(e).advancedConfigs,serverSide:await i(),user:f};h?.setAdvancedConfigs({...g.advancedConfigs,...g.user?.advancedConfigs});const _=h?.layers().user.mode;h?.replace(g.user?.mode===void 0&&_!==void 0?{...g.user,mode:_}:g.user,"user"),h?.replace(g.serverSide,"server"),await a(),await c()},u=f=>{const{commonStyles:h,...g}=f;return"commonStyles"in f&&Uf(e,h===void 0?void 0:h),g};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:i,getConfig:()=>aa(e)?ia(e):{},setConfig:t.decorate(async f=>{await d(u(f))}),updateConfig:t.decorate(async f=>{const h=u(f);await d({...sa(e).user,...h})}),announceAssembled(){s||(s=!0,e.getInstance(l.CONFIG_SOURCE_ID)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function la(e){return e.getOrCreateInstance(Mg,()=>xg(e))}function Fg(e){const t=la(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var Bg=l.defineMixin(e=>{const t=e.getInstance(l.DISPOSABLE_ID),n=t.addDisposable(new l.AsyncEmitter),r=t.addDisposable(new l.AsyncEmitter),o=l.getEmitter(e,l.CONFIG_CHANGED_EVENT_ID),s=U(n.event),i=U(r.event),a=Hi(U(o.event),e),c=t.addDisposable(new Ye(s)),d=t.addDisposable(new Ye(i)),u=t.addDisposable(new Ye(a));return{instance:{handleSetOptions:s,handleOptionsChanged:i,handleConfigChanged:a},async setOptions(f){c.setListener(f.handleSetOptions),d.setListener(f.handleOptionsChanged),u.setListener(f.handleConfigChanged),la(e).announceAssembled(),await n.fire(f),await r.fire(f)},dispose(){}}}),Tr,ca="core";function jg(){const e=__emailmaker__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([ca],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Ug(e){const t=__emailmaker__?.require?.warm;return typeof t!="function"?ht().then(()=>{}):t([ca],e)}function ht(){return Tr===void 0&&(Tr=jg().then(e=>(Je()&&e.installDiagnostics().catch(t=>{}),e))),Tr}var Cr=null,Ar=null;async function Hg(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Dr(){return Cr||(Cr=ht().then(()=>{})),Cr}function da(e){return Ar||(Ar=Hg(e)),Ar}function $g(){return da(typeof __emailmaker__<"u"?__emailmaker__:void 0)}function Vg(){const e=typeof __emailmaker__<"u"?__emailmaker__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function Gg(e){return Promise.all([Dr(),da(e)]).then(()=>{})}function Yg(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function ua(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Ug(t?{priority:t}:void 0)).then(()=>(Fn(t?{priority:t}:void 0),n?Dr():void 0)).catch(()=>{})}function Wg(e){const t=Yg(e);if(t==="eager")ua(e);else if(t==="idle"){const n=()=>ua(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var fa="PluginRegistry";function qg(e=l.resolveContainer()){return e.getOrCreateInstance(fa,()=>new sl)}var pa=new il(()=>qg()),Kg=["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"],zg=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],tn=new Map([...Kg.map(e=>[e,"event"]),...zg.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),Xg=new Map([["use","use `useAsync()` or await `ready` first"]]);function Jg(e){return Xg.get(e)??"await `ready` first"}var Qg=new Set(["async","queued"]),Zg=Symbol.for("emailmaker.earlyCtxPlaceholder");function ha(e){return e[Zg]=!0,e}function ev(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 (${Jg(e)}).`)}function tv(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function nv(e){return[...tn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function rv(e,t){for(const n of nv(e)){const r=tn.get(n);if(r!==void 0&&Qg.has(r)){const o=async(...s)=>{await t;const i=e[n];if(typeof i!="function"||i===o)throw tv(n);return i.apply(e,s)};e[n]=ha(o);continue}e[n]=ha(()=>{throw ev(n)})}}function ov(e,t,n){e.getInstanceAsync(Ke).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function sv(e,t){e.getInstanceAsync(Ke).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var iv=l.defineMixin(e=>{let t;function n(){return new Promise(o=>{const s=e.getOrCreateInstance(l.LATE_SURFACE_LISTENERS_ID,()=>new Set),i=()=>{s.delete(i),o()};s.add(i)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(o){const s=e.getInstance(l.INSTANCE_ID),i=e.getInstance(fa);if(!t){t=new ol(s,i,{ensureHostRuntimeReady:$g,explainScriptFailure:Vg,openEarlyWindow:()=>Bm(e),reportLoadFailure:d=>sv(e,d)}),e.inject(l.PLUGIN_COLLECTION_ID,t);const c=t.onLifecycle(d=>{d.type==="create:error"&&ov(e,d.name,d.error)});e.getInstance(l.DISPOSABLE_ID)?.addDisposable(c)}const a=o?.plugins||[];s&&(Xo(e),a.length>0&&rv(s,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}}}),ma=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}},av=l.createIdentifier$1("ELEMENT_INSERT_HTML_PIPELINE"),lv=l.createIdentifier$1("BLOCK_INSERT_HTML_PIPELINE"),cv="application_block_inserted",dv=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(lv,()=>new ma).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService),o=n?e.bind(n):e;return r.addListener(cv,o,t)}},Pr=l.createIdentifier$1("ComponentRegistry"),uv=l.createIdentifier$1("ComponentRegistryGate");function Or(){return l.DependencyResolver.getOrCreateInstance(uv,()=>({pending:[]}))}function fv(e=Pr){return Or().factory!==void 0||l.DependencyResolver.getInstance(e)!==void 0}function Rr(e,t,n=Pr){if(fv(n)){t(nn(e,n));return}Or().pending.push(()=>t(nn(e,n)))}function nn(e,t=Pr){const n=l.DependencyResolver.getInstance(t);if(n)return n;const r=Or().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return l.DependencyResolver.getOrCreateInstance(t,r)}var pv=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=s=>{if(!n){n=!0;for(const i of t)i.dispose();e(s)}};t.push(this._container.addService(l.ATOMS_HANDLERS_ID,{execute:s=>{r(s.value.map(i=>({name:i.name,html:i.html})))}}));const o=this._container.getInstance(l.HEADLESS_MODE_ID)?.watch(s=>{s&&r([])});o&&(n?o.dispose():t.push(o))})}update(e,t){const n=this._container;return n.addService(l.ATOMS_HANDLERS_ID,{execute:r=>{const o=nn(n),s=r.value.find(i=>i.name===e);if(s){const{icon:i,title:a,fallbackTooltip:c,...d}=t;i&&(s.icon=o.getReactNode(i)),a&&(s.title=o.getReactNode(a)),c&&(s.fallbackTooltip=o.getReactNode(c)),Object.assign(s,d)}}})}delete(e){this._container.addService(l.ATOMS_HANDLERS_ID,{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(l.ATOMS_HANDLERS_ID,{execute:r=>{const o=nn(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(av,()=>new ma).add(e,t??0,n)}handleInject(e,t,n){return l.getEmitter$1(this._container,l.HANDLE_ATOM_INSERT_ID).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},hv=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}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 mv(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function ga(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 gv=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=l.getEmitter$1(t,l.MODAL_SHOW_EVENT),this._closeModalEmitter=l.getEmitter$1(t,l.MODAL_CLOSE_EVENT),this._updateModalEmitter=l.getEmitter$1(t,l.MODAL_UPDATE_EVENT)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Rr(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:ga(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Rr(this._container,r=>{this._updateModalEmitter.fire(mv({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:ga(r,n)}))})}};function rn(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var vv=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)}},Ev=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}_createScriptHandle(e,t){const n=this._messageService.addListener(l.SANDBOX_EXTENSION_SCRIPT_STATUS_ID,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 vv(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(l.SANDBOX_EXTENSIONS_ID,{...rn(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(l.SANDBOX_EXTENSIONS_ID,{...rn(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(l.SANDBOX_EXTENSIONS_ID,{...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(l.SANDBOX_EXTENSIONS_ID,{...rn(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},_v=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function kr(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&_v.has(t)}function va(){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 Nr(){return`__settingsPanel:${va()}`}function Lr(e,t){return{type:e,props:t}}function bv(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!kr(e)}function Ea(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(kr(t)){const r=Nr();return n(e.add(r,t)),Lr(r,{})}if(typeof t=="function"){const r=Nr();return n(e.add(r,t)),Lr(r,{})}if(bv(t)){const r=t.type;if(typeof r=="string")return t;if(kr(r)||typeof r=="function"){const o=Nr();return n(e.add(o,r)),Lr(o,t.props)}return t}return t}var yv=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??va();Rr(this._container,n=>{const r=i=>this._trackRegistration(i),o=Ea(n,e.content,r),s=e.advancedTabs?.map(i=>({...i,content:Ea(n,i.content,r)}));l.getEmitter$1(this._container,l.SETTINGS_PANEL_EVENT).fire({...e,content:o,advancedTabs:s,instanceKey:t,type:l.ADVANCED_SETTINGS_PANEL})})}closeSettingsPanel(){this._clearPanelRegistrations(),l.getEmitter$1(this._container,l.SETTINGS_PANEL_EVENT).fire(null)}},_a={SandboxScriptApi:Ev,ElementsApi:pv,BlocksApi:dv,MessageService:hv,SettingsPanelApi:yv,ModalApi:gv};function Mr(e,t,n,r={}){const o=Object.assign({},e);for(const[s,i]of Object.entries(t))if(i!==void 0)if(n.includes(s)&&typeof i=="object"&&i!==null){const a=o[s],c=r[s]??{};o[s]=Object.assign({},typeof a=="object"&&a!==null?a:c,i)}else o[s]=i;return o}var pe={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}},Sv={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"},xr={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},ba={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},ze={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:pe.border,borderRadius:pe.borderRadius,textAlign:"center",padding:pe.padding},ya={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:pe.padding},Fr={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:pe.border,borderRadius:pe.borderRadiusCards};function wv(e){return{...Sv,...e}}function Iv(e){return{...xr,...e,bold:e?.bold??xr.bold,italic:e?.italic??xr.italic}}function Tv(e){return{...ba,...e,underline:e?.underline??ba.underline}}function Cv(e){return{...ze,...e,bold:e?.bold??ze.bold,italic:e?.italic??ze.italic,border:{...ze.border,...e?.border},borderRadius:{...ze.borderRadius,...e?.borderRadius},padding:{...ze.padding,...e?.padding}}}function Av(e){return{...ya,...e,padding:{...ya.padding,...e?.padding}}}function Dv(e){return{...Fr,...e,border:{...Fr.border,...e?.border},borderRadius:{...Fr.borderRadius,...e?.borderRadius}}}function Br(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 Sa(e){let t={...l.COMMON_STYLES};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function jr(e){return{text:wv(e.text),headings:Iv(e.headings),links:Tv(e.links),buttons:Cv(e.buttons),block:Av(e.block),cards:Dv(e.cards)}}var wa=l.createIdentifier$1("EmailSettingsPort"),Pv=1e4,Ia=class{_editor;_layoutSettingsChanged=new l.Emitter;_contentStylesChanged=new l.Emitter;_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(!Ui(this._editor.container)||!Be(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(wa);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Br(this._settings().read())}_getCurrentContentStyles(){const e=Be(this._editor.container)?.current()?.get().attributes.common_styles;return jr(Sa(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(wa),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService),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,s=o?.operation;if(s===l.EVENT_TYPES.APPLICATION_EMAIL_SETTINGS_SET){const c=Br(o?.settings),d=this._getLayoutSnapshot(c);d!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=d,this._layoutSettingsChanged.fire(c));return}if(s!==l.EVENT_TYPES.APPLICATION_COMMON_STYLES_UPDATE)return;const i=jr(r.data?.settings?.commonStyles??{...l.COMMON_STYLES}),a=this._getContentSnapshot(i);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(i))})})();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=Br(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Pv){const t=Be(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=l.getEvent(r,l.events.ON_EMAIL_INIT_ID);return new Promise(s=>{let i=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},d=o(()=>{i||(i=!0,c(),d.dispose(),s())});a=setTimeout(()=>{i||(i=!0,d.dispose(),s())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Be(this._editor.container)?.current();if(!t)return;const n=Sa(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=Mr(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:pe.border,borderRadius:pe.borderRadius,padding:pe.padding})),e.block!==void 0&&(n.block=Mr(n.block||{},e.block,["padding"],{padding:pe.padding})),e.cards!==void 0&&(n.cards=Mr(n.cards||{},e.cards,["border","borderRadius"],{border:pe.border,borderRadius:pe.borderRadiusCards}));const r=JSON.stringify(n);He(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const o=jr(n);this._prevContentSnapshot=this._getContentSnapshot(o),this._contentStylesChanged.fire(o)}},Ov={..._a,EmailSettingsApi:Ia},Rv={..._a},X_={...Rv,EmailSettingsApi:Ia},kv={...Ov};function Nv(){pa.addAll(kv)}var Lv=[l.defineMixin(()=>{Nv()}),Ag,Bg,Cg,l.JWTMixin,Ig,l.OAuthMixin];async function Mv(){return(await ht()).asyncMixins}var xv=iv,Fv=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let o;try{o=await Mv()}catch(i){throw e.failPendingWaits(i),i}t=o(e);const s=await e.getInstanceAsync(l.INSTANCE_ID);Object.assign(s,t.instance||{});for(const i of e.getInstance(l.LATE_SURFACE_LISTENERS_ID)??[])i()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},Bv=l.combineMixins([...Lv]);function Ur(){let e,t=!1;const n=new Map,r=new Map;function o(){for(const s of r.values())s();r.clear()}return{event(s,i,a){const c=Symbol("subscription");return t||(n.set(c,{listener:s,priority:i,thisArg:a}),e&&r.set(c,e(s,i,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(s){o(),e=s;for(const[i,{listener:a,priority:c,thisArg:d}]of n)r.set(i,s(a,c,d))},dispose(){t=!0,o(),n.clear(),e=void 0}}}function jv(e){const t=Ur(),n=Ur(),r=Ur();return e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(Ke).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 s=e.getInstance(Ke);if(s){s.notify(o);return}e.getInstanceAsync(Ke).then(i=>i.notify(o),()=>{})}}}var Ta=l.createIdentifier$1("CodeErrors"),Uv=[];function Hv(e){return e?.getInstance(Ta)?.get()??Uv}function $v(e){return e?.getInstance(Ta)!==void 0}var Vv=class extends l.Disposable{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=ct(e),this.addDisposable(l.getEvent(e,l.events.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){const e=Ae(this._container);if(e&&Q(e.sessionKey())&&!e.hasSuspended())throw new Error("[emailmaker] no open email: only a block is shown");return Ci(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=>le(t,this._container))}async _readProjectBlocks(){const e=await Ai(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=>ut(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=>fr(n,this._container))}async getEmailSnapshot(){return ue(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Ae(this._container),t=e?.current();return!e||!t||!Q(e.sessionKey())?null:(await t.whenReady(),le(Bt(t),this._container))}setEmailMeta(e){const t=cr(this._container);if(!t)return;const n=t.get().attributes.meta;He(t,{meta:Vt({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,o=>o&&Vt(o,e))}setBlockMeta(e,t){const n=Ae(this._container);if(n?.sessionKey()===At(e)){const o=n.current();o&&He(o,{meta:Vt({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,s=>s&&Vt(s,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return $v(this._container)?Hv(this._container):void 0}},Gv=l.createIdentifier$1("EmailDataController");function Yv(e){return e.getOrCreateInstance(Gv,()=>{const t=new Vv(e);return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(t),t})}function Wv(e){const t=Yv(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 qv(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 Kv(e){let t;const n=ri(e),r=l.getEvent(e,l.events.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:s})=>{t=s}));const o=()=>t?qv(t):void 0;return{undoRedoService:{undo:()=>o()?.undo(),redo:()=>o()?.redo(),clear:()=>o()?.clear(),getPast:s=>o()?.getPast(s)??[],getFuture:s=>o()?.getFuture(s)??[],canUndo:()=>o()?.canUndo()??!1,canRedo:()=>o()?.canRedo()??!1,createSnapshot:()=>o()?.createSnapshot(),restoreSnapshot:s=>o()?.restoreSnapshot(s)}}}var zv=l.createIdentifier$1("plugin.mountElement");function Xv(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function Jv(e){return e.getOrCreateInstance(zv,()=>{let t=!1,n;return{get:()=>t?n:Xv(e),set(r){t=!0,n=r}}})}function Qv(e){const t=Jv(e);return{getElement:()=>t.get()}}function Zv(e){return{handleLoadImage:U(l.getEvent(e,l.events.UPLOAD_EVENT_ID)),handleFileProxy:U(l.getEvent(e,l.events.FILE_PROXY_EVENT_ID)),handleUrlProxy:U(l.getEvent(e,l.events.PROXY_URL_EVENT_ID)),handleAITextRequest:U(l.getEvent(e,l.events.AI_TEXT_REQUEST_ID)),handleAIImageRequest:U(l.getEvent(e,l.events.AI_IMAGE_REQUEST_ID)),handleReadLocale:U(l.getEvent(e,l.events.READ_LOCALE)),handleLimitUsage:U(l.getEvent(e,l.events.ON_LIMIT_ID)),handleTranslate:U(l.getEvent(e,l.events.ON_TRANSLATE_ID))}}var eE=[Mp,qm,jv,Fg,Wv,Kv,Qv,Zv];function tE(e,t=eE){const n=Sr(e);yg(e);const r=Bv(e),o=xv(e),s=Fv(e),i={...r.instance,...o.instance,...s.instance};for(const c of t)Object.assign(i,c(e));let a=!0;return{instance:i,async setOptions(c){await r.setOptions(c);const d=a&&n.get()===c;a=!1,d||n.set(c),await o.setOptions(c),await s.setOptions(c)}}}function nE(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 rE=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]}},oE="editor-runtime.react.copies",Hr=8;function mt(e){return e&&typeof e=="object"?e:void 0}function Ca(e){const t=mt(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=mt(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function sE(e){const t=mt(e),n=t&&typeof t.version=="string"?t.version:void 0,r=mt(t?.default),o=r&&typeof r.version=="string"?r.version:void 0;return n??o??"unknown"}function iE(e,t,n){return e.package===t&&e.version===n}function aE({ourReact:e,entries:t,packageName:n,version:r}){const o=Ca(e);if(!o||!Array.isArray(t))return[];const s=[],i=new Set;for(const a of t){const c=mt(a);if(!c||!iE(c,n,r))continue;const d=Ca(c.react);!d||d===o||i.has(d)||(i.add(d),s.push({package:n,version:r,reactVersion:sE(c.react),react:c.react}))}return s}function lE({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,Hr))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Hr&&n.push(` …and ${t.length-Hr} 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(`
2153
+ `)}var Aa=new Set;function cE({packageName:e="@emailmaker/emailmaker",version:t="1.2.0",log:n=r=>{}}={}){const r=o=>{try{const s=globalThis[Symbol.for(oE)],i=aE({ourReact:o,entries:s,packageName:e,version:t}).filter(a=>!Aa.has(a.react));if(!i.length)return;i.forEach(a=>Aa.add(a.react)),n(lE({packageName:e,copies:i}))}catch{}};try{const o=pn()?.modules?.React;if(o&&typeof o.then=="function"){o.then(r,()=>{});return}r(o)}catch{}}async function dE(e,t,n){l.throwIfAborted(e.signal);const r=t??l.DependencyResolver.createChild();Sr(r);const o=r.getInstance(l.DISPOSABLE_ID);let s;async function i(){r.inject(l.COOKIE_MANAGER_ID,nE(new rE)),cE();const a=tE(r),c={...a.instance,container:r,get ready(){return s??Promise.resolve(c)},async reset(d){if(l.throwIfAborted(d.signal),o.isDisposed())throw _e();return await a.setOptions(d),c}};r.inject(l.INSTANCE_ID,c);try{if(n?.onInstance?.(c),await a.setOptions(e),l.throwIfAborted(e.signal),o.isDisposed()||await Gm(r),e.devTools)try{const d=r.getInstance(l.PLUGIN_COLLECTION_ID);d&&await(await ht()).initDevTools(r,d)}catch{}return l.throwIfAborted(e.signal),l.getEmitter(r,l.APP_LOAD_EVENT_ID).fire(c),c}catch(d){throw o.dispose(),d}}try{return s=l.raceWithAbortSignal(i(),e.signal),s.catch(()=>{}),await s}catch(a){throw o.isDisposed()||o.dispose(),a}}var gt=new WeakMap;function uE(e){return e?gt.get(e):void 0}function Da(e){try{e.getInstance(l.DISPOSABLE_ID)?.dispose()}catch{}try{e.dispose()}catch{}}function fE(e,t){if(!e)return;const n=gt.get(e);n&&n!==t&&Da(n),gt.set(e,t)}function pE(e,t){e&&gt.get(e)===t&&gt.delete(e)}function hE(e){const t=l.DependencyResolver.createChild();return st(e)&&t.inject(l.SECURITY_MODULE_ID,$t(e)),t}var vt=new WeakMap,mE="data-emailmaker-config-styles";function gE(e){return typeof e=="string"?e.trim():""}function Pa(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function vE(e,t,n){if(!e||typeof document>"u")return null;const r=gE(t),o=vt.get(e),s=n||e;if(!r)return o&&(o.remove(),vt.delete(e)),null;if(o)return o.textContent!==r&&(o.textContent=r),(o.parentNode!==s||o!==s.firstChild)&&Pa(s,o),o;const i=document.createElement("style");return i.setAttribute(mE,"true"),i.textContent=r,Pa(s,i),vt.set(e,i),i}function EE(e){if(!e)return;const t=vt.get(e);t&&(t.remove(),vt.delete(e))}var J_=!1;function Oa(){return!1}var Q_=28,_E=`
2154
2154
  .blocks-app-initial-spinner-wrapper {
2155
2155
  width: 100%;
2156
2156
  height: 100%;
@@ -2179,11 +2179,11 @@ __emailmaker__.define("emailmaker.js",["require","exports","module","static/umd/
2179
2179
  100% {
2180
2180
  transform: rotate(360deg);
2181
2181
  }
2182
- }`;function bE(){return()=>{}}function yE(e,t){if(!Oa()||!e||typeof document>"u")return bE();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.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=_E,document.head?.appendChild(o),e.appendChild(n);let s=!1;return()=>{s||(s=!0,n.remove(),o.remove())}}function SE(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function wE({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,s){const i=t.get(o);if(i!==void 0)return i;const a=s().catch(c=>{throw n.has(o)||(n.add(o),r(c)),SE(c)||t.delete(o),c});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var $r=wE();function Ra(){$r.clear()}l.setApiOriginFailoverHook(()=>$r.clear());var ka=new WeakMap;function Vr(e){return l.resolveExplicitApiBaseUrl(e)}function IE(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function TE(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function CE(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 Gr=new WeakMap;function Wr(e,t){Gr.set(e,t)}function AE(e){return Gr.get(e)}function DE(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&Gr.get(r)||e,s=Vr(n);if(!s)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await CE(o);if(o.getAuthToken&&!a)throw TE();a&&i.set("authorization",a);const c=await l.fetchWithApiOriginFailover("/app/v1/app_init",{method:"POST",headers:i,body:new URLSearchParams,credentials:"same-origin"},s,{attemptTimeout:er(o)||void 0});if(!c.ok)throw IE(c.status,c.statusText);return await c.json()}}function PE(e){return JSON.stringify({baseUrl:Vr(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function OE(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function RE(e){return t=>$r.run(PE(t),()=>(J("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>J("appInit:end",{kind:"network"}))))}function kE(e,t){if(st(e)||!e.appInit&&!Vr(e.baseUrl)||!OE(e))return e;const n=e.appInit??DE(e,t);let r=ka.get(n);return r||(r=RE(n),ka.set(n,r)),{...e,appInit:r}}var La=0;function LE(){return La}function NE(){La+=1,Ra()}var Na=new WeakMap,Ma=new WeakMap,ME=3e4;function xE(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function FE(e,t){try{const n=l.decodeJwt(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+ME}function BE(e){const t=new Map,n=new Map;return async(r,o,s)=>{const i=xE(r,o);if(s)return n.delete(i),t.delete(i),Ra(),e(r,o,s);const a=n.get(i);if(a&&!t.has(i)){if(a.expiresAtMs>Date.now())return a.token;n.delete(i)}let c=t.get(i);return c===void 0&&(J("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,o,s)).then(d=>{const u=String(d||"").trim();return u&&n.set(i,{token:d,expiresAtMs:FE(u,Date.now())}),d}).finally(()=>{J("authToken:end",{kind:"network"}),t.delete(i)}),t.set(i,c)),c}}function jE(e){if(st(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Na.get(t);const r=LE();return(!n||Ma.get(t)!==r)&&(n=BE(t),Na.set(t,n),Ma.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var UE="[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 HE(e){const t=new Error(UE,{cause:e});return t.name="EditorStartFailedError",t}var $E={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function xa(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var Fa=["handleLoad","handleDestroy"];function Ba(e,t){let n=e;for(const r of Fa){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(s,...i)=>o(t,...i)})}return n}function VE(e){let t,n="pending",r,o,s,i;const a=new Set,c=[],d=new Set;let u,f;const h=new Promise((A,p)=>{u=A,f=p});h.catch(()=>{});const v={},_=A=>t?.[A],y=()=>r??_e(),m=(A,p)=>{const S=_(A);if(typeof S!="function")throw xa(A);return S.apply(t,p)},T=(A,p)=>{try{return Promise.resolve(m(A,p))}catch(S){return Promise.reject(S)}},P=()=>{const A=t?.container?.getInstance?.(l.DISPOSABLE_ID);if(!(n!=="ready"||A?.isDisposed()||typeof _("getConfig")!="function"))try{i=m("getConfig",[])}catch{}},F=()=>n==="dead"?Promise.reject(y()):n==="ready"?Promise.resolve():h,N=()=>{for(const[A,p]of tn)p==="field"&&(v[A]=_(A))},C=A=>{const p=_(A.name);A.dispose||typeof p!="function"||n==="dead"||(A.dispose=p.apply(t,A.args))},E=()=>a.forEach(C),b=()=>{for(const A of a){try{A.dispose?.()}catch{}A.dispose=void 0}},w=()=>{N(),E()},O=()=>{s?.delete(w),s=void 0},M=(A,p)=>{const[S,...B]=p;return!Fa.includes(A)||typeof S!="function"?p:[(V,...$)=>S(v,...$),...B]},D=(A,p)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof _(A)!="function")throw xa(A);const S={name:A,args:M(A,p)};return a.add(S),C(S),()=>{a.delete(S),S.dispose?.(),S.dispose=void 0}},k=()=>t?.container?.getInstance(l.OPTIONS_SOURCE_ID)?.get()?.content,g=()=>{const A=e.element();return A!==void 0&&typeof A!="string"?A:void 0},I=(A,p)=>{switch(p){case"event":return(...S)=>D(A,S);case"async":return(...S)=>(A==="show"&&S[0]!==void 0&&e.shown?.(S[0]),n!=="dead"&&typeof _(A)=="function"?T(A,S):F().then(()=>m(A,S)));case"queued":return(...S)=>{if(n==="dead"){if(A==="notify")return;throw y()}if(n==="pending"){c.push({name:A,args:S});return}return m(A,S)};case"sync":return(...S)=>{if(n==="dead"){if(A==="getConfig")return i;throw y()}if(typeof _(A)!="function")throw new Error(`[emailmaker] \`${A}\` is not available before the editor is ready: ${$E[A]??"await `ready` first"}`);const B=m(A,S);return A==="getConfig"&&(i=B),B};case"element":return()=>{if(typeof _(A)!="function")return g();try{return m(A,[])}catch{return g()}};case"codeErrors":return()=>n==="ready"&&typeof _(A)=="function"?m(A,[]):[];case"field":return}};for(const[A,p]of tn)v[A]=I(A,p);v.reset=A=>(A?.content!==void 0&&e.shown?.(A.content),F().then(async()=>{const p=A?.content!==void 0&&l.deepEqual(A.content,k());await m("reset",[Ba(A,x)]),p&&await m("show",[A.content])}).then(()=>v)),v.destroy=()=>{if(n==="dead")return;const A=l.createAbortError("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),d.forEach(p=>p(A)),P(),e.destroy()},Object.defineProperty(v,"ready",{get:()=>o,enumerable:!0,configurable:!0});const x=v;return{object:x,get state(){return n},get editor(){return t},bind:A=>{n==="dead"||t===A||(b(),O(),t=A,N(),E(),n==="pending"&&(s=A.container.getOrCreateInstance(l.LATE_SURFACE_LISTENERS_ID,()=>new Set),s.add(w)))},settle:()=>{if(n==="pending"){n="ready",O(),N(),E();for(const A of c.splice(0))try{m(A.name,A.args)}catch(p){queueMicrotask(()=>{throw p})}u()}},kill:(A,p)=>{n!=="dead"&&(P(),n="dead",r=A,c.length=0,d.forEach(S=>S(A)),O(),p?.keepSubscriptions||(b(),a.clear()),f(A))},detach:()=>{b(),a.clear()},setReady:A=>{o=A},trackCall:A=>(d.add(A),()=>d.delete(A)),hasCalls:()=>d.size>0}}var Yr="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function GE(){return l.createAbortError(Yr)}function ja(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Yr}function WE(e,t,n){if(typeof document>"u")return;let r=!1,o;const s=()=>{r=!0,o?.disconnect(),o=void 0},i=()=>{r||(s(),t())};if(n.addDispose(s),!e.isConnected){queueMicrotask(i);return}o=new MutationObserver(()=>{e.isConnected||i()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function YE(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const s=new AbortController;return WE(n,()=>{n.id,s.abort(GE())},o),l.composeAbortSignals(r,s.signal)}var qr="Superseded by newer init() on the same mount element";function Ua(){return l.createAbortError(qr)}function Ha(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===qr}var Et=new Map,$a=new WeakMap,on=new WeakMap;function qE(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function zE(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=qE(e);(n?Et.get(n):void 0)?.forEach(u=>{u.element!==e&&u.controller.abort(Ua())});const r=$a.get(e)??new Set;t&&r.forEach(u=>{u.supersedable&&u.controller.abort(Ua())});const o=on.get(e)??Promise.resolve();let s;const i=new Promise(u=>{s=u}),a=o.then(()=>i);on.set(e,a),a.then(()=>{on.get(e)===a&&on.delete(e)});const c=new AbortController,d={element:e,controller:c,supersedable:t};if(r.add(d),$a.set(e,r),n){const u=Et.get(n)??new Set;u.add(d),Et.set(n,u)}return{signal:c.signal,previous:o,release:()=>{s(),r.delete(d);const u=n?Et.get(n):void 0;n&&u?.delete(d)&&u.size===0&&Et.delete(n)}}}var _t=new WeakMap;function zr(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function Kr(e){return Object.entries(e).filter(([t,n])=>zr(t,n)).map(([t])=>t).sort()}function Va(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!zr(n,r)&&(t[n]=r);return t}function Xr(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:_t.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},_t.set(e,r));const{current:o,trampolines:s}=r;o.clear();const i={...t};for(const a of Kr(t)){o.set(a,t[a]);let c=s.get(a);c||(c=(...d)=>o.get(a)?.(...d),s.set(a,c)),i[a]=c}return r.lastOptions=t,i}function Ga(e,t){const n=e?_t.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];zr(r,o)?n.current.set(r,o):n.current.delete(r)}}function KE(e){const t=e?_t.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,s)=>t.current.set(s,o)),t.lastOptions=r}}function XE(e,t,n){const r=e?_t.get(e):void 0;if(!r||!n)return!1;const o=Kr(t),s=l.deepEqual(o,Kr(r.lastOptions)),i=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!s||!i||!l.deepEqual(Va(t),Va(r.lastOptions))?!1:(Xr(e,t),!0)}var me=new WeakMap,Z_=0;function sn(e){let t=me.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},me.set(e,t)),t}var ye=e=>e!==void 0&&e.state!=="dead";function JE(e){const t=me.get(e)?.shared;return ye(t)?t:void 0}function QE(e,t){sn(e).shared=t}function ZE(e,t){!(ye(e.shared)&&[...e.counted].some(ye))||e.warned||!t.devTools||(e.warned=!0)}function e_(e,t,n,r){const o=sn(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(s=>s.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(s=>s!==t&&ye(s)),t],ZE(o,r),o.latestCall}function t_(e,t){return me.get(e)?.latestCall===t}function n_(e){const t=me.get(e);if(t)return t.order=t.order.filter(ye),t.order.at(-1)?.object}function bt(e,t){const n=me.get(e);return n?ye(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&ye(r)):!1}function r_(e,t){const n=me.get(e),r=n?.order.filter(o=>o!==t&&ye(o)).at(-1);return r?n?.options.get(r):void 0}function Wa(e,t){sn(e).content={value:t}}function o_(e){return me.get(e)?.content}function s_(e,t,n,r){const o=sn(e);if(o.counted.delete(t),o.options.delete(t),bt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),Ya(e,r)}function Ya(e,t){const n=me.get(e);!n||bt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!bt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function i_(e,t){const n=me.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);me.delete(e)}}var a_=dn.__exportAll({FileManagerApiError:()=>l_,IntegratorSaveTimeoutError:()=>Ct,SaveRefusedError:()=>et}),l_=class Xa 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,Xa)}},c_=dn.__exportAll({mapHttpStatusToErrorCode:()=>l.mapHttpStatusToErrorCode});function d_(e,t){return{...e,element:t}}function Jr(){return()=>{}}function u_(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Jr():(vE(t,e.config?.styles,t),()=>{EE(t)})}function f_(e){if(!Oa()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Jr()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Jr()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=yE(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function p_(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function an(e){try{e.destroy()}catch{}}function ln(e,...t){const n=l.ELEMENT_MAP.get(e);t.some(r=>r!==void 0&&r===n)&&l.ELEMENT_MAP.delete(e)}var h_="1.1.108";async function m_(e){Fn(),await Gg(typeof __emailmaker__<"u"?__emailmaker__:void 0)}async function g_(e){return qa(e).ready}function v_(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function E_(e){const t=l.ELEMENT_MAP.get(e);return t&&!(t instanceof Promise)?t:void 0}function cn(e,t,n){const r=t??E_(e);r&&(ln(e,r),an(r)),i_(e,n)}function __(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const i=t.editor;b_(i),t.kill(_e());return}if(n==="single"){cn(o,t.editor,_e());return}const s=r_(o,t);s_(o,t,_e(),()=>cn(o,t.editor,_e())),s&&bt(o)&&Ga(o,s)}function b_(e){e&&an(e)}function qa(e){J(oe.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=l.composeAbortSignals(e.signal,n.signal),o=t==="single"?v_(e.element):void 0,s=o?JE(o):void 0;let i;if(s)i={control:s,mode:t,ref:{host:o}};else{const u={},f=VE({element:()=>u.host??e.element,destroy:()=>__(i),shown:h=>{u.host&&Wa(u.host,h)}});i={control:f,mode:t,ref:u},o&&QE(o,f)}const{control:a}=i,c=a.trackCall(u=>n.abort(u)),d=C_(Ba({...e,signal:r},a.object),i).then(()=>(c(),J(oe.initEnd),a.settle(),a.object),u=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(u);const f=i.ref.host;throw f&&Ya(f,()=>cn(f,void 0,_e())),u});return a.setReady(d),a.object}function y_(e){const t=typeof e=="string"?document.querySelector(e):e;return t?n_(t):void 0}function S_(e){let t,n,r=!1;try{t=e.container.getInstance(l.OPTIONS_SOURCE_ID)?.get(),n=e.container.getInstance(l.INIT_PIPELINE_ID)?.externalSignal;const o=Be(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:w_(e),dirty:r}}async function w_(e){try{return await e.getEmailSnapshot()}catch{return}}function I_(e){const t=Be(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function za(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||bt(e,n)}async function T_(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),Ha(o)||ja(o))return;const s=()=>cn(t,e,HE(o)),{options:i}=n;if(!i||!za(t,r)){s();return}const a=await n.email,c=a&&(i.content!==void 0||a.id!==void 0)?a:void 0,d=typeof i.content=="object"&&"email"in i.content?i.content:void 0;try{await e.reset({...i,signal:i.signal??n.signal,content:c?{...d,email:c}:i.content}),n.dirty&&c&&I_(e),za(t,r)?l.ELEMENT_MAP.set(t,e):s()}catch{s()}}async function C_(e,t){l.throwIfAborted(e.signal);const n=new l.Disposable;let r,o,s,i,a=0;try{const c=await l.waitForElement(e.element,n,e.signal);c&&(i=c,t.ref.host=c,a=e_(c,t.control,t.mode,e));const d=YE({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),u=zE(c,{supersede:t.mode==="single"});r=u.release;const f=l.composeAbortSignals(d,u.signal);l.throwIfAborted(f),s=KE(c),Ga(c,e),await l.raceWithAbortSignal(u.previous,f),o=A_(e,c,t,f,s);const h=await l.raceWithAbortSignal(o,f);return c&&e.content!==void 0&&Wa(c,e.content),h}catch(c){throw i&&s&&t_(i,a)&&s(),c}finally{const c=r;o!==void 0&&c?o.then(c,c):c?.(),n.dispose()}}async function Ka(e,t,n,r){const o=o_(t);n===void 0||r||!o||l.deepEqual(n,o.value)||await e.show(n)}async function A_(e,t,n,r,o){const{control:s}=n,i=y=>s.bind(y);l.throwIfAborted(r);let a;const c=y=>{NE();const m=jE(d_(y,t)),T=kE(m,()=>a);return{preparedOptions:T,preparedOptionsWithSignal:r!=null?{...T,signal:r}:T}};let d;if(t){const y=l.ELEMENT_MAP.get(t);if(y){let m;try{m=await y,l.throwIfAborted(r)}catch{l.throwIfAborted(r),ln(t,y),m=void 0}if(m)if(m.getElement()===t){const T=uE(t);a=T;const P=m.container.getInstance(l.OPTIONS_SOURCE_ID)?.get();if(XE(t,e,P))return i(m),r&&m.container.getInstance(l.INIT_PIPELINE_ID)?.relinkExternalSignal(r),l.ELEMENT_MAP.set(t,m),await Ka(m,t,e.content,!1),m;const F=!l.deepEqual(e.content,P?.content);d=c(Xr(t,e));const{preparedOptions:N,preparedOptionsWithSignal:C}=d,E=T&&AE(T),b=S_(m);try{T&&Wr(T,N),i(m);const w=await m.reset(p_(e,C));return l.throwIfAborted(r),l.ELEMENT_MAP.set(t,m),await Ka(m,t,e.content,F),w}catch(w){if(T&&E&&Wr(T,E),!yl(w))throw o(),await T_(m,t,b,n,w),w;ln(t,y,m),an(m),l.throwIfAborted(r)}}else ln(t,y,m),an(m)}}l.throwIfAborted(r),d??=c(Xr(t,e,{fresh:!0}));const{preparedOptions:u}=d,f=u_(u),h=f_(u),v=r!=null?{...h.options,signal:r}:h.options;let _;try{a=hE(v),fE(t,a),Wr(a,u),Sr(a).set(v),await Dr(),J(oe.coreReady),l.throwIfAborted(r),l.throwIfAborted(r),_=dE(v,a,{onInstance:i}),t&&l.ELEMENT_MAP.set(t,_);const y=await _;if(r?.aborted&&(y.destroy(),l.throwIfAborted(r)),t)if(l.ELEMENT_MAP.get(t)===_)l.ELEMENT_MAP.set(t,y);else throw y.destroy(),l.throwIfAborted(r),l.createAbortError(r?.reason);return y}catch(y){throw f(),h.cleanup(),a&&(Da(a),pE(t,a)),t&&_&&l.ELEMENT_MAP.get(t)===_&&l.ELEMENT_MAP.delete(t),y}}async function D_(e){return(await ht()).parseAMP(e)}typeof window<"u"&&(Je()&&_l(),Yg(typeof __emailmaker__<"u"?__emailmaker__:void 0)),de.ELEMENT_DETACHED_ABORT_MESSAGE=Yr,de.SUPERSEDED_INIT_ABORT_MESSAGE=qr,de.create=qa,Object.defineProperty(de,"errors",{enumerable:!0,get:function(){return a_}}),de.getInstance=y_,Object.defineProperty(de,"helpers",{enumerable:!0,get:function(){return c_}}),de.init=g_,de.isElementDetachedError=ja,de.isSupersededInitError=Ha,de.parseAMP=D_,de.pluginRegistry=pa,de.preload=m_,de.version=h_});
2182
+ }`;function bE(){return()=>{}}function yE(e,t){if(!Oa()||!e||typeof document>"u")return bE();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.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=_E,document.head?.appendChild(o),e.appendChild(n);let s=!1;return()=>{s||(s=!0,n.remove(),o.remove())}}function SE(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function wE({report:e}={}){const t=new Map,n=new Set,r=e??(o=>{});return{run(o,s){const i=t.get(o);if(i!==void 0)return i;const a=s().catch(c=>{throw n.has(o)||(n.add(o),r(c)),SE(c)||t.delete(o),c});return t.set(o,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var $r=wE();function Ra(){$r.clear()}l.setApiOriginFailoverHook(()=>$r.clear());var ka=new WeakMap;function Vr(e){return l.resolveExplicitApiBaseUrl(e)}function IE(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function TE(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function CE(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 Gr=new WeakMap;function Yr(e,t){Gr.set(e,t)}function AE(e){return Gr.get(e)}function DE(e,t){return async({baseUrl:n})=>{const r=t(),o=r&&Gr.get(r)||e,s=Vr(n);if(!s)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await CE(o);if(o.getAuthToken&&!a)throw TE();a&&i.set("authorization",a);const c=await l.fetchWithApiOriginFailover("/app/v1/app_init",{method:"POST",headers:i,body:new URLSearchParams,credentials:"same-origin"},s,{attemptTimeout:er(o)||void 0});if(!c.ok)throw IE(c.status,c.statusText);return await c.json()}}function PE(e){return JSON.stringify({baseUrl:Vr(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function OE(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function RE(e){return t=>$r.run(PE(t),()=>(J("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>J("appInit:end",{kind:"network"}))))}function kE(e,t){if(st(e)||!e.appInit&&!Vr(e.baseUrl)||!OE(e))return e;const n=e.appInit??DE(e,t);let r=ka.get(n);return r||(r=RE(n),ka.set(n,r)),{...e,appInit:r}}var Na=0;function NE(){return Na}function LE(){Na+=1,Ra()}var La=new WeakMap,Ma=new WeakMap,ME=3e4;function xE(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function FE(e,t){try{const n=l.decodeJwt(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+ME}function BE(e){const t=new Map,n=new Map;return async(r,o,s)=>{const i=xE(r,o);if(s)return n.delete(i),t.delete(i),Ra(),e(r,o,s);const a=n.get(i);if(a&&!t.has(i)){if(a.expiresAtMs>Date.now())return a.token;n.delete(i)}let c=t.get(i);return c===void 0&&(J("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,o,s)).then(d=>{const u=String(d||"").trim();return u&&n.set(i,{token:d,expiresAtMs:FE(u,Date.now())}),d}).finally(()=>{J("authToken:end",{kind:"network"}),t.delete(i)}),t.set(i,c)),c}}function jE(e){if(st(e))return e;const t=e.getAuthToken;if(!t)return e;let n=La.get(t);const r=NE();return(!n||Ma.get(t)!==r)&&(n=BE(t),La.set(t,n),Ma.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(o=>{}),{...e,getAuthToken:n}}var UE="[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 HE(e){const t=new Error(UE,{cause:e});return t.name="EditorStartFailedError",t}var $E={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function xa(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var Fa=["handleLoad","handleDestroy"];function Ba(e,t){let n=e;for(const r of Fa){const o=e?.[r];typeof o=="function"&&(n={...n,[r]:(s,...i)=>o(t,...i)})}return n}function VE(e){let t,n="pending",r,o,s,i;const a=new Set,c=[],d=new Set;let u,f;const h=new Promise((I,p)=>{u=I,f=p});h.catch(()=>{});const g={},_=I=>t?.[I],y=()=>r??_e(),m=(I,p)=>{const S=_(I);if(typeof S!="function")throw xa(I);return S.apply(t,p)},T=(I,p)=>{try{return Promise.resolve(m(I,p))}catch(S){return Promise.reject(S)}},D=()=>{const I=t?.container?.getInstance?.(l.DISPOSABLE_ID);if(!(n!=="ready"||I?.isDisposed()||typeof _("getConfig")!="function"))try{i=m("getConfig",[])}catch{}},B=()=>n==="dead"?Promise.reject(y()):n==="ready"?Promise.resolve():h,M=()=>{for(const[I,p]of tn)p==="field"&&(g[I]=_(I))},C=I=>{const p=_(I.name);I.dispose||typeof p!="function"||n==="dead"||(I.dispose=p.apply(t,I.args))},E=()=>a.forEach(C),b=()=>{for(const I of a){try{I.dispose?.()}catch{}I.dispose=void 0}},w=()=>{M(),E()},O=()=>{s?.delete(w),s=void 0},x=(I,p)=>{const[S,...F]=p;return!Fa.includes(I)||typeof S!="function"?p:[(V,...$)=>S(g,...$),...F]},A=(I,p)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof _(I)!="function")throw xa(I);const S={name:I,args:x(I,p)};return a.add(S),C(S),()=>{a.delete(S),S.dispose?.(),S.dispose=void 0}},N=()=>t?.container?.getInstance(l.OPTIONS_SOURCE_ID)?.get()?.content,k=()=>{const I=e.element();return I!==void 0&&typeof I!="string"?I:void 0},P=(I,p)=>{switch(p){case"event":return(...S)=>A(I,S);case"async":return(...S)=>(I==="show"&&S[0]!==void 0&&e.shown?.(S[0]),n!=="dead"&&typeof _(I)=="function"?T(I,S):B().then(()=>m(I,S)));case"queued":return(...S)=>{if(n==="dead"){if(I==="notify")return;throw y()}if(n==="pending"){c.push({name:I,args:S});return}return m(I,S)};case"sync":return(...S)=>{if(n==="dead"){if(I==="getConfig")return i;throw y()}if(typeof _(I)!="function")throw new Error(`[emailmaker] \`${I}\` is not available before the editor is ready: ${$E[I]??"await `ready` first"}`);const F=m(I,S);return I==="getConfig"&&(i=F),F};case"element":return()=>{if(typeof _(I)!="function")return k();try{return m(I,[])}catch{return k()}};case"codeErrors":return()=>n==="ready"&&typeof _(I)=="function"?m(I,[]):[];case"field":return}};for(const[I,p]of tn)g[I]=P(I,p);g.reset=I=>(I?.content!==void 0&&e.shown?.(I.content),B().then(async()=>{const p=I?.content!==void 0&&l.deepEqual(I.content,N());await m("reset",[Ba(I,v)]),p&&await m("show",[I.content])}).then(()=>g)),g.destroy=()=>{if(n==="dead")return;const I=l.createAbortError("[emailmaker] editor was destroyed before it was ready");o?.catch(()=>{}),d.forEach(p=>p(I)),D(),e.destroy()},Object.defineProperty(g,"ready",{get:()=>o,enumerable:!0,configurable:!0});const v=g;return{object:v,get state(){return n},get editor(){return t},bind:I=>{n==="dead"||t===I||(b(),O(),t=I,M(),E(),n==="pending"&&(s=I.container.getOrCreateInstance(l.LATE_SURFACE_LISTENERS_ID,()=>new Set),s.add(w)))},settle:()=>{if(n==="pending"){n="ready",O(),M(),E();for(const I of c.splice(0))try{m(I.name,I.args)}catch(p){queueMicrotask(()=>{throw p})}u()}},kill:(I,p)=>{n!=="dead"&&(D(),n="dead",r=I,c.length=0,d.forEach(S=>S(I)),O(),p?.keepSubscriptions||(b(),a.clear()),f(I))},detach:()=>{b(),a.clear()},setReady:I=>{o=I},trackCall:I=>(d.add(I),()=>d.delete(I)),hasCalls:()=>d.size>0}}var Wr="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function GE(){return l.createAbortError(Wr)}function ja(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Wr}function YE(e,t,n){if(typeof document>"u")return;let r=!1,o;const s=()=>{r=!0,o?.disconnect(),o=void 0},i=()=>{r||(s(),t())};if(n.addDispose(s),!e.isConnected){queueMicrotask(i);return}o=new MutationObserver(()=>{e.isConnected||i()});let a=e.parentNode;for(;a;)o.observe(a,{childList:!0}),a=a.parentNode}function WE(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:o}=e;if(t===void 0||!(n instanceof Element))return r;const s=new AbortController;return YE(n,()=>{n.id,s.abort(GE())},o),l.composeAbortSignals(r,s.signal)}var qr="Superseded by newer init() on the same mount element";function Ua(){return l.createAbortError(qr)}function Ha(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===qr}var Et=new Map,$a=new WeakMap,on=new WeakMap;function qE(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function KE(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=qE(e);(n?Et.get(n):void 0)?.forEach(u=>{u.element!==e&&u.controller.abort(Ua())});const r=$a.get(e)??new Set;t&&r.forEach(u=>{u.supersedable&&u.controller.abort(Ua())});const o=on.get(e)??Promise.resolve();let s;const i=new Promise(u=>{s=u}),a=o.then(()=>i);on.set(e,a),a.then(()=>{on.get(e)===a&&on.delete(e)});const c=new AbortController,d={element:e,controller:c,supersedable:t};if(r.add(d),$a.set(e,r),n){const u=Et.get(n)??new Set;u.add(d),Et.set(n,u)}return{signal:c.signal,previous:o,release:()=>{s(),r.delete(d);const u=n?Et.get(n):void 0;n&&u?.delete(d)&&u.size===0&&Et.delete(n)}}}var _t=new WeakMap;function Kr(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function zr(e){return Object.entries(e).filter(([t,n])=>Kr(t,n)).map(([t])=>t).sort()}function Va(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!Kr(n,r)&&(t[n]=r);return t}function Xr(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:_t.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},_t.set(e,r));const{current:o,trampolines:s}=r;o.clear();const i={...t};for(const a of zr(t)){o.set(a,t[a]);let c=s.get(a);c||(c=(...d)=>o.get(a)?.(...d),s.set(a,c)),i[a]=c}return r.lastOptions=t,i}function Ga(e,t){const n=e?_t.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const o=t[r];Kr(r,o)?n.current.set(r,o):n.current.delete(r)}}function zE(e){const t=e?_t.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((o,s)=>t.current.set(s,o)),t.lastOptions=r}}function XE(e,t,n){const r=e?_t.get(e):void 0;if(!r||!n)return!1;const o=zr(t),s=l.deepEqual(o,zr(r.lastOptions)),i=o.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!s||!i||!l.deepEqual(Va(t),Va(r.lastOptions))?!1:(Xr(e,t),!0)}var me=new WeakMap,Z_=0;function sn(e){let t=me.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},me.set(e,t)),t}var ye=e=>e!==void 0&&e.state!=="dead";function JE(e){const t=me.get(e)?.shared;return ye(t)?t:void 0}function QE(e,t){sn(e).shared=t}function ZE(e,t){!(ye(e.shared)&&[...e.counted].some(ye))||e.warned||!t.devTools||(e.warned=!0)}function e_(e,t,n,r){const o=sn(e);return o.latestCall+=1,o.releaseTimer!==void 0&&(clearTimeout(o.releaseTimer),o.releaseTimer=void 0),o.leaving.forEach(s=>s.detach()),o.leaving.clear(),n==="single"?o.shared=t:o.counted.add(t),o.options.set(t,r),o.order=[...o.order.filter(s=>s!==t&&ye(s)),t],ZE(o,r),o.latestCall}function t_(e,t){return me.get(e)?.latestCall===t}function n_(e){const t=me.get(e);if(t)return t.order=t.order.filter(ye),t.order.at(-1)?.object}function bt(e,t){const n=me.get(e);return n?ye(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&ye(r)):!1}function r_(e,t){const n=me.get(e),r=n?.order.filter(o=>o!==t&&ye(o)).at(-1);return r?n?.options.get(r):void 0}function Ya(e,t){sn(e).content={value:t}}function o_(e){return me.get(e)?.content}function s_(e,t,n,r){const o=sn(e);if(o.counted.delete(t),o.options.delete(t),bt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),o.leaving.add(t),Wa(e,r)}function Wa(e,t){const n=me.get(e);!n||bt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!bt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function i_(e,t){const n=me.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);me.delete(e)}}var a_=dn.__exportAll({FileManagerApiError:()=>l_,IntegratorSaveTimeoutError:()=>Ct,SaveRefusedError:()=>et}),l_=class Xa 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,Xa)}},c_=dn.__exportAll({mapHttpStatusToErrorCode:()=>l.mapHttpStatusToErrorCode});function d_(e,t){return{...e,element:t}}function Jr(){return()=>{}}function u_(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Jr():(vE(t,e.config?.styles,t),()=>{EE(t)})}function f_(e){if(!Oa()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Jr()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Jr()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(o=>{o.remove()});const n=yE(t,"data-emailmaker"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function p_(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function an(e){try{e.destroy()}catch{}}function ln(e,...t){const n=l.ELEMENT_MAP.get(e);t.some(r=>r!==void 0&&r===n)&&l.ELEMENT_MAP.delete(e)}var h_="1.2.0";async function m_(e){Fn(),await Gg(typeof __emailmaker__<"u"?__emailmaker__:void 0)}async function g_(e){return qa(e).ready}function v_(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function E_(e){const t=l.ELEMENT_MAP.get(e);return t&&!(t instanceof Promise)?t:void 0}function cn(e,t,n){const r=t??E_(e);r&&(ln(e,r),an(r)),i_(e,n)}function __(e){const{control:t,mode:n,ref:r}=e,o=r.host;if(!o){const i=t.editor;b_(i),t.kill(_e());return}if(n==="single"){cn(o,t.editor,_e());return}const s=r_(o,t);s_(o,t,_e(),()=>cn(o,t.editor,_e())),s&&bt(o)&&Ga(o,s)}function b_(e){e&&an(e)}function qa(e){J(oe.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=l.composeAbortSignals(e.signal,n.signal),o=t==="single"?v_(e.element):void 0,s=o?JE(o):void 0;let i;if(s)i={control:s,mode:t,ref:{host:o}};else{const u={},f=VE({element:()=>u.host??e.element,destroy:()=>__(i),shown:h=>{u.host&&Ya(u.host,h)}});i={control:f,mode:t,ref:u},o&&QE(o,f)}const{control:a}=i,c=a.trackCall(u=>n.abort(u)),d=C_(Ba({...e,signal:r},a.object),i).then(()=>(c(),J(oe.initEnd),a.settle(),a.object),u=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(u);const f=i.ref.host;throw f&&Wa(f,()=>cn(f,void 0,_e())),u});return a.setReady(d),a.object}function y_(e){const t=typeof e=="string"?document.querySelector(e):e;return t?n_(t):void 0}function S_(e){let t,n,r=!1;try{t=e.container.getInstance(l.OPTIONS_SOURCE_ID)?.get(),n=e.container.getInstance(l.INIT_PIPELINE_ID)?.externalSignal;const o=Be(e.container)?.current();r=o!==void 0&&o.get().savedVersion!==null&&o.isDirty()}catch{t=void 0}return{options:t,signal:n,email:w_(e),dirty:r}}async function w_(e){try{return await e.getEmailSnapshot()}catch{return}}function I_(e){const t=Be(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function Ka(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||bt(e,n)}async function T_(e,t,n,r,o){if(r.mode==="counted"&&r.control.detach(),Ha(o)||ja(o))return;const s=()=>cn(t,e,HE(o)),{options:i}=n;if(!i||!Ka(t,r)){s();return}const a=await n.email,c=a&&(i.content!==void 0||a.id!==void 0)?a:void 0,d=typeof i.content=="object"&&"email"in i.content?i.content:void 0;try{await e.reset({...i,signal:i.signal??n.signal,content:c?{...d,email:c}:i.content}),n.dirty&&c&&I_(e),Ka(t,r)?l.ELEMENT_MAP.set(t,e):s()}catch{s()}}async function C_(e,t){l.throwIfAborted(e.signal);const n=new l.Disposable;let r,o,s,i,a=0;try{const c=await l.waitForElement(e.element,n,e.signal);c&&(i=c,t.ref.host=c,a=e_(c,t.control,t.mode,e));const d=WE({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),u=KE(c,{supersede:t.mode==="single"});r=u.release;const f=l.composeAbortSignals(d,u.signal);l.throwIfAborted(f),s=zE(c),Ga(c,e),await l.raceWithAbortSignal(u.previous,f),o=A_(e,c,t,f,s);const h=await l.raceWithAbortSignal(o,f);return c&&e.content!==void 0&&Ya(c,e.content),h}catch(c){throw i&&s&&t_(i,a)&&s(),c}finally{const c=r;o!==void 0&&c?o.then(c,c):c?.(),n.dispose()}}async function za(e,t,n,r){const o=o_(t);n===void 0||r||!o||l.deepEqual(n,o.value)||await e.show(n)}async function A_(e,t,n,r,o){const{control:s}=n,i=y=>s.bind(y);l.throwIfAborted(r);let a;const c=y=>{LE();const m=jE(d_(y,t)),T=kE(m,()=>a);return{preparedOptions:T,preparedOptionsWithSignal:r!=null?{...T,signal:r}:T}};let d;if(t){const y=l.ELEMENT_MAP.get(t);if(y){let m;try{m=await y,l.throwIfAborted(r)}catch{l.throwIfAborted(r),ln(t,y),m=void 0}if(m)if(m.getElement()===t){const T=uE(t);a=T;const D=m.container.getInstance(l.OPTIONS_SOURCE_ID)?.get();if(XE(t,e,D))return i(m),r&&m.container.getInstance(l.INIT_PIPELINE_ID)?.relinkExternalSignal(r),l.ELEMENT_MAP.set(t,m),await za(m,t,e.content,!1),m;const B=!l.deepEqual(e.content,D?.content);d=c(Xr(t,e));const{preparedOptions:M,preparedOptionsWithSignal:C}=d,E=T&&AE(T),b=S_(m);try{T&&Yr(T,M),i(m);const w=await m.reset(p_(e,C));return l.throwIfAborted(r),l.ELEMENT_MAP.set(t,m),await za(m,t,e.content,B),w}catch(w){if(T&&E&&Yr(T,E),!yl(w))throw o(),await T_(m,t,b,n,w),w;ln(t,y,m),an(m),l.throwIfAborted(r)}}else ln(t,y,m),an(m)}}l.throwIfAborted(r),d??=c(Xr(t,e,{fresh:!0}));const{preparedOptions:u}=d,f=u_(u),h=f_(u),g=r!=null?{...h.options,signal:r}:h.options;let _;try{a=hE(g),fE(t,a),Yr(a,u),Sr(a).set(g),await Dr(),J(oe.coreReady),l.throwIfAborted(r),l.throwIfAborted(r),_=dE(g,a,{onInstance:i}),t&&l.ELEMENT_MAP.set(t,_);const y=await _;if(r?.aborted&&(y.destroy(),l.throwIfAborted(r)),t)if(l.ELEMENT_MAP.get(t)===_)l.ELEMENT_MAP.set(t,y);else throw y.destroy(),l.throwIfAborted(r),l.createAbortError(r?.reason);return y}catch(y){throw f(),h.cleanup(),a&&(Da(a),pE(t,a)),t&&_&&l.ELEMENT_MAP.get(t)===_&&l.ELEMENT_MAP.delete(t),y}}async function D_(e){return(await ht()).parseAMP(e)}typeof window<"u"&&(Je()&&_l(),Wg(typeof __emailmaker__<"u"?__emailmaker__:void 0)),de.ELEMENT_DETACHED_ABORT_MESSAGE=Wr,de.SUPERSEDED_INIT_ABORT_MESSAGE=qr,de.create=qa,Object.defineProperty(de,"errors",{enumerable:!0,get:function(){return a_}}),de.getInstance=y_,Object.defineProperty(de,"helpers",{enumerable:!0,get:function(){return c_}}),de.init=g_,de.isElementDetachedError=ja,de.isSupersededInitError=Ha,de.parseAMP=D_,de.pluginRegistry=pa,de.preload=m_,de.version=h_});
2183
2183
 
2184
2184
 
2185
2185
  // Возвращаем API из entry модуля
2186
2186
  return __emailmaker__.syncRequire("emailmaker.js");
2187
2187
  });
2188
2188
 
2189
- __emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/13b2a363.js":["static/core/6c52be40.js"],"static/core/15ea858c.js":[],"static/core/22140fa1.js":[],"static/core/2455e45e.js":[],"static/core/2734fa96.js":[],"static/core/370f04c3.js":[],"static/core/3a6dbf2b.js":["static/core/7985de17.js","__delivery__/libs"],"static/core/43a8b244.js":[],"static/core/4797d4f7.js":[],"static/core/566e8ce8.js":[],"static/core/6933d533.js":[],"static/core/6ba8aedc.js":[],"static/core/6c52be40.js":[],"static/core/6e8d008d.js":["static/core/6f6a92e3.js"],"static/core/6f6a92e3.js":[],"static/core/7452d34b.js":[],"static/core/756e184f.js":[],"static/core/76d1f317.js":[],"static/core/7985de17.js":["static/core/a22823f9.js","__delivery__/libs"],"static/core/7e51da74.js":["static/core/6f6a92e3.js"],"static/core/7e69b03c.js":["static/core/a8cb6e27.js","static/core/e88db487.js","__delivery__/libs"],"static/core/8889dbc6.js":["static/core/7e69b03c.js","__delivery__/libs"],"static/core/8a5b1c18.js":[],"static/core/8a621181.js":["static/core/a22823f9.js","__delivery__/libs"],"static/core/8bf56b5b.js":[],"static/core/a22823f9.js":["__delivery__/libs"],"static/core/a8cb6e27.js":[],"static/core/abcacabc.js":[],"static/core/b43852b9.js":["static/core/6c52be40.js","static/core/6f6a92e3.js","static/core/6e8d008d.js"],"static/core/b712bb05.js":["static/core/e88db487.js"],"static/core/b916e437.js":[],"static/core/d0b845c8.js":[],"static/core/d5cd2a7b.js":[],"static/core/d74c1e57.js":[],"static/core/d8800deb.js":[],"static/core/dbc12df7.js":["static/core/7e69b03c.js","static/core/e88db487.js","__delivery__/libs"],"static/core/e1f8b6ea.js":[],"static/core/e88db487.js":[],"static/core/ecaf7c36.js":["static/core/7e69b03c.js","static/core/edf49656.js","static/core/8889dbc6.js","static/core/3a6dbf2b.js","__delivery__/libs"],"static/core/edf49656.js":["static/core/7e69b03c.js","__delivery__/libs"],"static/core/f20ffa90.js":["static/core/edf49656.js","static/core/7985de17.js","__delivery__/libs","static/core/7e69b03c.js"],"static/core/f37da79c.js":["static/core/370f04c3.js","__delivery__/libs","monaco"],"static/monaco/editor.api-DqgksfDR.js":[],"monaco":["static/monaco/editor.api-DqgksfDR.js","static/monaco/lspLanguageFeatures-BnvITcKb.js"],"static/monaco/lspLanguageFeatures-BnvITcKb.js":["static/monaco/editor.api-DqgksfDR.js"],"emailmaker.js":[],"static/umd/312a9b80.js":[],"static/umd/3f12d6ff.js":["static/umd/790cf6cb.js"],"static/umd/790cf6cb.js":[],"static/umd/b3ebeaee.js":[]},"bundles":{"static/core/7985de17.js":["static/core/64c41269.js","static/core/581b1621.js","static/core/8d28faeb.js"],"static/core/13b2a363.js":["static/core/a54d9b28.js"],"static/core/dbc12df7.js":["static/core/74d00db4.js"],"static/core/3a6dbf2b.js":["static/core/61378c9e.js"],"static/core/f20ffa90.js":["static/core/5d940257.js"],"core":["static/core/5dc34752.js","static/core/c9d6507f.js","static/core/f6b0d077.js","static/core/52ec2041.js","static/core/5329bafd.js"]}});
2189
+ __emailmaker__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/15ea858c.js":[],"static/core/29b3ccef.js":[],"static/core/2e70fae0.js":["static/core/ec5f739e.js","__delivery__/libs"],"static/core/370f04c3.js":[],"static/core/43a8b244.js":[],"static/core/44fac8d4.js":[],"static/core/4797d4f7.js":[],"static/core/5c4239d8.js":[],"static/core/64c27f91.js":["static/core/5c4239d8.js"],"static/core/6933d533.js":[],"static/core/727a165f.js":[],"static/core/7452d34b.js":[],"static/core/76d1f317.js":[],"static/core/790366d3.js":["static/core/ec5f739e.js","static/core/e88db487.js","__delivery__/libs"],"static/core/7be64bf5.js":[],"static/core/7d006e7b.js":[],"static/core/83d2ca5d.js":["static/core/a2c7aeb0.js","__delivery__/libs"],"static/core/8a5b1c18.js":[],"static/core/8b89090c.js":[],"static/core/8bf56b5b.js":[],"static/core/8da91a53.js":["static/core/a2c7aeb0.js","__delivery__/libs"],"static/core/99c15a5d.js":["static/core/db685f4e.js"],"static/core/9f7e0f94.js":["static/core/ec5f739e.js","static/core/2e70fae0.js","static/core/b7dee12b.js","static/core/e7bbe544.js","__delivery__/libs"],"static/core/a2c7aeb0.js":["__delivery__/libs"],"static/core/a8cb6e27.js":[],"static/core/a9235d9e.js":[],"static/core/abcacabc.js":[],"static/core/b27aec0b.js":[],"static/core/b712bb05.js":["static/core/e88db487.js"],"static/core/b74171bd.js":["static/core/5c4239d8.js"],"static/core/b7dee12b.js":["static/core/ec5f739e.js","__delivery__/libs"],"static/core/bbb87124.js":["static/core/db685f4e.js","static/core/5c4239d8.js","static/core/b74171bd.js"],"static/core/c5713f94.js":[],"static/core/ccb090eb.js":["static/core/370f04c3.js","__delivery__/libs","monaco"],"static/core/d0b845c8.js":[],"static/core/db685f4e.js":[],"static/core/e15ab856.js":[],"static/core/e7bbe544.js":["static/core/83d2ca5d.js","__delivery__/libs"],"static/core/e88db487.js":[],"static/core/ec5f739e.js":["static/core/a8cb6e27.js","static/core/e88db487.js","__delivery__/libs"],"static/core/f2ced98d.js":["static/core/2e70fae0.js","static/core/83d2ca5d.js","__delivery__/libs","static/core/ec5f739e.js"],"static/core/f54ef492.js":[],"static/monaco/editor.api-DqgksfDR.js":[],"monaco":["static/monaco/editor.api-DqgksfDR.js","static/monaco/lspLanguageFeatures-BnvITcKb.js"],"static/monaco/lspLanguageFeatures-BnvITcKb.js":["static/monaco/editor.api-DqgksfDR.js"],"emailmaker.js":[],"static/umd/3a37cbb5.js":[],"static/umd/3f12d6ff.js":["static/umd/790cf6cb.js"],"static/umd/790cf6cb.js":[],"static/umd/b3ebeaee.js":[]},"bundles":{"static/core/83d2ca5d.js":["static/core/66d55956.js","static/core/bc1a9bce.js","static/core/ca683630.js"],"static/core/99c15a5d.js":["static/core/a54d9b28.js"],"static/core/790366d3.js":["static/core/74d00db4.js"],"static/core/e7bbe544.js":["static/core/61378c9e.js"],"static/core/f2ced98d.js":["static/core/73d746bd.js"],"core":["static/core/5dc34752.js","static/core/2462bf5f.js","static/core/f33f0316.js","static/core/64a89155.js","static/core/b65ac970.js"]}});