useblocks 1.1.85-dev.6 → 1.1.85-dev.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +17 -3
  2. package/iframe/.vite/manifest.json +4 -4
  3. package/iframe/js/{discussHandlers.Ced_gtP0.js → discussHandlers.BuuVtU3Y.js} +5 -5
  4. package/iframe/js/iframe-eblock.body.js +1 -1
  5. package/iframe/js/iframe-eblock.js +1 -1
  6. package/iframe/js/iframe.body.js +2 -2
  7. package/iframe/js/iframe.js +1 -1
  8. package/node_modules/useblocks-ui-kit/es/components/Custom/FormPanel/FormSection/index.js +1 -1
  9. package/node_modules/useblocks-ui-kit/es/components/Custom/Inputs/ColorPickerInput/index.js +1 -1
  10. package/node_modules/useblocks-ui-kit/es/components/Custom/Inputs/ControlFontFamily/index.js +1 -1
  11. package/node_modules/useblocks-ui-kit/es/components/Custom/Inputs/InputSelect/index.js +34 -31
  12. package/node_modules/useblocks-ui-kit/es/components/Custom/PanelForm/index.js +1 -1
  13. package/node_modules/useblocks-ui-kit/es/components/DataDisplay/Card/index.js +1 -1
  14. package/node_modules/useblocks-ui-kit/es/components/DataDisplay/Skeleton/index.js +1 -1
  15. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Cascader/index.js +1 -1
  16. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Checkbox/index.js +1 -1
  17. package/node_modules/useblocks-ui-kit/es/components/DataEntry/ColorPicker/index.js +1 -1
  18. package/node_modules/useblocks-ui-kit/es/components/DataEntry/DatePicker/index.js +1 -1
  19. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Form/index.js +1 -1
  20. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Input/index.js +1 -1
  21. package/node_modules/useblocks-ui-kit/es/components/DataEntry/InputNumber/index.js +1 -1
  22. package/node_modules/useblocks-ui-kit/es/components/DataEntry/InputOTP/index.js +1 -1
  23. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Password/index.js +1 -1
  24. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Radio/index.js +1 -1
  25. package/node_modules/useblocks-ui-kit/es/components/DataEntry/SearchInput/index.js +1 -1
  26. package/node_modules/useblocks-ui-kit/es/components/DataEntry/Switch/index.js +2 -2
  27. package/node_modules/useblocks-ui-kit/es/components/DataEntry/TextArea/index.js +1 -1
  28. package/node_modules/useblocks-ui-kit/es/components/Feedback/Alert/index.js +1 -1
  29. package/node_modules/useblocks-ui-kit/es/components/Feedback/Popconfirm/index.js +1 -1
  30. package/node_modules/useblocks-ui-kit/es/components/Feedback/Spin/index.js +1 -1
  31. package/node_modules/useblocks-ui-kit/es/components/Feedback/Tooltip/index.js +1 -1
  32. package/node_modules/useblocks-ui-kit/es/components/General/Button/index.js +1 -1
  33. package/node_modules/useblocks-ui-kit/es/components/Layout/Divider/index.js +1 -1
  34. package/node_modules/useblocks-ui-kit/es/components/Layout/Row/index.js +1 -1
  35. package/node_modules/useblocks-ui-kit/es/components/Layout/Space/index.js +1 -1
  36. package/node_modules/useblocks-ui-kit/es/components/Navigation/FloatButton/index.js +1 -1
  37. package/node_modules/useblocks-ui-kit/es/components/Navigation/Segmented/index.js +1 -1
  38. package/node_modules/useblocks-ui-kit/es/components/Navigation/Tabs/index.js +1 -1
  39. package/node_modules/useblocks-ui-kit/package.json +1 -1
  40. package/package.json +2 -2
  41. package/runtime/react/index.js +1 -1
  42. package/static/core/{9600caf9.js → 06d19668.js} +2 -2
  43. package/static/core/{51a46897.js → 13c7b13a.js} +1 -1
  44. package/static/core/{fdfb1e94.js → 1afe0f9c.js} +1 -1
  45. package/static/core/{8035d07f.js → 28160edc.js} +1 -1
  46. package/static/core/{6a939bac.js → 3d7934fb.js} +1 -1
  47. package/static/core/{6741eb70.js → 3df10afa.js} +8 -8
  48. package/static/core/{e2699a48.js → 41028939.js} +1 -1
  49. package/static/core/{7f91ed03.js → 45eb9af1.js} +1 -1
  50. package/static/core/{60f7aa8d.js → 48a8ba9d.js} +1 -1
  51. package/static/core/{740a4f32.js → 49a8dc9c.js} +1 -1
  52. package/static/core/{284b592e.js → 59cfe4a0.js} +1 -1
  53. package/static/core/{ec4827f1.js → 778aee63.js} +1 -1
  54. package/static/core/{c28968c1.js → 799f4d8e.js} +1 -1
  55. package/static/core/{d0eece8b.js → 7c047ede.js} +1 -1
  56. package/static/core/{9ea82ab5.js → 982730aa.js} +1 -1
  57. package/static/core/{23f020c5.js → a46eae76.js} +1 -1
  58. package/static/core/{fc390885.js → b165db74.js} +1 -1
  59. package/static/core/{991b35ff.js → cb42ad65.js} +1 -1
  60. package/static/core/{7d627bff.js → db82c42b.js} +1 -1
  61. package/static/core/{1bdeb37f.js → df189a9d.js} +1 -1
  62. package/static/core/{74c1d64b.js → f1478faf.js} +1 -1
  63. package/static/core/{6ff64eea.js → f1498d3c.js} +1 -1
  64. package/static/core/{b6c5e3be.js → f8d889a1.js} +2 -2
  65. package/static/core/{3a252a3c.js → fa60c7fb.js} +1 -1
  66. package/static/core/{d2bb1c0d.js → ff43365e.js} +1 -1
  67. package/static/esm/349f9e2c.js +1 -0
  68. package/static/umd-runtime/runtime.js +1 -1
  69. package/static/umd-runtime/ui-kit.js +2 -2
  70. package/{useblocks-core.d62ebebc.js → useblocks-core.ee20cf1c.js} +42 -42
  71. package/useblocks-esm.js +10 -10
  72. package/{useblocks-po.d62ebebc.js → useblocks-po.ee20cf1c.js} +1 -1
  73. package/useblocks.d.ts +33 -6
  74. package/useblocks.js +12 -12
  75. package/vite/index.cjs +38 -0
  76. package/vite/index.js +38 -0
  77. package/static/esm/ff1698e6.js +0 -1
  78. /package/iframe/{iframe-eblock.d62ebebc.html → iframe-eblock.ee20cf1c.html} +0 -0
  79. /package/iframe/{iframe.d62ebebc.html → iframe.ee20cf1c.html} +0 -0
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.d62ebebc.js","monaco":"static/monaco/index.js","po":"useblocks-po.d62ebebc.js"} });
1017
+ __amdEnv.require.config({ baseUrl: "./", paths: {"core":"useblocks-core.ee20cf1c.js","monaco":"static/monaco/index.js","po":"useblocks-po.ee20cf1c.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.1.85-dev.6";
1365
+ ns.version = "1.1.85-dev.8";
1366
1366
  }
1367
1367
 
1368
1368
  var modules = ns.modules = Object.create(null);
@@ -2072,17 +2072,17 @@ if (typeof ns.define === 'function') {
2072
2072
  })();
2073
2073
 
2074
2074
 
2075
- __useblocks__.define("static/umd/add4df98.js",["require","exports","module"],function(bn,u,Dn){var I=class ct{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof ct&&t.addDispose(()=>{this.removeDisposable(t)}),t}addDispose(t){this.addDisposable({dispose:t})}removeDisposable(t){const r=this._inner.indexOf(t);r>=0&&this._inner.splice(r,1)}isDisposed(){return this._isDisposed}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(const t of[...this._inner])t.dispose()}}};function M(e){return`service_container_${e}`}var y=new Set,H;function ut(){if(!H)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,se.prototype.getInstanceAsync),e.stack}function V(e){y.delete(e)&&H?.end(e)}var se=class oe extends I{_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 I){return n.addDisposable(this.onInject(i=>{t===i&&(n.dispose(),r(this.getInstance(i)))})),this._parent&&n.addDisposable(this._parent._onInject(t,r,n)),this.addDisposable(n),n}getInstance(t,r=!0){const n=this._find(t,r);if(typeof n=="function")return n()}getOrCreateInstance(t,r){const n=this._find(t);if(typeof n=="function")return n();const i=r(this);return this.inject(t,i),i}getInstanceAsync(t){const r=this._find(t);if(typeof r=="function")return Promise.resolve(r());const n=ut();return new Promise((i,o)=>{const s={id:String(t),startedAt:Date.now(),origin:n,container:this,reject:o};y.add(s),H?.start(s),this._onInject(t,()=>{V(s),i(this.getInstance(t))})})}failPendingWaits(t){for(const r of Array.from(y))r.container===this&&(V(r),r.reject(t))}pendingWaits(){return[...y].filter(t=>t.container===this)}addService(t,r){const n=M(t);this.injectFactory(n,(o,s=[])=>s.indexOf(r)<0?[...s,r]:s);const i=new I;return i.addDispose(()=>{this.injectFactory(n,(o,s=[])=>s.filter(a=>a!==r))}),i}addServiceFactory(t,r,n){const i=M(t);let o;this.injectFactory(i,(a,c=[])=>(o=r(a,o),o===void 0?c:c.indexOf(o)<0?[...c,o]:c),n);const s=new I;return s.addDispose(()=>{this.injectFactory(i,(a,c=[])=>o===void 0?c:c.filter(_=>_!==o))}),s}getServices(t){const r=M(t);return[...this.getInstance(r,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new oe(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const r=this._parent?.getOrCreateIsolatedContainer(t);return new oe(r)})}remove(t){const r=this._injections;delete r[String(t)]}injectListenerCount(){return this._injectCallbacks.length}dispose(){for(const t of Array.from(y))t.container===this&&V(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function $(e){return e.startsWith("__")?e:`__${e}__`}function _t(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=$(e),r=globalThis;return r[t]??={}}function lt(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function dt(e){if(e)return $(e);const t="useblocks".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return $(t)}function ae(e){const t=dt(e),r=_t(t);if(lt(r.container))return r.container;const n=new se(null);return r.container=n,n}function ft(e){return ae(e)}function Et(){let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let n=Math.random()*16;return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),(r==="x"?n:n&3|8).toString(16)})}function ce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Et()}function f(e=ce()){return e}function ue(){return"umd".trim()||"unknown"}function pt(e){if(typeof globalThis>"u")return;const t=ue(),r=globalThis[e]??{};globalThis[e]=r;const n=r.__diagnostics??={},i=n.diModuleEval??={evalCount:0,records:[]};i.records.push({buildSource:t,timestamp:Date.now(),stack:new Error().stack}),i.evalCount+=1}function ht(){const e="useblocks".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function Ot(e,t){if(pt(t),typeof globalThis>"u")return e;const r=ue(),n=globalThis,i=n[t]=n[t]||{},o=i.__diagnostics=i.__diagnostics||{},s=o.dependencyResolver=o.dependencyResolver||{entries:[]},a={container:e,source:"packages/runtime-core/di/index.ts",buildSource:r,timestamp:Date.now(),stack:new Error().stack};return s.entries.push(a),e}var j;function At(){if(j)return j;const e=ht();return j=Ot(ae(e),e),j}var W=new Proxy({},{get(e,t,r){const n=At(),i=Reflect.get(n,t,r);return typeof i=="function"?i.bind(n):i}});function gt(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}function S(e){if(e instanceof DOMException&&e.name==="AbortError")return e;const t=e===void 0?"The operation was aborted.":typeof e=="string"?e:e instanceof Error?e.message:String(e);return new DOMException(t,"AbortError")}function q(e){if(e?.aborted)throw S(e.reason)}function It(e,t){return t?(t.aborted&&e.catch(()=>{}),q(t),new Promise((r,n)=>{const i=()=>{o(),n(S(t.reason))},o=()=>{t.removeEventListener("abort",i)};t.addEventListener("abort",i),e.then(s=>{o(),r(s)},s=>{o(),n(s)})})):e}var _e=class extends I{_options;_listeners=[];constructor(e={}){super(),this._options=e}getListeners(e){return this._listeners.flatMap(([t])=>typeof t=="function"?t:t.getListeners(e))}hasListeners(){for(const[e]of this._listeners){if(typeof e=="function")return!0;const t=e;if(typeof t.hasListeners=="function"){if(t.hasListeners())return!0;continue}return!0}return!1}_addListener(e,t=0,r){if(this.isDisposed())return{dispose:()=>{}};const n=this._listeners,i=this._options;r&&typeof e=="function"&&(e=e.bind(r));const o=n.findIndex(([,a])=>a<t),s=[e,t];return n.splice(o>=0?o:n.length,0,s),n.length===1&&i.onFirstListenerAdd&&i.onFirstListenerAdd(),{dispose:()=>{const a=n.indexOf(s);a>=0&&(n.splice(a,1),!n.length&&i.onLastListenerRemove&&i.onLastListenerRemove())}}}on=this._addListener.bind(this);event=this._addListener.bind(this);once=(e,t=0,r)=>{const n=this._addListener((...i)=>(n?.dispose(),r?e.call(r,...i):e(...i)),t);return n};un=e=>{const t=this._listeners.findIndex(([r])=>r===e);t>=0&&(this._listeners.splice(t,1),this._listeners.length===0&&this._options.onLastListenerRemove&&this._options.onLastListenerRemove())};dispose(){this._listeners.splice(0,this._listeners.length),this._options.onLastListenerRemove&&this._options.onLastListenerRemove(),super.dispose()}},b=class extends _e{execute(e,t){for(const r of t)try{r(...e)}catch{}}fire(...e){if(!this.isDisposed()){const t=this.execute(e,this.getListeners(e));return t===void 0?void 0:t}}},mt=class extends b{execute([e],t){for(const r of t)try{r(e)}catch{}}},Tt=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)}},B=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 St(e,t=0){const r=new _e,n=e(r,t);return n&&r.addDisposable(n),r.event}function bt(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 Dt(e,t=0,r=0){const n=new b;let i,o;const s=e((...a)=>{o=a,i||(i=setTimeout(()=>{o&&n.fire(...o),i=void 0},t))},r);return s&&n.addDisposable(s),n.event}function Nt(e,t){return e.getOrCreateInstance(t,()=>new B)}function d(e){return f(e)}var K;(function(e){e.BEFORE_SAVE_EMAIL=d("events.BEFORE_SAVE_EMAIL"),e.ON_SAVEBUTTON_CLICK_ID=d("events.ON_SAVEBUTTON_CLICK_ID"),e.ON_NEXTBUTTON_CLICK_ID=d("events.ON_NEXTBUTTON_CLICK_ID"),e.ON_PREVIOUSBUTTON_CLICK_ID=d("events.ON_PREVIOUSBUTTON_CLICK_ID"),e.ON_DOCUMENT_SESSION_CHANGE=d("events.ON_DOCUMENT_SESSION_CHANGE"),e.WILL_EMAIL_INIT_ID=d("events.WILL_EMAIL_INIT_ID"),e.ON_EMAIL_INIT_ID=d("events.ON_EMAIL_INIT_ID"),e.ON_BLOCK_INIT_ID=d("events.ON_BLOCK_INIT_ID"),e.ON_CONTENT_CHANGED_ID=d("events.ON_CONTENT_CHANGED_ID"),e.ON_PREHEADER_CHANGED_ID=d("events.ON_PREHEADER_CHANGED_ID"),e.ON_SUBJECT_CHANGED_ID=d("events.ON_SUBJECT_CHANGED_ID"),e.ON_EMAIL_CHANGED_ID=d("events.ON_EMAIL_CHANGED_ID"),e.ON_HEADER_APPLIED_ID=d("events.ON_HEADER_APPLIED_ID"),e.ON_BLOCK_CHANGED_ID=d("events.ON_BLOCK_CHANGED_ID"),e.ON_CHUNKS_LOADED=d("events.ON_CHUNKS_LOADED"),e.ON_SEND_TESTEMAIL_ID=d("events.ON_SEND_TESTEMAIL_ID"),e.ON_SEND_LIVEPREVIEW_ID=d("events.ON_SEND_LIVEPREVIEW_ID"),e.ON_SHARE_ID=d("events.ON_SHARE_ID"),e.ON_SHOW_PREVIEW_ID=d("events.ON_SHOW_PREVIEW_ID"),e.ON_EMAIL_CLONE_ID=d("events.ON_EMAIL_CLONE_ID"),e.ON_SEND_EMAIL_MODAL_ID=d("events.ON_SEND_EMAIL_MODAL_ID"),e.ON_NOTIFICATION=d("events.ON_NOTIFICATION"),e.READ_LOCALE=d("events.READ_LOCALE"),e.ON_TRANSLATE_ID=d("events.ON_TRANSLATE_ID"),e.ON_CODE_VALIDATE_ID=d("events.ON_CODE_VALIDATE_ID"),e.UPLOAD_EVENT_ID=d("events.UPLOAD_EVENT_ID"),e.PROXY_URL_EVENT_ID=d("events.PROXY_URL_EVENT_ID"),e.FILE_PROXY_EVENT_ID=d("events.FILE_PROXY_EVENT_ID"),e.ON_LIMIT_ID=d("events.ON_LIMIT_ID"),e.ON_BROWSER_EXTENSION_DETECTED_ID=d("events.ON_BROWSER_EXTENSION_DETECTED_ID"),e.ON_LAYOUT_CONVERT_REQUEST_ID=d("events.ON_LAYOUT_CONVERT_REQUEST_ID"),e.ON_BROWSER_TRANSLATE_DETECTED_ID=d("events.ON_BROWSER_TRANSLATE_DETECTED_ID"),e.AI_TEXT_REQUEST_ID=d("events.AI_TEXT_REQUEST_ID"),e.AI_IMAGE_REQUEST_ID=d("events.AI_IMAGE_REQUEST_ID"),e.AI_TEXT_PROGRESS_ID=d("events.AI_TEXT_PROGRESS_ID"),e.AI_IMAGE_PROGRESS_ID=d("events.AI_IMAGE_PROGRESS_ID"),e.AI_TEXT_STREAM_ID=d("events.AI_TEXT_STREAM_ID")})(K||(K={}));function Pt(e,t){return e.getOrCreateInstance(t,()=>new B).event}function yt(e,t){return e.getOrCreateInstance(t,()=>new B)}var Ct=f("plugin.app"),Lt=f("plugin.disposable"),Rt=f("InitPipelineContext"),vt=f("plugin.instance"),wt=f("plugin.lateSurfaceListeners"),le=f("plugin.optionsSource"),Mt=f("plugin.store"),de=f("ConfigSource"),jt=f("plugin.standalone.project"),fe=f("plugin.standalone.bootstrapToken"),Nn=f("plugin.element"),Ee=f("plugin.securityModule"),Bt=f("plugin.standalone.activated"),xt=f("plugin.standalone.fileProxyRegistered"),z=f("plugin.jwt.token"),C=f("plugin.jwt.error"),Ft=f("PluginCollection"),kt=d("APP_LOAD_EVENT"),Ut=d("CONFIG_CHANGED_EVENT"),Gt=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),Xt=class{baseUrl="https://api.emailmaker.ru/wp-json";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(r=>this.encodeQueryParam(t,r)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(r=>typeof t[r]<"u").map(r=>Array.isArray(t[r])?this.addArrayQueryParam(t,r):this.addQueryParam(t,r)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce((t,r)=>{const n=e[r];return t.append(r,n instanceof Blob?n:typeof n=="object"&&n!==null?JSON.stringify(n):`${n}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const r=this.abortControllers.get(e);return r?r.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};async request({body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:a,extraQuery:c,proxyHandler:_,...l}){const E=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},h=this.mergeRequestParams(l,E);c&&(i=i?{...i,...c}:c);const p=i&&this.toQueryString(i),g=this.contentFormatters[n||"application/json"],O=o||h.format,G=`${s||this.baseUrl||""}${r}${p?`?${p}`:""}`,Tn=_?_(G,{body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:a,extraQuery:c,proxyHandler:_,...l}):G,st=new Request(Tn,{...h,headers:{...h.headers||{},...n&&n!=="multipart/form-data"?{"Content-Type":n}:{}},signal:(a?this.createAbortSignal(a):h.signal)||null,body:typeof e>"u"||e===null?null:g(e)});return this.customFetch(st).then(async at=>{const m=at;m.data=null,m.error=null,m.meta={request:st,response:m};const Sn=O?await at[O]().then(X=>(m.ok?m.data=X:m.error={data:X},m)).catch(X=>(m.error=X,m)):m;return a&&this.abortControllers.delete(a),Sn})}},Ht=f("prewarm.networkActivity");function Vt(){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 $t(e){return e.getOrCreateInstance(Ht,()=>Vt())}var pe=Symbol("rest.publicRequest"),x=f("rest.requestHandler"),Wt=f("rest.responseHandler"),J=f("rest.customFetch"),Y=f("rest_transport"),qt=e=>{e.inject(J,{execute:async(t,r={})=>{const n=e.getServices(x),i={public:r[pe]===!0},o=$t(e).begin();try{let s=t instanceof Request?t:new Request(t,r);for(const _ of n){const l=await _.execute(s,i);l instanceof Request&&(s=l)}let a=await fetch(s);const c=e.getServices(Wt);for(const _ of c)a=await _.execute(a);return a}finally{o()}}})};function Kt(e,t){const r=e.getInstance(Y);if(!r)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(n=>new n(r)))}function zt(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 Jt(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 Yt(e){return e}function Qt(e){return e&&typeof e=="object"}function he(e,t){return e&&typeof e=="object"&&e.operationId===t}var T="INIT_MESSAGE",Oe="em:port-ready",Zt="em:window-drained",Q="";function Ae(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var er=class extends I{_listeners=Object.create(null);addListenerAsync=(e,t,r=0,n)=>{const i=this._listeners[e]||(this._listeners[e]=[]);n&&typeof t=="function"&&(t=t.bind(n));const o=i.findIndex(([a,c])=>r<=c),s=[t,r];return this.isDisposed()||i.splice(o>=0?o:i.length,0,s),{dispose(){const a=i.indexOf(s);a>=0&&i.splice(a,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const r=this._listeners[e]||(this._listeners[e]=[]);let n;for(let i=0;i<r.length;i++){const o=r[i][0],s=n;n=a=>o(a,s)}if(n)return n(t)}};addListener=(e,t,r=0)=>this.addListenerAsync(e,(n,i)=>{try{t(n)}catch{}return i&&i(n)},r)},tr=class extends I{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_inited=!1;_emitter=this.addDisposable(new er);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;constructor(e,t){super(),this._singleton=t,this._transport=zt({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(T,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(T))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,r=t.data,n=t.source,i=r?.port===!0?t.ports?.[0]:void 0,o=!this._isPortSource(t.source);if(o&&n&&r?.operationId==="em:window-drained"){this._drained.add(n);return}if(!(o&&n&&this._drained.has(n))){if(n&&n!==this._target&&this._greeted.has(n)&&he(r,T)){this._greeted.delete(n),this._handshaken.add(n),this._postMessage(n,{operationId:T,data:{}}),i&&this.usePort(i,!0,n);return}if(Qt(r)&&(t.source===this.target||this._isCurrentPort(t.source))||this._singleton&&he(r,T)){if(i){const _=this._target;Promise.resolve().then(()=>this.usePort(i,!0,_))}const s=this._emitter.fireAsync(r.operationId||Q,r.operationId===void 0?t:r.data),a=r.result,c=r.error;a&&c&&Promise.resolve(s).then(_=>this._sendMessage(a,_),_=>this._sendMessage(c,_))}}};setTarget(e){if(this._target!==e){if(this._target=e,!e){this._inited=!1;return}if(this._handshaken.has(e)){this._inited=!0,this._emitter.fireAsync(T,void 0);return}this._inited=!1,this._postMessage(e,{operationId:T,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:T,data:{},port:!0},[t])}setOutgoingFilter(e){return this._outgoingFilter=e,()=>{this._outgoingFilter===e&&(this._outgoingFilter=void 0)}}greet(e){this._handshaken.has(e)||this._greeted.has(e)||this._target===e||(this._greeted.add(e),this._postMessage(e,{operationId:T,data:{}}))}forget(e){this._handshaken.delete(e),this._greeted.delete(e),this._closePort(e),this._drained.delete(e),this._target===e&&(this._inited=!1)}usePort(e,t=!1,r=this._target){if(!r||this._ports.has(r))return;const n=Jt(e),i=n.subscribe(this._onTransportMessage);this._ports.set(r,{transport:n,subscription:i}),t&&(n.send({operationId:Oe,data:{}}),this.drainWindow(r))}useWindow(e=this._target){e&&(this._closePort(e),this._drained.delete(e))}get usesPort(){return this._target!==void 0&&this._ports.has(this._target)}hasPort(e){return this._ports.has(e)}_closePort(e){const t=this._ports.get(e);t&&(t.subscription.dispose(),t.transport.close(),this._ports.delete(e))}drainWindow(e){this._ports.has(e)&&e.postMessage({operationId:Zt,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){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;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(Q,e,t)}sendAsync(e,t,r=!0){if(!r&&!this.isInited())return Promise.resolve();const n=Ae(),i=Ae();return new Promise((o,s)=>{const a=this.addDisposable(new I);a.addDisposable(this.onInit(c=>{try{this._postMessage(c,{operationId:e,data:t,result:n,error:i})}catch(_){a.dispose(),s(_);return}a.addDisposable(this._onMessage(n,_=>{o(_),a.dispose()})),a.addDisposable(this._onMessage(i,_=>{s(_),a.dispose()}))}))})}_onMessage(e,t,r=0){return this._emitter.addListener(e,t,r)}addListener(e,t,r){return t?this._onMessage(e,t,r):this._onMessage(Q,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 I);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?n.addDisposable(this.onInit(e,t,r)):e(this._target)}):n.addDisposable(this._onMessage(T,()=>{e(this._target)},r)),n}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function L(e){return f(e)}var rr=f("extensions.atomsHandlers"),nr=L("HANDLE_ATOM_INSERT"),ir=f("extensions.sandboxExtensions"),or="SANDBOX_EXTENSION_SCRIPT_STATUS",sr=f("MESSAGE_SERVICE"),ar=L("SETTINGS_PANEL_EVENT"),cr="advanced",ur=L("MODAL_SHOW_EVENT"),_r=L("MODAL_CLOSE_EVENT"),lr=L("MODAL_UPDATE_EVENT"),Pn=f("client"),yn=f("v2_client"),Cn=f("ai_client"),dr=f("app.cookieManager"),Ln=f("app.storageProvider"),Rn=f("image-blob-resolver"),fr=f("template-directives"),Er="INJECTION";function pr(e){return e.getState}function hr(e){if(!pr(e)){e.dispose();return}const t=e.getState()[Er];t&&(W.getInstance(t)?.dispose(),W.remove(t))}function ge(e){return Object.assign({},...e)}var Ie=["generic","stockImages","emFiles","cdn"];function Z(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function me(e){return!Z(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>Ie.includes(t))}function Te(e){return e.length===0?[]:e.length===1?e[0]:e}function Se(e){let t=!1,r=[];for(const n of e)if(n!==void 0){if(t=!0,Array.isArray(n)){r=[...n,...r];continue}r=[n,...r]}if(t)return Te(r)}function Or(e){return Z(e)&&("value"in e||"replace"in e)}function be(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function Ar(e){let t=!1,r=[],n=!1;for(const o of e)if(o!==void 0){if(Or(o)){t=!0,o.replace&&(r=[],n=!0),o.value!==void 0&&(r=be(r,o.value),n=!0);continue}r=be(r,o),n=!0}const i=n?Te(r):void 0;if(!t)return i;if(i!==void 0)return{value:i}}function gr(e){const t=e.filter(n=>n!==void 0);if(t.length===0)return;if(!t.some(n=>me(n)))return Se(t);const r={};for(const n of Ie){const i=Ar(e.map(o=>{if(o!==void 0)return me(o)?o[n]:n==="generic"?o:void 0}));i!==void 0&&(r[n]=i)}return Object.keys(r).length>0?r:void 0}function Ir(e){return Se(e)}function mr(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(Z(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function Tr(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 Sr(e){let t=[],r=!1;for(const n of e){const i=mr(n);i&&(r=!0,i.replace&&(t=[]),t=Tr(t,i.hosts))}return r?t:void 0}function br(e){const t=e.filter(i=>i!==void 0);if(t.length===0)return;const r=ge(t.map(({directHosts:i,...o})=>o)),n=Sr(t.map(i=>i?.directHosts));return n!==void 0&&(r.directHosts=n),r}function ee(e){return e?.backendProxy}function R(e){return e.replace(/\/$/,"")}function De(e){return/^https?:\/\//i.test(e)}function Ne(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Dr(e){const t=new Set;return e.filter(r=>!r.url||t.has(r.url)?!1:(t.add(r.url),!0))}function Nr(e){const t=ee(e);return t?[t]:[]}function Pr(e){return{proxyEmFiles:!0,proxyAi:!1}}function yr(e,t){const r=Pr(t),n=t?.backendProxyPolicy;switch(e){case"emFiles":return n?.proxyEmFiles??r.proxyEmFiles;case"ai":return n?.proxyAi??r.proxyAi;default:return!0}}var Cr={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 Lr(e){const t=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(n,i)=>(t.push(i),`(${Cr[i]||".+"})`));return{regex:new RegExp(`^${r}$`,"i"),tokens:t}}function Rr(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function vr(e,t){if(Rr(t))return e;try{const r=new URL(e);return`${r.origin}${r.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function wr(e,t,r){if(r.endsWith("_encoded"))return!0;const n=e.slice(0,t),i=n.lastIndexOf("#"),o=n.lastIndexOf("?"),s=n.lastIndexOf("&"),a=n.lastIndexOf("=");return a>Math.max(o,s)&&a>i}function Mr(e){try{const t=new URL(e),r=t.pathname.replace(/^\/+/,""),n=t.search.replace(/^\?/,""),i=t.hash.replace(/^#/,""),o=r.replace(/^wp-json\/?/i,""),s=o?`/${o}`:"/",a=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),c=a?.[1]||"",_=a?.[2]||"",l=a?.[3]||"";return{url:e,url_encoded:encodeURIComponent(e),origin:t.origin,origin_encoded:encodeURIComponent(t.origin),proxy_url:t.origin,proxy_url_encoded:encodeURIComponent(t.origin),path:r,pathname:r,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:n,search:t.search,hash:t.hash,fragment:i,pathname_after_wp_json:o,pathname_after_wp_json_with_slash:s,rest_namespace:c,rest_version:_,rest_route:l,rest_route_with_slash:l?`/${l}`:"/"}}catch{return}}function te(e,t){if(!e)return{};if(Array.isArray(e)){for(const a of e){const c=te(a,t);if(c!==void 0)return c}return}if(e==="*")return{};const r=vr(t,e),{regex:n,tokens:i}=Lr(e),o=n.exec(r);if(!o)return;const s={};return i.forEach((a,c)=>{s[`matched_${a}`]=o[c+1]||""}),s}function F(e,t,r={}){const n=Mr(t);if(!n)return t;const i={...n,...r};let o="",s=0;const a=/\{([a-z_]+)\}/gi;let c;for(;c=a.exec(e);){o+=e.slice(s,c.index);const _=i[c[1]]??"",l=wr(e,c.index,c[1])?encodeURIComponent(_):_;o+=l,s=c.index+c[0].length}o+=e.slice(s);try{const _=new URL(o),l=new URL(t);return!o.includes("{search}")&&!o.includes("{query}")&&l.search&&l.searchParams.forEach((E,h)=>{_.searchParams.has(h)||_.searchParams.append(h,E)}),!o.includes("{hash}")&&!o.includes("{fragment}")&&l.hash&&!_.hash&&(_.hash=l.hash),_.toString()}catch{return o}}function Pe(e,t){try{const r=new URL(t);return`${R(e)}/${r.pathname.replace(/^\//,"")}${r.search}${r.hash}`}catch{return t}}function ye(e,t){const r=R(e);return t?De(t)?t:t.startsWith("?")||t.startsWith("#")?`${r}${t}`:`${r}${t.startsWith("/")?"":"/"}${t}`:r}function Ce(e,t,r,n){const i=e.match;return i?Array.isArray(i)?i.some(o=>Ce({...e,match:o},t,r,n)):typeof i=="function"?!!i({url:t,method:n,requestType:r}):i==="*"?!0:te(i,t)!==void 0:!0}function jr(e,t,r,n="generic"){if(e==null)return[];const i=Array.isArray(e)?e:[e],o=[];return i.forEach((s,a)=>{if(!s)return;if(typeof s=="string"){const E=s.includes("{")&&s.includes("}")?F(s,t):Pe(s,t);o.push({key:`backend:${a}`,url:E,source:"resource"});return}if(!Ne(s)||!("rewrite"in s))return;const c=s;if(!Ce(c,t,n,r))return;const _=typeof c.match=="string"||Array.isArray(c.match)?te(c.match,t)||{}:{},l=typeof c.proxyBase=="string"&&c.proxyBase.trim()?c.proxyBase.trim():void 0;(Array.isArray(c.rewrite)?c.rewrite:[c.rewrite]).filter(Boolean).forEach((E,h)=>{const p=typeof E=="function"?(()=>{const g=E({url:t,proxyBase:l,method:r,requestType:n,..._}),O=l&&!De(g)?ye(l,g):g;return O.includes("{")&&O.includes("}")?F(O,t,_):O})():l?F(ye(l,E),t,_):E.includes("{")&&E.includes("}")?F(E,t,_):Pe(E,t);o.push({key:`backend:${c.id||"rule"}:${a}:${h}`,url:p,source:"resource"})})}),Dr(o)}function Br(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 xr(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}!Ne(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 Fr(e,t){return Nr(t).flatMap(r=>xr(r)).filter(Boolean).some(r=>r&&e.startsWith(r))}function kr(e,t){return!!ee(t)&&yr(e,t)}function Ur(e,t={}){const r=t.requestType||Br(e);return kr(r,t.config)?jr(ee(t.config),e,t.method,r):[]}function Gr(e,t={}){return Fr(e,t.config)?[e]:Ur(e,t).map(r=>r.url)}function D(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function Le(...e){const t=e.filter(o=>o!=null);if(t.length===0)return;if(t.length===1)return t[0];const r=t.find(o=>o.aborted);if(r)return r;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const n=new AbortController,i=o=>{n.signal.aborted||n.abort(o.reason)};for(const o of t)o.addEventListener("abort",()=>i(o),{once:!0});return n.signal}var Re=3e5,ve=15e3,A=null,we=!1;function Xr(){return!0}function Hr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return Re;const t=Number(e);return Number.isFinite(t)&&t>0?t:Re}function Vr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return ve;const t=Number(e);return Number.isFinite(t)&&t>0?t:ve}function $r(){const e="https://app.useblocks.io/api".trim();return e?D(e):void 0}function Wr(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const r=JSON.parse(t);if(!Array.isArray(r))throw new Error("expected JSON array");return r.map(n=>String(n).trim()).filter(Boolean)}catch{return we||(we=!0),[]}return t.split(",").map(r=>r.trim()).filter(Boolean)}function qr(e){const t=new Set,r=[];for(const n of e){const i=D(n);t.has(i)||(t.add(i),r.push(i))}return r}function Me(e){const t=String(e||"").trim();return t?D(t):$r()}function je(e,t=[]){return e?qr([e,...t]).slice(0,3):[]}function Be(){return Wr(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function Kr(e=Date.now()){return A?e-A.switchedAt>=Hr():!0}function xe(e=Date.now()){A&&Kr(e)&&(A=null)}function N(e){if(!Xr())return!1;const t=Me(e);if(!t)return!1;const r=Be();return r.length===0?!1:je(t,r).length>1}function v(e){const t=Me(e);if(!t)return[];const r=Be();return r.length===0?[t]:je(t,r)}function k(e){const t=v(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 Fe(e){const t=v(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 ke(e){return k(e)||void 0}function Ue(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const r=Vr(),n=new AbortController;let i;const o=setTimeout(()=>{i=zr(r),n.abort(i)},r);return{signal:Le(t,n.signal),timeoutError:()=>i,done:()=>clearTimeout(o)}}function zr(e){const t=`[apiOriginFailover] origin attempt timed out after ${e}ms`;if(typeof DOMException=="function")return new DOMException(t,"TimeoutError");const r=new Error(t);return r.name="TimeoutError",r}function Ge(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 He;function Jr(e){He=e}function U(e,t){if(!N(t))return;const r=v(t);if(r.length<=1)return;const n=r.indexOf(D(e));if(n<0)return;const i=n+1;if(i>=r.length)return;const o=r[i],s=A?.activeUrl;A={activeUrl:o,switchedAt:Date.now()},s!==o&&He?.()}function Ve(e,t){if(!N(t))return;const r=D(e),n=v(t);if(n.includes(r)){if(r===n[0]){A=null;return}A?.activeUrl!==r&&(A={activeUrl:r,switchedAt:Date.now()})}}function $e(){A=null}var Yr=e=>{const t=new FormData,r=(n,i,o)=>{if(i!=null){if(i instanceof Blob){n.append(o,i);return}if(Array.isArray(i)){i.forEach((s,a)=>{const c=o?`${o}[${a}]`:`${a}`;r(n,s,c)});return}if(typeof i=="object"){Object.keys(i).forEach(s=>{const a=i[s],c=o?`${o}[${s}]`:s;r(n,a,c)});return}n.append(o,String(i))}};return r(t,e),t},Qr={baseUrl:D("https://app.useblocks.io/api"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},P=new Map;function Zr(e){const t=e?.getInstance(de);return t?t.get()??t.bootstrap():void 0}var en=class extends Xt{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=Zr(this.container),n=this.container?.getInstance(Ee)!==void 0,i=Gr(e,{config:r,method:t,standalone:n}),o=i.length>0?i:[e],s=this.buildRequestKey(e,t),a=P.get(s);return!a||!o.includes(a)?o:[a,...o.filter(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,r=!1){const n={...e,baseUrl:t},i=this.buildRequestUrl(n),o=n.method||"GET",s=this.buildRequestKey(i,o),a=this.getBackendProxyCandidates(i,o);let c,_;for(const l of a){const E=p=>p===i?l:p,h=r?Ue(e.signal):void 0;try{const p=await super.request({...n,proxyHandler:E,...h?{signal:h.signal}:{}});if(!p.ok&&this.shouldRetryResponse(p)&&l!==a[a.length-1]){_=p,P.get(s)===l&&P.delete(s);continue}return P.set(s,l),p}catch(p){P.get(s)===l&&P.delete(s);const g=h?.timeoutError();if(g)throw g;if(c=p,(p instanceof DOMException||p instanceof Error)&&p.name==="AbortError")throw p}finally{h?.done()}}if(_)return _;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 r=this.resolveFailoverBaseUrl(),n=N(r),i=e.failoverAttemptTimeout??n,o=n?Fe(r):r?[k(r)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let s,a;for(let c=0;c<o.length;c++){const _=o[c],l=c===o.length-1;try{const E=await this.requestOnOrigin(e,_,i);if(!E.ok&&Ge(E.status)){if(a=E,!l){U(_,r);continue}break}return E.ok&&Ve(_,r),E}catch(E){if(!Xe(E))throw E;s=E,l||U(_,r)}}if(n&&$e(),a)return a;throw s instanceof Error?s:new Error("API origin failover chain failed")}};function We(e={},t){const r=new en({...Qr,...e},t);return r.contentFormatters["multipart/form-data"]=Yr,r}var qe=f("rest.clientFactory"),tn=e=>{qt(e);const t=We({customFetch:e.getInstance(J)?.execute||fetch},e);e.inject(Y,t)},Ke;(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})(Ke||(Ke={}));function w(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const r=Array.isArray(e),n=Array.isArray(t);if(r){if(!n)return!1;const a=e.length;if(t.length!==a)return!1;for(let c=0;c<a;c++)if(!w(e[c],t[c]))return!1}else if(n)return!1;const i=Object.keys(e),o=Object.keys(t),s=i.length;if(s!==o.length)return!1;for(let a=0;a<s;a++){const c=i[a];if(!t.hasOwnProperty(c)||!w(e[c],t[c]))return!1}}return!0}function rn(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(rn(r));return{exp:i.exp,createdAt:i.iat,data:i}}var re=f("plugin.auth.token"),Je=new WeakMap,nn=3e4;function on(e){let t;try{t=ze(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+nn}function sn(e,t,r,n){const i=Je.get(e);i&&(i.stale=!0);const o={stale:!1};Je.set(e,o),e.injectFactory(re,async(s,a)=>{if(o.stale)return"";try{let c=await a||void 0;if(!c){const _=e.getInstance(fe);_&&(c=await _)}return t?!c||on(c)?await t(r,n,c):c:""}catch{return""}},!0)}var Ye=f("auth.oauthProvided"),Qe=new WeakMap;function Ze(e,t){const r=Qe.get(e)??{applied:!1};(!r.applied||r.getAuthToken!==t.getAuthToken||!w(r.user,t.user)||r.project!==t.project)&&(Qe.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),sn(e,t.getAuthToken,t.user,t.project))}function et(e){if(e.getInstance(Ye))return;e.inject(Ye,!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(re)===void 0&&Ze(e,t);const i=await e.getInstanceAsync(re);i&&r.headers.set("authorization",`Bearer ${i}`)}})}var an={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}}},tt="ERROR",cn="useblocks",un={em_color_scheme:"em_color_scheme",em_code_mode_pane_sizes:"em_code_mode_pane_sizes",em_preview_pane_sizes:"em_preview_pane_sizes",em_default_sizes:"em_default_sizes",em_pane_sizes:"em_pane_sizes",em_test_emails:"em_test_emails",em_menu_is_locked:"em_menu_is_locked",em_code_mode_settings:"em_code_mode_settings",em_folder_is_open:"em_folder_is_open",em_active_tab:"em_active_tab",em_ai_settings:"em_ai_settings",em_last_active_page:"em_last_active_page",em_layout_convert_never_suggest:"em_layout_convert_never_suggest",em_filemanager_v2:"em_filemanager_v2",em_projects_v2:"em_projects_v2",em_translations_v2:"em_translations_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_guest_locale:"em_guest_locale"},_n="light",ln="dark",dn="(prefers-color-scheme: dark)",fn={MESSAGE:"message",INIT_PREVIEW:"init_preview",UPDATE_PREVIEW:"update_preview",UPDATE_EDITOR:"update_editor",UPDATE_EDITOR_POSITION:"update_editor_position",UPDATE_SIDE_MENU_EDITOR:"update_side_menu_editor",SAVE_EMAIL:"saveEmail",SANDBOX_ELEMENT_SETTINGS_SET:"sandbox_element_settings_set",SANDBOX_IMAGE_RESET:"sandbox_image_reset",SANDBOX_NATIVE_IMAGE_DROP_CLEAR:"sandbox_native-image-drop-clear",SANDBOX_EMAIL_SETTINGS_SET:"sandbox_email_settings_set",SANDBOX_BLOCK_SETTINGS_SET:"sandbox_block_settings_set",SANDBOX_ELEMENT_PARENT_GET:"sandbox_element_parent_get",SANDBOX_ELEMENT_PARENT_TABLE_GET:"sandbox_element_parent_table_get",SANDBOX_ELEMENT_PREV_GET:"sandbox_element_prev_get",SANDBOX_ELEMENT_NEXT_GET:"sandbox_element_next_get",SANDBOX_ELEMENT_REMOVE:"sandbox_element_remove",SANDBOX_ELEMENT_ACTIVE_RESET:"sandbox_element_active_reset",SANDBOX_ELEMENT_ACTIVE_SET:"sandbox_element_active_set",SANDBOX_ELEMENT_HOVER_SET:"sandbox_element_hover_set",SANDBOX_ELEMENT_IMG_LINK:"sandbox_element_img_link",SANDBOX_ELEMENT_TEXT:"sandbox_element_text",SANDBOX_EMAIL_CONTENT_GET:"sandbox_email_content_get",SANDBOX_SET_POSITION_TO_IMG:"sandbox_set_position_to_img",SANDBOX_SET_POSITION_TO_LINK:"sandbox_set_position_to_link",SANDBOX_ACCORDION_ADD_SECTION:"sandbox_accordion_add_section",SANDBOX_ACCORDION_REMOVE_SECTION:"sandbox_accordion_remove_section",APPLICATION_FOCUS_IN_IFRAME:"application_focus_in_iframe",APPLICATION_EMAIL_SETTINGS_SET:"application_email_settings_set",APPLICATION_BLOCK_SETTINGS_SET:"application_block_settings_set",APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",_APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",APPLICATION_ELEMENT_SETTINGS_CLOSE:"application_element_settings_close",APPLICATION_ACTION:"application_action",APPLICATION_EBLOCK_ADD:"application_eblock_add",SANDBOX_EBLOCK_SET_EM_BLOCK_ID:"sandbox_eblock_set_em_block_id",SANDBOX_GLOBAL_BLOCK_REPLACE:"sandbox_global_block_replace",APPLICATION_SCROLL_TO:"application_scroll-to",APPLICATION_SCROLL_BLOCK_SHOW:"application_scroll-block-show",APPLICATION_SCROLL_BLOCK_HIDE:"application_scroll-block-hide",APPLICATION_DISCUSS_SET_ID:"application_discuss_set_id",APPLICATION_DISCUSS_GET_COMMENT:"application_discuss_get_comment",APPLICATION_DISCUSS_NO_COMMENT:"application_discuss_no_comment",APPLICATION_DISCUSS_SAVE_TARGET:"application_discuss_save_target",APPLICATION_IFRAME_SET_HEIGHT:"application_iframe_set_height",APPLICATION_COMMON_STYLES_UPDATE:"application_commonStyles_update",APPLICATION_EMAIL_CONTENT_GET:"application_email_content_get",APPLICATION_OPEN_IMAGE_AI_POPUP:"application_open-image-ai-popup",APPLICATION_OPEN_IMAGE_UPLOAD_POPUP:"application_open-image-upload-popup",APPLICATION_OPEN_IMAGE_EDIT_POPUP:"application_open-image-edit-popup",APPLICATION_OPEN_IMAGE_GIF_POPUP:"application_open-image-gif-popup",APPLICATION_OPEN_IMAGE_STOCK_POPUP:"application_open-image-stock-popup",APPLICATION_CLOSE_IMAGE_EDIT_POPUP:"application_close-image-edit-popup",APPLICATION_NATIVE_IMAGE_DROP:"application_native-image-drop",APPLICATION_SUBJECT_UPDATE:"application_subject_update",APPLICATION_PREHEADER_UPDATE:"application_preheader_update",APPLICATION_DOMPARSER_ERROR:"application_domparser_error",APPLICATION_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_WINDOW_CHARACTERISTIC:"sandbox_window-characteristic",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_ADD_MERGETAG:"sandbox_add_mergetag",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"},rt=e=>{const t={current:Promise.resolve(),state:e,decorate:(r,n)=>(n&&(r=r.bind(n)),function(...i){const o=t.current.then(()=>r(...i));return t.current=o.then(s=>{t.state=s},s=>{}),o})};return t};function ne(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function En(e){return t=>{const r={},n=[];for(const s of e)n.push(s(t));for(const s of n)Object.assign(r,s.instance);return{instance:r,setOptions:async s=>{for(const a of n)await a.setOptions(s)},dispose:()=>{for(const s of n)s.dispose()}}}}function pn(e=tt){const t=new Error(e);return t.name="AuthPipelineError",t}async function hn(e,t,r,n){const i=n?.attemptTimeout??N(r),o=N(r)?Fe(r):v(r).length>0?[k(r)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const s=e.startsWith("/")?e:`/${e}`;let a,c;for(let _=0;_<o.length;_++){const l=o[_],E=_===o.length-1,h=i?Ue(t.signal):void 0;try{const p=await fetch(`${l}${s}`,{...t,...h?{signal:h.signal}:{}});if(!p.ok&&Ge(p.status)){if(a=p,!E){U(l,r);continue}break}return p.ok&&Ve(l,r),p}catch(p){const g=h?.timeoutError();if(!g&&!Xe(p))throw p;c=g||p,E||U(l,r)}finally{h?.done()}}if(N(r)&&$e(),a)return a;throw c instanceof Error?c:new Error("[apiOriginFailover] fetch chain failed")}function nt(e){e.inject(C,void 0),e.inject(z,void 0)}var On=ne(e=>{let t,r;const n=rt();return e.addService(x,{execute:n.decorate(async(i,o)=>{if(o?.public||!t)return;const s=String(e.getInstance(z)||"").trim();if(s){i.headers.append("authorization",`Bearer ${s}`);return}if(!e.getInstance(C))try{const a=e.getInstance(qe),c=String(a?.getOptions()?.baseUrl||"").trim(),_=ke(r||c||void 0);if(!_)throw new Error("JWT auth requires baseUrl");const l=await hn("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},_);if(!l.ok)throw new Error(`JWT auth failed: ${l.status}`);const E=await l.json(),h=String(E.token||"").trim();if(!h)throw new Error("JWT auth failed: empty token");e.inject(C,void 0),e.inject(z,h),i.headers.append("authorization",`Bearer ${h}`)}catch{throw e.inject(C,tt),pn()}})}),{setOptions(i){const o=i.jwtAuth,s=String(i.baseUrl||"").trim()||void 0,a=!w(o,t),c=s!==r;if(t=o,r=s,!o){nt(e);return}a||c?nt(e):e.inject(C,void 0)}}}),An=ne(e=>(et(e),{setOptions(t){Ze(e,t)}}));function gn(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function ie(e,t=document){try{const n=t.querySelector(e);if(n)return n}catch{return null}const r=t.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;if(!i)continue;const o=ie(e,i);if(o)return o}return null}function it(e,t=[]){const r=e.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;i&&(t.push(i),it(i,t))}return t}function In(e,t,r){if(e.isConnected)return e;const n=e.id?.trim();return n?ot(`#${gn(n)}`,t,r):Promise.reject(S("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function ot(e,t,r){if(q(r),typeof e<"u"){if(typeof e=="string"){const n=e,i=ie(n);if(i)return i;const o=t.addDisposable(new I);return new Promise((s,a)=>{const c=O=>{o.dispose(),O()},_=()=>{c(()=>a(S(r?.reason)))};if(r?.aborted){_();return}r?.addEventListener("abort",_),o.addDispose(()=>r?.removeEventListener("abort",_));const l=document.body??document.documentElement;if(!l){c(()=>a(S("Document is not ready to observe mount element")));return}const E=new Set,h=new MutationObserver(()=>{const O=ie(n);if(O){c(()=>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 G of it(O))p(G)};p(l),g(),o.addDispose(()=>h.disconnect())})}return e instanceof Element?In(e,t,r):e}return e}var mn=new Map;Object.defineProperty(u,"ADVANCED_SETTINGS_PANEL",{enumerable:!0,get:function(){return cr}}),Object.defineProperty(u,"APP_ID",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(u,"APP_LOAD_EVENT_ID",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(u,"ATOMS_HANDLERS_ID",{enumerable:!0,get:function(){return rr}}),Object.defineProperty(u,"AsyncEmitter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(u,"BaseEmitter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(u,"COMMON_STYLES",{enumerable:!0,get:function(){return an}}),Object.defineProperty(u,"CONFIG_CHANGED_EVENT_ID",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(u,"CONFIG_SOURCE_ID",{enumerable:!0,get:function(){return de}}),Object.defineProperty(u,"COOKIE_MANAGER_ID",{enumerable:!0,get:function(){return dr}}),Object.defineProperty(u,"CUSTOM_FETCH_ID",{enumerable:!0,get:function(){return J}}),Object.defineProperty(u,"ContentType",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(u,"DARK",{enumerable:!0,get:function(){return ln}}),Object.defineProperty(u,"DISPOSABLE_ID",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(u,"DependencyResolver",{enumerable:!0,get:function(){return W}}),Object.defineProperty(u,"Disposable",{enumerable:!0,get:function(){return I}}),Object.defineProperty(u,"ELEMENT_MAP",{enumerable:!0,get:function(){return mn}}),Object.defineProperty(u,"EVENT_TYPES",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(u,"Emitter",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(u,"HANDLE_ATOM_INSERT_ID",{enumerable:!0,get:function(){return nr}}),Object.defineProperty(u,"INIT_PIPELINE_ID",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(u,"INSTANCE_ID",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(u,"JWTMixin",{enumerable:!0,get:function(){return On}}),Object.defineProperty(u,"LATE_SURFACE_LISTENERS_ID",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(u,"LIGHT",{enumerable:!0,get:function(){return _n}}),Object.defineProperty(u,"LOCAL_STORAGE_ITEMS",{enumerable:!0,get:function(){return un}}),Object.defineProperty(u,"MESSAGE_SERVICE_ID",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(u,"MODAL_CLOSE_EVENT",{enumerable:!0,get:function(){return _r}}),Object.defineProperty(u,"MODAL_SHOW_EVENT",{enumerable:!0,get:function(){return ur}}),Object.defineProperty(u,"MODAL_UPDATE_EVENT",{enumerable:!0,get:function(){return lr}}),Object.defineProperty(u,"MessageService",{enumerable:!0,get:function(){return tr}}),Object.defineProperty(u,"OAuthMixin",{enumerable:!0,get:function(){return An}}),Object.defineProperty(u,"OPTIONS_SOURCE_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(u,"PLUGIN_COLLECTION_ID",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(u,"PORT_READY",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(u,"PREFERS_COLOR_SCHEME_DARK",{enumerable:!0,get:function(){return dn}}),Object.defineProperty(u,"PUBLIC_REQUEST",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(u,"REQUEST_HANDLER_ID",{enumerable:!0,get:function(){return x}}),Object.defineProperty(u,"REST_CLIENT_FACTORY_ID",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(u,"REST_TRANSPORT_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(u,"SANDBOX_EXTENSIONS_ID",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(u,"SANDBOX_EXTENSION_SCRIPT_STATUS_ID",{enumerable:!0,get:function(){return or}}),Object.defineProperty(u,"SECURITY_MODULE_ID",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(u,"SETTINGS_PANEL_EVENT",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(u,"STANDALONE_ACTIVATED_ID",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(u,"STANDALONE_BOOTSTRAP_TOKEN_ID",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(u,"STANDALONE_FILE_PROXY_REGISTERED_ID",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(u,"STANDALONE_PROJECT_ID",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(u,"STORE_ID",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(u,"Signal",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(u,"TEMPLATE_DIRECTIVES_ID",{enumerable:!0,get:function(){return fr}}),Object.defineProperty(u,"USEBLOCKS",{enumerable:!0,get:function(){return cn}}),Object.defineProperty(u,"combineMixins",{enumerable:!0,get:function(){return En}}),Object.defineProperty(u,"composeAbortSignals",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(u,"createAbortError",{enumerable:!0,get:function(){return S}}),Object.defineProperty(u,"createIdentifier",{enumerable:!0,get:function(){return Yt}}),Object.defineProperty(u,"createIdentifier$1",{enumerable:!0,get:function(){return f}}),Object.defineProperty(u,"createQueue",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(u,"createTransport",{enumerable:!0,get:function(){return We}}),Object.defineProperty(u,"debounce",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(u,"decodeJwt",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(u,"deepEqual",{enumerable:!0,get:function(){return w}}),Object.defineProperty(u,"defineMixin",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(u,"events",{enumerable:!0,get:function(){return K}}),Object.defineProperty(u,"filter",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(u,"generateUUID",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(u,"getActiveBaseUrl",{enumerable:!0,get:function(){return k}}),Object.defineProperty(u,"getApi",{enumerable:!0,get:function(){return Kt}}),Object.defineProperty(u,"getEmitter",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(u,"getEmitter$1",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(u,"getEvent",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(u,"getServiceContainerId",{enumerable:!0,get:function(){return M}}),Object.defineProperty(u,"mapHttpStatusToErrorCode",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(u,"mergeBackendProxyLayers",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(u,"mergeResourceProxyLayers",{enumerable:!0,get:function(){return gr}}),Object.defineProperty(u,"mergeResourceProxyPolicyLayers",{enumerable:!0,get:function(){return br}}),Object.defineProperty(u,"mergeShallowConfigLayers",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(u,"provideOAuth",{enumerable:!0,get:function(){return et}}),Object.defineProperty(u,"raceWithAbortSignal",{enumerable:!0,get:function(){return It}}),Object.defineProperty(u,"registerRestTransport",{enumerable:!0,get:function(){return tn}}),Object.defineProperty(u,"releaseContainer",{enumerable:!0,get:function(){return hr}}),Object.defineProperty(u,"resolveContainer",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(u,"resolveExplicitApiBaseUrl",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(u,"setApiOriginFailoverHook",{enumerable:!0,get:function(){return Jr}}),Object.defineProperty(u,"snapshot",{enumerable:!0,get:function(){return St}}),Object.defineProperty(u,"throwIfAborted",{enumerable:!0,get:function(){return q}}),Object.defineProperty(u,"waitForElement",{enumerable:!0,get:function(){return ot}})});
2075
+ __useblocks__.define("static/umd/993c2c90.js",["require","exports","module"],function(Dn,u,Nn){var I=class ct{_inner;_isDisposed=!1;constructor(t=[]){this._inner=t}addDisposable(t){return this._inner.push(t),t instanceof ct&&t.addDispose(()=>{this.removeDisposable(t)}),t}addDispose(t){this.addDisposable({dispose:t})}removeDisposable(t){const r=this._inner.indexOf(t);r>=0&&this._inner.splice(r,1)}isDisposed(){return this._isDisposed}dispose(){if(!this._isDisposed){this._isDisposed=!0;for(const t of[...this._inner])t.dispose()}}};function M(e){return`service_container_${e}`}var y=new Set,H;function ut(){if(!H)return;const e=new Error("getInstanceAsync"),t=Error;return typeof t.captureStackTrace=="function"&&t.captureStackTrace(e,se.prototype.getInstanceAsync),e.stack}function V(e){y.delete(e)&&H?.end(e)}var se=class oe extends I{_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 I){return n.addDisposable(this.onInject(i=>{t===i&&(n.dispose(),r(this.getInstance(i)))})),this._parent&&n.addDisposable(this._parent._onInject(t,r,n)),this.addDisposable(n),n}getInstance(t,r=!0){const n=this._find(t,r);if(typeof n=="function")return n()}getOrCreateInstance(t,r){const n=this._find(t);if(typeof n=="function")return n();const i=r(this);return this.inject(t,i),i}getInstanceAsync(t){const r=this._find(t);if(typeof r=="function")return Promise.resolve(r());const n=ut();return new Promise((i,o)=>{const s={id:String(t),startedAt:Date.now(),origin:n,container:this,reject:o};y.add(s),H?.start(s),this._onInject(t,()=>{V(s),i(this.getInstance(t))})})}failPendingWaits(t){for(const r of Array.from(y))r.container===this&&(V(r),r.reject(t))}pendingWaits(){return[...y].filter(t=>t.container===this)}addService(t,r){const n=M(t);this.injectFactory(n,(o,s=[])=>s.indexOf(r)<0?[...s,r]:s);const i=new I;return i.addDispose(()=>{this.injectFactory(n,(o,s=[])=>s.filter(a=>a!==r))}),i}addServiceFactory(t,r,n){const i=M(t);let o;this.injectFactory(i,(a,c=[])=>(o=r(a,o),o===void 0?c:c.indexOf(o)<0?[...c,o]:c),n);const s=new I;return s.addDispose(()=>{this.injectFactory(i,(a,c=[])=>o===void 0?c:c.filter(_=>_!==o))}),s}getServices(t){const r=M(t);return[...this.getInstance(r,!1)||[],...this._parent?.getServices(t)||[]]}createChild(){return new oe(this)}getOrCreateIsolatedContainer(t){return this.getOrCreateInstance(t,()=>{const r=this._parent?.getOrCreateIsolatedContainer(t);return new oe(r)})}remove(t){const r=this._injections;delete r[String(t)]}injectListenerCount(){return this._injectCallbacks.length}dispose(){for(const t of Array.from(y))t.container===this&&V(t);this._injections=Object.create(null),this._injectCallbacks=[],super.dispose()}};function $(e){return e.startsWith("__")?e:`__${e}__`}function _t(e){if(typeof globalThis>"u")throw new Error("[di] globalThis is required for namespace container access.");const t=$(e),r=globalThis;return r[t]??={}}function lt(e){return e!=null&&typeof e=="object"&&typeof e.inject=="function"&&typeof e.getInstance=="function"}function dt(e){if(e)return $(e);const t="useblocks".trim();if(!t)throw new Error("[di] REACT_APP_NAME is required for resolveContainer().");return $(t)}function ae(e){const t=dt(e),r=_t(t);if(lt(r.container))return r.container;const n=new se(null);return r.container=n,n}function ft(e){return ae(e)}function Et(){let e=new Date().getTime(),t=typeof performance<"u"&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(r){let n=Math.random()*16;return e>0?(n=(e+n)%16|0,e=Math.floor(e/16)):(n=(t+n)%16|0,t=Math.floor(t/16)),(r==="x"?n:n&3|8).toString(16)})}function ce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():Et()}function f(e=ce()){return e}function ue(){return"umd".trim()||"unknown"}function pt(e){if(typeof globalThis>"u")return;const t=ue(),r=globalThis[e]??{};globalThis[e]=r;const n=r.__diagnostics??={},i=n.diModuleEval??={evalCount:0,records:[]};i.records.push({buildSource:t,timestamp:Date.now(),stack:new Error().stack}),i.evalCount+=1}function ht(){const e="useblocks".trim();if(!e)throw new Error("[di] REACT_APP_NAME is required for DependencyResolver diagnostics.");return`__${e}__`}function Ot(e,t){if(pt(t),typeof globalThis>"u")return e;const r=ue(),n=globalThis,i=n[t]=n[t]||{},o=i.__diagnostics=i.__diagnostics||{},s=o.dependencyResolver=o.dependencyResolver||{entries:[]},a={container:e,source:"packages/runtime-core/di/index.ts",buildSource:r,timestamp:Date.now(),stack:new Error().stack};return s.entries.push(a),e}var j;function At(){if(j)return j;const e=ht();return j=Ot(ae(e),e),j}var W=new Proxy({},{get(e,t,r){const n=At(),i=Reflect.get(n,t,r);return typeof i=="function"?i.bind(n):i}});function gt(e,t="BackendError"){switch(e){case 400:return"ValidationError";case 401:return"AuthenticationFailed";case 403:return"AuthorizationFailed";case 404:return"FileNotFound";case 413:return"PayloadTooLarge";case 415:return"UnsupportedMediaType";case 429:return"RateLimitExceeded";case 500:return"BackendError";case 503:return"ServiceUnavailable";case 504:return"Timeout";default:return t}}function S(e){if(e instanceof DOMException&&e.name==="AbortError")return e;const t=e===void 0?"The operation was aborted.":typeof e=="string"?e:e instanceof Error?e.message:String(e);return new DOMException(t,"AbortError")}function It(e){return e instanceof DOMException&&e.name==="AbortError"}function q(e){if(e?.aborted)throw S(e.reason)}function mt(e,t){return t?(t.aborted&&e.catch(()=>{}),q(t),new Promise((r,n)=>{const i=()=>{o(),n(S(t.reason))},o=()=>{t.removeEventListener("abort",i)};t.addEventListener("abort",i),e.then(s=>{o(),r(s)},s=>{o(),n(s)})})):e}var _e=class extends I{_options;_listeners=[];constructor(e={}){super(),this._options=e}getListeners(e){return this._listeners.flatMap(([t])=>typeof t=="function"?t:t.getListeners(e))}hasListeners(){for(const[e]of this._listeners){if(typeof e=="function")return!0;const t=e;if(typeof t.hasListeners=="function"){if(t.hasListeners())return!0;continue}return!0}return!1}_addListener(e,t=0,r){if(this.isDisposed())return{dispose:()=>{}};const n=this._listeners,i=this._options;r&&typeof e=="function"&&(e=e.bind(r));const o=n.findIndex(([,a])=>a<t),s=[e,t];return n.splice(o>=0?o:n.length,0,s),n.length===1&&i.onFirstListenerAdd&&i.onFirstListenerAdd(),{dispose:()=>{const a=n.indexOf(s);a>=0&&(n.splice(a,1),!n.length&&i.onLastListenerRemove&&i.onLastListenerRemove())}}}on=this._addListener.bind(this);event=this._addListener.bind(this);once=(e,t=0,r)=>{const n=this._addListener((...i)=>(n?.dispose(),r?e.call(r,...i):e(...i)),t);return n};un=e=>{const t=this._listeners.findIndex(([r])=>r===e);t>=0&&(this._listeners.splice(t,1),this._listeners.length===0&&this._options.onLastListenerRemove&&this._options.onLastListenerRemove())};dispose(){this._listeners.splice(0,this._listeners.length),this._options.onLastListenerRemove&&this._options.onLastListenerRemove(),super.dispose()}},b=class extends _e{execute(e,t){for(const r of t)try{r(...e)}catch{}}fire(...e){if(!this.isDisposed()){const t=this.execute(e,this.getListeners(e));return t===void 0?void 0:t}}},Tt=class extends b{execute([e],t){for(const r of t)try{r(e)}catch{}}},St=class extends b{_suspendCounter=0;_wasFired=!1;execute([e],t){if(this._suspendCounter)this._wasFired=!0;else for(const r of t)try{r(e)}catch{}}suspend(){this._suspendCounter++}resume(){--this._suspendCounter===0&&this._wasFired&&(this.fire(),this._wasFired=!1)}},B=class extends b{async execute([e],t){const r=[];for(const n of t)try{r.push(await n(e))}catch{}return r}async fireSettled(e){const t={results:[],errors:[]};if(this.isDisposed())return t;for(const r of this.getListeners([e]))try{t.results.push(await r(e))}catch(n){t.errors.push(n)}return t}};function bt(e,t=0){const r=new _e,n=e(r,t);return n&&r.addDisposable(n),r.event}function Dt(e,t,r=0){const n=new b,i=e((...o)=>{if(t(...o))return n.fire(...o)},r);return i&&n.addDisposable(i),n.event}function Nt(e,t=0,r=0){const n=new b;let i,o;const s=e((...a)=>{o=a,i||(i=setTimeout(()=>{o&&n.fire(...o),i=void 0},t))},r);return s&&n.addDisposable(s),n.event}function Pt(e,t){return e.getOrCreateInstance(t,()=>new B)}function d(e){return f(e)}var K;(function(e){e.BEFORE_SAVE_EMAIL=d("events.BEFORE_SAVE_EMAIL"),e.ON_SAVEBUTTON_CLICK_ID=d("events.ON_SAVEBUTTON_CLICK_ID"),e.ON_NEXTBUTTON_CLICK_ID=d("events.ON_NEXTBUTTON_CLICK_ID"),e.ON_PREVIOUSBUTTON_CLICK_ID=d("events.ON_PREVIOUSBUTTON_CLICK_ID"),e.ON_DOCUMENT_SESSION_CHANGE=d("events.ON_DOCUMENT_SESSION_CHANGE"),e.WILL_EMAIL_INIT_ID=d("events.WILL_EMAIL_INIT_ID"),e.ON_EMAIL_INIT_ID=d("events.ON_EMAIL_INIT_ID"),e.ON_BLOCK_INIT_ID=d("events.ON_BLOCK_INIT_ID"),e.ON_CONTENT_CHANGED_ID=d("events.ON_CONTENT_CHANGED_ID"),e.ON_PREHEADER_CHANGED_ID=d("events.ON_PREHEADER_CHANGED_ID"),e.ON_SUBJECT_CHANGED_ID=d("events.ON_SUBJECT_CHANGED_ID"),e.ON_EMAIL_CHANGED_ID=d("events.ON_EMAIL_CHANGED_ID"),e.ON_HEADER_APPLIED_ID=d("events.ON_HEADER_APPLIED_ID"),e.ON_BLOCK_CHANGED_ID=d("events.ON_BLOCK_CHANGED_ID"),e.ON_CHUNKS_LOADED=d("events.ON_CHUNKS_LOADED"),e.ON_SEND_TESTEMAIL_ID=d("events.ON_SEND_TESTEMAIL_ID"),e.ON_SEND_LIVEPREVIEW_ID=d("events.ON_SEND_LIVEPREVIEW_ID"),e.ON_SHARE_ID=d("events.ON_SHARE_ID"),e.ON_SHOW_PREVIEW_ID=d("events.ON_SHOW_PREVIEW_ID"),e.ON_EMAIL_CLONE_ID=d("events.ON_EMAIL_CLONE_ID"),e.ON_SEND_EMAIL_MODAL_ID=d("events.ON_SEND_EMAIL_MODAL_ID"),e.ON_NOTIFICATION=d("events.ON_NOTIFICATION"),e.READ_LOCALE=d("events.READ_LOCALE"),e.ON_TRANSLATE_ID=d("events.ON_TRANSLATE_ID"),e.ON_CODE_VALIDATE_ID=d("events.ON_CODE_VALIDATE_ID"),e.UPLOAD_EVENT_ID=d("events.UPLOAD_EVENT_ID"),e.PROXY_URL_EVENT_ID=d("events.PROXY_URL_EVENT_ID"),e.FILE_PROXY_EVENT_ID=d("events.FILE_PROXY_EVENT_ID"),e.ON_LIMIT_ID=d("events.ON_LIMIT_ID"),e.ON_BROWSER_EXTENSION_DETECTED_ID=d("events.ON_BROWSER_EXTENSION_DETECTED_ID"),e.ON_LAYOUT_CONVERT_REQUEST_ID=d("events.ON_LAYOUT_CONVERT_REQUEST_ID"),e.ON_BROWSER_TRANSLATE_DETECTED_ID=d("events.ON_BROWSER_TRANSLATE_DETECTED_ID"),e.AI_TEXT_REQUEST_ID=d("events.AI_TEXT_REQUEST_ID"),e.AI_IMAGE_REQUEST_ID=d("events.AI_IMAGE_REQUEST_ID"),e.AI_TEXT_PROGRESS_ID=d("events.AI_TEXT_PROGRESS_ID"),e.AI_IMAGE_PROGRESS_ID=d("events.AI_IMAGE_PROGRESS_ID"),e.AI_TEXT_STREAM_ID=d("events.AI_TEXT_STREAM_ID")})(K||(K={}));function yt(e,t){return e.getOrCreateInstance(t,()=>new B).event}function Ct(e,t){return e.getOrCreateInstance(t,()=>new B)}var Lt=f("plugin.app"),Rt=f("plugin.disposable"),vt=f("InitPipelineContext"),wt=f("plugin.instance"),Mt=f("plugin.lateSurfaceListeners"),le=f("plugin.optionsSource"),jt=f("plugin.store"),de=f("ConfigSource"),Bt=f("plugin.standalone.project"),fe=f("plugin.standalone.bootstrapToken"),Pn=f("plugin.element"),Ee=f("plugin.securityModule"),xt=f("plugin.standalone.activated"),Ft=f("plugin.standalone.fileProxyRegistered"),z=f("plugin.jwt.token"),C=f("plugin.jwt.error"),kt=f("PluginCollection"),Ut=d("APP_LOAD_EVENT"),Gt=d("CONFIG_CHANGED_EVENT"),Xt=(function(e){return e.Json="application/json",e.FormData="multipart/form-data",e.UrlEncoded="application/x-www-form-urlencoded",e.Text="text/plain",e})({}),Ht=class{baseUrl="https://api.emailmaker.ru/wp-json";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(r=>this.encodeQueryParam(t,r)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(r=>typeof t[r]<"u").map(r=>Array.isArray(t[r])?this.addArrayQueryParam(t,r):this.addQueryParam(t,r)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce((t,r)=>{const n=e[r];return t.append(r,n instanceof Blob?n:typeof n=="object"&&n!==null?JSON.stringify(n):`${n}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const r=this.abortControllers.get(e);return r?r.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};async request({body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:a,extraQuery:c,proxyHandler:_,...l}){const E=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},h=this.mergeRequestParams(l,E);c&&(i=i?{...i,...c}:c);const p=i&&this.toQueryString(i),g=this.contentFormatters[n||"application/json"],O=o||h.format,G=`${s||this.baseUrl||""}${r}${p?`?${p}`:""}`,Sn=_?_(G,{body:e,secure:t,path:r,type:n,query:i,format:o,baseUrl:s,cancelToken:a,extraQuery:c,proxyHandler:_,...l}):G,st=new Request(Sn,{...h,headers:{...h.headers||{},...n&&n!=="multipart/form-data"?{"Content-Type":n}:{}},signal:(a?this.createAbortSignal(a):h.signal)||null,body:typeof e>"u"||e===null?null:g(e)});return this.customFetch(st).then(async at=>{const m=at;m.data=null,m.error=null,m.meta={request:st,response:m};const bn=O?await at[O]().then(X=>(m.ok?m.data=X:m.error={data:X},m)).catch(X=>(m.error=X,m)):m;return a&&this.abortControllers.delete(a),bn})}},Vt=f("prewarm.networkActivity");function $t(){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 Wt(e){return e.getOrCreateInstance(Vt,()=>$t())}var pe=Symbol("rest.publicRequest"),x=f("rest.requestHandler"),qt=f("rest.responseHandler"),J=f("rest.customFetch"),Y=f("rest_transport"),Kt=e=>{e.inject(J,{execute:async(t,r={})=>{const n=e.getServices(x),i={public:r[pe]===!0},o=Wt(e).begin();try{let s=t instanceof Request?t:new Request(t,r);for(const _ of n){const l=await _.execute(s,i);l instanceof Request&&(s=l)}let a=await fetch(s);const c=e.getServices(qt);for(const _ of c)a=await _.execute(a);return a}finally{o()}}})};function zt(e,t){const r=e.getInstance(Y);if(!r)throw new Error("[restApi] транспорт не зарегистрирован в контейнере");return Object.assign({},...t.map(n=>new n(r)))}function Jt(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 Yt(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 Qt(e){return e}function Zt(e){return e&&typeof e=="object"}function he(e,t){return e&&typeof e=="object"&&e.operationId===t}var T="INIT_MESSAGE",Oe="em:port-ready",er="em:window-drained",Q="";function Ae(){return Math.random().toString(36).substring(2,15)+Math.random().toString(36).substring(2,15)}var tr=class extends I{_listeners=Object.create(null);addListenerAsync=(e,t,r=0,n)=>{const i=this._listeners[e]||(this._listeners[e]=[]);n&&typeof t=="function"&&(t=t.bind(n));const o=i.findIndex(([a,c])=>r<=c),s=[t,r];return this.isDisposed()||i.splice(o>=0?o:i.length,0,s),{dispose(){const a=i.indexOf(s);a>=0&&i.splice(a,1)}}};fireAsync=(e,t)=>{if(!this.isDisposed()){const r=this._listeners[e]||(this._listeners[e]=[]);let n;for(let i=0;i<r.length;i++){const o=r[i][0],s=n;n=a=>o(a,s)}if(n)return n(t)}};addListener=(e,t,r=0)=>this.addListenerAsync(e,(n,i)=>{try{t(n)}catch{}return i&&i(n)},r)},rr=class extends I{_singleton;_target;_transport;_transportSubscription;_ports=new Map;_drained=new WeakSet;_inited=!1;_emitter=this.addDisposable(new tr);_handshaken=new WeakSet;_greeted=new WeakSet;_outgoingFilter;constructor(e,t){super(),this._singleton=t,this._transport=Jt({postMessage:()=>{}},window),this._transportSubscription=this.addDisposable(this._transport.subscribe(this._onTransportMessage)),this.addListener(T,()=>{this._inited||(this._inited=!0,this._target&&this._handshaken.add(this._target),this.send(T))}),e&&this.setTarget(e)}_onTransportMessage=e=>{const t=e,r=t.data,n=t.source,i=r?.port===!0?t.ports?.[0]:void 0,o=!this._isPortSource(t.source);if(o&&n&&r?.operationId==="em:window-drained"){this._drained.add(n);return}if(!(o&&n&&this._drained.has(n))){if(n&&n!==this._target&&this._greeted.has(n)&&he(r,T)){this._greeted.delete(n),this._handshaken.add(n),this._postMessage(n,{operationId:T,data:{}}),i&&this.usePort(i,!0,n);return}if(Zt(r)&&(t.source===this.target||this._isCurrentPort(t.source))||this._singleton&&he(r,T)){if(i){const _=this._target;Promise.resolve().then(()=>this.usePort(i,!0,_))}const s=this._emitter.fireAsync(r.operationId||Q,r.operationId===void 0?t:r.data),a=r.result,c=r.error;a&&c&&Promise.resolve(s).then(_=>this._sendMessage(a,_),_=>this._sendMessage(c,_))}}};setTarget(e){if(this._target!==e){if(this._target=e,!e){this._inited=!1;return}if(this._handshaken.has(e)){this._inited=!0,this._emitter.fireAsync(T,void 0);return}this._inited=!1,this._postMessage(e,{operationId:T,data:{}})}}sendPort(e,t){this._postMessage(e,{operationId:T,data:{},port:!0},[t])}setOutgoingFilter(e){return this._outgoingFilter=e,()=>{this._outgoingFilter===e&&(this._outgoingFilter=void 0)}}sendNow(e){const t=this._target;return!this._inited||!t?!1:(this._postMessage(t,e),!0)}greet(e){this._handshaken.has(e)||this._greeted.has(e)||this._target===e||(this._greeted.add(e),this._postMessage(e,{operationId:T,data:{}}))}forget(e){this._handshaken.delete(e),this._greeted.delete(e),this._closePort(e),this._drained.delete(e),this._target===e&&(this._inited=!1)}usePort(e,t=!1,r=this._target){if(!r||this._ports.has(r))return;const n=Yt(e),i=n.subscribe(this._onTransportMessage);this._ports.set(r,{transport:n,subscription:i}),t&&(n.send({operationId:Oe,data:{}}),this.drainWindow(r))}useWindow(e=this._target){e&&(this._closePort(e),this._drained.delete(e))}get usesPort(){return this._target!==void 0&&this._ports.has(this._target)}hasPort(e){return this._ports.has(e)}_closePort(e){const t=this._ports.get(e);t&&(t.subscription.dispose(),t.transport.close(),this._ports.delete(e))}drainWindow(e){this._ports.has(e)&&e.postMessage({operationId:er,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){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;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(Q,e,t)}sendAsync(e,t,r=!0){if(!r&&!this.isInited())return Promise.resolve();const n=Ae(),i=Ae();return new Promise((o,s)=>{const a=this.addDisposable(new I);a.addDisposable(this.onInit(c=>{try{this._postMessage(c,{operationId:e,data:t,result:n,error:i})}catch(_){a.dispose(),s(_);return}a.addDisposable(this._onMessage(n,_=>{o(_),a.dispose()})),a.addDisposable(this._onMessage(i,_=>{s(_),a.dispose()}))}))})}_onMessage(e,t,r=0){return this._emitter.addListener(e,t,r)}addListener(e,t,r){return t?this._onMessage(e,t,r):this._onMessage(Q,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 I);return this._inited&&this._target?t&&Promise.resolve().then(()=>{!this._inited||!this._target?n.addDisposable(this.onInit(e,t,r)):e(this._target)}):n.addDisposable(this._onMessage(T,()=>{e(this._target)},r)),n}dispose(){for(const e of Array.from(this._ports.keys()))this._closePort(e);this._transport.close(),super.dispose()}};function L(e){return f(e)}var nr=f("extensions.atomsHandlers"),ir=L("HANDLE_ATOM_INSERT"),or=f("extensions.sandboxExtensions"),sr="SANDBOX_EXTENSION_SCRIPT_STATUS",ar=f("MESSAGE_SERVICE"),cr=L("SETTINGS_PANEL_EVENT"),ur="advanced",_r=L("MODAL_SHOW_EVENT"),lr=L("MODAL_CLOSE_EVENT"),dr=L("MODAL_UPDATE_EVENT"),yn=f("client"),Cn=f("v2_client"),Ln=f("ai_client"),fr=f("app.cookieManager"),Rn=f("app.storageProvider"),vn=f("image-blob-resolver"),Er=f("template-directives"),pr="INJECTION";function hr(e){return e.getState}function Or(e){if(!hr(e)){e.dispose();return}const t=e.getState()[pr];t&&(W.getInstance(t)?.dispose(),W.remove(t))}function ge(e){return Object.assign({},...e)}var Ie=["generic","stockImages","emFiles","cdn"];function Z(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function me(e){return!Z(e)||"match"in e||"rewrite"in e||"proxyBase"in e?!1:Object.keys(e).some(t=>Ie.includes(t))}function Te(e){return e.length===0?[]:e.length===1?e[0]:e}function Se(e){let t=!1,r=[];for(const n of e)if(n!==void 0){if(t=!0,Array.isArray(n)){r=[...n,...r];continue}r=[n,...r]}if(t)return Te(r)}function Ar(e){return Z(e)&&("value"in e||"replace"in e)}function be(e,t){return t===void 0?e:Array.isArray(t)?[...t,...e]:[t,...e]}function gr(e){let t=!1,r=[],n=!1;for(const o of e)if(o!==void 0){if(Ar(o)){t=!0,o.replace&&(r=[],n=!0),o.value!==void 0&&(r=be(r,o.value),n=!0);continue}r=be(r,o),n=!0}const i=n?Te(r):void 0;if(!t)return i;if(i!==void 0)return{value:i}}function Ir(e){const t=e.filter(n=>n!==void 0);if(t.length===0)return;if(!t.some(n=>me(n)))return Se(t);const r={};for(const n of Ie){const i=gr(e.map(o=>{if(o!==void 0)return me(o)?o[n]:n==="generic"?o:void 0}));i!==void 0&&(r[n]=i)}return Object.keys(r).length>0?r:void 0}function mr(e){return Se(e)}function Tr(e){if(e!==void 0){if(Array.isArray(e))return{replace:!1,hosts:e};if(Z(e)&&Array.isArray(e.value))return{replace:!!e.replace,hosts:e.value}}}function Sr(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 br(e){let t=[],r=!1;for(const n of e){const i=Tr(n);i&&(r=!0,i.replace&&(t=[]),t=Sr(t,i.hosts))}return r?t:void 0}function Dr(e){const t=e.filter(i=>i!==void 0);if(t.length===0)return;const r=ge(t.map(({directHosts:i,...o})=>o)),n=br(t.map(i=>i?.directHosts));return n!==void 0&&(r.directHosts=n),r}function ee(e){return e?.backendProxy}function R(e){return e.replace(/\/$/,"")}function De(e){return/^https?:\/\//i.test(e)}function Ne(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Nr(e){const t=new Set;return e.filter(r=>!r.url||t.has(r.url)?!1:(t.add(r.url),!0))}function Pr(e){const t=ee(e);return t?[t]:[]}function yr(e){return{proxyEmFiles:!0,proxyAi:!1}}function Cr(e,t){const r=yr(t),n=t?.backendProxyPolicy;switch(e){case"emFiles":return n?.proxyEmFiles??r.proxyEmFiles;case"ai":return n?.proxyAi??r.proxyAi;default:return!0}}var Lr={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 Rr(e){const t=[],r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/\\\{([a-z_]+)\\\}/gi,(n,i)=>(t.push(i),`(${Lr[i]||".+"})`));return{regex:new RegExp(`^${r}$`,"i"),tokens:t}}function vr(e){return/[?#]/.test(e)||/\{(?:url|url_encoded|query|search|hash|fragment)\}/i.test(e)}function wr(e,t){if(vr(t))return e;try{const r=new URL(e);return`${r.origin}${r.pathname}`}catch{return e.split(/[?#]/)[0]||e}}function Mr(e,t,r){if(r.endsWith("_encoded"))return!0;const n=e.slice(0,t),i=n.lastIndexOf("#"),o=n.lastIndexOf("?"),s=n.lastIndexOf("&"),a=n.lastIndexOf("=");return a>Math.max(o,s)&&a>i}function jr(e){try{const t=new URL(e),r=t.pathname.replace(/^\/+/,""),n=t.search.replace(/^\?/,""),i=t.hash.replace(/^#/,""),o=r.replace(/^wp-json\/?/i,""),s=o?`/${o}`:"/",a=o.match(/^([^/]+)(?:\/([^/]+))?(?:\/(.*))?$/),c=a?.[1]||"",_=a?.[2]||"",l=a?.[3]||"";return{url:e,url_encoded:encodeURIComponent(e),origin:t.origin,origin_encoded:encodeURIComponent(t.origin),proxy_url:t.origin,proxy_url_encoded:encodeURIComponent(t.origin),path:r,pathname:r,path_with_slash:t.pathname||"/",pathname_with_slash:t.pathname||"/",query:n,search:t.search,hash:t.hash,fragment:i,pathname_after_wp_json:o,pathname_after_wp_json_with_slash:s,rest_namespace:c,rest_version:_,rest_route:l,rest_route_with_slash:l?`/${l}`:"/"}}catch{return}}function te(e,t){if(!e)return{};if(Array.isArray(e)){for(const a of e){const c=te(a,t);if(c!==void 0)return c}return}if(e==="*")return{};const r=wr(t,e),{regex:n,tokens:i}=Rr(e),o=n.exec(r);if(!o)return;const s={};return i.forEach((a,c)=>{s[`matched_${a}`]=o[c+1]||""}),s}function F(e,t,r={}){const n=jr(t);if(!n)return t;const i={...n,...r};let o="",s=0;const a=/\{([a-z_]+)\}/gi;let c;for(;c=a.exec(e);){o+=e.slice(s,c.index);const _=i[c[1]]??"",l=Mr(e,c.index,c[1])?encodeURIComponent(_):_;o+=l,s=c.index+c[0].length}o+=e.slice(s);try{const _=new URL(o),l=new URL(t);return!o.includes("{search}")&&!o.includes("{query}")&&l.search&&l.searchParams.forEach((E,h)=>{_.searchParams.has(h)||_.searchParams.append(h,E)}),!o.includes("{hash}")&&!o.includes("{fragment}")&&l.hash&&!_.hash&&(_.hash=l.hash),_.toString()}catch{return o}}function Pe(e,t){try{const r=new URL(t);return`${R(e)}/${r.pathname.replace(/^\//,"")}${r.search}${r.hash}`}catch{return t}}function ye(e,t){const r=R(e);return t?De(t)?t:t.startsWith("?")||t.startsWith("#")?`${r}${t}`:`${r}${t.startsWith("/")?"":"/"}${t}`:r}function Ce(e,t,r,n){const i=e.match;return i?Array.isArray(i)?i.some(o=>Ce({...e,match:o},t,r,n)):typeof i=="function"?!!i({url:t,method:n,requestType:r}):i==="*"?!0:te(i,t)!==void 0:!0}function Br(e,t,r,n="generic"){if(e==null)return[];const i=Array.isArray(e)?e:[e],o=[];return i.forEach((s,a)=>{if(!s)return;if(typeof s=="string"){const E=s.includes("{")&&s.includes("}")?F(s,t):Pe(s,t);o.push({key:`backend:${a}`,url:E,source:"resource"});return}if(!Ne(s)||!("rewrite"in s))return;const c=s;if(!Ce(c,t,n,r))return;const _=typeof c.match=="string"||Array.isArray(c.match)?te(c.match,t)||{}:{},l=typeof c.proxyBase=="string"&&c.proxyBase.trim()?c.proxyBase.trim():void 0;(Array.isArray(c.rewrite)?c.rewrite:[c.rewrite]).filter(Boolean).forEach((E,h)=>{const p=typeof E=="function"?(()=>{const g=E({url:t,proxyBase:l,method:r,requestType:n,..._}),O=l&&!De(g)?ye(l,g):g;return O.includes("{")&&O.includes("}")?F(O,t,_):O})():l?F(ye(l,E),t,_):E.includes("{")&&E.includes("}")?F(E,t,_):Pe(E,t);o.push({key:`backend:${c.id||"rule"}:${a}:${h}`,url:p,source:"resource"})})}),Nr(o)}function xr(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 Fr(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}!Ne(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 kr(e,t){return Pr(t).flatMap(r=>Fr(r)).filter(Boolean).some(r=>r&&e.startsWith(r))}function Ur(e,t){return!!ee(t)&&Cr(e,t)}function Gr(e,t={}){const r=t.requestType||xr(e);return Ur(r,t.config)?Br(ee(t.config),e,t.method,r):[]}function Xr(e,t={}){return kr(e,t.config)?[e]:Gr(e,t).map(r=>r.url)}function D(e){for(;e.endsWith("/");)e=e.slice(0,e.length-1);return/\/wp-json$/i.test(e)?e:`${e}/wp-json`}function Le(...e){const t=e.filter(o=>o!=null);if(t.length===0)return;if(t.length===1)return t[0];const r=t.find(o=>o.aborted);if(r)return r;if(typeof AbortSignal<"u"&&typeof AbortSignal.any=="function")return AbortSignal.any(t);const n=new AbortController,i=o=>{n.signal.aborted||n.abort(o.reason)};for(const o of t)o.addEventListener("abort",()=>i(o),{once:!0});return n.signal}var Re=3e5,ve=15e3,A=null,we=!1;function Hr(){return!0}function Vr(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_TTL_MS||"").trim();if(!e)return Re;const t=Number(e);return Number.isFinite(t)&&t>0?t:Re}function $r(){const e=String({}.REACT_APP_OPENAPI_FAILOVER_ATTEMPT_TIMEOUT_MS||"").trim();if(!e)return ve;const t=Number(e);return Number.isFinite(t)&&t>0?t:ve}function Wr(){const e="https://app.useblocks.io/api".trim();return e?D(e):void 0}function qr(e){const t=e.trim();if(!t)return[];if(t.startsWith("["))try{const r=JSON.parse(t);if(!Array.isArray(r))throw new Error("expected JSON array");return r.map(n=>String(n).trim()).filter(Boolean)}catch{return we||(we=!0),[]}return t.split(",").map(r=>r.trim()).filter(Boolean)}function Kr(e){const t=new Set,r=[];for(const n of e){const i=D(n);t.has(i)||(t.add(i),r.push(i))}return r}function Me(e){const t=String(e||"").trim();return t?D(t):Wr()}function je(e,t=[]){return e?Kr([e,...t]).slice(0,3):[]}function Be(){return qr(String({}.REACT_APP_OPENAPI_FAILOVER_BASE_URLS||"").trim())}function zr(e=Date.now()){return A?e-A.switchedAt>=Vr():!0}function xe(e=Date.now()){A&&zr(e)&&(A=null)}function N(e){if(!Hr())return!1;const t=Me(e);if(!t)return!1;const r=Be();return r.length===0?!1:je(t,r).length>1}function v(e){const t=Me(e);if(!t)return[];const r=Be();return r.length===0?[t]:je(t,r)}function k(e){const t=v(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 Fe(e){const t=v(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 ke(e){return k(e)||void 0}function Ue(e){const t=e||void 0;if(typeof AbortController>"u")return{signal:t,timeoutError:()=>{},done:()=>{}};const r=$r(),n=new AbortController;let i;const o=setTimeout(()=>{i=Jr(r),n.abort(i)},r);return{signal:Le(t,n.signal),timeoutError:()=>i,done:()=>clearTimeout(o)}}function Jr(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 Ge(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 He;function Yr(e){He=e}function U(e,t){if(!N(t))return;const r=v(t);if(r.length<=1)return;const n=r.indexOf(D(e));if(n<0)return;const i=n+1;if(i>=r.length)return;const o=r[i],s=A?.activeUrl;A={activeUrl:o,switchedAt:Date.now()},s!==o&&He?.()}function Ve(e,t){if(!N(t))return;const r=D(e),n=v(t);if(n.includes(r)){if(r===n[0]){A=null;return}A?.activeUrl!==r&&(A={activeUrl:r,switchedAt:Date.now()})}}function $e(){A=null}var Qr=e=>{const t=new FormData,r=(n,i,o)=>{if(i!=null){if(i instanceof Blob){n.append(o,i);return}if(Array.isArray(i)){i.forEach((s,a)=>{const c=o?`${o}[${a}]`:`${a}`;r(n,s,c)});return}if(typeof i=="object"){Object.keys(i).forEach(s=>{const a=i[s],c=o?`${o}[${s}]`:s;r(n,a,c)});return}n.append(o,String(i))}};return r(t,e),t},Zr={baseUrl:D("https://app.useblocks.io/api"),baseApiParams:{secure:!0,credentials:"same-origin",format:"json"},securityWorker:()=>({credentials:"same-origin"})},P=new Map;function en(e){const t=e?.getInstance(de);return t?t.get()??t.bootstrap():void 0}var tn=class extends Ht{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=en(this.container),n=this.container?.getInstance(Ee)!==void 0,i=Xr(e,{config:r,method:t,standalone:n}),o=i.length>0?i:[e],s=this.buildRequestKey(e,t),a=P.get(s);return!a||!o.includes(a)?o:[a,...o.filter(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,r=!1){const n={...e,baseUrl:t},i=this.buildRequestUrl(n),o=n.method||"GET",s=this.buildRequestKey(i,o),a=this.getBackendProxyCandidates(i,o);let c,_;for(const l of a){const E=p=>p===i?l:p,h=r?Ue(e.signal):void 0;try{const p=await super.request({...n,proxyHandler:E,...h?{signal:h.signal}:{}});if(!p.ok&&this.shouldRetryResponse(p)&&l!==a[a.length-1]){_=p,P.get(s)===l&&P.delete(s);continue}return P.set(s,l),p}catch(p){P.get(s)===l&&P.delete(s);const g=h?.timeoutError();if(g)throw g;if(c=p,(p instanceof DOMException||p instanceof Error)&&p.name==="AbortError")throw p}finally{h?.done()}}if(_)return _;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 r=this.resolveFailoverBaseUrl(),n=N(r),i=e.failoverAttemptTimeout??n,o=n?Fe(r):r?[k(r)]:[this.baseUrl].filter(Boolean);if(o.length===0)return this.requestOnOrigin(e,this.baseUrl);let s,a;for(let c=0;c<o.length;c++){const _=o[c],l=c===o.length-1;try{const E=await this.requestOnOrigin(e,_,i);if(!E.ok&&Ge(E.status)){if(a=E,!l){U(_,r);continue}break}return E.ok&&Ve(_,r),E}catch(E){if(!Xe(E))throw E;s=E,l||U(_,r)}}if(n&&$e(),a)return a;throw s instanceof Error?s:new Error("API origin failover chain failed")}};function We(e={},t){const r=new tn({...Zr,...e},t);return r.contentFormatters["multipart/form-data"]=Qr,r}var qe=f("rest.clientFactory"),rn=e=>{Kt(e);const t=We({customFetch:e.getInstance(J)?.execute||fetch},e);e.inject(Y,t)},Ke;(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})(Ke||(Ke={}));function w(e,t){if(e!==t){if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const r=Array.isArray(e),n=Array.isArray(t);if(r){if(!n)return!1;const a=e.length;if(t.length!==a)return!1;for(let c=0;c<a;c++)if(!w(e[c],t[c]))return!1}else if(n)return!1;const i=Object.keys(e),o=Object.keys(t),s=i.length;if(s!==o.length)return!1;for(let a=0;a<s;a++){const c=i[a];if(!t.hasOwnProperty(c)||!w(e[c],t[c]))return!1}}return!0}function nn(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(nn(r));return{exp:i.exp,createdAt:i.iat,data:i}}var re=f("plugin.auth.token"),Je=new WeakMap,on=3e4;function sn(e){let t;try{t=ze(e).exp}catch{return!0}return typeof t!="number"||!Number.isFinite(t)?!0:t*1e3<=Date.now()+on}function an(e,t,r,n){const i=Je.get(e);i&&(i.stale=!0);const o={stale:!1};Je.set(e,o),e.injectFactory(re,async(s,a)=>{if(o.stale)return"";try{let c=await a||void 0;if(!c){const _=e.getInstance(fe);_&&(c=await _)}return t?!c||sn(c)?await t(r,n,c):c:""}catch{return""}},!0)}var Ye=f("auth.oauthProvided"),Qe=new WeakMap;function Ze(e,t){const r=Qe.get(e)??{applied:!1};(!r.applied||r.getAuthToken!==t.getAuthToken||!w(r.user,t.user)||r.project!==t.project)&&(Qe.set(e,{applied:!0,getAuthToken:t.getAuthToken,user:t.user,project:t.project}),an(e,t.getAuthToken,t.user,t.project))}function et(e){if(e.getInstance(Ye))return;e.inject(Ye,!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(re)===void 0&&Ze(e,t);const i=await e.getInstanceAsync(re);i&&r.headers.set("authorization",`Bearer ${i}`)}})}var cn={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}}},tt="ERROR",un="useblocks",_n={em_color_scheme:"em_color_scheme",em_code_mode_pane_sizes:"em_code_mode_pane_sizes",em_preview_pane_sizes:"em_preview_pane_sizes",em_default_sizes:"em_default_sizes",em_pane_sizes:"em_pane_sizes",em_test_emails:"em_test_emails",em_menu_is_locked:"em_menu_is_locked",em_code_mode_settings:"em_code_mode_settings",em_folder_is_open:"em_folder_is_open",em_active_tab:"em_active_tab",em_ai_settings:"em_ai_settings",em_last_active_page:"em_last_active_page",em_layout_convert_never_suggest:"em_layout_convert_never_suggest",em_filemanager_v2:"em_filemanager_v2",em_projects_v2:"em_projects_v2",em_translations_v2:"em_translations_v2",em_defer_chrome:"em_defer_chrome",em_stripo_import:"em_stripo_import",em_guest_locale:"em_guest_locale"},ln="light",dn="dark",fn="(prefers-color-scheme: dark)",En={MESSAGE:"message",INIT_PREVIEW:"init_preview",UPDATE_PREVIEW:"update_preview",UPDATE_EDITOR:"update_editor",UPDATE_EDITOR_POSITION:"update_editor_position",UPDATE_SIDE_MENU_EDITOR:"update_side_menu_editor",SAVE_EMAIL:"saveEmail",SANDBOX_ELEMENT_SETTINGS_SET:"sandbox_element_settings_set",SANDBOX_IMAGE_RESET:"sandbox_image_reset",SANDBOX_NATIVE_IMAGE_DROP_CLEAR:"sandbox_native-image-drop-clear",SANDBOX_EMAIL_SETTINGS_SET:"sandbox_email_settings_set",SANDBOX_BLOCK_SETTINGS_SET:"sandbox_block_settings_set",SANDBOX_ELEMENT_PARENT_GET:"sandbox_element_parent_get",SANDBOX_ELEMENT_PARENT_TABLE_GET:"sandbox_element_parent_table_get",SANDBOX_ELEMENT_PREV_GET:"sandbox_element_prev_get",SANDBOX_ELEMENT_NEXT_GET:"sandbox_element_next_get",SANDBOX_ELEMENT_REMOVE:"sandbox_element_remove",SANDBOX_ELEMENT_ACTIVE_RESET:"sandbox_element_active_reset",SANDBOX_ELEMENT_ACTIVE_SET:"sandbox_element_active_set",SANDBOX_ELEMENT_HOVER_SET:"sandbox_element_hover_set",SANDBOX_ELEMENT_IMG_LINK:"sandbox_element_img_link",SANDBOX_ELEMENT_TEXT:"sandbox_element_text",SANDBOX_EMAIL_CONTENT_GET:"sandbox_email_content_get",SANDBOX_SET_POSITION_TO_IMG:"sandbox_set_position_to_img",SANDBOX_SET_POSITION_TO_LINK:"sandbox_set_position_to_link",SANDBOX_ACCORDION_ADD_SECTION:"sandbox_accordion_add_section",SANDBOX_ACCORDION_REMOVE_SECTION:"sandbox_accordion_remove_section",APPLICATION_FOCUS_IN_IFRAME:"application_focus_in_iframe",APPLICATION_EMAIL_SETTINGS_SET:"application_email_settings_set",APPLICATION_BLOCK_SETTINGS_SET:"application_block_settings_set",APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",_APPLICATION_ELEMENT_SETTINGS_SET:"application_element_settings_set",APPLICATION_ELEMENT_SETTINGS_CLOSE:"application_element_settings_close",APPLICATION_ACTION:"application_action",APPLICATION_EBLOCK_ADD:"application_eblock_add",SANDBOX_EBLOCK_SET_EM_BLOCK_ID:"sandbox_eblock_set_em_block_id",SANDBOX_GLOBAL_BLOCK_REPLACE:"sandbox_global_block_replace",APPLICATION_SCROLL_TO:"application_scroll-to",APPLICATION_SCROLL_BLOCK_SHOW:"application_scroll-block-show",APPLICATION_SCROLL_BLOCK_HIDE:"application_scroll-block-hide",APPLICATION_DISCUSS_SET_ID:"application_discuss_set_id",APPLICATION_DISCUSS_GET_COMMENT:"application_discuss_get_comment",APPLICATION_DISCUSS_NO_COMMENT:"application_discuss_no_comment",APPLICATION_DISCUSS_SAVE_TARGET:"application_discuss_save_target",APPLICATION_IFRAME_SET_HEIGHT:"application_iframe_set_height",APPLICATION_COMMON_STYLES_UPDATE:"application_commonStyles_update",APPLICATION_EMAIL_CONTENT_GET:"application_email_content_get",APPLICATION_OPEN_IMAGE_AI_POPUP:"application_open-image-ai-popup",APPLICATION_OPEN_IMAGE_UPLOAD_POPUP:"application_open-image-upload-popup",APPLICATION_OPEN_IMAGE_EDIT_POPUP:"application_open-image-edit-popup",APPLICATION_OPEN_IMAGE_GIF_POPUP:"application_open-image-gif-popup",APPLICATION_OPEN_IMAGE_STOCK_POPUP:"application_open-image-stock-popup",APPLICATION_CLOSE_IMAGE_EDIT_POPUP:"application_close-image-edit-popup",APPLICATION_NATIVE_IMAGE_DROP:"application_native-image-drop",APPLICATION_SUBJECT_UPDATE:"application_subject_update",APPLICATION_PREHEADER_UPDATE:"application_preheader_update",APPLICATION_DOMPARSER_ERROR:"application_domparser_error",APPLICATION_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_WINDOW_CHARACTERISTIC:"sandbox_window-characteristic",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_ADD_MERGETAG:"sandbox_add_mergetag",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"},rt=e=>{const t={current:Promise.resolve(),state:e,decorate:(r,n)=>(n&&(r=r.bind(n)),function(...i){const o=t.current.then(()=>r(...i));return t.current=o.then(s=>{t.state=s},s=>{}),o})};return t};function ne(e){return function(t){return{setOptions:()=>{},instance:{},dispose:()=>{},...e(t)||{}}}}function pn(e){return t=>{const r={},n=[];for(const s of e)n.push(s(t));for(const s of n)Object.assign(r,s.instance);return{instance:r,setOptions:async s=>{for(const a of n)await a.setOptions(s)},dispose:()=>{for(const s of n)s.dispose()}}}}function hn(e=tt){const t=new Error(e);return t.name="AuthPipelineError",t}async function On(e,t,r,n){const i=n?.attemptTimeout??N(r),o=N(r)?Fe(r):v(r).length>0?[k(r)]:[];if(o.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const s=e.startsWith("/")?e:`/${e}`;let a,c;for(let _=0;_<o.length;_++){const l=o[_],E=_===o.length-1,h=i?Ue(t.signal):void 0;try{const p=await fetch(`${l}${s}`,{...t,...h?{signal:h.signal}:{}});if(!p.ok&&Ge(p.status)){if(a=p,!E){U(l,r);continue}break}return p.ok&&Ve(l,r),p}catch(p){const g=h?.timeoutError();if(!g&&!Xe(p))throw p;c=g||p,E||U(l,r)}finally{h?.done()}}if(N(r)&&$e(),a)return a;throw c instanceof Error?c:new Error("[apiOriginFailover] fetch chain failed")}function nt(e){e.inject(C,void 0),e.inject(z,void 0)}var An=ne(e=>{let t,r;const n=rt();return e.addService(x,{execute:n.decorate(async(i,o)=>{if(o?.public||!t)return;const s=String(e.getInstance(z)||"").trim();if(s){i.headers.append("authorization",`Bearer ${s}`);return}if(!e.getInstance(C))try{const a=e.getInstance(qe),c=String(a?.getOptions()?.baseUrl||"").trim(),_=ke(r||c||void 0);if(!_)throw new Error("JWT auth requires baseUrl");const l=await On("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)},_);if(!l.ok)throw new Error(`JWT auth failed: ${l.status}`);const E=await l.json(),h=String(E.token||"").trim();if(!h)throw new Error("JWT auth failed: empty token");e.inject(C,void 0),e.inject(z,h),i.headers.append("authorization",`Bearer ${h}`)}catch{throw e.inject(C,tt),hn()}})}),{setOptions(i){const o=i.jwtAuth,s=String(i.baseUrl||"").trim()||void 0,a=!w(o,t),c=s!==r;if(t=o,r=s,!o){nt(e);return}a||c?nt(e):e.inject(C,void 0)}}}),gn=ne(e=>(et(e),{setOptions(t){Ze(e,t)}}));function In(e){return typeof CSS<"u"&&typeof CSS.escape=="function"?CSS.escape(e):e.replace(/([^a-zA-Z0-9_-])/g,"\\$1")}function ie(e,t=document){try{const n=t.querySelector(e);if(n)return n}catch{return null}const r=t.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;if(!i)continue;const o=ie(e,i);if(o)return o}return null}function it(e,t=[]){const r=e.querySelectorAll("*");for(let n=0;n<r.length;n++){const i=r[n]?.shadowRoot;i&&(t.push(i),it(i,t))}return t}function mn(e,t,r){if(e.isConnected)return e;const n=e.id?.trim();return n?ot(`#${In(n)}`,t,r):Promise.reject(S("Editor mount element was disconnected and has no id — pass a CSS selector or call init() again after the host remounts the container."))}function ot(e,t,r){if(q(r),typeof e<"u"){if(typeof e=="string"){const n=e,i=ie(n);if(i)return i;const o=t.addDisposable(new I);return new Promise((s,a)=>{const c=O=>{o.dispose(),O()},_=()=>{c(()=>a(S(r?.reason)))};if(r?.aborted){_();return}r?.addEventListener("abort",_),o.addDispose(()=>r?.removeEventListener("abort",_));const l=document.body??document.documentElement;if(!l){c(()=>a(S("Document is not ready to observe mount element")));return}const E=new Set,h=new MutationObserver(()=>{const O=ie(n);if(O){c(()=>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 G of it(O))p(G)};p(l),g(),o.addDispose(()=>h.disconnect())})}return e instanceof Element?mn(e,t,r):e}return e}var Tn=new Map;Object.defineProperty(u,"ADVANCED_SETTINGS_PANEL",{enumerable:!0,get:function(){return ur}}),Object.defineProperty(u,"APP_ID",{enumerable:!0,get:function(){return Lt}}),Object.defineProperty(u,"APP_LOAD_EVENT_ID",{enumerable:!0,get:function(){return Ut}}),Object.defineProperty(u,"ATOMS_HANDLERS_ID",{enumerable:!0,get:function(){return nr}}),Object.defineProperty(u,"AsyncEmitter",{enumerable:!0,get:function(){return B}}),Object.defineProperty(u,"BaseEmitter",{enumerable:!0,get:function(){return b}}),Object.defineProperty(u,"COMMON_STYLES",{enumerable:!0,get:function(){return cn}}),Object.defineProperty(u,"CONFIG_CHANGED_EVENT_ID",{enumerable:!0,get:function(){return Gt}}),Object.defineProperty(u,"CONFIG_SOURCE_ID",{enumerable:!0,get:function(){return de}}),Object.defineProperty(u,"COOKIE_MANAGER_ID",{enumerable:!0,get:function(){return fr}}),Object.defineProperty(u,"CUSTOM_FETCH_ID",{enumerable:!0,get:function(){return J}}),Object.defineProperty(u,"ContentType",{enumerable:!0,get:function(){return Xt}}),Object.defineProperty(u,"DARK",{enumerable:!0,get:function(){return dn}}),Object.defineProperty(u,"DISPOSABLE_ID",{enumerable:!0,get:function(){return Rt}}),Object.defineProperty(u,"DependencyResolver",{enumerable:!0,get:function(){return W}}),Object.defineProperty(u,"Disposable",{enumerable:!0,get:function(){return I}}),Object.defineProperty(u,"ELEMENT_MAP",{enumerable:!0,get:function(){return Tn}}),Object.defineProperty(u,"EVENT_TYPES",{enumerable:!0,get:function(){return En}}),Object.defineProperty(u,"Emitter",{enumerable:!0,get:function(){return Tt}}),Object.defineProperty(u,"HANDLE_ATOM_INSERT_ID",{enumerable:!0,get:function(){return ir}}),Object.defineProperty(u,"INIT_PIPELINE_ID",{enumerable:!0,get:function(){return vt}}),Object.defineProperty(u,"INSTANCE_ID",{enumerable:!0,get:function(){return wt}}),Object.defineProperty(u,"JWTMixin",{enumerable:!0,get:function(){return An}}),Object.defineProperty(u,"LATE_SURFACE_LISTENERS_ID",{enumerable:!0,get:function(){return Mt}}),Object.defineProperty(u,"LIGHT",{enumerable:!0,get:function(){return ln}}),Object.defineProperty(u,"LOCAL_STORAGE_ITEMS",{enumerable:!0,get:function(){return _n}}),Object.defineProperty(u,"MESSAGE_SERVICE_ID",{enumerable:!0,get:function(){return ar}}),Object.defineProperty(u,"MODAL_CLOSE_EVENT",{enumerable:!0,get:function(){return lr}}),Object.defineProperty(u,"MODAL_SHOW_EVENT",{enumerable:!0,get:function(){return _r}}),Object.defineProperty(u,"MODAL_UPDATE_EVENT",{enumerable:!0,get:function(){return dr}}),Object.defineProperty(u,"MessageService",{enumerable:!0,get:function(){return rr}}),Object.defineProperty(u,"OAuthMixin",{enumerable:!0,get:function(){return gn}}),Object.defineProperty(u,"OPTIONS_SOURCE_ID",{enumerable:!0,get:function(){return le}}),Object.defineProperty(u,"PLUGIN_COLLECTION_ID",{enumerable:!0,get:function(){return kt}}),Object.defineProperty(u,"PORT_READY",{enumerable:!0,get:function(){return Oe}}),Object.defineProperty(u,"PREFERS_COLOR_SCHEME_DARK",{enumerable:!0,get:function(){return fn}}),Object.defineProperty(u,"PUBLIC_REQUEST",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(u,"REQUEST_HANDLER_ID",{enumerable:!0,get:function(){return x}}),Object.defineProperty(u,"REST_CLIENT_FACTORY_ID",{enumerable:!0,get:function(){return qe}}),Object.defineProperty(u,"REST_TRANSPORT_ID",{enumerable:!0,get:function(){return Y}}),Object.defineProperty(u,"SANDBOX_EXTENSIONS_ID",{enumerable:!0,get:function(){return or}}),Object.defineProperty(u,"SANDBOX_EXTENSION_SCRIPT_STATUS_ID",{enumerable:!0,get:function(){return sr}}),Object.defineProperty(u,"SECURITY_MODULE_ID",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(u,"SETTINGS_PANEL_EVENT",{enumerable:!0,get:function(){return cr}}),Object.defineProperty(u,"STANDALONE_ACTIVATED_ID",{enumerable:!0,get:function(){return xt}}),Object.defineProperty(u,"STANDALONE_BOOTSTRAP_TOKEN_ID",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(u,"STANDALONE_FILE_PROXY_REGISTERED_ID",{enumerable:!0,get:function(){return Ft}}),Object.defineProperty(u,"STANDALONE_PROJECT_ID",{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(u,"STORE_ID",{enumerable:!0,get:function(){return jt}}),Object.defineProperty(u,"Signal",{enumerable:!0,get:function(){return St}}),Object.defineProperty(u,"TEMPLATE_DIRECTIVES_ID",{enumerable:!0,get:function(){return Er}}),Object.defineProperty(u,"USEBLOCKS",{enumerable:!0,get:function(){return un}}),Object.defineProperty(u,"combineMixins",{enumerable:!0,get:function(){return pn}}),Object.defineProperty(u,"composeAbortSignals",{enumerable:!0,get:function(){return Le}}),Object.defineProperty(u,"createAbortError",{enumerable:!0,get:function(){return S}}),Object.defineProperty(u,"createIdentifier",{enumerable:!0,get:function(){return Qt}}),Object.defineProperty(u,"createIdentifier$1",{enumerable:!0,get:function(){return f}}),Object.defineProperty(u,"createQueue",{enumerable:!0,get:function(){return rt}}),Object.defineProperty(u,"createTransport",{enumerable:!0,get:function(){return We}}),Object.defineProperty(u,"debounce",{enumerable:!0,get:function(){return Nt}}),Object.defineProperty(u,"decodeJwt",{enumerable:!0,get:function(){return ze}}),Object.defineProperty(u,"deepEqual",{enumerable:!0,get:function(){return w}}),Object.defineProperty(u,"defineMixin",{enumerable:!0,get:function(){return ne}}),Object.defineProperty(u,"events",{enumerable:!0,get:function(){return K}}),Object.defineProperty(u,"filter",{enumerable:!0,get:function(){return Dt}}),Object.defineProperty(u,"generateUUID",{enumerable:!0,get:function(){return ce}}),Object.defineProperty(u,"getActiveBaseUrl",{enumerable:!0,get:function(){return k}}),Object.defineProperty(u,"getApi",{enumerable:!0,get:function(){return zt}}),Object.defineProperty(u,"getEmitter",{enumerable:!0,get:function(){return Ct}}),Object.defineProperty(u,"getEmitter$1",{enumerable:!0,get:function(){return Pt}}),Object.defineProperty(u,"getEvent",{enumerable:!0,get:function(){return yt}}),Object.defineProperty(u,"getServiceContainerId",{enumerable:!0,get:function(){return M}}),Object.defineProperty(u,"isAbortError",{enumerable:!0,get:function(){return It}}),Object.defineProperty(u,"mapHttpStatusToErrorCode",{enumerable:!0,get:function(){return gt}}),Object.defineProperty(u,"mergeBackendProxyLayers",{enumerable:!0,get:function(){return mr}}),Object.defineProperty(u,"mergeResourceProxyLayers",{enumerable:!0,get:function(){return Ir}}),Object.defineProperty(u,"mergeResourceProxyPolicyLayers",{enumerable:!0,get:function(){return Dr}}),Object.defineProperty(u,"mergeShallowConfigLayers",{enumerable:!0,get:function(){return ge}}),Object.defineProperty(u,"provideOAuth",{enumerable:!0,get:function(){return et}}),Object.defineProperty(u,"raceWithAbortSignal",{enumerable:!0,get:function(){return mt}}),Object.defineProperty(u,"registerRestTransport",{enumerable:!0,get:function(){return rn}}),Object.defineProperty(u,"releaseContainer",{enumerable:!0,get:function(){return Or}}),Object.defineProperty(u,"resolveContainer",{enumerable:!0,get:function(){return ft}}),Object.defineProperty(u,"resolveExplicitApiBaseUrl",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(u,"setApiOriginFailoverHook",{enumerable:!0,get:function(){return Yr}}),Object.defineProperty(u,"snapshot",{enumerable:!0,get:function(){return bt}}),Object.defineProperty(u,"throwIfAborted",{enumerable:!0,get:function(){return q}}),Object.defineProperty(u,"waitForElement",{enumerable:!0,get:function(){return ot}})});
2076
2076
 
2077
2077
 
2078
- __useblocks__.define("useblocks.js",["require","exports","module","static/umd/add4df98.js"],function(mo,K,Wp){Object.defineProperties(K,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var En=Object.defineProperty,bn=(e,t)=>{let n={};for(var r in e)En(n,r,{get:e[r],enumerable:!0});return t||En(n,Symbol.toStringTag,{value:"Module"}),n};const a=mo("./static/umd/add4df98.js");var ho=new Function("url","return import(url)");function go(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Eo(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function bo(e){return e.type==="umd"||e.resolve==="registry"}function Xp(e){return e}var vo=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(Eo(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(bo(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await ho(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,r.onload=()=>t(),r.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(r)})}initSync(e){const t=[];for(const n of e){const r=this._getOrCreate(n,void 0);t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const{ctor:s,options:o}=await this._resolveEntry(r),i=this._getOrCreate(s,o);n.has(i)||(n.add(i),t.push(i))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const i of e){const c=await this._resolveEntry(i);t.add(c.ctor),n.push(c)}const r=[];this._map.forEach((i,c)=>{t.has(c)||r.push({key:c,plugin:i})});for(let i=r.length-1;i>=0;i--){const{key:c,plugin:l}=r[i];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(c),this._optionsMap.delete(c),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const u=this._creationOrder.indexOf(l);u>=0&&this._creationOrder.splice(u,1)}const s=[],o=new Set;for(const{ctor:i,options:c}of n){const l=this._getOrCreate(i,c);o.has(l)||(o.add(l),s.push(l))}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 c=()=>{i||(i=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,c),r())};this._pluginRegistry.on(e,c),n!==void 0&&n>0&&(o=setTimeout(()=>{i||(i=!0,this._pluginRegistry.off(e,c),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)}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);try{return go(e)?new e(this._context,t):e(this._context,t)||{}}finally{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});try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(s){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:s})}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(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)}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)}))}},_o=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)}}}},yo=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()}},vn=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 So(e,t){return t+e}function wo(){return typeof performance>"u"?Date.now():So(performance.now(),performance.timeOrigin)}var Io="emailmaker:diagnostics",To="diagnostics",Ao="diagnostics";function _n(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Ao}=1`:e}var nt;function Co(){try{const e=new URLSearchParams(window.location.search).get(To);return e===null?void 0:e!=="0"}catch{return}}function Po(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Do(){try{const e=window.localStorage.getItem(Io);return e===null?void 0:e==="1"}catch{return}}function _e(){return nt===void 0&&(nt=typeof window>"u"?!1:Co()??Po()??Do()??!1),nt}function Ro(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var z={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"},Jp=Object.values(z),Qp=[z.canvasPainted,z.canvasSettled,z.appVisible,z.editorVisible],Oo=5e3,Lo=3e3,yn="diagnosticsStore",Me,ye;function Sn(){return{marks:new vn(Oo),resources:new vn(Lo)}}function wn(){if(ye)return ye;const e=rt();return e?(ye=e[yn]??Me??Sn(),e[yn]=ye,Me=void 0,ye):(Me??=Sn(),Me)}function U(e,t){_e()&&wn().marks.push({phase:e,at:wo(),...t})}function rt(){if(typeof __useblocks__<"u"&&__useblocks__)return __useblocks__;if(typeof window>"u")return;const e=window[Ro()];return e!==null&&typeof e=="object"?e:void 0}function No(e){const t=e.length,n=wn();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Mo(){const e=rt();return!e||!Array.isArray(e.diagnosticsBuffer)?0:No(e.diagnosticsBuffer)}var xo="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function st(){const e=new Error(xo);return e.name="DestroyedInstanceError",e}function ot(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((c,l)=>ot(c,i[l]))}const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&ot(e[o],t[o]))}function In(e,t){const n={watch(r){let s,o=!1;return e.watch(i=>{const c=t(i);o&&ot(s,c)||(s=c,o=!0,r(c))})},select(r){return In(n,r)}};return n}function pe(...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 In(s,o)}};return s}var Tn=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:a.ContentType.UrlEncoded,...t})},An=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 ko(e){return String(e||"").trim()||void 0}var Fo=class extends a.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=ko(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)}},it=a.createIdentifier$1("AppInitService");function Bo(e){return async()=>{const t=await e();return(await new Tn(t).app_init_create({})).data}}function jo(e){e.injectFactory(it,()=>{const t=new Fo({options:e.getInstance(a.OPTIONS_SOURCE_ID),isStandalone:()=>!!e.getInstance(a.SECURITY_MODULE_ID),resolveRestBaseUrl:n=>n?a.getActiveBaseUrl(n):a.getActiveBaseUrl()||void 0,setRestBaseUrl:n=>{e.getInstance(a.REST_CLIENT_FACTORY_ID)?.setOptions(n?{baseUrl:n}:{})},fallbackAppInit:Bo(()=>e.getInstanceAsync(a.REST_TRANSPORT_ID)),publish:n=>{e.inject(a.APP_ID,n)}});return e.getInstance(a.DISPOSABLE_ID)?.addDisposable(t),t},!0)}var at=a.createIdentifier$1("documentSession.emailDocuments");function lt(e){return e?.getInstance(at)}var Uo=a.createIdentifier$1("RevisionServiceFlag");function Ho(e){return e.getOrCreateInstance(Uo,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Cn(e){return Ho(e).isEnabled()}var $o=a.createIdentifier$1("EmailRightsResolver");function Go(e,t){const n=e.getInstance($o);return n?n(t):!0}var Pn=a.createIdentifier$1("EmailHistoryAvailabilityResolver");function Vo(e){return e.getInstance(Pn)!==void 0}async function Yo(e){const t=e.getInstance(Pn);if(!t)return!0;try{return await t()}catch{return!1}}var ct={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Dn=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],Rn=2e4,qo=Dn.reduce((e,t)=>e+ct[t],0),On=Rn+qo+3e3;function zo(e){return Dn.reduce((t,n)=>t+Ln(n,e),0)}function Ln(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:ct[e]}function Nn(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:On}function Mn(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:Rn}function xn(e=On){return e+3e3}var Zp="[show-pipeline]";function em(e,t){}var Ko=()=>xn();function Wo(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function Xo(e){return t=>Wo(e.getOrCreateInstance(a.events.BEFORE_SAVE_EMAIL,()=>new a.AsyncEmitter).fire(t),Ko())}function Jo(e){return e!=null&&e!==""}var Qo;function xe(e,t){return Qo?.capture(e,t)}function Zo(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function ke(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var J=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} "${ke(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${ke(this.oldText)}")`:`(replace@${this.oldPosition} "${ke(this.oldText)}" with "${ke(this.newText)}")`}};function kn(e,t){return e===null||e.length===0?t:new ei(e,t).compress()}var ei=class te{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),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[l,u]=te._splitCurr(s,r.newPosition-s.oldPosition);this._acceptCurr(l),s=u;continue}if(r.newPosition<s.oldPosition){const[l,u]=te._splitPrev(r,s.oldPosition-r.newPosition);this._acceptPrev(l),r=u;continue}let i,c;if(s.oldEnd===r.newEnd)i=r,c=s,r=this._getPrev(++t),s=this._getCurr(++n);else if(s.oldEnd<r.newEnd){const[l,u]=te._splitPrev(r,s.oldLength);i=l,c=s,r=u,s=this._getCurr(++n)}else{const[l,u]=te._splitCurr(s,r.newLength);i=r,c=l,r=this._getPrev(++t),s=u}this._result[this._resultLen++]=new J(i.oldPosition,i.oldText,c.newPosition,c.newText),this._prevDeltaOffset+=i.newLength-i.oldLength,this._currDeltaOffset+=c.newLength-c.oldLength}const o=te._merge(this._result);return te._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=te._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=te._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new J(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new J(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 J(t.oldPosition,t.oldText,t.newPosition,r),new J(t.oldEnd,"",t.newPosition+n,s)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),s=t.oldText.substr(n);return[new J(t.oldPosition,r,t.newPosition,t.newText),new J(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 J(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 ti(e){return new J(e.newPosition,e.newText,e.oldPosition,e.oldText)}function ni(e){return e.map(ti)}function Fn(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function ri(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 si(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 c=o.oldPosition;if(s&&c===e.start)r+=n==="after"?i:0;else{if(e.start<c&&c<e.end)return null;c<=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}}var Fe=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Bn=0,oi=Math.random().toString(36).slice(2,8);function ii(){return Bn+=1,`doc-${oi}-${Bn}`}function ai(e){const t=e.createBuffer(),n=e.docId??ii();let r=e.serverId??null,s=0,o=null,i=e.attributes??{};const c=new Set;let l=!1,u=!1,d;const p=new Set;let m=null;const b=()=>(m?.version!==s&&(m={version:s,value:t.read()}),m.value),y=E=>Object.entries(E).some(([g,v])=>i[g]!==v);return{get:()=>({docId:n,serverId:r,version:s,savedVersion:o,attributes:i}),getContent:b,mutate(E,{source:g}){if(l)return s;const v=E.changes?.length?E.changes:void 0,_=v?ri(b(),v):E.content!==void 0?E.content:void 0,w=_!==void 0&&_!==b(),P=E.attributes!==void 0&&y(E.attributes);if(!w&&!P)return s;const D=!(s>(o??-1));return w&&t.write(_),P&&(i={...i,...E.attributes}),s+=1,g!=="user"&&D&&(o=s),c.forEach(h=>h({source:g,version:s,changes:v})),s},markSaved(E,g){const v={serverId:r,savedVersion:o};g!==void 0&&(r=g),(o===null||E>o)&&(o=E),(v.serverId!==r||v.savedVersion!==o)&&c.forEach(_=>_({source:"system",version:s}))},markReady(){u||d!==void 0||(u=!0,p.forEach(E=>E.resolve()),p.clear(),c.forEach(E=>E({source:"system",version:s})))},isReady:()=>u,markFailed(E){u||d!==void 0||l||(d=E,p.forEach(g=>g.reject(new Fe(E))),p.clear(),c.forEach(g=>g({source:"system",version:s})))},failure:()=>d,whenReady(){return u?Promise.resolve():d!==void 0?Promise.reject(new Fe(d)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((E,g)=>{p.add({resolve:E,reject:g})})},subscribe(E){return c.add(E),()=>c.delete(E)},isNew:()=>r===null,isDirty:()=>s>(o??-1),isDisposed:()=>l,dispose(){l=!0,p.forEach(E=>E.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),p.clear(),c.clear(),t.dispose()}}}var li=500,ci=100,dt=0;function di(e,t={}){const n=t.groupIntervalMs??li,r=t.maxSteps??ci,s=t.now??(()=>0);let o=[],i=0,c=dt+=1,l=null,u=!1,d=!1,p=!1;const m=new Set,b=()=>m.forEach(h=>h()),y=(h,I)=>{if(h.length){d=!0;try{e.mutate({changes:h},{source:I})}finally{d=!1}}},E=h=>y(h,"user"),g=h=>{const I=s();u&&l!==null&&I-l<n?o[i-1]=kn(o[i-1],h):(o=o.slice(0,i),o.push(h),i=o.length,u=!0,o.length>r&&(o=o.slice(o.length-r),i=o.length,c=dt+=1)),l=I,b()},v=()=>{u=!1,l=null},_=h=>{if(!h.length)return;const I=o.length>i;I&&(o=o.slice(0,i)),i>0&&(o[i-1]=kn(o[i-1],h)),v(),I&&b()},w=e.subscribe(({source:h,changes:I})=>{if(!(p||d||!I?.length)){if(h==="remote"){P();return}if(h!=="user"){_(I);return}g(I)}}),P=()=>{o=[],i=0,v(),c=dt+=1,b()},D=()=>{if(i===0)return!1;const h=ni(o[i-1]);return Fn(e.getContent(),h)?(E(h),i-=1,v(),!0):(o=o.slice(0,i-1),i=o.length,v(),b(),!1)};return{canUndo:()=>i>0,canRedo:()=>i<o.length,undo(){D()&&b()},redo(){if(!(i>=o.length)){if(!Fn(e.getContent(),o[i])){o=o.slice(0,i),v(),b();return}E(o[i]),i+=1,v(),b()}},clear:P,applyWithoutHistory(h){const I=e.get().version;if(y(h,"system"),e.get().version===I){v();return}_(h)},getPast:h=>o.slice(0,i).reverse().slice(0,h),getFuture:h=>o.slice(i).reverse().slice(0,h),createSnapshot:()=>({stackId:c,index:i}),restoreSnapshot(h){if(h.stackId!==c||h.index>i)return!1;for(;i>h.index;)if(!D())return b(),!1;return b(),!0},subscribe(h){return m.add(h),()=>m.delete(h)},dispose(){p=!0,w(),m.clear(),o=[],i=0}}}var ui=["edit","move","resize","insert"];function ut(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function fi(e){return typeof e=="string"?e:null}function pi(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function mi(e){return ui.includes(e)?e:null}function hi(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:fi(t.originId),changeId:ut(t.changeId),rev:ut(t.rev),baseRev:ut(t.baseRev),expected:pi(t.expected),intent:mi(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var jn=class extends Error{reason;constructor(e){super(`сохранение не состоялось: ${e}`),this.name="SaveRefusedError",this.reason=e}},Un="draft";function Se(e){return e==null||e===""?Un:String(e)}function gi(e){return e==null||e===""?`${ft}${Un}`:`${ft}${String(e)}`}var ft="block:";function ne(e){return e?.startsWith(ft)===!0}function we(e){return ne(e.sessionKey())?void 0:e.current()}function tm(e,t){}function Ie(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return U(`show:gate:${e}`,{kind:"wait"}),t.then(s=>(U(`show:gate:${e}:end`,{kind:"wait"}),s),s=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw`${e}`,{error:String(s),...n},s})}var nm=5e3;function Hn(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function $n(e,{freshSince:t}={}){return!(!e?.slug?.includes("autosave")||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Ei(e,t={}){const n=Hn((e??[]).filter(r=>r?.html?.trim()));return $n(n,t)?n:null}function bi(e){const t=Date.parse(Hn(e)?.modified??"");return{autosave:Ei(e),...Number.isFinite(t)?{latestAt:t}:{}}}function vi({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Gn=e=>e.replace(/\r\n?/g,`
2079
- `),Vn=["recovery","plugin","rest"],_i=["subject","preheader"];function yi(e){let t={},n;for(let s=Vn.length-1;s>=0;s--){const o=e.get(Vn[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 _i){const o=r?.[s];typeof o=="string"&&o!==""&&(t={...t,[s]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Yn(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Gn(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 J(0,n,0,r)]}:{}},{source:"remote"})}var qn=e=>typeof e=="string"?e.trim():"";function Si(e,t,n){const{version:r,attributes:s}=e.get(),o=s,i=qn(o.title)||qn(o.subject);return{version:r,payload:{html:e.getContent(),title:i,subject:o.subject,preheader:o.preheader,description:o.description,common_styles:o.common_styles||"",meta:o.meta,utm_parameters:o.utm_parameters,parent_email:o.parent_email,is_template:o.is_template||!1,is_inited:o.is_inited,tags:o.tags,emailtags:o.emailtags,group:o.group,renderGuid:e.get().docId,project:t.project??o.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source}}}async function wi(e,t,n,r,s){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)}function re(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=re(s)),n[r]=s)}return n}var Ii=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function zn(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Ii.has(t))):{}}function Be(e,t,n={}){e&&e.mutate({attributes:Ti(e.get().attributes,t)},{source:n.source??"user"})}function Ti(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function pt(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Ai(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Kn(e){if(!e)return null;const t=zn(e);return e.common_styles!==void 0&&(t.common_styles=Ai(e.common_styles)),pt(e.html,t)}function Wn(e){return e?pt(e.html,re(zn(e))):null}var Ci=["common_styles","subject","preheader","meta"];function Xn(e){if(!e?.html?.trim())return null;const t={};for(const n of Ci)Pi(n,e[n])&&(t[n]=e[n]);return pt(e.html,t)}function Pi(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 Di=10,Ri=(e,t)=>e.key===t.key&&Oi(e.serverId,t.serverId),Oi=(e,t)=>e==null||e===t;function Li(e){return typeof e?.then=="function"}var Jn=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},Qn=e=>{e.request.serverId!=null&&e.document.markSaved(e.document.get().version)},Ni=e=>{Yn(e.document,yi(e.reports)),Qn(e)},mt=(e,t)=>{if(!e.ready){Ni(e);return}Yn(e.document,t)},Mi=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 xi(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:s,resolveTerms:o,canEdit:i,notifyBeforeSave:c,onAdapterError:l,onTimeout:u}=e;let d;const p=new Set,m=new Set,b=()=>p.forEach(f=>f()),y=(f,S)=>{if(!(f.closed||f.ready)){if(f.error!==void 0){f.document.markFailed(f.error),f.document.get().docId;return}Qn(f),f.ready=!0,f.document.markReady(),f.document.get().docId,[...f.reports.keys()]}},E=(f,S,T)=>{l?.(S.id,T),!(!S.required||f.closed)&&(f.error=T,f.document.get().docId,S.id,b())},g=(f,S)=>{const T=new Set(S.map(C=>C.id));S.forEach(C=>{C.watch&&f.watchers.push(C.watch(L=>f.closed?!1:f.ready&&L?.content!==void 0&&vi({hasUnsavedUserEdit:f.document.isDirty()})==="skip"?(f.document.get().docId,C.id,!1):(L&&f.reports.set(C.id,L),mt(f,L),!0)))});const A=(C,L)=>{f.closed||(L&&f.reports.set(C.id,L),mt(f,L))},O=()=>{T.size>0||f.closed||(Jn(f),y(f,[]))},x=[];if(S.forEach(C=>{let L;try{L=C.load()}catch(H){E(f,C,H),T.delete(C.id);return}if(Li(L)){x.push({id:C.id,required:C.required,load:()=>L});return}A(C,L),T.delete(C.id)}),x.length===0){O();return}f.timer=setTimeout(()=>{f.timer=void 0,u?.([...T]),f.document.get().docId,[...T],y(f,[...T])},n),f.timer.unref?.(),x.forEach(C=>{C.load().then(L=>A(C,L)).catch(L=>{E(f,C,L)}).finally(()=>{T.delete(C.id),O()})})},v=async(f,S,T)=>{if(T==="snapshot"||T==="anchor")return;const A=o?.();if(A)return A.resolve({project:S.project??f.project,tags:(f.tags??[]).map(O=>({name:O}))})},_=f=>{if(f.lock===!0&&i?.(f)===!1)return new jn("locked");const S=f.tags?.length??0,T=f.emailtags?.length??0;if(Math.max(S,T)>Di)return new jn("too-many-tags")},w=async(f,S,T)=>{try{await f.document.whenReady()}catch(L){return f.saveError=L,f.saveFailures+=1,f.saveFailures,!1}if(f.closed)return!1;const A=_(f.document.get().attributes);if(A)return f.saveError=A,f.saveFailures+=1,A.reason,b(),!1;if(c&&(await c(Mi(f)).catch(()=>{}),f.closed))return!1;let O;try{O=await v(f.document.get().attributes,T,S)}catch(L){return f.saveError=L,f.saveFailures+=1,f.saveFailures,b(),!1}if(f.closed)return!1;const{payload:x,version:C}=Si(f.document,T,O);f.document.get().docId;try{const L=f.document.get().serverId!=null,H=await wi(r(),s(f.request.key),S,f.document.get().serverId,x);if(f.closed)return!0;let k;if(S==="snapshot"||S==="anchor"){const N=H?.modified!=null?Date.parse(H.modified):NaN;k=Number.isFinite(N)?N:Date.now(),f.snapshotVersion=C,f.lastRevisionAt=k}else f.document.markSaved(C,H?.id!=null?String(H.id):void 0);const V=f.document.get().serverId;!L&&V!=null&&(f.recoveryFacts={emailId:V,historyLoaded:!0,isRecovering:!1}),f.saveError=void 0,f.saveFailures=0,f.document.get().serverId,b();const ae={intent:S,serverId:f.document.get().serverId,created:!L,...k!==void 0?{revisionAt:k}:{}};return m.forEach(N=>N(ae)),!0}catch(L){return f.saveError=L,f.saveFailures+=1,f.saveFailures,b(),!1}},P=()=>{d&&(d.closed=!0,d.watchers.forEach(f=>f()),d.watchers=[],Jn(d),d.history.dispose(),d.document.dispose(),d=void 0)},D=(f,S,T)=>{let A=!1;S.show&&(f.show?.id!==S.show.id||f.show.token!==S.show.token)&&(f.show=S.show,A=!0,{docId:f.document.get().docId,...S.show});const O=T==="show"?Wn(S.patch):null;O&&(f.reports.set("plugin",O),mt(f,O)),A&&b()},h=(f,S={})=>{const T=d;return!T||T.closed?Promise.resolve(!1):T.saving?f==="snapshot"?Promise.resolve(!1):(T.inFlight??Promise.resolve(!1)).then(()=>h(f,S)):(T.saving=!0,T.inFlight=w(T,f,S).finally(()=>{T.saving=!1,T.inFlight=void 0}),T.inFlight)},I=(f,S="open")=>{if(d&&!d.closed&&S!=="new"&&Ri(d.request,f))return D(d,f,S),d.document;P();const T=ai({createBuffer:()=>Zo(""),serverId:f.serverId??null}),A={request:f,show:f.show,document:T,history:di(T,{now:Date.now}),watchers:[],saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return d=A,T.get().docId,f.serverId,g(A,t(f,{publishRecoveryFacts(O){A.closed||(A.recoveryFacts=O,b())},readShownContent:()=>A.closed?null:A.document.getContent()})),b(),T};return{openWith:I,open:(f,S={})=>I({key:Se(f),serverId:f,email:S.email,patch:S.patch,show:S.show},"open"),openDraft:(f,S={})=>I({key:Se(void 0),serverId:null,email:f,patch:S.patch,show:S.show},"open"),startNewDraft:(f,S={})=>I({key:Se(void 0),serverId:null,email:f,patch:S.patch,show:S.show},"new"),reload:(f,S={})=>I({key:Se(f),serverId:f,email:S.email,patch:S.patch,show:S.show},"new"),openBlock:(f,S)=>I({key:ne(f)?f:gi(f),serverId:S?.id!=null?String(S.id):null,email:S},"open"),show:(f,S)=>{const T=d;if(!(!T||T.closed))return I({...T.request,patch:f,show:S},"show")},current:()=>d?.document,save:h,saveState:()=>({error:d?.saveError,failures:d?.saveFailures??0,saving:d?.saving===!0}),revisionFacts(){if(!d)return;const f=d.revisionFactsSnapshot;return f&&f.snapshotVersion===d.snapshotVersion&&f.lastRevisionAt===d.lastRevisionAt?f:(d.revisionFactsSnapshot={snapshotVersion:d.snapshotVersion,lastRevisionAt:d.lastRevisionAt},d.revisionFactsSnapshot)},recoveryFacts:()=>d?.recoveryFacts,history:()=>d?.history,forcedHeaders:()=>d?.forcedHeaders,beginForcedHeaders(f){d&&!d.closed&&(d.forcedHeaders=f)},endForcedHeaders(){d&&(d.forcedHeaders=void 0)},onSaved(f){return m.add(f),()=>m.delete(f)},showFacts:()=>d?.show,sessionKey:()=>d?.request.key,openError:()=>d?.error,subscribe(f){return p.add(f),()=>p.delete(f)},close(){d&&(P(),b())}}}var Zn=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function er(e){if(e instanceof Zn)return e.reason;if(e instanceof Fe)return er(e.reason)}function ki(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new Zn("not-found");return Kn(n)}}}var tr=a.createIdentifier$1("EmailPort");function Fi(e){return e.getInstance(tr)}function Bi(e,t){e.inject(tr,t)}var nr=a.createIdentifier$1("documentSession.restEmailPortFactories");function rr(e){return e.getInstance(nr)!==void 0}function le(e){const t=e.getInstance(nr);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var ji=a.createIdentifier$1("EmailTermsResolver");function Ui(e){return e.getInstance(ji)}var sr=a.createIdentifier$1("EmailHistoryPort"),Hi=a.createIdentifier$1("BlockHistoryPort");function or(e){return e.getInstance(Hi)}function ir(e){return e.getInstance(sr)}function $i(e,t){e.inject(sr,t)}var Gi="em_autosave_pending",rm=6e4;function je(e){return`${Gi}_${e}`}function Vi(e,t){try{sessionStorage.setItem(je(e),JSON.stringify(t))}catch{}}function Yi(e){try{const t=sessionStorage.getItem(je(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(je(e)),null):n}catch{return null}}function Ue(e){try{sessionStorage.removeItem(je(e))}catch{}}var qi=2e3,zi=5e3,Ki=5,Wi=5e3,Xi=4;function Ji(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function Qi(e,t){return e==null||t==null?!1:e.replaceAll(`\r
2078
+ __useblocks__.define("useblocks.js",["require","exports","module","static/umd/993c2c90.js"],function(_o,K,lm){Object.defineProperties(K,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var In=Object.defineProperty,Tn=(e,t)=>{let n={};for(var r in e)In(n,r,{get:e[r],enumerable:!0});return t||In(n,Symbol.toStringTag,{value:"Module"}),n};const a=_o("./static/umd/993c2c90.js");var yo=new Function("url","return import(url)");function So(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function wo(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Io(e){return e.type==="umd"||e.resolve==="registry"}function cm(e){return e}var To=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(wo(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(Io(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await yo(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,r.onload=()=>t(),r.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(r)})}initSync(e){const t=[];for(const n of e){const r=this._getOrCreate(n,void 0);t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const{ctor:s,options:o}=await this._resolveEntry(r),i=this._getOrCreate(s,o);n.has(i)||(n.add(i),t.push(i))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const i of e){const c=await this._resolveEntry(i);t.add(c.ctor),n.push(c)}const r=[];this._map.forEach((i,c)=>{t.has(c)||r.push({key:c,plugin:i})});for(let i=r.length-1;i>=0;i--){const{key:c,plugin:l}=r[i];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(c),this._optionsMap.delete(c),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const u=this._creationOrder.indexOf(l);u>=0&&this._creationOrder.splice(u,1)}const s=[],o=new Set;for(const{ctor:i,options:c}of n){const l=this._getOrCreate(i,c);o.has(l)||(o.add(l),s.push(l))}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 c=()=>{i||(i=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,c),r())};this._pluginRegistry.on(e,c),n!==void 0&&n>0&&(o=setTimeout(()=>{i||(i=!0,this._pluginRegistry.off(e,c),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)}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);try{return So(e)?new e(this._context,t):e(this._context,t)||{}}finally{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});try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(s){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:s})}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(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)}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)}))}},Ao=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)}}}},Co=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()}},An=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 Po(e,t){return t+e}function Do(){return typeof performance>"u"?Date.now():Po(performance.now(),performance.timeOrigin)}var Ro="emailmaker:diagnostics",Oo="diagnostics",Lo="diagnostics";function Cn(e,t){return t?`${e}${e.includes("?")?"&":"?"}${Lo}=1`:e}var rt;function No(){try{const e=new URLSearchParams(window.location.search).get(Oo);return e===null?void 0:e!=="0"}catch{return}}function Mo(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function xo(){try{const e=window.localStorage.getItem(Ro);return e===null?void 0:e==="1"}catch{return}}function _e(){return rt===void 0&&(rt=typeof window>"u"?!1:No()??Mo()??xo()??!1),rt}function ko(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var z={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"},dm=Object.values(z),um=[z.canvasPainted,z.canvasSettled,z.appVisible,z.editorVisible],Fo=5e3,Bo=3e3,Pn="diagnosticsStore",ke,ye;function Dn(){return{marks:new An(Fo),resources:new An(Bo)}}function Rn(){if(ye)return ye;const e=st();return e?(ye=e[Pn]??ke??Dn(),e[Pn]=ye,ke=void 0,ye):(ke??=Dn(),ke)}function H(e,t){_e()&&Rn().marks.push({phase:e,at:Do(),...t})}function st(){if(typeof __useblocks__<"u"&&__useblocks__)return __useblocks__;if(typeof window>"u")return;const e=window[ko()];return e!==null&&typeof e=="object"?e:void 0}function jo(e){const t=e.length,n=Rn();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Uo(){const e=st();return!e||!Array.isArray(e.diagnosticsBuffer)?0:jo(e.diagnosticsBuffer)}var Ho="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function ot(){const e=new Error(Ho);return e.name="DestroyedInstanceError",e}function it(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((c,l)=>it(c,i[l]))}const r=Object.keys(e),s=Object.keys(t);return r.length!==s.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&it(e[o],t[o]))}function On(e,t){const n={watch(r){let s,o=!1;return e.watch(i=>{const c=t(i);o&&it(s,c)||(s=c,o=!0,r(c))})},select(r){return On(n,r)}};return n}function pe(...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 On(s,o)}};return s}var Ln=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:a.ContentType.UrlEncoded,...t})},Nn=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 $o(e){return String(e||"").trim()||void 0}var Go=class extends a.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=$o(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)}},at=a.createIdentifier$1("AppInitService");function Vo(e){return async()=>{const t=await e();return(await new Ln(t).app_init_create({})).data}}function Yo(e){e.injectFactory(at,()=>{const t=new Go({options:e.getInstance(a.OPTIONS_SOURCE_ID),isStandalone:()=>!!e.getInstance(a.SECURITY_MODULE_ID),resolveRestBaseUrl:n=>n?a.getActiveBaseUrl(n):a.getActiveBaseUrl()||void 0,setRestBaseUrl:n=>{e.getInstance(a.REST_CLIENT_FACTORY_ID)?.setOptions(n?{baseUrl:n}:{})},fallbackAppInit:Vo(()=>e.getInstanceAsync(a.REST_TRANSPORT_ID)),publish:n=>{e.inject(a.APP_ID,n)}});return e.getInstance(a.DISPOSABLE_ID)?.addDisposable(t),t},!0)}var lt=a.createIdentifier$1("documentSession.emailDocuments");function ct(e){return e?.getInstance(lt)}var qo=a.createIdentifier$1("RevisionServiceFlag");function zo(e){return e.getOrCreateInstance(qo,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Mn(e){return zo(e).isEnabled()}var Wo=a.createIdentifier$1("EmailRightsResolver");function Ko(e,t){const n=e.getInstance(Wo);return n?n(t):!0}var xn=a.createIdentifier$1("EmailHistoryAvailabilityResolver");function Xo(e){return e.getInstance(xn)!==void 0}async function Jo(e){const t=e.getInstance(xn);if(!t)return!0;try{return await t()}catch{return!1}}var dt={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},kn=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],Fn=2e4,Qo=kn.reduce((e,t)=>e+dt[t],0),Bn=Fn+Qo+3e3;function Zo(e){return kn.reduce((t,n)=>t+jn(n,e),0)}function jn(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:dt[e]}function Un(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:Bn}function Hn(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:Fn}function $n(e=Bn){return e+3e3}var fm="[show-pipeline]";function Gn(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}function pm(e,t){}var ei=()=>$n();function ti(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function ni(e){return t=>ti(e.getOrCreateInstance(a.events.BEFORE_SAVE_EMAIL,()=>new a.AsyncEmitter).fire(t),ei())}function ri(e){return e!=null&&e!==""}var si;function Fe(e,t){return si?.capture(e,t)}function oi(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Be(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var Q=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} "${Be(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Be(this.oldText)}")`:`(replace@${this.oldPosition} "${Be(this.oldText)}" with "${Be(this.newText)}")`}};function Vn(e,t){return e===null||e.length===0?t:new ii(e,t).compress()}var ii=class ne{_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[l,u]=ne._splitCurr(s,r.newPosition-s.oldPosition);this._acceptCurr(l),s=u;continue}if(r.newPosition<s.oldPosition){const[l,u]=ne._splitPrev(r,s.oldPosition-r.newPosition);this._acceptPrev(l),r=u;continue}let i,c;if(s.oldEnd===r.newEnd)i=r,c=s,r=this._getPrev(++t),s=this._getCurr(++n);else if(s.oldEnd<r.newEnd){const[l,u]=ne._splitPrev(r,s.oldLength);i=l,c=s,r=u,s=this._getCurr(++n)}else{const[l,u]=ne._splitCurr(s,r.newLength);i=r,c=l,r=this._getPrev(++t),s=u}this._result[this._resultLen++]=new Q(i.oldPosition,i.oldText,c.newPosition,c.newText),this._prevDeltaOffset+=i.newLength-i.oldLength,this._currDeltaOffset+=c.newLength-c.oldLength}const o=ne._merge(this._result);return ne._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=ne._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++]=ne._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 Q(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new Q(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 Q(t.oldPosition,t.oldText,t.newPosition,r),new Q(t.oldEnd,"",t.newPosition+n,s)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),s=t.oldText.substr(n);return[new Q(t.oldPosition,r,t.newPosition,t.newText),new Q(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 Q(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 ai(e){return new Q(e.newPosition,e.newText,e.oldPosition,e.oldText)}function li(e){return e.map(ai)}function Yn(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function ci(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 di(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 c=o.oldPosition;if(s&&c===e.start)r+=n==="after"?i:0;else{if(e.start<c&&c<e.end)return null;c<=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}}var je=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},qn=0,ui=Math.random().toString(36).slice(2,8);function fi(){return qn+=1,`doc-${ui}-${qn}`}function pi(e){const t=e.createBuffer(),n=e.docId??fi();let r=e.serverId??null,s=0,o=null,i=e.attributes??{};const c=new Set;let l=!1,u=!1,d;const p=new Set;let m=null;const b=()=>(m?.version!==s&&(m={version:s,value:t.read()}),m.value),S=E=>Object.entries(E).some(([g,v])=>i[g]!==v);return{get:()=>({docId:n,serverId:r,version:s,savedVersion:o,attributes:i}),getContent:b,mutate(E,{source:g}){if(l)return s;const v=E.changes?.length?E.changes:void 0,_=v?ci(b(),v):E.content!==void 0?E.content:void 0,w=_!==void 0&&_!==b(),P=E.attributes!==void 0&&S(E.attributes);if(!w&&!P)return s;const D=!(s>(o??-1));return w&&t.write(_),P&&(i={...i,...E.attributes}),s+=1,g!=="user"&&D&&(o=s),c.forEach(h=>h({source:g,version:s,changes:v})),s},markSaved(E,g){const v={serverId:r,savedVersion:o};g!==void 0&&(r=g),(o===null||E>o)&&(o=E),(v.serverId!==r||v.savedVersion!==o)&&c.forEach(_=>_({source:"system",version:s}))},markReady(){u||d!==void 0||(u=!0,p.forEach(E=>E.resolve()),p.clear(),c.forEach(E=>E({source:"system",version:s})))},isReady:()=>u,markFailed(E){u||d!==void 0||l||(d=E,p.forEach(g=>g.reject(new je(E))),p.clear(),c.forEach(g=>g({source:"system",version:s})))},failure:()=>d,whenReady(){return u?Promise.resolve():d!==void 0?Promise.reject(new je(d)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((E,g)=>{p.add({resolve:E,reject:g})})},subscribe(E){return c.add(E),()=>c.delete(E)},isNew:()=>r===null,isDirty:()=>s>(o??-1),isDisposed:()=>l,dispose(){l=!0,p.forEach(E=>E.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),p.clear(),c.clear(),t.dispose()}}}var mi=500,hi=100,ut=0;function gi(e,t={}){const n=t.groupIntervalMs??mi,r=t.maxSteps??hi,s=t.now??(()=>0);let o=[],i=0,c=ut+=1,l=null,u=!1,d=!1,p=!1;const m=new Set,b=()=>m.forEach(h=>h()),S=(h,I)=>{if(h.length){d=!0;try{e.mutate({changes:h},{source:I})}finally{d=!1}}},E=h=>S(h,"user"),g=h=>{const I=s();u&&l!==null&&I-l<n?o[i-1]=Vn(o[i-1],h):(o=o.slice(0,i),o.push(h),i=o.length,u=!0,o.length>r&&(o=o.slice(o.length-r),i=o.length,c=ut+=1)),l=I,b()},v=()=>{u=!1,l=null},_=h=>{if(!h.length)return;const I=o.length>i;I&&(o=o.slice(0,i)),i>0&&(o[i-1]=Vn(o[i-1],h)),v(),I&&b()},w=e.subscribe(({source:h,changes:I})=>{if(!(p||d||!I?.length)){if(h==="remote"){P();return}if(h!=="user"){_(I);return}g(I)}}),P=()=>{o=[],i=0,v(),c=ut+=1,b()},D=()=>{if(i===0)return!1;const h=li(o[i-1]);return Yn(e.getContent(),h)?(E(h),i-=1,v(),!0):(o=o.slice(0,i-1),i=o.length,v(),b(),!1)};return{canUndo:()=>i>0,canRedo:()=>i<o.length,undo(){D()&&b()},redo(){if(!(i>=o.length)){if(!Yn(e.getContent(),o[i])){o=o.slice(0,i),v(),b();return}E(o[i]),i+=1,v(),b()}},clear:P,applyWithoutHistory(h){const I=e.get().version;if(S(h,"system"),e.get().version===I){v();return}_(h)},getPast:h=>o.slice(0,i).reverse().slice(0,h),getFuture:h=>o.slice(i).reverse().slice(0,h),createSnapshot:()=>({stackId:c,index:i}),restoreSnapshot(h){if(h.stackId!==c||h.index>i)return!1;for(;i>h.index;)if(!D())return b(),!1;return b(),!0},subscribe(h){return m.add(h),()=>m.delete(h)},dispose(){p=!0,w(),m.clear(),o=[],i=0}}}var Ei=["edit","move","resize","insert"];function ft(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function bi(e){return typeof e=="string"?e:null}function vi(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function _i(e){return Ei.includes(e)?e:null}function yi(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:bi(t.originId),changeId:ft(t.changeId),rev:ft(t.rev),baseRev:ft(t.baseRev),expected:vi(t.expected),intent:_i(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var zn=class extends Error{reason;constructor(e){super(`сохранение не состоялось: ${e}`),this.name="SaveRefusedError",this.reason=e}},Wn="draft";function Se(e){return e==null||e===""?Wn:String(e)}function Si(e){return e==null||e===""?`${pt}${Wn}`:`${pt}${String(e)}`}var pt="block:";function re(e){return e?.startsWith(pt)===!0}function we(e){return re(e.sessionKey())?void 0:e.current()}function mm(e,t){}function Ie(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return H(`show:gate:${e}`,{kind:"wait"}),t.then(s=>(H(`show:gate:${e}:end`,{kind:"wait"}),s),s=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw a.isAbortError(s)?(`${e}`,{...n}):(`${e}`,{error:Gn(s),...n},void 0),s})}var hm=5e3;function Kn(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Xn(e,{freshSince:t}={}){return!(!e?.slug?.includes("autosave")||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function wi(e,t={}){const n=Kn((e??[]).filter(r=>r?.html?.trim()));return Xn(n,t)?n:null}function Ii(e){const t=Date.parse(Kn(e)?.modified??"");return{autosave:wi(e),...Number.isFinite(t)?{latestAt:t}:{}}}function Ti({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var Jn=e=>e.replace(/\r\n?/g,`
2079
+ `),Qn=["recovery","plugin","rest"],Ai=["subject","preheader"];function Ci(e){let t={},n;for(let s=Qn.length-1;s>=0;s--){const o=e.get(Qn[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 Ai){const o=r?.[s];typeof o=="string"&&o!==""&&(t={...t,[s]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Zn(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?Jn(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 Q(0,n,0,r)]}:{}},{source:"remote"})}var er=e=>typeof e=="string"?e.trim():"";function Pi(e,t,n){const{version:r,attributes:s}=e.get(),o=s,i=er(o.title)||er(o.subject);return{version:r,payload:{html:e.getContent(),title:i,subject:o.subject,preheader:o.preheader,description:o.description,common_styles:o.common_styles||"",meta:o.meta,utm_parameters:o.utm_parameters,parent_email:o.parent_email,is_template:o.is_template||!1,is_inited:o.is_inited,tags:o.tags,emailtags:o.emailtags,group:o.group,renderGuid:e.get().docId,project:t.project??o.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source}}}async function Di(e,t,n,r,s){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)}function se(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=se(s)),n[r]=s)}return n}var Ri=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function tr(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Ri.has(t))):{}}function Ue(e,t,n={}){e&&e.mutate({attributes:Oi(e.get().attributes,t)},{source:n.source??"user"})}function Oi(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function mt(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Li(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function nr(e){if(!e)return null;const t=tr(e);return e.common_styles!==void 0&&(t.common_styles=Li(e.common_styles)),mt(e.html,t)}function rr(e){return e?mt(e.html,se(tr(e))):null}var Ni=["common_styles","subject","preheader","meta"];function sr(e){if(!e?.html?.trim())return null;const t={};for(const n of Ni)Mi(n,e[n])&&(t[n]=e[n]);return mt(e.html,t)}function Mi(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 xi=10,ki=(e,t)=>e.key===t.key&&Fi(e.serverId,t.serverId),Fi=(e,t)=>e==null||e===t;function Bi(e){return typeof e?.then=="function"}var or=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},ir=e=>{e.request.serverId!=null&&e.document.markSaved(e.document.get().version)},ji=e=>{Zn(e.document,Ci(e.reports)),ir(e)},ht=(e,t)=>{if(!e.ready){ji(e);return}Zn(e.document,t)},Ui=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 Hi(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:s,resolveTerms:o,canEdit:i,notifyBeforeSave:c,onAdapterError:l,onTimeout:u}=e;let d;const p=new Set,m=new Set,b=()=>p.forEach(f=>f()),S=(f,y)=>{if(!(f.closed||f.ready)){if(f.error!==void 0){f.document.markFailed(f.error),f.document.get().docId;return}ir(f),f.ready=!0,f.document.markReady(),f.document.get().docId,[...f.reports.keys()]}},E=(f,y,A)=>{l?.(y.id,A),!(!y.required||f.closed)&&(f.error=A,f.document.get().docId,y.id,b())},g=(f,y)=>{const A=new Set(y.map(C=>C.id));y.forEach(C=>{C.watch&&f.watchers.push(C.watch(T=>f.closed?!1:f.ready&&T?.content!==void 0&&Ti({hasUnsavedUserEdit:f.document.isDirty()})==="skip"?(f.document.get().docId,C.id,!1):(T&&f.reports.set(C.id,T),ht(f,T),!0)))});const L=(C,T)=>{f.closed||(T&&f.reports.set(C.id,T),ht(f,T))},k=()=>{A.size>0||f.closed||(or(f),S(f,[]))},q=[];if(y.forEach(C=>{let T;try{T=C.load()}catch(O){E(f,C,O),A.delete(C.id);return}if(Bi(T)){q.push({id:C.id,required:C.required,load:()=>T});return}L(C,T),A.delete(C.id)}),q.length===0){k();return}f.timer=setTimeout(()=>{f.timer=void 0,u?.([...A]),f.document.get().docId,[...A],S(f,[...A])},n),f.timer.unref?.(),q.forEach(C=>{C.load().then(T=>L(C,T)).catch(T=>{E(f,C,T)}).finally(()=>{A.delete(C.id),k()})})},v=async(f,y,A)=>{if(A==="snapshot"||A==="anchor")return;const L=o?.();if(L)return L.resolve({project:y.project??f.project,tags:(f.tags??[]).map(k=>({name:k}))})},_=f=>{if(f.lock===!0&&i?.(f)===!1)return new zn("locked");const y=f.tags?.length??0,A=f.emailtags?.length??0;if(Math.max(y,A)>xi)return new zn("too-many-tags")},w=async(f,y,A)=>{try{await f.document.whenReady()}catch(T){return f.saveError=T,f.saveFailures+=1,f.saveFailures,!1}if(f.closed)return!1;const L=_(f.document.get().attributes);if(L)return f.saveError=L,f.saveFailures+=1,L.reason,b(),!1;if(c&&(await c(Ui(f)).catch(()=>{}),f.closed))return!1;let k;try{k=await v(f.document.get().attributes,A,y)}catch(T){return f.saveError=T,f.saveFailures+=1,f.saveFailures,b(),!1}if(f.closed)return!1;const{payload:q,version:C}=Pi(f.document,A,k);f.document.get().docId;try{const T=f.document.get().serverId!=null,O=await Di(r(),s(f.request.key),y,f.document.get().serverId,q);if(f.closed)return!0;let N;if(y==="snapshot"||y==="anchor"){const M=O?.modified!=null?Date.parse(O.modified):NaN;N=Number.isFinite(M)?M:Date.now(),f.snapshotVersion=C,f.lastRevisionAt=N}else f.document.markSaved(C,O?.id!=null?String(O.id):void 0);const F=f.document.get().serverId;!T&&F!=null&&(f.recoveryFacts={emailId:F,historyLoaded:!0,isRecovering:!1}),f.saveError=void 0,f.saveFailures=0,f.document.get().serverId,b();const W={intent:y,serverId:f.document.get().serverId,created:!T,...N!==void 0?{revisionAt:N}:{}};return m.forEach(M=>M(W)),!0}catch(T){return f.saveError=T,f.saveFailures+=1,f.saveFailures,b(),!1}},P=()=>{d&&(d.closed=!0,d.watchers.forEach(f=>f()),d.watchers=[],or(d),d.history.dispose(),d.document.dispose(),d=void 0)},D=(f,y,A)=>{let L=!1;y.show&&(f.show?.id!==y.show.id||f.show.token!==y.show.token)&&(f.show=y.show,L=!0,{docId:f.document.get().docId,...y.show});const k=A==="show"?rr(y.patch):null;k&&(f.reports.set("plugin",k),ht(f,k)),L&&b()},h=(f,y={})=>{const A=d;return!A||A.closed?Promise.resolve(!1):A.saving?f==="snapshot"?Promise.resolve(!1):(A.inFlight??Promise.resolve(!1)).then(()=>h(f,y)):(A.saving=!0,A.inFlight=w(A,f,y).finally(()=>{A.saving=!1,A.inFlight=void 0}),A.inFlight)},I=(f,y="open")=>{if(d&&!d.closed&&y!=="new"&&ki(d.request,f))return D(d,f,y),d.document;P();const A=pi({createBuffer:()=>oi(""),serverId:f.serverId??null}),L={request:f,show:f.show,document:A,history:gi(A,{now:Date.now}),watchers:[],saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return d=L,A.get().docId,f.serverId,g(L,t(f,{publishRecoveryFacts(k){L.closed||(L.recoveryFacts=k,b())},readShownContent:()=>L.closed?null:L.document.getContent()})),b(),A};return{openWith:I,open:(f,y={})=>I({key:Se(f),serverId:f,email:y.email,patch:y.patch,show:y.show},"open"),openDraft:(f,y={})=>I({key:Se(void 0),serverId:null,email:f,patch:y.patch,show:y.show},"open"),startNewDraft:(f,y={})=>I({key:Se(void 0),serverId:null,email:f,patch:y.patch,show:y.show},"new"),reload:(f,y={})=>I({key:Se(f),serverId:f,email:y.email,patch:y.patch,show:y.show},"new"),openBlock:(f,y)=>I({key:re(f)?f:Si(f),serverId:y?.id!=null?String(y.id):null,email:y},"open"),show:(f,y)=>{const A=d;if(!(!A||A.closed))return I({...A.request,patch:f,show:y},"show")},current:()=>d?.document,save:h,saveState:()=>({error:d?.saveError,failures:d?.saveFailures??0,saving:d?.saving===!0}),revisionFacts(){if(!d)return;const f=d.revisionFactsSnapshot;return f&&f.snapshotVersion===d.snapshotVersion&&f.lastRevisionAt===d.lastRevisionAt?f:(d.revisionFactsSnapshot={snapshotVersion:d.snapshotVersion,lastRevisionAt:d.lastRevisionAt},d.revisionFactsSnapshot)},recoveryFacts:()=>d?.recoveryFacts,history:()=>d?.history,forcedHeaders:()=>d?.forcedHeaders,beginForcedHeaders(f){d&&!d.closed&&(d.forcedHeaders=f)},endForcedHeaders(){d&&(d.forcedHeaders=void 0)},onSaved(f){return m.add(f),()=>m.delete(f)},showFacts:()=>d?.show,sessionKey:()=>d?.request.key,openError:()=>d?.error,subscribe(f){return p.add(f),()=>p.delete(f)},close(){d&&(P(),b())}}}var ar=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function lr(e){if(e instanceof ar)return e.reason;if(e instanceof je)return lr(e.reason)}function $i(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new ar("not-found");return nr(n)}}}var cr=a.createIdentifier$1("EmailPort");function Gi(e){return e.getInstance(cr)}function Vi(e,t){e.inject(cr,t)}var dr=a.createIdentifier$1("documentSession.restEmailPortFactories");function ur(e){return e.getInstance(dr)!==void 0}function le(e){const t=e.getInstance(dr);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var Yi=a.createIdentifier$1("EmailTermsResolver");function qi(e){return e.getInstance(Yi)}var fr=a.createIdentifier$1("EmailHistoryPort"),zi=a.createIdentifier$1("BlockHistoryPort");function pr(e){return e.getInstance(zi)}function mr(e){return e.getInstance(fr)}function Wi(e,t){e.inject(fr,t)}var Ki="em_autosave_pending",gm=6e4;function He(e){return`${Ki}_${e}`}function Xi(e,t){try{sessionStorage.setItem(He(e),JSON.stringify(t))}catch{}}function Ji(e){try{const t=sessionStorage.getItem(He(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(He(e)),null):n}catch{return null}}function $e(e){try{sessionStorage.removeItem(He(e))}catch{}}var Qi=2e3,Zi=5e3,ea=5,ta=5e3,na=4;function ra(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function sa(e,t){return e==null||t==null?!1:e.replaceAll(`\r
2080
2080
  `,`
2081
2081
  `)===t.replaceAll(`\r
2082
2082
  `,`
2083
- `)}function Zi({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:s,onFacts:o,onLate:i,onError:c,pageLoadTs:l=Ji()}){let u=null,d=!1,p=!1,m=0,b={emailId:e,historyLoaded:!1,isRecovering:!1},y=null;const E=new Promise(C=>{y=C}),g=C=>{b={...b,...C},o(b)},v=C=>{m+=1,g({applied:{phase:C,seq:m}})},_=()=>{u?.timer&&clearTimeout(u.timer),u=null},w=C=>{if(!p){if(y){const L=y;y=null,L(C),C.revision&&v(C.phase);return}i(C)&&C.revision&&v(C.phase)}},P=()=>{if(!u||p)return;const C=u.phase==="fast",L=C?qi:Wi,H=C?Ki:Xi;u.timer=setTimeout(()=>{const k=u;if(!(!k||p)){if(k.attempts+=1,S(),C&&k.attempts>=H){const{pending:V}=k;Ue(e),g({isRecovering:!1}),w({revision:{html:V.html,common_styles:V.common_styles,subject:V.subject,preheader:V.preheader},phase:"timeout"}),d=!0,k.phase="bg",k.attempts=0,P();return}if(!C&&k.attempts>=H){Ue(e),_(),g({isRecovering:!1}),d=!0;return}P()}},L),u.timer.unref?.()},D=C=>{u={phase:"fast",attempts:0,pending:C,timer:null},g({isRecovering:!0}),P()},h=(C,L)=>$n(C.autosave,L===void 0?{}:{freshSince:L})?C.autosave:null,I=C=>{if(p)return;if(g({historyLoaded:!0,latestRevisionAt:C.latestAt!==void 0&&Number.isFinite(C.latestAt)?C.latestAt:void 0}),n&&u){const k=h(C,u.pending.sentAt);if(!k)return;const V=u.phase==="fast"?"found":"bg";Ue(e),_(),g({isRecovering:!1}),d=!0,w({revision:k,phase:V});return}if(d)return;const L=n?Yi(e):null,H=L&&(L.sentAt<l||!Qi(L.html,s()))?L:null;if(H){const k=h(C,H.sentAt);if(k){Ue(e),d=!0,w({revision:k,phase:"found"});return}D(H);return}d=!0,w({revision:h(C),phase:"normal"})},f=C=>{p||(c?.(C),b.historyLoaded||(g({historyLoaded:!1,latestRevisionAt:void 0}),O()),!u&&w({revision:null,phase:"normal"}))},S=()=>t(e).then(I).catch(f);let T,A=!1;const O=()=>{A||u||p||(A=!0,T=setTimeout(()=>{T=void 0,!p&&!b.historyLoaded&&S()},zi))},x=()=>{p||(g({historyLoaded:!1,latestRevisionAt:void 0}),w({revision:null,phase:"normal"}))};return r?r().then(C=>C?S():x()):S(),{verdict:()=>E,dispose(){p=!0,T!==void 0&&(clearTimeout(T),T=void 0),_()}}}function ea({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:s,onFacts:o}){let i=null;const c=Zi({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:s,onFacts:o,onLate:({revision:l,phase:u})=>{const d=Xn(l);return i?.(d)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>c.verdict().then(({revision:l})=>Xn(l)),watch(l){return i=l,()=>{i=null,c.dispose()}}}}function ar(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){Vi(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const s=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),s}}}function ta(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const s=await t.updateEmail(n,r);return await e.updateEmail(n,r),s}}}var lr=a.createIdentifier$1("CurrentUser"),cr={};function dr(e){return e.getOrCreateInstance(lr,()=>pe(cr))}function ur(e){return e?.getInstance(lr)?.get()??cr}function fr(e){return e?.getInstance(a.CONFIG_SOURCE_ID)?.get()??{}}var na=1.5;function ra(e){return!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=na*e.autosaveTimeoutMs?"none":"revision"}var sa=4;function oa(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:s}=e,o=e.readFailures??(()=>0),i=()=>n().autosaveTimeoutMs*2**Math.min(o(),sa),c=()=>{const v=t();if(!v||v.isDisposed())return"none";const{latestRevisionAt:_,snapshotVersion:w,...P}=n();return ra({...P,isDirty:v.isDirty(),isNew:v.isNew(),isReady:v.isReady(),latestRevisionAgeMs:_!=null?Date.now()-_:void 0,isSnapshotSent:w!=null&&w===v.get().version})},l=()=>{const v=t();if(!v||v.isDisposed())return!1;if(!v.isDirty())return v.isNew();const{snapshotVersion:_}=n();return!(_!=null&&_===v.get().version)};let u,d,p,m,b=!1;const y=()=>{d=void 0;const v=t();if(!v||v.isDisposed())return;if(v.get().docId!==u){E();return}const _=c();_==="create"?r():_==="revision"?s():l()&&(u=v.get().docId,d=setTimeout(y,i()))},E=()=>{const v=t();b||!v||d!==void 0||c()==="none"&&!l()||(u=v.get().docId,d=setTimeout(y,i()))},g=()=>{const v=t();v!==p&&(m?.(),p=v,m=v?.subscribe(E),d!==void 0&&(clearTimeout(d),d=void 0))};return g(),E(),{refresh:()=>{b||(g(),E())},stop:()=>{b=!0,m?.(),m=void 0,p=void 0,d!==void 0&&(clearTimeout(d),d=void 0)}}}var pr=a.createIdentifier$1("documentSession.autosaveUiFacts"),mr={isUserBusy:!1,saveContext:{}};function ia(e){return e.getOrCreateInstance(pr,()=>pe(mr))}function hr(e){return e?.getInstance(pr)?.get()??mr}var aa=1e4;function la(e,t){const n=()=>{const l=t.current(),u=l?.get().serverId??void 0,d=ne(t.sessionKey()),p=t.recoveryFacts(),m=p?.emailId===u?p:void 0,b=t.revisionFacts(),y=m?.latestRevisionAt,E=b?.lastRevisionAt,g=ur(e).profile;return{isInited:d||l?.get().attributes.is_inited===!0,isEnabled:!!g?.autosaves,isHistoryLoaded:m?.historyLoaded===!0,isUserBusy:hr(e).isUserBusy,autosaveTimeoutMs:fr(e).autosaveTimeout||aa,latestRevisionAt:y!==void 0||E!==void 0?Math.max(y??0,E??0):void 0,snapshotVersion:b?.snapshotVersion}},r=()=>{const l=hr(e).saveContext;return{...l,project:l.project??t.current()?.get().attributes.project}},s=oa({readDocument:()=>t.current(),readEnvironment:n,readFailures:()=>t.saveState().failures,onCreate:()=>{ne(t.sessionKey())||t.save("materialize",r())},onRevision:()=>{t.save("snapshot",{project:r().project})}}),o=t.subscribe(s.refresh),i=dr(e).watch(()=>s.refresh()),c=ia(e).watch(()=>s.refresh());return()=>{o(),i.dispose(),c.dispose(),s.stop()}}var gr=12e3;function se(e){return e.getOrCreateInstance(at,()=>{const t=xi({resolveAdapters:(r,s)=>ua(r,e,s),resolveWritePort:()=>Er(e),resolveHistoryPort:r=>ne(r)?vr(e):br(e),resolveTerms:()=>Ui(e),canEdit:r=>Go(e,r),notifyBeforeSave:Xo(e),timeoutMs:gr,onAdapterError:(r,s)=>{s instanceof Error&&s.message,xe(s,{origin:"email-source-adapter",tags:{source:r}})},onTimeout:r=>{}}),n=la(e,t);return e.getInstance(a.DISPOSABLE_ID)?.addDispose(n),t})}function ht(e){return e?.getInstance(at)}function Er(e){const t=Fi(e);return t?gt(e)?ta(t,le(e).email(e)):t:le(e).email(e)}function ca(e){return ir(e)!==void 0||rr(e)}function br(e){const t=ir(e);return t?gt(e)?(U("port:history:server-backed"),ar(t,le(e).history(e))):(U("port:history:integrator"),t):(U("port:history:rest (порт не зарегистрирован)"),le(e).history(e))}function vr(e){const t=or(e);return t?gt(e)?(U("port:block-history:server-backed"),ar(t,le(e).blockHistory(e))):(U("port:block-history:integrator"),t):(U("port:block-history:rest (порт не зарегистрирован)"),le(e).blockHistory(e))}function da(e){return or(e)!==void 0||rr(e)}function gt(e){return Cn(e)}function ua({email:e,patch:t,serverId:n,key:r},s,o){const i=[];e?i.push({id:"rest",load:()=>Kn(e),required:!0}):n&&i.push(ki(Er(s),n)),t&&i.push({id:"plugin",load:()=>Wn(t)});const c=ne(r);return Jo(n)&&(c?da(s):ca(s))&&i.push(ea({port:c?vr(s):br(s),revisionServiceEnabled:Cn(s),...!c&&Vo(s)?{isHistoryAvailable:()=>Yo(s)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:l=>o.publishRecoveryFacts(l)})),i}function q(e){return e.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.MessageService)}var _r=new WeakMap,Et=new WeakMap;function oe(e){return _r.get(e)??0}function yr(e,t){let n=Et.get(e);return n||(n=new Set,Et.set(e,n)),n.add(t),()=>{n?.delete(t)}}function fa(e){_r.set(e,oe(e)+1),Et.get(e)?.forEach(t=>t())}function pa(e){const t=se(e),n=q(e).addListener(a.EVENT_TYPES.APPLICATION_HAS_AMP,r=>{we(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>n.dispose())}function ma(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function ha(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 c=await t(o,{mode:"cors",credentials:"omit",cache:i?"no-cache":"default"});if(!c.ok)return;const l=await c.blob();return ma(l)?l:void 0}catch{return}}}}var ce={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function ga(e){const t={maxBytes:e.maxBytes??ce.maxBytes,maxImageBytes:e.maxImageBytes??ce.maxImageBytes,ttlMs:e.ttlMs??ce.ttlMs},n=e.now??(()=>Date.now()),r=new Map,s=new Map,o={hits:0,loads:0,failures:0};let i=0;const c=p=>{const m=r.get(p);m&&(i-=m.bytes,r.delete(p))},l=p=>t.ttlMs<=0||n()-p.storedAt<t.ttlMs,u=()=>{if(i<=t.maxBytes)return;const p=[...r.entries()].sort((m,b)=>m[1].usedAt-b[1].usedAt);for(const[m]of p){if(i<=t.maxBytes)return;c(m)}},d=(p,m)=>{m.size>t.maxImageBytes||(r.set(p,{blob:m,bytes:m.size,storedAt:n(),usedAt:n()}),i+=m.size,u())};return{async get(p){const m=r.get(p);if(m&&l(m))return m.usedAt=n(),o.hits+=1,m.blob;m&&c(p);const b=s.get(p);if(b!==void 0)return b;o.loads+=1;const y=(async()=>{try{const E=await e.load(p);return E?d(p,E):o.failures+=1,E}catch{o.failures+=1;return}finally{s.delete(p)}})();return s.set(p,y),y},forget(p){c(p),s.delete(p)},clear(){r.clear(),s.clear(),i=0},stats(){return{entries:r.size,bytes:i,...o}}}}var Ea=["emcdn.ru","scr.emcdn.ru"];function ba(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 va(e,t){const n=(r,s)=>{const o=new Set(s?t:[]);for(const i of r){const c=ba(i);c&&o.add(c)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Sr(e){const t=e??{},n=t.isPlugin!==!0?Ea:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...ce};const s=r===!0||r===void 0?{}:r;return{enabled:s.enabled!==!1,sourceHosts:va(s.sourceHosts,n),maxBytes:s.maxBytes??ce.maxBytes,maxImageBytes:s.maxImageBytes??ce.maxImageBytes,ttlMs:s.ttlMs??ce.ttlMs}}function _a(e){const t=q(e),n=e.getInstance(a.CONFIG_SOURCE_ID);let r=Sr(n?.get());const s=ha({sourceHosts:()=>r.sourceHosts}),o=ga({load:y=>s.load(y),maxBytes:r.maxBytes,maxImageBytes:r.maxImageBytes,ttlMs:r.ttlMs}),i=()=>{t.send(a.EVENT_TYPES.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:r.enabled,sourceHosts:[...r.sourceHosts]})},c=t.onInit(()=>i()),l=n?.watch(()=>{const y=Sr(n.get()),E=JSON.stringify(y)!==JSON.stringify(r);r=y,y.enabled||o.clear(),E&&t.isInited()&&i()}),u={asked:0,served:0,refused:0},d=[],p=(y,E)=>(u.refused+=1,d.push({url:y,reason:E}),d.length>20&&d.shift(),{refused:!0}),m=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:r,counters:{...u},refusals:[...d],store:o.stats()})}),b=t.addListenerAsync(a.EVENT_TYPES.APPLICATION_CANVAS_IMAGE_GET,async y=>{const E=y?.url??"";if(u.asked+=1,!r.enabled||!E)return p(E,"disabled");if(!s.accepts(E))return p(E,"host");y.fresh&&o.forget(E);const g=await o.get(E);return g?(u.served+=1,{blob:g}):p(E,"load-failed")});e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{c.dispose(),l?.dispose(),b.dispose(),o.clear(),delete m.__emmCanvasImages__})}var ya=2e3;function Sa(e){const t=q(e),n=new Set,r=()=>{const i=t.getTarget();if(!i||t.hasPort(i))return;const c=new MessageChannel;let l=!1;const u=p=>{p.data?.operationId==="em:port-ready"&&(l=!0,c.port1.removeEventListener("message",u),t.drainWindow(i))};c.port1.addEventListener("message",u),t.sendPort(i,c.port2),t.usePort(c.port1,!1,i);const d=setTimeout(()=>{n.delete(d),!l&&(xe(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),c.port1.removeEventListener("message",u),t.useWindow(i))},ya);n.add(d)},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(a.DISPOSABLE_ID)?.addDispose(()=>{for(const i of n)clearTimeout(i);o.dispose(),delete s.__emmCanvasPort__})}var wa=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Ia(e){return wa.test(e)||e.indexOf("//")===0}function He(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Ta(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function wr(e,t){const n=e==null||e===""?"./":String(e);if(Ia(n))return He(n);const r=t??Ta();if(!r)return He(n);try{return He(new URL(n,r).href)}catch{return He(n)}}function Aa(){return typeof __useblocks__<"u"&&__useblocks__?.publicPath?wr(__useblocks__.publicPath):wr("/")}var Ca=()=>"",Pa=()=>"d62ebebc";function Ir(e){const t=e?"iframe-eblock":"iframe",n=Ca();if(n){const o=n.replace(/\/?$/,"/");return _n(`${o}${t}.html`,_e())}const r=Pa(),s=`${Aa().replace(/\/?$/,"/")}iframe/`;return _n(`${s}${t}${r?`.${r}`:""}.html`,_e())}var Tr="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function bt(e){return/^file:/i.test(String(e||"").trim())}function Da(e){return bt(e)?`${Tr} allow-same-origin`:Tr}var sm="em:module-body",Ra="em:module-body-ack";function Oa(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 vt(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.[0-9a-f]{6,})?\.html$/.exec(t);return n?`js/${n[1]}.body.js`:void 0}function La(e,t){const n=vt(t)?.replace(/^js\/|\.body\.js$/g,""),r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(s=>e[s]?.file).filter(s=>!!s):[]}function Na(e,t){const n=vt(t)?.replace(/\.body\.js$/,".js");if(!n||!(n in e))return[];const r=new Set([n]),s=[n],o=[];for(;s.length>0;)for(const i of e[s.shift()]??[])r.has(i)||(r.add(i),o.push(i),s.push(i));return o}async function Ma(e){try{const t=await fetch(e);return t.ok?await t.blob():void 0}catch{return}}function xa(e){const t=new Map,n=r=>{const s=Oa(r,e.canvasSrc,e.origin);if(!s)return;const o=t.get(s);if(o!==void 0)return o;const i=e.fetchBody(s);return t.set(s,i),i};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r){for(const s of r)n(s)},reset(){t.clear()},get size(){return t.size}}}async function ka(e,t,n){try{const r=new URL(".vite/manifest.json",new URL("./",new URL(e,t))).href,s=await fetch(r);if(!s.ok)return;const o=await s.json();n(La(o,e))}catch{}}function Fa(e){try{return bt(new URL(e,window.location.href).href)}catch{return bt(window.location.href)}}function Ba(e){q(e);const t=Ir(!1);if(Fa(t))return;const n=xa({canvasSrc:t,origin:window.location.href,fetchBody:Ma}),r=vt(t);r&&n.warm([r]);const s={"js/iframe-eblock.js":["js/discussHandlers.Ced_gtP0.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.Ced_gtP0.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.Ced_gtP0.js":["js/rolldown-runtime.BRlIiq3h.js"],"js/rolldown-runtime.BRlIiq3h.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.BbXdyfMT.js":["js/rolldown-runtime.BRlIiq3h.js"]};s?n.warm(Na(s,t)):ka(t,window.location.href,i=>n.warm(i));const o=i=>{const c=i.data;if(!c||c.operationId!=="em:module-body"||!c.result)return;const l=i.source;l&&(l.postMessage({operationId:Ra,for:c.result},"*"),n.take(c.data?.url??"").then(u=>{l.postMessage({operationId:c.result,data:u??null},"*")}))};window.addEventListener("message",o),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{window.removeEventListener("message",o),n.reset()})}var me=/<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,ja=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,he=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Ar=/display:\s*none\s*!important/gi,Ua=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,Ha=/\s*height\s*:\s*100%\s*!important\s*;?/gi,$a=/height\s*:\s*100%\s*!important/i,Ga=[".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 Va(e){return Ar.lastIndex=0,(e.match(Ar)||[]).length}function Cr(e){const t=e.trim(),n=Va(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=Ga.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 Ya(e){he.lastIndex=0;for(const t of e.matchAll(he))if(Cr(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function qa(e){let t=!1;return he.lastIndex=0,{html:e.replace(he,n=>Cr(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function za(e){return me.lastIndex=0,me.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Ya(e)}function Ka(e){if(!za(e))return{html:e,found:!1};let t=!1,n=e;me.lastIndex=0,me.test(n)&&(me.lastIndex=0,n=n.replace(me,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(ja,""),t=!0);const r=qa(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Wa(e){return!e||!$a.test(e)?e:(he.lastIndex=0,e.replace(he,t=>t.replace(Ua,(n,r,s,o)=>`${r}${s.replace(Ha,"")}${o}`)))}function Pr(e){const t=Ka(e.replaceAll(`\r
2083
+ `)}function oa({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:s,onFacts:o,onLate:i,onError:c,pageLoadTs:l=ra()}){let u=null,d=!1,p=!1,m=0,b={emailId:e,historyLoaded:!1,isRecovering:!1},S=null;const E=new Promise(C=>{S=C}),g=C=>{b={...b,...C},o(b)},v=C=>{m+=1,g({applied:{phase:C,seq:m}})},_=()=>{u?.timer&&clearTimeout(u.timer),u=null},w=C=>{if(!p){if(S){const T=S;S=null,T(C),C.revision&&v(C.phase);return}i(C)&&C.revision&&v(C.phase)}},P=()=>{if(!u||p)return;const C=u.phase==="fast",T=C?Qi:ta,O=C?ea:na;u.timer=setTimeout(()=>{const N=u;if(!(!N||p)){if(N.attempts+=1,y(),C&&N.attempts>=O){const{pending:F}=N;$e(e),g({isRecovering:!1}),w({revision:{html:F.html,common_styles:F.common_styles,subject:F.subject,preheader:F.preheader},phase:"timeout"}),d=!0,N.phase="bg",N.attempts=0,P();return}if(!C&&N.attempts>=O){$e(e),_(),g({isRecovering:!1}),d=!0;return}P()}},T),u.timer.unref?.()},D=C=>{u={phase:"fast",attempts:0,pending:C,timer:null},g({isRecovering:!0}),P()},h=(C,T)=>Xn(C.autosave,T===void 0?{}:{freshSince:T})?C.autosave:null,I=C=>{if(p)return;if(g({historyLoaded:!0,latestRevisionAt:C.latestAt!==void 0&&Number.isFinite(C.latestAt)?C.latestAt:void 0}),n&&u){const N=h(C,u.pending.sentAt);if(!N)return;const F=u.phase==="fast"?"found":"bg";$e(e),_(),g({isRecovering:!1}),d=!0,w({revision:N,phase:F});return}if(d)return;const T=n?Ji(e):null,O=T&&(T.sentAt<l||!sa(T.html,s()))?T:null;if(O){const N=h(C,O.sentAt);if(N){$e(e),d=!0,w({revision:N,phase:"found"});return}D(O);return}d=!0,w({revision:h(C),phase:"normal"})},f=C=>{p||(c?.(C),b.historyLoaded||(g({historyLoaded:!1,latestRevisionAt:void 0}),k()),!u&&w({revision:null,phase:"normal"}))},y=()=>t(e).then(I).catch(f);let A,L=!1;const k=()=>{L||u||p||(L=!0,A=setTimeout(()=>{A=void 0,!p&&!b.historyLoaded&&y()},Zi))},q=()=>{p||(g({historyLoaded:!1,latestRevisionAt:void 0}),w({revision:null,phase:"normal"}))};return r?r().then(C=>C?y():q()):y(),{verdict:()=>E,dispose(){p=!0,A!==void 0&&(clearTimeout(A),A=void 0),_()}}}function ia({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:s,onFacts:o}){let i=null;const c=oa({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:s,onFacts:o,onLate:({revision:l,phase:u})=>{const d=sr(l);return i?.(d)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>c.verdict().then(({revision:l})=>sr(l)),watch(l){return i=l,()=>{i=null,c.dispose()}}}}function hr(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){Xi(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const s=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),s}}}function aa(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const s=await t.updateEmail(n,r);return await e.updateEmail(n,r),s}}}var gr=a.createIdentifier$1("CurrentUser"),Er={};function br(e){return e.getOrCreateInstance(gr,()=>pe(Er))}function vr(e){return e?.getInstance(gr)?.get()??Er}function _r(e){return e?.getInstance(a.CONFIG_SOURCE_ID)?.get()??{}}var la=1.5;function ca(e){return!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=la*e.autosaveTimeoutMs?"none":"revision"}var da=4;function ua(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:s}=e,o=e.readFailures??(()=>0),i=()=>n().autosaveTimeoutMs*2**Math.min(o(),da),c=()=>{const v=t();if(!v||v.isDisposed())return"none";const{latestRevisionAt:_,snapshotVersion:w,...P}=n();return ca({...P,isDirty:v.isDirty(),isNew:v.isNew(),isReady:v.isReady(),latestRevisionAgeMs:_!=null?Date.now()-_:void 0,isSnapshotSent:w!=null&&w===v.get().version})},l=()=>{const v=t();if(!v||v.isDisposed())return!1;if(!v.isDirty())return v.isNew();const{snapshotVersion:_}=n();return!(_!=null&&_===v.get().version)};let u,d,p,m,b=!1;const S=()=>{d=void 0;const v=t();if(!v||v.isDisposed())return;if(v.get().docId!==u){E();return}const _=c();_==="create"?r():_==="revision"?s():l()&&(u=v.get().docId,d=setTimeout(S,i()))},E=()=>{const v=t();b||!v||d!==void 0||c()==="none"&&!l()||(u=v.get().docId,d=setTimeout(S,i()))},g=()=>{const v=t();v!==p&&(m?.(),p=v,m=v?.subscribe(E),d!==void 0&&(clearTimeout(d),d=void 0))};return g(),E(),{refresh:()=>{b||(g(),E())},stop:()=>{b=!0,m?.(),m=void 0,p=void 0,d!==void 0&&(clearTimeout(d),d=void 0)}}}var yr=a.createIdentifier$1("documentSession.autosaveUiFacts"),Sr={isUserBusy:!1,saveContext:{}};function fa(e){return e.getOrCreateInstance(yr,()=>pe(Sr))}function wr(e){return e?.getInstance(yr)?.get()??Sr}var pa=1e4;function ma(e,t){const n=()=>{const l=t.current(),u=l?.get().serverId??void 0,d=re(t.sessionKey()),p=t.recoveryFacts(),m=p?.emailId===u?p:void 0,b=t.revisionFacts(),S=m?.latestRevisionAt,E=b?.lastRevisionAt,g=vr(e).profile;return{isInited:d||l?.get().attributes.is_inited===!0,isEnabled:!!g?.autosaves,isHistoryLoaded:m?.historyLoaded===!0,isUserBusy:wr(e).isUserBusy,autosaveTimeoutMs:_r(e).autosaveTimeout||pa,latestRevisionAt:S!==void 0||E!==void 0?Math.max(S??0,E??0):void 0,snapshotVersion:b?.snapshotVersion}},r=()=>{const l=wr(e).saveContext;return{...l,project:l.project??t.current()?.get().attributes.project}},s=ua({readDocument:()=>t.current(),readEnvironment:n,readFailures:()=>t.saveState().failures,onCreate:()=>{re(t.sessionKey())||t.save("materialize",r())},onRevision:()=>{t.save("snapshot",{project:r().project})}}),o=t.subscribe(s.refresh),i=br(e).watch(()=>s.refresh()),c=fa(e).watch(()=>s.refresh());return()=>{o(),i.dispose(),c.dispose(),s.stop()}}var Ir=12e3;function oe(e){return e.getOrCreateInstance(lt,()=>{const t=Hi({resolveAdapters:(r,s)=>Ea(r,e,s),resolveWritePort:()=>Tr(e),resolveHistoryPort:r=>re(r)?Cr(e):Ar(e),resolveTerms:()=>qi(e),canEdit:r=>Ko(e,r),notifyBeforeSave:ni(e),timeoutMs:Ir,onAdapterError:(r,s)=>{s instanceof Error&&s.message,Fe(s,{origin:"email-source-adapter",tags:{source:r}})},onTimeout:r=>{}}),n=ma(e,t);return e.getInstance(a.DISPOSABLE_ID)?.addDispose(n),t})}function gt(e){return e?.getInstance(lt)}function Tr(e){const t=Gi(e);return t?Et(e)?aa(t,le(e).email(e)):t:le(e).email(e)}function ha(e){return mr(e)!==void 0||ur(e)}function Ar(e){const t=mr(e);return t?Et(e)?(H("port:history:server-backed"),hr(t,le(e).history(e))):(H("port:history:integrator"),t):(H("port:history:rest (порт не зарегистрирован)"),le(e).history(e))}function Cr(e){const t=pr(e);return t?Et(e)?(H("port:block-history:server-backed"),hr(t,le(e).blockHistory(e))):(H("port:block-history:integrator"),t):(H("port:block-history:rest (порт не зарегистрирован)"),le(e).blockHistory(e))}function ga(e){return pr(e)!==void 0||ur(e)}function Et(e){return Mn(e)}function Ea({email:e,patch:t,serverId:n,key:r},s,o){const i=[];e?i.push({id:"rest",load:()=>nr(e),required:!0}):n&&i.push($i(Tr(s),n)),t&&i.push({id:"plugin",load:()=>rr(t)});const c=re(r);return ri(n)&&(c?ga(s):ha(s))&&i.push(ia({port:c?Cr(s):Ar(s),revisionServiceEnabled:Mn(s),...!c&&Xo(s)?{isHistoryAvailable:()=>Jo(s)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:l=>o.publishRecoveryFacts(l)})),i}function Y(e){return e.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.MessageService)}var Pr=new WeakMap,bt=new WeakMap;function ie(e){return Pr.get(e)??0}function Dr(e,t){let n=bt.get(e);return n||(n=new Set,bt.set(e,n)),n.add(t),()=>{n?.delete(t)}}function ba(e){Pr.set(e,ie(e)+1),bt.get(e)?.forEach(t=>t())}function va(e){const t=oe(e),n=Y(e).addListener(a.EVENT_TYPES.APPLICATION_HAS_AMP,r=>{we(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>n.dispose())}function _a(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function ya(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 c=await t(o,{mode:"cors",credentials:"omit",cache:i?"no-cache":"default"});if(!c.ok)return;const l=await c.blob();return _a(l)?l:void 0}catch{return}}}}var ce={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Sa(e){const t={maxBytes:e.maxBytes??ce.maxBytes,maxImageBytes:e.maxImageBytes??ce.maxImageBytes,ttlMs:e.ttlMs??ce.ttlMs},n=e.now??(()=>Date.now()),r=new Map,s=new Map,o={hits:0,loads:0,failures:0};let i=0;const c=p=>{const m=r.get(p);m&&(i-=m.bytes,r.delete(p))},l=p=>t.ttlMs<=0||n()-p.storedAt<t.ttlMs,u=()=>{if(i<=t.maxBytes)return;const p=[...r.entries()].sort((m,b)=>m[1].usedAt-b[1].usedAt);for(const[m]of p){if(i<=t.maxBytes)return;c(m)}},d=(p,m)=>{m.size>t.maxImageBytes||(r.set(p,{blob:m,bytes:m.size,storedAt:n(),usedAt:n()}),i+=m.size,u())};return{async get(p){const m=r.get(p);if(m&&l(m))return m.usedAt=n(),o.hits+=1,m.blob;m&&c(p);const b=s.get(p);if(b!==void 0)return b;o.loads+=1;const S=(async()=>{try{const E=await e.load(p);return E?d(p,E):o.failures+=1,E}catch{o.failures+=1;return}finally{s.delete(p)}})();return s.set(p,S),S},forget(p){c(p),s.delete(p)},clear(){r.clear(),s.clear(),i=0},stats(){return{entries:r.size,bytes:i,...o}}}}var wa=["emcdn.ru","scr.emcdn.ru"];function Ia(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 Ta(e,t){const n=(r,s)=>{const o=new Set(s?t:[]);for(const i of r){const c=Ia(i);c&&o.add(c)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Rr(e){const t=e??{},n=t.isPlugin!==!0?wa:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...ce};const s=r===!0||r===void 0?{}:r;return{enabled:s.enabled!==!1,sourceHosts:Ta(s.sourceHosts,n),maxBytes:s.maxBytes??ce.maxBytes,maxImageBytes:s.maxImageBytes??ce.maxImageBytes,ttlMs:s.ttlMs??ce.ttlMs}}function Aa(e){const t=Y(e),n=e.getInstance(a.CONFIG_SOURCE_ID);let r=Rr(n?.get());const s=ya({sourceHosts:()=>r.sourceHosts}),o=Sa({load:S=>s.load(S),maxBytes:r.maxBytes,maxImageBytes:r.maxImageBytes,ttlMs:r.ttlMs}),i=()=>{t.send(a.EVENT_TYPES.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:r.enabled,sourceHosts:[...r.sourceHosts]})},c=t.onInit(()=>i()),l=n?.watch(()=>{const S=Rr(n.get()),E=JSON.stringify(S)!==JSON.stringify(r);r=S,S.enabled||o.clear(),E&&t.isInited()&&i()}),u={asked:0,served:0,refused:0},d=[],p=(S,E)=>(u.refused+=1,d.push({url:S,reason:E}),d.length>20&&d.shift(),{refused:!0}),m=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:r,counters:{...u},refusals:[...d],store:o.stats()})}),b=t.addListenerAsync(a.EVENT_TYPES.APPLICATION_CANVAS_IMAGE_GET,async S=>{const E=S?.url??"";if(u.asked+=1,!r.enabled||!E)return p(E,"disabled");if(!s.accepts(E))return p(E,"host");S.fresh&&o.forget(E);const g=await o.get(E);return g?(u.served+=1,{blob:g}):p(E,"load-failed")});e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{c.dispose(),l?.dispose(),b.dispose(),o.clear(),delete m.__emmCanvasImages__})}var Ca=2e3;function Pa(e){const t=Y(e),n=new Set,r=()=>{const i=t.getTarget();if(!i||t.hasPort(i))return;const c=new MessageChannel;let l=!1;const u=p=>{p.data?.operationId==="em:port-ready"&&(l=!0,c.port1.removeEventListener("message",u),t.drainWindow(i))};c.port1.addEventListener("message",u),t.sendPort(i,c.port2),t.usePort(c.port1,!1,i);const d=setTimeout(()=>{n.delete(d),!l&&(Fe(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),c.port1.removeEventListener("message",u),t.useWindow(i))},Ca);n.add(d)},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(a.DISPOSABLE_ID)?.addDispose(()=>{for(const i of n)clearTimeout(i);o.dispose(),delete s.__emmCanvasPort__})}var Da=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Ra(e){return Da.test(e)||e.indexOf("//")===0}function Ge(e){return e&&(e.endsWith("/")?e:`${e}/`)}function Oa(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Or(e,t){const n=e==null||e===""?"./":String(e);if(Ra(n))return Ge(n);const r=t??Oa();if(!r)return Ge(n);try{return Ge(new URL(n,r).href)}catch{return Ge(n)}}function La(){return typeof __useblocks__<"u"&&__useblocks__?.publicPath?Or(__useblocks__.publicPath):Or("/")}var Na=()=>"",Ma=()=>"ee20cf1c";function Lr(e){const t=e?"iframe-eblock":"iframe",n=Na();if(n){const o=n.replace(/\/?$/,"/");return Cn(`${o}${t}.html`,_e())}const r=Ma(),s=`${La().replace(/\/?$/,"/")}iframe/`;return Cn(`${s}${t}${r?`.${r}`:""}.html`,_e())}var Nr="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function vt(e){return/^file:/i.test(String(e||"").trim())}function xa(e){return vt(e)?`${Nr} allow-same-origin`:Nr}var Em="em:module-body",ka="em:module-body-ack";function Fa(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 _t(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.[0-9a-f]{6,})?\.html$/.exec(t);return n?`js/${n[1]}.body.js`:void 0}function Ba(e,t){const n=_t(t)?.replace(/^js\/|\.body\.js$/g,""),r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(s=>e[s]?.file).filter(s=>!!s):[]}function ja(e,t){const n=_t(t)?.replace(/\.body\.js$/,".js");if(!n||!(n in e))return[];const r=new Set([n]),s=[n],o=[];for(;s.length>0;)for(const i of e[s.shift()]??[])r.has(i)||(r.add(i),o.push(i),s.push(i));return o}async function Ua(e){try{const t=await fetch(e);return t.ok?await t.blob():void 0}catch{return}}function Ha(e){const t=new Map,n=r=>{const s=Fa(r,e.canvasSrc,e.origin);if(!s)return;const o=t.get(s);if(o!==void 0)return o;const i=e.fetchBody(s);return t.set(s,i),i};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r){for(const s of r)n(s)},reset(){t.clear()},get size(){return t.size}}}async function $a(e,t,n){try{const r=new URL(".vite/manifest.json",new URL("./",new URL(e,t))).href,s=await fetch(r);if(!s.ok)return;const o=await s.json();n(Ba(o,e))}catch{}}function Ga(e){try{return vt(new URL(e,window.location.href).href)}catch{return vt(window.location.href)}}function Va(e){Y(e);const t=Lr(!1);if(Ga(t))return;const n=Ha({canvasSrc:t,origin:window.location.href,fetchBody:Ua}),r=_t(t);r&&n.warm([r]);const s={"js/iframe-eblock.js":["js/discussHandlers.BuuVtU3Y.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.BuuVtU3Y.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.BuuVtU3Y.js":["js/rolldown-runtime.BRlIiq3h.js"],"js/rolldown-runtime.BRlIiq3h.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.BbXdyfMT.js":["js/rolldown-runtime.BRlIiq3h.js"]};s?n.warm(ja(s,t)):$a(t,window.location.href,i=>n.warm(i));const o=i=>{const c=i.data;if(!c||c.operationId!=="em:module-body"||!c.result)return;const l=i.source;l&&(l.postMessage({operationId:ka,for:c.result},"*"),n.take(c.data?.url??"").then(u=>{l.postMessage({operationId:c.result,data:u??null},"*")}))};window.addEventListener("message",o),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{window.removeEventListener("message",o),n.reset()})}var me=/<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,Ya=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,he=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Mr=/display:\s*none\s*!important/gi,qa=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,za=/\s*height\s*:\s*100%\s*!important\s*;?/gi,Wa=/height\s*:\s*100%\s*!important/i,Ka=[".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 Xa(e){return Mr.lastIndex=0,(e.match(Mr)||[]).length}function xr(e){const t=e.trim(),n=Xa(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=Ka.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 Ja(e){he.lastIndex=0;for(const t of e.matchAll(he))if(xr(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Qa(e){let t=!1;return he.lastIndex=0,{html:e.replace(he,n=>xr(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Za(e){return me.lastIndex=0,me.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Ja(e)}function el(e){if(!Za(e))return{html:e,found:!1};let t=!1,n=e;me.lastIndex=0,me.test(n)&&(me.lastIndex=0,n=n.replace(me,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(Ya,""),t=!0);const r=Qa(n);return n=r.html,t=t||r.found,{html:n,found:t}}function tl(e){return!e||!Wa.test(e)?e:(he.lastIndex=0,e.replace(he,t=>t.replace(qa,(n,r,s,o)=>`${r}${s.replace(za,"")}${o}`)))}function kr(e){const t=el(e.replaceAll(`\r
2084
2084
  `,`
2085
- `));return{html:Wa(t.html),hasBrowserExtensionArtifacts:t.found}}function _t(e){return e?.getContent()??""}function Dr(e,t){e?.mutate({content:Gn(t)},{source:"remote"})}function Rr(e){return a.createIdentifier$1(e)}function Q(e,t){return e.getOrCreateInstance(t,()=>new a.AsyncEmitter)}function $(e,t){return e.getOrCreateInstance(t,()=>new a.AsyncEmitter).event}function yt(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var Xa=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}},Ja=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(a.createAbortError("Superseded by newer show()")),n.aborted?Promise.reject(a.createAbortError(n.reason)):(this._activeRequest=e,new Promise((r,s)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{s(new Xa(e.showId,t))})},t);o.unref?.();const i=()=>{this._settle(e.showId,()=>{s(a.createAbortError(n.reason))})};n.addEventListener("abort",i,{once:!0});const c=()=>{clearTimeout(o),n.removeEventListener("abort",i)};this._pending.set(e.showId,{request:e,resolve:r,reject:s,timeoutId:o,dispose:c});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Qa(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Za(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Nn(e),n=Mn(e),r=zo(e.sandbox);t<n+r}var Or=class{_controller=new AbortController;_externalSignalDisposable=new a.Disposable;_sessionChangeListeners=new Set;_showRegistry=new Ja;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Nn(this._timeouts)}getSandboxTimeoutMs(e){return Ln(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return Mn(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=Qa(this._timeouts,e.timeouts),Za(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}abort(e){const t=e??a.createAbortError("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new a.Disposable}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new a.Disposable,this._showRegistry.rejectAll(a.createAbortError("Init session replaced")),this._controller.signal.aborted||this._controller.abort(a.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??a.createAbortError()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??a.createAbortError()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},St=(()=>{const e=new Or;return e.configure({}),e})(),el=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 tl(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 nl(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(a.throwIfAborted(n),new Promise((r,s)=>{let o=!1,i,c;const l=d=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),c?.dispose(),n?.removeEventListener("abort",u),d())},u=()=>{l(()=>s(a.createAbortError(n?.reason)))};if(c=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(i=setTimeout(()=>{l(()=>s(new el(t)))},t)),n?.addEventListener("abort",u)}))}var rl=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 sl(e,t,n){return t<=0?e:new Promise((r,s)=>{let o=!1,i;const c=l=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),l())};i=setTimeout(()=>{c(()=>s(new rl(n,t)))},t),e.then(l=>{c(()=>r(l))},l=>{c(()=>s(l))})})}var ol=2,$e=Symbol("sandbox:frame-replaced");function ee(e,t,n,r,s,o,i){const c=`sandbox:${t}`,l=o?.getSandboxTimeoutMs(t)??ct[t],u=()=>{let y=sl(e.sendAsync(n,r),l,c);return y=a.raceWithAbortSignal(y,o?.signal),Ie(c,y,s)};if(t==="INIT_START"&&tl(e)){const y=o?.getSandboxReadyTimeoutMs()??2e4,E=e,g=v=>{const _=nl(E,y,o?.signal);return Ie("sandbox:INIT_START:ready-wait",_,s).then(()=>{if(!i||v<=0)return u();const w=i.getGeneration();let P;const D=new Promise((I,f)=>{P=i.onChange(()=>{i.getGeneration()!==w&&f($e)})}),h=u();return h.catch(()=>{}),Promise.race([h,D]).finally(()=>P?.()).catch(I=>{if(I!==$e)throw I;return{...s},g(v-1)})})};return g(ol)}if(!i)return u();const d=i.getGeneration();let p;const m=new Promise((y,E)=>{p=i.onChange(()=>{i.getGeneration()!==d&&E($e)})}),b=u();return b.catch(()=>{}),Promise.race([b,m]).finally(()=>p?.()).catch(y=>{throw y===$e&&{...s},y})}var il=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],al=200;function ll(e=new Set){const t=new Set;return(n,r)=>{if(!il.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>=al&&t.clear(),t.add(s))}}function cl(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:ll()}}var dl=cl();function ge(e){return e?.getInstance(a.TEMPLATE_DIRECTIVES_ID)??dl}function ul(e){const t=se(e),n=q(e),r=()=>e.getInstance(a.INIT_PIPELINE_ID)??St;let s,o,i=!1,c=!1;const l=async(_,w,P)=>{const D=P.generation,h=()=>P.generation!==D||P.signal.aborted||t.current()!==_||c,I=oe(n);i=!0;try{if(await ee(n,"INIT_START",a.EVENT_TYPES.SANDBOX_INIT_START,{guid:w},void 0,P),h())return;const{html:f,hasBrowserExtensionArtifacts:S}=Pr(_t(_));if(S&&Q(e,a.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Dr(_,f),await ee(n,"SET_ENTITY",a.EVENT_TYPES.SANDBOX_SET_ENTITY,yt(_t(_),w,ge(e).editorPolicy,_.get().version),void 0,P),h())return;await ee(n,"INITED",a.EVENT_TYPES.SANDBOX_INITED,{guid:w},void 0,P),s=w,o=I}finally{i=!1}},u=()=>ne(t.sessionKey())?t.current():void 0,d=()=>{if(c||i)return;const _=u(),w=_?.get().docId;if(!_||!w||s===w&&o===oe(n)||!_.isReady())return;const P=r();P.signal.aborted||l(_,w,P).catch(()=>{})};let p=!1;const m=()=>{p||c||(p=!0,queueMicrotask(()=>{p=!1,d()}))};let b,y;const E=()=>{const _=u(),w=_?.get().docId;w!==y&&(b?.(),y=w,b=_?.subscribe(m)),m()},g=t.subscribe(E),v=yr(n,m);E(),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{c=!0,v(),b?.(),g()})}var fl=200;function pl({startVersion:e,limit:t=fl}){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 c=n.filter(u=>u.version>i);s(i);let l=o;for(const u of c){if(u.fromCanvas||u.contentReplaced||!u.changes)return null;const d=u.changes,p=[];for(const m of l){const b=si(m.range,d,"after");if(!b)return null;p.push({range:b,text:m.text})}l=p}return l}}}function ml(e,t){let n=0;return e.map(({start:r,end:s,text:o})=>{const i=new J(r,t.slice(r,s),r+n,o);return n+=o.length-(s-r),i})}function hl(e,t){const n=[...e].sort((r,s)=>r.range.start-s.range.start);return ml(n.map(({range:r,text:s})=>({start:r.start,end:r.end,text:s})),t)}function gl(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var wt=a.createIdentifier$1("canvas.sandboxFill");function Lr(e){return e.getInstance(wt)?.pipeline.isEventsLocked()===!0}function It(e){xe(e,{origin:"canvas-channel"})}function El(e){const t=se(e),n=q(e);let r;const s=(l,u)=>{const d=l.get().docId;let p=!1,m=null,b=null;const y=pl({startVersion:l.get().version});let E=l.getContent();const g=async(D,h)=>{if(b){b.push({edits:D,rev:h});return}b=[{edits:D,rev:h}];try{do{const I=b.splice(0,b.length);await n.sendAsync(a.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:I.map(f=>f.edits),guid:d,rev:I[I.length-1].rev})}while(b.length)}finally{b=null}},v=(D,h)=>{const I=b?.splice(0,b.length)??[];I.length&&n.sendAsync(a.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:I.map(f=>f.edits),guid:d,rev:I[I.length-1].rev}).catch(It),n.sendAsync(a.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:[D],guid:d,rev:l.get().version,...h!==null?{changeId:h}:{}}).catch(It)},_=D=>{const{guid:h,pushUndoStop:I}=D;if(h!==d)return;const f=hi(D);let{edits:S}=D;if(f.baseRev!==null){const A=y.rebase(S,f.baseRev);if(!A){xe(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),v([],f.changeId);return}S=A}const T=l.get().version;try{p=!0,m=f.changeId;const A=hl(S,l.getContent());I===!1?u.applyWithoutHistory(A):l.mutate({changes:A},{source:Lr(e)?"system":"user"})}finally{p=!1,m=null}l.get().version===T&&f.baseRev!==null&&v([],f.changeId)},w=l.subscribe(({changes:D,version:h})=>{const I=l.getContent(),f=!D?.length&&I!==E;if(E=I,y.record({version:h,changes:D,contentReplaced:f,fromCanvas:p}),!D?.length)return;const S=gl(D);p?v(S,m):g(S,h).catch(It)}),P=n.addListener(a.EVENT_TYPES.APPLICATION_UPDATE_ENTITY,_);return()=>{w(),P.dispose()}};let o;const i=()=>{const l=t.current(),u=t.history(),d=l?.get().docId;d!==o&&(r?.(),r=void 0,o=d,l&&u&&(r=s(l,u)))},c=t.subscribe(i);i(),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{r?.(),c()})}var bl=300,vl=15e3,Nr="em-canvas-busy-style";function _l(){if(document.getElementById(Nr))return;const e=document.createElement("style");e.id=Nr,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}function yl(e){const t=e.getBoundingClientRect(),n=document.createElement("div");return n.setAttribute("aria-busy","true"),Object.assign(n.style,{position:"fixed",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,cursor:"progress",display:"flex",alignItems:"center",justifyContent:"center"}),e.appendChild(n),{showSpinner(){_l(),n.style.background="rgba(128, 128, 128, 0.15)";const r=document.createElement("div");Object.assign(r.style,{width:"32px",height:"32px",borderRadius:"50%",border:"3px solid rgba(128, 128, 128, 0.35)",borderTopColor:"rgba(80, 80, 80, 0.9)",animation:"em-canvas-busy-spin 0.8s linear infinite"}),n.appendChild(r)},remove:()=>n.remove()}}var Sl=8e3;function wl(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,whenShown:()=>Promise.resolve(),alignTo:()=>{},resize:()=>{},dispose:()=>{}}}var Il=e=>{for(let t=e?.parentElement??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="hidden")return t}return null};function Tl(e,t,n,r,s){const o=n.readyTimeoutMs??Sl,i=document.createElement("div");i.dataset.canvasHost=e,r&&(i.dataset.canvasPlace=r),i.style.position="fixed",i.style.overflow="hidden",i.style.visibility="hidden";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,i.appendChild(l),t.appendChild(i),n.mark?.("created"),s||n.onCreated?.(l);const u=new a.Disposable;let d=!1,p=!1,m,b,y,E;const g=()=>{clearTimeout(E),E=setTimeout(()=>{p||(p=!0,b?.(new Error(`[canvas] ${e}: документ не загрузился за ${o} мс`)))},o)},v=()=>d?(y=Promise.resolve(),p=!0,y):(p=!1,y=new Promise((N,B)=>{m=N,b=B}),g(),y),_=()=>{if(clearTimeout(E),d=!0,p){y=Promise.resolve();return}p=!0,n.mark?.("loaded"),m?.()};l.addEventListener("load",_),u.addDispose(()=>{clearTimeout(E),l.removeEventListener("load",_)});let w;const P=()=>{w??=n.bindResizer?.(l)};let D=null,h=null,I;const f=()=>{if(!D){i.style.visibility="hidden",l.removeAttribute("id");return}n.elementId&&(l.id=n.elementId);const N=D.getBoundingClientRect(),B=h?.isConnected?h:Il(D),F=B?B.getBoundingClientRect():null,Y=F?Math.max(N.top,F.top):N.top,de=F?Math.min(N.bottom,F.bottom):N.bottom,tt=Math.max(0,de-Y);i.style.visibility=tt>0?"visible":"hidden",i.style.left=`${N.left}px`,i.style.top=`${Y}px`,i.style.width=`${N.width}px`,i.style.height=`${tt}px`,l.style.transform=`translateY(${N.top-Y}px)`};let S="",T="",A=0,O;const x=()=>{if(!D){O=void 0;return}O=window.requestAnimationFrame(x);const N=D.getBoundingClientRect(),B=h?.isConnected?h.getBoundingClientRect():void 0,F=`${Math.round(N.left)}:${Math.round(N.top)}:${Math.round(N.width)}:${Math.round(N.height)}:${B?`${Math.round(B.top)}:${Math.round(B.height)}`:"-"}`;F!==S&&(S=F,f());const Y=l.getBoundingClientRect().height;Y>0&&Y!==A&&(A=Y,D.style.height=`${Y}px`);const de=getComputedStyle(D).pointerEvents;de!==T&&(T=de,i.style.pointerEvents=de)},C=()=>{O===void 0&&D&&(O=window.requestAnimationFrame(x))},L=()=>{O!==void 0&&(window.cancelAnimationFrame(O),O=void 0)},H=()=>f();let k=[];const V=(N,B)=>{if(h=B,N&&k.length>0){const F=k;k=[],F.forEach(Y=>Y())}if(N===D){f();return}if(I?.disconnect(),I=void 0,D&&D.style.removeProperty("height"),S="",A=0,T="",D=N,!N){L(),f();return}n.onShown?.(l);try{if(typeof ResizeObserver=="function"){const F=new ResizeObserver(f);typeof F.observe=="function"&&(I=F,I.observe(N))}}catch{I=void 0}f(),P(),C()};window.addEventListener("scroll",H,!0),window.addEventListener("resize",H),u.addDispose(()=>{I?.disconnect(),O!==void 0&&window.cancelAnimationFrame(O),window.removeEventListener("scroll",H,!0),window.removeEventListener("resize",H)});const ae=N=>{d=!1,N&&n.onReload?.(l);let B;p||y===void 0?B=v():(g(),B=y);try{l.contentWindow?.location.reload()}catch{l.src=c}return B};return{element:l,ready(){return y??v()},reload:()=>ae(!0),reloadQuietly:()=>ae(!1),get shown(){return D!==null},whenShown(){return D!==null?Promise.resolve():new Promise(N=>{k.push(N)})},alignTo(N,B){V(N,B??null)},scrollBy(N,B){for(let F=D?.parentElement??null;F;F=F.parentElement){const Y=getComputedStyle(F);if((Y.overflowY==="auto"||Y.overflowY==="scroll")&&F.scrollHeight>F.clientHeight){F.scrollBy({left:N,top:B,behavior:"instant"});return}}window.scrollBy({left:N,top:B,behavior:"instant"})},resize(){w?.resize()},dispose(){V(null,null),w?.dispose(),u.dispose(),i.remove()}}}function Al(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",s=(d,p)=>d==="email"?`email:${p??n}`:d;let o,i=[];const c=()=>{i.forEach(d=>clearTimeout(d)),i=[],o?.remove(),o=void 0},l=new Map,u=(d,p,m)=>{const b=s(d,p),y=t.get(b);if(y)return y;const E=e.resolveMount();if(!E)return wl();const g=Tl(d,E,e,d==="email"?p??n:void 0,m);return t.set(b,g),g};return{get:d=>u(d),current:d=>u(d),peek:d=>t.get(s(d)),spare:()=>t.get(s("email",r())),ensureSpare:()=>u("email",r(),!0),promote(){const d=t.get(s("email",r()));if(!d)return;const p=t.get(s("email"));n=r();const m=l.get("email");d.alignTo(m?.slot??null,m?.clip??null),p?.alignTo(null)},alignSurface(d,p,m){l.set(d,{slot:p,clip:m??null}),(p?u(d):t.get(s(d)))?.alignTo(p,m??null)},visible(){for(const d of t.values())if(d.shown)return d},byWindow(d){if(d){for(const p of t.values())if(p.element.contentWindow===d)return p}},busy(d){c();const p=d?e.resolveMount():void 0;if(!p)return;const m=yl(p);o=m,i=[setTimeout(()=>m.showSpinner(),bl),setTimeout(c,vl)]},dispose(){c(),t.forEach(d=>d.dispose()),t.clear(),l.clear(),n="a"}}}var Cl=a.createIdentifier$1("canvas.resizerBinder"),Tt=a.createIdentifier$1("canvas.service"),Pl={created:z.canvasCreated,loaded:z.canvasLoaded};function Dl(e,t){if(e.getInstance(Tt))return;const n=Al({resolveMount:()=>t.resolveMount(),resolveSrc:s=>t.resolveSrc(s),resolveSandbox:Da,elementId:t.elementId,bindResizer:s=>e.getInstance(Cl)?.(s),onCreated:s=>Ge(e,s,"fresh"),onReload:s=>Ge(e,s,"fresh"),onShown:s=>Ge(e,s,"switch"),mark:s=>t.mark?.(Pl[s])}),r=q(e).addListener(a.EVENT_TYPES.SANDBOX_WHEEL,s=>{n.visible()?.scrollBy(s?.deltaX??0,s?.deltaY??0)});e.inject(Tt,n),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),n.dispose()})}function Ge(e,t,n){const r=q(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),fa(r))}function Rl(e,t){Ge(e,t,"promote")}function Ol(e,t){const n=t.contentWindow;n&&q(e).greet(n)}function Ll(e,t){const n=t.contentWindow;n&&q(e).forget(n)}function ie(e){return e.getInstance(Tt)}function Nl(e){const t=q(e),n=()=>ie(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(a.EVENT_TYPES.RELOAD,async()=>{await n()?.reload()}),s=t.addListener(i=>{i.data?.operation===a.EVENT_TYPES.SANDBOX_RESIZED&&n()?.resize()}),o=$(e,a.events.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),s.dispose(),o.dispose()})}var om=a.createIdentifier$1("HeadlessMode"),Ml=a.createIdentifier$1("HiddenMount");function xl(e){return e.getOrCreateInstance(Ml,()=>pe(!1))}function Mr(){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 kl(e){const t=e.getInstance(a.OPTIONS_SOURCE_ID);let n,r;e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{r?.remove(),r=void 0}),Dl(e,{resolveMount:()=>n,resolveSrc:o=>Ir(o==="block"),elementId:"email_iframe",mark:o=>U(o)}),t?.watch(o=>{if(n)return;const i=o?.element;if(i instanceof HTMLElement)n=i;else if(o!==void 0)n=r??=Mr();else return;ie(e)?.get("email")});let s;e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{s?.remove(),s=void 0}),xl(e).watch(o=>{const i=ie(e);if(i){if(o){s??=Mr(),i.alignSurface("email",s,s);return}s&&(i.alignSurface("email",null),s.remove(),s=void 0)}})}var xr=a.createIdentifier$1("canvas.headerFlow"),kr=["subject","preheader"],Fl=3e3,Bl={subject:a.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,preheader:a.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE};function jl(e){const t=se(e),n=q(e),r=E=>E?"remote":Lr(e)?"system":"user",s=(E,{guid:g,value:v,forced:_})=>{const w=we(t);if(!w||typeof v!="string"||g&&g!==w.get().docId)return;const P=t.forcedHeaders();if(P?.[E]&&!_&&v!==P[E])return;_&&t.endForcedHeaders();const D=w.get().attributes[E]??"";c=!0;try{Be(w,{[E]:v},{source:r(_)})}finally{c=!1}o[E]=v,Q(e,a.events.ON_HEADER_APPLIED_ID).fire({field:E,value:v,forced:!!_,isGenerated:v!==D&&!!v})};let o={},i,c=!1,l=Promise.resolve();const u=(E,g,v)=>{l=n.sendAsync(Bl[E],{value:g,guid:we(t)?.get().docId,...v?{force:!0,echo:!0}:{}}).catch(_=>{})};let d;e.inject(xr,{whenDelivered:async()=>{await l},reassert:E=>{const g=we(t),v=kr.filter(_=>E[_]);if(!(!g||v.length===0)){c=!0;try{Be(g,Object.fromEntries(v.map(_=>[_,E[_]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders({subject:E.subject??"",preheader:E.preheader??""}),clearTimeout(d),d=setTimeout(()=>t.endForcedHeaders(),Fl);for(const _ of v)o[_]=E[_],u(_,E[_],!0)}}});const p=()=>{i?.(),i=void 0;const E=we(t);if(!E){o={};return}const g=E.get().attributes;o={subject:g.subject,preheader:g.preheader},i=E.subscribe(({source:v})=>{if(c)return;const _=E.get().attributes,w=t.forcedHeaders();for(const P of kr){const D=_[P];D!==o[P]&&(o[P]=D,u(P,D??"",v==="system"&&w?.[P]!==void 0))}})};p();const m=t.subscribe(p),b=n.addListenerAsync(a.EVENT_TYPES.APPLICATION_SUBJECT_UPDATE,E=>s("subject",E)),y=n.addListenerAsync(a.EVENT_TYPES.APPLICATION_PREHEADER_UPDATE,E=>s("preheader",E));e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{b.dispose(),y.dispose(),m(),i?.(),clearTimeout(d)})}function Fr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function At(e,t){const n={...e};for(const r of Object.keys(t)){const s=t[r],o=e[r];Fr(s)&&Fr(o)?n[r]=At(o,s):s!==void 0&&(n[r]=s)}return n}function Ul(e,t){const n=a.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 At(n,s)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?At(n,t):n}function Hl(){const e=window.localStorage.getItem(a.LOCAL_STORAGE_ITEMS.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?a.DARK:a.LIGHT;return e&&e!=="system"?e:t}function $l(){const e=window.localStorage.getItem(a.LOCAL_STORAGE_ITEMS.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function Gl(e){const{config:t}=e;return{operation:a.EVENT_TYPES.UPDATE_PREVIEW,theme:e.theme,commonStyles:Ul(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}function Vl(e){const t=q(e),n=e.getInstance(a.CONFIG_SOURCE_ID),r=e.getInstance(a.OPTIONS_SOURCE_ID),s=se(e);let o,i="";const c=()=>{const v=n?.get()??{},_=Gl({config:v,emailCommonStyles:s.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:Hl(),codeMode:$l(),appName:"useblocks"}),w=JSON.stringify(_);w!==i&&(i=w,t.send(_))},l=t.onInit(()=>{i="",c()}),u=()=>{t.isInited()&&c()},d=n?.watch(u),p=r?.watch(v=>{o=v?.commonStyles,u()});let m;const b=()=>{m?.(),m=s.current()?.subscribe(u),u()};b();const y=s.subscribe(b),E=matchMedia(a.PREFERS_COLOR_SCHEME_DARK),g=()=>u();E.addEventListener("change",g),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{l.dispose(),d?.dispose(),p?.dispose(),m?.(),y(),E.removeEventListener("change",g)})}var Ct;(function(e){function t(s,o,i=(c,l)=>c===l){if(s===o)return!0;if(s.length!==o.length)return!1;for(let c=0;c<s.length;c++)if(!i(s[c],o[c]))return!1;return!0}e.isEqual=t;function n(s,o=i=>i){const i=new Set;return s.filter(c=>{const l=o(c);return i.has(l)?!1:(i.add(l),!0)})}e.unique=n;function r(s=[],o=[],i=(c,l)=>c===l){const c=[],l=[],u=[];for(const d of s){const p=o.find(m=>i(d,m));p?u.push({prev:d,next:p}):l.push(d)}for(const d of o)s.find(p=>i(d,p))||c.push(d);return{added:c,removed:l,exists:u}}e.diff=r})(Ct||(Ct={}));function Yl(e,t){return e.type===t.type&&e.key===t.key}function ql(e){const t=q(e),n=()=>e.getServices(a.SANDBOX_EXTENSIONS_ID)??[];let r=[];const s=t.onInit(()=>{r=n(),t.send(a.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,r)}),o=a.getServiceContainerId(a.SANDBOX_EXTENSIONS_ID),i=e.onInject(c=>{if(c!==o)return;const l=n();if(!t.isInited()){r=l;return}const{added:u,removed:d}=Ct.diff(r,l,Yl);if(r=l,d.length){if(d.some(p=>p.type==="script")){t.send(a.EVENT_TYPES.RELOAD);return}t.send(a.EVENT_TYPES.SANDBOX_REMOVE_EXTENSIONS,d.map(p=>p.key))}u.length&&t.send(a.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,u)});e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{s.dispose(),i?.dispose()})}var zl=a.createIdentifier$1("prewarm.editorVisible");function Kl(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Wl(e={}){const t=e.paint??Kl;let n=!1,r=!1,s=!1,o=!1,i=!1;const c=[],l=()=>{i||o||!n||!r||!s||(o=!0,t(()=>{i=!0,U(z.editorVisible);for(const u of c.splice(0))u()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){s=!0,l()},whenVisible(u){if(i){u();return}c.push(u)},contentShown:()=>s}}function Xl(e){return e.getOrCreateInstance(zl,()=>Wl())}var Jl=500,Ql=500,Zl=5e3;function ec(e){const t=e.quietMs??Jl,n=e.floorMs??Ql,r=e.ceilingMs??Zl;let s,o,i=0;const c=()=>{clearTimeout(s),clearTimeout(o),s=void 0,o=void 0},l=()=>{c(),e.run()},u=()=>{clearTimeout(s);const d=n-(Date.now()-i);s=setTimeout(l,Math.max(t,d))};return{start(){c(),i=Date.now(),o=setTimeout(l,r),u()},notify(){s!==void 0&&u()},cancel:c}}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},c={...e,...i};return Object.defineProperty(c,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),c}var Br="self-init:";function nc(e){return e.startsWith(Br)}function jr(e,t){const n=e.getActiveShowRequest();return nc(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function rc(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t();let s="";const o=()=>e.readDocument()?_t(e.readDocument()):s,i=()=>ge(e.container).editorPolicy,c=()=>e.readEmail(),l=()=>{const u=c();return{...u,id:e.isTemplate()||u.isNew?void 0:u.id,html:o()}};return{readContent:o,publicEmail:l,sendInitStart:()=>ee(n,"INIT_START",a.EVENT_TYPES.SANDBOX_INIT_START,{guid:c().renderGuid},void 0,r()),sendInited:()=>ee(n,"INITED",a.EVENT_TYPES.SANDBOX_INITED,{guid:c().renderGuid},void 0,r()),async sendContent(){const u=c(),{html:d,hasBrowserExtensionArtifacts:p}=Pr(u?.html||"");p&&e.events.browserExtensionDetected(),Dr(e.readDocument(),d),s=d,await ee(n,"SET_ENTITY",a.EVENT_TYPES.SANDBOX_SET_ENTITY,yt(o(),u.renderGuid,i(),e.readDocument()?.get().version),{guid:u.renderGuid,emailId:u.id??null},r())},refreshContent:()=>ee(n,"SET_ENTITY",a.EVENT_TYPES.SANDBOX_SET_ENTITY,yt(o(),c().renderGuid,i(),e.readDocument()?.get().version),void 0,r()),sendPreheader:async()=>{const u=c();if(u.preheader!==void 0)return ee(n,"PREHEADER",a.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE,{value:u.preheader,guid:u.renderGuid,force:!0},void 0,r())},sendSubject:async()=>{const u=c();if(u.subject!==void 0)return ee(n,"SUBJECT",a.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,{value:u.subject,guid:u.renderGuid,force:!0},void 0,r())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:u=>e.showFilled?.(u),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(l()),fireInit(u,d){if(!jr(t(),u)){t().getActiveShowRequest()?.showId;return}const p=c();p.id,p.renderGuid,t().completeShow(u),Be(e.readDocument(),{is_inited:!0},{source:"system"});const m=l();return d&&(m.reset=!0),e.events.inited(m)},fireEmailChanged(){e.events.emailChanged(l())},fireContentChanged(){e.events.contentChanged(o())}}}function sc(e){const t=()=>e.initPipeline();let n=!1,r,s,o,i=0,c;const l=rc({...e,waitScope:()=>({getSandboxTimeoutMs:g=>t().getSandboxTimeoutMs(g),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:c?.signal??t().signal})});let u;const d=(g,v)=>{if(u===g)return;u=g;const _=i;setTimeout(()=>{i!==_||t().signal.aborted||y(g,v).catch(()=>{})},0)},p=()=>{c?.abort(),c=void 0};let m;const b=()=>{const g=t().signal;g!==m&&(m?.removeEventListener("abort",p),m=g,g.addEventListener("abort",p))};async function y(g,v){const _=++i;p(),c=new AbortController,b();const w=()=>i!==_,P=l.readTarget(),D=t().generation,h=()=>D===t().generation&&!t().signal.aborted,I=v?"init:reset-":"init:";if(!v){const T=l.publicEmail();T?.id,T?.renderGuid,T?.preheader}let f=!1,S=!1;try{n=!0,await l.sendInitStart(),l.fireWillInit(),await(v?l.refreshContent():l.sendContent()),f=!0,v||l.publicEmail()?.id;try{await l.sendPreheader()}catch(T){`${I}`,String(T)}try{await l.sendSubject()}catch(T){`${I}`,String(T)}if(w()||l.showFilled(P),await l.sendInited(),S=!0,s===g){const T=e.readSandboxGeneration?.()??o;T!==void 0&&(r=T)}await l.revealFilled()}catch(T){throw w()||(`${I}`,{...e.describeSurface?.(),error:String(T)},void 0),!w()&&jr(t(),g)&&t().failShow(g,T),T}finally{E(g,v,I,{superseded:w(),sessionGeneration:D,contentApplied:f,sandboxInitedAcked:S,commit:h()})}}function E(g,v,_,w){const{superseded:P,contentApplied:D,sandboxInitedAcked:h}=w;if(P){`${_}`;return}h&&w.commit?l.fireInit(g,v||void 0):h?(`${_}`,w.sessionGeneration,t().generation,t().signal.aborted,void 0):D?(`${_}`,void 0):(`${_}`,void 0),n=!1,c=void 0,!h&&s===g&&(s=void 0,r===o&&(r=void 0)),!h&&D&&d(g,v)}return{channel:l,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:g=>{r=g},lastCorrelation:()=>s,markCorrelation:g=>{s=g},bumpRunSeq:()=>{i+=1},noteSandboxGeneration:g=>{o=g},fill:g=>y(g,!1),refill:g=>y(g,!0),stop:()=>{i+=1,p(),n=!1,m?.removeEventListener("abort",p),m=void 0}}}function oc(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:Ur(e,n)}function Ur(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function ic(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:s,readSandboxGeneration:o}=e,i=d=>{const p=n(),m=s();if(!oc(p,d,m)){d.showId,d.navId,d.emailId,p?.id,p?.showId,p?.renderGuid;return}d.showId,p?.id,p?.renderGuid,t.markFilled(o()),t.markCorrelation(d.showId),t.fill(d.showId).catch(()=>{})};return{showRequested:d=>{i(d)},showRequestIdentityChanged:()=>{const d=e.initPipeline().getActiveShowRequest();d&&i(d)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const d=o();if(t.filledGeneration()===d)return;const p=n(),m=s();if(!p?.renderGuid||!Ur(p,m))return;const b=`${Br}${p.renderGuid}`;t.markFilled(d),t.markCorrelation(b);const y=r()?.isReady()===!0;p.id,p.renderGuid,(y?E=>t.refill(E):E=>t.fill(E))(b).catch(()=>{t.lastCorrelation()===b&&t.markFilled(void 0)})},saasChanged:()=>{const d=n();d?.renderGuid,d?.showToken,d?.id}}}function ac(e){return e??""}function lc(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function cc(e){const t=se(e),n=q(e),r=()=>ne(t.sessionKey())?void 0:t.current(),s=()=>{const R=r();return tc({attributes:R?.get().attributes??{},readContent:()=>R?.getContent(),docId:R?.get().docId,hasSession:!!R,serverId:R?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(a.INIT_PIPELINE_ID)??St;let i={},c=!1;const l=e.getInstance(a.OPTIONS_SOURCE_ID)?.watch(R=>{c=!!R?.element});let u=!1,d=!1,p=!1,m=0;const b=()=>{const R=ie(e);if(!R)return;const G=++m,j=R.spare();return j&&Ll(e,j.element),(j?j.reloadQuietly():R.ensureSpare()?.ready())?.then(()=>{if(G!==m)return;u=!0;const Z=R.spare();Z&&Ol(e,Z.element),p&&(p=!1,T(),V())})},y=ec({run:()=>{p||b()?.catch(()=>{})}}),E=()=>{Xl(e).noteContentShown(),!u&&!p&&y.start()};let g=!1;const w=sc({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:s,revealFilled:()=>{const R=ie(e);return g&&R&&(g=!1,y.start()),c?R?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:R=>{const G=ie(e),j=G?.spare()?.element.contentWindow;d&&G&&j&&R===j&&(d=!1,G.promote(),G.busy(!1),g=!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!i.isTemplate,readSandboxGeneration:()=>oe(n),describeSurface:()=>({canvasPath:S,promoted:d,spareClean:u,handshake:n.isInited(),generation:oe(n)}),events:{willInit:R=>{Q(e,a.events.WILL_EMAIL_INIT_ID).fire(R)},inited:R=>{E(),Q(e,a.events.ON_EMAIL_INIT_ID).fire(R)},contentChanged:R=>{Q(e,a.events.ON_CONTENT_CHANGED_ID).fire(R)},emailChanged:R=>{Q(e,a.events.ON_EMAIL_CHANGED_ID).fire(R)},browserExtensionDetected:()=>{Q(e,a.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),P=ic({pipeline:w,initPipeline:o,readEmail:s,readDocument:r,readRouteEmailId:()=>i.emailId,readSandboxGeneration:()=>oe(n)});let D="",h="",I="";const f=R=>R.length>0;let S="none";const T=()=>{const R=ie(e)?.spare();R&&(n.send({operation:a.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!0}),u=!1,d=!0,Rl(e,R.element))},A=(R,G)=>{const j=ie(e);if(!j)return!0;const Z=j.spare(),ue=Z&&u?"spare":"prepare";if(S=ue,j.busy(!0),Z&&u)return T(),!0;y.cancel(),n.send({operation:a.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!0});const fe=b();if(fe===void 0)return S="reload",j.busy(!1),j.peek("email")?.reload(),!0;p=!0;const gn=m;return fe.catch(()=>{!p||gn!==m||(p=!1,S="reload",j.busy(!1),j.peek("email")?.reload())}),!1},O=()=>{de(),w.noteSandboxGeneration(oe(n));const R=s(),G=lc(R?.renderGuid,R?.showId,R?.id,i.emailId),j=ac(R?.renderGuid);if(j!==h){const fe=f(h),gn=h;h=j,fe&&A(gn,j)}if(p)return;G!==D&&(D=G,P.showRequestIdentityChanged());const Z=r(),ue=`${G}|${Z?.get().docId??""}|${oe(n)}`;ue!==I&&Z?.isReady()===!0&&(I=ue,P.selfInitChanged()),P.saasChanged(),H()};let x=!1,C="",L="";const H=()=>{const R=s();if(!R?.renderGuid)return;const G=w.channel.readContent(),j=JSON.stringify([R.preheader,R.common_styles,R.meta,R.subject,R.utm_parameters?.utm_campaign??"",R.utm_parameters?.utm_content??"",R.utm_parameters?.utm_medium??"",R.utm_parameters?.utm_source??"",R.utm_parameters?.utm_term??""]),Z=x&&G!==L,ue=x&&j!==C;if(x=!0,L=G,C=j,w.isEventsLocked())return;const fe={...R,id:i.isTemplate||R.isNew?void 0:R.id,html:G};if(Z){Q(e,a.events.ON_CONTENT_CHANGED_ID).fire(G),Q(e,a.events.ON_EMAIL_CHANGED_ID).fire(fe);return}ue&&R.is_inited&&Q(e,a.events.ON_EMAIL_CHANGED_ID).fire(fe)};let k=!1;const V=()=>{k||(k=!0,queueMicrotask(()=>{k=!1,O()}))};e.inject(wt,{pipeline:w,setRoute:R=>{R.emailId===i.emailId&&!!R.isTemplate==!!i.isTemplate||(i=R,V())}});let ae,N;const B=()=>{const R=r()?.get().docId;R!==N&&(ae?.(),N=R,ae=r()?.subscribe(V)),V()};let F,Y;const de=()=>{const R=e.getInstance(a.INIT_PIPELINE_ID);!R||R===F||(Y?.(),F=R,Y=R.onShowRequested(G=>P.showRequested(G)))},tt=n.addListener(R=>{R.data?.operation===a.EVENT_TYPES.SANDBOX_RESIZED&&y.notify()}),zp=t.subscribe(B),Kp=yr(n,V);B(),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{l?.dispose(),Y?.(),Kp(),zp(),ae?.(),tt.dispose(),y.cancel(),w.stop()})}function dc(){return a.USEBLOCKS!=="useblocks"}var Pt={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},uc={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},Hr=Pt,fc=["freeUserBlocks","blocks"],$r={};function pc(e){$r=e}var Gr=e=>fc.includes(e)?Hr:$r[e]??Hr,Dt={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},mc={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},hc={...Dt,config:{...Dt.config,imageCenterFileManagerView:!1}};pc({pro:uc,editor:mc,simple:dc()?Dt:hc,freeUserBlocks:Pt,blocks:Pt});var Vr=new Set;function gc(){return window.localStorage.getItem(a.LOCAL_STORAGE_ITEMS.em_color_scheme)??void 0}function Ec(e){return Vr.add(e),e(gc()),{dispose(){Vr.delete(e)}}}function Rt(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function bc(e,t){return t.modeDefaults(Rt(e,t.fallbackMode))}function vc(e,t){const n=Rt(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function _c(e,t){const n=Rt(e,t),r=e.user?.advancedConfigs?.[n],s=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...s}}function yc(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Sc(e){return a.mergeResourceProxyLayers(e.map(t=>t?.resourceProxy))}function wc(e){return a.mergeResourceProxyPolicyLayers(e.map(t=>t?.resourceProxyPolicy))}function Ic(e){return a.mergeBackendProxyLayers(e.map(t=>t?.backendProxy))}function Tc(e){return a.mergeShallowConfigLayers(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Ac(e,t){return[e.base,bc(e,t),e.profile,e.serverSide,vc(e,t.fallbackMode),e.user,_c(e,t.fallbackMode),e.local]}function Ot(e,t){const n=Ac(e,t),r=a.mergeShallowConfigLayers(n),s=yc(n);s!==void 0&&(r.fileManager=s);const o=Sc(n);o!==void 0&&(r.resourceProxy=o);const i=wc(n);i&&Object.keys(i).length>0&&(r.resourceProxyPolicy=i);const c=Ic(n);c!==void 0&&(r.backendProxy=c);const l=Tc(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}var Cc=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Yr(e){return e==="server"?"serverSide":e}function Pc({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},s=pe();let o={kind:"pending"},i;const c=new Promise(m=>{i=m}),l=n===void 0?void 0:setTimeout(()=>{d({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function u(){o.kind!=="pending"&&s.set(Ot(r,e))}function d(m){if(o.kind!=="pending")return;clearTimeout(l),o=m;const b=Ot(r,e);s.set(b),i(b)}function p(m,b){r[Yr(m)]=b,m==="server"&&o.kind==="pending"?d({kind:"applied"}):u()}return{watch:m=>s.watch(m),select:m=>s.select(m),get:()=>s.get(),ready:()=>c,state:()=>o,layers:()=>({...r}),bootstrap(){const m=Ot(r,e);return Object.fromEntries(Cc.map(b=>[b,m[b]]))},merge(m,b){p(b,{...r[Yr(b)],...m})},replace(m,b){p(b,m)},setMode(m){r.user={...r.user,mode:m},u()},setAdvancedConfigs(m){r.advancedConfigs=m,u()},serverAbsent(m){d({kind:"absent",reason:m})},applyServerResponse(m){o.kind==="pending"&&p("server",{...r.serverSide,...m})},dispose(){clearTimeout(l)}}}var Dc=5e3,Rc="blocks";function Oc(){return{...Gr(Rc)?.config,mergeTags:void 0}}function Lc(e,t){e.getInstance(a.OPTIONS_SOURCE_ID)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function Nc(e,t){let n;dr(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 Mc(e,t){let n=null;const r=Ec(s=>{const o=typeof s=="string"&&s?s:void 0;o!==n&&(n=o,t.replace(o?{theme:o}:{},"local"))});e.getInstance(a.DISPOSABLE_ID)?.addDisposable(r)}async function xc(e,t){if(e.getInstance(it)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(a.APP_ID);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function kc(e){e.injectFactory(a.CONFIG_SOURCE_ID,(t,n)=>{if(n)return n;const r=Pc({base:Oc(),env:{modeDefaults:s=>Gr(s)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Dc});return Lc(e,r),Nc(e,r),Mc(e,r),xc(e,r),e.getInstance(a.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var Ee=class extends a.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 M(e,t,n){const r=a.snapshot(e);return(s,o,i)=>{const c=r(async l=>{const u=t?t(l):l;i&&s.bind(i);const d=await s(u);return n?n(d):d},o,i);return()=>c.dispose()}}var Fc=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new a.Emitter;this.handleDestroy=M(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Ee(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{}}},Lt=a.createIdentifier$1("DestroyableService");function Bc(e){e.injectFactory(Lt,()=>{const t=e.getInstance(a.DISPOSABLE_ID);if(!t)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Fc({lifetime:t,options:e.getInstance(a.OPTIONS_SOURCE_ID),getInstance:()=>e.getInstance(a.INSTANCE_ID),release:()=>a.releaseContainer(e.getInstance(a.STORE_ID)??e)})},!0)}function jc(e){const t=e.getInstance(Lt);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var Uc=1e3;function qr(e,t,n=Uc,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(!qr(e[i],t[i],n,r+1))return!1;return!0}return!1}function Te(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];qr(s,o)||(n[r]=s)}return n}var Hc=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail не ответил за ${e}ms — письмо не сохранено`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}},$c=({source:e,emailtags:t,group:n,tags:r,...s})=>s,Gc=()=>xn();async function Vc({emails:e},t){const n=Gc();let r;try{return await Promise.race([e.notifySave(t),new Promise((s,o)=>{r=setTimeout(()=>{const i=new Hc(n);t.value.id,o(i)},n)})])}finally{r!==void 0&&clearTimeout(r)}}function Yc(e){const{emails:t}=e,n=async(r,s)=>{const o=$c(s),i=r===void 0?void 0:await t.cache.getIfPresent(r),c=i?{...i,...o}:o,l=await Vc(e,{prev:i,patch:i?Te(i,o):o,value:c,source:s.source??""}),u=String(l.id??r??a.generateUUID()),d=l.id===void 0?{...l,id:u}:l;return await t.cache.addOrUpdate(u,()=>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:a.generateUUID()}},async updateEmail(r,s){return await n(r,s)}}}var Nt=20,qc=({source:e,emailtags:t,group:n,tags:r,...s})=>s;function zc({revisions:e,revisionsByEmail:t}){const n=async(r,s)=>(t.clear(),await t.get(r,{page:s}),(await e.cache.values()??[]).filter(o=>String(o?.parent)===String(r)));return{async readRevisions(r,s=1){const o=await n(r,s);return{revisions:o.slice(Nt*(s-1),Nt*s),page:s,hasMore:o.length>Nt*s}},async readAutosave(r){return bi(await n(r,1))},async saveAutosave(r,s){const o=qc(s);return await e.create({...o,parent:r,modified:new Date().toString()})}}}var Kc=class extends a.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}},Wc=class extends a.AsyncEmitter{};function im(e){return e}var zr=class extends a.Disposable{_items=new Map;_onChangeEmitter=new a.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 a.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 Xc(e,{filter:t,order:n="asc",orderBy:r,page:s,pageSize:o=20}={}){const i=e.length;let c=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(u=>{for(const d of l){const p=u[d],m=t[d];return d==="id"||typeof p!="string"?p===m:typeof m=="string"&&p.startsWith(m)}return!0}),c=e.length}return r&&(e=e.sort((l,u)=>(l[r]>u[r]?1:u[r]>l[r]?-1:0)*(n==="asc"?1:-1))),s!==void 0&&(e=e.slice(o*(s-1),o*s)),{data:e,filteredTotal:c,total:i,totalPages:Math.ceil(c/o)}}function Jc(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 Qc(e,t){return Kr(e)&&Kr(t)?String(e)===String(t):e===t}function Kr(e){return typeof e=="string"||typeof e=="number"}var Zc=class extends a.Disposable{_cache=new zr;_readEmitter=new a.AsyncEmitter;_saveEmitter=this.addDisposable(new Kc);_removeEmitter=this.addDisposable(new Wc);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new a.Disposable);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new zr),s=n.addDisposable(new a.AsyncEmitter);t=this._foreignCache[e]={get:async(o,i={})=>{await r.getOrCreate(o,async()=>{try{const l=Jc(await s.fire(o))||[];for(const u of l)u[e]=o,await this._cache.add(u.id,u);return l}catch{return[]}});const c=(await this._cache.values()||[]).filter(l=>{const u=l[e];return u==null||Qc(u,o)});return Xc(c,i)},first(o,i={}){return t.get(o,{...i,page:1,pageSize:1}).then(({data:c})=>c[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=a.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?Te(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 Ae(e){const t=a.createIdentifier$1(e);return n=>n.getOrCreateInstance(t,()=>new Zc)}function ed(e){const t=e.getInstance(a.DISPOSABLE_ID);if(!t)throw new Error("Failed");return t}function Wr(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function td(e,t,n){return e&&!Wr(t)&&Wr(e)?{...n,meta:e.meta}:n}var Xr=Ae("plugin.dataSource.emails"),Jr=Ae("plugin.dataSource.emailRevisions"),Qr=a.createIdentifier$1("emailDocuments.provided");function nd(e){const t=Xr(e),n=Jr(e),r=n.byForeignKey("parent");return e.getInstance(Qr)?{emails:t,emailRevisions:n}:(e.inject(Qr,!0),Bi(e,Yc({emails:t})),$i(e,zc({revisions:n,revisionsByEmail:r})),ed(e).addDisposable(t.onSave(({prev:s,patch:o,value:i})=>td(s,o,i),Number.MIN_VALUE)),{emails:t,emailRevisions:n})}function Zr(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 rd(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var sd="po",Ve=null;function od(){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([sd],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function id(){return Ve===null&&(Ve=od().catch(e=>{throw Ve=null,e})),Ve}async function es(e){if(typeof e=="object")return Mt(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?ad(t):ld(t)}function Mt(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function ad(e){try{return Mt(JSON.parse(e))}catch{return}}var ts=!1;async function ld(e){try{return Mt((await id()).parsePoCatalog(e))}catch{ts||(ts=!0);return}}var cd="em_locale",dd="em_ant_locale",ud="locale",fd="ant_locale";function xt(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function ns(e,t){const n=xt(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function pd(){return xt("em_locale")??ns(ud,"em_locale")}function rs(e){try{localStorage.setItem(cd,JSON.stringify(e))}catch{}}function md(){return xt("em_ant_locale")??ns(fd,"em_ant_locale")}function hd(e,t){try{localStorage.setItem(dd,JSON.stringify({id:e,data:t}))}catch{}}var am="en_US",gd=8e3;function Ed(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 bd(e){const t=pd(),n=md();let r={ready:!1},s;const o=pe(r);let i=0;const c=g=>{r={...r,...g},o.set(r)},l=()=>{r.ready||c({ready:!0})},u=setTimeout(l,e.unlockAfterMs??gd),d=g=>g!==i;let p;async function m(g,v){if(n?.id===g&&n.data&&c({antd:n.data}),!p)return;const _=await p(g).catch(()=>{});!_||d(v)||(c({antd:_}),hd(g,_))}async function b(g,v){const _=await e.askHost(g).catch(()=>null);if(d(v))return!0;if(_==null)return!1;const w=await es(_);return d(v)||(w&&c({catalog:w}),l()),!0}async function y(g,v){const _=await e.readList();if(d(v))return;if("error"in _){c({failure:{kind:"GET_LOCALES_ERROR",error:_.error}}),l();return}const w=_.data.find(D=>D.locale===g);if(!w){rd("em_locale")&&c({catalog:void 0}),l();return}if(Zr(t,w)&&(!s||s.catalog===t?.data)){l();return}if(s?.entry&&r.catalog===s.catalog&&Zr(s.entry,w)){rs(s.entry),l();return}const P=await e.readCatalog(g);if(!d(v)){if("error"in P){c({failure:{kind:"GET_LOCALE_ERROR",error:P.error}}),l();return}P.data&&(s?.id===g&&r.catalog===s.catalog&&Ed(s.catalog,P.data)||c({catalog:P.data}),rs({id:g,time:w.updatedAt||Math.floor(Date.now()/1e3),hash:w.contentHash,data:P.data})),l()}}async function E(g,v){if(!await b(g,v)){if(!d(v)&&(s?.id===g&&r.catalog===s.catalog||g==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await y(g,v)}}return{set(g){if(!g||g===r.id)return;const v=i+=1;c({id:g,failure:void 0});const _=s?.id===g&&r.catalog===s.catalog;(s&&!_&&r.catalog===s.catalog||g==="en_US"&&r.catalog)&&c({catalog:void 0}),t?.id===g&&t.data&&(c({catalog:t.data}),l()),m(g,v),E(g,v)},prime(g,v,_){r.id||r.catalog||!v||(s=t?.id===g&&t.data&&(!_||t.time>=_.time)?{id:g,catalog:t.data}:{id:g,catalog:v,entry:_?{id:g,time:_.time,hash:_.hash,data:v}:void 0},c({catalog:s.catalog}))},useAntdLoader(g){p=g,r.id&&m(r.id,i)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(u)}}var vd=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})},_d=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:c,...l})=>{const u=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},d=this.mergeRequestParams(l,u),p=s&&this.toQueryString(s),m=this.contentFormatters[r||"application/json"],b=o||d.format;return this.customFetch(`${i||this.baseUrl||""}${n}${p?`?${p}`:""}`,{...d,headers:{...d.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(c?this.createAbortSignal(c):d.signal)||null,body:typeof e>"u"||e===null?null:m(e)}).then(async y=>{const E=y;E.data=null,E.error=null;const g=b?y.clone():y,v=b?await g[b]().then(_=>(E.ok?E.data=_:E.error=_,E)).catch(_=>(E.error=_,E)):E;return c&&this.abortControllers.delete(c),v})}},yd=a.createIdentifier$1("rest.v2.transport"),ss=Symbol("rest.v2.secureRequest");function Sd(e){return e.getOrCreateInstance(yd,()=>{const t=e.getInstance(a.CUSTOM_FETCH_ID)?.execute||fetch;return new _d({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[ss]:!0}),customFetch:(n,r={})=>{const{[ss]:s,...o}=r;return t(n,{...o,[a.PUBLIC_REQUEST]:s!==!0})}})})}function wd(e,t){const n=Sd(e);return Object.assign({},...t.map(r=>new r(n)))}function os(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function is(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:os(n.details,"wp_code")??n.code,message:os(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 as(e){return!e.ok||!!e.error}function Id(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function ls(){return Id(a.LOCAL_STORAGE_ITEMS.em_translations_v2)??!0}function Td(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Ad(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Cd(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:Td(r[1])}),t},[]):[]}function Pd(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Ad(n.updated_at),contentHash:n.content_hash}),t),[])}function cs(e){return wd(e,[vd])}function Ye(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function kt(e){return!e.ok||e.error!=null}function Ft(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Bt(e){return{data:await es(e)??null}}async function Dd(e){if(ls())try{const n=await cs(e).localesList();return as(n)?{error:is(n)}:{data:Pd(n.data)}}catch(n){return Ye(n)}const t=a.getApi(e,[An]);try{const n=await t.get_translations2({file:"react_app"});return kt(n)?Ft(n):{data:Cd(n.data)}}catch(n){return Ye(n)}}async function Rd(e,t){if(ls())try{const r=await cs(e).jsonList({locale:t});return as(r)?{error:is(r)}:Bt(r.data)}catch(r){return Ye(r)}const n=a.getApi(e,[An]);try{const r=await n.get_translations3({id:t,file:"react_app"});return kt(r)?Ft(r):Bt(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return kt(r)?Ft(r):Bt(r.data)}catch(r){return Ye(r)}}}var Ce=a.createIdentifier$1("locale.service");function Od(e){if(e.getInstance(Ce))return;const t=bd({readList:()=>Dd(e),readCatalog:n=>Rd(e,n),askHost:async n=>(await Q(e,a.events.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(a.SECURITY_MODULE_ID)});e.inject(Ce,t),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>t.dispose())}function Ld(e){const t=e.getInstance(a.CONFIG_SOURCE_ID);if(!t)return;const n=e.getInstance(Ce);if(!n)return;const r=t.select(s=>s.locale).watch(s=>n.set(s));e.getInstance(a.DISPOSABLE_ID)?.addDisposable(r)}var Nd="user_id",Md="project_id",ds=a.createIdentifier$1("rest.identityHeadersProvided");function xd(e){if(e.getInstance(ds))return;e.inject(ds,!0);let t;e.getInstance(a.OPTIONS_SOURCE_ID)?.watch(n=>{t=n}),e.addService(a.REQUEST_HANDLER_ID,{execute(n,r){if(r?.public)return;const s=t?.user?.id??ur(e).profile?.id;s!=null&&s!==""&&n.headers.set(Nd,String(s));const o=t?.project;o!=null&&o!==""&&n.headers.set(Md,String(o))}})}function kd(e){if(!e)return!1;try{return e.getInstance(a.SECURITY_MODULE_ID)!==void 0}catch{return!1}}var Fd="Invalid standaloneKey.",lm=a.createIdentifier$1("StandaloneMockGuard");function Bd(){const e=new Error(Fd);return e.name="InvalidStandaloneKeyError",e}function jd(e){e.addService(a.REQUEST_HANDLER_ID,{execute:()=>{if(kd(e))throw Bd()}})}function Ud(e){a.registerRestTransport(e),jd(e)}function Hd(e){const t=new Or;e.inject(a.INIT_PIPELINE_ID,t);let n;const r=e.getInstance(a.OPTIONS_SOURCE_ID)?.watch(o=>{o&&(o.signal!==void 0&&(n=o.signal),t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...n!==void 0?{signal:n}:{}}))}),s=e.getInstance(a.DISPOSABLE_ID);r&&s?.addDisposable(r),s?.addDispose(()=>{t.abort()})}var $d=Ae("plugin.dataSource.blocks"),Gd=Ae("plugin.dataSource.blockRevisions"),Vd=Ae("plugin.dataSource.comments"),Yd=Rr(),qd=Rr(),us=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2085
+ `));return{html:tl(t.html),hasBrowserExtensionArtifacts:t.found}}function yt(e){return e?.getContent()??""}function Fr(e,t){e?.mutate({content:Jn(t)},{source:"remote"})}function Br(e){return a.createIdentifier$1(e)}function Z(e,t){return e.getOrCreateInstance(t,()=>new a.AsyncEmitter)}function $(e,t){return e.getOrCreateInstance(t,()=>new a.AsyncEmitter).event}function St(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var nl=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}},rl=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(a.createAbortError("Superseded by newer show()")),n.aborted?Promise.reject(a.createAbortError(n.reason)):(this._activeRequest=e,new Promise((r,s)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{s(new nl(e.showId,t))})},t);o.unref?.();const i=()=>{this._settle(e.showId,()=>{s(a.createAbortError(n.reason))})};n.addEventListener("abort",i,{once:!0});const c=()=>{clearTimeout(o),n.removeEventListener("abort",i)};this._pending.set(e.showId,{request:e,resolve:r,reject:s,timeoutId:o,dispose:c});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function sl(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function ol(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Un(e),n=Hn(e),r=Zo(e.sandbox);t<n+r}var jr=class{_controller=new AbortController;_externalSignalDisposable=new a.Disposable;_sessionChangeListeners=new Set;_showRegistry=new rl;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Un(this._timeouts)}getSandboxTimeoutMs(e){return jn(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return Hn(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=sl(this._timeouts,e.timeouts),ol(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}abort(e){const t=e??a.createAbortError("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new a.Disposable}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new a.Disposable,this._showRegistry.rejectAll(a.createAbortError("Init session replaced")),this._controller.signal.aborted||this._controller.abort(a.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??a.createAbortError()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??a.createAbortError()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},wt=(()=>{const e=new jr;return e.configure({}),e})(),il=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 al(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 ll(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(a.throwIfAborted(n),new Promise((r,s)=>{let o=!1,i,c;const l=d=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),c?.dispose(),n?.removeEventListener("abort",u),d())},u=()=>{l(()=>s(a.createAbortError(n?.reason)))};if(c=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(i=setTimeout(()=>{l(()=>s(new il(t)))},t)),n?.addEventListener("abort",u)}))}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 dl(e,t,n){return t<=0?e:new Promise((r,s)=>{let o=!1,i;const c=l=>{o||(o=!0,i!==void 0&&(clearTimeout(i),i=void 0),l())};i=setTimeout(()=>{c(()=>s(new cl(n,t)))},t),e.then(l=>{c(()=>r(l))},l=>{c(()=>s(l))})})}var ul=2,Ve=Symbol("sandbox:frame-replaced");function te(e,t,n,r,s,o,i){const c=`sandbox:${t}`,l=o?.getSandboxTimeoutMs(t)??dt[t],u=()=>{let S=dl(e.sendAsync(n,r),l,c);return S=a.raceWithAbortSignal(S,o?.signal),Ie(c,S,s)};if(t==="INIT_START"&&al(e)){const S=o?.getSandboxReadyTimeoutMs()??2e4,E=e,g=v=>{const _=ll(E,S,o?.signal);return Ie("sandbox:INIT_START:ready-wait",_,s).then(()=>{if(!i||v<=0)return u();const w=i.getGeneration();let P;const D=new Promise((I,f)=>{P=i.onChange(()=>{i.getGeneration()!==w&&f(Ve)})}),h=u();return h.catch(()=>{}),Promise.race([h,D]).finally(()=>P?.()).catch(I=>{if(I!==Ve)throw I;return{...s},g(v-1)})})};return g(ul)}if(!i)return u();const d=i.getGeneration();let p;const m=new Promise((S,E)=>{p=i.onChange(()=>{i.getGeneration()!==d&&E(Ve)})}),b=u();return b.catch(()=>{}),Promise.race([b,m]).finally(()=>p?.()).catch(S=>{throw S===Ve&&{...s},S})}var fl=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],pl=200;function ml(e=new Set){const t=new Set;return(n,r)=>{if(!fl.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>=pl&&t.clear(),t.add(s))}}function hl(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:ml()}}var gl=hl();function ge(e){return e?.getInstance(a.TEMPLATE_DIRECTIVES_ID)??gl}function El(e){const t=oe(e),n=Y(e),r=()=>e.getInstance(a.INIT_PIPELINE_ID)??wt;let s,o,i=!1,c=!1;const l=async(_,w,P)=>{const D=P.generation,h=()=>P.generation!==D||P.signal.aborted||t.current()!==_||c,I=ie(n);i=!0;try{if(await te(n,"INIT_START",a.EVENT_TYPES.SANDBOX_INIT_START,{guid:w},void 0,P),h())return;const{html:f,hasBrowserExtensionArtifacts:y}=kr(yt(_));if(y&&Z(e,a.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Fr(_,f),await te(n,"SET_ENTITY",a.EVENT_TYPES.SANDBOX_SET_ENTITY,St(yt(_),w,ge(e).editorPolicy,_.get().version),void 0,P),h())return;await te(n,"INITED",a.EVENT_TYPES.SANDBOX_INITED,{guid:w},void 0,P),s=w,o=I}finally{i=!1}},u=()=>re(t.sessionKey())?t.current():void 0,d=()=>{if(c||i)return;const _=u(),w=_?.get().docId;if(!_||!w||s===w&&o===ie(n)||!_.isReady())return;const P=r();P.signal.aborted||l(_,w,P).catch(()=>{})};let p=!1;const m=()=>{p||c||(p=!0,queueMicrotask(()=>{p=!1,d()}))};let b,S;const E=()=>{const _=u(),w=_?.get().docId;w!==S&&(b?.(),S=w,b=_?.subscribe(m)),m()},g=t.subscribe(E),v=Dr(n,m);E(),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{c=!0,v(),b?.(),g()})}var bl=200;function vl({startVersion:e,limit:t=bl}){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 c=n.filter(u=>u.version>i);s(i);let l=o;for(const u of c){if(u.fromCanvas||u.contentReplaced||!u.changes)return null;const d=u.changes,p=[];for(const m of l){const b=di(m.range,d,"after");if(!b)return null;p.push({range:b,text:m.text})}l=p}return l}}}function _l(e,t){let n=0;return e.map(({start:r,end:s,text:o})=>{const i=new Q(r,t.slice(r,s),r+n,o);return n+=o.length-(s-r),i})}function yl(e,t){const n=[...e].sort((r,s)=>r.range.start-s.range.start);return _l(n.map(({range:r,text:s})=>({start:r.start,end:r.end,text:s})),t)}function Sl(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var It=a.createIdentifier$1("canvas.sandboxFill");function Ur(e){return e.getInstance(It)?.pipeline.isEventsLocked()===!0}function Tt(e){Fe(e,{origin:"canvas-channel"})}function wl(e){const t=oe(e),n=Y(e);let r;const s=(l,u)=>{const d=l.get().docId;let p=!1,m=null,b=null;const S=vl({startVersion:l.get().version});let E=l.getContent();const g=async(D,h)=>{if(b){b.push({edits:D,rev:h});return}b=[{edits:D,rev:h}];try{do{const I=b.splice(0,b.length);await n.sendAsync(a.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:I.map(f=>f.edits),guid:d,rev:I[I.length-1].rev})}while(b.length)}finally{b=null}},v=(D,h)=>{const I=b?.splice(0,b.length)??[];I.length&&n.sendAsync(a.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:I.map(f=>f.edits),guid:d,rev:I[I.length-1].rev}).catch(Tt),n.sendAsync(a.EVENT_TYPES.SANDBOX_UPDATE_ENTITY,{edits:[D],guid:d,rev:l.get().version,...h!==null?{changeId:h}:{}}).catch(Tt)},_=D=>{const{guid:h,pushUndoStop:I}=D;if(h!==d)return;const f=yi(D);let{edits:y}=D;if(f.baseRev!==null){const L=S.rebase(y,f.baseRev);if(!L){Fe(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),v([],f.changeId);return}y=L}const A=l.get().version;try{p=!0,m=f.changeId;const L=yl(y,l.getContent());I===!1?u.applyWithoutHistory(L):l.mutate({changes:L},{source:Ur(e)?"system":"user"})}finally{p=!1,m=null}l.get().version===A&&f.baseRev!==null&&v([],f.changeId)},w=l.subscribe(({changes:D,version:h})=>{const I=l.getContent(),f=!D?.length&&I!==E;if(E=I,S.record({version:h,changes:D,contentReplaced:f,fromCanvas:p}),!D?.length)return;const y=Sl(D);p?v(y,m):g(y,h).catch(Tt)}),P=n.addListener(a.EVENT_TYPES.APPLICATION_UPDATE_ENTITY,_);return()=>{w(),P.dispose()}};let o;const i=()=>{const l=t.current(),u=t.history(),d=l?.get().docId;d!==o&&(r?.(),r=void 0,o=d,l&&u&&(r=s(l,u)))},c=t.subscribe(i);i(),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{r?.(),c()})}var Il=300,Tl=15e3,Hr="em-canvas-busy-style";function Al(){if(document.getElementById(Hr))return;const e=document.createElement("style");e.id=Hr,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}function Cl(e){const t=e.getBoundingClientRect(),n=document.createElement("div");return n.setAttribute("aria-busy","true"),Object.assign(n.style,{position:"fixed",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,cursor:"progress",display:"flex",alignItems:"center",justifyContent:"center"}),e.appendChild(n),{showSpinner(){Al(),n.style.background="rgba(128, 128, 128, 0.15)";const r=document.createElement("div");Object.assign(r.style,{width:"32px",height:"32px",borderRadius:"50%",border:"3px solid rgba(128, 128, 128, 0.35)",borderTopColor:"rgba(80, 80, 80, 0.9)",animation:"em-canvas-busy-spin 0.8s linear infinite"}),n.appendChild(r)},remove:()=>n.remove()}}var Pl=8e3;function Dl(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,whenShown:()=>Promise.resolve(),alignTo:()=>{},resize:()=>{},dispose:()=>{}}}var Rl=e=>{for(let t=e?.parentElement??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="hidden")return t}return null};function Ol(e,t,n,r,s){const o=n.readyTimeoutMs??Pl,i=document.createElement("div");i.dataset.canvasHost=e,r&&(i.dataset.canvasPlace=r),i.style.position="fixed",i.style.overflow="hidden",i.style.visibility="hidden";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,i.appendChild(l),t.appendChild(i),n.mark?.("created"),s||n.onCreated?.(l);const u=new a.Disposable;let d=!1,p=!1,m,b,S,E;const g=()=>{clearTimeout(E),E=setTimeout(()=>{p||(p=!0,b?.(new Error(`[canvas] ${e}: документ не загрузился за ${o} мс`)))},o)},v=()=>d?(S=Promise.resolve(),p=!0,S):(p=!1,S=new Promise((M,j)=>{m=M,b=j}),g(),S),_=()=>{if(clearTimeout(E),d=!0,p){S=Promise.resolve();return}p=!0,n.mark?.("loaded"),m?.()};l.addEventListener("load",_),u.addDispose(()=>{clearTimeout(E),l.removeEventListener("load",_)});let w;const P=()=>{w??=n.bindResizer?.(l)};let D=null,h=null,I;const f=()=>{if(!D){i.style.visibility="hidden",l.removeAttribute("id");return}n.elementId&&(l.id=n.elementId);const M=D.getBoundingClientRect(),j=h?.isConnected?h:Rl(D),B=j?j.getBoundingClientRect():null,V=B?Math.max(M.top,B.top):M.top,de=B?Math.min(M.bottom,B.bottom):M.bottom,nt=Math.max(0,de-V);i.style.visibility=nt>0?"visible":"hidden",i.style.left=`${M.left}px`,i.style.top=`${V}px`,i.style.width=`${M.width}px`,i.style.height=`${nt}px`,l.style.transform=`translateY(${M.top-V}px)`};let y="",A="",L=0,k;const q=()=>{if(!D){k=void 0;return}k=window.requestAnimationFrame(q);const M=D.getBoundingClientRect(),j=h?.isConnected?h.getBoundingClientRect():void 0,B=`${Math.round(M.left)}:${Math.round(M.top)}:${Math.round(M.width)}:${Math.round(M.height)}:${j?`${Math.round(j.top)}:${Math.round(j.height)}`:"-"}`;B!==y&&(y=B,f());const V=l.getBoundingClientRect().height;V>0&&V!==L&&(L=V,D.style.height=`${V}px`);const de=getComputedStyle(D).pointerEvents;de!==A&&(A=de,i.style.pointerEvents=de)},C=()=>{k===void 0&&D&&(k=window.requestAnimationFrame(q))},T=()=>{k!==void 0&&(window.cancelAnimationFrame(k),k=void 0)},O=()=>f();let N=[];const F=(M,j)=>{if(h=j,M&&N.length>0){const B=N;N=[],B.forEach(V=>V())}if(M===D){f();return}if(I?.disconnect(),I=void 0,D&&D.style.removeProperty("height"),y="",L=0,A="",D=M,!M){T(),f();return}n.onShown?.(l);try{if(typeof ResizeObserver=="function"){const B=new ResizeObserver(f);typeof B.observe=="function"&&(I=B,I.observe(M))}}catch{I=void 0}f(),P(),C()};window.addEventListener("scroll",O,!0),window.addEventListener("resize",O),u.addDispose(()=>{I?.disconnect(),k!==void 0&&window.cancelAnimationFrame(k),window.removeEventListener("scroll",O,!0),window.removeEventListener("resize",O)});const W=M=>{d=!1,M&&n.onReload?.(l);let j;p||S===void 0?j=v():(g(),j=S);try{l.contentWindow?.location.reload()}catch{l.src=c}return j};return{element:l,ready(){return S??v()},reload:()=>W(!0),reloadQuietly:()=>W(!1),get shown(){return D!==null},whenShown(){return D!==null?Promise.resolve():new Promise(M=>{N.push(M)})},alignTo(M,j){F(M,j??null)},scrollBy(M,j){for(let B=D?.parentElement??null;B;B=B.parentElement){const V=getComputedStyle(B);if((V.overflowY==="auto"||V.overflowY==="scroll")&&B.scrollHeight>B.clientHeight){B.scrollBy({left:M,top:j,behavior:"instant"});return}}window.scrollBy({left:M,top:j,behavior:"instant"})},resize(){w?.resize()},dispose(){F(null,null),w?.dispose(),u.dispose(),i.remove()}}}function Ll(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",s=(d,p)=>d==="email"?`email:${p??n}`:d;let o,i=[];const c=()=>{i.forEach(d=>clearTimeout(d)),i=[],o?.remove(),o=void 0},l=new Map,u=(d,p,m)=>{const b=s(d,p),S=t.get(b);if(S)return S;const E=e.resolveMount();if(!E)return Dl();const g=Ol(d,E,e,d==="email"?p??n:void 0,m);return t.set(b,g),g};return{get:d=>u(d),current:d=>u(d),peek:d=>t.get(s(d)),spare:()=>t.get(s("email",r())),ensureSpare:()=>u("email",r(),!0),promote(){const d=t.get(s("email",r()));if(!d)return;const p=t.get(s("email"));n=r();const m=l.get("email");d.alignTo(m?.slot??null,m?.clip??null),p?.alignTo(null)},alignSurface(d,p,m){l.set(d,{slot:p,clip:m??null}),(p?u(d):t.get(s(d)))?.alignTo(p,m??null)},visible(){for(const d of t.values())if(d.shown)return d},byWindow(d){if(d){for(const p of t.values())if(p.element.contentWindow===d)return p}},busy(d){c();const p=d?e.resolveMount():void 0;if(!p)return;const m=Cl(p);o=m,i=[setTimeout(()=>m.showSpinner(),Il),setTimeout(c,Tl)]},dispose(){c(),t.forEach(d=>d.dispose()),t.clear(),l.clear(),n="a"}}}var Nl=a.createIdentifier$1("canvas.resizerBinder"),At=a.createIdentifier$1("canvas.service"),Ml={created:z.canvasCreated,loaded:z.canvasLoaded};function xl(e,t){if(e.getInstance(At))return;const n=Ll({resolveMount:()=>t.resolveMount(),resolveSrc:s=>t.resolveSrc(s),resolveSandbox:xa,elementId:t.elementId,bindResizer:s=>e.getInstance(Nl)?.(s),onCreated:s=>Ye(e,s,"fresh"),onReload:s=>Ye(e,s,"fresh"),onShown:s=>Ye(e,s,"switch"),mark:s=>t.mark?.(Ml[s])}),r=Y(e).addListener(a.EVENT_TYPES.SANDBOX_WHEEL,s=>{n.visible()?.scrollBy(s?.deltaX??0,s?.deltaY??0)});e.inject(At,n),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),n.dispose()})}function Ye(e,t,n){const r=Y(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),ba(r))}function kl(e,t){Ye(e,t,"promote")}function Fl(e,t){const n=t.contentWindow;n&&Y(e).greet(n)}function Bl(e,t){const n=t.contentWindow;n&&Y(e).forget(n)}function ae(e){return e.getInstance(At)}function jl(e){const t=Y(e),n=()=>ae(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(a.EVENT_TYPES.RELOAD,async()=>{await n()?.reload()}),s=t.addListener(i=>{i.data?.operation===a.EVENT_TYPES.SANDBOX_RESIZED&&n()?.resize()}),o=$(e,a.events.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{r.dispose(),s.dispose(),o.dispose()})}var bm=a.createIdentifier$1("HeadlessMode"),Ul=a.createIdentifier$1("HiddenMount");function Hl(e){return e.getOrCreateInstance(Ul,()=>pe(!1))}function $r(){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 $l(e){const t=e.getInstance(a.OPTIONS_SOURCE_ID);let n,r;e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{r?.remove(),r=void 0}),xl(e,{resolveMount:()=>n,resolveSrc:o=>Lr(o==="block"),elementId:"email_iframe",mark:o=>H(o)}),t?.watch(o=>{if(n)return;const i=o?.element;if(i instanceof HTMLElement)n=i;else if(o!==void 0)n=r??=$r();else return;ae(e)?.get("email")});let s;e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{s?.remove(),s=void 0}),Hl(e).watch(o=>{const i=ae(e);if(i){if(o){s??=$r(),i.alignSurface("email",s,s);return}s&&(i.alignSurface("email",null),s.remove(),s=void 0)}})}var Gr=a.createIdentifier$1("canvas.headerFlow"),Vr=["subject","preheader"],Gl=3e3,Vl={subject:a.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,preheader:a.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE};function Yl(e){const t=oe(e),n=Y(e),r=E=>E?"remote":Ur(e)?"system":"user",s=(E,{guid:g,value:v,forced:_})=>{const w=we(t);if(!w||typeof v!="string"||g&&g!==w.get().docId)return;const P=t.forcedHeaders();if(P?.[E]&&!_&&v!==P[E])return;_&&t.endForcedHeaders();const D=w.get().attributes[E]??"";c=!0;try{Ue(w,{[E]:v},{source:r(_)})}finally{c=!1}o[E]=v,Z(e,a.events.ON_HEADER_APPLIED_ID).fire({field:E,value:v,forced:!!_,isGenerated:v!==D&&!!v})};let o={},i,c=!1,l=Promise.resolve();const u=(E,g,v)=>{l=n.sendAsync(Vl[E],{value:g,guid:we(t)?.get().docId,...v?{force:!0,echo:!0}:{}}).catch(_=>{})};let d;e.inject(Gr,{whenDelivered:async()=>{await l},reassert:E=>{const g=we(t),v=Vr.filter(_=>E[_]);if(!(!g||v.length===0)){c=!0;try{Ue(g,Object.fromEntries(v.map(_=>[_,E[_]])),{source:"system"})}finally{c=!1}t.beginForcedHeaders({subject:E.subject??"",preheader:E.preheader??""}),clearTimeout(d),d=setTimeout(()=>t.endForcedHeaders(),Gl);for(const _ of v)o[_]=E[_],u(_,E[_],!0)}}});const p=()=>{i?.(),i=void 0;const E=we(t);if(!E){o={};return}const g=E.get().attributes;o={subject:g.subject,preheader:g.preheader},i=E.subscribe(({source:v})=>{if(c)return;const _=E.get().attributes,w=t.forcedHeaders();for(const P of Vr){const D=_[P];D!==o[P]&&(o[P]=D,u(P,D??"",v==="system"&&w?.[P]!==void 0))}})};p();const m=t.subscribe(p),b=n.addListenerAsync(a.EVENT_TYPES.APPLICATION_SUBJECT_UPDATE,E=>s("subject",E)),S=n.addListenerAsync(a.EVENT_TYPES.APPLICATION_PREHEADER_UPDATE,E=>s("preheader",E));e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{b.dispose(),S.dispose(),m(),i?.(),clearTimeout(d)})}function Yr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ct(e,t){const n={...e};for(const r of Object.keys(t)){const s=t[r],o=e[r];Yr(s)&&Yr(o)?n[r]=Ct(o,s):s!==void 0&&(n[r]=s)}return n}function ql(e,t){const n=a.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 Ct(n,s)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?Ct(n,t):n}function zl(){const e=window.localStorage.getItem(a.LOCAL_STORAGE_ITEMS.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?a.DARK:a.LIGHT;return e&&e!=="system"?e:t}function Wl(){const e=window.localStorage.getItem(a.LOCAL_STORAGE_ITEMS.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function Kl(e){const{config:t}=e;return{operation:a.EVENT_TYPES.UPDATE_PREVIEW,theme:e.theme,commonStyles:ql(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}function Xl(e){const t=Y(e),n=e.getInstance(a.CONFIG_SOURCE_ID),r=e.getInstance(a.OPTIONS_SOURCE_ID),s=oe(e);let o,i="";const c=()=>{const v=n?.get()??{},_=Kl({config:v,emailCommonStyles:s.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:zl(),codeMode:Wl(),appName:"useblocks"}),w=JSON.stringify(_);w!==i&&(i=w,t.send(_))},l=t.onInit(()=>{i="",c()}),u=()=>{t.isInited()&&c()},d=n?.watch(u),p=r?.watch(v=>{o=v?.commonStyles,u()});let m;const b=()=>{m?.(),m=s.current()?.subscribe(u),u()};b();const S=s.subscribe(b),E=matchMedia(a.PREFERS_COLOR_SCHEME_DARK),g=()=>u();E.addEventListener("change",g),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{l.dispose(),d?.dispose(),p?.dispose(),m?.(),S(),E.removeEventListener("change",g)})}var Pt;(function(e){function t(s,o,i=(c,l)=>c===l){if(s===o)return!0;if(s.length!==o.length)return!1;for(let c=0;c<s.length;c++)if(!i(s[c],o[c]))return!1;return!0}e.isEqual=t;function n(s,o=i=>i){const i=new Set;return s.filter(c=>{const l=o(c);return i.has(l)?!1:(i.add(l),!0)})}e.unique=n;function r(s=[],o=[],i=(c,l)=>c===l){const c=[],l=[],u=[];for(const d of s){const p=o.find(m=>i(d,m));p?u.push({prev:d,next:p}):l.push(d)}for(const d of o)s.find(p=>i(d,p))||c.push(d);return{added:c,removed:l,exists:u}}e.diff=r})(Pt||(Pt={}));function Jl(e,t){return e.type===t.type&&e.key===t.key}function Ql(e){const t=Y(e),n=()=>e.getServices(a.SANDBOX_EXTENSIONS_ID)??[];let r=[];const s=t.onInit(()=>{r=n(),t.send(a.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,r)}),o=a.getServiceContainerId(a.SANDBOX_EXTENSIONS_ID),i=e.onInject(c=>{if(c!==o)return;const l=n();if(!t.isInited()){r=l;return}const{added:u,removed:d}=Pt.diff(r,l,Jl);if(r=l,d.length){if(d.some(p=>p.type==="script")){t.send(a.EVENT_TYPES.RELOAD);return}t.send(a.EVENT_TYPES.SANDBOX_REMOVE_EXTENSIONS,d.map(p=>p.key))}u.length&&t.send(a.EVENT_TYPES.SANDBOX_ADD_EXTENSIONS,u)});e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{s.dispose(),i?.dispose()})}var Zl=a.createIdentifier$1("prewarm.editorVisible");function ec(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function tc(e={}){const t=e.paint??ec;let n=!1,r=!1,s=!1,o=!1,i=!1;const c=[],l=()=>{i||o||!n||!r||!s||(o=!0,t(()=>{i=!0,H(z.editorVisible);for(const u of c.splice(0))u()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){s=!0,l()},whenVisible(u){if(i){u();return}c.push(u)},contentShown:()=>s}}function nc(e){return e.getOrCreateInstance(Zl,()=>tc())}var rc=500,sc=500,oc=5e3;function ic(e){const t=e.quietMs??rc,n=e.floorMs??sc,r=e.ceilingMs??oc;let s,o,i=0;const c=()=>{clearTimeout(s),clearTimeout(o),s=void 0,o=void 0},l=()=>{c(),e.run()},u=()=>{clearTimeout(s);const d=n-(Date.now()-i);s=setTimeout(l,Math.max(t,d))};return{start(){c(),i=Date.now(),o=setTimeout(l,r),u()},notify(){s!==void 0&&u()},cancel:c}}function ac({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},c={...e,...i};return Object.defineProperty(c,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),c}var qr="self-init:";function lc(e){return e.startsWith(qr)}function zr(e,t){const n=e.getActiveShowRequest();return lc(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function cc(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t();let s="";const o=()=>e.readDocument()?yt(e.readDocument()):s,i=()=>ge(e.container).editorPolicy,c=()=>e.readEmail(),l=()=>{const u=c();return{...u,id:e.isTemplate()||u.isNew?void 0:u.id,html:o()}};return{readContent:o,publicEmail:l,sendInitStart:()=>te(n,"INIT_START",a.EVENT_TYPES.SANDBOX_INIT_START,{guid:c().renderGuid},void 0,r()),sendInited:()=>te(n,"INITED",a.EVENT_TYPES.SANDBOX_INITED,{guid:c().renderGuid},void 0,r()),async sendContent(){const u=c(),{html:d,hasBrowserExtensionArtifacts:p}=kr(u?.html||"");p&&e.events.browserExtensionDetected(),Fr(e.readDocument(),d),s=d,await te(n,"SET_ENTITY",a.EVENT_TYPES.SANDBOX_SET_ENTITY,St(o(),u.renderGuid,i(),e.readDocument()?.get().version),{guid:u.renderGuid,emailId:u.id??null},r())},refreshContent:()=>te(n,"SET_ENTITY",a.EVENT_TYPES.SANDBOX_SET_ENTITY,St(o(),c().renderGuid,i(),e.readDocument()?.get().version),void 0,r()),sendPreheader:async()=>{const u=c();if(u.preheader!==void 0)return te(n,"PREHEADER",a.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE,{value:u.preheader,guid:u.renderGuid,force:!0},void 0,r())},sendSubject:async()=>{const u=c();if(u.subject!==void 0)return te(n,"SUBJECT",a.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,{value:u.subject,guid:u.renderGuid,force:!0},void 0,r())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:u=>e.showFilled?.(u),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(l()),fireInit(u,d){if(!zr(t(),u)){t().getActiveShowRequest()?.showId;return}const p=c();p.id,p.renderGuid,t().completeShow(u),Ue(e.readDocument(),{is_inited:!0},{source:"system"});const m=l();return d&&(m.reset=!0),e.events.inited(m)},fireEmailChanged(){e.events.emailChanged(l())},fireContentChanged(){e.events.contentChanged(o())}}}function dc(e){const t=()=>e.initPipeline();let n=!1,r,s,o,i=0,c;const l=cc({...e,waitScope:()=>({getSandboxTimeoutMs:g=>t().getSandboxTimeoutMs(g),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:c?.signal??t().signal})});let u;const d=(g,v)=>{if(u===g)return;u=g;const _=i;setTimeout(()=>{i!==_||t().signal.aborted||S(g,v).catch(()=>{})},0)},p=()=>{c?.abort(),c=void 0};let m;const b=()=>{const g=t().signal;g!==m&&(m?.removeEventListener("abort",p),m=g,g.addEventListener("abort",p))};async function S(g,v){const _=++i;p(),c=new AbortController,b();const w=()=>i!==_,P=l.readTarget(),D=t().generation,h=()=>D===t().generation&&!t().signal.aborted,I=v?"init:reset-":"init:";if(!v){const A=l.publicEmail();A?.id,A?.renderGuid,A?.preheader}let f=!1,y=!1;try{n=!0,await l.sendInitStart(),l.fireWillInit(),await(v?l.refreshContent():l.sendContent()),f=!0,v||l.publicEmail()?.id;try{await l.sendPreheader()}catch(A){`${I}`,String(A)}try{await l.sendSubject()}catch(A){`${I}`,String(A)}if(w()||l.showFilled(P),await l.sendInited(),y=!0,s===g){const A=e.readSandboxGeneration?.()??o;A!==void 0&&(r=A)}await l.revealFilled()}catch(A){throw w()||(`${I}`,{...e.describeSurface?.(),error:String(A)},void 0),!w()&&zr(t(),g)&&t().failShow(g,A),A}finally{E(g,v,I,{superseded:w(),sessionGeneration:D,contentApplied:f,sandboxInitedAcked:y,commit:h()})}}function E(g,v,_,w){const{superseded:P,contentApplied:D,sandboxInitedAcked:h}=w;if(P){`${_}`;return}h&&w.commit?l.fireInit(g,v||void 0):h?(`${_}`,w.sessionGeneration,t().generation,t().signal.aborted,void 0):D?(`${_}`,void 0):(`${_}`,void 0),n=!1,c=void 0,!h&&s===g&&(s=void 0,r===o&&(r=void 0)),!h&&D&&d(g,v)}return{channel:l,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:g=>{r=g},lastCorrelation:()=>s,markCorrelation:g=>{s=g},bumpRunSeq:()=>{i+=1},noteSandboxGeneration:g=>{o=g},fill:g=>S(g,!1),refill:g=>S(g,!0),stop:()=>{i+=1,p(),n=!1,m?.removeEventListener("abort",p),m=void 0}}}function uc(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:Wr(e,n)}function Wr(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function fc(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:s,readSandboxGeneration:o}=e,i=d=>{const p=n(),m=s();if(!uc(p,d,m)){d.showId,d.navId,d.emailId,p?.id,p?.showId,p?.renderGuid;return}d.showId,p?.id,p?.renderGuid,t.markFilled(o()),t.markCorrelation(d.showId),t.fill(d.showId).catch(()=>{})};return{showRequested:d=>{i(d)},showRequestIdentityChanged:()=>{const d=e.initPipeline().getActiveShowRequest();d&&i(d)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const d=o();if(t.filledGeneration()===d)return;const p=n(),m=s();if(!p?.renderGuid||!Wr(p,m))return;const b=`${qr}${p.renderGuid}`;t.markFilled(d),t.markCorrelation(b);const S=r()?.isReady()===!0;p.id,p.renderGuid,(S?E=>t.refill(E):E=>t.fill(E))(b).catch(()=>{t.lastCorrelation()===b&&t.markFilled(void 0)})},saasChanged:()=>{const d=n();d?.renderGuid,d?.showToken,d?.id}}}function pc(e){return e??""}function mc(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function hc(e){const t=oe(e),n=Y(e),r=()=>re(t.sessionKey())?void 0:t.current(),s=()=>{const R=r();return ac({attributes:R?.get().attributes??{},readContent:()=>R?.getContent(),docId:R?.get().docId,hasSession:!!R,serverId:R?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(a.INIT_PIPELINE_ID)??wt;let i={},c=!1;const l=e.getInstance(a.OPTIONS_SOURCE_ID)?.watch(R=>{c=!!R?.element});let u=!1,d=!1,p=!1,m=0;const b=()=>{const R=ae(e);if(!R)return;const G=++m,U=R.spare();return U&&Bl(e,U.element),(U?U.reloadQuietly():R.ensureSpare()?.ready())?.then(()=>{if(G!==m)return;u=!0;const ee=R.spare();ee&&Fl(e,ee.element),p&&(p=!1,A(),F())})},S=ic({run:()=>{p||b()?.catch(()=>{})}}),E=()=>{nc(e).noteContentShown(),!u&&!p&&S.start()};let g=!1;const w=dc({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:s,revealFilled:()=>{const R=ae(e);return g&&R&&(g=!1,S.start()),c?R?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:R=>{const G=ae(e),U=G?.spare()?.element.contentWindow;d&&G&&U&&R===U&&(d=!1,G.promote(),G.busy(!1),g=!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!i.isTemplate,readSandboxGeneration:()=>ie(n),describeSurface:()=>({canvasPath:y,promoted:d,spareClean:u,handshake:n.isInited(),generation:ie(n)}),events:{willInit:R=>{Z(e,a.events.WILL_EMAIL_INIT_ID).fire(R)},inited:R=>{E(),Z(e,a.events.ON_EMAIL_INIT_ID).fire(R)},contentChanged:R=>{Z(e,a.events.ON_CONTENT_CHANGED_ID).fire(R)},emailChanged:R=>{Z(e,a.events.ON_EMAIL_CHANGED_ID).fire(R)},browserExtensionDetected:()=>{Z(e,a.events.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),P=fc({pipeline:w,initPipeline:o,readEmail:s,readDocument:r,readRouteEmailId:()=>i.emailId,readSandboxGeneration:()=>ie(n)});let D="",h="",I="";const f=R=>R.length>0;let y="none";const A=()=>{const R=ae(e)?.spare();R&&(n.sendNow({operation:a.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!0}),u=!1,d=!0,kl(e,R.element))},L=(R,G)=>{const U=ae(e);if(!U)return!0;const ee=U.spare(),ue=ee&&u?"spare":"prepare";if(y=ue,U.busy(!0),ee&&u)return A(),!0;S.cancel(),n.sendNow({operation:a.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!0});const fe=b();if(fe===void 0)return y="reload",U.busy(!1),U.peek("email")?.reload(),!0;p=!0;const wn=m;return fe.catch(()=>{!p||wn!==m||(p=!1,y="reload",U.busy(!1),U.peek("email")?.reload())}),!1},k=()=>{de(),w.noteSandboxGeneration(ie(n));const R=s(),G=mc(R?.renderGuid,R?.showId,R?.id,i.emailId),U=pc(R?.renderGuid);if(U!==h){const fe=f(h),wn=h;h=U,fe&&L(wn,U)}if(p)return;G!==D&&(D=G,P.showRequestIdentityChanged());const ee=r(),ue=`${G}|${ee?.get().docId??""}|${ie(n)}`;ue!==I&&ee?.isReady()===!0&&(I=ue,P.selfInitChanged()),P.saasChanged(),O()};let q=!1,C="",T="";const O=()=>{const R=s();if(!R?.renderGuid)return;const G=w.channel.readContent(),U=JSON.stringify([R.preheader,R.common_styles,R.meta,R.subject,R.utm_parameters?.utm_campaign??"",R.utm_parameters?.utm_content??"",R.utm_parameters?.utm_medium??"",R.utm_parameters?.utm_source??"",R.utm_parameters?.utm_term??""]),ee=q&&G!==T,ue=q&&U!==C;if(q=!0,T=G,C=U,w.isEventsLocked())return;const fe={...R,id:i.isTemplate||R.isNew?void 0:R.id,html:G};if(ee){Z(e,a.events.ON_CONTENT_CHANGED_ID).fire(G),Z(e,a.events.ON_EMAIL_CHANGED_ID).fire(fe);return}ue&&R.is_inited&&Z(e,a.events.ON_EMAIL_CHANGED_ID).fire(fe)};let N=!1;const F=()=>{N||(N=!0,queueMicrotask(()=>{N=!1,k()}))};e.inject(It,{pipeline:w,setRoute:R=>{R.emailId===i.emailId&&!!R.isTemplate==!!i.isTemplate||(i=R,F())}});let W,M;const j=()=>{const R=r()?.get().docId;R!==M&&(W?.(),M=R,W=r()?.subscribe(F)),F()};let B,V;const de=()=>{const R=e.getInstance(a.INIT_PIPELINE_ID);!R||R===B||(V?.(),B=R,V=R.onShowRequested(G=>P.showRequested(G)))},nt=n.addListener(R=>{R.data?.operation===a.EVENT_TYPES.SANDBOX_RESIZED&&S.notify()}),im=t.subscribe(j),am=Dr(n,F);j(),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{l?.dispose(),V?.(),am(),im(),W?.(),nt.dispose(),S.cancel(),w.stop()})}function gc(){return a.USEBLOCKS!=="useblocks"}var Dt={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Ec={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},Kr=Dt,bc=["freeUserBlocks","blocks"],Xr={};function vc(e){Xr=e}var Jr=e=>bc.includes(e)?Kr:Xr[e]??Kr,Rt={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},_c={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},yc={...Rt,config:{...Rt.config,imageCenterFileManagerView:!1}};vc({pro:Ec,editor:_c,simple:gc()?Rt:yc,freeUserBlocks:Dt,blocks:Dt});var Qr=new Set;function Sc(){return window.localStorage.getItem(a.LOCAL_STORAGE_ITEMS.em_color_scheme)??void 0}function wc(e){return Qr.add(e),e(Sc()),{dispose(){Qr.delete(e)}}}function Ot(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Ic(e,t){return t.modeDefaults(Ot(e,t.fallbackMode))}function Tc(e,t){const n=Ot(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Ac(e,t){const n=Ot(e,t),r=e.user?.advancedConfigs?.[n],s=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...s}}function Cc(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Pc(e){return a.mergeResourceProxyLayers(e.map(t=>t?.resourceProxy))}function Dc(e){return a.mergeResourceProxyPolicyLayers(e.map(t=>t?.resourceProxyPolicy))}function Rc(e){return a.mergeBackendProxyLayers(e.map(t=>t?.backendProxy))}function Oc(e){return a.mergeShallowConfigLayers(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Lc(e,t){return[e.base,Ic(e,t),e.profile,e.serverSide,Tc(e,t.fallbackMode),e.user,Ac(e,t.fallbackMode),e.local]}function Lt(e,t){const n=Lc(e,t),r=a.mergeShallowConfigLayers(n),s=Cc(n);s!==void 0&&(r.fileManager=s);const o=Pc(n);o!==void 0&&(r.resourceProxy=o);const i=Dc(n);i&&Object.keys(i).length>0&&(r.resourceProxyPolicy=i);const c=Rc(n);c!==void 0&&(r.backendProxy=c);const l=Oc(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}var Nc=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Zr(e){return e==="server"?"serverSide":e}function Mc({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},s=pe();let o={kind:"pending"},i;const c=new Promise(m=>{i=m}),l=n===void 0?void 0:setTimeout(()=>{d({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function u(){o.kind!=="pending"&&s.set(Lt(r,e))}function d(m){if(o.kind!=="pending")return;clearTimeout(l),o=m;const b=Lt(r,e);s.set(b),i(b)}function p(m,b){r[Zr(m)]=b,m==="server"&&o.kind==="pending"?d({kind:"applied"}):u()}return{watch:m=>s.watch(m),select:m=>s.select(m),get:()=>s.get(),ready:()=>c,state:()=>o,layers:()=>({...r}),bootstrap(){const m=Lt(r,e);return Object.fromEntries(Nc.map(b=>[b,m[b]]))},merge(m,b){p(b,{...r[Zr(b)],...m})},replace(m,b){p(b,m)},setMode(m){r.user={...r.user,mode:m},u()},setAdvancedConfigs(m){r.advancedConfigs=m,u()},serverAbsent(m){d({kind:"absent",reason:m})},applyServerResponse(m){o.kind==="pending"&&p("server",{...r.serverSide,...m})},dispose(){clearTimeout(l)}}}var xc=5e3,kc="blocks";function Fc(){return{...Jr(kc)?.config,mergeTags:void 0}}function Bc(e,t){e.getInstance(a.OPTIONS_SOURCE_ID)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function jc(e,t){let n;br(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 Uc(e,t){let n=null;const r=wc(s=>{const o=typeof s=="string"&&s?s:void 0;o!==n&&(n=o,t.replace(o?{theme:o}:{},"local"))});e.getInstance(a.DISPOSABLE_ID)?.addDisposable(r)}async function Hc(e,t){if(e.getInstance(at)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(a.APP_ID);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function $c(e){e.injectFactory(a.CONFIG_SOURCE_ID,(t,n)=>{if(n)return n;const r=Mc({base:Fc(),env:{modeDefaults:s=>Jr(s)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:xc});return Bc(e,r),jc(e,r),Uc(e,r),Hc(e,r),e.getInstance(a.DISPOSABLE_ID)?.addDisposable(r),r},!0)}var Ee=class extends a.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 x(e,t,n){const r=a.snapshot(e);return(s,o,i)=>{const c=r(async l=>{const u=t?t(l):l;i&&s.bind(i);const d=await s(u);return n?n(d):d},o,i);return()=>c.dispose()}}var Gc=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new a.Emitter;this.handleDestroy=x(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new Ee(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{}}},Nt=a.createIdentifier$1("DestroyableService");function Vc(e){e.injectFactory(Nt,()=>{const t=e.getInstance(a.DISPOSABLE_ID);if(!t)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new Gc({lifetime:t,options:e.getInstance(a.OPTIONS_SOURCE_ID),getInstance:()=>e.getInstance(a.INSTANCE_ID),release:()=>a.releaseContainer(e.getInstance(a.STORE_ID)??e)})},!0)}function Yc(e){const t=e.getInstance(Nt);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var qc=1e3;function es(e,t,n=qc,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(!es(e[i],t[i],n,r+1))return!1;return!0}return!1}function Te(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];es(s,o)||(n[r]=s)}return n}var zc=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail не ответил за ${e}ms — письмо не сохранено`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}},Wc=({source:e,emailtags:t,group:n,tags:r,...s})=>s,Kc=()=>$n();async function Xc({emails:e},t){const n=Kc();let r;try{return await Promise.race([e.notifySave(t),new Promise((s,o)=>{r=setTimeout(()=>{const i=new zc(n);t.value.id,o(i)},n)})])}finally{r!==void 0&&clearTimeout(r)}}function Jc(e){const{emails:t}=e,n=async(r,s)=>{const o=Wc(s),i=r===void 0?void 0:await t.cache.getIfPresent(r),c=i?{...i,...o}:o,l=await Xc(e,{prev:i,patch:i?Te(i,o):o,value:c,source:s.source??""}),u=String(l.id??r??a.generateUUID()),d=l.id===void 0?{...l,id:u}:l;return await t.cache.addOrUpdate(u,()=>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:a.generateUUID()}},async updateEmail(r,s){return await n(r,s)}}}var Mt=20,Qc=({source:e,emailtags:t,group:n,tags:r,...s})=>s;function Zc({revisions:e,revisionsByEmail:t}){const n=async(r,s)=>(t.clear(),await t.get(r,{page:s}),(await e.cache.values()??[]).filter(o=>String(o?.parent)===String(r)));return{async readRevisions(r,s=1){const o=await n(r,s);return{revisions:o.slice(Mt*(s-1),Mt*s),page:s,hasMore:o.length>Mt*s}},async readAutosave(r){return Ii(await n(r,1))},async saveAutosave(r,s){const o=Qc(s);return await e.create({...o,parent:r,modified:new Date().toString()})}}}var ed=class extends a.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}},td=class extends a.AsyncEmitter{};function vm(e){return e}var ts=class extends a.Disposable{_items=new Map;_onChangeEmitter=new a.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 a.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 nd(e,{filter:t,order:n="asc",orderBy:r,page:s,pageSize:o=20}={}){const i=e.length;let c=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(u=>{for(const d of l){const p=u[d],m=t[d];return d==="id"||typeof p!="string"?p===m:typeof m=="string"&&p.startsWith(m)}return!0}),c=e.length}return r&&(e=e.sort((l,u)=>(l[r]>u[r]?1:u[r]>l[r]?-1:0)*(n==="asc"?1:-1))),s!==void 0&&(e=e.slice(o*(s-1),o*s)),{data:e,filteredTotal:c,total:i,totalPages:Math.ceil(c/o)}}function rd(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 sd(e,t){return ns(e)&&ns(t)?String(e)===String(t):e===t}function ns(e){return typeof e=="string"||typeof e=="number"}var od=class extends a.Disposable{_cache=new ts;_readEmitter=new a.AsyncEmitter;_saveEmitter=this.addDisposable(new ed);_removeEmitter=this.addDisposable(new td);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new a.Disposable);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new ts),s=n.addDisposable(new a.AsyncEmitter);t=this._foreignCache[e]={get:async(o,i={})=>{await r.getOrCreate(o,async()=>{try{const l=rd(await s.fire(o))||[];for(const u of l)u[e]=o,await this._cache.add(u.id,u);return l}catch{return[]}});const c=(await this._cache.values()||[]).filter(l=>{const u=l[e];return u==null||sd(u,o)});return nd(c,i)},first(o,i={}){return t.get(o,{...i,page:1,pageSize:1}).then(({data:c})=>c[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=a.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?Te(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 Ae(e){const t=a.createIdentifier$1(e);return n=>n.getOrCreateInstance(t,()=>new od)}function id(e){const t=e.getInstance(a.DISPOSABLE_ID);if(!t)throw new Error("Failed");return t}function rs(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function ad(e,t,n){return e&&!rs(t)&&rs(e)?{...n,meta:e.meta}:n}var ss=Ae("plugin.dataSource.emails"),os=Ae("plugin.dataSource.emailRevisions"),is=a.createIdentifier$1("emailDocuments.provided");function ld(e){const t=ss(e),n=os(e),r=n.byForeignKey("parent");return e.getInstance(is)?{emails:t,emailRevisions:n}:(e.inject(is,!0),Vi(e,Jc({emails:t})),Wi(e,Zc({revisions:n,revisionsByEmail:r})),id(e).addDisposable(t.onSave(({prev:s,patch:o,value:i})=>ad(s,o,i),Number.MIN_VALUE)),{emails:t,emailRevisions:n})}function as(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 cd(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var dd="po",qe=null;function ud(){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([dd],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function fd(){return qe===null&&(qe=ud().catch(e=>{throw qe=null,e})),qe}async function ls(e){if(typeof e=="object")return xt(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?pd(t):md(t)}function xt(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function pd(e){try{return xt(JSON.parse(e))}catch{return}}var cs=!1;async function md(e){try{return xt((await fd()).parsePoCatalog(e))}catch{cs||(cs=!0);return}}var hd="em_locale",gd="em_ant_locale",Ed="locale",bd="ant_locale";function kt(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function ds(e,t){const n=kt(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function vd(){return kt("em_locale")??ds(Ed,"em_locale")}function us(e){try{localStorage.setItem(hd,JSON.stringify(e))}catch{}}function _d(){return kt("em_ant_locale")??ds(bd,"em_ant_locale")}function yd(e,t){try{localStorage.setItem(gd,JSON.stringify({id:e,data:t}))}catch{}}var _m="en_US",Sd=8e3;function wd(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 Id(e){const t=vd(),n=_d();let r={ready:!1},s;const o=pe(r);let i=0;const c=g=>{r={...r,...g},o.set(r)},l=()=>{r.ready||c({ready:!0})},u=setTimeout(l,e.unlockAfterMs??Sd),d=g=>g!==i;let p;async function m(g,v){if(n?.id===g&&n.data&&c({antd:n.data}),!p)return;const _=await p(g).catch(()=>{});!_||d(v)||(c({antd:_}),yd(g,_))}async function b(g,v){const _=await e.askHost(g).catch(()=>null);if(d(v))return!0;if(_==null)return!1;const w=await ls(_);return d(v)||(w&&c({catalog:w}),l()),!0}async function S(g,v){const _=await e.readList();if(d(v))return;if("error"in _){c({failure:{kind:"GET_LOCALES_ERROR",error:_.error}}),l();return}const w=_.data.find(D=>D.locale===g);if(!w){cd("em_locale")&&c({catalog:void 0}),l();return}if(as(t,w)&&(!s||s.catalog===t?.data)){l();return}if(s?.entry&&r.catalog===s.catalog&&as(s.entry,w)){us(s.entry),l();return}const P=await e.readCatalog(g);if(!d(v)){if("error"in P){c({failure:{kind:"GET_LOCALE_ERROR",error:P.error}}),l();return}P.data&&(s?.id===g&&r.catalog===s.catalog&&wd(s.catalog,P.data)||c({catalog:P.data}),us({id:g,time:w.updatedAt||Math.floor(Date.now()/1e3),hash:w.contentHash,data:P.data})),l()}}async function E(g,v){if(!await b(g,v)){if(!d(v)&&(s?.id===g&&r.catalog===s.catalog||g==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await S(g,v)}}return{set(g){if(!g||g===r.id)return;const v=i+=1;c({id:g,failure:void 0});const _=s?.id===g&&r.catalog===s.catalog;(s&&!_&&r.catalog===s.catalog||g==="en_US"&&r.catalog)&&c({catalog:void 0}),t?.id===g&&t.data&&(c({catalog:t.data}),l()),m(g,v),E(g,v)},prime(g,v,_){r.id||r.catalog||!v||(s=t?.id===g&&t.data&&(!_||t.time>=_.time)?{id:g,catalog:t.data}:{id:g,catalog:v,entry:_?{id:g,time:_.time,hash:_.hash,data:v}:void 0},c({catalog:s.catalog}))},useAntdLoader(g){p=g,r.id&&m(r.id,i)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(u)}}var Td=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})},Ad=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:c,...l})=>{const u=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},d=this.mergeRequestParams(l,u),p=s&&this.toQueryString(s),m=this.contentFormatters[r||"application/json"],b=o||d.format;return this.customFetch(`${i||this.baseUrl||""}${n}${p?`?${p}`:""}`,{...d,headers:{...d.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(c?this.createAbortSignal(c):d.signal)||null,body:typeof e>"u"||e===null?null:m(e)}).then(async S=>{const E=S;E.data=null,E.error=null;const g=b?S.clone():S,v=b?await g[b]().then(_=>(E.ok?E.data=_:E.error=_,E)).catch(_=>(E.error=_,E)):E;return c&&this.abortControllers.delete(c),v})}},Cd=a.createIdentifier$1("rest.v2.transport"),fs=Symbol("rest.v2.secureRequest");function Pd(e){return e.getOrCreateInstance(Cd,()=>{const t=e.getInstance(a.CUSTOM_FETCH_ID)?.execute||fetch;return new Ad({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[fs]:!0}),customFetch:(n,r={})=>{const{[fs]:s,...o}=r;return t(n,{...o,[a.PUBLIC_REQUEST]:s!==!0})}})})}function Dd(e,t){const n=Pd(e);return Object.assign({},...t.map(r=>new r(n)))}function ps(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function ms(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:ps(n.details,"wp_code")??n.code,message:ps(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 hs(e){return!e.ok||!!e.error}function Rd(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function gs(){return Rd(a.LOCAL_STORAGE_ITEMS.em_translations_v2)??!0}function Od(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Ld(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Nd(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:Od(r[1])}),t},[]):[]}function Md(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Ld(n.updated_at),contentHash:n.content_hash}),t),[])}function Es(e){return Dd(e,[Td])}function ze(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Ft(e){return!e.ok||e.error!=null}function Bt(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function jt(e){return{data:await ls(e)??null}}async function xd(e){if(gs())try{const n=await Es(e).localesList();return hs(n)?{error:ms(n)}:{data:Md(n.data)}}catch(n){return ze(n)}const t=a.getApi(e,[Nn]);try{const n=await t.get_translations2({file:"react_app"});return Ft(n)?Bt(n):{data:Nd(n.data)}}catch(n){return ze(n)}}async function kd(e,t){if(gs())try{const r=await Es(e).jsonList({locale:t});return hs(r)?{error:ms(r)}:jt(r.data)}catch(r){return ze(r)}const n=a.getApi(e,[Nn]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Ft(r)?Bt(r):jt(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Ft(r)?Bt(r):jt(r.data)}catch(r){return ze(r)}}}var Ce=a.createIdentifier$1("locale.service");function Fd(e){if(e.getInstance(Ce))return;const t=Id({readList:()=>xd(e),readCatalog:n=>kd(e,n),askHost:async n=>(await Z(e,a.events.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(a.SECURITY_MODULE_ID)});e.inject(Ce,t),e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>t.dispose())}function Bd(e){const t=e.getInstance(a.CONFIG_SOURCE_ID);if(!t)return;const n=e.getInstance(Ce);if(!n)return;const r=t.select(s=>s.locale).watch(s=>n.set(s));e.getInstance(a.DISPOSABLE_ID)?.addDisposable(r)}var jd="user_id",Ud="project_id",bs=a.createIdentifier$1("rest.identityHeadersProvided");function Hd(e){if(e.getInstance(bs))return;e.inject(bs,!0);let t;e.getInstance(a.OPTIONS_SOURCE_ID)?.watch(n=>{t=n}),e.addService(a.REQUEST_HANDLER_ID,{execute(n,r){if(r?.public)return;const s=t?.user?.id??vr(e).profile?.id;s!=null&&s!==""&&n.headers.set(jd,String(s));const o=t?.project;o!=null&&o!==""&&n.headers.set(Ud,String(o))}})}function $d(e){if(!e)return!1;try{return e.getInstance(a.SECURITY_MODULE_ID)!==void 0}catch{return!1}}var Gd="Invalid standaloneKey.",ym=a.createIdentifier$1("StandaloneMockGuard");function Vd(){const e=new Error(Gd);return e.name="InvalidStandaloneKeyError",e}function Yd(e){e.addService(a.REQUEST_HANDLER_ID,{execute:()=>{if($d(e))throw Vd()}})}function qd(e){a.registerRestTransport(e),Yd(e)}function zd(e){const t=new jr;e.inject(a.INIT_PIPELINE_ID,t);let n;const r=e.getInstance(a.OPTIONS_SOURCE_ID)?.watch(o=>{o&&(o.signal!==void 0&&(n=o.signal),t.configure({replaceSession:!0,...o.timeouts!==void 0?{timeouts:o.timeouts}:{},...n!==void 0?{signal:n}:{}}))}),s=e.getInstance(a.DISPOSABLE_ID);r&&s?.addDisposable(r),s?.addDispose(()=>{t.abort()})}var Wd=Ae("plugin.dataSource.blocks"),Kd=Ae("plugin.dataSource.blockRevisions"),Xd=Ae("plugin.dataSource.comments"),Jd=Br(),Qd=Br(),vs=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2086
2086
  <html>
2087
2087
  <head>
2088
2088
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
@@ -2123,10 +2123,10 @@ __useblocks__.define("useblocks.js",["require","exports","module","static/umd/ad
2123
2123
  </tr>
2124
2124
  </table>
2125
2125
  </body>
2126
- </html>`;function zd(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:us,project:e?.id,project_title:e?.title??"",tags:[],utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var Kd=a.createIdentifier$1("CurrentProject"),Wd={};function qe(e){return e?.getInstance(Kd)?.get()??Wd}function fs(e){const t=qe(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var ps=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Xd(e){return!Object.keys(e).some(t=>ps.has(t))}function Jd(e){const t={},n={};for(const[r,s]of Object.entries(e))ps.has(r)?t[r]=s:n[r]=s;return{showOptions:t,misplacedEmailFields:n}}function ms(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function cm(e){}function ze(e){return{emails:Xr(e),blocks:$d(e),emailRevisions:Jr(e),blocksRevision:Gd(e),comments:Vd(e)}}function Qd(e){const t=Object.values(ze(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function jt(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Xd(e))return{email:ms(e)};{const{showOptions:n,misplacedEmailFields:r}=Jd(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:ms({...r,...o})}}}function hs(e){return ht(e)?.current()}function Ke(e){return hs(e)?.getContent()}function Zd(e,t){const n=t??zd(),r=hs(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:Ke(e)??n.html}:n}async function Ut(e){return(await e.getInstanceAsync(a.APP_ID))?.project}function be({code:e,project:t,...n},r){const s=re(n),o=fs(r),i=ge(r);return e&&i.warnAboutUnconfiguredInput(e,n.id),{...s,...e?{html:i.toEditorForm(e)}:{},...o===void 0?{}:{project:o},utm_parameters:s.utm_parameters||{},_embedded:void 0}}function W({html:e,renderGuid:t,showToken:n,showId:r,...s},o){const{requested:i}=qe(o),c=fr(o);return re({...s,code:ge(o).toOutputForm(e),project:i===void 0?s.project:i,utm_parameters:c.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})}function Ht(e){return e==null?"":e.replaceAll(`\r
2126
+ </html>`;function Zd(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:vs,project:e?.id,project_title:e?.title??"",tags:[],utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var eu=a.createIdentifier$1("CurrentProject"),tu={};function We(e){return e?.getInstance(eu)?.get()??tu}function _s(e){const t=We(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var ys=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function nu(e){return!Object.keys(e).some(t=>ys.has(t))}function ru(e){const t={},n={};for(const[r,s]of Object.entries(e))ys.has(r)?t[r]=s:n[r]=s;return{showOptions:t,misplacedEmailFields:n}}function Ss(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function Sm(e){}function Ke(e){return{emails:ss(e),blocks:Wd(e),emailRevisions:os(e),blocksRevision:Kd(e),comments:Xd(e)}}function su(e){const t=Object.values(Ke(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function Ut(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(nu(e))return{email:Ss(e)};{const{showOptions:n,misplacedEmailFields:r}=ru(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:Ss({...r,...o})}}}function ws(e){return gt(e)?.current()}function Xe(e){return ws(e)?.getContent()}function ou(e,t){const n=t??Zd(),r=ws(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:Xe(e)??n.html}:n}async function Ht(e){return(await e.getInstanceAsync(a.APP_ID))?.project}function be({code:e,project:t,...n},r){const s=se(n),o=_s(r),i=ge(r);return e&&i.warnAboutUnconfiguredInput(e,n.id),{...s,...e?{html:i.toEditorForm(e)}:{},...o===void 0?{}:{project:o},utm_parameters:s.utm_parameters||{},_embedded:void 0}}function X({html:e,renderGuid:t,showToken:n,showId:r,...s},o){const{requested:i}=We(o),c=_r(o);return se({...s,code:ge(o).toOutputForm(e),project:i===void 0?s.project:i,utm_parameters:c.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})}function $t(e){return e==null?"":e.replaceAll(`\r
2127
2127
  `,`
2128
- `)}function gs(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function eu(e,t,n,r){const s=tu(e,t,n,r);return s===void 0}function tu(e,t,n,r){const{email:s}=jt(t,!1),o=be(s,e),i=o.id;if(i===void 0)return"no-id";if(r!==void 0&&r!==i)return"other-id-shown";const c=ht(e)?.current();if(!c)return"no-session";const l=c.get(),u=l.attributes;if(l.serverId!==i)return"document-id";if(u.is_inited!==!0)return"not-inited";const d=gs(Ht(n??c.getContent()));if(o.html!==void 0&&gs(Ht(o.html))!==d)return"html";if(o.subject!==void 0&&o.subject!==u.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==u.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==u.common_styles)return"common_styles"}function Es(e,t){const{email:n}=jt(t,!1),r=be(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:Ht(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function nu(e,t){const n={...e};return delete n.id,{...n,...t}}function ru(e){return e.html?e:{...e,html:us}}function Pe({code:e,project:t,...n},r,s){const o=s??fs(r);return{...n,...e?{html:ge(r).toEditorForm(e)}:{},renderGuid:a.generateUUID(),...o===void 0?{}:{project:o}}}function We({html:e,renderGuid:t,...n},r){const{requested:s}=qe(r);return re({...n,code:ge(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 bs(e){return ht(e)?.current()?.get().serverId??void 0}function $t(e,t,n){return n===void 0&&(n=e.post===void 0?bs(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function Xe(e,t){return re({...e,link:void 0,comment_status:void 0})}function Gt({code:e,...t},n,r){return r===void 0&&(r=t.parent===void 0?bs(n):t.parent),{...t,...e?{html:e}:{},parent:r}}function vs({html:e,...t},n){return re({...t,code:e,guid:void 0,compiled:re({html:e,ampHtml:e&&""})})}var su=a.createIdentifier$1("emailTemplate.reads");async function ou(e,t){try{return await le(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message;return}}function iu(e,t){const n=e.getOrCreateInstance(su,()=>new Map),r=n.get(t);if(r!==void 0)return r;const s=ou(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,s),s}var au="EXTERNAL";function lu(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"сохранение не состоялось")}var cu="email_id",du=class extends a.Disposable{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_dataSources;_eventLock;_queue=a.createQueue();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=ze(t),this._eventLock=Qd(t);const n=$(e,a.events.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(a.REQUEST_HANDLER_ID,{execute:(r,s)=>{!s?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(cu,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(a.INIT_PIPELINE_ID)??St}_throwIfDestroyed(){if(this.isDisposed())throw st()}async getTemplateEmail(e){const t=await iu(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Ut(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Pe(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,Gt(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,$t(s,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,s){const o=this._dataSources.emails,i=o.cache,c=await Ut(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let u=be(e,this._container);const d=u.id;let p=d;if(d!==void 0){const m=await o.get(d);u={...m??{},...u,renderGuid:m?.renderGuid??a.generateUUID(),...l>0?{showToken:l}:{},...s?{showId:s}:{},project:c}}else{p=n??a.generateUUID();const m=await o.get(p);u={...u,renderGuid:m?.renderGuid??a.generateUUID(),...l>0?{showToken:l}:{},...s?{showId:s}:{},project:c},delete u.project}if(t){const m=await this.getTemplateEmail(String(t));m&&(u=nu(m,u))}return d===void 0&&(u=ru(u)),await i.addOrUpdate(p,()=>u),u}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Es(this._container,e))return!1;const n=Ke(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Es(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Ke(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&t!==this._showRequests){this._showRequests;return}if(!e)return;const n=this._getInitPipeline();if(a.throwIfAborted(n.signal),eu(this._container,e,Ke(this._container),this._prevCommand?.id)||this._isRepeatOfLastShow(e))return;const r=jt(e);r.email.id,this._prevCommand?.id;let s,o="",i=0,c=!1,l,u=Promise.resolve(),d,p=!1;try{this._eventLock.suspendChange();const{email:m,blocks:b,autosaves:y,comments:E,templateId:g,reload:v}=r;s=m.id;const _=be(m,this._container),w=_.id,P=w??a.generateUUID(),D=await Ie("getProject",Ut(this._container));a.throwIfAborted(n.signal),o=a.generateUUID();const h={isNew:w===void 0,id:String(P),project:D},I=v===!0&&w!==void 0;I&&(await this._dataSources.emails.remove(String(w),{silent:!0}),String(w)),i=++this._showToken,String(P);const f=[];f.push(this.setBlocks(b)),m.id!==void 0&&(f.push(this.setComments(E)),f.push(this.setEmailRevisions(y,String(m.id)))),f.push(this.setEmail(m,Number(g),w===void 0?String(P):void 0,i,o)),await Ie("setEmail+blocks+revisions",Promise.all(f),{emailId:w??String(P),showId:o,targetShowToken:i}),a.throwIfAborted(n.signal);const S=await this._dataSources.emails.get(String(P)),T=se(this._container),A={id:o,token:i};w===void 0?d=T.startNewDraft(S??_,{patch:_,show:A}):I?d=T.reload(w,{email:S??_,patch:_,show:A}):T.sessionKey()===Se(w)?d=T.show(_,A):d=T.open(w,{email:S??_,patch:_,show:A});const O=!!this._prevCommand&&a.deepEqual(this._prevCommand,h);h.id,!this._prevCommand||a.deepEqual(this._prevCommand,h),this._prevCommand?.id,this._rememberShow(h),u=n.requestShow({showId:o,navId:String(P),emailId:w,isNew:w===void 0}),p=!0,String(P),c=!0}catch(m){l=m,p&&o&&n.failShow(o,m),String(m)}finally{this._eventLock.resumeChange()}if(!c)throw l instanceof Error?l:new Error(`[useblocks] show() setup failed: ${String(l??"unknown error")}`);return Ie("show-init-deferred",Promise.all([u,d?.whenReady().catch(m=>{if(m instanceof Fe){const b=er(m);throw b?new Error(`[useblocks] show(): email open failed (${b})`,{cause:m}):m}})??Promise.resolve()]).then(()=>{}),{showId:o,emailId:s??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();a.throwIfAborted(e.signal);const t=se(this._container),n=await t.save("publish",{source:au});if(a.throwIfAborted(e.signal),!n)throw lu(t.saveState().error);return W(Zd(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;return this._queuedShow(e,t)};save=this._queue.decorate(this._save,this)};function uu(e){return String(e).replace(/"/g,"&quot;")}function fu(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 pu(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 _s(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),s=uu(n);return r.test(e)?e.replace(r,`${t}="${s}"`):e.replace(/>$/,` ${t}="${s}">`)}function mu(e,t,n){if(!e?.trim()||!t)return e;const r=pu(e);if(!r)return e;const s=String(t),o=fu(n??new Date);let{full:i,index:c}=r;const l=i.length;return/\bem-block-id\s*=/.test(i)||(i=_s(i,"em-block-id",s)),i=_s(i,"em-block-version",o),e.slice(0,c)+i+e.slice(c+l)}function hu(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 gu(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:hu(e)}}function Vt(e,t){return t?gu(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var ys=["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"],Eu=[...ys,"html","id","project","password"],dm=new Set(["html",...ys,"global_block","project"]);function bu(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(Eu),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 vu(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...bu(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 Yt=new WeakMap;function _u(e){let t=Yt.get(e);return t||(t={byId:new Map,fallback:[]},Yt.set(e,t)),t}function yu(e){Yt.delete(e)}function Su(e,t){const{byId:n,fallback:r}=_u(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,c=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(i&&c)return r.splice(s,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function wu(e,t){const{blocks:n}=ze(e);return await n.cache.getIfPresent(t)??void 0}async function Iu(e,t){if(!t.blockId)return;const n=await wu(e,t.blockId);if(n)return vu(n,t)}async function Tu(e,t){const n=Su(e,t);if(n)return Vt(e,n);const r=await Iu(t,e);return r?Vt(e,r):Vt(e,void 0)}var Au=a.createIdentifier("application_block_inserted"),Cu=-1e3,Ss=new WeakSet;function Pu(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 Du(e){if(!e||Ss.has(e))return;Ss.add(e);const t=new a.Disposable,n=q(e);return t.addDisposable(n.addListenerAsyncPipe(Au,async(r,s)=>{const o=Pu(r)?await Tu(r,e):r;return s?s(o):o},Cu)),t.addDisposable({dispose:()=>{yu(e)}}),t}var ws=100,Ru=class extends a.Disposable{_container;_events;constructor(e){super(),this._container=e;const t=Du(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:s}=ze(e),o=$(e,a.events.ON_SHARE_ID),i=$(e,a.events.ON_SHOW_PREVIEW_ID),c=$(e,a.events.ON_EMAIL_CLONE_ID),l=$(e,a.events.ON_CODE_VALIDATE_ID),u=$(e,a.events.ON_SUBJECT_CHANGED_ID),d=$(e,a.events.ON_EMAIL_CHANGED_ID),p=$(e,a.events.ON_PREHEADER_CHANGED_ID),m=$(e,a.events.ON_SAVEBUTTON_CLICK_ID),b=$(e,a.events.ON_NEXTBUTTON_CLICK_ID),y=$(e,a.events.ON_SEND_LIVEPREVIEW_ID),E=$(e,a.events.ON_SEND_TESTEMAIL_ID),g=$(e,qd),v=$(e,a.events.ON_CONTENT_CHANGED_ID),_=$(e,Yd),w=$(e,a.events.ON_PREVIOUSBUTTON_CLICK_ID),P=$(e,a.events.ON_SEND_EMAIL_MODAL_ID),D=a.filter($(e,a.events.ON_EMAIL_INIT_ID),h=>!h.reset);return{handlePreheaderChanged:M(p),handleSubjectChanged:M(u),handleValidate:M(l),handleReadEmail:M(n.handlerRead,h=>h,h=>h&&be(h,e)),handleSaveEmail:M(n.onSave,function({prev:h,patch:I,value:f,source:S}){const T=h?W(h,e):void 0;return{prev:T,patch:Te(T,W(I,e)),value:W(f,e),source:S}},h=>h?be(h,e):void 0),handleRemoveEmail:M(n.onRemove,({value:h,source:I})=>({value:W(h,e),source:I}),()=>{}),handleReadCommonBlocks:M(g,h=>h.project,h=>h?.map(I=>Pe(I,e))),handleReadTemplateBlocks:M(_,h=>h,h=>h?.map(I=>Pe(I,e))),handleReadBlocks:M(t.byForeignKey("project").handleRead,h=>qe(e).requested||String(h),h=>h?.map(I=>Pe(I,e))),handleSaveBlock:M(t.onSave,function({prev:h,patch:I,value:f,source:S}){const T=f.global_block===!0&&f.id&&typeof f.html=="string"?{...f,html:mu(f.html,String(f.id))}:f,A=h?We(h,e):void 0;return{prev:A,patch:Te(A,We(I,e)),value:We(T,e),source:S}},h=>h?Pe(h,e):void 0),handleRemoveBlock:M(t.onRemove,({value:h,source:I})=>({value:We(h,e),source:I}),()=>{}),handleReadComments:M(r.byForeignKey("post").handleRead,h=>h,h=>h?.map(I=>$t(I,e))),handleSaveComment:M(r.onSave,function({prev:h,patch:I,value:f,source:S}){const T=h?Xe(h,e):void 0;return{prev:T,patch:Te(T,Xe(I,e)),value:Xe(f,e),source:S}},h=>h?$t(h,e):void 0),handleRemoveComment:M(r.onRemove,({value:h,source:I})=>({value:Xe(h,e),source:I}),()=>{}),handleReadEmailRevisions:M(s.byForeignKey("parent").handleRead,h=>h,h=>h?.map(I=>Gt(I,e))),handleEmailAutosave:M(s.onSave,function({prev:h,patch:I,value:f,source:S}){return{value:vs(f,e),source:S}},h=>h?Gt(h,e):void 0),handleRemoveEmailAutoSave:M(s.onRemove,({value:h,source:I})=>({value:vs(h,e),source:I}),()=>{}),handleEmailChanged:M(a.debounce(d,ws),h=>W(h,e)),handleEmailInit:M(D,h=>W(h,e)),handlePreviousButtonClick:M(w,h=>W(h,e)),handleNextButtonClick:M(b,h=>W(h,e)),handleSaveButtonClick:M(m,h=>W(h,e)),handleHtmlChanged:M(a.debounce(v,ws)),handleTestEmailSend:M(E,({html:h,...I})=>({...I,code:h,compiled:{html:h,ampHtml:""}})),handleTestEmailModal:M(P,h=>W(h,e)),handleCloneEmail:M(c,h=>W(h,e)),handleShareEmail:M(o),handlePreviewEmail:M(i),handleLivePreviewEmail:M(y)}}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 Ee(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Ou=a.createIdentifier$1("DataController"),Lu=a.createIdentifier$1("DataEvents");function Is(e){return e.getOrCreateInstance(Ou,()=>{const t=new du(e);return e.getInstance(a.DISPOSABLE_ID)?.addDisposable(t),t})}function Ts(e){return e.getOrCreateInstance(Lu,()=>new Ru(e))}var Nu=a.createIdentifier$1("plugin.startupShow");function Mu(e){const t=Is(e),n=Ts(e),r=e.getInstance(a.OPTIONS_SOURCE_ID),s=e.getInstance(a.DISPOSABLE_ID),o={current:Promise.resolve()};e.inject(Nu,o);const i=r?.watch(l=>{l&&n.setOptions(l)}),c=r?.select(l=>l?.content).watch(l=>{l!==void 0&&(U(z.showStart),o.current=(async()=>{try{await t.show(l)}catch{}finally{U(z.showEnd)}})())});i&&s?.addDisposable(i),c&&s?.addDisposable(c)}function xu(e){const t=Is(e);return{...Ts(e).get(),show(n){return U(z.showStart),t.show(n).finally(()=>U(z.showEnd))},save(){return t.save()}}}function um(e){return e}var ku=[{name:"rest.client",setup:Ud},{name:"auth.oauth",setup:a.provideOAuth},{name:"rest.identityHeaders",setup:xd},{name:"lifetime.destroyable",provides:[Lt],setup:Bc},{name:"appInit",provides:[a.APP_ID,it],setup:jo},{name:"config",provides:[a.CONFIG_SOURCE_ID],setup:kc},{name:"email.documents",setup:nd},{name:"show.initPipeline",provides:[a.INIT_PIPELINE_ID],setup:Hd},{name:"show",setup:Mu},{name:"locale.service",provides:[Ce],setup:Od},{name:"locale.fromConfig",awaits:{services:[a.CONFIG_SOURCE_ID,Ce]},setup:Ld},{name:"canvas.early",setup:kl},{name:"canvas.previewSettings",setup:Vl},{name:"canvas.sandboxExtensions",setup:ql},{name:"canvas.headerSync",provides:[xr],setup:jl},{name:"canvas.ampSync",setup:pa},{name:"canvas.moduleBridge",setup:Ba},{name:"canvas.port",setup:Sa},{name:"canvas.images",setup:_a},{name:"canvas.edits",setup:El},{name:"canvas.blockContent",setup:ul},{name:"canvas.sandboxFill",provides:[wt],setup:cc},{name:"canvas.reactions",setup:Nl}],Fu=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function Bu(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 ju(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 As(e){const t=Bu(e),n=[],r=new Set,s=[],o=new Set,i=c=>{if(!r.has(c)){if(o.has(c)){const l=s.indexOf(c);throw new Fu([...s.slice(l),c].map(u=>u.name))}o.add(c),s.push(c);for(const l of ju(c,t))i(l);s.pop(),o.delete(c),r.add(c),n.push(c)}};for(const c of e)i(c);return n}var Cs;function qt(e){const t=e.getInstance(a.OPTIONS_SOURCE_ID);if(t)return t;e.getInstance(a.DISPOSABLE_ID)||e.inject(a.DISPOSABLE_ID,new a.Disposable);const n=pe();e.inject(a.OPTIONS_SOURCE_ID,n),Cs??=As(ku);for(const r of Cs)r.setup(e);return n}function Uu(e){}var Hu=[{name:"save.previewFollow",setup:Uu}],Ps=a.createIdentifier$1("plugin.lateUnitsInstalled");function $u(e){if(!e.getInstance(Ps)){e.inject(Ps,!0);for(const t of As(Hu))t.setup(e)}}function Gu(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function Vu(e){if(!e)return;const t=a.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 Yu=a.defineMixin(e=>{let t,n,r;return{async setOptions(s){const o=r!==s.getAuthToken,i=!a.deepEqual(t,s.user),c=n!==s.project;if(r=s.getAuthToken,t=s.user,n=s.project,!(!e.getInstance(a.SECURITY_MODULE_ID)||!s.getAuthToken)&&!(!o&&!i&&!c))try{const l=await s.getAuthToken(s.user,s.project);e.inject(a.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(l||""));const u=Vu(l);if(!u)return;e.inject(a.STANDALONE_PROJECT_ID,u);const d=e.getInstance(a.APP_ID),p=d?await d.catch(()=>{}):void 0;e.inject(a.APP_ID,Promise.resolve(Gu(u,p)))}catch{}}}});function qu(e,t){if(e.getInstance(a.STANDALONE_FILE_PROXY_REGISTERED_ID))return;e.inject(a.STANDALONE_FILE_PROXY_REGISTERED_ID,!0);const n=a.getEvent(e,a.events.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}function zu(e){e.getInstance(a.STANDALONE_ACTIVATED_ID)||e.inject(a.SECURITY_MODULE_ID,void 0)}function Je(e){return String(e.standaloneKey||"").trim()||void 0}function Ku(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function zt(e){return Ku(e)?!!Je(e):!1}function Qe(e){return!!Je(e)&&!zt(e)}var Wu=a.defineMixin(e=>{let t,n=!1;return{setOptions(r){const s=n;if(n=!0,!Qe(r)){t&&(zu(e),zt(r)),t=void 0;return}const o=Je(r);if(!o||t===o&&e.getInstance(a.SECURITY_MODULE_ID))return;t=o,e.inject(a.SECURITY_MODULE_ID,o);const i=e.getInstance(a.DISPOSABLE_ID);i&&qu(e,i)}}}),Xu=a.defineMixin(e=>{const t=e.getInstance(a.DISPOSABLE_ID),n=a.getEvent(e,a.APP_LOAD_EVENT_ID),r=M(n),s=t.addDisposable(new Ee(r));return{setOptions({handleLoad:o}){s.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}}),Ju=a.defineMixin(e=>{const t=e.getInstance(a.DISPOSABLE_ID),n=t.addDisposable(new a.AsyncEmitter),r=t.addDisposable(new a.AsyncEmitter),s=a.getEmitter(e,a.CONFIG_CHANGED_EVENT_ID),o=M(n.event),i=M(r.event),c=M(s.event),l=t.addDisposable(new Ee(o)),u=t.addDisposable(new Ee(i)),d=t.addDisposable(new Ee(c));return{instance:{handleSetOptions:o,handleOptionsChanged:i,handleConfigChanged:c},async setOptions(p){l.setListener(p.handleSetOptions),u.setListener(p.handleOptionsChanged),d.setListener(p.handleConfigChanged),await n.fire(p),await r.fire(p)},dispose(){}}}),Kt,Ds="core";function Qu(){const e=__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Ds],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function Zu(e){const t=__useblocks__?.require?.warm;return typeof t!="function"?De().then(()=>{}):t([Ds],e)}function De(){return Kt===void 0&&(Kt=Qu().then(e=>(_e()&&e.installDiagnostics().catch(t=>{}),e))),Kt}var Wt=null,Xt=null;async function ef(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Jt(){return Wt||(Wt=De().then(()=>{})),Wt}function Rs(e){return Xt||(Xt=ef(e)),Xt}function tf(){return Rs(typeof __useblocks__<"u"?__useblocks__:void 0)}function nf(e){return Promise.all([Jt(),Rs(e)]).then(()=>{})}function rf(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function Os(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>Zu(t?{priority:t}:void 0)).then(()=>n?Jt():void 0).catch(()=>{})}function sf(e){const t=rf(e);if(t==="eager")Os(e);else if(t==="idle"){const n=()=>Os(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var Ls="PluginRegistry";function of(e=a.resolveContainer()){return e.getOrCreateInstance(Ls,()=>new _o)}var Ns=new yo(()=>of()),af=a.defineMixin(e=>{let t;function n(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(r){const s=e.getInstance(a.INSTANCE_ID),o=e.getInstance(Ls);t||(t=new vo(s,o,{ensureHostRuntimeReady:tf}),e.inject(a.PLUGIN_COLLECTION_ID,t));const i=r?.plugins||[];s&&await t.setPlugins(i)},instance:{use(r){return typeof r=="function"?n().useByCtor(r):n().useByKey(r)},useAsync(r){return n().useAsync(r)},waitPlugin(r){return n().waitFor(r)}},dispose(){t?.dispose(),t=void 0}}}),Ms=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}},lf=a.createIdentifier$1("ELEMENT_INSERT_HTML_PIPELINE"),cf=a.createIdentifier$1("BLOCK_INSERT_HTML_PIPELINE"),df="application_block_inserted",uf=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(cf,()=>new Ms).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.MessageService),s=n?e.bind(n):e;return r.addListener(df,s,t)}},ff=a.createIdentifier$1("ComponentRegistry"),xs;function Re(e,t=ff){const n=a.DependencyResolver.getInstance(t);if(n)return n;if(!xs)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return a.DependencyResolver.getOrCreateInstance(t,xs)}var pf=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=this._container.addService(a.ATOMS_HANDLERS_ID,{execute:n=>{t.dispose(),e(n.value.map(r=>({name:r.name,html:r.html})))}})})}update(e,t){const n=this._container,r=Re(n);return n.addService(a.ATOMS_HANDLERS_ID,{execute:s=>{const o=s.value.find(i=>i.name===e);if(o){const{icon:i,title:c,fallbackTooltip:l,...u}=t;i&&(o.icon=r.getReactNode(i)),c&&(o.title=r.getReactNode(c)),l&&(o.fallbackTooltip=r.getReactNode(l)),Object.assign(o,u)}}})}delete(e){this._container.addService(a.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,r=Re(n);return n.addService(a.ATOMS_HANDLERS_ID,{execute:s=>{s.value.splice(t??s.value.length,0,{...e,title:r.getReactNode(e.title),icon:r.getReactNode(e.icon),fallbackTooltip:r.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(lf,()=>new Ms).add(e,t??0,n)}handleInject(e,t,n){return a.getEmitter$1(this._container,a.HANDLE_ATOM_INSERT_ID).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},mf=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.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 hf(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}var gf=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=a.getEmitter$1(t,a.MODAL_SHOW_EVENT),this._closeModalEmitter=a.getEmitter$1(t,a.MODAL_CLOSE_EVENT),this._updateModalEmitter=a.getEmitter$1(t,a.MODAL_UPDATE_EVENT)}get _container(){return this._context.container}show(e){const t=Re(this._container),n=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,r=e.modalProps;return this._showModalEmitter.fire({...e,content:t.getReactNode(e.content),title:t.getReactNode(e.title),id:n,modalProps:r?{...r,footer:t.getReactNode(r.footer),okText:t.getReactNode(r.okText),cancelText:t.getReactNode(r.cancelText),closeIcon:t.getReactNode(r.closeIcon)}:void 0}),n}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=Re(this._container),r=t.modalProps;this._updateModalEmitter.fire(hf({...t,content:n.getReactNode(t.content),title:n.getReactNode(t.title),id:e,modalProps:r?{...r,footer:n.getReactNode(r.footer),okText:n.getReactNode(r.okText),cancelText:n.getReactNode(r.cancelText),closeIcon:n.getReactNode(r.closeIcon)}:void 0}))}},Ef=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{const s=()=>this._loadedDisposable.dispose(),o=()=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&s(),n())},i=c=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&s(),r(c))};this._resolveLoaded=o,this._rejectLoaded=i}),this.ready=new Promise((n,r)=>{const s=()=>this._loadedDisposable.dispose(),o=()=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&s(),n())},i=c=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&s(),r(c))};this._resolveReady=o,this._rejectReady=i})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady()}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},bf=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.MessageService)}_createScriptHandle(e,t){const n=this._messageService.addListener(a.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 Ef(t,n);return r}registerSandboxCSS(e){return this._container.addService(a.SANDBOX_EXTENSIONS_ID,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(a.SANDBOX_EXTENSIONS_ID,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(a.SANDBOX_EXTENSIONS_ID,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(a.SANDBOX_EXTENSIONS_ID,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},vf=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function Qt(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&vf.has(t)}function ks(){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 Zt(){return`__settingsPanel:${ks()}`}function en(e,t){return{type:e,props:t}}function _f(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!Qt(e)}function Fs(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(Qt(t)){const r=Zt();return n(e.add(r,t)),en(r,{})}if(typeof t=="function"){const r=Zt();return n(e.add(r,t)),en(r,{})}if(_f(t)){const r=t.type;if(typeof r=="string")return t;if(Qt(r)||typeof r=="function"){const s=Zt();return n(e.add(s,r)),en(s,t.props)}return t}return t}var yf=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=Re(this._container),n=i=>this._trackRegistration(i),r=Fs(t,e.content,n),s=e.advancedTabs?.map(i=>({...i,content:Fs(t,i.content,n)})),o=e.instanceKey??ks();a.getEmitter$1(this._container,a.SETTINGS_PANEL_EVENT).fire({...e,content:r,advancedTabs:s,instanceKey:o,type:a.ADVANCED_SETTINGS_PANEL})}closeSettingsPanel(){this._clearPanelRegistrations(),a.getEmitter$1(this._container,a.SETTINGS_PANEL_EVENT).fire(null)}},Bs={SandboxScriptApi:bf,ElementsApi:pf,BlocksApi:uf,MessageService:mf,SettingsPanelApi:yf,ModalApi:gf};function tn(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 c=s[o],l=r[o]??{};s[o]=Object.assign({},typeof c=="object"&&c!==null?c:l,i)}else s[o]=i;return s}var X={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}},Sf={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"},nn={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},js={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},ve={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:X.border,borderRadius:X.borderRadius,textAlign:"center",padding:X.padding},Us={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:X.padding},rn={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:X.border,borderRadius:X.borderRadiusCards};function wf(e){return{...Sf,...e}}function If(e){return{...nn,...e,bold:e?.bold??nn.bold,italic:e?.italic??nn.italic}}function Tf(e){return{...js,...e,underline:e?.underline??js.underline}}function Af(e){return{...ve,...e,bold:e?.bold??ve.bold,italic:e?.italic??ve.italic,border:{...ve.border,...e?.border},borderRadius:{...ve.borderRadius,...e?.borderRadius},padding:{...ve.padding,...e?.padding}}}function Cf(e){return{...Us,...e,padding:{...Us.padding,...e?.padding}}}function Pf(e){return{...rn,...e,border:{...rn.border,...e?.border},borderRadius:{...rn.borderRadius,...e?.borderRadius}}}function sn(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 Hs(e){let t={...a.COMMON_STYLES};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function on(e){return{text:wf(e.text),headings:If(e.headings),links:Tf(e.links),buttons:Af(e.buttons),block:Cf(e.block),cards:Pf(e.cards)}}var $s=a.createIdentifier$1("EmailSettingsPort"),Df=1e4,Gs=class{_editor;_layoutSettingsChanged=new a.Emitter;_contentStylesChanged=new a.Emitter;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance($s);if(!t)throw new Error("[extensions] настройки письма ещё не загружены — работа с UI начинается с init()");return t}_getCurrentLayoutSettings(){return sn(this._settings().read())}_getCurrentContentStyles(){const e=lt(this._editor.container)?.current()?.get().attributes.common_styles;return on(Hs(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($s),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.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===a.EVENT_TYPES.APPLICATION_EMAIL_SETTINGS_SET){const l=sn(s?.settings),u=this._getLayoutSnapshot(l);u!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=u,this._layoutSettingsChanged.fire(l));return}if(o!==a.EVENT_TYPES.APPLICATION_COMMON_STYLES_UPDATE)return;const i=on(r.data?.settings?.commonStyles??{...a.COMMON_STYLES}),c=this._getContentSnapshot(i);c!==this._prevContentSnapshot&&(this._prevContentSnapshot=c,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=sn(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Df){const t=lt(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=a.getEvent(r,a.events.ON_EMAIL_INIT_ID);return new Promise(o=>{let i=!1,c;const l=()=>{c&&(clearTimeout(c),c=void 0)},u=s(()=>{i||(i=!0,l(),u.dispose(),o())});c=setTimeout(()=>{i||(i=!0,u.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=lt(this._editor.container)?.current();if(!t)return;const n=Hs(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=tn(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:X.border,borderRadius:X.borderRadius,padding:X.padding})),e.block!==void 0&&(n.block=tn(n.block||{},e.block,["padding"],{padding:X.padding})),e.cards!==void 0&&(n.cards=tn(n.cards||{},e.cards,["border","borderRadius"],{border:X.border,borderRadius:X.borderRadiusCards}));const r=JSON.stringify(n);Be(t,{common_styles:r}),this._settings().markAppearanceChanged();const s=on(n);this._prevContentSnapshot=this._getContentSnapshot(s),this._contentStylesChanged.fire(s)}},Rf={...Bs,EmailSettingsApi:Gs},Of={...Bs},fm={...Of,EmailSettingsApi:Gs},Lf={...Rf};function Nf(){Ns.addAll(Lf)}var Mf=[a.defineMixin(()=>{Nf()}),Xu,Ju,Wu,a.JWTMixin,Yu,a.OAuthMixin];async function xf(){return(await De()).asyncMixins}var kf=af,Ff=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let s;try{s=await xf()}catch(i){throw e.failPendingWaits(i),i}t=s(e);const o=await e.getInstanceAsync(a.INSTANCE_ID);Object.assign(o,t.instance||{});for(const i of e.getInstance(a.LATE_SURFACE_LISTENERS_ID)??[])i()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},Bf=a.combineMixins([...Mf]);function an(){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,c){const l=Symbol("subscription");return t||(n.set(l,{listener:o,priority:i,thisArg:c}),e&&r.set(l,e(o,i,c))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(o){s(),e=o;for(const[i,{listener:c,priority:l,thisArg:u}]of n)r.set(i,o(c,l,u))},dispose(){t=!0,s(),n.clear(),e=void 0}}}var Vs=a.createIdentifier$1("NotificationService");function jf(e){const t=an(),n=an(),r=an();return e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(Vs).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(Vs);if(!o)throw new Error("[plugin] notify() вызван до загрузки редактора");o.notify(s)}}}var Uf=[jc,xu,jf];function Hf(e,t=Uf){const n=qt(e);$u(e);const r=Bf(e),s=kf(e),o=Ff(e),i={...r.instance,...s.instance,...o.instance};for(const l of t)Object.assign(i,l(e));let c=!0;return{instance:i,async setOptions(l){await r.setOptions(l);const u=c&&n.get()===l;c=!1,u||n.set(l),await s.setOptions(l),await o.setOptions(l)}}}var $f=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]}},Gf="editor-runtime.react.copies",ln=8;function Oe(e){return e&&typeof e=="object"?e:void 0}function Ys(e){const t=Oe(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Oe(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function Vf(e){const t=Oe(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Oe(t?.default),s=r&&typeof r.version=="string"?r.version:void 0;return n??s??"unknown"}function Yf(e,t,n){return e.package===t&&e.version===n}function qf({ourReact:e,entries:t,packageName:n,version:r}){const s=Ys(e);if(!s||!Array.isArray(t))return[];const o=[],i=new Set;for(const c of t){const l=Oe(c);if(!l||!Yf(l,n,r))continue;const u=Ys(l.react);!u||u===s||i.has(u)||(i.add(u),o.push({package:n,version:r,reactVersion:Vf(l.react),react:l.react}))}return o}function zf({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,ln))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>ln&&n.push(` …and ${t.length-ln} 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(`
2129
- `)}var qs=new Set;function Kf({packageName:e="useblocks",version:t="1.1.85-dev.6",log:n=r=>{}}={}){const r=s=>{try{const o=globalThis[Symbol.for(Gf)],i=qf({ourReact:s,entries:o,packageName:e,version:t}).filter(c=>!qs.has(c.react));if(!i.length)return;i.forEach(c=>qs.add(c.react)),n(zf({packageName:e,copies:i}))}catch{}};try{const s=rt()?.modules?.React;if(s&&typeof s.then=="function"){s.then(r,()=>{});return}r(s)}catch{}}async function Wf(e,t,n){a.throwIfAborted(e.signal);const r=t??a.DependencyResolver.createChild();qt(r);const s=r.getInstance(a.DISPOSABLE_ID);async function o(){r.inject(a.COOKIE_MANAGER_ID,new $f),Kf();const i=Hf(r),c={...i.instance,container:r,async reset(l){if(a.throwIfAborted(l.signal),s.isDisposed())throw st();return await i.setOptions(l),c}};r.inject(a.INSTANCE_ID,c);try{if(n?.onInstance?.(c),await i.setOptions(e),a.throwIfAborted(e.signal),s.isDisposed()||await r.getInstance(a.PLUGIN_COLLECTION_ID)?.activate(),e.devTools)try{const l=r.getInstance(a.PLUGIN_COLLECTION_ID);l&&await(await De()).initDevTools(r,l)}catch{}return a.throwIfAborted(e.signal),a.getEmitter(r,a.APP_LOAD_EVENT_ID).fire(c),c}catch(l){throw s.dispose(),l}}try{return await a.raceWithAbortSignal(o(),e.signal)}catch(i){throw s.isDisposed()||s.dispose(),i}}var Le=new WeakMap;function Xf(e){return e?Le.get(e):void 0}function zs(e){try{e.getInstance(a.DISPOSABLE_ID)?.dispose()}catch{}try{e.dispose()}catch{}}function Jf(e,t){if(!e)return;const n=Le.get(e);n&&n!==t&&zs(n),Le.set(e,t)}function Qf(e,t){e&&Le.get(e)===t&&Le.delete(e)}function Zf(e){const t=a.DependencyResolver.createChild();return Qe(e)&&t.inject(a.SECURITY_MODULE_ID,Je(e)),t}var Ne=new WeakMap,ep="data-useblocks-config-styles";function tp(e){return typeof e=="string"?e.trim():""}function Ks(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function np(e,t,n){if(!e||typeof document>"u")return null;const r=tp(t),s=Ne.get(e),o=n||e;if(!r)return s&&(s.remove(),Ne.delete(e)),null;if(s)return s.textContent!==r&&(s.textContent=r),(s.parentNode!==o||s!==o.firstChild)&&Ks(o,s),s;const i=document.createElement("style");return i.setAttribute(ep,"true"),i.textContent=r,Ks(o,i),Ne.set(e,i),i}function rp(e){if(!e)return;const t=Ne.get(e);t&&(t.remove(),Ne.delete(e))}var pm=!1;function Ws(){return!1}var mm=28,sp=`
2128
+ `)}function Is(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function iu(e,t,n,r){const s=au(e,t,n,r);return s===void 0}function au(e,t,n,r){const{email:s}=Ut(t,!1),o=be(s,e),i=o.id;if(i===void 0)return"no-id";if(r!==void 0&&r!==i)return"other-id-shown";const c=gt(e)?.current();if(!c)return"no-session";const l=c.get(),u=l.attributes;if(l.serverId!==i)return"document-id";if(u.is_inited!==!0)return"not-inited";const d=Is($t(n??c.getContent()));if(o.html!==void 0&&Is($t(o.html))!==d)return"html";if(o.subject!==void 0&&o.subject!==u.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==u.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==u.common_styles)return"common_styles"}function Ts(e,t){const{email:n}=Ut(t,!1),r=be(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:$t(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function lu(e,t){const n={...e};return delete n.id,{...n,...t}}function cu(e){return e.html?e:{...e,html:vs}}function Pe({code:e,project:t,...n},r,s){const o=s??_s(r);return{...n,...e?{html:ge(r).toEditorForm(e)}:{},renderGuid:a.generateUUID(),...o===void 0?{}:{project:o}}}function Je({html:e,renderGuid:t,...n},r){const{requested:s}=We(r);return se({...n,code:ge(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 As(e){return gt(e)?.current()?.get().serverId??void 0}function Gt(e,t,n){return n===void 0&&(n=e.post===void 0?As(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function Qe(e,t){return se({...e,link:void 0,comment_status:void 0})}function Vt({code:e,...t},n,r){return r===void 0&&(r=t.parent===void 0?As(n):t.parent),{...t,...e?{html:e}:{},parent:r}}function Cs({html:e,...t},n){return se({...t,code:e,guid:void 0,compiled:se({html:e,ampHtml:e&&""})})}var Yt=a.createIdentifier$1("NotificationService"),du=a.createIdentifier$1("emailTemplate.reads");async function uu(e,t){try{return await le(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,pu(e,t,n);return}}var fu=a.createIdentifier$1("emailTemplate.notifiedFailures");function pu(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(fu,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(Yt).then(()=>{a.getEmitter(e,a.events.ON_NOTIFICATION).fire({type:"error",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function mu(e,t){const n=e.getOrCreateInstance(du,()=>new Map),r=n.get(t);if(r!==void 0)return r;const s=uu(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,s),s}var hu="EXTERNAL";function gu(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"сохранение не состоялось")}var Eu="email_id",bu=class extends a.Disposable{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_dataSources;_eventLock;_queue=a.createQueue();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=Ke(t),this._eventLock=su(t);const n=$(e,a.events.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(a.REQUEST_HANDLER_ID,{execute:(r,s)=>{!s?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Eu,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(a.INIT_PIPELINE_ID)??wt}_throwIfDestroyed(){if(this.isDisposed())throw ot()}async getTemplateEmail(e){const t=await mu(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Ht(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Pe(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,Vt(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,Gt(s,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,s){const o=this._dataSources.emails,i=o.cache,c=await Ht(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let u=be(e,this._container);const d=u.id;let p=d;if(d!==void 0){const m=await o.get(d);u={...m??{},...u,renderGuid:m?.renderGuid??a.generateUUID(),...l>0?{showToken:l}:{},...s?{showId:s}:{},project:c}}else{p=n??a.generateUUID();const m=await o.get(p);u={...u,renderGuid:m?.renderGuid??a.generateUUID(),...l>0?{showToken:l}:{},...s?{showId:s}:{},project:c},delete u.project}if(t){const m=await this.getTemplateEmail(String(t));m&&(u=lu(m,u))}return d===void 0&&(u=cu(u)),await i.addOrUpdate(p,()=>u),u}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==Ts(this._container,e))return!1;const n=Xe(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=Ts(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Xe(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&t!==this._showRequests){this._showRequests;return}if(!e)return;const n=this._getInitPipeline();if(a.throwIfAborted(n.signal),iu(this._container,e,Xe(this._container),this._prevCommand?.id)||this._isRepeatOfLastShow(e))return;const r=Ut(e);r.email.id,this._prevCommand?.id;let s,o="",i=0,c=!1,l,u=Promise.resolve(),d,p=!1;try{this._eventLock.suspendChange();const{email:m,blocks:b,autosaves:S,comments:E,templateId:g,reload:v}=r;s=m.id;const _=be(m,this._container),w=_.id,P=w??a.generateUUID(),D=await Ie("getProject",Ht(this._container));a.throwIfAborted(n.signal),o=a.generateUUID();const h={isNew:w===void 0,id:String(P),project:D},I=v===!0&&w!==void 0;I&&(await this._dataSources.emails.remove(String(w),{silent:!0}),String(w)),i=++this._showToken,String(P);const f=[];f.push(this.setBlocks(b)),m.id!==void 0&&(f.push(this.setComments(E)),f.push(this.setEmailRevisions(S,String(m.id)))),f.push(this.setEmail(m,Number(g),w===void 0?String(P):void 0,i,o)),await Ie("setEmail+blocks+revisions",Promise.all(f),{emailId:w??String(P),showId:o,targetShowToken:i}),a.throwIfAborted(n.signal);const y=await this._dataSources.emails.get(String(P)),A=oe(this._container),L={id:o,token:i};w===void 0?d=A.startNewDraft(y??_,{patch:_,show:L}):I?d=A.reload(w,{email:y??_,patch:_,show:L}):A.sessionKey()===Se(w)?d=A.show(_,L):d=A.open(w,{email:y??_,patch:_,show:L});const k=!!this._prevCommand&&a.deepEqual(this._prevCommand,h);h.id,!this._prevCommand||a.deepEqual(this._prevCommand,h),this._prevCommand?.id,this._rememberShow(h),u=n.requestShow({showId:o,navId:String(P),emailId:w,isNew:w===void 0}),p=!0,String(P),c=!0}catch(m){l=m,p&&o&&n.failShow(o,m),a.isAbortError(m)||(Gn(m),void 0)}finally{this._eventLock.resumeChange()}if(!c)throw l instanceof Error?l:new Error(`[useblocks] show() setup failed: ${String(l??"unknown error")}`);return Ie("show-init-deferred",Promise.all([u,d?.whenReady().catch(m=>{if(m instanceof je){const b=lr(m);throw b?new Error(`[useblocks] show(): email open failed (${b})`,{cause:m}):m}})??Promise.resolve()]).then(()=>{}),{showId:o,emailId:s??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();a.throwIfAborted(e.signal);const t=oe(this._container),n=await t.save("publish",{source:hu});if(a.throwIfAborted(e.signal),!n)throw gu(t.saveState().error);return X(ou(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;return this._queuedShow(e,t)};save=this._queue.decorate(this._save,this)};function vu(e){return String(e).replace(/"/g,"&quot;")}function _u(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 yu(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 Ps(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),s=vu(n);return r.test(e)?e.replace(r,`${t}="${s}"`):e.replace(/>$/,` ${t}="${s}">`)}function Su(e,t,n){if(!e?.trim()||!t)return e;const r=yu(e);if(!r)return e;const s=String(t),o=_u(n??new Date);let{full:i,index:c}=r;const l=i.length;return/\bem-block-id\s*=/.test(i)||(i=Ps(i,"em-block-id",s)),i=Ps(i,"em-block-version",o),e.slice(0,c)+i+e.slice(c+l)}function wu(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 Iu(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:wu(e)}}function qt(e,t){return t?Iu(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Ds=["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"],Tu=[...Ds,"html","id","project","password"],wm=new Set(["html",...Ds,"global_block","project"]);function Au(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(Tu),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 Cu(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Au(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 zt=new WeakMap;function Pu(e){let t=zt.get(e);return t||(t={byId:new Map,fallback:[]},zt.set(e,t)),t}function Du(e){zt.delete(e)}function Ru(e,t){const{byId:n,fallback:r}=Pu(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,c=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(i&&c)return r.splice(s,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function Ou(e,t){const{blocks:n}=Ke(e);return await n.cache.getIfPresent(t)??void 0}async function Lu(e,t){if(!t.blockId)return;const n=await Ou(e,t.blockId);if(n)return Cu(n,t)}async function Nu(e,t){const n=Ru(e,t);if(n)return qt(e,n);const r=await Lu(t,e);return r?qt(e,r):qt(e,void 0)}var Mu=a.createIdentifier("application_block_inserted"),xu=-1e3,Rs=new WeakSet;function ku(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 Fu(e){if(!e||Rs.has(e))return;Rs.add(e);const t=new a.Disposable,n=Y(e);return t.addDisposable(n.addListenerAsyncPipe(Mu,async(r,s)=>{const o=ku(r)?await Nu(r,e):r;return s?s(o):o},xu)),t.addDisposable({dispose:()=>{Du(e)}}),t}var Os=100,Bu=class extends a.Disposable{_container;_events;constructor(e){super(),this._container=e;const t=Fu(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:s}=Ke(e),o=$(e,a.events.ON_SHARE_ID),i=$(e,a.events.ON_SHOW_PREVIEW_ID),c=$(e,a.events.ON_EMAIL_CLONE_ID),l=$(e,a.events.ON_CODE_VALIDATE_ID),u=$(e,a.events.ON_SUBJECT_CHANGED_ID),d=$(e,a.events.ON_EMAIL_CHANGED_ID),p=$(e,a.events.ON_PREHEADER_CHANGED_ID),m=$(e,a.events.ON_SAVEBUTTON_CLICK_ID),b=$(e,a.events.ON_NEXTBUTTON_CLICK_ID),S=$(e,a.events.ON_SEND_LIVEPREVIEW_ID),E=$(e,a.events.ON_SEND_TESTEMAIL_ID),g=$(e,Qd),v=$(e,a.events.ON_CONTENT_CHANGED_ID),_=$(e,Jd),w=$(e,a.events.ON_PREVIOUSBUTTON_CLICK_ID),P=$(e,a.events.ON_SEND_EMAIL_MODAL_ID),D=a.filter($(e,a.events.ON_EMAIL_INIT_ID),h=>!h.reset);return{handlePreheaderChanged:x(p),handleSubjectChanged:x(u),handleValidate:x(l),handleReadEmail:x(n.handlerRead,h=>h,h=>h&&be(h,e)),handleSaveEmail:x(n.onSave,function({prev:h,patch:I,value:f,source:y}){const A=h?X(h,e):void 0;return{prev:A,patch:Te(A,X(I,e)),value:X(f,e),source:y}},h=>h?be(h,e):void 0),handleRemoveEmail:x(n.onRemove,({value:h,source:I})=>({value:X(h,e),source:I}),()=>{}),handleReadCommonBlocks:x(g,h=>h.project,h=>h?.map(I=>Pe(I,e))),handleReadTemplateBlocks:x(_,h=>h,h=>h?.map(I=>Pe(I,e))),handleReadBlocks:x(t.byForeignKey("project").handleRead,h=>We(e).requested||String(h),h=>h?.map(I=>Pe(I,e))),handleSaveBlock:x(t.onSave,function({prev:h,patch:I,value:f,source:y}){const A=f.global_block===!0&&f.id&&typeof f.html=="string"?{...f,html:Su(f.html,String(f.id))}:f,L=h?Je(h,e):void 0;return{prev:L,patch:Te(L,Je(I,e)),value:Je(A,e),source:y}},h=>h?Pe(h,e):void 0),handleRemoveBlock:x(t.onRemove,({value:h,source:I})=>({value:Je(h,e),source:I}),()=>{}),handleReadComments:x(r.byForeignKey("post").handleRead,h=>h,h=>h?.map(I=>Gt(I,e))),handleSaveComment:x(r.onSave,function({prev:h,patch:I,value:f,source:y}){const A=h?Qe(h,e):void 0;return{prev:A,patch:Te(A,Qe(I,e)),value:Qe(f,e),source:y}},h=>h?Gt(h,e):void 0),handleRemoveComment:x(r.onRemove,({value:h,source:I})=>({value:Qe(h,e),source:I}),()=>{}),handleReadEmailRevisions:x(s.byForeignKey("parent").handleRead,h=>h,h=>h?.map(I=>Vt(I,e))),handleEmailAutosave:x(s.onSave,function({prev:h,patch:I,value:f,source:y}){return{value:Cs(f,e),source:y}},h=>h?Vt(h,e):void 0),handleRemoveEmailAutoSave:x(s.onRemove,({value:h,source:I})=>({value:Cs(h,e),source:I}),()=>{}),handleEmailChanged:x(a.debounce(d,Os),h=>X(h,e)),handleEmailInit:x(D,h=>X(h,e)),handlePreviousButtonClick:x(w,h=>X(h,e)),handleNextButtonClick:x(b,h=>X(h,e)),handleSaveButtonClick:x(m,h=>X(h,e)),handleHtmlChanged:x(a.debounce(v,Os)),handleTestEmailSend:x(E,({html:h,...I})=>({...I,code:h,compiled:{html:h,ampHtml:""}})),handleTestEmailModal:x(P,h=>X(h,e)),handleCloneEmail:x(c,h=>X(h,e)),handleShareEmail:x(o),handlePreviewEmail:x(i),handleLivePreviewEmail:x(S)}}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 Ee(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},ju=a.createIdentifier$1("DataController"),Uu=a.createIdentifier$1("DataEvents");function Ls(e){return e.getOrCreateInstance(ju,()=>{const t=new bu(e);return e.getInstance(a.DISPOSABLE_ID)?.addDisposable(t),t})}function Ns(e){return e.getOrCreateInstance(Uu,()=>new Bu(e))}var Hu=a.createIdentifier$1("plugin.startupShow");function $u(e){const t=Ls(e),n=Ns(e),r=e.getInstance(a.OPTIONS_SOURCE_ID),s=e.getInstance(a.DISPOSABLE_ID),o={current:Promise.resolve()};e.inject(Hu,o);const i=r?.watch(l=>{l&&n.setOptions(l)}),c=r?.select(l=>l?.content).watch(l=>{l!==void 0&&(H(z.showStart),o.current=(async()=>{try{await t.show(l)}catch{}finally{H(z.showEnd)}})())});i&&s?.addDisposable(i),c&&s?.addDisposable(c)}function Gu(e){const t=Ls(e);return{...Ns(e).get(),show(n){return H(z.showStart),t.show(n).finally(()=>H(z.showEnd))},save(){return t.save()}}}function Im(e){return e}var Vu=[{name:"rest.client",setup:qd},{name:"auth.oauth",setup:a.provideOAuth},{name:"rest.identityHeaders",setup:Hd},{name:"lifetime.destroyable",provides:[Nt],setup:Vc},{name:"appInit",provides:[a.APP_ID,at],setup:Yo},{name:"config",provides:[a.CONFIG_SOURCE_ID],setup:$c},{name:"email.documents",setup:ld},{name:"show.initPipeline",provides:[a.INIT_PIPELINE_ID],setup:zd},{name:"show",setup:$u},{name:"locale.service",provides:[Ce],setup:Fd},{name:"locale.fromConfig",awaits:{services:[a.CONFIG_SOURCE_ID,Ce]},setup:Bd},{name:"canvas.early",setup:$l},{name:"canvas.previewSettings",setup:Xl},{name:"canvas.sandboxExtensions",setup:Ql},{name:"canvas.headerSync",provides:[Gr],setup:Yl},{name:"canvas.ampSync",setup:va},{name:"canvas.moduleBridge",setup:Va},{name:"canvas.port",setup:Pa},{name:"canvas.images",setup:Aa},{name:"canvas.edits",setup:wl},{name:"canvas.blockContent",setup:El},{name:"canvas.sandboxFill",provides:[It],setup:hc},{name:"canvas.reactions",setup:jl}],Yu=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function qu(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 zu(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 Ms(e){const t=qu(e),n=[],r=new Set,s=[],o=new Set,i=c=>{if(!r.has(c)){if(o.has(c)){const l=s.indexOf(c);throw new Yu([...s.slice(l),c].map(u=>u.name))}o.add(c),s.push(c);for(const l of zu(c,t))i(l);s.pop(),o.delete(c),r.add(c),n.push(c)}};for(const c of e)i(c);return n}var xs;function Wt(e){const t=e.getInstance(a.OPTIONS_SOURCE_ID);if(t)return t;e.getInstance(a.DISPOSABLE_ID)||e.inject(a.DISPOSABLE_ID,new a.Disposable);const n=pe();e.inject(a.OPTIONS_SOURCE_ID,n),xs??=Ms(Vu);for(const r of xs)r.setup(e);return n}function Wu(e){}var Ku=[{name:"save.previewFollow",setup:Wu}],ks=a.createIdentifier$1("plugin.lateUnitsInstalled");function Xu(e){if(!e.getInstance(ks)){e.inject(ks,!0);for(const t of Ms(Ku))t.setup(e)}}function Ju(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function Qu(e){if(!e)return;const t=a.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 Zu=a.defineMixin(e=>{let t,n,r;return{async setOptions(s){const o=r!==s.getAuthToken,i=!a.deepEqual(t,s.user),c=n!==s.project;if(r=s.getAuthToken,t=s.user,n=s.project,!(!e.getInstance(a.SECURITY_MODULE_ID)||!s.getAuthToken)&&!(!o&&!i&&!c))try{const l=await s.getAuthToken(s.user,s.project);e.inject(a.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(l||""));const u=Qu(l);if(!u)return;e.inject(a.STANDALONE_PROJECT_ID,u);const d=e.getInstance(a.APP_ID),p=d?await d.catch(()=>{}):void 0;e.inject(a.APP_ID,Promise.resolve(Ju(u,p)))}catch{}}}});function ef(e,t){if(e.getInstance(a.STANDALONE_FILE_PROXY_REGISTERED_ID))return;e.inject(a.STANDALONE_FILE_PROXY_REGISTERED_ID,!0);const n=a.getEvent(e,a.events.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}function tf(e){e.getInstance(a.STANDALONE_ACTIVATED_ID)||e.inject(a.SECURITY_MODULE_ID,void 0)}function Ze(e){return String(e.standaloneKey||"").trim()||void 0}function nf(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function Kt(e){return nf(e)?!!Ze(e):!1}function et(e){return!!Ze(e)&&!Kt(e)}var rf=a.defineMixin(e=>{let t,n=!1;return{setOptions(r){const s=n;if(n=!0,!et(r)){t&&(tf(e),Kt(r)),t=void 0;return}const o=Ze(r);if(!o||t===o&&e.getInstance(a.SECURITY_MODULE_ID))return;t=o,e.inject(a.SECURITY_MODULE_ID,o);const i=e.getInstance(a.DISPOSABLE_ID);i&&ef(e,i)}}}),sf=a.defineMixin(e=>{const t=e.getInstance(a.DISPOSABLE_ID),n=a.getEvent(e,a.APP_LOAD_EVENT_ID),r=x(n),s=t.addDisposable(new Ee(r));return{setOptions({handleLoad:o}){s.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}}),of=a.defineMixin(e=>{const t=e.getInstance(a.DISPOSABLE_ID),n=t.addDisposable(new a.AsyncEmitter),r=t.addDisposable(new a.AsyncEmitter),s=a.getEmitter(e,a.CONFIG_CHANGED_EVENT_ID),o=x(n.event),i=x(r.event),c=x(s.event),l=t.addDisposable(new Ee(o)),u=t.addDisposable(new Ee(i)),d=t.addDisposable(new Ee(c));return{instance:{handleSetOptions:o,handleOptionsChanged:i,handleConfigChanged:c},async setOptions(p){l.setListener(p.handleSetOptions),u.setListener(p.handleOptionsChanged),d.setListener(p.handleConfigChanged),await n.fire(p),await r.fire(p)},dispose(){}}}),Xt,Fs="core";function af(){const e=__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Fs],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function lf(e){const t=__useblocks__?.require?.warm;return typeof t!="function"?De().then(()=>{}):t([Fs],e)}function De(){return Xt===void 0&&(Xt=af().then(e=>(_e()&&e.installDiagnostics().catch(t=>{}),e))),Xt}var Jt=null,Qt=null;async function cf(e){typeof e?.prefetch=="function"&&await e.prefetch()}function Zt(){return Jt||(Jt=De().then(()=>{})),Jt}function Bs(e){return Qt||(Qt=cf(e)),Qt}function df(){return Bs(typeof __useblocks__<"u"?__useblocks__:void 0)}function uf(e){return Promise.all([Zt(),Bs(e)]).then(()=>{})}function ff(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function js(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>lf(t?{priority:t}:void 0)).then(()=>n?Zt():void 0).catch(()=>{})}function pf(e){const t=ff(e);if(t==="eager")js(e);else if(t==="idle"){const n=()=>js(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var Us="PluginRegistry";function mf(e=a.resolveContainer()){return e.getOrCreateInstance(Us,()=>new Ao)}var Hs=new Co(()=>mf()),hf=a.defineMixin(e=>{let t;function n(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(r){const s=e.getInstance(a.INSTANCE_ID),o=e.getInstance(Us);t||(t=new To(s,o,{ensureHostRuntimeReady:df}),e.inject(a.PLUGIN_COLLECTION_ID,t));const i=r?.plugins||[];s&&await t.setPlugins(i)},instance:{use(r){return typeof r=="function"?n().useByCtor(r):n().useByKey(r)},useAsync(r){return n().useAsync(r)},waitPlugin(r){return n().waitFor(r)}},dispose(){t?.dispose(),t=void 0}}}),$s=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}},gf=a.createIdentifier$1("ELEMENT_INSERT_HTML_PIPELINE"),Ef=a.createIdentifier$1("BLOCK_INSERT_HTML_PIPELINE"),bf="application_block_inserted",vf=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Ef,()=>new $s).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.MessageService),s=n?e.bind(n):e;return r.addListener(bf,s,t)}},_f=a.createIdentifier$1("ComponentRegistry"),Gs;function Re(e,t=_f){const n=a.DependencyResolver.getInstance(t);if(n)return n;if(!Gs)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return a.DependencyResolver.getOrCreateInstance(t,Gs)}var yf=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=this._container.addService(a.ATOMS_HANDLERS_ID,{execute:n=>{t.dispose(),e(n.value.map(r=>({name:r.name,html:r.html})))}})})}update(e,t){const n=this._container,r=Re(n);return n.addService(a.ATOMS_HANDLERS_ID,{execute:s=>{const o=s.value.find(i=>i.name===e);if(o){const{icon:i,title:c,fallbackTooltip:l,...u}=t;i&&(o.icon=r.getReactNode(i)),c&&(o.title=r.getReactNode(c)),l&&(o.fallbackTooltip=r.getReactNode(l)),Object.assign(o,u)}}})}delete(e){this._container.addService(a.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,r=Re(n);return n.addService(a.ATOMS_HANDLERS_ID,{execute:s=>{s.value.splice(t??s.value.length,0,{...e,title:r.getReactNode(e.title),icon:r.getReactNode(e.icon),fallbackTooltip:r.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(gf,()=>new $s).add(e,t??0,n)}handleInject(e,t,n){return a.getEmitter$1(this._container,a.HANDLE_ATOM_INSERT_ID).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Sf=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.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 wf(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}var If=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=a.getEmitter$1(t,a.MODAL_SHOW_EVENT),this._closeModalEmitter=a.getEmitter$1(t,a.MODAL_CLOSE_EVENT),this._updateModalEmitter=a.getEmitter$1(t,a.MODAL_UPDATE_EVENT)}get _container(){return this._context.container}show(e){const t=Re(this._container),n=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,r=e.modalProps;return this._showModalEmitter.fire({...e,content:t.getReactNode(e.content),title:t.getReactNode(e.title),id:n,modalProps:r?{...r,footer:t.getReactNode(r.footer),okText:t.getReactNode(r.okText),cancelText:t.getReactNode(r.cancelText),closeIcon:t.getReactNode(r.closeIcon)}:void 0}),n}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=Re(this._container),r=t.modalProps;this._updateModalEmitter.fire(wf({...t,content:n.getReactNode(t.content),title:n.getReactNode(t.title),id:e,modalProps:r?{...r,footer:n.getReactNode(r.footer),okText:n.getReactNode(r.okText),cancelText:n.getReactNode(r.cancelText),closeIcon:n.getReactNode(r.closeIcon)}:void 0}))}},Tf=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{const s=()=>this._loadedDisposable.dispose(),o=()=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&s(),n())},i=c=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&s(),r(c))};this._resolveLoaded=o,this._rejectLoaded=i}),this.ready=new Promise((n,r)=>{const s=()=>this._loadedDisposable.dispose(),o=()=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&s(),n())},i=c=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&s(),r(c))};this._resolveReady=o,this._rejectReady=i})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady()}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},Af=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.MessageService)}_createScriptHandle(e,t){const n=this._messageService.addListener(a.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 Tf(t,n);return r}registerSandboxCSS(e){return this._container.addService(a.SANDBOX_EXTENSIONS_ID,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(a.SANDBOX_EXTENSIONS_ID,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(a.SANDBOX_EXTENSIONS_ID,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(a.SANDBOX_EXTENSIONS_ID,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},Cf=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function en(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&Cf.has(t)}function Vs(){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 tn(){return`__settingsPanel:${Vs()}`}function nn(e,t){return{type:e,props:t}}function Pf(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!en(e)}function Ys(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(en(t)){const r=tn();return n(e.add(r,t)),nn(r,{})}if(typeof t=="function"){const r=tn();return n(e.add(r,t)),nn(r,{})}if(Pf(t)){const r=t.type;if(typeof r=="string")return t;if(en(r)||typeof r=="function"){const s=tn();return n(e.add(s,r)),nn(s,t.props)}return t}return t}var Df=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=Re(this._container),n=i=>this._trackRegistration(i),r=Ys(t,e.content,n),s=e.advancedTabs?.map(i=>({...i,content:Ys(t,i.content,n)})),o=e.instanceKey??Vs();a.getEmitter$1(this._container,a.SETTINGS_PANEL_EVENT).fire({...e,content:r,advancedTabs:s,instanceKey:o,type:a.ADVANCED_SETTINGS_PANEL})}closeSettingsPanel(){this._clearPanelRegistrations(),a.getEmitter$1(this._container,a.SETTINGS_PANEL_EVENT).fire(null)}},qs={SandboxScriptApi:Af,ElementsApi:yf,BlocksApi:vf,MessageService:Sf,SettingsPanelApi:Df,ModalApi:If};function rn(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 c=s[o],l=r[o]??{};s[o]=Object.assign({},typeof c=="object"&&c!==null?c:l,i)}else s[o]=i;return s}var J={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}},Rf={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"},sn={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},zs={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},ve={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:J.border,borderRadius:J.borderRadius,textAlign:"center",padding:J.padding},Ws={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:J.padding},on={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:J.border,borderRadius:J.borderRadiusCards};function Of(e){return{...Rf,...e}}function Lf(e){return{...sn,...e,bold:e?.bold??sn.bold,italic:e?.italic??sn.italic}}function Nf(e){return{...zs,...e,underline:e?.underline??zs.underline}}function Mf(e){return{...ve,...e,bold:e?.bold??ve.bold,italic:e?.italic??ve.italic,border:{...ve.border,...e?.border},borderRadius:{...ve.borderRadius,...e?.borderRadius},padding:{...ve.padding,...e?.padding}}}function xf(e){return{...Ws,...e,padding:{...Ws.padding,...e?.padding}}}function kf(e){return{...on,...e,border:{...on.border,...e?.border},borderRadius:{...on.borderRadius,...e?.borderRadius}}}function an(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 Ks(e){let t={...a.COMMON_STYLES};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function ln(e){return{text:Of(e.text),headings:Lf(e.headings),links:Nf(e.links),buttons:Mf(e.buttons),block:xf(e.block),cards:kf(e.cards)}}var Xs=a.createIdentifier$1("EmailSettingsPort"),Ff=1e4,Js=class{_editor;_layoutSettingsChanged=new a.Emitter;_contentStylesChanged=new a.Emitter;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(Xs);if(!t)throw new Error("[extensions] настройки письма ещё не загружены — работа с UI начинается с init()");return t}_getCurrentLayoutSettings(){return an(this._settings().read())}_getCurrentContentStyles(){const e=ct(this._editor.container)?.current()?.get().attributes.common_styles;return ln(Ks(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(Xs),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(a.MESSAGE_SERVICE_ID,()=>new a.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===a.EVENT_TYPES.APPLICATION_EMAIL_SETTINGS_SET){const l=an(s?.settings),u=this._getLayoutSnapshot(l);u!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=u,this._layoutSettingsChanged.fire(l));return}if(o!==a.EVENT_TYPES.APPLICATION_COMMON_STYLES_UPDATE)return;const i=ln(r.data?.settings?.commonStyles??{...a.COMMON_STYLES}),c=this._getContentSnapshot(i);c!==this._prevContentSnapshot&&(this._prevContentSnapshot=c,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=an(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Ff){const t=ct(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=a.getEvent(r,a.events.ON_EMAIL_INIT_ID);return new Promise(o=>{let i=!1,c;const l=()=>{c&&(clearTimeout(c),c=void 0)},u=s(()=>{i||(i=!0,l(),u.dispose(),o())});c=setTimeout(()=>{i||(i=!0,u.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=ct(this._editor.container)?.current();if(!t)return;const n=Ks(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=rn(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:J.border,borderRadius:J.borderRadius,padding:J.padding})),e.block!==void 0&&(n.block=rn(n.block||{},e.block,["padding"],{padding:J.padding})),e.cards!==void 0&&(n.cards=rn(n.cards||{},e.cards,["border","borderRadius"],{border:J.border,borderRadius:J.borderRadiusCards}));const r=JSON.stringify(n);Ue(t,{common_styles:r}),this._settings().markAppearanceChanged();const s=ln(n);this._prevContentSnapshot=this._getContentSnapshot(s),this._contentStylesChanged.fire(s)}},Bf={...qs,EmailSettingsApi:Js},jf={...qs},Tm={...jf,EmailSettingsApi:Js},Uf={...Bf};function Hf(){Hs.addAll(Uf)}var $f=[a.defineMixin(()=>{Hf()}),sf,of,rf,a.JWTMixin,Zu,a.OAuthMixin];async function Gf(){return(await De()).asyncMixins}var Vf=hf,Yf=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let s;try{s=await Gf()}catch(i){throw e.failPendingWaits(i),i}t=s(e);const o=await e.getInstanceAsync(a.INSTANCE_ID);Object.assign(o,t.instance||{});for(const i of e.getInstance(a.LATE_SURFACE_LISTENERS_ID)??[])i()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},qf=a.combineMixins([...$f]);function cn(){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,c){const l=Symbol("subscription");return t||(n.set(l,{listener:o,priority:i,thisArg:c}),e&&r.set(l,e(o,i,c))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(o){s(),e=o;for(const[i,{listener:c,priority:l,thisArg:u}]of n)r.set(i,o(c,l,u))},dispose(){t=!0,s(),n.clear(),e=void 0}}}function zf(e){const t=cn(),n=cn(),r=cn();return e.getInstance(a.DISPOSABLE_ID)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(Yt).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(Yt);if(!o)throw new Error("[plugin] notify() вызван до загрузки редактора");o.notify(s)}}}var Wf=[Yc,Gu,zf];function Kf(e,t=Wf){const n=Wt(e);Xu(e);const r=qf(e),s=Vf(e),o=Yf(e),i={...r.instance,...s.instance,...o.instance};for(const l of t)Object.assign(i,l(e));let c=!0;return{instance:i,async setOptions(l){await r.setOptions(l);const u=c&&n.get()===l;c=!1,u||n.set(l),await s.setOptions(l),await o.setOptions(l)}}}var Xf=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]}},Jf="editor-runtime.react.copies",dn=8;function Oe(e){return e&&typeof e=="object"?e:void 0}function Qs(e){const t=Oe(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=Oe(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function Qf(e){const t=Oe(e),n=t&&typeof t.version=="string"?t.version:void 0,r=Oe(t?.default),s=r&&typeof r.version=="string"?r.version:void 0;return n??s??"unknown"}function Zf(e,t,n){return e.package===t&&e.version===n}function ep({ourReact:e,entries:t,packageName:n,version:r}){const s=Qs(e);if(!s||!Array.isArray(t))return[];const o=[],i=new Set;for(const c of t){const l=Oe(c);if(!l||!Zf(l,n,r))continue;const u=Qs(l.react);!u||u===s||i.has(u)||(i.add(u),o.push({package:n,version:r,reactVersion:Qf(l.react),react:l.react}))}return o}function tp({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,dn))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>dn&&n.push(` …and ${t.length-dn} 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(`
2129
+ `)}var Zs=new Set;function np({packageName:e="useblocks",version:t="1.1.85-dev.8",log:n=r=>{}}={}){const r=s=>{try{const o=globalThis[Symbol.for(Jf)],i=ep({ourReact:s,entries:o,packageName:e,version:t}).filter(c=>!Zs.has(c.react));if(!i.length)return;i.forEach(c=>Zs.add(c.react)),n(tp({packageName:e,copies:i}))}catch{}};try{const s=st()?.modules?.React;if(s&&typeof s.then=="function"){s.then(r,()=>{});return}r(s)}catch{}}async function rp(e,t,n){a.throwIfAborted(e.signal);const r=t??a.DependencyResolver.createChild();Wt(r);const s=r.getInstance(a.DISPOSABLE_ID);async function o(){r.inject(a.COOKIE_MANAGER_ID,new Xf),np();const i=Kf(r),c={...i.instance,container:r,async reset(l){if(a.throwIfAborted(l.signal),s.isDisposed())throw ot();return await i.setOptions(l),c}};r.inject(a.INSTANCE_ID,c);try{if(n?.onInstance?.(c),await i.setOptions(e),a.throwIfAborted(e.signal),s.isDisposed()||await r.getInstance(a.PLUGIN_COLLECTION_ID)?.activate(),e.devTools)try{const l=r.getInstance(a.PLUGIN_COLLECTION_ID);l&&await(await De()).initDevTools(r,l)}catch{}return a.throwIfAborted(e.signal),a.getEmitter(r,a.APP_LOAD_EVENT_ID).fire(c),c}catch(l){throw s.dispose(),l}}try{return await a.raceWithAbortSignal(o(),e.signal)}catch(i){throw s.isDisposed()||s.dispose(),i}}var Le=new WeakMap;function sp(e){return e?Le.get(e):void 0}function eo(e){try{e.getInstance(a.DISPOSABLE_ID)?.dispose()}catch{}try{e.dispose()}catch{}}function op(e,t){if(!e)return;const n=Le.get(e);n&&n!==t&&eo(n),Le.set(e,t)}function ip(e,t){e&&Le.get(e)===t&&Le.delete(e)}function ap(e){const t=a.DependencyResolver.createChild();return et(e)&&t.inject(a.SECURITY_MODULE_ID,Ze(e)),t}var Ne=new WeakMap,lp="data-useblocks-config-styles";function cp(e){return typeof e=="string"?e.trim():""}function to(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function dp(e,t,n){if(!e||typeof document>"u")return null;const r=cp(t),s=Ne.get(e),o=n||e;if(!r)return s&&(s.remove(),Ne.delete(e)),null;if(s)return s.textContent!==r&&(s.textContent=r),(s.parentNode!==o||s!==o.firstChild)&&to(o,s),s;const i=document.createElement("style");return i.setAttribute(lp,"true"),i.textContent=r,to(o,i),Ne.set(e,i),i}function up(e){if(!e)return;const t=Ne.get(e);t&&(t.remove(),Ne.delete(e))}var Am=!1;function no(){return!1}var Cm=28,fp=`
2130
2130
  .blocks-app-initial-spinner-wrapper {
2131
2131
  width: 100%;
2132
2132
  height: 100%;
@@ -2155,11 +2155,11 @@ __useblocks__.define("useblocks.js",["require","exports","module","static/umd/ad
2155
2155
  100% {
2156
2156
  transform: rotate(360deg);
2157
2157
  }
2158
- }`;function op(){return()=>{}}function ip(e,t){if(!Ws()||!e||typeof document>"u")return op();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=sp,document.head?.appendChild(s),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),s.remove())}}function ap(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function lp({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 c=o().catch(l=>{throw n.has(s)||(n.add(s),r(l)),ap(l)||t.delete(s),l});return t.set(s,c),c},clear(){t.clear(),n.clear()},size(){return t.size}}}var cn=lp();function Xs(){cn.clear()}a.setApiOriginFailoverHook(()=>cn.clear());var Js=new WeakMap,Qs=new WeakMap;function cp(e,t){let n=Qs.get(t);n||(n=new Map,Qs.set(t,n));const r=n.get(e);if(r!==void 0)return r;const s=t.getInstance(a.CUSTOM_FETCH_ID),o=a.createTransport({baseUrl:e,customFetch:s?.execute??fetch},t);return n.set(e,o),o}function dn(e){return a.resolveExplicitApiBaseUrl(e)}function dp(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function up(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function fp(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}function pp(e,t){return async({baseUrl:n})=>{const r=dn(n);if(!r)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json"});if(e.getAuthToken&&!await fp(e))throw up();const o=t();if(!o)throw new Error("[Loader] appInit requires the instance container");const i=new Tn(cp(r,o)),c={headers:Object.fromEntries(s.entries()),credentials:"same-origin",failoverAttemptTimeout:zt(e)||void 0},l=await i.app_init_create({},c);if(!l.ok)throw dp(l.status,l.statusText);return l.data}}function mp(e){return JSON.stringify({baseUrl:dn(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function hp(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function gp(e){return t=>cn.run(mp(t),()=>(U("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>U("appInit:end",{kind:"network"}))))}function Ep(e,t){if(Qe(e)||!e.appInit&&!dn(e.baseUrl)||!hp(e))return e;const n=e.appInit??pp(e,t);let r=Js.get(n);return r||(r=gp(n),Js.set(n,r)),{...e,appInit:r}}var Zs=0;function bp(){return Zs}function vp(){Zs+=1,Xs()}var eo=new WeakMap,to=new WeakMap,_p=3e4;function yp(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function Sp(e,t){try{const n=a.decodeJwt(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+_p}function wp(e){const t=new Map,n=new Map;return async(r,s,o)=>{const i=yp(r,s);if(o)return n.delete(i),t.delete(i),Xs(),e(r,s,o);const c=n.get(i);if(c&&!t.has(i)){if(c.expiresAtMs>Date.now())return c.token;n.delete(i)}let l=t.get(i);return l===void 0&&(U("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,s,o)).then(u=>{const d=String(u||"").trim();return d&&n.set(i,{token:u,expiresAtMs:Sp(d,Date.now())}),u}).finally(()=>{U("authToken:end",{kind:"network"}),t.delete(i)}),t.set(i,l)),l}}function Ip(e){if(Qe(e))return e;const t=e.getAuthToken;if(!t)return e;let n=eo.get(t);const r=bp();return(!n||to.get(t)!==r)&&(n=wp(t),eo.set(t,n),to.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(s=>{}),{...e,getAuthToken:n}}var un=new WeakMap;function no(e){const t=(un.get(e)??0)+1;return un.set(e,t),t}function Tp(e,t){return un.get(e)===t}var Ap=new Set(["setConfig","updateConfig","show","save","getEmailSnapshot","getEmail","compileEmail","getBlocks","getEmailRevisions","getComments","validateCode","reset","useAsync"]),Cp=new Set(["setEmailMeta","setBlockMeta","notify"]),ro=new Map([["getConfig","await `ready` first"],["use","use `useAsync()` or await `ready` first"],["container","await `ready` first"],["undoRedoService","await `ready` first"]]);function so(e){if(/^handle[A-Z]/.test(e))return"event";if(Ap.has(e))return"async";if(Cp.has(e))return"queued";if(e==="getElement")return"element";if(e==="getCodeErrors")return"codeErrors";if(ro.has(e))return"notReady"}function Pp(e){return ro.get(e)??"await `ready` first"}function oo(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}function Dp(e,t){let n,r=0,s="pending",o,i,c;const l=new Set,u=[];let d,p;const m=new Promise((A,O)=>{d=A,p=O});m.catch(()=>{});const b=A=>n?.[A],y=A=>{const O=b(A.name);A.dispose||typeof O!="function"||(A.dispose=O(...A.args))},E=()=>l.forEach(y),g=()=>{for(const A of l)A.dispose?.(),A.dispose=void 0},v=()=>E(),_=()=>{c?.delete(v),c=void 0},w=()=>{g(),l.clear(),_(),u.length=0,n=void 0},P=()=>s==="failed"?o:st(),D=(A,O,x)=>{if(s==="failed"||s==="destroyed")throw P();const C=b(A);if(typeof C!="function")throw oo(A);return C.apply(x,O)},h=()=>s==="ready"?Promise.resolve():s==="pending"?m:Promise.reject(P()),I=(A,O)=>{if(s==="failed"||s==="destroyed")throw P();if(s==="ready"&&typeof b(A)!="function")throw oo(A);const x={name:A,args:O};return l.add(x),y(x),()=>{l.delete(x),x.dispose?.(),x.dispose=void 0}},f=()=>{const A=e.element;return A!==void 0&&typeof A!="string"?A:void 0},S=new Proxy({},{get(A,O,x){if(typeof O!="string"||O==="then")return;const C=so(O);if(C==="event")return(...L)=>I(O,L);if(n&&O in n)return Reflect.get(n,O,x);switch(C){case"async":return(...L)=>h().then(()=>D(O,L,x));case"queued":return(...L)=>{if(s!=="pending")return D(O,L,x);u.push({name:O,args:L})};case"element":return f;case"codeErrors":return()=>[];case"notReady":throw new Error(`[emailmaker] \`${O}\` is not available before the editor is ready: ${Pp(O)}`);default:return O in Object.prototype?Reflect.get(Object.prototype,O,x):void 0}},has(A,O){return typeof O!="string"?!1:n!==void 0&&O in n||so(O)!==void 0}}),T=Object.create(S);return Object.defineProperty(T,"ready",{get:()=>i,enumerable:!0}),Object.defineProperty(T,"destroy",{enumerable:!0,value:()=>{if(s==="destroyed"||s==="failed")return;if(s==="pending"){s="destroyed",i?.catch(()=>{}),t(a.createAbortError("[emailmaker] editor was destroyed before it was ready"));return}const A=n!==void 0&&Tp(n,r),O=n;s="destroyed",w(),A&&O?.destroy()}}),{handle:T,bind:A=>{n!==A&&(g(),_(),n=A,E(),s==="pending"&&(c=A.container.getOrCreateInstance(a.LATE_SURFACE_LISTENERS_ID,()=>new Set),c.add(v)))},settle:()=>{const A=n;if(s==="destroyed"){w(),A&&(no(A),A.destroy());const O=a.createAbortError("[emailmaker] editor was destroyed before it was ready");throw o=O,p(O),O}A&&(r=no(A)),s="ready",_();for(const O of u.splice(0))try{D(O.name,O.args,T)}catch(x){queueMicrotask(()=>{throw x})}d()},fail:A=>{s!=="destroyed"&&(s="failed",o=A),w(),p(A)},setReady:A=>{i=A}}}var fn="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function Rp(){return a.createAbortError(fn)}function io(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===fn}function Op(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 c=e.parentNode;for(;c;)s.observe(c,{childList:!0}),c=c.parentNode}function Lp(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 Op(n,()=>{n.id,o.abort(Rp())},s),a.composeAbortSignals(r,o.signal)}var pn="Superseded by newer init() on the same mount element";function ao(){return a.createAbortError(pn)}function lo(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===pn}var Ze=new Map,et=new WeakMap;function Np(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function Mp(e){if(!e)return{release:()=>{}};const t=Np(e);et.get(e)?.abort(ao()),t&&Ze.get(t)?.abort(ao());const n=new AbortController;return et.set(e,n),t&&Ze.set(t,n),{signal:n.signal,release:()=>{et.get(e)===n&&et.delete(e),t&&Ze.get(t)===n&&Ze.delete(t)}}}var xp=bn({FileManagerApiError:()=>kp}),kp=class po 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,po)}},Fp=bn({mapHttpStatusToErrorCode:()=>a.mapHttpStatusToErrorCode});function Bp(e,t){return{...e,element:t}}function mn(){return()=>{}}function jp(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?mn():(np(t,e.config?.styles,t),()=>{rp(t)})}function Up(e){if(!Ws()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:mn()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:mn()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=ip(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function co(e){return e instanceof DOMException&&e.name==="AbortError"}function uo(e){try{e.destroy()}catch{}}function hn(e,...t){const n=a.ELEMENT_MAP.get(e);t.some(r=>r!==void 0&&r===n)&&a.ELEMENT_MAP.delete(e)}var Hp="1.1.85-dev.6";async function $p(e){await nf(typeof __useblocks__<"u"?__useblocks__:void 0)}async function Gp(e){return fo(e).ready}function fo(e){U(z.initStart);const t=new AbortController,n=a.composeAbortSignals(e.signal,t.signal),r=Dp(e,o=>t.abort(o)),s=Vp({...e,signal:n},r.bind).then(()=>(U(z.initEnd),r.settle(),r.handle),o=>{throw r.fail(o),o});return r.setReady(s),r.handle}async function Vp(e,t){a.throwIfAborted(e.signal);const n=new a.Disposable;let r;try{const s=await a.waitForElement(e.element,n,e.signal),o=Lp({hostElementOption:e.element,resolvedElement:s,externalSignal:e.signal,disposable:n}),i=Mp(s);r=i.release;const c=a.composeAbortSignals(o,i.signal);return a.throwIfAborted(c),await a.raceWithAbortSignal(Yp(e,s,t,c),c)}finally{r?.(),n.dispose()}}async function Yp(e,t,n,r){a.throwIfAborted(r),vp();const s=Bp(e,t),o=Ip(s);let i;const c=Ep(o,()=>i),l=r!=null?{...c,signal:r}:c;if(t){const b=a.ELEMENT_MAP.get(t);if(b){let y;try{y=await b,a.throwIfAborted(r)}catch(E){if(a.throwIfAborted(r),hn(t,b),co(E))throw E;y=void 0}if(y)if(y.getElement()===t)try{return i=Xf(t),n(y),await y.reset(l)}catch(E){if(a.throwIfAborted(r),lo(E)||io(E)||co(E)&&r?.aborted)throw E;hn(t,b,y),uo(y)}else hn(t,b,y),uo(y)}}a.throwIfAborted(r);const u=jp(c),d=Up(c),p=r!=null?{...d.options,signal:r}:d.options;let m;try{i=Zf(p),Jf(t,i),qt(i).set(p),await Jt(),U(z.coreReady),a.throwIfAborted(r),a.throwIfAborted(r),m=Wf(p,i,{onInstance:n}),t&&a.ELEMENT_MAP.set(t,m);const b=await m;if(r?.aborted&&(b.destroy(),a.throwIfAborted(r)),t)if(a.ELEMENT_MAP.get(t)===m)a.ELEMENT_MAP.set(t,b);else throw b.destroy(),a.throwIfAborted(r),a.createAbortError(r?.reason);return b}catch(b){throw u(),d.cleanup(),i&&(zs(i),Qf(t,i)),t&&m&&a.ELEMENT_MAP.get(t)===m&&a.ELEMENT_MAP.delete(t),b}}async function qp(e){return(await De()).parseAMP(e)}typeof window<"u"&&(_e()&&Mo(),sf(typeof __useblocks__<"u"?__useblocks__:void 0)),K.ELEMENT_DETACHED_ABORT_MESSAGE=fn,K.SUPERSEDED_INIT_ABORT_MESSAGE=pn,K.create=fo,Object.defineProperty(K,"errors",{enumerable:!0,get:function(){return xp}}),Object.defineProperty(K,"helpers",{enumerable:!0,get:function(){return Fp}}),K.init=Gp,K.isElementDetachedError=io,K.isSupersededInitError=lo,K.parseAMP=qp,K.pluginRegistry=Ns,K.preload=$p,K.version=Hp});
2158
+ }`;function pp(){return()=>{}}function mp(e,t){if(!no()||!e||typeof document>"u")return pp();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=fp,document.head?.appendChild(s),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),s.remove())}}function hp(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function gp({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 c=o().catch(l=>{throw n.has(s)||(n.add(s),r(l)),hp(l)||t.delete(s),l});return t.set(s,c),c},clear(){t.clear(),n.clear()},size(){return t.size}}}var un=gp();function ro(){un.clear()}a.setApiOriginFailoverHook(()=>un.clear());var so=new WeakMap,oo=new WeakMap;function Ep(e,t){let n=oo.get(t);n||(n=new Map,oo.set(t,n));const r=n.get(e);if(r!==void 0)return r;const s=t.getInstance(a.CUSTOM_FETCH_ID),o=a.createTransport({baseUrl:e,customFetch:s?.execute??fetch},t);return n.set(e,o),o}function fn(e){return a.resolveExplicitApiBaseUrl(e)}function bp(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function vp(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function _p(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 pn=new WeakMap;function mn(e,t){pn.set(e,t)}function yp(e){return pn.get(e)}function Sp(e,t){return async({baseUrl:n})=>{const r=t();if(!r)throw new Error("[Loader] appInit requires the instance container");const s=pn.get(r)??e,o=fn(n);if(!o)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const i=new Headers({Accept:"application/json"});if(s.getAuthToken&&!await _p(s))throw vp();const c=new Ln(Ep(o,r)),l={headers:Object.fromEntries(i.entries()),credentials:"same-origin",failoverAttemptTimeout:Kt(s)||void 0},u=await c.app_init_create({},l);if(!u.ok)throw bp(u.status,u.statusText);return u.data}}function wp(e){return JSON.stringify({baseUrl:fn(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function Ip(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function Tp(e){return t=>un.run(wp(t),()=>(H("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>H("appInit:end",{kind:"network"}))))}function Ap(e,t){if(et(e)||!e.appInit&&!fn(e.baseUrl)||!Ip(e))return e;const n=e.appInit??Sp(e,t);let r=so.get(n);return r||(r=Tp(n),so.set(n,r)),{...e,appInit:r}}var io=0;function Cp(){return io}function Pp(){io+=1,ro()}var ao=new WeakMap,lo=new WeakMap,Dp=3e4;function Rp(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function Op(e,t){try{const n=a.decodeJwt(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+Dp}function Lp(e){const t=new Map,n=new Map;return async(r,s,o)=>{const i=Rp(r,s);if(o)return n.delete(i),t.delete(i),ro(),e(r,s,o);const c=n.get(i);if(c&&!t.has(i)){if(c.expiresAtMs>Date.now())return c.token;n.delete(i)}let l=t.get(i);return l===void 0&&(H("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,s,o)).then(u=>{const d=String(u||"").trim();return d&&n.set(i,{token:u,expiresAtMs:Op(d,Date.now())}),u}).finally(()=>{H("authToken:end",{kind:"network"}),t.delete(i)}),t.set(i,l)),l}}function Np(e){if(et(e))return e;const t=e.getAuthToken;if(!t)return e;let n=ao.get(t);const r=Cp();return(!n||lo.get(t)!==r)&&(n=Lp(t),ao.set(t,n),lo.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(s=>{}),{...e,getAuthToken:n}}var Me=new WeakMap,hn=new WeakMap;function co(e,t){Me.set(e,t),hn.get(e)?.forEach(n=>n())}function Mp(e,t){const n=hn.get(e)??new Set;return n.add(t),hn.set(e,n),()=>n.delete(t)}function gn(e){const t=(Me.get(e)??0)+1;return co(e,t),t}var En=new WeakMap;function xp(e,t){const n=En.get(e)??new Set;n.add(t),En.set(e,n)}function kp(e,t,n){return Me.get(e)!==t?!0:En.get(e)?.has(n)?!1:(co(e,n),!0)}function bn(e,t){return Me.get(e)===t}function uo(e){return Me.get(e)??0}var Fp=new Set(["setConfig","updateConfig","show","save","getEmailSnapshot","getEmail","compileEmail","getBlocks","getEmailRevisions","getComments","validateCode","reset","useAsync"]),Bp=new Set(["setEmailMeta","setBlockMeta","notify"]),fo=new Map([["getConfig","await `ready` first"],["use","use `useAsync()` or await `ready` first"],["container","await `ready` first"],["undoRedoService","await `ready` first"]]);function po(e){if(/^handle[A-Z]/.test(e))return"event";if(Fp.has(e))return"async";if(Bp.has(e))return"queued";if(e==="getElement")return"element";if(e==="getCodeErrors")return"codeErrors";if(fo.has(e))return"notReady"}function jp(e){return fo.get(e)??"await `ready` first"}function mo(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}function Up(e,t){let n,r=0,s,o="pending",i,c,l,u;const d=new Set,p=[];let m,b;const S=new Promise((T,O)=>{m=T,b=O});S.catch(()=>{});const E=T=>n?.[T],g=()=>o==="pending"||n!==void 0&&bn(n,r),v=T=>{const O=E(T.name);T.dispose||typeof O!="function"||!g()||(T.dispose=O(...T.args))},_=()=>d.forEach(v),w=()=>{for(const T of d)T.dispose?.(),T.dispose=void 0},P=()=>_(),D=()=>{o==="ready"&&(g()?_():w())},h=()=>{l?.delete(P),l=void 0},I=()=>{u?.(),u=void 0,w(),d.clear(),h(),p.length=0,n=void 0},f=()=>o==="failed"?i:ot(),y=(T,O,N)=>{if(o==="failed"||o==="destroyed")throw f();const F=E(T);if(typeof F!="function")throw mo(T);return F.apply(N,O)},A=()=>o==="ready"?Promise.resolve():o==="pending"?S:Promise.reject(f()),L=(T,O)=>{if(o==="failed"||o==="destroyed")throw f();if(o==="ready"&&typeof E(T)!="function")throw mo(T);const N={name:T,args:O};return d.add(N),v(N),()=>{d.delete(N),N.dispose?.(),N.dispose=void 0}},k=()=>{const T=e.element;return T!==void 0&&typeof T!="string"?T:void 0},q=new Proxy({},{get(T,O,N){if(typeof O!="string"||O==="then")return;const F=po(O);if(F==="event")return(...W)=>L(O,W);if(n&&O in n)return Reflect.get(n,O,N);switch(F){case"async":return(...W)=>A().then(()=>y(O,W,N));case"queued":return(...W)=>{if(o!=="pending")return y(O,W,N);p.push({name:O,args:W})};case"element":return k;case"codeErrors":return()=>[];case"notReady":throw new Error(`[emailmaker] \`${O}\` is not available before the editor is ready: ${jp(O)}`);default:return O in Object.prototype?Reflect.get(Object.prototype,O,N):void 0}},has(T,O){return typeof O!="string"?!1:n!==void 0&&O in n||po(O)!==void 0}}),C=Object.create(q);return Object.defineProperty(C,"ready",{get:()=>c,enumerable:!0}),Object.defineProperty(C,"destroy",{enumerable:!0,value:()=>{if(o==="destroyed"||o==="failed")return;if(o==="pending"){const N=s!==void 0&&n!==void 0&&bn(n,r),F=n;o="destroyed",c?.catch(()=>{}),t(a.createAbortError("[emailmaker] editor was destroyed before it was ready")),N&&(I(),F?.destroy());return}const T=n!==void 0&&bn(n,r),O=n;o="destroyed",I(),T?O?.destroy():O&&xp(O,r)}}),{handle:C,bind:(T,O)=>{O?.adopt&&o==="pending"&&s===void 0?(s=uo(T),r=gn(T)):!O?.adopt&&n!==T&&(s=void 0),n!==T&&(w(),h(),n=T,_(),o==="pending"&&(l=T.container.getOrCreateInstance(a.LATE_SURFACE_LISTENERS_ID,()=>new Set),l.add(P)))},settle:()=>{const T=n;if(o==="destroyed"){I(),T&&(gn(T),T.destroy());const O=a.createAbortError("[emailmaker] editor was destroyed before it was ready");throw i=O,b(O),O}T&&s===void 0&&uo(T)===0&&(r=gn(T)),o="ready",T&&(u=Mp(T,D),D()),h();for(const O of p.splice(0))try{y(O.name,O.args,C)}catch(N){queueMicrotask(()=>{throw N})}m()},fail:T=>{o!=="destroyed"&&(o="failed",i=T,n&&s!==void 0&&!kp(n,r,s)&&n.destroy()),I(),b(T)},setReady:T=>{c=T}}}var vn="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function Hp(){return a.createAbortError(vn)}function ho(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===vn}function $p(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 c=e.parentNode;for(;c;)s.observe(c,{childList:!0}),c=c.parentNode}function Gp(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 $p(n,()=>{n.id,o.abort(Hp())},s),a.composeAbortSignals(r,o.signal)}var _n="Superseded by newer init() on the same mount element";function Vp(){return a.createAbortError(_n)}function go(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===_n}var xe=new Map,tt=new WeakMap;function Yp(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function qp(e){if(!e)return{previous:Promise.resolve(),release:()=>{}};const t=Yp(e);(t?xe.get(t):void 0)?.forEach(l=>{l.element!==e&&l.controller.abort(Vp())});const n=tt.get(e)??Promise.resolve();let r;const s=new Promise(l=>{r=l}),o=n.then(()=>s);tt.set(e,o),o.then(()=>{tt.get(e)===o&&tt.delete(e)});const i=new AbortController,c={element:e,controller:i};if(t){const l=xe.get(t)??new Set;l.add(c),xe.set(t,l)}return{signal:i.signal,previous:n,release:()=>{r();const l=t?xe.get(t):void 0;t&&l?.delete(c)&&l.size===0&&xe.delete(t)}}}var zp=Tn({FileManagerApiError:()=>Wp}),Wp=class vo 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,vo)}},Kp=Tn({mapHttpStatusToErrorCode:()=>a.mapHttpStatusToErrorCode});function Xp(e,t){return{...e,element:t}}function yn(){return()=>{}}function Jp(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?yn():(dp(t,e.config?.styles,t),()=>{up(t)})}function Qp(e){if(!no()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:yn()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:yn()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=mp(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function Zp(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function Eo(e){try{e.destroy()}catch{}}function Sn(e,...t){const n=a.ELEMENT_MAP.get(e);t.some(r=>r!==void 0&&r===n)&&a.ELEMENT_MAP.delete(e)}var em="1.1.85-dev.8";async function tm(e){await uf(typeof __useblocks__<"u"?__useblocks__:void 0)}async function nm(e){return bo(e).ready}function bo(e){H(z.initStart);const t=new AbortController,n=a.composeAbortSignals(e.signal,t.signal),r=Up(e,o=>t.abort(o)),s=rm({...e,signal:n},r.bind).then(()=>(H(z.initEnd),r.settle(),r.handle),o=>{throw r.fail(o),o});return r.setReady(s),r.handle}async function rm(e,t){a.throwIfAborted(e.signal);const n=new a.Disposable;let r,s;try{const o=await a.waitForElement(e.element,n,e.signal),i=Gp({hostElementOption:e.element,resolvedElement:o,externalSignal:e.signal,disposable:n}),c=qp(o);r=c.release;const l=a.composeAbortSignals(i,c.signal);return a.throwIfAborted(l),await a.raceWithAbortSignal(c.previous,l),s=sm(e,o,t,l),await a.raceWithAbortSignal(s,l)}finally{const o=r;s!==void 0&&o?s.then(o,o):o?.(),n.dispose()}}async function sm(e,t,n,r){a.throwIfAborted(r),Pp();const s=Xp(e,t),o=Np(s);let i;const c=Ap(o,()=>i),l=r!=null?{...c,signal:r}:c;if(t){const b=a.ELEMENT_MAP.get(t);if(b){let S;try{S=await b,a.throwIfAborted(r)}catch{a.throwIfAborted(r),Sn(t,b),S=void 0}if(S)if(S.getElement()===t){const E=sp(t);i=E;const g=E&&yp(E);try{E&&mn(E,c),n(S,{adopt:!0});const v=await S.reset(Zp(e,l));return a.ELEMENT_MAP.set(t,S),v}catch(v){if(E&&g&&mn(E,g),a.throwIfAborted(r),go(v)||ho(v)||a.isAbortError(v)&&r?.aborted)throw v;Sn(t,b,S),Eo(S)}}else Sn(t,b,S),Eo(S)}}a.throwIfAborted(r);const u=Jp(c),d=Qp(c),p=r!=null?{...d.options,signal:r}:d.options;let m;try{i=ap(p),op(t,i),mn(i,c),Wt(i).set(p),await Zt(),H(z.coreReady),a.throwIfAborted(r),a.throwIfAborted(r),m=rp(p,i,{onInstance:n}),t&&a.ELEMENT_MAP.set(t,m);const b=await m;if(r?.aborted&&(b.destroy(),a.throwIfAborted(r)),t)if(a.ELEMENT_MAP.get(t)===m)a.ELEMENT_MAP.set(t,b);else throw b.destroy(),a.throwIfAborted(r),a.createAbortError(r?.reason);return b}catch(b){throw u(),d.cleanup(),i&&(eo(i),ip(t,i)),t&&m&&a.ELEMENT_MAP.get(t)===m&&a.ELEMENT_MAP.delete(t),b}}async function om(e){return(await De()).parseAMP(e)}typeof window<"u"&&(_e()&&Uo(),pf(typeof __useblocks__<"u"?__useblocks__:void 0)),K.ELEMENT_DETACHED_ABORT_MESSAGE=vn,K.SUPERSEDED_INIT_ABORT_MESSAGE=_n,K.create=bo,Object.defineProperty(K,"errors",{enumerable:!0,get:function(){return zp}}),Object.defineProperty(K,"helpers",{enumerable:!0,get:function(){return Kp}}),K.init=nm,K.isElementDetachedError=ho,K.isSupersededInitError=go,K.parseAMP=om,K.pluginRegistry=Hs,K.preload=tm,K.version=em});
2159
2159
 
2160
2160
 
2161
2161
  // Возвращаем API из entry модуля
2162
2162
  return __useblocks__.syncRequire("useblocks.js");
2163
2163
  });
2164
2164
 
2165
- __useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/175b5b0f.js":[],"static/core/1bdeb37f.js":[],"static/core/23f020c5.js":[],"static/core/284b592e.js":[],"static/core/3a252a3c.js":["static/core/d2bb1c0d.js","static/core/5db1f013.js","static/core/9600caf9.js","static/core/d0eece8b.js","__delivery__/libs"],"static/core/3fd50a29.js":[],"static/core/48da14fd.js":[],"static/core/4c8d0155.js":[],"static/core/51a46897.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/5db1f013.js":["static/core/175b5b0f.js","__delivery__/libs"],"static/core/60aa31a3.js":[],"static/core/60f7aa8d.js":[],"static/core/6561b34a.js":[],"static/core/6741eb70.js":["__delivery__/libs"],"static/core/6a939bac.js":[],"static/core/6ff64eea.js":[],"static/core/740a4f32.js":[],"static/core/74c1d64b.js":["static/core/e2699a48.js"],"static/core/7b850506.js":[],"static/core/7d627bff.js":[],"static/core/7f91ed03.js":["static/core/e2699a48.js","static/core/6a939bac.js","static/core/c28968c1.js"],"static/core/8035d07f.js":[],"static/core/9600caf9.js":["static/core/5db1f013.js","__delivery__/libs"],"static/core/991b35ff.js":[],"static/core/9ea82ab5.js":["static/core/6a939bac.js"],"static/core/a5996860.js":["static/core/175b5b0f.js"],"static/core/ac50dfd1.js":[],"static/core/b6c5e3be.js":["static/core/9600caf9.js","static/core/6741eb70.js","__delivery__/libs","static/core/5db1f013.js"],"static/core/c28968c1.js":["static/core/6a939bac.js"],"static/core/d0eece8b.js":["static/core/6741eb70.js","__delivery__/libs"],"static/core/d2bb1c0d.js":[],"static/core/e2699a48.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/ec4827f1.js":[],"static/core/ec93b234.js":["static/core/175b5b0f.js","static/core/5db1f013.js","__delivery__/libs"],"static/core/fb2fe2db.js":[],"static/core/fc390885.js":[],"static/core/fdfb1e94.js":["static/core/d2bb1c0d.js","static/core/5db1f013.js","__delivery__/libs"],"static/monaco/editor.api-C9c1WLns.js":[],"monaco":["static/monaco/editor.api-C9c1WLns.js","static/monaco/lspLanguageFeatures-DY3n8M13.js"],"static/monaco/lspLanguageFeatures-DY3n8M13.js":["static/monaco/editor.api-C9c1WLns.js"],"useblocks.js":[],"static/umd/add4df98.js":[]},"bundles":{"static/core/6741eb70.js":["static/core/9281699f.js","static/core/41a7e33c.js","static/core/52b6b918.js","static/core/a669ca97.js"],"static/core/74c1d64b.js":["static/core/a71c4cd8.js"],"static/core/ec93b234.js":["static/core/4d436d7d.js"],"static/core/d0eece8b.js":["static/core/a73da823.js"],"static/core/b6c5e3be.js":["static/core/cfe2f3c5.js"],"core":["static/core/2ff39ddf.js","static/core/8782e9bb.js","static/core/10c6144f.js","static/core/cb7d16ff.js","static/core/68612347.js"]}});
2165
+ __useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/06d19668.js":["static/core/5db1f013.js","__delivery__/libs"],"static/core/13c7b13a.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/175b5b0f.js":[],"static/core/1afe0f9c.js":["static/core/ff43365e.js","static/core/5db1f013.js","__delivery__/libs"],"static/core/28160edc.js":[],"static/core/3d7934fb.js":[],"static/core/3df10afa.js":["__delivery__/libs"],"static/core/3fd50a29.js":[],"static/core/41028939.js":[],"static/core/45eb9af1.js":["static/core/41028939.js","static/core/3d7934fb.js","static/core/799f4d8e.js"],"static/core/48a8ba9d.js":[],"static/core/48da14fd.js":[],"static/core/49a8dc9c.js":[],"static/core/4c8d0155.js":[],"static/core/59cfe4a0.js":[],"static/core/5db1f013.js":["static/core/175b5b0f.js","__delivery__/libs"],"static/core/60aa31a3.js":[],"static/core/6561b34a.js":[],"static/core/778aee63.js":[],"static/core/799f4d8e.js":["static/core/3d7934fb.js"],"static/core/7b850506.js":[],"static/core/7c047ede.js":["static/core/3df10afa.js","__delivery__/libs"],"static/core/982730aa.js":["static/core/3d7934fb.js"],"static/core/a46eae76.js":[],"static/core/a5996860.js":["static/core/175b5b0f.js"],"static/core/ac50dfd1.js":[],"static/core/b165db74.js":[],"static/core/cb42ad65.js":[],"static/core/db82c42b.js":[],"static/core/df189a9d.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/ec93b234.js":["static/core/175b5b0f.js","static/core/5db1f013.js","__delivery__/libs"],"static/core/f1478faf.js":["static/core/41028939.js"],"static/core/f1498d3c.js":[],"static/core/f8d889a1.js":["static/core/06d19668.js","static/core/3df10afa.js","__delivery__/libs","static/core/5db1f013.js"],"static/core/fa60c7fb.js":["static/core/ff43365e.js","static/core/5db1f013.js","static/core/06d19668.js","static/core/7c047ede.js","__delivery__/libs"],"static/core/fb2fe2db.js":[],"static/core/ff43365e.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/993c2c90.js":[]},"bundles":{"static/core/3df10afa.js":["static/core/5cf8c192.js","static/core/4cda85e3.js","static/core/b6d27bcf.js","static/core/e02ef34c.js"],"static/core/f1478faf.js":["static/core/a71c4cd8.js"],"static/core/ec93b234.js":["static/core/4d436d7d.js"],"static/core/7c047ede.js":["static/core/a73da823.js"],"static/core/f8d889a1.js":["static/core/94d4ae45.js"],"core":["static/core/2ff39ddf.js","static/core/ca13058e.js","static/core/b2b19022.js","static/core/f72a1b7d.js","static/core/4d23db03.js"]}});