useblocks 1.3.14 → 1.3.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -1
- package/iframe/.vite/manifest.json +4 -4
- package/iframe/{iframe-eblock.cd84d2b9.html → iframe-eblock.7594857d.html} +2 -2
- package/iframe/{iframe.cd84d2b9.html → iframe.7594857d.html} +2 -2
- package/iframe/js/elMarkupHelper.CsLyPjC1.js +278 -0
- package/iframe/js/{iframe-eblock.body.cd84d2b9.js → iframe-eblock.body.7594857d.js} +1 -1
- package/iframe/js/iframe-eblock.js +2 -2
- package/iframe/js/iframe.body.7594857d.js +129 -0
- package/iframe/js/iframe.js +2 -2
- package/package.json +1 -1
- package/runtime/react/index.js +1 -1
- package/static/core/{f9238279.js → 16612c9f.js} +1 -1
- package/static/core/{33588588.js → 1e160f23.js} +1 -1
- package/static/core/{b5da36e5.js → 23e22cd2.js} +1 -1
- package/static/core/25562e5d.js +1 -0
- package/static/core/2633e871.js +1 -0
- package/static/core/{58c51568.js → 2740933f.js} +3 -3
- package/static/core/{d4513bf2.js → 2a8b14c0.js} +1 -1
- package/static/core/{36ffa6e4.js → 2ae78ac6.js} +1 -1
- package/static/core/{4bfd6086.js → 31e587ab.js} +1 -1
- package/static/core/3454ca99.js +1 -0
- package/static/core/36071466.js +2 -0
- package/static/core/{18b86617.js → 3cd95e0a.js} +1 -1
- package/static/core/{6c59da82.js → 3e1acefc.js} +1 -1
- package/static/core/3e80379e.js +4 -0
- package/static/core/{209e2686.js → 3f3feb86.js} +1 -1
- package/static/core/{39d9efa2.js → 4adb5ee9.js} +7 -7
- package/static/core/4e07805d.js +19 -0
- package/static/core/{3a605273.js → 4f8847e6.js} +1 -1
- package/static/core/519dfcc7.js +4 -0
- package/static/core/{a6303cb2.js → 53c22855.js} +1 -1
- package/static/core/{f4e70f7f.js → 552f7d30.js} +2 -2
- package/static/core/{c571b1dd.js → 5de3cd2c.js} +1 -1
- package/static/core/{5cac7517.js → 66853555.js} +1 -1
- package/static/core/{b1edf5c5.js → 69688fad.js} +6 -6
- package/static/core/713de1e1.js +1 -0
- package/static/core/{de3f9bdc.js → 7ae6cf52.js} +7 -7
- package/static/core/{57948058.js → 80907514.js} +1 -1
- package/static/core/{5d315649.js → 86f73ee9.js} +1 -1
- package/static/core/{6100ddd2.js → 8b9a4f49.js} +1 -1
- package/static/core/9348ac64.js +1 -0
- package/static/core/9da6c313.js +1 -0
- package/static/core/{5f0554d8.js → a004861a.js} +1 -1
- package/static/core/aeec5659.js +1 -0
- package/static/core/b492a9b0.js +93 -0
- package/static/core/{e37ba502.js → b6418818.js} +1 -1
- package/static/core/{9d0b4233.js → beebdf4d.js} +1 -1
- package/static/core/c03fc17e.js +7 -0
- package/static/core/c3344bbc.js +1 -0
- package/static/core/{e0282a25.js → c3544cf4.js} +1 -1
- package/static/core/{4224aefb.js → cc4458d8.js} +1 -1
- package/static/core/{87edea39.js → d551e71d.js} +1 -1
- package/static/core/{ce93456f.js → d5be6857.js} +1 -1
- package/static/core/{605267a0.js → d6c7eb44.js} +1 -1
- package/static/core/d9ff5568.js +1 -0
- package/static/core/{f4b9148a.js → e2710fd3.js} +1 -1
- package/static/core/{2209544a.js → e7c7173a.js} +3 -3
- package/static/core/{1dfb486f.js → e81b521f.js} +3 -3
- package/static/core/{92fb4e07.js → e94e24b5.js} +1 -1
- package/static/core/{1a17438d.js → e98b0c61.js} +2 -2
- package/static/core/{e35eca7d.js → ec079650.js} +1 -1
- package/static/core/ecc4d431.js +1 -0
- package/static/core/f0f20c47.js +1 -0
- package/static/core/{550803ff.js → f5d42c73.js} +1 -1
- package/static/core/{ff7d14e8.js → f674f125.js} +1 -1
- package/static/core/{5a21c667.js → f97efb0a.js} +1 -1
- package/static/core/{b4e4af36.js → ff0af9ff.js} +1 -1
- package/static/esm/1d0ba521.js +1 -0
- package/static/umd-runtime/{runtime.DAdCc3rx.js → runtime.8gUPr0nE.js} +1 -1
- package/useblocks-core.7594857d.js +875 -0
- package/useblocks-esm.js +12 -12
- package/{useblocks-po.cd84d2b9.js → useblocks-po.7594857d.js} +1 -1
- package/useblocks.js +13 -13
- package/vendor/useblocks-ui-kit/package.json +1 -1
- package/iframe/js/elMarkupHelper.CgToMPJX.js +0 -278
- package/iframe/js/iframe.body.cd84d2b9.js +0 -129
- package/static/core/1c9acdf4.js +0 -1
- package/static/core/243ff5f9.js +0 -19
- package/static/core/555c0dda.js +0 -1
- package/static/core/5661be7c.js +0 -7
- package/static/core/8f57829b.js +0 -1
- package/static/core/91d46f38.js +0 -4
- package/static/core/a8634edd.js +0 -2
- package/static/core/bff175af.js +0 -4
- package/static/core/c6114314.js +0 -93
- package/static/esm/c5372168.js +0 -1
- package/useblocks-core.cd84d2b9.js +0 -875
package/useblocks.js
CHANGED
|
@@ -1014,7 +1014,7 @@ var __amdEnv = window.__useblocks__ || (window.__useblocks__ = {});
|
|
|
1014
1014
|
|
|
1015
1015
|
|
|
1016
1016
|
// Configure AMD loader
|
|
1017
|
-
__amdEnv.require.config({ baseUrl: "./", paths: {"core":"useblocks-core.
|
|
1017
|
+
__amdEnv.require.config({ baseUrl: "./", paths: {"core":"useblocks-core.7594857d.js","monaco":"static/monaco/index.CO7s5UdA.js","po":"useblocks-po.7594857d.js","static/umd-runtime/delivery-libs.js":"static/umd-runtime/delivery-libs.BJHA1QD4.js","static/umd-runtime/runtime.js":"static/umd-runtime/runtime.8gUPr0nE.js","static/umd-runtime/ui-kit-icons.js":"static/umd-runtime/ui-kit-icons.DqlZwgBU.js","static/umd-runtime/ui-kit.js":"static/umd-runtime/ui-kit.BZ4Y4jr2.js"} });
|
|
1018
1018
|
|
|
1019
1019
|
// PublicPath (script detection: entry script lookup → document.currentScript)
|
|
1020
1020
|
if (!__useblocks__.publicPath) {
|
|
@@ -1362,7 +1362,7 @@ if (!ns.assetUrl) {
|
|
|
1362
1362
|
}
|
|
1363
1363
|
|
|
1364
1364
|
if (!ns.version) {
|
|
1365
|
-
ns.version = "1.3.
|
|
1365
|
+
ns.version = "1.3.16";
|
|
1366
1366
|
}
|
|
1367
1367
|
|
|
1368
1368
|
var modules = ns.modules = Object.create(null);
|
|
@@ -2093,27 +2093,27 @@ if (typeof ns.define === 'function') {
|
|
|
2093
2093
|
__useblocks__.define("static/umd/b11043e6.js",["require","exports","module"],function(y,l,w){var p=Object.create,_=Object.defineProperty,i=Object.getOwnPropertyDescriptor,b=Object.getOwnPropertyNames,f=Object.getPrototypeOf,a=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)_(t,u,{get:e[u],enumerable:!0});return r||_(t,Symbol.toStringTag,{value:"Module"}),t},P=(e,r,t,u)=>{if(r&&typeof r=="object"||typeof r=="function")for(var c=b(r),o=0,s=c.length,n;o<s;o++)n=c[o],!a.call(e,n)&&n!==t&&_(e,n,{get:(j=>r[j]).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||!a.call(e,"default")?_(t,"default",{value:e,enumerable:!0}):t,e));Object.defineProperty(l,"__commonJSMin",{enumerable:!0,get:function(){return O}}),Object.defineProperty(l,"__exportAll",{enumerable:!0,get:function(){return v}}),Object.defineProperty(l,"__toESM",{enumerable:!0,get:function(){return g}})});
|
|
2094
2094
|
|
|
2095
2095
|
|
|
2096
|
-
__useblocks__.define("static/umd/6d027ea0.js",["require","exports","module"],function(xn,a,Un){var m=class _t{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof _t&&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 j(e){return`service_container_${e}`}var y=new Set,W;function lt(){if(!W)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,K.prototype.getInstanceAsync),e.stack}function $(e){y.delete(e)&&W?.end(e)}var K=class se extends m{_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 m){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=lt();return new Promise((i,o)=>{const s={id:String(t),startedAt:Date.now(),origin:n,container:this,reject:o};y.add(s),W?.start(s),this._onInject(t,()=>{$(s),i(this.getInstance(t))})})}failPendingWaits(t){for(const r of Array.from(y))r.container===this&&($(r),r.reject(t))}pendingWaits(){return[...y].filter(t=>t.container===this)}addService(t,r){const n=j(t);this.injectFactory(n,(o,s=[])=>s.indexOf(r)<0?[...s,r]:s);const i=new m;return i.addDispose(()=>{this.injectFactory(n,(o,s=[])=>s.filter(c=>c!==r))}),i}addServiceFactory(t,r,n){const i=j(t);let o;this.injectFactory(i,(c,u=[])=>(o=r(c,o),o===void 0?u:u.indexOf(o)<0?[...u,o]:u),n);const s=new m;return s.addDispose(()=>{this.injectFactory(i,(c,u=[])=>o===void 0?u:u.filter(_=>_!==o))}),s}getServices(t){const r=j(t);return[...this.getInstance(r,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new se(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const r=this._parent?.getOrCreateIsolatedContainer(t);return new se(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&&$(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function q(e){return e.startsWith("__")?e:`__${e}__`}function dt(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=q(e),r=globalThis;return r[t]??={}}function ft(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function Et(e){if(e)return q(e);const t="useblocks".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return q(t)}function ae(e){const t=Et(e),r=dt(t);if(ft(r.container))return r.container;const n=new K(null);return r.container=n,n}function pt(e){return ae(e)}function ht(){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():ht()}function f(e=ce()){return e}function ue(){return"umd".trim()||"unknown"}function Ot(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 At(){const e="useblocks".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function gt(e,t){if(Ot(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:[]},c={container:e,source:"packages/runtime-core/di/index.ts",buildSource:r,timestamp:Date.now(),stack:new Error().stack};return s.entries.push(c),e}var B;function mt(){if(B)return B;const e=At();return B=gt(ae(e),e),B}var C=new Proxy({},{get(e,t,r){const n=mt(),i=Reflect.get(n,t,r);return typeof i=="function"?i.bind(n):i}});function It(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 T(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 St(e){return e instanceof DOMException&&e.name==="AbortError"}function Y(e){if(e?.aborted)throw T(e.reason)}function Tt(e,t){return t?(t.aborted&&e.catch(()=>{}),Y(t),new Promise((r,n)=>{const i=()=>{o(),n(T(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 m{_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(([,c])=>c<t),s=[e,t];return n.splice(o>=0?o:n.length,0,s),n.length===1&&i.onFirstListenerAdd&&i.onFirstListenerAdd(),{dispose:()=>{const c=n.indexOf(s);c>=0&&(n.splice(c,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}}},bt=class extends b{execute([e],t){for(const r of t)try{r(e)}catch{}}},Nt=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)}},F=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 Dt(e,t=0){const r=new _e,n=e(r,t);return n&&r.addDisposable(n),r.event}function Pt(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 yt(e,t=0,r=0){const n=new b;let i,o;const s=e((...c)=>{o=c,i||(i=setTimeout(()=>{o&&n.fire(...o),i=void 0},t))},r);return s&&n.addDisposable(s),n.event}function Ct(e,t){return e.getOrCreateInstance(t,()=>new F)}function d(e){return f(e)}var z;(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_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")})(z||(z={}));function Lt(e,t){return e.getOrCreateInstance(t,()=>new F).event}function vt(e,t){return e.getOrCreateInstance(t,()=>new F)}var Rt=f("plugin.app"),Mt=f("plugin.disposable"),wt=f("InitPipelineContext"),jt=f("plugin.instance"),Bt=f("plugin.lateSurfaceListeners"),le=f("plugin.optionsSource"),Ft=f("plugin.store"),de=f("ConfigSource"),kt=f("plugin.standalone.project"),fe=f("plugin.standalone.bootstrapToken"),Gn=f("plugin.element"),Ee=f("plugin.securityModule"),xt=f("plugin.standalone.activated"),Ut=f("plugin.standalone.fileProxyRegistered"),J=f("plugin.jwt.token"),L=f("plugin.jwt.error"),Gt=f("PluginCollection"),Vt=d("APP_LOAD_EVENT"),Ht=d("CONFIG_CHANGED_EVENT");function Xt(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 Wt(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 $t(e){return e}function Kt(e){return e&&typeof e=="object"}function pe(e,t){return e&&typeof e=="object"&&e.operationId===t}var S="INIT_MESSAGE",he="em:port-ready",qt="em:window-drained",k="";function Oe(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var Yt=class extends m{_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(([c,u])=>r<=u),s=[t,r];return this.isDisposed()||i.splice(o>=0?o:i.length,0,s),{dispose(){const c=i.indexOf(s);c>=0&&i.splice(c,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=c=>o(c,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)},zt=class extends m{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_portSendHeld=new WeakSet;_inited=!1;_emitter=this.addDisposable(new Yt);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;_outgoingObservers=new Set;_offTargetListeners=new Map;constructor(e,t){super(),this._singleton=t,this._transport=Xt({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(S,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(S))}),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,S)){this._greeted.delete(n),this._handshaken.add(n),this._postMessage(n,{operationId:S,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),Kt(r)&&s||this._singleton&&pe(r,S)){if(i&&s){const l=this._target;Promise.resolve().then(()=>this.usePort(i,!0,l))}const c=this._emitter.fireAsync(r.operationId||k,r.operationId===void 0?t:r.data),u=r.result,_=r.error;u&&_&&Promise.resolve(c).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(S,void 0);return}this._inited=!1,this._postMessage(e,{operationId:S,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:S,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:S,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=Wt(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:qt,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(k,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 c=this.addDisposable(new m);c.addDisposable(this.onInit(u=>{try{this._postMessage(u,{operationId:e,data:t,result:n,error:i})}catch(_){c.dispose(),s(_);return}c.addDisposable(this._onMessage(n,_=>{o(_),c.dispose()})),c.addDisposable(this._onMessage(i,_=>{s(_),c.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(k,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 m);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(S,()=>{e(this._target)},r)),n}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function v(e){return f(e)}var Jt=f("extensions.atomsHandlers"),Qt=v("HANDLE_ATOM_INSERT"),Zt=f("HeadlessMode"),er=f("extensions.sandboxExtensions"),tr="SANDBOX_EXTENSION_SCRIPT_STATUS",rr=f("MESSAGE_SERVICE"),nr=v("SETTINGS_PANEL_EVENT"),ir="advanced",or=v("MODAL_SHOW_EVENT"),sr=v("MODAL_CLOSE_EVENT"),ar=v("MODAL_UPDATE_EVENT"),Vn=f("client"),Hn=f("v2_client"),Xn=f("ai_client"),cr=f("app.cookieManager"),Wn=f("app.storageProvider"),$n=f("image-blob-resolver"),ur=f("template-directives"),_r=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),lr=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:c,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),g=this.contentFormatters[n||"application/json"],O=o||h.format,H=`${s||this.baseUrl||""}${r}${p?`?${p}`:""}`,Fn=_?_(H,{body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:c,extraQuery:u,proxyHandler:_,...l}):H,ct=new Request(Fn,{...h,headers:{...h.headers||{},...n&&n!=="multipart/form-data"?{"Content-Type":n}:{}},signal:(c?this.createAbortSignal(c):h.signal)||null,body:typeof e>"u"||e===null?null:g(e)});return this.customFetch(ct).then(async ut=>{const I=ut;I.data=null,I.error=null,I.meta={request:ct,response:I};const kn=O?await ut[O]().then(X=>(I.ok?I.data=X:I.error={data:X},I)).catch(X=>(I.error=X,I)):I;return c&&this.abortControllers.delete(c),kn})}},dr=f("prewarm.networkActivity");function fr(){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 Er(e){return e.getOrCreateInstance(dr,()=>fr())}var Ae=Symbol("rest.publicRequest"),x=f("rest.requestHandler"),pr=f("rest.responseHandler"),Q=f("rest.customFetch"),hr=(e,t)=>fetch(e,t),Z=f("rest_transport"),Or=e=>{e.inject(Q,{execute:async(t,r={})=>{const n=e.getServices(x),i={public:r[Ae]===!0},o=Er(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 c=await fetch(s);const u=e.getServices(pr);for(const _ of u)c=await _.execute(c,s);return c}finally{o()}}})};function Ar(e,t){const r=e.getInstance(Z);if(!r)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(n=>new n(r)))}var ge="INJECTION";function me(e){return e.getState}function gr(e){if(me(e)){const t=e.getState()[ge];return t&&C.getOrCreateInstance(t,()=>C.createChild())}else return e}function mr(e){if(!me(e)){e.dispose();return}const t=e.getState()[ge];t&&(C.getInstance(t)?.dispose(),C.remove(t))}function Ir(e,t){for(const r of e)if(r&&t in r)return r[t]}function Ie(e){return Object.assign({},...e)}var Se=["generic","stockImages","emFiles","cdn"];function ee(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Te(e){return!ee(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>Se.includes(t))}function be(e){return e.length===0?[]:e.length===1?e[0]:e}function Ne(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 be(r)}function Sr(e){return ee(e)&&("value"in e||"replace"in e)}function De(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(Sr(o)){t=!0,o.replace&&(r=[],n=!0),o.value!==void 0&&(r=De(r,o.value),n=!0);continue}r=De(r,o),n=!0}const i=n?be(r):void 0;if(!t)return i;if(i!==void 0)return{value:i}}function br(e){const t=e.filter(n=>n!==void 0);if(t.length===0)return;if(!t.some(n=>Te(n)))return Ne(t);const r={};for(const n of Se){const i=Tr(e.map(o=>{if(o!==void 0)return Te(o)?o[n]:n==="generic"?o:void 0}));i!==void 0&&(r[n]=i)}return Object.keys(r).length>0?r:void 0}function Nr(e){return Ne(e)}function Dr(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(ee(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function Pr(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=Pr(t,i.hosts))}return r?t:void 0}function Cr(e){const t=e.filter(i=>i!==void 0);if(t.length===0)return;const r=Ie(t.map(({directHosts:i,...o})=>o)),n=yr(t.map(i=>i?.directHosts));return n!==void 0&&(r.directHosts=n),r}function te(e){return e?.backendProxy}function R(e){return e.replace(/\/$/,"")}function Pe(e){return/^https?:\/\//i.test(e)}function ye(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Lr(e){const t=new Set;return e.filter(r=>!r.url||t.has(r.url)?!1:(t.add(r.url),!0))}function vr(e){const t=te(e);return t?[t]:[]}function Rr(e){return{proxyEmFiles:!0,proxyAi:!1}}function Mr(e,t){const r=Rr(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 jr(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 Fr(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 kr(e,t,r){if(r.endsWith("_encoded"))return!0;const n=e.slice(0,t),i=n.lastIndexOf("#"),o=n.lastIndexOf("?"),s=n.lastIndexOf("&"),c=n.lastIndexOf("=");return c>Math.max(o,s)&&c>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}`:"/",c=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),u=c?.[1]||"",_=c?.[2]||"",l=c?.[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 re(e,t){if(!e)return{};if(Array.isArray(e)){for(const c of e){const u=re(c,t);if(u!==void 0)return u}return}if(e==="*")return{};const r=Fr(t,e),{regex:n,tokens:i}=jr(e),o=n.exec(r);if(!o)return;const s={};return i.forEach((c,u)=>{s[`matched_${c}`]=o[u+1]||""}),s}function U(e,t,r={}){const n=xr(t);if(!n)return t;const i={...n,...r};let o="",s=0;const c=/\{([a-z_]+)\}/gi;let u;for(;u=c.exec(e);){o+=e.slice(s,u.index);const _=i[u[1]]??"",l=kr(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 Ce(e,t){try{const r=new URL(t);return`${R(e)}/${r.pathname.replace(/^\//,"")}${r.search}${r.hash}`}catch{return t}}function Le(e,t){const r=R(e);return t?Pe(t)?t:t.startsWith("?")||t.startsWith("#")?`${r}${t}`:`${r}${t.startsWith("/")?"":"/"}${t}`:r}function ve(e,t,r,n){const i=e.match;return i?Array.isArray(i)?i.some(o=>ve({...e,match:o},t,r,n)):typeof i=="function"?!!i({url:t,method:n,requestType:r}):i==="*"?!0:re(i,t)!==void 0:!0}function Ur(e,t,r,n="generic"){if(e==null)return[];const i=Array.isArray(e)?e:[e],o=[];return i.forEach((s,c)=>{if(!s)return;if(typeof s=="string"){const E=s.includes("{")&&s.includes("}")?U(s,t):Ce(s,t);o.push({key:`backend:${c}`,url:E,source:"resource"});return}if(!ye(s)||!("rewrite"in s))return;const u=s;if(!ve(u,t,n,r))return;const _=typeof u.match=="string"||Array.isArray(u.match)?re(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 g=E({url:t,proxyBase:l,method:r,requestType:n,..._}),O=l&&!Pe(g)?Le(l,g):g;return O.includes("{")&&O.includes("}")?U(O,t,_):O})():l?U(Le(l,E),t,_):E.includes("{")&&E.includes("}")?U(E,t,_):Ce(E,t);o.push({key:`backend:${u.id||"rule"}:${c}:${h}`,url:p,source:"resource"})})}),Lr(o)}function Gr(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 Vr(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(R(n));return}!ye(r)||!("rewrite"in r)||(typeof r.proxyBase=="string"&&r.proxyBase.trim()&&t.push(R(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(R(i))}))}}),t}function Hr(e,t){return vr(t).flatMap(r=>Vr(r)).filter(Boolean).some(r=>r&&e.startsWith(r))}function Xr(e,t){return!!te(t)&&Mr(e,t)}function Wr(e,t={}){const r=t.requestType||Gr(e);return Xr(r,t.config)?Ur(te(t.config),e,t.method,r):[]}function $r(e,t={}){return Hr(e,t.config)?[e]:Wr(e,t).map(r=>r.url)}function N(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function Re(...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 Me=3e5,we=15e3,A=null,je=!1;function Kr(){return!0}function qr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return Me;const t=Number(e);return Number.isFinite(t)&&t>0?t:Me}function Yr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return we;const t=Number(e);return Number.isFinite(t)&&t>0?t:we}function zr(){const e="https://app.useblocks.io/api".trim();return e?N(e):void 0}function Jr(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 je||(je=!0),[]}return t.split(",").map(r=>r.trim()).filter(Boolean)}function Qr(e){const t=new Set,r=[];for(const n of e){const i=N(n);t.has(i)||(t.add(i),r.push(i))}return r}function Be(e){const t=String(e||"").trim();return t?N(t):zr()}function Fe(e,t=[]){return e?Qr([e,...t]).slice(0,3):[]}function ke(){return Jr(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function Zr(e=Date.now()){return A?e-A.switchedAt>=qr():!0}function xe(e=Date.now()){A&&Zr(e)&&(A=null)}function D(e){if(!Kr())return!1;const t=Be(e);if(!t)return!1;const r=ke();return r.length===0?!1:Fe(t,r).length>1}function M(e){const t=Be(e);if(!t)return[];const r=ke();return r.length===0?[t]:Fe(t,r)}function G(e){const t=M(e);if(t.length===0)return"";if(xe(),A){const r=t.indexOf(A.activeUrl);if(r>=0)return t[r]}return t[0]}function Ue(e){const t=M(e);if(t.length<=1||(xe(),!A||!t.includes(A.activeUrl)))return t;const r=A.activeUrl;return[r,...t.filter(n=>n!==r)]}function Ge(e){return G(e)||void 0}function Ve(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const r=Yr(),n=new AbortController;let i;const o=setTimeout(()=>{i=en(r),n.abort(i)},r);return{signal:Re(t,n.signal),timeoutError:()=>i,done:()=>clearTimeout(o)}}function en(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 Xe(e){return!(e instanceof Error)&&!(e instanceof DOMException)?!1:e.name==="TimeoutError"?!0:e instanceof TypeError}var We;function tn(e){We=e}function V(e,t){if(!D(t))return;const r=M(t);if(r.length<=1)return;const n=r.indexOf(N(e));if(n<0)return;const i=n+1;if(i>=r.length)return;const o=r[i],s=A?.activeUrl;A={activeUrl:o,switchedAt:Date.now()},s!==o&&We?.()}function $e(e,t){if(!D(t))return;const r=N(e),n=M(t);if(n.includes(r)){if(r===n[0]){A=null;return}A?.activeUrl!==r&&(A={activeUrl:r,switchedAt:Date.now()})}}function Ke(){A=null}var rn=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,c)=>{const u=o?`${o}[${c}]`:`${c}`;r(n,s,u)});return}if(typeof i=="object"){Object.keys(i).forEach(s=>{const c=i[s],u=o?`${o}[${s}]`:s;r(n,c,u)});return}n.append(o,String(i))}};return r(t,e),t},nn={baseUrl:N("https://app.useblocks.io/api"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},P=new Map;function on(e){const t=e?.getInstance(de);return t?t.get()??t.bootstrap():void 0}var sn=class extends lr{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=on(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),c=P.get(s);return!c||!o.includes(c)?o:[c,...o.filter(u=>u!==c)]}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),c=this.getBackendProxyCandidates(i,o);let u,_;for(const l of c){const E=p=>p===i?l:p,h=r?Ve(e.signal):void 0;try{const p=await super.request({...n,proxyHandler:E,...h?{signal:h.signal}:{}});if(!p.ok&&this.shouldRetryResponse(p)&&l!==c[c.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 g=h?.timeoutError();if(g)throw g;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=D(r),i=e.failoverAttemptTimeout??n,o=n?Ue(r):r?[G(r)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let s,c;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(c=E,!l){V(_,r);continue}break}return E.ok&&$e(_,r),E}catch(E){if(!Xe(E))throw E;s=E,l||V(_,r)}}if(n&&Ke(),c)return c;throw s instanceof Error?s:new Error("API origin failover chain failed")}};function an(e={},t){const r=new sn({...nn,...e},t);return r.contentFormatters["multipart/form-data"]=rn,r}var qe=f("rest.clientFactory"),cn=e=>{Or(e);const t=an({customFetch:e.getInstance(Q)?.execute??hr},e);e.inject(Z,t)},Ye;(function(e){const t="https://racs.rest/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})(Ye||(Ye={}));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 c=e.length;if(t.length!==c)return!1;for(let u=0;u<c;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 c=0;c<s;c++){const u=i[c];if(!t.hasOwnProperty(u)||!w(e[u],t[u]))return!1}}return!0}function un(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 ze(e){const[t,r,n]=e.split("."),i=JSON.parse(un(r));return{exp:i.exp,createdAt:i.iat,data:i}}var ne=f("plugin.auth.token"),Je=new WeakMap,_n=3e4;function ln(e){let t;try{t=ze(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+_n}function dn(e,t,r,n){const i=Je.get(e);i&&(i.stale=!0);const o={stale:!1};Je.set(e,o),e.injectFactory(ne,async(s,c)=>{if(o.stale)return"";try{let u=await c||void 0;if(!u){const _=e.getInstance(fe);_&&(u=await _)}return t?!u||ln(u)?await t(r,n,u):u:""}catch{return""}},!0)}var Qe=f("auth.oauthProvided"),Ze=new WeakMap;function et(e,t){const r=Ze.get(e)??{applied:!1};(!r.applied||r.getAuthToken!==t.getAuthToken||!w(r.user,t.user)||r.project!==t.project)&&(Ze.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),dn(e,t.getAuthToken,t.user,t.project))}function tt(e){if(e.getInstance(Qe))return;e.inject(Qe,!0);let t;e.getInstance(le)?.watch(r=>{t=r}),e.addService(x,{execute:async(r,n)=>{if(n?.public||!t?.getAuthToken)return;e.getInstance(ne)===void 0&&et(e,t);const i=await e.getInstanceAsync(ne);i&&r.headers.set("authorization",`Bearer ${i}`)}})}function fn(e,t){if(e===t)return;let r=0;const n=Math.min(e.length,t.length);for(;r<n&&e[r]===t[r];)r++;let i=e.length,o=t.length;for(;i>r&&o>r&&e[i-1]===t[o-1];)i--,o--;return{start:r,fromEnd:i,toEnd:o}}function En(e){let t=2166136261;for(let r=0;r<e.length;r++)t=Math.imul(t^e.charCodeAt(r),16777619);return{length:e.length,hash:t>>>0}}var pn={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"},hn={text:{fontFamily:["Google Fonts","Sans Serif","Mulish","Regular"],fontSize:16,fontSizeDim:"px",lineHeight:24,lineHeightDim:"px",color:"#595959",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},headings:{fontFamily:["Google Fonts","Sans Serif","Mulish","Bold"],fontSize:28,fontSizeDim:"px",lineHeight:34,lineHeightDim:"px",color:"#000000",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},links:{color:"#1890ff",contrastColor:"#FFFFFF",underline:!0},buttons:{fontFamily:["Google Fonts","Sans Serif","Mulish","Medium"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1890ff",bold:!1,italic:!1,backgroundColor:"#1890ff",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:6,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:"#1890ff",padding:{all:null,top:null,right:null,bottom:null,left:null}},cards:{contrastBackgroundColor:"#1890ff",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}}},rt="ERROR",On="useblocks",An={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",prm_ref_link_id:"_p_rlid",em_active_tab:"em_active_tab"},gn={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_emails_v2:"em_emails_v2",em_checks_v2:"em_checks_v2",em_blocks_v2:"em_blocks_v2",em_revisions_v2:"em_revisions_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_billing_v2:"em_billing_v2",em_guest_locale:"em_guest_locale"},mn="light",In="dark",Sn="system",Tn="(prefers-color-scheme: dark)",bn=8e3,Nn=2e3,Dn=15e3,Pn=3e3,yn={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_EBLOCK_CLEAR_EM_BLOCK_ID:"sandbox_eblock_clear_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",SANDBOX_CANVAS_SYNCED:"sandbox_canvas_synced",SANDBOX_ELEMENT_OPERATION:"sandbox_element_operation"},Cn={language:"html",detectIndentation:!1,wordWrap:"on",wrappingIndent:"same",smoothScrolling:!0,automaticLayout:!0,tabSize:2,indentSize:2},nt=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 ie(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function Ln(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 c of n)await c.setOptions(s)},dispose:()=>{for(const s of n)s.dispose()}}}}function vn(e=rt){const t=new Error(e);return t.name="AuthPipelineError",t}async function it(e,t,r,n){const i=n?.attemptTimeout??D(r),o=D(r)?Ue(r):M(r).length>0?[G(r)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const s=e.startsWith("/")?e:`/${e}`;let c,u;for(let _=0;_<o.length;_++){const l=o[_],E=_===o.length-1,h=i?Ve(t.signal):void 0;try{const p=await fetch(`${l}${s}`,{...t,...h?{signal:h.signal}:{}});if(!p.ok&&He(p.status)){if(c=p,!E){V(l,r);continue}break}return p.ok&&$e(l,r),p}catch(p){const g=h?.timeoutError();if(!g&&!Xe(p))throw p;u=g||p,E||V(l,r)}finally{h?.done()}}if(D(r)&&Ke(),c)return c;throw u instanceof Error?u:new Error("[apiOriginFailover] fetch chain failed")}function ot(e){e.inject(L,void 0),e.inject(J,void 0)}var Rn=ie(e=>{let t,r;const n=nt();return e.addService(x,{execute:n.decorate(async(i,o)=>{if(o?.public||!t)return;const s=String(e.getInstance(J)||"").trim();if(s){i.headers.append("authorization",`Bearer ${s}`);return}if(!e.getInstance(L))try{const c=e.getInstance(qe),u=String(c?.getOptions()?.baseUrl||"").trim(),_=Ge(r||u||void 0);if(!_)throw new Error("JWT auth requires baseUrl");const l=await it("/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(L,void 0),e.inject(J,h),i.headers.append("authorization",`Bearer ${h}`)}catch{throw e.inject(L,rt),vn()}})}),{setOptions(i){const o=i.jwtAuth,s=String(i.baseUrl||"").trim()||void 0,c=!w(o,t),u=s!==r;if(t=o,r=s,!o){ot(e);return}c||u?ot(e):e.inject(L,void 0)}}}),Mn=ie(e=>(tt(e),{setOptions(t){et(e,t)}}));function wn(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function oe(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=oe(e,i);if(o)return o}return null}function st(e,t=[]){const r=e.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;i&&(t.push(i),st(i,t))}return t}function jn(e,t,r){if(e.isConnected)return e;const n=e.id?.trim();return n?at(`#${wn(n)}`,t,r):Promise.reject(T("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function at(e,t,r){if(Y(r),typeof e<"u"){if(typeof e=="string"){const n=e,i=oe(n);if(i)return i;const o=t.addDisposable(new m);return new Promise((s,c)=>{const u=O=>{o.dispose(),O()},_=()=>{u(()=>c(T(r?.reason)))};if(r?.aborted){_();return}r?.addEventListener("abort",_),o.addDispose(()=>r?.removeEventListener("abort",_));const l=document.body??document.documentElement;if(!l){u(()=>c(T("Document is not ready to observe mount element")));return}const E=new Set,h=new MutationObserver(()=>{const O=oe(n);if(O){u(()=>s(O));return}g()}),p=O=>{E.has(O)||(E.add(O),h.observe(O,{attributes:!0,childList:!0,subtree:!0}))},g=()=>{const O=document.documentElement;if(O)for(const H of st(O))p(H)};p(l),g(),o.addDispose(()=>h.disconnect())})}return e instanceof Element?jn(e,t,r):e}return e}var Bn=new Map;Object.defineProperty(a,"ADVANCED_SETTINGS_PANEL",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(a,"APP_COOKIES",{enumerable:!0,get:function(){return An}}),Object.defineProperty(a,"APP_ID",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(a,"APP_LOAD_EVENT_ID",{enumerable:!0,get:function(){return Vt}}),Object.defineProperty(a,"ATOMS_HANDLERS_ID",{enumerable:!0,get:function(){return Jt}}),Object.defineProperty(a,"AsyncEmitter",{enumerable:!0,get:function(){return F}}),Object.defineProperty(a,"BaseEmitter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(a,"CANVAS_ECHO_LOST_AFTER_MS",{enumerable:!0,get:function(){return Dn}}),Object.defineProperty(a,"CANVAS_ECHO_RECOVERY_WAIT_MS",{enumerable:!0,get:function(){return Pn}}),Object.defineProperty(a,"CANVAS_FACTS",{enumerable:!0,get:function(){return pn}}),Object.defineProperty(a,"CANVAS_FOCUS_WAIT_MS",{enumerable:!0,get:function(){return bn}}),Object.defineProperty(a,"CANVAS_SETTLE_MARGIN_MS",{enumerable:!0,get:function(){return Nn}}),Object.defineProperty(a,"COMMON_STYLES",{enumerable:!0,get:function(){return hn}}),Object.defineProperty(a,"CONFIG_CHANGED_EVENT_ID",{enumerable:!0,get:function(){return Ht}}),Object.defineProperty(a,"CONFIG_SOURCE_ID",{enumerable:!0,get:function(){return de}}),Object.defineProperty(a,"COOKIE_MANAGER_ID",{enumerable:!0,get:function(){return cr}}),Object.defineProperty(a,"CUSTOM_FETCH_ID",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(a,"CUSTOM_MESSAGE",{enumerable:!0,get:function(){return k}}),Object.defineProperty(a,"Container",{enumerable:!0,get:function(){return K}}),Object.defineProperty(a,"ContentType",{enumerable:!0,get:function(){return _r}}),Object.defineProperty(a,"DARK",{enumerable:!0,get:function(){return In}}),Object.defineProperty(a,"DISPOSABLE_ID",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(a,"DependencyResolver",{enumerable:!0,get:function(){return C}}),Object.defineProperty(a,"Disposable",{enumerable:!0,get:function(){return m}}),Object.defineProperty(a,"ELEMENT_MAP",{enumerable:!0,get:function(){return Bn}}),Object.defineProperty(a,"EVENT_TYPES",{enumerable:!0,get:function(){return yn}}),Object.defineProperty(a,"Emitter",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(a,"HANDLE_ATOM_INSERT_ID",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(a,"HEADLESS_MODE_ID",{enumerable:!0,get:function(){return Zt}}),Object.defineProperty(a,"INIT_PIPELINE_ID",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(a,"INSTANCE_ID",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(a,"JWTMixin",{enumerable:!0,get:function(){return Rn}}),Object.defineProperty(a,"LATE_SURFACE_LISTENERS_ID",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(a,"LIGHT",{enumerable:!0,get:function(){return mn}}),Object.defineProperty(a,"LOCAL_STORAGE_ITEMS",{enumerable:!0,get:function(){return gn}}),Object.defineProperty(a,"MESSAGE_SERVICE_ID",{enumerable:!0,get:function(){return rr}}),Object.defineProperty(a,"MODAL_CLOSE_EVENT",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(a,"MODAL_SHOW_EVENT",{enumerable:!0,get:function(){return or}}),Object.defineProperty(a,"MODAL_UPDATE_EVENT",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(a,"MONACO_EDITOR_OPTIONS",{enumerable:!0,get:function(){return Cn}}),Object.defineProperty(a,"MessageService",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(a,"OAuthMixin",{enumerable:!0,get:function(){return Mn}}),Object.defineProperty(a,"OPTIONS_SOURCE_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(a,"PLUGIN_COLLECTION_ID",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(a,"PORT_READY",{enumerable:!0,get:function(){return he}}),Object.defineProperty(a,"PREFERS_COLOR_SCHEME_DARK",{enumerable:!0,get:function(){return Tn}}),Object.defineProperty(a,"PUBLIC_REQUEST",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(a,"REQUEST_HANDLER_ID",{enumerable:!0,get:function(){return x}}),Object.defineProperty(a,"REST_CLIENT_FACTORY_ID",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(a,"REST_TRANSPORT_ID",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(a,"SANDBOX_EXTENSIONS_ID",{enumerable:!0,get:function(){return er}}),Object.defineProperty(a,"SANDBOX_EXTENSION_SCRIPT_STATUS_ID",{enumerable:!0,get:function(){return tr}}),Object.defineProperty(a,"SECURITY_MODULE_ID",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(a,"SETTINGS_PANEL_EVENT",{enumerable:!0,get:function(){return nr}}),Object.defineProperty(a,"STANDALONE_ACTIVATED_ID",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(a,"STANDALONE_BOOTSTRAP_TOKEN_ID",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(a,"STANDALONE_FILE_PROXY_REGISTERED_ID",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(a,"STANDALONE_PROJECT_ID",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(a,"STORE_ID",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(a,"SYSTEM",{enumerable:!0,get:function(){return Sn}}),Object.defineProperty(a,"Signal",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(a,"TEMPLATE_DIRECTIVES_ID",{enumerable:!0,get:function(){return ur}}),Object.defineProperty(a,"USEBLOCKS",{enumerable:!0,get:function(){return On}}),Object.defineProperty(a,"combineMixins",{enumerable:!0,get:function(){return Ln}}),Object.defineProperty(a,"composeAbortSignals",{enumerable:!0,get:function(){return Re}}),Object.defineProperty(a,"createAbortError",{enumerable:!0,get:function(){return T}}),Object.defineProperty(a,"createIdentifier",{enumerable:!0,get:function(){return $t}}),Object.defineProperty(a,"createIdentifier$1",{enumerable:!0,get:function(){return f}}),Object.defineProperty(a,"createQueue",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(a,"debounce",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(a,"decodeJwt",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(a,"deepEqual",{enumerable:!0,get:function(){return w}}),Object.defineProperty(a,"defineMixin",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(a,"events",{enumerable:!0,get:function(){return z}}),Object.defineProperty(a,"fetchWithApiOriginFailover",{enumerable:!0,get:function(){return it}}),Object.defineProperty(a,"filter",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(a,"findTextDiffBounds",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(a,"generateUUID",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(a,"getActiveBaseUrl",{enumerable:!0,get:function(){return G}}),Object.defineProperty(a,"getApi",{enumerable:!0,get:function(){return Ar}}),Object.defineProperty(a,"getContainer",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(a,"getEmitter",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(a,"getEmitter$1",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(a,"getEvent",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(a,"getServiceContainerId",{enumerable:!0,get:function(){return j}}),Object.defineProperty(a,"isAbortError",{enumerable:!0,get:function(){return St}}),Object.defineProperty(a,"mapHttpStatusToErrorCode",{enumerable:!0,get:function(){return It}}),Object.defineProperty(a,"mergeBackendProxyLayers",{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(a,"mergeResourceProxyLayers",{enumerable:!0,get:function(){return br}}),Object.defineProperty(a,"mergeResourceProxyPolicyLayers",{enumerable:!0,get:function(){return Cr}}),Object.defineProperty(a,"mergeShallowConfigLayers",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(a,"pickKey",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(a,"provideOAuth",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(a,"raceWithAbortSignal",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(a,"registerRestTransport",{enumerable:!0,get:function(){return cn}}),Object.defineProperty(a,"releaseContainer",{enumerable:!0,get:function(){return mr}}),Object.defineProperty(a,"resolveContainer",{enumerable:!0,get:function(){return pt}}),Object.defineProperty(a,"resolveExplicitApiBaseUrl",{enumerable:!0,get:function(){return Ge}}),Object.defineProperty(a,"setApiOriginFailoverHook",{enumerable:!0,get:function(){return tn}}),Object.defineProperty(a,"snapshot",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(a,"textFingerprint",{enumerable:!0,get:function(){return En}}),Object.defineProperty(a,"throwIfAborted",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(a,"waitForElement",{enumerable:!0,get:function(){return at}})});
|
|
2096
|
+
__useblocks__.define("static/umd/58ef5318.js",["require","exports","module"],function(Ve,o,ke){var l=class H{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof H&&t.addDispose(()=>{this.removeDisposable(t)}),t}addDispose(t){this.addDisposable({dispose:t})}removeDisposable(t){const n=this._inner.indexOf(t);n>=0&&this._inner.splice(n,1)}isDisposed(){return this._isDisposed}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(const t of[...this._inner])t.dispose()}}};function N(e){return`service_container_${e}`}var D=new Set,T;function W(){if(!T)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,h.prototype.getInstanceAsync),e.stack}function A(e){D.delete(e)&&T?.end(e)}var h=class m extends l{_parent;_injectCallbacks=[];_injections=Object.create(null);_runCallbacks(t){[...this._injectCallbacks].forEach(n=>n(t))}constructor(t=null){super(),this._parent=t,t&&this.addDisposable(t.onInject(n=>this._runCallbacks(n)))}onInject=t=>(this._injectCallbacks.push(t),{dispose:()=>{const n=this._injectCallbacks.indexOf(t);n>=0&&this._injectCallbacks.splice(n,1)}});inject(t,n){this._injections[t]=()=>n,this._runCallbacks(t)}injectFactory(t,n,r){const i=this._injections[t];let c=typeof i=="function"?i():i;const u=this._injections[t]=()=>(c=n(this,c),c);r&&u(),this._runCallbacks(t)}_find(t,n=!0){return this._injections[t]||n&&this._parent?._find(t)}_onInject(t,n,r=new l){return r.addDisposable(this.onInject(i=>{t===i&&!r.isDisposed()&&(r.dispose(),n(this.getInstance(i)))})),this._parent&&r.addDisposable(this._parent._onInject(t,n,r)),this.addDisposable(r),r}getInstance(t,n=!0){const r=this._find(t,n);if(typeof r=="function")return r()}getOrCreateInstance(t,n){const r=this._find(t);if(typeof r=="function")return r();const i=n(this);return this.inject(t,i),i}getInstanceAsync(t){const n=this._find(t);if(typeof n=="function")return Promise.resolve(n());const r=W();return new Promise((i,c)=>{const u={id:String(t),startedAt:Date.now(),origin:r,container:this,reject:c};D.add(u),T?.start(u),this._onInject(t,()=>{A(u),i(this.getInstance(t))})})}failPendingWaits(t){for(const n of Array.from(D))n.container===this&&(A(n),n.reject(t))}pendingWaits(){return[...D].filter(t=>t.container===this)}addService(t,n){const r=N(t);this.injectFactory(r,(c,u=[])=>u.indexOf(n)<0?[...u,n]:u);const i=new l;return i.addDispose(()=>{this.injectFactory(r,(c,u=[])=>u.filter(f=>f!==n))}),i}addServiceFactory(t,n,r){const i=N(t);let c;this.injectFactory(i,(f,_=[])=>(c=n(f,c),c===void 0?_:_.indexOf(c)<0?[..._,c]:_),r);const u=new l;return u.addDispose(()=>{this.injectFactory(i,(f,_=[])=>c===void 0?_:_.filter(E=>E!==c))}),u}getServices(t){const n=N(t);return[...this.getInstance(n,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new m(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const n=this._parent?.getOrCreateIsolatedContainer(t);return new m(n)})}remove(t){const n=this._injections;delete n[String(t)]}injectListenerCount(){return this._injectCallbacks.length}dispose(){for(const t of Array.from(D))t.container===this&&A(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function C(e){return e.startsWith("__")?e:`__${e}__`}function X(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=C(e),n=globalThis;return n[t]??={}}function Y(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function J(e){if(e)return C(e);const t="useblocks".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return C(t)}function y(e){const t=J(e),n=X(t);if(Y(n.container))return n.container;const r=new h(null);return n.container=r,r}function q(e){return y(e)}function Q(){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(n){let r=Math.random()*16;return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),(n==="x"?r:r&3|8).toString(16)})}function P(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Q()}function a(e=P()){return e}function R(){return"umd".trim()||"unknown"}function $(e){if(typeof globalThis>"u")return;const t=R(),n=globalThis[e]??{};globalThis[e]=n;const r=n.__diagnostics??={},i=r.diModuleEval??={evalCount:0,records:[]};i.records.push({buildSource:t,timestamp:Date.now(),stack:new Error().stack}),i.evalCount+=1}function z(){const e="useblocks".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function Z(e,t){if($(t),typeof globalThis>"u")return e;const n=R(),r=globalThis,i=r[t]=r[t]||{},c=i.__diagnostics=i.__diagnostics||{},u=c.dependencyResolver=c.dependencyResolver||{entries:[]},f={container:e,source:"packages/runtime-core/di/index.ts",buildSource:n,timestamp:Date.now(),stack:new Error().stack};return u.entries.push(f),e}var p;function ee(){if(p)return p;const e=z();return p=Z(y(e),e),p}var te=new Proxy({},{get(e,t,n){const r=ee(),i=Reflect.get(r,t,n);return typeof i=="function"?i.bind(r):i}});function ne(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 I(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 re(e){return e instanceof DOMException&&e.name==="AbortError"}function g(e){if(e?.aborted)throw I(e.reason)}function ie(e,t){return t?(t.aborted&&e.catch(()=>{}),g(t),new Promise((n,r)=>{const i=()=>{c(),r(I(t.reason))},c=()=>{t.removeEventListener("abort",i)};t.addEventListener("abort",i),e.then(u=>{c(),n(u)},u=>{c(),r(u)})})):e}var v=class extends l{_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,n){if(this.isDisposed())return{dispose:()=>{}};const r=this._listeners,i=this._options;n&&typeof e=="function"&&(e=e.bind(n));const c=r.findIndex(([,f])=>f<t),u=[e,t];return r.splice(c>=0?c:r.length,0,u),r.length===1&&i.onFirstListenerAdd&&i.onFirstListenerAdd(),{dispose:()=>{const f=r.indexOf(u);f>=0&&(r.splice(f,1),!r.length&&i.onLastListenerRemove&&i.onLastListenerRemove())}}}on=this._addListener.bind(this);event=this._addListener.bind(this);once=(e,t=0,n)=>{const r=this._addListener((...i)=>(r?.dispose(),n?e.call(n,...i):e(...i)),t);return r};un=e=>{const t=this._listeners.findIndex(([n])=>n===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()}},O=class extends v{execute(e,t){for(const n of t)try{n(...e)}catch{}}fire(...e){if(!this.isDisposed()){const t=this.execute(e,this.getListeners(e));return t===void 0?void 0:t}}},oe=class extends O{execute([e],t){for(const n of t)try{n(e)}catch{}}},se=class extends O{_suspendCounter=0;_wasFired=!1;execute([e],t){if(this._suspendCounter)this._wasFired=!0;else for(const n of t)try{n(e)}catch{}}suspend(){this._suspendCounter++}resume(){--this._suspendCounter===0&&this._wasFired&&(this.fire(),this._wasFired=!1)}},b=class extends O{async execute([e],t){const n=[];for(const r of t)try{n.push(await r(e))}catch{}return n}async fireSettled(e){const t={results:[],errors:[]};if(this.isDisposed())return t;for(const n of this.getListeners([e]))try{t.results.push(await n(e))}catch(r){t.errors.push(r)}return t}};function ce(e,t=0){const n=new v,r=e(n,t);return r&&n.addDisposable(r),n.event}function ue(e,t,n=0){const r=new O,i=e((...c)=>{if(t(...c))return r.fire(...c)},n);return i&&r.addDisposable(i),r.event}function ae(e,t=0,n=0){const r=new O;let i,c;const u=e((...f)=>{c=f,i||(i=setTimeout(()=>{c&&r.fire(...c),i=void 0},t))},n);return u&&r.addDisposable(u),r.event}function _e(e,t){return e.getOrCreateInstance(t,()=>new b)}function s(e){return a(e)}var L;(function(e){e.BEFORE_SAVE_EMAIL=s("events.BEFORE_SAVE_EMAIL"),e.ON_SAVEBUTTON_CLICK_ID=s("events.ON_SAVEBUTTON_CLICK_ID"),e.ON_NEXTBUTTON_CLICK_ID=s("events.ON_NEXTBUTTON_CLICK_ID"),e.ON_PREVIOUSBUTTON_CLICK_ID=s("events.ON_PREVIOUSBUTTON_CLICK_ID"),e.ON_DOCUMENT_SESSION_CHANGE=s("events.ON_DOCUMENT_SESSION_CHANGE"),e.WILL_EMAIL_INIT_ID=s("events.WILL_EMAIL_INIT_ID"),e.ON_EMAIL_INIT_ID=s("events.ON_EMAIL_INIT_ID"),e.ON_BLOCK_INIT_ID=s("events.ON_BLOCK_INIT_ID"),e.ON_CONTENT_CHANGED_ID=s("events.ON_CONTENT_CHANGED_ID"),e.ON_PREHEADER_CHANGED_ID=s("events.ON_PREHEADER_CHANGED_ID"),e.ON_SUBJECT_CHANGED_ID=s("events.ON_SUBJECT_CHANGED_ID"),e.ON_EMAIL_CHANGED_ID=s("events.ON_EMAIL_CHANGED_ID"),e.ON_BLOCK_CHANGED_ID=s("events.ON_BLOCK_CHANGED_ID"),e.ON_BLOCK_OPEN_ID=s("events.ON_BLOCK_OPEN_ID"),e.ON_BLOCK_CLOSE_ID=s("events.ON_BLOCK_CLOSE_ID"),e.OPEN_BLOCK_REQUEST_ID=s("events.OPEN_BLOCK_REQUEST_ID"),e.ON_BLOCK_SAVEBUTTON_CLICK_ID=s("events.ON_BLOCK_SAVEBUTTON_CLICK_ID"),e.ON_BLOCK_CLONE_ID=s("events.ON_BLOCK_CLONE_ID"),e.ON_CHUNKS_LOADED=s("events.ON_CHUNKS_LOADED"),e.ON_SEND_TESTEMAIL_ID=s("events.ON_SEND_TESTEMAIL_ID"),e.ON_SEND_LIVEPREVIEW_ID=s("events.ON_SEND_LIVEPREVIEW_ID"),e.ON_SHARE_ID=s("events.ON_SHARE_ID"),e.ON_SHOW_PREVIEW_ID=s("events.ON_SHOW_PREVIEW_ID"),e.ON_EMAIL_CLONE_ID=s("events.ON_EMAIL_CLONE_ID"),e.ON_SEND_EMAIL_MODAL_ID=s("events.ON_SEND_EMAIL_MODAL_ID"),e.ON_ANALYTICS_EVENT=s("events.ON_ANALYTICS_EVENT"),e.ON_NOTIFICATION=s("events.ON_NOTIFICATION"),e.READ_LOCALE=s("events.READ_LOCALE"),e.ON_TRANSLATE_ID=s("events.ON_TRANSLATE_ID"),e.ON_CODE_VALIDATE_ID=s("events.ON_CODE_VALIDATE_ID"),e.ON_IMPORT_VALIDATE_ID=s("events.ON_IMPORT_VALIDATE_ID"),e.UPLOAD_EVENT_ID=s("events.UPLOAD_EVENT_ID"),e.PROXY_URL_EVENT_ID=s("events.PROXY_URL_EVENT_ID"),e.FILE_PROXY_EVENT_ID=s("events.FILE_PROXY_EVENT_ID"),e.ON_LIMIT_ID=s("events.ON_LIMIT_ID"),e.ON_BROWSER_EXTENSION_DETECTED_ID=s("events.ON_BROWSER_EXTENSION_DETECTED_ID"),e.ON_LAYOUT_CONVERT_REQUEST_ID=s("events.ON_LAYOUT_CONVERT_REQUEST_ID"),e.ON_BROWSER_TRANSLATE_DETECTED_ID=s("events.ON_BROWSER_TRANSLATE_DETECTED_ID"),e.AI_TEXT_REQUEST_ID=s("events.AI_TEXT_REQUEST_ID"),e.AI_IMAGE_REQUEST_ID=s("events.AI_IMAGE_REQUEST_ID"),e.AI_TEXT_PROGRESS_ID=s("events.AI_TEXT_PROGRESS_ID"),e.AI_IMAGE_PROGRESS_ID=s("events.AI_IMAGE_PROGRESS_ID"),e.AI_TEXT_STREAM_ID=s("events.AI_TEXT_STREAM_ID")})(L||(L={}));function fe(e,t){return e.getOrCreateInstance(t,()=>new b).event}function de(e,t){return e.getOrCreateInstance(t,()=>new b)}var Ee=a("plugin.app"),le=a("plugin.disposable"),Ie=a("InitPipelineContext"),Oe=a("plugin.instance"),De=a("plugin.lateSurfaceListeners"),Ne=a("plugin.optionsSource"),pe=a("plugin.store"),be=a("ConfigSource"),Te=a("plugin.standalone.project"),j=a("plugin.standalone.bootstrapToken"),Ge=a("plugin.element"),Ae=a("plugin.securityModule"),he=a("plugin.standalone.activated"),Ce=a("plugin.standalone.fileProxyRegistered"),ge=a("plugin.jwt.token"),Le=a("plugin.jwt.error"),Se=a("PluginCollection"),me=s("APP_LOAD_EVENT"),ye=s("CONFIG_CHANGED_EVENT");function Pe(e){const t=e.replace(/-/g,"+").replace(/_/g,"/").padEnd(e.length+(4-e.length%4)%4,"="),n=atob(t),r=new Uint8Array(n.length);for(let i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return new TextDecoder().decode(r)}function w(e){const[t,n,r]=e.split("."),i=JSON.parse(Pe(n));return{exp:i.exp,createdAt:i.iat,data:i}}var M=a("plugin.auth.token"),U=new WeakMap,Re=3e4;function ve(e){let t;try{t=w(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+Re}function je(e,t,n,r){const i=U.get(e);i&&(i.stale=!0);const c={stale:!1};U.set(e,c),e.injectFactory(M,async(u,f)=>{if(c.stale)return"";try{let _=await f||void 0;if(!_){const E=e.getInstance(j);E&&(_=await E)}return t?!_||ve(_)?await t(n,r,_):_:""}catch{return""}},!0)}function we(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function Me(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function S(e,t=document){try{const r=t.querySelector(e);if(r)return r}catch{return null}const n=t.querySelectorAll("*");for(let r=0;r<n.length;r++){const i=n[r]?.shadowRoot;if(!i)continue;const c=S(e,i);if(c)return c}return null}function B(e,t=[]){const n=e.querySelectorAll("*");for(let r=0;r<n.length;r++){const i=n[r]?.shadowRoot;i&&(t.push(i),B(i,t))}return t}function Ue(e,t,n){if(e.isConnected)return e;const r=e.id?.trim();return r?F(`#${Me(r)}`,t,n):Promise.reject(I("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function F(e,t,n){if(g(n),typeof e<"u"){if(typeof e=="string"){const r=e,i=S(r);if(i)return i;const c=t.addDisposable(new l);return new Promise((u,f)=>{const _=d=>{c.dispose(),d()},E=()=>{_(()=>f(I(n?.reason)))};if(n?.aborted){E();return}n?.addEventListener("abort",E),c.addDispose(()=>n?.removeEventListener("abort",E));const V=document.body??document.documentElement;if(!V){_(()=>f(I("Document is not ready to observe mount element")));return}const k=new Set,G=new MutationObserver(()=>{const d=S(r);if(d){_(()=>u(d));return}x()}),K=d=>{k.has(d)||(k.add(d),G.observe(d,{attributes:!0,childList:!0,subtree:!0}))},x=()=>{const d=document.documentElement;if(d)for(const Fe of B(d))K(Fe)};K(V),x(),c.addDispose(()=>G.disconnect())})}return e instanceof Element?Ue(e,t,n):e}return e}var Be=new Map;Object.defineProperty(o,"APP_ID",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(o,"APP_LOAD_EVENT_ID",{enumerable:!0,get:function(){return me}}),Object.defineProperty(o,"AsyncEmitter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(o,"BaseEmitter",{enumerable:!0,get:function(){return O}}),Object.defineProperty(o,"CONFIG_CHANGED_EVENT_ID",{enumerable:!0,get:function(){return ye}}),Object.defineProperty(o,"CONFIG_SOURCE_ID",{enumerable:!0,get:function(){return be}}),Object.defineProperty(o,"Container",{enumerable:!0,get:function(){return h}}),Object.defineProperty(o,"DISPOSABLE_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(o,"DependencyResolver",{enumerable:!0,get:function(){return te}}),Object.defineProperty(o,"Disposable",{enumerable:!0,get:function(){return l}}),Object.defineProperty(o,"ELEMENT_MAP",{enumerable:!0,get:function(){return Be}}),Object.defineProperty(o,"Emitter",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(o,"INIT_PIPELINE_ID",{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(o,"INSTANCE_ID",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(o,"JWT_ERROR_ID",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(o,"JWT_TOKEN_ID",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(o,"LATE_SURFACE_LISTENERS_ID",{enumerable:!0,get:function(){return De}}),Object.defineProperty(o,"OPTIONS_SOURCE_ID",{enumerable:!0,get:function(){return Ne}}),Object.defineProperty(o,"PLUGIN_COLLECTION_ID",{enumerable:!0,get:function(){return Se}}),Object.defineProperty(o,"SECURITY_MODULE_ID",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(o,"STANDALONE_ACTIVATED_ID",{enumerable:!0,get:function(){return he}}),Object.defineProperty(o,"STANDALONE_BOOTSTRAP_TOKEN_ID",{enumerable:!0,get:function(){return j}}),Object.defineProperty(o,"STANDALONE_FILE_PROXY_REGISTERED_ID",{enumerable:!0,get:function(){return Ce}}),Object.defineProperty(o,"STANDALONE_PROJECT_ID",{enumerable:!0,get:function(){return Te}}),Object.defineProperty(o,"STORE_ID",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(o,"Signal",{enumerable:!0,get:function(){return se}}),Object.defineProperty(o,"TOKEN_ID",{enumerable:!0,get:function(){return M}}),Object.defineProperty(o,"createAbortError",{enumerable:!0,get:function(){return I}}),Object.defineProperty(o,"createIdentifier",{enumerable:!0,get:function(){return a}}),Object.defineProperty(o,"debounce",{enumerable:!0,get:function(){return ae}}),Object.defineProperty(o,"decodeJwt",{enumerable:!0,get:function(){return w}}),Object.defineProperty(o,"defineMixin",{enumerable:!0,get:function(){return we}}),Object.defineProperty(o,"events",{enumerable:!0,get:function(){return L}}),Object.defineProperty(o,"filter",{enumerable:!0,get:function(){return ue}}),Object.defineProperty(o,"generateUUID",{enumerable:!0,get:function(){return P}}),Object.defineProperty(o,"getEmitter",{enumerable:!0,get:function(){return de}}),Object.defineProperty(o,"getEmitter$1",{enumerable:!0,get:function(){return _e}}),Object.defineProperty(o,"getEvent",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(o,"getServiceContainerId",{enumerable:!0,get:function(){return N}}),Object.defineProperty(o,"isAbortError",{enumerable:!0,get:function(){return re}}),Object.defineProperty(o,"mapHttpStatusToErrorCode",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(o,"raceWithAbortSignal",{enumerable:!0,get:function(){return ie}}),Object.defineProperty(o,"recreateTokenProvider",{enumerable:!0,get:function(){return je}}),Object.defineProperty(o,"resolveContainer",{enumerable:!0,get:function(){return q}}),Object.defineProperty(o,"snapshot",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(o,"throwIfAborted",{enumerable:!0,get:function(){return g}}),Object.defineProperty(o,"waitForElement",{enumerable:!0,get:function(){return F}})});
|
|
2097
2097
|
|
|
2098
2098
|
|
|
2099
2099
|
__useblocks__.define("static/umd/d786efbb.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
|
-
__useblocks__.define("useblocks.js",["require","exports","module","static/umd/b11043e6.js","static/umd/6d027ea0.js","static/umd/d786efbb.js"],function(sn,ve,HT){Object.defineProperties(ve,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const wt=sn("./static/umd/b11043e6.js"),l=sn("./static/umd/6d027ea0.js"),Zd=sn("./static/umd/d786efbb.js");var eu=new Function("url","return import(url)");function tu(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function lr(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function _o(e){return e.type==="umd"||e.resolve==="registry"}var nu="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 ru(e){const t=Array.isArray(e)?e[0]:e;return lr(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function su(e,t){const n=ru(e),r=lr(e)?e:void 0,s=t instanceof Error?t.message:String(t),o=r&&_o(r)&&!/compat/iu.test(s)?` ${nu}`:"",i=new Error(`Plugin "${n}" was skipped: it failed to load. ${s}${o}`);return i.cause=t,{name:n,url:r?.url,error:i}}function ou(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}function VT(e){return e}var iu=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(lr(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(_o(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await eu(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 s;const o=a=>{s||(a.filename===r.src?s=this._scriptExecutionError(e,a.error??a.message):ou(a)&&(s=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},i=()=>window.removeEventListener("error",o);window.addEventListener("error",o),r.onload=()=>{if(i(),s){n(s);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 s=await this._resolveOrSkip(r);if(!s)continue;const o=this._createOrSkip(s.ctor,s.options);o&&!n.has(o)&&(n.add(o),t.push(o))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const 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 s=[],o=new Set;for(const{ctor:i,options:a}of n){const c=this._createOrSkip(i,a);c&&!o.has(c)&&(o.add(c),s.push(c))}this._activated&&await this._startPluginsBatch(s)}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,s)=>{let o,i=!1;const a=()=>{i||(i=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(o=setTimeout(()=>{i||(i=!0,this._pluginRegistry.off(e,a),s(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),s=this._createPluginInstance(e,r),o=s.constructor.name;this._emitLifecycle({type:"created",plugin:s,name:o}),s.required?.(),this._map.set(n,s),this._creationOrder.push(s),this._setupReadyPromise(s)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=su(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return tu(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const s of t){if(this._initializedPlugins.has(s))continue;const o=this._initializingPlugins.get(s);if(o){n.add(o);continue}r.push(s)}if(r.length>0){const s=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,s);n.add(s),s.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===s&&this._initializingPlugins.delete(o)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const s=this._options.openEarlyWindow?.();try{await this._callSync(n,r,"init"),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(o){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:o})}finally{s?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await this._callSync(n,r,"afterInit"),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(s){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:s})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}_callSync(e,t,n){this._emitLifecycle({type:`${n}:enter`,plugin:e,name:t});try{return e[n]?.()}finally{this._emitLifecycle({type:`${n}:leave`,plugin:e,name:t})}}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},au=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 s of n)try{s.callback(t)}catch{}const r=n.filter(s=>!s.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(s=>(t.ctor=s,t.loading=void 0,this._notifyListeners(e,s),s));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 s={callback:t,once:!1};return r.push(s),{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 s={callback:t,once:!0};return r.push(s),{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(s=>s.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)}}}},cu=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()}},Eo=class{capacity;items=[];constructor(e){this.capacity=e}push(e){this.items.length>=this.capacity&&this.items.shift(),this.items.push(e)}snapshot(){return this.items.slice()}size(){return this.items.length}clear(){this.items=[]}};function lu(e,t){return t+e}function du(){return typeof performance>"u"?Date.now():lu(performance.now(),performance.timeOrigin)}var uu="emailmaker:diagnostics",fu="diagnostics",hu="diagnostics";function bo(e,t){return t?`${e}${e.includes("?")?"&":"?"}${hu}=1`:e}var dr;function pu(){try{const e=new URLSearchParams(window.location.search).get(fu);return e===null?void 0:e!=="0"}catch{return}}function mu(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function gu(){try{const e=window.localStorage.getItem(uu);return e===null?void 0:e==="1"}catch{return}}function St(){return dr===void 0&&(dr=typeof window>"u"?!1:pu()??mu()??gu()??!1),dr}function vu(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var fe={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"},GT=Object.values(fe),WT=[fe.canvasPainted,fe.canvasSettled,fe.appVisible,fe.editorVisible],_u=5e3,Eu=3e3,yo="diagnosticsStore",on,It;function wo(){return{marks:new Eo(_u),resources:new Eo(Eu)}}function So(){if(It)return It;const e=ur();return e?(It=e[yo]??on??wo(),e[yo]=It,on=void 0,It):(on??=wo(),on)}function se(e,t){St()&&So().marks.push({phase:e,at:du(),...t})}function ur(){if(typeof __useblocks__<"u"&&__useblocks__)return __useblocks__;if(typeof window>"u")return;const e=window[vu()];return e!==null&&typeof e=="object"?e:void 0}function bu(e){const t=e.length,n=So();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function yu(){const e=ur();return!e||!Array.isArray(e.diagnosticsBuffer)?0:bu(e.diagnosticsBuffer)}var wu="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function ke(){const e=new Error(wu);return e.name="DestroyedInstanceError",e}function Su(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function fr(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const o=e,i=t;return o.length===i.length&&o.every((a,c)=>fr(a,i[c]))}const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&fr(e[o],t[o]))}function Io(e,t){const n={watch(r){let s,o=!1;return e.watch(i=>{const a=t(i);o&&fr(s,a)||(s=a,o=!0,r(a))})},select(r){return Io(n,r)}};return n}function re(...e){let t=e[0],n=e.length>0;const r=new Set,s={get(){return n?t:void 0},set(o){t=o,n=!0;for(const i of Array.from(r))i(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return Io(s,o)}};return s}var Iu=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})},To=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 Tu(e){return String(e||"").trim()||void 0}var Au=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=Tu(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)}},hr=l.createIdentifier$1("AppInitService");function Cu(e){return async()=>{const t=await e();return(await new Iu(t).app_init_create({})).data}}function Ou(e){e.injectFactory(hr,(t,n)=>{if(n)return n;const r=new Au({options:e.getInstance(l.OPTIONS_SOURCE_ID),isStandalone:()=>!!e.getInstance(l.SECURITY_MODULE_ID),resolveRestBaseUrl:s=>s?l.getActiveBaseUrl(s):l.getActiveBaseUrl()||void 0,setRestBaseUrl:s=>{e.getInstance(l.REST_CLIENT_FACTORY_ID)?.setOptions(s?{baseUrl:s}:{})},fallbackAppInit:Cu(()=>e.getInstanceAsync(l.REST_TRANSPORT_ID)),publish:s=>{e.inject(l.APP_ID,s)}});return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var nt=l.createIdentifier$1("documentSession.emailDocuments");function rt(e){return e?.getInstance(nt)}var Du=l.createIdentifier$1("RevisionServiceFlag");function Ao(e){return e.getOrCreateInstance(Du,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Co(e){return Ao(e).isEnabled()}var Oo=l.createIdentifier$1("EmailRightsResolver");function Pu(e,t){return e.onInject(n=>{n===Oo&&t()})}function Do(e,t){const n=e.getInstance(Oo);return n?n(t):!0}var pr={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Po=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],Ro=2e4,Ru=Po.reduce((e,t)=>e+pr[t],0),ko=Ro+Ru+3e3;function ku(e){return Po.reduce((t,n)=>t+No(n,e),0)}function No(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:pr[e]}function Lo(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:ko}function Mo(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:Ro}function Tt(e=ko){return e+3e3}var YT="[show-pipeline]";function xo(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}function KT(e,t){}var Nu=()=>Tt();function Lu(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function Mu(e){return t=>Lu(e.getOrCreateInstance(l.events.BEFORE_SAVE_EMAIL,()=>new l.AsyncEmitter).fire(t),Nu())}var Fo=Symbol.for("emailmaker.saveRefusedError"),Bo=Symbol.for("emailmaker.integratorSaveTimeoutError");function jo(e,t,n,r){return e!==t?Function.prototype[Symbol.hasInstance].call(e,r):typeof r=="object"&&r!==null&&n in r}var Oe=class Xd extends Error{reason;detail;static[Symbol.hasInstance](t){return jo(this,Xd,Fo,t)}constructor(t,n){super(n?`[emailmaker] save refused: ${t}: ${n}`:`[emailmaker] save refused: ${t}`),this.name="SaveRefusedError",this.reason=t,this.detail=n,Object.defineProperty(this,Fo,{value:!0})}},Uo=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[useblocks] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},an=class Jd extends Error{timeoutMs;static[Symbol.hasInstance](t){return jo(this,Jd,Bo,t)}constructor(t,n="handleSaveEmail",r="email"){super(`[useblocks] ${n} did not respond within ${t}ms — the ${r} was not saved`),this.timeoutMs=t,this.name="IntegratorSaveTimeoutError",Object.defineProperty(this,Bo,{value:!0})}};function ae(e){return e.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService)}var $o=new WeakMap,mr=new WeakMap;function _e(e){return $o.get(e)??0}function At(e,t){let n=mr.get(e);return n||(n=new Set,mr.set(e,n)),n.add(t),()=>{n?.delete(t)}}function xu(e){$o.set(e,_e(e)+1),mr.get(e)?.forEach(t=>t())}function gr(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var Fu=l.createIdentifier$1("documentSession.canvasReceipts");function Bu(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const s={guid:n,version:r};return e=s,()=>{e===s&&(e=void 0)}},note(n,r){const s=gr(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(s,n)}},read(n){if(!e)return;const{scope:r}=t,s={guid:e.guid,rev:e.version()};return r.originId!==null?{...s,changeId:t.changeId,originId:r.originId}:{...s,changeId:r.generation===n?t.changeId:0}}}}function Ho(e){return e.getOrCreateInstance(Fu,Bu)}var ju=2e3,Uu=l.CANVAS_ECHO_LOST_AFTER_MS+l.CANVAS_ECHO_RECOVERY_WAIT_MS+ju;function $u(e,t=Uu){return async()=>{const n=ae(e);let r;const s=new Promise(o=>{r=setTimeout(()=>o("silent"),t)});try{const o=Ho(e).read(_e(n)),i=await Promise.race([n.sendAsync(l.EVENT_TYPES.SANDBOX_CANVAS_SYNCED,o?{applied:o}:void 0,!1),s]);if(i==="silent"||i&&!i.synced)throw i==="silent"||i?.unsent,new Oe("canvas-not-synced")}finally{clearTimeout(r)}}}var Hu="em_autosave_pending",qT=6e4;function cn(e){return`${Hu}_${e}`}function vr(e,t){try{return sessionStorage.setItem(cn(e),JSON.stringify(t)),!0}catch{return!1}}function ln(e){try{const t=sessionStorage.getItem(cn(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(cn(e)),null):n}catch{return null}}function Be(e){try{sessionStorage.removeItem(cn(e))}catch{}}function _r(e){return`block:${e}`}function Vo(e,t){return t?_r(e):e}function Er(e,t){(ln(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&Be(e)}function Vu(e){return e!=null&&e!==""}function Go(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var Wo;function Gu(){return Go(l.LOCAL_STORAGE_ITEMS.em_revisions_v2)??!0}function Wu(){return Wo??=Gu(),Wo}function st(e){return Co(e)&&Wu()}function Yu(){return!1}var Yo;function Ct(e,t){return Yo?.capture(e,t)}function Ku(e,t){return Yo?.captureMessage(e,t)}var qu=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],zu=200;function Ko(e=new Set){const t=new Set;return(n,r)=>{if(!qu.some(([o,i])=>!e.has(o)&&i.test(n)))return;const s=r??`new:${n.length}:${n.slice(0,200)}`;t.has(s)||(t.size>=zu&&t.clear(),t.add(s))}}function qo(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Ko()}}var Xu=qo();function Ne(e){return e?.getInstance(l.TEMPLATE_DIRECTIVES_ID)??Xu}function Ju(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function dn(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Ie=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${dn(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${dn(this.oldText)}")`:`(replace@${this.oldPosition} "${dn(this.oldText)}" with "${dn(this.newText)}")`}};function zo(e,t){return e===null||e.length===0?t:new Qu(e,t).compress()}var Qu=class Re{_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),s=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(s===null)break;this._acceptCurr(s),s=this._getCurr(++n);continue}if(s===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(s.oldEnd<=r.newPosition){this._acceptCurr(s),s=this._getCurr(++n);continue}if(r.newEnd<=s.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(s.oldPosition<r.newPosition){const[c,d]=Re._splitCurr(s,r.newPosition-s.oldPosition);this._acceptCurr(c),s=d;continue}if(r.newPosition<s.oldPosition){const[c,d]=Re._splitPrev(r,s.oldPosition-r.newPosition);this._acceptPrev(c),r=d;continue}let i,a;if(s.oldEnd===r.newEnd)i=r,a=s,r=this._getPrev(++t),s=this._getCurr(++n);else if(s.oldEnd<r.newEnd){const[c,d]=Re._splitPrev(r,s.oldLength);i=c,a=s,r=d,s=this._getCurr(++n)}else{const[c,d]=Re._splitCurr(s,r.newLength);i=r,a=c,r=this._getPrev(++t),s=d}this._result[this._resultLen++]=new Ie(i.oldPosition,i.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=i.newLength-i.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const o=Re._merge(this._result);return Re._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=Re._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++]=Re._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new Ie(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Ie(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),s=t.newText.substr(n);return[new Ie(t.oldPosition,t.oldText,t.newPosition,r),new Ie(t.oldEnd,"",t.newPosition+n,s)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),s=t.oldText.substr(n);return[new Ie(t.oldPosition,r,t.newPosition,t.newText),new Ie(t.oldPosition+n,s,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,s=t[0];for(let o=1;o<t.length;o++){const i=t[o];s.oldEnd===i.oldPosition?s=new Ie(s.oldPosition,s.oldText+i.oldText,s.newPosition,s.newText+i.newText):(n[r++]=s,s=i)}return n[r++]=s,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let s=0;s<t.length;s++){const o=t[s];o.oldText!==o.newText&&(n[r++]=o)}return n}};function Zu(e){return new Ie(e.newPosition,e.newText,e.oldPosition,e.oldText)}function ef(e){return e.map(Zu)}function Xo(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function tf(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const s=t[r];n=n.slice(0,s.oldPosition)+s.newText+n.slice(s.oldEnd)}return n}function Jo(e,t,n){let r=0;const s=e.start===e.end;for(const o of t){const i=o.newLength-o.oldLength;if(o.oldLength===0){const a=o.oldPosition;if(s&&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(s){if(e.start>=o.oldEnd)r+=i;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=i;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}function Qo(e,t,n){if(!t.length)return[...e];const r=[];let s=0;for(const o of e){const i=Jo({start:o.oldPosition,end:o.oldEnd},t,n);if(!i)return null;r.push(new Ie(i.start,o.oldText,i.start+s,o.newText)),s+=o.newLength-o.oldLength}return r}var je=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Zo=0,nf=Math.random().toString(36).slice(2,8);function rf(){return Zo+=1,`doc-${nf}-${Zo}`}function sf(e){const t=e.createBuffer(),n=e.docId??rf();let r=e.serverId??null,s=0,o=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!==s&&(h={version:s,value:t.read()}),h.value),m=v=>Object.entries(v).some(([_,T])=>i[_]!==T);return{get:()=>({docId:n,serverId:r,version:s,savedVersion:o,attributes:i}),getContent:g,mutate(v,{source:_}){if(c)return s;const T=v.changes?.length?v.changes:void 0,A=T?tf(g(),T):v.content!==void 0?v.content:void 0,B=A!==void 0&&A!==g(),O=v.attributes!==void 0&&m(v.attributes);if(!B&&!O)return s;const S=!(s>(o??-1)),w=O?Object.keys(v.attributes).filter(I=>i[I]!==v.attributes[I]):[];B&&t.write(A),O&&(i={...i,...v.attributes}),s+=1,_!=="user"&&S&&(o=s);const D={source:_,version:s,changes:T,...B?{content:!0}:{},...w.length>0?{attributes:w}:{}};return a.forEach(I=>I(D)),s},markSaved(v,_){const T={serverId:r,savedVersion:o};_!==void 0&&(r=_),(o===null||v>o)&&(o=v),(T.serverId!==r||T.savedVersion!==o)&&a.forEach(A=>A({source:"system",version:s}))},markUnsaved(){c||o===null||o<s||(o=s-1,a.forEach(v=>v({source:"system",version:s})))},markReady(){d||u!==void 0||(d=!0,f.forEach(v=>v.resolve()),f.clear(),a.forEach(v=>v({source:"system",version:s})))},isReady:()=>d,markFailed(v){d||u!==void 0||c||(u=v,f.forEach(_=>_.reject(new je(v))),f.clear(),a.forEach(_=>_({source:"system",version:s})))},failure:()=>u,whenReady(){return d?Promise.resolve():u!==void 0?Promise.reject(new je(u)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((v,_)=>{f.add({resolve:v,reject:_})})},subscribe(v){return a.add(v),()=>a.delete(v)},isNew:()=>r===null,isDirty:()=>s>(o??-1),isDisposed:()=>c,dispose(){c=!0,f.forEach(v=>v.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),f.clear(),a.clear(),t.dispose()}}}var of=500,af=100,br=0,ei=0;function cf(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function ti(e,t,n){let r=0;for(const s of t){if(s.oldPosition>e||s.oldPosition===e&&(s.oldLength>0||!n))break;if(s.oldEnd>e)return s.newEnd;r=s.newEnd-s.oldEnd}return e+r}function yr(e,t){if(!e)return e;if(e.start===e.end){const n=t(e.start,"caret");return{start:n,end:n}}return{start:t(e.start,"start"),end:t(e.end,"end")}}var ni=(e,t)=>t==="old"?e.oldPosition:e.newPosition,ri=(e,t)=>t==="old"?e.oldEnd:e.newEnd;function si(e,t,n,r){const s=t==="start"?["start","end"]:["end","start"];for(const o of s){const i=r.findIndex(a=>(o==="start"?ni(a,n):ri(a,n))===e);if(i>=0)return{index:i,edge:o}}}function lf(e,t,n){if(!e?.after)return e;const r=(s,o)=>{const i=si(s,o,"new",n);return ti(s,t,i?i.edge==="start"&&n[i.index].newLength>0:o==="start")};return{...e,after:yr(e.after,r)}}function df(e,t,n,r,s){const o=(i,a)=>(c,d)=>{const u=si(c,d,i,t);return u?u.edge==="start"?ni(n[u.index],i):ri(n[u.index],i):ti(c,a,d==="start")};return e&&{before:yr(e.before,o("old",r)),after:yr(e.after,o("new",s))}}function uf(e,t={}){const n=t.groupIntervalMs??of,r=t.maxSteps??af,s=t.now??(()=>0);let o=[],i=0,a=br+=1,c=null,d,u,f,h=!1,g=!1,m=!1,v=0,_=!1,T=!1;const A=new Set,B=()=>A.forEach(E=>E()),O=(E,N)=>{if(E.length){m=!0;try{e.mutate({changes:E},{source:N})}finally{m=!1}}},S=E=>O(E,"user"),w=E=>{const N=d?.from??s(),F=v>0?_:g&&c!==null&&h===(d!==void 0)&&N>=c&&N-c<n;if(v>0&&(_=!0),F){const W=o[i-1];o[i-1]={...W,changes:zo(W.changes,E),selection:cf(W.selection,u)}}else o=o.slice(0,i),ei+=1,o.push({id:ei,below:o[i-1]?.id??0,changes:E,selection:u}),i=o.length,g=!0,o.length>r&&(o=o.slice(o.length-r),i=o.length,a=br+=1);c=d?.to??N,h=d!==void 0,B()},D=()=>{g=!1,c=null},I=E=>{let N=E;for(let F=i;F<o.length;F+=1){const W=o[F],ee=Qo(W.changes,N,"after"),te=ee&&Qo(N,W.changes,"before");if(!ee||!te)return o=o.slice(0,F),!0;o[F]={...W,changes:ee,selection:df(W.selection,W.changes,ee,N,te)},N=te}return!1},R=E=>{if(!E.length)return;const N=I(E);if(i>0){const F=o[i-1];o[i-1]={...F,changes:zo(F.changes,E),selection:lf(F.selection,E,F.changes)}}D(),N&&B()},M=e.subscribe(({source:E,changes:N})=>{if(!(T||m||!N?.length)){if(E==="remote"){P();return}if(E!=="user"){R(N);return}w(N)}}),P=()=>{o=[],i=0,_=!1,D(),a=br+=1,B()},L=(E,N)=>{_=!1,f=N;try{S(E)}finally{f=void 0}},x=(E=!1)=>{if(i===0)return!1;const N=o[i-1],F=ef(N.changes);return Xo(e.getContent(),F)?(L(F,E?{kind:"undo",selection:N.selection?.before}:void 0),i-=1,D(),!0):(o=o.slice(0,i-1),i=o.length,_=!1,D(),B(),!1)},U=()=>{const E=x(!0);return E&&B(),D(),E},y=()=>{if(i>=o.length)return D(),!1;const E=o[i];return Xo(e.getContent(),E.changes)?(L(E.changes,{kind:"redo",selection:E.selection?.after}),i+=1,D(),B(),!0):(o=o.slice(0,i),D(),B(),!1)};return{recordAt(E,N,F){const W=d,ee=u;d=E,u=F;try{return N()}finally{d=W,u=ee}},activeMove:()=>f,canUndo:()=>i>0,canRedo:()=>i<o.length,undo(){U()},redo(){y()},tryUndo:U,tryRedo:y,clear:P,closeGroup:D,beginTransaction(){v===0&&(_=!1),v+=1;let E=!1;return()=>{E||(E=!0,v-=1,v===0&&(_=!1,D()))}},applyWithoutHistory(E){const N=e.get().version;if(O(E,"system"),e.get().version===N){D();return}R(E)},getPast:E=>o.slice(0,i).reverse().slice(0,E).map(N=>N.changes),getFuture:E=>o.slice(i).reverse().slice(0,E).map(N=>N.changes),createSnapshot:()=>({stackId:a,index:i}),restoreSnapshot(E){if(E.stackId!==a||E.index>i)return!1;for(;i>E.index;)if(!x())return B(),!1;return B(),!0},currentStep:()=>({id:o[i-1]?.id??0,below:o[i-1]?.below??0}),subscribe(E){return A.add(E),()=>A.delete(E)},dispose(){T=!0,M(),A.clear(),o=[],i=0}}}var ff=["edit","move","resize","insert"];function wr(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function hf(e){return typeof e=="string"?e:null}function pf(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function mf(e){return ff.includes(e)?e:null}function gf(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:hf(t.originId),changeId:wr(t.changeId),rev:wr(t.rev),baseRev:wr(t.baseRev),expected:pf(t.expected),intent:mf(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}function vf(e){return e instanceof Oe?e.reason:void 0}var oi={"too-many-tags":"The email has more tags than allowed, so nothing was saved.","canvas-not-synced":"Not all canvas edits reached the document, so nothing was saved; try again in a moment.","plugin-refused":"A plugin refused the save, so nothing was saved."};function _f(e){const t=vf(e);if(t===void 0||t==="locked")return;const{detail:n}=e;return n?`${oi[t]} Its reason: ${n}`:oi[t]}var ii=Symbol.for("emailmaker.blockSaveFlight"),ai=Symbol.for("emailmaker.blockSaveSessionQueue"),Sr=new WeakMap;function ci(e,t){return Object.isExtensible(e)||t in e?e[t]:Sr.get(e)?.get(t)}function li(e,t,n){if(t in e||Object.isExtensible(e)){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0});return}const r=Sr.get(e)??new Map;r.set(t,n),Sr.set(e,r)}function Ef(e,t){li(e,ai,t)}function bf(e,t){const n=(ci(e,ii)??Promise.resolve()).then(t,t);return li(e,ii,n.catch(()=>{})),n}function yf(e,t){return ci(e,ai)?.(t)??bf(e,t)}var Ot=new Map,di=new Map;function wf(e){return Ot.set(e,(Ot.get(e)??0)+1),()=>{const t=(Ot.get(e)??1)-1;if(t>0){Ot.set(e,t);return}Ot.delete(e);const n=di.get(e);di.delete(e),n?.forEach(r=>r())}}var Ir=e=>e.replace(/\r\n?/g,`
|
|
2103
|
-
`),Sf=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function Tr(e){return typeof e=="string"&&Sf.test(e)}var If=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function Tf(){return typeof navigator<"u"&&navigator.onLine===!1}function Af(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 s=r.data;typeof r.data=="object"&&s.error!=null&&t.push(s.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 ui(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 ui(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 Cf(e){return Tf()?!0:Af(e).some(ui)}var fi=new WeakSet,hi=new WeakMap;function pi(e){typeof e=="object"&&e!==null&&fi.add(e)}function Of(e,t){typeof e=="object"&&e!==null&&hi.set(e,t)}function Df(e){return typeof e=="object"&&e!==null?hi.get(e):void 0}function Pf(e){return e instanceof an||e instanceof Uo||typeof e=="object"&&e!==null&&fi.has(e)}function Rf(e){return e instanceof Oe||mi(e)||e instanceof If||Pf(e)}function mi(e){return Ar(e)?.v2Error?.data?.code==="blocks.block_locked"}function gi(e){return Ar(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function Ar(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function kf(e){if(e instanceof Oe)return e.reason==="canvas-not-synced";if(Rf(e))return!1;const t=Ar(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?gi(e):!0}return Cf(e)||gi(e)}var vi="draft";function ot(e){return e==null||e===""?vi:String(e)}function un(e){return e==null||e===""?`${Cr}${vi}`:`${Cr}${String(e)}`}var Cr="block:";function J(e){return e?.startsWith(Cr)===!0}function it(e){return J(e.sessionKey())?void 0:e.current()}function zT(e,t){}function Ue(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return se(`show:gate:${e}`,{kind:"wait"}),t.then(s=>(se(`show:gate:${e}:end`,{kind:"wait"}),s),s=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw l.isAbortError(s)?(`${e}`,{...n}):(`${e}`,{error:xo(s),...n},void 0),s})}var XT=5e3,Nf=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function Lf(e){const t=e?.trim()??"";if(!Nf.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function Dt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Or(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Mf(e,t={}){const n=Dt((e??[]).filter(r=>r?.html?.trim()));return Or(n,t)?n:null}function xf(e,t){const n=Date.parse(Dt(e)?.modified??""),r=Mf(e),s=Date.parse(r?.modified??""),o=t===void 0||Number.isFinite(s)&&s>t,i=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:o?r:null,...i.length?{latestAt:Math.max(...i)}:{}}}function _i(e,t,n){const r=Dt((e??[]).filter(c=>c?.html?.trim())),s=Date.parse(r?.modified??""),o=Date.parse(Dt((n??[]).filter(c=>c?.html?.trim()))?.modified??""),i=r&&Number.isFinite(s)&&(t===void 0||s>t)&&!(o>s),a=[Date.parse(Dt(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:i&&Or(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Ff({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Ei=["recovery","plugin","rest"],Bf=["subject","preheader"];function jf(e){let t={},n;for(let s=Ei.length-1;s>=0;s--){const o=e.get(Ei[s]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const s of Bf){const o=r?.[s];typeof o=="string"&&o!==""&&(t={...t,[s]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function fn(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Ir(t.content):void 0,s=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...s?{changes:[new Ie(0,n,0,r)]}:{}},{source:"remote"})}var Dr=e=>typeof e=="string"?e.trim():"";function Uf(e,t,n,r){const{version:s,attributes:o}=e.get(),i=o,a=r==="snapshot"||r==="anchor",c=a?i.author:void 0,d=a?i.date_gmt:void 0,u=Dr(i.title)||Dr(i.subject)||Dr(t.fallbackTitle);return{version:s,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,projectCategories:i.projectCategories,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 $f=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Hf(e){const t={};for(const n of $f)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Vf(e,t,n,r,s,o){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(s);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,s):t.saveAutosave(r,s,o==null?void 0:{wpId:o})}function De(e,t=!1){const n={};for(const r of Object.keys(e)){let s=e[r];s!==void 0&&!(typeof s=="number"&&Number.isNaN(s))&&(t&&typeof s=="object"&&s!==null&&(s=De(s)),n[r]=s)}return n}function Gf(e){return typeof e=="string"&&e.includes("autosave")}var Wf=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function bi(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Wf.has(t))):{}}function at(e,t,n={}){e&&e.mutate({attributes:Yf(e.get().attributes,t)},{source:n.source??"user"})}function Yf(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Pr(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Kf(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function yi(e){if(!e)return null;const t=bi(e);return e.common_styles!==void 0&&(t.common_styles=Kf(e.common_styles)),Pr(e.html,t)}function wi(e){return e?Pr(e.html,De(bi(e))):null}var qf=["common_styles","subject","preheader","meta"];function Si(e){if(!e?.html?.trim())return null;const t={};for(const n of qf)zf(n,e[n])&&(t[n]=e[n]);return Pr(e.html,t)}function zf(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 Xf=["modified","lock","wpId","secretHash"];function Ii(e){if(!e)return null;const t={};for(const n of Xf)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Jf=10,Qf=(e,t)=>e.key===t.key&&Zf(e.serverId,t.serverId),Zf=(e,t)=>e==null||e===t;function eh(e){return typeof e?.then=="function"}var Ti=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Ai=e=>{e.request.serverId!=null&&!hn(e)&&e.document.markSaved(e.document.get().version)},hn=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Ci=(e,t)=>t?.content!==void 0&&Ff({hasUnsavedUserEdit:hn(e)})==="skip",Oi=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},th=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()}),nh=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.userTouched.clear(),e.document.get().docId))},rh=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([s,o])=>e.attributes[s]!==o)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},sh=e=>{const t=jf(e.reports),n=rh(e.lastMerged,t);e.lastMerged=t,e.broughtContent=pn(t.content)??e.broughtContent,n&&(fn(e.document,n),Ai(e))},Rr=(e,t)=>{if(!e.ready&&!hn(e)){sh(e);return}e.broughtContent=pn(t?.content)??e.broughtContent,fn(e.document,t)},pn=e=>e===void 0?void 0:Ir(e),oh=(e,t)=>t.content===void 0||pn(t.content)!==e.broughtContent||!hn(e)?t:{...t,content:void 0},Di=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 ih(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:s,resolveTerms:o,canEdit:i,notifyBeforeSave:a,confirmPublish:c,awaitCanvasSynced:d,savedEchoForm:u=p=>p,queuesOutsideWrites:f,onAdapterError:h,onTimeout:g}=e;let m,v;const _=new Set,T=new Set,A=()=>_.forEach(p=>p()),B=(p,b)=>{if(!(p.closed||p.ready)){if(p.error!==void 0){p.document.markFailed(p.error),p.document.get().docId;return}Ai(p),p.ready=!0,p.document.markReady(),p.document.get().docId,[...p.reports.keys()]}},O=(p,b,C)=>{h?.(b.id,C),!(!b.required||p.closed)&&(p.error=C,p.document.get().docId,b.id,A())},S=(p,b)=>{const C=new Set(b.map(V=>V.id));b.forEach(V=>{V.watch&&p.watchers.push(V.watch(Y=>p.closed?!1:p.ready&&(Ci(p,Y)||p.contentShown===!0&&Y?.content!==void 0)?(p.document.get().docId,V.id,!1):(Y&&p.reports.set(V.id,Y),Rr(p,Y),Y?.content!==void 0&&(p.showFill=void 0),!0)))});const j=(V,Y)=>{if(!p.closed){if(!V.required&&Ci(p,Y)){p.document.get().docId,V.id,V.loaded?.(!1);return}Y&&(p.reports.set(V.id,Y),V.id==="plugin"&&Oi(p,Y)),Rr(p,Y),V.loaded?.(Y!==null)}},G=()=>{C.size>0||p.closed||(Ti(p),B(p,[]))},z=[];if(b.forEach(V=>{let Y;try{Y=V.load()}catch(k){O(p,V,k),C.delete(V.id);return}if(eh(Y)){z.push({id:V.id,required:V.required,load:()=>Y,...V.loaded?{loaded:k=>V.loaded?.(k)}:{}});return}j(V,Y),C.delete(V.id)}),z.length===0){G();return}p.timer=setTimeout(()=>{p.timer=void 0,g?.([...C]),p.document.get().docId,[...C],B(p,[...C])},n),p.timer.unref?.(),z.forEach(V=>{V.load().then(Y=>j(V,Y)).catch(Y=>{O(p,V,Y)}).finally(()=>{C.delete(V.id),G()})})},w=async(p,b,C)=>{if(C==="snapshot"||C==="anchor")return;const j=o?.();if(j)return j.resolve({project:b.project??p.project,tags:(p.tags??[]).map(G=>({name:G}))})},D=p=>{if(p.lock===!0&&i?.(p)===!1)return new Oe("locked");const b=p.tags?.length??0,C=p.emailtags?.length??0;if(Math.max(b,C)>Jf)return new Oe("too-many-tags")},I=(p,b)=>{const C=p.document.get().serverId;C!=null&&(p.createKey=void 0),!(b||C==null)&&(p.recoveryFacts={emailId:C,historyLoaded:!0,isRecovering:!1},J(p.request.key)||(p.request={...p.request,key:ot(C),serverId:C}))},R=(p,b,C)=>{if(p.closed||C?.id==null)return;const j=p.document.get().serverId,G=j!=null;G&&j!==String(C.id)||(p.document.markSaved(b,String(C.id)),I(p,G),p.document.get().serverId,A())},M=(p,b,C)=>{if(!(b==="materialize"||b==="publish"&&p.document.get().serverId==null))return C;const j=p.createKey,G=j&&j.project===C.project?j:{key:l.generateUUID(),project:C.project};return p.createKey=G,{...C,idempotencyKey:G.key}},P=async(p,b,C)=>{try{await p.document.whenReady()}catch(k){return p.saveError=k,p.saveFailures+=1,p.failedIntent=b,p.saveFailures,!1}if(p.closed)return!1;const j=D(p.document.get().attributes);if(j)return p.saveError=j,p.saveFailures+=1,p.failedIntent=b,j.reason,A(),!1;if(a&&(await a(Di(p)).catch(()=>{}),p.closed))return!1;if(d){try{await d()}catch(k){return p.saveError=k,p.saveFailures+=1,p.failedIntent=b,p.saveFailures,A(),!1}if(p.closed)return!1}if(c&&b==="publish"){const k=await c(Di(p),p.request.key).catch(()=>{});if(p.closed)return!1;if(k!==void 0)return p.saveError=new Oe("plugin-refused",k),p.saveFailures+=1,p.failedIntent=b,A(),!1}let G;try{G=await w(p.document.get().attributes,C,b)}catch(k){return p.saveError=k,p.saveFailures+=1,p.failedIntent=b,p.saveFailures,A(),!1}if(p.closed)return!1;const{payload:z,version:V}=Uf(p.document,C,G,b),Y=M(p,b,z);p.document.get().docId;try{const k=p.document.get().serverId!=null,q=await Vf(r(),s(p.request.key),b,p.document.get().serverId,Y,p.document.get().attributes.wpId);if(p.closed)return!0;let X;if(b==="snapshot"||b==="anchor"){const Z=q?.modified!=null?Date.parse(q.modified):NaN;X=Number.isFinite(Z)?Z:Date.now(),p.snapshotVersion=V,p.lastRevisionAt=X}else{p.document.markSaved(V,q?.id!=null?String(q.id):void 0);const Z=q;fn(p.document,Ii(Z&&{wpId:Z.wpId,secretHash:Z.secretHash})),p.broughtContent=pn(u(Y.html))}I(p,k),p.saveError=void 0,p.saveFailures=0,p.failedIntent=void 0,p.document.get().serverId,A();const me={intent:b,serverId:p.document.get().serverId,created:!k,...X!==void 0?{revisionAt:X}:{}};return T.forEach(Z=>Z(me)),!0}catch(k){return(b==="publish"||b==="materialize")&&Df(k)?.then(q=>R(p,V,q)),p.saveError=k,p.saveFailures+=1,p.failedIntent=b,p.saveFailures,A(),!1}},L=p=>{p.closed=!0,p.watchers.forEach(b=>b()),p.watchers=[],Ti(p),p.history.dispose(),p.document.dispose()},x=()=>{m&&(L(m),m=void 0)},U=()=>{v&&(L(v),v=void 0)},y=(p,b,C)=>{let j=!1;b.show&&(p.show?.id!==b.show.id||p.show.token!==b.show.token)&&(p.show=b.show,j=!0,{docId:p.document.get().docId,...b.show});const G=C==="show"?wi(b.patch):null;if(G){p.reports.set("plugin",G),Oi(p,G);const z=oh(p,G);Rr(p,z),nh(p,z)}j&&A()},E=(p,b={})=>W(m,p,b),N=()=>m&&J(m.request.key??"")?v:m,F=p=>({error:p?.saveError,failures:p?.saveFailures??0,saving:p?.saving===!0,failedIntent:p?.failedIntent}),W=(p,b,C)=>!p||p.closed||b==="materialize"&&p.document.get().serverId!=null?Promise.resolve(!1):p.saving?b==="snapshot"||b==="materialize"?Promise.resolve(!1):(p.inFlight??Promise.resolve(!1)).then(()=>W(p,b,C)):(p.saving=!0,A(),p.inFlight=P(p,b,C).finally(()=>ee(p)),p.inFlight),ee=p=>{p.saving=!1,p.inFlight=void 0,m===p&&!p.closed&&A()},te=(p,b)=>{if(p.closed)return b();if(p.saving)return(p.inFlight??Promise.resolve(!1)).then(()=>te(p,b));p.saving=!0,A();const C=Promise.resolve().then(b);return p.inFlight=C.then(()=>!0,()=>!1).finally(()=>ee(p)),C},ne=(p,b)=>{const C=p.document.get().serverId,j=C==null?void 0:wf(C);return te(p,b).finally(j)},K=(p,b="open",C=!1)=>{if(m&&!m.closed&&b!=="new"&&Qf(m.request,p))return y(m,p,b),m.document;x(),C||U();const j=sf({createBuffer:()=>Ju(""),serverId:p.serverId??null}),G={request:p,show:p.show,document:j,history:uf(j,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return m=G,Ef(j,z=>f?.(G.request.key)===!0?ne(G,z):void 0),G.watchers.push(th(G)),j.get().docId,p.serverId,S(G,t(p,{publishRecoveryFacts(z){G.closed||(G.recoveryFacts=z,A())},readShownContent:()=>G.closed?null:G.document.getContent(),readWpId:()=>G.closed?void 0:G.document.get().attributes.wpId})),A(),j},$=(p,b,C)=>({key:J(p)?p:un(p),serverId:b?.id!=null?String(b.id):null,email:b,show:C});return{openWith:K,open:(p,b={})=>K({key:ot(p),serverId:p,email:b.email,patch:b.patch,show:b.show},"open"),openDraft:(p,b={})=>K({key:ot(void 0),serverId:null,email:p,patch:b.patch,show:b.show},"open"),startNewDraft:(p,b={})=>K({key:ot(void 0),serverId:null,email:p,patch:b.patch,show:b.show},"new"),reload:(p,b={})=>K({key:ot(p),serverId:p,email:b.email,patch:b.patch,show:b.show},"new"),openBlock:(p,b,C)=>K($(p,b,C),"open"),reloadBlock:(p,b,C)=>K($(p,b,C),"new"),openBlockOver:(p,b)=>{const C=$(p,b);return m&&!m.closed&&m.request.key===C.key?m.document:(m&&!m.closed&&!J(m.request.key)&&(U(),v=m,m=void 0),K(C,"open",!0))},resumeSuspended:()=>{if(v)return x(),m=v,v=void 0,A(),m.document},hasSuspended:()=>!!v,suspendedDocument:()=>v?.document,show:(p,b)=>{const C=m;if(!(!C||C.closed))return K({...C.request,patch:p,show:b},"show")},current:()=>m?.document,noteServerFacts:({serverId:p,block:b},C)=>{const j=m;!j||j.closed||j.request.serverId!==p||J(j.request.key??"")===b&&fn(j.document,Ii(C))},save:E,saveEmail:(p,b={})=>W(N(),p,b),saveState:()=>F(m),emailSaveState:()=>F(N()),revisionFacts(){if(!m)return;const p=m.revisionFactsSnapshot;return p&&p.snapshotVersion===m.snapshotVersion&&p.lastRevisionAt===m.lastRevisionAt?p:(m.revisionFactsSnapshot={snapshotVersion:m.snapshotVersion,lastRevisionAt:m.lastRevisionAt},m.revisionFactsSnapshot)},recoveryFacts:()=>m?.recoveryFacts,history:()=>m?.history,forcedHeaders:()=>m?.forcedHeaders,beginForcedHeaders(p){m&&!m.closed&&(m.forcedHeaders=p)},endForcedHeaders(){for(const p of[m,v])p&&(p.forcedHeaders=void 0)},onSaved(p){return T.add(p),()=>T.delete(p)},showFacts:()=>m?.show,shownHeaders:()=>({...m?.shownHeaders}),showFill:()=>m?.showFill,beginShowFill(p){m&&!m.closed&&(m.showFill={showId:p,codeEdits:0})},noteCodeEdit(){m?.showFill&&(m.showFill.codeEdits+=1)},endShowFill(p){for(const b of[m,v])b?.showFill?.showId===p&&(b.showFill=void 0)},sessionKey:()=>m?.request.key,openError:()=>m?.error,subscribe(p){return _.add(p),()=>_.delete(p)},close(){!m&&!v||(x(),U(),A())}}}var kr=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function Nr(e){if(e instanceof kr)return e.reason;if(e instanceof je)return Nr(e.reason)}function ah(e){const t=e instanceof je?e.reason:e;return t instanceof kr&&t.reason==="unavailable"&&t.cause instanceof TypeError}function ch(e){const t=Nr(e);return t!==void 0&&t!=="unavailable"}function lh(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new kr("not-found");return yi(n)}}}var Pi=l.createIdentifier$1("EmailPort");function dh(e){return e.getInstance(Pi)}function uh(e,t){e.inject(Pi,t)}var Ri=l.createIdentifier$1("documentSession.restEmailPortFactories");function ki(e){return e.getInstance(Ri)!==void 0}function $e(e){const t=e.getInstance(Ri);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var fh=l.createIdentifier$1("EmailTermsResolver");function hh(e){return e.getInstance(fh)}var Ni=l.createIdentifier$1("EmailHistoryPort"),ph=l.createIdentifier$1("BlockHistoryPort");function Li(e){return e.getInstance(ph)}function Mi(e){return e.getInstance(Ni)}function mh(e,t){e.inject(Ni,t)}var gh=2e3,vh=5e3,_h=5,Eh=5e3,bh=4;function yh(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function mn(e,t){return e==null||t==null?!1:e.replaceAll(`\r
|
|
2102
|
+
__useblocks__.define("useblocks.js",["require","exports","module","static/umd/b11043e6.js","static/umd/58ef5318.js","static/umd/d786efbb.js"],function(Sn,be,qO){Object.defineProperties(be,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Lt=Sn("./static/umd/b11043e6.js"),d=Sn("./static/umd/58ef5318.js"),Df=Sn("./static/umd/d786efbb.js");var Pf=new Function("url","return import(url)");function Rf(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function xr(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function ri(e){return e.type==="umd"||e.resolve==="registry"}var kf="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 Nf(e){const t=Array.isArray(e)?e[0]:e;return xr(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function Lf(e,t){const n=Nf(e),r=xr(e)?e:void 0,s=t instanceof Error?t.message:String(t),o=r&&ri(r)&&!/compat/iu.test(s)?` ${kf}`:"",i=new Error(`Plugin "${n}" was skipped: it failed to load. ${s}${o}`);return i.cause=t,{name:n,url:r?.url,error:i}}function xf(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}function zO(e){return e}var Mf=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(xr(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(ri(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await Pf(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 s;const o=a=>{s||(a.filename===r.src?s=this._scriptExecutionError(e,a.error??a.message):xf(a)&&(s=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},i=()=>window.removeEventListener("error",o);window.addEventListener("error",o),r.onload=()=>{if(i(),s){n(s);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 s=await this._resolveOrSkip(r);if(!s)continue;const o=this._createOrSkip(s.ctor,s.options);o&&!n.has(o)&&(n.add(o),t.push(o))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const 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 l=this._creationOrder.indexOf(c);l>=0&&this._creationOrder.splice(l,1)}const s=[],o=new Set;for(const{ctor:i,options:a}of n){const c=this._createOrSkip(i,a);c&&!o.has(c)&&(o.add(c),s.push(c))}this._activated&&await this._startPluginsBatch(s)}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,s)=>{let o,i=!1;const a=()=>{i||(i=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(o=setTimeout(()=>{i||(i=!0,this._pluginRegistry.off(e,a),s(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),s=this._createPluginInstance(e,r),o=s.constructor.name;this._emitLifecycle({type:"created",plugin:s,name:o}),s.required?.(),this._map.set(n,s),this._creationOrder.push(s),this._setupReadyPromise(s)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=Lf(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 Rf(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 s of t){if(this._initializedPlugins.has(s))continue;const o=this._initializingPlugins.get(s);if(o){n.add(o);continue}r.push(s)}if(r.length>0){const s=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,s);n.add(s),s.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===s&&this._initializingPlugins.delete(o)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const s=this._options.openEarlyWindow?.();try{await this._callSync(n,r,"init"),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(o){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:o})}finally{s?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await this._callSync(n,r,"afterInit"),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(s){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:s})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}_callSync(e,t,n){this._emitLifecycle({type:`${n}:enter`,plugin:e,name:t});try{return e[n]?.()}finally{this._emitLifecycle({type:`${n}:leave`,plugin:e,name:t})}}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},Ff=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 s of n)try{s.callback(t)}catch{}const r=n.filter(s=>!s.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(s=>(t.ctor=s,t.loading=void 0,this._notifyListeners(e,s),s));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 s={callback:t,once:!1};return r.push(s),{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 s={callback:t,once:!0};return r.push(s),{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(s=>s.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)}}}},Bf=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()}},si=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 jf(e,t){return t+e}function Uf(){return typeof performance>"u"?Date.now():jf(performance.now(),performance.timeOrigin)}var $f="emailmaker:diagnostics",Hf="diagnostics",Gf="diagnostics";function oi(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Gf}=1`:e}var Mr;function Vf(){try{const e=new URLSearchParams(window.location.search).get(Hf);return e===null?void 0:e!=="0"}catch{return}}function Wf(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Kf(){try{const e=window.localStorage.getItem($f);return e===null?void 0:e==="1"}catch{return}}function xt(){return Mr===void 0&&(Mr=typeof window>"u"?!1:Vf()??Wf()??Kf()??!1),Mr}function qf(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var he={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"},YO=Object.values(he),XO=[he.canvasPainted,he.canvasSettled,he.appVisible,he.editorVisible],zf=5e3,Yf=3e3,ii="diagnosticsStore",In,Mt;function ai(){return{marks:new si(zf),resources:new si(Yf)}}function ci(){if(Mt)return Mt;const e=Fr();return e?(Mt=e[ii]??In??ai(),e[ii]=Mt,In=void 0,Mt):(In??=ai(),In)}function oe(e,t){xt()&&ci().marks.push({phase:e,at:Uf(),...t})}function Fr(){if(typeof __useblocks__<"u"&&__useblocks__)return __useblocks__;if(typeof window>"u")return;const e=window[qf()];return e!==null&&typeof e=="object"?e:void 0}function Xf(e){const t=e.length,n=ci();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Jf(){const e=Fr();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Xf(e.diagnosticsBuffer)}var Qf="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function De(){const e=new Error(Qf);return e.name="DestroyedInstanceError",e}function Zf(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function Br(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const o=e,i=t;return o.length===i.length&&o.every((a,c)=>Br(a,i[c]))}const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&Br(e[o],t[o]))}function li(e,t){const n={watch(r){let s,o=!1;return e.watch(i=>{const a=t(i);o&&Br(s,a)||(s=a,o=!0,r(a))})},select(r){return li(n,r)}};return n}function se(...e){let t=e[0],n=e.length>0;const r=new Set,s={get(){return n?t:void 0},set(o){t=o,n=!0;for(const i of Array.from(r))i(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return li(s,o)}};return s}function eh(e,t=window){return{peer:e,send(n){e.postMessage(n,"*")},subscribe(n){const r=s=>{n({data:s.data,source:s.source,ports:s.ports})};return t.addEventListener("message",r),{dispose:()=>t.removeEventListener("message",r)}},close(){}}}function th(e){let t=!1;return{peer:e,send(n){e.postMessage(n)},subscribe(n){const r=s=>{n({data:s.data,source:e})};return e.addEventListener("message",r),t||(t=!0,e.start()),{dispose:()=>e.removeEventListener("message",r)}},close(){e.close()}}}function JO(e){return e}function nh(e){return e&&typeof e=="object"}function di(e,t){return e&&typeof e=="object"&&e.operationId===t}var Re="INIT_MESSAGE",rh="em:port-ready",sh="em:window-drained",An="";function ui(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var oh=class extends d.Disposable{_listeners=Object.create(null);addListenerAsync=(e,t,n=0,r)=>{const s=this._listeners[e]||(this._listeners[e]=[]);r&&typeof t=="function"&&(t=t.bind(r));const o=s.findIndex(([a,c])=>n<=c),i=[t,n];return this.isDisposed()||s.splice(o>=0?o:s.length,0,i),{dispose(){const a=s.indexOf(i);a>=0&&s.splice(a,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const n=this._listeners[e]||(this._listeners[e]=[]);let r;for(let s=0;s<n.length;s++){const o=n[s][0],i=r;r=a=>o(a,i)}if(r)return r(t)}};addListener=(e,t,n=0)=>this.addListenerAsync(e,(r,s)=>{try{t(r)}catch{}return s&&s(r)},n)},Ft=class extends d.Disposable{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_portSendHeld=new WeakSet;_inited=!1;_emitter=this.addDisposable(new oh);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;_outgoingObservers=new Set;_offTargetListeners=new Map;constructor(e,t){super(),this._singleton=t,this._transport=eh({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(Re,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(Re))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,n=t.data,r=t.source,s=n?.port===!0?t.ports?.[0]:void 0,o=!this._isPortSource(t.source);if(o&&r&&n?.operationId==="em:window-drained"){this._ports.has(r)&&this._drained.add(r);return}if(o&&r&&this._drained.has(r))return;if(r&&r!==this._target&&this._greeted.has(r)&&di(n,Re)){this._greeted.delete(r),this._handshaken.add(r),this._postMessage(r,{operationId:Re,data:{}}),s&&this.usePort(s,!0,r);return}const i=t.source===this.target||this._isCurrentPort(t.source);if(i||this._notifyOffTarget(n?.operationId,t.source),nh(n)&&i||this._singleton&&di(n,Re)){if(s&&i){const u=this._target;Promise.resolve().then(()=>this.usePort(s,!0,u))}const a=this._emitter.fireAsync(n.operationId||An,n.operationId===void 0?t:n.data),c=n.result,l=n.error;c&&l&&Promise.resolve(a).then(u=>this._sendMessage(c,u),u=>this._sendMessage(l,u))}};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(Re,void 0);return}this._inited=!1,this._postMessage(e,{operationId:Re,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:Re,data:{},port:!0},[t])}observeOutgoing(e){return this._outgoingObservers.add(e),{dispose:()=>{this._outgoingObservers.delete(e)}}}_notifyOutgoing(e,t){for(const n of Array.from(this._outgoingObservers))try{n(e,t)}catch{}}addOffTargetListener(e,t){let n=this._offTargetListeners.get(e);return n||(n=new Set,this._offTargetListeners.set(e,n)),n.add(t),{dispose:()=>{n.delete(t)}}}_notifyOffTarget(e,t){const n=typeof e=="string"?this._offTargetListeners.get(e):void 0,r=n?.size?this._knownPeer(t):void 0;if(!(!n||!r))for(const s of Array.from(n))try{s(r)}catch{}}_knownPeer(e){for(const[n,r]of this._ports)if(r.transport.peer===e)return n;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:Re,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,n=this._target){if(!n||this._ports.has(n))return;const r=th(e),s=r.subscribe(this._onTransportMessage);this._ports.set(n,{transport:r,subscription:s}),t&&(r.send({operationId:rh,data:{}}),this.drainWindow(n))}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 n=this._ports.get(e);return n!==void 0&&(t===void 0||n.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:sh,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,n){let r=t;this._outgoingFilter&&!n?.length&&(r="data"in t?{...t,data:this._outgoingFilter(t.data)}:this._outgoingFilter(t));try{const s=this._ports.get(e);if(s&&!this._portSendHeld.has(e)){s.transport.send(r);return}if(n?.length){e.postMessage(r,"*",n);return}e.postMessage(r,"*")}catch(s){if(s?.name==="DataCloneError"){const o=typeof r?.data=="object"&&r?.data!==null?r.data:void 0}throw s}}_sendMessage(e,t,n=!0){if(!n&&!this.isInited())return;e&&this._notifyOutgoing(e,t);const r=this.addDisposable(this.onInit(s=>{const o=e?{operationId:e,data:t}:t;try{this._postMessage(s,{...o})}finally{r.dispose()}}))}send(e,t,n){return typeof e=="string"?this._sendMessage(e,t,n):this._sendMessage(An,e,t)}sendAsync(e,t,n=!0){if(!n&&!this.isInited())return Promise.resolve();this._notifyOutgoing(e,t);const r=ui(),s=ui();return new Promise((o,i)=>{const a=this.addDisposable(new d.Disposable);a.addDisposable(this.onInit(c=>{try{this._postMessage(c,{operationId:e,data:t,result:r,error:s})}catch(l){a.dispose(),i(l);return}a.addDisposable(this._onMessage(r,l=>{o(l),a.dispose()})),a.addDisposable(this._onMessage(s,l=>{i(l),a.dispose()}))}))})}_onMessage(e,t,n=0){return this._emitter.addListener(e,t,n)}addListener(e,t,n){return t?this._onMessage(e,t,n):this._onMessage(An,e)}addListenerAsyncPipe(e,t,n=0){return this._emitter.addListenerAsync(e,t,n)}addListenerAsync(e,t,n=0){return this._emitter.addListenerAsync(e,async(r,s)=>{const o=await t(r);return s?s(r):o},n)}isInited(){return this._inited}get inited(){return this._inited}onInit(e,t=!0,n=0){const r=this.addDisposable(new d.Disposable);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?r.addDisposable(this.onInit(e,t,n)):e(this._target)}):r.addDisposable(this._onMessage(Re,()=>{e(this._target)},n)),r}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function Bt(e){return d.createIdentifier(e)}var Tn=d.createIdentifier("extensions.atomsHandlers"),ih=Bt("HANDLE_ATOM_INSERT"),ah=d.createIdentifier("HeadlessMode"),lt=d.createIdentifier("extensions.sandboxExtensions"),jr="SANDBOX_EXTENSION_SCRIPT_STATUS",jt=d.createIdentifier("MESSAGE_SERVICE"),fi=Bt("SETTINGS_PANEL_EVENT"),ch="advanced",lh=Bt("MODAL_SHOW_EVENT"),dh=Bt("MODAL_CLOSE_EVENT"),uh=Bt("MODAL_UPDATE_EVENT"),QO=d.createIdentifier("client"),ZO=d.createIdentifier("v2_client"),eD=d.createIdentifier("ai_client"),hi=d.createIdentifier("app.cookieManager"),tD=d.createIdentifier("app.storageProvider"),nD=d.createIdentifier("image-blob-resolver"),Ur=d.createIdentifier("template-directives"),fh=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),hh=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(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,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":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))};async request({body:e,secure:t,path:n,type:r,query:s,format:o,baseUrl:i,cancelToken:a,extraQuery:c,proxyHandler:l,...u}){const f=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},h=this.mergeRequestParams(u,f);c&&(s=s?{...s,...c}:c);const g=s&&this.toQueryString(s),p=this.contentFormatters[r||"application/json"],_=o||h.format,v=`${i||this.baseUrl||""}${n}${g?`?${g}`:""}`,A=l?l(v,{body:e,secure:t,path:n,type:r,query:s,format:o,baseUrl:i,cancelToken:a,extraQuery:c,proxyHandler:l,...u}):v,C=new Request(A,{...h,headers:{...h.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):h.signal)||null,body:typeof e>"u"||e===null?null:p(e)});return this.customFetch(C).then(async P=>{const I=P;I.data=null,I.error=null,I.meta={request:C,response:I};const S=_?await P[_]().then(w=>(I.ok?I.data=w:I.error={data:w},I)).catch(w=>(I.error=w,I)):I;return a&&this.abortControllers.delete(a),S})}},ph=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:fh.UrlEncoded,...t})},pi=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})},mh=d.createIdentifier("prewarm.networkActivity");function gh(){let e=0;const t=new Set,n=()=>{t.forEach(r=>r())};return{begin(){e+=1,n();let r=!1;return()=>{r||(r=!0,e-=1,n())}},inFlight:()=>e,watch(r){return t.add(r),()=>t.delete(r)}}}function _h(e){return e.getOrCreateInstance(mh,()=>gh())}var mi=Symbol("rest.publicRequest"),Ge=d.createIdentifier("rest.requestHandler"),vh=d.createIdentifier("rest.responseHandler"),$r=d.createIdentifier("rest.customFetch"),Eh=(e,t)=>fetch(e,t),Hr=d.createIdentifier("rest_transport"),bh=e=>{e.inject($r,{execute:async(t,n={})=>{const r=e.getServices(Ge),s={public:n[mi]===!0},o=_h(e).begin();try{let i=t instanceof Request?t:new Request(t,n);for(const l of r){const u=await l.execute(i,s);u instanceof Request&&(i=u)}let a=await fetch(i);const c=e.getServices(vh);for(const l of c)a=await l.execute(a,i);return a}finally{o()}}})};function gi(e,t){const n=e.getInstance(Hr);if(!n)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(r=>new r(n)))}var _i="INJECTION";function vi(e){return e.getState}function yh(e){if(vi(e)){const t=e.getState()[_i];return t&&d.DependencyResolver.getOrCreateInstance(t,()=>d.DependencyResolver.createChild())}else return e}function wh(e){if(!vi(e)){e.dispose();return}const t=e.getState()[_i];t&&(d.DependencyResolver.getInstance(t)?.dispose(),d.DependencyResolver.remove(t))}function Sh(e,t){for(const n of e)if(n&&t in n)return n[t]}function Gr(e){return Object.assign({},...e)}var Ei=["generic","stockImages","emFiles","cdn"];function Vr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function bi(e){return!Vr(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>Ei.includes(t))}function yi(e){return e.length===0?[]:e.length===1?e[0]:e}function wi(e){let t=!1,n=[];for(const r of e)if(r!==void 0){if(t=!0,Array.isArray(r)){n=[...r,...n];continue}n=[r,...n]}if(t)return yi(n)}function Ih(e){return Vr(e)&&("value"in e||"replace"in e)}function Si(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function Ah(e){let t=!1,n=[],r=!1;for(const o of e)if(o!==void 0){if(Ih(o)){t=!0,o.replace&&(n=[],r=!0),o.value!==void 0&&(n=Si(n,o.value),r=!0);continue}n=Si(n,o),r=!0}const s=r?yi(n):void 0;if(!t)return s;if(s!==void 0)return{value:s}}function Th(e){const t=e.filter(r=>r!==void 0);if(t.length===0)return;if(!t.some(r=>bi(r)))return wi(t);const n={};for(const r of Ei){const s=Ah(e.map(o=>{if(o!==void 0)return bi(o)?o[r]:r==="generic"?o:void 0}));s!==void 0&&(n[r]=s)}return Object.keys(n).length>0?n:void 0}function Ch(e){return wi(e)}function Oh(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(Vr(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function Dh(e,t){const n=[...e],r=new Set(n.map(s=>s.toLowerCase()));for(const s of t){const o=s.trim().replace(/:\d+$/,"");if(!o)continue;const i=o.toLowerCase();r.has(i)||(r.add(i),n.push(o))}return n}function Ph(e){let t=[],n=!1;for(const r of e){const s=Oh(r);s&&(n=!0,s.replace&&(t=[]),t=Dh(t,s.hosts))}return n?t:void 0}function Rh(e){const t=e.filter(s=>s!==void 0);if(t.length===0)return;const n=Gr(t.map(({directHosts:s,...o})=>o)),r=Ph(t.map(s=>s?.directHosts));return r!==void 0&&(n.directHosts=r),n}function Wr(e){return e?.backendProxy}function Ut(e){return e.replace(/\/$/,"")}function Ii(e){return/^https?:\/\//i.test(e)}function Ai(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function kh(e){const t=new Set;return e.filter(n=>!n.url||t.has(n.url)?!1:(t.add(n.url),!0))}function Nh(e){const t=Wr(e);return t?[t]:[]}function Lh(e){return{proxyEmFiles:!0,proxyAi:!1}}function xh(e,t){const n=Lh(t),r=t?.backendProxyPolicy;switch(e){case"emFiles":return r?.proxyEmFiles??n.proxyEmFiles;case"ai":return r?.proxyAi??n.proxyAi;default:return!0}}var Mh={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 Fh(e){const t=[],n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(r,s)=>(t.push(s),`(${Mh[s]||".+"})`));return{regex:new RegExp(`^${n}$`,"i"),tokens:t}}function Bh(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function jh(e,t){if(Bh(t))return e;try{const n=new URL(e);return`${n.origin}${n.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function Uh(e,t,n){if(n.endsWith("_encoded"))return!0;const r=e.slice(0,t),s=r.lastIndexOf("#"),o=r.lastIndexOf("?"),i=r.lastIndexOf("&"),a=r.lastIndexOf("=");return a>Math.max(o,i)&&a>s}function $h(e){try{const t=new URL(e),n=t.pathname.replace(/^\/+/,""),r=t.search.replace(/^\?/,""),s=t.hash.replace(/^#/,""),o=n.replace(/^wp-json\/?/i,""),i=o?`/${o}`:"/",a=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),c=a?.[1]||"",l=a?.[2]||"",u=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:n,pathname:n,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:r,search:t.search,hash:t.hash,fragment:s,pathname_after_wp_json:o,pathname_after_wp_json_with_slash:i,rest_namespace:c,rest_version:l,rest_route:u,rest_route_with_slash:u?`/${u}`:"/"}}catch{return}}function Kr(e,t){if(!e)return{};if(Array.isArray(e)){for(const a of e){const c=Kr(a,t);if(c!==void 0)return c}return}if(e==="*")return{};const n=jh(t,e),{regex:r,tokens:s}=Fh(e),o=r.exec(n);if(!o)return;const i={};return s.forEach((a,c)=>{i[`matched_${a}`]=o[c+1]||""}),i}function Cn(e,t,n={}){const r=$h(t);if(!r)return t;const s={...r,...n};let o="",i=0;const a=/\{([a-z_]+)\}/gi;let c;for(;c=a.exec(e);){o+=e.slice(i,c.index);const l=s[c[1]]??"",u=Uh(e,c.index,c[1])?encodeURIComponent(l):l;o+=u,i=c.index+c[0].length}o+=e.slice(i);try{const l=new URL(o),u=new URL(t);return!o.includes("{search}")&&!o.includes("{query}")&&u.search&&u.searchParams.forEach((f,h)=>{l.searchParams.has(h)||l.searchParams.append(h,f)}),!o.includes("{hash}")&&!o.includes("{fragment}")&&u.hash&&!l.hash&&(l.hash=u.hash),l.toString()}catch{return o}}function Ti(e,t){try{const n=new URL(t);return`${Ut(e)}/${n.pathname.replace(/^\//,"")}${n.search}${n.hash}`}catch{return t}}function Ci(e,t){const n=Ut(e);return t?Ii(t)?t:t.startsWith("?")||t.startsWith("#")?`${n}${t}`:`${n}${t.startsWith("/")?"":"/"}${t}`:n}function Oi(e,t,n,r){const s=e.match;return s?Array.isArray(s)?s.some(o=>Oi({...e,match:o},t,n,r)):typeof s=="function"?!!s({url:t,method:r,requestType:n}):s==="*"?!0:Kr(s,t)!==void 0:!0}function Hh(e,t,n,r="generic"){if(e==null)return[];const s=Array.isArray(e)?e:[e],o=[];return s.forEach((i,a)=>{if(!i)return;if(typeof i=="string"){const f=i.includes("{")&&i.includes("}")?Cn(i,t):Ti(i,t);o.push({key:`backend:${a}`,url:f,source:"resource"});return}if(!Ai(i)||!("rewrite"in i))return;const c=i;if(!Oi(c,t,r,n))return;const l=typeof c.match=="string"||Array.isArray(c.match)?Kr(c.match,t)||{}:{},u=typeof c.proxyBase=="string"&&c.proxyBase.trim()?c.proxyBase.trim():void 0;(Array.isArray(c.rewrite)?c.rewrite:[c.rewrite]).filter(Boolean).forEach((f,h)=>{const g=typeof f=="function"?(()=>{const p=f({url:t,proxyBase:u,method:n,requestType:r,...l}),_=u&&!Ii(p)?Ci(u,p):p;return _.includes("{")&&_.includes("}")?Cn(_,t,l):_})():u?Cn(Ci(u,f),t,l):f.includes("{")&&f.includes("}")?Cn(f,t,l):Ti(f,t);o.push({key:`backend:${c.id||"rule"}:${a}:${h}`,url:g,source:"resource"})})}),kh(o)}function Gh(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 Vh(e,t=[]){return e==null||(Array.isArray(e)?e:[e]).forEach(n=>{if(n){if(typeof n=="string"){const r=n.split("{")[0]?.trim();r&&t.push(Ut(r));return}!Ai(n)||!("rewrite"in n)||(typeof n.proxyBase=="string"&&n.proxyBase.trim()&&t.push(Ut(n.proxyBase.trim())),(Array.isArray(n.rewrite)?n.rewrite:[n.rewrite]).forEach(r=>{if(typeof r!="string")return;const s=r.split("{")[0]?.trim();s&&t.push(Ut(s))}))}}),t}function Wh(e,t){return Nh(t).flatMap(n=>Vh(n)).filter(Boolean).some(n=>n&&e.startsWith(n))}function Kh(e,t){return!!Wr(t)&&xh(e,t)}function qh(e,t={}){const n=t.requestType||Gh(e);return Kh(n,t.config)?Hh(Wr(t.config),e,t.method,n):[]}function zh(e,t={}){return Wh(e,t.config)?[e]:qh(e,t).map(n=>n.url)}function dt(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function On(...e){const t=e.filter(o=>o!=null);if(t.length===0)return;if(t.length===1)return t[0];const n=t.find(o=>o.aborted);if(n)return n;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const r=new AbortController,s=o=>{r.signal.aborted||r.abort(o.reason)};for(const o of t)o.addEventListener("abort",()=>s(o),{once:!0});return r.signal}var Di=3e5,Pi=15e3,_e=null,Ri=!1;function Yh(){return!0}function Xh(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return Di;const t=Number(e);return Number.isFinite(t)&&t>0?t:Di}function Jh(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return Pi;const t=Number(e);return Number.isFinite(t)&&t>0?t:Pi}function Qh(){const e="https://app.useblocks.io/api".trim();return e?dt(e):void 0}function Zh(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const n=JSON.parse(t);if(!Array.isArray(n))throw new Error("expected JSON array");return n.map(r=>String(r).trim()).filter(Boolean)}catch{return Ri||(Ri=!0),[]}return t.split(",").map(n=>n.trim()).filter(Boolean)}function ep(e){const t=new Set,n=[];for(const r of e){const s=dt(r);t.has(s)||(t.add(s),n.push(s))}return n}function ki(e){const t=String(e||"").trim();return t?dt(t):Qh()}function Ni(e,t=[]){return e?ep([e,...t]).slice(0,3):[]}function Li(){return Zh(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function tp(e=Date.now()){return _e?e-_e.switchedAt>=Xh():!0}function xi(e=Date.now()){_e&&tp(e)&&(_e=null)}function ut(e){if(!Yh())return!1;const t=ki(e);if(!t)return!1;const n=Li();return n.length===0?!1:Ni(t,n).length>1}function $t(e){const t=ki(e);if(!t)return[];const n=Li();return n.length===0?[t]:Ni(t,n)}function Ht(e){const t=$t(e);if(t.length===0)return"";if(xi(),_e){const n=t.indexOf(_e.activeUrl);if(n>=0)return t[n]}return t[0]}function Mi(e){const t=$t(e);if(t.length<=1||(xi(),!_e||!t.includes(_e.activeUrl)))return t;const n=_e.activeUrl;return[n,...t.filter(r=>r!==n)]}function Fi(e){return Ht(e)||void 0}function Bi(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const n=Jh(),r=new AbortController;let s;const o=setTimeout(()=>{s=np(n),r.abort(s)},n);return{signal:On(t,r.signal),timeoutError:()=>s,done:()=>clearTimeout(o)}}function np(e){const t=`[apiOriginFailover] origin attempt timed out after ${e}ms`;if(typeof DOMException=="function")return new DOMException(t,"TimeoutError");const n=new Error(t);return n.name="TimeoutError",n}function ji(e){return e===502||e===503||e===504}function Ui(e){return!(e instanceof Error)&&!(e instanceof DOMException)?!1:e.name==="TimeoutError"?!0:e instanceof TypeError}var $i;function rp(e){$i=e}function Dn(e,t){if(!ut(t))return;const n=$t(t);if(n.length<=1)return;const r=n.indexOf(dt(e));if(r<0)return;const s=r+1;if(s>=n.length)return;const o=n[s],i=_e?.activeUrl;_e={activeUrl:o,switchedAt:Date.now()},i!==o&&$i?.()}function Hi(e,t){if(!ut(t))return;const n=dt(e),r=$t(t);if(r.includes(n)){if(n===r[0]){_e=null;return}_e?.activeUrl!==n&&(_e={activeUrl:n,switchedAt:Date.now()})}}function Gi(){_e=null}var sp=e=>{const t=new FormData,n=(r,s,o)=>{if(s!=null){if(s instanceof Blob){r.append(o,s);return}if(Array.isArray(s)){s.forEach((i,a)=>{const c=o?`${o}[${a}]`:`${a}`;n(r,i,c)});return}if(typeof s=="object"){Object.keys(s).forEach(i=>{const a=s[i],c=o?`${o}[${i}]`:i;n(r,a,c)});return}r.append(o,String(s))}};return n(t,e),t},op={baseUrl:dt("https://app.useblocks.io/api"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},ft=new Map;function ip(e){const t=e?.getInstance(d.CONFIG_SOURCE_ID);return t?t.get()??t.bootstrap():void 0}var ap=class extends hh{container;constructor(e={},t){super(e),this.container=t}buildRequestUrl(e){const{path:t,baseUrl:n,extraQuery:r}=e;let{query:s}=e;r&&(s=s?{...s,...r}:r);const o=s&&this.toQueryString(s);return`${n||this.baseUrl||""}${t}${o?`?${o}`:""}`}buildRequestKey(e,t){return`${t.toUpperCase()} ${e}`}getBackendProxyCandidates(e,t){const n=ip(this.container),r=this.container?.getInstance(d.SECURITY_MODULE_ID)!==void 0,s=zh(e,{config:n,method:t,standalone:r}),o=s.length>0?s:[e],i=this.buildRequestKey(e,t),a=ft.get(i);return!a||!o.includes(a)?o:[a,...o.filter(c=>c!==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,n=!1){const r={...e,baseUrl:t},s=this.buildRequestUrl(r),o=r.method||"GET",i=this.buildRequestKey(s,o),a=this.getBackendProxyCandidates(s,o);let c,l;for(const u of a){const f=g=>g===s?u:g,h=n?Bi(e.signal):void 0;try{const g=await super.request({...r,proxyHandler:f,...h?{signal:h.signal}:{}});if(!g.ok&&this.shouldRetryResponse(g)&&u!==a[a.length-1]){l=g,ft.get(i)===u&&ft.delete(i);continue}return ft.set(i,u),g}catch(g){ft.get(i)===u&&ft.delete(i);const p=h?.timeoutError();if(p)throw p;if(c=g,(g instanceof DOMException||g instanceof Error)&&g.name==="AbortError")throw g}finally{h?.done()}}if(l)return l;throw c instanceof Error?c:new Error("Backend proxy chain failed")}async request(e){const t=String(e.baseUrl||"").trim();if(t)return this.requestOnOrigin(e,t);const n=this.resolveFailoverBaseUrl(),r=ut(n),s=e.failoverAttemptTimeout??r,o=r?Mi(n):n?[Ht(n)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let i,a;for(let c=0;c<o.length;c++){const l=o[c],u=c===o.length-1;try{const f=await this.requestOnOrigin(e,l,s);if(!f.ok&&ji(f.status)){if(a=f,!u){Dn(l,n);continue}break}return f.ok&&Hi(l,n),f}catch(f){if(!Ui(f))throw f;i=f,u||Dn(l,n)}}if(r&&Gi(),a)return a;throw i instanceof Error?i:new Error("API origin failover chain failed")}};function cp(e={},t){const n=new ap({...op,...e},t);return n.contentFormatters["multipart/form-data"]=sp,n}var Vi=d.createIdentifier("rest.clientFactory"),lp=e=>{bh(e);const t=cp({customFetch:e.getInstance($r)?.execute??Eh},e);e.inject(Hr,t)},Wi;(function(e){const t="https://racs.rest/v3";function n(s,o){const i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(o)};return fetch(`${t}?resource=${s}&dataset=${document.location.hostname}`,i)}e.post=n;async function r(s,o=0){const i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:`{"filter":{},"limit":${o}}`};return await(await fetch(`${t}/get?resource=${s}&dataset=${document.location.hostname}`,i)).json()}e.getAll=r})(Wi||(Wi={}));function dp(e){return String(e||"").trim()||void 0}var up=class extends d.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=dp(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)}},qr=d.createIdentifier("AppInitService");function fp(e){return async()=>{const t=await e();return(await new ph(t).app_init_create({})).data}}function hp(e){e.injectFactory(qr,(t,n)=>{if(n)return n;const r=new up({options:e.getInstance(d.OPTIONS_SOURCE_ID),isStandalone:()=>!!e.getInstance(d.SECURITY_MODULE_ID),resolveRestBaseUrl:s=>s?Ht(s):Ht()||void 0,setRestBaseUrl:s=>{e.getInstance(Vi)?.setOptions(s?{baseUrl:s}:{})},fallbackAppInit:fp(()=>e.getInstanceAsync(Hr)),publish:s=>{e.inject(d.APP_ID,s)}});return e.getInstance(d.DISPOSABLE_ID)?.addDisposable(r),r},!0)}function ve(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e),r=Array.isArray(t);if(n){if(!r)return!1;const a=e.length;if(t.length!==a)return!1;for(let c=0;c<a;c++)if(!ve(e[c],t[c]))return!1}else if(r)return!1;const s=Object.keys(e),o=Object.keys(t),i=s.length;if(i!==o.length)return!1;for(let a=0;a<i;a++){const c=s[a];if(!t.hasOwnProperty(c)||!ve(e[c],t[c]))return!1}}return!0}var pp=d.createIdentifier("plugin.optionsApplications");function mp(){const e=new Error("Options application was superseded by a newer one.");return e.name="AbortError",e}function gp(e){const t=new AbortController,n=[],r=new Map;let s,o,i,a=!1,c=!1,l=!1;const u=new Set,f=P=>{for(const I of Array.from(u))I(P);u.clear()},h=P=>{let I=r.get(P);if(!I){let S;I={promise:new Promise(w=>{S=w}),resolve:S,reached:!1,actions:[]},r.set(P,I)}return I},g=async()=>{await Promise.resolve();let P=0;for(;P<n.length;){const I=n.slice(P);P=n.length,await Promise.allSettled(I)}},p=P=>{t.signal.aborted||c||(a=!0,t.abort(P),o?.(P),i?.(P))},_=g(),v=new Promise((P,I)=>{i=I,_.then(()=>{a||P()})});v.catch(()=>{});const A=new Promise((P,I)=>{s=S=>{S.done.then(P,I)},o=I,_.then(()=>{t.signal.aborted||(c=!0,P())})});A.then(()=>e(C),()=>e(C));const C={signal:t.signal,get failed(){return a},done:A,settled:_,outcome:v,hold(P){const I=P.catch(S=>{if(!t.signal.aborted)return Promise.reject(S);l&&f(S)});I.catch(p),n.push(I)},reach(P){const I=h(P);if(I.reached)return;I.reached=!0,I.resolve();const S=I.actions.splice(0);for(const w of S){if(t.signal.aborted)return;try{w()}catch(D){C.hold(Promise.reject(D))}}},isReached(P){return r.get(P)?.reached??!1},reached(P){const I=t.signal.aborted?Promise.reject(t.signal.reason):new Promise((S,w)=>{const D=()=>w(t.signal.reason);t.signal.addEventListener("abort",D,{once:!0}),h(P).promise.then(()=>{t.signal.removeEventListener("abort",D),S()})});return I.catch(()=>{}),I},passed(P){const I=h(P),S=new Promise((w,D)=>{if(t.signal.aborted&&!l){D(t.signal.reason);return}const T=x=>{u.delete(T),D(x)};u.add(T);const k=()=>{l||T(t.signal.reason)};t.signal.addEventListener("abort",k,{once:!0}),I.promise.then(()=>{u.delete(T),t.signal.removeEventListener("abort",k),w()})});return S.catch(()=>{}),S},whenReached(P,I){if(t.signal.aborted)return;const S=h(P);if(!S.reached){S.actions.push(I);return}try{I()}catch(w){C.hold(Promise.reject(w))}}};return{application:C,supersede(P){l=!0,t.abort(mp()),s?.(P)},fail(P){t.abort(P),o?.(P),f(P)}}}function Ki(e,t,n){try{e(t,n)}catch(r){t.hold(Promise.reject(r))}}function ht(e){return e.getOrCreateInstance(pp,()=>{const t=e.getInstance(d.DISPOSABLE_ID);if(!t)throw new Error("[plugin] provideOptionsApplications: время жизни регистрирует bootstrapEarly — раньше него нельзя");let n;const r=new Set;let s,o=!1;const i=new Set,a=c=>{n?.application===c&&(n=void 0)};return t.addDispose(()=>{o=!0;for(const c of Array.from(r))c.fail(De());r.clear(),n=void 0}),{begin(c){if(o)throw De();const l=n,u=gp(a);r.add(u),u.application.settled.then(()=>r.delete(u)),n=u,s=c,l?.supersede(u.application);for(const f of Array.from(i))Ki(f,u.application,c);return u.application},current(){return n&&!n.application.signal.aborted?n.application:void 0},each(c){i.add(c);const l=n&&!n.application.signal.aborted?n.application:void 0;return l&&s&&Ki(c,l,s),{dispose:()=>i.delete(c)}}}})}function rD(e){return e}function sD(e){return e}var _p=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function vp(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const s=t.get(r)??[];s.push(n),t.set(r,s)}return t}function Ep(e,t){const n=[];for(const r of e.awaits?.services??[])for(const s of t.get(r)??[])s!==e&&n.push(s);return n}function zr(e){const t=vp(e),n=[],r=new Set,s=[],o=new Set,i=a=>{if(!r.has(a)){if(o.has(a)){const c=s.indexOf(a);throw new _p([...s.slice(c),a].map(l=>l.name))}o.add(a),s.push(a);for(const c of Ep(a,t))i(c);s.pop(),o.delete(a),r.add(a),n.push(a)}};for(const a of e)i(a);return n}var qi=d.createIdentifier("auth.oauthProvided"),Pn="auth.bootstrapTokenDecided",Yr="auth.applied",zi=new WeakMap;function Yi(e,t){const n=zi.get(e)??{applied:!1};(!n.applied||n.getAuthToken!==t.getAuthToken||!ve(n.user,t.user)||n.project!==t.project)&&(zi.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),d.recreateTokenProvider(e,t.getAuthToken,t.user,t.project))}function bp(e){if(e.getInstance(qi))return;e.inject(qi,!0);let t;e.getInstance(d.OPTIONS_SOURCE_ID)?.watch(n=>{t=n}),e.addService(Ge,{execute:async(n,r)=>{if(r?.public||!t?.getAuthToken)return;e.getInstance(d.TOKEN_ID)===void 0&&Yi(e,t);const s=await e.getInstanceAsync(d.TOKEN_ID);s&&n.headers.set("authorization",`Bearer ${s}`)}})}function yp(e){const t=ht(e).each((n,r)=>{n.whenReached(Pn,()=>{Yi(e,r),n.reach(Yr)})});e.getInstance(d.DISPOSABLE_ID)?.addDisposable(t)}function wp(e,t){if(e===t)return;let n=0;const r=Math.min(e.length,t.length);for(;n<r&&e[n]===t[n];)n++;let s=e.length,o=t.length;for(;s>n&&o>n&&e[s-1]===t[o-1];)s--,o--;return{start:n,fromEnd:s,toEnd:o}}function Xr(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return{length:e.length,hash:t>>>0}}var Fe={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"},Jr={text:{fontFamily:["Google Fonts","Sans Serif","Mulish","Regular"],fontSize:16,fontSizeDim:"px",lineHeight:24,lineHeightDim:"px",color:"#595959",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},headings:{fontFamily:["Google Fonts","Sans Serif","Mulish","Bold"],fontSize:28,fontSizeDim:"px",lineHeight:34,lineHeightDim:"px",color:"#000000",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},links:{color:"#1890ff",contrastColor:"#FFFFFF",underline:!0},buttons:{fontFamily:["Google Fonts","Sans Serif","Mulish","Medium"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1890ff",bold:!1,italic:!1,backgroundColor:"#1890ff",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:6,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:"#1890ff",padding:{all:null,top:null,right:null,bottom:null,left:null}},cards:{contrastBackgroundColor:"#1890ff",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}}},Xi="ERROR",Sp="useblocks",Ip={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",prm_ref_link_id:"_p_rlid",em_active_tab:"em_active_tab"},Rn={em_color_scheme:"em_color_scheme",em_compress_images:"em_compress_images",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_emails_v2:"em_emails_v2",em_checks_v2:"em_checks_v2",em_blocks_v2:"em_blocks_v2",em_revisions_v2:"em_revisions_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_billing_v2:"em_billing_v2",em_guest_locale:"em_guest_locale"},Ap="light",Tp="dark",oD="system",Cp="(prefers-color-scheme: dark)",Op=8e3,Dp=2e3,Pp=15e3,Rp=3e3,q={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_EBLOCK_CLEAR_EM_BLOCK_ID:"sandbox_eblock_clear_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",SANDBOX_CANVAS_SYNCED:"sandbox_canvas_synced",SANDBOX_ELEMENT_OPERATION:"sandbox_element_operation"},kp={language:"html",detectIndentation:!1,wordWrap:"on",wrappingIndent:"same",smoothScrolling:!0,automaticLayout:!0,tabSize:2,indentSize:2},pt=d.createIdentifier("documentSession.emailDocuments");function mt(e){return e?.getInstance(pt)}var Np=d.createIdentifier("RevisionServiceFlag");function Ji(e){return e.getOrCreateInstance(Np,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Qi(e){return Ji(e).isEnabled()}var Zi=d.createIdentifier("EmailRightsResolver");function Lp(e,t){return e.onInject(n=>{n===Zi&&t()})}function ea(e,t){const n=e.getInstance(Zi);return n?n(t):!0}var Qr={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},ta=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],na=2e4,xp=ta.reduce((e,t)=>e+Qr[t],0),ra=na+xp+3e3;function Mp(e){return ta.reduce((t,n)=>t+sa(n,e),0)}function sa(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:Qr[e]}function oa(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:ra}function ia(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:na}function Gt(e=ra){return e+3e3}var iD="[show-pipeline]";function aa(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}function aD(e,t){}var Fp=()=>Gt();function Bp(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function jp(e){return t=>Bp(e.getOrCreateInstance(d.events.BEFORE_SAVE_EMAIL,()=>new d.AsyncEmitter).fire(t),Fp())}var ca=Symbol.for("emailmaker.saveRefusedError"),la=Symbol.for("emailmaker.integratorSaveTimeoutError");function da(e,t,n,r){return e!==t?Function.prototype[Symbol.hasInstance].call(e,r):typeof r=="object"&&r!==null&&n in r}var Ne=class Tf extends Error{reason;detail;static[Symbol.hasInstance](t){return da(this,Tf,ca,t)}constructor(t,n){super(n?`[emailmaker] save refused: ${t}: ${n}`:`[emailmaker] save refused: ${t}`),this.name="SaveRefusedError",this.reason=t,this.detail=n,Object.defineProperty(this,ca,{value:!0})}},ua=class extends Error{timeoutMs;constructor(e,t="handleEmailAutosave"){super(`[useblocks] ${t} did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},kn=class Cf extends Error{timeoutMs;static[Symbol.hasInstance](t){return da(this,Cf,la,t)}constructor(t,n="handleSaveEmail",r="email"){super(`[useblocks] ${n} did not respond within ${t}ms — the ${r} was not saved`),this.timeoutMs=t,this.name="IntegratorSaveTimeoutError",Object.defineProperty(this,la,{value:!0})}};function ce(e){return e.getOrCreateInstance(jt,()=>new Ft)}var fa=new WeakMap,Zr=new WeakMap;function ye(e){return fa.get(e)??0}function Vt(e,t){let n=Zr.get(e);return n||(n=new Set,Zr.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Up(e){fa.set(e,ye(e)+1),Zr.get(e)?.forEach(t=>t())}function es(e,t){return e.originId!==null||t.originId!==null?e.originId===t.originId:e.generation===t.generation}var $p=d.createIdentifier("documentSession.canvasReceipts");function Hp(){let e,t={scope:{generation:-1,originId:null},changeId:0};return{open(n,r){const s={guid:n,version:r};return e=s,()=>{e===s&&(e=void 0)}},note(n,r){const s=es(t.scope,r)?t.changeId:0;t={scope:r,changeId:Math.max(s,n)}},read(n){if(!e)return;const{scope:r}=t,s={guid:e.guid,rev:e.version()};return r.originId!==null?{...s,changeId:t.changeId,originId:r.originId}:{...s,changeId:r.generation===n?t.changeId:0}}}}function ha(e){return e.getOrCreateInstance($p,Hp)}var Gp=2e3,Vp=Pp+Rp+Gp;function Wp(e,t=Vp){return async()=>{const n=ce(e);let r;const s=new Promise(o=>{r=setTimeout(()=>o("silent"),t)});try{const o=ha(e).read(ye(n)),i=await Promise.race([n.sendAsync(q.SANDBOX_CANVAS_SYNCED,o?{applied:o}:void 0,!1),s]);if(i==="silent"||i&&!i.synced)throw i==="silent"||i?.unsent,new Ne("canvas-not-synced")}finally{clearTimeout(r)}}}var Kp="em_autosave_pending",cD=6e4;function Nn(e){return`${Kp}_${e}`}function ts(e,t){try{return sessionStorage.setItem(Nn(e),JSON.stringify(t)),!0}catch{return!1}}function Ln(e){try{const t=sessionStorage.getItem(Nn(e));if(!t)return null;const n=JSON.parse(t);return!(n.baseRevisionId!==void 0||n.baseOpen===!0)&&Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(Nn(e)),null):n}catch{return null}}function Ve(e){try{sessionStorage.removeItem(Nn(e))}catch{}}function ns(e){return`block:${e}`}function pa(e,t){return t?ns(e):e}function rs(e,t){(Ln(e)?.sentAt??Number.POSITIVE_INFINITY)<=t&&Ve(e)}function qp(e){return e!=null&&e!==""}function ma(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}var ga;function zp(){return ma(Rn.em_revisions_v2)??!0}function Yp(){return ga??=zp(),ga}function gt(e){return Qi(e)&&Yp()}function Xp(){return!1}var _a;function Wt(e,t){return _a?.capture(e,t)}function Jp(e,t){return _a?.captureMessage(e,t)}var Qp=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Zp=200;function va(e=new Set){const t=new Set;return(n,r)=>{if(!Qp.some(([o,i])=>!e.has(o)&&i.test(n)))return;const s=r??`new:${n.length}:${n.slice(0,200)}`;t.has(s)||(t.size>=Zp&&t.clear(),t.add(s))}}function Ea(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:va()}}var em=Ea();function Be(e){return e?.getInstance(Ur)??em}function tm(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function xn(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Ce=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} "${xn(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${xn(this.oldText)}")`:`(replace@${this.oldPosition} "${xn(this.oldText)}" with "${xn(this.newText)}")`}};function ba(e,t){return e===null||e.length===0?t:new nm(e,t).compress()}var nm=class Me{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),s=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(s===null)break;this._acceptCurr(s),s=this._getCurr(++n);continue}if(s===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(s.oldEnd<=r.newPosition){this._acceptCurr(s),s=this._getCurr(++n);continue}if(r.newEnd<=s.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(s.oldPosition<r.newPosition){const[c,l]=Me._splitCurr(s,r.newPosition-s.oldPosition);this._acceptCurr(c),s=l;continue}if(r.newPosition<s.oldPosition){const[c,l]=Me._splitPrev(r,s.oldPosition-r.newPosition);this._acceptPrev(c),r=l;continue}let i,a;if(s.oldEnd===r.newEnd)i=r,a=s,r=this._getPrev(++t),s=this._getCurr(++n);else if(s.oldEnd<r.newEnd){const[c,l]=Me._splitPrev(r,s.oldLength);i=c,a=s,r=l,s=this._getCurr(++n)}else{const[c,l]=Me._splitCurr(s,r.newLength);i=r,a=c,r=this._getPrev(++t),s=l}this._result[this._resultLen++]=new Ce(i.oldPosition,i.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=i.newLength-i.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const o=Me._merge(this._result);return Me._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=Me._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=Me._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new Ce(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Ce(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),s=t.newText.substr(n);return[new Ce(t.oldPosition,t.oldText,t.newPosition,r),new Ce(t.oldEnd,"",t.newPosition+n,s)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),s=t.oldText.substr(n);return[new Ce(t.oldPosition,r,t.newPosition,t.newText),new Ce(t.oldPosition+n,s,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,s=t[0];for(let o=1;o<t.length;o++){const i=t[o];s.oldEnd===i.oldPosition?s=new Ce(s.oldPosition,s.oldText+i.oldText,s.newPosition,s.newText+i.newText):(n[r++]=s,s=i)}return n[r++]=s,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let s=0;s<t.length;s++){const o=t[s];o.oldText!==o.newText&&(n[r++]=o)}return n}};function rm(e){return new Ce(e.newPosition,e.newText,e.oldPosition,e.oldText)}function sm(e){return e.map(rm)}function ya(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function om(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const s=t[r];n=n.slice(0,s.oldPosition)+s.newText+n.slice(s.oldEnd)}return n}function wa(e,t,n){let r=0;const s=e.start===e.end;for(const o of t){const i=o.newLength-o.oldLength;if(o.oldLength===0){const a=o.oldPosition;if(s&&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(s){if(e.start>=o.oldEnd)r+=i;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=i;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}function Sa(e,t,n){if(!t.length)return[...e];const r=[];let s=0;for(const o of e){const i=wa({start:o.oldPosition,end:o.oldEnd},t,n);if(!i)return null;r.push(new Ce(i.start,o.oldText,i.start+s,o.newText)),s+=o.newLength-o.oldLength}return r}var We=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Ia=0,im=Math.random().toString(36).slice(2,8);function am(){return Ia+=1,`doc-${im}-${Ia}`}function cm(e){const t=e.createBuffer(),n=e.docId??am();let r=e.serverId??null,s=0,o=null,i=e.attributes??{};const a=new Set;let c=!1,l=!1,u;const f=new Set;let h=null;const g=()=>(h?.version!==s&&(h={version:s,value:t.read()}),h.value),p=_=>Object.entries(_).some(([v,A])=>i[v]!==A);return{get:()=>({docId:n,serverId:r,version:s,savedVersion:o,attributes:i}),getContent:g,mutate(_,{source:v}){if(c)return s;const A=_.changes?.length?_.changes:void 0,C=A?om(g(),A):_.content!==void 0?_.content:void 0,P=C!==void 0&&C!==g(),I=_.attributes!==void 0&&p(_.attributes);if(!P&&!I)return s;const S=!(s>(o??-1)),w=I?Object.keys(_.attributes).filter(T=>i[T]!==_.attributes[T]):[];P&&t.write(C),I&&(i={...i,..._.attributes}),s+=1,v!=="user"&&S&&(o=s);const D={source:v,version:s,changes:A,...P?{content:!0}:{},...w.length>0?{attributes:w}:{}};return a.forEach(T=>T(D)),s},markSaved(_,v){const A={serverId:r,savedVersion:o};v!==void 0&&(r=v),(o===null||_>o)&&(o=_),(A.serverId!==r||A.savedVersion!==o)&&a.forEach(C=>C({source:"system",version:s}))},markUnsaved(){c||o===null||o<s||(o=s-1,a.forEach(_=>_({source:"system",version:s})))},markReady(){l||u!==void 0||(l=!0,f.forEach(_=>_.resolve()),f.clear(),a.forEach(_=>_({source:"system",version:s})))},isReady:()=>l,markFailed(_){l||u!==void 0||c||(u=_,f.forEach(v=>v.reject(new We(_))),f.clear(),a.forEach(v=>v({source:"system",version:s})))},failure:()=>u,whenReady(){return l?Promise.resolve():u!==void 0?Promise.reject(new We(u)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((_,v)=>{f.add({resolve:_,reject:v})})},subscribe(_){return a.add(_),()=>a.delete(_)},isNew:()=>r===null,isDirty:()=>s>(o??-1),isDisposed:()=>c,dispose(){c=!0,f.forEach(_=>_.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),f.clear(),a.clear(),t.dispose()}}}var lm=500,dm=100,ss=0,Aa=0;function um(e,t){const n={before:e?.before,after:t?.after};return n.before||n.after?n:void 0}function Ta(e,t,n){let r=0;for(const s of t){if(s.oldPosition>e||s.oldPosition===e&&(s.oldLength>0||!n))break;if(s.oldEnd>e)return s.newEnd;r=s.newEnd-s.oldEnd}return e+r}function os(e,t){if(!e)return e;if(e.start===e.end){const n=t(e.start,"caret");return{start:n,end:n}}return{start:t(e.start,"start"),end:t(e.end,"end")}}var Ca=(e,t)=>t==="old"?e.oldPosition:e.newPosition,Oa=(e,t)=>t==="old"?e.oldEnd:e.newEnd;function Da(e,t,n,r){const s=t==="start"?["start","end"]:["end","start"];for(const o of s){const i=r.findIndex(a=>(o==="start"?Ca(a,n):Oa(a,n))===e);if(i>=0)return{index:i,edge:o}}}function fm(e,t,n){if(!e?.after)return e;const r=(s,o)=>{const i=Da(s,o,"new",n);return Ta(s,t,i?i.edge==="start"&&n[i.index].newLength>0:o==="start")};return{...e,after:os(e.after,r)}}function hm(e,t,n,r,s){const o=(i,a)=>(c,l)=>{const u=Da(c,l,i,t);return u?u.edge==="start"?Ca(n[u.index],i):Oa(n[u.index],i):Ta(c,a,l==="start")};return e&&{before:os(e.before,o("old",r)),after:os(e.after,o("new",s))}}function pm(e,t={}){const n=t.groupIntervalMs??lm,r=t.maxSteps??dm,s=t.now??(()=>0);let o=[],i=0,a=ss+=1,c=null,l,u,f,h=!1,g=!1,p=!1,_=0,v=!1,A=!1;const C=new Set,P=()=>C.forEach(E=>E()),I=(E,L)=>{if(E.length){p=!0;try{e.mutate({changes:E},{source:L})}finally{p=!1}}},S=E=>I(E,"user"),w=E=>{const L=l?.from??s(),B=_>0?v:g&&c!==null&&h===(l!==void 0)&&L>=c&&L-c<n;if(_>0&&(v=!0),B){const W=o[i-1];o[i-1]={...W,changes:ba(W.changes,E),selection:um(W.selection,u)}}else o=o.slice(0,i),Aa+=1,o.push({id:Aa,below:o[i-1]?.id??0,changes:E,selection:u}),i=o.length,g=!0,o.length>r&&(o=o.slice(o.length-r),i=o.length,a=ss+=1);c=l?.to??L,h=l!==void 0,P()},D=()=>{g=!1,c=null},T=E=>{let L=E;for(let B=i;B<o.length;B+=1){const W=o[B],te=Sa(W.changes,L,"after"),ne=te&&Sa(L,W.changes,"before");if(!te||!ne)return o=o.slice(0,B),!0;o[B]={...W,changes:te,selection:hm(W.selection,W.changes,te,L,ne)},L=ne}return!1},k=E=>{if(!E.length)return;const L=T(E);if(i>0){const B=o[i-1];o[i-1]={...B,changes:ba(B.changes,E),selection:fm(B.selection,E,B.changes)}}D(),L&&P()},x=e.subscribe(({source:E,changes:L})=>{if(!(A||p||!L?.length)){if(E==="remote"){R();return}if(E!=="user"){k(L);return}w(L)}}),R=()=>{o=[],i=0,v=!1,D(),a=ss+=1,P()},M=(E,L)=>{v=!1,f=L;try{S(E)}finally{f=void 0}},F=(E=!1)=>{if(i===0)return!1;const L=o[i-1],B=sm(L.changes);return ya(e.getContent(),B)?(M(B,E?{kind:"undo",selection:L.selection?.before}:void 0),i-=1,D(),!0):(o=o.slice(0,i-1),i=o.length,v=!1,D(),P(),!1)},U=()=>{const E=F(!0);return E&&P(),D(),E},y=()=>{if(i>=o.length)return D(),!1;const E=o[i];return ya(e.getContent(),E.changes)?(M(E.changes,{kind:"redo",selection:E.selection?.after}),i+=1,D(),P(),!0):(o=o.slice(0,i),D(),P(),!1)};return{recordAt(E,L,B){const W=l,te=u;l=E,u=B;try{return L()}finally{l=W,u=te}},activeMove:()=>f,canUndo:()=>i>0,canRedo:()=>i<o.length,undo(){U()},redo(){y()},tryUndo:U,tryRedo:y,clear:R,closeGroup:D,beginTransaction(){_===0&&(v=!1),_+=1;let E=!1;return()=>{E||(E=!0,_-=1,_===0&&(v=!1,D()))}},applyWithoutHistory(E){const L=e.get().version;if(I(E,"system"),e.get().version===L){D();return}k(E)},getPast:E=>o.slice(0,i).reverse().slice(0,E).map(L=>L.changes),getFuture:E=>o.slice(i).reverse().slice(0,E).map(L=>L.changes),createSnapshot:()=>({stackId:a,index:i}),restoreSnapshot(E){if(E.stackId!==a||E.index>i)return!1;for(;i>E.index;)if(!F())return P(),!1;return P(),!0},currentStep:()=>({id:o[i-1]?.id??0,below:o[i-1]?.below??0}),subscribe(E){return C.add(E),()=>C.delete(E)},dispose(){A=!0,x(),C.clear(),o=[],i=0}}}var mm=["edit","move","resize","insert"];function is(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function gm(e){return typeof e=="string"?e:null}function _m(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function vm(e){return mm.includes(e)?e:null}function Em(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:gm(t.originId),changeId:is(t.changeId),rev:is(t.rev),baseRev:is(t.baseRev),expected:_m(t.expected),intent:vm(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}function bm(e){return e instanceof Ne?e.reason:void 0}var Pa={"too-many-tags":"The email has more tags than allowed, so nothing was saved.","canvas-not-synced":"Not all canvas edits reached the document, so nothing was saved; try again in a moment.","plugin-refused":"A plugin refused the save, so nothing was saved."};function ym(e){const t=bm(e);if(t===void 0||t==="locked")return;const{detail:n}=e;return n?`${Pa[t]} Its reason: ${n}`:Pa[t]}var Ra=Symbol.for("emailmaker.blockSaveFlight"),ka=Symbol.for("emailmaker.blockSaveSessionQueue"),as=new WeakMap;function Na(e,t){return Object.isExtensible(e)||t in e?e[t]:as.get(e)?.get(t)}function La(e,t,n){if(t in e||Object.isExtensible(e)){Object.defineProperty(e,t,{value:n,writable:!0,configurable:!0});return}const r=as.get(e)??new Map;r.set(t,n),as.set(e,r)}function wm(e,t){La(e,ka,t)}function Sm(e,t){const n=(Na(e,Ra)??Promise.resolve()).then(t,t);return La(e,Ra,n.catch(()=>{})),n}function Im(e,t){return Na(e,ka)?.(t)??Sm(e,t)}var Kt=new Map,xa=new Map;function Am(e){return Kt.set(e,(Kt.get(e)??0)+1),()=>{const t=(Kt.get(e)??1)-1;if(t>0){Kt.set(e,t);return}Kt.delete(e);const n=xa.get(e);xa.delete(e),n?.forEach(r=>r())}}var cs=e=>e.replace(/\r\n?/g,`
|
|
2103
|
+
`),Tm=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/iu;function ls(e){return typeof e=="string"&&Tm.test(e)}var Cm=class extends Error{kind;failed;constructor(e,t){super(`не удалось завести термы (${e}): ${t.map(({name:n})=>n).join(", ")}`),this.name="TermsFailedError",this.kind=e,this.failed=t}};function Om(){return typeof navigator<"u"&&navigator.onLine===!1}function Dm(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 s=r.data;typeof r.data=="object"&&s.error!=null&&t.push(s.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 Ma(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 Ma(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 Pm(e){return Om()?!0:Dm(e).some(Ma)}var Fa=new WeakSet,Ba=new WeakMap;function ja(e){typeof e=="object"&&e!==null&&Fa.add(e)}function Rm(e,t){typeof e=="object"&&e!==null&&Ba.set(e,t)}function km(e){return typeof e=="object"&&e!==null?Ba.get(e):void 0}function Nm(e){return e instanceof kn||e instanceof ua||typeof e=="object"&&e!==null&&Fa.has(e)}function Lm(e){return e instanceof Ne||Ua(e)||e instanceof Cm||Nm(e)}function Ua(e){return ds(e)?.v2Error?.data?.code==="blocks.block_locked"}function $a(e){return ds(e)?.v2Error?.data?.code==="emails.mirror_unavailable"}function ds(e){return e instanceof Error&&e.name==="EmailWriteFailedError"?e:void 0}function xm(e){if(e instanceof Ne)return e.reason==="canvas-not-synced";if(Lm(e))return!1;const t=ds(e);if(t){const n=t.v2Error?.status??0;return n>=500?!0:n>0?$a(e):!0}return Pm(e)||$a(e)}var Ha="draft";function _t(e){return e==null||e===""?Ha:String(e)}function Mn(e){return e==null||e===""?`${us}${Ha}`:`${us}${String(e)}`}var us="block:";function Q(e){return e?.startsWith(us)===!0}function vt(e){return Q(e.sessionKey())?void 0:e.current()}function lD(e,t){}function Ke(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return oe(`show:gate:${e}`,{kind:"wait"}),t.then(s=>(oe(`show:gate:${e}:end`,{kind:"wait"}),s),s=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw d.isAbortError(s)?(`${e}`,{...n}):(`${e}`,{error:aa(s),...n},void 0),s})}var dD=5e3,Mm=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function Fm(e){const t=e?.trim()??"";if(!Mm.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function qt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function fs(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Bm(e,t={}){const n=qt((e??[]).filter(r=>r?.html?.trim()));return fs(n,t)?n:null}function jm(e,t){const n=Date.parse(qt(e)?.modified??""),r=Bm(e),s=Date.parse(r?.modified??""),o=t===void 0||Number.isFinite(s)&&s>t,i=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:o?r:null,...i.length?{latestAt:Math.max(...i)}:{}}}function Ga(e,t,n){const r=qt((e??[]).filter(c=>c?.html?.trim())),s=Date.parse(r?.modified??""),o=Date.parse(qt((n??[]).filter(c=>c?.html?.trim()))?.modified??""),i=r&&Number.isFinite(s)&&(t===void 0||s>t)&&!(o>s),a=[Date.parse(qt(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:i&&fs(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Um({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Va=["recovery","plugin","rest"],$m=["subject","preheader"];function Hm(e){let t={},n;for(let s=Va.length-1;s>=0;s--){const o=e.get(Va[s]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const s of $m){const o=r?.[s];typeof o=="string"&&o!==""&&(t={...t,[s]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Fn(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?cs(t.content):void 0,s=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...s?{changes:[new Ce(0,n,0,r)]}:{}},{source:"remote"})}var hs=e=>typeof e=="string"?e.trim():"";function Gm(e,t,n,r){const{version:s,attributes:o}=e.get(),i=o,a=r==="snapshot"||r==="anchor",c=a?i.author:void 0,l=a?i.date_gmt:void 0,u=hs(i.title)||hs(i.subject)||hs(t.fallbackTitle);return{version:s,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,projectCategories:i.projectCategories,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}:{},...l?{excerpt:l}:{}}}}var Vm=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Wm(e){const t={};for(const n of Vm)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Km(e,t,n,r,s,o){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(s);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,s):t.saveAutosave(r,s,o==null?void 0:{wpId:o})}function Le(e,t=!1){const n={};for(const r of Object.keys(e)){let s=e[r];s!==void 0&&!(typeof s=="number"&&Number.isNaN(s))&&(t&&typeof s=="object"&&s!==null&&(s=Le(s)),n[r]=s)}return n}function qm(e){return typeof e=="string"&&e.includes("autosave")}var zm=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function Wa(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!zm.has(t))):{}}function Et(e,t,n={}){e&&e.mutate({attributes:Ym(e.get().attributes,t)},{source:n.source??"user"})}function Ym(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function ps(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Xm(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Ka(e){if(!e)return null;const t=Wa(e);return e.common_styles!==void 0&&(t.common_styles=Xm(e.common_styles)),ps(e.html,t)}function qa(e){return e?ps(e.html,Le(Wa(e))):null}var Jm=["common_styles","subject","preheader","meta"];function za(e){if(!e?.html?.trim())return null;const t={};for(const n of Jm)Qm(n,e[n])&&(t[n]=e[n]);return ps(e.html,t)}function Qm(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 Zm=["modified","lock","wpId","secretHash"];function Ya(e){if(!e)return null;const t={};for(const n of Zm)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var eg=10,tg=(e,t)=>e.key===t.key&&ng(e.serverId,t.serverId),ng=(e,t)=>e==null||e===t;function rg(e){return typeof e?.then=="function"}var Xa=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Ja=e=>{e.request.serverId!=null&&!Bn(e)&&e.document.markSaved(e.document.get().version)},Bn=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Qa=(e,t)=>t?.content!==void 0&&Um({hasUnsavedUserEdit:Bn(e)})==="skip",Za=(e,t)=>{for(const n of["subject","preheader"]){const r=t.attributes?.[n];typeof r=="string"&&(e.shownHeaders[n]=r)}},sg=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()}),og=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.userTouched.clear(),e.document.get().docId))},ig=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([s,o])=>e.attributes[s]!==o)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},ag=e=>{const t=Hm(e.reports),n=ig(e.lastMerged,t);e.lastMerged=t,e.broughtContent=jn(t.content)??e.broughtContent,n&&(Fn(e.document,n),Ja(e))},ms=(e,t)=>{if(!e.ready&&!Bn(e)){ag(e);return}e.broughtContent=jn(t?.content)??e.broughtContent,Fn(e.document,t)},jn=e=>e===void 0?void 0:cs(e),cg=(e,t)=>t.content===void 0||jn(t.content)!==e.broughtContent||!Bn(e)?t:{...t,content:void 0},ec=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 lg(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:s,resolveTerms:o,canEdit:i,notifyBeforeSave:a,confirmPublish:c,awaitCanvasSynced:l,savedEchoForm:u=m=>m,queuesOutsideWrites:f,onAdapterError:h,onTimeout:g}=e;let p,_;const v=new Set,A=new Set,C=()=>v.forEach(m=>m()),P=(m,b)=>{if(!(m.closed||m.ready)){if(m.error!==void 0){m.document.markFailed(m.error),m.document.get().docId;return}Ja(m),m.ready=!0,m.document.markReady(),m.document.get().docId,[...m.reports.keys()]}},I=(m,b,O)=>{h?.(b.id,O),!(!b.required||m.closed)&&(m.error=O,m.document.get().docId,b.id,C())},S=(m,b)=>{const O=new Set(b.map(G=>G.id));b.forEach(G=>{G.watch&&m.watchers.push(G.watch(K=>m.closed?!1:m.ready&&(Qa(m,K)||m.contentShown===!0&&K?.content!==void 0)?(m.document.get().docId,G.id,!1):(K&&m.reports.set(G.id,K),ms(m,K),K?.content!==void 0&&(m.showFill=void 0),!0)))});const j=(G,K)=>{if(!m.closed){if(!G.required&&Qa(m,K)){m.document.get().docId,G.id,G.loaded?.(!1);return}K&&(m.reports.set(G.id,K),G.id==="plugin"&&Za(m,K)),ms(m,K),G.loaded?.(K!==null)}},V=()=>{O.size>0||m.closed||(Xa(m),P(m,[]))},X=[];if(b.forEach(G=>{let K;try{K=G.load()}catch(N){I(m,G,N),O.delete(G.id);return}if(rg(K)){X.push({id:G.id,required:G.required,load:()=>K,...G.loaded?{loaded:N=>G.loaded?.(N)}:{}});return}j(G,K),O.delete(G.id)}),X.length===0){V();return}m.timer=setTimeout(()=>{m.timer=void 0,g?.([...O]),m.document.get().docId,[...O],P(m,[...O])},n),m.timer.unref?.(),X.forEach(G=>{G.load().then(K=>j(G,K)).catch(K=>{I(m,G,K)}).finally(()=>{O.delete(G.id),V()})})},w=async(m,b,O)=>{if(O==="snapshot"||O==="anchor")return;const j=o?.();if(j)return j.resolve({project:b.project??m.project,tags:(m.tags??[]).map(V=>({name:V}))})},D=m=>{if(m.lock===!0&&i?.(m)===!1)return new Ne("locked");const b=m.tags?.length??0,O=m.emailtags?.length??0;if(Math.max(b,O)>eg)return new Ne("too-many-tags")},T=(m,b)=>{const O=m.document.get().serverId;O!=null&&(m.createKey=void 0),!(b||O==null)&&(m.recoveryFacts={emailId:O,historyLoaded:!0,isRecovering:!1},Q(m.request.key)||(m.request={...m.request,key:_t(O),serverId:O}))},k=(m,b,O)=>{if(m.closed||O?.id==null)return;const j=m.document.get().serverId,V=j!=null;V&&j!==String(O.id)||(m.document.markSaved(b,String(O.id)),T(m,V),m.document.get().serverId,C())},x=(m,b,O)=>{if(!(b==="materialize"||b==="publish"&&m.document.get().serverId==null))return O;const j=m.createKey,V=j&&j.project===O.project?j:{key:d.generateUUID(),project:O.project};return m.createKey=V,{...O,idempotencyKey:V.key}},R=async(m,b,O)=>{try{await m.document.whenReady()}catch(N){return m.saveError=N,m.saveFailures+=1,m.failedIntent=b,m.saveFailures,!1}if(m.closed)return!1;const j=D(m.document.get().attributes);if(j)return m.saveError=j,m.saveFailures+=1,m.failedIntent=b,j.reason,C(),!1;if(a&&(await a(ec(m)).catch(()=>{}),m.closed))return!1;if(l){try{await l()}catch(N){return m.saveError=N,m.saveFailures+=1,m.failedIntent=b,m.saveFailures,C(),!1}if(m.closed)return!1}if(c&&b==="publish"){const N=await c(ec(m),m.request.key).catch(()=>{});if(m.closed)return!1;if(N!==void 0)return m.saveError=new Ne("plugin-refused",N),m.saveFailures+=1,m.failedIntent=b,C(),!1}let V;try{V=await w(m.document.get().attributes,O,b)}catch(N){return m.saveError=N,m.saveFailures+=1,m.failedIntent=b,m.saveFailures,C(),!1}if(m.closed)return!1;const{payload:X,version:G}=Gm(m.document,O,V,b),K=x(m,b,X);m.document.get().docId;try{const N=m.document.get().serverId!=null,Y=await Km(r(),s(m.request.key),b,m.document.get().serverId,K,m.document.get().attributes.wpId);if(m.closed)return!0;let J;if(b==="snapshot"||b==="anchor"){const ee=Y?.modified!=null?Date.parse(Y.modified):NaN;J=Number.isFinite(ee)?ee:Date.now(),m.snapshotVersion=G,m.lastRevisionAt=J}else{m.document.markSaved(G,Y?.id!=null?String(Y.id):void 0);const ee=Y;Fn(m.document,Ya(ee&&{wpId:ee.wpId,secretHash:ee.secretHash})),m.broughtContent=jn(u(K.html))}T(m,N),m.saveError=void 0,m.saveFailures=0,m.failedIntent=void 0,m.document.get().serverId,C();const ge={intent:b,serverId:m.document.get().serverId,created:!N,...J!==void 0?{revisionAt:J}:{}};return A.forEach(ee=>ee(ge)),!0}catch(N){return(b==="publish"||b==="materialize")&&km(N)?.then(Y=>k(m,G,Y)),m.saveError=N,m.saveFailures+=1,m.failedIntent=b,m.saveFailures,C(),!1}},M=m=>{m.closed=!0,m.watchers.forEach(b=>b()),m.watchers=[],Xa(m),m.history.dispose(),m.document.dispose()},F=()=>{p&&(M(p),p=void 0)},U=()=>{_&&(M(_),_=void 0)},y=(m,b,O)=>{let j=!1;b.show&&(m.show?.id!==b.show.id||m.show.token!==b.show.token)&&(m.show=b.show,j=!0,{docId:m.document.get().docId,...b.show});const V=O==="show"?qa(b.patch):null;if(V){m.reports.set("plugin",V),Za(m,V);const X=cg(m,V);ms(m,X),og(m,X)}j&&C()},E=(m,b={})=>W(p,m,b),L=()=>p&&Q(p.request.key??"")?_:p,B=m=>({error:m?.saveError,failures:m?.saveFailures??0,saving:m?.saving===!0,failedIntent:m?.failedIntent}),W=(m,b,O)=>!m||m.closed||b==="materialize"&&m.document.get().serverId!=null?Promise.resolve(!1):m.saving?b==="snapshot"||b==="materialize"?Promise.resolve(!1):(m.inFlight??Promise.resolve(!1)).then(()=>W(m,b,O)):(m.saving=!0,C(),m.inFlight=R(m,b,O).finally(()=>te(m)),m.inFlight),te=m=>{m.saving=!1,m.inFlight=void 0,p===m&&!m.closed&&C()},ne=(m,b)=>{if(m.closed)return b();if(m.saving)return(m.inFlight??Promise.resolve(!1)).then(()=>ne(m,b));m.saving=!0,C();const O=Promise.resolve().then(b);return m.inFlight=O.then(()=>!0,()=>!1).finally(()=>te(m)),O},re=(m,b)=>{const O=m.document.get().serverId,j=O==null?void 0:Am(O);return ne(m,b).finally(j)},z=(m,b="open",O=!1)=>{if(p&&!p.closed&&b!=="new"&&tg(p.request,m))return y(p,m,b),p.document;F(),O||U();const j=cm({createBuffer:()=>tm(""),serverId:m.serverId??null}),V={request:m,show:m.show,document:j,history:pm(j,{now:Date.now}),watchers:[],userTouched:new Set,shownHeaders:{},saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return p=V,wm(j,X=>f?.(V.request.key)===!0?re(V,X):void 0),V.watchers.push(sg(V)),j.get().docId,m.serverId,S(V,t(m,{publishRecoveryFacts(X){V.closed||(V.recoveryFacts=X,C())},readShownContent:()=>V.closed?null:V.document.getContent(),readWpId:()=>V.closed?void 0:V.document.get().attributes.wpId})),C(),j},$=(m,b,O)=>({key:Q(m)?m:Mn(m),serverId:b?.id!=null?String(b.id):null,email:b,show:O});return{openWith:z,open:(m,b={})=>z({key:_t(m),serverId:m,email:b.email,patch:b.patch,show:b.show},"open"),openDraft:(m,b={})=>z({key:_t(void 0),serverId:null,email:m,patch:b.patch,show:b.show},"open"),startNewDraft:(m,b={})=>z({key:_t(void 0),serverId:null,email:m,patch:b.patch,show:b.show},"new"),reload:(m,b={})=>z({key:_t(m),serverId:m,email:b.email,patch:b.patch,show:b.show},"new"),openBlock:(m,b,O)=>z($(m,b,O),"open"),reloadBlock:(m,b,O)=>z($(m,b,O),"new"),openBlockOver:(m,b)=>{const O=$(m,b);return p&&!p.closed&&p.request.key===O.key?p.document:(p&&!p.closed&&!Q(p.request.key)&&(U(),_=p,p=void 0),z(O,"open",!0))},resumeSuspended:()=>{if(_)return F(),p=_,_=void 0,C(),p.document},hasSuspended:()=>!!_,suspendedDocument:()=>_?.document,show:(m,b)=>{const O=p;if(!(!O||O.closed))return z({...O.request,patch:m,show:b},"show")},current:()=>p?.document,noteServerFacts:({serverId:m,block:b},O)=>{const j=p;!j||j.closed||j.request.serverId!==m||Q(j.request.key??"")===b&&Fn(j.document,Ya(O))},save:E,saveEmail:(m,b={})=>W(L(),m,b),saveState:()=>B(p),emailSaveState:()=>B(L()),revisionFacts(){if(!p)return;const m=p.revisionFactsSnapshot;return m&&m.snapshotVersion===p.snapshotVersion&&m.lastRevisionAt===p.lastRevisionAt?m:(p.revisionFactsSnapshot={snapshotVersion:p.snapshotVersion,lastRevisionAt:p.lastRevisionAt},p.revisionFactsSnapshot)},recoveryFacts:()=>p?.recoveryFacts,history:()=>p?.history,forcedHeaders:()=>p?.forcedHeaders,beginForcedHeaders(m){p&&!p.closed&&(p.forcedHeaders=m)},endForcedHeaders(){for(const m of[p,_])m&&(m.forcedHeaders=void 0)},onSaved(m){return A.add(m),()=>A.delete(m)},showFacts:()=>p?.show,shownHeaders:()=>({...p?.shownHeaders}),showFill:()=>p?.showFill,beginShowFill(m){p&&!p.closed&&(p.showFill={showId:m,codeEdits:0})},noteCodeEdit(){p?.showFill&&(p.showFill.codeEdits+=1)},endShowFill(m){for(const b of[p,_])b?.showFill?.showId===m&&(b.showFill=void 0)},sessionKey:()=>p?.request.key,openError:()=>p?.error,subscribe(m){return v.add(m),()=>v.delete(m)},close(){!p&&!_||(F(),U(),C())}}}var gs=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function _s(e){if(e instanceof gs)return e.reason;if(e instanceof We)return _s(e.reason)}function dg(e){const t=e instanceof We?e.reason:e;return t instanceof gs&&t.reason==="unavailable"&&t.cause instanceof TypeError}function ug(e){const t=_s(e);return t!==void 0&&t!=="unavailable"}function fg(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new gs("not-found");return Ka(n)}}}var tc=d.createIdentifier("EmailPort");function hg(e){return e.getInstance(tc)}function pg(e,t){e.inject(tc,t)}var nc=d.createIdentifier("documentSession.restEmailPortFactories");function rc(e){return e.getInstance(nc)!==void 0}function qe(e){const t=e.getInstance(nc);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var mg=d.createIdentifier("EmailTermsResolver");function gg(e){return e.getInstance(mg)}var sc=d.createIdentifier("EmailHistoryPort"),_g=d.createIdentifier("BlockHistoryPort");function oc(e){return e.getInstance(_g)}function ic(e){return e.getInstance(sc)}function vg(e,t){e.inject(sc,t)}var Eg=2e3,bg=5e3,yg=5,wg=5e3,Sg=4;function Ig(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Un(e,t){return e==null||t==null?!1:e.replaceAll(`\r
|
|
2104
2104
|
`,`
|
|
2105
2105
|
`)===t.replaceAll(`\r
|
|
2106
2106
|
`,`
|
|
2107
|
-
`)}function gn(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function Pt(e,t){return Or(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function wh(e,t,n){const{latest:r}=e,s=mn(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(o=>mn(o,r.html))?s?{revision:null,phase:"normal"}:{revision:gn(t),phase:"timeout"}:s?{revision:Pt(e),phase:"normal"}:mn(t.html,r.html)?{revision:gn(t),phase:"found"}:{revision:Pt(e),phase:"normal"}}function Sh({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:s=!1,readShownContent:o,onFacts:i,onLate:a,onError:c,pageLoadTs:d=yh()}){const u=r??e;let f=null,h=!1,g=!1,m=0,v={emailId:e,historyLoaded:!1,isRecovering:!1},_=null;const T=new Promise(y=>{_=y}),A=y=>{v={...v,...y},i(v)};let B;const O=y=>{m+=1,A({applied:{phase:y,seq:m}})},S=()=>{f?.timer&&clearTimeout(f.timer),f=null},w=y=>{if(!g){if(_){const E=_;_=null,E(y),B=y.revision?y.phase:void 0;return}a(y)&&y.revision&&O(y.phase)}},D=()=>{if(!f||g)return;const y=f.phase==="fast",E=y?gh:Eh,N=y?_h:bh;f.timer=setTimeout(()=>{const F=f;if(!(!F||g)){if(F.attempts+=1,P(),y&&F.attempts>=N){const{pending:W}=F;Be(u),A({isRecovering:!1}),w({revision:gn(W),phase:"timeout"}),h=!0,F.phase="bg",F.attempts=0,D();return}if(!y&&F.attempts>=N){Be(u),S(),A({isRecovering:!1}),h=!0;return}D()}},E),f.timer.unref?.()},I=y=>{f={phase:"fast",attempts:0,pending:y,timer:null},A({isRecovering:!0}),D()},R=y=>{if(g)return;if(A({historyLoaded:!0,latestRevisionAt:y.latestAt!==void 0&&Number.isFinite(y.latestAt)?y.latestAt:void 0}),n&&f){const F=Pt(y,f.pending.sentAt);if(!F)return;const W=f.phase==="fast"?"found":"bg";Be(u),S(),A({isRecovering:!1}),h=!0,w({revision:F,phase:W});return}if(h)return;const E=n?ln(u):null,N=E&&(E.sentAt<d||!mn(E.html,o()))?E:null;if(N){if(s&&(N.baseRevisionId!==void 0||N.baseOpen)){Be(u),h=!0,w(wh(y,N,o()));return}const F=Pt(y,N.sentAt);if(F){Be(u),h=!0,w({revision:F,phase:"found"});return}if(s){if(Be(u),h=!0,y.latestAt!==void 0&&y.latestAt>N.sentAt+5e3){w({revision:null,phase:"normal"});return}w({revision:gn(N),phase:"timeout"});return}I(N);return}h=!0,w({revision:Pt(y),phase:"normal"})},M=y=>{g||(c?.(y),v.historyLoaded||(A({historyLoaded:!1,latestRevisionAt:void 0}),U()),!f&&w({revision:null,phase:"normal"}))},P=()=>t(e).then(R).catch(M);let L,x=!1;const U=()=>{x||f||g||(x=!0,L=setTimeout(()=>{L=void 0,!g&&!v.historyLoaded&&P()},vh))};return P(),{verdict:()=>T,confirmVerdict(y){const E=B;B=void 0,y&&E!==void 0&&!g&&O(E)},dispose(){g=!0,L!==void 0&&(clearTimeout(L),L=void 0),S()}}}function Ih({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:s,wpId:o,readShownContent:i,onFacts:a}){let c=null;const d=Sh({emailId:s,readAutosave:u=>o?e.readAutosave(u,{wpId:o()}):e.readAutosave(u),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:i,onFacts:a,onLate:({revision:u,phase:f})=>{const h=Si(u);return c?.(h)??!1},onError:u=>{u instanceof Error&&u.message}});return{id:"recovery",load:()=>d.verdict().then(({revision:u})=>Si(u)),loaded(u){d.confirmVerdict(u)},watch(u){return c=u,()=>{c=null,d.dispose()}}}}var Th=5e3,Ah=l.createIdentifier$1("plugin.knownRevisions");function ct(e){return e.getOrCreateInstance(Ah,()=>new Map)}function Lr(e,t,n,r){const s=n?.get(t)??[],o=s.filter(i=>i!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...s.length>xi?{baseOpen:!0}:o.length?{baseHtmls:o}:{}}}var Ch=l.createIdentifier$1("plugin.uncertainWrites"),xi=3;function Rt(e){return e.getOrCreateInstance(Ch,()=>new Map)}function Oh(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>xi||e.set(t,[...r,n])}function Fi(e,t){vr(e,t)||!t.baseHtmls||vr(e,{...t,baseHtmls:void 0,baseOpen:!0})}function vn(e,t,n,r=!1){const s=ln(e);!n||s?.sentAt!==t||!(r||s.baseOpen||s.baseHtmls)||vr(e,{...s,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function Bi(e,t,n,r){(ln(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||Fi(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var Dh=/(?:Z|[+-]\d{2}:?\d{2})$/i;function Ph(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",s=Dh.test(r)?Date.parse(r):NaN;return!Number.isFinite(s)||s>=t-Th}function ji(e,t,{pendingKey:n=i=>i,knownRevisions:r=new Map,uncertainWrites:s,synchronousHistory:o=!1}={}){return{readRevisions:(i,a,c)=>t.readRevisions(i,a,c),readRevision:(i,a,c)=>t.readRevision?t.readRevision(i,a,c):Promise.resolve(null),readAutosave:(i,a)=>t.readAutosave(i,a),async saveAutosave(i,a,c){const d=n(i),u=Date.now();Fi(d,{sentAt:u,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...Lr(r,d,s,a.html??"")});const f=await t.saveAutosave(i,a,c),h=f?.id;return Ph(f,u)?vn(d,u,h):h&&o&&(f.isAutosave===!0?Er(d,u):vn(d,u,h,!0)),await e.saveAutosave(i,a),f}}}function Rh(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,s){const o=Date.now();n&&Bi(r,s,o,Lr(n.knownRevisions,r,n.uncertainWrites,s.html??""));const i=await t.updateEmail(r,s);return n&&vn(r,o,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,s),Er(r,o),i&&{...i,id:r}}}}var Ui=Symbol.for("emailmaker.result");function $i(e){return Object.defineProperty(e,Ui,{value:!0})}var He=(e=>$i({ok:!0,value:e})),oe=((e,t="")=>$i({ok:!1,error:{code:e,message:t}}));function Hi(e){return typeof e=="object"&&e!==null&&e[Ui]===!0}var Ve=e=>({optional:!1,...e}),_n={string:()=>Ve({kind:"string"}),number:()=>Ve({kind:"number"}),boolean:()=>Ve({kind:"boolean"}),enum:(...e)=>Ve({kind:"enum",values:e}),element:(...e)=>Ve({kind:"element",kinds:e}),array:e=>Ve({kind:"array",item:e}),object:e=>Ve({kind:"object",shape:e}),optional:e=>({...e,optional:!0})};function Vi(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function En(e,t,n){if(t===void 0)return e.optional?void 0:`"${n}" is required`;switch(e.kind){case"string":case"number":case"boolean":return typeof t===e.kind?void 0:`"${n}" must be a ${e.kind}`;case"enum":return e.values?.includes(t)?void 0:`"${n}" must be one of: ${e.values?.join(", ")}`;case"element":return t!==null&&(typeof t=="object"||typeof t=="string")?void 0:`"${n}" must be an element reference`;case"array":if(!Array.isArray(t))return`"${n}" must be an array`;for(let r=0;r<t.length;r+=1){const s=En(e.item,t[r],`${n}[${r}]`);if(s)return s}return;case"object":return Vi(t)?Gi(e.shape,t,n):`"${n}" must be an object`}}function Gi(e,t,n){for(const[r,s]of Object.entries(e??{})){const o=En(s,t[r],n?`${n}.${r}`:r);if(o)return o}}function kh(e,t,n){return e?En(e,t,n):void 0}function Nh(e,t){if(!e)return;const n=e;return n.kind!=="object"?En(n,t,"arguments"):t!==void 0&&!Vi(t)?"arguments must be an object":Gi(n.shape,t??{},"")}function Wi(e){const t=e?.["~standard"];return typeof t=="object"&&t!==null&&typeof t.validate=="function"}function Lh(e){return(e.path??[]).map(t=>String(typeof t=="object"?t.key:t)).join(".")}function Yi(e,t){if(!Wi(e)){const n=Nh(e,t);return n?{ok:!1,problem:n}:{ok:!0,value:t??{}}}try{const n=e["~standard"].validate(t??{});return n instanceof Promise?n.then(qi,Ki):qi(n)}catch(n){return Ki(n)}}function Ki(e){return{ok:!1,problem:`the arguments check failed: ${e instanceof Error?e.message:String(e)}`}}function qi(e){if(e.issues){const[t]=e.issues,n=t?Lh(t):"";return{ok:!1,problem:t?n?`"${n}": ${t.message}`:t.message:"arguments are invalid"}}return{ok:!0,value:e.value}}var zi="Element reference returned by element.getTree, element.get or the selection.";function Mr(e){switch(e.kind){case"string":case"number":case"boolean":return{type:e.kind};case"enum":return{type:"string",enum:[...e.values??[]]};case"element":return e.kinds?.length?{type:"string",description:`${zi} Kinds: ${e.kinds.join(", ")}.`}:{type:"string",description:zi};case"array":return{type:"array",items:Mr(e.item)};case"object":{const t=Object.entries(e.shape??{}),n=t.filter(([,r])=>!r.optional).map(([r])=>r);return{type:"object",properties:Object.fromEntries(t.map(([r,s])=>[r,Mr(s)])),...n.length?{required:n}:{}}}}}var Mh={type:"object",properties:{}};function xh(e){if(!e)return Mh;if(!Wi(e))return Mr(e);const t=e["~standard"].jsonSchema;if(t&&typeof t.input=="function")return t.input({target:"draft-2020-12"});const n=e.toJSONSchema;if(typeof n=="function")return n.call(e);throw new Error(`The ${e["~standard"].vendor} schema cannot export JSON Schema; use a library version with Standard JSON Schema or Arg.object({...}).`)}function JT(e){}function Ee(e,t){try{t()}catch{}}var Fh=Symbol.for("emailmaker.platform.hostError"),bn="The editor could not load the code of its commands. Trying again does not help: the user has to reload the page.";function we(e,t){return Object.defineProperty(oe(e,t),Fh,{value:!0})}function Xi(e){const t=globalThis,n=Symbol.for(`emailmaker.platform.owner.${e}`);return t[n]??=Object.freeze({name:e})}var Ge=Xi("core"),Ji=Xi("unknown"),Qi=Symbol.for("emailmaker.platform.builtInPlugin");function Zi(e){return Symbol.for(`emailmaker.platform.builtInKey.${e}`)}function xr(e){return Object.entries(e).forEach(([t,n])=>{typeof n=="function"&&(Object.defineProperty(n,Qi,{value:!0}),Object.defineProperty(n,Zi(t),{value:!0}))}),e}function ea(e,t){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Zi(t))}function Bh(e){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Qi)}function ta(e){return Bh(e.constructor)}var jh=class{_owners=new WeakMap;_stack=[];_listeners=new Set;current(){return this._stack[this._stack.length-1]??Ji}execute(e,t){const n=e===Ge?Ji:e;this._stack.push(n);try{return t()}finally{this._leave(n)}}onUnload(e){return this._listeners.add(e),{dispose:()=>this._listeners.delete(e)}}handle(e){const{plugin:t}=e;if(t)switch(e.type){case"init:enter":case"afterInit:enter":ta(t)||this._stack.push(this._ownerOf(t,e.name));break;case"init:leave":case"afterInit:leave":ta(t)||this._leave(this._ownerOf(t,e.name));break;case"dispose:start":{const n=this._owners.get(t);n&&(this._leave(n),this._owners.delete(t),Array.from(this._listeners).forEach(r=>r(n)));break}}}_ownerOf(e,t){let n=this._owners.get(e);return n||(n={name:t},this._owners.set(e,n)),n}_leave(e){const t=this._stack.lastIndexOf(e);t>=0&&this._stack.splice(t,1)}};function yn(e){const t={watch:e,select:n=>yn(r=>{let s=!1,o;return t.watch(i=>{const a=n(i);s&&Object.is(o,a)||(s=!0,o=a,r(a))})})};return t}function Uh(e){return yn(t=>(t(e),{dispose:()=>{}}))}function $h(e,t){return yn(n=>{let r=!1,s=!1,o;const i=()=>{if(!r)return;const c=t();s&&Object.is(o,c)||(s=!0,o=c,n(c))},a=e.map(c=>c.watch(i));return r=!0,i(),{dispose:()=>a.forEach(c=>c.dispose())}})}function be(e){let t;return e.watch(n=>{t=n}).dispose(),t}function lt(e,t,n){return new Promise((r,s)=>{const o=()=>r(void 0),i=setTimeout(o,t),a=()=>{clearTimeout(i),n?.removeEventListener("abort",o)};n?.aborted&&o(),n?.addEventListener("abort",o,{once:!0}),Promise.resolve().then(e).then(c=>{a(),r(c)},c=>{a(),s(c)})})}function de(e,t){return{ok:!1,error:{code:e,message:t}}}function kt(e){return de("documentChanged",`"${e}" was not run: another email is open now, not the one this work started on. Stop and tell the user; do not repeat the call.`)}function Hh(e){return de("aborted",`"${e}" was not run: this tool became another command while the user was asked. Read the tools again and ask the user anew with a new call.`)}function Vh(e,t){return de("invalidArgs",`Call ${e} ("${t}") needs the user's consent, so its input cannot hold a "$result" reference: the consent window has to show the data. Run the earlier calls first, then send this call in a separate batch with the value written out. No call ran.`)}var Nt=e=>de("aborted",`The call of "${e}" was cancelled.`),wn=e=>e instanceof Error?e.message:String(e);function Gh(){return Object.assign(new Error(bn),{code:"unavailable"})}function Wh(){return{code:"undoConflict",message:"An agent call is still running; undo the answer when it ends."}}var Yh=64,Kh=/[\w-]+(?:\.[\w-]+)+/g;function dt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,Yh)}function Sn(e,t){return(e??[]).some(n=>n.endsWith(".*")?t.startsWith(n.slice(0,-1)):n===t)}function na(e,t){const n=new Map(t.map(([r,s])=>[s.id,r]));return e.replace(Kh,r=>n.get(r)??r)}var qh=3e3,zh=12,Xh=e=>typeof e?.label=="string"&&typeof e.value=="string";function Jh(e){const{title:t,details:n}=e??{};if(typeof t!="string"||!t)return;const r=(Array.isArray(n)?n:[]).filter(Xh).slice(0,zh);return r.length?{title:t,details:r.map(({label:s,value:o})=>({label:s,value:o}))}:{title:t}}async function Qh(e,t,n,r){const s=t.agent?.consent;if(s)try{return Jh(await lt(()=>e.asOwner(t.id,()=>s(n,r)),qh))}catch(o){`${t.id}${wn(o)}`;return}}function Zh(e,t,n,r,s){return{tool:e,command:t.id,title:t.title,description:t.description&&na(t.description,s()),input:n,...r?{consent:r}:{},...t.owner===Ge?{}:{fromPlugin:!0}}}async function ep({lifetime:e,ask:t,tool:n,signal:r,question:s}){if(r?.aborted||e.aborted)return Nt(n);if(!t)return de("forbidden",`The tool "${n}" needs the user's consent, and there is no one to ask in this editor.`);const o=new AbortController,i=()=>o.abort();r?.addEventListener("abort",i,{once:!0}),e.addEventListener("abort",i,{once:!0});const a=new Promise(d=>{o.signal.addEventListener("abort",()=>d(!1),{once:!0})}),c=async()=>{const d=await s(o.signal);return o.signal.aborted?!1:t({...d,signal:o.signal})};try{const d=await Promise.race([c(),a]);return o.signal.aborted?Nt(n):d===!0?void 0:we("declined",`The user declined "${n}". Do not repeat the call unless the user asks for it again.`)}catch(d){const u=wn(d);return`${n}${u}`,de("aborted",`The user was not asked about "${n}": ${u}`)}finally{r?.removeEventListener("abort",i),e.removeEventListener("abort",i),o.abort()}}var Fr=Symbol("bad input");function ra(e){try{return JSON.stringify(e)}catch{return Fr}}var ut=e=>e===void 0?void 0:JSON.parse(e);function sa(e){if(e===void 0)return null;try{return JSON.parse(JSON.stringify(e))}catch{return"[a value that cannot be serialized]"}}var ft="agent.batch",tp=5e3,np=5e3,rp=20,sp=new Set(["ui.openView","ui.closeView",ft]),op=class{_deps;_confirmHost;_bound;_turnDepth=0;_turnStart;_lastTurn;constructor(e){this._deps=e}setConfirmHost(e){return this._confirmHost=e,{dispose:()=>{this._confirmHost===e&&(this._confirmHost=void 0)}}}get _config(){return be(this._deps.config)??{}}get enabled(){return this._config.enabled!==!1}async tools(){const e=await this._describedOpened();return e.map(([t,n])=>({name:t,description:na(n.description??n.title,e),inputSchema:n.inputSchema??{type:"object",properties:{}},...this._needsConfirm(n)?{confirm:!0}:{}}))}invoke(e,t,n={}){return this._call(e,t,n)}async openBatch(e,t){const n=this._deps.commands.info(ft),r=n!==void 0&&this._needsConfirm(n),s=this._openDocument(),o=new Map,i=new Map;for(const[a,c]of e.entries()){const d=this._find(c.tool);if(!d)continue;const[u,f]=d,h=r||this._needsConfirm(f);if(!h&&!f.agent?.precheck)continue;if(c.deferred){if(h)return{ok:!1,error:Vh(a,u).error,index:a};continue}const g=ra(c.input);if(g===Fr)continue;const m=await this._checkInput(f,ut(g),t);if(!m||m.ok===!1||!this._deps.commands.availableNow(f.id))continue;const v=await this._precheck(u,f,m.value,t);if(v)return{ok:!1,error:v.error,index:a};o.set(a,f),h&&i.set(a,{tool:u,info:f,input:m.value,frozen:g})}if(n&&i.size>0){const a=sa(e.map(({tool:d,input:u})=>({tool:d,args:u}))),c=await this._ask(dt(ft),t,async d=>{const u=Array.from(i.values()),f=await Promise.all(u.slice(0,rp).map(async({tool:g,info:m,input:v,frozen:_})=>this._item(g,m,ut(_),await this._consentOf(m,v,d)))),h=await this._consentOf(n,void 0,d);return{...this._item(dt(ft),n,{calls:a},h),batch:{items:f,more:u.length-f.length}}});if(c)return{ok:!1,error:{...c.error,message:`${c.error.message} None of the calls of the batch ran.`}};if(this._openDocument()!==s)return{ok:!1,error:kt(dt(ft)).error}}return{ok:!0,run:(a,c)=>{const d=i.get(a);return this._call(e[a].tool,d?ut(d.frozen):c,{signal:t},{consented:d?.info,prechecked:o.get(a),askAll:r})}}}async _call(e,t,n,r={}){if(!this.enabled)return de("forbidden","The agent is switched off in this editor.");const s=this._find(e);if(!s)return this._deps.commands.info(e)??(be(this._deps.commands.commands)??[]).find(m=>dt(m.id)===e)?de("forbidden",`The tool "${e}" is not opened to the agent here.`):de("notInstalled",`There is no tool "${e}" in this editor.`);const[o,i]=s,a=ra(t);if(a===Fr)return de("invalidArgs",`Tool "${o}": the input must be plain JSON data.`);const c=await this._checkInput(i,ut(a),n.signal);if(!c)return n.signal?.aborted?Nt(o):de("unavailable",this._deps.commands.undescribed(i.id)?bn:`The input of the tool "${o}" could not be checked; try again.`);if(c.ok===!1)return de("invalidArgs",`Tool "${o}": ${c.problem}.`);const d=this._openDocument();if(this._adoptOpened(d),this._bound&&this._bound.document!==d)return kt(o);if(!this._deps.commands.availableNow(i.id))return de("unavailable",`The tool "${o}" is not available right now.`);if(r.prechecked!==i&&i.agent?.precheck){const m=await this._precheck(o,i,c.value,n.signal);if(m)return m;if(this._openDocument()!==d)return kt(o)}let u=r.consented;if(!u&&(r.askAll||this._needsConfirm(i))&&!(i.id===ft&&i.owner===Ge)){const m=await this._ask(o,n.signal,async v=>this._item(o,i,ut(a),await this._consentOf(i,c.value,v)));if(m)return m;if(this._openDocument()!==d)return kt(o);u=i}const f=this._deps.commands.prepared(i.id,n.signal);if(f!==!0){if(!await f)return n.signal?.aborted?Nt(o):de("unavailable",bn);const m=this._openDocument();if(this._adoptOpened(m),d!==void 0&&m!==d)return kt(o)}if(this._find(o)?.[1]!==(u??i))return Hh(o);const h=()=>this._deps.commands.run(i.id,ut(a),{caller:"agent",signal:n.signal}),g=await(sp.has(i.id)||i.agent?.readOnly?h():this._deps.history.group(h));return g.ok===!1?de(g.error.code,g.error.message||`The tool "${o}" failed: ${g.error.code}.`):{ok:!0,value:sa(g.value)}}readOnlyTool(e){return this._find(e)?.[1].agent?.readOnly===!0}get answerOpen(){return this._bound!==void 0}async holdDocument(e){const t=this._bound??={document:this._openDocument(),holders:0};t.holders+=1;try{return await e()}finally{t.holders-=1,t.holders===0&&(this._bound=void 0)}}_adoptOpened(e){this._bound&&this._bound.document===void 0&&e!==void 0&&(this._bound.document=e,this._deps.history.reopen(),this._turnDepth>0&&(this._turnStart=this._deps.history.answers?.capture()))}async turn(e){this._turnDepth===0&&(this._turnStart=this._deps.history.answers?.capture()),this._turnDepth+=1;try{return await this.holdDocument(()=>this._deps.history.group(e))}finally{this._turnDepth-=1,this._turnDepth===0&&(this._lastTurn={start:this._turnStart,end:this._deps.history.answers?.capture()})}}async undoTurn(){if(!this.enabled)return de("forbidden","The agent is switched off in this editor.");const e=this._deps.history.answers,t=e?.undoRefusal();if(t)return{ok:!1,error:t};const n=this._lastTurn;if(!e||!n)return de("nothingToUndo","There is no answer to undo.");this._lastTurn=void 0;try{const r=await e.settle()??(this._deps.history.grouping?Wh():e.undo(n.start,n.end));return r?(this._lastTurn??=n,{ok:!1,error:r}):{ok:!0,value:null}}catch(r){this._lastTurn??=n;const s=wn(r);return`${s}`,de("undoConflict",`The answer could not be undone: ${s}`)}}_needsConfirm(e){const{confirm:t}=this._config;return e.agent?.confirm===!0||Sn(t,e.id)||Sn(t,dt(e.id))}_openDocument(){return this._deps.history.answers?.document()}_find(e){return this._opened().find(([t,n])=>t===e||n.id===e)}_opened(){if(!this.enabled)return[];const e=this._config.deny,t=new Map;for(const n of be(this._deps.commands.commands)??[]){const r=dt(n.id);if(!n.agent||Sn(e,n.id)||Sn(e,r))continue;const s=t.get(r);if(s){`${s.id}${n.id}${r}`;continue}t.set(r,n)}return Array.from(t.entries())}async _describedOpened(){const{commands:e}=this._deps;let t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id));for(;n.length>0;){if((await Promise.all(n.map(([,r])=>e.described(r.id)))).includes(!1))throw Gh();t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id))}return t}async _checkInput(e,t,n){const{commands:r}=this._deps;if(r.undescribed(e.id)&&!await r.described(e.id,n))return;const s=Yi(this._deps.commands.declarationArgs(e.id),t);return s instanceof Promise?lt(()=>s,np,n):s}async _precheck(e,t,n,r){const s=t.agent?.precheck;if(s){try{const o=await lt(()=>this._deps.commands.asOwner(t.id,()=>s(n)),tp,r);if(Hi(o)&&o.ok===!1){const{code:i,message:a}=o.error;return de(i,a||`The tool "${e}" was refused: ${i}.`)}}catch(o){`${t.id}${wn(o)}`}return r?.aborted?Nt(e):void 0}}_consentOf(e,t,n){return Qh(this._deps.commands,e,t,n)}_item(e,t,n,r){return Zh(e,t,n,r,()=>this._opened())}_ask(e,t,n){const r=this._config.onConfirm??(be(this._deps.facts)?.headless?void 0:this._confirmHost);return ep({lifetime:this._deps.commands.lifetime,ask:r,tool:e,signal:t,question:n})}},ip={documentOpen:!1,selection:"none",codeMode:!1,readOnly:!1,headless:!1};function Lt(e,t){if(!e)return!0;if("any"in e)return e.any.some(r=>Lt(r,t));if("not"in e)return!Lt(e.not,t);const n={...ip,...t};return Object.entries(e).every(([r,s])=>n[r]===s)}var ap=5e3,oa=3e4;function ia(e){const{agent:t}=e;if(!t)return;if(t===!0)return{};const{readOnly:n,consent:r,precheck:s}=t;return{confirm:t.confirm===!0,...n===!0?{readOnly:!0}:{},...typeof r=="function"?{consent:r}:{},...typeof s=="function"?{precheck:s}:{}}}function aa(e,t,n){if(ia(n))try{return xh(n.args)}catch(r){throw new Error(`Command "${e}" of "${t.name}" is opened to the agent, but its arguments cannot be described for the model: `+(r instanceof Error?r.message:String(r)))}}function cp(e,t,{agent:n,description:r}){n&&!(typeof r=="string"&&r.trim())&&(`${e}${t.name}`,void 0)}var lp=class{_facts;_owners;_entries=new Map;_list=re([]);_disposed=!1;_lifetime=new AbortController;constructor(e,t){this._facts=e,this._owners=t}get commands(){return this._list}has(e){return this._entries.has(e)}register(e,t,n,r={},s={}){if(this._disposed)return`${e.name}`,{dispose:()=>{}};const o=Object.keys(t);for(const d of o){const u=this._entries.get(d);if(u&&!u.yieldable)throw new Error(`Command "${d}" is already registered by "${u.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(typeof n[d]!="function")throw new Error(`Command "${d}" of "${e.name}" has no handler.`)}const i=new Map(o.map(d=>[d,s.details?void 0:aa(d,e,t[d])]));s.details||o.forEach(d=>cp(d,e,t[d]));const a=o.map(d=>({id:d,owner:e,declaration:t[d],handler:n[d],enabled:r[d]??Uh(!0),pending:new Set,agent:ia(t[d]),inputSchema:i.get(d),yieldable:s.yieldable===!0,details:s.details,prepare:s.prepare}));this._detach(o.flatMap(d=>this._entries.get(d)??[])),a.forEach(d=>this._entries.set(d.id,d)),this._publish();let c=!1;return{dispose:()=>{c||(c=!0,this._remove(a))}}}disposeOwner(e){this._remove(Array.from(this._entries.values()).filter(t=>t.owner===e))}disposeAll(){this._disposed=!0,this._remove(Array.from(this._entries.values())),this._lifetime.abort()}get disposed(){return this._disposed}get lifetime(){return this._lifetime.signal}async run(e,t,n){if(this._disposed)return we("unavailable",`Command "${e}" is not available: the editor was destroyed.`);const r=this._entries.get(e);if(!r)return we("notInstalled",`Command "${e}" is not installed in this host.`);if(n.caller==="agent"&&!r.agent)return we("forbidden",`Command "${e}" is not opened to the agent.`);if(!Lt(r.declaration.when,be(this._facts)??{})||be(r.enabled)===!1)return we("unavailable",`Command "${e}" is not available right now.`);const s=n.signal,o=n.nested&&s?.aborted;if(r.details&&!await this._describe(r,o?void 0:s))return s?.aborted&&!o?oe("aborted",`Command "${e}" was cancelled.`):we("unavailable",bn);const i=Yi(r.declaration.args,t),a=i instanceof Promise?await lt(()=>i,ap,o?void 0:s):i;if(!a)return s?.aborted?oe("aborted",`Command "${e}" was cancelled.`):we("unavailable",`Command "${e}": the check of its arguments did not answer in time.`);if(a.ok===!1)return we("invalidArgs",`Command "${e}": ${a.problem}.`);if(this._disposed||this._entries.get(e)!==r)return we("unavailable",`Command "${e}" was removed while its arguments were checked.`);const c=new AbortController,d=new Promise(h=>{c.signal.addEventListener("abort",()=>h(oe("aborted",`Command "${e}" was cancelled.`)),{once:!0})});if(s?.aborted&&!o)return oe("aborted",`Command "${e}" was cancelled before it started.`);const u=()=>c.abort();s?.addEventListener("abort",u,{once:!0}),r.pending.add(c);const f={signal:c.signal,caller:n.caller,run:(h,g)=>this.run(h,g,{caller:"plugin",signal:c.signal,nested:!0})};try{return await Promise.race([this._execute(r,a.value,f),d])}finally{s?.removeEventListener("abort",u),r.pending.delete(c)}}visible(e){return $h([this._list,this._facts],()=>{const t=this._entries.get(e);return t!==void 0&&Lt(t.declaration.when,be(this._facts)??{})})}enabled(e){return yn(t=>{let n,r;const s=i=>{i!==r&&(r=i,t(i))},o=this._list.watch(()=>{n?.dispose();const i=this._entries.get(e);n=i?i.enabled.watch(s):void 0,i||s(!1)});return{dispose:()=>{o.dispose(),n?.dispose()}}})}declarationArgs(e){return this._entries.get(e)?.declaration.args}undescribed(e){return this._entries.get(e)?.details!==void 0}async described(e,t){const n=this._entries.get(e);return n?.details?this._describe(n,t):!0}prepared(e,t){const n=this._entries.get(e);return n?.prepare?this._prepare(n,n.prepare,t):!0}async _prepare(e,t,n){const r=new AbortController,s=()=>r.abort();n?.aborted&&s(),n?.addEventListener("abort",s,{once:!0}),e.pending.add(r);try{return await lt(()=>t().then(()=>!0),oa,r.signal)===!0}catch{return!1}finally{n?.removeEventListener("abort",s),e.pending.delete(r)}}availableNow(e){const t=this._entries.get(e);return!this._disposed&&t!==void 0&&Lt(t.declaration.when,be(this._facts)??{})&&be(t.enabled)!==!1}info(e){const t=this._entries.get(e);return t&&ca(t)}asOwner(e,t){const n=this._entries.get(e);return n&&this._owners?this._owners.execute(n.owner,t):t()}_describe(e,t){return lt(()=>{const{details:r}=e;return r&&(e.detailsLoading??=this._loadDetails(e,r))},oa,t).then(()=>e.details===void 0,()=>!1)}async _loadDetails(e,t){try{const n=await t(),r={...e.declaration,...n[e.id]};e.inputSchema=aa(e.id,e.owner,r),e.declaration=r,e.details=void 0}finally{e.detailsLoading=void 0}}async _execute(e,t,n){try{const r=e.handler,s=()=>r(t,n),o=await(this._owners?this._owners.execute(e.owner,s):s());return Hi(o)?o:He(o)}catch(r){return oe("internal",r instanceof Error?r.message:String(r))}}_remove(e){this._detach(e)&&this._publish()}_detach(e){let t=!1;for(const n of e)this._entries.get(n.id)===n&&(this._entries.delete(n.id),t=!0),n.pending.forEach(r=>r.abort());return t}_publish(){this._list.set(Array.from(this._entries.values()).map(ca))}};function ca(e){const{title:t,icon:n}=e.declaration;return e.info??={id:e.id,owner:e.owner,title:t,get description(){return e.declaration.description},icon:n,agent:e.agent,get inputSchema(){return e.inputSchema}}}var la=5e3,da=Symbol("timedOut"),dp=class{_willSave=[];_changes=[];_selection=re(null);get selection(){return this._selection}onWillSave(e,t){return this._add(this._willSave,{owner:e,handler:t})}onDidChange(e,t){return this._add(this._changes,{owner:e,handler:t})}async runWillSave(e){for(const{owner:t,handler:n}of this._willSave.slice()){const r=new AbortController;let s;const o=new Promise(i=>{s=setTimeout(()=>i(da),la)});try{const i=await Promise.race([Promise.resolve().then(()=>n({...e,signal:r.signal})),o]);if(i===da){`${t.name}${la}`;continue}if(i&&typeof i=="object"&&typeof i.refuse=="string")return{owner:t.name,message:i.refuse}}catch(i){`${t.name}${i instanceof Error?i.message:String(i)}`}finally{clearTimeout(s),r.abort()}}}emitChange(e){for(const{owner:t,handler:n}of this._changes.slice())try{n(e)}catch(r){`${t.name}${r instanceof Error?r.message:String(r)}`}}disposeOwner(e){for(const t of[this._willSave,this._changes])for(let n=t.length-1;n>=0;n-=1)t[n].owner===e&&t.splice(n,1)}_add(e,t){return e.push(t),{dispose:()=>{const n=e.indexOf(t);n>=0&&e.splice(n,1)}}}},up=Symbol.for("emailmaker.domView");function fp(e){return typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.$$typeof=="symbol"}function hp(e){return typeof e=="object"&&e!==null&&typeof e[up]=="function"}var Mt=["plugins"],pp={toolbar:{kind:"item",groups:["view","collaboration","document","plugins","primary"]},"menu:document":{kind:"item",groups:["document","plugins","access","danger"]},"menu:export":{kind:"item",groups:["formats","plugins","platforms"]},"menu:view":{kind:"item",groups:["preview","plugins","share"]},"menu:save":{kind:"item",groups:Mt},statusBar:{kind:"item",groups:["selection","document","plugins","collaboration"]},notices:{kind:"item",groups:Mt},sidebar:{kind:"view",groups:["content","collaboration","analysis","plugins","settings"]},dialog:{kind:"view",groups:Mt},documentSettings:{kind:"view",groups:Mt},inspector:{kind:"view",groups:Mt}},Br="plugins";function mp(e,t){const n=e.groups.indexOf(t);return n<0?e.groups.length:n}var QT="1.0",gp=Symbol.for("emailmaker.viewHost"),jr={dispose:()=>{}},vp=class{_deps;apiVersion="1.0";_locations=new Map(Object.entries(pp));_items=re([]);_views=re([]);_opened=re([]);_viewById=new Map;_seq=0;_openedKey=0;_disposed=!1;constructor(e){this._deps=e,this._registerCoreCommands()}get opened(){return this._opened}registerLocation(e,t){if(this._locations.has(e))throw new Error(`Location "${e}" is already registered.`);return this._locations.set(e,t),{dispose:()=>{this._locations.get(e)===t&&this._locations.delete(e)}}}addItem(e,t){if(this._skipAfterDispose(e))return jr;const n=this._itemLocation(t.location,"item",e);if(!n)return jr;const r={seq:this._nextSeq(),owner:e,location:t.location,group:this._groupOf(n,t.group,t.location),order:t.order??0,item:t};return this._items.set([...this._items.get()??[],r]),{dispose:()=>this._removeItems(s=>s===r)}}addViews(e,t,n,r){if(this._skipAfterDispose(e))return jr;const s=Object.keys(t);for(const i of s){const a=this._viewById.get(i);if(a)throw new Error(`View "${i}" is already registered by "${a.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(!fp(n[i])&&!hp(n[i]))throw new Error(`View "${i}" of "${e.name}" has no component; pass a React component or domView(renderer).`)}const o=[];for(const i of s){const a=t[i],c=this._itemLocation(a.location,"view",e);if(c){const d=this._groupOf(c,a.group,a.location);o.push({seq:this._nextSeq(),id:i,owner:e,location:a.location,group:d,order:a.order??0,declaration:a,renderer:n[i],editor:r})}}return o.forEach(i=>this._viewById.set(i.id,i)),this._views.set([...this._views.get()??[],...o]),{dispose:()=>this._removeViews(i=>o.includes(i))}}open(e,t){if(this._disposed)return Promise.resolve(oe("cancelled",`View "${e}" cannot open: the editor was destroyed.`));if(be(this._deps.facts)?.headless)return Promise.resolve(we("unavailable",`View "${e}" cannot open: the editor has no interface.`));const n=this._viewById.get(e);if(!n)return Promise.resolve(we("notInstalled",`View "${e}" is not installed in this host.`));const r=kh(n.declaration.input,t,"input");if(r)return Promise.resolve(we("invalidArgs",`View "${e}": ${r}.`));const s=n.location==="inspector"?this._inspectedElement():void 0;return n.location==="inspector"&&!s?Promise.resolve(we("unavailable",`View "${e}" cannot open: no element is selected.`)):(this.close(e),new Promise(o=>{const i=new AbortController;let a=!1;const c=h=>{if(!a){a=!0;try{this._opened.set((this._opened.get()??[]).filter(g=>g!==f))}finally{s?.dispose(),i.abort(),o(h)}}},d=h=>c(He(h)),u={input:t,signal:i.signal,close:d};s&&Object.defineProperty(u,"element",{value:s.element,enumerable:!0}),Object.defineProperty(u,gp,{value:this._viewHost(n)});const f={key:this._openedKey+=1,view:e,owner:n.owner,location:n.location,input:t,record:n,renderer:n.renderer,signal:i.signal,context:u,close:d,cancel:()=>c(oe("cancelled",`View "${e}" was closed without a result.`))};this._opened.set([...this._opened.get()??[],f])}))}_inspectedElement(){const e=this._deps.selection,t=e?be(e):void 0;if(!e||t==null)return;const n=re(t),r=e.watch(s=>{s!=null&&n.set(s)});return{element:n,dispose:()=>r.dispose()}}viewLocation(e){return this._viewById.get(e)?.location}close(e){(this._opened.get()??[]).filter(t=>t.view===e).forEach(t=>t.cancel())}items(e){return this._items.select(t=>this._sorted(t,e))}get allViews(){return this._views}views(e){return this._views.select(t=>this._sorted(t,e))}disposeOwner(e){Ee("items",()=>this._removeItems(t=>t.owner===e)),Ee("views",()=>this._removeViews(t=>t.owner===e))}disposeAll(){this._disposed=!0,Ee("items",()=>this._removeItems(()=>!0)),Ee("views",()=>this._removeViews(()=>!0))}supports(e,t){switch(e){case"service":return t==="Commands"||t==="Ui"||t==="Agent"||t==="Document";case"location":return this._locations.has(t);case"command":return this._deps.commands.has(t);case"view":return this._viewById.has(t)}}_sorted(e,t){const n=this._locations.get(t),r=s=>n?mp(n,s.group):0;return e.filter(s=>s.location===t).sort((s,o)=>r(s)-r(o)||s.order-o.order||s.seq-o.seq)}_itemLocation(e,t,n){const r=this._locations.get(e);if(!r)`${n.name}${e}`;else if(r.kind!==t){`${n.name}`,`${e}${r.kind}`;return}return r}_groupOf(e,t,n){return t===void 0?Br:e.groups.includes(t)?t:(`${n}${t}${Br}`,Br)}_nextSeq(){return this._seq+=1,this._seq}_removeItems(e){const t=this._items.get()??[];t.some(e)&&this._items.set(t.filter(n=>!e(n)))}_removeViews(e){const t=this._views.get()??[],n=t.filter(e);if(n.length!==0){n.forEach(r=>this._viewById.delete(r.id));try{this._views.set(t.filter(r=>!e(r)))}finally{(this._opened.get()??[]).filter(r=>n.includes(r.record)).forEach(r=>Ee(`close ${r.view}`,()=>r.cancel()))}}}_skipAfterDispose(e){return this._disposed&&(`${e.name}`,void 0),this._disposed}_viewHost(e){return{run:(t,n)=>this._deps.commands.run(t,n,{caller:"ui"}),editor:e.editor}}_registerCoreCommands(){this._deps.commands.register(Ge,{"ui.openView":{title:"Open view",description:"Opens a plugin view by id and waits for its output; a dialog resolves when the user closes it.",args:_n.object({view:_n.string()}),agent:!0},"ui.closeView":{title:"Close view",description:"Closes an open view by id.",args:_n.object({view:_n.string()}),agent:!0}},{"ui.openView":e=>this.open(e.view,e.input),"ui.closeView":e=>(this.close(e.view),He())})}};function _p(){return re({})}function xt(e,t){const n=e.get()??{};Object.keys(t).some(r=>n[r]!==t[r])&&e.set({...n,...t})}var Ep=class{_depth=0;_host;_open;connect(e){return this._host=e,{dispose:()=>{this._host===e&&(this._host=void 0)}}}get grouping(){return this._depth>0}get answers(){return this._host?.answers}async group(e){this._enter();try{return await e()}finally{this._leave()}}reopen(){this._depth>0&&this._open?.begin()}_enter(){this._depth+=1,this._depth===1&&(this._open=this._host,this._open?.begin())}_leave(){if(this._depth-=1,this._depth===0){const e=this._open;this._open=void 0,e?.end()}}},bp=l.createIdentifier$1("platform.ownerTracker"),yp=l.createIdentifier$1("platform.whenFacts"),wp=l.createIdentifier$1("platform.commandRegistry"),Sp=l.createIdentifier$1("platform.uiService"),Ip=l.createIdentifier$1("platform.editHistory"),Tp=l.createIdentifier$1("platform.agentConfig"),Ap=l.createIdentifier$1("platform.agentService"),Cp=l.createIdentifier$1("platform.documentEvents");function We(e){return e.getOrCreateInstance(bp,()=>{const t=new jh;return t.onUnload(n=>{Ee("commands",()=>Ce(e).disposeOwner(n)),Ee("ui",()=>In(e).disposeOwner(n)),Ee("document",()=>Le(e).disposeOwner(n))}),t})}function ht(e){return e.getOrCreateInstance(yp,_p)}function Ur(e){return e.getOrCreateInstance(Ip,()=>new Ep)}function Op(e){const{isDisposed:t}=e;return typeof t=="function"&&t.call(e)}function ua(e){return e.getOrCreateInstance(wp,()=>new lp(ht(e),We(e)))}function Dp(e){return e.getOrCreateInstance(Sp,()=>(We(e),new vp({commands:ua(e),facts:ht(e),selection:Le(e).selection})))}function fa(e){const t=ua(e),n=Dp(e);return!t.disposed&&Op(e)&&(Ee("ui",()=>n.disposeAll()),Ee("commands",()=>t.disposeAll())),{registry:t,ui:n}}function Ce(e){return fa(e).registry}function In(e){return fa(e).ui}function ha(e){return e.getOrCreateInstance(Tp,()=>re({}))}function Tn(e){return e.getOrCreateInstance(Ap,()=>new op({commands:Ce(e),history:Ur(e),config:ha(e),facts:ht(e)}))}function Le(e){return e.getOrCreateInstance(Cp,()=>new dp)}function Pp(e){return async(t,n)=>{const r=J(n)?"block":"email";return(await Le(e).runWillSave({kind:r,id:t.id==null?null:String(t.id),content:t.html??""}))?.message}}var pa=l.createIdentifier$1("CurrentUser"),ma={};function $r(e){return e.getOrCreateInstance(pa,()=>re(ma))}function ga(e){return e?.getInstance(pa)?.get()??ma}var va=l.createIdentifier$1("HeadlessMode");function Hr(e){return e.getOrCreateInstance(va,()=>re(!1))}function Rp(e){return e?.getInstance(va)?.get()??!1}var kp=l.createIdentifier$1("HiddenMount");function Np(e){return e.getOrCreateInstance(kp,()=>re(!1))}function Lp(e){if(!e)return!1;try{return!!l.decodeJwt(e).data?.act_as}catch{return!1}}function Mp(e){return Lp(e?.getInstance(l.COOKIE_MANAGER_ID)?.get(l.APP_COOKIES.em_token))}var xp="SAVE_BUTTON",Fp="AUTOSAVE",Bp=Symbol.for("emailmaker.saveNotified"),jp=l.createIdentifier$1("helpers.saveListeners");function Up(e,t="email"){return(e.getInstance(jp)?.[t]??0)>0}function _a(e){return e?.getInstance(l.CONFIG_SOURCE_ID)?.get()??{}}function An(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function $p(e,t){return t.modeDefaults(An(e,t.fallbackMode))}function Ea(e,t){const n=An(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function ba(e,t){const n=An(e,t),r=e.user?.advancedConfigs?.[n],s=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...s}}function Hp(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Vp(e){return l.mergeResourceProxyLayers(e.map(t=>t?.resourceProxy))}function Gp(e){return l.mergeResourceProxyPolicyLayers(e.map(t=>t?.resourceProxyPolicy))}function Wp(e){return l.mergeBackendProxyLayers(e.map(t=>t?.backendProxy))}function Yp(e){return l.mergeShallowConfigLayers(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Kp(e,t){return[e.base,$p(e,t),e.profile,e.serverSide,Ea(e,t.fallbackMode),e.local,e.user,ba(e,t.fallbackMode)]}function Vr(e,t){const n=Kp(e,t),r=l.mergeShallowConfigLayers(n),s=Hp(n);s!==void 0&&(r.fileManager=s);const o=Vp(n);o!==void 0&&(r.resourceProxy=o);const i=Gp(n);i&&Object.keys(i).length>0&&(r.resourceProxyPolicy=i);const a=Wp(n);a!==void 0&&(r.backendProxy=a);const c=Yp(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function qp(e,t,n){const r=Ea(e,n),s=ba(e,n);return l.pickKey([s,e.user,r,e.serverSide],t)}var zp=1.5;function Xp(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<=zp*e.autosaveTimeoutMs?"none":"revision"}var ZT=5,eA=3,Jp=1e4;function Qp(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:s}=e,o=e.readFailures??(()=>0),i=e.readFailureRetryable??(()=>!0);let a;const c=R=>a!==void 0&&a.version===R.get().version?o()-a.failuresAtStart:0,d=R=>{const M=c(R);if(M<=0)return!1;const P=n().retryMaxAttempts??5;return!i()||M>P},u=()=>{const{autosaveTimeoutMs:R,retryIntervalMs:M}=n(),P=t();return P!==void 0&&c(P)>0&&M!==void 0&&M>0?M:P?.isNew()?Jp:R},f=R=>R.isNew()&&o()>=3,h=()=>{const R=t();if(!R||R.isDisposed()||d(R))return"none";const{latestRevisionAt:M,snapshotVersion:P,...L}=n(),x=Date.now(),U=Xp({...L,isDirty:R.isDirty(),isNew:R.isNew(),isReady:R.isReady(),latestRevisionAgeMs:M!=null&&M<=x?x-M:void 0,isSnapshotSent:P!=null&&P===R.get().version});return U==="create"&&f(R)?"none":U},g=()=>{const R=t();if(!R||R.isDisposed()||f(R)||d(R)||n().isHeadless)return!1;if(!R.isDirty())return R.isNew();const{snapshotVersion:M}=n();return!(M!=null&&M===R.get().version)};let m,v=0,_=0,T,A,B,O=!1;const S=()=>{T=void 0;const R=t();if(!R||R.isDisposed())return;if(R.get().docId!==m){w();return}const M=h();M!=="none"&&a?.version!==R.get().version&&(a={version:R.get().version,failuresAtStart:o()}),M==="create"?r():M==="revision"?s():g()&&(m=R.get().docId,v=u(),_=o(),T=setTimeout(S,v))},w=()=>{const R=t();if(O||!R)return;const M=a?.version===R.get().version&&_!==o();T!==void 0&&(v!==u()||M)&&(clearTimeout(T),T=void 0),!(T!==void 0||h()==="none"&&!g())&&(m=R.get().docId,v=u(),_=o(),T=setTimeout(S,v))},D=R=>{const M=t();R.source==="user"?a=void 0:a&&M&&(a.version=M.get().version),R.source==="user"&&T!==void 0&&(clearTimeout(T),T=void 0),w()},I=()=>{const R=t();R!==A&&(B?.(),A=R,a=void 0,B=R?.subscribe(D),T!==void 0&&(clearTimeout(T),T=void 0))};return I(),w(),{refresh:()=>{O||(I(),w())},stop:()=>{O=!0,B?.(),B=void 0,A=void 0,T!==void 0&&(clearTimeout(T),T=void 0)}}}var ya=l.createIdentifier$1("documentSession.autosaveUiFacts"),wa={isUserBusy:!1,saveContext:{}};function Zp(e){return e.getOrCreateInstance(ya,()=>re(wa))}function Gr(e){return e?.getInstance(ya)?.get()??wa}function Sa(e){return Gr(e).saveContext.fallbackTitle||"Untitled email."}var em=1e4,tm=3e4;function nm(e,t){const n=h=>{const g=e.getInstance(l.CONFIG_SOURCE_ID)?.layers?.(),m=g?qp(g,h):void 0;return typeof m=="number"&&m>=0?m:void 0};let r;const s=h=>{const{error:g,failures:m}=t.saveState();return mi(g)?(r?.failures!==m&&(r={failures:m,saved:h??null}),r.saved===(h??null)):(r=void 0,!1)},o=()=>{const h=t.current(),g=h?.get().serverId??void 0,m=J(t.sessionKey()),v=t.recoveryFacts(),_=v?.emailId===g?v:void 0,T=t.revisionFacts(),A=_?.latestRevisionAt,B=T?.lastRevisionAt,O=ga(e).profile;return{isInited:m||h?.get().attributes.is_inited===!0,isEnabled:!!O?.autosaves&&!Mp(e)&&!s(h?.get().savedVersion),isHistoryLoaded:_?.historyLoaded===!0,isUserBusy:Gr(e).isUserBusy,isHeadless:Rp(e),autosaveTimeoutMs:_a(e).autosaveTimeout||em,latestRevisionAt:A!==void 0||B!==void 0?Math.max(A??0,B??0):void 0,snapshotVersion:T?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??tm,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},i=()=>{const h=Gr(e).saveContext;return{...h,project:h.project??t.current()?.get().attributes.project,fallbackTitle:Sa(e)}},a=Qp({readDocument:()=>t.current(),readEnvironment:o,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>kf(t.saveState().error),onCreate:()=>{J(t.sessionKey())||t.save("materialize",{...i(),source:Fp})},onRevision:()=>{t.save("snapshot",{project:i().project})}}),c=t.subscribe(()=>{s(t.current()?.get().savedVersion),a.refresh()}),d=$r(e).watch(()=>a.refresh()),u=Zp(e).watch(()=>a.refresh()),f=Hr(e).watch(()=>a.refresh());return()=>{c(),d.dispose(),u.dispose(),f.dispose(),a.stop()}}var Ia=12e3;function he(e){return e.getOrCreateInstance(nt,()=>{const t=ih({resolveAdapters:(r,s)=>om(r,e,s),resolveWritePort:()=>Ta(e),resolveHistoryPort:r=>J(r)?Ca(e):Aa(e),resolveTerms:()=>hh(e),canEdit:r=>Do(e,r),notifyBeforeSave:Mu(e),confirmPublish:Pp(e),awaitCanvasSynced:$u(e),savedEchoForm:r=>{const s=Ne(e);return s.toEditorForm(s.toOutputForm(r))},queuesOutsideWrites:r=>J(r)&&(Yu()||st(e)),timeoutMs:Ia,onAdapterError:(r,s)=>{s instanceof Error&&s.message;const o=ch(s),i=ah(s);Ct(s,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(o),network_failure:String(i)},level:o||i?"warning":"error"})},onTimeout:r=>{}}),n=nm(e,t);return e.getInstance(l.DISPOSABLE_ID)?.addDispose(n),t})}function ye(e){return e?.getInstance(nt)}function Ta(e){const t=dh(e);return t?Cn(e)?Rh(t,$e(e).email(e),st(e)?{knownRevisions:ct(e),uncertainWrites:Rt(e)}:void 0):t:$e(e).email(e)}function rm(e){return Mi(e)!==void 0||ki(e)}function Aa(e){const t=Mi(e);return t?Cn(e)?(se("port:history:server-backed"),ji(t,$e(e).history(e),{knownRevisions:ct(e),uncertainWrites:Rt(e),synchronousHistory:st(e)})):(se("port:history:integrator"),t):(se("port:history:rest (порт не зарегистрирован)"),$e(e).history(e))}function Ca(e){const t=Li(e);return t?Cn(e)?(se("port:block-history:server-backed"),ji(t,$e(e).blockHistory(e),{pendingKey:_r,knownRevisions:ct(e),uncertainWrites:Rt(e),synchronousHistory:st(e)})):(se("port:block-history:integrator"),t):(se("port:block-history:rest (порт не зарегистрирован)"),$e(e).blockHistory(e))}function sm(e){return Li(e)!==void 0||ki(e)}function Cn(e){return Co(e)}function om({email:e,patch:t,serverId:n,key:r},s,o){const i=[];e?i.push({id:"rest",load:()=>yi(e),required:!0}):n&&i.push(lh(Ta(s),n)),t&&i.push({id:"plugin",load:()=>wi(t)});const a=J(r);return Vu(n)&&(a?sm(s):rm(s))&&i.push(Ih({port:a?Ca(s):Aa(s),revisionServiceEnabled:Cn(s),pendingKey:Vo(n,a),historyIsSynchronous:st(s),emailId:n,wpId:()=>o.readWpId(),readShownContent:()=>o.readShownContent(),onFacts:c=>o.publishRecoveryFacts(c)})),i}function im(e){const t=he(e),n=ae(e).addListener(l.EVENT_TYPES.APPLICATION_HAS_AMP,r=>{it(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>n.dispose())}function am(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function cm(e){const t=e.fetchImpl??((o,i)=>fetch(o,i)),n=e.pageHost??(()=>window.location.hostname),r=new Set,s=o=>{try{const i=new URL(o,window.location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?!1:i.hostname===n()||e.sourceHosts().includes(i.hostname)}catch{return!1}};return{accepts:s,async load(o){if(!s(o))return;const i=!r.has(o);r.add(o);try{const a=await t(o,{mode:"cors",credentials:"omit",cache:i?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return am(c)?c:void 0}catch{return}}}}var Ye={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function lm(e){const t={maxBytes:e.maxBytes??Ye.maxBytes,maxImageBytes:e.maxImageBytes??Ye.maxImageBytes,ttlMs:e.ttlMs??Ye.ttlMs},n=e.now??(()=>Date.now()),r=new Map,s=new Map,o={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(),o.hits+=1,h.blob;h&&a(f);const g=s.get(f);if(g!==void 0)return g;o.loads+=1;const m=(async()=>{try{const v=await e.load(f);return v?u(f,v):o.failures+=1,v}catch{o.failures+=1;return}finally{s.delete(f)}})();return s.set(f,m),m},forget(f){a(f),s.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(),s.clear(),i=0},stats(){return{entries:r.size,bytes:i,...o}}}}var dm=["emcdn.ru","scr.emcdn.ru"];function um(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 fm(e,t){const n=(r,s)=>{const o=new Set(s?t:[]);for(const i of r){const a=um(i);a&&o.add(a)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function hm(e){const t=e??{},n=t.isPlugin!==!0?dm:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Ye};const s=r===!0||r===void 0?{}:r;return{enabled:s.enabled!==!1,sourceHosts:fm(s.sourceHosts,n),maxBytes:s.maxBytes??Ye.maxBytes,maxImageBytes:s.maxImageBytes??Ye.maxImageBytes,ttlMs:s.ttlMs??Ye.ttlMs}}function pm(e){const t=ae(e),n=e.getInstance(l.CONFIG_SOURCE_ID),r=()=>hm({...n?.get(),isPlugin:!0});let s=r();const o=cm({sourceHosts:()=>s.sourceHosts}),i=lm({load:v=>o.load(v),maxBytes:s.maxBytes,maxImageBytes:s.maxImageBytes,ttlMs:s.ttlMs}),a=()=>{t.send(l.EVENT_TYPES.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:s.enabled,sourceHosts:[...s.sourceHosts]})},c=t.onInit(()=>a()),d=n?.watch(()=>{const v=r(),_=JSON.stringify(v)!==JSON.stringify(s);s=v,i.configure(v),v.enabled||i.clear(),_&&t.isInited()&&a()}),u={asked:0,served:0,refused:0},f=[],h=(v,_)=>(u.refused+=1,f.push({url:v,reason:_}),f.length>20&&f.shift(),{refused:!0}),g=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:s,counters:{...u},refusals:[...f],store:i.stats()})}),m=t.addListenerAsync(l.EVENT_TYPES.APPLICATION_CANVAS_IMAGE_GET,async v=>{const _=v?.url??"";if(u.asked+=1,!s.enabled||!_)return h(_,"disabled");if(!o.accepts(_))return h(_,"host");v.fresh&&i.forget(_);const T=await i.get(_);return T?(u.served+=1,{blob:T}):h(_,"load-failed")});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{c.dispose(),d?.dispose(),m.dispose(),i.clear(),delete g.__emmCanvasImages__})}var mm=2e3;function gm(e){const t=ae(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))&&(Ct(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d=!0,t.holdPort(i))},mm);n.set(i,f)},s=Object.assign(globalThis,{__emmCanvasPort__:()=>{const i=t.getTarget();return{usesPort:t.usesPort,windowDrained:i?t.isWindowDrained(i):!1}}}),o=t.onInit(()=>r());e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{for(const i of n.values())clearTimeout(i);o.dispose(),delete s.__emmCanvasPort__})}var vm=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function _m(e){return vm.test(e)||e.indexOf("//")===0}function On(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Em(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Oa(e,t){const n=e==null||e===""?"./":String(e);if(_m(n))return On(n);const r=t??Em();if(!r)return On(n);try{return On(new URL(n,r).href)}catch{return On(n)}}function bm(){return typeof __useblocks__<"u"&&__useblocks__?.publicPath?Oa(__useblocks__.publicPath):Oa("/")}var ym=()=>"",wm=()=>"cd84d2b9";function Sm(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function Da(e){const t=e?"iframe-eblock":"iframe",n=ym();if(n){const o=Sm(n,window.location).replace(/\/?$/,"/");return bo(`${o}${t}.html`,St())}const r=wm(),s=`${bm().replace(/\/?$/,"/")}iframe/`;return bo(`${s}${t}${r?`.${r}`:""}.html`,St())}var Pa="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function Wr(e){return/^file:/i.test(String(e||"").trim())}function Im(e){return Wr(e)?`${Pa} allow-same-origin`:Pa}var tA="em:module-body",Tm="em:module-body-ack";function Am(e,t,n){try{const r=new URL("./",new URL(t,n)).href,s=new URL(e,r).href;return s.startsWith(r)?s:void 0}catch{return}}function Yr(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 Cm(e){const t=Yr(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function Om(e,t){const n=Yr(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(s=>e[s]?.file).filter(s=>!!s):[]}function Dm(e,t){const n=Yr(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const s=new Set([r]),o=[r],i=[];for(;o.length>0;)for(const a of e[o.shift()]??[])s.has(a)||(s.add(a),i.push(a),o.push(a));return i}var Pm=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function Rm(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&Pm.test(t[t.length-2])}async function km(e,t){const n=Rm(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 Nm(e){const t=new Map,n=(r,s)=>{const o=Am(r,e.canvasSrc,e.origin);if(!o)return;const i=t.get(o);if(i!==void 0)return i;const a=e.fetchBody(o,s);return t.set(o,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,s){for(const o of r)n(o,s)},reset(){t.clear()},get size(){return t.size}}}var Pe;function Lm(e){try{return Wr(new URL(e,window.location.href).href)}catch{return Wr(window.location.href)}}function Ra(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof __useblocks__<"u"&&__useblocks__?.preload?.canvasCrossOrigin===!0}var Mm=()=>Promise.resolve(void 0);function ka(){const e=Da(!1);if(!Lm(e)){if(!Pe||Pe.canvasSrc!==e){const t=Ra(e)?km:Mm;Pe={canvasSrc:e,store:Nm({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return Pe.store}}async function xm(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 s=await r.json();t(Om(s,e))}catch{}}function Kr(e){const t=ka();if(!t||!Pe||Pe.warmed||!Ra(Pe.canvasSrc))return;Pe.warmed=!0;const{canvasSrc:n}=Pe,r=Cm(n);r&&t.warm([r],e);const s={"js/iframe-eblock.js":["js/elMarkupHelper.CgToMPJX.js"],"js/iframe.js":["js/elMarkupHelper.CgToMPJX.js"],"js/darkreader.CyLMh7_H.js":[],"js/elMarkupHelper.CgToMPJX.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.CGEpDoct.js":[]};s?t.warm(Dm(s,n),e):xm(n,o=>t.warm(o,e))}function Fm(e){const t=ka();if(!t)return;Kr();const n=r=>{const s=r.data;if(!s||s.operationId!=="em:module-body"||!s.result)return;const o=r.source;o&&(o.postMessage({operationId:Tm,for:s.result},"*"),t.take(s.data?.url??"").then(i=>{o.postMessage({operationId:s.result,data:i??null},"*")}))};window.addEventListener("message",n),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{window.removeEventListener("message",n)})}var pt=/<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,Bm=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,mt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Na=/display:\s*none\s*!important/gi,jm="data-darkreader-",Um=/<(script|style)\b[\s\S]*?<\/\1\s*>|<[a-z][^\s<>]*(?:"[^"]*"|'[^']*'|[^<>"'])*?\sdata-darkreader-(?:"[^"]*"|'[^']*'|[^<>"'])*>/gi,$m=/\sdata-darkreader-[a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?/gi,Hm=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,Vm=/\s*height\s*:\s*100%\s*!important\s*;?/gi,Gm=/height\s*:\s*100%\s*!important/i,Wm=[".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 Ym(e){return Na.lastIndex=0,(e.match(Na)||[]).length}function La(e){const t=e.trim(),n=Ym(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=Wm.filter(s=>t.includes(s)).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 Km(e){mt.lastIndex=0;for(const t of e.matchAll(mt))if(La(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function qm(e){let t=!1;return mt.lastIndex=0,{html:e.replace(mt,n=>La(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function zm(e){return pt.lastIndex=0,pt.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Km(e)}function Xm(e){return e.toLowerCase().includes(jm)?e.replace(Um,(t,n)=>n?t:t.replace($m,"")):e}function Jm(e){const t=Xm(e);if(!zm(t))return{html:t,found:!1};let n=!1,r=t;pt.lastIndex=0,pt.test(r)&&(pt.lastIndex=0,r=r.replace(pt,""),n=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(r)||/\sdata-bis-config\s*=/.test(r))&&(r=r.replace(Bm,""),n=!0);const s=qm(r);return r=s.html,n=n||s.found,{html:r,found:n}}function Qm(e){return!e||!Gm.test(e)?e:(mt.lastIndex=0,e.replace(mt,t=>t.replace(Hm,(n,r,s,o)=>`${r}${s.replace(Vm,"")}${o}`)))}function Ma(e){const t=Jm(e.replaceAll(`\r
|
|
2107
|
+
`)}function $n(e){return{html:e.html,common_styles:e.common_styles,subject:e.subject,preheader:e.preheader}}function zt(e,t){return fs(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function Ag(e,t,n){const{latest:r}=e,s=Un(t.html,n);return!r||t.baseOpen||r.id===t.baseRevisionId||t.baseHtmls?.some(o=>Un(o,r.html))?s?{revision:null,phase:"normal"}:{revision:$n(t),phase:"timeout"}:s?{revision:zt(e),phase:"normal"}:Un(t.html,r.html)?{revision:$n(t),phase:"found"}:{revision:zt(e),phase:"normal"}}function Tg({emailId:e,readAutosave:t,revisionServiceEnabled:n,pendingKey:r,historyIsSynchronous:s=!1,readShownContent:o,onFacts:i,onLate:a,onError:c,pageLoadTs:l=Ig()}){const u=r??e;let f=null,h=!1,g=!1,p=0,_={emailId:e,historyLoaded:!1,isRecovering:!1},v=null;const A=new Promise(y=>{v=y}),C=y=>{_={..._,...y},i(_)};let P;const I=y=>{p+=1,C({applied:{phase:y,seq:p}})},S=()=>{f?.timer&&clearTimeout(f.timer),f=null},w=y=>{if(!g){if(v){const E=v;v=null,E(y),P=y.revision?y.phase:void 0;return}a(y)&&y.revision&&I(y.phase)}},D=()=>{if(!f||g)return;const y=f.phase==="fast",E=y?Eg:wg,L=y?yg:Sg;f.timer=setTimeout(()=>{const B=f;if(!(!B||g)){if(B.attempts+=1,R(),y&&B.attempts>=L){const{pending:W}=B;Ve(u),C({isRecovering:!1}),w({revision:$n(W),phase:"timeout"}),h=!0,B.phase="bg",B.attempts=0,D();return}if(!y&&B.attempts>=L){Ve(u),S(),C({isRecovering:!1}),h=!0;return}D()}},E),f.timer.unref?.()},T=y=>{f={phase:"fast",attempts:0,pending:y,timer:null},C({isRecovering:!0}),D()},k=y=>{if(g)return;if(C({historyLoaded:!0,latestRevisionAt:y.latestAt!==void 0&&Number.isFinite(y.latestAt)?y.latestAt:void 0}),n&&f){const B=zt(y,f.pending.sentAt);if(!B)return;const W=f.phase==="fast"?"found":"bg";Ve(u),S(),C({isRecovering:!1}),h=!0,w({revision:B,phase:W});return}if(h)return;const E=n?Ln(u):null,L=E&&(E.sentAt<l||!Un(E.html,o()))?E:null;if(L){if(s&&(L.baseRevisionId!==void 0||L.baseOpen)){Ve(u),h=!0,w(Ag(y,L,o()));return}const B=zt(y,L.sentAt);if(B){Ve(u),h=!0,w({revision:B,phase:"found"});return}if(s){if(Ve(u),h=!0,y.latestAt!==void 0&&y.latestAt>L.sentAt+5e3){w({revision:null,phase:"normal"});return}w({revision:$n(L),phase:"timeout"});return}T(L);return}h=!0,w({revision:zt(y),phase:"normal"})},x=y=>{g||(c?.(y),_.historyLoaded||(C({historyLoaded:!1,latestRevisionAt:void 0}),U()),!f&&w({revision:null,phase:"normal"}))},R=()=>t(e).then(k).catch(x);let M,F=!1;const U=()=>{F||f||g||(F=!0,M=setTimeout(()=>{M=void 0,!g&&!_.historyLoaded&&R()},bg))};return R(),{verdict:()=>A,confirmVerdict(y){const E=P;P=void 0,y&&E!==void 0&&!g&&I(E)},dispose(){g=!0,M!==void 0&&(clearTimeout(M),M=void 0),S()}}}function Cg({port:e,revisionServiceEnabled:t,pendingKey:n,historyIsSynchronous:r,emailId:s,wpId:o,readShownContent:i,onFacts:a}){let c=null;const l=Tg({emailId:s,readAutosave:u=>o?e.readAutosave(u,{wpId:o()}):e.readAutosave(u),revisionServiceEnabled:t,...n?{pendingKey:n}:{},...r?{historyIsSynchronous:r}:{},readShownContent:i,onFacts:a,onLate:({revision:u,phase:f})=>{const h=za(u);return c?.(h)??!1},onError:u=>{u instanceof Error&&u.message}});return{id:"recovery",load:()=>l.verdict().then(({revision:u})=>za(u)),loaded(u){l.confirmVerdict(u)},watch(u){return c=u,()=>{c=null,l.dispose()}}}}var Og=5e3,Dg=d.createIdentifier("plugin.knownRevisions");function bt(e){return e.getOrCreateInstance(Dg,()=>new Map)}function vs(e,t,n,r){const s=n?.get(t)??[],o=s.filter(i=>i!==r);return{...e.has(t)?{baseRevisionId:e.get(t)??null}:{},...s.length>ac?{baseOpen:!0}:o.length?{baseHtmls:o}:{}}}var Pg=d.createIdentifier("plugin.uncertainWrites"),ac=3;function Yt(e){return e.getOrCreateInstance(Pg,()=>new Map)}function Rg(e,t,n){const r=e.get(t)??[];r.includes(n)||r.length>ac||e.set(t,[...r,n])}function cc(e,t){ts(e,t)||!t.baseHtmls||ts(e,{...t,baseHtmls:void 0,baseOpen:!0})}function Hn(e,t,n,r=!1){const s=Ln(e);!n||s?.sentAt!==t||!(r||s.baseOpen||s.baseHtmls)||ts(e,{...s,baseRevisionId:n,baseHtmls:void 0,baseOpen:void 0})}function lc(e,t,n,r){(Ln(e)?.sentAt??Number.NEGATIVE_INFINITY)>n||cc(e,{sentAt:n,html:t.html??"",common_styles:t.common_styles??"",subject:t.subject,preheader:t.preheader,...r})}var kg=/(?:Z|[+-]\d{2}:?\d{2})$/i;function Ng(e,t){const n=e;if(n?.isAutosave!==!0)return!1;const r=n.modified??"",s=kg.test(r)?Date.parse(r):NaN;return!Number.isFinite(s)||s>=t-Og}function dc(e,t,{pendingKey:n=i=>i,knownRevisions:r=new Map,uncertainWrites:s,synchronousHistory:o=!1}={}){return{readRevisions:(i,a,c)=>t.readRevisions(i,a,c),readRevision:(i,a,c)=>t.readRevision?t.readRevision(i,a,c):Promise.resolve(null),readAutosave:(i,a)=>t.readAutosave(i,a),async saveAutosave(i,a,c){const l=n(i),u=Date.now();cc(l,{sentAt:u,html:a.html??"",common_styles:a.common_styles??"",subject:a.subject,preheader:a.preheader,...vs(r,l,s,a.html??"")});const f=await t.saveAutosave(i,a,c),h=f?.id;return Ng(f,u)?Hn(l,u,h):h&&o&&(f.isAutosave===!0?rs(l,u):Hn(l,u,h,!0)),await e.saveAutosave(i,a),f}}}function Lg(e,t,n){return{readEmail:r=>e.readEmail(r),createEmail:r=>e.createEmail(r),async updateEmail(r,s){const o=Date.now();n&&lc(r,s,o,vs(n.knownRevisions,r,n.uncertainWrites,s.html??""));const i=await t.updateEmail(r,s);return n&&Hn(r,o,n.knownRevisions.get(r)??void 0),await e.updateEmail(r,s),rs(r,o),i&&{...i,id:r}}}}var uc=Symbol.for("emailmaker.result");function fc(e){return Object.defineProperty(e,uc,{value:!0})}var ze=(e=>fc({ok:!0,value:e})),ie=((e,t="")=>fc({ok:!1,error:{code:e,message:t}}));function hc(e){return typeof e=="object"&&e!==null&&e[uc]===!0}var Ye=e=>({optional:!1,...e}),Gn={string:()=>Ye({kind:"string"}),number:()=>Ye({kind:"number"}),boolean:()=>Ye({kind:"boolean"}),enum:(...e)=>Ye({kind:"enum",values:e}),element:(...e)=>Ye({kind:"element",kinds:e}),array:e=>Ye({kind:"array",item:e}),object:e=>Ye({kind:"object",shape:e}),optional:e=>({...e,optional:!0})};function pc(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Vn(e,t,n){if(t===void 0)return e.optional?void 0:`"${n}" is required`;switch(e.kind){case"string":case"number":case"boolean":return typeof t===e.kind?void 0:`"${n}" must be a ${e.kind}`;case"enum":return e.values?.includes(t)?void 0:`"${n}" must be one of: ${e.values?.join(", ")}`;case"element":return t!==null&&(typeof t=="object"||typeof t=="string")?void 0:`"${n}" must be an element reference`;case"array":if(!Array.isArray(t))return`"${n}" must be an array`;for(let r=0;r<t.length;r+=1){const s=Vn(e.item,t[r],`${n}[${r}]`);if(s)return s}return;case"object":return pc(t)?mc(e.shape,t,n):`"${n}" must be an object`}}function mc(e,t,n){for(const[r,s]of Object.entries(e??{})){const o=Vn(s,t[r],n?`${n}.${r}`:r);if(o)return o}}function xg(e,t,n){return e?Vn(e,t,n):void 0}function Mg(e,t){if(!e)return;const n=e;return n.kind!=="object"?Vn(n,t,"arguments"):t!==void 0&&!pc(t)?"arguments must be an object":mc(n.shape,t??{},"")}function gc(e){const t=e?.["~standard"];return typeof t=="object"&&t!==null&&typeof t.validate=="function"}function Fg(e){return(e.path??[]).map(t=>String(typeof t=="object"?t.key:t)).join(".")}function _c(e,t){if(!gc(e)){const n=Mg(e,t);return n?{ok:!1,problem:n}:{ok:!0,value:t??{}}}try{const n=e["~standard"].validate(t??{});return n instanceof Promise?n.then(Ec,vc):Ec(n)}catch(n){return vc(n)}}function vc(e){return{ok:!1,problem:`the arguments check failed: ${e instanceof Error?e.message:String(e)}`}}function Ec(e){if(e.issues){const[t]=e.issues,n=t?Fg(t):"";return{ok:!1,problem:t?n?`"${n}": ${t.message}`:t.message:"arguments are invalid"}}return{ok:!0,value:e.value}}var bc="Element reference returned by element.getTree, element.get or the selection.";function Es(e){switch(e.kind){case"string":case"number":case"boolean":return{type:e.kind};case"enum":return{type:"string",enum:[...e.values??[]]};case"element":return e.kinds?.length?{type:"string",description:`${bc} Kinds: ${e.kinds.join(", ")}.`}:{type:"string",description:bc};case"array":return{type:"array",items:Es(e.item)};case"object":{const t=Object.entries(e.shape??{}),n=t.filter(([,r])=>!r.optional).map(([r])=>r);return{type:"object",properties:Object.fromEntries(t.map(([r,s])=>[r,Es(s)])),...n.length?{required:n}:{}}}}}var Bg={type:"object",properties:{}};function jg(e){if(!e)return Bg;if(!gc(e))return Es(e);const t=e["~standard"].jsonSchema;if(t&&typeof t.input=="function")return t.input({target:"draft-2020-12"});const n=e.toJSONSchema;if(typeof n=="function")return n.call(e);throw new Error(`The ${e["~standard"].vendor} schema cannot export JSON Schema; use a library version with Standard JSON Schema or Arg.object({...}).`)}function uD(e){}function we(e,t){try{t()}catch{}}var Ug=Symbol.for("emailmaker.platform.hostError"),Wn="The editor could not load the code of its commands. Trying again does not help: the user has to reload the page.";function Ae(e,t){return Object.defineProperty(ie(e,t),Ug,{value:!0})}function yc(e){const t=globalThis,n=Symbol.for(`emailmaker.platform.owner.${e}`);return t[n]??=Object.freeze({name:e})}var Xe=yc("core"),wc=yc("unknown"),Sc=Symbol.for("emailmaker.platform.builtInPlugin");function Ic(e){return Symbol.for(`emailmaker.platform.builtInKey.${e}`)}function bs(e){return Object.entries(e).forEach(([t,n])=>{typeof n=="function"&&(Object.defineProperty(n,Sc,{value:!0}),Object.defineProperty(n,Ic(t),{value:!0}))}),e}function Ac(e,t){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Ic(t))}function $g(e){return typeof e=="function"&&Object.prototype.hasOwnProperty.call(e,Sc)}function Tc(e){return $g(e.constructor)}var Hg=class{_owners=new WeakMap;_stack=[];_listeners=new Set;current(){return this._stack[this._stack.length-1]??wc}execute(e,t){const n=e===Xe?wc:e;this._stack.push(n);try{return t()}finally{this._leave(n)}}onUnload(e){return this._listeners.add(e),{dispose:()=>this._listeners.delete(e)}}handle(e){const{plugin:t}=e;if(t)switch(e.type){case"init:enter":case"afterInit:enter":Tc(t)||this._stack.push(this._ownerOf(t,e.name));break;case"init:leave":case"afterInit:leave":Tc(t)||this._leave(this._ownerOf(t,e.name));break;case"dispose:start":{const n=this._owners.get(t);n&&(this._leave(n),this._owners.delete(t),Array.from(this._listeners).forEach(r=>r(n)));break}}}_ownerOf(e,t){let n=this._owners.get(e);return n||(n={name:t},this._owners.set(e,n)),n}_leave(e){const t=this._stack.lastIndexOf(e);t>=0&&this._stack.splice(t,1)}};function Kn(e){const t={watch:e,select:n=>Kn(r=>{let s=!1,o;return t.watch(i=>{const a=n(i);s&&Object.is(o,a)||(s=!0,o=a,r(a))})})};return t}function Gg(e){return Kn(t=>(t(e),{dispose:()=>{}}))}function Vg(e,t){return Kn(n=>{let r=!1,s=!1,o;const i=()=>{if(!r)return;const c=t();s&&Object.is(o,c)||(s=!0,o=c,n(c))},a=e.map(c=>c.watch(i));return r=!0,i(),{dispose:()=>a.forEach(c=>c.dispose())}})}function Se(e){let t;return e.watch(n=>{t=n}).dispose(),t}function yt(e,t,n){return new Promise((r,s)=>{const o=()=>r(void 0),i=setTimeout(o,t),a=()=>{clearTimeout(i),n?.removeEventListener("abort",o)};n?.aborted&&o(),n?.addEventListener("abort",o,{once:!0}),Promise.resolve().then(e).then(c=>{a(),r(c)},c=>{a(),s(c)})})}function ue(e,t){return{ok:!1,error:{code:e,message:t}}}function Xt(e){return ue("documentChanged",`"${e}" was not run: another email is open now, not the one this work started on. Stop and tell the user; do not repeat the call.`)}function Wg(e){return ue("aborted",`"${e}" was not run: this tool became another command while the user was asked. Read the tools again and ask the user anew with a new call.`)}function Kg(e,t){return ue("invalidArgs",`Call ${e} ("${t}") needs the user's consent, so its input cannot hold a "$result" reference: the consent window has to show the data. Run the earlier calls first, then send this call in a separate batch with the value written out. No call ran.`)}var Jt=e=>ue("aborted",`The call of "${e}" was cancelled.`),qn=e=>e instanceof Error?e.message:String(e);function qg(){return Object.assign(new Error(Wn),{code:"unavailable"})}function zg(){return{code:"undoConflict",message:"An agent call is still running; undo the answer when it ends."}}var Yg=64,Xg=/[\w-]+(?:\.[\w-]+)+/g;function wt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"_").slice(0,Yg)}function zn(e,t){return(e??[]).some(n=>n.endsWith(".*")?t.startsWith(n.slice(0,-1)):n===t)}function Cc(e,t){const n=new Map(t.map(([r,s])=>[s.id,r]));return e.replace(Xg,r=>n.get(r)??r)}var Jg=3e3,Qg=12,Zg=e=>typeof e?.label=="string"&&typeof e.value=="string";function e_(e){const{title:t,details:n}=e??{};if(typeof t!="string"||!t)return;const r=(Array.isArray(n)?n:[]).filter(Zg).slice(0,Qg);return r.length?{title:t,details:r.map(({label:s,value:o})=>({label:s,value:o}))}:{title:t}}async function t_(e,t,n,r){const s=t.agent?.consent;if(s)try{return e_(await yt(()=>e.asOwner(t.id,()=>s(n,r)),Jg))}catch(o){`${t.id}${qn(o)}`;return}}function n_(e,t,n,r,s){return{tool:e,command:t.id,title:t.title,description:t.description&&Cc(t.description,s()),input:n,...r?{consent:r}:{},...t.owner===Xe?{}:{fromPlugin:!0}}}async function r_({lifetime:e,ask:t,tool:n,signal:r,question:s}){if(r?.aborted||e.aborted)return Jt(n);if(!t)return ue("forbidden",`The tool "${n}" needs the user's consent, and there is no one to ask in this editor.`);const o=new AbortController,i=()=>o.abort();r?.addEventListener("abort",i,{once:!0}),e.addEventListener("abort",i,{once:!0});const a=new Promise(l=>{o.signal.addEventListener("abort",()=>l(!1),{once:!0})}),c=async()=>{const l=await s(o.signal);return o.signal.aborted?!1:t({...l,signal:o.signal})};try{const l=await Promise.race([c(),a]);return o.signal.aborted?Jt(n):l===!0?void 0:Ae("declined",`The user declined "${n}". Do not repeat the call unless the user asks for it again.`)}catch(l){const u=qn(l);return`${n}${u}`,ue("aborted",`The user was not asked about "${n}": ${u}`)}finally{r?.removeEventListener("abort",i),e.removeEventListener("abort",i),o.abort()}}var ys=Symbol("bad input");function Oc(e){try{return JSON.stringify(e)}catch{return ys}}var St=e=>e===void 0?void 0:JSON.parse(e);function Dc(e){if(e===void 0)return null;try{return JSON.parse(JSON.stringify(e))}catch{return"[a value that cannot be serialized]"}}var It="agent.batch",s_=5e3,o_=5e3,i_=20,a_=new Set(["ui.openView","ui.closeView",It]),c_=class{_deps;_confirmHost;_bound;_turnDepth=0;_turnStart;_lastTurn;constructor(e){this._deps=e}setConfirmHost(e){return this._confirmHost=e,{dispose:()=>{this._confirmHost===e&&(this._confirmHost=void 0)}}}get _config(){return Se(this._deps.config)??{}}get enabled(){return this._config.enabled!==!1}async tools(){const e=await this._describedOpened();return e.map(([t,n])=>({name:t,description:Cc(n.description??n.title,e),inputSchema:n.inputSchema??{type:"object",properties:{}},...this._needsConfirm(n)?{confirm:!0}:{}}))}invoke(e,t,n={}){return this._call(e,t,n)}async openBatch(e,t){const n=this._deps.commands.info(It),r=n!==void 0&&this._needsConfirm(n),s=this._openDocument(),o=new Map,i=new Map;for(const[a,c]of e.entries()){const l=this._find(c.tool);if(!l)continue;const[u,f]=l,h=r||this._needsConfirm(f);if(!h&&!f.agent?.precheck)continue;if(c.deferred){if(h)return{ok:!1,error:Kg(a,u).error,index:a};continue}const g=Oc(c.input);if(g===ys)continue;const p=await this._checkInput(f,St(g),t);if(!p||p.ok===!1||!this._deps.commands.availableNow(f.id))continue;const _=await this._precheck(u,f,p.value,t);if(_)return{ok:!1,error:_.error,index:a};o.set(a,f),h&&i.set(a,{tool:u,info:f,input:p.value,frozen:g})}if(n&&i.size>0){const a=Dc(e.map(({tool:l,input:u})=>({tool:l,args:u}))),c=await this._ask(wt(It),t,async l=>{const u=Array.from(i.values()),f=await Promise.all(u.slice(0,i_).map(async({tool:g,info:p,input:_,frozen:v})=>this._item(g,p,St(v),await this._consentOf(p,_,l)))),h=await this._consentOf(n,void 0,l);return{...this._item(wt(It),n,{calls:a},h),batch:{items:f,more:u.length-f.length}}});if(c)return{ok:!1,error:{...c.error,message:`${c.error.message} None of the calls of the batch ran.`}};if(this._openDocument()!==s)return{ok:!1,error:Xt(wt(It)).error}}return{ok:!0,run:(a,c)=>{const l=i.get(a);return this._call(e[a].tool,l?St(l.frozen):c,{signal:t},{consented:l?.info,prechecked:o.get(a),askAll:r})}}}async _call(e,t,n,r={}){if(!this.enabled)return ue("forbidden","The agent is switched off in this editor.");const s=this._find(e);if(!s)return this._deps.commands.info(e)??(Se(this._deps.commands.commands)??[]).find(p=>wt(p.id)===e)?ue("forbidden",`The tool "${e}" is not opened to the agent here.`):ue("notInstalled",`There is no tool "${e}" in this editor.`);const[o,i]=s,a=Oc(t);if(a===ys)return ue("invalidArgs",`Tool "${o}": the input must be plain JSON data.`);const c=await this._checkInput(i,St(a),n.signal);if(!c)return n.signal?.aborted?Jt(o):ue("unavailable",this._deps.commands.undescribed(i.id)?Wn:`The input of the tool "${o}" could not be checked; try again.`);if(c.ok===!1)return ue("invalidArgs",`Tool "${o}": ${c.problem}.`);const l=this._openDocument();if(this._adoptOpened(l),this._bound&&this._bound.document!==l)return Xt(o);if(!this._deps.commands.availableNow(i.id))return ue("unavailable",`The tool "${o}" is not available right now.`);if(r.prechecked!==i&&i.agent?.precheck){const p=await this._precheck(o,i,c.value,n.signal);if(p)return p;if(this._openDocument()!==l)return Xt(o)}let u=r.consented;if(!u&&(r.askAll||this._needsConfirm(i))&&!(i.id===It&&i.owner===Xe)){const p=await this._ask(o,n.signal,async _=>this._item(o,i,St(a),await this._consentOf(i,c.value,_)));if(p)return p;if(this._openDocument()!==l)return Xt(o);u=i}const f=this._deps.commands.prepared(i.id,n.signal);if(f!==!0){if(!await f)return n.signal?.aborted?Jt(o):ue("unavailable",Wn);const p=this._openDocument();if(this._adoptOpened(p),l!==void 0&&p!==l)return Xt(o)}if(this._find(o)?.[1]!==(u??i))return Wg(o);const h=()=>this._deps.commands.run(i.id,St(a),{caller:"agent",signal:n.signal}),g=await(a_.has(i.id)||i.agent?.readOnly?h():this._deps.history.group(h));return g.ok===!1?ue(g.error.code,g.error.message||`The tool "${o}" failed: ${g.error.code}.`):{ok:!0,value:Dc(g.value)}}readOnlyTool(e){return this._find(e)?.[1].agent?.readOnly===!0}get answerOpen(){return this._bound!==void 0}async holdDocument(e){const t=this._bound??={document:this._openDocument(),holders:0};t.holders+=1;try{return await e()}finally{t.holders-=1,t.holders===0&&(this._bound=void 0)}}_adoptOpened(e){this._bound&&this._bound.document===void 0&&e!==void 0&&(this._bound.document=e,this._deps.history.reopen(),this._turnDepth>0&&(this._turnStart=this._deps.history.answers?.capture()))}async turn(e){this._turnDepth===0&&(this._turnStart=this._deps.history.answers?.capture()),this._turnDepth+=1;try{return await this.holdDocument(()=>this._deps.history.group(e))}finally{this._turnDepth-=1,this._turnDepth===0&&(this._lastTurn={start:this._turnStart,end:this._deps.history.answers?.capture()})}}async undoTurn(){if(!this.enabled)return ue("forbidden","The agent is switched off in this editor.");const e=this._deps.history.answers,t=e?.undoRefusal();if(t)return{ok:!1,error:t};const n=this._lastTurn;if(!e||!n)return ue("nothingToUndo","There is no answer to undo.");this._lastTurn=void 0;try{const r=await e.settle()??(this._deps.history.grouping?zg():e.undo(n.start,n.end));return r?(this._lastTurn??=n,{ok:!1,error:r}):{ok:!0,value:null}}catch(r){this._lastTurn??=n;const s=qn(r);return`${s}`,ue("undoConflict",`The answer could not be undone: ${s}`)}}_needsConfirm(e){const{confirm:t}=this._config;return e.agent?.confirm===!0||zn(t,e.id)||zn(t,wt(e.id))}_openDocument(){return this._deps.history.answers?.document()}_find(e){return this._opened().find(([t,n])=>t===e||n.id===e)}_opened(){if(!this.enabled)return[];const e=this._config.deny,t=new Map;for(const n of Se(this._deps.commands.commands)??[]){const r=wt(n.id);if(!n.agent||zn(e,n.id)||zn(e,r))continue;const s=t.get(r);if(s){`${s.id}${n.id}${r}`;continue}t.set(r,n)}return Array.from(t.entries())}async _describedOpened(){const{commands:e}=this._deps;let t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id));for(;n.length>0;){if((await Promise.all(n.map(([,r])=>e.described(r.id)))).includes(!1))throw qg();t=this._opened(),n=t.filter(([,r])=>e.undescribed(r.id))}return t}async _checkInput(e,t,n){const{commands:r}=this._deps;if(r.undescribed(e.id)&&!await r.described(e.id,n))return;const s=_c(this._deps.commands.declarationArgs(e.id),t);return s instanceof Promise?yt(()=>s,o_,n):s}async _precheck(e,t,n,r){const s=t.agent?.precheck;if(s){try{const o=await yt(()=>this._deps.commands.asOwner(t.id,()=>s(n)),s_,r);if(hc(o)&&o.ok===!1){const{code:i,message:a}=o.error;return ue(i,a||`The tool "${e}" was refused: ${i}.`)}}catch(o){`${t.id}${qn(o)}`}return r?.aborted?Jt(e):void 0}}_consentOf(e,t,n){return t_(this._deps.commands,e,t,n)}_item(e,t,n,r){return n_(e,t,n,r,()=>this._opened())}_ask(e,t,n){const r=this._config.onConfirm??(Se(this._deps.facts)?.headless?void 0:this._confirmHost);return r_({lifetime:this._deps.commands.lifetime,ask:r,tool:e,signal:t,question:n})}},l_={documentOpen:!1,selection:"none",codeMode:!1,readOnly:!1,headless:!1};function Qt(e,t){if(!e)return!0;if("any"in e)return e.any.some(r=>Qt(r,t));if("not"in e)return!Qt(e.not,t);const n={...l_,...t};return Object.entries(e).every(([r,s])=>n[r]===s)}var d_=5e3,Pc=3e4;function Rc(e){const{agent:t}=e;if(!t)return;if(t===!0)return{};const{readOnly:n,consent:r,precheck:s}=t;return{confirm:t.confirm===!0,...n===!0?{readOnly:!0}:{},...typeof r=="function"?{consent:r}:{},...typeof s=="function"?{precheck:s}:{}}}function kc(e,t,n){if(Rc(n))try{return jg(n.args)}catch(r){throw new Error(`Command "${e}" of "${t.name}" is opened to the agent, but its arguments cannot be described for the model: `+(r instanceof Error?r.message:String(r)))}}function u_(e,t,{agent:n,description:r}){n&&!(typeof r=="string"&&r.trim())&&(`${e}${t.name}`,void 0)}var f_=class{_facts;_owners;_entries=new Map;_list=se([]);_disposed=!1;_lifetime=new AbortController;constructor(e,t){this._facts=e,this._owners=t}get commands(){return this._list}has(e){return this._entries.has(e)}register(e,t,n,r={},s={}){if(this._disposed)return`${e.name}`,{dispose:()=>{}};const o=Object.keys(t);for(const l of o){const u=this._entries.get(l);if(u&&!u.yieldable)throw new Error(`Command "${l}" is already registered by "${u.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(typeof n[l]!="function")throw new Error(`Command "${l}" of "${e.name}" has no handler.`)}const i=new Map(o.map(l=>[l,s.details?void 0:kc(l,e,t[l])]));s.details||o.forEach(l=>u_(l,e,t[l]));const a=o.map(l=>({id:l,owner:e,declaration:t[l],handler:n[l],enabled:r[l]??Gg(!0),pending:new Set,agent:Rc(t[l]),inputSchema:i.get(l),yieldable:s.yieldable===!0,details:s.details,prepare:s.prepare}));this._detach(o.flatMap(l=>this._entries.get(l)??[])),a.forEach(l=>this._entries.set(l.id,l)),this._publish();let c=!1;return{dispose:()=>{c||(c=!0,this._remove(a))}}}disposeOwner(e){this._remove(Array.from(this._entries.values()).filter(t=>t.owner===e))}disposeAll(){this._disposed=!0,this._remove(Array.from(this._entries.values())),this._lifetime.abort()}get disposed(){return this._disposed}get lifetime(){return this._lifetime.signal}async run(e,t,n){if(this._disposed)return Ae("unavailable",`Command "${e}" is not available: the editor was destroyed.`);const r=this._entries.get(e);if(!r)return Ae("notInstalled",`Command "${e}" is not installed in this host.`);if(n.caller==="agent"&&!r.agent)return Ae("forbidden",`Command "${e}" is not opened to the agent.`);if(!Qt(r.declaration.when,Se(this._facts)??{})||Se(r.enabled)===!1)return Ae("unavailable",`Command "${e}" is not available right now.`);const s=n.signal,o=n.nested&&s?.aborted;if(r.details&&!await this._describe(r,o?void 0:s))return s?.aborted&&!o?ie("aborted",`Command "${e}" was cancelled.`):Ae("unavailable",Wn);const i=_c(r.declaration.args,t),a=i instanceof Promise?await yt(()=>i,d_,o?void 0:s):i;if(!a)return s?.aborted?ie("aborted",`Command "${e}" was cancelled.`):Ae("unavailable",`Command "${e}": the check of its arguments did not answer in time.`);if(a.ok===!1)return Ae("invalidArgs",`Command "${e}": ${a.problem}.`);if(this._disposed||this._entries.get(e)!==r)return Ae("unavailable",`Command "${e}" was removed while its arguments were checked.`);const c=new AbortController,l=new Promise(h=>{c.signal.addEventListener("abort",()=>h(ie("aborted",`Command "${e}" was cancelled.`)),{once:!0})});if(s?.aborted&&!o)return ie("aborted",`Command "${e}" was cancelled before it started.`);const u=()=>c.abort();s?.addEventListener("abort",u,{once:!0}),r.pending.add(c);const f={signal:c.signal,caller:n.caller,run:(h,g)=>this.run(h,g,{caller:"plugin",signal:c.signal,nested:!0})};try{return await Promise.race([this._execute(r,a.value,f),l])}finally{s?.removeEventListener("abort",u),r.pending.delete(c)}}visible(e){return Vg([this._list,this._facts],()=>{const t=this._entries.get(e);return t!==void 0&&Qt(t.declaration.when,Se(this._facts)??{})})}enabled(e){return Kn(t=>{let n,r;const s=i=>{i!==r&&(r=i,t(i))},o=this._list.watch(()=>{n?.dispose();const i=this._entries.get(e);n=i?i.enabled.watch(s):void 0,i||s(!1)});return{dispose:()=>{o.dispose(),n?.dispose()}}})}declarationArgs(e){return this._entries.get(e)?.declaration.args}undescribed(e){return this._entries.get(e)?.details!==void 0}async described(e,t){const n=this._entries.get(e);return n?.details?this._describe(n,t):!0}prepared(e,t){const n=this._entries.get(e);return n?.prepare?this._prepare(n,n.prepare,t):!0}async _prepare(e,t,n){const r=new AbortController,s=()=>r.abort();n?.aborted&&s(),n?.addEventListener("abort",s,{once:!0}),e.pending.add(r);try{return await yt(()=>t().then(()=>!0),Pc,r.signal)===!0}catch{return!1}finally{n?.removeEventListener("abort",s),e.pending.delete(r)}}availableNow(e){const t=this._entries.get(e);return!this._disposed&&t!==void 0&&Qt(t.declaration.when,Se(this._facts)??{})&&Se(t.enabled)!==!1}info(e){const t=this._entries.get(e);return t&&Nc(t)}asOwner(e,t){const n=this._entries.get(e);return n&&this._owners?this._owners.execute(n.owner,t):t()}_describe(e,t){return yt(()=>{const{details:r}=e;return r&&(e.detailsLoading??=this._loadDetails(e,r))},Pc,t).then(()=>e.details===void 0,()=>!1)}async _loadDetails(e,t){try{const n=await t(),r={...e.declaration,...n[e.id]};e.inputSchema=kc(e.id,e.owner,r),e.declaration=r,e.details=void 0}finally{e.detailsLoading=void 0}}async _execute(e,t,n){try{const r=e.handler,s=()=>r(t,n),o=await(this._owners?this._owners.execute(e.owner,s):s());return hc(o)?o:ze(o)}catch(r){return ie("internal",r instanceof Error?r.message:String(r))}}_remove(e){this._detach(e)&&this._publish()}_detach(e){let t=!1;for(const n of e)this._entries.get(n.id)===n&&(this._entries.delete(n.id),t=!0),n.pending.forEach(r=>r.abort());return t}_publish(){this._list.set(Array.from(this._entries.values()).map(Nc))}};function Nc(e){const{title:t,icon:n}=e.declaration;return e.info??={id:e.id,owner:e.owner,title:t,get description(){return e.declaration.description},icon:n,agent:e.agent,get inputSchema(){return e.inputSchema}}}var Lc=5e3,xc=Symbol("timedOut"),h_=class{_willSave=[];_changes=[];_selection=se(null);get selection(){return this._selection}onWillSave(e,t){return this._add(this._willSave,{owner:e,handler:t})}onDidChange(e,t){return this._add(this._changes,{owner:e,handler:t})}async runWillSave(e){for(const{owner:t,handler:n}of this._willSave.slice()){const r=new AbortController;let s;const o=new Promise(i=>{s=setTimeout(()=>i(xc),Lc)});try{const i=await Promise.race([Promise.resolve().then(()=>n({...e,signal:r.signal})),o]);if(i===xc){`${t.name}${Lc}`;continue}if(i&&typeof i=="object"&&typeof i.refuse=="string")return{owner:t.name,message:i.refuse}}catch(i){`${t.name}${i instanceof Error?i.message:String(i)}`}finally{clearTimeout(s),r.abort()}}}emitChange(e){for(const{owner:t,handler:n}of this._changes.slice())try{n(e)}catch(r){`${t.name}${r instanceof Error?r.message:String(r)}`}}disposeOwner(e){for(const t of[this._willSave,this._changes])for(let n=t.length-1;n>=0;n-=1)t[n].owner===e&&t.splice(n,1)}_add(e,t){return e.push(t),{dispose:()=>{const n=e.indexOf(t);n>=0&&e.splice(n,1)}}}},p_=Symbol.for("emailmaker.domView");function m_(e){return typeof e=="function"||typeof e=="object"&&e!==null&&typeof e.$$typeof=="symbol"}function g_(e){return typeof e=="object"&&e!==null&&typeof e[p_]=="function"}var Zt=["plugins"],__={toolbar:{kind:"item",groups:["view","collaboration","document","plugins","primary"]},"menu:document":{kind:"item",groups:["document","plugins","access","danger"]},"menu:export":{kind:"item",groups:["formats","plugins","platforms"]},"menu:view":{kind:"item",groups:["preview","plugins","share"]},"menu:save":{kind:"item",groups:Zt},statusBar:{kind:"item",groups:["selection","document","plugins","collaboration"]},notices:{kind:"item",groups:Zt},sidebar:{kind:"view",groups:["content","collaboration","analysis","plugins","settings"]},dialog:{kind:"view",groups:Zt},documentSettings:{kind:"view",groups:Zt},inspector:{kind:"view",groups:Zt}},ws="plugins";function v_(e,t){const n=e.groups.indexOf(t);return n<0?e.groups.length:n}var fD="1.0",E_=Symbol.for("emailmaker.viewHost"),Ss={dispose:()=>{}},b_=class{_deps;apiVersion="1.0";_locations=new Map(Object.entries(__));_items=se([]);_views=se([]);_opened=se([]);_viewById=new Map;_seq=0;_openedKey=0;_disposed=!1;constructor(e){this._deps=e,this._registerCoreCommands()}get opened(){return this._opened}registerLocation(e,t){if(this._locations.has(e))throw new Error(`Location "${e}" is already registered.`);return this._locations.set(e,t),{dispose:()=>{this._locations.get(e)===t&&this._locations.delete(e)}}}addItem(e,t){if(this._skipAfterDispose(e))return Ss;const n=this._itemLocation(t.location,"item",e);if(!n)return Ss;const r={seq:this._nextSeq(),owner:e,location:t.location,group:this._groupOf(n,t.group,t.location),order:t.order??0,item:t};return this._items.set([...this._items.get()??[],r]),{dispose:()=>this._removeItems(s=>s===r)}}addViews(e,t,n,r){if(this._skipAfterDispose(e))return Ss;const s=Object.keys(t);for(const i of s){const a=this._viewById.get(i);if(a)throw new Error(`View "${i}" is already registered by "${a.owner.name}"; "${e.name}" cannot register it again. Choose a unique id with your plugin namespace, and make sure the plugin is not loaded twice.`);if(!m_(n[i])&&!g_(n[i]))throw new Error(`View "${i}" of "${e.name}" has no component; pass a React component or domView(renderer).`)}const o=[];for(const i of s){const a=t[i],c=this._itemLocation(a.location,"view",e);if(c){const l=this._groupOf(c,a.group,a.location);o.push({seq:this._nextSeq(),id:i,owner:e,location:a.location,group:l,order:a.order??0,declaration:a,renderer:n[i],editor:r})}}return o.forEach(i=>this._viewById.set(i.id,i)),this._views.set([...this._views.get()??[],...o]),{dispose:()=>this._removeViews(i=>o.includes(i))}}open(e,t){if(this._disposed)return Promise.resolve(ie("cancelled",`View "${e}" cannot open: the editor was destroyed.`));if(Se(this._deps.facts)?.headless)return Promise.resolve(Ae("unavailable",`View "${e}" cannot open: the editor has no interface.`));const n=this._viewById.get(e);if(!n)return Promise.resolve(Ae("notInstalled",`View "${e}" is not installed in this host.`));const r=xg(n.declaration.input,t,"input");if(r)return Promise.resolve(Ae("invalidArgs",`View "${e}": ${r}.`));const s=n.location==="inspector"?this._inspectedElement():void 0;return n.location==="inspector"&&!s?Promise.resolve(Ae("unavailable",`View "${e}" cannot open: no element is selected.`)):(this.close(e),new Promise(o=>{const i=new AbortController;let a=!1;const c=h=>{if(!a){a=!0;try{this._opened.set((this._opened.get()??[]).filter(g=>g!==f))}finally{s?.dispose(),i.abort(),o(h)}}},l=h=>c(ze(h)),u={input:t,signal:i.signal,close:l};s&&Object.defineProperty(u,"element",{value:s.element,enumerable:!0}),Object.defineProperty(u,E_,{value:this._viewHost(n)});const f={key:this._openedKey+=1,view:e,owner:n.owner,location:n.location,input:t,record:n,renderer:n.renderer,signal:i.signal,context:u,close:l,cancel:()=>c(ie("cancelled",`View "${e}" was closed without a result.`))};this._opened.set([...this._opened.get()??[],f])}))}_inspectedElement(){const e=this._deps.selection,t=e?Se(e):void 0;if(!e||t==null)return;const n=se(t),r=e.watch(s=>{s!=null&&n.set(s)});return{element:n,dispose:()=>r.dispose()}}viewLocation(e){return this._viewById.get(e)?.location}close(e){(this._opened.get()??[]).filter(t=>t.view===e).forEach(t=>t.cancel())}items(e){return this._items.select(t=>this._sorted(t,e))}get allViews(){return this._views}views(e){return this._views.select(t=>this._sorted(t,e))}disposeOwner(e){we("items",()=>this._removeItems(t=>t.owner===e)),we("views",()=>this._removeViews(t=>t.owner===e))}disposeAll(){this._disposed=!0,we("items",()=>this._removeItems(()=>!0)),we("views",()=>this._removeViews(()=>!0))}supports(e,t){switch(e){case"service":return t==="Commands"||t==="Ui"||t==="Agent"||t==="Document";case"location":return this._locations.has(t);case"command":return this._deps.commands.has(t);case"view":return this._viewById.has(t)}}_sorted(e,t){const n=this._locations.get(t),r=s=>n?v_(n,s.group):0;return e.filter(s=>s.location===t).sort((s,o)=>r(s)-r(o)||s.order-o.order||s.seq-o.seq)}_itemLocation(e,t,n){const r=this._locations.get(e);if(!r)`${n.name}${e}`;else if(r.kind!==t){`${n.name}`,`${e}${r.kind}`;return}return r}_groupOf(e,t,n){return t===void 0?ws:e.groups.includes(t)?t:(`${n}${t}${ws}`,ws)}_nextSeq(){return this._seq+=1,this._seq}_removeItems(e){const t=this._items.get()??[];t.some(e)&&this._items.set(t.filter(n=>!e(n)))}_removeViews(e){const t=this._views.get()??[],n=t.filter(e);if(n.length!==0){n.forEach(r=>this._viewById.delete(r.id));try{this._views.set(t.filter(r=>!e(r)))}finally{(this._opened.get()??[]).filter(r=>n.includes(r.record)).forEach(r=>we(`close ${r.view}`,()=>r.cancel()))}}}_skipAfterDispose(e){return this._disposed&&(`${e.name}`,void 0),this._disposed}_viewHost(e){return{run:(t,n)=>this._deps.commands.run(t,n,{caller:"ui"}),editor:e.editor}}_registerCoreCommands(){this._deps.commands.register(Xe,{"ui.openView":{title:"Open view",description:"Opens a plugin view by id and waits for its output; a dialog resolves when the user closes it.",args:Gn.object({view:Gn.string()}),agent:!0},"ui.closeView":{title:"Close view",description:"Closes an open view by id.",args:Gn.object({view:Gn.string()}),agent:!0}},{"ui.openView":e=>this.open(e.view,e.input),"ui.closeView":e=>(this.close(e.view),ze())})}};function y_(){return se({})}function en(e,t){const n=e.get()??{};Object.keys(t).some(r=>n[r]!==t[r])&&e.set({...n,...t})}var w_=class{_depth=0;_host;_open;connect(e){return this._host=e,{dispose:()=>{this._host===e&&(this._host=void 0)}}}get grouping(){return this._depth>0}get answers(){return this._host?.answers}async group(e){this._enter();try{return await e()}finally{this._leave()}}reopen(){this._depth>0&&this._open?.begin()}_enter(){this._depth+=1,this._depth===1&&(this._open=this._host,this._open?.begin())}_leave(){if(this._depth-=1,this._depth===0){const e=this._open;this._open=void 0,e?.end()}}},S_=d.createIdentifier("platform.ownerTracker"),I_=d.createIdentifier("platform.whenFacts"),A_=d.createIdentifier("platform.commandRegistry"),T_=d.createIdentifier("platform.uiService"),C_=d.createIdentifier("platform.editHistory"),O_=d.createIdentifier("platform.agentConfig"),D_=d.createIdentifier("platform.agentService"),P_=d.createIdentifier("platform.documentEvents");function Je(e){return e.getOrCreateInstance(S_,()=>{const t=new Hg;return t.onUnload(n=>{we("commands",()=>ke(e).disposeOwner(n)),we("ui",()=>Yn(e).disposeOwner(n)),we("document",()=>je(e).disposeOwner(n))}),t})}function At(e){return e.getOrCreateInstance(I_,y_)}function Is(e){return e.getOrCreateInstance(C_,()=>new w_)}function R_(e){const{isDisposed:t}=e;return typeof t=="function"&&t.call(e)}function Mc(e){return e.getOrCreateInstance(A_,()=>new f_(At(e),Je(e)))}function k_(e){return e.getOrCreateInstance(T_,()=>(Je(e),new b_({commands:Mc(e),facts:At(e),selection:je(e).selection})))}function Fc(e){const t=Mc(e),n=k_(e);return!t.disposed&&R_(e)&&(we("ui",()=>n.disposeAll()),we("commands",()=>t.disposeAll())),{registry:t,ui:n}}function ke(e){return Fc(e).registry}function Yn(e){return Fc(e).ui}function Bc(e){return e.getOrCreateInstance(O_,()=>se({}))}function Xn(e){return e.getOrCreateInstance(D_,()=>new c_({commands:ke(e),history:Is(e),config:Bc(e),facts:At(e)}))}function je(e){return e.getOrCreateInstance(P_,()=>new h_)}function N_(e){return async(t,n)=>{const r=Q(n)?"block":"email";return(await je(e).runWillSave({kind:r,id:t.id==null?null:String(t.id),content:t.html??""}))?.message}}var jc=d.createIdentifier("CurrentUser"),Uc={};function As(e){return e.getOrCreateInstance(jc,()=>se(Uc))}function $c(e){return e?.getInstance(jc)?.get()??Uc}var Hc=d.createIdentifier("HeadlessMode");function Ts(e){return e.getOrCreateInstance(Hc,()=>se(!1))}function L_(e){return e?.getInstance(Hc)?.get()??!1}var x_=d.createIdentifier("HiddenMount");function M_(e){return e.getOrCreateInstance(x_,()=>se(!1))}function F_(e){if(!e)return!1;try{return!!d.decodeJwt(e).data?.act_as}catch{return!1}}function B_(e){return F_(e?.getInstance(hi)?.get(Ip.em_token))}var j_="SAVE_BUTTON",U_="AUTOSAVE",$_=Symbol.for("emailmaker.saveNotified"),H_=d.createIdentifier("helpers.saveListeners");function G_(e,t="email"){return(e.getInstance(H_)?.[t]??0)>0}function Gc(e){return e?.getInstance(d.CONFIG_SOURCE_ID)?.get()??{}}function Jn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function V_(e,t){return t.modeDefaults(Jn(e,t.fallbackMode))}function Vc(e,t){const n=Jn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Wc(e,t){const n=Jn(e,t),r=e.user?.advancedConfigs?.[n],s=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...s}}function W_(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function K_(e){return Th(e.map(t=>t?.resourceProxy))}function q_(e){return Rh(e.map(t=>t?.resourceProxyPolicy))}function z_(e){return Ch(e.map(t=>t?.backendProxy))}function Y_(e){return Gr(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function X_(e,t){return[e.base,V_(e,t),e.profile,e.serverSide,Vc(e,t.fallbackMode),e.local,e.user,Wc(e,t.fallbackMode)]}function Cs(e,t){const n=X_(e,t),r=Gr(n),s=W_(n);s!==void 0&&(r.fileManager=s);const o=K_(n);o!==void 0&&(r.resourceProxy=o);const i=q_(n);i&&Object.keys(i).length>0&&(r.resourceProxyPolicy=i);const a=z_(n);a!==void 0&&(r.backendProxy=a);const c=Y_(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function J_(e,t,n){const r=Vc(e,n),s=Wc(e,n);return Sh([s,e.user,r,e.serverSide],t)}var Q_=1.5;function Z_(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<=Q_*e.autosaveTimeoutMs?"none":"revision"}var hD=5,pD=3,ev=1e4;function tv(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:s}=e,o=e.readFailures??(()=>0),i=e.readFailureRetryable??(()=>!0);let a;const c=k=>a!==void 0&&a.version===k.get().version?o()-a.failuresAtStart:0,l=k=>{const x=c(k);if(x<=0)return!1;const R=n().retryMaxAttempts??5;return!i()||x>R},u=()=>{const{autosaveTimeoutMs:k,retryIntervalMs:x}=n(),R=t();return R!==void 0&&c(R)>0&&x!==void 0&&x>0?x:R?.isNew()?ev:k},f=k=>k.isNew()&&o()>=3,h=()=>{const k=t();if(!k||k.isDisposed()||l(k))return"none";const{latestRevisionAt:x,snapshotVersion:R,...M}=n(),F=Date.now(),U=Z_({...M,isDirty:k.isDirty(),isNew:k.isNew(),isReady:k.isReady(),latestRevisionAgeMs:x!=null&&x<=F?F-x:void 0,isSnapshotSent:R!=null&&R===k.get().version});return U==="create"&&f(k)?"none":U},g=()=>{const k=t();if(!k||k.isDisposed()||f(k)||l(k)||n().isHeadless)return!1;if(!k.isDirty())return k.isNew();const{snapshotVersion:x}=n();return!(x!=null&&x===k.get().version)};let p,_=0,v=0,A,C,P,I=!1;const S=()=>{A=void 0;const k=t();if(!k||k.isDisposed())return;if(k.get().docId!==p){w();return}const x=h();x!=="none"&&a?.version!==k.get().version&&(a={version:k.get().version,failuresAtStart:o()}),x==="create"?r():x==="revision"?s():g()&&(p=k.get().docId,_=u(),v=o(),A=setTimeout(S,_))},w=()=>{const k=t();if(I||!k)return;const x=a?.version===k.get().version&&v!==o();A!==void 0&&(_!==u()||x)&&(clearTimeout(A),A=void 0),!(A!==void 0||h()==="none"&&!g())&&(p=k.get().docId,_=u(),v=o(),A=setTimeout(S,_))},D=k=>{const x=t();k.source==="user"?a=void 0:a&&x&&(a.version=x.get().version),k.source==="user"&&A!==void 0&&(clearTimeout(A),A=void 0),w()},T=()=>{const k=t();k!==C&&(P?.(),C=k,a=void 0,P=k?.subscribe(D),A!==void 0&&(clearTimeout(A),A=void 0))};return T(),w(),{refresh:()=>{I||(T(),w())},stop:()=>{I=!0,P?.(),P=void 0,C=void 0,A!==void 0&&(clearTimeout(A),A=void 0)}}}var Kc=d.createIdentifier("documentSession.autosaveUiFacts"),qc={isUserBusy:!1,saveContext:{}};function nv(e){return e.getOrCreateInstance(Kc,()=>se(qc))}function Os(e){return e?.getInstance(Kc)?.get()??qc}function zc(e){return Os(e).saveContext.fallbackTitle||"Untitled email."}var rv=1e4,sv=3e4;function ov(e,t){const n=h=>{const g=e.getInstance(d.CONFIG_SOURCE_ID)?.layers?.(),p=g?J_(g,h):void 0;return typeof p=="number"&&p>=0?p:void 0};let r;const s=h=>{const{error:g,failures:p}=t.saveState();return Ua(g)?(r?.failures!==p&&(r={failures:p,saved:h??null}),r.saved===(h??null)):(r=void 0,!1)},o=()=>{const h=t.current(),g=h?.get().serverId??void 0,p=Q(t.sessionKey()),_=t.recoveryFacts(),v=_?.emailId===g?_:void 0,A=t.revisionFacts(),C=v?.latestRevisionAt,P=A?.lastRevisionAt,I=$c(e).profile;return{isInited:p||h?.get().attributes.is_inited===!0,isEnabled:!!I?.autosaves&&!B_(e)&&!s(h?.get().savedVersion),isHistoryLoaded:v?.historyLoaded===!0,isUserBusy:Os(e).isUserBusy,isHeadless:L_(e),autosaveTimeoutMs:Gc(e).autosaveTimeout||rv,latestRevisionAt:C!==void 0||P!==void 0?Math.max(C??0,P??0):void 0,snapshotVersion:A?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??sv,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},i=()=>{const h=Os(e).saveContext;return{...h,project:h.project??t.current()?.get().attributes.project,fallbackTitle:zc(e)}},a=tv({readDocument:()=>t.current(),readEnvironment:o,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>xm(t.saveState().error),onCreate:()=>{Q(t.sessionKey())||t.save("materialize",{...i(),source:U_})},onRevision:()=>{t.save("snapshot",{project:i().project})}}),c=t.subscribe(()=>{s(t.current()?.get().savedVersion),a.refresh()}),l=As(e).watch(()=>a.refresh()),u=nv(e).watch(()=>a.refresh()),f=Ts(e).watch(()=>a.refresh());return()=>{c(),l.dispose(),u.dispose(),f.dispose(),a.stop()}}var Yc=12e3;function pe(e){return e.getOrCreateInstance(pt,()=>{const t=lg({resolveAdapters:(r,s)=>cv(r,e,s),resolveWritePort:()=>Xc(e),resolveHistoryPort:r=>Q(r)?Qc(e):Jc(e),resolveTerms:()=>gg(e),canEdit:r=>ea(e,r),notifyBeforeSave:jp(e),confirmPublish:N_(e),awaitCanvasSynced:Wp(e),savedEchoForm:r=>{const s=Be(e);return s.toEditorForm(s.toOutputForm(r))},queuesOutsideWrites:r=>Q(r)&&(Xp()||gt(e)),timeoutMs:Yc,onAdapterError:(r,s)=>{s instanceof Error&&s.message;const o=ug(s),i=dg(s);Wt(s,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(o),network_failure:String(i)},level:o||i?"warning":"error"})},onTimeout:r=>{}}),n=ov(e,t);return e.getInstance(d.DISPOSABLE_ID)?.addDispose(n),t})}function Ie(e){return e?.getInstance(pt)}function Xc(e){const t=hg(e);return t?Qn(e)?Lg(t,qe(e).email(e),gt(e)?{knownRevisions:bt(e),uncertainWrites:Yt(e)}:void 0):t:qe(e).email(e)}function iv(e){return ic(e)!==void 0||rc(e)}function Jc(e){const t=ic(e);return t?Qn(e)?(oe("port:history:server-backed"),dc(t,qe(e).history(e),{knownRevisions:bt(e),uncertainWrites:Yt(e),synchronousHistory:gt(e)})):(oe("port:history:integrator"),t):(oe("port:history:rest (порт не зарегистрирован)"),qe(e).history(e))}function Qc(e){const t=oc(e);return t?Qn(e)?(oe("port:block-history:server-backed"),dc(t,qe(e).blockHistory(e),{pendingKey:ns,knownRevisions:bt(e),uncertainWrites:Yt(e),synchronousHistory:gt(e)})):(oe("port:block-history:integrator"),t):(oe("port:block-history:rest (порт не зарегистрирован)"),qe(e).blockHistory(e))}function av(e){return oc(e)!==void 0||rc(e)}function Qn(e){return Qi(e)}function cv({email:e,patch:t,serverId:n,key:r},s,o){const i=[];e?i.push({id:"rest",load:()=>Ka(e),required:!0}):n&&i.push(fg(Xc(s),n)),t&&i.push({id:"plugin",load:()=>qa(t)});const a=Q(r);return qp(n)&&(a?av(s):iv(s))&&i.push(Cg({port:a?Qc(s):Jc(s),revisionServiceEnabled:Qn(s),pendingKey:pa(n,a),historyIsSynchronous:gt(s),emailId:n,wpId:()=>o.readWpId(),readShownContent:()=>o.readShownContent(),onFacts:c=>o.publishRecoveryFacts(c)})),i}function lv(e){const t=pe(e),n=ce(e).addListener(q.APPLICATION_HAS_AMP,r=>{vt(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>n.dispose())}function dv(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function uv(e){const t=e.fetchImpl??((o,i)=>fetch(o,i)),n=e.pageHost??(()=>window.location.hostname),r=new Set,s=o=>{try{const i=new URL(o,window.location.href);return i.protocol!=="https:"&&i.protocol!=="http:"?!1:i.hostname===n()||e.sourceHosts().includes(i.hostname)}catch{return!1}};return{accepts:s,async load(o){if(!s(o))return;const i=!r.has(o);r.add(o);try{const a=await t(o,{mode:"cors",credentials:"omit",cache:i?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return dv(c)?c:void 0}catch{return}}}}var Qe={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function fv(e){const t={maxBytes:e.maxBytes??Qe.maxBytes,maxImageBytes:e.maxImageBytes??Qe.maxImageBytes,ttlMs:e.ttlMs??Qe.ttlMs},n=e.now??(()=>Date.now()),r=new Map,s=new Map,o={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,l=()=>{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,l())};return{async get(f){const h=r.get(f);if(h&&c(h))return h.usedAt=n(),o.hits+=1,h.blob;h&&a(f);const g=s.get(f);if(g!==void 0)return g;o.loads+=1;const p=(async()=>{try{const _=await e.load(f);return _?u(f,_):o.failures+=1,_}catch{o.failures+=1;return}finally{s.delete(f)}})();return s.set(f,p),p},forget(f){a(f),s.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);l()},clear(){r.clear(),s.clear(),i=0},stats(){return{entries:r.size,bytes:i,...o}}}}var hv=["emcdn.ru","scr.emcdn.ru"];function pv(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 mv(e,t){const n=(r,s)=>{const o=new Set(s?t:[]);for(const i of r){const a=pv(i);a&&o.add(a)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function gv(e){const t=e??{},n=t.isPlugin!==!0?hv:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Qe};const s=r===!0||r===void 0?{}:r;return{enabled:s.enabled!==!1,sourceHosts:mv(s.sourceHosts,n),maxBytes:s.maxBytes??Qe.maxBytes,maxImageBytes:s.maxImageBytes??Qe.maxImageBytes,ttlMs:s.ttlMs??Qe.ttlMs}}function _v(e){const t=ce(e),n=e.getInstance(d.CONFIG_SOURCE_ID),r=()=>gv({...n?.get(),isPlugin:!0});let s=r();const o=uv({sourceHosts:()=>s.sourceHosts}),i=fv({load:_=>o.load(_),maxBytes:s.maxBytes,maxImageBytes:s.maxImageBytes,ttlMs:s.ttlMs}),a=()=>{t.send(q.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:s.enabled,sourceHosts:[...s.sourceHosts]})},c=t.onInit(()=>a()),l=n?.watch(()=>{const _=r(),v=JSON.stringify(_)!==JSON.stringify(s);s=_,i.configure(_),_.enabled||i.clear(),v&&t.isInited()&&a()}),u={asked:0,served:0,refused:0},f=[],h=(_,v)=>(u.refused+=1,f.push({url:_,reason:v}),f.length>20&&f.shift(),{refused:!0}),g=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:s,counters:{...u},refusals:[...f],store:i.stats()})}),p=t.addListenerAsync(q.APPLICATION_CANVAS_IMAGE_GET,async _=>{const v=_?.url??"";if(u.asked+=1,!s.enabled||!v)return h(v,"disabled");if(!o.accepts(v))return h(v,"host");_.fresh&&i.forget(v);const A=await i.get(v);return A?(u.served+=1,{blob:A}):h(v,"load-failed")});e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{c.dispose(),l?.dispose(),p.dispose(),i.clear(),delete g.__emmCanvasImages__})}var vv=2e3;function Ev(e){const t=ce(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,l=!1;const u=h=>{h.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",u),l&&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))&&(Wt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),l=!0,t.holdPort(i))},vv);n.set(i,f)},s=Object.assign(globalThis,{__emmCanvasPort__:()=>{const i=t.getTarget();return{usesPort:t.usesPort,windowDrained:i?t.isWindowDrained(i):!1}}}),o=t.onInit(()=>r());e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{for(const i of n.values())clearTimeout(i);o.dispose(),delete s.__emmCanvasPort__})}var bv=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function yv(e){return bv.test(e)||e.indexOf("//")===0}function Zn(e){return e&&(e.endsWith("/")?e:`${e}/`)}function wv(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Zc(e,t){const n=e==null||e===""?"./":String(e);if(yv(n))return Zn(n);const r=t??wv();if(!r)return Zn(n);try{return Zn(new URL(n,r).href)}catch{return Zn(n)}}function Sv(){return typeof __useblocks__<"u"&&__useblocks__?.publicPath?Zc(__useblocks__.publicPath):Zc("/")}var Iv=()=>"",Av=()=>"7594857d";function Tv(e,t){const n=new URL(e);return n.hostname!=="localhost"||t.hostname==="localhost"?e:(n.hostname=t.hostname,n.toString())}function el(e){const t=e?"iframe-eblock":"iframe",n=Iv();if(n){const o=Tv(n,window.location).replace(/\/?$/,"/");return oi(`${o}${t}.html`,xt())}const r=Av(),s=`${Sv().replace(/\/?$/,"/")}iframe/`;return oi(`${s}${t}${r?`.${r}`:""}.html`,xt())}var tl="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function Ds(e){return/^file:/i.test(String(e||"").trim())}function Cv(e){return Ds(e)?`${tl} allow-same-origin`:tl}var mD="em:module-body",Ov="em:module-body-ack";function Dv(e,t,n){try{const r=new URL("./",new URL(t,n)).href,s=new URL(e,r).href;return s.startsWith(r)?s:void 0}catch{return}}function Ps(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function Pv(e){const t=Ps(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function Rv(e,t){const n=Ps(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(s=>e[s]?.file).filter(s=>!!s):[]}function kv(e,t){const n=Ps(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const s=new Set([r]),o=[r],i=[];for(;o.length>0;)for(const a of e[o.shift()]??[])s.has(a)||(s.add(a),i.push(a),o.push(a));return i}var Nv=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function Lv(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&Nv.test(t[t.length-2])}async function xv(e,t){const n=Lv(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 Mv(e){const t=new Map,n=(r,s)=>{const o=Dv(r,e.canvasSrc,e.origin);if(!o)return;const i=t.get(o);if(i!==void 0)return i;const a=e.fetchBody(o,s);return t.set(o,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,s){for(const o of r)n(o,s)},reset(){t.clear()},get size(){return t.size}}}var xe;function Fv(e){try{return Ds(new URL(e,window.location.href).href)}catch{return Ds(window.location.href)}}function nl(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof __useblocks__<"u"&&__useblocks__?.preload?.canvasCrossOrigin===!0}var Bv=()=>Promise.resolve(void 0);function rl(){const e=el(!1);if(!Fv(e)){if(!xe||xe.canvasSrc!==e){const t=nl(e)?xv:Bv;xe={canvasSrc:e,store:Mv({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return xe.store}}async function jv(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 s=await r.json();t(Rv(s,e))}catch{}}function Rs(e){const t=rl();if(!t||!xe||xe.warmed||!nl(xe.canvasSrc))return;xe.warmed=!0;const{canvasSrc:n}=xe,r=Pv(n);r&&t.warm([r],e);const s={"js/iframe-eblock.js":["js/elMarkupHelper.CsLyPjC1.js"],"js/iframe.js":["js/elMarkupHelper.CsLyPjC1.js"],"js/darkreader.CyLMh7_H.js":[],"js/elMarkupHelper.CsLyPjC1.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.CGEpDoct.js":[]};s?t.warm(kv(s,n),e):jv(n,o=>t.warm(o,e))}function Uv(e){const t=rl();if(!t)return;Rs();const n=r=>{const s=r.data;if(!s||s.operationId!=="em:module-body"||!s.result)return;const o=r.source;o&&(o.postMessage({operationId:Ov,for:s.result},"*"),t.take(s.data?.url??"").then(i=>{o.postMessage({operationId:s.result,data:i??null},"*")}))};window.addEventListener("message",n),e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{window.removeEventListener("message",n)})}var Tt=/<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,$v=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Ct=/<style\b[^>]*>[\s\S]*?<\/style>/gi,sl=/display:\s*none\s*!important/gi,Hv="data-darkreader-",Gv=/<(script|style)\b[\s\S]*?<\/\1\s*>|<[a-z][^\s<>]*(?:"[^"]*"|'[^']*'|[^<>"'])*?\sdata-darkreader-(?:"[^"]*"|'[^']*'|[^<>"'])*>/gi,Vv=/\sdata-darkreader-[a-z0-9-]*(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s>]+))?/gi,Wv=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,Kv=/\s*height\s*:\s*100%\s*!important\s*;?/gi,qv=/height\s*:\s*100%\s*!important/i,zv=[".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 Yv(e){return sl.lastIndex=0,(e.match(sl)||[]).length}function ol(e){const t=e.trim(),n=Yv(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=zv.filter(s=>t.includes(s)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function Xv(e){Ct.lastIndex=0;for(const t of e.matchAll(Ct))if(ol(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Jv(e){let t=!1;return Ct.lastIndex=0,{html:e.replace(Ct,n=>ol(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Qv(e){return Tt.lastIndex=0,Tt.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Xv(e)}function Zv(e){return e.toLowerCase().includes(Hv)?e.replace(Gv,(t,n)=>n?t:t.replace(Vv,"")):e}function eE(e){const t=Zv(e);if(!Qv(t))return{html:t,found:!1};let n=!1,r=t;Tt.lastIndex=0,Tt.test(r)&&(Tt.lastIndex=0,r=r.replace(Tt,""),n=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(r)||/\sdata-bis-config\s*=/.test(r))&&(r=r.replace($v,""),n=!0);const s=Jv(r);return r=s.html,n=n||s.found,{html:r,found:n}}function tE(e){return!e||!qv.test(e)?e:(Ct.lastIndex=0,e.replace(Ct,t=>t.replace(Wv,(n,r,s,o)=>`${r}${s.replace(Kv,"")}${o}`)))}function il(e){const t=eE(e.replaceAll(`\r
|
|
2108
2108
|
`,`
|
|
2109
|
-
`));return{html:Qm(t.html),hasBrowserExtensionArtifacts:t.found}}function Ft(e){return e?.getContent()??""}function xa(e,t){e?.mutate({content:Ir(t)},{source:"remote"})}function Dn(e){return l.createIdentifier$1(e)}function pe(e,t){return e.getOrCreateInstance(t,()=>new l.AsyncEmitter)}function Q(e,t){return e.getOrCreateInstance(t,()=>new l.AsyncEmitter).event}function Pn(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var Zm=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 eg(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 tg(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(l.throwIfAborted(n),new Promise((r,s)=>{let o=!1,i,a;const c=u=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),a?.dispose(),n?.removeEventListener("abort",d),u())},d=()=>{c(()=>s(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(()=>s(new Zm(t)))},t)),n?.addEventListener("abort",d)}))}var Fa=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 Ba(e,t,n){return t<=0?e:new Promise((r,s)=>{let o=!1,i;const a=c=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),c())};i=setTimeout(()=>{a(()=>s(new Fa(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>s(c))})})}var ng=2,Bt=Symbol("sandbox:frame-replaced");function ja(e){return e===Bt}function Ke(e,t,n,r,s,o,i){const a=`sandbox:${t}`,c=o?.getSandboxTimeoutMs(t)??pr[t],d=()=>{let m=Ba(e.sendAsync(n,r),c,a);return m=l.raceWithAbortSignal(m,o?.signal),Ue(a,m,s)};if(t==="INIT_START"&&eg(e)){const m=o?.getSandboxReadyTimeoutMs()??2e4,v=e,_=T=>{const A=tg(v,m,o?.signal);return Ue("sandbox:INIT_START:ready-wait",A,s).then(()=>{if(!i||T<=0)return d();const B=i.getGeneration();let O;const S=new Promise((D,I)=>{O=i.onChange(()=>{i.getGeneration()!==B&&I(Bt)})}),w=d();return w.catch(()=>{}),Promise.race([w,S]).finally(()=>O?.()).catch(D=>{if(D!==Bt)throw D;return{...s},_(T-1)})})};return _(ng)}if(!i)return d();const u=i.getGeneration();let f;const h=new Promise((m,v)=>{f=i.onChange(()=>{i.getGeneration()!==u&&v(Bt)})}),g=d();return g.catch(()=>{}),Promise.race([g,h]).finally(()=>f?.()).catch(m=>{throw m===Bt&&{...s},m})}var Ua="self-init:";function rg(e){return e.startsWith(Ua)}function qr(e,t){const n=e.getActiveShowRequest();return rg(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function sg(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),s=()=>e.frameWatch?.();let o="",i;const a=m=>{i={target:e.readTarget?.(),docId:m}},c=()=>e.readDocument()?Ft(e.readDocument()):o,d=()=>Ne(e.container).editorPolicy,u=()=>e.readEmail(),f=()=>{const m=u();return{...m,id:e.isTemplate()||m.isNew?void 0:m.id,html:c()}};let h=!1;const g={readContent:c,publicEmail:f,sendInitStart:()=>Ke(n,"INIT_START",l.EVENT_TYPES.SANDBOX_INIT_START,{guid:u().renderGuid},void 0,r()),sendInited:()=>Ke(n,"INITED",l.EVENT_TYPES.SANDBOX_INITED,{guid:u().renderGuid},void 0,r(),s()),async sendContent(){const m=u(),{html:v,hasBrowserExtensionArtifacts:_}=Ma(m?.html||"");_&&e.events.browserExtensionDetected(),xa(e.readDocument(),v),o=v,a(m.renderGuid),await Ke(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,Pn(c(),m.renderGuid,d(),e.readDocument()?.get().version),{guid:m.renderGuid,emailId:m.id??null},r(),s())},refreshContent:()=>(a(u().renderGuid),Ke(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,Pn(c(),u().renderGuid,d(),e.readDocument()?.get().version),void 0,r(),s())),sendPreheader:async()=>{const m=u();if(m.preheader!==void 0)return Ke(n,"PREHEADER",l.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE,{value:m.preheader,guid:m.renderGuid,force:!0},void 0,r(),s())},sendSubject:async()=>{const m=u();if(m.subject!==void 0)return Ke(n,"SUBJECT",l.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,{value:m.subject,guid:m.renderGuid,force:!0},void 0,r(),s())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:m=>e.showFilled?.(m),noteFilled:(m,v)=>e.noteFilled?.(m,v),contentSent:()=>i,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(f()),fireInit(m,v){if(!qr(t(),m)){t().getActiveShowRequest()?.showId;return}const _=u();_.id,_.renderGuid,t().completeShow(m);const T=e.readDocument();at(T,{is_inited:!0},{source:"system"});const A=()=>{const O=f();v&&(O.reset=!0);const S=e.events.inited(O);return v||(h&&g.fireEmailChanged(),h=!0),S};if(!T||T.isReady())return A();const{docId:B}=T.get();return T.whenReady().then(()=>e.readDocument()?.get().docId===B?A():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(f())},fireContentChanged(){e.events.contentChanged(c())}};return g}var og=class extends Error{showId;constructor(e,t){super(`[useblocks] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},ig=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,s)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{s(new og(e.showId,t))})},t);o.unref?.();const i=()=>{this._settle(e.showId,()=>{s(l.createAbortError(n.reason))})};n.addEventListener("abort",i,{once:!0});const a=()=>{clearTimeout(o),n.removeEventListener("abort",i)};this._pending.set(e.showId,{request:e,resolve:r,reject:s,timeoutId:o,dispose:a});for(const c of this._listeners)c(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function ag(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function cg(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Lo(e),n=Mo(e),r=ku(e.sandbox);t<n+r}var $a=class{_controller=new AbortController;_externalSignalDisposable=new l.Disposable;_sessionChangeListeners=new Set;_showRegistry=new ig;_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 Lo(this._timeouts)}getSandboxTimeoutMs(e){return No(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=ag(this._timeouts,e.timeouts),cg(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)})}},zr=(()=>{const e=new $a;return e.configure({}),e})();function qe(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function ze(e){return!e||e==="none"}function lg(e){const t=e.contain??"",n=e.willChange??"";return!ze(e.transform)||!ze(e.perspective)||!ze(e.filter)||!ze(e.backdropFilter)||!ze(e.translate)||!ze(e.rotate)||!ze(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Ha(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 dg(e){const t=[],n=document.documentElement,r=Ha(getComputedStyle(n)),s=r.x||r.y;let o="none";const i=getComputedStyle(e).position;(i==="absolute"||i==="fixed")&&(o=i);for(let a=qe(e);a&&a!==n;a=qe(a)){const c=getComputedStyle(a),d=o==="none"||lg(c)||o==="absolute"&&!!c.position&&c.position!=="static",u=a===document.body&&!s;if(d){o="none";const f=u?{x:!1,y:!1}:Ha(c);(f.x||f.y)&&t.push({node:a,...f})}(c.position==="absolute"||c.position==="fixed")&&(o==="none"||c.position==="fixed")&&(o=c.position==="fixed"?"fixed":"absolute")}return t}function Va(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 Rn(e){return Number.parseFloat(e)||0}function Xr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=Va(e),s=Rn(n.borderLeftWidth),o=Rn(n.borderTopWidth),i=Rn(n.borderRightWidth),a=Rn(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-s-i):0,d=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-o-a):0;return{left:t.left+s*r.x,top:t.top+o*r.y,right:t.right-(i+c)*r.x,bottom:t.bottom-(a+d)*r.y}}function ug(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},s=(o,i,a)=>{i&&(r.left=Math.max(r.left,o.left),r.right=Math.min(r.right,o.right)),a&&(r.top=Math.max(r.top,o.top),r.bottom=Math.min(r.bottom,o.bottom))};return t.forEach(o=>s(Xr(o.node),o.x,o.y)),n&&s(Xr(n),!0,!0),r}var Jr={originX:0,originY:0,scaleX:1,scaleY:1};function kn(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 Ga(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,s=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*s,scaleX:r,scaleY:s}}function Wa(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 fg=1e3;function hg(e){const{slot:t,own:n}=e;let r,s=0,o=!1;const i=()=>{if(r=void 0,!o){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<s)&&(r=window.requestAnimationFrame(i))}},a=()=>{!o&&r===void 0&&(r=window.requestAnimationFrame(i))},c=()=>{s=performance.now()+fg,a()},d=[window],u=[document.documentElement];for(let _=t;_;_=qe(_)){const T=_.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(_=>f.forEach(([T,A])=>_.addEventListener(T,A,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const h=typeof MutationObserver=="function"?new MutationObserver(_=>{_.some(T=>!n.contains(T.target))&&a()}):void 0;u.forEach(_=>h?.observe(_,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let g;try{if(typeof ResizeObserver=="function"){const _=new ResizeObserver(a);typeof _.observe=="function"&&(g=_)}}catch{g=void 0}let m=[];return{schedule:a,observe:_=>{!g||_.length===m.length&&_.every((T,A)=>T===m[A])||(g.disconnect(),m=_,_.forEach(T=>g?.observe(T)))},dispose(){o=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),d.forEach(_=>f.forEach(([T,A])=>_.removeEventListener(T,A,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),h?.disconnect(),g?.disconnect()}}}var pg="pluginZoom",mg=/^(?:ant|vscode|monaco|docs)-/;function gg(e){return mg.test(e)}function vg(){const e="ub".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var _g=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function Eg(){return _g}var bg=new Set;function yg(e,t,n=bg){return e.startsWith(`${t}-`)?!1:!gg(e)&&!n.has(e)}function wg(e,t){return`--${t}-${e}`}function Ya(e){const t=vg();return yg(e,t,Eg())?wg(e,t):`--${e}`}function Sg(e,t){const n=Ya(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function Ka(e,t){return Sg(e,t)}var qa=300,za=15e3,Ig=5e3,Xa="em-canvas-busy-style";function Tg(){if(document.getElementById(Xa))return;const e=document.createElement("style");e.id=Xa,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var Ag="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 Cg(e){const t=Ka("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(Ya("colorPrimary")).trim()||t}function Ja(e){Tg();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",Ag),n.appendChild(r);const s=document.createElement("span");return s.setAttribute("role","img"),s.setAttribute("aria-label","loading"),s.setAttribute("style",`display:inline-flex;color:${Cg(e)};animation:em-canvas-busy-spin 1s linear infinite`),s.appendChild(n),s}function Og(e,t,n){const r=t??e,s=Math.max(r.left,e.left,0),o=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 o<=s||a<=i?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(s+o)/2-e.left,y:(i+a)/2-e.top}}function Dg(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 s={left:n.left,top:n.top,right:n.right,bottom:n.bottom},o=r.getBoundingClientRect();if(o.width>0&&!Wa({left:o.left,top:o.top,width:o.width,height:o.height},s)){const i=kn(s,Ga(o,kn(s,Jr),Jr));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=Og(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(Ja(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Qr(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(Ja(e))},qa);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var Pg=8e3;function Rg(){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 kg(e,t){for(let n=qe(e);n;n=qe(n)){const r=getComputedStyle(n),s=r.overflowX!=="visible"||r.overflowY!=="visible",o=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(i=>gt(i)>0);if(s&&o)return n;if(n===t)return null}return null}function gt(e){return Number.parseFloat(e)||0}function Nn(e,t){return Math.abs(e-t)<=1}function Ng(e){const t=getComputedStyle(e),n=gt(t.borderTopWidth),r=gt(t.borderRightWidth),s=gt(t.borderBottomWidth),o=gt(t.borderLeftWidth),i=(a,c,d)=>Math.max(0,gt(a)-Math.max(c,d));return{...Xr(e),radii:[i(t.borderTopLeftRadius,n,o),i(t.borderTopRightRadius,n,r),i(t.borderBottomRightRadius,s,r),i(t.borderBottomLeftRadius,s,o)]}}function Lg(e,t){const n=Nn(t.top,e.top),r=Nn(t.bottom,e.bottom),s=Nn(t.left,e.left),o=Nn(t.right,e.right),i=[n&&s?e.radii[0]:0,n&&o?e.radii[1]:0,r&&o?e.radii[2]:0,r&&s?e.radii[3]:0];return i.every(a=>a===0)?"":i.map(a=>`${a}px`).join(" ")}function Mg(e,t,n,r,s,o){const i=n.readyTimeoutMs??Pg,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",Ka(pg,"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"),s||n.onCreated?.(d);const u=new l.Disposable;let f=!1,h,g=!1,m,v,_,T;const A=()=>{clearTimeout(T),T=setTimeout(()=>{g||(g=!0,v?.(new Error(`[canvas] ${e}: документ не загрузился за ${i} мс`)))},i)},B=()=>f?(_=Promise.resolve(),g=!0,_):(g=!1,_=new Promise(($,p)=>{m=$,v=p}),A(),_),O=()=>{if(clearTimeout(T),f=!0,g){_=Promise.resolve();return}g=!0,n.mark?.("loaded"),m?.()};d.addEventListener("load",O),u.addDispose(()=>{clearTimeout(T),d.removeEventListener("load",O)});let S;const w=()=>{S??=n.bindResizer?.(d)},D=()=>{S?.dispose(),S=void 0};let I=null,R=null,M,P=Jr,L="",x="",U=0;const y=$=>{const p=JSON.stringify($);return p===L?!1:(L=p,a.style.visibility=$.visibility,a.style.left=`${$.css.left}px`,a.style.top=`${$.css.top}px`,a.style.width=`${$.css.width}px`,a.style.height=`${$.css.height}px`,a.style.borderRadius=$.radius,d.style.width=$.elementWidth>0?`${$.elementWidth}px`:"100%",d.style.transform=$.shiftX!==0?`translate(${$.shiftX}px, ${$.shiftY}px)`:`translateY(${$.shiftY}px)`,!0)};let E=!1;const N=()=>{if(!I)return L="",a.style.visibility="hidden",d.removeAttribute("id"),!1;n.elementId&&(d.id=n.elementId);const $=I.getBoundingClientRect(),p=dg(I),b=R?.isConnected?R:null;M?.observe([I,d,...p.map(Z=>Z.node),...b?[b]:[]]);const C=ug($,p,b),j=Math.max(0,C.right-C.left),G=Math.max(0,C.bottom-C.top),z=getComputedStyle(I).visibility==="visible",V=j<=0||G<=0,Y=V?{left:C.left,top:C.top,right:C.left,bottom:C.top}:C,k=V?null:kg(I,b??p[0]?.node??null),q=k?Lg(Ng(k),Y):"",X=Z=>y({visibility:z&&!E?"":"hidden",css:kn(Y,Z),elementWidth:$.width/Z.scaleX,shiftX:($.left-Y.left)/Z.scaleX,shiftY:($.top-Y.top)/Z.scaleY,radius:q});let me=X(P);if(!V){const Z=a.getBoundingClientRect();Z.width>0&&!Wa({left:Z.left,top:Z.top,width:Z.width,height:Z.height},Y)&&(P=Ga(Z,kn(Y,P),P),me=X(P)||me)}return me},F=()=>{if(!I)return!1;let $=N();const p=d.getBoundingClientRect().height;p>0&&p!==U&&(U=p,I.style.height=`${p/Va(I).y}px`,$=!0);const b=getComputedStyle(I).pointerEvents;return b!==x&&(x=b,a.style.pointerEvents=b),$},W=()=>{M?.dispose(),M=void 0},ee=$=>{M=hg({slot:$,own:a,measure:F,onDetached:W})};let te=[];const ne=($,p)=>{if(R=p,$&&te.length>0){const b=te;te=[],b.forEach(C=>C())}if($===I){$&&!M&&ee($),F();return}if(W(),I&&I.style.removeProperty("height"),L="",U=0,x="",I=$,!$){N(),D();return}n.onShown?.(d),ee($),F(),w()};u.addDispose(W);const K=$=>{f=!1,h=void 0,o?.(),$&&n.onReload?.(d);let p;g||_===void 0?p=B():(A(),p=_);try{d.contentWindow?.location.reload()}catch{d.src=c}return p};return{element:d,ready(){return _??B()},reload:()=>K(!0),reloadQuietly:()=>K(!1),followReload:()=>{h=void 0,o?.(),n.onReload?.(d)},moveTo($){if(a.parentNode===$)return _??B();f=!1,h=void 0,o?.();let p;return g||_===void 0?p=B():(A(),p=_),$.appendChild(a),n.onReload?.(d),L="",M?.schedule(),p},get shown(){return I!==null},get slot(){return I},whenShown(){return I!==null?Promise.resolve():new Promise($=>{te.push($)})},get filled(){return h},noteFilled($){h=$},alignTo($,p){ne($,p??null)},hold($){E!==$&&(E=$,N())},scrollBy($,p){let b=$,C=p;for(let j=I?qe(I):null;j;j=qe(j)){if(Math.abs(b)<1&&Math.abs(C)<1)return;const G=getComputedStyle(j);if((G.overflowY==="auto"||G.overflowY==="scroll")&&j.scrollHeight>j.clientHeight){const z=j.scrollTop,V=j.scrollLeft;j.scrollBy({left:b,top:C,behavior:"instant"}),b-=j.scrollLeft-V,C-=j.scrollTop-z}}(Math.abs(b)>=1||Math.abs(C)>=1)&&window.scrollBy({left:b,top:C,behavior:"instant"})},resize(){S?.resize()},dispose(){ne(null,null),D(),u.dispose(),a.remove()}}}function xg(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",s=(P,L)=>P==="email"?`email:${L??n}`:P,o=new Map;let i,a=[],c=!1,d,u,f=!1,h,g,m="shown",v=0,_,T,A;const B=P=>u!==void 0&&P.filled!==void 0&&P.filled!==u,O=()=>{_=void 0;const P=h;!f||!P||u===void 0||T===u||!B(P)||(T=u,e.onForeignDocument?.({wanted:u,filled:P.filled,role:m,heldMs:Date.now()-v}))},S=()=>{f=!1,h=void 0,g=void 0,clearTimeout(_),_=void 0},w=(P,L)=>{const x=o.get("email"),U=x?.slot??null;return P&&U&&B(P)?(P.alignTo(null),f||(f=!0,v=Date.now(),_=setTimeout(O,Ig)),m=L,h=P,!(i!==void 0||c)&&g!==P&&(g=P,e.onShown?.(P.element)),!d&&!i&&(d=Qr(U)),!1):(f&&(S(),d?.remove(),d=void 0),P?.alignTo(U,x?.clip??null),!0)},D=()=>{f&&!c&&w(t.get(s("email")),"shown")},I=()=>{a.forEach(P=>clearTimeout(P)),a=[],i?.remove(),i=void 0,d?.remove(),d=void 0,(c||f)&&(c=!1,w(t.get(s("email")),"shown"))},R=(P,L,x)=>{const U=s(P,L),y=t.get(U);if(y)return y;const E=e.resolveMount();if(!E)return Rg();const N=Mg(P,E,e,P==="email"?L??n:void 0,x,P==="email"?()=>D():void 0);return t.set(U,N),N},M={get:P=>R(P),current:P=>R(P),peek:P=>t.get(s(P)),spare:()=>t.get(s("email",r())),ensureSpare:()=>R("email",r(),!0),promote(){const P=t.get(s("email",r()));if(!P)return;const L=t.get(s("email"));n=r(),A=void 0,w(P,"spare"),L?.alignTo(null)},alignSurface(P,L,x){const U=o.get(P);if(o.set(P,{slot:L,clip:x??null}),P==="email"&&c){d?.remove(),d=L?Qr(L):void 0;return}const y=L?R(P):t.get(s(P));if(P!=="email"){y?.alignTo(L,x??null);return}if(!L){A=U?.slot&&y?.shown?{slot:U.slot,handle:y}:void 0,f&&(S(),d?.remove(),d=void 0),y?.alignTo(null);return}const E=A?.slot===L&&A.handle===y;if(A=void 0,U?.slot===L&&y?.shown||E){y?.alignTo(L,x??null);return}w(y,"shown")},want(P){u=P,P!==void 0&&D()},noteFilled(P,L){const x=M.byWindow(P);x&&(x.noteFilled(L),x===t.get(s("email"))&&D())},visible(){for(const P of t.values())if(P.shown)return P},byWindow(P){if(P){for(const L of t.values())if(L.element.contentWindow===P)return L}},busy(P){if(I(),!P)return;if(!M.visible()){c=!0,d?.remove(),d=void 0;const U=o.get("email");U?.slot&&(d=Qr(U.slot)),a=[setTimeout(I,za)];return}const L=e.resolveMount();if(!L)return;const x=Dg(L,()=>M.visible()?.element.parentElement?.getBoundingClientRect()??null);i=x,a=[setTimeout(()=>x.showSpinner(),qa),setTimeout(I,za)]},remount(P){I();const L=s("email");t.forEach((x,U)=>{if(U===L){x.moveTo(P).catch(()=>{});return}x.dispose(),t.delete(U)})},dispose(){u=void 0,c=!1,S(),A=void 0,I(),t.forEach(P=>P.dispose()),t.clear(),o.clear(),n="a",u=void 0,T=void 0}};return M}var Fg=l.createIdentifier$1("canvas.resizerBinder"),Zr=l.createIdentifier$1("canvas.service"),Bg={created:fe.canvasCreated,loaded:fe.canvasLoaded},Qa=new WeakMap;function es(e){return Qa.get(e)??0}function jg(e,t){if(e.getInstance(Zr))return;const n=xg({resolveMount:()=>t.resolveMount(),resolveSrc:s=>t.resolveSrc(s),resolveSandbox:Im,elementId:t.elementId,bindResizer:s=>e.getInstance(Fg)?.(s),onCreated:s=>jt(e,s,"fresh"),onReload:s=>{Qa.set(s,es(s)+1),jt(e,s,"fresh")},onShown:s=>{const o=n.byWindow(ae(e).getTarget());o&&o.element!==s&&Za(o.element)===Za(s)||jt(e,s,"switch")},mark:s=>t.mark?.(Bg[s]),onForeignDocument:s=>{({...s},Ku("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:s.role},contexts:{canvasIdentity:{...s,path:window.location.pathname}}}))}}),r=ae(e).addListener(l.EVENT_TYPES.SANDBOX_WHEEL,s=>{n.visible()?.scrollBy(s?.deltaX??0,s?.deltaY??0)});e.inject(Zr,n),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),n.dispose()})}function Za(e){return e.parentElement?.dataset.canvasHost}function jt(e,t,n){const r=ae(e),s=t.contentWindow;if(!s)return;const o=r.getTarget()===s;o&&n==="switch"||(n==="fresh"&&(r.forget(s),o&&r.setTarget(void 0)),r.setTarget(s),xu(r))}function Ug(e,t){jt(e,t,"promote")}function $g(e,t){jt(e,t,"switch")}function Hg(e,t){const n=t.contentWindow;n&&ae(e).greet(n)}function ec(e,t){const n=t.contentWindow;n&&ae(e).forget(n)}function Vg(e,t){const n=ue(e)?.byWindow(t)?.element;if(!n)return;const r=es(n);return()=>es(n)!==r}function ue(e){return e.getInstance(Zr)}function tc({attributes:e,readContent:t,docId:n,hasSession:r,serverId:s,show:o}){if(!r)return;const i={id:s??void 0,renderGuid:n,showId:o?.id,isNew:s==null,showToken:o?.token},a={...e,...i};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function Ln(e){return{...tc({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function Mn(e){const t=he(e),n=t.current();if(!n||!J(t.sessionKey()))return;const r=Ln(n),s=n.isDirty();pe(e,l.events.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:s})}function Gg(e){const t=he(e);return!t.current()||!J(t.sessionKey())?!1:(Mn(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function Wg(e){const t=he(e),n=ae(e),r=()=>e.getInstance(l.INIT_PIPELINE_ID)??zr;let s,o,i=!1,a=!1,c,d;const u=x=>Ln(x),f=()=>{const x=B(),U=x?.get().docId;if(!x||!U||U!==c||i)return;const y=x.get().version;y!==d&&(d=y,pe(e,l.events.ON_BLOCK_CHANGED_ID).fire(u(x)))};let h;const g=x=>{const U=t.showFacts();!U||U.id===h||!qr(x,U.id)||(h=U.id,x.completeShow(U.id))},m=async(x,U,y)=>{const E=y.generation,N=()=>y.generation!==E||y.signal.aborted||t.current()!==x||a,F=_e(n);let W;const ee=new Promise(ne=>{W=At(n,()=>ne("regenerated"))}),te=async(...ne)=>await Promise.race([Ke(...ne).then(()=>"sent"),ee])==="sent";i=!0;try{if(!await te(n,"INIT_START",l.EVENT_TYPES.SANDBOX_INIT_START,{guid:U},void 0,y)||N())return;const{html:ne,hasBrowserExtensionArtifacts:K}=Ma(Ft(x));if(K&&pe(e,l.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),xa(x,ne),!await te(n,"SET_ENTITY",l.EVENT_TYPES.SANDBOX_SET_ENTITY,Pn(Ft(x),U,Ne(e).editorPolicy,x.get().version),void 0,y)||N()||!await te(n,"INITED",l.EVENT_TYPES.SANDBOX_INITED,{guid:U},void 0,y)||N())return;s=U,o=F,O(),d=x.get().version,c!==U&&(c=U,pe(e,l.events.ON_BLOCK_INIT_ID).fire(u(x))),g(y)}finally{W?.(),i=!1,(_e(n)!==F||t.current()!==x)&&D()}};let v,_,T;const A=()=>{const x=ue(e)?.peek("block");return x?.reload?(x.reload().catch(()=>{}),!0):!1},B=()=>J(t.sessionKey())?t.current():void 0,O=()=>{const x=B()?.get().docId,U=!x||T===x||s===x&&o===_e(n);ue(e)?.peek("block")?.hold(!U)},S=()=>{if(a||(O(),f(),i))return;const x=B(),U=x?.get().docId;if(!x||!U)return;if(s===U&&o===_e(n)){g(r());return}if(!x.isReady())return;const y=r();y.signal.aborted||s!==void 0&&s!==U&&v!==U&&(v=U,A())||m(x,U,y).catch(()=>{if(!(a||t.current()!==x)){if(_!==U){_=U,A();return}T=U,O()}})};let w=!1;const D=()=>{w||a||(w=!0,queueMicrotask(()=>{w=!1,S()}))};let I,R;const M=()=>{const x=B(),U=x?.get().docId;U!==R&&(I?.(),R=U,I=x?.subscribe(D)),O(),D()},P=t.subscribe(M),L=At(n,()=>{O(),D()});M(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{a=!0,L(),I?.(),P()})}function Yg(e){const t=he(e);let n="email";const r=()=>{if(!t.current())return;const o=J(t.sessionKey())?"block":"email",i=ue(e);if(o===n||!i)return;n=o;const a=i.peek(o);if(a){$g(e,a.element);return}i.get(o)},s=t.subscribe(r);e.getInstance(l.DISPOSABLE_ID)?.addDispose(s)}var Kg=200;function qg({startVersion:e,limit:t=Kg}){let n=[],r=e;const s=o=>{n=n.filter(i=>i.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&s(n[n.length-t-1].version))},rebase(o,i){if(i<r)return null;const a=n.filter(d=>d.version>i);s(i);let c=o;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(m=>h.range.start<=m.oldEnd&&h.range.end>=m.oldPosition))return null;const g=Jo(h.range,u,"after");if(!g)return null;f.push({range:g,text:h.text})}c=f}return c}}}function zg(e,t){let n=0;return e.map(({start:r,end:s,text:o})=>{const i=new Ie(r,t.slice(r,s),r+n,o);return n+=o.length-(s-r),i})}function Xg(e,t){const n=[...e].sort((r,s)=>r.range.start-s.range.start);return zg(n.map(({range:r,text:s})=>({start:r.start,end:r.end,text:s})),t)}function Jg(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var Qg=32;function Zg(e=Qg){const t=new Map;return{find(n,r){const s=t.get(n);return s&&gr(s.scope,r)?s.echo:void 0},remember(n,r,s){t.delete(n),t.set(n,{scope:r,echo:s}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>gr(r.scope,n)).map(r=>r.echo)}}}function ev(e,t){const n=l.findTextDiffBounds(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var ts=l.createIdentifier$1("canvas.sandboxFill");function nc(e){return e.getInstance(ts)?.pipeline.isEventsLocked()===!0}var nA=.2,tv=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,nv=/<\/?[a-zA-Z]/g;function rc(e){return e.match(nv)?.length??0}function sc(e){return[...e.matchAll(tv)].map(t=>[t.index,t.index+t[0].length])}function ns(e,t,n){let r=0,s=0;for(const[o,i]of n){for(;s<t.length&&t[s][1]<=o;)s++;let a=o;for(let c=s;c<t.length&&t[c][0]<i;c++)r+=rc(e.substring(a,Math.max(a,t[c][0]))),a=Math.max(a,t[c][1]);r+=rc(e.substring(Math.min(a,i),i))}return r}function oc(e,t){const n=[...t].sort((c,d)=>c.oldPosition-d.oldPosition||c.oldEnd-d.oldEnd),r=[],s=[],o=[];let i=0,a=0;for(const c of n){const d=e.substring(i,c.oldPosition);r.push(d,c.newText),a+=d.length,s.push([c.oldPosition,c.oldEnd]),o.push([a,a+c.newText.length]),a+=c.newText.length,i=c.oldEnd}return r.push(e.substring(i)),{next:r.join(""),removed:s,inserted:o}}var rv=/<(?:!doctype|html|head|body)\b/i;function sv(e,t){return e.reduce((n,r)=>n+r.oldLength,0)<t.trim().length?!1:rv.test(t)&&!oc(t,e).next.trim()}function ov(e,t){if(e.reduce((i,a)=>i+a.oldLength,0)<=200)return null;const n=sc(t),r=oc(t,e),s=ns(t,n,r.removed)-ns(r.next,sc(r.next),r.inserted),o=ns(t,n,[[0,t.length]]);return s>100&&s>o*.2?{removed:s,total:o}:null}function Xe(e){Ct(e,{origin:"canvas-channel"})}var iv=100;function av(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===l.EVENT_TYPES.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function cv(e){const t=he(e),n=ae(e);let r;const s=(c,d)=>{const u=c.get().docId;let f=!1,h=null,g=null,m;const v=qg({startVersion:c.get().version});let _=c.getContent();const T=Zg(),A=Ho(e),B=A.open(u,()=>c.get().version);let O=!1;const S=b=>({generation:_e(n),originId:b});let w=S(null),D=!0;const I=(b,C)=>{!D||t.current()!==c||(Ct(C,{origin:"canvas-channel"}),g?.splice(0,g.length),n.sendAsync(l.EVENT_TYPES.SANDBOX_SET_ENTITY,Pn(Ft(c),u,Ne(e).editorPolicy,c.get().version)).catch(Xe))},R=b=>{const C=b[b.length-1],j=[...b].reverse().find(V=>V.answer?.actionId!==void 0)?.answer?.actionId,G=C.answer?.selection,z=j!==void 0||G?{...j!==void 0?{actionId:j}:{},...G?{selection:G}:{}}:void 0;return{edits:b.map(V=>V.edits),guid:u,rev:C.rev,...z?{historyAnswer:z}:{}}},M=()=>{const b=d.activeMove(),C=b&&m?.action===b.kind?m:void 0;if(C&&(m=void 0),!(!C&&!b?.selection))return{...C?{actionId:C.actionId}:{},...b?.selection?{selection:b.selection}:{}}},P=b=>{L({edits:[],rev:c.get().version,answer:{actionId:b.actionId}}).catch(Xe)},L=async b=>{if(g){g.push(b);return}g=[b];try{do await n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,R(g.splice(0,g.length)));while(g.length)}catch(C){I("app edits failed to reach the canvas",C)}finally{g=null}},x=b=>{b.length&&n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,R(b)).catch(Xe)},U=(b,C)=>{O=!0,x(g?.splice(0,g.length)??[]);const j={edits:[b],guid:u,rev:c.get().version,...C!==null?{changeId:C}:{}};C!==null&&T.remember(C,w,j),n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,j).catch(Xe)},y=new Set,E=(b,C,j,G)=>{U([],G);const{length:z,hash:V}=l.textFingerprint(JSON.stringify(j.map(k=>[k.oldText,k.newText]))),Y=`${z}:${V}`;y.has(Y)||(y.add(Y),I(b,C))},N=(b,C,j)=>E("canvas service batch removes a large part of the email",new Error(`canvas service batch removes ${b.removed} of ${b.total} tags`),C,j),F=({changeId:b,baseRev:C})=>{!O&&(b!==null||C!==null)&&U([],b)},W=b=>{if(b.guid!==u)return;const C=gf(b);O=!1,w=S(C.originId);try{ee(b,C)}catch(j){F(C),I("canvas batch failed to apply",j)}finally{F(C),C.changeId!==null&&A.note(C.changeId,w)}},ee=(b,C)=>{const{pushUndoStop:j}=b,G=C.changeId!==null?T.find(C.changeId,w):void 0;if(G){O=!0,n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,G).catch(Xe);return}let{edits:z,selection:V}=b;if(C.baseRev!==null){const Y=v.rebase(z,C.baseRev);if(!Y){Ct(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),U([],C.changeId);return}Y!==z&&(V=void 0),z=Y}try{f=!0,h=C.changeId;const Y=Xg(z,c.getContent());if(sv(Y,c.getContent())){E("canvas batch erases the whole email",new Error("canvas batch erases the whole email"),Y,C.changeId);return}if(j===!1){const k=ov(Y,c.getContent());if(k){N(k,Y,C.changeId);return}d.applyWithoutHistory(Y)}else d.recordAt(b.typedAt,()=>c.mutate({changes:Y},{source:nc(e)?"system":"user"}),V),b.closesStep&&d.closeGroup()}finally{f=!1,h=null}},te=c.subscribe(({changes:b,version:C})=>{const j=c.getContent(),G=!b?.length&&j!==_;if(_=j,v.record({version:C,changes:b,contentReplaced:G,fromCanvas:f}),!b?.length)return;const z=Jg(b);f?U(z,h):L({edits:z,rev:C,answer:M()}).catch(Xe)}),ne=n.addListener(l.EVENT_TYPES.APPLICATION_UPDATE_ENTITY,W),K=n.addListenerAsyncPipe(l.CUSTOM_MESSAGE,(b,C)=>{m=av(b);try{return C?.(b)}finally{const j=m;m=void 0,j&&P(j)}},iv),$=(b,C,{reportId:j,dropsCovered:G})=>{const z=g?.splice(0,g.length)??[];n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:[ev(b,C)],guid:u,rev:c.get().version,resync:{textFingerprint:l.textFingerprint(C),reportId:j}}).catch(V=>I("canvas resync edit failed to reach the canvas",V)),G&&x(z)},p=n.addListener(l.EVENT_TYPES.APPLICATION_SYNC_DRIFT,b=>{if(!((b.reason==="echo-timeout"||b.reason==="resync-failed")&&b.guid!==void 0&&b.guid!==u)){if(b.reason==="resync-failed"){I("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(b.reason==="echo-timeout"){const{textFingerprint:C}=b,j=Ft(c),G=l.textFingerprint(j);if(C?.length===G.length&&C.hash===G.hash){T.echoes(S(b.originId??null)).forEach(V=>{n.sendAsync(l.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,V).catch(Xe)}),b.reportId!==void 0&&$(j,j,b);return}const z=new Error(`canvas echo timeout, ${b.unsent??0} edits unsent`);if(b.canvasText===void 0){I("canvas lost the echo of its batch",z);return}$(b.canvasText,j,b)}}});return()=>{D=!1,B(),te(),ne.dispose(),K.dispose(),p.dispose()}};let o;const i=()=>{const c=t.current(),d=t.history(),u=c?.get().docId;u!==o&&(r?.(),r=void 0,o=u,c&&d&&(r=s(c,d)))},a=t.subscribe(i);i(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r?.(),a()})}function lv(e){const t=ae(e),n=()=>ue(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(l.EVENT_TYPES.RELOAD,()=>{n()?.followReload()}),s=t.addOffTargetListener(l.EVENT_TYPES.RELOAD,a=>{const c=ue(e)?.byWindow(a);c&&ec(e,c.element)}),o=t.addListener(a=>{a.data?.operation===l.EVENT_TYPES.SANDBOX_RESIZED&&n()?.resize()}),i=Q(e,l.events.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),s.dispose(),o.dispose(),i.dispose()})}function ic(){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 dv(e){const t=e.getInstance(l.OPTIONS_SOURCE_ID);let n,r;e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{r?.remove(),r=void 0}),jg(e,{resolveMount:()=>n,resolveSrc:o=>Da(o==="block"),elementId:"email_iframe",mark:o=>se(o)}),t?.watch(o=>{const i=o?.element;if(n&&i instanceof HTMLElement&&i!==n){n=i,ue(e)?.remount(i),r?.remove(),r=void 0;return}if(!n){if(i instanceof HTMLElement)n=i;else if(o!==void 0){n=r??=ic(),ue(e)?.alignSurface("email",r,r);return}else return;ue(e)?.get("email")}});let s;e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{s?.remove(),s=void 0}),Np(e).watch(o=>{const i=ue(e);if(i){if(o){s??=ic(),i.alignSurface("email",s,s);return}s&&(i.alignSurface("email",null),s.remove(),s=void 0)}})}var rs=l.createIdentifier$1("canvas.headerFlow"),ac=["subject","preheader"],cc=3e3,uv=3,fv={subject:l.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,preheader:l.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE};function hv(e){const t=he(e),n=ae(e),r=S=>S?"remote":nc(e)?"system":"user",s=(S,{guid:w,value:D,forced:I})=>{const R=it(t);if(!R||typeof D!="string"||w&&w!==R.get().docId)return;const M=t.forcedHeaders();if(M?.[S]!==void 0&&!I&&D!==M[S])return;const P=R.get().attributes[S];if(!I&&g(S,D,P))return;const L=!I&&f.delete(S);I&&(_.delete(S),_.size===0&&t.endForcedHeaders()),c=!0;try{at(R,{[S]:D},{source:L?"system":r(I)})}finally{c=!1}o[S]=D};let o={},i,a,c=!1,d=Promise.resolve();const u={},f=new Map,h=(S,w)=>{o[S]=w;const D={};f.set(S,D);const I=()=>{f.get(S)===D&&f.delete(S)};m(S,w,{force:!0}).then(I),setTimeout(I,cc)},g=(S,w,D)=>{const I=t.showFill();if(!I||typeof D!="string")return!1;const R=u[S]?.showId===I.showId?u[S]:void 0;return w===D?(u[S]=R??{showId:I.showId,codeEdits:I.codeEdits,corrections:0},!1):R&&I.codeEdits>R.codeEdits&&w!==R.stale?!1:((!R||w===R.stale&&R.corrections<uv)&&(u[S]={showId:I.showId,stale:w,codeEdits:I.codeEdits,corrections:(R?.corrections??0)+1},h(S,D)),!0)},m=(S,w,{force:D=!1,echo:I=!1,undoStep:R=!1})=>(d=n.sendAsync(fv[S],{value:w,guid:it(t)?.get().docId,...D?{force:!0}:{},...I?{echo:!0}:{},...R?{undoStep:!0}:{}}).catch(M=>{}),d);let v;const _=new Set;e.inject(rs,{whenDelivered:async()=>{await d},reassert:S=>{const w=it(t),D=ac.filter(I=>typeof S[I]=="string");if(!(!w||D.length===0)){c=!0;try{at(w,Object.fromEntries(D.map(I=>[I,S[I]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders(Object.fromEntries(D.map(I=>[I,S[I]]))),clearTimeout(v),v=setTimeout(()=>{_.clear(),t.endForcedHeaders()},cc),_.clear();for(const I of D)_.add(I);for(const I of D)o[I]=S[I],m(I,S[I],{force:!0,echo:!0})}}});const T=()=>{i?.(),i=void 0;const S=it(t);if(S!==a&&f.clear(),a=S,!S){o={};return}const w=S.get().attributes;o={subject:w.subject,preheader:w.preheader},i=S.subscribe(({source:D})=>{if(c)return;const I=S.get().attributes,R=t.forcedHeaders();for(const M of ac){const P=I[M];if(P===o[M])continue;o[M]=P,f.delete(M);const L=D==="system"&&R?.[M]!==void 0;m(M,P??"",{force:L,echo:L,undoStep:D==="user"})}})};T();const A=t.subscribe(T),B=n.addListenerAsync(l.EVENT_TYPES.APPLICATION_SUBJECT_UPDATE,S=>s("subject",S)),O=n.addListenerAsync(l.EVENT_TYPES.APPLICATION_PREHEADER_UPDATE,S=>s("preheader",S));e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{B.dispose(),O.dispose(),A(),i?.(),clearTimeout(v)})}function pv(e){const t=he(e);let n={document:void 0,seq:0};const r=()=>{const o=t.recoveryFacts(),i=it(t);if(!o?.applied||!i||String(o.emailId)!==String(i.get().serverId)||(n.document!==i&&(n={document:i,seq:0}),o.applied.seq<=n.seq))return;n={document:i,seq:o.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance(rs)?.reassert(a)},s=t.subscribe(r);e.getInstance(l.DISPOSABLE_ID)?.addDispose(s)}function mv(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?l.DARK:l.LIGHT}function gv(e,t,n=!1){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,blocksTemplateEnabled:n}}function vv(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function lc(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function ss(e,t){const n={...e};for(const r of Object.keys(t)){const s=t[r],o=e[r];lc(s)&&lc(o)?n[r]=ss(o,s):s!==void 0&&(n[r]=s)}return n}function _v(e,t){const n=l.COMMON_STYLES;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length>0)return ss(n,s)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?ss(n,t):n}var Ev=re(void 0),dc=Ev,uc=l.createIdentifier$1("CodeMode");function fc(){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 bv(e){try{window.localStorage?.setItem(l.LOCAL_STORAGE_ITEMS.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function xn(e){return e.getOrCreateInstance(uc,()=>{const t=re(fc());return t.watch(bv),t})}function hc(e){return e?.getInstance(uc)?.get()??fc()}function os(e,t){const n=xn(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function yv(e,t){const n=xn(e);n.set({...n.get(),direction:t})}var wv=l.createIdentifier$1("DefaultCommonStyles");function pc(e){return e.getOrCreateInstance(wv,()=>re(void 0))}function Sv(e,t){pc(e).set(t)}var Iv=l.createIdentifier$1("CanvasViewport"),Tv=l.createIdentifier$1("CanvasPreviewPage"),Av=l.createIdentifier$1("CanvasTemplateBlocks");function Me(e,t,n){let r,s;const o=()=>{if(!r||!e.isInited())return;const c=r.value===void 0?"undefined":JSON.stringify(r.value);c!==s&&(s=c,e.send(t,r.value))},i=n.watch(c=>{r={value:c},o()}),a=e.onInit(()=>{s=void 0,o()});return{dispose(){i.dispose(),a.dispose()}}}function Fn(e){const t=re(e());return{source:t,refresh:()=>t.set(e())}}function Cv(e){const t=ae(e),n=e.getInstance(l.CONFIG_SOURCE_ID),r=e.getInstance(l.OPTIONS_SOURCE_ID),s=he(e),o=xn(e),i=matchMedia(l.PREFERS_COLOR_SCHEME_DARK),a=()=>n?.get()??{};let c;const d=Fn(()=>mv(dc.get()??a().theme,i.matches)),u=e.getOrCreateInstance(Av,()=>re(!1)),f=Fn(()=>gv(a(),J(s.sessionKey()),u.get()===!0)),h=u.watch(()=>f.refresh()),g=Fn(()=>a().lockEditor),m=Fn(()=>_v(s.current()?.get().attributes?.common_styles,c)),v=e.getOrCreateInstance(Iv,()=>re()),_=e.getOrCreateInstance(Tv,()=>re()),T=[Me(t,l.CANVAS_FACTS.theme,d.source),Me(t,l.CANVAS_FACTS.flags,f.source),Me(t,l.CANVAS_FACTS.lockEditor,g.source),Me(t,l.CANVAS_FACTS.commonStyles,m.source),Me(t,l.CANVAS_FACTS.codeMode,o.select(vv)),Me(t,l.CANVAS_FACTS.appName,re("useblocks")),Me(t,l.CANVAS_FACTS.previewPage,_),Me(t,l.CANVAS_FACTS.viewport,v)],A=()=>{d.refresh(),f.refresh(),g.refresh()},B=n?.watch(A),O=pc(e).watch(P=>{c=P,m.refresh()}),S=r?.watch(P=>{P&&"commonStyles"in P&&(c=P.commonStyles),m.refresh()});let w;const D=()=>{w?.(),w=s.current()?.subscribe(()=>m.refresh()),m.refresh(),f.refresh()};D();const I=s.subscribe(D),R=()=>d.refresh();i.addEventListener("change",R);const M=dc.watch(()=>d.refresh());e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{T.forEach(P=>P.dispose()),B?.dispose(),h.dispose(),O.dispose(),S?.dispose(),w?.(),I(),i.removeEventListener("change",R),M.dispose()})}var is;(function(e){function t(s,o,i=(a,c)=>a===c){if(s===o)return!0;if(s.length!==o.length)return!1;for(let a=0;a<s.length;a++)if(!i(s[a],o[a]))return!1;return!0}e.isEqual=t;function n(s,o=i=>i){const i=new Set;return s.filter(a=>{const c=o(a);return i.has(c)?!1:(i.add(c),!0)})}e.unique=n;function r(s=[],o=[],i=(a,c)=>a===c){const a=[],c=[],d=[];for(const u of s){const f=o.find(h=>i(u,h));f?d.push({prev:u,next:f}):c.push(u)}for(const u of o)s.find(f=>i(u,f))||a.push(u);return{added:a,removed:c,exists:d}}e.diff=r})(is||(is={}));function Ov(e,t){return e.type===t.type&&e.key===t.key}function Dv(e){const t=ae(e),n=()=>e.getServices(l.SANDBOX_EXTENSIONS_ID)??[];let r=[];const s=t.onInit(()=>{r=n(),t.send(l.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,r)}),o=l.getServiceContainerId(l.SANDBOX_EXTENSIONS_ID),i=e.onInject(a=>{if(a!==o)return;const c=n();if(!t.isInited()){r=c;return}const{added:d,removed:u}=is.diff(r,c,Ov);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(()=>{s.dispose(),i?.dispose()})}var Pv=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 Rv(e){return e.length>0&&!e.startsWith("em:")&&!Pv.has(e)}function kv(e){const t=ae(e),n=new Map;let r=!1,s=-1,o=new Set;const i=d=>(d!==s&&(s=d,o=new Set),o),a=t.observeOutgoing((d,u)=>{if(!r||!Rv(d))return;const f=_e(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=_e(t),f=i(u);f.add(d.key);for(const[h,g]of n)g.generation===u||![...g.scripts].every(m=>f.has(m))||(g.generation=u,t.send(l.createIdentifier(h),g.data))});e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{a.dispose(),c.dispose()})}var Nv=l.createIdentifier$1("prewarm.editorVisible");function Lv(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Mv(e={}){const t=e.paint??Lv;let n=!1,r=!1,s=!1,o=!1,i=!1;const a=[],c=()=>{i||o||!n||!r||!s||(o=!0,t(()=>{i=!0,se(fe.editorVisible);for(const d of a.splice(0))d()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){s=!0,c()},whenVisible(d){if(i){d();return}a.push(d)},contentShown:()=>s}}function xv(e){return e.getOrCreateInstance(Nv,()=>Mv())}var Fv=500,Bv=500,jv=5e3;function Uv(e){const t=e.quietMs??Fv,n=e.floorMs??Bv,r=e.ceilingMs??jv;let s,o,i=0;const a=()=>{clearTimeout(s),clearTimeout(o),s=void 0,o=void 0},c=()=>{a(),e.run()},d=()=>{clearTimeout(s);const u=n-(Date.now()-i);s=setTimeout(c,Math.max(t,u))};return{start(){a(),i=Date.now(),o=setTimeout(c,r),d()},notify(){s!==void 0&&d()},cancel:a}}var $v=2;function mc(){return new Error("[sandbox] document reloaded during fill")}function Hv(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function as(e){try{e()}catch{}}function Vv(e){let t;return as(()=>{t=e()}),{stage:n=>as(()=>t?.stage(n)),end:(n,r)=>as(()=>t?.end(n,r))}}function Gv(e){const t=()=>e.initPipeline();let n=!1,r,s,o,i=0,a,c;const d=()=>{const w=e.readTarget?.(),D=e.readSandboxGeneration?.();return w===void 0||D===void 0?void 0:{target:w,generation:D}},u=()=>{const w=d();return w&&{...w,canvasReplaced:e.trackDocument?.(w.target)}},f=w=>{if(w?.canvasReplaced?.())return!0;const D=d();return w!==void 0&&D?.target===w.target&&D.generation!==w.generation},g=sg({...e,waitScope:()=>({getSandboxTimeoutMs:w=>t().getSandboxTimeoutMs(w),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const w=c;if(!(!w||!e.onSandboxGenerationChange))return{getGeneration:()=>d()?.generation??w.generation,onChange:D=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===w.target||w.canvasReplaced?.())&&D()})??(()=>{})}}});let m;const v=(w,D)=>{if(m===w)return;m=w;const I=i;setTimeout(()=>{i!==I||t().signal.aborted||B(w,D).catch(()=>{})},0)},_=()=>{a?.abort(),a=void 0};let T;const A=()=>{const w=t().signal;w!==T&&(T?.removeEventListener("abort",_),T=w,w.addEventListener("abort",_))};async function B(w,D,I=0){const R=++i;_(),a=new AbortController,c=void 0,A();const M=()=>i!==R,P=g.readTarget(),L=t().generation,x=()=>L===t().generation&&!t().signal.aborted,U=D?"init:reset-":"init:",y=Vv(()=>e.observeShow?.(Hv(w,D,e.readEmail())));if(!D){const ne=g.publicEmail();ne?.id,ne?.renderGuid,ne?.preheader}let E=!1,N=!1,F,W=!1;const ee=()=>{if(f(F))throw mc()},te=()=>{if(M())throw l.createAbortError("Fill superseded")};try{n=!0,await g.sendInitStart(),te(),F=u(),c=F,I===0&&g.fireWillInit(),await(D||I>0?g.refreshContent():g.sendContent()),E=!0,te(),ee();const ne=g.contentSent();g.noteFilled(ne?.target,ne?.docId),y.stage("content"),D||g.publicEmail()?.id;try{await g.sendPreheader()}catch(K){if(ja(K)||M())throw K;`${U}`,String(K)}te();try{await g.sendSubject()}catch(K){if(ja(K)||M())throw K;`${U}`,String(K)}if(te(),ee(),g.showFilled(P),await g.sendInited(),te(),ee(),N=!0,s===w){const K=e.readSandboxGeneration?.()??o;K!==void 0&&(r=K)}y.stage("reveal"),await g.revealFilled(),ee(),y.end("revealed")}catch(ne){const K=!M()&&x()&&f(F),$=K?mc():void 0,p=$??ne,b=K&&I<$v?S(w,D,I+1):void 0;W=K&&b===void 0;const C=M()?void 0:{showId:w,contentApplied:E,sandboxInitedAcked:N,superseded:!1,...e.describeSurface?.(),error:String($??ne)};C&&(`${U}`,void 0);const j=!M()&&e.recoverFailedFill?.(P)===!0;if(y.end(M()?"superseded":j?"recovered":l.isAbortError(p)||!x()?"aborted":"failed",C),!j&&!M()&&qr(t(),w)&&t().failShow(w,p),b!==void 0)return b;throw p}finally{O(w,D,U,{superseded:M(),sessionGeneration:L,contentApplied:E,sandboxInitedAcked:N&&!W,retry:!W,commit:x()})}}function O(w,D,I,R){const{superseded:M,contentApplied:P,sandboxInitedAcked:L}=R;if(M){`${I}`;return}L&&R.commit?g.fireInit(w,D||void 0):L?(`${I}`,R.sessionGeneration,t().generation,t().signal.aborted,void 0):P?(`${I}`,void 0):(`${I}`,void 0),n=!1,a=void 0,!L&&s===w&&(s=void 0,r===o&&(r=void 0)),!L&&P&&R.retry&&v(w,D)}function S(w,D,I){return B(w,D,I)}return{channel:g,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:w=>{r=w},lastCorrelation:()=>s,markCorrelation:w=>{s=w},bumpRunSeq:()=>{i+=1},noteSandboxGeneration:w=>{o=w},fill:w=>B(w,!1),refill:w=>B(w,!0),stop:()=>{i+=1,_(),n=!1,T?.removeEventListener("abort",_),T=void 0}}}function Wv(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:gc(e,n)}function gc(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Yv(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:s,readSandboxGeneration:o}=e,i=u=>{const f=n(),h=s();if(!Wv(f,u,h)){u.showId,u.navId,u.emailId,f?.id,f?.showId,f?.renderGuid;return}u.showId,f?.id,f?.renderGuid,t.markFilled(o()),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=o();if(t.filledGeneration()===u)return;const f=n(),h=s();if(!f?.renderGuid||!gc(f,h))return;const g=`${Ua}${f.renderGuid}`;t.markFilled(u),t.markCorrelation(g);const m=r()?.isReady()===!0;f.id,f.renderGuid,(m?v=>t.refill(v):v=>t.fill(v))(g).catch(()=>{t.lastCorrelation()===g&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id,r()}}}var Kv=l.createIdentifier$1("canvas.health");function qv(e){return e??""}function zv(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function vc(e){return e.length>0}function Xv(e){const t=he(e),n=ae(e),r=()=>J(t.sessionKey())?void 0:t.current(),s=()=>{const k=r();return tc({attributes:k?.get().attributes??{},readContent:()=>k?.getContent(),docId:k?.get().docId,hasSession:!!k,serverId:k?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(l.INIT_PIPELINE_ID)??zr;let i={},a=!1;const c=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(k=>{a=!!k?.element});let d=!1,u=!1,f=!1,h=0;const g=()=>{const k=ue(e);if(!k)return;const q=++h,X=k.spare();return X&&ec(e,X.element),(X?X.reloadQuietly():k.ensureSpare()?.ready())?.then(()=>{if(q!==h)return;d=!0;const me=k.spare();me&&Hg(e,me.element),f&&(f=!1,L(),K())})},m=Uv({run:()=>{f||g()?.catch(()=>{})}}),v=()=>{xv(e).noteContentShown(),!d&&!f&&m.start()};let _=!1;const T=k=>{const q=ue(e),X=q?.spare()?.element.contentWindow;u&&q&&X&&k===X&&(u=!1,q.promote(),q.busy(!1),_=!0)};let A=!1;const S=Gv({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:s,revealFilled:()=>{const k=ue(e);return _&&k&&(_=!1,m.start()),a?k?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:T,noteFilled:(k,q)=>ue(e)?.noteFilled(k,q),recoverFailedFill:k=>{const q=ue(e),X=q?.spare()?.element.contentWindow;return!u||!q||!X||k!==X?!1:(u=!1,d=!1,M="reload",q.busy(!1),q.peek("email")?.reload(),A=!0,K(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!i.isTemplate,readSandboxGeneration:()=>_e(n),onSandboxGenerationChange:k=>At(n,k),trackDocument:k=>Vg(e,k),observeShow:k=>e.getInstance(Kv)?.begin(k),describeSurface:()=>({canvasPath:M,promoted:u,spareClean:d,handshake:n.isInited(),generation:_e(n)}),events:{willInit:k=>{pe(e,l.events.WILL_EMAIL_INIT_ID).fire(k)},inited:k=>{v(),pe(e,l.events.ON_EMAIL_INIT_ID).fire(k)},contentChanged:k=>{pe(e,l.events.ON_CONTENT_CHANGED_ID).fire(k)},emailChanged:k=>{pe(e,l.events.ON_EMAIL_CHANGED_ID).fire(k)},browserExtensionDetected:()=>{pe(e,l.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),w=Yv({pipeline:S,initPipeline:o,readEmail:s,readDocument:r,readRouteEmailId:()=>i.emailId,readSandboxGeneration:()=>_e(n)});let D="",I="",R="",M="none";const P=()=>{const k=ue(e)?.spare()?.element.contentWindow;k&&n.getTarget()===k||n.sendNow({operation:l.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!0})},L=()=>{const k=ue(e)?.spare();k&&(P(),d=!1,u=!0,Ug(e,k.element))},x=(k,q)=>{const X=ue(e);if(!X)return!0;const me=X.spare(),Z=me&&d?"spare":"prepare";if(M=Z,X.busy(!0),me&&d)return L(),!0;m.cancel(),P();const tt=g();if(tt===void 0)return M="reload",X.busy(!1),X.peek("email")?.reload(),!0;f=!0;const Fe=h;return tt.catch(()=>{!f||Fe!==h||(f=!1,M="reload",X.busy(!1),X.peek("email")?.reload())}),!1},U=()=>{if(J(t.sessionKey()))return;G(),S.noteSandboxGeneration(_e(n));const k=s(),q=zv(k?.renderGuid,k?.showId,k?.id,i.emailId),X=qv(k?.renderGuid);if(X!==I){const tt=I;I=X;const Fe=ue(e)?.peek("email")?.filled,$T=Fe!==void 0&&Fe!==X;vc(X)&&(vc(tt)||$T)&&x(tt||(Fe??""),X)}if(f)return;(q!==D||A)&&(A=!1,D=q,w.showRequestIdentityChanged());const me=r(),Z=`${q}|${me?.get().docId??""}|${_e(n)}`;Z!==R&&me?.isReady()===!0&&(R=Z,w.selfInitChanged()),w.saasChanged(),te()};let y=!1,E="",N="",F=!1,W=!1;const ee=k=>{k.source==="user"?W=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(F=!0),K()},te=()=>{const k=s();if(!k?.renderGuid)return;const q=S.channel.readContent(),X=JSON.stringify([k.preheader,k.common_styles,k.meta,k.subject,k.utm_parameters?.utm_campaign??"",k.utm_parameters?.utm_content??"",k.utm_parameters?.utm_medium??"",k.utm_parameters?.utm_source??"",k.utm_parameters?.utm_term??""]),me=y&&q!==N,Z=y&&X!==E;y=!0,N=q,E=X;const tt=F&&!W;if(F=!1,W=!1,S.isEventsLocked()||tt)return;const Fe={...k,id:i.isTemplate||k.isNew?void 0:k.id,html:q};if(me){pe(e,l.events.ON_CONTENT_CHANGED_ID).fire(q),pe(e,l.events.ON_EMAIL_CHANGED_ID).fire(Fe);return}Z&&k.is_inited&&pe(e,l.events.ON_EMAIL_CHANGED_ID).fire(Fe)};let ne=!1;const K=()=>{ne||(ne=!0,queueMicrotask(()=>{ne=!1,U()}))};e.inject(ts,{pipeline:S,setRoute:k=>{k.emailId===i.emailId&&!!k.isTemplate==!!i.isTemplate||(i=k,K())}});let $,p;const b=()=>{const k=r()?.get().docId;k!==p&&($?.(),p=k,$=r()?.subscribe(ee)),K()};let C,j;const G=()=>{const k=e.getInstance(l.INIT_PIPELINE_ID);!k||k===C||(j?.(),C=k,j=k.onShowRequested(q=>w.showRequested(q)))},z=n.addListener(k=>{k.data?.operation===l.EVENT_TYPES.SANDBOX_RESIZED&&m.notify()}),V=t.subscribe(b),Y=At(n,K);b(),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{c?.dispose(),j?.(),Y(),V(),$?.(),z.dispose(),m.cancel(),S.stop()})}function Jv(){return l.USEBLOCKS!=="useblocks"}var _c={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:!1,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},Qv={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:!0,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:!1,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}},Ec=_c,Zv=["freeUserBlocks","blocks"],cs={};function e_(e){cs=e}var bc=e=>Zv.includes(e)?Ec:cs[e]??cs.editor??Ec,ls={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:!1,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},t_={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:!0,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:!1,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},n_={...ls,config:{...ls.config,imageCenterFileManagerView:!1}};e_({pro:Qv,editor:t_,simple:Jv()?ls:n_,blocks:_c});function r_(e,t,n=e.getInstance(l.CONFIG_SOURCE_ID)){n?.setMode(t),n?.get()?.codeEnabled===!1&&hc(e).isCodeMode&&os(e,!1)}function s_(e){e.getInstance(l.STANDALONE_ACTIVATED_ID)||e.inject(l.SECURITY_MODULE_ID,void 0)}function Bn(e){return String(e.standaloneKey||"").trim()||void 0}function o_(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function ds(e){return o_(e)?!!Bn(e):!1}function Ut(e){return!!Bn(e)&&!ds(e)}var i_=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function yc(e){return e==="server"?"serverSide":e}function a_({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},s=re();let o={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(){o.kind!=="pending"&&s.set(Vr(r,e))}function u(h){if(o.kind!=="pending")return;clearTimeout(c),o=h;const g=Vr(r,e);s.set(g),i(g)}function f(h,g){r[yc(h)]=g,h==="server"&&o.kind==="pending"?u({kind:"applied"}):d()}return{watch:h=>s.watch(h),select:h=>s.select(h),get:()=>s.get(),ready:()=>a,state:()=>o,layers:()=>({...r}),bootstrap(){const h=Vr(r,e);return Object.fromEntries(i_.map(g=>[g,h[g]]))},merge(h,g){f(g,{...r[yc(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){o.kind==="pending"&&f("server",{...r.serverSide,...h})},dispose(){clearTimeout(c)}}}var c_=5e3,l_="blocks";function d_(){return{...bc(l_)?.config,mergeTags:void 0}}function u_(e,t){e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},s=t.layers().user.mode;t.replace(r.mode===void 0&&s!==void 0?{...r,mode:s}:r,"user")})}function f_(e,t){let n;$r(e).watch(({profile:r})=>{const s=`${r?.theme??""}|${r?.locale??""}`;if(s===n)return;n=s;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function h_(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function p_(e,t){let n,r=!1,s;const o=a=>{s??=An(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&r_(e,a,t)},i=$r(e).watch(({profile:a})=>{const c=a?.email_builder_config,d=h_(c);if(d===void 0||c===n)return;const u=n===void 0;n=c,!(u&&r)&&o(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:s)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,o(c)})}var wc="замкнутый контур: app_init не выполняется";function m_(e,t){if(e.getInstance(l.SECURITY_MODULE_ID)){t.serverAbsent(wc);return}const n=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(r=>{Ut(r)&&t.serverAbsent(wc)});n&&e.getInstance(l.DISPOSABLE_ID)?.addDisposable(n)}async function g_(e,t){if(e.getInstance(hr)===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 v_(e){e.injectFactory(l.CONFIG_SOURCE_ID,(t,n)=>{if(n)return n;const r=a_({base:d_(),env:{modeDefaults:s=>bc(s)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:c_});return u_(e,r),f_(e,r),p_(e,r),m_(e,r),g_(e,r),e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var vt=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 H(e,t,n){const r=l.snapshot(e);return(s,o,i)=>{const a=r(async c=>{const d=t?t(c):c;i&&s.bind(i);const u=await s(d);return n?n(u):u},o,i);return()=>a.dispose()}}var __=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new l.Emitter;this.handleDestroy=H(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new vt(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{}}},us=l.createIdentifier$1("DestroyableService");function E_(e){e.injectFactory(us,(t,n)=>{if(n)return n;const r=e.getInstance(l.DISPOSABLE_ID);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new __({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 b_(e){const t=e.getInstance(us);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var y_=1e3;function Sc(e,t,n=y_,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 s=Object.keys(e),o=Object.keys(t);if(s.length!==o.length)return!1;for(const i of s)if(!Sc(e[i],t[i],n,r+1))return!1;return!0}return!1}function $t(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 s=t[r],o=e[r];Sc(s,o)||(n[r]=s)}return n}var w_=({source:e,emailtags:t,group:n,tags:r,...s})=>s;async function S_(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function I_({emails:e,saveTimeoutMs:t},n,r){const s=t?.()??Tt();let o;try{const i=e.notifySave(n);return await Promise.race([i,new Promise((a,c)=>{o=setTimeout(()=>{const d=new an(s);n.value.id,Of(d,S_(i,r)),c(d)},s)})])}catch(i){throw pi(i),i}finally{o!==void 0&&clearTimeout(o)}}function T_(e){const{emails:t}=e,n=async(r,s)=>{const o=w_(s),i=r===void 0?void 0:await t.cache.getIfPresent(r),a=i?{...i,...o}:o,c=i?$t(i,o):o,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 I_(e,{prev:i,patch:c,value:a,source:s.source??""},d))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const s=await n(void 0,r);return s?.renderGuid?s:{...s,renderGuid:l.generateUUID()}},async updateEmail(r,s){return await n(r,s)}}}var fs=20;function A_(e){const t=C_(e);return e.saveTimeoutMs?O_(t,e.saveTimeoutMs):t}function C_({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:s,integratorProject:o}){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(fs*(c-1),fs*c),page:c,hasMore:d.length>fs*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 xf(await i(a,1),d);if(!u.revision)return _i([],d);const f={...u.revision,parent:a,isAutosave:!0};return _i([f],d,await i(a,1))},async saveAutosave(a,c){const d=await s?.(a),u=o?.();return await e.create({...Hf(c),...d!==void 0?{author:d}:{},...u!==void 0?{project:u}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function O_(e,t,n){return{...e,async saveAutosave(r,s){const o=t();if(o===void 0)return e.saveAutosave(r,s);let i;try{return await Promise.race([e.saveAutosave(r,s),new Promise((a,c)=>{i=setTimeout(()=>c(new Uo(o,n)),o)})])}catch(a){throw pi(a),a}finally{i!==void 0&&clearTimeout(i)}}}}var D_=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}},P_=class extends l.AsyncEmitter{};function rA(e){return e}var Ic=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 s=await t(n);return l.deepEqual(n,s)||this._onChangeEmitter.fire(),s}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(([s,o])=>s)),r=(await this.entries()).filter(([s,o])=>!n.has(s));for(const[s,o]of e)t.push(this.addOrUpdate(s,()=>o)),n.add(s);for(const[s]of r)t.push(this.remove(s));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 R_(e,{filter:t,order:n="asc",orderBy:r,page:s,pageSize:o=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))),s!==void 0&&(e=e.slice(o*(s-1),o*s)),{data:e,filteredTotal:a,total:i,totalPages:Math.ceil(a/o)}}function k_(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 s=t.get(r.id)||{};t.set(r.id,{...s,...r})}return[...t].map(([n,r])=>r)}function N_(e,t){return Tc(e)&&Tc(t)?String(e)===String(t):e===t}function Tc(e){return typeof e=="string"||typeof e=="number"}var L_=class extends l.Disposable{_cache=new Ic;_readEmitter=new l.AsyncEmitter;_saveEmitter=this.addDisposable(new D_);_removeEmitter=this.addDisposable(new P_);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}async confirmedMissing(e){if(!this.hasReadHandler())return!1;const{results:t,errors:n}=await this._readEmitter.fireSettled(e);return!n.length&&!t.some(Boolean)}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new l.Disposable);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Ic),s=n.addDisposable(new l.AsyncEmitter);t=this._foreignCache[e]={get:async(o,i={})=>{await r.getOrCreate(o,async()=>{try{const c=k_(await s.fire(o))||[];for(const d of c)d[e]=o,await this._cache.add(d.id,d);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const d=c[e];return d==null||N_(d,o)});return R_(a,i)},first(o,i={}){return t.get(o,{...i,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:s.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 s=>{const o=s?{...s,...t}:t;if(!r)return t=s?$t(s,t):t,await this._saveEmitter.fire({prev:s,patch:t,value:o,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function Ht(e){const t=l.createIdentifier$1(e);return n=>n.getOrCreateInstance(t,()=>new L_)}function Ac(e){const t=e.getInstance(l.DISPOSABLE_ID);if(!t)throw new Error("Failed");return t}function Cc(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function jn(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function M_(e,t,n){return e&&!Cc(t)&&Cc(e)?{...n,meta:e.meta}:n}var x_=l.createIdentifier$1("CurrentProject"),F_={};function Vt(e){return e?.getInstance(x_)?.get()??F_}function hs(e){const t=Vt(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Oc=Ht("plugin.dataSource.emails"),Dc=Ht("plugin.dataSource.emailRevisions"),Pc=Dn("plugin.readEmailAutosave"),Rc=l.createIdentifier$1("emailDocuments.provided");function B_(e){const t=Oc(e),n=Dc(e),r=n.byForeignKey("parent");if(e.getInstance(Rc))return{emails:t,emailRevisions:n};e.inject(Rc,!0);const s=()=>Tt(e.getInstance(l.INIT_PIPELINE_ID)?.contentReadyTimeoutMs),o=T_({emails:t,saveTimeoutMs:s}),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 uh(e,{...o,createEmail:c=>o.createEmail(c).then(a(Date.now())),updateEmail:(c,d)=>o.updateEmail(c,d).then(a(Date.now(),c))}),mh(e,A_({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const d=await pe(e,Pc).fire(c);return d.length===0?{asked:!1}:{asked:!0,revision:d[0]??null}},savedAt:async c=>{const d=Lf((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:s,integratorProject:()=>Vt(e).requested})),Ac(e).addDisposable(t.onSave(({prev:c,patch:d,value:u})=>M_(c,d,u),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function j_(e){return{handleLoadImage:H(l.getEvent(e,l.events.UPLOAD_EVENT_ID)),handleFileProxy:H(l.getEvent(e,l.events.FILE_PROXY_EVENT_ID)),handleUrlProxy:H(l.getEvent(e,l.events.PROXY_URL_EVENT_ID)),handleAITextRequest:H(l.getEvent(e,l.events.AI_TEXT_REQUEST_ID)),handleAIImageRequest:H(l.getEvent(e,l.events.AI_IMAGE_REQUEST_ID))}}function U_(e){return{handleLoad:H(l.getEvent(e,l.APP_LOAD_EVENT_ID)),...j_(e),handleReadLocale:H(l.getEvent(e,l.events.READ_LOCALE)),handleLimitUsage:H(l.getEvent(e,l.events.ON_LIMIT_ID)),handleTranslate:H(l.getEvent(e,l.events.ON_TRANSLATE_ID))}}function $_(e,t){const n=e.getInstance(l.DISPOSABLE_ID),r=e.getInstance(l.OPTIONS_SOURCE_ID);if(!n||!r)throw new Error(`[plugin] ${t}: время жизни и опции регистрирует bootstrapEarly`);return{lifetime:n,options:r}}function H_(e){const{lifetime:t,options:n}=$_(e,"provideLoadHandler");e.getInstanceAsync(l.INSTANCE_ID).then(r=>{if(t.isDisposed())return;const s=t.addDisposable(new vt(r.handleLoad));t.addDisposable(n.watch(({handleLoad:o})=>s.setListener(o)))},()=>{})}function kc(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 V_(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var G_="po",Un=null;function W_(){const e=typeof __useblocks__<"u"?__useblocks__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([G_],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Y_(){return Un===null&&(Un=W_().catch(e=>{throw Un=null,e})),Un}async function Nc(e){if(typeof e=="object")return ps(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?K_(t):q_(t)}function ps(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function K_(e){try{return ps(JSON.parse(e))}catch{return}}var Lc=!1;async function q_(e){try{return ps((await Y_()).parsePoCatalog(e))}catch{Lc||(Lc=!0);return}}var z_="em_locale",X_="em_ant_locale",J_="locale",Q_="ant_locale";function ms(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Mc(e,t){const n=ms(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function Z_(){return ms("em_locale")??Mc(J_,"em_locale")}function xc(e){try{localStorage.setItem(z_,JSON.stringify(e))}catch{}}function eE(){return ms("em_ant_locale")??Mc(Q_,"em_ant_locale")}function tE(e,t){try{localStorage.setItem(X_,JSON.stringify({id:e,data:t}))}catch{}}var sA="en_US",nE=8e3;function rE(e,t){const n=e,r=t,s=Object.keys(n).filter(o=>o!=="");return s.length!==Object.keys(r).filter(o=>o!=="").length?!1:s.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function sE(e){const t=Z_(),n=eE();let r={ready:!1},s;const o=re(r);let i=0;const a=_=>{r={...r,..._},o.set(r)},c=()=>{r.ready||a({ready:!0})},d=setTimeout(c,e.unlockAfterMs??nE),u=_=>_!==i;let f;async function h(_,T){if(n?.id===_&&n.data&&a({antd:n.data}),!f)return;const A=await f(_).catch(()=>{});!A||u(T)||(a({antd:A}),tE(_,A))}async function g(_,T){const A=await e.askHost(_).catch(()=>null);if(u(T))return!0;if(A==null)return!1;const B=await Nc(A);return u(T)||(B&&a({catalog:B}),c()),!0}async function m(_,T){const A=await e.readList();if(u(T))return;if("error"in A){a({failure:{kind:"GET_LOCALES_ERROR",error:A.error}}),c();return}const B=A.data.find(S=>S.locale===_);if(!B){V_("em_locale")&&a({catalog:void 0}),c();return}if(kc(t,B)&&(!s||s.catalog===t?.data)){c();return}if(s?.entry&&r.catalog===s.catalog&&kc(s.entry,B)){xc(s.entry),c();return}const O=await e.readCatalog(_);if(!u(T)){if("error"in O){a({failure:{kind:"GET_LOCALE_ERROR",error:O.error}}),c();return}O.data&&(s?.id===_&&r.catalog===s.catalog&&rE(s.catalog,O.data)||a({catalog:O.data}),xc({id:_,time:B.updatedAt||Math.floor(Date.now()/1e3),hash:B.contentHash,data:O.data})),c()}}async function v(_,T){if(!await g(_,T)){if(!u(T)&&(s?.id===_&&r.catalog===s.catalog||_==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await m(_,T)}}return{set(_){if(!_||_===r.id)return;const T=i+=1;a({id:_,failure:void 0});const A=s?.id===_&&r.catalog===s.catalog;(s&&!A&&r.catalog===s.catalog||_==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===_&&t.data&&(a({catalog:t.data}),c()),h(_,T),v(_,T)},prime(_,T,A){r.id&&r.id!==_||r.catalog||!T||(s=t?.id===_&&t.data&&(!A||t.time>=A.time)?{id:_,catalog:t.data}:{id:_,catalog:T,entry:A?{id:_,time:A.time,hash:A.hash,data:T}:void 0},a({catalog:s.catalog}))},useAntdLoader(_){f=_,r.id&&h(r.id,i)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(d)}}var oE=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})},Fc=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),iE=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:s,format:o,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=s&&this.toQueryString(s),h=this.contentFormatters[r||"application/json"],g=o||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 m=>{const v=m;v.data=null,v.error=null;const _=g?m.clone():m,T=g?await _[g]().then(A=>(v.ok?v.data=A:v.error=A,v)).catch(A=>(v.error=A,v)):v;return a&&this.abortControllers.delete(a),T})}},aE=l.createIdentifier$1("rest.v2.transport"),Bc=Symbol("rest.v2.secureRequest");function cE(e){return e.getOrCreateInstance(aE,()=>{const t=e.getInstance(l.CUSTOM_FETCH_ID)?.execute||fetch;return new iE({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[Bc]:!0}),customFetch:(n,r={})=>{const{[Bc]:s,...o}=r;return t(n,{...o,[l.PUBLIC_REQUEST]:s!==!0})}})})}function jc(e,t){const n=cE(e);return Object.assign({},...t.map(r=>new r(n)))}function Uc(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function $n(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:Uc(n.details,"wp_code")??n.code,message:Uc(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 $c(e){return!e.ok||!!e.error}function Hc(){return Go(l.LOCAL_STORAGE_ITEMS.em_translations_v2)??!0}function lE(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function dE(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function uE(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],s=r[0];return typeof s=="string"&&s!==""&&t.push({locale:s,updatedAt:lE(r[1])}),t},[]):[]}function fE(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:dE(n.updated_at),contentHash:n.content_hash}),t),[])}function Vc(e){return jc(e,[oE])}function Hn(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function gs(e){return!e.ok||e.error!=null}function vs(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function _s(e){return{data:await Nc(e)??null}}async function hE(e){if(Hc())try{const n=await Vc(e).localesList();return $c(n)?{error:$n(n)}:{data:fE(n.data)}}catch(n){return Hn(n)}const t=l.getApi(e,[To]);try{const n=await t.get_translations2({file:"react_app"});return gs(n)?vs(n):{data:uE(n.data)}}catch(n){return Hn(n)}}async function pE(e,t){if(Hc())try{const r=await Vc(e).jsonList({locale:t});return $c(r)?{error:$n(r)}:_s(r.data)}catch(r){return Hn(r)}const n=l.getApi(e,[To]);try{const r=await n.get_translations3({id:t,file:"react_app"});return gs(r)?vs(r):_s(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return gs(r)?vs(r):_s(r.data)}catch(r){return Hn(r)}}}var Vn=new WeakMap;function mE(e){const t=Vn.get(e);if(t!==void 0)return t;const n=hE(e).then(r=>("error"in r&&Vn.delete(e),r),r=>{throw Vn.delete(e),r});return Vn.set(e,n),n}var Je=l.createIdentifier$1("locale.service");function gE(e){if(e.getInstance(Je))return;const t=sE({readList:()=>mE(e),readCatalog:n=>pE(e,n),askHost:async n=>(await pe(e,l.events.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(l.SECURITY_MODULE_ID)});e.inject(Je,t),e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>t.dispose())}function vE(e){const t=e.getInstance(l.CONFIG_SOURCE_ID);if(!t)return;const n=e.getInstance(Je);if(!n)return;const r=t.select(s=>s.locale).watch(s=>n.set(s||"en_US"));e.getInstance(l.DISPOSABLE_ID)?.addDisposable(r)}var _E="user_id",EE="project_id",Gc=l.createIdentifier$1("rest.identityHeadersProvided");function bE(e){if(e.getInstance(Gc))return;e.inject(Gc,!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 s=t?.user?.id??ga(e).profile?.id;s!=null&&s!==""&&n.headers.set(_E,String(s));const o=t?.project;o!=null&&o!==""&&n.headers.set(EE,String(o))}})}function yE(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function wE(e){return e.id??yE(e.catalog)}function SE(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function IE(e){return SE(e||"en_US")}var TE="Accept-Language",Wc=l.createIdentifier$1("rest.localeHeaderProvided");function AE(e){e.getInstance(Wc)||(e.inject(Wc,!0),e.addService(l.REQUEST_HANDLER_ID,{execute(t){const n=e.getInstance(Je)?.snapshot();t.headers.set(TE,IE(n&&wE(n)))}}))}function CE(e){if(!e)return!1;try{return e.getInstance(l.SECURITY_MODULE_ID)!==void 0}catch{return!1}}var OE="Invalid standaloneKey.",oA=l.createIdentifier$1("StandaloneMockGuard");function DE(){const e=new Error(OE);return e.name="InvalidStandaloneKeyError",e}function PE(e){e.addService(l.REQUEST_HANDLER_ID,{execute:()=>{if(CE(e))throw DE()}})}function RE(e){l.registerRestTransport(e),PE(e)}function kE(e){const t=new $a;e.inject(l.INIT_PIPELINE_ID,t);const n=e.getInstance(l.OPTIONS_SOURCE_ID)?.watch(s=>{if(!s)return;const o=s.signal??t.externalSignal;t.configure({replaceSession:!0,...s.timeouts!==void 0?{timeouts:s.timeouts}:{},...o!==void 0?{signal:o}:{}})}),r=e.getInstance(l.DISPOSABLE_ID);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var Yc=Ht("plugin.dataSource.blocks"),NE=Ht("plugin.dataSource.blockRevisions"),LE=Ht("plugin.dataSource.comments"),ME=Dn("plugin.readTemplateBlocks"),xE=Dn("plugin.readCommonBlocks"),FE=e=>e.replaceAll("&","&").replaceAll("<","<");function Kc(e=""){return`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
2109
|
+
`));return{html:tE(t.html),hasBrowserExtensionArtifacts:t.found}}function tn(e){return e?.getContent()??""}function al(e,t){e?.mutate({content:cs(t)},{source:"remote"})}function er(e){return d.createIdentifier(e)}function me(e,t){return e.getOrCreateInstance(t,()=>new d.AsyncEmitter)}function Z(e,t){return e.getOrCreateInstance(t,()=>new d.AsyncEmitter).event}function tr(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var nE=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 rE(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 sE(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(d.throwIfAborted(n),new Promise((r,s)=>{let o=!1,i,a;const c=u=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),a?.dispose(),n?.removeEventListener("abort",l),u())},l=()=>{c(()=>s(d.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(()=>s(new nE(t)))},t)),n?.addEventListener("abort",l)}))}var cl=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 ll(e,t,n){return t<=0?e:new Promise((r,s)=>{let o=!1,i;const a=c=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),c())};i=setTimeout(()=>{a(()=>s(new cl(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>s(c))})})}var oE=2,nn=Symbol("sandbox:frame-replaced");function dl(e){return e===nn}function Ze(e,t,n,r,s,o,i){const a=`sandbox:${t}`,c=o?.getSandboxTimeoutMs(t)??Qr[t],l=()=>{let p=ll(e.sendAsync(n,r),c,a);return p=d.raceWithAbortSignal(p,o?.signal),Ke(a,p,s)};if(t==="INIT_START"&&rE(e)){const p=o?.getSandboxReadyTimeoutMs()??2e4,_=e,v=A=>{const C=sE(_,p,o?.signal);return Ke("sandbox:INIT_START:ready-wait",C,s).then(()=>{if(!i||A<=0)return l();const P=i.getGeneration();let I;const S=new Promise((D,T)=>{I=i.onChange(()=>{i.getGeneration()!==P&&T(nn)})}),w=l();return w.catch(()=>{}),Promise.race([w,S]).finally(()=>I?.()).catch(D=>{if(D!==nn)throw D;return{...s},v(A-1)})})};return v(oE)}if(!i)return l();const u=i.getGeneration();let f;const h=new Promise((p,_)=>{f=i.onChange(()=>{i.getGeneration()!==u&&_(nn)})}),g=l();return g.catch(()=>{}),Promise.race([g,h]).finally(()=>f?.()).catch(p=>{throw p===nn&&{...s},p})}var ul="self-init:";function iE(e){return e.startsWith(ul)}function ks(e,t){const n=e.getActiveShowRequest();return iE(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function aE(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),s=()=>e.frameWatch?.();let o="",i;const a=p=>{i={target:e.readTarget?.(),docId:p}},c=()=>e.readDocument()?tn(e.readDocument()):o,l=()=>Be(e.container).editorPolicy,u=()=>e.readEmail(),f=()=>{const p=u();return{...p,id:e.isTemplate()||p.isNew?void 0:p.id,html:c()}};let h=!1;const g={readContent:c,publicEmail:f,sendInitStart:()=>Ze(n,"INIT_START",q.SANDBOX_INIT_START,{guid:u().renderGuid},void 0,r()),sendInited:()=>Ze(n,"INITED",q.SANDBOX_INITED,{guid:u().renderGuid},void 0,r(),s()),async sendContent(){const p=u(),{html:_,hasBrowserExtensionArtifacts:v}=il(p?.html||"");v&&e.events.browserExtensionDetected(),al(e.readDocument(),_),o=_,a(p.renderGuid),await Ze(n,"SET_ENTITY",q.SANDBOX_SET_ENTITY,tr(c(),p.renderGuid,l(),e.readDocument()?.get().version),{guid:p.renderGuid,emailId:p.id??null},r(),s())},refreshContent:()=>(a(u().renderGuid),Ze(n,"SET_ENTITY",q.SANDBOX_SET_ENTITY,tr(c(),u().renderGuid,l(),e.readDocument()?.get().version),void 0,r(),s())),sendPreheader:async()=>{const p=u();if(p.preheader!==void 0)return Ze(n,"PREHEADER",q.SANDBOX_PREHEADER_UPDATE,{value:p.preheader,guid:p.renderGuid,force:!0},void 0,r(),s())},sendSubject:async()=>{const p=u();if(p.subject!==void 0)return Ze(n,"SUBJECT",q.SANDBOX_SUBJECT_UPDATE,{value:p.subject,guid:p.renderGuid,force:!0},void 0,r(),s())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:p=>e.showFilled?.(p),noteFilled:(p,_)=>e.noteFilled?.(p,_),contentSent:()=>i,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(f()),fireInit(p,_){if(!ks(t(),p)){t().getActiveShowRequest()?.showId;return}const v=u();v.id,v.renderGuid,t().completeShow(p);const A=e.readDocument();Et(A,{is_inited:!0},{source:"system"});const C=()=>{const I=f();_&&(I.reset=!0);const S=e.events.inited(I);return _||(h&&g.fireEmailChanged(),h=!0),S};if(!A||A.isReady())return C();const{docId:P}=A.get();return A.whenReady().then(()=>e.readDocument()?.get().docId===P?C():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(f())},fireContentChanged(){e.events.contentChanged(c())}};return g}var cE=class extends Error{showId;constructor(e,t){super(`[useblocks] show() timed out after ${t}ms waiting for editor init (showId=${e}). Check earlier console errors: wrong host-plugin publicPath (chunks return HTML), mount element removed without destroy(), or sandbox init never completed. Search for [show-pipeline] and [AMD] messages.`),this.name="ShowPipelineTimeoutError",this.showId=e}},lE=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(d.createAbortError("Superseded by newer show()")),n.aborted?Promise.reject(d.createAbortError(n.reason)):(this._activeRequest=e,new Promise((r,s)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{s(new cE(e.showId,t))})},t);o.unref?.();const i=()=>{this._settle(e.showId,()=>{s(d.createAbortError(n.reason))})};n.addEventListener("abort",i,{once:!0});const a=()=>{clearTimeout(o),n.removeEventListener("abort",i)};this._pending.set(e.showId,{request:e,resolve:r,reject:s,timeoutId:o,dispose:a});for(const c of this._listeners)c(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function dE(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function uE(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=oa(e),n=ia(e),r=Mp(e.sandbox);t<n+r}var fl=class{_controller=new AbortController;_externalSignalDisposable=new d.Disposable;_sessionChangeListeners=new Set;_showRegistry=new lE;_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 oa(this._timeouts)}getSandboxTimeoutMs(e){return sa(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return ia(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=dE(this._timeouts,e.timeouts),uE(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 d.Disposable,this._linkExternalSignal(e)}abort(e){const t=e??d.createAbortError("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new d.Disposable}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new d.Disposable,this._showRegistry.rejectAll(d.createAbortError("Init session replaced")),this._controller.signal.aborted||this._controller.abort(d.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??d.createAbortError()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??d.createAbortError()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Ns=(()=>{const e=new fl;return e.configure({}),e})();function et(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 tt(e){return!e||e==="none"}function fE(e){const t=e.contain??"",n=e.willChange??"";return!tt(e.transform)||!tt(e.perspective)||!tt(e.filter)||!tt(e.backdropFilter)||!tt(e.translate)||!tt(e.rotate)||!tt(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function hl(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 hE(e){const t=[],n=document.documentElement,r=hl(getComputedStyle(n)),s=r.x||r.y;let o="none";const i=getComputedStyle(e).position;(i==="absolute"||i==="fixed")&&(o=i);for(let a=et(e);a&&a!==n;a=et(a)){const c=getComputedStyle(a),l=o==="none"||fE(c)||o==="absolute"&&!!c.position&&c.position!=="static",u=a===document.body&&!s;if(l){o="none";const f=u?{x:!1,y:!1}:hl(c);(f.x||f.y)&&t.push({node:a,...f})}(c.position==="absolute"||c.position==="fixed")&&(o==="none"||c.position==="fixed")&&(o=c.position==="fixed"?"fixed":"absolute")}return t}function pl(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 nr(e){return Number.parseFloat(e)||0}function Ls(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=pl(e),s=nr(n.borderLeftWidth),o=nr(n.borderTopWidth),i=nr(n.borderRightWidth),a=nr(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-s-i):0,l=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-o-a):0;return{left:t.left+s*r.x,top:t.top+o*r.y,right:t.right-(i+c)*r.x,bottom:t.bottom-(a+l)*r.y}}function pE(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},s=(o,i,a)=>{i&&(r.left=Math.max(r.left,o.left),r.right=Math.min(r.right,o.right)),a&&(r.top=Math.max(r.top,o.top),r.bottom=Math.min(r.bottom,o.bottom))};return t.forEach(o=>s(Ls(o.node),o.x,o.y)),n&&s(Ls(n),!0,!0),r}var xs={originX:0,originY:0,scaleX:1,scaleY:1};function rr(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 ml(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,s=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*s,scaleX:r,scaleY:s}}function gl(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 mE=1e3;function gE(e){const{slot:t,own:n}=e;let r,s=0,o=!1;const i=()=>{if(r=void 0,!o){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<s)&&(r=window.requestAnimationFrame(i))}},a=()=>{!o&&r===void 0&&(r=window.requestAnimationFrame(i))},c=()=>{s=performance.now()+mE,a()},l=[window],u=[document.documentElement];for(let v=t;v;v=et(v)){const A=v.getRootNode();A instanceof ShadowRoot&&!l.includes(A)&&(l.push(A),u.push(A))}const f=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];l.forEach(v=>f.forEach(([A,C])=>v.addEventListener(A,C,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const h=typeof MutationObserver=="function"?new MutationObserver(v=>{v.some(A=>!n.contains(A.target))&&a()}):void 0;u.forEach(v=>h?.observe(v,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let g;try{if(typeof ResizeObserver=="function"){const v=new ResizeObserver(a);typeof v.observe=="function"&&(g=v)}}catch{g=void 0}let p=[];return{schedule:a,observe:v=>{!g||v.length===p.length&&v.every((A,C)=>A===p[C])||(g.disconnect(),p=v,v.forEach(A=>g?.observe(A)))},dispose(){o=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),l.forEach(v=>f.forEach(([A,C])=>v.removeEventListener(A,C,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),h?.disconnect(),g?.disconnect()}}}var _E="pluginZoom",vE=/^(?:ant|vscode|monaco|docs)-/;function EE(e){return vE.test(e)}function bE(){const e="ub".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var yE=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function wE(){return yE}var SE=new Set;function IE(e,t,n=SE){return e.startsWith(`${t}-`)?!1:!EE(e)&&!n.has(e)}function AE(e,t){return`--${t}-${e}`}function _l(e){const t=bE();return IE(e,t,wE())?AE(e,t):`--${e}`}function TE(e,t){const n=_l(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function vl(e,t){return TE(e,t)}var El=300,bl=15e3,CE=5e3,yl="em-canvas-busy-style";function OE(){if(document.getElementById(yl))return;const e=document.createElement("style");e.id=yl,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var DE="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 PE(e){const t=vl("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(_l("colorPrimary")).trim()||t}function wl(e){OE();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",DE),n.appendChild(r);const s=document.createElement("span");return s.setAttribute("role","img"),s.setAttribute("aria-label","loading"),s.setAttribute("style",`display:inline-flex;color:${PE(e)};animation:em-canvas-busy-spin 1s linear infinite`),s.appendChild(n),s}function RE(e,t,n){const r=t??e,s=Math.max(r.left,e.left,0),o=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 o<=s||a<=i?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(s+o)/2-e.left,y:(i+a)/2-e.top}}function kE(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 s={left:n.left,top:n.top,right:n.right,bottom:n.bottom},o=r.getBoundingClientRect();if(o.width>0&&!gl({left:o.left,top:o.top,width:o.width,height:o.height},s)){const i=rr(s,ml(o,rr(s,xs),xs));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=RE(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(wl(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Ms(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(wl(e))},El);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var NE=8e3;function LE(){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 xE(e,t){for(let n=et(e);n;n=et(n)){const r=getComputedStyle(n),s=r.overflowX!=="visible"||r.overflowY!=="visible",o=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(i=>Ot(i)>0);if(s&&o)return n;if(n===t)return null}return null}function Ot(e){return Number.parseFloat(e)||0}function sr(e,t){return Math.abs(e-t)<=1}function ME(e){const t=getComputedStyle(e),n=Ot(t.borderTopWidth),r=Ot(t.borderRightWidth),s=Ot(t.borderBottomWidth),o=Ot(t.borderLeftWidth),i=(a,c,l)=>Math.max(0,Ot(a)-Math.max(c,l));return{...Ls(e),radii:[i(t.borderTopLeftRadius,n,o),i(t.borderTopRightRadius,n,r),i(t.borderBottomRightRadius,s,r),i(t.borderBottomLeftRadius,s,o)]}}function FE(e,t){const n=sr(t.top,e.top),r=sr(t.bottom,e.bottom),s=sr(t.left,e.left),o=sr(t.right,e.right),i=[n&&s?e.radii[0]:0,n&&o?e.radii[1]:0,r&&o?e.radii[2]:0,r&&s?e.radii[3]:0];return i.every(a=>a===0)?"":i.map(a=>`${a}px`).join(" ")}function BE(e,t,n,r,s,o){const i=n.readyTimeoutMs??NE,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",vl(_E,"1"));const c=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(c)),l.setAttribute("allow","clipboard-read; clipboard-write"),l.setAttribute("title","Email content"),l.style.width="100%",l.style.border="0",l.style.display="block",l.style.minHeight="600px",l.src=c,a.appendChild(l),t.appendChild(a),n.mark?.("created"),s||n.onCreated?.(l);const u=new d.Disposable;let f=!1,h,g=!1,p,_,v,A;const C=()=>{clearTimeout(A),A=setTimeout(()=>{g||(g=!0,_?.(new Error(`[canvas] ${e}: документ не загрузился за ${i} мс`)))},i)},P=()=>f?(v=Promise.resolve(),g=!0,v):(g=!1,v=new Promise(($,m)=>{p=$,_=m}),C(),v),I=()=>{if(clearTimeout(A),f=!0,g){v=Promise.resolve();return}g=!0,n.mark?.("loaded"),p?.()};l.addEventListener("load",I),u.addDispose(()=>{clearTimeout(A),l.removeEventListener("load",I)});let S;const w=()=>{S??=n.bindResizer?.(l)},D=()=>{S?.dispose(),S=void 0};let T=null,k=null,x,R=xs,M="",F="",U=0;const y=$=>{const m=JSON.stringify($);return m===M?!1:(M=m,a.style.visibility=$.visibility,a.style.left=`${$.css.left}px`,a.style.top=`${$.css.top}px`,a.style.width=`${$.css.width}px`,a.style.height=`${$.css.height}px`,a.style.borderRadius=$.radius,l.style.width=$.elementWidth>0?`${$.elementWidth}px`:"100%",l.style.transform=$.shiftX!==0?`translate(${$.shiftX}px, ${$.shiftY}px)`:`translateY(${$.shiftY}px)`,!0)};let E=!1;const L=()=>{if(!T)return M="",a.style.visibility="hidden",l.removeAttribute("id"),!1;n.elementId&&(l.id=n.elementId);const $=T.getBoundingClientRect(),m=hE(T),b=k?.isConnected?k:null;x?.observe([T,l,...m.map(ee=>ee.node),...b?[b]:[]]);const O=pE($,m,b),j=Math.max(0,O.right-O.left),V=Math.max(0,O.bottom-O.top),X=getComputedStyle(T).visibility==="visible",G=j<=0||V<=0,K=G?{left:O.left,top:O.top,right:O.left,bottom:O.top}:O,N=G?null:xE(T,b??m[0]?.node??null),Y=N?FE(ME(N),K):"",J=ee=>y({visibility:X&&!E?"":"hidden",css:rr(K,ee),elementWidth:$.width/ee.scaleX,shiftX:($.left-K.left)/ee.scaleX,shiftY:($.top-K.top)/ee.scaleY,radius:Y});let ge=J(R);if(!G){const ee=a.getBoundingClientRect();ee.width>0&&!gl({left:ee.left,top:ee.top,width:ee.width,height:ee.height},K)&&(R=ml(ee,rr(K,R),R),ge=J(R)||ge)}return ge},B=()=>{if(!T)return!1;let $=L();const m=l.getBoundingClientRect().height;m>0&&m!==U&&(U=m,T.style.height=`${m/pl(T).y}px`,$=!0);const b=getComputedStyle(T).pointerEvents;return b!==F&&(F=b,a.style.pointerEvents=b),$},W=()=>{x?.dispose(),x=void 0},te=$=>{x=gE({slot:$,own:a,measure:B,onDetached:W})};let ne=[];const re=($,m)=>{if(k=m,$&&ne.length>0){const b=ne;ne=[],b.forEach(O=>O())}if($===T){$&&!x&&te($),B();return}if(W(),T&&T.style.removeProperty("height"),M="",U=0,F="",T=$,!$){L(),D();return}n.onShown?.(l),te($),B(),w()};u.addDispose(W);const z=$=>{f=!1,h=void 0,o?.(),$&&n.onReload?.(l);let m;g||v===void 0?m=P():(C(),m=v);try{l.contentWindow?.location.reload()}catch{l.src=c}return m};return{element:l,ready(){return v??P()},reload:()=>z(!0),reloadQuietly:()=>z(!1),followReload:()=>{h=void 0,o?.(),n.onReload?.(l)},moveTo($){if(a.parentNode===$)return v??P();f=!1,h=void 0,o?.();let m;return g||v===void 0?m=P():(C(),m=v),$.appendChild(a),n.onReload?.(l),M="",x?.schedule(),m},get shown(){return T!==null},get slot(){return T},whenShown(){return T!==null?Promise.resolve():new Promise($=>{ne.push($)})},get filled(){return h},noteFilled($){h=$},alignTo($,m){re($,m??null)},hold($){E!==$&&(E=$,L())},scrollBy($,m){let b=$,O=m;for(let j=T?et(T):null;j;j=et(j)){if(Math.abs(b)<1&&Math.abs(O)<1)return;const V=getComputedStyle(j);if((V.overflowY==="auto"||V.overflowY==="scroll")&&j.scrollHeight>j.clientHeight){const X=j.scrollTop,G=j.scrollLeft;j.scrollBy({left:b,top:O,behavior:"instant"}),b-=j.scrollLeft-G,O-=j.scrollTop-X}}(Math.abs(b)>=1||Math.abs(O)>=1)&&window.scrollBy({left:b,top:O,behavior:"instant"})},resize(){S?.resize()},dispose(){re(null,null),D(),u.dispose(),a.remove()}}}function jE(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",s=(R,M)=>R==="email"?`email:${M??n}`:R,o=new Map;let i,a=[],c=!1,l,u,f=!1,h,g,p="shown",_=0,v,A,C;const P=R=>u!==void 0&&R.filled!==void 0&&R.filled!==u,I=()=>{v=void 0;const R=h;!f||!R||u===void 0||A===u||!P(R)||(A=u,e.onForeignDocument?.({wanted:u,filled:R.filled,role:p,heldMs:Date.now()-_}))},S=()=>{f=!1,h=void 0,g=void 0,clearTimeout(v),v=void 0},w=(R,M)=>{const F=o.get("email"),U=F?.slot??null;return R&&U&&P(R)?(R.alignTo(null),f||(f=!0,_=Date.now(),v=setTimeout(I,CE)),p=M,h=R,!(i!==void 0||c)&&g!==R&&(g=R,e.onShown?.(R.element)),!l&&!i&&(l=Ms(U)),!1):(f&&(S(),l?.remove(),l=void 0),R?.alignTo(U,F?.clip??null),!0)},D=()=>{f&&!c&&w(t.get(s("email")),"shown")},T=()=>{a.forEach(R=>clearTimeout(R)),a=[],i?.remove(),i=void 0,l?.remove(),l=void 0,(c||f)&&(c=!1,w(t.get(s("email")),"shown"))},k=(R,M,F)=>{const U=s(R,M),y=t.get(U);if(y)return y;const E=e.resolveMount();if(!E)return LE();const L=BE(R,E,e,R==="email"?M??n:void 0,F,R==="email"?()=>D():void 0);return t.set(U,L),L},x={get:R=>k(R),current:R=>k(R),peek:R=>t.get(s(R)),spare:()=>t.get(s("email",r())),ensureSpare:()=>k("email",r(),!0),promote(){const R=t.get(s("email",r()));if(!R)return;const M=t.get(s("email"));n=r(),C=void 0,w(R,"spare"),M?.alignTo(null)},alignSurface(R,M,F){const U=o.get(R);if(o.set(R,{slot:M,clip:F??null}),R==="email"&&c){l?.remove(),l=M?Ms(M):void 0;return}const y=M?k(R):t.get(s(R));if(R!=="email"){y?.alignTo(M,F??null);return}if(!M){C=U?.slot&&y?.shown?{slot:U.slot,handle:y}:void 0,f&&(S(),l?.remove(),l=void 0),y?.alignTo(null);return}const E=C?.slot===M&&C.handle===y;if(C=void 0,U?.slot===M&&y?.shown||E){y?.alignTo(M,F??null);return}w(y,"shown")},want(R){u=R,R!==void 0&&D()},noteFilled(R,M){const F=x.byWindow(R);F&&(F.noteFilled(M),F===t.get(s("email"))&&D())},visible(){for(const R of t.values())if(R.shown)return R},byWindow(R){if(R){for(const M of t.values())if(M.element.contentWindow===R)return M}},busy(R){if(T(),!R)return;if(!x.visible()){c=!0,l?.remove(),l=void 0;const U=o.get("email");U?.slot&&(l=Ms(U.slot)),a=[setTimeout(T,bl)];return}const M=e.resolveMount();if(!M)return;const F=kE(M,()=>x.visible()?.element.parentElement?.getBoundingClientRect()??null);i=F,a=[setTimeout(()=>F.showSpinner(),El),setTimeout(T,bl)]},remount(R){T();const M=s("email");t.forEach((F,U)=>{if(U===M){F.moveTo(R).catch(()=>{});return}F.dispose(),t.delete(U)})},dispose(){u=void 0,c=!1,S(),C=void 0,T(),t.forEach(R=>R.dispose()),t.clear(),o.clear(),n="a",u=void 0,A=void 0}};return x}var UE=d.createIdentifier("canvas.resizerBinder"),Fs=d.createIdentifier("canvas.service"),$E={created:he.canvasCreated,loaded:he.canvasLoaded},Sl=new WeakMap;function Bs(e){return Sl.get(e)??0}function HE(e,t){if(e.getInstance(Fs))return;const n=jE({resolveMount:()=>t.resolveMount(),resolveSrc:s=>t.resolveSrc(s),resolveSandbox:Cv,elementId:t.elementId,bindResizer:s=>e.getInstance(UE)?.(s),onCreated:s=>rn(e,s,"fresh"),onReload:s=>{Sl.set(s,Bs(s)+1),rn(e,s,"fresh")},onShown:s=>{const o=n.byWindow(ce(e).getTarget());o&&o.element!==s&&Il(o.element)===Il(s)||rn(e,s,"switch")},mark:s=>t.mark?.($E[s]),onForeignDocument:s=>{({...s},Jp("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:s.role},contexts:{canvasIdentity:{...s,path:window.location.pathname}}}))}}),r=ce(e).addListener(q.SANDBOX_WHEEL,s=>{n.visible()?.scrollBy(s?.deltaX??0,s?.deltaY??0)});e.inject(Fs,n),e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),n.dispose()})}function Il(e){return e.parentElement?.dataset.canvasHost}function rn(e,t,n){const r=ce(e),s=t.contentWindow;if(!s)return;const o=r.getTarget()===s;o&&n==="switch"||(n==="fresh"&&(r.forget(s),o&&r.setTarget(void 0)),r.setTarget(s),Up(r))}function GE(e,t){rn(e,t,"promote")}function VE(e,t){rn(e,t,"switch")}function WE(e,t){const n=t.contentWindow;n&&ce(e).greet(n)}function Al(e,t){const n=t.contentWindow;n&&ce(e).forget(n)}function KE(e,t){const n=fe(e)?.byWindow(t)?.element;if(!n)return;const r=Bs(n);return()=>Bs(n)!==r}function fe(e){return e.getInstance(Fs)}function Tl({attributes:e,readContent:t,docId:n,hasSession:r,serverId:s,show:o}){if(!r)return;const i={id:s??void 0,renderGuid:n,showId:o?.id,isNew:s==null,showToken:o?.token},a={...e,...i};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}function or(e){return{...Tl({attributes:e.get().attributes,readContent:()=>e.getContent(),docId:e.get().docId,hasSession:!0,serverId:e.get().serverId,show:void 0}),html:e.getContent()}}function ir(e){const t=pe(e),n=t.current();if(!n||!Q(t.sessionKey()))return;const r=or(n),s=n.isDirty();me(e,d.events.ON_BLOCK_CLOSE_ID).fire({block:r,hasUnsavedChanges:s})}function qE(e){const t=pe(e);return!t.current()||!Q(t.sessionKey())?!1:(ir(e),t.hasSuspended()?t.resumeSuspended()!==void 0:!1)}function zE(e){const t=pe(e),n=ce(e),r=()=>e.getInstance(d.INIT_PIPELINE_ID)??Ns;let s,o,i=!1,a=!1,c,l;const u=F=>or(F),f=()=>{const F=P(),U=F?.get().docId;if(!F||!U||U!==c||i)return;const y=F.get().version;y!==l&&(l=y,me(e,d.events.ON_BLOCK_CHANGED_ID).fire(u(F)))};let h;const g=F=>{const U=t.showFacts();!U||U.id===h||!ks(F,U.id)||(h=U.id,F.completeShow(U.id))},p=async(F,U,y)=>{const E=y.generation,L=()=>y.generation!==E||y.signal.aborted||t.current()!==F||a,B=ye(n);let W;const te=new Promise(re=>{W=Vt(n,()=>re("regenerated"))}),ne=async(...re)=>await Promise.race([Ze(...re).then(()=>"sent"),te])==="sent";i=!0;try{if(!await ne(n,"INIT_START",q.SANDBOX_INIT_START,{guid:U},void 0,y)||L())return;const{html:re,hasBrowserExtensionArtifacts:z}=il(tn(F));if(z&&me(e,d.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),al(F,re),!await ne(n,"SET_ENTITY",q.SANDBOX_SET_ENTITY,tr(tn(F),U,Be(e).editorPolicy,F.get().version),void 0,y)||L()||!await ne(n,"INITED",q.SANDBOX_INITED,{guid:U},void 0,y)||L())return;s=U,o=B,I(),l=F.get().version,c!==U&&(c=U,me(e,d.events.ON_BLOCK_INIT_ID).fire(u(F))),g(y)}finally{W?.(),i=!1,(ye(n)!==B||t.current()!==F)&&D()}};let _,v,A;const C=()=>{const F=fe(e)?.peek("block");return F?.reload?(F.reload().catch(()=>{}),!0):!1},P=()=>Q(t.sessionKey())?t.current():void 0,I=()=>{const F=P()?.get().docId,U=!F||A===F||s===F&&o===ye(n);fe(e)?.peek("block")?.hold(!U)},S=()=>{if(a||(I(),f(),i))return;const F=P(),U=F?.get().docId;if(!F||!U)return;if(s===U&&o===ye(n)){g(r());return}if(!F.isReady())return;const y=r();y.signal.aborted||s!==void 0&&s!==U&&_!==U&&(_=U,C())||p(F,U,y).catch(()=>{if(!(a||t.current()!==F)){if(v!==U){v=U,C();return}A=U,I()}})};let w=!1;const D=()=>{w||a||(w=!0,queueMicrotask(()=>{w=!1,S()}))};let T,k;const x=()=>{const F=P(),U=F?.get().docId;U!==k&&(T?.(),k=U,T=F?.subscribe(D)),I(),D()},R=t.subscribe(x),M=Vt(n,()=>{I(),D()});x(),e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{a=!0,M(),T?.(),R()})}function YE(e){const t=pe(e);let n="email";const r=()=>{if(!t.current())return;const o=Q(t.sessionKey())?"block":"email",i=fe(e);if(o===n||!i)return;n=o;const a=i.peek(o);if(a){VE(e,a.element);return}i.get(o)},s=t.subscribe(r);e.getInstance(d.DISPOSABLE_ID)?.addDispose(s)}var XE=200;function JE({startVersion:e,limit:t=XE}){let n=[],r=e;const s=o=>{n=n.filter(i=>i.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&s(n[n.length-t-1].version))},rebase(o,i){if(i<r)return null;const a=n.filter(l=>l.version>i);s(i);let c=o;for(const l of a){if(l.contentReplaced||!l.changes)return null;const u=l.changes,f=[];for(const h of c){if(l.fromCanvas&&u.some(p=>h.range.start<=p.oldEnd&&h.range.end>=p.oldPosition))return null;const g=wa(h.range,u,"after");if(!g)return null;f.push({range:g,text:h.text})}c=f}return c}}}function QE(e,t){let n=0;return e.map(({start:r,end:s,text:o})=>{const i=new Ce(r,t.slice(r,s),r+n,o);return n+=o.length-(s-r),i})}function ZE(e,t){const n=[...e].sort((r,s)=>r.range.start-s.range.start);return QE(n.map(({range:r,text:s})=>({start:r.start,end:r.end,text:s})),t)}function eb(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var tb=32;function nb(e=tb){const t=new Map;return{find(n,r){const s=t.get(n);return s&&es(s.scope,r)?s.echo:void 0},remember(n,r,s){t.delete(n),t.set(n,{scope:r,echo:s}),t.size>e&&t.delete(t.keys().next().value)},echoes(n){return[...t.values()].filter(r=>es(r.scope,n)).map(r=>r.echo)}}}function rb(e,t){const n=wp(e,t);return n?[{range:{start:n.start,end:n.fromEnd},text:t.slice(n.start,n.toEnd)}]:[]}var js=d.createIdentifier("canvas.sandboxFill");function Cl(e){return e.getInstance(js)?.pipeline.isEventsLocked()===!0}var gD=.2,sb=/<(style|script|template|noscript|textarea)\b[^>]*>[\s\S]*?<\/\1\s*>|<!--[\s\S]*?-->/gi,ob=/<\/?[a-zA-Z]/g;function Ol(e){return e.match(ob)?.length??0}function Dl(e){return[...e.matchAll(sb)].map(t=>[t.index,t.index+t[0].length])}function Us(e,t,n){let r=0,s=0;for(const[o,i]of n){for(;s<t.length&&t[s][1]<=o;)s++;let a=o;for(let c=s;c<t.length&&t[c][0]<i;c++)r+=Ol(e.substring(a,Math.max(a,t[c][0]))),a=Math.max(a,t[c][1]);r+=Ol(e.substring(Math.min(a,i),i))}return r}function Pl(e,t){const n=[...t].sort((c,l)=>c.oldPosition-l.oldPosition||c.oldEnd-l.oldEnd),r=[],s=[],o=[];let i=0,a=0;for(const c of n){const l=e.substring(i,c.oldPosition);r.push(l,c.newText),a+=l.length,s.push([c.oldPosition,c.oldEnd]),o.push([a,a+c.newText.length]),a+=c.newText.length,i=c.oldEnd}return r.push(e.substring(i)),{next:r.join(""),removed:s,inserted:o}}var ib=/<(?:!doctype|html|head|body)\b/i;function ab(e,t){return e.reduce((n,r)=>n+r.oldLength,0)<t.trim().length?!1:ib.test(t)&&!Pl(t,e).next.trim()}function cb(e,t){if(e.reduce((i,a)=>i+a.oldLength,0)<=200)return null;const n=Dl(t),r=Pl(t,e),s=Us(t,n,r.removed)-Us(r.next,Dl(r.next),r.inserted),o=Us(t,n,[[0,t.length]]);return s>100&&s>o*.2?{removed:s,total:o}:null}function nt(e){Wt(e,{origin:"canvas-channel"})}var lb=100;function db(e){const t=e?.data,n=t?.action==="undo"||t?.action==="redo";return t?.operation===q.APPLICATION_ACTION&&n&&typeof t.actionId=="number"?{action:t.action,actionId:t.actionId}:void 0}function ub(e){const t=pe(e),n=ce(e);let r;const s=(c,l)=>{const u=c.get().docId;let f=!1,h=null,g=null,p;const _=JE({startVersion:c.get().version});let v=c.getContent();const A=nb(),C=ha(e),P=C.open(u,()=>c.get().version);let I=!1;const S=b=>({generation:ye(n),originId:b});let w=S(null),D=!0;const T=(b,O)=>{!D||t.current()!==c||(Wt(O,{origin:"canvas-channel"}),g?.splice(0,g.length),n.sendAsync(q.SANDBOX_SET_ENTITY,tr(tn(c),u,Be(e).editorPolicy,c.get().version)).catch(nt))},k=b=>{const O=b[b.length-1],j=[...b].reverse().find(G=>G.answer?.actionId!==void 0)?.answer?.actionId,V=O.answer?.selection,X=j!==void 0||V?{...j!==void 0?{actionId:j}:{},...V?{selection:V}:{}}:void 0;return{edits:b.map(G=>G.edits),guid:u,rev:O.rev,...X?{historyAnswer:X}:{}}},x=()=>{const b=l.activeMove(),O=b&&p?.action===b.kind?p:void 0;if(O&&(p=void 0),!(!O&&!b?.selection))return{...O?{actionId:O.actionId}:{},...b?.selection?{selection:b.selection}:{}}},R=b=>{M({edits:[],rev:c.get().version,answer:{actionId:b.actionId}}).catch(nt)},M=async b=>{if(g){g.push(b);return}g=[b];try{do await n.sendAsync(q.SANDBOX_UPDATE_ENTITY,k(g.splice(0,g.length)));while(g.length)}catch(O){T("app edits failed to reach the canvas",O)}finally{g=null}},F=b=>{b.length&&n.sendAsync(q.SANDBOX_UPDATE_ENTITY,k(b)).catch(nt)},U=(b,O)=>{I=!0,F(g?.splice(0,g.length)??[]);const j={edits:[b],guid:u,rev:c.get().version,...O!==null?{changeId:O}:{}};O!==null&&A.remember(O,w,j),n.sendAsync(q.SANDBOX_UPDATE_ENTITY,j).catch(nt)},y=new Set,E=(b,O,j,V)=>{U([],V);const{length:X,hash:G}=Xr(JSON.stringify(j.map(N=>[N.oldText,N.newText]))),K=`${X}:${G}`;y.has(K)||(y.add(K),T(b,O))},L=(b,O,j)=>E("canvas service batch removes a large part of the email",new Error(`canvas service batch removes ${b.removed} of ${b.total} tags`),O,j),B=({changeId:b,baseRev:O})=>{!I&&(b!==null||O!==null)&&U([],b)},W=b=>{if(b.guid!==u)return;const O=Em(b);I=!1,w=S(O.originId);try{te(b,O)}catch(j){B(O),T("canvas batch failed to apply",j)}finally{B(O),O.changeId!==null&&C.note(O.changeId,w)}},te=(b,O)=>{const{pushUndoStop:j}=b,V=O.changeId!==null?A.find(O.changeId,w):void 0;if(V){I=!0,n.sendAsync(q.SANDBOX_UPDATE_ENTITY,V).catch(nt);return}let{edits:X,selection:G}=b;if(O.baseRev!==null){const K=_.rebase(X,O.baseRev);if(!K){Wt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),U([],O.changeId);return}K!==X&&(G=void 0),X=K}try{f=!0,h=O.changeId;const K=ZE(X,c.getContent());if(ab(K,c.getContent())){E("canvas batch erases the whole email",new Error("canvas batch erases the whole email"),K,O.changeId);return}if(j===!1){const N=cb(K,c.getContent());if(N){L(N,K,O.changeId);return}l.applyWithoutHistory(K)}else l.recordAt(b.typedAt,()=>c.mutate({changes:K},{source:Cl(e)?"system":"user"}),G),b.closesStep&&l.closeGroup()}finally{f=!1,h=null}},ne=c.subscribe(({changes:b,version:O})=>{const j=c.getContent(),V=!b?.length&&j!==v;if(v=j,_.record({version:O,changes:b,contentReplaced:V,fromCanvas:f}),!b?.length)return;const X=eb(b);f?U(X,h):M({edits:X,rev:O,answer:x()}).catch(nt)}),re=n.addListener(q.APPLICATION_UPDATE_ENTITY,W),z=n.addListenerAsyncPipe(An,(b,O)=>{p=db(b);try{return O?.(b)}finally{const j=p;p=void 0,j&&R(j)}},lb),$=(b,O,{reportId:j,dropsCovered:V})=>{const X=g?.splice(0,g.length)??[];n.sendAsync(q.SANDBOX_UPDATE_ENTITY,{edits:[rb(b,O)],guid:u,rev:c.get().version,resync:{textFingerprint:Xr(O),reportId:j}}).catch(G=>T("canvas resync edit failed to reach the canvas",G)),V&&F(X)},m=n.addListener(q.APPLICATION_SYNC_DRIFT,b=>{if(!((b.reason==="echo-timeout"||b.reason==="resync-failed")&&b.guid!==void 0&&b.guid!==u)){if(b.reason==="resync-failed"){T("canvas failed to apply the resync edit",new Error("canvas resync failed"));return}if(b.reason==="echo-timeout"){const{textFingerprint:O}=b,j=tn(c),V=Xr(j);if(O?.length===V.length&&O.hash===V.hash){A.echoes(S(b.originId??null)).forEach(G=>{n.sendAsync(q.SANDBOX_UPDATE_ENTITY,G).catch(nt)}),b.reportId!==void 0&&$(j,j,b);return}const X=new Error(`canvas echo timeout, ${b.unsent??0} edits unsent`);if(b.canvasText===void 0){T("canvas lost the echo of its batch",X);return}$(b.canvasText,j,b)}}});return()=>{D=!1,P(),ne(),re.dispose(),z.dispose(),m.dispose()}};let o;const i=()=>{const c=t.current(),l=t.history(),u=c?.get().docId;u!==o&&(r?.(),r=void 0,o=u,c&&l&&(r=s(c,l)))},a=t.subscribe(i);i(),e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{r?.(),a()})}function fb(e){const t=ce(e),n=()=>fe(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(q.RELOAD,()=>{n()?.followReload()}),s=t.addOffTargetListener(q.RELOAD,a=>{const c=fe(e)?.byWindow(a);c&&Al(e,c.element)}),o=t.addListener(a=>{a.data?.operation===q.SANDBOX_RESIZED&&n()?.resize()}),i=Z(e,d.events.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),s.dispose(),o.dispose(),i.dispose()})}function Rl(){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 hb(e){const t=e.getInstance(d.OPTIONS_SOURCE_ID);let n,r;e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{r?.remove(),r=void 0}),HE(e,{resolveMount:()=>n,resolveSrc:o=>el(o==="block"),elementId:"email_iframe",mark:o=>oe(o)}),t?.watch(o=>{const i=o?.element;if(n&&i instanceof HTMLElement&&i!==n){n=i,fe(e)?.remount(i),r?.remove(),r=void 0;return}if(!n){if(i instanceof HTMLElement)n=i;else if(o!==void 0){n=r??=Rl(),fe(e)?.alignSurface("email",r,r);return}else return;fe(e)?.get("email")}});let s;e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{s?.remove(),s=void 0}),M_(e).watch(o=>{const i=fe(e);if(i){if(o){s??=Rl(),i.alignSurface("email",s,s);return}s&&(i.alignSurface("email",null),s.remove(),s=void 0)}})}var $s=d.createIdentifier("canvas.headerFlow"),kl=["subject","preheader"],Nl=3e3,pb=3,mb={subject:q.SANDBOX_SUBJECT_UPDATE,preheader:q.SANDBOX_PREHEADER_UPDATE};function gb(e){const t=pe(e),n=ce(e),r=S=>S?"remote":Cl(e)?"system":"user",s=(S,{guid:w,value:D,forced:T})=>{const k=vt(t);if(!k||typeof D!="string"||w&&w!==k.get().docId)return;const x=t.forcedHeaders();if(x?.[S]!==void 0&&!T&&D!==x[S])return;const R=k.get().attributes[S];if(!T&&g(S,D,R))return;const M=!T&&f.delete(S);T&&(v.delete(S),v.size===0&&t.endForcedHeaders()),c=!0;try{Et(k,{[S]:D},{source:M?"system":r(T)})}finally{c=!1}o[S]=D};let o={},i,a,c=!1,l=Promise.resolve();const u={},f=new Map,h=(S,w)=>{o[S]=w;const D={};f.set(S,D);const T=()=>{f.get(S)===D&&f.delete(S)};p(S,w,{force:!0}).then(T),setTimeout(T,Nl)},g=(S,w,D)=>{const T=t.showFill();if(!T||typeof D!="string")return!1;const k=u[S]?.showId===T.showId?u[S]:void 0;return w===D?(u[S]=k??{showId:T.showId,codeEdits:T.codeEdits,corrections:0},!1):k&&T.codeEdits>k.codeEdits&&w!==k.stale?!1:((!k||w===k.stale&&k.corrections<pb)&&(u[S]={showId:T.showId,stale:w,codeEdits:T.codeEdits,corrections:(k?.corrections??0)+1},h(S,D)),!0)},p=(S,w,{force:D=!1,echo:T=!1,undoStep:k=!1})=>(l=n.sendAsync(mb[S],{value:w,guid:vt(t)?.get().docId,...D?{force:!0}:{},...T?{echo:!0}:{},...k?{undoStep:!0}:{}}).catch(x=>{}),l);let _;const v=new Set;e.inject($s,{whenDelivered:async()=>{await l},reassert:S=>{const w=vt(t),D=kl.filter(T=>typeof S[T]=="string");if(!(!w||D.length===0)){c=!0;try{Et(w,Object.fromEntries(D.map(T=>[T,S[T]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders(Object.fromEntries(D.map(T=>[T,S[T]]))),clearTimeout(_),_=setTimeout(()=>{v.clear(),t.endForcedHeaders()},Nl),v.clear();for(const T of D)v.add(T);for(const T of D)o[T]=S[T],p(T,S[T],{force:!0,echo:!0})}}});const A=()=>{i?.(),i=void 0;const S=vt(t);if(S!==a&&f.clear(),a=S,!S){o={};return}const w=S.get().attributes;o={subject:w.subject,preheader:w.preheader},i=S.subscribe(({source:D})=>{if(c)return;const T=S.get().attributes,k=t.forcedHeaders();for(const x of kl){const R=T[x];if(R===o[x])continue;o[x]=R,f.delete(x);const M=D==="system"&&k?.[x]!==void 0;p(x,R??"",{force:M,echo:M,undoStep:D==="user"})}})};A();const C=t.subscribe(A),P=n.addListenerAsync(q.APPLICATION_SUBJECT_UPDATE,S=>s("subject",S)),I=n.addListenerAsync(q.APPLICATION_PREHEADER_UPDATE,S=>s("preheader",S));e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{P.dispose(),I.dispose(),C(),i?.(),clearTimeout(_)})}function _b(e){const t=pe(e);let n={document:void 0,seq:0};const r=()=>{const o=t.recoveryFacts(),i=vt(t);if(!o?.applied||!i||String(o.emailId)!==String(i.get().serverId)||(n.document!==i&&(n={document:i,seq:0}),o.applied.seq<=n.seq))return;n={document:i,seq:o.applied.seq};const a=t.shownHeaders();(a.subject!==void 0||a.preheader!==void 0)&&e.getInstance($s)?.reassert(a)},s=t.subscribe(r);e.getInstance(d.DISPOSABLE_ID)?.addDispose(s)}function vb(e,t){return(e&&e!=="system"?e:t?"dark":"light")==="dark"?Tp:Ap}function Eb(e,t,n=!1){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,blocksTemplateEnabled:n}}function bb(e){return e.isCodeMode&&(e.direction==="left"||e.direction==="right")}function Ll(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Hs(e,t){const n={...e};for(const r of Object.keys(t)){const s=t[r],o=e[r];Ll(s)&&Ll(o)?n[r]=Hs(o,s):s!==void 0&&(n[r]=s)}return n}function yb(e,t){const n=Jr;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const s=JSON.parse(r);if(s&&typeof s=="object"&&!Array.isArray(s)&&Object.keys(s).length>0)return Hs(n,s)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?Hs(n,t):n}var wb=se(void 0),xl=wb,Ml=d.createIdentifier("CodeMode");function Fl(){let e;try{const t=window.localStorage?.getItem(Rn.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 Sb(e){try{window.localStorage?.setItem(Rn.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function ar(e){return e.getOrCreateInstance(Ml,()=>{const t=se(Fl());return t.watch(Sb),t})}function Bl(e){return e?.getInstance(Ml)?.get()??Fl()}function Gs(e,t){const n=ar(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function Ib(e,t){const n=ar(e);n.set({...n.get(),direction:t})}var Ab=d.createIdentifier("DefaultCommonStyles");function jl(e){return e.getOrCreateInstance(Ab,()=>se(void 0))}function Tb(e,t){jl(e).set(t)}var Cb=d.createIdentifier("CanvasViewport"),Ob=d.createIdentifier("CanvasPreviewPage"),Db=d.createIdentifier("CanvasTemplateBlocks");function Ue(e,t,n){let r,s;const o=()=>{if(!r||!e.isInited())return;const c=r.value===void 0?"undefined":JSON.stringify(r.value);c!==s&&(s=c,e.send(t,r.value))},i=n.watch(c=>{r={value:c},o()}),a=e.onInit(()=>{s=void 0,o()});return{dispose(){i.dispose(),a.dispose()}}}function cr(e){const t=se(e());return{source:t,refresh:()=>t.set(e())}}function Pb(e){const t=ce(e),n=e.getInstance(d.CONFIG_SOURCE_ID),r=e.getInstance(d.OPTIONS_SOURCE_ID),s=pe(e),o=ar(e),i=matchMedia(Cp),a=()=>n?.get()??{};let c;const l=cr(()=>vb(xl.get()??a().theme,i.matches)),u=e.getOrCreateInstance(Db,()=>se(!1)),f=cr(()=>Eb(a(),Q(s.sessionKey()),u.get()===!0)),h=u.watch(()=>f.refresh()),g=cr(()=>a().lockEditor),p=cr(()=>yb(s.current()?.get().attributes?.common_styles,c)),_=e.getOrCreateInstance(Cb,()=>se()),v=e.getOrCreateInstance(Ob,()=>se()),A=[Ue(t,Fe.theme,l.source),Ue(t,Fe.flags,f.source),Ue(t,Fe.lockEditor,g.source),Ue(t,Fe.commonStyles,p.source),Ue(t,Fe.codeMode,o.select(bb)),Ue(t,Fe.appName,se("useblocks")),Ue(t,Fe.previewPage,v),Ue(t,Fe.viewport,_)],C=()=>{l.refresh(),f.refresh(),g.refresh()},P=n?.watch(C),I=jl(e).watch(R=>{c=R,p.refresh()}),S=r?.watch(R=>{R&&"commonStyles"in R&&(c=R.commonStyles),p.refresh()});let w;const D=()=>{w?.(),w=s.current()?.subscribe(()=>p.refresh()),p.refresh(),f.refresh()};D();const T=s.subscribe(D),k=()=>l.refresh();i.addEventListener("change",k);const x=xl.watch(()=>l.refresh());e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{A.forEach(R=>R.dispose()),P?.dispose(),h.dispose(),I.dispose(),S?.dispose(),w?.(),T(),i.removeEventListener("change",k),x.dispose()})}var Vs;(function(e){function t(s,o,i=(a,c)=>a===c){if(s===o)return!0;if(s.length!==o.length)return!1;for(let a=0;a<s.length;a++)if(!i(s[a],o[a]))return!1;return!0}e.isEqual=t;function n(s,o=i=>i){const i=new Set;return s.filter(a=>{const c=o(a);return i.has(c)?!1:(i.add(c),!0)})}e.unique=n;function r(s=[],o=[],i=(a,c)=>a===c){const a=[],c=[],l=[];for(const u of s){const f=o.find(h=>i(u,h));f?l.push({prev:u,next:f}):c.push(u)}for(const u of o)s.find(f=>i(u,f))||a.push(u);return{added:a,removed:c,exists:l}}e.diff=r})(Vs||(Vs={}));function Rb(e,t){return e.type===t.type&&e.key===t.key}function kb(e){const t=ce(e),n=()=>e.getServices(lt)??[];let r=[];const s=t.onInit(()=>{r=n(),t.send(q.SANDBOX_ADD_EXTENSIONS,r)}),o=d.getServiceContainerId(lt),i=e.onInject(a=>{if(a!==o)return;const c=n();if(!t.isInited()){r=c;return}const{added:l,removed:u}=Vs.diff(r,c,Rb);if(r=c,u.length){if(u.some(f=>f.type==="script")){t.send(q.RELOAD);return}t.send(q.SANDBOX_REMOVE_EXTENSIONS,u.map(f=>f.key))}l.length&&t.send(q.SANDBOX_ADD_EXTENSIONS,l)});e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{s.dispose(),i?.dispose()})}var Nb=new Set([...Object.values(q).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(jr)]);function Lb(e){return e.length>0&&!e.startsWith("em:")&&!Nb.has(e)}function xb(e){const t=ce(e),n=new Map;let r=!1,s=-1,o=new Set;const i=l=>(l!==s&&(s=l,o=new Set),o),a=t.observeOutgoing((l,u)=>{if(!r||!Lb(l))return;const f=ye(t);n.set(l,{data:u,generation:f,scripts:new Set(i(f))})}),c=t.addListener(jr,l=>{if(l.phase!=="ready"||l.status!=="success")return;r=!0;const u=ye(t),f=i(u);f.add(l.key);for(const[h,g]of n)g.generation===u||![...g.scripts].every(p=>f.has(p))||(g.generation=u,t.send(h,g.data))});e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{a.dispose(),c.dispose()})}var Mb=d.createIdentifier("prewarm.editorVisible");function Fb(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Bb(e={}){const t=e.paint??Fb;let n=!1,r=!1,s=!1,o=!1,i=!1;const a=[],c=()=>{i||o||!n||!r||!s||(o=!0,t(()=>{i=!0,oe(he.editorVisible);for(const l of a.splice(0))l()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){s=!0,c()},whenVisible(l){if(i){l();return}a.push(l)},contentShown:()=>s}}function jb(e){return e.getOrCreateInstance(Mb,()=>Bb())}var Ub=500,$b=500,Hb=5e3;function Gb(e){const t=e.quietMs??Ub,n=e.floorMs??$b,r=e.ceilingMs??Hb;let s,o,i=0;const a=()=>{clearTimeout(s),clearTimeout(o),s=void 0,o=void 0},c=()=>{a(),e.run()},l=()=>{clearTimeout(s);const u=n-(Date.now()-i);s=setTimeout(c,Math.max(t,u))};return{start(){a(),i=Date.now(),o=setTimeout(c,r),l()},notify(){s!==void 0&&l()},cancel:a}}var Vb=2;function Ul(){return new Error("[sandbox] document reloaded during fill")}function Wb(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Ws(e){try{e()}catch{}}function Kb(e){let t;return Ws(()=>{t=e()}),{stage:n=>Ws(()=>t?.stage(n)),end:(n,r)=>Ws(()=>t?.end(n,r))}}function qb(e){const t=()=>e.initPipeline();let n=!1,r,s,o,i=0,a,c;const l=()=>{const w=e.readTarget?.(),D=e.readSandboxGeneration?.();return w===void 0||D===void 0?void 0:{target:w,generation:D}},u=()=>{const w=l();return w&&{...w,canvasReplaced:e.trackDocument?.(w.target)}},f=w=>{if(w?.canvasReplaced?.())return!0;const D=l();return w!==void 0&&D?.target===w.target&&D.generation!==w.generation},g=aE({...e,waitScope:()=>({getSandboxTimeoutMs:w=>t().getSandboxTimeoutMs(w),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const w=c;if(!(!w||!e.onSandboxGenerationChange))return{getGeneration:()=>l()?.generation??w.generation,onChange:D=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===w.target||w.canvasReplaced?.())&&D()})??(()=>{})}}});let p;const _=(w,D)=>{if(p===w)return;p=w;const T=i;setTimeout(()=>{i!==T||t().signal.aborted||P(w,D).catch(()=>{})},0)},v=()=>{a?.abort(),a=void 0};let A;const C=()=>{const w=t().signal;w!==A&&(A?.removeEventListener("abort",v),A=w,w.addEventListener("abort",v))};async function P(w,D,T=0){const k=++i;v(),a=new AbortController,c=void 0,C();const x=()=>i!==k,R=g.readTarget(),M=t().generation,F=()=>M===t().generation&&!t().signal.aborted,U=D?"init:reset-":"init:",y=Kb(()=>e.observeShow?.(Wb(w,D,e.readEmail())));if(!D){const re=g.publicEmail();re?.id,re?.renderGuid,re?.preheader}let E=!1,L=!1,B,W=!1;const te=()=>{if(f(B))throw Ul()},ne=()=>{if(x())throw d.createAbortError("Fill superseded")};try{n=!0,await g.sendInitStart(),ne(),B=u(),c=B,T===0&&g.fireWillInit(),await(D||T>0?g.refreshContent():g.sendContent()),E=!0,ne(),te();const re=g.contentSent();g.noteFilled(re?.target,re?.docId),y.stage("content"),D||g.publicEmail()?.id;try{await g.sendPreheader()}catch(z){if(dl(z)||x())throw z;`${U}`,String(z)}ne();try{await g.sendSubject()}catch(z){if(dl(z)||x())throw z;`${U}`,String(z)}if(ne(),te(),g.showFilled(R),await g.sendInited(),ne(),te(),L=!0,s===w){const z=e.readSandboxGeneration?.()??o;z!==void 0&&(r=z)}y.stage("reveal"),await g.revealFilled(),te(),y.end("revealed")}catch(re){const z=!x()&&F()&&f(B),$=z?Ul():void 0,m=$??re,b=z&&T<Vb?S(w,D,T+1):void 0;W=z&&b===void 0;const O=x()?void 0:{showId:w,contentApplied:E,sandboxInitedAcked:L,superseded:!1,...e.describeSurface?.(),error:String($??re)};O&&(`${U}`,void 0);const j=!x()&&e.recoverFailedFill?.(R)===!0;if(y.end(x()?"superseded":j?"recovered":d.isAbortError(m)||!F()?"aborted":"failed",O),!j&&!x()&&ks(t(),w)&&t().failShow(w,m),b!==void 0)return b;throw m}finally{I(w,D,U,{superseded:x(),sessionGeneration:M,contentApplied:E,sandboxInitedAcked:L&&!W,retry:!W,commit:F()})}}function I(w,D,T,k){const{superseded:x,contentApplied:R,sandboxInitedAcked:M}=k;if(x){`${T}`;return}M&&k.commit?g.fireInit(w,D||void 0):M?(`${T}`,k.sessionGeneration,t().generation,t().signal.aborted,void 0):R?(`${T}`,void 0):(`${T}`,void 0),n=!1,a=void 0,!M&&s===w&&(s=void 0,r===o&&(r=void 0)),!M&&R&&k.retry&&_(w,D)}function S(w,D,T){return P(w,D,T)}return{channel:g,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:w=>{r=w},lastCorrelation:()=>s,markCorrelation:w=>{s=w},bumpRunSeq:()=>{i+=1},noteSandboxGeneration:w=>{o=w},fill:w=>P(w,!1),refill:w=>P(w,!0),stop:()=>{i+=1,v(),n=!1,A?.removeEventListener("abort",v),A=void 0}}}function zb(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:$l(e,n)}function $l(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Yb(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:s,readSandboxGeneration:o}=e,i=u=>{const f=n(),h=s();if(!zb(f,u,h)){u.showId,u.navId,u.emailId,f?.id,f?.showId,f?.renderGuid;return}u.showId,f?.id,f?.renderGuid,t.markFilled(o()),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=o();if(t.filledGeneration()===u)return;const f=n(),h=s();if(!f?.renderGuid||!$l(f,h))return;const g=`${ul}${f.renderGuid}`;t.markFilled(u),t.markCorrelation(g);const p=r()?.isReady()===!0;f.id,f.renderGuid,(p?_=>t.refill(_):_=>t.fill(_))(g).catch(()=>{t.lastCorrelation()===g&&t.markFilled(void 0)})},saasChanged:()=>{const u=n();u?.renderGuid,u?.showToken,u?.id,r()}}}var Xb=d.createIdentifier("canvas.health");function Jb(e){return e??""}function Qb(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Hl(e){return e.length>0}function Zb(e){const t=pe(e),n=ce(e),r=()=>Q(t.sessionKey())?void 0:t.current(),s=()=>{const N=r();return Tl({attributes:N?.get().attributes??{},readContent:()=>N?.getContent(),docId:N?.get().docId,hasSession:!!N,serverId:N?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(d.INIT_PIPELINE_ID)??Ns;let i={},a=!1;const c=e.getInstance(d.OPTIONS_SOURCE_ID)?.watch(N=>{a=!!N?.element});let l=!1,u=!1,f=!1,h=0;const g=()=>{const N=fe(e);if(!N)return;const Y=++h,J=N.spare();return J&&Al(e,J.element),(J?J.reloadQuietly():N.ensureSpare()?.ready())?.then(()=>{if(Y!==h)return;l=!0;const ge=N.spare();ge&&WE(e,ge.element),f&&(f=!1,M(),z())})},p=Gb({run:()=>{f||g()?.catch(()=>{})}}),_=()=>{jb(e).noteContentShown(),!l&&!f&&p.start()};let v=!1;const A=N=>{const Y=fe(e),J=Y?.spare()?.element.contentWindow;u&&Y&&J&&N===J&&(u=!1,Y.promote(),Y.busy(!1),v=!0)};let C=!1;const S=qb({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:s,revealFilled:()=>{const N=fe(e);return v&&N&&(v=!1,p.start()),a?N?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:A,noteFilled:(N,Y)=>fe(e)?.noteFilled(N,Y),recoverFailedFill:N=>{const Y=fe(e),J=Y?.spare()?.element.contentWindow;return!u||!Y||!J||N!==J?!1:(u=!1,l=!1,x="reload",Y.busy(!1),Y.peek("email")?.reload(),C=!0,z(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!i.isTemplate,readSandboxGeneration:()=>ye(n),onSandboxGenerationChange:N=>Vt(n,N),trackDocument:N=>KE(e,N),observeShow:N=>e.getInstance(Xb)?.begin(N),describeSurface:()=>({canvasPath:x,promoted:u,spareClean:l,handshake:n.isInited(),generation:ye(n)}),events:{willInit:N=>{me(e,d.events.WILL_EMAIL_INIT_ID).fire(N)},inited:N=>{_(),me(e,d.events.ON_EMAIL_INIT_ID).fire(N)},contentChanged:N=>{me(e,d.events.ON_CONTENT_CHANGED_ID).fire(N)},emailChanged:N=>{me(e,d.events.ON_EMAIL_CHANGED_ID).fire(N)},browserExtensionDetected:()=>{me(e,d.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),w=Yb({pipeline:S,initPipeline:o,readEmail:s,readDocument:r,readRouteEmailId:()=>i.emailId,readSandboxGeneration:()=>ye(n)});let D="",T="",k="",x="none";const R=()=>{const N=fe(e)?.spare()?.element.contentWindow;N&&n.getTarget()===N||n.sendNow({operation:q.SANDBOX_LOCK_EDIT,data:!0})},M=()=>{const N=fe(e)?.spare();N&&(R(),l=!1,u=!0,GE(e,N.element))},F=(N,Y)=>{const J=fe(e);if(!J)return!0;const ge=J.spare(),ee=ge&&l?"spare":"prepare";if(x=ee,J.busy(!0),ge&&l)return M(),!0;p.cancel(),R();const ct=g();if(ct===void 0)return x="reload",J.busy(!1),J.peek("email")?.reload(),!0;f=!0;const He=h;return ct.catch(()=>{!f||He!==h||(f=!1,x="reload",J.busy(!1),J.peek("email")?.reload())}),!1},U=()=>{if(Q(t.sessionKey()))return;V(),S.noteSandboxGeneration(ye(n));const N=s(),Y=Qb(N?.renderGuid,N?.showId,N?.id,i.emailId),J=Jb(N?.renderGuid);if(J!==T){const ct=T;T=J;const He=fe(e)?.peek("email")?.filled,KO=He!==void 0&&He!==J;Hl(J)&&(Hl(ct)||KO)&&F(ct||(He??""),J)}if(f)return;(Y!==D||C)&&(C=!1,D=Y,w.showRequestIdentityChanged());const ge=r(),ee=`${Y}|${ge?.get().docId??""}|${ye(n)}`;ee!==k&&ge?.isReady()===!0&&(k=ee,w.selfInitChanged()),w.saasChanged(),ne()};let y=!1,E="",L="",B=!1,W=!1;const te=N=>{N.source==="user"?W=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(B=!0),z()},ne=()=>{const N=s();if(!N?.renderGuid)return;const Y=S.channel.readContent(),J=JSON.stringify([N.preheader,N.common_styles,N.meta,N.subject,N.utm_parameters?.utm_campaign??"",N.utm_parameters?.utm_content??"",N.utm_parameters?.utm_medium??"",N.utm_parameters?.utm_source??"",N.utm_parameters?.utm_term??""]),ge=y&&Y!==L,ee=y&&J!==E;y=!0,L=Y,E=J;const ct=B&&!W;if(B=!1,W=!1,S.isEventsLocked()||ct)return;const He={...N,id:i.isTemplate||N.isNew?void 0:N.id,html:Y};if(ge){me(e,d.events.ON_CONTENT_CHANGED_ID).fire(Y),me(e,d.events.ON_EMAIL_CHANGED_ID).fire(He);return}ee&&N.is_inited&&me(e,d.events.ON_EMAIL_CHANGED_ID).fire(He)};let re=!1;const z=()=>{re||(re=!0,queueMicrotask(()=>{re=!1,U()}))};e.inject(js,{pipeline:S,setRoute:N=>{N.emailId===i.emailId&&!!N.isTemplate==!!i.isTemplate||(i=N,z())}});let $,m;const b=()=>{const N=r()?.get().docId;N!==m&&($?.(),m=N,$=r()?.subscribe(te)),z()};let O,j;const V=()=>{const N=e.getInstance(d.INIT_PIPELINE_ID);!N||N===O||(j?.(),O=N,j=N.onShowRequested(Y=>w.showRequested(Y)))},X=n.addListener(N=>{N.data?.operation===q.SANDBOX_RESIZED&&p.notify()}),G=t.subscribe(b),K=Vt(n,z);b(),e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{c?.dispose(),j?.(),K(),G(),$?.(),X.dispose(),p.cancel(),S.stop()})}function ey(){return Sp!=="useblocks"}var Gl={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:!1,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},ty={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:!0,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:!1,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}},Vl=Gl,ny=["freeUserBlocks","blocks"],Ks={};function ry(e){Ks=e}var Wl=e=>ny.includes(e)?Vl:Ks[e]??Ks.editor??Vl,qs={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:!1,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},sy={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:!0,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:!1,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},oy={...qs,config:{...qs.config,imageCenterFileManagerView:!1}};ry({pro:ty,editor:sy,simple:ey()?qs:oy,blocks:Gl});function iy(e,t,n=e.getInstance(d.CONFIG_SOURCE_ID)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Bl(e).isCodeMode&&Gs(e,!1)}function ay(e){e.getInstance(d.STANDALONE_ACTIVATED_ID)||e.inject(d.SECURITY_MODULE_ID,void 0)}function lr(e){return String(e.standaloneKey||"").trim()||void 0}function cy(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function zs(e){return cy(e)?!!lr(e):!1}function sn(e){return!!lr(e)&&!zs(e)}var ly=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Kl(e){return e==="server"?"serverSide":e}function dy({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},s=se();let o={kind:"pending"},i;const a=new Promise(h=>{i=h}),c=n===void 0?void 0:setTimeout(()=>{u({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function l(){o.kind!=="pending"&&s.set(Cs(r,e))}function u(h){if(o.kind!=="pending")return;clearTimeout(c),o=h;const g=Cs(r,e);s.set(g),i(g)}function f(h,g){r[Kl(h)]=g,h==="server"&&o.kind==="pending"?u({kind:"applied"}):l()}return{watch:h=>s.watch(h),select:h=>s.select(h),get:()=>s.get(),ready:()=>a,state:()=>o,layers:()=>({...r}),bootstrap(){const h=Cs(r,e);return Object.fromEntries(ly.map(g=>[g,h[g]]))},merge(h,g){f(g,{...r[Kl(g)],...h})},replace(h,g){f(g,h)},setMode(h){r.user={...r.user,mode:h},l()},setAdvancedConfigs(h){r.advancedConfigs=h,l()},serverAbsent(h){u({kind:"absent",reason:h})},applyServerResponse(h){o.kind==="pending"&&f("server",{...r.serverSide,...h})},dispose(){clearTimeout(c)}}}var uy=5e3,fy="blocks";function hy(){return{...Wl(fy)?.config,mergeTags:void 0}}function py(e,t){e.getInstance(d.OPTIONS_SOURCE_ID)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs});const r=n.config??{},s=t.layers().user.mode;t.replace(r.mode===void 0&&s!==void 0?{...r,mode:s}:r,"user")})}function my(e,t){let n;As(e).watch(({profile:r})=>{const s=`${r?.theme??""}|${r?.locale??""}`;if(s===n)return;n=s;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function gy(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function _y(e,t){let n,r=!1,s;const o=a=>{s??=Jn(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&iy(e,a,t)},i=As(e).watch(({profile:a})=>{const c=a?.email_builder_config,l=gy(c);if(l===void 0||c===n)return;const u=n===void 0;n=c,!(u&&r)&&o(l)});e.getInstance(d.DISPOSABLE_ID)?.addDisposable(i),t.ready().then(a=>{if(!a.configSwither)return;const c=localStorage.getItem("configSwither")||(n===void 0?a.mode:s)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,o(c)})}var ql="замкнутый контур: app_init не выполняется";function vy(e,t){if(e.getInstance(d.SECURITY_MODULE_ID)){t.serverAbsent(ql);return}const n=e.getInstance(d.OPTIONS_SOURCE_ID)?.watch(r=>{sn(r)&&t.serverAbsent(ql)});n&&e.getInstance(d.DISPOSABLE_ID)?.addDisposable(n)}async function Ey(e,t){if(e.getInstance(qr)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(d.APP_ID);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function by(e){e.injectFactory(d.CONFIG_SOURCE_ID,(t,n)=>{if(n)return n;const r=dy({base:hy(),env:{modeDefaults:s=>Wl(s)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:uy});return py(e,r),my(e,r),_y(e,r),vy(e,r),Ey(e,r),e.getInstance(d.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var Dt=class extends d.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 H(e,t,n){const r=d.snapshot(e);return(s,o,i)=>{const a=r(async c=>{const l=t?t(c):c;i&&s.bind(i);const u=await s(l);return n?n(u):u},o,i);return()=>a.dispose()}}var yy=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new d.Emitter;this.handleDestroy=H(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Dt(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{}}},Ys=d.createIdentifier("DestroyableService");function wy(e){e.injectFactory(Ys,(t,n)=>{if(n)return n;const r=e.getInstance(d.DISPOSABLE_ID);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new yy({lifetime:r,options:e.getInstance(d.OPTIONS_SOURCE_ID),getInstance:()=>e.getInstance(d.INSTANCE_ID),release:()=>wh(e.getInstance(d.STORE_ID)??e)})},!0)}function Sy(e){const t=e.getInstance(Ys);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var Iy=1e3;function zl(e,t,n=Iy,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 s=Object.keys(e),o=Object.keys(t);if(s.length!==o.length)return!1;for(const i of s)if(!zl(e[i],t[i],n,r+1))return!1;return!0}return!1}function on(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 s=t[r],o=e[r];zl(s,o)||(n[r]=s)}return n}var Ay=({source:e,emailtags:t,group:n,tags:r,...s})=>s;async function Ty(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function Cy({emails:e,saveTimeoutMs:t},n,r){const s=t?.()??Gt();let o;try{const i=e.notifySave(n);return await Promise.race([i,new Promise((a,c)=>{o=setTimeout(()=>{const l=new kn(s);n.value.id,Rm(l,Ty(i,r)),c(l)},s)})])}catch(i){throw ja(i),i}finally{o!==void 0&&clearTimeout(o)}}function Oy(e){const{emails:t}=e,n=async(r,s)=>{const o=Ay(s),i=r===void 0?void 0:await t.cache.getIfPresent(r),a=i?{...i,...o}:o,c=i?on(i,o):o,l=u=>{const f=String(u.id??r??d.generateUUID()),h=u.id===void 0?{...u,id:f}:u;return t.cache.addOrUpdate(f,()=>h)};return await l(await Cy(e,{prev:i,patch:c,value:a,source:s.source??""},l))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const s=await n(void 0,r);return s?.renderGuid?s:{...s,renderGuid:d.generateUUID()}},async updateEmail(r,s){return await n(r,s)}}}var Xs=20;function Dy(e){const t=Py(e);return e.saveTimeoutMs?Ry(t,e.saveTimeoutMs):t}function Py({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:s,integratorProject:o}){const i=async(a,c)=>(t.clear(),await t.get(a,{page:c}),(await e.cache.values()??[]).filter(l=>String(l?.parent)===String(a)));return{async readRevisions(a,c=1){const l=await i(a,c);return{revisions:l.slice(Xs*(c-1),Xs*c),page:c,hasMore:l.length>Xs*c}},async readAutosave(a){const c=await r?.(a)??NaN,l=Number.isFinite(c)?c:void 0,u=await n?.(a);if(!u?.asked)return jm(await i(a,1),l);if(!u.revision)return Ga([],l);const f={...u.revision,parent:a,isAutosave:!0};return Ga([f],l,await i(a,1))},async saveAutosave(a,c){const l=await s?.(a),u=o?.();return await e.create({...Wm(c),...l!==void 0?{author:l}:{},...u!==void 0?{project:u}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Ry(e,t,n){return{...e,async saveAutosave(r,s){const o=t();if(o===void 0)return e.saveAutosave(r,s);let i;try{return await Promise.race([e.saveAutosave(r,s),new Promise((a,c)=>{i=setTimeout(()=>c(new ua(o,n)),o)})])}catch(a){throw ja(a),a}finally{i!==void 0&&clearTimeout(i)}}}}var ky=class extends d.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}},Ny=class extends d.AsyncEmitter{};function _D(e){return e}var Yl=class extends d.Disposable{_items=new Map;_onChangeEmitter=new d.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 s=await t(n);return ve(n,s)||this._onChangeEmitter.fire(),s}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(([s,o])=>s)),r=(await this.entries()).filter(([s,o])=>!n.has(s));for(const[s,o]of e)t.push(this.addOrUpdate(s,()=>o)),n.add(s);for(const[s]of r)t.push(this.remove(s));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 Ly(e,{filter:t,order:n="asc",orderBy:r,page:s,pageSize:o=20}={}){const i=e.length;let a=e.length;if(t!==void 0){const c=Object.keys(t);e=e.filter(l=>{for(const u of c){const f=l[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,l)=>(c[r]>l[r]?1:l[r]>c[r]?-1:0)*(n==="asc"?1:-1))),s!==void 0&&(e=e.slice(o*(s-1),o*s)),{data:e,filteredTotal:a,total:i,totalPages:Math.ceil(a/o)}}function xy(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 s=t.get(r.id)||{};t.set(r.id,{...s,...r})}return[...t].map(([n,r])=>r)}function My(e,t){return Xl(e)&&Xl(t)?String(e)===String(t):e===t}function Xl(e){return typeof e=="string"||typeof e=="number"}var Fy=class extends d.Disposable{_cache=new Yl;_readEmitter=new d.AsyncEmitter;_saveEmitter=this.addDisposable(new ky);_removeEmitter=this.addDisposable(new Ny);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}hasReadHandler(){return this._readEmitter.hasListeners()}async confirmedMissing(e){if(!this.hasReadHandler())return!1;const{results:t,errors:n}=await this._readEmitter.fireSettled(e);return!n.length&&!t.some(Boolean)}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new d.Disposable);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Yl),s=n.addDisposable(new d.AsyncEmitter);t=this._foreignCache[e]={get:async(o,i={})=>{await r.getOrCreate(o,async()=>{try{const c=xy(await s.fire(o))||[];for(const l of c)l[e]=o,await this._cache.add(l.id,l);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const l=c[e];return l==null||My(l,o)});return Ly(a,i)},first(o,i={}){return t.get(o,{...i,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:s.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=d.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 s=>{const o=s?{...s,...t}:t;if(!r)return t=s?on(s,t):t,await this._saveEmitter.fire({prev:s,patch:t,value:o,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function an(e){const t=d.createIdentifier(e);return n=>n.getOrCreateInstance(t,()=>new Fy)}function Jl(e){const t=e.getInstance(d.DISPOSABLE_ID);if(!t)throw new Error("Failed");return t}function Ql(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function dr(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function By(e,t,n){return e&&!Ql(t)&&Ql(e)?{...n,meta:e.meta}:n}var jy=d.createIdentifier("CurrentProject"),Uy={};function cn(e){return e?.getInstance(jy)?.get()??Uy}function Js(e){const t=cn(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Zl=an("plugin.dataSource.emails"),ed=an("plugin.dataSource.emailRevisions"),td=er("plugin.readEmailAutosave"),nd=d.createIdentifier("emailDocuments.provided");function $y(e){const t=Zl(e),n=ed(e),r=n.byForeignKey("parent");if(e.getInstance(nd))return{emails:t,emailRevisions:n};e.inject(nd,!0);const s=()=>Gt(e.getInstance(d.INIT_PIPELINE_ID)?.contentReadyTimeoutMs),o=Oy({emails:t,saveTimeoutMs:s}),i=new Map,a=(c,l)=>u=>{const f=u?.id??l;return(typeof f=="string"||typeof f=="number")&&i.set(String(f),c),u};return pg(e,{...o,createEmail:c=>o.createEmail(c).then(a(Date.now())),updateEmail:(c,l)=>o.updateEmail(c,l).then(a(Date.now(),c))}),vg(e,Dy({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const l=await me(e,td).fire(c);return l.length===0?{asked:!1}:{asked:!0,revision:l[0]??null}},savedAt:async c=>{const l=Fm((await t.cache.getIfPresent(c))?.modified),u=i.get(String(c))??NaN;return Number.isFinite(u)&&!(l>=u)?u:l},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:s,integratorProject:()=>cn(e).requested})),Jl(e).addDisposable(t.onSave(({prev:c,patch:l,value:u})=>By(c,l,u),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function Hy(e){return{handleLoad:H(d.getEvent(e,d.APP_LOAD_EVENT_ID)),handleLoadImage:H(d.getEvent(e,d.events.UPLOAD_EVENT_ID)),handleFileProxy:H(d.getEvent(e,d.events.FILE_PROXY_EVENT_ID)),handleUrlProxy:H(d.getEvent(e,d.events.PROXY_URL_EVENT_ID)),handleAITextRequest:H(d.getEvent(e,d.events.AI_TEXT_REQUEST_ID)),handleAIImageRequest:H(d.getEvent(e,d.events.AI_IMAGE_REQUEST_ID)),handleReadLocale:H(d.getEvent(e,d.events.READ_LOCALE)),handleLimitUsage:H(d.getEvent(e,d.events.ON_LIMIT_ID)),handleTranslate:H(d.getEvent(e,d.events.ON_TRANSLATE_ID))}}function Gy(e,t){const n=e.getInstance(d.DISPOSABLE_ID),r=e.getInstance(d.OPTIONS_SOURCE_ID);if(!n||!r)throw new Error(`[plugin] ${t}: время жизни и опции регистрирует bootstrapEarly`);return{lifetime:n,options:r}}function Vy(e){const{lifetime:t,options:n}=Gy(e,"provideLoadHandler");e.getInstanceAsync(d.INSTANCE_ID).then(r=>{if(t.isDisposed())return;const s=t.addDisposable(new Dt(r.handleLoad));t.addDisposable(n.watch(({handleLoad:o})=>s.setListener(o)))},()=>{})}function rd(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 Wy(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var Ky="po",ur=null;function qy(){const e=typeof __useblocks__<"u"?__useblocks__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([Ky],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function zy(){return ur===null&&(ur=qy().catch(e=>{throw ur=null,e})),ur}async function sd(e){if(typeof e=="object")return Qs(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?Yy(t):Xy(t)}function Qs(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function Yy(e){try{return Qs(JSON.parse(e))}catch{return}}var od=!1;async function Xy(e){try{return Qs((await zy()).parsePoCatalog(e))}catch{od||(od=!0);return}}var Jy="em_locale",Qy="em_ant_locale",Zy="locale",ew="ant_locale";function Zs(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function id(e,t){const n=Zs(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function tw(){return Zs("em_locale")??id(Zy,"em_locale")}function ad(e){try{localStorage.setItem(Jy,JSON.stringify(e))}catch{}}function nw(){return Zs("em_ant_locale")??id(ew,"em_ant_locale")}function rw(e,t){try{localStorage.setItem(Qy,JSON.stringify({id:e,data:t}))}catch{}}var vD="en_US",sw=8e3;function ow(e,t){const n=e,r=t,s=Object.keys(n).filter(o=>o!=="");return s.length!==Object.keys(r).filter(o=>o!=="").length?!1:s.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function iw(e){const t=tw(),n=nw();let r={ready:!1},s;const o=se(r);let i=0;const a=v=>{r={...r,...v},o.set(r)},c=()=>{r.ready||a({ready:!0})},l=setTimeout(c,e.unlockAfterMs??sw),u=v=>v!==i;let f;async function h(v,A){if(n?.id===v&&n.data&&a({antd:n.data}),!f)return;const C=await f(v).catch(()=>{});!C||u(A)||(a({antd:C}),rw(v,C))}async function g(v,A){const C=await e.askHost(v).catch(()=>null);if(u(A))return!0;if(C==null)return!1;const P=await sd(C);return u(A)||(P&&a({catalog:P}),c()),!0}async function p(v,A){const C=await e.readList();if(u(A))return;if("error"in C){a({failure:{kind:"GET_LOCALES_ERROR",error:C.error}}),c();return}const P=C.data.find(S=>S.locale===v);if(!P){Wy("em_locale")&&a({catalog:void 0}),c();return}if(rd(t,P)&&(!s||s.catalog===t?.data)){c();return}if(s?.entry&&r.catalog===s.catalog&&rd(s.entry,P)){ad(s.entry),c();return}const I=await e.readCatalog(v);if(!u(A)){if("error"in I){a({failure:{kind:"GET_LOCALE_ERROR",error:I.error}}),c();return}I.data&&(s?.id===v&&r.catalog===s.catalog&&ow(s.catalog,I.data)||a({catalog:I.data}),ad({id:v,time:P.updatedAt||Math.floor(Date.now()/1e3),hash:P.contentHash,data:I.data})),c()}}async function _(v,A){if(!await g(v,A)){if(!u(A)&&(s?.id===v&&r.catalog===s.catalog||v==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await p(v,A)}}return{set(v){if(!v||v===r.id)return;const A=i+=1;a({id:v,failure:void 0});const C=s?.id===v&&r.catalog===s.catalog;(s&&!C&&r.catalog===s.catalog||v==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===v&&t.data&&(a({catalog:t.data}),c()),h(v,A),_(v,A)},prime(v,A,C){r.id&&r.id!==v||r.catalog||!A||(s=t?.id===v&&t.data&&(!C||t.time>=C.time)?{id:v,catalog:t.data}:{id:v,catalog:A,entry:C?{id:v,time:C.time,hash:C.hash,data:A}:void 0},a({catalog:s.catalog}))},useAntdLoader(v){f=v,r.id&&h(r.id,i)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(l)}}var aw=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})},cd=(function(e){return e.Json="application/json",e.JsonApi="application/vnd.api+json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),cw=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:s,format:o,baseUrl:i,cancelToken:a,...c})=>{const l=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},u=this.mergeRequestParams(c,l),f=s&&this.toQueryString(s),h=this.contentFormatters[r||"application/json"],g=o||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 p=>{const _=p;_.data=null,_.error=null;const v=g?p.clone():p,A=g?await v[g]().then(C=>(_.ok?_.data=C:_.error=C,_)).catch(C=>(_.error=C,_)):_;return a&&this.abortControllers.delete(a),A})}},lw=d.createIdentifier("rest.v2.transport"),ld=Symbol("rest.v2.secureRequest");function dw(e){return e.getOrCreateInstance(lw,()=>{const t=e.getInstance($r)?.execute||fetch;return new cw({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[ld]:!0}),customFetch:(n,r={})=>{const{[ld]:s,...o}=r;return t(n,{...o,[mi]:s!==!0})}})})}function dd(e,t){const n=dw(e);return Object.assign({},...t.map(r=>new r(n)))}function ud(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function fr(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:ud(n.details,"wp_code")??n.code,message:ud(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 fd(e){return!e.ok||!!e.error}function hd(){return ma(Rn.em_translations_v2)??!0}function uw(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function fw(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function hw(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],s=r[0];return typeof s=="string"&&s!==""&&t.push({locale:s,updatedAt:uw(r[1])}),t},[]):[]}function pw(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:fw(n.updated_at),contentHash:n.content_hash}),t),[])}function pd(e){return dd(e,[aw])}function hr(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function eo(e){return!e.ok||e.error!=null}function to(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function no(e){return{data:await sd(e)??null}}async function mw(e){if(hd())try{const n=await pd(e).localesList();return fd(n)?{error:fr(n)}:{data:pw(n.data)}}catch(n){return hr(n)}const t=gi(e,[pi]);try{const n=await t.get_translations2({file:"react_app"});return eo(n)?to(n):{data:hw(n.data)}}catch(n){return hr(n)}}async function gw(e,t){if(hd())try{const r=await pd(e).jsonList({locale:t});return fd(r)?{error:fr(r)}:no(r.data)}catch(r){return hr(r)}const n=gi(e,[pi]);try{const r=await n.get_translations3({id:t,file:"react_app"});return eo(r)?to(r):no(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return eo(r)?to(r):no(r.data)}catch(r){return hr(r)}}}var pr=new WeakMap;function _w(e){const t=pr.get(e);if(t!==void 0)return t;const n=mw(e).then(r=>("error"in r&&pr.delete(e),r),r=>{throw pr.delete(e),r});return pr.set(e,n),n}var rt=d.createIdentifier("locale.service");function vw(e){if(e.getInstance(rt))return;const t=iw({readList:()=>_w(e),readCatalog:n=>gw(e,n),askHost:async n=>(await me(e,d.events.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(d.SECURITY_MODULE_ID)});e.inject(rt,t),e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>t.dispose())}function Ew(e){const t=e.getInstance(d.CONFIG_SOURCE_ID);if(!t)return;const n=e.getInstance(rt);if(!n)return;const r=t.select(s=>s.locale).watch(s=>n.set(s||"en_US"));e.getInstance(d.DISPOSABLE_ID)?.addDisposable(r)}var bw="user_id",yw="project_id",md=d.createIdentifier("rest.identityHeadersProvided");function ww(e){if(e.getInstance(md))return;e.inject(md,!0);let t;e.getInstance(d.OPTIONS_SOURCE_ID)?.watch(n=>{t=n}),e.addService(Ge,{execute(n,r){if(r?.public)return;const s=t?.user?.id??$c(e).profile?.id;s!=null&&s!==""&&n.headers.set(bw,String(s));const o=t?.project;o!=null&&o!==""&&n.headers.set(yw,String(o))}})}function Sw(e){const t=e?.[""];return typeof t?.lang=="string"?t.lang:void 0}function Iw(e){return e.id??Sw(e.catalog)}function Aw(e){if(e==="uk"||e.startsWith("uk_"))return"uk";const t=e.search(/[_-]/);return t>0?e.slice(0,t):e}function Tw(e){return Aw(e||"en_US")}var Cw="Accept-Language",gd=d.createIdentifier("rest.localeHeaderProvided");function Ow(e){e.getInstance(gd)||(e.inject(gd,!0),e.addService(Ge,{execute(t){const n=e.getInstance(rt)?.snapshot();t.headers.set(Cw,Tw(n&&Iw(n)))}}))}function Dw(e){if(!e)return!1;try{return e.getInstance(d.SECURITY_MODULE_ID)!==void 0}catch{return!1}}var Pw="Invalid standaloneKey.",ED=d.createIdentifier("StandaloneMockGuard");function Rw(){const e=new Error(Pw);return e.name="InvalidStandaloneKeyError",e}function kw(e){e.addService(Ge,{execute:()=>{if(Dw(e))throw Rw()}})}function Nw(e){lp(e),kw(e)}function Lw(e){const t=new fl;e.inject(d.INIT_PIPELINE_ID,t);const n=e.getInstance(d.OPTIONS_SOURCE_ID)?.watch(s=>{if(!s)return;const o=s.signal??t.externalSignal;t.configure({replaceSession:!0,...s.timeouts!==void 0?{timeouts:s.timeouts}:{},...o!==void 0?{signal:o}:{}})}),r=e.getInstance(d.DISPOSABLE_ID);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var _d=an("plugin.dataSource.blocks"),xw=an("plugin.dataSource.blockRevisions"),Mw=an("plugin.dataSource.comments"),Fw=er("plugin.readTemplateBlocks"),Bw=er("plugin.readCommonBlocks"),jw=e=>e.replaceAll("&","&").replaceAll("<","<");function vd(e=""){return`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
2110
2110
|
<html>
|
|
2111
2111
|
|
|
2112
2112
|
<head>
|
|
2113
2113
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
2114
2114
|
<meta name="x-apple-disable-message-reformatting">
|
|
2115
2115
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2116
|
-
<title>${
|
|
2116
|
+
<title>${jw(e)}</title>
|
|
2117
2117
|
<style type="text/css">
|
|
2118
2118
|
html {
|
|
2119
2119
|
-webkit-text-size-adjust: none;
|
|
@@ -2161,10 +2161,10 @@ __useblocks__.define("useblocks.js",["require","exports","module","static/umd/b1
|
|
|
2161
2161
|
</table>
|
|
2162
2162
|
</body>
|
|
2163
2163
|
|
|
2164
|
-
</html>`}function
|
|
2164
|
+
</html>`}function Uw(e,t){return{isNew:!0,is_inited:!1,subject:t||void 0,preheader:void 0,description:"",html:vd(t),project:e?.id,project_title:e?.title??"",utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}function $w(e){return e("New email")}var Ed=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Hw(e){return!Object.keys(e).some(t=>Ed.has(t))}function Gw(e){const t={},n={};for(const[r,s]of Object.entries(e))Ed.has(r)?t[r]=s:n[r]=s;return{showOptions:t,misplacedEmailFields:n}}function bd(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function bD(e){}function mr(e){return typeof e=="object"&&e!==null&&Object.prototype.hasOwnProperty.call(e,"block")&&!Object.prototype.hasOwnProperty.call(e,"email")}function Vw(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 ln(e){return{emails:Zl(e),blocks:_d(e),emailRevisions:ed(e),blocksRevision:xw(e),comments:Mw(e)}}function Ww(e){const t=Object.values(ln(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function gr(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Hw(e))return{email:bd(e)};{const{showOptions:n,misplacedEmailFields:r}=Gw(e),s=Object.keys(r);t&&s.length>0&&void 0;const o=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:bd({...r,...o})}}}function ro(e){const t=Ie(e);return t&&Q(t.sessionKey())?t.suspendedDocument():t?.current()}function _r(e){return ro(e)?.getContent()}function yd(e,t){const n=t??Uw(),r=ro(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:_r(e)??n.html}:n}async function dn(e){return(await e.getInstanceAsync(d.APP_ID))?.project}async function wd(e){return Js(e)??await dn(e)}async function Sd(e,t){const n=_d(e);if(n.hasReadHandler()){const r=await n.get(t);if(r&&Object.keys(r).some(s=>s!=="id"))return r;await n.remove(t,{silent:!0});return}return n.byForeignKey("project").first(await wd(e),{filter:{id:t}})}function Id(e){if(!e)return;if(mr(e)){const n=typeof e.block=="string"?e.block:e.block.id;return n==null?void 0:`block:${n}`}const t=gr(e,!1).email.id;return t==null?void 0:String(t)}function Kw(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function qw(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}async function zw(e,t,n){const r=Gt(e.getInstance(d.INIT_PIPELINE_ID)?.contentReadyTimeoutMs);let s;try{return await Promise.race([t,new Promise((o,i)=>{s=setTimeout(()=>{t.then(n,()=>{}),i(new kn(r,"handleSaveBlock","block"))},r)})])}finally{clearTimeout(s)}}function Pt({code:e,project:t,...n},r){const s=Le(n),o=Js(r),i=Be(r);return e&&i.warnAboutUnconfiguredInput(e,n.id),{...s,...e?{html:i.toEditorForm(e)}:{},...o===void 0?{}:{project:o},..."utm_parameters"in s?{utm_parameters:s.utm_parameters||{}}:{},_embedded:void 0}}function Te({html:e,renderGuid:t,showToken:n,showId:r,...s},o){const{requested:i}=cn(o),a=Gc(o);return Le({...s,code:Be(o).toOutputForm(e),project:i===void 0?s.project:i,utm_parameters:a.UTMEnabled?s.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0,secretHash:void 0})}function so(e){return e==null?"":e.replaceAll(`\r
|
|
2165
2165
|
`,`
|
|
2166
|
-
`)}function el(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function KE(e,t,n,r){const s=qE(e,t,n,r);return s===void 0}function qE(e,t,n,r){if(Gn(t))return"block";const{email:s}=Wn(t,!1),o=_t(s,e),i=o.id;if(i===void 0)return"no-id";if(r!==void 0&&r!==i)return"other-id-shown";const a=ye(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=el(bs(n??a.getContent()));if(o.html!==void 0&&el(bs(o.html))!==u)return"html";if(o.subject!==void 0&&o.subject!==d.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==d.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==d.common_styles)return"common_styles"}function tl(e,t){if(Gn(t))return;const{email:n}=Wn(t,!1),r=_t(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:bs(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function zE(e){return Array.isArray(e)?e.some(t=>Tr(t)):Tr(e)}function XE(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])zE(t[n])&&delete t[n];return t}function JE(e,t){const n={...e};return delete n.id,{...n,...t}}function QE(e,t){var n=0,r,s;t=t||{};function o(){var i=r,a=arguments.length,c,d;e:for(;i;){if(i.args.length!==arguments.length){i=i.next;continue}for(d=0;d<a;d++)if(i.args[d]!==arguments[d]){i=i.next;continue e}return i!==r&&(i===s&&(s=i.prev),i.prev.next=i.next,i.next&&(i.next.prev=i.prev),i.next=r,i.prev=null,r.prev=i,r=i),i.val}for(c=new Array(a),d=0;d<a;d++)c[d]=arguments[d];return i={args:c,val:e.apply(null,c)},r?(r.prev=i,i.next=r):s=i,n===t.maxSize?(s=s.prev,s.next=null):n++,r=i,i.val}return o.clear=function(){r=null,s=null,n=0},o}var ZE=wt.__commonJSMin((e=>{(function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function n(a){return s(i(a),arguments)}function r(a,c){return n.apply(null,[a].concat(c||[]))}function s(a,c){for(var d=1,u=a.length,f,h="",g=0,m,v,_,T,A,B,O;g<u;g++)if(typeof a[g]=="string")h+=a[g];else if(typeof a[g]=="object"){if(v=a[g],v.keys)for(f=c[d],m=0;m<v.keys.length;m++){if(f==null)throw new Error(n('[sprintf] Cannot access property "%s" of undefined value "%s"',v.keys[m],v.keys[m-1]));f=f[v.keys[m]]}else v.param_no?f=c[v.param_no]:f=c[d++];if(t.not_type.test(v.type)&&t.not_primitive.test(v.type)&&f instanceof Function&&(f=f()),t.numeric_arg.test(v.type)&&typeof f!="number"&&isNaN(f))throw new TypeError(n("[sprintf] expecting number but found %T",f));switch(t.number.test(v.type)&&(B=f>=0),v.type){case"b":f=parseInt(f,10).toString(2);break;case"c":f=String.fromCharCode(parseInt(f,10));break;case"d":case"i":f=parseInt(f,10);break;case"j":f=JSON.stringify(f,null,v.width?parseInt(v.width):0);break;case"e":f=v.precision?parseFloat(f).toExponential(v.precision):parseFloat(f).toExponential();break;case"f":f=v.precision?parseFloat(f).toFixed(v.precision):parseFloat(f);break;case"g":f=v.precision?String(Number(f.toPrecision(v.precision))):parseFloat(f);break;case"o":f=(parseInt(f,10)>>>0).toString(8);break;case"s":f=String(f),f=v.precision?f.substring(0,v.precision):f;break;case"t":f=String(!!f),f=v.precision?f.substring(0,v.precision):f;break;case"T":f=Object.prototype.toString.call(f).slice(8,-1).toLowerCase(),f=v.precision?f.substring(0,v.precision):f;break;case"u":f=parseInt(f,10)>>>0;break;case"v":f=f.valueOf(),f=v.precision?f.substring(0,v.precision):f;break;case"x":f=(parseInt(f,10)>>>0).toString(16);break;case"X":f=(parseInt(f,10)>>>0).toString(16).toUpperCase()}t.json.test(v.type)?h+=f:(t.number.test(v.type)&&(!B||v.sign)?(O=B?"+":"-",f=f.toString().replace(t.sign,"")):O="",T=v.pad_char?v.pad_char==="0"?"0":v.pad_char.charAt(1):" ",A=v.width-(O+f).length,_=v.width&&A>0?T.repeat(A):"",h+=v.align?O+f+_:T==="0"?O+_+f:_+O+f)}return h}var o=Object.create(null);function i(a){if(o[a])return o[a];for(var c=a,d,u=[],f=0;c;){if((d=t.text.exec(c))!==null)u.push(d[0]);else if((d=t.modulo.exec(c))!==null)u.push("%");else if((d=t.placeholder.exec(c))!==null){if(d[2]){f|=1;var h=[],g=d[2],m=[];if((m=t.key.exec(g))!==null)for(h.push(m[1]);(g=g.substring(m[0].length))!=="";)if((m=t.key_access.exec(g))!==null)h.push(m[1]);else if((m=t.index_access.exec(g))!==null)h.push(m[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");d[2]=h}else f|=2;if(f===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");u.push({placeholder:d[0],param_no:d[1],keys:d[2],sign:d[3],pad_char:d[4],align:d[5],width:d[6],precision:d[7],type:d[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");c=c.substring(d[0].length)}return o[a]=u}typeof e<"u"&&(e.sprintf=n,e.vsprintf=r),typeof window<"u"&&(window.sprintf=n,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()})),aA=wt.__toESM(ZE()),cA=QE(console.error),nl={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1},eb=["(","?"],Kn={")":["("],":":["?","?:"]},tb=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;function nb(e){for(var t=[],n=[],r,s,o,i;r=e.match(tb);){for(s=r[0],o=e.substr(0,r.index).trim(),o&&t.push(o);i=n.pop();){if(Kn[s]){if(Kn[s][0]===i){s=Kn[s][1]||s;break}}else if(eb.indexOf(i)>=0||nl[i]<nl[s]){n.push(i);break}t.push(i)}Kn[s]||n.push(s),e=e.substr(r.index+s.length)}return e=e.trim(),e&&t.push(e),t.concat(n.reverse())}var rb={"!":function(e){return!e},"*":function(e,t){return e*t},"/":function(e,t){return e/t},"%":function(e,t){return e%t},"+":function(e,t){return e+t},"-":function(e,t){return e-t},"<":function(e,t){return e<t},"<=":function(e,t){return e<=t},">":function(e,t){return e>t},">=":function(e,t){return e>=t},"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},"&&":function(e,t){return e&&t},"||":function(e,t){return e||t},"?:":function(e,t,n){if(e)throw t;return n}};function sb(e,t){for(var n=[],r=0,s,o,i,a,c;r<e.length;r++){if(a=e[r],i=rb[a],i){for(s=i.length,o=Array(s);s--;)o[s]=n.pop();try{c=i.apply(null,o)}catch(d){return d}}else t.hasOwnProperty(a)?c=t[a]:c=+a;n.push(c)}return n[0]}function ob(e){var t=nb(e);return function(n){return sb(t,n)}}function ib(e){var t=ob(e);return function(n){return+t({n})}}var rl={contextDelimiter:"",onMissingKey:null};function ab(e){for(var t=e.split(";"),n=0,r;n<t.length;n++)if(r=t[n].trim(),r.indexOf("plural=")===0)return r.substr(7)}function ys(e,t){var n;this.data=e,this.pluralForms={},this.options={};for(n in rl)this.options[n]=t!==void 0&&n in t?t[n]:rl[n]}ys.prototype.getPluralForm=function(e,t){var n=this.pluralForms[e],r,s,o;return n||(r=this.data[e][""],o=r["Plural-Forms"]||r["plural-forms"]||r.plural_forms,typeof o!="function"&&(s=ab(r["Plural-Forms"]||r["plural-forms"]||r.plural_forms),o=ib(s)),n=this.pluralForms[e]=o),n(t)},ys.prototype.dcnpgettext=function(e,t,n,r,s){var o,i,a;return s===void 0?o=0:o=this.getPluralForm(e,s),i=n,t&&(i=t+this.options.contextDelimiter+n),a=this.data[e][i],a&&a[o]?a[o]:(this.options.onMissingKey&&this.options.onMissingKey(n,e),o===0?n:r)};var sl={"":{plural_forms(e){return e===1?0:1}}},cb=/^i18n\.(n?gettext|has_translation)(_|$)/,ol=(e,t,n)=>{const r=new ys({}),s=new Set,o=()=>{s.forEach(O=>O())},i=O=>(s.add(O),()=>s.delete(O)),a=(O="default")=>r.data[O],c=(O,S="default")=>{r.data[S]={...r.data[S],...O},r.data[S][""]={...sl[""],...r.data[S]?.[""]},delete r.pluralForms[S]},d=(O,S)=>{c(O,S),o()},u=(O,S="default")=>{r.data[S]={...r.data[S],...O,"":{...sl[""],...r.data[S]?.[""],...O?.[""]}},delete r.pluralForms[S],o()},f=(O,S)=>{r.data={},r.pluralForms={},d(O,S)},h=(O="default",S,w,D,I)=>(r.data[O]||c(void 0,O),r.dcnpgettext(O,S,w,D,I)),g=(O="default")=>O,m=(O,S)=>{let w=h(S,void 0,O);return n?(w=n.applyFilters("i18n.gettext",w,O,S),n.applyFilters("i18n.gettext_"+g(S),w,O,S)):w},v=(O,S,w)=>{let D=h(w,S,O);return n?(D=n.applyFilters("i18n.gettext_with_context",D,O,S,w),n.applyFilters("i18n.gettext_with_context_"+g(w),D,O,S,w)):D},_=(O,S,w,D)=>{let I=h(D,void 0,O,S,w);return n?(I=n.applyFilters("i18n.ngettext",I,O,S,w,D),n.applyFilters("i18n.ngettext_"+g(D),I,O,S,w,D)):I},T=(O,S,w,D,I)=>{let R=h(I,D,O,S,w);return n?(R=n.applyFilters("i18n.ngettext_with_context",R,O,S,w,D,I),n.applyFilters("i18n.ngettext_with_context_"+g(I),R,O,S,w,D,I)):R},A=()=>v("ltr","text direction")==="rtl",B=(O,S,w)=>{const D=S?S+""+O:O;let I=!!r.data?.[w??"default"]?.[D];return n&&(I=n.applyFilters("i18n.has_translation",I,O,S,w),I=n.applyFilters("i18n.has_translation_"+g(w),I,O,S,w)),I};if(e&&d(e,t),n){const O=S=>{cb.test(S)&&o()};n.addAction("hookAdded","core/i18n",O),n.addAction("hookRemoved","core/i18n",O)}return{getLocaleData:a,setLocaleData:d,addLocaleData:u,resetLocaleData:f,subscribe:i,__:m,_x:v,_n:_,_nx:T,isRTL:A,hasTranslation:B}};function il(e){return!(typeof e!="string"||e===""||!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e))}function ws(e){return!(typeof e!="string"||e===""||/^__/.test(e)||!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e))}function al(e,t){return function(r,s,o,i=10){const a=e[t];if(!ws(r)||!il(s)||typeof o!="function"||typeof i!="number")return;const c={callback:o,priority:i,namespace:s};if(a[r]){const d=a[r].handlers;let u;for(u=d.length;u>0&&!(i>=d[u-1].priority);u--);u===d.length?d[u]=c:d.splice(u,0,c),a.__current.forEach(f=>{f.name===r&&f.currentIndex>=u&&f.currentIndex++})}else a[r]={handlers:[c],runs:0};r!=="hookAdded"&&e.doAction("hookAdded",r,s,o,i)}}function qn(e,t,n=!1){return function(s,o){const i=e[t];if(!ws(s)||!n&&!il(o))return;if(!i[s])return 0;let a=0;if(n)a=i[s].handlers.length,i[s]={runs:i[s].runs,handlers:[]};else{const c=i[s].handlers;for(let d=c.length-1;d>=0;d--)c[d].namespace===o&&(c.splice(d,1),a++,i.__current.forEach(u=>{u.name===s&&u.currentIndex>=d&&u.currentIndex--}))}return s!=="hookRemoved"&&e.doAction("hookRemoved",s,o),a}}function cl(e,t){return function(r,s){const o=e[t];return typeof s<"u"?r in o&&o[r].handlers.some(i=>i.namespace===s):r in o}}function ll(e,t,n=!1){return function(s,...o){const i=e[t];i[s]||(i[s]={handlers:[],runs:0}),i[s].runs++;const a=i[s].handlers;if(!a||!a.length)return n?o[0]:void 0;const c={name:s,currentIndex:0};for(i.__current.push(c);c.currentIndex<a.length;){const d=a[c.currentIndex].callback.apply(null,o);n&&(o[0]=d),c.currentIndex++}if(i.__current.pop(),n)return o[0]}}function dl(e,t){return function(){var r;const s=e[t];return(r=s.__current[s.__current.length-1]?.name)!==null&&r!==void 0?r:null}}function ul(e,t){return function(r){const s=e[t];return typeof r>"u"?typeof s.__current[0]<"u":s.__current[0]?r===s.__current[0].name:!1}}function fl(e,t){return function(r){const s=e[t];if(ws(r))return s[r]&&s[r].runs?s[r].runs:0}}var lb=class{constructor(){this.actions=Object.create(null),this.actions.__current=[],this.filters=Object.create(null),this.filters.__current=[],this.addAction=al(this,"actions"),this.addFilter=al(this,"filters"),this.removeAction=qn(this,"actions"),this.removeFilter=qn(this,"filters"),this.hasAction=cl(this,"actions"),this.hasFilter=cl(this,"filters"),this.removeAllActions=qn(this,"actions",!0),this.removeAllFilters=qn(this,"filters",!0),this.doAction=ll(this,"actions"),this.applyFilters=ll(this,"filters",!0),this.currentAction=dl(this,"actions"),this.currentFilter=dl(this,"filters"),this.doingAction=ul(this,"actions"),this.doingFilter=ul(this,"filters"),this.didAction=fl(this,"actions"),this.didFilter=fl(this,"filters")}};function db(){return new lb}var hl=db(),{addAction:lA,addFilter:dA,removeAction:uA,removeFilter:fA,hasAction:hA,hasFilter:pA,removeAllActions:mA,removeAllFilters:gA,doAction:vA,applyFilters:_A,currentAction:EA,currentFilter:bA,doingAction:yA,doingFilter:wA,didAction:SA,didFilter:IA,actions:TA,filters:AA}=hl,le=ol(void 0,void 0,hl),CA=le.getLocaleData.bind(le),OA=le.setLocaleData.bind(le),DA=le.resetLocaleData.bind(le),PA=le.subscribe.bind(le),RA=le.__.bind(le),kA=le._x.bind(le),NA=le._n.bind(le),LA=le._nx.bind(le),MA=le.isRTL.bind(le),xA=le.hasTranslation.bind(le);function ub(e,t){if(e.html)return e;const n=e.subject||t;return{...e,subject:n,html:Kc(n)}}function fb(e,t){if(e.html||e.subject||!t?.subject)return e;const n={...e};return delete n.subject,n}async function hb(e){const t=e.getInstance(Je);t&&!t.snapshot().ready&&await new Promise(r=>{const s=t.state.watch(({ready:o})=>{o&&(queueMicrotask(()=>s.dispose()),r())})});const n=ol(t?.snapshot().catalog);return jE(r=>n.__(r))}function Qe({code:e,project:t,...n},r,s){const o=s??hs(r);return{...n,...e?{html:Ne(r).toEditorForm(e)}:{},renderGuid:l.generateUUID(),...o===void 0?{}:{project:o}}}function ge({html:e,renderGuid:t,...n},r){const{requested:s}=Vt(r);return De({...n,code:Ne(r).toOutputForm(e),project:s===void 0?n.project:s,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 pl(e){return ye(e)?.current()?.get().serverId??void 0}function Ss(e,t,n){return n===void 0&&(n=e.post===void 0?pl(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function Yt(e,t){return De({...e,link:void 0,comment_status:void 0})}function zn({code:e,autosave:t,...n},r,s){return s===void 0&&(s=n.parent===void 0?pl(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||Gf(n.slug),parent:s}}function Is({html:e,isAutosave:t,...n},r){return De({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:De({html:e,ampHtml:e&&""})})}function Xn({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function ml({html:e,isAutosave:t,...n}){return De({...n,autosave:t?!0:void 0,code:e,guid:void 0})}function pb(e){return String(e).replace(/"/g,""")}function mb(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 Ts(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 gl(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),s=pb(n);return r.test(e)?e.replace(r,`${t}="${s}"`):e.replace(/>$/,` ${t}="${s}">`)}function vl(e,t){return e.replace(new RegExp(`\\s+${t}\\s*=\\s*["'][^"']*["']`,"gi"),"")}function _l(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function El(e){if(!e?.trim())return{};const t=Ts(e);return t?{emBlockId:_l(t.full,"em-block-id"),emBlockVersion:_l(t.full,"em-block-version")}:{}}function bl(e,t,n){if(!e?.trim()||!t)return e;const r=Ts(e);if(!r)return e;const s=String(t),o=mb(n??new Date);let{full:i,index:a}=r;const c=i.length;return/\bem-block-id\s*=/.test(i)||(i=gl(i,"em-block-id",s)),i=gl(i,"em-block-version",o),e.slice(0,a)+i+e.slice(a+c)}function gb(e){const t=e?.trim()?Ts(e):null;if(!t)return e;const{full:n,index:r}=t,s=vl(vl(n,"em-block-id"),"em-block-version");return e.slice(0,r)+s+e.slice(r+n.length)}function vb(e,t){const{emBlockId:n,emBlockVersion:r}=El(e);return n&&r?e:bl(e,t)}var Et=l.createIdentifier$1("NotificationService"),_b=l.createIdentifier$1("emailTemplate.reads");async function Eb(e,t){try{const n=$e(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,yb(e,t,n);return}}var bb=l.createIdentifier$1("emailTemplate.notifiedFailures");function yb(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(bb,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(Et).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function wb(e,t){const n=e.getOrCreateInstance(_b,()=>new Map),r=n.get(t);if(r!==void 0)return r;const s=Eb(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,s),s}var Sb=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Fc.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:Fc.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},FA=l.createIdentifier$1("projects.v2IdByWpId"),BA=l.createIdentifier$1("projects.wpIdByV2Id"),jA=l.createIdentifier$1("emails.v2SavedAtOnOpen"),UA=l.createIdentifier$1("emails.v2OpeningReads"),As=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function Ib(e,t){if(!t)throw new As(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new As(e,$n(t))}function Tb(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var Ab=/^[A-Za-z0-9_-]{1,128}$/,Cb=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),yl=new Set;function Ob(e){return Ab.test(e)?!0:(yl.has(e)||yl.add(e),!1)}function Db(e){return e&&!e.ok?String($n(e).data.code??""):""}var wl=()=>({isAutosave:!1});function Sl(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function Pb(e,t){const n=new AbortController,r=Tt(e.getInstance(l.INIT_PIPELINE_ID)?.contentReadyTimeoutMs);let s;const o=new Promise((i,a)=>{s=setTimeout(()=>{n.abort(),a(new As("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),o])}finally{clearTimeout(s)}}function Rb(e,t){return Vo(t,e==="block")}async function kb(e,t,n,r,s){if(!Ob(n))return wl();const o=ct(e),i=Rt(e),a=Rb(t,n);try{const c=await Nb(e,t,n,r,s);return c.id&&(o.set(a,c.id),i.delete(a)),c}catch(c){throw Oh(i,a,r.html??""),c}}async function Nb(e,t,n,r,s){const o=jc(e,[Sb]),i={entityId:n,...s?{autosave:!0}:{}},a=await Pb(e,c=>t==="email"?o.emailsRevisionsCreate(i,Sl(t,r),{signal:c}):o.blocksRevisionsCreate(i,Sl(t,r),{signal:c}));return Cb.has(Db(a))?wl():(Ib("обновление",a),Tb(a.data??{}))}function Lb(e,t,n,r){return kb(e,t,n,r,!1)}async function Mb(e,t,n){if(t==null||t===""||n===void 0||!st(e))return Il;const r=Date.now(),s=_r(String(t));return Bi(s,{html:n},r,Lr(ct(e),s,Rt(e),n)),await Lb(e,"block",String(t),{html:n}),vn(s,r,ct(e).get(s)??void 0),()=>Er(s,r)}function Il(){}var Cs="EXTERNAL",Tl=Symbol("supersededShow");function xb(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var Fb="email_id";function Os(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var Bb=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=Gt(t),this._eventLock=VE(t);const n=Q(e,l.events.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(Q(e,l.events.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(l.REQUEST_HANDLER_ID,{execute:(r,s)=>{!s?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Fb,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(l.INIT_PIPELINE_ID)??zr}_throwIfDestroyed(){if(this.isDisposed())throw ke()}async getTemplateEmail(e){const t=await wb(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,XE(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Wt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Qe(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(s=>s.id!==void 0).map(s=>[s.id,zn(s,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(s=>s.id!==void 0).map(s=>[s.id,Ss(s,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,s){const o=this._dataSources.emails,i=o.cache,a=await Wt(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let d=_t(e,this._container);const u=d.id;let f=u;if(u!==void 0){const h=await o.get(u);d={...h??{},...d,utm_parameters:d.utm_parameters??h?.utm_parameters??{},renderGuid:h?.renderGuid??l.generateUUID(),...c>0?{showToken:c}:{},...s?{showId:s}:{},project:a}}else{f=n??l.generateUUID();const h=await o.get(f);d={...d,utm_parameters:d.utm_parameters??{},renderGuid:h?.renderGuid??l.generateUUID(),...c>0?{showToken:c}:{},...s?{showId:s}:{},project:a},delete d.project}if(t){const h=await this.getTemplateEmail(String(t));h&&(d=JE(h,d))}return u===void 0&&!d.html&&(d=ub(d,await hb(this._container))),await i.setAll([[f,d]]),d}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==tl(this._container,e))return!1;const n=Yn(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=tl(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Yn(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&GE({ticket:t,emailId:Zc(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,Tl;if(!e)return;const n=this._getInitPipeline();if(l.throwIfAborted(n.signal),Gn(e))return this._showBlock(e,n);const r=J(he(this._container).sessionKey()),s=WE(e);if(!r&&!s&&KE(this._container,e,Yn(this._container),this._prevCommand?.id)||!r&&!s&&this._isRepeatOfLastShow(e))return;const o=Wn(e);o.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:m,blocks:v,autosaves:_,comments:T,templateId:A,reload:B}=o;i=m.id;const O=_t(m,this._container),S=O.id,w=S??l.generateUUID(),D=await Ue("getProject",Wt(this._container));l.throwIfAborted(n.signal),a=l.generateUUID();const I={isNew:S===void 0,id:String(w),project:D},R=B===!0&&S!==void 0;R&&(await this._dataSources.emails.remove(String(S),{silent:!0}),String(S)),c=++this._showToken,String(w);const M=[];M.push(this.setBlocks(v)),m.id!==void 0&&(M.push(this.setComments(T)),M.push(this.setEmailRevisions(_,String(m.id)))),M.push(this.setEmail(m,Tr(A)?A:Number(A),S===void 0?String(w):void 0,c,a)),await Ue("setEmail+blocks+revisions",Promise.all(M),{emailId:S??String(w),showId:a,targetShowToken:c}),l.throwIfAborted(n.signal);const P=await this._dataSources.emails.get(String(w)),L=he(this._container),x={id:a,token:c};if(r){Mn(this._container);const E=L.suspendedDocument()?.get().serverId;!R&&S!==void 0&&E!=null&&String(E)===String(S)&&L.resumeSuspended()}S===void 0?h=L.startNewDraft(P??O,{patch:fb(O,P),show:x}):R?h=L.reload(S,{email:P??O,patch:O,show:x}):L.sessionKey()===ot(S)?h=L.show(O,x):h=L.open(S,{email:P??O,patch:O,show:x}),L.beginShowFill(a);const U=!!this._prevCommand&&l.deepEqual(this._prevCommand,I);I.id,!this._prevCommand||l.deepEqual(this._prevCommand,I),this._prevCommand?.id,this._rememberShow(I),f=n.requestShow({showId:a,navId:String(w),emailId:S,isNew:S===void 0}),g=!0;const y=()=>L.endShowFill(a);Promise.allSettled([f,h.whenReady()]).then(y),String(w),d=!0}catch(m){u=m,g&&a&&n.failShow(a,m),a&&ye(this._container)?.endShowFill(a),l.isAbortError(m)||(xo(m),void 0)}finally{this._eventLock.resumeChange()}if(!d)throw u instanceof Error?u:new Error(`[useblocks] show() setup failed: ${String(u??"unknown error")}`);return Ue("show-init-deferred",Promise.all([f,h?.whenReady().catch(m=>{if(m instanceof je){const v=Nr(m);throw v?new Error(`[useblocks] show(): email open failed (${v})`,{cause:m}):m}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:s,revisions:o,reload:i}=HE(e),a=l.generateUUID();let c=!1;try{await this.setBlocks(s),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=he(this._container);if(!i&&d!==void 0&&u.sessionKey()===un(d)){const A=Os(n)?await this._storeShownBlock(n):void 0,B={id:a,token:++this._showToken},O=u.show(A,B),S=t.requestShow({showId:a,navId:d,emailId:void 0,isNew:!1});c=!0,await Ue("show-block-init",Promise.all([S,O?.whenReady().catch(()=>{})]),{showId:a});return}const f=r||i?await Qc(this._container,String(n.id)):void 0,h=f&&(i||Os(n))?await this._storeShownBlock({...ge(f,this._container),...n}):r||i?f:await this._storeShownBlock(n);if(l.throwIfAborted(t.signal),!h)throw new Error(`[useblocks] show(): block ${String(n.id)} not found`);o!==void 0&&h.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(o.filter(A=>A.id!==void 0).map(A=>[A.id,Xn(A,String(h.id))])),this._prevCommand=void 0,this._lastShow=void 0;const g=h.id!==void 0?String(h.id):l.generateUUID(),m={id:a,token:++this._showToken};Mn(this._container);const v=i?u.reloadBlock(g,h,m):u.openBlock(g,h,m);h.id;const _=t.requestShow({showId:a,navId:g,emailId:void 0,isNew:h.id===void 0});c=!0;const T=v.whenReady().catch(A=>{if(A instanceof je)throw A});await Ue("show-block-init",Promise.all([_,T]),{showId:a})}catch(d){throw c&&t.failShow(a,d),d}}async _storeShownBlock(e){const t=Qe(e,this._container,await Wt(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=he(this._container);if(J(t.sessionKey())&&!t.hasSuspended())throw new Error("[useblocks] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:Cs,fallbackTitle:Sa(this._container)});if(l.throwIfAborted(e.signal),!n)throw xb(t.emailSaveState().error);return Se(Xc(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=he(this._container),t=e.current();if(!t||!J(e.sessionKey()))throw new Error("[useblocks] saveBlock(): no open block");return yf(t,async()=>{await t.whenReady();const n=Ln(t),r=t.get().version,s=t.get().serverId,o=typeof n.global_block=="boolean"?n.global_block:s!=null&&El(n.html??"").emBlockId===String(s),i=s!=null&&o?bl(n.html,String(s),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:i,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},c=this._dataSources.blocks,d=await Mb(this._container,t.get().serverId,a.html),u=t.get().serverId==null?c.create(a,{source:Cs}):c.update(String(t.get().serverId),a,{source:Cs}),f=await YE(this._container,u,h=>{h&&d(),h&&he(this._container).current()===t&&t.get().serverId==null&&h.id!==void 0&&t.markSaved(r,String(h.id))});if(!f)throw new Error("[useblocks] save(): block was not saved");return d(),t.markSaved(r,f.id!==void 0?String(f.id):void 0),ge(f,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=Zc(e);const n=this._queuedShow(e,t).then(r=>r===Tl?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=he(this._container);if(n!==void 0&&r.sessionKey()===un(n))return;const s=t.code===void 0&&n!==void 0?await Qc(this._container,n):void 0,o=s&&Os(t)?await this._storeShownBlock({...ge(s,this._container),...t}):t.code===void 0&&n!==void 0?s:await this._storeShownBlock(t);if(!o)throw new Error(`[useblocks] openBlock(): block ${String(n)} not found`);Mn(this._container);const i=r.openBlockOver(o.id!==void 0?String(o.id):l.generateUUID(),o);o.id,r.hasSuspended(),pe(this._container,l.events.ON_BLOCK_OPEN_ID).fire({block:o}),await i.whenReady().catch(a=>{if(a instanceof je)throw r.current()===i&&(pe(this._container,l.events.ON_BLOCK_CLOSE_ID).fire({block:o,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),Gg(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 jb(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 Ub(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),s=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:s,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:jb(e)}}function Ds(e,t){return t?Ub(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Al=["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"],$b=[...Al,"html","id","project","password"],$A=new Set(["html",...Al,"global_block","project"]);function Hb(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($b),r={};for(const s of Object.keys(e))n.has(s)||(r[s]=e[s]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Vb(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Hb(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 Ps=new WeakMap;function Gb(e){let t=Ps.get(e);return t||(t={byId:new Map,fallback:[]},Ps.set(e,t)),t}function Wb(e){Ps.delete(e)}function Yb(e,t){const{byId:n,fallback:r}=Gb(t);if(e.blockId){const s=n.get(e.blockId);if(s){n.delete(e.blockId);const o=r.indexOf(s);return o>=0&&r.splice(o,1),s}return}for(let s=r.length-1;s>=0;s--){const o=r[s],i=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,a=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(i&&a)return r.splice(s,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function Kb(e,t){const{blocks:n}=Gt(e);return await n.cache.getIfPresent(t)??void 0}async function qb(e,t){if(!t.blockId)return;const n=await Kb(e,t.blockId);if(n)return Vb(n,t)}async function zb(e,t){const n=Yb(e,t);if(n)return Ds(e,n);const r=await qb(t,e);return r?Ds(e,r):Ds(e,void 0)}var Xb=l.createIdentifier("application_block_inserted"),Jb=-1e3,Cl=new WeakSet;function Qb(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 Zb(e){if(!e||Cl.has(e))return;Cl.add(e);const t=new l.Disposable,n=ae(e);return t.addDisposable(n.addListenerAsyncPipe(Xb,async(r,s)=>{const o=Qb(r)?await zb(r,e):r;return s?s(o):o},Jb)),t.addDisposable({dispose:()=>{Wb(e)}}),t}var ey=Dn("plugin.readBlockAutosave"),HA=l.createIdentifier$1("blockDocuments.provided"),Ol=l.createIdentifier$1("plugin.earlyWindow");function ty(e){return e.getOrCreateInstance(Ol,()=>({depth:0}))}function ny(e){const t=ty(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function Dl(e){return(e?.getInstance(Ol)?.depth??0)>0}function Pl(e,t){let n,r=!1;return e(s=>{n=s,r=!0}),(s,o,i)=>{const a=e(s,o,i);if(r&&Dl(t)){const c=n;queueMicrotask(()=>{s.call(i,c)})}return a}}var Rs=100,ry=class extends l.Disposable{_container;_events;constructor(e){super(),this._container=e;const t=Zb(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:s,blocksRevision:o}=Gt(e),i=Q(e,l.events.ON_SHARE_ID),a=Q(e,l.events.ON_SHOW_PREVIEW_ID),c=Q(e,l.events.ON_EMAIL_CLONE_ID),d=Q(e,l.events.ON_BLOCK_OPEN_ID),u=Q(e,l.events.ON_BLOCK_CLOSE_ID),f=Q(e,l.events.ON_BLOCK_CLONE_ID),h=Q(e,l.events.ON_BLOCK_INIT_ID),g=Q(e,l.events.ON_BLOCK_CHANGED_ID),m=Q(e,l.events.ON_CODE_VALIDATE_ID),v=Q(e,l.events.ON_IMPORT_VALIDATE_ID),_=Q(e,l.events.ON_SUBJECT_CHANGED_ID),T=Q(e,l.events.ON_EMAIL_CHANGED_ID),A=Q(e,l.events.ON_PREHEADER_CHANGED_ID),B=Q(e,l.events.ON_SAVEBUTTON_CLICK_ID),O=Q(e,l.events.ON_BLOCK_SAVEBUTTON_CLICK_ID),S=Q(e,l.events.ON_NEXTBUTTON_CLICK_ID),w=Q(e,l.events.ON_SEND_LIVEPREVIEW_ID),D=Q(e,l.events.ON_SEND_TESTEMAIL_ID),I=Q(e,xE),R=Q(e,l.events.ON_CONTENT_CHANGED_ID),M=Q(e,ME),P=Q(e,l.events.ON_PREVIOUSBUTTON_CLICK_ID),L=Q(e,l.events.ON_SEND_EMAIL_MODAL_ID),x=l.filter(Q(e,l.events.ON_EMAIL_INIT_ID),y=>!y.reset),U=Q(e,l.events.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:H(A),handleSubjectChanged:H(_),handleValidate:H(m),handleImportValidate:H(v),handleReadEmail:H(n.handlerRead,y=>y,y=>y&&_t(y,e)),handleSaveEmail:H(n.onSave,function({prev:y,patch:E,value:N,source:F}){const W=y?Se(y,e):void 0;return{prev:W,patch:$t(W,Se(E,e)),value:Se(N,e),source:F}},y=>y?_t(y,e):void 0),handleRemoveEmail:H(n.onRemove,({value:y,source:E})=>({value:Se(y,e),source:E}),()=>{}),handleReadCommonBlocks:H(I,y=>y.project,y=>y?.map(E=>Qe(E,e))),handleReadTemplateBlocks:H(M,y=>y,y=>y?.map(E=>Qe(E,e))),handleReadBlocks:H(t.byForeignKey("project").handleRead,y=>Vt(e).requested||String(y),y=>y?.map(E=>Qe(E,e))),handleReadBlock:H(t.handlerRead,y=>y,y=>y?Qe(y,e):void 0),handleOpenBlock:H(d,({block:y})=>({block:ge(y,e)})),handleCloseBlock:H(u,({block:y,hasUnsavedChanges:E})=>({block:ge(y,e),hasUnsavedChanges:E})),handleCloneBlock:H(f,y=>ge({...y,html:gb(y.html)},e)),handleSaveBlock:H(t.onSave,function({prev:y,patch:E,value:N,source:F}){const W=N.global_block===!0&&N.id&&typeof N.html=="string"?{...N,html:vb(N.html,String(N.id))}:N,ee=y?ge(y,e):void 0;return{prev:ee,patch:$t(ee,ge(E,e)),value:ge(W,e),source:F}},y=>y?Qe(y,e):void 0),handleRemoveBlock:H(t.onRemove,({value:y,source:E})=>({value:ge(y,e),source:E}),()=>{}),handleReadComments:H(r.byForeignKey("post").handleRead,y=>y,y=>y?.map(E=>Ss(E,e))),handleSaveComment:H(r.onSave,function({prev:y,patch:E,value:N,source:F}){const W=y?Yt(y,e):void 0;return{prev:W,patch:$t(W,Yt(E,e)),value:Yt(N,e),source:F}},y=>y?Ss(y,e):void 0),handleRemoveComment:H(r.onRemove,({value:y,source:E})=>({value:Yt(y,e),source:E}),()=>{}),handleReadEmailRevisions:H(s.byForeignKey("parent").handleRead,y=>y,y=>y?.map(E=>zn(E,e))),handleReadEmailAutosave:H(Q(e,Pc),y=>y,y=>y?zn(y,e):null),handleEmailAutosave:H(s.onSave,function({prev:y,patch:E,value:N,source:F}){return{value:Is(N,e),source:F}},y=>y?zn(y,e):void 0),handleRemoveEmailAutoSave:H(s.onRemove,({value:y,source:E})=>({value:Is(y,e),source:E}),()=>{}),handleReadBlockRevisions:H(o.byForeignKey("parent").handleRead,y=>y,y=>y?.map(E=>Xn(E))),handleReadBlockAutosave:H(Q(e,ey),y=>y,y=>y?Xn(y):null),handleBlockAutosave:H(o.onSave,({value:y,source:E})=>({value:ml(y),source:E}),y=>y?Xn(y):void 0),handleRemoveBlockAutoSave:H(o.onRemove,({value:y,source:E})=>({value:ml(y),source:E}),()=>{}),handleBlockInit:H(h,y=>ge(y,e)),handleBlockChanged:H(l.debounce(g,Rs),y=>ge(y,e)),handleEmailChanged:H(l.debounce(T,Rs),y=>Se(y,e)),handleEmailInit:Pl(H(x,y=>Se(y,e)),e),handlePreviousButtonClick:H(P,y=>Se(y,e)),handleNextButtonClick:H(S,y=>Se(y,e)),handleSaveButtonClick:H(B,y=>Se(y,e)),handleSaveBlockButtonClick:H(O,y=>ge(y,e)),handleHtmlChanged:H(l.debounce(R,Rs)),handleTestEmailSend:H(D,({html:y,...E})=>({...E,code:y,compiled:{html:y,ampHtml:""}})),handleTestEmailModal:H(L,y=>Se(y,e)),handleCloneEmail:H(c,y=>Se(y,e)),handleShareEmail:H(i),handlePreviewEmail:H(a),handleLivePreviewEmail:H(w),handleAnalyticsEvent:H(U)}}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 vt(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},sy=l.createIdentifier$1("DataController"),oy=l.createIdentifier$1("DataEvents");function Rl(e){return e.getOrCreateInstance(sy,()=>{const t=new Bb(e);return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(t),t})}function kl(e){return e.getOrCreateInstance(oy,()=>new ry(e))}var iy=l.createIdentifier$1("plugin.pluginStart");function Nl(e){return e.getOrCreateInstance(iy,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>t()),{done:n,finish:t}})}function ay(e){return Nl(e).done}function cy(e){const t=Nl(e);return t.run===void 0&&(t.run=(e.getInstance(l.PLUGIN_COLLECTION_ID)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var ly=l.createIdentifier$1("plugin.startupShow");function dy(e){const t=Rl(e),n=kl(e),r=e.getInstance(l.OPTIONS_SOURCE_ID),s=e.getInstance(l.DISPOSABLE_ID),o={current:Promise.resolve()};e.inject(ly,o);let i=!1;const a=r?.watch(d=>{d&&n.setOptions(d),i=(d?.plugins?.length??0)>0,o.current=o.current.catch(()=>{})}),c=r?.select(d=>d?.content).watch(d=>{if(d===void 0)return;const u=()=>(se(fe.showStart),t.show(d).finally(()=>se(fe.showEnd))),f=i?ay(e).then(u):u();f.catch(()=>{}),o.current=f});a&&s?.addDisposable(a),c&&s?.addDisposable(c)}function uy(e){const t=Rl(e);return{...kl(e).get(),show(n){return se(fe.showStart),t.show(n).finally(()=>se(fe.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return se(fe.showStart),t.showBlock(n,r).finally(()=>se(fe.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function Ll(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function Jn(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",s=!1;for(let o=t;o<e.length;o++){const i=e[o];if(s){s=!1;continue}if(i==="\\"){s=!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 fy(e){return(t,n,r)=>Jn(t)?e(t,n,r):!1}function hy(e){return t=>Jn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function py(e){return(t,n,r)=>Jn(t)?Ll(t)?e(t,n,r):t:!1}function my(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return Jn(n)?Ll(n)?e(t):t:!1}}function gy(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function ks(e,t){const n=e.length;for(let r=0;r<n;r++){const s=e.charCodeAt(r);if(s===0||t==='"'&&s===34||t==="'"&&s===39||t===""&&(s===32||s===9||s===10||s===13||s===12||s===34||s===39||s===60||s===62||s===61||s===96))return!1}return!0}function vy(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let s="";for(let o=0;o<e;o++){const i=r[o]%62;s+=t.charAt(i)}return s}var _y=8,Ey=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=vy(_y),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Qn=new Ey;function Ml(e,t){return t!==void 0&&!ks(e,t)?`%|{${Qn.getOrCreateByKey(e)}}|%`:e}function by(e){const t=Qn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function ce(e,t,n){return t!==void 0?ks(e,t)?e:`%|{${Qn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function yy(e){return e.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function ie(e){return e.startsWith("<!--")&&e.endsWith("-->")?yy(e.slice(4,-3)):e}function wy(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 s=e.match(/\[%\s*([^%]*?)\s*%\]/);s&&(r=s[1]);const o=r.trim();return t.test(o)||n.test(o)}function Sy(e,t,n){return t!==void 0?ks(e,t)?e:`%|{${Qn.getOrCreateByKey(e)}}|%`:n||gy(e)||wy(e)?`<!--${e}-->`:e}var Ze=fy(ce),et=hy(ie),Iy=py(ce),Ty=my(ie),xl=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",by),e.escape("@{","}",ce,!0).unescape("<!--@{","}-->",ie,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",Ml,!0),e.escape("{{","}}",Ml,!0),e.createSyntax("brace-percent").escape("{%","%}",ce).unescape("<!--{%","%}-->",ie),e.createSyntax("brace-hash").escape("{#","#}",ce).unescape("<!--{#","#}-->",ie),e.createSyntax("proscript").escape("[%","%]",Sy,!0).unescape("<!--[%","%]-->",ie,!0),e.createSyntax("getresponse").escape("[[IF","]]",ce).escape("[[if","]]",ce).escape("[[ELSE]]","",ce).escape("[[else]]","",ce).escape("[[ENDIF]]","",ce).escape("[[endif]]","",ce).unescape("<!--[[IF","]]-->",ie).unescape("<!--[[if","]]-->",ie).unescape("<!--[[ELSE]]","-->",ie).unescape("<!--[[else]]","-->",ie).unescape("<!--[[ENDIF]]","-->",ie).unescape("<!--[[endif]]","-->",ie),e.createSyntax("expert-sender").escape("<if",">",ce).escape("</if",">",ce).escape("<else",">",ce).escape("</else",">",ce).escape("<var ",">",ce,!0).unescape("<!--<if ",">-->",ie).unescape("<!--</if",">-->",ie).unescape("<!--<else ",">-->",ie).unescape("<!--</else",">-->",ie).unescape("<!--<var",">-->",ie,!0),e.createSyntax("velocity").escape("#if",")",Ze).escape("#elseif",")",Ze).escape("#else","",ce).escape("#foreach",")",Ze).escape("#macro",")",Ze).escape("#set",")",Iy,!0).escape("#parse",")",Ze).escape("#include",")",Ze).escape("#evaluate",")",Ze).escape("#end","",ce).escape("#break","",ce).escape("#stop","",ce).unescape("<!--#macro","-->",et).unescape("<!--#if","-->",et).unescape("<!--#elseif","-->",et).unescape("<!--#else","-->",ie).unescape("<!--#foreach","-->",et).unescape("<!--#parse","-->",et).unescape("<!--#include","-->",et).unescape("<!--#evaluate","-->",et).unescape("<!--#end","-->",ie).unescape("<!--#break","-->",ie).unescape("<!--#stop","-->",ie).unescape("<!--#set","-->",Ty,!0),e.createSyntax("mailchimp").escape("*|","|*",ce).unescape("<!--*|","|*-->",ie)},Ns="bare",Ay=new Map;function Cy(e){return e?Ay.get(e)??Ns:Ns}var Fl=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function Bl(e){return Fl.includes(e)}function Kt(e){return e==="bare"||e==="html-comment"}function Ls(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Oy(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!Kt(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&&!Kt(u))return t(`templateDirectives.${d}: unknown form "${String(u)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!Ls(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(!(!Bl(d)||u===void 0||Kt(u))){if(!Ls(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&&!Kt(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 s=r.output??Ns;let o=r.editor;s==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),o=void 0);const i=[];if(r.syntaxes)for(const d of Object.keys(r.syntaxes)){if(!Bl(d)){t(`templateDirectives.syntaxes: unknown syntax id "${d}", entry ignored.`);continue}i.push(d)}else i.push(...Fl);const a={},c={};for(const d of i){const u=r.syntaxes?.[d],f=Ls(u)?u:void 0,h=(Kt(u)?u:f?.output)??s;let g=f?.editor??o??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 jl(e,t,n,r){for(let s=t;s<n;s++){const o=e[s];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?o===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(o)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):o==="<"?r.insideTag=!0:o===">"?r.insideTag=!1:r.insideTag&&(o==='"'||o==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=o,r.unquotedAttr=!1):r.insideTag&&/\S/.test(o)&&r.attributeQuoteChar===void 0&&e[s-1]==="="&&!['"',"'","`"].includes(o)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function qt(e,t){return e.start<t.end&&t.start<e.end}function Ul(e,t,n,r,s=[]){if(n&&(t=t.filter(u=>u.isVariable)),!t.length)return[];const o=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=s.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:m}of o){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):jl(e,d,u.start,c),d=u.end,a.some(A=>qt(A,u)))continue;const v=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,_=e.substring(u.start,u.end),T=f(_,v,c.insideTag);T!==!1&&T!==_&&(i.push({range:u,text:T,overrideBuiltins:h,syntax:g,isVariable:m}),a.push(u))}return i.sort((u,f)=>u.range.start-f.range.start||u.range.end-f.range.end)}function Dy(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("|"),s=new RegExp(r,"g"),o=[];let i;for(;(i=s.exec(e))!==null;){const a=i[0];o.push({start:i.index,startToken:a,endTokens:n[a]})}return o}function Ms(e,t,n,r,s=!1){const o=[];if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return o;const i=Dy(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='"'):jl(e,c,u,a),c=u;const g=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let m=!1;for(const{mapFn:v,value:_,syntax:T,isVariable:A}of h){let B=u+f.length,O=e.indexOf(_,B);for(;O!==-1;){let S=O,w=u+f.length,D=0;for(;S!==-1;){const L=e.indexOf(f,w);if(L!==-1&&L<S)D++,w=L+f.length,S=e.indexOf(_,w);else if(D>0)D--,w=S+_.length,S=e.indexOf(_,w);else break}if(S<0)break;const I=S+_.length,R=e.substring(u,I),M=v(R,g,a.insideTag);if(M===!1){B=O+Math.max(_.length,1),O=e.indexOf(_,B);continue}(s||M!==R)&&o.push({range:{start:u,end:I},text:s?R:M,syntax:T,isVariable:A});const P=i.findIndex(({start:L})=>L>=I);P>d?d=P-1:d=i.length,m=!0;break}if(m)break}}return o}function Zn(e,t){if(!t.length)return e;const n=t.slice().sort((s,o)=>o.range.start-s.range.start);let r=e;for(const{text:s,range:o}of n)r=r.slice(0,o.start)+s+r.slice(o.end);return r}var Py=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=xl){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,s,o,i){return t.push({start:r,end:s,mapFn:o,isVariable:i,syntax:this.syntax||r}),this},unescape(r,s,o,i){return n.push({start:r,end:s,mapFn:o,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 s=!1;const o={dispose:()=>{s||(s=!0,this._escapeMatchers=this._escapeMatchers.filter(i=>i!==n),this._unescapeMatchers=this._unescapeMatchers.filter(i=>i!==r))}};return this.addDisposable(o),o}_collectMappings(e,t,n){const r=Ms(e,this._escapes,t,n),s=Ul(e,this._escapeMatchers,t,n),o=s.filter(c=>c.overrideBuiltins).map(c=>c.range),i=r.filter(c=>!o.some(d=>qt(d,c.range))),a=s.filter(c=>c.overrideBuiltins||!i.some(d=>qt(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=Ms(e,this._unescapes,t),r=Ul(e,this._unescapeMatchers,t,!1),s=r.filter(a=>a.overrideBuiltins).map(a=>a.range),o=n.filter(a=>!s.some(c=>qt(c,a.range))),i=r.filter(a=>a.overrideBuiltins||!o.some(c=>qt(a.range,c.range)));return[...o,...i].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?s=>s!==void 0&&n.has(s):s=>Cy(s)==="html-comment";return this._collectRevertMappings(e,t).filter(s=>s.isVariable||!r(s.syntax))}getDetectedMappings(e,t,n){return Ms(e,this._escapes,t,n,!0)}getEscapedText(e,t){return Zn(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return Zn(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=o=>o===void 0?void 0:t[o],r=Object.values(t);let s=e;return r.includes("bare")&&(s=Zn(s,this._collectRevertMappings(s).filter(o=>n(o.syntax)==="bare"))),r.includes("html-comment")&&(s=Zn(s,this._collectMappings(s).filter(o=>!o.isVariable&&n(o.syntax)==="html-comment"&&o.text.startsWith("<!--")&&o.text.endsWith("-->")))),s}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()}},$l="em___script",zt=`<${$l}`,xs=`</${$l}>`;function Hl(e){return e.replace("<script",zt).replace("<\/script>",xs)}var Vl=new Py(e=>{e.escape("<script","<\/script>",t=>Hl(t)).unescape(zt,xs,t=>t.replace(zt,"<script").replace(xs,"<\/script>")),e.escape("<script","/>",t=>Hl(t)).unescape(zt,"/>",t=>t.replace(zt,"<script")),xl(e)});function Ry(e){const t=Oy(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return qo();const n=new Set(Object.keys(t.output).filter(s=>t.output[s]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:s=>Vl.normalizeToPolicy(s,t.editor),toOutputForm:s=>Vl.normalizeToPolicy(s,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:Ko(r)}}function ky(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:Ry(n)}),t.policy})}function VA(e){return e}var Ny=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function Ly(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const s=t.get(r)??[];s.push(n),t.set(r,s)}return t}function My(e,t){const n=[];for(const r of e.awaits?.services??[])for(const s of t.get(r)??[])s!==e&&n.push(s);return n}function Gl(e){const t=Ly(e),n=[],r=new Set,s=[],o=new Set,i=a=>{if(!r.has(a)){if(o.has(a)){const c=s.indexOf(a);throw new Ny([...s.slice(c),a].map(d=>d.name))}o.add(a),s.push(a);for(const c of My(a,t))i(c);s.pop(),o.delete(a),r.add(a),n.push(a)}};for(const a of e)i(a);return n}var xy=[{name:"rest.client",setup:RE},{name:"auth.oauth",setup:l.provideOAuth},{name:"rest.identityHeaders",setup:bE},{name:"rest.localeHeader",setup:AE},{name:"lifetime.destroyable",provides:[us],setup:E_},{name:"host.load",setup:H_},{name:"appInit",provides:[l.APP_ID,hr],setup:Ou},{name:"config",provides:[l.CONFIG_SOURCE_ID],setup:v_},{name:"templateDirectives",provides:[l.TEMPLATE_DIRECTIVES_ID],setup:ky},{name:"email.documents",setup:B_},{name:"show.initPipeline",provides:[l.INIT_PIPELINE_ID],setup:kE},{name:"show",setup:dy},{name:"locale.service",provides:[Je],setup:gE},{name:"locale.fromConfig",awaits:{services:[l.CONFIG_SOURCE_ID,Je]},setup:vE},{name:"canvas.early",setup:dv},{name:"canvas.previewSettings",setup:Cv},{name:"canvas.sandboxExtensions",setup:Dv},{name:"canvas.sandboxScriptRelay",setup:kv},{name:"canvas.headerSync",provides:[rs],setup:hv},{name:"canvas.headersAfterRecovery",setup:pv},{name:"canvas.ampSync",setup:im},{name:"canvas.moduleBridge",setup:Fm},{name:"canvas.port",setup:gm},{name:"canvas.images",setup:pm},{name:"canvas.edits",setup:cv},{name:"canvas.surfaceFollowsSession",setup:Yg},{name:"canvas.blockContent",setup:Wg},{name:"canvas.sandboxFill",provides:[ts],setup:Xv},{name:"canvas.reactions",setup:lv}],Wl;function Fs(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=re();e.inject(l.OPTIONS_SOURCE_ID,n),Wl??=Gl(xy);for(const r of Wl)r.setup(e);return n}function Fy(e){}var By=[{name:"save.previewFollow",setup:Fy}],Yl=l.createIdentifier$1("plugin.lateUnitsInstalled");function jy(e){if(!e.getInstance(Yl)){e.inject(Yl,!0);for(const t of Gl(By))t.setup(e)}}function Uy(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function $y(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 Hy=l.defineMixin(e=>{let t,n,r;return{async setOptions(s){const o=r!==s.getAuthToken,i=!l.deepEqual(t,s.user),a=n!==s.project;if(r=s.getAuthToken,t=s.user,n=s.project,!(!e.getInstance(l.SECURITY_MODULE_ID)||!s.getAuthToken)&&!(!o&&!i&&!a))try{const c=await s.getAuthToken(s.user,s.project);e.inject(l.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(c||""));const d=$y(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(Uy(d,f)))}catch{}}}});function Vy(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 Gy=l.defineMixin(e=>{let t,n=!1;return{setOptions(r){const s=n;if(n=!0,!Ut(r)){t&&(s_(e),ds(r)),t=void 0;return}const o=Bn(r);if(!o||t===o&&e.getInstance(l.SECURITY_MODULE_ID))return;t=o,e.inject(l.SECURITY_MODULE_ID,o);const i=e.getInstance(l.DISPOSABLE_ID);i&&Vy(e,i)}}});function Kl(e,t,n=!0){const r=e,s=t;for(const o of Object.keys(s)){const i=s[o];i!=null&&(n&&typeof i=="object"?r[o]=Kl(r[o]||{},i,!0):r[o]=i)}return e}async function Wy(e){const t=(await Zd.__vitePreload(()=>Promise.resolve().then(()=>Promise.resolve(sn("./static/umd/6639d610.js")).then(n=>wt.__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 ql=l.createIdentifier$1("EditorOptions"),Bs=l.MONACO_EDITOR_OPTIONS;function Yy(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 Ky(e){return e.getOrCreateInstance(ql,()=>{const t=re(Bs);let n=Bs.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(Wy(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function qy(e){return e?.getInstance(ql)?.get()??Bs}function zy(e,t={}){const n=Ky(e);n.set(Kl({...n.get()},Yy(t)))}function Xy(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 Jy(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var Qy=l.createIdentifier$1("plugin.publicConfig");function js(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.get()??{}}function zl(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function Xl(e){const t=hc(e),n=js(e);return{...n,locale:n.locale||"en_US",theme:n.theme||"light",editor:Jy(qy(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Jl(e){return e.getInstance(l.CONFIG_SOURCE_ID)?.get()!==void 0}function Zy(e){const t=l.createQueue(),n=pe(e,l.CONFIG_CHANGED_EVENT_ID);let r,s,o=!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(),Ao(e).set(js(e).revisionService===!0);const{codeModeDirection:h,editor:g}=js(e);g&&zy(e,Xy(g)),h!==void 0&&!(f&&h===s)&&(s=h,h==="none"?os(e,!1):(os(e,!0),yv(e,h)))},c=async()=>{if(!Jl(e))return;const f=Xl(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:zl(e).advancedConfigs,serverSide:await i(),user:f};h?.setAdvancedConfigs({...g.advancedConfigs,...g.user?.advancedConfigs});const m=h?.layers().user.mode;h?.replace(g.user?.mode===void 0&&m!==void 0?{...g.user,mode:m}:g.user,"user"),h?.replace(g.serverSide,"server"),await a(),await c()},u=f=>{const{commonStyles:h,...g}=f;return"commonStyles"in f&&Sv(e,h===void 0?void 0:h),g};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:i,getConfig:()=>Jl(e)?Xl(e):{},setConfig:t.decorate(async f=>{await d(u(f))}),updateConfig:t.decorate(async f=>{const h=u(f);await d({...zl(e).user,...h})}),announceAssembled(){o||(o=!0,e.getInstance(l.CONFIG_SOURCE_ID)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function Ql(e){return e.getOrCreateInstance(Qy,()=>Zy(e))}function ew(e){const t=Ql(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var tw=l.defineMixin(e=>{const t=e.getInstance(l.DISPOSABLE_ID),n=t.addDisposable(new l.AsyncEmitter),r=t.addDisposable(new l.AsyncEmitter),s=l.getEmitter(e,l.CONFIG_CHANGED_EVENT_ID),o=H(n.event),i=H(r.event),a=Pl(H(s.event),e),c=t.addDisposable(new vt(o)),d=t.addDisposable(new vt(i)),u=t.addDisposable(new vt(a));return{instance:{handleSetOptions:o,handleOptionsChanged:i,handleConfigChanged:a},async setOptions(f){c.setListener(f.handleSetOptions),d.setListener(f.handleOptionsChanged),u.setListener(f.handleConfigChanged),Ql(e).announceAssembled(),await n.fire(f),await r.fire(f)},dispose(){}}}),Us,Zl="core";function nw(){const e=__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Zl],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function rw(e){const t=__useblocks__?.require?.warm;return typeof t!="function"?Xt().then(()=>{}):t([Zl],e)}function Xt(){return Us===void 0&&(Us=nw().then(e=>(St()&&e.installDiagnostics().catch(t=>{}),e))),Us}var $s=null,Hs=null;async function sw(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Vs(){return $s||($s=Xt().then(()=>{})),$s}function ed(e){return Hs||(Hs=sw(e)),Hs}function ow(){return ed(typeof __useblocks__<"u"?__useblocks__:void 0)}function iw(){const e=typeof __useblocks__<"u"?__useblocks__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function aw(e){return Promise.all([Vs(),ed(e)]).then(()=>{})}function cw(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function td(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>rw(t?{priority:t}:void 0)).then(()=>(Kr(t?{priority:t}:void 0),n?Vs():void 0)).catch(()=>{})}function lw(e){const t=cw(e);if(t==="eager")td(e);else if(t==="idle"){const n=()=>td(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var nd="PluginRegistry";function dw(e=l.resolveContainer()){return e.getOrCreateInstance(nd,()=>new au)}var er=new cu(()=>dw());function uw(e){const t=Ce(e),n=In(e);return{dispose:()=>{Ee("ui",()=>n.disposeAll()),Ee("commands",()=>t.disposeAll())}}}function fw(e,t){const n=We(e);return t.onLifecycle(r=>n.handle(r))}var hw=["Commands","Ui","Agent","Document"],rd=new Set(["Agent","Document"]),sd=new Map;function pw(e,t){for(let n=e;typeof n=="function";n=Object.getPrototypeOf(n))if(ea(n,t))return!0;return!1}function mw(e,t,n){sd.get(e)!==t&&sd.set(e,t)}function gw(e,t){if(pw(t,e))return;const n=typeof t=="function"?t.name||"anonymous":typeof t;if(rd.has(e)){mw(e,t,n);return}}function vw(e){const t=hw.map(n=>e.on(n,r=>gw(n,r)));return{dispose:()=>t.forEach(n=>n.dispose())}}var od=new WeakMap,id=new WeakSet;function _w(e,t,n){const r=e.getInstance(l.DISPOSABLE_ID);if(r?.isDisposed()){Ee("ui",()=>In(e).disposeAll()),Ee("commands",()=>Ce(e).disposeAll());return}od.get(e)?.dispose();const s=new l.Disposable([fw(e,t),vw(n)]);od.set(e,s),r?.addDisposable(s),r&&!id.has(e)&&(id.add(e),r.addDisposable(uw(e)))}function Ew(e){return e?.lockEditor===!0}var ad={text:"text",img:"image",a:"link",button:"button",div:"container",vindent:"spacer",video:"video",table:"table",customTable:"table",structure:"row",column:"column",td:"cell",var:"variable",countdown:"countdown",carousel:"carousel",accordion:"accordion",social:"social",floatBlock:"floatingBlock"};function bw(e){return typeof e=="string"&&Object.hasOwn(ad,e)&&ad[e]||"none"}function Jt(e,t,n){let r,s;const o=()=>{const i=e.getInstance(t);return i===void 0||r?r!==void 0:(r=n(i),!0)};return o()||(s=e.onInject(i=>{i===t&&o()&&s?.dispose()})),{dispose:()=>{s?.dispose(),r?.dispose()}}}function yw(e){const t=ht(e),n={editor:!1,document:!1},r=()=>xt(t,{readOnly:n.editor||n.document});r();const s=[Hr(e).watch(o=>xt(t,{headless:o})),xn(e).watch(({isCodeMode:o})=>xt(t,{codeMode:o})),Jt(e,l.CONFIG_SOURCE_ID,o=>o.watch(i=>{n.editor=Ew(i),r()})),Jt(e,nt,o=>{let i,a;const c=()=>{const h=o.sessionKey(),g=h!==void 0&&!J(h)?o.current()?.get().attributes:void 0;n.document=g?.lock===!0&&!Do(e,g),r()},d=()=>{const h=o.sessionKey();xt(t,{documentOpen:h!==void 0,documentKind:h===void 0?void 0:J(h)?"block":"email"});const g=o.current();g!==i&&(a?.(),i=g,a=g?.subscribe(c)),c()};d();const u=o.subscribe(d),f=Pu(e,c);return{dispose:()=>{u(),a?.(),f.dispose()}}})];return s.push(Jt(e,l.STORE_ID,o=>{const i=()=>{const d=o.getState(),u=be(t)?.documentKind==="block"?d.blockSlice:d.emailSlice;xt(t,{selection:bw(u?.elementSettings?.type)})};i();const a=t.select(d=>d?.documentKind).watch(i),c=o.subscribe(i);return{dispose:()=>{c(),a.dispose()}}})),{dispose:()=>s.forEach(o=>o.dispose())}}var ww=["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"],Sw=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],tr=new Map([...ww.map(e=>[e,"event"]),...Sw.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),Iw=new Map([["use","use `useAsync()` or await `ready` first"]]);function Tw(e){return Iw.get(e)??"await `ready` first"}var Aw=new Set(["async","queued"]),Cw=Symbol.for("emailmaker.earlyCtxPlaceholder");function cd(e){return e[Cw]=!0,e}function Ow(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 (${Tw(e)}).`)}function Dw(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function Pw(e){return[...tr].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function Rw(e,t){for(const n of Pw(e)){const r=tr.get(n);if(r!==void 0&&Aw.has(r)){const s=async(...o)=>{await t;const i=e[n];if(typeof i!="function"||i===s)throw Dw(n);return i.apply(e,o)};e[n]=cd(s);continue}e[n]=cd(()=>{throw Ow(n)})}}function kw(e,t,n){e.getInstanceAsync(Et).then(()=>{l.getEmitter(e,l.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function Nw(e,t){e.getInstanceAsync(Et).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 Lw=l.defineMixin(e=>{let t;function n(){return new Promise(s=>{const o=e.getOrCreateInstance(l.LATE_SURFACE_LISTENERS_ID,()=>new Set),i=()=>{o.delete(i),s()};o.add(i)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(s){const o=e.getInstance(l.INSTANCE_ID),i=e.getInstance(nd);if(!t){t=new iu(o,i,{ensureHostRuntimeReady:ow,explainScriptFailure:iw,openEarlyWindow:()=>ny(e),reportLoadFailure:d=>Nw(e,d)}),e.inject(l.PLUGIN_COLLECTION_ID,t),_w(e,t,i);const c=t.onLifecycle(d=>{d.type==="create:error"&&kw(e,d.name,d.error)});e.getInstance(l.DISPOSABLE_ID)?.addDisposable(c),e.getInstance(l.DISPOSABLE_ID)?.addDisposable(yw(e))}const a=s?.plugins||[];o&&(Hr(e),a.length>0&&Rw(o,n()),await t.setPlugins(a))},instance:{use(s){return typeof s=="function"?r().useByCtor(s):r().useByKey(s)},useAsync(s){return r().useAsync(s)},waitPlugin(s){return r().waitFor(s)}},dispose(){t?.dispose(),t=void 0}}}),Mw=[tw,Gy,l.JWTMixin,Hy,l.OAuthMixin];async function xw(){return(await Xt()).asyncMixins}var Fw=Lw,Bw=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let s;try{s=await xw()}catch(i){throw e.failPendingWaits(i),i}t=s(e);const o=await e.getInstanceAsync(l.INSTANCE_ID);Object.assign(o,t.instance||{});for(const i of e.getInstance(l.LATE_SURFACE_LISTENERS_ID)??[])i()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},jw=l.combineMixins([...Mw]),Uw=class{_context;constructor(e){this._context=e}tools(){return Tn(this._context.container).tools()}invoke(e,t,n){return Tn(this._context.container).invoke(e,t,n)}turn(e){return Tn(this._context.container).turn(e)}undoTurn(){return Tn(this._context.container).undoTurn()}},ld=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const s=this._listeners.indexOf(r);s>=0&&this._listeners.splice(s,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}},$w=l.createIdentifier$1("ELEMENT_INSERT_HTML_PIPELINE"),Hw=l.createIdentifier$1("BLOCK_INSERT_HTML_PIPELINE"),Vw="application_block_inserted",Gw=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Hw,()=>new ld).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(l.MESSAGE_SERVICE_ID,()=>new l.MessageService),s=n?e.bind(n):e;return r.addListener(Vw,s,t)}},Ww=class{_context;constructor(e){this._context=e}register(e,t){const n=this._context.container,r=We(n).current(),s={},o={};for(const[i,a]of Object.entries(e)){const{run:c,...d}=a;if(typeof c!="function")throw new Error(`Command "${i}" of "${r.name}" has no \`run\`; declare it with defineCommand({ title, run }).`);s[i]=d,o[i]=c}return Ce(n).register(r,s,o,t)}run(e,...t){return Ce(this._context.container).run(e,t[0],{caller:"plugin"})}has(e){return Ce(this._context.container).has(e)}},Yw=class{_context;constructor(e){this._context=e}onWillSave(e){const t=this._context.container;return Le(t).onWillSave(We(t).current(),e)}onDidChange(e){const t=this._context.container;return Le(t).onDidChange(We(t).current(),e)}get selection(){return Le(this._context.container).selection}transaction(e){return Ur(this._context.container).group(e)}},Gs=l.createIdentifier$1("ComponentRegistry"),Kw=l.createIdentifier$1("ComponentRegistryGate");function Ws(){return l.DependencyResolver.getOrCreateInstance(Kw,()=>({pending:[]}))}function qw(e=Gs){return Ws().factory!==void 0||l.DependencyResolver.getInstance(e)!==void 0}function Ys(e,t,n=Gs){if(qw(n)){t(nr(e,n));return}Ws().pending.push(()=>t(nr(e,n)))}function nr(e,t=Gs){const n=l.DependencyResolver.getInstance(t);if(n)return n;const r=Ws().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 zw=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=o=>{if(!n){n=!0;for(const i of t)i.dispose();e(o)}};t.push(this._container.addService(l.ATOMS_HANDLERS_ID,{execute:o=>{r(o.value.map(i=>({name:i.name,html:i.html})))}}));const s=this._container.getInstance(l.HEADLESS_MODE_ID)?.watch(o=>{o&&r([])});s&&(n?s.dispose():t.push(s))})}update(e,t){const n=this._container;return n.addService(l.ATOMS_HANDLERS_ID,{execute:r=>{const s=nr(n),o=r.value.find(i=>i.name===e);if(o){const{icon:i,title:a,fallbackTooltip:c,...d}=t;i&&(o.icon=s.getReactNode(i)),a&&(o.title=s.getReactNode(a)),c&&(o.fallbackTooltip=s.getReactNode(c)),Object.assign(o,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 s=nr(n);r.value.splice(t??r.value.length,0,{...e,title:s.getReactNode(e.title),icon:s.getReactNode(e.icon),fallbackTooltip:s.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance($w,()=>new ld).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)}},Xw=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 Jw(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function dd(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 Qw=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 Ys(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:dd(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Ys(this._container,r=>{const s=o=>o===void 0?void 0:r.getReactNode(o);this._updateModalEmitter.fire(Jw({...t,content:s(t.content),title:s(t.title),id:e,modalProps:dd(r,n)}))})}};function rr(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var Zw=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=s=>{this._loadedSettled||(this._loadedSettled=!0,r(s))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=s=>{this._readySettled||(this._readySettled=!0,r(s))}})}_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)}},eS=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,s=>{if(s.key===e){if(s.phase==="load"&&s.status==="success"){r.resolveLoaded();return}if(s.phase==="ready"&&s.status==="success"){r.resolveReady();return}if(s.phase==="load"){r.rejectLoad(new Error(s.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(s.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new Zw(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(l.SANDBOX_EXTENSIONS_ID,{...rr(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,{...rr(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,{...rr(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,{...rr(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},tS=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function Ks(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&tS.has(t)}function ud(){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 qs(){return`__settingsPanel:${ud()}`}function zs(e,t){return{type:e,props:t}}function nS(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!Ks(e)}function fd(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(Ks(t)){const r=qs();return n(e.add(r,t)),zs(r,{})}if(typeof t=="function"){const r=qs();return n(e.add(r,t)),zs(r,{})}if(nS(t)){const r=t.type;if(typeof r=="string")return t;if(Ks(r)||typeof r=="function"){const s=qs();return n(e.add(s,r)),zs(s,t.props)}return t}return t}var rS=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??ud();Ys(this._container,n=>{const r=i=>this._trackRegistration(i),s=fd(n,e.content,r),o=e.advancedTabs?.map(i=>({...i,content:fd(n,i.content,r)}));l.getEmitter$1(this._container,l.SETTINGS_PANEL_EVENT).fire({...e,content:s,advancedTabs:o,instanceKey:t,type:l.ADVANCED_SETTINGS_PANEL})})}closeSettingsPanel(){this._clearPanelRegistrations(),l.getEmitter$1(this._container,l.SETTINGS_PANEL_EVENT).fire(null)}},sS=class{_context;constructor(e){this._context=e}get apiVersion(){return this._service().apiVersion}supports(e,t){return this._service().supports(e,t)}addViews(e,t){return this._service().addViews(this._owner(),e,t,this._context)}addItem(e){return this._service().addItem(this._owner(),e)}open(e,...t){return this._service().open(e,t[0])}_service(){return In(this._context.container)}_owner(){return We(this._context.container).current()}},hd=xr({SandboxScriptApi:eS,ElementsApi:zw,BlocksApi:Gw,MessageService:Xw,SettingsPanelApi:rS,ModalApi:Qw,Commands:Ww,Ui:sS,Agent:Uw,Document:Yw});function Xs(e,t,n,r={}){const s=Object.assign({},e);for(const[o,i]of Object.entries(t))if(i!==void 0)if(n.includes(o)&&typeof i=="object"&&i!==null){const a=s[o],c=r[o]??{};s[o]=Object.assign({},typeof a=="object"&&a!==null?a:c,i)}else s[o]=i;return s}var Te={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}},oS={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"},Js={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},pd={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},bt={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:Te.border,borderRadius:Te.borderRadius,textAlign:"center",padding:Te.padding},md={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:Te.padding},Qs={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:Te.border,borderRadius:Te.borderRadiusCards};function iS(e){return{...oS,...e}}function aS(e){return{...Js,...e,bold:e?.bold??Js.bold,italic:e?.italic??Js.italic}}function cS(e){return{...pd,...e,underline:e?.underline??pd.underline}}function lS(e){return{...bt,...e,bold:e?.bold??bt.bold,italic:e?.italic??bt.italic,border:{...bt.border,...e?.border},borderRadius:{...bt.borderRadius,...e?.borderRadius},padding:{...bt.padding,...e?.padding}}}function dS(e){return{...md,...e,padding:{...md.padding,...e?.padding}}}function uS(e){return{...Qs,...e,border:{...Qs.border,...e?.border},borderRadius:{...Qs.borderRadius,...e?.borderRadius}}}function Zs(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 gd(e){let t={...l.COMMON_STYLES};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function eo(e){return{text:iS(e.text),headings:aS(e.headings),links:cS(e.links),buttons:lS(e.buttons),block:dS(e.block),cards:uS(e.cards)}}var to=l.createIdentifier$1("EmailSettingsPort");function fS(e){return e?.getInstance(to)}var hS=1e4,vd=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(!Dl(this._editor.container)||!rt(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(to);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Zs(this._settings().read())}_getCurrentContentStyles(){const e=rt(this._editor.container)?.current()?.get().attributes.common_styles;return eo(gd(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(to),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 s=r?.data,o=s?.operation;if(o===l.EVENT_TYPES.APPLICATION_EMAIL_SETTINGS_SET){const c=Zs(s?.settings),d=this._getLayoutSnapshot(c);d!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=d,this._layoutSettingsChanged.fire(c));return}if(o!==l.EVENT_TYPES.APPLICATION_COMMON_STYLES_UPDATE)return;const i=eo(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=Zs(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=hS){const t=rt(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,s=l.getEvent(r,l.events.ON_EMAIL_INIT_ID);return new Promise(o=>{let i=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},d=s(()=>{i||(i=!0,c(),d.dispose(),o())});a=setTimeout(()=>{i||(i=!0,d.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=rt(this._editor.container)?.current();if(!t)return;const n=gd(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=Xs(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:Te.border,borderRadius:Te.borderRadius,padding:Te.padding})),e.block!==void 0&&(n.block=Xs(n.block||{},e.block,["padding"],{padding:Te.padding})),e.cards!==void 0&&(n.cards=Xs(n.cards||{},e.cards,["border","borderRadius"],{border:Te.border,borderRadius:Te.borderRadiusCards}));const r=JSON.stringify(n);at(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const s=eo(n);this._prevContentSnapshot=this._getContentSnapshot(s),this._contentStylesChanged.fire(s)}},pS={...hd,...xr({EmailSettingsApi:vd})};function mS(e){const t=e;return rd.has(e)&&er.has(t)&&!ea(er.get(t),e)}function gS(e){er.addAll(Object.fromEntries(Object.entries(e).filter(([t])=>!mS(t))))}var vS={...hd},GA={...vS,...xr({EmailSettingsApi:vd})},_S={...pS};function ES(){gS(_S)}function no(){let e,t=!1;const n=new Map,r=new Map;function s(){for(const o of r.values())o();r.clear()}return{event(o,i,a){const c=Symbol("subscription");return t||(n.set(c,{listener:o,priority:i,thisArg:a}),e&&r.set(c,e(o,i,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(o){s(),e=o;for(const[i,{listener:a,priority:c,thisArg:d}]of n)r.set(i,o(a,c,d))},dispose(){t=!0,s(),n.clear(),e=void 0}}}function bS(e){const t=no(),n=no(),r=no();return e.getInstance(l.DISPOSABLE_ID)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(Et).then(s=>{t.attach(s.onNotify),n.attach(s.onError),r.attach(s.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(s){const o=e.getInstance(Et);if(o){o.notify(s);return}e.getInstanceAsync(Et).then(i=>i.notify(s),()=>{})}}}var _d=l.createIdentifier$1("CodeErrors"),yS=[];function wS(e){return e?.getInstance(_d)?.get()??yS}function SS(e){return e?.getInstance(_d)!==void 0}function IS(e){const t=ha(e);let n;const r=()=>{const o=e.getInstance(l.CONFIG_SOURCE_ID);return o&&!n&&(n=o.watch(i=>t.set(i?.agent??{}))),n!==void 0},s=r()?void 0:e.onInject(o=>{o===l.CONFIG_SOURCE_ID&&r()&&s?.dispose()});return{dispose:()=>{s?.dispose(),n?.dispose()}}}function TS(e){const t=Le(e);return Jt(e,nt,n=>{let r,s;const o=()=>{const c=n.sessionKey();c!==void 0&&t.emitChange({kind:J(c)?"block":"email"})},i=()=>{const c=n.current();c!==r&&(s?.(),r=c,s=c?.subscribe(o),c&&o())};i();const a=n.subscribe(i);return{dispose:()=>{a(),s?.()}}})}function AS(e,t){if(e===t)return!0;try{return l.deepEqual(JSON.parse(e||"{}"),JSON.parse(t||"{}"))}catch{return!1}}var WA=l.createIdentifier$1("planFeatures.source");function ro(e){return ye(e)?.current()}function CS(e){return be(ht(e))?.readOnly===!0}var OS=()=>oe("readOnly","The document is read-only.");function DS(e,t){return!1}var PS=e=>oe("lockedByPlan",e);function RS(e,t,n){return DS(e,t)?PS(`Working with ${n} is not available on the current plan.`):void 0}function kS(e){return RS(e,"undo_redo","undo and redo")}var NS=l.CANVAS_FOCUS_WAIT_MS+l.CANVAS_SETTLE_MARGIN_MS;function Ed(e){const t=ae(e);return t.isInited()&&!!t.getTarget()}async function LS(e,t){const n=ae(e);if(!Ed(e))return oe("unavailable","The canvas is not open.");try{const r=await Ba(n.sendAsync(l.EVENT_TYPES.SANDBOX_ELEMENT_OPERATION,t),NS,"sandbox:element");if(!r)return oe("unavailable","The canvas does not support element commands.");if(r.ok)return He(r.value);const s=r;return oe(s.code,s.message)}catch(r){if(r instanceof Fa)return oe("unavailable","The canvas did not answer in time.");throw r}}var bd=["subject","preheader","title","utm_parameters","common_styles","meta"],MS={id:0,below:0},yd=()=>({code:"nothingToUndo",message:"The last answer changed nothing that could be undone."}),yt=e=>({code:"undoConflict",message:e});function xS(e,t,n){return e==="common_styles"?AS(t,n??""):l.deepEqual(t,n)}function wd(e,t){return Object.fromEntries(bd.filter(n=>!xS(n,e[n],t[n])).map(n=>[n,e[n]]))}function FS(e){const t=()=>{const n=ro(e);if(!n)return;const{docId:r,attributes:s}=n.get();return{docId:r,step:ye(e)?.history()?.currentStep()??MS,fields:Object.fromEntries(bd.map(o=>[o,s[o]]))}};return{document:()=>ro(e)?.get().docId,capture:t,undoRefusal:()=>kS(e)?.error,settle:async()=>{if(Ed(e))return(await LS(e,{op:"settle"})).ok?void 0:yt("The canvas did not answer, so edits made after the answer cannot be ruled out.")},undo:(n,r)=>{const s=n,o=r;if(!s)return yd();if(o?.docId!==s.docId)return yt("The answer ended on another email.");const i=o.step.id!==s.step.id,a=wd(s.fields,o.fields);if(!i&&Object.keys(a).length===0)return yd();const c=ro(e),d=t();if(!c||d?.docId!==o.docId)return yt("Another email is open now, not the one the answer changed.");if(CS(e))return OS().error;if(d.step.id!==o.step.id||Object.keys(wd(d.fields,o.fields)).length>0)return yt("The email was edited after the answer.");if(i&&o.step.below!==s.step.id)return yt("The answer moved through the undo history itself and cannot be taken back as one step.");if(i&&!ye(e)?.history()?.tryUndo())return yt("The step of the answer could not be undone: the text changed under it.");Object.keys(a).length>0&&(c.mutate({attributes:a},{source:"user"}),fS(e)?.markAppearanceChanged())}}}function BS(e){let t;return Ur(e).connect({begin:()=>{t??=ye(e)?.history()?.beginTransaction()},end:()=>{const n=t;t=void 0,n?.()},answers:FS(e)})}function jS(e){const t=Le(e).selection,n=ae(e),r=()=>t.set(null),s=n.addListener(a=>{const c=a?.data;c?.operation===l.EVENT_TYPES.APPLICATION_ELEMENT_SETTINGS_SET?t.set(c.type&&typeof c.elementRef=="string"?c.elementRef:null):c?.operation===l.EVENT_TYPES.APPLICATION_ELEMENT_SETTINGS_CLOSE&&r()}),o=At(n,r),i=Jt(e,nt,a=>{let c=a.current();return{dispose:a.subscribe(()=>{a.current()!==c&&(c=a.current(),r())})}});return{dispose:()=>{s.dispose(),o(),i.dispose()}}}function US(e){const t=[IS(e),BS(e),TS(e),jS(e)];return{dispose:()=>t.forEach(n=>n.dispose())}}function YA(e){return e}var $S="SAVE",HS="SAVE_BLOCK",KA="SET_THEME",qA="NOTIFY",zA="SET_CONFIG",XA="UPDATE_CONFIG",Sd=class extends l.Disposable{_options;_listeners=[];constructor(e){super(),this._options=e}fire=e=>{if(!this.isDisposed()){let t;const n=[...this._listeners];for(const r of n){if(t===!1)return!1;t instanceof Promise?t=t.then(s=>s===!1||this.isDisposed()?!1:r(s)).catch(s=>{}):t=r(e)}return t}};addEventListener=e=>{const t=this._listeners,n=this._options;return t.push(e),t.length===1&&this._options?.onFirstListenerAdd&&this._options.onFirstListenerAdd(),{dispose:()=>{const r=t.indexOf(e);r>=0&&(t.splice(r,1),t.length||n?.onFirstListenerAdd&&n.onLastListenerRemove())}}};event=this.addEventListener},Id;(function(e){function t(s){let o;const i=new Sd({onFirstListenerAdd(){o=s(i.fire)},onLastListenerRemove(){o.dispose()}});return i.event}e.snapshot=t;function n(s,o){return t(i=>s(a=>o(a)&&i(a)))}e.filter=n;function r(s,o){return t(i=>s(a=>i(o(a))))}e.map=r})(Id||(Id={}));var VS=l.createIdentifier$1("helpers.commandEmitter");function GS(e,t,n){e instanceof l.Container||(e=l.getContainer(e)),e.getOrCreateInstance(VS,()=>new Sd).fire({id:t,payload:n})}function WS(e,t,{yieldable:n=!1,details:r,prepare:s}={}){const o=Ce(e),i=new Map,a=new Set,c=o.commands.watch(()=>{o.disposed||Object.entries(t).forEach(([d,{declaration:u,handler:f}])=>{const h=o.info(d)?.owner;h?n&&h!==Ge&&!a.has(d)&&(a.add(d),`${d}${h.name}`,void 0):(a.delete(d),i.set(d,o.register(Ge,{[d]:u},{[d]:f},{},{yieldable:n,details:r,prepare:s})))})});return{dispose:()=>{c.dispose(),i.forEach(d=>d.dispose())}}}var so="document.getSnapshot",YS="document.save",Td=Symbol.for("emailmaker.legacyEmailSnapshot"),oo=Symbol.for("emailmaker.legacyEmailSnapshotError");function KS(e,t){return Object.defineProperty(e,Td,{value:t})}function qS(e){return KS({kind:"email",id:e.id==null?null:String(e.id),content:e.code??"",subject:e.subject??"",preheader:e.preheader??""},e)}function zS(e){return{kind:"block",id:e.id==null?null:String(e.id),content:e.code??"",subject:"",preheader:""}}function XS(e,t){return WS(e,{[so]:{declaration:{title:"Get document snapshot",description:"Returns the open document: kind, id, HTML content, subject and preheader.",agent:{readOnly:!0}},handler:async()=>{try{const n=ye(e),r=J(n?.sessionKey())?await t.getBlockSnapshot():null;return He(r?zS(r):qS(await t.readEmailSnapshot()))}catch(n){return Object.defineProperty(oe("internal",n instanceof Error?n.message:String(n)),oo,{value:n})}}},[YS]:{declaration:{title:"Save document",description:"Saves the open document and finishes when the save is done. A save refused by a rule (a plugin check, empty content, too many tags, edits still on their way, the host cancelled it) answers `refused`, and its message names the reason: tell the user.",agent:!0},handler:(n,r)=>tI(e,r.caller)}})}async function JS(e,t){const n=await Ce(e).run(so,void 0,{caller:"plugin"});if(n.ok===!1){if(oo in n)throw n[oo];return t()}return n.value[Td]}function QS(e){return Ce(e).info(so)?.owner===Ge}var ZS="The host cancelled this save, so nothing was saved. Tell the user; do not repeat the call unless the user asks for it again.";async function eI(e,t,n){const r=await new Promise(a=>{GS(e,t,{source:xp,settle:a})});if(r.ok!==!1)return He();if(r.reason==="unready")return;const s=n==="agent"?r.refusal??(r.reason==="aborted"?ZS:void 0):void 0,o=r.reason==="locked"?"readOnly":r.reason==="aborted"?"aborted":"internal",i=s?oe("refused",s):oe(o,r.message);return r.notified?Object.defineProperty(i,Bp,{value:!0}):i}async function tI(e,t){if(be(ht(e))?.readOnly)return oe("readOnly","The editor is read-only.");const n=ye(e)?.sessionKey();if(n!==void 0){const s=J(n);if(Up(e,s?"block":"email")){const o=await eI(e,s?HS:$S,t);if(o)return o}}const r=e.getInstance(l.INSTANCE_ID);if(n===void 0||!r)return oe("unavailable","There is no open document to save.");try{return await(J(n)?r.saveBlock():r.save()),He()}catch(s){if(s instanceof Oe&&s.reason==="locked")return oe("readOnly",s.message);const o=t==="agent"?_f(s):void 0;return o?oe("refused",o):oe("internal",s instanceof Error?s.message:String(s))}}var nI=class extends l.Disposable{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=Gt(e),this.addDisposable(l.getEvent(e,l.events.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t})),this.addDisposable(XS(e,this)),this.addDisposable(US(e))}openEmail(){const e=ye(this._container);if(e&&J(e.sessionKey())&&!e.hasSuspended())throw new Error("[useblocks] no open email: only a block is shown");return Xc(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=>ge(t,this._container))}async _readProjectBlocks(){const e=await Jc(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>Yt(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>Is(n,this._container))}async getEmailSnapshot(){return J(ye(this._container)?.sessionKey())||!QS(this._container)?this.readEmailSnapshot():JS(this._container,()=>this.readEmailSnapshot())}async readEmailSnapshot(){return Se(this.openEmail(),this._container)}async getBlockSnapshot(){const e=ye(this._container),t=e?.current();return!e||!t||!J(e.sessionKey())?null:(await t.whenReady(),ge(Ln(t),this._container))}setEmailMeta(e){const t=Es(this._container);if(!t)return;const n=t.get().attributes.meta;at(t,{meta:jn({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,s=>s&&jn(s,e))}setBlockMeta(e,t){const n=ye(this._container);if(n?.sessionKey()===un(e)){const s=n.current();s&&at(s,{meta:jn({meta:s.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:s}=this._dataSources.blocks;await s.getIfPresent(e)&&await s.addOrUpdate(e,o=>o&&jn(o,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return SS(this._container)?wS(this._container):void 0}},rI=l.createIdentifier$1("EmailDataController");function sI(e){return e.getOrCreateInstance(rI,()=>{const t=new nI(e);return e.getInstance(l.DISPOSABLE_ID)?.addDisposable(t),t})}function oI(e){const t=sI(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 iI(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 aI(e){let t;const n=Ac(e),r=l.getEvent(e,l.events.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:o})=>{t=o}));const s=()=>t?iI(t):void 0;return{undoRedoService:{undo:()=>s()?.undo(),redo:()=>s()?.redo(),clear:()=>s()?.clear(),getPast:o=>s()?.getPast(o)??[],getFuture:o=>s()?.getFuture(o)??[],canUndo:()=>s()?.canUndo()??!1,canRedo:()=>s()?.canRedo()??!1,createSnapshot:()=>s()?.createSnapshot(),restoreSnapshot:o=>s()?.restoreSnapshot(o)}}}var cI=l.createIdentifier$1("plugin.mountElement");function lI(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 dI(e){return e.getOrCreateInstance(cI,()=>{let t=!1,n;return{get:()=>t?n:lI(e),set(r){t=!0,n=r}}})}function uI(e){const t=dI(e);return{getElement:()=>t.get()}}var fI=[b_,uy,bS,ew,oI,aI,uI,U_];function hI(e,t=fI){const n=Fs(e);jy(e),ES();const r=jw(e),s=Fw(e),o=Bw(e),i={...r.instance,...s.instance,...o.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 s.setOptions(c),await o.setOptions(c)}}}function pI(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 mI=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]}},gI="editor-runtime.react.copies",io=8;function Qt(e){return e&&typeof e=="object"?e:void 0}function Ad(e){const t=Qt(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Qt(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function vI(e){const t=Qt(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Qt(t?.default),s=r&&typeof r.version=="string"?r.version:void 0;return n??s??"unknown"}function _I(e,t,n){return e.package===t&&e.version===n}function EI({ourReact:e,entries:t,packageName:n,version:r}){const s=Ad(e);if(!s||!Array.isArray(t))return[];const o=[],i=new Set;for(const a of t){const c=Qt(a);if(!c||!_I(c,n,r))continue;const d=Ad(c.react);!d||d===s||i.has(d)||(i.add(d),o.push({package:n,version:r,reactVersion:vI(c.react),react:c.react}))}return o}function bI({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,io))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>io&&n.push(` …and ${t.length-io} 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(`
|
|
2167
|
-
`)}var
|
|
2166
|
+
`)}function Ad(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function Yw(e,t,n,r){const s=Xw(e,t,n,r);return s===void 0}function Xw(e,t,n,r){if(mr(t))return"block";const{email:s}=gr(t,!1),o=Pt(s,e),i=o.id;if(i===void 0)return"no-id";if(r!==void 0&&r!==i)return"other-id-shown";const a=Ie(e)?.current();if(!a)return"no-session";const c=a.get(),l=c.attributes;if(c.serverId!==i)return"document-id";if(l.is_inited!==!0)return"not-inited";const u=Ad(so(n??a.getContent()));if(o.html!==void 0&&Ad(so(o.html))!==u)return"html";if(o.subject!==void 0&&o.subject!==l.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==l.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==l.common_styles)return"common_styles"}function Td(e,t){if(mr(t))return;const{email:n}=gr(t,!1),r=Pt(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:so(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function Jw(e){return Array.isArray(e)?e.some(t=>ls(t)):ls(e)}function Qw(e){const t={...e};delete t.wpId,delete t.secretHash,delete t.projectCategories;for(const n of["author","folder","project"])Jw(t[n])&&delete t[n];return t}function Zw(e,t){const n={...e};return delete n.id,{...n,...t}}function eS(e,t){var n=0,r,s;t=t||{};function o(){var i=r,a=arguments.length,c,l;e:for(;i;){if(i.args.length!==arguments.length){i=i.next;continue}for(l=0;l<a;l++)if(i.args[l]!==arguments[l]){i=i.next;continue e}return i!==r&&(i===s&&(s=i.prev),i.prev.next=i.next,i.next&&(i.next.prev=i.prev),i.next=r,i.prev=null,r.prev=i,r=i),i.val}for(c=new Array(a),l=0;l<a;l++)c[l]=arguments[l];return i={args:c,val:e.apply(null,c)},r?(r.prev=i,i.next=r):s=i,n===t.maxSize?(s=s.prev,s.next=null):n++,r=i,i.val}return o.clear=function(){r=null,s=null,n=0},o}var tS=Lt.__commonJSMin((e=>{(function(){"use strict";var t={not_string:/[^s]/,not_bool:/[^t]/,not_type:/[^T]/,not_primitive:/[^v]/,number:/[diefg]/,numeric_arg:/[bcdiefguxX]/,json:/[j]/,not_json:/[^j]/,text:/^[^\x25]+/,modulo:/^\x25{2}/,placeholder:/^\x25(?:([1-9]\d*)\$|\(([^)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-gijostTuvxX])/,key:/^([a-z_][a-z_\d]*)/i,key_access:/^\.([a-z_][a-z_\d]*)/i,index_access:/^\[(\d+)\]/,sign:/^[+-]/};function n(a){return s(i(a),arguments)}function r(a,c){return n.apply(null,[a].concat(c||[]))}function s(a,c){for(var l=1,u=a.length,f,h="",g=0,p,_,v,A,C,P,I;g<u;g++)if(typeof a[g]=="string")h+=a[g];else if(typeof a[g]=="object"){if(_=a[g],_.keys)for(f=c[l],p=0;p<_.keys.length;p++){if(f==null)throw new Error(n('[sprintf] Cannot access property "%s" of undefined value "%s"',_.keys[p],_.keys[p-1]));f=f[_.keys[p]]}else _.param_no?f=c[_.param_no]:f=c[l++];if(t.not_type.test(_.type)&&t.not_primitive.test(_.type)&&f instanceof Function&&(f=f()),t.numeric_arg.test(_.type)&&typeof f!="number"&&isNaN(f))throw new TypeError(n("[sprintf] expecting number but found %T",f));switch(t.number.test(_.type)&&(P=f>=0),_.type){case"b":f=parseInt(f,10).toString(2);break;case"c":f=String.fromCharCode(parseInt(f,10));break;case"d":case"i":f=parseInt(f,10);break;case"j":f=JSON.stringify(f,null,_.width?parseInt(_.width):0);break;case"e":f=_.precision?parseFloat(f).toExponential(_.precision):parseFloat(f).toExponential();break;case"f":f=_.precision?parseFloat(f).toFixed(_.precision):parseFloat(f);break;case"g":f=_.precision?String(Number(f.toPrecision(_.precision))):parseFloat(f);break;case"o":f=(parseInt(f,10)>>>0).toString(8);break;case"s":f=String(f),f=_.precision?f.substring(0,_.precision):f;break;case"t":f=String(!!f),f=_.precision?f.substring(0,_.precision):f;break;case"T":f=Object.prototype.toString.call(f).slice(8,-1).toLowerCase(),f=_.precision?f.substring(0,_.precision):f;break;case"u":f=parseInt(f,10)>>>0;break;case"v":f=f.valueOf(),f=_.precision?f.substring(0,_.precision):f;break;case"x":f=(parseInt(f,10)>>>0).toString(16);break;case"X":f=(parseInt(f,10)>>>0).toString(16).toUpperCase()}t.json.test(_.type)?h+=f:(t.number.test(_.type)&&(!P||_.sign)?(I=P?"+":"-",f=f.toString().replace(t.sign,"")):I="",A=_.pad_char?_.pad_char==="0"?"0":_.pad_char.charAt(1):" ",C=_.width-(I+f).length,v=_.width&&C>0?A.repeat(C):"",h+=_.align?I+f+v:A==="0"?I+v+f:v+I+f)}return h}var o=Object.create(null);function i(a){if(o[a])return o[a];for(var c=a,l,u=[],f=0;c;){if((l=t.text.exec(c))!==null)u.push(l[0]);else if((l=t.modulo.exec(c))!==null)u.push("%");else if((l=t.placeholder.exec(c))!==null){if(l[2]){f|=1;var h=[],g=l[2],p=[];if((p=t.key.exec(g))!==null)for(h.push(p[1]);(g=g.substring(p[0].length))!=="";)if((p=t.key_access.exec(g))!==null)h.push(p[1]);else if((p=t.index_access.exec(g))!==null)h.push(p[1]);else throw new SyntaxError("[sprintf] failed to parse named argument key");else throw new SyntaxError("[sprintf] failed to parse named argument key");l[2]=h}else f|=2;if(f===3)throw new Error("[sprintf] mixing positional and named placeholders is not (yet) supported");u.push({placeholder:l[0],param_no:l[1],keys:l[2],sign:l[3],pad_char:l[4],align:l[5],width:l[6],precision:l[7],type:l[8]})}else throw new SyntaxError("[sprintf] unexpected placeholder");c=c.substring(l[0].length)}return o[a]=u}typeof e<"u"&&(e.sprintf=n,e.vsprintf=r),typeof window<"u"&&(window.sprintf=n,window.vsprintf=r,typeof define=="function"&&define.amd&&define(function(){return{sprintf:n,vsprintf:r}}))})()})),yD=Lt.__toESM(tS()),wD=eS(console.error),Cd={"(":9,"!":8,"*":7,"/":7,"%":7,"+":6,"-":6,"<":5,"<=":5,">":5,">=":5,"==":4,"!=":4,"&&":3,"||":2,"?":1,"?:":1},nS=["(","?"],vr={")":["("],":":["?","?:"]},rS=/<=|>=|==|!=|&&|\|\||\?:|\(|!|\*|\/|%|\+|-|<|>|\?|\)|:/;function sS(e){for(var t=[],n=[],r,s,o,i;r=e.match(rS);){for(s=r[0],o=e.substr(0,r.index).trim(),o&&t.push(o);i=n.pop();){if(vr[s]){if(vr[s][0]===i){s=vr[s][1]||s;break}}else if(nS.indexOf(i)>=0||Cd[i]<Cd[s]){n.push(i);break}t.push(i)}vr[s]||n.push(s),e=e.substr(r.index+s.length)}return e=e.trim(),e&&t.push(e),t.concat(n.reverse())}var oS={"!":function(e){return!e},"*":function(e,t){return e*t},"/":function(e,t){return e/t},"%":function(e,t){return e%t},"+":function(e,t){return e+t},"-":function(e,t){return e-t},"<":function(e,t){return e<t},"<=":function(e,t){return e<=t},">":function(e,t){return e>t},">=":function(e,t){return e>=t},"==":function(e,t){return e===t},"!=":function(e,t){return e!==t},"&&":function(e,t){return e&&t},"||":function(e,t){return e||t},"?:":function(e,t,n){if(e)throw t;return n}};function iS(e,t){for(var n=[],r=0,s,o,i,a,c;r<e.length;r++){if(a=e[r],i=oS[a],i){for(s=i.length,o=Array(s);s--;)o[s]=n.pop();try{c=i.apply(null,o)}catch(l){return l}}else t.hasOwnProperty(a)?c=t[a]:c=+a;n.push(c)}return n[0]}function aS(e){var t=sS(e);return function(n){return iS(t,n)}}function cS(e){var t=aS(e);return function(n){return+t({n})}}var Od={contextDelimiter:"",onMissingKey:null};function lS(e){for(var t=e.split(";"),n=0,r;n<t.length;n++)if(r=t[n].trim(),r.indexOf("plural=")===0)return r.substr(7)}function oo(e,t){var n;this.data=e,this.pluralForms={},this.options={};for(n in Od)this.options[n]=t!==void 0&&n in t?t[n]:Od[n]}oo.prototype.getPluralForm=function(e,t){var n=this.pluralForms[e],r,s,o;return n||(r=this.data[e][""],o=r["Plural-Forms"]||r["plural-forms"]||r.plural_forms,typeof o!="function"&&(s=lS(r["Plural-Forms"]||r["plural-forms"]||r.plural_forms),o=cS(s)),n=this.pluralForms[e]=o),n(t)},oo.prototype.dcnpgettext=function(e,t,n,r,s){var o,i,a;return s===void 0?o=0:o=this.getPluralForm(e,s),i=n,t&&(i=t+this.options.contextDelimiter+n),a=this.data[e][i],a&&a[o]?a[o]:(this.options.onMissingKey&&this.options.onMissingKey(n,e),o===0?n:r)};var Dd={"":{plural_forms(e){return e===1?0:1}}},dS=/^i18n\.(n?gettext|has_translation)(_|$)/,Pd=(e,t,n)=>{const r=new oo({}),s=new Set,o=()=>{s.forEach(I=>I())},i=I=>(s.add(I),()=>s.delete(I)),a=(I="default")=>r.data[I],c=(I,S="default")=>{r.data[S]={...r.data[S],...I},r.data[S][""]={...Dd[""],...r.data[S]?.[""]},delete r.pluralForms[S]},l=(I,S)=>{c(I,S),o()},u=(I,S="default")=>{r.data[S]={...r.data[S],...I,"":{...Dd[""],...r.data[S]?.[""],...I?.[""]}},delete r.pluralForms[S],o()},f=(I,S)=>{r.data={},r.pluralForms={},l(I,S)},h=(I="default",S,w,D,T)=>(r.data[I]||c(void 0,I),r.dcnpgettext(I,S,w,D,T)),g=(I="default")=>I,p=(I,S)=>{let w=h(S,void 0,I);return n?(w=n.applyFilters("i18n.gettext",w,I,S),n.applyFilters("i18n.gettext_"+g(S),w,I,S)):w},_=(I,S,w)=>{let D=h(w,S,I);return n?(D=n.applyFilters("i18n.gettext_with_context",D,I,S,w),n.applyFilters("i18n.gettext_with_context_"+g(w),D,I,S,w)):D},v=(I,S,w,D)=>{let T=h(D,void 0,I,S,w);return n?(T=n.applyFilters("i18n.ngettext",T,I,S,w,D),n.applyFilters("i18n.ngettext_"+g(D),T,I,S,w,D)):T},A=(I,S,w,D,T)=>{let k=h(T,D,I,S,w);return n?(k=n.applyFilters("i18n.ngettext_with_context",k,I,S,w,D,T),n.applyFilters("i18n.ngettext_with_context_"+g(T),k,I,S,w,D,T)):k},C=()=>_("ltr","text direction")==="rtl",P=(I,S,w)=>{const D=S?S+""+I:I;let T=!!r.data?.[w??"default"]?.[D];return n&&(T=n.applyFilters("i18n.has_translation",T,I,S,w),T=n.applyFilters("i18n.has_translation_"+g(w),T,I,S,w)),T};if(e&&l(e,t),n){const I=S=>{dS.test(S)&&o()};n.addAction("hookAdded","core/i18n",I),n.addAction("hookRemoved","core/i18n",I)}return{getLocaleData:a,setLocaleData:l,addLocaleData:u,resetLocaleData:f,subscribe:i,__:p,_x:_,_n:v,_nx:A,isRTL:C,hasTranslation:P}};function Rd(e){return!(typeof e!="string"||e===""||!/^[a-zA-Z][a-zA-Z0-9_.\-\/]*$/.test(e))}function io(e){return!(typeof e!="string"||e===""||/^__/.test(e)||!/^[a-zA-Z][a-zA-Z0-9_.-]*$/.test(e))}function kd(e,t){return function(r,s,o,i=10){const a=e[t];if(!io(r)||!Rd(s)||typeof o!="function"||typeof i!="number")return;const c={callback:o,priority:i,namespace:s};if(a[r]){const l=a[r].handlers;let u;for(u=l.length;u>0&&!(i>=l[u-1].priority);u--);u===l.length?l[u]=c:l.splice(u,0,c),a.__current.forEach(f=>{f.name===r&&f.currentIndex>=u&&f.currentIndex++})}else a[r]={handlers:[c],runs:0};r!=="hookAdded"&&e.doAction("hookAdded",r,s,o,i)}}function Er(e,t,n=!1){return function(s,o){const i=e[t];if(!io(s)||!n&&!Rd(o))return;if(!i[s])return 0;let a=0;if(n)a=i[s].handlers.length,i[s]={runs:i[s].runs,handlers:[]};else{const c=i[s].handlers;for(let l=c.length-1;l>=0;l--)c[l].namespace===o&&(c.splice(l,1),a++,i.__current.forEach(u=>{u.name===s&&u.currentIndex>=l&&u.currentIndex--}))}return s!=="hookRemoved"&&e.doAction("hookRemoved",s,o),a}}function Nd(e,t){return function(r,s){const o=e[t];return typeof s<"u"?r in o&&o[r].handlers.some(i=>i.namespace===s):r in o}}function Ld(e,t,n=!1){return function(s,...o){const i=e[t];i[s]||(i[s]={handlers:[],runs:0}),i[s].runs++;const a=i[s].handlers;if(!a||!a.length)return n?o[0]:void 0;const c={name:s,currentIndex:0};for(i.__current.push(c);c.currentIndex<a.length;){const l=a[c.currentIndex].callback.apply(null,o);n&&(o[0]=l),c.currentIndex++}if(i.__current.pop(),n)return o[0]}}function xd(e,t){return function(){var r;const s=e[t];return(r=s.__current[s.__current.length-1]?.name)!==null&&r!==void 0?r:null}}function Md(e,t){return function(r){const s=e[t];return typeof r>"u"?typeof s.__current[0]<"u":s.__current[0]?r===s.__current[0].name:!1}}function Fd(e,t){return function(r){const s=e[t];if(io(r))return s[r]&&s[r].runs?s[r].runs:0}}var uS=class{constructor(){this.actions=Object.create(null),this.actions.__current=[],this.filters=Object.create(null),this.filters.__current=[],this.addAction=kd(this,"actions"),this.addFilter=kd(this,"filters"),this.removeAction=Er(this,"actions"),this.removeFilter=Er(this,"filters"),this.hasAction=Nd(this,"actions"),this.hasFilter=Nd(this,"filters"),this.removeAllActions=Er(this,"actions",!0),this.removeAllFilters=Er(this,"filters",!0),this.doAction=Ld(this,"actions"),this.applyFilters=Ld(this,"filters",!0),this.currentAction=xd(this,"actions"),this.currentFilter=xd(this,"filters"),this.doingAction=Md(this,"actions"),this.doingFilter=Md(this,"filters"),this.didAction=Fd(this,"actions"),this.didFilter=Fd(this,"filters")}};function fS(){return new uS}var Bd=fS(),{addAction:SD,addFilter:ID,removeAction:AD,removeFilter:TD,hasAction:CD,hasFilter:OD,removeAllActions:DD,removeAllFilters:PD,doAction:RD,applyFilters:kD,currentAction:ND,currentFilter:LD,doingAction:xD,doingFilter:MD,didAction:FD,didFilter:BD,actions:jD,filters:UD}=Bd,de=Pd(void 0,void 0,Bd),$D=de.getLocaleData.bind(de),HD=de.setLocaleData.bind(de),GD=de.resetLocaleData.bind(de),VD=de.subscribe.bind(de),WD=de.__.bind(de),KD=de._x.bind(de),qD=de._n.bind(de),zD=de._nx.bind(de),YD=de.isRTL.bind(de),XD=de.hasTranslation.bind(de);function hS(e,t){if(e.html)return e;const n=e.subject||t;return{...e,subject:n,html:vd(n)}}function pS(e,t){if(e.html||e.subject||!t?.subject)return e;const n={...e};return delete n.subject,n}async function mS(e){const t=e.getInstance(rt);t&&!t.snapshot().ready&&await new Promise(r=>{const s=t.state.watch(({ready:o})=>{o&&(queueMicrotask(()=>s.dispose()),r())})});const n=Pd(t?.snapshot().catalog);return $w(r=>n.__(r))}function st({code:e,project:t,...n},r,s){const o=s??Js(r);return{...n,...e?{html:Be(r).toEditorForm(e)}:{},renderGuid:d.generateUUID(),...o===void 0?{}:{project:o}}}function Ee({html:e,renderGuid:t,...n},r){const{requested:s}=cn(r);return Le({...n,code:Be(r).toOutputForm(e),project:s===void 0?n.project:s,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 jd(e){return Ie(e)?.current()?.get().serverId??void 0}function ao(e,t,n){return n===void 0&&(n=e.post===void 0?jd(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function un(e,t){return Le({...e,link:void 0,comment_status:void 0})}function br({code:e,autosave:t,...n},r,s){return s===void 0&&(s=n.parent===void 0?jd(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||qm(n.slug),parent:s}}function co({html:e,isAutosave:t,...n},r){return Le({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:Le({html:e,ampHtml:e&&""})})}function yr({code:e,autosave:t,...n},r){return{...n,...e?{html:e}:{},isAutosave:t===!0,parent:r??n.parent}}function Ud({html:e,isAutosave:t,...n}){return Le({...n,autosave:t?!0:void 0,code:e,guid:void 0})}var lo=e=>{const t={current:Promise.resolve(),state:e,decorate:(n,r)=>(r&&(n=n.bind(r)),function(...s){const o=t.current.then(()=>n(...s));return t.current=o.then(i=>{t.state=i},i=>{}),o})};return t};function gS(e){return String(e).replace(/"/g,""")}function _S(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 uo(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 $d(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),s=gS(n);return r.test(e)?e.replace(r,`${t}="${s}"`):e.replace(/>$/,` ${t}="${s}">`)}function Hd(e,t){return e.replace(new RegExp(`\\s+${t}\\s*=\\s*["'][^"']*["']`,"gi"),"")}function Gd(e,t){const n=new RegExp(`\\b${t}\\s*=\\s*["']([^"']*)["']`,"i").exec(e);return n?n[1]:void 0}function Vd(e){if(!e?.trim())return{};const t=uo(e);return t?{emBlockId:Gd(t.full,"em-block-id"),emBlockVersion:Gd(t.full,"em-block-version")}:{}}function Wd(e,t,n){if(!e?.trim()||!t)return e;const r=uo(e);if(!r)return e;const s=String(t),o=_S(n??new Date);let{full:i,index:a}=r;const c=i.length;return/\bem-block-id\s*=/.test(i)||(i=$d(i,"em-block-id",s)),i=$d(i,"em-block-version",o),e.slice(0,a)+i+e.slice(a+c)}function vS(e){const t=e?.trim()?uo(e):null;if(!t)return e;const{full:n,index:r}=t,s=Hd(Hd(n,"em-block-id"),"em-block-version");return e.slice(0,r)+s+e.slice(r+n.length)}function ES(e,t){const{emBlockId:n,emBlockVersion:r}=Vd(e);return n&&r?e:Wd(e,t)}var Rt=d.createIdentifier("NotificationService"),bS=d.createIdentifier("emailTemplate.reads");async function yS(e,t){try{const n=qe(e);return await(n.template?n.template(e):n.email(e)).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,SS(e,t,n);return}}var wS=d.createIdentifier("emailTemplate.notifiedFailures");function SS(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(wS,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(Rt).then(()=>{d.getEmitter(e,d.events.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function IS(e,t){const n=e.getOrCreateInstance(bS,()=>new Map),r=n.get(t);if(r!==void 0)return r;const s=yS(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,s),s}var AS=class{http;constructor(e){this.http=e}blocksRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});blocksRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/blocks/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:cd.Json,format:"json",...r});blocksRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/blocks/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});blocksRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/blocks/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"GET",secure:!0,format:"json",...t});emailsRevisionsCreate=({entityId:e,...t},n,r={})=>this.http.request({path:`/app/emails/${e}/revisions`,method:"POST",query:t,body:n,secure:!0,type:cd.Json,format:"json",...r});emailsRevisionsDetail=({entityId:e,revisionId:t},n={})=>this.http.request({path:`/app/emails/${e}/revisions/${t}`,method:"GET",secure:!0,format:"json",...n});emailsRevisionsLatestList=({entityId:e},t={})=>this.http.request({path:`/app/emails/${e}/revisions/latest`,method:"GET",secure:!0,format:"json",...t});initCreate=(e={})=>this.http.request({path:"/app/init",method:"POST",secure:!0,format:"json",...e})},JD=d.createIdentifier("projects.v2IdByWpId"),QD=d.createIdentifier("projects.wpIdByV2Id"),ZD=d.createIdentifier("emails.v2SavedAtOnOpen"),e0=d.createIdentifier("emails.v2OpeningReads"),fo=class extends Error{v2Error;operation;status;data;creation;constructor(e,t){const n=typeof t.data.message=="string"?t.data.message.trim():"";super(n||`${e==="создание"?"create":"update"}: ${t.status} ${t.data.code??""}`.trim()),this.name="EmailWriteFailedError",this.operation=e,this.creation=e==="создание",this.v2Error=t,this.status=t.status,this.data=t.data}};function TS(e,t){if(!t)throw new fo(e,{status:0,data:{code:"no_response"}});if(!t.ok)throw new fo(e,fr(t))}function CS(e){const t=e;return{...e.id!==void 0?{id:e.id}:{},...e.author_id?{author:e.author_id}:{},...t.author_name?{authorName:t.author_name}:{},...e.created_at!==void 0?{date:e.created_at,modified:e.created_at}:{},isAutosave:e.autosave===!0,...t.html!==void 0?{html:t.html}:{},...t.common_styles!==void 0?{common_styles:t.common_styles}:{}}}var OS=/^[A-Za-z0-9_-]{1,128}$/,DS=new Set(["apps.invalid_entity_id","apps.history_locked_by_plan"]),Kd=new Set;function PS(e){return OS.test(e)?!0:(Kd.has(e)||Kd.add(e),!1)}function RS(e){return e&&!e.ok?String(fr(e).data.code??""):""}var qd=()=>({isAutosave:!1});function zd(e,t){return e==="email"?{html:t.html??"",common_styles:t.common_styles??""}:{html:t.html??""}}async function kS(e,t){const n=new AbortController,r=Gt(e.getInstance(d.INIT_PIPELINE_ID)?.contentReadyTimeoutMs);let s;const o=new Promise((i,a)=>{s=setTimeout(()=>{n.abort(),a(new fo("обновление",{status:0,data:{code:"timeout"}}))},r)});try{return await Promise.race([t(n.signal),o])}finally{clearTimeout(s)}}function NS(e,t){return pa(t,e==="block")}async function LS(e,t,n,r,s){if(!PS(n))return qd();const o=bt(e),i=Yt(e),a=NS(t,n);try{const c=await xS(e,t,n,r,s);return c.id&&(o.set(a,c.id),i.delete(a)),c}catch(c){throw Rg(i,a,r.html??""),c}}async function xS(e,t,n,r,s){const o=dd(e,[AS]),i={entityId:n,...s?{autosave:!0}:{}},a=await kS(e,c=>t==="email"?o.emailsRevisionsCreate(i,zd(t,r),{signal:c}):o.blocksRevisionsCreate(i,zd(t,r),{signal:c}));return DS.has(RS(a))?qd():(TS("обновление",a),CS(a.data??{}))}function MS(e,t,n,r){return LS(e,t,n,r,!1)}async function FS(e,t,n){if(t==null||t===""||n===void 0||!gt(e))return Yd;const r=Date.now(),s=ns(String(t));return lc(s,{html:n},r,vs(bt(e),s,Yt(e),n)),await MS(e,"block",String(t),{html:n}),Hn(s,r,bt(e).get(s)??void 0),()=>rs(s,r)}function Yd(){}var ho="EXTERNAL",Xd=Symbol("supersededShow");function BS(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var jS="email_id";function po(e){return Object.entries(e).some(([t,n])=>t!=="id"&&n!==void 0)}var US=class extends d.Disposable{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=lo();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=ln(t),this._eventLock=Ww(t);const n=Z(e,d.events.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(Z(e,d.events.OPEN_BLOCK_REQUEST_ID)(r=>this.openBlock(r))),this.addDisposable(e.addService(Ge,{execute:(r,s)=>{!s?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(jS,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(d.INIT_PIPELINE_ID)??Ns}_throwIfDestroyed(){if(this.isDisposed())throw De()}async getTemplateEmail(e){const t=await IS(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,Qw(n)}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await dn(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,st(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(s=>s.id!==void 0).map(s=>[s.id,br(s,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(s=>s.id!==void 0).map(s=>[s.id,ao(s,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,s){const o=this._dataSources.emails,i=o.cache,a=await dn(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let l=Pt(e,this._container);const u=l.id;let f=u;if(u!==void 0){const h=await o.get(u);l={...h??{},...l,utm_parameters:l.utm_parameters??h?.utm_parameters??{},renderGuid:h?.renderGuid??d.generateUUID(),...c>0?{showToken:c}:{},...s?{showId:s}:{},project:a}}else{f=n??d.generateUUID();const h=await o.get(f);l={...l,utm_parameters:l.utm_parameters??{},renderGuid:h?.renderGuid??d.generateUUID(),...c>0?{showToken:c}:{},...s?{showId:s}:{},project:a},delete l.project}if(t){const h=await this.getTemplateEmail(String(t));h&&(l=Zw(h,l))}return u===void 0&&!l.html&&(l=hS(l,await mS(this._container))),await i.setAll([[f,l]]),l}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Td(this._container,e))return!1;const n=_r(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Td(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:_r(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&Kw({ticket:t,emailId:Id(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,Xd;if(!e)return;const n=this._getInitPipeline();if(d.throwIfAborted(n.signal),mr(e))return this._showBlock(e,n);const r=Q(pe(this._container).sessionKey()),s=qw(e);if(!r&&!s&&Yw(this._container,e,_r(this._container),this._prevCommand?.id)||!r&&!s&&this._isRepeatOfLastShow(e))return;const o=gr(e);o.email.id,this._prevCommand?.id;let i,a="",c=0,l=!1,u,f=Promise.resolve(),h,g=!1;try{this._eventLock.suspendChange();const{email:p,blocks:_,autosaves:v,comments:A,templateId:C,reload:P}=o;i=p.id;const I=Pt(p,this._container),S=I.id,w=S??d.generateUUID(),D=await Ke("getProject",dn(this._container));d.throwIfAborted(n.signal),a=d.generateUUID();const T={isNew:S===void 0,id:String(w),project:D},k=P===!0&&S!==void 0;k&&(await this._dataSources.emails.remove(String(S),{silent:!0}),String(S)),c=++this._showToken,String(w);const x=[];x.push(this.setBlocks(_)),p.id!==void 0&&(x.push(this.setComments(A)),x.push(this.setEmailRevisions(v,String(p.id)))),x.push(this.setEmail(p,ls(C)?C:Number(C),S===void 0?String(w):void 0,c,a)),await Ke("setEmail+blocks+revisions",Promise.all(x),{emailId:S??String(w),showId:a,targetShowToken:c}),d.throwIfAborted(n.signal);const R=await this._dataSources.emails.get(String(w)),M=pe(this._container),F={id:a,token:c};if(r){ir(this._container);const E=M.suspendedDocument()?.get().serverId;!k&&S!==void 0&&E!=null&&String(E)===String(S)&&M.resumeSuspended()}S===void 0?h=M.startNewDraft(R??I,{patch:pS(I,R),show:F}):k?h=M.reload(S,{email:R??I,patch:I,show:F}):M.sessionKey()===_t(S)?h=M.show(I,F):h=M.open(S,{email:R??I,patch:I,show:F}),M.beginShowFill(a);const U=!!this._prevCommand&&ve(this._prevCommand,T);T.id,!this._prevCommand||ve(this._prevCommand,T),this._prevCommand?.id,this._rememberShow(T),f=n.requestShow({showId:a,navId:String(w),emailId:S,isNew:S===void 0}),g=!0;const y=()=>M.endShowFill(a);Promise.allSettled([f,h.whenReady()]).then(y),String(w),l=!0}catch(p){u=p,g&&a&&n.failShow(a,p),a&&Ie(this._container)?.endShowFill(a),d.isAbortError(p)||(aa(p),void 0)}finally{this._eventLock.resumeChange()}if(!l)throw u instanceof Error?u:new Error(`[useblocks] show() setup failed: ${String(u??"unknown error")}`);return Ke("show-init-deferred",Promise.all([f,h?.whenReady().catch(p=>{if(p instanceof We){const _=_s(p);throw _?new Error(`[useblocks] show(): email open failed (${_})`,{cause:p}):p}})??Promise.resolve()]).then(()=>{}),{showId:a,emailId:i??null}).then(()=>{this._rememberShownContent(e)})}async _showBlock(e,t){const{block:n,byId:r,blocks:s,revisions:o,reload:i}=Vw(e),a=d.generateUUID();let c=!1;try{await this.setBlocks(s),d.throwIfAborted(t.signal),i&&(await this._dataSources.blocks.remove(String(n.id),{silent:!0}),this._dataSources.blocks.byForeignKey("project").clear(),String(n.id));const l=n.id!==void 0&&n.id!==""?String(n.id):void 0,u=pe(this._container);if(!i&&l!==void 0&&u.sessionKey()===Mn(l)){const C=po(n)?await this._storeShownBlock(n):void 0,P={id:a,token:++this._showToken},I=u.show(C,P),S=t.requestShow({showId:a,navId:l,emailId:void 0,isNew:!1});c=!0,await Ke("show-block-init",Promise.all([S,I?.whenReady().catch(()=>{})]),{showId:a});return}const f=r||i?await Sd(this._container,String(n.id)):void 0,h=f&&(i||po(n))?await this._storeShownBlock({...Ee(f,this._container),...n}):r||i?f:await this._storeShownBlock(n);if(d.throwIfAborted(t.signal),!h)throw new Error(`[useblocks] show(): block ${String(n.id)} not found`);o!==void 0&&h.id!==void 0&&await this._dataSources.blocksRevision.cache.setAll(o.filter(C=>C.id!==void 0).map(C=>[C.id,yr(C,String(h.id))])),this._prevCommand=void 0,this._lastShow=void 0;const g=h.id!==void 0?String(h.id):d.generateUUID(),p={id:a,token:++this._showToken};ir(this._container);const _=i?u.reloadBlock(g,h,p):u.openBlock(g,h,p);h.id;const v=t.requestShow({showId:a,navId:g,emailId:void 0,isNew:h.id===void 0});c=!0;const A=_.whenReady().catch(C=>{if(C instanceof We)throw C});await Ke("show-block-init",Promise.all([v,A]),{showId:a})}catch(l){throw c&&t.failShow(a,l),l}}async _storeShownBlock(e){const t=st(e,this._container,await dn(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();d.throwIfAborted(e.signal);const t=pe(this._container);if(Q(t.sessionKey())&&!t.hasSuspended())throw new Error("[useblocks] save(): no open email — a block is open, use saveBlock()");const n=await t.saveEmail("publish",{source:ho,fallbackTitle:zc(this._container)});if(d.throwIfAborted(e.signal),!n)throw BS(t.emailSaveState().error);return Te(yd(this._container,this._currentEmail),this._container)}async _saveBlock(){this._throwIfDestroyed();const e=pe(this._container),t=e.current();if(!t||!Q(e.sessionKey()))throw new Error("[useblocks] saveBlock(): no open block");return Im(t,async()=>{await t.whenReady();const n=or(t),r=t.get().version,s=t.get().serverId,o=typeof n.global_block=="boolean"?n.global_block:s!=null&&Vd(n.html??"").emBlockId===String(s),i=s!=null&&o?Wd(n.html,String(s),new Date):n.html,a={title:n.title,project:n.project,type:n.type??"Other",description:n.description,html:i,blocktags:n.blocktags,...n.meta?{meta:n.meta}:{}},c=this._dataSources.blocks,l=await FS(this._container,t.get().serverId,a.html),u=t.get().serverId==null?c.create(a,{source:ho}):c.update(String(t.get().serverId),a,{source:ho}),f=await zw(this._container,u,h=>{h&&l(),h&&pe(this._container).current()===t&&t.get().serverId==null&&h.id!==void 0&&t.markSaved(r,String(h.id))});if(!f)throw new Error("[useblocks] save(): block was not saved");return l(),t.markSaved(r,f.id!==void 0?String(f.id):void 0),Ee(f,this._container)})}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=Id(e);const n=this._queuedShow(e,t).then(r=>r===Xd?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(),d.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=pe(this._container);if(n!==void 0&&r.sessionKey()===Mn(n))return;const s=t.code===void 0&&n!==void 0?await Sd(this._container,n):void 0,o=s&&po(t)?await this._storeShownBlock({...Ee(s,this._container),...t}):t.code===void 0&&n!==void 0?s:await this._storeShownBlock(t);if(!o)throw new Error(`[useblocks] openBlock(): block ${String(n)} not found`);ir(this._container);const i=r.openBlockOver(o.id!==void 0?String(o.id):d.generateUUID(),o);o.id,r.hasSuspended(),me(this._container,d.events.ON_BLOCK_OPEN_ID).fire({block:o}),await i.whenReady().catch(a=>{if(a instanceof We)throw r.current()===i&&(me(this._container,d.events.ON_BLOCK_CLOSE_ID).fire({block:o,hasUnsavedChanges:!1}),r.resumeSuspended()),a})}async _closeBlock(){this._throwIfDestroyed(),qE(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 $S(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 HS(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),s=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:s,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:$S(e)}}function mo(e,t){return t?HS(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Jd=["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"],GS=[...Jd,"html","id","project","password"],t0=new Set(["html",...Jd,"global_block","project"]);function VS(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(GS),r={};for(const s of Object.keys(e))n.has(s)||(r[s]=e[s]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function WS(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...VS(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 go=new WeakMap;function KS(e){let t=go.get(e);return t||(t={byId:new Map,fallback:[]},go.set(e,t)),t}function qS(e){go.delete(e)}function zS(e,t){const{byId:n,fallback:r}=KS(t);if(e.blockId){const s=n.get(e.blockId);if(s){n.delete(e.blockId);const o=r.indexOf(s);return o>=0&&r.splice(o,1),s}return}for(let s=r.length-1;s>=0;s--){const o=r[s],i=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,a=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(i&&a)return r.splice(s,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function YS(e,t){const{blocks:n}=ln(e);return await n.cache.getIfPresent(t)??void 0}async function XS(e,t){if(!t.blockId)return;const n=await YS(e,t.blockId);if(n)return WS(n,t)}async function JS(e,t){const n=zS(e,t);if(n)return mo(e,n);const r=await XS(t,e);return r?mo(e,r):mo(e,void 0)}var QS="application_block_inserted",ZS=-1e3,Qd=new WeakSet;function eI(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 tI(e){if(!e||Qd.has(e))return;Qd.add(e);const t=new d.Disposable,n=ce(e);return t.addDisposable(n.addListenerAsyncPipe(QS,async(r,s)=>{const o=eI(r)?await JS(r,e):r;return s?s(o):o},ZS)),t.addDisposable({dispose:()=>{qS(e)}}),t}var nI=er("plugin.readBlockAutosave"),n0=d.createIdentifier("blockDocuments.provided"),Zd=d.createIdentifier("plugin.earlyWindow");function rI(e){return e.getOrCreateInstance(Zd,()=>({depth:0}))}function sI(e){const t=rI(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function eu(e){return(e?.getInstance(Zd)?.depth??0)>0}function tu(e,t){let n,r=!1;return e(s=>{n=s,r=!0}),(s,o,i)=>{const a=e(s,o,i);if(r&&eu(t)){const c=n;queueMicrotask(()=>{s.call(i,c)})}return a}}var _o=100,oI=class extends d.Disposable{_container;_events;constructor(e){super(),this._container=e;const t=tI(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:s,blocksRevision:o}=ln(e),i=Z(e,d.events.ON_SHARE_ID),a=Z(e,d.events.ON_SHOW_PREVIEW_ID),c=Z(e,d.events.ON_EMAIL_CLONE_ID),l=Z(e,d.events.ON_BLOCK_OPEN_ID),u=Z(e,d.events.ON_BLOCK_CLOSE_ID),f=Z(e,d.events.ON_BLOCK_CLONE_ID),h=Z(e,d.events.ON_BLOCK_INIT_ID),g=Z(e,d.events.ON_BLOCK_CHANGED_ID),p=Z(e,d.events.ON_CODE_VALIDATE_ID),_=Z(e,d.events.ON_IMPORT_VALIDATE_ID),v=Z(e,d.events.ON_SUBJECT_CHANGED_ID),A=Z(e,d.events.ON_EMAIL_CHANGED_ID),C=Z(e,d.events.ON_PREHEADER_CHANGED_ID),P=Z(e,d.events.ON_SAVEBUTTON_CLICK_ID),I=Z(e,d.events.ON_BLOCK_SAVEBUTTON_CLICK_ID),S=Z(e,d.events.ON_NEXTBUTTON_CLICK_ID),w=Z(e,d.events.ON_SEND_LIVEPREVIEW_ID),D=Z(e,d.events.ON_SEND_TESTEMAIL_ID),T=Z(e,Bw),k=Z(e,d.events.ON_CONTENT_CHANGED_ID),x=Z(e,Fw),R=Z(e,d.events.ON_PREVIOUSBUTTON_CLICK_ID),M=Z(e,d.events.ON_SEND_EMAIL_MODAL_ID),F=d.filter(Z(e,d.events.ON_EMAIL_INIT_ID),y=>!y.reset),U=Z(e,d.events.ON_ANALYTICS_EVENT);return{handlePreheaderChanged:H(C),handleSubjectChanged:H(v),handleValidate:H(p),handleImportValidate:H(_),handleReadEmail:H(n.handlerRead,y=>y,y=>y&&Pt(y,e)),handleSaveEmail:H(n.onSave,function({prev:y,patch:E,value:L,source:B}){const W=y?Te(y,e):void 0;return{prev:W,patch:on(W,Te(E,e)),value:Te(L,e),source:B}},y=>y?Pt(y,e):void 0),handleRemoveEmail:H(n.onRemove,({value:y,source:E})=>({value:Te(y,e),source:E}),()=>{}),handleReadCommonBlocks:H(T,y=>y.project,y=>y?.map(E=>st(E,e))),handleReadTemplateBlocks:H(x,y=>y,y=>y?.map(E=>st(E,e))),handleReadBlocks:H(t.byForeignKey("project").handleRead,y=>cn(e).requested||String(y),y=>y?.map(E=>st(E,e))),handleReadBlock:H(t.handlerRead,y=>y,y=>y?st(y,e):void 0),handleOpenBlock:H(l,({block:y})=>({block:Ee(y,e)})),handleCloseBlock:H(u,({block:y,hasUnsavedChanges:E})=>({block:Ee(y,e),hasUnsavedChanges:E})),handleCloneBlock:H(f,y=>Ee({...y,html:vS(y.html)},e)),handleSaveBlock:H(t.onSave,function({prev:y,patch:E,value:L,source:B}){const W=L.global_block===!0&&L.id&&typeof L.html=="string"?{...L,html:ES(L.html,String(L.id))}:L,te=y?Ee(y,e):void 0;return{prev:te,patch:on(te,Ee(E,e)),value:Ee(W,e),source:B}},y=>y?st(y,e):void 0),handleRemoveBlock:H(t.onRemove,({value:y,source:E})=>({value:Ee(y,e),source:E}),()=>{}),handleReadComments:H(r.byForeignKey("post").handleRead,y=>y,y=>y?.map(E=>ao(E,e))),handleSaveComment:H(r.onSave,function({prev:y,patch:E,value:L,source:B}){const W=y?un(y,e):void 0;return{prev:W,patch:on(W,un(E,e)),value:un(L,e),source:B}},y=>y?ao(y,e):void 0),handleRemoveComment:H(r.onRemove,({value:y,source:E})=>({value:un(y,e),source:E}),()=>{}),handleReadEmailRevisions:H(s.byForeignKey("parent").handleRead,y=>y,y=>y?.map(E=>br(E,e))),handleReadEmailAutosave:H(Z(e,td),y=>y,y=>y?br(y,e):null),handleEmailAutosave:H(s.onSave,function({prev:y,patch:E,value:L,source:B}){return{value:co(L,e),source:B}},y=>y?br(y,e):void 0),handleRemoveEmailAutoSave:H(s.onRemove,({value:y,source:E})=>({value:co(y,e),source:E}),()=>{}),handleReadBlockRevisions:H(o.byForeignKey("parent").handleRead,y=>y,y=>y?.map(E=>yr(E))),handleReadBlockAutosave:H(Z(e,nI),y=>y,y=>y?yr(y):null),handleBlockAutosave:H(o.onSave,({value:y,source:E})=>({value:Ud(y),source:E}),y=>y?yr(y):void 0),handleRemoveBlockAutoSave:H(o.onRemove,({value:y,source:E})=>({value:Ud(y),source:E}),()=>{}),handleBlockInit:H(h,y=>Ee(y,e)),handleBlockChanged:H(d.debounce(g,_o),y=>Ee(y,e)),handleEmailChanged:H(d.debounce(A,_o),y=>Te(y,e)),handleEmailInit:tu(H(F,y=>Te(y,e)),e),handlePreviousButtonClick:H(R,y=>Te(y,e)),handleNextButtonClick:H(S,y=>Te(y,e)),handleSaveButtonClick:H(P,y=>Te(y,e)),handleSaveBlockButtonClick:H(I,y=>Ee(y,e)),handleHtmlChanged:H(d.debounce(k,_o)),handleTestEmailSend:H(D,({html:y,...E})=>({...E,code:y,compiled:{html:y,ampHtml:""}})),handleTestEmailModal:H(M,y=>Te(y,e)),handleCloneEmail:H(c,y=>Te(y,e)),handleShareEmail:H(i),handlePreviewEmail:H(a),handleLivePreviewEmail:H(w),handleAnalyticsEvent:H(U)}}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 Dt(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},iI=d.createIdentifier("DataController"),aI=d.createIdentifier("DataEvents");function nu(e){return e.getOrCreateInstance(iI,()=>{const t=new US(e);return e.getInstance(d.DISPOSABLE_ID)?.addDisposable(t),t})}function ru(e){return e.getOrCreateInstance(aI,()=>new oI(e))}var cI=d.createIdentifier("plugin.pluginStart");function su(e){return e.getOrCreateInstance(cI,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>t()),{done:n,finish:t}})}function lI(e){return su(e).done}function dI(e){const t=su(e);return t.run===void 0&&(t.run=(e.getInstance(d.PLUGIN_COLLECTION_ID)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var uI=d.createIdentifier("plugin.startupShow");function fI(e){const t=nu(e),n=ru(e),r=e.getInstance(d.OPTIONS_SOURCE_ID),s=e.getInstance(d.DISPOSABLE_ID),o={current:Promise.resolve()};e.inject(uI,o);let i=!1;const a=r?.watch(l=>{l&&n.setOptions(l),i=(l?.plugins?.length??0)>0,o.current=o.current.catch(()=>{})}),c=r?.select(l=>l?.content).watch(l=>{if(l===void 0)return;const u=()=>(oe(he.showStart),t.show(l).finally(()=>oe(he.showEnd))),f=i?lI(e).then(u):u();f.catch(()=>{}),o.current=f});a&&s?.addDisposable(a),c&&s?.addDisposable(c)}function hI(e){const t=nu(e);return{...ru(e).get(),show(n){return oe(he.showStart),t.show(n).finally(()=>oe(he.showEnd))},openBlock(n){return t.openBlock(n)},closeBlock(){return t.closeBlock()},showBlock(n,r){return oe(he.showStart),t.showBlock(n,r).finally(()=>oe(he.showEnd))},save(){return t.save()},saveBlock(){return t.saveBlock()}}}function ou(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function wr(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",s=!1;for(let o=t;o<e.length;o++){const i=e[o];if(s){s=!1;continue}if(i==="\\"){s=!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 pI(e){return(t,n,r)=>wr(t)?e(t,n,r):!1}function mI(e){return t=>wr(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function gI(e){return(t,n,r)=>wr(t)?ou(t)?e(t,n,r):t:!1}function _I(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return wr(n)?ou(n)?e(t):t:!1}}function vI(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function vo(e,t){const n=e.length;for(let r=0;r<n;r++){const s=e.charCodeAt(r);if(s===0||t==='"'&&s===34||t==="'"&&s===39||t===""&&(s===32||s===9||s===10||s===13||s===12||s===34||s===39||s===60||s===62||s===61||s===96))return!1}return!0}function EI(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let s="";for(let o=0;o<e;o++){const i=r[o]%62;s+=t.charAt(i)}return s}var bI=8,yI=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=EI(bI),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},Sr=new yI;function iu(e,t){return t!==void 0&&!vo(e,t)?`%|{${Sr.getOrCreateByKey(e)}}|%`:e}function wI(e){const t=Sr.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function le(e,t,n){return t!==void 0?vo(e,t)?e:`%|{${Sr.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function SI(e){return e.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function ae(e){return e.startsWith("<!--")&&e.endsWith("-->")?SI(e.slice(4,-3)):e}function II(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 s=e.match(/\[%\s*([^%]*?)\s*%\]/);s&&(r=s[1]);const o=r.trim();return t.test(o)||n.test(o)}function AI(e,t,n){return t!==void 0?vo(e,t)?e:`%|{${Sr.getOrCreateByKey(e)}}|%`:n||vI(e)||II(e)?`<!--${e}-->`:e}var ot=pI(le),it=mI(ae),TI=gI(le),CI=_I(ae),au=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",wI),e.escape("@{","}",le,!0).unescape("<!--@{","}-->",ae,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",iu,!0),e.escape("{{","}}",iu,!0),e.createSyntax("brace-percent").escape("{%","%}",le).unescape("<!--{%","%}-->",ae),e.createSyntax("brace-hash").escape("{#","#}",le).unescape("<!--{#","#}-->",ae),e.createSyntax("proscript").escape("[%","%]",AI,!0).unescape("<!--[%","%]-->",ae,!0),e.createSyntax("getresponse").escape("[[IF","]]",le).escape("[[if","]]",le).escape("[[ELSE]]","",le).escape("[[else]]","",le).escape("[[ENDIF]]","",le).escape("[[endif]]","",le).unescape("<!--[[IF","]]-->",ae).unescape("<!--[[if","]]-->",ae).unescape("<!--[[ELSE]]","-->",ae).unescape("<!--[[else]]","-->",ae).unescape("<!--[[ENDIF]]","-->",ae).unescape("<!--[[endif]]","-->",ae),e.createSyntax("expert-sender").escape("<if",">",le).escape("</if",">",le).escape("<else",">",le).escape("</else",">",le).escape("<var ",">",le,!0).unescape("<!--<if ",">-->",ae).unescape("<!--</if",">-->",ae).unescape("<!--<else ",">-->",ae).unescape("<!--</else",">-->",ae).unescape("<!--<var",">-->",ae,!0),e.createSyntax("velocity").escape("#if",")",ot).escape("#elseif",")",ot).escape("#else","",le).escape("#foreach",")",ot).escape("#macro",")",ot).escape("#set",")",TI,!0).escape("#parse",")",ot).escape("#include",")",ot).escape("#evaluate",")",ot).escape("#end","",le).escape("#break","",le).escape("#stop","",le).unescape("<!--#macro","-->",it).unescape("<!--#if","-->",it).unescape("<!--#elseif","-->",it).unescape("<!--#else","-->",ae).unescape("<!--#foreach","-->",it).unescape("<!--#parse","-->",it).unescape("<!--#include","-->",it).unescape("<!--#evaluate","-->",it).unescape("<!--#end","-->",ae).unescape("<!--#break","-->",ae).unescape("<!--#stop","-->",ae).unescape("<!--#set","-->",CI,!0),e.createSyntax("mailchimp").escape("*|","|*",le).unescape("<!--*|","|*-->",ae)},Eo="bare",OI=new Map;function DI(e){return e?OI.get(e)??Eo:Eo}var cu=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function lu(e){return cu.includes(e)}function fn(e){return e==="bare"||e==="html-comment"}function bo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function PI(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!fn(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[l,u]of[["output",r.output],["editor",r.editor]])if(u!==void 0&&!fn(u))return t(`templateDirectives.${l}: unknown form "${String(u)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!bo(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[l,u]of Object.entries(r.syntaxes))if(!(!lu(l)||u===void 0||fn(u))){if(!bo(u))return t(`templateDirectives.syntaxes.${l}: expected a form or an object, configuration ignored.`),n;for(const f of["output","editor"]){const h=u[f];if(h!==void 0&&!fn(h))return t(`templateDirectives.syntaxes.${l}.${f}: unknown form "${String(h)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const s=r.output??Eo;let o=r.editor;s==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),o=void 0);const i=[];if(r.syntaxes)for(const l of Object.keys(r.syntaxes)){if(!lu(l)){t(`templateDirectives.syntaxes: unknown syntax id "${l}", entry ignored.`);continue}i.push(l)}else i.push(...cu);const a={},c={};for(const l of i){const u=r.syntaxes?.[l],f=bo(u)?u:void 0,h=(fn(u)?u:f?.output)??s;let g=f?.editor??o??h;h==="bare"&&g==="html-comment"&&(t(`templateDirectives.syntaxes.${l}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),g="bare"),a[l]=h,c[l]=g}return{output:a,editor:c}}function du(e,t,n,r){for(let s=t;s<n;s++){const o=e[s];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?o===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(o)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):o==="<"?r.insideTag=!0:o===">"?r.insideTag=!1:r.insideTag&&(o==='"'||o==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=o,r.unquotedAttr=!1):r.insideTag&&/\S/.test(o)&&r.attributeQuoteChar===void 0&&e[s-1]==="="&&!['"',"'","`"].includes(o)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function hn(e,t){return e.start<t.end&&t.start<e.end}function uu(e,t,n,r,s=[]){if(n&&(t=t.filter(u=>u.isVariable)),!t.length)return[];const o=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=s.slice().sort((u,f)=>u.start-f.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let l=0;for(const{range:u,mapFn:f,overrideBuiltins:h,syntax:g,isVariable:p}of o){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):du(e,l,u.start,c),l=u.end,a.some(C=>hn(C,u)))continue;const _=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,v=e.substring(u.start,u.end),A=f(v,_,c.insideTag);A!==!1&&A!==v&&(i.push({range:u,text:A,overrideBuiltins:h,syntax:g,isVariable:p}),a.push(u))}return i.sort((u,f)=>u.range.start-f.range.start||u.range.end-f.range.end)}function RI(e,t){const n=t.reduce((a,{mapFn:c,start:l,end:u,syntax:f,isVariable:h})=>(a[l]||(a[l]=[]),a[l].push({value:u,mapFn:c,syntax:f,isVariable:h}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),s=new RegExp(r,"g"),o=[];let i;for(;(i=s.exec(e))!==null;){const a=i[0];o.push({start:i.index,startToken:a,endTokens:n[a]})}return o}function yo(e,t,n,r,s=!1){const o=[];if(n&&(t=t.filter(l=>l.isVariable)),!t.length)return o;const i=RI(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let l=0;l<i.length;l++){const{start:u,startToken:f,endTokens:h}=i[l];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):du(e,c,u,a),c=u;const g=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let p=!1;for(const{mapFn:_,value:v,syntax:A,isVariable:C}of h){let P=u+f.length,I=e.indexOf(v,P);for(;I!==-1;){let S=I,w=u+f.length,D=0;for(;S!==-1;){const M=e.indexOf(f,w);if(M!==-1&&M<S)D++,w=M+f.length,S=e.indexOf(v,w);else if(D>0)D--,w=S+v.length,S=e.indexOf(v,w);else break}if(S<0)break;const T=S+v.length,k=e.substring(u,T),x=_(k,g,a.insideTag);if(x===!1){P=I+Math.max(v.length,1),I=e.indexOf(v,P);continue}(s||x!==k)&&o.push({range:{start:u,end:T},text:s?k:x,syntax:A,isVariable:C});const R=i.findIndex(({start:M})=>M>=T);R>l?l=R-1:l=i.length,p=!0;break}if(p)break}}return o}function Ir(e,t){if(!t.length)return e;const n=t.slice().sort((s,o)=>o.range.start-s.range.start);let r=e;for(const{text:s,range:o}of n)r=r.slice(0,o.start)+s+r.slice(o.end);return r}var kI=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=au){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,s,o,i){return t.push({start:r,end:s,mapFn:o,isVariable:i,syntax:this.syntax||r}),this},unescape(r,s,o,i){return n.push({start:r,end:s,mapFn:o,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 s=!1;const o={dispose:()=>{s||(s=!0,this._escapeMatchers=this._escapeMatchers.filter(i=>i!==n),this._unescapeMatchers=this._unescapeMatchers.filter(i=>i!==r))}};return this.addDisposable(o),o}_collectMappings(e,t,n){const r=yo(e,this._escapes,t,n),s=uu(e,this._escapeMatchers,t,n),o=s.filter(c=>c.overrideBuiltins).map(c=>c.range),i=r.filter(c=>!o.some(l=>hn(l,c.range))),a=s.filter(c=>c.overrideBuiltins||!i.some(l=>hn(c.range,l.range)));return[...i,...a].sort((c,l)=>c.range.start-l.range.start||c.range.end-l.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=yo(e,this._unescapes,t),r=uu(e,this._unescapeMatchers,t,!1),s=r.filter(a=>a.overrideBuiltins).map(a=>a.range),o=n.filter(a=>!s.some(c=>hn(c,a.range))),i=r.filter(a=>a.overrideBuiltins||!o.some(c=>hn(a.range,c.range)));return[...o,...i].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?s=>s!==void 0&&n.has(s):s=>DI(s)==="html-comment";return this._collectRevertMappings(e,t).filter(s=>s.isVariable||!r(s.syntax))}getDetectedMappings(e,t,n){return yo(e,this._escapes,t,n,!0)}getEscapedText(e,t){return Ir(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return Ir(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=o=>o===void 0?void 0:t[o],r=Object.values(t);let s=e;return r.includes("bare")&&(s=Ir(s,this._collectRevertMappings(s).filter(o=>n(o.syntax)==="bare"))),r.includes("html-comment")&&(s=Ir(s,this._collectMappings(s).filter(o=>!o.isVariable&&n(o.syntax)==="html-comment"&&o.text.startsWith("<!--")&&o.text.endsWith("-->")))),s}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()}},fu="em___script",pn=`<${fu}`,wo=`</${fu}>`;function hu(e){return e.replace("<script",pn).replace("<\/script>",wo)}var pu=new kI(e=>{e.escape("<script","<\/script>",t=>hu(t)).unescape(pn,wo,t=>t.replace(pn,"<script").replace(wo,"<\/script>")),e.escape("<script","/>",t=>hu(t)).unescape(pn,"/>",t=>t.replace(pn,"<script")),au(e)});function NI(e){const t=PI(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return Ea();const n=new Set(Object.keys(t.output).filter(s=>t.output[s]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:s=>pu.normalizeToPolicy(s,t.editor),toOutputForm:s=>pu.normalizeToPolicy(s,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:va(r)}}function LI(e){let t;e.injectFactory(Ur,()=>{const n=e.getInstance(d.CONFIG_SOURCE_ID)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:NI(n)}),t.policy})}var xI=[{name:"rest.client",setup:Nw},{name:"auth.oauth",setup:bp},{name:"auth.apply",awaits:{signals:[Pn]},reaches:[Yr],setup:yp},{name:"rest.identityHeaders",setup:ww},{name:"rest.localeHeader",setup:Ow},{name:"lifetime.destroyable",provides:[Ys],setup:wy},{name:"host.load",setup:Vy},{name:"appInit",provides:[d.APP_ID,qr],setup:hp},{name:"config",provides:[d.CONFIG_SOURCE_ID],setup:by},{name:"templateDirectives",provides:[Ur],setup:LI},{name:"email.documents",setup:$y},{name:"show.initPipeline",provides:[d.INIT_PIPELINE_ID],setup:Lw},{name:"show",setup:fI},{name:"locale.service",provides:[rt],setup:vw},{name:"locale.fromConfig",awaits:{services:[d.CONFIG_SOURCE_ID,rt]},setup:Ew},{name:"canvas.early",setup:hb},{name:"canvas.previewSettings",setup:Pb},{name:"canvas.sandboxExtensions",setup:kb},{name:"canvas.sandboxScriptRelay",setup:xb},{name:"canvas.headerSync",provides:[$s],setup:gb},{name:"canvas.headersAfterRecovery",setup:_b},{name:"canvas.ampSync",setup:lv},{name:"canvas.moduleBridge",setup:Uv},{name:"canvas.port",setup:Ev},{name:"canvas.images",setup:_v},{name:"canvas.edits",setup:ub},{name:"canvas.surfaceFollowsSession",setup:YE},{name:"canvas.blockContent",setup:zE},{name:"canvas.sandboxFill",provides:[js],setup:Zb},{name:"canvas.reactions",setup:fb}],mu;function So(e){const t=e.getInstance(d.OPTIONS_SOURCE_ID);if(t)return t;e.getInstance(d.DISPOSABLE_ID)||e.inject(d.DISPOSABLE_ID,new d.Disposable);const n=se();e.inject(d.OPTIONS_SOURCE_ID,n),mu??=zr(xI);for(const r of mu)r.setup(e);return n}function MI(e){}var FI=[{name:"save.previewFollow",setup:MI}],gu=d.createIdentifier("plugin.lateUnitsInstalled");function BI(e){if(!e.getInstance(gu)){e.inject(gu,!0);for(const t of zr(FI))t.setup(e)}}var Io,_u="core";function jI(){const e=__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([_u],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function UI(e){const t=__useblocks__?.require?.warm;return typeof t!="function"?mn().then(()=>{}):t([_u],e)}function mn(){return Io===void 0&&(Io=jI().then(e=>(xt()&&e.installDiagnostics().catch(t=>{}),e))),Io}var Ao=null,To=null;async function $I(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Co(){return Ao||(Ao=mn().then(()=>{})),Ao}function vu(e){return To||(To=$I(e)),To}function HI(){return vu(typeof __useblocks__<"u"?__useblocks__:void 0)}function GI(){const e=typeof __useblocks__<"u"?__useblocks__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function VI(e){return Promise.all([Co(),vu(e)]).then(()=>{})}function WI(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Eu(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>UI(t?{priority:t}:void 0)).then(()=>(Rs(t?{priority:t}:void 0),n?Co():void 0)).catch(()=>{})}function KI(e){const t=WI(e);if(t==="eager")Eu(e);else if(t==="idle"){const n=()=>Eu(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var bu="PluginRegistry";function qI(e=d.resolveContainer()){return e.getOrCreateInstance(bu,()=>new Ff)}var Ar=new Bf(()=>qI());function zI(e){const t=ke(e),n=Yn(e);return{dispose:()=>{we("ui",()=>n.disposeAll()),we("commands",()=>t.disposeAll())}}}function YI(e,t){const n=Je(e);return t.onLifecycle(r=>n.handle(r))}var XI=["Commands","Ui","Agent","Document"],yu=new Set(["Agent","Document"]),wu=new Map;function JI(e,t){for(let n=e;typeof n=="function";n=Object.getPrototypeOf(n))if(Ac(n,t))return!0;return!1}function QI(e,t,n){wu.get(e)!==t&&wu.set(e,t)}function ZI(e,t){if(JI(t,e))return;const n=typeof t=="function"?t.name||"anonymous":typeof t;if(yu.has(e)){QI(e,t,n);return}}function eA(e){const t=XI.map(n=>e.on(n,r=>ZI(n,r)));return{dispose:()=>t.forEach(n=>n.dispose())}}var Su=new WeakMap,Iu=new WeakSet;function tA(e,t,n){const r=e.getInstance(d.DISPOSABLE_ID);if(r?.isDisposed()){we("ui",()=>Yn(e).disposeAll()),we("commands",()=>ke(e).disposeAll());return}Su.get(e)?.dispose();const s=new d.Disposable([YI(e,t),eA(n)]);Su.set(e,s),r?.addDisposable(s),r&&!Iu.has(e)&&(Iu.add(e),r.addDisposable(zI(e)))}function nA(e){return e?.lockEditor===!0}var Au={text:"text",img:"image",a:"link",button:"button",div:"container",vindent:"spacer",video:"video",table:"table",customTable:"table",structure:"row",column:"column",td:"cell",var:"variable",countdown:"countdown",carousel:"carousel",accordion:"accordion",social:"social",floatBlock:"floatingBlock"};function rA(e){return typeof e=="string"&&Object.hasOwn(Au,e)&&Au[e]||"none"}function gn(e,t,n){let r,s;const o=()=>{const i=e.getInstance(t);return i===void 0||r?r!==void 0:(r=n(i),!0)};return o()||(s=e.onInject(i=>{i===t&&o()&&s?.dispose()})),{dispose:()=>{s?.dispose(),r?.dispose()}}}function sA(e){const t=At(e),n={editor:!1,document:!1},r=()=>en(t,{readOnly:n.editor||n.document});r();const s=[Ts(e).watch(o=>en(t,{headless:o})),ar(e).watch(({isCodeMode:o})=>en(t,{codeMode:o})),gn(e,d.CONFIG_SOURCE_ID,o=>o.watch(i=>{n.editor=nA(i),r()})),gn(e,pt,o=>{let i,a;const c=()=>{const h=o.sessionKey(),g=h!==void 0&&!Q(h)?o.current()?.get().attributes:void 0;n.document=g?.lock===!0&&!ea(e,g),r()},l=()=>{const h=o.sessionKey();en(t,{documentOpen:h!==void 0,documentKind:h===void 0?void 0:Q(h)?"block":"email"});const g=o.current();g!==i&&(a?.(),i=g,a=g?.subscribe(c)),c()};l();const u=o.subscribe(l),f=Lp(e,c);return{dispose:()=>{u(),a?.(),f.dispose()}}})];return s.push(gn(e,d.STORE_ID,o=>{const i=()=>{const l=o.getState(),u=Se(t)?.documentKind==="block"?l.blockSlice:l.emailSlice;en(t,{selection:rA(u?.elementSettings?.type)})};i();const a=t.select(l=>l?.documentKind).watch(i),c=o.subscribe(i);return{dispose:()=>{c(),a.dispose()}}})),{dispose:()=>s.forEach(o=>o.dispose())}}var oA=["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"],iA=["closeBlock","compileEmail","getBlockSnapshot","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","openBlock","save","saveBlock","setConfig","show","showBlock","updateConfig","useAsync","validateCode","waitPlugin"],Tr=new Map([...oA.map(e=>[e,"event"]),...iA.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),aA=new Map([["use","use `useAsync()` or await `ready` first"]]);function cA(e){return aA.get(e)??"await `ready` first"}var lA=new Set(["async","queued"]),dA=Symbol.for("emailmaker.earlyCtxPlaceholder");function Tu(e){return e[dA]=!0,e}function uA(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 (${cA(e)}).`)}function fA(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function hA(e){return[...Tr].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function pA(e,t){for(const n of hA(e)){const r=Tr.get(n);if(r!==void 0&&lA.has(r)){const s=async(...o)=>{await t;const i=e[n];if(typeof i!="function"||i===s)throw fA(n);return i.apply(e,o)};e[n]=Tu(s);continue}e[n]=Tu(()=>{throw uA(n)})}}function mA(e,t,n){e.getInstanceAsync(Rt).then(()=>{d.getEmitter(e,d.events.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function gA(e,t){e.getInstanceAsync(Rt).then(()=>{d.getEmitter(e,d.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 _A=d.defineMixin(e=>{let t;function n(){return new Promise(s=>{const o=e.getOrCreateInstance(d.LATE_SURFACE_LISTENERS_ID,()=>new Set),i=()=>{o.delete(i),s()};o.add(i)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(s){const o=e.getInstance(d.INSTANCE_ID),i=e.getInstance(bu);if(!t){t=new Mf(o,i,{ensureHostRuntimeReady:HI,explainScriptFailure:GI,openEarlyWindow:()=>sI(e),reportLoadFailure:l=>gA(e,l)}),e.inject(d.PLUGIN_COLLECTION_ID,t),tA(e,t,i);const c=t.onLifecycle(l=>{l.type==="create:error"&&mA(e,l.name,l.error)});e.getInstance(d.DISPOSABLE_ID)?.addDisposable(c),e.getInstance(d.DISPOSABLE_ID)?.addDisposable(sA(e))}const a=s?.plugins||[];o&&(Ts(e),a.length>0&&pA(o,n()),await t.setPlugins(a))},instance:{use(s){return typeof s=="function"?r().useByCtor(s):r().useByKey(s)},useAsync(s){return r().useAsync(s)},waitPlugin(s){return r().waitFor(s)}},dispose(){t?.dispose(),t=void 0}}});async function vA(){return(await mn()).asyncMixins}var EA=_A,bA=e=>{let t=null,n=null,r=!1;const s=async()=>{let o;try{o=await vA()}catch(c){throw e.failPendingWaits(c),c}const i=o(e),a=await e.getInstanceAsync(d.INSTANCE_ID);Object.assign(a,i.instance||{});for(const c of e.getInstance(d.LATE_SURFACE_LISTENERS_ID)??[])c();return i};return{instance:{},async setOptions(o){!t&&!r&&(n??=s().catch(i=>{throw n=null,i}),t=await n),t&&await t.setOptions(o)},dispose(){t?.dispose(),r=!0}}},yA=class{_context;constructor(e){this._context=e}tools(){return Xn(this._context.container).tools()}invoke(e,t,n){return Xn(this._context.container).invoke(e,t,n)}turn(e){return Xn(this._context.container).turn(e)}undoTurn(){return Xn(this._context.container).undoTurn()}},Cu=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const s=this._listeners.indexOf(r);s>=0&&this._listeners.splice(s,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}},wA=d.createIdentifier("ELEMENT_INSERT_HTML_PIPELINE"),SA=d.createIdentifier("BLOCK_INSERT_HTML_PIPELINE"),IA="application_block_inserted",AA=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(SA,()=>new Cu).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(jt,()=>new Ft),s=n?e.bind(n):e;return r.addListener(IA,s,t)}},TA=class{_context;constructor(e){this._context=e}register(e,t){const n=this._context.container,r=Je(n).current(),s={},o={};for(const[i,a]of Object.entries(e)){const{run:c,...l}=a;if(typeof c!="function")throw new Error(`Command "${i}" of "${r.name}" has no \`run\`; declare it with defineCommand({ title, run }).`);s[i]=l,o[i]=c}return ke(n).register(r,s,o,t)}run(e,...t){return ke(this._context.container).run(e,t[0],{caller:"plugin"})}has(e){return ke(this._context.container).has(e)}},CA=class{_context;constructor(e){this._context=e}onWillSave(e){const t=this._context.container;return je(t).onWillSave(Je(t).current(),e)}onDidChange(e){const t=this._context.container;return je(t).onDidChange(Je(t).current(),e)}get selection(){return je(this._context.container).selection}transaction(e){return Is(this._context.container).group(e)}},Oo=d.createIdentifier("ComponentRegistry"),OA=d.createIdentifier("ComponentRegistryGate");function Do(){return d.DependencyResolver.getOrCreateInstance(OA,()=>({pending:[]}))}function DA(e=Oo){return Do().factory!==void 0||d.DependencyResolver.getInstance(e)!==void 0}function Po(e,t,n=Oo){if(DA(n)){t(Cr(e,n));return}Do().pending.push(()=>t(Cr(e,n)))}function Cr(e,t=Oo){const n=d.DependencyResolver.getInstance(t);if(n)return n;const r=Do().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return d.DependencyResolver.getOrCreateInstance(t,r)}var PA=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=o=>{if(!n){n=!0;for(const i of t)i.dispose();e(o)}};t.push(this._container.addService(Tn,{execute:o=>{r(o.value.map(i=>({name:i.name,html:i.html})))}}));const s=this._container.getInstance(ah)?.watch(o=>{o&&r([])});s&&(n?s.dispose():t.push(s))})}update(e,t){const n=this._container;return n.addService(Tn,{execute:r=>{const s=Cr(n),o=r.value.find(i=>i.name===e);if(o){const{icon:i,title:a,fallbackTooltip:c,...l}=t;i&&(o.icon=s.getReactNode(i)),a&&(o.title=s.getReactNode(a)),c&&(o.fallbackTooltip=s.getReactNode(c)),Object.assign(o,l)}}})}delete(e){this._container.addService(Tn,{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(Tn,{execute:r=>{const s=Cr(n);r.value.splice(t??r.value.length,0,{...e,title:s.getReactNode(e.title),icon:s.getReactNode(e.icon),fallbackTooltip:s.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(wA,()=>new Cu).add(e,t??0,n)}handleInject(e,t,n){return d.getEmitter$1(this._container,ih).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},RA=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(jt,()=>new Ft)}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 kA(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Ou(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 NA=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=d.getEmitter$1(t,lh),this._closeModalEmitter=d.getEmitter$1(t,dh),this._updateModalEmitter=d.getEmitter$1(t,uh)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Po(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Ou(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Po(this._container,r=>{const s=o=>o===void 0?void 0:r.getReactNode(o);this._updateModalEmitter.fire(kA({...t,content:s(t.content),title:s(t.title),id:e,modalProps:Ou(r,n)}))})}};function Or(e){return e?.surfaces?{surfaces:[...e.surfaces]}:{}}var LA=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=s=>{this._loadedSettled||(this._loadedSettled=!0,r(s))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=s=>{this._readySettled||(this._readySettled=!0,r(s))}})}_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)}},xA=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(jt,()=>new Ft)}_createScriptHandle(e,t){const n=this._messageService.addListener(jr,s=>{if(s.key===e){if(s.phase==="load"&&s.status==="success"){r.resolveLoaded();return}if(s.phase==="ready"&&s.status==="success"){r.resolveReady();return}if(s.phase==="load"){r.rejectLoad(new Error(s.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(s.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new LA(t,n);return r}registerSandboxCSS(e,t){return this._container.addService(lt,{...Or(t),type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t,n){return this._container.addService(lt,{...Or(n),type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e,t){const n=this._container.addService(lt,{...Or(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(lt,{...Or(n),type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,r)}},MA=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function Ro(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&MA.has(t)}function Du(){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 ko(){return`__settingsPanel:${Du()}`}function No(e,t){return{type:e,props:t}}function FA(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!Ro(e)}function Pu(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(Ro(t)){const r=ko();return n(e.add(r,t)),No(r,{})}if(typeof t=="function"){const r=ko();return n(e.add(r,t)),No(r,{})}if(FA(t)){const r=t.type;if(typeof r=="string")return t;if(Ro(r)||typeof r=="function"){const s=ko();return n(e.add(s,r)),No(s,t.props)}return t}return t}var BA=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??Du();Po(this._container,n=>{const r=i=>this._trackRegistration(i),s=Pu(n,e.content,r),o=e.advancedTabs?.map(i=>({...i,content:Pu(n,i.content,r)}));d.getEmitter$1(this._container,fi).fire({...e,content:s,advancedTabs:o,instanceKey:t,type:ch})})}closeSettingsPanel(){this._clearPanelRegistrations(),d.getEmitter$1(this._container,fi).fire(null)}},jA=class{_context;constructor(e){this._context=e}get apiVersion(){return this._service().apiVersion}supports(e,t){return this._service().supports(e,t)}addViews(e,t){return this._service().addViews(this._owner(),e,t,this._context)}addItem(e){return this._service().addItem(this._owner(),e)}open(e,...t){return this._service().open(e,t[0])}_service(){return Yn(this._context.container)}_owner(){return Je(this._context.container).current()}},Ru=bs({SandboxScriptApi:xA,ElementsApi:PA,BlocksApi:AA,MessageService:RA,SettingsPanelApi:BA,ModalApi:NA,Commands:TA,Ui:jA,Agent:yA,Document:CA});function Lo(e,t,n,r={}){const s=Object.assign({},e);for(const[o,i]of Object.entries(t))if(i!==void 0)if(n.includes(o)&&typeof i=="object"&&i!==null){const a=s[o],c=r[o]??{};s[o]=Object.assign({},typeof a=="object"&&a!==null?a:c,i)}else s[o]=i;return s}var Oe={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}},UA={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"},xo={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},ku={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},kt={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:Oe.border,borderRadius:Oe.borderRadius,textAlign:"center",padding:Oe.padding},Nu={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:Oe.padding},Mo={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:Oe.border,borderRadius:Oe.borderRadiusCards};function $A(e){return{...UA,...e}}function HA(e){return{...xo,...e,bold:e?.bold??xo.bold,italic:e?.italic??xo.italic}}function GA(e){return{...ku,...e,underline:e?.underline??ku.underline}}function VA(e){return{...kt,...e,bold:e?.bold??kt.bold,italic:e?.italic??kt.italic,border:{...kt.border,...e?.border},borderRadius:{...kt.borderRadius,...e?.borderRadius},padding:{...kt.padding,...e?.padding}}}function WA(e){return{...Nu,...e,padding:{...Nu.padding,...e?.padding}}}function KA(e){return{...Mo,...e,border:{...Mo.border,...e?.border},borderRadius:{...Mo.borderRadius,...e?.borderRadius}}}function Fo(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 Lu(e){let t={...Jr};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function Bo(e){return{text:$A(e.text),headings:HA(e.headings),links:GA(e.links),buttons:VA(e.buttons),block:WA(e.block),cards:KA(e.cards)}}var jo=d.createIdentifier("EmailSettingsPort");function qA(e){return e?.getInstance(jo)}var zA=1e4,xu=class{_editor;_layoutSettingsChanged=new d.Emitter;_contentStylesChanged=new d.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(!eu(this._editor.container)||!mt(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(jo);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Fo(this._settings().read())}_getCurrentContentStyles(){const e=mt(this._editor.container)?.current()?.get().attributes.common_styles;return Bo(Lu(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(jo),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(jt,()=>new Ft),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const s=r?.data,o=s?.operation;if(o===q.APPLICATION_EMAIL_SETTINGS_SET){const c=Fo(s?.settings),l=this._getLayoutSnapshot(c);l!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=l,this._layoutSettingsChanged.fire(c));return}if(o!==q.APPLICATION_COMMON_STYLES_UPDATE)return;const i=Bo(r.data?.settings?.commonStyles??{...Jr}),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=Fo(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=zA){const t=mt(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,s=d.getEvent(r,d.events.ON_EMAIL_INIT_ID);return new Promise(o=>{let i=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},l=s(()=>{i||(i=!0,c(),l.dispose(),o())});a=setTimeout(()=>{i||(i=!0,l.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=mt(this._editor.container)?.current();if(!t)return;const n=Lu(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=Lo(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:Oe.border,borderRadius:Oe.borderRadius,padding:Oe.padding})),e.block!==void 0&&(n.block=Lo(n.block||{},e.block,["padding"],{padding:Oe.padding})),e.cards!==void 0&&(n.cards=Lo(n.cards||{},e.cards,["border","borderRadius"],{border:Oe.border,borderRadius:Oe.borderRadiusCards}));const r=JSON.stringify(n);Et(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const s=Bo(n);this._prevContentSnapshot=this._getContentSnapshot(s),this._contentStylesChanged.fire(s)}},YA={...Ru,...bs({EmailSettingsApi:xu})};function XA(e){const t=e;return yu.has(e)&&Ar.has(t)&&!Ac(Ar.get(t),e)}function JA(e){Ar.addAll(Object.fromEntries(Object.entries(e).filter(([t])=>!XA(t))))}var QA={...Ru},r0={...QA,...bs({EmailSettingsApi:xu})},ZA={...YA};function eT(){JA(ZA)}function Uo(){let e,t=!1;const n=new Map,r=new Map;function s(){for(const o of r.values())o();r.clear()}return{event(o,i,a){const c=Symbol("subscription");return t||(n.set(c,{listener:o,priority:i,thisArg:a}),e&&r.set(c,e(o,i,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(o){s(),e=o;for(const[i,{listener:a,priority:c,thisArg:l}]of n)r.set(i,o(a,c,l))},dispose(){t=!0,s(),n.clear(),e=void 0}}}function tT(e){const t=Uo(),n=Uo(),r=Uo();return e.getInstance(d.DISPOSABLE_ID)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(Rt).then(s=>{t.attach(s.onNotify),n.attach(s.onError),r.attach(s.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(s){const o=e.getInstance(Rt);if(o){o.notify(s);return}e.getInstanceAsync(Rt).then(i=>i.notify(s),()=>{})}}}function Mu(e,t,n=!0){const r=e,s=t;for(const o of Object.keys(s)){const i=s[o];i!=null&&(n&&typeof i=="object"?r[o]=Mu(r[o]||{},i,!0):r[o]=i)}return e}async function nT(e){const t=(await Df.__vitePreload(()=>Promise.resolve().then(()=>Promise.resolve(Sn("./static/umd/6639d610.js")).then(n=>Lt.__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 Fu=d.createIdentifier("EditorOptions"),$o=kp;function rT(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 sT(e){return e.getOrCreateInstance(Fu,()=>{const t=se($o);let n=$o.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(nT(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function oT(e){return e?.getInstance(Fu)?.get()??$o}function iT(e,t={}){const n=sT(e);n.set(Mu({...n.get()},rT(t)))}function aT(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 cT(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var lT=d.createIdentifier("plugin.publicConfig");function Ho(e){return e.getInstance(d.CONFIG_SOURCE_ID)?.get()??{}}function Bu(e){return e.getInstance(d.CONFIG_SOURCE_ID)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function ju(e){const t=Bl(e),n=Ho(e);return{...n,locale:n.locale||"en_US",theme:n.theme||"light",editor:cT(oT(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Uu(e){return e.getInstance(d.CONFIG_SOURCE_ID)?.get()!==void 0}function dT(e){const t=lo(),n=me(e,d.CONFIG_CHANGED_EVENT_ID);let r,s,o=!1;const i=async()=>{try{return e.getInstance(d.APP_ID)===void 0?{}:(await e.getInstanceAsync(d.APP_ID))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:f=!1}={})=>{await e.getInstance(d.CONFIG_SOURCE_ID)?.ready(),Ji(e).set(Ho(e).revisionService===!0);const{codeModeDirection:h,editor:g}=Ho(e);g&&iT(e,aT(g)),h!==void 0&&!(f&&h===s)&&(s=h,h==="none"?Gs(e,!1):(Gs(e,!0),Ib(e,h)))},c=async()=>{if(!Uu(e))return;const f=ju(e),h=JSON.stringify(f);h!==r&&(r=h,await n.fire(f))},l=async f=>{const h=e.getInstance(d.CONFIG_SOURCE_ID),g={advancedConfigs:Bu(e).advancedConfigs,serverSide:await i(),user:f};h?.setAdvancedConfigs({...g.advancedConfigs,...g.user?.advancedConfigs});const p=h?.layers().user.mode;h?.replace(g.user?.mode===void 0&&p!==void 0?{...g.user,mode:p}:g.user,"user"),h?.replace(g.serverSide,"server"),await a(),await c()},u=f=>{const{commonStyles:h,...g}=f;return"commonStyles"in f&&Tb(e,h===void 0?void 0:h),g};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:i,getConfig:()=>Uu(e)?ju(e):{},setConfig:t.decorate(async f=>{await l(u(f))}),updateConfig:t.decorate(async f=>{const h=u(f);await l({...Bu(e).user,...h})}),announceAssembled(){o||(o=!0,e.getInstance(d.CONFIG_SOURCE_ID)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function $u(e){return e.getOrCreateInstance(lT,()=>dT(e))}function uT(e){const t=$u(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var Hu=d.createIdentifier("CodeErrors"),fT=[];function hT(e){return e?.getInstance(Hu)?.get()??fT}function pT(e){return e?.getInstance(Hu)!==void 0}function mT(e){const t=Bc(e);let n;const r=()=>{const o=e.getInstance(d.CONFIG_SOURCE_ID);return o&&!n&&(n=o.watch(i=>t.set(i?.agent??{}))),n!==void 0},s=r()?void 0:e.onInject(o=>{o===d.CONFIG_SOURCE_ID&&r()&&s?.dispose()});return{dispose:()=>{s?.dispose(),n?.dispose()}}}function gT(e){const t=je(e);return gn(e,pt,n=>{let r,s;const o=()=>{const c=n.sessionKey();c!==void 0&&t.emitChange({kind:Q(c)?"block":"email"})},i=()=>{const c=n.current();c!==r&&(s?.(),r=c,s=c?.subscribe(o),c&&o())};i();const a=n.subscribe(i);return{dispose:()=>{a(),s?.()}}})}function _T(e,t){if(e===t)return!0;try{return ve(JSON.parse(e||"{}"),JSON.parse(t||"{}"))}catch{return!1}}var s0=d.createIdentifier("planFeatures.source");function Go(e){return Ie(e)?.current()}function vT(e){return Se(At(e))?.readOnly===!0}var ET=()=>ie("readOnly","The document is read-only.");function bT(e,t){return!1}var yT=e=>ie("lockedByPlan",e);function wT(e,t,n){return bT(e,t)?yT(`Working with ${n} is not available on the current plan.`):void 0}function ST(e){return wT(e,"undo_redo","undo and redo")}var IT=Op+Dp;function Gu(e){const t=ce(e);return t.isInited()&&!!t.getTarget()}async function AT(e,t){const n=ce(e);if(!Gu(e))return ie("unavailable","The canvas is not open.");try{const r=await ll(n.sendAsync(q.SANDBOX_ELEMENT_OPERATION,t),IT,"sandbox:element");if(!r)return ie("unavailable","The canvas does not support element commands.");if(r.ok)return ze(r.value);const s=r;return ie(s.code,s.message)}catch(r){if(r instanceof cl)return ie("unavailable","The canvas did not answer in time.");throw r}}var Vu=["subject","preheader","title","utm_parameters","common_styles","meta"],TT={id:0,below:0},Wu=()=>({code:"nothingToUndo",message:"The last answer changed nothing that could be undone."}),Nt=e=>({code:"undoConflict",message:e});function CT(e,t,n){return e==="common_styles"?_T(t,n??""):ve(t,n)}function Ku(e,t){return Object.fromEntries(Vu.filter(n=>!CT(n,e[n],t[n])).map(n=>[n,e[n]]))}function OT(e){const t=()=>{const n=Go(e);if(!n)return;const{docId:r,attributes:s}=n.get();return{docId:r,step:Ie(e)?.history()?.currentStep()??TT,fields:Object.fromEntries(Vu.map(o=>[o,s[o]]))}};return{document:()=>Go(e)?.get().docId,capture:t,undoRefusal:()=>ST(e)?.error,settle:async()=>{if(Gu(e))return(await AT(e,{op:"settle"})).ok?void 0:Nt("The canvas did not answer, so edits made after the answer cannot be ruled out.")},undo:(n,r)=>{const s=n,o=r;if(!s)return Wu();if(o?.docId!==s.docId)return Nt("The answer ended on another email.");const i=o.step.id!==s.step.id,a=Ku(s.fields,o.fields);if(!i&&Object.keys(a).length===0)return Wu();const c=Go(e),l=t();if(!c||l?.docId!==o.docId)return Nt("Another email is open now, not the one the answer changed.");if(vT(e))return ET().error;if(l.step.id!==o.step.id||Object.keys(Ku(l.fields,o.fields)).length>0)return Nt("The email was edited after the answer.");if(i&&o.step.below!==s.step.id)return Nt("The answer moved through the undo history itself and cannot be taken back as one step.");if(i&&!Ie(e)?.history()?.tryUndo())return Nt("The step of the answer could not be undone: the text changed under it.");Object.keys(a).length>0&&(c.mutate({attributes:a},{source:"user"}),qA(e)?.markAppearanceChanged())}}}function DT(e){let t;return Is(e).connect({begin:()=>{t??=Ie(e)?.history()?.beginTransaction()},end:()=>{const n=t;t=void 0,n?.()},answers:OT(e)})}function PT(e){const t=je(e).selection,n=ce(e),r=()=>t.set(null),s=n.addListener(a=>{const c=a?.data;c?.operation===q.APPLICATION_ELEMENT_SETTINGS_SET?t.set(c.type&&typeof c.elementRef=="string"?c.elementRef:null):c?.operation===q.APPLICATION_ELEMENT_SETTINGS_CLOSE&&r()}),o=Vt(n,r),i=gn(e,pt,a=>{let c=a.current();return{dispose:a.subscribe(()=>{a.current()!==c&&(c=a.current(),r())})}});return{dispose:()=>{s.dispose(),o(),i.dispose()}}}function RT(e){const t=[mT(e),DT(e),gT(e),PT(e)];return{dispose:()=>t.forEach(n=>n.dispose())}}function o0(e){return e}var kT="SAVE",NT="SAVE_BLOCK",i0="SET_THEME",a0="NOTIFY",c0="SET_CONFIG",l0="UPDATE_CONFIG",qu=class extends d.Disposable{_options;_listeners=[];constructor(e){super(),this._options=e}fire=e=>{if(!this.isDisposed()){let t;const n=[...this._listeners];for(const r of n){if(t===!1)return!1;t instanceof Promise?t=t.then(s=>s===!1||this.isDisposed()?!1:r(s)).catch(s=>{}):t=r(e)}return t}};addEventListener=e=>{const t=this._listeners,n=this._options;return t.push(e),t.length===1&&this._options?.onFirstListenerAdd&&this._options.onFirstListenerAdd(),{dispose:()=>{const r=t.indexOf(e);r>=0&&(t.splice(r,1),t.length||n?.onFirstListenerAdd&&n.onLastListenerRemove())}}};event=this.addEventListener},zu;(function(e){function t(s){let o;const i=new qu({onFirstListenerAdd(){o=s(i.fire)},onLastListenerRemove(){o.dispose()}});return i.event}e.snapshot=t;function n(s,o){return t(i=>s(a=>o(a)&&i(a)))}e.filter=n;function r(s,o){return t(i=>s(a=>i(o(a))))}e.map=r})(zu||(zu={}));var LT=d.createIdentifier("helpers.commandEmitter");function xT(e,t,n){e instanceof d.Container||(e=yh(e)),e.getOrCreateInstance(LT,()=>new qu).fire({id:t,payload:n})}function MT(e,t,{yieldable:n=!1,details:r,prepare:s}={}){const o=ke(e),i=new Map,a=new Set,c=o.commands.watch(()=>{o.disposed||Object.entries(t).forEach(([l,{declaration:u,handler:f}])=>{const h=o.info(l)?.owner;h?n&&h!==Xe&&!a.has(l)&&(a.add(l),`${l}${h.name}`,void 0):(a.delete(l),i.set(l,o.register(Xe,{[l]:u},{[l]:f},{},{yieldable:n,details:r,prepare:s})))})});return{dispose:()=>{c.dispose(),i.forEach(l=>l.dispose())}}}var Vo="document.getSnapshot",FT="document.save",Yu=Symbol.for("emailmaker.legacyEmailSnapshot"),Wo=Symbol.for("emailmaker.legacyEmailSnapshotError");function BT(e,t){return Object.defineProperty(e,Yu,{value:t})}function jT(e){return BT({kind:"email",id:e.id==null?null:String(e.id),content:e.code??"",subject:e.subject??"",preheader:e.preheader??""},e)}function UT(e){return{kind:"block",id:e.id==null?null:String(e.id),content:e.code??"",subject:"",preheader:""}}function $T(e,t){return MT(e,{[Vo]:{declaration:{title:"Get document snapshot",description:"Returns the open document: kind, id, HTML content, subject and preheader.",agent:{readOnly:!0}},handler:async()=>{try{const n=Ie(e),r=Q(n?.sessionKey())?await t.getBlockSnapshot():null;return ze(r?UT(r):jT(await t.readEmailSnapshot()))}catch(n){return Object.defineProperty(ie("internal",n instanceof Error?n.message:String(n)),Wo,{value:n})}}},[FT]:{declaration:{title:"Save document",description:"Saves the open document and finishes when the save is done. A save refused by a rule (a plugin check, empty content, too many tags, edits still on their way, the host cancelled it) answers `refused`, and its message names the reason: tell the user.",agent:!0},handler:(n,r)=>KT(e,r.caller)}})}async function HT(e,t){const n=await ke(e).run(Vo,void 0,{caller:"plugin"});if(n.ok===!1){if(Wo in n)throw n[Wo];return t()}return n.value[Yu]}function GT(e){return ke(e).info(Vo)?.owner===Xe}var VT="The host cancelled this save, so nothing was saved. Tell the user; do not repeat the call unless the user asks for it again.";async function WT(e,t,n){const r=await new Promise(a=>{xT(e,t,{source:j_,settle:a})});if(r.ok!==!1)return ze();if(r.reason==="unready")return;const s=n==="agent"?r.refusal??(r.reason==="aborted"?VT:void 0):void 0,o=r.reason==="locked"?"readOnly":r.reason==="aborted"?"aborted":"internal",i=s?ie("refused",s):ie(o,r.message);return r.notified?Object.defineProperty(i,$_,{value:!0}):i}async function KT(e,t){if(Se(At(e))?.readOnly)return ie("readOnly","The editor is read-only.");const n=Ie(e)?.sessionKey();if(n!==void 0){const s=Q(n);if(G_(e,s?"block":"email")){const o=await WT(e,s?NT:kT,t);if(o)return o}}const r=e.getInstance(d.INSTANCE_ID);if(n===void 0||!r)return ie("unavailable","There is no open document to save.");try{return await(Q(n)?r.saveBlock():r.save()),ze()}catch(s){if(s instanceof Ne&&s.reason==="locked")return ie("readOnly",s.message);const o=t==="agent"?ym(s):void 0;return o?ie("refused",o):ie("internal",s instanceof Error?s.message:String(s))}}var qT=class extends d.Disposable{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=ln(e),this.addDisposable(d.getEvent(e,d.events.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t})),this.addDisposable($T(e,this)),this.addDisposable(RT(e))}openEmail(){const e=Ie(this._container);if(e&&Q(e.sessionKey())&&!e.hasSuspended())throw new Error("[useblocks] no open email: only a block is shown");return yd(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=>Ee(t,this._container))}async _readProjectBlocks(){const e=await wd(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>un(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.readEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>co(n,this._container))}async getEmailSnapshot(){return Q(Ie(this._container)?.sessionKey())||!GT(this._container)?this.readEmailSnapshot():HT(this._container,()=>this.readEmailSnapshot())}async readEmailSnapshot(){return Te(this.openEmail(),this._container)}async getBlockSnapshot(){const e=Ie(this._container),t=e?.current();return!e||!t||!Q(e.sessionKey())?null:(await t.whenReady(),Ee(or(t),this._container))}setEmailMeta(e){const t=ro(this._container);if(!t)return;const n=t.get().attributes.meta;Et(t,{meta:dr({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,s=>s&&dr(s,e))}setBlockMeta(e,t){const n=Ie(this._container);if(n?.sessionKey()===Mn(e)){const s=n.current();s&&Et(s,{meta:dr({meta:s.get().attributes.meta},t).meta})}const r=async()=>{await this._readProjectBlocks();const{cache:s}=this._dataSources.blocks;await s.getIfPresent(e)&&await s.addOrUpdate(e,o=>o&&dr(o,t))};this._blockMetaWrites=this._blockMetaWrites.then(r).catch(()=>{})}getCodeErrors(){return pT(this._container)?hT(this._container):void 0}},zT=d.createIdentifier("EmailDataController");function YT(e){return e.getOrCreateInstance(zT,()=>{const t=new qT(e);return e.getInstance(d.DISPOSABLE_ID)?.addDisposable(t),t})}function XT(e){const t=YT(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 JT(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 QT(e){let t;const n=Jl(e),r=d.getEvent(e,d.events.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:o})=>{t=o}));const s=()=>t?JT(t):void 0;return{undoRedoService:{undo:()=>s()?.undo(),redo:()=>s()?.redo(),clear:()=>s()?.clear(),getPast:o=>s()?.getPast(o)??[],getFuture:o=>s()?.getFuture(o)??[],canUndo:()=>s()?.canUndo()??!1,canRedo:()=>s()?.canRedo()??!1,createSnapshot:()=>s()?.createSnapshot(),restoreSnapshot:o=>s()?.restoreSnapshot(o)}}}var ZT=d.createIdentifier("plugin.mountElement");function eC(e){const t=e.getInstance(d.OPTIONS_SOURCE_ID)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function tC(e){return e.getOrCreateInstance(ZT,()=>{let t=!1,n;return{get:()=>t?n:eC(e),set(r){t=!0,n=r}}})}function nC(e){const t=tC(e);return{getElement:()=>t.get()}}var at="options.announced",Xu={passes:[at],awaits:[Yr]},Ju=d.createIdentifier("plugin.optionsEvents");function rC(e){const t=e.getInstance(d.DISPOSABLE_ID),n=t.addDisposable(new d.AsyncEmitter),r=t.addDisposable(new d.AsyncEmitter),s=d.getEmitter(e,d.CONFIG_CHANGED_EVENT_ID),o={handleSetOptions:H(n.event),handleOptionsChanged:H(r.event),handleConfigChanged:tu(H(s.event),e)};e.inject(Ju,o);const i=t.addDisposable(new Dt(o.handleSetOptions)),a=t.addDisposable(new Dt(o.handleOptionsChanged)),c=t.addDisposable(new Dt(o.handleConfigChanged)),l=async f=>{await n.fire(f),await r.fire(f)},u=ht(e).each((f,h)=>{i.setListener(h.handleSetOptions),a.setListener(h.handleOptionsChanged),c.setListener(h.handleConfigChanged),$u(e).announceAssembled(),f.hold(l(h).then(()=>f.reach(at)))});t.addDisposable(u)}function sC(e){return{...e.getInstance(Ju)}}function oC(e=Xi){const t=new Error(e);return t.name="AuthPipelineError",t}async function Qu(e,t,n,r){const s=r?.attemptTimeout??ut(n),o=ut(n)?Mi(n):$t(n).length>0?[Ht(n)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const i=e.startsWith("/")?e:`/${e}`;let a,c;for(let l=0;l<o.length;l++){const u=o[l],f=l===o.length-1,h=s?Bi(t.signal):void 0;try{const g=await fetch(`${u}${i}`,{...t,...h?{signal:h.signal}:{}});if(!g.ok&&ji(g.status)){if(a=g,!f){Dn(u,n);continue}break}return g.ok&&Hi(u,n),g}catch(g){const p=h?.timeoutError();if(!p&&!Ui(g))throw g;c=p||g,f||Dn(u,n)}finally{h?.done()}}if(ut(n)&&Gi(),a)return a;throw c instanceof Error?c:new Error("[apiOriginFailover] fetch chain failed")}function Zu(e){e.inject(d.JWT_ERROR_ID,void 0),e.inject(d.JWT_TOKEN_ID,void 0)}function iC(e){let t,n;const r=lo();return e.addService(Ge,{execute:r.decorate(async(s,o)=>{if(o?.public||!t)return;const i=String(e.getInstance(d.JWT_TOKEN_ID)||"").trim();if(i){s.headers.append("authorization",`Bearer ${i}`);return}if(!e.getInstance(d.JWT_ERROR_ID))try{const a=e.getInstance(Vi),c=String(a?.getOptions()?.baseUrl||"").trim(),l=Fi(n||c||void 0);if(!l)throw new Error("JWT auth requires baseUrl");const u=await Qu("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},l);if(!u.ok)throw new Error(`JWT auth failed: ${u.status}`);const f=await u.json(),h=String(f.token||"").trim();if(!h)throw new Error("JWT auth failed: empty token");e.inject(d.JWT_ERROR_ID,void 0),e.inject(d.JWT_TOKEN_ID,h),s.headers.append("authorization",`Bearer ${h}`)}catch{throw e.inject(d.JWT_ERROR_ID,Xi),oC()}})}),{apply(s){const o=s.jwtAuth,i=String(s.baseUrl||"").trim()||void 0,a=!ve(o,t),c=i!==n;if(t=o,n=i,!o){Zu(e);return}a||c?Zu(e):e.inject(d.JWT_ERROR_ID,void 0)}}}function aC(e){const t=iC(e),n=ht(e).each((r,s)=>{r.whenReached(at,()=>t.apply(s))});e.getInstance(d.DISPOSABLE_ID)?.addDisposable(n)}function cC(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function lC(e){if(!e)return;const t=d.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}function dC(e,t){if(e.getInstance(d.STANDALONE_FILE_PROXY_REGISTERED_ID))return;e.inject(d.STANDALONE_FILE_PROXY_REGISTERED_ID,!0);const n=d.getEvent(e,d.events.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var Dr="standalone.keyDecided";function uC(e){let t,n=!1;return{apply(r,s){const o=s??n,i=n;if(o&&!i&&(t=e.getInstance(d.SECURITY_MODULE_ID)||void 0),n=!0,!sn(r)){t&&(ay(e),zs(r)),t=void 0;return}const a=lr(r);if(!a||i&&t===a&&e.getInstance(d.SECURITY_MODULE_ID))return;t=a,e.inject(d.SECURITY_MODULE_ID,a);const c=e.getInstance(d.DISPOSABLE_ID);c&&dC(e,c)}}}function fC(e){const t=uC(e);let n=0;const r=ht(e).each((s,o)=>{const i=n>0;n+=1,s.whenReached(at,()=>{t.apply(o,i),s.reach(Dr)})});e.getInstance(d.DISPOSABLE_ID)?.addDisposable(r)}var ef=new WeakMap;async function hC(e){if(e.getInstance(d.APP_ID)!==void 0)try{return await e.getInstanceAsync(d.APP_ID)}catch{return}}async function pC(e,t){const n=ef.get(e),r=n?.getAuthToken!==t.getAuthToken||!ve(n?.user,t.user)||n?.project!==t.project;if(ef.set(e,{getAuthToken:t.getAuthToken,user:t.user,project:t.project}),!(!e.getInstance(d.SECURITY_MODULE_ID)||!t.getAuthToken||!r))try{const s=await t.getAuthToken(t.user,t.project);e.inject(d.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(s||""));const o=lC(s);if(!o)return;e.inject(d.STANDALONE_PROJECT_ID,o),e.inject(d.APP_ID,Promise.resolve(cC(o,await hC(e))))}catch{}}function mC(e){const t=ht(e).each((n,r)=>{n.whenReached(Dr,()=>{n.hold(pC(e,r).then(()=>n.reach(Pn)))})});e.getInstance(d.DISPOSABLE_ID)?.addDisposable(t)}var gC=[{name:"options.events",reaches:[at],setup:rC},{name:"standalone.immediate",awaits:{signals:[at]},reaches:[Dr],setup:fC},{name:"auth.jwt",awaits:{signals:[at]},setup:aC},{name:"standalone.bootstrapToken",awaits:{signals:[Dr]},reaches:[Pn],setup:mC}],_C=[sC,Sy,hI,tT,uT,XT,QT,nC,Hy];function vC(e,t=_C){const n=So(e);BI(e),eT();for(const h of zr(gC))h.setup(e);const r=EA(e),s=bA(e),o={...r.instance,...s.instance};for(const h of t)Object.assign(o,h(e));let i=!0;const a=ht(e);let c=-1,l,u=0;const f=async(h,g,p)=>{const _=A=>{if(g.failed)throw A};for(const A of Xu.passes)await g.passed(A).catch(_);for(const A of Xu.awaits)g.isReached(A)||await g.reached(A).catch(_);if(c>p){await l?.outcome;return}c=p,l=g;const v=i&&n.get()===h;i=!1,v||n.set(h),await r.setOptions(h),await s.setOptions(h)};return{instance:o,async setOptions(h){const g=u++,p=a.begin(h),_=f(h,p,g);p.hold(_),await _,await p.outcome}}}function EC(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 bC=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]}},yC="editor-runtime.react.copies",Ko=8;function _n(e){return e&&typeof e=="object"?e:void 0}function tf(e){const t=_n(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=_n(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function wC(e){const t=_n(e),n=t&&typeof t.version=="string"?t.version:void 0,r=_n(t?.default),s=r&&typeof r.version=="string"?r.version:void 0;return n??s??"unknown"}function SC(e,t,n){return e.package===t&&e.version===n}function IC({ourReact:e,entries:t,packageName:n,version:r}){const s=tf(e);if(!s||!Array.isArray(t))return[];const o=[],i=new Set;for(const a of t){const c=_n(a);if(!c||!SC(c,n,r))continue;const l=tf(c.react);!l||l===s||i.has(l)||(i.add(l),o.push({package:n,version:r,reactVersion:wC(c.react),react:c.react}))}return o}function AC({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,Ko))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Ko&&n.push(` …and ${t.length-Ko} 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(`
|
|
2167
|
+
`)}var nf=new Set;function TC({packageName:e="useblocks",version:t="1.3.16",log:n=r=>{}}={}){const r=s=>{try{const o=globalThis[Symbol.for(yC)],i=IC({ourReact:s,entries:o,packageName:e,version:t}).filter(a=>!nf.has(a.react));if(!i.length)return;i.forEach(a=>nf.add(a.react)),n(AC({packageName:e,copies:i}))}catch{}};try{const s=Fr()?.modules?.React;if(s&&typeof s.then=="function"){s.then(r,()=>{});return}r(s)}catch{}}async function CC(e,t,n){d.throwIfAborted(e.signal);const r=t??d.DependencyResolver.createChild();So(r);const s=r.getInstance(d.DISPOSABLE_ID);let o;async function i(){r.inject(hi,EC(new bC)),TC();const a=vC(r),c={...a.instance,container:r,get ready(){return o??Promise.resolve(c)},async reset(l){if(d.throwIfAborted(l.signal),s.isDisposed())throw De();return await a.setOptions(l),c}};r.inject(d.INSTANCE_ID,c);try{if(n?.onInstance?.(c),await a.setOptions(e),d.throwIfAborted(e.signal),s.isDisposed())throw De();if(s.isDisposed()||await dI(r),e.devTools)try{const l=r.getInstance(d.PLUGIN_COLLECTION_ID);l&&await(await mn()).initDevTools(r,l)}catch{}return d.throwIfAborted(e.signal),d.getEmitter(r,d.APP_LOAD_EVENT_ID).fire(c),c}catch(l){throw s.dispose(),l}}try{return o=d.raceWithAbortSignal(i(),e.signal),o.catch(()=>{}),await o}catch(a){throw s.isDisposed()||s.dispose(),a}}var vn=new WeakMap;function OC(e){return e?vn.get(e):void 0}function rf(e){try{e.getInstance(d.DISPOSABLE_ID)?.dispose()}catch{}try{e.dispose()}catch{}}function DC(e,t){if(!e)return;const n=vn.get(e);n&&n!==t&&rf(n),vn.set(e,t)}function PC(e,t){e&&vn.get(e)===t&&vn.delete(e)}function RC(e){const t=d.DependencyResolver.createChild();return sn(e)&&t.inject(d.SECURITY_MODULE_ID,lr(e)),t}var En=new WeakMap,kC="data-useblocks-config-styles";function NC(e){return typeof e=="string"?e.trim():""}function sf(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function LC(e,t,n){if(!e||typeof document>"u")return null;const r=NC(t),s=En.get(e),o=n||e;if(!r)return s&&(s.remove(),En.delete(e)),null;if(s)return s.textContent!==r&&(s.textContent=r),(s.parentNode!==o||s!==o.firstChild)&&sf(o,s),s;const i=document.createElement("style");return i.setAttribute(kC,"true"),i.textContent=r,sf(o,i),En.set(e,i),i}function xC(e){if(!e)return;const t=En.get(e);t&&(t.remove(),En.delete(e))}var d0=!1;function of(){return!1}var u0=28,MC=`
|
|
2168
2168
|
.blocks-app-initial-spinner-wrapper {
|
|
2169
2169
|
width: 100%;
|
|
2170
2170
|
height: 100%;
|
|
@@ -2193,11 +2193,11 @@ __useblocks__.define("useblocks.js",["require","exports","module","static/umd/b1
|
|
|
2193
2193
|
100% {
|
|
2194
2194
|
transform: rotate(360deg);
|
|
2195
2195
|
}
|
|
2196
|
-
}`;function kI(){return()=>{}}function NI(e,t){if(!Pd()||!e||typeof document>"u")return kI();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 s=document.createElement("style");s.setAttribute(t,"true"),s.textContent=RI,document.head?.appendChild(s),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),s.remove())}}function LI(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function MI({report:e}={}){const t=new Map,n=new Set,r=e??(s=>{});return{run(s,o){const i=t.get(s);if(i!==void 0)return i;const a=o().catch(c=>{throw n.has(s)||(n.add(s),r(c)),LI(c)||t.delete(s),c});return t.set(s,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var ao=MI();function Rd(){ao.clear()}l.setApiOriginFailoverHook(()=>ao.clear());var kd=new WeakMap;function co(e){return l.resolveExplicitApiBaseUrl(e)}function xI(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function FI(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function BI(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 lo=new WeakMap;function uo(e,t){lo.set(e,t)}function jI(e){return lo.get(e)}function UI(e,t){return async({baseUrl:n})=>{const r=t(),s=r&&lo.get(r)||e,o=co(n);if(!o)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 BI(s);if(s.getAuthToken&&!a)throw FI();a&&i.set("authorization",a);const c=await l.fetchWithApiOriginFailover("/app/v1/app_init",{method:"POST",headers:i,body:new URLSearchParams,credentials:"same-origin"},o,{attemptTimeout:ds(s)||void 0});if(!c.ok)throw xI(c.status,c.statusText);return await c.json()}}function $I(e){return JSON.stringify({baseUrl:co(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function HI(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function VI(e){return t=>ao.run($I(t),()=>(se("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>se("appInit:end",{kind:"network"}))))}function GI(e,t){if(Ut(e)||!e.appInit&&!co(e.baseUrl)||!HI(e))return e;const n=e.appInit??UI(e,t);let r=kd.get(n);return r||(r=VI(n),kd.set(n,r)),{...e,appInit:r}}var Nd=0;function WI(){return Nd}function YI(){Nd+=1,Rd()}var Ld=new WeakMap,Md=new WeakMap,KI=3e4;function qI(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function zI(e,t){try{const n=l.decodeJwt(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+KI}function XI(e){const t=new Map,n=new Map;return async(r,s,o)=>{const i=qI(r,s);if(o)return n.delete(i),t.delete(i),Rd(),e(r,s,o);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&&(se("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,s,o)).then(d=>{const u=String(d||"").trim();return u&&n.set(i,{token:d,expiresAtMs:zI(u,Date.now())}),d}).finally(()=>{se("authToken:end",{kind:"network"}),t.delete(i)}),t.set(i,c)),c}}function JI(e){if(Ut(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Ld.get(t);const r=WI();return(!n||Md.get(t)!==r)&&(n=XI(t),Ld.set(t,n),Md.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(s=>{}),{...e,getAuthToken:n}}var QI="[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 ZI(e){const t=new Error(QI,{cause:e});return t.name="EditorStartFailedError",t}var eT={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function xd(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var Fd=["handleLoad","handleDestroy"];function Bd(e,t){let n=e;for(const r of Fd){const s=e?.[r];typeof s=="function"&&(n={...n,[r]:(o,...i)=>s(t,...i)})}return n}function tT(e){let t,n="pending",r,s,o,i;const a=new Set,c=[],d=new Set;let u,f;const h=new Promise((E,N)=>{u=E,f=N});h.catch(()=>{});const g={},m=E=>t?.[E],v=()=>r??ke(),_=(E,N)=>{const F=m(E);if(typeof F!="function")throw xd(E);return F.apply(t,N)},T=(E,N)=>{try{return Promise.resolve(_(E,N))}catch(F){return Promise.reject(F)}},A=()=>{const E=t?.container?.getInstance?.(l.DISPOSABLE_ID);if(!(n!=="ready"||E?.isDisposed()||typeof m("getConfig")!="function"))try{i=_("getConfig",[])}catch{}},B=()=>n==="dead"?Promise.reject(v()):n==="ready"?Promise.resolve():h,O=()=>{for(const[E,N]of tr)N==="field"&&(g[E]=m(E))},S=E=>{const N=m(E.name);E.dispose||typeof N!="function"||n==="dead"||(E.dispose=N.apply(t,E.args))},w=()=>a.forEach(S),D=()=>{for(const E of a){try{E.dispose?.()}catch{}E.dispose=void 0}},I=()=>{O(),w()},R=()=>{o?.delete(I),o=void 0},M=(E,N)=>{const[F,...W]=N;return!Fd.includes(E)||typeof F!="function"?N:[(ee,...te)=>F(g,...te),...W]},P=(E,N)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof m(E)!="function")throw xd(E);const F={name:E,args:M(E,N)};return a.add(F),S(F),()=>{a.delete(F),F.dispose?.(),F.dispose=void 0}},L=()=>t?.container?.getInstance(l.OPTIONS_SOURCE_ID)?.get()?.content,x=()=>{const E=e.element();return E!==void 0&&typeof E!="string"?E:void 0},U=(E,N)=>{switch(N){case"event":return(...F)=>P(E,F);case"async":return(...F)=>(E==="show"&&F[0]!==void 0&&e.shown?.(F[0]),n!=="dead"&&typeof m(E)=="function"?T(E,F):B().then(()=>_(E,F)));case"queued":return(...F)=>{if(n==="dead"){if(E==="notify")return;throw v()}if(n==="pending"){c.push({name:E,args:F});return}return _(E,F)};case"sync":return(...F)=>{if(n==="dead"){if(E==="getConfig")return i;throw v()}if(typeof m(E)!="function")throw new Error(`[emailmaker] \`${E}\` is not available before the editor is ready: ${eT[E]??"await `ready` first"}`);const W=_(E,F);return E==="getConfig"&&(i=W),W};case"element":return()=>{if(typeof m(E)!="function")return x();try{return _(E,[])}catch{return x()}};case"codeErrors":return()=>n==="ready"&&typeof m(E)=="function"?_(E,[]):[];case"field":return}};for(const[E,N]of tr)g[E]=U(E,N);g.reset=E=>(E?.content!==void 0&&e.shown?.(E.content),B().then(async()=>{const N=E?.content!==void 0&&l.deepEqual(E.content,L());await _("reset",[Bd(E,y)]),N&&await _("show",[E.content])}).then(()=>g)),g.destroy=()=>{if(n==="dead")return;const E=l.createAbortError("[emailmaker] editor was destroyed before it was ready");s?.catch(()=>{}),d.forEach(N=>N(E)),A(),e.destroy()},Object.defineProperty(g,"ready",{get:()=>s,enumerable:!0,configurable:!0});const y=g;return{object:y,get state(){return n},get editor(){return t},bind:E=>{n==="dead"||t===E||(D(),R(),t=E,O(),w(),n==="pending"&&(o=E.container.getOrCreateInstance(l.LATE_SURFACE_LISTENERS_ID,()=>new Set),o.add(I)))},settle:()=>{if(n==="pending"){n="ready",R(),O(),w();for(const E of c.splice(0))try{_(E.name,E.args)}catch(N){queueMicrotask(()=>{throw N})}u()}},kill:(E,N)=>{n!=="dead"&&(A(),n="dead",r=E,c.length=0,d.forEach(F=>F(E)),R(),N?.keepSubscriptions||(D(),a.clear()),f(E))},detach:()=>{D(),a.clear()},setReady:E=>{s=E},trackCall:E=>(d.add(E),()=>d.delete(E)),hasCalls:()=>d.size>0}}var fo="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function nT(){return l.createAbortError(fo)}function jd(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===fo}function rT(e,t,n){if(typeof document>"u")return;let r=!1,s;const o=()=>{r=!0,s?.disconnect(),s=void 0},i=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(i);return}s=new MutationObserver(()=>{e.isConnected||i()});let a=e.parentNode;for(;a;)s.observe(a,{childList:!0}),a=a.parentNode}function sT(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:s}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return rT(n,()=>{n.id,o.abort(nT())},s),l.composeAbortSignals(r,o.signal)}var ho="Superseded by newer init() on the same mount element";function Ud(){return l.createAbortError(ho)}function $d(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===ho}var tn=new Map,Hd=new WeakMap,sr=new WeakMap;function oT(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function iT(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=oT(e);(n?tn.get(n):void 0)?.forEach(u=>{u.element!==e&&u.controller.abort(Ud())});const r=Hd.get(e)??new Set;t&&r.forEach(u=>{u.supersedable&&u.controller.abort(Ud())});const s=sr.get(e)??Promise.resolve();let o;const i=new Promise(u=>{o=u}),a=s.then(()=>i);sr.set(e,a),a.then(()=>{sr.get(e)===a&&sr.delete(e)});const c=new AbortController,d={element:e,controller:c,supersedable:t};if(r.add(d),Hd.set(e,r),n){const u=tn.get(n)??new Set;u.add(d),tn.set(n,u)}return{signal:c.signal,previous:s,release:()=>{o(),r.delete(d);const u=n?tn.get(n):void 0;n&&u?.delete(d)&&u.size===0&&tn.delete(n)}}}var nn=new WeakMap;function po(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function mo(e){return Object.entries(e).filter(([t,n])=>po(t,n)).map(([t])=>t).sort()}function Vd(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!po(n,r)&&(t[n]=r);return t}function go(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:nn.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},nn.set(e,r));const{current:s,trampolines:o}=r;s.clear();const i={...t};for(const a of mo(t)){s.set(a,t[a]);let c=o.get(a);c||(c=(...d)=>s.get(a)?.(...d),o.set(a,c)),i[a]=c}return r.lastOptions=t,i}function Gd(e,t){const n=e?nn.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const s=t[r];po(r,s)?n.current.set(r,s):n.current.delete(r)}}function aT(e){const t=e?nn.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((s,o)=>t.current.set(o,s)),t.lastOptions=r}}function cT(e,t,n){const r=e?nn.get(e):void 0;if(!r||!n)return!1;const s=mo(t),o=l.deepEqual(s,mo(r.lastOptions)),i=s.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!o||!i||!l.deepEqual(Vd(t),Vd(r.lastOptions))?!1:(go(e,t),!0)}var Ae=new WeakMap,ZA=0;function or(e){let t=Ae.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},Ae.set(e,t)),t}var xe=e=>e!==void 0&&e.state!=="dead";function lT(e){const t=Ae.get(e)?.shared;return xe(t)?t:void 0}function dT(e,t){or(e).shared=t}function uT(e,t){!(xe(e.shared)&&[...e.counted].some(xe))||e.warned||!t.devTools||(e.warned=!0)}function fT(e,t,n,r){const s=or(e);return s.latestCall+=1,s.releaseTimer!==void 0&&(clearTimeout(s.releaseTimer),s.releaseTimer=void 0),s.leaving.forEach(o=>o.detach()),s.leaving.clear(),n==="single"?s.shared=t:s.counted.add(t),s.options.set(t,r),s.order=[...s.order.filter(o=>o!==t&&xe(o)),t],uT(s,r),s.latestCall}function hT(e,t){return Ae.get(e)?.latestCall===t}function pT(e){const t=Ae.get(e);if(t)return t.order=t.order.filter(xe),t.order.at(-1)?.object}function rn(e,t){const n=Ae.get(e);return n?xe(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&xe(r)):!1}function mT(e,t){const n=Ae.get(e),r=n?.order.filter(s=>s!==t&&xe(s)).at(-1);return r?n?.options.get(r):void 0}function Wd(e,t){or(e).content={value:t}}function gT(e){return Ae.get(e)?.content}function vT(e,t,n,r){const s=or(e);if(s.counted.delete(t),s.options.delete(t),rn(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),s.leaving.add(t),Yd(e,r)}function Yd(e,t){const n=Ae.get(e);!n||rn(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!rn(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function _T(e,t){const n=Ae.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);Ae.delete(e)}}var ET=wt.__exportAll({FileManagerApiError:()=>bT,IntegratorSaveTimeoutError:()=>an,SaveRefusedError:()=>Oe}),bT=class Qd extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,s){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=s,Error.captureStackTrace&&Error.captureStackTrace(this,Qd)}},yT=wt.__exportAll({mapHttpStatusToErrorCode:()=>l.mapHttpStatusToErrorCode});function wT(e,t){return{...e,element:t}}function vo(){return()=>{}}function ST(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?vo():(DI(t,e.config?.styles,t),()=>{PI(t)})}function IT(e){if(!Pd()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:vo()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:vo()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=NI(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function TT(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function ir(e){try{e.destroy()}catch{}}function ar(e,...t){const n=l.ELEMENT_MAP.get(e);t.some(r=>r!==void 0&&r===n)&&l.ELEMENT_MAP.delete(e)}var AT="1.3.14";async function CT(e){Kr(),await aw(typeof __useblocks__<"u"?__useblocks__:void 0)}async function OT(e){return Kd(e).ready}function DT(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function PT(e){const t=l.ELEMENT_MAP.get(e);return t&&!(t instanceof Promise)?t:void 0}function cr(e,t,n){const r=t??PT(e);r&&(ar(e,r),ir(r)),_T(e,n)}function RT(e){const{control:t,mode:n,ref:r}=e,s=r.host;if(!s){const i=t.editor;kT(i),t.kill(ke());return}if(n==="single"){cr(s,t.editor,ke());return}const o=mT(s,t);vT(s,t,ke(),()=>cr(s,t.editor,ke())),o&&rn(s)&&Gd(s,o)}function kT(e){e&&ir(e)}function Kd(e){se(fe.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=l.composeAbortSignals(e.signal,n.signal),s=t==="single"?DT(e.element):void 0,o=s?lT(s):void 0;let i;if(o)i={control:o,mode:t,ref:{host:s}};else{const u={},f=tT({element:()=>u.host??e.element,destroy:()=>RT(i),shown:h=>{u.host&&Wd(u.host,h)}});i={control:f,mode:t,ref:u},s&&dT(s,f)}const{control:a}=i,c=a.trackCall(u=>n.abort(u)),d=BT(Bd({...e,signal:r},a.object),i).then(()=>(c(),se(fe.initEnd),a.settle(),a.object),u=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(u);const f=i.ref.host;throw f&&Yd(f,()=>cr(f,void 0,ke())),u});return a.setReady(d),a.object}function NT(e){const t=typeof e=="string"?document.querySelector(e):e;return t?pT(t):void 0}function LT(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 s=rt(e.container)?.current();r=s!==void 0&&s.get().savedVersion!==null&&s.isDirty()}catch{t=void 0}return{options:t,signal:n,email:MT(e),dirty:r}}async function MT(e){try{return await e.getEmailSnapshot()}catch{return}}function xT(e){const t=rt(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function qd(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||rn(e,n)}async function FT(e,t,n,r,s){if(r.mode==="counted"&&r.control.detach(),$d(s)||jd(s))return;const o=()=>cr(t,e,ZI(s)),{options:i}=n;if(!i||!qd(t,r)){o();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&&xT(e),qd(t,r)?l.ELEMENT_MAP.set(t,e):o()}catch{o()}}async function BT(e,t){l.throwIfAborted(e.signal);const n=new l.Disposable;let r,s,o,i,a=0;try{const c=await l.waitForElement(e.element,n,e.signal);c&&(i=c,t.ref.host=c,a=fT(c,t.control,t.mode,e));const d=sT({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),u=iT(c,{supersede:t.mode==="single"});r=u.release;const f=l.composeAbortSignals(d,u.signal);l.throwIfAborted(f),o=aT(c),Gd(c,e),await l.raceWithAbortSignal(u.previous,f),s=jT(e,c,t,f,o);const h=await l.raceWithAbortSignal(s,f);return c&&e.content!==void 0&&Wd(c,e.content),h}catch(c){throw i&&o&&hT(i,a)&&o(),c}finally{const c=r;s!==void 0&&c?s.then(c,c):c?.(),n.dispose()}}async function zd(e,t,n,r){const s=gT(t);n===void 0||r||!s||l.deepEqual(n,s.value)||await e.show(n)}async function jT(e,t,n,r,s){const{control:o}=n,i=v=>o.bind(v);l.throwIfAborted(r);let a;const c=v=>{YI();const _=JI(wT(v,t)),T=GI(_,()=>a);return{preparedOptions:T,preparedOptionsWithSignal:r!=null?{...T,signal:r}:T}};let d;if(t){const v=l.ELEMENT_MAP.get(t);if(v){let _;try{_=await v,l.throwIfAborted(r)}catch{l.throwIfAborted(r),ar(t,v),_=void 0}if(_)if(_.getElement()===t){const T=SI(t);a=T;const A=_.container.getInstance(l.OPTIONS_SOURCE_ID)?.get();if(cT(t,e,A))return i(_),r&&_.container.getInstance(l.INIT_PIPELINE_ID)?.relinkExternalSignal(r),l.ELEMENT_MAP.set(t,_),await zd(_,t,e.content,!1),_;const B=!l.deepEqual(e.content,A?.content);d=c(go(t,e));const{preparedOptions:O,preparedOptionsWithSignal:S}=d,w=T&&jI(T),D=LT(_);try{T&&uo(T,O),i(_);const I=await _.reset(TT(e,S));return l.throwIfAborted(r),l.ELEMENT_MAP.set(t,_),await zd(_,t,e.content,B),I}catch(I){if(T&&w&&uo(T,w),!Su(I))throw s(),await FT(_,t,D,n,I),I;ar(t,v,_),ir(_),l.throwIfAborted(r)}}else ar(t,v,_),ir(_)}}l.throwIfAborted(r),d??=c(go(t,e,{fresh:!0}));const{preparedOptions:u}=d,f=ST(u),h=IT(u),g=r!=null?{...h.options,signal:r}:h.options;let m;try{a=AI(g),II(t,a),uo(a,u),Fs(a).set(g),await Vs(),se(fe.coreReady),l.throwIfAborted(r),l.throwIfAborted(r),m=wI(g,a,{onInstance:i}),t&&l.ELEMENT_MAP.set(t,m);const v=await m;if(r?.aborted&&(v.destroy(),l.throwIfAborted(r)),t)if(l.ELEMENT_MAP.get(t)===m)l.ELEMENT_MAP.set(t,v);else throw v.destroy(),l.throwIfAborted(r),l.createAbortError(r?.reason);return v}catch(v){throw f(),h.cleanup(),a&&(Od(a),TI(t,a)),t&&m&&l.ELEMENT_MAP.get(t)===m&&l.ELEMENT_MAP.delete(t),v}}async function UT(e){return(await Xt()).parseAMP(e)}typeof window<"u"&&(St()&&yu(),lw(typeof __useblocks__<"u"?__useblocks__:void 0)),ve.ELEMENT_DETACHED_ABORT_MESSAGE=fo,ve.SUPERSEDED_INIT_ABORT_MESSAGE=ho,ve.create=Kd,Object.defineProperty(ve,"errors",{enumerable:!0,get:function(){return ET}}),ve.getInstance=NT,Object.defineProperty(ve,"helpers",{enumerable:!0,get:function(){return yT}}),ve.init=OT,ve.isElementDetachedError=jd,ve.isSupersededInitError=$d,ve.parseAMP=UT,ve.pluginRegistry=er,ve.preload=CT,ve.version=AT});
|
|
2196
|
+
}`;function FC(){return()=>{}}function BC(e,t){if(!of()||!e||typeof document>"u")return FC();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 s=document.createElement("style");s.setAttribute(t,"true"),s.textContent=MC,document.head?.appendChild(s),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),s.remove())}}function jC(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function UC({report:e}={}){const t=new Map,n=new Set,r=e??(s=>{});return{run(s,o){const i=t.get(s);if(i!==void 0)return i;const a=o().catch(c=>{throw n.has(s)||(n.add(s),r(c)),jC(c)||t.delete(s),c});return t.set(s,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var qo=UC();function af(){qo.clear()}rp(()=>qo.clear());var cf=new WeakMap;function zo(e){return Fi(e)}function $C(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function HC(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function GC(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 Yo=new WeakMap;function Xo(e,t){Yo.set(e,t)}function VC(e){return Yo.get(e)}function WC(e,t){return async({baseUrl:n})=>{const r=t(),s=r&&Yo.get(r)||e,o=zo(n);if(!o)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 GC(s);if(s.getAuthToken&&!a)throw HC();a&&i.set("authorization",a);const c=await Qu("/app/v1/app_init",{method:"POST",headers:i,body:new URLSearchParams,credentials:"same-origin"},o,{attemptTimeout:zs(s)||void 0});if(!c.ok)throw $C(c.status,c.statusText);return await c.json()}}function KC(e){return JSON.stringify({baseUrl:zo(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function qC(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function zC(e){return t=>qo.run(KC(t),()=>(oe("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>oe("appInit:end",{kind:"network"}))))}function YC(e,t){if(sn(e)||!e.appInit&&!zo(e.baseUrl)||!qC(e))return e;const n=e.appInit??WC(e,t);let r=cf.get(n);return r||(r=zC(n),cf.set(n,r)),{...e,appInit:r}}var lf=0;function XC(){return lf}function JC(){lf+=1,af()}var df=new WeakMap,uf=new WeakMap,QC=3e4;function ZC(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function eO(e,t){try{const n=d.decodeJwt(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+QC}function tO(e){const t=new Map,n=new Map;return async(r,s,o)=>{const i=ZC(r,s);if(o)return n.delete(i),t.delete(i),af(),e(r,s,o);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&&(oe("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,s,o)).then(l=>{const u=String(l||"").trim();return u&&n.set(i,{token:l,expiresAtMs:eO(u,Date.now())}),l}).finally(()=>{oe("authToken:end",{kind:"network"}),t.delete(i)}),t.set(i,c)),c}}function nO(e){if(sn(e))return e;const t=e.getAuthToken;if(!t)return e;let n=df.get(t);const r=XC();return(!n||uf.get(t)!==r)&&(n=tO(t),df.set(t,n),uf.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(s=>{}),{...e,getAuthToken:n}}var rO="[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 sO(e){const t=new Error(rO,{cause:e});return t.name="EditorStartFailedError",t}var oO={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function ff(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var hf=["handleLoad","handleDestroy"];function pf(e,t){let n=e;for(const r of hf){const s=e?.[r];typeof s=="function"&&(n={...n,[r]:(o,...i)=>s(t,...i)})}return n}function iO(e){let t,n="pending",r,s,o,i;const a=new Set,c=[],l=new Set;let u,f;const h=new Promise((E,L)=>{u=E,f=L});h.catch(()=>{});const g={},p=E=>t?.[E],_=()=>r??De(),v=(E,L)=>{const B=p(E);if(typeof B!="function")throw ff(E);return B.apply(t,L)},A=(E,L)=>{try{return Promise.resolve(v(E,L))}catch(B){return Promise.reject(B)}},C=()=>{const E=t?.container?.getInstance?.(d.DISPOSABLE_ID);if(!(n!=="ready"||E?.isDisposed()||typeof p("getConfig")!="function"))try{i=v("getConfig",[])}catch{}},P=()=>n==="dead"?Promise.reject(_()):n==="ready"?Promise.resolve():h,I=()=>{for(const[E,L]of Tr)L==="field"&&(g[E]=p(E))},S=E=>{const L=p(E.name);E.dispose||typeof L!="function"||n==="dead"||(E.dispose=L.apply(t,E.args))},w=()=>a.forEach(S),D=()=>{for(const E of a){try{E.dispose?.()}catch{}E.dispose=void 0}},T=()=>{I(),w()},k=()=>{o?.delete(T),o=void 0},x=(E,L)=>{const[B,...W]=L;return!hf.includes(E)||typeof B!="function"?L:[(te,...ne)=>B(g,...ne),...W]},R=(E,L)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof p(E)!="function")throw ff(E);const B={name:E,args:x(E,L)};return a.add(B),S(B),()=>{a.delete(B),B.dispose?.(),B.dispose=void 0}},M=()=>t?.container?.getInstance(d.OPTIONS_SOURCE_ID)?.get()?.content,F=()=>{const E=e.element();return E!==void 0&&typeof E!="string"?E:void 0},U=(E,L)=>{switch(L){case"event":return(...B)=>R(E,B);case"async":return(...B)=>(E==="show"&&B[0]!==void 0&&e.shown?.(B[0]),n!=="dead"&&typeof p(E)=="function"?A(E,B):P().then(()=>v(E,B)));case"queued":return(...B)=>{if(n==="dead"){if(E==="notify")return;throw _()}if(n==="pending"){c.push({name:E,args:B});return}return v(E,B)};case"sync":return(...B)=>{if(n==="dead"){if(E==="getConfig")return i;throw _()}if(typeof p(E)!="function")throw new Error(`[emailmaker] \`${E}\` is not available before the editor is ready: ${oO[E]??"await `ready` first"}`);const W=v(E,B);return E==="getConfig"&&(i=W),W};case"element":return()=>{if(typeof p(E)!="function")return F();try{return v(E,[])}catch{return F()}};case"codeErrors":return()=>n==="ready"&&typeof p(E)=="function"?v(E,[]):[];case"field":return}};for(const[E,L]of Tr)g[E]=U(E,L);g.reset=E=>(E?.content!==void 0&&e.shown?.(E.content),P().then(async()=>{const L=E?.content!==void 0&&ve(E.content,M());await v("reset",[pf(E,y)]),L&&await v("show",[E.content])}).then(()=>g)),g.destroy=()=>{if(n==="dead")return;const E=d.createAbortError("[emailmaker] editor was destroyed before it was ready");s?.catch(()=>{}),l.forEach(L=>L(E)),C(),e.destroy()},Object.defineProperty(g,"ready",{get:()=>s,enumerable:!0,configurable:!0});const y=g;return{object:y,get state(){return n},get editor(){return t},bind:E=>{n==="dead"||t===E||(D(),k(),t=E,I(),w(),n==="pending"&&(o=E.container.getOrCreateInstance(d.LATE_SURFACE_LISTENERS_ID,()=>new Set),o.add(T)))},settle:()=>{if(n==="pending"){n="ready",k(),I(),w();for(const E of c.splice(0))try{v(E.name,E.args)}catch(L){queueMicrotask(()=>{throw L})}u()}},kill:(E,L)=>{n!=="dead"&&(C(),n="dead",r=E,c.length=0,l.forEach(B=>B(E)),k(),L?.keepSubscriptions||(D(),a.clear()),f(E))},detach:()=>{D(),a.clear()},setReady:E=>{s=E},trackCall:E=>(l.add(E),()=>l.delete(E)),hasCalls:()=>l.size>0}}var Jo="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function aO(){return d.createAbortError(Jo)}function mf(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Jo}function cO(e,t,n){if(typeof document>"u")return;let r=!1,s;const o=()=>{r=!0,s?.disconnect(),s=void 0},i=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(i);return}s=new MutationObserver(()=>{e.isConnected||i()});let a=e.parentNode;for(;a;)s.observe(a,{childList:!0}),a=a.parentNode}function lO(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:s}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return cO(n,()=>{n.id,o.abort(aO())},s),On(r,o.signal)}var Qo="Superseded by newer init() on the same mount element";function gf(){return d.createAbortError(Qo)}function _f(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Qo}var bn=new Map,vf=new WeakMap,Pr=new WeakMap;function dO(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function uO(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=dO(e);(n?bn.get(n):void 0)?.forEach(u=>{u.element!==e&&u.controller.abort(gf())});const r=vf.get(e)??new Set;t&&r.forEach(u=>{u.supersedable&&u.controller.abort(gf())});const s=Pr.get(e)??Promise.resolve();let o;const i=new Promise(u=>{o=u}),a=s.then(()=>i);Pr.set(e,a),a.then(()=>{Pr.get(e)===a&&Pr.delete(e)});const c=new AbortController,l={element:e,controller:c,supersedable:t};if(r.add(l),vf.set(e,r),n){const u=bn.get(n)??new Set;u.add(l),bn.set(n,u)}return{signal:c.signal,previous:s,release:()=>{o(),r.delete(l);const u=n?bn.get(n):void 0;n&&u?.delete(l)&&u.size===0&&bn.delete(n)}}}var yn=new WeakMap;function Zo(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function ei(e){return Object.entries(e).filter(([t,n])=>Zo(t,n)).map(([t])=>t).sort()}function Ef(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!Zo(n,r)&&(t[n]=r);return t}function ti(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:yn.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},yn.set(e,r));const{current:s,trampolines:o}=r;s.clear();const i={...t};for(const a of ei(t)){s.set(a,t[a]);let c=o.get(a);c||(c=(...l)=>s.get(a)?.(...l),o.set(a,c)),i[a]=c}return r.lastOptions=t,i}function bf(e,t){const n=e?yn.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const s=t[r];Zo(r,s)?n.current.set(r,s):n.current.delete(r)}}function fO(e){const t=e?yn.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((s,o)=>t.current.set(o,s)),t.lastOptions=r}}function hO(e,t,n){const r=e?yn.get(e):void 0;if(!r||!n)return!1;const s=ei(t),o=ve(s,ei(r.lastOptions)),i=s.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!o||!i||!ve(Ef(t),Ef(r.lastOptions))?!1:(ti(e,t),!0)}var Pe=new WeakMap,f0=0;function Rr(e){let t=Pe.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},Pe.set(e,t)),t}var $e=e=>e!==void 0&&e.state!=="dead";function pO(e){const t=Pe.get(e)?.shared;return $e(t)?t:void 0}function mO(e,t){Rr(e).shared=t}function gO(e,t){!($e(e.shared)&&[...e.counted].some($e))||e.warned||!t.devTools||(e.warned=!0)}function _O(e,t,n,r){const s=Rr(e);return s.latestCall+=1,s.releaseTimer!==void 0&&(clearTimeout(s.releaseTimer),s.releaseTimer=void 0),s.leaving.forEach(o=>o.detach()),s.leaving.clear(),n==="single"?s.shared=t:s.counted.add(t),s.options.set(t,r),s.order=[...s.order.filter(o=>o!==t&&$e(o)),t],gO(s,r),s.latestCall}function vO(e,t){return Pe.get(e)?.latestCall===t}function EO(e){const t=Pe.get(e);if(t)return t.order=t.order.filter($e),t.order.at(-1)?.object}function wn(e,t){const n=Pe.get(e);return n?$e(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&$e(r)):!1}function bO(e,t){const n=Pe.get(e),r=n?.order.filter(s=>s!==t&&$e(s)).at(-1);return r?n?.options.get(r):void 0}function yf(e,t){Rr(e).content={value:t}}function yO(e){return Pe.get(e)?.content}function wO(e,t,n,r){const s=Rr(e);if(s.counted.delete(t),s.options.delete(t),wn(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),s.leaving.add(t),wf(e,r)}function wf(e,t){const n=Pe.get(e);!n||wn(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!wn(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function SO(e,t){const n=Pe.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);Pe.delete(e)}}var IO=Lt.__exportAll({FileManagerApiError:()=>AO,IntegratorSaveTimeoutError:()=>kn,SaveRefusedError:()=>Ne}),AO=class Of extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,s){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=s,Error.captureStackTrace&&Error.captureStackTrace(this,Of)}},TO=Lt.__exportAll({mapHttpStatusToErrorCode:()=>d.mapHttpStatusToErrorCode});function CO(e,t){return{...e,element:t}}function ni(){return()=>{}}function OO(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?ni():(LC(t,e.config?.styles,t),()=>{xC(t)})}function DO(e){if(!of()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:ni()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:ni()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=BC(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function PO(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function kr(e){try{e.destroy()}catch{}}function Nr(e,...t){const n=d.ELEMENT_MAP.get(e);t.some(r=>r!==void 0&&r===n)&&d.ELEMENT_MAP.delete(e)}var RO="1.3.16";async function kO(e){Rs(),await VI(typeof __useblocks__<"u"?__useblocks__:void 0)}async function NO(e){return Sf(e).ready}function LO(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function xO(e){const t=d.ELEMENT_MAP.get(e);return t&&!(t instanceof Promise)?t:void 0}function Lr(e,t,n){const r=t??xO(e);r&&(Nr(e,r),kr(r)),SO(e,n)}function MO(e){const{control:t,mode:n,ref:r}=e,s=r.host;if(!s){const i=t.editor;FO(i),t.kill(De());return}if(n==="single"){Lr(s,t.editor,De());return}const o=bO(s,t);wO(s,t,De(),()=>Lr(s,t.editor,De())),o&&wn(s)&&bf(s,o)}function FO(e){e&&kr(e)}function Sf(e){oe(he.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=On(e.signal,n.signal),s=t==="single"?LO(e.element):void 0,o=s?pO(s):void 0;let i;if(o)i={control:o,mode:t,ref:{host:s}};else{const u={},f=iO({element:()=>u.host??e.element,destroy:()=>MO(i),shown:h=>{u.host&&yf(u.host,h)}});i={control:f,mode:t,ref:u},s&&mO(s,f)}const{control:a}=i,c=a.trackCall(u=>n.abort(u)),l=GO(pf({...e,signal:r},a.object),i).then(()=>(c(),oe(he.initEnd),a.settle(),a.object),u=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(u);const f=i.ref.host;throw f&&wf(f,()=>Lr(f,void 0,De())),u});return a.setReady(l),a.object}function BO(e){const t=typeof e=="string"?document.querySelector(e):e;return t?EO(t):void 0}function jO(e){let t,n,r=!1;try{t=e.container.getInstance(d.OPTIONS_SOURCE_ID)?.get(),n=e.container.getInstance(d.INIT_PIPELINE_ID)?.externalSignal;const s=mt(e.container)?.current();r=s!==void 0&&s.get().savedVersion!==null&&s.isDirty()}catch{t=void 0}return{options:t,signal:n,email:UO(e),dirty:r}}async function UO(e){try{return await e.getEmailSnapshot()}catch{return}}function $O(e){const t=mt(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function If(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||wn(e,n)}async function HO(e,t,n,r,s){if(r.mode==="counted"&&r.control.detach(),_f(s)||mf(s))return;const o=()=>Lr(t,e,sO(s)),{options:i}=n;if(!i||!If(t,r)){o();return}const a=await n.email,c=a&&(i.content!==void 0||a.id!==void 0)?a:void 0,l=typeof i.content=="object"&&"email"in i.content?i.content:void 0;try{await e.reset({...i,signal:i.signal??n.signal,content:c?{...l,email:c}:i.content}),n.dirty&&c&&$O(e),If(t,r)?d.ELEMENT_MAP.set(t,e):o()}catch{o()}}async function GO(e,t){d.throwIfAborted(e.signal);const n=new d.Disposable;let r,s,o,i,a=0;try{const c=await d.waitForElement(e.element,n,e.signal);c&&(i=c,t.ref.host=c,a=_O(c,t.control,t.mode,e));const l=lO({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),u=uO(c,{supersede:t.mode==="single"});r=u.release;const f=On(l,u.signal);d.throwIfAborted(f),o=fO(c),bf(c,e),await d.raceWithAbortSignal(u.previous,f),s=VO(e,c,t,f,o);const h=await d.raceWithAbortSignal(s,f);return c&&e.content!==void 0&&yf(c,e.content),h}catch(c){throw i&&o&&vO(i,a)&&o(),c}finally{const c=r;s!==void 0&&c?s.then(c,c):c?.(),n.dispose()}}async function Af(e,t,n,r){const s=yO(t);n===void 0||r||!s||ve(n,s.value)||await e.show(n)}async function VO(e,t,n,r,s){const{control:o}=n,i=_=>o.bind(_);d.throwIfAborted(r);let a;const c=_=>{JC();const v=nO(CO(_,t)),A=YC(v,()=>a);return{preparedOptions:A,preparedOptionsWithSignal:r!=null?{...A,signal:r}:A}};let l;if(t){const _=d.ELEMENT_MAP.get(t);if(_){let v;try{v=await _,d.throwIfAborted(r)}catch{d.throwIfAborted(r),Nr(t,_),v=void 0}if(v)if(v.getElement()===t){const A=OC(t);a=A;const C=v.container.getInstance(d.OPTIONS_SOURCE_ID)?.get();if(hO(t,e,C))return i(v),r&&v.container.getInstance(d.INIT_PIPELINE_ID)?.relinkExternalSignal(r),d.ELEMENT_MAP.set(t,v),await Af(v,t,e.content,!1),v;const P=!ve(e.content,C?.content);l=c(ti(t,e));const{preparedOptions:I,preparedOptionsWithSignal:S}=l,w=A&&VC(A),D=jO(v);try{A&&Xo(A,I),i(v);const T=await v.reset(PO(e,S));return d.throwIfAborted(r),d.ELEMENT_MAP.set(t,v),await Af(v,t,e.content,P),T}catch(T){if(A&&w&&Xo(A,w),!Zf(T))throw s(),await HO(v,t,D,n,T),T;Nr(t,_,v),kr(v),d.throwIfAborted(r)}}else Nr(t,_,v),kr(v)}}d.throwIfAborted(r),l??=c(ti(t,e,{fresh:!0}));const{preparedOptions:u}=l,f=OO(u),h=DO(u),g=r!=null?{...h.options,signal:r}:h.options;let p;try{a=RC(g),DC(t,a),Xo(a,u),So(a).set(g),await Co(),oe(he.coreReady),d.throwIfAborted(r),d.throwIfAborted(r),p=CC(g,a,{onInstance:i}),t&&d.ELEMENT_MAP.set(t,p);const _=await p;if(r?.aborted&&(_.destroy(),d.throwIfAborted(r)),t)if(d.ELEMENT_MAP.get(t)===p)d.ELEMENT_MAP.set(t,_);else throw _.destroy(),d.throwIfAborted(r),d.createAbortError(r?.reason);return _}catch(_){throw f(),h.cleanup(),a&&(rf(a),PC(t,a)),t&&p&&d.ELEMENT_MAP.get(t)===p&&d.ELEMENT_MAP.delete(t),_}}async function WO(e){return(await mn()).parseAMP(e)}typeof window<"u"&&(xt()&&Jf(),KI(typeof __useblocks__<"u"?__useblocks__:void 0)),be.ELEMENT_DETACHED_ABORT_MESSAGE=Jo,be.SUPERSEDED_INIT_ABORT_MESSAGE=Qo,be.create=Sf,Object.defineProperty(be,"errors",{enumerable:!0,get:function(){return IO}}),be.getInstance=BO,Object.defineProperty(be,"helpers",{enumerable:!0,get:function(){return TO}}),be.init=NO,be.isElementDetachedError=mf,be.isSupersededInitError=_f,be.parseAMP=WO,be.pluginRegistry=Ar,be.preload=kO,be.version=RO});
|
|
2197
2197
|
|
|
2198
2198
|
|
|
2199
2199
|
// Возвращаем API из entry модуля
|
|
2200
2200
|
return __useblocks__.syncRequire("useblocks.js");
|
|
2201
2201
|
});
|
|
2202
2202
|
|
|
2203
|
-
__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/160bf060.js":[],"static/core/
|
|
2203
|
+
__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/160bf060.js":[],"static/core/16612c9f.js":["static/core/3e1acefc.js"],"static/core/1e160f23.js":["static/core/66853555.js"],"static/core/1ed86ed3.js":[],"static/core/23e22cd2.js":[],"static/core/25562e5d.js":[],"static/core/2633e871.js":[],"static/core/2740933f.js":["static/core/beebdf4d.js"],"static/core/2a8b14c0.js":[],"static/core/2ae78ac6.js":["static/core/b6418818.js"],"static/core/31e587ab.js":["static/core/beebdf4d.js","static/core/b6418818.js","static/core/e94e24b5.js"],"static/core/3454ca99.js":[],"static/core/36071466.js":["static/core/d6c7eb44.js","__delivery__/libs"],"static/core/3cd95e0a.js":["static/core/b492a9b0.js","static/core/3e80379e.js","static/core/e98b0c61.js","static/core/c03fc17e.js","__delivery__/libs"],"static/core/3e1acefc.js":[],"static/core/3e80379e.js":["static/core/b492a9b0.js","__delivery__/libs"],"static/core/3f3feb86.js":[],"static/core/3fd50a29.js":[],"static/core/48da14fd.js":[],"static/core/4adb5ee9.js":[],"static/core/4e07805d.js":["static/core/9da6c313.js","static/core/e81b521f.js","static/core/f0f20c47.js","static/core/66853555.js","static/core/d6c7eb44.js","__delivery__/libs"],"static/core/4f8847e6.js":[],"static/core/519dfcc7.js":["static/core/3e80379e.js","static/core/4e07805d.js","__delivery__/libs","static/core/b492a9b0.js"],"static/core/53c22855.js":["static/core/f674f125.js"],"static/core/552f7d30.js":["static/core/b492a9b0.js","static/core/f674f125.js","__delivery__/libs"],"static/core/5de3cd2c.js":["static/core/e81b521f.js"],"static/core/6561b34a.js":[],"static/core/66853555.js":[],"static/core/69688fad.js":[],"static/core/713de1e1.js":["static/core/9da6c313.js"],"static/core/7ae6cf52.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/7b850506.js":[],"static/core/80907514.js":["static/core/f0f20c47.js"],"static/core/86f73ee9.js":["static/core/3e1acefc.js","static/core/ec079650.js","static/core/1e160f23.js"],"static/core/8b9a4f49.js":[],"static/core/9348ac64.js":[],"static/core/9da6c313.js":[],"static/core/a004861a.js":[],"static/core/aeec5659.js":[],"static/core/b492a9b0.js":["static/core/e7620593.js","static/core/f674f125.js","__delivery__/libs"],"static/core/b6418818.js":[],"static/core/beebdf4d.js":[],"static/core/c03fc17e.js":["static/core/9da6c313.js","static/core/4e07805d.js","__delivery__/libs"],"static/core/c3344bbc.js":[],"static/core/c3544cf4.js":["static/core/1e160f23.js"],"static/core/cc4458d8.js":[],"static/core/d551e71d.js":[],"static/core/d5be6857.js":[],"static/core/d6c7eb44.js":["__delivery__/libs"],"static/core/d9ff5568.js":[],"static/core/dcc37768.js":[],"static/core/e2710fd3.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/e7620593.js":[],"static/core/e7c7173a.js":["static/core/66853555.js","static/core/ec079650.js","static/core/1e160f23.js"],"static/core/e81b521f.js":[],"static/core/e94e24b5.js":["static/core/b6418818.js"],"static/core/e98b0c61.js":["static/core/b492a9b0.js","__delivery__/libs"],"static/core/ec079650.js":[],"static/core/ecc4d431.js":[],"static/core/f0f20c47.js":[],"static/core/f5d42c73.js":[],"static/core/f674f125.js":[],"static/core/f97efb0a.js":[],"static/core/fb2fe2db.js":[],"static/core/ff0af9ff.js":[],"static/monaco/editor.api-C9c1WLns.js":[],"monaco":["static/monaco/editor.api-C9c1WLns.js","static/monaco/lspLanguageFeatures-DY3n8M13.js"],"static/monaco/lspLanguageFeatures-DY3n8M13.js":["static/monaco/editor.api-C9c1WLns.js"],"useblocks.js":[],"static/umd/58ef5318.js":[],"static/umd/6639d610.js":["static/umd/b11043e6.js"],"static/umd/b11043e6.js":[],"static/umd/d786efbb.js":[]},"bundles":{"static/core/4e07805d.js":["static/core/50b377c7.js","static/core/523ea2ec.js","static/core/88cd6d99.js"],"static/core/2740933f.js":["static/core/a71c4cd8.js"],"static/core/552f7d30.js":["static/core/ac633841.js"],"static/core/c03fc17e.js":["static/core/a73da823.js"],"static/core/519dfcc7.js":["static/core/b1cc9ee5.js"],"core":["static/core/2ff39ddf.js","static/core/d3e42889.js","static/core/3fb28e82.js","static/core/e7f792fb.js","static/core/b6bccb63.js"]}});
|