useblocks 1.1.85-dev.9 → 1.1.102
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +91 -0
- package/README.md +74 -41
- package/compat-globals.js +1 -1
- package/iframe/.vite/manifest.json +4 -4
- package/iframe/css/sandbox.css +35 -1
- package/iframe/{iframe.bb6d921f.html → iframe-eblock.1c4e77a0.html} +2 -2
- package/iframe/{iframe-eblock.bb6d921f.html → iframe.1c4e77a0.html} +2 -2
- package/iframe/js/discussHandlers.Xh4-JUcT.js +88 -0
- package/iframe/js/{iframe-eblock.body.js → iframe-eblock.body.1c4e77a0.js} +1 -1
- package/iframe/js/iframe-eblock.js +2 -2
- package/iframe/js/iframe.body.1c4e77a0.js +319 -0
- package/iframe/js/iframe.js +2 -2
- package/package.json +8 -1
- package/runtime/THIRD_PARTY_LICENSES.txt +49 -42
- package/runtime/package.json +4 -1
- package/runtime/react/index.js +1 -1
- package/runtime/uuid/index.js +21 -0
- package/static/core/11b821ed.js +1 -0
- package/static/core/160bf060.js +104 -0
- package/static/core/1b68c0f0.js +1 -0
- package/static/core/1ed86ed3.js +1 -0
- package/static/core/26cc947d.js +1 -0
- package/static/core/{67f78cad.js → 3ec42945.js} +7 -7
- package/static/core/3fb172c7.js +1 -0
- package/static/core/448f03f8.js +1 -0
- package/static/core/44d2c046.js +1 -0
- package/static/core/{79749848.js → 4c8d0155.js} +5 -5
- package/static/core/53103851.js +4 -0
- package/static/core/{a767f327.js → 5d849eef.js} +1 -1
- package/static/core/5e7c221f.js +28 -0
- package/static/core/64be048b.js +27 -0
- package/static/core/{de07cade.js → 6a671446.js} +3 -3
- package/static/core/{db82c42b.js → 756874c6.js} +1 -1
- package/static/core/{4c3f5897.js → 847338a8.js} +2 -2
- package/static/core/91e07171.js +2 -0
- package/static/core/a2e57e5f.js +1 -0
- package/static/core/{a5996860.js → a6303cb2.js} +1 -1
- package/static/core/{9f137764.js → a98b6879.js} +1 -1
- package/static/core/ae22b7f6.js +93 -0
- package/static/core/{44a83e21.js → b653f9c5.js} +1 -1
- package/static/core/{cb46784e.js → b7aa9fec.js} +1 -1
- package/static/core/{d8bbcfbd.js → ca4dad9b.js} +2 -2
- package/static/core/{6faa23a1.js → cc180859.js} +1 -1
- package/static/core/d7666ad0.js +291 -0
- package/static/core/dcc37768.js +1 -0
- package/static/core/edf450a1.js +7 -0
- package/static/core/f1ee2bef.js +1 -0
- package/static/core/{1e3078da.js → f323e60e.js} +1 -1
- package/static/core/{175b5b0f.js → ff7d14e8.js} +1 -1
- package/static/esm/2490dab8.js +1 -0
- package/static/esm/668ee399.js +1 -0
- package/static/esm/971f1b2c.js +1 -0
- package/static/esm/f76c9d9d.js +1 -0
- package/static/umd/6639d610.js +1 -0
- package/static/umd-runtime/B7h7P1Np.js +1 -0
- package/static/umd-runtime/{DHIkHsbq.js → BAqQTgiL.js} +1 -1
- package/static/umd-runtime/{DiNHpyis.js → BB6AXfHj.js} +1 -1
- package/static/umd-runtime/{CnUGCoaH.js → BauvM4c_.js} +1 -1
- package/static/umd-runtime/{cL_ha9ef.js → CgVJ4rE0.js} +1 -1
- package/static/umd-runtime/Cvm7BS4_.js +341 -0
- package/static/umd-runtime/{BnE05QKl.js → D7DggGzi.js} +1 -1
- package/static/umd-runtime/{2iAslXEF.js → DBbch1O-.js} +1 -1
- package/static/umd-runtime/{Bcqtk2f7.js → Dqoi-pC_.js} +2 -2
- package/static/umd-runtime/{CDTBLHGd.js → G2k8ELiO.js} +3 -3
- package/static/umd-runtime/{CVtPwspX.js → SFp4nbvq.js} +1 -1
- package/static/umd-runtime/{DVB_-O4B.js → UsRzAWs2.js} +1 -1
- package/static/umd-runtime/runtime.2paN090q.js +1 -0
- package/static/umd-runtime/{ui-kit-icons.js → ui-kit-icons.DqlZwgBU.js} +1 -1
- package/static/umd-runtime/{ui-kit.js → ui-kit.CoVNet0I.js} +2 -2
- package/static/umd-runtime/{DP3QTW77.js → uk9LyZos.js} +1 -1
- package/ui-kit/icons.js +2 -0
- package/useblocks-core.1c4e77a0.js +859 -0
- package/useblocks-esm.js +11 -10
- package/{useblocks-po.bb6d921f.js → useblocks-po.1c4e77a0.js} +1 -1
- package/useblocks.d.ts +162 -28
- package/useblocks.js +39 -15
- package/vendor/@rc-component/cascader/package.json +1 -1
- package/vendor/@rc-component/dialog/es/Dialog/Content/Panel.js +3 -2
- package/vendor/@rc-component/dialog/package.json +1 -1
- package/vendor/@rc-component/image/es/Preview/index.js +3 -3
- package/vendor/@rc-component/image/package.json +1 -1
- package/vendor/@rc-component/input/es/BaseInput.js +3 -3
- package/vendor/@rc-component/input/es/Input.js +20 -27
- package/vendor/@rc-component/{textarea → input}/es/ResizableTextArea.js +5 -4
- package/vendor/@rc-component/{textarea → input}/es/TextArea.js +30 -40
- package/vendor/@rc-component/{textarea → input}/es/calculateNodeHeight.js +4 -4
- package/vendor/@rc-component/input/es/hooks/useCountDisplay.js +25 -0
- package/vendor/@rc-component/input/es/hooks/useCountExceed.js +25 -0
- package/vendor/@rc-component/input/es/hooks/useMergedValue.js +13 -0
- package/vendor/@rc-component/input/es/index.js +3 -1
- package/vendor/@rc-component/input/package.json +1 -1
- package/vendor/@rc-component/mentions/es/DropdownMenu.js +1 -1
- package/vendor/@rc-component/mentions/es/Mentions.js +35 -8
- package/vendor/@rc-component/mentions/package.json +1 -1
- package/vendor/@rc-component/menu/es/Menu.js +1 -0
- package/vendor/@rc-component/menu/es/MenuItem.js +1 -0
- package/vendor/@rc-component/menu/es/MenuItemGroup.js +1 -0
- package/vendor/@rc-component/menu/es/SubMenu/PopupTrigger.js +1 -0
- package/vendor/@rc-component/menu/es/SubMenu/index.js +1 -0
- package/vendor/@rc-component/menu/es/context/MenuContext.js +1 -0
- package/vendor/@rc-component/menu/es/hooks/useAccessibility.js +1 -0
- package/vendor/@rc-component/menu/es/hooks/useKeyRecords.js +1 -0
- package/vendor/@rc-component/menu/es/utils/commonUtil.js +1 -0
- package/vendor/@rc-component/menu/es/utils/nodeUtil.js +2 -1
- package/vendor/@rc-component/menu/es/utils/warnUtil.js +1 -0
- package/vendor/@rc-component/menu/package.json +1 -1
- package/vendor/@rc-component/notification/LICENSE +21 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/LICENSE +22 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Children/toArray.js +15 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Dom/canUseDom.js +6 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Dom/contains.js +13 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Dom/dynamicCSS.js +94 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Dom/findDOMNode.js +14 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Dom/focus.js +99 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Dom/isVisible.js +18 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Dom/shadow.js +12 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Dom/styleChecker.js +2 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/KeyCode.js +499 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/Portal.js +28 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/React/isFragment.js +12 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/React/render.js +2 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/getScrollBarSize.js +2 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/hooks/useControlledState.js +3 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/hooks/useDelayState.js +4 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/hooks/useEvent.js +9 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/hooks/useId.js +23 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/hooks/useLayoutEffect.js +26 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/hooks/useMemo.js +12 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/hooks/useMergedState.js +4 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/hooks/useState.js +24 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/hooks/useSyncState.js +20 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/index.js +36 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/is.js +21 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/isEqual.js +35 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/isMobile.js +11 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/mergeProps.js +14 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/omit.js +1 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/pickAttrs.js +50 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/proxyObject.js +1 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/raf.js +36 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/ref.js +38 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/test/domHook.js +36 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/utils/get.js +11 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/utils/set.js +58 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/es/warning.js +46 -0
- package/vendor/@rc-component/notification/_/@rc-component/util/package.json +6 -0
- package/vendor/@rc-component/notification/es/Notification.js +129 -0
- package/vendor/@rc-component/notification/es/NotificationList/Content.js +33 -0
- package/vendor/@rc-component/notification/es/NotificationList/index.js +174 -0
- package/vendor/@rc-component/notification/es/NotificationProvider.js +4 -3
- package/vendor/@rc-component/notification/es/Notifications.js +28 -31
- package/vendor/@rc-component/notification/es/Progress.js +10 -0
- package/vendor/@rc-component/notification/es/hooks/useClosable.js +30 -0
- package/vendor/@rc-component/notification/es/hooks/useListPosition/index.js +50 -0
- package/vendor/@rc-component/notification/es/hooks/useListPosition/useSizes.js +33 -0
- package/vendor/@rc-component/notification/es/hooks/useNoticeTimer.js +58 -0
- package/vendor/@rc-component/notification/es/hooks/useNotification.js +27 -18
- package/vendor/@rc-component/notification/es/hooks/useStack.js +4 -4
- package/vendor/@rc-component/notification/es/index.js +4 -2
- package/vendor/@rc-component/notification/package.json +1 -1
- package/vendor/@rc-component/picker/es/PickerInput/Selector/SingleSelector/MultipleDates.js +13 -3
- package/vendor/@rc-component/picker/es/PickerInput/Selector/SingleSelector/index.js +3 -1
- package/vendor/@rc-component/picker/es/PickerInput/SinglePicker.js +2 -1
- package/vendor/@rc-component/picker/package.json +1 -1
- package/vendor/@rc-component/table/LICENSE +21 -0
- package/vendor/@rc-component/table/es/Body/MeasureCell.js +1 -0
- package/vendor/@rc-component/table/es/Body/MeasureRow.js +1 -0
- package/vendor/@rc-component/table/es/Cell/useCellRender.js +1 -0
- package/vendor/@rc-component/table/es/FixedHolder/index.js +1 -0
- package/vendor/@rc-component/table/es/Table.js +17 -9
- package/vendor/@rc-component/table/es/VirtualTable/BodyGrid.js +10 -4
- package/vendor/@rc-component/table/es/VirtualTable/BodyLine.js +13 -5
- package/vendor/@rc-component/table/es/hooks/useColumns/index.js +1 -0
- package/vendor/@rc-component/table/es/hooks/useExpand.js +1 -0
- package/vendor/@rc-component/table/es/hooks/useFixedInfo.js +1 -0
- package/vendor/@rc-component/table/es/hooks/useSticky.js +1 -0
- package/vendor/@rc-component/table/es/index.js +2 -1
- package/vendor/@rc-component/table/es/stickyScrollBar.js +1 -0
- package/vendor/@rc-component/table/es/utils/legacyUtil.js +1 -0
- package/vendor/@rc-component/table/es/utils/offsetUtil.js +1 -0
- package/vendor/@rc-component/table/package.json +1 -1
- package/vendor/@rc-component/tabs/es/TabNavList/OperationNode.js +4 -2
- package/vendor/@rc-component/tabs/es/TabNavList/TabNode.js +5 -4
- package/vendor/@rc-component/tabs/es/TabNavList/index.js +11 -4
- package/vendor/@rc-component/tabs/es/Tabs.js +1 -0
- package/vendor/@rc-component/tabs/es/hooks/useAnimateConfig.js +1 -0
- package/vendor/@rc-component/tabs/es/hooks/useIndicator.js +1 -0
- package/vendor/@rc-component/tabs/es/hooks/useUpdate.js +1 -0
- package/vendor/@rc-component/tabs/package.json +1 -1
- package/vendor/@rc-component/tour/es/TourStep/DefaultPanel.js +4 -1
- package/vendor/@rc-component/tour/package.json +1 -1
- package/vendor/@rc-component/tree/es/MotionTreeNode.js +1 -0
- package/vendor/@rc-component/tree/es/NodeList.js +2 -2
- package/vendor/@rc-component/tree/es/Tree.js +4 -5
- package/vendor/@rc-component/tree/es/TreeNode.js +7 -2
- package/vendor/@rc-component/tree/es/index.js +3 -0
- package/vendor/@rc-component/tree/es/useUnmount.js +1 -0
- package/vendor/@rc-component/tree/es/util.js +1 -0
- package/vendor/@rc-component/tree/es/utils/conductUtil.js +1 -0
- package/vendor/@rc-component/tree/es/utils/treeUtil.js +1 -0
- package/vendor/@rc-component/tree/package.json +1 -1
- package/vendor/@rc-component/tree-select/package.json +1 -1
- package/vendor/@rc-component/util/es/index.js +10 -10
- package/vendor/antd/es/_util/ActionButton.js +2 -3
- package/vendor/antd/es/_util/ContextIsolator.js +1 -1
- package/vendor/antd/es/_util/PurePanel.js +7 -4
- package/vendor/antd/es/_util/convertToTooltipProps.js +2 -2
- package/vendor/antd/es/_util/fallbackProp.js +15 -0
- package/vendor/antd/es/_util/gapSize.js +2 -1
- package/vendor/antd/es/_util/getRenderPropValue.js +2 -1
- package/vendor/antd/es/_util/getScroll.js +4 -4
- package/vendor/antd/es/_util/hooks/index.js +2 -2
- package/vendor/antd/es/_util/hooks/useAllowClear.js +25 -0
- package/vendor/antd/es/_util/hooks/useClosable.js +6 -5
- package/vendor/antd/es/_util/hooks/{useMergeSemantic.js → useMergeSemantic/index.js} +14 -24
- package/vendor/antd/es/_util/hooks/useMergeSemantic/utils.js +14 -0
- package/vendor/antd/es/_util/hooks/useMergedMask.js +2 -1
- package/vendor/antd/es/_util/is.js +27 -0
- package/vendor/antd/es/_util/motion.js +8 -8
- package/vendor/antd/es/_util/normalizeIcon.js +9 -0
- package/vendor/antd/es/_util/placements.js +2 -1
- package/vendor/antd/es/_util/reactNode.js +2 -1
- package/vendor/antd/es/_util/responsiveObserver.js +3 -2
- package/vendor/antd/es/_util/scrollTo.js +3 -1
- package/vendor/antd/es/_util/styleChecker.js +1 -0
- package/vendor/antd/es/_util/throttleByAnimationFrame.js +1 -0
- package/vendor/antd/es/_util/toList.js +1 -1
- package/vendor/antd/es/_util/wave/WaveEffect.js +3 -1
- package/vendor/antd/es/_util/wave/index.js +14 -4
- package/vendor/antd/es/_util/wave/util.js +5 -3
- package/vendor/antd/es/alert/Alert.js +12 -10
- package/vendor/antd/es/alert/ErrorBoundary.js +1 -1
- package/vendor/antd/es/alert/style/index.js +16 -10
- package/vendor/antd/es/anchor/Anchor.js +23 -16
- package/vendor/antd/es/anchor/AnchorLink.js +4 -4
- package/vendor/antd/es/app/App.js +7 -3
- package/vendor/antd/es/auto-complete/AutoComplete.js +7 -8
- package/vendor/antd/es/avatar/Avatar.js +5 -3
- package/vendor/antd/es/back-top/index.js +1 -0
- package/vendor/antd/es/badge/Badge.js +5 -6
- package/vendor/antd/es/badge/Ribbon.js +1 -2
- package/vendor/antd/es/badge/style/index.js +4 -3
- package/vendor/antd/es/border-beam/BorderBeam.js +42 -0
- package/vendor/antd/es/border-beam/BorderBeamEffect.js +24 -0
- package/vendor/antd/es/border-beam/hooks/useBorderSize.js +37 -0
- package/vendor/antd/es/border-beam/hooks/useChildDom.js +24 -0
- package/vendor/antd/es/border-beam/index.js +7 -0
- package/vendor/antd/es/border-beam/style/index.js +60 -0
- package/vendor/antd/es/border-beam/util.js +26 -0
- package/vendor/antd/es/breadcrumb/Breadcrumb.js +1 -2
- package/vendor/antd/es/breadcrumb/BreadcrumbItem.js +1 -1
- package/vendor/antd/es/breadcrumb/useItemRender.js +3 -2
- package/vendor/antd/es/button/Button.js +7 -6
- package/vendor/antd/es/button/buttonHelpers.js +4 -8
- package/vendor/antd/es/button/index.js +2 -2
- package/vendor/antd/es/button/style/index.js +5 -0
- package/vendor/antd/es/calendar/generateCalendar.js +20 -8
- package/vendor/antd/es/card/Card.js +5 -7
- package/vendor/antd/es/card/CardMeta.js +1 -2
- package/vendor/antd/es/carousel/index.js +2 -1
- package/vendor/antd/es/cascader/Panel.js +1 -1
- package/vendor/antd/es/cascader/index.js +23 -16
- package/vendor/antd/es/cascader/style/columns.js +6 -2
- package/vendor/antd/es/checkbox/Checkbox.js +2 -3
- package/vendor/antd/es/checkbox/Group.js +2 -1
- package/vendor/antd/es/checkbox/style/index.js +1 -5
- package/vendor/antd/es/checkbox/useBubbleLock.js +1 -0
- package/vendor/antd/es/collapse/Collapse.js +3 -3
- package/vendor/antd/es/collapse/style/index.js +1 -4
- package/vendor/antd/es/color-picker/ColorPicker.js +1 -2
- package/vendor/antd/es/color-picker/ColorPickerPanel.js +2 -1
- package/vendor/antd/es/color-picker/components/ColorTrigger.js +3 -1
- package/vendor/antd/es/color-picker/components/PanelPicker/index.js +1 -0
- package/vendor/antd/es/config-provider/hooks/useSize.js +3 -2
- package/vendor/antd/es/config-provider/hooks/useTheme.js +2 -0
- package/vendor/antd/es/config-provider/index.js +11 -3
- package/vendor/antd/es/date-picker/generatePicker/generateRangePicker.js +20 -10
- package/vendor/antd/es/date-picker/generatePicker/generateSinglePicker.js +17 -8
- package/vendor/antd/es/date-picker/generatePicker/useSuffixIcon.js +1 -1
- package/vendor/antd/es/date-picker/hooks/useMergedPickerSemantic.js +1 -2
- package/vendor/antd/es/date-picker/style/index.js +13 -3
- package/vendor/antd/es/date-picker/style/multiple.js +3 -4
- package/vendor/antd/es/date-picker/style/panel.js +5 -20
- package/vendor/antd/es/date-picker/util.js +14 -13
- package/vendor/antd/es/descriptions/Cell.js +2 -3
- package/vendor/antd/es/descriptions/hooks/useItems.js +2 -1
- package/vendor/antd/es/descriptions/index.js +3 -3
- package/vendor/antd/es/divider/index.js +3 -2
- package/vendor/antd/es/drawer/Drawer.js +10 -5
- package/vendor/antd/es/drawer/DrawerPanel.js +3 -2
- package/vendor/antd/es/dropdown/dropdown.js +11 -8
- package/vendor/antd/es/dropdown/style/index.js +2 -6
- package/vendor/antd/es/empty/index.js +1 -2
- package/vendor/antd/es/flex/index.js +2 -2
- package/vendor/antd/es/float-button/BackTop.js +1 -0
- package/vendor/antd/es/float-button/FloatButton.js +3 -3
- package/vendor/antd/es/float-button/FloatButtonGroup.js +2 -2
- package/vendor/antd/es/form/ErrorList.js +13 -6
- package/vendor/antd/es/form/Form.js +7 -6
- package/vendor/antd/es/form/FormItem/ItemHolder.js +1 -1
- package/vendor/antd/es/form/FormItem/index.js +6 -6
- package/vendor/antd/es/form/FormItemInput.js +5 -3
- package/vendor/antd/es/form/FormItemLabel.js +2 -1
- package/vendor/antd/es/form/FormList.js +1 -0
- package/vendor/antd/es/form/hooks/useChildren.js +4 -3
- package/vendor/antd/es/form/hooks/useForm.js +3 -1
- package/vendor/antd/es/form/hooks/useFrameState.js +1 -0
- package/vendor/antd/es/form/hooks/useItemRef.js +7 -5
- package/vendor/antd/es/form/style/index.js +1 -3
- package/vendor/antd/es/grid/col.js +5 -7
- package/vendor/antd/es/grid/hooks/useBreakpoint.js +1 -0
- package/vendor/antd/es/grid/hooks/useGutter.js +2 -1
- package/vendor/antd/es/grid/row.js +7 -6
- package/vendor/antd/es/image/PreviewGroup.js +1 -2
- package/vendor/antd/es/image/Progress.js +58 -0
- package/vendor/antd/es/image/hooks/useMergedPreviewConfig.js +3 -1
- package/vendor/antd/es/image/hooks/usePlaceholderConfig.js +15 -0
- package/vendor/antd/es/image/hooks/usePreviewConfig.js +3 -2
- package/vendor/antd/es/image/index.js +36 -5
- package/vendor/antd/es/image/style/index.js +114 -4
- package/vendor/antd/es/image/style/progressAnimation.js +26 -0
- package/vendor/antd/es/index.js +2 -1
- package/vendor/antd/es/input/Input.js +9 -4
- package/vendor/antd/es/input/OTP/OTPInput.js +1 -0
- package/vendor/antd/es/input/OTP/index.js +3 -3
- package/vendor/antd/es/input/Password.js +45 -26
- package/vendor/antd/es/input/Search.js +6 -5
- package/vendor/antd/es/input/TextArea.js +13 -7
- package/vendor/antd/es/input/style/index.js +17 -11
- package/vendor/antd/es/input/style/otp.js +2 -1
- package/vendor/antd/es/input/style/variants.js +16 -10
- package/vendor/antd/es/input-number/index.js +3 -3
- package/vendor/antd/es/input-number/style/index.js +9 -9
- package/vendor/antd/es/layout/Sider.js +3 -2
- package/vendor/antd/es/list/index.js +5 -3
- package/vendor/antd/es/locale/en_US.js +3 -1
- package/vendor/antd/es/locale/ru_RU.js +3 -1
- package/vendor/antd/es/locale/useLocale.js +2 -1
- package/vendor/antd/es/masonry/Masonry.js +4 -3
- package/vendor/antd/es/mentions/index.js +28 -14
- package/vendor/antd/es/menu/MenuItem.js +2 -1
- package/vendor/antd/es/menu/OverrideContext.js +1 -0
- package/vendor/antd/es/menu/SubMenu.js +1 -1
- package/vendor/antd/es/menu/menu.js +5 -5
- package/vendor/antd/es/menu/style/index.js +21 -36
- package/vendor/antd/es/menu/style/vertical.js +2 -1
- package/vendor/antd/es/message/PureList.js +49 -0
- package/vendor/antd/es/message/PurePanel.js +28 -36
- package/vendor/antd/es/message/index.js +6 -3
- package/vendor/antd/es/message/style/index.js +102 -99
- package/vendor/antd/es/message/useMessage.js +29 -33
- package/vendor/antd/es/message/util.js +1 -1
- package/vendor/antd/es/modal/ConfirmDialog.js +11 -9
- package/vendor/antd/es/modal/Modal.js +12 -7
- package/vendor/antd/es/modal/PurePanel.js +1 -2
- package/vendor/antd/es/modal/confirm.js +4 -3
- package/vendor/antd/es/modal/shared.js +3 -2
- package/vendor/antd/es/modal/useModal/HookModal.js +2 -1
- package/vendor/antd/es/notification/PureList.js +46 -0
- package/vendor/antd/es/notification/PurePanel.js +37 -56
- package/vendor/antd/es/notification/hooks/useStackConfig.js +13 -0
- package/vendor/antd/es/notification/index.js +3 -1
- package/vendor/antd/es/notification/style/index.js +103 -170
- package/vendor/antd/es/notification/style/notification.js +191 -0
- package/vendor/antd/es/notification/style/placement.js +117 -60
- package/vendor/antd/es/notification/useNotification.js +37 -40
- package/vendor/antd/es/notification/util.js +9 -50
- package/vendor/antd/es/pagination/Pagination.js +1 -2
- package/vendor/antd/es/pagination/useShowSizeChanger.js +2 -1
- package/vendor/antd/es/popconfirm/PurePanel.js +4 -1
- package/vendor/antd/es/popconfirm/index.js +1 -2
- package/vendor/antd/es/popover/PurePanel.js +1 -2
- package/vendor/antd/es/popover/index.js +1 -2
- package/vendor/antd/es/progress/Circle.js +2 -1
- package/vendor/antd/es/progress/progress.js +3 -3
- package/vendor/antd/es/progress/utils.js +4 -3
- package/vendor/antd/es/qr-code/index.js +4 -4
- package/vendor/antd/es/radio/group.js +4 -3
- package/vendor/antd/es/radio/radio.js +2 -2
- package/vendor/antd/es/radio/style/index.js +1 -1
- package/vendor/antd/es/rate/index.js +2 -4
- package/vendor/antd/es/result/index.js +6 -5
- package/vendor/antd/es/result/style/index.js +10 -6
- package/vendor/antd/es/segmented/index.js +5 -3
- package/vendor/antd/es/select/index.js +23 -12
- package/vendor/antd/es/select/style/dropdown.js +1 -1
- package/vendor/antd/es/select/style/select-input.js +23 -15
- package/vendor/antd/es/select/useIcons.js +43 -26
- package/vendor/antd/es/skeleton/Element.js +2 -1
- package/vendor/antd/es/skeleton/Skeleton.js +3 -3
- package/vendor/antd/es/slider/SliderTooltip.js +1 -0
- package/vendor/antd/es/slider/index.js +5 -3
- package/vendor/antd/es/slider/useRafLock.js +1 -0
- package/vendor/antd/es/space/Compact.js +1 -1
- package/vendor/antd/es/space/Item.js +1 -1
- package/vendor/antd/es/space/index.js +2 -2
- package/vendor/antd/es/space/style/addon.js +5 -2
- package/vendor/antd/es/spin/Indicator/Progress.js +2 -1
- package/vendor/antd/es/spin/index.js +1 -2
- package/vendor/antd/es/splitter/Panel.js +7 -3
- package/vendor/antd/es/splitter/SplitBar.js +5 -4
- package/vendor/antd/es/splitter/Splitter.js +9 -6
- package/vendor/antd/es/splitter/hooks/useItems.js +2 -1
- package/vendor/antd/es/splitter/hooks/useSizes.js +1 -1
- package/vendor/antd/es/splitter/style/index.js +8 -6
- package/vendor/antd/es/statistic/Number.js +8 -4
- package/vendor/antd/es/statistic/Statistic.js +14 -10
- package/vendor/antd/es/steps/index.js +4 -4
- package/vendor/antd/es/style/compact-item-vertical.js +2 -1
- package/vendor/antd/es/style/compact-item.js +6 -6
- package/vendor/antd/es/switch/index.js +1 -2
- package/vendor/antd/es/table/InternalTable.js +23 -14
- package/vendor/antd/es/table/hooks/useFilledColumns.js +23 -0
- package/vendor/antd/es/table/hooks/useFilter/FilterDropdown.js +22 -16
- package/vendor/antd/es/table/hooks/useFilter/FilterWrapper.js +1 -0
- package/vendor/antd/es/table/hooks/useFilter/index.js +34 -18
- package/vendor/antd/es/table/hooks/useLazyKVMap.js +2 -1
- package/vendor/antd/es/table/hooks/usePagination.js +7 -4
- package/vendor/antd/es/table/hooks/useSelection.js +32 -21
- package/vendor/antd/es/table/hooks/useSorter.js +10 -5
- package/vendor/antd/es/table/style/bordered.js +5 -27
- package/vendor/antd/es/table/style/empty.js +1 -4
- package/vendor/antd/es/table/style/index.js +1 -4
- package/vendor/antd/es/table/util.js +6 -6
- package/vendor/antd/es/tabs/hooks/useAnimateConfig.js +2 -1
- package/vendor/antd/es/tabs/index.js +1 -2
- package/vendor/antd/es/tag/CheckableTagGroup.js +8 -5
- package/vendor/antd/es/tag/hooks/useColor.js +4 -3
- package/vendor/antd/es/tag/index.js +13 -7
- package/vendor/antd/es/theme/themes/dark/colors.js +2 -1
- package/vendor/antd/es/theme/themes/default/colors.js +2 -1
- package/vendor/antd/es/theme/useToken.js +2 -2
- package/vendor/antd/es/theme/util/alias.js +34 -29
- package/vendor/antd/es/timeline/Timeline.js +3 -4
- package/vendor/antd/es/tooltip/PurePanel.js +1 -2
- package/vendor/antd/es/tooltip/UniqueProvider/index.js +2 -1
- package/vendor/antd/es/tooltip/index.js +9 -7
- package/vendor/antd/es/tour/PurePanel.js +2 -2
- package/vendor/antd/es/tour/index.js +1 -1
- package/vendor/antd/es/tour/panelRender.js +4 -2
- package/vendor/antd/es/transfer/ListBody.js +3 -1
- package/vendor/antd/es/transfer/ListItem.js +2 -1
- package/vendor/antd/es/transfer/Section.js +17 -8
- package/vendor/antd/es/transfer/index.js +51 -16
- package/vendor/antd/es/transfer/style/index.js +5 -1
- package/vendor/antd/es/tree/Tree.js +1 -2
- package/vendor/antd/es/tree/style/index.js +5 -1
- package/vendor/antd/es/tree/utils/iconUtil.js +5 -4
- package/vendor/antd/es/tree-select/index.js +3 -3
- package/vendor/antd/es/typography/Base/CopyBtn.js +3 -2
- package/vendor/antd/es/typography/Base/Ellipsis.js +3 -3
- package/vendor/antd/es/typography/Base/index.js +38 -31
- package/vendor/antd/es/typography/Editable.js +10 -4
- package/vendor/antd/es/typography/Link.js +1 -0
- package/vendor/antd/es/typography/Text.js +2 -1
- package/vendor/antd/es/typography/Typography.js +20 -10
- package/vendor/antd/es/typography/hooks/useCopyClick.js +2 -1
- package/vendor/antd/es/typography/hooks/useMergedConfig.js +13 -7
- package/vendor/antd/es/typography/hooks/useTooltipProps.js +2 -1
- package/vendor/antd/es/typography/hooks/useTypographySemantic.js +33 -0
- package/vendor/antd/es/typography/style/index.js +12 -27
- package/vendor/antd/es/typography/style/mixins.js +46 -13
- package/vendor/antd/es/upload/Upload.js +13 -7
- package/vendor/antd/es/upload/UploadList/ListItem.js +6 -5
- package/vendor/antd/es/upload/UploadList/index.js +4 -3
- package/vendor/antd/es/upload/utils.js +18 -1
- package/vendor/antd/es/version/version.js +1 -1
- package/vendor/antd/es/watermark/index.js +6 -4
- package/vendor/antd/es/watermark/useSingletonCache.js +1 -0
- package/vendor/antd/es/watermark/useWatermark.js +3 -3
- package/vendor/antd/package.json +1 -1
- package/vendor/useblocks-ui-kit/es/components/DataEntry/Input/index.js +1 -1
- package/vendor/useblocks-ui-kit/es/components/General/EmIcons/deprecationNotice.js +1 -1
- package/vendor/useblocks-ui-kit/package.json +1 -1
- package/vite/index.cjs +2 -2
- package/vite/index.js +2 -2
- package/iframe/js/discussHandlers.ozU2Hn_l.js +0 -87
- package/iframe/js/iframe.body.js +0 -319
- package/static/core/1c535081.js +0 -1
- package/static/core/1cee0d36.js +0 -1
- package/static/core/4fbdd8b6.js +0 -2
- package/static/core/55a38638.js +0 -93
- package/static/core/605c665e.js +0 -28
- package/static/core/68cbe23d.js +0 -1
- package/static/core/89431649.js +0 -7
- package/static/core/8b821a61.js +0 -1
- package/static/core/9718977a.js +0 -1
- package/static/core/b7e9202e.js +0 -27
- package/static/core/b877f7b4.js +0 -1
- package/static/core/baded0c1.js +0 -1
- package/static/core/c6cc104d.js +0 -4
- package/static/core/d70aac44.js +0 -291
- package/static/core/e0d71533.js +0 -100
- package/static/core/fb57f60b.js +0 -1
- package/static/core/fe756e4d.js +0 -1
- package/static/esm/349f9e2c.js +0 -1
- package/static/esm/50fbfdf6.js +0 -1
- package/static/media/icon-sets/lucide.json +0 -6275
- package/static/media/icon-sets/tabler.json +0 -19336
- package/static/umd-runtime/Cl8heeC3.js +0 -1
- package/static/umd-runtime/D0xo8o9c.js +0 -335
- package/static/umd-runtime/runtime.js +0 -1
- package/useblocks-core.bb6d921f.js +0 -859
- package/vendor/@rc-component/notification/es/Notice.js +0 -106
- package/vendor/@rc-component/notification/es/NoticeList.js +0 -98
- package/vendor/@rc-component/textarea/LICENSE.md +0 -9
- package/vendor/@rc-component/textarea/es/index.js +0 -6
- package/vendor/@rc-component/textarea/package.json +0 -6
- package/vendor/antd/es/_util/extendsObject.js +0 -12
- package/vendor/antd/es/_util/getAllowClear.js +0 -12
- package/vendor/antd/es/_util/isNonNullable.js +0 -6
- package/vendor/antd/es/_util/isPrimitive.js +0 -4
- package/vendor/antd/es/notification/style/pure-panel.js +0 -18
- package/vendor/antd/es/notification/style/stack.js +0 -85
- /package/static/monaco/{index.js → index.CO7s5UdA.js} +0 -0
- /package/static/umd-runtime/{delivery-libs.js → delivery-libs.3Svr0avG.js} +0 -0
package/useblocks-esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{n as Go,r as bl}from"./static/esm/971f1b2c.js";import{A as Vo,At as rn,B as Cr,C as gi,Ct as Yn,D as yl,Dt as El,E as Tr,Et as _l,F as Ar,Ft as Se,G as Ot,H as Ht,I as wl,It as Sl,J as Il,K as Cl,L as qo,Lt as Tl,M as Al,Mt as Rl,N as Pl,Nt as nt,O as Dl,Ot as pe,P as Ol,Pt as F,Q as xt,R as xl,Rt as ie,S as Ml,St as kl,T as Ll,Tt as vi,U as Nl,V as Fl,W as jl,X as Rr,Y as Xe,Z as bi,_ as Pr,_t as j,a as Bl,at as U,b as Ce,bt as Ze,c as zo,ct as Dr,d as $,dt as Te,et as Wo,f as Ul,ft as Hl,g as $l,gt as Gl,h as Vl,ht as ql,i as zl,it as oe,j as Wl,jt as Y,k as Kl,kt as Or,l as Yl,lt as se,m as Xl,mt as yi,n as Jl,nt as Ko,o as Ql,ot as Ae,p as Mt,pt as Zl,q as ec,r as tc,rt as Yo,s as ot,st as hn,t as he,tt as xe,u as nc,ut as xr,v as rc,vt as kt,w as ic,wt as oc,x as sc,xt as Me,y as Mr,yt as ue,z as Xo}from"./static/esm/668ee399.js";import{t as ac}from"./static/esm/f76c9d9d.js";(function(){"use strict";var e=window.__useblocks__=window.__useblocks__||{};e.__facadeSentinel="@shared-runtime:init-complete",e.publicPath||(e.publicPath=(function(){var m=(function(){if(typeof document<"u"&&document.querySelector)try{var D=document.querySelector('script[src*="useblocks-esm.js"]')||document.querySelector('script[src*="useblocks.js"]');if(D&&D.src)return D.src.substring(0,D.src.lastIndexOf("/")+1)}catch{}try{var L=import.meta.url;if(L)return L.substring(0,L.lastIndexOf("/")+1)}catch{}return"./"})();m||(m="./");try{var l=String(m);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(l)||l.indexOf("//")===0)return l.charAt(l.length-1)==="/"?l:l+"/";var u=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",p=u?new URL(l,u).href:l;return p.charAt(p.length-1)==="/"?p:p+"/"}catch{var R=String(m);return R.charAt(R.length-1)==="/"?R:R+"/"}})()),typeof e.setPublicPath!="function"&&(e.setPublicPath=function(m){return e.publicPath=(function(){var l=m==null?"":String(m);l||(l="./");try{var u=String(l);if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0)return u.charAt(u.length-1)==="/"?u:u+"/";var p=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"",R=p?new URL(u,p).href:u;return R.charAt(R.length-1)==="/"?R:R+"/"}catch{var D=String(l);return D.charAt(D.length-1)==="/"?D:D+"/"}})(),e.publicPath}),e.__publicPathDiagnosticsLogged||(e.__publicPathDiagnosticsLogged=!0,(function(){var m=String(e.publicPath||"");if(m.indexOf("file:")!==0&&!(m&&m!=="./")){var l="";try{if(typeof window<"u"){for(var u in window)if(!(u==="__useblocks__"||!/^__[^_].*__$/.test(u))){var p;try{p=window[u]}catch{continue}if(p&&typeof p=="object"&&p.publicPath){l=" Another product namespace ("+u+") has publicPath set — verify the host bundler plugin matches the installed npm brand.";break}}}}catch{}}})()),e.assetUrl||(e.assetUrl=function(m){function l(I){try{var O=typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:"";return O?new URL(String(I||""),O).href:String(I||"")}catch{return String(I||"")}}var u=String(m||"");if(!u)return"";if(/^(?:data:|blob:)/.test(u))return u;if(/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(u)||u.indexOf("//")===0||u.charAt(0)==="/")return l(u);var p=u.replace(/^\.\/+/,"").replace(/^\/+/,""),R="static/media".replace(/^\.\/+/,"").replace(/^\/+/,"").replace(/\/+$/,""),D=R&&p.indexOf(R+"/")!==0?R+"/"+p:p,L=e.publicPath||"./";try{return new URL(D,L).href}catch{return L.slice(-1)!=="/"&&(L+="/"),l(L+D)}}),e.version||(e.version="1.1.102");var t=e.modules=Object.create(null);if(typeof e.define!="function"){var n=`/**
|
|
2
2
|
* Async AMD Loader (IIFE version for injection)
|
|
3
3
|
*
|
|
4
4
|
* This file is injected at the beginning of iframe entry points.
|
|
@@ -993,14 +993,15 @@ import{t as Li}from"./static/esm/50fbfdf6.js";import{$ as xs,A as Ms,At as N,B a
|
|
|
993
993
|
__amdEnv.syncRequire = syncRequire;
|
|
994
994
|
__amdEnv.diagnosticsBuffer = diagBuffer;
|
|
995
995
|
})();
|
|
996
|
-
`,r=new Function("__amdEnv",n);r(e),typeof e.require=="function"&&typeof e.require.config=="function"&&e.require.config({baseUrl:"./",paths:{core:"useblocks-core.bb6d921f.js",po:"useblocks-po.bb6d921f.js",monaco:"static/monaco/index.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(f){var c,d=function(){return c||(c=Promise.resolve().then(f))};return{then:function(p,h){return d().then(p,h)},catch:function(p){return d().catch(p)},finally:function(p){return d().finally(p)}}},o=i(function(){return e.require(["__delivery__/libs"]).then(function(f){return f[0]})});t.React=i(function(){return o.then(function(f){return f.React})}),t.ReactDom=i(function(){return o.then(function(f){return f.ReactDom})}),t.ReactDomClient=i(function(){return o.then(function(f){return f.ReactDomClient})}),t.ReactJsxRuntime=i(function(){return o.then(function(f){return f.ReactJsxRuntime})}),t.ReactJsxDevRuntime=i(function(){return o.then(function(f){return f.ReactJsxDevRuntime})}),t.AntDesignIconBase=i(function(){return o.then(function(f){return f.AntDesignIconBase})}),t.AntDesignCssinjs=i(function(){return o.then(function(f){return f.AntDesignCssinjs})}),t.Classnames=i(function(){return o.then(function(f){return f.Classnames})}),t.Dayjs=i(function(){return o.then(function(f){return f.Dayjs})});var s=i(function(){return Promise.all([o]).then(function(f){var c=f[0]||Object.create(null),d=Object.create(null);for(var p in c)Object.prototype.hasOwnProperty.call(c,p)&&(d[p]=c[p]);for(var h in d)Object.prototype.hasOwnProperty.call(d,h)&&(t[h]=d[h]);return d})}),a={},l={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",AntDesignIcons:"[runtime] `@ant-design/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKit:"[runtime] `useblocks-ui-kit` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKitIcons:"[runtime] `useblocks-ui-kit/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator."},u={Antd:"[runtime] `antd` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated.",AntDesignIcons:"[runtime] `@ant-design/icons` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated.",UiKit:"[runtime] `useblocks-ui-kit` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated.",UiKitIcons:"[runtime] `useblocks-ui-kit/icons` is served from the host runtime for backward compatibility. Rebuild the plugin with the current CLI to bundle it from its own copy of the package. This compatibility layer is deprecated."},m=Object.create(null);if(e.registerCompat=function(f){if(!(!f||typeof f!="object"))for(var c in f)Object.prototype.hasOwnProperty.call(f,c)&&(m[c]=f[c])},e.__compatPending){for(var v=0;v<e.__compatPending.length;v+=1)e.registerCompat(e.__compatPending[v]);e.__compatPending=void 0}for(var E in l)Object.prototype.hasOwnProperty.call(l,E)&&(function(f,c,d){var p=!1,h=function(){if(!(f in m))throw new Error(c);return m[f]};Object.defineProperty(t,f,{configurable:!0,enumerable:!0,get:function(){var w=h();return p||(p=!0),w},set:function(w){m[f]=w}}),Object.defineProperty(a,f,{configurable:!0,enumerable:!0,get:h,set:function(w){m[f]=w}})})(E,l[E],u[E]);var g=t;for(var _ in a)Object.prototype.hasOwnProperty.call(a,_)&&(g===t&&(g=Object.create(t)),Object.defineProperty(g,_,Object.getOwnPropertyDescriptor(a,_)));var b=s,y=[],S=function(){for(var f=[],c=0;c<y.length;c+=1)(function(d){var p=t[d];p&&typeof p.then=="function"&&f.push(Promise.resolve(p).then(function(h){t[d]=h}))})(y[c]);return Promise.all(f)},I=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(S).then(function(){if(typeof I=="function")return I.call(e)})},typeof e.define=="function"){let f=function(c){if(!c||typeof c!="object"&&typeof c!="function"||c.__esModule)return c;if(A){var d=A.get(c);if(d)return d}var p=Object.create(null);Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var h=Reflect.ownKeys(c),w=0;w<h.length;w++){var T=h[w];if(T!=="__esModule"){var D=Object.getOwnPropertyDescriptor(c,T);D&&Object.defineProperty(p,T,D)}}return Object.prototype.hasOwnProperty.call(p,"default")||Object.defineProperty(p,"default",{enumerable:!0,value:c,writable:!1}),A&&A.set(c,p),p};var A=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var c=g.React;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.React)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.React;return f(p)})}),e.define("useblocks/runtime/react",[],function(){var c=g.React;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.React)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.React;return f(p)})}),e.define("react-dom",[],function(){var c=g.ReactDom;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.ReactDom)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.ReactDom;return f(p)})}),e.define("useblocks/runtime/react-dom",[],function(){var c=g.ReactDom;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.ReactDom)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.ReactDom;return f(p)})}),e.define("react-dom/client",[],function(){var c=g.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.ReactDomClient)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.ReactDomClient;return f(p)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var c=g.ReactDomClient;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.ReactDomClient)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.ReactDomClient;return f(p)})}),e.define("react/jsx-runtime",[],function(){var c=g.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.ReactJsxRuntime)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.ReactJsxRuntime;return f(p)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var c=g.ReactJsxRuntime;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.ReactJsxRuntime)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.ReactJsxRuntime;return f(p)})}),e.define("react/jsx-dev-runtime",[],function(){var c=g.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.ReactJsxDevRuntime)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.ReactJsxDevRuntime;return f(p)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var c=g.ReactJsxDevRuntime;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.ReactJsxDevRuntime)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.ReactJsxDevRuntime;return f(p)})}),e.define("antd",[],function(){var c=g.Antd;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.Antd)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.Antd;return f(p)})}),e.define("useblocks/runtime/antd",[],function(){var c=g.Antd;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.Antd)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.Antd;return f(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var c=g.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.AntDesignIconBase)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.AntDesignIconBase;return f(p)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var c=g.AntDesignIconBase;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.AntDesignIconBase)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.AntDesignIconBase;return f(p)})}),e.define("@ant-design/icons",[],function(){var c=g.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.AntDesignIcons)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.AntDesignIcons;return f(p)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var c=g.AntDesignIcons;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.AntDesignIcons)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.AntDesignIcons;return f(p)})}),e.define("@ant-design/cssinjs",[],function(){var c=g.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.AntDesignCssinjs)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.AntDesignCssinjs;return f(p)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var c=g.AntDesignCssinjs;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.AntDesignCssinjs)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.AntDesignCssinjs;return f(p)})}),e.define("classnames",[],function(){var c=g.Classnames;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.Classnames)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.Classnames;return f(p)})}),e.define("useblocks/runtime/classnames",[],function(){var c=g.Classnames;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.Classnames)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.Classnames;return f(p)})}),e.define("dayjs",[],function(){var c=g.Dayjs;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.Dayjs)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.Dayjs;return f(p)})}),e.define("useblocks/runtime/dayjs",[],function(){var c=g.Dayjs;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.Dayjs)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.Dayjs;return f(p)})}),e.define("useblocks-ui-kit",[],function(){var c=g.UiKit;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.UiKit)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.UiKit;return f(p)})}),e.define("useblocks/ui-kit",[],function(){var c=g.UiKit;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.UiKit)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.UiKit;return f(p)})}),e.define("useblocks/ui-kit/icons",[],function(){var c=g.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.UiKitIcons)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.UiKitIcons;return f(p)})}),e.define("useblocks-ui-kit/icons",[],function(){var c=g.UiKitIcons;return c&&typeof c.then=="function"?c.then(function(d){return d===void 0?b.then(function(p){return f(p.UiKitIcons)}):f(d)}):c!==void 0?f(c):b.then(function(d){var p=d.UiKitIcons;return f(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var _a=new Function("url","return import(url)");function wa(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function Sa(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Ia(e){return e.type==="umd"||e.resolve==="registry"}var Aa=class{_context;_pluginRegistry;_options;_map=new Map;_optionsMap=new Map;_readyMap=new Map;_resolveMap=new Map;_initializingPlugins=new Map;_creatingPlugins=new Set;_initializedPlugins=new Set;_creationOrder=[];_lifecycleListeners=new Set;_activated=!1;constructor(e,t,n={}){this._context=e,this._pluginRegistry=t,this._options=n}activate(){return this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}activateSync(){this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}onLifecycle(e){return this._lifecycleListeners.add(e),{dispose:()=>this._lifecycleListeners.delete(e)}}_emitLifecycle(e){for(const t of Array.from(this._lifecycleListeners))try{t(e)}catch{}}async _resolveEntry(e){if(typeof e=="string"||typeof e=="symbol"){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);return{ctor:t}}if(typeof e=="function")return e.length===0?{ctor:await e()}:{ctor:e};if(Array.isArray(e)){const[t,n]=e;if(typeof t=="function")return{ctor:t,options:n};const r=await this._pluginRegistry.getAsync(t);if(!r)throw new Error(`Plugin "${String(t)}" not registered.`);return{ctor:r,options:n}}if(Sa(e))return this._resolveDescriptor(e);throw new Error(`Unknown plugin entry format: ${JSON.stringify(e)}`)}async _resolveDescriptor(e){const t=e.resolve??(e.type==="umd"?"window":"module");if(Ia(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await _a(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,r.onload=()=>t(),r.onerror=()=>n(new Error(`Failed to load script: ${e}`)),document.head.appendChild(r)})}initSync(e){const t=[];for(const n of e){const r=this._getOrCreate(n,void 0);t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const{ctor:i,options:o}=await this._resolveEntry(r),s=this._getOrCreate(i,o);n.has(s)||(n.add(s),t.push(s))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const a=await this._resolveEntry(s);t.add(a.ctor),n.push(a)}const r=[];this._map.forEach((s,a)=>{t.has(a)||r.push({key:a,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:a,plugin:l}=r[s];await this._initializingPlugins.get(l),await this._disposePlugin(l,l.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(l),this._resolveMap.delete(l),this._initializingPlugins.delete(l),this._initializedPlugins.delete(l);const u=this._creationOrder.indexOf(l);u>=0&&this._creationOrder.splice(u,1)}const i=[],o=new Set;for(const{ctor:s,options:a}of n){const l=this._getOrCreate(s,a);o.has(l)||(o.add(l),i.push(l))}this._activated&&await this._startPluginsBatch(i)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,i)=>{let o,s=!1;const a=()=>{s||(s=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(o=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,a),i(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),i=this._createPluginInstance(e,r),o=i.constructor.name;this._emitLifecycle({type:"created",plugin:i,name:o}),i.required?.(),this._map.set(n,i),this._creationOrder.push(i),this._setupReadyPromise(i)}return this._map.get(n)}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);try{return wa(e)?new e(this._context,t):e(this._context,t)||{}}finally{this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const i of t){if(this._initializedPlugins.has(i))continue;const o=this._initializingPlugins.get(i);if(o){n.add(o);continue}r.push(i)}if(r.length>0){const i=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,i);n.add(i),i.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===i&&this._initializingPlugins.delete(o)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(i){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:i})}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(i){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:i})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},Ta=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const i of n)try{i.callback(t)}catch{}const r=n.filter(i=>!i.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(i=>(t.ctor=i,t.loading=void 0,this._notifyListeners(e,i),i));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!1};return r.push(i),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!0};return r.push(i),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(i=>i.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},Ca=class{resolveRegistry;constructor(e){this.resolveRegistry=e}target(){return this.resolveRegistry()}get(e){return this.target().get(e)}getAsync(e){return this.target().getAsync(e)}add(e,t){return this.target().add(e,t)}addAll(e){return this.target().addAll(e)}addAsync(e,t){return this.target().addAsync(e,t)}has(e){return this.target().has(e)}isLoaded(e){return this.target().isLoaded(e)}override(e,t){return this.target().override(e,t)}on(e,t){return this.target().on(e,t)}once(e,t){return this.target().once(e,t)}off(e,t){return this.target().off(e,t)}keys(){return this.target().keys()}forContext(){return this.target().forContext()}},wr=class{capacity;items=[];constructor(e){this.capacity=e}push(e){this.items.length>=this.capacity&&this.items.shift(),this.items.push(e)}snapshot(){return this.items.slice()}size(){return this.items.length}clear(){this.items=[]}};function Ra(e,t){return t+e}function Pa(){return typeof performance>"u"?Date.now():Ra(performance.now(),performance.timeOrigin)}var Da="emailmaker:diagnostics",Oa="diagnostics",xa="diagnostics";function Sr(e,t){return t?`${e}${e.includes("?")?"&":"?"}${xa}=1`:e}var qt;function Ma(){try{const e=new URLSearchParams(window.location.search).get(Oa);return e===null?void 0:e!=="0"}catch{return}}function ka(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function La(){try{const e=window.localStorage.getItem(Da);return e===null?void 0:e==="1"}catch{return}}function et(){return qt===void 0&&(qt=typeof window>"u"?!1:Ma()??ka()??La()??!1),qt}function Na(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var Z={initStart:"loader:init:start",coreReady:"loader:core:ready",initEnd:"loader:init:end",chunksLoaded:"app:chunks:loaded",showStart:"show:start",showEnd:"show:end",canvasCreated:"canvas:created",canvasLoaded:"canvas:loaded",canvasPainted:"canvas:painted",appVisible:"app:visible",editorVisible:"editor:visible",canvasSettled:"canvas:settled"},Lg=Object.values(Z),Ng=[Z.canvasPainted,Z.canvasSettled,Z.appVisible,Z.editorVisible],Fa=5e3,ja=3e3,Ir="diagnosticsStore",ct,$e;function Ar(){return{marks:new wr(Fa),resources:new wr(ja)}}function qi(){if($e)return $e;const e=zn();return e?($e=e[Ir]??ct??Ar(),e[Ir]=$e,ct=void 0,$e):(ct??=Ar(),ct)}function V(e,t){et()&&qi().marks.push({phase:e,at:Pa(),...t})}function zn(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[Na()];return e!==null&&typeof e=="object"?e:void 0}function Ba(e){const t=e.length,n=qi();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Ua(){const e=zn();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Ba(e.diagnosticsBuffer)}var Ha="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Vn(){const e=new Error(Ha);return e.name="DestroyedInstanceError",e}function Ga(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function bn(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const o=e,s=t;return o.length===s.length&&o.every((a,l)=>bn(a,s[l]))}const r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&bn(e[o],t[o]))}function $i(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const a=t(s);o&&bn(i,a)||(i=a,o=!0,r(a))})},select(r){return $i(n,r)}};return n}function Te(...e){let t=e[0],n=e.length>0;const r=new Set,i={get(){return n?t:void 0},set(o){t=o,n=!0;for(const s of Array.from(r))s(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return $i(i,o)}};return i}var zi=class{http;constructor(e){this.http=e}app_init_create=(e,t={})=>this.http.request({path:"/app/v1/app_init",method:"POST",body:e,type:Zs.UrlEncoded,...t})},Vi=class{http;constructor(e){this.http=e}get_translations2=({file:e,...t},n={})=>this.http.request({path:`/translations/v1/${e}`,method:"GET",...n});get_translations3=({id:e,file:t,...n},r={})=>this.http.request({path:`/translations/v1/${t}/${e}`,method:"GET",...r})};function qa(e){return String(e||"").trim()||void 0}var $a=class extends Q{deps;_app;_baseUrl;_appInit;_restBaseUrl;_prevApp;constructor(e){super(),this.deps=e,this.addDisposable(e.options.select(t=>this._slice(t)).watch(t=>this._start(t)))}get app(){return this._app}_slice(e){return Object.prototype.hasOwnProperty.call(e,"baseUrl")&&(this._baseUrl=qa(e.baseUrl)),Object.prototype.hasOwnProperty.call(e,"appInit")&&(this._appInit=e.appInit),{appInit:this._appInit,user:e.user,project:e.project,baseUrl:this._baseUrl,restBaseUrl:this.deps.resolveRestBaseUrl(this._baseUrl),standalone:this.deps.isStandalone()}}_start(e){if(this._restBaseUrl!==e.restBaseUrl&&(this._restBaseUrl=e.restBaseUrl,this.deps.setRestBaseUrl(e.restBaseUrl)),e.standalone)return;const t=e.appInit||this.deps.fallbackAppInit,n=Promise.resolve(t({baseUrl:e.baseUrl,user:e.user,project:e.project,prevApp:this._prevApp}));this._app=n,n.then(r=>{this._app===n&&(this._prevApp=r)},()=>{}),this.deps.publish(n)}},Kn=N("AppInitService");function za(e){return async()=>{const t=await e();return(await new zi(t).app_init_create({})).data}}function Va(e){e.injectFactory(Kn,(t,n)=>{if(n)return n;const r=new $a({options:e.getInstance(ne),isStandalone:()=>!!e.getInstance(Ee),resolveRestBaseUrl:i=>i?Er(i):Er()||void 0,setRestBaseUrl:i=>{e.getInstance(ba)?.setOptions(i?{baseUrl:i}:{})},fallbackAppInit:za(()=>e.getInstanceAsync(Us)),publish:i=>{e.inject(Le,i)}});return e.getInstance(U)?.addDisposable(r),r},!0)}var Wn=N("documentSession.emailDocuments");function We(e){return e?.getInstance(Wn)}var Ka=N("RevisionServiceFlag");function Wa(e){return e.getOrCreateInstance(Ka,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function Ki(e){return Wa(e).isEnabled()}var Ya=N("EmailRightsResolver");function Xa(e,t){const n=e.getInstance(Ya);return n?n(t):!0}var Wi=N("EmailHistoryAvailabilityResolver");function Ja(e){return e.getInstance(Wi)!==void 0}async function Qa(e){const t=e.getInstance(Wi);if(!t)return!0;try{return await t()}catch{return!1}}var Yn={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},Yi=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],Xi=2e4,Za=Yi.reduce((e,t)=>e+Yn[t],0),Ji=Xi+Za+3e3;function el(e){return Yi.reduce((t,n)=>t+Qi(n,e),0)}function Qi(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:Yn[e]}function Zi(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:Ji}function eo(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:Xi}function Xn(e=Ji){return e+3e3}function to(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var tl=()=>Xn();function nl(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function rl(e){return t=>nl(e.getOrCreateInstance(G.BEFORE_SAVE_EMAIL,()=>new be).fire(t),tl())}function il(e){return e!=null&&e!==""}var ol;function Lt(e,t){return ol?.capture(e,t)}function sl(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function ut(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var le=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${ut(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${ut(this.oldText)}")`:`(replace@${this.oldPosition} "${ut(this.oldText)}" with "${ut(this.newText)}")`}};function Tr(e,t){return e===null||e.length===0?t:new al(e,t).compress()}var al=class ce{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),i=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(i===null)break;this._acceptCurr(i),i=this._getCurr(++n);continue}if(i===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldEnd<=r.newPosition){this._acceptCurr(i),i=this._getCurr(++n);continue}if(r.newEnd<=i.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldPosition<r.newPosition){const[l,u]=ce._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(l),i=u;continue}if(r.newPosition<i.oldPosition){const[l,u]=ce._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(l),r=u;continue}let s,a;if(i.oldEnd===r.newEnd)s=r,a=i,r=this._getPrev(++t),i=this._getCurr(++n);else if(i.oldEnd<r.newEnd){const[l,u]=ce._splitPrev(r,i.oldLength);s=l,a=i,r=u,i=this._getCurr(++n)}else{const[l,u]=ce._splitCurr(i,r.newLength);s=r,a=l,r=this._getPrev(++t),i=u}this._result[this._resultLen++]=new le(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const o=ce._merge(this._result);return ce._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=ce._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=ce._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new le(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new le(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),i=t.newText.substr(n);return[new le(t.oldPosition,t.oldText,t.newPosition,r),new le(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new le(t.oldPosition,r,t.newPosition,t.newText),new le(t.oldPosition+n,i,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,i=t[0];for(let o=1;o<t.length;o++){const s=t[o];i.oldEnd===s.oldPosition?i=new le(i.oldPosition,i.oldText+s.oldText,i.newPosition,i.newText+s.newText):(n[r++]=i,i=s)}return n[r++]=i,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];o.oldText!==o.newText&&(n[r++]=o)}return n}};function ll(e){return new le(e.newPosition,e.newText,e.oldPosition,e.oldText)}function dl(e){return e.map(ll)}function Cr(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function cl(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const i=t[r];n=n.slice(0,i.oldPosition)+i.newText+n.slice(i.oldEnd)}return n}function ul(e,t,n){let r=0;const i=e.start===e.end;for(const o of t){const s=o.newLength-o.oldLength;if(o.oldLength===0){const a=o.oldPosition;if(i&&a===e.start)r+=n==="after"?s:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=s)}continue}if(i){if(e.start>=o.oldEnd)r+=s;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=s;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var Tt=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Rr=0,fl=Math.random().toString(36).slice(2,8);function pl(){return Rr+=1,`doc-${fl}-${Rr}`}function hl(e){const t=e.createBuffer(),n=e.docId??pl();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const a=new Set;let l=!1,u=!1,m;const v=new Set;let E=null;const g=()=>(E?.version!==i&&(E={version:i,value:t.read()}),E.value),_=b=>Object.entries(b).some(([y,S])=>s[y]!==S);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:g,mutate(b,{source:y}){if(l)return i;const S=b.changes?.length?b.changes:void 0,I=S?cl(g(),S):b.content!==void 0?b.content:void 0,A=I!==void 0&&I!==g(),f=b.attributes!==void 0&&_(b.attributes);if(!A&&!f)return i;const c=!(i>(o??-1)),d=f?Object.keys(b.attributes).filter(h=>s[h]!==b.attributes[h]):[];A&&t.write(I),f&&(s={...s,...b.attributes}),i+=1,y!=="user"&&c&&(o=i);const p={source:y,version:i,changes:S,...A?{content:!0}:{},...d.length>0?{attributes:d}:{}};return a.forEach(h=>h(p)),i},markSaved(b,y){const S={serverId:r,savedVersion:o};y!==void 0&&(r=y),(o===null||b>o)&&(o=b),(S.serverId!==r||S.savedVersion!==o)&&a.forEach(I=>I({source:"system",version:i}))},markUnsaved(){l||o===null||o<i||(o=i-1,a.forEach(b=>b({source:"system",version:i})))},markReady(){u||m!==void 0||(u=!0,v.forEach(b=>b.resolve()),v.clear(),a.forEach(b=>b({source:"system",version:i})))},isReady:()=>u,markFailed(b){u||m!==void 0||l||(m=b,v.forEach(y=>y.reject(new Tt(b))),v.clear(),a.forEach(y=>y({source:"system",version:i})))},failure:()=>m,whenReady(){return u?Promise.resolve():m!==void 0?Promise.reject(new Tt(m)):l?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((b,y)=>{v.add({resolve:b,reject:y})})},subscribe(b){return a.add(b),()=>a.delete(b)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>l,dispose(){l=!0,v.forEach(b=>b.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),v.clear(),a.clear(),t.dispose()}}}var ml=500,gl=100,$t=0;function vl(e,t={}){const n=t.groupIntervalMs??ml,r=t.maxSteps??gl,i=t.now??(()=>0);let o=[],s=0,a=$t+=1,l=null,u=!1,m=!1,v=!1;const E=new Set,g=()=>E.forEach(d=>d()),_=(d,p)=>{if(d.length){m=!0;try{e.mutate({changes:d},{source:p})}finally{m=!1}}},b=d=>_(d,"user"),y=d=>{const p=i();u&&l!==null&&p-l<n?o[s-1]=Tr(o[s-1],d):(o=o.slice(0,s),o.push(d),s=o.length,u=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,a=$t+=1)),l=p,g()},S=()=>{u=!1,l=null},I=d=>{if(!d.length)return;const p=o.length>s;p&&(o=o.slice(0,s)),s>0&&(o[s-1]=Tr(o[s-1],d)),S(),p&&g()},A=e.subscribe(({source:d,changes:p})=>{if(!(v||m||!p?.length)){if(d==="remote"){f();return}if(d!=="user"){I(p);return}y(p)}}),f=()=>{o=[],s=0,S(),a=$t+=1,g()},c=()=>{if(s===0)return!1;const d=dl(o[s-1]);return Cr(e.getContent(),d)?(b(d),s-=1,S(),!0):(o=o.slice(0,s-1),s=o.length,S(),g(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){c()&&g()},redo(){if(!(s>=o.length)){if(!Cr(e.getContent(),o[s])){o=o.slice(0,s),S(),g();return}b(o[s]),s+=1,S(),g()}},clear:f,applyWithoutHistory(d){const p=e.get().version;if(_(d,"system"),e.get().version===p){S();return}I(d)},getPast:d=>o.slice(0,s).reverse().slice(0,d),getFuture:d=>o.slice(s).reverse().slice(0,d),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(d){if(d.stackId!==a||d.index>s)return!1;for(;s>d.index;)if(!c())return g(),!1;return g(),!0},subscribe(d){return E.add(d),()=>E.delete(d)},dispose(){v=!0,A(),E.clear(),o=[],s=0}}}var bl=["edit","move","resize","insert"];function zt(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function yl(e){return typeof e=="string"?e:null}function El(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function _l(e){return bl.includes(e)?e:null}function wl(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:yl(t.originId),changeId:zt(t.changeId),rev:zt(t.rev),baseRev:zt(t.baseRev),expected:El(t.expected),intent:_l(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var Pr=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},no="draft";function De(e){return e==null||e===""?no:String(e)}function Sl(e){return e==null||e===""?`${yn}${no}`:`${yn}${String(e)}`}var yn="block:";function de(e){return e?.startsWith(yn)===!0}function Ve(e){return de(e.sessionKey())?void 0:e.current()}function Ye(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return V(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(V(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw Bi(i)?(`${e}`,{...n}):(`${e}`,{error:to(i),...n},void 0),i})}function Ct(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Jn(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Il(e,t={}){const n=Ct((e??[]).filter(r=>r?.html?.trim()));return Jn(n,t)?n:null}function Al(e,t){const n=Date.parse(Ct(e)?.modified??""),r=Il(e),i=Date.parse(r?.modified??""),o=t===void 0||Number.isFinite(i)&&i>t,s=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:o?r:null,...s.length?{latestAt:Math.max(...s)}:{}}}function Tl(e,t){const n=Ct((e??[]).filter(s=>s?.html?.trim())),r=Date.parse(n?.modified??""),i=n&&Number.isFinite(r)&&(t===void 0||r>t),o=[Date.parse(Ct(e??[])?.modified??""),t??NaN].filter(s=>Number.isFinite(s));return{autosave:i&&Jn(n)?n:null,...o.length?{latestAt:Math.max(...o)}:{}}}function Cl({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var ro=e=>e.replace(/\r\n?/g,`
|
|
997
|
-
`),Dr=["recovery","plugin","rest"],Rl=["subject","preheader"];function Pl(e){let t={},n;for(let i=Dr.length-1;i>=0;i--){const o=e.get(Dr[i]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const i of Rl){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function Qn(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?ro(t.content):void 0,i=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...i?{changes:[new le(0,n,0,r)]}:{}},{source:"remote"})}var Vt=e=>typeof e=="string"?e.trim():"";function Dl(e,t,n){const{version:r,attributes:i}=e.get(),o=i,s=Vt(o.title)||Vt(o.subject)||Vt(t.fallbackTitle);return{version:r,payload:{html:e.getContent(),title:s,subject:o.subject,preheader:o.preheader,description:o.description,common_styles:o.common_styles||"",meta:o.meta,utm_parameters:o.utm_parameters,parent_email:o.parent_email,is_template:o.is_template||!1,is_inited:o.is_inited,tags:o.tags,emailtags:o.emailtags,group:o.group,renderGuid:e.get().docId,project:t.project??o.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source}}}async function Ol(e,t,n,r,i){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(i);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,i):t.saveAutosave(r,i)}function _e(e,t=!1){const n={};for(const r of Object.keys(e)){let i=e[r];i!==void 0&&!(typeof i=="number"&&Number.isNaN(i))&&(t&&typeof i=="object"&&i!==null&&(i=_e(i)),n[r]=i)}return n}var xl=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function io(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!xl.has(t))):{}}function Rt(e,t,n={}){e&&e.mutate({attributes:Ml(e.get().attributes,t)},{source:n.source??"user"})}function Ml(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Zn(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function kl(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function oo(e){if(!e)return null;const t=io(e);return e.common_styles!==void 0&&(t.common_styles=kl(e.common_styles)),Zn(e.html,t)}function so(e){return e?Zn(e.html,_e(io(e))):null}var Ll=["common_styles","subject","preheader","meta"];function Or(e){if(!e?.html?.trim())return null;const t={};for(const n of Ll)Nl(n,e[n])&&(t[n]=e[n]);return Zn(e.html,t)}function Nl(e,t){return e==="common_styles"?typeof t=="string"&&t.startsWith("{"):e==="meta"?typeof t=="object"&&t!==null&&!Array.isArray(t):typeof t=="string"}var Fl=["modified","lock"];function jl(e){if(!e)return null;const t={};for(const n of Fl)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Bl=10,Ul=(e,t)=>e.key===t.key&&Hl(e.serverId,t.serverId),Hl=(e,t)=>e==null||e===t;function Gl(e){return typeof e?.then=="function"}var xr=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},ao=e=>{e.request.serverId!=null&&!er(e)&&e.document.markSaved(e.document.get().version)},er=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Mr=(e,t)=>t?.content!==void 0&&Cl({hasUnsavedUserEdit:er(e)})==="skip",ql=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),$l=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.userTouched.clear(),e.document.get().docId))},zl=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([i,o])=>e.attributes[i]!==o)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Vl=e=>{const t=Pl(e.reports),n=zl(e.lastMerged,t);e.lastMerged=t,n&&(Qn(e.document,n),ao(e))},Kt=(e,t)=>{if(!e.ready&&!er(e)){Vl(e);return}Qn(e.document,t)},Kl=e=>{const{attributes:t,serverId:n,docId:r}=e.document.get();return{...t,html:e.document.getContent(),id:n??void 0,isNew:n==null,renderGuid:r}};function Wl(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:a,onAdapterError:l,onTimeout:u}=e;let m;const v=new Set,E=new Set,g=()=>v.forEach(h=>h()),_=(h,w)=>{if(!(h.closed||h.ready)){if(h.error!==void 0){h.document.markFailed(h.error),h.document.get().docId;return}ao(h),h.ready=!0,h.document.markReady(),h.document.get().docId,[...h.reports.keys()]}},b=(h,w,T)=>{l?.(w.id,T),!(!w.required||h.closed)&&(h.error=T,h.document.get().docId,w.id,g())},y=(h,w)=>{const T=new Set(w.map(k=>k.id));w.forEach(k=>{k.watch&&h.watchers.push(k.watch(R=>h.closed?!1:h.ready&&(Mr(h,R)||h.contentShown===!0&&R?.content!==void 0)?(h.document.get().docId,k.id,!1):(R&&h.reports.set(k.id,R),Kt(h,R),!0)))});const D=(k,R)=>{if(!h.closed){if(!k.required&&Mr(h,R)){h.document.get().docId,k.id,k.loaded?.(!1);return}R&&h.reports.set(k.id,R),Kt(h,R),k.loaded?.(R!==null)}},L=()=>{T.size>0||h.closed||(xr(h),_(h,[]))},Y=[];if(w.forEach(k=>{let R;try{R=k.load()}catch(F){b(h,k,F),T.delete(k.id);return}if(Gl(R)){Y.push({id:k.id,required:k.required,load:()=>R,...k.loaded?{loaded:F=>k.loaded?.(F)}:{}});return}D(k,R),T.delete(k.id)}),Y.length===0){L();return}h.timer=setTimeout(()=>{h.timer=void 0,u?.([...T]),h.document.get().docId,[...T],_(h,[...T])},n),h.timer.unref?.(),Y.forEach(k=>{k.load().then(R=>D(k,R)).catch(R=>{b(h,k,R)}).finally(()=>{T.delete(k.id),L()})})},S=async(h,w,T)=>{if(T==="snapshot"||T==="anchor")return;const D=o?.();if(D)return D.resolve({project:w.project??h.project,tags:(h.tags??[]).map(L=>({name:L}))})},I=h=>{if(h.lock===!0&&s?.(h)===!1)return new Pr("locked");const w=h.tags?.length??0,T=h.emailtags?.length??0;if(Math.max(w,T)>Bl)return new Pr("too-many-tags")},A=async(h,w,T)=>{try{await h.document.whenReady()}catch(R){return h.saveError=R,h.saveFailures+=1,h.saveFailures,!1}if(h.closed)return!1;const D=I(h.document.get().attributes);if(D)return h.saveError=D,h.saveFailures+=1,D.reason,g(),!1;if(a&&(await a(Kl(h)).catch(()=>{}),h.closed))return!1;let L;try{L=await S(h.document.get().attributes,T,w)}catch(R){return h.saveError=R,h.saveFailures+=1,h.saveFailures,g(),!1}if(h.closed)return!1;const{payload:Y,version:k}=Dl(h.document,T,L);h.document.get().docId;try{const R=h.document.get().serverId!=null,F=await Ol(r(),i(h.request.key),w,h.document.get().serverId,Y);if(h.closed)return!0;let C;if(w==="snapshot"||w==="anchor"){const x=F?.modified!=null?Date.parse(F.modified):NaN;C=Number.isFinite(x)?x:Date.now(),h.snapshotVersion=k,h.lastRevisionAt=C}else h.document.markSaved(k,F?.id!=null?String(F.id):void 0);const P=h.document.get().serverId;!R&&P!=null&&(h.recoveryFacts={emailId:P,historyLoaded:!0,isRecovering:!1},de(h.request.key)||(h.request={...h.request,key:De(P),serverId:P})),h.saveError=void 0,h.saveFailures=0,h.document.get().serverId,g();const j={intent:w,serverId:h.document.get().serverId,created:!R,...C!==void 0?{revisionAt:C}:{}};return E.forEach(x=>x(j)),!0}catch(R){return h.saveError=R,h.saveFailures+=1,h.saveFailures,g(),!1}},f=()=>{m&&(m.closed=!0,m.watchers.forEach(h=>h()),m.watchers=[],xr(m),m.history.dispose(),m.document.dispose(),m=void 0)},c=(h,w,T)=>{let D=!1;w.show&&(h.show?.id!==w.show.id||h.show.token!==w.show.token)&&(h.show=w.show,D=!0,{docId:h.document.get().docId,...w.show});const L=T==="show"?so(w.patch):null;L&&(h.reports.set("plugin",L),Kt(h,L),$l(h,L)),D&&g()},d=(h,w={})=>{const T=m;return!T||T.closed||h==="materialize"&&T.document.get().serverId!=null?Promise.resolve(!1):T.saving?h==="snapshot"||h==="materialize"?Promise.resolve(!1):(T.inFlight??Promise.resolve(!1)).then(()=>d(h,w)):(T.saving=!0,g(),T.inFlight=A(T,h,w).finally(()=>{T.saving=!1,T.inFlight=void 0,m===T&&!T.closed&&g()}),T.inFlight)},p=(h,w="open")=>{if(m&&!m.closed&&w!=="new"&&Ul(m.request,h))return c(m,h,w),m.document;f();const T=hl({createBuffer:()=>sl(""),serverId:h.serverId??null}),D={request:h,show:h.show,document:T,history:vl(T,{now:Date.now}),watchers:[],userTouched:new Set,saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return m=D,D.watchers.push(ql(D)),T.get().docId,h.serverId,y(D,t(h,{publishRecoveryFacts(L){D.closed||(D.recoveryFacts=L,g())},readShownContent:()=>D.closed?null:D.document.getContent()})),g(),T};return{openWith:p,open:(h,w={})=>p({key:De(h),serverId:h,email:w.email,patch:w.patch,show:w.show},"open"),openDraft:(h,w={})=>p({key:De(void 0),serverId:null,email:h,patch:w.patch,show:w.show},"open"),startNewDraft:(h,w={})=>p({key:De(void 0),serverId:null,email:h,patch:w.patch,show:w.show},"new"),reload:(h,w={})=>p({key:De(h),serverId:h,email:w.email,patch:w.patch,show:w.show},"new"),openBlock:(h,w)=>p({key:de(h)?h:Sl(h),serverId:w?.id!=null?String(w.id):null,email:w},"open"),show:(h,w)=>{const T=m;if(!(!T||T.closed))return p({...T.request,patch:h,show:w},"show")},current:()=>m?.document,noteServerFacts:({serverId:h,block:w},T)=>{const D=m;!D||D.closed||D.request.serverId!==h||de(D.request.key??"")===w&&Qn(D.document,jl(T))},save:d,saveState:()=>({error:m?.saveError,failures:m?.saveFailures??0,saving:m?.saving===!0}),revisionFacts(){if(!m)return;const h=m.revisionFactsSnapshot;return h&&h.snapshotVersion===m.snapshotVersion&&h.lastRevisionAt===m.lastRevisionAt?h:(m.revisionFactsSnapshot={snapshotVersion:m.snapshotVersion,lastRevisionAt:m.lastRevisionAt},m.revisionFactsSnapshot)},recoveryFacts:()=>m?.recoveryFacts,history:()=>m?.history,forcedHeaders:()=>m?.forcedHeaders,beginForcedHeaders(h){m&&!m.closed&&(m.forcedHeaders=h)},endForcedHeaders(){m&&(m.forcedHeaders=void 0)},onSaved(h){return E.add(h),()=>E.delete(h)},showFacts:()=>m?.show,sessionKey:()=>m?.request.key,openError:()=>m?.error,subscribe(h){return v.add(h),()=>v.delete(h)},close(){m&&(f(),g())}}}var lo=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function co(e){if(e instanceof lo)return e.reason;if(e instanceof Tt)return co(e.reason)}function Yl(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new lo("not-found");return oo(n)}}}var uo=N("EmailPort");function Xl(e){return e.getInstance(uo)}function Jl(e,t){e.inject(uo,t)}var fo=N("documentSession.restEmailPortFactories");function po(e){return e.getInstance(fo)!==void 0}function Ae(e){const t=e.getInstance(fo);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var Ql=N("EmailTermsResolver");function Zl(e){return e.getInstance(Ql)}var ho=N("EmailHistoryPort"),ed=N("BlockHistoryPort");function mo(e){return e.getInstance(ed)}function go(e){return e.getInstance(ho)}function td(e,t){e.inject(ho,t)}var nd="em_autosave_pending";function Pt(e){return`${nd}_${e}`}function rd(e,t){try{sessionStorage.setItem(Pt(e),JSON.stringify(t))}catch{}}function id(e){try{const t=sessionStorage.getItem(Pt(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(Pt(e)),null):n}catch{return null}}function ft(e){try{sessionStorage.removeItem(Pt(e))}catch{}}var od=2e3,sd=5e3,ad=5,ld=5e3,dd=4;function cd(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function ud(e,t){return e==null||t==null?!1:e.replaceAll(`\r
|
|
996
|
+
`,r=new Function("__amdEnv",n);r(e),typeof e.require=="function"&&typeof e.require.config=="function"&&e.require.config({baseUrl:"./",paths:{core:"useblocks-core.1c4e77a0.js",po:"useblocks-po.1c4e77a0.js",monaco:"static/monaco/index.CO7s5UdA.js"}})}e.define("__delivery__/libs",[],function(){return import("./static/esm/delivery-libs.js")});var i=function(m){var l,u=function(){return l||(l=Promise.resolve().then(m))};return{then:function(p,R){return u().then(p,R)},catch:function(p){return u().catch(p)},finally:function(p){return u().finally(p)}}},o=i(function(){return e.require(["__delivery__/libs"]).then(function(m){return m[0]})});t.React=i(function(){return o.then(function(m){return m.React})}),t.ReactDom=i(function(){return o.then(function(m){return m.ReactDom})}),t.ReactDomClient=i(function(){return o.then(function(m){return m.ReactDomClient})}),t.ReactJsxRuntime=i(function(){return o.then(function(m){return m.ReactJsxRuntime})}),t.ReactJsxDevRuntime=i(function(){return o.then(function(m){return m.ReactJsxDevRuntime})}),t.AntDesignIconBase=i(function(){return o.then(function(m){return m.AntDesignIconBase})}),t.AntDesignCssinjs=i(function(){return o.then(function(m){return m.AntDesignCssinjs})}),t.Classnames=i(function(){return o.then(function(m){return m.Classnames})}),t.Dayjs=i(function(){return o.then(function(m){return m.Dayjs})});var s=i(function(){return Promise.all([o]).then(function(m){var l=m[0]||Object.create(null),u=Object.create(null);for(var p in l)Object.prototype.hasOwnProperty.call(l,p)&&(u[p]=l[p]);for(var R in u)Object.prototype.hasOwnProperty.call(u,R)&&(t[R]=u[R]);return u})}),a={Uuid:"the shared `uuid` package was removed from the editor runtime; bundle `uuid` into the plugin or use `crypto.randomUUID()`"},c=["then","toString","valueOf","constructor","inspect","$$typeof"];for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&t[d]===void 0&&(t[d]=(function(m,l){return new Proxy(Object.create(null),{get:function(u,p){if(!(typeof p=="symbol"||c.indexOf(p)!==-1))throw new Error("[shared-runtime] "+m+"."+String(p)+" is not available: "+l+".")}})})(d,a[d]));var f={},h={Antd:"[runtime] `antd` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",AntDesignIcons:"[runtime] `@ant-design/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKit:"[runtime] `useblocks-ui-kit` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator.",UiKitIcons:"[runtime] `useblocks-ui-kit/icons` is not available: the compatibility layer for global plugins is not enabled. Add `import 'useblocks/compat-globals';` before creating the editor, or turn on the `compatGlobals` option of the bundler plugin. ESM builds omit this layer by default so that plugin compatibility is not paid for by every integrator."},y={Antd:"[runtime] `antd` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",AntDesignIcons:"[runtime] `@ant-design/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKit:"[runtime] `useblocks-ui-kit` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version.",UiKitIcons:"[runtime] `useblocks-ui-kit/icons` is served to a plugin from the host runtime through the compatibility layer for global plugins. This layer is deprecated and may be removed in a future major version."},b=Object.create(null),T=function(m){for(var l=String(m&&m.stack||"").split(`
|
|
997
|
+
`),u="",p=0;p<l.length;p+=1){var R=/((?:https?|file|blob):\/\/[^\s()]+?)(?::\d+){1,2}\)?\s*$/.exec(l[p]);if(R){if(!u){u=R[1];continue}if(R[1]!==u)return R[1]}}return""},w=function(m){var l=T(new Error(m)),u=l?m+" Requested by: "+l+".":m;return e.__compatMissingReason=u,u};if(e.registerCompat=function(m){if(!(!m||typeof m!="object"))for(var l in m)Object.prototype.hasOwnProperty.call(m,l)&&(b[l]=m[l])},e.__compatPending){for(var g=0;g<e.__compatPending.length;g+=1)e.registerCompat(e.__compatPending[g]);e.__compatPending=void 0}for(var C in h)Object.prototype.hasOwnProperty.call(h,C)&&(function(m,l,u){var p=!1,R=function(){if(!(m in b))throw new Error(w(l));return b[m]};Object.defineProperty(t,m,{configurable:!0,enumerable:!0,get:function(){var D=R();return p||(p=!0),D},set:function(D){b[m]=D}}),Object.defineProperty(f,m,{configurable:!0,enumerable:!0,get:R,set:function(D){b[m]=D}})})(C,h[C],y[C]);var _=t;for(var P in f)Object.prototype.hasOwnProperty.call(f,P)&&(_===t&&(_=Object.create(t)),Object.defineProperty(_,P,Object.getOwnPropertyDescriptor(f,P)));var S=s,M=[],v=function(){for(var m=[],l=0;l<M.length;l+=1)(function(u){var p=t[u];p&&typeof p.then=="function"&&m.push(Promise.resolve(p).then(function(R){t[u]=R}))})(M[l]);return Promise.all(m)},E=typeof e.prefetch=="function"?e.prefetch:void 0;if(e.prefetch=function(){return s.then(v).then(function(){if(typeof E=="function")return E.call(e)})},typeof e.define=="function"){let m=function(l){if(!l||typeof l!="object"&&typeof l!="function"||l.__esModule)return l;if(A){var u=A.get(l);if(u)return u}var p=Object.create(null);Object.defineProperties(p,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var R=Reflect.ownKeys(l),D=0;D<R.length;D++){var L=R[D];if(L!=="__esModule"){var I=Object.getOwnPropertyDescriptor(l,L);I&&Object.defineProperty(p,L,I)}}return Object.prototype.hasOwnProperty.call(p,"default")||Object.defineProperty(p,"default",{enumerable:!0,value:l,writable:!1}),A&&A.set(l,p),p};var A=typeof WeakMap<"u"?new WeakMap:null;e.define("react",[],function(){var l=_.React;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.React)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.React;return m(p)})}),e.define("useblocks/runtime/react",[],function(){var l=_.React;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.React)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.React;return m(p)})}),e.define("react-dom",[],function(){var l=_.ReactDom;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.ReactDom)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.ReactDom;return m(p)})}),e.define("useblocks/runtime/react-dom",[],function(){var l=_.ReactDom;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.ReactDom)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.ReactDom;return m(p)})}),e.define("react-dom/client",[],function(){var l=_.ReactDomClient;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.ReactDomClient)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.ReactDomClient;return m(p)})}),e.define("useblocks/runtime/react-dom/client",[],function(){var l=_.ReactDomClient;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.ReactDomClient)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.ReactDomClient;return m(p)})}),e.define("react/jsx-runtime",[],function(){var l=_.ReactJsxRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.ReactJsxRuntime)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.ReactJsxRuntime;return m(p)})}),e.define("useblocks/runtime/react/jsx-runtime",[],function(){var l=_.ReactJsxRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.ReactJsxRuntime)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.ReactJsxRuntime;return m(p)})}),e.define("react/jsx-dev-runtime",[],function(){var l=_.ReactJsxDevRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.ReactJsxDevRuntime)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.ReactJsxDevRuntime;return m(p)})}),e.define("useblocks/runtime/react/jsx-dev-runtime",[],function(){var l=_.ReactJsxDevRuntime;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.ReactJsxDevRuntime)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.ReactJsxDevRuntime;return m(p)})}),e.define("antd",[],function(){var l=_.Antd;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.Antd)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.Antd;return m(p)})}),e.define("useblocks/runtime/antd",[],function(){var l=_.Antd;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.Antd)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.Antd;return m(p)})}),e.define("@ant-design/icons/es/components/AntdIcon",[],function(){var l=_.AntDesignIconBase;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.AntDesignIconBase)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.AntDesignIconBase;return m(p)})}),e.define("useblocks/runtime/@ant-design/icons/es/components/AntdIcon",[],function(){var l=_.AntDesignIconBase;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.AntDesignIconBase)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.AntDesignIconBase;return m(p)})}),e.define("@ant-design/icons",[],function(){var l=_.AntDesignIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.AntDesignIcons)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.AntDesignIcons;return m(p)})}),e.define("useblocks/runtime/@ant-design/icons",[],function(){var l=_.AntDesignIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.AntDesignIcons)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.AntDesignIcons;return m(p)})}),e.define("@ant-design/cssinjs",[],function(){var l=_.AntDesignCssinjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.AntDesignCssinjs)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.AntDesignCssinjs;return m(p)})}),e.define("useblocks/runtime/@ant-design/cssinjs",[],function(){var l=_.AntDesignCssinjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.AntDesignCssinjs)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.AntDesignCssinjs;return m(p)})}),e.define("classnames",[],function(){var l=_.Classnames;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.Classnames)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.Classnames;return m(p)})}),e.define("useblocks/runtime/classnames",[],function(){var l=_.Classnames;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.Classnames)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.Classnames;return m(p)})}),e.define("dayjs",[],function(){var l=_.Dayjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.Dayjs)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.Dayjs;return m(p)})}),e.define("useblocks/runtime/dayjs",[],function(){var l=_.Dayjs;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.Dayjs)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.Dayjs;return m(p)})}),e.define("useblocks-ui-kit",[],function(){var l=_.UiKit;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.UiKit)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.UiKit;return m(p)})}),e.define("useblocks/ui-kit",[],function(){var l=_.UiKit;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.UiKit)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.UiKit;return m(p)})}),e.define("useblocks/ui-kit/icons",[],function(){var l=_.UiKitIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.UiKitIcons)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.UiKitIcons;return m(p)})}),e.define("useblocks-ui-kit/icons",[],function(){var l=_.UiKitIcons;return l&&typeof l.then=="function"?l.then(function(u){return u===void 0?S.then(function(p){return m(p.UiKitIcons)}):m(u)}):l!==void 0?m(l):S.then(function(u){var p=u.UiKitIcons;return m(p)})})}globalThis.__SHARED_RUNTIME_INIT_SENTINEL__="@shared-runtime:init-complete"})();var lc=new Function("url","return import(url)");function cc(e){if(typeof e!="function")return!1;try{return Reflect.construct(String,[],e),!0}catch{return!1}}function kr(e){return typeof e=="object"&&e!==null&&"type"in e&&"url"in e}function Jo(e){return e.type==="umd"||e.resolve==="registry"}var dc="If the plugin is built on globals, enable the compatibility layer: the `compatGlobals` option of the bundler plugin or `import '<package>/compat-globals'` before creating the editor.";function uc(e){const t=Array.isArray(e)?e[0]:e;return kr(t)?t.name??t.url:typeof t=="function"?t.name||"anonymous plugin":String(t)}function fc(e,t){const n=uc(e),r=kr(e)?e:void 0,i=t instanceof Error?t.message:String(t),o=r&&Jo(r)&&!/compat/iu.test(i)?` ${dc}`:"",s=new Error(`Plugin "${n}" was skipped: it failed to load. ${i}${o}`);return s.cause=t,{name:n,url:r?.url,error:s}}function pc(e){return!e.filename&&!e.error&&/^Script error\.?$/.test(e.message)}var hc=class{_context;_pluginRegistry;_options;_map=new Map;_optionsMap=new Map;_readyMap=new Map;_resolveMap=new Map;_initializingPlugins=new Map;_creatingPlugins=new Set;_initializedPlugins=new Set;_creationOrder=[];_lifecycleListeners=new Set;_activated=!1;constructor(e,t,n={}){this._context=e,this._pluginRegistry=t,this._options=n}activate(){return this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}activateSync(){this._activated=!0,this._startPluginsBatch(Array.from(this._map.values()))}onLifecycle(e){return this._lifecycleListeners.add(e),{dispose:()=>this._lifecycleListeners.delete(e)}}_emitLifecycle(e){for(const t of Array.from(this._lifecycleListeners))try{t(e)}catch{}}async _resolveEntry(e){if(typeof e=="string"||typeof e=="symbol"){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);return{ctor:t}}if(typeof e=="function")return e.length===0?{ctor:await e()}:{ctor:e};if(Array.isArray(e)){const[t,n]=e;if(typeof t=="function")return{ctor:t,options:n};const r=await this._pluginRegistry.getAsync(t);if(!r)throw new Error(`Plugin "${String(t)}" not registered.`);return{ctor:r,options:n}}if(kr(e))return this._resolveDescriptor(e);throw new Error(`Unknown plugin entry format: ${JSON.stringify(e)}`)}async _resolveDescriptor(e){const t=e.resolve??(e.type==="umd"?"window":"module");if(Jo(e)&&await this._options.ensureHostRuntimeReady?.(e),e.type==="esm"){const n=await lc(e.url);if(t==="module")return{ctor:n.default??n};if(t==="registry"&&e.name){const r=await this._pluginRegistry.getAsync(e.name);if(!r)throw new Error(`Plugin "${e.name}" not found in registry after ESM load`);return{ctor:r}}}if(e.type==="umd"){if(await this._loadScript(e.url),t==="window"&&e.name){const n=globalThis[e.name];if(!n)throw new Error(`Plugin "${e.name}" not found on window after script load`);return{ctor:n}}if(t==="registry"&&e.name){const n=await this._pluginRegistry.getAsync(e.name);if(!n)throw new Error(`Plugin "${e.name}" not found in registry after script load`);return{ctor:n}}}throw new Error(`Cannot resolve descriptor: type=${e.type}, resolve=${t}, name=${e.name??"none"}`)}_loadScript(e){return new Promise((t,n)=>{if(typeof document>"u"){n(new Error("Cannot load UMD script in non-browser environment"));return}const r=document.createElement("script");r.src=e,this._options.explainScriptFailure?.();let i;const o=a=>{i||(a.filename===r.src?i=this._scriptExecutionError(e,a.error??a.message):pc(a)&&(i=this._scriptExecutionError(e,this._options.explainScriptFailure?.()??a.message)))},s=()=>window.removeEventListener("error",o);window.addEventListener("error",o),r.onload=()=>{if(s(),i){n(i);return}t()},r.onerror=()=>{s(),n(new Error(`Failed to load script: ${e}`))},document.head.appendChild(r)})}_scriptExecutionError(e,t){const n=t instanceof Error?t.message:String(t),r=new Error(`Plugin script "${e}" threw while executing: ${n}`);return r.cause=t,r}initSync(e){const t=[];for(const n of e){const r=this._createOrSkip(n,void 0);r&&t.push(r)}this._activated=!0,this._startPluginsBatch(t)}async init(e){const t=[],n=new Set;for(const r of e){const i=await this._resolveOrSkip(r);if(!i)continue;const o=this._createOrSkip(i.ctor,i.options);o&&!n.has(o)&&(n.add(o),t.push(o))}this._activated=!0,await this._startPluginsBatch(t)}async setPlugins(e){const t=new Set,n=[];for(const s of e){const a=await this._resolveOrSkip(s);a&&(t.add(a.ctor),n.push(a))}const r=[];this._map.forEach((s,a)=>{t.has(a)||r.push({key:a,plugin:s})});for(let s=r.length-1;s>=0;s--){const{key:a,plugin:c}=r[s];await this._initializingPlugins.get(c),await this._disposePlugin(c,c.constructor.name),this._map.delete(a),this._optionsMap.delete(a),this._readyMap.delete(c),this._resolveMap.delete(c),this._initializingPlugins.delete(c),this._initializedPlugins.delete(c);const d=this._creationOrder.indexOf(c);d>=0&&this._creationOrder.splice(d,1)}const i=[],o=new Set;for(const{ctor:s,options:a}of n){const c=this._createOrSkip(s,a);c&&!o.has(c)&&(o.add(c),i.push(c))}this._activated&&await this._startPluginsBatch(i)}isReady(e){return this._initializedPlugins.has(e)}ready(e){return this._initializingPlugins.get(e)??this._readyMap.get(e)??Promise.resolve()}async waitFor(e,t){if(this._pluginRegistry.has(e))return this.useByKeyAsync(e);const{timeout:n}=t??{};return await new Promise((r,i)=>{let o,s=!1;const a=()=>{s||(s=!0,o&&clearTimeout(o),this._pluginRegistry.off(e,a),r())};this._pluginRegistry.on(e,a),n!==void 0&&n>0&&(o=setTimeout(()=>{s||(s=!0,this._pluginRegistry.off(e,a),i(new Error(`waitFor("${String(e)}") timed out after ${n}ms`)))},n))}),this.useByKeyAsync(e)}useByKey(e){const t=this._pluginRegistry.get(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered or not loaded yet. Use useByKeyAsync() for async plugins.`);const n=this._getOrCreate(t);return this._activated&&this._startPluginsBatch([n]),n}async useByKeyAsync(e){const t=await this._pluginRegistry.getAsync(e);if(!t)throw new Error(`Plugin "${String(e)}" not registered.`);const n=this._getOrCreate(t);return this._activated&&await this._startPluginsBatch([n]),n}useByCtor(e,t){const n=this._getOrCreate(e,t);return this._activated&&this._startPluginsBatch([n]),n}use(e){return typeof e=="function"?this.useByCtor(e):this.useByKey(e)}async useAsync(e){const{ctor:t,options:n}=await this._resolveEntry(e),r=this._getOrCreate(t,n);return this._activated&&await this._startPluginsBatch([r]),r}_getOrCreate(e,t){const n=e;if(!this._map.has(n)){t!==void 0&&this._optionsMap.set(n,t);const r=this._optionsMap.get(n),i=this._createPluginInstance(e,r),o=i.constructor.name;this._emitLifecycle({type:"created",plugin:i,name:o}),i.required?.(),this._map.set(n,i),this._creationOrder.push(i),this._setupReadyPromise(i)}return this._map.get(n)}async _resolveOrSkip(e){try{return await this._resolveEntry(e)}catch(t){const n=fc(e,t);try{this._options.reportLoadFailure?.(n)}catch{}return}}_createOrSkip(e,t){try{return this._getOrCreate(e,t)}catch(n){const r=e.name||"anonymous plugin";this._emitLifecycle({type:"create:error",ctor:e,name:r,error:n});return}}_createPluginInstance(e,t){const n=e;if(this._creatingPlugins.has(n))throw new Error(`Cyclic dependency for plugin ${e.name}`);this._creatingPlugins.add(n);const r=this._options.openEarlyWindow?.();try{return cc(e)?new e(this._context,t):e(this._context,t)||{}}finally{r?.(),this._creatingPlugins.delete(n)}}_setupReadyPromise(e){const t=new Promise(n=>{this._resolveMap.set(e,n)});this._readyMap.set(e,t)}async _startPluginsBatch(e){const t=Array.from(new Set(e)),n=new Set,r=[];for(const i of t){if(this._initializedPlugins.has(i))continue;const o=this._initializingPlugins.get(i);if(o){n.add(o);continue}r.push(i)}if(r.length>0){const i=this._runBatchLifecycle(r);for(const o of r)this._initializingPlugins.set(o,i);n.add(i),i.finally(()=>{for(const o of r)this._initializingPlugins.get(o)===i&&this._initializingPlugins.delete(o)})}await Promise.all(n)}async _runBatchLifecycle(e){const t=[];for(const n of e){const r=n.constructor.name;this._emitLifecycle({type:"init:start",plugin:n,name:r});const i=this._options.openEarlyWindow?.();try{await n.init?.(),this._emitLifecycle({type:"init:success",plugin:n,name:r}),t.push(n)}catch(o){this._emitLifecycle({type:"init:error",plugin:n,name:r,error:o})}finally{i?.()}}for(const n of t){const r=n.constructor.name;this._emitLifecycle({type:"afterInit:start",plugin:n,name:r});try{await n.afterInit?.(),this._emitLifecycle({type:"afterInit:success",plugin:n,name:r})}catch(i){this._emitLifecycle({type:"afterInit:error",plugin:n,name:r,error:i})}}for(const n of e)this._initializedPlugins.add(n),this._resolveMap.get(n)?.(),this._resolveMap.delete(n)}async _disposePlugin(e,t){this._emitLifecycle({type:"dispose:start",plugin:e,name:t});try{await e.dispose?.(),this._emitLifecycle({type:"dispose:success",plugin:e,name:t})}catch(n){this._emitLifecycle({type:"dispose:error",plugin:e,name:t,error:n})}}async dispose(){for(let e=this._creationOrder.length-1;e>=0;e--){const t=this._creationOrder[e];await this._initializingPlugins.get(t),await this._disposePlugin(t,t.constructor.name)}this._map.clear(),this._optionsMap.clear(),this._readyMap.clear(),this._resolveMap.clear(),this._initializingPlugins.clear(),this._initializedPlugins.clear(),this._creationOrder.length=0,this._lifecycleListeners.clear()}getStatus(){return Array.from(this._map.values()).map(e=>({name:e.constructor.name,initialized:this._initializedPlugins.has(e)}))}},mc=class{_plugins=new Map;_listeners=new Map;_getOrCreateEntry(e){let t=this._plugins.get(e);return t||(t={overrides:[]},this._plugins.set(e,t)),t}_applyOverrides(e,t){const n=this._plugins.get(e);if(n?.overrides)for(const r of n.overrides)t=r(t)||t;return t}_notifyListeners(e,t){const n=this._listeners.get(e);if(!n||n.length===0)return;for(const i of n)try{i.callback(t)}catch{}const r=n.filter(i=>!i.once);r.length>0?this._listeners.set(e,r):this._listeners.delete(e)}get(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor)}async getAsync(e){const t=this._plugins.get(e);if(t?.ctor)return this._applyOverrides(e,t.ctor);if(t?.loading){const n=await t.loading;return this._applyOverrides(e,n)}if(t?.factory){const n=Promise.resolve(t.factory()).then(i=>(t.ctor=i,t.loading=void 0,this._notifyListeners(e,i),i));t.loading=n;const r=await n;return this._applyOverrides(e,r)}return new Promise(n=>{this.on(e,r=>n(this._applyOverrides(e,r)))})}add(e,t){const n=this._getOrCreateEntry(e);n.ctor=t,this._notifyListeners(e,t)}addAll(e){for(const t of Object.keys(e)){const n=e[t];n!==void 0&&this.add(t,n)}}addAsync(e,t){const n=this._getOrCreateEntry(e);return n.factory=t,{dispose:()=>{n.ctor||(n.factory=void 0)}}}has(e){const t=this._plugins.get(e);return!!(t?.ctor||t?.factory)}isLoaded(e){return!!this._plugins.get(e)?.ctor}override(e,t){const n=this._getOrCreateEntry(e);return n.overrides.push(t),{dispose:()=>{const r=n.overrides.indexOf(t);r>=0&&n.overrides.splice(r,1)}}}on(e,t){const n=this.get(e);n&&t(n);let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!1};return r.push(i),{dispose:()=>this._removeListener(e,t)}}once(e,t){const n=this.get(e);if(n)return t(n),{dispose:()=>{}};let r=this._listeners.get(e);r||(r=[],this._listeners.set(e,r));const i={callback:t,once:!0};return r.push(i),{dispose:()=>this._removeListener(e,t)}}off(e,t){this._removeListener(e,t)}_removeListener(e,t){const n=this._listeners.get(e);if(n){const r=n.findIndex(i=>i.callback===t);r>=0&&n.splice(r,1),n.length===0&&this._listeners.delete(e)}}keys(){return Array.from(this._plugins.keys())}forContext(){const e=this;return{add(t,n){e.add(t,n)}}}},gc=class{resolveRegistry;constructor(e){this.resolveRegistry=e}target(){return this.resolveRegistry()}get(e){return this.target().get(e)}getAsync(e){return this.target().getAsync(e)}add(e,t){return this.target().add(e,t)}addAll(e){return this.target().addAll(e)}addAsync(e,t){return this.target().addAsync(e,t)}has(e){return this.target().has(e)}isLoaded(e){return this.target().isLoaded(e)}override(e,t){return this.target().override(e,t)}on(e,t){return this.target().on(e,t)}once(e,t){return this.target().once(e,t)}off(e,t){return this.target().off(e,t)}keys(){return this.target().keys()}forContext(){return this.target().forContext()}},Ei=class{capacity;items=[];constructor(e){this.capacity=e}push(e){this.items.length>=this.capacity&&this.items.shift(),this.items.push(e)}snapshot(){return this.items.slice()}size(){return this.items.length}clear(){this.items=[]}};function vc(e,t){return t+e}function bc(){return typeof performance>"u"?Date.now():vc(performance.now(),performance.timeOrigin)}var yc="emailmaker:diagnostics",Ec="diagnostics",_c="diagnostics";function _i(e,t){return t?`${e}${e.includes("?")?"&":"?"}${_c}=1`:e}var _n;function wc(){try{const e=new URLSearchParams(window.location.search).get(Ec);return e===null?void 0:e!=="0"}catch{return}}function Sc(){const e=window.__DIAGNOSTICS__;return typeof e=="boolean"?e:void 0}function Ic(){try{const e=window.localStorage.getItem(yc);return e===null?void 0:e==="1"}catch{return}}function wt(){return _n===void 0&&(_n=typeof window>"u"?!1:wc()??Sc()??Ic()??!1),_n}function Cc(e){return`__${(e||"useblocks").toLowerCase().replaceAll("-","")}__`}var le={initStart:"loader:init:start",coreReady:"loader:core:ready",initEnd:"loader:init:end",chunksLoaded:"app:chunks:loaded",showStart:"show:start",showEnd:"show:end",canvasCreated:"canvas:created",canvasLoaded:"canvas:loaded",canvasPainted:"canvas:painted",appVisible:"app:visible",editorVisible:"editor:visible",canvasSettled:"canvas:settled"},RE=Object.values(le),PE=[le.canvasPainted,le.canvasSettled,le.appVisible,le.editorVisible],Tc=5e3,Ac=3e3,wi="diagnosticsStore",$t,at;function Si(){return{marks:new Ei(Tc),resources:new Ei(Ac)}}function Qo(){if(at)return at;const e=Lr();return e?(at=e[wi]??$t??Si(),e[wi]=at,$t=void 0,at):($t??=Si(),$t)}function Z(e,t){wt()&&Qo().marks.push({phase:e,at:bc(),...t})}function Lr(){if(typeof window.__useblocks__<"u"&&window.__useblocks__)return window.__useblocks__;if(typeof window>"u")return;const e=window[Cc()];return e!==null&&typeof e=="object"?e:void 0}function Rc(e){const t=e.length,n=Qo();return e.forEach(r=>n.marks.push(r)),e.length=0,t}function Pc(){const e=Lr();return!e||!Array.isArray(e.diagnosticsBuffer)?0:Rc(e.diagnosticsBuffer)}var Dc="Editor instance was destroyed and cannot be reused. A fresh instance will be created instead.";function Oe(){const e=new Error(Dc);return e.name="DestroyedInstanceError",e}function Oc(e){return e instanceof Error&&e.name==="DestroyedInstanceError"}function Xn(e,t){if(e===t)return!0;if(!e||!t||typeof e!="object"||typeof t!="object")return!1;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){const o=e,s=t;return o.length===s.length&&o.every((a,c)=>Xn(a,s[c]))}const r=Object.keys(e),i=Object.keys(t);return r.length!==i.length?!1:r.every(o=>Object.prototype.hasOwnProperty.call(t,o)&&Xn(e[o],t[o]))}function Zo(e,t){const n={watch(r){let i,o=!1;return e.watch(s=>{const a=t(s);o&&Xn(i,a)||(i=a,o=!0,r(a))})},select(r){return Zo(n,r)}};return n}function Ee(...e){let t=e[0],n=e.length>0;const r=new Set,i={get(){return n?t:void 0},set(o){t=o,n=!0;for(const s of Array.from(r))s(o)},watch(o){return r.add(o),n&&o(t),{dispose:()=>r.delete(o)}},select(o){return Zo(i,o)}};return i}var xc=class{http;constructor(e){this.http=e}app_init_create=(e,t={})=>this.http.request({path:"/app/v1/app_init",method:"POST",body:e,type:xl.UrlEncoded,...t})},es=class{http;constructor(e){this.http=e}get_translations2=({file:e,...t},n={})=>this.http.request({path:`/translations/v1/${e}`,method:"GET",...n});get_translations3=({id:e,file:t,...n},r={})=>this.http.request({path:`/translations/v1/${t}/${e}`,method:"GET",...r})};function Mc(e){return String(e||"").trim()||void 0}var kc=class extends ie{deps;_app;_baseUrl;_appInit;_restBaseUrl;_prevApp;constructor(e){super(),this.deps=e,this.addDisposable(e.options.select(t=>this._slice(t)).watch(t=>this._start(t)))}get app(){return this._app}_slice(e){return Object.prototype.hasOwnProperty.call(e,"baseUrl")&&(this._baseUrl=Mc(e.baseUrl)),Object.prototype.hasOwnProperty.call(e,"appInit")&&(this._appInit=e.appInit),{appInit:this._appInit,user:e.user,project:e.project,baseUrl:this._baseUrl,restBaseUrl:this.deps.resolveRestBaseUrl(this._baseUrl),standalone:this.deps.isStandalone()}}_start(e){if(this._restBaseUrl!==e.restBaseUrl&&(this._restBaseUrl=e.restBaseUrl,this.deps.setRestBaseUrl(e.restBaseUrl)),e.standalone)return;const t=e.appInit||this.deps.fallbackAppInit,n=Promise.resolve(t({baseUrl:e.baseUrl,user:e.user,project:e.project,prevApp:this._prevApp}));this._app=n,n.then(r=>{this._app===n&&(this._prevApp=r)},()=>{}),this.deps.publish(n)}},Nr=F("AppInitService");function Lc(e){return async()=>{const t=await e();return(await new xc(t).app_init_create({})).data}}function Nc(e){e.injectFactory(Nr,(t,n)=>{if(n)return n;const r=new kc({options:e.getInstance(se),isStandalone:()=>!!e.getInstance(Te),resolveRestBaseUrl:i=>i?gi(i):gi()||void 0,setRestBaseUrl:i=>{e.getInstance(sc)?.setOptions(i?{baseUrl:i}:{})},fallbackAppInit:Lc(()=>e.getInstanceAsync(wl)),publish:i=>{e.inject(xe,i)}});return e.getInstance(U)?.addDisposable(r),r},!0)}var Fr=F("documentSession.emailDocuments");function Je(e){return e?.getInstance(Fr)}var Fc=F("RevisionServiceFlag");function ts(e){return e.getOrCreateInstance(Fc,()=>{let t=!1;return{isEnabled:()=>t,set:n=>{t=n}}})}function ns(e){return ts(e).isEnabled()}var jc=F("EmailRightsResolver");function Bc(e,t){const n=e.getInstance(jc);return n?n(t):!0}var rs=F("EmailHistoryAvailabilityResolver");function Uc(e){return e.getInstance(rs)!==void 0}async function Hc(e){const t=e.getInstance(rs);if(!t)return!0;try{return await t()}catch{return!1}}var jr={INIT_START:5e3,SET_ENTITY:12e3,PREHEADER:5e3,SUBJECT:5e3,INITED:5e3,UPDATE_ENTITY:5e3},is=["INIT_START","SET_ENTITY","PREHEADER","SUBJECT","INITED"],os=2e4,$c=is.reduce((e,t)=>e+jr[t],0),ss=os+$c+3e3;function Gc(e){return is.reduce((t,n)=>t+as(n,e),0)}function as(e,t){const n=t?.[e];return typeof n=="number"&&n>0?n:jr[e]}function ls(e){const t=e?.contentReady;return typeof t=="number"&&t>0?t:ss}function cs(e){const t=e?.sandboxReady;return typeof t=="number"&&t>0?t:os}function Br(e=ss){return e+3e3}function ds(e){return e instanceof Error?`${e.name}: ${e.message}`:typeof e=="string"?e:JSON.stringify(e)??"undefined"}var Vc=()=>Br();function qc(e,t){let n;return Promise.race([e,new Promise(r=>{n=setTimeout(()=>{r()},t)})]).finally(()=>{n!==void 0&&clearTimeout(n)})}function zc(e){return t=>qc(e.getOrCreateInstance(j.BEFORE_SAVE_EMAIL,()=>new Me).fire(t),Vc())}function Wc(e){return e!=null&&e!==""}var us;function St(e,t){return us?.capture(e,t)}function Kc(e,t){return us?.captureMessage(e,t)}function Yc(e=""){let t=e;return{read:()=>t,write:n=>{t=n},dispose:()=>{t=""}}}function Gt(e){return e.replace(/\n/g,"\\n").replace(/\r/g,"\\r")}var ge=class{oldPosition;oldText;newPosition;newText;get oldLength(){return this.oldText.length}get oldEnd(){return this.oldPosition+this.oldText.length}get newLength(){return this.newText.length}get newEnd(){return this.newPosition+this.newText.length}constructor(e,t,n,r){this.oldPosition=e,this.oldText=t,this.newPosition=n,this.newText=r}toString(){return this.oldText.length===0?`(insert@${this.oldPosition} "${Gt(this.newText)}")`:this.newText.length===0?`(delete@${this.oldPosition} "${Gt(this.oldText)}")`:`(replace@${this.oldPosition} "${Gt(this.oldText)}" with "${Gt(this.newText)}")`}};function Ii(e,t){return e===null||e.length===0?t:new Xc(e,t).compress()}var Xc=class _e{_prevEdits;_currEdits;_result;_resultLen;_prevLen;_prevDeltaOffset;_currLen;_currDeltaOffset;constructor(t,n){this._prevEdits=t,this._currEdits=n,this._result=[],this._resultLen=0,this._prevLen=this._prevEdits.length,this._prevDeltaOffset=0,this._currLen=this._currEdits.length,this._currDeltaOffset=0}compress(){let t=0,n=0,r=this._getPrev(t),i=this._getCurr(n);for(;t<this._prevLen||n<this._currLen;){if(r===null){if(i===null)break;this._acceptCurr(i),i=this._getCurr(++n);continue}if(i===null){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldEnd<=r.newPosition){this._acceptCurr(i),i=this._getCurr(++n);continue}if(r.newEnd<=i.oldPosition){this._acceptPrev(r),r=this._getPrev(++t);continue}if(i.oldPosition<r.newPosition){const[c,d]=_e._splitCurr(i,r.newPosition-i.oldPosition);this._acceptCurr(c),i=d;continue}if(r.newPosition<i.oldPosition){const[c,d]=_e._splitPrev(r,i.oldPosition-r.newPosition);this._acceptPrev(c),r=d;continue}let s,a;if(i.oldEnd===r.newEnd)s=r,a=i,r=this._getPrev(++t),i=this._getCurr(++n);else if(i.oldEnd<r.newEnd){const[c,d]=_e._splitPrev(r,i.oldLength);s=c,a=i,r=d,i=this._getCurr(++n)}else{const[c,d]=_e._splitCurr(i,r.newLength);s=r,a=c,r=this._getPrev(++t),i=d}this._result[this._resultLen++]=new ge(s.oldPosition,s.oldText,a.newPosition,a.newText),this._prevDeltaOffset+=s.newLength-s.oldLength,this._currDeltaOffset+=a.newLength-a.oldLength}const o=_e._merge(this._result);return _e._removeNoOps(o)}_acceptCurr(t){this._result[this._resultLen++]=_e._rebaseCurr(this._prevDeltaOffset,t),this._currDeltaOffset+=t.newLength-t.oldLength}_getCurr(t){return t<this._currLen?this._currEdits[t]:null}_acceptPrev(t){this._result[this._resultLen++]=_e._rebasePrev(this._currDeltaOffset,t),this._prevDeltaOffset+=t.newLength-t.oldLength}_getPrev(t){return t<this._prevLen?this._prevEdits[t]:null}static _rebaseCurr(t,n){return new ge(n.oldPosition-t,n.oldText,n.newPosition,n.newText)}static _rebasePrev(t,n){return new ge(n.oldPosition,n.oldText,n.newPosition+t,n.newText)}static _splitPrev(t,n){const r=t.newText.substr(0,n),i=t.newText.substr(n);return[new ge(t.oldPosition,t.oldText,t.newPosition,r),new ge(t.oldEnd,"",t.newPosition+n,i)]}static _splitCurr(t,n){const r=t.oldText.substr(0,n),i=t.oldText.substr(n);return[new ge(t.oldPosition,r,t.newPosition,t.newText),new ge(t.oldPosition+n,i,t.newEnd,"")]}static _merge(t){if(t.length===0)return t;const n=[];let r=0,i=t[0];for(let o=1;o<t.length;o++){const s=t[o];i.oldEnd===s.oldPosition?i=new ge(i.oldPosition,i.oldText+s.oldText,i.newPosition,i.newText+s.newText):(n[r++]=i,i=s)}return n[r++]=i,n}static _removeNoOps(t){if(t.length===0)return t;const n=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];o.oldText!==o.newText&&(n[r++]=o)}return n}};function Jc(e){return new ge(e.newPosition,e.newText,e.oldPosition,e.oldText)}function Qc(e){return e.map(Jc)}function Ci(e,t){return t.every(n=>e.slice(n.oldPosition,n.oldEnd)===n.oldText)}function Zc(e,t){let n=e;for(let r=t.length-1;r>=0;r-=1){const i=t[r];n=n.slice(0,i.oldPosition)+i.newText+n.slice(i.oldEnd)}return n}function ed(e,t,n){let r=0;const i=e.start===e.end;for(const o of t){const s=o.newLength-o.oldLength;if(o.oldLength===0){const a=o.oldPosition;if(i&&a===e.start)r+=n==="after"?s:0;else{if(e.start<a&&a<e.end)return null;a<=e.start&&(r+=s)}continue}if(i){if(e.start>=o.oldEnd)r+=s;else if(e.start>o.oldPosition)return null;continue}if(e.start>=o.oldEnd)r+=s;else if(e.end>o.oldPosition)return null}return{start:e.start+r,end:e.end+r}}var It=class extends Error{reason;constructor(e){super("Открытие документа не удалось"),this.reason=e,this.name="DocumentOpenFailedError"}},Ti=0,td=Math.random().toString(36).slice(2,8);function nd(){return Ti+=1,`doc-${td}-${Ti}`}function rd(e){const t=e.createBuffer(),n=e.docId??nd();let r=e.serverId??null,i=0,o=null,s=e.attributes??{};const a=new Set;let c=!1,d=!1,f;const h=new Set;let y=null;const b=()=>(y?.version!==i&&(y={version:i,value:t.read()}),y.value),T=w=>Object.entries(w).some(([g,C])=>s[g]!==C);return{get:()=>({docId:n,serverId:r,version:i,savedVersion:o,attributes:s}),getContent:b,mutate(w,{source:g}){if(c)return i;const C=w.changes?.length?w.changes:void 0,_=C?Zc(b(),C):w.content!==void 0?w.content:void 0,P=_!==void 0&&_!==b(),S=w.attributes!==void 0&&T(w.attributes);if(!P&&!S)return i;const M=!(i>(o??-1)),v=S?Object.keys(w.attributes).filter(A=>s[A]!==w.attributes[A]):[];P&&t.write(_),S&&(s={...s,...w.attributes}),i+=1,g!=="user"&&M&&(o=i);const E={source:g,version:i,changes:C,...P?{content:!0}:{},...v.length>0?{attributes:v}:{}};return a.forEach(A=>A(E)),i},markSaved(w,g){const C={serverId:r,savedVersion:o};g!==void 0&&(r=g),(o===null||w>o)&&(o=w),(C.serverId!==r||C.savedVersion!==o)&&a.forEach(_=>_({source:"system",version:i}))},markUnsaved(){c||o===null||o<i||(o=i-1,a.forEach(w=>w({source:"system",version:i})))},markReady(){d||f!==void 0||(d=!0,h.forEach(w=>w.resolve()),h.clear(),a.forEach(w=>w({source:"system",version:i})))},isReady:()=>d,markFailed(w){d||f!==void 0||c||(f=w,h.forEach(g=>g.reject(new It(w))),h.clear(),a.forEach(g=>g({source:"system",version:i})))},failure:()=>f,whenReady(){return d?Promise.resolve():f!==void 0?Promise.reject(new It(f)):c?Promise.reject(new Error("Документ закрыт до того, как наполнение закончилось")):new Promise((w,g)=>{h.add({resolve:w,reject:g})})},subscribe(w){return a.add(w),()=>a.delete(w)},isNew:()=>r===null,isDirty:()=>i>(o??-1),isDisposed:()=>c,dispose(){c=!0,h.forEach(w=>w.reject(new Error("Документ закрыт до того, как наполнение закончилось"))),h.clear(),a.clear(),t.dispose()}}}var id=500,od=100,wn=0;function sd(e,t={}){const n=t.groupIntervalMs??id,r=t.maxSteps??od,i=t.now??(()=>0);let o=[],s=0,a=wn+=1,c=null,d=!1,f=!1,h=!1;const y=new Set,b=()=>y.forEach(v=>v()),T=(v,E)=>{if(v.length){f=!0;try{e.mutate({changes:v},{source:E})}finally{f=!1}}},w=v=>T(v,"user"),g=v=>{const E=i();d&&c!==null&&E-c<n?o[s-1]=Ii(o[s-1],v):(o=o.slice(0,s),o.push(v),s=o.length,d=!0,o.length>r&&(o=o.slice(o.length-r),s=o.length,a=wn+=1)),c=E,b()},C=()=>{d=!1,c=null},_=v=>{if(!v.length)return;const E=o.length>s;E&&(o=o.slice(0,s)),s>0&&(o[s-1]=Ii(o[s-1],v)),C(),E&&b()},P=e.subscribe(({source:v,changes:E})=>{if(!(h||f||!E?.length)){if(v==="remote"){S();return}if(v!=="user"){_(E);return}g(E)}}),S=()=>{o=[],s=0,C(),a=wn+=1,b()},M=()=>{if(s===0)return!1;const v=Qc(o[s-1]);return Ci(e.getContent(),v)?(w(v),s-=1,C(),!0):(o=o.slice(0,s-1),s=o.length,C(),b(),!1)};return{canUndo:()=>s>0,canRedo:()=>s<o.length,undo(){M()&&b()},redo(){if(!(s>=o.length)){if(!Ci(e.getContent(),o[s])){o=o.slice(0,s),C(),b();return}w(o[s]),s+=1,C(),b()}},clear:S,applyWithoutHistory(v){const E=e.get().version;if(T(v,"system"),e.get().version===E){C();return}_(v)},getPast:v=>o.slice(0,s).reverse().slice(0,v),getFuture:v=>o.slice(s).reverse().slice(0,v),createSnapshot:()=>({stackId:a,index:s}),restoreSnapshot(v){if(v.stackId!==a||v.index>s)return!1;for(;s>v.index;)if(!M())return b(),!1;return b(),!0},subscribe(v){return y.add(v),()=>y.delete(v)},dispose(){h=!0,P(),y.clear(),o=[],s=0}}}var ad=["edit","move","resize","insert"];function Sn(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}function ld(e){return typeof e=="string"?e:null}function cd(e){return!Array.isArray(e)||!e.every(t=>typeof t=="string")?null:e}function dd(e){return ad.includes(e)?e:null}function ud(e){const t=typeof e=="object"&&e!==null?e:{},n={originId:ld(t.originId),changeId:Sn(t.changeId),rev:Sn(t.rev),baseRev:Sn(t.baseRev),expected:cd(t.expected),intent:dd(t.intent)};return{...n,legacy:Object.values(n).every(r=>r===null)}}var vt=class extends Error{reason;constructor(e){super(`[emailmaker] save refused: ${e}`),this.name="SaveRefusedError",this.reason=e}},fs=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleEmailAutosave did not respond within ${e}ms — the autosave was not written`),this.timeoutMs=e,this.name="IntegratorAutosaveTimeoutError"}},Ur=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail did not respond within ${e}ms — the email was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}};function fd(){return typeof navigator<"u"&&navigator.onLine===!1}function pd(e){if(e==null)return[];const t=[e];if(typeof e!="object")return t;const n=e;if(n.error!=null&&(t.push(n.error),typeof n.error=="object")){const r=n.error;r.data!=null&&t.push(r.data),r.error!=null&&t.push(r.error)}if(n.data!=null&&(t.push(n.data),typeof n.data=="object")){const r=n.data;r.error!=null&&t.push(r.error)}return n.innerException!=null&&t.push(n.innerException),t}function ps(e){if(!e)return!1;if(typeof e=="string"){const n=e.toLowerCase();return n.includes("fetch")||n.includes("network")||n.includes("timeout")||n.includes("failed to fetch")||n.includes("load failed")||n.includes("networkerror")}if(e instanceof Error)return ps(e.message);if(typeof e!="object")return!1;const t=e;return t.status==="FETCH_ERROR"||t.status==="TIMEOUT_ERROR"||t.status==="PARSING_ERROR"?!0:typeof t.status=="number"?t.status===0||t.status===408||t.status>=500:!1}function hd(e){return fd()?!0:pd(e).some(ps)}var hs=new WeakSet,ms=new WeakMap;function gs(e){typeof e=="object"&&e!==null&&hs.add(e)}function md(e,t){typeof e=="object"&&e!==null&&ms.set(e,t)}function gd(e){return typeof e=="object"&&e!==null?ms.get(e):void 0}function vd(e){return e instanceof Ur||e instanceof fs||typeof e=="object"&&e!==null&&hs.has(e)}function bd(e){return e instanceof vt||vd(e)}function yd(e){return!bd(e)&&hd(e)}var vs="draft";function Ke(e){return e==null||e===""?vs:String(e)}function Ed(e){return e==null||e===""?`${Jn}${vs}`:`${Jn}${String(e)}`}var Jn="block:";function ye(e){return e?.startsWith(Jn)===!0}function dt(e){return ye(e.sessionKey())?void 0:e.current()}function bt(e,t,n){const r=typeof performance<"u"?performance.now():Date.now();return Z(`show:gate:${e}`,{kind:"wait"}),t.then(i=>(Z(`show:gate:${e}:end`,{kind:"wait"}),i),i=>{const o=Math.round((typeof performance<"u"?performance.now():Date.now())-r);throw Or(i)?(`${e}`,{...n}):(`${e}`,{error:ds(i),...n},void 0),i})}var _d=/^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/;function wd(e){const t=e?.trim()??"";if(!_d.test(t))return Date.parse(t);const n=t.replace(" ","T");return Math.max(Date.parse(n),Date.parse(`${n}Z`))}function yt(e){return e?.length?[...e].sort((t,n)=>Date.parse(n.modified)-Date.parse(t.modified))[0]:null}function Hr(e,{freshSince:t}={}){return!(e?.isAutosave!==!0||!e?.html?.trim()||t!==void 0&&Date.parse(e.modified)<t-5e3)}function Sd(e,t={}){const n=yt((e??[]).filter(r=>r?.html?.trim()));return Hr(n,t)?n:null}function Id(e,t){const n=Date.parse(yt(e)?.modified??""),r=Sd(e),i=Date.parse(r?.modified??""),o=t===void 0||Number.isFinite(i)&&i>t,s=[n,t??NaN].filter(a=>Number.isFinite(a));return{autosave:o?r:null,...s.length?{latestAt:Math.max(...s)}:{}}}function Ai(e,t,n){const r=yt((e??[]).filter(c=>c?.html?.trim())),i=Date.parse(r?.modified??""),o=Date.parse(yt((n??[]).filter(c=>c?.html?.trim()))?.modified??""),s=r&&Number.isFinite(i)&&(t===void 0||i>t)&&!(o>i),a=[Date.parse(yt(e??[])?.modified??""),t??NaN].filter(c=>Number.isFinite(c));return{autosave:s&&Hr(r)?r:null,...a.length?{latestAt:Math.max(...a)}:{}}}function Cd({hasUnsavedUserEdit:e}){return e?"skip":"apply"}var bs=e=>e.replace(/\r\n?/g,`
|
|
998
|
+
`),Ri=["recovery","plugin","rest"],Td=["subject","preheader"];function Ad(e){let t={},n;for(let i=Ri.length-1;i>=0;i--){const o=e.get(Ri[i]);o&&(o.attributes&&(t={...t,...o.attributes}),o.content!==void 0&&(n=o.content))}const r=e.get("plugin")?.attributes;for(const i of Td){const o=r?.[i];typeof o=="string"&&o!==""&&(t={...t,[i]:o})}return n!==void 0?{content:n,attributes:t}:{attributes:t}}function $r(e,t){if(!e||!t)return;const n=e.getContent(),r=t.content!==void 0?bs(t.content):void 0,i=r!==void 0&&r!==n;e.get().docId,Object.keys(t.attributes??{}),e.mutate({attributes:t.attributes??{},...i?{changes:[new ge(0,n,0,r)]}:{}},{source:"remote"})}var In=e=>typeof e=="string"?e.trim():"";function Rd(e,t,n,r){const{version:i,attributes:o}=e.get(),s=o,a=r==="snapshot"||r==="anchor",c=a?s.author:void 0,d=a?s.date_gmt:void 0,f=In(s.title)||In(s.subject)||In(t.fallbackTitle);return{version:i,payload:{html:e.getContent(),title:f,subject:s.subject,preheader:s.preheader,description:s.description,common_styles:s.common_styles||"",meta:s.meta,utm_parameters:s.utm_parameters,parent_email:s.parent_email,is_template:s.is_template||!1,is_inited:s.is_inited,tags:s.tags,emailtags:s.emailtags,group:s.group,renderGuid:e.get().docId,project:t.project??s.project,folder:t.folder,...n?.emailtags?{emailtags:n.emailtags}:{},...n?.group?{group:n.group}:{},source:t.source,...c!=null&&c!==""?{author:c}:{},...d?{excerpt:d}:{}}}}var Pd=["meta","title","author","project","html","excerpt","subject","preheader","common_styles","parent_email"];function Dd(e){const t={};for(const n of Pd)e[n]!==void 0&&(t[n]=e[n]);return t.excerpt||(t.excerpt=new Date().toISOString()),t}async function Od(e,t,n,r,i){if(n==="materialize"&&r!=null)throw new Error("Письмо уже создано на сервере");if(n==="materialize"||n==="publish"&&r==null)return e.createEmail(i);if(r==null)throw new Error("Письмо ещё не создано на сервере");return n==="publish"?e.updateEmail(r,i):t.saveAutosave(r,i)}function ke(e,t=!1){const n={};for(const r of Object.keys(e)){let i=e[r];i!==void 0&&!(typeof i=="number"&&Number.isNaN(i))&&(t&&typeof i=="object"&&i!==null&&(i=ke(i)),n[r]=i)}return n}function xd(e){return typeof e=="string"&&e.includes("autosave")}var Md=new Set(["html","id","renderGuid","showToken","showId","isNew"]);function ys(e){return e?Object.fromEntries(Object.entries(e).filter(([t])=>!Md.has(t))):{}}function Ct(e,t,n={}){e&&e.mutate({attributes:kd(e.get().attributes,t)},{source:n.source??"user"})}function kd(e,t){return t.subject===void 0||t.title!==void 0?t:(e.title??"")===(e.subject??"")?{...t,title:t.subject}:t}function Gr(e,t){return e===void 0&&Object.keys(t).length===0?null:{...e!==void 0?{content:e}:{},attributes:t}}function Ld(e){return typeof e=="string"&&e.startsWith("{")?e:"{}"}function Es(e){if(!e)return null;const t=ys(e);return e.common_styles!==void 0&&(t.common_styles=Ld(e.common_styles)),Gr(e.html,t)}function _s(e){return e?Gr(e.html,ke(ys(e))):null}var Nd=["common_styles","subject","preheader","meta"];function Pi(e){if(!e?.html?.trim())return null;const t={};for(const n of Nd)Fd(n,e[n])&&(t[n]=e[n]);return Gr(e.html,t)}function Fd(e,t){return e==="common_styles"?typeof t=="string"&&t.startsWith("{"):e==="meta"?typeof t=="object"&&t!==null&&!Array.isArray(t):typeof t=="string"}var jd=["modified","lock"];function Bd(e){if(!e)return null;const t={};for(const n of jd)e[n]!==void 0&&(t[n]=e[n]);return Object.keys(t).length===0?null:{attributes:t}}var Ud=10,Hd=(e,t)=>e.key===t.key&&$d(e.serverId,t.serverId),$d=(e,t)=>e==null||e===t;function Gd(e){return typeof e?.then=="function"}var Di=e=>{e.timer!==void 0&&(clearTimeout(e.timer),e.timer=void 0)},ws=e=>{e.request.serverId!=null&&!Vr(e)&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent())},Vd=e=>e.document.get().serverId!=null&&!e.document.getContent().trim()&&!!(e.savedContent??e.lastMerged?.content??"").trim(),Vr=e=>e.document.get().savedVersion!==null&&e.document.isDirty(),Oi=(e,t)=>t?.content!==void 0&&Cd({hasUnsavedUserEdit:Vr(e)})==="skip",qd=e=>e.document.subscribe(t=>{t.source==="user"&&(t.content&&e.userTouched.add("content"),t.attributes?.forEach(n=>e.userTouched.add(n))),e.document.isDirty()||e.userTouched.clear()}),zd=(e,t)=>{!e.ready||t.content===void 0||e.document.get().serverId==null||(e.contentShown=!0,!(![...e.userTouched].every(n=>n==="content"||n in(t.attributes??{}))||!e.document.isDirty())&&(e.document.markSaved(e.document.get().version),e.savedContent=e.document.getContent(),e.userTouched.clear(),e.document.get().docId))},Wd=(e,t)=>{if(!e)return t;const n=Object.fromEntries(Object.entries(t.attributes).filter(([i,o])=>e.attributes[i]!==o)),r=t.content!==void 0&&t.content!==e.content?t.content:void 0;return r===void 0&&Object.keys(n).length===0?null:r===void 0?{attributes:n}:{content:r,attributes:n}},Kd=e=>{const t=Ad(e.reports),n=Wd(e.lastMerged,t);e.lastMerged=t,n&&($r(e.document,n),ws(e))},Cn=(e,t)=>{if(!e.ready&&!Vr(e)){Kd(e);return}$r(e.document,t)},Yd=e=>{const{attributes:t,serverId:n,docId:r}=e.document.get();return{...t,html:e.document.getContent(),id:n??void 0,isNew:n==null,renderGuid:r}};function Xd(e){const{resolveAdapters:t,timeoutMs:n,resolveWritePort:r,resolveHistoryPort:i,resolveTerms:o,canEdit:s,notifyBeforeSave:a,onAdapterError:c,onTimeout:d}=e;let f;const h=new Set,y=new Set,b=()=>h.forEach(l=>l()),T=(l,u)=>{if(!(l.closed||l.ready)){if(l.error!==void 0){l.document.markFailed(l.error),l.document.get().docId;return}ws(l),l.ready=!0,l.document.markReady(),l.document.get().docId,[...l.reports.keys()]}},w=(l,u,p)=>{c?.(u.id,p),!(!u.required||l.closed)&&(l.error=p,l.document.get().docId,u.id,b())},g=(l,u)=>{const p=new Set(u.map(I=>I.id));u.forEach(I=>{I.watch&&l.watchers.push(I.watch(O=>l.closed?!1:l.ready&&(Oi(l,O)||l.contentShown===!0&&O?.content!==void 0)?(l.document.get().docId,I.id,!1):(O&&l.reports.set(I.id,O),Cn(l,O),!0)))});const R=(I,O)=>{if(!l.closed){if(!I.required&&Oi(l,O)){l.document.get().docId,I.id,I.loaded?.(!1);return}O&&l.reports.set(I.id,O),Cn(l,O),I.loaded?.(O!==null)}},D=()=>{p.size>0||l.closed||(Di(l),T(l,[]))},L=[];if(u.forEach(I=>{let O;try{O=I.load()}catch(k){w(l,I,k),p.delete(I.id);return}if(Gd(O)){L.push({id:I.id,required:I.required,load:()=>O,...I.loaded?{loaded:k=>I.loaded?.(k)}:{}});return}R(I,O),p.delete(I.id)}),L.length===0){D();return}l.timer=setTimeout(()=>{l.timer=void 0,d?.([...p]),l.document.get().docId,[...p],T(l,[...p])},n),l.timer.unref?.(),L.forEach(I=>{I.load().then(O=>R(I,O)).catch(O=>{w(l,I,O)}).finally(()=>{p.delete(I.id),D()})})},C=async(l,u,p)=>{if(p==="snapshot"||p==="anchor")return;const R=o?.();if(R)return R.resolve({project:u.project??l.project,tags:(l.tags??[]).map(D=>({name:D}))})},_=l=>{if(l.lock===!0&&s?.(l)===!1)return new vt("locked");const u=l.tags?.length??0,p=l.emailtags?.length??0;if(Math.max(u,p)>Ud)return new vt("too-many-tags")},P=(l,u)=>{const p=l.document.get().serverId;u||p==null||(l.recoveryFacts={emailId:p,historyLoaded:!0,isRecovering:!1},ye(l.request.key)||(l.request={...l.request,key:Ke(p),serverId:p}))},S=(l,u,p)=>{if(l.closed||p?.id==null)return;const R=l.document.get().serverId,D=R!=null;D&&R!==String(p.id)||(l.document.markSaved(u,String(p.id)),P(l,D),l.document.get().serverId,b())},M=async(l,u,p)=>{try{await l.document.whenReady()}catch(O){return l.saveError=O,l.saveFailures+=1,l.failedIntent=u,l.saveFailures,!1}if(l.closed)return!1;const R=_(l.document.get().attributes);if(R)return l.saveError=R,l.saveFailures+=1,l.failedIntent=u,R.reason,b(),!1;if(a&&(await a(Yd(l)).catch(()=>{}),l.closed))return!1;if(Vd(l))return u==="snapshot"||(l.saveError=new vt("empty-content"),l.saveFailures+=1,l.failedIntent=u,b()),!1;let D;try{D=await C(l.document.get().attributes,p,u)}catch(O){return l.saveError=O,l.saveFailures+=1,l.failedIntent=u,l.saveFailures,b(),!1}if(l.closed)return!1;const{payload:L,version:I}=Rd(l.document,p,D,u);l.document.get().docId;try{const O=l.document.get().serverId!=null,k=await Od(r(),i(l.request.key),u,l.document.get().serverId,L);if(l.closed)return!0;let ee;if(u==="snapshot"||u==="anchor"){const X=k?.modified!=null?Date.parse(k.modified):NaN;ee=Number.isFinite(X)?X:Date.now(),l.snapshotVersion=I,l.lastRevisionAt=ee}else l.document.markSaved(I,k?.id!=null?String(k.id):void 0),l.savedContent=L.html;P(l,O),l.saveError=void 0,l.saveFailures=0,l.failedIntent=void 0,l.document.get().serverId,b();const ce={intent:u,serverId:l.document.get().serverId,created:!O,...ee!==void 0?{revisionAt:ee}:{}};return y.forEach(X=>X(ce)),!0}catch(O){return(u==="publish"||u==="materialize")&&gd(O)?.then(k=>S(l,I,k)),l.saveError=O,l.saveFailures+=1,l.failedIntent=u,l.saveFailures,b(),!1}},v=()=>{f&&(f.closed=!0,f.watchers.forEach(l=>l()),f.watchers=[],Di(f),f.history.dispose(),f.document.dispose(),f=void 0)},E=(l,u,p)=>{let R=!1;u.show&&(l.show?.id!==u.show.id||l.show.token!==u.show.token)&&(l.show=u.show,R=!0,{docId:l.document.get().docId,...u.show});const D=p==="show"?_s(u.patch):null;D&&(l.reports.set("plugin",D),Cn(l,D),zd(l,D)),R&&b()},A=(l,u={})=>{const p=f;return!p||p.closed||l==="materialize"&&p.document.get().serverId!=null?Promise.resolve(!1):p.saving?l==="snapshot"||l==="materialize"?Promise.resolve(!1):(p.inFlight??Promise.resolve(!1)).then(()=>A(l,u)):(p.saving=!0,b(),p.inFlight=M(p,l,u).finally(()=>{p.saving=!1,p.inFlight=void 0,f===p&&!p.closed&&b()}),p.inFlight)},m=(l,u="open")=>{if(f&&!f.closed&&u!=="new"&&Hd(f.request,l))return E(f,l,u),f.document;v();const p=rd({createBuffer:()=>Yc(""),serverId:l.serverId??null}),R={request:l,show:l.show,document:p,history:sd(p,{now:Date.now}),watchers:[],userTouched:new Set,saveFailures:0,saving:!1,reports:new Map,ready:!1,closed:!1};return f=R,R.watchers.push(qd(R)),p.get().docId,l.serverId,g(R,t(l,{publishRecoveryFacts(D){R.closed||(R.recoveryFacts=D,b())},readShownContent:()=>R.closed?null:R.document.getContent()})),b(),p};return{openWith:m,open:(l,u={})=>m({key:Ke(l),serverId:l,email:u.email,patch:u.patch,show:u.show},"open"),openDraft:(l,u={})=>m({key:Ke(void 0),serverId:null,email:l,patch:u.patch,show:u.show},"open"),startNewDraft:(l,u={})=>m({key:Ke(void 0),serverId:null,email:l,patch:u.patch,show:u.show},"new"),reload:(l,u={})=>m({key:Ke(l),serverId:l,email:u.email,patch:u.patch,show:u.show},"new"),openBlock:(l,u)=>m({key:ye(l)?l:Ed(l),serverId:u?.id!=null?String(u.id):null,email:u},"open"),show:(l,u)=>{const p=f;if(!(!p||p.closed))return m({...p.request,patch:l,show:u},"show")},current:()=>f?.document,noteServerFacts:({serverId:l,block:u},p)=>{const R=f;!R||R.closed||R.request.serverId!==l||ye(R.request.key??"")===u&&$r(R.document,Bd(p))},save:A,saveState:()=>({error:f?.saveError,failures:f?.saveFailures??0,saving:f?.saving===!0,failedIntent:f?.failedIntent}),revisionFacts(){if(!f)return;const l=f.revisionFactsSnapshot;return l&&l.snapshotVersion===f.snapshotVersion&&l.lastRevisionAt===f.lastRevisionAt?l:(f.revisionFactsSnapshot={snapshotVersion:f.snapshotVersion,lastRevisionAt:f.lastRevisionAt},f.revisionFactsSnapshot)},recoveryFacts:()=>f?.recoveryFacts,history:()=>f?.history,forcedHeaders:()=>f?.forcedHeaders,beginForcedHeaders(l){f&&!f.closed&&(f.forcedHeaders=l)},endForcedHeaders(){f&&(f.forcedHeaders=void 0)},onSaved(l){return y.add(l),()=>y.delete(l)},showFacts:()=>f?.show,sessionKey:()=>f?.request.key,openError:()=>f?.error,subscribe(l){return h.add(l),()=>h.delete(l)},close(){f&&(v(),b())}}}var qr=class extends Error{reason;constructor(e,t){super(`письмо не открылось: ${e}`),this.name="EmailOpenFailedError",this.reason=e,this.cause=t}};function zr(e){if(e instanceof qr)return e.reason;if(e instanceof It)return zr(e.reason)}function Jd(e){const t=e instanceof It?e.reason:e;return t instanceof qr&&t.reason==="unavailable"&&t.cause instanceof TypeError}function Qd(e){const t=zr(e);return t==="forbidden"||t==="not-found"}function Zd(e,t){return{id:"rest",required:!0,load:async()=>{const n=await e.readEmail(t);if(!n)throw new qr("not-found");return Es(n)}}}var Ss=F("EmailPort");function eu(e){return e.getInstance(Ss)}function tu(e,t){e.inject(Ss,t)}var Is=F("documentSession.restEmailPortFactories");function Cs(e){return e.getInstance(Is)!==void 0}function Ve(e){const t=e.getInstance(Is);if(!t)throw new Error("[documentSession] порты поверх REST ещё не загружены — работа с сервером начинается с init()");return t}var nu=F("EmailTermsResolver");function ru(e){return e.getInstance(nu)}var Ts=F("EmailHistoryPort"),iu=F("BlockHistoryPort");function As(e){return e.getInstance(iu)}function Rs(e){return e.getInstance(Ts)}function ou(e,t){e.inject(Ts,t)}var su="em_autosave_pending";function on(e){return`${su}_${e}`}function au(e,t){try{sessionStorage.setItem(on(e),JSON.stringify(t))}catch{}}function Ps(e){try{const t=sessionStorage.getItem(on(e));if(!t)return null;const n=JSON.parse(t);return Date.now()-n.sentAt>6e4?(sessionStorage.removeItem(on(e)),null):n}catch{return null}}function ut(e){try{sessionStorage.removeItem(on(e))}catch{}}var lu=2e3,cu=5e3,du=5,uu=5e3,fu=4;function pu(){return typeof performance<"u"&&typeof performance.timeOrigin=="number"?performance.timeOrigin:Date.now()}function hu(e,t){return e==null||t==null?!1:e.replaceAll(`\r
|
|
998
999
|
`,`
|
|
999
1000
|
`)===t.replaceAll(`\r
|
|
1000
1001
|
`,`
|
|
1001
|
-
`)}function fd({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:a,pageLoadTs:l=cd()}){let u=null,m=!1,v=!1,E=0,g={emailId:e,historyLoaded:!1,isRecovering:!1},_=null;const b=new Promise(R=>{_=R}),y=R=>{g={...g,...R},o(g)};let S;const I=R=>{E+=1,y({applied:{phase:R,seq:E}})},A=()=>{u?.timer&&clearTimeout(u.timer),u=null},f=R=>{if(!v){if(_){const F=_;_=null,F(R),S=R.revision?R.phase:void 0;return}s(R)&&R.revision&&I(R.phase)}},c=()=>{if(!u||v)return;const R=u.phase==="fast",F=R?od:ld,C=R?ad:dd;u.timer=setTimeout(()=>{const P=u;if(!(!P||v)){if(P.attempts+=1,T(),R&&P.attempts>=C){const{pending:j}=P;ft(e),y({isRecovering:!1}),f({revision:{html:j.html,common_styles:j.common_styles,subject:j.subject,preheader:j.preheader},phase:"timeout"}),m=!0,P.phase="bg",P.attempts=0,c();return}if(!R&&P.attempts>=C){ft(e),A(),y({isRecovering:!1}),m=!0;return}c()}},F),u.timer.unref?.()},d=R=>{u={phase:"fast",attempts:0,pending:R,timer:null},y({isRecovering:!0}),c()},p=(R,F)=>Jn(R.autosave,F===void 0?{}:{freshSince:F})?R.autosave:null,h=R=>{if(v)return;if(y({historyLoaded:!0,latestRevisionAt:R.latestAt!==void 0&&Number.isFinite(R.latestAt)?R.latestAt:void 0}),n&&u){const P=p(R,u.pending.sentAt);if(!P)return;const j=u.phase==="fast"?"found":"bg";ft(e),A(),y({isRecovering:!1}),m=!0,f({revision:P,phase:j});return}if(m)return;const F=n?id(e):null,C=F&&(F.sentAt<l||!ud(F.html,i()))?F:null;if(C){const P=p(R,C.sentAt);if(P){ft(e),m=!0,f({revision:P,phase:"found"});return}d(C);return}m=!0,f({revision:p(R),phase:"normal"})},w=R=>{v||(a?.(R),g.historyLoaded||(y({historyLoaded:!1,latestRevisionAt:void 0}),Y()),!u&&f({revision:null,phase:"normal"}))},T=()=>t(e).then(h).catch(w);let D,L=!1;const Y=()=>{L||u||v||(L=!0,D=setTimeout(()=>{D=void 0,!v&&!g.historyLoaded&&T()},sd))},k=()=>{v||(y({historyLoaded:!1,latestRevisionAt:void 0}),f({revision:null,phase:"normal"}))};return r?r().then(R=>R?T():k()):T(),{verdict:()=>b,confirmVerdict(R){const F=S;S=void 0,R&&F!==void 0&&!v&&I(F)},dispose(){v=!0,D!==void 0&&(clearTimeout(D),D=void 0),A()}}}function pd({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const a=fd({emailId:r,readAutosave:l=>e.readAutosave(l),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:l,phase:u})=>{const m=Or(l);return s?.(m)??!1},onError:l=>{l instanceof Error&&l.message}});return{id:"recovery",load:()=>a.verdict().then(({revision:l})=>Or(l)),loaded(l){a.confirmVerdict(l)},watch(l){return s=l,()=>{s=null,a.dispose()}}}}function vo(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){rd(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const i=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),i}}}function hd(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const i=await t.updateEmail(n,r);return await e.updateEmail(n,r),i}}}var bo=N("CurrentUser"),yo={};function tr(e){return e.getOrCreateInstance(bo,()=>Te(yo))}function Eo(e){return e?.getInstance(bo)?.get()??yo}function _o(e){return e?.getInstance(ye)?.get()??{}}var md=1.5;function gd(e){return!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=md*e.autosaveTimeoutMs?"none":"revision"}var vd=4;function bd(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=()=>n().autosaveTimeoutMs*2**Math.min(o(),vd),a=()=>{const S=t();if(!S||S.isDisposed())return"none";const{latestRevisionAt:I,snapshotVersion:A,...f}=n();return gd({...f,isDirty:S.isDirty(),isNew:S.isNew(),isReady:S.isReady(),latestRevisionAgeMs:I!=null?Date.now()-I:void 0,isSnapshotSent:A!=null&&A===S.get().version})},l=()=>{const S=t();if(!S||S.isDisposed())return!1;if(!S.isDirty())return S.isNew();const{snapshotVersion:I}=n();return!(I!=null&&I===S.get().version)};let u,m,v,E,g=!1;const _=()=>{m=void 0;const S=t();if(!S||S.isDisposed())return;if(S.get().docId!==u){b();return}const I=a();I==="create"?r():I==="revision"?i():l()&&(u=S.get().docId,m=setTimeout(_,s()))},b=()=>{const S=t();g||!S||m!==void 0||a()==="none"&&!l()||(u=S.get().docId,m=setTimeout(_,s()))},y=()=>{const S=t();S!==v&&(E?.(),v=S,E=S?.subscribe(b),m!==void 0&&(clearTimeout(m),m=void 0))};return y(),b(),{refresh:()=>{g||(y(),b())},stop:()=>{g=!0,E?.(),E=void 0,v=void 0,m!==void 0&&(clearTimeout(m),m=void 0)}}}var wo=N("documentSession.autosaveUiFacts"),So={isUserBusy:!1,saveContext:{}};function yd(e){return e.getOrCreateInstance(wo,()=>Te(So))}function kr(e){return e?.getInstance(wo)?.get()??So}var Ed=1e4;function _d(e,t){const n=()=>{const l=t.current(),u=l?.get().serverId??void 0,m=de(t.sessionKey()),v=t.recoveryFacts(),E=v?.emailId===u?v:void 0,g=t.revisionFacts(),_=E?.latestRevisionAt,b=g?.lastRevisionAt,y=Eo(e).profile;return{isInited:m||l?.get().attributes.is_inited===!0,isEnabled:!!y?.autosaves,isHistoryLoaded:E?.historyLoaded===!0,isUserBusy:kr(e).isUserBusy,autosaveTimeoutMs:_o(e).autosaveTimeout||Ed,latestRevisionAt:_!==void 0||b!==void 0?Math.max(_??0,b??0):void 0,snapshotVersion:g?.snapshotVersion}},r=()=>{const l=kr(e).saveContext;return{...l,project:l.project??t.current()?.get().attributes.project}},i=bd({readDocument:()=>t.current(),readEnvironment:n,readFailures:()=>t.saveState().failures,onCreate:()=>{de(t.sessionKey())||t.save("materialize",r())},onRevision:()=>{t.save("snapshot",{project:r().project})}}),o=t.subscribe(i.refresh),s=tr(e).watch(()=>i.refresh()),a=yd(e).watch(()=>i.refresh());return()=>{o(),s.dispose(),a.dispose(),i.stop()}}var Lr=12e3;function we(e){return e.getOrCreateInstance(Wn,()=>{const t=Wl({resolveAdapters:(r,i)=>Id(r,e,i),resolveWritePort:()=>Io(e),resolveHistoryPort:r=>de(r)?To(e):Ao(e),resolveTerms:()=>Zl(e),canEdit:r=>Xa(e,r),notifyBeforeSave:rl(e),timeoutMs:Lr,onAdapterError:(r,i)=>{i instanceof Error&&i.message,Lt(i,{origin:"email-source-adapter",tags:{source:r}})},onTimeout:r=>{}}),n=_d(e,t);return e.getInstance(U)?.addDispose(n),t})}function nr(e){return e?.getInstance(Wn)}function Io(e){const t=Xl(e);return t?rr(e)?hd(t,Ae(e).email(e)):t:Ae(e).email(e)}function wd(e){return go(e)!==void 0||po(e)}function Ao(e){const t=go(e);return t?rr(e)?(V("port:history:server-backed"),vo(t,Ae(e).history(e))):(V("port:history:integrator"),t):(V("port:history:rest (порт не зарегистрирован)"),Ae(e).history(e))}function To(e){const t=mo(e);return t?rr(e)?(V("port:block-history:server-backed"),vo(t,Ae(e).blockHistory(e))):(V("port:block-history:integrator"),t):(V("port:block-history:rest (порт не зарегистрирован)"),Ae(e).blockHistory(e))}function Sd(e){return mo(e)!==void 0||po(e)}function rr(e){return Ki(e)}function Id({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>oo(e),required:!0}):n&&s.push(Yl(Io(i),n)),t&&s.push({id:"plugin",load:()=>so(t)});const a=de(r);return il(n)&&(a?Sd(i):wd(i))&&s.push(pd({port:a?To(i):Ao(i),revisionServiceEnabled:Ki(i),...!a&&Ja(i)?{isHistoryAvailable:()=>Qa(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:l=>o.publishRecoveryFacts(l)})),s}function ee(e){return e.getOrCreateInstance(ot,()=>new st)}var Co=new WeakMap,En=new WeakMap;function me(e){return Co.get(e)??0}function Ro(e,t){let n=En.get(e);return n||(n=new Set,En.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Ad(e){Co.set(e,me(e)+1),En.get(e)?.forEach(t=>t())}function Td(e){const t=we(e),n=ee(e).addListener(H.APPLICATION_HAS_AMP,r=>{Ve(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(U)?.addDispose(()=>n.dispose())}function Cd(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Rd(e){const t=e.fetchImpl??((o,s)=>fetch(o,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,i=o=>{try{const s=new URL(o,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:i,async load(o){if(!i(o))return;const s=!r.has(o);r.add(o);try{const a=await t(o,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!a.ok)return;const l=await a.blob();return Cd(l)?l:void 0}catch{return}}}}var Ie={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function Pd(e){const t={maxBytes:e.maxBytes??Ie.maxBytes,maxImageBytes:e.maxImageBytes??Ie.maxImageBytes,ttlMs:e.ttlMs??Ie.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const a=v=>{const E=r.get(v);E&&(s-=E.bytes,r.delete(v))},l=v=>t.ttlMs<=0||n()-v.storedAt<t.ttlMs,u=()=>{if(s<=t.maxBytes)return;const v=[...r.entries()].sort((E,g)=>E[1].usedAt-g[1].usedAt);for(const[E]of v){if(s<=t.maxBytes)return;a(E)}},m=(v,E)=>{E.size>t.maxImageBytes||(r.set(v,{blob:E,bytes:E.size,storedAt:n(),usedAt:n()}),s+=E.size,u())};return{async get(v){const E=r.get(v);if(E&&l(E))return E.usedAt=n(),o.hits+=1,E.blob;E&&a(v);const g=i.get(v);if(g!==void 0)return g;o.loads+=1;const _=(async()=>{try{const b=await e.load(v);return b?m(v,b):o.failures+=1,b}catch{o.failures+=1;return}finally{i.delete(v)}})();return i.set(v,_),_},forget(v){a(v),i.delete(v)},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var Dd=["emcdn.ru","scr.emcdn.ru"];function Od(e){const t=String(e??"").trim();if(!t)return"";try{return new URL(t.includes("//")?t:`https://${t}`).hostname}catch{return t.split("/")[0].split(":")[0]}}function xd(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const a=Od(s);a&&o.add(a)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Nr(e){const t=e??{},n=t.isPlugin!==!0?Dd:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Ie};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:xd(i.sourceHosts,n),maxBytes:i.maxBytes??Ie.maxBytes,maxImageBytes:i.maxImageBytes??Ie.maxImageBytes,ttlMs:i.ttlMs??Ie.ttlMs}}function Md(e){const t=ee(e),n=e.getInstance(ye);let r=Nr(n?.get());const i=Rd({sourceHosts:()=>r.sourceHosts}),o=Pd({load:_=>i.load(_),maxBytes:r.maxBytes,maxImageBytes:r.maxImageBytes,ttlMs:r.ttlMs}),s=()=>{t.send(H.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:r.enabled,sourceHosts:[...r.sourceHosts]})},a=t.onInit(()=>s()),l=n?.watch(()=>{const _=Nr(n.get()),b=JSON.stringify(_)!==JSON.stringify(r);r=_,_.enabled||o.clear(),b&&t.isInited()&&s()}),u={asked:0,served:0,refused:0},m=[],v=(_,b)=>(u.refused+=1,m.push({url:_,reason:b}),m.length>20&&m.shift(),{refused:!0}),E=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:r,counters:{...u},refusals:[...m],store:o.stats()})}),g=t.addListenerAsync(H.APPLICATION_CANVAS_IMAGE_GET,async _=>{const b=_?.url??"";if(u.asked+=1,!r.enabled||!b)return v(b,"disabled");if(!i.accepts(b))return v(b,"host");_.fresh&&o.forget(b);const y=await o.get(b);return y?(u.served+=1,{blob:y}):v(b,"load-failed")});e.getInstance(U)?.addDispose(()=>{a.dispose(),l?.dispose(),g.dispose(),o.clear(),delete E.__emmCanvasImages__})}var kd=2e3;function Ld(e){const t=ee(e),n=new Set,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;const a=new MessageChannel;let l=!1;const u=v=>{v.data?.operationId==="em:port-ready"&&(l=!0,a.port1.removeEventListener("message",u),t.drainWindow(s))};a.port1.addEventListener("message",u),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const m=setTimeout(()=>{n.delete(m),!l&&(Lt(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),a.port1.removeEventListener("message",u),t.useWindow(s))},kd);n.add(m)},i=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),o=t.onInit(()=>r());e.getInstance(U)?.addDispose(()=>{for(const s of n)clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var Nd=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function Fd(e){return Nd.test(e)||e.indexOf("//")===0}function pt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function jd(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Fr(e,t){const n=e==null||e===""?"./":String(e);if(Fd(n))return pt(n);const r=t??jd();if(!r)return pt(n);try{return pt(new URL(n,r).href)}catch{return pt(n)}}function Bd(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?Fr(window.__useblocks__.publicPath):Fr("/")}var Ud=()=>"",Hd=()=>"bb6d921f";function Po(e){const t=e?"iframe-eblock":"iframe",n=Ud();if(n){const o=n.replace(/\/?$/,"/");return Sr(`${o}${t}.html`,et())}const r=Hd(),i=`${Bd().replace(/\/?$/,"/")}iframe/`;return Sr(`${i}${t}${r?`.${r}`:""}.html`,et())}var jr="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function _n(e){return/^file:/i.test(String(e||"").trim())}function Gd(e){return _n(e)?`${jr} allow-same-origin`:jr}var qd="em:module-body-ack";function $d(e,t,n){try{const r=new URL("./",new URL(t,n)).href,i=new URL(e,r).href;return i.startsWith(r)?i:void 0}catch{return}}function ir(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.[0-9a-f]{6,})?\.html$/.exec(t);return n?`js/${n[1]}.body.js`:void 0}function zd(e,t){const n=ir(t)?.replace(/^js\/|\.body\.js$/g,""),r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function Vd(e,t){const n=ir(t)?.replace(/\.body\.js$/,".js");if(!n||!(n in e))return[];const r=new Set([n]),i=[n],o=[];for(;i.length>0;)for(const s of e[i.shift()]??[])r.has(s)||(r.add(s),o.push(s),i.push(s));return o}async function Kd(e,t){try{const n=await fetch(e,t?.priority?{priority:t.priority}:void 0);return n.ok?await n.blob():void 0}catch{return}}function Wd(e){const t=new Map,n=(r,i)=>{const o=$d(r,e.canvasSrc,e.origin);if(!o)return;const s=t.get(o);if(s!==void 0)return s;const a=e.fetchBody(o,i);return t.set(o,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,i){for(const o of r)n(o,i)},reset(){t.clear()},get size(){return t.size}}}var ve;function Yd(e){try{return _n(new URL(e,window.location.href).href)}catch{return _n(window.location.href)}}function Do(){const e=Po(!1);if(!Yd(e))return(!ve||ve.canvasSrc!==e)&&(ve={canvasSrc:e,store:Wd({canvasSrc:e,origin:window.location.href,fetchBody:Kd}),warmed:!1}),ve.store}async function Xd(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n);if(!r.ok)return;const i=await r.json();t(zd(i,e))}catch{}}function or(e){const t=Do();if(!t||!ve||ve.warmed)return;ve.warmed=!0;const{canvasSrc:n}=ve,r=ir(n);r&&t.warm([r],e);const i={"js/iframe-eblock.js":["js/discussHandlers.ozU2Hn_l.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.ozU2Hn_l.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.ozU2Hn_l.js":["js/rolldown-runtime.BRlIiq3h.js"],"js/rolldown-runtime.BRlIiq3h.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.BbXdyfMT.js":["js/rolldown-runtime.BRlIiq3h.js"]};i?t.warm(Vd(i,n),e):Xd(n,o=>t.warm(o,e))}function Jd(e){const t=Do();if(!t)return;or();const n=r=>{const i=r.data;if(!i||i.operationId!=="em:module-body"||!i.result)return;const o=r.source;o&&(o.postMessage({operationId:qd,for:i.result},"*"),t.take(i.data?.url??"").then(s=>{o.postMessage({operationId:i.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(U)?.addDispose(()=>{window.removeEventListener("message",n)})}var xe=/<script\b(?=[^>]*(?:\bbis_use(?:=|\s)|\bdata-bis-config(?:=|\s)|\bdata-dynamic-id(?:=|\s)|local\.adguard\.org|(?:chrome-extension|moz-extension|safari-extension):\/\/))[^>]*>[\s\S]*?<\/script>/gi,Qd=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,Fe=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Br=/display:\s*none\s*!important/gi,Zd=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,ec=/\s*height\s*:\s*100%\s*!important\s*;?/gi,tc=/height\s*:\s*100%\s*!important/i,nc=[".socialshare,",".advertisment,",".adHolder,",".adsbygoogle-noablate","#ab_adblock","#popmechanic-snippet","filter_ads_by_classname","clever-core-ads","--gn-ov-ad-height","pub_728x90.text-ad.textAd","html-load.com/player","content-loader.com/player",".adblock","#advblock","body { overflow: visible!important; }"];function rc(e){return Br.lastIndex=0,(e.match(Br)||[]).length}function Oo(e){const t=e.trim(),n=rc(t);if(n===0)return!1;if(t.includes(".advertisment,")&&t.includes(".adHolder,")&&(t.includes(".socialshare,")||n>=3||t.length>2e3))return!0;const r=nc.filter(i=>t.includes(i)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function ic(e){Fe.lastIndex=0;for(const t of e.matchAll(Fe))if(Oo(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function oc(e){let t=!1;return Fe.lastIndex=0,{html:e.replace(Fe,n=>Oo(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function sc(e){return xe.lastIndex=0,xe.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||ic(e)}function ac(e){if(!sc(e))return{html:e,found:!1};let t=!1,n=e;xe.lastIndex=0,xe.test(n)&&(xe.lastIndex=0,n=n.replace(xe,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(Qd,""),t=!0);const r=oc(n);return n=r.html,t=t||r.found,{html:n,found:t}}function lc(e){return!e||!tc.test(e)?e:(Fe.lastIndex=0,e.replace(Fe,t=>t.replace(Zd,(n,r,i,o)=>`${r}${i.replace(ec,"")}${o}`)))}function xo(e){const t=ac(e.replaceAll(`\r
|
|
1002
|
+
`)}function Tn(e,t){return Hr(e.autosave,t===void 0?{}:{freshSince:t})?e.autosave:null}function mu({emailId:e,readAutosave:t,revisionServiceEnabled:n,isHistoryAvailable:r,readShownContent:i,onFacts:o,onLate:s,onError:a,pageLoadTs:c=pu()}){let d=null,f=!1,h=!1,y=0,b={emailId:e,historyLoaded:!1,isRecovering:!1},T=null;const w=new Promise(D=>{T=D}),g=D=>{b={...b,...D},o(b)};let C;const _=D=>{y+=1,g({applied:{phase:D,seq:y}})},P=()=>{d?.timer&&clearTimeout(d.timer),d=null},S=D=>{if(!h){if(T){const L=T;T=null,L(D),C=D.revision?D.phase:void 0;return}s(D)&&D.revision&&_(D.phase)}},M=()=>{if(!d||h)return;const D=d.phase==="fast",L=D?lu:uu,I=D?du:fu;d.timer=setTimeout(()=>{const O=d;if(!(!O||h)){if(O.attempts+=1,m(),D&&O.attempts>=I){const{pending:k}=O;ut(e),g({isRecovering:!1}),S({revision:{html:k.html,common_styles:k.common_styles,subject:k.subject,preheader:k.preheader},phase:"timeout"}),f=!0,O.phase="bg",O.attempts=0,M();return}if(!D&&O.attempts>=I){ut(e),P(),g({isRecovering:!1}),f=!0;return}M()}},L),d.timer.unref?.()},v=D=>{d={phase:"fast",attempts:0,pending:D,timer:null},g({isRecovering:!0}),M()},E=D=>{if(h)return;if(g({historyLoaded:!0,latestRevisionAt:D.latestAt!==void 0&&Number.isFinite(D.latestAt)?D.latestAt:void 0}),n&&d){const O=Tn(D,d.pending.sentAt);if(!O)return;const k=d.phase==="fast"?"found":"bg";ut(e),P(),g({isRecovering:!1}),f=!0,S({revision:O,phase:k});return}if(f)return;const L=n?Ps(e):null,I=L&&(L.sentAt<c||!hu(L.html,i()))?L:null;if(I){const O=Tn(D,I.sentAt);if(O){ut(e),f=!0,S({revision:O,phase:"found"});return}v(I);return}f=!0,S({revision:Tn(D),phase:"normal"})},A=D=>{h||(a?.(D),b.historyLoaded||(g({historyLoaded:!1,latestRevisionAt:void 0}),p()),!d&&S({revision:null,phase:"normal"}))},m=()=>t(e).then(E).catch(A);let l,u=!1;const p=()=>{u||d||h||(u=!0,l=setTimeout(()=>{l=void 0,!h&&!b.historyLoaded&&m()},cu))},R=()=>{h||(g({historyLoaded:!1,latestRevisionAt:void 0}),S({revision:null,phase:"normal"}))};return r?r().then(D=>D?m():R()):m(),{verdict:()=>w,confirmVerdict(D){const L=C;C=void 0,D&&L!==void 0&&!h&&_(L)},dispose(){h=!0,l!==void 0&&(clearTimeout(l),l=void 0),P()}}}function gu({port:e,revisionServiceEnabled:t,isHistoryAvailable:n,emailId:r,readShownContent:i,onFacts:o}){let s=null;const a=mu({emailId:r,readAutosave:c=>e.readAutosave(c),revisionServiceEnabled:t,...n?{isHistoryAvailable:n}:{},readShownContent:i,onFacts:o,onLate:({revision:c,phase:d})=>{const f=Pi(c);return s?.(f)??!1},onError:c=>{c instanceof Error&&c.message}});return{id:"recovery",load:()=>a.verdict().then(({revision:c})=>Pi(c)),loaded(c){a.confirmVerdict(c)},watch(c){return s=c,()=>{s=null,a.dispose()}}}}function Ds(e,t){return{readRevisions:(n,r)=>t.readRevisions(n,r),readAutosave:n=>t.readAutosave(n),async saveAutosave(n,r){au(n,{sentAt:Date.now(),html:r.html??"",common_styles:r.common_styles??"",subject:r.subject,preheader:r.preheader});const i=await t.saveAutosave(n,r);return await e.saveAutosave(n,r),i}}}function vu(e,t){return{readEmail:n=>e.readEmail(n),createEmail:n=>e.createEmail(n),async updateEmail(n,r){const i=Date.now(),o=await t.updateEmail(n,r);return await e.updateEmail(n,r),(Ps(n)?.sentAt??Number.POSITIVE_INFINITY)<=i&&ut(n),o}}}var Os=F("CurrentUser"),xs={};function Wr(e){return e.getOrCreateInstance(Os,()=>Ee(xs))}function Ms(e){return e?.getInstance(Os)?.get()??xs}var ks=F("HeadlessMode");function Ls(e){return e.getOrCreateInstance(ks,()=>Ee(!1))}function bu(e){return e?.getInstance(ks)?.get()??!1}var yu=F("HiddenMount");function Eu(e){return e.getOrCreateInstance(yu,()=>Ee(!1))}function _u(e){if(!e)return!1;try{return!!Mr(e).data?.act_as}catch{return!1}}function wu(e){return _u(e?.getInstance(Xo)?.get(Yl.em_token))}function Ns(e){return e?.getInstance(oe)?.get()??{}}function mn(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Su(e,t){return t.modeDefaults(mn(e,t.fallbackMode))}function Fs(e,t){const n=mn(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function js(e,t){const n=mn(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function Iu(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Cu(e){return Dl(e.map(t=>t?.resourceProxy))}function Tu(e){return Kl(e.map(t=>t?.resourceProxyPolicy))}function Au(e){return yl(e.map(t=>t?.backendProxy))}function Ru(e){return Vo(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Pu(e,t){return[e.base,Su(e,t),e.profile,e.serverSide,Fs(e,t.fallbackMode),e.local,e.user,js(e,t.fallbackMode)]}function An(e,t){const n=Pu(e,t),r=Vo(n),i=Iu(n);i!==void 0&&(r.fileManager=i);const o=Cu(n);o!==void 0&&(r.resourceProxy=o);const s=Tu(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=Au(n);a!==void 0&&(r.backendProxy=a);const c=Ru(n);return c&&Object.keys(c).length>0&&(r.backendProxyPolicy=c),r}function Du(e,t,n){const r=Fs(e,n),i=js(e,n);return Wl([i,e.user,r,e.serverSide],t)}var Ou=1.5;function xu(e){return e.isHeadless||!e.isEnabled||e.isUserBusy||!e.isReady||!e.isInited?"none":e.isNew?"create":!e.isDirty||e.isSnapshotSent||!e.isHistoryLoaded||e.latestRevisionAgeMs!==void 0&&e.latestRevisionAgeMs<=Ou*e.autosaveTimeoutMs?"none":"revision"}function Mu(e){const{readDocument:t,readEnvironment:n,onCreate:r,onRevision:i}=e,o=e.readFailures??(()=>0),s=e.readFailureRetryable??(()=>!0);let a;const c=E=>a!==void 0&&a.version===E.get().version?o()-a.failuresAtStart:0,d=E=>{const A=c(E);if(A<=0)return!1;const m=n().retryMaxAttempts??5;return!s()||A>m},f=()=>{const{autosaveTimeoutMs:E,retryIntervalMs:A}=n(),m=t();return m!==void 0&&c(m)>0&&A!==void 0&&A>0?A:E},h=E=>E.isNew()&&o()>=3,y=()=>{const E=t();if(!E||E.isDisposed()||d(E))return"none";const{latestRevisionAt:A,snapshotVersion:m,...l}=n(),u=Date.now(),p=xu({...l,isDirty:E.isDirty(),isNew:E.isNew(),isReady:E.isReady(),latestRevisionAgeMs:A!=null&&A<=u?u-A:void 0,isSnapshotSent:m!=null&&m===E.get().version});return p==="create"&&h(E)?"none":p},b=()=>{const E=t();if(!E||E.isDisposed()||h(E)||d(E)||n().isHeadless)return!1;if(!E.isDirty())return E.isNew();const{snapshotVersion:A}=n();return!(A!=null&&A===E.get().version)};let T,w,g,C,_=!1;const P=()=>{w=void 0;const E=t();if(!E||E.isDisposed())return;if(E.get().docId!==T){S();return}const A=y();A!=="none"&&a?.version!==E.get().version&&(a={version:E.get().version,failuresAtStart:o()}),A==="create"?r():A==="revision"?i():b()&&(T=E.get().docId,w=setTimeout(P,f()))},S=()=>{const E=t();_||!E||w!==void 0||y()==="none"&&!b()||(T=E.get().docId,w=setTimeout(P,f()))},M=E=>{E.source==="user"&&w!==void 0&&(clearTimeout(w),w=void 0),S()},v=()=>{const E=t();E!==g&&(C?.(),g=E,a=void 0,C=E?.subscribe(M),w!==void 0&&(clearTimeout(w),w=void 0))};return v(),S(),{refresh:()=>{_||(v(),S())},stop:()=>{_=!0,C?.(),C=void 0,g=void 0,w!==void 0&&(clearTimeout(w),w=void 0)}}}var Bs=F("documentSession.autosaveUiFacts"),Us={isUserBusy:!1,saveContext:{}};function ku(e){return e.getOrCreateInstance(Bs,()=>Ee(Us))}function Qn(e){return e?.getInstance(Bs)?.get()??Us}function Hs(e){return Qn(e).saveContext.fallbackTitle||"Untitled email."}var Lu=1e4,Nu=3e4;function Fu(e,t){const n=f=>{const h=e.getInstance(oe)?.layers?.(),y=h?Du(h,f):void 0;return typeof y=="number"&&y>=0?y:void 0},r=()=>{const f=t.current(),h=f?.get().serverId??void 0,y=ye(t.sessionKey()),b=t.recoveryFacts(),T=b?.emailId===h?b:void 0,w=t.revisionFacts(),g=T?.latestRevisionAt,C=w?.lastRevisionAt,_=Ms(e).profile;return{isInited:y||f?.get().attributes.is_inited===!0,isEnabled:!!_?.autosaves&&!wu(e),isHistoryLoaded:T?.historyLoaded===!0,isUserBusy:Qn(e).isUserBusy,isHeadless:bu(e),autosaveTimeoutMs:Ns(e).autosaveTimeout||Lu,latestRevisionAt:g!==void 0||C!==void 0?Math.max(g??0,C??0):void 0,snapshotVersion:w?.snapshotVersion,retryIntervalMs:n("autosaveRetryIntervalMs")??Nu,retryMaxAttempts:n("autosaveRetryMaxAttempts")}},i=()=>{const f=Qn(e).saveContext;return{...f,project:f.project??t.current()?.get().attributes.project,fallbackTitle:Hs(e)}},o=Mu({readDocument:()=>t.current(),readEnvironment:r,readFailures:()=>t.saveState().failures,readFailureRetryable:()=>yd(t.saveState().error),onCreate:()=>{ye(t.sessionKey())||t.save("materialize",i())},onRevision:()=>{t.save("snapshot",{project:i().project})}}),s=t.subscribe(o.refresh),a=Wr(e).watch(()=>o.refresh()),c=ku(e).watch(()=>o.refresh()),d=Ls(e).watch(()=>o.refresh());return()=>{s(),a.dispose(),c.dispose(),d.dispose(),o.stop()}}var xi=12e3;function Le(e){return e.getOrCreateInstance(Fr,()=>{const t=Xd({resolveAdapters:(r,i)=>Uu(r,e,i),resolveWritePort:()=>$s(e),resolveHistoryPort:r=>ye(r)?Vs(e):Gs(e),resolveTerms:()=>ru(e),canEdit:r=>Bc(e,r),notifyBeforeSave:zc(e),timeoutMs:xi,onAdapterError:(r,i)=>{i instanceof Error&&i.message;const o=Qd(i),s=Jd(i);St(i,{origin:"email-source-adapter",tags:{source:r,expected_refusal:String(o),network_failure:String(s)},level:o||s?"warning":"error"})},onTimeout:r=>{}}),n=Fu(e,t);return e.getInstance(U)?.addDispose(n),t})}function Kr(e){return e?.getInstance(Fr)}function $s(e){const t=eu(e);return t?Yr(e)?vu(t,Ve(e).email(e)):t:Ve(e).email(e)}function ju(e){return Rs(e)!==void 0||Cs(e)}function Gs(e){const t=Rs(e);return t?Yr(e)?(Z("port:history:server-backed"),Ds(t,Ve(e).history(e))):(Z("port:history:integrator"),t):(Z("port:history:rest (порт не зарегистрирован)"),Ve(e).history(e))}function Vs(e){const t=As(e);return t?Yr(e)?(Z("port:block-history:server-backed"),Ds(t,Ve(e).blockHistory(e))):(Z("port:block-history:integrator"),t):(Z("port:block-history:rest (порт не зарегистрирован)"),Ve(e).blockHistory(e))}function Bu(e){return As(e)!==void 0||Cs(e)}function Yr(e){return ns(e)}function Uu({email:e,patch:t,serverId:n,key:r},i,o){const s=[];e?s.push({id:"rest",load:()=>Es(e),required:!0}):n&&s.push(Zd($s(i),n)),t&&s.push({id:"plugin",load:()=>_s(t)});const a=ye(r);return Wc(n)&&(a?Bu(i):ju(i))&&s.push(gu({port:a?Vs(i):Gs(i),revisionServiceEnabled:ns(i),...!a&&Uc(i)?{isHistoryAvailable:()=>Hc(i)}:{},emailId:n,readShownContent:()=>o.readShownContent(),onFacts:c=>o.publishRecoveryFacts(c)})),s}function ae(e){return e.getOrCreateInstance(Ot,()=>new xt)}var qs=new WeakMap,Zn=new WeakMap;function be(e){return qs.get(e)??0}function er(e,t){let n=Zn.get(e);return n||(n=new Set,Zn.set(e,n)),n.add(t),()=>{n?.delete(t)}}function Hu(e){qs.set(e,be(e)+1),Zn.get(e)?.forEach(t=>t())}function $u(e){const t=Le(e),n=ae(e).addListener($.APPLICATION_HAS_AMP,r=>{dt(t)?.mutate({attributes:{isAmp:r}},{source:"remote"})});e.getInstance(U)?.addDispose(()=>n.dispose())}function Gu(e){return e.size>0&&(e.type===""||e.type.startsWith("image/"))}function Vu(e){const t=e.fetchImpl??((o,s)=>fetch(o,s)),n=e.pageHost??(()=>window.location.hostname),r=new Set,i=o=>{try{const s=new URL(o,window.location.href);return s.protocol!=="https:"&&s.protocol!=="http:"?!1:s.hostname===n()||e.sourceHosts().includes(s.hostname)}catch{return!1}};return{accepts:i,async load(o){if(!i(o))return;const s=!r.has(o);r.add(o);try{const a=await t(o,{mode:"cors",credentials:"omit",cache:s?"no-cache":"default"});if(!a.ok)return;const c=await a.blob();return Gu(c)?c:void 0}catch{return}}}}var Ge={maxBytes:67108864,maxImageBytes:4194304,ttlMs:18e5};function qu(e){const t={maxBytes:e.maxBytes??Ge.maxBytes,maxImageBytes:e.maxImageBytes??Ge.maxImageBytes,ttlMs:e.ttlMs??Ge.ttlMs},n=e.now??(()=>Date.now()),r=new Map,i=new Map,o={hits:0,loads:0,failures:0};let s=0;const a=h=>{const y=r.get(h);y&&(s-=y.bytes,r.delete(h))},c=h=>t.ttlMs<=0||n()-h.storedAt<t.ttlMs,d=()=>{if(s<=t.maxBytes)return;const h=[...r.entries()].sort((y,b)=>y[1].usedAt-b[1].usedAt);for(const[y]of h){if(s<=t.maxBytes)return;a(y)}},f=(h,y)=>{y.size>t.maxImageBytes||(r.set(h,{blob:y,bytes:y.size,storedAt:n(),usedAt:n()}),s+=y.size,d())};return{async get(h){const y=r.get(h);if(y&&c(y))return y.usedAt=n(),o.hits+=1,y.blob;y&&a(h);const b=i.get(h);if(b!==void 0)return b;o.loads+=1;const T=(async()=>{try{const w=await e.load(h);return w?f(h,w):o.failures+=1,w}catch{o.failures+=1;return}finally{i.delete(h)}})();return i.set(h,T),T},forget(h){a(h),i.delete(h)},configure(h){Object.assign(t,{maxBytes:h.maxBytes??t.maxBytes,maxImageBytes:h.maxImageBytes??t.maxImageBytes,ttlMs:h.ttlMs??t.ttlMs});for(const[y,b]of r)b.bytes>t.maxImageBytes&&a(y);d()},clear(){r.clear(),i.clear(),s=0},stats(){return{entries:r.size,bytes:s,...o}}}}var zu=["emcdn.ru","scr.emcdn.ru"];function Wu(e){const t=String(e??"").trim();if(!t)return"";try{return new URL(t.includes("//")?t:`https://${t}`).hostname}catch{return t.split("/")[0].split(":")[0]}}function Ku(e,t){const n=(r,i)=>{const o=new Set(i?t:[]);for(const s of r){const a=Wu(s);a&&o.add(a)}return[...o]};return e?Array.isArray(e)?n(e,!0):n(e.value??[],e.replace!==!0):[...t]}function Yu(e){const t=e??{},n=t.isPlugin!==!0?zu:[],r=t.canvasImageCache;if(r===!1)return{enabled:!1,sourceHosts:[],...Ge};const i=r===!0||r===void 0?{}:r;return{enabled:i.enabled!==!1,sourceHosts:Ku(i.sourceHosts,n),maxBytes:i.maxBytes??Ge.maxBytes,maxImageBytes:i.maxImageBytes??Ge.maxImageBytes,ttlMs:i.ttlMs??Ge.ttlMs}}function Xu(e){const t=ae(e),n=e.getInstance(oe),r=()=>Yu({...n?.get(),isPlugin:!0});let i=r();const o=Vu({sourceHosts:()=>i.sourceHosts}),s=qu({load:w=>o.load(w),maxBytes:i.maxBytes,maxImageBytes:i.maxImageBytes,ttlMs:i.ttlMs}),a=()=>{t.send($.SANDBOX_CANVAS_IMAGE_CACHE_SETUP,{enabled:i.enabled,sourceHosts:[...i.sourceHosts]})},c=t.onInit(()=>a()),d=n?.watch(()=>{const w=r(),g=JSON.stringify(w)!==JSON.stringify(i);i=w,s.configure(w),w.enabled||s.clear(),g&&t.isInited()&&a()}),f={asked:0,served:0,refused:0},h=[],y=(w,g)=>(f.refused+=1,h.push({url:w,reason:g}),h.length>20&&h.shift(),{refused:!0}),b=Object.assign(globalThis,{__emmCanvasImages__:()=>({settings:i,counters:{...f},refusals:[...h],store:s.stats()})}),T=t.addListenerAsync($.APPLICATION_CANVAS_IMAGE_GET,async w=>{const g=w?.url??"";if(f.asked+=1,!i.enabled||!g)return y(g,"disabled");if(!o.accepts(g))return y(g,"host");w.fresh&&s.forget(g);const C=await s.get(g);return C?(f.served+=1,{blob:C}):y(g,"load-failed")});e.getInstance(U)?.addDispose(()=>{c.dispose(),d?.dispose(),T.dispose(),s.clear(),delete b.__emmCanvasImages__})}var Ju=2e3;function Qu(e){const t=ae(e),n=new Map,r=()=>{const s=t.getTarget();if(!s||t.hasPort(s))return;clearTimeout(n.get(s));const a=new MessageChannel;let c=!1,d=!1;const f=y=>{y.data?.operationId==="em:port-ready"&&(c=!0,a.port1.removeEventListener("message",f),d&&t.resumePort(s),t.drainWindow(s))};a.port1.addEventListener("message",f),t.sendPort(s,a.port2),t.usePort(a.port1,!1,s);const h=setTimeout(()=>{n.get(s)===h&&n.delete(s),!(c||!t.hasPort(s,a.port1))&&(St(new Error("canvas port did not come up, staying on window messaging"),{origin:"canvas-channel"}),d=!0,t.holdPort(s))},Ju);n.set(s,h)},i=Object.assign(globalThis,{__emmCanvasPort__:()=>{const s=t.getTarget();return{usesPort:t.usesPort,windowDrained:s?t.isWindowDrained(s):!1}}}),o=t.onInit(()=>r());e.getInstance(U)?.addDispose(()=>{for(const s of n.values())clearTimeout(s);o.dispose(),delete i.__emmCanvasPort__})}var Zu=/^[a-zA-Z][a-zA-Z\d+\-.]*:/;function ef(e){return Zu.test(e)||e.indexOf("//")===0}function Vt(e){return e&&(e.endsWith("/")?e:`${e}/`)}function tf(){return typeof document<"u"&&document.baseURI?document.baseURI:typeof window<"u"&&window.location?window.location.href:""}function Mi(e,t){const n=e==null||e===""?"./":String(e);if(ef(n))return Vt(n);const r=t??tf();if(!r)return Vt(n);try{return Vt(new URL(n,r).href)}catch{return Vt(n)}}function nf(){return typeof window.__useblocks__<"u"&&window.__useblocks__?.publicPath?Mi(window.__useblocks__.publicPath):Mi("/")}var rf=()=>"",of=()=>"1c4e77a0";function zs(e){const t=e?"iframe-eblock":"iframe",n=rf();if(n){const o=n.replace(/\/?$/,"/");return _i(`${o}${t}.html`,wt())}const r=of(),i=`${nf().replace(/\/?$/,"/")}iframe/`;return _i(`${i}${t}${r?`.${r}`:""}.html`,wt())}var ki="allow-top-navigation allow-scripts allow-popups allow-popups-to-escape-sandbox";function tr(e){return/^file:/i.test(String(e||"").trim())}function sf(e){return tr(e)?`${ki} allow-same-origin`:ki}var af="em:module-body-ack";function lf(e,t,n){try{const r=new URL("./",new URL(t,n)).href,i=new URL(e,r).href;return i.startsWith(r)?i:void 0}catch{return}}function Xr(e){const t=e.split(/[?#]/)[0].split("/").pop()??"",n=/^(.+?)(?:\.([0-9a-f]{6,}))?\.html$/.exec(t);return n?{name:n[1],hash:n[2]}:void 0}function cf(e){const t=Xr(e);if(t)return t.hash?`js/${t.name}.body.${t.hash}.js`:`js/${t.name}.body.js`}function df(e,t){const n=Xr(t)?.name,r=n?e[`${n}.html`]:void 0;return r?(r.imports??[]).map(i=>e[i]?.file).filter(i=>!!i):[]}function uf(e,t){const n=Xr(t)?.name,r=n?`js/${n}.js`:void 0;if(!r||!(r in e))return[];const i=new Set([r]),o=[r],s=[];for(;o.length>0;)for(const a of e[o.shift()]??[])i.has(a)||(i.add(a),s.push(a),o.push(a));return s}var ff=/^(?=[\w-]{8}$)(?:.*\d|(?=.*[a-z]).*[A-Z])/;function pf(e){const t=(e.split(/[?#]/)[0].split("/").pop()??"").split(".");return t.length>=3&&ff.test(t[t.length-2])}async function hf(e,t){const n=pf(e)?{}:{cache:"no-cache"};t?.priority&&(n.priority=t.priority);try{const r=await fetch(e,n);return r.ok?await r.blob():void 0}catch{return}}function mf(e){const t=new Map,n=(r,i)=>{const o=lf(r,e.canvasSrc,e.origin);if(!o)return;const s=t.get(o);if(s!==void 0)return s;const a=e.fetchBody(o,i);return t.set(o,a),a};return{take(r){return n(r)??Promise.resolve(void 0)},warm(r,i){for(const o of r)n(o,i)},reset(){t.clear()},get size(){return t.size}}}var Ie;function gf(e){try{return tr(new URL(e,window.location.href).href)}catch{return tr(window.location.href)}}function Ws(e){try{if(new URL(e,window.location.href).origin===window.location.origin)return!0}catch{return!1}return typeof window.__useblocks__<"u"&&window.__useblocks__?.preload?.canvasCrossOrigin===!0}var vf=()=>Promise.resolve(void 0);function Ks(){const e=zs(!1);if(!gf(e)){if(!Ie||Ie.canvasSrc!==e){const t=Ws(e)?hf:vf;Ie={canvasSrc:e,store:mf({canvasSrc:e,origin:window.location.href,fetchBody:t}),warmed:!1}}return Ie.store}}async function bf(e,t){try{const n=new URL(".vite/manifest.json",new URL("./",new URL(e,window.location.href))).href,r=await fetch(n,{cache:"no-cache"});if(!r.ok)return;const i=await r.json();t(df(i,e))}catch{}}function Jr(e){const t=Ks();if(!t||!Ie||Ie.warmed||!Ws(Ie.canvasSrc))return;Ie.warmed=!0;const{canvasSrc:n}=Ie,r=cf(n);r&&t.warm([r],e);const i={"js/iframe-eblock.js":["js/discussHandlers.Xh4-JUcT.js","js/typograf.all.BbXdyfMT.js"],"js/iframe.js":["js/rolldown-runtime.BRlIiq3h.js","js/discussHandlers.Xh4-JUcT.js"],"js/darkreader.CyLMh7_H.js":[],"js/discussHandlers.Xh4-JUcT.js":["js/rolldown-runtime.BRlIiq3h.js"],"js/rolldown-runtime.BRlIiq3h.js":[],"js/rules.CL_BitCE.js":[],"js/typograf.all.BbXdyfMT.js":["js/rolldown-runtime.BRlIiq3h.js"]};i?t.warm(uf(i,n),e):bf(n,o=>t.warm(o,e))}function yf(e){const t=Ks();if(!t)return;Jr();const n=r=>{const i=r.data;if(!i||i.operationId!=="em:module-body"||!i.result)return;const o=r.source;o&&(o.postMessage({operationId:af,for:i.result},"*"),t.take(i.data?.url??"").then(s=>{o.postMessage({operationId:i.result,data:s??null},"*")}))};window.addEventListener("message",n),e.getInstance(U)?.addDispose(()=>{window.removeEventListener("message",n)})}var Qe=/<script\b(?=[^>]*(?:\bbis_use(?:=|\s)|\bdata-bis-config(?:=|\s)|\bdata-dynamic-id(?:=|\s)|local\.adguard\.org|(?:chrome-extension|moz-extension|safari-extension):\/\/))[^>]*>[\s\S]*?<\/script>/gi,Ef=/\s(?:bis_[a-z0-9_-]+|data-bis-config|data-dynamic-id)=(["'])(?:(?!\1).)*\1/gi,rt=/<style\b[^>]*>[\s\S]*?<\/style>/gi,Li=/display:\s*none\s*!important/gi,_f=/((?:html\s*,\s*body|body\s*,\s*html)\s*\{)([^}]*)(\})/gi,wf=/\s*height\s*:\s*100%\s*!important\s*;?/gi,Sf=/height\s*:\s*100%\s*!important/i,If=[".socialshare,",".advertisment,",".adHolder,",".adsbygoogle-noablate","#ab_adblock","#popmechanic-snippet","filter_ads_by_classname","clever-core-ads","--gn-ov-ad-height","pub_728x90.text-ad.textAd","html-load.com/player","content-loader.com/player",".adblock","#advblock","body { overflow: visible!important; }"];function Cf(e){return Li.lastIndex=0,(e.match(Li)||[]).length}function Ys(e){const t=e.trim(),n=Cf(t);if(n===0)return!1;if(t.includes(".advertisment,")&&t.includes(".adHolder,")&&(t.includes(".socialshare,")||n>=3||t.length>2e3))return!0;const r=If.filter(i=>t.includes(i)).length;return r>=1&&(n>=3||t.length>2e3)||n>=5&&r>=1?!0:n>=20&&/\b(?:\.ad(?:s|vert|vertisment|Holder|banner|box|Container|Wrapper)?[,{]|#ad[-_]|ins\.adsbygoogle)/i.test(t)}function Tf(e){rt.lastIndex=0;for(const t of e.matchAll(rt))if(Ys(t[0].replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,"")))return!0;return!1}function Af(e){let t=!1;return rt.lastIndex=0,{html:e.replace(rt,n=>Ys(n.replace(/^<style\b[^>]*>/i,"").replace(/<\/style>$/i,""))?(t=!0,""):n),found:t}}function Rf(e){return Qe.lastIndex=0,Qe.test(e)||/\sbis_[a-z0-9_-]+\s*=/.test(e)||/\sdata-bis-config\s*=/.test(e)||Tf(e)}function Pf(e){if(!Rf(e))return{html:e,found:!1};let t=!1,n=e;Qe.lastIndex=0,Qe.test(n)&&(Qe.lastIndex=0,n=n.replace(Qe,""),t=!0),(/\sbis_[a-z0-9_-]+\s*=/.test(n)||/\sdata-bis-config\s*=/.test(n))&&(n=n.replace(Ef,""),t=!0);const r=Af(n);return n=r.html,t=t||r.found,{html:n,found:t}}function Df(e){return!e||!Sf.test(e)?e:(rt.lastIndex=0,e.replace(rt,t=>t.replace(_f,(n,r,i,o)=>`${r}${i.replace(wf,"")}${o}`)))}function Xs(e){const t=Pf(e.replaceAll(`\r
|
|
1002
1003
|
`,`
|
|
1003
|
-
`));return{html:lc(t.html),hasBrowserExtensionArtifacts:t.found}}function wn(e){return e?.getContent()??""}function Mo(e,t){e?.mutate({content:ro(t)},{source:"remote"})}function sr(e){return N(e)}function ie(e,t){return e.getOrCreateInstance(t,()=>new be)}function W(e,t){return e.getOrCreateInstance(t,()=>new be).event}function Sn(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var dc=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}},cc=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(te("Superseded by newer show()")),n.aborted?Promise.reject(te(n.reason)):(this._activeRequest=e,new Promise((r,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new dc(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(te(n.reason))})};n.addEventListener("abort",s,{once:!0});const a=()=>{clearTimeout(o),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:i,timeoutId:o,dispose:a});for(const l of this._listeners)l(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function uc(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function fc(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=Zi(e),n=eo(e),r=el(e.sandbox);t<n+r}var ko=class{_controller=new AbortController;_externalSignalDisposable=new Q;_sessionChangeListeners=new Set;_showRegistry=new cc;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return Zi(this._timeouts)}getSandboxTimeoutMs(e){return Qi(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return eo(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=uc(this._timeouts,e.timeouts),fc(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Q,this._linkExternalSignal(e)}abort(e){const t=e??te("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Q}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new Q,this._showRegistry.rejectAll(te("Init session replaced")),this._controller.signal.aborted||this._controller.abort(te("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??te()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??te()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},ar=(()=>{const e=new ko;return e.configure({}),e})(),pc=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 hc(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 mc(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(z(n),new Promise((r,i)=>{let o=!1,s,a;const l=m=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",u),m())},u=()=>{l(()=>i(te(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&l(()=>r())}),e.isInited()&&e.getTarget()){l(()=>r());return}t>0&&(s=setTimeout(()=>{l(()=>i(new pc(t)))},t)),n?.addEventListener("abort",u)}))}var gc=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 vc(e,t,n){return t<=0?e:new Promise((r,i)=>{let o=!1,s;const a=l=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),l())};s=setTimeout(()=>{a(()=>i(new gc(n,t)))},t),e.then(l=>{a(()=>r(l))},l=>{a(()=>i(l))})})}var bc=2,ht=Symbol("sandbox:frame-replaced");function ue(e,t,n,r,i,o,s){const a=`sandbox:${t}`,l=o?.getSandboxTimeoutMs(t)??Yn[t],u=()=>{let _=vc(e.sendAsync(n,r),l,a);return _=It(_,o?.signal),Ye(a,_,i)};if(t==="INIT_START"&&hc(e)){const _=o?.getSandboxReadyTimeoutMs()??2e4,b=e,y=S=>{const I=mc(b,_,o?.signal);return Ye("sandbox:INIT_START:ready-wait",I,i).then(()=>{if(!s||S<=0)return u();const A=s.getGeneration();let f;const c=new Promise((p,h)=>{f=s.onChange(()=>{s.getGeneration()!==A&&h(ht)})}),d=u();return d.catch(()=>{}),Promise.race([d,c]).finally(()=>f?.()).catch(p=>{if(p!==ht)throw p;return{...i},y(S-1)})})};return y(bc)}if(!s)return u();const m=s.getGeneration();let v;const E=new Promise((_,b)=>{v=s.onChange(()=>{s.getGeneration()!==m&&b(ht)})}),g=u();return g.catch(()=>{}),Promise.race([g,E]).finally(()=>v?.()).catch(_=>{throw _===ht&&{...i},_})}var yc=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],Ec=200;function _c(e=new Set){const t=new Set;return(n,r)=>{if(!yc.some(([o,s])=>!e.has(o)&&s.test(n)))return;const i=r??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=Ec&&t.clear(),t.add(i))}}function wc(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:_c()}}var Sc=wc();function He(e){return e?.getInstance(ca)??Sc}function Ic(e){const t=we(e),n=ee(e),r=()=>e.getInstance(pe)??ar;let i,o,s=!1,a=!1;const l=async(I,A,f)=>{const c=f.generation,d=()=>f.generation!==c||f.signal.aborted||t.current()!==I||a,p=me(n);s=!0;try{if(await ue(n,"INIT_START",H.SANDBOX_INIT_START,{guid:A},void 0,f),d())return;const{html:h,hasBrowserExtensionArtifacts:w}=xo(wn(I));if(w&&ie(e,G.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Mo(I,h),await ue(n,"SET_ENTITY",H.SANDBOX_SET_ENTITY,Sn(wn(I),A,He(e).editorPolicy,I.get().version),void 0,f),d())return;await ue(n,"INITED",H.SANDBOX_INITED,{guid:A},void 0,f),i=A,o=p}finally{s=!1}},u=()=>de(t.sessionKey())?t.current():void 0,m=()=>{if(a||s)return;const I=u(),A=I?.get().docId;if(!I||!A||i===A&&o===me(n)||!I.isReady())return;const f=r();f.signal.aborted||l(I,A,f).catch(()=>{})};let v=!1;const E=()=>{v||a||(v=!0,queueMicrotask(()=>{v=!1,m()}))};let g,_;const b=()=>{const I=u(),A=I?.get().docId;A!==_&&(g?.(),_=A,g=I?.subscribe(E)),E()},y=t.subscribe(b),S=Ro(n,E);b(),e.getInstance(U)?.addDispose(()=>{a=!0,S(),g?.(),y()})}var Ac=200;function Tc({startVersion:e,limit:t=Ac}){let n=[],r=e;const i=o=>{n=n.filter(s=>s.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&i(n[n.length-t-1].version))},rebase(o,s){if(s<r)return null;const a=n.filter(u=>u.version>s);i(s);let l=o;for(const u of a){if(u.fromCanvas||u.contentReplaced||!u.changes)return null;const m=u.changes,v=[];for(const E of l){const g=ul(E.range,m,"after");if(!g)return null;v.push({range:g,text:E.text})}l=v}return l}}}function Cc(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new le(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function Rc(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Cc(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Pc(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var lr=N("canvas.sandboxFill");function Lo(e){return e.getInstance(lr)?.pipeline.isEventsLocked()===!0}function Wt(e){Lt(e,{origin:"canvas-channel"})}function Dc(e){const t=we(e),n=ee(e);let r;const i=(l,u)=>{const m=l.get().docId;let v=!1,E=null,g=null;const _=Tc({startVersion:l.get().version});let b=l.getContent();const y=async(c,d)=>{if(g){g.push({edits:c,rev:d});return}g=[{edits:c,rev:d}];try{do{const p=g.splice(0,g.length);await n.sendAsync(H.SANDBOX_UPDATE_ENTITY,{edits:p.map(h=>h.edits),guid:m,rev:p[p.length-1].rev})}while(g.length)}finally{g=null}},S=(c,d)=>{const p=g?.splice(0,g.length)??[];p.length&&n.sendAsync(H.SANDBOX_UPDATE_ENTITY,{edits:p.map(h=>h.edits),guid:m,rev:p[p.length-1].rev}).catch(Wt),n.sendAsync(H.SANDBOX_UPDATE_ENTITY,{edits:[c],guid:m,rev:l.get().version,...d!==null?{changeId:d}:{}}).catch(Wt)},I=c=>{const{guid:d,pushUndoStop:p}=c;if(d!==m)return;const h=wl(c);let{edits:w}=c;if(h.baseRev!==null){const D=_.rebase(w,h.baseRev);if(!D){Lt(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),S([],h.changeId);return}w=D}const T=l.get().version;try{v=!0,E=h.changeId;const D=Rc(w,l.getContent());p===!1?u.applyWithoutHistory(D):l.mutate({changes:D},{source:Lo(e)?"system":"user"})}finally{v=!1,E=null}l.get().version===T&&h.baseRev!==null&&S([],h.changeId)},A=l.subscribe(({changes:c,version:d})=>{const p=l.getContent(),h=!c?.length&&p!==b;if(b=p,_.record({version:d,changes:c,contentReplaced:h,fromCanvas:v}),!c?.length)return;const w=Pc(c);v?S(w,E):y(w,d).catch(Wt)}),f=n.addListener(H.APPLICATION_UPDATE_ENTITY,I);return()=>{A(),f.dispose()}};let o;const s=()=>{const l=t.current(),u=t.history(),m=l?.get().docId;m!==o&&(r?.(),r=void 0,o=m,l&&u&&(r=i(l,u)))},a=t.subscribe(s);s(),e.getInstance(U)?.addDispose(()=>{r?.(),a()})}var No=300,Ur=15e3,Hr="em-canvas-busy-style";function Fo(){if(document.getElementById(Hr))return;const e=document.createElement("style");e.id=Hr,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}function Oc(e){const t=e.getBoundingClientRect(),n=document.createElement("div");return n.setAttribute("aria-busy","true"),Object.assign(n.style,{position:"fixed",left:`${t.left}px`,top:`${t.top}px`,width:`${t.width}px`,height:`${t.height}px`,cursor:"progress",display:"flex",alignItems:"center",justifyContent:"center"}),e.appendChild(n),{showSpinner(){Fo(),n.style.background="rgba(128, 128, 128, 0.15)";const r=document.createElement("div");Object.assign(r.style,{width:"32px",height:"32px",borderRadius:"50%",border:"3px solid rgba(128, 128, 128, 0.35)",borderTopColor:"rgba(80, 80, 80, 0.9)",animation:"em-canvas-busy-spin 0.8s linear infinite"}),n.appendChild(r)},remove:()=>n.remove()}}function Gr(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{Fo();const i=document.createElement("div");Object.assign(i.style,{width:"32px",height:"32px",borderRadius:"50%",border:"3px solid rgba(128, 128, 128, 0.35)",borderTopColor:"rgba(80, 80, 80, 0.9)",animation:"em-canvas-busy-spin 0.8s linear infinite"}),t.appendChild(i)},No);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var xc=8e3;function Mc(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,whenShown:()=>Promise.resolve(),alignTo:()=>{},resize:()=>{},dispose:()=>{}}}var kc=e=>{for(let t=e?.parentElement??null;t;t=t.parentElement){const n=getComputedStyle(t).overflowY;if(n==="auto"||n==="scroll"||n==="hidden")return t}return null};function Lc(e,t,n,r,i){const o=n.readyTimeoutMs??xc,s=document.createElement("div");s.dataset.canvasHost=e,r&&(s.dataset.canvasPlace=r),s.style.position="fixed",s.style.overflow="hidden",s.style.visibility="hidden";const a=n.resolveSrc(e),l=document.createElement("iframe");l.setAttribute("sandbox",n.resolveSandbox(a)),l.setAttribute("allow","clipboard-read; clipboard-write"),l.setAttribute("title","Email content"),l.style.width="100%",l.style.border="0",l.style.display="block",l.style.minHeight="600px",l.src=a,s.appendChild(l),t.appendChild(s),n.mark?.("created"),i||n.onCreated?.(l);const u=new Q;let m=!1,v=!1,E,g,_,b;const y=()=>{clearTimeout(b),b=setTimeout(()=>{v||(v=!0,g?.(new Error(`[canvas] ${e}: документ не загрузился за ${o} мс`)))},o)},S=()=>m?(_=Promise.resolve(),v=!0,_):(v=!1,_=new Promise((x,M)=>{E=x,g=M}),y(),_),I=()=>{if(clearTimeout(b),m=!0,v){_=Promise.resolve();return}v=!0,n.mark?.("loaded"),E?.()};l.addEventListener("load",I),u.addDispose(()=>{clearTimeout(b),l.removeEventListener("load",I)});let A;const f=()=>{A??=n.bindResizer?.(l)};let c=null,d=null,p;const h=()=>{if(!c){s.style.visibility="hidden",l.removeAttribute("id");return}n.elementId&&(l.id=n.elementId);const x=c.getBoundingClientRect(),M=d?.isConnected?d:kc(c),q=M?M.getBoundingClientRect():null,X=q?Math.max(x.top,q.top):x.top,K=q?Math.min(x.bottom,q.bottom):x.bottom,he=Math.max(0,K-X);s.style.visibility=he>0?"visible":"hidden",s.style.left=`${x.left}px`,s.style.top=`${X}px`,s.style.width=`${x.width}px`,s.style.height=`${he}px`,l.style.transform=`translateY(${x.top-X}px)`};let w="",T="",D=0,L;const Y=()=>{if(!c){L=void 0;return}L=window.requestAnimationFrame(Y);const x=c.getBoundingClientRect(),M=d?.isConnected?d.getBoundingClientRect():void 0,q=`${Math.round(x.left)}:${Math.round(x.top)}:${Math.round(x.width)}:${Math.round(x.height)}:${M?`${Math.round(M.top)}:${Math.round(M.height)}`:"-"}`;q!==w&&(w=q,h());const X=l.getBoundingClientRect().height;X>0&&X!==D&&(D=X,c.style.height=`${X}px`);const K=getComputedStyle(c).pointerEvents;K!==T&&(T=K,s.style.pointerEvents=K)},k=()=>{L===void 0&&c&&(L=window.requestAnimationFrame(Y))},R=()=>{L!==void 0&&(window.cancelAnimationFrame(L),L=void 0)},F=()=>h();let C=[];const P=(x,M)=>{if(d=M,x&&C.length>0){const q=C;C=[],q.forEach(X=>X())}if(x===c){h();return}if(p?.disconnect(),p=void 0,c&&c.style.removeProperty("height"),w="",D=0,T="",c=x,!x){R(),h();return}n.onShown?.(l);try{if(typeof ResizeObserver=="function"){const q=new ResizeObserver(h);typeof q.observe=="function"&&(p=q,p.observe(x))}}catch{p=void 0}h(),f(),k()};window.addEventListener("scroll",F,!0),window.addEventListener("resize",F),u.addDispose(()=>{p?.disconnect(),L!==void 0&&window.cancelAnimationFrame(L),window.removeEventListener("scroll",F,!0),window.removeEventListener("resize",F)});const j=x=>{m=!1,x&&n.onReload?.(l);let M;v||_===void 0?M=S():(y(),M=_);try{l.contentWindow?.location.reload()}catch{l.src=a}return M};return{element:l,ready(){return _??S()},reload:()=>j(!0),reloadQuietly:()=>j(!1),get shown(){return c!==null},whenShown(){return c!==null?Promise.resolve():new Promise(x=>{C.push(x)})},alignTo(x,M){P(x,M??null)},scrollBy(x,M){let q=x,X=M;for(let K=c?.parentElement??null;K;K=K.parentElement){if(Math.abs(q)<1&&Math.abs(X)<1)return;const he=getComputedStyle(K);if((he.overflowY==="auto"||he.overflowY==="scroll")&&K.scrollHeight>K.clientHeight){const qe=K.scrollTop,Gt=K.scrollLeft;K.scrollBy({left:q,top:X,behavior:"instant"}),q-=K.scrollLeft-Gt,X-=K.scrollTop-qe}}(Math.abs(q)>=1||Math.abs(X)>=1)&&window.scrollBy({left:q,top:X,behavior:"instant"})},resize(){A?.resize()},dispose(){P(null,null),A?.dispose(),u.dispose(),s.remove()}}}function Nc(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(g,_)=>g==="email"?`email:${_??n}`:g,o=new Map;let s,a=[],l=!1,u;const m=()=>{if(a.forEach(g=>clearTimeout(g)),a=[],s?.remove(),s=void 0,u?.remove(),u=void 0,l){l=!1;const g=o.get("email");t.get(i("email"))?.alignTo(g?.slot??null,g?.clip??null)}},v=(g,_,b)=>{const y=i(g,_),S=t.get(y);if(S)return S;const I=e.resolveMount();if(!I)return Mc();const A=Lc(g,I,e,g==="email"?_??n:void 0,b);return t.set(y,A),A},E={get:g=>v(g),current:g=>v(g),peek:g=>t.get(i(g)),spare:()=>t.get(i("email",r())),ensureSpare:()=>v("email",r(),!0),promote(){const g=t.get(i("email",r()));if(!g)return;const _=t.get(i("email"));n=r();const b=o.get("email");g.alignTo(b?.slot??null,b?.clip??null),_?.alignTo(null)},alignSurface(g,_,b){if(o.set(g,{slot:_,clip:b??null}),g==="email"&&l){u?.remove(),u=_?Gr(_):void 0;return}(_?v(g):t.get(i(g)))?.alignTo(_,b??null)},visible(){for(const g of t.values())if(g.shown)return g},byWindow(g){if(g){for(const _ of t.values())if(_.element.contentWindow===g)return _}},busy(g){if(m(),!g)return;if(!E.visible()){l=!0;const y=o.get("email");y?.slot&&(u=Gr(y.slot)),a=[setTimeout(m,Ur)];return}const _=e.resolveMount();if(!_)return;const b=Oc(_);s=b,a=[setTimeout(()=>b.showSpinner(),No),setTimeout(m,Ur)]},dispose(){m(),t.forEach(g=>g.dispose()),t.clear(),o.clear(),n="a"}};return E}var Fc=N("canvas.resizerBinder"),In=N("canvas.service"),jc={created:Z.canvasCreated,loaded:Z.canvasLoaded};function Bc(e,t){if(e.getInstance(In))return;const n=Nc({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:Gd,elementId:t.elementId,bindResizer:i=>e.getInstance(Fc)?.(i),onCreated:i=>_t(e,i,"fresh"),onReload:i=>_t(e,i,"fresh"),onShown:i=>_t(e,i,"switch"),mark:i=>t.mark?.(jc[i])}),r=ee(e).addListener(H.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(In,n),e.getInstance(U)?.addDispose(()=>{r.dispose(),n.dispose()})}function _t(e,t,n){const r=ee(e),i=t.contentWindow;if(!i)return;const o=r.getTarget()===i;o&&n==="switch"||(n==="fresh"&&(r.forget(i),o&&r.setTarget(void 0)),r.setTarget(i),Ad(r))}function Uc(e,t){_t(e,t,"promote")}function Hc(e,t){const n=t.contentWindow;n&&ee(e).greet(n)}function Gc(e,t){const n=t.contentWindow;n&&ee(e).forget(n)}function ge(e){return e.getInstance(In)}function qc(e){const t=ee(e),n=()=>ge(e)?.byWindow(t.getTarget()),r=t.addListenerAsync(H.RELOAD,async()=>{await n()?.reload()}),i=t.addListener(s=>{s.data?.operation===H.SANDBOX_RESIZED&&n()?.resize()}),o=W(e,G.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(U)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose()})}var Fg=N("HeadlessMode"),$c=N("HiddenMount");function zc(e){return e.getOrCreateInstance($c,()=>Te(!1))}function qr(){const e=document.createElement("div");return e.dataset.canvasOffscreen="true",e.style.position="absolute",e.style.left="-10000px",e.style.top="-10000px",e.style.width="1600px",e.style.height="1000px",document.body.appendChild(e),e}function Vc(e){const t=e.getInstance(ne);let n,r;e.getInstance(U)?.addDispose(()=>{r?.remove(),r=void 0}),Bc(e,{resolveMount:()=>n,resolveSrc:o=>Po(o==="block"),elementId:"email_iframe",mark:o=>V(o)}),t?.watch(o=>{if(n)return;const s=o?.element;if(s instanceof HTMLElement)n=s;else if(o!==void 0)n=r??=qr();else return;ge(e)?.get("email")});let i;e.getInstance(U)?.addDispose(()=>{i?.remove(),i=void 0}),zc(e).watch(o=>{const s=ge(e);if(s){if(o){i??=qr(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var jo=N("canvas.headerFlow"),$r=["subject","preheader"],Kc=3e3,Wc={subject:H.SANDBOX_SUBJECT_UPDATE,preheader:H.SANDBOX_PREHEADER_UPDATE};function Yc(e){const t=we(e),n=ee(e),r=y=>y?"remote":Lo(e)?"system":"user",i=(y,{guid:S,value:I,forced:A})=>{const f=Ve(t);if(!f||typeof I!="string"||S&&S!==f.get().docId)return;const c=t.forcedHeaders();if(c?.[y]&&!A&&I!==c[y])return;A&&(v.delete(y),v.size===0&&t.endForcedHeaders());const d=f.get().attributes[y]??"";a=!0;try{Rt(f,{[y]:I},{source:r(A)})}finally{a=!1}o[y]=I,ie(e,G.ON_HEADER_APPLIED_ID).fire({field:y,value:I,forced:!!A,isGenerated:I!==d&&!!I})};let o={},s,a=!1,l=Promise.resolve();const u=(y,S,I,A=!1)=>{l=n.sendAsync(Wc[y],{value:S,guid:Ve(t)?.get().docId,...I?{force:!0,echo:!0}:{},...A?{undoStep:!0}:{}}).catch(f=>{})};let m;const v=new Set;e.inject(jo,{whenDelivered:async()=>{await l},reassert:y=>{const S=Ve(t),I=$r.filter(A=>y[A]);if(!(!S||I.length===0)){a=!0;try{Rt(S,Object.fromEntries(I.map(A=>[A,y[A]])),{source:"system"})}finally{a=!1}t.beginForcedHeaders({subject:y.subject??"",preheader:y.preheader??""}),clearTimeout(m),m=setTimeout(()=>{v.clear(),t.endForcedHeaders()},Kc),v.clear();for(const A of I)v.add(A);for(const A of I)o[A]=y[A],u(A,y[A],!0)}}});const E=()=>{s?.(),s=void 0;const y=Ve(t);if(!y){o={};return}const S=y.get().attributes;o={subject:S.subject,preheader:S.preheader},s=y.subscribe(({source:I})=>{if(a)return;const A=y.get().attributes,f=t.forcedHeaders();for(const c of $r){const d=A[c];d!==o[c]&&(o[c]=d,u(c,d??"",I==="system"&&f?.[c]!==void 0,I==="user"))}})};E();const g=t.subscribe(E),_=n.addListenerAsync(H.APPLICATION_SUBJECT_UPDATE,y=>i("subject",y)),b=n.addListenerAsync(H.APPLICATION_PREHEADER_UPDATE,y=>i("preheader",y));e.getInstance(U)?.addDispose(()=>{_.dispose(),b.dispose(),g(),s?.(),clearTimeout(m)})}function zr(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function An(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];zr(i)&&zr(o)?n[r]=An(o,i):i!==void 0&&(n[r]=i)}return n}function Xc(e,t){const n=Hn;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const i=JSON.parse(r);if(i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length>0)return An(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?An(n,t):n}function Jc(){const e=window.localStorage.getItem(Be.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?ra:va;return e&&e!=="system"?e:t}function Qc(){const e=window.localStorage.getItem(Be.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function Zc(e){const{config:t}=e;return{operation:H.UPDATE_PREVIEW,theme:e.theme,commonStyles:Xc(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}function eu(e){const t=ee(e),n=e.getInstance(ye),r=e.getInstance(ne),i=we(e);let o,s="";const a=()=>{const S=n?.get()??{},I=Zc({config:S,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:Jc(),codeMode:Qc(),appName:"useblocks"}),A=JSON.stringify(I);A!==s&&(s=A,t.send(I))},l=t.onInit(()=>{s="",a()}),u=()=>{t.isInited()&&a()},m=n?.watch(u),v=r?.watch(S=>{o=S?.commonStyles,u()});let E;const g=()=>{E?.(),E=i.current()?.subscribe(u),u()};g();const _=i.subscribe(g),b=matchMedia(sa),y=()=>u();b.addEventListener("change",y),e.getInstance(U)?.addDispose(()=>{l.dispose(),m?.dispose(),v?.dispose(),E?.(),_(),b.removeEventListener("change",y)})}var Tn;(function(e){function t(i,o,s=(a,l)=>a===l){if(i===o)return!0;if(i.length!==o.length)return!1;for(let a=0;a<i.length;a++)if(!s(i[a],o[a]))return!1;return!0}e.isEqual=t;function n(i,o=s=>s){const s=new Set;return i.filter(a=>{const l=o(a);return s.has(l)?!1:(s.add(l),!0)})}e.unique=n;function r(i=[],o=[],s=(a,l)=>a===l){const a=[],l=[],u=[];for(const m of i){const v=o.find(E=>s(m,E));v?u.push({prev:m,next:v}):l.push(m)}for(const m of o)i.find(v=>s(m,v))||a.push(m);return{added:a,removed:l,exists:u}}e.diff=r})(Tn||(Tn={}));function tu(e,t){return e.type===t.type&&e.key===t.key}function nu(e){const t=ee(e),n=()=>e.getServices(Oe)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send(H.SANDBOX_ADD_EXTENSIONS,r)}),o=zs(Oe),s=e.onInject(a=>{if(a!==o)return;const l=n();if(!t.isInited()){r=l;return}const{added:u,removed:m}=Tn.diff(r,l,tu);if(r=l,m.length){if(m.some(v=>v.type==="script")){t.send(H.RELOAD);return}t.send(H.SANDBOX_REMOVE_EXTENSIONS,m.map(v=>v.key))}u.length&&t.send(H.SANDBOX_ADD_EXTENSIONS,u)});e.getInstance(U)?.addDispose(()=>{i.dispose(),s?.dispose()})}var ru=N("prewarm.editorVisible");function iu(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function ou(e={}){const t=e.paint??iu;let n=!1,r=!1,i=!1,o=!1,s=!1;const a=[],l=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,V(Z.editorVisible);for(const u of a.splice(0))u()}))};return{noteShellVisible(){n=!0,l()},notePagePainted(){r=!0,l()},noteContentShown(){i=!0,l()},whenVisible(u){if(s){u();return}a.push(u)},contentShown:()=>i}}function su(e){return e.getOrCreateInstance(ru,()=>ou())}var au=500,lu=500,du=5e3;function cu(e){const t=e.quietMs??au,n=e.floorMs??lu,r=e.ceilingMs??du;let i,o,s=0;const a=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},l=()=>{a(),e.run()},u=()=>{clearTimeout(i);const m=n-(Date.now()-s);i=setTimeout(l,Math.max(t,m))};return{start(){a(),s=Date.now(),o=setTimeout(l,r),u()},notify(){i!==void 0&&u()},cancel:a}}function uu({attributes:e,readContent:t,docId:n,hasSession:r,serverId:i,show:o}){if(!r)return;const s={id:i??void 0,renderGuid:n,showId:o?.id,isNew:i==null,showToken:o?.token},a={...e,...s};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}var Bo="self-init:";function fu(e){return e.startsWith(Bo)}function Uo(e,t){const n=e.getActiveShowRequest();return fu(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function pu(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t();let i="";const o=()=>e.readDocument()?wn(e.readDocument()):i,s=()=>He(e.container).editorPolicy,a=()=>e.readEmail(),l=()=>{const u=a();return{...u,id:e.isTemplate()||u.isNew?void 0:u.id,html:o()}};return{readContent:o,publicEmail:l,sendInitStart:()=>ue(n,"INIT_START",H.SANDBOX_INIT_START,{guid:a().renderGuid},void 0,r()),sendInited:()=>ue(n,"INITED",H.SANDBOX_INITED,{guid:a().renderGuid},void 0,r()),async sendContent(){const u=a(),{html:m,hasBrowserExtensionArtifacts:v}=xo(u?.html||"");v&&e.events.browserExtensionDetected(),Mo(e.readDocument(),m),i=m,await ue(n,"SET_ENTITY",H.SANDBOX_SET_ENTITY,Sn(o(),u.renderGuid,s(),e.readDocument()?.get().version),{guid:u.renderGuid,emailId:u.id??null},r())},refreshContent:()=>ue(n,"SET_ENTITY",H.SANDBOX_SET_ENTITY,Sn(o(),a().renderGuid,s(),e.readDocument()?.get().version),void 0,r()),sendPreheader:async()=>{const u=a();if(u.preheader!==void 0)return ue(n,"PREHEADER",H.SANDBOX_PREHEADER_UPDATE,{value:u.preheader,guid:u.renderGuid,force:!0},void 0,r())},sendSubject:async()=>{const u=a();if(u.subject!==void 0)return ue(n,"SUBJECT",H.SANDBOX_SUBJECT_UPDATE,{value:u.subject,guid:u.renderGuid,force:!0},void 0,r())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:u=>e.showFilled?.(u),readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(l()),fireInit(u,m){if(!Uo(t(),u)){t().getActiveShowRequest()?.showId;return}const v=a();v.id,v.renderGuid,t().completeShow(u),Rt(e.readDocument(),{is_inited:!0},{source:"system"});const E=l();return m&&(E.reset=!0),e.events.inited(E)},fireEmailChanged(){e.events.emailChanged(l())},fireContentChanged(){e.events.contentChanged(o())}}}function hu(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,a;const l=pu({...e,waitScope:()=>({getSandboxTimeoutMs:y=>t().getSandboxTimeoutMs(y),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal})});let u;const m=(y,S)=>{if(u===y)return;u=y;const I=s;setTimeout(()=>{s!==I||t().signal.aborted||_(y,S).catch(()=>{})},0)},v=()=>{a?.abort(),a=void 0};let E;const g=()=>{const y=t().signal;y!==E&&(E?.removeEventListener("abort",v),E=y,y.addEventListener("abort",v))};async function _(y,S){const I=++s;v(),a=new AbortController,g();const A=()=>s!==I,f=l.readTarget(),c=t().generation,d=()=>c===t().generation&&!t().signal.aborted,p=S?"init:reset-":"init:";if(!S){const T=l.publicEmail();T?.id,T?.renderGuid,T?.preheader}let h=!1,w=!1;try{n=!0,await l.sendInitStart(),l.fireWillInit(),await(S?l.refreshContent():l.sendContent()),h=!0,S||l.publicEmail()?.id;try{await l.sendPreheader()}catch(T){`${p}`,String(T)}try{await l.sendSubject()}catch(T){`${p}`,String(T)}if(A()||l.showFilled(f),await l.sendInited(),w=!0,i===y){const T=e.readSandboxGeneration?.()??o;T!==void 0&&(r=T)}await l.revealFilled()}catch(T){throw A()||(`${p}`,{...e.describeSurface?.(),error:String(T)},void 0),!A()&&Uo(t(),y)&&t().failShow(y,T),T}finally{b(y,S,p,{superseded:A(),sessionGeneration:c,contentApplied:h,sandboxInitedAcked:w,commit:d()})}}function b(y,S,I,A){const{superseded:f,contentApplied:c,sandboxInitedAcked:d}=A;if(f){`${I}`;return}d&&A.commit?l.fireInit(y,S||void 0):d?(`${I}`,A.sessionGeneration,t().generation,t().signal.aborted,void 0):c?(`${I}`,void 0):(`${I}`,void 0),n=!1,a=void 0,!d&&i===y&&(i=void 0,r===o&&(r=void 0)),!d&&c&&m(y,S)}return{channel:l,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:y=>{r=y},lastCorrelation:()=>i,markCorrelation:y=>{i=y},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:y=>{o=y},fill:y=>_(y,!1),refill:y=>_(y,!0),stop:()=>{s+=1,v(),n=!1,E?.removeEventListener("abort",v),E=void 0}}}function mu(e,t,n){if(!e?.renderGuid||!e.showId||e.showId!==t.showId)return!1;if(t.isNew)return e.id==null;const r=t.emailId??t.navId;return r!=null&&String(e.id??"")!==String(r)?!1:Ho(e,n)}function Ho(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function gu(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=m=>{const v=n(),E=i();if(!mu(v,m,E)){m.showId,m.navId,m.emailId,v?.id,v?.showId,v?.renderGuid;return}m.showId,v?.id,v?.renderGuid,t.markFilled(o()),t.markCorrelation(m.showId),t.fill(m.showId).catch(()=>{})};return{showRequested:m=>{s(m)},showRequestIdentityChanged:()=>{const m=e.initPipeline().getActiveShowRequest();m&&s(m)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const m=o();if(t.filledGeneration()===m)return;const v=n(),E=i();if(!v?.renderGuid||!Ho(v,E))return;const g=`${Bo}${v.renderGuid}`;t.markFilled(m),t.markCorrelation(g);const _=r()?.isReady()===!0;v.id,v.renderGuid,(_?b=>t.refill(b):b=>t.fill(b))(g).catch(()=>{t.lastCorrelation()===g&&t.markFilled(void 0)})},saasChanged:()=>{const m=n();m?.renderGuid,m?.showToken,m?.id,r()}}}function vu(e){return e??""}function bu(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function yu(e){const t=we(e),n=ee(e),r=()=>de(t.sessionKey())?void 0:t.current(),i=()=>{const O=r();return uu({attributes:O?.get().attributes??{},readContent:()=>O?.getContent(),docId:O?.get().docId,hasSession:!!O,serverId:O?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(pe)??ar;let s={},a=!1;const l=e.getInstance(ne)?.watch(O=>{a=!!O?.element});let u=!1,m=!1,v=!1,E=0;const g=()=>{const O=ge(e);if(!O)return;const J=++E,$=O.spare();return $&&Gc(e,$.element),($?$.reloadQuietly():O.ensureSpare()?.ready())?.then(()=>{if(J!==E)return;u=!0;const se=O.spare();se&&Hc(e,se.element),v&&(v=!1,T(),M())})},_=cu({run:()=>{v||g()?.catch(()=>{})}}),b=()=>{su(e).noteContentShown(),!u&&!v&&_.start()};let y=!1;const A=hu({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const O=ge(e);return y&&O&&(y=!1,_.start()),a?O?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:O=>{const J=ge(e),$=J?.spare()?.element.contentWindow;m&&J&&$&&O===$&&(m=!1,J.promote(),J.busy(!1),y=!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>me(n),describeSurface:()=>({canvasPath:w,promoted:m,spareClean:u,handshake:n.isInited(),generation:me(n)}),events:{willInit:O=>{ie(e,G.WILL_EMAIL_INIT_ID).fire(O)},inited:O=>{b(),ie(e,G.ON_EMAIL_INIT_ID).fire(O)},contentChanged:O=>{ie(e,G.ON_CONTENT_CHANGED_ID).fire(O)},emailChanged:O=>{ie(e,G.ON_EMAIL_CHANGED_ID).fire(O)},browserExtensionDetected:()=>{ie(e,G.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),f=gu({pipeline:A,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>me(n)});let c="",d="",p="";const h=O=>O.length>0;let w="none";const T=()=>{const O=ge(e)?.spare();O&&(n.sendNow({operation:H.SANDBOX_LOCK_EDIT,data:!0}),u=!1,m=!0,Uc(e,O.element))},D=(O,J)=>{const $=ge(e);if(!$)return!0;const se=$.spare(),Se=se&&u?"spare":"prepare";if(w=Se,$.busy(!0),se&&u)return T(),!0;_.cancel(),n.sendNow({operation:H.SANDBOX_LOCK_EDIT,data:!0});const Ce=g();if(Ce===void 0)return w="reload",$.busy(!1),$.peek("email")?.reload(),!0;v=!0;const Re=E;return Ce.catch(()=>{!v||Re!==E||(v=!1,w="reload",$.busy(!1),$.peek("email")?.reload())}),!1},L=()=>{Gt(),A.noteSandboxGeneration(me(n));const O=i(),J=bu(O?.renderGuid,O?.showId,O?.id,s.emailId),$=vu(O?.renderGuid);if($!==d){const Ce=h(d),Re=d;d=$,Ce&&D(Re,$)}if(v)return;J!==c&&(c=J,f.showRequestIdentityChanged());const se=r(),Se=`${J}|${se?.get().docId??""}|${me(n)}`;Se!==p&&se?.isReady()===!0&&(p=Se,f.selfInitChanged()),f.saasChanged(),j()};let Y=!1,k="",R="",F=!1,C=!1;const P=O=>{O.source==="user"?C=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(F=!0),M()},j=()=>{const O=i();if(!O?.renderGuid)return;const J=A.channel.readContent(),$=JSON.stringify([O.preheader,O.common_styles,O.meta,O.subject,O.utm_parameters?.utm_campaign??"",O.utm_parameters?.utm_content??"",O.utm_parameters?.utm_medium??"",O.utm_parameters?.utm_source??"",O.utm_parameters?.utm_term??""]),se=Y&&J!==R,Se=Y&&$!==k;Y=!0,R=J,k=$;const Ce=F&&!C;if(F=!1,C=!1,A.isEventsLocked()||Ce)return;const Re={...O,id:s.isTemplate||O.isNew?void 0:O.id,html:J};if(se){ie(e,G.ON_CONTENT_CHANGED_ID).fire(J),ie(e,G.ON_EMAIL_CHANGED_ID).fire(Re);return}Se&&O.is_inited&&ie(e,G.ON_EMAIL_CHANGED_ID).fire(Re)};let x=!1;const M=()=>{x||(x=!0,queueMicrotask(()=>{x=!1,L()}))};e.inject(lr,{pipeline:A,setRoute:O=>{O.emailId===s.emailId&&!!O.isTemplate==!!s.isTemplate||(s=O,M())}});let q,X;const K=()=>{const O=r()?.get().docId;O!==X&&(q?.(),X=O,q=r()?.subscribe(P)),M()};let he,qe;const Gt=()=>{const O=e.getInstance(pe);!O||O===he||(qe?.(),he=O,qe=O.onShowRequested(J=>f.showRequested(J)))},Ps=n.addListener(O=>{O.data?.operation===H.SANDBOX_RESIZED&&_.notify()}),Ds=t.subscribe(K),Os=Ro(n,M);K(),e.getInstance(U)?.addDispose(()=>{l?.dispose(),qe?.(),Os(),Ds(),q?.(),Ps.dispose(),_.cancel(),A.stop()})}function Eu(){return ha!=="useblocks"}var Cn={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},_u={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!0,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},Vr=Cn,wu=["freeUserBlocks","blocks"],Go={};function Su(e){Go=e}var qo=e=>wu.includes(e)?Vr:Go[e]??Vr,Rn={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},Iu={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!0,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Au={...Rn,config:{...Rn.config,imageCenterFileManagerView:!1}};Su({pro:_u,editor:Iu,simple:Eu()?Rn:Au,freeUserBlocks:Cn,blocks:Cn});var $o=N("CodeMode");function zo(){let e;try{const t=window.localStorage?.getItem(Be.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function Tu(e){try{window.localStorage?.setItem(Be.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function Cu(e){return e.getOrCreateInstance($o,()=>{const t=Te(zo());return t.watch(Tu),t})}function Ru(e){return e?.getInstance($o)?.get()??zo()}function Pu(e,t){const n=Cu(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function Du(e,t,n=e.getInstance(ye)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Ru(e).isCodeMode&&Pu(e,!1)}var Kr=new Set;function Ou(){return window.localStorage.getItem(Be.em_color_scheme)??void 0}function xu(e){return Kr.add(e),e(Ou()),{dispose(){Kr.delete(e)}}}function Nt(e,t){return e.user.mode||e.serverSide.mode||t||"pro"}function Mu(e,t){return t.modeDefaults(Nt(e,t.fallbackMode))}function ku(e,t){const n=Nt(e,t);return e.serverSide.advancedConfigs?.[n]||{}}function Lu(e,t){const n=Nt(e,t),r=e.user?.advancedConfigs?.[n],i=r!==void 0?r:e.user?.advancedConfigs?.pro;return{...e.advancedConfigs?.[n],...i}}function Nu(e){let t;for(const n of e)n?.fileManager&&(t={...t,...n.fileManager});return t}function Fu(e){return js(e.map(t=>t?.resourceProxy))}function ju(e){return Fs(e.map(t=>t?.resourceProxyPolicy))}function Bu(e){return Js(e.map(t=>t?.backendProxy))}function Uu(e){return Fi(e.map(t=>t?.backendProxyPolicy||{}).filter(Boolean))}function Hu(e,t){return[e.base,Mu(e,t),e.profile,e.serverSide,ku(e,t.fallbackMode),e.user,Lu(e,t.fallbackMode),e.local]}function Yt(e,t){const n=Hu(e,t),r=Fi(n),i=Nu(n);i!==void 0&&(r.fileManager=i);const o=Fu(n);o!==void 0&&(r.resourceProxy=o);const s=ju(n);s&&Object.keys(s).length>0&&(r.resourceProxyPolicy=s);const a=Bu(n);a!==void 0&&(r.backendProxy=a);const l=Uu(n);return l&&Object.keys(l).length>0&&(r.backendProxyPolicy=l),r}var Gu=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function Wr(e){return e==="server"?"serverSide":e}function qu({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=Te();let o={kind:"pending"},s;const a=new Promise(E=>{s=E}),l=n===void 0?void 0:setTimeout(()=>{m({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function u(){o.kind!=="pending"&&i.set(Yt(r,e))}function m(E){if(o.kind!=="pending")return;clearTimeout(l),o=E;const g=Yt(r,e);i.set(g),s(g)}function v(E,g){r[Wr(E)]=g,E==="server"&&o.kind==="pending"?m({kind:"applied"}):u()}return{watch:E=>i.watch(E),select:E=>i.select(E),get:()=>i.get(),ready:()=>a,state:()=>o,layers:()=>({...r}),bootstrap(){const E=Yt(r,e);return Object.fromEntries(Gu.map(g=>[g,E[g]]))},merge(E,g){v(g,{...r[Wr(g)],...E})},replace(E,g){v(g,E)},setMode(E){r.user={...r.user,mode:E},u()},setAdvancedConfigs(E){r.advancedConfigs=E,u()},serverAbsent(E){m({kind:"absent",reason:E})},applyServerResponse(E){o.kind==="pending"&&v("server",{...r.serverSide,...E})},dispose(){clearTimeout(l)}}}var $u=5e3,zu="blocks";function Vu(){return{...qo(zu)?.config,mergeTags:void 0}}function Ku(e,t){e.getInstance(ne)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function Wu(e,t){let n;tr(e).watch(({profile:r})=>{const i=`${r?.theme??""}|${r?.locale??""}`;if(i===n)return;n=i;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function Yu(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function Xu(e,t){let n,r=!1,i;const o=a=>{i??=Nt(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&Du(e,a,t)},s=tr(e).watch(({profile:a})=>{const l=a?.email_builder_config,u=Yu(l);if(u===void 0||l===n)return;const m=n===void 0;n=l,!(m&&r)&&o(u)});e.getInstance(U)?.addDisposable(s),t.ready().then(a=>{if(!a.configSwither)return;const l=localStorage.getItem("configSwither")||(n===void 0?a.mode:i)||"editor";localStorage.setItem("configSwither",l),r=n===void 0,o(l)})}function Ju(e,t){let n=null;const r=xu(i=>{const o=typeof i=="string"&&i?i:void 0;o!==n&&(n=o,t.replace(o?{theme:o}:{},"local"))});e.getInstance(U)?.addDisposable(r)}async function Qu(e,t){if(e.getInstance(Kn)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(Le);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function Zu(e){e.injectFactory(ye,(t,n)=>{if(n)return n;const r=qu({base:Vu(),env:{modeDefaults:i=>qo(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:$u});return Ku(e,r),Wu(e,r),Xu(e,r),Ju(e,r),Qu(e,r),e.getInstance(U)?.addDisposable(r),r},!0)}var ke=class extends Q{_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 B(e,t,n){const r=Ns(e);return(i,o,s)=>{const a=r(async l=>{const u=t?t(l):l;s&&i.bind(s);const m=await i(u);return n?n(m):m},o,s);return()=>a.dispose()}}var ef=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new vn;this.handleDestroy=B(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new ke(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},dr=N("DestroyableService");function tf(e){e.injectFactory(dr,(t,n)=>{if(n)return n;const r=e.getInstance(U);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new ef({lifetime:r,options:e.getInstance(ne),getInstance:()=>e.getInstance(kt),release:()=>ua(e.getInstance(aa)??e)})},!0)}function nf(e){const t=e.getInstance(dr);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var rf=1e3;function Vo(e,t,n=rf,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const s of i)if(!Vo(e[s],t[s],n,r+1))return!1;return!0}return!1}function Xe(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const i=t[r],o=e[r];Vo(i,o)||(n[r]=i)}return n}var of=class extends Error{timeoutMs;constructor(e){super(`[useblocks] handleSaveEmail did not respond within ${e}ms — the email was not saved`),this.timeoutMs=e,this.name="IntegratorSaveTimeoutError"}},sf=({source:e,emailtags:t,group:n,tags:r,...i})=>i;async function af({emails:e,saveTimeoutMs:t},n){const r=t?.()??Xn();let i;try{return await Promise.race([e.notifySave(n),new Promise((o,s)=>{i=setTimeout(()=>{const a=new of(r);n.value.id,s(a)},r)})])}finally{i!==void 0&&clearTimeout(i)}}function lf(e){const{emails:t}=e,n=async(r,i)=>{const o=sf(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...o}:o,l=await af(e,{prev:s,patch:s?Xe(s,o):o,value:a,source:i.source??""}),u=String(l.id??r??fe()),m=l.id===void 0?{...l,id:u}:l;return await t.cache.addOrUpdate(u,()=>m)};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const i=await n(void 0,r);return i?.renderGuid?i:{...i,renderGuid:fe()}},async updateEmail(r,i){return await n(r,i)}}}var Xt=20,df=({source:e,emailtags:t,group:n,tags:r,...i})=>i;function cf({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r}){const i=async(o,s)=>(t.clear(),await t.get(o,{page:s}),(await e.cache.values()??[]).filter(a=>String(a?.parent)===String(o)));return{async readRevisions(o,s=1){const a=await i(o,s);return{revisions:a.slice(Xt*(s-1),Xt*s),page:s,hasMore:a.length>Xt*s}},async readAutosave(o){const s=await r?.(o)??NaN,a=Number.isFinite(s)?s:void 0,l=await n?.(o);if(l?.asked){const u=l.revision?[{...l.revision,parent:o,isAutosave:!0}]:[];return Tl(u,a)}return Al(await i(o,1),a)},async saveAutosave(o,s){const a=df(s);return await e.create({...a,parent:o,isAutosave:!0,modified:new Date().toString()})}}}var uf=class extends ya{async execute([e],t){for(const n of t){const r=await n(e);r&&(r.id===void 0&&(r.id=e.value.id),e.value=r)}return e.value}},ff=class extends be{};var Yr=class extends Q{_items=new Map;_onChangeEmitter=new na;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const i=await t(n);return Ne(n,i)||this._onChangeEmitter.fire(),i}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([i,o])=>i)),r=(await this.entries()).filter(([i,o])=>!n.has(i));for(const[i,o]of e)t.push(this.addOrUpdate(i,()=>o)),n.add(i);for(const[i]of r)t.push(this.remove(i));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function pf(e,{filter:t,order:n="asc",orderBy:r,page:i,pageSize:o=20}={}){const s=e.length;let a=e.length;if(t!==void 0){const l=Object.keys(t);e=e.filter(u=>{for(const m of l){const v=u[m],E=t[m];return m==="id"||typeof v!="string"?v===E:typeof E=="string"&&v.startsWith(E)}return!0}),a=e.length}return r&&(e=e.sort((l,u)=>(l[r]>u[r]?1:u[r]>l[r]?-1:0)*(n==="asc"?1:-1))),i!==void 0&&(e=e.slice(o*(i-1),o*i)),{data:e,filteredTotal:a,total:s,totalPages:Math.ceil(a/o)}}function hf(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const i=t.get(r.id)||{};t.set(r.id,{...i,...r})}return[...t].map(([n,r])=>r)}function mf(e,t){return Xr(e)&&Xr(t)?String(e)===String(t):e===t}function Xr(e){return typeof e=="string"||typeof e=="number"}var gf=class extends Q{_cache=new Yr;_readEmitter=new be;_saveEmitter=this.addDisposable(new uf);_removeEmitter=this.addDisposable(new ff);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new Q);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Yr),i=n.addDisposable(new be);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const l=hf(await i.fire(o))||[];for(const u of l)u[e]=o,await this._cache.add(u.id,u);return l}catch{return[]}});const a=(await this._cache.values()||[]).filter(l=>{const u=l[e];return u==null||mf(u,o)});return pf(a,s)},first(o,s={}){return t.get(o,{...s,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:i.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=fe()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async i=>{const o=i?{...i,...t}:t;if(!r)return t=i?Xe(i,t):t,await this._saveEmitter.fire({prev:i,patch:t,value:o,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function at(e){const t=N(e);return n=>n.getOrCreateInstance(t,()=>new gf)}function vf(e){const t=e.getInstance(U);if(!t)throw new Error("Failed");return t}function Jr(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function bf(e,t,n){return e&&!Jr(t)&&Jr(e)?{...n,meta:e.meta}:n}var Ko=at("plugin.dataSource.emails"),Wo=at("plugin.dataSource.emailRevisions"),Yo=sr("plugin.readEmailAutosave"),Qr=N("emailDocuments.provided");function yf(e){const t=Ko(e),n=Wo(e),r=n.byForeignKey("parent");return e.getInstance(Qr)?{emails:t,emailRevisions:n}:(e.inject(Qr,!0),Jl(e,lf({emails:t,saveTimeoutMs:()=>Xn(e.getInstance(pe)?.contentReadyTimeoutMs)})),td(e,cf({revisions:n,revisionsByEmail:r,readAutosave:async i=>{const o=await ie(e,Yo).fire(i);return o.length===0?{asked:!1}:{asked:!0,revision:o[0]??null}},savedAt:async i=>Date.parse((await t.cache.getIfPresent(i))?.modified??"")})),vf(e).addDisposable(t.onSave(({prev:i,patch:o,value:s})=>bf(i,o,s),Number.MIN_VALUE)),{emails:t,emailRevisions:n})}function Zr(e,t){return!e?.data||!t||e.id!==t.locale?!1:t.contentHash?e.hash===t.contentHash:t.updatedAt>0&&t.updatedAt<=e.time}function Ef(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var _f="po",mt=null;function wf(){const e=typeof window.__useblocks__<"u"?window.__useblocks__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([_f],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function Sf(){return mt===null&&(mt=wf().catch(e=>{throw mt=null,e})),mt}async function Xo(e){if(typeof e=="object")return cr(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?If(t):Af(t)}function cr(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function If(e){try{return cr(JSON.parse(e))}catch{return}}var ei=!1;async function Af(e){try{return cr((await Sf()).parsePoCatalog(e))}catch{ei||(ei=!0);return}}var Tf="em_locale",Cf="em_ant_locale",Rf="locale",Pf="ant_locale";function ur(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Jo(e,t){const n=ur(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function Df(){return ur("em_locale")??Jo(Rf,"em_locale")}function ti(e){try{localStorage.setItem(Tf,JSON.stringify(e))}catch{}}function Of(){return ur("em_ant_locale")??Jo(Pf,"em_ant_locale")}function xf(e,t){try{localStorage.setItem(Cf,JSON.stringify({id:e,data:t}))}catch{}}var Mf=8e3;function kf(e,t){const n=e,r=t,i=Object.keys(n).filter(o=>o!=="");return i.length!==Object.keys(r).filter(o=>o!=="").length?!1:i.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function Lf(e){const t=Df(),n=Of();let r={ready:!1},i;const o=Te(r);let s=0;const a=y=>{r={...r,...y},o.set(r)},l=()=>{r.ready||a({ready:!0})},u=setTimeout(l,e.unlockAfterMs??Mf),m=y=>y!==s;let v;async function E(y,S){if(n?.id===y&&n.data&&a({antd:n.data}),!v)return;const I=await v(y).catch(()=>{});!I||m(S)||(a({antd:I}),xf(y,I))}async function g(y,S){const I=await e.askHost(y).catch(()=>null);if(m(S))return!0;if(I==null)return!1;const A=await Xo(I);return m(S)||(A&&a({catalog:A}),l()),!0}async function _(y,S){const I=await e.readList();if(m(S))return;if("error"in I){a({failure:{kind:"GET_LOCALES_ERROR",error:I.error}}),l();return}const A=I.data.find(c=>c.locale===y);if(!A){Ef("em_locale")&&a({catalog:void 0}),l();return}if(Zr(t,A)&&(!i||i.catalog===t?.data)){l();return}if(i?.entry&&r.catalog===i.catalog&&Zr(i.entry,A)){ti(i.entry),l();return}const f=await e.readCatalog(y);if(!m(S)){if("error"in f){a({failure:{kind:"GET_LOCALE_ERROR",error:f.error}}),l();return}f.data&&(i?.id===y&&r.catalog===i.catalog&&kf(i.catalog,f.data)||a({catalog:f.data}),ti({id:y,time:A.updatedAt||Math.floor(Date.now()/1e3),hash:A.contentHash,data:f.data})),l()}}async function b(y,S){if(!await g(y,S)){if(!m(S)&&(i?.id===y&&r.catalog===i.catalog||y==="en_US")&&l(),e.canUseNetwork&&!e.canUseNetwork()){l();return}await _(y,S)}}return{set(y){if(!y||y===r.id)return;const S=s+=1;a({id:y,failure:void 0});const I=i?.id===y&&r.catalog===i.catalog;(i&&!I&&r.catalog===i.catalog||y==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===y&&t.data&&(a({catalog:t.data}),l()),E(y,S),b(y,S)},prime(y,S,I){r.id&&r.id!==y||r.catalog||!S||(i=t?.id===y&&t.data&&(!I||t.time>=I.time)?{id:y,catalog:t.data}:{id:y,catalog:S,entry:I?{id:y,time:I.time,hash:I.hash,data:S}:void 0},a({catalog:i.catalog}))},useAntdLoader(y){v=y,r.id&&E(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(u)}}var Nf=class{http;constructor(e){this.http=e}jsonList=({locale:e},t={})=>this.http.request({path:`/translations/${e}.json`,method:"GET",format:"json",...t});getTranslations=({locale:e},t={})=>this.http.request({path:`/translations/${e}.po`,method:"GET",...t});localesList=(e={})=>this.http.request({path:"/translations/locales",method:"GET",format:"json",...e})},Ff=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:i,format:o,baseUrl:s,cancelToken:a,...l})=>{const u=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},m=this.mergeRequestParams(l,u),v=i&&this.toQueryString(i),E=this.contentFormatters[r||"application/json"],g=o||m.format;return this.customFetch(`${s||this.baseUrl||""}${n}${v?`?${v}`:""}`,{...m,headers:{...m.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):m.signal)||null,body:typeof e>"u"||e===null?null:E(e)}).then(async _=>{const b=_;b.data=null,b.error=null;const y=g?_.clone():_,S=g?await y[g]().then(I=>(b.ok?b.data=I:b.error=I,b)).catch(I=>(b.error=I,b)):b;return a&&this.abortControllers.delete(a),S})}},jf=N("rest.v2.transport"),ni=Symbol("rest.v2.secureRequest");function Bf(e){return e.getOrCreateInstance(jf,()=>{const t=e.getInstance(Ni)?.execute||fetch;return new Ff({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[ni]:!0}),customFetch:(n,r={})=>{const{[ni]:i,...o}=r;return t(n,{...o,[Hs]:i!==!0})}})})}function Uf(e,t){const n=Bf(e);return Object.assign({},...t.map(r=>new r(n)))}function ri(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Qo(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:ri(n.details,"wp_code")??n.code,message:ri(n.details,"wp_message")??n.message,details:n.details}}:t&&typeof t=="object"?{status:e.status,data:t}:{status:e.status,data:{message:e.statusText||"request failed"}}}function Zo(e){return!e.ok||!!e.error}function Hf(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function es(){return Hf(Be.em_translations_v2)??!0}function Gf(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function qf(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function $f(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],i=r[0];return typeof i=="string"&&i!==""&&t.push({locale:i,updatedAt:Gf(r[1])}),t},[]):[]}function zf(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:qf(n.updated_at),contentHash:n.content_hash}),t),[])}function ts(e){return Uf(e,[Nf])}function Dt(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function Pn(e){return!e.ok||e.error!=null}function Dn(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function Jt(e){return{data:await Xo(e)??null}}async function Vf(e){if(es())try{const n=await ts(e).localesList();return Zo(n)?{error:Qo(n)}:{data:zf(n.data)}}catch(n){return Dt(n)}const t=Ui(e,[Vi]);try{const n=await t.get_translations2({file:"react_app"});return Pn(n)?Dn(n):{data:$f(n.data)}}catch(n){return Dt(n)}}async function Kf(e,t){if(es())try{const r=await ts(e).jsonList({locale:t});return Zo(r)?{error:Qo(r)}:Jt(r.data)}catch(r){return Dt(r)}const n=Ui(e,[Vi]);try{const r=await n.get_translations3({id:t,file:"react_app"});return Pn(r)?Dn(r):Jt(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return Pn(r)?Dn(r):Jt(r.data)}catch(r){return Dt(r)}}}var gt=new WeakMap;function Wf(e){const t=gt.get(e);if(t!==void 0)return t;const n=Vf(e).then(r=>("error"in r&>.delete(e),r),r=>{throw gt.delete(e),r});return gt.set(e,n),n}var tt=N("locale.service");function Yf(e){if(e.getInstance(tt))return;const t=Lf({readList:()=>Wf(e),readCatalog:n=>Kf(e,n),askHost:async n=>(await ie(e,G.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(Ee)});e.inject(tt,t),e.getInstance(U)?.addDispose(()=>t.dispose())}function Xf(e){const t=e.getInstance(ye);if(!t)return;const n=e.getInstance(tt);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i||"en_US"));e.getInstance(U)?.addDisposable(r)}var Jf="user_id",Qf="project_id",ii=N("rest.identityHeadersProvided");function Zf(e){if(e.getInstance(ii))return;e.inject(ii,!0);let t;e.getInstance(ne)?.watch(n=>{t=n}),e.addService(qn,{execute(n,r){if(r?.public)return;const i=t?.user?.id??Eo(e).profile?.id;i!=null&&i!==""&&n.headers.set(Jf,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(Qf,String(o))}})}function ep(e){if(!e)return!1;try{return e.getInstance(Ee)!==void 0}catch{return!1}}var tp="Invalid standaloneKey.",jg=N("StandaloneMockGuard");function np(){const e=new Error(tp);return e.name="InvalidStandaloneKeyError",e}function rp(e){e.addService(qn,{execute:()=>{if(ep(e))throw np()}})}function ip(e){ta(e),rp(e)}function op(e){const t=new ko;e.inject(pe,t);const n=e.getInstance(ne)?.watch(i=>{if(!i)return;const o=i.signal??t.externalSignal;t.configure({replaceSession:!0,...i.timeouts!==void 0?{timeouts:i.timeouts}:{},...o!==void 0?{signal:o}:{}})}),r=e.getInstance(U);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var sp=at("plugin.dataSource.blocks"),ap=at("plugin.dataSource.blockRevisions"),lp=at("plugin.dataSource.comments"),dp=sr(),cp=sr(),ns=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
1004
|
+
`));return{html:Df(t.html),hasBrowserExtensionArtifacts:t.found}}function sn(e){return e?.getContent()??""}function Js(e,t){e?.mutate({content:bs(t)},{source:"remote"})}function Qr(e){return F(e)}function fe(e,t){return e.getOrCreateInstance(t,()=>new Me)}function te(e,t){return e.getOrCreateInstance(t,()=>new Me).event}function an(e,t,n,r){return{html:e,guid:t,...Object.keys(n).length>0?{templateDirectivesPolicy:n}:{},...r!==void 0?{rev:r}:{}}}var Of=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(pe("Superseded by newer show()")),n.aborted?Promise.reject(pe(n.reason)):(this._activeRequest=e,new Promise((r,i)=>{const o=setTimeout(()=>{this._settle(e.showId,()=>{i(new Of(e.showId,t))})},t);o.unref?.();const s=()=>{this._settle(e.showId,()=>{i(pe(n.reason))})};n.addEventListener("abort",s,{once:!0});const a=()=>{clearTimeout(o),n.removeEventListener("abort",s)};this._pending.set(e.showId,{request:e,resolve:r,reject:i,timeoutId:o,dispose:a});for(const c of this._listeners)c(e)}))}completeShow(e){this._settle(e,t=>{t.resolve()})}hasPendingShow(e){return this._pending.has(e)}failShow(e,t){this._settle(e,n=>{n.reject(t)})}rejectAll(e){this._rejectPending(e),this._activeRequest=null}_settle(e,t){const n=this._pending.get(e);n&&(n.dispose(),this._pending.delete(e),this._activeRequest?.showId===e&&(this._activeRequest=null),t(n))}_rejectPending(e){for(const[,t]of this._pending)t.dispose(),t.reject(e);this._pending.clear()}};function Mf(e,t){return{contentReady:t.contentReady??e?.contentReady,sandboxReady:t.sandboxReady??e?.sandboxReady,sandbox:t.sandbox?{...e?.sandbox,...t.sandbox}:e?.sandbox}}function kf(e){if(!e||!(e.contentReady!==void 0||e.sandboxReady!==void 0||e.sandbox!==void 0))return;const t=ls(e),n=cs(e),r=Gc(e.sandbox);t<n+r}var Qs=class{_controller=new AbortController;_externalSignalDisposable=new ie;_sessionChangeListeners=new Set;_showRegistry=new xf;_timeouts;_generation=0;_sessionStarted=!1;_externalSignal;get signal(){return this._controller.signal}get externalSignal(){return this._externalSignal}get generation(){return this._generation}get contentReadyTimeoutMs(){return ls(this._timeouts)}getSandboxTimeoutMs(e){return as(e,this._timeouts?.sandbox)}getSandboxReadyTimeoutMs(){return cs(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=Mf(this._timeouts,e.timeouts),kf(this._timeouts));const t=e.replaceSession===!0||!this._sessionStarted||e.timeouts!==void 0||e.signal!==void 0;this._sessionStarted=!0,e.signal!==void 0&&(this._externalSignal=e.signal),t&&(this._replaceSessionController(),this.bumpGeneration()),(e.signal!==void 0||t)&&this._linkExternalSignal(e.signal)}relinkExternalSignal(e){this._externalSignal=e,this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ie,this._linkExternalSignal(e)}abort(e){const t=e??pe("Editor instance destroyed");this._showRegistry.rejectAll(t),this._controller.signal.aborted||(this._controller.abort(t),this.bumpGeneration()),this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ie}_replaceSessionController(){this._externalSignalDisposable.dispose(),this._externalSignalDisposable=new ie,this._showRegistry.rejectAll(pe("Init session replaced")),this._controller.signal.aborted||this._controller.abort(pe("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??pe()),this.bumpGeneration());return}const t=()=>{this._controller.signal.aborted||(this._controller.abort(e.reason??pe()),this.bumpGeneration())};e.addEventListener("abort",t),this._externalSignalDisposable.addDispose(()=>{e.removeEventListener("abort",t)})}},Zr=(()=>{const e=new Qs;return e.configure({}),e})(),Lf=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 Nf(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 Ff(e,t,n){return e.isInited()&&e.getTarget()?Promise.resolve():(Y(n),new Promise((r,i)=>{let o=!1,s,a;const c=f=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),a?.dispose(),n?.removeEventListener("abort",d),f())},d=()=>{c(()=>i(pe(n?.reason)))};if(a=e.onInit(()=>{e.isInited()&&e.getTarget()&&c(()=>r())}),e.isInited()&&e.getTarget()){c(()=>r());return}t>0&&(s=setTimeout(()=>{c(()=>i(new Lf(t)))},t)),n?.addEventListener("abort",d)}))}var jf=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 Bf(e,t,n){return t<=0?e:new Promise((r,i)=>{let o=!1,s;const a=c=>{o||(o=!0,s!==void 0&&(clearTimeout(s),s=void 0),c())};s=setTimeout(()=>{a(()=>i(new jf(n,t)))},t),e.then(c=>{a(()=>r(c))},c=>{a(()=>i(c))})})}var Uf=2,ft=Symbol("sandbox:frame-replaced");function Ni(e){return e===ft}function we(e,t,n,r,i,o,s){const a=`sandbox:${t}`,c=o?.getSandboxTimeoutMs(t)??jr[t],d=()=>{let T=Bf(e.sendAsync(n,r),c,a);return T=rn(T,o?.signal),bt(a,T,i)};if(t==="INIT_START"&&Nf(e)){const T=o?.getSandboxReadyTimeoutMs()??2e4,w=e,g=C=>{const _=Ff(w,T,o?.signal);return bt("sandbox:INIT_START:ready-wait",_,i).then(()=>{if(!s||C<=0)return d();const P=s.getGeneration();let S;const M=new Promise((E,A)=>{S=s.onChange(()=>{s.getGeneration()!==P&&A(ft)})}),v=d();return v.catch(()=>{}),Promise.race([v,M]).finally(()=>S?.()).catch(E=>{if(E!==ft)throw E;return{...i},g(C-1)})})};return g(Uf)}if(!s)return d();const f=s.getGeneration();let h;const y=new Promise((T,w)=>{h=s.onChange(()=>{s.getGeneration()!==f&&w(ft)})}),b=d();return b.catch(()=>{}),Promise.race([b,y]).finally(()=>h?.()).catch(T=>{throw T===ft&&{...i},T})}var Hf=[["brace-percent",/<!--\{%/],["brace-hash",/<!--\{#/],["proscript",/<!--\[%/],["getresponse",/<!--\[\[(?:if|else\]\]|endif\]\])/i],["mailchimp",/<!--\*\|/],["expert-sender",/<!--<\/?(?:if|else|var)/i]],$f=200;function Zs(e=new Set){const t=new Set;return(n,r)=>{if(!Hf.some(([o,s])=>!e.has(o)&&s.test(n)))return;const i=r??`new:${n.length}:${n.slice(0,200)}`;t.has(i)||(t.size>=$f&&t.clear(),t.add(i))}}function ea(){return{isConfigured:()=>!1,toEditorForm:e=>e,toOutputForm:e=>e,keepWrappedOnOutput:new Set,editorPolicy:{},warnAboutUnconfiguredInput:Zs()}}var Gf=ea();function ze(e){return e?.getInstance(Cr)??Gf}function Vf(e){const t=Le(e),n=ae(e),r=()=>e.getInstance(Ae)??Zr;let i,o,s=!1,a=!1;const c=async(_,P,S)=>{const M=S.generation,v=()=>S.generation!==M||S.signal.aborted||t.current()!==_||a,E=be(n);s=!0;try{if(await we(n,"INIT_START",$.SANDBOX_INIT_START,{guid:P},void 0,S),v())return;const{html:A,hasBrowserExtensionArtifacts:m}=Xs(sn(_));if(m&&fe(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire(),Js(_,A),await we(n,"SET_ENTITY",$.SANDBOX_SET_ENTITY,an(sn(_),P,ze(e).editorPolicy,_.get().version),void 0,S),v())return;await we(n,"INITED",$.SANDBOX_INITED,{guid:P},void 0,S),i=P,o=E}finally{s=!1}},d=()=>ye(t.sessionKey())?t.current():void 0,f=()=>{if(a||s)return;const _=d(),P=_?.get().docId;if(!_||!P||i===P&&o===be(n)||!_.isReady())return;const S=r();S.signal.aborted||c(_,P,S).catch(()=>{})};let h=!1;const y=()=>{h||a||(h=!0,queueMicrotask(()=>{h=!1,f()}))};let b,T;const w=()=>{const _=d(),P=_?.get().docId;P!==T&&(b?.(),T=P,b=_?.subscribe(y)),y()},g=t.subscribe(w),C=er(n,y);w(),e.getInstance(U)?.addDispose(()=>{a=!0,C(),b?.(),g()})}var qf=200;function zf({startVersion:e,limit:t=qf}){let n=[],r=e;const i=o=>{n=n.filter(s=>s.version>o),r=Math.max(r,o)};return{record(o){!o.changes?.length&&!o.contentReplaced||(n.push(o),n.length>t&&i(n[n.length-t-1].version))},rebase(o,s){if(s<r)return null;const a=n.filter(d=>d.version>s);i(s);let c=o;for(const d of a){if(d.contentReplaced||!d.changes)return null;const f=d.changes,h=[];for(const y of c){if(d.fromCanvas&&f.some(T=>y.range.start<=T.oldEnd&&y.range.end>=T.oldPosition))return null;const b=ed(y.range,f,"after");if(!b)return null;h.push({range:b,text:y.text})}c=h}return c}}}function Wf(e,t){let n=0;return e.map(({start:r,end:i,text:o})=>{const s=new ge(r,t.slice(r,i),r+n,o);return n+=o.length-(i-r),s})}function Kf(e,t){const n=[...e].sort((r,i)=>r.range.start-i.range.start);return Wf(n.map(({range:r,text:i})=>({start:r.start,end:r.end,text:i})),t)}function Yf(e){return[...e].sort((t,n)=>n.oldPosition-t.oldPosition).map(t=>({range:{start:t.oldPosition,end:t.oldEnd},text:t.newText}))}var ei=F("canvas.sandboxFill");function ta(e){return e.getInstance(ei)?.pipeline.isEventsLocked()===!0}function qt(e){St(e,{origin:"canvas-channel"})}function Xf(e){const t=Le(e),n=ae(e);let r;const i=(c,d)=>{const f=c.get().docId;let h=!1,y=null,b=null;const T=zf({startVersion:c.get().version});let w=c.getContent(),g=!0;const C=(E,A)=>{!g||t.current()!==c||(St(A,{origin:"canvas-channel"}),n.sendAsync($.SANDBOX_SET_ENTITY,an(sn(c),f,ze(e).editorPolicy,c.get().version)).catch(qt))},_=async(E,A)=>{if(b){b.push({edits:E,rev:A});return}b=[{edits:E,rev:A}];try{do{const m=b.splice(0,b.length);await n.sendAsync($.SANDBOX_UPDATE_ENTITY,{edits:m.map(l=>l.edits),guid:f,rev:m[m.length-1].rev})}while(b.length)}catch(m){C("app edits failed to reach the canvas",m)}finally{b=null}},P=(E,A)=>{const m=b?.splice(0,b.length)??[];m.length&&n.sendAsync($.SANDBOX_UPDATE_ENTITY,{edits:m.map(l=>l.edits),guid:f,rev:m[m.length-1].rev}).catch(qt),n.sendAsync($.SANDBOX_UPDATE_ENTITY,{edits:[E],guid:f,rev:c.get().version,...A!==null?{changeId:A}:{}}).catch(qt)},S=E=>{const{guid:A,pushUndoStop:m}=E;if(A!==f)return;const l=ud(E);let{edits:u}=E;if(l.baseRev!==null){const R=T.rebase(u,l.baseRev);if(!R){St(new Error("canvas batch conflicts with newer document changes"),{origin:"canvas-channel"}),P([],l.changeId);return}u=R}const p=c.get().version;try{h=!0,y=l.changeId;const R=Kf(u,c.getContent());m===!1?d.applyWithoutHistory(R):c.mutate({changes:R},{source:ta(e)?"system":"user"})}catch(R){C("canvas batch failed to apply",R);return}finally{h=!1,y=null}c.get().version===p&&l.baseRev!==null&&P([],l.changeId)},M=c.subscribe(({changes:E,version:A})=>{const m=c.getContent(),l=!E?.length&&m!==w;if(w=m,T.record({version:A,changes:E,contentReplaced:l,fromCanvas:h}),!E?.length)return;const u=Yf(E);h?P(u,y):_(u,A).catch(qt)}),v=n.addListener($.APPLICATION_UPDATE_ENTITY,S);return()=>{g=!1,M(),v.dispose()}};let o;const s=()=>{const c=t.current(),d=t.history(),f=c?.get().docId;f!==o&&(r?.(),r=void 0,o=f,c&&d&&(r=i(c,d)))},a=t.subscribe(s);s(),e.getInstance(U)?.addDispose(()=>{r?.(),a()})}var Jf=/^(?:ant|vscode|monaco|docs)-/;function Qf(e){return Jf.test(e)}function Zf(){const e="ub".trim();if(!/^[a-z][a-z0-9]*$/i.test(e))throw new Error(`[cssVars] REACT_APP_CSS_VAR_PREFIX="${e}" is not a valid CSS identifier fragment.`);return e}var ep=new Set(["animation-opacity","inline-edit-border-radius","separator-border","text-link-decoration"]);function tp(){return ep}var np=new Set;function rp(e,t,n=np){return e.startsWith(`${t}-`)?!1:!Qf(e)&&!n.has(e)}function ip(e,t){return`--${t}-${e}`}function na(e){const t=Zf();return rp(e,t,tp())?ip(e,t):`--${e}`}function op(e,t){const n=na(e);return t!==void 0?`var(${n}, ${t})`:`var(${n})`}function sp(e,t){return op(e,t)}function qe(e){const t=e.assignedSlot;if(t)return t;if(e.parentElement)return e.parentElement;const n=e.parentNode;return n instanceof ShadowRoot&&n.host instanceof HTMLElement?n.host:null}function Ue(e){return!e||e==="none"}function ap(e){const t=e.contain??"",n=e.willChange??"";return!Ue(e.transform)||!Ue(e.perspective)||!Ue(e.filter)||!Ue(e.backdropFilter)||!Ue(e.translate)||!Ue(e.rotate)||!Ue(e.scale)||/transform|perspective|filter/.test(n)||/paint|layout|strict|content/.test(t)||!!e.containerType&&e.containerType!=="normal"}function Fi(e){const t=/paint|strict|content/.test(e.contain??"");return{x:t||!!e.overflowX&&e.overflowX!=="visible",y:t||!!e.overflowY&&e.overflowY!=="visible"}}function lp(e){const t=[],n=document.documentElement,r=Fi(getComputedStyle(n)),i=r.x||r.y;let o="none";const s=getComputedStyle(e).position;(s==="absolute"||s==="fixed")&&(o=s);for(let a=qe(e);a&&a!==n;a=qe(a)){const c=getComputedStyle(a),d=o==="none"||ap(c)||o==="absolute"&&!!c.position&&c.position!=="static",f=a===document.body&&!i;if(d){o="none";const h=f?{x:!1,y:!1}:Fi(c);(h.x||h.y)&&t.push({node:a,...h})}(c.position==="absolute"||c.position==="fixed")&&(o==="none"||c.position==="fixed")&&(o=c.position==="fixed"?"fixed":"absolute")}return t}function ra(e){const t=e.getBoundingClientRect(),n=e.offsetWidth>0&&t.width>0?t.width/e.offsetWidth:1;return{x:n,y:e.offsetHeight>0&&t.height>0?t.height/e.offsetHeight:n}}function zt(e){return Number.parseFloat(e)||0}function nr(e){const t=e.getBoundingClientRect(),n=getComputedStyle(e),r=ra(e),i=zt(n.borderLeftWidth),o=zt(n.borderTopWidth),s=zt(n.borderRightWidth),a=zt(n.borderBottomWidth),c=e.offsetWidth>0?Math.max(0,e.offsetWidth-e.clientWidth-i-s):0,d=e.offsetHeight>0?Math.max(0,e.offsetHeight-e.clientHeight-o-a):0;return{left:t.left+i*r.x,top:t.top+o*r.y,right:t.right-(s+c)*r.x,bottom:t.bottom-(a+d)*r.y}}function cp(e,t,n){const r={left:e.left,top:e.top,right:e.right,bottom:e.bottom},i=(o,s,a)=>{s&&(r.left=Math.max(r.left,o.left),r.right=Math.min(r.right,o.right)),a&&(r.top=Math.max(r.top,o.top),r.bottom=Math.min(r.bottom,o.bottom))};return t.forEach(o=>i(nr(o.node),o.x,o.y)),n&&i(nr(n),!0,!0),r}var rr={originX:0,originY:0,scaleX:1,scaleY:1};function ln(e,t){return{left:(e.left-t.originX)/t.scaleX,top:(e.top-t.originY)/t.scaleY,width:Math.max(0,e.right-e.left)/t.scaleX,height:Math.max(0,e.bottom-e.top)/t.scaleY}}function ia(e,t,n){const r=t.width>0&&e.width>0?e.width/t.width:n.scaleX,i=t.height>0&&e.height>0?e.height/t.height:r;return{originX:e.left-t.left*r,originY:e.top-t.top*i,scaleX:r,scaleY:i}}function oa(e,t){return Math.abs(e.left-t.left)<=.5&&Math.abs(e.top-t.top)<=.5&&Math.abs(e.width-(t.right-t.left))<=.5&&Math.abs(e.height-(t.bottom-t.top))<=.5}var dp=1e3;function up(e){const{slot:t,own:n}=e;let r,i=0,o=!1;const s=()=>{if(r=void 0,!o){if(!t.isConnected||!n.isConnected){e.onDetached();return}(e.measure()||performance.now()<i)&&(r=window.requestAnimationFrame(s))}},a=()=>{!o&&r===void 0&&(r=window.requestAnimationFrame(s))},c=()=>{i=performance.now()+dp,a()},d=[window],f=[document.documentElement];for(let g=t;g;g=qe(g)){const C=g.getRootNode();C instanceof ShadowRoot&&!d.includes(C)&&(d.push(C),f.push(C))}const h=[["scroll",a],["load",a],["transitionrun",c],["transitionend",a],["transitioncancel",a],["animationstart",c],["animationend",a],["animationcancel",a]];d.forEach(g=>h.forEach(([C,_])=>g.addEventListener(C,_,{capture:!0,passive:!0}))),window.addEventListener("resize",a),document.fonts?.addEventListener?.("loadingdone",a);const y=typeof MutationObserver=="function"?new MutationObserver(g=>{g.some(C=>!n.contains(C.target))&&a()}):void 0;f.forEach(g=>y?.observe(g,{attributes:!0,childList:!0,subtree:!0,characterData:!0}));let b;try{if(typeof ResizeObserver=="function"){const g=new ResizeObserver(a);typeof g.observe=="function"&&(b=g)}}catch{b=void 0}let T=[];return{schedule:a,observe:g=>{!b||g.length===T.length&&g.every((C,_)=>C===T[_])||(b.disconnect(),T=g,g.forEach(C=>b?.observe(C)))},dispose(){o=!0,r!==void 0&&(window.cancelAnimationFrame(r),r=void 0),d.forEach(g=>h.forEach(([C,_])=>g.removeEventListener(C,_,{capture:!0}))),window.removeEventListener("resize",a),document.fonts?.removeEventListener?.("loadingdone",a),y?.disconnect(),b?.disconnect()}}}var sa=300,ji=15e3,fp=5e3,Bi="em-canvas-busy-style";function pp(){if(document.getElementById(Bi))return;const e=document.createElement("style");e.id=Bi,e.textContent="@keyframes em-canvas-busy-spin{to{transform:rotate(360deg)}}",document.head.appendChild(e)}var hp="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 00-94.3-139.9 437.71 437.71 0 00-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z";function mp(e){const t=sp("colorPrimary","#1677ff");return e&&getComputedStyle(e).getPropertyValue(na("colorPrimary")).trim()||t}function aa(e){pp();const t="http://www.w3.org/2000/svg",n=document.createElementNS(t,"svg");n.setAttribute("viewBox","0 0 1024 1024"),n.setAttribute("width","48"),n.setAttribute("height","48"),n.setAttribute("fill","currentColor"),n.setAttribute("aria-hidden","true");const r=document.createElementNS(t,"path");r.setAttribute("d",hp),n.appendChild(r);const i=document.createElement("span");return i.setAttribute("role","img"),i.setAttribute("aria-label","loading"),i.setAttribute("style",`display:inline-flex;color:${mp(e)};animation:em-canvas-busy-spin 1s linear infinite`),i.appendChild(n),i}function gp(e,t,n){const r=t??e,i=Math.max(r.left,e.left,0),o=Math.min(r.right,e.right,n.width),s=Math.max(r.top,e.top,0),a=Math.min(r.bottom,e.bottom,n.height);return o<=i||a<=s?{x:(e.left+e.right)/2-e.left,y:(e.top+e.bottom)/2-e.top}:{x:(i+o)/2-e.left,y:(s+a)/2-e.top}}function vp(e,t){const n=e.getBoundingClientRect(),r=document.createElement("div");r.setAttribute("aria-busy","true"),Object.assign(r.style,{position:"fixed",left:`${n.left}px`,top:`${n.top}px`,width:`${n.width}px`,height:`${n.height}px`,cursor:"progress"}),e.appendChild(r);const i={left:n.left,top:n.top,right:n.right,bottom:n.bottom},o=r.getBoundingClientRect();if(o.width>0&&!oa({left:o.left,top:o.top,width:o.width,height:o.height},i)){const s=ln(i,ia(o,ln(i,rr),rr));Object.assign(r.style,{left:`${s.left}px`,top:`${s.top}px`,width:`${s.width}px`,height:`${s.height}px`})}return{showSpinner(){r.style.background="rgba(128, 128, 128, 0.15)";const s=gp(n,t(),{width:window.innerWidth,height:window.innerHeight}),a=document.createElement("div");Object.assign(a.style,{position:"absolute",left:`${s.x}px`,top:`${s.y}px`,transform:"translate(-50%, -50%)",lineHeight:"0"}),a.appendChild(aa(e.querySelector(".ant-app")??e)),r.appendChild(a)},remove:()=>r.remove()}}function Rn(e){const t=document.createElement("div");t.setAttribute("aria-busy","true"),Object.assign(t.style,{position:"absolute",inset:"0",display:"flex",alignItems:"center",justifyContent:"center",cursor:"progress"});const n=getComputedStyle(e).position!=="static";n||(e.style.position="relative"),e.appendChild(t);const r=setTimeout(()=>{t.appendChild(aa(e))},sa);return{remove(){clearTimeout(r),t.remove(),n||(e.style.position="")}}}var bp=8e3;function yp(){return{element:document.createElement("iframe"),ready:()=>Promise.reject(new Error("[canvas] нет элемента монтирования")),reload:()=>Promise.resolve(),reloadQuietly:()=>Promise.resolve(),followReload:()=>{},moveTo:()=>Promise.resolve(),scrollBy:()=>{},shown:!1,slot:null,whenShown:()=>Promise.resolve(),filled:void 0,noteFilled:()=>{},alignTo:()=>{},resize:()=>{},dispose:()=>{}}}function Ep(e,t){for(let n=qe(e);n;n=qe(n)){const r=getComputedStyle(n),i=r.overflowX!=="visible"||r.overflowY!=="visible",o=[r.borderTopLeftRadius,r.borderTopRightRadius,r.borderBottomRightRadius,r.borderBottomLeftRadius].some(s=>Ye(s)>0);if(i&&o)return n;if(n===t)return null}return null}function Ye(e){return Number.parseFloat(e)||0}function Wt(e,t){return Math.abs(e-t)<=1}function _p(e){const t=getComputedStyle(e),n=Ye(t.borderTopWidth),r=Ye(t.borderRightWidth),i=Ye(t.borderBottomWidth),o=Ye(t.borderLeftWidth),s=(a,c,d)=>Math.max(0,Ye(a)-Math.max(c,d));return{...nr(e),radii:[s(t.borderTopLeftRadius,n,o),s(t.borderTopRightRadius,n,r),s(t.borderBottomRightRadius,i,r),s(t.borderBottomLeftRadius,i,o)]}}function wp(e,t){const n=Wt(t.top,e.top),r=Wt(t.bottom,e.bottom),i=Wt(t.left,e.left),o=Wt(t.right,e.right),s=[n&&i?e.radii[0]:0,n&&o?e.radii[1]:0,r&&o?e.radii[2]:0,r&&i?e.radii[3]:0];return s.every(a=>a===0)?"":s.map(a=>`${a}px`).join(" ")}function Sp(e,t,n,r,i,o){const s=n.readyTimeoutMs??bp,a=document.createElement("div");a.dataset.canvasHost=e,r&&(a.dataset.canvasPlace=r),a.style.position="fixed",a.style.overflow="hidden",a.style.visibility="hidden";const c=n.resolveSrc(e),d=document.createElement("iframe");d.setAttribute("sandbox",n.resolveSandbox(c)),d.setAttribute("allow","clipboard-read; clipboard-write"),d.setAttribute("title","Email content"),d.style.width="100%",d.style.border="0",d.style.display="block",d.style.minHeight="600px",d.src=c,a.appendChild(d),t.appendChild(a),n.mark?.("created"),i||n.onCreated?.(d);const f=new ie;let h=!1,y,b=!1,T,w,g,C;const _=()=>{clearTimeout(C),C=setTimeout(()=>{b||(b=!0,w?.(new Error(`[canvas] ${e}: документ не загрузился за ${s} мс`)))},s)},P=()=>h?(g=Promise.resolve(),b=!0,g):(b=!1,g=new Promise((N,H)=>{T=N,w=H}),_(),g),S=()=>{if(clearTimeout(C),h=!0,b){g=Promise.resolve();return}b=!0,n.mark?.("loaded"),T?.()};d.addEventListener("load",S),f.addDispose(()=>{clearTimeout(C),d.removeEventListener("load",S)});let M;const v=()=>{M??=n.bindResizer?.(d)},E=()=>{M?.dispose(),M=void 0};let A=null,m=null,l,u=rr,p="",R="",D=0;const L=N=>{const H=JSON.stringify(N);return H===p?!1:(p=H,a.style.visibility=N.visibility,a.style.left=`${N.css.left}px`,a.style.top=`${N.css.top}px`,a.style.width=`${N.css.width}px`,a.style.height=`${N.css.height}px`,a.style.borderRadius=N.radius,d.style.width=N.elementWidth>0?`${N.elementWidth}px`:"100%",d.style.transform=N.shiftX!==0?`translate(${N.shiftX}px, ${N.shiftY}px)`:`translateY(${N.shiftY}px)`,!0)},I=()=>{if(!A)return p="",a.style.visibility="hidden",d.removeAttribute("id"),!1;n.elementId&&(d.id=n.elementId);const N=A.getBoundingClientRect(),H=lp(A),W=m?.isConnected?m:null;l?.observe([A,d,...H.map(q=>q.node),...W?[W]:[]]);const z=cp(N,H,W),ne=Math.max(0,z.right-z.left),Re=Math.max(0,z.bottom-z.top),st=getComputedStyle(A).visibility==="visible",Fe=ne<=0||Re<=0,Pe=Fe?{left:z.left,top:z.top,right:z.left,bottom:z.top}:z,Ut=Fe?null:Ep(A,W??H[0]?.node??null),x=Ut?wp(_p(Ut),Pe):"",V=q=>L({visibility:st?"":"hidden",css:ln(Pe,q),elementWidth:N.width/q.scaleX,shiftX:(N.left-Pe.left)/q.scaleX,shiftY:(N.top-Pe.top)/q.scaleY,radius:x});let G=V(u);if(!Fe){const q=a.getBoundingClientRect();q.width>0&&!oa({left:q.left,top:q.top,width:q.width,height:q.height},Pe)&&(u=ia(q,ln(Pe,u),u),G=V(u)||G)}return G},O=()=>{if(!A)return!1;let N=I();const H=d.getBoundingClientRect().height;H>0&&H!==D&&(D=H,A.style.height=`${H/ra(A).y}px`,N=!0);const W=getComputedStyle(A).pointerEvents;return W!==R&&(R=W,a.style.pointerEvents=W),N},k=()=>{l?.dispose(),l=void 0},ee=N=>{l=up({slot:N,own:a,measure:O,onDetached:k})};let ce=[];const X=(N,H)=>{if(m=H,N&&ce.length>0){const W=ce;ce=[],W.forEach(z=>z())}if(N===A){N&&!l&&ee(N),O();return}if(k(),A&&A.style.removeProperty("height"),p="",D=0,R="",A=N,!N){I(),E();return}n.onShown?.(d),ee(N),O(),v()};f.addDispose(k);const J=N=>{h=!1,y=void 0,o?.(),N&&n.onReload?.(d);let H;b||g===void 0?H=P():(_(),H=g);try{d.contentWindow?.location.reload()}catch{d.src=c}return H};return{element:d,ready(){return g??P()},reload:()=>J(!0),reloadQuietly:()=>J(!1),followReload:()=>{y=void 0,o?.(),n.onReload?.(d)},moveTo(N){if(a.parentNode===N)return g??P();h=!1,y=void 0,o?.();let H;return b||g===void 0?H=P():(_(),H=g),N.appendChild(a),n.onReload?.(d),p="",l?.schedule(),H},get shown(){return A!==null},get slot(){return A},whenShown(){return A!==null?Promise.resolve():new Promise(N=>{ce.push(N)})},get filled(){return y},noteFilled(N){y=N},alignTo(N,H){X(N,H??null)},scrollBy(N,H){let W=N,z=H;for(let ne=A?qe(A):null;ne;ne=qe(ne)){if(Math.abs(W)<1&&Math.abs(z)<1)return;const Re=getComputedStyle(ne);if((Re.overflowY==="auto"||Re.overflowY==="scroll")&&ne.scrollHeight>ne.clientHeight){const st=ne.scrollTop,Fe=ne.scrollLeft;ne.scrollBy({left:W,top:z,behavior:"instant"}),W-=ne.scrollLeft-Fe,z-=ne.scrollTop-st}}(Math.abs(W)>=1||Math.abs(z)>=1)&&window.scrollBy({left:W,top:z,behavior:"instant"})},resize(){M?.resize()},dispose(){X(null,null),E(),f.dispose(),a.remove()}}}function Ip(e){const t=new Map;let n="a";const r=()=>n==="a"?"b":"a",i=(u,p)=>u==="email"?`email:${p??n}`:u,o=new Map;let s,a=[],c=!1,d,f,h=!1,y,b,T="shown",w=0,g,C,_;const P=u=>f!==void 0&&u.filled!==void 0&&u.filled!==f,S=()=>{g=void 0;const u=y;!h||!u||f===void 0||C===f||!P(u)||(C=f,e.onForeignDocument?.({wanted:f,filled:u.filled,role:T,heldMs:Date.now()-w}))},M=()=>{h=!1,y=void 0,b=void 0,clearTimeout(g),g=void 0},v=(u,p)=>{const R=o.get("email"),D=R?.slot??null;return u&&D&&P(u)?(u.alignTo(null),h||(h=!0,w=Date.now(),g=setTimeout(S,fp)),T=p,y=u,!(s!==void 0||c)&&b!==u&&(b=u,e.onShown?.(u.element)),!d&&!s&&(d=Rn(D)),!1):(h&&(M(),d?.remove(),d=void 0),u?.alignTo(D,R?.clip??null),!0)},E=()=>{h&&!c&&v(t.get(i("email")),"shown")},A=()=>{a.forEach(u=>clearTimeout(u)),a=[],s?.remove(),s=void 0,d?.remove(),d=void 0,(c||h)&&(c=!1,v(t.get(i("email")),"shown"))},m=(u,p,R)=>{const D=i(u,p),L=t.get(D);if(L)return L;const I=e.resolveMount();if(!I)return yp();const O=Sp(u,I,e,u==="email"?p??n:void 0,R,u==="email"?()=>E():void 0);return t.set(D,O),O},l={get:u=>m(u),current:u=>m(u),peek:u=>t.get(i(u)),spare:()=>t.get(i("email",r())),ensureSpare:()=>m("email",r(),!0),promote(){const u=t.get(i("email",r()));if(!u)return;const p=t.get(i("email"));n=r(),_=void 0,v(u,"spare"),p?.alignTo(null)},alignSurface(u,p,R){const D=o.get(u);if(o.set(u,{slot:p,clip:R??null}),u==="email"&&c){d?.remove(),d=p?Rn(p):void 0;return}const L=p?m(u):t.get(i(u));if(u!=="email"){L?.alignTo(p,R??null);return}if(!p){_=D?.slot&&L?.shown?{slot:D.slot,handle:L}:void 0,h&&(M(),d?.remove(),d=void 0),L?.alignTo(null);return}const I=_?.slot===p&&_.handle===L;if(_=void 0,D?.slot===p&&L?.shown||I){L?.alignTo(p,R??null);return}v(L,"shown")},want(u){f=u,u!==void 0&&E()},noteFilled(u,p){const R=l.byWindow(u);R&&(R.noteFilled(p),R===t.get(i("email"))&&E())},visible(){for(const u of t.values())if(u.shown)return u},byWindow(u){if(u){for(const p of t.values())if(p.element.contentWindow===u)return p}},busy(u){if(A(),!u)return;if(!l.visible()){c=!0,d?.remove(),d=void 0;const D=o.get("email");D?.slot&&(d=Rn(D.slot)),a=[setTimeout(A,ji)];return}const p=e.resolveMount();if(!p)return;const R=vp(p,()=>l.visible()?.element.parentElement?.getBoundingClientRect()??null);s=R,a=[setTimeout(()=>R.showSpinner(),sa),setTimeout(A,ji)]},remount(u){A();const p=i("email");t.forEach((R,D)=>{if(D===p){R.moveTo(u).catch(()=>{});return}R.dispose(),t.delete(D)})},dispose(){f=void 0,c=!1,M(),_=void 0,A(),t.forEach(u=>u.dispose()),t.clear(),o.clear(),n="a",f=void 0,C=void 0}};return l}var Cp=F("canvas.resizerBinder"),ir=F("canvas.service"),Tp={created:le.canvasCreated,loaded:le.canvasLoaded},la=new WeakMap;function or(e){return la.get(e)??0}function Ap(e,t){if(e.getInstance(ir))return;const n=Ip({resolveMount:()=>t.resolveMount(),resolveSrc:i=>t.resolveSrc(i),resolveSandbox:sf,elementId:t.elementId,bindResizer:i=>e.getInstance(Cp)?.(i),onCreated:i=>Qt(e,i,"fresh"),onReload:i=>{la.set(i,or(i)+1),Qt(e,i,"fresh")},onShown:i=>Qt(e,i,"switch"),mark:i=>t.mark?.(Tp[i]),onForeignDocument:i=>{({...i},Kc("canvas identity: place held, frame has another document",{origin:"canvas-identity",level:"warning",tags:{role:i.role},contexts:{canvasIdentity:{...i,path:window.location.pathname}}}))}}),r=ae(e).addListener($.SANDBOX_WHEEL,i=>{n.visible()?.scrollBy(i?.deltaX??0,i?.deltaY??0)});e.inject(ir,n),e.getInstance(U)?.addDispose(()=>{r.dispose(),n.dispose()})}function Qt(e,t,n){const r=ae(e),i=t.contentWindow;if(!i)return;const o=r.getTarget()===i;o&&n==="switch"||(n==="fresh"&&(r.forget(i),o&&r.setTarget(void 0)),r.setTarget(i),Hu(r))}function Rp(e,t){Qt(e,t,"promote")}function Pp(e,t){const n=t.contentWindow;n&&ae(e).greet(n)}function ca(e,t){const n=t.contentWindow;n&&ae(e).forget(n)}function Dp(e,t){const n=re(e)?.byWindow(t)?.element;if(!n)return;const r=or(n);return()=>or(n)!==r}function re(e){return e.getInstance(ir)}function Op(e){const t=ae(e),n=()=>re(e)?.byWindow(t.getTarget()),r=t.addListenerAsync($.RELOAD,()=>{n()?.followReload()}),i=t.addOffTargetListener($.RELOAD,a=>{const c=re(e)?.byWindow(a);c&&ca(e,c.element)}),o=t.addListener(a=>{a.data?.operation===$.SANDBOX_RESIZED&&n()?.resize()}),s=te(e,j.ON_EMAIL_INIT_ID)(()=>{n()?.resize()});e.getInstance(U)?.addDispose(()=>{r.dispose(),i.dispose(),o.dispose(),s.dispose()})}function Ui(){const e=document.createElement("div");return e.dataset.canvasOffscreen="true",e.style.position="absolute",e.style.left="-10000px",e.style.top="-10000px",e.style.width="1600px",e.style.height="1000px",document.body.appendChild(e),e}function xp(e){const t=e.getInstance(se);let n,r;e.getInstance(U)?.addDispose(()=>{r?.remove(),r=void 0}),Ap(e,{resolveMount:()=>n,resolveSrc:o=>zs(o==="block"),elementId:"email_iframe",mark:o=>Z(o)}),t?.watch(o=>{const s=o?.element;if(n&&s instanceof HTMLElement&&s!==n){n=s,re(e)?.remount(s),r?.remove(),r=void 0;return}if(!n){if(s instanceof HTMLElement)n=s;else if(o!==void 0){n=r??=Ui(),re(e)?.alignSurface("email",r,r);return}else return;re(e)?.get("email")}});let i;e.getInstance(U)?.addDispose(()=>{i?.remove(),i=void 0}),Eu(e).watch(o=>{const s=re(e);if(s){if(o){i??=Ui(),s.alignSurface("email",i,i);return}i&&(s.alignSurface("email",null),i.remove(),i=void 0)}})}var da=F("canvas.headerFlow"),Hi=["subject","preheader"],Mp=3e3,kp={subject:$.SANDBOX_SUBJECT_UPDATE,preheader:$.SANDBOX_PREHEADER_UPDATE};function Lp(e){const t=Le(e),n=ae(e),r=g=>g?"remote":ta(e)?"system":"user",i=(g,{guid:C,value:_,forced:P})=>{const S=dt(t);if(!S||typeof _!="string"||C&&C!==S.get().docId)return;const M=t.forcedHeaders();if(M?.[g]&&!P&&_!==M[g])return;P&&(h.delete(g),h.size===0&&t.endForcedHeaders());const v=S.get().attributes[g]??"";a=!0;try{Ct(S,{[g]:_},{source:r(P)})}finally{a=!1}o[g]=_,fe(e,j.ON_HEADER_APPLIED_ID).fire({field:g,value:_,forced:!!P,isGenerated:_!==v&&!!_})};let o={},s,a=!1,c=Promise.resolve();const d=(g,C,_,P=!1)=>{c=n.sendAsync(kp[g],{value:C,guid:dt(t)?.get().docId,..._?{force:!0,echo:!0}:{},...P?{undoStep:!0}:{}}).catch(S=>{})};let f;const h=new Set;e.inject(da,{whenDelivered:async()=>{await c},reassert:g=>{const C=dt(t),_=Hi.filter(P=>g[P]);if(!(!C||_.length===0)){a=!0;try{Ct(C,Object.fromEntries(_.map(P=>[P,g[P]])),{source:"system"})}finally{a=!1}t.beginForcedHeaders({subject:g.subject??"",preheader:g.preheader??""}),clearTimeout(f),f=setTimeout(()=>{h.clear(),t.endForcedHeaders()},Mp),h.clear();for(const P of _)h.add(P);for(const P of _)o[P]=g[P],d(P,g[P],!0)}}});const y=()=>{s?.(),s=void 0;const g=dt(t);if(!g){o={};return}const C=g.get().attributes;o={subject:C.subject,preheader:C.preheader},s=g.subscribe(({source:_})=>{if(a)return;const P=g.get().attributes,S=t.forcedHeaders();for(const M of Hi){const v=P[M];v!==o[M]&&(o[M]=v,d(M,v??"",_==="system"&&S?.[M]!==void 0,_==="user"))}})};y();const b=t.subscribe(y),T=n.addListenerAsync($.APPLICATION_SUBJECT_UPDATE,g=>i("subject",g)),w=n.addListenerAsync($.APPLICATION_PREHEADER_UPDATE,g=>i("preheader",g));e.getInstance(U)?.addDispose(()=>{T.dispose(),w.dispose(),b(),s?.(),clearTimeout(f)})}function $i(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function sr(e,t){const n={...e};for(const r of Object.keys(t)){const i=t[r],o=e[r];$i(i)&&$i(o)?n[r]=sr(o,i):i!==void 0&&(n[r]=i)}return n}function Np(e,t){const n=Pr;if(typeof e=="string"){const r=e.trim();if(r.startsWith("{"))try{const i=JSON.parse(r);if(i&&typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length>0)return sr(n,i)}catch{}}return t&&typeof t=="object"&&!Array.isArray(t)?sr(n,t):n}function Fp(){const e=window.localStorage.getItem(Mt.em_color_scheme),t=matchMedia("(prefers-color-scheme: dark)").matches?nc:Ul;return e&&e!=="system"?e:t}function jp(){const e=window.localStorage.getItem(Mt.em_code_mode_settings);if(!e)return!1;try{const t=JSON.parse(e);return!!(t?.isCodeMode&&(t.codeModeDirection==="left"||t.codeModeDirection==="right"))}catch{return!1}}function Bp(e){const{config:t}=e;return{operation:$.UPDATE_PREVIEW,theme:e.theme,commonStyles:Np(e.emailCommonStyles,e.defaultCommonStyles),pathEnabled:t.pathEnabled,copyPasteEnabled:t.copyPasteEnabled,saveBlockEnabled:t.saveBlockEnabled,editImageControlEnabled:t.editImageControlEnabled,codeMode:e.codeMode,elementAIimageEnabled:t.elementAIimageEnabled,imageCenterStockEnabled:t.imageCenterStockEnabled,imageCenterGifEnabled:t.imageCenterGifEnabled,imageCenterEditorEnabled:t.imageCenterEditorEnabled,blocksAddPanelEnabled:t.blocksAddPanelEnabled!==!1&&t.blocksSectionsShow!==!1,lockEditor:t.lockEditor,appName:e.appName}}var Up=F("DefaultCommonStyles");function ua(e){return e.getOrCreateInstance(Up,()=>Ee(void 0))}function Hp(e,t){ua(e).set(t)}function $p(e){const t=ae(e),n=e.getInstance(oe),r=e.getInstance(se),i=Le(e);let o,s="";const a=()=>{const _=n?.get()??{},P=Bp({config:_,emailCommonStyles:i.current()?.get().attributes?.common_styles,defaultCommonStyles:o,theme:Fp(),codeMode:jp(),appName:"useblocks"}),S=JSON.stringify(P);S!==s&&(s=S,t.send(P))},c=t.onInit(()=>{s="",a()}),d=()=>{t.isInited()&&a()},f=n?.watch(d),h=ua(e).watch(_=>{o=_,d()}),y=r?.watch(_=>{_&&"commonStyles"in _&&(o=_.commonStyles),d()});let b;const T=()=>{b?.(),b=i.current()?.subscribe(d),d()};T();const w=i.subscribe(T),g=matchMedia(Vl),C=()=>d();g.addEventListener("change",C),e.getInstance(U)?.addDispose(()=>{c.dispose(),f?.dispose(),h.dispose(),y?.dispose(),b?.(),w(),g.removeEventListener("change",C)})}var ar;(function(e){function t(i,o,s=(a,c)=>a===c){if(i===o)return!0;if(i.length!==o.length)return!1;for(let a=0;a<i.length;a++)if(!s(i[a],o[a]))return!1;return!0}e.isEqual=t;function n(i,o=s=>s){const s=new Set;return i.filter(a=>{const c=o(a);return s.has(c)?!1:(s.add(c),!0)})}e.unique=n;function r(i=[],o=[],s=(a,c)=>a===c){const a=[],c=[],d=[];for(const f of i){const h=o.find(y=>s(f,y));h?d.push({prev:f,next:h}):c.push(f)}for(const f of o)i.find(h=>s(f,h))||a.push(f);return{added:a,removed:c,exists:d}}e.diff=r})(ar||(ar={}));function Gp(e,t){return e.type===t.type&&e.key===t.key}function Vp(e){const t=ae(e),n=()=>e.getServices(Xe)??[];let r=[];const i=t.onInit(()=>{r=n(),t.send($.SANDBOX_ADD_EXTENSIONS,r)}),o=Tl(Xe),s=e.onInject(a=>{if(a!==o)return;const c=n();if(!t.isInited()){r=c;return}const{added:d,removed:f}=ar.diff(r,c,Gp);if(r=c,f.length){if(f.some(h=>h.type==="script")){t.send($.RELOAD);return}t.send($.SANDBOX_REMOVE_EXTENSIONS,f.map(h=>h.key))}d.length&&t.send($.SANDBOX_ADD_EXTENSIONS,d)});e.getInstance(U)?.addDispose(()=>{i.dispose(),s?.dispose()})}var qp=new Set([...Object.values($).map(e=>String(e)),"INIT_MESSAGE","FETCH_USER","USER_LOGGED_IN",String(Rr)]);function zp(e){return e.length>0&&!e.startsWith("em:")&&!qp.has(e)}function Wp(e){const t=ae(e),n=new Map;let r=!1,i=-1,o=new Set;const s=d=>(d!==i&&(i=d,o=new Set),o),a=t.observeOutgoing((d,f)=>{if(!r||!zp(d))return;const h=be(t);n.set(d,{data:f,generation:h,scripts:new Set(s(h))})}),c=t.addListener(Rr,d=>{if(d.phase!=="ready"||d.status!=="success")return;r=!0;const f=be(t),h=s(f);h.add(d.key);for(const[y,b]of n)b.generation===f||![...b.scripts].every(T=>h.has(T))||(b.generation=f,t.send(Wo(y),b.data))});e.getInstance(U)?.addDispose(()=>{a.dispose(),c.dispose()})}var Kp=F("prewarm.editorVisible");function Yp(e){if(typeof requestAnimationFrame!="function"){setTimeout(e,0);return}requestAnimationFrame(()=>requestAnimationFrame(e))}function Xp(e={}){const t=e.paint??Yp;let n=!1,r=!1,i=!1,o=!1,s=!1;const a=[],c=()=>{s||o||!n||!r||!i||(o=!0,t(()=>{s=!0,Z(le.editorVisible);for(const d of a.splice(0))d()}))};return{noteShellVisible(){n=!0,c()},notePagePainted(){r=!0,c()},noteContentShown(){i=!0,c()},whenVisible(d){if(s){d();return}a.push(d)},contentShown:()=>i}}function Jp(e){return e.getOrCreateInstance(Kp,()=>Xp())}var Qp=500,Zp=500,eh=5e3;function th(e){const t=e.quietMs??Qp,n=e.floorMs??Zp,r=e.ceilingMs??eh;let i,o,s=0;const a=()=>{clearTimeout(i),clearTimeout(o),i=void 0,o=void 0},c=()=>{a(),e.run()},d=()=>{clearTimeout(i);const f=n-(Date.now()-s);i=setTimeout(c,Math.max(t,f))};return{start(){a(),s=Date.now(),o=setTimeout(c,r),d()},notify(){i!==void 0&&d()},cancel:a}}function nh({attributes:e,readContent:t,docId:n,hasSession:r,serverId:i,show:o}){if(!r)return;const s={id:i??void 0,renderGuid:n,showId:o?.id,isNew:i==null,showToken:o?.token},a={...e,...s};return Object.defineProperty(a,"html",{get:()=>t()??"",enumerable:!0,configurable:!0}),a}var fa="self-init:";function rh(e){return e.startsWith(fa)}function pa(e,t){const n=e.getActiveShowRequest();return rh(t)?n===null:n?.showId===t&&e.hasPendingShow(t)}function ih(e){const t=()=>e.initPipeline(),n=e.messageService,r=()=>e.waitScope?.()??t(),i=()=>e.frameWatch?.();let o="",s;const a=T=>{s={target:e.readTarget?.(),docId:T}},c=()=>e.readDocument()?sn(e.readDocument()):o,d=()=>ze(e.container).editorPolicy,f=()=>e.readEmail(),h=()=>{const T=f();return{...T,id:e.isTemplate()||T.isNew?void 0:T.id,html:c()}};let y=!1;const b={readContent:c,publicEmail:h,sendInitStart:()=>we(n,"INIT_START",$.SANDBOX_INIT_START,{guid:f().renderGuid},void 0,r()),sendInited:()=>we(n,"INITED",$.SANDBOX_INITED,{guid:f().renderGuid},void 0,r(),i()),async sendContent(){const T=f(),{html:w,hasBrowserExtensionArtifacts:g}=Xs(T?.html||"");g&&e.events.browserExtensionDetected(),Js(e.readDocument(),w),o=w,a(T.renderGuid),await we(n,"SET_ENTITY",$.SANDBOX_SET_ENTITY,an(c(),T.renderGuid,d(),e.readDocument()?.get().version),{guid:T.renderGuid,emailId:T.id??null},r(),i())},refreshContent:()=>(a(f().renderGuid),we(n,"SET_ENTITY",$.SANDBOX_SET_ENTITY,an(c(),f().renderGuid,d(),e.readDocument()?.get().version),void 0,r(),i())),sendPreheader:async()=>{const T=f();if(T.preheader!==void 0)return we(n,"PREHEADER",$.SANDBOX_PREHEADER_UPDATE,{value:T.preheader,guid:T.renderGuid,force:!0},void 0,r(),i())},sendSubject:async()=>{const T=f();if(T.subject!==void 0)return we(n,"SUBJECT",$.SANDBOX_SUBJECT_UPDATE,{value:T.subject,guid:T.renderGuid,force:!0},void 0,r(),i())},revealFilled:()=>e.revealFilled?.()??Promise.resolve(),showFilled:T=>e.showFilled?.(T),noteFilled:(T,w)=>e.noteFilled?.(T,w),contentSent:()=>s,readTarget:()=>e.readTarget?.(),fireWillInit:()=>e.events.willInit(h()),fireInit(T,w){if(!pa(t(),T)){t().getActiveShowRequest()?.showId;return}const g=f();g.id,g.renderGuid,t().completeShow(T);const C=e.readDocument();Ct(C,{is_inited:!0},{source:"system"});const _=()=>{const S=h();w&&(S.reset=!0);const M=e.events.inited(S);return w||(y&&b.fireEmailChanged(),y=!0),M};if(!C||C.isReady())return _();const{docId:P}=C.get();return C.whenReady().then(()=>e.readDocument()?.get().docId===P?_():void 0,()=>{})},fireEmailChanged(){e.events.emailChanged(h())},fireContentChanged(){e.events.contentChanged(c())}};return b}var oh=2;function Gi(){return new Error("[sandbox] document reloaded during fill")}function sh(e,t,n){return{showId:e,reset:t,emailId:n?.id,renderGuid:n?.renderGuid}}function Pn(e){try{e()}catch{}}function ah(e){let t;return Pn(()=>{t=e()}),{stage:n=>Pn(()=>t?.stage(n)),end:(n,r)=>Pn(()=>t?.end(n,r))}}function lh(e){const t=()=>e.initPipeline();let n=!1,r,i,o,s=0,a,c;const d=()=>{const v=e.readTarget?.(),E=e.readSandboxGeneration?.();return v===void 0||E===void 0?void 0:{target:v,generation:E}},f=()=>{const v=d();return v&&{...v,canvasReplaced:e.trackDocument?.(v.target)}},h=v=>{if(v?.canvasReplaced?.())return!0;const E=d();return v!==void 0&&E?.target===v.target&&E.generation!==v.generation},b=ih({...e,waitScope:()=>({getSandboxTimeoutMs:v=>t().getSandboxTimeoutMs(v),getSandboxReadyTimeoutMs:()=>t().getSandboxReadyTimeoutMs(),signal:a?.signal??t().signal}),frameWatch:()=>{const v=c;if(!(!v||!e.onSandboxGenerationChange))return{getGeneration:()=>d()?.generation??v.generation,onChange:E=>e.onSandboxGenerationChange?.(()=>{(e.readTarget?.()===v.target||v.canvasReplaced?.())&&E()})??(()=>{})}}});let T;const w=(v,E)=>{if(T===v)return;T=v;const A=s;setTimeout(()=>{s!==A||t().signal.aborted||P(v,E).catch(()=>{})},0)},g=()=>{a?.abort(),a=void 0};let C;const _=()=>{const v=t().signal;v!==C&&(C?.removeEventListener("abort",g),C=v,v.addEventListener("abort",g))};async function P(v,E,A=0){const m=++s;g(),a=new AbortController,c=void 0,_();const l=()=>s!==m,u=b.readTarget(),p=t().generation,R=()=>p===t().generation&&!t().signal.aborted,D=E?"init:reset-":"init:",L=ah(()=>e.observeShow?.(sh(v,E,e.readEmail())));if(!E){const X=b.publicEmail();X?.id,X?.renderGuid,X?.preheader}let I=!1,O=!1,k,ee=!1;const ce=()=>{if(h(k))throw Gi()};try{n=!0,await b.sendInitStart(),l()||(k=f(),c=k),A===0&&b.fireWillInit(),await(E||A>0?b.refreshContent():b.sendContent()),I=!0,ce();const X=b.contentSent();b.noteFilled(X?.target,X?.docId),L.stage("content"),E||b.publicEmail()?.id;try{await b.sendPreheader()}catch(J){if(Ni(J))throw J;`${D}`,String(J)}try{await b.sendSubject()}catch(J){if(Ni(J))throw J;`${D}`,String(J)}if(ce(),l()||b.showFilled(u),await b.sendInited(),ce(),O=!0,i===v){const J=e.readSandboxGeneration?.()??o;J!==void 0&&(r=J)}L.stage("reveal"),await b.revealFilled(),ce(),L.end("revealed")}catch(X){const J=!l()&&R()&&h(k),N=J?Gi():void 0,H=N??X,W=J&&A<oh?M(v,E,A+1):void 0;ee=J&&W===void 0;const z=l()?void 0:{showId:v,contentApplied:I,sandboxInitedAcked:O,superseded:!1,...e.describeSurface?.(),error:String(N??X)};z&&(`${D}`,void 0);const ne=!l()&&e.recoverFailedFill?.(u)===!0;if(L.end(l()?"superseded":ne?"recovered":Or(H)||!R()?"aborted":"failed",z),!ne&&!l()&&pa(t(),v)&&t().failShow(v,H),W!==void 0)return W;throw H}finally{S(v,E,D,{superseded:l(),sessionGeneration:p,contentApplied:I,sandboxInitedAcked:O&&!ee,retry:!ee,commit:R()})}}function S(v,E,A,m){const{superseded:l,contentApplied:u,sandboxInitedAcked:p}=m;if(l){`${A}`;return}p&&m.commit?b.fireInit(v,E||void 0):p?(`${A}`,m.sessionGeneration,t().generation,t().signal.aborted,void 0):u?(`${A}`,void 0):(`${A}`,void 0),n=!1,a=void 0,!p&&i===v&&(i=void 0,r===o&&(r=void 0)),!p&&u&&m.retry&&w(v,E)}function M(v,E,A){return P(v,E,A)}return{channel:b,isEventsLocked:()=>n,filledGeneration:()=>r,markFilled:v=>{r=v},lastCorrelation:()=>i,markCorrelation:v=>{i=v},bumpRunSeq:()=>{s+=1},noteSandboxGeneration:v=>{o=v},fill:v=>P(v,!1),refill:v=>P(v,!0),stop:()=>{s+=1,g(),n=!1,C?.removeEventListener("abort",g),C=void 0}}}function ch(e,t,n){if(!e?.renderGuid||!e.showId||e.showId!==t.showId)return!1;if(t.isNew)return e.id==null;const r=t.emailId??t.navId;return r!=null&&String(e.id??"")!==String(r)?!1:ha(e,n)}function ha(e,t){return t?e?.id==null?!1:String(e.id)===String(t):!0}function dh(e){const{pipeline:t,readEmail:n,readDocument:r,readRouteEmailId:i,readSandboxGeneration:o}=e,s=f=>{const h=n(),y=i();if(!ch(h,f,y)){f.showId,f.navId,f.emailId,h?.id,h?.showId,h?.renderGuid;return}f.showId,h?.id,h?.renderGuid,t.markFilled(o()),t.markCorrelation(f.showId),t.fill(f.showId).catch(()=>{})};return{showRequested:f=>{s(f)},showRequestIdentityChanged:()=>{const f=e.initPipeline().getActiveShowRequest();f&&s(f)},selfInitChanged:()=>{if(e.initPipeline().getActiveShowRequest())return;const f=o();if(t.filledGeneration()===f)return;const h=n(),y=i();if(!h?.renderGuid||!ha(h,y))return;const b=`${fa}${h.renderGuid}`;t.markFilled(f),t.markCorrelation(b);const T=r()?.isReady()===!0;h.id,h.renderGuid,(T?w=>t.refill(w):w=>t.fill(w))(b).catch(()=>{t.lastCorrelation()===b&&t.markFilled(void 0)})},saasChanged:()=>{const f=n();f?.renderGuid,f?.showToken,f?.id,r()}}}var uh=F("canvas.health");function fh(e){return e??""}function ph(e,t,n,r){return[e??"",t??"",n==null?"":String(n),r??""].join("|")}function Vi(e){return e.length>0}function hh(e){const t=Le(e),n=ae(e),r=()=>ye(t.sessionKey())?void 0:t.current(),i=()=>{const x=r();return nh({attributes:x?.get().attributes??{},readContent:()=>x?.getContent(),docId:x?.get().docId,hasSession:!!x,serverId:x?.get().serverId,show:t.showFacts()})},o=()=>e.getInstance(Ae)??Zr;let s={},a=!1;const c=e.getInstance(se)?.watch(x=>{a=!!x?.element});let d=!1,f=!1,h=!1,y=0;const b=()=>{const x=re(e);if(!x)return;const V=++y,G=x.spare();return G&&ca(e,G.element),(G?G.reloadQuietly():x.ensureSpare()?.ready())?.then(()=>{if(V!==y)return;d=!0;const q=x.spare();q&&Pp(e,q.element),h&&(h=!1,p(),N())})},T=th({run:()=>{h||b()?.catch(()=>{})}}),w=()=>{Jp(e).noteContentShown(),!d&&!h&&T.start()};let g=!1;const C=x=>{const V=re(e),G=V?.spare()?.element.contentWindow;f&&V&&G&&x===G&&(f=!1,V.promote(),V.busy(!1),g=!0)};let _=!1;const M=lh({container:e,messageService:n,initPipeline:o,readDocument:r,readEmail:i,revealFilled:()=>{const x=re(e);return g&&x&&(g=!1,T.start()),a?x?.current("email").whenShown()??Promise.resolve():Promise.resolve()},showFilled:C,noteFilled:(x,V)=>re(e)?.noteFilled(x,V),recoverFailedFill:x=>{const V=re(e),G=V?.spare()?.element.contentWindow;return!f||!V||!G||x!==G?!1:(f=!1,d=!1,l="reload",V.busy(!1),V.peek("email")?.reload(),_=!0,N(),!0)},readTarget:()=>n.getTarget(),isTemplate:()=>!!s.isTemplate,readSandboxGeneration:()=>be(n),onSandboxGenerationChange:x=>er(n,x),trackDocument:x=>Dp(e,x),observeShow:x=>e.getInstance(uh)?.begin(x),describeSurface:()=>({canvasPath:l,promoted:f,spareClean:d,handshake:n.isInited(),generation:be(n)}),events:{willInit:x=>{fe(e,j.WILL_EMAIL_INIT_ID).fire(x)},inited:x=>{w(),fe(e,j.ON_EMAIL_INIT_ID).fire(x)},contentChanged:x=>{fe(e,j.ON_CONTENT_CHANGED_ID).fire(x)},emailChanged:x=>{fe(e,j.ON_EMAIL_CHANGED_ID).fire(x)},browserExtensionDetected:()=>{fe(e,j.ON_BROWSER_EXTENSION_DETECTED_ID).fire()}}}),v=dh({pipeline:M,initPipeline:o,readEmail:i,readDocument:r,readRouteEmailId:()=>s.emailId,readSandboxGeneration:()=>be(n)});let E="",A="",m="",l="none";const u=()=>{const x=re(e)?.spare()?.element.contentWindow;x&&n.getTarget()===x||n.sendNow({operation:$.SANDBOX_LOCK_EDIT,data:!0})},p=()=>{const x=re(e)?.spare();x&&(u(),d=!1,f=!0,Rp(e,x.element))},R=(x,V)=>{const G=re(e);if(!G)return!0;const q=G.spare(),je=q&&d?"spare":"prepare";if(l=je,G.busy(!0),q&&d)return p(),!0;T.cancel(),u();const Be=b();if(Be===void 0)return l="reload",G.busy(!1),G.peek("email")?.reload(),!0;h=!0;const De=y;return Be.catch(()=>{!h||De!==y||(h=!1,l="reload",G.busy(!1),G.peek("email")?.reload())}),!1},D=()=>{st(),M.noteSandboxGeneration(be(n));const x=i(),V=ph(x?.renderGuid,x?.showId,x?.id,s.emailId),G=fh(x?.renderGuid);if(G!==A){const Be=A;A=G;const De=re(e)?.peek("email")?.filled,vl=De!==void 0&&De!==G;Vi(G)&&(Vi(Be)||vl)&&R(Be||(De??""),G)}if(h)return;(V!==E||_)&&(_=!1,E=V,v.showRequestIdentityChanged());const q=r(),je=`${V}|${q?.get().docId??""}|${be(n)}`;je!==m&&q?.isReady()===!0&&(m=je,v.selfInitChanged()),v.saasChanged(),X()};let L=!1,I="",O="",k=!1,ee=!1;const ce=x=>{x.source==="user"?ee=!0:(r()?.isReady()===!1||t.forcedHeaders()!==void 0)&&(k=!0),N()},X=()=>{const x=i();if(!x?.renderGuid)return;const V=M.channel.readContent(),G=JSON.stringify([x.preheader,x.common_styles,x.meta,x.subject,x.utm_parameters?.utm_campaign??"",x.utm_parameters?.utm_content??"",x.utm_parameters?.utm_medium??"",x.utm_parameters?.utm_source??"",x.utm_parameters?.utm_term??""]),q=L&&V!==O,je=L&&G!==I;L=!0,O=V,I=G;const Be=k&&!ee;if(k=!1,ee=!1,M.isEventsLocked()||Be)return;const De={...x,id:s.isTemplate||x.isNew?void 0:x.id,html:V};if(q){fe(e,j.ON_CONTENT_CHANGED_ID).fire(V),fe(e,j.ON_EMAIL_CHANGED_ID).fire(De);return}je&&x.is_inited&&fe(e,j.ON_EMAIL_CHANGED_ID).fire(De)};let J=!1;const N=()=>{J||(J=!0,queueMicrotask(()=>{J=!1,D()}))};e.inject(ei,{pipeline:M,setRoute:x=>{x.emailId===s.emailId&&!!x.isTemplate==!!s.isTemplate||(s=x,N())}});let H,W;const z=()=>{const x=r()?.get().docId;x!==W&&(H?.(),W=x,H=r()?.subscribe(ce)),N()};let ne,Re;const st=()=>{const x=e.getInstance(Ae);!x||x===ne||(Re?.(),ne=x,Re=x.onShowRequested(V=>v.showRequested(V)))},Fe=n.addListener(x=>{x.data?.operation===$.SANDBOX_RESIZED&&T.notify()}),Pe=t.subscribe(z),Ut=er(n,N);z(),e.getInstance(U)?.addDispose(()=>{c?.dispose(),Re?.(),Ut(),Pe(),H?.(),Fe.dispose(),T.cancel(),M.stop()})}function mh(){return $l!=="useblocks"}var ma={config:{mode:"freeUserBlocks",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formButtonFieldReplacerEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!1,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},gh={config:{mode:"pro",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!0,styles:"",revisionService:!1,headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!0,commonStylesEnabled:!0,emailResponsiveControlEnabled:!0,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!0,annotationsEnabled:!0,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!0,formFieldBorderRadiusEnabled:!0,formFieldBoxShadowEnabled:!0,formFieldVisibilityEnabled:!0,formFieldExportAsPictureEnabled:!0,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!0,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!0,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!0,formImageFieldReplacerEnabled:!0,formImageFieldHeightEnabled:!0,formTextFieldTypografEnabled:!0,formTextFieldReplacerEnabled:!0,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!0,elementAIimageEnabled:!0,elementAItextEnabled:!0,elementCarouselEnabled:!0,elementAccordionEnabled:!0,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!0,formFieldAmpVisibilityEnabled:!0,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0,enableCopyFile:!0}},project:void 0,page:{isNew:!0,type:"email",project:0,id:"",showToken:0}},qi=ma,vh=["freeUserBlocks","blocks"],lr={};function bh(e){lr=e}var ga=e=>vh.includes(e)?qi:lr[e]??lr.editor??qi,cr={config:{mode:"simple",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!0,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!0,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!1,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!0,emailDropdownMenuClone:!0,emailDropdownMenuImport:!0,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportZipEnabled:!0,exportTextEnabled:!0,exportMarkdownEnabled:!0,exportClipboardEnabled:!0,exportWebHookEnabled:!0,exportOutlookEnabled:!1,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!0,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!0,aiAssistentEnabled:!0,optimizeEnabled:!0,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!0,tagsEnabled:!0,isTemplateEnabled:!0,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!0,deleteButtonEnabled:!0,toggleSidePanel:!0,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!0,formFieldImageTitleEnabled:!0,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!0,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!0,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!0,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!0,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!1,elementCountdownEnabled:!1,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4,fileManager:{defaultFolderName:"",enableMoveFolder:!0,enableEdit:!0,enableTrash:!0}},project:void 0},yh={config:{mode:"editor",autosaveTimeout:5e3,autosaveRetryMaxAttempts:5,autosaveRetryIntervalMs:3e4,theme:"",themes:{},mergeTagsShow:!1,styles:"",headerShow:!0,headerTitleVisible:!0,headerPreheaderVisible:!0,headerArrowBackVisible:!0,historyEnabled:!0,codeEnabled:!1,codeSideEnabled:!0,previewIconEnabled:!0,previewModeEnabled:!0,livePreviewEnabled:!0,sendTestEnabled:!0,sharePreviewEnabled:!1,webversionEnabled:!1,commonStylesEnabled:!1,emailResponsiveControlEnabled:!1,templateNotEmAlertShow:!1,beeFreeConverterEnabled:!0,stripoConverterEnabled:!0,aiLayoutConverterEnabled:!1,emailDropdownMenuEnabled:!1,emailDropdownMenuClone:!0,emailDropdownMenuImport:!1,emailDropdownMenuImportButton:!1,emailDropdownMenuConvert:!0,emailDropdownMenuLock:!0,emailDropdownMenuRemove:!0,emailExportEnabled:!0,exportHtmlEnabled:!0,exportTextEnabled:!1,exportMarkdownEnabled:!1,exportZipEnabled:!0,exportClipboardEnabled:!1,exportWebHookEnabled:!1,exportOutlookEnabled:!0,exportPdfEnabled:!0,exportPngEnabled:!0,nextButtonEnabled:!1,nextButtonText:"",saveButtonEnabled:!0,saveButtonText:"",commandButtonsEnabled:!0,emailIdShow:!1,sidePanelFloating:!0,desktopMobileSwitchRule:!0,desktopMobileSwitchPanel:!1,onlyCodeModeInMobile:!1,pathEnabled:!0,copyPasteEnabled:!1,saveBlockEnabled:!0,globalBlockCheckboxEnabled:!0,editImageControlEnabled:!0,lockEditor:!1,lockPreheaderAndTitle:!1,disableSideMenu:!1,menuDirection:"right",defaultBuildPanel:"",commentsEnabled:!1,aiAssistentEnabled:!1,optimizeEnabled:!1,optimizeLinksEnabled:!0,optimizeImagesEnabled:!0,optimizeSpamAssassinEnabled:!0,optimizeCheckCodeEnabled:!0,settingsEnabled:!0,settingsTabEnabled:!0,UTMEnabled:!1,annotationsEnabled:!1,subjectEnabled:!0,preheaderEnabled:!0,descriptionEnabled:!1,tagsEnabled:!0,isTemplateEnabled:!1,switchDesktopMobilePropsEnabled:!0,stepToOtherElementEnabled:!1,deleteButtonEnabled:!0,toggleSidePanel:!1,blocksSectionsShow:!0,blocksEmptyEnabled:!0,blocksSavedEnabled:!0,blocksCommonEnabled:!0,blocksTemplateEnabled:!0,blocksSearchEnabled:!0,blocksAddPanelEnabled:!0,imagePathDropdownEnabled:!1,formFieldImageTitleEnabled:!1,formFieldBorderEnabled:!1,formFieldBorderRadiusEnabled:!1,formFieldBoxShadowEnabled:!1,formFieldVisibilityEnabled:!1,formFieldExportAsPictureEnabled:!1,emailPaneDesktopSize:0,formButtonFieldInsertImageEnabled:!1,formButtonFieldVerticalAlignEnabled:!0,formButtonFieldTextAlignEnabled:!1,formButtonFieldBackgroundImageEnabled:!0,formButtonFieldPaddingsEnabled:!1,formButtonFieldReplacerEnabled:!1,formCellFieldVerticalAlignEnabled:!1,formCellFieldBackgroundImageEnabled:!0,formCellFieldPaddingsEnabled:!0,formCellFieldSizeEnabled:!1,formLinkFieldInsertImageEnabled:!0,formTableFieldBackgroundImageEnabled:!0,formDivFieldBackgroundImageEnabled:!0,formImageFieldVerticalAlignEnabled:!1,formImageFieldReplacerEnabled:!1,formImageFieldHeightEnabled:!1,formTextFieldTypografEnabled:!1,formTextFieldReplacerEnabled:!1,formEmailFieldBackgroundImageEnabled:!0,elementImageEnabled:!0,elementTextEnabled:!0,elementHeaderEnabled:!0,elementButtonEnabled:!0,elementListULEnabled:!0,elementListOLEnabled:!0,elementDividerEnabled:!0,elementSpacerEnabled:!0,elementSocialEnabled:!0,elementTableEnabled:!0,elementCountdownEnabled:!0,elementVideoEnabled:!1,elementAIimageEnabled:!0,elementAItextEnabled:!1,elementCarouselEnabled:!1,elementAccordionEnabled:!1,elementFormEnabled:!1,preventSendDataToEM:!1,imageInfoToolUrl:"",resourceProxy:void 0,resourceProxyPolicy:void 0,imageCenterFileManagerView:!0,imageCenterLocalUploadEnabled:!0,imageCenterStockEnabled:!0,imageCenterGifEnabled:!0,imageCenterIconStockEnabled:!0,imageCenterEditorEnabled:!0,compressMaxSize:1,compressMaxWidthOrHeight:2e3,ampExportEnabled:!1,formFieldAmpVisibilityEnabled:!1,testEmails:[],pushToGTM:!0,activeNextButton:!0,iconStrokeWidth:1.4},project:void 0},Eh={...cr,config:{...cr.config,imageCenterFileManagerView:!1}};bh({pro:gh,editor:yh,simple:mh()?cr:Eh,blocks:ma});var va=F("CodeMode");function ba(){let e;try{const t=window.localStorage?.getItem(Mt.em_code_mode_settings);e=t?JSON.parse(t):void 0}catch{e=void 0}return{isCodeMode:!!(e?.isCodeMode||e?.isCodeMode===void 0),direction:e?.codeModeDirection||"left"}}function _h(e){try{window.localStorage?.setItem(Mt.em_code_mode_settings,JSON.stringify({isCodeMode:e.isCodeMode,codeModeDirection:e.direction}))}catch{}}function ya(e){return e.getOrCreateInstance(va,()=>{const t=Ee(ba());return t.watch(_h),t})}function Ea(e){return e?.getInstance(va)?.get()??ba()}function dr(e,t){const n=ya(e);n.get().isCodeMode!==t&&n.set({...n.get(),isCodeMode:t})}function wh(e,t){const n=ya(e);n.set({...n.get(),direction:t})}function Sh(e,t,n=e.getInstance(oe)){n?.setMode(t),n?.get()?.codeEnabled===!1&&Ea(e).isCodeMode&&dr(e,!1)}function Ih(e){e.getInstance(Hl)||e.inject(Te,void 0)}function gn(e){return String(e.standaloneKey||"").trim()||void 0}function Ch(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function ti(e){return Ch(e)?!!gn(e):!1}function Lt(e){return!!gn(e)&&!ti(e)}var Th=["backendProxy","backendProxyPolicy","resourceProxy","resourceProxyPolicy"];function zi(e){return e==="server"?"serverSide":e}function Ah({env:e,base:t={},budgetMs:n}){const r={base:t,profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}},i=Ee();let o={kind:"pending"},s;const a=new Promise(y=>{s=y}),c=n===void 0?void 0:setTimeout(()=>{f({kind:"absent",reason:`серверный слой не пришёл за ${n} мс`})},n);function d(){o.kind!=="pending"&&i.set(An(r,e))}function f(y){if(o.kind!=="pending")return;clearTimeout(c),o=y;const b=An(r,e);i.set(b),s(b)}function h(y,b){r[zi(y)]=b,y==="server"&&o.kind==="pending"?f({kind:"applied"}):d()}return{watch:y=>i.watch(y),select:y=>i.select(y),get:()=>i.get(),ready:()=>a,state:()=>o,layers:()=>({...r}),bootstrap(){const y=An(r,e);return Object.fromEntries(Th.map(b=>[b,y[b]]))},merge(y,b){h(b,{...r[zi(b)],...y})},replace(y,b){h(b,y)},setMode(y){r.user={...r.user,mode:y},d()},setAdvancedConfigs(y){r.advancedConfigs=y,d()},serverAbsent(y){f({kind:"absent",reason:y})},applyServerResponse(y){o.kind==="pending"&&h("server",{...r.serverSide,...y})},dispose(){clearTimeout(c)}}}var Rh=5e3,Ph="blocks";function Dh(){return{...ga(Ph)?.config,mergeTags:void 0}}function Oh(e,t){e.getInstance(se)?.watch(n=>{t.setAdvancedConfigs({...n.advancedConfigs,...n.config?.advancedConfigs}),t.replace(n.config??{},"user")})}function xh(e,t){let n;Wr(e).watch(({profile:r})=>{const i=`${r?.theme??""}|${r?.locale??""}`;if(i===n)return;n=i;const o={};r?.theme&&(o.theme=r.theme),r?.locale&&(o.locale=r.locale),t.replace(o,"profile")})}function Mh(e){if(!(!e||typeof e!="string"))return e==="simple"?"pro":e}function kh(e,t){let n,r=!1,i;const o=a=>{i??=mn(t.layers(),localStorage.getItem("configSwither")||void 0),t.get()?.mode!==a&&Sh(e,a,t)},s=Wr(e).watch(({profile:a})=>{const c=a?.email_builder_config,d=Mh(c);if(d===void 0||c===n)return;const f=n===void 0;n=c,!(f&&r)&&o(d)});e.getInstance(U)?.addDisposable(s),t.ready().then(a=>{if(!a.configSwither)return;const c=localStorage.getItem("configSwither")||(n===void 0?a.mode:i)||"editor";localStorage.setItem("configSwither",c),r=n===void 0,o(c)})}var Wi="замкнутый контур: app_init не выполняется";function Lh(e,t){if(e.getInstance(Te)){t.serverAbsent(Wi);return}const n=e.getInstance(se)?.watch(r=>{Lt(r)&&t.serverAbsent(Wi)});n&&e.getInstance(U)?.addDisposable(n)}async function Nh(e,t){if(e.getInstance(Nr)===void 0){t.serverAbsent("app_init не зарегистрирован");return}try{const n=await e.getInstanceAsync(xe);t.applyServerResponse(n?.app_config??{})}catch(n){t.serverAbsent(`app_init не выполнился: ${String(n)}`)}}function Fh(e){e.injectFactory(oe,(t,n)=>{if(n)return n;const r=Ah({base:Dh(),env:{modeDefaults:i=>ga(i)?.config||{},fallbackMode:localStorage.getItem("configSwither")||void 0},budgetMs:Rh});return Oh(e,r),xh(e,r),kh(e,r),Lh(e,r),Nh(e,r),e.getInstance(U)?.addDisposable(r),r},!0)}var et=class extends ie{_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 B(e,t,n){const r=El(e);return(i,o,s)=>{const a=r(async c=>{const d=t?t(c):c;s&&i.bind(s);const f=await i(d);return n?n(f):f},o,s);return()=>a.dispose()}}var jh=class{deps;handleDestroy;constructor(e){this.deps=e;const t=new Yn;this.handleDestroy=B(t.event),e.lifetime.addDispose(()=>t.fire(e.getInstance()));const n=e.lifetime.addDisposable(new et(this.handleDestroy));e.lifetime.addDisposable(t),e.lifetime.addDisposable(e.options.watch(({handleDestroy:r})=>n.setListener(r))),e.lifetime.addDispose(()=>e.release())}destroy(){if(!this.deps.lifetime.isDisposed())try{this.deps.lifetime.dispose()}catch{}}},ni=F("DestroyableService");function Bh(e){e.injectFactory(ni,(t,n)=>{if(n)return n;const r=e.getInstance(U);if(!r)throw new Error("[plugin] время жизни экземпляра не зарегистрировано");return new jh({lifetime:r,options:e.getInstance(se),getInstance:()=>e.getInstance(hn),release:()=>Al(e.getInstance(Gl)??e)})},!0)}function Uh(e){const t=e.getInstance(ni);if(!t)throw new Error("[plugin] provideDestroyable не выполнен до сборки поверхности");return{handleDestroy:t.handleDestroy,destroy:()=>t.destroy()}}var Hh=1e3;function _a(e,t,n=Hh,r=0){if(r>n||e===t)return!0;if(typeof e!=typeof t||e===null||t===null)return!1;if(typeof e=="object"&&typeof t=="object"){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const i=Object.keys(e),o=Object.keys(t);if(i.length!==o.length)return!1;for(const s of i)if(!_a(e[s],t[s],n,r+1))return!1;return!0}return!1}function Et(e,t){if(!e||typeof e!="object")return t;if(!t||typeof t!="object")return{};const n={};for(const r of Object.keys(t)){const i=t[r],o=e[r];_a(i,o)||(n[r]=i)}return n}var $h=({source:e,emailtags:t,group:n,tags:r,...i})=>i;async function Gh(e,t){try{return{id:(await t(await e)).id}}catch{return}}async function Vh({emails:e,saveTimeoutMs:t},n,r){const i=t?.()??Br();let o;try{const s=e.notifySave(n);return await Promise.race([s,new Promise((a,c)=>{o=setTimeout(()=>{const d=new Ur(i);n.value.id,md(d,Gh(s,r)),c(d)},i)})])}catch(s){throw gs(s),s}finally{o!==void 0&&clearTimeout(o)}}function qh(e){const{emails:t}=e,n=async(r,i)=>{const o=$h(i),s=r===void 0?void 0:await t.cache.getIfPresent(r),a=s?{...s,...o}:o,c=s?Et(s,o):o,d=f=>{const h=String(f.id??r??Se()),y=f.id===void 0?{...f,id:h}:f;return t.cache.addOrUpdate(h,()=>y)};return await d(await Vh(e,{prev:s,patch:c,value:a,source:i.source??""},d))};return{async readEmail(r){return await t.get(r)??null},async createEmail(r){const i=await n(void 0,r);return i?.renderGuid?i:{...i,renderGuid:Se()}},async updateEmail(r,i){return await n(r,i)}}}var Dn=20;function zh(e){const t=Wh(e);return e.saveTimeoutMs?Kh(t,e.saveTimeoutMs):t}function Wh({revisions:e,revisionsByEmail:t,readAutosave:n,savedAt:r,emailAuthor:i,integratorProject:o}){const s=async(a,c)=>(t.clear(),await t.get(a,{page:c}),(await e.cache.values()??[]).filter(d=>String(d?.parent)===String(a)));return{async readRevisions(a,c=1){const d=await s(a,c);return{revisions:d.slice(Dn*(c-1),Dn*c),page:c,hasMore:d.length>Dn*c}},async readAutosave(a){const c=await r?.(a)??NaN,d=Number.isFinite(c)?c:void 0,f=await n?.(a);if(!f?.asked)return Id(await s(a,1),d);if(!f.revision)return Ai([],d);const h={...f.revision,parent:a,isAutosave:!0};return Ai([h],d,await s(a,1))},async saveAutosave(a,c){const d=await i?.(a),f=o?.();return await e.create({...Dd(c),...d!==void 0?{author:d}:{},...f!==void 0?{project:f}:{},parent:a,isAutosave:!0,modified:new Date().toString()})}}}function Kh(e,t){return{...e,async saveAutosave(n,r){const i=t();let o;try{return await Promise.race([e.saveAutosave(n,r),new Promise((s,a)=>{o=setTimeout(()=>a(new fs(i)),i)})])}catch(s){throw gs(s),s}finally{o!==void 0&&clearTimeout(o)}}}}var Yh=class extends kl{async execute([e],t){for(const n of t){const r=await n(e);r&&(r.id===void 0&&(r.id=e.value.id),e.value=r)}return e.value}},Xh=class extends Me{};var Ki=class extends ie{_items=new Map;_onChangeEmitter=new oc;async _getOrCreate(e,t){const n=this._items;let r;if(n.has(e))try{r=await n.get(e)}catch{t&&(r=await t())}else t&&(r=await t(),r&&this._onChangeEmitter.fire());return r}async _addOrUpdate(e,t){let n;const r=this._items;if(r.has(e))try{n=await r.get(e)}catch{}const i=await t(n);return Ce(n,i)||this._onChangeEmitter.fire(),i}entries(){return Promise.all([...this._items.entries()].map(([e,t])=>t.then(n=>[e,n]))).then(e=>e.filter(([t,n])=>!!n))}values(){return Promise.all([...this._items.values()].map(e=>e).filter(e=>!!e))}getOrCreate(e,t){const n=this._getOrCreate(e,()=>t(e));return this._items.set(e,n),n}addOrUpdate(e,t){const n=this._addOrUpdate(e,t);return this._items.set(e,n),n}async getIfPresent(e){if(this._items.has(e))try{return await this._items.get(e)}catch{return}}add(e,t){const n=Promise.resolve(t);return this._items.set(e,n),n}remove(e){if(this._items.has(e)){const t=this._items.get(e);return this._items.delete(e),this._onChangeEmitter.fire(),t}return Promise.resolve(void 0)}async setAll(e){try{this.suspendChange();const t=[],n=new Set(Array.from(e).map(([i,o])=>i)),r=(await this.entries()).filter(([i,o])=>!n.has(i));for(const[i,o]of e)t.push(this.addOrUpdate(i,()=>o)),n.add(i);for(const[i]of r)t.push(this.remove(i));return await Promise.all(t),r}finally{this.resumeChange()}}clear(){this._items.clear(),this._onChangeEmitter.fire()}suspendChange(){this._onChangeEmitter.suspend()}resumeChange(){this._onChangeEmitter.resume()}onChange=this._onChangeEmitter.event};function Jh(e,{filter:t,order:n="asc",orderBy:r,page:i,pageSize:o=20}={}){const s=e.length;let a=e.length;if(t!==void 0){const c=Object.keys(t);e=e.filter(d=>{for(const f of c){const h=d[f],y=t[f];return f==="id"||typeof h!="string"?h===y:typeof y=="string"&&h.startsWith(y)}return!0}),a=e.length}return r&&(e=e.sort((c,d)=>(c[r]>d[r]?1:d[r]>c[r]?-1:0)*(n==="asc"?1:-1))),i!==void 0&&(e=e.slice(o*(i-1),o*i)),{data:e,filteredTotal:a,total:s,totalPages:Math.ceil(a/o)}}function Qh(e=[]){if(e=e.filter(n=>n),e.length<=1)return e[0];const t=new Map;for(const n of e)for(const r of n)if(r.id!==void 0){const i=t.get(r.id)||{};t.set(r.id,{...i,...r})}return[...t].map(([n,r])=>r)}function Zh(e,t){return Yi(e)&&Yi(t)?String(e)===String(t):e===t}function Yi(e){return typeof e=="string"||typeof e=="number"}var em=class extends ie{_cache=new Ki;_readEmitter=new Me;_saveEmitter=this.addDisposable(new Yh);_removeEmitter=this.addDisposable(new Xh);_foreignCache=Object.create(null);async get(e){return this._cache.getOrCreate(e,async t=>Object.assign({id:e},...(await this._readEmitter.fire(e)).filter(n=>!!n)))}get cache(){return this._cache}byForeignKey(e){let t=this._foreignCache[e];if(!t){const n=this.addDisposable(new ie);n.addDispose(()=>delete this._foreignCache[e]);const r=n.addDisposable(new Ki),i=n.addDisposable(new Me);t=this._foreignCache[e]={get:async(o,s={})=>{await r.getOrCreate(o,async()=>{try{const c=Qh(await i.fire(o))||[];for(const d of c)d[e]=o,await this._cache.add(d.id,d);return c}catch{return[]}});const a=(await this._cache.values()||[]).filter(c=>{const d=c[e];return d==null||Zh(d,o)});return Jh(a,s)},first(o,s={}){return t.get(o,{...s,page:1,pageSize:1}).then(({data:a})=>a[0])},handleRead:i.event,clear(){r.clear()},dispose(){n.dispose()}}}return t}async create(e,{source:t="",silent:n}={}){let r=e;return n||(r=await this._saveEmitter.fire({prev:void 0,patch:e,value:r,source:t})),r.id===void 0&&(r.id=Se()),await this._cache.addOrUpdate(r.id,()=>r)}notifySave(e){return this._saveEmitter.fire(e)}async update(e,t,{source:n="",silent:r}={}){return this._cache.addOrUpdate(e,async i=>{const o=i?{...i,...t}:t;if(!r)return t=i?Et(i,t):t,await this._saveEmitter.fire({prev:i,patch:t,value:o,source:n})})}async remove(e,{source:t="",silent:n}={}){const r=await this._cache.remove(e);return n||await this._removeEmitter.fire({value:r,source:t}),r}refresh(){this._cache.clear();for(const e of Object.values(this._foreignCache))e.clear()}suspendChange(){this._cache.suspendChange()}resumeChange(){this._cache.resumeChange()}handlerRead=this._readEmitter.event;onSave=this._saveEmitter.event;onRemove=this._removeEmitter.event;onChange=this._cache.onChange};function Nt(e){const t=F(e);return n=>n.getOrCreateInstance(t,()=>new em)}function wa(e){const t=e.getInstance(U);if(!t)throw new Error("Failed");return t}function Xi(e){return Object.prototype.hasOwnProperty.call(e,"meta")}function On(e,t){const n={...e};return t===void 0?(delete n.meta,n):(n.meta={...e.meta??{},...t},n)}function tm(e,t,n){return e&&!Xi(t)&&Xi(e)?{...n,meta:e.meta}:n}var nm=F("CurrentProject"),rm={};function Ft(e){return e?.getInstance(nm)?.get()??rm}function ri(e){const t=Ft(e).card?.id,n=Number(t);return t!=null&&t!==""&&Number.isFinite(n)?n:void 0}var Sa=Nt("plugin.dataSource.emails"),Ia=Nt("plugin.dataSource.emailRevisions"),Ca=Qr("plugin.readEmailAutosave"),Ji=F("emailDocuments.provided");function im(e){const t=Sa(e),n=Ia(e),r=n.byForeignKey("parent");if(e.getInstance(Ji))return{emails:t,emailRevisions:n};e.inject(Ji,!0);const i=()=>Br(e.getInstance(Ae)?.contentReadyTimeoutMs),o=qh({emails:t,saveTimeoutMs:i}),s=new Map,a=(c,d)=>f=>{const h=f?.id??d;return(typeof h=="string"||typeof h=="number")&&s.set(String(h),c),f};return tu(e,{...o,createEmail:c=>o.createEmail(c).then(a(Date.now())),updateEmail:(c,d)=>o.updateEmail(c,d).then(a(Date.now(),c))}),ou(e,zh({revisions:n,revisionsByEmail:r,readAutosave:async c=>{const d=await fe(e,Ca).fire(c);return d.length===0?{asked:!1}:{asked:!0,revision:d[0]??null}},savedAt:async c=>{const d=wd((await t.cache.getIfPresent(c))?.modified),f=s.get(String(c))??NaN;return Number.isFinite(f)&&!(d>=f)?f:d},emailAuthor:async c=>(await t.cache.getIfPresent(c))?.author,saveTimeoutMs:i,integratorProject:()=>Ft(e).requested})),wa(e).addDisposable(t.onSave(({prev:c,patch:d,value:f})=>tm(c,d,f),Number.MIN_VALUE)),{emails:t,emailRevisions:n}}function Qi(e,t){return!e?.data||!t||e.id!==t.locale?!1:t.contentHash?e.hash===t.contentHash:t.updatedAt>0&&t.updatedAt<=e.time}function om(e){try{return localStorage.getItem(e)===null?!1:(localStorage.removeItem(e),!0)}catch{return!1}}var sm="po",Kt=null;function am(){const e=typeof window.__useblocks__<"u"?window.__useblocks__?.require:void 0;return typeof e!="function"?Promise.reject(new Error("[loadPoParser] AMD loader is unavailable")):new Promise((t,n)=>{e([sm],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadPoParser] Failed to require po module")))})}function lm(){return Kt===null&&(Kt=am().catch(e=>{throw Kt=null,e})),Kt}async function Ta(e){if(typeof e=="object")return ii(e);if(typeof e!="string")return;const t=e.trim();if(t)return t.startsWith("{")||t.startsWith("[")?cm(t):dm(t)}function ii(e){if(!(e==null||typeof e!="object"||Array.isArray(e)))return e}function cm(e){try{return ii(JSON.parse(e))}catch{return}}var Zi=!1;async function dm(e){try{return ii((await lm()).parsePoCatalog(e))}catch{Zi||(Zi=!0);return}}var um="em_locale",fm="em_ant_locale",pm="locale",hm="ant_locale";function oi(e){try{return JSON.parse(localStorage.getItem(e)||"")}catch{return null}}function Aa(e,t){const n=oi(e);if(!n)return null;try{localStorage.removeItem(e),localStorage.setItem(t,JSON.stringify(n))}catch{}return n}function mm(){return oi("em_locale")??Aa(pm,"em_locale")}function eo(e){try{localStorage.setItem(um,JSON.stringify(e))}catch{}}function gm(){return oi("em_ant_locale")??Aa(hm,"em_ant_locale")}function vm(e,t){try{localStorage.setItem(fm,JSON.stringify({id:e,data:t}))}catch{}}var bm=8e3;function ym(e,t){const n=e,r=t,i=Object.keys(n).filter(o=>o!=="");return i.length!==Object.keys(r).filter(o=>o!=="").length?!1:i.every(o=>JSON.stringify(n[o])===JSON.stringify(r[o]))}function Em(e){const t=mm(),n=gm();let r={ready:!1},i;const o=Ee(r);let s=0;const a=g=>{r={...r,...g},o.set(r)},c=()=>{r.ready||a({ready:!0})},d=setTimeout(c,e.unlockAfterMs??bm),f=g=>g!==s;let h;async function y(g,C){if(n?.id===g&&n.data&&a({antd:n.data}),!h)return;const _=await h(g).catch(()=>{});!_||f(C)||(a({antd:_}),vm(g,_))}async function b(g,C){const _=await e.askHost(g).catch(()=>null);if(f(C))return!0;if(_==null)return!1;const P=await Ta(_);return f(C)||(P&&a({catalog:P}),c()),!0}async function T(g,C){const _=await e.readList();if(f(C))return;if("error"in _){a({failure:{kind:"GET_LOCALES_ERROR",error:_.error}}),c();return}const P=_.data.find(M=>M.locale===g);if(!P){om("em_locale")&&a({catalog:void 0}),c();return}if(Qi(t,P)&&(!i||i.catalog===t?.data)){c();return}if(i?.entry&&r.catalog===i.catalog&&Qi(i.entry,P)){eo(i.entry),c();return}const S=await e.readCatalog(g);if(!f(C)){if("error"in S){a({failure:{kind:"GET_LOCALE_ERROR",error:S.error}}),c();return}S.data&&(i?.id===g&&r.catalog===i.catalog&&ym(i.catalog,S.data)||a({catalog:S.data}),eo({id:g,time:P.updatedAt||Math.floor(Date.now()/1e3),hash:P.contentHash,data:S.data})),c()}}async function w(g,C){if(!await b(g,C)){if(!f(C)&&(i?.id===g&&r.catalog===i.catalog||g==="en_US")&&c(),e.canUseNetwork&&!e.canUseNetwork()){c();return}await T(g,C)}}return{set(g){if(!g||g===r.id)return;const C=s+=1;a({id:g,failure:void 0});const _=i?.id===g&&r.catalog===i.catalog;(i&&!_&&r.catalog===i.catalog||g==="en_US"&&r.catalog)&&a({catalog:void 0}),t?.id===g&&t.data&&(a({catalog:t.data}),c()),y(g,C),w(g,C)},prime(g,C,_){r.id&&r.id!==g||r.catalog||!C||(i=t?.id===g&&t.data&&(!_||t.time>=_.time)?{id:g,catalog:t.data}:{id:g,catalog:C,entry:_?{id:g,time:_.time,hash:_.hash,data:C}:void 0},a({catalog:i.catalog}))},useAntdLoader(g){h=g,r.id&&y(r.id,s)},state:o,snapshot:()=>r,dispose:()=>clearTimeout(d)}}var _m=class{http;constructor(e){this.http=e}jsonList=({locale:e},t={})=>this.http.request({path:`/translations/${e}.json`,method:"GET",format:"json",...t});getTranslations=({locale:e},t={})=>this.http.request({path:`/translations/${e}.po`,method:"GET",...t});localesList=(e={})=>this.http.request({path:"/translations/locales",method:"GET",format:"json",...e})},wm=class{baseUrl="/api/v2";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...e)=>fetch(...e);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(e={}){Object.assign(this,e)}setSecurityData=e=>{this.securityData=e};encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent(typeof t=="number"?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map(n=>this.encodeQueryParam(t,n)).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter(n=>typeof t[n]<"u").map(n=>Array.isArray(t[n])?this.addArrayQueryParam(t,n):this.addQueryParam(t,n)).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}contentFormatters={"application/json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"application/vnd.api+json":e=>e!==null&&(typeof e=="object"||typeof e=="string")?JSON.stringify(e):e,"text/plain":e=>e!==null&&typeof e!="string"?JSON.stringify(e):e,"multipart/form-data":e=>e instanceof FormData?e:Object.keys(e||{}).reduce((t,n)=>{const r=e[n];return t.append(n,r instanceof Blob?r:typeof r=="object"&&r!==null?JSON.stringify(r):`${r}`),t},new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)};mergeRequestParams(e,t){return{...this.baseApiParams,...e,...t||{},headers:{...this.baseApiParams.headers||{},...e.headers||{},...t&&t.headers||{}}}}createAbortSignal=e=>{if(this.abortControllers.has(e)){const n=this.abortControllers.get(e);return n?n.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal};abortRequest=e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))};request=async({body:e,secure:t,path:n,type:r,query:i,format:o,baseUrl:s,cancelToken:a,...c})=>{const d=(typeof t=="boolean"?t:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{},f=this.mergeRequestParams(c,d),h=i&&this.toQueryString(i),y=this.contentFormatters[r||"application/json"],b=o||f.format;return this.customFetch(`${s||this.baseUrl||""}${n}${h?`?${h}`:""}`,{...f,headers:{...f.headers||{},...r&&r!=="multipart/form-data"?{"Content-Type":r}:{}},signal:(a?this.createAbortSignal(a):f.signal)||null,body:typeof e>"u"||e===null?null:y(e)}).then(async T=>{const w=T;w.data=null,w.error=null;const g=b?T.clone():T,C=b?await g[b]().then(_=>(w.ok?w.data=_:w.error=_,w)).catch(_=>(w.error=_,w)):w;return a&&this.abortControllers.delete(a),C})}},Sm=F("rest.v2.transport"),to=Symbol("rest.v2.secureRequest");function Im(e){return e.getOrCreateInstance(Sm,()=>{const t=e.getInstance(Pl)?.execute||fetch;return new wm({baseUrl:"https://app.useblocks.io/api/v2",securityWorker:()=>({[to]:!0}),customFetch:(n,r={})=>{const{[to]:i,...o}=r;return t(n,{...o,[Ol]:i!==!0})}})})}function Cm(e,t){const n=Im(e);return Object.assign({},...t.map(r=>new r(n)))}function no(e,t){if(e!=null&&typeof e=="object"){const n=e[t];if(typeof n=="string"&&n!=="")return n}}function Ra(e){const t=e.error,n=t?.error;return n&&typeof n=="object"?{status:e.status,data:{code:no(n.details,"wp_code")??n.code,message:no(n.details,"wp_message")??n.message,details:n.details}}:t&&typeof t=="object"?{status:e.status,data:t}:{status:e.status,data:{message:e.statusText||"request failed"}}}function Pa(e){return!e.ok||!!e.error}function Tm(e){try{const t=localStorage.getItem(e);if(t==="true")return!0;if(t==="false")return!1}catch{}}function Da(){return Tm(Mt.em_translations_v2)??!0}function Am(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function Rm(e){const t=e?Date.parse(e):NaN;return Number.isNaN(t)?0:Math.floor(t/1e3)}function Pm(e){return Array.isArray(e)?e.reduce((t,n)=>{const r=Array.isArray(n)?n:[],i=r[0];return typeof i=="string"&&i!==""&&t.push({locale:i,updatedAt:Am(r[1])}),t},[]):[]}function Dm(e){return(e?.items??[]).reduce((t,n)=>(n.locale&&t.push({locale:n.locale,updatedAt:Rm(n.updated_at),contentHash:n.content_hash}),t),[])}function Oa(e){return Cm(e,[_m])}function cn(e){return{error:{status:"FETCH_ERROR",error:e instanceof Error?e.message:"locale request failed"}}}function ur(e){return!e.ok||e.error!=null}function fr(e){const t=e.error;return{error:{status:e.status,data:t?.data??e.error}}}async function xn(e){return{data:await Ta(e)??null}}async function Om(e){if(Da())try{const n=await Oa(e).localesList();return Pa(n)?{error:Ra(n)}:{data:Dm(n.data)}}catch(n){return cn(n)}const t=qo(e,[es]);try{const n=await t.get_translations2({file:"react_app"});return ur(n)?fr(n):{data:Pm(n.data)}}catch(n){return cn(n)}}async function xm(e,t){if(Da())try{const r=await Oa(e).jsonList({locale:t});return Pa(r)?{error:Ra(r)}:xn(r.data)}catch(r){return cn(r)}const n=qo(e,[es]);try{const r=await n.get_translations3({id:t,file:"react_app"});return ur(r)?fr(r):xn(r.data)}catch{try{const r=await n.get_translations3({id:"en_US",file:"react_app"});return ur(r)?fr(r):xn(r.data)}catch(r){return cn(r)}}}var Yt=new WeakMap;function Mm(e){const t=Yt.get(e);if(t!==void 0)return t;const n=Om(e).then(r=>("error"in r&&Yt.delete(e),r),r=>{throw Yt.delete(e),r});return Yt.set(e,n),n}var Tt=F("locale.service");function km(e){if(e.getInstance(Tt))return;const t=Em({readList:()=>Mm(e),readCatalog:n=>xm(e,n),askHost:async n=>(await fe(e,j.READ_LOCALE).fire(n))[0],canUseNetwork:()=>!e.getInstance(Te)});e.inject(Tt,t),e.getInstance(U)?.addDispose(()=>t.dispose())}function Lm(e){const t=e.getInstance(oe);if(!t)return;const n=e.getInstance(Tt);if(!n)return;const r=t.select(i=>i.locale).watch(i=>n.set(i||"en_US"));e.getInstance(U)?.addDisposable(r)}var Nm="user_id",Fm="project_id",ro=F("rest.identityHeadersProvided");function jm(e){if(e.getInstance(ro))return;e.inject(ro,!0);let t;e.getInstance(se)?.watch(n=>{t=n}),e.addService(Ar,{execute(n,r){if(r?.public)return;const i=t?.user?.id??Ms(e).profile?.id;i!=null&&i!==""&&n.headers.set(Nm,String(i));const o=t?.project;o!=null&&o!==""&&n.headers.set(Fm,String(o))}})}function Bm(e){if(!e)return!1;try{return e.getInstance(Te)!==void 0}catch{return!1}}var Um="Invalid standaloneKey.",DE=F("StandaloneMockGuard");function Hm(){const e=new Error(Um);return e.name="InvalidStandaloneKeyError",e}function $m(e){e.addService(Ar,{execute:()=>{if(Bm(e))throw Hm()}})}function Gm(e){Ml(e),$m(e)}function Vm(e){const t=new Qs;e.inject(Ae,t);const n=e.getInstance(se)?.watch(i=>{if(!i)return;const o=i.signal??t.externalSignal;t.configure({replaceSession:!0,...i.timeouts!==void 0?{timeouts:i.timeouts}:{},...o!==void 0?{signal:o}:{}})}),r=e.getInstance(U);n&&r?.addDisposable(n),r?.addDispose(()=>{t.abort()})}var qm=Nt("plugin.dataSource.blocks"),zm=Nt("plugin.dataSource.blockRevisions"),Wm=Nt("plugin.dataSource.comments"),Km=Qr(),Ym=Qr(),xa=`<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
1004
1005
|
<html>
|
|
1005
1006
|
<head>
|
|
1006
1007
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
@@ -1041,10 +1042,10 @@ import{t as Li}from"./static/esm/50fbfdf6.js";import{$ as xs,A as Ms,At as N,B a
|
|
|
1041
1042
|
</tr>
|
|
1042
1043
|
</table>
|
|
1043
1044
|
</body>
|
|
1044
|
-
</html>`;function
|
|
1045
|
+
</html>`;function Xm(e){return{isNew:!0,is_inited:!1,subject:void 0,preheader:void 0,description:"",html:xa,project:e?.id,project_title:e?.title??"",tags:[],utm_parameters:{utm_source:"",utm_medium:"",utm_campaign:"",utm_term:"",utm_content:""},parent_email:null,common_styles:"{}",title:"",emailtags:[],isAmp:!1}}var Ma=new Set(["email","block","blocks","autosaves","revisions","comments","templateId","reload"]);function Jm(e){return!Object.keys(e).some(t=>Ma.has(t))}function Qm(e){const t={},n={};for(const[r,i]of Object.entries(e))Ma.has(r)?t[r]=i:n[r]=i;return{showOptions:t,misplacedEmailFields:n}}function io(e){const t=e.id;if(!(t===null||typeof t=="string"&&t.trim()===""))return e;const n={...e};return delete n.id,n}function jt(e){return{emails:Sa(e),blocks:qm(e),emailRevisions:Ia(e),blocksRevision:zm(e),comments:Wm(e)}}function Zm(e){const t=Object.values(jt(e));return{suspendChange(){t.forEach(n=>n.suspendChange())},resumeChange(){t.forEach(n=>n.resumeChange())}}}function vn(e,t=!0){if(typeof e=="string")return{email:{code:e}};if(Jm(e))return{email:io(e)};{const{showOptions:n,misplacedEmailFields:r}=Qm(e),i=Object.keys(r);t&&i.length>0&&void 0;const o=typeof e.email=="string"?{code:e.email}:e.email;return{...n,email:io({...r,...o})}}}function si(e){return Kr(e)?.current()}function Zt(e){return si(e)?.getContent()}function ka(e,t){const n=t??Xm(),r=si(e)?.get();return r?{...n,...r.attributes,id:r.serverId??void 0,isNew:r.serverId===null,html:Zt(e)??n.html}:n}async function en(e){return(await e.getInstanceAsync(xe))?.project}async function eg(e){return ri(e)??await en(e)}function oo(e){if(!e)return;const t=vn(e,!1).email.id;return t==null?void 0:String(t)}function tg(e,t){return e.ticket===t.ticket?!1:e.emailId===void 0||e.emailId!==t.emailId}function ng(e){return typeof e=="object"&&e!==null&&"reload"in e&&e.reload===!0}function it({code:e,project:t,...n},r){const i=ke(n),o=ri(r),s=ze(r);return e&&s.warnAboutUnconfiguredInput(e,n.id),{...i,...e?{html:s.toEditorForm(e)}:{},...o===void 0?{}:{project:o},..."utm_parameters"in i?{utm_parameters:i.utm_parameters||{}}:{},_embedded:void 0}}function de({html:e,renderGuid:t,showToken:n,showId:r,...i},o){const{requested:s}=Ft(o),a=Ns(o);return ke({...i,code:ze(o).toOutputForm(e),project:s===void 0?i.project:s,utm_parameters:a.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})}function pr(e){return e==null?"":e.replaceAll(`\r
|
|
1045
1046
|
`,`
|
|
1046
|
-
`)}function ai(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function Ep(e,t,n,r){const i=_p(e,t,n,r);return i===void 0}function _p(e,t,n,r){const{email:i}=Bt(t,!1),o=je(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=nr(e)?.current();if(!a)return"no-session";const l=a.get(),u=l.attributes;if(l.serverId!==s)return"document-id";if(u.is_inited!==!0)return"not-inited";const m=ai(On(n??a.getContent()));if(o.html!==void 0&&ai(On(o.html))!==m)return"html";if(o.subject!==void 0&&o.subject!==u.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==u.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==u.common_styles)return"common_styles"}function li(e,t){const{email:n}=Bt(t,!1),r=je(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:On(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function wp(e,t){const n={...e};return delete n.id,{...n,...t}}function Sp(e){return e.html?e:{...e,html:ns}}function Ke({code:e,project:t,...n},r,i){const o=i??rs(r);return{...n,...e?{html:He(r).toEditorForm(e)}:{},renderGuid:fe(),...o===void 0?{}:{project:o}}}function vt({html:e,renderGuid:t,...n},r){const{requested:i}=Ft(r);return _e({...n,code:He(r).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 ss(e){return nr(e)?.current()?.get().serverId??void 0}function xn(e,t,n){return n===void 0&&(n=e.post===void 0?ss(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function bt(e,t){return _e({...e,link:void 0,comment_status:void 0})}function St({code:e,autosave:t,...n},r,i){return i===void 0&&(i=n.parent===void 0?ss(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0,parent:i}}function di({html:e,isAutosave:t,...n},r){return _e({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:_e({html:e,ampHtml:e&&""})})}var Mn=N("NotificationService"),Ip=N("emailTemplate.reads");async function Ap(e,t){try{return await Ae(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,Cp(e,t,n);return}}var Tp=N("emailTemplate.notifiedFailures");function Cp(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(Tp,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(Mn).then(()=>{Gn(e,G.ON_NOTIFICATION).fire({type:"error",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function Rp(e,t){const n=e.getOrCreateInstance(Ip,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=Ap(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var Pp="EXTERNAL";function Dp(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var Op="email_id",xp=class extends Q{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_dataSources;_eventLock;_queue=ga();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=jt(t),this._eventLock=gp(t);const n=W(e,G.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(qn,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(Op,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(pe)??ar}_throwIfDestroyed(){if(this.isDisposed())throw Vn()}async getTemplateEmail(e){const t=await Rp(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await Qt(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,Ke(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,St(i,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,xn(i,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,i){const o=this._dataSources.emails,s=o.cache,a=await Qt(this._container),l=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let u=je(e,this._container);const m=u.id;let v=m;if(m!==void 0){const E=await o.get(m);u={...E??{},...u,utm_parameters:u.utm_parameters??E?.utm_parameters??{},renderGuid:E?.renderGuid??fe(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:a}}else{v=n??fe();const E=await o.get(v);u={...u,utm_parameters:u.utm_parameters??{},renderGuid:E?.renderGuid??fe(),...l>0?{showToken:l}:{},...i?{showId:i}:{},project:a},delete u.project}if(t){const E=await this.getTemplateEmail(String(t));E&&(u=wp(E,u))}return m===void 0&&(u=Sp(u)),await s.addOrUpdate(v,()=>u),u}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==li(this._container,e))return!1;const n=wt(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=li(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:wt(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&bp({ticket:t,emailId:si(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId})){this._showRequests;return}if(!e)return;const n=this._getInitPipeline();z(n.signal);const r=yp(e);if(!r&&Ep(this._container,e,wt(this._container),this._prevCommand?.id)||!r&&this._isRepeatOfLastShow(e))return;const i=Bt(e);i.email.id,this._prevCommand?.id;let o,s="",a=0,l=!1,u,m=Promise.resolve(),v,E=!1;try{this._eventLock.suspendChange();const{email:g,blocks:_,autosaves:b,comments:y,templateId:S,reload:I}=i;o=g.id;const A=je(g,this._container),f=A.id,c=f??fe(),d=await Ye("getProject",Qt(this._container));z(n.signal),s=fe();const p={isNew:f===void 0,id:String(c),project:d},h=I===!0&&f!==void 0;h&&(await this._dataSources.emails.remove(String(f),{silent:!0}),String(f)),a=++this._showToken,String(c);const w=[];w.push(this.setBlocks(_)),g.id!==void 0&&(w.push(this.setComments(y)),w.push(this.setEmailRevisions(b,String(g.id)))),w.push(this.setEmail(g,Number(S),f===void 0?String(c):void 0,a,s)),await Ye("setEmail+blocks+revisions",Promise.all(w),{emailId:f??String(c),showId:s,targetShowToken:a}),z(n.signal);const T=await this._dataSources.emails.get(String(c)),D=we(this._container),L={id:s,token:a};f===void 0?v=D.startNewDraft(T??A,{patch:A,show:L}):h?v=D.reload(f,{email:T??A,patch:A,show:L}):D.sessionKey()===De(f)?v=D.show(A,L):v=D.open(f,{email:T??A,patch:A,show:L});const Y=!!this._prevCommand&&Ne(this._prevCommand,p);p.id,!this._prevCommand||Ne(this._prevCommand,p),this._prevCommand?.id,this._rememberShow(p),m=n.requestShow({showId:s,navId:String(c),emailId:f,isNew:f===void 0}),E=!0,String(c),l=!0}catch(g){u=g,E&&s&&n.failShow(s,g),Bi(g)||(to(g),void 0)}finally{this._eventLock.resumeChange()}if(!l)throw u instanceof Error?u:new Error(`[useblocks] show() setup failed: ${String(u??"unknown error")}`);return Ye("show-init-deferred",Promise.all([m,v?.whenReady().catch(g=>{if(g instanceof Tt){const _=co(g);throw _?new Error(`[useblocks] show(): email open failed (${_})`,{cause:g}):g}})??Promise.resolve()]).then(()=>{}),{showId:s,emailId:o??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();z(e.signal);const t=we(this._container),n=await t.save("publish",{source:Pp});if(z(e.signal),!n)throw Dp(t.saveState().error);return re(vp(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;return this._latestShowEmailId=si(e),this._queuedShow(e,t)};save=this._queue.decorate(this._save,this)};function Mp(e){return String(e).replace(/"/g,""")}function kp(e=new Date){const t=n=>String(n).padStart(2,"0");return String(e.getFullYear())+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function Lp(e){const t=/<(table|tr|div)(\s[^>]*)>/gi;let n;for(;(n=t.exec(e))!==null;){const r=n[2]??"";if(/\bem\s*=\s*["']block["']/i.test(r))return{full:n[0],index:n.index}}return null}function ci(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=Mp(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function Np(e,t,n){if(!e?.trim()||!t)return e;const r=Lp(e);if(!r)return e;const i=String(t),o=kp(n??new Date);let{full:s,index:a}=r;const l=s.length;return/\bem-block-id\s*=/.test(s)||(s=ci(s,"em-block-id",i)),s=ci(s,"em-block-version",o),e.slice(0,a)+s+e.slice(a+l)}function Fp(e){if(e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object")return e.meta;const t=e.catalogExtra?.meta;if(t!=null&&typeof t=="object")return t}function jp(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),i=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:i,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Fp(e)}}function Zt(e,t){return t?jp(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var as=["title","slug","type","tags","blocktags","modified","author","lock","subject","description","excerpt","status","is_template","link","renderGuid","date","date_gmt","modified_gmt","comment_status","ping_status","template","related_email","project_title","project_author","isAmp","meta"],Bp=[...as,"html","id","project","password"],Bg=new Set(["html",...as,"global_block","project"]);function Up(e){if(!e||typeof e!="object")return{};const t={};e.id!=null&&e.id!==""&&(t.id=String(e.id)),e.title!=null&&e.title!==""&&(t.title=e.title),e.slug!=null&&e.slug!==""&&(t.slug=e.slug),e.type!=null&&e.type!==""&&(t.type=e.type),e.tags!=null&&(t.tags=e.tags),e.blocktags!=null&&(t.blocktags=e.blocktags),e.modified!=null&&e.modified!==""&&(t.modified=e.modified),e.author!=null&&e.author!==""&&(t.author=String(e.author)),e.lock!=null&&(t.lock=e.lock),e.subject!=null&&e.subject!==""&&(t.subject=e.subject),e.description!=null&&e.description!==""&&(t.description=e.description),e.excerpt!=null&&e.excerpt!==""&&(t.excerpt=e.excerpt),e.status!=null&&e.status!==""&&(t.status=e.status),e.is_template!=null&&(t.is_template=e.is_template),e.link!=null&&e.link!==""&&(t.link=e.link),e.renderGuid!=null&&e.renderGuid!==""&&(t.renderGuid=e.renderGuid),e.date!=null&&e.date!==""&&(t.date=e.date),e.date_gmt!=null&&e.date_gmt!==""&&(t.date_gmt=e.date_gmt),e.modified_gmt!=null&&e.modified_gmt!==""&&(t.modified_gmt=e.modified_gmt),e.comment_status!=null&&e.comment_status!==""&&(t.comment_status=e.comment_status),e.ping_status!=null&&e.ping_status!==""&&(t.ping_status=e.ping_status),e.template!=null&&e.template!==""&&(t.template=e.template),e.related_email!=null&&e.related_email!==""&&(t.related_email=e.related_email),e.project_title!=null&&e.project_title!==""&&(t.project_title=e.project_title),e.project_author!=null&&e.project_author!==""&&(t.project_author=e.project_author),e.isAmp!=null&&(t.isAmp=e.isAmp),e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object"&&(t.meta=e.meta);const n=new Set(Bp),r={};for(const i of Object.keys(e))n.has(i)||(r[i]=e[i]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Hp(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Up(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var kn=new WeakMap;function Gp(e){let t=kn.get(e);return t||(t={byId:new Map,fallback:[]},kn.set(e,t)),t}function qp(e){kn.delete(e)}function $p(e,t){const{byId:n,fallback:r}=Gp(t);if(e.blockId){const i=n.get(e.blockId);if(i){n.delete(e.blockId);const o=r.indexOf(i);return o>=0&&r.splice(o,1),i}return}for(let i=r.length-1;i>=0;i--){const o=r[i],s=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,a=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(s&&a)return r.splice(i,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function zp(e,t){const{blocks:n}=jt(e);return await n.cache.getIfPresent(t)??void 0}async function Vp(e,t){if(!t.blockId)return;const n=await zp(e,t.blockId);if(n)return Hp(n,t)}async function Kp(e,t){const n=$p(e,t);if(n)return Zt(e,n);const r=await Vp(t,e);return r?Zt(e,r):Zt(e,void 0)}var Wp=Qs("application_block_inserted"),Yp=-1e3,ui=new WeakSet;function Xp(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.type=="string"||typeof t.name=="string"||typeof t.blockId=="string"||typeof t.project=="string"||typeof t.project=="number"}function Jp(e){if(!e||ui.has(e))return;ui.add(e);const t=new Q,n=ee(e);return t.addDisposable(n.addListenerAsyncPipe(Wp,async(r,i)=>{const o=Xp(r)?await Kp(r,e):r;return i?i(o):o},Yp)),t.addDisposable({dispose:()=>{qp(e)}}),t}var fi=100,Qp=class extends Q{_container;_events;constructor(e){super(),this._container=e;const t=Jp(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=jt(e),o=W(e,G.ON_SHARE_ID),s=W(e,G.ON_SHOW_PREVIEW_ID),a=W(e,G.ON_EMAIL_CLONE_ID),l=W(e,G.ON_CODE_VALIDATE_ID),u=W(e,G.ON_SUBJECT_CHANGED_ID),m=W(e,G.ON_EMAIL_CHANGED_ID),v=W(e,G.ON_PREHEADER_CHANGED_ID),E=W(e,G.ON_SAVEBUTTON_CLICK_ID),g=W(e,G.ON_NEXTBUTTON_CLICK_ID),_=W(e,G.ON_SEND_LIVEPREVIEW_ID),b=W(e,G.ON_SEND_TESTEMAIL_ID),y=W(e,cp),S=W(e,G.ON_CONTENT_CHANGED_ID),I=W(e,dp),A=W(e,G.ON_PREVIOUSBUTTON_CLICK_ID),f=W(e,G.ON_SEND_EMAIL_MODAL_ID),c=Xs(W(e,G.ON_EMAIL_INIT_ID),d=>!d.reset);return{handlePreheaderChanged:B(v),handleSubjectChanged:B(u),handleValidate:B(l),handleReadEmail:B(n.handlerRead,d=>d,d=>d&&je(d,e)),handleSaveEmail:B(n.onSave,function({prev:d,patch:p,value:h,source:w}){const T=d?re(d,e):void 0;return{prev:T,patch:Xe(T,re(p,e)),value:re(h,e),source:w}},d=>d?je(d,e):void 0),handleRemoveEmail:B(n.onRemove,({value:d,source:p})=>({value:re(d,e),source:p}),()=>{}),handleReadCommonBlocks:B(y,d=>d.project,d=>d?.map(p=>Ke(p,e))),handleReadTemplateBlocks:B(I,d=>d,d=>d?.map(p=>Ke(p,e))),handleReadBlocks:B(t.byForeignKey("project").handleRead,d=>Ft(e).requested||String(d),d=>d?.map(p=>Ke(p,e))),handleSaveBlock:B(t.onSave,function({prev:d,patch:p,value:h,source:w}){const T=h.global_block===!0&&h.id&&typeof h.html=="string"?{...h,html:Np(h.html,String(h.id))}:h,D=d?vt(d,e):void 0;return{prev:D,patch:Xe(D,vt(p,e)),value:vt(T,e),source:w}},d=>d?Ke(d,e):void 0),handleRemoveBlock:B(t.onRemove,({value:d,source:p})=>({value:vt(d,e),source:p}),()=>{}),handleReadComments:B(r.byForeignKey("post").handleRead,d=>d,d=>d?.map(p=>xn(p,e))),handleSaveComment:B(r.onSave,function({prev:d,patch:p,value:h,source:w}){const T=d?bt(d,e):void 0;return{prev:T,patch:Xe(T,bt(p,e)),value:bt(h,e),source:w}},d=>d?xn(d,e):void 0),handleRemoveComment:B(r.onRemove,({value:d,source:p})=>({value:bt(d,e),source:p}),()=>{}),handleReadEmailRevisions:B(i.byForeignKey("parent").handleRead,d=>d,d=>d?.map(p=>St(p,e))),handleReadEmailAutosave:B(W(e,Yo),d=>d,d=>d?St(d,e):null),handleEmailAutosave:B(i.onSave,function({prev:d,patch:p,value:h,source:w}){return{value:di(h,e),source:w}},d=>d?St(d,e):void 0),handleRemoveEmailAutoSave:B(i.onRemove,({value:d,source:p})=>({value:di(d,e),source:p}),()=>{}),handleEmailChanged:B(_r(m,fi),d=>re(d,e)),handleEmailInit:B(c,d=>re(d,e)),handlePreviousButtonClick:B(A,d=>re(d,e)),handleNextButtonClick:B(g,d=>re(d,e)),handleSaveButtonClick:B(E,d=>re(d,e)),handleHtmlChanged:B(_r(S,fi)),handleTestEmailSend:B(b,({html:d,...p})=>({...p,code:d,compiled:{html:d,ampHtml:""}})),handleTestEmailModal:B(f,d=>re(d,e)),handleCloneEmail:B(a,d=>re(d,e)),handleShareEmail:B(o),handlePreviewEmail:B(s),handleLivePreviewEmail:B(_)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new ke(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},Zp=N("DataController"),eh=N("DataEvents");function ls(e){return e.getOrCreateInstance(Zp,()=>{const t=new xp(e);return e.getInstance(U)?.addDisposable(t),t})}function ds(e){return e.getOrCreateInstance(eh,()=>new Qp(e))}var th=N("plugin.startupShow");function nh(e){const t=ls(e),n=ds(e),r=e.getInstance(ne),i=e.getInstance(U),o={current:Promise.resolve()};e.inject(th,o);const s=r?.watch(l=>{l&&n.setOptions(l),o.current=o.current.catch(()=>{})}),a=r?.select(l=>l?.content).watch(l=>{if(l===void 0)return;V(Z.showStart);const u=t.show(l).finally(()=>V(Z.showEnd));u.catch(()=>{}),o.current=u});s&&i?.addDisposable(s),a&&i?.addDisposable(a)}function rh(e){const t=ls(e);return{...ds(e).get(),show(n){return V(Z.showStart),t.show(n).finally(()=>V(Z.showEnd))},save(){return t.save()}}}var ih=[{name:"rest.client",setup:ip},{name:"auth.oauth",setup:la},{name:"rest.identityHeaders",setup:Zf},{name:"lifetime.destroyable",provides:[dr],setup:tf},{name:"appInit",provides:[Le,Kn],setup:Va},{name:"config",provides:[ye],setup:Zu},{name:"email.documents",setup:yf},{name:"show.initPipeline",provides:[pe],setup:op},{name:"show",setup:nh},{name:"locale.service",provides:[tt],setup:Yf},{name:"locale.fromConfig",awaits:{services:[ye,tt]},setup:Xf},{name:"canvas.early",setup:Vc},{name:"canvas.previewSettings",setup:eu},{name:"canvas.sandboxExtensions",setup:nu},{name:"canvas.headerSync",provides:[jo],setup:Yc},{name:"canvas.ampSync",setup:Td},{name:"canvas.moduleBridge",setup:Jd},{name:"canvas.port",setup:Ld},{name:"canvas.images",setup:Md},{name:"canvas.edits",setup:Dc},{name:"canvas.blockContent",setup:Ic},{name:"canvas.sandboxFill",provides:[lr],setup:yu},{name:"canvas.reactions",setup:qc}],oh=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function sh(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function ah(e,t){const n=[];for(const r of e.awaits?.services??[])for(const i of t.get(r)??[])i!==e&&n.push(i);return n}function cs(e){const t=sh(e),n=[],r=new Set,i=[],o=new Set,s=a=>{if(!r.has(a)){if(o.has(a)){const l=i.indexOf(a);throw new oh([...i.slice(l),a].map(u=>u.name))}o.add(a),i.push(a);for(const l of ah(a,t))s(l);i.pop(),o.delete(a),r.add(a),n.push(a)}};for(const a of e)s(a);return n}var pi;function fr(e){const t=e.getInstance(ne);if(t)return t;e.getInstance(U)||e.inject(U,new Q);const n=Te();e.inject(ne,n),pi??=cs(ih);for(const r of pi)r.setup(e);return n}function lh(e){}var dh=[{name:"save.previewFollow",setup:lh}],hi=N("plugin.lateUnitsInstalled");function ch(e){if(!e.getInstance(hi)){e.inject(hi,!0);for(const t of cs(dh))t.setup(e)}}function uh(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function fh(e){if(!e)return;const t=Hi(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(r=>typeof r=="string"?r.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(r=>/^project_\d+$/.test(r))?.replace(/^project_/,"")||void 0}var ph=Ue(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!Ne(t,i.user),a=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(Ee)||!i.getAuthToken)&&!(!o&&!s&&!a))try{const l=await i.getAuthToken(i.user,i.project);e.inject(fa,Promise.resolve(l||""));const u=fh(l);if(!u)return;e.inject(oa,u);const m=e.getInstance(Le),v=m?await m.catch(()=>{}):void 0;e.inject(Le,Promise.resolve(uh(u,v)))}catch{}}}});function hh(e,t){if(e.getInstance(yr))return;e.inject(yr,!0);const n=Un(e,G.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}function mh(e){e.getInstance(ia)||e.inject(Ee,void 0)}function Ut(e){return String(e.standaloneKey||"").trim()||void 0}function gh(e){return e.standaloneOnAuthFailure===!0?!0:e.config?.standaloneOnAuthFailure===!0}function pr(e){return gh(e)?!!Ut(e):!1}function Ht(e){return!!Ut(e)&&!pr(e)}var vh=Ue(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!Ht(r)){t&&(mh(e),pr(r)),t=void 0;return}const o=Ut(r);if(!o||t===o&&e.getInstance(Ee))return;t=o,e.inject(Ee,o);const s=e.getInstance(U);s&&hh(e,s)}}}),bh=Ue(e=>{const t=e.getInstance(U),n=Un(e,ji),r=B(n),i=t.addDisposable(new ke(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}}),yh=Ue(e=>{const t=e.getInstance(U),n=t.addDisposable(new be),r=t.addDisposable(new be),i=Gn(e,xs),o=B(n.event),s=B(r.event),a=B(i.event),l=t.addDisposable(new ke(o)),u=t.addDisposable(new ke(s)),m=t.addDisposable(new ke(a));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(v){l.setListener(v.handleSetOptions),u.setListener(v.handleOptionsChanged),m.setListener(v.handleConfigChanged),await n.fire(v),await r.fire(v)},dispose(){}}}),en,us="core";function Eh(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([us],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function _h(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?lt().then(()=>{}):t([us],e)}function lt(){return en===void 0&&(en=Eh().then(e=>(et()&&e.installDiagnostics().catch(t=>{}),e))),en}var tn=null,nn=null;async function wh(e){typeof e?.prefetch=="function"&&await e.prefetch()}function hr(){return tn||(tn=lt().then(()=>{})),tn}function fs(e){return nn||(nn=wh(e)),nn}function Sh(){return fs(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function Ih(e){return Promise.all([hr(),fs(e)]).then(()=>{})}function Ah(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function mi(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>_h(t?{priority:t}:void 0)).then(()=>(or(t?{priority:t}:void 0),n?hr():void 0)).catch(()=>{})}function Th(e){const t=Ah(e);if(t==="eager")mi(e);else if(t==="idle"){const n=()=>mi(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var ps="PluginRegistry";function Ch(e=$s()){return e.getOrCreateInstance(ps,()=>new Ta)}var Rh=new Ca(()=>Ch()),Ph=Ue(e=>{let t;function n(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(r){const i=e.getInstance(kt),o=e.getInstance(ps);t||(t=new Aa(i,o,{ensureHostRuntimeReady:Sh}),e.inject(gn,t));const s=r?.plugins||[];i&&await t.setPlugins(s)},instance:{use(r){return typeof r=="function"?n().useByCtor(r):n().useByKey(r)},useAsync(r){return n().useAsync(r)},waitPlugin(r){return n().waitFor(r)}},dispose(){t?.dispose(),t=void 0}}}),hs=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const i=this._listeners.indexOf(r);i>=0&&this._listeners.splice(i,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},Dh=N("ELEMENT_INSERT_HTML_PIPELINE"),Oh=N("BLOCK_INSERT_HTML_PIPELINE"),xh="application_block_inserted",Mh=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Oh,()=>new hs).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(ot,()=>new st),i=n?e.bind(n):e;return r.addListener(xh,i,t)}},kh=N("ComponentRegistry"),gi;function nt(e,t=kh){const n=At.getInstance(t);if(n)return n;if(!gi)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return At.getOrCreateInstance(t,gi)}var Lh=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=this._container.addService(dt,{execute:n=>{t.dispose(),e(n.value.map(r=>({name:r.name,html:r.html})))}})})}update(e,t){const n=this._container,r=nt(n);return n.addService(dt,{execute:i=>{const o=i.value.find(s=>s.name===e);if(o){const{icon:s,title:a,fallbackTooltip:l,...u}=t;s&&(o.icon=r.getReactNode(s)),a&&(o.title=r.getReactNode(a)),l&&(o.fallbackTooltip=r.getReactNode(l)),Object.assign(o,u)}}})}delete(e){this._container.addService(dt,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container,r=nt(n);return n.addService(dt,{execute:i=>{i.value.splice(t??i.value.length,0,{...e,title:r.getReactNode(e.title),icon:r.getReactNode(e.icon),fallbackTooltip:r.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(Dh,()=>new hs).add(e,t??0,n)}handleInject(e,t,n){return Me(this._container,Ks).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},Nh=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(ot,()=>new st)}send(e,t,n){this._messageService.send(e,t,n)}sendAsync(e,t,n=!0){return this._messageService.sendAsync(e,t,n)}addListener(e,t,n){return this._messageService.addListener(e,t,n)}addListenerAsync(e,t,n=0){return this._messageService.addListenerAsync(e,t,n)}onInit(e,t=!0,n=0){return this._messageService.onInit(e,t,n)}isInited(){return this._messageService.isInited()}};function Fh(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}var jh=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Me(t,Gs),this._closeModalEmitter=Me(t,Bs),this._updateModalEmitter=Me(t,Ws)}get _container(){return this._context.container}show(e){const t=nt(this._container),n=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,r=e.modalProps;return this._showModalEmitter.fire({...e,content:t.getReactNode(e.content),title:t.getReactNode(e.title),id:n,modalProps:r?{...r,footer:t.getReactNode(r.footer),okText:t.getReactNode(r.okText),cancelText:t.getReactNode(r.cancelText),closeIcon:t.getReactNode(r.closeIcon)}:void 0}),n}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=nt(this._container),r=t.modalProps;this._updateModalEmitter.fire(Fh({...t,content:n.getReactNode(t.content),title:n.getReactNode(t.title),id:e,modalProps:r?{...r,footer:n.getReactNode(r.footer),okText:n.getReactNode(r.okText),cancelText:n.getReactNode(r.cancelText),closeIcon:n.getReactNode(r.closeIcon)}:void 0}))}},Bh=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),n())},s=a=>{this._loadedSettled||(this._loadedSettled=!0,this._readySettled&&i(),r(a))};this._resolveLoaded=o,this._rejectLoaded=s}),this.ready=new Promise((n,r)=>{const i=()=>this._loadedDisposable.dispose(),o=()=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),n())},s=a=>{this._readySettled||(this._readySettled=!0,this._loadedSettled&&i(),r(a))};this._resolveReady=o,this._rejectReady=s})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady()}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},Uh=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(ot,()=>new st)}_createScriptHandle(e,t){const n=this._messageService.addListener(ks,i=>{if(i.key===e){if(i.phase==="load"&&i.status==="success"){r.resolveLoaded();return}if(i.phase==="ready"&&i.status==="success"){r.resolveReady();return}if(i.phase==="load"){r.rejectLoad(new Error(i.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(i.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new Bh(t,n);return r}registerSandboxCSS(e){return this._container.addService(Oe,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Oe,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Oe,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Oe,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},Hh=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function Ln(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&Hh.has(t)}function ms(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}return`nohwcrypto-${Date.now()}`}function rn(){return`__settingsPanel:${ms()}`}function on(e,t){return{type:e,props:t}}function Gh(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!Ln(e)}function vi(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(Ln(t)){const r=rn();return n(e.add(r,t)),on(r,{})}if(typeof t=="function"){const r=rn();return n(e.add(r,t)),on(r,{})}if(Gh(t)){const r=t.type;if(typeof r=="string")return t;if(Ln(r)||typeof r=="function"){const i=rn();return n(e.add(i,r)),on(i,t.props)}return t}return t}var qh=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=nt(this._container),n=s=>this._trackRegistration(s),r=vi(t,e.content,n),i=e.advancedTabs?.map(s=>({...s,content:vi(t,s.content,n)})),o=e.instanceKey??ms();Me(this._container,br).fire({...e,content:r,advancedTabs:i,instanceKey:o,type:qs})}closeSettingsPanel(){this._clearPanelRegistrations(),Me(this._container,br).fire(null)}},gs={SandboxScriptApi:Uh,ElementsApi:Lh,BlocksApi:Mh,MessageService:Nh,SettingsPanelApi:qh,ModalApi:jh};function sn(e,t,n,r={}){const i=Object.assign({},e);for(const[o,s]of Object.entries(t))if(s!==void 0)if(n.includes(o)&&typeof s=="object"&&s!==null){const a=i[o],l=r[o]??{};i[o]=Object.assign({},typeof a=="object"&&a!==null?a:l,s)}else i[o]=s;return i}var oe={border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},borderRadiusCards:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},padding:{all:null,top:null,right:null,bottom:null,left:null}},$h={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},an={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:24,fontSizeDim:"px",lineHeight:32,lineHeightDim:"px",color:"#333333",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},bi={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},Pe={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:oe.border,borderRadius:oe.borderRadius,textAlign:"center",padding:oe.padding},yi={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:oe.padding},ln={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:oe.border,borderRadius:oe.borderRadiusCards};function zh(e){return{...$h,...e}}function Vh(e){return{...an,...e,bold:e?.bold??an.bold,italic:e?.italic??an.italic}}function Kh(e){return{...bi,...e,underline:e?.underline??bi.underline}}function Wh(e){return{...Pe,...e,bold:e?.bold??Pe.bold,italic:e?.italic??Pe.italic,border:{...Pe.border,...e?.border},borderRadius:{...Pe.borderRadius,...e?.borderRadius},padding:{...Pe.padding,...e?.padding}}}function Yh(e){return{...yi,...e,padding:{...yi.padding,...e?.padding}}}function Xh(e){return{...ln,...e,border:{...ln.border,...e?.border},borderRadius:{...ln.borderRadius,...e?.borderRadius}}}function dn(e={}){return{backgroundColor:e.backgroundColor||"",backgroundImage:(e.backgroundImage||[]).map(t=>({type:"url",value:t?.value||""})),backgroundPositionX:e.backgroundPositionX||"",backgroundPositionY:e.backgroundPositionY||"",backgroundRepeat:e.backgroundRepeat||"",backgroundSize:e.backgroundSize||"",backgroundColorContent:e.backgroundColorContent||"",textStrong:e.textStrong||!1,textItalic:e.textItalic||!1,textUnderline:e.textUnderline||!1,width:e.width,responsive:e.responsive}}function Ei(e){let t={...Hn};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function cn(e){return{text:zh(e.text),headings:Vh(e.headings),links:Kh(e.links),buttons:Wh(e.buttons),block:Yh(e.block),cards:Xh(e.cards)}}var _i=N("EmailSettingsPort"),Jh=1e4,vs=class{_editor;_layoutSettingsChanged=new vn;_contentStylesChanged=new vn;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(_i);if(!t)throw new Error("[extensions] настройки письма ещё не загружены — работа с UI начинается с init()");return t}_getCurrentLayoutSettings(){return dn(this._settings().read())}_getCurrentContentStyles(){const e=We(this._editor.container)?.current()?.get().attributes.common_styles;return cn(Ei(e))}_getLayoutSnapshot(e){return JSON.stringify(e)}_getContentSnapshot(e){return JSON.stringify(e)}async _ensureMessageSubscription(){if(!this._messageSubscription){if(this._messageSubscriptionPromise)return this._messageSubscriptionPromise;this._messageSubscriptionPromise=(async()=>{if(await this._editor.container.getInstanceAsync(_i),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(ot,()=>new st),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const i=r?.data,o=i?.operation;if(o===H.APPLICATION_EMAIL_SETTINGS_SET){const l=dn(i?.settings),u=this._getLayoutSnapshot(l);u!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=u,this._layoutSettingsChanged.fire(l));return}if(o!==H.APPLICATION_COMMON_STYLES_UPDATE)return;const s=cn(r.data?.settings?.commonStyles??{...Hn}),a=this._getContentSnapshot(s);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=dn(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Jh){const t=We(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,i=Un(r,G.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,a;const l=()=>{a&&(clearTimeout(a),a=void 0)},u=i(()=>{s||(s=!0,l(),u.dispose(),o())});a=setTimeout(()=>{s||(s=!0,u.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=We(this._editor.container)?.current();if(!t)return;const n=Ei(t.get().attributes.common_styles);e.text!==void 0&&(n.text={...n.text||{},...e.text}),e.headings!==void 0&&(n.headings={...n.headings||{},...e.headings}),e.links!==void 0&&(n.links={...n.links||{},...e.links}),e.buttons!==void 0&&(n.buttons=sn(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:oe.border,borderRadius:oe.borderRadius,padding:oe.padding})),e.block!==void 0&&(n.block=sn(n.block||{},e.block,["padding"],{padding:oe.padding})),e.cards!==void 0&&(n.cards=sn(n.cards||{},e.cards,["border","borderRadius"],{border:oe.border,borderRadius:oe.borderRadiusCards}));const r=JSON.stringify(n);Rt(t,{common_styles:r}),this._settings().markAppearanceChanged();const i=cn(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},Qh={...gs,EmailSettingsApi:vs},Zh={...gs},Ug={...Zh,EmailSettingsApi:vs},em={...Qh};function tm(){Rh.addAll(em)}var nm=[Ue(()=>{tm()}),bh,yh,vh,da,ph,ma];async function rm(){return(await lt()).asyncMixins}var im=Ph,om=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await rm()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(kt);Object.assign(o,t.instance||{});for(const s of e.getInstance(Gi)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},sm=ea([...nm]);function un(){let e,t=!1;const n=new Map,r=new Map;function i(){for(const o of r.values())o();r.clear()}return{event(o,s,a){const l=Symbol("subscription");return t||(n.set(l,{listener:o,priority:s,thisArg:a}),e&&r.set(l,e(o,s,a))),()=>{n.delete(l),r.get(l)?.(),r.delete(l)}},attach(o){i(),e=o;for(const[s,{listener:a,priority:l,thisArg:u}]of n)r.set(s,o(a,l,u))},dispose(){t=!0,i(),n.clear(),e=void 0}}}function am(e){const t=un(),n=un(),r=un();return e.getInstance(U)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(Mn).then(i=>{t.attach(i.onNotify),n.attach(i.onError),r.attach(i.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(i){const o=e.getInstance(Mn);if(!o)throw new Error("[plugin] notify() вызван до загрузки редактора");o.notify(i)}}}var lm=[nf,rh,am];function dm(e,t=lm){const n=fr(e);ch(e);const r=sm(e),i=im(e),o=om(e),s={...r.instance,...i.instance,...o.instance};for(const l of t)Object.assign(s,l(e));let a=!0;return{instance:s,async setOptions(l){await r.setOptions(l);const u=a&&n.get()===l;a=!1,u||n.set(l),await i.setOptions(l),await o.setOptions(l)}}}var cm=class{_storage=Object.create(null);get(e){const t=this._storage[e];return t&&(!t.expires||t.expires<Date.now())?t.value:""}set(e,t,n){this._storage[e]={value:t,expires:n.expires?n.expires*1e3+Date.now():void 0}}remove(e){delete this._storage[e]}},um="editor-runtime.react.copies",fn=8;function rt(e){return e&&typeof e=="object"?e:void 0}function wi(e){const t=rt(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=rt(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function fm(e){const t=rt(e),n=t&&typeof t.version=="string"?t.version:void 0,r=rt(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function pm(e,t,n){return e.package===t&&e.version===n}function hm({ourReact:e,entries:t,packageName:n,version:r}){const i=wi(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const a of t){const l=rt(a);if(!l||!pm(l,n,r))continue;const u=wi(l.react);!u||u===i||s.has(u)||(s.add(u),o.push({package:n,version:r,reactVersion:fm(l.react),react:l.react}))}return o}function mm({packageName:e,copies:t}){const n=[`[${e}] A second copy of React is on this page (singleton invariant broken).`,`The editor runs on its own React, the plugin got another one from ${e}/runtime/react.`,`This shows up as "Cannot read properties of null (reading 'useState')" and takes down the whole`,"editor, not just the plugin panel: plugin components render inside the editor tree.","","Found:"];for(const r of t.slice(0,fn))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>fn&&n.push(` …and ${t.length-fn} more`),n.push("","Likely root cause: the editor is loaded from its UMD entry (a <script> on the page), while the","plugin was built as an ESM package by the host bundler. Those two never share a React.","","Fix it either way:"," • build the plugin on globals — it then takes React from the page registry, or"," • load the editor from its ESM entry and build both with the same bundler."),n.join(`
|
|
1047
|
-
`)}var
|
|
1047
|
+
`)}function so(e){return e.replace(/<title[^>]*>[\s\S]*?<\/title>/gi,"")}function rg(e,t,n,r){const i=ig(e,t,n,r);return i===void 0}function ig(e,t,n,r){const{email:i}=vn(t,!1),o=it(i,e),s=o.id;if(s===void 0)return"no-id";if(r!==void 0&&r!==s)return"other-id-shown";const a=Kr(e)?.current();if(!a)return"no-session";const c=a.get(),d=c.attributes;if(c.serverId!==s)return"document-id";if(d.is_inited!==!0)return"not-inited";const f=so(pr(n??a.getContent()));if(o.html!==void 0&&so(pr(o.html))!==f)return"html";if(o.subject!==void 0&&o.subject!==d.subject)return"subject";if(o.preheader!==void 0&&o.preheader!==d.preheader)return"preheader";if(o.common_styles!==void 0&&o.common_styles!==d.common_styles)return"common_styles"}function ao(e,t){const{email:n}=vn(t,!1),r=it(n,e);if(r.id!==void 0)return JSON.stringify([r.id,r.html===void 0?null:pr(r.html),r.subject??null,r.preheader??null,r.common_styles??null])}function og(e,t){const n={...e};return delete n.id,{...n,...t}}function sg(e){return e.html?e:{...e,html:xa}}function pt({code:e,project:t,...n},r,i){const o=i??ri(r);return{...n,...e?{html:ze(r).toEditorForm(e)}:{},renderGuid:Se(),...o===void 0?{}:{project:o}}}function ht({html:e,renderGuid:t,...n},r){const{requested:i}=Ft(r);return ke({...n,code:ze(r).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 La(e){return Kr(e)?.current()?.get().serverId??void 0}function hr(e,t,n){return n===void 0&&(n=e.post===void 0?La(t):e.post),{...e,content:e.content?`<p>${e.content}</p>`:"",post:n}}function mt(e,t){return ke({...e,link:void 0,comment_status:void 0})}function tn({code:e,autosave:t,...n},r,i){return i===void 0&&(i=n.parent===void 0?La(r):n.parent),{...n,...e?{html:e}:{},isAutosave:t===!0||xd(n.slug),parent:i}}function mr({html:e,isAutosave:t,...n},r){return ke({...n,autosave:t?!0:void 0,code:e,guid:void 0,compiled:ke({html:e,ampHtml:e&&""})})}var tt=F("NotificationService"),ag=F("emailTemplate.reads");async function lg(e,t){try{return await Ve(e).email(e).readEmail(t)??void 0}catch(n){n instanceof Error&&n.message,dg(e,t,n);return}}var cg=F("emailTemplate.notifiedFailures");function dg(e,t,n){if(n instanceof DOMException&&n.name==="AbortError")return;const r=e.getOrCreateInstance(cg,()=>new Set);r.has(t)||(r.add(t),e.getInstanceAsync(tt).then(()=>{kt(e,j.ON_NOTIFICATION).fire({type:"warning",id:"TEMPLATE_READ_ERROR",data:{templateId:t},innerException:n})},()=>{}))}function ug(e,t){const n=e.getOrCreateInstance(ag,()=>new Map),r=n.get(t);if(r!==void 0)return r;const i=lg(e,t).then(o=>(o===void 0&&n.delete(t),o));return n.set(t,i),i}var fg="EXTERNAL",lo=Symbol("supersededShow");function pg(e){return e instanceof Error?e:new Error(typeof e=="string"?e:"[emailmaker] save failed")}var hg="email_id",mg=class extends ie{_container;_prevCommand;_lastShow;_showToken=0;_showRequests=0;_latestShowEmailId;_latestShow=Promise.resolve();_dataSources;_eventLock;_queue=zo();_currentEmail;constructor(e){super(),this._container=e;const t=e;this._dataSources=jt(t),this._eventLock=Zm(t);const n=te(e,j.ON_EMAIL_CHANGED_ID);this.addDisposable(n(r=>{this._currentEmail=r})),this.addDisposable(e.addService(Ar,{execute:(r,i)=>{!i?.public&&this._currentEmail?.id&&!this._currentEmail.isNew&&r.headers.append(hg,this._currentEmail.id)}}))}_getInitPipeline(){return this._container?.getInstance(Ae)??Zr}_throwIfDestroyed(){if(this.isDisposed())throw Oe()}async getTemplateEmail(e){const t=await ug(this._container,String(e));if(!t)return;const n={...t,lock:!1,parent_email:String(e)};return delete n.id,n}async setBlocks(e=[]){const{cache:t}=this._dataSources.blocks,n=await en(this._container);await t.setAll(e.filter(r=>r.id!==void 0).map(r=>[r.id,pt(r,this._container,n)]))}async setEmailRevisions(e,t){if(e===void 0)return;const{cache:n}=this._dataSources.emailRevisions,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,tn(i,this._container,t)]);await n.setAll(r)}async setComments(e=[],t){const{cache:n}=this._dataSources.comments,r=e.filter(i=>i.id!==void 0).map(i=>[i.id,hr(i,this._container,t)]);await n.setAll(r)}async setEmail(e,t,n,r,i){const o=this._dataSources.emails,s=o.cache,a=await en(this._container),c=r??this._showToken;e=typeof e=="string"?{code:e}:{...e};let d=it(e,this._container);const f=d.id;let h=f;if(f!==void 0){const y=await o.get(f);d={...y??{},...d,utm_parameters:d.utm_parameters??y?.utm_parameters??{},renderGuid:y?.renderGuid??Se(),...c>0?{showToken:c}:{},...i?{showId:i}:{},project:a}}else{h=n??Se();const y=await o.get(h);d={...d,utm_parameters:d.utm_parameters??{},renderGuid:y?.renderGuid??Se(),...c>0?{showToken:c}:{},...i?{showId:i}:{},project:a},delete d.project}if(t){const y=await this.getTemplateEmail(String(t));y&&(d=og(y,d))}return f===void 0&&(d=sg(d)),await s.setAll([[h,d]]),d}_rememberShow(e){this._prevCommand=e}_isRepeatOfLastShow(e){const t=this._lastShow;if(!t||t.signature!==ao(this._container,e))return!1;const n=Zt(this._container);return n===void 0||n===t.html}_rememberShownContent(e){const t=ao(this._container,e);this._lastShow=t===void 0?void 0:{signature:t,html:Zt(this._container)??""}}async _show(e,t){if(this._throwIfDestroyed(),t!==void 0&&tg({ticket:t,emailId:oo(e)},{ticket:this._showRequests,emailId:this._latestShowEmailId}))return this._showRequests,lo;if(!e)return;const n=this._getInitPipeline();Y(n.signal);const r=ng(e);if(!r&&rg(this._container,e,Zt(this._container),this._prevCommand?.id)||!r&&this._isRepeatOfLastShow(e))return;const i=vn(e);i.email.id,this._prevCommand?.id;let o,s="",a=0,c=!1,d,f=Promise.resolve(),h,y=!1;try{this._eventLock.suspendChange();const{email:b,blocks:T,autosaves:w,comments:g,templateId:C,reload:_}=i;o=b.id;const P=it(b,this._container),S=P.id,M=S??Se(),v=await bt("getProject",en(this._container));Y(n.signal),s=Se();const E={isNew:S===void 0,id:String(M),project:v},A=_===!0&&S!==void 0;A&&(await this._dataSources.emails.remove(String(S),{silent:!0}),String(S)),a=++this._showToken,String(M);const m=[];m.push(this.setBlocks(T)),b.id!==void 0&&(m.push(this.setComments(g)),m.push(this.setEmailRevisions(w,String(b.id)))),m.push(this.setEmail(b,Number(C),S===void 0?String(M):void 0,a,s)),await bt("setEmail+blocks+revisions",Promise.all(m),{emailId:S??String(M),showId:s,targetShowToken:a}),Y(n.signal);const l=await this._dataSources.emails.get(String(M)),u=Le(this._container),p={id:s,token:a};S===void 0?h=u.startNewDraft(l??P,{patch:P,show:p}):A?h=u.reload(S,{email:l??P,patch:P,show:p}):u.sessionKey()===Ke(S)?h=u.show(P,p):h=u.open(S,{email:l??P,patch:P,show:p});const R=!!this._prevCommand&&Ce(this._prevCommand,E);E.id,!this._prevCommand||Ce(this._prevCommand,E),this._prevCommand?.id,this._rememberShow(E),f=n.requestShow({showId:s,navId:String(M),emailId:S,isNew:S===void 0}),y=!0,String(M),c=!0}catch(b){d=b,y&&s&&n.failShow(s,b),Or(b)||(ds(b),void 0)}finally{this._eventLock.resumeChange()}if(!c)throw d instanceof Error?d:new Error(`[useblocks] show() setup failed: ${String(d??"unknown error")}`);return bt("show-init-deferred",Promise.all([f,h?.whenReady().catch(b=>{if(b instanceof It){const T=zr(b);throw T?new Error(`[useblocks] show(): email open failed (${T})`,{cause:b}):b}})??Promise.resolve()]).then(()=>{}),{showId:s,emailId:o??null}).then(()=>{this._rememberShownContent(e)})}async _save(){this._throwIfDestroyed();const e=this._getInitPipeline();Y(e.signal);const t=Le(this._container),n=await t.save("publish",{source:fg,fallbackTitle:Hs(this._container)});if(Y(e.signal),!n)throw pg(t.saveState().error);return de(ka(this._container,this._currentEmail),this._container)}_queuedShow=this._queue.decorate((e,t)=>this._show(e,t),this);show=e=>{const t=this._showRequests+=1;this._latestShowEmailId=oo(e);const n=this._queuedShow(e,t).then(r=>r===lo?this._latestShow.catch(()=>{}):void 0);return this._latestShow=n,n};save=this._queue.decorate(this._save,this)};function gg(e){return String(e).replace(/"/g,""")}function vg(e=new Date){const t=n=>String(n).padStart(2,"0");return String(e.getFullYear())+t(e.getMonth()+1)+t(e.getDate())+t(e.getHours())+t(e.getMinutes())+t(e.getSeconds())}function bg(e){const t=/<(table|tr|div)(\s[^>]*)>/gi;let n;for(;(n=t.exec(e))!==null;){const r=n[2]??"";if(/\bem\s*=\s*["']block["']/i.test(r))return{full:n[0],index:n.index}}return null}function co(e,t,n){const r=new RegExp(`\\b${t}\\s*=\\s*["'][^"']*["']`,"i"),i=gg(n);return r.test(e)?e.replace(r,`${t}="${i}"`):e.replace(/>$/,` ${t}="${i}">`)}function yg(e,t,n){if(!e?.trim()||!t)return e;const r=bg(e);if(!r)return e;const i=String(t),o=vg(n??new Date);let{full:s,index:a}=r;const c=s.length;return/\bem-block-id\s*=/.test(s)||(s=co(s,"em-block-id",i)),s=co(s,"em-block-version",o),e.slice(0,a)+s+e.slice(a+c)}function Eg(e){if(e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object")return e.meta;const t=e.catalogExtra?.meta;if(t!=null&&typeof t=="object")return t}function _g(e,t){const n=e.insertFrom??t?.type,r=t?.blockId??(e.id!=null&&e.id!==""?String(e.id):void 0),i=t?.project??(e.project!==void 0&&e.project!==null?String(e.project):void 0);return{type:t?.type??n,insertFrom:n,name:t?.name??e.name,blockId:r,project:i,fragmentRole:e.fragmentRole,id:r,title:e.title??void 0,blockType:e.type,meta:Eg(e)}}function Mn(e,t){return t?_g(t,e):{type:e.type,name:e.name,blockId:e.blockId,project:e.project,insertFrom:e.type}}var Na=["title","slug","type","tags","blocktags","modified","author","lock","subject","description","excerpt","status","is_template","link","renderGuid","date","date_gmt","modified_gmt","comment_status","ping_status","template","related_email","project_title","project_author","isAmp","meta"],wg=[...Na,"html","id","project","password"],OE=new Set(["html",...Na,"global_block","project"]);function Sg(e){if(!e||typeof e!="object")return{};const t={};e.id!=null&&e.id!==""&&(t.id=String(e.id)),e.title!=null&&e.title!==""&&(t.title=e.title),e.slug!=null&&e.slug!==""&&(t.slug=e.slug),e.type!=null&&e.type!==""&&(t.type=e.type),e.tags!=null&&(t.tags=e.tags),e.blocktags!=null&&(t.blocktags=e.blocktags),e.modified!=null&&e.modified!==""&&(t.modified=e.modified),e.author!=null&&e.author!==""&&(t.author=String(e.author)),e.lock!=null&&(t.lock=e.lock),e.subject!=null&&e.subject!==""&&(t.subject=e.subject),e.description!=null&&e.description!==""&&(t.description=e.description),e.excerpt!=null&&e.excerpt!==""&&(t.excerpt=e.excerpt),e.status!=null&&e.status!==""&&(t.status=e.status),e.is_template!=null&&(t.is_template=e.is_template),e.link!=null&&e.link!==""&&(t.link=e.link),e.renderGuid!=null&&e.renderGuid!==""&&(t.renderGuid=e.renderGuid),e.date!=null&&e.date!==""&&(t.date=e.date),e.date_gmt!=null&&e.date_gmt!==""&&(t.date_gmt=e.date_gmt),e.modified_gmt!=null&&e.modified_gmt!==""&&(t.modified_gmt=e.modified_gmt),e.comment_status!=null&&e.comment_status!==""&&(t.comment_status=e.comment_status),e.ping_status!=null&&e.ping_status!==""&&(t.ping_status=e.ping_status),e.template!=null&&e.template!==""&&(t.template=e.template),e.related_email!=null&&e.related_email!==""&&(t.related_email=e.related_email),e.project_title!=null&&e.project_title!==""&&(t.project_title=e.project_title),e.project_author!=null&&e.project_author!==""&&(t.project_author=e.project_author),e.isAmp!=null&&(t.isAmp=e.isAmp),e.meta!==void 0&&e.meta!==null&&typeof e.meta=="object"&&(t.meta=e.meta);const n=new Set(wg),r={};for(const i of Object.keys(e))n.has(i)||(r[i]=e[i]);return Object.keys(r).length>0&&(t.catalogExtra=r),t}function Ig(e,t={}){return!e||typeof e!="object"?{html:"",insertFrom:t.type,name:t.name,project:t.project,id:t.blockId}:{...Sg(e),html:typeof e.html=="string"?e.html:"",insertFrom:t.type,name:t.name,project:t.project??e.project,id:e.id!=null&&e.id!==""?String(e.id):t.blockId}}var gr=new WeakMap;function Cg(e){let t=gr.get(e);return t||(t={byId:new Map,fallback:[]},gr.set(e,t)),t}function Tg(e){gr.delete(e)}function Ag(e,t){const{byId:n,fallback:r}=Cg(t);if(e.blockId){const i=n.get(e.blockId);if(i){n.delete(e.blockId);const o=r.indexOf(i);return o>=0&&r.splice(o,1),i}return}for(let i=r.length-1;i>=0;i--){const o=r[i],s=e.name!=null&&e.name!==""&&o.name!=null&&o.name!==""&&o.name===e.name,a=e.type!=null&&e.type!==""&&o.insertFrom===e.type;if(s&&a)return r.splice(i,1),o.id!=null&&o.id!==""&&n.delete(String(o.id)),o}}async function Rg(e,t){const{blocks:n}=jt(e);return await n.cache.getIfPresent(t)??void 0}async function Pg(e,t){if(!t.blockId)return;const n=await Rg(e,t.blockId);if(n)return Ig(n,t)}async function Dg(e,t){const n=Ag(e,t);if(n)return Mn(e,n);const r=await Pg(t,e);return r?Mn(e,r):Mn(e,void 0)}var Og=Wo("application_block_inserted"),xg=-1e3,uo=new WeakSet;function Mg(e){if(e===null||typeof e!="object")return!1;const t=e;return typeof t.type=="string"||typeof t.name=="string"||typeof t.blockId=="string"||typeof t.project=="string"||typeof t.project=="number"}function kg(e){if(!e||uo.has(e))return;uo.add(e);const t=new ie,n=ae(e);return t.addDisposable(n.addListenerAsyncPipe(Og,async(r,i)=>{const o=Mg(r)?await Dg(r,e):r;return i?i(o):o},xg)),t.addDisposable({dispose:()=>{Tg(e)}}),t}var Fa=F("plugin.earlyWindow");function Lg(e){return e.getOrCreateInstance(Fa,()=>({depth:0}))}function Ng(e){const t=Lg(e);t.depth+=1;let n=!1;return()=>{n||(n=!0,t.depth-=1)}}function ja(e){return(e?.getInstance(Fa)?.depth??0)>0}function Ba(e,t){let n,r=!1;return e(i=>{n=i,r=!0}),(i,o,s)=>{const a=e(i,o,s);if(r&&ja(t)){const c=n;queueMicrotask(()=>{i.call(s,c)})}return a}}var fo=100,Fg=class extends ie{_container;_events;constructor(e){super(),this._container=e;const t=kg(e);t&&this.addDisposable(t)}_get(){const e=this._container,{blocks:t,emails:n,comments:r,emailRevisions:i}=jt(e),o=te(e,j.ON_SHARE_ID),s=te(e,j.ON_SHOW_PREVIEW_ID),a=te(e,j.ON_EMAIL_CLONE_ID),c=te(e,j.ON_CODE_VALIDATE_ID),d=te(e,j.ON_SUBJECT_CHANGED_ID),f=te(e,j.ON_EMAIL_CHANGED_ID),h=te(e,j.ON_PREHEADER_CHANGED_ID),y=te(e,j.ON_SAVEBUTTON_CLICK_ID),b=te(e,j.ON_NEXTBUTTON_CLICK_ID),T=te(e,j.ON_SEND_LIVEPREVIEW_ID),w=te(e,j.ON_SEND_TESTEMAIL_ID),g=te(e,Ym),C=te(e,j.ON_CONTENT_CHANGED_ID),_=te(e,Km),P=te(e,j.ON_PREVIOUSBUTTON_CLICK_ID),S=te(e,j.ON_SEND_EMAIL_MODAL_ID),M=_l(te(e,j.ON_EMAIL_INIT_ID),v=>!v.reset);return{handlePreheaderChanged:B(h),handleSubjectChanged:B(d),handleValidate:B(c),handleReadEmail:B(n.handlerRead,v=>v,v=>v&&it(v,e)),handleSaveEmail:B(n.onSave,function({prev:v,patch:E,value:A,source:m}){const l=v?de(v,e):void 0;return{prev:l,patch:Et(l,de(E,e)),value:de(A,e),source:m}},v=>v?it(v,e):void 0),handleRemoveEmail:B(n.onRemove,({value:v,source:E})=>({value:de(v,e),source:E}),()=>{}),handleReadCommonBlocks:B(g,v=>v.project,v=>v?.map(E=>pt(E,e))),handleReadTemplateBlocks:B(_,v=>v,v=>v?.map(E=>pt(E,e))),handleReadBlocks:B(t.byForeignKey("project").handleRead,v=>Ft(e).requested||String(v),v=>v?.map(E=>pt(E,e))),handleSaveBlock:B(t.onSave,function({prev:v,patch:E,value:A,source:m}){const l=A.global_block===!0&&A.id&&typeof A.html=="string"?{...A,html:yg(A.html,String(A.id))}:A,u=v?ht(v,e):void 0;return{prev:u,patch:Et(u,ht(E,e)),value:ht(l,e),source:m}},v=>v?pt(v,e):void 0),handleRemoveBlock:B(t.onRemove,({value:v,source:E})=>({value:ht(v,e),source:E}),()=>{}),handleReadComments:B(r.byForeignKey("post").handleRead,v=>v,v=>v?.map(E=>hr(E,e))),handleSaveComment:B(r.onSave,function({prev:v,patch:E,value:A,source:m}){const l=v?mt(v,e):void 0;return{prev:l,patch:Et(l,mt(E,e)),value:mt(A,e),source:m}},v=>v?hr(v,e):void 0),handleRemoveComment:B(r.onRemove,({value:v,source:E})=>({value:mt(v,e),source:E}),()=>{}),handleReadEmailRevisions:B(i.byForeignKey("parent").handleRead,v=>v,v=>v?.map(E=>tn(E,e))),handleReadEmailAutosave:B(te(e,Ca),v=>v,v=>v?tn(v,e):null),handleEmailAutosave:B(i.onSave,function({prev:v,patch:E,value:A,source:m}){return{value:mr(A,e),source:m}},v=>v?tn(v,e):void 0),handleRemoveEmailAutoSave:B(i.onRemove,({value:v,source:E})=>({value:mr(v,e),source:E}),()=>{}),handleEmailChanged:B(vi(f,fo),v=>de(v,e)),handleEmailInit:Ba(B(M,v=>de(v,e)),e),handlePreviousButtonClick:B(P,v=>de(v,e)),handleNextButtonClick:B(b,v=>de(v,e)),handleSaveButtonClick:B(y,v=>de(v,e)),handleHtmlChanged:B(vi(C,fo)),handleTestEmailSend:B(w,({html:v,...E})=>({...E,code:v,compiled:{html:v,ampHtml:""}})),handleTestEmailModal:B(S,v=>de(v,e)),handleCloneEmail:B(a,v=>de(v,e)),handleShareEmail:B(o),handlePreviewEmail:B(s),handleLivePreviewEmail:B(T)}}get(){return this._events||(this._events=this._get())}_listenersUpdaters;setOptions(e={}){const t=this.get();let n=this._listenersUpdaters;if(!n){n=this._listenersUpdaters={};for(const r of Object.keys(t))n[r]=this.addDisposable(new et(t[r]))}for(const r of Object.keys(t))n[r].setListener(e[r])}},jg=F("DataController"),Bg=F("DataEvents");function Ua(e){return e.getOrCreateInstance(jg,()=>{const t=new mg(e);return e.getInstance(U)?.addDisposable(t),t})}function Ha(e){return e.getOrCreateInstance(Bg,()=>new Fg(e))}var Ug=F("plugin.pluginStart");function $a(e){return e.getOrCreateInstance(Ug,()=>{let t;const n=new Promise(r=>{t=r});return e.getInstance(U)?.addDispose(()=>t()),{done:n,finish:t}})}function Hg(e){return $a(e).done}function $g(e){const t=$a(e);return t.run===void 0&&(t.run=(e.getInstance(xr)?.activate()??Promise.resolve()).finally(t.finish)),t.run}var Gg=F("plugin.startupShow");function Vg(e){const t=Ua(e),n=Ha(e),r=e.getInstance(se),i=e.getInstance(U),o={current:Promise.resolve()};e.inject(Gg,o);let s=!1;const a=r?.watch(d=>{d&&n.setOptions(d),s=(d?.plugins?.length??0)>0,o.current=o.current.catch(()=>{})}),c=r?.select(d=>d?.content).watch(d=>{if(d===void 0)return;const f=()=>(Z(le.showStart),t.show(d).finally(()=>Z(le.showEnd))),h=s?Hg(e).then(f):f();h.catch(()=>{}),o.current=h});a&&i?.addDisposable(a),c&&i?.addDisposable(c)}function qg(e){const t=Ua(e);return{...Ha(e).get(),show(n){return Z(le.showStart),t.show(n).finally(()=>Z(le.showEnd))},save(){return t.save()}}}function Ga(e){return/#set\s*\(\s*.*=.*\)/.test(e)}function bn(e){const t=e.indexOf("(");if(t<0)return!0;let n=0,r="",i=!1;for(let o=t;o<e.length;o++){const s=e[o];if(i){i=!1;continue}if(s==="\\"){i=!0;continue}if(r){s===r&&(r="");continue}if(s==='"'||s==="'"){r=s;continue}if(s==="("){n++;continue}if(s===")"&&(n--,n<0))return!1}return n===0}function zg(e){return(t,n,r)=>bn(t)?e(t,n,r):!1}function Wg(e){return t=>bn(t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t)?e(t):!1}function Kg(e){return(t,n,r)=>bn(t)?Ga(t)?e(t,n,r):t:!1}function Yg(e){return t=>{const n=t.startsWith("<!--")&&t.endsWith("-->")?t.slice(4,-3):t;return bn(n)?Ga(n)?e(t):t:!1}}function Xg(e){const t=/[<>&]/g;for(;t.exec(e)!==null;)return!0;return!1}function ai(e,t){const n=e.length;for(let r=0;r<n;r++){const i=e.charCodeAt(r);if(i===0||t==='"'&&i===34||t==="'"&&i===39||t===""&&(i===32||i===9||i===10||i===13||i===12||i===34||i===39||i===60||i===62||i===61||i===96))return!1}return!0}function Jg(e){const t="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789",r=new Uint8Array(e);crypto.getRandomValues(r);let i="";for(let o=0;o<e;o++){const s=r[o]%62;i+=t.charAt(s)}return i}var Qg=8,Zg=class{_byKey=Object.create(null);_byValue=Object.create(null);getOrCreateByKey(e){let t=this._byKey[e];return t===void 0&&(t=Jg(Qg),this._byKey[e]=t,this._byValue[t]=e),t}getByValue(e){return this._byValue[e]}},yn=new Zg;function po(e,t){return t!==void 0&&!ai(e,t)?`%|{${yn.getOrCreateByKey(e)}}|%`:e}function ev(e){const t=yn.getByValue(e.slice(3,e.length-3));return t===void 0?e:t}function Q(e,t,n){return t!==void 0?ai(e,t)?e:`%|{${yn.getOrCreateByKey(e)}}|%`:`<!--${e}-->`}function tv(e){return e.replace(/>/g,">").replace(/</g,"<").replace(/&/g,"&")}function K(e){return e.startsWith("<!--")&&e.endsWith("-->")?tv(e.slice(4,-3)):e}function nv(e){const t=/^(IF|ELSE|ELSIF|ELSEIF|END|FOREACH|WHILE|NEXT|LAST|BREAK|DO|UNLESS|CONTINUE|SET|UNSET|DEFINE|INCLUDE)\b/i,n=/\w+\s*\(/;let r=e;const i=e.match(/\[%\s*([^%]*?)\s*%\]/);i&&(r=i[1]);const o=r.trim();return t.test(o)||n.test(o)}function rv(e,t,n){return t!==void 0?ai(e,t)?e:`%|{${yn.getOrCreateByKey(e)}}|%`:n||Xg(e)||nv(e)?`<!--${e}-->`:e}var He=zg(Q),$e=Wg(K),iv=Kg(Q),ov=Yg(K),Va=e=>{e.escape("<!--","-->",t=>t,!1),e.escape("<style","</style>",t=>t,!1),e.escape("<script","<\/script>",t=>t,!1),e.unescape("%|{","}|%",ev),e.escape("@{","}",Q,!0).unescape("<!--@{","}-->",K,!0),e.unescape("<!--%%%{{{","}}}%%%-->",t=>t.substring(10,t.length-9),!1),e.escape("${","}",po,!0),e.escape("{{","}}",po,!0),e.createSyntax("brace-percent").escape("{%","%}",Q).unescape("<!--{%","%}-->",K),e.createSyntax("brace-hash").escape("{#","#}",Q).unescape("<!--{#","#}-->",K),e.createSyntax("proscript").escape("[%","%]",rv,!0).unescape("<!--[%","%]-->",K,!0),e.createSyntax("getresponse").escape("[[IF","]]",Q).escape("[[if","]]",Q).escape("[[ELSE]]","",Q).escape("[[else]]","",Q).escape("[[ENDIF]]","",Q).escape("[[endif]]","",Q).unescape("<!--[[IF","]]-->",K).unescape("<!--[[if","]]-->",K).unescape("<!--[[ELSE]]","-->",K).unescape("<!--[[else]]","-->",K).unescape("<!--[[ENDIF]]","-->",K).unescape("<!--[[endif]]","-->",K),e.createSyntax("expert-sender").escape("<if",">",Q).escape("</if",">",Q).escape("<else",">",Q).escape("</else",">",Q).escape("<var ",">",Q,!0).unescape("<!--<if ",">-->",K).unescape("<!--</if",">-->",K).unescape("<!--<else ",">-->",K).unescape("<!--</else",">-->",K).unescape("<!--<var",">-->",K,!0),e.createSyntax("velocity").escape("#if",")",He).escape("#elseif",")",He).escape("#else","",Q).escape("#foreach",")",He).escape("#macro",")",He).escape("#set",")",iv,!0).escape("#parse",")",He).escape("#include",")",He).escape("#evaluate",")",He).escape("#end","",Q).escape("#break","",Q).escape("#stop","",Q).unescape("<!--#macro","-->",$e).unescape("<!--#if","-->",$e).unescape("<!--#elseif","-->",$e).unescape("<!--#else","-->",K).unescape("<!--#foreach","-->",$e).unescape("<!--#parse","-->",$e).unescape("<!--#include","-->",$e).unescape("<!--#evaluate","-->",$e).unescape("<!--#end","-->",K).unescape("<!--#break","-->",K).unescape("<!--#stop","-->",K).unescape("<!--#set","-->",ov,!0),e.createSyntax("mailchimp").escape("*|","|*",Q).unescape("<!--*|","|*-->",K)},vr="bare",sv=new Map;function av(e){return e?sv.get(e)??vr:vr}var qa=["brace-percent","brace-hash","proscript","getresponse","expert-sender","mailchimp","velocity"];function ho(e){return qa.includes(e)}function lt(e){return e==="bare"||e==="html-comment"}function kn(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function lv(e,t=n=>{}){const n={output:{},editor:{}};if(e==null)return n;let r;if(typeof e=="string"){if(!lt(e))return t(`templateDirectives: unknown form "${String(e)}", falling back to the default ("bare").`),n;r={output:e}}else if(typeof e=="object"&&!Array.isArray(e))r=e;else return t(`templateDirectives: expected a string or an object, got ${typeof e}. Ignored.`),n;for(const[d,f]of[["output",r.output],["editor",r.editor]])if(f!==void 0&&!lt(f))return t(`templateDirectives.${d}: unknown form "${String(f)}", configuration ignored.`),n;if(r.syntaxes!==void 0&&!kn(r.syntaxes))return t("templateDirectives.syntaxes: expected an object, configuration ignored."),n;if(r.syntaxes){for(const[d,f]of Object.entries(r.syntaxes))if(!(!ho(d)||f===void 0||lt(f))){if(!kn(f))return t(`templateDirectives.syntaxes.${d}: expected a form or an object, configuration ignored.`),n;for(const h of["output","editor"]){const y=f[h];if(y!==void 0&&!lt(y))return t(`templateDirectives.syntaxes.${d}.${h}: unknown form "${String(y)}", configuration ignored.`),n}}}if(r.output===void 0&&r.editor===void 0&&r.syntaxes===void 0)return n;const i=r.output??vr;let o=r.editor;i==="bare"&&r.editor==="html-comment"&&(t('templateDirectives: editor="html-comment" requires output="html-comment"; editor was reset to match output.'),o=void 0);const s=[];if(r.syntaxes)for(const d of Object.keys(r.syntaxes)){if(!ho(d)){t(`templateDirectives.syntaxes: unknown syntax id "${d}", entry ignored.`);continue}s.push(d)}else s.push(...qa);const a={},c={};for(const d of s){const f=r.syntaxes?.[d],h=kn(f)?f:void 0,y=(lt(f)?f:h?.output)??i;let b=h?.editor??o??y;y==="bare"&&b==="html-comment"&&(t(`templateDirectives.syntaxes.${d}: editor="html-comment" requires output="html-comment" for this id; editor was reset to "bare" for it.`),b="bare"),a[d]=y,c[d]=b}return{output:a,editor:c}}function za(e,t,n,r){for(let i=t;i<n;i++){const o=e[i];r.insideAttributeValue?r.attributeQuoteChar==='"'||r.attributeQuoteChar==="'"?o===r.attributeQuoteChar&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0):r.unquotedAttr&&/[\s>]/.test(o)&&(r.insideAttributeValue=!1,r.attributeQuoteChar=void 0,r.unquotedAttr=!1):o==="<"?r.insideTag=!0:o===">"?r.insideTag=!1:r.insideTag&&(o==='"'||o==="'")?(r.insideAttributeValue=!0,r.attributeQuoteChar=o,r.unquotedAttr=!1):r.insideTag&&/\S/.test(o)&&r.attributeQuoteChar===void 0&&e[i-1]==="="&&!['"',"'","`"].includes(o)&&(r.insideAttributeValue=!0,r.attributeQuoteChar="",r.unquotedAttr=!0)}}function gt(e,t){return e.start<t.end&&t.start<e.end}function mo(e,t,n,r,i=[]){if(n&&(t=t.filter(f=>f.isVariable)),!t.length)return[];const o=t.flatMap(f=>f.match(e).flatMap(h=>!Number.isInteger(h.start)||!Number.isInteger(h.end)||h.start<0||h.end>e.length||h.start>=h.end?[]:[{range:h,mapFn:f.mapFn,overrideBuiltins:f.overrideBuiltins,syntax:f.syntax,isVariable:f.isVariable}])).sort((f,h)=>f.range.start-h.range.start||f.range.end-h.range.end),s=[],a=i.slice().sort((f,h)=>f.start-h.start),c={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let d=0;for(const{range:f,mapFn:h,overrideBuiltins:y,syntax:b,isVariable:T}of o){if(r?(c.insideAttributeValue=!0,c.attributeQuoteChar='"'):za(e,d,f.start,c),d=f.end,a.some(_=>gt(_,f)))continue;const w=c.insideAttributeValue?c.attributeQuoteChar??"":void 0,g=e.substring(f.start,f.end),C=h(g,w,c.insideTag);C!==!1&&C!==g&&(s.push({range:f,text:C,overrideBuiltins:y,syntax:b,isVariable:T}),a.push(f))}return s.sort((f,h)=>f.range.start-h.range.start||f.range.end-h.range.end)}function cv(e,t){const n=t.reduce((a,{mapFn:c,start:d,end:f,syntax:h,isVariable:y})=>(a[d]||(a[d]=[]),a[d].push({value:f,mapFn:c,syntax:h,isVariable:y}),a),Object.create(null)),r=Object.keys(n).map(a=>a.replace(/[-[\]{}()*+?.,\\^$|]/g,"\\$&")).join("|"),i=new RegExp(r,"g"),o=[];let s;for(;(s=i.exec(e))!==null;){const a=s[0];o.push({start:s.index,startToken:a,endTokens:n[a]})}return o}function Ln(e,t,n,r,i=!1){const o=[];if(n&&(t=t.filter(d=>d.isVariable)),!t.length)return o;const s=cv(e,t),a={insideTag:!1,insideAttributeValue:!1,attributeQuoteChar:void 0,unquotedAttr:!1};let c=0;for(let d=0;d<s.length;d++){const{start:f,startToken:h,endTokens:y}=s[d];r?(a.insideAttributeValue=!0,a.attributeQuoteChar='"'):za(e,c,f,a),c=f;const b=a.insideAttributeValue?a.attributeQuoteChar??"":void 0;let T=!1;for(const{mapFn:w,value:g,syntax:C,isVariable:_}of y){let P=f+h.length,S=e.indexOf(g,P);for(;S!==-1;){let M=S,v=f+h.length,E=0;for(;M!==-1;){const p=e.indexOf(h,v);if(p!==-1&&p<M)E++,v=p+h.length,M=e.indexOf(g,v);else if(E>0)E--,v=M+g.length,M=e.indexOf(g,v);else break}if(M<0)break;const A=M+g.length,m=e.substring(f,A),l=w(m,b,a.insideTag);if(l===!1){P=S+Math.max(g.length,1),S=e.indexOf(g,P);continue}(i||l!==m)&&o.push({range:{start:f,end:A},text:i?m:l,syntax:C,isVariable:_});const u=s.findIndex(({start:p})=>p>=A);u>d?d=u-1:d=s.length,T=!0;break}if(T)break}}return o}function Xt(e,t){if(!t.length)return e;const n=t.slice().sort((i,o)=>o.range.start-i.range.start);let r=e;for(const{text:i,range:o}of n)r=r.slice(0,o.start)+i+r.slice(o.end);return r}var dv=class{_disposables=[];_escapes=[];_unescapes=[];_escapeMatchers=[];_unescapeMatchers=[];constructor(e=Va){const{_escapes:t,_unescapes:n}=this;e({createSyntax(r){return{...this,syntax:r}},escape(r,i,o,s){return t.push({start:r,end:i,mapFn:o,isVariable:s,syntax:this.syntax||r}),this},unescape(r,i,o,s){return n.push({start:r,end:i,mapFn:o,isVariable:s,syntax:this.syntax||r}),this}})}registerMatcherPair(e){const t=e.syntax||"matcher",n={syntax:t,match:e.escape.match,mapFn:e.escape.mapFn,isVariable:e.escape.isVariable,overrideBuiltins:e.escape.overrideBuiltins},r={syntax:t,match:e.unescape.match,mapFn:e.unescape.mapFn,isVariable:e.unescape.isVariable,overrideBuiltins:e.unescape.overrideBuiltins};this._escapeMatchers.push(n),this._unescapeMatchers.push(r);let i=!1;const o={dispose:()=>{i||(i=!0,this._escapeMatchers=this._escapeMatchers.filter(s=>s!==n),this._unescapeMatchers=this._unescapeMatchers.filter(s=>s!==r))}};return this.addDisposable(o),o}_collectMappings(e,t,n){const r=Ln(e,this._escapes,t,n),i=mo(e,this._escapeMatchers,t,n),o=i.filter(c=>c.overrideBuiltins).map(c=>c.range),s=r.filter(c=>!o.some(d=>gt(d,c.range))),a=i.filter(c=>c.overrideBuiltins||!s.some(d=>gt(c.range,d.range)));return[...s,...a].sort((c,d)=>c.range.start-d.range.start||c.range.end-d.range.end)}getMappings(e,t,n){return this._collectMappings(e,t,n)}_collectRevertMappings(e,t){const n=Ln(e,this._unescapes,t),r=mo(e,this._unescapeMatchers,t,!1),i=r.filter(a=>a.overrideBuiltins).map(a=>a.range),o=n.filter(a=>!i.some(c=>gt(c,a.range))),s=r.filter(a=>a.overrideBuiltins||!o.some(c=>gt(a.range,c.range)));return[...o,...s].sort((a,c)=>a.range.start-c.range.start||a.range.end-c.range.end)}getRevertMappings(e,t,n){const r=n?i=>i!==void 0&&n.has(i):i=>av(i)==="html-comment";return this._collectRevertMappings(e,t).filter(i=>i.isVariable||!r(i.syntax))}getDetectedMappings(e,t,n){return Ln(e,this._escapes,t,n,!0)}getEscapedText(e,t){return Xt(e,this.getMappings(e,t))}getUnescapedText(e,t,n){return Xt(e,this.getRevertMappings(e,t,n))}normalizeToPolicy(e,t){const n=o=>o===void 0?void 0:t[o],r=Object.values(t);let i=e;return r.includes("bare")&&(i=Xt(i,this._collectRevertMappings(i).filter(o=>n(o.syntax)==="bare"))),r.includes("html-comment")&&(i=Xt(i,this._collectMappings(i).filter(o=>!o.isVariable&&n(o.syntax)==="html-comment"&&o.text.startsWith("<!--")&&o.text.endsWith("-->")))),i}hasDetectedMappings(e,t,n){return this.getDetectedMappings(e,t,n).length>0}addDisposable(e){this._disposables.push(e)}dispose(){for(const e of this._disposables)e.dispose()}};function go(e){return e.replace("<script","<___script").replace("<\/script>","</___script>")}var vo=new dv(e=>{e.escape("<script","<\/script>",t=>go(t)).unescape("<___script","</___script>",t=>t.replace("<___script","<script").replace("</___script>","<\/script>")),e.escape("<script","/>",t=>go(t)).unescape("<___script","/>",t=>t.replace("<___script","<script")),Va(e)});function uv(e){const t=lv(e);if(!(Object.keys(t.output).length>0||Object.keys(t.editor).length>0))return ea();const n=new Set(Object.keys(t.output).filter(i=>t.output[i]==="html-comment")),r=new Set(Object.keys(t.output));return{isConfigured:()=>!0,toEditorForm:i=>vo.normalizeToPolicy(i,t.editor),toOutputForm:i=>vo.normalizeToPolicy(i,t.output),keepWrappedOnOutput:n,editorPolicy:t.editor,warnAboutUnconfiguredInput:Zs(r)}}function fv(e){let t;e.injectFactory(Cr,()=>{const n=e.getInstance(oe)?.layers().user.templateDirectives;return(!t||t.raw!==n)&&(t={raw:n,policy:uv(n)}),t.policy})}var pv=[{name:"rest.client",setup:Gm},{name:"auth.oauth",setup:rc},{name:"rest.identityHeaders",setup:jm},{name:"lifetime.destroyable",provides:[ni],setup:Bh},{name:"appInit",provides:[xe,Nr],setup:Nc},{name:"config",provides:[oe],setup:Fh},{name:"templateDirectives",provides:[Cr],setup:fv},{name:"email.documents",setup:im},{name:"show.initPipeline",provides:[Ae],setup:Vm},{name:"show",setup:Vg},{name:"locale.service",provides:[Tt],setup:km},{name:"locale.fromConfig",awaits:{services:[oe,Tt]},setup:Lm},{name:"canvas.early",setup:xp},{name:"canvas.previewSettings",setup:$p},{name:"canvas.sandboxExtensions",setup:Vp},{name:"canvas.sandboxScriptRelay",setup:Wp},{name:"canvas.headerSync",provides:[da],setup:Lp},{name:"canvas.ampSync",setup:$u},{name:"canvas.moduleBridge",setup:yf},{name:"canvas.port",setup:Qu},{name:"canvas.images",setup:Xu},{name:"canvas.edits",setup:Xf},{name:"canvas.blockContent",setup:Vf},{name:"canvas.sandboxFill",provides:[ei],setup:hh},{name:"canvas.reactions",setup:Op}],hv=class extends Error{cycle;constructor(e){super(`[units] цикл в зависимостях: ${e.join(" → ")}`),this.cycle=e}};function mv(e){const t=new Map;for(const n of e)for(const r of n.provides??[]){const i=t.get(r)??[];i.push(n),t.set(r,i)}return t}function gv(e,t){const n=[];for(const r of e.awaits?.services??[])for(const i of t.get(r)??[])i!==e&&n.push(i);return n}function Wa(e){const t=mv(e),n=[],r=new Set,i=[],o=new Set,s=a=>{if(!r.has(a)){if(o.has(a)){const c=i.indexOf(a);throw new hv([...i.slice(c),a].map(d=>d.name))}o.add(a),i.push(a);for(const c of gv(a,t))s(c);i.pop(),o.delete(a),r.add(a),n.push(a)}};for(const a of e)s(a);return n}var bo;function li(e){const t=e.getInstance(se);if(t)return t;e.getInstance(U)||e.inject(U,new ie);const n=Ee();e.inject(se,n),bo??=Wa(pv);for(const r of bo)r.setup(e);return n}function vv(e){}var bv=[{name:"save.previewFollow",setup:vv}],yo=F("plugin.lateUnitsInstalled");function yv(e){if(!e.getInstance(yo)){e.inject(yo,!0);for(const t of Wa(bv))t.setup(e)}}function Ev(e,t){return{project:Number(e),app_id:t?.app_id||0,app_config:t?.app_config||{},user:t?.user}}function _v(e){if(!e)return;const t=Mr(e)?.data,n=t?.data?.scope??t?.scope;return(Array.isArray(n)?n.flatMap(r=>typeof r=="string"?r.split(/\s+/):[]):typeof n=="string"?n.split(/\s+/):[]).find(r=>/^project_\d+$/.test(r))?.replace(/^project_/,"")||void 0}var wv=ot(e=>{let t,n,r;return{async setOptions(i){const o=r!==i.getAuthToken,s=!Ce(t,i.user),a=n!==i.project;if(r=i.getAuthToken,t=i.user,n=i.project,!(!e.getInstance(Te)||!i.getAuthToken)&&!(!o&&!s&&!a))try{const c=await i.getAuthToken(i.user,i.project);e.inject(Zl,Promise.resolve(c||""));const d=_v(c);if(!d)return;e.inject(ql,d);const f=e.getInstance(xe),h=f?await f.catch(()=>{}):void 0;e.inject(xe,Promise.resolve(Ev(d,h)))}catch{}}}});function Sv(e,t){if(e.getInstance(yi))return;e.inject(yi,!0);const n=ue(e,j.FILE_PROXY_EVENT_ID);t.addDisposable(n(async({url:r})=>(await fetch(r)).blob(),Number.MIN_VALUE))}var Iv=ot(e=>{let t,n=!1;return{setOptions(r){const i=n;if(n=!0,!Lt(r)){t&&(Ih(e),ti(r)),t=void 0;return}const o=gn(r);if(!o||t===o&&e.getInstance(Te))return;t=o,e.inject(Te,o);const s=e.getInstance(U);s&&Sv(e,s)}}}),Cv=ot(e=>{const t=e.getInstance(U),n=ue(e,Ko),r=B(n),i=t.addDisposable(new et(r));return{setOptions({handleLoad:o}){i.setListener(o)},instance:{handleLoad:r},dispose:()=>t.dispose()}});function Ka(e,t,n=!0){const r=e,i=t;for(const o of Object.keys(i)){const s=i[o];s!=null&&(n&&typeof s=="object"?r[o]=Ka(r[o]||{},s,!0):r[o]=s)}return e}async function Tv(e){const t=(await ac(()=>import("./static/esm/2490dab8.js").then(n=>bl(n.default)),[],import.meta.url)).default;return new Promise((n,r)=>{t.load({google:{families:[e]},classes:!1,active:()=>n(),inactive:()=>r(new Error(`Шрифт не загрузился: ${e}`))})})}var Ya=F("EditorOptions"),br=Xl;function Av(e){const t=typeof e.font_family=="string"?`${e.font_family}, sans-serif`:void 0,n=e.word_wrap===void 0?void 0:e.word_wrap?"on":"off";return{tabSize:e.tab_size,fontFamily:t,fontSize:e.font_size,wordWrap:n,insertSpaces:e.insert_spaces,minimap:{enabled:e.minimap}}}function Rv(e){return e.getOrCreateInstance(Ya,()=>{const t=Ee(br);let n=br.fontFamily;return t.watch(r=>{!r.fontFamily||r.fontFamily===n||(n=r.fontFamily,Promise.resolve(Tv(r.fontFamily.split(",")[0])).catch(()=>{}))}),t})}function Pv(e){return e?.getInstance(Ya)?.get()??br}function Dv(e,t={}){const n=Rv(e);n.set(Ka({...n.get()},Av(t)))}function Ov(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 xv(e){return{fontSize:e.fontSize,fontFamily:e.fontFamily,tabSize:e.tabSize,wordWrap:e.wordWrap!=="off",minimap:e.minimap?.enabled,insertSpaces:e.insertSpaces}}var Mv=F("plugin.publicConfig");function yr(e){return e.getInstance(oe)?.get()??{}}function Eo(e){return e.getInstance(oe)?.layers()??{base:{},profile:{},serverSide:{},user:{},local:{},advancedConfigs:{}}}function _o(e){const t=Ea(e),n=yr(e);return{...n,locale:n.locale||"en_US",theme:n.theme||"light",editor:xv(Pv(e)),codeModeDirection:t.isCodeMode?t.direction:"none"}}function wo(e){return e.getInstance(oe)?.get()!==void 0}function kv(e){const t=zo(),n=fe(e,Yo);let r,i,o=!1;const s=async()=>{try{return e.getInstance(xe)===void 0?{}:(await e.getInstanceAsync(xe))?.app_config||{}}catch{return{}}},a=async({onlyChangedCodeMode:h=!1}={})=>{await e.getInstance(oe)?.ready(),ts(e).set(yr(e).revisionService===!0);const{codeModeDirection:y,editor:b}=yr(e);b&&Dv(e,Ov(b)),y!==void 0&&!(h&&y===i)&&(i=y,y==="none"?dr(e,!1):(dr(e,!0),wh(e,y)))},c=async()=>{if(!wo(e))return;const h=_o(e),y=JSON.stringify(h);y!==r&&(r=y,await n.fire(h))},d=async h=>{const y=e.getInstance(oe),b={advancedConfigs:Eo(e).advancedConfigs,serverSide:await s(),user:h};y?.setAdvancedConfigs({...b.advancedConfigs,...b.user?.advancedConfigs}),y?.replace(b.user,"user"),y?.replace(b.serverSide,"server"),await a(),await c()},f=h=>{const{commonStyles:y,...b}=h;return"commonStyles"in h&&Hp(e,y===void 0?void 0:y),b};return{queue:t,reactToConfig:a,emitConfigChanged:c,resolveServerSideConfig:s,getConfig:()=>wo(e)?_o(e):{},setConfig:t.decorate(async h=>{await d(f(h))}),updateConfig:t.decorate(async h=>{const y=f(h);await d({...Eo(e).user,...y})}),announceAssembled(){o||(o=!0,e.getInstance(oe)?.ready().then(t.decorate(async()=>{await a({onlyChangedCodeMode:!0}),await c()})))}}}function Xa(e){return e.getOrCreateInstance(Mv,()=>kv(e))}function Lv(e){const t=Xa(e);return{getConfig:()=>t.getConfig(),setConfig:n=>t.setConfig(n),updateConfig:n=>t.updateConfig(n)}}var Nv=ot(e=>{const t=e.getInstance(U),n=t.addDisposable(new Me),r=t.addDisposable(new Me),i=kt(e,Yo),o=B(n.event),s=B(r.event),a=Ba(B(i.event),e),c=t.addDisposable(new et(o)),d=t.addDisposable(new et(s)),f=t.addDisposable(new et(a));return{instance:{handleSetOptions:o,handleOptionsChanged:s,handleConfigChanged:a},async setOptions(h){c.setListener(h.handleSetOptions),d.setListener(h.handleOptionsChanged),f.setListener(h.handleConfigChanged),Xa(e).announceAssembled(),await n.fire(h),await r.fire(h)},dispose(){}}}),Nn,Ja="core";function Fv(){const e=window.__useblocks__?.require;return typeof e!="function"?Promise.reject(new Error("[loadCore] AMD loader is unavailable")):new Promise((t,n)=>{e([Ja],r=>t(r),r=>n(r instanceof Error?r:new Error("[loadCore] Failed to require core module")))})}function jv(e){const t=window.__useblocks__?.require?.warm;return typeof t!="function"?Bt().then(()=>{}):t([Ja],e)}function Bt(){return Nn===void 0&&(Nn=Fv().then(e=>(wt()&&e.installDiagnostics().catch(t=>{}),e))),Nn}var Fn=null,jn=null;async function Bv(e){typeof e?.prefetch=="function"&&await e.prefetch()}function ci(){return Fn||(Fn=Bt().then(()=>{})),Fn}function Qa(e){return jn||(jn=Bv(e)),jn}function Uv(){return Qa(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}function Hv(){const e=typeof window.__useblocks__<"u"?window.__useblocks__:void 0,t=e?.__compatMissingReason;return e&&(e.__compatMissingReason=void 0),typeof t=="string"?t:void 0}function $v(e){return Promise.all([ci(),Qa(e)]).then(()=>{})}function Gv(e){const t=e?.preload?.start??e?.startupPrefetchMode;return t==="eager"||t==="idle"||t==="manual"||t==="off"?t:"idle"}function So(e,t){const n=e?.preload?.execute!==!1;Promise.resolve().then(()=>jv(t?{priority:t}:void 0)).then(()=>(Jr(t?{priority:t}:void 0),n?ci():void 0)).catch(()=>{})}function Vv(e){const t=Gv(e);if(t==="eager")So(e);else if(t==="idle"){const n=()=>So(e,"low");document.readyState==="complete"?n():window.addEventListener("load",n,{once:!0})}}var Za="PluginRegistry";function qv(e=Sl()){return e.getOrCreateInstance(Za,()=>new mc)}var zv=new gc(()=>qv()),Wv=["handleAIImageRequest","handleAITextRequest","handleCloneEmail","handleConfigChanged","handleDestroy","handleEmailAutosave","handleEmailChanged","handleEmailInit","handleError","handleFileProxy","handleHtmlChanged","handleLimitUsage","handleLivePreviewEmail","handleLoad","handleLoadImage","handleNextButtonClick","handleNotify","handleOptionsChanged","handlePreheaderChanged","handlePreviewEmail","handlePreviousButtonClick","handleReadBlocks","handleReadComments","handleReadCommonBlocks","handleReadEmail","handleReadEmailAutosave","handleReadEmailRevisions","handleReadLocale","handleReadTemplateBlocks","handleRemoveBlock","handleRemoveComment","handleRemoveEmail","handleRemoveEmailAutoSave","handleSaveBlock","handleSaveButtonClick","handleSaveComment","handleSaveEmail","handleSetOptions","handleShareEmail","handleSubjectChanged","handleSuccess","handleTestEmailModal","handleTestEmailSend","handleTranslate","handleUrlProxy","handleValidate"],Kv=["compileEmail","getBlocks","getComments","getEmail","getEmailRevisions","getEmailSnapshot","save","setConfig","show","updateConfig","useAsync","validateCode","waitPlugin"],dn=new Map([...Wv.map(e=>[e,"event"]),...Kv.map(e=>[e,"async"]),["setEmailMeta","queued"],["setBlockMeta","queued"],["notify","queued"],["getConfig","sync"],["use","sync"],["getElement","element"],["getCodeErrors","codeErrors"],["container","field"],["undoRedoService","field"]]),Yv=new Map([["use","use `useAsync()` or await `ready` first"]]);function Xv(e){return Yv.get(e)??"await `ready` first"}var Jv=new Set(["async","queued"]),Qv=Symbol.for("emailmaker.earlyCtxPlaceholder");function Io(e){return e[Qv]=!0,e}function Zv(e){return new Error(`[emailmaker] ${e}() is not available in a plugin constructor: the editor core is still loading. Call it from init() or later (${Xv(e)}).`)}function eb(e){return new Error(`[emailmaker] ${e}() is missing from the editor instance after the core has loaded.`)}function tb(e){return[...dn].filter(([t,n])=>n!=="field"&&e[t]===void 0).map(([t])=>t).sort((t,n)=>t.localeCompare(n))}function nb(e,t){for(const n of tb(e)){const r=dn.get(n);if(r!==void 0&&Jv.has(r)){const i=async(...o)=>{await t;const s=e[n];if(typeof s!="function"||s===i)throw eb(n);return s.apply(e,o)};e[n]=Io(i);continue}e[n]=Io(()=>{throw Zv(n)})}}function rb(e,t,n){e.getInstanceAsync(tt).then(()=>{kt(e,j.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_CREATE_ERROR",data:{plugin:t},innerException:n})},()=>{})}function ib(e,t){e.getInstanceAsync(tt).then(()=>{kt(e,j.ON_NOTIFICATION).fire({type:"error",id:"PLUGIN_LOAD_ERROR",data:{plugin:t.name,url:t.url,message:t.error.message},innerException:t.error})},()=>{})}var ob=ot(e=>{let t;function n(){return new Promise(i=>{const o=e.getOrCreateInstance(Dr,()=>new Set),s=()=>{o.delete(s),i()};o.add(s)})}function r(){if(!t)throw new Error("PluginCollection not initialized. Call init() first.");return t}return{async setOptions(i){const o=e.getInstance(hn),s=e.getInstance(Za);if(!t){t=new hc(o,s,{ensureHostRuntimeReady:Uv,explainScriptFailure:Hv,openEarlyWindow:()=>Ng(e),reportLoadFailure:d=>ib(e,d)}),e.inject(xr,t);const c=t.onLifecycle(d=>{d.type==="create:error"&&rb(e,d.name,d.error)});e.getInstance(U)?.addDisposable(c)}const a=i?.plugins||[];o&&(Ls(e),a.length>0&&nb(o,n()),await t.setPlugins(a))},instance:{use(i){return typeof i=="function"?r().useByCtor(i):r().useByKey(i)},useAsync(i){return r().useAsync(i)},waitPlugin(i){return r().waitFor(i)}},dispose(){t?.dispose(),t=void 0}}}),el=class{_listeners=[];add(e,t=0,n){const r={fn:n?e.bind(n):e,priority:t};return this._listeners.push(r),{dispose:()=>{const i=this._listeners.indexOf(r);i>=0&&this._listeners.splice(i,1)}}}async run(e){const t=[...this._listeners].sort((n,r)=>r.priority-n.priority);for(const{fn:n}of t){const r=await n(e);r!==null&&typeof r=="object"&&!Array.isArray(r)&&!(r instanceof Date)&&!(r instanceof RegExp)&&Object.assign(e,r)}return e}},sb=F("ELEMENT_INSERT_HTML_PIPELINE"),ab=F("BLOCK_INSERT_HTML_PIPELINE"),lb="application_block_inserted",cb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(ab,()=>new el).add(e,t??0,n)}handleInject(e,t,n){const r=this._container.getOrCreateInstance(Ot,()=>new xt),i=n?e.bind(n):e;return r.addListener(lb,i,t)}},di=F("ComponentRegistry"),db=F("ComponentRegistryGate");function ui(){return nt.getOrCreateInstance(db,()=>({pending:[]}))}function ub(e=di){return ui().factory!==void 0||nt.getInstance(e)!==void 0}function Er(e,t,n=di){if(ub(n)){t(un(e,n));return}ui().pending.push(()=>t(un(e,n)))}function un(e,t=di){const n=nt.getInstance(t);if(n)return n;const r=ui().factory;if(!r)throw new Error("[extensions] component registry is not loaded yet — UI work starts at init()");return nt.getOrCreateInstance(t,r)}var fb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}getNames(){return new Promise(e=>{const t=[];let n=!1;const r=o=>{if(!n){n=!0;for(const s of t)s.dispose();e(o)}};t.push(this._container.addService(Ht,{execute:o=>{r(o.value.map(s=>({name:s.name,html:s.html})))}}));const i=this._container.getInstance(jl)?.watch(o=>{o&&r([])});i&&(n?i.dispose():t.push(i))})}update(e,t){const n=this._container;return n.addService(Ht,{execute:r=>{const i=un(n),o=r.value.find(s=>s.name===e);if(o){const{icon:s,title:a,fallbackTooltip:c,...d}=t;s&&(o.icon=i.getReactNode(s)),a&&(o.title=i.getReactNode(a)),c&&(o.fallbackTooltip=i.getReactNode(c)),Object.assign(o,d)}}})}delete(e){this._container.addService(Ht,{execute:t=>{const n=t.value.findIndex(r=>r.name===e);n>=0&&t.value.splice(n,1)}})}insert(e,t){const n=this._container;return n.addService(Ht,{execute:r=>{const i=un(n);r.value.splice(t??r.value.length,0,{...e,title:i.getReactNode(e.title),icon:i.getReactNode(e.icon),fallbackTooltip:i.getReactNode(e.fallbackTooltip)})}})}handleBeforeInject(e,t,n){return this._container.getOrCreateInstance(sb,()=>new el).add(e,t??0,n)}handleInject(e,t,n){return Ze(this._container,Nl).event(r=>{e({name:r.name,className:r.className||"",html:r.html})},t,n)}},pb=class{_messageService;constructor(e){this._messageService=e.container.getOrCreateInstance(Ot,()=>new xt)}send(e,t,n){this._messageService.send(e,t,n)}sendAsync(e,t,n=!0){return this._messageService.sendAsync(e,t,n)}addListener(e,t,n){return this._messageService.addListener(e,t,n)}addListenerAsync(e,t,n=0){return this._messageService.addListenerAsync(e,t,n)}onInit(e,t=!0,n=0){return this._messageService.onInit(e,t,n)}isInited(){return this._messageService.isInited()}};function hb(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0))}function Co(e,t){if(!t)return;const n=r=>r===void 0?void 0:e.getReactNode(r);return{...t,footer:n(t.footer),okText:n(t.okText),cancelText:n(t.cancelText),closeIcon:n(t.closeIcon)}}var mb=class{_context;_showModalEmitter;_closeModalEmitter;_updateModalEmitter;constructor(e){this._context=e;const t=e.container;this._showModalEmitter=Ze(t,ec),this._closeModalEmitter=Ze(t,Cl),this._updateModalEmitter=Ze(t,Il)}get _container(){return this._context.container}show(e){const t=`modal_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,n=e.modalProps;return Er(this._container,r=>{this._showModalEmitter.fire({...e,content:r.getReactNode(e.content),title:r.getReactNode(e.title),id:t,modalProps:Co(r,n)})}),t}close(e){this._closeModalEmitter.fire(e)}closeAll(){this._closeModalEmitter.fire()}update(e,t){const n=t.modalProps;Er(this._container,r=>{this._updateModalEmitter.fire(hb({...t,content:r.getReactNode(t.content),title:r.getReactNode(t.title),id:e,modalProps:Co(r,n)}))})}},gb=class{_registration;_loadedDisposable;loaded;ready;_loadedSettled=!1;_readySettled=!1;_readyListeners=new Set;constructor(e,t){this._registration=e,this._loadedDisposable=t,this.loaded=new Promise((n,r)=>{this._resolveLoaded=()=>{this._loadedSettled||(this._loadedSettled=!0,n())},this._rejectLoaded=i=>{this._loadedSettled||(this._loadedSettled=!0,r(i))}}),this.ready=new Promise((n,r)=>{this._resolveReady=()=>{this._readySettled||(this._readySettled=!0,n())},this._rejectReady=i=>{this._readySettled||(this._readySettled=!0,r(i))}})}_resolveLoaded=()=>{};_rejectLoaded=()=>{};_resolveReady=()=>{};_rejectReady=()=>{};resolveLoaded(){this._resolveLoaded()}resolveReady(){this._resolveReady();for(const e of Array.from(this._readyListeners))try{e()}catch{}}onReady(e){return this._readyListeners.add(e),this._readySettled&&e(),{dispose:()=>{this._readyListeners.delete(e)}}}rejectLoad(e){this._rejectLoaded(e),this._rejectReady(e)}rejectReady(e){this._rejectReady(e)}dispose(){this._registration.dispose(),this._loadedDisposable.dispose(),this._readyListeners.clear();const e=new Error("Sandbox script registration disposed before completion.");this.rejectLoad(e),this.rejectReady(e)}},vb=class{_context;constructor(e){this._context=e}get _container(){return this._context.container}get _messageService(){return this._container.getOrCreateInstance(Ot,()=>new xt)}_createScriptHandle(e,t){const n=this._messageService.addListener(Rr,i=>{if(i.key===e){if(i.phase==="load"&&i.status==="success"){r.resolveLoaded();return}if(i.phase==="ready"&&i.status==="success"){r.resolveReady();return}if(i.phase==="load"){r.rejectLoad(new Error(i.error||`Sandbox script "${e}" failed to load.`));return}r.rejectReady(new Error(i.error||`Sandbox script "${e}" failed to initialize.`))}}),r=new gb(t,n);return r}registerSandboxCSS(e){return this._container.addService(Xe,{type:"link",key:e,parent:"head",attributes:{rel:"stylesheet",type:"text/css",href:e}})}registerSandboxCSSCode(e,t){return this._container.addService(Xe,{type:"style",key:e,parent:"head",attributes:{type:"text/css"},innerHTML:t})}registerSandboxScript(e){const t=this._container.addService(Xe,{type:"script",key:e,parent:"head",attributes:{src:e,type:"text/javascript"}});return this._createScriptHandle(e,t)}registerSandboxScriptCode(e,t){const n=this._container.addService(Xe,{type:"script",key:e,parent:"head",attributes:{type:"text/javascript"},innerHTML:t});return this._createScriptHandle(e,n)}},bb=new Set([Symbol.for("react.element"),Symbol.for("react.transitional.element")]);function _r(e){if(typeof e!="object"||e===null)return!1;const t=e.$$typeof;return typeof t=="symbol"&&bb.has(t)}function tl(){const e=globalThis.crypto;if(e&&typeof e.randomUUID=="function")return e.randomUUID();if(e&&typeof e.getRandomValues=="function"){const t=new Uint8Array(16);return e.getRandomValues(t),Array.from(t,n=>n.toString(16).padStart(2,"0")).join("")}return`nohwcrypto-${Date.now()}`}function Bn(){return`__settingsPanel:${tl()}`}function Un(e,t){return{type:e,props:t}}function yb(e){return typeof e=="object"&&e!==null&&"type"in e&&"props"in e&&!_r(e)}function To(e,t,n){if(t==null||typeof t=="number"||typeof t=="boolean"||typeof t=="string")return t;if(_r(t)){const r=Bn();return n(e.add(r,t)),Un(r,{})}if(typeof t=="function"){const r=Bn();return n(e.add(r,t)),Un(r,{})}if(yb(t)){const r=t.type;if(typeof r=="string")return t;if(_r(r)||typeof r=="function"){const i=Bn();return n(e.add(i,r)),Un(i,t.props)}return t}return t}var Eb=class{_context;_panelRegistrationDisposables=[];constructor(e){this._context=e}get _container(){return this._context.container}_clearPanelRegistrations(){for(const e of this._panelRegistrationDisposables)e.dispose();this._panelRegistrationDisposables.length=0}_trackRegistration(e){this._panelRegistrationDisposables.push(e)}showSettingsPanel(e){this._clearPanelRegistrations();const t=e.instanceKey??tl();Er(this._container,n=>{const r=s=>this._trackRegistration(s),i=To(n,e.content,r),o=e.advancedTabs?.map(s=>({...s,content:To(n,s.content,r)}));Ze(this._container,bi).fire({...e,content:i,advancedTabs:o,instanceKey:t,type:Fl})})}closeSettingsPanel(){this._clearPanelRegistrations(),Ze(this._container,bi).fire(null)}},nl={SandboxScriptApi:vb,ElementsApi:fb,BlocksApi:cb,MessageService:pb,SettingsPanelApi:Eb,ModalApi:mb};function Hn(e,t,n,r={}){const i=Object.assign({},e);for(const[o,s]of Object.entries(t))if(s!==void 0)if(n.includes(o)&&typeof s=="object"&&s!==null){const a=i[o],c=r[o]??{};i[o]=Object.assign({},typeof a=="object"&&a!==null?a:c,s)}else i[o]=s;return i}var me={border:{all:null,top:null,right:null,bottom:null,left:null},borderRadius:{all:5,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},borderRadiusCards:{all:10,topLeft:null,topRight:null,bottomRight:null,bottomLeft:null},padding:{all:null,top:null,right:null,bottom:null,left:null}},_b={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",lineHeight:21,lineHeightDim:"px",color:"#5a5a5a",contrastColor:"#FFFFFF",textAlign:"left",paddingBottom:10,paddingBottomDim:"px"},$n={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:24,fontSizeDim:"px",lineHeight:32,lineHeightDim:"px",color:"#333333",contrastColor:"#FFFFFF",textAlign:"left",paddingTop:20,paddingTopDim:"px",paddingBottom:20,paddingBottomDim:"px",letterSpacing:0,letterSpacingDim:"px",bold:!0,italic:!1},Ao={color:"#1C52DC",contrastColor:"#FFFFFF",underline:!0},We={fontFamily:["Safe Fonts","-apple-system, 'Segoe UI', 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif"],fontSize:16,fontSizeDim:"px",letterSpacing:0,letterSpacingDim:"px",color:"#FFFFFF",contrastColor:"#1C52DC",bold:!1,italic:!1,backgroundColor:"#1C52DC",contrastBackgroundColor:"#FFFFFF",marginTop:10,marginTopDim:"px",marginBottom:10,marginBottomDim:"px",border:me.border,borderRadius:me.borderRadius,textAlign:"center",padding:me.padding},Ro={backgroundColor:"#FFFFFF",contrastBackgroundColor:"#1C52DC",padding:me.padding},Gn={contrastBackgroundColor:"#1C52DC",contrastTextColor:"#FFFFFF",baseBackgroundColor:"#F8F8F8",baseTextColor:"#333333",border:me.border,borderRadius:me.borderRadiusCards};function wb(e){return{..._b,...e}}function Sb(e){return{...$n,...e,bold:e?.bold??$n.bold,italic:e?.italic??$n.italic}}function Ib(e){return{...Ao,...e,underline:e?.underline??Ao.underline}}function Cb(e){return{...We,...e,bold:e?.bold??We.bold,italic:e?.italic??We.italic,border:{...We.border,...e?.border},borderRadius:{...We.borderRadius,...e?.borderRadius},padding:{...We.padding,...e?.padding}}}function Tb(e){return{...Ro,...e,padding:{...Ro.padding,...e?.padding}}}function Ab(e){return{...Gn,...e,border:{...Gn.border,...e?.border},borderRadius:{...Gn.borderRadius,...e?.borderRadius}}}function Vn(e={}){return{backgroundColor:e.backgroundColor||"",backgroundImage:(e.backgroundImage||[]).map(t=>({type:"url",value:t?.value||""})),backgroundPositionX:e.backgroundPositionX||"",backgroundPositionY:e.backgroundPositionY||"",backgroundRepeat:e.backgroundRepeat||"",backgroundSize:e.backgroundSize||"",backgroundColorContent:e.backgroundColorContent||"",textStrong:e.textStrong||!1,textItalic:e.textItalic||!1,textUnderline:e.textUnderline||!1,width:e.width,responsive:e.responsive}}function Po(e){let t={...Pr};try{e&&e!=="{}"&&(t=JSON.parse(e))}catch{}return t}function qn(e){return{text:wb(e.text),headings:Sb(e.headings),links:Ib(e.links),buttons:Cb(e.buttons),block:Tb(e.block),cards:Ab(e.cards)}}var Do=F("EmailSettingsPort"),Rb=1e4,rl=class{_editor;_layoutSettingsChanged=new Yn;_contentStylesChanged=new Yn;_messageSubscription;_messageSubscriptionPromise;_prevLayoutSnapshot;_prevContentSnapshot;constructor(e){this._editor=e}onChangeEmailLayoutSettings(e){const t=this._layoutSettingsChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentLayoutSettings()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}onChangeEmailContentStyles(e){const t=this._contentStylesChanged.event(e);return this._ensureMessageSubscription(),this._replayToEarlyPlugin(e,()=>this._getCurrentContentStyles()),{dispose:()=>{t.dispose(),this._disposeMessageSubscriptionIfUnused()}}}_replayToEarlyPlugin(e,t){if(!ja(this._editor.container)||!Je(this._editor.container)?.current()?.get().attributes.is_inited)return;const n=t();queueMicrotask(()=>e(n))}_disposeMessageSubscriptionIfUnused(){this._layoutSettingsChanged.hasListeners()||this._contentStylesChanged.hasListeners()||(this._messageSubscription?.dispose(),this._messageSubscription=void 0)}_settings(e=this._editor.container){const t=e.getInstance(Do);if(!t)throw new Error("[extensions] email settings are not loaded yet — UI work starts at init()");return t}_getCurrentLayoutSettings(){return Vn(this._settings().read())}_getCurrentContentStyles(){const e=Je(this._editor.container)?.current()?.get().attributes.common_styles;return qn(Po(e))}_getLayoutSnapshot(e){return JSON.stringify(e)}_getContentSnapshot(e){return JSON.stringify(e)}async _ensureMessageSubscription(){if(!this._messageSubscription){if(this._messageSubscriptionPromise)return this._messageSubscriptionPromise;this._messageSubscriptionPromise=(async()=>{if(await this._editor.container.getInstanceAsync(Do),this._messageSubscription)return;const e=this._editor.container.getOrCreateInstance(Ot,()=>new xt),t=this._getCurrentLayoutSettings(),n=this._getCurrentContentStyles();this._prevLayoutSnapshot=this._getLayoutSnapshot(t),this._prevContentSnapshot=this._getContentSnapshot(n),this._messageSubscription=e.addListener(r=>{const i=r?.data,o=i?.operation;if(o===$.APPLICATION_EMAIL_SETTINGS_SET){const c=Vn(i?.settings),d=this._getLayoutSnapshot(c);d!==this._prevLayoutSnapshot&&(this._prevLayoutSnapshot=d,this._layoutSettingsChanged.fire(c));return}if(o!==$.APPLICATION_COMMON_STYLES_UPDATE)return;const s=qn(r.data?.settings?.commonStyles??{...Pr}),a=this._getContentSnapshot(s);a!==this._prevContentSnapshot&&(this._prevContentSnapshot=a,this._contentStylesChanged.fire(s))})})();try{await this._messageSubscriptionPromise}finally{this._messageSubscriptionPromise=void 0}}}async getEmailLayoutSettings(){return await this._waitForEmailSettingsFromIframe(),this._getCurrentLayoutSettings()}async setEmailLayoutSettings(e){await this._waitForEmailSettingsFromIframe();const t=this._settings(),n={...t.read(),...e};t.write(n);const r=Vn(n);this._prevLayoutSnapshot=this._getLayoutSnapshot(r),this._layoutSettingsChanged.fire(r)}async _waitForEmailSettingsFromIframe(e=Rb){const t=Je(this._editor.container)?.current()?.get().attributes.is_inited,n=this._settings().read();if(t&&n&&Object.keys(n).length>0&&(n.backgroundColor||n.backgroundImage?.[0]?.value||n.width?.value||n.responsive!==void 0)||t)return;const r=this._editor.container,i=ue(r,j.ON_EMAIL_INIT_ID);return new Promise(o=>{let s=!1,a;const c=()=>{a&&(clearTimeout(a),a=void 0)},d=i(()=>{s||(s=!0,c(),d.dispose(),o())});a=setTimeout(()=>{s||(s=!0,d.dispose(),o())},e)})}async getEmailContentStyles(){return this._getCurrentContentStyles()}async setEmailContentStyles(e){const t=Je(this._editor.container)?.current();if(!t)return;const n=Po(t.get().attributes.common_styles);e.text!==void 0&&(n.text={...n.text||{},...e.text}),e.headings!==void 0&&(n.headings={...n.headings||{},...e.headings}),e.links!==void 0&&(n.links={...n.links||{},...e.links}),e.buttons!==void 0&&(n.buttons=Hn(n.buttons||{},e.buttons,["border","borderRadius","padding"],{border:me.border,borderRadius:me.borderRadius,padding:me.padding})),e.block!==void 0&&(n.block=Hn(n.block||{},e.block,["padding"],{padding:me.padding})),e.cards!==void 0&&(n.cards=Hn(n.cards||{},e.cards,["border","borderRadius"],{border:me.border,borderRadius:me.borderRadiusCards}));const r=JSON.stringify(n);Ct(t,{common_styles:r},{source:"system"}),this._settings().markAppearanceChanged();const i=qn(n);this._prevContentSnapshot=this._getContentSnapshot(i),this._contentStylesChanged.fire(i)}},Pb={...nl,EmailSettingsApi:rl},Db={...nl},xE={...Db,EmailSettingsApi:rl},Ob={...Pb};function xb(){zv.addAll(Ob)}var Mb=[ot(()=>{xb()}),Cv,Nv,Iv,zl,wv,tc];async function kb(){return(await Bt()).asyncMixins}var Lb=ob,Nb=e=>{let t=null,n=!1;return{instance:{},async setOptions(r){if(!t&&!n){let i;try{i=await kb()}catch(s){throw e.failPendingWaits(s),s}t=i(e);const o=await e.getInstanceAsync(hn);Object.assign(o,t.instance||{});for(const s of e.getInstance(Dr)??[])s()}t&&await t.setOptions(r)},dispose(){t?.dispose(),n=!0}}},Fb=Ql([...Mb]);function zn(){let e,t=!1;const n=new Map,r=new Map;function i(){for(const o of r.values())o();r.clear()}return{event(o,s,a){const c=Symbol("subscription");return t||(n.set(c,{listener:o,priority:s,thisArg:a}),e&&r.set(c,e(o,s,a))),()=>{n.delete(c),r.get(c)?.(),r.delete(c)}},attach(o){i(),e=o;for(const[s,{listener:a,priority:c,thisArg:d}]of n)r.set(s,o(a,c,d))},dispose(){t=!0,i(),n.clear(),e=void 0}}}function jb(e){const t=zn(),n=zn(),r=zn();return e.getInstance(U)?.addDispose(()=>{t.dispose(),n.dispose(),r.dispose()}),e.getInstanceAsync(tt).then(i=>{t.attach(i.onNotify),n.attach(i.onError),r.attach(i.onSuccess)},()=>{}),{handleNotify:t.event,handleError:n.event,handleSuccess:r.event,notify(i){const o=e.getInstance(tt);if(o){o.notify(i);return}e.getInstanceAsync(tt).then(s=>s.notify(i),()=>{})}}}var il=F("CodeErrors"),Bb=[];function Ub(e){return e?.getInstance(il)?.get()??Bb}function Hb(e){return e?.getInstance(il)!==void 0}var $b=class extends ie{_container;_dataSources;_currentEmail;_blockMetaWrites=Promise.resolve();constructor(e){super(),this._container=e,this._dataSources=jt(e),this.addDisposable(ue(e,j.ON_EMAIL_CHANGED_ID)(t=>{this._currentEmail=t}))}openEmail(){return ka(this._container,this._currentEmail)}async getBlocks(){const e=await this._readProjectBlocks();return await this._blockMetaWrites,(await this._dataSources.blocks.cache.values()).filter(t=>String(t.project)===String(e)).map(t=>ht(t,this._container))}async _readProjectBlocks(){const e=await eg(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=>mt(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=>mr(n,this._container))}async getEmailSnapshot(){return de(this.openEmail(),this._container)}setEmailMeta(e){const t=si(this._container);if(!t)return;const n=t.get().attributes.meta;Ct(t,{meta:On({meta:n},e).meta});const r=t.get().serverId;r!=null&&this._dataSources.emails.cache.addOrUpdate(r,i=>i&&On(i,e))}setBlockMeta(e,t){const n=async()=>{await this._readProjectBlocks();const{cache:r}=this._dataSources.blocks;await r.getIfPresent(e)&&await r.addOrUpdate(e,i=>i&&On(i,t))};this._blockMetaWrites=this._blockMetaWrites.then(n).catch(()=>{})}getCodeErrors(){return Hb(this._container)?Ub(this._container):void 0}},Gb=F("EmailDataController");function Vb(e){return e.getOrCreateInstance(Gb,()=>{const t=new $b(e);return e.getInstance(U)?.addDisposable(t),t})}function qb(e){const t=Vb(e);return{getEmailSnapshot:()=>t.getEmailSnapshot(),getCodeErrors:()=>t.getCodeErrors(),getBlocks:()=>t.getBlocks(),getComments:()=>t.getComments(),getEmailRevisions:()=>t.getEmailRevisions(),setEmailMeta:n=>t.setEmailMeta(n),setBlockMeta:(n,r)=>t.setBlockMeta(n,r)}}function zb(e){return{undo:()=>e.undo(),redo:()=>e.redo(),clear:()=>e.clear(),canUndo:()=>e.canUndo(),canRedo:()=>e.canRedo(),createSnapshot:()=>e.createSnapshot(),restoreSnapshot:t=>{e.restoreSnapshot(t)},getPast:t=>e.getPast(t).map(n=>({changes:n})),getFuture:t=>e.getFuture(t).map(n=>({changes:n}))}}function Wb(e){let t;const n=wa(e),r=ue(e,j.ON_DOCUMENT_SESSION_CHANGE);n.addDisposable(r(({history:o})=>{t=o}));const i=()=>t?zb(t):void 0;return{undoRedoService:{undo:()=>i()?.undo(),redo:()=>i()?.redo(),clear:()=>i()?.clear(),getPast:o=>i()?.getPast(o)??[],getFuture:o=>i()?.getFuture(o)??[],canUndo:()=>i()?.canUndo()??!1,canRedo:()=>i()?.canRedo()??!1,createSnapshot:()=>i()?.createSnapshot(),restoreSnapshot:o=>i()?.restoreSnapshot(o)}}}var Kb=F("plugin.mountElement");function Yb(e){const t=e.getInstance(se)?.get()?.element;if(typeof Element<"u"&&t instanceof Element||typeof DocumentFragment<"u"&&t instanceof DocumentFragment)return t}function Xb(e){return e.getOrCreateInstance(Kb,()=>{let t=!1,n;return{get:()=>t?n:Yb(e),set(r){t=!0,n=r}}})}function Jb(e){const t=Xb(e);return{getElement:()=>t.get()}}function Qb(e){return{handleLoadImage:B(ue(e,j.UPLOAD_EVENT_ID)),handleFileProxy:B(ue(e,j.FILE_PROXY_EVENT_ID)),handleUrlProxy:B(ue(e,j.PROXY_URL_EVENT_ID)),handleAITextRequest:B(ue(e,j.AI_TEXT_REQUEST_ID)),handleAIImageRequest:B(ue(e,j.AI_IMAGE_REQUEST_ID)),handleReadLocale:B(ue(e,j.READ_LOCALE)),handleLimitUsage:B(ue(e,j.ON_LIMIT_ID)),handleTranslate:B(ue(e,j.ON_TRANSLATE_ID))}}var Zb=[Uh,qg,jb,Lv,qb,Wb,Jb,Qb];function ey(e,t=Zb){const n=li(e);yv(e);const r=Fb(e),i=Lb(e),o=Nb(e),s={...r.instance,...i.instance,...o.instance};for(const c of t)Object.assign(s,c(e));let a=!0;return{instance:s,async setOptions(c){await r.setOptions(c);const d=a&&n.get()===c;a=!1,d||n.set(c),await i.setOptions(c),await o.setOptions(c)}}}function ty(e){return{get:t=>e.get(t),remove:(t,n)=>e.remove(t,n),set:(t,n,r)=>{if(n==null){e.get(t),e.remove(t,r);return}e.set(t,n,r)}}}var ny=class{_storage=Object.create(null);get(e){const t=this._storage[e];return t&&(!t.expires||t.expires<Date.now())?t.value:""}set(e,t,n){this._storage[e]={value:t,expires:n.expires?n.expires*1e3+Date.now():void 0}}remove(e){delete this._storage[e]}},ry="editor-runtime.react.copies",Wn=8;function At(e){return e&&typeof e=="object"?e:void 0}function Oo(e){const t=At(e);if(!t)return;if(typeof t.useState=="function")return t.useState;const n=At(t.default);return n&&typeof n.useState=="function"?n.useState:void 0}function iy(e){const t=At(e),n=t&&typeof t.version=="string"?t.version:void 0,r=At(t?.default),i=r&&typeof r.version=="string"?r.version:void 0;return n??i??"unknown"}function oy(e,t,n){return e.package===t&&e.version===n}function sy({ourReact:e,entries:t,packageName:n,version:r}){const i=Oo(e);if(!i||!Array.isArray(t))return[];const o=[],s=new Set;for(const a of t){const c=At(a);if(!c||!oy(c,n,r))continue;const d=Oo(c.react);!d||d===i||s.has(d)||(s.add(d),o.push({package:n,version:r,reactVersion:iy(c.react),react:c.react}))}return o}function ay({packageName:e,copies:t}){const n=[`[${e}] A second copy of React is on this page (singleton invariant broken).`,`The editor runs on its own React, the plugin got another one from ${e}/runtime/react.`,`This shows up as "Cannot read properties of null (reading 'useState')" and takes down the whole`,"editor, not just the plugin panel: plugin components render inside the editor tree.","","Found:"];for(const r of t.slice(0,Wn))n.push(` • React ${r.reactVersion}, loaded through ${r.package}@${r.version}/runtime/react`);return t.length>Wn&&n.push(` …and ${t.length-Wn} more`),n.push("","Likely root cause: the editor is loaded from its UMD entry (a <script> on the page), while the","plugin was built as an ESM package by the host bundler. Those two never share a React.","","Fix it either way:"," • build the plugin on globals — it then takes React from the page registry, or"," • load the editor from its ESM entry and build both with the same bundler."),n.join(`
|
|
1048
|
+
`)}var xo=new Set;function ly({packageName:e="useblocks",version:t="1.1.102",log:n=r=>{}}={}){const r=i=>{try{const o=globalThis[Symbol.for(ry)],s=sy({ourReact:i,entries:o,packageName:e,version:t}).filter(a=>!xo.has(a.react));if(!s.length)return;s.forEach(a=>xo.add(a.react)),n(ay({packageName:e,copies:s}))}catch{}};try{const i=Lr()?.modules?.React;if(i&&typeof i.then=="function"){i.then(r,()=>{});return}r(i)}catch{}}async function cy(e,t,n){Y(e.signal);const r=t??nt.createChild();li(r);const i=r.getInstance(U);let o;async function s(){r.inject(Xo,ty(new ny)),ly();const a=ey(r),c={...a.instance,container:r,get ready(){return o??Promise.resolve(c)},async reset(d){if(Y(d.signal),i.isDisposed())throw Oe();return await a.setOptions(d),c}};r.inject(hn,c);try{if(n?.onInstance?.(c),await a.setOptions(e),Y(e.signal),i.isDisposed()||await $g(r),e.devTools)try{const d=r.getInstance(xr);d&&await(await Bt()).initDevTools(r,d)}catch{}return Y(e.signal),kt(r,Ko).fire(c),c}catch(d){throw i.dispose(),d}}try{return o=rn(s(),e.signal),o.catch(()=>{}),await o}catch(a){throw i.isDisposed()||i.dispose(),a}}var Rt=new WeakMap;function dy(e){return e?Rt.get(e):void 0}function ol(e){try{e.getInstance(U)?.dispose()}catch{}try{e.dispose()}catch{}}function uy(e,t){if(!e)return;const n=Rt.get(e);n&&n!==t&&ol(n),Rt.set(e,t)}function fy(e,t){e&&Rt.get(e)===t&&Rt.delete(e)}function py(e){const t=nt.createChild();return Lt(e)&&t.inject(Te,gn(e)),t}var _t=new WeakMap,hy="data-useblocks-config-styles";function my(e){return typeof e=="string"?e.trim():""}function Mo(e,t){if(e.firstChild){e.insertBefore(t,e.firstChild);return}e.appendChild(t)}function gy(e,t,n){if(!e||typeof document>"u")return null;const r=my(t),i=_t.get(e),o=n||e;if(!r)return i&&(i.remove(),_t.delete(e)),null;if(i)return i.textContent!==r&&(i.textContent=r),(i.parentNode!==o||i!==o.firstChild)&&Mo(o,i),i;const s=document.createElement("style");return s.setAttribute(hy,"true"),s.textContent=r,Mo(o,s),_t.set(e,s),s}function vy(e){if(!e)return;const t=_t.get(e);t&&(t.remove(),_t.delete(e))}function sl(){return!1}var by=`
|
|
1048
1049
|
.blocks-app-initial-spinner-wrapper {
|
|
1049
1050
|
width: 100%;
|
|
1050
1051
|
height: 100%;
|
|
@@ -1073,7 +1074,7 @@ import{t as Li}from"./static/esm/50fbfdf6.js";import{$ as xs,A as Ms,At as N,B a
|
|
|
1073
1074
|
100% {
|
|
1074
1075
|
transform: rotate(360deg);
|
|
1075
1076
|
}
|
|
1076
|
-
}`;function Cm(){return()=>{}}function Rm(e,t){if(!ys()||!e||typeof document>"u")return Cm();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const i=document.createElement("style");i.setAttribute(t,"true"),i.textContent=Tm,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function Pm(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function Dm({report:e}={}){const t=new Map,n=new Set,r=e??(i=>{});return{run(i,o){const s=t.get(i);if(s!==void 0)return s;const a=o().catch(l=>{throw n.has(i)||(n.add(i),r(l)),Pm(l)||t.delete(i),l});return t.set(i,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var mr=Dm();function Es(){mr.clear()}Ls(()=>mr.clear());var Ai=new WeakMap,Ti=new WeakMap;function Om(e,t){let n=Ti.get(t);n||(n=new Map,Ti.set(t,n));const r=n.get(e);if(r!==void 0)return r;const i=t.getInstance(Ni),o=Ea({baseUrl:e,customFetch:i?.execute??fetch},t);return n.set(e,o),o}function gr(e){return Ys(e)}function xm(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function Mm(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function km(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}var vr=new WeakMap;function pn(e,t){vr.set(e,t)}function Lm(e){return vr.get(e)}function Nm(e,t){return async({baseUrl:n})=>{const r=t();if(!r)throw new Error("[Loader] appInit requires the instance container");const i=vr.get(r)??e,o=gr(n);if(!o)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json"});if(i.getAuthToken&&!await km(i))throw Mm();const a=new zi(Om(o,r)),l={headers:Object.fromEntries(s.entries()),credentials:"same-origin",failoverAttemptTimeout:pr(i)||void 0},u=await a.app_init_create({},l);if(!u.ok)throw xm(u.status,u.statusText);return u.data}}function Fm(e){return JSON.stringify({baseUrl:gr(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function jm(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function Bm(e){return t=>mr.run(Fm(t),()=>(V("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>V("appInit:end",{kind:"network"}))))}function Um(e,t){if(Ht(e)||!e.appInit&&!gr(e.baseUrl)||!jm(e))return e;const n=e.appInit??Nm(e,t);let r=Ai.get(n);return r||(r=Bm(n),Ai.set(n,r)),{...e,appInit:r}}var _s=0;function Hm(){return _s}function Gm(){_s+=1,Es()}var Ci=new WeakMap,Ri=new WeakMap,qm=3e4;function $m(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function zm(e,t){try{const n=Hi(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+qm}function Vm(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=$m(r,i);if(o)return n.delete(s),t.delete(s),Es(),e(r,i,o);const a=n.get(s);if(a&&!t.has(s)){if(a.expiresAtMs>Date.now())return a.token;n.delete(s)}let l=t.get(s);return l===void 0&&(V("authToken:start",{kind:"network"}),l=Promise.resolve(e(r,i,o)).then(u=>{const m=String(u||"").trim();return m&&n.set(s,{token:u,expiresAtMs:zm(m,Date.now())}),u}).finally(()=>{V("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,l)),l}}function Km(e){if(Ht(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Ci.get(t);const r=Hm();return(!n||Ri.get(t)!==r)&&(n=Vm(t),Ci.set(t,n),Ri.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var Wm="[emailmaker] This editor instance was taken over by a later init()/create() into the same element. Get the current one with getInstance(element).";function Ym(){const e=new Error(Wm);return e.name="EditorReleasedError",e}var Xm="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function Jm(e){const t=new Error(Xm,{cause:e});return t.name="EditorStartFailedError",t}var Ge=new WeakMap,Ot=new WeakMap;function ws(e,t){Ge.set(e,t),Ot.get(e)?.forEach(n=>n())}function Qm(e,t){const n=Ot.get(e)??new Set;return n.add(t),Ot.set(e,n),()=>n.delete(t)}function hn(e){const t=(Ge.get(e)??0)+1;return ws(e,t),t}var xt=new WeakMap;function Zm(e,t){const n=xt.get(e)??new Set;n.add(t),xt.set(e,n)}function eg(e,t,n){return Ge.get(e)!==t?!0:xt.get(e)?.has(n)?!1:(ws(e,n),!0)}function Pi(e,t){return xt.get(e)?.has(t)===!0}var Ss=new WeakMap;function tg(e,t){Ss.set(e,{reason:t}),Ot.get(e)?.forEach(n=>n())}function mn(e){return Ss.get(e)}function yt(e,t){return Ge.get(e)===t}var Nn=new WeakMap;function ng(e,t){const n=Nn.get(e)??new Set;n.add(t),Nn.set(e,n)}function rg(e,t){const n=Ge.get(e);return n!==void 0&&n!==t&&Nn.get(e)?.has(n)===!0}function Di(e){return Ge.get(e)??0}var ig=new Set(["setConfig","updateConfig","show","save","getEmailSnapshot","getEmail","compileEmail","getBlocks","getEmailRevisions","getComments","validateCode","reset","useAsync"]),og=new Set(["setEmailMeta","setBlockMeta","notify"]),Is=new Map([["getConfig","await `ready` first"],["use","use `useAsync()` or await `ready` first"],["container","await `ready` first"],["undoRedoService","await `ready` first"]]);function Oi(e){if(/^handle[A-Z]/.test(e))return"event";if(ig.has(e))return"async";if(og.has(e))return"queued";if(e==="getElement")return"element";if(e==="getCodeErrors")return"codeErrors";if(Is.has(e))return"notReady"}function sg(e){return Is.get(e)??"await `ready` first"}function xi(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}function ag(e,t){let n,r=0,i,o,s="pending",a,l,u,m;const v=new Set,E=[];let g,_;const b=new Promise((C,P)=>{g=C,_=P});b.catch(()=>{});const y=C=>n?.[C],S=()=>s==="pending"||n!==void 0&&yt(n,r)&&mn(n)===void 0,I=C=>{const P=y(C.name);C.dispose||typeof P!="function"||!S()||(C.dispose=P(...C.args))},A=()=>v.forEach(I),f=()=>{for(const C of v)C.dispose?.(),C.dispose=void 0},c=()=>A(),d=()=>{s==="ready"&&(S()?A():f())},p=()=>{u?.delete(c),u=void 0},h=()=>{m?.(),m=void 0,f(),v.clear(),p(),E.length=0,n=void 0},w=()=>s==="failed"?a:Vn(),T=()=>{if(s!=="ready"||n===void 0)return;if(rg(n,r))return Ym();const C=mn(n);return C?Jm(C.reason):void 0},D=(C,P,j)=>{if(s==="failed"||s==="destroyed")throw w();const x=T();if(x)throw x;const M=y(C);if(typeof M!="function")throw xi(C);return M.apply(j,P)},L=()=>s==="ready"?Promise.resolve():s==="pending"?b:Promise.reject(w()),Y=(C,P)=>{if(s==="failed"||s==="destroyed")throw w();if(s==="ready"&&typeof y(C)!="function")throw xi(C);const j={name:C,args:P};return v.add(j),I(j),()=>{v.delete(j),j.dispose?.(),j.dispose=void 0}},k=()=>{const C=e.element;return C!==void 0&&typeof C!="string"?C:void 0},R=new Proxy({},{get(C,P,j){if(typeof P!="string"||P==="then")return;const x=Oi(P);if(x==="event")return(...M)=>Y(P,M);if(P==="reset")return(...M)=>L().then(()=>D(P,M,j)).then(()=>F);if(s==="pending"&&(x==="queued"||x==="codeErrors"))return x==="codeErrors"?()=>[]:(...M)=>{E.push({name:P,args:M})};if(n&&P in n){const M=T();if(M){if(typeof y(P)!="function")throw M;return x==="async"?()=>Promise.reject(M):()=>{throw M}}return Reflect.get(n,P,j)}switch(x){case"async":return(...M)=>L().then(()=>D(P,M,j));case"queued":return(...M)=>{if(s!=="pending")return D(P,M,j);E.push({name:P,args:M})};case"element":return k;case"codeErrors":return()=>[];case"notReady":throw new Error(`[emailmaker] \`${P}\` is not available before the editor is ready: ${sg(P)}`);default:return P in Object.prototype?Reflect.get(Object.prototype,P,j):void 0}},has(C,P){return typeof P!="string"?!1:n!==void 0&&P in n||Oi(P)!==void 0}}),F=Object.create(R);return Object.defineProperty(F,"ready",{get:()=>l,enumerable:!0}),Object.defineProperty(F,"destroy",{enumerable:!0,value:()=>{if(s==="destroyed"||s==="failed")return;if(s==="pending"){const x=i!==void 0&&n!==void 0&&yt(n,r),M=n;s="destroyed",l?.catch(()=>{}),t(te("[emailmaker] editor was destroyed before it was ready")),x&&(h(),M?.destroy());return}const C=n!==void 0&&yt(n,r),P=n,j=P!==void 0&&mn(P)!==void 0;s="destroyed",h(),!j&&(C?P?.destroy():P&&Zm(P,r))}}),{handle:F,bind:(C,P)=>{P?.adopt&&s==="pending"&&i===void 0?(i=Di(C),o=C,r=hn(C)):!P?.adopt&&n!==C&&(i=void 0,o=void 0),n!==C&&(f(),p(),n=C,A(),s==="pending"&&(u=C.container.getOrCreateInstance(Gi,()=>new Set),u.add(c)))},settle:()=>{const C=n;if(s==="destroyed"){h(),C&&(hn(C),C.destroy());const P=te("[emailmaker] editor was destroyed before it was ready");throw a=P,_(P),P}C&&i===void 0&&Di(C)===0&&(r=hn(C)),s="ready",C&&(ng(C,r),m=Qm(C,d),d()),p();for(const P of E.splice(0))try{D(P.name,P.args,F)}catch(j){queueMicrotask(()=>{throw j})}g()},fail:C=>{s!=="destroyed"&&(s="failed",a=C),h(),_(C)},canHandBack:()=>o!==void 0&&i!==void 0&&s!=="destroyed"&&yt(o,r)&&!Pi(o,i),finishAdoption:(C,P)=>{const j=o,x=i;if(o=void 0,i=void 0,!j||x===void 0||s==="destroyed")return;const M=!C||Pi(j,x);if(M&&tg(j,P),!eg(j,r,x)||M)try{j.destroy()}catch{}},setReady:C=>{l=C},isCurrent:()=>s==="pending"||s==="ready"&&T()===void 0}}var As="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function lg(){return te(As)}function dg(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===As}function cg(e,t,n){if(typeof document>"u")return;let r=!1,i;const o=()=>{r=!0,i?.disconnect(),i=void 0},s=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(s);return}i=new MutationObserver(()=>{e.isConnected||s()});let a=e.parentNode;for(;a;)i.observe(a,{childList:!0}),a=a.parentNode}function ug(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:i}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return cg(n,()=>{n.id,o.abort(lg())},i),$n(r,o.signal)}var Ts="Superseded by newer init() on the same mount element";function fg(){return te(Ts)}function pg(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===Ts}var ze=new Map,Et=new WeakMap;function hg(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function mg(e){if(!e)return{previous:Promise.resolve(),release:()=>{}};const t=hg(e);(t?ze.get(t):void 0)?.forEach(l=>{l.element!==e&&l.controller.abort(fg())});const n=Et.get(e)??Promise.resolve();let r;const i=new Promise(l=>{r=l}),o=n.then(()=>i);Et.set(e,o),o.then(()=>{Et.get(e)===o&&Et.delete(e)});const s=new AbortController,a={element:e,controller:s};if(t){const l=ze.get(t)??new Set;l.add(a),ze.set(t,l)}return{signal:s.signal,previous:n,release:()=>{r();const l=t?ze.get(t):void 0;t&&l?.delete(a)&&l.size===0&&ze.delete(t)}}}var Mt=new WeakMap;function Cs(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function Fn(e){return Object.entries(e).filter(([t,n])=>Cs(t,n)).map(([t])=>t).sort()}function Mi(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!Cs(n,r)&&(t[n]=r);return t}function jn(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Mt.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Mt.set(e,r));const{current:i,trampolines:o}=r;i.clear();const s={...t};for(const a of Fn(t)){i.set(a,t[a]);let l=o.get(a);l||(l=(...u)=>i.get(a)?.(...u),o.set(a,l)),s[a]=l}return r.lastOptions=t,s}function gg(e){const t=e?Mt.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((i,o)=>t.current.set(o,i)),t.lastOptions=r}}function vg(e,t,n){const r=e?Mt.get(e):void 0;if(!r||!n)return!1;const i=Fn(t),o=Ne(i,Fn(r.lastOptions)),s=i.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!o||!s||!Ne(Mi(t),Mi(r.lastOptions))?!1:(jn(e,t),!0)}var Qe=new WeakMap;function bg(e,t){const n=Qe.get(e)??[];n.push(t),Qe.set(e,n)}function yg(e){const t=Qe.get(e);if(!t)return;const n=t.filter(r=>r.isCurrent());if(n.length===0){Qe.delete(e);return}return Qe.set(e,n),n[n.length-1].handle}var Hg=Li({FileManagerApiError:()=>Eg}),Eg=class Rs extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,i){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,Rs)}},Gg=Li({mapHttpStatusToErrorCode:()=>Vs});function _g(e,t){return{...e,element:t}}function Bn(){return()=>{}}function wg(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Bn():(Im(t,e.config?.styles,t),()=>{Am(t)})}function Sg(e){if(!ys()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Bn()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Bn()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=Rm(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function Ig(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function ki(e){try{e.destroy()}catch{}}function Ze(e,...t){const n=ae.get(e);t.some(r=>r!==void 0&&r===n)&&ae.delete(e)}var qg="1.1.85-dev.9";async function $g(e){or(),await Ih(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function zg(e){return Ag(e).ready}function Ag(e){V(Z.initStart);const t=new AbortController,n=$n(e.signal,t.signal),r=ag(e,s=>t.abort(s)),i=s=>bg(s,r),o=Dg({...e,signal:n},r,i).then(()=>(V(Z.initEnd),r.settle(),r.handle),s=>{throw r.fail(s),s});return r.setReady(o),r.handle}function Vg(e){const t=typeof e=="string"?document.querySelector(e):e;return t?yg(t):void 0}function Tg(e){let t,n,r=!1;try{t=e.container.getInstance(ne)?.get(),n=e.container.getInstance(pe)?.externalSignal;const i=We(e.container)?.current();r=i!==void 0&&i.get().savedVersion!==null&&i.isDirty()}catch{t=void 0}return{options:t,signal:n,email:Cg(e),dirty:r}}async function Cg(e){try{return await e.getEmailSnapshot()}catch{return}}function Rg(e){const t=We(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}async function Pg(e,t,n,r,i){if(r.fail(i),pg(i)||dg(i)||!r.canHandBack()){r.finishAdoption(!0,i);return}const{options:o}=n;if(!o){Ze(t,e),r.finishAdoption(!1,i);return}const s=await n.email,a=s&&(o.content!==void 0||s.id!==void 0)?s:void 0,l=typeof o.content=="object"&&"email"in o.content?o.content:void 0;try{await e.reset({...o,signal:o.signal??n.signal,content:a?{...l,email:a}:o.content}),n.dirty&&a&&Rg(e),r.canHandBack()&&ae.set(t,e),r.finishAdoption(!0,i)}catch{Ze(t,e),r.finishAdoption(!1,i)}}async function Dg(e,t,n){z(e.signal);const r=new Q;let i,o;try{const s=await pa(e.element,r,e.signal);s&&n(s);const a=ug({hostElementOption:e.element,resolvedElement:s,externalSignal:e.signal,disposable:r}),l=mg(s);i=l.release;const u=$n(a,l.signal);return z(u),await It(l.previous,u),o=Og(e,s,t,u),await It(o,u)}finally{const s=i;o!==void 0&&s?o.then(s,s):s?.(),r.dispose()}}async function Og(e,t,n,r){const{bind:i}=n;z(r);let o;const s=g=>{Gm();const _=Km(_g(g,t)),b=Um(_,()=>o);return{preparedOptions:b,preparedOptionsWithSignal:r!=null?{...b,signal:r}:b}};let a;if(t){const g=ae.get(t);if(g){let _;try{_=await g,z(r)}catch{z(r),Ze(t,g),_=void 0}if(_)if(_.getElement()===t){const b=bm(t);o=b;const y=_.container.getInstance(ne)?.get();if(vg(t,e,y))return i(_,{adopt:!0}),r&&_.container.getInstance(pe)?.relinkExternalSignal(r),ae.set(t,_),_;const S=gg(t);a=s(jn(t,e));const{preparedOptions:I,preparedOptionsWithSignal:A}=a,f=b&&Lm(b),c=Tg(_);try{b&&pn(b,I),i(_,{adopt:!0});const d=await _.reset(Ig(e,A));return z(r),ae.set(t,_),d}catch(d){if(b&&f&&pn(b,f),!Ga(d))throw S(),await Pg(_,t,c,n,d),d;n.finishAdoption(!1,d),Ze(t,g,_),ki(_),z(r)}}else Ze(t,g,_),ki(_)}}z(r),a??=s(jn(t,e,{fresh:!0}));const{preparedOptions:l}=a,u=wg(l),m=Sg(l),v=r!=null?{...m.options,signal:r}:m.options;let E;try{o=_m(v),ym(t,o),pn(o,l),fr(o).set(v),await hr(),V(Z.coreReady),z(r),z(r),E=vm(v,o,{onInstance:i}),t&&ae.set(t,E);const g=await E;if(r?.aborted&&(g.destroy(),z(r)),t)if(ae.get(t)===E)ae.set(t,g);else throw g.destroy(),z(r),te(r?.reason);return g}catch(g){throw u(),m.cleanup(),o&&(bs(o),Em(t,o)),t&&E&&ae.get(t)===E&&ae.delete(t),g}}async function Kg(e){return(await lt()).parseAMP(e)}typeof window<"u"&&(et()&&Ua(),Th(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{As as ELEMENT_DETACHED_ABORT_MESSAGE,Ts as SUPERSEDED_INIT_ABORT_MESSAGE,Ag as create,Hg as errors,Vg as getInstance,Gg as helpers,zg as init,dg as isElementDetachedError,pg as isSupersededInitError,Kg as parseAMP,Rh as pluginRegistry,$g as preload,qg as version};
|
|
1077
|
+
}`;function yy(){return()=>{}}function Ey(e,t){if(!sl()||!e||typeof document>"u")return yy();e.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(s=>{s.remove()});const n=document.createElement("div");n.classList.add("blocks-app-initial-spinner-wrapper");const r=document.createElement("div");r.classList.add("blocks-app-initial-spinner"),n.appendChild(r);const i=document.createElement("style");i.setAttribute(t,"true"),i.textContent=by,document.head?.appendChild(i),e.appendChild(n);let o=!1;return()=>{o||(o=!0,n.remove(),i.remove())}}function _y(e){if(!(e instanceof Error))return!1;const t=e;return t.terminal===!0||t.status===403||t.status===404}function wy({report:e}={}){const t=new Map,n=new Set,r=e??(i=>{});return{run(i,o){const s=t.get(i);if(s!==void 0)return s;const a=o().catch(c=>{throw n.has(i)||(n.add(i),r(c)),_y(c)||t.delete(i),c});return t.set(i,a),a},clear(){t.clear(),n.clear()},size(){return t.size}}}var fi=wy();function al(){fi.clear()}Ll(()=>fi.clear());var ko=new WeakMap;function pi(e){return ic(e)}function Sy(e,t){const n=new Error(`[Loader] appInit request failed: ${e} ${t}`);return n.status=e,n}function Iy(){const e=new Error("[Loader] appInit skipped: empty auth token");return e.terminal=!0,e}async function Cy(e){if(!e.getAuthToken)return;const t=await e.getAuthToken(e.user,e.project,void 0),n=String(t||"").trim();return n?`Bearer ${n}`:void 0}var hi=new WeakMap;function Kn(e,t){hi.set(e,t)}function Ty(e){return hi.get(e)}function Ay(e,t){return async({baseUrl:n})=>{const r=t(),i=r&&hi.get(r)||e,o=pi(n);if(!o)throw new Error("[Loader] appInit requires baseUrl or REACT_APP_OPENAPI_BASE_URL");const s=new Headers({Accept:"application/json","Content-Type":"application/x-www-form-urlencoded;charset=UTF-8"}),a=await Cy(i);if(i.getAuthToken&&!a)throw Iy();a&&s.set("authorization",a);const c=await Bl("/app/v1/app_init",{method:"POST",headers:s,body:new URLSearchParams,credentials:"same-origin"},o,{attemptTimeout:ti(i)||void 0});if(!c.ok)throw Sy(c.status,c.statusText);return await c.json()}}function Ry(e){return JSON.stringify({baseUrl:pi(e.baseUrl)||"",project:e.project??"",userId:e.user?.id??""})}function Py(e){return e.appInit?!0:!(e.jwtAuth&&!e.getAuthToken)}function Dy(e){return t=>fi.run(Ry(t),()=>(Z("appInit:start",{kind:"network"}),Promise.resolve(e(t)).finally(()=>Z("appInit:end",{kind:"network"}))))}function Oy(e,t){if(Lt(e)||!e.appInit&&!pi(e.baseUrl)||!Py(e))return e;const n=e.appInit??Ay(e,t);let r=ko.get(n);return r||(r=Dy(n),ko.set(n,r)),{...e,appInit:r}}var ll=0;function xy(){return ll}function My(){ll+=1,al()}var Lo=new WeakMap,No=new WeakMap,ky=3e4;function Ly(e,t){return JSON.stringify({userId:e?.id??"",project:t??""})}function Ny(e,t){try{const n=Mr(e)?.exp;if(typeof n=="number"&&Number.isFinite(n)&&n>0)return n*1e3}catch{}return t+ky}function Fy(e){const t=new Map,n=new Map;return async(r,i,o)=>{const s=Ly(r,i);if(o)return n.delete(s),t.delete(s),al(),e(r,i,o);const a=n.get(s);if(a&&!t.has(s)){if(a.expiresAtMs>Date.now())return a.token;n.delete(s)}let c=t.get(s);return c===void 0&&(Z("authToken:start",{kind:"network"}),c=Promise.resolve(e(r,i,o)).then(d=>{const f=String(d||"").trim();return f&&n.set(s,{token:d,expiresAtMs:Ny(f,Date.now())}),d}).finally(()=>{Z("authToken:end",{kind:"network"}),t.delete(s)}),t.set(s,c)),c}}function jy(e){if(Lt(e))return e;const t=e.getAuthToken;if(!t)return e;let n=Lo.get(t);const r=xy();return(!n||No.get(t)!==r)&&(n=Fy(t),Lo.set(t,n),No.set(t,r)),Promise.resolve(n(e.user,e.project,void 0)).catch(i=>{}),{...e,getAuthToken:n}}var By="[emailmaker] This editor was destroyed: a later init()/create() into the same element failed to start, and the editor could not be handed back. Call init() again; the reason is in `cause`.";function Uy(e){const t=new Error(By,{cause:e});return t.name="EditorStartFailedError",t}var Hy={getConfig:"await `ready` first",use:"use `useAsync()` or await `ready` first"};function Fo(e){return new Error(`[emailmaker] \`${e}\` is not available on this editor`)}var cl=["handleLoad","handleDestroy"];function dl(e,t){let n=e;for(const r of cl){const i=e?.[r];typeof i=="function"&&(n={...n,[r]:(o,...s)=>i(t,...s)})}return n}function $y(e){let t,n="pending",r,i,o,s;const a=new Set,c=[],d=new Set;let f,h;const y=new Promise((I,O)=>{f=I,h=O});y.catch(()=>{});const b={},T=I=>t?.[I],w=()=>r??Oe(),g=(I,O)=>{const k=T(I);if(typeof k!="function")throw Fo(I);return k.apply(t,O)},C=(I,O)=>{try{return Promise.resolve(g(I,O))}catch(k){return Promise.reject(k)}},_=()=>{const I=t?.container?.getInstance?.(U);if(!(n!=="ready"||I?.isDisposed()||typeof T("getConfig")!="function"))try{s=g("getConfig",[])}catch{}},P=()=>n==="dead"?Promise.reject(w()):n==="ready"?Promise.resolve():y,S=()=>{for(const[I,O]of dn)O==="field"&&(b[I]=T(I))},M=I=>{const O=T(I.name);I.dispose||typeof O!="function"||n==="dead"||(I.dispose=O.apply(t,I.args))},v=()=>a.forEach(M),E=()=>{for(const I of a){try{I.dispose?.()}catch{}I.dispose=void 0}},A=()=>{S(),v()},m=()=>{o?.delete(A),o=void 0},l=(I,O)=>{const[k,...ee]=O;return!cl.includes(I)||typeof k!="function"?O:[(ce,...X)=>k(b,...X),...ee]},u=(I,O)=>{if(n==="dead")return()=>{};if(n==="ready"&&typeof T(I)!="function")throw Fo(I);const k={name:I,args:l(I,O)};return a.add(k),M(k),()=>{a.delete(k),k.dispose?.(),k.dispose=void 0}},p=()=>t?.container?.getInstance(se)?.get()?.content,R=()=>{const I=e.element();return I!==void 0&&typeof I!="string"?I:void 0},D=(I,O)=>{switch(O){case"event":return(...k)=>u(I,k);case"async":return(...k)=>(I==="show"&&k[0]!==void 0&&e.shown?.(k[0]),n!=="dead"&&typeof T(I)=="function"?C(I,k):P().then(()=>g(I,k)));case"queued":return(...k)=>{if(n==="dead"){if(I==="notify")return;throw w()}if(n==="pending"){c.push({name:I,args:k});return}return g(I,k)};case"sync":return(...k)=>{if(n==="dead"){if(I==="getConfig")return s;throw w()}if(typeof T(I)!="function")throw new Error(`[emailmaker] \`${I}\` is not available before the editor is ready: ${Hy[I]??"await `ready` first"}`);const ee=g(I,k);return I==="getConfig"&&(s=ee),ee};case"element":return()=>{if(typeof T(I)!="function")return R();try{return g(I,[])}catch{return R()}};case"codeErrors":return()=>n==="ready"&&typeof T(I)=="function"?g(I,[]):[];case"field":return}};for(const[I,O]of dn)b[I]=D(I,O);b.reset=I=>(I?.content!==void 0&&e.shown?.(I.content),P().then(async()=>{const O=I?.content!==void 0&&Ce(I.content,p());await g("reset",[dl(I,L)]),O&&await g("show",[I.content])}).then(()=>b)),b.destroy=()=>{if(n==="dead")return;const I=pe("[emailmaker] editor was destroyed before it was ready");i?.catch(()=>{}),d.forEach(O=>O(I)),_(),e.destroy()},Object.defineProperty(b,"ready",{get:()=>i,enumerable:!0,configurable:!0});const L=b;return{object:L,get state(){return n},get editor(){return t},bind:I=>{n==="dead"||t===I||(E(),m(),t=I,S(),v(),n==="pending"&&(o=I.container.getOrCreateInstance(Dr,()=>new Set),o.add(A)))},settle:()=>{if(n==="pending"){n="ready",m(),S(),v();for(const I of c.splice(0))try{g(I.name,I.args)}catch(O){queueMicrotask(()=>{throw O})}f()}},kill:(I,O)=>{n!=="dead"&&(_(),n="dead",r=I,c.length=0,d.forEach(k=>k(I)),m(),O?.keepSubscriptions||(E(),a.clear()),h(I))},detach:()=>{E(),a.clear()},setReady:I=>{i=I},trackCall:I=>(d.add(I),()=>d.delete(I)),hasCalls:()=>d.size>0}}var ul="Editor mount element was removed from the document. Call instance.destroy() on host unmount.";function Gy(){return pe(ul)}function Vy(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===ul}function qy(e,t,n){if(typeof document>"u")return;let r=!1,i;const o=()=>{r=!0,i?.disconnect(),i=void 0},s=()=>{r||(o(),t())};if(n.addDispose(o),!e.isConnected){queueMicrotask(s);return}i=new MutationObserver(()=>{e.isConnected||s()});let a=e.parentNode;for(;a;)i.observe(a,{childList:!0}),a=a.parentNode}function zy(e){const{hostElementOption:t,resolvedElement:n,externalSignal:r,disposable:i}=e;if(t===void 0||!(n instanceof Element))return r;const o=new AbortController;return qy(n,()=>{n.id,o.abort(Gy())},i),Tr(r,o.signal)}var fl="Superseded by newer init() on the same mount element";function jo(){return pe(fl)}function Wy(e){return!(e instanceof DOMException)||e.name!=="AbortError"?!1:e.message===fl}var ct=new Map,Bo=new WeakMap,Jt=new WeakMap;function Ky(e){if(e instanceof Element){const t=e.id?.trim();if(t)return`#${t}`}}function Yy(e,{supersede:t=!1}={}){if(!e)return{previous:Promise.resolve(),release:()=>{}};const n=Ky(e);(n?ct.get(n):void 0)?.forEach(f=>{f.element!==e&&f.controller.abort(jo())});const r=Bo.get(e)??new Set;t&&r.forEach(f=>{f.supersedable&&f.controller.abort(jo())});const i=Jt.get(e)??Promise.resolve();let o;const s=new Promise(f=>{o=f}),a=i.then(()=>s);Jt.set(e,a),a.then(()=>{Jt.get(e)===a&&Jt.delete(e)});const c=new AbortController,d={element:e,controller:c,supersedable:t};if(r.add(d),Bo.set(e,r),n){const f=ct.get(n)??new Set;f.add(d),ct.set(n,f)}return{signal:c.signal,previous:i,release:()=>{o(),r.delete(d);const f=n?ct.get(n):void 0;n&&f?.delete(d)&&f.size===0&&ct.delete(n)}}}var Pt=new WeakMap;function mi(e,t){return typeof t=="function"&&(/^(handle|on)[A-Z]/.test(e)||e==="getAuthToken")}function wr(e){return Object.entries(e).filter(([t,n])=>mi(t,n)).map(([t])=>t).sort()}function Uo(e){const t={};for(const[n,r]of Object.entries(e))n!=="signal"&&!mi(n,r)&&(t[n]=r);return t}function Sr(e,t,{fresh:n=!1}={}){if(!e)return t;let r=n?void 0:Pt.get(e);r||(r={current:new Map,trampolines:new Map,lastOptions:t},Pt.set(e,r));const{current:i,trampolines:o}=r;i.clear();const s={...t};for(const a of wr(t)){i.set(a,t[a]);let c=o.get(a);c||(c=(...d)=>i.get(a)?.(...d),o.set(a,c)),s[a]=c}return r.lastOptions=t,s}function pl(e,t){const n=e?Pt.get(e):void 0;if(n)for(const r of n.trampolines.keys()){const i=t[r];mi(r,i)?n.current.set(r,i):n.current.delete(r)}}function Xy(e){const t=e?Pt.get(e):void 0;if(!t)return()=>{};const n=new Map(t.current),{lastOptions:r}=t;return()=>{t.current.clear(),n.forEach((i,o)=>t.current.set(o,i)),t.lastOptions=r}}function Jy(e,t,n){const r=e?Pt.get(e):void 0;if(!r||!n)return!1;const i=wr(t),o=Ce(i,wr(r.lastOptions)),s=i.every(a=>a==="getAuthToken"||n[a]===r.trampolines.get(a));return!o||!s||!Ce(Uo(t),Uo(r.lastOptions))?!1:(Sr(e,t),!0)}var ve=new WeakMap;function En(e){let t=ve.get(e);return t||(t={counted:new Set,leaving:new Set,order:[],options:new Map,latestCall:0,warned:!1},ve.set(e,t)),t}var Ne=e=>e!==void 0&&e.state!=="dead";function Qy(e){const t=ve.get(e)?.shared;return Ne(t)?t:void 0}function Zy(e,t){En(e).shared=t}function eE(e,t){!(Ne(e.shared)&&[...e.counted].some(Ne))||e.warned||!t.devTools||(e.warned=!0)}function tE(e,t,n,r){const i=En(e);return i.latestCall+=1,i.releaseTimer!==void 0&&(clearTimeout(i.releaseTimer),i.releaseTimer=void 0),i.leaving.forEach(o=>o.detach()),i.leaving.clear(),n==="single"?i.shared=t:i.counted.add(t),i.options.set(t,r),i.order=[...i.order.filter(o=>o!==t&&Ne(o)),t],eE(i,r),i.latestCall}function nE(e,t){return ve.get(e)?.latestCall===t}function rE(e){const t=ve.get(e);if(t)return t.order=t.order.filter(Ne),t.order.at(-1)?.object}function Dt(e,t){const n=ve.get(e);return n?Ne(n.shared)&&n.shared!==t||[...n.counted].some(r=>r!==t&&Ne(r)):!1}function iE(e,t){const n=ve.get(e),r=n?.order.filter(i=>i!==t&&Ne(i)).at(-1);return r?n?.options.get(r):void 0}function hl(e,t){En(e).content={value:t}}function oE(e){return ve.get(e)?.content}function sE(e,t,n,r){const i=En(e);if(i.counted.delete(t),i.options.delete(t),Dt(e)){t.kill(n);return}t.kill(n,{keepSubscriptions:!0}),i.leaving.add(t),ml(e,r)}function ml(e,t){const n=ve.get(e);!n||Dt(e)||n.releaseTimer!==void 0||(n.releaseTimer=setTimeout(()=>{n.releaseTimer=void 0,!Dt(e)&&(t(),n.leaving.forEach(r=>r.detach()),n.leaving.clear())},0))}function aE(e,t){const n=ve.get(e);if(n){n.releaseTimer!==void 0&&clearTimeout(n.releaseTimer);for(const r of[n.shared,...n.counted,...n.leaving])r?.kill(t);ve.delete(e)}}var ME=Go({FileManagerApiError:()=>lE,IntegratorSaveTimeoutError:()=>Ur,SaveRefusedError:()=>vt}),lE=class gl extends Error{code;status;details;get httpStatus(){return this.status}constructor(t,n,r,i){super(t),this.name="FileManagerApiError",this.code=n,this.status=r,this.details=i,Error.captureStackTrace&&Error.captureStackTrace(this,gl)}},kE=Go({mapHttpStatusToErrorCode:()=>Rl});function cE(e,t){return{...e,element:t}}function Ir(){return()=>{}}function dE(e){const t=e.element;return!t||typeof t=="string"||typeof document>"u"?Ir():(gy(t,e.config?.styles,t),()=>{vy(t)})}function uE(e){if(!sl()||e.initialSpinner===!1||typeof document>"u")return{options:e,cleanup:Ir()};const t=e.element;if(!t||typeof t=="string")return{options:e,cleanup:Ir()};t.querySelectorAll(".blocks-app-initial-spinner-wrapper").forEach(i=>{i.remove()});const n=Ey(t,"data-useblocks"),r=e.handleChunkLoaded;return{options:{...e,handleChunkLoaded:()=>{n(),r?.()}},cleanup:n}}function fE(e,t){if(e.appInit||!("appInit"in t))return t;const n={...t};return delete n.appInit,n}function fn(e){try{e.destroy()}catch{}}function nn(e,...t){const n=he.get(e);t.some(r=>r!==void 0&&r===n)&&he.delete(e)}var LE="1.1.102";async function NE(e){Jr(),await $v(typeof window.__useblocks__<"u"?window.__useblocks__:void 0)}async function FE(e){return vE(e).ready}function pE(e){if(typeof e!="string")return e??void 0;try{return document.querySelector(e)??void 0}catch{return}}function hE(e){const t=he.get(e);return t&&!(t instanceof Promise)?t:void 0}function pn(e,t,n){const r=t??hE(e);r&&(nn(e,r),fn(r)),aE(e,n)}function mE(e){const{control:t,mode:n,ref:r}=e,i=r.host;if(!i){const s=t.editor;gE(s),t.kill(Oe());return}if(n==="single"){pn(i,t.editor,Oe());return}const o=iE(i,t);sE(i,t,Oe(),()=>pn(i,t.editor,Oe())),o&&Dt(i)&&pl(i,o)}function gE(e){e&&fn(e)}function vE(e){Z(le.initStart);const t=e.ownership==="counted"?"counted":"single",n=new AbortController,r=Tr(e.signal,n.signal),i=t==="single"?pE(e.element):void 0,o=i?Qy(i):void 0;let s;if(o)s={control:o,mode:t,ref:{host:i}};else{const f={},h=$y({element:()=>f.host??e.element,destroy:()=>mE(s),shown:y=>{f.host&&hl(f.host,y)}});s={control:h,mode:t,ref:f},i&&Zy(i,h)}const{control:a}=s,c=a.trackCall(f=>n.abort(f)),d=wE(dl({...e,signal:r},a.object),s).then(()=>(c(),Z(le.initEnd),a.settle(),a.object),f=>{c(),a.state==="pending"&&!a.hasCalls()&&a.kill(f);const h=s.ref.host;throw h&&ml(h,()=>pn(h,void 0,Oe())),f});return a.setReady(d),a.object}function jE(e){const t=typeof e=="string"?document.querySelector(e):e;return t?rE(t):void 0}function bE(e){let t,n,r=!1;try{t=e.container.getInstance(se)?.get(),n=e.container.getInstance(Ae)?.externalSignal;const i=Je(e.container)?.current();r=i!==void 0&&i.get().savedVersion!==null&&i.isDirty()}catch{t=void 0}return{options:t,signal:n,email:yE(e),dirty:r}}async function yE(e){try{return await e.getEmailSnapshot()}catch{return}}function EE(e){const t=Je(e.container)?.current();t?.whenReady().then(()=>t.markUnsaved()).catch(()=>{})}function Ho(e,t){const{control:n,mode:r}=t;return r==="single"&&n.state==="ready"||Dt(e,n)}async function _E(e,t,n,r,i){if(r.mode==="counted"&&r.control.detach(),Wy(i)||Vy(i))return;const o=()=>pn(t,e,Uy(i)),{options:s}=n;if(!s||!Ho(t,r)){o();return}const a=await n.email,c=a&&(s.content!==void 0||a.id!==void 0)?a:void 0,d=typeof s.content=="object"&&"email"in s.content?s.content:void 0;try{await e.reset({...s,signal:s.signal??n.signal,content:c?{...d,email:c}:s.content}),n.dirty&&c&&EE(e),Ho(t,r)?he.set(t,e):o()}catch{o()}}async function wE(e,t){Y(e.signal);const n=new ie;let r,i,o,s,a=0;try{const c=await Jl(e.element,n,e.signal);c&&(s=c,t.ref.host=c,a=tE(c,t.control,t.mode,e));const d=zy({hostElementOption:e.element,resolvedElement:c,externalSignal:e.signal,disposable:n}),f=Yy(c,{supersede:t.mode==="single"});r=f.release;const h=Tr(d,f.signal);Y(h),o=Xy(c),pl(c,e),await rn(f.previous,h),i=SE(e,c,t,h,o);const y=await rn(i,h);return c&&e.content!==void 0&&hl(c,e.content),y}catch(c){throw s&&o&&nE(s,a)&&o(),c}finally{const c=r;i!==void 0&&c?i.then(c,c):c?.(),n.dispose()}}async function $o(e,t,n,r){const i=oE(t);n===void 0||r||!i||Ce(n,i.value)||await e.show(n)}async function SE(e,t,n,r,i){const{control:o}=n,s=w=>o.bind(w);Y(r);let a;const c=w=>{My();const g=jy(cE(w,t)),C=Oy(g,()=>a);return{preparedOptions:C,preparedOptionsWithSignal:r!=null?{...C,signal:r}:C}};let d;if(t){const w=he.get(t);if(w){let g;try{g=await w,Y(r)}catch{Y(r),nn(t,w),g=void 0}if(g)if(g.getElement()===t){const C=dy(t);a=C;const _=g.container.getInstance(se)?.get();if(Jy(t,e,_))return s(g),r&&g.container.getInstance(Ae)?.relinkExternalSignal(r),he.set(t,g),await $o(g,t,e.content,!1),g;const P=!Ce(e.content,_?.content);d=c(Sr(t,e));const{preparedOptions:S,preparedOptionsWithSignal:M}=d,v=C&&Ty(C),E=bE(g);try{C&&Kn(C,S),s(g);const A=await g.reset(fE(e,M));return Y(r),he.set(t,g),await $o(g,t,e.content,P),A}catch(A){if(C&&v&&Kn(C,v),!Oc(A))throw i(),await _E(g,t,E,n,A),A;nn(t,w,g),fn(g),Y(r)}}else nn(t,w,g),fn(g)}}Y(r),d??=c(Sr(t,e,{fresh:!0}));const{preparedOptions:f}=d,h=dE(f),y=uE(f),b=r!=null?{...y.options,signal:r}:y.options;let T;try{a=py(b),uy(t,a),Kn(a,f),li(a).set(b),await ci(),Z(le.coreReady),Y(r),Y(r),T=cy(b,a,{onInstance:s}),t&&he.set(t,T);const w=await T;if(r?.aborted&&(w.destroy(),Y(r)),t)if(he.get(t)===T)he.set(t,w);else throw w.destroy(),Y(r),pe(r?.reason);return w}catch(w){throw h(),y.cleanup(),a&&(ol(a),fy(t,a)),t&&T&&he.get(t)===T&&he.delete(t),w}}async function BE(e){return(await Bt()).parseAMP(e)}typeof window<"u"&&(wt()&&Pc(),Vv(typeof window.__useblocks__<"u"?window.__useblocks__:void 0));export{ul as ELEMENT_DETACHED_ABORT_MESSAGE,fl as SUPERSEDED_INIT_ABORT_MESSAGE,vE as create,ME as errors,jE as getInstance,kE as helpers,FE as init,Vy as isElementDetachedError,Wy as isSupersededInitError,BE as parseAMP,zv as pluginRegistry,NE as preload,LE as version};
|
|
1077
1078
|
|
|
1078
1079
|
|
|
1079
|
-
window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/
|
|
1080
|
+
window.__useblocks__.require.config({"graph":{"core":["__delivery__/libs"],"static/core/11b821ed.js":[],"static/core/160bf060.js":[],"static/core/1b68c0f0.js":[],"static/core/1ed86ed3.js":[],"static/core/26cc947d.js":[],"static/core/3ec42945.js":[],"static/core/3fb172c7.js":[],"static/core/3fd50a29.js":[],"static/core/448f03f8.js":[],"static/core/44d2c046.js":[],"static/core/48da14fd.js":[],"static/core/4c8d0155.js":[],"static/core/53103851.js":["static/core/ae22b7f6.js","__delivery__/libs"],"static/core/5d849eef.js":[],"static/core/5e7c221f.js":["__delivery__/libs"],"static/core/64be048b.js":["static/core/e47dcbb0.js","__delivery__/libs","monaco"],"static/core/6561b34a.js":[],"static/core/6a671446.js":["static/core/5d849eef.js"],"static/core/756874c6.js":[],"static/core/7b850506.js":[],"static/core/847338a8.js":["static/core/ae22b7f6.js","static/core/ff7d14e8.js","__delivery__/libs"],"static/core/91e07171.js":["static/core/ae22b7f6.js","static/core/53103851.js","static/core/d7666ad0.js","static/core/edf450a1.js","__delivery__/libs"],"static/core/a2e57e5f.js":[],"static/core/a6303cb2.js":["static/core/ff7d14e8.js"],"static/core/a98b6879.js":["static/core/b653f9c5.js"],"static/core/ae22b7f6.js":["static/core/e7620593.js","static/core/ff7d14e8.js","__delivery__/libs"],"static/core/b653f9c5.js":[],"static/core/b7aa9fec.js":["static/core/5d849eef.js","static/core/b653f9c5.js","static/core/a98b6879.js"],"static/core/ca4dad9b.js":["static/core/53103851.js","static/core/5e7c221f.js","__delivery__/libs","static/core/ae22b7f6.js"],"static/core/cc180859.js":[],"static/core/d7666ad0.js":["static/core/ae22b7f6.js","__delivery__/libs"],"static/core/dcc37768.js":[],"static/core/e47dcbb0.js":[],"static/core/e50befab.js":[],"static/core/e7620593.js":[],"static/core/edf450a1.js":["static/core/5e7c221f.js","__delivery__/libs"],"static/core/f1ee2bef.js":[],"static/core/f323e60e.js":["static/core/b653f9c5.js"],"static/core/fb2fe2db.js":[],"static/core/ff7d14e8.js":[],"static/monaco/editor.api-C9c1WLns.js":[],"monaco":["static/monaco/editor.api-C9c1WLns.js","static/monaco/lspLanguageFeatures-DY3n8M13.js"],"static/monaco/lspLanguageFeatures-DY3n8M13.js":["static/monaco/editor.api-C9c1WLns.js"],"compat-globals.js":["static/esm/971f1b2c.js"],"static/esm/delivery-libs.js":[],"useblocks-esm.js":["static/esm/971f1b2c.js","static/esm/668ee399.js","static/esm/f76c9d9d.js"],"static/esm/2490dab8.js":["static/esm/971f1b2c.js"],"static/esm/668ee399.js":[],"static/esm/971f1b2c.js":[],"static/esm/f76c9d9d.js":[]},"bundles":{"static/core/5e7c221f.js":["static/core/c57eb9c3.js","static/core/9242dd6e.js","static/core/9977c164.js"],"static/core/6a671446.js":["static/core/a71c4cd8.js"],"static/core/847338a8.js":["static/core/8daf15a4.js"],"static/core/edf450a1.js":["static/core/a73da823.js"],"static/core/ca4dad9b.js":["static/core/56ce0894.js"],"core":["static/core/2ff39ddf.js","static/core/c1dc75d5.js","static/core/d68c5a64.js","static/core/c75aa9c7.js","static/core/3c41f519.js"]}});
|