useblocks 1.1.85-dev.6 → 1.1.85-dev.7

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.
@@ -92,9 +92,9 @@ ${l}`}function R(t,e=!0){const i=f.decodeFileNameFromPath(t);return e?T(i):i}fun
92
92
  `).trim()}catch{return""}}Object.defineProperty(b,"changeHtml",{enumerable:!0,get:function(){return D}}),Object.defineProperty(b,"extractDocumentTextContent",{enumerable:!0,get:function(){return nt}}),Object.defineProperty(b,"getEML",{enumerable:!0,get:function(){return C}}),Object.defineProperty(b,"getFileNameAndExt",{enumerable:!0,get:function(){return j}}),Object.defineProperty(b,"getFileNameWithExt",{enumerable:!0,get:function(){return R}}),Object.defineProperty(b,"getImageByUrl",{enumerable:!0,get:function(){return O}}),Object.defineProperty(b,"htmlFilesToZip",{enumerable:!0,get:function(){return tt}}),Object.defineProperty(b,"htmlToFilesData",{enumerable:!0,get:function(){return k}}),Object.defineProperty(b,"imageToBlob",{enumerable:!0,get:function(){return _}}),Object.defineProperty(b,"prepareHTML",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(b,"replaceImagesInDocument",{enumerable:!0,get:function(){return N}}),Object.defineProperty(b,"sanitizeFileName",{enumerable:!0,get:function(){return T}})});
93
93
 
94
94
  (function(){try{if(typeof document<"u"){var t='html,body{width:100%;height:100%}.blocks-app input::-ms-clear{display:none}.blocks-app input::-ms-reveal{display:none}.blocks-app *,.blocks-app :before,.blocks-app :after{box-sizing:border-box}html{-webkit-text-size-adjust:100%;-ms-text-size-adjust:100%;-ms-overflow-style:scrollbar;-webkit-tap-highlight-color:#0000;font-family:sans-serif;line-height:1.15}.blocks-app [tabindex="-1"]:focus{outline:none}.blocks-app hr{box-sizing:content-box;height:0;overflow:visible}.blocks-app h1,.blocks-app h2,.blocks-app h3,.blocks-app h4,.blocks-app h5,.blocks-app h6{margin-top:0;margin-bottom:.5em;font-weight:500}.blocks-app p{margin-top:0;margin-bottom:1em}.blocks-app abbr[title],.blocks-app abbr[data-original-title]{cursor:help;border-bottom:0;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.blocks-app address{font-style:normal;line-height:inherit;margin-bottom:1em}.blocks-app input[type=text],.blocks-app input[type=password],.blocks-app input[type=number],.blocks-app textarea{-webkit-appearance:none}.blocks-app ol,.blocks-app ul,.blocks-app dl{margin-top:0;margin-bottom:1em}.blocks-app ol ol,.blocks-app ul ul,.blocks-app ol ul,.blocks-app ul ol{margin-bottom:0}.blocks-app dt{font-weight:500}.blocks-app dd{margin-bottom:.5em;margin-left:0}.blocks-app blockquote{margin:0 0 1em}.blocks-app dfn{font-style:italic}.blocks-app b,.blocks-app strong{font-weight:bolder}.blocks-app small{font-size:80%}.blocks-app sub,.blocks-app sup{vertical-align:baseline;font-size:75%;line-height:0;position:relative}.blocks-app sub{bottom:-.25em}.blocks-app sup{top:-.5em}.blocks-app pre,.blocks-app code,.blocks-app kbd,.blocks-app samp{font-family:SFMono-Regular,Consolas,Liberation Mono,Menlo,Courier,monospace;font-size:1em}.blocks-app pre{margin-top:0;margin-bottom:1em;overflow:auto}.blocks-app figure{margin:0 0 1em}.blocks-app img{vertical-align:middle;border-style:none}.blocks-app a,.blocks-app area,.blocks-app button,.blocks-app [role=button],.blocks-app input:not([type=range]),.blocks-app label,.blocks-app select,.blocks-app summary,.blocks-app textarea{touch-action:manipulation}.blocks-app table{border-collapse:collapse}.blocks-app caption{text-align:left;caption-side:bottom;padding-top:.75em;padding-bottom:.3em}.blocks-app input,.blocks-app button,.blocks-app select,.blocks-app optgroup,.blocks-app textarea{color:inherit;font-size:inherit;font-family:inherit;line-height:inherit;margin:0}.blocks-app button,.blocks-app input{overflow:visible}.blocks-app button,.blocks-app select{text-transform:none}.blocks-app button,html [type=button],.blocks-app [type=reset],.blocks-app [type=submit]{-webkit-appearance:button}.blocks-app button::-moz-focus-inner{border-style:none;padding:0}.blocks-app [type=button]::-moz-focus-inner{border-style:none;padding:0}.blocks-app [type=reset]::-moz-focus-inner{border-style:none;padding:0}.blocks-app [type=submit]::-moz-focus-inner{border-style:none;padding:0}.blocks-app input[type=radio],.blocks-app input[type=checkbox]{box-sizing:border-box;padding:0}.blocks-app input[type=date],.blocks-app input[type=time],.blocks-app input[type=datetime-local],.blocks-app input[type=month]{-webkit-appearance:listbox}.blocks-app textarea{resize:vertical;overflow:auto}.blocks-app fieldset{border:0;min-width:0;margin:0;padding:0}.blocks-app legend{width:100%;max-width:100%;color:inherit;font-size:1.5em;line-height:inherit;white-space:normal;margin-bottom:.5em;padding:0;display:block}.blocks-app progress{vertical-align:baseline}.blocks-app [type=number]::-webkit-inner-spin-button{height:auto}.blocks-app [type=number]::-webkit-outer-spin-button{height:auto}.blocks-app [type=search]{outline-offset:-2px;-webkit-appearance:none}.blocks-app [type=search]::-webkit-search-cancel-button{-webkit-appearance:none}.blocks-app [type=search]::-webkit-search-decoration{-webkit-appearance:none}.blocks-app ::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}.blocks-app output{display:inline-block}.blocks-app summary{display:list-item}.blocks-app template{display:none}.blocks-app [hidden]{display:none!important}.blocks-app .blocks-plugin{zoom:var(--ub-appZoom)}.blocks-app .blocks-plugin .ant-layout-sider-children{display:none}.blocks-app *,.blocks-app ul.ai-roles-list *,.blocks-app .ai-response-variant[class*=ai-response] *,.blocks-app ul.buttons-variants [class*=ai-response]{-webkit-user-select:none;user-select:none}.codicon[class*=codicon-]{font:16px/1 codicon!important}.blocks-app .element-card__title,.blocks-app [class*=ai-response],.blocks-app [class*=ai-response] *,.blocks-app .ant-comment-content-detail{-webkit-user-select:text;user-select:text}.blocks-app .code-mode__pane *{-webkit-user-select:auto;user-select:auto}.blocks-app,.blocks-app .ant-app,.blocks-app .ant-app .main,.blocks-app .ant-app .main__pane-content{height:100%}@media (width<=1300px){.blocks-app .ant-app .main{min-width:1270px}}.blocks-app .ant-app [role=button],.blocks-app .ant-app a,.blocks-app .ant-app area,.blocks-app .ant-app button,.blocks-app .ant-app input:not([type=range]),.blocks-app .ant-app label,.blocks-app .ant-app select,.blocks-app .ant-app summary,.blocks-app .ant-app textarea{touch-action:manipulation}.blocks-app .ant-app ::-webkit-scrollbar{width:10px;height:10px}.blocks-app .ant-app ::-webkit-scrollbar-corner{background:0 0}.blocks-app .ant-app ::-webkit-scrollbar-track{background:0 0}.blocks-app .ant-app ::-webkit-scrollbar-thumb{min-height:20px;box-shadow:inset 0 0 0 10px var(--ub-colorFillSecondaryDarken);background-clip:content-box;border:3px solid #0000;border-radius:8px;transition:all .2s}.blocks-app .ant-app ::-webkit-scrollbar-thumb:hover{box-shadow:inset 0 0 0 10px var(--ub-colorTextDisabled)}.blocks-app .ant-app textarea::-webkit-scrollbar-track{margin:10px}.blocks-app .ant-app .ant-btn.ant-btn-icon-only .free-mode-firewall-icon,.blocks-app .ant-app .email-pane .ant-tabs-tab .free-mode-firewall-icon,.blocks-app .ant-app .free-mode-firewall-icon{background-color:var(--ub-colorBgLayout);border-radius:100%;justify-content:center;display:flex;position:absolute;bottom:0;right:0}.blocks-app .ant-app .email-pane .ant-tabs-tab .free-mode-firewall-icon_emailpane{background-color:var(--ub-colorBgContainer);bottom:13px;right:13px}.blocks-app .ant-app .ant-table-wrapper .ant-table{border-radius:calc(var(--ub-borderRadiusXL) * 1px);overflow:hidden;background:0 0!important}.blocks-app .ant-app .ant-table-wrapper .ant-table .ant-table-thead>tr,.blocks-app .ant-app .ant-table-wrapper .ant-table .ant-table-thead>tr>th,.blocks-app .ant-app .ant-table-wrapper .ant-table .ant-table-thead>tr>td{background:0 0!important}.blocks-app .ant-app .email-pane__content-col .ant-radio-button-wrapper,.blocks-app .ant-app .email-pane__content-col .selected-td-form__button:not(.ant-btn-text),.blocks-app .ant-app .email-pane__content-col .ant-btn-default{background:var(--ub-colorFillSecondary);border:1px solid #0000!important}.blocks-app .ant-app .email-pane__content-col .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled){color:var(--ub-colorPrimary);background:var(--ub-colorFillSecondary);border-color:#0000}.blocks-app .ant-app .email-pane__content-col .selected-td-form__button{min-height:calc(var(--ub-formControlHeight) * 1px);min-width:calc(var(--ub-formControlHeight) * 1px);padding:0 8px;line-height:1;position:relative}.blocks-app .ant-app .email-pane__content-col .selected-td-form__button.ant-btn-icon-only .ant-btn-icon{justify-content:center;align-items:center;width:100%;height:100%;display:inline-flex}.blocks-app .ant-app .email-pane__content-col .selected-td-form__button.ant-btn-icon-only .anticon{vertical-align:0;justify-content:center;align-items:center;line-height:1;display:inline-flex}.blocks-app .ant-app .email-pane__content-col .selected-td-form__button.ghost-button:before{content:"";z-index:1;cursor:pointer;background-color:#0000;width:385px;height:50px;position:absolute;top:-9px;left:-338px}.blocks-app .ant-app .email-pane__content-col .ant-btn-default:not(:disabled,.ant-btn-disabled,.email-pane__content-col .selected-td-form__button--active):hover{background:var(--ub-colorFillSecondaryDarken);color:inherit;border-color:#0000}.blocks-app .ant-app .email-pane__content-col .selected-td-form__button--active,.blocks-app .ant-app .email-pane__content-col .ant-btn-default.selected-td-form__button--active{background:var(--ub-colorPrimaryBg);color:var(--ub-colorPrimary);border-color:#0000}.blocks-app .ant-app .email-pane__content-col .selected-td-form__button--active:hover{background:var(--ub-colorPrimaryBgHover);color:var(--ub-colorPrimaryTextHover)}.blocks-app .ant-app .email-pane__content-col .ant-radio-button-wrapper,.blocks-app .ant-app .email-page .ant-btn{min-width:calc(var(--ub-formControlHeight) * 1px);height:calc(var(--ub-formControlHeight) * 1px);line-height:calc((var(--ub-formControlHeight) - 2) * 1px);text-align:center;padding:0 9px}.blocks-app .ant-app .email-pane__content-col .ant-radio-button-wrapper{justify-content:center;align-items:center;padding:0 7px;display:flex}.blocks-app .ant-app .email-pane__content-col .ant-radio-button-wrapper>span{display:inline-flex}.blocks-app .ant-app .ant-btn.ant-btn-icon-only.project-page__add-folder{margin-top:26px}.blocks-app .ant-app .email-pane__content-col .ant-radio-button-wrapper:not(.ant-radio-button-wrapper-checked):hover{color:inherit;background:var(--ub-colorFillSecondaryDarken)}.blocks-app .ant-app .email-pane__content-col .ant-radio-button-wrapper.ant-radio-button-wrapper-checked{background:var(--ub-colorPrimaryBg)}.blocks-app .ant-app .email-pane__content-col .ant-radio-button-wrapper.ant-radio-button-wrapper-checked:hover{background:var(--ub-colorPrimaryBgHover);color:var(--ub-colorPrimaryTextHover)}.blocks-app .ant-app .email-pane__content-col .ant-form-item{margin-bottom:calc(var(--ub-formItemMarginBottomMD) * 1px)}.blocks-app .ant-app .email-pane__content-col .ant-form-item.form-item-margin-xs{margin-bottom:calc(var(--ub-formItemMarginBottomXS) * 1px)}.blocks-app .ant-app .selected-td-form__br-input{margin-bottom:8px!important}.blocks-app .ant-app .addon-text-content{font-size:11px;font-weight:600}.blocks-app .ant-app .addon-text-content--icon{align-items:center;font-size:0;line-height:0;display:inline-flex}.blocks-app .ant-app .ant-btn.ant-btn-lg.project-page__folder_menu{text-align:center;width:32px;height:32px;padding:0;line-height:32px}.blocks-app .ant-app .editor .main__pane{overflow:hidden}.blocks-app .ant-app .element-card_block.ant-card-bordered .ant-card-cover .element-card__img-wrapper{background-color:#0000;background-image:linear-gradient(45deg,#0000001a 25%,#0000 0 75%,#0000001a 0),linear-gradient(45deg,#0000001a 25%,#0000 0 75%,#0000001a 0);background-position:0 0,4px 4px;background-repeat:repeat,repeat;background-size:8px 8px;background-attachment:scroll,scroll;background-origin:padding-box,padding-box;background-clip:border-box,border-box}.blocks-app .ant-app .ant-tabs-tabpane{width:100%}.blocks-app .ant-app .ant-tabs-large>.ant-tabs-nav .ant-tabs-tab{padding:18px 0}.blocks-app .ant-app .ant-tabs-content-holder{position:relative}.blocks-app .ant-app #filerobot-editor ::-webkit-scrollbar-thumb{border:none}.blocks-app .ant-app .email-pane__bottom .code-mode__pane{border-top:1px solid var(--ub-colorBorder)}.blocks-app .ant-app .container{width:100%;margin:0 auto;padding:0 65px}@media (width<=1550px){.blocks-app .ant-app .container{gap:10px;padding:0 10px}}.blocks-app .ant-app .projects-page__container .container{padding-top:30px}.blocks-app .ant-app .container.email-pane__col-wrapper_pinch{padding-right:0}.blocks-app .ant-app body,.blocks-app .ant-app .ant-layout{transition:background-color .2s ease-in-out}.blocks-app .ant-app p{margin-top:0}.blocks-app .ant-app .ant-layout-content.container{padding-bottom:40px}.blocks-app .ant-app .ant-table-wrapper{width:100%}.blocks-app .ant-app .ant-table{border-radius:16px;overflow:hidden}.blocks-app .ant-app .verticalColorpicker.ant-color-picker .ant-color-picker-inner-content{width:340px}.blocks-app .ant-app .ant-color-picker .ant-color-picker-inner-content .ant-color-picker-panel .ant-color-picker-select .ant-color-picker-palette{min-height:160px}.blocks-app .ant-app .easylogic-colorpicker{border-radius:8px}.blocks-app .ant-app .easylogic-colorpicker .colorpicker-body .color{border-radius:8px 8px 0 0}.blocks-app .ant-app .ant-page-header-heading-title{max-width:700px;white-space:unset;box-shadow:none;align-items:baseline;padding:0;font-size:18px;line-height:24px}.blocks-app .ant-app .ant-page-header-heading-title.ant-typography-edit-content{overflow:unset;margin-top:0}.blocks-app .ant-app .ant-page-header-heading-title textarea{background:0 0;font-size:16px;font-weight:500;line-height:20px}.blocks-app .ant-app .ant-page-header-heading-preheader:disabled,.blocks-app .ant-app .ant-page-header-heading-title:disabled{cursor:not-allowed;-webkit-user-select:none;user-select:none;pointer-events:none}.blocks-app .ant-app .ant-menu{background:inherit}.blocks-app .ant-app .ant-page-header{background:inherit;margin-bottom:20px;padding:20px 0}@media (width<=1450px){.blocks-app .ant-app .ant-page-header{padding:10px 0}}.blocks-app .ant-app .ant-page-header-heading-left{margin:0;overflow:visible}.blocks-app .ant-app .ant-page-header-heading-extra{margin:0}.blocks-app .ant-app .ant-page-header-heading-sub-title{display:block;overflow:visible}.blocks-app .ant-app .ant-progress-inner{background-color:#fff}.blocks-app .ant-app .dark .ant-progress-inner{background-color:#ffffff14}.blocks-app .ant-app .ant-collapse>.ant-collapse-item>.ant-collapse-header{flex-direction:row-reverse}.blocks-app .ant-app .ant-tabs-tab{justify-content:center}.blocks-app .ant-app .nobr{white-space:nowrap}.blocks-app .ant-app .checkbox-horizontal .ant-row{flex-direction:row-reverse;justify-content:flex-end;align-items:center}.blocks-app .ant-app .checkbox-horizontal .ant-form-item-control{margin-right:10px;flex-grow:0!important;width:auto!important}.blocks-app .ant-app .checkbox-horizontal .ant-form-item-label{padding:0!important}.blocks-app .ant-app .ant-comment .ant-comment-nested{margin-left:24px}.blocks-app .ant-app .ant-comment .ant-comment-avatar{margin-top:-2px;margin-right:8px;position:relative}.blocks-app .ant-app .ant-comment .ant-comment-avatar img{width:24px;height:24px}.blocks-app .ant-app .ant-comment .ant-comment-inner{background:var(--ub-colorBgLayout);border-radius:8px;margin-bottom:12px;padding:12px;display:flex}.blocks-app .ant-app img:not([srcset*=\\.],[src*=\\.],[src*=data\\:image]){display:none}.blocks-app .ant-app .dark .targetted-comment-item>.ant-comment-inner{background:#7030d43b}.blocks-app .ant-app .ant-tabs-top:not(.secondary-tabs_unset_scroll)>.ant-tabs-nav:before,.blocks-app .blocks-modal .ant-tabs-top:not(.secondary-tabs_unset_scroll)>.ant-tabs-nav:before{background:linear-gradient(180deg, var(--ub-colorBgContainerDisabled), transparent 40%);border-top:1px solid var(--ub-colorBorderSecondary);z-index:1;background-position:0 -2px;background-repeat:no-repeat;border-bottom:none;height:20px;bottom:-20px}.blocks-app .ant-app .ant-tabs-top[style*=vh]>.ant-tabs-nav:before,.blocks-app .blocks-modal .ant-tabs-top[style*=vh]>.ant-tabs-nav:before{background:0 0}.dark .blocks-app .ant-app .ant-tabs-top:not(.secondary-tabs_unset_scroll)>.ant-tabs-nav:before,.dark .blocks-app .blocks-modal .ant-tabs-top:not(.secondary-tabs_unset_scroll)>.ant-tabs-nav:before{background:linear-gradient(180deg, var(--ub-colorBgBase) -100%, transparent 50%)}.blocks-app .ant-app .ant-tabs-top>.ant-tabs-nav,.blocks-app .blocks-modal .ant-tabs-top>.ant-tabs-nav{margin-bottom:20px}.blocks-app .ant-app .ant-tabs.email-pane__col_settings-inner>.ant-tabs-nav .ant-tabs-nav-operations,.blocks-app .ant-app .ant-tabs.email-pane__col_settings-inner>div>.ant-tabs-nav .ant-tabs-nav-operations,.blocks-app .blocks-modal .ant-tabs.email-pane__col_settings-inner>.ant-tabs-nav .ant-tabs-nav-operations,.blocks-app .blocks-modal .ant-tabs.email-pane__col_settings-inner>div>.ant-tabs-nav .ant-tabs-nav-operations{visibility:hidden;pointer-events:none;position:absolute}.blocks-app .transition-enter{opacity:0}.blocks-app .transition-enter-active{opacity:1;transition:opacity .3s ease-in}.blocks-app .transition-exit{opacity:1}.blocks-app .transition-exit-active{opacity:0;transition:opacity .3s ease-in}.blocks-app #carrotquest-messenger-collapsed-container{z-index:10!important}.blocks-app .carrot-messenger-frame-container{z-index:11!important}.blocks-app .default-mode__pane_editor,.blocks-app .code-mode{z-index:20}@media (height<=700px){.blocks-app .ant-color-picker-presets .ant-collapse-item:last-child{display:none}}@media only screen and (device-width<=480px),only screen and (width<=480px){.blocks-app .email-pane_only_code_mode_mobile .email-pane__row .ant-col:first-child{display:none}.blocks-app .email-pane_only_code_mode_mobile .email-pane__row .ant-col:last-child{width:100%!important}}.blocks-app .em-filemanager .uploadProgress{right:105px!important}body{margin:0}.blocks-app .ant-menu-submenu-placement-rightTop:before,.blocks-app .ant-menu-submenu-placement-rightTop:after{display:none!important}.blocks-app .main{overflow:hidden}.blocks-app .main__pane-layout{height:100%;min-height:100%}.blocks-app .main__pane{height:100%;transition:height .2s cubic-bezier(0,0,.2,1);position:relative}.blocks-app .main__pane_editor{z-index:2;box-shadow:0 10px 60px #2223}.blocks-app .main__pane .ant-layout-sider-trigger{flex-direction:column;justify-content:center;display:flex;overflow:hidden}.blocks-app .main__pane-trigger{box-sizing:border-box;justify-content:space-between;align-items:center;gap:8px;width:100%;min-width:0;max-width:100%;display:flex}.blocks-app .main__pane-trigger .anticon{flex-shrink:0}.blocks-app .main__pane-trigger .theme-switcher{flex:auto;min-width:0}.blocks-app .main__pane-trigger_compact{justify-content:center;gap:0}.blocks-app .main__pane-trigger .anticon-menu-unfold,.blocks-app .main__pane-trigger:hover .anticon-menu{display:none}.blocks-app .main__pane-trigger:hover .anticon-menu-unfold,.blocks-app .main__pane-trigger .anticon-menu{display:inline-flex}.blocks-app .main__panes-resizer{position:relative}.blocks-app .main__panes-resizer:before{content:"";background-color:#0000;border-bottom:2px solid #0000;width:100%;height:10px;transition:border-color .2s;position:absolute;bottom:0;left:0;right:0}.blocks-app .main__panes-resizer:hover{cursor:row-resize}.blocks-app .main__panes-resizer:hover:before{border-color:var(--ub-colorPrimary)}.blocks-app .main__pane-close-btn{z-index:21;bottom:0;left:50%;transform:translate(-50%)}.blocks-app .main__pane-close-btn.ant-btn{border:0;border-radius:25px 25px 0 0;width:50px;height:25px;padding:0;position:absolute}.blocks-app .main__pane-close-btn .anticon{border-radius:50px 50px 0 0;outline:0 solid #188fff40;align-items:flex-end;height:100%;transition:all .1s cubic-bezier(0,0,.2,1)}.blocks-app .main__pane-close-btn .anticon.show-halo{outline-width:12px}.blocks-app .main__pane-close-btn .anticon.opened{align-items:flex-start;transform:rotate(180deg)}.blocks-app .main__pane-trigger .anticon.anticon-menu-fold{display:inline-flex}.blocks-app .main__pane-trigger.ant-btn{z-index:1;width:100%;height:70px;box-shadow:none;background:0 0;border:0;display:block;position:absolute;top:0;left:0;right:0}.blocks-app .main__pane-trigger.ant-btn:hover,.blocks-app .main__pane-trigger.ant-btn:focus{background:0 0}.blocks-app .main__pane-trigger.ant-btn:empty{visibility:visible;width:100%;display:block}.blocks-app .main__menu{z-index:11;height:100%;position:sticky;top:0}.blocks-app .main__menu .ant-layout-sider-children{box-sizing:border-box;max-height:100vh;overflow:hidden auto}.blocks-app .main__menu>div{border-right:1px solid;border-color:inherit}.blocks-app .main__menu:not(.ant-layout-sider-collapsed){margin-right:-180px;top:0;left:0;box-shadow:0 3px 6px -4px #0000001f,0 6px 16px #00000014,0 9px 28px 8px #0000000d}.blocks-app body.dark .main__menu:not(.ant-layout-sider-collapsed){box-shadow:0 3px 6px -4px #0000007a,0 6px 16px #00000052,0 9px 28px 8px #0003}.blocks-app .main__menu.main__menu_lock{box-shadow:none;margin-right:0}.blocks-app body.dark .main__menu.main__menu_lock{box-shadow:none}.blocks-app .main__menu *{text-overflow:unset!important}@media (width<=1400px){.blocks-app .main__menu .ant-layout-sider-zero-width-trigger{z-index:100000;top:50%;text-align:center;visibility:visible;width:20px;height:60px;font-size:16px;inset-inline-start:0;transform:translateY(-30px);box-shadow:0 1px 2px -2px #00000029,0 3px 6px #0000001f,0 5px 12px 4px #0000000f}.blocks-app .main__menu .ant-layout-sider-zero-width-trigger-right{visibility:hidden}}.blocks-app .main__content-wrapper{position:relative}@media (width<=1550px){.blocks-app .main__header{padding:0 20px 0 40px!important}}.blocks-app .ant-layout .ant-layout-sider-trigger{text-align:left;border-bottom:none;padding:0 30px}.blocks-app .ant-app .main__menu:not(.ant-layout-sider-collapsed) .ant-layout-sider-trigger{padding:0 30px}.blocks-app .ant-app .main__menu.ant-layout-sider-collapsed .ant-layout-sider-trigger{padding:0 10px}.blocks-app .ant-layout-sider-light .ant-layout-sider-trigger{background:0 0}.blocks-app .ant-btn.project-menu__block-button{padding:0!important}.blocks-app .selected-element-panel__columns-settings__controls__field{background:var(--ub-colorBgElevated);border:calc(var(--ub-borderWidth) * 1px) solid var(--ub-colorFillSecondaryDarken);transition:all .2s linear .2s}.blocks-app .selected-element-panel__columns-settings__controls__field:hover{border-color:var(--ub-borderColorHover)}.blocks-app .selected-element-panel__columns-settings__controls__field:focus,.blocks-app .selected-element-panel__columns-settings__controls__field:focus-within{border-color:var(--ub-colorPrimaryBorder);box-shadow:0 0 0 2px #0591ff1a}.blocks-app .selected-element-panel__columns-settings__controls__column.current .selected-element-panel__columns-settings__controls__field{background:var(--ub-colorPrimaryBg);border-color:var(--ub-colorPrimaryBorder)}.blocks-app .structures{margin-left:-3px;margin-right:-3px;overflow:visible}.blocks-app .structures__list{margin-bottom:-10px}.blocks-app .structures__item{box-sizing:border-box;cursor:grab;flex-direction:row;justify-content:center;align-items:center;width:100%;min-width:100%;height:50px;margin-bottom:20px;padding:0;display:flex}.blocks-app .structures__item:hover .structures__item-row{background:var(--ub-colorFillTertiary);border:#0000;box-shadow:0 1px 2px -2px #00000029,0 3px 6px #0000001f,0 5px 12px 4px #00000017}.dark .blocks-app .structures__item:hover .structures__item-row{background:var(--ub-colorBgSpotlight)}.blocks-app .structures__item-row{background:var(--ub-colorFillSecondary);border-radius:calc(var(--ub-borderRadius) * 1.2px);width:97%;height:100%;padding:6px 3px;transition:box-shadow .3s,border-color .3s,background-color .3s}.blocks-app .structures__item-col{border-radius:calc(var(--ub-borderRadius) * 1px);border:1px solid var(--ub-controlItemBgActiveHover);background:var(--ub-controlItemBgActive);width:100%;height:100%}.dark .blocks-app .structures__item-col{border-color:var(--ub-colorBgElevated);background:var(--ub-colorFillTertiary)}.blocks-app .em-dragging-element .structures__item .structures__item-row{background-color:var(--ub-controlTmpOutline);box-shadow:none}.dark .blocks-app .em-dragging-element .structures__item .structures__item-row{background:var(--ub-controlTmpOutline)}.blocks-app .em-dragging-element .structures__item .structures__item-row .structures__item-col{opacity:0;border-radius:calc(var(--ub-borderRadius) * 1px)}.blocks-app .em-ghost-element{background-color:var(--ub-colorBgContainer);border-radius:calc(var(--ub-borderRadiusXL) * 1px)}.blocks-app .em-ghost-element .structures__item-col{opacity:1!important}.dark .blocks-app .em-ghost-element{background:var(--ub-colorBgSpotlight)}@media (width<=1550px){.blocks-app .structures__item{margin-bottom:16px}.blocks-app .structures__item:last-child{margin-bottom:20px}}.blocks-app .atoms{overflow:visible}.blocks-app .atoms__list{margin-bottom:20px;transition:opacity .2s}.blocks-app .atoms__item{font:inherit;text-align:center;appearance:none;box-sizing:border-box;border-radius:calc(var(--ub-borderRadius) * 1px);width:109px;height:70px;color:var(--ub-colorTextSecondary);background:var(--ub-colorFillSecondary);border:0;flex-direction:column;justify-content:center;align-items:center;margin:0;padding:5px;display:flex;position:relative}.blocks-app .atoms__item.ant-card-hoverable{cursor:grab!important}.blocks-app .atoms__item:hover{border-color:var(--ub-colorBgElevated)}.dark .blocks-app .atoms__item:hover{border-color:var(--ub-colorTextDisabled);background:var(--ub-colorBorder)}.blocks-app .atoms__item_inactive{opacity:.5;cursor:default}.blocks-app .atoms__item_inactive:hover{border-color:var(--ub-colorBorder)}.blocks-app .atoms__item_locked .atom-image{opacity:.55;margin-bottom:6px;display:inline-flex;position:relative}.blocks-app .atoms__item_locked .atom-image__lock{opacity:1;background-color:var(--ub-colorBgContainer);border-radius:100%;position:absolute;bottom:-2px;right:-6px}.blocks-app .atoms__item_locked .atom-title{opacity:.55}.blocks-app .atoms__item.ai:before{content:"AI";color:#fff;background-color:var(--ub-colorInfo);text-align:center;border-radius:0 calc(var(--ub-borderRadius) * 1px) 0 calc(var(--ub-borderRadiusSM) * 1px);width:36px;padding:1px 5px;font-size:12px;line-height:1.2;display:inline-block;position:absolute;top:0;right:0}.blocks-app .atoms__item.amp:before{content:"AMP";color:#fff;background-color:var(--ub-colorPrimary);text-align:center;border-radius:0 8px 0 5px;width:36px;padding:1px 5px;font-size:12px;line-height:1.2;display:inline-block;position:absolute;top:0;right:0}.blocks-app .atoms .anticon{color:var(--ub-colorTextSecondary);font-size:28px}.blocks-app .atoms .em-dragging-element .atoms__item{background-color:var(--ub-controlTmpOutline)}.blocks-app .atoms .em-ghost-element{background-color:var(--ub-colorBgContainer)!important;border:1px solid var(--ub-colorBorder)!important}.blocks-app .atoms .atom-title{color:var(--ub-colorTextTertiary);text-align:center;font-size:13px;line-height:1}.blocks-app #email_iframe{vertical-align:top;background-color:#f8f8f8;border:0;width:1px;min-width:100%}.blocks-app .iframe-provider+#email_iframe_slot{pointer-events:none}.blocks-app .iframe-provider{width:100%;height:100%;position:absolute;top:0;left:0}.blocks-app .browser-extension-warning-modal__footer,.blocks-app .browser-translate-warning-modal__footer{justify-content:center;margin-top:24px;display:flex}.blocks-app .email-pane{position:relative}.blocks-app .email-pane__loader{z-index:10;background-color:#fff6;width:100%;height:100%;position:fixed;top:0;left:0}.dark .blocks-app .email-pane__loader{background-color:#0006}.blocks-app .email-pane__paths{border-top:1px solid var(--ub-colorBorder);z-index:10;background-color:var(--ub-colorBgContainer);justify-content:space-between;align-items:center;width:100%;transition:all .5s;display:flex;position:sticky;bottom:0;left:0}.blocks-app .email-pane__paths>div{color:var(--ub-colorTextTertiary);padding:3px 15px}.blocks-app .email-pane__paths .ant-breadcrumb{white-space:nowrap;overflow:auto hidden}.blocks-app .email-pane__paths .ant-breadcrumb ol{flex-wrap:nowrap;padding-right:10px}.blocks-app .email-pane__paths .ant-breadcrumb li{position:relative}.blocks-app .email-pane__paths .ant-breadcrumb li:hover>span{color:var(--ub-colorPrimary)}.blocks-app .email-pane__paths .ant-breadcrumb li>span{color:var(--ub-colorTextSecondary);cursor:pointer;padding:3px 15px;display:block}.blocks-app .email-pane__paths .ant-breadcrumb li>span span{align-items:center;gap:4px;display:flex}.blocks-app .email-pane__paths .ant-breadcrumb li:after{content:"";border-style:solid;border-width:15px 0 15px 10px;border-color:transparent transparent transparent var(--ub-colorBgContainer);width:0;height:0;transition:all .5s;position:absolute;top:50%;right:-5px;transform:translateY(-50%)}.blocks-app .email-pane__paths .ant-breadcrumb li:before{content:"";border-style:solid;border-width:15px 0 15px 10px;border-color:transparent transparent transparent var(--ub-colorBorder);width:0;height:0;transition:all .5s;position:absolute;top:50%;right:-6px;transform:translateY(-50%)}.blocks-app .email-pane__code-size{white-space:nowrap;margin-left:auto;padding:3px 15px;font-size:14px}.blocks-app .email-pane__code-size_exceeded{color:var(--ub-colorError)}.blocks-app .email-pane .ant-btn-primary.mobile_view{background-color:var(--ub-colorInfo)}.blocks-app .email-pane .ant-btn-primary.mobile_view:hover{background-color:var(--ub-colorInfoHover)}.blocks-app .email-pane .ant-tabs .ant-tabs-tab-btn{transition:none}.blocks-app .email-pane .ant-tabs-extra-content{justify-content:center;align-items:center;display:flex}.blocks-app .email-pane .ant-tabs-extra-content .ant-segmented_editor-mode{margin-top:22px;transform:rotate(90deg)}.blocks-app .email-pane .ant-tabs-extra-content .ant-segmented_editor-mode .ant-segmented-item-label{min-height:40px;padding:0;line-height:40px}.blocks-app .email-pane .ant-tabs-extra-content .ant-segmented_editor-mode .ant-segmented-item-icon{width:28px;height:40px;display:inline-block;transform:rotate(-90deg)}.blocks-app .email-pane .ant-tabs-extra-content .ant-segmented_editor-mode .ant-segmented-item-icon .anticon{position:relative}.blocks-app .email-pane .email-pane_code-mode .email-pane__col-wrapper{transition:all .5s;padding-top:0!important}.blocks-app .blocks-plugin .email-pane .email-pane_code-mode .email-pane__resizable{padding-top:60px;transition:all .5s}.blocks-app .email-pane .email-pane_code-mode:not(.email-pane_is-mobile,.email-pane_code-mode-bottom) .email-pane__col-wrapper{padding-top:0!important}.blocks-app .email-pane .email-pane_code-mode:not(.email-pane_is-mobile,.email-pane_code-mode-bottom) .email-pane__left .email-pane__content-col_main{border-width:0;border-radius:0;margin-left:0;margin-right:0;border-top-width:0!important;border-bottom-width:0!important;border-right-width:0!important}.blocks-app .email-pane .email-pane_code-mode:not(.email-pane_is-mobile,.email-pane_code-mode-bottom) .email-pane__right .email-pane__content-col_main{border-width:0;border-radius:0;margin-left:0;margin-right:0;border-top-width:0!important;border-bottom-width:0!important;border-left-width:0!important}.blocks-app .blocks-plugin .email-pane .email-pane_code-mode:not(.email-pane_is-mobile,.email-pane_code-mode-bottom) .email-pane__resizable{max-width:calc(100% - 2px);margin-bottom:0;padding-top:0}.blocks-app .email-pane .selected-td-form__padding-input .ant-input-number-focused input{text-align:left}.blocks-app .email-pane .selected-td-form__padding-input input{text-align:center}.blocks-app .email-pane .email-pane__comment-counter{background-color:var(--ub-colorInfo);color:var(--ub-colorWhite);border:none}.blocks-app .email-pane .element-controls{width:100%;height:100%}.blocks-app .email-pane #selected_element_form_desktop_props{height:100%}.blocks-app .email-pane .ant-tabs .ant-divider-horizontal.selected-td-form__divider{border-top:1px solid var(--ub-colorBorderSecondary);background:linear-gradient(180deg, var(--ub-colorBgContainerDisabled), transparent 40%);width:calc(100% + 50px);margin:26px -23px}.dark .blocks-app .email-pane .ant-tabs .ant-divider-horizontal.selected-td-form__divider{background:linear-gradient(180deg, var(--ub-colorBgBase), transparent 40%)}.blocks-app .email-pane .ant-tabs .element-controls .selected-td-form__divider{margin-top:0;margin-bottom:0}.blocks-app .email-pane .ant-tabs .blocks-search__divider{pointer-events:none;width:auto;height:20px;margin:24px 0 0;position:absolute;bottom:-20px;left:-24px;right:-13px}.blocks-app .email-pane .ant-tabs ::-webkit-scrollbar-thumb{box-shadow:inset 0 0 0 10px var(--ub-colorFillSecondary)}.blocks-app .email-pane .ant-tabs ::-webkit-scrollbar-thumb:hover{box-shadow:inset 0 0 0 10px var(--ub-colorFill)}.blocks-app .email-pane .ant-tabs .blocks-search__empty-shadow{height:100%;position:relative}.blocks-app .email-pane .ant-tabs .blocks-search__empty-shadow:after{content:"";background:linear-gradient(180deg, var(--ub-colorBgContainerDisabled), transparent 40%);z-index:1;width:calc(100% + 48px);height:20px;margin-left:-24px;position:absolute;top:0;left:0}.blocks-app .email-pane .ant-tabs .blocks-search__empty-wrapper{height:calc(100% + 10px);margin:0 -24px;padding:24px 14px 0 24px;position:relative;overflow:scroll}.blocks-app .email-pane__container{scroll-behavior:smooth;min-height:100%;padding-top:0}.blocks-app .email-pane_code-mode .email-pane__container{overflow:unset;height:unset;padding-bottom:0;position:relative}.blocks-app .email-pane_code-mode:not(.email-pane_code-mode-bottom) .email-pane__container>.selected-element-panel{z-index:101;pointer-events:none;height:0;position:absolute;inset:0 0 auto}.blocks-app .email-pane_code-mode:not(.email-pane_code-mode-bottom) .email-pane__container>.selected-element-panel>div{pointer-events:auto}.blocks-app .email-pane_code-mode:not(.email-pane_code-mode-bottom) .email-pane__container>.selected-element-panel .selected-element-panel-content.selected-element-panel__content_abs{width:fit-content;max-width:calc(100% - 24px);min-height:auto;display:block}.blocks-app .email-pane_code-mode:not(.email-pane_code-mode-bottom) .email-pane__container>.selected-element-panel .selected-element-panel-content.selected-element-panel__content_abs form.element-controls{height:auto;min-height:auto}.blocks-app .email-pane__col-wrapper{flex-wrap:nowrap;gap:30px;display:flex;position:relative}.blocks-app .email-pane__col-wrapper .email-pane__col_settings{margin-top:30px}.blocks-app .email-pane__col-wrapper .email-pane__col_settings-inner{border-radius:8px;position:sticky;top:30px;left:0}.blocks-app .ant-app .email-pane__col-wrapper_reverse{flex-direction:row-reverse}.blocks-app .email-pane .email-pane__sizeSwitcher:not(.email-pane__pinch,.email-pane__right) .email-pane__col-wrapper{top:-114px}.blocks-app .email-pane_code-mode .email-pane__code-divider{opacity:0;cursor:ew-resize;background-color:var(--ub-colorPrimary);width:5px;height:100%;transition:opacity .4s;position:absolute}.blocks-app .email-pane_code-mode .email-pane__code-divider:hover,.blocks-app .email-pane_code-mode .email-pane__code-divider:active{opacity:1;background-color:var(--ub-colorPrimary)}.blocks-app .email-pane_code-mode.email-pane .email-pane__row:not(.email-pane__bottom,.email-pane__sizeSwitcher) .email-pane__content-col_main{border-radius:0;border:0 solid var(--ub-colorBorder)!important;margin:0!important}.blocks-app .email-pane_code-mode.email-pane .email-pane__row:not(.email-pane__bottom,.email-pane__sizeSwitcher) [class^=device-width__] button{display:none}.blocks-app .email-pane_code-mode .email-pane__left{flex-direction:row}.blocks-app .email-pane_code-mode .email-pane__left>div:first-child{border-right:1px solid var(--ub-colorBorder);overflow-y:auto!important}.blocks-app .email-pane_code-mode .email-pane__left .email-pane__handle.left{display:none}.blocks-app .email-pane_code-mode .email-pane__left .email-pane__code-divider{left:-2px}.blocks-app .email-pane_code-mode .email-pane__right{flex-direction:row-reverse}.blocks-app .email-pane_code-mode .email-pane__right>div:first-child{border-left:1px solid var(--ub-colorBorder);overflow-y:auto!important}.blocks-app .email-pane_code-mode .email-pane__right .email-pane__handle.right{display:none}.blocks-app .email-pane_code-mode .email-pane__right .email-pane__code-divider{right:-2px}.blocks-app .email-pane_code-mode .email-pane__bottom{max-width:unset;flex-direction:column;margin:0}.blocks-app .email-pane_code-mode .email-pane__bottom .email-pane__col-wrapper{width:100%;margin:0 auto}.blocks-app .email-pane_code-mode .email-pane__bottom .email-pane__code-divider{opacity:0;cursor:ns-resize;z-index:10;width:100%;height:2px;top:-2px}.blocks-app .email-pane_code-mode .email-pane__bottom .email-pane__code-divider:hover,.blocks-app .email-pane_code-mode .email-pane__bottom .email-pane__code-divider:active{opacity:1;background-color:var(--ub-colorPrimary)}.blocks-app .email-pane .email-pane__col-wrapper_pinch.email-pane__col-wrapper{gap:0;height:100%;padding-left:3px}.blocks-app .email-pane .email-pane__col-wrapper_pinch.email-pane__col-wrapper .email-pane__col.email-pane__col_preview{overflow-y:scroll;height:100%!important}@media (width<=1590px){.blocks-app .email-pane .email-pane__col-wrapper_pinch.email-pane__col-wrapper .email-pane__col.email-pane__col_preview{overflow-x:hidden}}.blocks-app .email-pane .email-pane__col-wrapper_pinch.email-pane__col-wrapper .ant-tabs-content-holder{border-radius:0}.blocks-app .email-pane .email-pane__col-wrapper_pinch.email-pane__col-wrapper.email-pane__col-wrapper_reverse .email-pane__col.email-pane__col_preview{padding-left:10px;padding-right:0}.blocks-app .email-pane__left .email-pane .email-pane__col-wrapper_pinch.email-pane__col-wrapper.email-pane__col-wrapper_reverse .email-pane__col.email-pane__col_preview{padding-left:65px;padding-right:0}.blocks-app .email-pane .email-pane__col-wrapper_pinch.email-pane__col-wrapper .ant-tabs-right>.ant-tabs-nav .ant-tabs-tab{height:53px;padding-top:6px;padding-left:6px;padding-right:6px}.blocks-app .email-pane .email-pane.email-pane_code-mode .email-pane__col-wrapper_reverse .email-pane__col.email-pane__col_preview{padding-right:0}.blocks-app .email-pane .email-pane.email-pane_code-mode .email-pane__col-wrapper_pinch.email-pane__col-wrapper{padding-left:0}.blocks-app .email-pane .email-pane__right.email-pane__sizeSwitcher .email-pane__col.email-pane__col_preview{padding-left:0;padding-right:35px;overflow:visible}.blocks-app .email-pane .email-pane__right.email-pane__sizeSwitcher .email-pane__col.email-pane__col_preview .email-pane__content-col.email-pane__content-col_main{border-width:1px}.blocks-app .email-pane .email-pane__left.email-pane__sizeSwitcher .email-pane__col.email-pane__col_preview{padding-left:65px!important;padding-right:0!important}.blocks-app .email-pane .email-pane__right .email-pane__col-wrapper_reverse .email-pane__col.email-pane__col_preview,.blocks-app .email-pane .email-pane__left.email-pane__sizeSwitcher .email-pane__col-wrapper_reverse .email-pane__col.email-pane__col_preview{padding-left:0!important;padding-right:0!important}.blocks-app .email-pane .email-pane__right:not(.email-pane__pinch) .email-pane__col-wrapper_pinch.email-pane__col-wrapper{padding-left:0;padding-right:65px}.blocks-app .email-pane .email-pane__right.email-pane__pinch.email-pane__sizeSwitcher .email-pane__col-wrapper_pinch.email-pane__col-wrapper{padding-left:0}.blocks-app .email-pane .email-pane__right.email-pane__pinch.email-pane__sizeSwitcher .email-pane__col-wrapper_pinch.email-pane__col-wrapper .email-pane__col_preview{padding-left:0;padding-right:65px}.blocks-app .email-pane .email-pane__reverse .email-pane__col-wrapper_pinch.email-pane__col-wrapper{padding-left:0}.blocks-app .email-pane .email-pane__sizeSwitcher .email-pane__col.email-pane__col_preview{padding-top:30px}.blocks-app .email-pane .email-pane__sizeSwitcher .email-pane__col-wrapper_pinch .email-pane__col.email-pane__col_preview{padding:60px 2px 0}.blocks-app .email-pane .email-pane__reverse.email-pane__sizeSwitcher .email-pane__col.email-pane__col_preview{padding-right:65px}.blocks-app .email-pane .email-pane.email-pane_code-mode .email-pane__right .email-pane__col.email-pane__col_preview,.blocks-app .email-pane .email-pane.email-pane_code-mode .email-pane__left .email-pane__col.email-pane__col_preview{padding-top:0}.blocks-app .email-pane .email-pane__right .email-pane__col_preview,.blocks-app .email-pane .email-pane__left .email-pane__col_preview{padding-left:0;padding-right:0}.blocks-app .email-pane .email-pane.email-pane_code-mode .email-pane__col-wrapper_pinch.email-pane__col-wrapper .email-pane__col.email-pane__col_preview{height:100%!important}.blocks-app .email-pane .email-pane__sizes-panel-wrapper{z-index:5;position:sticky;top:30px;left:15px}.blocks-app .email-pane .email-pane__right .email-pane__sizes-panel-wrapper{left:auto;right:15px}.blocks-app .email-pane .email-pane__right.email-pane__sizeSwitcher .email-pane__sizes-panel-wrapper{display:none}.blocks-app .email-pane .email-pane__pinch .email-pane__sizes-panel-wrapper{position:absolute;top:12px;left:calc(50% - 266px)}.blocks-app .email-pane .email-pane__reverse .email-pane__sizes-panel-wrapper{left:auto;right:calc(50% - 266px)}.blocks-app .email-pane .email-pane__reverse.email-pane__left.email-pane__pinch .email-pane__sizes-panel-wrapper{display:none;left:15px;right:auto}.blocks-app .email-pane .email-pane__sizes-panel{background-color:var(--ub-colorBgElevated);border:1px solid var(--ub-colorBorder);border-radius:34px}.blocks-app .email-pane__header{padding-right:10px}.blocks-app .email-pane__header .header__left{margin-left:0}.blocks-app .email-pane__header .header__logo{float:left;height:auto;margin-top:5px;margin-right:26px;padding-right:0;font-size:22px!important}.blocks-app .email-pane__header__title{align-items:center;width:100%;display:flex}.blocks-app .email-pane__header__title__project a{white-space:nowrap;text-overflow:ellipsis;flex:1;max-width:190px;display:flex;overflow:hidden}.blocks-app .email-pane__header__title__project{float:left;margin-top:10px}.blocks-app .email-pane__header__title__project a:hover{color:var(--ub-colorPrimary)}.blocks-app .email-pane__header__title .ant-typography{white-space:nowrap;text-overflow:ellipsis;flex:1;margin:10px 0 10px 20px;padding:0;display:flex;overflow:hidden}.blocks-app .email-pane__row{flex-wrap:nowrap;justify-content:space-between;gap:30px;height:100%;position:relative}.blocks-app .email-pane_path-enabled .email-pane__row{height:calc(100% - 29px)}.blocks-app .email-pane_code-mode .email-pane__row{gap:0;height:calc(100% - 29px);padding:0}.blocks-app .email-pane__col_settings{border-color:var(--ub-colorBorder);height:100%;margin-right:50px;position:sticky;top:0;bottom:60px;overflow:visible}.blocks-app .email-pane__col_disabled.email-pane__content-col_tabs.email-pane__content-col{width:68px;min-width:68px;margin-right:0}.blocks-app .email-pane__col_settings-inner{height:100%;max-height:100%;margin-right:0}.blocks-app .email-pane__col_settings-inner_reverse{flex-direction:row-reverse}.blocks-app .email-pane__col_settings-inner_reverse .email-pane__tab-bar.ant-tabs-nav{margin-left:0;margin-right:8px}.blocks-app .email-pane__col_settings-inner_reverse .email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab-btn>span{line-height:1}.blocks-app .email-pane__col .email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab-btn>span{height:24px;margin-right:0;font-size:20px}.blocks-app .email-pane__col-wrapper_pinch .email-pane__col .email-pane__tab-bar.ant-tabs-nav{border-left:1px solid var(--ub-colorBorderSecondary);background:var(--ub-colorBgContainer)}.blocks-app .email-pane__reverse .email-pane__col-wrapper_pinch .email-pane__col .email-pane__tab-bar.ant-tabs-nav{border-left:none}.blocks-app .email-pane__col .email-pane__col_settings-inner_reverse{border-right:1px solid var(--ub-colorBorder)}.blocks-app .email-pane_view .email-pane__col{height:calc(100vh - 48px);top:0;bottom:0;overflow:auto}.blocks-app .email-pane__col_settings{height:calc(100vh - 76px);position:sticky;top:10px;bottom:60px;overflow:auto}.blocks-app .email-pane_view .email-pane__col_settings{height:calc(100vh - 48px)}.blocks-app .email-pane__col_settings-collapsed{flex:0 0;max-width:0}.blocks-app .email-pane__col_preview{scroll-behavior:smooth}.blocks-app .email-pane_code-mode .email-pane__row:not(.email-pane__bottom) .email-pane__col_preview{overflow:auto;width:100%!important}.blocks-app .email-pane__col_preview-collapsed{flex:0 0 100%;width:100%;max-width:100%}.blocks-app .email-pane__col_settings{z-index:11;height:100%;position:sticky;top:20px;bottom:60px;overflow:visible}.blocks-app .email-pane__col_settings-inner{height:100%;max-height:100%}.blocks-app .email-pane__col_menu{margin-left:20px}.blocks-app .email-pane__col .ant-modal-close{top:14px;width:34px;height:34px;font-size:16px;position:absolute;inset-inline-end:12px;padding:0!important}.blocks-app .email-pane__col_code-mode .ant-menu-vertical.element-preview-menu__list_discuss li.ant-menu-item{text-align:center}.blocks-app .email-pane__col__alert{z-index:100;width:40%;max-width:400px;bottom:40px;left:10px;position:absolute!important}.blocks-app .email-pane__collapse-wrapper{background-color:var(--ub-colorBgContainer);border:1px solid var(--ub-colorBgContainer);border-radius:calc(var(--ub-borderRadiusXL) * 1px);flex-direction:column;align-self:flex-start;height:auto;min-height:0;max-height:100%;display:flex;overflow:hidden}.dark .blocks-app .email-pane__collapse-wrapper{border:1px solid var(--ub-colorBorderSecondary)}.blocks-app .email-pane__collapse-wrapper_disabled{display:none}.blocks-app .email-pane__collapse-wrapper>*{min-height:0;max-height:100%}.blocks-app .email-pane__collapse-wrapper .ant-tabs-content-holder{border-radius:0 0 calc(var(--ub-borderRadiusXL) * 1px) calc(var(--ub-borderRadiusXL) * 1px);border:none;margin:0 -1px -1px;transition:all .3s;overflow:hidden}.blocks-app .email-pane__collapse-wrapper .selected_form-mobile-props-title,.blocks-app .email-pane__collapse-wrapper .selected_form-desktop-props-title{opacity:0;will-change:transform, height;padding-top:0;transition:height .45s cubic-bezier(.16,1,.3,1),margin-top .45s cubic-bezier(.16,1,.3,1),transform .45s cubic-bezier(.16,1,.3,1),opacity .3s ease-out;transform:translateY(-100%)}@keyframes em-mobile-props-title-slide-in{0%{opacity:0;height:0;transform:translateY(-100%)}to{opacity:1;height:32px;transform:translateY(0)}}.blocks-app .email-pane__collapse-wrapper #selected_element_form_desktop_props{transition:all .1s}.blocks-app .email-pane__collapse-wrapper .selected_form-props-wrapper_optimize{padding-top:0}.blocks-app .ant-app .email-pane__collapse-wrapper .selected_form-mobile-props-title,.blocks-app .ant-app .email-pane__collapse-wrapper .selected_form-desktop-props-title{background-color:var(--ub-colorInfoBg);border:none;border-radius:0;height:0;padding:0 24px;top:0;overflow:hidden}.blocks-app .email-pane__collapse-wrapper.mobile-properties .panel-form__body{border:1px solid var(--ub-colorInfo);border-radius:0 0 calc(var(--ub-borderRadius) * 2px) calc(var(--ub-borderRadius) * 2px);scrollbar-gutter:auto;flex-direction:column;display:flex;overflow:hidden}.blocks-app .email-pane__collapse-wrapper.mobile-properties .panel-form__body-content{flex-direction:column;flex:1;min-height:0;padding:0;display:flex;overflow:hidden}.blocks-app .email-pane__collapse-wrapper.mobile-properties .panel-form__body-content>div{flex-direction:column;flex:1;min-height:0;display:flex;overflow:hidden}.blocks-app .email-pane__collapse-wrapper.mobile-properties .ant-tabs .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn{color:var(--ub-colorInfo)}.blocks-app .email-pane__collapse-wrapper.mobile-properties .ant-tabs .ant-tabs-ink-bar{background:var(--ub-colorInfo)}.blocks-app .email-pane__collapse-wrapper.mobile-properties .email-properties__collapse:after{display:none}.blocks-app .email-pane__collapse-wrapper.mobile-properties .selected-element-panel-content{flex-direction:column;flex:1;min-height:0;padding:0;display:flex;overflow:hidden}.blocks-app .email-pane__collapse-wrapper.mobile-properties .selected-element-panel{flex-direction:column;flex:1;min-height:0;padding-left:0;padding-right:0;display:flex;overflow:hidden}.blocks-app .email-pane__collapse-wrapper.mobile-properties .selected-element-panel>div{flex-direction:column;flex:1;min-height:0;display:flex;overflow:hidden}.blocks-app .email-pane__collapse-wrapper.mobile-properties form.element-controls{flex-direction:column;height:100%;min-height:0;display:flex}.blocks-app .email-pane__collapse-wrapper.mobile-properties #selected_element_form_desktop_props{min-height:0;padding:24px var(--ub-panel-form-padding-x,24px) 0;flex:1;overflow:hidden auto}.blocks-app .email-pane__collapse-wrapper.mobile-properties .selected_form-mobile-props-wrapper{flex-direction:column;flex:1;min-height:0;display:flex;overflow:hidden}.blocks-app .email-pane__collapse-wrapper.mobile-properties .selected_form-mobile-props-header{flex-shrink:0}.blocks-app .email-pane__collapse-wrapper.mobile-properties .selected_form-mobile-props{scrollbar-gutter:stable;flex:1;min-height:0;overflow:hidden auto}.blocks-app .email-pane__collapse-wrapper.mobile-properties .selected-element-panel__float-blocks-settings{display:none}.blocks-app .email-pane__collapse-wrapper.mobile-properties .selected_form-desktop-props-title{opacity:1;height:32px;animation:.45s cubic-bezier(.16,1,.3,1) both em-mobile-props-title-slide-in;transform:translateY(0)}.blocks-app .email-pane__collapse-wrapper.mobile-properties .selected_form-mobile-props-title{z-index:1;border:none;border-bottom:1px solid var(--ub-colorBorderSecondary);background-color:var(--ub-colorInfoBg);padding:5px 24px;transform:translateY(0)}.blocks-app .email-pane__collapse-wrapper.mobile-view .ant-tabs-tab:first-child:hover{color:var(--ub-colorInfo)}.blocks-app .email-pane__collapse-wrapper.mobile-view .selected_form-mobile-props-title{opacity:1;height:32px;animation:.45s cubic-bezier(.16,1,.3,1) both em-mobile-props-title-slide-in;transform:translateY(0)}.blocks-app .email-pane__collapse-wrapper.mobile-view .selected_form-mobile-props-title .ant-alert-title{color:var(--ub-colorInfoText)}.blocks-app .email-pane__collapse-wrapper_build{flex:1;align-self:stretch;height:100%}.blocks-app .email-pane__collapse-wrapper_build>.email-pane__collapse{flex:1;min-height:0}.blocks-app .email-pane__collapse-wrapper_build>.email-pane__collapse>.ant-tabs-content-holder{flex:1;min-height:0;display:flex}.blocks-app .email-pane__collapse-wrapper_build>.email-pane__collapse>.ant-tabs-content-holder>.ant-tabs-content{height:100%;min-height:0}.blocks-app .email-pane__collapse-wrapper_build>.email-pane__collapse>.ant-tabs-content-holder>.ant-tabs-content>.ant-tabs-tabpane-active{flex-direction:column;flex:1;min-height:0;display:flex}.blocks-app .email-pane__col-wrapper_pinch .email-pane__collapse-wrapper{border:none;border-left:1px solid var(--ub-colorBorder);border-radius:0;height:100%}.blocks-app .email-pane__collapse{flex-direction:column;flex:1;width:100%;height:100%;min-height:0;max-height:100%;display:flex;overflow:hidden}.blocks-app .email-pane__collapse.ant-collapse{border:0}.blocks-app .email-pane__collapse-panel.ant-collapse-item{min-height:50px;overflow:hidden}.blocks-app .email-pane__comment-counter{border-radius:10px;width:27px;height:16px;margin:5px;padding:0 6px;font-size:12px}.blocks-app .email-pane__add-new-element-btn{width:100%;margin-bottom:60px}.blocks-app .email-pane__tab-bar.ant-tabs-nav{z-index:1;width:60px;margin-bottom:0;margin-left:8px;margin-right:0;top:0}.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab-active{border-radius:8px;border-right:none!important}.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-tabpane,.blocks-app .ant-tabs-left>.email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab{padding-left:0}.blocks-app .ant-tabs-left>.email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab+.ant-tabs-tab,.blocks-app .ant-tabs-right>.email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab+.ant-tabs-tab{margin-top:0}.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-nav-list{background:var(--ub-colorBgContainer);border-radius:8px;flex:none;padding:0 0 4px;box-shadow:0 2px 10px #0500380a}.blocks-app .email-pane__col-wrapper_pinch .email-pane__tab-bar.ant-tabs-nav .ant-tabs-nav-list{box-shadow:none;border-radius:0;height:100%}.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-nav-wrap{overflow:unset;flex:none}.blocks-app .email-pane__tab-bar.ant-tabs-nav+.ant-tabs-content-holder{border-left:none;margin-left:0}.blocks-app .email-pane__tab-bar.ant-tabs-nav+.ant-tabs-content-holder .ant-tabs-content>.ant-tabs-tabpane{padding-left:0}.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab:first-child,.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab:nth-child(2),.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab:nth-child(3){display:none}.blocks-app .email-pane__col-wrapper_pinch .email-pane__tab-bar.ant-tabs-nav{margin-left:0;margin-right:0}.blocks-app .email-pane .ant-tabs-right>.ant-tabs-content-holder,.blocks-app .email-pane .ant-tabs-right>div>.ant-tabs-content-holder{border-right:none;margin-right:0}.blocks-app .email-pane .ant-tabs-left>.ant-tabs-nav .ant-tabs-tab{border:1px solid #0000;height:60px;padding:14px 24px}@media (width<=1550px){.blocks-app .email-pane .ant-tabs-left>.ant-tabs-nav .ant-tabs-tab{height:50px}}.blocks-app .email-pane .ant-collapse-panel{box-sizing:content-box;height:calc(100% - 50px);margin-top:-1px;overflow:auto}.blocks-app .email-pane .ant-tabs-content{height:100%;max-height:100%}.blocks-app .email-pane .ant-collapse-body,.blocks-app .email-pane .secondary-tabs .ant-tabs-content{height:100%;padding-bottom:0;position:relative;overflow:hidden scroll}.blocks-app .email-pane__comment-counter{position:absolute;top:-4px;right:0}@media (width<=1550px){.blocks-app .email-pane__comment-counter{right:-5px}}.blocks-app .email-pane__content-col_disable{pointer-events:none}.blocks-app .email-pane .header__project{vertical-align:middle;align-items:center;height:28px;padding-top:0;display:inline-flex}.blocks-app .email-pane .header__project .ant-avatar.ant-avatar-circle{min-width:28px}.blocks-app .email-pane_view .header__project{pointer-events:none}.blocks-app .email-pane__pane{height:100%;transition:height .2s cubic-bezier(0,0,.2,1);position:relative}.blocks-app .email-pane__panes{height:calc(100vh - 48px);display:flex;overflow:auto}.blocks-app .email-pane__panes-resizer{z-index:2;position:relative}.blocks-app .email-pane__panes-resizer:before{content:"";background-color:#0000;border-left:2px solid #0000;width:10px;height:100%;transition:border-color .2s;position:absolute;inset:0}.blocks-app .email-pane__panes-resizer:hover{cursor:col-resize}.blocks-app .email-pane__panes-resizer:hover:before{border-color:var(--ub-colorPrimary)}.blocks-app .email-pane__footer{z-index:2;border-top:1px solid #d9d9d9;height:28px;display:none;position:relative}.blocks-app .email-pane:not(.email-pane_view) .email-pane__pane-content{height:100%;position:absolute;inset:0;overflow:hidden}.blocks-app .email-pane__pane_main .email-pane:not(.email-pane_view) .email-pane__pane-content{overflow:auto}.blocks-app .email-pane:not(.email-pane_view) .email-pane__pane-content .email-pane__pane_editor{height:100%;overflow:visible}.blocks-app .email-pane:not(.email-pane_view) .email-pane__pane-content .email-pane__pane_editor .email-pane__pane-content{height:100%}.blocks-app .email-pane__buttons{text-align:right}.blocks-app .email-pane__buttons .ant-space.ant-space-horizontal.ant-space-align-center{display:flex}.blocks-app .email-pane__buttons button{width:46px;height:24px;margin-left:8px;padding:0}.blocks-app .email-pane__iframe-scroll-bottom,.blocks-app .email-pane__iframe-scroll-top{z-index:10;width:100%;height:50px;display:none;position:sticky;left:0;right:0}.blocks-app .email-pane__iframe-scroll-top{margin-bottom:-50px;top:0}.blocks-app .email-pane__iframe-scroll-bottom{margin-top:-50px;bottom:0}.blocks-app .email-pane__list{border:none;line-height:20px}.blocks-app .email-pane__list.ant-menu-horizontal>.ant-menu-item{padding:0 14px}.blocks-app .email-pane__list.ant-menu-horizontal>.ant-menu-item:after{content:none}.blocks-app .email-pane__list-item_active{color:var(--ub-colorPrimaryTextHover)}.blocks-app .ant-menu-item .email-pane__list-item-icon.anticon{font-size:20px}.blocks-app .email-pane__list-item:hover .email-pane__list-item-icon.anticon,.blocks-app .email-pane__list-item_active.ant-menu-item .email-pane__list-item-icon.anticon{color:var(--ub-colorPrimaryTextHover)}.blocks-app .email-pane__list-item.ant-menu-item.ant-menu-item-selected,.blocks-app .email-pane__list-item.ant-menu-item-disabled:hover .email-pane__list-item-icon.anticon{color:inherit}.blocks-app .email-pane__content-col.email-pane__content-col_menu{min-width:462px;margin-left:0}.blocks-app .email-pane__content-col_menu-left{margin-right:10px}.blocks-app .email-pane__code-mode{margin-top:10px;display:flex}.blocks-app .email-pane__code-mode .email-pane__panes{width:100%}.blocks-app .email-pane__code-mode .email-pane__panes+.email-pane__content-col.email-pane__content-col_menu,.blocks-app .email-pane__code-mode .email-pane__content-col.email-pane__content-col_menu:not(.email-pane__content-col_menu-right){width:60px;min-width:60px;margin-top:5px;margin-left:10px;margin-right:10px}.blocks-app .email-pane__code-mode .email-pane__content-col.email-pane__content-col_menu.email-pane__content-col_menu-right{width:50px;min-width:50px;margin-top:5px;margin-left:10px;margin-right:10px}.blocks-app .email-pane__col_code-mode{top:0}.blocks-app .email-pane__comments-icon-wrapper{text-align:center;cursor:pointer;width:50px;height:60px;margin-right:5px;padding:13px 21px;position:relative}.blocks-app .email-pane__comments-icon-wrapper:hover{color:#999da0}.blocks-app .email-pane__comment-counter{color:#000000d9;width:auto;min-width:28px;height:18px;text-shadow:none;border:1px solid #fff;border-radius:10px;margin:5px;padding:0 6px;font-size:12px;position:absolute;top:-8px;right:-10px}.blocks-app body.dark .email-pane__comment-counter{color:#f0f0f0;border-color:#1f1f1f}.blocks-app .email-pane__col-wrapper_pinch .email-pane__comment-counter{right:0}.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-tabpane,.blocks-app .ant-tabs-left>.email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab{padding-left:0}.blocks-app .ant-tabs-right>.email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab{padding-right:0}.blocks-app .ant-tabs-left>.email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab+.ant-tabs-tab{margin-top:0}.blocks-app .ant-tabs-right>.email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab+.ant-tabs-tab{z-index:1;margin-top:0}.blocks-app .ant-tabs-right>.email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab+.ant-tabs-tab .ant-tabs-tab-btn{background:0 0;border-radius:6px;justify-content:center;align-items:center;width:100%;height:100%;display:flex}.blocks-app .ant-tabs-right>.email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab+.ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn{background:var(--ub-controlItemBgActive)}.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-nav-list .ant-tabs-ink-bar{box-sizing:border-box;background:#fff;border:none;border-radius:6px;width:60px;margin:0 2px;display:none;box-shadow:0 2px 8px -2px #0000000d,0 1px 4px -1px #00000012,0 0 1px #00000014}.blocks-app .email-pane__tab-bar.ant-tabs-nav+.ant-tabs-content-holder{border-left:none;width:397px;margin-left:0}.blocks-app .email-pane__tab-bar.ant-tabs-nav+.ant-tabs-content-holder .ant-tabs-content>.ant-tabs-tabpane{padding-left:0;padding-right:0}.blocks-app .email-pane__tab-bar.ant-tabs-nav .ant-tabs-tab:first-child{display:none}.blocks-app .email-pane .ant-tabs-left>.ant-tabs-nav .ant-tabs-tab,.blocks-app .email-pane .ant-tabs-right>.ant-tabs-nav .ant-tabs-tab{border:none;height:56px;padding:4px 4px 0}.blocks-app .email-pane .ant-tabs-tab .anticon{margin-right:0;font-size:20px}.blocks-app .email-pane__code-mode:not(.email-pane__col_preview-collapsed){padding-left:60px}.blocks-app .email-pane__content-col_tabs.email-pane__content-col{margin-left:0;margin-right:0;transition:all .3s cubic-bezier(.075,.82,.165,1);top:30px}@media (width<=1350px){.blocks-app .email-pane__content-col_tabs.email-pane__content-col{transform-origin:0 0;transform:scale(.83)}}.blocks-app .email-pane__col-wrapper_pinch .email-pane__content-col_tabs.email-pane__content-col{margin-top:0;top:0;height:100%!important}.blocks-app .email-pane .email-pane__col-wrapper_pinch .blocks-search__empty-wrapper{height:calc(100% - 30px)}.blocks-app .email-pane__col_preview-collapsed{margin-left:70px}.blocks-app .email-pane .email-pane__content-col_main{border:1px solid var(--ub-colorBorder);border-radius:calc(var(--ub-borderRadiusXL) * 1px);margin-left:-2px;margin-right:-2px;transition:border-color .4s;overflow:hidden auto}.blocks-app .email-pane .secondary-tabs.secondary-tabs_unset_scroll .ant-tabs-nav:after{display:none}.blocks-app .email-pane .secondary-tabs.secondary-tabs_unset_scroll .ant-tabs-content{overflow-y:hidden;padding-top:0!important;padding-right:24px!important}.blocks-app .email-pane__col.email-pane__col_preview{flex-direction:column;justify-content:flex-start;align-items:center;max-width:1600px;margin:0;padding:0 2px;display:flex}.blocks-app .email-pane__sizes{border:1px solid var(--ub-colorBorder);z-index:10;opacity:.9;border-top:none;border-radius:0 0 8px 8px;justify-content:center;width:100%;height:15px;min-height:15px;margin-bottom:15px;transition:all .5s;display:flex;position:sticky;top:0;left:0}.blocks-app .email-pane__sizes:hover{opacity:1}.blocks-app .email-pane_code-mode .email-pane__row:not(.email-pane__bottom) .email-pane__sizes{border-width:0;height:0;min-height:0;margin-bottom:0}.blocks-app .email-pane__sizes .email-pane__width-selectors-wrapper{justify-content:center;width:100%;display:flex}.blocks-app .email-pane__sizes .device-width__theme{border-right:1px solid var(--ub-colorBorder);background-color:var(--ub-colorBgElevated);flex-shrink:0;width:36px;transition:all .3s;position:relative}.blocks-app .email-pane__sizes .device-width__theme .email-pane__theme-toggle{margin:0}.blocks-app .email-pane__sizes .device-width__theme-placeholder{flex-shrink:0;width:36px;cursor:default!important}.blocks-app .email-pane__sizes [class^=device-width__]{border-right:1px solid var(--ub-colorBorder);background-color:var(--ub-colorBgElevated);cursor:pointer;transition:all .3s;position:relative}.blocks-app .email-pane__sizes [class^=device-width__]:first-child{border-bottom-left-radius:calc(var(--ub-borderRadius) * 1px)}.blocks-app .email-pane__sizes [class^=device-width__]:last-child{border-bottom-right-radius:calc(var(--ub-borderRadius) * 1px);border:none}.blocks-app .ant-app .email-pane__sizes [class^=device-width__] button{color:var(--ub-colorTextDescription);width:24px;min-width:24px;height:24px;line-height:1}.blocks-app .ant-app .email-pane__sizes [class^=device-width__] button:hover{background:var(--ub-colorPrimaryBg)}.blocks-app .email-pane__sizes .device-width__320{text-align:center;color:var(--ub-colorText);font-size:12px;line-height:15px}.blocks-app .email-pane__sizes.device-width__full-hovered [class^=device-width__],.blocks-app .email-pane__sizes.device-width__768-hovered [class*=__768],.blocks-app .email-pane__sizes.device-width__768-hovered [class*=__425],.blocks-app .email-pane__sizes.device-width__768-hovered [class*=__375],.blocks-app .email-pane__sizes.device-width__768-hovered [class*=__320],.blocks-app .email-pane__sizes.device-width__425-hovered [class*=__425],.blocks-app .email-pane__sizes.device-width__425-hovered [class*=__375],.blocks-app .email-pane__sizes.device-width__425-hovered [class*=__320],.blocks-app .email-pane__sizes.device-width__375-hovered [class*=__375],.blocks-app .email-pane__sizes.device-width__375-hovered [class*=__320],.blocks-app .email-pane__sizes.device-width__320-hovered [class*=__320]{background:var(--ub-colorPrimaryBg)}.blocks-app .email-pane__resizable{width:100%;margin-bottom:29px;transition:max-width .5s;position:relative}.blocks-app .blocks-plugin .email-pane__resizable{padding:0 2px}.blocks-app .email-pane__resizable_drag{transition:none}.blocks-app .email-pane__resizable .email-pane__handle{box-sizing:border-box;opacity:0;cursor:ew-resize;width:5px;height:100%;transition:opacity .4s;position:absolute}.blocks-app .email-pane_code-mode .email-pane__row:not(.email-pane__bottom) .email-pane__resizable .email-pane__handle{pointer-events:none}.blocks-app .email-pane__resizable .email-pane__handle:hover,.blocks-app .email-pane__resizable .email-pane__handle:active{opacity:1}.blocks-app .email-pane__resizable .email-pane__handle.left{left:0}.blocks-app .email-pane__resizable .email-pane__handle.right{right:0}.blocks-app .email-pane__left .email-pane__resizable,.blocks-app .email-pane__right .email-pane__resizable{margin-bottom:0}.blocks-app .email-pane__tooltip{margin-right:20px}.blocks-app .email-pane .ant-layout-content.container.email-pane__container{padding-bottom:0}.blocks-app .email-pane .ant-tabs-tabpane.ant-tabs-tabpane-active.em-analytics__email-tab-build{border-top-left-radius:0}.blocks-app .email-pane .ant-tabs-large.secondary-tabs .ant-tabs-nav-list{padding-left:24px}.blocks-app .email-pane .ant-tabs-large.secondary-tabs .ant-tabs-nav{margin-bottom:0}.blocks-app .email-pane .ant-tabs-large.secondary-tabs .ant-tabs-tab .ant-tabs-tab-btn{font-size:14px;font-weight:400}.blocks-app .email-pane .ant-tabs-large.secondary-tabs .ant-tabs-tab+.ant-tabs-tab{margin:0 0 0 20px}.blocks-app .email-pane .ant-tabs-large.secondary-tabs .ant-tabs-content{padding:24px 13px 4px 24px}.blocks-app .email-pane .ant-tabs-large.secondary-tabs.secondary-tabs_optimise .ant-tabs-content{padding:0 25px}.blocks-app .email-pane .ant-tabs-large.secondary-tabs.email-properties__collapse .ant-tabs-content{padding-bottom:0}.blocks-app .email-pane.email-pane_no-element-navigation .ant-tabs-large.secondary-tabs.email-properties__collapse .ant-tabs-content{padding-top:0}.blocks-app .email-pane .email-properties__collapse{position:relative}.blocks-app .email-pane .email-properties__collapse:after{content:"";background:linear-gradient(180deg, var(--ub-colorBgContainerDisabled), transparent 40%);border-top:1px solid var(--ub-colorBorderSecondary);z-index:1;width:100%;height:20px;position:absolute;top:58px;left:0}.dark .blocks-app .email-pane .email-properties__collapse:after{background:linear-gradient(180deg, var(--ub-colorBgBase) -100%, transparent 50%)}.blocks-app .email-pane .ant-tooltip{pointer-events:none}.blocks-app .email-pane__blocks-search{overflow-clip-margin:40px;flex-direction:column;height:calc(100% - 44px);min-height:0;display:flex;overflow:clip}.blocks-app .email-pane__blocks-search label.ant-segmented-item{margin-top:0}.blocks-app .email-pane__blocks-panel,.blocks-app .email-pane__blocks-panel-body{height:100%}.blocks-app .email-pane__blocks-panel-header{flex-shrink:0}.blocks-app .email-pane__blocks-panel-results{display:none}.blocks-app .email-pane__blocks-panel-results_visible{flex-direction:column;flex:1;min-height:0;display:flex;overflow:hidden}.blocks-app .email-pane__blocks-panel_scrollable,.blocks-app .email-pane__blocks-panel_scrollable{overflow-clip-margin:40px;flex-direction:column;flex:1;min-height:0;display:flex;overflow:clip}.blocks-app .email-pane__blocks-panel_scrollable .email-pane__blocks-panel-body{flex-direction:column;flex:1;min-height:0;margin-left:-24px;margin-right:-24px;display:flex;overflow:hidden}.blocks-app .email-pane__blocks-panel_scrollable .blocks-search__empty-shadow{padding-left:24px;padding-right:24px}.blocks-app .email-pane .email-pane__blocks-search .ant-segmented{position:relative;top:-7px}@media screen and (width<=700px){.blocks-app .email-pane_view .email-pane__buttons{display:none}.blocks-app .email-pane__content{margin:0;padding-right:0}.blocks-app .email-pane__content .email-pane__content-col_main{min-width:100%}.blocks-app .email-pane__content .email-pane__content-col_menu{display:none}.blocks-app .email-pane__content .email-pane__content-col_menu+.email-pane__resizer{border-left:none;border-right:2px solid #0000}.blocks-app .email-pane__content .email-pane__content-col_menu+.email-pane__resizer:hover{border-color:var(--ub-colorPrimary)}}.blocks-app .ant-menu-vertical.element-preview-menu__list_discuss li.ant-menu-item{text-align:right;padding:0 10px}.blocks-app .ant-tooltip{pointer-events:none}@media (width<=1550px){.blocks-app .email-pane .ant-tabs .secondary-tabs.email-pane__collapse:not(.secondary-tabs_unset_scroll):after{margin-top:44px}}.dark .blocks-app .email-pane .ant-tabs .blocks-search__empty-shadow:after{background:linear-gradient(180deg, var(--ub-colorBgBase) -100%, transparent 50%)}.dark .blocks-app .ant-app .email-pane .ant-tabs-extra-content .ant-segmented_editor-mode{background-color:#121212}.blocks-app .collaborator-list{position:absolute;bottom:30px}.blocks-app .ant-app .email-pane__col-wrapper_pinch .ant-switch.ant-switch_editor-mode{width:48px}.blocks-app .ant-app .email-pane__col-wrapper_pinch .ant-switch.ant-switch_editor-mode.ant-switch-checked{background:var(--ub-controlItemBgActive)}.blocks-app .ant-app .email-pane__col-wrapper_pinch .ant-switch.ant-switch_editor-mode.ant-switch-checked .ant-switch-inner-checked{color:var(--ub-colorPrimary)}.blocks-app .email-preview-menu__versions .ant-btn,.blocks-app .email-preview-menu__code .ant-btn,.blocks-app .email-preview-menu__preview .ant-btn,.blocks-app .email-preview-menu__test{justify-content:center;align-items:center;display:inline-flex}.blocks-app .email-preview-menu__list-item-icon{align-items:center;display:inline-flex}.blocks-app .email-preview-menu_right{margin-left:auto}.blocks-app .email-preview-menu_new{align-items:center;padding-right:22px;display:flex}.blocks-app .email-preview-menu .email-preview-menu__history *{pointer-events:none}.blocks-app .ant-menu.email-preview-menu__list{border:0}.blocks-app .ant-menu-vertical .ant-menu-item.email-preview-menu__list-item{margin-top:0;padding:0 10px}.blocks-app .ant-menu-vertical .ant-menu-item.email-preview-menu__list-item_disabled{cursor:not-allowed}.blocks-app .ant-menu-vertical .ant-menu-item.email-preview-menu__list-item:hover .ant-menu-item.email-preview-menu__list-item_disabled .anticon.email-preview-menu__list-item-icon{color:inherit}.blocks-app .ant-menu-vertical .ant-menu-item.email-preview-menu__list-item a{width:40px;height:40px;margin-left:-10px;display:block}.blocks-app .ant-menu-vertical .ant-menu-item.email-preview-menu__list-item a .email-preview-menu__list-item-icon{margin-left:10px}.blocks-app .ant-menu-item .anticon.email-preview-menu__list-item-icon{font-size:20px}.blocks-app .ant-menu-item .anticon.email-preview-menu__list-item-icon_revert{transform:scaleX(-1)}.blocks-app .email-preview-menu__list-item:hover .anticon.email-preview-menu__list-item-icon,.blocks-app .ant-menu-item.email-preview-menu__list-item_active .anticon.email-preview-menu__list-item-icon{color:var(--ub-colorPrimaryHover)}.blocks-app .ant-menu-item.ant-menu-item-selected.email-preview-menu__list-item,.blocks-app .ant-menu-item-disabled.email-preview-menu__list-item:hover .anticon.email-preview-menu__list-item-icon{color:inherit}.blocks-app .ant-menu-vertical>.email-preview-menu__list__scroll-buttons{cursor:default;text-align:center;height:auto;margin:0;padding:0}.blocks-app .ant-menu-vertical>.email-preview-menu__list__scroll-buttons .ant-space{display:block}.blocks-app .ant-menu-vertical>.email-preview-menu__list__scroll-buttons button{width:40px;height:40px;box-shadow:none;text-shadow:none;background:0 0;border:none;margin-bottom:8px;padding:0;display:block}.blocks-app .ant-menu-vertical>.email-preview-menu__list__scroll-buttons button .anticon{font-size:20px;transition:color .3s}.blocks-app .ant-menu-vertical>.email-preview-menu__list__scroll-buttons button .anticon :hover{color:var(--ub-colorPrimaryHover)}.blocks-app .ant-menu-vertical .email-preview-menu__list__divider{border-top:2px solid var(--ub-colorBorder);width:20px;min-width:auto;margin:20px 0}.blocks-app .ant-menu-vertical .email-preview-menu__list__divider.second-devider{margin-left:10px}.blocks-app .code-size-warning-modal .ant-modal-container{padding:32px}.blocks-app .code-size-warning-modal__content{flex-direction:column;display:flex}.blocks-app .code-size-warning-modal__icon{color:var(--ub-colorWarning);margin-bottom:16px;font-size:64px}.blocks-app .code-size-warning-modal__icon .anticon{display:block}.blocks-app .code-size-warning-modal__title{color:var(--ub-colorText);margin:0 0 12px;font-size:18px;font-weight:600}.blocks-app .code-size-warning-modal__message{color:var(--ub-colorTextSecondary);margin-bottom:24px;font-size:14px;line-height:1.6}.blocks-app .code-size-warning-modal__message p{margin:0 0 12px}.blocks-app .code-size-warning-modal__message p:last-child{margin-bottom:0}.blocks-app .code-size-warning-modal__message strong{color:var(--ub-colorError);font-weight:600}.blocks-app .code-size-warning-modal__image{width:100%;margin-bottom:24px}.blocks-app .code-size-warning-modal__image-placeholder{border-radius:8px;width:100%;height:200px;display:flex}.blocks-app .code-size-warning-modal__image-placeholder img{object-fit:contain;max-width:100%;max-height:100%}.blocks-app .code-size-warning-modal__actions{width:100%;display:flex}.blocks-app .code-size-warning-modal__actions .ant-btn{min-width:140px}.blocks-app .integration-tile{border:1px solid var(--ub-colorBorderSecondary);background:var(--ub-colorBgContainer);border-radius:8px;flex-direction:column;min-height:254px;padding:16px;transition:border-color .2s;display:flex}.blocks-app .integration-tile--error{border-color:var(--ub-colorError)}.blocks-app .integration-tile__body{flex:1;min-height:0}.blocks-app .integration-tile__icon{object-fit:contain;width:48px;height:48px;margin-bottom:12px}.blocks-app .integration-tile__icon-svg{margin-bottom:12px;font-size:48px;line-height:1}.blocks-app .integration-tile__title{color:var(--ub-colorText);margin:0 0 4px;font-size:14px;font-weight:500;line-height:1.3;display:block}.blocks-app .integration-tile__description{color:var(--ub-colorTextSecondary);margin:0;font-size:12px;font-weight:300;line-height:1.4;display:block}.blocks-app .integration-tile__footer{justify-content:space-between;align-items:flex-end;gap:8px;min-height:40px;margin-top:16px;display:flex}.blocks-app .integration-tile__badge{white-space:nowrap;border-radius:11px;align-items:center;height:22px;padding:0 8px;font-size:12px;font-weight:400;line-height:1;display:inline-flex}.blocks-app .integration-tile__badge--connected{color:var(--ub-colorSuccess);background:var(--ub-colorSuccessBg)}.blocks-app .integration-tile__badge--not_connected{color:var(--ub-colorTextSecondary);background:var(--ub-colorFillTertiary)}.blocks-app .integration-tile__badge--error{color:var(--ub-colorError);background:var(--ub-colorErrorBg)}.blocks-app .integration-tile__badge--coming_soon{color:var(--ub-colorPrimary);background:var(--ub-colorPrimaryBg)}.blocks-app .integration-tile__configure.ant-btn{box-sizing:border-box;width:40px;min-width:40px;height:40px;box-shadow:none;background:var(--ub-colorFillQuaternary);color:var(--ub-colorTextSecondary);border:none;border-radius:6px;flex-direction:row;flex:none;justify-content:center;align-items:center;gap:0;padding:0;display:inline-flex}.blocks-app .integration-tile__configure.ant-btn.ant-btn-icon-only{width:40px;min-width:40px;height:40px;padding:0}.blocks-app .integration-tile__configure.ant-btn .ant-btn-icon{justify-content:center;align-items:center;width:16px;height:16px;margin:0;line-height:0;display:inline-flex}.blocks-app .integration-tile__configure.ant-btn:not(:disabled):hover,.blocks-app .integration-tile__configure.ant-btn:not(:disabled):focus-visible{box-shadow:none;background:var(--ub-colorFillTertiary);color:var(--ub-colorTextSecondary);border:none}.blocks-app .integration-tile__configure.ant-btn:disabled,.blocks-app .integration-tile__configure.ant-btn.ant-btn-disabled{cursor:not-allowed;box-shadow:none;opacity:1;background:var(--ub-colorFillQuaternary);color:var(--ub-colorTextQuaternary);border:none}.blocks-app .integration-tile__configure.ant-btn:disabled .ant-btn-icon,.blocks-app .integration-tile__configure.ant-btn.ant-btn-disabled .ant-btn-icon{color:var(--ub-colorTextQuaternary)}.blocks-app .integration-tile__configure.ant-btn:disabled:hover,.blocks-app .integration-tile__configure.ant-btn:disabled:focus-visible,.blocks-app .integration-tile__configure.ant-btn.ant-btn-disabled:hover,.blocks-app .integration-tile__configure.ant-btn.ant-btn-disabled:focus-visible{box-shadow:none;background:var(--ub-colorFillQuaternary);color:var(--ub-colorTextQuaternary);border:none}.blocks-app .ant-app .integration-tile__configure.ant-btn.ant-btn-icon-only{width:40px;min-width:40px;height:40px;padding:0}.blocks-app .ant-app .integration-tile__configure.ant-btn.ant-btn-icon-only:disabled,.blocks-app .ant-app .integration-tile__configure.ant-btn.ant-btn-icon-only.ant-btn-disabled{opacity:1;background:var(--ub-colorFillQuaternary);color:var(--ub-colorTextQuaternary)}.blocks-app .em-export-platforms-submenu .ant-dropdown-menu{max-height:420px;overflow-y:auto}.blocks-app .app-logo{color:#000;line-height:1.35;display:inline-block}.blocks-app .app-logo:hover{color:#000}.blocks-app .em-analytics__email-save .ant-btn-loading-icon .anticon,.blocks-app .em-analytics__block-save .ant-btn-loading-icon .anticon{font-size:16px}.blocks-app .main__ribbon{background:var(--ub-colorInfo);min-height:43px;color:var(--ub-colorTextLightSolid);flex-direction:row;justify-content:center;align-items:center;font-size:16px;display:flex}.blocks-app .main__ribbon button{background:var(--ub-colorInfoTextHover)}.blocks-app .main__ribbon button:hover{background:var(--ub-colorInfoHover)!important}.blocks-app .main__ribbon .main__ribbon-resend.ant-btn.ant-btn-sm{padding-block:5px;padding-inline:14px}.blocks-app .header{box-sizing:content-box;border-bottom:1px solid;height:70px;min-height:70px}.blocks-app .header_blocks{padding-right:10px}.blocks-app .header_main{z-index:1}.blocks-app .header__container{justify-content:space-between;align-items:center;gap:30px;min-height:70px;transition:opacity .3s;display:flex}.blocks-app .header__logo,.blocks-app .header__project{white-space:nowrap;text-overflow:ellipsis;max-width:220px;display:block;overflow:hidden}.blocks-app .header__logo{padding-top:10px}.blocks-app .header h2,.blocks-app .header h3{margin:0}.blocks-app .header__right{max-height:40px}.blocks-app .header__right .header__action-btn.ant-btn{align-items:center;height:34px;min-height:34px;padding-block:0;display:inline-flex}.blocks-app .header__right .ant-space.ant-space-horizontal.ant-space-align-center{align-items:center;display:flex}.blocks-app .header__right,.blocks-app .header__left{display:flex}.blocks-app .header__left .ant-space,.blocks-app .header__left .ant-space .ant-space-item:last-child{flex-grow:1}.blocks-app .header .project-menu__list-item{cursor:pointer;transition:color .3s}.blocks-app .header .project-menu__list-item:hover{color:#40a9ff}.blocks-app .header .project-menu__list-item svg{width:1.2em;height:1.2em;vertical-align:inherit}.blocks-app .header .project-menu__list-item .anticon-bell svg{width:1.4em;height:1.4em}.blocks-app .header .ant-typography{margin-bottom:0}.blocks-app .foo-title{color:#fff;letter-spacing:1px;background:#9254de;border-radius:3px;margin-top:-10px;margin-left:-4px;padding:0 7px;font-size:13px;font-weight:500;position:absolute}.blocks-app .email-page-header__dropdown-menu{top:10px}.blocks-app .email-page-header__email-id{color:var(--ub-colorTextTertiary)}.blocks-app .email-page-header .button{cursor:pointer}.blocks-app .anticon.anticon-edit.email-page-header__icon-edit{color:#8c8c8c;margin-left:6px;font-size:16px}.blocks-app .ant-typography-edit:hover .anticon.anticon-edit.email-page-header__icon-edit{color:var(--ub-colorPrimaryHover)}.blocks-app .ant-page-header-heading{max-width:700px;transition:all .2s;position:relative}.blocks-app .ant-page-header-heading svg{cursor:pointer;opacity:0;justify-content:center;width:0;height:0;transition:all .2s .2s;position:absolute;top:0;right:3px}.blocks-app .ant-page-header-heading svg:hover{color:var(--ub-colorPrimaryHover)}.blocks-app .ant-page-header-heading.focus{background-color:var(--ub-colorFillSecondary);border-radius:calc(var(--ub-borderRadiusSM) * 1px);padding:0 8px}.blocks-app .ant-page-header-heading.focus svg{opacity:1;width:20px;height:20px;top:3px}.blocks-app .ant-page-header-heading.ant-page-header-heading_preheader.focus svg{top:3px}.blocks-app .ant-page-header-heading_preheader .anticon{top:-2px}.blocks-app .email-page-header .ant-page-header-heading-left{flex-grow:1;overflow:visible}.blocks-app .email-page-header .ant-page-header-back{align-self:flex-start;margin-right:0;padding-top:8px}.blocks-app div.ant-typography-edit-content.ant-page-header-heading-preheader,.blocks-app div.ant-typography-edit-content.ant-page-header-heading-title{margin-top:0;margin-bottom:0;inset-inline-start:0}.blocks-app .header__left .ant-form-item-control-input,.blocks-app .header__left .ant-form-item-control-input-content{line-height:normal;min-height:auto!important}.blocks-app .header__left .ant-page-header-heading-title{white-space:pre-wrap;text-overflow:ellipsis;border-radius:0;flex-grow:1;min-height:auto;font-weight:500;line-height:1;overflow:visible;height:auto!important;padding:3px 20px 3px 0!important}.blocks-app .header__left .ant-page-header-heading-preheader{max-width:700px;min-height:auto;box-shadow:none;text-overflow:ellipsis;white-space:nowrap;border-radius:0;display:block;overflow:hidden;height:auto!important;padding:3px 20px 3px 0!important;line-height:20px!important}.blocks-app .header__left .ant-skeleton.ant-skeleton-element{width:100%;display:block}.blocks-app .ant-page-header-heading-title,.blocks-app .ant-page-header-heading-preheader{background:0 0;padding:0;box-shadow:none!important;border:none!important;transition:none!important}.blocks-app .ant-page-header-heading-preheader{color:var(--ub-colorTextSecondary);min-height:auto}.blocks-app .subject_preheader_form__title{width:80px;color:var(--ub-colorTextTertiary);white-space:nowrap}.blocks-app .ant-page-header-heading-title{line-height:22px!important}.blocks-app .email-page-header .ant-typography{align-items:center;margin-bottom:0;padding:0 12px;display:flex}.blocks-app .email-page-header .ant-typography-edit-content{margin-top:-10px;padding:0;top:5px;left:auto}.blocks-app .email-page-header .ant-input{font-size:inherit;font-weight:inherit}.blocks-app .email-page-header .ant-page-header-heading-extra>*{margin-left:8px}.blocks-app header .ant-btn.email-page-header__btn_extra{width:32px;padding:0}.blocks-app .update-global-blocks-modal__hint{color:#000000a6;margin-bottom:16px}.blocks-app .update-global-blocks-modal__list{flex-direction:column;gap:12px;max-height:320px;display:flex;overflow-y:auto}.blocks-app .update-global-blocks-modal__row{align-items:center;gap:12px;display:flex}.blocks-app .update-global-blocks-modal__title{flex-direction:column;flex:auto;display:flex;overflow:hidden}.blocks-app .update-global-blocks-modal__version{color:#00000073;font-size:12px}.blocks-app .update-global-blocks-modal__count{color:#00000073;flex:none;font-size:12px}.blocks-app .update-global-blocks-modal__footer{justify-content:flex-end;gap:8px;display:flex}.blocks-app .convert-layout-modal .ant-modal-header{text-align:center;margin-top:16px;margin-bottom:8px}.blocks-app .convert-layout-modal .ant-modal-footer{margin-top:16px;padding:0 8px}.blocks-app .convert-layout-modal__title{color:var(--ub-colorText);font-size:20px;font-weight:600}.blocks-app .convert-layout-modal__content{flex-direction:column;align-items:center;gap:24px;display:flex;overflow:hidden}.blocks-app .convert-layout-modal__text{font-size:14px;line-height:1.5}.blocks-app .convert-layout-modal__intro-text{text-align:center;color:var(--ub-colorTextSecondary);padding:0 16px}.blocks-app .convert-layout-modal__image{border-radius:8px;width:100%;max-width:100%;height:auto;display:block}.blocks-app .convert-layout-modal__footer{justify-content:flex-end;gap:8px;margin-top:8px;display:flex}.blocks-app .convert-layout-modal__footer--between{justify-content:space-between}.blocks-app .convert-layout-modal__error-details{background-color:var(--ub-colorErrorBg,#ff00000f);color:var(--ub-colorTextSecondary);word-break:break-word;border-radius:8px;margin-top:12px;padding:8px 12px;font-size:12px}.blocks-app .conversion-overlay{z-index:2000;background-color:var(--ub-colorBgMask,#00000073);justify-content:center;align-items:center;display:flex;position:fixed;inset:0}.blocks-app .conversion-overlay__content{background-color:var(--ub-colorBgElevated);width:360px;max-width:80vw;box-shadow:var(--ub-boxShadowSecondary);text-align:center;border-radius:12px;flex-direction:column;align-items:center;gap:16px;padding:32px;display:flex}.blocks-app .conversion-overlay__title{color:var(--ub-colorText);font-size:16px;font-weight:600}.blocks-app .conversion-overlay__hint{color:var(--ub-colorTextSecondary);font-size:13px}.blocks-app .conversion-overlay__progress{width:100%}@media (width<=1550px){.blocks-app .email-pane__col_settings{margin-left:48px;margin-right:32px}}.blocks-app .em-dragging-element{border-radius:8px}.blocks-app .em-dragging-element>div{box-shadow:none!important}.blocks-app .em-dragging-element .blocks-search__result-html,.blocks-app .em-dragging-element span,.blocks-app .em-dragging-element .atoms__item:before{visibility:hidden}.blocks-app .em-ghost-element.blocks-search__result-html,.blocks-app .em-ghost-element span,.blocks-app .em-ghost-element.atoms__item:before{visibility:visible!important}.blocks-app .em-ghost-element table{border-collapse:initial}',e=window.__useblocks_styles__||(window.__useblocks_styles__={sheets:{},order:[]}),a=t;if(!e.sheets[a]){var p=!1;try{if(typeof CSSStyleSheet=="function"&&"replaceSync"in CSSStyleSheet.prototype&&document.adoptedStyleSheets){var n=new CSSStyleSheet;n.replaceSync(t),document.adoptedStyleSheets=document.adoptedStyleSheets.concat([n]),e.sheets[a]=n,e.order.push(a),p=!0}}catch{p=!1}if(!p){var o=document.createElement("style");o.setAttribute("data-useblocks","true"),o.appendChild(document.createTextNode(t)),document.head.appendChild(o),e.sheets[a]=o,e.order.push(a)}}}}catch(i){console.error("vite-plugin-css-injected-by-js",i)}})();
95
- __useblocks__.define("core",["require","exports","module","static/core/2ff39ddf.js","static/core/8782e9bb.js","static/core/10c6144f.js","static/core/cb7d16ff.js","static/core/68612347.js","react","react/jsx-runtime","__delivery__/libs","vite/preload-helper","react-dom/client","classnames","dayjs"],function(ve,nn,Nv){Object.defineProperties(nn,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const zt=ve("./static/core/2ff39ddf.js"),h=ve("./static/core/8782e9bb.js"),r=ve("./static/core/10c6144f.js"),xt=ve("./static/core/cb7d16ff.js"),yt=ve("./static/core/68612347.js");let l=ve("react");l=zt.__toESM(l);let a=ve("react/jsx-runtime"),_=ve("__delivery__/libs"),Ke=ve("vite/preload-helper"),tl=ve("react-dom/client"),rt=ve("classnames");rt=zt.__toESM(rt);let En=ve("dayjs");En=zt.__toESM(En);var nl="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function rl(){return h.createAbortError(nl)}function ol(e,t,n){if(typeof document>"u")return;let o=!1,i;const s=()=>{o=!0,i?.disconnect(),i=void 0},c=()=>{o||(s(),t())};if(n.addDispose(s),!e.isConnected){queueMicrotask(c);return}i=new MutationObserver(()=>{e.isConnected||c()});let d=e.parentNode;for(;d;)i.observe(d,{childList:!0}),d=d.parentNode}var il="-host-mount";function sl(){return`data-useblocks${il}`}function al(e,t){Array.from(e.children).forEach(n=>{n.nodeType===Node.ELEMENT_NODE&&n.hasAttribute(t)&&n.remove()})}function ll(e){const t=sl();al(e,t);const n=document.createElement("div");n.setAttribute(t,"true"),n.setAttribute("translate","no"),n.classList.add("notranslate"),n.style.display="block",n.style.width="100%",n.style.height="100%",n.style.minHeight="100%";const o=e.querySelector(":scope > [data-canvas-host]");return o?e.insertBefore(n,o):e.appendChild(n),n}function cl(e,t,n){n.addDispose(()=>{t.parentNode===e&&t.remove()})}function zn(e){return t=>{let n=null,o=!1;return{async setOptions(i){if(!n&&!o){n=await e(t);const s=await t.getInstanceAsync(h.INSTANCE_ID);Object.assign(s,n.instance||{})}n.setOptions&&await n.setOptions(i)},instance:{},dispose(){n?.dispose&&n?.dispose(),o=!0}}}}var dl=class{shadowRoot;markerAttr;observer;addedKeys=new Set;constructor({shadowRoot:e,markerAttr:t="data-useblocks"}){this.shadowRoot=e,this.markerAttr=t,this.observer=new MutationObserver(this.handleMutations),this.observer.observe(document.head,{childList:!0,subtree:!1}),this.syncExistingStyles()}syncExistingStyles(){const e=document.querySelectorAll(`style[${this.markerAttr}], link[${this.markerAttr}]`);for(let t=e.length-1;t>=0;t--)this.cloneAndInjectNode(e[t])}getNodeKey(e){return e.tagName==="STYLE"?(e.textContent||"").trim():e.tagName==="LINK"?e.href:null}cloneAndInjectNode(e){const t=this.getNodeKey(e);if(!t||this.addedKeys.has(t))return;const n=e.cloneNode(!0);this.shadowRoot.insertBefore(n,this.shadowRoot.firstChild),this.addedKeys.add(t)}handleMutations=e=>{for(const t of e)for(const n of t.addedNodes)n.nodeType===1&&(n instanceof HTMLStyleElement||n instanceof HTMLLinkElement)&&n.hasAttribute(this.markerAttr)&&this.cloneAndInjectNode(n)};dispose(){this.observer.disconnect(),this.addedKeys.clear()}};function ul({children:e}){return(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)("div",{className:"config-gate-fallback"}),children:e})}var pl=document.querySelectorAll("link[rel=stylesheet][media*=prefers-color-scheme][media*=dark]"),ml=document.querySelectorAll("link[rel=stylesheet][media*=prefers-color-scheme][media*=light]"),fl=e=>{if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&!/\s/.test(t)},gl=e=>{let t,n;e==="system"?(t=r.PREFERS_COLOR_SCHEME_LIGHT,n=r.PREFERS_COLOR_SCHEME_DARK):(t=e==="light"?"all":r.NOT_ALL,n=e==="dark"?"all":r.NOT_ALL),[...ml].forEach(o=>{o.media=t}),[...pl].forEach(o=>{o.media=n})},hl=(e={})=>{const t=document.querySelector("head"),n=document.createElement("style");if(n.type="text/css",n.dataset.themeVaribalse=!0,n.setAttribute("data-useblocks","true"),Object.entries(e).length){let o="";Object.entries(e).forEach(([s,c])=>{typeof c!="object"&&(o+=` ${r.themeTokenCssVarName(s)}: ${c};
95
+ __useblocks__.define("core",["require","exports","module","static/core/2ff39ddf.js","static/core/8782e9bb.js","static/core/10c6144f.js","static/core/cb7d16ff.js","static/core/68612347.js","react","react/jsx-runtime","__delivery__/libs","vite/preload-helper","react-dom/client","classnames","dayjs"],function(ve,nn,Bv){Object.defineProperties(nn,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const zt=ve("./static/core/2ff39ddf.js"),g=ve("./static/core/8782e9bb.js"),r=ve("./static/core/10c6144f.js"),xt=ve("./static/core/cb7d16ff.js"),yt=ve("./static/core/68612347.js");let l=ve("react");l=zt.__toESM(l);let a=ve("react/jsx-runtime"),_=ve("__delivery__/libs"),Ke=ve("vite/preload-helper"),tl=ve("react-dom/client"),rt=ve("classnames");rt=zt.__toESM(rt);let En=ve("dayjs");En=zt.__toESM(En);var nl="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function rl(){return g.createAbortError(nl)}function ol(e,t,n){if(typeof document>"u")return;let o=!1,i;const s=()=>{o=!0,i?.disconnect(),i=void 0},c=()=>{o||(s(),t())};if(n.addDispose(s),!e.isConnected){queueMicrotask(c);return}i=new MutationObserver(()=>{e.isConnected||c()});let d=e.parentNode;for(;d;)i.observe(d,{childList:!0}),d=d.parentNode}var il="-host-mount";function sl(){return`data-useblocks${il}`}function al(e,t){Array.from(e.children).forEach(n=>{n.nodeType===Node.ELEMENT_NODE&&n.hasAttribute(t)&&n.remove()})}function ll(e){const t=sl();al(e,t);const n=document.createElement("div");n.setAttribute(t,"true"),n.setAttribute("translate","no"),n.classList.add("notranslate"),n.style.display="block",n.style.width="100%",n.style.height="100%",n.style.minHeight="100%";const o=e.querySelector(":scope > [data-canvas-host]");return o?e.insertBefore(n,o):e.appendChild(n),n}function cl(e,t,n){n.addDispose(()=>{t.parentNode===e&&t.remove()})}function zn(e){return t=>{let n=null,o=!1;return{async setOptions(i){if(!n&&!o){n=await e(t);const s=await t.getInstanceAsync(g.INSTANCE_ID);Object.assign(s,n.instance||{})}n.setOptions&&await n.setOptions(i)},instance:{},dispose(){n?.dispose&&n?.dispose(),o=!0}}}}var dl=class{shadowRoot;markerAttr;observer;addedKeys=new Set;constructor({shadowRoot:e,markerAttr:t="data-useblocks"}){this.shadowRoot=e,this.markerAttr=t,this.observer=new MutationObserver(this.handleMutations),this.observer.observe(document.head,{childList:!0,subtree:!1}),this.syncExistingStyles()}syncExistingStyles(){const e=document.querySelectorAll(`style[${this.markerAttr}], link[${this.markerAttr}]`);for(let t=e.length-1;t>=0;t--)this.cloneAndInjectNode(e[t])}getNodeKey(e){return e.tagName==="STYLE"?(e.textContent||"").trim():e.tagName==="LINK"?e.href:null}cloneAndInjectNode(e){const t=this.getNodeKey(e);if(!t||this.addedKeys.has(t))return;const n=e.cloneNode(!0);this.shadowRoot.insertBefore(n,this.shadowRoot.firstChild),this.addedKeys.add(t)}handleMutations=e=>{for(const t of e)for(const n of t.addedNodes)n.nodeType===1&&(n instanceof HTMLStyleElement||n instanceof HTMLLinkElement)&&n.hasAttribute(this.markerAttr)&&this.cloneAndInjectNode(n)};dispose(){this.observer.disconnect(),this.addedKeys.clear()}};function ul(){let e,t,n=!1;const o=()=>{const i=e;!n||!i||i===t||(t=i,i.handleChunkLoaded?.())};return{use:i=>{e=i,o()},loaded:()=>{n=!0,o()}}}function pl({children:e}){return(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)("div",{className:"config-gate-fallback"}),children:e})}var ml=document.querySelectorAll("link[rel=stylesheet][media*=prefers-color-scheme][media*=dark]"),fl=document.querySelectorAll("link[rel=stylesheet][media*=prefers-color-scheme][media*=light]"),gl=e=>{if(typeof e!="string")return!1;const t=e.trim();return t.length>0&&!/\s/.test(t)},hl=e=>{let t,n;e==="system"?(t=r.PREFERS_COLOR_SCHEME_LIGHT,n=r.PREFERS_COLOR_SCHEME_DARK):(t=e==="light"?"all":r.NOT_ALL,n=e==="dark"?"all":r.NOT_ALL),[...fl].forEach(o=>{o.media=t}),[...ml].forEach(o=>{o.media=n})},_l=(e={})=>{const t=document.querySelector("head"),n=document.createElement("style");if(n.type="text/css",n.dataset.themeVaribalse=!0,n.setAttribute("data-useblocks","true"),Object.entries(e).length){let o="";Object.entries(e).forEach(([s,c])=>{typeof c!="object"&&(o+=` ${r.themeTokenCssVarName(s)}: ${c};
96
96
  `)}),o=`.blocks-body, .blocks-app, .ant-modal-root, .ant-tooltip, .ant-notification {
97
- ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-theme-varibalse="true"]');i?t.replaceChild(n,i):t.insertBefore(n,t.firstChild)}},_l=e=>{if(!fl(e))return;const t=e.trim(),n=document.body;n.classList.contains(t)||setTimeout(()=>{n.classList.remove(t==="dark"?r.LIGHT:r.DARK),n.classList.add(t)},200)},yl=()=>{const e=r.useSendPostMessage();return(0,l.useCallback)(()=>{const t=window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme),n=matchMedia("(prefers-color-scheme: dark)").matches?r.DARK:r.LIGHT,o=t||n;e({operation:r.EVENT_TYPES.UPDATE_PREVIEW,theme:o})},[e])},Gt={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},Dv={defaultMerge:Gt.defaultMerge};function vl(e,t){return t}function Zo(e){return typeof e!="object"||e===null?0:Array.isArray(e)?2:Sl(e)?1:e instanceof Set?3:e instanceof Map?4:5}function bl(e){const t=new Set;for(const n of e)for(const o of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(o);return t}function El(e,t){return typeof e=="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function ei(e){return{*[Symbol.iterator](){for(const t of e)for(const n of t)yield n}}}var ti=new Set(["[object Object]","[object Module]"]);function Sl(e){if(!ti.has(Object.prototype.toString.call(e)))return!1;const{constructor:t}=e;if(t===void 0)return!0;const n=t.prototype;return!(n===null||typeof n!="object"||!ti.has(Object.prototype.toString.call(n))||!n.hasOwnProperty("isPrototypeOf"))}function wl(e,t,n){const o={};for(const i of bl(e)){const s=[];for(const d of e)El(d,i)&&s.push(d[i]);if(s.length===0)continue;const c=ri(s,t,t.metaDataUpdater(n,{key:i,parents:e}));c!==Gt.skip&&(i==="__proto__"?Object.defineProperty(o,i,{value:c,configurable:!0,enumerable:!0,writable:!0}):o[i]=c)}return o}function kl(e){return e.flat()}function Cl(e){return new Set(ei(e))}function Tl(e){return new Map(ei(e))}function ni(e){return e.at(-1)}var Gr=Object.freeze({__proto__:null,mergeArrays:kl,mergeMaps:Tl,mergeOthers:ni,mergeRecords:wl,mergeSets:Cl});function Wr(...e){return Il({})(...e)}function Il(e,t){const n=Al(e,o);function o(...i){return ri(i,n,t)}return o}function Al(e,t){return{defaultMergeFunctions:Gr,mergeFunctions:{...Gr,...Object.fromEntries(Object.entries(e).filter(([n,o])=>Object.hasOwn(Gr,n)).map(([n,o])=>o===!1?[n,ni]:[n,o]))},metaDataUpdater:e.metaDataUpdater??vl,deepmerge:t,useImplicitDefaultMerging:e.enableImplicitDefaultMerging??!1,actions:Gt}}function ri(e,t,n){if(e.length===0)return;if(e.length===1)return Hr(e,t,n);const o=Zo(e[0]);if(o!==0&&o!==5){for(let i=1;i<e.length;i++)if(Zo(e[i])!==o)return Hr(e,t,n)}switch(o){case 1:return xl(e,t,n);case 2:return Pl(e,t,n);case 3:return jl(e,t,n);case 4:return Rl(e,t,n);default:return Hr(e,t,n)}}function xl(e,t,n){const o=t.mergeFunctions.mergeRecords(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):o}function Pl(e,t,n){const o=t.mergeFunctions.mergeArrays(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):o}function jl(e,t,n){const o=t.mergeFunctions.mergeSets(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):o}function Rl(e,t,n){const o=t.mergeFunctions.mergeMaps(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):o}function Hr(e,t,n){const o=t.mergeFunctions.mergeOthers(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):o}function Ol(e){r.requiredArgs(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||r._typeof(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):new Date(NaN)}function Ll(e){const t=new Map,n=new Set;let o=null,i=null;const s=(d,u)=>{const p={participantId:d.participant.id,acknowledgedVersion:d.acknowledged,documentVersion:e.get().version,error:u};n.forEach(f=>f(p))},c=d=>{if(d.detached)return;const u=e.get().version;if(d.acknowledged===u||d.skipVersion===u)return;if(d.pushing){d.stale=!0;return}d.pushing=!0;const{attributes:p}=e.get(),f=d.participant.applyChanges&&i?.version===u&&d.acknowledged===u-1?i:null;(f?d.participant.applyChanges(f.changes,u,p):d.participant.apply(e.getContent(),u,p)).then(()=>{d.acknowledged=u}).catch(g=>{s(d,g)}).finally(()=>{d.pushing=!1,d.stale&&(d.stale=!1,c(d))})};return e.subscribe(({version:d,changes:u})=>{i=u?.length?{version:d,changes:u}:null,t.forEach(c)}),{attach(d){const u={participant:d,acknowledged:null,pushing:!1,stale:!1,detached:!1,skipVersion:null};return t.set(d.id,u),c(u),{acknowledgedVersion:()=>u.acknowledged,reset(){u.acknowledged=null,u.skipVersion=null,c(u)},detach(){u.detached=!0,t.delete(d.id)}}},setPrimacy(d){o=d},getPrimacy:()=>o,mutateFrom(d,u,p){const f=t.get(d);if(p.echo!==!0&&o!==null&&o!==d)return f?.participant.dropUnsent?.(),null;const g=e.get().version;f&&(f.skipVersion=g+1);const y=e.mutate(u,{source:p.source});return f&&y===g?f.skipVersion=null:f&&(f.acknowledged=y),y},onOutOfSync(d){return n.add(d),()=>n.delete(d)}}}var Ml=({children:e})=>{const[t,n]=(0,l.useState)([]),o=r.useEvent(h.MODAL_SHOW_EVENT),i=r.useEvent(h.MODAL_CLOSE_EVENT),s=r.useEvent(h.MODAL_UPDATE_EVENT),c=r.useModalRootElement(),d=(0,l.useCallback)(g=>{n(y=>g===void 0?[]:y.filter(m=>m.id!==g))},[n]),u=(0,l.useCallback)(g=>{n(y=>{const m=y.find(S=>S.id===g.id);return m?y.map(S=>S===m?{...S,...m}:S):[...y,{...g,visible:!0}]})},[n]),p=(0,l.useCallback)(g=>{n(y=>{const m=y.find(S=>S.id===g.id);return m?y.map(S=>S===m?{...S,...m}:S):y})},[n]),f=(0,l.useCallback)(()=>c,[c]);return(0,l.useEffect)(()=>{const g=new h.Disposable;return g.addDisposable(o(u)),g.addDisposable(s(p)),g.addDisposable(i(d)),()=>g.dispose()},[o,i,s,u,d,p]),(0,a.jsxs)(a.Fragment,{children:[t.map(({id:g,content:y,props:m,visible:S,onOk:k,onClose:w,modalProps:b,...A})=>{const x=()=>d(g),Y=async()=>{k&&await k(),d(g)};return(0,a.jsx)(_.ui_kit$Modal,{open:S,onCancel:x,onOk:Y,afterClose:w,getContainer:f,...b,...A,children:typeof y!="function"?y:l.default.createElement(y,m)},g)}),e]})},Nl=new Set;function oi(e){const t=typeof e=="string"&&e?e:void 0;t?window.localStorage.setItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme,t):window.localStorage.removeItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme);for(const n of Nl)n(t)}var Dl=[(0,_.ui_kit$createTransformer)()],Fl={colorDarken1:"rgba(0, 0, 0, 0.08)",colorFillSecondaryDarken:"rgba(0, 0, 0, 0.1)",formControlHeight:34,borderWidth:1,borderColorHover:"#C5C5C5",formItemMarginBottomMD:20,formItemMarginBottomXS:8,colorSecondaryH:265.03,colorSecondaryS:"63.92%",colorSecondaryL:"50%",colorSecondaryBgH:273,colorSecondaryBgS:"100%",colorSecondaryBgL:"93%",appZoom:1},Bl={colorDarken1:"rgba(0, 0, 0, 0.9)",colorFillSecondaryDarken:"rgba(255, 255, 255, 0.16)",formControlHeight:34,borderWidth:1,borderColorHover:"rgba(255, 255, 255, 0.3)",formItemMarginBottomMD:20,formItemMarginBottomXS:8,appZoom:1},$l=Wr(_.ui_kit$lightThemePreset,{token:Fl}),Ul=Wr(_.ui_kit$darkThemePreset,{token:Bl});function zl({children:e}){const t=r.useSelector(r.selectEditorThemeColor$1),n=(0,l.useMemo)(()=>matchMedia("(prefers-color-scheme: dark)").matches?r.DARK:r.LIGHT,[]),o=r.useAppConfig(),[i,s]=(0,l.useState)(o.theme||n),c=r.useDispatch(),d=yl();(0,l.useEffect)(()=>{const k=o.theme||n;s(k),_l(k),c(r.setEditorThemeColor$1(k==="dark"?`vs-${k}`:r.LIGHT)),d()},[t,n,o.theme,o.pathEnabled,c,d]);const u=(0,l.useCallback)(k=>{k&&k!=="system"?(gl(k),oi(k)):oi(void 0)},[]);(0,l.useEffect)(()=>{const k=o.theme,w=localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme);k&&k!==w&&u(k)},[o.theme,u]);const p=(0,l.useCallback)(()=>{const k=localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme);u(k)},[u]);(0,l.useEffect)(()=>{p()},[p]);const f=o.themes,[g]=(0,l.useState)(1),y=(0,l.useMemo)(()=>{const k=i==="light"?$l:Ul,w=f[i],b=w?Wr(k,w):k;return{...b,token:{...b.token,appZoom:g}}},[i,f,g]),m=r.useModalRootElement(),S=(0,l.useCallback)(()=>m,[m]);return(0,a.jsx)(_.ui_kit$ThemeProvider,{theme:y,getPopupContainer:S,children:(0,a.jsx)(_.ui_kit$StyleProvider,{transformers:Dl,children:(0,a.jsx)(Ml,{children:(0,a.jsx)(_.ui_kit$App,{children:(0,a.jsx)(r.ImagePickerProvider,{children:e})})})})})}var Gl=({onLoad:e,children:t})=>{(0,l.useEffect)(()=>{e&&e()},[e]);const n=r.useAppDispatch();return(0,l.useEffect)(()=>{n(r.authorizationApi.endpoints.getMe.initiate(""))},[n]),t};function ii({title:e,content:t,acf:{seen:n,type:o,event:i,data:s},...c}){return{...c,seen:n,type:o,event:i,data:s,title:r.getRendererString(e),content:t}}var Sn="Notifications",Gn=r.createApi({reducerPath:"notificationsApi",tagTypes:[Sn],baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/wp-json/wp/v2/"}),endpoints:e=>({getNotifications:e.query({queryFn(t,n){return r.clientFromApi(n).wp.notification_list({author:[Number(t)]}).then(r.transformListResponseFn(ii))},providesTags:t=>t?[...t.map(({id:n})=>({type:Sn,id:n})),{type:Sn,id:"LIST"}]:[{type:Sn,id:"LIST"}]}),notificationShown:e.mutation({queryFn({id:t,datetime:n},o){return r.clientFromApi(o).wp.notification_create2({id:t},{},{type:h.ContentType.Json,extraQuery:{"acf[seen]":n}}).then(r.transformResponseFn(ii))},invalidatesTags:[{type:Sn,id:"LIST"}]})})}),{useGetNotificationsQuery:Wl,useNotificationShownMutation:Hl}=Gn,ql=()=>{const e=r.useCookieManager(),t=r.useContainer(),n=r.useRoutePathname();(0,l.useEffect)(()=>{n.endsWith("/new")||e.remove(r.APP_COOKIES.em_new_email)},[n,e,t])},Vl=()=>{const e=r.useCookieManager(),t=r.useRoutePathname();(0,l.useEffect)(()=>{t.endsWith("/new")||e.remove(r.APP_COOKIES.em_new_block)},[t,e])},si="em_notification_mark_seen_skipped_ids";function ai(){try{const e=sessionStorage.getItem(si),t=e?JSON.parse(e):[];return Array.isArray(t)?t.map(String):[]}catch{return[]}}function Kl(e){try{const t=String(e),n=new Set(ai());n.has(t)||(n.add(t),sessionStorage.setItem(si,JSON.stringify([...n])))}catch{}}var Yl=({children:e=void 0,sider:t=null,modals:n=null,hasEmail:o=!1,hasBlock:i=!1})=>{const{token:s}=(0,_.ui_kit$useToken)(),c=r.useDispatch(),d=r.useSelector(r.selectActiveModal$1),u=r.useCurrentUser();r.useSelector(r.selectIsCodeMode);const p=r.usePushToDataLayer(),[f]=Hl(),g=r.useNotification();(0,l.useEffect)(()=>{hl(s)},[s]);const{data:y=[],isSuccess:m}=Wl(u?.id??"",{pollingInterval:3e5,skip:!!d||!u?.id});return(0,l.useEffect)(()=>{const S=y.filter(k=>k.seen===""||k.seen===null);setTimeout(()=>{if(S.length&&m){const k=new Set(ai());S.forEach(w=>{if(k.has(String(w.id)))return;w.event==="subscription_payment"&&p({event:"payment",data:w.data}),g[w.type]({title:w.title?.rendered||w.title||"",description:w.content?.rendered||""});const b=new Date().toLocaleString();f({id:w.id,datetime:b}).unwrap().catch(A=>{const x=A&&typeof A=="object"?A:{};(x.data&&typeof x.data=="object"&&x.data!==null&&"code"in x.data?String(x.data.code):void 0)==="em_rest_notification_403"&&Kl(w.id)})})}},5e3)},[m,f,y,g]),ql(),Vl(),(0,l.useEffect)(()=>{i||c(r.resetBlockSlice()),o||c(r.resetEmailSlice())},[i,o,c]),(0,a.jsx)("div",{className:"main",children:(0,a.jsx)("div",{className:"main__pane main__pane_main",children:(0,a.jsx)("div",{className:"main__pane-content",id:"pane-content-iframe","data-scroll-area":"page",children:(0,a.jsxs)(_.ui_kit$Layout,{className:"main__pane-layout",hasSider:!!t,children:[t,n,e??(0,a.jsx)(r.RouteOutlet,{})]})})})})},Ql={toggle:()=>{},set:()=>{},setDirection:()=>{}};function qr(){const e=r.useContainer();return(0,l.useMemo)(()=>e?{toggle:()=>r.toggleCodeMode(e),set:t=>r.setCodeMode$1(e,t),setDirection:t=>r.setCodeModeDirection(e,t)}:Ql,[e])}var Xl=`
97
+ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-theme-varibalse="true"]');i?t.replaceChild(n,i):t.insertBefore(n,t.firstChild)}},yl=e=>{if(!gl(e))return;const t=e.trim(),n=document.body;n.classList.contains(t)||setTimeout(()=>{n.classList.remove(t==="dark"?r.LIGHT:r.DARK),n.classList.add(t)},200)},vl=()=>{const e=r.useSendPostMessage();return(0,l.useCallback)(()=>{const t=window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme),n=matchMedia("(prefers-color-scheme: dark)").matches?r.DARK:r.LIGHT,o=t||n;e({operation:r.EVENT_TYPES.UPDATE_PREVIEW,theme:o})},[e])},Gt={defaultMerge:Symbol("deepmerge-ts: default merge"),skip:Symbol("deepmerge-ts: skip")},$v={defaultMerge:Gt.defaultMerge};function bl(e,t){return t}function ei(e){return typeof e!="object"||e===null?0:Array.isArray(e)?2:wl(e)?1:e instanceof Set?3:e instanceof Map?4:5}function El(e){const t=new Set;for(const n of e)for(const o of[...Object.keys(n),...Object.getOwnPropertySymbols(n)])t.add(o);return t}function Sl(e,t){return typeof e=="object"&&Object.prototype.propertyIsEnumerable.call(e,t)}function ti(e){return{*[Symbol.iterator](){for(const t of e)for(const n of t)yield n}}}var ni=new Set(["[object Object]","[object Module]"]);function wl(e){if(!ni.has(Object.prototype.toString.call(e)))return!1;const{constructor:t}=e;if(t===void 0)return!0;const n=t.prototype;return!(n===null||typeof n!="object"||!ni.has(Object.prototype.toString.call(n))||!n.hasOwnProperty("isPrototypeOf"))}function kl(e,t,n){const o={};for(const i of El(e)){const s=[];for(const d of e)Sl(d,i)&&s.push(d[i]);if(s.length===0)continue;const c=oi(s,t,t.metaDataUpdater(n,{key:i,parents:e}));c!==Gt.skip&&(i==="__proto__"?Object.defineProperty(o,i,{value:c,configurable:!0,enumerable:!0,writable:!0}):o[i]=c)}return o}function Tl(e){return e.flat()}function Cl(e){return new Set(ti(e))}function Il(e){return new Map(ti(e))}function ri(e){return e.at(-1)}var Gr=Object.freeze({__proto__:null,mergeArrays:Tl,mergeMaps:Il,mergeOthers:ri,mergeRecords:kl,mergeSets:Cl});function Wr(...e){return Al({})(...e)}function Al(e,t){const n=xl(e,o);function o(...i){return oi(i,n,t)}return o}function xl(e,t){return{defaultMergeFunctions:Gr,mergeFunctions:{...Gr,...Object.fromEntries(Object.entries(e).filter(([n,o])=>Object.hasOwn(Gr,n)).map(([n,o])=>o===!1?[n,ri]:[n,o]))},metaDataUpdater:e.metaDataUpdater??bl,deepmerge:t,useImplicitDefaultMerging:e.enableImplicitDefaultMerging??!1,actions:Gt}}function oi(e,t,n){if(e.length===0)return;if(e.length===1)return Hr(e,t,n);const o=ei(e[0]);if(o!==0&&o!==5){for(let i=1;i<e.length;i++)if(ei(e[i])!==o)return Hr(e,t,n)}switch(o){case 1:return Pl(e,t,n);case 2:return Rl(e,t,n);case 3:return Ol(e,t,n);case 4:return jl(e,t,n);default:return Hr(e,t,n)}}function Pl(e,t,n){const o=t.mergeFunctions.mergeRecords(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeRecords!==t.defaultMergeFunctions.mergeRecords?t.defaultMergeFunctions.mergeRecords(e,t,n):o}function Rl(e,t,n){const o=t.mergeFunctions.mergeArrays(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeArrays!==t.defaultMergeFunctions.mergeArrays?t.defaultMergeFunctions.mergeArrays(e):o}function Ol(e,t,n){const o=t.mergeFunctions.mergeSets(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeSets!==t.defaultMergeFunctions.mergeSets?t.defaultMergeFunctions.mergeSets(e):o}function jl(e,t,n){const o=t.mergeFunctions.mergeMaps(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeMaps!==t.defaultMergeFunctions.mergeMaps?t.defaultMergeFunctions.mergeMaps(e):o}function Hr(e,t,n){const o=t.mergeFunctions.mergeOthers(e,t,n);return o===Gt.defaultMerge||t.useImplicitDefaultMerging&&o===void 0&&t.mergeFunctions.mergeOthers!==t.defaultMergeFunctions.mergeOthers?t.defaultMergeFunctions.mergeOthers(e):o}function Ll(e){r.requiredArgs(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||r._typeof(e)==="object"&&t==="[object Date]"?new Date(e.getTime()):typeof e=="number"||t==="[object Number]"?new Date(e):new Date(NaN)}function Ml(e){const t=new Map,n=new Set;let o=null,i=null;const s=(d,u)=>{const p={participantId:d.participant.id,acknowledgedVersion:d.acknowledged,documentVersion:e.get().version,error:u};n.forEach(f=>f(p))},c=d=>{if(d.detached)return;const u=e.get().version;if(d.acknowledged===u||d.skipVersion===u)return;if(d.pushing){d.stale=!0;return}d.pushing=!0;const{attributes:p}=e.get(),f=d.participant.applyChanges&&i?.version===u&&d.acknowledged===u-1?i:null;(f?d.participant.applyChanges(f.changes,u,p):d.participant.apply(e.getContent(),u,p)).then(()=>{d.acknowledged=u}).catch(h=>{s(d,h)}).finally(()=>{d.pushing=!1,d.stale&&(d.stale=!1,c(d))})};return e.subscribe(({version:d,changes:u})=>{i=u?.length?{version:d,changes:u}:null,t.forEach(c)}),{attach(d){const u={participant:d,acknowledged:null,pushing:!1,stale:!1,detached:!1,skipVersion:null};return t.set(d.id,u),c(u),{acknowledgedVersion:()=>u.acknowledged,reset(){u.acknowledged=null,u.skipVersion=null,c(u)},detach(){u.detached=!0,t.delete(d.id)}}},setPrimacy(d){o=d},getPrimacy:()=>o,mutateFrom(d,u,p){const f=t.get(d);if(p.echo!==!0&&o!==null&&o!==d)return f?.participant.dropUnsent?.(),null;const h=e.get().version;f&&(f.skipVersion=h+1);const y=e.mutate(u,{source:p.source});return f&&y===h?f.skipVersion=null:f&&(f.acknowledged=y),y},onOutOfSync(d){return n.add(d),()=>n.delete(d)}}}var Nl=({children:e})=>{const[t,n]=(0,l.useState)([]),o=r.useEvent(g.MODAL_SHOW_EVENT),i=r.useEvent(g.MODAL_CLOSE_EVENT),s=r.useEvent(g.MODAL_UPDATE_EVENT),c=r.useModalRootElement(),d=(0,l.useCallback)(h=>{n(y=>h===void 0?[]:y.filter(m=>m.id!==h))},[n]),u=(0,l.useCallback)(h=>{n(y=>{const m=y.find(E=>E.id===h.id);return m?y.map(E=>E===m?{...E,...m}:E):[...y,{...h,visible:!0}]})},[n]),p=(0,l.useCallback)(h=>{n(y=>{const m=y.find(E=>E.id===h.id);return m?y.map(E=>E===m?{...E,...m}:E):y})},[n]),f=(0,l.useCallback)(()=>c,[c]);return(0,l.useEffect)(()=>{const h=new g.Disposable;return h.addDisposable(o(u)),h.addDisposable(s(p)),h.addDisposable(i(d)),()=>h.dispose()},[o,i,s,u,d,p]),(0,a.jsxs)(a.Fragment,{children:[t.map(({id:h,content:y,props:m,visible:E,onOk:T,onClose:w,modalProps:S,...I})=>{const x=()=>d(h),K=async()=>{T&&await T(),d(h)};return(0,a.jsx)(_.ui_kit$Modal,{open:E,onCancel:x,onOk:K,afterClose:w,getContainer:f,...S,...I,children:typeof y!="function"?y:l.default.createElement(y,m)},h)}),e]})},Dl=new Set;function ii(e){const t=typeof e=="string"&&e?e:void 0;t?window.localStorage.setItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme,t):window.localStorage.removeItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme);for(const n of Dl)n(t)}var Fl=[(0,_.ui_kit$createTransformer)()],Bl={colorDarken1:"rgba(0, 0, 0, 0.08)",colorFillSecondaryDarken:"rgba(0, 0, 0, 0.1)",formControlHeight:34,borderWidth:1,borderColorHover:"#C5C5C5",formItemMarginBottomMD:20,formItemMarginBottomXS:8,colorSecondaryH:265.03,colorSecondaryS:"63.92%",colorSecondaryL:"50%",colorSecondaryBgH:273,colorSecondaryBgS:"100%",colorSecondaryBgL:"93%",appZoom:1},$l={colorDarken1:"rgba(0, 0, 0, 0.9)",colorFillSecondaryDarken:"rgba(255, 255, 255, 0.16)",formControlHeight:34,borderWidth:1,borderColorHover:"rgba(255, 255, 255, 0.3)",formItemMarginBottomMD:20,formItemMarginBottomXS:8,appZoom:1},Ul=Wr(_.ui_kit$lightThemePreset,{token:Bl}),zl=Wr(_.ui_kit$darkThemePreset,{token:$l});function Gl({children:e}){const t=r.useSelector(r.selectEditorThemeColor$1),n=(0,l.useMemo)(()=>matchMedia("(prefers-color-scheme: dark)").matches?r.DARK:r.LIGHT,[]),o=r.useAppConfig(),[i,s]=(0,l.useState)(o.theme||n),c=r.useDispatch(),d=vl();(0,l.useEffect)(()=>{const T=o.theme||n;s(T),yl(T),c(r.setEditorThemeColor$1(T==="dark"?`vs-${T}`:r.LIGHT)),d()},[t,n,o.theme,o.pathEnabled,c,d]);const u=(0,l.useCallback)(T=>{T&&T!=="system"?(hl(T),ii(T)):ii(void 0)},[]);(0,l.useEffect)(()=>{const T=o.theme,w=localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme);T&&T!==w&&u(T)},[o.theme,u]);const p=(0,l.useCallback)(()=>{const T=localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_color_scheme);u(T)},[u]);(0,l.useEffect)(()=>{p()},[p]);const f=o.themes,[h]=(0,l.useState)(1),y=(0,l.useMemo)(()=>{const T=i==="light"?Ul:zl,w=f[i],S=w?Wr(T,w):T;return{...S,token:{...S.token,appZoom:h}}},[i,f,h]),m=r.useModalRootElement(),E=(0,l.useCallback)(()=>m,[m]);return(0,a.jsx)(_.ui_kit$ThemeProvider,{theme:y,getPopupContainer:E,children:(0,a.jsx)(_.ui_kit$StyleProvider,{transformers:Fl,children:(0,a.jsx)(Nl,{children:(0,a.jsx)(_.ui_kit$App,{children:(0,a.jsx)(r.ImagePickerProvider,{children:e})})})})})}var Wl=({onLoad:e,children:t})=>{(0,l.useEffect)(()=>{e&&e()},[e]);const n=r.useAppDispatch();return(0,l.useEffect)(()=>{n(r.authorizationApi.endpoints.getMe.initiate(""))},[n]),t};function si({title:e,content:t,acf:{seen:n,type:o,event:i,data:s},...c}){return{...c,seen:n,type:o,event:i,data:s,title:r.getRendererString(e),content:t}}var Sn="Notifications",Gn=r.createApi({reducerPath:"notificationsApi",tagTypes:[Sn],baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/wp-json/wp/v2/"}),endpoints:e=>({getNotifications:e.query({queryFn(t,n){return r.clientFromApi(n).wp.notification_list({author:[Number(t)]}).then(r.transformListResponseFn(si))},providesTags:t=>t?[...t.map(({id:n})=>({type:Sn,id:n})),{type:Sn,id:"LIST"}]:[{type:Sn,id:"LIST"}]}),notificationShown:e.mutation({queryFn({id:t,datetime:n},o){return r.clientFromApi(o).wp.notification_create2({id:t},{},{type:g.ContentType.Json,extraQuery:{"acf[seen]":n}}).then(r.transformResponseFn(si))},invalidatesTags:[{type:Sn,id:"LIST"}]})})}),{useGetNotificationsQuery:Hl,useNotificationShownMutation:ql}=Gn,Vl=()=>{const e=r.useCookieManager(),t=r.useContainer(),n=r.useRoutePathname();(0,l.useEffect)(()=>{n.endsWith("/new")||e.remove(r.APP_COOKIES.em_new_email)},[n,e,t])},Kl=()=>{const e=r.useCookieManager(),t=r.useRoutePathname();(0,l.useEffect)(()=>{t.endsWith("/new")||e.remove(r.APP_COOKIES.em_new_block)},[t,e])},ai="em_notification_mark_seen_skipped_ids";function li(){try{const e=sessionStorage.getItem(ai),t=e?JSON.parse(e):[];return Array.isArray(t)?t.map(String):[]}catch{return[]}}function Yl(e){try{const t=String(e),n=new Set(li());n.has(t)||(n.add(t),sessionStorage.setItem(ai,JSON.stringify([...n])))}catch{}}var Ql=({children:e=void 0,sider:t=null,modals:n=null,hasEmail:o=!1,hasBlock:i=!1})=>{const{token:s}=(0,_.ui_kit$useToken)(),c=r.useDispatch(),d=r.useSelector(r.selectActiveModal$1),u=r.useCurrentUser();r.useSelector(r.selectIsCodeMode);const p=r.usePushToDataLayer(),[f]=ql(),h=r.useNotification();(0,l.useEffect)(()=>{_l(s)},[s]);const{data:y=[],isSuccess:m}=Hl(u?.id??"",{pollingInterval:3e5,skip:!!d||!u?.id});return(0,l.useEffect)(()=>{const E=y.filter(T=>T.seen===""||T.seen===null);setTimeout(()=>{if(E.length&&m){const T=new Set(li());E.forEach(w=>{if(T.has(String(w.id)))return;w.event==="subscription_payment"&&p({event:"payment",data:w.data}),h[w.type]({title:w.title?.rendered||w.title||"",description:w.content?.rendered||""});const S=new Date().toLocaleString();f({id:w.id,datetime:S}).unwrap().catch(I=>{const x=I&&typeof I=="object"?I:{};(x.data&&typeof x.data=="object"&&x.data!==null&&"code"in x.data?String(x.data.code):void 0)==="em_rest_notification_403"&&Yl(w.id)})})}},5e3)},[m,f,y,h]),Vl(),Kl(),(0,l.useEffect)(()=>{i||c(r.resetBlockSlice()),o||c(r.resetEmailSlice())},[i,o,c]),(0,a.jsx)("div",{className:"main",children:(0,a.jsx)("div",{className:"main__pane main__pane_main",children:(0,a.jsx)("div",{className:"main__pane-content",id:"pane-content-iframe","data-scroll-area":"page",children:(0,a.jsxs)(_.ui_kit$Layout,{className:"main__pane-layout",hasSider:!!t,children:[t,n,e??(0,a.jsx)(r.RouteOutlet,{})]})})})})},Xl={toggle:()=>{},set:()=>{},setDirection:()=>{}};function qr(){const e=r.useContainer();return(0,l.useMemo)(()=>e?{toggle:()=>r.toggleCodeMode(e),set:t=>r.setCodeMode$1(e,t),setDirection:t=>r.setCodeModeDirection(e,t)}:Xl,[e])}var Jl=`
98
98
  <style>
99
99
  @media only screen and (max-device-width: 660px), only screen and (max-width: 660px) {
100
100
  .em-mob-width-100perc {
@@ -141,7 +141,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
141
141
  </td>
142
142
  </tr>
143
143
 
144
- `,Jl=`
144
+ `,Zl=`
145
145
  <style>
146
146
  @media only screen and (max-device-width: 660px), only screen and (max-width: 660px) {
147
147
  .em-mob-width-100perc {
@@ -197,7 +197,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
197
197
  </td>
198
198
  </tr>
199
199
 
200
- `,Zl=`
200
+ `,ec=`
201
201
  <style>
202
202
  @media only screen and (max-device-width: 660px), only screen and (max-width: 660px) {
203
203
  .em-mob-width-100perc {
@@ -253,7 +253,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
253
253
  </td>
254
254
  </tr>
255
255
 
256
- `,ec=`
256
+ `,tc=`
257
257
  <style>
258
258
  @media only screen and (max-device-width: 660px), only screen and (max-width: 660px) {
259
259
  .em-mob-width-100perc {
@@ -309,7 +309,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
309
309
  </td>
310
310
  </tr>
311
311
 
312
- `,tc=`
312
+ `,nc=`
313
313
  <style>
314
314
  @media only screen and (max-device-width: 660px), only screen and (max-width: 660px) {
315
315
  .em-mob-width-100perc {
@@ -374,7 +374,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
374
374
  </td>
375
375
  </tr>
376
376
 
377
- `,nc=`
377
+ `,rc=`
378
378
  <style>
379
379
  @media only screen and (max-device-width: 660px), only screen and (max-width: 660px) {
380
380
  .em-mob-width-100perc {
@@ -434,7 +434,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
434
434
  </td>
435
435
  </tr>
436
436
 
437
- `,li=[{sizeArray:[24],name:"column-one",html:Xl},{sizeArray:[12,12],name:"column-two-50",html:ec},{sizeArray:[8,8,8],name:"column-three",html:tc},{sizeArray:[6,6,6,6],name:"column-four",html:nc},{sizeArray:[8,16],name:"column-two-33",html:Jl},{sizeArray:[16,8],name:"column-two-66",html:Zl}],ci=()=>{const e=xt.useSetHtmlElementInIframeHandler(),t=xt.useDragStartBlockToIframeHandler();return(0,a.jsx)("div",{className:"structures blocks-search__empty-wrapper",children:(0,a.jsx)("div",{className:"structures__list",children:(0,a.jsx)("div",{children:li&&li.map(n=>(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"structures__item",draggable:!0,onClick:o=>e(o,n.html,void 0,n.name,{id:n.name,title:n.name,type:"structure"}),onDragStart:o=>t(o,n.html,void 0,n.name,{id:n.name,title:n.name,type:"structure"}),children:(0,a.jsx)(_.ui_kit$Row,{gutter:[6,6],className:"structures__item-row",children:n.sizeArray.map((o,i)=>(0,a.jsx)(_.ui_kit$Col,{span:o,children:(0,a.jsx)("div",{className:"structures__item-col"})},n.name+i))})})},n.name))})})})};ci.propTypes={};var rc=`<style em="styles">
437
+ `,ci=[{sizeArray:[24],name:"column-one",html:Jl},{sizeArray:[12,12],name:"column-two-50",html:tc},{sizeArray:[8,8,8],name:"column-three",html:nc},{sizeArray:[6,6,6,6],name:"column-four",html:rc},{sizeArray:[8,16],name:"column-two-33",html:Zl},{sizeArray:[16,8],name:"column-two-66",html:ec}],di=()=>{const e=xt.useSetHtmlElementInIframeHandler(),t=xt.useDragStartBlockToIframeHandler();return(0,a.jsx)("div",{className:"structures blocks-search__empty-wrapper",children:(0,a.jsx)("div",{className:"structures__list",children:(0,a.jsx)("div",{children:ci&&ci.map(n=>(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"structures__item",draggable:!0,onClick:o=>e(o,n.html,void 0,n.name,{id:n.name,title:n.name,type:"structure"}),onDragStart:o=>t(o,n.html,void 0,n.name,{id:n.name,title:n.name,type:"structure"}),children:(0,a.jsx)(_.ui_kit$Row,{gutter:[6,6],className:"structures__item-row",children:n.sizeArray.map((o,i)=>(0,a.jsx)(_.ui_kit$Col,{span:o,children:(0,a.jsx)("div",{className:"structures__item-col"})},n.name+i))})})},n.name))})})})};di.propTypes={};var oc=`<style em="styles">
438
438
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
439
439
  .em-mob-width-100perc {
440
440
  width: 100%!important;
@@ -462,7 +462,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
462
462
  </tr>
463
463
  </table>
464
464
  </td>
465
- </tr>`,oc=`<style em="styles">
465
+ </tr>`,ic=`<style em="styles">
466
466
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
467
467
  .em-mob-width-100perc {
468
468
  width: 100%!important;
@@ -496,7 +496,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
496
496
  </tr>
497
497
  </table>
498
498
  </td>
499
- </tr>`,ic=`<style em="styles">
499
+ </tr>`,sc=`<style em="styles">
500
500
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
501
501
  .em-mob-width-100perc {
502
502
  width: 100%!important;
@@ -530,7 +530,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
530
530
  </tr>
531
531
  </table>
532
532
  </td>
533
- </tr>`,sc=`<style em="styles">
533
+ </tr>`,ac=`<style em="styles">
534
534
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
535
535
  .em-mob-width-100perc {
536
536
  width: 100%!important;
@@ -564,7 +564,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
564
564
  </tr>
565
565
  </table>
566
566
  </td>
567
- </tr>`,ac=`<style em="styles">
567
+ </tr>`,lc=`<style em="styles">
568
568
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
569
569
  .em-mob-width-100perc {
570
570
  width: 100%!important;
@@ -600,7 +600,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
600
600
  </tr>
601
601
  </table>
602
602
  </td>
603
- </tr>`,lc=`<style em="styles">
603
+ </tr>`,cc=`<style em="styles">
604
604
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
605
605
  .em-mob-width-100perc {
606
606
  width: 100%!important;
@@ -638,7 +638,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
638
638
  </tr>
639
639
  </table>
640
640
  </td>
641
- </tr>`,di=[{sizeArray:[24],name:"column-one",html:rc},{sizeArray:[12,12],name:"column-two-50",html:sc},{sizeArray:[8,8,8],name:"column-three",html:ac},{sizeArray:[6,6,6,6],name:"column-four",html:lc},{sizeArray:[8,16],name:"column-two-33",html:oc},{sizeArray:[16,8],name:"column-two-66",html:ic}],ui=()=>{const e=xt.useSetHtmlElementInIframeHandler(),t=xt.useDragStartBlockToIframeHandler();return(0,a.jsx)("div",{className:"structures blocks-search__empty-wrapper",children:(0,a.jsx)("div",{className:"structures__list",children:(0,a.jsx)("div",{children:di&&di.map(n=>(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"structures__item",draggable:!0,onClick:o=>e(o,n.html,void 0,n.name,{id:n.name,title:n.name,type:"structure"}),onDragStart:o=>t(o,n.html,void 0,n.name,{id:n.name,title:n.name,type:"structure"}),children:(0,a.jsx)(_.ui_kit$Row,{gutter:[6,6],className:"structures__item-row",children:n.sizeArray.map((o,i)=>(0,a.jsx)(_.ui_kit$Col,{span:o,children:(0,a.jsx)("div",{className:"structures__item-col"})},n.name+i))})})},n.name))})})})};ui.propTypes={};var cc=`<style em="styles">
641
+ </tr>`,ui=[{sizeArray:[24],name:"column-one",html:oc},{sizeArray:[12,12],name:"column-two-50",html:ac},{sizeArray:[8,8,8],name:"column-three",html:lc},{sizeArray:[6,6,6,6],name:"column-four",html:cc},{sizeArray:[8,16],name:"column-two-33",html:ic},{sizeArray:[16,8],name:"column-two-66",html:sc}],pi=()=>{const e=xt.useSetHtmlElementInIframeHandler(),t=xt.useDragStartBlockToIframeHandler();return(0,a.jsx)("div",{className:"structures blocks-search__empty-wrapper",children:(0,a.jsx)("div",{className:"structures__list",children:(0,a.jsx)("div",{children:ui&&ui.map(n=>(0,a.jsx)("div",{children:(0,a.jsx)("div",{className:"structures__item",draggable:!0,onClick:o=>e(o,n.html,void 0,n.name,{id:n.name,title:n.name,type:"structure"}),onDragStart:o=>t(o,n.html,void 0,n.name,{id:n.name,title:n.name,type:"structure"}),children:(0,a.jsx)(_.ui_kit$Row,{gutter:[6,6],className:"structures__item-row",children:n.sizeArray.map((o,i)=>(0,a.jsx)(_.ui_kit$Col,{span:o,children:(0,a.jsx)("div",{className:"structures__item-col"})},n.name+i))})})},n.name))})})})};pi.propTypes={};var dc=`<style em="styles">
642
642
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
643
643
  .em-mob-width-100perc {
644
644
  width: 100%!important;
@@ -648,7 +648,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
648
648
  </style>
649
649
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td>
650
650
  <img src=${__useblocks__.assetUrl("empty-image.png")} width="150" border="0" alt="" style="display: block; width: 100%; max-width: 150px;" />
651
- </td></tr></table>`,dc=`<style em="styles">
651
+ </td></tr></table>`,uc=`<style em="styles">
652
652
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
653
653
  .em-mob-width-100perc {
654
654
  width: 100%!important;
@@ -658,7 +658,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
658
658
  </style>
659
659
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td>
660
660
  <img class="em-ai-img em-just-inserted" src="${__useblocks__.assetUrl("ai-image.png")}" width="150" border="0" alt="" style="display: block; width: 100%; max-width: 150px;" />
661
- </td></tr></table>`,uc=({__:e})=>`<style em="styles">
661
+ </td></tr></table>`,pc=({__:e})=>`<style em="styles">
662
662
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
663
663
  .em-mob-width-100perc {
664
664
  width: 100%!important;
@@ -668,7 +668,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
668
668
  </style>
669
669
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td style="padding-bottom: 10px;">
670
670
  <div style="font-family: -apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 21px; color: #5A5A5A;">${e("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")}</div>
671
- </td></tr></table>`,pc=({__:e})=>`<style em="styles">
671
+ </td></tr></table>`,mc=({__:e})=>`<style em="styles">
672
672
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
673
673
  .em-mob-width-100perc {
674
674
  width: 100%!important;
@@ -678,7 +678,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
678
678
  </style>
679
679
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td style="padding: 20px 0 10px;">
680
680
  <div style="font-family: -apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 24px; line-height: 32px; color: #333333;"><strong>${e("Header text")}</strong></div>
681
- </td></tr></table>`,mc=({__:e})=>`<style em="styles">
681
+ </td></tr></table>`,fc=({__:e})=>`<style em="styles">
682
682
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
683
683
  .em-mob-width-100perc {
684
684
  width: 100%!important;
@@ -696,7 +696,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
696
696
  </td>
697
697
  </tr>
698
698
  </table>
699
- </td></tr></table>`,fc=({__:e})=>`<style em="styles">
699
+ </td></tr></table>`,gc=({__:e})=>`<style em="styles">
700
700
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
701
701
  .em-mob-width-100perc {
702
702
  width: 100%!important;
@@ -715,7 +715,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
715
715
  </td>
716
716
  </tr>
717
717
  </table>
718
- </td></tr></table>`,gc=({__:e})=>`<style em="styles">
718
+ </td></tr></table>`,hc=({__:e})=>`<style em="styles">
719
719
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
720
720
  .em-mob-width-100perc {
721
721
  width: 100%!important;
@@ -734,7 +734,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
734
734
  </td>
735
735
  </tr>
736
736
  </table>
737
- </td></tr></table>`,hc=`<style em="styles">
737
+ </td></tr></table>`,_c=`<style em="styles">
738
738
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
739
739
  .em-mob-width-100perc {
740
740
  width: 100%!important;
@@ -742,7 +742,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
742
742
  }
743
743
  }
744
744
  </style>
745
- <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td height="0" style="padding: 20px 0 0; border-top: 1px solid #BFBFBF;">&nbsp;</td></tr></table>`,_c=`<style em="styles">
745
+ <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td height="0" style="padding: 20px 0 0; border-top: 1px solid #BFBFBF;">&nbsp;</td></tr></table>`,yc=`<style em="styles">
746
746
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
747
747
  .em-mob-width-100perc {
748
748
  width: 100%!important;
@@ -750,7 +750,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
750
750
  }
751
751
  }
752
752
  </style>
753
- <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td height="20"></td></tr></table>`,yc=r.SOCIAL_ICON_BY_PLATFORM;function pi(e){return String(e??"").replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function mi(e){const t=String(e??"").trim();if(!t)return"";if(/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(t))return t;const n=typeof window<"u"&&window.location?.origin?window.location.origin:"";if(!n)return t;try{return new URL(t,n).href}catch{return t}}function vc(e){return e>0?`<td width="${e}">&nbsp;</td>`:""}var bc={align:"center",iconSize:40,borderRadius:0,gap:8,bgEnabled:!1,bgColor:"",borderWidth:0,borderColor:"",buttonBorderColor:"",buttonBorderWidth:0,showLabel:!1};function fi(e){const{iconSize:t,gap:n,align:o}=bc,i=Math.max(0,Math.round(Number(n)||0)),s=e.length>1;return`<style em="styles">
753
+ <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td height="20"></td></tr></table>`,vc=r.SOCIAL_ICON_BY_PLATFORM;function mi(e){return String(e??"").replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;")}function fi(e){const t=String(e??"").trim();if(!t)return"";if(/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(t))return t;const n=typeof window<"u"&&window.location?.origin?window.location.origin:"";if(!n)return t;try{return new URL(t,n).href}catch{return t}}function bc(e){return e>0?`<td width="${e}">&nbsp;</td>`:""}var Ec={align:"center",iconSize:40,borderRadius:0,gap:8,bgEnabled:!1,bgColor:"",borderWidth:0,borderColor:"",buttonBorderColor:"",buttonBorderWidth:0,showLabel:!1};function gi(e){const{iconSize:t,gap:n,align:o}=Ec,i=Math.max(0,Math.round(Number(n)||0)),s=e.length>1;return`<style em="styles">
754
754
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
755
755
  .em-mob-width-100perc {
756
756
  width: 100%!important;
@@ -760,10 +760,10 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
760
760
  </style>
761
761
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom" em-type="social"><tr><td align="${o}">
762
762
  <table border="0" cellspacing="0" cellpadding="0">
763
- <tr>${e.map(c=>{const d=mi(c.iconSrc),u=d||mi(yc[c.platform]);if(!u)return"";const p=pi(c.label),f=pi(c.href||""),g=s?' draggable="true"':"",y=d?" em-custom-icon":"";return`<td em-platform="${c.platform}"${y}${g}><a href="${f}" target="_blank" draggable="false"><img src="${u}" width="${t}" height="${t}" border="0" alt="${p}" draggable="false" style="display:block;" /></a></td>`}).filter(Boolean).reduce((c,d,u)=>(u>0&&c.push(vc(i)),c.push(d),c),[]).join("")}
763
+ <tr>${e.map(c=>{const d=fi(c.iconSrc),u=d||fi(vc[c.platform]);if(!u)return"";const p=mi(c.label),f=mi(c.href||""),h=s?' draggable="true"':"",y=d?" em-custom-icon":"";return`<td em-platform="${c.platform}"${y}${h}><a href="${f}" target="_blank" draggable="false"><img src="${u}" width="${t}" height="${t}" border="0" alt="${p}" draggable="false" style="display:block;" /></a></td>`}).filter(Boolean).reduce((c,d,u)=>(u>0&&c.push(bc(i)),c.push(d),c),[]).join("")}
764
764
  </tr>
765
765
  </table>
766
- </td></tr></table>`}var Ec=fi(r.getDefaultSocialItemsBlocks()),Sc=({__:e})=>`<style em="styles">
766
+ </td></tr></table>`}var Sc=gi(r.getDefaultSocialItemsBlocks()),wc=({__:e})=>`<style em="styles">
767
767
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
768
768
  .em-mob-width-100perc {
769
769
  width: 100%!important;
@@ -783,7 +783,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
783
783
  <div style="font-family: -apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 16px; line-height: 21px; color: #5A5A5A;">${e("Column")} 3</div>
784
784
  </td>
785
785
  </tr>
786
- </table>`,wc="https://cdt3.useblocks.io/rndt",gi=new Date(+new Date+432e6).toISOString(),hi=-new Date().getTimezoneOffset()/60,kc=e=>`${wc}?locale=${e.replace("_","-")}&bg=FFFFFF&tp=false&color1=000000&color2=959595&size1=72&size2=28&font1=roboto&font2=roboto&border=10&delimiter=:&spacing=10&time=${gi}&timezone=${hi}&frames=20`,Cc=e=>`<style em="styles">
786
+ </table>`,kc="https://cdt3.useblocks.io/rndt",hi=new Date(+new Date+432e6).toISOString(),_i=-new Date().getTimezoneOffset()/60,Tc=e=>`${kc}?locale=${e.replace("_","-")}&bg=FFFFFF&tp=false&color1=000000&color2=959595&size1=72&size2=28&font1=roboto&font2=roboto&border=10&delimiter=:&spacing=10&time=${hi}&timezone=${_i}&frames=20`,Cc=e=>`<style em="styles">
787
787
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
788
788
  .em-mob-width-100perc {
789
789
  width: 100%!important;
@@ -791,7 +791,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
791
791
  }
792
792
  }
793
793
  </style>
794
- <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td align="center"><img class="em-countdown" em-cd-settings="locale=${e.replace("_","-")}&bg=FFFFFF&tp=false&color1=000000&color2=959595&size1=72&size2=28&font1=roboto&font2=roboto&border=10&delimiter=:&spacing=10&time=${gi}&timezone=${hi}&frames=20" src="${kc(e)}" border="0" alt="" style="display: block;" /></td></tr></table>`,Tc=`<style em="styles">
794
+ <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td align="center"><img class="em-countdown" em-cd-settings="locale=${e.replace("_","-")}&bg=FFFFFF&tp=false&color1=000000&color2=959595&size1=72&size2=28&font1=roboto&font2=roboto&border=10&delimiter=:&spacing=10&time=${hi}&timezone=${_i}&frames=20" src="${Tc(e)}" border="0" alt="" style="display: block;" /></td></tr></table>`,Ic=`<style em="styles">
795
795
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
796
796
  .em-mob-width-100perc {
797
797
  width: 100%!important;
@@ -801,7 +801,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
801
801
  </style>
802
802
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="em-mob-width-100perc" em="atom"><tr><td>
803
803
  <img class="em-video" src="${__useblocks__.assetUrl("video.png")}" width="150" border="0" alt="" style="display: inline-block; width: 100%; max-width: 150px;" />
804
- </td></tr></table>`,Ic=({__:e})=>`<style em="styles">
804
+ </td></tr></table>`,Ac=({__:e})=>`<style em="styles">
805
805
  @media only screen and (max-device-width:660px),only screen and (max-width:660px) {
806
806
  .em-mob-width-100perc {
807
807
  width: 100%!important;
@@ -815,7 +815,7 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
815
815
  <amp-img src="${e("https://cdn.useblocks.io/1351/241031_18_aJAY1Xz.png")}" width="800" height="600" layout="responsive" alt=""></amp-img>
816
816
  <amp-img src="${e("https://cdn.useblocks.io/1351/241031_18_OQEyMEF.png")}" width="800" height="600" layout="responsive" alt=""></amp-img>
817
817
  </amp-carousel>
818
- </td></tr></table>`,Ac=({__:e})=>`<style em="styles">
818
+ </td></tr></table>`,xc=({__:e})=>`<style em="styles">
819
819
  amp-accordion > section > * {
820
820
  background: none !important;
821
821
  padding: 0 !important;
@@ -852,6 +852,6 @@ ${o}}`,n.appendChild(document.createTextNode(o));const i=t.querySelector('[data-
852
852
  </div>
853
853
  </section>
854
854
  </amp-accordion>
855
- </td></tr></table>`,xc={image:"element_image","ai-image":"element_ai_image",text:"element_text",header:"element_heading",button:"element_button",spacer:"element_spacer","list-ul":"element_lists","list-ol":"element_lists",divider:"element_divider",social:"element_social",table:"element_table",countdown:"element_timer",video:"element_video","amp-carousel":"element_amp_carousel","amp-accordion":"element_amp_accordion","amp-form":"element_amp_form"};function _i(e){return xc[e]??null}var yi=e=>Number(e)||void 0,Pc={colors:[],fonts:[],socials:[]},Vr=(e="entity")=>{const t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t?.randomUUID)return t.randomUUID();const n=typeof performance<"u"?performance.now().toString(36).replace(".",""):String(Date.now());return`${e}-${Date.now().toString(36)}-${n}`},jc=()=>Vr("soc"),Rc=/^[a-z][a-z0-9+.-]*:/i,vi=e=>{const t=String(e??"").trim();return t?Rc.test(t)?t:`https://${t}`:""},Oc=e=>{const t=vi(e);if(!t)return!1;try{const n=new URL(t);return n.protocol==="https:"&&!!n.hostname}catch{return!1}},Lc=e=>[...e].filter(t=>t.url.trim()!=="").sort((t,n)=>t.order-n.order),Mc=e=>Lc(e).map(t=>({platform:t.icon_key,href:t.url,label:t.name,...t.icon_url?{iconSrc:t.icon_url}:{}})),Nc=/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,Dc=/^#?([0-9a-f]{6})$/i,Kr=e=>{if(!e)return null;const t=String(e).trim().toLowerCase(),n=Dc.exec(t);if(n)return`#${n[1]}`;const o=Nc.exec(t);if(o){const[,i,s,c]=o;return`#${i}${i}${s}${s}${c}${c}`}return null},bi=()=>Vr("bc"),Fc=/\.(woff2|woff|ttf|otf)$/i,Bc=e=>{const t=Fc.exec(e.trim().toLowerCase());return t?`.${t[1]}`:null},$c={".woff":"application/x-font-woff",".woff2":"application/font-woff2",".ttf":"font/sfnt",".otf":"font/sfnt"},Uc={".woff":["application/x-font-woff","font/woff","application/font-woff"],".woff2":["application/font-woff2","font/woff2"],".ttf":["font/sfnt","application/font-sfnt","application/x-font-ttf","font/ttf","application/x-font-truetype"],".otf":["font/sfnt","application/font-sfnt","application/vnd.ms-opentype","application/x-font-opentype","font/otf","font/opentype"]},zc=new Set(["","application/octet-stream","binary/octet-stream"]),Gc=e=>{const t=Bc(e.name);if(!t)return e;const n=e.type.trim().toLowerCase();return Uc[t].includes(n)||!zc.has(n)?e:new File([e],e.name,{type:$c[t],lastModified:e.lastModified})},Wc=()=>Vr("fnt"),Hc=e=>e.family?.trim()||e.name.trim(),qc=e=>e.filter(t=>t.source_url?.trim()).map(t=>({family:t.family?.trim()||t.name.trim(),source_url:t.source_url?.trim()??"",weight:t.weight?.trim()||"400",style:t.style??"normal"})),Vc=(e,t={})=>{const n=t.srcOverride?.trim()||e.source_url?.trim();if(!n||!t.srcOverride&&Ei(e)||t.srcOverride&&r.isGoogleFontsCssUrl(n))return null;const o=t.familyOverride?.trim()||Hc(e),i=e.weight?.trim()||"400",s=e.style??"normal";return`@font-face{font-family:${JSON.stringify(o)};src:url(${JSON.stringify(n)});font-weight:${i};font-style:${s};font-display:swap;}`},Kc=e=>e.source_kind?e.source_kind:r.isGoogleFontsCssUrl(e.source_url)?"google_stylesheet":e.file_name?.trim()?"uploaded":"remote_file",Ei=e=>e.source_kind?e.source_kind==="google_stylesheet"||e.source_kind==="remote_stylesheet":r.isGoogleFontsCssUrl(e.source_url),Si="data-em-project-fonts-face",wi="data-em-project-font-link",Yc=e=>{const t=e.filter(n=>Ei(n)).map(n=>n.source_url?.trim()??"").filter(Boolean);return[...new Set(t)]},Qc=e=>e.map(t=>Vc(t)).filter(t=>!!t).join(""),Xc=(e,t=document)=>{const n=Qc(e),{head:o}=t;let i=o.querySelector(`style[${Si}]`);if(!n){i?.remove();return}i||(i=t.createElement("style"),i.setAttribute(Si,""),o.appendChild(i)),i.textContent=n},Jc=(e,t=document)=>{const n=new Set(Yc(e)),{head:o}=t;o.querySelectorAll(`link[${wi}]`).forEach(i=>{const s=i.getAttribute("href")??"";n.has(s)?n.delete(s):i.remove()}),n.forEach(i=>{const s=t.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href",i),s.setAttribute(wi,""),o.appendChild(s)})},Zc=(e,t=document)=>{Xc(e,t),Jc(e,t)},ed=new Set(["normal","italic","oblique"]),Fv="[emailmaker] projectStyles:",Wt=e=>{},vt=e=>typeof e=="string"?e.trim():"",ki=e=>!e||e.startsWith("//")?!1:e.startsWith("/")||e.startsWith("./")||e.startsWith("../")?!0:e.toLowerCase().startsWith("https://"),td=e=>r.isGoogleFontsCssUrl(e)?"google_stylesheet":(e.split(/[?#]/)[0]??"").toLowerCase().endsWith(".css")?"remote_stylesheet":"remote_file",Yr=(e,t,n)=>e.length<=t?e:(Wt(`${n} list is capped at ${t} entries, ${e.length-t} dropped`),e.slice(0,t)),nd=(e,t)=>{const n=Kr(e?.hex);if(!n){Wt(`colors[${t}] skipped: "${String(e?.hex)}" is not a hex color`);return}return{id:vt(e.id)||bi(),name:vt(e.name),hex:n,order:0}},rd=(e,t)=>{const n=vt(e?.family),o=vt(e?.source_url);if(!n){Wt(`fonts[${t}] skipped: family is required`);return}if(!o){Wt(`fonts[${t}] skipped: source_url is required`);return}if(!ki(o)){Wt(`fonts[${t}] skipped: source_url must be https or relative, got "${o}"`);return}const i=vt(e.style);return{id:vt(e.id)||Wc(),name:vt(e.name)||n,family:n,source_url:o,source_kind:td(o),weight:vt(e.weight)||"400",style:ed.has(i)?i:"normal",order:0}},od=(e,t)=>{const n=vi(e?.url);if(!n||!Oc(n)){Wt(`socials[${t}] skipped: url must be https, got "${String(e?.url)}"`);return}const o=vt(e.icon_key),i=vt(e.icon_url);let s;if(i&&ki(i)?s=i:i&&Wt(`socials[${t}]: icon_url must be https or relative, got "${i}" — icon dropped`),!o&&!s){Wt(`socials[${t}] skipped: icon_key or icon_url is required`);return}return{id:vt(e.id)||jc(),name:vt(e.name),url:n,icon_key:o,...s?{icon_url:s}:{},enabled:!0,order:0}},Qr=e=>e.map((t,n)=>({...t,order:n})),id=e=>({colors:Qr(Yr(e?.colors??[],32,"colors").map(nd).filter(t=>t!==void 0)),fonts:Qr(Yr(e?.fonts??[],20,"fonts").map(rd).filter(t=>t!==void 0)),socials:Qr(Yr(e?.socials??[],20,"socials").map(od).filter(t=>t!==void 0))}),sd={tg:"telegram",yt:"youtube",yd:"yandex_zen",tt:"tiktok",pi:"pinterest",ig:"instagram",fb:"facebook",xa:"x",tw:"twitter"},Ci="vk",ad=new Set(r.EM_SOCIAL_SELECT_ORDER),ld=e=>ad.has(e),Ti=e=>{const t=String(e??"").trim().toLowerCase();return t?ld(t)?t:sd[t]??Ci:Ci},cd=e=>Ti(e),dd=new Set(["normal","italic","oblique"]),ud=new Set(["uploaded","remote_file","google_stylesheet"]),Pt=e=>(e??"").trim(),wn=e=>Pt(e)||void 0,Ii=e=>typeof e=="number"&&e>0?e:void 0,pd=e=>dd.has(e)?e:void 0,md=e=>ud.has(e)?e:void 0,fd=(e,t)=>{const n=Kr(Pt(e.hex));return n?{id:Pt(e.id)||bi(),name:Pt(e.name),hex:n,order:e.order??t}:null},Ai=(e,t=0)=>({id:Pt(e.id),name:Pt(e.name),source_url:wn(e.source_url),source_kind:md(e.source_kind),file_name:wn(e.file_name),family:wn(e.family),weight:wn(e.weight),style:pd(e.style),preview_url:wn(e.preview_url),storage_fallback:e.storage_fallback||void 0,font_size_px:Ii(e.font_size_px),line_height_px:Ii(e.line_height_px),order:e.order??t}),gd=(e,t)=>{const n=Pt(e.url);return n?{id:Pt(e.id),name:Pt(e.name),url:n,icon_key:Ti(Pt(e.icon_key)),enabled:e.enabled??!0,order:e.order??t}:null},rn=e=>[...e].sort((t,n)=>t.order-n.order),xi=e=>e?{colors:rn((e.colors??[]).map(fd).filter(t=>t!==null)),fonts:rn((e.fonts??[]).map(Ai)),socials:rn((e.socials??[]).map(gd).filter(t=>t!==null))}:Pc,hd=e=>e==="remote_stylesheet"?"remote_file":e,_d=e=>{const t={};return e.colors&&(t.colors=rn(e.colors).map(n=>({id:n.id,name:n.name.trim(),hex:Kr(n.hex)||n.hex}))),e.fonts&&(t.fonts=rn(e.fonts).map(n=>({id:n.id,name:n.name.trim(),source_url:n.source_url??"",source_kind:hd(Kc(n)),file_name:n.file_name??"",family:n.family??"",weight:n.weight??"",style:n.style??"",preview_url:n.preview_url??"",storage_fallback:n.storage_fallback??!1,font_size_px:n.font_size_px??0,line_height_px:n.line_height_px??0}))),e.socials&&(t.socials=rn(e.socials).map(n=>({id:n.id,name:n.name.trim(),url:n.url,icon_key:cd(n.icon_key),enabled:n.enabled}))),t},Pi="ProjectBrandStyles",Qt=r.createApi({reducerPath:"projectSettingsStylesApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),tagTypes:[Pi],endpoints:e=>({getProjectStyles:e.query({async queryFn({projectId:t},n){const o=r.v2ResultOf(await r.getClientV2(h.getContainer(n)).projects.stylesList({id:String(t)}));return"error"in o?{error:o.error}:{data:xi(o.data)}},providesTags:(t,n,{projectId:o})=>[{type:Pi,id:String(o)}]}),updateProjectStyles:e.mutation({async queryFn({projectId:t,patch:n},o){const i=r.v2ResultOf(await r.getClientV2(h.getContainer(o)).projects.stylesPartialUpdate({id:String(t)},_d(n)));return"error"in i?{error:i.error}:{data:xi(i.data)}},async onQueryStarted({projectId:t,patch:n},{dispatch:o,queryFulfilled:i}){const s=o(Qt.util.updateQueryData("getProjectStyles",{projectId:t},c=>Object.assign(c,n)));try{const{data:c}=await i;o(Qt.util.upsertQueryData("getProjectStyles",{projectId:t},c))}catch{s.undo()}}}),uploadProjectFont:e.mutation({async queryFn({projectId:t,file:n},o){const i=new FormData;i.append("file",Gc(n));const s=r.v2ResultOf(await r.getClientV2(h.getContainer(o)).request({path:`/projects/${String(t)}/styles/fonts`,method:"POST",body:i,secure:!0,type:r.ContentType.FormData,format:"json"}));return"error"in s?{error:s.error}:{data:Ai(s.data)}},async onQueryStarted({projectId:t},{dispatch:n,queryFulfilled:o}){try{const{data:i}=await o;n(Qt.util.updateQueryData("getProjectStyles",{projectId:t},s=>{s.fonts=s.fonts.some(c=>c.id===i.id)?s.fonts.map(c=>c.id===i.id?i:c):[...s.fonts,i],s.fonts.sort((c,d)=>c.order-d.order)}))}catch{}}})})}),{useGetProjectStylesQuery:yd,useUpdateProjectStylesMutation:Bv,useUploadProjectFontMutation:$v}=Qt,ji=e=>{const t=r.useIntegratorConfigValue("projectStyles"),{data:n}=yd({projectId:e},{skip:!0});return(0,l.useMemo)(()=>id(t),[t])},vd=2.5,bd=({atom:e,onSelect:t,onDragStart:n,isDroppedAtom:o})=>{const i=(0,l.useCallback)(d=>t(d,e),[t,e]),s=(0,l.useCallback)(d=>n(d,e,o),[n,e,o]),c=(0,l.useCallback)(d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),t(d,e))},[t,e]);return(0,a.jsxs)("button",{type:"button",className:"ant-card-hoverable atoms__item "+e.className+(e.isLockedByPlan?" atoms__item_locked":""),draggable:!0,onClick:i,onKeyDown:c,onDragStart:s,"data-test-name":e.name,children:[(0,a.jsxs)("span",{className:"atom-image",children:[e.icon,e.isLockedByPlan&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:12,strokeWidth:vd,className:"atom-image__lock"})]}),(0,a.jsx)("span",{className:"atom-title",children:e.title})]})},Ri=()=>{const e=r.useI18n(),{__:t}=e,n=r.useAppConfig(),o=r.useProjectData(),i=r.useCurrentUserLocale()||"en_US",s=xt.useSetHtmlAtomInIframeHandler(),c=xt.useDragStartAtomToIframeHandler(),[d,u]=(0,l.useState)(!1),[p,f]=(0,l.useState)(0),g=r.useMessageService(),y=r.useServices(h.ATOMS_HANDLERS_ID),m=r.useEventEmitter(h.HANDLE_ATOM_INSERT_ID),S=r.usePlanFeatureLocks(),k=yi(o?.id),w=ji(k),b=w?Mc(w.socials):[],A=b.length>0?fi(b):Ec;let x=[];if(n.elementImageEnabled&&x.push({title:t("Image"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementImage",component:_.icons$ElementImage,size:24,strokeWidth:n.iconStrokeWidth}),html:cc,className:"",name:"image"}),n.elementAIimageEnabled&&x.push({title:t("AI image"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementImageAI",component:_.icons$ElementImageAI,size:24,strokeWidth:n.iconStrokeWidth}),html:dc,className:"ai",name:"ai-image"}),n.elementTextEnabled&&x.push({title:t("Text"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementText",component:_.icons$ElementText,size:24,strokeWidth:n.iconStrokeWidth}),html:uc(e),className:"",name:"text"}),n.elementHeaderEnabled&&x.push({title:t("Header"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementTitle",component:_.icons$ElementTitle,size:24,strokeWidth:n.iconStrokeWidth}),html:pc(e),className:"",name:"header"}),n.elementButtonEnabled&&x.push({title:t("Button"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementButton",component:_.icons$ElementButton,size:24,strokeWidth:n.iconStrokeWidth}),html:mc(e),className:"",name:"button"}),n.elementSpacerEnabled&&x.push({title:t("Spacer"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementSpacer",component:_.icons$ElementSpacer,size:24,strokeWidth:n.iconStrokeWidth}),html:_c,className:"",name:"spacer"}),n.elementListULEnabled&&x.push({title:t("List UL"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementListUL",component:_.icons$ElementListUL,size:24,strokeWidth:n.iconStrokeWidth}),html:fc(e),className:"",name:"list-ul"}),n.elementListOLEnabled&&x.push({title:t("List OL"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementListOL",component:_.icons$ElementListOL,size:24,strokeWidth:n.iconStrokeWidth}),html:gc(e),className:"",name:"list-ol"}),n.elementDividerEnabled&&x.push({title:t("Divider"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementDivider",component:_.icons$ElementDivider,size:24,strokeWidth:n.iconStrokeWidth}),html:hc,className:"",name:"divider"}),n.elementSocialEnabled&&x.push({title:t("Social media"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementSocial",component:_.icons$ElementSocial,size:24,strokeWidth:n.iconStrokeWidth}),html:A,className:"",name:"social"}),n.elementTableEnabled&&x.push({title:t("Table"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementTable",component:_.icons$ElementTable,size:24,strokeWidth:n.iconStrokeWidth}),html:Sc(e),className:"",name:"table"}),n.elementCountdownEnabled&&x.push({title:t("Countdown"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementCountdown",component:_.icons$ElementCountdown,size:24,strokeWidth:n.iconStrokeWidth}),html:Cc(i),className:"",name:"countdown"}),n.elementVideoEnabled&&x.push({title:t("Video"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementVideo",component:_.icons$ElementVideo,size:24,strokeWidth:n.iconStrokeWidth}),html:Tc,className:"",name:"video"}),n.elementCarouselEnabled&&x.push({title:t("Carousel"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementCarousel",component:_.icons$ElementCarousel,size:24,strokeWidth:n.iconStrokeWidth}),html:Ic(e),className:"amp",name:"amp-carousel"}),n.elementAccordionEnabled&&x.push({title:t("Accordion"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementAccordion",component:_.icons$ElementAccordion,size:24,strokeWidth:n.iconStrokeWidth}),html:Ac(e),className:"amp",name:"amp-accordion"}),n.elementFormEnabled&&x.push({title:t("Form"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementForm",component:_.icons$ElementForm,size:24,strokeWidth:n.iconStrokeWidth}),html:null,className:"amp",name:"amp-form"}),x=x.map(I=>({...I,fallbackTooltip:t("Coming soon"),planFeature:_i(I.name),isLockedByPlan:S(_i(I.name))})),y){const I={value:x};for(const R of y)R.execute(I);x=I.value}(0,l.useEffect)(()=>{const{dispose:I}=g.addListener(r.EVENT_TYPES.APPLICATION_ATOM_INSERTED,R=>{const z=x.find(B=>B.name===R);z&&m.fire(z)});return()=>I()},[g,x,m]);const Y=(0,l.useCallback)(I=>{u(!0),f(I.planFeature?r.FEATURE_UPSELL_SLIDE[I.planFeature]:1)},[]),Z=(0,l.useCallback)(I=>I.isLockedByPlan?(setTimeout(()=>Y(I),1e3),!1):!0,[Y]),M=(0,l.useCallback)((I,R)=>{if(R.isLockedByPlan){Y(R);return}s(I,R)},[Y,s]),O=(0,l.useCallback)((I,R,z)=>{c(I,R,z)},[c]);return(0,a.jsxs)("div",{className:"atoms",children:[(0,a.jsx)("div",{className:"atoms__list",children:(0,a.jsx)(_.ui_kit$Space,{wrap:!0,style:{justifyContent:"space-between",rowGap:10},children:x&&x.map((I,R)=>I.html?(0,a.jsx)(bd,{atom:I,onSelect:M,onDragStart:O,isDroppedAtom:Z},I.title+R.toString()):(0,a.jsx)(_.ui_kit$Tooltip,{title:I.fallbackTooltip||t("Coming soon"),placement:"top",children:(0,a.jsxs)("div",{className:"atoms__item atoms__item_inactive "+I.className,"data-test-name":I.name,children:[(0,a.jsx)("span",{className:"atom-image",children:I.icon}),(0,a.jsx)("span",{className:"atom-title",children:I.title})]},I.title+R.toString())},I.title+R.toString()))})}),(0,a.jsx)(r.PlanUpgradePrompt,{open:d,onCancel:()=>u(!1),initialSlide:p})]})};Ri.propTypes={};var Ed={full:{flexGrow:1},768:{width:171},425:{width:25},375:{width:28},320:{width:320}},Oi={right:-12,top:4,zIndex:999,padding:0,position:"absolute"},Sd=[{kind:"full",width:1200},{kind:"768",width:768},{kind:"425",width:425},{kind:"375",width:375},{kind:"320",width:320,showLabel:!0},{kind:"375",width:375},{kind:"425",width:425,control:"mobile"},{kind:"768",width:768,control:"desktop"},{kind:"full",width:1200}];function wd({kind:e,width:t,label:n,onSelect:o,onHover:i,children:s}){const c=(0,l.useCallback)(()=>i(e,n),[i,e,n]),d=(0,l.useCallback)(()=>i(null,""),[i]),u=(0,l.useCallback)(()=>o(t),[o,t]),p=(0,l.useCallback)(f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),o(t))},[o,t]);return(0,a.jsx)("div",{className:`device-width__${e}`,style:Ed[e],role:"button",tabIndex:0,"aria-label":n,onMouseEnter:c,onMouseLeave:d,onClick:u,onKeyDown:p,children:s})}function kd({onSelectWidth:e,themeToggle:t}){const{__:n}=r.useI18n(),[o,i]=(0,l.useState)(""),[s,c]=(0,l.useState)(""),d={full:n("Desktop"),768:n("Small desktop – 768px"),425:n("Mobile L – 425px"),375:n("Mobile M – 375px"),320:n("Mobile S – 320px")},u=(0,l.useCallback)((p,f)=>{i(p?`device-width__${p}-hovered`:""),c(f)},[]);return(0,a.jsx)("div",{className:`email-pane__sizes ${o}`,children:(0,a.jsxs)("div",{className:"email-pane__width-selectors-wrapper",children:[(0,a.jsx)("div",{className:"device-width__theme",children:t}),Sd.map((p,f)=>(0,a.jsxs)(wd,{kind:p.kind,width:p.width,label:d[p.kind],onSelect:e,onHover:u,children:[p.showLabel?s:null,p.control==="mobile"&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Mobile view"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"default",icon:(0,a.jsx)(r.EmIcons,{icon:"MobileOutlined",component:_.icons$MobileOutlined,size:16,strokeWidth:2}),size:"small",shape:"circle",style:Oi})}),p.control==="desktop"&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Desktop view"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"default",icon:(0,a.jsx)(r.EmIcons,{icon:"DesktopOutlined",component:_.icons$DesktopOutlined,size:16,strokeWidth:2}),size:"small",shape:"circle",style:Oi})})]},`${p.kind}-${f}`)),(0,a.jsx)("div",{className:"device-width__theme-placeholder"})]})})}var Ue=zt.__toESM(r.require_prop_types()),Li=h.createIdentifier$1("canvas.resizerBinder"),Cd=h.createIdentifier$1("canvas.service"),Uv={created:r.PHASES.canvasCreated,loaded:r.PHASES.canvasLoaded};function Td(e){return e.getInstance(Cd)}function Mi(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}var Id={canUndo:!1,canRedo:!1},Ad={undo:()=>{},redo:()=>{},clear:()=>{},canUndo:()=>!1,canRedo:()=>!1,createSnapshot:()=>{},restoreSnapshot:()=>{},getPast:()=>[],getFuture:()=>[]};function Xr(e){const t=r.useDocumentSessionContext(),{history:n}=e??t;return(0,l.useMemo)(()=>n?Mi(n):Ad,[n])}function xd(){const{history:e}=r.useDocumentSessionContext(),t=(0,l.useCallback)(i=>e?e.subscribe(i):()=>{},[e]),n=(0,l.useRef)(null),o=(0,l.useCallback)(()=>{if(!e)return Id;const i={canUndo:e.canUndo(),canRedo:e.canRedo()},s=n.current;return s&&s.canUndo===i.canUndo&&s.canRedo===i.canRedo?s:(n.current=i,i)},[e]);return(0,l.useSyncExternalStore)(t,o)}var Ni=2e3,Pd=10,jd="iframe_errors",Rd=5;function Od(e){const{__:t}=r.useI18n(),n=r.useMessageService(),o=Xr(),{error:i}=r.useNotification(),{document:s}=r.useDocumentSessionContext(),c=(0,l.useCallback)(()=>s?.getContent()??"",[s]),d=(0,l.useRef)(0),u=(0,l.useRef)(void 0),p=(0,l.useRef)(!1),f=r.useCurrentUser(),g=(0,l.useCallback)(m=>new Promise((S,k)=>{const w=n.addListener(r.EVENT_TYPES.SANDBOX_READY,()=>{w.dispose(),S()});m&&setTimeout(()=>{w.dispose(),k("timeout")})}),[n]),y=(0,l.useCallback)(m=>{g(Ni).catch(S=>{}).finally(()=>{Promise.resolve().then(()=>{if(!p.current){if(++d.current){if(u.current){if(d.current<Rd){o.restoreSnapshot(u.current);for(let S=0;S<d.current;S++)o.undo()}}else u.current=o.createSnapshot();n.send(r.EVENT_TYPES.RELOAD)}setTimeout(()=>{if(--d.current===0){u.current=null;const S=new Error(m.message);m.stack&&(S.stack=m.stack);const k=r.reportError(S,{origin:"iframe"}),w={past:o.getPast(Pd),future:o.getFuture(),errorResolved:!p.current,text:c(),message:m.message,stack:m.stack,userId:f?.id,entityId:e?.id,entityType:document.location.pathname.indexOf("emails")>0?"email":"block",sentryEventId:k};i({id:"IFRAME_ERROR",data:w,title:t("Something went wrong")}),h.RACS.post(jd,w).catch(b=>{}),p.current=!1}},Ni)}})})},[o,c,i,f?.id,e?.id,t,g,n]);r.useListenPostMessage(r.EVENT_TYPES.APPLICATION_DOMPARSER_ERROR,y)}function Ld(e,t){const n=JSON.stringify(t??{});Md(e?.get().attributes.common_styles,n)||r.writeEmailAttributes(e,{common_styles:n})}function Md(e,t){if(e===t)return!0;try{return h.deepEqual(JSON.parse(e||"{}"),JSON.parse(t||"{}"))}catch{return!1}}var Wn=Symbol("isIframeEvent");function Nd({children:e}){const[t,n]=(0,l.useState)(),[o,i]=(0,l.useState)(),[s,c]=(0,l.useState)(!1),d=r.useMessageService();return(0,l.useEffect)(()=>{if(t){const u=d.addListener(r.EVENT_TYPES.APPLICATION_IFRAME_DRAG_EVENT,p=>{if(p.type!=="drageleave"&&p.type!=="dragenter"){const f=t.getBoundingClientRect(),g=p.clientX+f.x+window.scrollX,y=p.clientY+f.y+window.scrollY,m=document.elementFromPoint(g,y);if(m){const S=new DataTransfer,k=new DragEvent(p.type,{clientX:g,clientY:y,cancelable:!0,bubbles:!0,dataTransfer:S});k[Wn]=!0,m.dispatchEvent(k)}}});return()=>u.dispose()}},[d,t]),(0,l.useEffect)(()=>{const u=f=>{f[Wn]||c(!0)},p=f=>{f[Wn]||c(!1)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",p),()=>{window.removeEventListener("dragstart",u),window.removeEventListener("dragend",p)}},[o]),(0,l.useEffect)(()=>{const u=p=>{if(!p[Wn]){const f=o.getBoundingClientRect();d.send(r.EVENT_TYPES.SANDBOX_DRAG_EVENT,{value:p.dataTransfer?.getData("Text")||"",type:p.type,clientX:p.pageX-f.x-window.scrollX,clientY:p.pageY-f.y-window.scrollY})}};if(o)return o.addEventListener("dragenter",u),o.addEventListener("dragover",u),o.addEventListener("dragleave",u),o.addEventListener("drop",u),o.addEventListener("dragend",u),()=>{o.removeEventListener("dragenter",u),o.removeEventListener("dragover",u),o.removeEventListener("dragleave",u),o.removeEventListener("drop",u),o.removeEventListener("dragend",u)}},[o,d]),(0,a.jsxs)("div",{ref:n,children:[s&&(0,a.jsx)("div",{ref:i,className:"iframe-provider"}),e]})}var Dd=["colorBgBase","colorBgElevated","colorError","colorInfo","colorInfoBg","colorInfoBgHover","colorInfoBorder","colorInfoBorderHover","colorLink","colorPrimary","colorPrimaryBg","colorPrimaryBgHover","colorPrimaryBorder","colorPrimaryBorderHover"];function Fd(e){const t={};for(const n of Dd){const o=e[n];typeof o=="string"&&(t[n]=o)}return t}function Jr(e,t){const n=r.useMessageService(),o=t?.async??!1;(0,l.useEffect)(()=>{const i=o?n.addListenerAsync(r.EVENT_TYPES.RELOAD,e):n.addListener(r.EVENT_TYPES.RELOAD,e);return()=>i.dispose()},[n,e,o]),(0,l.useEffect)(()=>{},[e])}function Bd(){const e=r.useMessageService(),{token:t}=(0,_.ui_kit$useToken)(),[n,o]=(0,l.useState)();(0,l.useEffect)(()=>{if(!h.deepEqual(n,t)){const s=e.onInit(()=>{e.send(r.EVENT_TYPES.SANDBOX_SET_THEME_VARIABLES,Fd(t)),o(t)});return()=>s.dispose()}},[t,n,o,e]);const i=(0,l.useCallback)(()=>{o(void 0)},[]);Jr(i)}var $d={minHeight:600},Ud="#pane-content-wrapper, .email-pane__col_preview, .preview-mode__pane-content";function Di(e){e?.current?.resize?.()}var Fi=(0,l.forwardRef)(({className:e=null,email:t=null,handlerSendPosition:n=()=>{},surface:o,clip:i=null},s)=>{const c=r.useAppConfig(),d=r.useContainer(),u=o??(t?.hasOwnProperty("type")?"block":"email"),p=(0,l.useMemo)(()=>Td(d),[d]),f=(0,l.useMemo)(()=>p?.current(u),[p,u]),g=(0,l.useRef)(null),y=(0,l.useCallback)(()=>{r.mark(r.PHASES.canvasLoaded),Di(s),n()},[n,s]);(0,l.useImperativeHandle)(s,()=>({getIframeElement:()=>p?.current(u)?.element,resize:()=>p?.current(u)?.resize()}),[p,u]),(0,l.useEffect)(()=>{if(!p)return;const w=g.current,b=i??w?.closest(Ud)??null;return p.alignSurface(u,w,b),()=>p.alignSurface(u,null)},[p,u,i,c.sidePanelFloating]);const m=(0,l.useRef)(y);m.current=y,(0,l.useEffect)(()=>{if(!f)return;let w=!1;const b=()=>{w||m.current({target:f.element})};return f.ready().then(b).catch(()=>{window.requestAnimationFrame(()=>{w||f.ready().then(b).catch(()=>{})})}),()=>{w=!0}},[f]),Bd(),Od(t);const{document:S}=r.useDocumentSessionContext();(0,l.useEffect)(()=>{const w=r.subscribeToContent(S,()=>{Di(s)});return()=>w.dispose()},[S,s]);const k=(0,l.useCallback)(w=>{const{operation:b,settings:A}=w.data;b===r.EVENT_TYPES.APPLICATION_COMMON_STYLES_UPDATE&&Ld(S,A?.commonStyles)},[S]);return r.useListenPostMessage(k),(0,a.jsx)(Nd,{children:(0,a.jsx)("div",{ref:g,className:(0,rt.default)("email-preview",e),id:"email_iframe_slot",style:$d})})});Fi.propTypes={className:Ue.default.string,surface:Ue.default.oneOf(["email","block","preview"]),email:Ue.default.shape({html:Ue.default.string}),handlerSendPosition:Ue.default.func,clip:Ue.default.object};var Zr=new Map,zd=new Map;function Gd(e,t){e.set(t,(e.get(t)??0)+1)}function Wd(e,t){const n=e.get(t)??0;n<=1?e.delete(t):e.set(t,n-1)}function Bi(e,t){return(e.get(t)??0)>0}function Hd(e){return Bi(Zr,e)||Bi(zd,e)}function qd(e){Gd(Zr,e);let t=!1;return{dispose(){t||(t=!0,Vd(e))}}}function Vd(e){Wd(Zr,e)}function Kd(e,t){return Qd([...e.changes].sort((n,o)=>n.rangeOffset-o.rangeOffset).map(n=>({start:n.rangeOffset,end:n.rangeOffset+n.rangeLength,text:n.text})),t)}function Yd(e,t){return e.map(n=>{const o=t.getPositionAt(n.oldPosition),i=t.getPositionAt(n.oldEnd);return{text:n.newText,range:{startLineNumber:o.lineNumber,startColumn:o.column,endLineNumber:i.lineNumber,endColumn:i.column}}})}function Qd(e,t){let n=0;return e.map(({start:o,end:i,text:s})=>{const c=new r.TextChange(o,t.slice(o,i),o+n,s);return n+=s.length-(i-o),c})}var $i=new WeakMap;function Xd(e){const t=$i.get(e);if(t)return t;const n=Ll(e);return $i.set(e,n),n}var Ui="monaco";function Jd(e,t){(0,l.useEffect)(()=>{if(!e||!t)return;const n=Xd(e);let o=!1;const i=d=>{o=!0;const u=qd(t);try{d()}finally{u.dispose(),o=!1}},s=n.attach({id:Ui,apply(d){return t.getValue()!==d&&i(()=>t.setValue(d)),Promise.resolve()},applyChanges(d){return i(()=>t.applyEdits(Yd(d,t))),Promise.resolve()}}),c=t.onDidChangeContent(d=>{if(o)return;const u=Hd(t)?"remote":"user";n.mutateFrom(Ui,{changes:Kd(d,e.getContent())},{source:u})});return()=>{s.detach(),c.dispose()}},[e,t])}function Zd(e,t){const[n,o]=(0,l.useState)(void 0),i=(0,l.useRef)(!1),{error:s}=r.useNotification(),{__:c}=r.useI18n(),d=(0,l.useRef)(t);d.current=t;const u=(0,l.useRef)({error:s,__:c});u.current={error:s,__:c},(0,l.useEffect)(()=>{if(!e||n||i.current)return;i.current=!0;let f=!1;return d.current().then(g=>{if(f){g.dispose();return}o(g)}).catch(()=>{const{error:g,__:y}=u.current;g({id:"CODE_EDITOR_LOAD_FAILED",title:y("Failed to load the code editor")})}).finally(()=>{i.current=!1}),()=>{f=!0}},[e,n]);const p=(0,l.useRef)(void 0);return p.current=n,(0,l.useEffect)(()=>()=>{p.current?.dispose()},[]),n}var Hn;function eo(){return Hn===void 0&&(Hn=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/51a46897.js")),void 0,{}.url).catch(e=>{throw Hn=void 0,e})),Hn}function eu(){return eo().then(e=>e.ensureMonaco())}var tu=r.lazyRoute(()=>eo().then(e=>({default:e.MonacoEditor}))),nu=()=>eo().then(e=>e.loadEditorModel()),ru={height:"100%"};function ou(e){const t=Zd(!0,nu),{document:n}=r.useDocumentSessionContext();return(0,l.useEffect)(()=>{},[]),(0,l.useEffect)(()=>{},[t]),Jd(n,t),(0,a.jsx)(r.EditorModelContext.Provider,{value:t,children:(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$Flex,{justify:"center",align:"center",style:ru,children:(0,a.jsx)(_.ui_kit$Spin,{size:"large"})}),children:(0,a.jsx)(tu,{...e})})})}var iu=({elementPath:e})=>{const{_x:t}=r.useI18n(),n=r.useDispatch(),o=r.useMessageService(),i=r.useAppConfig(),{blockId:s}=r.useRouteParams(),c=r.useEditorProjectId(),d=r.useRouteEmailId(),u=r.useProjectData(),p=r.usePushToDataLayer(),f=(0,l.useCallback)(A=>{o.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_SET,index:A})},[o]),g=(0,l.useCallback)(A=>{let x="element";A?.target?.closest("svg")||A?.target?.closest(".anticon")||A?.target?.closest('[class*="icon"]')?x="icon":A?.target?.textContent&&!A?.target?.closest("svg")&&!A?.target?.closest(".anticon")&&(x="text"),n(r.setActiveSettingsTab(r.STYLES)),o.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1}),o.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),p({event:"click",action:"click_breadcrumb_email",email_id:d||s,project_id:u?.id||c,click_target:x})},[o,n,p,d,s,c,u]),y={title:(0,a.jsxs)("span",{onClick:g,children:[(0,a.jsx)(r.EmIcons,{icon:"Email",component:_.icons$Email,size:16,strokeWidth:i.iconStrokeWidth})," ",t("Email","letter")]})},[m,S]=(0,l.useState)([y]),k=(0,l.useCallback)(A=>{o.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_HOVER_SET,index:A})},[o]),w=A=>{if(A.includes("em-element-path-item-text"))return(0,a.jsx)(r.EmIcons,{icon:"ElementText",component:_.icons$ElementText,size:16,strokeWidth:i.iconStrokeWidth});if(A.includes("em-element-path-item-image"))return(0,a.jsx)(r.EmIcons,{icon:"ElementImage",component:_.icons$ElementImage,size:16,strokeWidth:i.iconStrokeWidth});if(A.includes("em-element-path-item-link"))return(0,a.jsx)(r.EmIcons,{icon:"LinkOutlined",component:_.icons$LinkOutlined,size:16,strokeWidth:i.iconStrokeWidth});if(A.includes("em-element-path-item-atom"))return(0,a.jsx)(r.EmIcons,{icon:"Atom",component:_.icons$Atom,size:16,strokeWidth:i.iconStrokeWidth});if(A.includes("em-element-path-item-column"))return(0,a.jsx)(r.EmIcons,{icon:"Column",component:_.icons$Column,size:16,strokeWidth:i.iconStrokeWidth});if(A.includes("em-element-path-item-block"))return(0,a.jsx)(r.EmIcons,{icon:"Block",component:_.icons$Block,size:16,strokeWidth:i.iconStrokeWidth});if(A.includes("em-element-path-item-group"))return(0,a.jsx)(r.EmIcons,{icon:"Group",component:_.icons$Group,size:16,strokeWidth:i.iconStrokeWidth});if(A.includes("em-element-path-item-button"))return(0,a.jsx)(r.EmIcons,{icon:"ElementButton",component:_.icons$ElementButton,size:16,strokeWidth:i.iconStrokeWidth});if(A.includes("em-element-path-item-table"))return(0,a.jsx)(r.EmIcons,{icon:"ElementTable",component:_.icons$ElementTable,size:16,strokeWidth:i.iconStrokeWidth});if(A.includes("em-element-path-item-amp"))return(0,a.jsx)(r.EmIcons,{icon:"AMP",component:_.icons$AMP,size:16,strokeWidth:i.iconStrokeWidth})},b=(0,l.useCallback)((A,x)=>{const Y=Z=>{let M="element";Z.target.closest("svg")||Z.target.closest(".anticon")||Z.target.closest('[class*="icon"]')?M="icon":Z.target.textContent&&!Z.target.closest("svg")&&!Z.target.closest(".anticon")&&(M="text");const O=e?.[x],I=O?.className?.replace("em-element-path-item-","")||"unknown";p({event:"click",action:"click_breadcrumb_element",email_id:d||s,project_id:u?.id||c,element_type:I,element_index:x,element_title:O?.title||"",click_target:M}),f(x)};return(0,a.jsxs)("span",{className:A.className,onClick:Y,onMouseOver:()=>{k(x)},children:[w(A.className)," ",A.title]})},[f,k,e,p,d,s,c,u]);return(0,l.useEffect)(()=>{if(e){const A=e.map((x,Y)=>({title:b(x,Y)}));S([{title:(0,a.jsxs)("span",{onClick:g,children:[(0,a.jsx)(r.EmIcons,{icon:"Email",component:_.icons$Email,size:16,strokeWidth:i.iconStrokeWidth})," ",t("Email","letter")]})},...A])}},[e,b,g,t]),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(_.ui_kit$Breadcrumb,{items:m,type:"separator",separator:""})})};function su(){const{document:e}=r.useDocumentSessionContext(),t=(0,l.useCallback)(o=>e?e.subscribe(o):()=>{},[e]),n=(0,l.useCallback)(()=>e?.getContent()??"",[e]);return(0,l.useSyncExternalStore)(t,n)}var au=({fallbackHtml:e})=>{const{__:t}=r.useI18n(),n=su(),o=(0,l.useMemo)(()=>r.getCodeSize(n||e||""),[e,n]),i=r.formatCodeSize(o),s=r.isCodeSizeExceeded(o);return(0,a.jsx)(_.ui_kit$Tooltip,{placement:"left",title:t(s?"The code size exceeds the recommended value 90kB":"Code size"),children:(0,a.jsx)("span",{className:(0,rt.default)("email-pane__code-size",{"email-pane__code-size_exceeded":s}),children:i})})};function zi(e){const{limits:t,isLoaded:n}=r.useProjectPlanLimits();return r.useProjectData(),(0,l.useMemo)(()=>({isLocked:!1,state:{state:"allowed"},isPlanDataReady:n,exceeded:null}),[!1,e,t,n])}var lu=({open:e,onClose:t})=>{const{__:n}=r.useI18n();return(0,a.jsxs)(_.ui_kit$Modal,{open:e,centered:!0,closable:!1,mask:{closable:!1},footer:null,width:520,className:"browser-extension-warning-modal",title:n("Browser extension detected"),onCancel:t,children:[(0,a.jsx)("p",{children:n("A browser extension (for example, Urban VPN Proxy or similar ad blockers/VPN tools) is injecting code into the email preview. This can corrupt your template when saving.")}),(0,a.jsx)("p",{children:n("We removed the injected code automatically. To avoid this issue, disable the extension for this site or use the editor in an incognito window without extensions.")}),(0,a.jsx)("div",{className:"browser-extension-warning-modal__footer",children:(0,a.jsxs)(_.ui_kit$Button,{type:"primary",onClick:t,children:[n("Got it")," "]})})]})},cu={closable:!1},du=({open:e,onClose:t})=>{const{__:n}=r.useI18n();return(0,a.jsxs)(_.ui_kit$Modal,{open:e,centered:!0,closable:!1,mask:cu,footer:null,width:520,className:"browser-translate-warning-modal",title:n("Browser translation detected"),children:[(0,a.jsx)("p",{children:n("Browser page translation (for example, Google Translate) is active. It can break the editor and cause errors when saving.")}),(0,a.jsx)("p",{children:n("To avoid this issue, disable translation for this site in your browser settings or turn off auto-translate.")}),(0,a.jsx)("div",{className:"browser-translate-warning-modal__footer",children:(0,a.jsx)(_.ui_kit$Button,{type:"primary",onClick:t,children:n("Got it")})})]})},uu=h.createIdentifier$1("prewarm.editorVisible");function pu(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function mu(e={}){const t=e.paint??pu;let n=!1,o=!1,i=!1,s=!1,c=!1;const d=[],u=()=>{c||s||!n||!o||!i||(s=!0,t(()=>{c=!0,r.mark(r.PHASES.editorVisible);for(const p of d.splice(0))p()}))};return{noteShellVisible(){n=!0,u()},notePagePainted(){o=!0,u()},noteContentShown(){i=!0,u()},whenVisible(p){if(c){p();return}d.push(p)},contentShown:()=>i}}function Ht(e){return e.getOrCreateInstance(uu,()=>mu())}function kn(e){const t=(0,l.useRef)(!1);return e&&(t.current=!0),t.current}var Gi=4e3;function Xt(e){const t=window.requestIdleCallback;if(typeof t=="function"){t(e,{timeout:Gi});return}window.setTimeout(e,Gi)}var qn,to;function no(){return qn===void 0&&(qn=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/6741eb70.js")).then(e=>e.panels_exports).then(e=>(to=e,e),e=>{throw qn=void 0,e}),void 0,{}.url)),qn}function fu(e){(0,l.useEffect)(()=>{Ht(e).whenVisible(()=>{Xt(()=>{no().catch(()=>{})})})},[e])}function ut(e){const t=r.lazyRoute(()=>no().then(o=>({default:o[e]})),"panels");function n(o){const[i]=(0,l.useState)(()=>to?to[e]:t);return(0,l.createElement)(i,o)}return n.displayName=`PanelDoor(${String(e)})`,n}var Wi=ut("EmailProperties"),gu=ut("SelectedElementPanel"),hu=ut("EmailSettings"),_u=ut("EmailStyles"),yu=ut("DiscussAi"),vu=ut("Optimise"),bu=ut("FileManagerDataLayer"),Eu=ut("BlocksSearch"),Su=ut("Discuss"),wu=ut("HistoryPanel"),ku=ut("AddNewBlockModal"),Cu=ut("AddAllBlocksModal"),Tu=ut("SendTestEmailModal"),Iu=ut("SaveBlockBtn"),ro=ut("LimitUpgradeModal"),Au={height:"100%"},xu=()=>{const e=r.useContainer(),t=r.isImageCenterModal(r.useSelector(r.selectActiveModal$1)),[n,o]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{e&&Ht(e).whenVisible(()=>o(!0))},[e]),kn(n||t)?(0,a.jsx)(l.Suspense,{fallback:t?(0,a.jsx)(_.ui_kit$PageLoader,{style:Au}):null,children:(0,a.jsx)(bu,{})}):null},Vn;function Pu(){return Vn===void 0&&(Vn=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/9281699f.js")),void 0,{}.url).catch(e=>{throw Vn=void 0,e})),Vn}function Cn(e){return r.lazyRoute(()=>Pu().then(t=>({default:t[e]})),"form-panels")}var zv=Cn("FormEditorCalendarPanel"),Gv=Cn("FormEditorCheckboxPanel"),Wv=Cn("FormEditorDropdownListPanel"),Hv=Cn("FormEditorInputPanel"),qv=Cn("FormEditorRadioPanel");function ju(){try{const e=new URLSearchParams(window.location.search).get("deferChrome");return e===null?void 0:e!=="0"&&e!=="false"}catch{return}}function Ru(e,t){const n=ju()??r.readLocalToggle(r.LOCAL_STORAGE_ITEMS.em_defer_chrome);if(n!==void 0)return n;const o=t?.deferEditorChrome;return typeof o=="boolean"?o:o&&typeof o=="object"?o[e]??!0:{}.REACT_APP_DEFER_EDITOR_CHROME_DEFAULT!=="false"}function Hi(e){const t=r.useAppConfig(),[n,o]=(0,l.useState)(()=>!Ru(e,t));return(0,l.useEffect)(()=>{if(n)return;let i=0;const s=window.requestAnimationFrame(()=>{i=window.requestAnimationFrame(()=>(0,l.startTransition)(()=>o(!0)))});return()=>{window.cancelAnimationFrame(s),window.cancelAnimationFrame(i)}},[n]),n}var qi=r.createState({blocksTotal:null,blocksTotalPages:null,parentEmailBlocksTotal:null,parentEmailBlocksTotalPages:null,templateBlocks:[],templateBlocksTotal:null,templateBlocksTotalPages:null,elementsView:r.CARDS,elementsList:[],customFolders:{},blocksTrashTotal:0,elementsTrashList:[]}),Kn="blocksPageSlice",oo=r.createSlice({name:Kn,initialState:qi,reducers:{resetPagesAndTotal:()=>qi,resetElementsList:e=>{e.elementsList=[]},toggleElementsView:(e,t)=>{e.elementsView=t.payload},removeBlockFromList:(e,{payload:t})=>{const n=e.customFolders;t.folder!=="all"&&n[t.folder]?.list&&(n[t.folder]={...n[t.folder],list:n[t.folder].list.filter(o=>o.id!==t.emailId),total:n[t.folder].total-1},e.customFolders=n)}},extraReducers:e=>{e.addMatcher(r.blocksApi.endpoints.getBlocks.matchFulfilled,(t,{meta:n,payload:o})=>{const i=n.baseQueryMeta?.response.headers.get("X-WP-Total")||o?.length,s=n.arg.originalArgs?.status==="trash",c=!!n.arg.originalArgs?.name?.length,d=n.arg.originalArgs?.page,u=n.arg.originalArgs?.folderTag||n.arg.originalArgs?.tags?.[0];s?(c||(t.blocksTrashTotal=i),t.elementsTrashList=o):u?t.customFolders={...t.customFolders,[u]:{list:o,page:d,total:i}}:(t.blocksTotal=i,t.elementsList=o)}),e.addMatcher(r.blocksApi.endpoints.getParentEmailBlocks.matchFulfilled,(t,{meta:n,payload:o})=>{const i=n.baseQueryMeta?.response.headers.get("X-WP-Total")||o?.length||null,s=n.baseQueryMeta?.response.headers.get("X-WP-TotalPages");t.parentEmailBlocksTotal=i,t.parentEmailBlocksTotalPages=s}),e.addMatcher(r.blocksApi.endpoints.getTemplateBlocks.matchFulfilled,(t,{meta:n,payload:o})=>{const i=n.baseQueryMeta?.response.headers.get("X-WP-Total")||o?.length||null,s=n.baseQueryMeta?.response.headers.get("X-WP-TotalPages");t.templateBlocks=o,t.templateBlocksTotal=i,t.templateBlocksTotalPages=s}),e.addMatcher(r.blocksApi.endpoints.editBlock.matchFulfilled,(t,{payload:n})=>{t.elementsList.map(o=>o.id?.toString()===n.id?.toString()?Object.assign(o,{lock:n.lock,title:n.title,blocktags:n.blocktags}):o)})}}),{resetPagesAndTotal:Vv,resetElementsList:Kv,toggleElementsView:Yv,removeBlockFromList:Qv}=oo.actions,Ou=e=>e[Kn].blocksTotal,Lu=e=>e[Kn].templateBlocksTotal,Mu=e=>e[Kn].parentEmailBlocksTotal,Nu=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 Vi(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 Ki(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(h.throwIfAborted(n),new Promise((o,i)=>{let s=!1,c,d;const u=f=>{s||(s=!0,c!==void 0&&(clearTimeout(c),c=void 0),d?.dispose(),n?.removeEventListener("abort",p),f())},p=()=>{u(()=>i(h.createAbortError(n?.reason)))};if(d=e.onInit(()=>{e.isInited()&&e.getTarget()&&u(()=>o())}),e.isInited()&&e.getTarget()){u(()=>o());return}t>0&&(c=setTimeout(()=>{u(()=>i(new Nu(t)))},t)),n?.addEventListener("abort",p)}))}var Du=()=>{try{return localStorage.getItem("em-debug-project-fonts")==="1"}catch{return!1}},Tn=(e,t)=>{Du()},Fu=e=>[...e].sort((t,n)=>t.order-n.order).map(t=>t.hex.toUpperCase()),Bu=(e,t)=>{const n=Array.isArray(e?.usedColors)?e.usedColors:[],o=new Set,i=[];for(const s of[...n,...Fu(t)]){const c=String(s??"").trim().toUpperCase();!c||o.has(c)||(o.add(c),i.push(s))}return{...e,usedColors:i}},Yi,$u=e=>{Yi=e},Yn=e=>Bu(e,Yi?.colors??[]),Uu=e=>{const t=r.useMessageService(),n=ji(e),[o,i]=(0,l.useState)("");(0,l.useEffect)(()=>{$u(n);const c=n?.fonts??[];r.setCachedProjectFonts(c),Zc(c),Tn("parent: cache + host @font-face synced",{projectId:e,fontsCount:c.length,families:c.map(d=>d.family?.trim()||d.name)})},[n,e]),(0,l.useEffect)(()=>{const c=n?.fonts??[],d=qc(c),u=JSON.stringify(d);if(u===o){Tn("parent: iframe send skipped (unchanged)",{entriesCount:d.length});return}Tn("parent: scheduling SANDBOX_SET_PROJECT_FONTS",{entriesCount:d.length,entries:d});const p=()=>{t.send(r.EVENT_TYPES.SANDBOX_SET_PROJECT_FONTS,d),i(u),Tn("parent: SANDBOX_SET_PROJECT_FONTS sent",{entriesCount:d.length})};if(t.inited){p();return}const f=t.onInit(()=>{p()});return()=>f.dispose()},[t,n,o]);const s=(0,l.useCallback)(()=>{Tn("parent: iframe reload — will resend project fonts map"),i("")},[]);Jr(s)};function zu(e,t){const n=e,o=n?.data?.operation!==void 0?n.data:n;if(o?.operation===t)return o.file instanceof File?o.file:void 0}async function Gu(e,t){const{userId:n,folderId:o}=t.readContext();if(n==null||o==null||o==="")return{status:"skipped"};try{const i=await t.prepare(e),s=await t.upload({user_id:n,folder:String(o),file:i});if(s.error)return{status:"failed",error:s.error};const{extractUploadResult:c}=await(0,Ke.__vitePreload)(async()=>{const{extractUploadResult:u}=await Promise.resolve().then(()=>ve("./static/core/41a7e33c.js")).then(p=>p.import_exports);return{extractUploadResult:u}},void 0,{}.url),d=c(s.data);return d.error||!d.file_url?{status:"skipped"}:{status:"uploaded",url:d.file_url}}catch(i){return{status:"failed",error:i}}}function Wu(){const[e,t]=(0,l.useState)(!1),n=r.useHeadless(),o=r.useEventEmitter(h.events.ON_BROWSER_EXTENSION_DETECTED_ID),i=(0,l.useCallback)(()=>{t(!1)},[]);return(0,l.useEffect)(()=>{const s=o.event(()=>{n||t(!0)});return()=>s.dispose()},[o,n]),{open:e,close:i}}function Hu(){const[e,t]=(0,l.useState)(!1),n=r.useHeadless(),o=r.useEventEmitter(h.events.ON_BROWSER_TRANSLATE_DETECTED_ID),i=(0,l.useCallback)(()=>{t(!1)},[]);return(0,l.useEffect)(()=>{const s=o.event(()=>{n||t(!0)});return()=>s.dispose()},[o,n]),{open:e,close:i}}var qu=["translated-ltr","translated-rtl"],Vu=".goog-te-banner-frame",io=!1;function Ku(e){if(e)return e;if(!(typeof document>"u"))return document}function Yu(e){const t=Ku(e);if(!t?.documentElement)return!1;const n=t.documentElement.classList;return qu.some(o=>n.contains(o))?!0:t.querySelector(Vu)!=null}function Qu(){io=!1}function Xu(e){const t=Yu();return t&&!io&&e(),io=t,t}var Ju=500;function Zu(){const e=r.useEventEmitter(h.events.ON_BROWSER_TRANSLATE_DETECTED_ID),t=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(typeof window>"u")return;const n=()=>{Xu(()=>{e.fire()})},o=()=>{t.current!=null&&clearTimeout(t.current),t.current=setTimeout(()=>{t.current=null,n()},Ju)};n();const i=()=>{o()},s=()=>{document.visibilityState==="visible"&&o()},c=new MutationObserver(()=>{o()});return c.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),window.addEventListener("focus",i),document.addEventListener("visibilitychange",s),()=>{t.current!=null&&clearTimeout(t.current),Qu(),c.disconnect(),window.removeEventListener("focus",i),document.removeEventListener("visibilitychange",s)}},[e])}var so={},Qi=(0,l.createContext)(so),Xi=(0,l.createContext)({current:so}),Ji=(0,l.createContext)(()=>{});function ep({children:e}){const t=r.useDispatch(),n=r.useSelector(r.selectActiveSettingsTab),o=r.useEvent(h.SETTINGS_PANEL_EVENT),[i,s]=(0,l.useState)(so),c=(0,l.useRef)(i);return c.current=i,(0,l.useEffect)(()=>{const d=o(u=>{const p=u?.type===h.ADVANCED_SETTINGS_PANEL;if((!u||!u.type&&!u.content&&!u.advancedTabs?.length)&&n==="Properties")s({}),t(r.resetToLastActiveSettingsTab());else if(n!=="Properties"&&t(r.setActiveSettingsTab(r.PROPERTIES)),u.advancedTabs?.length&&!p&&!u.content){const f=u.advancedTabs.map(g=>({content:g.content,label:g.label,key:g.key,className:g.className}));s(g=>({settings:{},extraTabs:f}))}else if(p&&u.content){const f=u.advancedTabs?.map(g=>({content:g.content,label:g.label,key:g.key,className:g.className}));s(g=>({settings:{},type:u.type,content:u.content,instanceKey:u.instanceKey,parent:u.parent,caption:u.caption,extraTabs:f,deletable:u.deletable}))}});return()=>d.dispose()},[o,s,t,n]),(0,a.jsx)(Ji.Provider,{value:s,children:(0,a.jsx)(Xi.Provider,{value:c,children:(0,a.jsx)(Qi.Provider,{value:i,children:e})})})}function ao(){return(0,l.useContext)(Qi)}function tp(){return(0,l.useContext)(Xi)}function np(){return(0,l.useContext)(Ji)}var Zi={widthCodeSplit:50,isResizing:!1,currentSide:null},es=(0,l.createContext)({current:Zi}),ts=(0,l.createContext)(Zi.widthCodeSplit),ns=(0,l.createContext)({isResizing:!1,currentSide:null}),rs=(0,l.createContext)({setWidthCodeSplit:()=>{},setIsResizing:()=>{},setCurrentSide:()=>{},setBlockMaxHeight:()=>{}}),os=(0,l.createContext)("unset");function rp({children:e}){const[t,n]=(0,l.useState)(()=>+window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_code_mode_pane_sizes)||50),[o,i]=(0,l.useState)(!1),[s,c]=(0,l.useState)(null),[d,u]=(0,l.useState)("unset"),p=(0,l.useMemo)(()=>({widthCodeSplit:t,isResizing:o,currentSide:s}),[t,o,s]),f=(0,l.useMemo)(()=>({isResizing:o,currentSide:s}),[o,s]),g=(0,l.useRef)(p);g.current=p;const y=(0,l.useMemo)(()=>({setWidthCodeSplit:n,setIsResizing:i,setCurrentSide:c,setBlockMaxHeight:u}),[]);return(0,a.jsx)(rs.Provider,{value:y,children:(0,a.jsx)(es.Provider,{value:g,children:(0,a.jsx)(ns.Provider,{value:f,children:(0,a.jsx)(ts.Provider,{value:t,children:(0,a.jsx)(os.Provider,{value:d,children:e})})})})})}function is(){return(0,l.useContext)(ns)}function ss(){return(0,l.useContext)(ts)}function op(){return(0,l.useContext)(es)}function ip(){return(0,l.useContext)(os)}function sp(){return(0,l.useContext)(rs)}var as=(0,l.createContext)({previewAlertShow:!1,templateNotEmAlertShow:!1}),ls=(0,l.createContext)({setPreviewAlertShow:()=>{},setTemplateNotEmAlertShow:()=>{}});function ap({children:e}){const[t,n]=(0,l.useState)(!1),[o,i]=(0,l.useState)(!1),s=(0,l.useMemo)(()=>({previewAlertShow:t,templateNotEmAlertShow:o}),[t,o]),c=(0,l.useMemo)(()=>({setPreviewAlertShow:n,setTemplateNotEmAlertShow:i}),[]);return(0,a.jsx)(ls.Provider,{value:c,children:(0,a.jsx)(as.Provider,{value:s,children:e})})}function lp(){return(0,l.useContext)(as)}function cp(){return(0,l.useContext)(ls)}function dp({className:e,sidePanelFloating:t,isCodeMode:n,codeModeDirection:o,children:i}){const s=ip(),c=(0,l.useMemo)(()=>{const d=Number.isFinite(s)?`${s}px`:"unset";return{"--ub-em-pane-block-height":t?n&&o==="bottom"?d:"calc(100% - 30px)":"100%"}},[t,n,o,s]);return(0,a.jsx)(_.ui_kit$Layout,{className:e,style:c,children:i})}function up({maxPaneWidth:e,isCodeMode:t,codeModeDirection:n,isShowMobileSettings:o,desktopMobileSwitchPanel:i,children:s}){const c=r.useSelector(r.selectEmailWidth),{isResizing:d,currentSide:u}=is(),p=t&&n!=="bottom"&&!o&&i?"100%":c,f=(0,l.useMemo)(()=>({maxWidth:typeof p=="number"?Math.min(p,e):e}),[p,e]);return(0,a.jsx)("div",{className:(0,rt.default)("email-pane__resizable",{"email-pane__resizable_drag":u||d}),style:f,children:s})}function pp({isCodeMode:e,codeModeDirection:t,sidePanelFloating:n,contentWrapperRef:o,children:i}){const s=ss(),c=(0,l.useMemo)(()=>({flexGrow:1,overflowY:n?"scroll":"hidden",overflowX:"hidden",height:e&&t==="bottom"?`calc(${s}%)`:"100%",width:`${t==="left"?100-s:t==="bottom"?100:s}%`}),[e,t,n,s]);return(0,a.jsx)(_.ui_kit$Col,{style:c,id:"pane-content-wrapper",ref:o,children:i})}function mp({isCodeMode:e,codeModeDirection:t,children:n}){const o=ss(),i=(0,l.useMemo)(()=>({width:`${t==="right"?100-o:t==="bottom"?100:o}%`,position:"relative",height:t==="bottom"?`calc(${100-o}%)`:"unset",display:e?"initial":"none"}),[e,t,o]);return(0,a.jsx)(_.ui_kit$Col,{style:i,children:n})}function fp({wrapperRef:e,children:t}){const{isResizing:n,currentSide:o}=is();return(0,a.jsx)("div",{className:(0,rt.default)("email-pane__content-col email-pane__content-col_main",{"email-pane__content-col_disable":o||n}),ref:e,children:t})}function gp({isShowMobileSettings:e,headless:t,templateNotEmAlertEnabled:n}){const{__:o}=r.useI18n(),{previewAlertShow:i,templateNotEmAlertShow:s}=lp();return(0,a.jsxs)(a.Fragment,{children:[i&&e&&(0,a.jsx)(_.ui_kit$Alert,{title:o("Template is not mobile-friendly"),description:o("While editing, some elements of the email no longer fit the screen of the mobile device. Check that these elements are set to a smaller width for mobile devices."),type:"warning",className:"email-pane__col__alert",closable:!0}),s&&!t&&n&&(0,a.jsx)(_.ui_kit$Alert,{title:o("Template from another editor"),description:o("This template was created in another editor. Rebuild it from our components to get stable rendering, error-free editing, and full design control."),type:"warning",className:"email-pane__col__alert",closable:!0})]})}function cs(){const e=r.useElementEntityKind(),t=r.useSelector(r.selectElementSettings$1),n=r.useSelector(r.selectElementSettings);return e==="email"?t:n}function hp({isShowMobileSettings:e,propertiesPanelKey:t,onMouseLeave:n,email:o,onClosePanel:i}){const s=cs(),c=ao();return s?.type||c?.type||c?.content||c?.extraTabs?.length?(0,a.jsx)("div",{className:(0,rt.default)("email-pane__collapse-wrapper",{"mobile-view":e,"mobile-properties":e&&t!=="Structure"}),onMouseLeave:n,children:(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(Wi,{email:o,formSettings:c,onClosePanel:i})})}):null}function _p({className:e,emailElementType:t}){return(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(gu,{className:e,emailElementType:t,formSettings:ao()})})}function yp({isCodeMode:e,codeModeDirection:t}){const n=r.useElementEntityKind(),o=cs()?.type;return!(o===r.ELEMENT_TYPES.TEXT||o===r.ELEMENT_TYPES.LINK||o===r.ELEMENT_TYPES.IMG||o===r.ELEMENT_TYPES.BUTTON)||!e||t==="bottom"?null:(0,a.jsx)(_p,{className:(0,rt.default)("selected-element-panel__content selected-element-panel__content_abs",{"selected-element-panel__hidden":o===r.ELEMENT_TYPES.IMG}),emailElementType:n})}function vp({isCodeMode:e,codeModeDirection:t,email:n,onClosePanel:o}){const i=ao();return i?.type!=="img"||!e||t==="bottom"?null:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper email-pane__collapse-wrapper_disabled",children:(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(Wi,{email:n,formSettings:i,onClosePanel:o})})})}var bp="code",Ep=(e,t)=>(0,a.jsx)(t,{className:"email-pane__tab-bar",...e}),{Content:Sp}=_.ui_kit$Layout,wp=()=>{no().catch(()=>{})},Jt=e=>(0,l.memo)(t=>(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(e,{...t})})),kp=Jt(yu),Cp=Jt(_u),Tp=Jt(vu),Ip=Jt(Eu),Ap=(0,l.memo)(e=>(0,a.jsx)(ou,{...e})),xp=(0,l.memo)((0,l.forwardRef)((e,t)=>(0,a.jsx)(Fi,{...e,ref:t}))),Pp=(0,l.memo)(e=>(0,a.jsx)(Ri,{...e})),jp=Jt(hu),Rp=Jt(wu),Op=Jt(Su),ds=({emailElement:e,isSuccess:t,setIsCollaborationEditor:n,isShowAddAllBlocksModal:o,triggerOpenSavedBlocksTab:i,setIsShowAddAllBlocksModal:s})=>{const{__:d,_x:u}=r.useI18n(),p=r.useMessageService(),{blockId:f}=r.useRouteParams(),g=r.useEditorProjectId(),y=r.useRouteEmailId(),m=r.useDispatch(),S=qr(),k=r.useOpenPlanCatalog(),{modal:w}=_.ui_kit$App.useApp(),b=r.useAppConfig(),A=r.useConfigSource(),x=r.useHeadless(),Y=r.useContainer(),Z=Hi("panel");fu(Y),(0,l.useEffect)(()=>{Ht(Y).notePagePainted()},[Y]);const{token:M}=(0,_.ui_kit$useToken)(),O=r.useNotification(),I=r.usePushToDataLayer(),R=r.useProjectData(),z=yi(R?.id||g);Uu(z);const B=r.useCookieManager(),U=r.useSelector(r.selectActiveSettingsTab),de=r.useCurrentUser(),me=r.toLanguageCode(r.useInterfaceLocale()),q=r.useStore(),ee=op(),{setWidthCodeSplit:Fe,setIsResizing:be,setCurrentSide:et,setBlockMaxHeight:Ee}=sp(),fe=r.useSelector(r.selectActiveModal$1),Q=r.useSelector(r.selectIsCodeMode),pe=r.useSelector(r.selectCodeModeDirection),[se,ae]=(0,l.useState)(Q);(0,l.useEffect)(()=>{Q&&ae(!0)},[Q]);const Ie=r.useSelector(Ou),Ce=r.useSelector(Lu),Be=r.useSelector(Mu),J=r.useSelector(r.selectPropertiesPanelKey),[_e]=r.useLazyClearAiChatQuery(),[Te]=r.useUploadImageMutation(),ge=r.useSelector(r.selectEmailViewType)===r.MOBILE,[Re,ze]=(0,l.useState)(r.LIGHT),[C,T]=(0,l.useState)(),[P,N]=(0,l.useState)(b.defaultBuildPanel||"empty"),[D,v]=(0,l.useState)("empty"),[W,Pe]=(0,l.useState)(!1),[Ae,Qe]=(0,l.useState)([]),[Ge,Ze]=(0,l.useState)([]),{setPreviewAlertShow:pt,setTemplateNotEmAlertShow:bt}=cp(),{open:ft,close:lt}=Wu(),{open:G,close:K}=Hu();Zu();const ne=r.useRootElement(),ue=r.isEditorLockedByPlan(R,{isPlugin:!0}),he=r.usePlanFeatureGate("discussion"),We=r.usePlanFeatureGate("code_editor"),Ve=zi("ai"),st=Ve.exceeded?r.getLimitUpgradePresetDefinition(Ve.exceeded.presetId):null,Bt=b?.configSwither||!1;(0,l.useEffect)(()=>{m(r.resetParentBlocks())},[m]),(0,l.useEffect)(()=>{const E=window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_active_tab);E&&m(r.setActiveSettingsTab(E))},[B,m]);const Me=y||f,Xe=e.hasOwnProperty("type")?r.BLOCK:r.EMAIL,ie=np(),te=tp(),$=(0,l.useRef)(null),le=(0,l.useRef)(null),xe=(0,l.useRef)(),Se=(0,l.useRef)(),Ne=(0,l.useRef)(null),He=(0,l.useRef)(),$e=(0,l.useRef)(),ot=(0,l.useRef)(null),fn=(0,l.useRef)(!1),Ot=(0,l.useRef)(!1),ct=(0,l.useCallback)(()=>{Ot.current=!1},[]),Et=(0,l.useCallback)(()=>{Ot.current=!0},[]),Lt=(0,l.useCallback)(E=>{E?.type===r.ELEMENT_TYPES.SOCIAL&&Et()},[Et]),[Rn,On]=(0,l.useState)(!1),[gn,Ln]=(0,l.useState)(!1),[Mn]=r.useEditMeMutation(),[gt,St]=(0,l.useState)(!1),[ce,we]=(0,l.useState)(0),[De,nt]=(0,l.useState)(!1),Oe=(0,l.useCallback)(()=>nt(!1),[]),Yt=(0,l.useCallback)(()=>{nt(!1),k()},[k]),[$t,dt]=(0,l.useState)(!1),Nn=b.configSwither?localStorage.getItem("configSwither")==="pro"?!0:localStorage.getItem("configSwither")==="editor"?!1:b.mode==="pro":!1,Ut=(0,l.useCallback)(()=>{clearTimeout(ot.current);const E=".blocks-search__result-holder";ne.querySelector(E)&&(Ie||Ce||Be)&&(ne.querySelector(E).style.removeProperty("transition"),ne.querySelector(E).style.opacity=0,ot.current=setTimeout(()=>{r.measureBlockPreviews(ne,207/640),ne.querySelector(E)&&(ne.querySelector(E).style.transition="opacity 0.2s",ne.querySelectorAll(E).forEach(j=>j.style.opacity=1))},200))},[Ce,Ie,Be]),Tt=(0,l.useRef)(void 0),It=(0,l.useCallback)(E=>{const j=E.target;j&&(window.clearTimeout(Tt.current),Tt.current=window.setTimeout(()=>{On(!!j.closest(".desktop_view")),Ln(!!j.closest(".mobile_view"))},100))},[]);(0,l.useEffect)(()=>()=>{window.clearTimeout(Tt.current)},[]),(0,l.useEffect)(()=>{const E=r.addDocumentListenerFromShadow(ne,"mouseover",It);return()=>{E.dispose()}},[ne,It]),(0,l.useEffect)(()=>{typeof n=="function"&&(Ge.length>0?n(!0):n(!1))},[Ge]);const[Dr]=r.useSendMessageMutation(),{data:ht={},refetch:L,status:V}=r.useGetDialogQuery({entity_id:Me},{skip:!Me||b.aiAssistentEnabled===!1||ue}),X=r.useEventEmitter(h.events.AI_TEXT_REQUEST_ID).hasListeners(),oe=r.useIsStandalone(),re=!X&&!oe,H=(0,l.useMemo)(()=>re?[{data:{role:"assistant",message:d("Typing..."),isLoading:!0}}]:[],[re,d]),[ke,ye]=(0,l.useState)([]),[qe,hn]=(0,l.useState)(b.defaultBuildPanel!==""?r.BLOCKS:r.ATOMS),Dn=(0,l.useRef)(null),mt=(0,l.useCallback)(()=>{const E=Se.current?.getBoundingClientRect(),j=C?.getBoundingClientRect();p.send({operation:r.EVENT_TYPES.SANDBOX_WINDOW_CHARACTERISTIC,settings:{iframeOffsetTop:Q&&pe!=="bottom"?0:30,scrollTop:-E?.top+j?.top+30,innerHeight:window.innerHeight,previewHeight:j?.height,mode:Q&&pe!=="bottom"?bp:"default"}})},[pe,Q,C,p]),Fr=t&&e,_n=(0,l.useCallback)(E=>{const j=window.navigator.platform.match("Mac");b.codeEnabled&&b.codeSideEnabled&&E.altKey&&E.keyCode===88&&(S.toggle(),We.isLocked&&(St(!0),we(r.FEATURE_UPSELL_SLIDE.code_editor))),((j?E.metaKey:E.ctrlKey)&&E.shiftKey&&E.keyCode===76||(j?E.metaKey:E.ctrlKey)&&E.shiftKey&&E.keyCode===69||(j?E.metaKey:E.ctrlKey)&&E.shiftKey&&E.keyCode===82)&&E.preventDefault()},[b.codeEnabled,We.isLocked,b.codeSideEnabled,S]),wt=fe.includes("UPLOAD_IMAGE_")||fe.includes("UPLOAD_BACKGROUND_"),yn=(0,l.useRef)(!1),_t=(0,l.useCallback)(E=>{const j=E.target,F=j.closest(".email-pane__content-col")||j.closest(".email-pane__collapse-wrapper")||j.closest(".selected-element-panel-content")||j.closest(".selected-element-panel")||j.closest(".em-analytics__email-tab-properties")||j.closest(".em-analytics__email-tab-styles")||j.closest(".em-analytics__email-tab-history")||j.closest(".blocks-modal-container")||j.closest(".email-pane__sizes")||j.closest(".email-preview-menu")||j.closest(".monaco-editor")||j.closest(".ant-modal-wrap");yn.current=!!F},[]),za=(0,l.useCallback)(E=>{const j=yn.current,F=window.getSelection().toString().length>0||document.activeElement&&document.activeElement.tagName==="INPUT"&&document.activeElement.selectionStart!==document.activeElement.selectionEnd;yn.current=!1,!(j||F)&&(!document.querySelector(".easylogic-colorpicker")&&!ne.querySelector(".easylogic-colorpicker")&&!E.target.closest(".email-pane__content-col")&&!E.target.closest(".blocks-modal-container")&&!E.target.closest(".email-pane__collapse-wrapper")&&!E.target.closest(".selected-element-panel__columns-settings__controls__column__remove")&&!E.target.closest(".email-preview__content-col_main")&&!E.target.closest(".email-preview-menu")&&!E.target.closest(".monaco-editor")&&!E.target.closest(".main__pane-close-btn")&&!E.target.closest(".main__pane-trigger")&&!E.target.closest(".ant-modal-wrap")&&!E.target.closest(".email-pane__sizes")&&!E.target.closest(".ant-input-clear-icon")&&!E.target.closest(".ant-color-picker")&&!E.target.closest(".control-font-family-dropdown")&&!Dn.current&&!E.target.closest(".email-preview-menu__history")&&!E.target.closest(".selected-element-panel-content")&&!E.target.closest(".ant-select-dropdown")&&!E.target.closest(".ant-picker-dropdown")&&!E.target.closest(".toggle_view")&&!E.target.closest(".upload-bg-image__menu")&&!E.target.closest(".email-pane__paths")&&!E.target.closest(".ant-tabs-extra-content")&&!E.target.closest(".anticon-delete")&&!wt&&fe!==r.MODALS.IMAGE_EDITOR_MODAL&&(U==="Properties"&&(Et(),m(r.resetToLastActiveSettingsTab()),p.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),Qe([])),U==="History"&&m(r.setActiveSettingsTab(r.BUILD)),m(r.switchIsPanelHistoryCollapsed(!0)),p.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1}),setTimeout(()=>{e.type?m(r.setElementSettings({type:null})):m(r.setElementSettings$1({type:null}))},300)),Dn.current=null)},[m,e.type,fe,U,p,wt]),[fv,Ga]=(0,l.useState)(!0),{data:Ho=[],refetch:Br}=r.useGetCommentsQuery(Me,{skip:!Me||ue});(0,l.useEffect)(()=>{Me&&!ue&&Br()},[U,Me,ue,Br]),(0,l.useEffect)(()=>{Me&&!Object.keys(ht).length&&V==="fulfilled"&&L()},[U,Me,L,ht,V]),(0,l.useEffect)(()=>{const E=new h.Disposable,j=window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_active_tab);if(ht?.totalCount===0&&V!=="pending"){const je={project_id:g,connection:"chat",entity_id:Me,context:"default",locale:me};!j&&re&&r.runOnceInFlight(`email-default-context:${Me}`,()=>{r.swallowPromiseRejection(Dr({body:je}).then(()=>{E.isDisposed()||V==="fulfilled"&&L()}))})}const F={data:{role:"assistant",message:d("Typing..."),isLoading:!0}};return ht?.documents?.length>0?(window.localStorage.removeItem(r.LOCAL_STORAGE_ITEMS.em_active_tab),ye(ht?.documents),re&&ht?.documents[ht?.documents?.length-1].data?.userInfo&&ye([...ht?.documents,F])):j||ye(re?[F]:[]),()=>E.dispose()},[Me,me,ht?.totalCount,ht?.documents,re,g,L,Dr,V]),(0,l.useEffect)(()=>{ie({}),m(Xe==="email"?r.setElementSettings$1({}):r.setElementSettings({}))},[m,Xe]);const Wa=(0,l.useCallback)(E=>{m(r.setEmailSettings(Yn(E)))},[m]),Ha=(0,l.useCallback)(E=>{m(r.setBlockSettings(Yn(E)))},[m]),Fn=(0,l.useCallback)(E=>{m(Xe==="email"?r.setElementSettings$1(Yn(E)):r.setElementSettings(Yn(E)))},[m,Xe]);(0,l.useEffect)(()=>{const E=He.current,j=Ne.current;T(Q?j??E:E)},[Q,pe]);const[gv,hv]=(0,l.useState)(null),_v=(0,l.useCallback)(E=>{b.sidePanelFloating&&(Ne.current=E),hv(E)},[b.sidePanelFloating]),Bn=(0,l.useCallback)(E=>{N(E),E==="search"?Pe(!0):(Pe(!1),v(E)),setTimeout(Ut,50)},[Ut]),yv=(0,l.useCallback)(E=>{const j=E.data.operation,F=E.data,je=E.data.action;if(j==="application_block_inserted"||E.data.operationId==="application_block_inserted"){const Le=E.data.operationId?E.data.data:F||{},Nt=Le.type==="project"||Le.type==="template"||Le.type==="common"?"block":"structure",bn=Le.name||Le.type||(Nt==="block"?"block":"structure");I({event:"add",action:"add_element_to_email",element_type:Nt,element_name:bn,entity_id:e?.id||y||f,project_id:R?.id||g})}if(j===r.EVENT_TYPES.APPLICATION_SCROLL_TO&&setTimeout(()=>{Ne.current?.scrollTo({top:E.data.settings.value,behavior:"smooth"})},100),j===r.EVENT_TYPES.APPLICATION_PREVIEW_ALERT_SHOW&&pt(F.settings.show),j===r.EVENT_TYPES.APPLICATION_TEMPLATE_NOT_EM_ALERT_SHOW&&bt(!0),j===r.EVENT_TYPES.APPLICATION_ACTION&&je==="toggle_editor"&&S.toggle(),j===r.EVENT_TYPES.APPLICATION_IFRAME_SET_HEIGHT&&(ne.querySelector(".email-pane__iframe").style.height=F.settings.height+"px"),j===r.EVENT_TYPES.APPLICATION_EMAIL_SETTINGS_SET){let Le=Object.assign({},F.settings);delete Le.preheader,Object.values(Le).every(Nt=>!Nt)?(m(r.setEmailSettingsDisable(!0)),m(r.resetToLastActiveSettingsTab())):Wa(F.settings),F.settings.noBlocks,m(r.setMobileViewActive(F.settings.responsive)),Ga(Le.structuresMedia)}if(j===r.EVENT_TYPES.APPLICATION_BLOCK_SETTINGS_SET&&(Object.values(F.settings).every(Le=>!Le)?(m(r.setBlockSettingsDisable(!0)),m(r.resetToLastActiveSettingsTab())):(Ha(F.settings),Ga(F.settings.structuresMedia))),j===r.EVENT_TYPES.APPLICATION_ELEMENT_SETTINGS_SET){const Le=Object.values(r.ELEMENT_TYPES).includes(F.type),Nt=te.current,bn=Nt?.type==="advanced"&&!!Nt.content,At=F.tab?!0:!Le&&!bn,{type:Rv,caption:Ov,settings:Lv}=F,el=JSON.stringify([Rv,Ov,Lv]),Mv=el!==$.current;if($.current=el,At&&U==="Properties"&&m(r.resetToLastActiveSettingsTab()),F.type===r.ELEMENT_TYPES.EMPTY_TABLE||F.type===r.ELEMENT_TYPES.EMPTY_TD?(m(r.setActiveSettingsTab(r.BUILD)),F.type===r.ELEMENT_TYPES.EMPTY_TABLE?(hn(r.BLOCKS),F.tab?Bn(F.tab):Bn("common")):F.type===r.ELEMENT_TYPES.EMPTY_TD&&hn(r.ATOMS)):F.type&&U!=="Properties"?F.type===r.ELEMENT_TYPES.SOCIAL&&Ot.current?ct():(ct(),m(r.setActiveSettingsTab(r.PROPERTIES))):F.type!==r.ELEMENT_TYPES.SOCIAL&&ct(),!Mv)return;F.type===r.ELEMENT_TYPES.CAROUSEL||F.type===r.ELEMENT_TYPES.ACCORDION||F.type===r.ELEMENT_TYPES.SOCIAL?(ie(tn=>({settings:{...F.settings,type:At?null:F.type,caption:F.caption,parent:At?null:F.settings.parent},type:At?null:F.type,parent:At?null:F.settings.parent,caption:F.caption,extraTabs:tn.extraTabs})),Fn({})):(Fn({...F.settings,type:At?null:F.type,parent:At?null:F.settings.parent,caption:F.caption}),ie(tn=>!Le&&tn.type==="advanced"&&tn.content?{...tn,settings:{...F.settings,type:F.type,parent:F.settings?.parent,caption:F.caption}}:tn.extraTabs?.length?{extraTabs:tn.extraTabs}:{})),F.settings?.path?.length>0&&Qe(F.settings?.path)}j===r.EVENT_TYPES.APPLICATION_ELEMENT_SETTINGS_CLOSE&&($.current=null,te.current?.type===r.ELEMENT_TYPES.SOCIAL&&Et(),m(r.resetToLastActiveSettingsTab()))},[m,Wa,Ha,Fn,U,Bn,ne,I,e,y,f,R,ct,Et,S,g,te,ie,pt,bt]);(0,l.useEffect)(()=>{r.identifyUser({id:de?.id,email:de?.email,username:de?.name})},[de]),(0,l.useEffect)(()=>{const E=de.email_builder_config,j=!ue,F=A.get()?.mode;if(!E||typeof E!="string")return;const je=j&&E==="simple"?"pro":E;je!==F&&m(r.changeConfig(je))},[ue,de.email_builder_config,de.id,m,q,A]),(0,l.useEffect)(()=>{if(Q&&We.isLocked&&S.toggle(),b.configSwither){let E=localStorage.getItem("configSwither")||b.mode||"editor";localStorage.setItem("configSwither",E),m(r.changeConfig(E))}},[]);const qa=E=>{setTimeout(()=>{if(ue)m(r.changeConfig("pro")),dt(!0),St(!0),I({event:"change",action:"change_config_mode",config_mode:"pro",entity_id:e?.id||y||f,project_id:R?.id||g});else{let j=E?"pro":"editor";localStorage.setItem("configSwither",j),m(r.changeConfig(j)),I({event:"change",action:"change_config_mode",config_mode:j,entity_id:e?.id||y||f,project_id:R?.id||g})}},200)},vv=()=>{Q&&S.toggle(),m(r.resetToLastActiveSettingsTab()),m(r.changeConfig("simple")),dt(!1),St(!1),I({event:"change",action:"change_config_mode",config_mode:"simple",entity_id:e?.id||y||f,project_id:R?.id||g})},bv=(0,l.useCallback)(()=>{St(!1)},[]);r.useListenPostMessage(yv),(0,l.useEffect)(()=>{const E=p.addListener(j=>{const F=zu(j,r.EVENT_TYPES.APPLICATION_NATIVE_IMAGE_DROP);if(!F)return;const je=()=>p.send({operation:r.EVENT_TYPES.SANDBOX_NATIVE_IMAGE_DROP_CLEAR});(async()=>{const Le=await Gu(F,{readContext:()=>({userId:de?.id,folderId:R?.id??g}),prepare:At=>r.prepareImageForEditorUpload(At,b),upload:At=>Te(At)});if(Le.status==="failed"&&O.fromError("IMAGE_UPLOAD_ERROR",F,Le.error,!0),Le.status!=="uploaded"){je();return}p.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_SETTINGS_SET,type:r.ELEMENT_TYPES.IMG,settings:{src:Le.url}});const Nt=q.getState(),bn=Xe==="email"?r.selectElementSettings$1(Nt):r.selectElementSettings(Nt);bn?.type===r.ELEMENT_TYPES.IMG&&Fn({...bn,src:Le.url,changeKey:"src"})})()});return()=>E.dispose()},[p,Te,de,g,R?.id,b,O,Fn,q,Xe]),(0,l.useEffect)(()=>{const E=p.addListener("application_atom_inserted",F=>{I({event:"add",action:"add_element_to_email",element_type:"atom",element_name:F||"atom",entity_id:e?.id||y||f,project_id:R?.id||g})}),j=p.addListener("application_block_inserted",F=>{const je=F?.type==="project"||F?.type==="template"||F?.type==="common"?"block":"structure",Le=F?.name||F?.type||(je==="block"?"block":"structure");I({event:"add",action:"add_element_to_email",element_type:je,element_name:Le,entity_id:e?.id||y||f,project_id:R?.id||g})});return()=>{E?.dispose(),j?.dispose()}},[p,I,e?.id,y,f,g,R?.id]);const Ev=E=>{let j=ne.querySelector(".atoms__list");b.toggleSidePanel&&E===U?m(r.setActiveSettingsTab(r.DISABLED_TAB)):E==="Optimize"?xt.comingSoonHandler(d,w):E!=="Properties"&&E!=="History"?(m(r.setActiveSettingsTab(E)),I({event:"navigate",action:"navigate_email_pane_tab",tab_name:E==="Disabled_tab"?"DISABLED_TAB":E,entity_id:e?.id||y||f,project_id:R?.id||g}),p.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1}),p.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),Qe([])):(E==="Properties"||E==="History")&&I({event:"navigate",action:"navigate_email_pane_tab",tab_name:E,entity_id:e?.id||y||f,project_id:R?.id||g}),he.isLocked&&E==="Discuss"&&(St(!0),we(r.FEATURE_UPSELL_SLIDE.discussion)),ue&&E==="Optimise"&&(St(!0),we(6)),Ve.isLocked&&E==="AiChat"&&(Ve.state.state==="locked_by_limit"&&Ve.exceeded?nt(!0):(St(!0),we(9)))},qo=(0,l.useRef)(null),$r=(0,l.useRef)(void 0),Mt=(0,l.useCallback)(()=>{const E=Ne.current?.getBoundingClientRect();if(qo?.current?.getBoundingClientRect().top>=0&&E){const j=Math.round(E.height-30);qo.current.style.height=`${j}px`,Ee(j-30)}$r.current&&window.clearTimeout($r.current),$r.current=window.setTimeout(function(){p.isInited()&&mt()},100)},[mt,p,Ee]);(0,l.useEffect)(()=>()=>{window.clearTimeout($r.current)},[]),(0,l.useEffect)(()=>(U==="AiChat"&&!ue?le.current=setInterval(()=>{L({entity_id:Me})},5e3):clearInterval(le.current),clearInterval(le.current)),[Me,ue,L,U]);const Sv=E=>hn(E||""),wv=()=>{Pe(!1),N(D)},Vo=()=>{let E=ne.querySelector(".block-search__preview");E&&(E.style.opacity="0",E.style.transform="translateX(-99%)",setTimeout(function(){E.remove()},300))};let vn=[];const $n={display:"flex",alignItems:"center",justifyContent:"center"};b.blocksEmptyEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Empty blocks"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"BorderOuterOutlined",component:_.icons$BorderOuterOutlined,style:{fontSize:18}})})}),value:"empty"}),b.blocksSavedEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Saved blocks"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"AppstoreAddOutlined",component:_.icons$AppstoreAddOutlined,style:{fontSize:18}})})}),value:"project"}),b.blocksCommonEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Common blocks"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"AppstoreOutlined",component:_.icons$AppstoreOutlined,style:{fontSize:18}})})}),value:"common"}),b.blocksTemplateEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Template blocks"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"BuildOutlined",component:_.icons$BuildOutlined,style:{fontSize:18}})})}),value:"template"}),b.blocksSearchEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Blocks search"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"SearchOutlined",component:_.icons$SearchOutlined,style:{fontSize:18}})})}),value:"search"});const Ur=P!=="empty"||W,kv=!b.blocksSectionsShow||Ur?"100%":"calc(100% - 44px)";let Cv=[{label:(0,a.jsx)("div",{className:"email-pane__tab",children:d("Elements")}),key:r.ATOMS,className:"email-pane__collapse-panel email-pane__atoms",children:(0,a.jsx)(Pp,{})},{label:(0,a.jsx)("div",{className:"email-pane__tab",children:d("Blocks")}),key:r.BLOCKS,className:"email-pane__collapse-panel email-pane__blocks-search",style:{height:kv},children:(0,a.jsxs)("div",{className:(0,rt.default)("email-pane__blocks-panel",{"email-pane__blocks-panel_scrollable":Ur}),children:[b.blocksSectionsShow&&(0,a.jsxs)("div",{className:"email-pane__blocks-panel-header",children:[(0,a.jsxs)(_.ui_kit$Space.Compact,{block:!0,children:[!W&&(0,a.jsx)(_.ui_kit$Segmented,{block:!0,style:{width:"100%",marginTop:24},onChange:Bn,value:P,options:vn}),W&&(0,a.jsx)("div",{style:{width:"100%",height:36}}),W&&(0,a.jsx)("div",{style:{width:36,textAlign:"right",marginTop:22},children:(0,a.jsx)(r.EmIcons,{icon:"CloseOutlined",component:_.icons$CloseOutlined,style:{padding:"0 2px 0",cursor:"pointer"},onClick:wv})})]}),(0,a.jsx)("div",{className:"blocks-search__divider-wrapper",style:{marginTop:W?28:12},children:(0,a.jsx)(_.ui_kit$Divider,{className:"blocks-search__divider"})})]}),(0,a.jsxs)("div",{className:"email-pane__blocks-panel-body",children:[(0,a.jsx)("div",{className:"blocks-search__empty-shadow",style:{display:P==="empty"&&!W?"block":"none"},children:fv?(0,a.jsx)(ui,{}):(0,a.jsx)(ci,{})}),(0,a.jsx)("div",{className:(0,rt.default)("email-pane__blocks-panel-results",{"email-pane__blocks-panel-results_visible":Ur}),children:(0,a.jsx)(Ip,{parentEmailId:e?.parent_email,blocksTab:P,search:W,reloadBlockScreens:Ut,setIsShowAddAllBlocksModal:s})})]})]})}];const Un=[{disabled:gt,key:r.PROPERTIES,style:{height:"var(--ub-em-pane-block-height)"},className:"em-analytics__email-tab-properties",children:(0,a.jsx)(hp,{isShowMobileSettings:ge,propertiesPanelKey:J,onMouseLeave:Vo,email:e,onClosePanel:Lt})},{disabled:gt,key:r.HISTORY,style:{height:"var(--ub-em-pane-block-height)"},className:"em-analytics__email-tab-history",children:Fr&&(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",onMouseLeave:Vo,children:(0,a.jsx)(Rp,{setCollapsedHistory:()=>m(r.switchIsPanelHistoryCollapsed(!0)),emailElement:Fr})})},{key:r.DISABLED_TAB,className:"em-analytics__email-tab-properties"},{disabled:gt,label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"left",title:u("Build","tab"),children:(0,a.jsx)(r.EmIcons,{"data-testid":"contentIcon",icon:"PlusCircleOutlined",component:_.icons$PlusCircleOutlined,size:24,strokeWidth:b.iconStrokeWidth})}),key:r.BUILD,className:"em-analytics__email-tab-build",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:(0,rt.default)("email-pane__collapse-wrapper",{"email-pane__collapse-wrapper_no-topleft-radius":U==="Build"||!U,"email-pane__collapse-wrapper_build":qe==="Blocks"&&Ur}),onMouseLeave:Vo,children:(0,a.jsx)(_.ui_kit$Tabs,{className:(0,rt.default)("secondary-tabs email-pane__collapse",{"secondary-tabs_unset_scroll":qe===r.BLOCKS}),size:"large",activeKey:qe,onChange:Sv,items:Cv})})},{disabled:gt,label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"left",title:u("Styles","tab"),children:(0,a.jsx)(r.EmIcons,{"data-testid":"stylesIcon",icon:"Styles",component:_.icons$Styles,size:24,strokeWidth:b.iconStrokeWidth})}),key:r.STYLES,className:"em-analytics__email-tab-styles",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(Cp,{email:e})})}];b.commentsEnabled&&Un.push({disabled:gt,label:(0,a.jsxs)(_.ui_kit$Tooltip,{placement:"left",title:u("Discuss","tab"),children:[(0,a.jsx)(r.EmIcons,{"data-testid":"commentsIcon",icon:"CommentOutlined",component:_.icons$CommentOutlined,size:24,strokeWidth:b.iconStrokeWidth}),he.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:b.iconStrokeWidth,className:"free-mode-firewall-icon free-mode-firewall-icon_emailpane"}),!!Ho.length&&(0,a.jsx)("span",{className:"email-pane__comment-counter",children:Ho.filter(E=>E.comment_status!=="deleted").length})]}),key:"Discuss",className:"email-pane__tab-discuss em-analytics__email-tab-discuss",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(_.ui_kit$Tabs,{className:"secondary-tabs email-settings__collapse discuss-wrapper",size:"large",activeKey:"Discuss",items:[{label:(0,a.jsx)(a.Fragment,{children:d("Discuss")}),key:"Discuss",forceRender:!0,className:"email-settings__collapse-panel",children:Me?(0,a.jsx)(Op,{email:e,comments:Ho,subjectId:Me,isLoggedIn:!0,emailElementType:Xe}):(0,a.jsx)("div",{className:"aside-content-wrapper",children:e.hasOwnProperty("type")?(0,a.jsx)(_.ui_kit$Alert,{description:d("Save the block before commenting."),type:"info",showIcon:!0,style:{marginBottom:20}}):(0,a.jsx)(_.ui_kit$Alert,{description:d("Save the email before commenting."),type:"info",showIcon:!0,style:{marginBottom:20}})})}]})})});const Tv=()=>{_e({entity_id:Me}).then(E=>{E.error?O.error({title:E.error.data.code,description:E.error.data.message}):E.data.success&&O.success({title:d("Success"),description:E.data.success}),ue||L()})};b.aiAssistentEnabled&&Un.push({disabled:gt,label:(0,a.jsxs)(_.ui_kit$Tooltip,{placement:"left",title:u("AI assistant","tab"),children:[(0,a.jsx)(r.EmIcons,{"data-testid":"aiAssistentIcon",icon:"AI",component:_.icons$AI,size:24,strokeWidth:b.iconStrokeWidth}),Ve.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:b.iconStrokeWidth,className:"free-mode-firewall-icon free-mode-firewall-icon_emailpane"}),ht?.totalCount>0&&Me&&(0,a.jsx)("span",{className:"email-pane__comment-counter",children:ht?.totalCount})]}),key:"AiChat",className:"email-pane__tab-discuss em-analytics__email-tab-discuss",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(_.ui_kit$Tabs,{className:"secondary-tabs email-settings__collapse discuss-ai-wrapper",size:"large",activeKey:"AiChat",tabBarExtraContent:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Clear chat"),children:(0,a.jsx)(_.ui_kit$Popconfirm,{description:d("Clear chat history?"),onConfirm:Tv,okText:d("Yes"),cancelText:d("No"),icon:"",placement:"leftTop",title:!1,children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsx)(r.EmIcons,{icon:"ClearChat",component:_.icons$ClearChat,style:{fontSize:16}}),style:{marginRight:16}})})}),items:[{label:(0,a.jsx)(a.Fragment,{children:d("AI assistant")}),key:"AiChat",forceRender:!0,className:"email-settings__collapse-panel",children:Me||window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_active_tab)?(0,a.jsx)(kp,{messages:ke.length>0?ke:H,newEmailAiGeneratorRef:fn}):(0,a.jsx)("div",{className:"aside-content-wrapper",children:e.hasOwnProperty("type")?(0,a.jsx)(_.ui_kit$Alert,{description:d("Save the block before commenting."),type:"info",showIcon:!0,style:{marginBottom:20}}):(0,a.jsx)(_.ui_kit$Alert,{description:d("Save the email before commenting."),type:"info",showIcon:!0,style:{marginBottom:20}})})}]})})})}),b.optimizeEnabled&&Un.push({disabled:gt,label:(0,a.jsxs)(_.ui_kit$Tooltip,{placement:"left",title:u("Optimize","tab"),children:[(0,a.jsx)(r.EmIcons,{"data-testid":"optimizeIcon",icon:"Speed",component:_.icons$Speed,size:24,strokeWidth:b.iconStrokeWidth}),ue&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:b.iconStrokeWidth,className:"free-mode-firewall-icon free-mode-firewall-icon_emailpane"})]}),key:"Optimise",className:"em-analytics__email-tab-optimise",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(_.ui_kit$Tabs,{className:"secondary-tabs secondary-tabs_optimise email-settings__collapse optimise-wrapper",size:"large",activeKey:"Optimise",items:[{label:(0,a.jsx)(a.Fragment,{children:d("Optimize")}),key:"Optimise",forceRender:!0,className:"email-settings__collapse-panel",children:(0,a.jsx)(Tp,{})}]})})}),b.settingsEnabled&&Un.push({disabled:gt,label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"left",title:u("Settings","tab"),children:(0,a.jsx)(r.EmIcons,{"data-testid":"settingsIcon",icon:"SettingOutlined",component:_.icons$SettingOutlined,size:24,strokeWidth:b.iconStrokeWidth})}),key:"Edit",className:"em-analytics__email-tab-edit",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(jp,{email:e})})});const Va=U===r.DISCUSS,Ka=(0,l.useRef)(0),Ya=(0,l.useRef)(0),Qa=(0,l.useRef)(0),Iv=(0,l.useCallback)(()=>(ne.querySelector(".email-pane__col_preview")?.getBoundingClientRect().width??0)-(b.sidePanelFloating?0:38),[ne,b.sidePanelFloating]);(0,l.useEffect)(()=>{Me&&!ue&&Br()},[Me,ue,Br]),(0,l.useEffect)(()=>{const E=p.onInit(()=>{p.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1}),p.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_DISCUSS,value:Va})});return()=>E.dispose()},[Va,p]),(0,l.useEffect)(()=>{if(!C||!Vi(p))return;const E=new AbortController;return Ki(p,r.DEFAULT_SANDBOX_READY_TIMEOUT_MS,E.signal).then(()=>mt()).catch(()=>{}),()=>E.abort()},[C,mt,p]);const Ko=(0,l.useCallback)(E=>{const j=E??r.selectEmailWidth(q.getState());p.send({operation:r.EVENT_TYPES.SANDBOX_IFRAME_SETSIZE,settings:{iframeWidth:typeof j=="number"?j+2:j}}),xe.current?.resize()},[q,p]);(0,l.useEffect)(()=>{if(!ge&&U!=="Disabled_tab"){const E=ne.querySelector(".email-pane__row")?.getBoundingClientRect().width;Se?.current?.getBoundingClientRect().width+540>E&&m(r.setEmailWidth("100%"))}},[m,U,ne,ge]);const Yo=(0,l.useCallback)(()=>{const E=Se.current;E&&(E.style.borderWidth="1px",b.sidePanelFloating||(E.style.marginLeft="-1px",E.style.marginRight="-1px"),E.style.borderLeftColor=null,E.style.borderRightColor=null)},[b.sidePanelFloating]),Xa=(0,l.useCallback)(E=>{const j=ee.current.widthCodeSplit;be(!1),ee.current.currentSide&&(setTimeout(()=>Ko(),50),et(null)),E.target.classList.contains("email-pane__handle")||Yo(),window.localStorage.setItem(r.LOCAL_STORAGE_ITEMS.em_code_mode_pane_sizes,JSON.stringify(j))},[Ko,ee,be,et,Yo]),Ja=E=>j=>{j.target.classList.contains("email-pane__handle")&&(j.preventDefault(),Ka.current=j.target.parentNode.offsetWidth,Ya.current=j.pageX,Qa.current=Iv(),et(E),Dn.current=E)},zr=E=>{const j=Se.current,{currentSide:F}=ee.current;typeof E=="string"&&(!F||F===E)?(ne.querySelector(".email-pane__iframe").style.width="calc(100% + 1px)",E==="right"?(j.style.borderRightColor=M.colorPrimary,j.style.borderRightWidth="2px"):(j.style.borderLeftColor=M.colorPrimary,j.style.borderLeftWidth="2px",ne.querySelector(".email-pane__iframe").style.marginLeft="-1px")):F||(Yo(),ne.querySelector(".email-pane__iframe").style.width="1px",ne.querySelector(".email-pane__iframe").style.removeProperty("margin-left"))},Av=(0,l.useCallback)(()=>{be(!0)},[be]),Qo=(0,l.useCallback)(E=>{const{currentSide:j}=ee.current;if(!j)return;const F=(E.pageX-Ya.current)*2,je=Ka.current+(j==="left"?-F:F),Le=Math.min(Qa.current,1200);je>318&&je<Le&&(m(r.setEmailWidth(Math.min(je,1200))),xe.current?.resize())},[m,ee]),Xo=(0,l.useCallback)(E=>{if(ee.current.isResizing)if(pe==="bottom"){const j=$e.current.getBoundingClientRect().height,F=$e.current.getBoundingClientRect().top,je=(E.clientY-F)/j*100;if(je<20||je>80)return;Fe(je),Mt()}else{const j=$e.current.getBoundingClientRect().width,F=$e.current.getBoundingClientRect().left,je=(E.clientX-F)/j*100,Le=Se.current.getBoundingClientRect().width;if(b.desktopMobileSwitchPanel&&typeof Le=="number"&&Le<=425&&m(r.setEmailWidth(425)),je<20||je>80)return;Fe(je)}},[ee,Fe,pe,Mt,m,b.desktopMobileSwitchPanel]);(0,l.useEffect)(()=>{Mt()},[Q,Mt]);const xv=E=>{E?.stopPropagation?.();const j=Re==="light"?r.DARK:r.LIGHT;p.send({operation:r.EVENT_TYPES.SANDBOX_SWITCH_THEME,data:{theme:j}}),ze(j)},Za=(E="panel")=>{const j=E==="panel",F=Re===r.DARK,je={size:j?18:16,strokeWidth:j?b.iconStrokeWidth:2};return(0,a.jsx)(_.ui_kit$Tooltip,{title:d(F?"Light theme":"Dark theme"),placement:j?"top":"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:j?F?"primary":"text":"default",icon:F?(0,a.jsx)(r.EmIcons,{icon:"LightMode",component:_.icons$LightMode,...je}):(0,a.jsx)(r.EmIcons,{icon:"DarkMode",component:_.icons$DarkMode,...je}),shape:"circle",size:j?void 0:"small",onClick:xv,className:"toggle_view theme_view email-pane__theme-toggle",style:j?void 0:{left:4,top:4,zIndex:999,padding:0,position:"absolute"}})})},Jo=E=>{const j=typeof E=="number"?Math.min(E,1200):E;m(r.setEmailWidth(j)),setTimeout(()=>Ko(j),700);const F=typeof j=="number"?j:j==="100%"?"full":j,je=typeof j=="number"&&j<=425?"mobile":"desktop";I({event:"change",action:"change_email_size",email_id:e?.id||y||f,project_id:R?.id||g,width:F,view_type:je})};(0,l.useEffect)(()=>{const E=new h.Disposable;return E.addDisposable(r.addWindowListenerFromShadow(ne,"mousedown",_t,!0)),E.addDisposable(r.addWindowListenerFromShadow(ne,"click",za)),E.addDisposable(r.addWindowListenerFromShadow(ne,"mouseup",j=>Xa(j),!0)),()=>{E.dispose()}},[ne,za,_t,Xa]),(0,l.useEffect)(()=>{const E=Ne.current;if(!E||typeof ResizeObserver!="function")return;const j=new ResizeObserver(Mt);return j.observe(E),()=>j.disconnect()},[Mt,b.sidePanelFloating]),(0,l.useEffect)(()=>(window.addEventListener("scroll",Mt,!0),window.addEventListener("mousemove",Qo,!0),window.addEventListener("mousemove",Xo),window.addEventListener("keydown",_n),()=>{window.removeEventListener("mousemove",Qo,!0),window.removeEventListener("mousemove",Xo),window.removeEventListener("scroll",Mt,!0),window.removeEventListener("keydown",_n)}),[Mt,Qo,Xo,_n]);const Pv=E=>{const j=Q?"visual":"code",F=!Q;if(Q?S.toggle():typeof E=="string"?(S.setDirection(E),!Q&&S.toggle()):S.toggle(),F){const je=Xe==="block"?"block":"email",Le=typeof E=="string"?E:pe||"toggle";I({event:"activate",action:"activate_code_mode",entity_type:je,entity_id:e?.id||y||f,project_id:R?.id||g,code_mode_direction:Le})}I({event:"change",action:"change_editor_mode",editor_mode:j,entity_id:e?.id||y||f,project_id:R?.id||g}),m(r.resetToLastActiveSettingsTab()),setTimeout(()=>{m(Xe==="block"?r.setElementSettings({type:null}):r.setElementSettings$1({type:null}))},300),p.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),m(r.resetPanes())};(0,l.useEffect)(()=>{b.emailPaneDesktopSize&&m(r.setEmailWidth(b.emailPaneDesktopSize))},[m,b.emailPaneDesktopSize]);const jv=()=>{hn(r.BLOCKS),Bn("project")};return(0,l.useEffect)(()=>{i&&jv()},[i]),(0,a.jsx)(r.ElementEntityKindProvider,{kind:Xe,children:(0,a.jsxs)(dp,{className:(0,rt.default)("email-pane",{"email-pane_code-mode":Q,"email-pane_only_code_mode_mobile":b.onlyCodeModeInMobile,"email-pane_code-mode-bottom":Q&&pe==="bottom","email-pane_no-element-navigation":!b.switchDesktopMobilePropsEnabled&&!b.stepToOtherElementEnabled&&!b.deleteButtonEnabled,"email-pane_is-mobile":ge,"email-pane_path-enabled":b.pathEnabled}),sidePanelFloating:!!b.sidePanelFloating,isCodeMode:!!Q,codeModeDirection:String(pe),children:[(0,a.jsxs)(Sp,{className:"email-pane__container",ref:He,children:[(0,a.jsx)(yp,{isCodeMode:Q,codeModeDirection:pe}),(0,a.jsx)(gp,{isShowMobileSettings:ge,headless:!!x,templateNotEmAlertEnabled:!!b.templateNotEmAlertShow}),(0,a.jsxs)(_.ui_kit$Row,{ref:$e,className:(0,rt.default)("email-pane__row",{"email-pane__left":Q&&pe==="right","email-pane__right":Q&&pe==="left","email-pane__bottom":Q&&pe==="bottom","email-pane__sizeSwitcher":b.desktopMobileSwitchPanel,"email-pane__reverse":b.menuDirection==="left","email-pane__pinch":!b.sidePanelFloating}),children:[(0,a.jsxs)(pp,{isCodeMode:Q,codeModeDirection:pe,sidePanelFloating:b.sidePanelFloating,contentWrapperRef:_v,children:[(0,a.jsx)("div",{className:"email-pane__iframe-scroll-top",id:"iframe-scroll-top"}),b.desktopMobileSwitchPanel&&(0,a.jsxs)(_.ui_kit$Space,{className:"email-pane__sizes-panel-wrapper",orientation:"vertical",size:10,children:[(0,a.jsxs)(_.ui_kit$Space,{className:"email-pane__sizes-panel",size:0,children:[Za("panel"),(0,a.jsx)(_.ui_kit$Tooltip,{title:d("Desktop view"),placement:"top",open:Rn,children:(0,a.jsx)(_.ui_kit$Button,{type:ge?"text":"primary",icon:(0,a.jsx)(r.EmIcons,{icon:"DesktopOutlined",component:_.icons$DesktopOutlined,size:18,strokeWidth:b.iconStrokeWidth}),shape:"circle",onClick:()=>Jo(b.emailPaneDesktopSize||1e3),className:"toggle_view desktop_view"})}),(0,a.jsx)(_.ui_kit$Tooltip,{title:d("Mobile view"),placement:"top",open:gn,children:(0,a.jsx)(_.ui_kit$Button,{type:ge?"primary":"text",icon:(0,a.jsx)(r.EmIcons,{icon:"MobileOutlined",component:_.icons$MobileOutlined,size:18,strokeWidth:b.iconStrokeWidth}),shape:"circle",onClick:()=>Jo(425),className:"toggle_view mobile_view"})})]}),b.codeSideEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:d("Code mode"),placement:"right",children:(0,a.jsx)(_.ui_kit$Button,{type:Q?"primary":"default",icon:(0,a.jsx)(r.EmIcons,{icon:"Code",component:_.icons$Code}),shape:"circle",onClick:()=>Pv("right")})})]}),(0,a.jsxs)(_.ui_kit$Row,{className:(0,rt.default)("email-pane__col-wrapper",{container:Q&&pe==="bottom"||!Q,"email-pane__col-wrapper_reverse":b.menuDirection==="left","email-pane__col-wrapper_pinch":!b.sidePanelFloating}),style:{flexGrow:1,maxWidth:"unset",paddingTop:b.desktopMobileSwitchPanel&&Q&&pe!=="bottom"?"60px":""},children:[(0,a.jsxs)(_.ui_kit$Col,{className:"email-pane__col email-pane__col_preview",style:{flexGrow:1,maxWidth:"unset"},ref:b.sidePanelFloating?null:Ne,children:[b.desktopMobileSwitchRule&&(0,a.jsx)(kd,{onSelectWidth:Jo,themeToggle:Za("rule")}),(0,a.jsxs)(up,{maxPaneWidth:1200,isCodeMode:Q,codeModeDirection:pe,isShowMobileSettings:ge,desktopMobileSwitchPanel:b.desktopMobileSwitchPanel,children:[(0,a.jsx)("div",{className:"email-pane__handle left",onMouseDown:Ja("left"),onMouseEnter:()=>zr("left"),onMouseLeave:zr}),(0,a.jsx)("div",{className:"email-pane__handle right",onMouseDown:Ja("right"),onMouseEnter:()=>zr("right"),onMouseLeave:zr}),(0,a.jsx)(fp,{wrapperRef:Se,children:(0,a.jsx)(xp,{ref:xe,className:"email-pane__iframe",email:e,handlerSendPosition:Mt,clip:gv})})]})]}),(0,a.jsx)(_.ui_kit$Col,{style:{display:Q&&pe!=="bottom"||b.disableSideMenu?"none":"initial"},ref:qo,onPointerEnter:wp,className:(0,rt.default)("email-pane__content-col email-pane__content-col_menu email-pane__content-col_tabs email-pane__col email-pane__col_settings",{"email-pane__col_disabled":U===r.DISABLED_TAB}),children:(!Q||pe==="bottom")&&Z&&(0,a.jsx)(_.ui_kit$Tabs,{className:(0,rt.default)("email-pane__col_settings-inner",{"email-pane__col_settings-inner_reverse":b.menuDirection==="left"}),size:"medium",activeKey:U,onTabClick:Ev,renderTabBar:Ep,tabPlacement:"right",items:Un,tabBarExtraContent:Bt&&(0,a.jsx)("div",{style:{paddingTop:15,textAlign:"center"},children:ue?(0,a.jsx)(_.ui_kit$Switch,{variant:"editorMode",checkedChildren:"Pro",unCheckedChildren:"Pro",onChange:qa,checked:$t}):(0,a.jsx)(_.ui_kit$Switch,{variant:"editorMode",checkedChildren:"Pro",unCheckedChildren:"Pro",onChange:qa,defaultChecked:Nn})})})})]}),(0,a.jsx)("div",{className:"email-pane__iframe-scroll-bottom",id:"iframe-scroll-bottom"})]}),(0,a.jsxs)(mp,{isCodeMode:Q,codeModeDirection:pe,children:[(0,a.jsx)("div",{className:"email-pane__code-divider",onMouseDown:Av}),(0,a.jsx)("div",{className:"code-mode__pane code-mode__pane_editor email-pane__pane email-pane__pane_editor",children:(0,a.jsx)("div",{className:"code-mode__pane-content email-pane__pane-content",children:se&&(0,a.jsx)(Ap,{email:e,setOtherUsers:Ze,readOnly:b.lockEditor,newEmailAiGeneratorRef:fn})})})]})]}),b.pathEnabled&&(0,a.jsxs)("div",{className:"email-pane__paths",children:[(0,a.jsx)(iu,{elementPath:Ae}),(0,a.jsx)(au,{fallbackHtml:e?.html})]}),(0,a.jsx)("div",{className:"collaborator-list",children:(0,a.jsx)(r.CollaboratorList,{users:Ge,isEditor:!1,isPlugin:!0,token:M})})]}),(0,a.jsx)(vp,{isCodeMode:Q,codeModeDirection:pe,email:e,onClosePanel:Lt}),(0,a.jsx)(xu,{}),(0,a.jsx)(r.PlanUpgradePrompt,{open:gt,onCancel:vv,onTrialActivated:bv,initialSlide:ce}),st&&Ve.exceeded?(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(ro,{open:De,onClose:Oe,title:d(st.titleKey),subtitle:d(st.subtitleKey),usageResource:st.usageResource,previousDisplay:r.presetLimitDisplay(Ve.exceeded.previousLimit),nextDisplay:r.presetLimitDisplay(Ve.exceeded.nextLimit),onChangePlan:Yt})}):null,(0,a.jsx)(lu,{open:ft,onClose:lt}),(0,a.jsx)(du,{open:G,onClose:K})]})})};ds.propTypes={};var Lp=e=>(0,a.jsx)(ep,{children:(0,a.jsx)(rp,{children:(0,a.jsx)(ap,{children:(0,a.jsx)(ds,{...e})})})}),Mp=(0,l.memo)(Lp),Np=({open:e,onClose:t})=>{const{__:n}=r.useI18n(),o=r.getSupportEmail(),[i,s=""]=n("To send a test email, you need to confirm your email address. If you haven’t received the confirmation link, contact support in the chat or email {supportEmail}.").split("{supportEmail}");return(0,a.jsx)(_.ui_kit$Modal,{width:440,open:e,onCancel:t,title:(0,a.jsxs)("div",{style:{paddingBottom:8},children:[(0,a.jsx)(r.EmIcons,{icon:"EmailConfirmation",component:_.icons$EmailConfirmation,size:20,strokeWidth:2})," ",n("Email confirmation required")]}),footer:[(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",onClick:t,children:n("Got it")},"ok")],children:(0,a.jsxs)("p",{children:[i,(0,a.jsx)("a",{href:`mailto:${o}`,children:o}),s]})})},Qn=e=>{const t=r.useCurrentUser(),[n,o]=(0,l.useState)({owner:!1,admin:!1,user:!1}),i=r.useProjectData(),{data:s}=r.useGetProjectQuery(e,{skip:!e||!t.id||!!i}),c=i||s;return(0,l.useEffect)(()=>{if(c){const d=r.getMyProjectRole(c,t);o({owner:d==="owner",admin:d==="admin",user:d==="user"})}},[c,t]),n},lo=r.getLimitUpgradePresetDefinition("preview_exceeded"),us=({emailElement:e,isCollaborationEditor:t})=>{const{__:n}=r.useI18n(),o=r.useDispatch(),i=qr(),s=r.useOpenPlanCatalog(),c=r.useSendPostMessage(),{blockId:d}=r.useRouteParams(),u=r.useRouteEmailId(),p=r.useSelector(r.selectActiveModal$1)===r.MODALS.SEND_TEST_EMAIL,f=kn(p),[g,y]=(0,l.useState)(!1),[m,S]=r.useSendLivePreviewMutation(),k=r.useCurrentUser(),w=r.useDocumentHistoryReader(),b=r.useProjectPlanLimitPreflight(),{owner:A}=Qn(),x=Xr(),Y=xd(),Z=r.useContentReader(),M=r.useSelector(r.selectIsPanelHistoryCollapsed),O=r.useSelector(r.selectIsCodeMode),I=r.useSelector(r.selectCodeModeDirection),{token:R}=(0,_.ui_kit$useToken)(),z=r.useNotification(),B=r.useAppConfig(),U=e.hasOwnProperty("type")?r.BLOCK:r.EMAIL,de=r.useEventEmitter(h.events.ON_SHARE_ID),me=r.useEventEmitter(h.events.ON_SHOW_PREVIEW_ID),[q,ee]=(0,l.useState)(!1),[Fe,be]=(0,l.useState)(0),[et,Ee]=(0,l.useState)(!1),fe=kn(et),Q=(0,l.useCallback)(()=>Ee(!1),[]),pe=(0,l.useCallback)(()=>{Ee(!1),s()},[s]),[se,ae]=(0,l.useState)(n("—")),[Ie,Ce]=(0,l.useState)(!1),Be=r.useProjectData(),J=r.usePlanFeatureGate("version_history"),_e=r.usePlanFeatureGate("code_editor"),Te=r.usePlanFeatureGate("preview_service"),ge=r.usePlanFeatureGate("undo_redo"),Re=r.isEditorLockedByPlan(Be,{isPlugin:!0}),ze=r.usePushToDataLayer(),C=e?.project,T=he=>{const We=U==="block"?"block":"email";typeof he=="string"?(i.setDirection(he),!O&&i.toggle()):i.toggle(),ze({event:"activate",action:"activate_code_mode",entity_type:We,entity_id:e?.id||u||d,project_id:e?.project||C}),setTimeout(()=>{o(U==="block"?r.setElementSettings({type:null}):r.setElementSettings$1({type:null}))},300),c({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),_e.isLocked&&(ee(!0),be(r.FEATURE_UPSELL_SLIDE.code_editor))},P=(0,l.useCallback)(async()=>!0,[b]),N=async()=>{if(Re){ee(!0),be(8);return}await P()&&(o(r.openModal$1(r.MODALS.SEND_TEST_EMAIL)),ze({event:"open",action:"open_test_email_modal",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||C}))},D=()=>{ee(!0),be(r.FEATURE_UPSELL_SLIDE.undo_redo)},v=()=>{x.undo()},W=()=>{x.redo()},Pe=async()=>{const he=(await de.fire({project:C,id:u})).find(We=>We===!1||typeof We=="string");he!==!1&&navigator.clipboard.writeText(he||r.buildEmailRawShareUrl(u,C)).then(()=>{z.success(n("A shareable link to this page has been copied to the clipboard.")),ze({event:"click",action:"share_email",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||C})})},Ae=async()=>{if(!g){if(!await P())return;const he={email:u,subject:encodeURIComponent("#"+e.project+" "+e.title).replaceAll(/%20/gi,"+").replaceAll(/%0A/gi,"%0D%0A"),content:encodeURIComponent(Z()).replaceAll(/%20/gi,"+").replaceAll(/%0A/gi,"%0D%0A")};m(he),y(!0),ze({event:"click",action:"open_email_inbox_tests",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||C})}},Qe=(0,l.useCallback)(async()=>{await P()&&(ae(n("—")),Ee(!0))},[n,P]);(0,l.useEffect)(()=>{S.isError&&(z.error(S),y(!1))},[S]),(0,l.useEffect)(()=>{if(S.isSuccess&&g){if(S.data?.status===401)z.error({title:S.data.code,description:S.data.message});else if(S.data){let he=document.createElement("A");he.setAttribute("target","_blank"),he.setAttribute("href",S.data.message),he.click()}y(!1)}},[S,g,z]);const[Ge,Ze]=(0,l.useState)(!1),pt=()=>{c({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:M}),o(r.switchIsPanelHistoryCollapsed(!M))},bt=()=>w(e?.id),ft=()=>{M?(Ze(!0),bt().then(he=>{he.isSuccess?he.data.data.length:he.isError&&z.error(he),pt(),o(r.setActiveSettingsTab(r.HISTORY)),Ze(!1),ze({event:"open",action:"open_version_control",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||C}),J.isLocked&&(ee(!0),be(r.FEATURE_UPSELL_SLIDE.version_history))})):(o(r.resetToLastActiveSettingsTab()),pt())},lt=()=>{M||(pt(),o(r.resetToLastActiveSettingsTab())),O&&i.toggle(),ee(!1)};let G=[];const K=(0,l.useCallback)(async()=>{const he=await me.fire({project:C,id:u});he.find(We=>We===!1||typeof We=="string")!==!1&&(window.open(he.find(We=>We)||r.buildEmailRawSharePath(u,C)),ze({event:"click",action:"open_email_preview",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||C}))},[me,C,u,ze,U,e,d]),ne=(0,l.useCallback)(async()=>{window.open(r.buildGetElementPreviewPath(r.EMAIL,u,C)),ze({event:"click",action:"open_web_version",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||C})},[C,u,ze,U,e,d]);B.previewModeEnabled&&G.push({key:"Preview_mode",icon:(0,a.jsx)(r.EmIcons,{icon:"EyeOutlined",component:_.icons$EyeOutlined,size:18,strokeWidth:B.iconStrokeWidth}),label:n("Preview mode"),onClick:K}),B.livePreviewEnabled&&G.push({key:"Live_preview",icon:g?(0,a.jsx)(r.EmIcons,{icon:"LoadingOutlined",component:_.icons$LoadingOutlined,style:{fontSize:16}}):(0,a.jsx)(r.EmIcons,{icon:"CheckCircleVerified",component:_.icons$CheckCircleVerified,size:18,strokeWidth:B.iconStrokeWidth}),label:n("Live preview"),onClick:k.id?.toString()===e.project_author?.toString()&&k?.subscription?.post_name==="community"&&A?Qe:Ae}),B.webversionEnabled&&G.push({key:"Web version",icon:(0,a.jsx)(r.EmIcons,{icon:"Web",component:_.icons$Web,size:18,strokeWidth:B.iconStrokeWidth}),label:n("Web version"),onClick:ne}),B.sharePreviewEnabled&&G.push({key:"Share",icon:(0,a.jsx)(r.EmIcons,{icon:"ShareAltOutlined",component:_.icons$ShareAltOutlined,size:18,strokeWidth:B.iconStrokeWidth}),label:n("Share"),onClick:Pe,className:"em-analytics__email-share"});const ue=[{key:"Left_mode",icon:(0,a.jsx)(r.EmIcons,{icon:"PanelLeft",component:_.icons$PanelLeft,size:18,strokeWidth:B.iconStrokeWidth,style:{color:I==="left"&&O?R.colorPrimary:"inherit"}}),label:n("Left Code panel"),onClick:()=>T("left")},{key:"Right_mode",icon:(0,a.jsx)(r.EmIcons,{icon:"PanelLeft",component:_.icons$PanelLeft,size:18,strokeWidth:B.iconStrokeWidth,style:{transform:"rotate(180deg)",color:I==="right"&&O?R.colorPrimary:"inherit"}}),label:n("Right Code panel"),onClick:()=>T("right")},{key:"Bottom_mode",icon:(0,a.jsx)(r.EmIcons,{icon:"PanelLeft",component:_.icons$PanelLeft,size:18,strokeWidth:B.iconStrokeWidth,style:{transform:"rotate(-90deg)",color:I==="bottom"&&O?R.colorPrimary:"inherit"}}),label:n("Bottom Code panel"),onClick:()=>T("bottom")}];return(0,a.jsxs)("div",{className:"email-preview-menu email-preview-menu_new",children:[(0,a.jsxs)(_.ui_kit$Space,{size:32,children:[(0,a.jsxs)(_.ui_kit$Space,{className:"email-preview-menu__versions",size:8,style:{borderRadius:`calc(${r.emCssVar("borderRadius")} * 1px)`},children:[(0,a.jsx)(_.ui_kit$Tooltip,{title:n(t?r.COLLABORATION_EDITOR_WARNING_TEXT:"Undo (Ctrl+Z)"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"UndoOutlined",component:_.icons$UndoOutlined,size:22,strokeWidth:B.iconStrokeWidth}),ge.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:ge.isLocked?D:v,disabled:!ge.isLocked&&!Y.canUndo})}),(0,a.jsx)(_.ui_kit$Tooltip,{title:n(t?r.COLLABORATION_EDITOR_WARNING_TEXT:"Redo (Ctrl+Shift+Z)"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"RedoOutlined",component:_.icons$RedoOutlined,size:22,strokeWidth:B.iconStrokeWidth}),ge.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:ge.isLocked?D:W,disabled:!ge.isLocked&&!Y.canRedo})}),B.historyEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Version history"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:M?"text":"primary",ghost:!M,onClick:ft,disabled:e.isNew||Ge,className:"email-preview-menu__history",icon:Ge?(0,a.jsx)(_.ui_kit$Spin,{size:"small"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"HistoryOutlined",component:_.icons$HistoryOutlined,size:22,strokeWidth:B.iconStrokeWidth,className:"email-preview-menu__list-item-icon email-preview-menu__list-item-icon_revert"}),J.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]})})})]}),(0,a.jsxs)(_.ui_kit$Space,{size:8,style:{borderRadius:`calc(${r.emCssVar("borderRadius")} * 1px)`},children:[B.codeEnabled&&(0,a.jsx)(_.ui_kit$Dropdown,{arrow:!0,placement:"bottom",menu:{items:ue},trigger:"hover",mouseEnterDelay:0,className:"email-preview-menu__code",children:(0,a.jsx)(_.ui_kit$Button,{type:O?"primary":"text",ghost:O,icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"Code",component:_.icons$Code,size:22,strokeWidth:B.iconStrokeWidth}),_e.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:T})},"Code mode"),B.previewIconEnabled&&(Te.isLocked?(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Preview mode"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"EyeOutlined",component:_.icons$EyeOutlined,size:22,strokeWidth:B.iconStrokeWidth,className:"email-preview-menu__list-item-icon"}),(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:()=>{ee(!0),be(r.FEATURE_UPSELL_SLIDE.preview_service)}})}):(0,a.jsx)(_.ui_kit$Dropdown,{arrow:!0,placement:"bottom",menu:{items:G},className:"email-preview-menu__preview",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",target:"_blank",rel:"noreferrer",icon:(0,a.jsx)(r.EmIcons,{icon:"EyeOutlined",component:_.icons$EyeOutlined,size:22,strokeWidth:B.iconStrokeWidth,className:"email-preview-menu__list-item-icon"}),onClick:B.previewModeEnabled?K:void 0})},"Preview")),B.sendTestEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Send a test email"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{className:"em-analytics__email-open-test email-preview-menu__test",type:"text",icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"SendOutlined",component:_.icons$SendOutlined,size:22,strokeWidth:B.iconStrokeWidth,className:"email-preview-menu__list-item-icon"}),Re&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:N})})]})]}),f&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(Tu,{isModalVisible:p,email:e})}),(0,a.jsx)(Np,{open:Ie,onClose:()=>Ce(!1)}),(0,a.jsx)(r.PlanUpgradePrompt,{open:q,onCancel:lt,initialSlide:Fe}),fe&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(ro,{open:et,onClose:Q,title:n(lo.titleKey),subtitle:n(lo.subtitleKey),usageResource:lo.usageResource,previousDisplay:se,nextDisplay:r.presetLimitDisplay("infinity"),onChangePlan:pe})})]})};us.propTypes={};var Dp=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Fp=200;function ps(e=new Set){const t=new Set;return(n,o)=>{if(!Dp.some(([s,c])=>!e.has(s)&&c.test(n)))return;const i=o??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=Fp&&t.clear(),t.add(i))}}function ms(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:ps()}}var Bp=ms();function on(e){return e?.getInstance(h.TEMPLATE_DIRECTIVES_ID)??Bp}function $p({html:e,renderGuid:t,showToken:n,showId:o,...i},s){const{requested:c}=r.getCurrentProject(s),d=r.getAppConfig(s);return r.filterUndefined({...i,code:on(s).toOutputForm(e),project:c===void 0?i.project:c,utm_parameters:d.UTMEnabled?i.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0})}var Up=zt.__commonJSMin(((e,t)=>{r.init__polyfill_node_global(),(function(n,o){typeof define=="function"&&define.amd?define([],o):typeof e<"u"?o():(o(),n.FileSaver={})})(e,function(){"use strict";function n(p,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function o(p,f,g){var y=new XMLHttpRequest;y.open("GET",p),y.responseType="blob",y.onload=function(){u(y.response,f,g)},y.onerror=function(){},y.send()}function i(p){var f=new XMLHttpRequest;f.open("HEAD",p,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function s(p){try{p.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(f)}}var c=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof r._polyfill_node_global_default=="object"&&r._polyfill_node_global_default.global===r._polyfill_node_global_default?r._polyfill_node_global_default:void 0,d=c.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),u=c.saveAs||(typeof window!="object"||window!==c?function(){}:"download"in HTMLAnchorElement.prototype&&!d?function(p,f,g){var y=c.URL||c.webkitURL,m=document.createElement("a");f=f||p.name||"download",m.download=f,m.rel="noopener",typeof p=="string"?(m.href=p,m.origin===location.origin?s(m):i(m.href)?o(p,f,g):s(m,m.target="_blank")):(m.href=y.createObjectURL(p),setTimeout(function(){y.revokeObjectURL(m.href)},4e4),setTimeout(function(){s(m)},0))}:"msSaveOrOpenBlob"in navigator?function(p,f,g){if(f=f||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(n(p,g),f);else if(i(p))o(p,f,g);else{var y=document.createElement("a");y.href=p,y.target="_blank",setTimeout(function(){s(y)})}}:function(p,f,g,y){if(y=y||open("","_blank"),y&&(y.document.title=y.document.body.innerText="downloading..."),typeof p=="string")return o(p,f,g);var m=p.type==="application/octet-stream",S=/constructor/i.test(c.HTMLElement)||c.safari,k=/CriOS\/[\d]+/.test(navigator.userAgent);if((k||m&&S||d)&&typeof FileReader<"u"){var w=new FileReader;w.onloadend=function(){var x=w.result;x=k?x:x.replace(/^data:[^;]*;/,"data:attachment/file;"),y?y.location.href=x:location=x,y=null},w.readAsDataURL(p)}else{var b=c.URL||c.webkitURL,A=b.createObjectURL(p);y?y.location=A:location.href=A,y=null,setTimeout(function(){b.revokeObjectURL(A)},4e4)}});c.saveAs=u.saveAs=u,typeof t<"u"&&(t.exports=u)})})),sn=Up(),In="NEXT_BUTTON",co="SAVE_BUTTON",uo="KEYBOARD",zp="EXTERNAL",Gp=new Set([co,In,uo]);function Wp(e){return e!=null&&e!==""&&Gp.has(e)}function fs(e){if(!e||e==="all")return;const t=Number(e);return Number.isFinite(t)?[t]:void 0}var gs=(0,l.createContext)(null);function Hp(){const e=(0,l.useContext)(gs);if(!e)throw new Error("useEmailSaveController must be used within EmailSaveContext.Provider");return e}var qp=2;function Vp({email:e,documentSession:t,save:n,saveState:o}){const i=r.useDispatch(),{__:s}=r.useI18n(),c=r.useEditorProjectId();r.useRouteEmailId();const d=+c,u=Number.isFinite(d)&&d>0?d:e?.project,p=r.useCookieManager(),f=r.useContainer(),g=r.useNotification(),y=r.useAppConfig(),m=r.useConfigSource(),[S,k]=(0,l.useState)(0),w=(0,l.useRef)(""),[b,A]=(0,l.useState)(!1),x=r.useEventEmitter(h.events.ON_NEXTBUTTON_CLICK_ID),Y=r.useEventEmitter(h.events.ON_SAVEBUTTON_CLICK_ID);r.useEvent(h.events.ON_EMAIL_INIT_ID);const Z=y.activeNextButton===!1,M=y.disableDoubleClickNextButton!==!1,O=(0,l.useRef)(!1),I=(0,l.useRef)(void 0),R=(0,l.useRef)(null),z=(0,l.useRef)(null),B=(0,l.useRef)(e);B.current=e;const U=(0,l.useCallback)(()=>{I.current=void 0},[]),de=(0,l.useCallback)(J=>{m.merge({activeNextButton:!J},"user")},[m]),me=(0,l.useCallback)((J,_e)=>{const Te=r.saveRefusalReason(_e);if(Te==="locked"){g.error({id:"EMAIL_ACCESS_TO_LOCKED_ERROR",data:r.getEmailDesc(J),message:s("No access to edit the letter.")});return}if(Te==="too-many-tags"){g.error({id:"EMAIL_TOO_MANY_TAGS_ERROR",data:r.getEmailDesc(J),message:s("Maximum 10 tags available.")});return}const ge=r.failedTerms(_e);if(ge){ge.failed.forEach(Re=>{if(ge.kind==="group"){g.fromError("GROUP_CREATING_ERROR",{id:Re.id??0,name:Re.name,parent:Re.parent??0},_e);return}g.fromError("TAG_CREATING_ERROR",Re.name,_e)});return}g.fromError(J.isNew?"EMAIL_CREATING_ERROR":"EMAIL_EDITING_ERROR",r.getEmailDesc(J),_e)},[g,s]),q=(0,l.useCallback)(J=>{const _e=Wp(J),Te=()=>{A(!1),J===In&&(O.current=!1,de(!1))};if(!e){Te();return}const ge=async()=>{(ze=>{n("publish",{project:ze.isNew?u:ze.project,folder:fs(p.get(r.APP_COOKIES.em_folder)),source:J}).then(C=>{if(A(!1),O.current=!1,!C){J===In&&de(!1),_e&&(me(ze,o().error),U());return}_e&&(g.success({id:"EMAIL_SAVING_SUCCESS",message:s("The email was successfully saved."),data:r.getEmailDesc(ze)}),U())})})(e)};A(!0),ge()},[e,i,c,s,t,p,u,g,me,n,o,de,U]);r.useCommand(r.SAVE_COMMAND_ID,(0,l.useCallback)(J=>q(J||zp),[q]));const ee=(0,l.useRef)(void 0),Fe=(0,l.useRef)(q);Fe.current=q;const be=(0,l.useCallback)(J=>{w.current=J,k(_e=>_e+1)},[]);(0,l.useEffect)(()=>()=>{ee.current!==void 0&&clearTimeout(ee.current)},[]),(0,l.useEffect)(()=>{if(S===0)return;const J=w.current;B.current?.isNew&&(I.current=J),ee.current!==void 0&&clearTimeout(ee.current),ee.current=setTimeout(()=>{ee.current=void 0,Fe.current(J)})},[S]);const et=(0,l.useCallback)(J=>{(J.ctrlKey||J.metaKey)&&J.keyCode===83&&(J.preventDefault(),be(uo))},[be]);(0,l.useEffect)(()=>(document.addEventListener("keydown",et),()=>{document.removeEventListener("keydown",et)}),[et]);const Ee=(0,l.useCallback)(J=>{const _e=J.data.operation,Te=J.data.action;_e===r.EVENT_TYPES.APPLICATION_ACTION&&Te==="save_email"&&be(uo)},[be]);r.useListenPostMessage(Ee),(0,l.useEffect)(()=>{e?.isNew&&(z.current=null,R.current=null)},[e?.isNew,e?.renderGuid]),(0,l.useEffect)(()=>{O.current=!1},[e?.id]);const fe=p.get(r.APP_COOKIES.em_folder),Q=f?r.provideAutosaveUiFacts(f):void 0;(0,l.useEffect)(()=>{Q?.set({...Q?.get()??{isUserBusy:!1,saveContext:{}},saveContext:{project:u,folder:fs(fe)}})},[Q,u,fe]);const pe=(0,l.useRef)(!1),se=o().failures;(0,l.useEffect)(()=>{se>=qp&&!pe.current&&(pe.current=!0,g.warning({message:s("Changes are not being saved. Check your connection.")})),se===0&&(pe.current=!1)},[se,g,s]);const ae=b,Ie=o().saving,Ce=(0,l.useCallback)(J=>{be(J||co)},[be]),Be=(0,l.useCallback)(async(J,_e)=>{if(J===In){if(O.current)return;O.current=!0;try{M&&de(!0),(await x.fire(_e)).every(Te=>Te!==!1)?be(In):(de(!1),O.current=!1)}catch(Te){g.fromError("NEXT_BUTTON_CLICK_EVENT_ERROR",r.getEmailDesc(_e),Te,!0),de(!1),O.current=!1}return}try{(await Y.fire(_e)).every(Te=>Te!==!1)&&be(J||co)}catch(Te){g.fromError("SAVE_BUTTON_CLICK_EVENT_ERROR",r.getEmailDesc(_e),Te,!0)}},[M,x,Y,g,de,be]);return(0,l.useMemo)(()=>({requestSave:Ce,requestSaveWithEvents:Be,isLoading:ae,isAutosaveLoading:Ie,nextButtonDisabled:Z}),[Ce,Be,ae,Ie,Z])}var Kp="NEXT_BUTTON",Yp="SAVE_BUTTON",hs=({email:e=null,disabled:t})=>{const{__:n}=r.useI18n(),o=r.useAppConfig(),i=r.useContentReader(),s=r.useNotification(),{requestSaveWithEvents:c,isLoading:d,isAutosaveLoading:u,nextButtonDisabled:p}=Hp(),f=d||u,[g,y]=(0,l.useState)(null);(0,l.useEffect)(()=>{window?.navigator?.userAgent.includes("Macintosh")&&y(!0)},[]);const m=o.saveButtonEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n(g?"Save by ⌘S":"Save by Ctrl+S"),placement:"bottom",children:(0,a.jsx)("span",{className:"em-analytics__email-save-tooltip-target",children:(0,a.jsx)(_.ui_kit$Button,{disabled:t||u,type:o.nextButtonEnabled?"default":"primary",block:"false",className:"em-analytics__email-save",loading:f,icon:(0,a.jsx)(r.EmIcons,{icon:"SaveOutlined",component:_.icons$SaveOutlined,size:16,strokeWidth:o.iconStrokeWidth}),onClick:async k=>{const w=k.currentTarget,b={...e,html:i()};try{await c(Yp,b)}catch(A){s.fromError("SAVE_BUTTON_CLICK_EVENT_ERROR",r.getEmailDesc(b),A,!0)}finally{try{w?.blur?.()}catch{}}},children:o.saveButtonText||n("Save")})})},"save-button"),S=o.nextButtonEnabled&&(0,a.jsx)(_.ui_kit$Button,{disabled:t||p,type:"primary",block:"false",className:"em-analytics__email-save",icon:o.primaryCommandButtonIcon,loading:d,onClick:async()=>{const k={...e,html:i()};await c(Kp,k)},children:o.nextButtonText||n("Continue")},"next-button");return(0,a.jsx)(a.Fragment,{children:o.saveButtonEnabled&&o.nextButtonEnabled?(0,a.jsx)(_.ui_kit$Space,{children:[m,S]}):[m,S]})};hs.propTypes={email:Ue.default.shape({id:Ue.default.string,isNew:Ue.default.bool,title:Ue.default.string,lock:Ue.default.bool,subject:Ue.default.string,html:Ue.default.string,description:Ue.default.string,utm_parameters:Ue.default.shape({utm_source:Ue.default.string,utm_medium:Ue.default.string,utm_campaign:Ue.default.string,utm_term:Ue.default.string,utm_content:Ue.default.string}),project:Ue.default.number,is_template:Ue.default.bool}),disabled:Ue.default.bool};var _s=({element:e,context:t="list"})=>{const{__:n,_x:o}=r.useI18n(),[i]=r.useEditEmailMutation(),[s]=r.useEditBlockMutation(),c=r.useNotification(),d=r.usePushToDataLayer();e.hasOwnProperty("type");const u=(f,g)=>{if(f.error)return c.error(f),!1;c.success(n("The ")+(g.hasOwnProperty("type")?n("block"):o("email","letter"))+" "+n("“")+f.data.title+n("”")+n("was successfully")+" "+(g.lock?g.hasOwnProperty("type")?o("unlocked.","block"):o("unlocked.","email"):g.hasOwnProperty("type")?o("locked.","block"):o("locked.","email")))},p=()=>{const f=!e.lock,g=f?"lock_email":"unlock_email";e.hasOwnProperty("type")?s({blockId:e.id,lock:f}).then(y=>{u(y,e),y.error||d({event:f?"lock":"unlock",action:f?"lock_block":"unlock_block",entity_type:"block",entity_id:e.id,project_id:e.project,context:t})}):i({emailId:e.id,lock:f}).then(y=>{u(y,e),y.error||d({event:f?"lock":"unlock",action:g,entity_type:"email",entity_id:e.id,project_id:e.project,context:t})})};return(0,a.jsx)("div",{className:e.hasOwnProperty("type")?"em-analytics__block-lock":"em-analytics__email-lock",onClick:p,children:e.lock?n("Unlock"):n("Lock")})};_s.propTypes={element:Ue.default.shape({lock:Ue.default.bool,id:Ue.default.string})};var Qp=({open:e,codeSize:t,onMinimize:n,onDownloadAsIs:o,onCancel:i})=>{const{__:s}=r.useI18n(),c=r.formatCodeSize(t);return(0,a.jsx)(_.ui_kit$Modal,{open:e,onCancel:i,footer:null,className:"code-size-warning-modal",width:480,children:(0,a.jsxs)("div",{className:"code-size-warning-modal__content",children:[(0,a.jsx)("h3",{className:"code-size-warning-modal__title",children:s("Code Size Warning")}),(0,a.jsxs)("div",{className:"code-size-warning-modal__message",children:[(0,a.jsxs)("p",{children:[s("The current code size is")," ",(0,a.jsx)("strong",{children:c}),","," ",s("which exceeds the recommended 90 KB limit.")]}),(0,a.jsx)("p",{children:s("Large emails may have delivery issues and load slowly. We recommend minimizing code before exporting.")})]}),(0,a.jsxs)(_.ui_kit$Space,{className:"code-size-warning-modal__actions",size:"medium",children:[(0,a.jsx)(_.ui_kit$Button,{type:"primary",onClick:n,size:"large",children:s("Minimize code")}),(0,a.jsx)(_.ui_kit$Button,{onClick:o,size:"large",children:s("Download as is")})]})]})})};function Xp(e){return e.includes("em-narrow-table")}function Jp(e){if(!e||Xp(e))return!1;const t=e.includes("nl-container"),n=/row-content\s+stack/.test(e)||/stack\s+row-content/.test(e),o=/\brow-\d/.test(e),i=/_block\s+block-\d/.test(e),s=e.includes('role="presentation"');return t&&n&&(o||i)&&s}function Zp(e){return e?e.includes("em-narrow-table"):!1}function em(e){return e.includes("em-narrow-table")}function tm(e){return e.includes("i-amphtml")||e.includes("amp-runtime")||e.includes("amp-version")}function nm(e){if(!e||em(e)||tm(e))return!1;const t=e.includes("es-wrapper"),n=/es-(?:header|content|footer)-body/.test(e);return t||n}function ys(){r.useAppConfig();const e=r.useIntegratorConfigValue("beeFreeConverterEnabled"),t=r.useIntegratorConfigValue("stripoConverterEnabled"),n=r.useIntegratorConfigValue("aiLayoutConverterEnabled"),o=e===!0,i=t===!0,s=n===!0;return{beeFreeConverterEnabled:o,stripoConverterEnabled:i,aiLayoutConverterEnabled:s,anyConverterEnabled:o||i||s}}function vs(e,t){return!e||Zp(e)?null:Jp(e)?t.beeFreeConverterEnabled?"beefree":null:nm(e)?t.stripoConverterEnabled?"stripo":null:t.aiLayoutConverterEnabled?"ai":null}var rm=()=>"useblocks",om={unisender:{id:"unisender",name:"Unisender",icon:"/images/integrations/unisender.svg",description:"Export emails to Unisender",cardDescription:"Mass mailing automation, audience segmentation, and campaign performance analytics.",apps:["emailmaker"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter Unisender API key",helpUrl:"https://app.unisender.com/ru/v5/cp/user/info/api"},{name:"sender_email",type:"email",label:"Sender Email",required:!0,placeholder:"sender@example.com",extra:"This email must be verified in Unisender"},{name:"sender_name",type:"text",label:"Sender Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"list_id",type:"number",label:"Contact List ID",required:!0,placeholder:"e.g., 123456"}]},mailganer:{id:"mailganer",name:"Mailganer",icon:"/images/integrations/mailganer.svg",description:"Export emails to Mailganer",cardDescription:"Contact sync, content personalization, and real-time campaign results tracking.",apps:["emailmaker"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter Mailganer API key",helpUrl:"https://mailganer.com/app/profile/"},{name:"from_email",type:"email",label:"Sender Email",required:!1,placeholder:"sender@example.com",extra:"This email must be verified in Mailganer"},{name:"from_name",type:"text",label:"Sender Name",required:!1,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Mailing Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"theme",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},sendsay:{id:"sendsay",name:"Sendsay",icon:"/images/integrations/sendsay.svg",description:"Export emails to Sendsay",cardDescription:"Mailing automation, audience segmentation, and email personalization.",apps:["emailmaker"],settingsFields:[{name:"login",type:"text",label:"Account Login",required:!0,placeholder:"e.g., myaccount or myaccount/sublogin",extra:"Your Sendsay account login (not email). For sublogin use format: account/sublogin",fullWidth:!0},{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter Sendsay API key",helpUrl:"https://docs.sendsay.ru/sendsay-api/how-to-get-apikey"},{name:"from_email",type:"email",label:"Sender Email",required:!1,placeholder:"sender@example.com",extra:"This email must be verified in Sendsay"},{name:"from_name",type:"text",label:"Sender Name",required:!1,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Draft Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!0,placeholder:"e.g., Special offer for you!"}]},klaviyo:{id:"klaviyo",name:"Klaviyo",icon:"/images/integrations/klaviyo.svg",description:"Export emails to Klaviyo",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"e.g., pk_xxxxxxxx",helpUrl:"https://help.klaviyo.com/hc/en-us/articles/7423954176283-How-to-create-a-private-API-key",extra:"Use a custom key with templates:write and campaigns:write (or Full access). Campaigns-only is not enough — export creates a template first."},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"This email must be verified in Klaviyo"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"list_id",type:"text",label:"List ID",required:!0,placeholder:"e.g., ABC123",helpText:"Find your List ID in Klaviyo: Lists & Segments → List → Settings"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},campaign_monitor:{id:"campaign_monitor",name:"Campaign Monitor",icon:"/images/integrations/campaign_monitor.svg",description:"Export emails to Campaign Monitor",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter API Key",fullWidth:!0,helpUrl:"https://help.campaignmonitor.com/s/article/api-keys"},{name:"client_id",type:"text",label:"Client ID",required:!0,placeholder:"e.g., 4a397ccaaa55eb4e6aa1221e1e2d7122",helpText:"Find in Account Settings → API Keys"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be verified in Campaign Monitor"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"list_id",type:"text",label:"List ID",required:!0,placeholder:"e.g., a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",helpText:"Find in Lists → List ID"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},constant_contact:{id:"constant_contact",name:"Constant Contact",icon:"/images/integrations/constant_contact.svg",description:"Export emails to Constant Contact",apps:["useblocks"],settingsFields:[{name:"access_token",type:"password",label:"Access Token",required:!0,placeholder:"OAuth2 Bearer token",fullWidth:!0,helpText:"Get from Constant Contact Developer Portal. Token expires in 24 hours.",helpUrl:"https://developer.constantcontact.com/api_guide/getting_started.html"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be confirmed in Constant Contact"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"list_id",type:"text",label:"Contact List ID",required:!0,placeholder:"e.g., fa32f620-6d82-11e8-8b59-fa163e56c9b0",helpText:"Find via GET /contact_lists API"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},bento:{id:"bento",name:"Bento",icon:"/images/integrations/bento.svg",description:"Export emails to Bento",apps:["useblocks"],settingsFields:[{name:"publishable_key",type:"password",label:"Publishable Key",required:!0,placeholder:"Enter Publishable Key",fullWidth:!0,helpUrl:"https://app.bentonow.com/account/teams"},{name:"secret_key",type:"password",label:"Secret Key",required:!0,placeholder:"Enter Secret Key",fullWidth:!0},{name:"site_uuid",type:"text",label:"Site UUID",required:!0,placeholder:"Your site UUID",helpText:"Find in Bento dashboard"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be an author in your Bento account"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Broadcast Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"},{name:"inclusive_tags",type:"text",label:"Tags (inclusive)",required:!1,placeholder:"e.g., subscribers,newsletter",helpText:"Comma-separated tags to send to. Default: subscribers"}]},dotdigital:{id:"dotdigital",name:"Dotdigital",icon:"/images/integrations/dotdigital.svg",description:"Export emails to Dotdigital",apps:["useblocks"],settingsFields:[{name:"username",type:"text",label:"API Username",required:!0,placeholder:"API user email",helpText:"API user email from Settings → Access → API users",helpUrl:"https://developer.dotdigital.com/docs/setting-up-an-api-user"},{name:"password",type:"password",label:"API Password",required:!0,placeholder:"API user password",fullWidth:!0},{name:"region",type:"text",label:"Region",required:!0,placeholder:"r1, r2, or r3",helpText:"r1=Europe, r2=North America, r3=Asia Pacific"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",fullWidth:!0,extra:"Use an email registered as a Custom from address in Dotdigital (see support.dotdigital.com — “Create a custom from address”). If it does not match, export uses your account default sender."},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},getresponse:{id:"getresponse",name:"GetResponse",icon:"/images/integrations/getresponse.svg",description:"Export emails to GetResponse",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter API Key",fullWidth:!0,helpUrl:"https://app.getresponse.com/api"},{name:"from_field_id",type:"text",label:"From Field ID",required:!0,placeholder:"e.g., V",helpText:"Find via GET /from-fields API"}],exportFields:[{name:"name",type:"text",label:"Newsletter Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"campaign_id",type:"text",label:"Campaign ID",required:!0,placeholder:"e.g., C",helpText:"List/campaign ID from GET /campaigns"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},brevo:{id:"brevo",name:"Brevo",icon:"/images/integrations/brevo.svg",description:"Export emails to Brevo",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter API Key",fullWidth:!0,helpUrl:"https://help.brevo.com/hc/en-us/articles/209467485-Create-and-manage-your-API-keys"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be verified in Brevo"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"list_id",type:"number",label:"List ID",required:!0,placeholder:"e.g., 2",helpText:"Find in Contacts → Lists"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},activecampaign:{id:"activecampaign",name:"ActiveCampaign",icon:"/images/integrations/activecampaign.svg",description:"Export emails as draft campaigns to ActiveCampaign",apps:["useblocks"],settingsFields:[{name:"api_url",type:"text",label:"API URL",required:!0,placeholder:"e.g., https://youraccount.api-us1.com",helpText:"Find in Settings → Developer → API Access",helpUrl:"https://help.activecampaign.com/hc/en-us/articles/207317590-Getting-started-with-the-API"},{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter API Key",fullWidth:!0},{name:"list_id",type:"text",label:"List ID",required:!0,placeholder:"e.g., 1",extra:"Find in Lists → Click your list → The ID is in the URL (e.g., /app/contacts?listid=1)"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be verified in ActiveCampaign"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},salesforce_mc:{id:"salesforce_mc",name:"Salesforce",icon:"/images/integrations/salesforce.svg",description:"Export emails to Salesforce",apps:["useblocks"],settingsFields:[{name:"subdomain",type:"text",label:"Tenant Subdomain",required:!0,placeholder:"e.g., mc563885gzs27c5t9-63k636ttgm",helpText:"Find in Installed Packages → API Integration → REST Base URI",helpUrl:"https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/your-subdomain-tenant-specific-endpoints.html"},{name:"client_id",type:"text",label:"Client ID",required:!0,placeholder:"From Installed Package"},{name:"client_secret",type:"password",label:"Client Secret",required:!0,placeholder:"From Installed Package"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be verified in Marketing Cloud"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Email Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},hubspot:{id:"hubspot",name:"HubSpot Email",icon:"/images/integrations/hubspot.svg",description:"Export emails to HubSpot",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"Private App Access Token",required:!0,placeholder:"e.g., pat-na1-xxxx",helpUrl:"https://developers.hubspot.com/docs/api/private-apps"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"This email must be verified in HubSpot"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Email Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},mailchimp:{id:"mailchimp",name:"Mailchimp",icon:"/images/integrations/mailchimp.svg",description:"Export emails to Mailchimp",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"e.g., xxxxxxxx-us1",helpUrl:"https://mailchimp.com/help/about-api-keys/"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"This email must be verified in Mailchimp"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"list_id",type:"text",label:"Audience ID",required:!0,placeholder:"e.g., a1b2c3d4e5",helpText:"Find your Audience ID in Audience settings → Audience name and defaults"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},enkod:{id:"enkod",name:"enKod",icon:"/images/integrations/enkod.svg",description:"Export emails to enKod",cardDescription:"Multi-channel campaigns automation (email, SMS, push, WhatsApp, and more).",apps:["emailmaker"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter enKod API key",helpUrl:"https://help.enkod.io/doku.php/api:start"},{name:"sender_email",type:"email",label:"Sender Email",required:!0,placeholder:"sender@example.com"},{name:"sender_name",type:"text",label:"Sender Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"subject",type:"text",label:"Email Subject",required:!0,placeholder:"e.g., Special offer for you!"}]}},im=(e,t)=>!e.apps||e.apps.length===0?!0:e.apps.includes(t),po=e=>{const t=om[e];if(t&&im(t,rm()))return t},sm=(e,t)=>{const n={placeholder:e.placeholder?t(e.placeholder):void 0,style:{width:"100%"}};switch(e.type){case"number":return(0,a.jsx)(_.ui_kit$InputNumber,{...n,min:1});case"email":return(0,a.jsx)(_.ui_kit$Input,{...n,type:"email"});default:return(0,a.jsx)(_.ui_kit$Input,{...n})}},am=({integration:e,visible:t,loading:n=!1,onConfirm:o,onCancel:i,__:s})=>{const[c]=_.ui_kit$Form.useForm(),d=e.exportFields||[];(0,l.useEffect)(()=>{t||c.resetFields()},[t,c]);const u=()=>{n||c.validateFields().then(g=>{o(g)})},p=()=>{c.resetFields(),i()};if(d.length===0)return null;const f=d.find(g=>g.helpText);return(0,a.jsxs)(_.ui_kit$Modal,{title:s(`Export to ${e.name}`),open:t,onOk:u,onCancel:p,okText:s("Export"),cancelText:s("Cancel"),confirmLoading:n,cancelButtonProps:{disabled:n},children:[f&&(0,a.jsx)(_.ui_kit$Alert,{title:s(f.label),description:s(f.helpText),type:"info",showIcon:!0,style:{marginBottom:16}}),(0,a.jsx)(_.ui_kit$Form,{form:c,layout:"vertical",children:d.map(g=>(0,a.jsx)(_.ui_kit$Form.Item,{label:s(g.label),name:g.name,rules:[...g.required?[{required:!0,message:s(`Please enter ${g.label.toLowerCase()}`)}]:[],...g.type==="number"?[{type:"number",message:s(`${g.label} must be a number`)}]:[]],children:sm(g,s)},g.name))})]})},Xn=r.createApi({reducerPath:"unisenderApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createEmailMessage:e.mutation({query:t=>{const n="https://api.unisender.com/ru/api/createEmailMessage",o=new URLSearchParams;return o.append("format","json"),Object.entries(t).forEach(([i,s])=>{o.append(i,String(s))}),{url:`?proxy_url=${encodeURIComponent(n)}`,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString()}}})})}),{useCreateEmailMessageMutation:lm}=Xn,Jn=r.createApi({reducerPath:"mailganerApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://mailganer.com"}),endpoints:e=>({createMailing:e.mutation({query:t=>{const n=new URLSearchParams;return n.append("api_key",t.api_key),n.append("name",t.name),n.append("html-content",t.html_content),t.theme&&n.append("theme",t.theme),t.from_name&&n.append("from_name",t.from_name),t.from_email&&n.append("from_email",t.from_email),t.segment_id&&n.append("segment_id",String(t.segment_id)),t.utm_campaign&&n.append("utm_campaign",t.utm_campaign),t.utm_source&&n.append("utm_source",t.utm_source),t.utm_medium&&n.append("utm_medium",t.utm_medium),{url:"/api/v1/mailing/create/",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()}}})})}),{useCreateMailingMutation:cm}=Jn,Zn=r.createApi({reducerPath:"sendsayApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://api.sendsay.ru"}),endpoints:e=>({createDraft:e.mutation({query:t=>{const n={action:"issue.draft.set",apikey:t.api_key,return_fresh_obj:1,obj:{name:t.name,letter:{subject:t.subject,"from.name":t.from_name||void 0,"from.email":t.from_email||void 0,message:{html:t.html_content}}}};return{url:`/general/api/v100/json/${t.login.split("/").map(o=>encodeURIComponent(o)).join("/")}`,method:"POST",headers:{"Content-Type":"application/json"},body:n}}})})}),{useCreateDraftMutation:dm}=Zn,er=r.createApi({reducerPath:"altcraftApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({addTemplate:e.mutation({query:t=>{const n=`${t.api_url}/api/v1.1/templates/add`,o={token:t.api_key,name:t.name,channels:[{sid:"email",fields:{html:t.html_content,text:"",subject:t.subject||t.name,from_email:t.from_email||"",from_name:t.from_name||"",replyto_email:"",replyto_name:"",is_not_inline:!0}}],is_draft:t.is_draft??!1};return{url:`?proxy_url=${encodeURIComponent(n)}`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}}})})}),{useAddTemplateMutation:um}=er,pm=e=>e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/\s+/g," ").trim(),tr=r.createApi({reducerPath:"enkodApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://api.enkod.ru"}),endpoints:e=>({createMessage:e.mutation({query:t=>{const n=pm(t.html_content)||t.subject,o={message:{subject:t.subject,fromEmail:t.sender_email||"",fromName:t.sender_name||"",html:t.html_content,plainText:n},isDraft:!0};return{url:"/v1/message/onetime/",method:"POST",headers:{"Content-Type":"application/json",Apikey:t.api_key},body:o}}})})}),{useCreateMessageMutation:mm}=tr,fm=e=>{const t=e.split("-");return t.length>1?t[1]:"us1"},gm=e=>`https://${fm(e)}.api.mailchimp.com/3.0`,nr=r.createApi({reducerPath:"mailchimpApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=gm(t.api_key),c=btoa(`anystring:${t.api_key}`),d={type:"regular",recipients:{list_id:t.list_id},settings:{subject_line:t.subject,from_name:t.from_name,reply_to:t.from_email}},u=await i({url:`?proxy_url=${encodeURIComponent(`${s}/campaigns`)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(d)});if(u.error){const y=u.error,m=y?.data?.detail||y?.error||String(u.error),S=y?.data?.errors;return{error:{status:"CUSTOM_ERROR",error:S?.length?S.map(k=>k.detail||k.title).join("; "):m}}}const p=u.data;if(!p?.id)return{error:{status:"CUSTOM_ERROR",error:u.data?.errors?.map(y=>y.detail||y.title).join("; ")||"Failed to create campaign"}};const f={html:t.html},g=await i({url:`?proxy_url=${encodeURIComponent(`${s}/campaigns/${p.id}/content`)}`,method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(f)});if(g.error){const y=g.error;return{error:{status:"CUSTOM_ERROR",error:y?.data?.detail||y?.error||String(g.error)}}}return{data:{id:p.id,status:p.status,web_id:p.web_id}}}})})}),{useCreateCampaignMutation:hm}=nr,mo="https://a.klaviyo.com/api",_m="2025-04-15",ym=e=>({"Content-Type":"application/json",Accept:"application/json",Authorization:`Klaviyo-API-Key ${e}`,revision:_m}),rr=r.createApi({reducerPath:"klaviyoApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=ym(t.api_key),c={data:{type:"template",attributes:{name:`Email ${Date.now()}`,editor_type:"CODE",html:t.html}}},d=await i({url:`?proxy_url=${encodeURIComponent(`${mo}/templates`)}`,method:"POST",headers:s,body:JSON.stringify(c)});if(d.error){const w=d.error,b=w?.data?.errors,A=w?.data?.detail;return{error:{status:"CUSTOM_ERROR",error:b?.length?b.map(x=>x.detail||x.status).join("; "):A||w?.error||String(d.error)}}}const u=d.data?.data?.id;if(!u)return{error:{status:"CUSTOM_ERROR",error:"Failed to create template"}};const p={data:{type:"campaign",attributes:{name:`Campaign ${Date.now()}`,audiences:{included:[t.list_id],excluded:[]},send_strategy:{method:"immediate"},"campaign-messages":{data:[{type:"campaign-message",attributes:{definition:{channel:"email",label:t.subject,content:{subject:t.subject,from_email:t.from_email,from_label:t.from_name,reply_to_email:t.from_email}}}}]}}}},f=await i({url:`?proxy_url=${encodeURIComponent(`${mo}/campaigns`)}`,method:"POST",headers:s,body:JSON.stringify(p)});if(f.error){const w=f.error,b=w?.data?.errors,A=w?.data?.detail;return{error:{status:"CUSTOM_ERROR",error:b?.length?b.map(x=>x.detail||x.status).join("; "):A||w?.error||String(f.error)}}}const g=f.data,y=g?.data?.relationships?.["campaign-messages"]?.data?.[0]?.id,m=g?.data?.id;if(!y)return{error:{status:"CUSTOM_ERROR",error:"Failed to get campaign message from campaign"}};const S={data:{type:"campaign-message",id:y,relationships:{template:{data:{type:"template",id:u}}}}},k=await i({url:`?proxy_url=${encodeURIComponent(`${mo}/campaign-message-assign-template`)}`,method:"POST",headers:s,body:JSON.stringify(S)});if(k.error){const w=k.error,b=w?.data?.errors,A=w?.data?.detail;return{error:{status:"CUSTOM_ERROR",error:b?.length?b.map(x=>x.detail||x.status).join("; "):A||w?.error||String(k.error)}}}return{data:{id:m,campaign_message_id:y}}}})})}),{useCreateCampaignMutation:vm}=rr,bm="https://api.hubapi.com",Em=e=>({"Content-Type":"application/json",Authorization:`Bearer ${e}`}),or=r.createApi({reducerPath:"hubspotApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createEmail:e.mutation({queryFn:async(t,n,o,i)=>{const s=Em(t.api_key),c={name:t.name,subject:t.subject,from:{fromName:t.from_name,replyTo:t.from_email},content:{templatePath:"@hubspot/email/dnd/plain_text.html",widgets:{"module-0-1-1":{body:{html:t.html,path:"@hubspot/rich_text",schema_version:2},child_css:{},css:{},id:"module-0-1-1",name:"module-0-1-1",order:2,styles:{},type:"module"},"module-1-1-1":{body:{align:"center",path:"@hubspot/email_footer",schema_version:2,unsubscribe_link_type:"both"},child_css:{},css:{},id:"module-1-1-1",name:"module-1-1-1",order:3,styles:{},type:"module"}}}},d=await i({url:`?proxy_url=${encodeURIComponent(`${bm}/marketing/v3/emails/`)}`,method:"POST",headers:s,body:JSON.stringify(c)});if(d.error){const p=d.error,f=p?.data?.errors,g=p?.data?.message;return{error:{status:"CUSTOM_ERROR",error:f?.length?f.map(y=>y.message||y.errorType).join("; "):g||p?.error||String(d.error)}}}const u=d.data;return u?.id?{data:{id:u.id}}:{error:{status:"CUSTOM_ERROR",error:d.data?.errors?.map(p=>p.message||p.errorType).join("; ")||"Failed to create email"}}}})})}),{useCreateEmailMutation:Sm}=or,ir=r.createApi({reducerPath:"salesforceMcApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createEmail:e.mutation({queryFn:async(t,n,o,i)=>{const s=`https://${t.subdomain}.auth.marketingcloudapis.com/v2/token`,c=await i({url:`?proxy_url=${encodeURIComponent(s)}`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"client_credentials",client_id:t.client_id,client_secret:t.client_secret})});if(c.error){const m=c.error;return{error:{status:"CUSTOM_ERROR",error:m?.data?.error_description||m?.data?.error||m?.error||String(c.error)}}}const d=c.data,u=d?.access_token,p=d?.rest_instance_url;if(!u||!p)return{error:{status:"CUSTOM_ERROR",error:d?.error_description||d?.error||"Failed to get access token"}};const f={name:t.name,assetType:{id:208,name:"htmlemail"},views:{html:{content:t.html},text:{},subjectline:{content:t.subject},preheader:{}},data:{email:{options:{characterEncoding:"utf-8"}}}},g=await i({url:`?proxy_url=${encodeURIComponent(`${p.replace(/\/$/,"")}/asset/v1/content/assets`)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(f)});if(g.error){const m=g.error,S=m?.data?.errors,k=m?.data?.message;return{error:{status:"CUSTOM_ERROR",error:S?.length?S.map(w=>w.message||w.documentation).join("; "):k||m?.error||String(g.error)}}}const y=g.data;return y?.id?{data:{id:y.id}}:{error:{status:"CUSTOM_ERROR",error:g.data?.errors?.map(m=>m.message).join("; ")||"Failed to create email"}}}})})}),{useCreateEmailMutation:wm}=ir,km=e=>e.replace(/\/$/,""),Cm=e=>e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()||" ",sr=r.createApi({reducerPath:"activecampaignApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=km(t.api_url),c=t.api_key,d={"Content-Type":"application/json","Api-Token":c},u=await i({url:`?proxy_url=${encodeURIComponent(`${s}/api/3/addresses`)}`,method:"GET",headers:{"Api-Token":c}});if(u.error)return{error:{status:"CUSTOM_ERROR",error:"Failed to load mailing addresses. Check your API URL and Key."}};const p=u.data?.addresses??[],f=p.find(x=>x.isDefault==="1")??p[0];if(!f?.id)return{error:{status:"CUSTOM_ERROR",error:"NO_MAILING_ADDRESS"}};const g={message:{name:t.name,fromname:t.from_name,fromemail:t.from_email,email:t.from_email,reply2:t.from_email,subject:t.subject,html:t.html,text:Cm(t.html),preheader_text:"",format:"mime"}},y=await i({url:`?proxy_url=${encodeURIComponent(`${s}/api/3/messages`)}`,method:"POST",headers:d,body:JSON.stringify(g)});if(y.error){const x=y.error;return{error:{status:"CUSTOM_ERROR",error:x?.data?.message||x?.error||"Failed to create message."}}}const m=y.data?.message?.id;if(!m)return{error:{status:"CUSTOM_ERROR",error:"Message created but no ID returned."}};const S=`${s}/admin/api.php?api_action=campaign_create&api_output=json`,k=new URLSearchParams;k.append("type","single"),k.append("name",t.name),k.append("sdate","2099-12-31 12:00:00"),k.append("status","0"),k.append("public","1"),k.append("trackreads","1"),k.append("tracklinks","all"),k.append("htmlunsub","1"),k.append("textunsub","1"),k.append("addressid",String(f.id)),k.append(`p[${t.list_id}]`,t.list_id),k.append(`m[${m}]`,"100");const w=await i({url:`?proxy_url=${encodeURIComponent(S)}`,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","Api-Token":c},body:k.toString()});if(w.error){const x=w.error;return{error:{status:"CUSTOM_ERROR",error:x?.data?.result_message||x?.error||"Message created, but campaign creation failed."}}}const b=w.data;if(Number(b?.result_code)===0)return{error:{status:"CUSTOM_ERROR",error:b?.result_message||"Campaign creation failed (v1 API)."}};const A=b?.id;return A?{data:{campaignId:String(A)}}:{error:{status:"CUSTOM_ERROR",error:b?.result_message||"Campaign created but no ID returned."}}}})})}),{useCreateCampaignMutation:Tm}=sr,Im="https://api.brevo.com/v3",ar=r.createApi({reducerPath:"brevoApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s={name:t.name,subject:t.subject,sender:{name:t.from_name,email:t.from_email},htmlContent:t.html,recipients:{listIds:[t.list_id]}},c=await i({url:`?proxy_url=${encodeURIComponent(`${Im}/emailCampaigns`)}`,method:"POST",headers:{"Content-Type":"application/json","api-key":t.api_key},body:JSON.stringify(s)});if(c.error){const u=c.error;return{error:{status:"CUSTOM_ERROR",error:u?.data?.message||u?.data?.code||u?.error||String(c.error)}}}const d=c.data;return d?.id?{data:{id:d.id}}:{error:{status:"CUSTOM_ERROR",error:c.data?.message||"Failed to create campaign"}}}})})}),{useCreateCampaignMutation:Am}=ar,xm="https://api.createsend.com/api/v3.3",Pm=e=>`Basic ${btoa(`${e}:x`)}`,lr=r.createApi({reducerPath:"campaignMonitorApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s={Name:t.name,Subject:t.subject,FromName:t.from_name,FromEmail:t.from_email,ReplyTo:t.from_email,HtmlUrl:t.html_url,ListIDs:[t.list_id],InlineCss:!0},c=await i({url:`?proxy_url=${encodeURIComponent(`${xm}/campaigns/${t.client_id}.json`)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:Pm(t.api_key)},body:JSON.stringify(s)});if(c.error){const p=c.error;return{error:{status:"CUSTOM_ERROR",error:p?.data?.Message||p?.error||String(c.error)}}}const d=c.data,u=typeof d=="string"?d:d?.id;return!u||typeof u!="string"?{error:{status:"CUSTOM_ERROR",error:d?.Message||"Failed to create campaign"}}:{data:{id:u}}}})})}),{useCreateCampaignMutation:jm}=lr,bs="https://api.cc.email/v3",Rm=e=>e.includes("[[trackingImage]]")?e:e.replace(/<body([^>]*)>/i,"<body$1>[[trackingImage]]"),cr=r.createApi({reducerPath:"constantContactApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=Rm(t.html),c={name:t.name,email_campaign_activities:[{format_type:5,from_email:t.from_email,reply_to_email:t.from_email,from_name:t.from_name,subject:t.subject,html_content:s}]},d=await i({url:`?proxy_url=${encodeURIComponent(`${bs}/emails`)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.access_token}`},body:JSON.stringify(c)});if(d.error){const m=d.error;return{error:{status:"CUSTOM_ERROR",error:m?.data?.error_message||m?.data?.error_key||m?.error||String(d.error)}}}const u=d.data,p=u?.campaign_activities?.find(m=>m.role==="primary_email")?.campaign_activity_id,f=u?.campaign_id;if(!p||!f)return{error:{status:"CUSTOM_ERROR",error:"Failed to create campaign"}};const g={campaign_activity_id:p,campaign_id:f,role:"primary_email",contact_list_ids:[t.list_id],segment_ids:[],current_status:"DRAFT",format_type:5,from_email:t.from_email,from_name:t.from_name,reply_to_email:t.from_email,subject:t.subject,html_content:s},y=await i({url:`?proxy_url=${encodeURIComponent(`${bs}/emails/activities/${p}`)}`,method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.access_token}`},body:JSON.stringify(g)});if(y.error){const m=y.error;return{error:{status:"CUSTOM_ERROR",error:m?.data?.error_message||m?.data?.error_key||m?.error||String(y.error)}}}return{data:{campaign_id:f}}}})})}),{useCreateCampaignMutation:Om}=cr,Lm="https://api.getresponse.com/v3",Mm=e=>`api-key ${e}`,dr=r.createApi({reducerPath:"getresponseApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createNewsletter:e.mutation({queryFn:async(t,n,o,i)=>{const s=t.html.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim(),c={name:t.name,type:"draft",subject:t.subject,fromField:{fromFieldId:t.from_field_id},replyTo:{fromFieldId:t.from_field_id},campaign:{campaignId:t.campaign_id},content:{html:t.html,plain:s||"Newsletter"},flags:["openrate","clicktrack"],sendSettings:{selectedCampaigns:[t.campaign_id]}},d=await i({url:`?proxy_url=${encodeURIComponent(`${Lm}/newsletters`)}`,method:"POST",headers:{"Content-Type":"application/json","X-Auth-Token":Mm(t.api_key)},body:JSON.stringify(c)});if(d.error){const p=d.error;return{error:{status:"CUSTOM_ERROR",error:p?.data?.message||p?.data?.code||p?.error||String(d.error)}}}const u=d.data;return u?.newsletterId?{data:{newsletterId:u.newsletterId}}:{error:{status:"CUSTOM_ERROR",error:d.data?.message||"Failed to create newsletter"}}}})})}),{useCreateNewsletterMutation:Nm}=dr,Dm=e=>`https://${e||"r1"}-api.dotdigital.com/v2`,Es=(e,t)=>`Basic ${btoa(`${e}:${t}`)}`,Ss=e=>e&&typeof e=="object"&&"data"in e&&e.data!==void 0?e.data:e,ws=e=>e.trim().toLowerCase(),ur=r.createApi({reducerPath:"dotdigitalApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=t.html.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim(),c=Dm(t.region),d={"Content-Type":"application/json",Authorization:Es(t.username,t.password)},u=await i({url:`?proxy_url=${encodeURIComponent(`${c}/custom-from-addresses`)}`,method:"GET",headers:{Authorization:Es(t.username,t.password)}});let p=[];if(!u.error){const w=Ss(u.data);Array.isArray(w)?p=w:w&&typeof w=="object"&&Array.isArray(w.items)&&(p=w.items)}const f=ws(t.from_email),g=p.find(w=>w.email&&ws(w.email)===f),y={name:t.name,subject:t.subject,fromName:t.from_name,htmlContent:t.html,plainTextContent:s||"Newsletter"},m=!g?.id;g?.id!=null&&(y.fromAddress={id:g.id});const S=await i({url:`?proxy_url=${encodeURIComponent(`${c}/campaigns`)}`,method:"POST",headers:d,body:JSON.stringify(y)});if(S.error){const w=S.error;return{error:{status:"CUSTOM_ERROR",error:w?.data?.message||w?.error||String(S.error)}}}const k=Ss(S.data);return k?.id?{data:{id:k.id,usedAccountDefaultFromAddress:m}}:{error:{status:"CUSTOM_ERROR",error:S.data?.message||k?.message||"Failed to create campaign"}}}})})}),{useCreateCampaignMutation:Fm}=ur,Bm="https://app.bentonow.com/api/v1",$m=(e,t)=>`Basic ${btoa(`${e}:${t}`)}`,pr=r.createApi({reducerPath:"bentoApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createBroadcast:e.mutation({queryFn:async(t,n,o,i)=>{const s={broadcasts:[{name:t.name,subject:t.subject,content:t.html,type:"raw",from:{email:t.from_email,name:t.from_name},inclusive_tags:t.inclusive_tags||"subscribers",exclusive_tags:"",segment_id:t.segment_id||"",batch_size_per_hour:500,approved:!1}]},c=`${Bm}/batch/broadcasts?site_uuid=${encodeURIComponent(t.site_uuid)}`,d=await i({url:`?proxy_url=${encodeURIComponent(c)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:$m(t.publishable_key,t.secret_key),"User-Agent":"EmailMaker/1.0"},body:JSON.stringify(s)});if(d.error){const u=d.error;return{error:{status:"CUSTOM_ERROR",error:u?.data?.message||u?.error||String(d.error)}}}return{data:{count:d.data?.count??1}}}})})}),{useCreateBroadcastMutation:Um}=pr,zm=()=>{const{__:e}=r.useI18n(),[t,{isLoading:n}]=lm(),[o,{isLoading:i}]=cm(),[s,{isLoading:c}]=dm(),[d,{isLoading:u}]=um(),[p,{isLoading:f}]=mm(),[g,{isLoading:y}]=hm(),[m,{isLoading:S}]=vm(),[k,{isLoading:w}]=Sm(),[b,{isLoading:A}]=wm(),[x,{isLoading:Y}]=Tm(),[Z,{isLoading:M}]=Am(),[O,{isLoading:I}]=jm(),[R,{isLoading:z}]=Om(),[B,{isLoading:U}]=Nm(),[de,{isLoading:me}]=Fm(),[q,{isLoading:ee}]=Um(),Fe=n||i||c||u||f||y||S||w||A||Y||M||I||z||U||me||ee,ze={unisender:async(T,P,N,D)=>{try{const v=await t({api_key:T.api_key,sender_name:T.sender_name,sender_email:T.sender_email,subject:D,body:N,list_id:P.list_id,generate_text:1,lang:"ru"}).unwrap();return v.result?.message_id?{success:!0,message:e("Email successfully created!"),link:{url:`https://app.unisender.com/ru/v5/spa/email-campaign/editor/${v.result.message_id}?step=send`,text:e("Open in Unisender")}}:v.error?{success:!1,error:v.error+(v.code?` (${v.code})`:"")}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create email")}}},mailganer:async(T,P,N,D)=>{try{const v=await o({api_key:T.api_key,name:P.name,html_content:N,theme:P.theme||D,from_name:T.from_name,from_email:T.from_email}).unwrap();return v.status===1&&v.public_id?{success:!0,message:e("Mailing successfully created!"),link:v.step1_url?{url:v.step1_url,text:e("Open in Mailganer")}:void 0}:v.error?{success:!1,error:v.error}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create mailing")}}},sendsay:async(T,P,N,D)=>{try{const v=await s({login:T.login,api_key:T.api_key,name:P.name,subject:P.subject,html_content:N,from_name:T.from_name,from_email:T.from_email}).unwrap();return v.obj?.id?{success:!0,message:e("Draft successfully created!"),link:{url:`https://app.sendsay.ru/content/drafts/email/${v.obj.id}/settings`,text:e("Open in Sendsay")}}:v.errors&&v.errors.length>0?{success:!1,error:v.errors.map(W=>W.explain).join(", ")}:v.error?{success:!1,error:v.explain||v.error}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create draft")}}},altcraft:async(T,P,N,D)=>{try{const v=await d({api_url:T.api_url,api_key:T.api_key,name:P.name,html_content:N,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email}).unwrap();return v.error===0?{success:!0,message:e("Template successfully created!")}:{success:!1,error:v.error_text||e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create template")}}},enkod:async(T,P,N,D)=>{try{const v=await p({api_key:T.api_key,subject:P.subject,html_content:N,sender_name:T.sender_name,sender_email:T.sender_email}).unwrap();if(v.success||v.messageId||v.id){const W=v.messageId||v.id;return{success:!0,message:e("Draft successfully created!"),link:W?{url:`https://app.enkod.ru/ensend/messages/detail/${W}/preview`,text:e("Open in enKod")}:void 0}}else if(v.error||v.message)return{success:!1,error:v.error||v.message||e("Unknown error")};return{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create draft")}}},mailchimp:async(T,P,N,D)=>{try{const v=await g({api_key:T.api_key,list_id:P.list_id,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html:N}).unwrap();if(v.id){const W=T.api_key?.split("-")[1]||"us1";return{success:!0,message:e("Campaign successfully created!"),link:{url:`https://${W}.admin.mailchimp.com/campaigns/#r:campaignId=${v.id}`,text:e("Open in Mailchimp")}}}return{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},klaviyo:async(T,P,N,D)=>{try{const v=await m({api_key:T.api_key,list_id:P.list_id,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html:N}).unwrap();return v.id?{success:!0,message:e("Campaign successfully created!"),link:{url:`https://www.klaviyo.com/campaign/${v.id}/wizard/1`,text:e("Open in Klaviyo")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},hubspot:async(T,P,N,D)=>{try{const v=await k({api_key:T.api_key,name:P.name,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html:N}).unwrap();return v.id?{success:!0,message:e("Email successfully created!"),link:{url:`https://app.hubspot.com/email/0/edit/${v.id}`,text:e("Open in HubSpot")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create email")}}},salesforce_mc:async(T,P,N,D)=>{try{const v=await b({subdomain:T.subdomain,client_id:T.client_id,client_secret:T.client_secret,name:P.name,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html:N}).unwrap();return v.id?{success:!0,message:e("Email successfully created!"),link:{url:`https://app.s7.exacttarget.com/ContentBuilder?app=contentbuilder&id=${v.id}`,text:e("Open in Marketing Cloud")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create email")}}},activecampaign:async(T,P,N,D)=>{try{const v=await x({api_url:T.api_url,api_key:T.api_key,list_id:T.list_id,name:P.name,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html:N}).unwrap();if(v.campaignId){const W=(T.api_url||"").replace(/\/$/,"").match(/https?:\/\/([^.]+)\.api-/),Pe=W?W[1]:"",Ae=Pe?`https://${Pe}.activehosted.com/app/campaigns/${v.campaignId}`:"https://www.activecampaign.com/app/campaigns";return{success:!0,message:e("Draft campaign created! Open it to review and schedule."),link:{url:Ae,text:e("Open draft campaign")}}}return{success:!1,error:e("Unknown error")}}catch(v){const W=v.message||v.error||"";if(W==="NO_MAILING_ADDRESS"){const Pe=(T.api_url||"").replace(/\/$/,"").match(/https?:\/\/([^.]+)\.api-/),Ae=Pe?Pe[1]:"",Qe=Ae?`https://${Ae}.activehosted.com/app/settings/addresses`:"https://www.activecampaign.com/app/settings/addresses";return{success:!1,error:e("No mailing address found. Add one in ActiveCampaign: ")+Qe}}return{success:!1,error:W||e("Failed to create campaign")}}},brevo:async(T,P,N,D)=>{try{const v=await Z({api_key:T.api_key,list_id:Number(P.list_id),name:P.name,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html:N}).unwrap();return v.id?{success:!0,message:e("Campaign successfully created!"),link:{url:`https://app.brevo.com/marketing-campaign/edit/${v.id}`,text:e("Open in Brevo")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},campaign_monitor:async(T,P,N,D)=>{try{const v=P.html_url?.trim();if(!v)return{success:!1,error:e("HTML URL is required. Save the email first, or paste a custom URL to your hosted HTML.")};const W=await O({api_key:T.api_key,client_id:T.client_id,list_id:P.list_id,name:P.name,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html_url:v.trim()}).unwrap();return W.id?{success:!0,message:e("Campaign successfully created!"),link:{url:`https://app.createsend.com/campaigns/#/${W.id}`,text:e("Open in Campaign Monitor")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},constant_contact:async(T,P,N,D)=>{try{return(await R({access_token:T.access_token,list_id:P.list_id,name:P.name,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html:N}).unwrap()).campaign_id?{success:!0,message:e("Campaign successfully created!"),link:{url:"https://app.constantcontact.com/pages/email/campaigns",text:e("Open in Constant Contact")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},getresponse:async(T,P,N,D)=>{try{const v=await B({api_key:T.api_key,from_field_id:T.from_field_id,campaign_id:P.campaign_id,name:P.name,subject:P.subject||D,html:N}).unwrap();return v.newsletterId?{success:!0,message:e("Newsletter successfully created!"),link:{url:`https://app.getresponse.com/letter/${v.newsletterId}`,text:e("Open in GetResponse")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create newsletter")}}},dotdigital:async(T,P,N,D)=>{try{const v=await de({username:T.username,password:T.password,region:T.region||"r1",name:P.name,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html:N}).unwrap();return v.id?{success:!0,message:v.usedAccountDefaultFromAddress?e("Campaign created. Dotdigital used your account default sender because this From email is not registered as a custom from address. Add the address in Dotdigital and export again to use it."):e("Campaign successfully created!"),link:{url:"https://login.dotdigital.com/",text:e("Open in Dotdigital")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},bento:async(T,P,N,D)=>{try{return await q({publishable_key:T.publishable_key,secret_key:T.secret_key,site_uuid:T.site_uuid,name:P.name,subject:P.subject||D,from_name:T.from_name,from_email:T.from_email,html:N,inclusive_tags:P.inclusive_tags}).unwrap(),{success:!0,message:e("Broadcast successfully created!"),link:{url:"https://app.bentonow.com/",text:e("Open in Bento")}}}catch(v){return{success:!1,error:v.message||e("Failed to create broadcast")}}}};return{exportToIntegration:async(T,P,N,D,v)=>{const W=ze[T];return W?W(P,N,D,v):{success:!1,error:e("Unknown integration")}},isLoading:Fe}},jt={INFO:"info",STORAGE:"storage",STYLES:"styles",MEMBERS:"members",INTEGRATIONS:"integrations",PLUGIN:"plugin"},Xv=jt.INFO,Jv=[jt.INFO,jt.STORAGE,jt.STYLES,jt.MEMBERS,jt.INTEGRATIONS,jt.PLUGIN],Zv={mainsettings:jt.INFO,ftpsettings:jt.STORAGE,webhooksettings:jt.INTEGRATIONS},Gm=async(e,t,n)=>{try{const{notification:o,...i}=e,s=await r.fetchBaseQuery({baseUrl:"https://racs.rest/v3"})(i,t,n);if(s.error)throw new Error;return s}catch(o){return(e?.notification).error(o),{error:o}}},mr=r.createApi({reducerPath:"exportPngApi",baseQuery:Gm,endpoints:e=>({makeTemporaryMailForPng:e.mutation({query:({file:t,title:n,notification:o})=>{const i=new Blob([t],{type:"text/html"}),s=new FormData;return s.append("file",i,"base.html"),s.append("contentType","text/html"),{url:"?resource=exportPngApi",method:"POST",body:s,notification:o}}}),deleteTemporaryMail:e.mutation({query:({id:t,notification:n})=>({url:`/${t}?resource=exportPngApi`,method:"DELETE",notification:n})})})}),{useMakeTemporaryMailForPngMutation:Wm,useDeleteTemporaryMailMutation:Hm}=mr,fr=r.createApi({reducerPath:"webHookApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({postDataByWebHook:e.mutation({query:({url:t,body:n})=>({url:`?proxy_url=${encodeURIComponent(t)}`,method:"POST",body:n})})})}),{usePostDataByWebHookMutation:qm}=fr,Vm=async(e,t,n)=>{try{const{notification:o,...i}=e,s=await r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"})(i,t,n);if(s.error)throw new Error;return s}catch(o){return(e?.notification).error(o),{error:o}}},gr=r.createApi({reducerPath:"htmlToPdfPlusApi",baseQuery:Vm,endpoints:e=>({generateHtmlToPdf:e.mutation({query:({htmlContent:t,notification:n})=>({url:"emails/pdf",method:"POST",body:t,notification:n,responseHandler:o=>o.blob()})})})}),{useGenerateHtmlToPdfMutation:Km}=gr,hr=r.createApi({reducerPath:"proxyApi",tagTypes:["Proxy"],baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/wp-json/cors-proxy/v1/get"}),endpoints:e=>({getFile:e.query({queryFn({url:t,tryFetch:n=!0,type:o},i){const s=r.clientFromApi(i),c=n?fetch(t):Promise.reject(),d=p=>{switch(o){case"json":return p.json();case"text":return p.text();default:return p.blob()}},u=p=>d(p).then(f=>({data:f}));return c.then(p=>u(p)).catch(()=>s.corsProxy.get_list({format:"blob",extraQuery:{url:encodeURIComponent(t)}}))}})})}),{useGetFileQuery:eb,useLazyGetFileQuery:Ym}=hr,tb="email",nb=100;function Qm(e){return yt.sanitizeFileName(String(e??"").trim()).slice(0,100).trimEnd()||"email"}function ks(e){const t=Qm(e);return{archive:`${t}.zip`,desktop:`${t}-desktop.png`,mobile:`${t}-mobile.png`}}function Xm(e,t){const n=ks(e);return{[n.desktop]:t.desktop,[n.mobile]:t.mobile}}var fo=()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/41a7e33c.js")).then(e=>e.import_exports),void 0,{}.url),Jm=1,Zm=2,ef=375,Dt={fontSize:"16px"},tf={position:"absolute",bottom:-4,right:-4,borderRadius:"100%",backgroundColor:r.emCssVar("colorBgContainer")},nf={position:"relative",display:"inline-flex"},qt=({icon:e,locked:t,strokeWidth:n,className:o})=>(0,a.jsxs)("span",{className:o,style:nf,children:[e,t&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:12,strokeWidth:n,style:tf})]}),rf=({email:e,autoSaveBlockResult:t})=>{const{__:n,_x:o}=r.useI18n(),i=r.useDispatch(),s=r.useEmailAttributesWriter(),[c]=Ym(),[d]=r.useUploadImageMutation(),u=r.useAppNavigate(),{owner:p,admin:f}=Qn(),g=r.useCurrentUser(),y=r.useProjectData(),{modal:m}=_.ui_kit$App.useApp(),S=r.useNotification(),{confirm:k}=m,w=r.useAppStore(),b=()=>on(h.getContainer(w)).keepWrappedOnOutput,A=(L,V,X,oe)=>yt.prepareHTML(L,V,X,oe,b()),x=(L,V,X,oe,re,H)=>yt.getEML(L,V,X,oe,re,H,b()),Y=(L,V,X,oe,re)=>yt.htmlToFilesData(L,V,X,oe,re,b()),Z=r.useCookieManager(),M=r.useAppConfig(),O=ys(),{beeFreeConverterEnabled:I,aiLayoutConverterEnabled:R}=O,z=r.useEditorProjectId(),B=r.useEventEmitter(h.events.ON_EMAIL_CLONE_ID),U=r.useEventEmitter(h.events.ON_BROWSER_EXTENSION_DETECTED_ID),[de]=qm(),me=!0,{data:q}=r.useGetProjectIntegrationsQuery(y?.id??0,{skip:me}),{data:ee}=r.useGetProjectWebhookQuery(y?.id??0,{skip:me}),[Fe]=r.useLazyGetIntegrationCredentialsQuery(),{exportToIntegration:be,isLoading:et}=zm(),Ee=r.usePushToDataLayer(),[fe,Q]=(0,l.useState)(()=>!Ht(h.getContainer(w)).contentShown()),[pe,se]=(0,l.useState)(!1),[ae,Ie]=(0,l.useState)(null),[Ce,Be]=(0,l.useState)(""),[J,_e]=(0,l.useState)(!1),[Te,ge]=(0,l.useState)(0),[Re,ze]=(0,l.useState)(null),[C,T]=(0,l.useState)(""),[P,N]=(0,l.useState)(!1),D=r.usePlanFeatureGate("export_html"),v=r.usePlanFeatureGate("export_pdf"),W=r.usePlanFeatureGate("export_png");r.usePlanFeatureGate("export_webhook");const Pe=r.usePlanFeatureGate("export_platforms"),Ae=r.usePlanFeatureGate("export_amp"),Qe=r.usePlanFeatureGate("template_import"),Ge=r.usePlanFeatureGate("code_minify"),Ze=L=>{_e(!0),ge(r.FEATURE_UPSELL_SLIDE[L])},[pt]=r.emailsApi.useDeleteEmailMutation(),bt=async(L,V)=>{try{const X=await pt(L.id).unwrap();L.project,S.success(n('The email "')+X.title+o('" was successfully removed.',"email")),Ee({event:"delete",action:"delete_email",entity_type:"email",entity_id:L.id,project_id:L.project,context:"editor"})}catch(X){S.error(X)}},[ft,lt]=r.useAddEmailMutation(),[G]=Wm(),[K]=Hm(),[ne]=Km(),ue=r.useProjectData(),he=r.useInvalidateTerms(),We=r.useSelector(r.selectIsHeaderCodeMenuOpen);(0,l.useEffect)(()=>{We.switched&&Q(!1)},[We]);const Ve=()=>{const{title:L}=e;return L===null?n("New email title"):L},st=(L,V,X=!1)=>{const oe=r.getCodeSize(L);X&&r.isCodeSizeExceeded(oe)?(Be(L),Ie(()=>V),se(!0)):V(L)},Bt=()=>{if(se(!1),Ge.isLocked){Ze("code_minify");return}if(ae&&Ce){r.getCodeSize(Ce);const L=r.minifyHtml(Ce);r.getCodeSize(L),ae(L),Ie(null),Be("")}},Me=()=>{se(!1),ae&&Ce&&(ae(Ce),Ie(null),Be(""))},Xe=()=>{se(!1),Ie(null),Be("")},ie=r.useContentReader(),te=r.useContentReplacer(),$=r.useEvent(h.events.ON_EMAIL_INIT_ID),le=r.useEventEmitter(h.events.ON_LAYOUT_CONVERT_REQUEST_ID);(0,l.useEffect)(()=>{const L=$(()=>{Q(!1)});return()=>L.dispose()},[$]);const xe=async(L,V=ie())=>{const X=document.querySelector(".email-preview"),oe=getComputedStyle(X);return V=await A(V,[oe.width],e.utm_parameters,async re=>{ot(re)}),G({file:V,title:Ve(),notification:S}).unwrap().then(re=>{const H={id:re._id,...re};return L(H,()=>K({id:H.id,notification:S}))}).catch(re=>{S.error({title:re.data?.code,description:re.data?.message})})},Se=(L,V=1)=>xe((X,oe)=>({hrefs:L.map(re=>r.previewHrefForRacs(X.id,void 0,!1,V,void 0,void 0,re)),dispose:oe})),Ne=(L,V,X=2)=>xe((oe,re)=>({data:L.map(H=>({selector:H,href:r.previewHrefForRacs(oe.id,void 0,!1,X,H)})),dispose:re}),V),He=async(L,V)=>{const X=typeof L=="string"?(await c({url:L}))?.data:L;if(!X)return typeof L=="string"?L:"";let oe=r.decodeFileNameFromPath(V);if(typeof L=="string"&&/^https?:\/\//i.test(L)){const qe=r.decodeFileNameFromUrl(L);qe&&(oe=qe)}const re=X,{ensureFileExtension:H,extractUploadResult:ke}=await fo();oe=await H(oe,re.type||"");const ye=new File([re],oe.toLowerCase(),{type:re.type||""});try{const qe=ke(await d({user_id:g.id,folder:String(ue.id),file:ye}).unwrap());if(qe.error)return typeof L=="string"?L:"";if(qe.file_url)return qe.file_url}catch{}return typeof L=="string"?L:""},$e=async L=>{const V=L.document.querySelectorAll("[em-operation=exportAsPicture]"),X=new Map;for(let oe=0,re=V.length;oe<re;oe++){const H=V[oe];H.setAttribute("em-export-id",String(oe)),X.set(`[em-export-id='${oe}']`,H)}X.size&&L.handleRender(async({contentDocument:oe,managedNodeController:re})=>{try{const{data:H,dispose:ke}=await Ne([...X.keys()],r.getOuterHtml(oe),Zm);try{const ye=H.map(async({href:qe,selector:hn},Dn)=>{const mt=X.get(hn);if(mt.tagName==="TD"){mt.removeAttribute("style");for(const _t of[...mt.classList])_t.startsWith("em-mob-")&&mt.classList.remove(_t)}re.commit();const Fr=await He(qe,`${Dn}-${mt.tagName.toLowerCase()}.png`),_n=parseInt(getComputedStyle(mt).width);let wt=new Image(_n);wt.setAttribute("border","0"),wt.setAttribute("style",`display: block; width: 100%; max-width: ${_n}px;`),wt.alt="",wt.src=Fr;const yn=mt.querySelector("a");if(yn){const _t=document.createElement("a");_t.setAttribute("target","_blank"),_t.setAttribute("href",yn.getAttribute("href")),_t.appendChild(wt),wt=_t}if(mt.tagName==="TD"){const _t=mt.cloneNode();_t.removeAttribute("em-operation"),_t.appendChild(wt),wt=_t}mt.replaceWith(wt),re.commit()});await Promise.all(ye)}catch{}finally{ke()}}catch{}})},ot=L=>{const V=L.document;if(ue?.limits?.preview_limit==="0"&&z&&g?.counters?.emails_counter>2&&!V.querySelector(".em-powered-logo")){const X=`<a href="${`https://https://racs.rest/v3/v3/link?app=useblocks&project=${z}&email=${e.id}&link=https%3A%2F%2Fuseblocks.io`}" target="_blank"><img src="https://https://racs.rest/v3/v3/pixel/123.png?image=https://cdn.useblocks.io/blocks/powered.png&project=${z}&email=${e.id}" width="150" height="50" border="0" alt="" style="display: inline-block; width: 100%; max-width: 150px;"></a>`;V.querySelector("body > table:last-child > tbody:last-child > tr:last-child, body > div > table:last-child > tbody:last-child > tr:last-child")&&V.querySelector("body > table:last-child > tbody:last-child > tr:last-child, body > div > table:last-child > tbody:last-child > tr:last-child").insertAdjacentHTML("afterend",`<tr em="block" class="em-powered-logo">
855
+ </td></tr></table>`,Pc={image:"element_image","ai-image":"element_ai_image",text:"element_text",header:"element_heading",button:"element_button",spacer:"element_spacer","list-ul":"element_lists","list-ol":"element_lists",divider:"element_divider",social:"element_social",table:"element_table",countdown:"element_timer",video:"element_video","amp-carousel":"element_amp_carousel","amp-accordion":"element_amp_accordion","amp-form":"element_amp_form"};function yi(e){return Pc[e]??null}var vi=e=>Number(e)||void 0,Rc={colors:[],fonts:[],socials:[]},Vr=(e="entity")=>{const t=typeof globalThis<"u"?globalThis.crypto:void 0;if(t?.randomUUID)return t.randomUUID();const n=typeof performance<"u"?performance.now().toString(36).replace(".",""):String(Date.now());return`${e}-${Date.now().toString(36)}-${n}`},Oc=()=>Vr("soc"),jc=/^[a-z][a-z0-9+.-]*:/i,bi=e=>{const t=String(e??"").trim();return t?jc.test(t)?t:`https://${t}`:""},Lc=e=>{const t=bi(e);if(!t)return!1;try{const n=new URL(t);return n.protocol==="https:"&&!!n.hostname}catch{return!1}},Mc=e=>[...e].filter(t=>t.url.trim()!=="").sort((t,n)=>t.order-n.order),Nc=e=>Mc(e).map(t=>({platform:t.icon_key,href:t.url,label:t.name,...t.icon_url?{iconSrc:t.icon_url}:{}})),Dc=/^#?([0-9a-f])([0-9a-f])([0-9a-f])$/i,Fc=/^#?([0-9a-f]{6})$/i,Kr=e=>{if(!e)return null;const t=String(e).trim().toLowerCase(),n=Fc.exec(t);if(n)return`#${n[1]}`;const o=Dc.exec(t);if(o){const[,i,s,c]=o;return`#${i}${i}${s}${s}${c}${c}`}return null},Ei=()=>Vr("bc"),Bc=/\.(woff2|woff|ttf|otf)$/i,$c=e=>{const t=Bc.exec(e.trim().toLowerCase());return t?`.${t[1]}`:null},Uc={".woff":"application/x-font-woff",".woff2":"application/font-woff2",".ttf":"font/sfnt",".otf":"font/sfnt"},zc={".woff":["application/x-font-woff","font/woff","application/font-woff"],".woff2":["application/font-woff2","font/woff2"],".ttf":["font/sfnt","application/font-sfnt","application/x-font-ttf","font/ttf","application/x-font-truetype"],".otf":["font/sfnt","application/font-sfnt","application/vnd.ms-opentype","application/x-font-opentype","font/otf","font/opentype"]},Gc=new Set(["","application/octet-stream","binary/octet-stream"]),Wc=e=>{const t=$c(e.name);if(!t)return e;const n=e.type.trim().toLowerCase();return zc[t].includes(n)||!Gc.has(n)?e:new File([e],e.name,{type:Uc[t],lastModified:e.lastModified})},Hc=()=>Vr("fnt"),qc=e=>e.family?.trim()||e.name.trim(),Vc=e=>e.filter(t=>t.source_url?.trim()).map(t=>({family:t.family?.trim()||t.name.trim(),source_url:t.source_url?.trim()??"",weight:t.weight?.trim()||"400",style:t.style??"normal"})),Kc=(e,t={})=>{const n=t.srcOverride?.trim()||e.source_url?.trim();if(!n||!t.srcOverride&&Si(e)||t.srcOverride&&r.isGoogleFontsCssUrl(n))return null;const o=t.familyOverride?.trim()||qc(e),i=e.weight?.trim()||"400",s=e.style??"normal";return`@font-face{font-family:${JSON.stringify(o)};src:url(${JSON.stringify(n)});font-weight:${i};font-style:${s};font-display:swap;}`},Yc=e=>e.source_kind?e.source_kind:r.isGoogleFontsCssUrl(e.source_url)?"google_stylesheet":e.file_name?.trim()?"uploaded":"remote_file",Si=e=>e.source_kind?e.source_kind==="google_stylesheet"||e.source_kind==="remote_stylesheet":r.isGoogleFontsCssUrl(e.source_url),wi="data-em-project-fonts-face",ki="data-em-project-font-link",Qc=e=>{const t=e.filter(n=>Si(n)).map(n=>n.source_url?.trim()??"").filter(Boolean);return[...new Set(t)]},Xc=e=>e.map(t=>Kc(t)).filter(t=>!!t).join(""),Jc=(e,t=document)=>{const n=Xc(e),{head:o}=t;let i=o.querySelector(`style[${wi}]`);if(!n){i?.remove();return}i||(i=t.createElement("style"),i.setAttribute(wi,""),o.appendChild(i)),i.textContent=n},Zc=(e,t=document)=>{const n=new Set(Qc(e)),{head:o}=t;o.querySelectorAll(`link[${ki}]`).forEach(i=>{const s=i.getAttribute("href")??"";n.has(s)?n.delete(s):i.remove()}),n.forEach(i=>{const s=t.createElement("link");s.setAttribute("rel","stylesheet"),s.setAttribute("href",i),s.setAttribute(ki,""),o.appendChild(s)})},ed=(e,t=document)=>{Jc(e,t),Zc(e,t)},td=new Set(["normal","italic","oblique"]),Uv="[emailmaker] projectStyles:",Wt=e=>{},vt=e=>typeof e=="string"?e.trim():"",Ti=e=>!e||e.startsWith("//")?!1:e.startsWith("/")||e.startsWith("./")||e.startsWith("../")?!0:e.toLowerCase().startsWith("https://"),nd=e=>r.isGoogleFontsCssUrl(e)?"google_stylesheet":(e.split(/[?#]/)[0]??"").toLowerCase().endsWith(".css")?"remote_stylesheet":"remote_file",Yr=(e,t,n)=>e.length<=t?e:(Wt(`${n} list is capped at ${t} entries, ${e.length-t} dropped`),e.slice(0,t)),rd=(e,t)=>{const n=Kr(e?.hex);if(!n){Wt(`colors[${t}] skipped: "${String(e?.hex)}" is not a hex color`);return}return{id:vt(e.id)||Ei(),name:vt(e.name),hex:n,order:0}},od=(e,t)=>{const n=vt(e?.family),o=vt(e?.source_url);if(!n){Wt(`fonts[${t}] skipped: family is required`);return}if(!o){Wt(`fonts[${t}] skipped: source_url is required`);return}if(!Ti(o)){Wt(`fonts[${t}] skipped: source_url must be https or relative, got "${o}"`);return}const i=vt(e.style);return{id:vt(e.id)||Hc(),name:vt(e.name)||n,family:n,source_url:o,source_kind:nd(o),weight:vt(e.weight)||"400",style:td.has(i)?i:"normal",order:0}},id=(e,t)=>{const n=bi(e?.url);if(!n||!Lc(n)){Wt(`socials[${t}] skipped: url must be https, got "${String(e?.url)}"`);return}const o=vt(e.icon_key),i=vt(e.icon_url);let s;if(i&&Ti(i)?s=i:i&&Wt(`socials[${t}]: icon_url must be https or relative, got "${i}" — icon dropped`),!o&&!s){Wt(`socials[${t}] skipped: icon_key or icon_url is required`);return}return{id:vt(e.id)||Oc(),name:vt(e.name),url:n,icon_key:o,...s?{icon_url:s}:{},enabled:!0,order:0}},Qr=e=>e.map((t,n)=>({...t,order:n})),sd=e=>({colors:Qr(Yr(e?.colors??[],32,"colors").map(rd).filter(t=>t!==void 0)),fonts:Qr(Yr(e?.fonts??[],20,"fonts").map(od).filter(t=>t!==void 0)),socials:Qr(Yr(e?.socials??[],20,"socials").map(id).filter(t=>t!==void 0))}),ad={tg:"telegram",yt:"youtube",yd:"yandex_zen",tt:"tiktok",pi:"pinterest",ig:"instagram",fb:"facebook",xa:"x",tw:"twitter"},Ci="vk",ld=new Set(r.EM_SOCIAL_SELECT_ORDER),cd=e=>ld.has(e),Ii=e=>{const t=String(e??"").trim().toLowerCase();return t?cd(t)?t:ad[t]??Ci:Ci},dd=e=>Ii(e),ud=new Set(["normal","italic","oblique"]),pd=new Set(["uploaded","remote_file","google_stylesheet"]),Pt=e=>(e??"").trim(),wn=e=>Pt(e)||void 0,Ai=e=>typeof e=="number"&&e>0?e:void 0,md=e=>ud.has(e)?e:void 0,fd=e=>pd.has(e)?e:void 0,gd=(e,t)=>{const n=Kr(Pt(e.hex));return n?{id:Pt(e.id)||Ei(),name:Pt(e.name),hex:n,order:e.order??t}:null},xi=(e,t=0)=>({id:Pt(e.id),name:Pt(e.name),source_url:wn(e.source_url),source_kind:fd(e.source_kind),file_name:wn(e.file_name),family:wn(e.family),weight:wn(e.weight),style:md(e.style),preview_url:wn(e.preview_url),storage_fallback:e.storage_fallback||void 0,font_size_px:Ai(e.font_size_px),line_height_px:Ai(e.line_height_px),order:e.order??t}),hd=(e,t)=>{const n=Pt(e.url);return n?{id:Pt(e.id),name:Pt(e.name),url:n,icon_key:Ii(Pt(e.icon_key)),enabled:e.enabled??!0,order:e.order??t}:null},rn=e=>[...e].sort((t,n)=>t.order-n.order),Pi=e=>e?{colors:rn((e.colors??[]).map(gd).filter(t=>t!==null)),fonts:rn((e.fonts??[]).map(xi)),socials:rn((e.socials??[]).map(hd).filter(t=>t!==null))}:Rc,_d=e=>e==="remote_stylesheet"?"remote_file":e,yd=e=>{const t={};return e.colors&&(t.colors=rn(e.colors).map(n=>({id:n.id,name:n.name.trim(),hex:Kr(n.hex)||n.hex}))),e.fonts&&(t.fonts=rn(e.fonts).map(n=>({id:n.id,name:n.name.trim(),source_url:n.source_url??"",source_kind:_d(Yc(n)),file_name:n.file_name??"",family:n.family??"",weight:n.weight??"",style:n.style??"",preview_url:n.preview_url??"",storage_fallback:n.storage_fallback??!1,font_size_px:n.font_size_px??0,line_height_px:n.line_height_px??0}))),e.socials&&(t.socials=rn(e.socials).map(n=>({id:n.id,name:n.name.trim(),url:n.url,icon_key:dd(n.icon_key),enabled:n.enabled}))),t},Ri="ProjectBrandStyles",Qt=r.createApi({reducerPath:"projectSettingsStylesApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),tagTypes:[Ri],endpoints:e=>({getProjectStyles:e.query({async queryFn({projectId:t},n){const o=r.v2ResultOf(await r.getClientV2(g.getContainer(n)).projects.stylesList({id:String(t)}));return"error"in o?{error:o.error}:{data:Pi(o.data)}},providesTags:(t,n,{projectId:o})=>[{type:Ri,id:String(o)}]}),updateProjectStyles:e.mutation({async queryFn({projectId:t,patch:n},o){const i=r.v2ResultOf(await r.getClientV2(g.getContainer(o)).projects.stylesPartialUpdate({id:String(t)},yd(n)));return"error"in i?{error:i.error}:{data:Pi(i.data)}},async onQueryStarted({projectId:t,patch:n},{dispatch:o,queryFulfilled:i}){const s=o(Qt.util.updateQueryData("getProjectStyles",{projectId:t},c=>Object.assign(c,n)));try{const{data:c}=await i;o(Qt.util.upsertQueryData("getProjectStyles",{projectId:t},c))}catch{s.undo()}}}),uploadProjectFont:e.mutation({async queryFn({projectId:t,file:n},o){const i=new FormData;i.append("file",Wc(n));const s=r.v2ResultOf(await r.getClientV2(g.getContainer(o)).request({path:`/projects/${String(t)}/styles/fonts`,method:"POST",body:i,secure:!0,type:r.ContentType.FormData,format:"json"}));return"error"in s?{error:s.error}:{data:xi(s.data)}},async onQueryStarted({projectId:t},{dispatch:n,queryFulfilled:o}){try{const{data:i}=await o;n(Qt.util.updateQueryData("getProjectStyles",{projectId:t},s=>{s.fonts=s.fonts.some(c=>c.id===i.id)?s.fonts.map(c=>c.id===i.id?i:c):[...s.fonts,i],s.fonts.sort((c,d)=>c.order-d.order)}))}catch{}}})})}),{useGetProjectStylesQuery:vd,useUpdateProjectStylesMutation:zv,useUploadProjectFontMutation:Gv}=Qt,Oi=e=>{const t=r.useIntegratorConfigValue("projectStyles"),{data:n}=vd({projectId:e},{skip:!0});return(0,l.useMemo)(()=>sd(t),[t])},bd=2.5,Ed=({atom:e,onSelect:t,onDragStart:n,isDroppedAtom:o})=>{const i=(0,l.useCallback)(d=>t(d,e),[t,e]),s=(0,l.useCallback)(d=>n(d,e,o),[n,e,o]),c=(0,l.useCallback)(d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),t(d,e))},[t,e]);return(0,a.jsxs)("button",{type:"button",className:"ant-card-hoverable atoms__item "+e.className+(e.isLockedByPlan?" atoms__item_locked":""),draggable:!0,onClick:i,onKeyDown:c,onDragStart:s,"data-test-name":e.name,children:[(0,a.jsxs)("span",{className:"atom-image",children:[e.icon,e.isLockedByPlan&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:12,strokeWidth:bd,className:"atom-image__lock"})]}),(0,a.jsx)("span",{className:"atom-title",children:e.title})]})},ji=()=>{const e=r.useI18n(),{__:t}=e,n=r.useAppConfig(),o=r.useProjectData(),i=r.useCurrentUserLocale()||"en_US",s=xt.useSetHtmlAtomInIframeHandler(),c=xt.useDragStartAtomToIframeHandler(),[d,u]=(0,l.useState)(!1),[p,f]=(0,l.useState)(0),h=r.useMessageService(),y=r.useServices(g.ATOMS_HANDLERS_ID),m=r.useEventEmitter(g.HANDLE_ATOM_INSERT_ID),E=r.usePlanFeatureLocks(),T=vi(o?.id),w=Oi(T),S=w?Nc(w.socials):[],I=S.length>0?gi(S):Sc;let x=[];if(n.elementImageEnabled&&x.push({title:t("Image"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementImage",component:_.icons$ElementImage,size:24,strokeWidth:n.iconStrokeWidth}),html:dc,className:"",name:"image"}),n.elementAIimageEnabled&&x.push({title:t("AI image"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementImageAI",component:_.icons$ElementImageAI,size:24,strokeWidth:n.iconStrokeWidth}),html:uc,className:"ai",name:"ai-image"}),n.elementTextEnabled&&x.push({title:t("Text"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementText",component:_.icons$ElementText,size:24,strokeWidth:n.iconStrokeWidth}),html:pc(e),className:"",name:"text"}),n.elementHeaderEnabled&&x.push({title:t("Header"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementTitle",component:_.icons$ElementTitle,size:24,strokeWidth:n.iconStrokeWidth}),html:mc(e),className:"",name:"header"}),n.elementButtonEnabled&&x.push({title:t("Button"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementButton",component:_.icons$ElementButton,size:24,strokeWidth:n.iconStrokeWidth}),html:fc(e),className:"",name:"button"}),n.elementSpacerEnabled&&x.push({title:t("Spacer"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementSpacer",component:_.icons$ElementSpacer,size:24,strokeWidth:n.iconStrokeWidth}),html:yc,className:"",name:"spacer"}),n.elementListULEnabled&&x.push({title:t("List UL"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementListUL",component:_.icons$ElementListUL,size:24,strokeWidth:n.iconStrokeWidth}),html:gc(e),className:"",name:"list-ul"}),n.elementListOLEnabled&&x.push({title:t("List OL"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementListOL",component:_.icons$ElementListOL,size:24,strokeWidth:n.iconStrokeWidth}),html:hc(e),className:"",name:"list-ol"}),n.elementDividerEnabled&&x.push({title:t("Divider"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementDivider",component:_.icons$ElementDivider,size:24,strokeWidth:n.iconStrokeWidth}),html:_c,className:"",name:"divider"}),n.elementSocialEnabled&&x.push({title:t("Social media"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementSocial",component:_.icons$ElementSocial,size:24,strokeWidth:n.iconStrokeWidth}),html:I,className:"",name:"social"}),n.elementTableEnabled&&x.push({title:t("Table"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementTable",component:_.icons$ElementTable,size:24,strokeWidth:n.iconStrokeWidth}),html:wc(e),className:"",name:"table"}),n.elementCountdownEnabled&&x.push({title:t("Countdown"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementCountdown",component:_.icons$ElementCountdown,size:24,strokeWidth:n.iconStrokeWidth}),html:Cc(i),className:"",name:"countdown"}),n.elementVideoEnabled&&x.push({title:t("Video"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementVideo",component:_.icons$ElementVideo,size:24,strokeWidth:n.iconStrokeWidth}),html:Ic,className:"",name:"video"}),n.elementCarouselEnabled&&x.push({title:t("Carousel"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementCarousel",component:_.icons$ElementCarousel,size:24,strokeWidth:n.iconStrokeWidth}),html:Ac(e),className:"amp",name:"amp-carousel"}),n.elementAccordionEnabled&&x.push({title:t("Accordion"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementAccordion",component:_.icons$ElementAccordion,size:24,strokeWidth:n.iconStrokeWidth}),html:xc(e),className:"amp",name:"amp-accordion"}),n.elementFormEnabled&&x.push({title:t("Form"),icon:(0,a.jsx)(r.EmIcons,{icon:"ElementForm",component:_.icons$ElementForm,size:24,strokeWidth:n.iconStrokeWidth}),html:null,className:"amp",name:"amp-form"}),x=x.map(A=>({...A,fallbackTooltip:t("Coming soon"),planFeature:yi(A.name),isLockedByPlan:E(yi(A.name))})),y){const A={value:x};for(const O of y)O.execute(A);x=A.value}(0,l.useEffect)(()=>{const{dispose:A}=h.addListener(r.EVENT_TYPES.APPLICATION_ATOM_INSERTED,O=>{const z=x.find(B=>B.name===O);z&&m.fire(z)});return()=>A()},[h,x,m]);const K=(0,l.useCallback)(A=>{u(!0),f(A.planFeature?r.FEATURE_UPSELL_SLIDE[A.planFeature]:1)},[]),Z=(0,l.useCallback)(A=>A.isLockedByPlan?(setTimeout(()=>K(A),1e3),!1):!0,[K]),M=(0,l.useCallback)((A,O)=>{if(O.isLockedByPlan){K(O);return}s(A,O)},[K,s]),j=(0,l.useCallback)((A,O,z)=>{c(A,O,z)},[c]);return(0,a.jsxs)("div",{className:"atoms",children:[(0,a.jsx)("div",{className:"atoms__list",children:(0,a.jsx)(_.ui_kit$Space,{wrap:!0,style:{justifyContent:"space-between",rowGap:10},children:x&&x.map((A,O)=>A.html?(0,a.jsx)(Ed,{atom:A,onSelect:M,onDragStart:j,isDroppedAtom:Z},A.title+O.toString()):(0,a.jsx)(_.ui_kit$Tooltip,{title:A.fallbackTooltip||t("Coming soon"),placement:"top",children:(0,a.jsxs)("div",{className:"atoms__item atoms__item_inactive "+A.className,"data-test-name":A.name,children:[(0,a.jsx)("span",{className:"atom-image",children:A.icon}),(0,a.jsx)("span",{className:"atom-title",children:A.title})]},A.title+O.toString())},A.title+O.toString()))})}),(0,a.jsx)(r.PlanUpgradePrompt,{open:d,onCancel:()=>u(!1),initialSlide:p})]})};ji.propTypes={};var Sd={full:{flexGrow:1},768:{width:171},425:{width:25},375:{width:28},320:{width:320}},Li={right:-12,top:4,zIndex:999,padding:0,position:"absolute"},wd=[{kind:"full",width:1200},{kind:"768",width:768},{kind:"425",width:425},{kind:"375",width:375},{kind:"320",width:320,showLabel:!0},{kind:"375",width:375},{kind:"425",width:425,control:"mobile"},{kind:"768",width:768,control:"desktop"},{kind:"full",width:1200}];function kd({kind:e,width:t,label:n,onSelect:o,onHover:i,children:s}){const c=(0,l.useCallback)(()=>i(e,n),[i,e,n]),d=(0,l.useCallback)(()=>i(null,""),[i]),u=(0,l.useCallback)(()=>o(t),[o,t]),p=(0,l.useCallback)(f=>{(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),o(t))},[o,t]);return(0,a.jsx)("div",{className:`device-width__${e}`,style:Sd[e],role:"button",tabIndex:0,"aria-label":n,onMouseEnter:c,onMouseLeave:d,onClick:u,onKeyDown:p,children:s})}function Td({onSelectWidth:e,themeToggle:t}){const{__:n}=r.useI18n(),[o,i]=(0,l.useState)(""),[s,c]=(0,l.useState)(""),d={full:n("Desktop"),768:n("Small desktop – 768px"),425:n("Mobile L – 425px"),375:n("Mobile M – 375px"),320:n("Mobile S – 320px")},u=(0,l.useCallback)((p,f)=>{i(p?`device-width__${p}-hovered`:""),c(f)},[]);return(0,a.jsx)("div",{className:`email-pane__sizes ${o}`,children:(0,a.jsxs)("div",{className:"email-pane__width-selectors-wrapper",children:[(0,a.jsx)("div",{className:"device-width__theme",children:t}),wd.map((p,f)=>(0,a.jsxs)(kd,{kind:p.kind,width:p.width,label:d[p.kind],onSelect:e,onHover:u,children:[p.showLabel?s:null,p.control==="mobile"&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Mobile view"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"default",icon:(0,a.jsx)(r.EmIcons,{icon:"MobileOutlined",component:_.icons$MobileOutlined,size:16,strokeWidth:2}),size:"small",shape:"circle",style:Li})}),p.control==="desktop"&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Desktop view"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"default",icon:(0,a.jsx)(r.EmIcons,{icon:"DesktopOutlined",component:_.icons$DesktopOutlined,size:16,strokeWidth:2}),size:"small",shape:"circle",style:Li})})]},`${p.kind}-${f}`)),(0,a.jsx)("div",{className:"device-width__theme-placeholder"})]})})}var Ue=zt.__toESM(r.require_prop_types()),Mi=g.createIdentifier$1("canvas.resizerBinder"),Cd=g.createIdentifier$1("canvas.service"),Wv={created:r.PHASES.canvasCreated,loaded:r.PHASES.canvasLoaded};function Id(e){return e.getInstance(Cd)}function Ni(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}var Ad={canUndo:!1,canRedo:!1},xd={undo:()=>{},redo:()=>{},clear:()=>{},canUndo:()=>!1,canRedo:()=>!1,createSnapshot:()=>{},restoreSnapshot:()=>{},getPast:()=>[],getFuture:()=>[]};function Xr(e){const t=r.useDocumentSessionContext(),{history:n}=e??t;return(0,l.useMemo)(()=>n?Ni(n):xd,[n])}function Pd(){const{history:e}=r.useDocumentSessionContext(),t=(0,l.useCallback)(i=>e?e.subscribe(i):()=>{},[e]),n=(0,l.useRef)(null),o=(0,l.useCallback)(()=>{if(!e)return Ad;const i={canUndo:e.canUndo(),canRedo:e.canRedo()},s=n.current;return s&&s.canUndo===i.canUndo&&s.canRedo===i.canRedo?s:(n.current=i,i)},[e]);return(0,l.useSyncExternalStore)(t,o)}var Di=2e3,Rd=10,Od="iframe_errors",jd=5;function Ld(e){const{__:t}=r.useI18n(),n=r.useMessageService(),o=Xr(),{error:i}=r.useNotification(),{document:s}=r.useDocumentSessionContext(),c=(0,l.useCallback)(()=>s?.getContent()??"",[s]),d=(0,l.useRef)(0),u=(0,l.useRef)(void 0),p=(0,l.useRef)(!1),f=r.useCurrentUser(),h=(0,l.useCallback)(m=>new Promise((E,T)=>{const w=n.addListener(r.EVENT_TYPES.SANDBOX_READY,()=>{w.dispose(),E()});m&&setTimeout(()=>{w.dispose(),T("timeout")})}),[n]),y=(0,l.useCallback)(m=>{h(Di).catch(E=>{}).finally(()=>{Promise.resolve().then(()=>{if(!p.current){if(++d.current){if(u.current){if(d.current<jd){o.restoreSnapshot(u.current);for(let E=0;E<d.current;E++)o.undo()}}else u.current=o.createSnapshot();n.send(r.EVENT_TYPES.RELOAD)}setTimeout(()=>{if(--d.current===0){u.current=null;const E=new Error(m.message);m.stack&&(E.stack=m.stack);const T=r.reportError(E,{origin:"iframe"}),w={past:o.getPast(Rd),future:o.getFuture(),errorResolved:!p.current,text:c(),message:m.message,stack:m.stack,userId:f?.id,entityId:e?.id,entityType:document.location.pathname.indexOf("emails")>0?"email":"block",sentryEventId:T};i({id:"IFRAME_ERROR",data:w,title:t("Something went wrong")}),g.RACS.post(Od,w).catch(S=>{}),p.current=!1}},Di)}})})},[o,c,i,f?.id,e?.id,t,h,n]);r.useListenPostMessage(r.EVENT_TYPES.APPLICATION_DOMPARSER_ERROR,y)}function Md(e,t){const n=JSON.stringify(t??{});Nd(e?.get().attributes.common_styles,n)||r.writeEmailAttributes(e,{common_styles:n})}function Nd(e,t){if(e===t)return!0;try{return g.deepEqual(JSON.parse(e||"{}"),JSON.parse(t||"{}"))}catch{return!1}}var Wn=Symbol("isIframeEvent");function Dd({children:e}){const[t,n]=(0,l.useState)(),[o,i]=(0,l.useState)(),[s,c]=(0,l.useState)(!1),d=r.useMessageService();return(0,l.useEffect)(()=>{if(t){const u=d.addListener(r.EVENT_TYPES.APPLICATION_IFRAME_DRAG_EVENT,p=>{if(p.type!=="drageleave"&&p.type!=="dragenter"){const f=t.getBoundingClientRect(),h=p.clientX+f.x+window.scrollX,y=p.clientY+f.y+window.scrollY,m=document.elementFromPoint(h,y);if(m){const E=new DataTransfer,T=new DragEvent(p.type,{clientX:h,clientY:y,cancelable:!0,bubbles:!0,dataTransfer:E});T[Wn]=!0,m.dispatchEvent(T)}}});return()=>u.dispose()}},[d,t]),(0,l.useEffect)(()=>{const u=f=>{f[Wn]||c(!0)},p=f=>{f[Wn]||c(!1)};return window.addEventListener("dragstart",u),window.addEventListener("dragend",p),()=>{window.removeEventListener("dragstart",u),window.removeEventListener("dragend",p)}},[o]),(0,l.useEffect)(()=>{const u=p=>{if(!p[Wn]){const f=o.getBoundingClientRect();d.send(r.EVENT_TYPES.SANDBOX_DRAG_EVENT,{value:p.dataTransfer?.getData("Text")||"",type:p.type,clientX:p.pageX-f.x-window.scrollX,clientY:p.pageY-f.y-window.scrollY})}};if(o)return o.addEventListener("dragenter",u),o.addEventListener("dragover",u),o.addEventListener("dragleave",u),o.addEventListener("drop",u),o.addEventListener("dragend",u),()=>{o.removeEventListener("dragenter",u),o.removeEventListener("dragover",u),o.removeEventListener("dragleave",u),o.removeEventListener("drop",u),o.removeEventListener("dragend",u)}},[o,d]),(0,a.jsxs)("div",{ref:n,children:[s&&(0,a.jsx)("div",{ref:i,className:"iframe-provider"}),e]})}var Fd=["colorBgBase","colorBgElevated","colorError","colorInfo","colorInfoBg","colorInfoBgHover","colorInfoBorder","colorInfoBorderHover","colorLink","colorPrimary","colorPrimaryBg","colorPrimaryBgHover","colorPrimaryBorder","colorPrimaryBorderHover"];function Bd(e){const t={};for(const n of Fd){const o=e[n];typeof o=="string"&&(t[n]=o)}return t}function Jr(e,t){const n=r.useMessageService(),o=t?.async??!1;(0,l.useEffect)(()=>{const i=o?n.addListenerAsync(r.EVENT_TYPES.RELOAD,e):n.addListener(r.EVENT_TYPES.RELOAD,e);return()=>i.dispose()},[n,e,o]),(0,l.useEffect)(()=>{},[e])}function $d(){const e=r.useMessageService(),{token:t}=(0,_.ui_kit$useToken)(),[n,o]=(0,l.useState)();(0,l.useEffect)(()=>{if(!g.deepEqual(n,t)){const s=e.onInit(()=>{e.send(r.EVENT_TYPES.SANDBOX_SET_THEME_VARIABLES,Bd(t)),o(t)});return()=>s.dispose()}},[t,n,o,e]);const i=(0,l.useCallback)(()=>{o(void 0)},[]);Jr(i)}var Ud={minHeight:600},zd="#pane-content-wrapper, .email-pane__col_preview, .preview-mode__pane-content";function Fi(e){e?.current?.resize?.()}var Bi=(0,l.forwardRef)(({className:e=null,email:t=null,handlerSendPosition:n=()=>{},surface:o,clip:i=null},s)=>{const c=r.useAppConfig(),d=r.useContainer(),u=o??(t?.hasOwnProperty("type")?"block":"email"),p=(0,l.useMemo)(()=>Id(d),[d]),f=(0,l.useMemo)(()=>p?.current(u),[p,u]),h=(0,l.useRef)(null),y=(0,l.useCallback)(()=>{r.mark(r.PHASES.canvasLoaded),Fi(s),n()},[n,s]);(0,l.useImperativeHandle)(s,()=>({getIframeElement:()=>p?.current(u)?.element,resize:()=>p?.current(u)?.resize()}),[p,u]),(0,l.useEffect)(()=>{if(!p)return;const w=h.current,S=i??w?.closest(zd)??null;return p.alignSurface(u,w,S),()=>p.alignSurface(u,null)},[p,u,i,c.sidePanelFloating]);const m=(0,l.useRef)(y);m.current=y,(0,l.useEffect)(()=>{if(!f)return;let w=!1;const S=()=>{w||m.current({target:f.element})};return f.ready().then(S).catch(()=>{window.requestAnimationFrame(()=>{w||f.ready().then(S).catch(()=>{})})}),()=>{w=!0}},[f]),$d(),Ld(t);const{document:E}=r.useDocumentSessionContext();(0,l.useEffect)(()=>{const w=r.subscribeToContent(E,()=>{Fi(s)});return()=>w.dispose()},[E,s]);const T=(0,l.useCallback)(w=>{const{operation:S,settings:I}=w.data;S===r.EVENT_TYPES.APPLICATION_COMMON_STYLES_UPDATE&&Md(E,I?.commonStyles)},[E]);return r.useListenPostMessage(T),(0,a.jsx)(Dd,{children:(0,a.jsx)("div",{ref:h,className:(0,rt.default)("email-preview",e),id:"email_iframe_slot",style:Ud})})});Bi.propTypes={className:Ue.default.string,surface:Ue.default.oneOf(["email","block","preview"]),email:Ue.default.shape({html:Ue.default.string}),handlerSendPosition:Ue.default.func,clip:Ue.default.object};var Zr=new Map,Gd=new Map;function Wd(e,t){e.set(t,(e.get(t)??0)+1)}function Hd(e,t){const n=e.get(t)??0;n<=1?e.delete(t):e.set(t,n-1)}function $i(e,t){return(e.get(t)??0)>0}function qd(e){return $i(Zr,e)||$i(Gd,e)}function Vd(e){Wd(Zr,e);let t=!1;return{dispose(){t||(t=!0,Kd(e))}}}function Kd(e){Hd(Zr,e)}function Yd(e,t){return Xd([...e.changes].sort((n,o)=>n.rangeOffset-o.rangeOffset).map(n=>({start:n.rangeOffset,end:n.rangeOffset+n.rangeLength,text:n.text})),t)}function Qd(e,t){return e.map(n=>{const o=t.getPositionAt(n.oldPosition),i=t.getPositionAt(n.oldEnd);return{text:n.newText,range:{startLineNumber:o.lineNumber,startColumn:o.column,endLineNumber:i.lineNumber,endColumn:i.column}}})}function Xd(e,t){let n=0;return e.map(({start:o,end:i,text:s})=>{const c=new r.TextChange(o,t.slice(o,i),o+n,s);return n+=s.length-(i-o),c})}var Ui=new WeakMap;function Jd(e){const t=Ui.get(e);if(t)return t;const n=Ml(e);return Ui.set(e,n),n}var zi="monaco";function Zd(e,t){(0,l.useEffect)(()=>{if(!e||!t)return;const n=Jd(e);let o=!1;const i=d=>{o=!0;const u=Vd(t);try{d()}finally{u.dispose(),o=!1}},s=n.attach({id:zi,apply(d){return t.getValue()!==d&&i(()=>t.setValue(d)),Promise.resolve()},applyChanges(d){return i(()=>t.applyEdits(Qd(d,t))),Promise.resolve()}}),c=t.onDidChangeContent(d=>{if(o)return;const u=qd(t)?"remote":"user";n.mutateFrom(zi,{changes:Yd(d,e.getContent())},{source:u})});return()=>{s.detach(),c.dispose()}},[e,t])}function eu(e,t){const[n,o]=(0,l.useState)(void 0),i=(0,l.useRef)(!1),{error:s}=r.useNotification(),{__:c}=r.useI18n(),d=(0,l.useRef)(t);d.current=t;const u=(0,l.useRef)({error:s,__:c});u.current={error:s,__:c},(0,l.useEffect)(()=>{if(!e||n||i.current)return;i.current=!0;let f=!1;return d.current().then(h=>{if(f){h.dispose();return}o(h)}).catch(()=>{const{error:h,__:y}=u.current;h({id:"CODE_EDITOR_LOAD_FAILED",title:y("Failed to load the code editor")})}).finally(()=>{i.current=!1}),()=>{f=!0}},[e,n]);const p=(0,l.useRef)(void 0);return p.current=n,(0,l.useEffect)(()=>()=>{p.current?.dispose()},[]),n}var Hn;function eo(){return Hn===void 0&&(Hn=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/51a46897.js")),void 0,{}.url).catch(e=>{throw Hn=void 0,e})),Hn}function tu(){return eo().then(e=>e.ensureMonaco())}var nu=r.lazyRoute(()=>eo().then(e=>({default:e.MonacoEditor}))),ru=()=>eo().then(e=>e.loadEditorModel()),ou={height:"100%"};function iu(e){const t=eu(!0,ru),{document:n}=r.useDocumentSessionContext();return(0,l.useEffect)(()=>{},[]),(0,l.useEffect)(()=>{},[t]),Zd(n,t),(0,a.jsx)(r.EditorModelContext.Provider,{value:t,children:(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$Flex,{justify:"center",align:"center",style:ou,children:(0,a.jsx)(_.ui_kit$Spin,{size:"large"})}),children:(0,a.jsx)(nu,{...e})})})}var su=({elementPath:e})=>{const{_x:t}=r.useI18n(),n=r.useDispatch(),o=r.useMessageService(),i=r.useAppConfig(),{blockId:s}=r.useRouteParams(),c=r.useEditorProjectId(),d=r.useRouteEmailId(),u=r.useProjectData(),p=r.usePushToDataLayer(),f=(0,l.useCallback)(I=>{o.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_SET,index:I})},[o]),h=(0,l.useCallback)(I=>{let x="element";I?.target?.closest("svg")||I?.target?.closest(".anticon")||I?.target?.closest('[class*="icon"]')?x="icon":I?.target?.textContent&&!I?.target?.closest("svg")&&!I?.target?.closest(".anticon")&&(x="text"),n(r.setActiveSettingsTab(r.STYLES)),o.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1}),o.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),p({event:"click",action:"click_breadcrumb_email",email_id:d||s,project_id:u?.id||c,click_target:x})},[o,n,p,d,s,c,u]),y={title:(0,a.jsxs)("span",{onClick:h,children:[(0,a.jsx)(r.EmIcons,{icon:"Email",component:_.icons$Email,size:16,strokeWidth:i.iconStrokeWidth})," ",t("Email","letter")]})},[m,E]=(0,l.useState)([y]),T=(0,l.useCallback)(I=>{o.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_HOVER_SET,index:I})},[o]),w=I=>{if(I.includes("em-element-path-item-text"))return(0,a.jsx)(r.EmIcons,{icon:"ElementText",component:_.icons$ElementText,size:16,strokeWidth:i.iconStrokeWidth});if(I.includes("em-element-path-item-image"))return(0,a.jsx)(r.EmIcons,{icon:"ElementImage",component:_.icons$ElementImage,size:16,strokeWidth:i.iconStrokeWidth});if(I.includes("em-element-path-item-link"))return(0,a.jsx)(r.EmIcons,{icon:"LinkOutlined",component:_.icons$LinkOutlined,size:16,strokeWidth:i.iconStrokeWidth});if(I.includes("em-element-path-item-atom"))return(0,a.jsx)(r.EmIcons,{icon:"Atom",component:_.icons$Atom,size:16,strokeWidth:i.iconStrokeWidth});if(I.includes("em-element-path-item-column"))return(0,a.jsx)(r.EmIcons,{icon:"Column",component:_.icons$Column,size:16,strokeWidth:i.iconStrokeWidth});if(I.includes("em-element-path-item-block"))return(0,a.jsx)(r.EmIcons,{icon:"Block",component:_.icons$Block,size:16,strokeWidth:i.iconStrokeWidth});if(I.includes("em-element-path-item-group"))return(0,a.jsx)(r.EmIcons,{icon:"Group",component:_.icons$Group,size:16,strokeWidth:i.iconStrokeWidth});if(I.includes("em-element-path-item-button"))return(0,a.jsx)(r.EmIcons,{icon:"ElementButton",component:_.icons$ElementButton,size:16,strokeWidth:i.iconStrokeWidth});if(I.includes("em-element-path-item-table"))return(0,a.jsx)(r.EmIcons,{icon:"ElementTable",component:_.icons$ElementTable,size:16,strokeWidth:i.iconStrokeWidth});if(I.includes("em-element-path-item-amp"))return(0,a.jsx)(r.EmIcons,{icon:"AMP",component:_.icons$AMP,size:16,strokeWidth:i.iconStrokeWidth})},S=(0,l.useCallback)((I,x)=>{const K=Z=>{let M="element";Z.target.closest("svg")||Z.target.closest(".anticon")||Z.target.closest('[class*="icon"]')?M="icon":Z.target.textContent&&!Z.target.closest("svg")&&!Z.target.closest(".anticon")&&(M="text");const j=e?.[x],A=j?.className?.replace("em-element-path-item-","")||"unknown";p({event:"click",action:"click_breadcrumb_element",email_id:d||s,project_id:u?.id||c,element_type:A,element_index:x,element_title:j?.title||"",click_target:M}),f(x)};return(0,a.jsxs)("span",{className:I.className,onClick:K,onMouseOver:()=>{T(x)},children:[w(I.className)," ",I.title]})},[f,T,e,p,d,s,c,u]);return(0,l.useEffect)(()=>{if(e){const I=e.map((x,K)=>({title:S(x,K)}));E([{title:(0,a.jsxs)("span",{onClick:h,children:[(0,a.jsx)(r.EmIcons,{icon:"Email",component:_.icons$Email,size:16,strokeWidth:i.iconStrokeWidth})," ",t("Email","letter")]})},...I])}},[e,S,h,t]),(0,a.jsx)(a.Fragment,{children:(0,a.jsx)(_.ui_kit$Breadcrumb,{items:m,type:"separator",separator:""})})};function au(){const{document:e}=r.useDocumentSessionContext(),t=(0,l.useCallback)(o=>e?e.subscribe(o):()=>{},[e]),n=(0,l.useCallback)(()=>e?.getContent()??"",[e]);return(0,l.useSyncExternalStore)(t,n)}var lu=({fallbackHtml:e})=>{const{__:t}=r.useI18n(),n=au(),o=(0,l.useMemo)(()=>r.getCodeSize(n||e||""),[e,n]),i=r.formatCodeSize(o),s=r.isCodeSizeExceeded(o);return(0,a.jsx)(_.ui_kit$Tooltip,{placement:"left",title:t(s?"The code size exceeds the recommended value 90kB":"Code size"),children:(0,a.jsx)("span",{className:(0,rt.default)("email-pane__code-size",{"email-pane__code-size_exceeded":s}),children:i})})};function Gi(e){const{limits:t,isLoaded:n}=r.useProjectPlanLimits();return r.useProjectData(),(0,l.useMemo)(()=>({isLocked:!1,state:{state:"allowed"},isPlanDataReady:n,exceeded:null}),[!1,e,t,n])}var cu=({open:e,onClose:t})=>{const{__:n}=r.useI18n();return(0,a.jsxs)(_.ui_kit$Modal,{open:e,centered:!0,closable:!1,mask:{closable:!1},footer:null,width:520,className:"browser-extension-warning-modal",title:n("Browser extension detected"),onCancel:t,children:[(0,a.jsx)("p",{children:n("A browser extension (for example, Urban VPN Proxy or similar ad blockers/VPN tools) is injecting code into the email preview. This can corrupt your template when saving.")}),(0,a.jsx)("p",{children:n("We removed the injected code automatically. To avoid this issue, disable the extension for this site or use the editor in an incognito window without extensions.")}),(0,a.jsx)("div",{className:"browser-extension-warning-modal__footer",children:(0,a.jsxs)(_.ui_kit$Button,{type:"primary",onClick:t,children:[n("Got it")," "]})})]})},du={closable:!1},uu=({open:e,onClose:t})=>{const{__:n}=r.useI18n();return(0,a.jsxs)(_.ui_kit$Modal,{open:e,centered:!0,closable:!1,mask:du,footer:null,width:520,className:"browser-translate-warning-modal",title:n("Browser translation detected"),children:[(0,a.jsx)("p",{children:n("Browser page translation (for example, Google Translate) is active. It can break the editor and cause errors when saving.")}),(0,a.jsx)("p",{children:n("To avoid this issue, disable translation for this site in your browser settings or turn off auto-translate.")}),(0,a.jsx)("div",{className:"browser-translate-warning-modal__footer",children:(0,a.jsx)(_.ui_kit$Button,{type:"primary",onClick:t,children:n("Got it")})})]})},pu=g.createIdentifier$1("prewarm.editorVisible");function mu(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function fu(e={}){const t=e.paint??mu;let n=!1,o=!1,i=!1,s=!1,c=!1;const d=[],u=()=>{c||s||!n||!o||!i||(s=!0,t(()=>{c=!0,r.mark(r.PHASES.editorVisible);for(const p of d.splice(0))p()}))};return{noteShellVisible(){n=!0,u()},notePagePainted(){o=!0,u()},noteContentShown(){i=!0,u()},whenVisible(p){if(c){p();return}d.push(p)},contentShown:()=>i}}function Ht(e){return e.getOrCreateInstance(pu,()=>fu())}function kn(e){const t=(0,l.useRef)(!1);return e&&(t.current=!0),t.current}var Wi=4e3;function Xt(e){const t=window.requestIdleCallback;if(typeof t=="function"){t(e,{timeout:Wi});return}window.setTimeout(e,Wi)}var qn,to;function no(){return qn===void 0&&(qn=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/53bcd609.js")).then(e=>e.panels_exports).then(e=>(to=e,e),e=>{throw qn=void 0,e}),void 0,{}.url)),qn}function gu(e){(0,l.useEffect)(()=>{Ht(e).whenVisible(()=>{Xt(()=>{no().catch(()=>{})})})},[e])}function ut(e){const t=r.lazyRoute(()=>no().then(o=>({default:o[e]})),"panels");function n(o){const[i]=(0,l.useState)(()=>to?to[e]:t);return(0,l.createElement)(i,o)}return n.displayName=`PanelDoor(${String(e)})`,n}var Hi=ut("EmailProperties"),hu=ut("SelectedElementPanel"),_u=ut("EmailSettings"),yu=ut("EmailStyles"),vu=ut("DiscussAi"),bu=ut("Optimise"),Eu=ut("FileManagerDataLayer"),Su=ut("BlocksSearch"),wu=ut("Discuss"),ku=ut("HistoryPanel"),Tu=ut("AddNewBlockModal"),Cu=ut("AddAllBlocksModal"),Iu=ut("SendTestEmailModal"),Au=ut("SaveBlockBtn"),ro=ut("LimitUpgradeModal"),xu={height:"100%"},Pu=()=>{const e=r.useContainer(),t=r.isImageCenterModal(r.useSelector(r.selectActiveModal$1)),[n,o]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{e&&Ht(e).whenVisible(()=>o(!0))},[e]),kn(n||t)?(0,a.jsx)(l.Suspense,{fallback:t?(0,a.jsx)(_.ui_kit$PageLoader,{style:xu}):null,children:(0,a.jsx)(Eu,{})}):null},Vn;function Ru(){return Vn===void 0&&(Vn=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/9281699f.js")),void 0,{}.url).catch(e=>{throw Vn=void 0,e})),Vn}function Tn(e){return r.lazyRoute(()=>Ru().then(t=>({default:t[e]})),"form-panels")}var Hv=Tn("FormEditorCalendarPanel"),qv=Tn("FormEditorCheckboxPanel"),Vv=Tn("FormEditorDropdownListPanel"),Kv=Tn("FormEditorInputPanel"),Yv=Tn("FormEditorRadioPanel");function Ou(){try{const e=new URLSearchParams(window.location.search).get("deferChrome");return e===null?void 0:e!=="0"&&e!=="false"}catch{return}}function ju(e,t){const n=Ou()??r.readLocalToggle(r.LOCAL_STORAGE_ITEMS.em_defer_chrome);if(n!==void 0)return n;const o=t?.deferEditorChrome;return typeof o=="boolean"?o:o&&typeof o=="object"?o[e]??!0:{}.REACT_APP_DEFER_EDITOR_CHROME_DEFAULT!=="false"}function qi(e){const t=r.useAppConfig(),[n,o]=(0,l.useState)(()=>!ju(e,t));return(0,l.useEffect)(()=>{if(n)return;let i=0;const s=window.requestAnimationFrame(()=>{i=window.requestAnimationFrame(()=>(0,l.startTransition)(()=>o(!0)))});return()=>{window.cancelAnimationFrame(s),window.cancelAnimationFrame(i)}},[n]),n}var Vi=r.createState({blocksTotal:null,blocksTotalPages:null,parentEmailBlocksTotal:null,parentEmailBlocksTotalPages:null,templateBlocks:[],templateBlocksTotal:null,templateBlocksTotalPages:null,elementsView:r.CARDS,elementsList:[],customFolders:{},blocksTrashTotal:0,elementsTrashList:[]}),Kn="blocksPageSlice",oo=r.createSlice({name:Kn,initialState:Vi,reducers:{resetPagesAndTotal:()=>Vi,resetElementsList:e=>{e.elementsList=[]},toggleElementsView:(e,t)=>{e.elementsView=t.payload},removeBlockFromList:(e,{payload:t})=>{const n=e.customFolders;t.folder!=="all"&&n[t.folder]?.list&&(n[t.folder]={...n[t.folder],list:n[t.folder].list.filter(o=>o.id!==t.emailId),total:n[t.folder].total-1},e.customFolders=n)}},extraReducers:e=>{e.addMatcher(r.blocksApi.endpoints.getBlocks.matchFulfilled,(t,{meta:n,payload:o})=>{const i=n.baseQueryMeta?.response.headers.get("X-WP-Total")||o?.length,s=n.arg.originalArgs?.status==="trash",c=!!n.arg.originalArgs?.name?.length,d=n.arg.originalArgs?.page,u=n.arg.originalArgs?.folderTag||n.arg.originalArgs?.tags?.[0];s?(c||(t.blocksTrashTotal=i),t.elementsTrashList=o):u?t.customFolders={...t.customFolders,[u]:{list:o,page:d,total:i}}:(t.blocksTotal=i,t.elementsList=o)}),e.addMatcher(r.blocksApi.endpoints.getParentEmailBlocks.matchFulfilled,(t,{meta:n,payload:o})=>{const i=n.baseQueryMeta?.response.headers.get("X-WP-Total")||o?.length||null,s=n.baseQueryMeta?.response.headers.get("X-WP-TotalPages");t.parentEmailBlocksTotal=i,t.parentEmailBlocksTotalPages=s}),e.addMatcher(r.blocksApi.endpoints.getTemplateBlocks.matchFulfilled,(t,{meta:n,payload:o})=>{const i=n.baseQueryMeta?.response.headers.get("X-WP-Total")||o?.length||null,s=n.baseQueryMeta?.response.headers.get("X-WP-TotalPages");t.templateBlocks=o,t.templateBlocksTotal=i,t.templateBlocksTotalPages=s}),e.addMatcher(r.blocksApi.endpoints.editBlock.matchFulfilled,(t,{payload:n})=>{t.elementsList.map(o=>o.id?.toString()===n.id?.toString()?Object.assign(o,{lock:n.lock,title:n.title,blocktags:n.blocktags}):o)})}}),{resetPagesAndTotal:Qv,resetElementsList:Xv,toggleElementsView:Jv,removeBlockFromList:Zv}=oo.actions,Lu=e=>e[Kn].blocksTotal,Mu=e=>e[Kn].templateBlocksTotal,Nu=e=>e[Kn].parentEmailBlocksTotal,Du=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 Ki(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 Yi(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(g.throwIfAborted(n),new Promise((o,i)=>{let s=!1,c,d;const u=f=>{s||(s=!0,c!==void 0&&(clearTimeout(c),c=void 0),d?.dispose(),n?.removeEventListener("abort",p),f())},p=()=>{u(()=>i(g.createAbortError(n?.reason)))};if(d=e.onInit(()=>{e.isInited()&&e.getTarget()&&u(()=>o())}),e.isInited()&&e.getTarget()){u(()=>o());return}t>0&&(c=setTimeout(()=>{u(()=>i(new Du(t)))},t)),n?.addEventListener("abort",p)}))}var Fu=()=>{try{return localStorage.getItem("em-debug-project-fonts")==="1"}catch{return!1}},Cn=(e,t)=>{Fu()},Bu=e=>[...e].sort((t,n)=>t.order-n.order).map(t=>t.hex.toUpperCase()),$u=(e,t)=>{const n=Array.isArray(e?.usedColors)?e.usedColors:[],o=new Set,i=[];for(const s of[...n,...Bu(t)]){const c=String(s??"").trim().toUpperCase();!c||o.has(c)||(o.add(c),i.push(s))}return{...e,usedColors:i}},Qi,Uu=e=>{Qi=e},Yn=e=>$u(e,Qi?.colors??[]),zu=e=>{const t=r.useMessageService(),n=Oi(e),[o,i]=(0,l.useState)("");(0,l.useEffect)(()=>{Uu(n);const c=n?.fonts??[];r.setCachedProjectFonts(c),ed(c),Cn("parent: cache + host @font-face synced",{projectId:e,fontsCount:c.length,families:c.map(d=>d.family?.trim()||d.name)})},[n,e]),(0,l.useEffect)(()=>{const c=n?.fonts??[],d=Vc(c),u=JSON.stringify(d);if(u===o){Cn("parent: iframe send skipped (unchanged)",{entriesCount:d.length});return}Cn("parent: scheduling SANDBOX_SET_PROJECT_FONTS",{entriesCount:d.length,entries:d});const p=()=>{t.send(r.EVENT_TYPES.SANDBOX_SET_PROJECT_FONTS,d),i(u),Cn("parent: SANDBOX_SET_PROJECT_FONTS sent",{entriesCount:d.length})};if(t.inited){p();return}const f=t.onInit(()=>{p()});return()=>f.dispose()},[t,n,o]);const s=(0,l.useCallback)(()=>{Cn("parent: iframe reload — will resend project fonts map"),i("")},[]);Jr(s)};function Gu(e,t){const n=e,o=n?.data?.operation!==void 0?n.data:n;if(o?.operation===t)return o.file instanceof File?o.file:void 0}async function Wu(e,t){const{userId:n,folderId:o}=t.readContext();if(n==null||o==null||o==="")return{status:"skipped"};try{const i=await t.prepare(e),s=await t.upload({user_id:n,folder:String(o),file:i});if(s.error)return{status:"failed",error:s.error};const{extractUploadResult:c}=await(0,Ke.__vitePreload)(async()=>{const{extractUploadResult:u}=await Promise.resolve().then(()=>ve("./static/core/41a7e33c.js")).then(p=>p.import_exports);return{extractUploadResult:u}},void 0,{}.url),d=c(s.data);return d.error||!d.file_url?{status:"skipped"}:{status:"uploaded",url:d.file_url}}catch(i){return{status:"failed",error:i}}}function Hu(){const[e,t]=(0,l.useState)(!1),n=r.useHeadless(),o=r.useEventEmitter(g.events.ON_BROWSER_EXTENSION_DETECTED_ID),i=(0,l.useCallback)(()=>{t(!1)},[]);return(0,l.useEffect)(()=>{const s=o.event(()=>{n||t(!0)});return()=>s.dispose()},[o,n]),{open:e,close:i}}function qu(){const[e,t]=(0,l.useState)(!1),n=r.useHeadless(),o=r.useEventEmitter(g.events.ON_BROWSER_TRANSLATE_DETECTED_ID),i=(0,l.useCallback)(()=>{t(!1)},[]);return(0,l.useEffect)(()=>{const s=o.event(()=>{n||t(!0)});return()=>s.dispose()},[o,n]),{open:e,close:i}}var Vu=["translated-ltr","translated-rtl"],Ku=".goog-te-banner-frame",io=!1;function Yu(e){if(e)return e;if(!(typeof document>"u"))return document}function Qu(e){const t=Yu(e);if(!t?.documentElement)return!1;const n=t.documentElement.classList;return Vu.some(o=>n.contains(o))?!0:t.querySelector(Ku)!=null}function Xu(){io=!1}function Ju(e){const t=Qu();return t&&!io&&e(),io=t,t}var Zu=500;function ep(){const e=r.useEventEmitter(g.events.ON_BROWSER_TRANSLATE_DETECTED_ID),t=(0,l.useRef)(null);(0,l.useEffect)(()=>{if(typeof window>"u")return;const n=()=>{Ju(()=>{e.fire()})},o=()=>{t.current!=null&&clearTimeout(t.current),t.current=setTimeout(()=>{t.current=null,n()},Zu)};n();const i=()=>{o()},s=()=>{document.visibilityState==="visible"&&o()},c=new MutationObserver(()=>{o()});return c.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),window.addEventListener("focus",i),document.addEventListener("visibilitychange",s),()=>{t.current!=null&&clearTimeout(t.current),Xu(),c.disconnect(),window.removeEventListener("focus",i),document.removeEventListener("visibilitychange",s)}},[e])}var so={},Xi=(0,l.createContext)(so),Ji=(0,l.createContext)({current:so}),Zi=(0,l.createContext)(()=>{});function tp({children:e}){const t=r.useDispatch(),n=r.useSelector(r.selectActiveSettingsTab),o=r.useEvent(g.SETTINGS_PANEL_EVENT),[i,s]=(0,l.useState)(so),c=(0,l.useRef)(i);return c.current=i,(0,l.useEffect)(()=>{const d=o(u=>{const p=u?.type===g.ADVANCED_SETTINGS_PANEL;if((!u||!u.type&&!u.content&&!u.advancedTabs?.length)&&n==="Properties")s({}),t(r.resetToLastActiveSettingsTab());else if(n!=="Properties"&&t(r.setActiveSettingsTab(r.PROPERTIES)),u.advancedTabs?.length&&!p&&!u.content){const f=u.advancedTabs.map(h=>({content:h.content,label:h.label,key:h.key,className:h.className}));s(h=>({settings:{},extraTabs:f}))}else if(p&&u.content){const f=u.advancedTabs?.map(h=>({content:h.content,label:h.label,key:h.key,className:h.className}));s(h=>({settings:{},type:u.type,content:u.content,instanceKey:u.instanceKey,parent:u.parent,caption:u.caption,extraTabs:f,deletable:u.deletable}))}});return()=>d.dispose()},[o,s,t,n]),(0,a.jsx)(Zi.Provider,{value:s,children:(0,a.jsx)(Ji.Provider,{value:c,children:(0,a.jsx)(Xi.Provider,{value:i,children:e})})})}function ao(){return(0,l.useContext)(Xi)}function np(){return(0,l.useContext)(Ji)}function rp(){return(0,l.useContext)(Zi)}var es={widthCodeSplit:50,isResizing:!1,currentSide:null},ts=(0,l.createContext)({current:es}),ns=(0,l.createContext)(es.widthCodeSplit),rs=(0,l.createContext)({isResizing:!1,currentSide:null}),os=(0,l.createContext)({setWidthCodeSplit:()=>{},setIsResizing:()=>{},setCurrentSide:()=>{},setBlockMaxHeight:()=>{}}),is=(0,l.createContext)("unset");function op({children:e}){const[t,n]=(0,l.useState)(()=>+window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_code_mode_pane_sizes)||50),[o,i]=(0,l.useState)(!1),[s,c]=(0,l.useState)(null),[d,u]=(0,l.useState)("unset"),p=(0,l.useMemo)(()=>({widthCodeSplit:t,isResizing:o,currentSide:s}),[t,o,s]),f=(0,l.useMemo)(()=>({isResizing:o,currentSide:s}),[o,s]),h=(0,l.useRef)(p);h.current=p;const y=(0,l.useMemo)(()=>({setWidthCodeSplit:n,setIsResizing:i,setCurrentSide:c,setBlockMaxHeight:u}),[]);return(0,a.jsx)(os.Provider,{value:y,children:(0,a.jsx)(ts.Provider,{value:h,children:(0,a.jsx)(rs.Provider,{value:f,children:(0,a.jsx)(ns.Provider,{value:t,children:(0,a.jsx)(is.Provider,{value:d,children:e})})})})})}function ss(){return(0,l.useContext)(rs)}function as(){return(0,l.useContext)(ns)}function ip(){return(0,l.useContext)(ts)}function sp(){return(0,l.useContext)(is)}function ap(){return(0,l.useContext)(os)}var ls=(0,l.createContext)({previewAlertShow:!1,templateNotEmAlertShow:!1}),cs=(0,l.createContext)({setPreviewAlertShow:()=>{},setTemplateNotEmAlertShow:()=>{}});function lp({children:e}){const[t,n]=(0,l.useState)(!1),[o,i]=(0,l.useState)(!1),s=(0,l.useMemo)(()=>({previewAlertShow:t,templateNotEmAlertShow:o}),[t,o]),c=(0,l.useMemo)(()=>({setPreviewAlertShow:n,setTemplateNotEmAlertShow:i}),[]);return(0,a.jsx)(cs.Provider,{value:c,children:(0,a.jsx)(ls.Provider,{value:s,children:e})})}function cp(){return(0,l.useContext)(ls)}function dp(){return(0,l.useContext)(cs)}function up({className:e,sidePanelFloating:t,isCodeMode:n,codeModeDirection:o,children:i}){const s=sp(),c=(0,l.useMemo)(()=>{const d=Number.isFinite(s)?`${s}px`:"unset";return{"--ub-em-pane-block-height":t?n&&o==="bottom"?d:"calc(100% - 30px)":"100%"}},[t,n,o,s]);return(0,a.jsx)(_.ui_kit$Layout,{className:e,style:c,children:i})}function pp(){const[e,t]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{let n=0;const o=window.requestAnimationFrame(()=>{n=window.requestAnimationFrame(()=>t(!0))});return()=>{window.cancelAnimationFrame(o),window.cancelAnimationFrame(n)}},[]),e}function mp({maxPaneWidth:e,isCodeMode:t,codeModeDirection:n,isShowMobileSettings:o,desktopMobileSwitchPanel:i,children:s}){const c=r.useSelector(r.selectEmailWidth),{isResizing:d,currentSide:u}=ss(),p=t&&n!=="bottom"&&!o&&i?"100%":c,f=pp(),h=(0,l.useMemo)(()=>({maxWidth:typeof p=="number"?Math.min(p,e):e,...f?{}:{transition:"none"}}),[p,e,f]);return(0,a.jsx)("div",{className:(0,rt.default)("email-pane__resizable",{"email-pane__resizable_drag":u||d}),style:h,children:s})}function fp({isCodeMode:e,codeModeDirection:t,sidePanelFloating:n,contentWrapperRef:o,children:i}){const s=as(),c=(0,l.useMemo)(()=>({flexGrow:1,overflowY:n?"scroll":"hidden",overflowX:"hidden",height:e&&t==="bottom"?`calc(${s}%)`:"100%",width:`${t==="left"?100-s:t==="bottom"?100:s}%`}),[e,t,n,s]);return(0,a.jsx)(_.ui_kit$Col,{style:c,id:"pane-content-wrapper",ref:o,children:i})}function gp({isCodeMode:e,codeModeDirection:t,children:n}){const o=as(),i=(0,l.useMemo)(()=>({width:`${t==="right"?100-o:t==="bottom"?100:o}%`,position:"relative",height:t==="bottom"?`calc(${100-o}%)`:"unset",display:e?"initial":"none"}),[e,t,o]);return(0,a.jsx)(_.ui_kit$Col,{style:i,children:n})}function hp({wrapperRef:e,children:t}){const{isResizing:n,currentSide:o}=ss();return(0,a.jsx)("div",{className:(0,rt.default)("email-pane__content-col email-pane__content-col_main",{"email-pane__content-col_disable":o||n}),ref:e,children:t})}function _p({isShowMobileSettings:e,headless:t,templateNotEmAlertEnabled:n}){const{__:o}=r.useI18n(),{previewAlertShow:i,templateNotEmAlertShow:s}=cp();return(0,a.jsxs)(a.Fragment,{children:[i&&e&&(0,a.jsx)(_.ui_kit$Alert,{title:o("Template is not mobile-friendly"),description:o("While editing, some elements of the email no longer fit the screen of the mobile device. Check that these elements are set to a smaller width for mobile devices."),type:"warning",className:"email-pane__col__alert",closable:!0}),s&&!t&&n&&(0,a.jsx)(_.ui_kit$Alert,{title:o("Template from another editor"),description:o("This template was created in another editor. Rebuild it from our components to get stable rendering, error-free editing, and full design control."),type:"warning",className:"email-pane__col__alert",closable:!0})]})}function ds(){const e=r.useElementEntityKind(),t=r.useSelector(r.selectElementSettings$1),n=r.useSelector(r.selectElementSettings);return e==="email"?t:n}function yp({isShowMobileSettings:e,propertiesPanelKey:t,onMouseLeave:n,email:o,onClosePanel:i}){const s=ds(),c=ao();return s?.type||c?.type||c?.content||c?.extraTabs?.length?(0,a.jsx)("div",{className:(0,rt.default)("email-pane__collapse-wrapper",{"mobile-view":e,"mobile-properties":e&&t!=="Structure"}),onMouseLeave:n,children:(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(Hi,{email:o,formSettings:c,onClosePanel:i})})}):null}function vp({className:e,emailElementType:t}){return(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(hu,{className:e,emailElementType:t,formSettings:ao()})})}function bp({isCodeMode:e,codeModeDirection:t}){const n=r.useElementEntityKind(),o=ds()?.type;return!(o===r.ELEMENT_TYPES.TEXT||o===r.ELEMENT_TYPES.LINK||o===r.ELEMENT_TYPES.IMG||o===r.ELEMENT_TYPES.BUTTON)||!e||t==="bottom"?null:(0,a.jsx)(vp,{className:(0,rt.default)("selected-element-panel__content selected-element-panel__content_abs",{"selected-element-panel__hidden":o===r.ELEMENT_TYPES.IMG}),emailElementType:n})}function Ep({isCodeMode:e,codeModeDirection:t,email:n,onClosePanel:o}){const i=ao();return i?.type!=="img"||!e||t==="bottom"?null:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper email-pane__collapse-wrapper_disabled",children:(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(Hi,{email:n,formSettings:i,onClosePanel:o})})})}var Sp="code",wp=(e,t)=>(0,a.jsx)(t,{className:"email-pane__tab-bar",...e}),{Content:kp}=_.ui_kit$Layout,Tp=()=>{no().catch(()=>{})},Jt=e=>(0,l.memo)(t=>(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(e,{...t})})),Cp=Jt(vu),Ip=Jt(yu),Ap=Jt(bu),xp=Jt(Su),Pp=(0,l.memo)(e=>(0,a.jsx)(iu,{...e})),Rp=(0,l.memo)((0,l.forwardRef)((e,t)=>(0,a.jsx)(Bi,{...e,ref:t}))),Op=(0,l.memo)(e=>(0,a.jsx)(ji,{...e})),jp=Jt(_u),Lp=Jt(ku),Mp=Jt(wu),us=({emailElement:e,isSuccess:t,setIsCollaborationEditor:n,isShowAddAllBlocksModal:o,triggerOpenSavedBlocksTab:i,setIsShowAddAllBlocksModal:s})=>{const{__:d,_x:u}=r.useI18n(),p=r.useMessageService(),{blockId:f}=r.useRouteParams(),h=r.useEditorProjectId(),y=r.useRouteEmailId(),m=r.useDispatch(),E=qr(),T=r.useOpenPlanCatalog(),{modal:w}=_.ui_kit$App.useApp(),S=r.useAppConfig(),I=r.useConfigSource(),x=r.useHeadless(),K=r.useContainer(),Z=qi("panel");gu(K),(0,l.useEffect)(()=>{Ht(K).notePagePainted()},[K]);const{token:M}=(0,_.ui_kit$useToken)(),j=r.useNotification(),A=r.usePushToDataLayer(),O=r.useProjectData(),z=vi(O?.id||h);zu(z);const B=r.useCookieManager(),U=r.useSelector(r.selectActiveSettingsTab),de=r.useCurrentUser(),me=r.toLanguageCode(r.useInterfaceLocale()),q=r.useStore(),ee=ip(),{setWidthCodeSplit:Fe,setIsResizing:be,setCurrentSide:et,setBlockMaxHeight:Ee}=ap(),fe=r.useSelector(r.selectActiveModal$1),Q=r.useSelector(r.selectIsCodeMode),pe=r.useSelector(r.selectCodeModeDirection),[se,ae]=(0,l.useState)(Q);(0,l.useEffect)(()=>{Q&&ae(!0)},[Q]);const Ie=r.useSelector(Lu),Te=r.useSelector(Mu),Be=r.useSelector(Nu),J=r.useSelector(r.selectPropertiesPanelKey),[_e]=r.useLazyClearAiChatQuery(),[Ce]=r.useUploadImageMutation(),ge=r.useSelector(r.selectEmailViewType)===r.MOBILE,[Oe,ze]=(0,l.useState)(r.LIGHT),[k,C]=(0,l.useState)(),[P,N]=(0,l.useState)(S.defaultBuildPanel||"empty"),[D,v]=(0,l.useState)("empty"),[W,Pe]=(0,l.useState)(!1),[Ae,Qe]=(0,l.useState)([]),[Ge,Ze]=(0,l.useState)([]),{setPreviewAlertShow:pt,setTemplateNotEmAlertShow:bt}=dp(),{open:ft,close:lt}=Hu(),{open:G,close:Y}=qu();ep();const ne=r.useRootElement(),ue=r.isEditorLockedByPlan(O,{isPlugin:!0}),he=r.usePlanFeatureGate("discussion"),We=r.usePlanFeatureGate("code_editor"),Ve=Gi("ai"),st=Ve.exceeded?r.getLimitUpgradePresetDefinition(Ve.exceeded.presetId):null,Bt=S?.configSwither||!1;(0,l.useEffect)(()=>{m(r.resetParentBlocks())},[m]),(0,l.useEffect)(()=>{const b=window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_active_tab);b&&m(r.setActiveSettingsTab(b))},[B,m]);const Me=y||f,Xe=e.hasOwnProperty("type")?r.BLOCK:r.EMAIL,ie=rp(),te=np(),$=(0,l.useRef)(null),le=(0,l.useRef)(null),xe=(0,l.useRef)(),Se=(0,l.useRef)(),Ne=(0,l.useRef)(null),He=(0,l.useRef)(),$e=(0,l.useRef)(),ot=(0,l.useRef)(null),fn=(0,l.useRef)(!1),jt=(0,l.useRef)(!1),ct=(0,l.useCallback)(()=>{jt.current=!1},[]),Et=(0,l.useCallback)(()=>{jt.current=!0},[]),Lt=(0,l.useCallback)(b=>{b?.type===r.ELEMENT_TYPES.SOCIAL&&Et()},[Et]),[On,jn]=(0,l.useState)(!1),[gn,Ln]=(0,l.useState)(!1),[Mn]=r.useEditMeMutation(),[gt,St]=(0,l.useState)(!1),[ce,we]=(0,l.useState)(0),[De,nt]=(0,l.useState)(!1),je=(0,l.useCallback)(()=>nt(!1),[]),Yt=(0,l.useCallback)(()=>{nt(!1),T()},[T]),[$t,dt]=(0,l.useState)(!1),Nn=S.configSwither?localStorage.getItem("configSwither")==="pro"?!0:localStorage.getItem("configSwither")==="editor"?!1:S.mode==="pro":!1,Ut=(0,l.useCallback)(()=>{clearTimeout(ot.current);const b=".blocks-search__result-holder";ne.querySelector(b)&&(Ie||Te||Be)&&(ne.querySelector(b).style.removeProperty("transition"),ne.querySelector(b).style.opacity=0,ot.current=setTimeout(()=>{r.measureBlockPreviews(ne,207/640),ne.querySelector(b)&&(ne.querySelector(b).style.transition="opacity 0.2s",ne.querySelectorAll(b).forEach(R=>R.style.opacity=1))},200))},[Te,Ie,Be]),Ct=(0,l.useRef)(void 0),It=(0,l.useCallback)(b=>{const R=b.target;R&&(window.clearTimeout(Ct.current),Ct.current=window.setTimeout(()=>{jn(!!R.closest(".desktop_view")),Ln(!!R.closest(".mobile_view"))},100))},[]);(0,l.useEffect)(()=>()=>{window.clearTimeout(Ct.current)},[]),(0,l.useEffect)(()=>{const b=r.addDocumentListenerFromShadow(ne,"mouseover",It);return()=>{b.dispose()}},[ne,It]),(0,l.useEffect)(()=>{typeof n=="function"&&(Ge.length>0?n(!0):n(!1))},[Ge]);const[Dr]=r.useSendMessageMutation(),{data:ht={},refetch:L,status:V}=r.useGetDialogQuery({entity_id:Me},{skip:!Me||S.aiAssistentEnabled===!1||ue}),X=r.useEventEmitter(g.events.AI_TEXT_REQUEST_ID).hasListeners(),oe=r.useIsStandalone(),re=!X&&!oe,H=(0,l.useMemo)(()=>re?[{data:{role:"assistant",message:d("Typing..."),isLoading:!0}}]:[],[re,d]),[ke,ye]=(0,l.useState)([]),[qe,hn]=(0,l.useState)(S.defaultBuildPanel!==""?r.BLOCKS:r.ATOMS),Dn=(0,l.useRef)(null),mt=(0,l.useCallback)(()=>{const b=Se.current?.getBoundingClientRect(),R=k?.getBoundingClientRect();p.send({operation:r.EVENT_TYPES.SANDBOX_WINDOW_CHARACTERISTIC,settings:{iframeOffsetTop:Q&&pe!=="bottom"?0:30,scrollTop:-b?.top+R?.top+30,innerHeight:window.innerHeight,previewHeight:R?.height,mode:Q&&pe!=="bottom"?Sp:"default"}})},[pe,Q,k,p]),Fr=t&&e,_n=(0,l.useCallback)(b=>{const R=window.navigator.platform.match("Mac");S.codeEnabled&&S.codeSideEnabled&&b.altKey&&b.keyCode===88&&(E.toggle(),We.isLocked&&(St(!0),we(r.FEATURE_UPSELL_SLIDE.code_editor))),((R?b.metaKey:b.ctrlKey)&&b.shiftKey&&b.keyCode===76||(R?b.metaKey:b.ctrlKey)&&b.shiftKey&&b.keyCode===69||(R?b.metaKey:b.ctrlKey)&&b.shiftKey&&b.keyCode===82)&&b.preventDefault()},[S.codeEnabled,We.isLocked,S.codeSideEnabled,E]),wt=fe.includes("UPLOAD_IMAGE_")||fe.includes("UPLOAD_BACKGROUND_"),yn=(0,l.useRef)(!1),_t=(0,l.useCallback)(b=>{const R=b.target,F=R.closest(".email-pane__content-col")||R.closest(".email-pane__collapse-wrapper")||R.closest(".selected-element-panel-content")||R.closest(".selected-element-panel")||R.closest(".em-analytics__email-tab-properties")||R.closest(".em-analytics__email-tab-styles")||R.closest(".em-analytics__email-tab-history")||R.closest(".blocks-modal-container")||R.closest(".email-pane__sizes")||R.closest(".email-preview-menu")||R.closest(".monaco-editor")||R.closest(".ant-modal-wrap");yn.current=!!F},[]),za=(0,l.useCallback)(b=>{const R=yn.current,F=window.getSelection().toString().length>0||document.activeElement&&document.activeElement.tagName==="INPUT"&&document.activeElement.selectionStart!==document.activeElement.selectionEnd;yn.current=!1,!(R||F)&&(!document.querySelector(".easylogic-colorpicker")&&!ne.querySelector(".easylogic-colorpicker")&&!b.target.closest(".email-pane__content-col")&&!b.target.closest(".blocks-modal-container")&&!b.target.closest(".email-pane__collapse-wrapper")&&!b.target.closest(".selected-element-panel__columns-settings__controls__column__remove")&&!b.target.closest(".email-preview__content-col_main")&&!b.target.closest(".email-preview-menu")&&!b.target.closest(".monaco-editor")&&!b.target.closest(".main__pane-close-btn")&&!b.target.closest(".main__pane-trigger")&&!b.target.closest(".ant-modal-wrap")&&!b.target.closest(".email-pane__sizes")&&!b.target.closest(".ant-input-clear-icon")&&!b.target.closest(".ant-color-picker")&&!b.target.closest(".control-font-family-dropdown")&&!Dn.current&&!b.target.closest(".email-preview-menu__history")&&!b.target.closest(".selected-element-panel-content")&&!b.target.closest(".ant-select-dropdown")&&!b.target.closest(".ant-picker-dropdown")&&!b.target.closest(".toggle_view")&&!b.target.closest(".upload-bg-image__menu")&&!b.target.closest(".email-pane__paths")&&!b.target.closest(".ant-tabs-extra-content")&&!b.target.closest(".anticon-delete")&&!wt&&fe!==r.MODALS.IMAGE_EDITOR_MODAL&&(U==="Properties"&&(Et(),m(r.resetToLastActiveSettingsTab()),p.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),Qe([])),U==="History"&&m(r.setActiveSettingsTab(r.BUILD)),m(r.switchIsPanelHistoryCollapsed(!0)),p.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1}),setTimeout(()=>{e.type?m(r.setElementSettings({type:null})):m(r.setElementSettings$1({type:null}))},300)),Dn.current=null)},[m,e.type,fe,U,p,wt]),[_v,Ga]=(0,l.useState)(!0),{data:qo=[],refetch:Br}=r.useGetCommentsQuery(Me,{skip:!Me||ue});(0,l.useEffect)(()=>{Me&&!ue&&Br()},[U,Me,ue,Br]),(0,l.useEffect)(()=>{Me&&!Object.keys(ht).length&&V==="fulfilled"&&L()},[U,Me,L,ht,V]),(0,l.useEffect)(()=>{const b=new g.Disposable,R=window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_active_tab);if(ht?.totalCount===0&&V!=="pending"){const Re={project_id:h,connection:"chat",entity_id:Me,context:"default",locale:me};!R&&re&&r.runOnceInFlight(`email-default-context:${Me}`,()=>{r.swallowPromiseRejection(Dr({body:Re}).then(()=>{b.isDisposed()||V==="fulfilled"&&L()}))})}const F={data:{role:"assistant",message:d("Typing..."),isLoading:!0}};return ht?.documents?.length>0?(window.localStorage.removeItem(r.LOCAL_STORAGE_ITEMS.em_active_tab),ye(ht?.documents),re&&ht?.documents[ht?.documents?.length-1].data?.userInfo&&ye([...ht?.documents,F])):R||ye(re?[F]:[]),()=>b.dispose()},[Me,me,ht?.totalCount,ht?.documents,re,h,L,Dr,V]),(0,l.useEffect)(()=>{ie({}),m(Xe==="email"?r.setElementSettings$1({}):r.setElementSettings({}))},[m,Xe]);const Wa=(0,l.useCallback)(b=>{m(r.setEmailSettings(Yn(b)))},[m]),Ha=(0,l.useCallback)(b=>{m(r.setBlockSettings(Yn(b)))},[m]),Fn=(0,l.useCallback)(b=>{m(Xe==="email"?r.setElementSettings$1(Yn(b)):r.setElementSettings(Yn(b)))},[m,Xe]);(0,l.useEffect)(()=>{const b=He.current,R=Ne.current;C(Q?R??b:b)},[Q,pe]);const[yv,vv]=(0,l.useState)(null),bv=(0,l.useCallback)(b=>{S.sidePanelFloating&&(Ne.current=b),vv(b)},[S.sidePanelFloating]),Bn=(0,l.useCallback)(b=>{N(b),b==="search"?Pe(!0):(Pe(!1),v(b)),setTimeout(Ut,50)},[Ut]),Ev=(0,l.useCallback)(b=>{const R=b.data.operation,F=b.data,Re=b.data.action;if(R==="application_block_inserted"||b.data.operationId==="application_block_inserted"){const Le=b.data.operationId?b.data.data:F||{},Nt=Le.type==="project"||Le.type==="template"||Le.type==="common"?"block":"structure",bn=Le.name||Le.type||(Nt==="block"?"block":"structure");A({event:"add",action:"add_element_to_email",element_type:Nt,element_name:bn,entity_id:e?.id||y||f,project_id:O?.id||h})}if(R===r.EVENT_TYPES.APPLICATION_SCROLL_TO&&setTimeout(()=>{Ne.current?.scrollTo({top:b.data.settings.value,behavior:"smooth"})},100),R===r.EVENT_TYPES.APPLICATION_PREVIEW_ALERT_SHOW&&pt(F.settings.show),R===r.EVENT_TYPES.APPLICATION_TEMPLATE_NOT_EM_ALERT_SHOW&&bt(!0),R===r.EVENT_TYPES.APPLICATION_ACTION&&Re==="toggle_editor"&&E.toggle(),R===r.EVENT_TYPES.APPLICATION_IFRAME_SET_HEIGHT&&(ne.querySelector(".email-pane__iframe").style.height=F.settings.height+"px"),R===r.EVENT_TYPES.APPLICATION_EMAIL_SETTINGS_SET){let Le=Object.assign({},F.settings);delete Le.preheader,Object.values(Le).every(Nt=>!Nt)?(m(r.setEmailSettingsDisable(!0)),m(r.resetToLastActiveSettingsTab())):Wa(F.settings),F.settings.noBlocks,m(r.setMobileViewActive(F.settings.responsive)),Ga(Le.structuresMedia)}if(R===r.EVENT_TYPES.APPLICATION_BLOCK_SETTINGS_SET&&(Object.values(F.settings).every(Le=>!Le)?(m(r.setBlockSettingsDisable(!0)),m(r.resetToLastActiveSettingsTab())):(Ha(F.settings),Ga(F.settings.structuresMedia))),R===r.EVENT_TYPES.APPLICATION_ELEMENT_SETTINGS_SET){const Le=Object.values(r.ELEMENT_TYPES).includes(F.type),Nt=te.current,bn=Nt?.type==="advanced"&&!!Nt.content,At=F.tab?!0:!Le&&!bn,{type:Mv,caption:Nv,settings:Dv}=F,el=JSON.stringify([Mv,Nv,Dv]),Fv=el!==$.current;if($.current=el,At&&U==="Properties"&&m(r.resetToLastActiveSettingsTab()),F.type===r.ELEMENT_TYPES.EMPTY_TABLE||F.type===r.ELEMENT_TYPES.EMPTY_TD?(m(r.setActiveSettingsTab(r.BUILD)),F.type===r.ELEMENT_TYPES.EMPTY_TABLE?(hn(r.BLOCKS),F.tab?Bn(F.tab):Bn("common")):F.type===r.ELEMENT_TYPES.EMPTY_TD&&hn(r.ATOMS)):F.type&&U!=="Properties"?F.type===r.ELEMENT_TYPES.SOCIAL&&jt.current?ct():(ct(),m(r.setActiveSettingsTab(r.PROPERTIES))):F.type!==r.ELEMENT_TYPES.SOCIAL&&ct(),!Fv)return;F.type===r.ELEMENT_TYPES.CAROUSEL||F.type===r.ELEMENT_TYPES.ACCORDION||F.type===r.ELEMENT_TYPES.SOCIAL?(ie(tn=>({settings:{...F.settings,type:At?null:F.type,caption:F.caption,parent:At?null:F.settings.parent},type:At?null:F.type,parent:At?null:F.settings.parent,caption:F.caption,extraTabs:tn.extraTabs})),Fn({})):(Fn({...F.settings,type:At?null:F.type,parent:At?null:F.settings.parent,caption:F.caption}),ie(tn=>!Le&&tn.type==="advanced"&&tn.content?{...tn,settings:{...F.settings,type:F.type,parent:F.settings?.parent,caption:F.caption}}:tn.extraTabs?.length?{extraTabs:tn.extraTabs}:{})),F.settings?.path?.length>0&&Qe(F.settings?.path)}R===r.EVENT_TYPES.APPLICATION_ELEMENT_SETTINGS_CLOSE&&($.current=null,te.current?.type===r.ELEMENT_TYPES.SOCIAL&&Et(),m(r.resetToLastActiveSettingsTab()))},[m,Wa,Ha,Fn,U,Bn,ne,A,e,y,f,O,ct,Et,E,h,te,ie,pt,bt]);(0,l.useEffect)(()=>{r.identifyUser({id:de?.id,email:de?.email,username:de?.name})},[de]),(0,l.useEffect)(()=>{const b=de.email_builder_config,R=!ue,F=I.get()?.mode;if(!b||typeof b!="string")return;const Re=R&&b==="simple"?"pro":b;Re!==F&&m(r.changeConfig(Re))},[ue,de.email_builder_config,de.id,m,q,I]),(0,l.useEffect)(()=>{if(Q&&We.isLocked&&E.toggle(),S.configSwither){let b=localStorage.getItem("configSwither")||S.mode||"editor";localStorage.setItem("configSwither",b),m(r.changeConfig(b))}},[]);const qa=b=>{setTimeout(()=>{if(ue)m(r.changeConfig("pro")),dt(!0),St(!0),A({event:"change",action:"change_config_mode",config_mode:"pro",entity_id:e?.id||y||f,project_id:O?.id||h});else{let R=b?"pro":"editor";localStorage.setItem("configSwither",R),m(r.changeConfig(R)),A({event:"change",action:"change_config_mode",config_mode:R,entity_id:e?.id||y||f,project_id:O?.id||h})}},200)},Sv=()=>{Q&&E.toggle(),m(r.resetToLastActiveSettingsTab()),m(r.changeConfig("simple")),dt(!1),St(!1),A({event:"change",action:"change_config_mode",config_mode:"simple",entity_id:e?.id||y||f,project_id:O?.id||h})},wv=(0,l.useCallback)(()=>{St(!1)},[]);r.useListenPostMessage(Ev),(0,l.useEffect)(()=>{const b=p.addListener(R=>{const F=Gu(R,r.EVENT_TYPES.APPLICATION_NATIVE_IMAGE_DROP);if(!F)return;const Re=()=>p.send({operation:r.EVENT_TYPES.SANDBOX_NATIVE_IMAGE_DROP_CLEAR});(async()=>{const Le=await Wu(F,{readContext:()=>({userId:de?.id,folderId:O?.id??h}),prepare:At=>r.prepareImageForEditorUpload(At,S),upload:At=>Ce(At)});if(Le.status==="failed"&&j.fromError("IMAGE_UPLOAD_ERROR",F,Le.error,!0),Le.status!=="uploaded"){Re();return}p.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_SETTINGS_SET,type:r.ELEMENT_TYPES.IMG,settings:{src:Le.url}});const Nt=q.getState(),bn=Xe==="email"?r.selectElementSettings$1(Nt):r.selectElementSettings(Nt);bn?.type===r.ELEMENT_TYPES.IMG&&Fn({...bn,src:Le.url,changeKey:"src"})})()});return()=>b.dispose()},[p,Ce,de,h,O?.id,S,j,Fn,q,Xe]),(0,l.useEffect)(()=>{const b=p.addListener("application_atom_inserted",F=>{A({event:"add",action:"add_element_to_email",element_type:"atom",element_name:F||"atom",entity_id:e?.id||y||f,project_id:O?.id||h})}),R=p.addListener("application_block_inserted",F=>{const Re=F?.type==="project"||F?.type==="template"||F?.type==="common"?"block":"structure",Le=F?.name||F?.type||(Re==="block"?"block":"structure");A({event:"add",action:"add_element_to_email",element_type:Re,element_name:Le,entity_id:e?.id||y||f,project_id:O?.id||h})});return()=>{b?.dispose(),R?.dispose()}},[p,A,e?.id,y,f,h,O?.id]);const kv=b=>{let R=ne.querySelector(".atoms__list");S.toggleSidePanel&&b===U?m(r.setActiveSettingsTab(r.DISABLED_TAB)):b==="Optimize"?xt.comingSoonHandler(d,w):b!=="Properties"&&b!=="History"?(m(r.setActiveSettingsTab(b)),A({event:"navigate",action:"navigate_email_pane_tab",tab_name:b==="Disabled_tab"?"DISABLED_TAB":b,entity_id:e?.id||y||f,project_id:O?.id||h}),p.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1}),p.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),Qe([])):(b==="Properties"||b==="History")&&A({event:"navigate",action:"navigate_email_pane_tab",tab_name:b,entity_id:e?.id||y||f,project_id:O?.id||h}),he.isLocked&&b==="Discuss"&&(St(!0),we(r.FEATURE_UPSELL_SLIDE.discussion)),ue&&b==="Optimise"&&(St(!0),we(6)),Ve.isLocked&&b==="AiChat"&&(Ve.state.state==="locked_by_limit"&&Ve.exceeded?nt(!0):(St(!0),we(9)))},Vo=(0,l.useRef)(null),$r=(0,l.useRef)(void 0),Mt=(0,l.useCallback)(()=>{const b=Ne.current?.getBoundingClientRect();if(Vo?.current?.getBoundingClientRect().top>=0&&b){const R=Math.round(b.height-30);Vo.current.style.height=`${R}px`,Ee(R-30)}$r.current&&window.clearTimeout($r.current),$r.current=window.setTimeout(function(){p.isInited()&&mt()},100)},[mt,p,Ee]);(0,l.useEffect)(()=>()=>{window.clearTimeout($r.current)},[]),(0,l.useEffect)(()=>(U==="AiChat"&&!ue?le.current=setInterval(()=>{L({entity_id:Me})},5e3):clearInterval(le.current),clearInterval(le.current)),[Me,ue,L,U]);const Tv=b=>hn(b||""),Cv=()=>{Pe(!1),N(D)},Ko=()=>{let b=ne.querySelector(".block-search__preview");b&&(b.style.opacity="0",b.style.transform="translateX(-99%)",setTimeout(function(){b.remove()},300))};let vn=[];const $n={display:"flex",alignItems:"center",justifyContent:"center"};S.blocksEmptyEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Empty blocks"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"BorderOuterOutlined",component:_.icons$BorderOuterOutlined,style:{fontSize:18}})})}),value:"empty"}),S.blocksSavedEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Saved blocks"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"AppstoreAddOutlined",component:_.icons$AppstoreAddOutlined,style:{fontSize:18}})})}),value:"project"}),S.blocksCommonEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Common blocks"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"AppstoreOutlined",component:_.icons$AppstoreOutlined,style:{fontSize:18}})})}),value:"common"}),S.blocksTemplateEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Template blocks"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"BuildOutlined",component:_.icons$BuildOutlined,style:{fontSize:18}})})}),value:"template"}),S.blocksSearchEnabled&&vn.push({label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Blocks search"),children:(0,a.jsx)("div",{style:$n,children:(0,a.jsx)(r.EmIcons,{icon:"SearchOutlined",component:_.icons$SearchOutlined,style:{fontSize:18}})})}),value:"search"});const Ur=P!=="empty"||W,Iv=!S.blocksSectionsShow||Ur?"100%":"calc(100% - 44px)";let Av=[{label:(0,a.jsx)("div",{className:"email-pane__tab",children:d("Elements")}),key:r.ATOMS,className:"email-pane__collapse-panel email-pane__atoms",children:(0,a.jsx)(Op,{})},{label:(0,a.jsx)("div",{className:"email-pane__tab",children:d("Blocks")}),key:r.BLOCKS,className:"email-pane__collapse-panel email-pane__blocks-search",style:{height:Iv},children:(0,a.jsxs)("div",{className:(0,rt.default)("email-pane__blocks-panel",{"email-pane__blocks-panel_scrollable":Ur}),children:[S.blocksSectionsShow&&(0,a.jsxs)("div",{className:"email-pane__blocks-panel-header",children:[(0,a.jsxs)(_.ui_kit$Space.Compact,{block:!0,children:[!W&&(0,a.jsx)(_.ui_kit$Segmented,{block:!0,style:{width:"100%",marginTop:24},onChange:Bn,value:P,options:vn}),W&&(0,a.jsx)("div",{style:{width:"100%",height:36}}),W&&(0,a.jsx)("div",{style:{width:36,textAlign:"right",marginTop:22},children:(0,a.jsx)(r.EmIcons,{icon:"CloseOutlined",component:_.icons$CloseOutlined,style:{padding:"0 2px 0",cursor:"pointer"},onClick:Cv})})]}),(0,a.jsx)("div",{className:"blocks-search__divider-wrapper",style:{marginTop:W?28:12},children:(0,a.jsx)(_.ui_kit$Divider,{className:"blocks-search__divider"})})]}),(0,a.jsxs)("div",{className:"email-pane__blocks-panel-body",children:[(0,a.jsx)("div",{className:"blocks-search__empty-shadow",style:{display:P==="empty"&&!W?"block":"none"},children:_v?(0,a.jsx)(pi,{}):(0,a.jsx)(di,{})}),(0,a.jsx)("div",{className:(0,rt.default)("email-pane__blocks-panel-results",{"email-pane__blocks-panel-results_visible":Ur}),children:(0,a.jsx)(xp,{parentEmailId:e?.parent_email,blocksTab:P,search:W,reloadBlockScreens:Ut,setIsShowAddAllBlocksModal:s})})]})]})}];const Un=[{disabled:gt,key:r.PROPERTIES,style:{height:"var(--ub-em-pane-block-height)"},className:"em-analytics__email-tab-properties",children:(0,a.jsx)(yp,{isShowMobileSettings:ge,propertiesPanelKey:J,onMouseLeave:Ko,email:e,onClosePanel:Lt})},{disabled:gt,key:r.HISTORY,style:{height:"var(--ub-em-pane-block-height)"},className:"em-analytics__email-tab-history",children:Fr&&(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",onMouseLeave:Ko,children:(0,a.jsx)(Lp,{setCollapsedHistory:()=>m(r.switchIsPanelHistoryCollapsed(!0)),emailElement:Fr})})},{key:r.DISABLED_TAB,className:"em-analytics__email-tab-properties"},{disabled:gt,label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"left",title:u("Build","tab"),children:(0,a.jsx)(r.EmIcons,{"data-testid":"contentIcon",icon:"PlusCircleOutlined",component:_.icons$PlusCircleOutlined,size:24,strokeWidth:S.iconStrokeWidth})}),key:r.BUILD,className:"em-analytics__email-tab-build",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:(0,rt.default)("email-pane__collapse-wrapper",{"email-pane__collapse-wrapper_no-topleft-radius":U==="Build"||!U,"email-pane__collapse-wrapper_build":qe==="Blocks"&&Ur}),onMouseLeave:Ko,children:(0,a.jsx)(_.ui_kit$Tabs,{className:(0,rt.default)("secondary-tabs email-pane__collapse",{"secondary-tabs_unset_scroll":qe===r.BLOCKS}),size:"large",activeKey:qe,onChange:Tv,items:Av})})},{disabled:gt,label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"left",title:u("Styles","tab"),children:(0,a.jsx)(r.EmIcons,{"data-testid":"stylesIcon",icon:"Styles",component:_.icons$Styles,size:24,strokeWidth:S.iconStrokeWidth})}),key:r.STYLES,className:"em-analytics__email-tab-styles",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(Ip,{email:e})})}];S.commentsEnabled&&Un.push({disabled:gt,label:(0,a.jsxs)(_.ui_kit$Tooltip,{placement:"left",title:u("Discuss","tab"),children:[(0,a.jsx)(r.EmIcons,{"data-testid":"commentsIcon",icon:"CommentOutlined",component:_.icons$CommentOutlined,size:24,strokeWidth:S.iconStrokeWidth}),he.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:S.iconStrokeWidth,className:"free-mode-firewall-icon free-mode-firewall-icon_emailpane"}),!!qo.length&&(0,a.jsx)("span",{className:"email-pane__comment-counter",children:qo.filter(b=>b.comment_status!=="deleted").length})]}),key:"Discuss",className:"email-pane__tab-discuss em-analytics__email-tab-discuss",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(_.ui_kit$Tabs,{className:"secondary-tabs email-settings__collapse discuss-wrapper",size:"large",activeKey:"Discuss",items:[{label:(0,a.jsx)(a.Fragment,{children:d("Discuss")}),key:"Discuss",forceRender:!0,className:"email-settings__collapse-panel",children:Me?(0,a.jsx)(Mp,{email:e,comments:qo,subjectId:Me,isLoggedIn:!0,emailElementType:Xe}):(0,a.jsx)("div",{className:"aside-content-wrapper",children:e.hasOwnProperty("type")?(0,a.jsx)(_.ui_kit$Alert,{description:d("Save the block before commenting."),type:"info",showIcon:!0,style:{marginBottom:20}}):(0,a.jsx)(_.ui_kit$Alert,{description:d("Save the email before commenting."),type:"info",showIcon:!0,style:{marginBottom:20}})})}]})})});const xv=()=>{_e({entity_id:Me}).then(b=>{b.error?j.error({title:b.error.data.code,description:b.error.data.message}):b.data.success&&j.success({title:d("Success"),description:b.data.success}),ue||L()})};S.aiAssistentEnabled&&Un.push({disabled:gt,label:(0,a.jsxs)(_.ui_kit$Tooltip,{placement:"left",title:u("AI assistant","tab"),children:[(0,a.jsx)(r.EmIcons,{"data-testid":"aiAssistentIcon",icon:"AI",component:_.icons$AI,size:24,strokeWidth:S.iconStrokeWidth}),Ve.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:S.iconStrokeWidth,className:"free-mode-firewall-icon free-mode-firewall-icon_emailpane"}),ht?.totalCount>0&&Me&&(0,a.jsx)("span",{className:"email-pane__comment-counter",children:ht?.totalCount})]}),key:"AiChat",className:"email-pane__tab-discuss em-analytics__email-tab-discuss",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)(a.Fragment,{children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(_.ui_kit$Tabs,{className:"secondary-tabs email-settings__collapse discuss-ai-wrapper",size:"large",activeKey:"AiChat",tabBarExtraContent:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"top",title:d("Clear chat"),children:(0,a.jsx)(_.ui_kit$Popconfirm,{description:d("Clear chat history?"),onConfirm:xv,okText:d("Yes"),cancelText:d("No"),icon:"",placement:"leftTop",title:!1,children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsx)(r.EmIcons,{icon:"ClearChat",component:_.icons$ClearChat,style:{fontSize:16}}),style:{marginRight:16}})})}),items:[{label:(0,a.jsx)(a.Fragment,{children:d("AI assistant")}),key:"AiChat",forceRender:!0,className:"email-settings__collapse-panel",children:Me||window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_active_tab)?(0,a.jsx)(Cp,{messages:ke.length>0?ke:H,newEmailAiGeneratorRef:fn}):(0,a.jsx)("div",{className:"aside-content-wrapper",children:e.hasOwnProperty("type")?(0,a.jsx)(_.ui_kit$Alert,{description:d("Save the block before commenting."),type:"info",showIcon:!0,style:{marginBottom:20}}):(0,a.jsx)(_.ui_kit$Alert,{description:d("Save the email before commenting."),type:"info",showIcon:!0,style:{marginBottom:20}})})}]})})})}),S.optimizeEnabled&&Un.push({disabled:gt,label:(0,a.jsxs)(_.ui_kit$Tooltip,{placement:"left",title:u("Optimize","tab"),children:[(0,a.jsx)(r.EmIcons,{"data-testid":"optimizeIcon",icon:"Speed",component:_.icons$Speed,size:24,strokeWidth:S.iconStrokeWidth}),ue&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:S.iconStrokeWidth,className:"free-mode-firewall-icon free-mode-firewall-icon_emailpane"})]}),key:"Optimise",className:"em-analytics__email-tab-optimise",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(_.ui_kit$Tabs,{className:"secondary-tabs secondary-tabs_optimise email-settings__collapse optimise-wrapper",size:"large",activeKey:"Optimise",items:[{label:(0,a.jsx)(a.Fragment,{children:d("Optimize")}),key:"Optimise",forceRender:!0,className:"email-settings__collapse-panel",children:(0,a.jsx)(Ap,{})}]})})}),S.settingsEnabled&&Un.push({disabled:gt,label:(0,a.jsx)(_.ui_kit$Tooltip,{placement:"left",title:u("Settings","tab"),children:(0,a.jsx)(r.EmIcons,{"data-testid":"settingsIcon",icon:"SettingOutlined",component:_.icons$SettingOutlined,size:24,strokeWidth:S.iconStrokeWidth})}),key:"Edit",className:"em-analytics__email-tab-edit",style:{height:"var(--ub-em-pane-block-height)",overflow:"hidden"},children:(0,a.jsx)("div",{className:"email-pane__collapse-wrapper",children:(0,a.jsx)(jp,{email:e})})});const Va=U===r.DISCUSS,Ka=(0,l.useRef)(0),Ya=(0,l.useRef)(0),Qa=(0,l.useRef)(0),Pv=(0,l.useCallback)(()=>(ne.querySelector(".email-pane__col_preview")?.getBoundingClientRect().width??0)-(S.sidePanelFloating?0:38),[ne,S.sidePanelFloating]);(0,l.useEffect)(()=>{Me&&!ue&&Br()},[Me,ue,Br]),(0,l.useEffect)(()=>{const b=p.onInit(()=>{p.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1}),p.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_DISCUSS,value:Va})});return()=>b.dispose()},[Va,p]),(0,l.useEffect)(()=>{if(!k||!Ki(p))return;const b=new AbortController;return Yi(p,r.DEFAULT_SANDBOX_READY_TIMEOUT_MS,b.signal).then(()=>mt()).catch(()=>{}),()=>b.abort()},[k,mt,p]);const Yo=(0,l.useCallback)(b=>{const R=b??r.selectEmailWidth(q.getState());p.send({operation:r.EVENT_TYPES.SANDBOX_IFRAME_SETSIZE,settings:{iframeWidth:typeof R=="number"?R+2:R}}),xe.current?.resize()},[q,p]);(0,l.useEffect)(()=>{if(!ge&&U!=="Disabled_tab"){const b=ne.querySelector(".email-pane__row")?.getBoundingClientRect().width;Se?.current?.getBoundingClientRect().width+540>b&&m(r.setEmailWidth("100%"))}},[m,U,ne,ge]);const Qo=(0,l.useCallback)(()=>{const b=Se.current;b&&(b.style.borderWidth="1px",S.sidePanelFloating||(b.style.marginLeft="-1px",b.style.marginRight="-1px"),b.style.borderLeftColor=null,b.style.borderRightColor=null)},[S.sidePanelFloating]),Xa=(0,l.useCallback)(b=>{const R=ee.current.widthCodeSplit;be(!1),ee.current.currentSide&&(setTimeout(()=>Yo(),50),et(null)),b.target.classList.contains("email-pane__handle")||Qo(),window.localStorage.setItem(r.LOCAL_STORAGE_ITEMS.em_code_mode_pane_sizes,JSON.stringify(R))},[Yo,ee,be,et,Qo]),Ja=b=>R=>{R.target.classList.contains("email-pane__handle")&&(R.preventDefault(),Ka.current=R.target.parentNode.offsetWidth,Ya.current=R.pageX,Qa.current=Pv(),et(b),Dn.current=b)},zr=b=>{const R=Se.current,{currentSide:F}=ee.current;typeof b=="string"&&(!F||F===b)?(ne.querySelector(".email-pane__iframe").style.width="calc(100% + 1px)",b==="right"?(R.style.borderRightColor=M.colorPrimary,R.style.borderRightWidth="2px"):(R.style.borderLeftColor=M.colorPrimary,R.style.borderLeftWidth="2px",ne.querySelector(".email-pane__iframe").style.marginLeft="-1px")):F||(Qo(),ne.querySelector(".email-pane__iframe").style.width="1px",ne.querySelector(".email-pane__iframe").style.removeProperty("margin-left"))},Rv=(0,l.useCallback)(()=>{be(!0)},[be]),Xo=(0,l.useCallback)(b=>{const{currentSide:R}=ee.current;if(!R)return;const F=(b.pageX-Ya.current)*2,Re=Ka.current+(R==="left"?-F:F),Le=Math.min(Qa.current,1200);Re>318&&Re<Le&&(m(r.setEmailWidth(Math.min(Re,1200))),xe.current?.resize())},[m,ee]),Jo=(0,l.useCallback)(b=>{if(ee.current.isResizing)if(pe==="bottom"){const R=$e.current.getBoundingClientRect().height,F=$e.current.getBoundingClientRect().top,Re=(b.clientY-F)/R*100;if(Re<20||Re>80)return;Fe(Re),Mt()}else{const R=$e.current.getBoundingClientRect().width,F=$e.current.getBoundingClientRect().left,Re=(b.clientX-F)/R*100,Le=Se.current.getBoundingClientRect().width;if(S.desktopMobileSwitchPanel&&typeof Le=="number"&&Le<=425&&m(r.setEmailWidth(425)),Re<20||Re>80)return;Fe(Re)}},[ee,Fe,pe,Mt,m,S.desktopMobileSwitchPanel]);(0,l.useEffect)(()=>{Mt()},[Q,Mt]);const Ov=b=>{b?.stopPropagation?.();const R=Oe==="light"?r.DARK:r.LIGHT;p.send({operation:r.EVENT_TYPES.SANDBOX_SWITCH_THEME,data:{theme:R}}),ze(R)},Za=(b="panel")=>{const R=b==="panel",F=Oe===r.DARK,Re={size:R?18:16,strokeWidth:R?S.iconStrokeWidth:2};return(0,a.jsx)(_.ui_kit$Tooltip,{title:d(F?"Light theme":"Dark theme"),placement:R?"top":"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:R?F?"primary":"text":"default",icon:F?(0,a.jsx)(r.EmIcons,{icon:"LightMode",component:_.icons$LightMode,...Re}):(0,a.jsx)(r.EmIcons,{icon:"DarkMode",component:_.icons$DarkMode,...Re}),shape:"circle",size:R?void 0:"small",onClick:Ov,className:"toggle_view theme_view email-pane__theme-toggle",style:R?void 0:{left:4,top:4,zIndex:999,padding:0,position:"absolute"}})})},Zo=b=>{const R=typeof b=="number"?Math.min(b,1200):b;m(r.setEmailWidth(R)),setTimeout(()=>Yo(R),700);const F=typeof R=="number"?R:R==="100%"?"full":R,Re=typeof R=="number"&&R<=425?"mobile":"desktop";A({event:"change",action:"change_email_size",email_id:e?.id||y||f,project_id:O?.id||h,width:F,view_type:Re})};(0,l.useEffect)(()=>{const b=new g.Disposable;return b.addDisposable(r.addWindowListenerFromShadow(ne,"mousedown",_t,!0)),b.addDisposable(r.addWindowListenerFromShadow(ne,"click",za)),b.addDisposable(r.addWindowListenerFromShadow(ne,"mouseup",R=>Xa(R),!0)),()=>{b.dispose()}},[ne,za,_t,Xa]),(0,l.useEffect)(()=>{const b=Ne.current;if(!b||typeof ResizeObserver!="function")return;const R=new ResizeObserver(Mt);return R.observe(b),()=>R.disconnect()},[Mt,S.sidePanelFloating]),(0,l.useEffect)(()=>(window.addEventListener("scroll",Mt,!0),window.addEventListener("mousemove",Xo,!0),window.addEventListener("mousemove",Jo),window.addEventListener("keydown",_n),()=>{window.removeEventListener("mousemove",Xo,!0),window.removeEventListener("mousemove",Jo),window.removeEventListener("scroll",Mt,!0),window.removeEventListener("keydown",_n)}),[Mt,Xo,Jo,_n]);const jv=b=>{const R=Q?"visual":"code",F=!Q;if(Q?E.toggle():typeof b=="string"?(E.setDirection(b),!Q&&E.toggle()):E.toggle(),F){const Re=Xe==="block"?"block":"email",Le=typeof b=="string"?b:pe||"toggle";A({event:"activate",action:"activate_code_mode",entity_type:Re,entity_id:e?.id||y||f,project_id:O?.id||h,code_mode_direction:Le})}A({event:"change",action:"change_editor_mode",editor_mode:R,entity_id:e?.id||y||f,project_id:O?.id||h}),m(r.resetToLastActiveSettingsTab()),setTimeout(()=>{m(Xe==="block"?r.setElementSettings({type:null}):r.setElementSettings$1({type:null}))},300),p.send({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),m(r.resetPanes())};(0,l.useEffect)(()=>{S.emailPaneDesktopSize&&m(r.setEmailWidth(S.emailPaneDesktopSize))},[m,S.emailPaneDesktopSize]);const Lv=()=>{hn(r.BLOCKS),Bn("project")};return(0,l.useEffect)(()=>{i&&Lv()},[i]),(0,a.jsx)(r.ElementEntityKindProvider,{kind:Xe,children:(0,a.jsxs)(up,{className:(0,rt.default)("email-pane",{"email-pane_code-mode":Q,"email-pane_only_code_mode_mobile":S.onlyCodeModeInMobile,"email-pane_code-mode-bottom":Q&&pe==="bottom","email-pane_no-element-navigation":!S.switchDesktopMobilePropsEnabled&&!S.stepToOtherElementEnabled&&!S.deleteButtonEnabled,"email-pane_is-mobile":ge,"email-pane_path-enabled":S.pathEnabled}),sidePanelFloating:!!S.sidePanelFloating,isCodeMode:!!Q,codeModeDirection:String(pe),children:[(0,a.jsxs)(kp,{className:"email-pane__container",ref:He,children:[(0,a.jsx)(bp,{isCodeMode:Q,codeModeDirection:pe}),(0,a.jsx)(_p,{isShowMobileSettings:ge,headless:!!x,templateNotEmAlertEnabled:!!S.templateNotEmAlertShow}),(0,a.jsxs)(_.ui_kit$Row,{ref:$e,className:(0,rt.default)("email-pane__row",{"email-pane__left":Q&&pe==="right","email-pane__right":Q&&pe==="left","email-pane__bottom":Q&&pe==="bottom","email-pane__sizeSwitcher":S.desktopMobileSwitchPanel,"email-pane__reverse":S.menuDirection==="left","email-pane__pinch":!S.sidePanelFloating}),children:[(0,a.jsxs)(fp,{isCodeMode:Q,codeModeDirection:pe,sidePanelFloating:S.sidePanelFloating,contentWrapperRef:bv,children:[(0,a.jsx)("div",{className:"email-pane__iframe-scroll-top",id:"iframe-scroll-top"}),S.desktopMobileSwitchPanel&&(0,a.jsxs)(_.ui_kit$Space,{className:"email-pane__sizes-panel-wrapper",orientation:"vertical",size:10,children:[(0,a.jsxs)(_.ui_kit$Space,{className:"email-pane__sizes-panel",size:0,children:[Za("panel"),(0,a.jsx)(_.ui_kit$Tooltip,{title:d("Desktop view"),placement:"top",open:On,children:(0,a.jsx)(_.ui_kit$Button,{type:ge?"text":"primary",icon:(0,a.jsx)(r.EmIcons,{icon:"DesktopOutlined",component:_.icons$DesktopOutlined,size:18,strokeWidth:S.iconStrokeWidth}),shape:"circle",onClick:()=>Zo(S.emailPaneDesktopSize||1e3),className:"toggle_view desktop_view"})}),(0,a.jsx)(_.ui_kit$Tooltip,{title:d("Mobile view"),placement:"top",open:gn,children:(0,a.jsx)(_.ui_kit$Button,{type:ge?"primary":"text",icon:(0,a.jsx)(r.EmIcons,{icon:"MobileOutlined",component:_.icons$MobileOutlined,size:18,strokeWidth:S.iconStrokeWidth}),shape:"circle",onClick:()=>Zo(425),className:"toggle_view mobile_view"})})]}),S.codeSideEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:d("Code mode"),placement:"right",children:(0,a.jsx)(_.ui_kit$Button,{type:Q?"primary":"default",icon:(0,a.jsx)(r.EmIcons,{icon:"Code",component:_.icons$Code}),shape:"circle",onClick:()=>jv("right")})})]}),(0,a.jsxs)(_.ui_kit$Row,{className:(0,rt.default)("email-pane__col-wrapper",{container:Q&&pe==="bottom"||!Q,"email-pane__col-wrapper_reverse":S.menuDirection==="left","email-pane__col-wrapper_pinch":!S.sidePanelFloating}),style:{flexGrow:1,maxWidth:"unset",paddingTop:S.desktopMobileSwitchPanel&&Q&&pe!=="bottom"?"60px":""},children:[(0,a.jsxs)(_.ui_kit$Col,{className:"email-pane__col email-pane__col_preview",style:{flexGrow:1,maxWidth:"unset"},ref:S.sidePanelFloating?null:Ne,children:[S.desktopMobileSwitchRule&&(0,a.jsx)(Td,{onSelectWidth:Zo,themeToggle:Za("rule")}),(0,a.jsxs)(mp,{maxPaneWidth:1200,isCodeMode:Q,codeModeDirection:pe,isShowMobileSettings:ge,desktopMobileSwitchPanel:S.desktopMobileSwitchPanel,children:[(0,a.jsx)("div",{className:"email-pane__handle left",onMouseDown:Ja("left"),onMouseEnter:()=>zr("left"),onMouseLeave:zr}),(0,a.jsx)("div",{className:"email-pane__handle right",onMouseDown:Ja("right"),onMouseEnter:()=>zr("right"),onMouseLeave:zr}),(0,a.jsx)(hp,{wrapperRef:Se,children:(0,a.jsx)(Rp,{ref:xe,className:"email-pane__iframe",email:e,handlerSendPosition:Mt,clip:yv})})]})]}),(0,a.jsx)(_.ui_kit$Col,{style:{display:Q&&pe!=="bottom"||S.disableSideMenu?"none":"initial"},ref:Vo,onPointerEnter:Tp,className:(0,rt.default)("email-pane__content-col email-pane__content-col_menu email-pane__content-col_tabs email-pane__col email-pane__col_settings",{"email-pane__col_disabled":U===r.DISABLED_TAB}),children:(!Q||pe==="bottom")&&Z&&(0,a.jsx)(_.ui_kit$Tabs,{className:(0,rt.default)("email-pane__col_settings-inner",{"email-pane__col_settings-inner_reverse":S.menuDirection==="left"}),size:"medium",activeKey:U,onTabClick:kv,renderTabBar:wp,tabPlacement:"right",items:Un,tabBarExtraContent:Bt&&(0,a.jsx)("div",{style:{paddingTop:15,textAlign:"center"},children:ue?(0,a.jsx)(_.ui_kit$Switch,{variant:"editorMode",checkedChildren:"Pro",unCheckedChildren:"Pro",onChange:qa,checked:$t}):(0,a.jsx)(_.ui_kit$Switch,{variant:"editorMode",checkedChildren:"Pro",unCheckedChildren:"Pro",onChange:qa,defaultChecked:Nn})})})})]}),(0,a.jsx)("div",{className:"email-pane__iframe-scroll-bottom",id:"iframe-scroll-bottom"})]}),(0,a.jsxs)(gp,{isCodeMode:Q,codeModeDirection:pe,children:[(0,a.jsx)("div",{className:"email-pane__code-divider",onMouseDown:Rv}),(0,a.jsx)("div",{className:"code-mode__pane code-mode__pane_editor email-pane__pane email-pane__pane_editor",children:(0,a.jsx)("div",{className:"code-mode__pane-content email-pane__pane-content",children:se&&(0,a.jsx)(Pp,{email:e,setOtherUsers:Ze,readOnly:S.lockEditor,newEmailAiGeneratorRef:fn})})})]})]}),S.pathEnabled&&(0,a.jsxs)("div",{className:"email-pane__paths",children:[(0,a.jsx)(su,{elementPath:Ae}),(0,a.jsx)(lu,{fallbackHtml:e?.html})]}),(0,a.jsx)("div",{className:"collaborator-list",children:(0,a.jsx)(r.CollaboratorList,{users:Ge,isEditor:!1,isPlugin:!0,token:M})})]}),(0,a.jsx)(Ep,{isCodeMode:Q,codeModeDirection:pe,email:e,onClosePanel:Lt}),(0,a.jsx)(Pu,{}),(0,a.jsx)(r.PlanUpgradePrompt,{open:gt,onCancel:Sv,onTrialActivated:wv,initialSlide:ce}),st&&Ve.exceeded?(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(ro,{open:De,onClose:je,title:d(st.titleKey),subtitle:d(st.subtitleKey),usageResource:st.usageResource,previousDisplay:r.presetLimitDisplay(Ve.exceeded.previousLimit),nextDisplay:r.presetLimitDisplay(Ve.exceeded.nextLimit),onChangePlan:Yt})}):null,(0,a.jsx)(cu,{open:ft,onClose:lt}),(0,a.jsx)(uu,{open:G,onClose:Y})]})})};us.propTypes={};var Np=e=>(0,a.jsx)(tp,{children:(0,a.jsx)(op,{children:(0,a.jsx)(lp,{children:(0,a.jsx)(us,{...e})})})}),Dp=(0,l.memo)(Np),Fp=({open:e,onClose:t})=>{const{__:n}=r.useI18n(),o=r.getSupportEmail(),[i,s=""]=n("To send a test email, you need to confirm your email address. If you haven’t received the confirmation link, contact support in the chat or email {supportEmail}.").split("{supportEmail}");return(0,a.jsx)(_.ui_kit$Modal,{width:440,open:e,onCancel:t,title:(0,a.jsxs)("div",{style:{paddingBottom:8},children:[(0,a.jsx)(r.EmIcons,{icon:"EmailConfirmation",component:_.icons$EmailConfirmation,size:20,strokeWidth:2})," ",n("Email confirmation required")]}),footer:[(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",onClick:t,children:n("Got it")},"ok")],children:(0,a.jsxs)("p",{children:[i,(0,a.jsx)("a",{href:`mailto:${o}`,children:o}),s]})})},Qn=e=>{const t=r.useCurrentUser(),[n,o]=(0,l.useState)({owner:!1,admin:!1,user:!1}),i=r.useProjectData(),{data:s}=r.useGetProjectQuery(e,{skip:!e||!t.id||!!i}),c=i||s;return(0,l.useEffect)(()=>{if(c){const d=r.getMyProjectRole(c,t);o({owner:d==="owner",admin:d==="admin",user:d==="user"})}},[c,t]),n},lo=r.getLimitUpgradePresetDefinition("preview_exceeded"),ps=({emailElement:e,isCollaborationEditor:t})=>{const{__:n}=r.useI18n(),o=r.useDispatch(),i=qr(),s=r.useOpenPlanCatalog(),c=r.useSendPostMessage(),{blockId:d}=r.useRouteParams(),u=r.useRouteEmailId(),p=r.useSelector(r.selectActiveModal$1)===r.MODALS.SEND_TEST_EMAIL,f=kn(p),[h,y]=(0,l.useState)(!1),[m,E]=r.useSendLivePreviewMutation(),T=r.useCurrentUser(),w=r.useDocumentHistoryReader(),S=r.useProjectPlanLimitPreflight(),{owner:I}=Qn(),x=Xr(),K=Pd(),Z=r.useContentReader(),M=r.useSelector(r.selectIsPanelHistoryCollapsed),j=r.useSelector(r.selectIsCodeMode),A=r.useSelector(r.selectCodeModeDirection),{token:O}=(0,_.ui_kit$useToken)(),z=r.useNotification(),B=r.useAppConfig(),U=e.hasOwnProperty("type")?r.BLOCK:r.EMAIL,de=r.useEventEmitter(g.events.ON_SHARE_ID),me=r.useEventEmitter(g.events.ON_SHOW_PREVIEW_ID),[q,ee]=(0,l.useState)(!1),[Fe,be]=(0,l.useState)(0),[et,Ee]=(0,l.useState)(!1),fe=kn(et),Q=(0,l.useCallback)(()=>Ee(!1),[]),pe=(0,l.useCallback)(()=>{Ee(!1),s()},[s]),[se,ae]=(0,l.useState)(n("—")),[Ie,Te]=(0,l.useState)(!1),Be=r.useProjectData(),J=r.usePlanFeatureGate("version_history"),_e=r.usePlanFeatureGate("code_editor"),Ce=r.usePlanFeatureGate("preview_service"),ge=r.usePlanFeatureGate("undo_redo"),Oe=r.isEditorLockedByPlan(Be,{isPlugin:!0}),ze=r.usePushToDataLayer(),k=e?.project,C=he=>{const We=U==="block"?"block":"email";typeof he=="string"?(i.setDirection(he),!j&&i.toggle()):i.toggle(),ze({event:"activate",action:"activate_code_mode",entity_type:We,entity_id:e?.id||u||d,project_id:e?.project||k}),setTimeout(()=>{o(U==="block"?r.setElementSettings({type:null}):r.setElementSettings$1({type:null}))},300),c({operation:r.EVENT_TYPES.SANDBOX_ELEMENT_ACTIVE_RESET}),_e.isLocked&&(ee(!0),be(r.FEATURE_UPSELL_SLIDE.code_editor))},P=(0,l.useCallback)(async()=>!0,[S]),N=async()=>{if(Oe){ee(!0),be(8);return}await P()&&(o(r.openModal$1(r.MODALS.SEND_TEST_EMAIL)),ze({event:"open",action:"open_test_email_modal",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||k}))},D=()=>{ee(!0),be(r.FEATURE_UPSELL_SLIDE.undo_redo)},v=()=>{x.undo()},W=()=>{x.redo()},Pe=async()=>{const he=(await de.fire({project:k,id:u})).find(We=>We===!1||typeof We=="string");he!==!1&&navigator.clipboard.writeText(he||r.buildEmailRawShareUrl(u,k)).then(()=>{z.success(n("A shareable link to this page has been copied to the clipboard.")),ze({event:"click",action:"share_email",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||k})})},Ae=async()=>{if(!h){if(!await P())return;const he={email:u,subject:encodeURIComponent("#"+e.project+" "+e.title).replaceAll(/%20/gi,"+").replaceAll(/%0A/gi,"%0D%0A"),content:encodeURIComponent(Z()).replaceAll(/%20/gi,"+").replaceAll(/%0A/gi,"%0D%0A")};m(he),y(!0),ze({event:"click",action:"open_email_inbox_tests",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||k})}},Qe=(0,l.useCallback)(async()=>{await P()&&(ae(n("—")),Ee(!0))},[n,P]);(0,l.useEffect)(()=>{E.isError&&(z.error(E),y(!1))},[E]),(0,l.useEffect)(()=>{if(E.isSuccess&&h){if(E.data?.status===401)z.error({title:E.data.code,description:E.data.message});else if(E.data){let he=document.createElement("A");he.setAttribute("target","_blank"),he.setAttribute("href",E.data.message),he.click()}y(!1)}},[E,h,z]);const[Ge,Ze]=(0,l.useState)(!1),pt=()=>{c({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:M}),o(r.switchIsPanelHistoryCollapsed(!M))},bt=()=>w(e?.id),ft=()=>{M?(Ze(!0),bt().then(he=>{he.isSuccess?he.data.data.length:he.isError&&z.error(he),pt(),o(r.setActiveSettingsTab(r.HISTORY)),Ze(!1),ze({event:"open",action:"open_version_control",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||k}),J.isLocked&&(ee(!0),be(r.FEATURE_UPSELL_SLIDE.version_history))})):(o(r.resetToLastActiveSettingsTab()),pt())},lt=()=>{M||(pt(),o(r.resetToLastActiveSettingsTab())),j&&i.toggle(),ee(!1)};let G=[];const Y=(0,l.useCallback)(async()=>{const he=await me.fire({project:k,id:u});he.find(We=>We===!1||typeof We=="string")!==!1&&(window.open(he.find(We=>We)||r.buildEmailRawSharePath(u,k)),ze({event:"click",action:"open_email_preview",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||k}))},[me,k,u,ze,U,e,d]),ne=(0,l.useCallback)(async()=>{window.open(r.buildGetElementPreviewPath(r.EMAIL,u,k)),ze({event:"click",action:"open_web_version",entity_type:U==="block"?"block":"email",entity_id:e?.id||u||d,project_id:e?.project||k})},[k,u,ze,U,e,d]);B.previewModeEnabled&&G.push({key:"Preview_mode",icon:(0,a.jsx)(r.EmIcons,{icon:"EyeOutlined",component:_.icons$EyeOutlined,size:18,strokeWidth:B.iconStrokeWidth}),label:n("Preview mode"),onClick:Y}),B.livePreviewEnabled&&G.push({key:"Live_preview",icon:h?(0,a.jsx)(r.EmIcons,{icon:"LoadingOutlined",component:_.icons$LoadingOutlined,style:{fontSize:16}}):(0,a.jsx)(r.EmIcons,{icon:"CheckCircleVerified",component:_.icons$CheckCircleVerified,size:18,strokeWidth:B.iconStrokeWidth}),label:n("Live preview"),onClick:T.id?.toString()===e.project_author?.toString()&&T?.subscription?.post_name==="community"&&I?Qe:Ae}),B.webversionEnabled&&G.push({key:"Web version",icon:(0,a.jsx)(r.EmIcons,{icon:"Web",component:_.icons$Web,size:18,strokeWidth:B.iconStrokeWidth}),label:n("Web version"),onClick:ne}),B.sharePreviewEnabled&&G.push({key:"Share",icon:(0,a.jsx)(r.EmIcons,{icon:"ShareAltOutlined",component:_.icons$ShareAltOutlined,size:18,strokeWidth:B.iconStrokeWidth}),label:n("Share"),onClick:Pe,className:"em-analytics__email-share"});const ue=[{key:"Left_mode",icon:(0,a.jsx)(r.EmIcons,{icon:"PanelLeft",component:_.icons$PanelLeft,size:18,strokeWidth:B.iconStrokeWidth,style:{color:A==="left"&&j?O.colorPrimary:"inherit"}}),label:n("Left Code panel"),onClick:()=>C("left")},{key:"Right_mode",icon:(0,a.jsx)(r.EmIcons,{icon:"PanelLeft",component:_.icons$PanelLeft,size:18,strokeWidth:B.iconStrokeWidth,style:{transform:"rotate(180deg)",color:A==="right"&&j?O.colorPrimary:"inherit"}}),label:n("Right Code panel"),onClick:()=>C("right")},{key:"Bottom_mode",icon:(0,a.jsx)(r.EmIcons,{icon:"PanelLeft",component:_.icons$PanelLeft,size:18,strokeWidth:B.iconStrokeWidth,style:{transform:"rotate(-90deg)",color:A==="bottom"&&j?O.colorPrimary:"inherit"}}),label:n("Bottom Code panel"),onClick:()=>C("bottom")}];return(0,a.jsxs)("div",{className:"email-preview-menu email-preview-menu_new",children:[(0,a.jsxs)(_.ui_kit$Space,{size:32,children:[(0,a.jsxs)(_.ui_kit$Space,{className:"email-preview-menu__versions",size:8,style:{borderRadius:`calc(${r.emCssVar("borderRadius")} * 1px)`},children:[(0,a.jsx)(_.ui_kit$Tooltip,{title:n(t?r.COLLABORATION_EDITOR_WARNING_TEXT:"Undo (Ctrl+Z)"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"UndoOutlined",component:_.icons$UndoOutlined,size:22,strokeWidth:B.iconStrokeWidth}),ge.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:ge.isLocked?D:v,disabled:!ge.isLocked&&!K.canUndo})}),(0,a.jsx)(_.ui_kit$Tooltip,{title:n(t?r.COLLABORATION_EDITOR_WARNING_TEXT:"Redo (Ctrl+Shift+Z)"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"RedoOutlined",component:_.icons$RedoOutlined,size:22,strokeWidth:B.iconStrokeWidth}),ge.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:ge.isLocked?D:W,disabled:!ge.isLocked&&!K.canRedo})}),B.historyEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Version history"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:M?"text":"primary",ghost:!M,onClick:ft,disabled:e.isNew||Ge,className:"email-preview-menu__history",icon:Ge?(0,a.jsx)(_.ui_kit$Spin,{size:"small"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"HistoryOutlined",component:_.icons$HistoryOutlined,size:22,strokeWidth:B.iconStrokeWidth,className:"email-preview-menu__list-item-icon email-preview-menu__list-item-icon_revert"}),J.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]})})})]}),(0,a.jsxs)(_.ui_kit$Space,{size:8,style:{borderRadius:`calc(${r.emCssVar("borderRadius")} * 1px)`},children:[B.codeEnabled&&(0,a.jsx)(_.ui_kit$Dropdown,{arrow:!0,placement:"bottom",menu:{items:ue},trigger:"hover",mouseEnterDelay:0,className:"email-preview-menu__code",children:(0,a.jsx)(_.ui_kit$Button,{type:j?"primary":"text",ghost:j,icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"Code",component:_.icons$Code,size:22,strokeWidth:B.iconStrokeWidth}),_e.isLocked&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:C})},"Code mode"),B.previewIconEnabled&&(Ce.isLocked?(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Preview mode"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"EyeOutlined",component:_.icons$EyeOutlined,size:22,strokeWidth:B.iconStrokeWidth,className:"email-preview-menu__list-item-icon"}),(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:()=>{ee(!0),be(r.FEATURE_UPSELL_SLIDE.preview_service)}})}):(0,a.jsx)(_.ui_kit$Dropdown,{arrow:!0,placement:"bottom",menu:{items:G},className:"email-preview-menu__preview",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",target:"_blank",rel:"noreferrer",icon:(0,a.jsx)(r.EmIcons,{icon:"EyeOutlined",component:_.icons$EyeOutlined,size:22,strokeWidth:B.iconStrokeWidth,className:"email-preview-menu__list-item-icon"}),onClick:B.previewModeEnabled?Y:void 0})},"Preview")),B.sendTestEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n("Send a test email"),placement:"bottom",children:(0,a.jsx)(_.ui_kit$Button,{className:"em-analytics__email-open-test email-preview-menu__test",type:"text",icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(r.EmIcons,{icon:"SendOutlined",component:_.icons$SendOutlined,size:22,strokeWidth:B.iconStrokeWidth,className:"email-preview-menu__list-item-icon"}),Oe&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:14,strokeWidth:B.iconStrokeWidth,className:"free-mode-firewall-icon"})]}),onClick:N})})]})]}),f&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(Iu,{isModalVisible:p,email:e})}),(0,a.jsx)(Fp,{open:Ie,onClose:()=>Te(!1)}),(0,a.jsx)(r.PlanUpgradePrompt,{open:q,onCancel:lt,initialSlide:Fe}),fe&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(ro,{open:et,onClose:Q,title:n(lo.titleKey),subtitle:n(lo.subtitleKey),usageResource:lo.usageResource,previousDisplay:se,nextDisplay:r.presetLimitDisplay("infinity"),onChangePlan:pe})})]})};ps.propTypes={};var Bp=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],$p=200;function ms(e=new Set){const t=new Set;return(n,o)=>{if(!Bp.some(([s,c])=>!e.has(s)&&c.test(n)))return;const i=o??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=$p&&t.clear(),t.add(i))}}function fs(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:ms()}}var Up=fs();function on(e){return e?.getInstance(g.TEMPLATE_DIRECTIVES_ID)??Up}function zp({html:e,renderGuid:t,showToken:n,showId:o,...i},s){const{requested:c}=r.getCurrentProject(s),d=r.getAppConfig(s);return r.filterUndefined({...i,code:on(s).toOutputForm(e),project:c===void 0?i.project:c,utm_parameters:d.UTMEnabled?i.utm_parameters:void 0,tags:void 0,template:void 0,guid:void 0,emailtags:void 0,project_title:void 0,project_author:void 0,is_template:void 0,is_inited:void 0})}var Gp=zt.__commonJSMin(((e,t)=>{r.init__polyfill_node_global(),(function(n,o){typeof define=="function"&&define.amd?define([],o):typeof e<"u"?o():(o(),n.FileSaver={})})(e,function(){"use strict";function n(p,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(p.type)?new Blob(["\uFEFF",p],{type:p.type}):p}function o(p,f,h){var y=new XMLHttpRequest;y.open("GET",p),y.responseType="blob",y.onload=function(){u(y.response,f,h)},y.onerror=function(){},y.send()}function i(p){var f=new XMLHttpRequest;f.open("HEAD",p,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function s(p){try{p.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),p.dispatchEvent(f)}}var c=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof r._polyfill_node_global_default=="object"&&r._polyfill_node_global_default.global===r._polyfill_node_global_default?r._polyfill_node_global_default:void 0,d=c.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),u=c.saveAs||(typeof window!="object"||window!==c?function(){}:"download"in HTMLAnchorElement.prototype&&!d?function(p,f,h){var y=c.URL||c.webkitURL,m=document.createElement("a");f=f||p.name||"download",m.download=f,m.rel="noopener",typeof p=="string"?(m.href=p,m.origin===location.origin?s(m):i(m.href)?o(p,f,h):s(m,m.target="_blank")):(m.href=y.createObjectURL(p),setTimeout(function(){y.revokeObjectURL(m.href)},4e4),setTimeout(function(){s(m)},0))}:"msSaveOrOpenBlob"in navigator?function(p,f,h){if(f=f||p.name||"download",typeof p!="string")navigator.msSaveOrOpenBlob(n(p,h),f);else if(i(p))o(p,f,h);else{var y=document.createElement("a");y.href=p,y.target="_blank",setTimeout(function(){s(y)})}}:function(p,f,h,y){if(y=y||open("","_blank"),y&&(y.document.title=y.document.body.innerText="downloading..."),typeof p=="string")return o(p,f,h);var m=p.type==="application/octet-stream",E=/constructor/i.test(c.HTMLElement)||c.safari,T=/CriOS\/[\d]+/.test(navigator.userAgent);if((T||m&&E||d)&&typeof FileReader<"u"){var w=new FileReader;w.onloadend=function(){var x=w.result;x=T?x:x.replace(/^data:[^;]*;/,"data:attachment/file;"),y?y.location.href=x:location=x,y=null},w.readAsDataURL(p)}else{var S=c.URL||c.webkitURL,I=S.createObjectURL(p);y?y.location=I:location.href=I,y=null,setTimeout(function(){S.revokeObjectURL(I)},4e4)}});c.saveAs=u.saveAs=u,typeof t<"u"&&(t.exports=u)})})),sn=Gp(),In="NEXT_BUTTON",co="SAVE_BUTTON",uo="KEYBOARD",Wp="EXTERNAL",Hp=new Set([co,In,uo]);function qp(e){return e!=null&&e!==""&&Hp.has(e)}function gs(e){if(!e||e==="all")return;const t=Number(e);return Number.isFinite(t)?[t]:void 0}var hs=(0,l.createContext)(null);function Vp(){const e=(0,l.useContext)(hs);if(!e)throw new Error("useEmailSaveController must be used within EmailSaveContext.Provider");return e}var Kp=2;function Yp({email:e,documentSession:t,save:n,saveState:o}){const i=r.useDispatch(),{__:s}=r.useI18n(),c=r.useEditorProjectId();r.useRouteEmailId();const d=+c,u=Number.isFinite(d)&&d>0?d:e?.project,p=r.useCookieManager(),f=r.useContainer(),h=r.useNotification(),y=r.useAppConfig(),m=r.useConfigSource(),[E,T]=(0,l.useState)(0),w=(0,l.useRef)(""),[S,I]=(0,l.useState)(!1),x=r.useEventEmitter(g.events.ON_NEXTBUTTON_CLICK_ID),K=r.useEventEmitter(g.events.ON_SAVEBUTTON_CLICK_ID);r.useEvent(g.events.ON_EMAIL_INIT_ID);const Z=y.activeNextButton===!1,M=y.disableDoubleClickNextButton!==!1,j=(0,l.useRef)(!1),A=(0,l.useRef)(void 0),O=(0,l.useRef)(null),z=(0,l.useRef)(null),B=(0,l.useRef)(e);B.current=e;const U=(0,l.useCallback)(()=>{A.current=void 0},[]),de=(0,l.useCallback)(J=>{m.merge({activeNextButton:!J},"user")},[m]),me=(0,l.useCallback)((J,_e)=>{const Ce=r.saveRefusalReason(_e);if(Ce==="locked"){h.error({id:"EMAIL_ACCESS_TO_LOCKED_ERROR",data:r.getEmailDesc(J),message:s("No access to edit the letter.")});return}if(Ce==="too-many-tags"){h.error({id:"EMAIL_TOO_MANY_TAGS_ERROR",data:r.getEmailDesc(J),message:s("Maximum 10 tags available.")});return}const ge=r.failedTerms(_e);if(ge){ge.failed.forEach(Oe=>{if(ge.kind==="group"){h.fromError("GROUP_CREATING_ERROR",{id:Oe.id??0,name:Oe.name,parent:Oe.parent??0},_e);return}h.fromError("TAG_CREATING_ERROR",Oe.name,_e)});return}h.fromError(J.isNew?"EMAIL_CREATING_ERROR":"EMAIL_EDITING_ERROR",r.getEmailDesc(J),_e)},[h,s]),q=(0,l.useCallback)(J=>{const _e=qp(J),Ce=()=>{I(!1),J===In&&(j.current=!1,de(!1))};if(!e){Ce();return}const ge=async()=>{(ze=>{n("publish",{project:ze.isNew?u:ze.project,folder:gs(p.get(r.APP_COOKIES.em_folder)),source:J}).then(k=>{if(I(!1),j.current=!1,!k){J===In&&de(!1),_e&&(me(ze,o().error),U());return}_e&&(h.success({id:"EMAIL_SAVING_SUCCESS",message:s("The email was successfully saved."),data:r.getEmailDesc(ze)}),U())})})(e)};I(!0),ge()},[e,i,c,s,t,p,u,h,me,n,o,de,U]);r.useCommand(r.SAVE_COMMAND_ID,(0,l.useCallback)(J=>q(J||Wp),[q]));const ee=(0,l.useRef)(void 0),Fe=(0,l.useRef)(q);Fe.current=q;const be=(0,l.useCallback)(J=>{w.current=J,T(_e=>_e+1)},[]);(0,l.useEffect)(()=>()=>{ee.current!==void 0&&clearTimeout(ee.current)},[]),(0,l.useEffect)(()=>{if(E===0)return;const J=w.current;B.current?.isNew&&(A.current=J),ee.current!==void 0&&clearTimeout(ee.current),ee.current=setTimeout(()=>{ee.current=void 0,Fe.current(J)})},[E]);const et=(0,l.useCallback)(J=>{(J.ctrlKey||J.metaKey)&&J.keyCode===83&&(J.preventDefault(),be(uo))},[be]);(0,l.useEffect)(()=>(document.addEventListener("keydown",et),()=>{document.removeEventListener("keydown",et)}),[et]);const Ee=(0,l.useCallback)(J=>{const _e=J.data.operation,Ce=J.data.action;_e===r.EVENT_TYPES.APPLICATION_ACTION&&Ce==="save_email"&&be(uo)},[be]);r.useListenPostMessage(Ee),(0,l.useEffect)(()=>{e?.isNew&&(z.current=null,O.current=null)},[e?.isNew,e?.renderGuid]),(0,l.useEffect)(()=>{j.current=!1},[e?.id]);const fe=p.get(r.APP_COOKIES.em_folder),Q=f?r.provideAutosaveUiFacts(f):void 0;(0,l.useEffect)(()=>{Q?.set({...Q?.get()??{isUserBusy:!1,saveContext:{}},saveContext:{project:u,folder:gs(fe)}})},[Q,u,fe]);const pe=(0,l.useRef)(!1),se=o().failures;(0,l.useEffect)(()=>{se>=Kp&&!pe.current&&(pe.current=!0,h.warning({message:s("Changes are not being saved. Check your connection.")})),se===0&&(pe.current=!1)},[se,h,s]);const ae=S,Ie=o().saving,Te=(0,l.useCallback)(J=>{be(J||co)},[be]),Be=(0,l.useCallback)(async(J,_e)=>{if(J===In){if(j.current)return;j.current=!0;try{M&&de(!0),(await x.fire(_e)).every(Ce=>Ce!==!1)?be(In):(de(!1),j.current=!1)}catch(Ce){h.fromError("NEXT_BUTTON_CLICK_EVENT_ERROR",r.getEmailDesc(_e),Ce,!0),de(!1),j.current=!1}return}try{(await K.fire(_e)).every(Ce=>Ce!==!1)&&be(J||co)}catch(Ce){h.fromError("SAVE_BUTTON_CLICK_EVENT_ERROR",r.getEmailDesc(_e),Ce,!0)}},[M,x,K,h,de,be]);return(0,l.useMemo)(()=>({requestSave:Te,requestSaveWithEvents:Be,isLoading:ae,isAutosaveLoading:Ie,nextButtonDisabled:Z}),[Te,Be,ae,Ie,Z])}var Qp="NEXT_BUTTON",Xp="SAVE_BUTTON",_s=({email:e=null,disabled:t})=>{const{__:n}=r.useI18n(),o=r.useAppConfig(),i=r.useContentReader(),s=r.useNotification(),{requestSaveWithEvents:c,isLoading:d,isAutosaveLoading:u,nextButtonDisabled:p}=Vp(),f=d||u,[h,y]=(0,l.useState)(null);(0,l.useEffect)(()=>{window?.navigator?.userAgent.includes("Macintosh")&&y(!0)},[]);const m=o.saveButtonEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:n(h?"Save by ⌘S":"Save by Ctrl+S"),placement:"bottom",children:(0,a.jsx)("span",{className:"em-analytics__email-save-tooltip-target",children:(0,a.jsx)(_.ui_kit$Button,{disabled:t||u,type:o.nextButtonEnabled?"default":"primary",block:"false",className:"em-analytics__email-save",loading:f,icon:(0,a.jsx)(r.EmIcons,{icon:"SaveOutlined",component:_.icons$SaveOutlined,size:16,strokeWidth:o.iconStrokeWidth}),onClick:async T=>{const w=T.currentTarget,S={...e,html:i()};try{await c(Xp,S)}catch(I){s.fromError("SAVE_BUTTON_CLICK_EVENT_ERROR",r.getEmailDesc(S),I,!0)}finally{try{w?.blur?.()}catch{}}},children:o.saveButtonText||n("Save")})})},"save-button"),E=o.nextButtonEnabled&&(0,a.jsx)(_.ui_kit$Button,{disabled:t||p,type:"primary",block:"false",className:"em-analytics__email-save",icon:o.primaryCommandButtonIcon,loading:d,onClick:async()=>{const T={...e,html:i()};await c(Qp,T)},children:o.nextButtonText||n("Continue")},"next-button");return(0,a.jsx)(a.Fragment,{children:o.saveButtonEnabled&&o.nextButtonEnabled?(0,a.jsx)(_.ui_kit$Space,{children:[m,E]}):[m,E]})};_s.propTypes={email:Ue.default.shape({id:Ue.default.string,isNew:Ue.default.bool,title:Ue.default.string,lock:Ue.default.bool,subject:Ue.default.string,html:Ue.default.string,description:Ue.default.string,utm_parameters:Ue.default.shape({utm_source:Ue.default.string,utm_medium:Ue.default.string,utm_campaign:Ue.default.string,utm_term:Ue.default.string,utm_content:Ue.default.string}),project:Ue.default.number,is_template:Ue.default.bool}),disabled:Ue.default.bool};var ys=({element:e,context:t="list"})=>{const{__:n,_x:o}=r.useI18n(),[i]=r.useEditEmailMutation(),[s]=r.useEditBlockMutation(),c=r.useNotification(),d=r.usePushToDataLayer();e.hasOwnProperty("type");const u=(f,h)=>{if(f.error)return c.error(f),!1;c.success(n("The ")+(h.hasOwnProperty("type")?n("block"):o("email","letter"))+" "+n("“")+f.data.title+n("”")+n("was successfully")+" "+(h.lock?h.hasOwnProperty("type")?o("unlocked.","block"):o("unlocked.","email"):h.hasOwnProperty("type")?o("locked.","block"):o("locked.","email")))},p=()=>{const f=!e.lock,h=f?"lock_email":"unlock_email";e.hasOwnProperty("type")?s({blockId:e.id,lock:f}).then(y=>{u(y,e),y.error||d({event:f?"lock":"unlock",action:f?"lock_block":"unlock_block",entity_type:"block",entity_id:e.id,project_id:e.project,context:t})}):i({emailId:e.id,lock:f}).then(y=>{u(y,e),y.error||d({event:f?"lock":"unlock",action:h,entity_type:"email",entity_id:e.id,project_id:e.project,context:t})})};return(0,a.jsx)("div",{className:e.hasOwnProperty("type")?"em-analytics__block-lock":"em-analytics__email-lock",onClick:p,children:e.lock?n("Unlock"):n("Lock")})};ys.propTypes={element:Ue.default.shape({lock:Ue.default.bool,id:Ue.default.string})};var Jp=({open:e,codeSize:t,onMinimize:n,onDownloadAsIs:o,onCancel:i})=>{const{__:s}=r.useI18n(),c=r.formatCodeSize(t);return(0,a.jsx)(_.ui_kit$Modal,{open:e,onCancel:i,footer:null,className:"code-size-warning-modal",width:480,children:(0,a.jsxs)("div",{className:"code-size-warning-modal__content",children:[(0,a.jsx)("h3",{className:"code-size-warning-modal__title",children:s("Code Size Warning")}),(0,a.jsxs)("div",{className:"code-size-warning-modal__message",children:[(0,a.jsxs)("p",{children:[s("The current code size is")," ",(0,a.jsx)("strong",{children:c}),","," ",s("which exceeds the recommended 90 KB limit.")]}),(0,a.jsx)("p",{children:s("Large emails may have delivery issues and load slowly. We recommend minimizing code before exporting.")})]}),(0,a.jsxs)(_.ui_kit$Space,{className:"code-size-warning-modal__actions",size:"medium",children:[(0,a.jsx)(_.ui_kit$Button,{type:"primary",onClick:n,size:"large",children:s("Minimize code")}),(0,a.jsx)(_.ui_kit$Button,{onClick:o,size:"large",children:s("Download as is")})]})]})})};function Zp(e){return e.includes("em-narrow-table")}function em(e){if(!e||Zp(e))return!1;const t=e.includes("nl-container"),n=/row-content\s+stack/.test(e)||/stack\s+row-content/.test(e),o=/\brow-\d/.test(e),i=/_block\s+block-\d/.test(e),s=e.includes('role="presentation"');return t&&n&&(o||i)&&s}function tm(e){return e?e.includes("em-narrow-table"):!1}function nm(e){return e.includes("em-narrow-table")}function rm(e){return e.includes("i-amphtml")||e.includes("amp-runtime")||e.includes("amp-version")}function om(e){if(!e||nm(e)||rm(e))return!1;const t=e.includes("es-wrapper"),n=/es-(?:header|content|footer)-body/.test(e);return t||n}function vs(){r.useAppConfig();const e=r.useIntegratorConfigValue("beeFreeConverterEnabled"),t=r.useIntegratorConfigValue("stripoConverterEnabled"),n=r.useIntegratorConfigValue("aiLayoutConverterEnabled"),o=e===!0,i=t===!0,s=n===!0;return{beeFreeConverterEnabled:o,stripoConverterEnabled:i,aiLayoutConverterEnabled:s,anyConverterEnabled:o||i||s}}function bs(e,t){return!e||tm(e)?null:em(e)?t.beeFreeConverterEnabled?"beefree":null:om(e)?t.stripoConverterEnabled?"stripo":null:t.aiLayoutConverterEnabled?"ai":null}var im=()=>"useblocks",sm={unisender:{id:"unisender",name:"Unisender",icon:"/images/integrations/unisender.svg",description:"Export emails to Unisender",cardDescription:"Mass mailing automation, audience segmentation, and campaign performance analytics.",apps:["emailmaker"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter Unisender API key",helpUrl:"https://app.unisender.com/ru/v5/cp/user/info/api"},{name:"sender_email",type:"email",label:"Sender Email",required:!0,placeholder:"sender@example.com",extra:"This email must be verified in Unisender"},{name:"sender_name",type:"text",label:"Sender Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"list_id",type:"number",label:"Contact List ID",required:!0,placeholder:"e.g., 123456"}]},mailganer:{id:"mailganer",name:"Mailganer",icon:"/images/integrations/mailganer.svg",description:"Export emails to Mailganer",cardDescription:"Contact sync, content personalization, and real-time campaign results tracking.",apps:["emailmaker"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter Mailganer API key",helpUrl:"https://mailganer.com/app/profile/"},{name:"from_email",type:"email",label:"Sender Email",required:!1,placeholder:"sender@example.com",extra:"This email must be verified in Mailganer"},{name:"from_name",type:"text",label:"Sender Name",required:!1,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Mailing Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"theme",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},sendsay:{id:"sendsay",name:"Sendsay",icon:"/images/integrations/sendsay.svg",description:"Export emails to Sendsay",cardDescription:"Mailing automation, audience segmentation, and email personalization.",apps:["emailmaker"],settingsFields:[{name:"login",type:"text",label:"Account Login",required:!0,placeholder:"e.g., myaccount or myaccount/sublogin",extra:"Your Sendsay account login (not email). For sublogin use format: account/sublogin",fullWidth:!0},{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter Sendsay API key",helpUrl:"https://docs.sendsay.ru/sendsay-api/how-to-get-apikey"},{name:"from_email",type:"email",label:"Sender Email",required:!1,placeholder:"sender@example.com",extra:"This email must be verified in Sendsay"},{name:"from_name",type:"text",label:"Sender Name",required:!1,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Draft Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!0,placeholder:"e.g., Special offer for you!"}]},klaviyo:{id:"klaviyo",name:"Klaviyo",icon:"/images/integrations/klaviyo.svg",description:"Export emails to Klaviyo",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"e.g., pk_xxxxxxxx",helpUrl:"https://help.klaviyo.com/hc/en-us/articles/7423954176283-How-to-create-a-private-API-key",extra:"Use a custom key with templates:write and campaigns:write (or Full access). Campaigns-only is not enough — export creates a template first."},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"This email must be verified in Klaviyo"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"list_id",type:"text",label:"List ID",required:!0,placeholder:"e.g., ABC123",helpText:"Find your List ID in Klaviyo: Lists & Segments → List → Settings"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},campaign_monitor:{id:"campaign_monitor",name:"Campaign Monitor",icon:"/images/integrations/campaign_monitor.svg",description:"Export emails to Campaign Monitor",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter API Key",fullWidth:!0,helpUrl:"https://help.campaignmonitor.com/s/article/api-keys"},{name:"client_id",type:"text",label:"Client ID",required:!0,placeholder:"e.g., 4a397ccaaa55eb4e6aa1221e1e2d7122",helpText:"Find in Account Settings → API Keys"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be verified in Campaign Monitor"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"list_id",type:"text",label:"List ID",required:!0,placeholder:"e.g., a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1",helpText:"Find in Lists → List ID"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},constant_contact:{id:"constant_contact",name:"Constant Contact",icon:"/images/integrations/constant_contact.svg",description:"Export emails to Constant Contact",apps:["useblocks"],settingsFields:[{name:"access_token",type:"password",label:"Access Token",required:!0,placeholder:"OAuth2 Bearer token",fullWidth:!0,helpText:"Get from Constant Contact Developer Portal. Token expires in 24 hours.",helpUrl:"https://developer.constantcontact.com/api_guide/getting_started.html"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be confirmed in Constant Contact"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"list_id",type:"text",label:"Contact List ID",required:!0,placeholder:"e.g., fa32f620-6d82-11e8-8b59-fa163e56c9b0",helpText:"Find via GET /contact_lists API"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},bento:{id:"bento",name:"Bento",icon:"/images/integrations/bento.svg",description:"Export emails to Bento",apps:["useblocks"],settingsFields:[{name:"publishable_key",type:"password",label:"Publishable Key",required:!0,placeholder:"Enter Publishable Key",fullWidth:!0,helpUrl:"https://app.bentonow.com/account/teams"},{name:"secret_key",type:"password",label:"Secret Key",required:!0,placeholder:"Enter Secret Key",fullWidth:!0},{name:"site_uuid",type:"text",label:"Site UUID",required:!0,placeholder:"Your site UUID",helpText:"Find in Bento dashboard"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be an author in your Bento account"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Broadcast Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"},{name:"inclusive_tags",type:"text",label:"Tags (inclusive)",required:!1,placeholder:"e.g., subscribers,newsletter",helpText:"Comma-separated tags to send to. Default: subscribers"}]},dotdigital:{id:"dotdigital",name:"Dotdigital",icon:"/images/integrations/dotdigital.svg",description:"Export emails to Dotdigital",apps:["useblocks"],settingsFields:[{name:"username",type:"text",label:"API Username",required:!0,placeholder:"API user email",helpText:"API user email from Settings → Access → API users",helpUrl:"https://developer.dotdigital.com/docs/setting-up-an-api-user"},{name:"password",type:"password",label:"API Password",required:!0,placeholder:"API user password",fullWidth:!0},{name:"region",type:"text",label:"Region",required:!0,placeholder:"r1, r2, or r3",helpText:"r1=Europe, r2=North America, r3=Asia Pacific"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",fullWidth:!0,extra:"Use an email registered as a Custom from address in Dotdigital (see support.dotdigital.com — “Create a custom from address”). If it does not match, export uses your account default sender."},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},getresponse:{id:"getresponse",name:"GetResponse",icon:"/images/integrations/getresponse.svg",description:"Export emails to GetResponse",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter API Key",fullWidth:!0,helpUrl:"https://app.getresponse.com/api"},{name:"from_field_id",type:"text",label:"From Field ID",required:!0,placeholder:"e.g., V",helpText:"Find via GET /from-fields API"}],exportFields:[{name:"name",type:"text",label:"Newsletter Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"campaign_id",type:"text",label:"Campaign ID",required:!0,placeholder:"e.g., C",helpText:"List/campaign ID from GET /campaigns"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},brevo:{id:"brevo",name:"Brevo",icon:"/images/integrations/brevo.svg",description:"Export emails to Brevo",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter API Key",fullWidth:!0,helpUrl:"https://help.brevo.com/hc/en-us/articles/209467485-Create-and-manage-your-API-keys"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be verified in Brevo"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"list_id",type:"number",label:"List ID",required:!0,placeholder:"e.g., 2",helpText:"Find in Contacts → Lists"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},activecampaign:{id:"activecampaign",name:"ActiveCampaign",icon:"/images/integrations/activecampaign.svg",description:"Export emails as draft campaigns to ActiveCampaign",apps:["useblocks"],settingsFields:[{name:"api_url",type:"text",label:"API URL",required:!0,placeholder:"e.g., https://youraccount.api-us1.com",helpText:"Find in Settings → Developer → API Access",helpUrl:"https://help.activecampaign.com/hc/en-us/articles/207317590-Getting-started-with-the-API"},{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter API Key",fullWidth:!0},{name:"list_id",type:"text",label:"List ID",required:!0,placeholder:"e.g., 1",extra:"Find in Lists → Click your list → The ID is in the URL (e.g., /app/contacts?listid=1)"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be verified in ActiveCampaign"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Campaign Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},salesforce_mc:{id:"salesforce_mc",name:"Salesforce",icon:"/images/integrations/salesforce.svg",description:"Export emails to Salesforce",apps:["useblocks"],settingsFields:[{name:"subdomain",type:"text",label:"Tenant Subdomain",required:!0,placeholder:"e.g., mc563885gzs27c5t9-63k636ttgm",helpText:"Find in Installed Packages → API Integration → REST Base URI",helpUrl:"https://developer.salesforce.com/docs/marketing/marketing-cloud/guide/your-subdomain-tenant-specific-endpoints.html"},{name:"client_id",type:"text",label:"Client ID",required:!0,placeholder:"From Installed Package"},{name:"client_secret",type:"password",label:"Client Secret",required:!0,placeholder:"From Installed Package"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"Must be verified in Marketing Cloud"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Email Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},hubspot:{id:"hubspot",name:"HubSpot Email",icon:"/images/integrations/hubspot.svg",description:"Export emails to HubSpot",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"Private App Access Token",required:!0,placeholder:"e.g., pat-na1-xxxx",helpUrl:"https://developers.hubspot.com/docs/api/private-apps"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"This email must be verified in HubSpot"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"name",type:"text",label:"Email Name",required:!0,placeholder:"e.g., Newsletter June 2026"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},mailchimp:{id:"mailchimp",name:"Mailchimp",icon:"/images/integrations/mailchimp.svg",description:"Export emails to Mailchimp",apps:["useblocks"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"e.g., xxxxxxxx-us1",helpUrl:"https://mailchimp.com/help/about-api-keys/"},{name:"from_email",type:"email",label:"From Email",required:!0,placeholder:"sender@example.com",extra:"This email must be verified in Mailchimp"},{name:"from_name",type:"text",label:"From Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"list_id",type:"text",label:"Audience ID",required:!0,placeholder:"e.g., a1b2c3d4e5",helpText:"Find your Audience ID in Audience settings → Audience name and defaults"},{name:"subject",type:"text",label:"Email Subject",required:!1,placeholder:"e.g., Special offer for you!"}]},enkod:{id:"enkod",name:"enKod",icon:"/images/integrations/enkod.svg",description:"Export emails to enKod",cardDescription:"Multi-channel campaigns automation (email, SMS, push, WhatsApp, and more).",apps:["emailmaker"],settingsFields:[{name:"api_key",type:"password",label:"API Key",required:!0,placeholder:"Enter enKod API key",helpUrl:"https://help.enkod.io/doku.php/api:start"},{name:"sender_email",type:"email",label:"Sender Email",required:!0,placeholder:"sender@example.com"},{name:"sender_name",type:"text",label:"Sender Name",required:!0,placeholder:"e.g., Your Company"}],exportFields:[{name:"subject",type:"text",label:"Email Subject",required:!0,placeholder:"e.g., Special offer for you!"}]}},am=(e,t)=>!e.apps||e.apps.length===0?!0:e.apps.includes(t),po=e=>{const t=sm[e];if(t&&am(t,im()))return t},lm=(e,t)=>{const n={placeholder:e.placeholder?t(e.placeholder):void 0,style:{width:"100%"}};switch(e.type){case"number":return(0,a.jsx)(_.ui_kit$InputNumber,{...n,min:1});case"email":return(0,a.jsx)(_.ui_kit$Input,{...n,type:"email"});default:return(0,a.jsx)(_.ui_kit$Input,{...n})}},cm=({integration:e,visible:t,loading:n=!1,onConfirm:o,onCancel:i,__:s})=>{const[c]=_.ui_kit$Form.useForm(),d=e.exportFields||[];(0,l.useEffect)(()=>{t||c.resetFields()},[t,c]);const u=()=>{n||c.validateFields().then(h=>{o(h)})},p=()=>{c.resetFields(),i()};if(d.length===0)return null;const f=d.find(h=>h.helpText);return(0,a.jsxs)(_.ui_kit$Modal,{title:s(`Export to ${e.name}`),open:t,onOk:u,onCancel:p,okText:s("Export"),cancelText:s("Cancel"),confirmLoading:n,cancelButtonProps:{disabled:n},children:[f&&(0,a.jsx)(_.ui_kit$Alert,{title:s(f.label),description:s(f.helpText),type:"info",showIcon:!0,style:{marginBottom:16}}),(0,a.jsx)(_.ui_kit$Form,{form:c,layout:"vertical",children:d.map(h=>(0,a.jsx)(_.ui_kit$Form.Item,{label:s(h.label),name:h.name,rules:[...h.required?[{required:!0,message:s(`Please enter ${h.label.toLowerCase()}`)}]:[],...h.type==="number"?[{type:"number",message:s(`${h.label} must be a number`)}]:[]],children:lm(h,s)},h.name))})]})},Xn=r.createApi({reducerPath:"unisenderApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createEmailMessage:e.mutation({query:t=>{const n="https://api.unisender.com/ru/api/createEmailMessage",o=new URLSearchParams;return o.append("format","json"),Object.entries(t).forEach(([i,s])=>{o.append(i,String(s))}),{url:`?proxy_url=${encodeURIComponent(n)}`,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:o.toString()}}})})}),{useCreateEmailMessageMutation:dm}=Xn,Jn=r.createApi({reducerPath:"mailganerApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://mailganer.com"}),endpoints:e=>({createMailing:e.mutation({query:t=>{const n=new URLSearchParams;return n.append("api_key",t.api_key),n.append("name",t.name),n.append("html-content",t.html_content),t.theme&&n.append("theme",t.theme),t.from_name&&n.append("from_name",t.from_name),t.from_email&&n.append("from_email",t.from_email),t.segment_id&&n.append("segment_id",String(t.segment_id)),t.utm_campaign&&n.append("utm_campaign",t.utm_campaign),t.utm_source&&n.append("utm_source",t.utm_source),t.utm_medium&&n.append("utm_medium",t.utm_medium),{url:"/api/v1/mailing/create/",method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:n.toString()}}})})}),{useCreateMailingMutation:um}=Jn,Zn=r.createApi({reducerPath:"sendsayApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://api.sendsay.ru"}),endpoints:e=>({createDraft:e.mutation({query:t=>{const n={action:"issue.draft.set",apikey:t.api_key,return_fresh_obj:1,obj:{name:t.name,letter:{subject:t.subject,"from.name":t.from_name||void 0,"from.email":t.from_email||void 0,message:{html:t.html_content}}}};return{url:`/general/api/v100/json/${t.login.split("/").map(o=>encodeURIComponent(o)).join("/")}`,method:"POST",headers:{"Content-Type":"application/json"},body:n}}})})}),{useCreateDraftMutation:pm}=Zn,er=r.createApi({reducerPath:"altcraftApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({addTemplate:e.mutation({query:t=>{const n=`${t.api_url}/api/v1.1/templates/add`,o={token:t.api_key,name:t.name,channels:[{sid:"email",fields:{html:t.html_content,text:"",subject:t.subject||t.name,from_email:t.from_email||"",from_name:t.from_name||"",replyto_email:"",replyto_name:"",is_not_inline:!0}}],is_draft:t.is_draft??!1};return{url:`?proxy_url=${encodeURIComponent(n)}`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)}}})})}),{useAddTemplateMutation:mm}=er,fm=e=>e.replace(/<style[^>]*>[\s\S]*?<\/style>/gi,"").replace(/<script[^>]*>[\s\S]*?<\/script>/gi,"").replace(/<[^>]+>/g," ").replace(/&nbsp;/g," ").replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,'"').replace(/\s+/g," ").trim(),tr=r.createApi({reducerPath:"enkodApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://api.enkod.ru"}),endpoints:e=>({createMessage:e.mutation({query:t=>{const n=fm(t.html_content)||t.subject,o={message:{subject:t.subject,fromEmail:t.sender_email||"",fromName:t.sender_name||"",html:t.html_content,plainText:n},isDraft:!0};return{url:"/v1/message/onetime/",method:"POST",headers:{"Content-Type":"application/json",Apikey:t.api_key},body:o}}})})}),{useCreateMessageMutation:gm}=tr,hm=e=>{const t=e.split("-");return t.length>1?t[1]:"us1"},_m=e=>`https://${hm(e)}.api.mailchimp.com/3.0`,nr=r.createApi({reducerPath:"mailchimpApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=_m(t.api_key),c=btoa(`anystring:${t.api_key}`),d={type:"regular",recipients:{list_id:t.list_id},settings:{subject_line:t.subject,from_name:t.from_name,reply_to:t.from_email}},u=await i({url:`?proxy_url=${encodeURIComponent(`${s}/campaigns`)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(d)});if(u.error){const y=u.error,m=y?.data?.detail||y?.error||String(u.error),E=y?.data?.errors;return{error:{status:"CUSTOM_ERROR",error:E?.length?E.map(T=>T.detail||T.title).join("; "):m}}}const p=u.data;if(!p?.id)return{error:{status:"CUSTOM_ERROR",error:u.data?.errors?.map(y=>y.detail||y.title).join("; ")||"Failed to create campaign"}};const f={html:t.html},h=await i({url:`?proxy_url=${encodeURIComponent(`${s}/campaigns/${p.id}/content`)}`,method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Basic ${c}`},body:JSON.stringify(f)});if(h.error){const y=h.error;return{error:{status:"CUSTOM_ERROR",error:y?.data?.detail||y?.error||String(h.error)}}}return{data:{id:p.id,status:p.status,web_id:p.web_id}}}})})}),{useCreateCampaignMutation:ym}=nr,mo="https://a.klaviyo.com/api",vm="2025-04-15",bm=e=>({"Content-Type":"application/json",Accept:"application/json",Authorization:`Klaviyo-API-Key ${e}`,revision:vm}),rr=r.createApi({reducerPath:"klaviyoApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=bm(t.api_key),c={data:{type:"template",attributes:{name:`Email ${Date.now()}`,editor_type:"CODE",html:t.html}}},d=await i({url:`?proxy_url=${encodeURIComponent(`${mo}/templates`)}`,method:"POST",headers:s,body:JSON.stringify(c)});if(d.error){const w=d.error,S=w?.data?.errors,I=w?.data?.detail;return{error:{status:"CUSTOM_ERROR",error:S?.length?S.map(x=>x.detail||x.status).join("; "):I||w?.error||String(d.error)}}}const u=d.data?.data?.id;if(!u)return{error:{status:"CUSTOM_ERROR",error:"Failed to create template"}};const p={data:{type:"campaign",attributes:{name:`Campaign ${Date.now()}`,audiences:{included:[t.list_id],excluded:[]},send_strategy:{method:"immediate"},"campaign-messages":{data:[{type:"campaign-message",attributes:{definition:{channel:"email",label:t.subject,content:{subject:t.subject,from_email:t.from_email,from_label:t.from_name,reply_to_email:t.from_email}}}}]}}}},f=await i({url:`?proxy_url=${encodeURIComponent(`${mo}/campaigns`)}`,method:"POST",headers:s,body:JSON.stringify(p)});if(f.error){const w=f.error,S=w?.data?.errors,I=w?.data?.detail;return{error:{status:"CUSTOM_ERROR",error:S?.length?S.map(x=>x.detail||x.status).join("; "):I||w?.error||String(f.error)}}}const h=f.data,y=h?.data?.relationships?.["campaign-messages"]?.data?.[0]?.id,m=h?.data?.id;if(!y)return{error:{status:"CUSTOM_ERROR",error:"Failed to get campaign message from campaign"}};const E={data:{type:"campaign-message",id:y,relationships:{template:{data:{type:"template",id:u}}}}},T=await i({url:`?proxy_url=${encodeURIComponent(`${mo}/campaign-message-assign-template`)}`,method:"POST",headers:s,body:JSON.stringify(E)});if(T.error){const w=T.error,S=w?.data?.errors,I=w?.data?.detail;return{error:{status:"CUSTOM_ERROR",error:S?.length?S.map(x=>x.detail||x.status).join("; "):I||w?.error||String(T.error)}}}return{data:{id:m,campaign_message_id:y}}}})})}),{useCreateCampaignMutation:Em}=rr,Sm="https://api.hubapi.com",wm=e=>({"Content-Type":"application/json",Authorization:`Bearer ${e}`}),or=r.createApi({reducerPath:"hubspotApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createEmail:e.mutation({queryFn:async(t,n,o,i)=>{const s=wm(t.api_key),c={name:t.name,subject:t.subject,from:{fromName:t.from_name,replyTo:t.from_email},content:{templatePath:"@hubspot/email/dnd/plain_text.html",widgets:{"module-0-1-1":{body:{html:t.html,path:"@hubspot/rich_text",schema_version:2},child_css:{},css:{},id:"module-0-1-1",name:"module-0-1-1",order:2,styles:{},type:"module"},"module-1-1-1":{body:{align:"center",path:"@hubspot/email_footer",schema_version:2,unsubscribe_link_type:"both"},child_css:{},css:{},id:"module-1-1-1",name:"module-1-1-1",order:3,styles:{},type:"module"}}}},d=await i({url:`?proxy_url=${encodeURIComponent(`${Sm}/marketing/v3/emails/`)}`,method:"POST",headers:s,body:JSON.stringify(c)});if(d.error){const p=d.error,f=p?.data?.errors,h=p?.data?.message;return{error:{status:"CUSTOM_ERROR",error:f?.length?f.map(y=>y.message||y.errorType).join("; "):h||p?.error||String(d.error)}}}const u=d.data;return u?.id?{data:{id:u.id}}:{error:{status:"CUSTOM_ERROR",error:d.data?.errors?.map(p=>p.message||p.errorType).join("; ")||"Failed to create email"}}}})})}),{useCreateEmailMutation:km}=or,ir=r.createApi({reducerPath:"salesforceMcApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createEmail:e.mutation({queryFn:async(t,n,o,i)=>{const s=`https://${t.subdomain}.auth.marketingcloudapis.com/v2/token`,c=await i({url:`?proxy_url=${encodeURIComponent(s)}`,method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"client_credentials",client_id:t.client_id,client_secret:t.client_secret})});if(c.error){const m=c.error;return{error:{status:"CUSTOM_ERROR",error:m?.data?.error_description||m?.data?.error||m?.error||String(c.error)}}}const d=c.data,u=d?.access_token,p=d?.rest_instance_url;if(!u||!p)return{error:{status:"CUSTOM_ERROR",error:d?.error_description||d?.error||"Failed to get access token"}};const f={name:t.name,assetType:{id:208,name:"htmlemail"},views:{html:{content:t.html},text:{},subjectline:{content:t.subject},preheader:{}},data:{email:{options:{characterEncoding:"utf-8"}}}},h=await i({url:`?proxy_url=${encodeURIComponent(`${p.replace(/\/$/,"")}/asset/v1/content/assets`)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${u}`},body:JSON.stringify(f)});if(h.error){const m=h.error,E=m?.data?.errors,T=m?.data?.message;return{error:{status:"CUSTOM_ERROR",error:E?.length?E.map(w=>w.message||w.documentation).join("; "):T||m?.error||String(h.error)}}}const y=h.data;return y?.id?{data:{id:y.id}}:{error:{status:"CUSTOM_ERROR",error:h.data?.errors?.map(m=>m.message).join("; ")||"Failed to create email"}}}})})}),{useCreateEmailMutation:Tm}=ir,Cm=e=>e.replace(/\/$/,""),Im=e=>e.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim()||" ",sr=r.createApi({reducerPath:"activecampaignApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=Cm(t.api_url),c=t.api_key,d={"Content-Type":"application/json","Api-Token":c},u=await i({url:`?proxy_url=${encodeURIComponent(`${s}/api/3/addresses`)}`,method:"GET",headers:{"Api-Token":c}});if(u.error)return{error:{status:"CUSTOM_ERROR",error:"Failed to load mailing addresses. Check your API URL and Key."}};const p=u.data?.addresses??[],f=p.find(x=>x.isDefault==="1")??p[0];if(!f?.id)return{error:{status:"CUSTOM_ERROR",error:"NO_MAILING_ADDRESS"}};const h={message:{name:t.name,fromname:t.from_name,fromemail:t.from_email,email:t.from_email,reply2:t.from_email,subject:t.subject,html:t.html,text:Im(t.html),preheader_text:"",format:"mime"}},y=await i({url:`?proxy_url=${encodeURIComponent(`${s}/api/3/messages`)}`,method:"POST",headers:d,body:JSON.stringify(h)});if(y.error){const x=y.error;return{error:{status:"CUSTOM_ERROR",error:x?.data?.message||x?.error||"Failed to create message."}}}const m=y.data?.message?.id;if(!m)return{error:{status:"CUSTOM_ERROR",error:"Message created but no ID returned."}};const E=`${s}/admin/api.php?api_action=campaign_create&api_output=json`,T=new URLSearchParams;T.append("type","single"),T.append("name",t.name),T.append("sdate","2099-12-31 12:00:00"),T.append("status","0"),T.append("public","1"),T.append("trackreads","1"),T.append("tracklinks","all"),T.append("htmlunsub","1"),T.append("textunsub","1"),T.append("addressid",String(f.id)),T.append(`p[${t.list_id}]`,t.list_id),T.append(`m[${m}]`,"100");const w=await i({url:`?proxy_url=${encodeURIComponent(E)}`,method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded","Api-Token":c},body:T.toString()});if(w.error){const x=w.error;return{error:{status:"CUSTOM_ERROR",error:x?.data?.result_message||x?.error||"Message created, but campaign creation failed."}}}const S=w.data;if(Number(S?.result_code)===0)return{error:{status:"CUSTOM_ERROR",error:S?.result_message||"Campaign creation failed (v1 API)."}};const I=S?.id;return I?{data:{campaignId:String(I)}}:{error:{status:"CUSTOM_ERROR",error:S?.result_message||"Campaign created but no ID returned."}}}})})}),{useCreateCampaignMutation:Am}=sr,xm="https://api.brevo.com/v3",ar=r.createApi({reducerPath:"brevoApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s={name:t.name,subject:t.subject,sender:{name:t.from_name,email:t.from_email},htmlContent:t.html,recipients:{listIds:[t.list_id]}},c=await i({url:`?proxy_url=${encodeURIComponent(`${xm}/emailCampaigns`)}`,method:"POST",headers:{"Content-Type":"application/json","api-key":t.api_key},body:JSON.stringify(s)});if(c.error){const u=c.error;return{error:{status:"CUSTOM_ERROR",error:u?.data?.message||u?.data?.code||u?.error||String(c.error)}}}const d=c.data;return d?.id?{data:{id:d.id}}:{error:{status:"CUSTOM_ERROR",error:c.data?.message||"Failed to create campaign"}}}})})}),{useCreateCampaignMutation:Pm}=ar,Rm="https://api.createsend.com/api/v3.3",Om=e=>`Basic ${btoa(`${e}:x`)}`,lr=r.createApi({reducerPath:"campaignMonitorApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s={Name:t.name,Subject:t.subject,FromName:t.from_name,FromEmail:t.from_email,ReplyTo:t.from_email,HtmlUrl:t.html_url,ListIDs:[t.list_id],InlineCss:!0},c=await i({url:`?proxy_url=${encodeURIComponent(`${Rm}/campaigns/${t.client_id}.json`)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:Om(t.api_key)},body:JSON.stringify(s)});if(c.error){const p=c.error;return{error:{status:"CUSTOM_ERROR",error:p?.data?.Message||p?.error||String(c.error)}}}const d=c.data,u=typeof d=="string"?d:d?.id;return!u||typeof u!="string"?{error:{status:"CUSTOM_ERROR",error:d?.Message||"Failed to create campaign"}}:{data:{id:u}}}})})}),{useCreateCampaignMutation:jm}=lr,Es="https://api.cc.email/v3",Lm=e=>e.includes("[[trackingImage]]")?e:e.replace(/<body([^>]*)>/i,"<body$1>[[trackingImage]]"),cr=r.createApi({reducerPath:"constantContactApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=Lm(t.html),c={name:t.name,email_campaign_activities:[{format_type:5,from_email:t.from_email,reply_to_email:t.from_email,from_name:t.from_name,subject:t.subject,html_content:s}]},d=await i({url:`?proxy_url=${encodeURIComponent(`${Es}/emails`)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.access_token}`},body:JSON.stringify(c)});if(d.error){const m=d.error;return{error:{status:"CUSTOM_ERROR",error:m?.data?.error_message||m?.data?.error_key||m?.error||String(d.error)}}}const u=d.data,p=u?.campaign_activities?.find(m=>m.role==="primary_email")?.campaign_activity_id,f=u?.campaign_id;if(!p||!f)return{error:{status:"CUSTOM_ERROR",error:"Failed to create campaign"}};const h={campaign_activity_id:p,campaign_id:f,role:"primary_email",contact_list_ids:[t.list_id],segment_ids:[],current_status:"DRAFT",format_type:5,from_email:t.from_email,from_name:t.from_name,reply_to_email:t.from_email,subject:t.subject,html_content:s},y=await i({url:`?proxy_url=${encodeURIComponent(`${Es}/emails/activities/${p}`)}`,method:"PUT",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.access_token}`},body:JSON.stringify(h)});if(y.error){const m=y.error;return{error:{status:"CUSTOM_ERROR",error:m?.data?.error_message||m?.data?.error_key||m?.error||String(y.error)}}}return{data:{campaign_id:f}}}})})}),{useCreateCampaignMutation:Mm}=cr,Nm="https://api.getresponse.com/v3",Dm=e=>`api-key ${e}`,dr=r.createApi({reducerPath:"getresponseApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createNewsletter:e.mutation({queryFn:async(t,n,o,i)=>{const s=t.html.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim(),c={name:t.name,type:"draft",subject:t.subject,fromField:{fromFieldId:t.from_field_id},replyTo:{fromFieldId:t.from_field_id},campaign:{campaignId:t.campaign_id},content:{html:t.html,plain:s||"Newsletter"},flags:["openrate","clicktrack"],sendSettings:{selectedCampaigns:[t.campaign_id]}},d=await i({url:`?proxy_url=${encodeURIComponent(`${Nm}/newsletters`)}`,method:"POST",headers:{"Content-Type":"application/json","X-Auth-Token":Dm(t.api_key)},body:JSON.stringify(c)});if(d.error){const p=d.error;return{error:{status:"CUSTOM_ERROR",error:p?.data?.message||p?.data?.code||p?.error||String(d.error)}}}const u=d.data;return u?.newsletterId?{data:{newsletterId:u.newsletterId}}:{error:{status:"CUSTOM_ERROR",error:d.data?.message||"Failed to create newsletter"}}}})})}),{useCreateNewsletterMutation:Fm}=dr,Bm=e=>`https://${e||"r1"}-api.dotdigital.com/v2`,Ss=(e,t)=>`Basic ${btoa(`${e}:${t}`)}`,ws=e=>e&&typeof e=="object"&&"data"in e&&e.data!==void 0?e.data:e,ks=e=>e.trim().toLowerCase(),ur=r.createApi({reducerPath:"dotdigitalApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createCampaign:e.mutation({queryFn:async(t,n,o,i)=>{const s=t.html.replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim(),c=Bm(t.region),d={"Content-Type":"application/json",Authorization:Ss(t.username,t.password)},u=await i({url:`?proxy_url=${encodeURIComponent(`${c}/custom-from-addresses`)}`,method:"GET",headers:{Authorization:Ss(t.username,t.password)}});let p=[];if(!u.error){const w=ws(u.data);Array.isArray(w)?p=w:w&&typeof w=="object"&&Array.isArray(w.items)&&(p=w.items)}const f=ks(t.from_email),h=p.find(w=>w.email&&ks(w.email)===f),y={name:t.name,subject:t.subject,fromName:t.from_name,htmlContent:t.html,plainTextContent:s||"Newsletter"},m=!h?.id;h?.id!=null&&(y.fromAddress={id:h.id});const E=await i({url:`?proxy_url=${encodeURIComponent(`${c}/campaigns`)}`,method:"POST",headers:d,body:JSON.stringify(y)});if(E.error){const w=E.error;return{error:{status:"CUSTOM_ERROR",error:w?.data?.message||w?.error||String(E.error)}}}const T=ws(E.data);return T?.id?{data:{id:T.id,usedAccountDefaultFromAddress:m}}:{error:{status:"CUSTOM_ERROR",error:E.data?.message||T?.message||"Failed to create campaign"}}}})})}),{useCreateCampaignMutation:$m}=ur,Um="https://app.bentonow.com/api/v1",zm=(e,t)=>`Basic ${btoa(`${e}:${t}`)}`,pr=r.createApi({reducerPath:"bentoApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({createBroadcast:e.mutation({queryFn:async(t,n,o,i)=>{const s={broadcasts:[{name:t.name,subject:t.subject,content:t.html,type:"raw",from:{email:t.from_email,name:t.from_name},inclusive_tags:t.inclusive_tags||"subscribers",exclusive_tags:"",segment_id:t.segment_id||"",batch_size_per_hour:500,approved:!1}]},c=`${Um}/batch/broadcasts?site_uuid=${encodeURIComponent(t.site_uuid)}`,d=await i({url:`?proxy_url=${encodeURIComponent(c)}`,method:"POST",headers:{"Content-Type":"application/json",Authorization:zm(t.publishable_key,t.secret_key),"User-Agent":"EmailMaker/1.0"},body:JSON.stringify(s)});if(d.error){const u=d.error;return{error:{status:"CUSTOM_ERROR",error:u?.data?.message||u?.error||String(d.error)}}}return{data:{count:d.data?.count??1}}}})})}),{useCreateBroadcastMutation:Gm}=pr,Wm=()=>{const{__:e}=r.useI18n(),[t,{isLoading:n}]=dm(),[o,{isLoading:i}]=um(),[s,{isLoading:c}]=pm(),[d,{isLoading:u}]=mm(),[p,{isLoading:f}]=gm(),[h,{isLoading:y}]=ym(),[m,{isLoading:E}]=Em(),[T,{isLoading:w}]=km(),[S,{isLoading:I}]=Tm(),[x,{isLoading:K}]=Am(),[Z,{isLoading:M}]=Pm(),[j,{isLoading:A}]=jm(),[O,{isLoading:z}]=Mm(),[B,{isLoading:U}]=Fm(),[de,{isLoading:me}]=$m(),[q,{isLoading:ee}]=Gm(),Fe=n||i||c||u||f||y||E||w||I||K||M||A||z||U||me||ee,ze={unisender:async(C,P,N,D)=>{try{const v=await t({api_key:C.api_key,sender_name:C.sender_name,sender_email:C.sender_email,subject:D,body:N,list_id:P.list_id,generate_text:1,lang:"ru"}).unwrap();return v.result?.message_id?{success:!0,message:e("Email successfully created!"),link:{url:`https://app.unisender.com/ru/v5/spa/email-campaign/editor/${v.result.message_id}?step=send`,text:e("Open in Unisender")}}:v.error?{success:!1,error:v.error+(v.code?` (${v.code})`:"")}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create email")}}},mailganer:async(C,P,N,D)=>{try{const v=await o({api_key:C.api_key,name:P.name,html_content:N,theme:P.theme||D,from_name:C.from_name,from_email:C.from_email}).unwrap();return v.status===1&&v.public_id?{success:!0,message:e("Mailing successfully created!"),link:v.step1_url?{url:v.step1_url,text:e("Open in Mailganer")}:void 0}:v.error?{success:!1,error:v.error}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create mailing")}}},sendsay:async(C,P,N,D)=>{try{const v=await s({login:C.login,api_key:C.api_key,name:P.name,subject:P.subject,html_content:N,from_name:C.from_name,from_email:C.from_email}).unwrap();return v.obj?.id?{success:!0,message:e("Draft successfully created!"),link:{url:`https://app.sendsay.ru/content/drafts/email/${v.obj.id}/settings`,text:e("Open in Sendsay")}}:v.errors&&v.errors.length>0?{success:!1,error:v.errors.map(W=>W.explain).join(", ")}:v.error?{success:!1,error:v.explain||v.error}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create draft")}}},altcraft:async(C,P,N,D)=>{try{const v=await d({api_url:C.api_url,api_key:C.api_key,name:P.name,html_content:N,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email}).unwrap();return v.error===0?{success:!0,message:e("Template successfully created!")}:{success:!1,error:v.error_text||e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create template")}}},enkod:async(C,P,N,D)=>{try{const v=await p({api_key:C.api_key,subject:P.subject,html_content:N,sender_name:C.sender_name,sender_email:C.sender_email}).unwrap();if(v.success||v.messageId||v.id){const W=v.messageId||v.id;return{success:!0,message:e("Draft successfully created!"),link:W?{url:`https://app.enkod.ru/ensend/messages/detail/${W}/preview`,text:e("Open in enKod")}:void 0}}else if(v.error||v.message)return{success:!1,error:v.error||v.message||e("Unknown error")};return{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create draft")}}},mailchimp:async(C,P,N,D)=>{try{const v=await h({api_key:C.api_key,list_id:P.list_id,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html:N}).unwrap();if(v.id){const W=C.api_key?.split("-")[1]||"us1";return{success:!0,message:e("Campaign successfully created!"),link:{url:`https://${W}.admin.mailchimp.com/campaigns/#r:campaignId=${v.id}`,text:e("Open in Mailchimp")}}}return{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},klaviyo:async(C,P,N,D)=>{try{const v=await m({api_key:C.api_key,list_id:P.list_id,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html:N}).unwrap();return v.id?{success:!0,message:e("Campaign successfully created!"),link:{url:`https://www.klaviyo.com/campaign/${v.id}/wizard/1`,text:e("Open in Klaviyo")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},hubspot:async(C,P,N,D)=>{try{const v=await T({api_key:C.api_key,name:P.name,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html:N}).unwrap();return v.id?{success:!0,message:e("Email successfully created!"),link:{url:`https://app.hubspot.com/email/0/edit/${v.id}`,text:e("Open in HubSpot")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create email")}}},salesforce_mc:async(C,P,N,D)=>{try{const v=await S({subdomain:C.subdomain,client_id:C.client_id,client_secret:C.client_secret,name:P.name,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html:N}).unwrap();return v.id?{success:!0,message:e("Email successfully created!"),link:{url:`https://app.s7.exacttarget.com/ContentBuilder?app=contentbuilder&id=${v.id}`,text:e("Open in Marketing Cloud")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create email")}}},activecampaign:async(C,P,N,D)=>{try{const v=await x({api_url:C.api_url,api_key:C.api_key,list_id:C.list_id,name:P.name,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html:N}).unwrap();if(v.campaignId){const W=(C.api_url||"").replace(/\/$/,"").match(/https?:\/\/([^.]+)\.api-/),Pe=W?W[1]:"",Ae=Pe?`https://${Pe}.activehosted.com/app/campaigns/${v.campaignId}`:"https://www.activecampaign.com/app/campaigns";return{success:!0,message:e("Draft campaign created! Open it to review and schedule."),link:{url:Ae,text:e("Open draft campaign")}}}return{success:!1,error:e("Unknown error")}}catch(v){const W=v.message||v.error||"";if(W==="NO_MAILING_ADDRESS"){const Pe=(C.api_url||"").replace(/\/$/,"").match(/https?:\/\/([^.]+)\.api-/),Ae=Pe?Pe[1]:"",Qe=Ae?`https://${Ae}.activehosted.com/app/settings/addresses`:"https://www.activecampaign.com/app/settings/addresses";return{success:!1,error:e("No mailing address found. Add one in ActiveCampaign: ")+Qe}}return{success:!1,error:W||e("Failed to create campaign")}}},brevo:async(C,P,N,D)=>{try{const v=await Z({api_key:C.api_key,list_id:Number(P.list_id),name:P.name,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html:N}).unwrap();return v.id?{success:!0,message:e("Campaign successfully created!"),link:{url:`https://app.brevo.com/marketing-campaign/edit/${v.id}`,text:e("Open in Brevo")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},campaign_monitor:async(C,P,N,D)=>{try{const v=P.html_url?.trim();if(!v)return{success:!1,error:e("HTML URL is required. Save the email first, or paste a custom URL to your hosted HTML.")};const W=await j({api_key:C.api_key,client_id:C.client_id,list_id:P.list_id,name:P.name,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html_url:v.trim()}).unwrap();return W.id?{success:!0,message:e("Campaign successfully created!"),link:{url:`https://app.createsend.com/campaigns/#/${W.id}`,text:e("Open in Campaign Monitor")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},constant_contact:async(C,P,N,D)=>{try{return(await O({access_token:C.access_token,list_id:P.list_id,name:P.name,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html:N}).unwrap()).campaign_id?{success:!0,message:e("Campaign successfully created!"),link:{url:"https://app.constantcontact.com/pages/email/campaigns",text:e("Open in Constant Contact")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},getresponse:async(C,P,N,D)=>{try{const v=await B({api_key:C.api_key,from_field_id:C.from_field_id,campaign_id:P.campaign_id,name:P.name,subject:P.subject||D,html:N}).unwrap();return v.newsletterId?{success:!0,message:e("Newsletter successfully created!"),link:{url:`https://app.getresponse.com/letter/${v.newsletterId}`,text:e("Open in GetResponse")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create newsletter")}}},dotdigital:async(C,P,N,D)=>{try{const v=await de({username:C.username,password:C.password,region:C.region||"r1",name:P.name,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html:N}).unwrap();return v.id?{success:!0,message:v.usedAccountDefaultFromAddress?e("Campaign created. Dotdigital used your account default sender because this From email is not registered as a custom from address. Add the address in Dotdigital and export again to use it."):e("Campaign successfully created!"),link:{url:"https://login.dotdigital.com/",text:e("Open in Dotdigital")}}:{success:!1,error:e("Unknown error")}}catch(v){return{success:!1,error:v.message||e("Failed to create campaign")}}},bento:async(C,P,N,D)=>{try{return await q({publishable_key:C.publishable_key,secret_key:C.secret_key,site_uuid:C.site_uuid,name:P.name,subject:P.subject||D,from_name:C.from_name,from_email:C.from_email,html:N,inclusive_tags:P.inclusive_tags}).unwrap(),{success:!0,message:e("Broadcast successfully created!"),link:{url:"https://app.bentonow.com/",text:e("Open in Bento")}}}catch(v){return{success:!1,error:v.message||e("Failed to create broadcast")}}}};return{exportToIntegration:async(C,P,N,D,v)=>{const W=ze[C];return W?W(P,N,D,v):{success:!1,error:e("Unknown integration")}},isLoading:Fe}},Rt={INFO:"info",STORAGE:"storage",STYLES:"styles",MEMBERS:"members",INTEGRATIONS:"integrations",PLUGIN:"plugin"},eb=Rt.INFO,tb=[Rt.INFO,Rt.STORAGE,Rt.STYLES,Rt.MEMBERS,Rt.INTEGRATIONS,Rt.PLUGIN],nb={mainsettings:Rt.INFO,ftpsettings:Rt.STORAGE,webhooksettings:Rt.INTEGRATIONS},Hm=async(e,t,n)=>{try{const{notification:o,...i}=e,s=await r.fetchBaseQuery({baseUrl:"https://racs.rest/v3"})(i,t,n);if(s.error)throw new Error;return s}catch(o){return(e?.notification).error(o),{error:o}}},mr=r.createApi({reducerPath:"exportPngApi",baseQuery:Hm,endpoints:e=>({makeTemporaryMailForPng:e.mutation({query:({file:t,title:n,notification:o})=>{const i=new Blob([t],{type:"text/html"}),s=new FormData;return s.append("file",i,"base.html"),s.append("contentType","text/html"),{url:"?resource=exportPngApi",method:"POST",body:s,notification:o}}}),deleteTemporaryMail:e.mutation({query:({id:t,notification:n})=>({url:`/${t}?resource=exportPngApi`,method:"DELETE",notification:n})})})}),{useMakeTemporaryMailForPngMutation:qm,useDeleteTemporaryMailMutation:Vm}=mr,fr=r.createApi({reducerPath:"webHookApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({postDataByWebHook:e.mutation({query:({url:t,body:n})=>({url:`?proxy_url=${encodeURIComponent(t)}`,method:"POST",body:n})})})}),{usePostDataByWebHookMutation:Km}=fr,Ym=async(e,t,n)=>{try{const{notification:o,...i}=e,s=await r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"})(i,t,n);if(s.error)throw new Error;return s}catch(o){return(e?.notification).error(o),{error:o}}},gr=r.createApi({reducerPath:"htmlToPdfPlusApi",baseQuery:Ym,endpoints:e=>({generateHtmlToPdf:e.mutation({query:({htmlContent:t,notification:n})=>({url:"emails/pdf",method:"POST",body:t,notification:n,responseHandler:o=>o.blob()})})})}),{useGenerateHtmlToPdfMutation:Qm}=gr,hr=r.createApi({reducerPath:"proxyApi",tagTypes:["Proxy"],baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/wp-json/cors-proxy/v1/get"}),endpoints:e=>({getFile:e.query({queryFn({url:t,tryFetch:n=!0,type:o},i){const s=r.clientFromApi(i),c=n?fetch(t):Promise.reject(),d=p=>{switch(o){case"json":return p.json();case"text":return p.text();default:return p.blob()}},u=p=>d(p).then(f=>({data:f}));return c.then(p=>u(p)).catch(()=>s.corsProxy.get_list({format:"blob",extraQuery:{url:encodeURIComponent(t)}}))}})})}),{useGetFileQuery:rb,useLazyGetFileQuery:Xm}=hr,ob="email",ib=100;function Jm(e){return yt.sanitizeFileName(String(e??"").trim()).slice(0,100).trimEnd()||"email"}function Ts(e){const t=Jm(e);return{archive:`${t}.zip`,desktop:`${t}-desktop.png`,mobile:`${t}-mobile.png`}}function Zm(e,t){const n=Ts(e);return{[n.desktop]:t.desktop,[n.mobile]:t.mobile}}var fo=()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/41a7e33c.js")).then(e=>e.import_exports),void 0,{}.url),ef=1,tf=2,nf=375,Dt={fontSize:"16px"},rf={position:"absolute",bottom:-4,right:-4,borderRadius:"100%",backgroundColor:r.emCssVar("colorBgContainer")},of={position:"relative",display:"inline-flex"},qt=({icon:e,locked:t,strokeWidth:n,className:o})=>(0,a.jsxs)("span",{className:o,style:of,children:[e,t&&(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:12,strokeWidth:n,style:rf})]}),sf=({email:e,autoSaveBlockResult:t})=>{const{__:n,_x:o}=r.useI18n(),i=r.useDispatch(),s=r.useEmailAttributesWriter(),[c]=Xm(),[d]=r.useUploadImageMutation(),u=r.useAppNavigate(),{owner:p,admin:f}=Qn(),h=r.useCurrentUser(),y=r.useProjectData(),{modal:m}=_.ui_kit$App.useApp(),E=r.useNotification(),{confirm:T}=m,w=r.useAppStore(),S=()=>on(g.getContainer(w)).keepWrappedOnOutput,I=(L,V,X,oe)=>yt.prepareHTML(L,V,X,oe,S()),x=(L,V,X,oe,re,H)=>yt.getEML(L,V,X,oe,re,H,S()),K=(L,V,X,oe,re)=>yt.htmlToFilesData(L,V,X,oe,re,S()),Z=r.useCookieManager(),M=r.useAppConfig(),j=vs(),{beeFreeConverterEnabled:A,aiLayoutConverterEnabled:O}=j,z=r.useEditorProjectId(),B=r.useEventEmitter(g.events.ON_EMAIL_CLONE_ID),U=r.useEventEmitter(g.events.ON_BROWSER_EXTENSION_DETECTED_ID),[de]=Km(),me=!0,{data:q}=r.useGetProjectIntegrationsQuery(y?.id??0,{skip:me}),{data:ee}=r.useGetProjectWebhookQuery(y?.id??0,{skip:me}),[Fe]=r.useLazyGetIntegrationCredentialsQuery(),{exportToIntegration:be,isLoading:et}=Wm(),Ee=r.usePushToDataLayer(),[fe,Q]=(0,l.useState)(()=>!Ht(g.getContainer(w)).contentShown()),[pe,se]=(0,l.useState)(!1),[ae,Ie]=(0,l.useState)(null),[Te,Be]=(0,l.useState)(""),[J,_e]=(0,l.useState)(!1),[Ce,ge]=(0,l.useState)(0),[Oe,ze]=(0,l.useState)(null),[k,C]=(0,l.useState)(""),[P,N]=(0,l.useState)(!1),D=r.usePlanFeatureGate("export_html"),v=r.usePlanFeatureGate("export_pdf"),W=r.usePlanFeatureGate("export_png");r.usePlanFeatureGate("export_webhook");const Pe=r.usePlanFeatureGate("export_platforms"),Ae=r.usePlanFeatureGate("export_amp"),Qe=r.usePlanFeatureGate("template_import"),Ge=r.usePlanFeatureGate("code_minify"),Ze=L=>{_e(!0),ge(r.FEATURE_UPSELL_SLIDE[L])},[pt]=r.emailsApi.useDeleteEmailMutation(),bt=async(L,V)=>{try{const X=await pt(L.id).unwrap();L.project,E.success(n('The email "')+X.title+o('" was successfully removed.',"email")),Ee({event:"delete",action:"delete_email",entity_type:"email",entity_id:L.id,project_id:L.project,context:"editor"})}catch(X){E.error(X)}},[ft,lt]=r.useAddEmailMutation(),[G]=qm(),[Y]=Vm(),[ne]=Qm(),ue=r.useProjectData(),he=r.useInvalidateTerms(),We=r.useSelector(r.selectIsHeaderCodeMenuOpen);(0,l.useEffect)(()=>{We.switched&&Q(!1)},[We]);const Ve=()=>{const{title:L}=e;return L===null?n("New email title"):L},st=(L,V,X=!1)=>{const oe=r.getCodeSize(L);X&&r.isCodeSizeExceeded(oe)?(Be(L),Ie(()=>V),se(!0)):V(L)},Bt=()=>{if(se(!1),Ge.isLocked){Ze("code_minify");return}if(ae&&Te){r.getCodeSize(Te);const L=r.minifyHtml(Te);r.getCodeSize(L),ae(L),Ie(null),Be("")}},Me=()=>{se(!1),ae&&Te&&(ae(Te),Ie(null),Be(""))},Xe=()=>{se(!1),Ie(null),Be("")},ie=r.useContentReader(),te=r.useContentReplacer(),$=r.useEvent(g.events.ON_EMAIL_INIT_ID),le=r.useEventEmitter(g.events.ON_LAYOUT_CONVERT_REQUEST_ID);(0,l.useEffect)(()=>{const L=$(()=>{Q(!1)});return()=>L.dispose()},[$]);const xe=async(L,V=ie())=>{const X=document.querySelector(".email-preview"),oe=getComputedStyle(X);return V=await I(V,[oe.width],e.utm_parameters,async re=>{ot(re)}),G({file:V,title:Ve(),notification:E}).unwrap().then(re=>{const H={id:re._id,...re};return L(H,()=>Y({id:H.id,notification:E}))}).catch(re=>{E.error({title:re.data?.code,description:re.data?.message})})},Se=(L,V=1)=>xe((X,oe)=>({hrefs:L.map(re=>r.previewHrefForRacs(X.id,void 0,!1,V,void 0,void 0,re)),dispose:oe})),Ne=(L,V,X=2)=>xe((oe,re)=>({data:L.map(H=>({selector:H,href:r.previewHrefForRacs(oe.id,void 0,!1,X,H)})),dispose:re}),V),He=async(L,V)=>{const X=typeof L=="string"?(await c({url:L}))?.data:L;if(!X)return typeof L=="string"?L:"";let oe=r.decodeFileNameFromPath(V);if(typeof L=="string"&&/^https?:\/\//i.test(L)){const qe=r.decodeFileNameFromUrl(L);qe&&(oe=qe)}const re=X,{ensureFileExtension:H,extractUploadResult:ke}=await fo();oe=await H(oe,re.type||"");const ye=new File([re],oe.toLowerCase(),{type:re.type||""});try{const qe=ke(await d({user_id:h.id,folder:String(ue.id),file:ye}).unwrap());if(qe.error)return typeof L=="string"?L:"";if(qe.file_url)return qe.file_url}catch{}return typeof L=="string"?L:""},$e=async L=>{const V=L.document.querySelectorAll("[em-operation=exportAsPicture]"),X=new Map;for(let oe=0,re=V.length;oe<re;oe++){const H=V[oe];H.setAttribute("em-export-id",String(oe)),X.set(`[em-export-id='${oe}']`,H)}X.size&&L.handleRender(async({contentDocument:oe,managedNodeController:re})=>{try{const{data:H,dispose:ke}=await Ne([...X.keys()],r.getOuterHtml(oe),tf);try{const ye=H.map(async({href:qe,selector:hn},Dn)=>{const mt=X.get(hn);if(mt.tagName==="TD"){mt.removeAttribute("style");for(const _t of[...mt.classList])_t.startsWith("em-mob-")&&mt.classList.remove(_t)}re.commit();const Fr=await He(qe,`${Dn}-${mt.tagName.toLowerCase()}.png`),_n=parseInt(getComputedStyle(mt).width);let wt=new Image(_n);wt.setAttribute("border","0"),wt.setAttribute("style",`display: block; width: 100%; max-width: ${_n}px;`),wt.alt="",wt.src=Fr;const yn=mt.querySelector("a");if(yn){const _t=document.createElement("a");_t.setAttribute("target","_blank"),_t.setAttribute("href",yn.getAttribute("href")),_t.appendChild(wt),wt=_t}if(mt.tagName==="TD"){const _t=mt.cloneNode();_t.removeAttribute("em-operation"),_t.appendChild(wt),wt=_t}mt.replaceWith(wt),re.commit()});await Promise.all(ye)}catch{}finally{ke()}}catch{}})},ot=L=>{const V=L.document;if(ue?.limits?.preview_limit==="0"&&z&&h?.counters?.emails_counter>2&&!V.querySelector(".em-powered-logo")){const X=`<a href="${`https://https://racs.rest/v3/v3/link?app=useblocks&project=${z}&email=${e.id}&link=https%3A%2F%2Fuseblocks.io`}" target="_blank"><img src="https://https://racs.rest/v3/v3/pixel/123.png?image=https://cdn.useblocks.io/blocks/powered.png&project=${z}&email=${e.id}" width="150" height="50" border="0" alt="" style="display: inline-block; width: 100%; max-width: 150px;"></a>`;V.querySelector("body > table:last-child > tbody:last-child > tr:last-child, body > div > table:last-child > tbody:last-child > tr:last-child")&&V.querySelector("body > table:last-child > tbody:last-child > tr:last-child, body > div > table:last-child > tbody:last-child > tr:last-child").insertAdjacentHTML("afterend",`<tr em="block" class="em-powered-logo">
856
856
  <td align="center" bgcolor="#FFFFFF">${X}</td>
857
- </tr>`)}},fn=async()=>{const L=ie();st(L,async V=>{try{const X=document.querySelector(".email-preview"),oe=getComputedStyle(X),re=await A(V,[oe.width],e.utm_parameters,async qe=>{ot(qe)}),H=await ne({htmlContent:re,notification:S}).unwrap(),ke=window.URL.createObjectURL(new Blob([H],{type:"application/pdf"})),ye=document.createElement("a");ye.href=ke,ye.setAttribute("download",`${Ve()}.pdf`),document.body.appendChild(ye),ye.click(),document.body.removeChild(ye),window.URL.revokeObjectURL(ke)}catch{}})},Ot=L=>{const V=ie();st(V,X=>{Ee({event:"click",action:"export_email",export_type:"HTML"});const oe=document.querySelector(".email-preview"),re=getComputedStyle(oe);A(X,[re.width],e.utm_parameters,async H=>{await $e(H),ot(H),await r.processAmp(H,L)}).then(H=>{const ke=new Blob([H],{type:"text/html;charset=utf-8"});(0,sn.saveAs)(ke,`${Ve()}.html`)}).catch(H=>{})},!0)},ct=L=>{const V=ie();st(V,X=>{Ee({event:"click",action:"export_email",export_type:"TEXT"});const oe=document.querySelector(".email-preview"),re=getComputedStyle(oe);A(X,[re.width],e.utm_parameters,async H=>{await $e(H),ot(H),await r.processAmp(H,L);const[{htmlToText:ke},{EmailTextPlainConvertOptions:ye}]=await Promise.all([(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/6a939bac.js")),void 0,{}.url),(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/c28968c1.js")),void 0,{}.url)]);H.handleReadHtml(qe=>{qe.html=ke(qe.contentDocument,ye)})}).then(H=>{const ke=new Blob([H],{type:"text/plain;charset=utf-8"});(0,sn.saveAs)(ke,`${Ve()}.txt`)}).catch(H=>{})})},Et=()=>{const L=ie();st(L,V=>{Ee({event:"click",action:"export_email",export_type:"MARKDOWN"});const X=document.querySelector(".email-preview"),oe=getComputedStyle(X),{utm_parameters:re}=e;A(V,[oe.width],re,async H=>{ot(H),await r.processAmp(H,"html");const{htmlToMarkdown:ke}=await(0,Ke.__vitePreload)(async()=>{const{htmlToMarkdown:ye}=await Promise.resolve().then(()=>ve("./static/core/9ea82ab5.js"));return{htmlToMarkdown:ye}},void 0,{}.url);H.handleReadHtml(ye=>{ye.html=ke(ye.contentDocument)})}).then(H=>{const ke=new Blob([H],{type:"text/markdown;charset=utf-8"});(0,sn.saveAs)(ke,`${Ve()}.md`)}).catch(H=>r.reportError(H,{origin:"markdown-export"}))})},Lt=L=>{const V=ie();st(V,X=>{Ee({event:"click",action:"export_email",export_type:"Clipboard"});const oe=document.querySelector(".email-preview"),re=getComputedStyle(oe);A(X,[re.width],e.utm_parameters,async H=>{await $e(H),ot(H),await r.processAmp(H,L)}).then(H=>navigator.clipboard.writeText(H).then(function(){S.success(n("The email has been copied to the clipboard."))})).catch(H=>{})},!0)},Rn=async L=>{Re&&po(Re)},On=()=>{ze(null),T("")},gn=async()=>{if(!P){N(!0);try{const L=await Se([800,ef],Jm);if(!L)return;const{hrefs:V,dispose:X}=L;try{const[oe,re]=await Promise.all(V.map(ye=>yt.getImageByUrl(ye).then(qe=>yt.imageToBlob(qe)))),H=Ve(),ke=await yt.htmlFilesToZip(Xm(H,{desktop:oe,mobile:re}));(0,sn.saveAs)(ke,ks(H).archive),Ee({event:"click",action:"export_email",export_type:"Image"})}finally{X()}}catch{S.error({title:n("Error"),description:n("Failed to export the email as images. Please try again.")})}finally{N(!1)}}},Ln=L=>{const V=Z.get(r.APP_COOKIES.em_token);return fetch(`https://app.useblocks.io/api/wp-json/cors-proxy/v1/get?url=${encodeURIComponent(L)}`,{headers:{authorization:`Bearer ${V}`}}).then(X=>X.blob())},Mn=L=>new Promise((V,X)=>{const oe=()=>Ln(L).then(V,X);fetch(L).then(re=>V(re.blob()),oe).catch(()=>{})}),gt=(L,V)=>{const X=ie();st(X,oe=>{Ee({event:"click",action:"export_email",export_type:"Outlook"});const re=document.querySelector(".email-preview"),H=getComputedStyle(re),ke=async(ye,qe)=>{ye.document,await r.processAmp(ye,qe),await $e(ye),ot(ye)};x(e.title,oe,[H.width,H.height],e.utm_parameters,L?ye=>ke(ye,"html"):ye=>ke(ye),V?{embedImagesAsBase64:!0,getImageBlob:Mn}:void 0).then(ye=>{const qe=new Blob([ye],{type:"text/html;charset=utf-8"});(0,sn.saveAs)(qe,`${Ve()}.eml`)}).catch(ye=>{})})},St=L=>{k({centered:!0,mask:{closable:!0},title:n("Embed images in the file?"),content:n('If "Yes", images will be included in the file itself. This is useful for offline viewing or if external images are blocked, but increases file size. If "No", images will be loaded from external links.'),okText:n("Yes"),cancelText:n("No"),onOk:()=>gt(L,!0),onCancel:()=>gt(L,!1)})},ce=async()=>{const L=ie();st(L,async V=>{Ee({event:"click",action:"export_email",export_type:"ZIP"});const X=document.querySelector(".email-preview"),oe=getComputedStyle(X),re=await Y(V,[oe.width,void 0],e.utm_parameters,Mn,async ke=>{await $e(ke),ot(ke),Tt&&await r.processAmp(ke,"html")});Tt&&(re["amp.html"]=await A(V,[oe.width],e.utm_parameters,async ke=>{await $e(ke),ot(ke),await r.processAmp(ke,"amp")}));const H=await yt.htmlFilesToZip(re);(0,sn.saveAs)(H,`${Ve()}.zip`)},!0)},we=async()=>{if(Ee({event:"click",action:"duplicate_email",entity_type:"email",entity_id:e.id,project_id:e.project,context:"editor"}),e.isNew)S.warning({title:n("To create a copy, you need to save the email.")});else{if((await B.fire(e)).some(L=>L===!1))return;ft({title:xt.generateCopyTitle(e.title),...e.meta!==void 0?{meta:e.meta}:{},project:Number(ue?.id),description:e.description,html:xt.generateCopyHtml(ie()||"",String(e.title)),parent_email:e.parent_email||6892,common_styles:e.common_styles||"",utm_parameters:{utm_source:e.utm_parameters?.utm_source,utm_medium:e.utm_parameters?.utm_medium,utm_campaign:e.utm_parameters?.utm_campaign,utm_term:e.utm_parameters?.utm_term,utm_content:e.utm_parameters?.utm_content},emailtags:e.emailtags,folder:e.folder}).unwrap().then(L=>{u(`/projects/${ue.id}/emails/${L.id}`),S.success({title:n('The copy of email "')+e.title+n('" was successfully created.')}),Ee({event:"duplicate",action:"duplicate_email_success",entity_type:"email",entity_id:e.id,cloned_entity_id:L.id,project_id:e.project,context:"editor"}),he("folder")}).catch(L=>{S.error({title:L.data.code,description:L.data.message})})}},De=()=>{Ee({event:"click",action:"click_delete_email_menu_item",entity_type:"email",entity_id:e.id,project_id:e.project,context:"editor"}),e.isNew?S.success(n("The draft of the email has been deleted.")):nt(e,u)},nt=(L,V)=>{Ee({event:"open",action:"open_delete_email_modal",entity_type:"email",entity_id:L.id,project_id:L.project,context:"editor"}),k({mask:{closable:!0},centered:!0,title:o('Are you sure to delete "',"email")+L.title+n('" email?'),icon:(0,a.jsx)(r.EmIcons,{icon:"DeleteOutlined",component:_.icons$DeleteOutlined,size:22,style:{color:_.ui_kit$iconColors.danger,marginInlineEnd:12,flexShrink:0}}),okText:n("Yes"),cancelText:n("No"),onOk:()=>bt(L,V)})},Oe=()=>{fo().catch(()=>{}),r.uploadFile("application/zip, message/rfc822, text/html",Yt)},Yt=async L=>{const V=L[0];try{i(r.setIsGlobalLoading(!0));const{createDocumentProcessor:X,createFileProcessor:oe,importEmail:re}=await fo(),{html:H,hasBrowserExtensionArtifacts:ke}=await re(V,oe(c,d,g,ue,M),X(V))??{html:"",hasBrowserExtensionArtifacts:!1};ke&&U.fire();const[ye]=yt.getFileNameAndExt(V.name.replaceAll("&nbsp;"," ")),qe=ye||xt.getTitleFromHtml(H)||"";te(H,{undoable:!0}),s({title:qe}),i(r.setIsGlobalLoading(!1)),le.fire({html:H})}catch(X){i(r.setIsGlobalLoading(!1));const oe=X instanceof Error?X.message:X;S.error({title:oe})}Ee({event:"upload_file",action:"import_email"})},$t=()=>{const L=ie();L&&(Ee({event:"click",action:"convert_layout"}),le.fire({html:L}))},dt=[];M.emailDropdownMenuClone&&dt.push({label:n("Clone"),icon:(0,a.jsx)(r.EmIcons,{icon:"CopyOutlined",component:_.icons$CopyOutlined,size:16,strokeWidth:M.iconStrokeWidth}),key:"Clone",className:"em-analytics__email-clone",disabled:lt.isLoading,onClick:we}),M.emailDropdownMenuImport&&dt.push({label:o("Import","verb"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"CloudUploadOutlined",component:_.icons$CloudUploadOutlined,style:Dt}),locked:Qe.isLocked,strokeWidth:M.iconStrokeWidth}),key:"Import",className:"em-analytics__editor-page__import",onClick:()=>{if(Qe.isLocked){Ze("template_import");return}Ee({event:"click",action:"import_email"}),Oe()}});const Nn=ie(),Ut=!e.hasOwnProperty("type")&&vs(Nn,O)!==null;M.emailDropdownMenuConvert&&Ut&&dt.push({label:n("Convert"),icon:(0,a.jsx)(r.EmIcons,{icon:"SwapOutlined",component:_.icons$SwapOutlined,size:16,strokeWidth:M.iconStrokeWidth}),key:"ConvertLayout",className:"em-analytics__email-convert",onClick:$t}),(p||f||g.id?.toString()===e.author?.toString())&&(M.emailDropdownMenuLock&&dt.push({label:(0,a.jsx)(_s,{element:e,context:"editor"},"Lock"),icon:e.lock?(0,a.jsx)(r.EmIcons,{icon:"UnLock",component:_.icons$UnLock,size:16,strokeWidth:M.iconStrokeWidth}):(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:16,strokeWidth:M.iconStrokeWidth}),disabled:e.isNew}),M.emailDropdownMenuRemove&&dt.push({label:n("Remove"),icon:(0,a.jsx)(r.EmIcons,{icon:"DeleteOutlined",component:_.icons$DeleteOutlined,size:16,strokeWidth:M.iconStrokeWidth}),key:"Remove",className:"em-analytics__email-remove",style:{color:"#ff4d4f"},onClick:De}));const Tt=e.isAmp,It=[],Dr=()=>[...Tt?[{key:"html_txt",label:`${n("Plain text")} (HTML)`,onClick:()=>ct("html")},{key:"сode_txt",label:`${n("Plain text")} (AMP)`,onClick:()=>ct("amp")}]:[{key:"plain_txt",label:n("Plain text"),onClick:()=>ct()}],{key:"markdown",label:n("Markdown"),onClick:()=>Et()}];M.exportHtmlEnabled&&It.push({key:"html",label:n("Code"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FileTextOutlined",component:_.icons$FileTextOutlined,style:Dt}),locked:D.isLocked,strokeWidth:M.iconStrokeWidth}),...D.isLocked?{onClick:()=>Ze("export_html")}:Tt?{children:[{key:"сode_html",label:n("AMP"),onClick:()=>Ae.isLocked?Ze("export_amp"):Ot("amp")},{key:"html_amp",label:n("HTML"),onClick:()=>Ot("html")}]}:{onClick:()=>Ot()}}),M.exportZipEnabled&&It.push({key:"zip",label:n("ZIP"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FileZipOutlined",component:_.icons$FileZipOutlined,style:Dt}),locked:D.isLocked,strokeWidth:M.iconStrokeWidth}),...D.isLocked?{onClick:()=>Ze("export_html")}:{onClick:()=>ce().catch(L=>{})}}),M.exportClipboardEnabled&&It.push({key:"clipboard",label:n("Clipboard"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"SnippetsOutlined",component:_.icons$SnippetsOutlined,style:Dt}),locked:D.isLocked,strokeWidth:M.iconStrokeWidth}),...D.isLocked?{onClick:()=>Ze("export_html")}:Tt?{children:[{key:"clipboard_html",label:n("AMP"),onClick:()=>Ae.isLocked?Ze("export_amp"):Lt("amp")},{key:"clipboard_amp",label:n("HTML"),onClick:()=>Lt("html")}]}:{onClick:()=>Lt()}}),M.exportTextEnabled&&It.push({key:"text",label:n("Text"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FileOutlined",component:_.icons$FileOutlined,style:Dt}),locked:D.isLocked,strokeWidth:M.iconStrokeWidth}),...D.isLocked?{onClick:()=>Ze("export_html")}:M.exportMarkdownEnabled?{children:Dr()}:Tt?{children:[{key:"сode_txt",label:n("AMP"),onClick:()=>Ae.isLocked?Ze("export_amp"):ct("amp")},{key:"html_txt",label:n("HTML"),onClick:()=>ct("html")}]}:{onClick:()=>ct()}}),M.exportOutlookEnabled&&It.push({key:"outlook",icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FileWordOutlined",component:_.icons$FileWordOutlined,style:Dt}),locked:Pe.isLocked,strokeWidth:M.iconStrokeWidth}),label:n("Outlook"),onClick:()=>Pe.isLocked?Ze("export_platforms"):St(!!Tt)}),M.exportPdfEnabled&&It.push({key:"pdf",icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FilePdfOutlined",component:_.icons$FilePdfOutlined,style:Dt}),locked:v.isLocked,strokeWidth:M.iconStrokeWidth}),label:n("PDF"),onClick:()=>v.isLocked?Ze("export_pdf"):fn()}),M.exportPngEnabled&&It.push({key:"img",icon:(0,a.jsx)(qt,{icon:P?(0,a.jsx)(r.EmIcons,{icon:"LoadingOutlined",component:_.icons$LoadingOutlined,spin:!0,style:Dt}):(0,a.jsx)(r.EmIcons,{icon:"FileImageOutlined",component:_.icons$FileImageOutlined,style:Dt}),locked:W.isLocked,strokeWidth:M.iconStrokeWidth}),label:n("PNG"),disabled:!W.isLocked&&P,onClick:()=>W.isLocked?Ze("export_png"):gn()});const ht=e.author;return(0,a.jsxs)(_.ui_kit$Space,{children:[M.emailDropdownMenuEnabled?(0,a.jsx)(_.ui_kit$Dropdown,{arrow:{pointAtCenter:!0},placement:"bottom",menu:{items:dt},children:(0,a.jsx)(_.ui_kit$Button,{type:"default",block:!1,className:"email-page-header__btn email-page-header__btn_extra",onClick:()=>{},children:(0,a.jsx)(r.EmIcons,{icon:"DotsHoriz",component:_.icons$DotsHoriz,size:18,strokeWidth:M.iconStrokeWidth})})},"Actions"):M.emailDropdownMenuImport&&(0,a.jsx)(_.ui_kit$Tooltip,{title:o("Import","verb"),placement:"bottom",children:M.emailDropdownMenuImportButton?(0,a.jsx)(_.ui_kit$Button,{className:"em-analytics__editor-page__import",icon:(0,a.jsx)(r.EmIcons,{icon:"CloudUploadOutlined",component:_.icons$CloudUploadOutlined,size:16,strokeWidth:M.iconStrokeWidth}),onClick:()=>{Ee({event:"click",action:"import_email"}),Oe()},children:n("Import")}):(0,a.jsx)(_.ui_kit$Button,{className:"em-analytics__editor-page__import",type:"text",icon:(0,a.jsx)(r.EmIcons,{icon:"CloudUploadOutlined",component:_.icons$CloudUploadOutlined,size:22,strokeWidth:M.iconStrokeWidth}),onClick:()=>{Ee({event:"click",action:"import_email"}),Oe()}})}),M.emailExportEnabled&&(0,a.jsx)(_.ui_kit$Dropdown,{arrow:{pointAtCenter:!0},placement:"bottom",menu:{items:It},children:(0,a.jsx)(_.ui_kit$Button,{className:"em-analytics__email-page__export",type:"default",icon:(0,a.jsx)(r.EmIcons,{icon:"CloudDownloadOutlined",component:_.icons$CloudDownloadOutlined,size:16,strokeWidth:M.iconStrokeWidth}),children:n("Export")},"Export")},"Export"),!e.hasOwnProperty("type")&&(0,a.jsx)(hs,{disabled:fe,email:e},"Save"),!!e.hasOwnProperty("type")&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(Iu,{disabled:fe,rightCol:void 0,block:e,isEditableRights:p||f||g.id?.toString()===ht?.toString(),autoSaveBlockResult:t})},"Save"),(0,a.jsx)(Qp,{open:pe,codeSize:r.getCodeSize(Ce),onMinimize:Bt,onDownloadAsIs:Me,onCancel:Xe}),Re&&po(Re)&&(0,a.jsx)(am,{integration:po(Re),visible:!!Re,loading:et,onConfirm:Rn,onCancel:On,__:n}),(0,a.jsx)(r.PlanUpgradePrompt,{open:J,sideOnOk:void 0,onCancel:()=>_e(!1),initialSlide:Te})]})},_r=r.createApi({reducerPath:"confirmationMailApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/",responseHandler:e=>e.text()}),endpoints:e=>({getConfirmationMail:e.query({query:({userId:t,email:n})=>({url:`?proxy_url=${encodeURIComponent(`https://webhook.latenode.com/5868/prod/1fbda9c1-3211-4b12-be45-9cd2ea73d73d?user_id=${t}&user_email=${n}`)}`})})})}),{useLazyGetConfirmationMailQuery:of}=_r,sf=()=>{const{__:e}=r.useI18n(),t=r.useNotification(),n=r.useCurrentUser(),[o]=of(),[i,s]=(0,l.useState)(!1),c=r.usePushToDataLayer();(0,l.useEffect)(()=>{n.hasOwnProperty("email_confirmation")&&s(n.email_confirmation)},[n,i]);const d=()=>{c({event:"click",action:"click_resend_confirmation_email",user_email:n.email,user_id:n.id}),o({userId:n.id,email:n.email}).then(({data:u,error:p})=>{u?t.success(e("Confirmation email has been sent to {confirmedEmail}.").replace("{confirmedEmail}",n.email)):p&&t.error(p)})};return n?.email_confirmation||!n?.privacy_policy_agreement?null:(0,a.jsx)("div",{className:"main__ribbon",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(r.EmIcons,{icon:"EmailConfirmation",component:_.icons$EmailConfirmation,size:16,style:{marginRight:10,verticalAlign:"-0.15em"}}),e("Confirmation email was sent to")," ",(0,a.jsx)("em",{children:n.email}),". ",e("Didn't receive an email?")," ",(0,a.jsxs)(_.ui_kit$Button,{type:"primary",size:"small",className:"main__ribbon-resend",style:{fontSize:16,lineHeight:1,display:"inline-flex",alignItems:"center",gap:8},onClick:d,children:[e("Resend"),(0,a.jsx)(r.EmIcons,{icon:"SendOutlined",component:_.icons$SendOutlined,size:16,style:{flexShrink:0}})]})]})})},af=({className:e,leftBlock:t,rightBlock:n,isHeaderCodeMenuOpen:o=!1})=>{const{token:i}=(0,_.ui_kit$useToken)(),s=(0,l.useRef)(),c=r.useAppConfig();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(sf,{}),c.headerShow&&(0,a.jsx)("header",{className:(0,rt.default)("header",{[e]:e}),style:{borderColor:i.colorBorder},children:!o&&(0,a.jsx)(r.CSSTransition,{nodeRef:s,in:!o,timeout:300,classNames:"transition",children:(0,a.jsxs)("div",{className:"header__container container",children:[(0,a.jsx)("div",{className:"header__left",style:{flexGrow:1},children:t}),(0,a.jsx)("div",{className:"header__right",children:(0,a.jsx)(_.ui_kit$Space,{size:10,children:n})})]})})})]})},lf=e=>{},Cs=h.createIdentifier$1("canvas.headerFlow");function cf(e){const t=(0,l.useCallback)(n=>e?e.subscribe(n):()=>{},[e]);return(0,l.useSyncExternalStore)(t,()=>e?.isReady()===!0)}var Ts=({email:e,isCollaborationEditor:t})=>{const[n]=_.ui_kit$Form.useForm(),{__:o}=r.useI18n();let i=r.useDispatch();const s=r.useEmailAttributesWriter(),c=r.useAppNavigate(),d=r.useOpenPlanCatalog(),u=Hi("header"),p=r.useCurrentUser(),f=r.useContainer().getInstance(Cs),g=r.useProjectData(),{owner:y,admin:m}=Qn(),{token:S}=(0,_.ui_kit$useToken)(),k=r.useAppConfig(),w=r.usePushToDataLayer(),b=(0,l.useRef)(),A=(0,l.useRef)(),x=(0,l.useRef)(),Y=r.useEventEmitter(h.events.ON_PREVIOUSBUTTON_CLICK_ID),Z=r.useEventEmitter(h.events.ON_PREHEADER_CHANGED_ID),M=r.useEventEmitter(h.events.ON_SUBJECT_CHANGED_ID),O=r.useSelector(r.selectCodeModeDirection),I=e.hasOwnProperty("type")?r.BLOCK:r.EMAIL,R=r.useSelector(r.selectElementSettings$1),z=r.useSelector(r.selectElementSettings),B=I==="email"?R:z,U=r.useSelector(r.selectIsCodeMode),[de,me]=(0,l.useState)(!1),[q,ee]=(0,l.useState)(!1),[Fe,be]=(0,l.useState)(!1),et=(0,l.useCallback)(()=>be(!1),[]),Ee=(0,l.useCallback)(()=>{be(!1),d()},[d]),fe=zi("email_generate"),Q=fe.exceeded?r.getLimitUpgradePresetDefinition(fe.exceeded.presetId):null;(0,l.useEffect)(()=>{const v=!!B?.type&&(B?.type===r.ELEMENT_TYPES.TEXT||B?.type===r.ELEMENT_TYPES.LINK||B.type===r.ELEMENT_TYPES.BUTTON)&&U&&O!=="bottom";me(v),i(r.setHeaderCodeMenuOpen(v))},[B,O,U]);const pe=(0,l.useCallback)(()=>{w({event:"click",action:"click_back_button",entity_type:I==="block"?"block":"email",entity_id:e?.id,project_id:e?.project||g?.id,context:"editor"}),Y.fire(e)},[c,Y,e,g?.id,w,I]),{document:se}=r.useCurrentSession(),ae=cf(se);r.usePrevious(([v])=>{ae&&v!==e.subject&&M.fire(e.subject)},[e.subject,ae]);const Ie=(0,l.useCallback)(v=>{const W=v.target.value;M.fire(W)},[M]),Ce=(0,l.useCallback)(v=>{const W=v.target.value;Z.fire(W)},[Z]);r.usePrevious(([v])=>{ae&&v!==e.preheader&&Z.fire(e.preheader)},[e.preheader,ae]);const Be=(0,l.useCallback)((v,W="?")=>{v.subject?.length,v.preheader?.length,n.setFieldValue("subject",v.subject??""),n.setFieldValue("preheader",v.preheader??"")},[n]),J=(0,l.useRef)(void 0);(0,l.useEffect)(()=>{const v=e?.renderGuid??(e?.id!=null?String(e.id):void 0);!ae||!v||J.current===v||(J.current=v,Be(e,"identity"))},[ae,e,Be]);const _e=(0,l.useCallback)(v=>{const W=r.stripSubjectTags(v.value).trim();return W!==v.value&&n.setFieldValue("subject",W),W},[n]),Te=(0,l.useCallback)(v=>{const W=_e(v.target);s({subject:W})},[s,_e]),ge=r.useEvent(h.events.BEFORE_SAVE_EMAIL),Re=(0,l.useCallback)(async v=>{const W=A.current?.input;if(document.activeElement===W){const Ae=_e(W);Ae!==v.subject&&(v.subject=Ae,s({subject:Ae}))}const Pe=x.current?.input;if(document.activeElement===Pe){const Ae=Pe.value.trim();Ae!==v.preheader&&(v.preheader=Ae,s({preheader:Ae}))}await f?.whenDelivered()},[f,s,_e]);(0,l.useEffect)(()=>{const v=ge(Re);return()=>v.dispose()},[ge,Re]);const ze=(0,l.useCallback)(v=>{const W=v.target.value.trim();s({preheader:W})},[s]),C=r.useEvent(h.events.ON_HEADER_APPLIED_ID);(0,l.useEffect)(()=>{const v=C(({field:W,value:Pe})=>{n.setFieldValue(W,Pe)});return()=>v.dispose()},[C,n]),lf(e.title===null?o("New email title"):e.title);const T=(0,l.useCallback)(()=>{i(r.setActiveSettingsTab(r.AICHAT)),setTimeout(()=>{const v=document.querySelector('li.ai-response-change-context[role="theme-and-preheader-generator"]');v&&v.click()},100)},[i]),P=(0,l.useCallback)(()=>{fe.isLocked?fe.state.state==="locked_by_limit"&&fe.exceeded?be(!0):ee(!0):T()},[fe,T]),N=(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(_.ui_kit$Space,{ref:b,size:10,children:[k.headerArrowBackVisible&&(0,a.jsx)(_.ui_kit$Tooltip,{title:o("Back"),placement:"left",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsx)(r.EmIcons,{icon:"ArrowLeftOutlined",component:_.icons$ArrowLeftOutlined,size:22,strokeWidth:k.iconStrokeWidth}),onClick:pe,shape:"circle"})}),(0,a.jsx)("div",{children:(k.headerTitleVisible||k.headerPreheaderVisible)&&(0,a.jsxs)(_.ui_kit$Form,{form:n,layout:"vertical",name:"subject_preheader_form",autoComplete:"off",initialValues:{subject:"",preheader:""},children:[k.headerTitleVisible&&(0,a.jsx)("div",{style:{marginTop:ae?-3:0},children:(0,a.jsxs)(_.ui_kit$Space,{style:{width:"100%"},align:"baseline",size:12,children:[(0,a.jsx)("div",{className:"subject_preheader_form__title",children:o("Subject")}),ae?(0,a.jsxs)("div",{className:"ant-page-header-heading",children:[(0,a.jsx)(_.ui_kit$Form.Item,{name:"subject",noStyle:!0,children:(0,a.jsx)(_.ui_kit$Input,{className:"ant-page-header-heading-title",ref:A,placeholder:o("Enter subject line here"),variant:"borderless",autoComplete:"off","data-lpignore":"true","data-1p-ignore":"","data-bwignore":"true","data-form-type":"other",onChange:Ie,onPressEnter:Te,onBlur:v=>{Te(v),document.querySelector(".ant-page-header-heading-title").closest(".ant-page-header-heading").classList.remove("focus")},onFocus:()=>{document.querySelector(".ant-page-header-heading-title").closest(".ant-page-header-heading").classList.add("focus")},disabled:k.lockPreheaderAndTitle})}),k.aiAssistentEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:o("Generate with AI"),children:(0,a.jsx)(r.EmIcons,{icon:"AI",component:_.icons$AI,size:12,strokeWidth:k.iconStrokeWidth,onClick:P})})]}):(0,a.jsx)(_.ui_kit$Skeleton.Input,{active:!0,size:16,style:{width:"40%",marginTop:3}})]})}),k.headerPreheaderVisible&&(0,a.jsx)("div",{children:(0,a.jsxs)(_.ui_kit$Space,{style:{width:"100%"},align:"baseline",size:12,children:[(0,a.jsx)("div",{className:"subject_preheader_form__title",children:o("Preheader")}),ae?(0,a.jsxs)("div",{className:"ant-page-header-heading ant-page-header-heading_preheader",children:[(0,a.jsx)(_.ui_kit$Form.Item,{name:"preheader",noStyle:!0,children:(0,a.jsx)(_.ui_kit$Input,{className:"ant-page-header-heading-preheader",ref:x,placeholder:o("Enter preheader here"),variant:"borderless",autoComplete:"off","data-lpignore":"true","data-1p-ignore":"","data-bwignore":"true","data-form-type":"other",onChange:Ce,onPressEnter:ze,onBlur:v=>{ze(v),document.querySelector(".ant-page-header-heading-preheader").closest(".ant-page-header-heading").classList.remove("focus")},onFocus:()=>{document.querySelector(".ant-page-header-heading-preheader").closest(".ant-page-header-heading").classList.add("focus")},disabled:k.lockPreheaderAndTitle})}),k.aiAssistentEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:o("Generate with AI"),children:(0,a.jsx)(r.EmIcons,{icon:"AI",component:_.icons$AI,size:12,strokeWidth:k.iconStrokeWidth,onClick:P})})]}):(0,a.jsx)(_.ui_kit$Skeleton.Input,{active:!0,size:16,style:{width:"80%",marginTop:2}})]})})]})})]})}),D=(0,a.jsxs)(a.Fragment,{children:[k.emailIdShow&&!!e.id&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"email-page-header__email-id",children:"ID"+e.id}),(0,a.jsx)(_.ui_kit$Divider,{orientation:"vertical"})]}),(0,a.jsx)(us,{emailElement:e,isCollaborationEditor:t}),k.commandButtonsEnabled&&(0,a.jsxs)(a.Fragment,{children:[e.lock?(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:18,strokeWidth:k.iconStrokeWidth,className:(0,rt.default)("lock-icon",{"lock-icon__disabled":!(y||m||p.id?.toString()===e.author?.toString())}),style:{color:S.colorPrimary,verticalAlign:"sub"}},"Lock"):null,(0,a.jsx)(rf,{email:e,isHeaderCodeMenuOpen:de},"Buttons")]})]});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(af,{className:"email-pane__header",leftBlock:u?N:null,rightBlock:u?D:null,isHeaderCodeMenuOpen:de}),(0,a.jsx)(r.PlanUpgradePrompt,{open:q,onCancel:()=>ee(!1),initialSlide:9}),Q&&fe.exceeded?(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(ro,{open:Fe,onClose:et,title:o(Q.titleKey),subtitle:o(Q.subtitleKey),usageResource:Q.usageResource,previousDisplay:r.presetLimitDisplay(fe.exceeded.previousLimit),nextDisplay:r.presetLimitDisplay(fe.exceeded.nextLimit),onChangePlan:Ee})}):null]})};Ts.propTypes={};function df(e){const t=r.parseEmBlockVersion(e);if(!t)return e;const n=o=>String(o).padStart(2,"0");return`${n(t.getDate())}.${n(t.getMonth()+1)}.${t.getFullYear()} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}var uf=({open:e,blocks:t,projectId:n,onClose:o})=>{const{__:i,_n:s}=r.useI18n(),c=r.useSendPostMessage(),d=r.useNotification(),[u,p]=(0,l.useState)({});(0,l.useEffect)(()=>{e&&p(Object.fromEntries(t.map(m=>[m.emBlockId,!0])))},[e,t]);const f=(0,l.useMemo)(()=>Object.values(u).filter(Boolean).length,[u]),g=(m,S)=>{p(k=>({...k,[m]:S}))},y=()=>{const m=t.filter(S=>u[S.emBlockId]);m.length&&(m.forEach(S=>{c({operation:r.EVENT_TYPES.SANDBOX_GLOBAL_BLOCK_REPLACE,settings:{emBlockId:S.emBlockId,blockHTML:S.savedHtml,type:"project",...n?{project:String(n)}:{}}})}),d.success({message:i("Updated")+" "+m.length+" "+s("block","blocks",m.length),placement:"bottomRight"}),o())};return(0,a.jsxs)(_.ui_kit$Modal,{title:(0,a.jsx)("div",{className:"ant-modal-title",children:i("Update global blocks")}),open:e,onOk:y,onCancel:o,footer:(0,a.jsxs)("div",{className:"update-global-blocks-modal__footer",children:[(0,a.jsx)(_.ui_kit$Button,{size:"large",onClick:o,children:i("Cancel")}),(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",disabled:f===0,onClick:y,children:i("Update")})]}),children:[(0,a.jsx)("div",{className:"update-global-blocks-modal__hint",children:i("These global blocks have a newer saved version. Select the ones to update in the template.")}),(0,a.jsx)("div",{className:"update-global-blocks-modal__list",children:t.map(m=>(0,a.jsxs)("div",{className:"update-global-blocks-modal__row",children:[(0,a.jsx)(_.ui_kit$Switch,{checked:!!u[m.emBlockId],onChange:S=>g(m.emBlockId,S)}),(0,a.jsxs)("span",{className:"update-global-blocks-modal__title",title:m.title,children:[m.title,(0,a.jsxs)("span",{className:"update-global-blocks-modal__version",children:[i("Version of")," ",df(m.savedVersion)]})]}),m.instances>1&&(0,a.jsxs)("span",{className:"update-global-blocks-modal__count",children:[m.instances," ",s("instance","instances",m.instances)]})]},m.emBlockId))})]})};function pf(e){const t=new Map;return e?.trim()&&new DOMParser().parseFromString(e,"text/html").querySelectorAll('[em="block"][em-block-id]').forEach(n=>{const o=n.getAttribute("em-block-id");if(!o)return;const i=n.getAttribute("em-block-version")??void 0,s=t.get(o);s?(s.versions.add(i),s.count+=1):t.set(o,{versions:new Set([i]),count:1})}),t}function mf(e,t){const n=pf(e);if(!n.size||!t?.length)return[];const o=[];for(const i of t){if(!i.global_block||!i.id||!i.html)continue;const s=String(i.id),c=n.get(s);if(!c)continue;const d=r.readRootEmBlockAttrs(i.html).emBlockVersion;d&&[...c.versions].some(u=>u!==d)&&o.push({emBlockId:s,title:i.title?.trim()||s,savedHtml:i.html,savedVersion:d,templateVersion:[...c.versions][0],instances:c.count})}return o}var Is="em-block-id";function ff({projectId:e,document:t}){const n=r.useEvent(h.events.ON_EMAIL_INIT_ID),o=r.useHeadless(),[i,s]=(0,l.useState)([]),[c,d]=(0,l.useState)(!1),[u,p]=(0,l.useState)(null),f=(0,l.useCallback)(S=>t?.subscribe(S)??(()=>{}),[t]),g=(0,l.useSyncExternalStore)(f,()=>!!t?.getContent().includes(Is)),{data:y}=r.blocksApi.endpoints.getBlocks.useQuery(r.projectBlocksArgs(e),{skip:!e||!g}),m=(0,l.useRef)(!1);return(0,l.useEffect)(()=>{g&&m.current&&t&&(m.current=!1,p(t.getContent()))},[g,t]),(0,l.useEffect)(()=>{const S=new h.Disposable;return S.addDisposable(n(k=>{if(k?.reset)return;const w=k?.html??"",b=w.includes(Is);m.current=!b,p(b?w:null)})),()=>S.dispose()},[n]),(0,l.useEffect)(()=>{if(u==null||!y)return;if(o){p(null);return}const S=mf(u,y);S.length&&(s(S),d(!0)),p(null)},[u,y,o]),{outdatedBlocks:i,isOpen:c,close:(0,l.useCallback)(()=>d(!1),[])}}var gf=({open:e,html:t,emBlockId:n,onSaveAsNew:o,onClose:i})=>{const{__:s}=r.useI18n(),c=r.useSendPostMessage(),d=r.useNotification(),[u]=r.useEditBlockMutation(),[p,f]=(0,l.useState)(!1),g=async()=>{if(!n||!t){i();return}f(!0);const y=new Date,m=r.formatEmBlockVersion(y),S=r.injectEmBlockIdIntoBlockHtml(t,String(n),y),k=await u({blockId:String(n),html:S});if(f(!1),"error"in k&&k.error){d.error({message:s("Failed to update the global block."),placement:"bottomRight"});return}c({operation:r.EVENT_TYPES.SANDBOX_EBLOCK_SET_EM_BLOCK_ID,settings:{emBlockId:String(n),emBlockVersion:m}}),d.success({message:s("The global block was updated."),placement:"bottomRight"}),i()};return(0,a.jsx)(_.ui_kit$Modal,{title:(0,a.jsx)("div",{className:"ant-modal-title",children:s("Saving changes in the block")}),open:e,onCancel:i,footer:(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,a.jsx)(_.ui_kit$Button,{size:"large",disabled:p,onClick:o,children:s("Create new block")}),(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",loading:p,onClick:g,children:s("Update current block")})]}),children:(0,a.jsx)("div",{children:s("This is a global block. You can create a new one to apply changes only in this email, or update the current one — then the changes will be applied everywhere this block is used.")})})},hf=(function(){var e=window.__useblocks__;if(e&&e.assetUrl)return e.assetUrl("converter-intro.bf4ee74d750b35ae2c10.png");if(e&&e.publicPath)try{return new URL("static/media/converter-intro.bf4ee74d750b35ae2c10.png",e.publicPath).href}catch{}try{return new URL("/static/media/converter-intro.bf4ee74d750b35ae2c10.png",typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"").href}catch{return"/static/media/converter-intro.bf4ee74d750b35ae2c10.png"}})(),_f={closable:!1},yf=hf,vf=({open:e,onConfirm:t,onCancel:n,neverSuggestAgain:o,onNeverSuggestAgainChange:i})=>{const{__:s}=r.useI18n();return(0,a.jsx)(_.ui_kit$Modal,{className:"convert-layout-modal",title:(0,a.jsx)("div",{className:"convert-layout-modal__title",children:s("Template conversion")}),open:e,onOk:t,onCancel:n,mask:_f,width:480,footer:(0,a.jsxs)("div",{className:"convert-layout-modal__footer",style:{display:"flex",flexDirection:"column",gap:16},children:[(0,a.jsx)(_.ui_kit$Switch,{size:"small",checked:o,onChange:i,label:s("Don't suggest again"),labelSize:"small"}),(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,a.jsx)(_.ui_kit$Button,{size:"large",onClick:n,children:s("Cancel")}),(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",onClick:t,children:s("Convert")})]})]}),children:(0,a.jsxs)("div",{className:"convert-layout-modal__content",style:{display:"flex",flexDirection:"column",alignItems:"center",gap:24,padding:"0 8px",overflow:"hidden"},children:[(0,a.jsx)("div",{className:"convert-layout-modal__text convert-layout-modal__intro-text",style:{textAlign:"center"},children:s("This layout was not created in our editor. Convert it to unlock full editing capabilities: easily change texts, replace images, and manage blocks.")}),(0,a.jsx)("img",{src:yf,alt:"Converter Intro",className:"convert-layout-modal__image",style:{display:"block",width:"100%",maxWidth:"100%",height:"auto",borderRadius:8}})]})})},bf={closable:!1},Ef=({open:e,message:t,onRetry:n,onCancel:o})=>{const{__:i}=r.useI18n();return(0,a.jsx)(_.ui_kit$Modal,{title:(0,a.jsx)("div",{className:"ant-modal-title",children:i("Conversion failed")}),open:e,onOk:n,onCancel:o,mask:bf,footer:(0,a.jsxs)("div",{className:"convert-layout-modal__footer",children:[(0,a.jsx)(_.ui_kit$Button,{size:"large",onClick:o,children:i("Cancel")}),(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",onClick:n,children:i("Try again")})]}),children:(0,a.jsxs)("div",{className:"convert-layout-modal__text",children:[i("Something went wrong during layout conversion. You can try running the conversion again."),t?(0,a.jsx)("div",{className:"convert-layout-modal__error-details",children:t}):null]})})},Sf=({open:e,progress:t})=>{const{__:n}=r.useI18n();return e?(0,a.jsx)("div",{className:"conversion-overlay",children:(0,a.jsxs)("div",{className:"conversion-overlay__content",children:[(0,a.jsx)(_.ui_kit$Spin,{size:"large"}),(0,a.jsx)("div",{className:"conversion-overlay__title",children:n("Converting layout…")}),(0,a.jsx)("div",{className:"conversion-overlay__hint",children:n("This may take several minutes. Please keep this tab open.")}),(0,a.jsx)(_.ui_kit$Progress,{className:"conversion-overlay__progress",percent:Math.round(t),status:"active",strokeColor:r.emCssVar("colorPrimary")})]})}):null},yr=r.createApi({reducerPath:"layoutConverterApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({createConvertJob:e.mutation({query:({html:t})=>({url:"/ai/converter/jobs",method:"POST",body:{html:t}})}),getConvertJobStatus:e.query({query:t=>({url:`/ai/converter/jobs/${t}`,method:"GET"})})})}),{useCreateConvertJobMutation:wf,useLazyGetConvertJobStatusQuery:kf}=yr;function Cf(){try{return window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_layout_convert_never_suggest)==="true"}catch{return!1}}function Tf(e){try{e?window.localStorage.setItem(r.LOCAL_STORAGE_ITEMS.em_layout_convert_never_suggest,"true"):window.localStorage.removeItem(r.LOCAL_STORAGE_ITEMS.em_layout_convert_never_suggest)}catch{}}function As(e){return e==="beefree"?(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/4c8d0155.js")).then(t=>t.convertBeeFreeToEmailMaker),void 0,{}.url):(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/60aa31a3.js")).then(t=>t.convertStripoToEmailMaker),void 0,{}.url)}var If=5,xs=95,Af=35e3,xf=1e3,Pf=e=>new Promise(t=>setTimeout(t,e));function jf(e,t){if(e&&typeof e=="object"){const n=e,o=n.data;if(o&&typeof o=="object"){const i=o.error;if(typeof i=="object"&&i?.message)return i.message;if(typeof i=="string"&&i)return i;if(o.message)return o.message}if(typeof o=="string"&&o)return o;if(n.error)return n.error;if(n.message)return n.message}return t}function Rf(){const{__:e}=r.useI18n(),t=r.useContentReplacer(),n=r.useNotification(),o=ys(),{aiLayoutConverterEnabled:i,anyConverterEnabled:s}=o,c=r.useHeadless(),d=r.useEvent(h.events.ON_EMAIL_INIT_ID),u=r.useEvent(h.events.ON_LAYOUT_CONVERT_REQUEST_ID),[p]=wf(),[f]=kf(),[g,y]=(0,l.useState)(Cf),m=(0,l.useRef)(g),S=(0,l.useCallback)(se=>{m.current=se,y(se),Tf(se)},[]),[k,w]=(0,l.useState)(!1),[b,A]=(0,l.useState)(!1),[x,Y]=(0,l.useState)(0),[Z,M]=(0,l.useState)(!1),[O,I]=(0,l.useState)(""),R=(0,l.useRef)(""),z=(0,l.useRef)(null),B=(0,l.useRef)(null),U=(0,l.useRef)(!1),de=(0,l.useRef)({cancelled:!0}),me=(0,l.useRef)(null);(0,l.useEffect)(()=>{U.current=b},[b]);const q=(0,l.useCallback)(()=>{me.current!==null&&(clearInterval(me.current),me.current=null)},[]),ee=(0,l.useCallback)(()=>{q();const se=Date.now();me.current=setInterval(()=>{const ae=Date.now()-se,Ie=xs*(1-Math.exp(-ae/Af));Y(Ce=>Math.max(Ce,Math.min(xs,Ie)))},xf)},[q]),Fe=(0,l.useCallback)(se=>{se&&(t(se,{undoable:!0}),B.current=se)},[t]),be=(0,l.useCallback)(async se=>{const ae={cancelled:!1};de.current=ae,M(!1);const Ie=z.current;if(Ie==="beefree"||Ie==="stripo"){try{const Ce=await As(Ie),Be=ae.cancelled?"":Ce(se);if(Be&&!ae.cancelled){Fe(Be),n.success({message:r.isUseBlocksBuild()?e("Layout converted to Blocks format"):e("Layout converted to EmailMaker format"),placement:"bottomRight"});return}}catch{}if(!i){ae.cancelled||(I(e("Layout conversion failed")),M(!0));return}}if(i){A(!0),Y(0),ee();try{const Ce=await p({html:se}).unwrap();if(ae.cancelled)return;let Be=Ce.retry_after>0?Ce.retry_after:If;for(;!ae.cancelled;){if(await Pf(Be*1e3),ae.cancelled)return;const J=await f(Ce.job_id).unwrap();if(ae.cancelled)return;if(J.retry_after&&J.retry_after>0&&(Be=J.retry_after),J.status==="completed"){q(),Y(100),Fe(J.html??""),n.success({message:r.isUseBlocksBuild()?e("Layout converted to Blocks format"):e("Layout converted to EmailMaker format"),placement:"bottomRight"}),setTimeout(()=>{ae.cancelled||(A(!1),Y(0))},400);return}if(J.status==="failed")throw new Error(J.error?.message||e("Layout conversion failed"))}}catch(Ce){if(ae.cancelled)return;q(),A(!1),Y(0),I(jf(Ce,e("Layout conversion failed"))),M(!0)}}},[e,i,Fe,p,n,f,ee,q]),et=(0,l.useCallback)(()=>{w(!1);const se=R.current;se&&be(se)},[be]),Ee=(0,l.useCallback)(()=>{w(!1),B.current=R.current},[]),fe=(0,l.useCallback)(()=>{M(!1);const se=R.current;se&&be(se)},[be]),Q=(0,l.useCallback)(()=>{M(!1),B.current=R.current},[]),pe=(0,l.useCallback)((se,ae=!1)=>{const Ie=vs(se,o);if(s&&!c&&Ie&&!U.current){if(ae)B.current=null;else{if(m.current)return;if(B.current===se)return}R.current=se,z.current=Ie,Ie!=="ai"&&As(Ie).catch(()=>{}),w(!0)}},[s,o,c]);return(0,l.useEffect)(()=>{if(!s)return;const se=new h.Disposable;return se.addDisposable(d(ae=>{ae?.reset||pe(ae?.html??"")})),()=>se.dispose()},[s,d,pe]),(0,l.useEffect)(()=>{if(!s)return;const se=new h.Disposable;return se.addDisposable(u(ae=>{pe(ae?.html??"",!0)})),()=>se.dispose()},[s,u,pe]),(0,l.useEffect)(()=>()=>{de.current.cancelled=!0,q()},[q]),{isPromptOpen:k,isConverting:b,progress:x,isErrorOpen:Z,errorMessage:O,confirmConversion:et,cancelPrompt:Ee,retryConversion:fe,closeError:Q,neverSuggestAgain:g,setNeverSuggestAgain:S}}var Of=6e4,Ps=new Map;function Lf(e){const t=e?String(e):"",n=Ps.get(t);if(n&&(Ps.delete(t),!(Date.now()-n.at>Of)))return n.promise}var go={data:void 0,isSuccess:!1,isError:!1,error:void 0,isLoading:!1};function Mf(e){const t=r.useStore(),n=(0,l.useRef)(t);n.current=t;const[o,i]=(0,l.useState)(go),s=e?String(e):void 0;return(0,l.useEffect)(()=>{if(!s){i(go);return}let c=!1;return i({...go,isLoading:!0}),(Lf(s)??r.resolveEmailPort(h.getContainer(n.current)).readEmail(s)).then(d=>{c||i({data:d??void 0,isSuccess:!0,isError:!1,error:void 0,isLoading:!1})}).catch(d=>{c||i({data:void 0,isSuccess:!1,isError:!0,error:d,isLoading:!1})}),()=>{c=!0}},[s]),o}var rb=2;function Nf(){const e=r.useProjectData()?.id,t=!0,{data:n,isError:o,isFetching:i,refetch:s}=r.useGetProjectPlanQuery(e,{skip:t}),[c,d]=(0,l.useState)(0),u=(0,l.useRef)(!1),p=!!o,f=c>=2,g=(0,l.useCallback)(()=>{u.current=!1,d(0),s()},[s]);(0,l.useEffect)(()=>{},[p,i,s,c,t]),(0,l.useEffect)(()=>{},[p,e,f,t]);const y="ready";return(0,l.useMemo)(()=>({status:y,retry:g}),[y,g])}var ob=300,Df=h.createIdentifier$1("prewarm.queue");function Ff(e){const t=[];let n=!1,o=!1,i;const s=()=>{i&&(i.unwatch(),e.clearTimer(i.timer),i=void 0)},c=()=>{const p=t.shift();if(!p)return;o=!0;const f=()=>{o=!1,u()};p.start().then(f,f)},d=()=>{s(),e.idle(()=>{if(!(o||t.length===0)){if(e.activity.inFlight()>0){u();return}c()}})};function u(){if(!n||o||i||t.length===0)return;const p=()=>e.setTimer(d,300),f={timer:e.activity.inFlight()===0?p():void 0,unwatch:e.activity.watch(()=>{e.clearTimer(f.timer),f.timer=e.activity.inFlight()===0?p():void 0})};i=f}return e.whenVisible(()=>{n=!0,u()}),{add(p){t.some(f=>f.name===p.name)||(t.push(p),u())},remove(p){const f=t.findIndex(g=>g.name===p);f>=0&&t.splice(f,1),t.length===0&&s()}}}function Bf(e){return e.getOrCreateInstance(Df,()=>Ff({activity:h.getNetworkActivity(e),whenVisible:t=>Ht(e).whenVisible(t),idle:Xt,setTimer:(t,n)=>window.setTimeout(t,n),clearTimer:t=>window.clearTimeout(t)}))}function $f({projectId:e,project:t,emailProjectId:n,parentEmailId:o}){const i=r.useContainer(),s=r.useAppDispatch(),d=!!r.useCookieManager().get(r.APP_COOKIES.em_token);(0,l.useEffect)(()=>{const u=Bf(i),p=[],f=[],g=(m,S)=>{f.push(m),u.add({name:m,start:()=>{const k=S();return p.push(k),Promise.resolve(k)}})},y=r.parentEmailSource(o);return y&&g("blocks.parentEmail",()=>s(r.blocksApi.endpoints.getParentEmailBlocks.initiate(r.parentEmailBlocksArgs(y)))),g("blocks.template",()=>s(r.blocksApi.endpoints.getTemplateBlocks.initiate(r.templateBlocksArgs()))),e&&g("blocks.list",()=>s(r.blocksApi.endpoints.getBlocks.initiate(r.projectBlocksArgs(e)))),g("blocks.schema",()=>s(r.blocksApi.endpoints.getBlocksSchema.initiate(void 0))),t?.id&&g("blocks.tags",()=>s(r.taxonomiesApi.endpoints.getTerms.initiate({project:t,kind:r.BLOCK_TAGS}))),()=>{f.forEach(m=>u.remove(m)),p.forEach(m=>m.unsubscribe())}},[i,s,e,t,n,o,d])}var ho="AUTOSAVE_RECOVERY";function Uf(e,t,n=!1,o){const i=t?.get().serverId??void 0,{__:s}=r.useI18n(),c=r.useNotification(),d=r.useAppConfig(),u=r.useSelector(r.selectMonacoFocusing),p=r.useContainer(),f=p?.getInstance(Cs),g=(0,l.useRef)(0),y=r.useSelector(r.selectIsPanelHistoryCollapsed),m=r.useSelector(r.selectActiveSettingsTab),S=r.useDispatch(),k=(0,l.useSyncExternalStore)((0,l.useCallback)(O=>o?.subscribe(O)??(()=>{}),[o]),()=>o?.recoveryFacts()),w=d?.revisionService===!0,b=k?.isRecovering===!0,A=k?.applied,x=(0,l.useCallback)(()=>{S(r.markAppearanceNeedsUpdate());const O=e?.renderGuid,I=e?.preheader,R=e?.subject;O&&(I||R)&&f?.reassert({...I?{preheader:I}:{},...R?{subject:R}:{}})},[S,f,e?.preheader,e?.subject,e?.title,e?.common_styles,e?.renderGuid,t,o]);(0,l.useEffect)(()=>()=>{clearTimeout(g.current),o?.endForcedHeaders()},[i,o]),(0,l.useEffect)(()=>{w&&b&&c.info({key:ho,title:s("Loading latest changes..."),duration:0})},[w,b,c,s]);const Y=(0,l.useRef)({emailId:void 0,seq:0});(0,l.useEffect)(()=>{if(!A||k?.emailId!==i||(Y.current.emailId!==i&&(Y.current={emailId:i,seq:0}),A.seq<=Y.current.seq))return;Y.current={emailId:i,seq:A.seq},x();const{phase:O}=A;!w||O==="normal"||(O==="found"?c.success({key:ho,title:s("Changes loaded"),duration:3}):O==="timeout"?c.warning({key:ho,title:s("Locally saved version applied"),description:s("Syncing with the server in the background..."),duration:5}):O==="bg"&&c.info({key:"AUTOSAVE_BG_SYNCED",title:s("Email synced with the server"),duration:3}))},[w,A,k?.emailId,i,x,c,s]),(0,l.useEffect)(()=>{if(!n)return;const O=I=>{I.preventDefault()};return window.addEventListener("beforeunload",O),()=>window.removeEventListener("beforeunload",O)},[n]);const Z=!y||u||m==="Discuss",M=p?r.provideAutosaveUiFacts(p):void 0;(0,l.useEffect)(()=>{M?.set({...M.get()??{isUserBusy:!1,saveContext:{}},isUserBusy:Z})},[M,Z])}var zf=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 Gf(e,t,n){return t<=0?e:new Promise((o,i)=>{let s=!1,c;const d=u=>{s||(s=!0,c!==void 0&&(clearTimeout(c),c=void 0),u())};c=setTimeout(()=>{d(()=>i(new zf(n,t)))},t),e.then(u=>{d(()=>o(u))},u=>{d(()=>i(u))})})}var Wf=2,vr=Symbol("sandbox:frame-replaced");function an(e,t,n,o,i,s,c){const d=`sandbox:${t}`,u=s?.getSandboxTimeoutMs(t)??r.DEFAULT_SANDBOX_OP_TIMEOUT_MS[t],p=()=>{let S=Gf(e.sendAsync(n,o),u,d);return S=h.raceWithAbortSignal(S,s?.signal),r.logShowPipelineWait(d,S,i)};if(t==="INIT_START"&&Vi(e)){const S=s?.getSandboxReadyTimeoutMs()??2e4,k=e,w=b=>{const A=Ki(k,S,s?.signal);return r.logShowPipelineWait("sandbox:INIT_START:ready-wait",A,i).then(()=>{if(!c||b<=0)return p();const x=c.getGeneration();let Y;const Z=new Promise((O,I)=>{Y=c.onChange(()=>{c.getGeneration()!==x&&I(vr)})}),M=p();return M.catch(()=>{}),Promise.race([M,Z]).finally(()=>Y?.()).catch(O=>{if(O!==vr)throw O;return{...i},w(b-1)})})};return w(Wf)}if(!c)return p();const f=c.getGeneration();let g;const y=new Promise((S,k)=>{g=c.onChange(()=>{c.getGeneration()!==f&&k(vr)})}),m=p();return m.catch(()=>{}),Promise.race([m,y]).finally(()=>g?.()).catch(S=>{throw S===vr&&{...i},S})}function js(e,t,n,o){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...o!==void 0?{rev:o}:{}}}var Rs="self-init:";function Hf(e){return e.startsWith(Rs)}function Os(e,t){const n=e.getActiveShowRequest();return Hf(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function qf(e){const t=()=>e.initPipeline(),n=e.messageService,o=()=>e.waitScope?.()??t();let i="";const s=()=>e.readDocument()?r.readDocumentContent(e.readDocument()):i,c=()=>on(e.container).editorPolicy,d=()=>e.readEmail(),u=()=>{const p=d();return{...p,id:e.isTemplate()||p.isNew?void 0:p.id,html:s()}};return{readContent:s,publicEmail:u,sendInitStart:()=>an(n,"INIT_START",r.EVENT_TYPES.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,o()),sendInited:()=>an(n,"INITED",r.EVENT_TYPES.SANDBOX_INITED,{guid:d().renderGuid},void 0,o()),async sendContent(){const p=d(),{html:f,hasBrowserExtensionArtifacts:g}=r.prepareEmailHtmlForEditor(p?.html||"");g&&e.events.browserExtensionDetected(),r.loadDocumentContent(e.readDocument(),f),i=f,await an(n,"SET_ENTITY",r.EVENT_TYPES.SANDBOX_SET_ENTITY,js(s(),p.renderGuid,c(),e.readDocument()?.get().version),{guid:p.renderGuid,emailId:p.id??null},o())},refreshContent:()=>an(n,"SET_ENTITY",r.EVENT_TYPES.SANDBOX_SET_ENTITY,js(s(),d().renderGuid,c(),e.readDocument()?.get().version),void 0,o()),sendPreheader:async()=>{const p=d();if(p.preheader!==void 0)return an(n,"PREHEADER",r.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE,{value:p.preheader,guid:p.renderGuid,force:!0},void 0,o())},sendSubject:async()=>{const p=d();if(p.subject!==void 0)return an(n,"SUBJECT",r.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,{value:p.subject,guid:p.renderGuid,force:!0},void 0,o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:p=>e.showFilled?.(p),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(u()),fireInit(p,f){if(!Os(t(),p)){t().getActiveShowRequest()?.showId;return}const g=d();g.id,g.renderGuid,t().completeShow(p),r.writeEmailAttributes(e.readDocument(),{is_inited:!0},{source:"system"});const y=u();return f&&(y.reset=!0),e.events.inited(y)},fireEmailChanged(){e.events.emailChanged(u())},fireContentChanged(){e.events.contentChanged(s())}}}function Vf(e){const t=()=>e.initPipeline();let n=!1,o,i,s,c=0,d;const u=qf({...e,waitScope:()=>({getSandboxTimeoutMs:w=>t().getSandboxTimeoutMs(w),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:d?.signal??t().signal})});let p;const f=(w,b)=>{if(p===w)return;p=w;const A=c;setTimeout(()=>{c!==A||t().signal.aborted||S(w,b).catch(()=>{})},0)},g=()=>{d?.abort(),d=void 0};let y;const m=()=>{const w=t().signal;w!==y&&(y?.removeEventListener("abort",g),y=w,w.addEventListener("abort",g))};async function S(w,b){const A=++c;g(),d=new AbortController,m();const x=()=>c!==A,Y=u.readTarget(),Z=t().generation,M=()=>Z===t().generation&&!t().signal.aborted,O=b?"init:reset-":"init:";if(!b){const z=u.publicEmail();z?.id,z?.renderGuid,z?.preheader}let I=!1,R=!1;try{n=!0,await u.sendInitStart(),u.fireWillInit(),await(b?u.refreshContent():u.sendContent()),I=!0,b||u.publicEmail()?.id;try{await u.sendPreheader()}catch(z){r.logShowPipelineError(`${O}preheader-failed`,{showId:w,error:String(z)})}try{await u.sendSubject()}catch(z){r.logShowPipelineError(`${O}subject-failed`,{showId:w,error:String(z)})}if(x()||u.showFilled(Y),await u.sendInited(),R=!0,i===w){const z=e.readSandboxGeneration?.()??s;z!==void 0&&(o=z)}await u.revealFilled()}catch(z){throw x()||r.logShowPipelineError(`${O}failed`,{showId:w,contentApplied:I,sandboxInitedAcked:R,superseded:!1,...e.describeSurface?.(),error:String(z)}),!x()&&Os(t(),w)&&t().failShow(w,z),z}finally{k(w,b,O,{superseded:x(),sessionGeneration:Z,contentApplied:I,sandboxInitedAcked:R,commit:M()})}}function k(w,b,A,x){const{superseded:Y,contentApplied:Z,sandboxInitedAcked:M}=x;if(Y){`${A}`;return}M&&x.commit?u.fireInit(w,b||void 0):M?r.logShowPipelineError(`${A}aborted (stale session or signal)`,{showId:w,sessionGeneration:x.sessionGeneration,currentGeneration:t().generation,aborted:t().signal.aborted}):Z?r.logShowPipelineError(`${A}aborted (sandbox INITED ack missing)`,{showId:w}):r.logShowPipelineError(`${A}aborted (content not applied)`,{showId:w}),n=!1,d=void 0,!M&&i===w&&(i=void 0,o===s&&(o=void 0)),!M&&Z&&f(w,b)}return{channel:u,isEventsLocked:()=>n,filledGeneration:()=>o,markFilled:w=>{o=w},lastCorrelation:()=>i,markCorrelation:w=>{i=w},bumpRunSeq:()=>{c+=1},noteSandboxGeneration:w=>{s=w},fill:w=>S(w,!1),refill:w=>S(w,!0),stop:()=>{c+=1,g(),n=!1,y?.removeEventListener("abort",g),y=void 0}}}function Kf(e,t,n){if(!e?.renderGuid||!e.showId||e.showId!==t.showId)return!1;if(t.isNew)return e.id==null;const o=t.emailId??t.navId;return o!=null&&String(e.id??"")!==String(o)?!1:Ls(e,n)}function Ls(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Yf(e){const{pipeline:t,readEmail:n,readDocument:o,readRouteEmailId:i,readSandboxGeneration:s}=e,c=f=>{const g=n(),y=i();if(!Kf(g,f,y)){f.showId,f.navId,f.emailId,g?.id,g?.showId,g?.renderGuid;return}f.showId,g?.id,g?.renderGuid,t.markFilled(s()),t.markCorrelation(f.showId),t.fill(f.showId).catch(()=>{})};return{showRequested:f=>{c(f)},showRequestIdentityChanged:()=>{const f=e.initPipeline().getActiveShowRequest();f&&c(f)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const f=s();if(t.filledGeneration()===f)return;const g=n(),y=i();if(!g?.renderGuid||!Ls(g,y))return;const m=`${Rs}${g.renderGuid}`;t.markFilled(f),t.markCorrelation(m);const S=o()?.isReady()===!0;g.id,g.renderGuid,(S?k=>t.refill(k):k=>t.fill(k))(m).catch(()=>{t.lastCorrelation()===m&&t.markFilled(void 0)})},saasChanged:()=>{const f=n();f?.renderGuid,f?.showToken,f?.id}}}var Ms=h.createIdentifier$1("canvas.sandboxFill"),Qf=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}},Xf=class{_activeRequest=null;_pending=new Map;_listeners=new Set;getActiveShowRequest(){return this._activeRequest}onShowRequested(e){return this._listeners.add(e),()=>{this._listeners.delete(e)}}requestShow(e,t,n){return this._rejectPending(h.createAbortError("Superseded by newer show()")),n.aborted?Promise.reject(h.createAbortError(n.reason)):(this._activeRequest=e,new Promise((o,i)=>{const s=setTimeout(()=>{this._settle(e.showId,()=>{i(new Qf(e.showId,t))})},t);s.unref?.();const c=()=>{this._settle(e.showId,()=>{i(h.createAbortError(n.reason))})};n.addEventListener("abort",c,{once:!0});const d=()=>{clearTimeout(s),n.removeEventListener("abort",c)};this._pending.set(e.showId,{request:e,resolve:o,reject:i,timeoutId:s,dispose:d});for(const u of this._listeners)u(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 Jf(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function Zf(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=r.resolveContentReadyTimeoutMs(e),n=r.resolveSandboxReadyTimeoutMs(e),o=r.resolveSequentialSandboxOpBudgetMs(e.sandbox);t<n+o}var eg=class{_controller=new AbortController;_externalSignalDisposable=new h.Disposable;_sessionChangeListeners=new Set;_showRegistry=new Xf;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return r.resolveContentReadyTimeoutMs(this._timeouts)}getSandboxTimeoutMs(e){return r.resolveSandboxOpTimeoutMs(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return r.resolveSandboxReadyTimeoutMs(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=Jf(this._timeouts,e.timeouts),Zf(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??h.createAbortError("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new h.Disposable}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new h.Disposable,this._showRegistry.rejectAll(h.createAbortError("Init session replaced")),this._controller.signal.aborted||this._controller.abort(h.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??h.createAbortError()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??h.createAbortError()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},tg=(()=>{const e=new eg;return e.configure({}),e})();function _o(){const e=r.useStore();return(0,l.useMemo)(()=>h.getContainer(e)?.getInstance(h.INIT_PIPELINE_ID)??tg,[e])}function ng(e){const t=_o(),n=(0,l.useRef)(e);n.current=e,(0,l.useEffect)(()=>{let o;const i=()=>{o?.();const c=t.signal;if(c.aborted){n.current();return}const d=()=>n.current();c.addEventListener("abort",d),o=()=>c.removeEventListener("abort",d)};i();const s=t.onSessionReplaced(i);return()=>{s(),o?.()}},[t])}function rg(e){const t=_o(),n=(0,l.useRef)(e);n.current=e,(0,l.useEffect)(()=>t.onShowRequested(o=>n.current(o)),[t])}var og=(e,t,n,o,i)=>{const s=r.useStore(),c=r.useMessageService(),d=_o(),u=(0,l.useRef)(d);u.current=d;const p=r.useEventEmitter(h.events.WILL_EMAIL_INIT_ID),f=r.useEventEmitter(h.events.ON_EMAIL_INIT_ID),g=r.useEventEmitter(h.events.ON_CONTENT_CHANGED_ID),y=r.useEventEmitter(h.events.ON_EMAIL_CHANGED_ID),m=r.useEventEmitter(h.events.ON_BROWSER_EXTENSION_DETECTED_ID),S=e?.id!==void 0,k=e?.showToken??0,w=k,b=(0,l.useRef)(w);b.current=w;const A=(0,l.useRef)(void 0);A.current=e;const[x,Y]=(0,l.useState)(()=>r.getSandboxGeneration(c)),Z=(0,l.useRef)(x);Z.current=x,(0,l.useEffect)(()=>(Y(r.getSandboxGeneration(c)),r.onSandboxGenerationChange(c,()=>{Y(r.getSandboxGeneration(c))})),[c]);const M=(0,l.useRef)(o);M.current=o;const O=(0,l.useRef)(t);O.current=t;const I=i?.standalone?void 0:h.getContainer(s)?.getInstance(Ms),R=!I,z=(0,l.useRef)(I?.pipeline);z.current||(z.current=Vf({container:h.getContainer(s),messageService:c,initPipeline:()=>u.current,readDocument:()=>M.current,readEmail:()=>A.current,isTemplate:()=>!!O.current,readSandboxGeneration:()=>Z.current,events:{willInit:q=>p.fire(q),inited:q=>f.fire(q),contentChanged:q=>g.fire(q),emailChanged:q=>y.fire(q),browserExtensionDetected:()=>m.fire()}}));const B=z.current,U=(0,l.useRef)(n);U.current=n;const de=(0,l.useRef)(void 0);R&&!de.current&&(de.current=Yf({pipeline:B,initPipeline:()=>u.current,readEmail:()=>A.current,readDocument:()=>M.current,readRouteEmailId:()=>U.current,readSandboxGeneration:()=>Z.current}));const me=de.current;B.noteSandboxGeneration(Z.current),(0,l.useEffect)(()=>{if(R)return()=>z.current?.stop()},[R]),(0,l.useEffect)(()=>{I?.setRoute({emailId:n,isTemplate:t})},[I,n,t]),(0,l.useEffect)(()=>{const q=A.current;if(R&&!B.isEventsLocked()&&e?.renderGuid===q?.renderGuid&&q?.is_inited&&q){const ee=B.channel.readContent();y.fire({...q,id:t||q.isNew?void 0:q.id,html:ee})}},[B,e?.renderGuid,e?.preheader,e?.common_styles,e?.meta,e?.subject,e?.utm_parameters?.utm_campaign||"",e?.utm_parameters?.utm_content||"",e?.utm_parameters?.utm_medium||"",e?.utm_parameters?.utm_source||"",e?.utm_parameters?.utm_term||"",y,t,R]),(0,l.useEffect)(()=>{if(R){const q=r.subscribeToContent(o,()=>{const ee=A.current;if(!B.isEventsLocked()&&e?.renderGuid===ee?.renderGuid&&ee){const Fe=B.channel.readContent();g.fire(Fe),y.fire({...ee,id:t||ee.isNew?void 0:ee.id,html:Fe})}});return()=>q.dispose()}},[o,B,g,y,e,t,R]),ng(()=>{R&&B.stop()}),rg(q=>{me?.showRequested(q)}),(0,l.useEffect)(()=>{me?.showRequestIdentityChanged()},[me,d,e?.renderGuid,e?.showId,e?.id,n]),(0,l.useEffect)(()=>{me?.selfInitChanged()},[me,d,e?.renderGuid,e?.showId,e?.id,n,o,x]),r.usePrevious(()=>{me?.saasChanged()},[e?.renderGuid,k,S,me]),Jr(async()=>{if(!R)return;const q=d.getActiveShowRequest()?.showId;q&&(B.markFilled(Z.current),await B.refill(q))},{async:!0})};function ig(e){const t=r.useEvent(h.events.ON_EMAIL_INIT_ID);(0,l.useEffect)(()=>{if(!e)return;const n=t(()=>e.clear());return()=>n.dispose()},[e,t])}function sg(e,t){const n=r.useEventEmitter(h.events.ON_DOCUMENT_SESSION_CHANGE);(0,l.useEffect)(()=>{n.fire({document:e,history:t})},[e,t,n])}function ag({templateEmailId:e,templateEmail:t,newEmail:n}){return e?t:n}function lg({routeEmailId:e,draft:t}){const n=r.useStore();(0,l.useRef)(0),(0,l.useEffect)(()=>{},[n,e,t])}function cg(e,t){return t}function dg(e){return!1}function ug({documents:e,push:t,projectId:n,subscription:o}){(0,l.useEffect)(()=>e.onSaved(i=>{i.intent==="publish"&&t({event:"save",action:"save_email",email_id:i.serverId??void 0,project_id:n,subscription:o})}),[e,t,n,o])}function pg(e){const t=r.useStore();(0,l.useEffect)(()=>{},[t,e])}function mg(e,t,n){const o=r.useAppNavigate(),i=r.useContainer();(0,l.useEffect)(()=>{},[o,e,t,n,i])}function fg(e){if(!e)return{status:"unknown"};if("status"in e){const t=e.data,n=t&&typeof t=="object"?t.message:void 0,o=typeof n=="string"?n:typeof t=="string"?t:void 0;return{status:String(e.status),message:o}}return{status:e.name??"unknown",message:e.message}}function Ns(e,t,n){const{status:o,message:i}=fg(n);r.reportMessage(`Failed to load ${e} ${t??"?"}: ${o}`,{origin:"entity-load-error",tags:{mechanism:"entity-load-error",entity_type:e,http_status:o},level:"error",contexts:{entity_load_error:{entityType:e,entityId:t,status:o,message:i,url:window.location.href}}})}var{Content:gg}=_.ui_kit$Layout,hg={paddingTop:"40px"},_g=()=>{const{__:e}=r.useI18n(),{owner:t,admin:n}=Qn(),o=r.useDispatch(),i=qr(),s=r.useAppNavigate(),{modal:c}=_.ui_kit$App.useApp(),d=r.useAppConfig(),u=r.useRootElement(),p=r.useCookieManager(),f=r.useMessageService(),{emailId:g,preview:y}=r.useRouteParams(),m=r.useEditorProjectId(),S=r.useAppSearchParams(),k=r.useSelector(r.selectIsCodeMode),w=r.useSelector(r.selectActiveModal),b=r.useCurrentUser(),A=r.useProjectData(),x=(0,l.useMemo)(()=>r.createNewEmailDraft(A?{id:Number(A.id),title:A.name}:void 0),[A]),Y=r.useSelector(r.selectIsGlobalLoading),[Z]=r.useLazyGetMeQuery(),{isSuccess:M,data:O}=r.useGetSubscriptionsQuery(),I=Nf(),[R,z]=(0,l.useState)(!1),[B,U]=(0,l.useState)(!1),[de,me]=(0,l.useState)(),[q,ee]=(0,l.useState)(null),[Fe,be]=(0,l.useState)(!1),[et,Ee]=(0,l.useState)(!1),[fe,Q]=(0,l.useState)(!1),[pe,se]=(0,l.useState)(!1),[ae,Ie]=(0,l.useState)(!1),Ce=(0,l.useRef)(),{confirm:Be}=c,{counters:J,subscription:_e}=b,Te=J?.emails_counter;p.get(r.APP_COOKIES.em_template_email);const ge=S.get("template")||!B&&!g&&p.get(r.APP_COOKIES.em_new_email),{isSuccess:Re,isLoading:ze,isError:C,error:T,data:P}=Mf(g?void 0:ge),N=ag({templateEmailId:ge,templateEmail:P,newEmail:x});lg({routeEmailId:g,draft:N});const{document:D,email:v,error:W}=r.useOpenEmail(),Pe=v?.id!=null?String(v.id):void 0,Ae=cg(g,Pe);(0,l.useEffect)(()=>{},[g,Pe,D,ge]),mg(g,v?.id,m);const Qe=r.useStore(),Ge=r.getEmailDocuments(h.getContainer(Qe)),Ze=(0,l.useCallback)((ce,we)=>Ge.save(ce,we),[Ge]),pt=(0,l.useCallback)(()=>Ge.saveState(),[Ge]),bt=r.usePushToDataLayer();ug({documents:Ge,push:bt,projectId:m,subscription:_e?.post_title}),(0,l.useEffect)(()=>{!B&&v?.id&&U(!0)},[U,B,v?.id]);const ft=Ge.history();sg(D,ft),ig(ft),og(v,dg(g),Ae,D);const lt=Xr({document:D,history:ft});Uf(v,D,Ge.saveState().saving,Ge),pg(m),(0,l.useEffect)(()=>{r.injectEmailRightsResolver(h.getContainer(Qe),ce=>!!(t||n||b.id?.toString()===ce?.author?.toString()))},[Qe,t,n,b.id]);const G=Vp({email:v,save:Ze,saveState:pt,documentSession:D}),{outdatedBlocks:K,isOpen:ne,close:ue}=ff({projectId:m,document:D});$f({projectId:m,project:A,emailProjectId:v?.project,parentEmailId:v?.parent_email});const he=w===r.MODALS.ADD_NEW_EBLOCK_MODAL,We=kn(he),Ve=kn(fe),{isPromptOpen:st,isConverting:Bt,progress:Me,isErrorOpen:Xe,errorMessage:ie,confirmConversion:te,cancelPrompt:$,retryConversion:le,closeError:xe,neverSuggestAgain:Se,setNeverSuggestAgain:Ne}=Rf(),He=W??(ge?T:void 0),$e=!!He,ot=!v&&!$e,fn=!!v;(0,l.useEffect)(()=>{$e&&He&&Ns("email",g||ge,He)},[$e,He,g,ge]),(0,l.useEffect)(()=>{ge&&Re&&(U(!0),S.set({}))},[ge,Re,S]),(0,l.useEffect)(()=>(o(r.switchIsPanelHistoryCollapsed(!0)),()=>o(r.switchIsPanelHistoryCollapsed(!0))),[o]);const Ot=(0,l.useCallback)(()=>{i.toggle(),o(r.resetPanes())},[o,i]);(0,l.useEffect)(()=>{y&&!k&&Ot()},[k,y,Ot]),(0,l.useEffect)(()=>{document.body.classList.add("editor"),o(r.setActiveSettingsTab(r.BUILD))},[o]),(0,l.useEffect)(()=>{!R&&Te<3&&(Z(),z(!0))},[Z,Te,R]);const ct=(0,l.useCallback)(()=>{lt.undo()},[lt]),Et=(0,l.useCallback)(()=>{lt.redo()},[lt]);(0,l.useEffect)(()=>{Ce.current!==v?.id&&(lt.clear(),Ce.current=v?.id)},[v,lt]);const Lt=(0,l.useCallback)(ce=>{(window.navigator.appVersion.indexOf("Mac")&&ce.metaKey||ce.ctrlKey)&&ce.code==="KeyZ"&&(ce.preventDefault(),ce.shiftKey?Et():ct())},[ct,Et]);(0,l.useEffect)(()=>()=>{o(r.resetPanes()),o(r.closeModal()),o(r.closeModal$1()),o(r.resetElementHistorySlice())},[o]);const Rn=(0,l.useCallback)(ce=>{const we=()=>{o(r.openModal(r.MODALS.ADD_NEW_EBLOCK_MODAL))},De=ce.data.operation,nt=ce.data,Oe=ce.data.action,Yt=u.querySelector("#iframe-scroll-top"),$t=u.querySelector("#iframe-scroll-bottom");if(De===r.EVENT_TYPES.APPLICATION_EBLOCK_ADD){const dt=nt.settings?.emBlockId;dt?ee({html:nt.data,emBlockId:String(dt)}):(me(nt.data),we())}if(De===r.EVENT_TYPES.APPLICATION_ACTION&&(Oe==="undo"?ct():Oe==="redo"&&Et()),De===r.EVENT_TYPES.APPLICATION_SCROLL_BLOCK_SHOW){const dt=u.querySelector("#email_iframe_slot"),Nn=document.body.getBoundingClientRect().height,Ut=dt.getClientRects()[0];Ut.top<0&&(Yt.style.display="block"),Ut.top+Ut.height>Nn&&($t.style.display="block")}De===r.EVENT_TYPES.APPLICATION_SCROLL_BLOCK_HIDE&&(Yt.style.display="none",$t.style.display="none")},[o,ct,Et,u]);r.useListenPostMessage(Rn);const On=ce=>{if(ce.target?.closest?.(".file-manager, .ant-modal.file-manager"))return;const we=ce.dataTransfer,De=(we?Array.from(we.types||[]):[]).includes(r.DND_SOCIAL_LIST_REORDER_MIME),nt=typeof ce.composedPath=="function"?ce.composedPath():[];ce.target?.closest?.(".selected-social-form")||nt.some(Oe=>Oe&&Oe.nodeType===1&&typeof Oe.classList?.contains=="function"&&Oe.classList.contains("selected-social-form"))||De||(ce.preventDefault(),ce.target&&f.send({operation:r.EVENT_TYPES.SANDBOX_DRAG_CANCEL}),u.querySelectorAll(".em-dragging-element").forEach(Oe=>{Oe.classList.remove("em-dragging-element")}))},gn=(0,l.useRef)({});(0,l.useEffect)(()=>{const ce=new h.Disposable,we=De=>nt=>gn.current[De]?.(nt);return ce.addDisposable(r.addWindowListenerFromShadow(u,"drop",we("drop"))),ce.addDisposable(r.addWindowListenerFromShadow(u,"dragover",we("dragover"))),ce.addDisposable(r.addWindowListenerFromShadow(u,"dragstart",we("dragstart"))),ce.addDisposable(r.addWindowListenerFromShadow(u,"dragend",we("dragend"))),()=>{ce.dispose()}},[u]),(0,l.useEffect)(()=>(window.addEventListener("keydown",Lt),()=>{window.removeEventListener("keydown",Lt)}),[Lt]);const Ln=ce=>{if(ce.preventDefault(),ce.target?.closest?.(".file-manager, .ant-modal.file-manager"))return;const we=u.querySelector("#iframe-scroll-top"),De=u.querySelector("#iframe-scroll-bottom"),nt=d.sidePanelFloating?u.querySelector("#pane-content-wrapper"):u.querySelector(".email-pane__col_preview"),Oe=u.querySelector(".blocks-app").getBoundingClientRect().top,{height:Yt,top:$t}=u.querySelector("#email_iframe_slot").getBoundingClientRect(),dt=nt.getBoundingClientRect().height;$t>96?we.style.display==="block"&&(we.style.display="none"):(we.style.display==="none"||we.style.display==="")&&(we.style.display="block"),Yt-dt+$t-Oe<44?De.style.display==="block"&&(De.style.display="none"):De.style.display==="none"&&(De.style.display="block"),ce.target===we&&nt.scrollBy(0,-15),ce.target===De&&nt.scrollBy(0,15)},Mn=()=>{const ce=u.querySelector("#iframe-scroll-top"),we=u.querySelector("#iframe-scroll-bottom");ce&&we&&(ce.style.display="none",we.style.display="none"),u.querySelectorAll(".em-dragging-element").forEach(De=>{De.classList.remove("em-dragging-element")})},gt=ce=>{const we=ce.target,De=we instanceof Element?we:we.parentElement;if(!(De instanceof Element)||De.closest(".selected-social-form"))return;De.parentElement?.classList.add("em-dragging-element");const nt=!!De.closest(".blocks-search__result-wrapper");var Oe=nt?r.cloneBlockPreviewForDrag(De.querySelector(".blocks-search__result-html")):De.cloneNode(!0);Oe.classList.add("em-ghost-element"),Oe.style.height=nt?"auto":"70px",Oe.style.width=nt?"600px":"109px",Oe.style.position="absolute",Oe.style.top="0",Oe.style.left="0",Oe.style.zIndex="-1",De.appendChild(Oe),ce.dataTransfer.setDragImage(Oe,0,0),window.setTimeout(function(){Oe.parentNode.removeChild(Oe)},1e3)};gn.current={drop:On,dragover:Ln,dragstart:gt,dragend:Mn};const St=(0,l.useCallback)(()=>{Be({title:e("You reached the plan limit"),icon:(0,a.jsx)(r.EmIcons,{icon:"ExclamationCircleOutlined",component:_.icons$ExclamationCircleOutlined}),content:(0,a.jsx)("div",{style:{maxWidth:"330px"},children:e("Switch to a different plan to save more emails.")}),centered:!0,okText:e("Choose a plan"),cancelText:e("Continue without saving"),width:"unset",onOk(){s("/billing")},onCancel(){}})},[s,e,Be]);return(0,l.useEffect)(()=>{if(M&&O){const ce=O?.find(we=>we.id?.toString()===_e?.ID?.toString())?.limits?.emails_limit;ce&&Te>=ce&&!Fe&&!g&&t&&(St(),be(!0))}},[O,M,_e,Te,Fe,St,g,t]),(0,l.useEffect)(()=>{const ce=f.onInit(()=>{f.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1})});return()=>ce.dispose()},[f]),(0,a.jsx)(r.DocumentSessionProvider,{document:D,history:ft,children:(0,a.jsx)(gs.Provider,{value:G,children:(0,a.jsxs)(_.ui_kit$Layout,{className:"email-page",children:[ot&&(0,a.jsx)(_.ui_kit$PageLoader,{}),!ot&&I.status==="pending"&&(0,a.jsx)(_.ui_kit$PageLoader,{}),I.status==="error"&&(0,a.jsx)(gg,{style:hg,children:(0,a.jsx)("div",{className:"container",children:(0,a.jsx)(_.ui_kit$Result,{status:"warning",title:e("Failed to load plan data"),subTitle:e("Editor features depend on your plan. Check your connection and try again."),extra:(0,a.jsx)(_.ui_kit$Button,{type:"primary",onClick:I.retry,children:e("Try again")})})})}),$e&&He&&!1,v&&!ot&&I.status==="ready"&&(0,a.jsxs)(_.ui_kit$Layout,{className:"email-pane",children:[Y&&(0,a.jsx)("div",{className:"email-pane__loader",children:(0,a.jsx)(_.ui_kit$PageLoader,{small:!0})}),(0,a.jsx)(Ts,{email:v,isCollaborationEditor:et}),(0,a.jsx)(Mp,{emailElement:v,isSuccess:fn,setIsCollaborationEditor:Ee,setIsShowAddAllBlocksModal:Q,triggerOpenSavedBlocksTab:pe})]}),We&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(ku,{isModalVisible:he,htmlContent:de,projectId:m,setIsShowAddAllBlocksModal:Q,setIsShowAddAllBlocksModalForNewEmail:Ie,currentEmail:v})}),(0,a.jsx)(uf,{open:ne,blocks:K,projectId:m,onClose:ue}),(0,a.jsx)(gf,{open:!!q,html:q?.html,emBlockId:q?.emBlockId,onSaveAsNew:()=>{me(q?.html),ee(null),o(r.openModal(r.MODALS.ADD_NEW_EBLOCK_MODAL))},onClose:()=>ee(null)}),Ve&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(Cu,{isModalVisible:fe,currentEmail:v,setIsShowAddAllBlocksModal:Q,setTriggerOpenSavedBlocksTab:se,autoStart:!ae,projectId:m})}),(0,a.jsx)(vf,{open:st,onConfirm:te,onCancel:$,neverSuggestAgain:Se,onNeverSuggestAgainChange:Ne}),(0,a.jsx)(Sf,{open:Bt,progress:Me}),(0,a.jsx)(Ef,{open:Xe,message:ie,onRetry:le,onCancel:xe})]})})})};function yg(){const e=r.useStore(),t=r.getEmailDocuments(h.getContainer(e)),n=(0,l.useCallback)(o=>t.subscribe(o),[t]);return(0,l.useSyncExternalStore)(n,()=>!!t.current())}function vg(e,t){const n=r.useStore(),o=r.useAppConfig(),i=r.useStorageProvider();(0,l.useRef)(new Set),(0,l.useEffect)(()=>{},[e,t,o,n,i])}var bg=30;function Eg(e){const t=r.useContainer(),n=r.useGetProjectQuery(+e,{skip:!e,refetchOnMountOrArgChange:bg}),{isSuccess:o,isError:i,error:s,data:c,isFetching:d}=n;vg(e,o),(0,l.useEffect)(()=>{t&&r.setCurrentProjectRefreshing(t,d)},[t,d]),(0,l.useEffect)(()=>{t&&o&&c&&String(c.id)===String(e)&&r.setCurrentProjectCard(t,c)},[o,c,t,e]),(0,l.useEffect)(()=>{i&&s&&Ns("project",e,s)},[i,s,e]);const u=r.useProjectData(),p=!!u&&String(u.id)===String(e);return{...n,projectReady:p}}var An=r.createApi({reducerPath:"promoApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.emailmaker.ru/api/wp-json/promo/v1/"}),endpoints:e=>({checkPromo:e.mutation({queryFn:({code:t,type:n},o)=>r.clientFromApi(o).promo.set_code_create({code:t,type:n})}),getPromoInfo:e.query({queryFn({code:t},n){return r.clientFromApi(n).promo.get_code_info_list({code:t})}})})}),{useCheckPromoMutation:ib,useGetPromoInfoQuery:sb}=An;function Sg(){const e=r.useContainer(),[t,n]=(0,l.useState)();return(0,l.useEffect)(()=>{if(!e)return;let o=!0;return r.getAppProject(e).then(i=>{o&&i!=null&&n(String(i))},()=>{}),()=>{o=!1}},[e]),t}var wg=()=>{const e=r.useDispatch(),t=r.useCookieManager(),n=r.useCurrentUser(),o=r.useContainer();(0,l.useEffect)(()=>{const s=n?.code_editor;s&&o&&r.applyEditorOptions(o,s)},[n,o]),(0,l.useEffect)(()=>{const s=t.get(r.APP_COOKIES.em_token),c=t.get(r.APP_COOKIES.promocode);s&&c&&(e(An.endpoints.checkPromo.initiate({code:c,type:"by_link"})),t.remove(r.APP_COOKIES.promocode))},[e,t]),r.useNotifyCommand();const i=yg();return Eg(Sg()),i?(0,a.jsx)(Yl,{hasEmail:!0,children:(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(_g,{})})}):null};function kg(e,t){const n=(0,l.useRef)(!1);(0,l.useEffect)(()=>{!e||n.current||(n.current=!0,r.mark(r.PHASES.appVisible),t&&Ht(t).noteShellVisible())},[e,t])}var xn=new WeakMap,Cg="data-useblocks-config-styles";function Tg(e){return typeof e=="string"?e.trim():""}function Ds(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function Ig(e,t,n){if(!e||typeof document>"u")return null;const o=Tg(t),i=xn.get(e),s=n||e;if(!o)return i&&(i.remove(),xn.delete(e)),null;if(i)return i.textContent!==o&&(i.textContent=o),(i.parentNode!==s||i!==s.firstChild)&&Ds(s,i),i;const c=document.createElement("style");return c.setAttribute(Cg,"true"),c.textContent=o,Ds(s,c),xn.set(e,c),c}function yo(e){if(!e)return;const t=xn.get(e);t&&(t.remove(),xn.delete(e))}var Ag={height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},xg=({children:e,handleBeforeRender:t})=>{const[n,o]=(0,l.useState)(),i=r.useIsLocaleInited();kg(i,r.useContainer());const s=r.useAppConfig().styles,c=(0,l.useRef)(null),d=(0,l.useRef)(!1),u=(0,l.useRef)(void 0),p=r.useRootElement();return(0,l.useLayoutEffect)(()=>{d.current||(d.current=!0,t&&t())},[]),(0,l.useLayoutEffect)(()=>{if(!p){u.current&&(yo(u.current),u.current=void 0);return}u.current&&u.current!==p&&yo(u.current),Ig(p,s,c.current||void 0),u.current=p},[p,s]),(0,l.useLayoutEffect)(()=>()=>{u.current&&(yo(u.current),u.current=void 0)},[]),(0,a.jsxs)(_.ui_kit$StyleProvider,{container:r.findShadowRoot(p)||document.head,children:[(0,a.jsxs)("div",{ref:c,className:"App blocks-app blocks-plugin",style:i?{}:{visibility:"hidden"},children:[(0,a.jsx)(r.ModalRootContext.Provider,{value:n,children:e}),(0,a.jsx)("div",{ref:o,className:"blocks-modal-container"})]}),!i&&(0,a.jsx)(_.ui_kit$Space,{size:"large",style:Ag,children:(0,a.jsx)(_.ui_kit$Spin,{size:"large"})})]})};async function Pg({container:e,renderTarget:t,mapKey:n,disposable:o,chunkLoadedFire:i}){const s=await e.getInstanceAsync(h.STORE_ID);return new Promise(c=>{if(o.isDisposed()){c();return}const d=(0,tl.createRoot)(t),u=(0,a.jsx)(r.Provider,{store:s,children:(0,a.jsx)(Gl,{onLoad:c,children:(0,a.jsx)(r.RootContext.Provider,{value:{element:n},children:(0,a.jsx)(_.ui_kit$StyleProvider,{container:r.isDocumentFragment(n)?document.head:n,children:(0,a.jsx)(r.LocaleProvider,{children:(0,a.jsx)(xg,{handleBeforeRender:i,children:(0,a.jsx)(ul,{children:(0,a.jsx)(zl,{children:(0,a.jsx)(wg,{})})})})})})})})});d.render(u),o.addDispose(c),o.addDispose(()=>{try{d.unmount()}catch(p){if(p instanceof DOMException&&p.name==="NotFoundError"||p instanceof Error&&p.name==="NotFoundError"&&/removeChild/i.test(p.message)){r.logShowPipelineError("mount:unmount-dom-mismatch (host container was already removed)",{hint:"Usually harmless during host React StrictMode teardown. Ensure instance.destroy() runs before the host removes the mount container."});return}throw p}}),o.addDispose(()=>{h.ELEMENT_MAP.delete(n)})})}var ab="multiple init call on single HTMLELEMENT",jg=zn(async e=>{let t=null,n=!1;const o=h.getEmitter(e,h.events.ON_CHUNKS_LOADED),i=e.getInstance(h.DISPOSABLE_ID);let s,c=!1;const d=()=>{c||(c=!0,r.mark(r.PHASES.chunksLoaded),o.fire())},u=(p,f)=>Pg({container:e,renderTarget:p,mapKey:f,disposable:s,chunkLoadedFire:d});return{instance:{getElement(){return t}},async setOptions(p){const f=e.getInstance(h.INIT_PIPELINE_ID),g=await h.waitForElement(p.element,i,f.signal),y=e.getInstance(h.INSTANCE_ID),m=!!p.hidden&&!!g;if(t===g&&n===m)return;const S=t===g&&n&&!m;n=m,i.addDisposable(o.event(()=>{p.handleChunkLoaded&&p.handleChunkLoaded()})),t&&h.ELEMENT_MAP.delete(t),g&&h.ELEMENT_MAP.has(g),s&&s.dispose(),s=i.addDisposable(new h.Disposable);const k=p.element!==void 0;if(r.setHeadlessMode(e,!g||m),r.setHiddenMount(e,m),!g){r.mark(r.MOUNT_HEADLESS_MARK);const b=document.createElement("div");b.style.position="absolute",b.style.left="-10000px",b.style.top="-10000px",b.style.width="1600px",b.style.height="1000px",document.body.appendChild(b),t=b,d(),s.addDispose(()=>{b.parentNode===document.body&&b.remove()});return}const w=r.findShadowRoot(g);if(w&&s.addDisposable(new dl({shadowRoot:w})),k&&g instanceof Element){const b=g;ol(b,()=>{i.isDisposed()||s?.isDisposed()||(r.logShowPipelineError("mount:detached (host removed element without destroy)",{elementId:b.id||null}),f.abort(rl()))},s)}if(m){r.mark(r.MOUNT_HEADLESS_MARK),t=g,d();return}if(k&&g instanceof Element){const b=g,A=ll(b);t=b;const x=u(A,b);return cl(b,A,s),x}return t=g,u(g,g)},dispose(){s&&!s.isDisposed()&&s.dispose()}}});function vo(e){return zn(async t=>(await t.getInstanceAsync(h.STORE_ID),await e(t)))}function Rg({html:e,renderGuid:t,...n},o){const{requested:i}=r.getCurrentProject(o);return r.filterUndefined({...n,code:on(o).toOutputForm(e),project:i===void 0?n.project:i,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function Og(e,t){return r.filterUndefined({...e,link:void 0,comment_status:void 0})}function Lg({html:e,...t},n){return r.filterUndefined({...t,code:e,guid:void 0,compiled:r.filterUndefined({html:e,ampHtml:e&&""})})}var Fs=e=>{const t={current:Promise.resolve(),state:e,decorate:(n,o)=>(o&&(n=n.bind(o)),function(...i){const s=t.current.then(()=>n(...i));return t.current=s.then(c=>{t.state=c},c=>{}),s})};return t},Mg=h.createIdentifier$1("emailTemplate.reads");async function Ng(e,t){try{return await r.getRestEmailPortFactories(e).email(e).readEmail(t)??void 0}catch(n){r.logShowPipelineError("show:template-read-failed",{templateId:t,error:n instanceof Error?n.message:"неизвестная ошибка"});return}}function Dg(e,t){const n=e.getOrCreateInstance(Mg,()=>new Map),o=n.get(t);if(o!==void 0)return o;const i=Ng(e,t).then(s=>(s===void 0&&n.delete(t),s));return n.set(t,i),i}var kt=class extends h.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 Ct(e,t,n){const o=h.snapshot(e);return(i,s,c)=>{const d=o(async u=>{const p=t?t(u):u;c&&i.bind(c);const f=await i(p);return n?n(f):f},s,c);return()=>d.dispose()}}var lb=h.createIdentifier("application_block_inserted"),cb=h.createIdentifier$1("DataController"),db=h.createIdentifier$1("DataEvents"),Fg=h.createIdentifier$1("plugin.startupShow");function Bg(e){return e.getInstance(Fg)?.current??Promise.resolve()}var Bs=vo(async()=>({instance:{}})),$s=vo(async e=>({instance:{},async setOptions(){await Bg(e)}})),ub=h.combineMixins([Bs,$s]),Us=()=>({title:"",description:"",website:"",company_size:"",industry:"",email:"",phone:"",logo_url:""}),$g={title:"title",description:"description",website:"website",company_size:"company_size",industry:"industry",email:"email",phone:"phone",logo_url:"logo"},zs=e=>({...Us(),title:e?.title??"",description:e?.description??"",website:e?.website??"",company_size:e?.company_size??"",industry:e?.industry??"",email:e?.email??"",phone:e?.phone??"",logo_url:e?.logo??""}),Gs=e=>(e??[]).filter(t=>!!t?.code).map(({code:t,label:n})=>({value:t,label:n??t})),Ug=e=>({company_sizes:Gs(e?.company_sizes),industries:Gs(e?.industries)}),pb=Object.keys(Us()),Ws="ProjectProfile",Pn=r.createApi({reducerPath:"projectSettingsProfileApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),tagTypes:[Ws],endpoints:e=>({getProjectProfile:e.query({async queryFn(t,n){const o=r.v2ResultOf(await r.getClientV2(h.getContainer(n)).projects.profileList({id:String(t)}));return"error"in o?{error:o.error}:{data:zs(o.data)}},providesTags:(t,n,o)=>[{type:Ws,id:String(o)}]}),getProjectProfileOptions:e.query({async queryFn(t,n){const o=r.v2ResultOf(await r.getClientV2(h.getContainer(n)).projects.profileOptionsList());return"error"in o?{error:o.error}:{data:Ug(o.data)}}}),updateProjectProfileField:e.mutation({async queryFn({projectId:t,field:n,value:o},i){const s={[$g[n]]:o},c=r.v2ResultOf(await r.getClientV2(h.getContainer(i)).projects.profilePartialUpdate({id:String(t)},s));return"error"in c?{error:c.error}:{data:zs(c.data)}},async onQueryStarted({projectId:t},{dispatch:n,queryFulfilled:o}){try{const{data:i}=await o;n(Pn.util.updateQueryData("getProjectProfile",t,()=>i))}catch{}}})})}),{useGetProjectProfileQuery:mb,useGetProjectProfileOptionsQuery:fb,useUpdateProjectProfileFieldMutation:gb}=Pn,Hs="ProjectStorage",jn=r.createApi({reducerPath:"projectSettingsStorageApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),tagTypes:[Hs],endpoints:e=>({getProjectStorage:e.query({async queryFn(t,n){const o=r.v2ResultOf(await r.getClientV2(h.getContainer(n)).projects.storageList({id:String(t)}));return"error"in o?{error:o.error}:{data:o.data}},providesTags:(t,n,o)=>[{type:Hs,id:String(o)}]}),updateProjectStorage:e.mutation({async queryFn({projectId:t,body:n},o){const i=r.v2ResultOf(await r.getClientV2(h.getContainer(o)).projects.storageUpdate({id:String(t)},n));return"error"in i?{error:i.error}:{data:i.data}},async onQueryStarted({projectId:t},{dispatch:n,queryFulfilled:o}){const{data:i}=await o;n(jn.util.upsertQueryData("getProjectStorage",t,i))}}),testProjectStorageConnection:e.mutation({async queryFn({projectId:t,body:n},o){const i=r.v2ResultOf(await r.getClientV2(h.getContainer(o)).projects.storageTestCreate({id:String(t)},n));return"error"in i?{error:i.error}:{data:i.data}}})})}),{useGetProjectStorageQuery:hb,useUpdateProjectStorageMutation:_b,useTestProjectStorageConnectionMutation:yb}=jn,zg=class{http;constructor(e){this.http=e}settings_summary_detail=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/settings-summary/${e}`,method:"GET",...n})},qs=class{http;constructor(e){this.http=e}developer_credentials_detail=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/developer-credentials/${e}`,method:"GET",...n});developer_credentials_partial_update=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/developer-credentials/${e}`,method:"PATCH",...n});developer_credentials_rotate_secret_create=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/developer-credentials/${e}/rotate-secret`,method:"POST",...n});developer_credentials_verify_secret_create=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/developer-credentials/${e}/verify-secret`,method:"POST",...n})},Gg=class{http;constructor(e){this.http=e}developer_kit_postman_collection_list=(e={})=>this.http.request({path:"/projects/v1/developer-kit/postman-collection",method:"GET",...e})},Wg=class{http;constructor(e){this.http=e}billing_context_detail=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/billing-context/${e}`,method:"GET",...n});billing_context_payments_list=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/billing-context/${e}/payments`,method:"GET",query:t,...n})},Hg=class{http;constructor(e){this.http=e}usage_detail=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/usage/${e}`,method:"GET",...n});usage_timeseries_list=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/usage/${e}/timeseries`,method:"GET",query:t,...n})},Ye={PLUGIN_INIT:"plugin_init",LINK_CHECK:"link_check",IMAGE_CHECK:"image_check",SPAM_ASSASSIN:"spam_assassin",AI_IMAGE:"ai_image",AI_WRITE:"ai_write",AI_REPHRASE:"ai_rephrase"},Zt={TODAY:"today",WEEK:"week",MONTH:"month",CUSTOM:"custom"},vb=[Ye.PLUGIN_INIT,Ye.LINK_CHECK,Ye.IMAGE_CHECK,Ye.SPAM_ASSASSIN,Ye.AI_IMAGE,Ye.AI_WRITE],ln={current:0,limit:null},qg=()=>({pluginInit:{...ln},aiAssistant:{...ln},aiImage:{...ln},linkCheck:{...ln},imageCheck:{...ln},spamAssassin:{...ln}}),tt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Je=(e,t,n="")=>{for(const o of t){const i=e[o];if(typeof i=="string")return i;if(typeof i=="number"&&Number.isFinite(i))return String(i)}return n},Ft=(e,t,n=0)=>{for(const o of t){const i=e[o];if(typeof i=="number"&&Number.isFinite(i))return i;if(typeof i=="string"&&i.trim()&&Number.isFinite(Number(i)))return Number(i)}return n},bo=(e,t,n=!1)=>{for(const o of t){const i=e[o];if(typeof i=="boolean")return i}return n},br=(e,t)=>{for(const n of t){const o=e[n];if(o===null)return null;if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"&&o.trim()&&Number.isFinite(Number(o)))return Number(o)}return null},Vg=new Set(Object.values(Ye)),Kg=e=>Vg.has(e)?e:null,en=e=>tt(e)&&"data"in e&&(e.ok===!0||typeof e.success=="boolean"||e.success===void 0)?e.data:e,cn=(e,t)=>{for(const n of t){const o=e[n];if(tt(o))return o}return null},Yg=(e,t)=>{for(const n of t){const o=e[n];if(!Array.isArray(o))continue;const i=o.filter(s=>typeof s=="string");if(i.length>0)return i}},Qg=e=>tt(e)?{clientId:Je(e,["clientId","client_id"]),clientSecretConfigured:bo(e,["clientSecretConfigured","client_secret_configured"]),rotatedAt:Je(e,["rotatedAt","rotated_at"])||void 0,scopesSuggested:Yg(e,["scopesSuggested","scopes_suggested"])}:{clientId:"",clientSecretConfigured:!1},Vs=(e,t)=>{for(const n of t){const o=e[n];if(typeof o=="boolean")return o}},Xg=e=>{const t=Vs(e,["pluginConnected","plugin_connected","connected","is_connected"]);if(t!==void 0)return t;for(const n of["plugin","developer_credentials","developerCredentials"]){const o=cn(e,[n]);if(!o)continue;const i=Vs(o,["connected","plugin_connected","is_connected"]);if(i!==void 0)return i;const s=Je(o,["clientId","client_id"]),c=bo(o,["clientSecretConfigured","client_secret_configured"]);if(s)return c}},Jg=e=>{const t=en(e);if(!tt(t))return{};const n=cn(t,["members"]);return{myRole:Je(t,["myRole","my_role","role"])||(n?Je(n,["myRole","my_role","role"]):"")||void 0,pluginConnected:Xg(t)}},Zg=e=>tt(e)?{clientId:Je(e,["clientId","client_id"]),secret:Je(e,["secret","clientSecret","client_secret"])}:{clientId:"",secret:""},eh=e=>{if(!tt(e))return null;const t=Je(e,["event","type","key"]),n=Kg(t);if(!n)return null;const o=e.delta??e.change??e.trend,i=o==null?null:typeof o=="number"&&Number.isFinite(o)?o:Number.isFinite(Number(o))?Number(o):null;return{event:n,total:Ft(e,["total","count","value"],0),delta:i}},Ks=e=>{if(!tt(e))return null;const t=Je(e,["date","day","x"]);if(!t)return null;const n={date:t},o=e.event_counts??e.eventCounts;if(tt(o)){for(const[i,s]of Object.entries(o))typeof s=="number"&&Number.isFinite(s)&&(n[i]=s);return n}for(const[i,s]of Object.entries(e))i==="date"||i==="day"||i==="x"||i==="event_counts"||i==="eventCounts"||typeof s=="number"&&Number.isFinite(s)&&(n[i]=s);return n},th=e=>{const t=en(e);return tt(t)?(Array.isArray(t.chart)?t.chart:Array.isArray(t.series)?t.series:Array.isArray(t.time_series)?t.time_series:Array.isArray(t.history)?t.history:[]).map(Ks).filter(n=>n!==null):[]},nh=e=>{if(!tt(e))return{current:0,limit:null};const t=Ft(e,["current","count","used","value","total"],0),n=br(e,["limit","max","quota","cap"]);return{current:t,limit:n===null?null:n}},dn=(e,t)=>{for(const n of t)if(n in e)return nh(e[n]);return{current:0,limit:null}},un={pluginInit:[Ye.PLUGIN_INIT,"plugin_init","pluginInit"],aiAssistant:["ai_assistant","aiAssistant","ai"],aiImage:[Ye.AI_IMAGE,"ai_image","ai_img","aiImg"],linkCheck:[Ye.LINK_CHECK,"link_check","linkCheck"],imageCheck:[Ye.IMAGE_CHECK,"image_check","imageCheck"],spamAssassin:[Ye.SPAM_ASSASSIN,"spam_assassin","spamAssassin","spam_check","spamCheck"]},Eo=e=>{const t=qg(),n=en(e),o=tt(n)&&tt(n.usage)?n.usage:n;if(!tt(o))return t;const i=Ft(o,["operationsTotal","operations_total"],0),s=Ft(o,["operationsLast30d","operations_last_30d"],0),c=cn(o,["metrics","counters","limits","events","usage_by_event","usageByEvent"])??o;return{pluginInit:dn(c,un.pluginInit),aiAssistant:dn(c,un.aiAssistant),aiImage:dn(c,un.aiImage),linkCheck:dn(c,un.linkCheck),imageCheck:dn(c,un.imageCheck),spamAssassin:dn(c,un.spamAssassin),lastActivityAt:Je(o,["lastActivityAt","last_activity_at"])||void 0,operationsTotal:i>0?i:void 0,operationsLast30d:s>0?s:void 0}},Ys=(e,t)=>{const n=[{event:Ye.LINK_CHECK,total:e.linkCheck.current,delta:null},{event:Ye.IMAGE_CHECK,total:e.imageCheck.current,delta:null},{event:Ye.SPAM_ASSASSIN,total:e.spamAssassin.current,delta:null},{event:Ye.AI_IMAGE,total:e.aiImage.current,delta:null}],o=t?th(t):[];return o.length>0?{cards:n,chart:o}:{cards:n,chart:[]}},rh=e=>{const t=en(e);if(!tt(t))return Ys(Eo(e),e);const n=Array.isArray(t.cards)?t.cards:Array.isArray(t.summary)?t.summary:[],o=Array.isArray(t.chart)?t.chart:Array.isArray(t.series)?t.series:[];return n.length>0||o.length>0?{cards:n.map(eh).filter(i=>i!==null),chart:o.map(Ks).filter(i=>i!==null)}:Ys(Eo(t),t)},oh=e=>{if(!tt(e))return null;const t=Je(e,["id","payment_id"]);return t?{id:t,date:Je(e,["date","created_at","paid_at"]),amount:Ft(e,["amount","sum"],0),currency:Je(e,["currency"],"RUB"),status:Je(e,["status"],"unknown"),receiptUrl:Je(e,["receiptUrl","receipt_url","pdf_url"])||void 0}:null},ih=e=>{const t=en(e),n=tt(t)&&Array.isArray(t.payments)?t.payments:[];return{payments:n.map(oh).filter(o=>o!==null),page:tt(t)?Ft(t,["page"],1):1,perPage:tt(t)?Ft(t,["perPage","per_page"],20):20,total:tt(t)?Ft(t,["total"],n.length):n.length,totalPages:tt(t)?Ft(t,["totalPages","total_pages"],1):1}},sh=e=>{const t=en(e);if(!tt(t))return{viewerSeesBilling:!1};const n=cn(t,["endpoints"])??{},o=cn(t,["documentLinks","document_links"]),i=o?Object.fromEntries(Object.entries(o).filter(f=>typeof f[1]=="string")):void 0,s=br(t,["ownerUserId","owner_user_id"]),c=cn(t,["tariff","plan","subscription"]),d=Je(t,["planDescription","plan_description"])||(c?Je(c,["description","about","plan_description"]):"")||void 0,u=br(t,["planPrice","plan_price","price","amount"])??(c?br(c,["price","amount"]):null),p=Je(t,["planCurrency","plan_currency","currency"])||(c?Je(c,["currency"]):"")||void 0;return{viewerSeesBilling:bo(t,["viewerSeesBilling","viewer_sees_billing"]),ownerUserId:s??void 0,planName:Je(t,["planName","plan_name"])||void 0,planDescription:d,planPrice:u??void 0,planCurrency:p||void 0,endpoints:{limitsStats:Je(n,["limitsStats","limits_stats"])||void 0,subscriptionMe:Je(n,["subscriptionMe","subscription_me"])||void 0,payments:Je(n,["payments"])||void 0},documentLinks:i&&Object.keys(i).length>0?i:void 0}},ah={myRole:"owner"},lh=()=>({...ah}),ch={clientId:"rust-awkward-bear",clientSecretConfigured:{}.REACT_APP_PLUGIN_SETTINGS_MOCK_CONNECTED!=="false"},Qs=()=>({...ch,clientSecretConfigured:{}.REACT_APP_PLUGIN_SETTINGS_MOCK_CONNECTED!=="false"}),Xs=Object.values(Ye),dh={[Ye.PLUGIN_INIT]:42,[Ye.LINK_CHECK]:-15,[Ye.IMAGE_CHECK]:28,[Ye.SPAM_ASSASSIN]:9,[Ye.AI_IMAGE]:6,[Ye.AI_WRITE]:-11,[Ye.AI_REPHRASE]:4},uh=(e,t)=>{const n={date:e};return Xs.forEach((o,i)=>{const s=Math.sin(t*.65+i*.9),c=t*(i%2===0?.35:.2),d=2+i;n[o]=Math.max(0,Math.round(d+s*4+c))}),n},ph=e=>Xs.map(t=>({event:t,total:e.reduce((n,o)=>n+(typeof o[t]=="number"?o[t]:0),0),delta:dh[t]})),mh=({period:e,dateFrom:t,dateTo:n})=>{const o=(0,En.default)().startOf("day");if(e===Zt.WEEK)return{startDate:o.subtract(6,"day"),days:7};if(e===Zt.MONTH)return{startDate:o.subtract(29,"day"),days:30};if(e===Zt.CUSTOM&&t&&n){const i=(0,En.default)(t),s=(0,En.default)(n);return{startDate:i,days:Math.max(1,s.diff(i,"day")+1)}}return{startDate:o,days:1}},So=(e={period:Zt.TODAY})=>{const{startDate:t,days:n}=mh(e),o=Array.from({length:n},(i,s)=>uh(t.add(s,"day").format("YYYY-MM-DD"),s));return{cards:ph(o),chart:o}},bb=So({period:Zt.WEEK}),fh={pluginInit:{current:0,limit:null},aiAssistant:{current:0,limit:null},aiImage:{current:42,limit:100},linkCheck:{current:128,limit:500},imageCheck:{current:64,limit:200},spamAssassin:{current:31,limit:150},lastActivityAt:"2026-05-02T12:00:00Z"},Js={payments:[{id:"98765",date:"2026-05-12T10:15:00+00:00",amount:990,currency:"RUB",status:"success",receiptUrl:"https://receipts.example/98765.pdf"},{id:"98764",date:"2026-04-12T10:15:00+00:00",amount:990,currency:"RUB",status:"success"},{id:"98763",date:"2026-03-12T10:15:00+00:00",amount:990,currency:"RUB",status:"failed"}],page:1,perPage:20,total:3,totalPages:1},gh={viewerSeesBilling:!0,ownerUserId:1,planName:"Corporate",planDescription:"For fully addressing all necessary tasks in any field.",planPrice:3200,planCurrency:"RUB",endpoints:{limitsStats:"/wp-json/limits/v1/stats",subscriptionMe:"/wp-json/subscription/v2/me",payments:"/wp-json/projects/v1/billing-context/2581/payments"}},hh={info:{name:"EmailMaker Plugin Requests",schema:"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},item:[]},_h=e=>e,yh=()=>!1,vh=()=>!1,bh=e=>e,pn="ProjectPlugin",Eh=()=>({}).REACT_APP_PLUGIN_SETTINGS_USE_MOCK==="true",Vt=(e,t,n)=>e.error&&Eh()?{data:n(t)}:r.transformResponseFn(n)(e),Sh=e=>_h(Qg(e)),wh=e=>bh(sh(e)),kh=({period:e,dateFrom:t,dateTo:n})=>{if(e===Zt.CUSTOM){const o={};return t&&(o.date_from=t),n&&(o.date_to=n),o}return{period:e??Zt.TODAY}},Er=r.createApi({reducerPath:"projectSettingsPluginApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api".replaceAll(/[\\/]$/g,"")}),tagTypes:[pn],endpoints:e=>({getPluginSummary:e.query({queryFn({projectId:t},n){return h.getApi(h.getContainer(n),[zg]).settings_summary_detail({projectId:t}).then(o=>Vt(o,lh(),Jg))},providesTags:(t,n,{projectId:o})=>[{type:pn,id:o}]}),getPluginCredentials:e.query({queryFn({projectId:t},n){return h.getApi(h.getContainer(n),[qs]).developer_credentials_detail({projectId:t}).then(o=>Vt(o,Qs(),Sh))},providesTags:(t,n,{projectId:o})=>[{type:pn,id:`credentials-${o}`}]}),rotatePluginSecret:e.mutation({queryFn({projectId:t},n){return h.getApi(h.getContainer(n),[qs]).developer_credentials_rotate_secret_create({projectId:t}).then(o=>Vt(o,{clientId:Qs().clientId,secret:"mock-rotated-secret"},Zg))},invalidatesTags:(t,n,{projectId:o})=>[{type:pn,id:`credentials-${o}`}]}),getPostmanCollection:e.query({queryFn({projectId:t},n){return h.getApi(h.getContainer(n),[Gg]).developer_kit_postman_collection_list({extraQuery:{project_id:String(t)}}).then(o=>Vt(o,hh,i=>en(i)??i))}}),getPluginAnalytics:e.query({queryFn({projectId:t,period:n,dateFrom:o,dateTo:i},s){const c={period:n,dateFrom:o,dateTo:i};return yh()?Promise.resolve({data:So(c)}):r.getClient(h.getContainer(s)).request({path:`/projects/v1/usage/${t}/timeseries`,method:"GET",query:kh(c)}).then(d=>Vt(d,So(c),rh))}}),getPluginBillingContext:e.query({queryFn({projectId:t},n){return h.getApi(h.getContainer(n),[Wg]).billing_context_detail({projectId:t}).then(o=>Vt(o,gh,wh))},providesTags:(t,n,{projectId:o})=>[{type:pn,id:`billing-${o}`}]}),getPluginUsage:e.query({queryFn({projectId:t},n){return h.getApi(h.getContainer(n),[Hg]).usage_detail({projectId:t}).then(o=>Vt(o,fh,Eo))}}),getPluginPayments:e.query({queryFn({projectId:t,page:n=1,perPage:o=20},i){return vh()?Promise.resolve({data:Js}):r.getClient(h.getContainer(i)).request({path:`/projects/v1/billing-context/${t}/payments`,method:"GET",query:{page:String(n),per_page:String(o)}}).then(s=>Vt(s,Js,ih))},providesTags:(t,n,{projectId:o})=>[{type:pn,id:`payments-${o}`}]})})}),{useGetPluginSummaryQuery:Eb,useGetPluginCredentialsQuery:Sb,useRotatePluginSecretMutation:wb,useLazyGetPostmanCollectionQuery:kb,useGetPluginAnalyticsQuery:Cb,useGetPluginBillingContextQuery:Tb,useGetPluginPaymentsQuery:Ib,useGetPluginUsageQuery:Ab}=Er,Zs="EmailRaw",Sr=r.createApi({reducerPath:"emailRawApi",tagTypes:[Zs],baseQuery:r.fetchBaseQuery({baseUrl:"https://app.useblocks.io/api/wp-json/wp/v2/"}),endpoints:e=>({getEmailRaw:e.query({queryFn:function({emailId:t,secret_hash:n},o){return h.getApi(h.getContainer(o),[h.WpEmailApi]).email_detail({id:t},{extraQuery:{secret_hash:n}}).then(r.transformResponseFn(r.WpEmailToEmail))},providesTags:(t,n,o)=>[{type:Zs,id:o}]})})}),{useGetEmailRawQuery:xb}=Sr,wr=r.createApi({reducerPath:"yandexAuthApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({validateYandexToken:e.mutation({query:t=>({url:"/auth/yandex",method:"POST",body:t})})})}),{useValidateYandexTokenMutation:Pb}=wr,kr=r.createApi({reducerPath:"elamaAuthApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({validateElamaCode:e.mutation({query:t=>({url:"/auth/elama",method:"POST",body:t})})})}),{useValidateElamaCodeMutation:jb}=kr,Cr=r.createApi({reducerPath:"googleAuthApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({validateGoogleToken:e.mutation({query:t=>({url:"/auth/google",method:"POST",body:t})})})}),{useValidateGoogleTokenMutation:Rb}=Cr,ea=async e=>{const t=await e.text();let n=t;try{n=JSON.parse(t)}catch{n=t}return n},Ch=(e,t,n)=>{if(!e)throw new Error(`Set ${n}`);return{url:`?proxy_url=${encodeURIComponent(e)}`,method:"POST",headers:{"Content-Type":"application/json"},body:t,responseHandler:ea}},Th=(e,t,n)=>{if(!e)throw new Error(`Set ${n}`);return{url:`?proxy_url=${encodeURIComponent(e)}`,method:"POST",body:t,responseHandler:ea}},Tr=r.createApi({reducerPath:"requestPlaneApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({getRequest:e.mutation({query:t=>Th("https://webhook.latenode.com/5868/prod/5c07527e-9d53-467a-a148-87220d46e9ae",t,"REACT_APP_PIPEDREAM_REQUEST_PLANE_SRC")}),getInvoiceRequest:e.mutation({query:t=>Ch("https://webhook.latenode.com/5868/prod/5c07527e-9d53-467a-a148-87220d46e9ae",t,"REACT_APP_REQUEST_PLANE_WEBHOOK_URL")})})}),{useGetRequestMutation:Ob,useGetInvoiceRequestMutation:Lb}=Tr,Ir=r.createApi({reducerPath:"getCheckoutUrlApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({GetCheckoutUrl:e.mutation({query:t=>({url:`?proxy_url=${encodeURIComponent("https://webhook.latenode.com/5868/prod/5072387e-5ace-4ca7-9a25-2f952a7075af")}`,method:"POST",body:t})})})}),{useGetCheckoutUrlMutation:Mb}=Ir,wo=r.createApi({reducerPath:"recoverPasswordApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://app.useblocks.io/api/wp-json/bdpwr/v1/"}),endpoints:()=>({})}),Ar=r.createApi({reducerPath:"addUserToProjectApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/wp-json/user_to_project/v1/add_user"}),endpoints:e=>({addUserToProject:e.mutation({queryFn(t,n){return r.clientFromApi(n).userToProject.add_user_create(t,{type:h.ContentType.FormData})}})})}),{useAddUserToProjectMutation:Nb}=Ar,xr=r.createApi({reducerPath:"recurrenceSubscriptionsOffApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({getCanselRecurrence:e.query({query:t=>({url:`?proxy_url=${encodeURIComponent(`https://webhook.latenode.com/5868/prod/38815aec-cb5d-4b40-8dcb-75e7453573a0?subscription_id=${t.sid}&user_id=${t.uid}`)}`})})})}),{useLazyGetCanselRecurrenceQuery:Db,useGetCanselRecurrenceQuery:Fb}=xr,Pr=r.createApi({reducerPath:"recurrenceSubscriptionsOnApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({getRecurrence:e.query({query:t=>({url:`?proxy_url=${encodeURIComponent(`https://webhook.latenode.com/5868/prod/7ac13d46-e4af-4dea-ab21-aab55415575b?subscription_id=${t.sid}&user_id=${t.uid}`)}`})})})}),{useLazyGetRecurrenceQuery:Bb,useGetRecurrenceQuery:$b}=Pr,Ih="https://app.useblocks.io/api/v2",jr=r.createApi({reducerPath:"authApi",baseQuery:r.fetchBaseQueryApp({baseUrl:Ih,prepareHeaders:e=>{const t=r.api.get(r.APP_COOKIES.em_token);return t&&!e.has("authorization")&&e.set("authorization",`Bearer ${t}`),e}}),endpoints:e=>({login:e.mutation({query:t=>({url:"/auth/token",method:"POST",body:t})}),register:e.mutation({query:t=>({url:"/auth/register",method:"POST",body:t})}),refreshToken:e.mutation({query:t=>({url:"/auth/token/refresh",method:"POST",body:t})}),logout:e.mutation({query:()=>({url:"/auth/token",method:"DELETE"})}),getUser:e.query({query:()=>"/auth/user",transformResponse:t=>{const n=Array.isArray(t)?t[0]:t;return r.WpUserToUser(n)}}),changePassword:e.mutation({query:t=>({url:"/auth/password/change",method:"POST",body:t})}),resetPassword:e.mutation({query:t=>({url:"/auth/password/reset",method:"POST",body:t})}),resetPasswordConfirm:e.mutation({query:t=>({url:"/auth/password/reset/confirm",method:"POST",body:t})})})}),{useLoginMutation:Ub,useRegisterMutation:zb,useRefreshTokenMutation:Gb,useLogoutMutation:Wb,useGetUserQuery:Hb,useLazyGetUserQuery:qb,useChangePasswordMutation:Vb,useResetPasswordMutation:Kb,useResetPasswordConfirmMutation:Yb}=jr;function ta(e){return{id:e.id??0,name:e.name??"",children:(e.children??[]).map(ta)}}function Ah(e){return(e?.folders??[]).map(ta)}function xh(e){return{items:(e?.items??[]).flatMap(t=>t.id?[{kind:t.kind??"email",id:t.id,name:t.name??"",title:t.title??"",preheader:t.preheader??"",folderId:t.folder_id??0,hasAmp:t.has_amp??!1,previewImage:t.preview_image??"",updatedAt:t.updated_at??"",imported:t.imported??!1}]:[]),total:e?.total??0}}function ko(e){const t=e.status??"pending";return{id:e.id??"",status:t,outcome:e.outcome,total:e.total??0,imported:e.imported??0,warnings:e.warnings??0,failed:e.failed??0,finished:t==="done"||t==="failed",items:(e.items??[]).map(n=>({kind:n.kind??"email",stripoId:n.stripo_id??0,name:n.name??"",status:n.status??"failed",reason:n.reason,emailId:n.email_id})),createdAt:e.created_at??"",finishedAt:e.finished_at}}function Ph(e){return{selectors:e.map(t=>({kind:t.kind,...t.ids?.length?{ids:t.ids}:{},...t.all?{all:!0}:{},...t.folderId?{folder_id:t.folderId}:{},...t.rootOnly?{root_only:!0}:{},...t.search?{search:t.search}:{}}))}}var Co="StripoItems",To="StripoFolders",Rr="StripoImportJob",mn=(e,t)=>{const n=r.v2ResultOf(e);return"error"in n?{error:n.error}:{data:t(n.data)}},Or=r.createApi({reducerPath:"stripoImportApi",tagTypes:[Co,To,Rr],baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({saveStripoKey:e.mutation({async queryFn({projectId:t,apiKey:n},o){return mn(await r.getClientV2(h.getContainer(o)).projects.stripoKeyUpdate({id:String(t)},{api_key:n}),()=>{})},invalidatesTags:[Co,To]}),getStripoFolders:e.query({async queryFn({projectId:t,kind:n},o){return mn(await r.getClientV2(h.getContainer(o)).projects.stripoFoldersList({id:String(t),kind:n}),Ah)},providesTags:[To]}),getStripoItems:e.query({async queryFn({projectId:t,kind:n,folderId:o,rootOnly:i,search:s,page:c,limit:d},u){return mn(await r.getClientV2(h.getContainer(u)).projects.stripoItemsList({id:String(t),kind:n,...o?{folder_id:o}:{},...i?{root_only:!0}:{},...s?{search:s}:{},page:c,limit:d}),xh)},providesTags:[Co]}),startStripoImport:e.mutation({async queryFn({projectId:t,selectors:n},o){return mn(await r.getClientV2(h.getContainer(o)).projects.stripoImportsCreate({id:String(t)},Ph(n)),ko)},invalidatesTags:[Rr]}),getCurrentStripoImport:e.query({async queryFn(t,n){const o=await r.getClientV2(h.getContainer(n)).projects.stripoImportsCurrentList({id:String(t)});return o.status===204?{data:null}:mn(o,ko)},providesTags:[Rr]}),getStripoImport:e.query({async queryFn({projectId:t,jobId:n},o){return mn(await r.getClientV2(h.getContainer(o)).projects.stripoImportsDetail({id:String(t),jobId:n}),ko)},providesTags:[Rr]})})}),{useSaveStripoKeyMutation:Qb,useGetStripoFoldersQuery:Xb,useGetStripoItemsQuery:Jb,useLazyGetStripoItemsQuery:Zb,useStartStripoImportMutation:e0,useGetCurrentStripoImportQuery:t0,useGetStripoImportQuery:n0}=Or,jh=r.createState({activeGroupsTags:[],activeProjectGroupsTags:[],groupsTemplateTotal:null,groupsTemplateProjectTotalPages:null,groupsTemplateProjectTotal:null}),Rh="projectSlice",Io=r.createSlice({name:Rh,initialState:jh,reducers:{setActiveGroupsTags:(e,{payload:t})=>{e.activeGroupsTags=t,t.length&&(e.activeProjectGroupsTags=[])},setActiveProjectGroupsTags:(e,{payload:t})=>{e.activeProjectGroupsTags=t,t.length&&(e.activeGroupsTags=[])},resetAllTags:e=>{e.activeProjectGroupsTags=[],e.activeGroupsTags=[]}},extraReducers:e=>{e.addMatcher(r.emailsApi.endpoints.getTemplateEmails.matchFulfilled,(t,{payload:n,meta:o})=>{const{projectId:i}=o.arg.originalArgs;i?(t.groupsTemplateProjectTotal=+o.baseQueryMeta?.response.headers.get("X-WP-Total"),t.groupsTemplateProjectTotalPages=+o.baseQueryMeta?.response.headers.get("X-WP-TotalPages")):t.groupsTemplateTotal=+o.baseQueryMeta?.response.headers.get("X-WP-Total")})}}),{setActiveGroupsTags:r0,setActiveProjectGroupsTags:o0,resetAllTags:i0}=Io.actions,Oh=r.createState({emailsTotal:0,elementsList:[],emailsTrashTotal:0,elementsTrashList:[],customFolders:{},elementsView:r.CARDS}),Lh="emailsPageSlice";function Mh(e){const t=e?.baseQueryMeta?.response;return Number(t?.headers?.get("X-WP-Total"))||0}function na(e,t){const{emails:n,total:o,isSearch:i,page:s,tagOrFolderId:c}=t;if(t.status==="trash")!i&&o!==void 0&&(e.emailsTrashTotal=o),e.elementsTrashList=n;else if(c){const d=e.customFolders[c];e.customFolders={...e.customFolders,[c]:{list:n,page:s,total:o??d?.total??0}}}else o!==void 0&&(e.emailsTotal=o),e.elementsList=n}var Ao=r.createSlice({name:Lh,initialState:Oh,reducers:{resetElementsList:e=>{e.elementsList=[]},syncElementsList:(e,{payload:t})=>{na(e,t)},toggleElementsView:(e,t)=>{e.elementsView=t.payload},removeEmailFromList:(e,{payload:t})=>{const n=e.customFolders;t.folder!=="all"&&n[t.folder]?.list&&(n[t.folder]={...n[t.folder],list:n[t.folder].list.filter(o=>o.id!==t.emailId),total:n[t.folder].total-1},e.customFolders=n)}},extraReducers:e=>{e.addMatcher(r.emailsApi.endpoints.getEmails.matchFulfilled,(t,{meta:n,payload:o})=>{const i=n.arg.originalArgs;na(t,{emails:o,total:Mh(n),status:i?.status,page:i?.page,isSearch:!!i?.name?.length,tagOrFolderId:i?.folderTag||i?.tags?.[0]})}),e.addMatcher(r.emailsApi.endpoints.getTemplateEmails.matchFulfilled,(t,{meta:n,payload:o})=>{const i=+n.baseQueryMeta?.response.headers.get("X-WP-Total")||0;t.elementsList=o,t.emailsTotal=i;const{projectGroup:s,projectId:c,tags:d}=n.arg.originalArgs;(s?.length&&c||d?.length||!d?.length&&!s?.length)&&(t.emailsTotal=i)}),e.addMatcher(r.emailsApi.endpoints.editEmail.matchFulfilled,(t,{payload:n})=>{t.elementsList.map(o=>o.id?.toString()===n.id?.toString()?Object.assign(o,{lock:n.lock,title:n.title,emailtags:n.emailtags}):o)})}}),{toggleElementsView:s0,resetElementsList:a0,syncElementsList:l0,removeEmailFromList:c0}=Ao.actions,ra=r.combineReducers({[r.di.reducerPath]:r.di.reducer,[r.AiApi.reducerPath]:r.AiApi.reducer,[r.userSlice.name]:r.userSlice.reducer,[r.emailSlice.name]:r.emailSlice.reducer,[r.blockSlice.name]:r.blockSlice.reducer,[r.imageApi.reducerPath]:r.imageApi.reducer,[An.reducerPath]:An.reducer,[hr.reducerPath]:hr.reducer,[Io.name]:Io.reducer,[r.blocksApi.reducerPath]:r.blocksApi.reducer,[r.emailsApi.reducerPath]:r.emailsApi.reducer,[fr.reducerPath]:fr.reducer,[Xn.reducerPath]:Xn.reducer,[Jn.reducerPath]:Jn.reducer,[Zn.reducerPath]:Zn.reducer,[er.reducerPath]:er.reducer,[tr.reducerPath]:tr.reducer,[nr.reducerPath]:nr.reducer,[rr.reducerPath]:rr.reducer,[or.reducerPath]:or.reducer,[ir.reducerPath]:ir.reducer,[sr.reducerPath]:sr.reducer,[ar.reducerPath]:ar.reducer,[lr.reducerPath]:lr.reducer,[cr.reducerPath]:cr.reducer,[dr.reducerPath]:dr.reducer,[ur.reducerPath]:ur.reducer,[pr.reducerPath]:pr.reducer,[r.emailPageSlice.name]:r.emailPageSlice.reducer,[r.projectsApi.reducerPath]:r.projectsApi.reducer,[Pn.reducerPath]:Pn.reducer,[Qt.reducerPath]:Qt.reducer,[jn.reducerPath]:jn.reducer,[Er.reducerPath]:Er.reducer,[r.saveFileApi.reducerPath]:r.saveFileApi.reducer,[Sr.reducerPath]:Sr.reducer,[r.commentsApi.reducerPath]:r.commentsApi.reducer,[r.optimiseApi.reducerPath]:r.optimiseApi.reducer,[oo.name]:oo.reducer,[Ao.name]:Ao.reducer,[mr.reducerPath]:mr.reducer,[Cr.reducerPath]:Cr.reducer,[wr.reducerPath]:wr.reducer,[kr.reducerPath]:kr.reducer,[r.taxonomiesApi.reducerPath]:r.taxonomiesApi.reducer,[r.projectsPageSlice.name]:r.projectsPageSlice.reducer,[r.AiApiGenerator.reducerPath]:r.AiApiGenerator.reducer,[Tr.reducerPath]:Tr.reducer,[gr.reducerPath]:gr.reducer,[yr.reducerPath]:yr.reducer,[Gn.reducerPath]:Gn.reducer,[r.authorizationApi.reducerPath]:r.authorizationApi.reducer,[r.limitsApi.reducerPath]:r.limitsApi.reducer,[r.revisionHistorySlice.name]:r.revisionHistorySlice.reducer,[Ir.reducerPath]:Ir.reducer,[r.defaultModePanesSlice.name]:r.defaultModePanesSlice.reducer,[wo.reducerPath]:wo.reducer,[Ar.reducerPath]:Ar.reducer,[_r.reducerPath]:_r.reducer,[Pr.reducerPath]:Pr.reducer,[xr.reducerPath]:xr.reducer,[jr.reducerPath]:jr.reducer,[r.projectSettingsV2Api.reducerPath]:r.projectSettingsV2Api.reducer,[Or.reducerPath]:Or.reducer}),Nh=(e,t)=>t.type==="authorizationApi/resetApiState"?ra({[r.reducerPath]:e[r.reducerPath]},t):ra(e,t),oa=[r.AiApi,r.imageApi,hr,r.emailsApi,An,r.blocksApi,fr,Xn,Jn,Zn,er,tr,nr,rr,or,ir,sr,ar,lr,cr,dr,ur,pr,Sr,r.projectsApi,Pn,Qt,jn,Er,r.commentsApi,r.optimiseApi,r.saveFileApi,mr,Cr,r.taxonomiesApi,wr,kr,r.AiApiGenerator,Tr,r.authorizationApi,r.limitsApi,gr,yr,Gn,Ir,wo,jr,r.projectSettingsV2Api,Or,Ar,_r,Pr,xr];function Dh(e){let t={};if(e){const o=h.createIdentifier$1();h.DependencyResolver.inject(o,e),t={INJECTION:o}}const n=r.configureStore({reducer:Nh,middleware:o=>o({serializableCheck:!1}).concat(oa.map(i=>i.middleware)),preloadedState:t});return r.setupListeners(n.dispatch),n}var ia=h.createIdentifier$1("RtkApiRegistry");function Fh(e,t){e.inject(ia,new Map(t.map(n=>[n.reducerPath,n])))}function at(e,t){const n=e?.getInstance(ia)?.get(t);if(!n)throw new Error(`RTK api "${t}" is not in the container registry (provideRtkApiRegistry did not run)`);return n}function Bh(e,t){let n={isCodeMode:void 0,direction:void 0};return r.provideCodeMode(e).watch(o=>{n.isCodeMode!==o.isCodeMode&&t.dispatch(r.setCodeMode(o.isCodeMode)),n.direction!==o.direction&&t.dispatch(r.switchCodeModeDirection(o.direction)),n={isCodeMode:o.isCodeMode,direction:o.direction}})}function $h(e,t){const n=r.provideCurrentUser(e),o=r.authorizationApi.endpoints.getMe.select("");let i=n.get()?.profile;const s=()=>{const c=o(t.getState()).data;!c||c===i||(i=c,n.set({profile:c}))};return s(),{dispose:t.subscribe(s)}}var Uh=h.createIdentifier$1("EmailSettingsPort");function zh(e,t){e.inject(Uh,{read:()=>r.selectEmailSettings(t.getState())??{},write:n=>{t.dispatch(r.setEmailSettings(n))},markAppearanceChanged:()=>{t.dispatch(r.markAppearanceNeedsUpdate())}})}var Gh="Invalid standaloneKey.",Wh="not implemented",d0=1,Hh=h.createIdentifier$1("StandaloneMockGuard");function xo(){const e=new Error(Gh);return e.name="InvalidStandaloneKeyError",e}function Po(e){return r.isStandaloneRuntime(h.getContainer(e))}function qh(e){return e instanceof Error?e.name==="InvalidStandaloneKeyError"||e.message==="Invalid standaloneKey."||e.message==="not implemented":e===Wh}function sa(e){if(Po(e))throw xo()}function Vh(e,t,n){return n instanceof Error&&n.name==="InvalidStandaloneKeyError"?n:xo()}var Kh=()=>()=>{throw xo()};function Yh(e){if(!e)throw new Error("DI container not found for standalone mock guard");e.inject(Hh,1)}function Qh(e){return typeof e!="function"}var u0="[plugin-api-mock]";function aa(){return!0}function Xh(e){try{if(e===null||typeof e!="object")return e;const t={};for(const n of Object.keys(e).slice(0,12)){const o=e[n];t[n]=typeof o=="string"&&o.length>120?`${o.slice(0,120)}…(${o.length})`:o}return t}catch{return"(unserializable arg)"}}function Jh(e,t){return n=>{const o=n.query,i=n.queryFn||((s,c,d,u)=>{if(!o)throw new Error("query not found EndpointDefinition");return u(o(s))});i&&(n.query=void 0,n.queryFn=async(s,c,d,u)=>{try{let p;const f=h.getContainer(c).getServices(e);for(let g=f.length-1;g>=0;g--){const y=f[g];if(p=p?await p(async m=>await y.execute(m),c):await y.execute(s),Qh(p))return{data:p,error:null}}if(p)p=await p(async(g,y=c,m=d,S=u)=>{sa(c);const k=await i(g,y,m,S);if(k.error)throw k.error;return k.data},c);else{sa(c),aa();const g=await i(s,c,d,u);if(g.error)throw g.error;p=g.data}return{data:p,error:null}}catch(p){return Po(c)&&qh(p)?{error:Vh(t,Xh(s),p)}:(aa(),{error:p})}})}}var la=new Set;function it(e){return(t,n)=>{const o=Object.create(null),i=Object.keys(n),s=new h.Disposable;for(const c of i){const d=`api_listeners_flag_${t.reducerPath}/${c.toString()}`,u=h.createIdentifier$1(`api_listeners_${t.reducerPath}/${c.toString()}`);la.has(d)||(o[c]=Jh(u,`${t.reducerPath}/${c.toString()}`),la.add(d)),s.addDisposable(e.addService(u,{execute:n[c]}))}return Object.keys(o).length&&t.enhanceEndpoints({endpoints:o}),r.getDisposable(e).addDisposable(s),s}}function ca(e,t){for(const n of Object.keys(t))try{t[n](e)}catch{}}function p0(e){return e}function da(e,t){return e({body:t}).catch(()=>new Promise(n=>setTimeout(n,1e3)))}function Zh(e){it(e)(at(e,"AiApi"),{sendMessage:({body:t})=>async(n,o)=>{const i=r.getEmitter(e,h.events.AI_TEXT_REQUEST_ID);if(!i.hasListeners())return da(n,t);const s=t,c={message:s.message??s.context,locale:s.locale,entityId:s.entity_id,projectId:s.project_id!=null?String(s.project_id):void 0,subject:s.subject,preheader:s.preheader,textContent:s.textContent,context:s.context??s.connection,connection:s.connection,onProgress:(d,u)=>{r.getEmitter(e,h.events.AI_TEXT_PROGRESS_ID).fire({progress:Number.isFinite(d)?d:0,status:typeof u=="string"?u:void 0})},onStreamChunk:d=>{typeof d!="string"||!d||r.getEmitter(e,h.events.AI_TEXT_STREAM_ID).fire({partialHtml:d})},signal:o.signal};for(const d of i.getListeners([c])){const u=await d(c);if(u)return{status:200,_eventResult:!0,aiMessage:typeof u.message=="string"?u.message:"",aiHtml:typeof u.html=="string"?u.html:void 0}}return da(n,t)},getDialog:t=>(n,o)=>Po(o)?Promise.resolve({documents:[],totalCount:0}):n(t)})}function e_(e){const t=it(e),n=r.getEmitter(e,h.events.FILE_PROXY_EVENT_ID);t(at(e,"proxyApi"),{async getFile({url:o,tryFetch:i=!0,type:s}){return async c=>{const{requested:d}=r.getCurrentProject(e),u=(await n.fire({url:o,project:d})).filter(p=>p instanceof Blob)[0];if(u)switch(s){case"json":return JSON.parse(await u.text());case"text":return u.text();default:return u}else return c({url:o,tryFetch:i,type:s})}}})}function t_(e){it(e)(at(e,"tokenApi"),{tokenCreate(t){return n=>n(t)},tokenValidate(){return t=>t({})}})}function m0(e){return e}function n_(e){it(e)(at(e,"imageApi"),{sendAiImageRequest:function({body:t}){return async(n,o)=>{const i=r.getEmitter(e,h.events.AI_IMAGE_REQUEST_ID);if(!i.hasListeners()||t.request!=="create-image")return n({body:t});const s={prompt:t.message??"",size:t.size,entityId:t.entity_id,projectId:t.project_id!=null?String(t.project_id):void 0,onProgress:(c,d)=>{r.getEmitter(e,h.events.AI_IMAGE_PROGRESS_ID).fire({progress:Number.isFinite(c)?c:0,status:typeof d=="string"?d:void 0})},signal:o.signal};for(const c of i.getListeners([s])){const d=await c(s);if(d&&d.images?.length)return{data:{status:200,_eventResult:!0,task:{images:d.images}}}}return n({body:t})}},getAiImage(t){return n=>n(t)}})}async function ua(e,t,n,o,i){try{const s=(await e.fire({project:String(t),emailId:n})).filter(c=>c!=null);if(s.length)return s.flat()}catch{}return o(i)}function r_(e){const t=it(e),n=at(e,"blocksApi"),o=r.blocksDataSourceProvider(e),i=o.byForeignKey("project"),s=r.blockRevisionsDataSourceProvider(e);s.byForeignKey("parent");const{dispatch:c}=r.getStore(e),d=r.getDisposable(e);d.addDisposable(o.onChange(()=>c(n.util.invalidateTags(["Blocks"])))),d.addDisposable(o.onSave(({prev:f,patch:g,value:y})=>{const m=f?{...f,...g}:g;let S=r.mergeEntityPreservingMeta(f,g,y);return m&&S.html===m.html&&S.title===m.title&&(S={...S,renderGuid:m.renderGuid}),S},Number.MIN_VALUE));const u=r.getEmitter(e,r.READ_COMMON_BLOCKS_EVENT_ID),p=r.getEmitter(e,r.READ_TEMPLATE_BLOCKS_EVENT_ID);t(n,{async getBlocks(f){const g={};f.name&&(g.title=f.name),f.type&&(g.type=f.type);const y=f.projectId??await r.getBlocksProject(e);return await i.get(y,{filter:g,page:f.page,pageSize:f.pageSize,order:f.order,orderBy:f.orderby}).then(({data:m})=>m)},getBlocksSchema(){return f=>f(void 0)},getParentEmailBlocks(f){return async g=>{const y=r.getCurrentProject(e).requested||"";return ua(p,y,f.emailId||"",g,f)}},getTemplateBlocks(f){return async g=>{const y=r.getCurrentProject(e).requested||"";return ua(u,y,f.emailId||"",g,f)}},async getBlock(f){const g=r.getCurrentProject(e).card?.id;if(g!==void 0)return i.first(Number(g),{filter:{id:f}})},addBlock(f){return async g=>{const y=await o.create(f);return r.getAppConfig(e).preventSendDataToEM||g(y).catch(m=>{}),y}},editBlock({blockId:f,...g}){return o.update(f,g)},deleteBlock(f){return o.remove(typeof f=="object"?f.id:f)},addTag(f){return f},getDeletableTag([f,g]){return[]},autoSaveBlock({blockId:f,body:g}){return s.create({...g,parent:f})}})}function o_(e){const{emails:t,emailRevisions:n}=r.provideEmailDocuments(e),{dispatch:o}=r.getStore(e),i=r.getDisposable(e),s=it(e),c=at(e,"emailsApi");i.addDisposable(t.onChange(async()=>{o(c.util.invalidateTags(["Email"]))})),s(c,{getEmails:d=>[],getTemplateEmails:d=>[],async addEmail({source:d,...u}){const p=await t.create(u,{source:d});return p.renderGuid||(p.renderGuid=h.generateUUID()),p},editEmail(d){return async u=>{const{emailId:p,source:f,...g}=d;return r.isRevisionServiceEnabled(e)&&await u(d),t.update(p,g,{source:f})}},deleteEmail(d){return t.remove(typeof d=="object"?d.id:d)},addTag(){throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},getDeletableTag([d,u]){return[]},autoSaveEmail({emailId:d,body:u}){return async p=>{r.isRevisionServiceEnabled(e)&&await p({emailId:d,body:u});const f=await n.create({...u,parent:d,modified:new Date().toString()});return f&&!f.html&&u.html?{...f,html:u.html}:f}}})}var i_="tmp",f0=h.createIdentifier$1();function s_(e){const t=it(e);if(!e.getInstance(h.DISPOSABLE_ID))throw new Error("Something was wrong");const n=r.getEmitter(e,h.events.UPLOAD_EVENT_ID),o=r.getEmitter(e,h.events.ON_SEND_TESTEMAIL_ID),i=r.getEmitter(e,h.events.ON_SEND_LIVEPREVIEW_ID);t(at(e,"saveFileApi"),{uploadImage(s){return async c=>{const{requested:d}=r.getCurrentProject(e),u=async()=>c({...s,user_id:String((await e.getInstanceAsync(h.APP_ID)).app_id)});if(s.folder===i_)return u();const p=await r.fireUploadImageEvent(n,{file:s.file,project:d});if(p.url)return[{file_url:p.url,project:d}];if(!r.shouldFallbackToBuiltInUpload(p,{isStandalone:r.isStandaloneRuntime(e)}))throw r.toUploadImageError(p);return u()}},sendTestEmail(s){return async c=>{const{requested:d}=r.getCurrentProject(e);(await o.fire({project:d,email_id:s.email_id,subject:s.subject,email:s.email,html:s.html,from_name:s.from_name})).some(u=>u===!1)&&await c({...s,user_id:String((await e.getInstanceAsync(h.APP_ID)).app_id)})}},async sendLivePreview(s){const{requested:c}=r.getCurrentProject(e);(await i.fire({project:c,id:s.email,subject:s.subject,html:s.content})).some(d=>d===!1)},sendShortLink(s){return c=>c(s)}})}function a_(e){it(e)(at(e,"emailRawApi"),{getEmailRaw({emailId:t,secret_hash:n}){throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)}})}function Kt(e,t){for(var n=e<0?"-":"",o=Math.abs(e).toString();o.length<t;)o="0"+o;return n+o}function l_(e,t){var n,o;r.requiredArgs(1,arguments);var i=Ol(e);if(isNaN(i.getTime()))throw new RangeError("Invalid time value");var s=String((n=t?.format)!==null&&n!==void 0?n:"extended"),c=String((o=t?.representation)!==null&&o!==void 0?o:"complete");if(s!=="extended"&&s!=="basic")throw new RangeError("format must be 'extended' or 'basic'");if(c!=="date"&&c!=="time"&&c!=="complete")throw new RangeError("representation must be 'date', 'time', or 'complete'");var d="",u="",p=s==="extended"?"-":"",f=s==="extended"?":":"";if(c!=="time"){var g=Kt(i.getDate(),2),y=Kt(i.getMonth()+1,2),m=Kt(i.getFullYear(),4);d="".concat(m).concat(p).concat(y).concat(p).concat(g)}if(c!=="date"){var S=i.getTimezoneOffset();if(S!==0){var k=Math.abs(S),w=Kt(Math.floor(k/60),2),b=Kt(k%60,2),A=S<0?"+":"-";u="".concat(A).concat(w,":").concat(b)}else u="Z";var x=Kt(i.getHours(),2),Y=Kt(i.getMinutes(),2),Z=Kt(i.getSeconds(),2),M=d===""?"":"T",O=[x,Y,Z].join(f);d="".concat(d).concat(M).concat(O).concat(u)}return d}function c_(e){const t=it(e),n=at(e,"commentsApi"),o=r.commentsDataSourceProvider(e),i=o.byForeignKey("post"),{dispatch:s}=r.getStore(e);r.getDisposable(e).addDisposable(o.onChange(()=>s(n.util.invalidateTags(["Comments"])))),t(n,{getComments(c){return i.get(c).then(({data:d})=>d)},addComment({subjectId:c,author:d,parent:u,content:p,author_name:f,author_email:g,targetId:y}){const m={post:c,author:d,author_name:f,author_email:g,content:p,parent:u,target_id:y,date:l_(new Date),author_avatar_urls:{}};return o.create(m)},deleteComment(c){return o.remove(c)},editComment({commentId:c,...d}){return o.update(c,d)},deleteTarget(c){return o.update(c,{target_id:""})}})}function jo(e){return{id:String(e),name:"",myRole:"",members:[],invites:[],emailsCount:0,blocksCount:0,title:"",group:[],folder:[],blockfolder:[]}}function pa(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function d_(e,t){const n=jo(String(t)),o=r.getCurrentProject(e).card;return o&&String(o.id)===String(t)?Promise.resolve({...n,...o,id:String(t)}):Promise.resolve({...n,id:String(t)})}function u_(e){let t,n;const o=i=>((t!==i||!n)&&(t=i,n=d_(e,i)),n);it(e)(at(e,"projectsApi"),{getProjects(i={page:1}){return[]},getProject(i){return async s=>r.isStandaloneRuntime(e)?s(i):{...await o(i),id:String(i)}},addProject(i){throw new Error},async editProject({projectId:i,...s}){const c={...await o(i),...s,id:String(i)};return t=i,n=Promise.resolve(c),c},deleteProject(i){throw new Error},mutateProjectMembers(){throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},addProjectMember(){throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},getFrequentProjects(){return[]}})}function p_(e){let t={id:"0",username:"",email:"",password:"",code_editor:{},theme:"light",locale:r.getCurrentUser(e).profile?.locale,counters:{},avatar_urls:{},autosaves:!0};it(e)(at(e,"authorizationApi"),{getSchema:()=>n=>n({}),getMe:()=>t,editMe:n=>t={...t,...n},getSubscriptions:()=>[]})}function m_(e){it(e)(at(e,"notificationsApi"),{getNotifications(t){return[]},notificationShown({id:t,datetime:n}){throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)}})}function f_(e){it(e)(at(e,"addUserToProjectApi"),{addUserToProject:()=>{}})}function g_(e){r.injectEmailTermsResolver(e,{resolve:async()=>{}}),it(e)(at(e,"taxonomiesApi"),{getTerms:()=>[],getStandardGroups:()=>[],addTerm:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},editTerm:t=>({id:t.id,name:t.name,parent:0,count:0}),deleteTerm:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)}})}function h_(e){it(e)(at(e,"projectSettingsV2Api"),{getProjectIntegrations:()=>({}),getProjectWebhook:()=>"",getProjectStorage:()=>({}),getProjectTestRecipients:()=>[],getIntegrationCredentials:()=>({}),putProjectIntegration:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},deleteProjectIntegration:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},putProjectWebhook:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},putProjectSettings:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},putProjectTestRecipients:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)}})}function __(e){it(e)(at(e,"stripoImportApi"),{getStripoFolders:()=>[],getStripoItems:()=>({items:[],total:0}),getCurrentStripoImport:()=>null,getStripoImport:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},saveStripoKey:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)},startStripoImport:()=>{throw new Error(h.NOT_IMPLEMENTED_IN_PLUGIN)}})}var ma={addUserToProjectApiMock:f_,AiApiMock:Zh,authorizationApiMock:p_,blocksApiMock:r_,commentsApiMock:c_,emailsApiMock:o_,emailRawApiMock:a_,imageApiMock:n_,notificationsApiMock:m_,projectsApiMock:u_,projectSettingsV2ApiMock:h_,proxyApiMock:e_,saveFileApiMock:s_,stripoImportApiMock:__,taxonomiesApiMock:g_,tokenApiMock:t_},Ro=r.createApi({reducerPath:"tokenApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/wp-json/jwt-auth/v1/"}),endpoints:e=>({tokenCreate:e.mutation({queryFn(t,n){return r.clientFromApi(n).jwtAuth.token_create({body:t,type:h.ContentType.Json})}}),tokenValidate:e.mutation({queryFn(t,n){return r.clientFromApi(n).jwtAuth.token_validate_create({type:h.ContentType.Json})}})})}),{useTokenCreateMutation:g0,useTokenValidateMutation:h0}=Ro;function Oo(){const e=new Map;for(const t of oa)e.set(t.reducerPath,t);return e.set(Ro.reducerPath,Ro),[...e.values()]}function y_(e,t){const n=Object.keys(t.endpoints);n.length&&e(t,Object.fromEntries(n.map(o=>[o,Kh])))}function v_(e){Yh(e);const t=it(e);for(const n of Oo())y_(t,n)}function b_(e){if(!e)return;const t=h.decodeJwt(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(o=>typeof o=="string"?o.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(o=>/^project_\d+$/.test(o))?.replace(/^project_/,"")||void 0}var E_={AiApi:new Set(["sendMessage","getDialog"]),imageApi:new Set(["sendAiImageRequest","getAiImage","getAiImageSSE"])};function S_(e){return r.getAppConfig(h.getContainer(e))}function w_(e){return e?.backendProxy!==void 0&&e?.backendProxyPolicy?.proxyAi===!0}function k_(e){return w_(S_(e))}function C_(e,t,n,o){return E_[t]?.has(n)?i=>k_(e)?s=>s(i):o(i):o}function T_(e){const t=it(e);return((n,o)=>{if(!n||typeof n.reducerPath!="string")return new h.Disposable;const i=Object.fromEntries(Object.entries(o??{}).map(([s,c])=>[s,typeof c=="function"?C_(e,n.reducerPath,s,c):c]));return t(n,i)})}function I_(e){const t=`blocks_${h.generateUUID().replaceAll("-","")}`,n=document.createElement("script");return n.type="text/javascript",n.text=`window.${t}(function(module, exports, require) { ${e}; })`,new Promise((o,i)=>{window[t]=function(s){const c={exports:{}},d=()=>{};s(c,c.exports,d),o(c.exports)},document.head.appendChild(n)}).finally(()=>{n.remove(),delete window[t]})}async function fa(e){const t=h.getContainer(e),n=t?.getInstance(h.STANDALONE_PROJECT_ID),o=n?void 0:await t?.getInstanceAsync(h.APP_ID).catch(()=>{}),i=n||(o?.project!==void 0?String(o.project):void 0);i&&t&&r.setCurrentProjectCard(t,jo(i))}async function A_(e,t){try{const n=function(d){const u=e.getInstance(h.STANDALONE_PROJECT_ID),p=u?pa(u,d):d;e.injectFactory(h.APP_ID,async()=>p)},o=T_(e),i=await r.readZipFromBase64(t),s=i.key&&r.zipEntryToText(i.key);if(typeof s!="string")return;const c=await I_(s);if(typeof c!="object"||c===null||typeof c.execute!="function")return;c.execute(n,o,Oo())}catch{}}async function ga(e,t){v_(h.getContainer(e)),await A_(h.getContainer(e),t),ca(h.getContainer(e),ma)}var x_=zn(async e=>{const t=Dh(e);e.inject(h.STORE_ID,t),Fh(e,Oo()),zh(e,t),r.getDisposable(e).addDisposable($h(e,t)),r.getDisposable(e).addDisposable(Bh(e,t));const n=h.getContainer(t);n&&(e.inject(h.MESSAGE_SERVICE_ID,r.getMessageService(n)),e.inject(r.CURRENT_PROJECT_ID,r.provideCurrentProject(n)));const o=e.getInstance(h.SECURITY_MODULE_ID);return o?(await ga(t,o),await fa(t)):ca(h.getContainer(t),ma),{instance:{}}}),ha=["historyEnabled","commentsEnabled","aiAssistentEnabled","livePreviewEnabled","sendTestEnabled","sharePreviewEnabled","webversionEnabled","optimizeSpamAssassinEnabled","exportWebHookEnabled","aiLayoutConverterEnabled","elementAIimageEnabled","elementAItextEnabled","revisionService"];function P_(e){const t={...e};for(const n of ha)t[n]=!1;return t}function j_(e){const t={...e};for(const n of ha)n in t&&typeof t[n]=="boolean"&&(t[n]=!1);return t}function R_(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,o]of Object.entries(e))!o||typeof o!="object"||Array.isArray(o)||(t[n]=j_(o));return Object.keys(t).length>0?t:void 0}function Lo(e){const t=P_(e),n=R_(e.advancedConfigs),o={...t};return n?o.advancedConfigs=n:delete o.advancedConfigs,o}var _0=1,O_=2592e6;function _a(){return"useblocks".trim()||void 0}function L_(e){return{schemaVersion:1,savedAt:Date.now(),project:e.project,app_id:e.app_id,app_config:Lo(va(e.app_config))}}function ya(e){return{...e,app_config:va(e.app_config)}}function va(e){if(!e||typeof e!="object"||Array.isArray(e))return{};try{if(typeof structuredClone=="function")return structuredClone(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return{}}}async function M_(e){const t=_a();t&&await z_(t,L_(e))}async function N_(e=Date.now()){const t=_a();if(t)return G_(t,e)}function D_(e,t=Date.now()){return e.savedAt>t?!1:t-e.savedAt<=O_}function ba(e){if(!e||typeof e!="object")return!1;const t=e,n=typeof t.project=="number"&&Number.isFinite(t.project)||typeof t.project=="string"&&t.project.trim()!=="";return t.schemaVersion===1&&typeof t.savedAt=="number"&&Number.isFinite(t.savedAt)&&n&&typeof t.app_id=="number"&&Number.isFinite(t.app_id)&&t.app_config!=null&&typeof t.app_config=="object"&&!Array.isArray(t.app_config)}var Rt="snapshots",F_=1;function B_(){return`${"useblocks".trim()||"plugin"}-plugin-deferred-config`}function Lr(){return new Promise((e,t)=>{if(typeof indexedDB>"u"){t(new Error("indexedDB is not available"));return}const n=indexedDB.open(B_(),F_);n.onerror=()=>t(n.error||new Error("indexedDB open failed")),n.onupgradeneeded=()=>{const o=n.result;o.objectStoreNames.contains(Rt)||o.createObjectStore(Rt)},n.onsuccess=()=>e(n.result)})}function $_(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error||new Error("indexedDB request failed"))})}function U_(){return{async get(e){const t=await Lr();try{const n=await $_(t.transaction(Rt,"readonly").objectStore(Rt).get(e));return n===void 0?void 0:n}finally{t.close()}},async put(e,t){const n=await Lr();try{const o=n.transaction(Rt,"readwrite");o.objectStore(Rt).put(t,e),await new Promise((i,s)=>{o.oncomplete=()=>i(),o.onerror=()=>s(o.error||new Error("indexedDB write failed")),o.onabort=()=>s(o.error||new Error("indexedDB write aborted"))})}finally{n.close()}},async delete(e){const t=await Lr();try{const n=t.transaction(Rt,"readwrite");n.objectStore(Rt).delete(e),await new Promise((o,i)=>{n.oncomplete=()=>o(),n.onerror=()=>i(n.error||new Error("indexedDB delete failed")),n.onabort=()=>i(n.error||new Error("indexedDB delete aborted"))})}finally{t.close()}},async clear(){const e=await Lr();try{const t=e.transaction(Rt,"readwrite");t.objectStore(Rt).clear(),await new Promise((n,o)=>{t.oncomplete=()=>n(),t.onerror=()=>o(t.error||new Error("indexedDB clear failed")),t.onabort=()=>o(t.error||new Error("indexedDB clear aborted"))})}finally{e.close()}}}}var Ea,Mo;function No(){return Ea||(Mo||(Mo=U_()),Mo)}function Sa(e){No().delete(e).catch(()=>{})}async function z_(e,t){if(ba(t))try{await No().put(e,ya(t))}catch{}}async function G_(e,t=Date.now()){try{const n=await No().get(e);if(n===void 0)return;if(!ba(n)){Sa(e);return}if(!D_(n,t)){Sa(e);return}return ya(n)}catch{return}}function W_(e,t){if(e.getInstance(h.STANDALONE_FILE_PROXY_REGISTERED_ID))return;e.inject(h.STANDALONE_FILE_PROXY_REGISTERED_ID,!0);const n=h.getEvent(e,h.events.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:o})=>(await fetch(o)).blob(),Number.MIN_VALUE))}function wa(e){try{return b_(e)||void 0}catch{return}}async function H_(e,t,n){if(!e)return;let o;try{const i=await e(t,n,void 0);o=String(i||"").trim()}catch{return}if(o)return{token:o,serverProjectId:wa(o)}}function q_(e){if(e==null)return;const t=String(e).trim();return/^\d+$/.test(t)?t:void 0}function V_(e){const t=String(e.getInstance(h.JWT_TOKEN_ID)||"").trim();if(t)return wa(t)}function ka(e,t,n){e.inject(h.APP_ID,void 0),e.inject(h.APP_ID,Promise.resolve(pa(t,n)))}function K_(e){return{app_id:e.app_id,app_config:Lo(e.app_config)}}async function Ca(){const e=await N_();return e?K_(e):{app_config:Lo({})}}function Y_(e,t){e.getInstance(h.STANDALONE_ACTIVATED_ID)||(e.inject(h.SECURITY_MODULE_ID,void 0),e.inject(h.STANDALONE_BOOTSTRAP_TOKEN_ID,void 0),e.inject(h.STANDALONE_PROJECT_ID,void 0),t&&e.inject(h.APP_ID,void 0),e.inject(h.STANDALONE_FILE_PROXY_REGISTERED_ID,void 0))}async function Ta(e){const{container:t,store:n,standaloneKey:o,project:i,reason:s,getAuthToken:c,user:d}=e,u=e.disposable||t.getInstance(h.DISPOSABLE_ID);if(t.getInstance(h.STANDALONE_ACTIVATED_ID))return;const p=await H_(c,d,i),f=q_(i),g=p?.serverProjectId??V_(t)??(p?void 0:f);t.inject(h.SECURITY_MODULE_ID,o);let y=!1;try{if(p&&(t.inject(h.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(p.token)),c&&h.recreateTokenProvider(t,c,d,i)),g){const m=await Ca();t.inject(h.STANDALONE_PROJECT_ID,g),ka(t,g,m),y=!0,r.setCurrentProjectCard(t,jo(g))}if(await ga(n,o),y=!0,!g){await fa(n);const m=t.getInstance(h.STANDALONE_PROJECT_ID);if(m)ka(t,m,await Ca()),y=!0;else if(t.getInstance(h.APP_ID)!==void 0)try{(await t.getInstanceAsync(h.APP_ID))?.project==null}catch{}}u&&W_(t,u),t.inject(h.STANDALONE_ACTIVATED_ID,!0)}catch(m){throw Y_(t,y),m}}async function Q_(e,t,n,o){const i=o?.attemptTimeout??h.isFailoverEnabled(n),s=h.isFailoverEnabled(n)?h.getOrderedOriginCandidates(n):h.getOriginChain(n).length>0?[h.getActiveBaseUrl(n)]:[];if(s.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const c=e.startsWith("/")?e:`/${e}`;let d,u;for(let p=0;p<s.length;p++){const f=s[p],g=p===s.length-1,y=i?h.beginFailoverAttempt(t.signal):void 0;try{const m=await fetch(`${f}${c}`,{...t,...y?{signal:y.signal}:{}});if(!m.ok&&h.shouldFailoverResponse(m.status)){if(d=m,!g){h.reportOriginFailure(f,n);continue}break}return m.ok&&h.reportOriginSuccess(f,n),m}catch(m){const S=y?.timeoutError();if(!S&&!h.shouldFailoverError(m))throw m;u=S||m,g||h.reportOriginFailure(f,n)}finally{y?.done()}}if(h.isFailoverEnabled(n)&&h.abandonStickyOrigin(),d)return d;throw u instanceof Error?u:new Error("[apiOriginFailover] fetch chain failed")}function X_(e,t){const n=String(t.baseUrl||"").trim();if(n)return h.resolveExplicitApiBaseUrl(n);const o=e.getInstance(h.REST_CLIENT_FACTORY_ID),i=String(o?.getOptions()?.baseUrl||"").trim();return h.resolveExplicitApiBaseUrl(i||void 0)}async function J_(e,t){if(t.getAuthToken)try{const n=await t.getAuthToken(t.user,t.project,void 0);if(String(n||"").trim())return!0}catch{if(!t.jwtAuth)return!1}if(t.jwtAuth)try{if(String(e.getInstance(h.JWT_TOKEN_ID)||"").trim())return!0;const n=X_(e,t);if(!n)return!1;const o=await Q_("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.jwtAuth)},n,{attemptTimeout:!0});if(!o.ok)return!1;const i=await o.json();return i.token?(e.inject(h.JWT_ERROR_ID,void 0),e.inject(h.JWT_TOKEN_ID,i.token),!0):!1}catch{return!1}return!1}async function Z_(e){try{if(e.getInstance(h.APP_ID)===void 0)return!1;const t=await ty(e.getInstanceAsync(h.APP_ID));return t!=null&&t.project!=null?t:!1}catch{return!1}}function ey(){return h.getFailoverAttemptTimeoutMs()*Math.max(1,h.getOriginChain().length)}function ty(e){const t=ey();return new Promise((n,o)=>{const i=setTimeout(()=>{n(void 0)},t);e.then(s=>{clearTimeout(i),n(s)},s=>{clearTimeout(i),o(s)})})}function Ia(e){return String(e.standaloneKey||"").trim()||void 0}function ny(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function ry(e){return ny(e)?!!Ia(e):!1}var oy=zn(async e=>{const t=e.getInstance(h.DISPOSABLE_ID),n=()=>e.getInstanceAsync(h.STORE_ID);return{async setOptions(o){if(!ry(o)){e.getInstance(h.STANDALONE_ACTIVATED_ID);return}const i=Ia(o);if(!i||e.getInstance(h.STANDALONE_ACTIVATED_ID))return;const s=await n(),c=!!(o.getAuthToken||o.jwtAuth),d=c?await J_(e,o):!0;if(c&&!d){await Ta({container:e,store:s,standaloneKey:i,project:o.project,getAuthToken:o.getAuthToken,user:o.user,disposable:t,reason:"auth pipeline failed"});return}const u=await Z_(e);if(u){await M_(u).catch(()=>{});return}await Ta({container:e,store:s,standaloneKey:i,project:o.project,getAuthToken:o.getAuthToken,user:o.user,disposable:t,reason:"app_init failed"})}}}),iy=h.defineMixin(e=>{let t;const n=r.getDisposable(e),o=h.getEvent(e,h.events.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(o(({history:s})=>{t=s}));const i=()=>t?Mi(t):void 0;return{instance:{undoRedoService:{undo:()=>i()?.undo(),redo:()=>i()?.redo(),clear:()=>i()?.clear(),getPast:s=>i()?.getPast(s)??[],getFuture:s=>i()?.getFuture(s)??[],canUndo:()=>i()?.canUndo()??!1,canRedo:()=>i()?.canRedo()??!1,createSnapshot:()=>i()?.createSnapshot(),restoreSnapshot:s=>i()?.restoreSnapshot(s)}}}});function sy(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function ay(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}async function Aa(e){const t=r.getCurrentUser(e).profile;if(t)return t;const n=e.getInstance(h.STORE_ID);if(n)return(await n.dispatch(r.authorizationApi.endpoints.getMe.initiate("",{forceRefetch:!0}))).data}function ly(e){const t=r.resolveTemplateDirectivesConfig(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return ms();const n=new Set(Object.keys(t.output).filter(i=>t.output[i]==="html-comment")),o=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:i=>r.mapper.normalizeToPolicy(i,t.editor),toOutputForm:i=>r.mapper.normalizeToPolicy(i,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:ps(o)}}function xa(e){const t=r.getCodeMode(e);return{...Mr(e),editor:ay(r.getEditorOptions(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Mr(e){return e.getInstance(h.CONFIG_SOURCE_ID)?.get()??{}}function Do(e){return e.getInstance(h.CONFIG_SOURCE_ID)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}var cy=vo(e=>{const t=r.getDisposable(e),n=Ct(r.getEvent(e,h.events.ON_LIMIT_ID)),o=t.addDisposable(new kt(n)),i=Ct(r.getEvent(e,h.events.READ_LOCALE)),s=t.addDisposable(new kt(i)),c=Ct(r.getEvent(e,h.events.ON_TRANSLATE_ID)),d=t.addDisposable(new kt(c)),u=r.getEmitter(e,h.CONFIG_CHANGED_EVENT_ID),p=async()=>{try{return e.getInstance(h.APP_ID)===void 0?{}:(await e.getInstanceAsync(h.APP_ID))?.app_config||{}}catch{return{}}},f=Fs(),g=Fs();let y,m=!1,S;const k=async()=>{const I=xa(e);if(!m){S=h.deepClone(I),m=!0;return}S!==void 0&&h.deepEqual(S,I)||(S=h.deepClone(I),await u.fire(I))},w=I=>{if(typeof I=="number")return String(I);if(typeof I=="string")return I},b=I=>{if(I!==void 0){const R=r.provideCurrentProject(e);R.set({...R.get(),requested:String(I)})}},A=async(I,R)=>{if(!I){const ee=await Aa(e);return y=w(ee?.id),{didReset:!1}}const z=await Aa(e),B=I.id!==void 0?w(I.id):w(z?.id),U=y!==void 0?String(y):void 0,de=B!==void 0?String(B):void 0,me=U!==void 0&&de!==void 0&&U!==de,q={...z,...r.filterUndefined(I),id:B};if(I.id===void 0&&!z?.id&&delete q.id,r.provideCurrentUser(e).set({profile:q}),me&&R){const ee=e.getInstance(h.INSTANCE_ID);if(ee?.reset)return await ee.reset(R),{didReset:!0}}return y=de,{didReset:!1}},x=I=>{const R=e.getInstance(h.CONFIG_SOURCE_ID);R?.setAdvancedConfigs({...I.advancedConfigs,...I.user?.advancedConfigs}),R?.replace(I.user,"user"),R?.replace(I.serverSide,"server")},Y=async()=>{await e.getInstance(h.CONFIG_SOURCE_ID)?.ready(),r.getRevisionServiceFlag(e).set(Mr(e).revisionService===!0);const{codeModeDirection:I,editor:R}=Mr(e);R&&r.applyEditorOptions(e,sy(R)),I!==void 0&&(I==="none"?r.setCodeMode$1(e,!1):(r.setCodeMode$1(e,!0),r.setCodeModeDirection(e,I)))},Z=async I=>{x(I),await Y()};let M;const O=f.decorate(async({config:I={},project:R,user:z,advancedConfigs:B},U)=>{e.getInstance(h.CONFIG_SOURCE_ID)?.replace(await p(),"server"),await Y(),e.inject(h.TEMPLATE_DIRECTIVES_ID,ly(Mr(e).templateDirectives)),b(R),U&&"commonStyles"in U&&r.setDefaultCommonStyles(e,U.commonStyles===void 0?void 0:U.commonStyles);const{didReset:de}=await A(z,U)});return{setOptions:g.decorate(async I=>{const{config:R={},project:z,user:B,advancedConfigs:U,handleReadLocale:de,handleLimitUsage:me,handleTranslate:q,storageProvider:ee}=I;e.inject(h.STORAGE_PROVIDER_ID,ee),s.setListener(de),o.setListener(me),d.setListener(q),await O({config:R,project:z,user:B,advancedConfigs:U},I).catch(Fe=>{}),await k(),M&&M.dispose(),M=new h.Disposable}),instance:{setConfig:g.decorate(async I=>{const R=I,{commonStyles:z,...B}=R;"commonStyles"in R&&r.setDefaultCommonStyles(e,z===void 0?void 0:z),await Z({advancedConfigs:Do(e).advancedConfigs,serverSide:await p(),user:B}),await k()}),getConfig:()=>xa(e),updateConfig:g.decorate(async I=>{const R=I,{commonStyles:z,...B}=R;"commonStyles"in R&&r.setDefaultCommonStyles(e,z===void 0?void 0:z),await Z({advancedConfigs:Do(e).advancedConfigs,serverSide:await p(),user:{...Do(e).user,...B}}),await k()}),handleReadLocale:i,handleLimitUsage:n,handleTranslate:c}}}),Nr;function Fo(){return Nr===void 0&&(Nr=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/7f91ed03.js")),void 0,{}.url).catch(e=>{throw Nr=void 0,e})),Nr}var Pa;function dy(){return Pa??=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/e47dcbb0.js")).then(e=>zt.__toESM(e.require_core())),void 0,{}.url),Pa}function uy(e){const t=[0],n=[];let o=0;for(;o<e.length;){const i=e.charCodeAt(o);i===10||i===13?(n.push(o-t[t.length-1]),o+=i===13&&e.charCodeAt(o+1)===10?2:1,t.push(o)):o+=1}return n.push(e.length-t[t.length-1]),{starts:t,lengths:n}}function ja({starts:e,lengths:t},n,o){const i=Math.min(Math.max(n,1),e.length)-1;return e[i]+Math.min(Math.max(o,1),t[i]+1)-1}var py={error:8,warning:4,info:2};function my(e,t){const n=e.evidence!==""?e.col+e.evidence.length:t.lengths[e.line-1]??e.col+1;return{severity:py[e.type]??8,message:e.message,startLineNumber:e.line,startColumn:e.col,endLineNumber:e.line,endColumn:n,startOffset:ja(t,e.line,e.col),endOffset:ja(t,e.line,n)}}async function fy(e){const{HTMLHint:t}=await dy(),n=uy(e);return t.verify(e,r.EMAIL_CODE_RULESET).map(o=>my(o,n))}var gy=class extends h.Disposable{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=r.getDataSources(e),this.addDisposable(h.getEvent(e,h.events.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>t.project===e).map(t=>Rg(t,this._container))}async _readProjectBlocks(){const e=await r.getBlocksProject(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>Og(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>Lg(n,this._container))}async getEmailSnapshot(){return $p(r.getOpenEmail(this._container,this._currentEmail),this._container)}async getEmail(e=!0){return this.compile(e)}async compileEmail(e=!0){return this.compile(e)}async compile(e){const{compileEmail:t}=await Fo();return t(await this.getEmailSnapshot(),e,on(this._container).keepWrappedOnOutput)}setEmailMeta(e){const t=r.getOpenDocument(this._container);if(!t)return;const n=t.get().attributes.meta;r.writeEmailAttributes(t,{meta:r.applyMetaPatch({meta:n},e).meta});const o=t.get().serverId;o!=null&&this._dataSources.emails.cache.addOrUpdate(o,i=>i&&r.applyMetaPatch(i,e))}setBlockMeta(e,t){const n=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,i=>i&&r.applyMetaPatch(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(n).catch(()=>{})}getCodeErrors(){const e=r.getCodeErrors(this._container);return e.length>0?e:void 0}validateCode(){return Promise.resolve(fy(r.getOpenEmail(this._container,this._currentEmail).html??""))}};function Ra(){Fo().catch(()=>{})}function hy(e){const t=r.provideHeadlessMode(e).watch(n=>{n&&Ra()});e.getInstance(h.DISPOSABLE_ID)?.addDisposable(t),Ht(e).whenVisible(()=>{Xt(Ra)})}var _y=h.createIdentifier$1("EmailOperationsController");function Oa(e){return e.getOrCreateInstance(_y,()=>{const t=new gy(e);return e.getInstance(h.DISPOSABLE_ID)?.addDisposable(t),t})}function yy(e){Oa(e),hy(e)}function vy(e){const t=Oa(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getEmail:()=>t.getEmail(),async compileEmail(n,o=!0){if(!n)return t.compileEmail(o);const{compileEmail:i}=await Fo();return i(n,o,on(e).keepWrappedOnOutput)},validateCode:()=>t.validateCode(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,o)=>t.setBlockMeta(n,o)}}var by=h.defineMixin(e=>{const t=e.getInstance(h.DISPOSABLE_ID),n=h.getEvent(e,h.events.UPLOAD_EVENT_ID),o=h.getEvent(e,h.events.FILE_PROXY_EVENT_ID),i=h.getEmitter(e,h.events.PROXY_URL_EVENT_ID).event,s=Ct(n),c=Ct(i),d=Ct(o),u=t.addDisposable(new kt(s)),p=t.addDisposable(new kt(d)),f=t.addDisposable(new kt(c));return{setOptions(g){u.setListener(g.handleLoadImage),p.setListener(g.handleFileProxy),f.setListener(g.handleUrlProxy)},instance:{handleLoadImage:s,handleFileProxy:d,handleUrlProxy:c}}}),Ey=h.defineMixin(e=>{const t=e.getInstance(h.DISPOSABLE_ID),n=h.getEvent(e,h.events.AI_TEXT_REQUEST_ID),o=h.getEvent(e,h.events.AI_IMAGE_REQUEST_ID),i=Ct(n),s=Ct(o),c=t.addDisposable(new kt(i)),d=t.addDisposable(new kt(s));return{setOptions(u){c.setListener(u.handleAITextRequest),d.setListener(u.handleAIImageRequest)},instance:{handleAITextRequest:i,handleAIImageRequest:s}}}),Sy=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function wy(e){const t=new Map;for(const n of e)for(const o of n.provides??[]){const i=t.get(o)??[];i.push(n),t.set(o,i)}return t}function ky(e,t){const n=[];for(const o of e.awaits?.services??[])for(const i of t.get(o)??[])i!==e&&n.push(i);return n}function Cy(e){const t=wy(e),n=[],o=new Set,i=[],s=new Set,c=d=>{if(!o.has(d)){if(s.has(d)){const u=i.indexOf(d);throw new Sy([...i.slice(u),d].map(p=>p.name))}s.add(d),i.push(d);for(const u of ky(d,t))c(u);i.pop(),s.delete(d),o.add(d),n.push(d)}};for(const d of e)c(d);return n}var Ty="author,slug,date,modified,title,acf.html,id,parent,date_gmt",Iy="author,slug,date,modified,modified_gmt,title,acf.html,id,parent",Ay=20,Bo=[h.WpEblockApi];function La(e){return typeof e=="string"&&e?`${e.replace(/Z$/,"")}Z`:void 0}function xy(e){return{async readRevisions(t,n=1){const o=await h.getApi(e,Bo).eblock_revisions_list({parent:t,per_page:Ay,page:n},{extraQuery:{_fields:Ty}}),i=(o?.data??[]).map(c=>r.WpBlockRevisionToBlockRevision(c)),s=Number(o?.headers?.get("X-WP-TotalPages"));return{revisions:i,page:n,hasMore:Number.isFinite(s)&&n<s}},async readAutosave(t){const n=h.getApi(e,Bo),[o,i]=await Promise.all([n.eblock_autosaves_list({id:t},{extraQuery:{_fields:Iy}}),n.eblock_detail({id:t},{extraQuery:{_fields:"modified_gmt"}})]),s=(o?.data??[]).map(d=>{const u=d,p=r.WpBlockRevisionToBlockRevision(u),f=La(u.modified_gmt);return f?{...p,modified:f}:p}),c=Date.parse(La(i?.data?.modified_gmt)??"");return r.autosaveStateFromSlots(s,Number.isFinite(c)?c:void 0)},async saveAutosave(t,n){const o=n,i=o.global_block&&o.html?r.injectEmBlockIdIntoBlockHtml(o.html,t):o.html??"";r.writePendingData(t,{sentAt:Date.now(),html:i,common_styles:""});const s=await h.getApi(e,Bo).eblock_autosaves_create({id:t},r.BlockAutoSaveToWpBlockAutoSave({title:o.title,html:i,project:o.project,excerpt:new Date().toISOString()}),{type:h.ContentType.FormData});return r.WpBlockRevisionToBlockRevision(s?.data)}}}var Py="author,slug,date,modified,title,meta,acf.html,acf.common_styles,id,parent,date_gmt",jy="author,slug,date,modified,modified_gmt,title,meta,acf.html,acf.common_styles,id,parent";function Ma(e){return typeof e=="string"&&e?`${e.replace(/Z$/,"")}Z`:void 0}var Ry=20,$o=[h.WpEmailApi];function Oy(e){return{async readRevisions(t,n=1){const o=await h.getApi(e,$o).email_revisions_list({parent:t,per_page:Ry,page:n},{extraQuery:{_fields:Py}}),i=(o?.data??[]).map(c=>r.WpEmailRevisionToEmailRevision(c)),s=Number(o?.headers?.get("X-WP-TotalPages"));return{revisions:i,page:n,hasMore:Number.isFinite(s)&&n<s}},async readAutosave(t){const n=h.getApi(e,$o),[o,i]=await Promise.all([n.email_autosaves_list({id:t},{extraQuery:{_fields:jy}}),n.email_detail({id:t},{extraQuery:{_fields:"modified_gmt"}})]),s=(o?.data??[]).map(d=>{const u=d,p=r.WpEmailRevisionToEmailRevision(u),f=Ma(u.modified_gmt);return f?{...p,modified:f}:p}),c=Date.parse(Ma(i?.data?.modified_gmt)??"");return r.autosaveStateFromSlots(s,Number.isFinite(c)?c:void 0)},async saveAutosave(t,n){const o=await h.getApi(e,$o).email_autosaves_create({id:t},r.EmailAutoSaveToWpEmailAutoSave({...n,excerpt:new Date().toISOString()}),{type:h.ContentType.FormData});return r.WpEmailRevisionToEmailRevision(o?.data)}}}var Na=["_embedded","id","author","title","meta","emailtags","folder","group","modified","date","type","parent","date_gmt","acf.description","acf.html","acf.common_styles","acf.is_template","acf.lock","acf.parent_email","acf.project","acf.secret_hash","acf.subject","acf.utm_parameters"].join(","),Uo=[h.WpEmailApi],Da=e=>r.EmailToWpEmail(e);function Ly(e){return{async readEmail(t){const n=await h.getApi(e,Uo).email_detail({id:r.toNumberSafe(t)},{extraQuery:{_embed:"wp:term",_fields:Na}});if(!n)throw new r.EmailOpenFailedError("unavailable");if(n.ok===!1)throw r.openFailureFromResponse(n);return n.data?r.WpEmailToEmail(n.data):null},async createEmail(t){const n={status:"publish",...Da(t)},o=await h.getApi(e,Uo).email_create(n,{type:h.ContentType.Json});return r.WpEmailToEmail(o?.data)},async updateEmail(t,n){const o=await h.getApi(e,Uo).email_partial_update({id:t},Da(n),{type:h.ContentType.Json,extraQuery:{_embed:"wp:term",_fields:Na}});return r.WpEmailToEmail(o?.data)}}}function My(e){r.injectRestEmailPortFactories(e,{email:Ly,history:Oy,blockHistory:xy})}var zo=20,Ny=({source:e,emailtags:t,group:n,tags:o,...i})=>i;function Dy({revisions:e,revisionsByBlock:t}){const n=async(o,i)=>(t.clear(),await t.get(o,{page:i}),(await e.cache.values()??[]).filter(s=>String(s?.parent)===String(o)));return{async readRevisions(o,i=1){const s=await n(o,i);return{revisions:s.slice(zo*(i-1),zo*i),page:i,hasMore:s.length>zo*i}},async readAutosave(o){return r.autosaveStateFromRevisions(await n(o,1))},async saveAutosave(o,i){const s=Ny(i);return await e.create({...s,parent:o,modified:new Date().toString()})}}}var Fa=h.createIdentifier$1("blockDocuments.provided");function Fy(e){if(e.getInstance(Fa))return;e.inject(Fa,!0);const t=r.blockRevisionsDataSourceProvider(e);r.injectBlockHistoryPort(e,Dy({revisions:t,revisionsByBlock:t.byForeignKey("parent")}))}var By=zt.__commonJSMin(((e,t)=>{(function(n){if(typeof window>"u")return;var o=0,i,s=!1,c=!1,d=7,u="[iFrameSizer]",p=u.length,f=null,g=window.requestAnimationFrame,y=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),m={},S=null,k=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,license:"1jqr0si6pnt",log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){R("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function w(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function b(C,T,P){C.addEventListener(T,P,!1)}function A(C,T,P){C.removeEventListener(T,P,!1)}function x(){for(var C=["moz","webkit","o","ms"],T=0;T<C.length&&!g;T+=1)g=window[C[T]+"RequestAnimationFrame"];g?g=g.bind(window):O("setup","RequestAnimationFrame not supported")}function Y(C){var T="Host page: "+C;return window.top!==window.self&&(T=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+C:"Nested host page: "+C),T}function Z(C){return u+"["+Y(C)+"]"}function M(C){return m[C]?m[C].log:s}function O(C,T){z("log",C,T,M(C))}function I(C,T){z("info",C,T,M(C))}function R(C,T){z("warn",C,T,!0)}function z(C,T,P,N){N===!0&&window.console}function B(C){function T(){function $(){et(ie),ee(te),We("onResized",ie)}v("Height"),v("Width"),Ee($,ie,"init")}function P(){var $=Xe.slice(p).split(":"),le=$[1]?parseInt($[1],10):0,xe=m[$[0]]&&m[$[0]].iframe,Se=getComputedStyle(xe);return{iframe:xe,id:$[0],height:le+N(Se)+D(Se),width:$[2],type:$[3]}}function N($){return $.boxSizing!=="border-box"?0:($.paddingTop?parseInt($.paddingTop,10):0)+($.paddingBottom?parseInt($.paddingBottom,10):0)}function D($){return $.boxSizing!=="border-box"?0:($.borderTopWidth?parseInt($.borderTopWidth,10):0)+($.borderBottomWidth?parseInt($.borderBottomWidth,10):0)}function v($){var le=Number(m[te]["max"+$]),xe=Number(m[te]["min"+$]),Se=$.toLowerCase(),Ne=Number(ie[Se]);O(te,"Checking "+Se+" is in range "+xe+"-"+le),Ne<xe&&(Ne=xe,O(te,"Set "+Se+" to min value")),Ne>le&&(Ne=le,O(te,"Set "+Se+" to max value")),ie[Se]=""+Ne}function W(){function $(){function Se(){var He=0,$e=!1;for(O(te,"Checking connection is from allowed list of origins: "+xe);He<xe.length;He++)if(xe[He]===le){$e=!0;break}return $e}function Ne(){var He=m[te]&&m[te].remoteHost;return O(te,"Checking connection is from: "+He),le===He}return xe.constructor===Array?Se():Ne()}var le=C.origin,xe=m[te]&&m[te].checkOrigin;if(xe&&""+le!="null"&&!$())throw new Error("Unexpected message received from: "+le+" for "+ie.iframe.id+". Message was: "+C.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function Pe(){return u===(""+Xe).slice(0,p)&&Xe.slice(p).split(":")[0]in m}function Ae(){var $=ie.type in{true:1,false:1,undefined:1};return $&&O(te,"Ignoring init message from meta parent page"),$}function Qe($){return Xe.slice(Xe.indexOf(":")+d+$)}function Ge($){O(te,"onMessage passed: {iframe: "+ie.iframe.id+", message: "+$+"}"),We("onMessage",{iframe:ie.iframe,message:JSON.parse($)}),O(te,"--")}function Ze(){var $=document.body.getBoundingClientRect(),le=ie.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:le.height,iframeWidth:le.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(le.top-$.top,10),offsetLeft:parseInt(le.left-$.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function pt($,le){function xe(){fe("Send Page Info","pageInfo:"+Ze(),$,le)}Ce(xe,32,le)}function bt(){function $(Ne,He){function $e(){m[Se]?pt(m[Se].iframe,Se):le()}["scroll","resize"].forEach(function(ot){O(Se,Ne+ot+" listener for sendPageInfo"),He(window,ot,$e)})}function le(){$("Remove ",A)}function xe(){$("Add ",b)}var Se=te;xe(),m[Se]&&(m[Se].stopPageInfo=le)}function ft(){m[te]&&m[te].stopPageInfo&&(m[te].stopPageInfo(),delete m[te].stopPageInfo)}function lt(){var $=!0;return ie.iframe===null&&(R(te,"IFrame ("+ie.id+") not found"),$=!1),$}function G($){var le=$.getBoundingClientRect();return q(te),{x:Math.floor(Number(le.left)+Number(f.x)),y:Math.floor(Number(le.top)+Number(f.y))}}function K($){function le(){f=He,ne(),O(te,"--")}function xe(){return{x:Number(ie.width)+Ne.x,y:Number(ie.height)+Ne.y}}function Se(){window.parentIFrame?window.parentIFrame["scrollTo"+($?"Offset":"")](He.x,He.y):R(te,"Unable to scroll to requested position, window.parentIFrame not found")}var Ne=$?G(ie.iframe):{x:0,y:0},He=xe();O(te,"Reposition requested from iFrame (offset x:"+Ne.x+" y:"+Ne.y+")"),window.top===window.self?le():Se()}function ne(){We("onScroll",f)===!1?Fe():ee(te)}function ue($){function le(){var $e=G(He);O(te,"Moving to in page link (#"+Se+") at x: "+$e.x+" y: "+$e.y),f={x:$e.x,y:$e.y},ne(),O(te,"--")}function xe(){window.parentIFrame?window.parentIFrame.moveToAnchor(Se):O(te,"In page link #"+Se+" not found and window.parentIFrame not found")}var Se=$.split("#")[1]||"",Ne=decodeURIComponent(Se),He=document.getElementById(Ne)||document.getElementsByName(Ne)[0];He?le():window.top===window.self?O(te,"In page link #"+Se+" not found"):xe()}function he($){var le={};if(Number(ie.width)===0&&Number(ie.height)===0){var xe=Qe(9).split(":");le={x:xe[1],y:xe[0]}}else le={x:ie.width,y:ie.height};We($,{iframe:ie.iframe,screenX:Number(le.x),screenY:Number(le.y),type:ie.type})}function We($,le){return U(te,$,le)}function Ve(){switch(m[te]&&m[te].firstRun&&Me(),ie.type){case"close":me(ie.iframe);break;case"message":Ge(Qe(6));break;case"mouseenter":he("onMouseEnter");break;case"mouseleave":he("onMouseLeave");break;case"autoResize":m[te].autoResize=JSON.parse(Qe(9));break;case"scrollTo":K(!1);break;case"scrollToOffset":K(!0);break;case"pageInfo":pt(m[te]&&m[te].iframe,te),bt();break;case"pageInfoStop":ft();break;case"inPageLink":ue(Qe(9));break;case"reset":be(ie);break;case"init":T(),We("onInit",ie.iframe);break;default:Number(ie.width)===0&&Number(ie.height)===0?R("Unsupported message received ("+ie.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):T()}}function st($){var le=!0;return m[$]||(le=!1,R(ie.type+" No settings for "+$+". Message was: "+Xe)),le}function Bt(){for(var $ in m)fe("iFrame requested init",Q($),m[$].iframe,$)}function Me(){m[te]&&(m[te].firstRun=!1)}var Xe=C.data,ie={},te=null;Xe==="[iFrameResizerChild]Ready"?Bt():Pe()?(ie=P(),te=ie.id,m[te]&&(m[te].loaded=!0),!Ae()&&st(te)&&(O(te,"Received: "+Xe),lt()&&W()&&Ve())):I(te,"Ignored: "+Xe)}function U(C,T,P){var N=null,D=null;if(m[C])if(N=m[C][T],typeof N=="function")D=N(P);else throw new TypeError(T+" on iFrame["+C+"] is not a function");return D}function de(C){var T=C.id;delete m[T]}function me(C){var T=C.id;if(U(T,"onClose",T)===!1){O(T,"Close iframe cancelled by onClose event");return}O(T,"Removing iFrame: "+T);try{C.parentNode&&C.parentNode.removeChild(C)}catch(P){R(P)}U(T,"onClosed",T),O(T,"--"),de(C),i&&(i.disconnect(),i=null)}function q(C){f===null&&(f={x:window.pageXOffset===n?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===n?document.documentElement.scrollTop:window.pageYOffset},O(C,"Get page position: "+f.x+","+f.y))}function ee(C){f!==null&&(window.scrollTo(f.x,f.y),O(C,"Set page position: "+f.x+","+f.y),Fe())}function Fe(){f=null}function be(C){function T(){et(C),fe("reset","reset",C.iframe,C.id)}O(C.id,"Size reset requested by "+(C.type==="init"?"host page":"iFrame")),q(C.id),Ee(T,C,"reset")}function et(C){function T(v){if(!C.id){O("undefined","messageData id not set");return}C.iframe.style[v]=C[v]+"px",O(C.id,"IFrame ("+D+") "+v+" set to "+C[v]+"px")}function P(v){!c&&C[v]==="0"&&(c=!0,O(D,"Hidden iFrame detected, creating visibility listener"),Be())}function N(v){T(v),P(v)}var D=C.iframe.id;m[D]&&(m[D].sizeHeight&&N("height"),m[D].sizeWidth&&N("width"))}function Ee(C,T,P){P!==T.type&&g&&!window.jasmine?(O(T.id,"Requesting animation frame"),g(C)):C()}function fe(C,T,P,N,D){function v(){var Ge=m[N]&&m[N].targetOrigin;O(N,"["+C+"] Sending msg to iframe["+N+"] ("+T+") targetOrigin: "+Ge),P.contentWindow.postMessage(u+T,Ge)}function W(){R(N,"["+C+"] IFrame("+N+") not found")}function Pe(){P&&"contentWindow"in P&&P.contentWindow!==null?v():W()}function Ae(){function Ge(){m[N]&&!m[N].loaded&&!Qe&&(Qe=!0,R(N,"IFrame has not responded within "+m[N].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}D&&m[N]&&m[N].warningTimeout&&(m[N].msgTimeout=setTimeout(Ge,m[N].warningTimeout))}var Qe=!1;N=N||P.id,m[N]&&(Pe(),Ae())}function Q(C){return C+":"+m[C].bodyMarginV1+":"+m[C].sizeWidth+":"+m[C].log+":"+m[C].interval+":"+m[C].enablePublicMethods+":"+m[C].autoResize+":"+m[C].bodyMargin+":"+m[C].heightCalculationMethod+":"+m[C].bodyBackground+":"+m[C].bodyPadding+":"+m[C].tolerance+":"+m[C].inPageLinks+":"+m[C].resizeFrom+":"+m[C].widthCalculationMethod+":"+m[C].mouseEvents}function pe(C){return typeof C=="number"}function se(C,T){function P(){function K(ue){var he=m[G][ue];he!==1/0&&he!==0&&(C.style[ue]=pe(he)?he+"px":he,O(G,"Set "+ue+" = "+C.style[ue]))}function ne(ue){if(m[G]["min"+ue]>m[G]["max"+ue])throw new Error("Value for min"+ue+" can not be greater than max"+ue)}ne("Height"),ne("Width"),K("maxHeight"),K("minHeight"),K("maxWidth"),K("minWidth")}function N(){var K=T&&T.id||k.id+o++;return document.getElementById(K)!==null&&(K+=o++),K}function D(K){if(typeof K!="string")throw new TypeError("Invaild id for iFrame. Expected String");return K===""&&(C.id=K=N(),s=(T||{}).log,O(K,"Added missing iframe ID: "+K+" ("+C.src+")")),K}function v(){switch(O(G,"IFrame scrolling "+(m[G]&&m[G].scrolling?"enabled":"disabled")+" for "+G),C.style.overflow=(m[G]&&m[G].scrolling)===!1?"hidden":"auto",m[G]&&m[G].scrolling){case"omit":break;case!0:C.scrolling="yes";break;case!1:C.scrolling="no";break;default:C.scrolling=m[G]?m[G].scrolling:"no"}}function W(){(typeof(m[G]&&m[G].bodyMargin)=="number"||(m[G]&&m[G].bodyMargin)==="0")&&(m[G].bodyMarginV1=m[G].bodyMargin,m[G].bodyMargin=""+m[G].bodyMargin+"px")}function Pe(){var K=m[G]&&m[G].firstRun,ne=m[G]&&m[G].heightCalculationMethod in y;!K&&ne&&be({iframe:C,height:0,width:0,type:"init"})}function Ae(){m[G]&&(m[G].iframe.iFrameResizer={close:me.bind(null,m[G].iframe),removeListeners:de.bind(null,m[G].iframe),resize:fe.bind(null,"Window resize","resize",m[G].iframe),moveToAnchor:function(K){fe("Move to anchor","moveToAnchor:"+K,m[G].iframe,G)},sendMessage:function(K){K=JSON.stringify(K),fe("Send Message","message:"+K,m[G].iframe,G)}})}function Qe(K){function ne(){fe("iFrame.onload",K,C,n,!0),Pe()}function ue(We){if(!C.parentNode)return null;var Ve=new We(function(st){st.forEach(function(Bt){Array.prototype.slice.call(Bt.removedNodes).forEach(function(Me){Me===C&&me(C)})})});return Ve.observe(C.parentNode,{childList:!0}),Ve}var he=w();he&&(i=ue(he)),b(C,"load",ne),fe("init",K,C,n,!0)}function Ge(K){if(typeof K!="object")throw new TypeError("Options is not an object")}function Ze(K){for(var ne in k)Object.prototype.hasOwnProperty.call(k,ne)&&(m[G][ne]=Object.prototype.hasOwnProperty.call(K,ne)?K[ne]:k[ne])}function pt(K){return K===""||K.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":K}function bt(K){var ne=K.split("Callback");if(ne.length===2){var ue="on"+ne[0].charAt(0).toUpperCase()+ne[0].slice(1);this[ue]=this[K],delete this[K],R(G,"Deprecated: '"+K+"' has been renamed '"+ue+"'. The old method will be removed in the next major version.")}}function ft(K){K=K||{},m[G]=Object.create(null),m[G].iframe=C,m[G].firstRun=!0,m[G].remoteHost=C.src&&C.src.split("/").slice(0,3).join("/"),Ge(K),Object.keys(K).forEach(bt,K),Ze(K),m[G]&&(m[G].targetOrigin=m[G].checkOrigin===!0?pt(m[G].remoteHost):"*")}function lt(){return G in m&&"iFrameResizer"in C}var G=D(C.id);lt()?R(G,"Ignored iFrame, already setup."):(ft(T),v(),P(),W(),Qe(Q(G)),Ae())}function ae(C,T){S===null&&(S=setTimeout(function(){S=null,C()},T))}var Ie={};function Ce(C,T,P){Ie[P]||(Ie[P]=setTimeout(function(){Ie[P]=null,C()},T))}function Be(){function C(){function D(v){function W(Ae){return(m[v]&&m[v].iframe.style[Ae])==="0px"}function Pe(Ae){return Ae.offsetParent!==null}m[v]&&Pe(m[v].iframe)&&(W("height")||W("width"))&&fe("Visibility change","resize",m[v].iframe,v)}Object.keys(m).forEach(function(v){D(v)})}function T(D){O("window","Mutation observed: "+D[0].target+" "+D[0].type),ae(C,16)}function P(){var D=document.querySelector("body");new N(T).observe(D,{attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0})}var N=w();N&&P()}function J(C){function T(){Te("Window "+C,"resize")}O("window","Trigger event: "+C),ae(T,16)}function _e(){function C(){Te("Tab Visible","resize")}document.visibilityState!=="hidden"&&(O("document","Trigger event: Visibility change"),ae(C,16))}function Te(C,T){function P(N){return m[N]&&m[N].resizeFrom==="parent"&&m[N].autoResize&&!m[N].firstRun}Object.keys(m).forEach(function(N){P(N)&&fe(C,T,m[N].iframe,N)})}function ge(){b(window,"message",B),b(window,"resize",function(){J("resize")}),b(document,"visibilitychange",_e),b(document,"-webkit-visibilitychange",_e)}function Re(){function C(N,D){function v(){if(D.tagName){if(D.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+D.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}D&&(v(),se(D,N),P.push(D))}function T(N){N&&N.enablePublicMethods&&R("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var P;return x(),ge(),function(D,v){switch(P=[],T(D),typeof v){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(v||"iframe"),C.bind(n,D));break;case"object":C(D,v);break;default:throw new TypeError("Unexpected data type ("+typeof v+")")}return P}}function ze(C){C.fn?C.fn.iFrameResize||(C.fn.iFrameResize=function(P){function N(D,v){se(v,P)}return this.filter("iframe").each(N).end()}):I("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==n&&ze(window.jQuery),typeof define=="function"&&define.amd?define([],Re):typeof t=="object"&&typeof t.exports=="object"&&(t.exports=Re()),window.iFrameResize=window.iFrameResize||Re()})()})),$y=zt.__toESM(By()),Uy={checkOrigin:!1,minHeight:600,scrolling:!1};function zy(e){const t=()=>e.iFrameResizer;return(0,$y.default)(Uy,e),{resize:()=>t()?.resize?.(),dispose:()=>t()?.removeListeners?.()}}function Gy(e){e.inject(Li,zy)}function Wy(e){const t=r.getMessageService(e),n=e.getInstance(r.LOCALE_SERVICE_ID);if(!n)return;let o="";const i=()=>{const d=n.snapshot(),u=d.id??"";if(!t.isInited()||u===o)return;const p=r.createI18n(d.catalog),f=y=>p.__(y),g=r.SANDBOX_TRANSLATIONS_MAP(f);o=u,t.send(r.EVENT_TYPES.SANDBOX_TRANSLATIONS,{name:u,data:g})},s=t.onInit(()=>{o="",i()}),c=n.state.watch(i);e.getInstance(h.DISPOSABLE_ID)?.addDispose(()=>{s.dispose(),c.dispose()})}function Hy(e){const t=e?.content?.templateId;return t==null||t===""?void 0:String(t)}function qy(e){e.getInstance(h.OPTIONS_SOURCE_ID)?.watch(t=>{const n=Hy(t);n!==void 0&&Dg(e,n)})}var Go={en_US:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/10c6144f.js")).then(e=>e.en_US_exports),void 0,{}.url),ru_RU:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/fc390885.js")),void 0,{}.url),uk_UA:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/60f7aa8d.js")),void 0,{}.url),es_ES:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/ec4827f1.js")),void 0,{}.url),pt_BR:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/23f020c5.js")),void 0,{}.url),de_DE:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/8035d07f.js")),void 0,{}.url),fr_FR:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/284b592e.js")),void 0,{}.url),it_IT:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/6ff64eea.js")),void 0,{}.url),pl_PL:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/740a4f32.js")),void 0,{}.url)};async function Vy(e){const t=Go[e];if(!t){const n=Go.en_US;return n?(await n()).default:void 0}return(await t()).default}var y0=Object.keys(Go),Ky=e=>e==="uk"?"uk_UA":e;function Yy(e){e.getInstance(r.LOCALE_SERVICE_ID)?.useAntdLoader(t=>Vy(Ky(t)))}function Qy(e){}function Ba(e,t,n){let o=!1;const i=e.watch(s=>{o||!t(s)||(o=!0,n())});o&&i.dispose()}function Xy(e,t){const n=e.getInstance(h.CONFIG_SOURCE_ID);n&&Ba(n,o=>!!o?.codeEnabled||!!o?.codeSideEnabled,()=>{ev(e,()=>{tv(e,()=>{Zy(e,()=>{Ht(e).whenVisible(()=>{Xt(()=>{Jy(t).catch(()=>{})})})})})})})}async function Jy(e){await e()}function Zy(e,t){const n=e.getInstance(Ms);if(!n){Xt(t);return}const o=()=>{if(n.pipeline.filledGeneration()!==void 0){t();return}Xt(o)};Xt(o)}function ev(e,t){const n=e.getInstance(r.EMAIL_DOCUMENTS_ID);if(!n)return;if(n.current()){t();return}let o=!1;const i=n.subscribe(()=>{o||!n.current()||(o=!0,t())});o&&i()}function tv(e,t){const n=e.getInstance(h.OPTIONS_SOURCE_ID);n&&Ba(n,o=>!!o?.element,t)}function nv(e){Xy(e,eu)}var $a=h.createIdentifier$1("NotificationService");function Ua(e,t="success"){return typeof e=="string"&&(e={message:e}),r.filterUndefined({type:e.type||t,data:e.data,innerException:e.innerException,title:e.message,description:e.description,actions:e.btn,onClose:e.onClose,duration:e.duration,icon:e.icon,placement:e.placement,style:e.style,closeIcon:e.closeIcon,props:e.props,role:e.role})}var rv="bottomRight";function Wo(e,t){return typeof e=="string"||typeof e=="object"?Ua(e,t):e}var ov=class extends h.Disposable{send;onNotify;onError;onSuccess;constructor(e,t,n){super(),this.send=n,this.onNotify=Ct(t,c=>c,c=>Wo(c)),this.onError=Ct(h.filter(t,c=>c.type==="error"),c=>c,c=>Wo(c,"error")),this.onSuccess=Ct(h.filter(t,c=>c.type==="success"),c=>c,c=>Wo(c));const o=this.addDisposable(new kt(this.onNotify)),i=this.addDisposable(new kt(this.onError)),s=this.addDisposable(new kt(this.onSuccess));this.addDisposable(e.watch(({handleNotify:c,handleError:d,handleSuccess:u})=>{o.setListener(c),i.setListener(d),s.setListener(u)}))}notify(e){this.send({placement:rv,...Ua(e)})}};function iv(e){e.injectFactory($a,()=>{const t=new ov(e.getInstance(h.OPTIONS_SOURCE_ID),h.getEvent(e,h.events.ON_NOTIFICATION),n=>{r.executeCommand(e,r.NOTIFY_COMMAND_ID,n)});return e.getInstance(h.DISPOSABLE_ID)?.addDisposable(t),t},!0)}function sv(e){const t=r.getEmailDocuments(e),n=i=>{e.getInstance(h.STORE_ID)?.dispatch(r.taxonomiesApi.util.invalidateTags([{type:"folder",id:i}]))},o=t.onSaved(i=>{i.created&&n("folder")});e.getInstance(h.DISPOSABLE_ID)?.addDispose(o)}function v0(e){return e}var av=[{name:"rest.legacySections",provides:[h.REST_CLIENT_ID],setup:h.provideLegacyRestSections},{name:"canvas.resizer",provides:[Li],setup:Gy},{name:"canvas.sandboxLocale",awaits:{services:[r.LOCALE_SERVICE_ID]},setup:Wy},{name:"locale.brandCatalog",awaits:{services:[r.LOCALE_SERVICE_ID]},setup:Qy},{name:"email.restPorts",provides:[r.REST_EMAIL_PORTS_ID],setup:My},{name:"block.historyPort",setup:Fy},{name:"email.templatePrefetch",setup:qy},{name:"locale.antd",awaits:{services:[r.LOCALE_SERVICE_ID]},setup:Yy},{name:"save.listsFollow",setup:sv},{name:"monaco.prewarm",awaits:{services:[h.CONFIG_SOURCE_ID]},setup:nv},{name:"notifications",provides:[$a],setup:iv},{name:"email.operations",setup:yy}],lv=h.defineMixin(e=>{for(const t of Cy(av))t.setup(e);return{instance:vy(e)}}),cv=h.combineMixins([lv,x_,oy,cy,by,Ey,jg,iy,Bs,$s]);async function dv(e){const t=new Map;typeof e=="object"&&(e=e.code);const{amp2html:n,html2amp:o}=await(0,Ke.__vitePreload)(async()=>{const{amp2html:c,html2amp:d}=await Promise.resolve().then(()=>ve("./static/core/74c1d64b.js"));return{amp2html:c,html2amp:d}},void 0,{}.url),i=await yt.changeHtml(e,async c=>{await yt.replaceImagesInDocument(c.document,d=>r.mapper.getEscapedText(d)!==d?d:r.toAbsoluteUrl(d),t);for(const d of c.document.querySelectorAll(".em-amp-show-disabled"))d.remove();c.handleRender(async({contentDocument:d,managedNodeController:u})=>{await o(d,{mappedTags:{script:"___script"},commit:()=>u.commit()})})},[800]),s=await yt.changeHtml(e,async c=>{await yt.replaceImagesInDocument(c.document,d=>r.mapper.getEscapedText(d)!==d?d:r.toAbsoluteUrl(d),t);for(const d of c.document.querySelectorAll(".em-amp-show-only"))d.remove();await n(c.document,{mappedTags:{script:"___script"}})},[800]);return{code:e,html:s,ampHtml:i}}async function uv(){const{installDiagnostics:e}=await(0,Ke.__vitePreload)(async()=>{const{installDiagnostics:t}=await Promise.resolve().then(()=>ve("./static/core/991b35ff.js"));return{installDiagnostics:t}},void 0,{}.url);return e()}async function pv(e,t){const{initDevTools:n}=await(0,Ke.__vitePreload)(async()=>{const{initDevTools:o}=await Promise.resolve().then(()=>ve("./static/core/7d627bff.js"));return{initDevTools:o}},void 0,{}.url);n(e,t)}var mv="1.1.85-dev.6";nn.asyncMixins=cv,nn.initDevTools=pv,nn.installDiagnostics=uv,nn.parseAMP=dv,nn.version=mv});
857
+ </tr>`)}},fn=async()=>{const L=ie();st(L,async V=>{try{const X=document.querySelector(".email-preview"),oe=getComputedStyle(X),re=await I(V,[oe.width],e.utm_parameters,async qe=>{ot(qe)}),H=await ne({htmlContent:re,notification:E}).unwrap(),ke=window.URL.createObjectURL(new Blob([H],{type:"application/pdf"})),ye=document.createElement("a");ye.href=ke,ye.setAttribute("download",`${Ve()}.pdf`),document.body.appendChild(ye),ye.click(),document.body.removeChild(ye),window.URL.revokeObjectURL(ke)}catch{}})},jt=L=>{const V=ie();st(V,X=>{Ee({event:"click",action:"export_email",export_type:"HTML"});const oe=document.querySelector(".email-preview"),re=getComputedStyle(oe);I(X,[re.width],e.utm_parameters,async H=>{await $e(H),ot(H),await r.processAmp(H,L)}).then(H=>{const ke=new Blob([H],{type:"text/html;charset=utf-8"});(0,sn.saveAs)(ke,`${Ve()}.html`)}).catch(H=>{})},!0)},ct=L=>{const V=ie();st(V,X=>{Ee({event:"click",action:"export_email",export_type:"TEXT"});const oe=document.querySelector(".email-preview"),re=getComputedStyle(oe);I(X,[re.width],e.utm_parameters,async H=>{await $e(H),ot(H),await r.processAmp(H,L);const[{htmlToText:ke},{EmailTextPlainConvertOptions:ye}]=await Promise.all([(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/6a939bac.js")),void 0,{}.url),(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/c28968c1.js")),void 0,{}.url)]);H.handleReadHtml(qe=>{qe.html=ke(qe.contentDocument,ye)})}).then(H=>{const ke=new Blob([H],{type:"text/plain;charset=utf-8"});(0,sn.saveAs)(ke,`${Ve()}.txt`)}).catch(H=>{})})},Et=()=>{const L=ie();st(L,V=>{Ee({event:"click",action:"export_email",export_type:"MARKDOWN"});const X=document.querySelector(".email-preview"),oe=getComputedStyle(X),{utm_parameters:re}=e;I(V,[oe.width],re,async H=>{ot(H),await r.processAmp(H,"html");const{htmlToMarkdown:ke}=await(0,Ke.__vitePreload)(async()=>{const{htmlToMarkdown:ye}=await Promise.resolve().then(()=>ve("./static/core/9ea82ab5.js"));return{htmlToMarkdown:ye}},void 0,{}.url);H.handleReadHtml(ye=>{ye.html=ke(ye.contentDocument)})}).then(H=>{const ke=new Blob([H],{type:"text/markdown;charset=utf-8"});(0,sn.saveAs)(ke,`${Ve()}.md`)}).catch(H=>r.reportError(H,{origin:"markdown-export"}))})},Lt=L=>{const V=ie();st(V,X=>{Ee({event:"click",action:"export_email",export_type:"Clipboard"});const oe=document.querySelector(".email-preview"),re=getComputedStyle(oe);I(X,[re.width],e.utm_parameters,async H=>{await $e(H),ot(H),await r.processAmp(H,L)}).then(H=>navigator.clipboard.writeText(H).then(function(){E.success(n("The email has been copied to the clipboard."))})).catch(H=>{})},!0)},On=async L=>{Oe&&po(Oe)},jn=()=>{ze(null),C("")},gn=async()=>{if(!P){N(!0);try{const L=await Se([800,nf],ef);if(!L)return;const{hrefs:V,dispose:X}=L;try{const[oe,re]=await Promise.all(V.map(ye=>yt.getImageByUrl(ye).then(qe=>yt.imageToBlob(qe)))),H=Ve(),ke=await yt.htmlFilesToZip(Zm(H,{desktop:oe,mobile:re}));(0,sn.saveAs)(ke,Ts(H).archive),Ee({event:"click",action:"export_email",export_type:"Image"})}finally{X()}}catch{E.error({title:n("Error"),description:n("Failed to export the email as images. Please try again.")})}finally{N(!1)}}},Ln=L=>{const V=Z.get(r.APP_COOKIES.em_token);return fetch(`https://app.useblocks.io/api/wp-json/cors-proxy/v1/get?url=${encodeURIComponent(L)}`,{headers:{authorization:`Bearer ${V}`}}).then(X=>X.blob())},Mn=L=>new Promise((V,X)=>{const oe=()=>Ln(L).then(V,X);fetch(L).then(re=>V(re.blob()),oe).catch(()=>{})}),gt=(L,V)=>{const X=ie();st(X,oe=>{Ee({event:"click",action:"export_email",export_type:"Outlook"});const re=document.querySelector(".email-preview"),H=getComputedStyle(re),ke=async(ye,qe)=>{ye.document,await r.processAmp(ye,qe),await $e(ye),ot(ye)};x(e.title,oe,[H.width,H.height],e.utm_parameters,L?ye=>ke(ye,"html"):ye=>ke(ye),V?{embedImagesAsBase64:!0,getImageBlob:Mn}:void 0).then(ye=>{const qe=new Blob([ye],{type:"text/html;charset=utf-8"});(0,sn.saveAs)(qe,`${Ve()}.eml`)}).catch(ye=>{})})},St=L=>{T({centered:!0,mask:{closable:!0},title:n("Embed images in the file?"),content:n('If "Yes", images will be included in the file itself. This is useful for offline viewing or if external images are blocked, but increases file size. If "No", images will be loaded from external links.'),okText:n("Yes"),cancelText:n("No"),onOk:()=>gt(L,!0),onCancel:()=>gt(L,!1)})},ce=async()=>{const L=ie();st(L,async V=>{Ee({event:"click",action:"export_email",export_type:"ZIP"});const X=document.querySelector(".email-preview"),oe=getComputedStyle(X),re=await K(V,[oe.width,void 0],e.utm_parameters,Mn,async ke=>{await $e(ke),ot(ke),Ct&&await r.processAmp(ke,"html")});Ct&&(re["amp.html"]=await I(V,[oe.width],e.utm_parameters,async ke=>{await $e(ke),ot(ke),await r.processAmp(ke,"amp")}));const H=await yt.htmlFilesToZip(re);(0,sn.saveAs)(H,`${Ve()}.zip`)},!0)},we=async()=>{if(Ee({event:"click",action:"duplicate_email",entity_type:"email",entity_id:e.id,project_id:e.project,context:"editor"}),e.isNew)E.warning({title:n("To create a copy, you need to save the email.")});else{if((await B.fire(e)).some(L=>L===!1))return;ft({title:xt.generateCopyTitle(e.title),...e.meta!==void 0?{meta:e.meta}:{},project:Number(ue?.id),description:e.description,html:xt.generateCopyHtml(ie()||"",String(e.title)),parent_email:e.parent_email||6892,common_styles:e.common_styles||"",utm_parameters:{utm_source:e.utm_parameters?.utm_source,utm_medium:e.utm_parameters?.utm_medium,utm_campaign:e.utm_parameters?.utm_campaign,utm_term:e.utm_parameters?.utm_term,utm_content:e.utm_parameters?.utm_content},emailtags:e.emailtags,folder:e.folder}).unwrap().then(L=>{u(`/projects/${ue.id}/emails/${L.id}`),E.success({title:n('The copy of email "')+e.title+n('" was successfully created.')}),Ee({event:"duplicate",action:"duplicate_email_success",entity_type:"email",entity_id:e.id,cloned_entity_id:L.id,project_id:e.project,context:"editor"}),he("folder")}).catch(L=>{E.error({title:L.data.code,description:L.data.message})})}},De=()=>{Ee({event:"click",action:"click_delete_email_menu_item",entity_type:"email",entity_id:e.id,project_id:e.project,context:"editor"}),e.isNew?E.success(n("The draft of the email has been deleted.")):nt(e,u)},nt=(L,V)=>{Ee({event:"open",action:"open_delete_email_modal",entity_type:"email",entity_id:L.id,project_id:L.project,context:"editor"}),T({mask:{closable:!0},centered:!0,title:o('Are you sure to delete "',"email")+L.title+n('" email?'),icon:(0,a.jsx)(r.EmIcons,{icon:"DeleteOutlined",component:_.icons$DeleteOutlined,size:22,style:{color:_.ui_kit$iconColors.danger,marginInlineEnd:12,flexShrink:0}}),okText:n("Yes"),cancelText:n("No"),onOk:()=>bt(L,V)})},je=()=>{fo().catch(()=>{}),r.uploadFile("application/zip, message/rfc822, text/html",Yt)},Yt=async L=>{const V=L[0];try{i(r.setIsGlobalLoading(!0));const{createDocumentProcessor:X,createFileProcessor:oe,importEmail:re}=await fo(),{html:H,hasBrowserExtensionArtifacts:ke}=await re(V,oe(c,d,h,ue,M),X(V))??{html:"",hasBrowserExtensionArtifacts:!1};ke&&U.fire();const[ye]=yt.getFileNameAndExt(V.name.replaceAll("&nbsp;"," ")),qe=ye||xt.getTitleFromHtml(H)||"";te(H,{undoable:!0}),s({title:qe}),i(r.setIsGlobalLoading(!1)),le.fire({html:H})}catch(X){i(r.setIsGlobalLoading(!1));const oe=X instanceof Error?X.message:X;E.error({title:oe})}Ee({event:"upload_file",action:"import_email"})},$t=()=>{const L=ie();L&&(Ee({event:"click",action:"convert_layout"}),le.fire({html:L}))},dt=[];M.emailDropdownMenuClone&&dt.push({label:n("Clone"),icon:(0,a.jsx)(r.EmIcons,{icon:"CopyOutlined",component:_.icons$CopyOutlined,size:16,strokeWidth:M.iconStrokeWidth}),key:"Clone",className:"em-analytics__email-clone",disabled:lt.isLoading,onClick:we}),M.emailDropdownMenuImport&&dt.push({label:o("Import","verb"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"CloudUploadOutlined",component:_.icons$CloudUploadOutlined,style:Dt}),locked:Qe.isLocked,strokeWidth:M.iconStrokeWidth}),key:"Import",className:"em-analytics__editor-page__import",onClick:()=>{if(Qe.isLocked){Ze("template_import");return}Ee({event:"click",action:"import_email"}),je()}});const Nn=ie(),Ut=!e.hasOwnProperty("type")&&bs(Nn,j)!==null;M.emailDropdownMenuConvert&&Ut&&dt.push({label:n("Convert"),icon:(0,a.jsx)(r.EmIcons,{icon:"SwapOutlined",component:_.icons$SwapOutlined,size:16,strokeWidth:M.iconStrokeWidth}),key:"ConvertLayout",className:"em-analytics__email-convert",onClick:$t}),(p||f||h.id?.toString()===e.author?.toString())&&(M.emailDropdownMenuLock&&dt.push({label:(0,a.jsx)(ys,{element:e,context:"editor"},"Lock"),icon:e.lock?(0,a.jsx)(r.EmIcons,{icon:"UnLock",component:_.icons$UnLock,size:16,strokeWidth:M.iconStrokeWidth}):(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:16,strokeWidth:M.iconStrokeWidth}),disabled:e.isNew}),M.emailDropdownMenuRemove&&dt.push({label:n("Remove"),icon:(0,a.jsx)(r.EmIcons,{icon:"DeleteOutlined",component:_.icons$DeleteOutlined,size:16,strokeWidth:M.iconStrokeWidth}),key:"Remove",className:"em-analytics__email-remove",style:{color:"#ff4d4f"},onClick:De}));const Ct=e.isAmp,It=[],Dr=()=>[...Ct?[{key:"html_txt",label:`${n("Plain text")} (HTML)`,onClick:()=>ct("html")},{key:"сode_txt",label:`${n("Plain text")} (AMP)`,onClick:()=>ct("amp")}]:[{key:"plain_txt",label:n("Plain text"),onClick:()=>ct()}],{key:"markdown",label:n("Markdown"),onClick:()=>Et()}];M.exportHtmlEnabled&&It.push({key:"html",label:n("Code"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FileTextOutlined",component:_.icons$FileTextOutlined,style:Dt}),locked:D.isLocked,strokeWidth:M.iconStrokeWidth}),...D.isLocked?{onClick:()=>Ze("export_html")}:Ct?{children:[{key:"сode_html",label:n("AMP"),onClick:()=>Ae.isLocked?Ze("export_amp"):jt("amp")},{key:"html_amp",label:n("HTML"),onClick:()=>jt("html")}]}:{onClick:()=>jt()}}),M.exportZipEnabled&&It.push({key:"zip",label:n("ZIP"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FileZipOutlined",component:_.icons$FileZipOutlined,style:Dt}),locked:D.isLocked,strokeWidth:M.iconStrokeWidth}),...D.isLocked?{onClick:()=>Ze("export_html")}:{onClick:()=>ce().catch(L=>{})}}),M.exportClipboardEnabled&&It.push({key:"clipboard",label:n("Clipboard"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"SnippetsOutlined",component:_.icons$SnippetsOutlined,style:Dt}),locked:D.isLocked,strokeWidth:M.iconStrokeWidth}),...D.isLocked?{onClick:()=>Ze("export_html")}:Ct?{children:[{key:"clipboard_html",label:n("AMP"),onClick:()=>Ae.isLocked?Ze("export_amp"):Lt("amp")},{key:"clipboard_amp",label:n("HTML"),onClick:()=>Lt("html")}]}:{onClick:()=>Lt()}}),M.exportTextEnabled&&It.push({key:"text",label:n("Text"),icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FileOutlined",component:_.icons$FileOutlined,style:Dt}),locked:D.isLocked,strokeWidth:M.iconStrokeWidth}),...D.isLocked?{onClick:()=>Ze("export_html")}:M.exportMarkdownEnabled?{children:Dr()}:Ct?{children:[{key:"сode_txt",label:n("AMP"),onClick:()=>Ae.isLocked?Ze("export_amp"):ct("amp")},{key:"html_txt",label:n("HTML"),onClick:()=>ct("html")}]}:{onClick:()=>ct()}}),M.exportOutlookEnabled&&It.push({key:"outlook",icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FileWordOutlined",component:_.icons$FileWordOutlined,style:Dt}),locked:Pe.isLocked,strokeWidth:M.iconStrokeWidth}),label:n("Outlook"),onClick:()=>Pe.isLocked?Ze("export_platforms"):St(!!Ct)}),M.exportPdfEnabled&&It.push({key:"pdf",icon:(0,a.jsx)(qt,{icon:(0,a.jsx)(r.EmIcons,{icon:"FilePdfOutlined",component:_.icons$FilePdfOutlined,style:Dt}),locked:v.isLocked,strokeWidth:M.iconStrokeWidth}),label:n("PDF"),onClick:()=>v.isLocked?Ze("export_pdf"):fn()}),M.exportPngEnabled&&It.push({key:"img",icon:(0,a.jsx)(qt,{icon:P?(0,a.jsx)(r.EmIcons,{icon:"LoadingOutlined",component:_.icons$LoadingOutlined,spin:!0,style:Dt}):(0,a.jsx)(r.EmIcons,{icon:"FileImageOutlined",component:_.icons$FileImageOutlined,style:Dt}),locked:W.isLocked,strokeWidth:M.iconStrokeWidth}),label:n("PNG"),disabled:!W.isLocked&&P,onClick:()=>W.isLocked?Ze("export_png"):gn()});const ht=e.author;return(0,a.jsxs)(_.ui_kit$Space,{children:[M.emailDropdownMenuEnabled?(0,a.jsx)(_.ui_kit$Dropdown,{arrow:{pointAtCenter:!0},placement:"bottom",menu:{items:dt},children:(0,a.jsx)(_.ui_kit$Button,{type:"default",block:!1,className:"email-page-header__btn email-page-header__btn_extra",onClick:()=>{},children:(0,a.jsx)(r.EmIcons,{icon:"DotsHoriz",component:_.icons$DotsHoriz,size:18,strokeWidth:M.iconStrokeWidth})})},"Actions"):M.emailDropdownMenuImport&&(0,a.jsx)(_.ui_kit$Tooltip,{title:o("Import","verb"),placement:"bottom",children:M.emailDropdownMenuImportButton?(0,a.jsx)(_.ui_kit$Button,{className:"em-analytics__editor-page__import",icon:(0,a.jsx)(r.EmIcons,{icon:"CloudUploadOutlined",component:_.icons$CloudUploadOutlined,size:16,strokeWidth:M.iconStrokeWidth}),onClick:()=>{Ee({event:"click",action:"import_email"}),je()},children:n("Import")}):(0,a.jsx)(_.ui_kit$Button,{className:"em-analytics__editor-page__import",type:"text",icon:(0,a.jsx)(r.EmIcons,{icon:"CloudUploadOutlined",component:_.icons$CloudUploadOutlined,size:22,strokeWidth:M.iconStrokeWidth}),onClick:()=>{Ee({event:"click",action:"import_email"}),je()}})}),M.emailExportEnabled&&(0,a.jsx)(_.ui_kit$Dropdown,{arrow:{pointAtCenter:!0},placement:"bottom",menu:{items:It},children:(0,a.jsx)(_.ui_kit$Button,{className:"em-analytics__email-page__export",type:"default",icon:(0,a.jsx)(r.EmIcons,{icon:"CloudDownloadOutlined",component:_.icons$CloudDownloadOutlined,size:16,strokeWidth:M.iconStrokeWidth}),children:n("Export")},"Export")},"Export"),!e.hasOwnProperty("type")&&(0,a.jsx)(_s,{disabled:fe,email:e},"Save"),!!e.hasOwnProperty("type")&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(Au,{disabled:fe,rightCol:void 0,block:e,isEditableRights:p||f||h.id?.toString()===ht?.toString(),autoSaveBlockResult:t})},"Save"),(0,a.jsx)(Jp,{open:pe,codeSize:r.getCodeSize(Te),onMinimize:Bt,onDownloadAsIs:Me,onCancel:Xe}),Oe&&po(Oe)&&(0,a.jsx)(cm,{integration:po(Oe),visible:!!Oe,loading:et,onConfirm:On,onCancel:jn,__:n}),(0,a.jsx)(r.PlanUpgradePrompt,{open:J,sideOnOk:void 0,onCancel:()=>_e(!1),initialSlide:Ce})]})},_r=r.createApi({reducerPath:"confirmationMailApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/",responseHandler:e=>e.text()}),endpoints:e=>({getConfirmationMail:e.query({query:({userId:t,email:n})=>({url:`?proxy_url=${encodeURIComponent(`https://webhook.latenode.com/5868/prod/1fbda9c1-3211-4b12-be45-9cd2ea73d73d?user_id=${t}&user_email=${n}`)}`})})})}),{useLazyGetConfirmationMailQuery:af}=_r,lf=()=>{const{__:e}=r.useI18n(),t=r.useNotification(),n=r.useCurrentUser(),[o]=af(),[i,s]=(0,l.useState)(!1),c=r.usePushToDataLayer();(0,l.useEffect)(()=>{n.hasOwnProperty("email_confirmation")&&s(n.email_confirmation)},[n,i]);const d=()=>{c({event:"click",action:"click_resend_confirmation_email",user_email:n.email,user_id:n.id}),o({userId:n.id,email:n.email}).then(({data:u,error:p})=>{u?t.success(e("Confirmation email has been sent to {confirmedEmail}.").replace("{confirmedEmail}",n.email)):p&&t.error(p)})};return n?.email_confirmation||!n?.privacy_policy_agreement?null:(0,a.jsx)("div",{className:"main__ribbon",children:(0,a.jsxs)("span",{children:[(0,a.jsx)(r.EmIcons,{icon:"EmailConfirmation",component:_.icons$EmailConfirmation,size:16,style:{marginRight:10,verticalAlign:"-0.15em"}}),e("Confirmation email was sent to")," ",(0,a.jsx)("em",{children:n.email}),". ",e("Didn't receive an email?")," ",(0,a.jsxs)(_.ui_kit$Button,{type:"primary",size:"small",className:"main__ribbon-resend",style:{fontSize:16,lineHeight:1,display:"inline-flex",alignItems:"center",gap:8},onClick:d,children:[e("Resend"),(0,a.jsx)(r.EmIcons,{icon:"SendOutlined",component:_.icons$SendOutlined,size:16,style:{flexShrink:0}})]})]})})},cf=({className:e,leftBlock:t,rightBlock:n,isHeaderCodeMenuOpen:o=!1})=>{const{token:i}=(0,_.ui_kit$useToken)(),s=(0,l.useRef)(),c=r.useAppConfig();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(lf,{}),c.headerShow&&(0,a.jsx)("header",{className:(0,rt.default)("header",{[e]:e}),style:{borderColor:i.colorBorder},children:!o&&(0,a.jsx)(r.CSSTransition,{nodeRef:s,in:!o,timeout:300,classNames:"transition",children:(0,a.jsxs)("div",{className:"header__container container",children:[(0,a.jsx)("div",{className:"header__left",style:{flexGrow:1},children:t}),(0,a.jsx)("div",{className:"header__right",children:(0,a.jsx)(_.ui_kit$Space,{size:10,children:n})})]})})})]})},df=e=>{},Cs=g.createIdentifier$1("canvas.headerFlow");function uf(e){const t=(0,l.useCallback)(n=>e?e.subscribe(n):()=>{},[e]);return(0,l.useSyncExternalStore)(t,()=>e?.isReady()===!0)}var Is=({email:e,isCollaborationEditor:t})=>{const[n]=_.ui_kit$Form.useForm(),{__:o}=r.useI18n();let i=r.useDispatch();const s=r.useEmailAttributesWriter(),c=r.useAppNavigate(),d=r.useOpenPlanCatalog(),u=qi("header"),p=r.useCurrentUser(),f=r.useContainer().getInstance(Cs),h=r.useProjectData(),{owner:y,admin:m}=Qn(),{token:E}=(0,_.ui_kit$useToken)(),T=r.useAppConfig(),w=r.usePushToDataLayer(),S=(0,l.useRef)(),I=(0,l.useRef)(),x=(0,l.useRef)(),K=r.useEventEmitter(g.events.ON_PREVIOUSBUTTON_CLICK_ID),Z=r.useEventEmitter(g.events.ON_PREHEADER_CHANGED_ID),M=r.useEventEmitter(g.events.ON_SUBJECT_CHANGED_ID),j=r.useSelector(r.selectCodeModeDirection),A=e.hasOwnProperty("type")?r.BLOCK:r.EMAIL,O=r.useSelector(r.selectElementSettings$1),z=r.useSelector(r.selectElementSettings),B=A==="email"?O:z,U=r.useSelector(r.selectIsCodeMode),[de,me]=(0,l.useState)(!1),[q,ee]=(0,l.useState)(!1),[Fe,be]=(0,l.useState)(!1),et=(0,l.useCallback)(()=>be(!1),[]),Ee=(0,l.useCallback)(()=>{be(!1),d()},[d]),fe=Gi("email_generate"),Q=fe.exceeded?r.getLimitUpgradePresetDefinition(fe.exceeded.presetId):null;(0,l.useEffect)(()=>{const v=!!B?.type&&(B?.type===r.ELEMENT_TYPES.TEXT||B?.type===r.ELEMENT_TYPES.LINK||B.type===r.ELEMENT_TYPES.BUTTON)&&U&&j!=="bottom";me(v),i(r.setHeaderCodeMenuOpen(v))},[B,j,U]);const pe=(0,l.useCallback)(()=>{w({event:"click",action:"click_back_button",entity_type:A==="block"?"block":"email",entity_id:e?.id,project_id:e?.project||h?.id,context:"editor"}),K.fire(e)},[c,K,e,h?.id,w,A]),{document:se}=r.useCurrentSession(),ae=uf(se);r.usePrevious(([v])=>{ae&&v!==e.subject&&M.fire(e.subject)},[e.subject,ae]);const Ie=(0,l.useCallback)(v=>{const W=v.target.value;M.fire(W)},[M]),Te=(0,l.useCallback)(v=>{const W=v.target.value;Z.fire(W)},[Z]);r.usePrevious(([v])=>{ae&&v!==e.preheader&&Z.fire(e.preheader)},[e.preheader,ae]);const Be=(0,l.useCallback)((v,W="?")=>{v.subject?.length,v.preheader?.length,n.setFieldValue("subject",v.subject??""),n.setFieldValue("preheader",v.preheader??"")},[n]),J=(0,l.useRef)(void 0);(0,l.useEffect)(()=>{const v=e?.renderGuid??(e?.id!=null?String(e.id):void 0);!ae||!v||J.current===v||(J.current=v,Be(e,"identity"))},[ae,e,Be]);const _e=(0,l.useCallback)(v=>{const W=r.stripSubjectTags(v.value).trim();return W!==v.value&&n.setFieldValue("subject",W),W},[n]),Ce=(0,l.useCallback)(v=>{const W=_e(v.target);s({subject:W})},[s,_e]),ge=r.useEvent(g.events.BEFORE_SAVE_EMAIL),Oe=(0,l.useCallback)(async v=>{const W=I.current?.input;if(document.activeElement===W){const Ae=_e(W);Ae!==v.subject&&(v.subject=Ae,s({subject:Ae}))}const Pe=x.current?.input;if(document.activeElement===Pe){const Ae=Pe.value.trim();Ae!==v.preheader&&(v.preheader=Ae,s({preheader:Ae}))}await f?.whenDelivered()},[f,s,_e]);(0,l.useEffect)(()=>{const v=ge(Oe);return()=>v.dispose()},[ge,Oe]);const ze=(0,l.useCallback)(v=>{const W=v.target.value.trim();s({preheader:W})},[s]),k=r.useEvent(g.events.ON_HEADER_APPLIED_ID);(0,l.useEffect)(()=>{const v=k(({field:W,value:Pe})=>{n.setFieldValue(W,Pe)});return()=>v.dispose()},[k,n]),df(e.title===null?o("New email title"):e.title);const C=(0,l.useCallback)(()=>{i(r.setActiveSettingsTab(r.AICHAT)),setTimeout(()=>{const v=document.querySelector('li.ai-response-change-context[role="theme-and-preheader-generator"]');v&&v.click()},100)},[i]),P=(0,l.useCallback)(()=>{fe.isLocked?fe.state.state==="locked_by_limit"&&fe.exceeded?be(!0):ee(!0):C()},[fe,C]),N=(0,a.jsx)(a.Fragment,{children:(0,a.jsxs)(_.ui_kit$Space,{ref:S,size:10,children:[T.headerArrowBackVisible&&(0,a.jsx)(_.ui_kit$Tooltip,{title:o("Back"),placement:"left",children:(0,a.jsx)(_.ui_kit$Button,{type:"text",icon:(0,a.jsx)(r.EmIcons,{icon:"ArrowLeftOutlined",component:_.icons$ArrowLeftOutlined,size:22,strokeWidth:T.iconStrokeWidth}),onClick:pe,shape:"circle"})}),(0,a.jsx)("div",{children:(T.headerTitleVisible||T.headerPreheaderVisible)&&(0,a.jsxs)(_.ui_kit$Form,{form:n,layout:"vertical",name:"subject_preheader_form",autoComplete:"off",initialValues:{subject:"",preheader:""},children:[T.headerTitleVisible&&(0,a.jsx)("div",{style:{marginTop:ae?-3:0},children:(0,a.jsxs)(_.ui_kit$Space,{style:{width:"100%"},align:"baseline",size:12,children:[(0,a.jsx)("div",{className:"subject_preheader_form__title",children:o("Subject")}),ae?(0,a.jsxs)("div",{className:"ant-page-header-heading",children:[(0,a.jsx)(_.ui_kit$Form.Item,{name:"subject",noStyle:!0,children:(0,a.jsx)(_.ui_kit$Input,{className:"ant-page-header-heading-title",ref:I,placeholder:o("Enter subject line here"),variant:"borderless",autoComplete:"off","data-lpignore":"true","data-1p-ignore":"","data-bwignore":"true","data-form-type":"other",onChange:Ie,onPressEnter:Ce,onBlur:v=>{Ce(v),document.querySelector(".ant-page-header-heading-title").closest(".ant-page-header-heading").classList.remove("focus")},onFocus:()=>{document.querySelector(".ant-page-header-heading-title").closest(".ant-page-header-heading").classList.add("focus")},disabled:T.lockPreheaderAndTitle})}),T.aiAssistentEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:o("Generate with AI"),children:(0,a.jsx)(r.EmIcons,{icon:"AI",component:_.icons$AI,size:12,strokeWidth:T.iconStrokeWidth,onClick:P})})]}):(0,a.jsx)(_.ui_kit$Skeleton.Input,{active:!0,size:16,style:{width:"40%",marginTop:3}})]})}),T.headerPreheaderVisible&&(0,a.jsx)("div",{children:(0,a.jsxs)(_.ui_kit$Space,{style:{width:"100%"},align:"baseline",size:12,children:[(0,a.jsx)("div",{className:"subject_preheader_form__title",children:o("Preheader")}),ae?(0,a.jsxs)("div",{className:"ant-page-header-heading ant-page-header-heading_preheader",children:[(0,a.jsx)(_.ui_kit$Form.Item,{name:"preheader",noStyle:!0,children:(0,a.jsx)(_.ui_kit$Input,{className:"ant-page-header-heading-preheader",ref:x,placeholder:o("Enter preheader here"),variant:"borderless",autoComplete:"off","data-lpignore":"true","data-1p-ignore":"","data-bwignore":"true","data-form-type":"other",onChange:Te,onPressEnter:ze,onBlur:v=>{ze(v),document.querySelector(".ant-page-header-heading-preheader").closest(".ant-page-header-heading").classList.remove("focus")},onFocus:()=>{document.querySelector(".ant-page-header-heading-preheader").closest(".ant-page-header-heading").classList.add("focus")},disabled:T.lockPreheaderAndTitle})}),T.aiAssistentEnabled&&(0,a.jsx)(_.ui_kit$Tooltip,{title:o("Generate with AI"),children:(0,a.jsx)(r.EmIcons,{icon:"AI",component:_.icons$AI,size:12,strokeWidth:T.iconStrokeWidth,onClick:P})})]}):(0,a.jsx)(_.ui_kit$Skeleton.Input,{active:!0,size:16,style:{width:"80%",marginTop:2}})]})})]})})]})}),D=(0,a.jsxs)(a.Fragment,{children:[T.emailIdShow&&!!e.id&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"email-page-header__email-id",children:"ID"+e.id}),(0,a.jsx)(_.ui_kit$Divider,{orientation:"vertical"})]}),(0,a.jsx)(ps,{emailElement:e,isCollaborationEditor:t}),T.commandButtonsEnabled&&(0,a.jsxs)(a.Fragment,{children:[e.lock?(0,a.jsx)(r.EmIcons,{icon:"Lock",component:_.icons$Lock,size:18,strokeWidth:T.iconStrokeWidth,className:(0,rt.default)("lock-icon",{"lock-icon__disabled":!(y||m||p.id?.toString()===e.author?.toString())}),style:{color:E.colorPrimary,verticalAlign:"sub"}},"Lock"):null,(0,a.jsx)(sf,{email:e,isHeaderCodeMenuOpen:de},"Buttons")]})]});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(cf,{className:"email-pane__header",leftBlock:u?N:null,rightBlock:u?D:null,isHeaderCodeMenuOpen:de}),(0,a.jsx)(r.PlanUpgradePrompt,{open:q,onCancel:()=>ee(!1),initialSlide:9}),Q&&fe.exceeded?(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(ro,{open:Fe,onClose:et,title:o(Q.titleKey),subtitle:o(Q.subtitleKey),usageResource:Q.usageResource,previousDisplay:r.presetLimitDisplay(fe.exceeded.previousLimit),nextDisplay:r.presetLimitDisplay(fe.exceeded.nextLimit),onChangePlan:Ee})}):null]})};Is.propTypes={};function pf(e){const t=r.parseEmBlockVersion(e);if(!t)return e;const n=o=>String(o).padStart(2,"0");return`${n(t.getDate())}.${n(t.getMonth()+1)}.${t.getFullYear()} ${n(t.getHours())}:${n(t.getMinutes())}:${n(t.getSeconds())}`}var mf=({open:e,blocks:t,projectId:n,onClose:o})=>{const{__:i,_n:s}=r.useI18n(),c=r.useSendPostMessage(),d=r.useNotification(),[u,p]=(0,l.useState)({});(0,l.useEffect)(()=>{e&&p(Object.fromEntries(t.map(m=>[m.emBlockId,!0])))},[e,t]);const f=(0,l.useMemo)(()=>Object.values(u).filter(Boolean).length,[u]),h=(m,E)=>{p(T=>({...T,[m]:E}))},y=()=>{const m=t.filter(E=>u[E.emBlockId]);m.length&&(m.forEach(E=>{c({operation:r.EVENT_TYPES.SANDBOX_GLOBAL_BLOCK_REPLACE,settings:{emBlockId:E.emBlockId,blockHTML:E.savedHtml,type:"project",...n?{project:String(n)}:{}}})}),d.success({message:i("Updated")+" "+m.length+" "+s("block","blocks",m.length),placement:"bottomRight"}),o())};return(0,a.jsxs)(_.ui_kit$Modal,{title:(0,a.jsx)("div",{className:"ant-modal-title",children:i("Update global blocks")}),open:e,onOk:y,onCancel:o,footer:(0,a.jsxs)("div",{className:"update-global-blocks-modal__footer",children:[(0,a.jsx)(_.ui_kit$Button,{size:"large",onClick:o,children:i("Cancel")}),(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",disabled:f===0,onClick:y,children:i("Update")})]}),children:[(0,a.jsx)("div",{className:"update-global-blocks-modal__hint",children:i("These global blocks have a newer saved version. Select the ones to update in the template.")}),(0,a.jsx)("div",{className:"update-global-blocks-modal__list",children:t.map(m=>(0,a.jsxs)("div",{className:"update-global-blocks-modal__row",children:[(0,a.jsx)(_.ui_kit$Switch,{checked:!!u[m.emBlockId],onChange:E=>h(m.emBlockId,E)}),(0,a.jsxs)("span",{className:"update-global-blocks-modal__title",title:m.title,children:[m.title,(0,a.jsxs)("span",{className:"update-global-blocks-modal__version",children:[i("Version of")," ",pf(m.savedVersion)]})]}),m.instances>1&&(0,a.jsxs)("span",{className:"update-global-blocks-modal__count",children:[m.instances," ",s("instance","instances",m.instances)]})]},m.emBlockId))})]})};function ff(e){const t=new Map;return e?.trim()&&new DOMParser().parseFromString(e,"text/html").querySelectorAll('[em="block"][em-block-id]').forEach(n=>{const o=n.getAttribute("em-block-id");if(!o)return;const i=n.getAttribute("em-block-version")??void 0,s=t.get(o);s?(s.versions.add(i),s.count+=1):t.set(o,{versions:new Set([i]),count:1})}),t}function gf(e,t){const n=ff(e);if(!n.size||!t?.length)return[];const o=[];for(const i of t){if(!i.global_block||!i.id||!i.html)continue;const s=String(i.id),c=n.get(s);if(!c)continue;const d=r.readRootEmBlockAttrs(i.html).emBlockVersion;d&&[...c.versions].some(u=>u!==d)&&o.push({emBlockId:s,title:i.title?.trim()||s,savedHtml:i.html,savedVersion:d,templateVersion:[...c.versions][0],instances:c.count})}return o}var As="em-block-id";function hf({projectId:e,document:t}){const n=r.useEvent(g.events.ON_EMAIL_INIT_ID),o=r.useHeadless(),[i,s]=(0,l.useState)([]),[c,d]=(0,l.useState)(!1),[u,p]=(0,l.useState)(null),f=(0,l.useCallback)(E=>t?.subscribe(E)??(()=>{}),[t]),h=(0,l.useSyncExternalStore)(f,()=>!!t?.getContent().includes(As)),{data:y}=r.blocksApi.endpoints.getBlocks.useQuery(r.projectBlocksArgs(e),{skip:!e||!h}),m=(0,l.useRef)(!1);return(0,l.useEffect)(()=>{h&&m.current&&t&&(m.current=!1,p(t.getContent()))},[h,t]),(0,l.useEffect)(()=>{const E=new g.Disposable;return E.addDisposable(n(T=>{if(T?.reset)return;const w=T?.html??"",S=w.includes(As);m.current=!S,p(S?w:null)})),()=>E.dispose()},[n]),(0,l.useEffect)(()=>{if(u==null||!y)return;if(o){p(null);return}const E=gf(u,y);E.length&&(s(E),d(!0)),p(null)},[u,y,o]),{outdatedBlocks:i,isOpen:c,close:(0,l.useCallback)(()=>d(!1),[])}}var _f=({open:e,html:t,emBlockId:n,onSaveAsNew:o,onClose:i})=>{const{__:s}=r.useI18n(),c=r.useSendPostMessage(),d=r.useNotification(),[u]=r.useEditBlockMutation(),[p,f]=(0,l.useState)(!1),h=async()=>{if(!n||!t){i();return}f(!0);const y=new Date,m=r.formatEmBlockVersion(y),E=r.injectEmBlockIdIntoBlockHtml(t,String(n),y),T=await u({blockId:String(n),html:E});if(f(!1),"error"in T&&T.error){d.error({message:s("Failed to update the global block."),placement:"bottomRight"});return}c({operation:r.EVENT_TYPES.SANDBOX_EBLOCK_SET_EM_BLOCK_ID,settings:{emBlockId:String(n),emBlockVersion:m}}),d.success({message:s("The global block was updated."),placement:"bottomRight"}),i()};return(0,a.jsx)(_.ui_kit$Modal,{title:(0,a.jsx)("div",{className:"ant-modal-title",children:s("Saving changes in the block")}),open:e,onCancel:i,footer:(0,a.jsxs)("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[(0,a.jsx)(_.ui_kit$Button,{size:"large",disabled:p,onClick:o,children:s("Create new block")}),(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",loading:p,onClick:h,children:s("Update current block")})]}),children:(0,a.jsx)("div",{children:s("This is a global block. You can create a new one to apply changes only in this email, or update the current one — then the changes will be applied everywhere this block is used.")})})},yf=(function(){var e=window.__useblocks__;if(e&&e.assetUrl)return e.assetUrl("converter-intro.bf4ee74d750b35ae2c10.png");if(e&&e.publicPath)try{return new URL("static/media/converter-intro.bf4ee74d750b35ae2c10.png",e.publicPath).href}catch{}try{return new URL("/static/media/converter-intro.bf4ee74d750b35ae2c10.png",typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"").href}catch{return"/static/media/converter-intro.bf4ee74d750b35ae2c10.png"}})(),vf={closable:!1},bf=yf,Ef=({open:e,onConfirm:t,onCancel:n,neverSuggestAgain:o,onNeverSuggestAgainChange:i})=>{const{__:s}=r.useI18n();return(0,a.jsx)(_.ui_kit$Modal,{className:"convert-layout-modal",title:(0,a.jsx)("div",{className:"convert-layout-modal__title",children:s("Template conversion")}),open:e,onOk:t,onCancel:n,mask:vf,width:480,footer:(0,a.jsxs)("div",{className:"convert-layout-modal__footer",style:{display:"flex",flexDirection:"column",gap:16},children:[(0,a.jsx)(_.ui_kit$Switch,{size:"small",checked:o,onChange:i,label:s("Don't suggest again"),labelSize:"small"}),(0,a.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[(0,a.jsx)(_.ui_kit$Button,{size:"large",onClick:n,children:s("Cancel")}),(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",onClick:t,children:s("Convert")})]})]}),children:(0,a.jsxs)("div",{className:"convert-layout-modal__content",style:{display:"flex",flexDirection:"column",alignItems:"center",gap:24,padding:"0 8px",overflow:"hidden"},children:[(0,a.jsx)("div",{className:"convert-layout-modal__text convert-layout-modal__intro-text",style:{textAlign:"center"},children:s("This layout was not created in our editor. Convert it to unlock full editing capabilities: easily change texts, replace images, and manage blocks.")}),(0,a.jsx)("img",{src:bf,alt:"Converter Intro",className:"convert-layout-modal__image",style:{display:"block",width:"100%",maxWidth:"100%",height:"auto",borderRadius:8}})]})})},Sf={closable:!1},wf=({open:e,message:t,onRetry:n,onCancel:o})=>{const{__:i}=r.useI18n();return(0,a.jsx)(_.ui_kit$Modal,{title:(0,a.jsx)("div",{className:"ant-modal-title",children:i("Conversion failed")}),open:e,onOk:n,onCancel:o,mask:Sf,footer:(0,a.jsxs)("div",{className:"convert-layout-modal__footer",children:[(0,a.jsx)(_.ui_kit$Button,{size:"large",onClick:o,children:i("Cancel")}),(0,a.jsx)(_.ui_kit$Button,{size:"large",type:"primary",onClick:n,children:i("Try again")})]}),children:(0,a.jsxs)("div",{className:"convert-layout-modal__text",children:[i("Something went wrong during layout conversion. You can try running the conversion again."),t?(0,a.jsx)("div",{className:"convert-layout-modal__error-details",children:t}):null]})})},kf=({open:e,progress:t})=>{const{__:n}=r.useI18n();return e?(0,a.jsx)("div",{className:"conversion-overlay",children:(0,a.jsxs)("div",{className:"conversion-overlay__content",children:[(0,a.jsx)(_.ui_kit$Spin,{size:"large"}),(0,a.jsx)("div",{className:"conversion-overlay__title",children:n("Converting layout…")}),(0,a.jsx)("div",{className:"conversion-overlay__hint",children:n("This may take several minutes. Please keep this tab open.")}),(0,a.jsx)(_.ui_kit$Progress,{className:"conversion-overlay__progress",percent:Math.round(t),status:"active",strokeColor:r.emCssVar("colorPrimary")})]})}):null},yr=r.createApi({reducerPath:"layoutConverterApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({createConvertJob:e.mutation({query:({html:t})=>({url:"/ai/converter/jobs",method:"POST",body:{html:t}})}),getConvertJobStatus:e.query({query:t=>({url:`/ai/converter/jobs/${t}`,method:"GET"})})})}),{useCreateConvertJobMutation:Tf,useLazyGetConvertJobStatusQuery:Cf}=yr;function If(){try{return window.localStorage.getItem(r.LOCAL_STORAGE_ITEMS.em_layout_convert_never_suggest)==="true"}catch{return!1}}function Af(e){try{e?window.localStorage.setItem(r.LOCAL_STORAGE_ITEMS.em_layout_convert_never_suggest,"true"):window.localStorage.removeItem(r.LOCAL_STORAGE_ITEMS.em_layout_convert_never_suggest)}catch{}}function xs(e){return e==="beefree"?(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/4c8d0155.js")).then(t=>t.convertBeeFreeToEmailMaker),void 0,{}.url):(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/60aa31a3.js")).then(t=>t.convertStripoToEmailMaker),void 0,{}.url)}var xf=5,Ps=95,Pf=35e3,Rf=1e3,Of=e=>new Promise(t=>setTimeout(t,e));function jf(e,t){if(e&&typeof e=="object"){const n=e,o=n.data;if(o&&typeof o=="object"){const i=o.error;if(typeof i=="object"&&i?.message)return i.message;if(typeof i=="string"&&i)return i;if(o.message)return o.message}if(typeof o=="string"&&o)return o;if(n.error)return n.error;if(n.message)return n.message}return t}function Lf(){const{__:e}=r.useI18n(),t=r.useContentReplacer(),n=r.useNotification(),o=vs(),{aiLayoutConverterEnabled:i,anyConverterEnabled:s}=o,c=r.useHeadless(),d=r.useEvent(g.events.ON_EMAIL_INIT_ID),u=r.useEvent(g.events.ON_LAYOUT_CONVERT_REQUEST_ID),[p]=Tf(),[f]=Cf(),[h,y]=(0,l.useState)(If),m=(0,l.useRef)(h),E=(0,l.useCallback)(se=>{m.current=se,y(se),Af(se)},[]),[T,w]=(0,l.useState)(!1),[S,I]=(0,l.useState)(!1),[x,K]=(0,l.useState)(0),[Z,M]=(0,l.useState)(!1),[j,A]=(0,l.useState)(""),O=(0,l.useRef)(""),z=(0,l.useRef)(null),B=(0,l.useRef)(null),U=(0,l.useRef)(!1),de=(0,l.useRef)({cancelled:!0}),me=(0,l.useRef)(null);(0,l.useEffect)(()=>{U.current=S},[S]);const q=(0,l.useCallback)(()=>{me.current!==null&&(clearInterval(me.current),me.current=null)},[]),ee=(0,l.useCallback)(()=>{q();const se=Date.now();me.current=setInterval(()=>{const ae=Date.now()-se,Ie=Ps*(1-Math.exp(-ae/Pf));K(Te=>Math.max(Te,Math.min(Ps,Ie)))},Rf)},[q]),Fe=(0,l.useCallback)(se=>{se&&(t(se,{undoable:!0}),B.current=se)},[t]),be=(0,l.useCallback)(async se=>{const ae={cancelled:!1};de.current=ae,M(!1);const Ie=z.current;if(Ie==="beefree"||Ie==="stripo"){try{const Te=await xs(Ie),Be=ae.cancelled?"":Te(se);if(Be&&!ae.cancelled){Fe(Be),n.success({message:r.isUseBlocksBuild()?e("Layout converted to Blocks format"):e("Layout converted to EmailMaker format"),placement:"bottomRight"});return}}catch{}if(!i){ae.cancelled||(A(e("Layout conversion failed")),M(!0));return}}if(i){I(!0),K(0),ee();try{const Te=await p({html:se}).unwrap();if(ae.cancelled)return;let Be=Te.retry_after>0?Te.retry_after:xf;for(;!ae.cancelled;){if(await Of(Be*1e3),ae.cancelled)return;const J=await f(Te.job_id).unwrap();if(ae.cancelled)return;if(J.retry_after&&J.retry_after>0&&(Be=J.retry_after),J.status==="completed"){q(),K(100),Fe(J.html??""),n.success({message:r.isUseBlocksBuild()?e("Layout converted to Blocks format"):e("Layout converted to EmailMaker format"),placement:"bottomRight"}),setTimeout(()=>{ae.cancelled||(I(!1),K(0))},400);return}if(J.status==="failed")throw new Error(J.error?.message||e("Layout conversion failed"))}}catch(Te){if(ae.cancelled)return;q(),I(!1),K(0),A(jf(Te,e("Layout conversion failed"))),M(!0)}}},[e,i,Fe,p,n,f,ee,q]),et=(0,l.useCallback)(()=>{w(!1);const se=O.current;se&&be(se)},[be]),Ee=(0,l.useCallback)(()=>{w(!1),B.current=O.current},[]),fe=(0,l.useCallback)(()=>{M(!1);const se=O.current;se&&be(se)},[be]),Q=(0,l.useCallback)(()=>{M(!1),B.current=O.current},[]),pe=(0,l.useCallback)((se,ae=!1)=>{const Ie=bs(se,o);if(s&&!c&&Ie&&!U.current){if(ae)B.current=null;else{if(m.current)return;if(B.current===se)return}O.current=se,z.current=Ie,Ie!=="ai"&&xs(Ie).catch(()=>{}),w(!0)}},[s,o,c]);return(0,l.useEffect)(()=>{if(!s)return;const se=new g.Disposable;return se.addDisposable(d(ae=>{ae?.reset||pe(ae?.html??"")})),()=>se.dispose()},[s,d,pe]),(0,l.useEffect)(()=>{if(!s)return;const se=new g.Disposable;return se.addDisposable(u(ae=>{pe(ae?.html??"",!0)})),()=>se.dispose()},[s,u,pe]),(0,l.useEffect)(()=>()=>{de.current.cancelled=!0,q()},[q]),{isPromptOpen:T,isConverting:S,progress:x,isErrorOpen:Z,errorMessage:j,confirmConversion:et,cancelPrompt:Ee,retryConversion:fe,closeError:Q,neverSuggestAgain:h,setNeverSuggestAgain:E}}var Mf=6e4,Rs=new Map;function Nf(e){const t=e?String(e):"",n=Rs.get(t);if(n&&(Rs.delete(t),!(Date.now()-n.at>Mf)))return n.promise}var go={data:void 0,isSuccess:!1,isError:!1,error:void 0,isLoading:!1};function Df(e){const t=r.useStore(),n=(0,l.useRef)(t);n.current=t;const[o,i]=(0,l.useState)(go),s=e?String(e):void 0;return(0,l.useEffect)(()=>{if(!s){i(go);return}let c=!1;return i({...go,isLoading:!0}),(Nf(s)??r.resolveEmailPort(g.getContainer(n.current)).readEmail(s)).then(d=>{c||i({data:d??void 0,isSuccess:!0,isError:!1,error:void 0,isLoading:!1})}).catch(d=>{c||i({data:void 0,isSuccess:!1,isError:!0,error:d,isLoading:!1})}),()=>{c=!0}},[s]),o}var sb=2;function Ff(){const e=r.useProjectData()?.id,t=!0,{data:n,isError:o,isFetching:i,refetch:s}=r.useGetProjectPlanQuery(e,{skip:t}),[c,d]=(0,l.useState)(0),u=(0,l.useRef)(!1),p=!!o,f=c>=2,h=(0,l.useCallback)(()=>{u.current=!1,d(0),s()},[s]);(0,l.useEffect)(()=>{},[p,i,s,c,t]),(0,l.useEffect)(()=>{},[p,e,f,t]);const y="ready";return(0,l.useMemo)(()=>({status:y,retry:h}),[y,h])}var ab=300,Bf=g.createIdentifier$1("prewarm.queue");function $f(e){const t=[];let n=!1,o=!1,i;const s=()=>{i&&(i.unwatch(),e.clearTimer(i.timer),i=void 0)},c=()=>{const p=t.shift();if(!p)return;o=!0;const f=()=>{o=!1,u()};p.start().then(f,f)},d=()=>{s(),e.idle(()=>{if(!(o||t.length===0)){if(e.activity.inFlight()>0){u();return}c()}})};function u(){if(!n||o||i||t.length===0)return;const p=()=>e.setTimer(d,300),f={timer:e.activity.inFlight()===0?p():void 0,unwatch:e.activity.watch(()=>{e.clearTimer(f.timer),f.timer=e.activity.inFlight()===0?p():void 0})};i=f}return e.whenVisible(()=>{n=!0,u()}),{add(p){t.some(f=>f.name===p.name)||(t.push(p),u())},remove(p){const f=t.findIndex(h=>h.name===p);f>=0&&t.splice(f,1),t.length===0&&s()}}}function Uf(e){return e.getOrCreateInstance(Bf,()=>$f({activity:g.getNetworkActivity(e),whenVisible:t=>Ht(e).whenVisible(t),idle:Xt,setTimer:(t,n)=>window.setTimeout(t,n),clearTimer:t=>window.clearTimeout(t)}))}function zf({projectId:e,project:t,emailProjectId:n,parentEmailId:o}){const i=r.useContainer(),s=r.useAppDispatch(),d=!!r.useCookieManager().get(r.APP_COOKIES.em_token);(0,l.useEffect)(()=>{const u=Uf(i),p=[],f=[],h=(m,E)=>{f.push(m),u.add({name:m,start:()=>{const T=E();return p.push(T),Promise.resolve(T)}})},y=r.parentEmailSource(o);return y&&h("blocks.parentEmail",()=>s(r.blocksApi.endpoints.getParentEmailBlocks.initiate(r.parentEmailBlocksArgs(y)))),h("blocks.template",()=>s(r.blocksApi.endpoints.getTemplateBlocks.initiate(r.templateBlocksArgs()))),e&&h("blocks.list",()=>s(r.blocksApi.endpoints.getBlocks.initiate(r.projectBlocksArgs(e)))),h("blocks.schema",()=>s(r.blocksApi.endpoints.getBlocksSchema.initiate(void 0))),t?.id&&h("blocks.tags",()=>s(r.taxonomiesApi.endpoints.getTerms.initiate({project:t,kind:r.BLOCK_TAGS}))),()=>{f.forEach(m=>u.remove(m)),p.forEach(m=>m.unsubscribe())}},[i,s,e,t,n,o,d])}var ho="AUTOSAVE_RECOVERY";function Gf(e,t,n=!1,o){const i=t?.get().serverId??void 0,{__:s}=r.useI18n(),c=r.useNotification(),d=r.useAppConfig(),u=r.useSelector(r.selectMonacoFocusing),p=r.useContainer(),f=p?.getInstance(Cs),h=(0,l.useRef)(0),y=r.useSelector(r.selectIsPanelHistoryCollapsed),m=r.useSelector(r.selectActiveSettingsTab),E=r.useDispatch(),T=(0,l.useSyncExternalStore)((0,l.useCallback)(j=>o?.subscribe(j)??(()=>{}),[o]),()=>o?.recoveryFacts()),w=d?.revisionService===!0,S=T?.isRecovering===!0,I=T?.applied,x=(0,l.useCallback)(()=>{E(r.markAppearanceNeedsUpdate());const j=e?.renderGuid,A=e?.preheader,O=e?.subject;j&&(A||O)&&f?.reassert({...A?{preheader:A}:{},...O?{subject:O}:{}})},[E,f,e?.preheader,e?.subject,e?.title,e?.common_styles,e?.renderGuid,t,o]);(0,l.useEffect)(()=>()=>{clearTimeout(h.current),o?.endForcedHeaders()},[i,o]),(0,l.useEffect)(()=>{w&&S&&c.info({key:ho,title:s("Loading latest changes..."),duration:0})},[w,S,c,s]);const K=(0,l.useRef)({emailId:void 0,seq:0});(0,l.useEffect)(()=>{if(!I||T?.emailId!==i||(K.current.emailId!==i&&(K.current={emailId:i,seq:0}),I.seq<=K.current.seq))return;K.current={emailId:i,seq:I.seq},x();const{phase:j}=I;!w||j==="normal"||(j==="found"?c.success({key:ho,title:s("Changes loaded"),duration:3}):j==="timeout"?c.warning({key:ho,title:s("Locally saved version applied"),description:s("Syncing with the server in the background..."),duration:5}):j==="bg"&&c.info({key:"AUTOSAVE_BG_SYNCED",title:s("Email synced with the server"),duration:3}))},[w,I,T?.emailId,i,x,c,s]),(0,l.useEffect)(()=>{if(!n)return;const j=A=>{A.preventDefault()};return window.addEventListener("beforeunload",j),()=>window.removeEventListener("beforeunload",j)},[n]);const Z=!y||u||m==="Discuss",M=p?r.provideAutosaveUiFacts(p):void 0;(0,l.useEffect)(()=>{M?.set({...M.get()??{isUserBusy:!1,saveContext:{}},isUserBusy:Z})},[M,Z])}var Wf=class extends Error{label;timeoutMs;constructor(e,t){super(`[${e}] timed out after ${t}ms`),this.name="OperationTimeoutError",this.label=e,this.timeoutMs=t}};function Hf(e,t,n){return t<=0?e:new Promise((o,i)=>{let s=!1,c;const d=u=>{s||(s=!0,c!==void 0&&(clearTimeout(c),c=void 0),u())};c=setTimeout(()=>{d(()=>i(new Wf(n,t)))},t),e.then(u=>{d(()=>o(u))},u=>{d(()=>i(u))})})}var qf=2,vr=Symbol("sandbox:frame-replaced");function an(e,t,n,o,i,s,c){const d=`sandbox:${t}`,u=s?.getSandboxTimeoutMs(t)??r.DEFAULT_SANDBOX_OP_TIMEOUT_MS[t],p=()=>{let E=Hf(e.sendAsync(n,o),u,d);return E=g.raceWithAbortSignal(E,s?.signal),r.logShowPipelineWait(d,E,i)};if(t==="INIT_START"&&Ki(e)){const E=s?.getSandboxReadyTimeoutMs()??2e4,T=e,w=S=>{const I=Yi(T,E,s?.signal);return r.logShowPipelineWait("sandbox:INIT_START:ready-wait",I,i).then(()=>{if(!c||S<=0)return p();const x=c.getGeneration();let K;const Z=new Promise((j,A)=>{K=c.onChange(()=>{c.getGeneration()!==x&&A(vr)})}),M=p();return M.catch(()=>{}),Promise.race([M,Z]).finally(()=>K?.()).catch(j=>{if(j!==vr)throw j;return{...i},w(S-1)})})};return w(qf)}if(!c)return p();const f=c.getGeneration();let h;const y=new Promise((E,T)=>{h=c.onChange(()=>{c.getGeneration()!==f&&T(vr)})}),m=p();return m.catch(()=>{}),Promise.race([m,y]).finally(()=>h?.()).catch(E=>{throw E===vr&&{...i},E})}function Os(e,t,n,o){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...o!==void 0?{rev:o}:{}}}var js="self-init:";function Vf(e){return e.startsWith(js)}function Ls(e,t){const n=e.getActiveShowRequest();return Vf(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function Kf(e){const t=()=>e.initPipeline(),n=e.messageService,o=()=>e.waitScope?.()??t();let i="";const s=()=>e.readDocument()?r.readDocumentContent(e.readDocument()):i,c=()=>on(e.container).editorPolicy,d=()=>e.readEmail(),u=()=>{const p=d();return{...p,id:e.isTemplate()||p.isNew?void 0:p.id,html:s()}};return{readContent:s,publicEmail:u,sendInitStart:()=>an(n,"INIT_START",r.EVENT_TYPES.SANDBOX_INIT_START,{guid:d().renderGuid},void 0,o()),sendInited:()=>an(n,"INITED",r.EVENT_TYPES.SANDBOX_INITED,{guid:d().renderGuid},void 0,o()),async sendContent(){const p=d(),{html:f,hasBrowserExtensionArtifacts:h}=r.prepareEmailHtmlForEditor(p?.html||"");h&&e.events.browserExtensionDetected(),r.loadDocumentContent(e.readDocument(),f),i=f,await an(n,"SET_ENTITY",r.EVENT_TYPES.SANDBOX_SET_ENTITY,Os(s(),p.renderGuid,c(),e.readDocument()?.get().version),{guid:p.renderGuid,emailId:p.id??null},o())},refreshContent:()=>an(n,"SET_ENTITY",r.EVENT_TYPES.SANDBOX_SET_ENTITY,Os(s(),d().renderGuid,c(),e.readDocument()?.get().version),void 0,o()),sendPreheader:async()=>{const p=d();if(p.preheader!==void 0)return an(n,"PREHEADER",r.EVENT_TYPES.SANDBOX_PREHEADER_UPDATE,{value:p.preheader,guid:p.renderGuid,force:!0},void 0,o())},sendSubject:async()=>{const p=d();if(p.subject!==void 0)return an(n,"SUBJECT",r.EVENT_TYPES.SANDBOX_SUBJECT_UPDATE,{value:p.subject,guid:p.renderGuid,force:!0},void 0,o())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:p=>e.showFilled?.(p),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(u()),fireInit(p,f){if(!Ls(t(),p)){t().getActiveShowRequest()?.showId;return}const h=d();h.id,h.renderGuid,t().completeShow(p),r.writeEmailAttributes(e.readDocument(),{is_inited:!0},{source:"system"});const y=u();return f&&(y.reset=!0),e.events.inited(y)},fireEmailChanged(){e.events.emailChanged(u())},fireContentChanged(){e.events.contentChanged(s())}}}function Yf(e){const t=()=>e.initPipeline();let n=!1,o,i,s,c=0,d;const u=Kf({...e,waitScope:()=>({getSandboxTimeoutMs:w=>t().getSandboxTimeoutMs(w),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:d?.signal??t().signal})});let p;const f=(w,S)=>{if(p===w)return;p=w;const I=c;setTimeout(()=>{c!==I||t().signal.aborted||E(w,S).catch(()=>{})},0)},h=()=>{d?.abort(),d=void 0};let y;const m=()=>{const w=t().signal;w!==y&&(y?.removeEventListener("abort",h),y=w,w.addEventListener("abort",h))};async function E(w,S){const I=++c;h(),d=new AbortController,m();const x=()=>c!==I,K=u.readTarget(),Z=t().generation,M=()=>Z===t().generation&&!t().signal.aborted,j=S?"init:reset-":"init:";if(!S){const z=u.publicEmail();z?.id,z?.renderGuid,z?.preheader}let A=!1,O=!1;try{n=!0,await u.sendInitStart(),u.fireWillInit(),await(S?u.refreshContent():u.sendContent()),A=!0,S||u.publicEmail()?.id;try{await u.sendPreheader()}catch(z){r.logShowPipelineError(`${j}preheader-failed`,{showId:w,error:String(z)})}try{await u.sendSubject()}catch(z){r.logShowPipelineError(`${j}subject-failed`,{showId:w,error:String(z)})}if(x()||u.showFilled(K),await u.sendInited(),O=!0,i===w){const z=e.readSandboxGeneration?.()??s;z!==void 0&&(o=z)}await u.revealFilled()}catch(z){throw x()||r.logShowPipelineError(`${j}failed`,{showId:w,contentApplied:A,sandboxInitedAcked:O,superseded:!1,...e.describeSurface?.(),error:String(z)}),!x()&&Ls(t(),w)&&t().failShow(w,z),z}finally{T(w,S,j,{superseded:x(),sessionGeneration:Z,contentApplied:A,sandboxInitedAcked:O,commit:M()})}}function T(w,S,I,x){const{superseded:K,contentApplied:Z,sandboxInitedAcked:M}=x;if(K){`${I}`;return}M&&x.commit?u.fireInit(w,S||void 0):M?r.logShowPipelineError(`${I}aborted (stale session or signal)`,{showId:w,sessionGeneration:x.sessionGeneration,currentGeneration:t().generation,aborted:t().signal.aborted}):Z?r.logShowPipelineError(`${I}aborted (sandbox INITED ack missing)`,{showId:w}):r.logShowPipelineError(`${I}aborted (content not applied)`,{showId:w}),n=!1,d=void 0,!M&&i===w&&(i=void 0,o===s&&(o=void 0)),!M&&Z&&f(w,S)}return{channel:u,isEventsLocked:()=>n,filledGeneration:()=>o,markFilled:w=>{o=w},lastCorrelation:()=>i,markCorrelation:w=>{i=w},bumpRunSeq:()=>{c+=1},noteSandboxGeneration:w=>{s=w},fill:w=>E(w,!1),refill:w=>E(w,!0),stop:()=>{c+=1,h(),n=!1,y?.removeEventListener("abort",h),y=void 0}}}function Qf(e,t,n){if(!e?.renderGuid||!e.showId||e.showId!==t.showId)return!1;if(t.isNew)return e.id==null;const o=t.emailId??t.navId;return o!=null&&String(e.id??"")!==String(o)?!1:Ms(e,n)}function Ms(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function Xf(e){const{pipeline:t,readEmail:n,readDocument:o,readRouteEmailId:i,readSandboxGeneration:s}=e,c=f=>{const h=n(),y=i();if(!Qf(h,f,y)){f.showId,f.navId,f.emailId,h?.id,h?.showId,h?.renderGuid;return}f.showId,h?.id,h?.renderGuid,t.markFilled(s()),t.markCorrelation(f.showId),t.fill(f.showId).catch(()=>{})};return{showRequested:f=>{c(f)},showRequestIdentityChanged:()=>{const f=e.initPipeline().getActiveShowRequest();f&&c(f)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const f=s();if(t.filledGeneration()===f)return;const h=n(),y=i();if(!h?.renderGuid||!Ms(h,y))return;const m=`${js}${h.renderGuid}`;t.markFilled(f),t.markCorrelation(m);const E=o()?.isReady()===!0;h.id,h.renderGuid,(E?T=>t.refill(T):T=>t.fill(T))(m).catch(()=>{t.lastCorrelation()===m&&t.markFilled(void 0)})},saasChanged:()=>{const f=n();f?.renderGuid,f?.showToken,f?.id}}}var Ns=g.createIdentifier$1("canvas.sandboxFill"),Jf=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}},Zf=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(g.createAbortError("Superseded by newer show()")),n.aborted?Promise.reject(g.createAbortError(n.reason)):(this._activeRequest=e,new Promise((o,i)=>{const s=setTimeout(()=>{this._settle(e.showId,()=>{i(new Jf(e.showId,t))})},t);s.unref?.();const c=()=>{this._settle(e.showId,()=>{i(g.createAbortError(n.reason))})};n.addEventListener("abort",c,{once:!0});const d=()=>{clearTimeout(s),n.removeEventListener("abort",c)};this._pending.set(e.showId,{request:e,resolve:o,reject:i,timeoutId:s,dispose:d});for(const u of this._listeners)u(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 eg(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function tg(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=r.resolveContentReadyTimeoutMs(e),n=r.resolveSandboxReadyTimeoutMs(e),o=r.resolveSequentialSandboxOpBudgetMs(e.sandbox);t<n+o}var ng=class{_controller=new AbortController;_externalSignalDisposable=new g.Disposable;_sessionChangeListeners=new Set;_showRegistry=new Zf;_timeouts;_generation=0;_sessionStarted=!1;get signal(){return this._controller.signal}get generation(){return this._generation}get contentReadyTimeoutMs(){return r.resolveContentReadyTimeoutMs(this._timeouts)}getSandboxTimeoutMs(e){return r.resolveSandboxOpTimeoutMs(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return r.resolveSandboxReadyTimeoutMs(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=eg(this._timeouts,e.timeouts),tg(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??g.createAbortError("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new g.Disposable}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new g.Disposable,this._showRegistry.rejectAll(g.createAbortError("Init session replaced")),this._controller.signal.aborted||this._controller.abort(g.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??g.createAbortError()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??g.createAbortError()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},rg=(()=>{const e=new ng;return e.configure({}),e})();function _o(){const e=r.useStore();return(0,l.useMemo)(()=>g.getContainer(e)?.getInstance(g.INIT_PIPELINE_ID)??rg,[e])}function og(e){const t=_o(),n=(0,l.useRef)(e);n.current=e,(0,l.useEffect)(()=>{let o;const i=()=>{o?.();const c=t.signal;if(c.aborted){n.current();return}const d=()=>n.current();c.addEventListener("abort",d),o=()=>c.removeEventListener("abort",d)};i();const s=t.onSessionReplaced(i);return()=>{s(),o?.()}},[t])}function ig(e){const t=_o(),n=(0,l.useRef)(e);n.current=e,(0,l.useEffect)(()=>t.onShowRequested(o=>n.current(o)),[t])}var sg=(e,t,n,o,i)=>{const s=r.useStore(),c=r.useMessageService(),d=_o(),u=(0,l.useRef)(d);u.current=d;const p=r.useEventEmitter(g.events.WILL_EMAIL_INIT_ID),f=r.useEventEmitter(g.events.ON_EMAIL_INIT_ID),h=r.useEventEmitter(g.events.ON_CONTENT_CHANGED_ID),y=r.useEventEmitter(g.events.ON_EMAIL_CHANGED_ID),m=r.useEventEmitter(g.events.ON_BROWSER_EXTENSION_DETECTED_ID),E=e?.id!==void 0,T=e?.showToken??0,w=T,S=(0,l.useRef)(w);S.current=w;const I=(0,l.useRef)(void 0);I.current=e;const[x,K]=(0,l.useState)(()=>r.getSandboxGeneration(c)),Z=(0,l.useRef)(x);Z.current=x,(0,l.useEffect)(()=>(K(r.getSandboxGeneration(c)),r.onSandboxGenerationChange(c,()=>{K(r.getSandboxGeneration(c))})),[c]);const M=(0,l.useRef)(o);M.current=o;const j=(0,l.useRef)(t);j.current=t;const A=i?.standalone?void 0:g.getContainer(s)?.getInstance(Ns),O=!A,z=(0,l.useRef)(A?.pipeline);z.current||(z.current=Yf({container:g.getContainer(s),messageService:c,initPipeline:()=>u.current,readDocument:()=>M.current,readEmail:()=>I.current,isTemplate:()=>!!j.current,readSandboxGeneration:()=>Z.current,events:{willInit:q=>p.fire(q),inited:q=>f.fire(q),contentChanged:q=>h.fire(q),emailChanged:q=>y.fire(q),browserExtensionDetected:()=>m.fire()}}));const B=z.current,U=(0,l.useRef)(n);U.current=n;const de=(0,l.useRef)(void 0);O&&!de.current&&(de.current=Xf({pipeline:B,initPipeline:()=>u.current,readEmail:()=>I.current,readDocument:()=>M.current,readRouteEmailId:()=>U.current,readSandboxGeneration:()=>Z.current}));const me=de.current;B.noteSandboxGeneration(Z.current),(0,l.useEffect)(()=>{if(O)return()=>z.current?.stop()},[O]),(0,l.useEffect)(()=>{A?.setRoute({emailId:n,isTemplate:t})},[A,n,t]),(0,l.useEffect)(()=>{const q=I.current;if(O&&!B.isEventsLocked()&&e?.renderGuid===q?.renderGuid&&q?.is_inited&&q){const ee=B.channel.readContent();y.fire({...q,id:t||q.isNew?void 0:q.id,html:ee})}},[B,e?.renderGuid,e?.preheader,e?.common_styles,e?.meta,e?.subject,e?.utm_parameters?.utm_campaign||"",e?.utm_parameters?.utm_content||"",e?.utm_parameters?.utm_medium||"",e?.utm_parameters?.utm_source||"",e?.utm_parameters?.utm_term||"",y,t,O]),(0,l.useEffect)(()=>{if(O){const q=r.subscribeToContent(o,()=>{const ee=I.current;if(!B.isEventsLocked()&&e?.renderGuid===ee?.renderGuid&&ee){const Fe=B.channel.readContent();h.fire(Fe),y.fire({...ee,id:t||ee.isNew?void 0:ee.id,html:Fe})}});return()=>q.dispose()}},[o,B,h,y,e,t,O]),og(()=>{O&&B.stop()}),ig(q=>{me?.showRequested(q)}),(0,l.useEffect)(()=>{me?.showRequestIdentityChanged()},[me,d,e?.renderGuid,e?.showId,e?.id,n]),(0,l.useEffect)(()=>{me?.selfInitChanged()},[me,d,e?.renderGuid,e?.showId,e?.id,n,o,x]),r.usePrevious(()=>{me?.saasChanged()},[e?.renderGuid,T,E,me]),Jr(async()=>{if(!O)return;const q=d.getActiveShowRequest()?.showId;q&&(B.markFilled(Z.current),await B.refill(q))},{async:!0})};function ag(e){const t=r.useEvent(g.events.ON_EMAIL_INIT_ID);(0,l.useEffect)(()=>{if(!e)return;const n=t(()=>e.clear());return()=>n.dispose()},[e,t])}function lg(e,t){const n=r.useEventEmitter(g.events.ON_DOCUMENT_SESSION_CHANGE);(0,l.useEffect)(()=>{n.fire({document:e,history:t})},[e,t,n])}function cg({templateEmailId:e,templateEmail:t,newEmail:n}){return e?t:n}function dg({routeEmailId:e,draft:t}){const n=r.useStore();(0,l.useRef)(0),(0,l.useEffect)(()=>{},[n,e,t])}function ug(e,t){return t}function pg(e){return!1}function mg({documents:e,push:t,projectId:n,subscription:o}){(0,l.useEffect)(()=>e.onSaved(i=>{i.intent==="publish"&&t({event:"save",action:"save_email",email_id:i.serverId??void 0,project_id:n,subscription:o})}),[e,t,n,o])}function fg(e){const t=r.useStore();(0,l.useEffect)(()=>{},[t,e])}function gg(e,t,n){const o=r.useAppNavigate(),i=r.useContainer();(0,l.useEffect)(()=>{},[o,e,t,n,i])}function hg(e){if(!e)return{status:"unknown"};if("status"in e){const t=e.data,n=t&&typeof t=="object"?t.message:void 0,o=typeof n=="string"?n:typeof t=="string"?t:void 0;return{status:String(e.status),message:o}}return{status:e.name??"unknown",message:e.message}}function Ds(e,t,n){const{status:o,message:i}=hg(n);r.reportMessage(`Failed to load ${e} ${t??"?"}: ${o}`,{origin:"entity-load-error",tags:{mechanism:"entity-load-error",entity_type:e,http_status:o},level:"error",contexts:{entity_load_error:{entityType:e,entityId:t,status:o,message:i,url:window.location.href}}})}var{Content:_g}=_.ui_kit$Layout,yg={paddingTop:"40px"},vg=()=>{const{__:e}=r.useI18n(),{owner:t,admin:n}=Qn(),o=r.useDispatch(),i=qr(),s=r.useAppNavigate(),{modal:c}=_.ui_kit$App.useApp(),d=r.useAppConfig(),u=r.useRootElement(),p=r.useCookieManager(),f=r.useMessageService(),{emailId:h,preview:y}=r.useRouteParams(),m=r.useEditorProjectId(),E=r.useAppSearchParams(),T=r.useSelector(r.selectIsCodeMode),w=r.useSelector(r.selectActiveModal),S=r.useCurrentUser(),I=r.useProjectData(),x=(0,l.useMemo)(()=>r.createNewEmailDraft(I?{id:Number(I.id),title:I.name}:void 0),[I]),K=r.useSelector(r.selectIsGlobalLoading),[Z]=r.useLazyGetMeQuery(),{isSuccess:M,data:j}=r.useGetSubscriptionsQuery(),A=Ff(),[O,z]=(0,l.useState)(!1),[B,U]=(0,l.useState)(!1),[de,me]=(0,l.useState)(),[q,ee]=(0,l.useState)(null),[Fe,be]=(0,l.useState)(!1),[et,Ee]=(0,l.useState)(!1),[fe,Q]=(0,l.useState)(!1),[pe,se]=(0,l.useState)(!1),[ae,Ie]=(0,l.useState)(!1),Te=(0,l.useRef)(),{confirm:Be}=c,{counters:J,subscription:_e}=S,Ce=J?.emails_counter;p.get(r.APP_COOKIES.em_template_email);const ge=E.get("template")||!B&&!h&&p.get(r.APP_COOKIES.em_new_email),{isSuccess:Oe,isLoading:ze,isError:k,error:C,data:P}=Df(h?void 0:ge),N=cg({templateEmailId:ge,templateEmail:P,newEmail:x});dg({routeEmailId:h,draft:N});const{document:D,email:v,error:W}=r.useOpenEmail(),Pe=v?.id!=null?String(v.id):void 0,Ae=ug(h,Pe);(0,l.useEffect)(()=>{},[h,Pe,D,ge]),gg(h,v?.id,m);const Qe=r.useStore(),Ge=r.getEmailDocuments(g.getContainer(Qe)),Ze=(0,l.useCallback)((ce,we)=>Ge.save(ce,we),[Ge]),pt=(0,l.useCallback)(()=>Ge.saveState(),[Ge]),bt=r.usePushToDataLayer();mg({documents:Ge,push:bt,projectId:m,subscription:_e?.post_title}),(0,l.useEffect)(()=>{!B&&v?.id&&U(!0)},[U,B,v?.id]);const ft=Ge.history();lg(D,ft),ag(ft),sg(v,pg(h),Ae,D);const lt=Xr({document:D,history:ft});Gf(v,D,Ge.saveState().saving,Ge),fg(m),(0,l.useEffect)(()=>{r.injectEmailRightsResolver(g.getContainer(Qe),ce=>!!(t||n||S.id?.toString()===ce?.author?.toString()))},[Qe,t,n,S.id]);const G=Yp({email:v,save:Ze,saveState:pt,documentSession:D}),{outdatedBlocks:Y,isOpen:ne,close:ue}=hf({projectId:m,document:D});zf({projectId:m,project:I,emailProjectId:v?.project,parentEmailId:v?.parent_email});const he=w===r.MODALS.ADD_NEW_EBLOCK_MODAL,We=kn(he),Ve=kn(fe),{isPromptOpen:st,isConverting:Bt,progress:Me,isErrorOpen:Xe,errorMessage:ie,confirmConversion:te,cancelPrompt:$,retryConversion:le,closeError:xe,neverSuggestAgain:Se,setNeverSuggestAgain:Ne}=Lf(),He=W??(ge?C:void 0),$e=!!He,ot=!v&&!$e,fn=!!v;(0,l.useEffect)(()=>{$e&&He&&Ds("email",h||ge,He)},[$e,He,h,ge]),(0,l.useEffect)(()=>{ge&&Oe&&(U(!0),E.set({}))},[ge,Oe,E]),(0,l.useEffect)(()=>(o(r.switchIsPanelHistoryCollapsed(!0)),()=>o(r.switchIsPanelHistoryCollapsed(!0))),[o]);const jt=(0,l.useCallback)(()=>{i.toggle(),o(r.resetPanes())},[o,i]);(0,l.useEffect)(()=>{y&&!T&&jt()},[T,y,jt]),(0,l.useEffect)(()=>{document.body.classList.add("editor"),o(r.setActiveSettingsTab(r.BUILD))},[o]),(0,l.useEffect)(()=>{!O&&Ce<3&&(Z(),z(!0))},[Z,Ce,O]);const ct=(0,l.useCallback)(()=>{lt.undo()},[lt]),Et=(0,l.useCallback)(()=>{lt.redo()},[lt]);(0,l.useEffect)(()=>{Te.current!==v?.id&&(lt.clear(),Te.current=v?.id)},[v,lt]);const Lt=(0,l.useCallback)(ce=>{(window.navigator.appVersion.indexOf("Mac")&&ce.metaKey||ce.ctrlKey)&&ce.code==="KeyZ"&&(ce.preventDefault(),ce.shiftKey?Et():ct())},[ct,Et]);(0,l.useEffect)(()=>()=>{o(r.resetPanes()),o(r.closeModal()),o(r.closeModal$1()),o(r.resetElementHistorySlice())},[o]);const On=(0,l.useCallback)(ce=>{const we=()=>{o(r.openModal(r.MODALS.ADD_NEW_EBLOCK_MODAL))},De=ce.data.operation,nt=ce.data,je=ce.data.action,Yt=u.querySelector("#iframe-scroll-top"),$t=u.querySelector("#iframe-scroll-bottom");if(De===r.EVENT_TYPES.APPLICATION_EBLOCK_ADD){const dt=nt.settings?.emBlockId;dt?ee({html:nt.data,emBlockId:String(dt)}):(me(nt.data),we())}if(De===r.EVENT_TYPES.APPLICATION_ACTION&&(je==="undo"?ct():je==="redo"&&Et()),De===r.EVENT_TYPES.APPLICATION_SCROLL_BLOCK_SHOW){const dt=u.querySelector("#email_iframe_slot"),Nn=document.body.getBoundingClientRect().height,Ut=dt.getClientRects()[0];Ut.top<0&&(Yt.style.display="block"),Ut.top+Ut.height>Nn&&($t.style.display="block")}De===r.EVENT_TYPES.APPLICATION_SCROLL_BLOCK_HIDE&&(Yt.style.display="none",$t.style.display="none")},[o,ct,Et,u]);r.useListenPostMessage(On);const jn=ce=>{if(ce.target?.closest?.(".file-manager, .ant-modal.file-manager"))return;const we=ce.dataTransfer,De=(we?Array.from(we.types||[]):[]).includes(r.DND_SOCIAL_LIST_REORDER_MIME),nt=typeof ce.composedPath=="function"?ce.composedPath():[];ce.target?.closest?.(".selected-social-form")||nt.some(je=>je&&je.nodeType===1&&typeof je.classList?.contains=="function"&&je.classList.contains("selected-social-form"))||De||(ce.preventDefault(),ce.target&&f.send({operation:r.EVENT_TYPES.SANDBOX_DRAG_CANCEL}),u.querySelectorAll(".em-dragging-element").forEach(je=>{je.classList.remove("em-dragging-element")}))},gn=(0,l.useRef)({});(0,l.useEffect)(()=>{const ce=new g.Disposable,we=De=>nt=>gn.current[De]?.(nt);return ce.addDisposable(r.addWindowListenerFromShadow(u,"drop",we("drop"))),ce.addDisposable(r.addWindowListenerFromShadow(u,"dragover",we("dragover"))),ce.addDisposable(r.addWindowListenerFromShadow(u,"dragstart",we("dragstart"))),ce.addDisposable(r.addWindowListenerFromShadow(u,"dragend",we("dragend"))),()=>{ce.dispose()}},[u]),(0,l.useEffect)(()=>(window.addEventListener("keydown",Lt),()=>{window.removeEventListener("keydown",Lt)}),[Lt]);const Ln=ce=>{if(ce.preventDefault(),ce.target?.closest?.(".file-manager, .ant-modal.file-manager"))return;const we=u.querySelector("#iframe-scroll-top"),De=u.querySelector("#iframe-scroll-bottom"),nt=d.sidePanelFloating?u.querySelector("#pane-content-wrapper"):u.querySelector(".email-pane__col_preview"),je=u.querySelector(".blocks-app").getBoundingClientRect().top,{height:Yt,top:$t}=u.querySelector("#email_iframe_slot").getBoundingClientRect(),dt=nt.getBoundingClientRect().height;$t>96?we.style.display==="block"&&(we.style.display="none"):(we.style.display==="none"||we.style.display==="")&&(we.style.display="block"),Yt-dt+$t-je<44?De.style.display==="block"&&(De.style.display="none"):De.style.display==="none"&&(De.style.display="block"),ce.target===we&&nt.scrollBy(0,-15),ce.target===De&&nt.scrollBy(0,15)},Mn=()=>{const ce=u.querySelector("#iframe-scroll-top"),we=u.querySelector("#iframe-scroll-bottom");ce&&we&&(ce.style.display="none",we.style.display="none"),u.querySelectorAll(".em-dragging-element").forEach(De=>{De.classList.remove("em-dragging-element")})},gt=ce=>{const we=ce.target,De=we instanceof Element?we:we.parentElement;if(!(De instanceof Element)||De.closest(".selected-social-form"))return;De.parentElement?.classList.add("em-dragging-element");const nt=!!De.closest(".blocks-search__result-wrapper");var je=nt?r.cloneBlockPreviewForDrag(De.querySelector(".blocks-search__result-html")):De.cloneNode(!0);je.classList.add("em-ghost-element"),je.style.height=nt?"auto":"70px",je.style.width=nt?"600px":"109px",je.style.position="absolute",je.style.top="0",je.style.left="0",je.style.zIndex="-1",De.appendChild(je),ce.dataTransfer.setDragImage(je,0,0),window.setTimeout(function(){je.parentNode.removeChild(je)},1e3)};gn.current={drop:jn,dragover:Ln,dragstart:gt,dragend:Mn};const St=(0,l.useCallback)(()=>{Be({title:e("You reached the plan limit"),icon:(0,a.jsx)(r.EmIcons,{icon:"ExclamationCircleOutlined",component:_.icons$ExclamationCircleOutlined}),content:(0,a.jsx)("div",{style:{maxWidth:"330px"},children:e("Switch to a different plan to save more emails.")}),centered:!0,okText:e("Choose a plan"),cancelText:e("Continue without saving"),width:"unset",onOk(){s("/billing")},onCancel(){}})},[s,e,Be]);return(0,l.useEffect)(()=>{if(M&&j){const ce=j?.find(we=>we.id?.toString()===_e?.ID?.toString())?.limits?.emails_limit;ce&&Ce>=ce&&!Fe&&!h&&t&&(St(),be(!0))}},[j,M,_e,Ce,Fe,St,h,t]),(0,l.useEffect)(()=>{const ce=f.onInit(()=>{f.send({operation:r.EVENT_TYPES.SANDBOX_LOCK_EDIT,data:!1})});return()=>ce.dispose()},[f]),(0,a.jsx)(r.DocumentSessionProvider,{document:D,history:ft,children:(0,a.jsx)(hs.Provider,{value:G,children:(0,a.jsxs)(_.ui_kit$Layout,{className:"email-page",children:[ot&&(0,a.jsx)(_.ui_kit$PageLoader,{}),!ot&&A.status==="pending"&&(0,a.jsx)(_.ui_kit$PageLoader,{}),A.status==="error"&&(0,a.jsx)(_g,{style:yg,children:(0,a.jsx)("div",{className:"container",children:(0,a.jsx)(_.ui_kit$Result,{status:"warning",title:e("Failed to load plan data"),subTitle:e("Editor features depend on your plan. Check your connection and try again."),extra:(0,a.jsx)(_.ui_kit$Button,{type:"primary",onClick:A.retry,children:e("Try again")})})})}),$e&&He&&!1,v&&!ot&&A.status==="ready"&&(0,a.jsxs)(_.ui_kit$Layout,{className:"email-pane",children:[K&&(0,a.jsx)("div",{className:"email-pane__loader",children:(0,a.jsx)(_.ui_kit$PageLoader,{small:!0})}),(0,a.jsx)(Is,{email:v,isCollaborationEditor:et}),(0,a.jsx)(Dp,{emailElement:v,isSuccess:fn,setIsCollaborationEditor:Ee,setIsShowAddAllBlocksModal:Q,triggerOpenSavedBlocksTab:pe})]}),We&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(Tu,{isModalVisible:he,htmlContent:de,projectId:m,setIsShowAddAllBlocksModal:Q,setIsShowAddAllBlocksModalForNewEmail:Ie,currentEmail:v})}),(0,a.jsx)(mf,{open:ne,blocks:Y,projectId:m,onClose:ue}),(0,a.jsx)(_f,{open:!!q,html:q?.html,emBlockId:q?.emBlockId,onSaveAsNew:()=>{me(q?.html),ee(null),o(r.openModal(r.MODALS.ADD_NEW_EBLOCK_MODAL))},onClose:()=>ee(null)}),Ve&&(0,a.jsx)(l.Suspense,{fallback:null,children:(0,a.jsx)(Cu,{isModalVisible:fe,currentEmail:v,setIsShowAddAllBlocksModal:Q,setTriggerOpenSavedBlocksTab:se,autoStart:!ae,projectId:m})}),(0,a.jsx)(Ef,{open:st,onConfirm:te,onCancel:$,neverSuggestAgain:Se,onNeverSuggestAgainChange:Ne}),(0,a.jsx)(kf,{open:Bt,progress:Me}),(0,a.jsx)(wf,{open:Xe,message:ie,onRetry:le,onCancel:xe})]})})})};function bg(){const e=r.useStore(),t=r.getEmailDocuments(g.getContainer(e)),n=(0,l.useCallback)(o=>t.subscribe(o),[t]);return(0,l.useSyncExternalStore)(n,()=>!!t.current())}function Eg(e,t){const n=r.useStore(),o=r.useAppConfig(),i=r.useStorageProvider();(0,l.useRef)(new Set),(0,l.useEffect)(()=>{},[e,t,o,n,i])}var Sg=30;function wg(e){const t=r.useContainer(),n=r.useGetProjectQuery(+e,{skip:!e,refetchOnMountOrArgChange:Sg}),{isSuccess:o,isError:i,error:s,data:c,isFetching:d}=n;Eg(e,o),(0,l.useEffect)(()=>{t&&r.setCurrentProjectRefreshing(t,d)},[t,d]),(0,l.useEffect)(()=>{t&&o&&c&&String(c.id)===String(e)&&r.setCurrentProjectCard(t,c)},[o,c,t,e]),(0,l.useEffect)(()=>{i&&s&&Ds("project",e,s)},[i,s,e]);const u=r.useProjectData(),p=!!u&&String(u.id)===String(e);return{...n,projectReady:p}}var An=r.createApi({reducerPath:"promoApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.emailmaker.ru/api/wp-json/promo/v1/"}),endpoints:e=>({checkPromo:e.mutation({queryFn:({code:t,type:n},o)=>r.clientFromApi(o).promo.set_code_create({code:t,type:n})}),getPromoInfo:e.query({queryFn({code:t},n){return r.clientFromApi(n).promo.get_code_info_list({code:t})}})})}),{useCheckPromoMutation:lb,useGetPromoInfoQuery:cb}=An;function kg(){const e=r.useContainer(),[t,n]=(0,l.useState)();return(0,l.useEffect)(()=>{if(!e)return;let o=!0;return r.getAppProject(e).then(i=>{o&&i!=null&&n(String(i))},()=>{}),()=>{o=!1}},[e]),t}var Tg=()=>{const e=r.useDispatch(),t=r.useCookieManager(),n=r.useCurrentUser(),o=r.useContainer();(0,l.useEffect)(()=>{const s=n?.code_editor;s&&o&&r.applyEditorOptions(o,s)},[n,o]),(0,l.useEffect)(()=>{const s=t.get(r.APP_COOKIES.em_token),c=t.get(r.APP_COOKIES.promocode);s&&c&&(e(An.endpoints.checkPromo.initiate({code:c,type:"by_link"})),t.remove(r.APP_COOKIES.promocode))},[e,t]),r.useNotifyCommand();const i=bg();return wg(kg()),i?(0,a.jsx)(Ql,{hasEmail:!0,children:(0,a.jsx)(l.Suspense,{fallback:(0,a.jsx)(_.ui_kit$PageLoader,{}),children:(0,a.jsx)(vg,{})})}):null};function Cg(e,t){const n=(0,l.useRef)(!1);(0,l.useEffect)(()=>{!e||n.current||(n.current=!0,r.mark(r.PHASES.appVisible),t&&Ht(t).noteShellVisible())},[e,t])}var xn=new WeakMap,Ig="data-useblocks-config-styles";function Ag(e){return typeof e=="string"?e.trim():""}function Fs(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function xg(e,t,n){if(!e||typeof document>"u")return null;const o=Ag(t),i=xn.get(e),s=n||e;if(!o)return i&&(i.remove(),xn.delete(e)),null;if(i)return i.textContent!==o&&(i.textContent=o),(i.parentNode!==s||i!==s.firstChild)&&Fs(s,i),i;const c=document.createElement("style");return c.setAttribute(Ig,"true"),c.textContent=o,Fs(s,c),xn.set(e,c),c}function yo(e){if(!e)return;const t=xn.get(e);t&&(t.remove(),xn.delete(e))}var Pg={height:"100%",display:"flex",justifyContent:"center",alignItems:"center"},Rg=({children:e,handleBeforeRender:t})=>{const[n,o]=(0,l.useState)(),i=r.useIsLocaleInited();Cg(i,r.useContainer());const s=r.useAppConfig().styles,c=(0,l.useRef)(null),d=(0,l.useRef)(!1),u=(0,l.useRef)(void 0),p=r.useRootElement();return(0,l.useLayoutEffect)(()=>{d.current||(d.current=!0,t&&t())},[]),(0,l.useLayoutEffect)(()=>{if(!p){u.current&&(yo(u.current),u.current=void 0);return}u.current&&u.current!==p&&yo(u.current),xg(p,s,c.current||void 0),u.current=p},[p,s]),(0,l.useLayoutEffect)(()=>()=>{u.current&&(yo(u.current),u.current=void 0)},[]),(0,a.jsxs)(_.ui_kit$StyleProvider,{container:r.findShadowRoot(p)||document.head,children:[(0,a.jsxs)("div",{ref:c,className:"App blocks-app blocks-plugin",style:i?{}:{visibility:"hidden"},children:[(0,a.jsx)(r.ModalRootContext.Provider,{value:n,children:e}),(0,a.jsx)("div",{ref:o,className:"blocks-modal-container"})]}),!i&&(0,a.jsx)(_.ui_kit$Space,{size:"large",style:Pg,children:(0,a.jsx)(_.ui_kit$Spin,{size:"large"})})]})};async function Og({container:e,renderTarget:t,mapKey:n,disposable:o,chunkLoadedFire:i}){const s=await e.getInstanceAsync(g.STORE_ID);return new Promise(c=>{if(o.isDisposed()){c();return}const d=(0,tl.createRoot)(t),u=(0,a.jsx)(r.Provider,{store:s,children:(0,a.jsx)(Wl,{onLoad:c,children:(0,a.jsx)(r.RootContext.Provider,{value:{element:n},children:(0,a.jsx)(_.ui_kit$StyleProvider,{container:r.isDocumentFragment(n)?document.head:n,children:(0,a.jsx)(r.LocaleProvider,{children:(0,a.jsx)(Rg,{handleBeforeRender:i,children:(0,a.jsx)(pl,{children:(0,a.jsx)(Gl,{children:(0,a.jsx)(Tg,{})})})})})})})})});d.render(u),o.addDispose(c),o.addDispose(()=>{try{d.unmount()}catch(p){if(p instanceof DOMException&&p.name==="NotFoundError"||p instanceof Error&&p.name==="NotFoundError"&&/removeChild/i.test(p.message)){r.logShowPipelineError("mount:unmount-dom-mismatch (host container was already removed)",{hint:"Usually harmless during host React StrictMode teardown. Ensure instance.destroy() runs before the host removes the mount container."});return}throw p}}),o.addDispose(()=>{g.ELEMENT_MAP.delete(n)})})}var db="multiple init call on single HTMLELEMENT",jg=zn(async e=>{let t=null,n=!1;const o=g.getEmitter(e,g.events.ON_CHUNKS_LOADED),i=e.getInstance(g.DISPOSABLE_ID);let s,c=!1;const d=()=>{c||(c=!0,r.mark(r.PHASES.chunksLoaded),o.fire())},u=ul();i.addDisposable(o.event(()=>u.loaded()));const p=(f,h)=>Og({container:e,renderTarget:f,mapKey:h,disposable:s,chunkLoadedFire:d});return{instance:{getElement(){return t}},async setOptions(f){u.use(f);const h=e.getInstance(g.INIT_PIPELINE_ID),y=await g.waitForElement(f.element,i,h.signal),m=e.getInstance(g.INSTANCE_ID),E=!!f.hidden&&!!y;if(t===y&&n===E)return;const T=t===y&&n&&!E;n=E,t&&g.ELEMENT_MAP.delete(t),y&&g.ELEMENT_MAP.has(y),s&&s.dispose(),s=i.addDisposable(new g.Disposable);const w=f.element!==void 0;if(r.setHeadlessMode(e,!y||E),r.setHiddenMount(e,E),!y){r.mark(r.MOUNT_HEADLESS_MARK);const I=document.createElement("div");I.style.position="absolute",I.style.left="-10000px",I.style.top="-10000px",I.style.width="1600px",I.style.height="1000px",document.body.appendChild(I),t=I,d(),s.addDispose(()=>{I.parentNode===document.body&&I.remove()});return}const S=r.findShadowRoot(y);if(S&&s.addDisposable(new dl({shadowRoot:S})),w&&y instanceof Element){const I=y;ol(I,()=>{i.isDisposed()||s?.isDisposed()||(r.logShowPipelineError("mount:detached (host removed element without destroy)",{elementId:I.id||null}),h.abort(rl()))},s)}if(E){r.mark(r.MOUNT_HEADLESS_MARK),t=y,d();return}if(w&&y instanceof Element){const I=y,x=ll(I);t=I;const K=p(x,I);return cl(I,x,s),K}return t=y,p(y,y)},dispose(){s&&!s.isDisposed()&&s.dispose()}}});function vo(e){return zn(async t=>(await t.getInstanceAsync(g.STORE_ID),await e(t)))}function Lg({html:e,renderGuid:t,...n},o){const{requested:i}=r.getCurrentProject(o);return r.filterUndefined({...n,code:on(o).toOutputForm(e),project:i===void 0?n.project:i,guid:void 0,link:void 0,status:void 0,slug:void 0,password:void 0,comment_status:void 0,template:void 0,blocktags:void 0,project_title:void 0,ping_status:void 0,lock:void 0,tag:void 0,is_template:void 0})}function Mg(e,t){return r.filterUndefined({...e,link:void 0,comment_status:void 0})}function Ng({html:e,...t},n){return r.filterUndefined({...t,code:e,guid:void 0,compiled:r.filterUndefined({html:e,ampHtml:e&&""})})}var Bs=e=>{const t={current:Promise.resolve(),state:e,decorate:(n,o)=>(o&&(n=n.bind(o)),function(...i){const s=t.current.then(()=>n(...i));return t.current=s.then(c=>{t.state=c},c=>{}),s})};return t},bo=g.createIdentifier$1("NotificationService"),Dg=g.createIdentifier$1("emailTemplate.reads");async function Fg(e,t){try{return await r.getRestEmailPortFactories(e).email(e).readEmail(t)??void 0}catch(n){r.logShowPipelineError("show:template-read-failed",{templateId:t,error:n instanceof Error?n.message:"неизвестная ошибка"}),Bg(e,t,n);return}}function Bg(e,t,n){e.getInstanceAsync(bo).then(()=>{g.getEmitter(e,g.events.ON_NOTIFICATION).fire({type:"error",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{})}function $g(e,t){const n=e.getOrCreateInstance(Dg,()=>new Map),o=n.get(t);if(o!==void 0)return o;const i=Fg(e,t).then(s=>(s===void 0&&n.delete(t),s));return n.set(t,i),i}var kt=class extends g.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 Tt(e,t,n){const o=g.snapshot(e);return(i,s,c)=>{const d=o(async u=>{const p=t?t(u):u;c&&i.bind(c);const f=await i(p);return n?n(f):f},s,c);return()=>d.dispose()}}var ub=g.createIdentifier("application_block_inserted"),pb=g.createIdentifier$1("DataController"),mb=g.createIdentifier$1("DataEvents"),Ug=g.createIdentifier$1("plugin.startupShow");function zg(e){return e.getInstance(Ug)?.current??Promise.resolve()}var $s=vo(async()=>({instance:{}})),Us=vo(async e=>({instance:{},async setOptions(){await zg(e)}})),fb=g.combineMixins([$s,Us]),zs=()=>({title:"",description:"",website:"",company_size:"",industry:"",email:"",phone:"",logo_url:""}),Gg={title:"title",description:"description",website:"website",company_size:"company_size",industry:"industry",email:"email",phone:"phone",logo_url:"logo"},Gs=e=>({...zs(),title:e?.title??"",description:e?.description??"",website:e?.website??"",company_size:e?.company_size??"",industry:e?.industry??"",email:e?.email??"",phone:e?.phone??"",logo_url:e?.logo??""}),Ws=e=>(e??[]).filter(t=>!!t?.code).map(({code:t,label:n})=>({value:t,label:n??t})),Wg=e=>({company_sizes:Ws(e?.company_sizes),industries:Ws(e?.industries)}),gb=Object.keys(zs()),Hs="ProjectProfile",Pn=r.createApi({reducerPath:"projectSettingsProfileApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),tagTypes:[Hs],endpoints:e=>({getProjectProfile:e.query({async queryFn(t,n){const o=r.v2ResultOf(await r.getClientV2(g.getContainer(n)).projects.profileList({id:String(t)}));return"error"in o?{error:o.error}:{data:Gs(o.data)}},providesTags:(t,n,o)=>[{type:Hs,id:String(o)}]}),getProjectProfileOptions:e.query({async queryFn(t,n){const o=r.v2ResultOf(await r.getClientV2(g.getContainer(n)).projects.profileOptionsList());return"error"in o?{error:o.error}:{data:Wg(o.data)}}}),updateProjectProfileField:e.mutation({async queryFn({projectId:t,field:n,value:o},i){const s={[Gg[n]]:o},c=r.v2ResultOf(await r.getClientV2(g.getContainer(i)).projects.profilePartialUpdate({id:String(t)},s));return"error"in c?{error:c.error}:{data:Gs(c.data)}},async onQueryStarted({projectId:t},{dispatch:n,queryFulfilled:o}){try{const{data:i}=await o;n(Pn.util.updateQueryData("getProjectProfile",t,()=>i))}catch{}}})})}),{useGetProjectProfileQuery:hb,useGetProjectProfileOptionsQuery:_b,useUpdateProjectProfileFieldMutation:yb}=Pn,qs="ProjectStorage",Rn=r.createApi({reducerPath:"projectSettingsStorageApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),tagTypes:[qs],endpoints:e=>({getProjectStorage:e.query({async queryFn(t,n){const o=r.v2ResultOf(await r.getClientV2(g.getContainer(n)).projects.storageList({id:String(t)}));return"error"in o?{error:o.error}:{data:o.data}},providesTags:(t,n,o)=>[{type:qs,id:String(o)}]}),updateProjectStorage:e.mutation({async queryFn({projectId:t,body:n},o){const i=r.v2ResultOf(await r.getClientV2(g.getContainer(o)).projects.storageUpdate({id:String(t)},n));return"error"in i?{error:i.error}:{data:i.data}},async onQueryStarted({projectId:t},{dispatch:n,queryFulfilled:o}){const{data:i}=await o;n(Rn.util.upsertQueryData("getProjectStorage",t,i))}}),testProjectStorageConnection:e.mutation({async queryFn({projectId:t,body:n},o){const i=r.v2ResultOf(await r.getClientV2(g.getContainer(o)).projects.storageTestCreate({id:String(t)},n));return"error"in i?{error:i.error}:{data:i.data}}})})}),{useGetProjectStorageQuery:vb,useUpdateProjectStorageMutation:bb,useTestProjectStorageConnectionMutation:Eb}=Rn,Hg=class{http;constructor(e){this.http=e}settings_summary_detail=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/settings-summary/${e}`,method:"GET",...n})},Vs=class{http;constructor(e){this.http=e}developer_credentials_detail=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/developer-credentials/${e}`,method:"GET",...n});developer_credentials_partial_update=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/developer-credentials/${e}`,method:"PATCH",...n});developer_credentials_rotate_secret_create=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/developer-credentials/${e}/rotate-secret`,method:"POST",...n});developer_credentials_verify_secret_create=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/developer-credentials/${e}/verify-secret`,method:"POST",...n})},qg=class{http;constructor(e){this.http=e}developer_kit_postman_collection_list=(e={})=>this.http.request({path:"/projects/v1/developer-kit/postman-collection",method:"GET",...e})},Vg=class{http;constructor(e){this.http=e}billing_context_detail=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/billing-context/${e}`,method:"GET",...n});billing_context_payments_list=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/billing-context/${e}/payments`,method:"GET",query:t,...n})},Kg=class{http;constructor(e){this.http=e}usage_detail=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/usage/${e}`,method:"GET",...n});usage_timeseries_list=({projectId:e,...t},n={})=>this.http.request({path:`/projects/v1/usage/${e}/timeseries`,method:"GET",query:t,...n})},Ye={PLUGIN_INIT:"plugin_init",LINK_CHECK:"link_check",IMAGE_CHECK:"image_check",SPAM_ASSASSIN:"spam_assassin",AI_IMAGE:"ai_image",AI_WRITE:"ai_write",AI_REPHRASE:"ai_rephrase"},Zt={TODAY:"today",WEEK:"week",MONTH:"month",CUSTOM:"custom"},Sb=[Ye.PLUGIN_INIT,Ye.LINK_CHECK,Ye.IMAGE_CHECK,Ye.SPAM_ASSASSIN,Ye.AI_IMAGE,Ye.AI_WRITE],ln={current:0,limit:null},Yg=()=>({pluginInit:{...ln},aiAssistant:{...ln},aiImage:{...ln},linkCheck:{...ln},imageCheck:{...ln},spamAssassin:{...ln}}),tt=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),Je=(e,t,n="")=>{for(const o of t){const i=e[o];if(typeof i=="string")return i;if(typeof i=="number"&&Number.isFinite(i))return String(i)}return n},Ft=(e,t,n=0)=>{for(const o of t){const i=e[o];if(typeof i=="number"&&Number.isFinite(i))return i;if(typeof i=="string"&&i.trim()&&Number.isFinite(Number(i)))return Number(i)}return n},Eo=(e,t,n=!1)=>{for(const o of t){const i=e[o];if(typeof i=="boolean")return i}return n},br=(e,t)=>{for(const n of t){const o=e[n];if(o===null)return null;if(typeof o=="number"&&Number.isFinite(o))return o;if(typeof o=="string"&&o.trim()&&Number.isFinite(Number(o)))return Number(o)}return null},Qg=new Set(Object.values(Ye)),Xg=e=>Qg.has(e)?e:null,en=e=>tt(e)&&"data"in e&&(e.ok===!0||typeof e.success=="boolean"||e.success===void 0)?e.data:e,cn=(e,t)=>{for(const n of t){const o=e[n];if(tt(o))return o}return null},Jg=(e,t)=>{for(const n of t){const o=e[n];if(!Array.isArray(o))continue;const i=o.filter(s=>typeof s=="string");if(i.length>0)return i}},Zg=e=>tt(e)?{clientId:Je(e,["clientId","client_id"]),clientSecretConfigured:Eo(e,["clientSecretConfigured","client_secret_configured"]),rotatedAt:Je(e,["rotatedAt","rotated_at"])||void 0,scopesSuggested:Jg(e,["scopesSuggested","scopes_suggested"])}:{clientId:"",clientSecretConfigured:!1},Ks=(e,t)=>{for(const n of t){const o=e[n];if(typeof o=="boolean")return o}},eh=e=>{const t=Ks(e,["pluginConnected","plugin_connected","connected","is_connected"]);if(t!==void 0)return t;for(const n of["plugin","developer_credentials","developerCredentials"]){const o=cn(e,[n]);if(!o)continue;const i=Ks(o,["connected","plugin_connected","is_connected"]);if(i!==void 0)return i;const s=Je(o,["clientId","client_id"]),c=Eo(o,["clientSecretConfigured","client_secret_configured"]);if(s)return c}},th=e=>{const t=en(e);if(!tt(t))return{};const n=cn(t,["members"]);return{myRole:Je(t,["myRole","my_role","role"])||(n?Je(n,["myRole","my_role","role"]):"")||void 0,pluginConnected:eh(t)}},nh=e=>tt(e)?{clientId:Je(e,["clientId","client_id"]),secret:Je(e,["secret","clientSecret","client_secret"])}:{clientId:"",secret:""},rh=e=>{if(!tt(e))return null;const t=Je(e,["event","type","key"]),n=Xg(t);if(!n)return null;const o=e.delta??e.change??e.trend,i=o==null?null:typeof o=="number"&&Number.isFinite(o)?o:Number.isFinite(Number(o))?Number(o):null;return{event:n,total:Ft(e,["total","count","value"],0),delta:i}},Ys=e=>{if(!tt(e))return null;const t=Je(e,["date","day","x"]);if(!t)return null;const n={date:t},o=e.event_counts??e.eventCounts;if(tt(o)){for(const[i,s]of Object.entries(o))typeof s=="number"&&Number.isFinite(s)&&(n[i]=s);return n}for(const[i,s]of Object.entries(e))i==="date"||i==="day"||i==="x"||i==="event_counts"||i==="eventCounts"||typeof s=="number"&&Number.isFinite(s)&&(n[i]=s);return n},oh=e=>{const t=en(e);return tt(t)?(Array.isArray(t.chart)?t.chart:Array.isArray(t.series)?t.series:Array.isArray(t.time_series)?t.time_series:Array.isArray(t.history)?t.history:[]).map(Ys).filter(n=>n!==null):[]},ih=e=>{if(!tt(e))return{current:0,limit:null};const t=Ft(e,["current","count","used","value","total"],0),n=br(e,["limit","max","quota","cap"]);return{current:t,limit:n===null?null:n}},dn=(e,t)=>{for(const n of t)if(n in e)return ih(e[n]);return{current:0,limit:null}},un={pluginInit:[Ye.PLUGIN_INIT,"plugin_init","pluginInit"],aiAssistant:["ai_assistant","aiAssistant","ai"],aiImage:[Ye.AI_IMAGE,"ai_image","ai_img","aiImg"],linkCheck:[Ye.LINK_CHECK,"link_check","linkCheck"],imageCheck:[Ye.IMAGE_CHECK,"image_check","imageCheck"],spamAssassin:[Ye.SPAM_ASSASSIN,"spam_assassin","spamAssassin","spam_check","spamCheck"]},So=e=>{const t=Yg(),n=en(e),o=tt(n)&&tt(n.usage)?n.usage:n;if(!tt(o))return t;const i=Ft(o,["operationsTotal","operations_total"],0),s=Ft(o,["operationsLast30d","operations_last_30d"],0),c=cn(o,["metrics","counters","limits","events","usage_by_event","usageByEvent"])??o;return{pluginInit:dn(c,un.pluginInit),aiAssistant:dn(c,un.aiAssistant),aiImage:dn(c,un.aiImage),linkCheck:dn(c,un.linkCheck),imageCheck:dn(c,un.imageCheck),spamAssassin:dn(c,un.spamAssassin),lastActivityAt:Je(o,["lastActivityAt","last_activity_at"])||void 0,operationsTotal:i>0?i:void 0,operationsLast30d:s>0?s:void 0}},Qs=(e,t)=>{const n=[{event:Ye.LINK_CHECK,total:e.linkCheck.current,delta:null},{event:Ye.IMAGE_CHECK,total:e.imageCheck.current,delta:null},{event:Ye.SPAM_ASSASSIN,total:e.spamAssassin.current,delta:null},{event:Ye.AI_IMAGE,total:e.aiImage.current,delta:null}],o=t?oh(t):[];return o.length>0?{cards:n,chart:o}:{cards:n,chart:[]}},sh=e=>{const t=en(e);if(!tt(t))return Qs(So(e),e);const n=Array.isArray(t.cards)?t.cards:Array.isArray(t.summary)?t.summary:[],o=Array.isArray(t.chart)?t.chart:Array.isArray(t.series)?t.series:[];return n.length>0||o.length>0?{cards:n.map(rh).filter(i=>i!==null),chart:o.map(Ys).filter(i=>i!==null)}:Qs(So(t),t)},ah=e=>{if(!tt(e))return null;const t=Je(e,["id","payment_id"]);return t?{id:t,date:Je(e,["date","created_at","paid_at"]),amount:Ft(e,["amount","sum"],0),currency:Je(e,["currency"],"RUB"),status:Je(e,["status"],"unknown"),receiptUrl:Je(e,["receiptUrl","receipt_url","pdf_url"])||void 0}:null},lh=e=>{const t=en(e),n=tt(t)&&Array.isArray(t.payments)?t.payments:[];return{payments:n.map(ah).filter(o=>o!==null),page:tt(t)?Ft(t,["page"],1):1,perPage:tt(t)?Ft(t,["perPage","per_page"],20):20,total:tt(t)?Ft(t,["total"],n.length):n.length,totalPages:tt(t)?Ft(t,["totalPages","total_pages"],1):1}},ch=e=>{const t=en(e);if(!tt(t))return{viewerSeesBilling:!1};const n=cn(t,["endpoints"])??{},o=cn(t,["documentLinks","document_links"]),i=o?Object.fromEntries(Object.entries(o).filter(f=>typeof f[1]=="string")):void 0,s=br(t,["ownerUserId","owner_user_id"]),c=cn(t,["tariff","plan","subscription"]),d=Je(t,["planDescription","plan_description"])||(c?Je(c,["description","about","plan_description"]):"")||void 0,u=br(t,["planPrice","plan_price","price","amount"])??(c?br(c,["price","amount"]):null),p=Je(t,["planCurrency","plan_currency","currency"])||(c?Je(c,["currency"]):"")||void 0;return{viewerSeesBilling:Eo(t,["viewerSeesBilling","viewer_sees_billing"]),ownerUserId:s??void 0,planName:Je(t,["planName","plan_name"])||void 0,planDescription:d,planPrice:u??void 0,planCurrency:p||void 0,endpoints:{limitsStats:Je(n,["limitsStats","limits_stats"])||void 0,subscriptionMe:Je(n,["subscriptionMe","subscription_me"])||void 0,payments:Je(n,["payments"])||void 0},documentLinks:i&&Object.keys(i).length>0?i:void 0}},dh={myRole:"owner"},uh=()=>({...dh}),ph={clientId:"rust-awkward-bear",clientSecretConfigured:{}.REACT_APP_PLUGIN_SETTINGS_MOCK_CONNECTED!=="false"},Xs=()=>({...ph,clientSecretConfigured:{}.REACT_APP_PLUGIN_SETTINGS_MOCK_CONNECTED!=="false"}),Js=Object.values(Ye),mh={[Ye.PLUGIN_INIT]:42,[Ye.LINK_CHECK]:-15,[Ye.IMAGE_CHECK]:28,[Ye.SPAM_ASSASSIN]:9,[Ye.AI_IMAGE]:6,[Ye.AI_WRITE]:-11,[Ye.AI_REPHRASE]:4},fh=(e,t)=>{const n={date:e};return Js.forEach((o,i)=>{const s=Math.sin(t*.65+i*.9),c=t*(i%2===0?.35:.2),d=2+i;n[o]=Math.max(0,Math.round(d+s*4+c))}),n},gh=e=>Js.map(t=>({event:t,total:e.reduce((n,o)=>n+(typeof o[t]=="number"?o[t]:0),0),delta:mh[t]})),hh=({period:e,dateFrom:t,dateTo:n})=>{const o=(0,En.default)().startOf("day");if(e===Zt.WEEK)return{startDate:o.subtract(6,"day"),days:7};if(e===Zt.MONTH)return{startDate:o.subtract(29,"day"),days:30};if(e===Zt.CUSTOM&&t&&n){const i=(0,En.default)(t),s=(0,En.default)(n);return{startDate:i,days:Math.max(1,s.diff(i,"day")+1)}}return{startDate:o,days:1}},wo=(e={period:Zt.TODAY})=>{const{startDate:t,days:n}=hh(e),o=Array.from({length:n},(i,s)=>fh(t.add(s,"day").format("YYYY-MM-DD"),s));return{cards:gh(o),chart:o}},wb=wo({period:Zt.WEEK}),_h={pluginInit:{current:0,limit:null},aiAssistant:{current:0,limit:null},aiImage:{current:42,limit:100},linkCheck:{current:128,limit:500},imageCheck:{current:64,limit:200},spamAssassin:{current:31,limit:150},lastActivityAt:"2026-05-02T12:00:00Z"},Zs={payments:[{id:"98765",date:"2026-05-12T10:15:00+00:00",amount:990,currency:"RUB",status:"success",receiptUrl:"https://receipts.example/98765.pdf"},{id:"98764",date:"2026-04-12T10:15:00+00:00",amount:990,currency:"RUB",status:"success"},{id:"98763",date:"2026-03-12T10:15:00+00:00",amount:990,currency:"RUB",status:"failed"}],page:1,perPage:20,total:3,totalPages:1},yh={viewerSeesBilling:!0,ownerUserId:1,planName:"Corporate",planDescription:"For fully addressing all necessary tasks in any field.",planPrice:3200,planCurrency:"RUB",endpoints:{limitsStats:"/wp-json/limits/v1/stats",subscriptionMe:"/wp-json/subscription/v2/me",payments:"/wp-json/projects/v1/billing-context/2581/payments"}},vh={info:{name:"EmailMaker Plugin Requests",schema:"https://schema.getpostman.com/json/collection/v2.1.0/collection.json"},item:[]},bh=e=>e,Eh=()=>!1,Sh=()=>!1,wh=e=>e,pn="ProjectPlugin",kh=()=>({}).REACT_APP_PLUGIN_SETTINGS_USE_MOCK==="true",Vt=(e,t,n)=>e.error&&kh()?{data:n(t)}:r.transformResponseFn(n)(e),Th=e=>bh(Zg(e)),Ch=e=>wh(ch(e)),Ih=({period:e,dateFrom:t,dateTo:n})=>{if(e===Zt.CUSTOM){const o={};return t&&(o.date_from=t),n&&(o.date_to=n),o}return{period:e??Zt.TODAY}},Er=r.createApi({reducerPath:"projectSettingsPluginApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api".replaceAll(/[\\/]$/g,"")}),tagTypes:[pn],endpoints:e=>({getPluginSummary:e.query({queryFn({projectId:t},n){return g.getApi(g.getContainer(n),[Hg]).settings_summary_detail({projectId:t}).then(o=>Vt(o,uh(),th))},providesTags:(t,n,{projectId:o})=>[{type:pn,id:o}]}),getPluginCredentials:e.query({queryFn({projectId:t},n){return g.getApi(g.getContainer(n),[Vs]).developer_credentials_detail({projectId:t}).then(o=>Vt(o,Xs(),Th))},providesTags:(t,n,{projectId:o})=>[{type:pn,id:`credentials-${o}`}]}),rotatePluginSecret:e.mutation({queryFn({projectId:t},n){return g.getApi(g.getContainer(n),[Vs]).developer_credentials_rotate_secret_create({projectId:t}).then(o=>Vt(o,{clientId:Xs().clientId,secret:"mock-rotated-secret"},nh))},invalidatesTags:(t,n,{projectId:o})=>[{type:pn,id:`credentials-${o}`}]}),getPostmanCollection:e.query({queryFn({projectId:t},n){return g.getApi(g.getContainer(n),[qg]).developer_kit_postman_collection_list({extraQuery:{project_id:String(t)}}).then(o=>Vt(o,vh,i=>en(i)??i))}}),getPluginAnalytics:e.query({queryFn({projectId:t,period:n,dateFrom:o,dateTo:i},s){const c={period:n,dateFrom:o,dateTo:i};return Eh()?Promise.resolve({data:wo(c)}):r.getClient(g.getContainer(s)).request({path:`/projects/v1/usage/${t}/timeseries`,method:"GET",query:Ih(c)}).then(d=>Vt(d,wo(c),sh))}}),getPluginBillingContext:e.query({queryFn({projectId:t},n){return g.getApi(g.getContainer(n),[Vg]).billing_context_detail({projectId:t}).then(o=>Vt(o,yh,Ch))},providesTags:(t,n,{projectId:o})=>[{type:pn,id:`billing-${o}`}]}),getPluginUsage:e.query({queryFn({projectId:t},n){return g.getApi(g.getContainer(n),[Kg]).usage_detail({projectId:t}).then(o=>Vt(o,_h,So))}}),getPluginPayments:e.query({queryFn({projectId:t,page:n=1,perPage:o=20},i){return Sh()?Promise.resolve({data:Zs}):r.getClient(g.getContainer(i)).request({path:`/projects/v1/billing-context/${t}/payments`,method:"GET",query:{page:String(n),per_page:String(o)}}).then(s=>Vt(s,Zs,lh))},providesTags:(t,n,{projectId:o})=>[{type:pn,id:`payments-${o}`}]})})}),{useGetPluginSummaryQuery:kb,useGetPluginCredentialsQuery:Tb,useRotatePluginSecretMutation:Cb,useLazyGetPostmanCollectionQuery:Ib,useGetPluginAnalyticsQuery:Ab,useGetPluginBillingContextQuery:xb,useGetPluginPaymentsQuery:Pb,useGetPluginUsageQuery:Rb}=Er,ea="EmailRaw",Sr=r.createApi({reducerPath:"emailRawApi",tagTypes:[ea],baseQuery:r.fetchBaseQuery({baseUrl:"https://app.useblocks.io/api/wp-json/wp/v2/"}),endpoints:e=>({getEmailRaw:e.query({queryFn:function({emailId:t,secret_hash:n},o){return g.getApi(g.getContainer(o),[g.WpEmailApi]).email_detail({id:t},{extraQuery:{secret_hash:n}}).then(r.transformResponseFn(r.WpEmailToEmail))},providesTags:(t,n,o)=>[{type:ea,id:o}]})})}),{useGetEmailRawQuery:Ob}=Sr,wr=r.createApi({reducerPath:"yandexAuthApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({validateYandexToken:e.mutation({query:t=>({url:"/auth/yandex",method:"POST",body:t})})})}),{useValidateYandexTokenMutation:jb}=wr,kr=r.createApi({reducerPath:"elamaAuthApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({validateElamaCode:e.mutation({query:t=>({url:"/auth/elama",method:"POST",body:t})})})}),{useValidateElamaCodeMutation:Lb}=kr,Tr=r.createApi({reducerPath:"googleAuthApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({validateGoogleToken:e.mutation({query:t=>({url:"/auth/google",method:"POST",body:t})})})}),{useValidateGoogleTokenMutation:Mb}=Tr,ta=async e=>{const t=await e.text();let n=t;try{n=JSON.parse(t)}catch{n=t}return n},Ah=(e,t,n)=>{if(!e)throw new Error(`Set ${n}`);return{url:`?proxy_url=${encodeURIComponent(e)}`,method:"POST",headers:{"Content-Type":"application/json"},body:t,responseHandler:ta}},xh=(e,t,n)=>{if(!e)throw new Error(`Set ${n}`);return{url:`?proxy_url=${encodeURIComponent(e)}`,method:"POST",body:t,responseHandler:ta}},Cr=r.createApi({reducerPath:"requestPlaneApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({getRequest:e.mutation({query:t=>xh("https://webhook.latenode.com/5868/prod/5c07527e-9d53-467a-a148-87220d46e9ae",t,"REACT_APP_PIPEDREAM_REQUEST_PLANE_SRC")}),getInvoiceRequest:e.mutation({query:t=>Ah("https://webhook.latenode.com/5868/prod/5c07527e-9d53-467a-a148-87220d46e9ae",t,"REACT_APP_REQUEST_PLANE_WEBHOOK_URL")})})}),{useGetRequestMutation:Nb,useGetInvoiceRequestMutation:Db}=Cr,Ir=r.createApi({reducerPath:"getCheckoutUrlApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({GetCheckoutUrl:e.mutation({query:t=>({url:`?proxy_url=${encodeURIComponent("https://webhook.latenode.com/5868/prod/5072387e-5ace-4ca7-9a25-2f952a7075af")}`,method:"POST",body:t})})})}),{useGetCheckoutUrlMutation:Fb}=Ir,ko=r.createApi({reducerPath:"recoverPasswordApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://app.useblocks.io/api/wp-json/bdpwr/v1/"}),endpoints:()=>({})}),Ar=r.createApi({reducerPath:"addUserToProjectApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/wp-json/user_to_project/v1/add_user"}),endpoints:e=>({addUserToProject:e.mutation({queryFn(t,n){return r.clientFromApi(n).userToProject.add_user_create(t,{type:g.ContentType.FormData})}})})}),{useAddUserToProjectMutation:Bb}=Ar,xr=r.createApi({reducerPath:"recurrenceSubscriptionsOffApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({getCanselRecurrence:e.query({query:t=>({url:`?proxy_url=${encodeURIComponent(`https://webhook.latenode.com/5868/prod/38815aec-cb5d-4b40-8dcb-75e7453573a0?subscription_id=${t.sid}&user_id=${t.uid}`)}`})})})}),{useLazyGetCanselRecurrenceQuery:$b,useGetCanselRecurrenceQuery:Ub}=xr,Pr=r.createApi({reducerPath:"recurrenceSubscriptionsOnApi",baseQuery:r.fetchBaseQuery({baseUrl:"https://px0.useblocks.io/"}),endpoints:e=>({getRecurrence:e.query({query:t=>({url:`?proxy_url=${encodeURIComponent(`https://webhook.latenode.com/5868/prod/7ac13d46-e4af-4dea-ab21-aab55415575b?subscription_id=${t.sid}&user_id=${t.uid}`)}`})})})}),{useLazyGetRecurrenceQuery:zb,useGetRecurrenceQuery:Gb}=Pr,Ph="https://app.useblocks.io/api/v2",Rr=r.createApi({reducerPath:"authApi",baseQuery:r.fetchBaseQueryApp({baseUrl:Ph,prepareHeaders:e=>{const t=r.api.get(r.APP_COOKIES.em_token);return t&&!e.has("authorization")&&e.set("authorization",`Bearer ${t}`),e}}),endpoints:e=>({login:e.mutation({query:t=>({url:"/auth/token",method:"POST",body:t})}),register:e.mutation({query:t=>({url:"/auth/register",method:"POST",body:t})}),refreshToken:e.mutation({query:t=>({url:"/auth/token/refresh",method:"POST",body:t})}),logout:e.mutation({query:()=>({url:"/auth/token",method:"DELETE"})}),getUser:e.query({query:()=>"/auth/user",transformResponse:t=>{const n=Array.isArray(t)?t[0]:t;return r.WpUserToUser(n)}}),changePassword:e.mutation({query:t=>({url:"/auth/password/change",method:"POST",body:t})}),resetPassword:e.mutation({query:t=>({url:"/auth/password/reset",method:"POST",body:t})}),resetPasswordConfirm:e.mutation({query:t=>({url:"/auth/password/reset/confirm",method:"POST",body:t})})})}),{useLoginMutation:Wb,useRegisterMutation:Hb,useRefreshTokenMutation:qb,useLogoutMutation:Vb,useGetUserQuery:Kb,useLazyGetUserQuery:Yb,useChangePasswordMutation:Qb,useResetPasswordMutation:Xb,useResetPasswordConfirmMutation:Jb}=Rr;function na(e){return{id:e.id??0,name:e.name??"",children:(e.children??[]).map(na)}}function Rh(e){return(e?.folders??[]).map(na)}function Oh(e){return{items:(e?.items??[]).flatMap(t=>t.id?[{kind:t.kind??"email",id:t.id,name:t.name??"",title:t.title??"",preheader:t.preheader??"",folderId:t.folder_id??0,hasAmp:t.has_amp??!1,previewImage:t.preview_image??"",updatedAt:t.updated_at??"",imported:t.imported??!1}]:[]),total:e?.total??0}}function To(e){const t=e.status??"pending";return{id:e.id??"",status:t,outcome:e.outcome,total:e.total??0,imported:e.imported??0,warnings:e.warnings??0,failed:e.failed??0,finished:t==="done"||t==="failed",items:(e.items??[]).map(n=>({kind:n.kind??"email",stripoId:n.stripo_id??0,name:n.name??"",status:n.status??"failed",reason:n.reason,emailId:n.email_id})),createdAt:e.created_at??"",finishedAt:e.finished_at}}function jh(e){return{selectors:e.map(t=>({kind:t.kind,...t.ids?.length?{ids:t.ids}:{},...t.all?{all:!0}:{},...t.folderId?{folder_id:t.folderId}:{},...t.rootOnly?{root_only:!0}:{},...t.search?{search:t.search}:{}}))}}var Co="StripoItems",Io="StripoFolders",Or="StripoImportJob",mn=(e,t)=>{const n=r.v2ResultOf(e);return"error"in n?{error:n.error}:{data:t(n.data)}},jr=r.createApi({reducerPath:"stripoImportApi",tagTypes:[Co,Io,Or],baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/v2"}),endpoints:e=>({saveStripoKey:e.mutation({async queryFn({projectId:t,apiKey:n},o){return mn(await r.getClientV2(g.getContainer(o)).projects.stripoKeyUpdate({id:String(t)},{api_key:n}),()=>{})},invalidatesTags:[Co,Io]}),getStripoFolders:e.query({async queryFn({projectId:t,kind:n},o){return mn(await r.getClientV2(g.getContainer(o)).projects.stripoFoldersList({id:String(t),kind:n}),Rh)},providesTags:[Io]}),getStripoItems:e.query({async queryFn({projectId:t,kind:n,folderId:o,rootOnly:i,search:s,page:c,limit:d},u){return mn(await r.getClientV2(g.getContainer(u)).projects.stripoItemsList({id:String(t),kind:n,...o?{folder_id:o}:{},...i?{root_only:!0}:{},...s?{search:s}:{},page:c,limit:d}),Oh)},providesTags:[Co]}),startStripoImport:e.mutation({async queryFn({projectId:t,selectors:n},o){return mn(await r.getClientV2(g.getContainer(o)).projects.stripoImportsCreate({id:String(t)},jh(n)),To)},invalidatesTags:[Or]}),getCurrentStripoImport:e.query({async queryFn(t,n){const o=await r.getClientV2(g.getContainer(n)).projects.stripoImportsCurrentList({id:String(t)});return o.status===204?{data:null}:mn(o,To)},providesTags:[Or]}),getStripoImport:e.query({async queryFn({projectId:t,jobId:n},o){return mn(await r.getClientV2(g.getContainer(o)).projects.stripoImportsDetail({id:String(t),jobId:n}),To)},providesTags:[Or]})})}),{useSaveStripoKeyMutation:Zb,useGetStripoFoldersQuery:e0,useGetStripoItemsQuery:t0,useLazyGetStripoItemsQuery:n0,useStartStripoImportMutation:r0,useGetCurrentStripoImportQuery:o0,useGetStripoImportQuery:i0}=jr,Lh=r.createState({activeGroupsTags:[],activeProjectGroupsTags:[],groupsTemplateTotal:null,groupsTemplateProjectTotalPages:null,groupsTemplateProjectTotal:null}),Mh="projectSlice",Ao=r.createSlice({name:Mh,initialState:Lh,reducers:{setActiveGroupsTags:(e,{payload:t})=>{e.activeGroupsTags=t,t.length&&(e.activeProjectGroupsTags=[])},setActiveProjectGroupsTags:(e,{payload:t})=>{e.activeProjectGroupsTags=t,t.length&&(e.activeGroupsTags=[])},resetAllTags:e=>{e.activeProjectGroupsTags=[],e.activeGroupsTags=[]}},extraReducers:e=>{e.addMatcher(r.emailsApi.endpoints.getTemplateEmails.matchFulfilled,(t,{payload:n,meta:o})=>{const{projectId:i}=o.arg.originalArgs;i?(t.groupsTemplateProjectTotal=+o.baseQueryMeta?.response.headers.get("X-WP-Total"),t.groupsTemplateProjectTotalPages=+o.baseQueryMeta?.response.headers.get("X-WP-TotalPages")):t.groupsTemplateTotal=+o.baseQueryMeta?.response.headers.get("X-WP-Total")})}}),{setActiveGroupsTags:s0,setActiveProjectGroupsTags:a0,resetAllTags:l0}=Ao.actions,Nh=r.createState({emailsTotal:0,elementsList:[],emailsTrashTotal:0,elementsTrashList:[],customFolders:{},elementsView:r.CARDS}),Dh="emailsPageSlice";function Fh(e){const t=e?.baseQueryMeta?.response;return Number(t?.headers?.get("X-WP-Total"))||0}function ra(e,t){const{emails:n,total:o,isSearch:i,page:s,tagOrFolderId:c}=t;if(t.status==="trash")!i&&o!==void 0&&(e.emailsTrashTotal=o),e.elementsTrashList=n;else if(c){const d=e.customFolders[c];e.customFolders={...e.customFolders,[c]:{list:n,page:s,total:o??d?.total??0}}}else o!==void 0&&(e.emailsTotal=o),e.elementsList=n}var xo=r.createSlice({name:Dh,initialState:Nh,reducers:{resetElementsList:e=>{e.elementsList=[]},syncElementsList:(e,{payload:t})=>{ra(e,t)},toggleElementsView:(e,t)=>{e.elementsView=t.payload},removeEmailFromList:(e,{payload:t})=>{const n=e.customFolders;t.folder!=="all"&&n[t.folder]?.list&&(n[t.folder]={...n[t.folder],list:n[t.folder].list.filter(o=>o.id!==t.emailId),total:n[t.folder].total-1},e.customFolders=n)}},extraReducers:e=>{e.addMatcher(r.emailsApi.endpoints.getEmails.matchFulfilled,(t,{meta:n,payload:o})=>{const i=n.arg.originalArgs;ra(t,{emails:o,total:Fh(n),status:i?.status,page:i?.page,isSearch:!!i?.name?.length,tagOrFolderId:i?.folderTag||i?.tags?.[0]})}),e.addMatcher(r.emailsApi.endpoints.getTemplateEmails.matchFulfilled,(t,{meta:n,payload:o})=>{const i=+n.baseQueryMeta?.response.headers.get("X-WP-Total")||0;t.elementsList=o,t.emailsTotal=i;const{projectGroup:s,projectId:c,tags:d}=n.arg.originalArgs;(s?.length&&c||d?.length||!d?.length&&!s?.length)&&(t.emailsTotal=i)}),e.addMatcher(r.emailsApi.endpoints.editEmail.matchFulfilled,(t,{payload:n})=>{t.elementsList.map(o=>o.id?.toString()===n.id?.toString()?Object.assign(o,{lock:n.lock,title:n.title,emailtags:n.emailtags}):o)})}}),{toggleElementsView:c0,resetElementsList:d0,syncElementsList:u0,removeEmailFromList:p0}=xo.actions,oa=r.combineReducers({[r.di.reducerPath]:r.di.reducer,[r.AiApi.reducerPath]:r.AiApi.reducer,[r.userSlice.name]:r.userSlice.reducer,[r.emailSlice.name]:r.emailSlice.reducer,[r.blockSlice.name]:r.blockSlice.reducer,[r.imageApi.reducerPath]:r.imageApi.reducer,[An.reducerPath]:An.reducer,[hr.reducerPath]:hr.reducer,[Ao.name]:Ao.reducer,[r.blocksApi.reducerPath]:r.blocksApi.reducer,[r.emailsApi.reducerPath]:r.emailsApi.reducer,[fr.reducerPath]:fr.reducer,[Xn.reducerPath]:Xn.reducer,[Jn.reducerPath]:Jn.reducer,[Zn.reducerPath]:Zn.reducer,[er.reducerPath]:er.reducer,[tr.reducerPath]:tr.reducer,[nr.reducerPath]:nr.reducer,[rr.reducerPath]:rr.reducer,[or.reducerPath]:or.reducer,[ir.reducerPath]:ir.reducer,[sr.reducerPath]:sr.reducer,[ar.reducerPath]:ar.reducer,[lr.reducerPath]:lr.reducer,[cr.reducerPath]:cr.reducer,[dr.reducerPath]:dr.reducer,[ur.reducerPath]:ur.reducer,[pr.reducerPath]:pr.reducer,[r.emailPageSlice.name]:r.emailPageSlice.reducer,[r.projectsApi.reducerPath]:r.projectsApi.reducer,[Pn.reducerPath]:Pn.reducer,[Qt.reducerPath]:Qt.reducer,[Rn.reducerPath]:Rn.reducer,[Er.reducerPath]:Er.reducer,[r.saveFileApi.reducerPath]:r.saveFileApi.reducer,[Sr.reducerPath]:Sr.reducer,[r.commentsApi.reducerPath]:r.commentsApi.reducer,[r.optimiseApi.reducerPath]:r.optimiseApi.reducer,[oo.name]:oo.reducer,[xo.name]:xo.reducer,[mr.reducerPath]:mr.reducer,[Tr.reducerPath]:Tr.reducer,[wr.reducerPath]:wr.reducer,[kr.reducerPath]:kr.reducer,[r.taxonomiesApi.reducerPath]:r.taxonomiesApi.reducer,[r.projectsPageSlice.name]:r.projectsPageSlice.reducer,[r.AiApiGenerator.reducerPath]:r.AiApiGenerator.reducer,[Cr.reducerPath]:Cr.reducer,[gr.reducerPath]:gr.reducer,[yr.reducerPath]:yr.reducer,[Gn.reducerPath]:Gn.reducer,[r.authorizationApi.reducerPath]:r.authorizationApi.reducer,[r.limitsApi.reducerPath]:r.limitsApi.reducer,[r.revisionHistorySlice.name]:r.revisionHistorySlice.reducer,[Ir.reducerPath]:Ir.reducer,[r.defaultModePanesSlice.name]:r.defaultModePanesSlice.reducer,[ko.reducerPath]:ko.reducer,[Ar.reducerPath]:Ar.reducer,[_r.reducerPath]:_r.reducer,[Pr.reducerPath]:Pr.reducer,[xr.reducerPath]:xr.reducer,[Rr.reducerPath]:Rr.reducer,[r.projectSettingsV2Api.reducerPath]:r.projectSettingsV2Api.reducer,[jr.reducerPath]:jr.reducer}),Bh=(e,t)=>t.type==="authorizationApi/resetApiState"?oa({[r.reducerPath]:e[r.reducerPath]},t):oa(e,t),ia=[r.AiApi,r.imageApi,hr,r.emailsApi,An,r.blocksApi,fr,Xn,Jn,Zn,er,tr,nr,rr,or,ir,sr,ar,lr,cr,dr,ur,pr,Sr,r.projectsApi,Pn,Qt,Rn,Er,r.commentsApi,r.optimiseApi,r.saveFileApi,mr,Tr,r.taxonomiesApi,wr,kr,r.AiApiGenerator,Cr,r.authorizationApi,r.limitsApi,gr,yr,Gn,Ir,ko,Rr,r.projectSettingsV2Api,jr,Ar,_r,Pr,xr];function $h(e){let t={};if(e){const o=g.createIdentifier$1();g.DependencyResolver.inject(o,e),t={INJECTION:o}}const n=r.configureStore({reducer:Bh,middleware:o=>o({serializableCheck:!1}).concat(ia.map(i=>i.middleware)),preloadedState:t});return r.setupListeners(n.dispatch),n}var sa=g.createIdentifier$1("RtkApiRegistry");function Uh(e,t){e.inject(sa,new Map(t.map(n=>[n.reducerPath,n])))}function at(e,t){const n=e?.getInstance(sa)?.get(t);if(!n)throw new Error(`RTK api "${t}" is not in the container registry (provideRtkApiRegistry did not run)`);return n}function zh(e,t){let n={isCodeMode:void 0,direction:void 0};return r.provideCodeMode(e).watch(o=>{n.isCodeMode!==o.isCodeMode&&t.dispatch(r.setCodeMode(o.isCodeMode)),n.direction!==o.direction&&t.dispatch(r.switchCodeModeDirection(o.direction)),n={isCodeMode:o.isCodeMode,direction:o.direction}})}function Gh(e,t){const n=r.provideCurrentUser(e),o=r.authorizationApi.endpoints.getMe.select("");let i=n.get()?.profile;const s=()=>{const c=o(t.getState()).data;!c||c===i||(i=c,n.set({profile:c}))};return s(),{dispose:t.subscribe(s)}}var Wh=g.createIdentifier$1("EmailSettingsPort");function Hh(e,t){e.inject(Wh,{read:()=>r.selectEmailSettings(t.getState())??{},write:n=>{t.dispatch(r.setEmailSettings(n))},markAppearanceChanged:()=>{t.dispatch(r.markAppearanceNeedsUpdate())}})}var qh="Invalid standaloneKey.",Vh="not implemented",m0=1,Kh=g.createIdentifier$1("StandaloneMockGuard");function Po(){const e=new Error(qh);return e.name="InvalidStandaloneKeyError",e}function Ro(e){return r.isStandaloneRuntime(g.getContainer(e))}function Yh(e){return e instanceof Error?e.name==="InvalidStandaloneKeyError"||e.message==="Invalid standaloneKey."||e.message==="not implemented":e===Vh}function aa(e){if(Ro(e))throw Po()}function Qh(e,t,n){return n instanceof Error&&n.name==="InvalidStandaloneKeyError"?n:Po()}var Xh=()=>()=>{throw Po()};function Jh(e){if(!e)throw new Error("DI container not found for standalone mock guard");e.inject(Kh,1)}function Zh(e){return typeof e!="function"}var f0="[plugin-api-mock]";function la(){return!0}function e_(e){try{if(e===null||typeof e!="object")return e;const t={};for(const n of Object.keys(e).slice(0,12)){const o=e[n];t[n]=typeof o=="string"&&o.length>120?`${o.slice(0,120)}…(${o.length})`:o}return t}catch{return"(unserializable arg)"}}function t_(e,t){return n=>{const o=n.query,i=n.queryFn||((s,c,d,u)=>{if(!o)throw new Error("query not found EndpointDefinition");return u(o(s))});i&&(n.query=void 0,n.queryFn=async(s,c,d,u)=>{try{let p;const f=g.getContainer(c).getServices(e);for(let h=f.length-1;h>=0;h--){const y=f[h];if(p=p?await p(async m=>await y.execute(m),c):await y.execute(s),Zh(p))return{data:p,error:null}}if(p)p=await p(async(h,y=c,m=d,E=u)=>{aa(c);const T=await i(h,y,m,E);if(T.error)throw T.error;return T.data},c);else{aa(c),la();const h=await i(s,c,d,u);if(h.error)throw h.error;p=h.data}return{data:p,error:null}}catch(p){return Ro(c)&&Yh(p)?{error:Qh(t,e_(s),p)}:(la(),{error:p})}})}}var ca=new Set;function it(e){return(t,n)=>{const o=Object.create(null),i=Object.keys(n),s=new g.Disposable;for(const c of i){const d=`api_listeners_flag_${t.reducerPath}/${c.toString()}`,u=g.createIdentifier$1(`api_listeners_${t.reducerPath}/${c.toString()}`);ca.has(d)||(o[c]=t_(u,`${t.reducerPath}/${c.toString()}`),ca.add(d)),s.addDisposable(e.addService(u,{execute:n[c]}))}return Object.keys(o).length&&t.enhanceEndpoints({endpoints:o}),r.getDisposable(e).addDisposable(s),s}}function da(e,t){for(const n of Object.keys(t))try{t[n](e)}catch{}}function g0(e){return e}function ua(e,t){return e({body:t}).catch(()=>new Promise(n=>setTimeout(n,1e3)))}function n_(e){it(e)(at(e,"AiApi"),{sendMessage:({body:t})=>async(n,o)=>{const i=r.getEmitter(e,g.events.AI_TEXT_REQUEST_ID);if(!i.hasListeners())return ua(n,t);const s=t,c={message:s.message??s.context,locale:s.locale,entityId:s.entity_id,projectId:s.project_id!=null?String(s.project_id):void 0,subject:s.subject,preheader:s.preheader,textContent:s.textContent,context:s.context??s.connection,connection:s.connection,onProgress:(d,u)=>{r.getEmitter(e,g.events.AI_TEXT_PROGRESS_ID).fire({progress:Number.isFinite(d)?d:0,status:typeof u=="string"?u:void 0})},onStreamChunk:d=>{typeof d!="string"||!d||r.getEmitter(e,g.events.AI_TEXT_STREAM_ID).fire({partialHtml:d})},signal:o.signal};for(const d of i.getListeners([c])){const u=await d(c);if(u)return{status:200,_eventResult:!0,aiMessage:typeof u.message=="string"?u.message:"",aiHtml:typeof u.html=="string"?u.html:void 0}}return ua(n,t)},getDialog:t=>(n,o)=>Ro(o)?Promise.resolve({documents:[],totalCount:0}):n(t)})}function r_(e){const t=it(e),n=r.getEmitter(e,g.events.FILE_PROXY_EVENT_ID);t(at(e,"proxyApi"),{async getFile({url:o,tryFetch:i=!0,type:s}){return async c=>{const{requested:d}=r.getCurrentProject(e),u=(await n.fire({url:o,project:d})).filter(p=>p instanceof Blob)[0];if(u)switch(s){case"json":return JSON.parse(await u.text());case"text":return u.text();default:return u}else return c({url:o,tryFetch:i,type:s})}}})}function o_(e){it(e)(at(e,"tokenApi"),{tokenCreate(t){return n=>n(t)},tokenValidate(){return t=>t({})}})}function h0(e){return e}function i_(e){it(e)(at(e,"imageApi"),{sendAiImageRequest:function({body:t}){return async(n,o)=>{const i=r.getEmitter(e,g.events.AI_IMAGE_REQUEST_ID);if(!i.hasListeners()||t.request!=="create-image")return n({body:t});const s={prompt:t.message??"",size:t.size,entityId:t.entity_id,projectId:t.project_id!=null?String(t.project_id):void 0,onProgress:(c,d)=>{r.getEmitter(e,g.events.AI_IMAGE_PROGRESS_ID).fire({progress:Number.isFinite(c)?c:0,status:typeof d=="string"?d:void 0})},signal:o.signal};for(const c of i.getListeners([s])){const d=await c(s);if(d&&d.images?.length)return{data:{status:200,_eventResult:!0,task:{images:d.images}}}}return n({body:t})}},getAiImage(t){return n=>n(t)}})}async function pa(e,t,n,o,i){try{const s=(await e.fire({project:String(t),emailId:n})).filter(c=>c!=null);if(s.length)return s.flat()}catch{}return o(i)}function s_(e){const t=it(e),n=at(e,"blocksApi"),o=r.blocksDataSourceProvider(e),i=o.byForeignKey("project"),s=r.blockRevisionsDataSourceProvider(e);s.byForeignKey("parent");const{dispatch:c}=r.getStore(e),d=r.getDisposable(e);d.addDisposable(o.onChange(()=>c(n.util.invalidateTags(["Blocks"])))),d.addDisposable(o.onSave(({prev:f,patch:h,value:y})=>{const m=f?{...f,...h}:h;let E=r.mergeEntityPreservingMeta(f,h,y);return m&&E.html===m.html&&E.title===m.title&&(E={...E,renderGuid:m.renderGuid}),E},Number.MIN_VALUE));const u=r.getEmitter(e,r.READ_COMMON_BLOCKS_EVENT_ID),p=r.getEmitter(e,r.READ_TEMPLATE_BLOCKS_EVENT_ID);t(n,{async getBlocks(f){const h={};f.name&&(h.title=f.name),f.type&&(h.type=f.type);const y=f.projectId??await r.getBlocksProject(e);return await i.get(y,{filter:h,page:f.page,pageSize:f.pageSize,order:f.order,orderBy:f.orderby}).then(({data:m})=>m)},getBlocksSchema(){return f=>f(void 0)},getParentEmailBlocks(f){return async h=>{const y=r.getCurrentProject(e).requested||"";return pa(p,y,f.emailId||"",h,f)}},getTemplateBlocks(f){return async h=>{const y=r.getCurrentProject(e).requested||"";return pa(u,y,f.emailId||"",h,f)}},async getBlock(f){const h=r.getCurrentProject(e).card?.id;if(h!==void 0)return i.first(Number(h),{filter:{id:f}})},addBlock(f){return async h=>{const y=await o.create(f);return r.getAppConfig(e).preventSendDataToEM||h(y).catch(m=>{}),y}},editBlock({blockId:f,...h}){return o.update(f,h)},deleteBlock(f){return o.remove(typeof f=="object"?f.id:f)},addTag(f){return f},getDeletableTag([f,h]){return[]},autoSaveBlock({blockId:f,body:h}){return s.create({...h,parent:f})}})}function a_(e){const{emails:t,emailRevisions:n}=r.provideEmailDocuments(e),{dispatch:o}=r.getStore(e),i=r.getDisposable(e),s=it(e),c=at(e,"emailsApi");i.addDisposable(t.onChange(async()=>{o(c.util.invalidateTags(["Email"]))})),s(c,{getEmails:d=>[],getTemplateEmails:d=>[],async addEmail({source:d,...u}){const p=await t.create(u,{source:d});return p.renderGuid||(p.renderGuid=g.generateUUID()),p},editEmail(d){return async u=>{const{emailId:p,source:f,...h}=d;return r.isRevisionServiceEnabled(e)&&await u(d),t.update(p,h,{source:f})}},deleteEmail(d){return t.remove(typeof d=="object"?d.id:d)},addTag(){throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},getDeletableTag([d,u]){return[]},autoSaveEmail({emailId:d,body:u}){return async p=>{r.isRevisionServiceEnabled(e)&&await p({emailId:d,body:u});const f=await n.create({...u,parent:d,modified:new Date().toString()});return f&&!f.html&&u.html?{...f,html:u.html}:f}}})}var l_="tmp",_0=g.createIdentifier$1();function c_(e){const t=it(e);if(!e.getInstance(g.DISPOSABLE_ID))throw new Error("Something was wrong");const n=r.getEmitter(e,g.events.UPLOAD_EVENT_ID),o=r.getEmitter(e,g.events.ON_SEND_TESTEMAIL_ID),i=r.getEmitter(e,g.events.ON_SEND_LIVEPREVIEW_ID);t(at(e,"saveFileApi"),{uploadImage(s){return async c=>{const{requested:d}=r.getCurrentProject(e),u=async()=>c({...s,user_id:String((await e.getInstanceAsync(g.APP_ID)).app_id)});if(s.folder===l_)return u();const p=await r.fireUploadImageEvent(n,{file:s.file,project:d});if(p.url)return[{file_url:p.url,project:d}];if(!r.shouldFallbackToBuiltInUpload(p,{isStandalone:r.isStandaloneRuntime(e)}))throw r.toUploadImageError(p);return u()}},sendTestEmail(s){return async c=>{const{requested:d}=r.getCurrentProject(e);(await o.fire({project:d,email_id:s.email_id,subject:s.subject,email:s.email,html:s.html,from_name:s.from_name})).some(u=>u===!1)&&await c({...s,user_id:String((await e.getInstanceAsync(g.APP_ID)).app_id)})}},async sendLivePreview(s){const{requested:c}=r.getCurrentProject(e);(await i.fire({project:c,id:s.email,subject:s.subject,html:s.content})).some(d=>d===!1)},sendShortLink(s){return c=>c(s)}})}function d_(e){it(e)(at(e,"emailRawApi"),{getEmailRaw({emailId:t,secret_hash:n}){throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)}})}function Kt(e,t){for(var n=e<0?"-":"",o=Math.abs(e).toString();o.length<t;)o="0"+o;return n+o}function u_(e,t){var n,o;r.requiredArgs(1,arguments);var i=Ll(e);if(isNaN(i.getTime()))throw new RangeError("Invalid time value");var s=String((n=t?.format)!==null&&n!==void 0?n:"extended"),c=String((o=t?.representation)!==null&&o!==void 0?o:"complete");if(s!=="extended"&&s!=="basic")throw new RangeError("format must be 'extended' or 'basic'");if(c!=="date"&&c!=="time"&&c!=="complete")throw new RangeError("representation must be 'date', 'time', or 'complete'");var d="",u="",p=s==="extended"?"-":"",f=s==="extended"?":":"";if(c!=="time"){var h=Kt(i.getDate(),2),y=Kt(i.getMonth()+1,2),m=Kt(i.getFullYear(),4);d="".concat(m).concat(p).concat(y).concat(p).concat(h)}if(c!=="date"){var E=i.getTimezoneOffset();if(E!==0){var T=Math.abs(E),w=Kt(Math.floor(T/60),2),S=Kt(T%60,2),I=E<0?"+":"-";u="".concat(I).concat(w,":").concat(S)}else u="Z";var x=Kt(i.getHours(),2),K=Kt(i.getMinutes(),2),Z=Kt(i.getSeconds(),2),M=d===""?"":"T",j=[x,K,Z].join(f);d="".concat(d).concat(M).concat(j).concat(u)}return d}function p_(e){const t=it(e),n=at(e,"commentsApi"),o=r.commentsDataSourceProvider(e),i=o.byForeignKey("post"),{dispatch:s}=r.getStore(e);r.getDisposable(e).addDisposable(o.onChange(()=>s(n.util.invalidateTags(["Comments"])))),t(n,{getComments(c){return i.get(c).then(({data:d})=>d)},addComment({subjectId:c,author:d,parent:u,content:p,author_name:f,author_email:h,targetId:y}){const m={post:c,author:d,author_name:f,author_email:h,content:p,parent:u,target_id:y,date:u_(new Date),author_avatar_urls:{}};return o.create(m)},deleteComment(c){return o.remove(c)},editComment({commentId:c,...d}){return o.update(c,d)},deleteTarget(c){return o.update(c,{target_id:""})}})}function Oo(e){return{id:String(e),name:"",myRole:"",members:[],invites:[],emailsCount:0,blocksCount:0,title:"",group:[],folder:[],blockfolder:[]}}function ma(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function m_(e,t){const n=Oo(String(t)),o=r.getCurrentProject(e).card;return o&&String(o.id)===String(t)?Promise.resolve({...n,...o,id:String(t)}):Promise.resolve({...n,id:String(t)})}function f_(e){let t,n;const o=i=>((t!==i||!n)&&(t=i,n=m_(e,i)),n);it(e)(at(e,"projectsApi"),{getProjects(i={page:1}){return[]},getProject(i){return async s=>r.isStandaloneRuntime(e)?s(i):{...await o(i),id:String(i)}},addProject(i){throw new Error},async editProject({projectId:i,...s}){const c={...await o(i),...s,id:String(i)};return t=i,n=Promise.resolve(c),c},deleteProject(i){throw new Error},mutateProjectMembers(){throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},addProjectMember(){throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},getFrequentProjects(){return[]}})}function g_(e){let t={id:"0",username:"",email:"",password:"",code_editor:{},theme:"light",locale:r.getCurrentUser(e).profile?.locale,counters:{},avatar_urls:{},autosaves:!0};it(e)(at(e,"authorizationApi"),{getSchema:()=>n=>n({}),getMe:()=>t,editMe:n=>t={...t,...n},getSubscriptions:()=>[]})}function h_(e){it(e)(at(e,"notificationsApi"),{getNotifications(t){return[]},notificationShown({id:t,datetime:n}){throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)}})}function __(e){it(e)(at(e,"addUserToProjectApi"),{addUserToProject:()=>{}})}function y_(e){r.injectEmailTermsResolver(e,{resolve:async()=>{}}),it(e)(at(e,"taxonomiesApi"),{getTerms:()=>[],getStandardGroups:()=>[],addTerm:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},editTerm:t=>({id:t.id,name:t.name,parent:0,count:0}),deleteTerm:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)}})}function v_(e){it(e)(at(e,"projectSettingsV2Api"),{getProjectIntegrations:()=>({}),getProjectWebhook:()=>"",getProjectStorage:()=>({}),getProjectTestRecipients:()=>[],getIntegrationCredentials:()=>({}),putProjectIntegration:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},deleteProjectIntegration:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},putProjectWebhook:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},putProjectSettings:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},putProjectTestRecipients:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)}})}function b_(e){it(e)(at(e,"stripoImportApi"),{getStripoFolders:()=>[],getStripoItems:()=>({items:[],total:0}),getCurrentStripoImport:()=>null,getStripoImport:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},saveStripoKey:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)},startStripoImport:()=>{throw new Error(g.NOT_IMPLEMENTED_IN_PLUGIN)}})}var fa={addUserToProjectApiMock:__,AiApiMock:n_,authorizationApiMock:g_,blocksApiMock:s_,commentsApiMock:p_,emailsApiMock:a_,emailRawApiMock:d_,imageApiMock:i_,notificationsApiMock:h_,projectsApiMock:f_,projectSettingsV2ApiMock:v_,proxyApiMock:r_,saveFileApiMock:c_,stripoImportApiMock:b_,taxonomiesApiMock:y_,tokenApiMock:o_},jo=r.createApi({reducerPath:"tokenApi",baseQuery:r.fetchBaseQueryApp({baseUrl:"https://app.useblocks.io/api/wp-json/jwt-auth/v1/"}),endpoints:e=>({tokenCreate:e.mutation({queryFn(t,n){return r.clientFromApi(n).jwtAuth.token_create({body:t,type:g.ContentType.Json})}}),tokenValidate:e.mutation({queryFn(t,n){return r.clientFromApi(n).jwtAuth.token_validate_create({type:g.ContentType.Json})}})})}),{useTokenCreateMutation:y0,useTokenValidateMutation:v0}=jo;function Lo(){const e=new Map;for(const t of ia)e.set(t.reducerPath,t);return e.set(jo.reducerPath,jo),[...e.values()]}function E_(e,t){const n=Object.keys(t.endpoints);n.length&&e(t,Object.fromEntries(n.map(o=>[o,Xh])))}function S_(e){Jh(e);const t=it(e);for(const n of Lo())E_(t,n)}function w_(e){if(!e)return;const t=g.decodeJwt(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(o=>typeof o=="string"?o.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(o=>/^project_\d+$/.test(o))?.replace(/^project_/,"")||void 0}var k_={AiApi:new Set(["sendMessage","getDialog"]),imageApi:new Set(["sendAiImageRequest","getAiImage","getAiImageSSE"])};function T_(e){return r.getAppConfig(g.getContainer(e))}function C_(e){return e?.backendProxy!==void 0&&e?.backendProxyPolicy?.proxyAi===!0}function I_(e){return C_(T_(e))}function A_(e,t,n,o){return k_[t]?.has(n)?i=>I_(e)?s=>s(i):o(i):o}function x_(e){const t=it(e);return((n,o)=>{if(!n||typeof n.reducerPath!="string")return new g.Disposable;const i=Object.fromEntries(Object.entries(o??{}).map(([s,c])=>[s,typeof c=="function"?A_(e,n.reducerPath,s,c):c]));return t(n,i)})}function P_(e){const t=`blocks_${g.generateUUID().replaceAll("-","")}`,n=document.createElement("script");return n.type="text/javascript",n.text=`window.${t}(function(module, exports, require) { ${e}; })`,new Promise((o,i)=>{window[t]=function(s){const c={exports:{}},d=()=>{};s(c,c.exports,d),o(c.exports)},document.head.appendChild(n)}).finally(()=>{n.remove(),delete window[t]})}async function ga(e){const t=g.getContainer(e),n=t?.getInstance(g.STANDALONE_PROJECT_ID),o=n?void 0:await t?.getInstanceAsync(g.APP_ID).catch(()=>{}),i=n||(o?.project!==void 0?String(o.project):void 0);i&&t&&r.setCurrentProjectCard(t,Oo(i))}async function R_(e,t){try{const n=function(d){const u=e.getInstance(g.STANDALONE_PROJECT_ID),p=u?ma(u,d):d;e.injectFactory(g.APP_ID,async()=>p)},o=x_(e),i=await r.readZipFromBase64(t),s=i.key&&r.zipEntryToText(i.key);if(typeof s!="string")return;const c=await P_(s);if(typeof c!="object"||c===null||typeof c.execute!="function")return;c.execute(n,o,Lo())}catch{}}async function ha(e,t){S_(g.getContainer(e)),await R_(g.getContainer(e),t),da(g.getContainer(e),fa)}var O_=zn(async e=>{const t=$h(e);e.inject(g.STORE_ID,t),Uh(e,Lo()),Hh(e,t),r.getDisposable(e).addDisposable(Gh(e,t)),r.getDisposable(e).addDisposable(zh(e,t));const n=g.getContainer(t);n&&(e.inject(g.MESSAGE_SERVICE_ID,r.getMessageService(n)),e.inject(r.CURRENT_PROJECT_ID,r.provideCurrentProject(n)));const o=e.getInstance(g.SECURITY_MODULE_ID);return o?(await ha(t,o),await ga(t)):da(g.getContainer(t),fa),{instance:{}}}),_a=["historyEnabled","commentsEnabled","aiAssistentEnabled","livePreviewEnabled","sendTestEnabled","sharePreviewEnabled","webversionEnabled","optimizeSpamAssassinEnabled","exportWebHookEnabled","aiLayoutConverterEnabled","elementAIimageEnabled","elementAItextEnabled","revisionService"];function j_(e){const t={...e};for(const n of _a)t[n]=!1;return t}function L_(e){const t={...e};for(const n of _a)n in t&&typeof t[n]=="boolean"&&(t[n]=!1);return t}function M_(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,o]of Object.entries(e))!o||typeof o!="object"||Array.isArray(o)||(t[n]=L_(o));return Object.keys(t).length>0?t:void 0}function Mo(e){const t=j_(e),n=M_(e.advancedConfigs),o={...t};return n?o.advancedConfigs=n:delete o.advancedConfigs,o}var b0=1,N_=2592e6;function ya(){return"useblocks".trim()||void 0}function D_(e){return{schemaVersion:1,savedAt:Date.now(),project:e.project,app_id:e.app_id,app_config:Mo(ba(e.app_config))}}function va(e){return{...e,app_config:ba(e.app_config)}}function ba(e){if(!e||typeof e!="object"||Array.isArray(e))return{};try{if(typeof structuredClone=="function")return structuredClone(e)}catch{}try{return JSON.parse(JSON.stringify(e))}catch{return{}}}async function F_(e){const t=ya();t&&await H_(t,D_(e))}async function B_(e=Date.now()){const t=ya();if(t)return q_(t,e)}function $_(e,t=Date.now()){return e.savedAt>t?!1:t-e.savedAt<=N_}function Ea(e){if(!e||typeof e!="object")return!1;const t=e,n=typeof t.project=="number"&&Number.isFinite(t.project)||typeof t.project=="string"&&t.project.trim()!=="";return t.schemaVersion===1&&typeof t.savedAt=="number"&&Number.isFinite(t.savedAt)&&n&&typeof t.app_id=="number"&&Number.isFinite(t.app_id)&&t.app_config!=null&&typeof t.app_config=="object"&&!Array.isArray(t.app_config)}var Ot="snapshots",U_=1;function z_(){return`${"useblocks".trim()||"plugin"}-plugin-deferred-config`}function Lr(){return new Promise((e,t)=>{if(typeof indexedDB>"u"){t(new Error("indexedDB is not available"));return}const n=indexedDB.open(z_(),U_);n.onerror=()=>t(n.error||new Error("indexedDB open failed")),n.onupgradeneeded=()=>{const o=n.result;o.objectStoreNames.contains(Ot)||o.createObjectStore(Ot)},n.onsuccess=()=>e(n.result)})}function G_(e){return new Promise((t,n)=>{e.onsuccess=()=>t(e.result),e.onerror=()=>n(e.error||new Error("indexedDB request failed"))})}function W_(){return{async get(e){const t=await Lr();try{const n=await G_(t.transaction(Ot,"readonly").objectStore(Ot).get(e));return n===void 0?void 0:n}finally{t.close()}},async put(e,t){const n=await Lr();try{const o=n.transaction(Ot,"readwrite");o.objectStore(Ot).put(t,e),await new Promise((i,s)=>{o.oncomplete=()=>i(),o.onerror=()=>s(o.error||new Error("indexedDB write failed")),o.onabort=()=>s(o.error||new Error("indexedDB write aborted"))})}finally{n.close()}},async delete(e){const t=await Lr();try{const n=t.transaction(Ot,"readwrite");n.objectStore(Ot).delete(e),await new Promise((o,i)=>{n.oncomplete=()=>o(),n.onerror=()=>i(n.error||new Error("indexedDB delete failed")),n.onabort=()=>i(n.error||new Error("indexedDB delete aborted"))})}finally{t.close()}},async clear(){const e=await Lr();try{const t=e.transaction(Ot,"readwrite");t.objectStore(Ot).clear(),await new Promise((n,o)=>{t.oncomplete=()=>n(),t.onerror=()=>o(t.error||new Error("indexedDB clear failed")),t.onabort=()=>o(t.error||new Error("indexedDB clear aborted"))})}finally{e.close()}}}}var Sa,No;function Do(){return Sa||(No||(No=W_()),No)}function wa(e){Do().delete(e).catch(()=>{})}async function H_(e,t){if(Ea(t))try{await Do().put(e,va(t))}catch{}}async function q_(e,t=Date.now()){try{const n=await Do().get(e);if(n===void 0)return;if(!Ea(n)){wa(e);return}if(!$_(n,t)){wa(e);return}return va(n)}catch{return}}function V_(e,t){if(e.getInstance(g.STANDALONE_FILE_PROXY_REGISTERED_ID))return;e.inject(g.STANDALONE_FILE_PROXY_REGISTERED_ID,!0);const n=g.getEvent(e,g.events.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:o})=>(await fetch(o)).blob(),Number.MIN_VALUE))}function ka(e){try{return w_(e)||void 0}catch{return}}async function K_(e,t,n){if(!e)return;let o;try{const i=await e(t,n,void 0);o=String(i||"").trim()}catch{return}if(o)return{token:o,serverProjectId:ka(o)}}function Y_(e){if(e==null)return;const t=String(e).trim();return/^\d+$/.test(t)?t:void 0}function Q_(e){const t=String(e.getInstance(g.JWT_TOKEN_ID)||"").trim();if(t)return ka(t)}function Ta(e,t,n){e.inject(g.APP_ID,void 0),e.inject(g.APP_ID,Promise.resolve(ma(t,n)))}function X_(e){return{app_id:e.app_id,app_config:Mo(e.app_config)}}async function Ca(){const e=await B_();return e?X_(e):{app_config:Mo({})}}function J_(e,t){e.getInstance(g.STANDALONE_ACTIVATED_ID)||(e.inject(g.SECURITY_MODULE_ID,void 0),e.inject(g.STANDALONE_BOOTSTRAP_TOKEN_ID,void 0),e.inject(g.STANDALONE_PROJECT_ID,void 0),t&&e.inject(g.APP_ID,void 0),e.inject(g.STANDALONE_FILE_PROXY_REGISTERED_ID,void 0))}async function Ia(e){const{container:t,store:n,standaloneKey:o,project:i,reason:s,getAuthToken:c,user:d}=e,u=e.disposable||t.getInstance(g.DISPOSABLE_ID);if(t.getInstance(g.STANDALONE_ACTIVATED_ID))return;const p=await K_(c,d,i),f=Y_(i),h=p?.serverProjectId??Q_(t)??(p?void 0:f);t.inject(g.SECURITY_MODULE_ID,o);let y=!1;try{if(p&&(t.inject(g.STANDALONE_BOOTSTRAP_TOKEN_ID,Promise.resolve(p.token)),c&&g.recreateTokenProvider(t,c,d,i)),h){const m=await Ca();t.inject(g.STANDALONE_PROJECT_ID,h),Ta(t,h,m),y=!0,r.setCurrentProjectCard(t,Oo(h))}if(await ha(n,o),y=!0,!h){await ga(n);const m=t.getInstance(g.STANDALONE_PROJECT_ID);if(m)Ta(t,m,await Ca()),y=!0;else if(t.getInstance(g.APP_ID)!==void 0)try{(await t.getInstanceAsync(g.APP_ID))?.project==null}catch{}}u&&V_(t,u),t.inject(g.STANDALONE_ACTIVATED_ID,!0)}catch(m){throw J_(t,y),m}}async function Z_(e,t,n,o){const i=o?.attemptTimeout??g.isFailoverEnabled(n),s=g.isFailoverEnabled(n)?g.getOrderedOriginCandidates(n):g.getOriginChain(n).length>0?[g.getActiveBaseUrl(n)]:[];if(s.length===0)throw new Error("[apiOriginFailover] no API base URL configured");const c=e.startsWith("/")?e:`/${e}`;let d,u;for(let p=0;p<s.length;p++){const f=s[p],h=p===s.length-1,y=i?g.beginFailoverAttempt(t.signal):void 0;try{const m=await fetch(`${f}${c}`,{...t,...y?{signal:y.signal}:{}});if(!m.ok&&g.shouldFailoverResponse(m.status)){if(d=m,!h){g.reportOriginFailure(f,n);continue}break}return m.ok&&g.reportOriginSuccess(f,n),m}catch(m){const E=y?.timeoutError();if(!E&&!g.shouldFailoverError(m))throw m;u=E||m,h||g.reportOriginFailure(f,n)}finally{y?.done()}}if(g.isFailoverEnabled(n)&&g.abandonStickyOrigin(),d)return d;throw u instanceof Error?u:new Error("[apiOriginFailover] fetch chain failed")}function ey(e,t){const n=String(t.baseUrl||"").trim();if(n)return g.resolveExplicitApiBaseUrl(n);const o=e.getInstance(g.REST_CLIENT_FACTORY_ID),i=String(o?.getOptions()?.baseUrl||"").trim();return g.resolveExplicitApiBaseUrl(i||void 0)}async function ty(e,t){if(t.getAuthToken)try{const n=await t.getAuthToken(t.user,t.project,void 0);if(String(n||"").trim())return!0}catch{if(!t.jwtAuth)return!1}if(t.jwtAuth)try{if(String(e.getInstance(g.JWT_TOKEN_ID)||"").trim())return!0;const n=ey(e,t);if(!n)return!1;const o=await Z_("/jwt-auth/token",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t.jwtAuth)},n,{attemptTimeout:!0});if(!o.ok)return!1;const i=await o.json();return i.token?(e.inject(g.JWT_ERROR_ID,void 0),e.inject(g.JWT_TOKEN_ID,i.token),!0):!1}catch{return!1}return!1}async function ny(e){try{if(e.getInstance(g.APP_ID)===void 0)return!1;const t=await oy(e.getInstanceAsync(g.APP_ID));return t!=null&&t.project!=null?t:!1}catch{return!1}}function ry(){return g.getFailoverAttemptTimeoutMs()*Math.max(1,g.getOriginChain().length)}function oy(e){const t=ry();return new Promise((n,o)=>{const i=setTimeout(()=>{n(void 0)},t);e.then(s=>{clearTimeout(i),n(s)},s=>{clearTimeout(i),o(s)})})}function Aa(e){return String(e.standaloneKey||"").trim()||void 0}function iy(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function sy(e){return iy(e)?!!Aa(e):!1}var ay=zn(async e=>{const t=e.getInstance(g.DISPOSABLE_ID),n=()=>e.getInstanceAsync(g.STORE_ID);return{async setOptions(o){if(!sy(o)){e.getInstance(g.STANDALONE_ACTIVATED_ID);return}const i=Aa(o);if(!i||e.getInstance(g.STANDALONE_ACTIVATED_ID))return;const s=await n(),c=!!(o.getAuthToken||o.jwtAuth),d=c?await ty(e,o):!0;if(c&&!d){await Ia({container:e,store:s,standaloneKey:i,project:o.project,getAuthToken:o.getAuthToken,user:o.user,disposable:t,reason:"auth pipeline failed"});return}const u=await ny(e);if(u){await F_(u).catch(()=>{});return}await Ia({container:e,store:s,standaloneKey:i,project:o.project,getAuthToken:o.getAuthToken,user:o.user,disposable:t,reason:"app_init failed"})}}}),ly=g.defineMixin(e=>{let t;const n=r.getDisposable(e),o=g.getEvent(e,g.events.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(o(({history:s})=>{t=s}));const i=()=>t?Ni(t):void 0;return{instance:{undoRedoService:{undo:()=>i()?.undo(),redo:()=>i()?.redo(),clear:()=>i()?.clear(),getPast:s=>i()?.getPast(s)??[],getFuture:s=>i()?.getFuture(s)??[],canUndo:()=>i()?.canUndo()??!1,canRedo:()=>i()?.canRedo()??!1,createSnapshot:()=>i()?.createSnapshot(),restoreSnapshot:s=>i()?.restoreSnapshot(s)}}}});function cy(e){return{font_size:e.fontSize,font_family:e.fontFamily,tab_size:e.tabSize,word_wrap:e.wordWrap,minimap:e.minimap,insert_spaces:e.insertSpaces}}function dy(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}async function xa(e){const t=r.getCurrentUser(e).profile;if(t)return t;const n=e.getInstance(g.STORE_ID);if(n)return(await n.dispatch(r.authorizationApi.endpoints.getMe.initiate("",{forceRefetch:!0}))).data}function uy(e){const t=r.resolveTemplateDirectivesConfig(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return fs();const n=new Set(Object.keys(t.output).filter(i=>t.output[i]==="html-comment")),o=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:i=>r.mapper.normalizeToPolicy(i,t.editor),toOutputForm:i=>r.mapper.normalizeToPolicy(i,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:ms(o)}}function Pa(e){const t=r.getCodeMode(e);return{...Mr(e),editor:dy(r.getEditorOptions(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function Mr(e){return e.getInstance(g.CONFIG_SOURCE_ID)?.get()??{}}function Fo(e){return e.getInstance(g.CONFIG_SOURCE_ID)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}var py=vo(e=>{const t=r.getDisposable(e),n=Tt(r.getEvent(e,g.events.ON_LIMIT_ID)),o=t.addDisposable(new kt(n)),i=Tt(r.getEvent(e,g.events.READ_LOCALE)),s=t.addDisposable(new kt(i)),c=Tt(r.getEvent(e,g.events.ON_TRANSLATE_ID)),d=t.addDisposable(new kt(c)),u=r.getEmitter(e,g.CONFIG_CHANGED_EVENT_ID),p=async()=>{try{return e.getInstance(g.APP_ID)===void 0?{}:(await e.getInstanceAsync(g.APP_ID))?.app_config||{}}catch{return{}}},f=Bs(),h=Bs();let y,m=!1,E;const T=async()=>{const A=Pa(e);if(!m){E=g.deepClone(A),m=!0;return}E!==void 0&&g.deepEqual(E,A)||(E=g.deepClone(A),await u.fire(A))},w=A=>{if(typeof A=="number")return String(A);if(typeof A=="string")return A},S=A=>{if(A!==void 0){const O=r.provideCurrentProject(e);O.set({...O.get(),requested:String(A)})}},I=async(A,O)=>{if(!A){const ee=await xa(e);return y=w(ee?.id),{didReset:!1}}const z=await xa(e),B=A.id!==void 0?w(A.id):w(z?.id),U=y!==void 0?String(y):void 0,de=B!==void 0?String(B):void 0,me=U!==void 0&&de!==void 0&&U!==de,q={...z,...r.filterUndefined(A),id:B};if(A.id===void 0&&!z?.id&&delete q.id,r.provideCurrentUser(e).set({profile:q}),me&&O){const ee=e.getInstance(g.INSTANCE_ID);if(ee?.reset)return await ee.reset(O),{didReset:!0}}return y=de,{didReset:!1}},x=A=>{const O=e.getInstance(g.CONFIG_SOURCE_ID);O?.setAdvancedConfigs({...A.advancedConfigs,...A.user?.advancedConfigs}),O?.replace(A.user,"user"),O?.replace(A.serverSide,"server")},K=async()=>{await e.getInstance(g.CONFIG_SOURCE_ID)?.ready(),r.getRevisionServiceFlag(e).set(Mr(e).revisionService===!0);const{codeModeDirection:A,editor:O}=Mr(e);O&&r.applyEditorOptions(e,cy(O)),A!==void 0&&(A==="none"?r.setCodeMode$1(e,!1):(r.setCodeMode$1(e,!0),r.setCodeModeDirection(e,A)))},Z=async A=>{x(A),await K()};let M;const j=f.decorate(async({config:A={},project:O,user:z,advancedConfigs:B},U)=>{e.getInstance(g.CONFIG_SOURCE_ID)?.replace(await p(),"server"),await K(),e.inject(g.TEMPLATE_DIRECTIVES_ID,uy(Mr(e).templateDirectives)),S(O),U&&"commonStyles"in U&&r.setDefaultCommonStyles(e,U.commonStyles===void 0?void 0:U.commonStyles);const{didReset:de}=await I(z,U)});return{setOptions:h.decorate(async A=>{const{config:O={},project:z,user:B,advancedConfigs:U,handleReadLocale:de,handleLimitUsage:me,handleTranslate:q,storageProvider:ee}=A;e.inject(g.STORAGE_PROVIDER_ID,ee),s.setListener(de),o.setListener(me),d.setListener(q),await j({config:O,project:z,user:B,advancedConfigs:U},A).catch(Fe=>{}),await T(),M&&M.dispose(),M=new g.Disposable}),instance:{setConfig:h.decorate(async A=>{const O=A,{commonStyles:z,...B}=O;"commonStyles"in O&&r.setDefaultCommonStyles(e,z===void 0?void 0:z),await Z({advancedConfigs:Fo(e).advancedConfigs,serverSide:await p(),user:B}),await T()}),getConfig:()=>Pa(e),updateConfig:h.decorate(async A=>{const O=A,{commonStyles:z,...B}=O;"commonStyles"in O&&r.setDefaultCommonStyles(e,z===void 0?void 0:z),await Z({advancedConfigs:Fo(e).advancedConfigs,serverSide:await p(),user:{...Fo(e).user,...B}}),await T()}),handleReadLocale:i,handleLimitUsage:n,handleTranslate:c}}}),Nr;function Bo(){return Nr===void 0&&(Nr=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/7f91ed03.js")),void 0,{}.url).catch(e=>{throw Nr=void 0,e})),Nr}var Ra;function my(){return Ra??=(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/e47dcbb0.js")).then(e=>zt.__toESM(e.require_core())),void 0,{}.url),Ra}function fy(e){const t=[0],n=[];let o=0;for(;o<e.length;){const i=e.charCodeAt(o);i===10||i===13?(n.push(o-t[t.length-1]),o+=i===13&&e.charCodeAt(o+1)===10?2:1,t.push(o)):o+=1}return n.push(e.length-t[t.length-1]),{starts:t,lengths:n}}function Oa({starts:e,lengths:t},n,o){const i=Math.min(Math.max(n,1),e.length)-1;return e[i]+Math.min(Math.max(o,1),t[i]+1)-1}var gy={error:8,warning:4,info:2};function hy(e,t){const n=e.evidence!==""?e.col+e.evidence.length:t.lengths[e.line-1]??e.col+1;return{severity:gy[e.type]??8,message:e.message,startLineNumber:e.line,startColumn:e.col,endLineNumber:e.line,endColumn:n,startOffset:Oa(t,e.line,e.col),endOffset:Oa(t,e.line,n)}}async function _y(e){const{HTMLHint:t}=await my(),n=fy(e);return t.verify(e,r.EMAIL_CODE_RULESET).map(o=>hy(o,n))}var yy=class extends g.Disposable{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=r.getDataSources(e),this.addDisposable(g.getEvent(e,g.events.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>t.project===e).map(t=>Lg(t,this._container))}async _readProjectBlocks(){const e=await r.getBlocksProject(this._container);return await this._dataSources.blocks.byForeignKey("project").get(e),e}async getComments(){const{cache:e}=this._dataSources.comments,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.post===t.id).map(n=>Mg(n,this._container))}async getEmailRevisions(){const{cache:e}=this._dataSources.emailRevisions,t=await this.getEmailSnapshot();return(await e.values()).filter(n=>n.parent===t.id).map(n=>Ng(n,this._container))}async getEmailSnapshot(){return zp(r.getOpenEmail(this._container,this._currentEmail),this._container)}async getEmail(e=!0){return this.compile(e)}async compileEmail(e=!0){return this.compile(e)}async compile(e){const{compileEmail:t}=await Bo();return t(await this.getEmailSnapshot(),e,on(this._container).keepWrappedOnOutput)}setEmailMeta(e){const t=r.getOpenDocument(this._container);if(!t)return;const n=t.get().attributes.meta;r.writeEmailAttributes(t,{meta:r.applyMetaPatch({meta:n},e).meta});const o=t.get().serverId;o!=null&&this._dataSources.emails.cache.addOrUpdate(o,i=>i&&r.applyMetaPatch(i,e))}setBlockMeta(e,t){const n=async()=>{await this._readProjectBlocks();const{cache:o}=this._dataSources.blocks;await o.getIfPresent(e)&&await o.addOrUpdate(e,i=>i&&r.applyMetaPatch(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(n).catch(()=>{})}getCodeErrors(){const e=r.getCodeErrors(this._container);return e.length>0?e:void 0}validateCode(){return Promise.resolve(_y(r.getOpenEmail(this._container,this._currentEmail).html??""))}};function ja(){Bo().catch(()=>{})}function vy(e){const t=r.provideHeadlessMode(e).watch(n=>{n&&ja()});e.getInstance(g.DISPOSABLE_ID)?.addDisposable(t),Ht(e).whenVisible(()=>{Xt(ja)})}var by=g.createIdentifier$1("EmailOperationsController");function La(e){return e.getOrCreateInstance(by,()=>{const t=new yy(e);return e.getInstance(g.DISPOSABLE_ID)?.addDisposable(t),t})}function Ey(e){La(e),vy(e)}function Sy(e){const t=La(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getEmail:()=>t.getEmail(),async compileEmail(n,o=!0){if(!n)return t.compileEmail(o);const{compileEmail:i}=await Bo();return i(n,o,on(e).keepWrappedOnOutput)},validateCode:()=>t.validateCode(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,o)=>t.setBlockMeta(n,o)}}var wy=g.defineMixin(e=>{const t=e.getInstance(g.DISPOSABLE_ID),n=g.getEvent(e,g.events.UPLOAD_EVENT_ID),o=g.getEvent(e,g.events.FILE_PROXY_EVENT_ID),i=g.getEmitter(e,g.events.PROXY_URL_EVENT_ID).event,s=Tt(n),c=Tt(i),d=Tt(o),u=t.addDisposable(new kt(s)),p=t.addDisposable(new kt(d)),f=t.addDisposable(new kt(c));return{setOptions(h){u.setListener(h.handleLoadImage),p.setListener(h.handleFileProxy),f.setListener(h.handleUrlProxy)},instance:{handleLoadImage:s,handleFileProxy:d,handleUrlProxy:c}}}),ky=g.defineMixin(e=>{const t=e.getInstance(g.DISPOSABLE_ID),n=g.getEvent(e,g.events.AI_TEXT_REQUEST_ID),o=g.getEvent(e,g.events.AI_IMAGE_REQUEST_ID),i=Tt(n),s=Tt(o),c=t.addDisposable(new kt(i)),d=t.addDisposable(new kt(s));return{setOptions(u){c.setListener(u.handleAITextRequest),d.setListener(u.handleAIImageRequest)},instance:{handleAITextRequest:i,handleAIImageRequest:s}}}),Ty=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function Cy(e){const t=new Map;for(const n of e)for(const o of n.provides??[]){const i=t.get(o)??[];i.push(n),t.set(o,i)}return t}function Iy(e,t){const n=[];for(const o of e.awaits?.services??[])for(const i of t.get(o)??[])i!==e&&n.push(i);return n}function Ay(e){const t=Cy(e),n=[],o=new Set,i=[],s=new Set,c=d=>{if(!o.has(d)){if(s.has(d)){const u=i.indexOf(d);throw new Ty([...i.slice(u),d].map(p=>p.name))}s.add(d),i.push(d);for(const u of Iy(d,t))c(u);i.pop(),s.delete(d),o.add(d),n.push(d)}};for(const d of e)c(d);return n}var xy="author,slug,date,modified,title,acf.html,id,parent,date_gmt",Py="author,slug,date,modified,modified_gmt,title,acf.html,id,parent",Ry=20,$o=[g.WpEblockApi];function Ma(e){return typeof e=="string"&&e?`${e.replace(/Z$/,"")}Z`:void 0}function Oy(e){return{async readRevisions(t,n=1){const o=await g.getApi(e,$o).eblock_revisions_list({parent:t,per_page:Ry,page:n},{extraQuery:{_fields:xy}}),i=(o?.data??[]).map(c=>r.WpBlockRevisionToBlockRevision(c)),s=Number(o?.headers?.get("X-WP-TotalPages"));return{revisions:i,page:n,hasMore:Number.isFinite(s)&&n<s}},async readAutosave(t){const n=g.getApi(e,$o),[o,i]=await Promise.all([n.eblock_autosaves_list({id:t},{extraQuery:{_fields:Py}}),n.eblock_detail({id:t},{extraQuery:{_fields:"modified_gmt"}})]),s=(o?.data??[]).map(d=>{const u=d,p=r.WpBlockRevisionToBlockRevision(u),f=Ma(u.modified_gmt);return f?{...p,modified:f}:p}),c=Date.parse(Ma(i?.data?.modified_gmt)??"");return r.autosaveStateFromSlots(s,Number.isFinite(c)?c:void 0)},async saveAutosave(t,n){const o=n,i=o.global_block&&o.html?r.injectEmBlockIdIntoBlockHtml(o.html,t):o.html??"";r.writePendingData(t,{sentAt:Date.now(),html:i,common_styles:""});const s=await g.getApi(e,$o).eblock_autosaves_create({id:t},r.BlockAutoSaveToWpBlockAutoSave({title:o.title,html:i,project:o.project,excerpt:new Date().toISOString()}),{type:g.ContentType.FormData});return r.WpBlockRevisionToBlockRevision(s?.data)}}}var jy="author,slug,date,modified,title,meta,acf.html,acf.common_styles,id,parent,date_gmt",Ly="author,slug,date,modified,modified_gmt,title,meta,acf.html,acf.common_styles,id,parent";function Na(e){return typeof e=="string"&&e?`${e.replace(/Z$/,"")}Z`:void 0}var My=20,Uo=[g.WpEmailApi];function Ny(e){return{async readRevisions(t,n=1){const o=await g.getApi(e,Uo).email_revisions_list({parent:t,per_page:My,page:n},{extraQuery:{_fields:jy}}),i=(o?.data??[]).map(c=>r.WpEmailRevisionToEmailRevision(c)),s=Number(o?.headers?.get("X-WP-TotalPages"));return{revisions:i,page:n,hasMore:Number.isFinite(s)&&n<s}},async readAutosave(t){const n=g.getApi(e,Uo),[o,i]=await Promise.all([n.email_autosaves_list({id:t},{extraQuery:{_fields:Ly}}),n.email_detail({id:t},{extraQuery:{_fields:"modified_gmt"}})]),s=(o?.data??[]).map(d=>{const u=d,p=r.WpEmailRevisionToEmailRevision(u),f=Na(u.modified_gmt);return f?{...p,modified:f}:p}),c=Date.parse(Na(i?.data?.modified_gmt)??"");return r.autosaveStateFromSlots(s,Number.isFinite(c)?c:void 0)},async saveAutosave(t,n){const o=await g.getApi(e,Uo).email_autosaves_create({id:t},r.EmailAutoSaveToWpEmailAutoSave({...n,excerpt:new Date().toISOString()}),{type:g.ContentType.FormData});return r.WpEmailRevisionToEmailRevision(o?.data)}}}var Da=["_embedded","id","author","title","meta","emailtags","folder","group","modified","date","type","parent","date_gmt","acf.description","acf.html","acf.common_styles","acf.is_template","acf.lock","acf.parent_email","acf.project","acf.secret_hash","acf.subject","acf.utm_parameters"].join(","),zo=[g.WpEmailApi],Fa=e=>r.EmailToWpEmail(e);function Dy(e){return{async readEmail(t){const n=await g.getApi(e,zo).email_detail({id:r.toNumberSafe(t)},{extraQuery:{_embed:"wp:term",_fields:Da}});if(!n)throw new r.EmailOpenFailedError("unavailable");if(n.ok===!1)throw r.openFailureFromResponse(n);return n.data?r.WpEmailToEmail(n.data):null},async createEmail(t){const n={status:"publish",...Fa(t)},o=await g.getApi(e,zo).email_create(n,{type:g.ContentType.Json});return r.WpEmailToEmail(o?.data)},async updateEmail(t,n){const o=await g.getApi(e,zo).email_partial_update({id:t},Fa(n),{type:g.ContentType.Json,extraQuery:{_embed:"wp:term",_fields:Da}});return r.WpEmailToEmail(o?.data)}}}function Fy(e){r.injectRestEmailPortFactories(e,{email:Dy,history:Ny,blockHistory:Oy})}var Go=20,By=({source:e,emailtags:t,group:n,tags:o,...i})=>i;function $y({revisions:e,revisionsByBlock:t}){const n=async(o,i)=>(t.clear(),await t.get(o,{page:i}),(await e.cache.values()??[]).filter(s=>String(s?.parent)===String(o)));return{async readRevisions(o,i=1){const s=await n(o,i);return{revisions:s.slice(Go*(i-1),Go*i),page:i,hasMore:s.length>Go*i}},async readAutosave(o){return r.autosaveStateFromRevisions(await n(o,1))},async saveAutosave(o,i){const s=By(i);return await e.create({...s,parent:o,modified:new Date().toString()})}}}var Ba=g.createIdentifier$1("blockDocuments.provided");function Uy(e){if(e.getInstance(Ba))return;e.inject(Ba,!0);const t=r.blockRevisionsDataSourceProvider(e);r.injectBlockHistoryPort(e,$y({revisions:t,revisionsByBlock:t.byForeignKey("parent")}))}var zy=zt.__commonJSMin(((e,t)=>{(function(n){if(typeof window>"u")return;var o=0,i,s=!1,c=!1,d=7,u="[iFrameSizer]",p=u.length,f=null,h=window.requestAnimationFrame,y=Object.freeze({max:1,scroll:1,bodyScroll:1,documentElementScroll:1}),m={},E=null,T=Object.freeze({autoResize:!0,bodyBackground:null,bodyMargin:null,bodyMarginV1:8,bodyPadding:null,checkOrigin:!0,inPageLinks:!1,enablePublicMethods:!0,heightCalculationMethod:"bodyOffset",id:"iFrameResizer",interval:32,license:"1jqr0si6pnt",log:!1,maxHeight:1/0,maxWidth:1/0,minHeight:0,minWidth:0,mouseEvents:!0,resizeFrom:"parent",scrolling:!1,sizeHeight:!0,sizeWidth:!1,warningTimeout:5e3,tolerance:0,widthCalculationMethod:"scroll",onClose:function(){return!0},onClosed:function(){},onInit:function(){},onMessage:function(){O("onMessage function not defined")},onMouseEnter:function(){},onMouseLeave:function(){},onResized:function(){},onScroll:function(){return!0}});function w(){return window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver}function S(k,C,P){k.addEventListener(C,P,!1)}function I(k,C,P){k.removeEventListener(C,P,!1)}function x(){for(var k=["moz","webkit","o","ms"],C=0;C<k.length&&!h;C+=1)h=window[k[C]+"RequestAnimationFrame"];h?h=h.bind(window):j("setup","RequestAnimationFrame not supported")}function K(k){var C="Host page: "+k;return window.top!==window.self&&(C=window.parentIFrame&&window.parentIFrame.getId?window.parentIFrame.getId()+": "+k:"Nested host page: "+k),C}function Z(k){return u+"["+K(k)+"]"}function M(k){return m[k]?m[k].log:s}function j(k,C){z("log",k,C,M(k))}function A(k,C){z("info",k,C,M(k))}function O(k,C){z("warn",k,C,!0)}function z(k,C,P,N){N===!0&&window.console}function B(k){function C(){function $(){et(ie),ee(te),We("onResized",ie)}v("Height"),v("Width"),Ee($,ie,"init")}function P(){var $=Xe.slice(p).split(":"),le=$[1]?parseInt($[1],10):0,xe=m[$[0]]&&m[$[0]].iframe,Se=getComputedStyle(xe);return{iframe:xe,id:$[0],height:le+N(Se)+D(Se),width:$[2],type:$[3]}}function N($){return $.boxSizing!=="border-box"?0:($.paddingTop?parseInt($.paddingTop,10):0)+($.paddingBottom?parseInt($.paddingBottom,10):0)}function D($){return $.boxSizing!=="border-box"?0:($.borderTopWidth?parseInt($.borderTopWidth,10):0)+($.borderBottomWidth?parseInt($.borderBottomWidth,10):0)}function v($){var le=Number(m[te]["max"+$]),xe=Number(m[te]["min"+$]),Se=$.toLowerCase(),Ne=Number(ie[Se]);j(te,"Checking "+Se+" is in range "+xe+"-"+le),Ne<xe&&(Ne=xe,j(te,"Set "+Se+" to min value")),Ne>le&&(Ne=le,j(te,"Set "+Se+" to max value")),ie[Se]=""+Ne}function W(){function $(){function Se(){var He=0,$e=!1;for(j(te,"Checking connection is from allowed list of origins: "+xe);He<xe.length;He++)if(xe[He]===le){$e=!0;break}return $e}function Ne(){var He=m[te]&&m[te].remoteHost;return j(te,"Checking connection is from: "+He),le===He}return xe.constructor===Array?Se():Ne()}var le=k.origin,xe=m[te]&&m[te].checkOrigin;if(xe&&""+le!="null"&&!$())throw new Error("Unexpected message received from: "+le+" for "+ie.iframe.id+". Message was: "+k.data+". This error can be disabled by setting the checkOrigin: false option or by providing of array of trusted domains.");return!0}function Pe(){return u===(""+Xe).slice(0,p)&&Xe.slice(p).split(":")[0]in m}function Ae(){var $=ie.type in{true:1,false:1,undefined:1};return $&&j(te,"Ignoring init message from meta parent page"),$}function Qe($){return Xe.slice(Xe.indexOf(":")+d+$)}function Ge($){j(te,"onMessage passed: {iframe: "+ie.iframe.id+", message: "+$+"}"),We("onMessage",{iframe:ie.iframe,message:JSON.parse($)}),j(te,"--")}function Ze(){var $=document.body.getBoundingClientRect(),le=ie.iframe.getBoundingClientRect();return JSON.stringify({iframeHeight:le.height,iframeWidth:le.width,clientHeight:Math.max(document.documentElement.clientHeight,window.innerHeight||0),clientWidth:Math.max(document.documentElement.clientWidth,window.innerWidth||0),offsetTop:parseInt(le.top-$.top,10),offsetLeft:parseInt(le.left-$.left,10),scrollTop:window.pageYOffset,scrollLeft:window.pageXOffset,documentHeight:document.documentElement.clientHeight,documentWidth:document.documentElement.clientWidth,windowHeight:window.innerHeight,windowWidth:window.innerWidth})}function pt($,le){function xe(){fe("Send Page Info","pageInfo:"+Ze(),$,le)}Te(xe,32,le)}function bt(){function $(Ne,He){function $e(){m[Se]?pt(m[Se].iframe,Se):le()}["scroll","resize"].forEach(function(ot){j(Se,Ne+ot+" listener for sendPageInfo"),He(window,ot,$e)})}function le(){$("Remove ",I)}function xe(){$("Add ",S)}var Se=te;xe(),m[Se]&&(m[Se].stopPageInfo=le)}function ft(){m[te]&&m[te].stopPageInfo&&(m[te].stopPageInfo(),delete m[te].stopPageInfo)}function lt(){var $=!0;return ie.iframe===null&&(O(te,"IFrame ("+ie.id+") not found"),$=!1),$}function G($){var le=$.getBoundingClientRect();return q(te),{x:Math.floor(Number(le.left)+Number(f.x)),y:Math.floor(Number(le.top)+Number(f.y))}}function Y($){function le(){f=He,ne(),j(te,"--")}function xe(){return{x:Number(ie.width)+Ne.x,y:Number(ie.height)+Ne.y}}function Se(){window.parentIFrame?window.parentIFrame["scrollTo"+($?"Offset":"")](He.x,He.y):O(te,"Unable to scroll to requested position, window.parentIFrame not found")}var Ne=$?G(ie.iframe):{x:0,y:0},He=xe();j(te,"Reposition requested from iFrame (offset x:"+Ne.x+" y:"+Ne.y+")"),window.top===window.self?le():Se()}function ne(){We("onScroll",f)===!1?Fe():ee(te)}function ue($){function le(){var $e=G(He);j(te,"Moving to in page link (#"+Se+") at x: "+$e.x+" y: "+$e.y),f={x:$e.x,y:$e.y},ne(),j(te,"--")}function xe(){window.parentIFrame?window.parentIFrame.moveToAnchor(Se):j(te,"In page link #"+Se+" not found and window.parentIFrame not found")}var Se=$.split("#")[1]||"",Ne=decodeURIComponent(Se),He=document.getElementById(Ne)||document.getElementsByName(Ne)[0];He?le():window.top===window.self?j(te,"In page link #"+Se+" not found"):xe()}function he($){var le={};if(Number(ie.width)===0&&Number(ie.height)===0){var xe=Qe(9).split(":");le={x:xe[1],y:xe[0]}}else le={x:ie.width,y:ie.height};We($,{iframe:ie.iframe,screenX:Number(le.x),screenY:Number(le.y),type:ie.type})}function We($,le){return U(te,$,le)}function Ve(){switch(m[te]&&m[te].firstRun&&Me(),ie.type){case"close":me(ie.iframe);break;case"message":Ge(Qe(6));break;case"mouseenter":he("onMouseEnter");break;case"mouseleave":he("onMouseLeave");break;case"autoResize":m[te].autoResize=JSON.parse(Qe(9));break;case"scrollTo":Y(!1);break;case"scrollToOffset":Y(!0);break;case"pageInfo":pt(m[te]&&m[te].iframe,te),bt();break;case"pageInfoStop":ft();break;case"inPageLink":ue(Qe(9));break;case"reset":be(ie);break;case"init":C(),We("onInit",ie.iframe);break;default:Number(ie.width)===0&&Number(ie.height)===0?O("Unsupported message received ("+ie.type+"), this is likely due to the iframe containing a later version of iframe-resizer than the parent page"):C()}}function st($){var le=!0;return m[$]||(le=!1,O(ie.type+" No settings for "+$+". Message was: "+Xe)),le}function Bt(){for(var $ in m)fe("iFrame requested init",Q($),m[$].iframe,$)}function Me(){m[te]&&(m[te].firstRun=!1)}var Xe=k.data,ie={},te=null;Xe==="[iFrameResizerChild]Ready"?Bt():Pe()?(ie=P(),te=ie.id,m[te]&&(m[te].loaded=!0),!Ae()&&st(te)&&(j(te,"Received: "+Xe),lt()&&W()&&Ve())):A(te,"Ignored: "+Xe)}function U(k,C,P){var N=null,D=null;if(m[k])if(N=m[k][C],typeof N=="function")D=N(P);else throw new TypeError(C+" on iFrame["+k+"] is not a function");return D}function de(k){var C=k.id;delete m[C]}function me(k){var C=k.id;if(U(C,"onClose",C)===!1){j(C,"Close iframe cancelled by onClose event");return}j(C,"Removing iFrame: "+C);try{k.parentNode&&k.parentNode.removeChild(k)}catch(P){O(P)}U(C,"onClosed",C),j(C,"--"),de(k),i&&(i.disconnect(),i=null)}function q(k){f===null&&(f={x:window.pageXOffset===n?document.documentElement.scrollLeft:window.pageXOffset,y:window.pageYOffset===n?document.documentElement.scrollTop:window.pageYOffset},j(k,"Get page position: "+f.x+","+f.y))}function ee(k){f!==null&&(window.scrollTo(f.x,f.y),j(k,"Set page position: "+f.x+","+f.y),Fe())}function Fe(){f=null}function be(k){function C(){et(k),fe("reset","reset",k.iframe,k.id)}j(k.id,"Size reset requested by "+(k.type==="init"?"host page":"iFrame")),q(k.id),Ee(C,k,"reset")}function et(k){function C(v){if(!k.id){j("undefined","messageData id not set");return}k.iframe.style[v]=k[v]+"px",j(k.id,"IFrame ("+D+") "+v+" set to "+k[v]+"px")}function P(v){!c&&k[v]==="0"&&(c=!0,j(D,"Hidden iFrame detected, creating visibility listener"),Be())}function N(v){C(v),P(v)}var D=k.iframe.id;m[D]&&(m[D].sizeHeight&&N("height"),m[D].sizeWidth&&N("width"))}function Ee(k,C,P){P!==C.type&&h&&!window.jasmine?(j(C.id,"Requesting animation frame"),h(k)):k()}function fe(k,C,P,N,D){function v(){var Ge=m[N]&&m[N].targetOrigin;j(N,"["+k+"] Sending msg to iframe["+N+"] ("+C+") targetOrigin: "+Ge),P.contentWindow.postMessage(u+C,Ge)}function W(){O(N,"["+k+"] IFrame("+N+") not found")}function Pe(){P&&"contentWindow"in P&&P.contentWindow!==null?v():W()}function Ae(){function Ge(){m[N]&&!m[N].loaded&&!Qe&&(Qe=!0,O(N,"IFrame has not responded within "+m[N].warningTimeout/1e3+" seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ignored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning."))}D&&m[N]&&m[N].warningTimeout&&(m[N].msgTimeout=setTimeout(Ge,m[N].warningTimeout))}var Qe=!1;N=N||P.id,m[N]&&(Pe(),Ae())}function Q(k){return k+":"+m[k].bodyMarginV1+":"+m[k].sizeWidth+":"+m[k].log+":"+m[k].interval+":"+m[k].enablePublicMethods+":"+m[k].autoResize+":"+m[k].bodyMargin+":"+m[k].heightCalculationMethod+":"+m[k].bodyBackground+":"+m[k].bodyPadding+":"+m[k].tolerance+":"+m[k].inPageLinks+":"+m[k].resizeFrom+":"+m[k].widthCalculationMethod+":"+m[k].mouseEvents}function pe(k){return typeof k=="number"}function se(k,C){function P(){function Y(ue){var he=m[G][ue];he!==1/0&&he!==0&&(k.style[ue]=pe(he)?he+"px":he,j(G,"Set "+ue+" = "+k.style[ue]))}function ne(ue){if(m[G]["min"+ue]>m[G]["max"+ue])throw new Error("Value for min"+ue+" can not be greater than max"+ue)}ne("Height"),ne("Width"),Y("maxHeight"),Y("minHeight"),Y("maxWidth"),Y("minWidth")}function N(){var Y=C&&C.id||T.id+o++;return document.getElementById(Y)!==null&&(Y+=o++),Y}function D(Y){if(typeof Y!="string")throw new TypeError("Invaild id for iFrame. Expected String");return Y===""&&(k.id=Y=N(),s=(C||{}).log,j(Y,"Added missing iframe ID: "+Y+" ("+k.src+")")),Y}function v(){switch(j(G,"IFrame scrolling "+(m[G]&&m[G].scrolling?"enabled":"disabled")+" for "+G),k.style.overflow=(m[G]&&m[G].scrolling)===!1?"hidden":"auto",m[G]&&m[G].scrolling){case"omit":break;case!0:k.scrolling="yes";break;case!1:k.scrolling="no";break;default:k.scrolling=m[G]?m[G].scrolling:"no"}}function W(){(typeof(m[G]&&m[G].bodyMargin)=="number"||(m[G]&&m[G].bodyMargin)==="0")&&(m[G].bodyMarginV1=m[G].bodyMargin,m[G].bodyMargin=""+m[G].bodyMargin+"px")}function Pe(){var Y=m[G]&&m[G].firstRun,ne=m[G]&&m[G].heightCalculationMethod in y;!Y&&ne&&be({iframe:k,height:0,width:0,type:"init"})}function Ae(){m[G]&&(m[G].iframe.iFrameResizer={close:me.bind(null,m[G].iframe),removeListeners:de.bind(null,m[G].iframe),resize:fe.bind(null,"Window resize","resize",m[G].iframe),moveToAnchor:function(Y){fe("Move to anchor","moveToAnchor:"+Y,m[G].iframe,G)},sendMessage:function(Y){Y=JSON.stringify(Y),fe("Send Message","message:"+Y,m[G].iframe,G)}})}function Qe(Y){function ne(){fe("iFrame.onload",Y,k,n,!0),Pe()}function ue(We){if(!k.parentNode)return null;var Ve=new We(function(st){st.forEach(function(Bt){Array.prototype.slice.call(Bt.removedNodes).forEach(function(Me){Me===k&&me(k)})})});return Ve.observe(k.parentNode,{childList:!0}),Ve}var he=w();he&&(i=ue(he)),S(k,"load",ne),fe("init",Y,k,n,!0)}function Ge(Y){if(typeof Y!="object")throw new TypeError("Options is not an object")}function Ze(Y){for(var ne in T)Object.prototype.hasOwnProperty.call(T,ne)&&(m[G][ne]=Object.prototype.hasOwnProperty.call(Y,ne)?Y[ne]:T[ne])}function pt(Y){return Y===""||Y.match(/^(about:blank|javascript:|file:\/\/)/)!==null?"*":Y}function bt(Y){var ne=Y.split("Callback");if(ne.length===2){var ue="on"+ne[0].charAt(0).toUpperCase()+ne[0].slice(1);this[ue]=this[Y],delete this[Y],O(G,"Deprecated: '"+Y+"' has been renamed '"+ue+"'. The old method will be removed in the next major version.")}}function ft(Y){Y=Y||{},m[G]=Object.create(null),m[G].iframe=k,m[G].firstRun=!0,m[G].remoteHost=k.src&&k.src.split("/").slice(0,3).join("/"),Ge(Y),Object.keys(Y).forEach(bt,Y),Ze(Y),m[G]&&(m[G].targetOrigin=m[G].checkOrigin===!0?pt(m[G].remoteHost):"*")}function lt(){return G in m&&"iFrameResizer"in k}var G=D(k.id);lt()?O(G,"Ignored iFrame, already setup."):(ft(C),v(),P(),W(),Qe(Q(G)),Ae())}function ae(k,C){E===null&&(E=setTimeout(function(){E=null,k()},C))}var Ie={};function Te(k,C,P){Ie[P]||(Ie[P]=setTimeout(function(){Ie[P]=null,k()},C))}function Be(){function k(){function D(v){function W(Ae){return(m[v]&&m[v].iframe.style[Ae])==="0px"}function Pe(Ae){return Ae.offsetParent!==null}m[v]&&Pe(m[v].iframe)&&(W("height")||W("width"))&&fe("Visibility change","resize",m[v].iframe,v)}Object.keys(m).forEach(function(v){D(v)})}function C(D){j("window","Mutation observed: "+D[0].target+" "+D[0].type),ae(k,16)}function P(){var D=document.querySelector("body");new N(C).observe(D,{attributes:!0,attributeOldValue:!1,characterData:!0,characterDataOldValue:!1,childList:!0,subtree:!0})}var N=w();N&&P()}function J(k){function C(){Ce("Window "+k,"resize")}j("window","Trigger event: "+k),ae(C,16)}function _e(){function k(){Ce("Tab Visible","resize")}document.visibilityState!=="hidden"&&(j("document","Trigger event: Visibility change"),ae(k,16))}function Ce(k,C){function P(N){return m[N]&&m[N].resizeFrom==="parent"&&m[N].autoResize&&!m[N].firstRun}Object.keys(m).forEach(function(N){P(N)&&fe(k,C,m[N].iframe,N)})}function ge(){S(window,"message",B),S(window,"resize",function(){J("resize")}),S(document,"visibilitychange",_e),S(document,"-webkit-visibilitychange",_e)}function Oe(){function k(N,D){function v(){if(D.tagName){if(D.tagName.toUpperCase()!=="IFRAME")throw new TypeError("Expected <IFRAME> tag, found <"+D.tagName+">")}else throw new TypeError("Object is not a valid DOM element")}D&&(v(),se(D,N),P.push(D))}function C(N){N&&N.enablePublicMethods&&O("enablePublicMethods option has been removed, public methods are now always available in the iFrame")}var P;return x(),ge(),function(D,v){switch(P=[],C(D),typeof v){case"undefined":case"string":Array.prototype.forEach.call(document.querySelectorAll(v||"iframe"),k.bind(n,D));break;case"object":k(D,v);break;default:throw new TypeError("Unexpected data type ("+typeof v+")")}return P}}function ze(k){k.fn?k.fn.iFrameResize||(k.fn.iFrameResize=function(P){function N(D,v){se(v,P)}return this.filter("iframe").each(N).end()}):A("","Unable to bind to jQuery, it is not fully loaded.")}window.jQuery!==n&&ze(window.jQuery),typeof define=="function"&&define.amd?define([],Oe):typeof t=="object"&&typeof t.exports=="object"&&(t.exports=Oe()),window.iFrameResize=window.iFrameResize||Oe()})()})),Gy=zt.__toESM(zy()),Wy={checkOrigin:!1,minHeight:600,scrolling:!1};function Hy(e){const t=()=>e.iFrameResizer;return(0,Gy.default)(Wy,e),{resize:()=>t()?.resize?.(),dispose:()=>t()?.removeListeners?.()}}function qy(e){e.inject(Mi,Hy)}function Vy(e){const t=r.getMessageService(e),n=e.getInstance(r.LOCALE_SERVICE_ID);if(!n)return;let o="";const i=()=>{const d=n.snapshot(),u=d.id??"";if(!t.isInited()||u===o)return;const p=r.createI18n(d.catalog),f=y=>p.__(y),h=r.SANDBOX_TRANSLATIONS_MAP(f);o=u,t.send(r.EVENT_TYPES.SANDBOX_TRANSLATIONS,{name:u,data:h})},s=t.onInit(()=>{o="",i()}),c=n.state.watch(i);e.getInstance(g.DISPOSABLE_ID)?.addDispose(()=>{s.dispose(),c.dispose()})}function Ky(e){const t=e?.content?.templateId;return t==null||t===""?void 0:String(t)}function Yy(e){e.getInstance(g.OPTIONS_SOURCE_ID)?.watch(t=>{const n=Ky(t);n!==void 0&&$g(e,n)})}var Wo={en_US:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/10c6144f.js")).then(e=>e.en_US_exports),void 0,{}.url),ru_RU:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/fc390885.js")),void 0,{}.url),uk_UA:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/60f7aa8d.js")),void 0,{}.url),es_ES:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/ec4827f1.js")),void 0,{}.url),pt_BR:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/23f020c5.js")),void 0,{}.url),de_DE:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/8035d07f.js")),void 0,{}.url),fr_FR:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/284b592e.js")),void 0,{}.url),it_IT:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/6ff64eea.js")),void 0,{}.url),pl_PL:()=>(0,Ke.__vitePreload)(()=>Promise.resolve().then(()=>ve("./static/core/740a4f32.js")),void 0,{}.url)};async function Qy(e){const t=Wo[e];if(!t){const n=Wo.en_US;return n?(await n()).default:void 0}return(await t()).default}var E0=Object.keys(Wo),Xy=e=>e==="uk"?"uk_UA":e;function Jy(e){e.getInstance(r.LOCALE_SERVICE_ID)?.useAntdLoader(t=>Qy(Xy(t)))}function Zy(e){}function $a(e,t,n){let o=!1;const i=e.watch(s=>{o||!t(s)||(o=!0,n())});o&&i.dispose()}function ev(e,t){const n=e.getInstance(g.CONFIG_SOURCE_ID);n&&$a(n,o=>!!o?.codeEnabled||!!o?.codeSideEnabled,()=>{rv(e,()=>{ov(e,()=>{nv(e,()=>{Ht(e).whenVisible(()=>{Xt(()=>{tv(t).catch(()=>{})})})})})})})}async function tv(e){await e()}function nv(e,t){const n=e.getInstance(Ns);if(!n){Xt(t);return}const o=()=>{if(n.pipeline.filledGeneration()!==void 0){t();return}Xt(o)};Xt(o)}function rv(e,t){const n=e.getInstance(r.EMAIL_DOCUMENTS_ID);if(!n)return;if(n.current()){t();return}let o=!1;const i=n.subscribe(()=>{o||!n.current()||(o=!0,t())});o&&i()}function ov(e,t){const n=e.getInstance(g.OPTIONS_SOURCE_ID);n&&$a(n,o=>!!o?.element,t)}function iv(e){ev(e,tu)}function Ua(e,t="success"){return typeof e=="string"&&(e={message:e}),r.filterUndefined({type:e.type||t,data:e.data,innerException:e.innerException,title:e.message,description:e.description,actions:e.btn,onClose:e.onClose,duration:e.duration,icon:e.icon,placement:e.placement,style:e.style,closeIcon:e.closeIcon,props:e.props,role:e.role})}var sv="bottomRight";function Ho(e,t){return typeof e=="string"||typeof e=="object"?Ua(e,t):e}var av=class extends g.Disposable{send;onNotify;onError;onSuccess;constructor(e,t,n){super(),this.send=n,this.onNotify=Tt(t,c=>c,c=>Ho(c)),this.onError=Tt(g.filter(t,c=>c.type==="error"),c=>c,c=>Ho(c,"error")),this.onSuccess=Tt(g.filter(t,c=>c.type==="success"),c=>c,c=>Ho(c));const o=this.addDisposable(new kt(this.onNotify)),i=this.addDisposable(new kt(this.onError)),s=this.addDisposable(new kt(this.onSuccess));this.addDisposable(e.watch(({handleNotify:c,handleError:d,handleSuccess:u})=>{o.setListener(c),i.setListener(d),s.setListener(u)}))}notify(e){this.send({placement:sv,...Ua(e)})}};function lv(e){e.injectFactory(bo,()=>{const t=new av(e.getInstance(g.OPTIONS_SOURCE_ID),g.getEvent(e,g.events.ON_NOTIFICATION),n=>{r.executeCommand(e,r.NOTIFY_COMMAND_ID,n)});return e.getInstance(g.DISPOSABLE_ID)?.addDisposable(t),t},!0)}function cv(e){const t=r.getEmailDocuments(e),n=i=>{e.getInstance(g.STORE_ID)?.dispatch(r.taxonomiesApi.util.invalidateTags([{type:"folder",id:i}]))},o=t.onSaved(i=>{i.created&&n("folder")});e.getInstance(g.DISPOSABLE_ID)?.addDispose(o)}function S0(e){return e}var dv=[{name:"rest.legacySections",provides:[g.REST_CLIENT_ID],setup:g.provideLegacyRestSections},{name:"canvas.resizer",provides:[Mi],setup:qy},{name:"canvas.sandboxLocale",awaits:{services:[r.LOCALE_SERVICE_ID]},setup:Vy},{name:"locale.brandCatalog",awaits:{services:[r.LOCALE_SERVICE_ID]},setup:Zy},{name:"email.restPorts",provides:[r.REST_EMAIL_PORTS_ID],setup:Fy},{name:"block.historyPort",setup:Uy},{name:"email.templatePrefetch",setup:Yy},{name:"locale.antd",awaits:{services:[r.LOCALE_SERVICE_ID]},setup:Jy},{name:"save.listsFollow",setup:cv},{name:"monaco.prewarm",awaits:{services:[g.CONFIG_SOURCE_ID]},setup:iv},{name:"notifications",provides:[bo],setup:lv},{name:"email.operations",setup:Ey}],uv=g.defineMixin(e=>{for(const t of Ay(dv))t.setup(e);return{instance:Sy(e)}}),pv=g.combineMixins([uv,O_,ay,py,wy,ky,jg,ly,$s,Us]);async function mv(e){const t=new Map;typeof e=="object"&&(e=e.code);const{amp2html:n,html2amp:o}=await(0,Ke.__vitePreload)(async()=>{const{amp2html:c,html2amp:d}=await Promise.resolve().then(()=>ve("./static/core/74c1d64b.js"));return{amp2html:c,html2amp:d}},void 0,{}.url),i=await yt.changeHtml(e,async c=>{await yt.replaceImagesInDocument(c.document,d=>r.mapper.getEscapedText(d)!==d?d:r.toAbsoluteUrl(d),t);for(const d of c.document.querySelectorAll(".em-amp-show-disabled"))d.remove();c.handleRender(async({contentDocument:d,managedNodeController:u})=>{await o(d,{mappedTags:{script:"___script"},commit:()=>u.commit()})})},[800]),s=await yt.changeHtml(e,async c=>{await yt.replaceImagesInDocument(c.document,d=>r.mapper.getEscapedText(d)!==d?d:r.toAbsoluteUrl(d),t);for(const d of c.document.querySelectorAll(".em-amp-show-only"))d.remove();await n(c.document,{mappedTags:{script:"___script"}})},[800]);return{code:e,html:s,ampHtml:i}}async function fv(){const{installDiagnostics:e}=await(0,Ke.__vitePreload)(async()=>{const{installDiagnostics:t}=await Promise.resolve().then(()=>ve("./static/core/991b35ff.js"));return{installDiagnostics:t}},void 0,{}.url);return e()}async function gv(e,t){const{initDevTools:n}=await(0,Ke.__vitePreload)(async()=>{const{initDevTools:o}=await Promise.resolve().then(()=>ve("./static/core/7d627bff.js"));return{initDevTools:o}},void 0,{}.url);n(e,t)}var hv="1.1.85-dev.7";nn.asyncMixins=pv,nn.initDevTools=gv,nn.installDiagnostics=fv,nn.parseAMP=mv,nn.version=hv});