@ones-editor/editor 0.0.3-beta.81 → 0.0.3-beta.82
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/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +23 -23
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
(function(){"use strict";try{if(typeof document!="undefined"){var t=document.createElement("style");t.appendChild(document.createTextNode(`@charset "UTF-8";@keyframes ones-editor-blink{0%,to{background-color:transparent}50%{background-color:var(--primary-color)}}*{--link-color: #338fe5;--color-0: #e52727;--color-1: #eb6414;--color-2: #f0a100;--color-3: #24b47e;--color-4: #338fe5;--color-5: #9678d3;--color-6: #909090;--background-color-0: #fad4d4;--background-color-1: #fbe0d0;--background-color-2: #fceccc;--background-color-3: #d3f0e5;--background-color-4: #d6e9fa;--background-color-5: #eae4f6;--background-color-6: #dedede;--background-color-7: #e52727;--background-color-8: #eb6414;--background-color-9: #f0a100;--background-color-10: #24b47e;--background-color-11: #338fe5;--background-color-12: #9678d3;--background-color-13: #909090;--background-color-14: #e8e8e8;--font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif}div.editor-root{--text-color: #303030;--primary-color: #338fe5;--background-selection: #338fe533;--background-code: #eeeeee}div.editor-root{color:var(--text-color);position:relative;box-sizing:border-box;height:100%;width:100%;z-index:1}div.editor-root.readonly div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] span.text.link{cursor:pointer}div.editor-root *{box-sizing:border-box;font-family:var(--font-family)}div.editor-root button{outline:none}div.editor-root.active div.editor-content .editor-cursor{opacity:1}div.editor-root .safari.mobile div.editor-content .editor-input{pointer-events:all;width:8px}div.editor-root div.editor-content{height:100%;width:100%;padding:0 30px 30px}div.editor-root div.editor-content .editor-cursor{position:absolute;background:var(--primary-color);width:2px;transition:top .1s ease-in,left .1s linear;animation:ones-editor-blink 1s ease-in-out infinite;opacity:0;pointer-events:none}div.editor-root div.editor-content .editor-input{position:absolute;opacity:0;pointer-events:none;width:16px;height:20px;font-size:16px}div.editor-root div.editor-content div[data-type=editor-container]{position:relative}div.editor-root div.editor-content div[data-type=editor-container].root{user-select:none;width:100%;cursor:text}div.editor-root div.editor-content div[data-type=editor-container].root>.container-blocks>*+*{margin-top:1em}div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block]:not(:first-of-type){background-color:var(--background-selection)}div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block]:not(:first-of-type) div[data-type=block-background]>.editor-selection-background{background-color:transparent!important}div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block].embed-block>div[data-type=block-content]:before,div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block].embed-block .embed-selected-content:before{display:none}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]+div[data-type=editor-block][data-style-quoted]{margin-top:0}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block]{position:relative;--font-size: 15px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-align=center] div[data-type=block-content]{text-align:center}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-align=right] div[data-type=block-content]{text-align:end}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].block-hidden{display:none}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-block-type=text]{cursor:text}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]{word-break:break-word;position:relative}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span{font-size:var(--font-size);line-height:var(--line-height);cursor:text}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text{white-space:pre-wrap}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.link{color:var(--link-color)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.link:hover{text-decoration:underline}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.link.style-strikethrough:hover{text-decoration:underline line-through}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-bold{font-weight:700}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-italic{font-style:italic}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-underline{text-decoration:underline}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-strikethrough{text-decoration:line-through}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-underline.style-strikethrough{text-decoration:underline line-through}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-code{border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;background-color:var(--background-code);padding:4px;font:.8em Monaco,Consolas,"Andale Mono",DejaVu Sans Mono,monospace}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-subscript{vertical-align:sub;font-size:70%}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-superscript{vertical-align:super;font-size:70%}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="0"]{color:var(--color-0)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="1"]{color:var(--color-1)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="2"]{color:var(--color-2)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="3"]{color:var(--color-3)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="4"]{color:var(--color-4)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="5"]{color:var(--color-5)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="6"]{color:var(--color-6)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="0"]{background-color:var(--background-color-0)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="1"]{background-color:var(--background-color-1)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="2"]{background-color:var(--background-color-2)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="3"]{background-color:var(--background-color-3)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="4"]{background-color:var(--background-color-4)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="5"]{background-color:var(--background-color-5)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="6"]{background-color:var(--background-color-6)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="7"]{background-color:var(--background-color-7)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="8"]{background-color:var(--background-color-8)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="9"]{background-color:var(--background-color-9)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="10"]{background-color:var(--background-color-10)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="11"]{background-color:var(--background-color-11)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="12"]{background-color:var(--background-color-12)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="13"]{background-color:var(--background-color-13)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="14"]{background-color:var(--background-color-14)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].inputting-insertion>span[data-type=insertion-content]{border-bottom:1px solid var(--primary-color)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion{width:0px;position:relative;display:inline-block;vertical-align:text-bottom;overflow:visible;height:1em}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion>span[data-type=insertion-content]{position:absolute;color:transparent;width:3px;left:-3px;border-right:var(--cursor-color) 1px solid;text-overflow:clip;display:inline-block;top:-5px;bottom:0}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion>span[data-type=insertion-content] span[data-cursor-name]{display:inline-block;width:8px;background-color:transparent;border:none}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion>span[data-type=insertion-content] span[data-cursor-name]:hover:before,div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion.active>span[data-type=insertion-content] span[data-cursor-name]:before{content:attr(data-cursor-name);position:absolute;top:-12px;height:1.1em;background-color:var(--cursor-color);z-index:27;left:0px;color:#fff;white-space:nowrap;font-size:12px;display:flex;align-items:center;padding:1px 4px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] span[data-type=box-content]{border-radius:2px;margin-left:8px;margin-right:8px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] span[data-type=editor-box].br-box>span[data-type=box-content] img{vertical-align:middle;max-width:1em}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-tools] .editor-block-anchor{position:absolute}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-background] .editor-selection-background{position:absolute;background-color:var(--background-selection);z-index:1;pointer-events:none}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block,div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block{cursor:default}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.hover>div[data-type=block-content],div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block.hover>div[data-type=block-content]{outline:1px solid #338fe5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block>div[data-type=block-content],div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block>div[data-type=block-content]{display:flex}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.hover .embed-hover-content{outline:1px solid #338fe5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected>div[data-type=block-content],div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content{position:relative}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected>div[data-type=block-content]:before,div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content:before{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#338fe5;opacity:.1}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block{color:#909090;font-size:12px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block>div[data-type=block-content]{padding:5px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]{border-left:4px solid #e8e8e8;color:#909090}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]:not([data-list-level]){padding-left:8px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="1"]{--font-size: 28px;--line-height: 1.5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="2"]{--font-size: 26px;--line-height: 1.5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="3"]{--font-size: 24px;--line-height: 1.5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="4"]{--font-size: 22px;--line-height: 1.5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="5"]{--font-size: 20px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="6"]{--font-size: 18px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="7"]{--font-size: 16px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="8"]{--font-size: 14px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading]{font-size:var(--font-size);line-height:var(--line-height);font-weight:700}.editor-disable-scroll{position:fixed;left:0;top:0;width:100vw;height:100vh;z-index:9900;overflow:hidden}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-anchor{position:absolute;pointer-events:none;z-index:-1}.editor-command-bar.toolbar .color-button{width:24px;height:24px;display:flex;padding:0;margin:0;align-items:center;justify-content:center;background-color:transparent;border:0;outline:0;border-radius:3px;cursor:pointer}.editor-command-bar.toolbar .color-button[data-color="0"]{color:var(--color-0)}.editor-command-bar.toolbar .color-button[data-color="1"]{color:var(--color-1)}.editor-command-bar.toolbar .color-button[data-color="2"]{color:var(--color-2)}.editor-command-bar.toolbar .color-button[data-color="3"]{color:var(--color-3)}.editor-command-bar.toolbar .color-button[data-color="4"]{color:var(--color-4)}.editor-command-bar.toolbar .color-button[data-color="5"]{color:var(--color-5)}.editor-command-bar.toolbar .color-button[data-color="6"]{color:var(--color-6)}.editor-command-bar.toolbar .color-button[data-background-color="0"]{background-color:var(--background-color-0)}.editor-command-bar.toolbar .color-button[data-background-color="1"]{background-color:var(--background-color-1)}.editor-command-bar.toolbar .color-button[data-background-color="2"]{background-color:var(--background-color-2)}.editor-command-bar.toolbar .color-button[data-background-color="3"]{background-color:var(--background-color-3)}.editor-command-bar.toolbar .color-button[data-background-color="4"]{background-color:var(--background-color-4)}.editor-command-bar.toolbar .color-button[data-background-color="5"]{background-color:var(--background-color-5)}.editor-command-bar.toolbar .color-button[data-background-color="6"]{background-color:var(--background-color-6)}.editor-command-bar.toolbar .color-button[data-background-color="7"]{background-color:var(--background-color-7)}.editor-command-bar.toolbar .color-button[data-background-color="8"]{background-color:var(--background-color-8)}.editor-command-bar.toolbar .color-button[data-background-color="9"]{background-color:var(--background-color-9)}.editor-command-bar.toolbar .color-button[data-background-color="10"]{background-color:var(--background-color-10)}.editor-command-bar.toolbar .color-button[data-background-color="11"]{background-color:var(--background-color-11)}.editor-command-bar.toolbar .color-button[data-background-color="12"]{background-color:var(--background-color-12)}.editor-command-bar.toolbar .color-button[data-background-color="13"]{background-color:var(--background-color-13)}.editor-command-bar.toolbar .color-button[data-background-color="14"]{background-color:var(--background-color-14)}.tippy-content{white-space:pre-line}.editor-button{min-height:26px;min-width:46px;font-size:12px;font-weight:500;outline:none;background-color:var(--editor-button-bg-color, #338fe5);color:var(--editor-button-color, #fff);border:0;padding:4px 8px;border-radius:4px;margin-right:8px;cursor:pointer}.editor-button:hover{background-color:#5ca5ea}.tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{position:relative;background-color:#333;color:#fff;border-radius:4px;font-size:14px;line-height:1.4;white-space:normal;outline:0;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{bottom:-7px;left:0;border-width:8px 8px 0;border-top-color:initial;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{top:-7px;left:0;border-width:0 8px 8px;border-bottom-color:initial;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-width:8px 0 8px 8px;border-left-color:initial;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{left:-7px;border-width:8px 8px 8px 0;border-right-color:initial;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{width:16px;height:16px;color:#333}.tippy-arrow:before{content:"";position:absolute;border-color:transparent;border-style:solid}.tippy-content{position:relative;padding:5px 9px;z-index:1}[data-theme=dropdown-list]{border-radius:4px;background:white;position:relative;max-width:calc(100vw - 24px);box-shadow:#0f0f0f0d 0 0 0 1px,#0f0f0f1a 0 3px 6px,#0f0f0f33 0 9px 24px;overflow:hidden}[data-theme=dropdown-list] .tippy-content{padding:0;background:white;color:#303030}[data-theme=dropdown-list] .tippy-content .editor-command-bar{max-height:50vh}[data-theme=dropdown-list] .filterable-list{min-width:100px;max-width:300px;display:flex;flex-direction:column;max-height:100%}[data-theme=dropdown-list] .filterable-list .filter{padding:8px}[data-theme=dropdown-list] .filterable-list .filter .filter-container{width:100%;font-size:14px;line-height:20px;padding:3px 6px;position:relative;border-radius:3px;box-shadow:#0f0f0f1a 0 0 0 1px inset;background:rgba(242,241,238,.6);cursor:text;height:28px;box-sizing:border-box;display:flex;align-items:center}[data-theme=dropdown-list] .filterable-list .filter .filter-container input.filter-input{border:none;outline:none;flex-grow:1;background:transparent}[data-theme=dropdown-list] .filterable-list .list{max-height:60vh;overflow-y:auto;padding:8px 0}[data-theme=dropdown-list] .filterable-list .list .list-item{user-select:none;transition:background 20ms ease-in 0s;cursor:pointer;width:calc(100% - 8px);margin-left:4px;margin-right:4px;border-radius:3px;height:24px;padding:4px 8px;display:flex;align-items:center;box-sizing:border-box}[data-theme=dropdown-list] .filterable-list .list .list-item .list-text{white-space:nowrap}[data-theme=dropdown-list] .filterable-list .list .list-item.selected{background-color:#eee}::placeholder{color:#bbb}.toast{font-family:Avenir,Helvetica,Arial,sans-serif;visibility:hidden;min-width:250px;margin-left:-125px;background-color:#333;color:#fff;text-align:center;border-radius:2px;padding:8px;position:fixed;z-index:1;left:50%;bottom:30px}.toast.show{visibility:visible;animation:toast_fade_in .5s,toast_fade_out .5s 2.5s}.toast.positioned.show{animation:toast_fade_in_positioned .5s,toast_fade_out_positioned .5s 2.5s}.toast.positioned{bottom:unset}@keyframes toast_fade_in{0%{bottom:0;opacity:0}to{bottom:30px;opacity:1}}@keyframes toast_fade_out{0%{bottom:30px;opacity:1}to{bottom:0;opacity:0}}@keyframes toast_fade_in_positioned{0%{opacity:0}to{opacity:1}}@keyframes toast_fade_out_positioned{0%{opacity:1}to{opacity:0}}div.tippy-box[data-theme=toolbar] .tippy-content,div.tippy-box[data-theme=menu] .tippy-content{padding:0}div.tippy-box[data-theme=menu] .tippy-content .editor-command-bar.menu{min-width:180px}div.tippy-box button{outline:none}.editor-command-bar{pointer-events:all;display:flex;box-sizing:border-box;--text-color: #606060;--primary-color: #338fe5;--selected-color: #f8f8f8;--separator-color: #dedede;--warn-color: #fdf4f4}.editor-command-bar.menu{display:flex;flex-direction:column;align-items:flex-start;padding:5px 0;background:#ffffff;box-shadow:0 0 1px #30303040,0 12px 24px #30303026;border-radius:2px;max-height:50vh;overflow:auto}.editor-command-bar.menu .command-item.standard{color:var(--text-color);user-select:none;transition:background 20ms ease-in 0s;cursor:pointer;width:100%;height:32px;padding:6px 10px;display:flex;align-items:center;box-sizing:border-box}.editor-command-bar.menu .command-item.standard .menu-item-icon{align-items:center;height:24px;width:24px;margin-right:5px;margin-top:-2px;display:flex;flex-direction:column;justify-content:center}.editor-command-bar.menu .command-item.standard .menu-item-name{white-space:nowrap;flex-grow:1;display:flex;align-items:center}.editor-command-bar.menu .command-item.standard .item-subtext{color:#b2bccd}.editor-command-bar.menu .command-item.standard .menu-item-sub-indicator{display:flex;align-items:center;justify-content:center}.editor-command-bar.menu .command-item.standard .menu-item-sub-indicator svg{width:16px;height:16px}.editor-command-bar.menu .command-item.standard.disabled{color:#c7c7c7;cursor:not-allowed}.editor-command-bar.menu .command-item.separator{height:1px;margin:4px 0;background-color:var(--separator-color);width:100%}.editor-command-bar.menu .command-item.section{font-size:.8em;color:#ccc;padding:5px 5px 5px 10px}.editor-command-bar.menu .command-item.selected{background-color:var(--selected-color)}.editor-command-bar.menu .command-item.selected[data-id=delete]{background-color:var(--warn-color)}.editor-command-bar.menu .command-item.selected.disabled{background-color:transparent}.editor-command-bar.menu .command-item.checked{color:var(--primary-color)}.editor-command-bar.menu .command-item.checked .menu-item-checked-icon{display:flex;align-items:center;justify-content:center;margin-left:10px}.editor-command-bar.menu .command-item.checked.disabled{color:#c7c7c7}.editor-command-bar.menu .command-item span.highlight{color:#e52727}.editor-command-bar.toolbar{display:flex;flex-direction:row;align-items:flex-start;padding:5px 10px;gap:5px;background:#ffffff;box-shadow:0 0 1px #30303033,0 8px 16px #30303026;border-radius:3px}.editor-command-bar.toolbar .command-item{background:transparent;border:none;display:flex;align-items:center;justify-content:center;color:var(--text-color);height:24px;padding:0;cursor:pointer;border-radius:3px;min-width:24px}.editor-command-bar.toolbar .command-item.selected:not(.disabled){background-color:var(--selected-color)}.editor-command-bar.toolbar .command-item.disabled{color:#c7c7c7}.editor-command-bar.toolbar .command-item.checked{color:var(--primary-color)}.editor-command-bar.toolbar .command-item.checked.disabled{color:#c7c7c7}.editor-command-bar.toolbar .command-item.separator{margin:auto 2px;height:20px;min-width:1px;width:1px;background-color:var(--separator-color);padding:0;pointer-events:none;cursor:default}.editor-command-bar.toolbar .command-item .toolbar-item-name-container,.editor-command-bar.toolbar .command-item .toolbar-item-icon-container{display:flex}.editor-command-bar.toolbar .command-item[data-dropdown=true]{padding-left:4px;padding-right:4px}.editor-command-bar.toolbar .command-item[data-dropdown=true] .toolbar-item-icon-container{width:24px;height:24px;align-items:center;justify-content:center}.editor-command-bar.toolbar .command-item .toolbar-item-dropdown-container{display:flex}.editor-command-bar.toolbar .command-item .toolbar-item-dropdown-container svg{transform:rotate(360deg);transition:transform .2s linear}.editor-command-bar.toolbar .command-item.active .toolbar-item-dropdown-container svg{transform:rotate(180deg)}.editor-command-bar.toolbar .editor-button+.editor-button{margin-left:5px}.reference-hidden .tippy-box[data-reference-hidden]{opacity:0;pointer-events:none;transition:none}.tippy-box[data-theme~=light]{color:#26323d;box-shadow:0 0 20px 4px #9aa1b126,0 4px 80px -8px #24282f40,0 4px 4px -2px #5b5e6926;background-color:#fff}.tippy-box[data-theme~=light][data-placement^=top]>.tippy-arrow:before{border-top-color:#fff}.tippy-box[data-theme~=light][data-placement^=bottom]>.tippy-arrow:before{border-bottom-color:#fff}.tippy-box[data-theme~=light][data-placement^=left]>.tippy-arrow:before{border-left-color:#fff}.tippy-box[data-theme~=light][data-placement^=right]>.tippy-arrow:before{border-right-color:#fff}.tippy-box[data-theme~=light]>.tippy-backdrop{background-color:#fff}.tippy-box[data-theme~=light]>.tippy-svg-arrow{fill:#fff}.scale-border:after,.color-palette .palette-container-row .background-color-button.selected:after,.color-palette .palette-container-row .background-color-button:hover:after{content:"";outline:1px solid #d6e9fa;border-radius:3px;position:absolute;left:0;right:0;top:0;bottom:0;transform:scale(1.1)}.color-palette{display:flex;flex-direction:column;align-items:center;padding-top:5px;background-color:#fff;--active-color: #2872b7}.color-palette .bar-desc{box-sizing:border-box;width:100%;height:24px;padding-left:10px;margin-bottom:10px;line-height:24px;font-size:12px;font-weight:500;background:#F8F8F8;color:#909090}.color-palette .palette-container{padding:0 10px}.color-palette .background-color .palette-container-row:first-child{margin-bottom:5px}.color-palette .palette-container-row{display:flex;flex-direction:row;margin-bottom:20px}.color-palette .palette-container-row .color-button{width:24px;height:24px;border:none;outline:none;cursor:pointer;border-radius:3px;background-color:#fff;border:1px solid #f0f0f0;display:flex;margin:0;padding:0;align-items:center;justify-content:center}.color-palette .palette-container-row .color-button:hover{border:1px solid #d6e9fa}.color-palette .palette-container-row .color-button.selected{border:1px solid var(--primary-color)}.color-palette .palette-container-row .color-button[data-color-index="-1"]{color:var(--text-color)}.color-palette .palette-container-row .color-button[data-color-index="0"]{color:var(--color-0)}.color-palette .palette-container-row .color-button[data-color-index="1"]{color:var(--color-1)}.color-palette .palette-container-row .color-button[data-color-index="2"]{color:var(--color-2)}.color-palette .palette-container-row .color-button[data-color-index="3"]{color:var(--color-3)}.color-palette .palette-container-row .color-button[data-color-index="4"]{color:var(--color-4)}.color-palette .palette-container-row .color-button[data-color-index="5"]{color:var(--color-5)}.color-palette .palette-container-row .color-button[data-color-index="6"]{color:var(--color-6)}.color-palette .palette-container-row .background-color-button{width:24px;height:24px;border:none;outline:none;cursor:pointer;border-radius:3px;position:relative}.color-palette .palette-container-row .background-color-button.selected:after{outline:1px solid var(--primary-color)}.color-palette .palette-container-row .background-color-button[data-color-index="-1"]{position:relative;background-color:#fff;border:1px solid #e8e8e8}.color-palette .palette-container-row .background-color-button[data-color-index="-1"]:after{transform:scale(1.2)}.color-palette .palette-container-row .background-color-button[data-color-index="-1"]:before{content:"";position:absolute;width:1px;height:56px;top:2px;left:22px;background-color:#c7c7c7;transform:rotate(45deg) scale(.5);transform-origin:-1px -2px}.color-palette .palette-container-row .background-color-button[data-color-index="0"]{background-color:var(--background-color-0)}.color-palette .palette-container-row .background-color-button[data-color-index="1"]{background-color:var(--background-color-1)}.color-palette .palette-container-row .background-color-button[data-color-index="2"]{background-color:var(--background-color-2)}.color-palette .palette-container-row .background-color-button[data-color-index="3"]{background-color:var(--background-color-3)}.color-palette .palette-container-row .background-color-button[data-color-index="4"]{background-color:var(--background-color-4)}.color-palette .palette-container-row .background-color-button[data-color-index="5"]{background-color:var(--background-color-5)}.color-palette .palette-container-row .background-color-button[data-color-index="6"]{background-color:var(--background-color-6)}.color-palette .palette-container-row .background-color-button[data-color-index="7"]{background-color:var(--background-color-7)}.color-palette .palette-container-row .background-color-button[data-color-index="8"]{background-color:var(--background-color-8)}.color-palette .palette-container-row .background-color-button[data-color-index="9"]{background-color:var(--background-color-9)}.color-palette .palette-container-row .background-color-button[data-color-index="10"]{background-color:var(--background-color-10)}.color-palette .palette-container-row .background-color-button[data-color-index="11"]{background-color:var(--background-color-11)}.color-palette .palette-container-row .background-color-button[data-color-index="12"]{background-color:var(--background-color-12)}.color-palette .palette-container-row .background-color-button[data-color-index="13"]{background-color:var(--background-color-13)}.color-palette .palette-container-row .background-color-button[data-color-index="14"]{background-color:var(--background-color-14)}.color-palette .palette-container-row .color-button+.color-button{margin-left:5px}.color-palette .palette-container-row .background-color-button+.background-color-button{margin-left:5px}.color-palette .clear-button-container{box-sizing:border-box;width:100%;margin-bottom:5px;padding:0 10px}.color-palette .clear-button-container .clear-button{box-sizing:border-box;padding:3px 10px;width:100%;height:26px;background:#ffffff;color:#606060;border:1px solid #c7c7c7;border-radius:3px;cursor:pointer}.color-palette .clear-button-container .clear-button:hover{border-color:var(--primary-color);color:var(--primary-color)}.color-palette .clear-button-container .clear-button:active{border-color:var(--active-color);color:var(--active-color);background-color:#d6e9fa}.editor-input-wrap .editor-input-label{margin-top:8px;margin-bottom:8px;position:relative}.editor-input-wrap .editor-input-label.required:before{content:"*";color:#e82100;position:absolute;left:-8px;top:3px}.editor-input-wrap .editor-input-label .span{font-size:14px;line-height:1.4;font-weight:700;color:#303030}.editor-input-wrap .editor-input-container{display:flex;border:none;border-radius:4px;padding:4px;background-color:#fff}.editor-input-wrap .editor-input-container .editor-input{outline:none;border:1px solid #c7c7c7;border-radius:3px;padding:4px 10px;font-size:14px;line-height:1.4;color:#000;width:100%}.editor-input-wrap .editor-input-container .editor-input:focus{border-color:#338fe5;box-shadow:0 0 0 2px #338fe533}.editor-input-wrap.error .editor-input-container{border:1px solid #e82100}.editor-input-wrap.error .editor-input-container .editor-input{border:none;outline:none;box-shadow:unset}.editor-input-wrap.error .editor-input-error{margin-top:8px;color:red;display:block}.editor-input-wrap .editor-input-error{display:none}div.scroll-container-root{position:relative}div.scroll-container-root>div.scroll-container{position:relative;overflow-x:auto;overflow-y:hidden;box-sizing:border-box;line-height:0px}div.scroll-container-root>div.scroll-container>.scroll-area{position:relative;display:inline-block;overflow:hidden;line-height:normal}div.scroll-container-root>div.scroll-container{scrollbar-width:none}div.scroll-container-root>div.scroll-container::-webkit-scrollbar{height:0;opacity:0}div.scroll-container-root>div.container-scroll-tool .container-border-shadow{position:absolute;top:0;opacity:0;width:0;border:none;pointer-events:none;transition:opacity 50ms ease-in;z-index:1}div.scroll-container-root>div.container-scroll-tool .container-right-border-shadow{right:0;background:linear-gradient(90deg,rgba(31,35,41,0) 0,rgba(31,35,41,.1));border-right:0px solid #dee0e3}div.scroll-container-root>div.container-scroll-tool .container-left-border-shadow{left:0;background:linear-gradient(270deg,rgba(31,35,41,0) 0,rgba(31,35,41,.1));border-left:0px solid #dee0e3}div.scroll-container-root>div.container-scroll-tool .container-border-shadow.active{width:8px;opacity:1}div.scroll-container-root>div.container-scroll-tool .container-right-border-shadow.active{border-right-width:1px}div.scroll-container-root>div.container-scroll-tool .container-left-border-shadow.active{border-left-width:1px}div.scroll-container-root>div.container-scroll-tool .container-scrollbar{position:absolute;left:0;z-index:1000;visibility:visible;overflow-x:auto;overflow-y:hidden;cursor:auto}div.scroll-container-root>div.container-scroll-tool .container-scrollbar div{height:1px}div.scroll-container-root>div.container-scroll-tool div.container-scrollbar.fixed{position:fixed}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar{opacity:.6;transition:opacity .1s ease-in-out}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar::-webkit-scrollbar{height:8px}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar::-webkit-scrollbar-track{background-color:transparent}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar::-webkit-scrollbar-thumb{background-color:#646a73cc;border-radius:8px}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar::-webkit-scrollbar-button{display:none}[data-tippy-root]{font-family:Avenir,Helvetica,Arial,sans-serif}[data-command-bar-id=editor-toolbar]{padding-top:10px;padding-bottom:5px}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text]{height:32px;width:unset}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text].selected:hover{background-color:transparent}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text] .link-href-button{max-width:275px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#303030;text-decoration:none}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text] .link-href-button:hover{text-decoration:underline}[data-command-bar-id=editor-toolbar] .command-item[data-id=edit-link],[data-command-bar-id=editor-toolbar] .command-item[data-id=remove-link]{height:32px}[data-command-bar-id=editor-toolbar] .command-item[data-id=edit-link] svg,[data-command-bar-id=editor-toolbar] .command-item[data-id=remove-link] svg{stroke-width:2}[data-command-bar-id=editor-toolbar] .command-item[data-id=edit-link].selected:hover,[data-command-bar-id=editor-toolbar] .command-item[data-id=remove-link].selected:hover{background-color:transparent;color:#338fe5}[data-command-bar-id=quick-menu],[data-command-bar-id=empty-block-menu]{box-sizing:border-box;width:240px}[data-command-bar-id=quick-menu] .command-item.menu-item,[data-command-bar-id=empty-block-menu] .command-item.menu-item{width:100%;cursor:pointer}[data-command-bar-id=quick-menu] .command-item.menu-item.section,[data-command-bar-id=empty-block-menu] .command-item.menu-item.section{height:24px;padding:2px 10px;font-weight:500;font-size:12px;line-height:20px;color:#909090;background:#F8F8F8;min-height:initial;box-sizing:border-box;margin-bottom:5px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item{color:#303030;display:flex;width:100%;padding:6px 10px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-icon-container,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-icon-container{display:flex;align-items:center;justify-content:center;padding-right:6px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-icon-container .quick-menu-item-icon,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-icon-container .quick-menu-item-icon{width:16px;height:16px;display:flex;align-items:center;justify-content:center}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content{flex-grow:1;display:flex;flex-direction:column;justify-content:center}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1{display:flex;align-items:center}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .item-name,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .item-name{flex-grow:1;font-size:14px;line-height:22px;color:#303030}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .item-subtext,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .item-subtext{color:#b2bccd}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .quick-menu-item-submenu-icon,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .quick-menu-item-submenu-icon{display:flex;align-items:center;margin-left:12px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-2,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-2{margin-top:5px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-2 .item-markdown,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-2 .item-markdown{color:#b2bccd}[data-command-bar-id=quick-menu] .command-item.menu-item[data-id=placeholder] .quick-menu-item-icon-container,[data-command-bar-id=empty-block-menu] .command-item.menu-item[data-id=placeholder] .quick-menu-item-icon-container{display:none}[data-command-bar-id=quick-menu] .command-item.menu-item[data-id=placeholder] .item-name.text,[data-command-bar-id=empty-block-menu] .command-item.menu-item[data-id=placeholder] .item-name.text{color:#909090!important;padding:5px 0}[data-command-bar-id=block-menu]{width:240px}div.tippy-box .editor-tooltip-desc{display:block;margin-top:2px;color:#a8a9ab}.link-popup-content{padding:10px 7px}.link-popup-content .link-popup-gap{margin-top:16px}.link-popup-content .editor-input-container{padding:4px 0}.link-popup-content .editor-input-container .editor-input{width:330px;line-height:1.5}.link-popup-content .editor-input-wrap .editor-input-label{margin-bottom:4px}.link-popup-content .link-popup-footer{margin:10px 0 5px;text-align:right}.link-popup-content .link-popup-footer button{min-width:58px;min-height:30px;padding:0 10px;border-radius:3px;background-color:#eef3f8;font-size:14px;color:#fff;cursor:pointer;outline:none}.link-popup-content .link-popup-footer .cancel-button{margin:0 8px 0 0;background-color:transparent;border:1px solid #c7c7c7;color:#606060}.link-popup-content .link-popup-footer .cancel-button:hover{color:#303030;background:#eee;border:1px solid #c7c7c7}.link-popup-content .link-popup-footer .submit-button{outline:none;background-color:#338fe5;color:#fff;border:0}.link-popup-content .link-popup-footer .submit-button:disabled{color:#fff;background-color:#338fe580}.link-popup-content .link-popup-footer .submit-button:disabled:hover{background-color:#338fe580}.link-popup-content .link-popup-footer .submit-button:hover{background-color:#5ca5ea}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="1"]{padding-left:24px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="1"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="2"]{padding-left:48px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="2"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="3"]{padding-left:72px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="3"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="4"]{padding-left:96px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="4"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="5"]{padding-left:120px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="5"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="6"]{padding-left:144px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="6"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="7"]{padding-left:168px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="7"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="8"]{padding-left:192px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="8"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="9"]{padding-left:216px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="9"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="10"]{padding-left:240px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="10"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="11"]{padding-left:264px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="11"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="12"]{padding-left:288px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="12"]>div[data-type=block-content]{position:relative}:root{--mindmap-bg-color: #f0f2f4}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block.focused [data-type=block-tools] .editor-mindmap-svg{border-radius:3px;outline:1px solid #338FE5}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block.editor-in-mindmap-first{height:600px;min-width:150px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-content]{margin-right:24px;transition:background-color .25s linear}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-tools] .editor-mindmap-svg{position:absolute;left:0;top:0;right:0;bottom:0;z-index:2;font-size:14px;background-color:var(--mindmap-bg-color)}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-tools] .mindmap-toolbar{position:absolute;top:8px;right:8px;height:24px;z-index:3}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-tools] .mindmap-toolbar .editor-button.mindmap-button{background-color:transparent;outline:none;border:none;fill:none;color:#c1c1c1;cursor:pointer;min-width:initial;margin-right:0}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-tools] .mindmap-toolbar .editor-button.mindmap-button:hover{color:#5587f0}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block.to-mindmap-highlight [data-type=block-content],.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block.to-mindmap-highlight:hover [data-type=block-content]{background-color:#eaf3fc}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block .list-to-mindmap-wrap,.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block .mention-button-wrap{position:absolute;right:0;top:2px;display:flex;align-items:center;height:calc(var(--font-size) * var(--line-height))}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=list-to-mindmap],.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=mention-button]{flex-grow:0;flex-shrink:0;width:24px;height:24px;min-width:24px;min-height:24px;padding:0;border:0;outline:0;display:flex;align-items:center;justify-content:end;background-color:transparent;color:#07142a}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=list-to-mindmap] svg,.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=mention-button] svg{width:16px;height:16px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=list-block-mention]:hover>svg{cursor:initial;background-color:#eee}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button+button[data-button-id=list-block-mention]{right:20px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="1"]{padding-left:0}div.editor-root div.editor-content div[data-block-type=list][data-list-level="2"]{padding-left:24px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="3"]{padding-left:48px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="4"]{padding-left:72px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="5"]{padding-left:96px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="6"]{padding-left:120px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="7"]{padding-left:144px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="8"]{padding-left:168px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="9"]{padding-left:192px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="10"]{padding-left:216px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="11"]{padding-left:240px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="12"]{padding-left:264px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block+div[data-type=editor-block].list-block{margin-top:0}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block{display:flex;padding-bottom:2px;padding-top:2px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block[data-list-type=text-only] .list-container{pointer-events:none}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block[data-list-type=checked] div[data-type=block-content] span.text{color:#c7c7c7}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block[data-list-type=unordered] .list-container .list-marker{font-family:PingFangSC-Regular,PingFang SC;justify-content:space-around}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-content]{position:relative;flex-grow:1;padding-left:2px;margin-right:29px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block .list-container{display:flex;min-width:24px;align-items:center;justify-content:center;flex-shrink:0;border-radius:3px;height:calc(var(--font-size) * var(--line-height))}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block .list-container .list-marker{min-width:16px;border:none;background-color:transparent;outline:none;display:flex;align-items:center;justify-content:flex-end;padding:0;overflow:visible;color:var(--primary-color);font-size:var(--font-size)}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block div[data-type=block-tools] .block-helper{top:2px}.editor-root.readonly button[data-button-id=mindmap-close]{display:none}.editor-root:not(.readonly) div[data-type=editor-block].list-block.active [data-type=block-content],.editor-root:not(.readonly) div[data-type=editor-block].list-block.hover [data-type=block-content]{background-color:#f4f4f4}.editor-root:not(.readonly) div[data-type=editor-block].list-block.active [data-type=block-content] .list-container,.editor-root:not(.readonly) div[data-type=editor-block].list-block.hover [data-type=block-content] .list-container{cursor:pointer}.editor-root:not(.readonly) div[data-type=editor-block].list-block .list-container:hover .list-marker{cursor:pointer}.editor-root:not(.readonly) div[data-type=editor-block].list-block:not([data-list-type=unchecked]):not([data-list-type=checked]) .list-container:hover{background-color:var(--background-selection)}.editor-root:not(.readonly) div[data-type=editor-block].list-block[data-list-type=unchecked] .list-container:hover .list-marker svg>*{fill:var(--background-selection)}[data-tippy-root] .customize-start-panel{max-width:350px;padding:0 16px;color:#333;font-size:14px;line-height:21px;user-select:none;background-color:#fff!important}[data-tippy-root] .customize-start-panel-input{width:64px;margin:0 8px;border:1px solid #CFD6E1;height:24px;border-radius:3px;padding:1px 0 1px 8px;outline:none;color:inherit;background-color:#fff}[data-tippy-root] .customize-start-panel-button{min-width:40px;font-size:12px;min-height:30px;margin:0 8px 0 0;background-color:var(--primary-color);color:#fff;outline:none;border:none;padding:4px 8px;border-radius:4px;cursor:pointer}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.math-box{display:inline-flex}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.math-box .mathjax-tex-text.mathjax-error{color:var(--color-0)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] img.mathjax{max-width:100%}div.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-embed-type=math]>div[data-type=block-content]{align-items:center;justify-content:center;min-height:40px}div.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-embed-type=math]>div[data-type=block-content] img{margin:auto;padding:8px}.mathjax-editor-textarea{border:none;outline:none;width:400px;height:128px}.editor-text-button{border:0;color:var(--text-button-color, #c1c1c1);background-color:var(--text-button-bg-color, transparent);cursor:pointer;border-radius:var(--editor-border-radius, 3px);font-size:14px;padding:1px 6px;display:flex;align-items:center}.editor-text-button:hover{color:var(--text-button-color-hover, #5587F0);background-color:var(--text-button-bg-color-hover, transparent)}div[data-type=editor-block].table-block{--table-bar-width: 6px;--table-bar-left: -6px;--table-bar-top: -6px}div[data-type=editor-block].table-block>div[data-type=block-content]{position:relative;left:-26px}div[data-type=editor-block].table-block.locked-by-self>[data-type=block-content]:after,div[data-type=editor-block].table-block.locked-by-others>[data-type=block-content]:after{display:none}div[data-type=editor-block].table-block.locked-by-self>[data-type=block-content] div[data-type=table-content],div[data-type=editor-block].table-block.locked-by-others>[data-type=block-content] div[data-type=table-content]{position:relative}div[data-type=editor-block].table-block.locked-by-self>[data-type=block-content] div[data-type=table-content]:after,div[data-type=editor-block].table-block.locked-by-others>[data-type=block-content] div[data-type=table-content]:after{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#303030;opacity:.1}div[data-type=editor-block].table-block div[data-type=table-tools] .table-resize-gripper{position:absolute;background-color:transparent;cursor:col-resize;padding:0 2px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-resize-gripper>.table-resize-gripper-indicator{pointer-events:none;background-color:var(--primary-color);width:100%;height:100%}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container{position:absolute;background-color:transparent;z-index:10}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container.top{left:var(--table-bar-left);top:var(--table-bar-top);right:0;height:var(--table-bar-width);flex-direction:row}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container.left{top:0;left:var(--table-bar-left);width:var(--table-bar-width);bottom:0;flex-direction:column}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar{position:absolute;left:0;top:0;right:0;bottom:0;cursor:pointer;display:flex}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar.left{flex-direction:column}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell{background-color:#e8e8e8;position:relative;flex-grow:0;flex-shrink:0}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.corner{width:var(--table-bar-width)}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.top{height:100%}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell:hover{background-color:#dedede}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.selected{background-color:var(--primary-color)}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.danger{background-color:#e52727}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root{position:relative}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root.top{max-width:0;width:0;overflow:visible}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root.top:last-child{margin-left:-2px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root.left{max-height:0;height:0;overflow:visible}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root.left:last-child{margin-top:-2px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container{position:absolute;width:26px;height:26px;display:flex;align-items:center;justify-content:center;z-index:1}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container.top{right:-14px;top:-22px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container.left{transform:rotate(270deg);left:-22px;bottom:-14px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container .insert-indicator{position:absolute;width:3px;height:3px;background:#e8e8e8;border-radius:50%;margin-top:6px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .insert-indicator{display:none}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .insert-column-button{display:unset}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .insert-column-button span.icon{margin-top:2px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .drop-marker{opacity:1;transform:scale(.7)}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container .drop-marker{width:26px;height:26px;border-radius:3px;background:var(--primary-color);cursor:pointer;opacity:0;transform:scale(.4);transition:transform .2s ease-in,opacity .2s ease-in}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container .drop-marker:after{content:"";display:block;width:10px;height:1px;background-color:#fff;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container .drop-marker:before{content:"";display:block;width:1px;height:10px;background-color:#fff;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}div[data-type=editor-block].table-block div[data-type=table-tools] .editor-table-chart{padding-top:16px}div[data-type=editor-block].table-block div[data-type=table-content]{position:relative}div[data-type=editor-block].table-block div[data-type=table-content] .error{color:red;border:1px solid red;padding:8px}div[data-type=editor-block].table-block div[data-type=table-content]>table{border-collapse:collapse;width:max-content;border-spacing:0}div[data-type=editor-block].table-block div[data-type=table-content]>table colgroup col{min-width:40px}div[data-type=editor-block].table-block div[data-type=table-content]>table,div[data-type=editor-block].table-block div[data-type=table-content]>table td,div[data-type=editor-block].table-block div[data-type=table-content]>table th{border:1px solid #c7c7c7;background-color:transparent}div[data-type=editor-block].table-block div[data-type=table-content]>table tr td.danger{background-color:#fce9e9!important}div[data-type=editor-block].table-block div[data-type=table-content]>table td{min-width:40px;padding:0;position:relative}div[data-type=editor-block].table-block div[data-type=table-content]>table td .table-cell-menu-btn{display:none;position:absolute;right:2px;top:2px;padding:0;width:16px;height:16px;border:none;border-radius:3px;background:#eaf3fc;color:#338fe5;cursor:pointer;transform:rotate(0);transition:transform .2s}div[data-type=editor-block].table-block div[data-type=table-content]>table td .table-cell-menu-btn.active{transform:rotate(180deg)}div[data-type=editor-block].table-block div[data-type=table-content]>table td>div[data-type=editor-container].child{padding:8px}div[data-type=editor-block].table-block div[data-type=table-content]>table td>div[data-type=editor-container].child div[data-type=editor-block].table-block>div[data-type=block-content]{pointer-events:none}div[data-type=editor-block].table-block div[data-type=table-content]>table td>div[data-type=editor-container].child div[data-type=editor-block].table-block>div[data-type=block-content] div[data-type=table-content]{pointer-events:auto}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-0{background-color:var(--background-color-0)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-1{background-color:var(--background-color-1)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-2{background-color:var(--background-color-2)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-3{background-color:var(--background-color-3)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-4{background-color:var(--background-color-4)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-5{background-color:var(--background-color-5)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-6{background-color:var(--background-color-6)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-7{background-color:var(--background-color-7)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-8{background-color:var(--background-color-8)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-9{background-color:var(--background-color-9)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-10{background-color:var(--background-color-10)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-11{background-color:var(--background-color-11)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-12{background-color:var(--background-color-12)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-13{background-color:var(--background-color-13)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-14{background-color:var(--background-color-14)}div[data-type=editor-block].table-block div[data-type=table-content]>table.row-title>tbody>tr:first-child>td,div[data-type=editor-block].table-block div[data-type=table-content]>table.col-title td.col-title-item{background-color:#f8f8f8}div[data-type=editor-block].table-block div[data-type=table-content]>table.stripe:not(.row-title)>tbody>tr:nth-of-type(2n),div[data-type=editor-block].table-block div[data-type=table-content]>table.stripe.row-title>tbody>tr:nth-of-type(2n + 1){background-color:#f5f8fb}div[data-type=editor-block].table-block div[data-type=table-content]>table.no-border,div[data-type=editor-block].table-block div[data-type=table-content]>.no-border>tbody>tr>td{border:1px dashed;border-color:transparent}div[data-type=editor-block].table-block.focused div[data-type=table-content]>table.no-border,div[data-type=editor-block].table-block.focused div[data-type=table-content]>table.no-border>tbody>tr>td,div[data-type=editor-block].table-block.child-focused div[data-type=table-content]>table.no-border,div[data-type=editor-block].table-block.child-focused div[data-type=table-content]>table.no-border>tbody>tr>td{border-color:#b9bfc8}div[data-type=editor-block].table-block.full-selected>div[data-type=block-content]>.scroll-container-root>.scroll-container>.scroll-area>div[data-type=table-content]>table{background-color:var(--background-selection)}div[data-type=editor-block].table-block div[data-type=table-content]>table tbody tr td.selected,div[data-type=editor-block].table-block div[data-type=table-content]>table.row-title tbody tr td.selected,div[data-type=editor-block].table-block div[data-type=table-content]>table.col-title tbody tr td.selected{background-color:var(--background-selection)}div[data-type=editor-block].table-block div[data-type=table-content]>table td div[data-type=editor-block].table-block div[data-type=table-content]>table{max-width:100%}.command-item.menu-item .table-creator{background-color:#fff;padding:0 5px}.command-item.menu-item .table-creator .table-creator-row{display:flex}.command-item.menu-item .table-creator .table-creator-row .table-creator-cell{width:16px;height:16px;margin:3px;border:solid 1px #ddd}.command-item.menu-item .table-creator .table-creator-row .table-creator-cell.active{background-color:#99c7f2}div.editor-root div.editor-content div[data-type=editor-container].root div[data-type=editor-block].table-block{margin-top:0}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color]{width:100%}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .bar-desc{display:none}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item{box-sizing:border-box;width:100%;height:32px;padding:5px 10px;display:flex;align-items:center;justify-content:space-between;color:var(--text-color)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-sub-indicator{display:flex;align-items:center;margin-left:5px}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-sub-indicator svg{height:16px;width:16px}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button{width:24px;height:24px;border:none;outline:none;cursor:pointer;border-radius:3px;position:relative;margin-left:auto}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="-1"]{position:relative;background-color:#fff;border:1px solid #e8e8e8}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="-1"]:after{transform:scale(1.2)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="-1"]:before{content:"";position:absolute;width:1px;height:56px;top:2px;left:22px;background-color:#c7c7c7;transform:rotate(45deg) scale(.5);transform-origin:-1px -2px}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="0"]{background-color:var(--background-color-0)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="1"]{background-color:var(--background-color-1)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="2"]{background-color:var(--background-color-2)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="3"]{background-color:var(--background-color-3)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="4"]{background-color:var(--background-color-4)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="5"]{background-color:var(--background-color-5)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="6"]{background-color:var(--background-color-6)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="7"]{background-color:var(--background-color-7)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="8"]{background-color:var(--background-color-8)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="9"]{background-color:var(--background-color-9)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="10"]{background-color:var(--background-color-10)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="11"]{background-color:var(--background-color-11)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="12"]{background-color:var(--background-color-12)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="13"]{background-color:var(--background-color-13)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="14"]{background-color:var(--background-color-14)}div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table]{background-color:transparent}div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table] table.row-title>tbody>tr:first-child>td,div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table] table.col-title td.col-title-item{background-color:transparent}div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table] table.stripe:not(.row-title)>tbody>tr:nth-of-type(2n),div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table] table.stripe.row-title>tbody>tr:nth-of-type(2n + 1){background-color:transparent}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer{position:absolute;background-color:transparent;border:1px solid #338FE5;pointer-events:none;z-index:1;display:none}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer.active{display:block}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper{position:absolute;width:16px;height:16px;border:2px solid white;background-color:#338fe5;border-radius:50%;pointer-events:all}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.bottom{left:calc(50% - 8px);bottom:-8px;cursor:ns-resize}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.top-left{left:-8px;top:-8px;cursor:nwse-resize}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.top-right{right:-8px;top:-8px;cursor:nesw-resize}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.bottom-left{left:-8px;bottom:-8px;cursor:nesw-resize}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.bottom-right{right:-8px;bottom:-8px;cursor:nwse-resize}div.editor-root.readonly div.editor-content div[data-type=editor-block]>[data-type=block-tools] .block-resizer{display:none}.editor-dialog-container{min-width:500px;position:relative;left:-9px}.editor-dialog-container .dialog-header{display:flex;justify-content:space-between;align-items:center;padding:0 20px;border-bottom:1px solid #e8e8e8}.editor-dialog-container .dialog-header .close-icon{cursor:pointer}.editor-dialog-container .dialog-header .dialog-header-title{padding:8px 0 11px;font-size:18px;font-weight:700;flex-grow:1}.editor-dialog-container .dialog-content{padding:20px;border-bottom:1px solid #e8e8e8}.editor-dialog-container .dialog-footer{margin:10px 0 5px;padding:0 20px;text-align:right}.editor-dialog-container .dialog-footer button{min-width:58px;min-height:30px;padding:0 10px;border-radius:3px;background-color:#eef3f8;font-size:14px;color:#fff;cursor:pointer}.editor-dialog-container .dialog-footer .cancel-button{margin:0 8px 0 0;background-color:transparent;border:1px solid #c7c7c7;color:#606060}.editor-dialog-container .dialog-footer .cancel-button:hover{color:#303030;background:#eee;border:1px solid #c7c7c7}.editor-dialog-container .dialog-footer .submit-button{outline:none;background-color:#338fe5;color:#fff;border:0}.editor-dialog-container .dialog-footer .submit-button:hover{background-color:#5ca5ea}.embed-block[data-embed-type=webpage]{height:400px;min-height:100px;max-height:1000px}.embed-block[data-embed-type=webpage] .webpage-mask{position:absolute;left:0;right:0;top:0;bottom:0;z-index:1;background-color:transparent}.embed-block[data-embed-type=webpage].resizing [data-type=block-tools] .block-resizer{pointer-events:all!important}.embed-block[data-embed-type=webpage].hover>div[data-type=block-content]{outline:none!important}.embed-block[data-embed-type=webpage].selected>div[data-type=block-content]{outline:none!important}.embed-block[data-embed-type=webpage]>div[data-type=block-content]{justify-content:center;height:100%}.embed-block[data-embed-type=webpage]>div[data-type=block-content]>.editor-embed{width:100%}.embed-block[data-embed-type=webpage]>div[data-type=block-content]>.editor-embed .editor-preview-iframe{width:100%;max-height:500px;height:100%;border:none;position:relative}.embed-block[data-embed-type=webpage]>div[data-type=block-content]>.editor-embed .editor-preview-iframe-loading{position:absolute;top:0;left:0;bottom:0;right:0;display:flex;justify-content:center;align-items:center;background-color:#fff}.webpage-content .help-container{color:#303030;border:1px solid #dedede;padding:10px;border-radius:4px;border-left:4px solid #338fe5;margin-top:16px;margin-bottom:16px}.webpage-content .help-container .help-content{display:flex;align-items:center}.webpage-content .help-container .help-content .help-icon{color:#338fe5;margin-right:12px}.webpage-content .help-link-container{margin-top:8px;display:flex;align-items:center}.webpage-content .help-link-container .help-link-content{display:flex;align-items:center;color:#338fe5;text-decoration:none}.webpage-content .help-link-container .help-link-content .help-link-icon{width:16px;height:16px;margin-left:8px}div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-embed-type=webpage]>div[data-type=block-content]:before{display:block}div.editor-root:not(.readonly) div.editor-content div[data-type=editor-container] div[data-type=editor-block] [data-type=block-content][data-title-placeholder]:before{position:absolute;left:0;top:0;right:0;bottom:0;content:attr(data-title-placeholder);color:#c7c7c7}div.editor-root:not(.readonly) div.editor-content div[data-type=editor-container] div[data-type=editor-block] [data-type=block-content][data-content-placeholder]:before{position:absolute;left:0;top:0;right:0;bottom:0;content:attr(data-content-placeholder);color:#c7c7c7;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:flex;align-items:center}div.editor-root:not(.readonly) div.editor-content div[data-type=editor-container] div[data-type=editor-block] [data-type=block-tools] .block-placeholder-container{position:absolute;left:0;top:0;right:0}div.editor-root.readonly div.editor-content div[data-type=editor-container] div[data-type=editor-block] [data-type=block-content][data-title-placeholder]:before{position:absolute;left:0;top:0;right:0;bottom:0;content:attr(data-title-placeholder-readonly);color:#c7c7c7}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block{min-width:360px;counter-reset:code-line}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.full-selected{background-color:var(--background-selection)}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.editing-language div[data-type=block-tools] .code-block-header,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.child-focused div[data-type=block-tools] .code-block-header,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block:hover div[data-type=block-tools] .code-block-header{opacity:1}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.wrap>div[data-type=block-tools] .code-block-header button[data-id=wrap] *{color:var(--primary-color)}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block:not(.wrap)>div[data-type=block-content] div[data-type=editor-container].child{overflow-x:auto}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block:not(.wrap)>div[data-type=block-content] div[data-type=editor-container].child div[data-type=block-content]{word-break:keep-all;overflow:visible;white-space:pre}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block:not(.wrap)>div[data-type=block-content] div[data-type=editor-container].child div[data-type=block-content]>span.text,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block:not(.wrap)>div[data-type=block-content] div[data-type=editor-container].child div[data-type=block-content]>span.inputting-insertion{white-space:pre}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header{opacity:0;transition:opacity .3s ease-in 0s;position:absolute;top:0;display:flex;padding-left:16px;padding-right:4px;align-items:center;left:0;right:0;height:32px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .language-select{font-size:14px;color:#999;cursor:pointer;display:flex;align-items:center}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .language-select .arrow-icon{width:16px;height:16px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .code-header-spacer{flex-grow:1}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .code-header-button{display:flex;justify-content:center;align-items:center;height:24px;background:#ddd;border:none;border-radius:2px;margin-left:4px;cursor:pointer}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .code-header-button .button-icon{width:16px;height:16px;display:flex;align-items:center;justify-content:center}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .code-header-button .button-label{margin-left:4px;font-size:14px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.full-selected>div[data-type=block-content]>div.editor-code-root>div.code-text-root{background-color:unset}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root{background-color:var(--background-code)}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container]{padding-left:32px;padding-top:32px;padding-bottom:24px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container].selected{background-color:var(--background-selection)}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] *{font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:14px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block+div.text-block{margin-top:4px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block:before{content:counter(code-line);counter-increment:code-line;position:absolute;left:-48px;top:10px;z-index:1;margin-top:-6px;display:block;width:48px;padding-right:8px;text-align:right;color:#aaa;box-sizing:border-box;font-size:12px;font-weight:400;line-height:12px;letter-spacing:0;white-space:nowrap;opacity:1}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-comment,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-prolog,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-doctype,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-cdata{color:#708090}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-punctuation{color:#999}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-namespace{opacity:.7}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-property,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-tag,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-boolean,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-number,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-constant,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-symbol,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-deleted{color:#905}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-selector,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-attr-name,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-string,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-char,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-builtin,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-inserted{color:#690}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-operator,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-entity,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-url,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-string{color:#9a6e3a}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-atrule,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-attr-value,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-keyword{color:#07a}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-function,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-class-name{color:#dd4a68}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-regex,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-important,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-variable{color:#e90}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-important,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-bold{font-weight:700}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-italic{font-style:italic}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-entity{cursor:help}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-caption-root{padding:8px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-caption-root *{color:#aaa}div.editor-root div.editor-content div[data-type=editor-container].root.select-all div[data-type=block-content]>div.editor-code-root>div.code-text-root{background-color:unset}.before-content,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].selected [data-type=block-content] .images .image-container.active:before,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].selected:not(.focused) [data-type=block-content] .images .image-container:before{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#338fe5;opacity:.1}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image]{display:flex}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image][data-style-align=left]{justify-content:flex-start}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image][data-style-align=right]{justify-content:flex-end}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].hover [data-type=block-content]{outline:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].hover [data-type=block-content] .images .image-container.empty:hover,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].hover [data-type=block-content] .images .image-container.error:hover{outline:1px solid #338FE5}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].selected [data-type=block-content]:before{display:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].selected [data-type=block-content]{outline:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].multi [data-type=block-tools] .block-resizer{display:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image]:not(.multi) [data-type=block-content] .images.empty{min-height:400px}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content]{cursor:default}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images{width:100%;display:flex;align-items:flex-start}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-splitter{width:10px;flex-grow:0;flex-shrink:0;padding:0 4px;cursor:col-resize;height:100%}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-splitter .image-splitter-indicator{width:100%;height:100%}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-splitter:active .image-splitter-indicator,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-splitter:hover .image-splitter-indicator{background-color:#d9d9d9}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container{position:relative;flex:1;background-color:#f8f8f8;display:flex;min-height:inherit}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container img{max-width:100%;width:100%;height:auto}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.empty .upload-image-icon{color:#c7c7c7}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.error{height:100%;outline:1px solid #DEDEDE;border-radius:3px}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.error img{display:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error{position:absolute;left:0;top:0;right:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:1}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-icon,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-icon{color:#c7c7c7}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message{display:flex;flex-direction:column;align-items:center;overflow:hidden}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-1,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-1{margin-top:10px;font-size:18px;font-weight:500;color:#303030;height:26px;vertical-align:middle;line-height:26px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex-shrink:0}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-2,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-3,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-2,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-3{font-size:14px;color:#606060;vertical-align:middle;height:22px;line-height:22px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex-shrink:0}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-2 a,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-3 a,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-2 a,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-3 a{text-decoration:none;color:#338fe5}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .line-3 a{display:inline-flex;align-items:center;text-decoration:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .line-3 a:after{content:" ";display:inline-block;width:16px;height:16px;margin-left:5px;background-image:url("data:image/svg+xml,%3Csvg width='17' height='16' viewBox='0 0 17 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6.5 2H3.5C2.94772 2 2.5 2.44772 2.5 3V13C2.5 13.5523 2.94772 14 3.5 14H13.5C14.0523 14 14.5 13.5523 14.5 13V10' stroke='%23338FE5'/%3E%3Cpath d='M14.5 2L9 7.5' stroke='%23338FE5'/%3E%3Cpath d='M8.5 2H14.5V8' stroke='%23338FE5'/%3E%3C/svg%3E%0A")}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .uploading-progress-mask{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#303030;opacity:.8;display:flex;align-items:center;justify-content:center}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .uploading-progress-mask .uploading-progress-bar{width:75%;height:6px;border-radius:3px;display:flex;background-color:#fff}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .uploading-progress-mask .uploading-progress-bar .uploading-progress-bar-value{background-color:#338fe5}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .image-warning{position:absolute;right:5px;top:5px;color:#fff;background-color:#f8f8f8;width:24px;height:24px;display:flex;align-items:center;justify-content:center;border-radius:3px;z-index:2}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.empty{display:flex;flex-direction:column;align-items:center;outline:1px solid #DEDEDE;border-radius:3px;justify-content:center}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.empty svg{width:64px;height:64px}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-tools] .drag-container{display:flex;box-sizing:content-box;pointer-events:none;position:fixed;z-index:100;background-color:#fff;border:1px solid #338FE5}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-tools] .drag-container .drag-target{width:100%}.editor-root[readonly=true] .image-splitter{visibility:hidden}.editor-root .editor-content div[data-type=editor-block].dragging div[data-type=block-tools] .block-helper{opacity:0}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper{position:absolute;right:100%;top:0;padding-right:8px;display:flex;align-items:center}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .helper-sizer{width:0;opacity:0;pointer-events:none}div[data-type=editor-block].locked-by-self>[data-type=block-content],div[data-type=editor-block].locked-by-others>[data-type=block-content]{position:relative}div[data-type=editor-block].locked-by-self>[data-type=block-content]:after,div[data-type=editor-block].locked-by-others>[data-type=block-content]:after{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;z-index:1;background-color:#303030;opacity:.1}div[data-type=editor-block].locked-by-self.text-block>[data-type=block-content]:after,div[data-type=editor-block].locked-by-self.locked-by-self>[data-type=block-content]:after,div[data-type=editor-block].locked-by-others.text-block>[data-type=block-content]:after,div[data-type=editor-block].locked-by-others.locked-by-self>[data-type=block-content]:after{pointer-events:none}div[data-type=editor-block].locked-by-self.text-block>[data-type=block-content]:after,div[data-type=editor-block].locked-by-others.text-block>[data-type=block-content]:after{outline:2px solid #303030}.editor-root{--selected-color: #e8e8e8}.editor-root .editor-content .editor-drop-indicator{position:absolute;background-color:var(--primary-color);pointer-events:none;transition:top .2s linear,left .2s linear,width .2s linear}.editor-root .editor-content div[data-type=editor-block].text-block.highlighted{outline:2px solid var(--background-selection);background-color:var(--background-selection)}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .block-button{width:24px;height:24px;cursor:grab;margin:0;padding:0;display:flex;align-items:center;justify-content:center;background-color:transparent;border:none;border-radius:3px}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .block-button:hover{background-color:var(--selected-color)}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .block-button svg{width:16px;height:16px;color:#909090}.drag-image-container{position:fixed;z-index:100;box-shadow:0 3px 20px #00000026;background-color:#fff;opacity:.4}.drag-image-container.drag-placeholder{width:500px;height:200px;border:1px solid #dedede;border-radius:3px;background:#e8e8e8}.drag-image-container .drag-image{width:100%;display:none}.drag-image-container[data-status=loaded] .drag-image{display:block}.drag-image-container[data-status=loaded] .drag-loading{display:none}.editor-command-bar-root .editor-command-bar .command-item.menu-item{display:flex;align-items:center;flex:none}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles{padding:5px 10px;background-color:#fff}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section+.text-style-section{margin-top:5px}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section{display:flex;flex-wrap:wrap}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section .style-icon{width:24px;height:24px;padding:0;margin:0 5px 0 0;display:flex;align-items:center;justify-content:center;background-color:transparent;border:none;outline:none;cursor:pointer;border-radius:3px;color:#606060}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section .style-icon:hover{background-color:var(--selected-color)}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section .style-icon.active{color:#338fe5}div[data-type=editor-block].block-exclusive:after{content:attr(data-user-name);position:absolute;top:0px;left:0px;padding:2px;background:#faf8f3;color:#f8ac09;opacity:.95;font-size:12px;border-radius:var(--editor-border-radius);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;right:0;bottom:0}:root{--editor-quoted-color: #7084a4;--editor-drawio-empty-svg: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0zOC43MjAzIDI4LjcwOTdIMjUuOTIzM0MyNS4yMTY1IDI4LjcwOTcgMjQuNjQzNSAyOC4xNDgxIDI0LjY0MzUgMjcuNDU1MlYyNS43MzMzSDIwLjUyODNDMjAuNDk4NiAyNS43Njk2IDIwLjQ2NjkgMjUuODA0MiAyMC40MzMzIDI1LjgzN0wxNS45MTkyIDMwLjI2MjFWMzQuNzU1NkgyNC42NDM1VjMzLjcyNzZDMjQuNjQzNSAzMy4wMzQ4IDI1LjIxNjUgMzIuNDczMiAyNS45MjMzIDMyLjQ3MzJIMzguNzIwM0MzOS40MjcgMzIuNDczMiA0MCAzMy4wMzQ4IDQwIDMzLjcyNzZWMzguNzQ1NUM0MCAzOS40MzgzIDM5LjQyNyA0MCAzOC43MjAzIDQwSDI1LjkyMzNDMjUuMjE2NSA0MCAyNC42NDM1IDM5LjQzODMgMjQuNjQzNSAzOC43NDU1VjM3LjMzMzNIMTQuNjI2M0MxMy45MTIyIDM3LjMzMzMgMTMuMzMzMyAzNi43NTYyIDEzLjMzMzMgMzYuMDQ0NFYzMC42OTQxTDguMzc4NTIgMjUuODM3QzguMTM2MjYgMjUuNjAxNCA4IDI1LjI4MDggOCAyNC45NDYzQzggMjQuNjExOCA4LjEzNjI2IDI0LjI5MTEgOC4zNzg1MiAyNC4wNTU2TDEzLjMzMzMgMTkuMTk4NVYxNS43NzJDMTEuNzc5OCAxNS4yMjI5IDEwLjY2NjcgMTMuNzQxNiAxMC42NjY3IDEyQzEwLjY2NjcgOS43OTA4NSAxMi40NTc1IDggMTQuNjY2NyA4QzE2Ljg3NTggOCAxOC42NjY2IDkuNzkwODUgMTguNjY2NiAxMkMxOC42NjY2IDEzLjcyNjUgMTcuNTU4OCAxNS4yNTgxIDE1LjkxOTEgMTUuNzk4OFYxOS4yODg4QzE1LjkxOTEgMTkuMzkxOCAxNS45MDY4IDE5LjQ5NDMgMTUuODgyMyAxOS41OTQzTDE5LjUxNTEgMjMuMTU1NUgyNC42NDM1VjIyLjQzNzNDMjQuNjQzNSAyMS43NDQ1IDI1LjIxNjUgMjEuMTgyOSAyNS45MjMzIDIxLjE4MjlIMzguNzIwM0MzOS40MjcgMjEuMTgyOSA0MCAyMS43NDQ1IDQwIDIyLjQzNzNWMjcuNDU1MkM0MCAyOC4xNDgxIDM5LjQyNyAyOC43MDk3IDM4LjcyMDMgMjguNzA5N1pNMjcuMjAzIDM3LjQ5MUgzNy40NDA2VjM0Ljk4MjFIMjcuMjAzVjM3LjQ5MVpNMTQuNDA1OSAyOC4xOTU0TDExLjA5MTUgMjQuOTQ2M0wxNC40MDU5IDIxLjY5NzJMMTcuNzIwNCAyNC45NDYzTDE0LjQwNTkgMjguMTk1NFpNMjcuMjAzIDI2LjIwMDhIMzcuNDQwNlYyMy42OTE4SDI3LjIwM1YyNi4yMDA4WiIgZmlsbD0iIzA3MTQyQSIvPgo8L3N2Zz4K)}.flex-center,.editor-drawio-iframe-container.loading:before,.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed:after,.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed:before{display:flex;align-items:center;justify-content:center}.full-screen,.editor-drawio-iframe-container.loading:before,.drawio-iframe-element,.editor-drawio-iframe-container{width:100%;height:100%}.editor-drawio-iframe-container{position:fixed;top:0;left:0;z-index:1000}div[data-type=editor-block].embed-block[data-embed-type=drawio]>div[data-type=block-content]{outline:1px solid #DEDEDE}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio]>div[data-type=block-content]{justify-content:center;border-radius:3px;padding:10px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio]>div[data-type=block-content] .editor-drawio-content{text-align:center}.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed{width:240px;height:80px;display:inline-block;text-align:center}.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed:before{background-image:var(--editor-drawio-empty-svg);position:absolute;content:" ";color:var(--editor-quoted-color);top:8px;left:calc(50% - 24px);width:48px;height:48px}.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed:after{position:absolute;content:attr(data-empty-drawio-content);color:var(--editor-quoted-color);bottom:0;left:0;width:100%;height:32px;top:50%}div.editor-root div.editor-content div[data-type=editor-container] div[data-embed-type=drawio].embed-block>div[data-type=block-content] img{max-width:100%;height:auto}.editor-drawio-iframe-container.loading:before{content:attr(data-placeholder);position:absolute;top:0;left:0;background-color:#f7f6f3;z-index:2}.editor-content .editing{background-color:#cdcdcd40}.editor-content div[data-type=block-tools] .embed-code-editor-container{position:absolute;top:0;left:0px;right:0px;bottom:0;background-color:#cdcdcd40;z-index:var(--wiz-editor-z-embed-code-editor-mask);padding:8px}.editor-content div[data-type=block-tools] .embed-code-editor-container textarea{width:100%;height:100%;resize:none;outline:none;padding:12px;border:1px solid #b9bfc8;border-radius:4px;background-color:#fff;color:#333}.flex-row-center,.embed-block div[data-type=block-content] .graph-embed,div[data-embed-type=mermaid] div[data-type=block-content] .graph-embed,div[data-embed-type=flowchart] div[data-type=block-content] .graph-embed,div[data-embed-type=plantuml] div[data-type=block-content] .graph-embed,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block div[data-type=block-content] .empty-embed:after,div[data-embed-type=mermaid] div[data-type=block-content] .empty-embed:after,div[data-embed-type=flowchart] div[data-type=block-content] .empty-embed:after,div[data-embed-type=plantuml] div[data-type=block-content] .empty-embed:after,.embed-block,div[data-embed-type=mermaid],div[data-embed-type=flowchart],div[data-embed-type=plantuml]{display:flex;flex-direction:row;align-items:center;justify-content:center}.embed-block div[data-type=block-content],div[data-embed-type=mermaid] div[data-type=block-content],.embed-block div[data-type=block-content],div[data-embed-type=flowchart] div[data-type=block-content],.embed-block div[data-type=block-content],div[data-embed-type=plantuml] div[data-type=block-content]{width:100%;position:relative}.embed-block div[data-type=block-content] .empty-embed,div[data-embed-type=mermaid] div[data-type=block-content] .empty-embed,.embed-block div[data-type=block-content] .empty-embed,div[data-embed-type=flowchart] div[data-type=block-content] .empty-embed,.embed-block div[data-type=block-content] .empty-embed,div[data-embed-type=plantuml] div[data-type=block-content] .empty-embed{width:100%;min-height:106px;background-color:#cdcdcd40}.embed-block div[data-type=block-content] .empty-embed:after,div[data-embed-type=mermaid] div[data-type=block-content] .empty-embed:after,.embed-block div[data-type=block-content] .empty-embed:after,div[data-embed-type=flowchart] div[data-type=block-content] .empty-embed:after,.embed-block div[data-type=block-content] .empty-embed:after,div[data-embed-type=plantuml] div[data-type=block-content] .empty-embed:after{content:attr(data-empty-tips);position:absolute;top:0;right:0;width:100%;height:100%;color:#07142a;white-space:nowrap}.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed){width:100%;height:100px}.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed) img,div[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed) img,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed) img,div[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed) img,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed) img,div[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed) img{display:none}.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed):after,div[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed):after,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed):after,div[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed):after,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed):after,div[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed):after{content:attr(data-invalid-text);position:absolute;top:0;right:0;width:100%;height:100%;outline:1px solid red;display:flex;flex-direction:row;align-items:center;justify-content:center;color:red}.embed-block div[data-type=block-content] .embed-img-content,div[data-embed-type=mermaid] div[data-type=block-content] .embed-img-content,.embed-block div[data-type=block-content] .embed-img-content,div[data-embed-type=flowchart] div[data-type=block-content] .embed-img-content,.embed-block div[data-type=block-content] .embed-img-content,div[data-embed-type=plantuml] div[data-type=block-content] .embed-img-content{width:100%;text-align:center}.embed-block div[data-type=block-content] .mermaid-embed-img,div[data-embed-type=mermaid] div[data-type=block-content] .mermaid-embed-img,.embed-block div[data-type=block-content] .mermaid-embed-img,div[data-embed-type=flowchart] div[data-type=block-content] .mermaid-embed-img,.embed-block div[data-type=block-content] .mermaid-embed-img,div[data-embed-type=plantuml] div[data-type=block-content] .mermaid-embed-img{max-width:100%;min-width:200px}.embed-block div[data-type=block-content] .editor-plantuml-img,div[data-embed-type=mermaid] div[data-type=block-content] .editor-plantuml-img,.embed-block div[data-type=block-content] .editor-plantuml-img,div[data-embed-type=flowchart] div[data-type=block-content] .editor-plantuml-img,.embed-block div[data-type=block-content] .editor-plantuml-img,div[data-embed-type=plantuml] div[data-type=block-content] .editor-plantuml-img{max-width:100%}.embed-block div[data-type=block-content] .embed-graph-img-content,div[data-embed-type=mermaid] div[data-type=block-content] .embed-graph-img-content,.embed-block div[data-type=block-content] .embed-graph-img-content,div[data-embed-type=flowchart] div[data-type=block-content] .embed-graph-img-content,.embed-block div[data-type=block-content] .embed-graph-img-content,div[data-embed-type=plantuml] div[data-type=block-content] .embed-graph-img-content{width:100%;text-align:center;padding:10px}.embed-block div[data-type=block-content] .embed-graph-img-content img,div[data-embed-type=mermaid] div[data-type=block-content] .embed-graph-img-content img,.embed-block div[data-type=block-content] .embed-graph-img-content img,div[data-embed-type=flowchart] div[data-type=block-content] .embed-graph-img-content img,.embed-block div[data-type=block-content] .embed-graph-img-content img,div[data-embed-type=plantuml] div[data-type=block-content] .embed-graph-img-content img{max-width:100%}.embed-block div[data-type=block-content] .graph-embed,div[data-embed-type=mermaid] div[data-type=block-content] .graph-embed,.embed-block div[data-type=block-content] .graph-embed,div[data-embed-type=flowchart] div[data-type=block-content] .graph-embed,.embed-block div[data-type=block-content] .graph-embed,div[data-embed-type=plantuml] div[data-type=block-content] .graph-embed{width:100%}.hr-transition,.embed-block div[data-type=block-content] .editor-embed-container .editor-embed-hr{transition:border-top ease-in-out .4s}.embed-block div[data-type=block-content] .editor-embed-container{display:flex;align-items:center;width:100%}.embed-block div[data-type=block-content] .editor-embed-container .editor-embed-hr{display:block;width:100%;border:none;margin:0;border-top:2px dashed #cccccc;cursor:pointer}.embed-block:is(.focused) div[data-type=block-content] .editor-embed-container .editor-embed-hr{caret-color:transparent}.embed-block[data-type=editor-block][data-embed-type=hr]>div[data-type=block-content] .editor-embed-container{height:30px}.embed-block[data-type=editor-block][data-embed-type=hr].hover>div[data-type=block-content]{outline:none!important}.embed-block[data-type=editor-block][data-embed-type=hr].selected>div[data-type=block-content]{outline:none!important}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-anchor[data-id=paste-special-button-anchor]{z-index:unset}[data-command-bar-id=paste-special-button] .editor-command-bar.toolbar{padding:0}[data-command-bar-id=paste-special-button] .editor-command-bar.toolbar .command-item[data-dropdown=true]{padding-left:5px;padding-right:5px}.editor-find-dialog{--popover-input-border: 1px solid #CFD6E1;--editor-find-dialog-input-container-border-color: #CFD6E1;--editor-find-dialog-input-container-bg-color: transparent;--editor-border-radius-big: 3px;--editor-color: #07142A;--button-black-text-color: #333;--editor-find-dialog-button-color: #333;--editor-find-dialog-icon-button-color: #333;--editor-find-dialog-button-border-bg-color: rgba(255, 255, 255, .56);--editor-find-dialog-input-placeholder-color: #b9bfc8;--editor-find-dialog-button-disabled-color: #ccc !important;--editor-find-dialog-button-hover-color: rgba(150, 150, 150, .2);--editor-find-dialog-button-border: solid 1px #ccc;box-sizing:border-box;width:400px;background-color:var(--editor-find-dialog-bg-color);border:var(--editor-find-dialog-border);border-radius:var(--editor-border-radius-big);display:flex;padding:8px 8px 0 16px;align-items:flex-start;font-size:14px;font-family:var(--editor-font-family)}.editor-find-dialog .editor-find-content{display:flex;flex-direction:column;flex-grow:1;font-family:inherit}.editor-find-dialog .editor-find-dialog-row{display:flex;margin-bottom:8px;align-items:center}.editor-find-dialog .editor-find-dialog-label{width:80px;flex-grow:0;flex-shrink:0;align-self:center}.editor-find-dialog .editor-find-dialog-input-container{border:var(--popover-input-border);border-color:var(--editor-find-dialog-input-container-border-color);background-color:var(--editor-find-dialog-input-container-bg-color);border-radius:var(--editor-border-radius-big);flex-grow:1;display:flex;padding:2px;align-items:center;height:32px;box-sizing:border-box}.editor-find-dialog .editor-find-dialog-input{border:none;flex-grow:1;width:80px;outline:none;background-color:transparent;color:var(--editor-color)}.editor-find-dialog .editor-find-dialog-input::placeholder{color:var(--editor-find-dialog-input-placeholder-color);opacity:1}.editor-find-dialog .editor-find-dialog-prev{width:24px}.editor-find-dialog .editor-find-dialog-curr{flex-grow:0;text-align:center;flex-shrink:1;display:flex;align-items:center;margin-bottom:2px}.editor-find-dialog .editor-find-dialog-next{width:24px}.editor-find-dialog .editor-find-dialog-icon-button{cursor:pointer;border-radius:4px;color:var(--editor-find-dialog-icon-button-color);background-color:var(--editor-find-dialog-button-border-bg-color);border:none;display:flex;padding:0}.editor-find-dialog .editor-find-dialog-button{padding:6px 16px;cursor:pointer;border-radius:4px;color:var(--editor-find-dialog-button-color);background-color:var(--editor-find-dialog-button-border-bg-color);margin:0 4px;border:none;font-family:inherit;line-height:21px}.editor-find-dialog .editor-find-dialog-button.icon-button{width:32px;height:32px}.editor-find-dialog .editor-find-dialog-button.active,.editor-find-dialog .editor-find-dialog-button:hover{background-color:var(--editor-find-dialog-button-hover-color)}.editor-find-dialog .editor-find-dialog-button:disabled{color:var(--editor-find-dialog-button-disabled-color);cursor:default}.editor-find-dialog .editor-find-dialog-button:disabled:hover{background-color:transparent}.editor-find-dialog .editor-find-dialog-button svg{fill:currentColor}.editor-find-dialog .editor-find-dialog-space{flex-grow:1}.editor-find-dialog .editor-find-dialog-icon-button-border{margin:0 0 0 8px;cursor:pointer;border-radius:4px;color:var(--button-black-text-color);border:var(--editor-find-dialog-button-border);background-color:var(--editor-find-dialog-button-border-bg-color);padding:0;width:32px;display:flex;justify-content:center;align-items:center}.editor-find-dialog .editor-find-dialog-button-close{margin:0 0 0 8px;cursor:pointer;border-radius:4px;color:var(--button-black-text-color);background-color:var(--editor-find-dialog-button-border-bg-color);border:none;padding:0;width:32px;height:32px;display:flex;justify-content:center;align-items:center}.editor-find-dialog .editor-find-dialog-icon-button-border svg,.editor-find-dialog .editor-find-dialog-button-close svg{fill:currentColor}.editor-find-dialog .editor-highlight{opacity:.6;pointer-events:none}.editor-find-dialog .editor-highlight .editor-highlight-child{position:absolute;background-color:bisque}.editor-find-dialog .editor-highlight.active .editor-highlight-child{position:absolute;background-color:tomato}.editor-find-dialog .editor-search-result-highlight{opacity:.6;pointer-events:none}.editor-find-dialog .editor-search-result-highlight .editor-highlight-child{position:absolute;background-color:#40e0d0}.editor-find-dialog .editor-find-dialog-status{display:flex}.editor-highlight{opacity:.6;pointer-events:none}.editor-highlight .editor-highlight-child{position:absolute;background-color:bisque}.editor-highlight.active .editor-highlight-child{position:absolute;background-color:tomato}.editor-search-result-highlight{opacity:.6;pointer-events:none}.editor-search-result-highlight .editor-highlight-child{position:absolute;background-color:#40e0d0}.editor-find-dialog-status{display:flex}.comment-editor{font-size:14px;border:1px solid #c7c7c7;border-radius:3px;padding:1px 10px;margin:6px 10px 0}.comment-editor:after{content:"";height:0;display:block;clear:both}.comment-editor-root{display:inline-block;min-width:calc(100% - 40px);padding-top:2px}.comment-editor-root .editor-root .editor-content{padding:0}.comment-editor-img{float:right;color:#c1c1c1;padding:0}.comment-editor-root:not(.comment-editor-readonly) .editor-root .editor-content [data-type=editor-block]:not([data-block-type=text]){width:248px}.comment-editor-editing{border:1px solid #338fe5}.comment-editor-readonly{border:none;padding-left:37px;margin:0}.comment-editor-readonly .comment-editor-img{display:none}.comment-item-root{position:relative;margin-top:10px}.comment-item-root:not(.last-comment-item):before{content:" ";display:block;position:absolute;left:20px;width:1px;background-color:var(--editor-border-color, #e8e8e8);overflow:hidden;opacity:.8;top:21px;bottom:-12px;transform:scaleX(.5)}.comment-item-root .item-head{padding:0 10px;position:relative;display:flex;align-items:center}.comment-item-root .item-head-avatar{margin-right:5px;width:var(--editor-comment-avatar-width, 21px);height:var(--editor-comment-avatar-width, 21px);border-radius:100%}.comment-item-root .item-head-username{font-size:var(--editor-comment-username-font-size, 12px);color:var(--editor-comment-username-color, #07142a);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.comment-item-root .item-head-modified{margin-left:8px;font-size:12px;color:var(--editor-comment-modified-color, #808080);flex-grow:1;white-space:nowrap}.comment-item-root .item-head-tools{display:flex;align-items:center;visibility:hidden}.comment-item-root .item-head-tools .editor-text-button svg{width:20px;height:20px}.comment-item-root .item-head-tools.active{visibility:visible}.comment-item-root .item-actions{margin-top:10px;display:flex;justify-content:flex-end}.comment-item-root .item-actions.hidden{display:none}.comment-item-root .item-actions .editor-button[data-button-id=comment-item-cancel]{color:#606060;background:transparent;border:1px solid #c7c7c7}.comment-item-root .item-actions .editor-button[data-button-id=comment-item-cancel]:hover{color:#303030;background:#eee;border:1px solid #c7c7c7}.comment-item-root .item-actions .editor-button.disabled[data-button-id=comment-item-ok]{color:#fff;background-color:#338fe580;cursor:default}.comment-item-root:hover:not(.comment-item-editing) .item-head-tools{visibility:visible}.comment-item-root.readonly .item-head-tools{display:none}.mobile-comment-item{margin-top:4px;background-color:var(--editor-comment-layer-bg-color);padding-bottom:20px;color:var(--editor-comment-username-color)}.mobile-comment-item .item-head{padding:12px;display:flex;align-items:center}.mobile-comment-item .item-head-avatar{width:var(--editor-comment-avatar-size);height:var(--editor-comment-avatar-size);flex-grow:0}.mobile-comment-item .item-head-username{margin-left:12px}.mobile-comment-item .item-head-modified{margin-left:12px;color:#999}.mobile-comment-item .item-editor .comment-editor-readonly{padding-left:18px}.mini-comment-item{position:relative;line-height:16px;width:20px;height:16px;text-align:center;font-size:12px;border-radius:1px;background-color:var(--editor-comment-active-color, #FFC328);color:var(--editor-comment-mini-text-color, #ffffff);cursor:pointer}.mini-comment-item:after{content:"";position:absolute;left:50%;bottom:-4px;width:6px;height:6px;background-color:var(--editor-comment-active-color, #FFC328);border-radius:1px;transform:matrix(.71,.61,.82,-.71,0,0) translate(-50%);z-index:-1}.comment-quick-reply .quick-reply-button{position:absolute;left:8px;bottom:3px;z-index:2;color:var(--editor-comment-quick-reply-color, #7084A4);font-size:12px}.comment-quick-reply .quick-reply-button.editor-text-button:hover{color:var(--text-button-color-hover, #5587F0);background-color:var(--text-button-bg-color-hover, transparent)}.comment-quick-reply .quick-reply-editor{display:none}.comment-quick-reply .quick-reply-editor .reply-editor-actions{display:flex;justify-content:flex-end;margin-top:10px}.comment-quick-reply .quick-reply-editor .reply-editor-actions .editor-button[data-button-id=quick-reply-cancel]{color:#606060;background:transparent;border:1px solid #c7c7c7}.comment-quick-reply .quick-reply-editor .reply-editor-actions .editor-button[data-button-id=quick-reply-cancel]:hover{color:#303030;background:#eee;border:1px solid #c7c7c7}.comment-quick-reply .quick-reply-editor .reply-editor-actions .editor-button.disabled[data-button-id=quick-reply-ok]{color:#fff;background-color:#338fe580;cursor:default}.comment-quick-reply.hidden,.comment-quick-reply.reply-editor-editing .quick-reply-button{display:none}.comment-quick-reply.reply-editor-editing .quick-reply-editor{display:block}:root{--editor-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Robot, "Helvetica Neue", Helvetica, Arial, sans-serif;--editor-comment-layer-bg-color:#ffffff;--editor-comment-group-bg-color: #ffffff;--comment-root-border-color: #eaeaea;--editor-comment-layer-active-border-color: #cecece;--editor-box-shadow: 0px 3px 20px rgba(0, 0, 0, .15);--wiz-editor-z-comment-group-active-top-before: 29;--editor-comment-quote-color: #909090;--editor-comment-quote-before-bg-color: #909090;--editor-comment-switch-button-width: 12px;--editor-comment-active-color: #FFC328;--editor-bg-color: #ffffff;--wiz-editor-z-comment-head:11;--text-button-color-hover:#5587f0;--editor-comment-username-color:#07142A;--editor-comment-avatar-size: 32px}.disabled-scroll{overflow:hidden}.editor-root .editor-content div[data-type=editor-block].text-block.comment span{border-bottom:2px solid #f8e6ab}.editor-root .editor-content div[data-type=editor-block].text-block.comment.active span{background-color:#f8e6ab}.editor-root .editor-content div[data-type=editor-block] span.text.comment{border-bottom:2px solid #f8e6ab}.editor-root .editor-content div[data-type=editor-block] span.text.comment.active{background-color:#f8e6ab}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-comment-button{all:unset;position:absolute;right:-28px;top:0;width:24px;height:24px;display:flex;align-items:center;justify-content:center;padding:0;border-radius:3px;color:#07142a;cursor:pointer}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-comment-button:hover{background:#eaeaea}.editor-web-comment-root{position:absolute;right:0;width:300px;top:0;bottom:0;transition:width .16s ease-in;will-change:width;font-family:var(--editor-font-family)}.editor-web-comment-root .comment-groups-container .comment-group-item-root{position:absolute;left:50%;right:0;width:290px;transform:translate(-50%);background-color:var(--editor-comment-group-bg-color);border-radius:2px;border-color:var(--editor-comment-layer-active-border-color);box-shadow:var(--editor-box-shadow);padding-bottom:18px}.editor-web-comment-root .comment-groups-container .comment-group-item-root:not(.no-animation){transition:top .2s ease-in,opacity .35s ease-in}.editor-web-comment-root .comment-groups-container .comment-group-item-root:before{content:"";position:absolute;left:0;right:0;height:6px;background-color:#fff;border-radius:2px 2px 0 0;z-index:var(--wiz-editor-z-comment-group-active-top-before)}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head{display:flex;align-items:center}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-quote{font-size:12px;line-height:12px;height:12px;color:var(--editor-comment-quote-color);padding:18px 12px 10px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;width:100%;max-width:calc(100% - 80px)}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-quote:before{content:"";display:block;width:2px;height:100%;background-color:var(--editor-comment-quote-before-bg-color);margin-right:6px;float:left;border-radius:10px}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch{display:flex;align-items:center;height:22px;padding-top:6px;visibility:hidden}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch .editor-text-button{padding:0;width:var(--editor-comment-switch-button-width);margin:3px 0;color:#606060}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch .editor-text-button[data-button-id=switch-up]{margin-right:16px}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch .editor-text-button:not(.disabled):hover{color:var(--text-button-color-hover)}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch .editor-text-button.disabled{color:#60606080;cursor:not-allowed}.editor-web-comment-root .comment-groups-container .comment-group-item-root.active:before{background-color:var(--editor-comment-active-color)}.editor-web-comment-root .comment-groups-container .comment-group-item-root.active .item-head-switch{visibility:visible}.editor-web-comment-root .comment-groups-container .comment-group-item-root.readonly .comment-quick-reply{display:none}.editor-mobile-comments-root{position:fixed;left:0;right:0;bottom:0;top:0;overflow:hidden;z-index:11}.editor-mobile-comments-root .mobile-comment-mask{position:absolute;left:0;right:0;bottom:0;top:0;background-color:#00000073}.editor-mobile-comments-root .mobile-comment-groups-container{position:absolute;width:100%;height:100vh;z-index:1;overflow:hidden}.editor-mobile-comments-root .mobile-comment-groups-container .mobile-comment-groups-scroll-container{padding:0 12px}.editor-mobile-comments-root .mobile-comment-pull-info-container{position:absolute;right:0;left:0;bottom:100px;z-index:2;text-align:center;display:none}.editor-mobile-comments-root .mobile-comment-pull-info-container .mobile-comment-pull-info{display:inline-block;padding:12px;border-radius:36px;margin:0 auto;background-color:#000c;color:#fff;font-size:12px;opacity:0;transition:opacity .25s cubic-bezier(.65,.05,.36,1)}.editor-mobile-comments-root .mobile-comment-pull-info-container.active{display:block}.editor-mobile-comments-root .mobile-comment-pull-info-container.active .mobile-comment-pull-info{opacity:1}.editor-mobile-comments-root .mobile-group-item-root{margin:0 auto;width:100%;height:100vh;overflow:hidden}.editor-mobile-comments-root .mobile-group-item-root .mobile-group-item{min-height:calc(100vh + 1px);padding-bottom:50px}.editor-mobile-comments-root .mobile-group-item-root .mobile-group-item-space{height:50vh}.editor-mobile-comments-root .mobile-group-item-root .mobile-group-item-abstract{background-color:var(--editor-comment-layer-bg-color);padding:12px;color:#999;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.editor-mini-comment-root{position:absolute;right:0;top:0;bottom:0;width:48px;border-left:1px solid #f0f0f0;transition:width .16s ease-in;will-change:width;font-family:var(--editor-font-family);border:none;background-color:transparent;z-index:11}.editor-mini-comment-root .comment-groups-container{width:100%;height:100%}.editor-mini-comment-root .comment-groups-container .mini-group-item{position:absolute;top:0;left:50%;margin-left:-10px;transition:top .2s cubic-bezier(.65,.05,.36,1)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=file] span[data-type=box-content]{margin:0}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=file] span[data-type=box-content] span.file-icon{display:inline-flex;vertical-align:text-bottom}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=file] span[data-type=box-content] .file-name{color:var(--primary-color);padding:0;border-radius:12px;margin-right:4px;white-space:wrap;word-break:break-all;cursor:pointer}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office]{justify-content:start}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office].hover [data-type=block-content]{border-radius:3px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content]{max-width:360px;min-width:360px;height:48px;cursor:pointer}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root{display:flex;align-items:center;min-width:360px;max-width:100%;background-color:#f5f6f7;border-radius:3px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root:before{border-radius:3px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-details{display:flex;flex-direction:column;justify-content:center;font-size:14px;flex-grow:1}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-details .file-name{color:#1f2329;max-width:185px;display:flex;flex-direction:row;align-items:center;white-space:nowrap}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-details .file-size{color:#646a73;font-size:12px;margin-top:2px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-details .file-name-pre{text-overflow:ellipsis;overflow:hidden}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-actions button{width:34px;height:34px;background-color:#fff;border:1px solid #dee0e3;border-radius:50%;margin:0 8px;padding:0;background-repeat:no-repeat;background-position:50%;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-actions button svg{width:16px;height:16px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-icon{display:flex;width:36px;height:36px;margin:6px 6px 6px 12px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-icon>svg{width:100%;height:100%}:root{--hover-color: #40a9ff}.flex-column-center,.embed-block[data-embed-type=video]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error{display:flex;justify-content:center;align-items:center;flex-flow:column}.common{width:400px;height:180px;background-color:#fafafa;border:1px dashed #d9d9d9;border-radius:2px;transition:border-color .3s}.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error{height:200px}.editor-root .editor-content div[data-type=editor-block].embed-block.media-block-uploading div[data-type=block-tools] .block-helper{display:none}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error{height:400px}.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content]:after,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content]:after,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content]:after,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content]:after{display:none}.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .video-container,.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .audio-container,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .video-container,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .audio-container,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .video-container,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .audio-container,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .video-container,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .audio-container{position:relative}.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .video-container:after,.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .audio-container:after,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .video-container:after,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .audio-container:after,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .video-container:after,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .audio-container:after,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .video-container:after,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .audio-container:after{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#303030;opacity:.1}.embed-block[data-embed-type=video].hover>div[data-type=block-content],.embed-block[data-embed-type=audio].hover>div[data-type=block-content]{outline:none!important}.embed-block[data-embed-type=video].selected>div[data-type=block-content]:before,.embed-block[data-embed-type=audio].selected>div[data-type=block-content]:before{display:none}.embed-block[data-embed-type=video]>div[data-type=block-content],.embed-block[data-embed-type=audio]>div[data-type=block-content]{justify-content:center;max-width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media{width:100%;display:flex;justify-content:center}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress{position:relative;max-width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress audio,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress audio{display:block;width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress video,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress video{display:block;max-width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress .uploading-progress-mask,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress .uploading-progress-mask{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#303030;opacity:.8;display:flex;align-items:center;justify-content:center}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress .uploading-progress-mask .uploading-progress-bar,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress .uploading-progress-mask .uploading-progress-bar{width:75%;height:6px;border-radius:3px;display:flex;background-color:#fff;overflow:hidden}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress .uploading-progress-mask .uploading-progress-bar .uploading-progress-bar-value,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress .uploading-progress-mask .uploading-progress-bar .uploading-progress-bar-value{background-color:#338fe5}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error{width:100%;background:#F8F8F8;outline:1px solid #DEDEDE;border-radius:3px}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error-icon svg,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error-icon svg{width:48px;height:48px;color:#c7c7c7}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error .line-1,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error .line-1{margin-top:10px;font-size:18px;text-align:center;color:#303030}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error .line-2,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error .line-2{margin-top:5px;font-size:14px;text-align:center;color:#606060}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error a,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error a{margin-left:4px;color:#338fe5;cursor:pointer;text-decoration:none}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-empty{width:100%;background:#FFFFFF;outline:1px solid #DEDEDE;border-radius:3px}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-empty svg,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-empty svg{width:48px;height:48px;color:#c7c7c7}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-element,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-element{width:100%;display:flex;justify-content:center}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-element .video-container video,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-element .video-container video{display:block;min-width:50px;max-width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-element .audio-container,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-element .audio-container{width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-element .audio-container audio,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-element .audio-container audio{display:block;width:100%}:root{--editor-version-select-bg-color: green;--editor-version-button-border: black;--editor-bg-color: #ffffff;--editor-version-list-bg-color: #f5f8fb;--editor-version-select-bg-color: #dae6f2}.version-dialog{display:flex;background-color:var(--editor-bg-color);width:100%;height:100%;color:var(--editor-color);font-family:var(--font-family)}.version-dialog-note-viewer{flex:1;display:flex;flex-direction:column;width:0;padding:16px 32px 32px 16px}.version-dialog-note-viewer .dialog-button-text{margin-top:1px;margin-left:-4px}.version-dialog-action-container{height:48px;display:flex;align-items:center;justify-content:space-between;padding-bottom:16px;box-sizing:border-box}.version-dialog-note-viewer .dialog-text-button{outline:none;background:transparent;border:none;display:flex;align-items:center;color:var(--editor-color);font-size:16px;font-weight:500;padding:4px 0;cursor:pointer}.dialog-text-button .dialog-button-icon{margin-right:0;width:24px;height:24px}.dialog-text-button .dialog-button-icon svg{fill:currentColor}.dialog-version-button{outline:none;background:transparent;border:1px solid var(--editor-version-button-border);min-width:88px;height:32px;color:var(--editor-color);font-weight:500;padding:4px 0;border-radius:4px;font-size:16px;cursor:pointer}.dialog-version-button[disabled]{color:#7084a4;cursor:not-allowed;pointer-events:unset;background-color:#cfd6e1}.version-dialog-versions-list{width:320px;background:var(--editor-version-list-bg-color);overflow-y:auto;padding:32px 8px}.version-dialog-list-header{padding:0 12px;font-size:16px;display:flex;align-items:center;margin-top:16px;margin-bottom:12px}.dialog-version-list-item{padding:4px 12px;border-radius:8px;cursor:pointer}.dialog-version-list-item.child{padding-left:32px}.dialog-version-list-item.active{background-color:var(--editor-version-select-bg-color)}.dialog-version-list-item:not(.active):hover{background:rgba(112,132,164,.1)}.dialog-version-list-item-title{display:flex;align-items:center;margin-top:16px;margin-bottom:12px}.dialog-version-list-item-title .dialog-version-list-item-date{font-size:14px}.dialog-version-list-item-now-ver{border-radius:3px;background:#909090;color:#fff;padding:3px 4px;font-size:12px;line-height:14px;margin-left:8px}.dialog-version-list-item-authors{list-style:none;margin:0;padding-left:0;font-size:14px}.dialog-version-list-item-author{display:flex;align-items:center;margin-right:8px;margin-top:8px;margin-bottom:12px}.dialog-version-list-item-mark-author{width:10px;height:10px;border-radius:5px;margin-right:8px;margin-top:1px}.version-dialog-editor{flex-grow:1;overflow-y:auto}.editor-root.history .root-container .editor-block .text-element .inline-plugin.editor-box-loading{display:none}.editor-root.history .editor-content{padding:72px 32px 32px 48px}.version-dialog .dialog-version-item-from-container{color:#909090;font-size:12px;line-height:1.5em;margin-bottom:4px}.editor-root.history .history-inserted-block[data-type=editor-block]:not(.table-block,.list-block,.text-block) [data-type=block-content]{border:4px solid var(--op-selected-color)}.editor-root.history .history-inserted-block[data-type=editor-block]:not(.table-block,.list-block,.text-block){position:relative}.editor-root.history .history-inserted-block[data-type=editor-block]:not(.table-block,.list-block,.text-block):hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history .history-inserted-block[data-type=editor-block].table-block table{border:4px solid var(--op-selected-color)}.editor-root.history .history-inserted-block[data-type=editor-block].table-block table .child{pointer-events:none}.editor-root.history .history-inserted-block[data-type=editor-block].table-block{position:relative}.editor-root.history .history-inserted-block[data-type=editor-block].table-block:hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]{border:4px solid var(--op-selected-color)}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]{position:relative}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]:after,.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]:before{content:" ";position:absolute;display:flex;z-index:var(--wiz-editor-z-history-delete-marker);color:var(--op-color);justify-items:center;align-items:center;justify-content:center;align-content:center;pointer-events:none;overflow:visible;max-width:100%;max-height:100%;left:calc(50% - 16px);top:calc(50% - 2px);width:32px;height:4px;background-color:var(--op-color);transform:rotate(45deg);opacity:1}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]:before{transform:rotate(135deg)}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block){position:relative}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block):hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history .history-inserted-text{line-height:revert!important;background-color:var(--op-selected-color)}.editor-root.history .history-inserted-text{position:relative}.editor-root.history .history-inserted-text:hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history .history-deleted-box{background-color:var(--op-selected-color);text-decoration:line-through}.editor-root.history .history-deleted-box{position:relative}.editor-root.history .history-deleted-box:hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history [data-box-type=history-deleted-box]>span[data-type=box-content]{border:none!important;margin:0!important}.editor-root.history [data-type=editor-block].table-block div[data-type=block-content]{overflow-x:revert}.dialog-root{position:absolute;left:0;top:0;bottom:0;right:0;background-color:#639;z-index:1}.editor-root .editor-content div[data-type=editor-block].heading-collapsed div[data-type=block-tools] .block-helper .heading-collapse-button svg{transform:rotate(270deg)}.editor-root .editor-content div[data-type=editor-block].focused div[data-type=block-tools] .block-helper .heading-marker,.editor-root .editor-content div[data-type=editor-block].highlighted div[data-type=block-tools] .block-helper .heading-marker{display:none}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker,.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-collapse-button{width:24px;height:24px;cursor:grab;margin:0;padding:0;display:flex;align-items:center;justify-content:center;background-color:transparent;border:none;border-radius:3px}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker:hover,.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-collapse-button:hover{background-color:var(--selected-color)}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker svg,.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-collapse-button svg{transform:rotate(360deg);transition:transform .2s linear}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker svg,.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-collapse-button svg{width:16px;height:16px}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker:hover{background-color:transparent}.embed-block div[data-type=block-content] .editor-toc-container{display:block;width:100%;background-color:#f0f0f0;padding:20px}.embed-block div[data-type=block-content] .editor-toc-container.loading{margin:0;min-height:100px}.embed-block div[data-type=block-content] .editor-toc-container .toc-node+.toc-node{margin-top:10px}.embed-block div[data-type=block-content] .editor-toc-container .toc-node .toc-text{cursor:pointer;color:var(--primary-color)}.embed-block div[data-type=block-content] .editor-toc-container .toc-node .toc-children{margin-top:10px;padding-left:20px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=mention] span[data-type=box-content]{margin:0}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=mention] span[data-type=box-content] .mention-name{color:var(--primary-color);padding:0;border-radius:12px;margin-left:4px;margin-right:4px;white-space:wrap;word-break:break-all;cursor:pointer}[data-command-bar-id=editor-mention] .editor-command-bar.menu .command-item.menu-item .menu-item-icon{width:20px;height:20px;border-radius:50%;overflow:hidden}[data-command-bar-id=editor-mention] .editor-command-bar.menu .command-item.menu-item .menu-item-icon img{width:100%;height:100%}[data-command-bar-id=editor-mention] .editor-command-bar.menu .command-item.menu-item .menu-item-name{flex-grow:0;margin-right:5px}.editor-root .editor-templates{position:fixed;bottom:26px;height:256px;width:auto;max-width:100%;padding-left:30px;padding-right:44px;overflow:hidden}.editor-root .editor-templates .editor-templates-title{color:#909090;font-size:14px;margin-left:0;margin-bottom:20px;line-height:19.6px}.editor-root .editor-templates .editor-templates-cards{display:flex;margin-left:0}.editor-root .editor-templates .editor-templates-cards .editor-template-card{box-sizing:border-box;display:flex;flex-direction:column;justify-content:center;cursor:pointer;flex-shrink:0;height:192px;width:188px;background:none;border:1px solid #e8e8e8;border-radius:3px;margin:0 0 0 15px;padding:0;align-items:revert}.editor-root .editor-templates .editor-templates-cards .editor-template-card:first-child{margin-left:0}.editor-root .editor-templates .editor-templates-cards .editor-template-card:hover{box-shadow:0 0 1px #30303033,0 8px 16px #30303026}.editor-root .editor-templates .editor-templates-cards .editor-template-card:hover>.editor-template-name{color:#338fe5}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-name{display:flex;align-items:center;height:40px;width:100%;border-top:1px solid #dedede;padding-left:20px;padding-right:20px;flex:0 0 50px;font-size:14px;font-weight:500;line-height:22px;color:#303030}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-name span{display:block;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.editor-root .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-name{border-top:none}.editor-root .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-name span{padding-left:0;text-align:center}.editor-root .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-thumb-container{display:flex;align-items:center;justify-content:center;padding:16px 39px 14px}.editor-root .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-thumb-container>img{width:110px;height:112px;max-width:revert}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-thumb-container{flex:1;position:relative;padding:10px 5px 0;height:142px;margin:0;overflow:revert}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-thumb-container>img{max-width:100%}div[data-type=editor-block].encrypted-block{border:2px solid #ccc;padding:8px;border-radius:4px}div[data-type=editor-block].encrypted-block.encrypted div[data-type=block-content]{min-height:60px;width:100%}div[data-type=editor-block].encrypted-block.full-selected>div[data-type=block-content]{background-color:var(--background-selection)}div[data-type=editor-block].encrypted-block .password-container{position:absolute;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}`)),document.head.appendChild(t)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
|
|
2
|
-
(function(g,Ie){typeof exports=="object"&&typeof module<"u"?Ie(exports,require("kiwi-intl"),require("lodash.merge"),require("string-template"),require("nanoid"),require("events"),require("query-string"),require("js-base64"),require("snabbdom"),require("lodash.clonedeep"),require("lodash.isequal"),require("quill-delta"),require("tiny-typed-emitter"),require("lodash.intersection"),require("ot-json1"),require("axios"),require("lodash.findlastindex"),require("reconnecting-websocket"),require("fast-sha256"),require("lodash.debounce"),require("tippy.js"),require("blueimp-md5"),require("css-color-converter"),require("markmap-view"),require("lodash.throttle"),require("prismjs"),require("prismjs/components/prism-c"),require("prismjs/components/prism-cpp"),require("prismjs/components/prism-abap"),require("prismjs/components/prism-arduino"),require("prismjs/components/prism-bash"),require("prismjs/components/prism-basic"),require("prismjs/components/prism-clojure"),require("prismjs/components/prism-coffeescript"),require("prismjs/components/prism-csharp"),require("prismjs/components/prism-css"),require("prismjs/components/prism-dart"),require("prismjs/components/prism-diff"),require("prismjs/components/prism-docker"),require("prismjs/components/prism-elixir"),require("prismjs/components/prism-elm"),require("prismjs/components/prism-erlang"),require("prismjs/components/prism-flow"),require("prismjs/components/prism-fortran"),require("prismjs/components/prism-fsharp"),require("prismjs/components/prism-gherkin"),require("prismjs/components/prism-glsl"),require("prismjs/components/prism-go"),require("prismjs/components/prism-graphql"),require("prismjs/components/prism-groovy"),require("prismjs/components/prism-haskell"),require("prismjs/components/prism-java"),require("prismjs/components/prism-javascript"),require("prismjs/components/prism-json"),require("prismjs/components/prism-julia"),require("prismjs/components/prism-kotlin"),require("prismjs/components/prism-latex"),require("prismjs/components/prism-less"),require("prismjs/components/prism-lisp"),require("prismjs/components/prism-livescript"),require("prismjs/components/prism-lua"),require("prismjs/components/prism-makefile"),require("prismjs/components/prism-markdown"),require("prismjs/components/prism-markup"),require("prismjs/components/prism-matlab"),require("prismjs/components/prism-mermaid"),require("prismjs/components/prism-nix"),require("prismjs/components/prism-objectivec"),require("prismjs/components/prism-ocaml"),require("prismjs/components/prism-pascal"),require("prismjs/components/prism-perl"),require("prismjs/components/prism-php"),require("prismjs/components/prism-powershell"),require("prismjs/components/prism-prolog"),require("prismjs/components/prism-protobuf"),require("prismjs/components/prism-python"),require("prismjs/components/prism-r"),require("prismjs/components/prism-reason"),require("prismjs/components/prism-ruby"),require("prismjs/components/prism-rust"),require("prismjs/components/prism-sass"),require("prismjs/components/prism-scala"),require("prismjs/components/prism-scheme"),require("prismjs/components/prism-scss"),require("prismjs/components/prism-solidity"),require("prismjs/components/prism-sql"),require("prismjs/components/prism-swift"),require("prismjs/components/prism-typescript"),require("prismjs/components/prism-vbnet"),require("prismjs/components/prism-verilog"),require("prismjs/components/prism-vhdl"),require("prismjs/components/prism-visual-basic"),require("prismjs/components/prism-wasm"),require("prismjs/components/prism-yaml"),require("mime-db"),require("dom-to-image"),require("plantuml-encoder"),require("@guyplusplus/turndown-plugin-gfm"),require("turndown"),require("marked"),require("@better-scroll/core"),require("docx")):typeof define=="function"&&define.amd?define(["exports","kiwi-intl","lodash.merge","string-template","nanoid","events","query-string","js-base64","snabbdom","lodash.clonedeep","lodash.isequal","quill-delta","tiny-typed-emitter","lodash.intersection","ot-json1","axios","lodash.findlastindex","reconnecting-websocket","fast-sha256","lodash.debounce","tippy.js","blueimp-md5","css-color-converter","markmap-view","lodash.throttle","prismjs","prismjs/components/prism-c","prismjs/components/prism-cpp","prismjs/components/prism-abap","prismjs/components/prism-arduino","prismjs/components/prism-bash","prismjs/components/prism-basic","prismjs/components/prism-clojure","prismjs/components/prism-coffeescript","prismjs/components/prism-csharp","prismjs/components/prism-css","prismjs/components/prism-dart","prismjs/components/prism-diff","prismjs/components/prism-docker","prismjs/components/prism-elixir","prismjs/components/prism-elm","prismjs/components/prism-erlang","prismjs/components/prism-flow","prismjs/components/prism-fortran","prismjs/components/prism-fsharp","prismjs/components/prism-gherkin","prismjs/components/prism-glsl","prismjs/components/prism-go","prismjs/components/prism-graphql","prismjs/components/prism-groovy","prismjs/components/prism-haskell","prismjs/components/prism-java","prismjs/components/prism-javascript","prismjs/components/prism-json","prismjs/components/prism-julia","prismjs/components/prism-kotlin","prismjs/components/prism-latex","prismjs/components/prism-less","prismjs/components/prism-lisp","prismjs/components/prism-livescript","prismjs/components/prism-lua","prismjs/components/prism-makefile","prismjs/components/prism-markdown","prismjs/components/prism-markup","prismjs/components/prism-matlab","prismjs/components/prism-mermaid","prismjs/components/prism-nix","prismjs/components/prism-objectivec","prismjs/components/prism-ocaml","prismjs/components/prism-pascal","prismjs/components/prism-perl","prismjs/components/prism-php","prismjs/components/prism-powershell","prismjs/components/prism-prolog","prismjs/components/prism-protobuf","prismjs/components/prism-python","prismjs/components/prism-r","prismjs/components/prism-reason","prismjs/components/prism-ruby","prismjs/components/prism-rust","prismjs/components/prism-sass","prismjs/components/prism-scala","prismjs/components/prism-scheme","prismjs/components/prism-scss","prismjs/components/prism-solidity","prismjs/components/prism-sql","prismjs/components/prism-swift","prismjs/components/prism-typescript","prismjs/components/prism-vbnet","prismjs/components/prism-verilog","prismjs/components/prism-vhdl","prismjs/components/prism-visual-basic","prismjs/components/prism-wasm","prismjs/components/prism-yaml","mime-db","dom-to-image","plantuml-encoder","@guyplusplus/turndown-plugin-gfm","turndown","marked","@better-scroll/core","docx"],Ie):(g=typeof globalThis<"u"?globalThis:g||self,Ie(g["oneseditor-editor"]={},g.KiwiIntl,g.merge,g.stringFormat,g.nanoid$1,g.events,g.queryString,g.jsBase64,g.snabbdom,g.cloneDeep,g.isEqual,g.Delta,g.tinyTypedEmitter,g.intersection,g.json1,g.axios,g.findLastIndex,g.ReconnectingWebSocket,g.sha256,g.debounce,g.tippy$1,g.md5,g.cssColorConverter,g.markmap,g.throttle,g.Prism,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,g.mime,g.domToImage,g.plantumlEncoder,g.turndownPluginGfm,g.TurndownService,g.marked,g.BetterScroll,g.docx))})(this,function(g,Ie,zo,S7,D7,hm,L7,Ri,io,M7,R7,O7,Yt,N7,P7,$7,_7,F7,H7,j7,iu,z7,su,U7,V7,q7,Nz,Pz,$z,_z,Fz,Hz,jz,zz,Uz,Vz,qz,Wz,Gz,Zz,Qz,Yz,Jz,Kz,Xz,tU,eU,nU,oU,rU,iU,sU,lU,cU,aU,uU,dU,hU,fU,mU,gU,pU,CU,AU,bU,vU,yU,kU,wU,BU,EU,IU,xU,TU,SU,DU,LU,MU,RU,OU,NU,PU,$U,_U,FU,HU,jU,zU,UU,VU,qU,WU,GU,ZU,W7,G7,Z7,Q7,Y7,fm,J7,Y){"use strict";var Rz=Object.defineProperty;var Oz=(g,Ie,zo)=>Ie in g?Rz(g,Ie,{enumerable:!0,configurable:!0,writable:!0,value:zo}):g[Ie]=zo;var h=(g,Ie,zo)=>(Oz(g,typeof Ie!="symbol"?Ie+"":Ie,zo),zo);const Pt=n=>n&&typeof n=="object"&&"default"in n?n:{default:n};function Bl(n){if(n&&n.__esModule)return n;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const K7=Pt(Ie),lu=Pt(zo),X7=Pt(S7),mm=Pt(hm),Q=Pt(M7),El=Pt(R7),se=Pt(O7),cu=Pt(N7),Il=Bl(P7),t8=Pt($7),e8=Pt(_7),n8=Pt(F7),o8=Bl(H7),ee=Pt(j7),r8=Pt(iu),i8=Bl(iu),Er=Pt(z7),s8=Bl(U7),l8=Pt(V7),Oi=Pt(q7),au=Pt(W7),gm=Pt(G7),c8=Pt(Z7),a8=Pt(Y7),pm=Pt(J7);function u8(n){const t=o=>o<10?`0${String(o)}`:String(o),e=o=>o<10?`00${String(o)}`:o<100?`0${String(o)}`:String(o);return`${n.getFullYear()}-${t(n.getMonth()+1)}-${t(n.getDate())} ${t(n.getHours())}:${t(n.getMinutes())}:${t(n.getSeconds())}.${e(n.getMilliseconds())}`}var Ni=(n=>(n.DEBUG="DEBUG",n.INFO="INFO ",n.WARN="WARN ",n.ERROR="ERROR",n))(Ni||{});const Cm=new Map,Ei=class{constructor(t){h(this,"times",new Map);this.category=t}shouldLog(t){const e=Object.values(Ni).indexOf(t),o=Object.values(Ni).indexOf(Ei.level);return e>=o}_log(t,e,o,r){var A;if(!this.shouldLog(t))return;const i=typeof process>"u"?{}:process;let s="";if(typeof e=="object")try{s="message"in e?e.message:JSON.stringify(e,null,4)}catch{s=""}else typeof e=="string"?e&&(s=e):s=JSON.stringify(e);s=r?`${s} - ${r}`:s;const l=`${this.category}`;let c=console.log;t==="WARN "&&(c=console.warn),t==="ERROR"&&(c=console.error);const a=`${u8(new Date)}`,d=t,f=l,m=Ei.extParams?"[{date}] {level}: [{module} {extParams}] - {msg}":"[{date}] {level}: [{module}] - {msg}",p=[X7.default(((A=i.env)==null?void 0:A.LOG_TEMPLATE)||m,{date:a,level:d,module:f,msg:s,extParams:Ei.extParams})];if(typeof e=="object"){const k=e.stack;k&&p.push(k)}if(c===console.error&&Ei.debugMode){const k=new Error().stack;k&&p.push(k)}c(...p),o&&this._log(t,o)}log(t,e){this._log("INFO ",t,void 0,e)}debug(t,e){this._log("DEBUG",t,void 0,e)}info(t,e){this._log("INFO ",t,void 0,e)}warn(t,e,o){this._log("WARN ",t,e,o)}error(t,e,o){this._log("ERROR",t,e,o)}time(t){this.times.set(t,Date.now())}timeEnd(t){this.timeLog(t),this.times.delete(t)}timeLog(t){const e=this.times.get(t);if(!e){this.warn(`no time label: ${t}`);return}this.debug(`${t}: ${Date.now()-e}`)}static setExtParams(t){this.extParams=t}};let so=Ei;h(so,"debugMode",!1),h(so,"level","DEBUG"),h(so,"extParams","");function w(n){const t=Cm.get(n);if(t)return t;const e=new so(n);return Cm.set(n,e),e}const d8={name:"Ones Editor",date:{dateFromFuture:"From future",dateJustNow:"Just now",dateYesterday:"Yesterday",dateMinutesAgo:"{num} minutes ago",date1HourAgo:"1 hour ago",dateHoursAgo:"{num} hours ago",dateDaysAgo:"{num} days ago",dateWeeksAgo:"{num} weeks ago"},common:{cancel:"cancel"}},h8={name:"Ones Editor",date:{dateFromFuture:"\u6765\u81EA\u672A\u6765",dateJustNow:"\u521A\u521A",dateYesterday:"\u6628\u5929",dateMinutesAgo:"{num}\u5206\u949F\u524D",date1HourAgo:"1\u5C0F\u65F6\u524D",dateHoursAgo:"{num}\u5C0F\u65F6\u524D",dateDaysAgo:"{num}\u5929\u524D",dateWeeksAgo:"{num}\u5468\u524D"},common:{cancel:"\u53D6\u6D88"}},f8=w("i18n"),m8={"en-US":d8,"zh-CN":h8},xl=K7.default.init("en-US",m8);function g8(n=void 0){xl.setLang&&xl.setLang(n||"en-US")}function p8(n){lu.default(xl.__metas__,n)}function C8(n,t){const e=xl.get(n,t);return e===n&&f8.warn(`no locale value for key ${n}`),e}const x=Object.freeze(Object.defineProperty({__proto__:null,setLang:g8,mergeLang:p8,t:C8},Symbol.toStringTag,{value:"Module"})),QU="";class Am{constructor(t,e){this.editor=t,this.data=e}getData(){return this.data}getEditor(){return this.editor}destroy(){}}class A8 extends Error{constructor(t){if(super(t),this.code="Assert",this.stack){const e=this.stack.split(`
|
|
2
|
+
(function(g,Ie){typeof exports=="object"&&typeof module<"u"?Ie(exports,require("kiwi-intl"),require("lodash.merge"),require("string-template"),require("nanoid"),require("events"),require("query-string"),require("js-base64"),require("snabbdom"),require("lodash.clonedeep"),require("lodash.isequal"),require("quill-delta"),require("tiny-typed-emitter"),require("lodash.intersection"),require("ot-json1"),require("axios"),require("lodash.findlastindex"),require("reconnecting-websocket"),require("fast-sha256"),require("lodash.debounce"),require("tippy.js"),require("blueimp-md5"),require("css-color-converter"),require("markmap-view"),require("lodash.throttle"),require("prismjs"),require("prismjs/components/prism-c"),require("prismjs/components/prism-cpp"),require("prismjs/components/prism-abap"),require("prismjs/components/prism-arduino"),require("prismjs/components/prism-bash"),require("prismjs/components/prism-basic"),require("prismjs/components/prism-clojure"),require("prismjs/components/prism-coffeescript"),require("prismjs/components/prism-csharp"),require("prismjs/components/prism-css"),require("prismjs/components/prism-dart"),require("prismjs/components/prism-diff"),require("prismjs/components/prism-docker"),require("prismjs/components/prism-elixir"),require("prismjs/components/prism-elm"),require("prismjs/components/prism-erlang"),require("prismjs/components/prism-flow"),require("prismjs/components/prism-fortran"),require("prismjs/components/prism-fsharp"),require("prismjs/components/prism-gherkin"),require("prismjs/components/prism-glsl"),require("prismjs/components/prism-go"),require("prismjs/components/prism-graphql"),require("prismjs/components/prism-groovy"),require("prismjs/components/prism-haskell"),require("prismjs/components/prism-java"),require("prismjs/components/prism-javascript"),require("prismjs/components/prism-json"),require("prismjs/components/prism-julia"),require("prismjs/components/prism-kotlin"),require("prismjs/components/prism-latex"),require("prismjs/components/prism-less"),require("prismjs/components/prism-lisp"),require("prismjs/components/prism-livescript"),require("prismjs/components/prism-lua"),require("prismjs/components/prism-makefile"),require("prismjs/components/prism-markdown"),require("prismjs/components/prism-markup"),require("prismjs/components/prism-matlab"),require("prismjs/components/prism-mermaid"),require("prismjs/components/prism-nix"),require("prismjs/components/prism-objectivec"),require("prismjs/components/prism-ocaml"),require("prismjs/components/prism-pascal"),require("prismjs/components/prism-perl"),require("prismjs/components/prism-php"),require("prismjs/components/prism-powershell"),require("prismjs/components/prism-prolog"),require("prismjs/components/prism-protobuf"),require("prismjs/components/prism-python"),require("prismjs/components/prism-r"),require("prismjs/components/prism-reason"),require("prismjs/components/prism-ruby"),require("prismjs/components/prism-rust"),require("prismjs/components/prism-sass"),require("prismjs/components/prism-scala"),require("prismjs/components/prism-scheme"),require("prismjs/components/prism-scss"),require("prismjs/components/prism-solidity"),require("prismjs/components/prism-sql"),require("prismjs/components/prism-swift"),require("prismjs/components/prism-typescript"),require("prismjs/components/prism-vbnet"),require("prismjs/components/prism-verilog"),require("prismjs/components/prism-vhdl"),require("prismjs/components/prism-visual-basic"),require("prismjs/components/prism-wasm"),require("prismjs/components/prism-yaml"),require("mime-db"),require("dom-to-image"),require("plantuml-encoder"),require("@guyplusplus/turndown-plugin-gfm"),require("turndown"),require("marked"),require("@better-scroll/core"),require("docx")):typeof define=="function"&&define.amd?define(["exports","kiwi-intl","lodash.merge","string-template","nanoid","events","query-string","js-base64","snabbdom","lodash.clonedeep","lodash.isequal","quill-delta","tiny-typed-emitter","lodash.intersection","ot-json1","axios","lodash.findlastindex","reconnecting-websocket","fast-sha256","lodash.debounce","tippy.js","blueimp-md5","css-color-converter","markmap-view","lodash.throttle","prismjs","prismjs/components/prism-c","prismjs/components/prism-cpp","prismjs/components/prism-abap","prismjs/components/prism-arduino","prismjs/components/prism-bash","prismjs/components/prism-basic","prismjs/components/prism-clojure","prismjs/components/prism-coffeescript","prismjs/components/prism-csharp","prismjs/components/prism-css","prismjs/components/prism-dart","prismjs/components/prism-diff","prismjs/components/prism-docker","prismjs/components/prism-elixir","prismjs/components/prism-elm","prismjs/components/prism-erlang","prismjs/components/prism-flow","prismjs/components/prism-fortran","prismjs/components/prism-fsharp","prismjs/components/prism-gherkin","prismjs/components/prism-glsl","prismjs/components/prism-go","prismjs/components/prism-graphql","prismjs/components/prism-groovy","prismjs/components/prism-haskell","prismjs/components/prism-java","prismjs/components/prism-javascript","prismjs/components/prism-json","prismjs/components/prism-julia","prismjs/components/prism-kotlin","prismjs/components/prism-latex","prismjs/components/prism-less","prismjs/components/prism-lisp","prismjs/components/prism-livescript","prismjs/components/prism-lua","prismjs/components/prism-makefile","prismjs/components/prism-markdown","prismjs/components/prism-markup","prismjs/components/prism-matlab","prismjs/components/prism-mermaid","prismjs/components/prism-nix","prismjs/components/prism-objectivec","prismjs/components/prism-ocaml","prismjs/components/prism-pascal","prismjs/components/prism-perl","prismjs/components/prism-php","prismjs/components/prism-powershell","prismjs/components/prism-prolog","prismjs/components/prism-protobuf","prismjs/components/prism-python","prismjs/components/prism-r","prismjs/components/prism-reason","prismjs/components/prism-ruby","prismjs/components/prism-rust","prismjs/components/prism-sass","prismjs/components/prism-scala","prismjs/components/prism-scheme","prismjs/components/prism-scss","prismjs/components/prism-solidity","prismjs/components/prism-sql","prismjs/components/prism-swift","prismjs/components/prism-typescript","prismjs/components/prism-vbnet","prismjs/components/prism-verilog","prismjs/components/prism-vhdl","prismjs/components/prism-visual-basic","prismjs/components/prism-wasm","prismjs/components/prism-yaml","mime-db","dom-to-image","plantuml-encoder","@guyplusplus/turndown-plugin-gfm","turndown","marked","@better-scroll/core","docx"],Ie):(g=typeof globalThis<"u"?globalThis:g||self,Ie(g["oneseditor-editor"]={},g.KiwiIntl,g.merge,g.stringFormat,g.nanoid$1,g.events,g.queryString,g.jsBase64,g.snabbdom,g.cloneDeep,g.isEqual,g.Delta,g.tinyTypedEmitter,g.intersection,g.json1,g.axios,g.findLastIndex,g.ReconnectingWebSocket,g.sha256,g.debounce,g.tippy$1,g.md5,g.cssColorConverter,g.markmap,g.throttle,g.Prism,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,g.mime,g.domToImage,g.plantumlEncoder,g.turndownPluginGfm,g.TurndownService,g.marked,g.BetterScroll,g.docx))})(this,function(g,Ie,zo,S7,D7,hm,L7,Ri,io,M7,R7,O7,Yt,N7,P7,$7,_7,F7,H7,j7,iu,z7,su,U7,V7,q7,Nz,Pz,$z,_z,Fz,Hz,jz,zz,Uz,Vz,qz,Wz,Gz,Zz,Qz,Yz,Jz,Kz,Xz,tU,eU,nU,oU,rU,iU,sU,lU,cU,aU,uU,dU,hU,fU,mU,gU,pU,CU,AU,bU,vU,yU,kU,wU,BU,EU,IU,xU,TU,SU,DU,LU,MU,RU,OU,NU,PU,$U,_U,FU,HU,jU,zU,UU,VU,qU,WU,GU,ZU,W7,G7,Z7,Q7,Y7,fm,J7,Y){"use strict";var Rz=Object.defineProperty;var Oz=(g,Ie,zo)=>Ie in g?Rz(g,Ie,{enumerable:!0,configurable:!0,writable:!0,value:zo}):g[Ie]=zo;var h=(g,Ie,zo)=>(Oz(g,typeof Ie!="symbol"?Ie+"":Ie,zo),zo);const Pt=n=>n&&typeof n=="object"&&"default"in n?n:{default:n};function Bl(n){if(n&&n.__esModule)return n;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const K7=Pt(Ie),lu=Pt(zo),X7=Pt(S7),mm=Pt(hm),Q=Pt(M7),El=Pt(R7),se=Pt(O7),cu=Pt(N7),Il=Bl(P7),t8=Pt($7),e8=Pt(_7),n8=Pt(F7),o8=Bl(H7),ee=Pt(j7),r8=Pt(iu),i8=Bl(iu),Er=Pt(z7),s8=Bl(U7),l8=Pt(V7),Oi=Pt(q7),au=Pt(W7),gm=Pt(G7),c8=Pt(Z7),a8=Pt(Y7),pm=Pt(J7);function u8(n){const t=o=>o<10?`0${String(o)}`:String(o),e=o=>o<10?`00${String(o)}`:o<100?`0${String(o)}`:String(o);return`${n.getFullYear()}-${t(n.getMonth()+1)}-${t(n.getDate())} ${t(n.getHours())}:${t(n.getMinutes())}:${t(n.getSeconds())}.${e(n.getMilliseconds())}`}var Ni=(n=>(n.DEBUG="DEBUG",n.INFO="INFO ",n.WARN="WARN ",n.ERROR="ERROR",n))(Ni||{});const Cm=new Map,Ei=class{constructor(t){h(this,"times",new Map);this.category=t}shouldLog(t){const e=Object.values(Ni).indexOf(t),o=Object.values(Ni).indexOf(Ei.level);return e>=o}_log(t,e,o,r){var A;if(!this.shouldLog(t))return;const i=typeof process>"u"?{}:process;let s="";if(typeof e=="object")try{s="message"in e?e.message:JSON.stringify(e,null,4)}catch{s=""}else typeof e=="string"?e&&(s=e):s=JSON.stringify(e);s=r?`${s} - ${r}`:s;const l=`${this.category}`;let c=console.log;t==="WARN "&&(c=console.warn),t==="ERROR"&&(c=console.error);const a=`${u8(new Date)}`,d=t,f=l,m=Ei.extParams?"[{date}] {level}: [{module} {extParams}] - {msg}":"[{date}] {level}: [{module}] - {msg}",p=[X7.default(((A=i.env)==null?void 0:A.LOG_TEMPLATE)||m,{date:a,level:d,module:f,msg:s,extParams:Ei.extParams})];if(typeof e=="object"){const k=e.stack;k&&p.push(k)}if(c===console.error&&Ei.debugMode){const k=new Error().stack;k&&p.push(k)}c(...p),o&&this._log(t,o)}log(t,e){this._log("INFO ",t,void 0,e)}debug(t,e){this._log("DEBUG",t,void 0,e)}info(t,e){this._log("INFO ",t,void 0,e)}warn(t,e,o){this._log("WARN ",t,e,o)}error(t,e,o){this._log("ERROR",t,e,o)}time(t){this.times.set(t,Date.now())}timeEnd(t){this.timeLog(t),this.times.delete(t)}timeLog(t){const e=this.times.get(t);if(!e){this.warn(`no time label: ${t}`);return}this.debug(`${t}: ${Date.now()-e}`)}static setExtParams(t){this.extParams=t}};let so=Ei;h(so,"debugMode",!1),h(so,"level","DEBUG"),h(so,"extParams","");function w(n){const t=Cm.get(n);if(t)return t;const e=new so(n);return Cm.set(n,e),e}const d8={name:"Ones Editor",date:{dateFromFuture:"From future",dateJustNow:"Just now",dateYesterday:"Yesterday",dateMinutesAgo:"{num} minutes ago",date1HourAgo:"1 hour ago",dateHoursAgo:"{num} hours ago",dateDaysAgo:"{num} days ago",dateWeeksAgo:"{num} weeks ago"},common:{cancel:"cancel"}},h8={name:"Ones Editor",date:{dateFromFuture:"\u6765\u81EA\u672A\u6765",dateJustNow:"\u521A\u521A",dateYesterday:"\u6628\u5929",dateMinutesAgo:"{num}\u5206\u949F\u524D",date1HourAgo:"1\u5C0F\u65F6\u524D",dateHoursAgo:"{num}\u5C0F\u65F6\u524D",dateDaysAgo:"{num}\u5929\u524D",dateWeeksAgo:"{num}\u5468\u524D"},common:{cancel:"\u53D6\u6D88"}},f8=w("i18n"),m8={"en-US":d8,"zh-CN":h8},xl=K7.default.init("en-US",m8);function g8(n=void 0){xl.setLang&&xl.setLang(n||"en-US")}function p8(n){lu.default(xl.__metas__,n)}function C8(n,t){const e=xl.get(n,t);return e===n&&f8.warn(`no locale value for key ${n}`),e}const T=Object.freeze(Object.defineProperty({__proto__:null,setLang:g8,mergeLang:p8,t:C8},Symbol.toStringTag,{value:"Module"})),QU="";class Am{constructor(t,e){this.editor=t,this.data=e}getData(){return this.data}getEditor(){return this.editor}destroy(){}}class A8 extends Error{constructor(t){if(super(t),this.code="Assert",this.stack){const e=this.stack.split(`
|
|
3
3
|
`);if(e.length>1)if(this.lineNumber&&this.columnNumber){const o=e[1].match(/(.*)@(.*):(\d+):(\d+)/);o&&(this.lineNumber=+o[3],this.columnNumber=+o[4],this.fileName=o[2]),e.splice(0,1)}else e.splice(1,1);this.stack=e.join(`
|
|
4
4
|
`)}}}function u(n,t,e){if(!t)throw n.error(`assert failed: ${e}`),new A8(e)}const b8=D7.customAlphabet("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",8),bm="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function v8(){return bm[Date.now()%bm.length]}const P=()=>`${v8()}${b8()}`;class vm extends mm.default.EventEmitter{constructor(e=60){super();h(this,"cache",new Map);h(this,"expiredSeconds");this.expiredSeconds=e,this.startAutoClear()}delete(e){const o=this.cache.get(e);o&&this.emit("delete",o.data),this.cache.delete(e)}getSync(e,o){const r=this.cache.get(e),i=Date.now();if(r&&(i-r.lastRead)/1e3<this.expiredSeconds)return r.lastRead=i,r.data;const s=o(e);return this.cache.set(e,{lastRead:i,data:s}),s}async get(e,o){const r=this.cache.get(e),i=Date.now();if(r&&(i-r.lastRead)/1e3<this.expiredSeconds)return r.lastRead=i,r.data;const s=await o(e);return this.cache.set(e,{lastRead:i,data:s}),s}startAutoClear(){setInterval(()=>{const e=Date.now();Array.from(this.cache.entries()).forEach(([o,r])=>{(e-r.lastRead)/1e3>this.expiredSeconds&&this.delete(o)})},10*1e3)}}class Pi{constructor(){h(this,"_callbacks",new Set)}get callbacks(){return Array.from(this._callbacks)}registerCallback(t){this._callbacks.add(t)}unregisterCallback(t){this._callbacks.delete(t)}clearCallbacks(){this._callbacks.clear()}}const y8=w("await-locker");class k8{constructor(){h(this,"_acquired",!1);h(this,"_waitingResolvers",[]);this._acquired=!1,this._waitingResolvers=[]}acquireAsync(t){return this._acquired?new Promise((e,o)=>{this._waitingResolvers.push(e),t&&t>0&&setTimeout(()=>{const r=this._waitingResolvers.indexOf(e);if(r!==-1){this._waitingResolvers.splice(r,1);const i=new Error(`lock timeout: ${t}, waiting resolves: ${this._waitingResolvers.length}`);o(i)}},t)}):(this._acquired=!0,Promise.resolve())}tryAcquire(){return this._acquired?!1:(this._acquired=!0,!0)}release(){if(!this._acquired)throw new Error("Cannot release an unacquired lock");if(this._waitingResolvers.length>0){const t=this._waitingResolvers.shift();u(y8,t,"Resolver missing"),t(void 0)}else this._acquired=!1}acquired(){return this._acquired}debug(){const t=this._waitingResolvers.length;return console.log(`waiting resolves: ${t}`),{waitingCount:t}}}class w8{constructor(){h(this,"_map");this._map=new Map}getLocker(t){let e=this._map.get(t);return e||(e=new k8,this._map.set(t,e)),e}async lock(t,e){await this.getLocker(t).acquireAsync(e)}release(t){this.getLocker(t).release()}remove(t){this.isLocking(t)||this._map.delete(t)}isLocking(t){return this._map.has(t)?this.getLocker(t).acquired():!1}}const Ge=new w8;/**
|
|
5
5
|
* @name string-character-is-astral-surrogate
|
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
Available method signatures are:
|
|
13
13
|
animateScrollTo(y:number, options)
|
|
14
14
|
animateScrollTo([x:number | null, y:number | null], options)
|
|
15
|
-
animateScrollTo(scrollToElement:Element, options)`;e+=i.horizontalOffset,o+=i.verticalOffset;const f=d.getMaxHorizontalScroll(),m=d.getHorizontalScroll();e>f&&(e=f);const p=e-m,A=d.getMaxVerticalScroll(),k=d.getVerticalScroll();k<o?o-=window.innerHeight*3/4:o-=window.innerHeight*1/4,o>A&&(o=A);const v=o-k,T=Math.abs(Math.round(p/1e3*i.speed)),E=Math.abs(Math.round(v/1e3*i.speed));let L=T>E?T:E;return L<i.minDuration?L=i.minDuration:L>i.maxDuration&&(L=i.maxDuration),new Promise((R,$)=>{p===0&&v===0&&R(!0),Fn.remove(d.element,!0);let q;const ot=()=>{de(),cancelAnimationFrame(q),R(!1)};Fn.add(d.element,ot);const lt=qe=>qe.preventDefault(),gt=i.cancelOnUserAction?ot:lt,ht=i.cancelOnUserAction?{passive:!0}:{passive:!1},kt=["wheel","touchstart","keydown","mousedown"],de=()=>{kt.forEach(qe=>{d.element.removeEventListener(qe,gt,ht)})};kt.forEach(qe=>{d.element.addEventListener(qe,gt,ht)});const oo=Date.now(),re=()=>{const qe=Date.now()-oo,$o=qe/L,kr=Math.round(m+p*i.easing($o)),wr=Math.round(k+v*i.easing($o));qe<L&&(kr!==e||wr!==o)?(d.scrollTo(kr,wr),q=requestAnimationFrame(re)):(d.scrollTo(e,o),cancelAnimationFrame(q),de(),Fn.remove(d.element,!1),R(!0))};q=requestAnimationFrame(re)})}function Wo(n,t,e){return n.left<=t&&t<=n.right&&n.top<=e&&e<=n.bottom}function D8(n){const t="\xA0";if(!n)return"";if(n===" ")return t;let e=n;return e.startsWith(" ")&&(e=t+e.substr(1)),e.endsWith(" ")&&(e=e.substr(0,e.length-1)+t),e=e.replace(/ {2}/g,` ${t}`),e}function Tm(n){if(!/["'&<>]/.exec(n))return n;const o={'"':""","'":"'","&":"&","<":"<",">":">"};return n.split("").map(l=>o[l]||l).join("")}function Sm(n){const t=document.getElementById(n);t&&t.remove()}function Dm(n,t){const e=document.getElementById(t);if(e)return e.textContent=n,e;const o=document.createElement("style");return o.id=t,o.textContent=n,document.head.append(o),o}function Fi(n){const t="custom-cursor-style";if(n){const e=`body * { cursor: ${n} !important}`;Dm(e,t)}else Sm(t)}const Lm=3,Mm=w("drag-drop");class Rm{constructor(t){h(this,"dragStarted",!1);h(this,"mouseDownEvent",null);h(this,"_dragOffsetX",0);h(this,"_dragOffsetY",0);h(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.mouseDownEvent=t;const e=this.options.elem.getBoundingClientRect();this._dragOffsetX=this.mouseDownEvent.x-e.left,this._dragOffsetY=this.mouseDownEvent.y-e.top,this.bindEvents()});h(this,"handleMouseMove",t=>{var i;t.preventDefault(),t.stopPropagation(),u(Mm,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,o=t.y-this.mouseDownEvent.y;if(this.dragStarted){this.onDragging(t,e,o);return}const r=(i=this.options.minThreshold)!=null?i:Lm;(Math.abs(e)>=r||Math.abs(o)>=r)&&this.onDragStart(this.mouseDownEvent)});h(this,"handleMouseUp",t=>{if(t.button===0){u(Mm,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,o=t.y-this.mouseDownEvent.y;this.onDragEnd(t,e,o),t.preventDefault(),t.stopPropagation()}});this.options=t,this.options.mouseDownEvent?this.handleMouseDown(this.options.mouseDownEvent):this.trackEvents()}get data(){return this.options.data}get dragOffsetX(){return this._dragOffsetX}get dragOffsetY(){return this._dragOffsetY}get dragOffset(){return{x:this._dragOffsetX,y:this._dragOffsetY}}trackEvents(){this.options.elem.addEventListener("mousedown",this.handleMouseDown)}untrackEvents(){this.options.elem.removeEventListener("mousedown",this.handleMouseDown)}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}onDragStart(t){this.dragStarted=!0,this.options.cursor&&Fi(this.options.cursor),this.options.onDragStart(this,t,this.options.elem)}onDragging(t,e,o){this.options.onDragging(this,t,this.options.elem,e,o)}onDragEnd(t,e,o){this.options.cursor&&Fi(null),this.dragStarted&&this.options.onDragEnd(this,t,this.options.elem,e,o),this.unbindEvents(),this.dragStarted=!1}destroy(){this.unbindEvents(),this.untrackEvents()}}function Cu(n){return new Rm(n)}const L8=w("character");function Om(n,t){for(let e=0;e<t.length;e++){const o=t[e][0],r=t[e].length>1?t[e][1]:null;if(r===null&&n===o||r!==null&&n>=o&&n<=r)return!0}return!1}function Nm(n){const t=n.charAt(0);return t>="0"&&t<="9"}function Pm(n){const t=n.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"||t.toUpperCase()!==t.toLowerCase()?!0:RegExp(/^\p{L}/,"u").test(t)}function Ll(n){const t=[[9,13],[32],[160]];return Om(n.charCodeAt(0),t)}function $m(n){const t=[[12352,12687],[13056,13183],[13312,15661],[19968,40959],[63744,64255],[44032,55215]];return Om(n.charCodeAt(0),t)}function Au(n,t){let e=t;return u(L8,e.length===1,"invalid char length"),e==="]"&&(e="\\]"),e==="\\"&&(e="\\\\"),n.replace(new RegExp(`^[${e}]+|[${e}]+$`,"g"),"")}const Hn=navigator.userAgent;function _m(){const n=navigator.userAgent.toLowerCase();return n.indexOf("safari")!==-1&&!(n.indexOf("chrome")>-1)}function bu(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}const xt={isAndroid:!!Hn.match(/Android/i),isIOS:!!Hn.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),isIPad:!!Hn.match(/iPad/i),isIPhone:!!Hn.match(/iPhone/i),isLinux:!!Hn.match(/Linux/i),isMac:!!Hn.match(/Macintosh/i),isMobile:!!Hn.match(/AppleWebKit.*Mobile.*/i),isWindows:!!Hn.match(/Window/i),isIe:!!Hn.match(/msie|trident/i),isSafari:_m(),isMobileSafari:!1};xt.isMobileSafari=xt.isMobile&&xt.isSafari;function vu(n){return n?n.length===1||n==="Process"||n==="Unidentified"&&xt.isAndroid:!1}function Fm(n){switch(n){case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":case"End":case"Home":case"PageDown":case"PageUp":return!0;default:return!1}}function M8(n){return Fm(n.key)}function R8(n){switch(n){case"ArrowUp":case"ArrowLeft":case"Home":case"PageUp":return!0;default:return!1}}function Go(n){return n.ctrlKey||n.altKey||n.shiftKey||n.metaKey}function O8(n){return n.key?!!(n.ctrlKey||n.metaKey||n.altKey):!1}function Hm(n){return xt.isMac?n.metaKey&&!n.ctrlKey:!n.metaKey&&n.ctrlKey}function N8(n){return Hm(n)&&!n.altKey&&!n.shiftKey}function P8(n){return!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.altKey}function jm(n){return!Go(n)&&n.key==="Enter"}function $8(n){return n.key==="Enter"&&n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey}function yu(n){return!Go(n)&&n.key==="Escape"}function _8(n){return!Go(n)&&n.key==="Delete"}function zm(n){return!Go(n)&&n.key==="Backspace"}function F8(n){return!Go(n)&&n.key==="Tab"}function H8(n){return n.shiftKey&&n.key==="Tab"&&!n.ctrlKey&&!n.metaKey}function j8(n){if(!n)return"";if(xt.isMac){const t=n.replace("CtrlOrCmd","\u2318").replace("Shift","\u21E7").replace("Ctrl","\u2303").replace("Alt","\u2325").replace(/\+(?!$)/gm,""),e={"\u2318":4,"\u21E7":3,"\u2325":2,"\u2303":1};return t.split(/(?=[\s\S])/u).sort((r,i)=>{var c,a;const s=(c=e[r])!=null?c:5,l=(a=e[i])!=null?a:5;return s-l}).join("")}return n.replace("CtrlOrCmd","Ctrl")}function Um(n){const t={ctrl:!1,alt:!1,shift:!1,cmd:!1,key:""},e=n.toLocaleUpperCase().split("+");for(let o=0;o<e.length;o++){const r=e[o];r==="CTRL"||r==="CONTROL"?t.ctrl=!0:r==="ALT"||r==="OPTION"?t.alt=!0:r==="SHIFT"?t.shift=!0:r==="CMD"||r==="COMMAND"?t.cmd=!0:r==="CMDORCTRL"||r==="CTRLORCMD"?xt.isMac?t.cmd=!0:t.ctrl=!0:r==="SPACE"?t.key=" ":t.key=r.substring(0,1)+r.substring(1).toLocaleLowerCase()}return t}function jn(n,t){const e=Um(t);return e.ctrl!==n.ctrlKey||e.alt!==n.altKey||e.shift!==n.shiftKey||xt.isMac&&e.cmd!==n.metaKey?!1:e.key.length===1?e.key===n.key.toUpperCase():e.key.toUpperCase()===n.key.toUpperCase()}function ku(n,t){return L7.stringifyUrl({url:n,query:t})}function Zo(n){return typeof n=="string"?Ri.Base64.encode(n,!0):Ri.Base64.fromUint8Array(n,!0)}function Ml(n){return Ri.Base64.decode(n)}function z8(n){return Ri.Base64.toUint8Array(n)}function wu(n){return new Blob([Ri.Base64.toUint8Array(n)])}const U8=io.init([io.classModule,io.styleModule,io.datasetModule,io.attributesModule,io.propsModule]);function Hi(n,t){const e=io.toVNode(n),o=io.toVNode(t);U8(e,o)}async function Bu(n,t){const e=new FileReader,o=new Promise((i,s)=>{e.onload=i,e.onerror=s});return e.readAsDataURL(new Blob([n],{type:t})),await o,e.result}async function Tr(n){const t=new FileReader,e=new Promise((r,i)=>{t.onload=r,t.onerror=i});return t.readAsDataURL(n),await e,t.result}function V8(n,...t){const e=n.tagName.toLowerCase();for(let o=0,r=t.length;o<r;o++)if(e===t[o].toLowerCase())return!0;return!1}function bn(n,t){let e=n;for(;e;){const o=window.getComputedStyle(e);if(t!=null&&t.horizontal){if(/auto|scroll/i.test(o.overflowX))break}else if(/auto|scroll/i.test(o.overflowY))break;e=e.parentElement}return(!e||V8(e,"body"))&&(e=document.documentElement),e}function Vm(n){n.preventDefault(),n.stopPropagation()}function qm(n){if(document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))return;const t=b("div",["editor-disable-scroll"],null);t.setAttribute("data-scroll-id",n),t.addEventListener("wheel",Vm,{passive:!1}),document.body.appendChild(t)}function Wm(n){const t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`);t&&(t.removeEventListener("wheel",Vm),t.remove())}function Eu(n,t,e){const o=new Blob([n]),r=new File([o],e,{type:t});return URL.createObjectURL(r)}function Rl(n){const t=document.createElement("template");if("content"in t)return t.innerHTML=n,document.importNode(t.content,!0);const e=document.createDocumentFragment(),o=document.createElement("div");for(o.innerHTML=n;o.firstChild;)e.appendChild(o.firstChild);return e}function Gm(n){const t=document.createElement("div");return t.appendChild(n),t.innerHTML}function Zm(n){let t=n.getPropertyValue("font");if(t)return t;const e=n.getPropertyValue("font-style"),o=n.getPropertyValue("font-variant"),r=n.getPropertyValue("font-weight"),i=n.getPropertyValue("font-size"),s=n.getPropertyValue("font-family");return t=`${e} ${o} ${r} ${i} ${s}`.replace(/ +/g," ").trim(),t}function Ol(n,t){const o=(Ol.canvas||(Ol.canvas=document.createElement("canvas"))).getContext("2d");return o?(typeof t=="string"?t?o.font=t:o.font=Zm(window.getComputedStyle(document.body)):t instanceof Element&&(o.font=Zm(window.getComputedStyle(t))),o.measureText(n).width+4):200}const q8=w("editor-clipboard");async function W8(n,t){if(t.clipboardData){const e=t.clipboardData;for(const o of n)e.setData(o.type,o.data);return!0}return!1}async function Nl(n){try{const t={};n.forEach(o=>{t[o.type]=o.data});const e=new ClipboardItem(t);return await navigator.clipboard.write([e]),!0}catch(t){return q8.error(t),!1}}function Qo(n,t){return new Promise((e,o)=>{const r=document.createElement("input");r.type="file",r.style.display="none",t!=null&&t.multiple&&(r.multiple=!0),r.accept=n,r.onchange=()=>{const i=r.files;if(i){const s=t!=null&&t.multiple?Array.from(i):i[0];e(s)}r.remove()},r.onerror=i=>{o(i),r.remove()},r.click()})}function Pl(n){return Array.isArray(n)?n.every(t=>t instanceof File):!1}function Iu(n){const t=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function $l(n,t){const e=document.createElement("a");e.setAttribute("download",`${t||""}`),e.setAttribute("href",`${n}`),e.click(),e.remove()}const Qm=w("auto-scroll");function Ym(n,t){return!(n.scrollHeight===n.clientHeight||t==="top"&&n.scrollTop===0||t==="bottom"&&n.scrollTop+n.clientHeight===n.scrollHeight||t==="left"&&n.scrollLeft===0||t==="right"&&n.scrollLeft+n.clientWidth===n.scrollWidth)}function Jm(n,{direction:t,step:e}){let o=null;const r=t==="left"||t==="right",i=()=>{if(!Ym(n,t))return Qm.debug("No need for scroll"),null;if(r){const s=n.scrollLeft,l=t==="left"?s-e:s+e;n.scrollLeft=l}else{const s=n.scrollTop,l=t==="top"?s-e:s+e;n.scrollTop=l}return o=requestAnimationFrame(i),o};return o=requestAnimationFrame(i),()=>{o&&cancelAnimationFrame(o)}}class Km{constructor(t){h(this,"cancelScroll",null);h(this,"options");h(this,"scrollDomInfo");h(this,"scrolling",!1);h(this,"getScrollingDirection",t=>{const{x:e,y:o}=t,{top:r,bottom:i,left:s,right:l}=this.scrollDomInfo,{edge:c}=this.options;return c.top&&o>=r&&o<=c.top+r?"top":c.bottom&&o<=i&&o>=i-c.bottom?"bottom":c.left&&e>=s&&e<=s+c.left?"left":c.right&&e<=l&&e>=l-c.right?"right":null});h(this,"handleMouseMove",t=>{var s;const{scrollElement:e,step:o=10,onDirectionChange:r}=this.options,i=this.getScrollingDirection(t);if(i){if(this.scrolling)return;Qm.debug(`scroll direction: ${i}`),this.cancelScroll=Jm(e,{direction:i,step:o}),r==null||r(i),this.scrolling=!0}else(s=this.cancelScroll)==null||s.call(this),this.scrolling=!1});this.options=t,this.scrollDomInfo=this.getScrollDomInfo()}getScrollDomInfo(){const{scrollElement:t}=this.options,e=t.clientTop,o=t.clientLeft,r=t.clientHeight,i=t.clientWidth;return{left:o,top:e,right:i,bottom:r}}active(){const{trackMouseEvent:t="mousemove"}=this.options;window.addEventListener(t,this.handleMouseMove,!0)}inactive(){var e;const{trackMouseEvent:t="mousemove"}=this.options;window.removeEventListener(t,this.handleMouseMove,!0),(e=this.cancelScroll)==null||e.call(this),this.scrolling=!1}}function Xm(n,t){if(n===0)return"0 Bytes";const e=1024,o=t||2,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**i).toFixed(o))} ${r[i]}`}function xu(n,t){let e=`${n}`;const o=t-e.length;for(let r=0;r<o;r++)e=`0${e}`;return e}const{t:Yo}=x;function Tu(n,t){const e=new Date(n).getTime()+864e5*t;return new Date(e)}function G8(n,t){const e=n,o=Math.floor(t/12),r=t-o*12;return o&&e.setFullYear(e.getFullYear()+o),r&&e.setMonth(e.getMonth()+r),e}function Z8(n,t){return Tu(n,t)}function Su(n,t){const e=new Date(n),o=new Date(t);return e.getDate()===o.getDate()&&e.getMonth()===o.getMonth()&&e.getFullYear()===o.getFullYear()}function tg(n){const t=new Date,e=new Date(n);return Su(t,e)}function eg(n){const t=Tu(new Date,-1);return Su(t,n)}function Q8(n,t){return Math.round((n.getTime()-t.getTime())/864e5)}function ng(n,t){const e=new Date(n);if(t){const o=e.getFullYear(),r=e.getMonth()+1,i=e.getDate();let s=t;return s=s.replace("yyyy",`${o}`),s=s.replace("mm",xu(r,2)),s=s.replace("dd",xu(i,2)),s=s.replace("m",`${r}`),s=s.replace("d",`${i}`),s}return n.toLocaleDateString()}function Du(n,t){const e=new Date(n),o=new Date;if(e.getTime()-o.getTime()>10*1e3)return x.t("date.dateFromFuture");if(tg(e)){const i=(o.getTime()-n.getTime())/1e3;if(i<10*60)return Yo("date.dateJustNow");if(i<60*60)return Yo("date.dateMinutesAgo",{num:`${Math.floor(i/60)}`});const s=Math.floor(i/60/60);return s===1?Yo("date.date1HourAgo"):Yo("date.dateHoursAgo",{num:`${s}`})}if(eg(n))return Yo("date.dateYesterday");const r=Math.floor((o.getTime()-n.getTime())/1e3/24/60/60)+1;return r<14?Yo("date.dateDaysAgo",{num:`${r}`}):r<28?Yo("date.dateWeeksAgo",{num:`${Math.round(r/7)}`}):ng(n,t)}function Lu(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Y8(n,t,e){return n.replace(new RegExp(Lu(t),"g"),e)}function J8(n,t,e){return n.replace(new RegExp(Lu(t),"gi"),e)}const og=w("container-children");function Mt(n){const t=Array.from(n.querySelectorAll(":scope > .container-blocks > div[data-type=editor-block]"));return u(og,t.length>0,"container have not any child block"),t}function Ft(n){const t=n.querySelector(":scope > .container-blocks > div[data-type=editor-block]");return u(og,t,"container have not any child block"),t}function Jt(n){const t=Mt(n);return t[t.length-1]}function Ze(n){return Mt(n).length}function Sr(n,t){return Mt(n)[t]}const Qe=w("block-dom");function Jo(n){return n instanceof HTMLDivElement?n.getAttribute("data-type")==="editor-block":!1}function rg(n){M(n,"block-hidden")}function ig(n){H(n,"block-hidden")}function _l(n){return!rt(n,"block-hidden")}function j(n){const{id:t}=n;return u(Qe,t,"no block id"),t}function it(n){const t=n.getAttribute("data-block-type");return u(Qe,t,"invalid block dom, no data-type"),t}function U(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]");return e||null}function Fl(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]:not(:scope)");return e||null}function z(n){const t=n.closest("div[data-type=editor-container]");return u(Qe,t,"failed to get block container"),t}function st(n){const t=n.querySelector(":scope >div[data-type=block-content]");return u(Qe,t,"no block content"),t}function Rt(n){let t=n.querySelector(":scope >div[data-type=block-tools]");return t||(t=b("div",[],n),t.setAttribute("data-type","block-tools")),u(Qe,t,"no block tools"),t}function Hl(n){const t=n.querySelector(":scope >div[data-type=block-tools]");return t||null}function sg(n){let t=n.querySelector(":scope > div[data-type=block-background]");return t||(t=b("div",[],n),t.setAttribute("data-type","block-background")),t}function lg(n,t,e){const o=n.editorDecorators.decorateBlock(t,e),{id:r,type:i}=o;u(Qe,r,"no block id");const s=b("div",[`${i}-block`],null);s.id=r,s.setAttribute("data-type","editor-block"),s.setAttribute("data-block-type",i);const l=n.editorBlockRenders.renderBlock(n,t,e);return l.classes&&M(s,...l.classes),l.attributes&&Object.entries(l.attributes).forEach(([c,a])=>{s.setAttribute(c,a)}),l.styles&&Object.entries(l.styles).forEach(([c,a])=>{s.style.setProperty(c,a)}),s}function lo(n,t){const e=b(t,[],null);return e.setAttribute("data-type","block-content"),n&&n.appendChild(e),e}function cg(n){const t=b("span",[`${n.type}-box`],null);return t.setAttribute("data-type","editor-box"),t.setAttribute("data-box-type",n.type),t.id=n.id,t}function ji(n){const t=n.getAttribute("data-box-type");return u(Qe,t,"not a valid box element, no type"),t}function Mu(n){return n instanceof HTMLSpanElement?n.getAttribute("data-type")==="editor-box":!1}function ag(n){const{id:t}=n;return u(Qe,t,"no box id"),t}function Ru(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("span[data-type=editor-box]");return e||null}function ug(n){n.innerHTML="",b("span",["box-space-start"],n,$i);const t=b("span",[],n);return t.setAttribute("data-type","box-content"),b("span",["box-space-start"],n,$i),t}function Ou(n){const t=n.querySelector("span[data-type=box-content]");return u(Qe,t,"invalid box dom, no content"),t}function dg(n,t){const e=b("span",[`${n}-insertion`],null);return e.setAttribute("data-type","editor-insertion"),e.setAttribute("data-insertion-id",t),e}function hg(n,t){return n.rootContainer.querySelector(`[data-insertion-id=${t}]`)}function fg(n){n.innerHTML="",b("span",["insertion-space-start"],n,$i);const t=b("span",[],n);return t.setAttribute("data-type","insertion-content"),b("span",["insertion-space-start"],n,$i),t}function Nu(n){const t=n.querySelector("span[data-type=insertion-content]");return u(Qe,t,"invalid insertion-child dom, no content"),t}function bt(n){let t=n.previousElementSibling;for(;t;){if(Jo(t))return t;t=t.nextElementSibling}return null}function dt(n){let t=n.nextElementSibling;for(;t;){if(Jo(t))return t;t=t.nextElementSibling}return null}function Dr(n){let t=n.previousElementSibling;for(;t;){if(Jo(t)&&_l(t))return t;t=t.previousElementSibling}return null}function Lr(n){let t=n.nextElementSibling;for(;t;){if(Jo(t)&&_l(t))return t;t=t.nextElementSibling}return null}function K(n){const t=z(n),o=Mt(t).indexOf(n);return u(Qe,o!==-1,"invalid block & container dom, failed to get block index"),o}function Pu(n){return!n||!(n instanceof Node)?!1:!!U(n)}function zi(n){if(!Pu(n))return!1;const t=n,e=t instanceof Element?t:t.parentElement;return e?!!e.closest("div[data-type=block-tools]"):!1}const mg=w("block-class");function pt(n,t){return n.editorBlocks.getBlockClass(it(t))}function gg(n,t){const e=n.editorBlocks.getBlockClass(it(t));return u(mg,e.blockKind==="text",`is not a text block, ${e.blockType}`),e}function xe(n,t){const e=n.editorBlocks.getBlockClass(it(t));return u(mg,e.blockKind==="complex",`is not a text block, ${e.blockType}`),e}function Mr(n,t){return n.editorBlocks.getBlockClass(t)}function Ye(n,t,e){return pt(n,t).getCaretRect(t,e)}function _(n,t){return pt(n,t).blockKind==="text"}function Ui(n,t){return n.editorBlocks.getBlockClass(t).blockKind==="text"}function at(n,t){return pt(n,t).blockKind==="complex"}function K8(n,t){return!at(n,t)}function Je(n,t){return pt(n,t).blockKind}const pg=w("container");function vn(n){return n.getAttribute("data-type")==="editor-container"}function Ct(n){return rt(n,"root")}function Ke(n){return rt(n,"child")}function V(n){const t=n.getAttribute("data-container-id");return u(pg,t,"no id for container"),Ct(n)&&u(pg,t==="root",`invalid root container id, : ${t}`),t}function Cg(n,t){const e=V(n);return t.getContainerBlocks(e)}const $u=w("block");function G(n,t){return pt(n,t).getBlockTextLength(t)}function Ag(n){n.editorBlocks.forEach(t=>{t.clearSelection(n)})}function bg(n,t,e,o){pt(n,t).updateSelection(n,t,e,o)}function _u(n){for(;;){const t=z(n);if(Ct(t))return n;const e=U(t);u($u,e,"no parent block exists for child container"),n=e}}function vg(n,t){const e=pt(n,t);if(!!e.getMinWidth)return e.getMinWidth(n,t)}function yg(n,t,e){const o=pt(n,t);o.handleBlockElementUpdated&&o.handleBlockElementUpdated(n,t,e)}function jl(n,t,e,o){try{const r=Mr(n,e).convertFrom;return r?r(n,t,o):null}catch{return $u.debug(`unsupported block type: ${e}`),null}}function co(n,t,e){const o=pt(n,t);return o.getClientRects?o.getClientRects(n,t,e):[t.getBoundingClientRect()]}function X8(n,t){const e=pt(n,t);if(e.getBlockStyles)return e.getBlockStyles(n,t);const o=n.getBlockData(t),r=Object.fromEntries(Object.entries(o).filter(([i])=>i.startsWith("style-")));return Object.entries(r).forEach(([,i])=>{const s=typeof i;u($u,s==="string"||s==="number"||s==="boolean","invalid style value")}),r}function Tt(n,t){return Je(n,t)==="text"?G(n,t)===0:!1}const kg=w("block-path");function ao(n){const t=[];let e=n;for(;e;){const o=z(e);if(t.unshift({containerId:V(o),blockIndex:K(e)}),Ct(o))return t;const r=U(o);u(kg,r,"no parent block"),e=r}return u(kg,!1,"no parent block"),[]}function tA(n,t){var r,i;const e=pt(n,t);return(i=(r=e.getOptions)==null?void 0:r.call(e,n))!=null?i:{name:it(t)}}function wg(n,t){var r;const e=pt(n,t);return(r=e.getBlockProperties)==null?void 0:r.call(e,n,t)}function Fu(n,t){var i,s;const e=pt(n,t),o=(i=e.getBlockProperties)==null?void 0:i.call(e,n,t);let r={};o!=null&&o.blockCommands&&(r={...o.blockCommands});for(const l of n.blockHooks){const c=(s=l.commands)==null?void 0:s.call(l,n,t);c&&(r[c.group]=c)}return r}function Bg(n,t,e){var s,l,c,a;const o=pt(n,t),r=(s=o.getBlockProperties)==null?void 0:s.call(o,n,t);let i={};r!=null&&r.blockCommands&&(i={...r.blockCommands});for(const d of n.blockHooks){const f=(l=d.commands)==null?void 0:l.call(d,n,t);f&&(i[f.group]=f)}return(a=(c=i[e])==null?void 0:c.commands)!=null?a:[]}const Eg=w("embed-block-common");function Te(n){return it(n)==="embed"}function Ne(n){u(Eg,Te(n),"not an embed block");const t=n.getAttribute("data-embed-type");return u(Eg,t,"no embed data type"),t}function eA(n,t){return n.editorEmbeds.getEmbedClass(Ne(t))}function Ko(n,t){return n.editorEmbeds.getEmbedClass(t)}async function Hu(n,t,e,o,r){const i=Ko(n,t);if(!i.getOptions)return null;const s=i.getOptions(n);if(!s.insertEmbedCommandItems||!s.insertEmbedCommandItems||s.insertEmbedCommandItems.length===0||!s.handleInsertEmptyEmbed)return null;const l=s.insertEmbedCommandItems[0];return s.handleInsertEmptyEmbed(n,{item:l,containerId:e,blockIndex:o,data:r})}function nA(n,t,e,o,r){var l,c;const i=(c=(l=Mr(n,t)).getOptions)==null?void 0:c.call(l,n);if(!i||!i.insertBlockCommandItems||i.insertBlockCommandItems.length===0||!i.handleInsertEmptyBlock)return null;const s=i.insertBlockCommandItems[0];return i.handleInsertEmptyBlock(n,{item:s,containerId:e,blockIndex:o,data:r})}const oA=w("execute-block-command");function Ig(n,t,e,o){var a;u(oA,Te(t),"not a embed block");const r=Ne(t),i=Ko(n,r);if(!i.getOptions)return;const s=(a=i.getBlockProperties)==null?void 0:a.call(i,n,t),l=s==null?void 0:s.blockCommands;if(!l)return;const c=Object.entries(l);for(const d of c)if(d[0]===e)return d[1].executeCommand(n,t,o)}function xg(n,t,e,o){const r=Fu(n,t);if(!r)return;const i=Object.entries(r);for(const s of i)if(s[0]===e)return s[1].executeCommand(n,t,o)}const rA=w("complex-block-position");class Xe{constructor(t,e,o){h(this,"blockId");h(this,"childContainerId");h(this,"custom");t instanceof HTMLElement?this.blockId=j(t):(u(rA,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.childContainerId=e,o!==void 0&&(this.custom=o)}isSimple(){return!1}}const iA=w("simple-block-position");class qt{constructor(t,e,o){h(this,"blockId");h(this,"offset");h(this,"type");t instanceof HTMLElement?this.blockId=j(t):(u(iA,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.offset=e,this.type=o}isSimple(){return!0}}const ju=w("editor-position");function F(n,t,e){return new qt(n,t,e)}function Bt(n,t,e){return new Xe(n,t,e)}function uo(n){return n instanceof qt}function zu(n){return n instanceof Xe}function Uu(n,t,e){if(uo(t)&&uo(e)){const o=t,r=e;if(o.blockId===r.blockId)return o.offset-r.offset;const i=n.getBlockById(t.blockId),s=n.getBlockById(e.blockId);return u(ju,i!==s,"comparePosition: blocks are the same"),Dl(i,s)}if(zu(t)&&zu(e)){const o=t,r=e;if(o.childContainerId===r.childContainerId)return 0;const i=n.getContainerById(o.childContainerId),s=n.getContainerById(r.childContainerId);return u(ju,i!==s,"comparePosition: containers are the same"),Dl(i,s)}return u(ju,!1,"invalid "),0}const zl=w("simple-range");class Kt{constructor(t,e){h(this,"editor");h(this,"_anchor");h(this,"_focus");h(this,"reverse");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=Uu(this.editor,this._anchor,this._focus)>0}isCollapsed(){return this.start.blockId===this.end.blockId&&this.start.offset===this.end.offset}isEqual(t){if(!(t instanceof Kt))return!1;const e=t,{start:o,end:r}=e;return this.start.blockId===o.blockId&&this.start.offset===o.offset&&this.start.type===o.type&&this.end.blockId===r.blockId&&this.end.offset===r.offset&&this.end.type===r.type}isSimple(){return!0}isReverse(){return this.reverse}getEditor(){return this.editor}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}get anchor(){return this._anchor}get focus(){return this._focus}getSelectedBlocks(){const{editor:t}=this,e=t.getBlockById(this.start.blockId),o=t.getBlockById(this.end.blockId);u(zl,e,"no start block"),u(zl,o,"no end block");const r=z(e),i=z(o);u(zl,r===i,"invalid range");const s=[];if(e===o)s.push({block:e,start:this.start,end:this.end});else{const l=K(e),c=K(o);u(zl,l<c,"invalid range, start > index"),s.push({block:e,start:this.start,end:F(e,G(this.editor,e),"end")});const a=Mt(r);for(let d=l+1;d<c;d+=1){const f=a[d];s.push({block:f,start:F(f,0,"home"),end:F(f,G(this.editor,f),"end")})}s.push({block:o,start:F(o,0,"home"),end:this.end})}return s}getSelectedContainers(){return[]}getAnchorPos(){return this.isReverse()?this.end:this.start}getFocusedPos(){return this.isReverse()?this.start:this.end}clone(){return new Kt(this.editor,this)}toDocRange(){return{anchor:this.anchor,focus:this.focus}}static from(t,e){return new Kt(t,e)}}w("unknown-block");function sA(n,t,e,o,r){M(o,"unknown-block");const i=lo(o,"div");return i.innerText=`unknown block (${r.type}): ${JSON.stringify(r)}`,i}function lA(n){return 1}function cA(n,t,e,o){return null}function aA(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=j(t),s=F(i,0,"home"),l=F(i,1,"end");return new Kt(n,{anchor:s,focus:l})}function uA(n,t){const o=st(n).getBoundingClientRect();return new DOMRect(o.left+o.width/2,o.top,1,o.height)}function dA(n,t,e,o){M(t,"selected")}function hA(n){n.rootContainer.querySelectorAll("div.unknown-block[data-type=editor-block]").forEach(t=>{H(t,"selected")})}function fA(n,t,e,o){return`[unknown block, ${t.type}]`}const mA={blockType:"unknown-block",blockKind:"embed",createBlockContent:sA,getBlockTextLength:lA,getRangeFromPoint:aA,moveCaret:cA,getCaretRect:uA,updateSelection:dA,clearSelection:hA,convertTo:fA},Vu=w("editor-blocks");class Tg{constructor(t){h(this,"blocks",new Map);this.editor=t}registerBlockClass(t){const e=t.blockType,o=this.blocks.get(e);u(Vu,!o,`duplicated block type: ${e}`),this.blocks.set(e,t)}getBlockClass(t){const e=this.blocks.get(t);return u(Vu,e,`unknown block type: ${t}`),e}hasBlock(t){return this.blocks.has(t)}createBlock(t,e,o){const r=lg(this.editor,t,o);let i;this.hasBlock(o.type)?i=this.getBlockClass(o.type):i=this.registerUnknownBlock(o.type);const s=i.createBlockContent(this.editor,t,e,r,o);return s.parentElement!==r&&(Vu.warn("content parent is not block"),r.appendChild(s)),this.editor.blockHooks.forEach(l=>{var c;(c=l.create)==null||c.call(l,this.editor,t,e,r,o)}),r}forEach(t){this.blocks.forEach(t)}registerUnknownBlock(t){const e={...mA,blockType:t};return this.editor.editorBlocks.registerBlockClass(e),e}}const Sg=w("editor-embeds");class Dg{constructor(t){h(this,"objects",new Map);this.editor=t}registerEmbedClass(t){const e=t.embedType,o=this.objects.get(e);u(Sg,!o,`duplicated embed object type: ${e}`),this.objects.set(e,t)}getEmbedClass(t){const e=this.objects.get(t);return u(Sg,e,`unknown embed type: ${t}`),e}getEmbedClassFromBlock(t){return this.getEmbedClass(Ne(t))}forEach(t){this.objects.forEach(t)}}const Lg=w("embed-block");function gA(n,t,e,o,r){const i=lo(o,"div");u(Lg,r.type==="embed",`not an embed data: ${JSON.stringify(r)}`);const s=r;return u(Lg,s.embedType&&s.embedData,`not an embed data: ${JSON.stringify(s)}`),n.editorEmbeds.getEmbedClass(s.embedType).createEmbedContent(n,i,s,t,e,o),o.setAttribute("data-embed-type",s.embedType),i}function pA(n){return 1}function CA(n,t,e,o){return null}function AA(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=j(t),s=F(i,0,"home"),l=F(i,1,"end");return new Kt(n,{anchor:s,focus:l})}function bA(n,t){const o=st(n).getBoundingClientRect();return new DOMRect(o.left+o.width/2,o.top,1,o.height)}function vA(n,t,e,o){M(t,"selected")}function yA(n){n.rootContainer.querySelectorAll("div.embed-block[data-type=editor-block][data-block-type=embed]").forEach(t=>{H(t,"selected")})}function kA(n,t,e){let o=null;return n.editorEmbeds.forEach(r=>{var s,l;const i=(l=(s=r.convertFrom)==null?void 0:s.call(r,n,t,e))!=null?l:null;i&&(o=i)}),o}function wA(n,t,e,o){const r=Ko(n,t.embedType);return r.convertTo?r.convertTo(n,t,e,o):""}function BA(n,t){const e=eA(n,t);return e.getBlockProperties?e.getBlockProperties(n,t):{}}function EA(n){const t=new Map,e=[];return n.editorEmbeds.forEach(o=>{if(o.getOptions){const r=o.getOptions(n);r.insertEmbedCommandItems&&r.insertEmbedCommandItems.forEach(i=>{e.push(i),t.set(i.id,o)})}}),{name:"EmbedBlock",insertBlockCommandItems:e,async handleInsertEmptyBlock(o,r){const i=t.get(r.item.id);if(!i||!i.getOptions)return null;const s=i.getOptions(o);return s.handleInsertEmptyEmbed?s.handleInsertEmptyEmbed(o,r):null}}}function IA(n,t,e,o){const r=Ne(t),i=Ko(n,r);!i.handleDeleteBlock||i.handleDeleteBlock(n,t,e,o)}function xA(n,t,e){const o=Ne(t),r=Ko(n,o);return r.handleUpdateBlock?r.handleUpdateBlock(n,t,e):!1}function TA(n,t,e,o,r){const i=Ne(t),s=Ko(n,i);if(s.handleDropOver)return s.handleDropOver(n,t,e,o,r)}function SA(n,t,e,o,r){const i=Ne(t),s=Ko(n,i);if(s.handleDrop&&n.isWritable())return s.handleDrop(n,t,e,o,r)}async function DA(n,t,e){const o=t.embedType,r=n.editorEmbeds.getEmbedClass(o);if(r.toStandardDoc){const i=n.getBlockById(t.id),s=ao(i);return r.toStandardDoc(n,t,e,s)}}const Mg={blockType:"embed",blockKind:"embed",createBlockContent:gA,getBlockTextLength:pA,getRangeFromPoint:AA,moveCaret:CA,getCaretRect:bA,updateSelection:vA,clearSelection:yA,convertFrom:kA,convertTo:wA,getBlockProperties:BA,getOptions:EA,handleDeleteBlock:IA,handleUpdateBlock:xA,handleDropOver:TA,handleDrop:SA,toStandardDoc:DA},fe=w("complex-block-helper");function Se(n,t){return xe(n,t).getChildContainers(n,t)}function Rr(n,t,e,o){return e.isSimple()?(u(fe,o.isSimple(),"invalid start and end position"),Se(n,t)):(u(fe,!e.isSimple(),"invalid start pos"),u(fe,!o.isSimple(),"invalid end pos"),xe(n,t).getSelectedContainers(n,t,e,o))}function LA(n,t){if(K(t)!==0)return!1;const e=U(z(t));if(!e)return!1;u(fe,at(n,e),"not a complex block");const o=z(t),i=Se(n,e).indexOf(o);return u(fe,i>=0,"not valid child container"),i===0}function qu(n,t){const e=Se(n,t);if(e.length===0)return null;const o=e[0],r=Ft(o);return at(n,r)?qu(n,r):r}function Vi(n,t){const e=Se(n,t);if(e.length===0)return null;const o=e[e.length-1],r=Jt(o);return at(n,r)?Vi(n,r):r}function Rg(n,t){u(fe,Ke(t),"not a child container");const e=U(t);u(fe,e,"no parent block"),u(fe,at(n,e),"not a complex block");const o=Se(n,e),r=o.indexOf(t);if(u(fe,r!==-1,"child container not found"),r===0){const l=bt(e);return l?at(n,l)?Vi(n,l):l:null}const i=o[r-1],s=Jt(i);return at(n,s)?Vi(n,s):s}function Og(n,t){u(fe,at(n,t),"not a complex block");const e=Se(n,t);if(u(fe,e.length>0,"no child container"),e.length===1)return e;const o=e[0],r=o.getBoundingClientRect();let i=r.left,s=r.right;const l=[o];for(let c=1;c<e.length;c++){const a=e[c],d=a.getBoundingClientRect();if(d.right<=i){l.push(a),i=d.left;continue}if(d.left>=s){s=d.right;continue}}return l}function Ng(n,t){u(fe,at(n,t),"not a complex block");const e=Se(n,t);if(u(fe,e.length>0,"no child container"),e.length===1)return e;const o=e[e.length-1],r=o.getBoundingClientRect();let i=r.left,s=r.right;const l=[o];for(let c=e.length-2;c>=0;c--){const a=e[c],d=a.getBoundingClientRect();if(d.right<=i){l.push(a),i=d.left;continue}if(d.left>=s){s=d.right;continue}}return l}function Pg(n,t,e,o){const r=t.getBoundingClientRect(),i=o<r.top,s=i?Og(n,t):Ng(n,t);let l=s[0],c=An(l.getBoundingClientRect(),e,o);for(let a=1;a<s.length;a++){const d=s[a],f=d.getBoundingClientRect(),m=An(f,e,o);m<c&&(l=d,c=m)}return i?Ft(l):Jt(l)}function Ul(n,t,e,o){const r=j(t);u(fe,r===e.blockId,"invalid start pos"),u(fe,r===o.blockId,"invalid end pos");const i=xe(n,t);return i.adjustSelectionPos?i.adjustSelectionPos(n,t,e,o):{anchor:e,focus:o}}class tn{constructor(t,e){h(this,"editor");h(this,"reverse");h(this,"_anchor");h(this,"_focus");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=Uu(this.editor,this._anchor,this._focus)>0}isCollapsed(){return!1}isEqual(t){if(!(t instanceof tn))return!1;const e=t,{anchor:o,focus:r}=e;return this._anchor.blockId===o.blockId&&this._anchor.childContainerId===o.childContainerId&&this._focus.blockId===r.blockId&&this._focus.childContainerId===r.childContainerId&&this._anchor.custom===o.custom&&this._focus.custom===r.custom}isReverse(){return this.reverse}isSimple(){return!1}getEditor(){return this.editor}get anchor(){return this._anchor}get focus(){return this._focus}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}getSelectedBlocks(){const t=this.start,e=this.end;return[{block:this.editor.getBlockById(t.blockId),start:t,end:e}]}getAnchorPos(){return this._anchor}getFocusedPos(){return this._focus}getSelectedContainers(){const t=this.editor.getBlockById(this._anchor.blockId);return Rr(this.editor,t,this.start,this.end)}clone(){return new tn(this.editor,this)}toDocRange(){return{anchor:this._anchor,focus:this._focus}}}const MA=w("selection-range");function Wt(n,t){const{anchor:e,focus:o}=t;return e instanceof qt&&o instanceof qt?new Kt(n,{anchor:e,focus:o}):(u(MA,e instanceof Xe&&o instanceof Xe,"start position type does not math end type"),new tn(n,{anchor:e,focus:o}))}function Ot(n,t,e,o){const r=new qt(t,e,"normal"),i=new qt(t,o!=null?o:e,"normal");return Wt(n,{anchor:r,focus:i})}function RA(n){return!!n.anchor.childContainerId}function ho(n,t){var r,i;if(RA(t)){const s=Bt(t.anchor.blockId,t.anchor.childContainerId,(r=t.anchor)==null?void 0:r.custom),l=Bt(t.focus.blockId,t.focus.childContainerId,(i=t.focus)==null?void 0:i.custom);return Wt(n,{anchor:s,focus:l})}const e=F(t.anchor.blockId,t.anchor.offset,"normal"),o=F(t.focus.blockId,t.focus.offset,"normal");return Wt(n,{anchor:e,focus:o})}const $g=w("range-from-point");function Vl(n,t,e){const o=[0,-8,8];for(let r=0;r<o.length;r++){const i=document.elementsFromPoint(t,e+o[r])[0];if(!i)continue;const s=i.getBoundingClientRect();if(i.clientWidth&&i.clientHeight&&r===0&&(s.left+i.clientWidth<t||s.top+i.clientHeight<e))return $g.debug("click on scrollbar, out of element rect"),null;if(!n.rootContainer.contains(i))continue;const l=U(i);if(!l||!n.contains(l))continue;const c=pt(n,l).getRangeFromPoint(n,l,t,e+o[r]);if(c)return c}return null}function _g(n,t,e,o){const r=t.getBoundingClientRect();if(o<=r.top){const c=Ft(t),a=pt(n,c).getRangeFromPoint(n,c,e,c.getBoundingClientRect().top+4);if(a!=null&&a.isSimple())return Kt.from(n,a);const d=F(c,0,"home");return new Kt(n,{anchor:d,focus:d})}const i=Jt(t),s=pt(n,i).getRangeFromPoint(n,i,e,i.getBoundingClientRect().bottom-4);if(s!=null&&s.isSimple())return Kt.from(n,s);const l=F(i,G(n,i),"end");return new Kt(n,{anchor:l,focus:l})}function Fg(n,t,e){const o=Vl(n,t,e);if(o){if(o instanceof Kt)return o;u($g,o instanceof tn,`invalid range type: ${typeof o}`);const c=o,a=n.getContainerById(c.start.childContainerId);return _g(n,a,t,e)}const r=document.elementsFromPoint(t,e)[0];if(!r)return null;const{children:i}=r,s=Array.from(i).filter(c=>vn(c));if(s.length===0)return null;const l=s.reduce((c,a)=>{const d=c.getBoundingClientRect(),f=a.getBoundingClientRect();return An(d,t,e)>An(f,t,e)?a:c});return _g(n,l,t,e)}function Wu(n,t){const e=[];return Mt(t).forEach(r=>{e.push(r),at(n,r)&&Se(n,r).forEach(s=>{e.push(...Wu(n,s))})}),e}function Gu(n,t){let e=Wu(n,n.rootContainer);return t!=null&&t.simpleBlockOnly&&(e=e.filter(o=>!at(n,o))),e}function en(n,t){const e=n.selection.range.getSelectedBlocks(),o=[];for(const r of e)o.push(r),at(n,r.block)&&Rr(n,r.block,r.start,r.end).forEach(s=>{const c=Wu(n,s).map(a=>({block:a,start:F(a,0,"home"),end:F(a,G(n,a),"home")}));o.push(...c)});return t!=null&&t.simpleBlockOnly?o.filter(r=>!at(n,r.block)):o}const YU="",zn=w("text-block-child");function qi(n){return n.tagName==="SPAN"}function Pe(n){return u(zn,qi(n),"not a valid text child"),n.getAttribute("data-type")==="editor-box"}function Un(n){return u(zn,qi(n),"not a valid text child"),n.getAttribute("data-type")==="editor-insertion"}function Wi(n){return!Pe(n)&&!Un(n)}function Hg(n){return u(zn,qi(n),"not a valid text child"),Pe(n)?"box":Un(n)?"insertion":"text"}function $e(n){const t=Hg(n);return t==="insertion"?0:t==="box"?1:(u(zn,n.textContent!==null,"text block content is undefined"),u(zn,n.textContent.length>=0,"text block content length is negative"),n.textContent.length)}function yn(n){const t=st(n),e=Array.from(t.children);return e.forEach(o=>{u(zn,qi(o),"not a valid text child")}),e}function ql(n,t){const e=yn(n);let o=0;for(let r=0;r<e.length;r++){const i=e[r],s=$e(i);if(o+s<t){o+=s;continue}if(o===t)return{prev:e[r-1],next:i,offset:0};if(o+s===t)return{prev:i,next:e[r+1],offset:0};const l=t-o;return u(zn,l>0,"invalid offset value"),u(zn,!Pe(i),"invalid box child"),{prev:i,next:i,offset:l}}u(zn,!1,`invalid block child at position: ${t}`)}const Xt=w("text-range");function OA(n,t){const e=(i,s)=>{if(Un(i))return u(Xt,s===0,`invalid offset for insertion child: ${s}`),{child:i,container:i,offset:2};if(Pe(i))return u(Xt,s===0||s===1,`invalid offset for box: ${s}`),{child:i,container:i,offset:s===0?1:2};const l=i.firstChild;return u(Xt,l,"no child node for text child"),u(Xt,l instanceof Text||l instanceof HTMLBRElement,`invalid child for text child, ${l.nodeName}`),l instanceof HTMLBRElement?(u(Xt,s>=0&&s<=0,"invalid offset for text child"),{child:i,container:l,offset:s}):(u(Xt,s>=0&&s<=l.data.length,"invalid offset for text child"),{child:i,container:l,offset:s})};let o=0;const r=yn(n);for(let i=0;i<r.length;i++){const s=r[i],l=$e(s);if(t===o)return[e(s,0)];if(t<o+l)return[e(s,t-o)];if(t===o+l){const c=[];c.push(e(s,$e(s)));const a=r[i+1];return a&&c.push(e(a,0)),c}o+=l}u(Xt,!1,"failed to get range info")}function NA(n,t,e){if(t===e?u(Xt,Un(n),"only insertion child can be zero offset"):u(Xt,t<e,`invalid start & end: ${t}, ${e}`),Un(n)){u(Xt,t===e,`invalid insertion child range offset: ${t}, ${e}`),u(Xt,t===0,`invalid insertion child range start: ${t}`);const i=n;return u(Xt,i.children.length===3,`invalid insertion dom, children.length = ${i.children.length}`),Tl(i,1,i,2)}if(Pe(n)){u(Xt,t+1===e,`invalid box child range offset: ${t}, ${e}`),u(Xt,t===0,`invalid box child range start: ${t}`);const i=n;return u(Xt,i.children.length===3,`invalid box dom, children.length = ${i.children.length}`),Tl(i,1,i,2)}const o=$e(n);u(Xt,e<=o,`invalid child end: ${e}, ${o}`);const r=n.firstChild;return u(Xt,r instanceof Text,"invalid block text child"),u(Xt,r.data.length>=e,`invalid range end: ${e}, ${r.data.length}`),Tl(r,t,r,e)}const nn=w("caret-rect");function PA(n,t){if(Mu(t)){const e=t,o=Ou(e);if(e.getAttribute("data-box-type")==="br"){const r=st(n),i=Number.parseFloat(window.getComputedStyle(r).lineHeight)||o.getBoundingClientRect().height,s=Array.from(o.getClientRects());u(nn,s.length>0,"no box client rects");const l=r.getBoundingClientRect(),c=s[0],a=new DOMRect(l.left,c.bottom,1,i);return s.push(a),s}return o.getClientRects()}return Nu(t).getClientRects()}function De(n,t){var l,c;const e=OA(n,t.offset);if(e[1]&&e[0].child!==((l=e[1])==null?void 0:l.child)){if(t.type==="end"){const d=Vo(e[0].child);return new DOMRect(d.right,d.top,1,d.height)}u(nn,e[1],"invalid ranges");const a=Sl(e[1].child);return new DOMRect(a.left,a.top,1,a.height)}let r=e[0];if(u(nn,e.length>=1,"failed to get block range"),e.length===1)r=e[0];else{if(u(nn,e.length>=2,`invalid range info length: ${e.length}`),Un(e[e.length-1].child)){r=e[e.length-1];const a=r.child,f=Nu(a).getClientRects();u(nn,f.length>=1,"no client rects for box content");const m=f[f.length-1];return new DOMRect(m.right,m.y,1,m.height)}t.type==="home"?r=e[1]:t.type==="end"||Wi(e[0].child)?r=e[0]:Wi(e[1].child)&&(r=e[1])}if(r.container instanceof HTMLBRElement){u(nn,t.offset===0,"invalid offset for empty block text");const a=(c=r.container.parentElement)==null?void 0:c.parentElement;u(nn,a===st(n),"invalid br parent, is not block parent");const d=a.getBoundingClientRect();return new DOMRect(d.left,d.top,1,d.height)}const s=km(r.container,r.offset).getClientRects();if(s.length===0){u(nn,!Wi(r.child),"only box or insertion child range has zero client rect"),u(nn,r.offset===1||r.offset===2,"invalid offset for box or insertion child");const a=r.child,d=PA(n,a);if(u(nn,d.length>=1,"no client rects for box content"),r.offset===1){const m=d[0];return new DOMRect(m.x,m.y,1,m.height)}const f=d[d.length-1];return t.type==="end"||r.offset===2?new DOMRect(f.right,f.y,1,f.height):new DOMRect(f.x,f.y,1,f.height)}return u(nn,s.length>0,"no client rects for range"),t.type==="home"?s[s.length-1]:s[0]}const $A=w("core");function fo(n,t,e,o){const r=Rt(t);let i=r.querySelector(`.block-anchor[data-id=${e}]`);i||(i=b("div",["block-anchor"],r),i.setAttribute("data-id",e));const s=o!=null?o:t.getBoundingClientRect(),l=t.getBoundingClientRect(),c=new DOMRect(s.left-l.left,s.top-l.top,s.width,s.height);return i.style.left=`${c.left}px`,i.style.top=`${c.top}px`,i.style.width=`${c.width}px`,i.style.height=`${c.height}px`,i}function jg(n,t,e,o){u($A,_(n,t),"not a text kind block");const r=De(t,F(t,e,"normal")),i=t.getBoundingClientRect(),s=Rt(t);let l=s.querySelector(`.block-anchor[data-id=${o}]`);l||(l=b("div",["block-anchor"],s),l.setAttribute("data-id",o));const c=new DOMRect(r.left-i.left,r.top-i.top,r.width,r.height);return l.style.left=`${c.left}px`,l.style.top=`${c.top}px`,l.style.width=`${c.width}px`,l.style.height=`${c.height}px`,l}function Gi(n){const t=yn(n);let e=0;return t.forEach(o=>{e+=$e(o)}),e}const zg=w("box");function Zi(n){return!n.attributes||!n.attributes.box?!1:(u(zg,n.attributes.box===!0,`invalid op attribute box property, ${n.attributes.box}`),u(zg,n.attributes.type,`no box type: ${JSON.stringify(n)}`),!0)}const Ug=w("rich-text-length");function Zu(n){return u(Ug,typeof n.insert=="string","op.insert is not string"),n.insert.length}function me(n){let t=0;return n.forEach(e=>{e.insert&&(u(Ug,typeof e.insert=="string","op.insert is not string"),t+=Zu(e))}),t}const kn=w("split-text");function ve(n,t,e){if(n=Q.default(n),t===0)return{left:[],right:n};if(t===-1)return{left:n,right:[]};let o=0;for(let r=0;r<n.length;r++){const i=n[r];u(kn,typeof i=="object",`invalid op type, ${typeof i}`),u(kn,typeof i.insert=="string",`invalid op.insert type, ${typeof i.insert}`);const s=Zu(i);if(o+s<t)o+=s;else{if(o+s===t)return{left:n.slice(0,r+1),right:n.slice(r+1)};{u(kn,o+s>t,`invalid offset, ${o}, ${s}, ${t}`);const l=t-o,c=Q.default(i);u(kn,c.insert,"no copied.insert"),u(kn,typeof c.insert=="string","invalid copied.insert type"),c.insert=c.insert.substr(0,l),i.insert=i.insert.substr(l),c.insert===""&&u(kn,!1,"invalid copied.insert, is empty string"),i.insert===""&&u(kn,!1,"invalid op.insert, is empty string");const a=[i,...n.slice(r+1)],d=[...n.splice(0,r),c];return e&&(e.sourceOp=i),{left:d,right:a}}}}throw new Error(`invalid split offset: ${t}, ${JSON.stringify(n)}`)}function Gt(n,t,e){u(kn,t>=0,"invalid offset, < 0"),u(kn,e>0,"invalid length, <= 0"),u(kn,t+e<=me(n),"invalid offset + length < text length");const{left:o,right:r}=ve(n,t+e),{left:i,right:s}=ve(o,t);return{left:i,middle:s,right:r}}function Vg(n,t){const e=Array.from(new Set(t)).sort((i,s)=>i-s),o=[];let r=n;for(let i=e.length-1;i>=0;i--){const s=e[i],{left:l,right:c}=ve(r,s);r=l,o.unshift(c)}return r.length>0&&o.unshift(r),o}function qg(n,t,e){return Gt(n,t,e).middle}const Or=w("text-block-content");function _A(n,t,e,o,r){if(u(Or,o,"no text for block"),o.length===0&&(!r||r.size===0)){e.innerHTML="<span><br></span>";return}const i=[];r&&i.push(...r.keys());const s=f=>n.editorInsertions.createInsertion(e,f),l=(f,m)=>{const p=r==null?void 0:r.get(m);p&&(p.forEach(A=>{f.appendChild(s(A))}),r==null||r.delete(m))},c=document.createDocumentFragment();let a=0;const d=Vg(o,i);for(let f=0;f<d.length;f++){l(c,a);const m=d[f];a+=me(m);for(let p=0;p<m.length;p++){const A=m[p];if(Zi(A)){u(Or,A.attributes,`op is not an valid box: ${JSON.stringify(A)}`);const v=n.editorBoxes.createBox(e,A.attributes);u(Or,v instanceof HTMLSpanElement,`invalid box element: ${v.tagName}`),c.appendChild(v);continue}u(Or,A.insert,`no insert in op: ${JSON.stringify(A)}`);const k=b("span",["text"],c,A.insert);if(A.attributes){const v=n.editorBlockRenders.renderText(t,A.attributes);v.classes&&M(k,...v.classes),v.attributes&&Object.entries(v.attributes).forEach(([T,E])=>{k.setAttribute(T,E)}),v.styles&&Object.entries(v.styles).forEach(([T,E])=>{k.style.setProperty(T,E)})}c.appendChild(k)}}l(c,a),e.innerHTML="",e.appendChild(c)}function Wl(n,t,e,o,r){const{text:i,insertions:s}=n.editorDecorators.decorateText(t,r),l=n.compositingText;if(l){const c=n.selection.range.start;u(Or,c.isSimple(),"not an simple position while compositing"),c.blockId===e&&s.set(c.offset,[{type:"inputting",id:P(),text:l}])}return _A(n,t,o,i,s)}function FA(n){const t=n.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');t.length&&Or.debug(`remove ${t.length} temp composition span`),Array.from(t).forEach(e=>e.remove())}const wn=w("client-rects");function HA(n){const t=yn(n);let e=0;const o=[];for(let r=0;r<t.length;r++){const i=t[r],s=$e(i);o.push({child:i,startBlockOffset:e,endBlockOffset:e+s}),e+=s}return o}function jA(n,t,e,o){u(wn,e<o,`invalid from & to: ${e}, ${o}`);const r=G(n,t);u(wn,e>=0&&o>=0&&e<=r&&o<=r,`invalid offset: ${e}, ${o}, length: ${r}`);const i=HA(t),s=i.findIndex(p=>p.startBlockOffset<=e&&e<p.endBlockOffset),l=i.findIndex(p=>p.startBlockOffset<o&&o<=p.endBlockOffset);if(u(wn,s!==-1,"failed to find start child"),u(wn,l!==-1,"failed to find end child"),u(wn,s<=l,`invalid start index & end index: ${s}, ${l}`),s===l){const p=i[s];return[{child:p.child,startChildOffset:e-p.startBlockOffset,endChildOffset:o-p.startBlockOffset}]}const c=[],a=i[s],d={child:a.child,startChildOffset:e-a.startBlockOffset,endChildOffset:$e(a.child)};c.push(d);for(let p=s+1;p<l;p++){const A=i[p],k={child:A.child,startChildOffset:0,endChildOffset:A.endBlockOffset-A.startBlockOffset};c.push(k)}const f=i[l],m={child:f.child,startChildOffset:0,endChildOffset:o-f.startBlockOffset};return c.push(m),c}function zA(n){const t=(o,r)=>o.left<=r.left&&o.top<=r.top&&o.right>=r.right&&o.bottom>=r.bottom&&(o.width!==r.width||o.height!==r.height);n=n.filter(o=>!n.find(i=>t(o,i)));const e=[];return n=n.filter(o=>e.find(r=>r.left===o.left&&r.top===o.top&&r.width===o.width&&r.height===o.height)?!1:(e.push(o),!0)),n}function Wg(n,t,e,o){if(G(n,t)===0){const d=st(t).getBoundingClientRect();return[new DOMRect(d.left,d.top,4,d.height)]}const r=e.offset,i=o.offset;if(r===i)return[De(t,e)];const l=jA(n,t,r,i).map(a=>NA(a.child,a.startChildOffset,a.endChildOffset)),c=[];return l.forEach(a=>{const d=zA(Array.from(a.getClientRects()));c.push(...d)}),c}function UA(n,t,e){u(wn,e instanceof Kt,"invalid range");const o=e.start,r=e.end;return u(wn,o.isSimple(),"text block only allow simple position"),u(wn,r.isSimple(),"text block only allow simple position"),u(wn,o.blockId===r.blockId,"only allow update one text block selection"),u(wn,o.blockId===j(t),"only allow update one text block selection"),Wg(n,t,o,r)}const Qu=w("selection-background");function VA(n,t,e,o){u(Qu,e.isSimple(),"text block only allow simple position"),u(Qu,o.isSimple(),"text block only allow simple position"),u(Qu,e.blockId===o.blockId,"only allow update one text block selection");const r=e.offset,i=o.offset;if(r===i&&(G(n,t)!==0||n.selection.range.isCollapsed()))return;const s=Wg(n,t,e,o),l=t.getBoundingClientRect(),c=sg(t);c.innerHTML="",s.forEach(a=>{const d=b("div",["editor-selection-background"],c);d.style.left=`${a.left-l.left}px`,d.style.top=`${a.top-l.top}px`,d.style.width=`${a.width}px`,d.style.height=`${a.height}px`})}function qA(n){n.rootContainer.querySelectorAll("div[data-type=block-background]").forEach(t=>{t.remove()})}const Xo=w("text-offset"),Gg="\u200D";function mo(n,t){const e=yn(n);let o=0;for(let r=0;r<e.length;r++){const i=e[r],s=$e(i);if(i===t){const l=o+s;return{start:o,end:l}}o+=s}u(Xo,!1,"can not find child in children")}function le(n,t){u(Xo,t>=0,`invalid offset: ${t}`);const e=ql(n,t),{prev:o,next:r,offset:i}=e;if(!o&&!r&&u(Xo,!1,"invalid offset, no prev & next child at offset"),o!==r)return!0;const s=o;if(u(Xo,s,"no child"),Pe(s))return u(Xo,i===0||i===1,`invalid box child offset: ${i}`),!0;const l=s.textContent;u(Xo,l,"no content for text child");const c=l.charAt(i-1),a=l.charAt(i);return!(c===Gg||a===Gg||uu(l[i]))}function go(n,t){if(t===0)return 0;const e=t-1;if(le(n,e))return e;let o=e-1;for(;!le(n,o);)o-=1;return o}function tr(n,t){const e=Gi(n);if(u(Xo,t>=0&&t<=e,`invalid offset: ${t}, ${e}`),t===e)return e;const o=t+1;if(le(n,o))return o;let r=o+1;for(;!le(n,r);)r+=1;return r}const er=w("line-breaker");function Qi(n){const t=c=>{const a=Sl(c);return Vo(c).top>a.top+a.height/2},e=(c,a)=>{const d=Vo(c);return Sl(a).left<d.right},o=(c,a)=>{const d=Vo(c),f=Vo(a);return f.top+f.height/2>d.bottom},r=c=>{if(c.length===0||c.length===1)return!1;const a=c[0],d=c[c.length-1];return a.right-d.left>10},i=[];let s=0;const l=yn(n);for(let c=0;c<l.length;c++){const a=l[c];if(Un(a)){const v=a,T=l[c+1];if(!T)break;const E=l[c-1];if(E&&o(E,v)&&i.push({offset:s,type:"betweenChild",childInfo:{prevChild:E,nextChild:v,wrap:"nextWrapped",prevWrapped:t(E),nextWrapped:t(v)}}),e(v,T)){i.push({offset:s,type:"betweenChild",childInfo:{prevChild:E,nextChild:v,wrap:"nowrap",prevWrapped:t(E),nextWrapped:t(v)}});continue}continue}if(Pe(a)){const v=a,T=l[c+1];if(!T)break;const E=l[c-1];if(E&&o(E,v)&&i.push({offset:s,type:"betweenChild",childInfo:{prevChild:E,nextChild:v,wrap:"nextWrapped",prevWrapped:t(E),nextWrapped:t(v)}}),e(v,T)){s+=1,i.push({offset:s,type:"betweenChild",childInfo:{prevChild:E,nextChild:a,wrap:"nowrap",prevWrapped:t(E),nextWrapped:t(a)}});continue}s+=1;continue}const d=a,f=d.getClientRects();if(u(er,f.length>0,"invalid text child dom"),f.length===1){const v=l[c+1];if(!v)break;if(e(d,v)){s+=$e(d),i.push({offset:s,type:"betweenChild",childInfo:{prevChild:d,nextChild:v,wrap:"nowrap",prevWrapped:t(d),nextWrapped:t(v)}});continue}s+=$e(d);continue}const m=d.firstChild;u(er,m,"invalid text child, no text node"),u(er,m instanceof Text,`invalid text child, not a valid text node: ${typeof m}`);const p=document.createRange(),A=document.createRange(),k=$e(d);u(er,m.data.length===k,"text node data length not equal child text length");for(let v=0;v<m.data.length;v++){if(!le(n,s+v))continue;p.setStart(m,v),bu()&&p.selectNodeContents(m);const T=p.getClientRects();if(u(er,T.length>=1,"invalid text node, no client rects"),r(T)){const q=s+v;i.push({offset:q,type:"textBreakWord",childInfo:{prevChild:a,nextChild:a,wrap:"nowrap",prevWrapped:t(a),nextWrapped:t(a)}});continue}let E=v+1;le(n,s+E)||(E=v+2),A.setStart(m,E);const L=A.getClientRects(),R=T[0];L[0].left<R.right&&u(er,!1,"span pre-wrap should not has a line-wrap by white space")}s+=k}return i}function Yu(n,t){const e=Qi(n);for(let o=0;o<e.length;o++){const{offset:r,type:i}=e[o];if(t.offset<r)return{lineIndex:o,lineBreaks:e};if(t.offset===r&&t.type==="end")return{lineIndex:o,lineBreaks:e}}return u(er,t.offset<=Gi(n),"invalid position, offset > block length"),{lineIndex:e.length,lineBreaks:e}}const WA=w("line-offset");function Ju(n){const t=Qi(n),e=[];let o=0;for(let r=0;r<t.length;r++){const i=t[r];e.push({start:o,end:i.offset}),o=i.offset}return e.push({start:o,end:Gi(n)}),e}function Gl(n,t){const e=Ju(n);return u(WA,t>=0&&t<e.length,`invalid line index: ${t}, ${e.length}`),e[t]}function Zg(n,t){const{lineIndex:e}=Yu(n,t);return Gl(n,e)}function GA(n){const t=Ju(n),e=n.getBoundingClientRect(),o=[];return t.forEach(({start:r,end:i})=>{const s=F(n,r,"home");let l=De(n,s);const c=F(n,i,"end"),a=De(n,c);l.top+l.height/2<a.top&&(l=new DOMRect(e.left-1e4,a.top,1,a.height));const d=new DOMRect(l.left,a.top,a.left-l.left,a.height),f=new DOMRect(e.left,a.top,e.width,a.height);o.push({start:r,end:i,rect:f,contentRect:d})}),o}function ZA(n,t,e){const r=GA(n).find(s=>Wo(s.rect,t,e));if(!r)return null;const i=r.contentRect;return t-i.left<i.right-t?F(n,r.start,"home"):F(n,r.end,"end")}function Qg(n,t,e){const o=De(n,t),r=De(n,e),i=o.top+o.height/2,s=r.top+r.height/2,l=r.top<i&&i<r.bottom,c=o.top<s&&s<o.bottom;return l&&c}function Yg(n){return Ju(n).length}const nr=w("find-text-position");function Jg(n,t){const{start:e,end:o}=Gl(n,t),r=j(n),i=De(n,F(r,e,"home"));if(!(De(n,F(r,o,"end")).top>i.top+i.height/2))return!1;const c=ql(n,e);return u(nr,c.next,"no next child at offset"),u(nr,!Wi(c.next),"next child is not text child"),!0}function QA(n,t){const e=j(n);u(nr,Jg(n,t),"line is not wrapped");const{start:o,end:r}=Gl(n,t),i=F(e,o,"home");for(let s=o+1;s<=r;s+=1){let l="normal";s===o?l="home":s===r&&(l="end");const c=F(e,s,l);if(!Qg(n,i,c))return s-1}return u(nr,!1,"failed to find wrapped offset"),0}function Zl(n,t,e,o,r,i,s){u(nr,_(n,t),`not a text kind block: ${it(t)}`);const{start:l,end:c}=Gl(t,e);let a=l;const d=j(t);if(t===o&&Jg(t,e)){const v=QA(t,e);(i==="up"||i==="down"&&Qg(t,r,F(d,l,"home")))&&(a=v+1)}let f=Number.MAX_SAFE_INTEGER;const m=Ye(n,o,r),p=s!=null?s:m.left+m.width/2,A=m.top+m.height/2;let k=F(d,a,"home");for(let v=a;v<=c;v++){if(!le(t,v))continue;let T="normal";v===l?T="home":v===c&&(T="end");const E=F(d,v,T),L=De(t,E),R=An(L,p,A);R<f&&(f=R,k=E)}return k}function YA(n,t,e,o,r){return u(nr,_(n,t),"not a text block"),Zl(n,t,Yg(t)-1,e,o,"up",r)}function JA(n,t,e,o,r){return u(nr,_(n,t),"not a text block"),Zl(n,t,0,e,o,"down",r)}function KA(n,t,e,o){const{lineIndex:r}=Yu(t,e);if(r===Yg(t)-1)return null;const i=Zl(n,t,r+1,t,e,"down",o);return i||null}function XA(n,t){if(t.offset===0)return null;const e=Qi(n),o=e.find(r=>r.offset===t.offset);if(!o){const r=go(n,t.offset);return e.find(s=>s.offset===r)?{offset:r,type:"home"}:{offset:r,type:"normal"}}if(o.type==="betweenChild"){if(t.type==="home"&&o.childInfo.wrap==="nowrap")return{offset:t.offset,type:"end"};if(o.childInfo.prevWrapped)return{offset:go(n,t.offset),type:"normal"}}return{offset:go(n,t.offset),type:"normal"}}function tb(n,t){const e=Gi(n);if(t.offset===e)return null;const o=Qi(n),r=o.find(i=>i.offset===t.offset);if(!r){const i=tr(n,t.offset),s=o.find(l=>l.offset===i);return s?s.type==="betweenChild"?{offset:i,type:"end"}:{offset:i,type:"home"}:{offset:i,type:"normal"}}return r.type==="betweenChild"?r.childInfo.wrap==="nowrap"&&t.type==="end"?{offset:t.offset,type:"home"}:{offset:tr(n,t.offset),type:"home"}:{offset:tr(n,t.offset),type:"normal"}}function eb(n,t,e,o){const{lineIndex:r}=Yu(t,e);if(r===0)return null;const i=Zl(n,t,r-1,t,e,"up",o);return i||null}const nb=w("move-caret");function ob(n,t,e,o){if(o==="ArrowLeft"){const r=XA(t,e);return r?F(j(t),r.offset,r.type):null}if(o==="ArrowRight"){const r=tb(t,e);return r?F(j(t),r.offset,r.type):null}if(o==="ArrowUp"){const r=eb(n,t,e,n.selection.getSuggestedCaretX());return r?F(j(t),r.offset,r.type):null}if(o==="ArrowDown"){const r=KA(n,t,e,n.selection.getSuggestedCaretX());return r?F(j(t),r.offset,r.type):null}u(nb,!1,`invalid navigation direction: ${o}`)}const Ku=w("text-range");function rb(n){const t=[];return yn(n).forEach(o=>{const r=Array.from(o.getClientRects()).map(i=>({rect:i,child:o}));t.push(...r)}),t}function ib(n,t,e){const o=rb(n);for(let r=1;r<o.length;r++){const i=o[r-1],s=o[r];if(t>=i.rect.right&&t<=s.rect.left&&e>=i.rect.top&&e<=i.rect.bottom&&e>=s.rect.top&&e<=s.rect.bottom)return mo(n,s.child).start}return null}function sb(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=r.closest("div[data-type=block-content]>span");if(!i){const T=t.getBoundingClientRect();if(!Wo(T,e,o))return null;const E=ib(t,e,o);if(E!==null){const R=F(t,E,"normal");return new Kt(n,{anchor:R,focus:R})}const L=ZA(t,e,o);return L?new Kt(n,{anchor:L,focus:L}):null}const s=yn(t);u(Ku,s.indexOf(i)!==-1,"failed to find child in children");const l=mo(t,i);u(Ku,l,"failed to get child offset");const{start:c}=l;let a,d;Un(i)||Pe(i)?(a=c,d=0):(u(Ku,i.firstChild instanceof Text,"child is not text"),a=c+wm(i.firstChild,e,o),d=0);const f=j(t),p=Qi(t).find(T=>T.offset===a);let A="normal";if(p){const T=F(f,a,"home"),E=F(f,a,"end"),L=De(t,T),R=De(t,E),$=An(L,e,o),q=An(R,e,o);A=$<q?"home":"end"}const k=F(f,a,A);let v;return d&&(v=F(f,a+d,A)),new Kt(n,{anchor:k,focus:v!=null?v:k})}const lb=w("create-text-op");function _e(n,t){u(lb,n,"text is empty");const e={insert:n};return t&&Object.keys(t).length>0&&(e.attributes=t),e}function Xu(n,t){if(n.length===0)return[];if(n.indexOf(`
|
|
15
|
+
animateScrollTo(scrollToElement:Element, options)`;e+=i.horizontalOffset,o+=i.verticalOffset;const f=d.getMaxHorizontalScroll(),m=d.getHorizontalScroll();e>f&&(e=f);const p=e-m,A=d.getMaxVerticalScroll(),k=d.getVerticalScroll();k<o?o-=window.innerHeight*3/4:o-=window.innerHeight*1/4,o>A&&(o=A);const v=o-k,x=Math.abs(Math.round(p/1e3*i.speed)),E=Math.abs(Math.round(v/1e3*i.speed));let L=x>E?x:E;return L<i.minDuration?L=i.minDuration:L>i.maxDuration&&(L=i.maxDuration),new Promise((R,$)=>{p===0&&v===0&&R(!0),Fn.remove(d.element,!0);let q;const ot=()=>{de(),cancelAnimationFrame(q),R(!1)};Fn.add(d.element,ot);const lt=qe=>qe.preventDefault(),gt=i.cancelOnUserAction?ot:lt,ht=i.cancelOnUserAction?{passive:!0}:{passive:!1},kt=["wheel","touchstart","keydown","mousedown"],de=()=>{kt.forEach(qe=>{d.element.removeEventListener(qe,gt,ht)})};kt.forEach(qe=>{d.element.addEventListener(qe,gt,ht)});const oo=Date.now(),re=()=>{const qe=Date.now()-oo,$o=qe/L,kr=Math.round(m+p*i.easing($o)),wr=Math.round(k+v*i.easing($o));qe<L&&(kr!==e||wr!==o)?(d.scrollTo(kr,wr),q=requestAnimationFrame(re)):(d.scrollTo(e,o),cancelAnimationFrame(q),de(),Fn.remove(d.element,!1),R(!0))};q=requestAnimationFrame(re)})}function Wo(n,t,e){return n.left<=t&&t<=n.right&&n.top<=e&&e<=n.bottom}function D8(n){const t="\xA0";if(!n)return"";if(n===" ")return t;let e=n;return e.startsWith(" ")&&(e=t+e.substr(1)),e.endsWith(" ")&&(e=e.substr(0,e.length-1)+t),e=e.replace(/ {2}/g,` ${t}`),e}function Tm(n){if(!/["'&<>]/.exec(n))return n;const o={'"':""","'":"'","&":"&","<":"<",">":">"};return n.split("").map(l=>o[l]||l).join("")}function Sm(n){const t=document.getElementById(n);t&&t.remove()}function Dm(n,t){const e=document.getElementById(t);if(e)return e.textContent=n,e;const o=document.createElement("style");return o.id=t,o.textContent=n,document.head.append(o),o}function Fi(n){const t="custom-cursor-style";if(n){const e=`body * { cursor: ${n} !important}`;Dm(e,t)}else Sm(t)}const Lm=3,Mm=w("drag-drop");class Rm{constructor(t){h(this,"dragStarted",!1);h(this,"mouseDownEvent",null);h(this,"_dragOffsetX",0);h(this,"_dragOffsetY",0);h(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.mouseDownEvent=t;const e=this.options.elem.getBoundingClientRect();this._dragOffsetX=this.mouseDownEvent.x-e.left,this._dragOffsetY=this.mouseDownEvent.y-e.top,this.bindEvents()});h(this,"handleMouseMove",t=>{var i;t.preventDefault(),t.stopPropagation(),u(Mm,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,o=t.y-this.mouseDownEvent.y;if(this.dragStarted){this.onDragging(t,e,o);return}const r=(i=this.options.minThreshold)!=null?i:Lm;(Math.abs(e)>=r||Math.abs(o)>=r)&&this.onDragStart(this.mouseDownEvent)});h(this,"handleMouseUp",t=>{if(t.button===0){u(Mm,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,o=t.y-this.mouseDownEvent.y;this.onDragEnd(t,e,o),t.preventDefault(),t.stopPropagation()}});this.options=t,this.options.mouseDownEvent?this.handleMouseDown(this.options.mouseDownEvent):this.trackEvents()}get data(){return this.options.data}get dragOffsetX(){return this._dragOffsetX}get dragOffsetY(){return this._dragOffsetY}get dragOffset(){return{x:this._dragOffsetX,y:this._dragOffsetY}}trackEvents(){this.options.elem.addEventListener("mousedown",this.handleMouseDown)}untrackEvents(){this.options.elem.removeEventListener("mousedown",this.handleMouseDown)}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}onDragStart(t){this.dragStarted=!0,this.options.cursor&&Fi(this.options.cursor),this.options.onDragStart(this,t,this.options.elem)}onDragging(t,e,o){this.options.onDragging(this,t,this.options.elem,e,o)}onDragEnd(t,e,o){this.options.cursor&&Fi(null),this.dragStarted&&this.options.onDragEnd(this,t,this.options.elem,e,o),this.unbindEvents(),this.dragStarted=!1}destroy(){this.unbindEvents(),this.untrackEvents()}}function Cu(n){return new Rm(n)}const L8=w("character");function Om(n,t){for(let e=0;e<t.length;e++){const o=t[e][0],r=t[e].length>1?t[e][1]:null;if(r===null&&n===o||r!==null&&n>=o&&n<=r)return!0}return!1}function Nm(n){const t=n.charAt(0);return t>="0"&&t<="9"}function Pm(n){const t=n.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"||t.toUpperCase()!==t.toLowerCase()?!0:RegExp(/^\p{L}/,"u").test(t)}function Ll(n){const t=[[9,13],[32],[160]];return Om(n.charCodeAt(0),t)}function $m(n){const t=[[12352,12687],[13056,13183],[13312,15661],[19968,40959],[63744,64255],[44032,55215]];return Om(n.charCodeAt(0),t)}function Au(n,t){let e=t;return u(L8,e.length===1,"invalid char length"),e==="]"&&(e="\\]"),e==="\\"&&(e="\\\\"),n.replace(new RegExp(`^[${e}]+|[${e}]+$`,"g"),"")}const Hn=navigator.userAgent;function _m(){const n=navigator.userAgent.toLowerCase();return n.indexOf("safari")!==-1&&!(n.indexOf("chrome")>-1)}function bu(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}const xt={isAndroid:!!Hn.match(/Android/i),isIOS:!!Hn.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),isIPad:!!Hn.match(/iPad/i),isIPhone:!!Hn.match(/iPhone/i),isLinux:!!Hn.match(/Linux/i),isMac:!!Hn.match(/Macintosh/i),isMobile:!!Hn.match(/AppleWebKit.*Mobile.*/i),isWindows:!!Hn.match(/Window/i),isIe:!!Hn.match(/msie|trident/i),isSafari:_m(),isMobileSafari:!1};xt.isMobileSafari=xt.isMobile&&xt.isSafari;function vu(n){return n?n.length===1||n==="Process"||n==="Unidentified"&&xt.isAndroid:!1}function Fm(n){switch(n){case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":case"End":case"Home":case"PageDown":case"PageUp":return!0;default:return!1}}function M8(n){return Fm(n.key)}function R8(n){switch(n){case"ArrowUp":case"ArrowLeft":case"Home":case"PageUp":return!0;default:return!1}}function Go(n){return n.ctrlKey||n.altKey||n.shiftKey||n.metaKey}function O8(n){return n.key?!!(n.ctrlKey||n.metaKey||n.altKey):!1}function Hm(n){return xt.isMac?n.metaKey&&!n.ctrlKey:!n.metaKey&&n.ctrlKey}function N8(n){return Hm(n)&&!n.altKey&&!n.shiftKey}function P8(n){return!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.altKey}function jm(n){return!Go(n)&&n.key==="Enter"}function $8(n){return n.key==="Enter"&&n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey}function yu(n){return!Go(n)&&n.key==="Escape"}function _8(n){return!Go(n)&&n.key==="Delete"}function zm(n){return!Go(n)&&n.key==="Backspace"}function F8(n){return!Go(n)&&n.key==="Tab"}function H8(n){return n.shiftKey&&n.key==="Tab"&&!n.ctrlKey&&!n.metaKey}function j8(n){if(!n)return"";if(xt.isMac){const t=n.replace("CtrlOrCmd","\u2318").replace("Shift","\u21E7").replace("Ctrl","\u2303").replace("Alt","\u2325").replace(/\+(?!$)/gm,""),e={"\u2318":4,"\u21E7":3,"\u2325":2,"\u2303":1};return t.split(/(?=[\s\S])/u).sort((r,i)=>{var c,a;const s=(c=e[r])!=null?c:5,l=(a=e[i])!=null?a:5;return s-l}).join("")}return n.replace("CtrlOrCmd","Ctrl")}function Um(n){const t={ctrl:!1,alt:!1,shift:!1,cmd:!1,key:""},e=n.toLocaleUpperCase().split("+");for(let o=0;o<e.length;o++){const r=e[o];r==="CTRL"||r==="CONTROL"?t.ctrl=!0:r==="ALT"||r==="OPTION"?t.alt=!0:r==="SHIFT"?t.shift=!0:r==="CMD"||r==="COMMAND"?t.cmd=!0:r==="CMDORCTRL"||r==="CTRLORCMD"?xt.isMac?t.cmd=!0:t.ctrl=!0:r==="SPACE"?t.key=" ":t.key=r.substring(0,1)+r.substring(1).toLocaleLowerCase()}return t}function jn(n,t){const e=Um(t);return e.ctrl!==n.ctrlKey||e.alt!==n.altKey||e.shift!==n.shiftKey||xt.isMac&&e.cmd!==n.metaKey?!1:e.key.length===1?e.key===n.key.toUpperCase():e.key.toUpperCase()===n.key.toUpperCase()}function ku(n,t){return L7.stringifyUrl({url:n,query:t})}function Zo(n){return typeof n=="string"?Ri.Base64.encode(n,!0):Ri.Base64.fromUint8Array(n,!0)}function Ml(n){return Ri.Base64.decode(n)}function z8(n){return Ri.Base64.toUint8Array(n)}function wu(n){return new Blob([Ri.Base64.toUint8Array(n)])}const U8=io.init([io.classModule,io.styleModule,io.datasetModule,io.attributesModule,io.propsModule]);function Hi(n,t){const e=io.toVNode(n),o=io.toVNode(t);U8(e,o)}async function Bu(n,t){const e=new FileReader,o=new Promise((i,s)=>{e.onload=i,e.onerror=s});return e.readAsDataURL(new Blob([n],{type:t})),await o,e.result}async function Tr(n){const t=new FileReader,e=new Promise((r,i)=>{t.onload=r,t.onerror=i});return t.readAsDataURL(n),await e,t.result}function V8(n,...t){const e=n.tagName.toLowerCase();for(let o=0,r=t.length;o<r;o++)if(e===t[o].toLowerCase())return!0;return!1}function bn(n,t){let e=n;for(;e;){const o=window.getComputedStyle(e);if(t!=null&&t.horizontal){if(/auto|scroll/i.test(o.overflowX))break}else if(/auto|scroll/i.test(o.overflowY))break;e=e.parentElement}return(!e||V8(e,"body"))&&(e=document.documentElement),e}function Vm(n){n.preventDefault(),n.stopPropagation()}function qm(n){if(document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))return;const t=b("div",["editor-disable-scroll"],null);t.setAttribute("data-scroll-id",n),t.addEventListener("wheel",Vm,{passive:!1}),document.body.appendChild(t)}function Wm(n){const t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`);t&&(t.removeEventListener("wheel",Vm),t.remove())}function Eu(n,t,e){const o=new Blob([n]),r=new File([o],e,{type:t});return URL.createObjectURL(r)}function Rl(n){const t=document.createElement("template");if("content"in t)return t.innerHTML=n,document.importNode(t.content,!0);const e=document.createDocumentFragment(),o=document.createElement("div");for(o.innerHTML=n;o.firstChild;)e.appendChild(o.firstChild);return e}function Gm(n){const t=document.createElement("div");return t.appendChild(n),t.innerHTML}function Zm(n){let t=n.getPropertyValue("font");if(t)return t;const e=n.getPropertyValue("font-style"),o=n.getPropertyValue("font-variant"),r=n.getPropertyValue("font-weight"),i=n.getPropertyValue("font-size"),s=n.getPropertyValue("font-family");return t=`${e} ${o} ${r} ${i} ${s}`.replace(/ +/g," ").trim(),t}function Ol(n,t){const o=(Ol.canvas||(Ol.canvas=document.createElement("canvas"))).getContext("2d");return o?(typeof t=="string"?t?o.font=t:o.font=Zm(window.getComputedStyle(document.body)):t instanceof Element&&(o.font=Zm(window.getComputedStyle(t))),o.measureText(n).width+4):200}const q8=w("editor-clipboard");async function W8(n,t){if(t.clipboardData){const e=t.clipboardData;for(const o of n)e.setData(o.type,o.data);return!0}return!1}async function Nl(n){try{const t={};n.forEach(o=>{t[o.type]=o.data});const e=new ClipboardItem(t);return await navigator.clipboard.write([e]),!0}catch(t){return q8.error(t),!1}}function Qo(n,t){return new Promise((e,o)=>{const r=document.createElement("input");r.type="file",r.style.display="none",t!=null&&t.multiple&&(r.multiple=!0),r.accept=n,r.onchange=()=>{const i=r.files;if(i){const s=t!=null&&t.multiple?Array.from(i):i[0];e(s)}r.remove()},r.onerror=i=>{o(i),r.remove()},r.click()})}function Pl(n){return Array.isArray(n)?n.every(t=>t instanceof File):!1}function Iu(n){const t=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function $l(n,t){const e=document.createElement("a");e.setAttribute("download",`${t||""}`),e.setAttribute("href",`${n}`),e.click(),e.remove()}const Qm=w("auto-scroll");function Ym(n,t){return!(n.scrollHeight===n.clientHeight||t==="top"&&n.scrollTop===0||t==="bottom"&&n.scrollTop+n.clientHeight===n.scrollHeight||t==="left"&&n.scrollLeft===0||t==="right"&&n.scrollLeft+n.clientWidth===n.scrollWidth)}function Jm(n,{direction:t,step:e}){let o=null;const r=t==="left"||t==="right",i=()=>{if(!Ym(n,t))return Qm.debug("No need for scroll"),null;if(r){const s=n.scrollLeft,l=t==="left"?s-e:s+e;n.scrollLeft=l}else{const s=n.scrollTop,l=t==="top"?s-e:s+e;n.scrollTop=l}return o=requestAnimationFrame(i),o};return o=requestAnimationFrame(i),()=>{o&&cancelAnimationFrame(o)}}class Km{constructor(t){h(this,"cancelScroll",null);h(this,"options");h(this,"scrollDomInfo");h(this,"scrolling",!1);h(this,"getScrollingDirection",t=>{const{x:e,y:o}=t,{top:r,bottom:i,left:s,right:l}=this.scrollDomInfo,{edge:c}=this.options;return c.top&&o>=r&&o<=c.top+r?"top":c.bottom&&o<=i&&o>=i-c.bottom?"bottom":c.left&&e>=s&&e<=s+c.left?"left":c.right&&e<=l&&e>=l-c.right?"right":null});h(this,"handleMouseMove",t=>{var s;const{scrollElement:e,step:o=10,onDirectionChange:r}=this.options,i=this.getScrollingDirection(t);if(i){if(this.scrolling)return;Qm.debug(`scroll direction: ${i}`),this.cancelScroll=Jm(e,{direction:i,step:o}),r==null||r(i),this.scrolling=!0}else(s=this.cancelScroll)==null||s.call(this),this.scrolling=!1});this.options=t,this.scrollDomInfo=this.getScrollDomInfo()}getScrollDomInfo(){const{scrollElement:t}=this.options,e=t.clientTop,o=t.clientLeft,r=t.clientHeight,i=t.clientWidth;return{left:o,top:e,right:i,bottom:r}}active(){const{trackMouseEvent:t="mousemove"}=this.options;window.addEventListener(t,this.handleMouseMove,!0)}inactive(){var e;const{trackMouseEvent:t="mousemove"}=this.options;window.removeEventListener(t,this.handleMouseMove,!0),(e=this.cancelScroll)==null||e.call(this),this.scrolling=!1}}function Xm(n,t){if(n===0)return"0 Bytes";const e=1024,o=t||2,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**i).toFixed(o))} ${r[i]}`}function xu(n,t){let e=`${n}`;const o=t-e.length;for(let r=0;r<o;r++)e=`0${e}`;return e}const{t:Yo}=T;function Tu(n,t){const e=new Date(n).getTime()+864e5*t;return new Date(e)}function G8(n,t){const e=n,o=Math.floor(t/12),r=t-o*12;return o&&e.setFullYear(e.getFullYear()+o),r&&e.setMonth(e.getMonth()+r),e}function Z8(n,t){return Tu(n,t)}function Su(n,t){const e=new Date(n),o=new Date(t);return e.getDate()===o.getDate()&&e.getMonth()===o.getMonth()&&e.getFullYear()===o.getFullYear()}function tg(n){const t=new Date,e=new Date(n);return Su(t,e)}function eg(n){const t=Tu(new Date,-1);return Su(t,n)}function Q8(n,t){return Math.round((n.getTime()-t.getTime())/864e5)}function ng(n,t){const e=new Date(n);if(t){const o=e.getFullYear(),r=e.getMonth()+1,i=e.getDate();let s=t;return s=s.replace("yyyy",`${o}`),s=s.replace("mm",xu(r,2)),s=s.replace("dd",xu(i,2)),s=s.replace("m",`${r}`),s=s.replace("d",`${i}`),s}return n.toLocaleDateString()}function Du(n,t){const e=new Date(n),o=new Date;if(e.getTime()-o.getTime()>10*1e3)return T.t("date.dateFromFuture");if(tg(e)){const i=(o.getTime()-n.getTime())/1e3;if(i<10*60)return Yo("date.dateJustNow");if(i<60*60)return Yo("date.dateMinutesAgo",{num:`${Math.floor(i/60)}`});const s=Math.floor(i/60/60);return s===1?Yo("date.date1HourAgo"):Yo("date.dateHoursAgo",{num:`${s}`})}if(eg(n))return Yo("date.dateYesterday");const r=Math.floor((o.getTime()-n.getTime())/1e3/24/60/60)+1;return r<14?Yo("date.dateDaysAgo",{num:`${r}`}):r<28?Yo("date.dateWeeksAgo",{num:`${Math.round(r/7)}`}):ng(n,t)}function Lu(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Y8(n,t,e){return n.replace(new RegExp(Lu(t),"g"),e)}function J8(n,t,e){return n.replace(new RegExp(Lu(t),"gi"),e)}const og=w("container-children");function Mt(n){const t=Array.from(n.querySelectorAll(":scope > .container-blocks > div[data-type=editor-block]"));return u(og,t.length>0,"container have not any child block"),t}function Ft(n){const t=n.querySelector(":scope > .container-blocks > div[data-type=editor-block]");return u(og,t,"container have not any child block"),t}function Jt(n){const t=Mt(n);return t[t.length-1]}function Ze(n){return Mt(n).length}function Sr(n,t){return Mt(n)[t]}const Qe=w("block-dom");function Jo(n){return n instanceof HTMLDivElement?n.getAttribute("data-type")==="editor-block":!1}function rg(n){M(n,"block-hidden")}function ig(n){H(n,"block-hidden")}function _l(n){return!rt(n,"block-hidden")}function j(n){const{id:t}=n;return u(Qe,t,"no block id"),t}function it(n){const t=n.getAttribute("data-block-type");return u(Qe,t,"invalid block dom, no data-type"),t}function U(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]");return e||null}function Fl(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]:not(:scope)");return e||null}function z(n){const t=n.closest("div[data-type=editor-container]");return u(Qe,t,"failed to get block container"),t}function st(n){const t=n.querySelector(":scope >div[data-type=block-content]");return u(Qe,t,"no block content"),t}function Rt(n){let t=n.querySelector(":scope >div[data-type=block-tools]");return t||(t=b("div",[],n),t.setAttribute("data-type","block-tools")),u(Qe,t,"no block tools"),t}function Hl(n){const t=n.querySelector(":scope >div[data-type=block-tools]");return t||null}function sg(n){let t=n.querySelector(":scope > div[data-type=block-background]");return t||(t=b("div",[],n),t.setAttribute("data-type","block-background")),t}function lg(n,t,e){const o=n.editorDecorators.decorateBlock(t,e),{id:r,type:i}=o;u(Qe,r,"no block id");const s=b("div",[`${i}-block`],null);s.id=r,s.setAttribute("data-type","editor-block"),s.setAttribute("data-block-type",i);const l=n.editorBlockRenders.renderBlock(n,t,e);return l.classes&&M(s,...l.classes),l.attributes&&Object.entries(l.attributes).forEach(([c,a])=>{s.setAttribute(c,a)}),l.styles&&Object.entries(l.styles).forEach(([c,a])=>{s.style.setProperty(c,a)}),s}function lo(n,t){const e=b(t,[],null);return e.setAttribute("data-type","block-content"),n&&n.appendChild(e),e}function cg(n){const t=b("span",[`${n.type}-box`],null);return t.setAttribute("data-type","editor-box"),t.setAttribute("data-box-type",n.type),t.id=n.id,t}function ji(n){const t=n.getAttribute("data-box-type");return u(Qe,t,"not a valid box element, no type"),t}function Mu(n){return n instanceof HTMLSpanElement?n.getAttribute("data-type")==="editor-box":!1}function ag(n){const{id:t}=n;return u(Qe,t,"no box id"),t}function Ru(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("span[data-type=editor-box]");return e||null}function ug(n){n.innerHTML="",b("span",["box-space-start"],n,$i);const t=b("span",[],n);return t.setAttribute("data-type","box-content"),b("span",["box-space-start"],n,$i),t}function Ou(n){const t=n.querySelector("span[data-type=box-content]");return u(Qe,t,"invalid box dom, no content"),t}function dg(n,t){const e=b("span",[`${n}-insertion`],null);return e.setAttribute("data-type","editor-insertion"),e.setAttribute("data-insertion-id",t),e}function hg(n,t){return n.rootContainer.querySelector(`[data-insertion-id=${t}]`)}function fg(n){n.innerHTML="",b("span",["insertion-space-start"],n,$i);const t=b("span",[],n);return t.setAttribute("data-type","insertion-content"),b("span",["insertion-space-start"],n,$i),t}function Nu(n){const t=n.querySelector("span[data-type=insertion-content]");return u(Qe,t,"invalid insertion-child dom, no content"),t}function bt(n){let t=n.previousElementSibling;for(;t;){if(Jo(t))return t;t=t.nextElementSibling}return null}function dt(n){let t=n.nextElementSibling;for(;t;){if(Jo(t))return t;t=t.nextElementSibling}return null}function Dr(n){let t=n.previousElementSibling;for(;t;){if(Jo(t)&&_l(t))return t;t=t.previousElementSibling}return null}function Lr(n){let t=n.nextElementSibling;for(;t;){if(Jo(t)&&_l(t))return t;t=t.nextElementSibling}return null}function K(n){const t=z(n),o=Mt(t).indexOf(n);return u(Qe,o!==-1,"invalid block & container dom, failed to get block index"),o}function Pu(n){return!n||!(n instanceof Node)?!1:!!U(n)}function zi(n){if(!Pu(n))return!1;const t=n,e=t instanceof Element?t:t.parentElement;return e?!!e.closest("div[data-type=block-tools]"):!1}const mg=w("block-class");function pt(n,t){return n.editorBlocks.getBlockClass(it(t))}function gg(n,t){const e=n.editorBlocks.getBlockClass(it(t));return u(mg,e.blockKind==="text",`is not a text block, ${e.blockType}`),e}function xe(n,t){const e=n.editorBlocks.getBlockClass(it(t));return u(mg,e.blockKind==="complex",`is not a text block, ${e.blockType}`),e}function Mr(n,t){return n.editorBlocks.getBlockClass(t)}function Ye(n,t,e){return pt(n,t).getCaretRect(t,e)}function _(n,t){return pt(n,t).blockKind==="text"}function Ui(n,t){return n.editorBlocks.getBlockClass(t).blockKind==="text"}function at(n,t){return pt(n,t).blockKind==="complex"}function K8(n,t){return!at(n,t)}function Je(n,t){return pt(n,t).blockKind}const pg=w("container");function vn(n){return n.getAttribute("data-type")==="editor-container"}function Ct(n){return rt(n,"root")}function Ke(n){return rt(n,"child")}function V(n){const t=n.getAttribute("data-container-id");return u(pg,t,"no id for container"),Ct(n)&&u(pg,t==="root",`invalid root container id, : ${t}`),t}function Cg(n,t){const e=V(n);return t.getContainerBlocks(e)}const $u=w("block");function G(n,t){return pt(n,t).getBlockTextLength(t)}function Ag(n){n.editorBlocks.forEach(t=>{t.clearSelection(n)})}function bg(n,t,e,o){pt(n,t).updateSelection(n,t,e,o)}function _u(n){for(;;){const t=z(n);if(Ct(t))return n;const e=U(t);u($u,e,"no parent block exists for child container"),n=e}}function vg(n,t){const e=pt(n,t);if(!!e.getMinWidth)return e.getMinWidth(n,t)}function yg(n,t,e){const o=pt(n,t);o.handleBlockElementUpdated&&o.handleBlockElementUpdated(n,t,e)}function jl(n,t,e,o){try{const r=Mr(n,e).convertFrom;return r?r(n,t,o):null}catch{return $u.debug(`unsupported block type: ${e}`),null}}function co(n,t,e){const o=pt(n,t);return o.getClientRects?o.getClientRects(n,t,e):[t.getBoundingClientRect()]}function X8(n,t){const e=pt(n,t);if(e.getBlockStyles)return e.getBlockStyles(n,t);const o=n.getBlockData(t),r=Object.fromEntries(Object.entries(o).filter(([i])=>i.startsWith("style-")));return Object.entries(r).forEach(([,i])=>{const s=typeof i;u($u,s==="string"||s==="number"||s==="boolean","invalid style value")}),r}function Tt(n,t){return Je(n,t)==="text"?G(n,t)===0:!1}const kg=w("block-path");function ao(n){const t=[];let e=n;for(;e;){const o=z(e);if(t.unshift({containerId:V(o),blockIndex:K(e)}),Ct(o))return t;const r=U(o);u(kg,r,"no parent block"),e=r}return u(kg,!1,"no parent block"),[]}function tA(n,t){var r,i;const e=pt(n,t);return(i=(r=e.getOptions)==null?void 0:r.call(e,n))!=null?i:{name:it(t)}}function wg(n,t){var r;const e=pt(n,t);return(r=e.getBlockProperties)==null?void 0:r.call(e,n,t)}function Fu(n,t){var i,s;const e=pt(n,t),o=(i=e.getBlockProperties)==null?void 0:i.call(e,n,t);let r={};o!=null&&o.blockCommands&&(r={...o.blockCommands});for(const l of n.blockHooks){const c=(s=l.commands)==null?void 0:s.call(l,n,t);c&&(r[c.group]=c)}return r}function Bg(n,t,e){var s,l,c,a;const o=pt(n,t),r=(s=o.getBlockProperties)==null?void 0:s.call(o,n,t);let i={};r!=null&&r.blockCommands&&(i={...r.blockCommands});for(const d of n.blockHooks){const f=(l=d.commands)==null?void 0:l.call(d,n,t);f&&(i[f.group]=f)}return(a=(c=i[e])==null?void 0:c.commands)!=null?a:[]}const Eg=w("embed-block-common");function Te(n){return it(n)==="embed"}function Ne(n){u(Eg,Te(n),"not an embed block");const t=n.getAttribute("data-embed-type");return u(Eg,t,"no embed data type"),t}function eA(n,t){return n.editorEmbeds.getEmbedClass(Ne(t))}function Ko(n,t){return n.editorEmbeds.getEmbedClass(t)}async function Hu(n,t,e,o,r){const i=Ko(n,t);if(!i.getOptions)return null;const s=i.getOptions(n);if(!s.insertEmbedCommandItems||!s.insertEmbedCommandItems||s.insertEmbedCommandItems.length===0||!s.handleInsertEmptyEmbed)return null;const l=s.insertEmbedCommandItems[0];return s.handleInsertEmptyEmbed(n,{item:l,containerId:e,blockIndex:o,data:r})}function nA(n,t,e,o,r){var l,c;const i=(c=(l=Mr(n,t)).getOptions)==null?void 0:c.call(l,n);if(!i||!i.insertBlockCommandItems||i.insertBlockCommandItems.length===0||!i.handleInsertEmptyBlock)return null;const s=i.insertBlockCommandItems[0];return i.handleInsertEmptyBlock(n,{item:s,containerId:e,blockIndex:o,data:r})}const oA=w("execute-block-command");function Ig(n,t,e,o){var a;u(oA,Te(t),"not a embed block");const r=Ne(t),i=Ko(n,r);if(!i.getOptions)return;const s=(a=i.getBlockProperties)==null?void 0:a.call(i,n,t),l=s==null?void 0:s.blockCommands;if(!l)return;const c=Object.entries(l);for(const d of c)if(d[0]===e)return d[1].executeCommand(n,t,o)}function xg(n,t,e,o){const r=Fu(n,t);if(!r)return;const i=Object.entries(r);for(const s of i)if(s[0]===e)return s[1].executeCommand(n,t,o)}const rA=w("complex-block-position");class Xe{constructor(t,e,o){h(this,"blockId");h(this,"childContainerId");h(this,"custom");t instanceof HTMLElement?this.blockId=j(t):(u(rA,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.childContainerId=e,o!==void 0&&(this.custom=o)}isSimple(){return!1}}const iA=w("simple-block-position");class qt{constructor(t,e,o){h(this,"blockId");h(this,"offset");h(this,"type");t instanceof HTMLElement?this.blockId=j(t):(u(iA,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.offset=e,this.type=o}isSimple(){return!0}}const ju=w("editor-position");function F(n,t,e){return new qt(n,t,e)}function Bt(n,t,e){return new Xe(n,t,e)}function uo(n){return n instanceof qt}function zu(n){return n instanceof Xe}function Uu(n,t,e){if(uo(t)&&uo(e)){const o=t,r=e;if(o.blockId===r.blockId)return o.offset-r.offset;const i=n.getBlockById(t.blockId),s=n.getBlockById(e.blockId);return u(ju,i!==s,"comparePosition: blocks are the same"),Dl(i,s)}if(zu(t)&&zu(e)){const o=t,r=e;if(o.childContainerId===r.childContainerId)return 0;const i=n.getContainerById(o.childContainerId),s=n.getContainerById(r.childContainerId);return u(ju,i!==s,"comparePosition: containers are the same"),Dl(i,s)}return u(ju,!1,"invalid "),0}const zl=w("simple-range");class Kt{constructor(t,e){h(this,"editor");h(this,"_anchor");h(this,"_focus");h(this,"reverse");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=Uu(this.editor,this._anchor,this._focus)>0}isCollapsed(){return this.start.blockId===this.end.blockId&&this.start.offset===this.end.offset}isEqual(t){if(!(t instanceof Kt))return!1;const e=t,{start:o,end:r}=e;return this.start.blockId===o.blockId&&this.start.offset===o.offset&&this.start.type===o.type&&this.end.blockId===r.blockId&&this.end.offset===r.offset&&this.end.type===r.type}isSimple(){return!0}isReverse(){return this.reverse}getEditor(){return this.editor}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}get anchor(){return this._anchor}get focus(){return this._focus}getSelectedBlocks(){const{editor:t}=this,e=t.getBlockById(this.start.blockId),o=t.getBlockById(this.end.blockId);u(zl,e,"no start block"),u(zl,o,"no end block");const r=z(e),i=z(o);u(zl,r===i,"invalid range");const s=[];if(e===o)s.push({block:e,start:this.start,end:this.end});else{const l=K(e),c=K(o);u(zl,l<c,"invalid range, start > index"),s.push({block:e,start:this.start,end:F(e,G(this.editor,e),"end")});const a=Mt(r);for(let d=l+1;d<c;d+=1){const f=a[d];s.push({block:f,start:F(f,0,"home"),end:F(f,G(this.editor,f),"end")})}s.push({block:o,start:F(o,0,"home"),end:this.end})}return s}getSelectedContainers(){return[]}getAnchorPos(){return this.isReverse()?this.end:this.start}getFocusedPos(){return this.isReverse()?this.start:this.end}clone(){return new Kt(this.editor,this)}toDocRange(){return{anchor:this.anchor,focus:this.focus}}static from(t,e){return new Kt(t,e)}}w("unknown-block");function sA(n,t,e,o,r){M(o,"unknown-block");const i=lo(o,"div");return i.innerText=`unknown block (${r.type}): ${JSON.stringify(r)}`,i}function lA(n){return 1}function cA(n,t,e,o){return null}function aA(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=j(t),s=F(i,0,"home"),l=F(i,1,"end");return new Kt(n,{anchor:s,focus:l})}function uA(n,t){const o=st(n).getBoundingClientRect();return new DOMRect(o.left+o.width/2,o.top,1,o.height)}function dA(n,t,e,o){M(t,"selected")}function hA(n){n.rootContainer.querySelectorAll("div.unknown-block[data-type=editor-block]").forEach(t=>{H(t,"selected")})}function fA(n,t,e,o){return`[unknown block, ${t.type}]`}const mA={blockType:"unknown-block",blockKind:"embed",createBlockContent:sA,getBlockTextLength:lA,getRangeFromPoint:aA,moveCaret:cA,getCaretRect:uA,updateSelection:dA,clearSelection:hA,convertTo:fA},Vu=w("editor-blocks");class Tg{constructor(t){h(this,"blocks",new Map);this.editor=t}registerBlockClass(t){const e=t.blockType,o=this.blocks.get(e);u(Vu,!o,`duplicated block type: ${e}`),this.blocks.set(e,t)}getBlockClass(t){const e=this.blocks.get(t);return u(Vu,e,`unknown block type: ${t}`),e}hasBlock(t){return this.blocks.has(t)}createBlock(t,e,o){const r=lg(this.editor,t,o);let i;this.hasBlock(o.type)?i=this.getBlockClass(o.type):i=this.registerUnknownBlock(o.type);const s=i.createBlockContent(this.editor,t,e,r,o);return s.parentElement!==r&&(Vu.warn("content parent is not block"),r.appendChild(s)),this.editor.blockHooks.forEach(l=>{var c;(c=l.create)==null||c.call(l,this.editor,t,e,r,o)}),r}forEach(t){this.blocks.forEach(t)}registerUnknownBlock(t){const e={...mA,blockType:t};return this.editor.editorBlocks.registerBlockClass(e),e}}const Sg=w("editor-embeds");class Dg{constructor(t){h(this,"objects",new Map);this.editor=t}registerEmbedClass(t){const e=t.embedType,o=this.objects.get(e);u(Sg,!o,`duplicated embed object type: ${e}`),this.objects.set(e,t)}getEmbedClass(t){const e=this.objects.get(t);return u(Sg,e,`unknown embed type: ${t}`),e}getEmbedClassFromBlock(t){return this.getEmbedClass(Ne(t))}forEach(t){this.objects.forEach(t)}}const Lg=w("embed-block");function gA(n,t,e,o,r){const i=lo(o,"div");u(Lg,r.type==="embed",`not an embed data: ${JSON.stringify(r)}`);const s=r;return u(Lg,s.embedType&&s.embedData,`not an embed data: ${JSON.stringify(s)}`),n.editorEmbeds.getEmbedClass(s.embedType).createEmbedContent(n,i,s,t,e,o),o.setAttribute("data-embed-type",s.embedType),i}function pA(n){return 1}function CA(n,t,e,o){return null}function AA(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=j(t),s=F(i,0,"home"),l=F(i,1,"end");return new Kt(n,{anchor:s,focus:l})}function bA(n,t){const o=st(n).getBoundingClientRect();return new DOMRect(o.left+o.width/2,o.top,1,o.height)}function vA(n,t,e,o){M(t,"selected")}function yA(n){n.rootContainer.querySelectorAll("div.embed-block[data-type=editor-block][data-block-type=embed]").forEach(t=>{H(t,"selected")})}function kA(n,t,e){let o=null;return n.editorEmbeds.forEach(r=>{var s,l;const i=(l=(s=r.convertFrom)==null?void 0:s.call(r,n,t,e))!=null?l:null;i&&(o=i)}),o}function wA(n,t,e,o){const r=Ko(n,t.embedType);return r.convertTo?r.convertTo(n,t,e,o):""}function BA(n,t){const e=eA(n,t);return e.getBlockProperties?e.getBlockProperties(n,t):{}}function EA(n){const t=new Map,e=[];return n.editorEmbeds.forEach(o=>{if(o.getOptions){const r=o.getOptions(n);r.insertEmbedCommandItems&&r.insertEmbedCommandItems.forEach(i=>{e.push(i),t.set(i.id,o)})}}),{name:"EmbedBlock",insertBlockCommandItems:e,async handleInsertEmptyBlock(o,r){const i=t.get(r.item.id);if(!i||!i.getOptions)return null;const s=i.getOptions(o);return s.handleInsertEmptyEmbed?s.handleInsertEmptyEmbed(o,r):null}}}function IA(n,t,e,o){const r=Ne(t),i=Ko(n,r);!i.handleDeleteBlock||i.handleDeleteBlock(n,t,e,o)}function xA(n,t,e){const o=Ne(t),r=Ko(n,o);return r.handleUpdateBlock?r.handleUpdateBlock(n,t,e):!1}function TA(n,t,e,o,r){const i=Ne(t),s=Ko(n,i);if(s.handleDropOver)return s.handleDropOver(n,t,e,o,r)}function SA(n,t,e,o,r){const i=Ne(t),s=Ko(n,i);if(s.handleDrop&&n.isWritable())return s.handleDrop(n,t,e,o,r)}async function DA(n,t,e){const o=t.embedType,r=n.editorEmbeds.getEmbedClass(o);if(r.toStandardDoc){const i=n.getBlockById(t.id),s=ao(i);return r.toStandardDoc(n,t,e,s)}}const Mg={blockType:"embed",blockKind:"embed",createBlockContent:gA,getBlockTextLength:pA,getRangeFromPoint:AA,moveCaret:CA,getCaretRect:bA,updateSelection:vA,clearSelection:yA,convertFrom:kA,convertTo:wA,getBlockProperties:BA,getOptions:EA,handleDeleteBlock:IA,handleUpdateBlock:xA,handleDropOver:TA,handleDrop:SA,toStandardDoc:DA},fe=w("complex-block-helper");function Se(n,t){return xe(n,t).getChildContainers(n,t)}function Rr(n,t,e,o){return e.isSimple()?(u(fe,o.isSimple(),"invalid start and end position"),Se(n,t)):(u(fe,!e.isSimple(),"invalid start pos"),u(fe,!o.isSimple(),"invalid end pos"),xe(n,t).getSelectedContainers(n,t,e,o))}function LA(n,t){if(K(t)!==0)return!1;const e=U(z(t));if(!e)return!1;u(fe,at(n,e),"not a complex block");const o=z(t),i=Se(n,e).indexOf(o);return u(fe,i>=0,"not valid child container"),i===0}function qu(n,t){const e=Se(n,t);if(e.length===0)return null;const o=e[0],r=Ft(o);return at(n,r)?qu(n,r):r}function Vi(n,t){const e=Se(n,t);if(e.length===0)return null;const o=e[e.length-1],r=Jt(o);return at(n,r)?Vi(n,r):r}function Rg(n,t){u(fe,Ke(t),"not a child container");const e=U(t);u(fe,e,"no parent block"),u(fe,at(n,e),"not a complex block");const o=Se(n,e),r=o.indexOf(t);if(u(fe,r!==-1,"child container not found"),r===0){const l=bt(e);return l?at(n,l)?Vi(n,l):l:null}const i=o[r-1],s=Jt(i);return at(n,s)?Vi(n,s):s}function Og(n,t){u(fe,at(n,t),"not a complex block");const e=Se(n,t);if(u(fe,e.length>0,"no child container"),e.length===1)return e;const o=e[0],r=o.getBoundingClientRect();let i=r.left,s=r.right;const l=[o];for(let c=1;c<e.length;c++){const a=e[c],d=a.getBoundingClientRect();if(d.right<=i){l.push(a),i=d.left;continue}if(d.left>=s){s=d.right;continue}}return l}function Ng(n,t){u(fe,at(n,t),"not a complex block");const e=Se(n,t);if(u(fe,e.length>0,"no child container"),e.length===1)return e;const o=e[e.length-1],r=o.getBoundingClientRect();let i=r.left,s=r.right;const l=[o];for(let c=e.length-2;c>=0;c--){const a=e[c],d=a.getBoundingClientRect();if(d.right<=i){l.push(a),i=d.left;continue}if(d.left>=s){s=d.right;continue}}return l}function Pg(n,t,e,o){const r=t.getBoundingClientRect(),i=o<r.top,s=i?Og(n,t):Ng(n,t);let l=s[0],c=An(l.getBoundingClientRect(),e,o);for(let a=1;a<s.length;a++){const d=s[a],f=d.getBoundingClientRect(),m=An(f,e,o);m<c&&(l=d,c=m)}return i?Ft(l):Jt(l)}function Ul(n,t,e,o){const r=j(t);u(fe,r===e.blockId,"invalid start pos"),u(fe,r===o.blockId,"invalid end pos");const i=xe(n,t);return i.adjustSelectionPos?i.adjustSelectionPos(n,t,e,o):{anchor:e,focus:o}}class tn{constructor(t,e){h(this,"editor");h(this,"reverse");h(this,"_anchor");h(this,"_focus");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=Uu(this.editor,this._anchor,this._focus)>0}isCollapsed(){return!1}isEqual(t){if(!(t instanceof tn))return!1;const e=t,{anchor:o,focus:r}=e;return this._anchor.blockId===o.blockId&&this._anchor.childContainerId===o.childContainerId&&this._focus.blockId===r.blockId&&this._focus.childContainerId===r.childContainerId&&this._anchor.custom===o.custom&&this._focus.custom===r.custom}isReverse(){return this.reverse}isSimple(){return!1}getEditor(){return this.editor}get anchor(){return this._anchor}get focus(){return this._focus}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}getSelectedBlocks(){const t=this.start,e=this.end;return[{block:this.editor.getBlockById(t.blockId),start:t,end:e}]}getAnchorPos(){return this._anchor}getFocusedPos(){return this._focus}getSelectedContainers(){const t=this.editor.getBlockById(this._anchor.blockId);return Rr(this.editor,t,this.start,this.end)}clone(){return new tn(this.editor,this)}toDocRange(){return{anchor:this._anchor,focus:this._focus}}}const MA=w("selection-range");function Wt(n,t){const{anchor:e,focus:o}=t;return e instanceof qt&&o instanceof qt?new Kt(n,{anchor:e,focus:o}):(u(MA,e instanceof Xe&&o instanceof Xe,"start position type does not math end type"),new tn(n,{anchor:e,focus:o}))}function Ot(n,t,e,o){const r=new qt(t,e,"normal"),i=new qt(t,o!=null?o:e,"normal");return Wt(n,{anchor:r,focus:i})}function RA(n){return!!n.anchor.childContainerId}function ho(n,t){var r,i;if(RA(t)){const s=Bt(t.anchor.blockId,t.anchor.childContainerId,(r=t.anchor)==null?void 0:r.custom),l=Bt(t.focus.blockId,t.focus.childContainerId,(i=t.focus)==null?void 0:i.custom);return Wt(n,{anchor:s,focus:l})}const e=F(t.anchor.blockId,t.anchor.offset,"normal"),o=F(t.focus.blockId,t.focus.offset,"normal");return Wt(n,{anchor:e,focus:o})}const $g=w("range-from-point");function Vl(n,t,e){const o=[0,-8,8];for(let r=0;r<o.length;r++){const i=document.elementsFromPoint(t,e+o[r])[0];if(!i)continue;const s=i.getBoundingClientRect();if(i.clientWidth&&i.clientHeight&&r===0&&(s.left+i.clientWidth<t||s.top+i.clientHeight<e))return $g.debug("click on scrollbar, out of element rect"),null;if(!n.rootContainer.contains(i))continue;const l=U(i);if(!l||!n.contains(l))continue;const c=pt(n,l).getRangeFromPoint(n,l,t,e+o[r]);if(c)return c}return null}function _g(n,t,e,o){const r=t.getBoundingClientRect();if(o<=r.top){const c=Ft(t),a=pt(n,c).getRangeFromPoint(n,c,e,c.getBoundingClientRect().top+4);if(a!=null&&a.isSimple())return Kt.from(n,a);const d=F(c,0,"home");return new Kt(n,{anchor:d,focus:d})}const i=Jt(t),s=pt(n,i).getRangeFromPoint(n,i,e,i.getBoundingClientRect().bottom-4);if(s!=null&&s.isSimple())return Kt.from(n,s);const l=F(i,G(n,i),"end");return new Kt(n,{anchor:l,focus:l})}function Fg(n,t,e){const o=Vl(n,t,e);if(o){if(o instanceof Kt)return o;u($g,o instanceof tn,`invalid range type: ${typeof o}`);const c=o,a=n.getContainerById(c.start.childContainerId);return _g(n,a,t,e)}const r=document.elementsFromPoint(t,e)[0];if(!r)return null;const{children:i}=r,s=Array.from(i).filter(c=>vn(c));if(s.length===0)return null;const l=s.reduce((c,a)=>{const d=c.getBoundingClientRect(),f=a.getBoundingClientRect();return An(d,t,e)>An(f,t,e)?a:c});return _g(n,l,t,e)}function Wu(n,t){const e=[];return Mt(t).forEach(r=>{e.push(r),at(n,r)&&Se(n,r).forEach(s=>{e.push(...Wu(n,s))})}),e}function Gu(n,t){let e=Wu(n,n.rootContainer);return t!=null&&t.simpleBlockOnly&&(e=e.filter(o=>!at(n,o))),e}function en(n,t){const e=n.selection.range.getSelectedBlocks(),o=[];for(const r of e)o.push(r),at(n,r.block)&&Rr(n,r.block,r.start,r.end).forEach(s=>{const c=Wu(n,s).map(a=>({block:a,start:F(a,0,"home"),end:F(a,G(n,a),"home")}));o.push(...c)});return t!=null&&t.simpleBlockOnly?o.filter(r=>!at(n,r.block)):o}const YU="",zn=w("text-block-child");function qi(n){return n.tagName==="SPAN"}function Pe(n){return u(zn,qi(n),"not a valid text child"),n.getAttribute("data-type")==="editor-box"}function Un(n){return u(zn,qi(n),"not a valid text child"),n.getAttribute("data-type")==="editor-insertion"}function Wi(n){return!Pe(n)&&!Un(n)}function Hg(n){return u(zn,qi(n),"not a valid text child"),Pe(n)?"box":Un(n)?"insertion":"text"}function $e(n){const t=Hg(n);return t==="insertion"?0:t==="box"?1:(u(zn,n.textContent!==null,"text block content is undefined"),u(zn,n.textContent.length>=0,"text block content length is negative"),n.textContent.length)}function yn(n){const t=st(n),e=Array.from(t.children);return e.forEach(o=>{u(zn,qi(o),"not a valid text child")}),e}function ql(n,t){const e=yn(n);let o=0;for(let r=0;r<e.length;r++){const i=e[r],s=$e(i);if(o+s<t){o+=s;continue}if(o===t)return{prev:e[r-1],next:i,offset:0};if(o+s===t)return{prev:i,next:e[r+1],offset:0};const l=t-o;return u(zn,l>0,"invalid offset value"),u(zn,!Pe(i),"invalid box child"),{prev:i,next:i,offset:l}}u(zn,!1,`invalid block child at position: ${t}`)}const Xt=w("text-range");function OA(n,t){const e=(i,s)=>{if(Un(i))return u(Xt,s===0,`invalid offset for insertion child: ${s}`),{child:i,container:i,offset:2};if(Pe(i))return u(Xt,s===0||s===1,`invalid offset for box: ${s}`),{child:i,container:i,offset:s===0?1:2};const l=i.firstChild;return u(Xt,l,"no child node for text child"),u(Xt,l instanceof Text||l instanceof HTMLBRElement,`invalid child for text child, ${l.nodeName}`),l instanceof HTMLBRElement?(u(Xt,s>=0&&s<=0,"invalid offset for text child"),{child:i,container:l,offset:s}):(u(Xt,s>=0&&s<=l.data.length,"invalid offset for text child"),{child:i,container:l,offset:s})};let o=0;const r=yn(n);for(let i=0;i<r.length;i++){const s=r[i],l=$e(s);if(t===o)return[e(s,0)];if(t<o+l)return[e(s,t-o)];if(t===o+l){const c=[];c.push(e(s,$e(s)));const a=r[i+1];return a&&c.push(e(a,0)),c}o+=l}u(Xt,!1,"failed to get range info")}function NA(n,t,e){if(t===e?u(Xt,Un(n),"only insertion child can be zero offset"):u(Xt,t<e,`invalid start & end: ${t}, ${e}`),Un(n)){u(Xt,t===e,`invalid insertion child range offset: ${t}, ${e}`),u(Xt,t===0,`invalid insertion child range start: ${t}`);const i=n;return u(Xt,i.children.length===3,`invalid insertion dom, children.length = ${i.children.length}`),Tl(i,1,i,2)}if(Pe(n)){u(Xt,t+1===e,`invalid box child range offset: ${t}, ${e}`),u(Xt,t===0,`invalid box child range start: ${t}`);const i=n;return u(Xt,i.children.length===3,`invalid box dom, children.length = ${i.children.length}`),Tl(i,1,i,2)}const o=$e(n);u(Xt,e<=o,`invalid child end: ${e}, ${o}`);const r=n.firstChild;return u(Xt,r instanceof Text,"invalid block text child"),u(Xt,r.data.length>=e,`invalid range end: ${e}, ${r.data.length}`),Tl(r,t,r,e)}const nn=w("caret-rect");function PA(n,t){if(Mu(t)){const e=t,o=Ou(e);if(e.getAttribute("data-box-type")==="br"){const r=st(n),i=Number.parseFloat(window.getComputedStyle(r).lineHeight)||o.getBoundingClientRect().height,s=Array.from(o.getClientRects());u(nn,s.length>0,"no box client rects");const l=r.getBoundingClientRect(),c=s[0],a=new DOMRect(l.left,c.bottom,1,i);return s.push(a),s}return o.getClientRects()}return Nu(t).getClientRects()}function De(n,t){var l,c;const e=OA(n,t.offset);if(e[1]&&e[0].child!==((l=e[1])==null?void 0:l.child)){if(t.type==="end"){const d=Vo(e[0].child);return new DOMRect(d.right,d.top,1,d.height)}u(nn,e[1],"invalid ranges");const a=Sl(e[1].child);return new DOMRect(a.left,a.top,1,a.height)}let r=e[0];if(u(nn,e.length>=1,"failed to get block range"),e.length===1)r=e[0];else{if(u(nn,e.length>=2,`invalid range info length: ${e.length}`),Un(e[e.length-1].child)){r=e[e.length-1];const a=r.child,f=Nu(a).getClientRects();u(nn,f.length>=1,"no client rects for box content");const m=f[f.length-1];return new DOMRect(m.right,m.y,1,m.height)}t.type==="home"?r=e[1]:t.type==="end"||Wi(e[0].child)?r=e[0]:Wi(e[1].child)&&(r=e[1])}if(r.container instanceof HTMLBRElement){u(nn,t.offset===0,"invalid offset for empty block text");const a=(c=r.container.parentElement)==null?void 0:c.parentElement;u(nn,a===st(n),"invalid br parent, is not block parent");const d=a.getBoundingClientRect();return new DOMRect(d.left,d.top,1,d.height)}const s=km(r.container,r.offset).getClientRects();if(s.length===0){u(nn,!Wi(r.child),"only box or insertion child range has zero client rect"),u(nn,r.offset===1||r.offset===2,"invalid offset for box or insertion child");const a=r.child,d=PA(n,a);if(u(nn,d.length>=1,"no client rects for box content"),r.offset===1){const m=d[0];return new DOMRect(m.x,m.y,1,m.height)}const f=d[d.length-1];return t.type==="end"||r.offset===2?new DOMRect(f.right,f.y,1,f.height):new DOMRect(f.x,f.y,1,f.height)}return u(nn,s.length>0,"no client rects for range"),t.type==="home"?s[s.length-1]:s[0]}const $A=w("core");function fo(n,t,e,o){const r=Rt(t);let i=r.querySelector(`.block-anchor[data-id=${e}]`);i||(i=b("div",["block-anchor"],r),i.setAttribute("data-id",e));const s=o!=null?o:t.getBoundingClientRect(),l=t.getBoundingClientRect(),c=new DOMRect(s.left-l.left,s.top-l.top,s.width,s.height);return i.style.left=`${c.left}px`,i.style.top=`${c.top}px`,i.style.width=`${c.width}px`,i.style.height=`${c.height}px`,i}function jg(n,t,e,o){u($A,_(n,t),"not a text kind block");const r=De(t,F(t,e,"normal")),i=t.getBoundingClientRect(),s=Rt(t);let l=s.querySelector(`.block-anchor[data-id=${o}]`);l||(l=b("div",["block-anchor"],s),l.setAttribute("data-id",o));const c=new DOMRect(r.left-i.left,r.top-i.top,r.width,r.height);return l.style.left=`${c.left}px`,l.style.top=`${c.top}px`,l.style.width=`${c.width}px`,l.style.height=`${c.height}px`,l}function Gi(n){const t=yn(n);let e=0;return t.forEach(o=>{e+=$e(o)}),e}const zg=w("box");function Zi(n){return!n.attributes||!n.attributes.box?!1:(u(zg,n.attributes.box===!0,`invalid op attribute box property, ${n.attributes.box}`),u(zg,n.attributes.type,`no box type: ${JSON.stringify(n)}`),!0)}const Ug=w("rich-text-length");function Zu(n){return u(Ug,typeof n.insert=="string","op.insert is not string"),n.insert.length}function me(n){let t=0;return n.forEach(e=>{e.insert&&(u(Ug,typeof e.insert=="string","op.insert is not string"),t+=Zu(e))}),t}const kn=w("split-text");function ve(n,t,e){if(n=Q.default(n),t===0)return{left:[],right:n};if(t===-1)return{left:n,right:[]};let o=0;for(let r=0;r<n.length;r++){const i=n[r];u(kn,typeof i=="object",`invalid op type, ${typeof i}`),u(kn,typeof i.insert=="string",`invalid op.insert type, ${typeof i.insert}`);const s=Zu(i);if(o+s<t)o+=s;else{if(o+s===t)return{left:n.slice(0,r+1),right:n.slice(r+1)};{u(kn,o+s>t,`invalid offset, ${o}, ${s}, ${t}`);const l=t-o,c=Q.default(i);u(kn,c.insert,"no copied.insert"),u(kn,typeof c.insert=="string","invalid copied.insert type"),c.insert=c.insert.substr(0,l),i.insert=i.insert.substr(l),c.insert===""&&u(kn,!1,"invalid copied.insert, is empty string"),i.insert===""&&u(kn,!1,"invalid op.insert, is empty string");const a=[i,...n.slice(r+1)],d=[...n.splice(0,r),c];return e&&(e.sourceOp=i),{left:d,right:a}}}}throw new Error(`invalid split offset: ${t}, ${JSON.stringify(n)}`)}function Gt(n,t,e){u(kn,t>=0,"invalid offset, < 0"),u(kn,e>0,"invalid length, <= 0"),u(kn,t+e<=me(n),"invalid offset + length < text length");const{left:o,right:r}=ve(n,t+e),{left:i,right:s}=ve(o,t);return{left:i,middle:s,right:r}}function Vg(n,t){const e=Array.from(new Set(t)).sort((i,s)=>i-s),o=[];let r=n;for(let i=e.length-1;i>=0;i--){const s=e[i],{left:l,right:c}=ve(r,s);r=l,o.unshift(c)}return r.length>0&&o.unshift(r),o}function qg(n,t,e){return Gt(n,t,e).middle}const Or=w("text-block-content");function _A(n,t,e,o,r){if(u(Or,o,"no text for block"),o.length===0&&(!r||r.size===0)){e.innerHTML="<span><br></span>";return}const i=[];r&&i.push(...r.keys());const s=f=>n.editorInsertions.createInsertion(e,f),l=(f,m)=>{const p=r==null?void 0:r.get(m);p&&(p.forEach(A=>{f.appendChild(s(A))}),r==null||r.delete(m))},c=document.createDocumentFragment();let a=0;const d=Vg(o,i);for(let f=0;f<d.length;f++){l(c,a);const m=d[f];a+=me(m);for(let p=0;p<m.length;p++){const A=m[p];if(Zi(A)){u(Or,A.attributes,`op is not an valid box: ${JSON.stringify(A)}`);const v=n.editorBoxes.createBox(e,A.attributes);u(Or,v instanceof HTMLSpanElement,`invalid box element: ${v.tagName}`),c.appendChild(v);continue}u(Or,A.insert,`no insert in op: ${JSON.stringify(A)}`);const k=b("span",["text"],c,A.insert);if(A.attributes){const v=n.editorBlockRenders.renderText(t,A.attributes);v.classes&&M(k,...v.classes),v.attributes&&Object.entries(v.attributes).forEach(([x,E])=>{k.setAttribute(x,E)}),v.styles&&Object.entries(v.styles).forEach(([x,E])=>{k.style.setProperty(x,E)})}c.appendChild(k)}}l(c,a),e.innerHTML="",e.appendChild(c)}function Wl(n,t,e,o,r){const{text:i,insertions:s}=n.editorDecorators.decorateText(t,r),l=n.compositingText;if(l){const c=n.selection.range.start;u(Or,c.isSimple(),"not an simple position while compositing"),c.blockId===e&&s.set(c.offset,[{type:"inputting",id:P(),text:l}])}return _A(n,t,o,i,s)}function FA(n){const t=n.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');t.length&&Or.debug(`remove ${t.length} temp composition span`),Array.from(t).forEach(e=>e.remove())}const wn=w("client-rects");function HA(n){const t=yn(n);let e=0;const o=[];for(let r=0;r<t.length;r++){const i=t[r],s=$e(i);o.push({child:i,startBlockOffset:e,endBlockOffset:e+s}),e+=s}return o}function jA(n,t,e,o){u(wn,e<o,`invalid from & to: ${e}, ${o}`);const r=G(n,t);u(wn,e>=0&&o>=0&&e<=r&&o<=r,`invalid offset: ${e}, ${o}, length: ${r}`);const i=HA(t),s=i.findIndex(p=>p.startBlockOffset<=e&&e<p.endBlockOffset),l=i.findIndex(p=>p.startBlockOffset<o&&o<=p.endBlockOffset);if(u(wn,s!==-1,"failed to find start child"),u(wn,l!==-1,"failed to find end child"),u(wn,s<=l,`invalid start index & end index: ${s}, ${l}`),s===l){const p=i[s];return[{child:p.child,startChildOffset:e-p.startBlockOffset,endChildOffset:o-p.startBlockOffset}]}const c=[],a=i[s],d={child:a.child,startChildOffset:e-a.startBlockOffset,endChildOffset:$e(a.child)};c.push(d);for(let p=s+1;p<l;p++){const A=i[p],k={child:A.child,startChildOffset:0,endChildOffset:A.endBlockOffset-A.startBlockOffset};c.push(k)}const f=i[l],m={child:f.child,startChildOffset:0,endChildOffset:o-f.startBlockOffset};return c.push(m),c}function zA(n){const t=(o,r)=>o.left<=r.left&&o.top<=r.top&&o.right>=r.right&&o.bottom>=r.bottom&&(o.width!==r.width||o.height!==r.height);n=n.filter(o=>!n.find(i=>t(o,i)));const e=[];return n=n.filter(o=>e.find(r=>r.left===o.left&&r.top===o.top&&r.width===o.width&&r.height===o.height)?!1:(e.push(o),!0)),n}function Wg(n,t,e,o){if(G(n,t)===0){const d=st(t).getBoundingClientRect();return[new DOMRect(d.left,d.top,4,d.height)]}const r=e.offset,i=o.offset;if(r===i)return[De(t,e)];const l=jA(n,t,r,i).map(a=>NA(a.child,a.startChildOffset,a.endChildOffset)),c=[];return l.forEach(a=>{const d=zA(Array.from(a.getClientRects()));c.push(...d)}),c}function UA(n,t,e){u(wn,e instanceof Kt,"invalid range");const o=e.start,r=e.end;return u(wn,o.isSimple(),"text block only allow simple position"),u(wn,r.isSimple(),"text block only allow simple position"),u(wn,o.blockId===r.blockId,"only allow update one text block selection"),u(wn,o.blockId===j(t),"only allow update one text block selection"),Wg(n,t,o,r)}const Qu=w("selection-background");function VA(n,t,e,o){u(Qu,e.isSimple(),"text block only allow simple position"),u(Qu,o.isSimple(),"text block only allow simple position"),u(Qu,e.blockId===o.blockId,"only allow update one text block selection");const r=e.offset,i=o.offset;if(r===i&&(G(n,t)!==0||n.selection.range.isCollapsed()))return;const s=Wg(n,t,e,o),l=t.getBoundingClientRect(),c=sg(t);c.innerHTML="",s.forEach(a=>{const d=b("div",["editor-selection-background"],c);d.style.left=`${a.left-l.left}px`,d.style.top=`${a.top-l.top}px`,d.style.width=`${a.width}px`,d.style.height=`${a.height}px`})}function qA(n){n.rootContainer.querySelectorAll("div[data-type=block-background]").forEach(t=>{t.remove()})}const Xo=w("text-offset"),Gg="\u200D";function mo(n,t){const e=yn(n);let o=0;for(let r=0;r<e.length;r++){const i=e[r],s=$e(i);if(i===t){const l=o+s;return{start:o,end:l}}o+=s}u(Xo,!1,"can not find child in children")}function le(n,t){u(Xo,t>=0,`invalid offset: ${t}`);const e=ql(n,t),{prev:o,next:r,offset:i}=e;if(!o&&!r&&u(Xo,!1,"invalid offset, no prev & next child at offset"),o!==r)return!0;const s=o;if(u(Xo,s,"no child"),Pe(s))return u(Xo,i===0||i===1,`invalid box child offset: ${i}`),!0;const l=s.textContent;u(Xo,l,"no content for text child");const c=l.charAt(i-1),a=l.charAt(i);return!(c===Gg||a===Gg||uu(l[i]))}function go(n,t){if(t===0)return 0;const e=t-1;if(le(n,e))return e;let o=e-1;for(;!le(n,o);)o-=1;return o}function tr(n,t){const e=Gi(n);if(u(Xo,t>=0&&t<=e,`invalid offset: ${t}, ${e}`),t===e)return e;const o=t+1;if(le(n,o))return o;let r=o+1;for(;!le(n,r);)r+=1;return r}const er=w("line-breaker");function Qi(n){const t=c=>{const a=Sl(c);return Vo(c).top>a.top+a.height/2},e=(c,a)=>{const d=Vo(c);return Sl(a).left<d.right},o=(c,a)=>{const d=Vo(c),f=Vo(a);return f.top+f.height/2>d.bottom},r=c=>{if(c.length===0||c.length===1)return!1;const a=c[0],d=c[c.length-1];return a.right-d.left>10},i=[];let s=0;const l=yn(n);for(let c=0;c<l.length;c++){const a=l[c];if(Un(a)){const v=a,x=l[c+1];if(!x)break;const E=l[c-1];if(E&&o(E,v)&&i.push({offset:s,type:"betweenChild",childInfo:{prevChild:E,nextChild:v,wrap:"nextWrapped",prevWrapped:t(E),nextWrapped:t(v)}}),e(v,x)){i.push({offset:s,type:"betweenChild",childInfo:{prevChild:E,nextChild:v,wrap:"nowrap",prevWrapped:t(E),nextWrapped:t(v)}});continue}continue}if(Pe(a)){const v=a,x=l[c+1];if(!x)break;const E=l[c-1];if(E&&o(E,v)&&i.push({offset:s,type:"betweenChild",childInfo:{prevChild:E,nextChild:v,wrap:"nextWrapped",prevWrapped:t(E),nextWrapped:t(v)}}),e(v,x)){s+=1,i.push({offset:s,type:"betweenChild",childInfo:{prevChild:E,nextChild:a,wrap:"nowrap",prevWrapped:t(E),nextWrapped:t(a)}});continue}s+=1;continue}const d=a,f=d.getClientRects();if(u(er,f.length>0,"invalid text child dom"),f.length===1){const v=l[c+1];if(!v)break;if(e(d,v)){s+=$e(d),i.push({offset:s,type:"betweenChild",childInfo:{prevChild:d,nextChild:v,wrap:"nowrap",prevWrapped:t(d),nextWrapped:t(v)}});continue}s+=$e(d);continue}const m=d.firstChild;u(er,m,"invalid text child, no text node"),u(er,m instanceof Text,`invalid text child, not a valid text node: ${typeof m}`);const p=document.createRange(),A=document.createRange(),k=$e(d);u(er,m.data.length===k,"text node data length not equal child text length");for(let v=0;v<m.data.length;v++){if(!le(n,s+v))continue;p.setStart(m,v),bu()&&p.selectNodeContents(m);const x=p.getClientRects();if(u(er,x.length>=1,"invalid text node, no client rects"),r(x)){const q=s+v;i.push({offset:q,type:"textBreakWord",childInfo:{prevChild:a,nextChild:a,wrap:"nowrap",prevWrapped:t(a),nextWrapped:t(a)}});continue}let E=v+1;le(n,s+E)||(E=v+2),A.setStart(m,E);const L=A.getClientRects(),R=x[0];L[0].left<R.right&&u(er,!1,"span pre-wrap should not has a line-wrap by white space")}s+=k}return i}function Yu(n,t){const e=Qi(n);for(let o=0;o<e.length;o++){const{offset:r,type:i}=e[o];if(t.offset<r)return{lineIndex:o,lineBreaks:e};if(t.offset===r&&t.type==="end")return{lineIndex:o,lineBreaks:e}}return u(er,t.offset<=Gi(n),"invalid position, offset > block length"),{lineIndex:e.length,lineBreaks:e}}const WA=w("line-offset");function Ju(n){const t=Qi(n),e=[];let o=0;for(let r=0;r<t.length;r++){const i=t[r];e.push({start:o,end:i.offset}),o=i.offset}return e.push({start:o,end:Gi(n)}),e}function Gl(n,t){const e=Ju(n);return u(WA,t>=0&&t<e.length,`invalid line index: ${t}, ${e.length}`),e[t]}function Zg(n,t){const{lineIndex:e}=Yu(n,t);return Gl(n,e)}function GA(n){const t=Ju(n),e=n.getBoundingClientRect(),o=[];return t.forEach(({start:r,end:i})=>{const s=F(n,r,"home");let l=De(n,s);const c=F(n,i,"end"),a=De(n,c);l.top+l.height/2<a.top&&(l=new DOMRect(e.left-1e4,a.top,1,a.height));const d=new DOMRect(l.left,a.top,a.left-l.left,a.height),f=new DOMRect(e.left,a.top,e.width,a.height);o.push({start:r,end:i,rect:f,contentRect:d})}),o}function ZA(n,t,e){const r=GA(n).find(s=>Wo(s.rect,t,e));if(!r)return null;const i=r.contentRect;return t-i.left<i.right-t?F(n,r.start,"home"):F(n,r.end,"end")}function Qg(n,t,e){const o=De(n,t),r=De(n,e),i=o.top+o.height/2,s=r.top+r.height/2,l=r.top<i&&i<r.bottom,c=o.top<s&&s<o.bottom;return l&&c}function Yg(n){return Ju(n).length}const nr=w("find-text-position");function Jg(n,t){const{start:e,end:o}=Gl(n,t),r=j(n),i=De(n,F(r,e,"home"));if(!(De(n,F(r,o,"end")).top>i.top+i.height/2))return!1;const c=ql(n,e);return u(nr,c.next,"no next child at offset"),u(nr,!Wi(c.next),"next child is not text child"),!0}function QA(n,t){const e=j(n);u(nr,Jg(n,t),"line is not wrapped");const{start:o,end:r}=Gl(n,t),i=F(e,o,"home");for(let s=o+1;s<=r;s+=1){let l="normal";s===o?l="home":s===r&&(l="end");const c=F(e,s,l);if(!Qg(n,i,c))return s-1}return u(nr,!1,"failed to find wrapped offset"),0}function Zl(n,t,e,o,r,i,s){u(nr,_(n,t),`not a text kind block: ${it(t)}`);const{start:l,end:c}=Gl(t,e);let a=l;const d=j(t);if(t===o&&Jg(t,e)){const v=QA(t,e);(i==="up"||i==="down"&&Qg(t,r,F(d,l,"home")))&&(a=v+1)}let f=Number.MAX_SAFE_INTEGER;const m=Ye(n,o,r),p=s!=null?s:m.left+m.width/2,A=m.top+m.height/2;let k=F(d,a,"home");for(let v=a;v<=c;v++){if(!le(t,v))continue;let x="normal";v===l?x="home":v===c&&(x="end");const E=F(d,v,x),L=De(t,E),R=An(L,p,A);R<f&&(f=R,k=E)}return k}function YA(n,t,e,o,r){return u(nr,_(n,t),"not a text block"),Zl(n,t,Yg(t)-1,e,o,"up",r)}function JA(n,t,e,o,r){return u(nr,_(n,t),"not a text block"),Zl(n,t,0,e,o,"down",r)}function KA(n,t,e,o){const{lineIndex:r}=Yu(t,e);if(r===Yg(t)-1)return null;const i=Zl(n,t,r+1,t,e,"down",o);return i||null}function XA(n,t){if(t.offset===0)return null;const e=Qi(n),o=e.find(r=>r.offset===t.offset);if(!o){const r=go(n,t.offset);return e.find(s=>s.offset===r)?{offset:r,type:"home"}:{offset:r,type:"normal"}}if(o.type==="betweenChild"){if(t.type==="home"&&o.childInfo.wrap==="nowrap")return{offset:t.offset,type:"end"};if(o.childInfo.prevWrapped)return{offset:go(n,t.offset),type:"normal"}}return{offset:go(n,t.offset),type:"normal"}}function tb(n,t){const e=Gi(n);if(t.offset===e)return null;const o=Qi(n),r=o.find(i=>i.offset===t.offset);if(!r){const i=tr(n,t.offset),s=o.find(l=>l.offset===i);return s?s.type==="betweenChild"?{offset:i,type:"end"}:{offset:i,type:"home"}:{offset:i,type:"normal"}}return r.type==="betweenChild"?r.childInfo.wrap==="nowrap"&&t.type==="end"?{offset:t.offset,type:"home"}:{offset:tr(n,t.offset),type:"home"}:{offset:tr(n,t.offset),type:"normal"}}function eb(n,t,e,o){const{lineIndex:r}=Yu(t,e);if(r===0)return null;const i=Zl(n,t,r-1,t,e,"up",o);return i||null}const nb=w("move-caret");function ob(n,t,e,o){if(o==="ArrowLeft"){const r=XA(t,e);return r?F(j(t),r.offset,r.type):null}if(o==="ArrowRight"){const r=tb(t,e);return r?F(j(t),r.offset,r.type):null}if(o==="ArrowUp"){const r=eb(n,t,e,n.selection.getSuggestedCaretX());return r?F(j(t),r.offset,r.type):null}if(o==="ArrowDown"){const r=KA(n,t,e,n.selection.getSuggestedCaretX());return r?F(j(t),r.offset,r.type):null}u(nb,!1,`invalid navigation direction: ${o}`)}const Ku=w("text-range");function rb(n){const t=[];return yn(n).forEach(o=>{const r=Array.from(o.getClientRects()).map(i=>({rect:i,child:o}));t.push(...r)}),t}function ib(n,t,e){const o=rb(n);for(let r=1;r<o.length;r++){const i=o[r-1],s=o[r];if(t>=i.rect.right&&t<=s.rect.left&&e>=i.rect.top&&e<=i.rect.bottom&&e>=s.rect.top&&e<=s.rect.bottom)return mo(n,s.child).start}return null}function sb(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=r.closest("div[data-type=block-content]>span");if(!i){const x=t.getBoundingClientRect();if(!Wo(x,e,o))return null;const E=ib(t,e,o);if(E!==null){const R=F(t,E,"normal");return new Kt(n,{anchor:R,focus:R})}const L=ZA(t,e,o);return L?new Kt(n,{anchor:L,focus:L}):null}const s=yn(t);u(Ku,s.indexOf(i)!==-1,"failed to find child in children");const l=mo(t,i);u(Ku,l,"failed to get child offset");const{start:c}=l;let a,d;Un(i)||Pe(i)?(a=c,d=0):(u(Ku,i.firstChild instanceof Text,"child is not text"),a=c+wm(i.firstChild,e,o),d=0);const f=j(t),p=Qi(t).find(x=>x.offset===a);let A="normal";if(p){const x=F(f,a,"home"),E=F(f,a,"end"),L=De(t,x),R=De(t,E),$=An(L,e,o),q=An(R,e,o);A=$<q?"home":"end"}const k=F(f,a,A);let v;return d&&(v=F(f,a+d,A)),new Kt(n,{anchor:k,focus:v!=null?v:k})}const lb=w("create-text-op");function _e(n,t){u(lb,n,"text is empty");const e={insert:n};return t&&Object.keys(t).length>0&&(e.attributes=t),e}function Xu(n,t){if(n.length===0)return[];if(n.indexOf(`
|
|
16
16
|
`)===-1)return[_e(n,t)];const e=n.replace(/\r\n/g,`
|
|
17
17
|
`).replace(/\r/g,`
|
|
18
18
|
`).replace(/\n/g," "),o=[];return e&&o.push(_e(e,t)),o}const Ql=w("merge-ops");function td(n){if(n.length<=1)return n;const t=(r,i)=>r.insert===void 0||i.insert===void 0||r.delete!==void 0||i.delete!==void 0||r.retain!==void 0||i.retain!==void 0||r.attributes!==void 0&&i.attributes===void 0||r.attributes===void 0&&i.attributes!==void 0?!1:r.attributes===void 0?(u(Ql,i.attributes===void 0,"op2.attributes is not undefined"),!0):(u(Ql,r.attributes&&i.attributes,"op1.attributes && op2.attributes is undefined"),El.default(r.attributes,i.attributes)),e=[];let o=n[0];e.push(o);for(let r=1;r<n.length;r+=1){const i=n[r];t(o,i)?(u(Ql,typeof o.insert=="string","before.insert is not string"),u(Ql,typeof i.insert=="string","op.insert is not string"),o.insert+=i.insert):(e.push(i),o=i)}return e}function cb(n){let t;for(t=n.length-1;t>=0;t--){const e=n[t];if(!e.attributes||!e.attributes.box||e.attributes.type!=="br")break}return t===n.length-1?n:n.slice(0,t+1)}const Kg=w("delete-text");function ed(n,t,e){const{left:o,right:r}=Gt(n,t,e),i=[...o,...r];return td(i)}function Xg(n,t){u(Kg,n>=0,`invalid offset: ${n}`),u(Kg,t>=1,`invalid delete count: ${t}`);const e=[];return n!==0&&e.push({retain:n}),e.push({delete:t}),e}const tp=w("delta");function ep(n,t){const e=new se.default(n),o=new se.default(t);return e.diff(o).ops}function ab(n,t,e){return new se.default(t).transformPosition(n,!e)}function ub(n){u(tp,n,"ops is null or undefined");for(let t=0;t<n.length;t++){const e=n[t];if(e.insert===null||e.insert===void 0||e.retain!==void 0||e.delete!==void 0)return!1}return!0}function db(n,t){const e=new se.default(n),o=new se.default(t);return e.compose(o).ops}class ce{static ensureValidText(t){u(tp,ub(t),`text is not a valid text, ${JSON.stringify(t)}`)}static diff(t,e){return this.ensureValidText(t),this.ensureValidText(e),ep(t,e)}static transformCursor(t,e,o){return ab(t,e,o)}static transformOffset(t,e,o){const r=ep(t,e),i=new se.default(r);return o.map(s=>i.transformPosition(s))}static apply(t,e){this.ensureValidText(t);const o=db(t,e);return this.ensureValidText(o),o}}const np=w("insert-text");function po(n,t,e,o){u(np,e,`invalid text to insert: ${e}`);const{left:r,right:i}=ve(n,t),s=typeof e=="string"?[_e(e,o)]:e,l=[...r,...s,...i];return td(l)}function op(n){return{insert:" ",attributes:n}}function Yl(n,t,e){if(u(np,n>=0,`invalid offset: ${n}`),t.length===0)return[];const o=[];if(n>0&&o.push({retain:n}),typeof t!="string")return o.push(...t),o;const i={insert:t.replaceAll(`\r
|
|
19
19
|
`," ").replaceAll(`
|
|
20
20
|
`," ").replaceAll("\r"," ")};return e&&Object.keys(e).length>0&&(i.attributes=e),o.push(i),o}function hb(n,t){return[...n,...t]}const rp=w("text-op");function nd(n){return u(rp,typeof n.insert=="string","invalid op, no insert"),n.insert.length}function ip(n,t){const e=n;let o=0;for(let r=0;r<e.length;r++){const i=e[r];u(rp,typeof i.insert=="string","invalid text op, no insert");const s=o+nd(i);if(s>t)return[i];if(s===t){const l=[i];return r<e.length-1&&l.push(e[r+1]),l}o=s}return[]}const od="style-color-",rd="style-bg-color-";function Jl(n,t,e){const o=Q.default(n);return o.forEach(r=>{if(!(r.attributes&&r.attributes.box===!0))if(e===void 0){if(!r.attributes||r.attributes[t]===void 0)return;delete r.attributes[t],Object.keys(r.attributes).length===0&&delete r.attributes}else r.attributes||(r.attributes={}),r.attributes[t]=e}),o}function id(n,t,e,o){const r=Q.default(n);return r.forEach(i=>{i.attributes&&i.attributes.box===!0||i.attributes&&((o==null?void 0:o.ignoreValue)||i.attributes[t]===e)&&(delete i.attributes[t],Object.keys(i.attributes).length===0&&delete i.attributes)}),r}function Yi(n,t,e,o,r){if(t===0)return e;const i=Gt(e,n,t);return[...i.left,...Jl(i.middle,o,r),...i.right]}function Nr(n,t,e,o,r,i){if(t===0)return e;const s=Gt(e,n,t);return[...s.left,...id(s.middle,o,r,i),...s.right]}function Ji(n,t){const e=ip(n,t);if(e.length===1)return e[0].attributes;if(e.length===2)return e[1].attributes}function sp(n,t,e,o){if(t===0)return e;const r=Gt(e,n,t),i=r.middle.map(s=>o(s));return[...r.left,...i,...r.right]}function lp(n,t){t==="color"?Object.keys(n).forEach(e=>{e.startsWith("style-color-")&&delete n[e]}):t==="backgroundColor"&&Object.keys(n).forEach(e=>{e.startsWith("style-bg-color-")&&delete n[e]})}function fb(n,t){if(!n.attributes||n.attributes.box)return;const e=n.attributes;lp(e,t),Object.keys(e).length===0&&delete n.attributes}function mb(n,t,e){n.attributes||(n.attributes={}),!n.attributes.box&&(t==="color"?n.attributes[`style-color-${e}`]=!0:n.attributes[`style-bg-color-${e}`]=!0)}function cp(n,t,e,o,r){const i=Q.default(e);return sp(n,t,i,l=>(fb(l,o),r!==null&&mb(l,o,r),l))}function sd(n){var r,i;if(!n||n.box)return[null,null];const t=Array.from(Object.keys(n));let e=null,o=null;for(let s=0;s<t.length;s++){const l=t[s];l.startsWith(od)?e=(r=Number.parseInt(l.substring(od.length),10))!=null?r:null:l.startsWith(rd)&&(o=(i=Number.parseInt(l.substring(rd.length),10))!=null?i:null)}return[e,o]}function ap(n,t,e){lp(n,t),t==="color"?n[`style-color-${e}`]=!0:n[`style-bg-color-${e}`]=!0}function up(n){return n.attributes?n.attributes.box?[null,null]:sd(n.attributes):[null,null]}function dp(n,t,e){let o=[];if(t===0?n!==0&&(o=Gt(e,n-1,1).middle):o=Gt(e,n,t).middle,o.length===0)return[null,null];let[r,i]=up(o[0]);if(r===null&&i===null)return[r,i];for(let s=1;s<o.length;s++){const l=o[s];if(!l.attributes)return[null,null];if(l.attributes.box)continue;const[c,a]=up(l);c===null||r===null?r=null:r=c===r?r:null,a===null||i===null?i=null:i=a===i?i:null}return[r,i]}function hp(n){return Q.default(n)}const gb=w("update-op-attribute");function fp(n,t,e,o){const r=hp(n),i=r.findIndex(l=>l.attributes?l.attributes[t]===e:!1);u(gb,i!==-1,`can not find op by key: ${t}, value: ${e}`);const s=r[i];return s.attributes={...s.attributes,...o},r}const pb="\u200B",Cb=w("to-plain-text");function vt(n,t){let e="";return n.forEach(o=>{if(u(Cb,typeof o.insert=="string","invalid op"),o.attributes&&o.attributes.box===!0){if(t!=null&&t.boxReplacement){e+=t.boxReplacement;return}if(o.attributes.text){e+=o.attributes.text;return}e+=" "}e+=o.insert}),e}function ld(n){return vt(n,{boxReplacement:" "})}function Kl(n,t,e,o){const r=Ji(n,t),i=ed(n,t,e-t);return o?po(i,t,o,r!=null?r:null):i}function cd(n,t){if(!t)return[];const e=t.length,o=vt(n,{boxReplacement:" "}).toLowerCase();t=t.toLowerCase();let r=o.indexOf(t,0);const i=[];for(;r!==-1;)i.push({start:r,end:r+e}),r=o.indexOf(t,r+e);return i}function mp(n,t,e,o){const r=cd(n,t);let i=Q.default(n);return r.length===0||(r.reverse().forEach(s=>{i=Kl(i,s.start,s.end,e)}),o&&(o.count=r.length)),i}function Co(n,t){return n?[{insert:n,attributes:t}]:[]}function Vn(n,t){return{id:P(),type:"text",text:typeof n=="string"?Co(n):n,...t}}function Xl(n){return Vn(n!=null?n:"")}function or(n,t){return{blocks:{root:(n!=null?n:"").replaceAll("\r","").split(`
|
|
21
21
|
`).map((r,i)=>{const l=i===0&&(t==null?void 0:t.firstLineAsTitle)?{heading:1}:void 0;return Vn(r,l)})},meta:{},comments:{}}}function tc(n){const t=n.blocks.root;if(t.length!==1)return!1;const e=t[0];return!(!e.text||me(e.text))}function gp(n,t){const e=P();return n.localInsertChildContainer(e,t),e}function Bn(n,t){return gp(n,[Xl(t)])}function pp(n){return typeof n.offset=="number"}function ec(n){return pp(n.anchor)}function Ab(n){return ec(n)&&n.anchor.offset===n.focus.offset&&n.anchor.blockId===n.focus.blockId}function Cp(n,t){return{blockId:n,offset:t}}function nc(n,t){const e=Cp(n,t);return{anchor:e,focus:e}}function Ap(n,t){return{blockId:n,childContainerId:t}}function bb(n,t){const e=Ap(n,t);return{anchor:e,focus:e}}const vb=w("block-to-text");function yb(n,t,e){let o="";return t.forEach(r=>{if(u(vb,typeof r.insert=="string","invalid op"),r.attributes&&r.attributes.box===!0){const i=r.attributes,s=n.editorBoxes.getBoxClass(i.type);if(s!=null&&s.convertTo){o+=s.convertTo(n,i,e,"text");return}if(r.attributes.text){o+=r.attributes.text;return}o+=`[${i.type}]`}o+=r.insert}),o}const kb=w("block-to-text");function wb(n,t,e){let o="";return t.forEach(r=>{if(u(kb,typeof r.insert=="string","invalid op"),r.attributes&&r.attributes.box===!0){const s=r.attributes,l=n.editorBoxes.getBoxClass(s.type);if(l!=null&&l.convertTo){o+=l.convertTo(n,s,e,"markdown");return}if(r.attributes.text){o+=r.attributes.text;return}o+=`[${s.type}]`}const i=r.attributes;if(i){let s=r.insert;i.link&&(s=`[${s}](${i.link})`);const l=[];i["style-code"]?l.push("`"):(i["style-bold"]&&l.push("**"),i["style-italic"]&&l.push("*"),i["style-underline"]&&l.push("__"),i["style-strikethrough"]&&l.push("~~"));const c=l.join("");o.endsWith(c.substring(0,1))&&(o+=" ");const a=l.reverse().join("");o+=c+s+a;return}o+=r.insert}),o}function Bb(n,t,e){const o=t.text||[];let i=wb(n,o,e);if(t.heading){const s=t.heading;i=`${"#".repeat(s)} ${i}`}return t.quoted&&(i=`> ${i}`),t.type==="text"&&(i=`${i}
|
|
22
|
-
`),i}const Eb=w("block-to-text");function Ib(n,t,e){let o="";return t.forEach(r=>{if(u(Eb,typeof r.insert=="string","invalid op"),r.attributes&&r.attributes.box===!0){const s=r.attributes,l=n.editorBoxes.getBoxClass(s.type);if(l!=null&&l.convertTo){o+=l.convertTo(n,s,e,"html");return}if(r.attributes.text){o+=r.attributes.text;return}o+=`[${s.type}]`}const i=r.attributes;if(i){let s=r.insert;i.link&&(s=`<a href="${i.link}">${s}</a>`);const l=[];i.bold&&l.push("strong"),i.italic&&l.push("em"),i.underline&&l.push("u"),i.strike&&l.push("s"),i.code&&l.push("code");const c=l.map(d=>`<${d}>`).join(""),a=l.reverse().map(d=>`</${d}>`).join("");o+=c+s+a;return}o+=r.insert}),o||(o="<br>"),`<p>${o}</p>`}const Ki=w("text-block");function xb(n,t,e,o,r){const{text:i}=r;u(Ki,i,"no text for text block");const s=lo(o,"div");return Wl(n,t,r.id,s,i),s}function Tb(n,t,e){u(Ki,e,"no text to update");const o=lo(null,"div");Wl(n,ao(t),j(t),o,e);const r=st(t);Hi(r,o)}function Sb(n,t,e){return UA(n,t,e)}function bp(n,t){let e="";return t.forEach(o=>{if(!!o.insert){if(o.attributes&&o.attributes.box===!0&&o.attributes.type==="math"){e+=`[${x.t("mathjax.abstract")}] `;return}e+=o.insert}}),e}function Db(n,t){u(Ki,_(n,t),"block in not textBlock");const e=n.selection.range;let o="";if(e.isCollapsed()){const r=n.getBlockText(t);o=bp(n,r)}else{const r=j(t),i=en(n,{simpleBlockOnly:!0}).find(s=>j(s.block)===r);if(i&&!Tt(n,i.block)){u(Ki,i.block===t,"block not match");const s=n.getBlockText(t),{start:l,end:c}=i,a=l.offset,d=c.offset-a;if(d>0){const{middle:f}=Gt(s,a,d);o=bp(n,f)}}}return{abstract:o.trim()}}function Lb(n,t,e,o){return u(Ki,t.text,"no text for text block"),o==="text"?yb(n,t.text,e):o==="markdown"?Bb(n,t,e):Ib(n,t.text,e)}const ye={blockType:"text",blockKind:"text",createBlockContent:xb,getBlockTextLength:Gi,getRangeFromPoint:sb,moveCaret:ob,updateSelection:VA,clearSelection:qA,getCaretRect:De,getClientRects:Sb,setBlockText:Tb,getBlockProperties:Db,convertTo:Lb},Mb=Wl,oc=w("action-helper");function Ao(n,t){const e=z(t),o=V(e),r=K(t);return n.doc.getBlockData(o,r)}function ge(n,t){u(oc,_(n,t),"not a text kind block");const o=Ao(n,t).text;return u(oc,o,"no text in block"),o}function rc(n,t,e){return ve(ge(n,t),e).left}function vp(n,t){const e=U(t);u(oc,e,"no parent block");const o=ge(n,e),r=ag(t),i=o.find(s=>{const l=s.attributes;return l?l.box&&l.id===r:!1});return u(oc,i,"failed to find box"),i.attributes}const St=w("block-text");function Rb(n,t,e){u(St,_(n,t),"not a text kind block"),u(St,le(t,e),"not a valid offset"),u(St,e>=0&&e<G(n,t),`invalid offset: ${e}`);const r=tr(t,e)-e;r===0&&u(St,!1,`no text after offset: ${e}`);const i=ge(n,t),{middle:s}=Gt(i,e,r);u(St,s.length===1,"failed to split text to 3 parts");const l=s[0];return Zi(l)?" ":(u(St,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function Ob(n,t,e){u(St,_(n,t),"not a text kind block"),u(St,le(t,e),"not a valid offset"),u(St,e>0&&e<=G(n,t),`invalid offset: ${e}`);const o=go(t,e),r=e-o;r===0&&u(St,!1,`no text before offset: ${e}`);const i=ge(n,t),{middle:s}=Gt(i,o,r);u(St,s.length===1,"failed to split text to 3 parts");const l=s[0];return Zi(l)?" ":(u(St,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function ic(n,t,e){u(St,_(n,t),"not a text kind block"),u(St,le(t,e),"not a valid offset"),u(St,e>0&&e<=G(n,t),`invalid offset: ${e}`);const o=go(t,e),r=e-o;r===0&&u(St,!1,`no text before offset: ${e}`);const i=ge(n,t),{middle:s}=Gt(i,o,r);u(St,s.length===1,"failed to split text to 3 parts");const l=s[0];return Zi(l)?{op:l,charType:"box",offset:o,length:1}:{op:l,charType:Ll(l.insert)?"space":"text",offset:o,length:l.insert.length}}function Xi(n,t,e){u(St,_(n,t),"not a text kind block"),u(St,le(t,e),"not a valid offset"),u(St,e>=0&&e<G(n,t),`invalid offset: ${e}`);const r=tr(t,e)-e;r===0&&u(St,!1,`no text after offset: ${e}`);const i=ge(n,t),{middle:s}=Gt(i,e,r);u(St,s.length===1,"failed to split text to 3 parts");const l=s[0];return Zi(l)?{op:l,charType:"box",offset:e,length:1}:{op:l,charType:Ll(l.insert)?"space":"text",offset:e,length:l.insert.length}}function Nb(n,t,e,o){let r=e;for(;r>0;){const i=ic(n,t,r);if(i.charType===o)return i;r-=i.length}return null}function Pb(n,t,e,o){const r=G(n,t);let i=e;for(;i<r;){const s=Xi(n,t,i);if(s.charType===o)return s;i+=s.length}return null}function ad(n,t,e,o){let r=e;for(;r>0;){const i=ic(n,t,r);if(i.charType!==o)return i;r-=i.length}return null}function ud(n,t,e,o){const r=G(n,t);let i=e;for(;i<r;){const s=Xi(n,t,i);if(s.charType!==o)return s;i+=s.length}return null}function dd(n,t,e){if(u(St,_(n,t),"invalid blok type"),Tt(n,t))return 0;const o=ic(n,t,e);if(o.charType==="box")return e-1;let r=e;if(o.charType==="space"){const s=ad(n,t,r,"space");if(!s||s.offset===0)return 0;if(s.charType==="box")return s.offset;r=s.offset}const i=ad(n,t,r,"text");return i?i.offset+i.length:0}function hd(n,t,e){if(u(St,_(n,t),"invalid blok type"),Tt(n,t))return 0;const o=Xi(n,t,e);if(o.charType==="box")return e+1;let r=e;if(o.charType==="space"){const s=ud(n,t,r,"space");if(!s||s.offset===0)return G(n,t);if(s.charType==="box")return s.offset;r=s.offset}const i=ud(n,t,r,"text");return i?i.offset:G(n,t)}const yp=w("element");function fd(n,t,e){const o=b("div",[t],n);return o.setAttribute("data-type","editor-container"),o.setAttribute("data-container-id",e),b("div",["container-blocks"],o),o}function Pr(n,t){const e=n.rootElement.querySelector(`[data-container-id=${t}`);return u(yp,e,`no container: ${t}`),e}function kp(n,t){return n.rootElement.querySelector(`[data-container-id=${t}`)}function sc(n){const t=n.querySelector(":scope > .container-blocks");return u(yp,t,"no container blocks element"),t}function $b(n){let t=n.querySelector(":scope > .container-tools");return t||(t=b("div",["container-tools"],n)),t}const _b=w("child-container-path");function wp(n){if(Ct(n))return[];const t=U(n);return u(_b,t,"no parent block"),ao(t)}const Bp=w("load-blocks");function md(n,t,e){const o=V(t),r=Cg(t,n.doc);u(Bp,r.length>0,"no blocks in container");const i=document.createDocumentFragment();r.forEach((l,c)=>{const a=n.editorBlocks.createBlock([...e,{containerId:o,blockIndex:c}],t,l);i.appendChild(a)}),sc(t).appendChild(i)}function Fb(n,t,e){const o=sc(n);if(t===0)return o.insertBefore(e,o.firstChild),e;const r=Mt(n);return u(Bp,t>=0&&t<=r.length,"invalid block index"),t===r.length?o.appendChild(e):o.insertBefore(e,r[t]),e}function Hb(n,t,e,o){const r=wp(t);r.push({containerId:V(t),blockIndex:e});const i=n.editorBlocks.createBlock(r,t,o);return Fb(t,e,i),i}const Ep=w("root-container");class jb{constructor(t,e){h(this,"resizeObserver");h(this,"handleContextMenu",t=>{});h(this,"handleResize",()=>{try{this.editor.selection.updateSelection(null),this.editor.emit("resize",this.editor)}catch(t){Ep.warn(`failed to update selection while container resizing: ${t.message}`)}});h(this,"handleClick",t=>{this.editor.emit("click",this.editor,t);const e=t.target;if(!zi(e)&&(t.detail===1&&this.editor.input.focus(),t.detail===3&&this.editor.selectionHandler.handleTripleClick(t),t.detail===1&&t.button===0)){const o=document.elementFromPoint(t.clientX,t.clientY);if(o&&wt(this.rootContainer,o)){const r=U(o);r&&wt(r,o)&&this.handleBlockClick(t,r,o)}}});h(this,"handleBlockClick",(t,e,o)=>{var s,l;if(!_(this.editor,e))return;const r=Ru(o);if(r){const c=U(r);u(Ep,c,"no parent block"),(l=(s=this.editor.editorBoxes.getBoxClass(ji(r)))==null?void 0:s.handleClickBox)==null||l.call(s,this.editor,r,t);return}const i=o.closest("span.text.link");i&&yn(e).indexOf(i)!==-1&&this.editor.emit("clickLink",this.editor,t,i)});h(this,"handleDblClick",t=>{zi(t.target)||this.editor.selectionHandler.handleDblClick(t)});h(this,"handleMouseDown",t=>{const e=t.target;if(!!e&&e instanceof Node&&!zi(e)){if(e instanceof HTMLElement&&e.draggable){this.editor.selectionHandler.handleMouseDown(t),this.editor.selectionHandler.stopSelection(),this.editor.input.focus();return}t.button===0&&(document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),this.editor.selectionHandler.handleMouseDown(t)),xt.isMobileSafari||(t.preventDefault(),this.editor.input.focus()),t.button===2&&t.stopPropagation()}});h(this,"handleMouseMove",t=>{this.editor.selectionHandler.handleMouseMove(t)});h(this,"handleMouseUp",t=>{t.button===0&&(this.editor.selectionHandler.handleMouseUp(t),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp))});this.editor=t,this.rootContainer=e,this.editor=t,this.resizeObserver=new ResizeObserver(this.handleResize),this.bindEvents(e)}bindEvents(t){this.resizeObserver.observe(t);const e=this.editor.rootElement;e.onmousedown=this.handleMouseDown,e.ondblclick=this.handleDblClick,e.onclick=this.handleClick,e.oncontextmenu=this.handleContextMenu}unbindEvents(){this.resizeObserver.disconnect();const t=this.editor.rootElement;t.onmousedown=null,t.ondblclick=null,t.onclick=null,t.oncontextmenu=null}destroy(){this.unbindEvents()}reload(){const t=this.editor.selection.range,e=sc(this.rootContainer);e.innerHTML="",md(this.editor,this.rootContainer,[]);const o=this.editor.findBlockById(t.start.blockId);if(o)this.editor.selection.selectBlock(o,0);else{const r=Ft(this.rootContainer);this.editor.selection.selectBlock(r,0)}}}function Ip(n){const t=fd(n.contentElement,"root","root");return n.rootContainer=t,md(n,t,[]),new jb(n,t)}function xp(n,t,e,o){const r=kp(n,o);if(r)return e.appendChild(r),r;const i=fd(e,"child",o);return md(n,i,t),i}function Tp(n,t){const e=n.getBoundingClientRect().width;return t.withPadding?e:e-du(n)}function gd(n,t){let e=Number.MAX_SAFE_INTEGER;const o=Mt(t);for(let i=0;i<o.length;i++){const s=o[i],l=vg(n,s);l&&(e=Math.min(e,l))}return e===Number.MAX_SAFE_INTEGER?void 0:e+du(t)}function pd(n,t){const e=Mt(t);return e.length!==1?!1:Tt(n,e[0])}const Sp=w("text-box");function zb(n,t,e,o){u(Sp,o.text,`no text for text box data: ${JSON.stringify(o)}`),u(Sp,typeof o.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`),b("span",[],e,o.text)}function Ub(n,t,e,o){var r;return(r=t.text)!=null?r:""}const Dp={boxType:"text",updateBoxContent:zb,convertTo:Ub},Vb="data:image/svg+xml;base64,Cjxzdmcgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTguMjQ0NSA2QzE3LjgyNzQgNiAxNy41MzYzIDYuMjkxMTcgMTcuNTM2MyA2LjcwODI2QzE3LjUzNjMgNi45ODM3IDE3LjU1OTkgNy4yMzU1MyAxNy41NTk5IDcuNjEzMjdDMTcuNTU5OSAxMC4yODExIDE2LjYyMzQgMTEuMzc0OSAxMy45NzkyIDExLjM3NDlIOC45NDI2Nkw3LjEyNDc5IDExLjQ4NTFMOS41NDA3NSA5LjI4MTYyTDExLjE5MzQgNy41OTc1M0MxMS4zMjcxIDcuNDcxNjEgMTEuMzk4IDcuMjgyNzQgMTEuMzk4IDcuMDkzODdDMTEuMzk4IDYuNjkyNTIgMTEuMDk4OSA2LjQwMTM1IDEwLjY5NzYgNi40MDEzNUMxMC41MDg3IDYuNDAxMzUgMTAuMzM1NiA2LjQ3MjE4IDEwLjE3ODIgNi42MjE3TDUuMjQzOTYgMTEuNTQ4MUM1LjA4NjU3IDExLjcwNTUgNSAxMS44OTQzIDUgMTIuMDkxMUM1IDEyLjI4NzggNS4wODY1NyAxMi40NzY3IDUuMjQzOTYgMTIuNjI2MkwxMC4xNjI1IDE3LjUzNjhDMTAuMzM1NiAxNy43MDk5IDEwLjUwODcgMTcuNzgwOCAxMC42OTc2IDE3Ljc4MDhDMTEuMDk4OSAxNy43ODA4IDExLjM5OCAxNy40ODk2IDExLjM5OCAxNy4wODgzQzExLjM5OCAxNi44OTE1IDExLjMyNzEgMTYuNzEwNSAxMS4xOTM0IDE2LjU4NDZMOS41NDA3NSAxNC45MDA1TDcuMTMyNjYgMTIuNjk3TDguOTQyNjYgMTIuODA3MkgxNC4wNTc5QzE3LjU1OTkgMTIuODA3MiAxOSAxMS4yNDExIDE5IDcuNjc2MjJDMTkgNy4yMzU1MyAxOC45OTIxIDYuODY1NjUgMTguOTM3IDYuNjEzODNDMTguODc0MSA2LjI5OTA0IDE4LjY3NzMgNiAxOC4yNDQ1IDZaIiBmaWxsPSIjQjJCQ0NEIi8+Cjwvc3ZnPgo=";function qb(n,t,e,o){ym(Vb,[],e),b("br",[],e)}function Wb(n,t,e,o){return o==="text"?`
|
|
22
|
+
`),i}const Eb=w("block-to-text");function Ib(n,t,e){let o="";return t.forEach(r=>{if(u(Eb,typeof r.insert=="string","invalid op"),r.attributes&&r.attributes.box===!0){const s=r.attributes,l=n.editorBoxes.getBoxClass(s.type);if(l!=null&&l.convertTo){o+=l.convertTo(n,s,e,"html");return}if(r.attributes.text){o+=r.attributes.text;return}o+=`[${s.type}]`}const i=r.attributes;if(i){let s=r.insert;i.link&&(s=`<a href="${i.link}">${s}</a>`);const l=[];i.bold&&l.push("strong"),i.italic&&l.push("em"),i.underline&&l.push("u"),i.strike&&l.push("s"),i.code&&l.push("code");const c=l.map(d=>`<${d}>`).join(""),a=l.reverse().map(d=>`</${d}>`).join("");o+=c+s+a;return}o+=r.insert}),o||(o="<br>"),`<p>${o}</p>`}const Ki=w("text-block");function xb(n,t,e,o,r){const{text:i}=r;u(Ki,i,"no text for text block");const s=lo(o,"div");return Wl(n,t,r.id,s,i),s}function Tb(n,t,e){u(Ki,e,"no text to update");const o=lo(null,"div");Wl(n,ao(t),j(t),o,e);const r=st(t);Hi(r,o)}function Sb(n,t,e){return UA(n,t,e)}function bp(n,t){let e="";return t.forEach(o=>{if(!!o.insert){if(o.attributes&&o.attributes.box===!0&&o.attributes.type==="math"){e+=`[${T.t("mathjax.abstract")}] `;return}e+=o.insert}}),e}function Db(n,t){u(Ki,_(n,t),"block in not textBlock");const e=n.selection.range;let o="";if(e.isCollapsed()){const r=n.getBlockText(t);o=bp(n,r)}else{const r=j(t),i=en(n,{simpleBlockOnly:!0}).find(s=>j(s.block)===r);if(i&&!Tt(n,i.block)){u(Ki,i.block===t,"block not match");const s=n.getBlockText(t),{start:l,end:c}=i,a=l.offset,d=c.offset-a;if(d>0){const{middle:f}=Gt(s,a,d);o=bp(n,f)}}}return{abstract:o.trim()}}function Lb(n,t,e,o){return u(Ki,t.text,"no text for text block"),o==="text"?yb(n,t.text,e):o==="markdown"?Bb(n,t,e):Ib(n,t.text,e)}const ye={blockType:"text",blockKind:"text",createBlockContent:xb,getBlockTextLength:Gi,getRangeFromPoint:sb,moveCaret:ob,updateSelection:VA,clearSelection:qA,getCaretRect:De,getClientRects:Sb,setBlockText:Tb,getBlockProperties:Db,convertTo:Lb},Mb=Wl,oc=w("action-helper");function Ao(n,t){const e=z(t),o=V(e),r=K(t);return n.doc.getBlockData(o,r)}function ge(n,t){u(oc,_(n,t),"not a text kind block");const o=Ao(n,t).text;return u(oc,o,"no text in block"),o}function rc(n,t,e){return ve(ge(n,t),e).left}function vp(n,t){const e=U(t);u(oc,e,"no parent block");const o=ge(n,e),r=ag(t),i=o.find(s=>{const l=s.attributes;return l?l.box&&l.id===r:!1});return u(oc,i,"failed to find box"),i.attributes}const St=w("block-text");function Rb(n,t,e){u(St,_(n,t),"not a text kind block"),u(St,le(t,e),"not a valid offset"),u(St,e>=0&&e<G(n,t),`invalid offset: ${e}`);const r=tr(t,e)-e;r===0&&u(St,!1,`no text after offset: ${e}`);const i=ge(n,t),{middle:s}=Gt(i,e,r);u(St,s.length===1,"failed to split text to 3 parts");const l=s[0];return Zi(l)?" ":(u(St,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function Ob(n,t,e){u(St,_(n,t),"not a text kind block"),u(St,le(t,e),"not a valid offset"),u(St,e>0&&e<=G(n,t),`invalid offset: ${e}`);const o=go(t,e),r=e-o;r===0&&u(St,!1,`no text before offset: ${e}`);const i=ge(n,t),{middle:s}=Gt(i,o,r);u(St,s.length===1,"failed to split text to 3 parts");const l=s[0];return Zi(l)?" ":(u(St,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function ic(n,t,e){u(St,_(n,t),"not a text kind block"),u(St,le(t,e),"not a valid offset"),u(St,e>0&&e<=G(n,t),`invalid offset: ${e}`);const o=go(t,e),r=e-o;r===0&&u(St,!1,`no text before offset: ${e}`);const i=ge(n,t),{middle:s}=Gt(i,o,r);u(St,s.length===1,"failed to split text to 3 parts");const l=s[0];return Zi(l)?{op:l,charType:"box",offset:o,length:1}:{op:l,charType:Ll(l.insert)?"space":"text",offset:o,length:l.insert.length}}function Xi(n,t,e){u(St,_(n,t),"not a text kind block"),u(St,le(t,e),"not a valid offset"),u(St,e>=0&&e<G(n,t),`invalid offset: ${e}`);const r=tr(t,e)-e;r===0&&u(St,!1,`no text after offset: ${e}`);const i=ge(n,t),{middle:s}=Gt(i,e,r);u(St,s.length===1,"failed to split text to 3 parts");const l=s[0];return Zi(l)?{op:l,charType:"box",offset:e,length:1}:{op:l,charType:Ll(l.insert)?"space":"text",offset:e,length:l.insert.length}}function Nb(n,t,e,o){let r=e;for(;r>0;){const i=ic(n,t,r);if(i.charType===o)return i;r-=i.length}return null}function Pb(n,t,e,o){const r=G(n,t);let i=e;for(;i<r;){const s=Xi(n,t,i);if(s.charType===o)return s;i+=s.length}return null}function ad(n,t,e,o){let r=e;for(;r>0;){const i=ic(n,t,r);if(i.charType!==o)return i;r-=i.length}return null}function ud(n,t,e,o){const r=G(n,t);let i=e;for(;i<r;){const s=Xi(n,t,i);if(s.charType!==o)return s;i+=s.length}return null}function dd(n,t,e){if(u(St,_(n,t),"invalid blok type"),Tt(n,t))return 0;const o=ic(n,t,e);if(o.charType==="box")return e-1;let r=e;if(o.charType==="space"){const s=ad(n,t,r,"space");if(!s||s.offset===0)return 0;if(s.charType==="box")return s.offset;r=s.offset}const i=ad(n,t,r,"text");return i?i.offset+i.length:0}function hd(n,t,e){if(u(St,_(n,t),"invalid blok type"),Tt(n,t))return 0;const o=Xi(n,t,e);if(o.charType==="box")return e+1;let r=e;if(o.charType==="space"){const s=ud(n,t,r,"space");if(!s||s.offset===0)return G(n,t);if(s.charType==="box")return s.offset;r=s.offset}const i=ud(n,t,r,"text");return i?i.offset:G(n,t)}const yp=w("element");function fd(n,t,e){const o=b("div",[t],n);return o.setAttribute("data-type","editor-container"),o.setAttribute("data-container-id",e),b("div",["container-blocks"],o),o}function Pr(n,t){const e=n.rootElement.querySelector(`[data-container-id=${t}`);return u(yp,e,`no container: ${t}`),e}function kp(n,t){return n.rootElement.querySelector(`[data-container-id=${t}`)}function sc(n){const t=n.querySelector(":scope > .container-blocks");return u(yp,t,"no container blocks element"),t}function $b(n){let t=n.querySelector(":scope > .container-tools");return t||(t=b("div",["container-tools"],n)),t}const _b=w("child-container-path");function wp(n){if(Ct(n))return[];const t=U(n);return u(_b,t,"no parent block"),ao(t)}const Bp=w("load-blocks");function md(n,t,e){const o=V(t),r=Cg(t,n.doc);u(Bp,r.length>0,"no blocks in container");const i=document.createDocumentFragment();r.forEach((l,c)=>{const a=n.editorBlocks.createBlock([...e,{containerId:o,blockIndex:c}],t,l);i.appendChild(a)}),sc(t).appendChild(i)}function Fb(n,t,e){const o=sc(n);if(t===0)return o.insertBefore(e,o.firstChild),e;const r=Mt(n);return u(Bp,t>=0&&t<=r.length,"invalid block index"),t===r.length?o.appendChild(e):o.insertBefore(e,r[t]),e}function Hb(n,t,e,o){const r=wp(t);r.push({containerId:V(t),blockIndex:e});const i=n.editorBlocks.createBlock(r,t,o);return Fb(t,e,i),i}const Ep=w("root-container");class jb{constructor(t,e){h(this,"resizeObserver");h(this,"handleContextMenu",t=>{});h(this,"handleResize",()=>{try{this.editor.selection.updateSelection(null),this.editor.emit("resize",this.editor)}catch(t){Ep.warn(`failed to update selection while container resizing: ${t.message}`)}});h(this,"handleClick",t=>{this.editor.emit("click",this.editor,t);const e=t.target;if(!zi(e)&&(t.detail===1&&this.editor.input.focus(),t.detail===3&&this.editor.selectionHandler.handleTripleClick(t),t.detail===1&&t.button===0)){const o=document.elementFromPoint(t.clientX,t.clientY);if(o&&wt(this.rootContainer,o)){const r=U(o);r&&wt(r,o)&&this.handleBlockClick(t,r,o)}}});h(this,"handleBlockClick",(t,e,o)=>{var s,l;if(!_(this.editor,e))return;const r=Ru(o);if(r){const c=U(r);u(Ep,c,"no parent block"),(l=(s=this.editor.editorBoxes.getBoxClass(ji(r)))==null?void 0:s.handleClickBox)==null||l.call(s,this.editor,r,t);return}const i=o.closest("span.text.link");i&&yn(e).indexOf(i)!==-1&&this.editor.emit("clickLink",this.editor,t,i)});h(this,"handleDblClick",t=>{zi(t.target)||this.editor.selectionHandler.handleDblClick(t)});h(this,"handleMouseDown",t=>{const e=t.target;if(!!e&&e instanceof Node&&!zi(e)){if(e instanceof HTMLElement&&e.draggable){this.editor.selectionHandler.handleMouseDown(t),this.editor.selectionHandler.stopSelection(),this.editor.input.focus();return}t.button===0&&(document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),this.editor.selectionHandler.handleMouseDown(t)),xt.isMobileSafari||(t.preventDefault(),this.editor.input.focus()),t.button===2&&t.stopPropagation()}});h(this,"handleMouseMove",t=>{this.editor.selectionHandler.handleMouseMove(t)});h(this,"handleMouseUp",t=>{t.button===0&&(this.editor.selectionHandler.handleMouseUp(t),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp))});this.editor=t,this.rootContainer=e,this.editor=t,this.resizeObserver=new ResizeObserver(this.handleResize),this.bindEvents(e)}bindEvents(t){this.resizeObserver.observe(t);const e=this.editor.rootElement;e.onmousedown=this.handleMouseDown,e.ondblclick=this.handleDblClick,e.onclick=this.handleClick,e.oncontextmenu=this.handleContextMenu}unbindEvents(){this.resizeObserver.disconnect();const t=this.editor.rootElement;t.onmousedown=null,t.ondblclick=null,t.onclick=null,t.oncontextmenu=null}destroy(){this.unbindEvents()}reload(){const t=this.editor.selection.range,e=sc(this.rootContainer);e.innerHTML="",md(this.editor,this.rootContainer,[]);const o=this.editor.findBlockById(t.start.blockId);if(o)this.editor.selection.selectBlock(o,0);else{const r=Ft(this.rootContainer);this.editor.selection.selectBlock(r,0)}}}function Ip(n){const t=fd(n.contentElement,"root","root");return n.rootContainer=t,md(n,t,[]),new jb(n,t)}function xp(n,t,e,o){const r=kp(n,o);if(r)return e.appendChild(r),r;const i=fd(e,"child",o);return md(n,i,t),i}function Tp(n,t){const e=n.getBoundingClientRect().width;return t.withPadding?e:e-du(n)}function gd(n,t){let e=Number.MAX_SAFE_INTEGER;const o=Mt(t);for(let i=0;i<o.length;i++){const s=o[i],l=vg(n,s);l&&(e=Math.min(e,l))}return e===Number.MAX_SAFE_INTEGER?void 0:e+du(t)}function pd(n,t){const e=Mt(t);return e.length!==1?!1:Tt(n,e[0])}const Sp=w("text-box");function zb(n,t,e,o){u(Sp,o.text,`no text for text box data: ${JSON.stringify(o)}`),u(Sp,typeof o.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`),b("span",[],e,o.text)}function Ub(n,t,e,o){var r;return(r=t.text)!=null?r:""}const Dp={boxType:"text",updateBoxContent:zb,convertTo:Ub},Vb="data:image/svg+xml;base64,Cjxzdmcgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTguMjQ0NSA2QzE3LjgyNzQgNiAxNy41MzYzIDYuMjkxMTcgMTcuNTM2MyA2LjcwODI2QzE3LjUzNjMgNi45ODM3IDE3LjU1OTkgNy4yMzU1MyAxNy41NTk5IDcuNjEzMjdDMTcuNTU5OSAxMC4yODExIDE2LjYyMzQgMTEuMzc0OSAxMy45NzkyIDExLjM3NDlIOC45NDI2Nkw3LjEyNDc5IDExLjQ4NTFMOS41NDA3NSA5LjI4MTYyTDExLjE5MzQgNy41OTc1M0MxMS4zMjcxIDcuNDcxNjEgMTEuMzk4IDcuMjgyNzQgMTEuMzk4IDcuMDkzODdDMTEuMzk4IDYuNjkyNTIgMTEuMDk4OSA2LjQwMTM1IDEwLjY5NzYgNi40MDEzNUMxMC41MDg3IDYuNDAxMzUgMTAuMzM1NiA2LjQ3MjE4IDEwLjE3ODIgNi42MjE3TDUuMjQzOTYgMTEuNTQ4MUM1LjA4NjU3IDExLjcwNTUgNSAxMS44OTQzIDUgMTIuMDkxMUM1IDEyLjI4NzggNS4wODY1NyAxMi40NzY3IDUuMjQzOTYgMTIuNjI2MkwxMC4xNjI1IDE3LjUzNjhDMTAuMzM1NiAxNy43MDk5IDEwLjUwODcgMTcuNzgwOCAxMC42OTc2IDE3Ljc4MDhDMTEuMDk4OSAxNy43ODA4IDExLjM5OCAxNy40ODk2IDExLjM5OCAxNy4wODgzQzExLjM5OCAxNi44OTE1IDExLjMyNzEgMTYuNzEwNSAxMS4xOTM0IDE2LjU4NDZMOS41NDA3NSAxNC45MDA1TDcuMTMyNjYgMTIuNjk3TDguOTQyNjYgMTIuODA3MkgxNC4wNTc5QzE3LjU1OTkgMTIuODA3MiAxOSAxMS4yNDExIDE5IDcuNjc2MjJDMTkgNy4yMzU1MyAxOC45OTIxIDYuODY1NjUgMTguOTM3IDYuNjEzODNDMTguODc0MSA2LjI5OTA0IDE4LjY3NzMgNiAxOC4yNDQ1IDZaIiBmaWxsPSIjQjJCQ0NEIi8+Cjwvc3ZnPgo=";function qb(n,t,e,o){ym(Vb,[],e),b("br",[],e)}function Wb(n,t,e,o){return o==="text"?`
|
|
23
23
|
`:o==="html"?"<br>":o==="markdown"?`
|
|
24
24
|
`:""}const Lp={boxType:"br",updateBoxContent:qb,convertTo:Wb},Mp=w("editor-boxes");class Rp{constructor(t){h(this,"boxes",new Map);this.editor=t}registerBoxClass(t){const e=t.boxType,o=this.boxes.get(e);u(Mp,!o,`duplicated box type: ${e}`),this.boxes.set(e,t)}getBoxClass(t){const e=this.boxes.get(t);return u(Mp,e,`unknown box type: ${t}`),e}createBox(t,e){const o=cg(e),r=ug(o);return this.getBoxClass(e.type).updateBoxContent(this.editor,o,r,e),o}}function Gb(n,t,e,o){b("span",[],e,o.text)}const Op={insertionType:"inputting",updateInsertionContent:Gb},Np=w("editor-insertion");class Pp{constructor(t){h(this,"insertions",new Map);this.editor=t}registerInsertionClass(t){const e=t.insertionType,o=this.insertions.get(e);u(Np,!o,`duplicated insertion type: ${e}`),this.insertions.set(e,t)}getInsertionClass(t){const e=this.insertions.get(t);return u(Np,e,`unknown insertion type: ${t}`),e}createInsertion(t,e){const o=dg(e.type,e.id),r=fg(o);return this.getInsertionClass(e.type).updateInsertionContent(this.editor,o,r,e),o}}class Zb{constructor(t){h(this,"cursors",new Map);h(this,"timer");this.editor=t,this.timer=this.startTimer()}add(t,e){this.cursors.set(t,e)}startTimer(){return setInterval(()=>{const t=Date.now();Array.from(this.cursors).forEach(([e,o])=>{if(t-o>3e3){const r=hg(this.editor,e);r&&H(r,"active"),this.cursors.delete(e)}})},1e3)}destroy(){clearInterval(this.timer)}}function Qb(n,t,e,o){var l;const r=o;Date.now()-r.time<5*1e3&&(n.addCustom("active-cursors",a=>new Zb(a)).add(r.id,r.time),M(t,"active")),b("span",[],e,"|").setAttribute("data-cursor-name",r.name),t.style.setProperty("--cursor-color",n.getColor((l=r.rainbowIndex)!=null?l:0))}const Cd={insertionType:"remote-cursor",updateInsertionContent:Qb};class $p{constructor(t){h(this,"decorators",[]);this.editor=t}registerDecorator(t){this.decorators.push(t)}decorateBlock(t,e){let o=e;return this.decorators.forEach(r=>{if(r.decorateBlock){const i=r.decorateBlock(this.editor,t,e);i&&(o=Q.default(i))}}),o}decorateText(t,e){let o=e;const r=new Map;return this.decorators.forEach(i=>{if(i.decorateText){const s=i.decorateText(this.editor,t,e);if(s){const{insertions:l,text:c}=s;l&&Array.from(l.entries()).forEach(([a,d])=>{const f=r.get(a);f?f.push(...d):r.set(a,d)}),c&&(o=Q.default(c))}}}),{insertions:r,text:o}}}const Ad=w("editor-input");class Yb{constructor(t,e){h(this,"editor");h(this,"composing",!1);h(this,"callbacks");h(this,"inputElement");h(this,"handleDocumentSelectionChange",()=>{setTimeout(()=>{var e;const t=(e=document.getSelection())==null?void 0:e.focusNode;t&&this.editor.contains(t)&&!zi(t)?(this.editor.emit("focus",this.editor),this.callbacks.onFocus(),this.editor.input.focus()):(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});h(this,"handleEditorSelectionChanged",()=>{const e=!this.editor.isWritable();this.inputElement.readOnly=e});h(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});h(this,"handleCompositionstart",t=>{this.composing=!0,this.callbacks.onCompositionStart(t)});h(this,"handleCompositionend",t=>{this.composing=!1,this.callbacks.onUpdateCompositionText(t,this.inputElement.value,!0),this.inputElement.value=""});h(this,"handleInput",t=>{if(t instanceof InputEvent&&!!t.data){if(this.editor.readonly){this.inputElement.value="";return}this.composing?this.callbacks.onUpdateCompositionText(t,t.data,!1):(this.callbacks.onInsertText(t,t.data),this.inputElement.value="")}});h(this,"handleKeyDown",t=>{if(!this.composing){if(this.callbacks.onKeyDown(t)){t.preventDefault(),t.stopPropagation();return}!this.editor.isWritable()||setTimeout(()=>{this.composing||(this.inputElement.value="")})}});h(this,"handleCopy",t=>{this.callbacks.onCopy(t)});h(this,"handleCut",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}Ad.debug("on cut")});h(this,"handlePaste",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onPaste(t)});h(this,"handlePasteText",t=>{this.callbacks.onPasteText(t)});this.editor=t,this.callbacks=e;const o=b("input",["editor-input"],t.contentElement);o.type="text",o.name="editor-input",o.onkeydown=this.handleKeyDown,o.oninput=this.handleInput,o.oncopy=this.handleCopy,o.onpaste=this.handlePaste,o.oncut=this.handleCut,o.addEventListener("compositionstart",this.handleCompositionstart),o.addEventListener("compositionend",this.handleCompositionend),this.inputElement=o,document.addEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.addListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){this.callbacks.destroy(),document.removeEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.removeListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged);const t=this.inputElement;t.removeEventListener("compositionstart",this.handleCompositionstart),t.removeEventListener("compositionend",this.handleCompositionend),t.onkeydown=null,t.oninput=null,t.oncopy=null,t.onpaste=null,t.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),xt.isMobileSafari?this.inputElement.focus():setTimeout(()=>{this.inputElement.focus()})}handleChanged(t){this.callbacks.onChanged(t)}handleRemoteChanged(t){this.callbacks.onRemoteChanged(t)}addHandler(t){this.callbacks.addHandler(t)}removeHandler(t){this.callbacks.removeHandler(t)}defaultInsertText(t,e,o,r,i){u(Ad,t===this.editor,"invalid editor"),this.callbacks.defaultInsertText(t,e,o,r,i)}defaultHandleKeydown(t,e){return u(Ad,t===this.editor,"invalid editor"),this.callbacks.defaultHandleKeydown(t,e)}}function _p(n){const e=n.rootElement.getBoundingClientRect(),o=window.innerWidth,r=window.innerHeight,i=e.left<0?0:e.left,s=e.top<0?0:e.top,l=e.right>o?o:e.right,c=e.bottom>r?r:e.bottom,a=(i+l)/2,d=(s+c)/2,f=0-e.left+a,m=0-e.top+d,p=n.input.inputElement;p.style.left=`${f}px`,p.style.top=`${m}px`}const bd=w("editor-caret");class Jb{constructor(t){h(this,"editor");h(this,"caretElem");h(this,"handleReadOnlyChanged",()=>{this.update()});this.editor=t,this.caretElem=b("div",["editor-cursor"],this.editor.contentElement),this.editor.on("readonlyChanged",this.handleReadOnlyChanged)}destroy(){this.editor.off("readonlyChanged",this.handleReadOnlyChanged)}visible(){const t=window.getComputedStyle(this.caretElem);return t.display!=="none"&&t.opacity!=="0"}hasCaret(){if(this.editor.readonly||!this.editor.selection.range.isCollapsed())return!1;const t=this.editor.selection.range.start;if(!(t instanceof qt))return!1;const e=this.editor.getBlockById(t.blockId);return!!_(this.editor,e)}update(){if(Bm(this.editor.rootElement))return;const t=this.caretElem;if(this.hasCaret())t.style.display="";else{t.style.display="none",_p(this.editor);return}const{range:e}=this.editor.selection;u(bd,e.isCollapsed,"range is not collapsed");const o=e.start;u(bd,o instanceof qt,"only simple block position can has caret");const r=this.editor.getBlockById(o.blockId);u(bd,_(this.editor,r),"only text kind block can has caret");let i;const s=r.querySelector("span.inputting-insertion");s?(i=Vo(s),i=new DOMRect(i.right,i.top,1,i.height)):i=De(r,o);const l=this.editor.contentElement.getBoundingClientRect(),c=i.left-l.left,a=i.top-l.top;t.style.left=`${c}px`,t.style.top=`${a}px`,t.style.height=`${i.height}px`;const d=this.editor.input.inputElement;d.style.left=`${c}px`,d.style.top=`${a+i.height-24}px`,xt.isMobileSafari&&(d.style.left=`${c-4}px`,d.style.height=`${i.height}px`);const m=bn(r,{horizontal:!0}).getBoundingClientRect(),p=m.left-l.left,A=p+m.width;c<p||c>A?(_p(this.editor),t.style.display="none"):t.style.display=""}}function Kb(n){Ag(n),n.selection.range.getSelectedBlocks().forEach(t=>bg(n,t.block,t.start,t.end))}const Xb=w("editor-dom");function Fp(n){return bn(n.rootContainer).clientHeight}function tv(n){return n.getFirstBlock().getBoundingClientRect().top}function ev(n){return n.getLastBlock().getBoundingClientRect().bottom}function vd(n){const e=bn(n.rootContainer).getBoundingClientRect(),o=e.x<0?0:e.x,r=e.y<0?0:e.y,i=e.right>window.innerWidth?window.innerWidth:e.right,s=e.bottom>window.innerHeight?window.innerHeight:e.bottom;return new DOMRect(o,r,i-o,s-r)}function nv(n,t){const e=vd(n),o=n.getBlockById(t.blockId),i=Ye(n,o,t);return Wo(e,i.x,i.y)&&Wo(e,i.right,i.bottom)}function ov(n,t){const e=vd(n),o=t.getBoundingClientRect();return o.top>=e.top&&o.top<=e.bottom||o.bottom<=e.bottom&&o.bottom>=e.top}function rv(n,t){const e=vd(n),o=t.getBoundingClientRect();return Wo(e,o.x,o.y)||Wo(e,o.right,o.bottom)}function iv(n){if(!gu(n.rootContainer)){Xb.warn("editorScrollIntoView: editor is not visible");return}const t=n.rootContainer.getBoundingClientRect();if(t.height<1&&t.width<1)return;const e=n.selection,o=e.range.focus;if(!o.isSimple()){const d=o,f=n.getContainerById(d.childContainerId);rv(n,f)||f.scrollIntoView();return}if(e.range.start.blockId===e.range.end.blockId){const d=n.getBlockById(e.range.start.blockId);if(Te(d)&&ov(n,d))return}const r=o,i=n.getBlockById(r.blockId);if(nv(n,r))return;const s=Ye(n,i,r),l=i.getBoundingClientRect(),c=Rt(i),a=b("div",["editor-block-anchor"],c);a.style.top=`${s.top-l.top}px`,pu(a,{elementToScroll:bn(n.rootContainer)}),setTimeout(()=>{a.remove()},200)}function sv(n,t){if(t.isCollapsed())return!1;const e=Ft(n.rootContainer),o=Jt(n.rootContainer),{start:r,end:i}=t;return r.blockId===j(e)&&r.offset===0&&i.blockId===j(o)&&i.offset===G(n,o)}const Hp=w("range-in-block");function jp(n,t){const e=t.getEditor(),o=e.getBlockById(t.start.blockId),r=e.getBlockById(t.end.blockId),i=o===n||wt(n,o),s=r===n||wt(n,r);return!!(i||s)}function zp(n,t){const e=n.doc.toJSON(),o=new Set(Object.values(e.blocks).map(s=>s.map(l=>l.id)).flat());let r,i=bt(t);if(i){for(;i&&!o.has(j(i));)i=bt(i);u(Hp,i,"no prev block while deleting a block"),r=Ot(n,i,G(n,i))}else{const s=dt(t);u(Hp,s,"no prev and next block while deleting a block"),r=Ot(n,s,0)}return r}const lv=w("block-to-html");function yd(n,t,e,o){const r=Mr(n,t.type);if(r.convertTo)return r.convertTo(n,t,e,"html",o);if(r.blockKind!=="text")return`[${t.type}]`;u(lv,t.text,"no text");const i=vt(t.text);return`<div>${Tm(i)}</div>`}const Up=w("block-to-text");function cv(n,t,e){let o="";return t.forEach(r=>{if(u(Up,typeof r.insert=="string","invalid op"),r.attributes&&r.attributes.box===!0){const i=r.attributes,s=n.editorBoxes.getBoxClass(i.type);if(s!=null&&s.convertTo){o+=s.convertTo(n,i,e,"text");return}if(r.attributes.text){o+=r.attributes.text;return}o+=`[${i.type}]`}o+=r.insert}),o}function lc(n,t,e,o){const r=Mr(n,t.type);return r.convertTo?r.convertTo(n,t,e,"text",o):r.blockKind!=="text"?`[${t.type}]`:(u(Up,t.text,"no text"),cv(n,t.text,e))}function kd(n,t,e,o){const r=Mr(n,t.type);return r.convertTo?r.convertTo(n,t,e,"markdown",o):lc(n,t,e,o)}function ts(n,t){return t.blocks.root.map((r,i)=>yd(n,r,t,[{containerId:"root",blockIndex:i}])).join(`
|
|
25
25
|
`)}function Vp(n,t){return`<!doctype html><html><head><meta charset="utf8" /></head><body>${ts(n,t)}</body></html>`}function cc(n,t){return t.blocks.root.map((r,i)=>lc(n,r,t,[{containerId:"root",blockIndex:i}])).join(`
|
|
26
26
|
`)}function $r(n,t){return t.blocks.root.map((r,i)=>kd(n,r,t,[{containerId:"root",blockIndex:i}])).join(`
|
|
27
|
-
`)}const av=w("get-text-position");function _r(n,t){const e=t!=null?t:n.selection.range.start;e instanceof qt||u(av,!1,`invalid insert pos type: ${typeof e}`);const{blockId:o}=e,r=n.getBlockById(o),i=K(r),s=z(r),l=V(s),{offset:c}=e;return{block:r,container:s,containerId:l,blockIndex:i,offset:c}}const es=w("insert-text");function qp(n,t,e,o){var s;const r=n.doc.getBlockData(t,e);if(u(es,r,"no block data"),u(es,r.text,"no block text"),me(r.text)===0)return u(es,o===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,r.id);if(o===0)return;const i=Gt(r.text,o-1,1).middle;if(!((s=i[0].attributes)!=null&&s.box))return i[0].attributes}function uv(n,t,e){const o=z(t),r=V(o),i=K(t);return qp(n,r,i,e)}function Wp(n,t,e,o,r){const i=z(t),s=V(i),l=K(t),c=uv(n,t,e),a=Yl(e,o,c!=null?c:null);return n.doc.localUpdateBlockText(s,l,a,r),ge(n,t)}function Gp(n,t,e,o){const r=z(t),i=V(r),s=K(t),l=Yl(e," ",o);return n.doc.localUpdateBlockText(i,s,l),ge(n,t)}function wd(n,t,e,o,r){const i=n.doc.getBlockData(e,o);u(es,i,"no block data"),u(es,i.text,"no block text");const s=qp(n,e,o,r),l=Yl(r,t,s!=null?s:null);return n.doc.localUpdateBlockText(e,o,l),ge(n,n.getBlockById(i.id))}function Bd(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:e,blockIndex:o,offset:r}=_r(n);wd(n,t,e,o,r)}const ac=w("update-composition-text");function Zp(n){const t=n.selection.range.start;t instanceof qt||u(ac,!1,`invalid insert pos type: ${typeof t}`);const{blockId:e}=t,o=n.getBlockById(e);u(ac,_(n,o),"not a text kind block");const r=z(o),i=V(r),s=K(o),l=n.doc.getBlockData(i,s);u(ac,l,"no block data in doc"),u(ac,l.text,"no text data in text block");const c=st(o);Wl(n,ao(o),e,c,l.text)}function Qp(n){FA(n)}function Fr(n,t,e,o,r,i){return n.doc.localInsertBlock(t,e,o,r,i),n.getBlockById(o.id)}const ns=w("delete-block-text");function Ed(n,t,e,o,r){if(!n.isBlockWritable(t))return ns.error("block is not writable"),0;u(ns,_(n,t),"block is not a text kind block");const i=z(t),s=V(i),l=K(t),c=n.doc.getBlockData(s,l);u(ns,c,"no block data in doc"),u(ns,c.text,"no text data in text block");let a=e;le(t,e)||(a=go(t,a));let d=e+o;u(ns,d<=G(n,t),`invalid offset and count: ${e}, ${o}`),le(t,d)||(d=tr(t,d));const f=d-a,m=Xg(a,f);return n.doc.localUpdateBlockText(s,l,m,r),f}const Id=w("break-text-block");function Yp(n,t){const o=n.getBlockData(t).quoted;return o?{quoted:o}:{}}function Hr(n,t,e,o){u(Id,_(n,t),`block is not a text kind block: ${it(t)}`),u(Id,e>=0&&e<=G(n,t),`invalid offset: ${e}`);const r=z(t),i=V(r),s=K(t),l=o!=null&&o.copyBlockAttributes?Yp(n,t):{};if(!(o!=null&&o.forceInsertAfter)&&(e===0||e===G(n,t))){const p=e===0?s:s+1,A={...Vn(""),...l,...o==null?void 0:o.newBlockData},k=Ot(n,t.id,0),v=Fr(n,i,p,A,k);return{block:t,newBlock:v}}u(Id,le(t,e),"not a valid offset");const c=ge(n,t),{right:a}=ve(c,e),d=me(a);d>0&&Ed(n,t,e,d);const f={...Vn(a),...l,...o==null?void 0:o.newBlockData},m=Fr(n,i,s+1,f,Ot(n,f.id,0));return{block:t,newBlock:m}}const dv=w("prepare-insert-new-block");function hv(n,t,e){if(t&&e!==void 0&&e!==null){const a=n.getContainerById(t),d=Mt(a);return u(dv,e>=0&&e<=d.length,`invalid blockIndex: ${e}`),{containerId:t,blockIndex:e}}const o=n.selection.range.start;if(!o.isSimple())return null;const r=n.getBlockById(o.blockId);if(t=V(z(r)),e=K(r),!_(n,r))return{containerId:t,blockIndex:e+1};const s=o.offset;if(s===0||s===G(n,r))return{containerId:t,blockIndex:s===0?e:e+1};const c=Hr(n,r,s).newBlock;return{containerId:t,blockIndex:K(c)}}const fv=w("auto-insert-block");function Jp(n,t,e,o,r,i){const s=hv(n,e,o);u(fv,s,`not an valid insert position: ${n.selection.range}`);const l={blockId:t.id,offset:0},c={anchor:l,focus:l};return Fr(n,s.containerId,s.blockIndex,t,r!=null?r:c,i)}const mv=w("delete-block");function uc(n,t,e){t.children&&(e.push(...t.children),t.children.forEach(o=>{n.getChildContainerData(o).forEach(i=>{uc(n,i,e)})}))}function xd(n,t,e){const o=z(t),r=V(o),i=K(t),s=n.doc.getBlockData(r,i);return u(mv,s,"no block data in doc"),n.doc.localDeleteBlock(r,i,Wt(n,{anchor:e.start,focus:e.end})),s}function Td(n,t,e){return n.undoManager.runInGroup(()=>{const o=z(t);Ze(o)===1&&n.insertTextBlock("",V(o),0);let r=e?ho(n,e):null;if(!r){const l=n.selection.range;jp(t,l)?r=zp(n,t):r=l}const i=xd(n,t,r),s=[];return uc(n,i,s),s.length>0&&n.doc.localDeleteChildContainers(s),i})}function gv(n,t){const e=[t];n.doc.getContainerBlocks(t).forEach(r=>{uc(n,r,e)}),n.doc.localDeleteChildContainers(e)}function Kp(n,t){const e=[...t];t.forEach(o=>{n.doc.getContainerBlocks(o).forEach(i=>{uc(n,i,e)})}),n.doc.localDeleteChildContainers(e)}const Sd=w("merge-text-block");function Xp(n,t,e){u(Sd,_(n,t),"only text block can be merged"),u(Sd,_(n,e),"only text block can be merged");const o=Ao(n,t),r=Ao(n,e),i=o.text,s=r.text;u(Sd,i&&s,"block data has no text");const l=z(t),c=V(l),a=K(t),d=G(n,t),f=wd(n,s,c,a,d),m=Ot(n,t,me(i));return Td(n,e,m),f}const En=w("clear-selected-contents");function dc(n,t){u(En,_(n,t.block),"not a text kind block");const{start:e,end:o}=t;u(En,e.isSimple(),"not a simple block position"),u(En,o.isSimple(),"not a simple block position");const r=e.offset,i=o.offset;u(En,r<=i,`invalid delete text offset: ${r}, ${i}`),r!==i&&n.deleteTextFromBlock(t.block,r,i-r)}function t0(n,t,e){const o=V(t),r=Mt(t),i=e.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",o,0,{newRange:i});e.focus&&n.selection.selectBlock(s,0),r.reverse().forEach(l=>{n.deleteBlock(l)})}function pv(n,t){const{block:e,start:o,end:r}=t;if(_(n,e)){dc(n,t);return}if(Te(e)||o.isSimple()){u(En,r.isSimple(),"invalid range");const s=z(e),l=K(e),c=n.insertTextBlock("",V(s),l);n.selection.selectBlock(c,0),n.deleteBlock(e);return}u(En,at(n,e),"invalid block kind"),u(En,!o.isSimple()&&!r.isSimple(),"invalid range"),Rr(n,e,o,r),n.selection.range.getSelectedContainers().forEach((s,l)=>{t0(n,s,{focus:l===0})})}function Cv(n){if(!n.isWritable())return;const t=n.selection.range;if(t.isCollapsed())return;const e=t.getSelectedBlocks();if(u(En,e.length>0,"no selected block"),e.length===1){pv(n,e[0]);return}const o=e[0],r=o.block,i=z(r);u(En,e.length>1,"no selected block");const s=e[e.length-1],l=s.block;if(_(n,r)){dc(n,o);const d=Ot(n,o.block,o.start.offset);if(e.slice(1,e.length-1).reverse().forEach(m=>n.deleteBlock(m.block)),_(n,l)){dc(n,s),n.mergeTextBlock(r,l,{focus:!0}),n.selection.setRange(d);return}n.deleteBlock(l),n.selection.setRange(d);return}if(_(n,l)){dc(n,s),e.slice(0,e.length-1).reverse().forEach(d=>n.deleteBlock(d.block)),n.selection.selectBlock(s.block,0);return}if(e.length===Ze(i)){t0(n,i,{focus:!0});return}const c=bt(r),a=dt(l);u(En,c||a,"no prev or next block"),e.forEach(d=>n.deleteBlock(d.block))}function Dd(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n);try{n.doc.beginBatchUpdate(),Cv(n)}finally{n.doc.endBatchUpdate()}n.emit("afterClearSelection",n)})}const Av=w("core");function e0(n,t,e){const o=z(t),r=V(o),i=K(t);return n.doc.localUpdateBlockText(r,i,e),setTimeout(()=>{n.selection.updateSelection(null)}),ge(n,t)}function n0(n,t,e){if(!n.isBlockWritable(t)){Av.error("block is not writable");return}const o=n.getBlockText(t),r=ce.diff(o,e);e0(n,t,r)}function hc(n,t,e){const o=ge(n,t),r=typeof e=="string"?Co(e):e,i=ce.diff(o,r);return e0(n,t,i)}const os=w("update-block-data");function fc(n,t,e,o){const r=z(t),i=V(r),s=K(t),l=n.doc.getBlockData(i,s),c={insert:{},delete:[]},a=new Set(Object.keys(l)),d=new Set(Object.keys(e));return a.forEach(m=>{if(!d.has(m)){if(m==="id"||m==="type"||m==="text")return;os.debug(`delete key: ${m}`),c.delete.push(m)}}),Object.entries(e).forEach(([m,p])=>{u(os,m!=="id"&&m!=="type",`invalid block data delta, ${m}`);const A=l[m];if(p==null){A!=null&&(os.debug(`delete key: ${m}`),c.delete.push(m));return}A!==p&&(El.default(A,p)||m==="text"&&ce.diff(A,p).length===0||(a.has(m)?(os.debug(`replace key: ${m}`),c.delete.push(m)):os.debug(`insert key: ${m}`),c.insert[m]=p))}),n.doc.localUpdateBlockData(i,s,c,o),Ao(n,t)}function o0(n,t,e,o){const i={...n.getBlockData(t),embedData:e};return n.updateBlockData(t,i,o)}function Ld(n,t,e){if(!at(n,t)||!(e!=null&&e.tryFocusToChildSimpleBlock)){n.selection.selectBlock(t,0);return}const r=xe(n,t).getChildContainers(n,t)[0],i=Ft(r);Ld(n,i,e)}function rr(n){const t=[];let e={};return n.forEach(o=>{t.push(...o.blocks.root);const{root:r,...i}=o.blocks;e={...e,...i}}),{blocks:{...e,root:t},meta:{},comments:{}}}const rs=w("clone-block");function bo(n,t,e,o){const r=n.getBlockClass(e.type);if(r.blockToDoc)return r.blockToDoc(t,e,(d,f)=>(u(rs,e!==f,"invalid child block"),bo(n,d,e,o)));let i={};const s=new Map,l=Q.default(e);l.children&&(l.children=l.children.map(d=>{const f=P(),m=t.blocks[d];u(rs,Array.isArray(m),"invalid child blocks");const p=m.map(T=>bo(n,t,T,o)),A=rr(p),{root:k,...v}=A.blocks;return i={...i,...v},i[f]=A.blocks.root,s.set(d,f),f}));const c=Array.from(s.entries()),a=d=>{for(const f of c){const[m,p]=f;{const A=`${m}/`;if(d.startsWith(A)){const k=d.substring(A.length),v=`${p}/${k}`;return rs.debug(`replace key: ${d} -> ${v}`),v}}{const A=`${m}_`;if(d.startsWith(A)){const k=d.substring(A.length),v=`${p}_${k}`;return rs.debug(`replace key: ${d} -> ${v}`),v}}}return d};return Array.from(Object.entries(l)).forEach(([d,f])=>{const m=a(d);m!==d&&delete l.key,l[m]=f}),l.id=P(),o&&(o.blockIdMap.set(e.id,l.id),s.forEach((d,f)=>o.containerIdMap.set(f,d))),{blocks:{root:[l],...i},meta:{},comments:{}}}function Md(n,t,e,o){const r=t.blocks[e];u(rs,Array.isArray(r),"invalid child blocks");const i=r.map(l=>bo(n,t,l,o));return rr(i)}function Rd(n,t,e){const o=t.blocks.root.map(r=>bo(n.editorBlocks,t,r,e));return Q.default(rr(o))}const r0=w("insert-doc");function i0(n,t,e,o,r){if(at(n,t)){r0.warn("failed to insert doc into a complex block");return}const i=Rd(n,o,r),s=z(t),l=K(t),c=V(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var E,L,R;Object.entries(i.blocks).forEach(([$,q])=>{$!=="root"&&n.doc.localInsertChildContainer($,q)});const a=i.blocks.root;if(Te(t)){n.deleteBlock(t);let $;a.reverse().forEach(q=>{const ot=n.insertBlock(c,l,q);$||($=ot)}),$&&n.selection.selectBlock($,G(n,$));return}if(u(r0,_(n,t),"not a text block"),Tt(n,t)){const $=K(t);let q;a.forEach((ot,lt)=>{const gt=n.insertBlock(c,$+lt,ot);lt===a.length-1&&(q=gt)}),q&&n.selection.selectBlock(q,G(n,q));return}if(a.length===1){const $=a[0];if(Ui(n,$.type)){n.insertTextToBlock(t,e,(E=$.text)!=null?E:[]);return}n.breakTextBlock(t,e),n.insertBlock(c,l+1,$);return}const d=e===G(n,t),f=e===0,m=a[0],p=a[a.length-1];let A;!d&&!f?A=n.breakTextBlock(t,e,{forceInsertAfter:!0}):A=t;const k=f?l:l+1;d?(A=n.insertBlock(c,l+1,p),n.selection.selectBlock(A,G(n,A))):(n.selection.selectBlock(A,0),Ui(n,p.type)?n.insertTextToBlock(A,0,(L=p.text)!=null?L:[]):n.insertBlock(c,k,p));const v=n.selection.range;let T=k;Ui(n,m.type)?f?(n.insertBlock(c,k,m),T+=1):n.insertTextToBlock(t,e,(R=m.text)!=null?R:[]):(n.insertBlock(c,k,m),T+=1),a.slice(1,a.length-1).reverse().forEach($=>{n.insertBlock(c,T,$)}),n.selection.setRange(v)}),n.doc.endBatchUpdate()}function Od(n,t,e,o,r){const i=Rd(n,o,r),s=V(t),l=[];return n.undoManager.runInGroup(()=>{Object.entries(i.blocks).forEach(([a,d])=>{a!=="root"&&n.doc.localInsertChildContainer(a,d)}),i.blocks.root.reverse().forEach(a=>{const d=n.insertBlock(s,e,a);l.push(d)})}),l}function s0(n,t,e){const o=Ze(t);Od(n,t,o,e);for(let r=0;r<o;r++){const i=Ft(t);n.deleteBlock(i)}}const is=w("add-text-attribute");function bv(n,t,e,o){const{start:r,end:i}=e;u(is,r.blockId===i.blockId&&r.blockId===j(t),"invalid range"),u(is,o,"invalid attribute name");const s=n.getBlockText(t),l=Nr(r.offset,i.offset-r.offset,s,o,void 0,{ignoreValue:!0});return n.setBlockText(t,l),l}function l0(n,t,e,o,r){const{start:i,end:s}=e;u(is,i.blockId===s.blockId&&i.blockId===j(t),"invalid range"),u(is,o,"invalid attribute name");const l=n.getBlockText(t),c=Yi(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(t,c),c}function jr(n,t,e,o,r){const{start:i,end:s}=e;u(is,i.blockId===s.blockId&&i.blockId===j(t),"invalid range");const l=n.getBlockText(t),c=cp(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(t,c),c}function c0(n,t,e,o){const r=en(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:s,start:l,end:c}=i;if(!_(n,s))return;if(Tt(n,s)){o(n,j(s),t,e);return}const a=Wt(n,{anchor:l,focus:c});t==="color"||t==="backgroundColor"?jr(n,s,a,t,e):(jr(n,s,a,"color",null),jr(n,s,a,"backgroundColor",null))})})}function a0(n,t,e){const o=en(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{o.forEach(r=>{const{block:i,start:s,end:l}=r;if(!_(n,i))return;if(Tt(n,i)){(t==="clearColor"||t==="clearAll")&&e(n,j(i),"color",null),(t==="clearBackground"||t==="clearAll")&&e(n,j(i),"backgroundColor",null);return}const c=Wt(n,{anchor:s,focus:l});(t==="clearColor"||t==="clearAll")&&jr(n,i,c,"color",null),(t==="clearBackground"||t==="clearAll")&&jr(n,i,c,"backgroundColor",null)})})}function Nd(n,t){const e=en(n,{simpleBlockOnly:!0}).filter(s=>_(n,s.block));if(e.length===0)return[null,null];const o=s=>{if(G(n,s.block)===0)return t(n,j(s.block));const l=s.start,c=s.end,a=n.getBlockText(s.block);return dp(l.offset,c.offset-l.offset,a)};let[r,i]=o(e[0]);return r===null&&i===null?[r,i]:(e.forEach(s=>{const[l,c]=o(s);l===null||r===null?r=null:r=l===r?r:null,c===null||i===null?i=null:i=c===i?i:null}),[r,i])}const Le=w("adjust-selection-pos");function u0(n){const t=[];for(;n;){const e=z(n);if(t.unshift(e),Ct(e))return t;const o=U(e);u(Le,o,"child container has not parent container"),n=o}u(Le,!1,"should not come here: getParentContainers")}function d0(n,t){for(;t;){const e=z(t);if(e===n)return t;const o=U(e);u(Le,o,"could not find parent block for a child container"),t=o}u(Le,!1,"no parent block in specified container")}function vv(n,t){const e=u0(n),o=u0(t);u(Le,e.length>0&&o.length>0,"block has not parent container"),u(Le,e[0]===o[0],"root container does not equal");let r=e[0];for(let l=1;l<e.length||o.length;l++)if(e[l]!==o[l]){r=e[l-1];break}const i=d0(r,n),s=d0(r,t);return{parentContainer:r,newBlock1:i,newBlock2:s}}function h0(n,t){let e=U(t);for(u(Le,e,"element is not in a block");e;){const o=z(e);u(Le,Ke(o),"not a child container");const r=U(o);if(u(Le,r,"child container has not parent block"),r===n)return o;e=r}u(Le,!1,"failed to find parent container in complex block")}function mc(n,t,e){const o=n.getBlockById(t.blockId),r=n.getBlockById(e.blockId);if(o===r)return t instanceof qt&&e instanceof qt?{anchor:t,focus:e}:t instanceof Xe&&e instanceof Xe?Ul(n,o,t,e):null;const i=z(o),s=z(r);if(i===s)return t instanceof Xe&&(t=F(o,0,"home")),e instanceof Xe&&(e=F(r,G(n,r),"end")),u(Le,t instanceof qt,"not valid position type"),u(Le,e instanceof qt,"not valid position type"),{anchor:t,focus:e};if(o.contains(s))return null;if(r.contains(i)){if(t instanceof qt&&e instanceof Xe){const A=n.getContainerById(e.childContainerId);if(A===i)return{anchor:e,focus:e};const k=U(i);if(k&&k===U(A)){const v=Bt(k,V(i)),T=Bt(k,V(A));return Ul(n,k,v,T)}}return null}const l=Dl(o,r)>0,{newBlock1:c,newBlock2:a}=vv(o,r);if(c===a){const A=c,k=h0(A,o),v=h0(A,r);return t=Bt(c,V(k)),e=Bt(c,V(v)),Le.debug(`select in complex block: ${k.id}, ${v.id}`),Ul(n,A,t,e)}let d=l?G(n,c):0;c===o&&t instanceof qt&&(d=t.offset);let m=l?0:G(n,a);return a===r&&e instanceof qt&&(m=e.offset),t=F(c,d,l?"end":"home"),e=F(a,m,l?"home":"end"),{anchor:t,focus:e}}const yv=w("move-complex-block-position");function kv(n,t,e){const o=n.getBlockById(t.blockId);u(yv,at(n,o),"is not a complex block");const r=xe(n,o),i=n.getContainerById(t.childContainerId),s=r.getNextContainer(n,o,i,e,{noWrap:!0});return s?Bt(o,V(s)):null}const ss=w("move-simple-block-position");function f0(n,t){const e=Se(n,t);u(ss,e.length>0,"complex block has not any child container");const o=e[0];return Ft(o)}function m0(n,t){const e=Se(n,t);u(ss,e.length>0,"complex block has not any child container");const o=e[e.length-1];return Jt(o)}function g0(n,t,e){const o=e?f0(n,t):m0(n,t);return at(n,o)?g0(n,o,e):o}function wv(n,t){const e=n.getBlockById(t.blockId);return at(n,e)&&t.offset===0?f0(n,e):Lr(e)}function Bv(n,t){const e=n.getBlockById(t.blockId);return at(n,e)&&t.offset===1?m0(n,e):Dr(e)}function Pd(n){return n==="ArrowLeft"||n==="ArrowUp"}function $d(n,t,e){const o=z(t);if(Ct(o))return null;const r=U(o);u(ss,r,"child container has not parent block"),u(ss,at(n,r),"is not a complex block");const i=xe(n,r).getNextContainer(n,r,o,e);return i?Pd(e)?Jt(i):Ft(i):$d(n,r,e)}function Ev(n,t,e){const o=z(t);if(Ct(o))return null;const r=U(o);if(u(ss,r,"child container has not parent block"),Pd(e)){const l=bt(r);if(l)return l}else{const l=dt(r);if(l)return l}const i=$d(n,r,e);if(i)return i;let s=r;for(;!Ct(z(s));)s=U(z(s));return Pd(e)?bt(s):dt(s)}function Iv(n,t,e){return!at(n,t)||xe(n,t).enableKeyboardSelect?t:g0(n,t,e==="ArrowDown"||e==="ArrowRight")}function xv(n,t,e){const o=n.getBlockById(t.blockId),i=pt(n,o).moveCaret(n,o,t,e);if(i)return i;let s=e==="ArrowDown"||e==="ArrowRight"?wv(n,t):Bv(n,t);if(s||(s=$d(n,o,e),s||(s=Ev(n,o,e))),!s){if(e==="ArrowDown"||e==="ArrowRight"){if(n.readonly||!Ct(z(o)))return null;const l=n.insertTextBlock("",V(n.rootContainer),Ze(n.rootContainer));return F(l,0,"home")}return null}if(s=Iv(n,s,e),_(n,s)){const l=n.selection.getSuggestedCaretX();if(e==="ArrowDown")return JA(n,s,o,t,l);if(e==="ArrowUp")return YA(n,s,o,t,l)}return e==="ArrowLeft"||e==="ArrowUp"?F(s,G(n,s),"end"):e==="ArrowRight"||e==="ArrowDown"?F(s,0,"home"):null}function Tv(n,t,e){if(t==="ArrowLeft")return e.start;const o=e.end,r=n.getBlockById(o.blockId);if(_(n,r))return o;const i=dt(r);if(i)return F(i,0,"home");if(!Ct(z(r))||n.readonly)return o;const s=n.insertTextBlock("",V(n.rootContainer),Ze(n.rootContainer));return F(s,0,"home")}function Sv(n,t,e){const o=n.selection.range;let r;if(o instanceof Kt)e==="move"&&!o.isCollapsed()&&(t==="ArrowLeft"||t==="ArrowRight")?r=Tv(n,t,o):r=xv(n,o.getFocusedPos(),t);else if(r=kv(n,o.focus,t),e==="move"){const i=r!=null?r:o.focus,s=n.getContainerById(i.childContainerId);if(t==="ArrowLeft"||t==="ArrowUp"){const l=Jt(s);r=F(l,0,"home")}else{const l=Ft(s);r=F(l,G(n,l),"end")}}return r?e==="move"?{anchor:r,focus:r}:mc(n,o.anchor,r):null}function vo(n,t,e){const o=Sv(n,t,e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),(t==="ArrowLeft"||t==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function p0(n){return vo(n,"ArrowLeft","move"),!0}function C0(n){return vo(n,"ArrowRight","move"),!0}function A0(n){return vo(n,"ArrowUp","move"),!0}function b0(n){if(vo(n,"ArrowDown","move")||n.readonly)return!0;const t=n.getFocusedBlock(),e=z(t);if(Ct(e)||Jt(e)!==t)return!0;const o=n.rootContainer;return n.insertTextBlock("",V(o),Ze(o)),!0}function v0(n){return vo(n,"ArrowDown","select"),!0}function y0(n){return vo(n,"ArrowLeft","select"),!0}function k0(n){return vo(n,"ArrowRight","select"),!0}function w0(n){return vo(n,"ArrowUp","select"),!0}const B0=w("word-offset");function _d(n,t){const e=n.selection.range.focus;u(B0,e.isSimple(),"invalid range type");const o=n.getBlockById(e.blockId);if(Tt(n,o))return F(o,0,"home");if(e.offset===0||!_(n,o)){const s=bt(o);if(!s)return null;const l=F(s,G(n,s),"end");if(t==="select"&&_(n,s)){const c=dd(n,s,l.offset);return F(s,c,"normal")}return l}const r=dd(n,o,e.offset);return F(o,r,"normal")}function Fd(n,t){const e=n.selection.range.focus;u(B0,e.isSimple(),"invalid range type");const o=n.getBlockById(e.blockId);if(Tt(n,o))return F(o,0,"end");if(e.offset===G(n,o)||!_(n,o)){const s=dt(o);if(!s)return null;const l=F(s,0,"home");if(t==="select"&&_(n,s)){const c=hd(n,s,l.offset);return F(s,c,"end")}return l}const r=hd(n,o,e.offset);return F(o,r,"normal")}function E0(n){if(!n.selection.range.focus.isSimple())return!1;const e=_d(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function I0(n){if(!n.selection.range.focus.isSimple())return!1;const e=Fd(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function x0(n){if(!n.selection.range.focus.isSimple())return!1;const e=_d(n,"select");return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function T0(n){if(!n.selection.range.focus.isSimple())return!1;const e=Fd(n,"select");return e?(n.selection.setSelection(n.selection.range.anchor,e),n.selection.updateLastCaretRect(),!0):!1}w("find-block");function Hd(n,t){if(!at(n,t))return t;const o=xe(n,t).getChildContainers(n,t)[0],i=Mt(o)[0];return Hd(n,i)}function jd(n,t){if(!at(n,t))return t;const e=xe(n,t).getChildContainers(n,t),o=e[e.length-1],r=Mt(o),i=r[r.length-1];return jd(n,i)}function S0(n){const t=jd(n,Jt(n.rootContainer)),e=F(t,G(n,t),"end");return n.selection.setSelection(e),!0}function D0(n){const t=Hd(n,n.getFirstBlock()),e=F(t,0,"home");return n.selection.setSelection(e),!0}function L0(n){const t=Hd(n,n.getFirstBlock()),e=F(t,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function zd(n){const t=jd(n,Jt(n.rootContainer)),e=F(t,G(n,t),"end");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}const M0=w("line-offset");function R0(n){const t=n.selection.range.focus;u(M0,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===0||!_(n,e))return F(e,0,"home");let r=Zg(e,t).start;const{next:i}=ql(e,r);return i&&Pe(i)&&ji(i)==="br"&&(r+=1),F(e,r,"home")}function O0(n){const t=n.selection.range.focus;u(M0,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===G(n,e)||!_(n,e))return F(e,G(n,e),"end");const o=Zg(e,t);return F(e,o.end,"end")}function N0(n){if(!n.selection.range.focus.isSimple())return!1;const e=R0(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function P0(n){if(!n.selection.range.focus.isSimple())return!1;const e=O0(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function $0(n){if(!n.selection.range.focus.isSimple())return!1;const e=R0(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function _0(n){if(!n.selection.range.focus.isSimple())return!1;const e=O0(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}const F0=w("find-block-position");function Dv(n,t,e,o){u(F0,at(n,t),"is not a complex block");const r=xe(n,t).getChildContainers(n,t);u(F0,r.length>0,"complex block has not any child container");const i=Ye(n,e,o),s=i.left+i.width/2,l=i.top+i.height/2,c=Pg(n,t,s,l);return Ud(n,c,e,o)}function Ud(n,t,e,o){if(at(n,t))return Dv(n,t,e,o);const r=j(t);let i=Number.MAX_SAFE_INTEGER;const s=Ye(n,e,o),l=s.left+s.width/2,c=s.top+s.height/2;let a=F(r,0,"home");const d=G(n,t);for(let f=0;f<=d;f++){const m=F(r,f,"normal"),p=Ye(n,t,m),A=An(p,l,c);A<i&&(i=A,a=m)}return a}const H0=w("page-offset");function Lv(n,t){const e=Fp(n)*.9,r=t.getBoundingClientRect().bottom-e;if(r<tv(n))return n.getFirstBlock();const i=bt(t);if(!i)return n.getFirstBlock();let s=i;for(;s;){if(s.getBoundingClientRect().y<r)return s;s=bt(s)}return n.getFirstBlock()}function Mv(n,t){const e=Fp(n)*.9,o=t.getBoundingClientRect(),r=ev(n),i=o.top+e;if(i>r)return n.getLastBlock();const s=dt(t);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>i)return l;l=dt(l)}return n.getLastBlock()}function j0(n){const t=n.selection.range.focus;u(H0,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),o=Lv(n,e);let r;return o===n.getFirstBlock()?r=F(o,0,"home"):r=Ud(n,o,e,t),r}function z0(n){const t=n.selection.range.focus;u(H0,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),o=Mv(n,e);let r;return o===n.getLastBlock()?r=F(o,G(n,o),"end"):r=Ud(n,o,e,t),r}function U0(n){if(!n.selection.range.focus.isSimple())return!1;const e=j0(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function V0(n){if(!n.selection.range.focus.isSimple())return!1;const e=z0(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function q0(n){if(!n.selection.range.focus.isSimple())return!1;const e=j0(n);if(!e)return!1;const o=mc(n,n.selection.getAnchorPos(),e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}function W0(n){if(!n.selection.range.focus.isSimple())return!1;const e=z0(n);if(!e)return!1;const o=mc(n,n.selection.getAnchorPos(),e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}const ls=w("select-all");function G0(n,t){const e=Ft(n),o=Jt(n);return t.start.offset===0&&t.start.blockId===j(e)&&t.end.offset===G(t.getEditor(),o)&&t.end.blockId===j(o)}function Rv(n,t){const e=t.getEditor(),o=xe(e,n).getChildContainers(e,n),r=o[0],i=o[o.length-1],s=j(n);return t.start.blockId===s&&t.start.childContainerId===V(r)&&t.end.blockId===s&&t.end.childContainerId===V(i)}function Ov(n,t){u(ls,t,"no parent block"),u(ls,at(n,t),"not a complex block");const e=xe(n,t).getChildContainers(n,t),o=e[0],r=e[e.length-1];n.selection.setRange(Wt(n,{anchor:Bt(t,V(o)),focus:Bt(t,V(r))}))}function Z0(n,t){const e=z(t);Vd(n,e)}function Q0(n){const t=n.getFocusedBlock(),e=n.selection.range;if(e.start.isSimple()){if(e.start.blockId===e.end.blockId&&_(n,t)){const r=e.start,i=e.end,s=G(n,t);if(r.offset>0||i.offset<s)return n.selection.selectBlock(t,0,s),!1}return M(n.rootContainer,"select-all"),Z0(n,Ft(n.rootContainer)),!1}return u(ls,!e.isSimple(),"invalid range type"),Rv(t,e)?(Z0(n,t),!1):(u(ls,t,"no parent block"),u(ls,at(n,t),"not a complex block"),Ov(n,t),!0)}function Vd(n,t){const e=Mt(t),o=e[0],r=e[e.length-1],i=F(o,0,"home"),s=F(r,G(n,r),"end");n.selection.setSelection(i,s,{noScroll:!0})}function Y0(n){zd(n),n.focus()}const qd=w("selected-block-to-doc");function J0(n,t,e){!t.children||t.children.forEach(o=>{const r=n.getChildContainerData(o);r.forEach(i=>{J0(n,i,e)}),e.blocks[o]=Q.default(r)})}function gc(n,t){const e=pt(n,t.block);if(e.selectionToDoc)return e.selectionToDoc(n,t);const o=Q.default(Ao(n,t.block));if(_(n,t.block)){const i=t.start,s=t.end;if(u(qd,o.text,"no block text"),i.offset===s.offset)return{blocks:{root:[{...o,text:[]}]},meta:{},comments:{}};const{middle:l}=Gt(o.text,i.offset,s.offset-i.offset);return{blocks:{root:[{...o,text:l}]},meta:{},comments:{}}}if(Te(t.block))return{blocks:{root:[o]},meta:{},comments:{}};u(qd,at(n,t.block),"not complex block"),u(qd,o.children,"no children");const r={blocks:{root:[o]},meta:{},comments:{}};return J0(n,o,r),r}function Wd(n,t){const e=F(t,0,"normal"),o=F(t,G(n,t),"end");return gc(n,{block:t,start:e,end:o})}const Nv=w("block-to-doc");function Pv(n,t){u(Nv,t.length>0,"invalid params, no blocks");const e=t.map(o=>Wd(n,o));return rr(e)}function cs(n){const e=n.selection.range.getSelectedBlocks().map(o=>gc(n,o));return rr(e)}function K0(n,t){const e=n.getContainerById(t),i=Mt(e).map(s=>({start:F(s,0,"home"),end:F(s,G(n,s),"end"),block:s})).map(s=>gc(n,s));return rr(i)}const pc=w("editor-selection");class $v{constructor(t){h(this,"editor");h(this,"caret");h(this,"_range");h(this,"lastCaretRect");h(this,"handleBlockDelete",(t,e,o,r)=>{if(o||r.child)return;const i=this.range;if(jp(e,i)){pc.debug("adjust selection because remote deleted current block");const s=zp(t,e);this.setRange(s,{noScroll:!0})}});this.editor=t;const e=t.getFirstBlock(),o=j(e);this.caret=new Jb(t);const r=F(o,0,"normal");this._range=Wt(t,{anchor:r,focus:r}),this.lastCaretRect=null,this.editor.addListener("blockDeleted",this.handleBlockDelete),setTimeout(()=>{this.updateFocusedBlock(null)})}destroy(){this.caret.destroy()}get range(){return this._range}get focusedBlock(){return this.getFocusedBlock()}get startBlock(){return this.getStartBlock()}get endBlock(){return this.getEndBlock()}getFocusedBlock(){const t=this.range.focus;return this.editor.getBlockById(t.blockId)}getStartBlock(){const t=this.range.start;return this.editor.getBlockById(t.blockId)}getEndBlock(){const t=this.range.end;return this.editor.getBlockById(t.blockId)}selectBlock(t,e,o){const r=F(t,e,"normal");let i;o&&(i=F(t,o,"normal")),this.setSelection(r,i)}setSelection(t,e,o){if(e||(e=t),this.verifyPos(t),this.verifyPos(e),!this.selectionChanging(t,e))return this.range;const r=Wt(this.editor,{anchor:t,focus:e});if(this.range.isEqual(r))return this.range;const i=this._range;return this._range=r,this.selectionChanged(),this.updateFocusedBlock(i),rt(this.editor.rootContainer,"select-all")&&(!r.isSimple()||!sv(this.editor,r))&&H(this.editor.rootContainer,"select-all"),o!=null&&o.noScroll||this.scrollIntoView(),this.range}setRange(t,e){return this.setSelection(t.anchor,t.focus,e)}updateSelection(){this.caret.update(),Kb(this.editor)}getFocusedPos(){return this.range.focus}getAnchorPos(){return this.range.anchor}selectionChanging(t,e){return!0}selectionChanged(){this.updateSelection(),this.editor.emit("selectionChanged",this.editor)}updateLastCaretRect(){const t=this.range.focus;if(!uo(t))return;const e=this.editor.getBlockById(t.blockId);this.lastCaretRect=Ye(this.editor,e,t)}getSuggestedCaretX(){var t;return(t=this.lastCaretRect)==null?void 0:t.x}scrollIntoView(){iv(this.editor)}verifyPos(t){const e=this.editor.getBlockById(t.blockId);if(t.isSimple())t.offset>=0&&t.offset<=G(this.editor,e)||u(pc,!1,"invalid block position, out of range");else{const o=t.childContainerId;!!this.editor.getContainerById(o)||u(pc,!1,"invalid complex block position, no container found")}}updateFocusedBlock(t){if(t&&this.range.start.blockId===t.start.blockId)return;let e;t&&t.start.blockId===t.end.blockId&&(e=this.editor.findBlockById(t.start.blockId));let o;(this.range.isCollapsed()||!this.range.isSimple()||this.range.start.blockId===this.range.end.blockId)&&(o=this.editor.getBlockById(this.range.start.blockId));let r=!1;e&&rt(e,"focused")&&(H(e,"focused"),r=!0),this.removeAllBlockFocusedClass(),o&&this.setBlockFocused(o)&&(r=!0),r&&this.editor.emit("focusBlockChanged",this.editor,o!=null?o:null,e!=null?e:null)}verify(){this.verifyPos(this._range.start),this.verifyPos(this._range.end)}to(t){const e=cs(this.editor);return t==="text"?cc(this.editor,e):t==="markdown"?$r(this.editor,e):Vp(this.editor,e)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(t=>{H(t,"focused"),H(t,"child-focused")})}setBlockFocused(t){if(rt(t,"focused"))return!1;M(t,"focused");let e=z(t);for(;Ke(e);){const o=U(e);u(pc,o,"parent block not found"),M(o,"child-focused"),e=z(o)}return!0}}function _v(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);!e||n.selection.selectBlock(e,0,G(n,e))}function Fv(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);if(!e||!_(n,e))return;let o=_d(n,"select"),r=Fd(n,"select");if(!o||!r)return;const i=t.blockId;o.blockId!==i&&(o=F(e,0,"home")),r.blockId!==i&&(r=F(e,G(n,e),"end")),n.selection.setSelection(o,r)}class Hv{constructor(t){h(this,"editor");h(this,"startPos",null);h(this,"lastCaretRect");h(this,"mouseDownEvent",null);h(this,"handleMouseDown",t=>{this.mouseDownEvent=t;const e=Fg(this.editor,t.x,t.y);if(e){if(e instanceof tn)return;const o=this.editor.selection.range;if(t.shiftKey&&o.isSimple()){const r=o.anchor;this.editor.selection.setSelection(r,e.focus),this.startPos=e.start}else this.editor.selection.setSelection(e.anchor,e.focus),this.startPos=e.start;this.editor.selection.updateLastCaretRect()}});h(this,"handleMouseMove",t=>{if(!this.startPos||!this.mouseDownEvent||Math.abs(this.mouseDownEvent.x-t.x)<3&&Math.abs(this.mouseDownEvent.y-t.y)<3)return;const e=Vl(this.editor,t.x,t.y);if(!e)return;const o=mc(this.editor,this.startPos,e.end);if(!o)return;const{anchor:r,focus:i}=o;this.editor.selection.setSelection(r,i)});h(this,"handleMouseUp",t=>{this.startPos=null});this.editor=t,this.startPos=null,this.lastCaretRect=new DOMRect}isSelecting(){return this.startPos!==null}stopSelection(){this.startPos=null}handleDblClick(t){Fv(this.editor)}handleTripleClick(t){_v(this.editor)}}function jv(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function zv(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const X0=w("delete-text");function t2(n,t,e,o){const r=o!=null?o:n.selection.range.start;r instanceof qt||u(X0,!1,`invalid insert pos type: ${typeof r}`);const{blockId:i}=r,s=n.getBlockById(i);u(X0,_(n,s),"block is not a text kind block");let{offset:l}=r;if(t==="backward"){if(l-e<0)return 0;if(!le(s,l-e)){const c=go(s,l);e=l-c}}else if(t==="forward"&&l+e>G(n,s))return 0;return t==="backward"&&(l-=e),n.deleteTextFromBlock(s,l,e)}function e2(n,t){if(n.getBlockData(t).quoted){const e={quoted:null};return n.updateBlockData(t,e),!0}return!1}const Uv=w("handle-backspace");function Gd(n,t){if(!Tt(n,t))return;const e=z(t);Ze(e)!==1&&n.deleteBlock(t)}function Vv(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,o=n.getBlockById(e.blockId);if(_(n,o))if(e.offset===0){if(e2(n,o))return;const r=bt(o);if(r){if(!n.isBlockWritable(r))return;if(_(n,r))n.mergeTextBlock(r,o,{focus:!0});else if(at(n,r)){Gd(n,o);const i=Vi(n,r);i?n.selection.selectBlock(i,G(n,i)):n.selection.selectBlock(r,0,G(n,r))}else Gd(n,o),u(Uv,Te(r),"prev block is not embed block"),n.selection.selectBlock(r,1)}else{const i=z(o);if(Ke(i)){const s=Rg(n,i);if(s){if(!n.isBlockWritable(s))return;Gd(n,o),n.selection.selectBlock(s,G(n,s))}}}}else t2(n,"backward",1,null),n.selection.updateLastCaretRect();else{const r=K(o),i=z(o);n.insertTextBlock("",V(i),r),n.deleteBlock(o)}}function qv(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,o=n.getBlockById(e.blockId);if(_(n,o))if(e.offset===G(n,o)){const r=dt(o);if(r){if(!n.isBlockWritable(r))return;_(n,r)?n.mergeTextBlock(o,r,{focus:!0}):Tt(n,o)?n.deleteBlock(o,Ot(n,r,0)):n.deleteBlock(r)}}else t2(n,"forward",1,null);else{const r=K(o),i=z(o);n.insertTextBlock("",V(i),r),n.deleteBlock(o)}}function Wv(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const e=n.getFocusedBlock();if(_(n,e)){if(Tt(n,e)&&e2(n,e))return;const o=n.selection.range.start,r=n.breakTextBlock(e,o.offset,{copyBlockAttributes:!0});o.offset!==0?n.selection.selectBlock(r,0):n.selection.scrollIntoView()}else{const o=n.insertTextBlock();n.selection.selectBlock(o,0)}}function Gv(n,t){const e=n.selection.range.getSelectedBlocks()[0],{block:o}=e;if(!_(n,o))return!1;const r=e.end;return n.insertBoxToBlock(o,r.offset,{type:"br",id:P(),box:!0,created:Date.now()}),!0}const Zv=w("input-handler-actions");function Qv(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(Wv(n),!0))}function Yv(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(qv(n),!0))}function Jv(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(Vv(n),!0))}function Kv(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(Gv(n),!0))}function Xv(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(t=>{n.input.handlePasteText(t)}).catch(t=>{Zv.error(t)}),!0)}function n2(n,t,e){if(t.type==="embed"){const s=t.embedData.src;s&&typeof s=="string"&&e.add(s);return}const o=t.text;o&&o.forEach(i=>{i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"&&e.add(i.attributes.src)});const r=t.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{n2(n,l,e)})})}function ty(n,t){const e=new Set;return t.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.getResources?i.getResources(r).forEach(s=>{e.add(s)}):n2(t,r,e)}),Array.from(e)}function as(n,t){return`<!doctype html><html><head><meta charset="utf8" />${`<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${Zo(JSON.stringify(t))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function us(n,t){var i,s,l;const e=(l=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i))!=null?l:{},o=ty(n,t),r={};o.forEach(c=>{const a=n.doc.buildResourceUrl(c,{withToken:!0});r[c]=a}),t.meta={...e,resources:r}}function ey(n,t,e){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;let o=cs(n);const r=e==null?void 0:e(n,t,o);if(r===!0)return;typeof r=="object"&&r!==null&&(o=r),us(n,o);const i=ts(n,o),s=$r(n,o),l=as(i,o);t.clipboardData.setData("text/html",l),t.clipboardData.setData("text/plain",s),t.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(o))}function ny(n){if(n.selection.range.isCollapsed())return;const t=cs(n);us(n,t);const e=ts(n,t),o=as(e,t),r=$r(n,t),i=new Blob([o],{type:"text/html"});Nl([{type:"text/plain",data:new Blob([r],{type:"text/plain"})},{type:"text/html",data:i}])}async function Cc(n,t){const e=Wd(n,t);us(n,e);const o=ts(n,e),r=$r(n,e),i=as(o,e);return Nl([{type:"text/plain",data:new Blob([r],{type:"text/plain"})},{type:"text/html",data:new Blob([i],{type:"text/html"})}])}function oy(n){return ny(n),Dd(n),!0}const Ac={ArrowDown:b0,ArrowUp:A0,ArrowLeft:p0,ArrowRight:C0,"Shift+ArrowDown":v0,"Shift+ArrowUp":w0,"Shift+ArrowLeft":y0,"Shift+ArrowRight":k0,"CtrlOrCmd+ArrowLeft":E0,"CtrlOrCmd+ArrowRight":I0,"CtrlOrCmd+Shift+ArrowLeft":x0,"CtrlOrCmd+Shift+ArrowRight":T0,"CtrlOrCmd+ArrowUp":D0,"CtrlOrCmd+ArrowDown":S0,"CtrlOrCmd+Shift+ArrowUp":L0,"CtrlOrCmd+Shift+ArrowDown":zd,"CtrlOrCmd+A":Q0,Home:$0,End:_0,"Shift+Home":N0,"Shift+End":P0,PageUp:U0,PageDown:V0,"Shift+PageUp":q0,"Shift+PageDown":W0,"CtrlOrCmd+X":oy,"CtrlOrCmd+Z":jv,"CtrlOrCmd+Shift+Z":zv,Enter:Qv,Delete:Yv,Backspace:Jv,"Shift+Enter":Kv,"CtrlOrCmd+Shift+V":Xv};function o2(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function r2(n,t,e){if(t.type==="embed"){const i=t.embedData,s=i.src;if(s&&typeof s=="string"){const l=e.get(s);l&&(i.src=l)}return}const o=t.text;o&&o.forEach(i=>{if(i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"){const s=e.get(i.attributes.src);s&&(i.attributes.src=s)}});const r=t.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{r2(n,l,e)})})}function i2(n,t,e){if(e.size===0)return;t.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.replaceResources?i.replaceResources(r,e):r2(t,r,e)})}async function ry(n,t){const e=t.filter(i=>i.indexOf(":")===-1),o=await n.doc.addResources(e),r=new Map;if(e.length!==o.length)return r;for(let i=0;i<e.length;i++)r.set(e[i],o[i]);return r}function iy(n,t){var i,s;const o=t.meta.serverId;if(!o||typeof o!="string")return!1;const r=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i);return!(!r||r.serverId!==o)}async function sy(n,t){const o=t.meta.resources;if(!o||Object.keys(o).length===0)return;let r=new Map;if(iy(n,t)){const s=Array.from(Object.keys(o));r=await ry(n,s),i2(n,t,r)}const i=new Map;Object.entries(o).forEach(([s,l])=>{r.get(s)===void 0&&s!==l&&i.set(s,l)}),i.size!==0&&i2(n,t,i)}async function ly(n,t){await sy(n,t),n.undoManager.runInGroup(()=>{n.clearSelectedContents();const{block:e,offset:o}=_r(n);n.insertDoc(e,o,t)})}const cy=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function ay(n){let t;for(const e of cy)if(t=n[e],t)break;return t||null}class uy{constructor(t){h(this,"editor");h(this,"handlers",[]);h(this,"onPasteText",async t=>{const e=new DataTransfer;e.setData("text/plain",t);const o=await this.editor.dataConverter.fromData(this.editor,e);o&&this.pasteDocs(o,null)});this.editor=t}onInsertText(t,e){if(!_(this.editor,this.editor.getFocusedBlock()))return;const{containerId:o,blockIndex:r,offset:i}=_r(this.editor);this.handleBeforeInsertText(o,r,i,e)||(this.defaultInsertText(this.editor,o,r,i,e),this.handleAfterInsertText(o,r,i,e),this.editor.selection.updateLastCaretRect())}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];o.handleChanged&&o.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];o.handleRemoteChanged&&o.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:o,offset:r}=_r(this.editor);for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];s.handleCompositionStart&&s.handleCompositionStart(this.editor,e,o,r)}}onUpdateCompositionText(t,e,o){this.editor.updateCompositionText(e,o),this.editor.selection.caret.update();const{containerId:r,blockIndex:i,offset:s}=_r(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,r,i,s,o)}this.editor.selection.updateLastCaretRect()}onCopy(t){ey(this.editor,t,(e,o,r)=>{for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeCopy){const l=s.handleBeforeCopy(this.editor,o,r);if(l===!0)return!0;if(typeof l=="object"&&l!=null)return l}}})}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;this.editor.dataConverter.fromData(this.editor,t.clipboardData).then(async o=>{o&&this.pasteDocs(o,t)})}onFocus(){M(this.editor.rootElement,"active")}onBlur(){H(this.editor.rootElement,"active")}addHandler(t){this.handlers.push(t)}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,t,e,o,r))return!0}return!1}handleAfterInsertText(t,e,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,t,e,o,r))return!0}return!1}handleBeforeKeyDown(t){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,o,r,i){Bd(this.editor,i)}defaultHandleKeydown(t,e){return o2(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];if(o.handleBeforePasteDoc&&await o.handleBeforePasteDoc(this.editor,t))return}await ly(this.editor,t);for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];if(o.handleAfterPasteDoc&&await o.handleAfterPasteDoc(this.editor,t))return}}async pasteDocs(t,e){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePaste&&await i.handleBeforePaste(this.editor,e,t))return}const o=ay(t);if(!!o){await this.pasteDoc(o);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPaste&&await i.handleAfterPaste(this.editor,e,t))return}}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}}function dy(n,t,e){const o=Sr(t,e);return o.remove(),o}w("copy-dom-attributes");const s2=["onabort","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onauxclick","onblur","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","ongotpointercapture","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onlostpointercapture","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onpause","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointermove","onpointerout","onpointerover","onpointerup","onprogress","onratechange","onreset","onresize","onscroll","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectionchange","onselectstart","onslotchange","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onvolumechange","onwaiting","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel"];function hy(n,t){for(let l=0;l<s2.length;l++){const c=s2[l];t[c]=n[c]}const e=n.attributes,o=t.attributes,r=[],i=[];for(let l=0;l<e.length;l++){const c=e[l],a=o.getNamedItem(c.name);a?a.value!==c.value&&(a.value=c.value,i.push(c)):r.push(c)}const s=[];for(let l=0;l<o.length;l++){const c=o[l];e.getNamedItem(c.name)||s.push(c)}r.forEach(l=>{t.setAttribute(l.name,l.value)}),i.forEach(l=>{t.setAttribute(l.name,l.value)}),s.forEach(l=>{t.removeAttribute(l.name)})}function l2(n){const t=Array.from(n.childNodes);return t.forEach(e=>{e instanceof HTMLElement&&e.getAttribute("data-type")==="block-tools"||e.remove()}),t}function c2(n,t,e){var a;const o=n.getContainerById(t),r=Sr(o,e),i=ao(r),s=n.doc.getBlockData(t,e),l=pt(n,r);if((a=l==null?void 0:l.handleUpdateBlock)==null?void 0:a.call(l,n,r,s))n.editorBlockRenders.updateBlock(n,i,r,s);else{const d=n.editorBlocks.createBlock(i,o,s),f=l2(d);l2(r),f.forEach(p=>r.appendChild(p));const m=Hl(d);if(m){const p=Hl(r);p&&p.remove(),r.appendChild(m)}hy(d,r)}yg(n,r,s),n.blockHooks.forEach(d=>{var f;(f=d.update)==null||f.call(d,n,i,o,r,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const fy=w("transform-selection");function a2(n,t,e,o){const{range:r}=n.selection,{anchor:i,focus:s}=r;if(i.blockId!==t&&s.blockId!==t)return r;u(fy,i.isSimple()&&s.isSimple(),"invalid text pos type");let l=i;if(i.blockId===t){const a=ce.transformCursor(i.offset,e,o);l=F(t,a,"normal")}let c=s;if(s.blockId===t){const a=ce.transformCursor(s.offset,e,o);c=F(t,a,"normal")}return Wt(n,{anchor:l,focus:c})}const my=w("handle-block-text-changed");function gy(n,t,e,o,r){const i=n.getContainerById(t),s=Sr(i,e),l=n.doc.getBlockData(t,e);if(u(my,l.text,"no block text"),gg(n,s).setBlockText(n,s,l.text),!r){const c=a2(n,l.id,o,r);n.selection.setRange(c,{noScroll:!0})}}function py(n,t){const e=Q.default(n);return t.delete.forEach(r=>{delete e[r]}),{...e,...t.insert}}function u2(n,t,e,o){const r=pt(n,t);r.handleDeleteBlock&&r.handleDeleteBlock(n,t,e,o),n.emit("blockDeleted",n,t,e,o)}function Cy(n,t,e,o){const r=n.getBlockByIndex(t,e);r.querySelectorAll('[data-type="editor-block"]').forEach(i=>{u2(n,i,o,{child:!0})}),u2(n,r,o,{child:!1})}const on=w("editor-doc");class Ay extends Pi{constructor(e,o,r){super();h(this,"localEvents",[]);this.editor=e,this.externalDoc=o,this.externalDoc.registerCallback(this),this.registerLocalEvents(r)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var o,r;return(r=(o=this.externalDoc).getVersionHelper)==null?void 0:r.call(o)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}getBlockData(e,o){return this.externalDoc.getBlockData(e,o)}verifyBlockWritable(e,o){const r=this.editor.getBlockByIndex(e,o);u(on,this.editor.isBlockWritable(r),`block is not writable, ${e}, ${o}`)}localUpdateBlockText(e,o,r,i){u(on,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,o);const s=this.getBlockData(e,o),l=s.text;u(on,l,`no text, ${e}, ${o}`);const c=a2(this.editor,s.id,r,!0),a=ce.apply(l,r);this.localEvents.forEach(f=>f.onBeforeUpdateBlockText(e,s.id,l,a,c.toDocRange()));const d=this.externalDoc.localUpdateBlockText(e,o,r);return this.editor.selection.setRange(c,i),d}localUpdateBlockData(e,o,r,i){u(on,!this.editor.readonly,"editor is readonly");const s=this.editor.getBlockByIndex(e,o);this.editor.isBlockWritable(s)||u(on,!1,`block is not writable, ${JSON.stringify(r)}}`);const l=Q.default(this.getBlockData(e,o)),c=Q.default(py(l,r));this.localEvents.forEach(d=>d.onBeforeUpdateBlockData(e,l.id,l,c,i));const a=this.externalDoc.localUpdateBlockData(e,o,r,i);return this.editor.selection.setRange(ho(this.editor,i)),a}localInsertBlock(e,o,r,i,s){u(on,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(c=>c.onBeforeInsertBlock(e,o,r,i));const l=this.externalDoc.localInsertBlock(e,o,r,i);return this.editor.selection.setRange(ho(this.editor,i),s),l}localDeleteBlock(e,o,r){u(on,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,o);const i=Q.default(this.getBlockData(e,o));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,o,i,r));const s=this.externalDoc.localDeleteBlock(e,o,r);return this.editor.selection.setRange(ho(this.editor,r)),s}localDeleteChildContainers(e){return u(on,!this.editor.readonly,"editor is readonly"),e.forEach(o=>{const r=Q.default(this.getContainerBlocks(o));this.localEvents.forEach(i=>i.onBeforeDeleteChildContainer(o,r))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainer(e,o){return u(on,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(r=>r.onBeforeInsertChildContainer(e,Q.default(o))),this.externalDoc.localInsertChildContainer(e,o)}onRequestReload(e){on.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,e)});const o=!1;this.editor.emit("docChanged",this.editor,o)}onUpdateBlockText(e,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,e,o,r,i)}),gy(this.editor,e,o,r,i),this.editor.emit("docChanged",this.editor,i)}onUpdateBlockData(e,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,o,r,i)}),c2(this.editor,e,o),this.editor.emit("docChanged",this.editor,i)}onInsertBlock(e,o,r,i){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,o,r,i)});const s=this.editor.getContainerById(e);Hb(this.editor,s,o,r),this.editor.emit("docChanged",this.editor,i)}onDeleteBlock(e,o,r){Cy(this.editor,e,o,r),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,o,r)});const i=this.editor.getContainerById(e);dy(this.editor,i,o),this.editor.emit("docChanged",this.editor,r)}onInsertChildContainer(e,o,r){this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,r)})}onDeleteChildContainer(e,o){this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,e,o)})}onCustomMessage(e){this.callbacks.forEach(o=>{var r;return(r=o.onCustomMessage)==null?void 0:r.call(o,e)})}onStatusChanged(e){this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,e)})}onError(e){this.callbacks.forEach(o=>{var r;return(r=o.onError)==null?void 0:r.call(o,e)})}uploadResource(e,o){return this.externalDoc.uploadResource(e,o)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,o){return this.externalDoc.buildResourceUrl(e,o)}request(e,o){return this.externalDoc.request(e,o)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,o,r;return(r=(o=(e=this.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}reset(e){on.log("reset doc"),this.externalDoc=e,this.externalDoc.registerCallback(this),this.editor.reload()}}function d2(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const Zd=w("undo-action");class zr{constructor(t,e,o){h(this,"beforeRange");h(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=o}undo(t){return!1}redo(t){return!1}combinable(t){return u(Zd,t,"no other action"),!1}combine(t){u(Zd,!1,"no other")}setAfterRange(t){this.afterRange&&Zd.warn("after range has already set"),this.afterRange=t}}const by=w("block-action");class h2 extends zr{constructor(e,o,r,i,s){super(e,o,s);h(this,"blockData");h(this,"blockIndex");this.blockData=Q.default(i),this.blockIndex=r}deleteBlock(e,o){if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockData.id);return i?(u(by,this.blockIndex===K(i),"invalid block index"),xd(e,i,ho(e,o)),!0):!1}insertBlock(e,o){return Fr(e,this.containerId,this.blockIndex,Q.default(this.blockData),o),!0}}class vy extends h2{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class yy extends h2{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class ky extends zr{constructor(e){super(e,V(e.rootContainer),e.selection.range.toDocRange());h(this,"actions",[])}addAction(e){d2(this.actions,e),this.afterRange=e.afterRange}undo(e){let o=!1;return this.actions.concat().reverse().forEach(r=>{r.undo(e)&&(o=!0)}),o}redo(e){let o=!1;return this.actions.forEach(r=>{r.redo(e)&&(o=!0)}),o}setAfterRange(e){this.afterRange=e;const o=this.actions[this.actions.length-1];!o||o instanceof zr&&(o.afterRange||o.setAfterRange(e))}}const ir=w("update-block-data-action");class bc extends zr{constructor(e,o,r,i,s,l){super(e,o,l);h(this,"beforeBlockData");h(this,"afterBlockData");h(this,"blockId");this.blockId=r,u(ir,this.blockId===i.id,"invalid block id"),u(ir,this.blockId===s.id,"invalid block id"),this.beforeBlockData=Q.default(i),this.afterBlockData=Q.default(s),u(ir,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){u(ir,e,"no editor");const o=e.getBlockById(this.blockId);if(!o)return!1;const r=e.getContainerById(this.containerId);return u(ir,r,"no container"),fc(e,o,bc.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){u(ir,e,"no editor");const o=e.getBlockById(this.blockId);if(!o)return!1;const r=e.getContainerById(this.containerId);return u(ir,r,"no container"),fc(e,o,bc.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const o=Q.default(e);return delete o.id,delete o.type,o}}const Qd=w("update-block-text-action");class ds extends zr{constructor(e,o,r,i,s,l){super(e,o,l);h(this,"beforeRichTextData");h(this,"afterRichTextData");h(this,"blockId");h(this,"type");this.blockId=r,this.beforeRichTextData=Q.default(i),this.afterRichTextData=Q.default(s),this.type=ds.calType(i,s)}static calType(e,o){u(Qd,e,"no old data"),u(Qd,o,"no new data");const i=ce.diff(e,o),s=new Set;let l=!1;const c=d=>$m(d)?`cjk_${d}`:Nm(d)?"number":Ll(d)?"space":Pm(d)?"letter":"unknown";let a=!1;return i.forEach(d=>{d.insert?d.insert===" "?s.add("insert_letter"):typeof d.insert=="string"&&d.insert.startsWith(" ")&&d.insert.length>1?(l=!0,a=!0,s.add(`insert_${c(d.insert.substr(1))}`)):s.add(`insert_${c(d.insert)}`):d.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:a}}undo(e){if(!e.getContainerById(this.containerId))return!1;const r=e.getBlockById(this.blockId);return r?(hc(e,r,this.beforeRichTextData),!0):!1}redo(e){if(!e.getContainerById(this.containerId))return!1;const r=e.getBlockById(this.blockId);return r?(hc(e,r,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof ds)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const o=e.beforeRange,r=o.anchor;if(!r.isSimple())return!1;const i=this.afterRange;if(!i)return!1;const s=i.anchor;return!(!s.isSimple()||s.blockId!==o.anchor.blockId||s.offset!==r.offset)}combine(e){u(Qd,e instanceof ds,"invalid action type");const o=e;this.afterRichTextData=o.afterRichTextData,this.afterRange=e.afterRange}}class f2 extends zr{constructor(t,e,o){super(t,e,t.selection.range.toDocRange()),this.blocks=o}deleteChildContainer(t){return t.doc.localDeleteChildContainers([this.containerId]),!0}insertChildContainer(t){return t.doc.localInsertChildContainer(this.containerId,Q.default(this.blocks)),!0}}class wy extends f2{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class By extends f2{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const rn=w("undo");class Ey{constructor(t){h(this,"editor");h(this,"actions",[]);h(this,"undoCursor");h(this,"currentGroup",null);h(this,"groupCounter",0);h(this,"undoRedoing",!1);h(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(d2(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(u(rn,!this.currentGroup,"current group already exists"),this.currentGroup=new ky(this.editor),this.groupCounter=1):(u(rn,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){u(rn,this.currentGroup,"current group not exists"),u(rn,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?rn.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw rn.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange(ho(this.editor,t.beforeRange))}catch(e){rn.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange(ho(this.editor,e)):rn.warn("no after range")}catch(e){rn.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,o,r,i){this.undoRedoing||(this.prepareSaveUndoState(),ce.diff(o,r).length!==0&&this.addAction(new ds(this.editor,t,e,o,r,i)))}onBeforeUpdateBlockData(t,e,o,r,i){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new bc(this.editor,t,e,o,r,i);this.addAction(s)}onBeforeInsertBlock(t,e,o,r){this.undoRedoing||(this.prepareSaveUndoState(),u(rn,e>=0,"invalid block index"),u(rn,o,"no block data"),this.addAction(new vy(this.editor,t,e,o,r)))}onBeforeDeleteBlock(t,e,o,r){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new yy(this.editor,t,e,o,r)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new wy(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new By(this.editor,t,e)))}}class Iy{async fromData(t,e){const o=e.getData("text/x-ones-editor-doc");if(o)return{"text/x-ones-editor-doc":JSON.parse(o)}}}class xy{constructor(){h(this,"converters",[]);this.addConverter(new Iy)}async fromData(t,e){let o={};for(const r of this.converters){const i=await r.fromData(t,e);i&&(o={...o,...i})}return o}addConverter(t){this.converters.push(t)}}class Ty{constructor(t){h(this,"renders",[]);this.editor=t}registerRender(t){this.renders.push(t)}renderText(t,e){const o={classes:[],attributes:{},styles:{}};return this.renders.forEach(r=>{if(r.renderText){const i=r.renderText(this.editor,t,e);i.classes&&o.classes.push(...i.classes),i.attributes&&(o.attributes={...o.attributes,...i.attributes}),i.styles&&(o.styles={...o.styles,...i.styles})}}),o}renderBlock(t,e,o){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBlock){const s=i.renderBlock(this.editor,e,o);s.classes&&r.classes.push(...s.classes),s.attributes&&(r.attributes={...r.attributes,...s.attributes}),s.styles&&(r.styles={...r.styles,...s.styles})}}),r}updateBlock(t,e,o,r){this.renders.forEach(i=>{var s;(s=i.updateBlock)==null||s.call(i,t,e,o,r)})}}class $t extends Yt.TypedEmitter{constructor(e){super();h(this,"hoveringBlock",null);h(this,"hoveringTextChild",null);h(this,"filters",[]);h(this,"finders",[]);h(this,"handleDocumentMouseMove",e=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,e))return}const o=document.elementFromPoint(e.x,e.y);if(!o){this.setHoveringBlock(null,e,null);return}let r=U(o);if((!r||!wt(this.editor.rootContainer,r))&&(r=this.findBlockByFinders(e),!r)){this.setHoveringBlock(null,e,null);return}const i=this.getParentTextContentChild(r,o);this.setHoveringBlock(r,e,i)});this.editor=e,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(e=>e.destroy()),this.filters=[],this.finders.forEach(e=>e.destroy()),this.finders=[]}addFilter(e){this.filters.push(e)}addFinder(e){this.finders.push(e)}hoveringBlockId(){return this.hoveringBlock?j(this.hoveringBlock):""}findBlockByFinders(e){for(let o=0;o<this.finders.length;o++){const i=this.finders[o].findTargetBlock(this.editor,e);if(i)return i}return null}setHoveringBlock(e,o,r){if(this.hoveringBlock===e&&this.hoveringTextChild===r)return;if(this.hoveringBlock!==e){const s=this.hoveringBlock&&wt(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&H(s,"hover"),e&&M(e,"hover"),this.hoveringBlock=e,this.emit("change",this.hoveringBlock,s,o)}const i=this.hoveringTextChild;this.hoveringTextChild=r,this.emit("childChange",this.hoveringBlock,r,i,o)}static get(e){return e.addCustom("standard-hovering-block",()=>new $t(e))}getParentTextContentChild(e,o){if(!_(this.editor,e))return null;const r=st(e);return o.parentElement===r?o:Ru(o)}}const m2="style-color-",g2="style-bg-color-";class Sy{renderText(t,e,o){const r=[],i={};return Object.entries(o).forEach(([s,l])=>{l===!0?s.startsWith(m2)?i["data-style-color"]=s.substring(m2.length):s.startsWith(g2)?i["data-style-bg-color"]=s.substring(g2.length):s.startsWith("style")&&r.push(s):typeof l=="string"&&s==="link"&&(r.push("link"),i.link=l)}),{classes:r,attributes:i}}renderBlock(t,e,o){var l,c;const r={};Object.entries(o).filter(a=>a[0].startsWith("style-")).forEach(([a,d])=>{r[`data-${a}`]=`${d}`});const s=[];return((c=(l=t.selection)==null?void 0:l.range)==null?void 0:c.start.blockId)===o.id&&s.push("focused"),typeof o.align=="string"&&o.align&&(r["data-style-align"]=o.align),o.heading&&(r["data-style-heading"]=String(o.heading)),o.quoted&&(r["data-style-quoted"]="true"),$t.get(t).hoveringBlockId()===o.id&&s.push("hover"),{attributes:r,classes:s}}updateBlock(t,e,o,r){var s,l;Array.from(o.attributes).forEach(c=>{c.name.startsWith("data-style-")&&o.removeAttribute(c.name)}),Object.entries(r).filter(c=>c[0].startsWith("style-")).forEach(([c,a])=>{o.setAttribute(`data-${c}`,`${a}`)}),((l=(s=t.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===r.id&&M(o,"focused"),$t.get(t).hoveringBlockId()===r.id&&M(o,"hover")}}function Dy(n){n.editorBlocks.registerBlockClass(ye),n.editorBlocks.registerBlockClass(Mg),n.editorBoxes.registerBoxClass(Dp),n.editorBoxes.registerBoxClass(Lp),n.editorInsertions.registerInsertionClass(Op),n.editorBlockRenders.registerRender(new Sy)}function Ly(n,t){Dy(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const p2=w("range-commands");function C2(n,t){n.forEach(e=>{e.source=t,e.children&&C2(e.children,t)})}function A2(n,t,e){const o=j(t);u(p2,o===e.start.blockId,"invalid start range"),u(p2,o===e.end.blockId,"invalid end range");const r=n.editorCommandProviders.getCommandProviders();let i=[];return r.forEach(s=>{const l=s.getAvailableCommands(n,t,e);C2(l,s.id),i.push(...l)}),r.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,t,e,i);l&&(i=l)}}),at(n,t)&&Rr(n,t,e.start,e.end).forEach(l=>{Mt(l).forEach(a=>{const d=G(n,a),f=Wt(n,{anchor:F(a,0,"home"),focus:F(a,d,"end")}),m=A2(n,a,f);i.push(...m)})}),i}function b2(n){const t=n.getEditor(),e=n.getSelectedBlocks(),o=[];return e.forEach(r=>{const i=Wt(t,{anchor:r.start,focus:r.end});A2(t,r.block,i).forEach(l=>{o.push(l)})}),o}function v2(n,t,e,o,r,i){var d;const s=n.editorCommandProviders.getCommandProviders();for(let f=0;f<s.length;f++){const m=s[f];if(m.beforeExecuteCommand&&m.beforeExecuteCommand(n,t,e,o,r))return!1}const l=n.editorCommandProviders.getCommandProvider(o.source),c={};if((d=l.executeCommand)!=null&&d.call(l,n,t,e,o,r,{}))return i[j(t)]=c,!0;let a=!1;return at(n,t)&&Rr(n,t,e.start,e.end).forEach(m=>{Mt(m).forEach(A=>{const k=G(n,A),v=Wt(n,{anchor:F(A,0,"home"),focus:F(A,k,"end")});v2(n,A,v,o,r,i)&&(a=!0)})}),s.forEach(f=>{f.afterExecuteCommand&&f.afterExecuteCommand(n,t,e,o,r,i)}),a}function y2(n,t,e){const o=n.getEditor(),r={},i=o.editorCommandProviders.getCommandProvider(t.source);return i.executeRangeCommand&&i.executeRangeCommand(o,n,t,e,r)||n.getSelectedBlocks().forEach(l=>{const c=Wt(o,{anchor:l.start,focus:l.end});v2(o,l.block,c,t,e,r)}),r}const My=w("command-providers");class k2{constructor(t){h(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(o=>o.id===t);return u(My,e,`no command provider, id=${t}`),e}getCommands(t){return b2(t)}executeCommand(t,e,o){return this.editor.undoManager.runInGroup(()=>y2(t,e,o))}getEmptyBlockTextAttributes(t,e){let o={};if(this.providers.forEach(r=>{var s;const i=(s=r.getEmptyBlockTextAttributes)==null?void 0:s.call(r,t,e);i&&(o={...o,...i})}),Object.keys(o).length!==0)return o}}function Ry(n,t){const e=z(t),o=V(e),r=K(t);c2(n,o,r)}const Oy=w("table-scroll");class w2{constructor(t,e,o,r,i){h(this,"handleEvent",t=>{this.handler(this.editor,t,this.data)});this.editor=t,this.dom=e,this.name=o,this.handler=r,this.data=i,e.addEventListener(o,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class Ny{constructor(t){h(this,"handlers",new Map);this.editor=t}destroy(){Array.from(this.handlers.entries()).forEach(([t,e])=>{e.forEach(o=>o.destroy()),this.handlers.delete(t)})}addEventListener(t,e,o,r){const i=this.handlers.get(t);if(i){if(i.find(s=>s.handler===o&&s.name===e)){Oy.warn(`event has already registered: ${e}`);return}i.push(new w2(this.editor,t,e,o,r))}else{const s=new w2(this.editor,t,e,o,r);this.handlers.set(t,[s])}}removeEventListener(t,e,o){if(!t){for(const[i,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const c=s[l];if(e)e===c.name&&o===c.handler&&s.splice(l,1);else if(o===c.handler){s.splice(l,1),c.destroy(),s.length===0&&this.handlers.delete(i);continue}}return}const r=this.handlers.get(t);if(r){const i=r.findIndex(s=>s.handler===o&&s.name===e);if(i!==-1){const s=r[i];r.splice(i,1),s.destroy(),r.length===0&&this.handlers.delete(t)}}}removeAllListeners(t,e){const o=this.handlers.get(t);if(o)if(e)for(let r=0;r<o.length;r++){const i=o[r];i.name===e&&(o.splice(r,1),i.destroy())}else o.forEach(r=>{r.destroy()}),this.handlers.delete(t)}}const B2=w("update-block-text");function Py(n,t){const e=n.getBoxById(t.id),o=U(e);u(B2,o,"no parent block"),u(B2,_(n,o),"not a text block");const r=n.getBlockText(o),i=fp(r,"id",t.id,t);n0(n,o,i)}function $y(n,t){for(const e of n.blockHooks)if(e.writable){const o=e.writable(n,t);if(typeof o=="boolean")return o}return!0}function _y(n){return n.readonly?!1:!en(n).find(o=>!n.isBlockWritable(o.block))}class Fy{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}getItem(t){return window.localStorage.getItem(this.getKey(t))}setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class Hy{constructor(){h(this,"shortcuts",[])}handleKeyboardEvents(t,e){const o=this.shortcuts;for(const r of o){const i=Object.entries(r);for(const[s,l]of i)if(jn(e,s)){const c=l(t,e);if(c!==void 0)return c}}}}const qn=w("editor");class jy extends Yt.TypedEmitter{constructor(e,o,r){var i,s,l,c,a,d,f;super();h(this,"parent");h(this,"rootElement");h(this,"contentElement");h(this,"rootContainerObject");h(this,"rootContainer");h(this,"input");h(this,"selection");h(this,"selectionHandler");h(this,"doc");h(this,"id");h(this,"clientId");h(this,"compositingText","");h(this,"undoManager");h(this,"shortcuts",new Hy);h(this,"dataConverter",new xy);h(this,"editorBlocks",new Tg(this));h(this,"editorBoxes",new Rp(this));h(this,"editorInsertions",new Pp(this));h(this,"editorEmbeds",new Dg(this));h(this,"editorDecorators",new $p(this));h(this,"editorCommandProviders",new k2(this));h(this,"editorBlockRenders",new Ty(this));h(this,"blockHooks",[]);h(this,"domEvents",new Ny(this));h(this,"customs",new Map);h(this,"options");h(this,"inputHandlers",new uy(this));h(this,"settingsProvider");h(this,"_readonly",!1);qn.debug("create editor"),this.setMaxListeners(100),this.options={colors:(i=r==null?void 0:r.colors)!=null?i:["#9923E9","#4587C2","#8BDB7A","#FB28D3","#CBC619","#10FEEB","#812A1A","#8A3F25","#22D742","#A53E74","#555C87","#57E0AA"],componentsOptions:(l=(s=r==null?void 0:r.components)==null?void 0:s.options)!=null?l:{},scrollContainer:r==null?void 0:r.scrollContainer},this.settingsProvider=(c=r==null?void 0:r.settingsProvider)!=null?c:new Fy(this),Ly(this,r==null?void 0:r.components),this.blockHooks.push(...(d=(a=r==null?void 0:r.components)==null?void 0:a.blockHooks)!=null?d:[]),this.id=(f=r==null?void 0:r.id)!=null?f:P(),this.clientId=P(),this.undoManager=new Ey(this),this.doc=new Ay(this,o,this.undoManager),this.parent=e,this.rootElement=b("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=b("div",["editor-content"],this.rootElement),this.rootContainerObject=Ip(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new Yb(this,this.inputHandlers),this.selection=new $v(this),this.selectionHandler=new Hv(this),r!=null&&r.shortcuts&&this.shortcuts.shortcuts.push(...r.shortcuts),xt.isMobile&&M(this.rootElement,"mobile"),xt.isSafari&&M(this.rootElement,"safari"),this._readonly&&M(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?M(this.rootElement,"readonly"):H(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:bn(this.rootContainer)}addCustom(e,o){const r=this.customs.get(e);if(r)return r;const i=o(this);return this.customs.set(e,i),i}getCustom(e){const o=this.customs.get(e);return u(qn,o,`${e} does not exists`),o}replaceCustom(e,o){const r=this.customs.get(e);return r&&r.destroy(),this.customs.set(e,o),o}findCustom(e){return this.customs.get(e)}findCustomByType(e){const o=this.customs.values();for(const r of o)if(r instanceof e)return r;return null}destroyCustom(e){const o=this.customs.get(e);o&&(this.customs.delete(e),o.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,o,r){return this.editorBlocks.createBlock(e,o,r)}createBox(e,o){return this.editorBoxes.createBox(e,o)}createInsertion(e,o){return this.editorInsertions.createInsertion(e,o)}destroy(){qn.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,o){Ld(this,e,o)}isWritable(){return _y(this)}isBlockWritable(e){return $y(this,e)}getChildContainerData(e){const o=this.doc.getContainerBlocks(e);return u(qn,o,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),u(qn,Array.isArray(o),`container data is not an array: ${JSON.stringify(o)}`),o}createChildContainer(e,o,r){return xp(this,e,o,r)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const o=this.rootContainer.querySelector(`#${e}`);return o&&u(qn,Jo(o),"not an valid block element"),o!=null?o:null}findBoxById(e){const o=this.rootContainer.querySelector(`#${e}`);return o&&u(qn,Mu(o),"not an valid box element"),o!=null?o:null}getBlockById(e){const o=this.findBlockById(e);return u(qn,o,`no block, id=${e}`),o}getBoxById(e){const o=this.findBoxById(e);return u(qn,o,`no box, id=${e}`),o}getBlockByIndex(e,o){const r=this.getContainerById(e);return Sr(r,o)}getBlockIndex(e){if(typeof e=="string"){const o=this.getBlockById(e);return K(o)}return K(e)}getContainerById(e){return Pr(this,e)}getParentContainer(e){return z(e)}reloadBlock(e){Ry(this,e)}contains(e){const o=e instanceof Element?e:e.parentElement;return o?o.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,o,r,i,s){const l={blockId:r.id,offset:0},c={anchor:l,focus:l};return Fr(this,e,o,r,i!=null?i:c,s)}insertEmbed(e,o,r,i,s){const l={id:P(),type:"embed",embedType:r,embedData:i};return this.insertBlock(e,o,l,s)}deleteBlock(e,o){Td(this,e,o)}mergeTextBlock(e,o){return Xp(this,e,o)}breakTextBlock(e,o,r){return Hr(this,e,o,r).newBlock}getTextPosition(){return _r(this)}getBlockString(e,o){const r=this.getBlockText(e);return vt(r,o)}getBlockData(e){return Ao(this,e)}getBoxData(e){return vp(this,e)}getBlockText(e){return ge(this,e)}setBlockText(e,o){n0(this,e,o)}deleteTextFromBlock(e,o,r,i){return Ed(this,e,o,r,i)}insertTextToBlock(e,o,r,i){return Wp(this,e,o,r,i)}insertBoxToBlock(e,o,r){return Gp(this,e,o,r)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,o,r,i){i0(this,e,o,r,i)}insertDocAt(e,o,r,i){return Od(this,e,o,r,i)}deleteChildContainers(e){Kp(this,e)}replaceBlockText(e,o){return hc(this,e,o)}updateBlockData(e,o,r){const i={...this.getBlockData(e),...o},{id:s,type:l,...c}=i;return fc(this,e,c,(r!=null?r:this.selection.range).toDocRange())}updateEmbedData(e,o,r){return o0(this,e,o,r)}updateBoxData(e){Py(this,e)}getSelectedText(){const e=cs(this);return cc(this,e)}clearSelectedContents(){Dd(this)}insertTextBlock(e,o,r,i){const s=Vn(e!=null?e:"");return Jp(this,s,o,r,i==null?void 0:i.newRange,i==null?void 0:i.insertBlockOptions)}updateCompositionText(e,o){if(e&&!o&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!o){Qp(this);return}o?(this.compositingText="",bu()||Bd(this,e)):(this.compositingText=e,Zp(this))}getColor(e){const o=this.options.colors;return o.length===0?"#FF1A75":o[e%o.length]}}function hs(n,t,e){return new jy(n,t,e)}function zy(n){const t=(o,r)=>{const i=o.findIndex(l=>l.id===r.id);if(i===-1){o.push(r);return}const s=o[i];if(s.value!==r.value){o.splice(i,1);return}if(!!s.states){if(!r.states){s.states=[];return}s.states=cu.default(s.states,r.states)}},e=[];return n.forEach(o=>{o.forEach(r=>{t(e,r)})}),e}const Uy=["#FBBFBD","#FFDDB6","#FFF897","#C5F0C1","#CEDDFE","#DCC9FC","#E5E6E8","#F76964","#FFA53D","#FFE928","#63D156","#A0BBFE","#C4A5FB","#BBBFC3"];class vc extends Yt.TypedEmitter{constructor(e){super();h(this,"users",new Map);h(this,"cursors",new Map);h(this,"addingUser",!1);h(this,"colors");this.colors=e&&e.length>0?e:Uy}setCursor(e){this.addUser(e.user);const o=this.cursors.get(e.user.userId);if(o&&El.default(o,e))return;this.cursors.set(e.user.userId,e);const r=new Set([e.range.anchor.blockId,e.range.focus.blockId]),i=new Set(r);o&&new Set([o.range.anchor.blockId,o.range.focus.blockId]).forEach(l=>{r.has(l)||i.add(l)}),this.emit("remote-carets-change",[...i])}addUsers(e){this.addingUser=!0,e.forEach(o=>this.addUser(o)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var o;return(o=this.users.get(e))!=null?o:null}removeUser(e){this.users.delete(e),this.cursors.delete(e),this.emit("change",Array.from(this.users.values()))}updateUsers(e){this.users.clear(),this.addingUser=!0;try{e.forEach(o=>{this.addUser(o)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const o=new Map;return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e&&ec(r.range)).forEach(r=>{const i=r.range.focus.offset;let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}),o}getCursors(e){return Array.from(this.cursors.values()).filter(o=>o.range.anchor.blockId===e||o.range.focus.blockId===e)}onUpdateBlockText(e,o,r){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(ec(l.range)){const{anchor:c,focus:a}=l.range;c.blockId===e.id&&(c.offset=ce.transformCursor(c.offset,o,r)),a.blockId===e.id&&(a.offset=ce.transformCursor(a.offset,o,r))}})}getFixedUserColor(e,o){let r=0;Array.from(e).forEach(s=>{r+=s.charCodeAt(0)});const i=r%this.colors.length;return this.colors[i]}destroy(){this.removeAllListeners()}}const ne=w("local-doc");class Yd extends Pi{constructor(e,o){super();h(this,"doc");h(this,"serviceUrl");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[Vn("")]}},this.serviceUrl=(o==null?void 0:o.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Q.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);u(ne,r,`no container data: ${e}`);const i=r[o];return u(ne,i,`no block data: ${o}`),i}localUpdateBlockText(e,o,r){const i=this.getBlockData(e,o);u(ne,i.text,"no text for data");const s=ce.apply(i.text,r);return i.text=s,u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,o,r,!0)}),s}localUpdateBlockData(e,o,r){const i=this.getBlockData(e,o);return r.delete.forEach(s=>delete i[s]),Object.entries(r.insert).forEach(([s,l])=>{i[s]=l}),u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,o,r,!0)}),i}localInsertBlock(e,o,r){const i=this.getContainerBlocks(e);return u(ne,i,`no container data: ${e}`),u(ne,o>=0&&o<=i.length,`invalid block index: ${o}, ${i.length}`),i.splice(o,0,r),u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,e,o,r,!0)}),r}localDeleteBlock(e,o){const r=this.getContainerBlocks(e);u(ne,r,`no container data: ${e}`),u(ne,o>=0&&o<=r.length,`invalid block index: ${o}, ${r.length}`);const i=r[o];return r.splice(o,1),u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,o,!0)}),i}localInsertChildContainer(e,o){this.doc.blocks[e]=o,u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onInsertChildContainer)==null?void 0:i.call(r,e,o,!0)})}localDeleteChildContainers(e){ne.debug(`delete child containers: ${e}`),e.forEach(o=>{u(ne,this.doc.blocks[o],`no child container: ${o}`),delete this.doc.blocks[o]}),e.forEach(o=>{u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,o,!0)})})}uploadResource(e,o){u(ne,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,o){u(ne,!1,"not implemented")}broadcastMessage(e){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new vc}setDoc(e){this.doc=Q.default(e),this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,"change doc")})}destroy(){this.clearCallbacks()}}function Wn(n){return Ct(z(n))}class Vy{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function Jd(n,t,e){n.addCustom(t,()=>{var i;const o=(i=e())!=null?i:void 0;return new Vy(o)})}const qy=w("remote-cursor");class Wy{constructor(){h(this,"remoteUsers",new vc)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const o=e;this.handleUpdateUsers(o.users)}else e.type==="caret"?this.handleUpdateCaret(e):qy.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function Gy(n){const{blocks:t,meta:e,comments:o,...r}=n;return{rootBlocks:t,meta:e,comments:o,childBlocks:r}}function fs(n){const{childBlocks:t,meta:e,comments:o,rootBlocks:r}=Gy(Q.default(n));return{blocks:{root:r,...t},meta:e,comments:o}}function yo(n){return n==="root"?"blocks":n}function Ur(n){return n==="blocks"?"root":n}const Zy={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new se.default(n)},apply(n,t){const e=new se.default(n),o=new se.default(t);return e.compose(o).ops},compose(n,t){const e=new se.default(n),o=new se.default(t);return e.compose(o).ops},diff(n,t){const e=new se.default(n),o=new se.default(t);return e.diff(o).ops},transform(n,t,e){const o=new se.default(n);return new se.default(t).transform(o,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const o=new se.default(t),r=this.transformCursor(n.index,o,e),i=this.transformCursor(n.index+n.length,o,e);return{...n,index:r,length:i-r}}}};var ms=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ko={},Kd=mm.default.EventEmitter;ko.EventEmitter=Kd,ko.mixin=Qy;function Qy(n){for(var t in Kd.prototype)n.prototype[t]=Kd.prototype[t]}var E2=["info","warn","error"];function I2(){var n={};E2.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var Yy=I2;I2.prototype.setMethods=function(n){n=n||{};var t=this;E2.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var Jy=Yy,Ky=new Jy,x2=Ky;function sr(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,sr):this.stack=new Error().stack}sr.prototype=Object.create(Error.prototype),sr.prototype.constructor=sr,sr.prototype.name="ShareDBError",sr.CODES={ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT:"ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT",ERR_APPLY_SNAPSHOT_NOT_PROVIDED:"ERR_APPLY_SNAPSHOT_NOT_PROVIDED",ERR_CLIENT_ID_BADLY_FORMED:"ERR_CLIENT_ID_BADLY_FORMED",ERR_CANNOT_PING_OFFLINE:"ERR_CANNOT_PING_OFFLINE",ERR_CONNECTION_SEQ_INTEGER_OVERFLOW:"ERR_CONNECTION_SEQ_INTEGER_OVERFLOW",ERR_CONNECTION_STATE_TRANSITION_INVALID:"ERR_CONNECTION_STATE_TRANSITION_INVALID",ERR_DATABASE_ADAPTER_NOT_FOUND:"ERR_DATABASE_ADAPTER_NOT_FOUND",ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE:"ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE",ERR_DATABASE_METHOD_NOT_IMPLEMENTED:"ERR_DATABASE_METHOD_NOT_IMPLEMENTED",ERR_DEFAULT_TYPE_MISMATCH:"ERR_DEFAULT_TYPE_MISMATCH",ERR_DOC_MISSING_VERSION:"ERR_DOC_MISSING_VERSION",ERR_DOC_ALREADY_CREATED:"ERR_DOC_ALREADY_CREATED",ERR_DOC_DOES_NOT_EXIST:"ERR_DOC_DOES_NOT_EXIST",ERR_DOC_TYPE_NOT_RECOGNIZED:"ERR_DOC_TYPE_NOT_RECOGNIZED",ERR_DOC_WAS_DELETED:"ERR_DOC_WAS_DELETED",ERR_INFLIGHT_OP_MISSING:"ERR_INFLIGHT_OP_MISSING",ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION:"ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION",ERR_MAX_SUBMIT_RETRIES_EXCEEDED:"ERR_MAX_SUBMIT_RETRIES_EXCEEDED",ERR_MESSAGE_BADLY_FORMED:"ERR_MESSAGE_BADLY_FORMED",ERR_MILESTONE_ARGUMENT_INVALID:"ERR_MILESTONE_ARGUMENT_INVALID",ERR_OP_ALREADY_SUBMITTED:"ERR_OP_ALREADY_SUBMITTED",ERR_OP_NOT_ALLOWED_IN_PROJECTION:"ERR_OP_NOT_ALLOWED_IN_PROJECTION",ERR_OP_SUBMIT_REJECTED:"ERR_OP_SUBMIT_REJECTED",ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM:"ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM",ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM:"ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM",ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT:"ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT",ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED:"ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED",ERR_OT_OP_BADLY_FORMED:"ERR_OT_OP_BADLY_FORMED",ERR_OT_OP_NOT_APPLIED:"ERR_OT_OP_NOT_APPLIED",ERR_OT_OP_NOT_PROVIDED:"ERR_OT_OP_NOT_PROVIDED",ERR_PRESENCE_TRANSFORM_FAILED:"ERR_PRESENCE_TRANSFORM_FAILED",ERR_PROTOCOL_VERSION_NOT_SUPPORTED:"ERR_PROTOCOL_VERSION_NOT_SUPPORTED",ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED:"ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED",ERR_SNAPSHOT_READ_SILENT_REJECTION:"ERR_SNAPSHOT_READ_SILENT_REJECTION",ERR_SNAPSHOT_READS_REJECTED:"ERR_SNAPSHOT_READS_REJECTED",ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND:"ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND",ERR_TYPE_CANNOT_BE_PROJECTED:"ERR_TYPE_CANNOT_BE_PROJECTED",ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE:"ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE",ERR_UNKNOWN_ERROR:"ERR_UNKNOWN_ERROR"};var yc=sr,gs={},T2=Xy;function Xy(n,t,e,o){var r=function(s,l,c,a){t(c,s,l,"left"),t(a,l,s,"right")},i=n.transformX=function(s,l){e(s),e(l);for(var c=[],a=0;a<l.length;a++){for(var d=l[a],f=[],m=0;m<s.length;){var p=[];if(r(s[m],d,f,p),m++,p.length===1)d=p[0];else if(p.length===0){for(var A=m;A<s.length;A++)o(f,s[A]);d=null;break}else{for(var k=i(s.slice(m),p),v=0;v<k[0].length;v++)o(f,k[0][v]);for(var T=0;T<k[1].length;T++)o(c,k[1][T]);d=null;break}}d!=null&&o(c,d),s=f}return[s,c]};n.transform=function(s,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?t([],s[0],l[0],c):c==="left"?i(s,l)[0]:i(l,s)[1]}}var S2={exports:{}},wo=S2.exports={name:"text0",uri:"http://sharejs.org/types/textv0",create:function(n){if(n!=null&&typeof n!="string")throw new Error("Initial data must be a string");return n||""}},Xd=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},th=function(n){if(typeof n.p!="number")throw new Error("component missing position field");if(typeof n.i=="string"==(typeof n.d=="string"))throw new Error("component needs an i or d field");if(n.p<0)throw new Error("position cannot be negative")},kc=function(n){for(var t=0;t<n.length;t++)th(n[t])};wo.apply=function(n,t){var e;kc(t);for(var o=0;o<t.length;o++){var r=t[o];if(r.i!=null)n=Xd(n,r.p,r.i);else{if(e=n.slice(r.p,r.p+r.d.length),r.d!==e)throw new Error("Delete component '"+r.d+"' does not match deleted text '"+e+"'");n=n.slice(0,r.p)+n.slice(r.p+r.d.length)}}return n};var Gn=wo._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:Xd(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:Xd(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};wo.compose=function(n,t){kc(n),kc(t);for(var e=n.slice(),o=0;o<t.length;o++)Gn(e,t[o]);return e},wo.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var o=n[e];o.p==null&&(o.p=0),Gn(t,o)}return t};var eh=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};wo.transformCursor=function(n,t,e){for(var o=e==="right",r=0;r<t.length;r++)n=eh(n,t[r],o);return n};var tk=wo._tc=function(n,t,e,o){if(th(t),th(e),t.i!=null)Gn(n,{i:t.i,p:eh(t.p,e,o==="right")});else if(e.i!=null){var r=t.d;t.p<e.p&&(Gn(n,{d:r.slice(0,e.p-t.p),p:t.p}),r=r.slice(e.p-t.p)),r!==""&&Gn(n,{d:r,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)Gn(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)Gn(n,t);else{var i={d:"",p:t.p};t.p<e.p&&(i.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(i.d+=t.d.slice(e.p+e.d.length-t.p));var s=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(s-t.p,l-t.p),a=e.d.slice(s-e.p,l-e.p);if(c!==a)throw new Error("Delete ops delete different text in the same region of the document");i.d!==""&&(i.p=eh(i.p,e),Gn(n,i))}return n},ek=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};wo.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=ek(n[t]);return n},T2(wo,tk,kc,Gn);var wc=function(n){return Object.prototype.toString.call(n)=="[object Array]"},nk=function(n){return!!n&&n.constructor===Object},sn=function(n){return JSON.parse(JSON.stringify(n))},et={name:"json0",uri:"http://sharejs.org/types/JSONv0"},Zn={};et.registerSubtype=function(n){Zn[n.name]=n},et.create=function(n){return n===void 0?null:sn(n)},et.invertComponent=function(n){var t={p:n.p};return n.t&&Zn[n.t]&&(t.t=n.t,t.o=Zn[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},et.invert=function(n){for(var t=n.slice().reverse(),e=[],o=0;o<t.length;o++)e.push(et.invertComponent(t[o]));return e},et.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!wc(n[t].p))throw new Error("Missing path")},et.checkList=function(n){if(!wc(n))throw new Error("Referenced element not a list")},et.checkObj=function(n){if(!nk(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function ps(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function Cs(n){n.p.push(n.o[0].p),n.o[0].i!=null&&(n.si=n.o[0].i),n.o[0].d!=null&&(n.sd=n.o[0].d),delete n.t,delete n.o}et.apply=function(n,t){et.checkValidOp(t),t=sn(t);for(var e={data:n},o=0;o<t.length;o++){var r=t[o];(r.si!=null||r.sd!=null)&&ps(r);for(var i=null,s=e,l="data",c=0;c<r.p.length;c++){var a=r.p[c];if(i=s,s=s[l],l=a,i==null)throw new Error("Path invalid")}if(r.t&&r.o!==void 0&&Zn[r.t])s[l]=Zn[r.t].apply(s[l],r.o);else if(r.na!==void 0){if(typeof s[l]!="number")throw new Error("Referenced element not a number");s[l]+=r.na}else if(r.li!==void 0&&r.ld!==void 0)et.checkList(s),s[l]=r.li;else if(r.li!==void 0)et.checkList(s),s.splice(l,0,r.li);else if(r.ld!==void 0)et.checkList(s),s.splice(l,1);else if(r.lm!==void 0){if(et.checkList(s),r.lm!=l){var d=s[l];s.splice(l,1),s.splice(r.lm,0,d)}}else if(r.oi!==void 0)et.checkObj(s),s[l]=r.oi;else if(r.od!==void 0)et.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return e.data},et.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},et.incrementalApply=function(n,t,e){for(var o=0;o<t.length;o++){var r=[t[o]];n=et.apply(n,r),e(r,n)}return n};var ok=et.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var o=0;o<n.length;o++)if(n[o]!==t[o]&&(!e||o!==n.length-1))return!1;return!0};et.append=function(n,t){if(t=sn(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(ps(t),ps(e)),ok(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&Zn[t.t]){if(e.o=Zn[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var o=t.p,r=0;r<e.o.length-1;r++)t.o=[e.o.pop()],t.p=o.slice(),Cs(t),n.push(t);Cs(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Cs(t),Cs(e)),n.push(t)},et.compose=function(n,t){et.checkValidOp(n),et.checkValidOp(t);for(var e=sn(n),o=0;o<t.length;o++)et.append(e,t[o]);return e},et.normalize=function(n){var t=[];n=wc(n)?n:[n];for(var e=0;e<n.length;e++){var o=n[e];o.p==null&&(o.p=[]),et.append(t,o)}return t},et.commonLengthForOps=function(n,t){var e=n.p.length,o=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&o++,e===0)return-1;if(o===0)return null;e--,o--;for(var r=0;r<e;r++){var i=n.p[r];if(r>=o||i!==t.p[r])return null}return e},et.canOpAffectPath=function(n,t){return et.commonLengthForOps({p:t},n)!=null},et.transformComponent=function(n,t,e,o){t=sn(t);var r=et.commonLengthForOps(e,t),i=et.commonLengthForOps(t,e),s=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&s++,(e.na!=null||e.t)&&l++,i!=null&&l>s&&t.p[i]==e.p[i]){if(t.ld!==void 0){var c=sn(e);c.p=c.p.slice(s),t.ld=et.apply(sn(t.ld),[c])}else if(t.od!==void 0){var c=sn(e);c.p=c.p.slice(s),t.od=et.apply(sn(t.od),[c])}}if(r!=null){var a=s==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(ps(t),c=sn(e),ps(c)),c.t&&Zn[c.t]){if(t.t&&t.t===c.t){var d=Zn[t.t].transform(t.o,c.o,o);if(t.si!=null||t.sd!=null)for(var f=t.p,m=0;m<d.length;m++)t.o=[d[m]],t.p=f.slice(),Cs(t),et.append(n,t);else(!wc(d)||d.length>0)&&(t.o=d,et.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[r]===t.p[r])if(a){if(t.ld!==void 0)if(t.li!==void 0&&o==="left")t.ld=sn(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&a&&t.p[r]===e.p[r]?o==="right"&&t.p[r]++:e.p[r]<=t.p[r]&&t.p[r]++,t.lm!==void 0&&a&&e.p[r]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&a){if(e.p[r]===t.p[r])return n;var f=e.p[r],p=t.p[r],A=t.lm;(f<A||f===A&&p<A)&&t.lm--}if(e.p[r]<t.p[r])t.p[r]--;else if(e.p[r]===t.p[r]){if(l<s)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&s===l){var p=t.p[r],A=t.lm,k=e.p[r],v=e.lm;if(k!==v)if(p===k)if(o==="left")t.p[r]=v,p===A&&(t.lm=v);else return n;else p>k&&t.p[r]--,p>v?t.p[r]++:p===v&&k>v&&(t.p[r]++,p===A&&t.lm++),(A>k||A===k&&A>p)&&t.lm--,A>v?t.lm++:A===v&&(v>k&&A>p||v<k&&A<p?o==="right"&&t.lm++:A>p?t.lm++:A===k&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&a){var p=e.p[r],A=e.lm;f=t.p[r],f>p&&t.p[r]--,f>A&&t.p[r]++}else{var p=e.p[r],A=e.lm;f=t.p[r],f===p?t.p[r]=A:(f>p&&t.p[r]--,(f>A||f===A&&p>A)&&t.p[r]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[r]===e.p[r])if(t.oi!==void 0&&a){if(o==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[r]===e.p[r])if(o==="left")et.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[r]==e.p[r]){if(!a)return n;if(t.oi!==void 0)delete t.od;else return n}}}return et.append(n,t),n},T2(et,et.transformComponent,et.checkValidOp,et.append);var rk=S2.exports;et.registerSubtype(rk);var ik=et,sk={type:ik};(function(n){n.defaultType=sk.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(gs);var ln={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var o in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],o=1;o<arguments.length;o++){var r=arguments[o];e=e[r]||(o===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],o=arguments[arguments.length-1],r=1;r<arguments.length-1;r++){var i=arguments[r];e=e[i]||(e[i]=r===arguments.length-2?o():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],o=[e],r=1;r<arguments.length-1;r++){var i=arguments[r];if(!e.hasOwnProperty(i))break;e=e[i],o.push(e)}for(var r=o.length-1;r>=0;r--){var s=o[r],i=arguments[r+1],l=s[i];(r===o.length-1||!n.hasKeys(l))&&delete s[i]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,o){var r=!1;return e.forEach(function(i){i&&(i(o),r=!0)}),r},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];setTimeout(function(){e.apply(null,o)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(ln);var D2=Array.isArray,L2=Object.keys,lk=Object.prototype.hasOwnProperty,ck=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var o=D2(t),r=D2(e),i,s,l;if(o&&r){if(s=t.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!n(t[i],e[i]))return!1;return!0}if(o!=r)return!1;var c=t instanceof Date,a=e instanceof Date;if(c!=a)return!1;if(c&&a)return t.getTime()==e.getTime();var d=t instanceof RegExp,f=e instanceof RegExp;if(d!=f)return!1;if(d&&f)return t.toString()==e.toString();var m=L2(t);if(s=m.length,s!==L2(e).length)return!1;for(i=s;i--!==0;)if(!lk.call(e,m[i]))return!1;for(i=s;i--!==0;)if(l=m[i],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},M2=ko,ak=x2,Me=yc,Bc=gs,cn=ln,uk=cn.clone,dk=ck,ke=Me.CODES,hk=ct;function ct(n,t,e){M2.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}M2.mixin(ct),ct.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},ct.prototype._setType=function(n){if(typeof n=="string"&&(n=Bc.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new Me(ke.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},ct.prototype._setData=function(n){this.data=n,this._dataStateVersion++},ct.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new Me(ke.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new Me(ke.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var o=n.type===void 0?Bc.defaultType:n.type;this._setType(o),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},ct.prototype.whenNothingPending=function(n){var t=this;cn.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},ct.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},ct.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},ct.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},ct.prototype._emitResponseError=function(n,t){if(n&&n.code===ke.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},ct.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var o=this.inflightFetch.shift();if(o&&e.push(o),e.length&&(o=function(r){cn.callEach(e,r)}),n)return this._emitResponseError(n,o);this.ingestSnapshot(t,o),this._emitNothingPending()},ct.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var o=this.pendingFetch;this.pendingFetch=[],e.callback&&o.push(e.callback);var r;if(o.length&&(r=function(i){cn.callEach(o,i)}),n)return this._emitResponseError(n,r);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,r):r&&r(),this._emitNothingPending(),this._flushSubscribe()},ct.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===ke.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=Ec(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var o=0;o<this.pendingOps.length;o++){var e=Ec(this.pendingOps[o],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(r){return this._hardRollback(r)}}},ct.prototype._onConnectionStateChanged=function(){this.connection.canSend?(this.flush(),this._resubscribe()):(this.inflightOp&&(this.pendingOps.unshift(this.inflightOp),this.inflightOp=null),this.subscribed=!1,this.inflightSubscribe&&(this.inflightSubscribe.wantSubscribe?(this.pendingSubscribe.unshift(this.inflightSubscribe),this.inflightSubscribe=null):this._handleSubscribe()),this.inflightFetch.length&&(this.pendingFetch=this.pendingFetch.concat(this.inflightFetch),this.inflightFetch.length=0))},ct.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},ct.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);fk(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},ct.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},ct.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},ct.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,o=e&&e.wantSubscribe===n;if(o){e.callback=mk([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},ct.prototype._flushSubscribe=function(){if(!(this.inflightSubscribe||!this.pendingSubscribe.length)){if(this.connection.canSend){this.inflightSubscribe=this.pendingSubscribe.shift(),this.wantSubscribe=this.inflightSubscribe.wantSubscribe,this.wantSubscribe?this.connection.sendSubscribe(this):(this.subscribed=!1,this.connection.sendUnsubscribe(this));return}if(!this.pendingSubscribe[0].wantSubscribe){this.inflightSubscribe=this.pendingSubscribe.shift();var n=this;cn.nextTick(function(){n._handleSubscribe()})}}};function fk(n,t,e){if(t){var o=n.pop();n.push(function(r){o&&o(r),e&&e(r)})}else n.push(e)}function mk(n){return n=n.filter(cn.truthy),n.length?function(t){cn.callEach(n,t)}:null}ct.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function gk(n){delete n.op,delete n.create,delete n.del}function Ec(n,t){if(n.del)return gk(t);if(t.del)return new Me(ke.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new Me(ke.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new Me(ke.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var o=n.type.transform(n.op,t.op,"left"),r=n.type.transform(t.op,n.op,"right");n.op=o,t.op=r}}}ct.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new Me(ke.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===Bc.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,o=0;o<n.op.length;o++){var r=n.op[o],i={op:[r]};this.emit("before op",i.op,t,n.src);for(var s=e;s<this.applyStack.length;s++){var l=Ec(this.applyStack[s],i);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,i.op)),this.emit("op",i.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},ct.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new Me(ke.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=cn.MAX_SAFE_INTEGER)return this.emit("error",new Me(ke.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},ct.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var o=new Me(ke.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(o):this.emit("error",o)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(i){return this._hardRollback(i)}var r=this;cn.nextTick(function(){r.flush()})},ct.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var o=this._tryCompose(n);if(o){o.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},ct.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var o=this.pendingOps.splice(e),e=0;e<o.length;e++){var t=o[e],r=this._tryCompose(t);r?r.callbacks=r.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},ct.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!dk(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},ct.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var o={op:n},r=t&&t.source;this._submit(o,r,e)},ct.prototype.create=function(n,t,e,o){if(typeof t=="function"?(o=t,e=null,t=null):typeof e=="function"&&(o=e,e=null),t||(t=Bc.defaultType.uri),this.type){var r=new Me(ke.ERR_DOC_ALREADY_CREATED,"Document already exists");return o?o(r):this.emit("error",r)}var i={create:{type:t,data:n}},s=e&&e.source;this._submit(i,s,o)},ct.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new Me(ke.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var o={del:!0},r=n&&n.source;this._submit(o,r,t)},ct.prototype.pause=function(){this.paused=!0},ct.prototype.resume=function(){this.paused=!1,this.flush()},ct.prototype.toSnapshot=function(){return{v:this.version,data:uk(this.data),type:this.type.uri}},ct.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return ak.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},ct.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var o=Ec(this.pendingOps[e],t);if(o)return this._hardRollback(o)}try{this._otApply(t,!1)}catch(r){return this._hardRollback(r)}this._clearInflightOp(n);return}this._hardRollback(n)},ct.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var o=!!t.length,r=0;r<t.length;r++)o=cn.callEach(t[r].callbacks,n)&&o;if(n&&!o)return e.emit("error",n)})},ct.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=cn.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var lr={};lr.ACTIONS={initLegacy:"init",handshake:"hs",queryFetch:"qf",querySubscribe:"qs",queryUnsubscribe:"qu",queryUpdate:"q",bulkFetch:"bf",bulkSubscribe:"bs",bulkUnsubscribe:"bu",fetch:"f",subscribe:"s",unsubscribe:"u",op:"op",snapshotFetch:"nf",snapshotFetchByTimestamp:"nt",pingPong:"pp",presence:"p",presenceSubscribe:"ps",presenceUnsubscribe:"pu",presenceRequest:"pr"};var R2=ko,O2=lr.ACTIONS,pk=ln,Ck=we;function we(n,t,e,o,r,i,s){R2.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=o,this.query=r,this.results=null,i&&i.results&&(this.results=i.results,delete i.results),this.extra=void 0,this.options=i,this.callback=s,this.ready=!1,this.sent=!1}R2.mixin(we),we.prototype.hasPending=function(){return!this.ready},we.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var o=this.results[e];t.push([o.id,o.version])}n.r=t}this.connection.send(n),this.sent=!0}},we.prototype.destroy=function(n){this.connection.canSend&&this.action===O2.querySubscribe&&this.connection.send({a:O2.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&pk.nextTick(n)},we.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},we.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},we.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},we.prototype._handleResponse=function(n,t,e){var o=this.callback;if(this.callback=null,n)return this._finishResponse(n,o);if(!t)return this._finishResponse(null,o);var r=this,i=1,s=function(d){if(d)return r._finishResponse(d,o);--i||r._finishResponse(null,o)};if(Array.isArray(t))i+=t.length,this.results=this._ingestSnapshots(t,s),this.extra=e;else for(var l in t){i++;var c=t[l],a=this.connection.get(c.c||this.collection,l);a.ingestSnapshot(c,s)}s()},we.prototype._ingestSnapshots=function(n,t){for(var e=[],o=0;o<n.length;o++){var r=n[o],i=this.connection.get(r.c||this.collection,r.d);i.ingestSnapshot(r,t),e.push(i)}return e},we.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},we.prototype._handleError=function(n){this.emit("error",n)},we.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var o=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(o)),this.emit("insert",o,e.index);break;case"remove":var i=e.howMany||1,r=this.results.splice(e.index,i);this.emit("remove",r,e.index);break;case"move":var i=e.howMany||1,s=this.results.splice(e.from,i);Array.prototype.splice.apply(this.results,[e.to,0].concat(s)),this.emit("move",s,e.from,e.to);break}}this.emit("changed",this.results)},we.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var N2=ko,Ak=lr.ACTIONS,bk=ln,P2=In;function In(n,t){if(N2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}N2.mixin(In),In.prototype.submit=function(n,t){this.value=n,this.send(t)},In.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},In.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},In.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},In.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},In.prototype._message=function(){return{a:Ak.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},In.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},In.prototype._callbackOrEmit=function(n,t){if(t)return bk.nextTick(t,n);n&&this.emit("error",n)};var vk=ln,$2=nh;function nh(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}nh.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},nh.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&vk.nextTick(n)};var oh={exports:{}};(function(n,t){(function(e,o){o(t)})(ms,function(e){function o(C,y){y=y|0;for(var B=Math.max(C.length-y,0),I=Array(B),D=0;D<B;D++)I[D]=C[y+D];return I}var r=function(C){var y=o(arguments,1);return function(){var B=o(arguments);return C.apply(null,y.concat(B))}},i=function(C){return function(){var y=o(arguments),B=y.pop();C.call(this,y,B)}};function s(C){var y=typeof C;return C!=null&&(y=="object"||y=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function a(C){setTimeout(C,0)}function d(C){return function(y){var B=o(arguments,1);C(function(){y.apply(null,B)})}}var f;l?f=setImmediate:c?f=process.nextTick:f=a;var m=d(f);function p(C){return i(function(y,B){var I;try{I=C.apply(this,y)}catch(D){return B(D)}s(I)&&typeof I.then=="function"?I.then(function(D){A(B,null,D)},function(D){A(B,D.message?D:new Error(D))}):B(null,I)})}function A(C,y,B){try{C(y,B)}catch(I){m(k,I)}}function k(C){throw C}var v=typeof Symbol=="function";function T(C){return v&&C[Symbol.toStringTag]==="AsyncFunction"}function E(C){return T(C)?p(C):C}function L(C){return function(y){var B=o(arguments,1),I=i(function(D,S){var O=this;return C(y,function(N,W){E(N).apply(O,D.concat(W))},S)});return B.length?I.apply(this,B):I}}var R=typeof ms=="object"&&ms&&ms.Object===Object&&ms,$=typeof self=="object"&&self&&self.Object===Object&&self,q=R||$||Function("return this")(),ot=q.Symbol,lt=Object.prototype,gt=lt.hasOwnProperty,ht=lt.toString,kt=ot?ot.toStringTag:void 0;function de(C){var y=gt.call(C,kt),B=C[kt];try{C[kt]=void 0;var I=!0}catch{}var D=ht.call(C);return I&&(y?C[kt]=B:delete C[kt]),D}var oo=Object.prototype,re=oo.toString;function qe(C){return re.call(C)}var $o="[object Null]",kr="[object Undefined]",wr=ot?ot.toStringTag:void 0;function _o(C){return C==null?C===void 0?kr:$o:wr&&wr in Object(C)?de(C):qe(C)}var Na="[object AsyncFunction]",EH="[object Function]",IH="[object GeneratorFunction]",xH="[object Proxy]";function TH(C){if(!s(C))return!1;var y=_o(C);return y==EH||y==IH||y==Na||y==xH}var SH=9007199254740991;function C9(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=SH}function ml(C){return C!=null&&C9(C.length)&&!TH(C)}var Gf={};function ft(){}function Fo(C){return function(){if(C!==null){var y=C;C=null,y.apply(this,arguments)}}}var Zf=typeof Symbol=="function"&&Symbol.iterator,DH=function(C){return Zf&&C[Zf]&&C[Zf]()};function LH(C,y){for(var B=-1,I=Array(C);++B<C;)I[B]=y(B);return I}function Pa(C){return C!=null&&typeof C=="object"}var MH="[object Arguments]";function A9(C){return Pa(C)&&_o(C)==MH}var b9=Object.prototype,RH=b9.hasOwnProperty,OH=b9.propertyIsEnumerable,NH=A9(function(){return arguments}())?A9:function(C){return Pa(C)&&RH.call(C,"callee")&&!OH.call(C,"callee")},pn=Array.isArray;function PH(){return!1}var v9=typeof e=="object"&&e&&!e.nodeType&&e,y9=v9&&!0&&n&&!n.nodeType&&n,$H=y9&&y9.exports===v9,k9=$H?q.Buffer:void 0,_H=k9?k9.isBuffer:void 0,FH=_H||PH,HH=9007199254740991,jH=/^(?:0|[1-9]\d*)$/;function zH(C,y){var B=typeof C;return y=y==null?HH:y,!!y&&(B=="number"||B!="symbol"&&jH.test(C))&&C>-1&&C%1==0&&C<y}var UH="[object Arguments]",VH="[object Array]",qH="[object Boolean]",WH="[object Date]",GH="[object Error]",ZH="[object Function]",QH="[object Map]",YH="[object Number]",JH="[object Object]",KH="[object RegExp]",XH="[object Set]",tj="[object String]",ej="[object WeakMap]",nj="[object ArrayBuffer]",oj="[object DataView]",rj="[object Float32Array]",ij="[object Float64Array]",sj="[object Int8Array]",lj="[object Int16Array]",cj="[object Int32Array]",aj="[object Uint8Array]",uj="[object Uint8ClampedArray]",dj="[object Uint16Array]",hj="[object Uint32Array]",Et={};Et[rj]=Et[ij]=Et[sj]=Et[lj]=Et[cj]=Et[aj]=Et[uj]=Et[dj]=Et[hj]=!0,Et[UH]=Et[VH]=Et[nj]=Et[qH]=Et[oj]=Et[WH]=Et[GH]=Et[ZH]=Et[QH]=Et[YH]=Et[JH]=Et[KH]=Et[XH]=Et[tj]=Et[ej]=!1;function fj(C){return Pa(C)&&C9(C.length)&&!!Et[_o(C)]}function mj(C){return function(y){return C(y)}}var w9=typeof e=="object"&&e&&!e.nodeType&&e,gl=w9&&!0&&n&&!n.nodeType&&n,gj=gl&&gl.exports===w9,Qf=gj&&R.process,B9=function(){try{var C=gl&&gl.require&&gl.require("util").types;return C||Qf&&Qf.binding&&Qf.binding("util")}catch{}}(),E9=B9&&B9.isTypedArray,pj=E9?mj(E9):fj,Cj=Object.prototype,Aj=Cj.hasOwnProperty;function bj(C,y){var B=pn(C),I=!B&&NH(C),D=!B&&!I&&FH(C),S=!B&&!I&&!D&&pj(C),O=B||I||D||S,N=O?LH(C.length,String):[],W=N.length;for(var J in C)(y||Aj.call(C,J))&&!(O&&(J=="length"||D&&(J=="offset"||J=="parent")||S&&(J=="buffer"||J=="byteLength"||J=="byteOffset")||zH(J,W)))&&N.push(J);return N}var vj=Object.prototype;function yj(C){var y=C&&C.constructor,B=typeof y=="function"&&y.prototype||vj;return C===B}function kj(C,y){return function(B){return C(y(B))}}var wj=kj(Object.keys,Object),Bj=Object.prototype,Ej=Bj.hasOwnProperty;function Ij(C){if(!yj(C))return wj(C);var y=[];for(var B in Object(C))Ej.call(C,B)&&B!="constructor"&&y.push(B);return y}function Yf(C){return ml(C)?bj(C):Ij(C)}function xj(C){var y=-1,B=C.length;return function(){return++y<B?{value:C[y],key:y}:null}}function Tj(C){var y=-1;return function(){var I=C.next();return I.done?null:(y++,{value:I.value,key:y})}}function Sj(C){var y=Yf(C),B=-1,I=y.length;return function D(){var S=y[++B];return S==="__proto__"?D():B<I?{value:C[S],key:S}:null}}function Dj(C){if(ml(C))return xj(C);var y=DH(C);return y?Tj(y):Sj(C)}function Pn(C){return function(){if(C===null)throw new Error("Callback was already called.");var y=C;C=null,y.apply(this,arguments)}}function $a(C){return function(y,B,I){if(I=Fo(I||ft),C<=0||!y)return I(null);var D=Dj(y),S=!1,O=0,N=!1;function W(Z,tt){if(O-=1,Z)S=!0,I(Z);else{if(tt===Gf||S&&O<=0)return S=!0,I(null);N||J()}}function J(){for(N=!0;O<C&&!S;){var Z=D();if(Z===null){S=!0,O<=0&&I(null);return}O+=1,B(Z.value,Z.key,Pn(W))}N=!1}J()}}function Br(C,y,B,I){$a(y)(C,E(B),I)}function ie(C,y){return function(B,I,D){return C(B,y,I,D)}}function Lj(C,y,B){B=Fo(B||ft);var I=0,D=0,S=C.length;S===0&&B(null);function O(N,W){N?B(N):(++D===S||W===Gf)&&B(null)}for(;I<S;I++)y(C[I],I,Pn(O))}var Mj=ie(Br,1/0),Ho=function(C,y,B){var I=ml(C)?Lj:Mj;I(C,E(y),B)};function Ii(C){return function(y,B,I){return C(Ho,y,E(B),I)}}function I9(C,y,B,I){I=I||ft,y=y||[];var D=[],S=0,O=E(B);C(y,function(N,W,J){var Z=S++;O(N,function(tt,It){D[Z]=It,J(tt)})},function(N){I(N,D)})}var _a=Ii(I9),x9=L(_a);function xi(C){return function(y,B,I,D){return C($a(B),y,E(I),D)}}var Ti=xi(I9),Jf=ie(Ti,1),T9=L(Jf);function Fa(C,y){for(var B=-1,I=C==null?0:C.length;++B<I&&y(C[B],B,C)!==!1;);return C}function Rj(C){return function(y,B,I){for(var D=-1,S=Object(y),O=I(y),N=O.length;N--;){var W=O[C?N:++D];if(B(S[W],W,S)===!1)break}return y}}var Oj=Rj();function pl(C,y){return C&&Oj(C,y,Yf)}function Nj(C,y,B,I){for(var D=C.length,S=B+(I?1:-1);I?S--:++S<D;)if(y(C[S],S,C))return S;return-1}function Pj(C){return C!==C}function $j(C,y,B){for(var I=B-1,D=C.length;++I<D;)if(C[I]===y)return I;return-1}function Ha(C,y,B){return y===y?$j(C,y,B):Nj(C,Pj,B)}var Kf=function(C,y,B){typeof y=="function"&&(B=y,y=null),B=Fo(B||ft);var I=Yf(C),D=I.length;if(!D)return B(null);y||(y=D);var S={},O=0,N=!1,W=Object.create(null),J=[],Z=[],tt={};pl(C,function(Dt,Lt){if(!pn(Dt)){It(Lt,[Dt]),Z.push(Lt);return}var te=Dt.slice(0,Dt.length-1),ro=te.length;if(ro===0){It(Lt,Dt),Z.push(Lt);return}tt[Lt]=ro,Fa(te,function(Mi){if(!C[Mi])throw new Error("async.auto task `"+Lt+"` has a non-existent dependency `"+Mi+"` in "+te.join(", "));$n(Mi,function(){ro--,ro===0&&It(Lt,Dt)})})}),Sz(),he();function It(Dt,Lt){J.push(function(){_n(Dt,Lt)})}function he(){if(J.length===0&&O===0)return B(null,S);for(;J.length&&O<y;){var Dt=J.shift();Dt()}}function $n(Dt,Lt){var te=W[Dt];te||(te=W[Dt]=[]),te.push(Lt)}function We(Dt){var Lt=W[Dt]||[];Fa(Lt,function(te){te()}),he()}function _n(Dt,Lt){if(!N){var te=Pn(function(Mi,um){if(O--,arguments.length>2&&(um=o(arguments,1)),Mi){var dm={};pl(S,function(Lz,Mz){dm[Mz]=Lz}),dm[Dt]=um,N=!0,W=Object.create(null),B(Mi,dm)}else S[Dt]=um,We(Dt)});O++;var ro=E(Lt[Lt.length-1]);Lt.length>1?ro(S,te):ro(te)}}function Sz(){for(var Dt,Lt=0;Z.length;)Dt=Z.pop(),Lt++,Fa(Dz(Dt),function(te){--tt[te]===0&&Z.push(te)});if(Lt!==D)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function Dz(Dt){var Lt=[];return pl(C,function(te,ro){pn(te)&&Ha(te,Dt,0)>=0&&Lt.push(ro)}),Lt}};function Si(C,y){for(var B=-1,I=C==null?0:C.length,D=Array(I);++B<I;)D[B]=y(C[B],B,C);return D}var _j="[object Symbol]";function Fj(C){return typeof C=="symbol"||Pa(C)&&_o(C)==_j}var Hj=1/0,S9=ot?ot.prototype:void 0,D9=S9?S9.toString:void 0;function Xf(C){if(typeof C=="string")return C;if(pn(C))return Si(C,Xf)+"";if(Fj(C))return D9?D9.call(C):"";var y=C+"";return y=="0"&&1/C==-Hj?"-0":y}function jj(C,y,B){var I=-1,D=C.length;y<0&&(y=-y>D?0:D+y),B=B>D?D:B,B<0&&(B+=D),D=y>B?0:B-y>>>0,y>>>=0;for(var S=Array(D);++I<D;)S[I]=C[I+y];return S}function zj(C,y,B){var I=C.length;return B=B===void 0?I:B,!y&&B>=I?C:jj(C,y,B)}function Uj(C,y){for(var B=C.length;B--&&Ha(y,C[B],0)>-1;);return B}function Vj(C,y){for(var B=-1,I=C.length;++B<I&&Ha(y,C[B],0)>-1;);return B}function qj(C){return C.split("")}var Wj="\\ud800-\\udfff",Gj="\\u0300-\\u036f",Zj="\\ufe20-\\ufe2f",Qj="\\u20d0-\\u20ff",Yj=Gj+Zj+Qj,Jj="\\ufe0e\\ufe0f",Kj="\\u200d",Xj=RegExp("["+Kj+Wj+Yj+Jj+"]");function tz(C){return Xj.test(C)}var L9="\\ud800-\\udfff",ez="\\u0300-\\u036f",nz="\\ufe20-\\ufe2f",oz="\\u20d0-\\u20ff",rz=ez+nz+oz,iz="\\ufe0e\\ufe0f",sz="["+L9+"]",tm="["+rz+"]",em="\\ud83c[\\udffb-\\udfff]",lz="(?:"+tm+"|"+em+")",M9="[^"+L9+"]",R9="(?:\\ud83c[\\udde6-\\uddff]){2}",O9="[\\ud800-\\udbff][\\udc00-\\udfff]",cz="\\u200d",N9=lz+"?",P9="["+iz+"]?",az="(?:"+cz+"(?:"+[M9,R9,O9].join("|")+")"+P9+N9+")*",uz=P9+N9+az,dz="(?:"+[M9+tm+"?",tm,R9,O9,sz].join("|")+")",hz=RegExp(em+"(?="+em+")|"+dz+uz,"g");function fz(C){return C.match(hz)||[]}function $9(C){return tz(C)?fz(C):qj(C)}function mz(C){return C==null?"":Xf(C)}var gz=/^\s+|\s+$/g;function pz(C,y,B){if(C=mz(C),C&&(B||y===void 0))return C.replace(gz,"");if(!C||!(y=Xf(y)))return C;var I=$9(C),D=$9(y),S=Vj(I,D),O=Uj(I,D)+1;return zj(I,S,O).join("")}var Cz=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,Az=/,/,bz=/(=.+)?(\s*)$/,vz=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function yz(C){return C=C.toString().replace(vz,""),C=C.match(Cz)[2].replace(" ",""),C=C?C.split(Az):[],C=C.map(function(y){return pz(y.replace(bz,""))}),C}function _9(C,y){var B={};pl(C,function(I,D){var S,O=T(I),N=!O&&I.length===1||O&&I.length===0;if(pn(I))S=I.slice(0,-1),I=I[I.length-1],B[D]=S.concat(S.length>0?W:I);else if(N)B[D]=I;else{if(S=yz(I),I.length===0&&!O&&S.length===0)throw new Error("autoInject task functions require explicit parameters.");O||S.pop(),B[D]=S.concat(W)}function W(J,Z){var tt=Si(S,function(It){return J[It]});tt.push(Z),E(I).apply(null,tt)}}),Kf(B,y)}function Cn(){this.head=this.tail=null,this.length=0}function F9(C,y){C.length=1,C.head=C.tail=y}Cn.prototype.removeLink=function(C){return C.prev?C.prev.next=C.next:this.head=C.next,C.next?C.next.prev=C.prev:this.tail=C.prev,C.prev=C.next=null,this.length-=1,C},Cn.prototype.empty=function(){for(;this.head;)this.shift();return this},Cn.prototype.insertAfter=function(C,y){y.prev=C,y.next=C.next,C.next?C.next.prev=y:this.tail=y,C.next=y,this.length+=1},Cn.prototype.insertBefore=function(C,y){y.prev=C.prev,y.next=C,C.prev?C.prev.next=y:this.head=y,C.prev=y,this.length+=1},Cn.prototype.unshift=function(C){this.head?this.insertBefore(this.head,C):F9(this,C)},Cn.prototype.push=function(C){this.tail?this.insertAfter(this.tail,C):F9(this,C)},Cn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},Cn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},Cn.prototype.toArray=function(){for(var C=Array(this.length),y=this.head,B=0;B<this.length;B++)C[B]=y.data,y=y.next;return C},Cn.prototype.remove=function(C){for(var y=this.head;y;){var B=y.next;C(y)&&this.removeLink(y),y=B}return this};function H9(C,y,B){if(y==null)y=1;else if(y===0)throw new Error("Concurrency must not be zero");var I=E(C),D=0,S=[],O=!1;function N(tt,It,he){if(he!=null&&typeof he!="function")throw new Error("task callback must be a function");if(Z.started=!0,pn(tt)||(tt=[tt]),tt.length===0&&Z.idle())return m(function(){Z.drain()});for(var $n=0,We=tt.length;$n<We;$n++){var _n={data:tt[$n],callback:he||ft};It?Z._tasks.unshift(_n):Z._tasks.push(_n)}O||(O=!0,m(function(){O=!1,Z.process()}))}function W(tt){return function(It){D-=1;for(var he=0,$n=tt.length;he<$n;he++){var We=tt[he],_n=Ha(S,We,0);_n===0?S.shift():_n>0&&S.splice(_n,1),We.callback.apply(We,arguments),It!=null&&Z.error(It,We.data)}D<=Z.concurrency-Z.buffer&&Z.unsaturated(),Z.idle()&&Z.drain(),Z.process()}}var J=!1,Z={_tasks:new Cn,concurrency:y,payload:B,saturated:ft,unsaturated:ft,buffer:y/4,empty:ft,drain:ft,error:ft,started:!1,paused:!1,push:function(tt,It){N(tt,!1,It)},kill:function(){Z.drain=ft,Z._tasks.empty()},unshift:function(tt,It){N(tt,!0,It)},remove:function(tt){Z._tasks.remove(tt)},process:function(){if(!J){for(J=!0;!Z.paused&&D<Z.concurrency&&Z._tasks.length;){var tt=[],It=[],he=Z._tasks.length;Z.payload&&(he=Math.min(he,Z.payload));for(var $n=0;$n<he;$n++){var We=Z._tasks.shift();tt.push(We),S.push(We),It.push(We.data)}D+=1,Z._tasks.length===0&&Z.empty(),D===Z.concurrency&&Z.saturated();var _n=Pn(W(tt));I(It,_n)}J=!1}},length:function(){return Z._tasks.length},running:function(){return D},workersList:function(){return S},idle:function(){return Z._tasks.length+D===0},pause:function(){Z.paused=!0},resume:function(){Z.paused!==!1&&(Z.paused=!1,m(Z.process))}};return Z}function j9(C,y){return H9(C,1,y)}var Di=ie(Br,1);function jo(C,y,B,I){I=Fo(I||ft);var D=E(B);Di(C,function(S,O,N){D(y,S,function(W,J){y=J,N(W)})},function(S){I(S,y)})}function nm(){var C=Si(arguments,E);return function(){var y=o(arguments),B=this,I=y[y.length-1];typeof I=="function"?y.pop():I=ft,jo(C,y,function(D,S,O){S.apply(B,D.concat(function(N){var W=o(arguments,1);O(N,W)}))},function(D,S){I.apply(B,[D].concat(S))})}}var z9=function(){return nm.apply(null,o(arguments).reverse())},kz=Array.prototype.concat,ja=function(C,y,B,I){I=I||ft;var D=E(B);Ti(C,y,function(S,O){D(S,function(N){return N?O(N):O(null,o(arguments,1))})},function(S,O){for(var N=[],W=0;W<O.length;W++)O[W]&&(N=kz.apply(N,O[W]));return I(S,N)})},U9=ie(ja,1/0),V9=ie(ja,1),q9=function(){var C=o(arguments),y=[null].concat(C);return function(){var B=arguments[arguments.length-1];return B.apply(this,y)}};function Cl(C){return C}function Li(C,y){return function(B,I,D,S){S=S||ft;var O=!1,N;B(I,function(W,J,Z){D(W,function(tt,It){tt?Z(tt):C(It)&&!N?(O=!0,N=y(!0,W),Z(null,Gf)):Z()})},function(W){W?S(W):S(null,O?N:y(!1))})}}function W9(C,y){return y}var za=Ii(Li(Cl,W9)),Al=xi(Li(Cl,W9)),Ua=ie(Al,1);function G9(C){return function(y){var B=o(arguments,1);B.push(function(I){var D=o(arguments,1);typeof console=="object"&&(I?console.error&&console.error(I):console[C]&&Fa(D,function(S){console[C](S)}))}),E(y).apply(null,B)}}var Z9=G9("dir");function Q9(C,y,B){B=Pn(B||ft);var I=E(C),D=E(y);function S(N){if(N)return B(N);var W=o(arguments,1);W.push(O),D.apply(this,W)}function O(N,W){if(N)return B(N);if(!W)return B(null);I(S)}O(null,!0)}function om(C,y,B){B=Pn(B||ft);var I=E(C),D=function(S){if(S)return B(S);var O=o(arguments,1);if(y.apply(this,O))return I(D);B.apply(null,[null].concat(O))};I(D)}function Y9(C,y,B){om(C,function(){return!y.apply(this,arguments)},B)}function J9(C,y,B){B=Pn(B||ft);var I=E(y),D=E(C);function S(N){if(N)return B(N);D(O)}function O(N,W){if(N)return B(N);if(!W)return B(null);I(S)}D(O)}function K9(C){return function(y,B,I){return C(y,I)}}function Va(C,y,B){Ho(C,K9(E(y)),B)}function bl(C,y,B,I){$a(y)(C,K9(E(B)),I)}var vl=ie(bl,1);function rm(C){return T(C)?C:i(function(y,B){var I=!0;y.push(function(){var D=arguments;I?m(function(){B.apply(null,D)}):B.apply(null,D)}),C.apply(this,y),I=!1})}function qa(C){return!C}var Wa=Ii(Li(qa,qa)),yl=xi(Li(qa,qa)),Ga=ie(yl,1);function X9(C){return function(y){return y==null?void 0:y[C]}}function wz(C,y,B,I){var D=new Array(y.length);C(y,function(S,O,N){B(S,function(W,J){D[O]=!!J,N(W)})},function(S){if(S)return I(S);for(var O=[],N=0;N<y.length;N++)D[N]&&O.push(y[N]);I(null,O)})}function Bz(C,y,B,I){var D=[];C(y,function(S,O,N){B(S,function(W,J){W?N(W):(J&&D.push({index:O,value:S}),N())})},function(S){S?I(S):I(null,Si(D.sort(function(O,N){return O.index-N.index}),X9("value")))})}function im(C,y,B,I){var D=ml(y)?wz:Bz;D(C,y,E(B),I||ft)}var Za=Ii(im),kl=xi(im),Qa=ie(kl,1);function t7(C,y){var B=Pn(y||ft),I=E(rm(C));function D(S){if(S)return B(S);I(D)}D()}var Ya=function(C,y,B,I){I=I||ft;var D=E(B);Ti(C,y,function(S,O){D(S,function(N,W){return N?O(N):O(null,{key:W,val:S})})},function(S,O){for(var N={},W=Object.prototype.hasOwnProperty,J=0;J<O.length;J++)if(O[J]){var Z=O[J].key,tt=O[J].val;W.call(N,Z)?N[Z].push(tt):N[Z]=[tt]}return I(S,N)})},e7=ie(Ya,1/0),n7=ie(Ya,1),o7=G9("log");function Ja(C,y,B,I){I=Fo(I||ft);var D={},S=E(B);Br(C,y,function(O,N,W){S(O,N,function(J,Z){if(J)return W(J);D[N]=Z,W()})},function(O){I(O,D)})}var r7=ie(Ja,1/0),i7=ie(Ja,1);function s7(C,y){return y in C}function l7(C,y){var B=Object.create(null),I=Object.create(null);y=y||Cl;var D=E(C),S=i(function(N,W){var J=y.apply(null,N);s7(B,J)?m(function(){W.apply(null,B[J])}):s7(I,J)?I[J].push(W):(I[J]=[W],D.apply(null,N.concat(function(){var Z=o(arguments);B[J]=Z;var tt=I[J];delete I[J];for(var It=0,he=tt.length;It<he;It++)tt[It].apply(null,Z)})))});return S.memo=B,S.unmemoized=C,S}var Ka;c?Ka=process.nextTick:l?Ka=setImmediate:Ka=a;var c7=d(Ka);function sm(C,y,B){B=B||ft;var I=ml(y)?[]:{};C(y,function(D,S,O){E(D)(function(N,W){arguments.length>2&&(W=o(arguments,1)),I[S]=W,O(N)})},function(D){B(D,I)})}function a7(C,y){sm(Ho,C,y)}function u7(C,y,B){sm($a(y),C,B)}var lm=function(C,y){var B=E(C);return H9(function(I,D){B(I[0],D)},y,1)},d7=function(C,y){var B=lm(C,y);return B.push=function(I,D,S){if(S==null&&(S=ft),typeof S!="function")throw new Error("task callback must be a function");if(B.started=!0,pn(I)||(I=[I]),I.length===0)return m(function(){B.drain()});D=D||0;for(var O=B._tasks.head;O&&D>=O.priority;)O=O.next;for(var N=0,W=I.length;N<W;N++){var J={data:I[N],priority:D,callback:S};O?B._tasks.insertBefore(O,J):B._tasks.push(J)}m(B.process)},delete B.unshift,B};function h7(C,y){if(y=Fo(y||ft),!pn(C))return y(new TypeError("First argument to race must be an array of functions"));if(!C.length)return y();for(var B=0,I=C.length;B<I;B++)E(C[B])(y)}function Xa(C,y,B,I){var D=o(C).reverse();jo(D,y,B,I)}function tu(C){var y=E(C);return i(function(I,D){return I.push(function(O,N){if(O)D(null,{error:O});else{var W;arguments.length<=2?W=N:W=o(arguments,1),D(null,{value:W})}}),y.apply(this,I)})}function f7(C){var y;return pn(C)?y=Si(C,tu):(y={},pl(C,function(B,I){y[I]=tu.call(this,B)})),y}function m7(C,y,B,I){im(C,y,function(D,S){B(D,function(O,N){S(O,!N)})},I)}var g7=Ii(m7),cm=xi(m7),p7=ie(cm,1);function C7(C){return function(){return C}}function eu(C,y,B){var I=5,D=0,S={times:I,intervalFunc:C7(D)};function O(Z,tt){if(typeof tt=="object")Z.times=+tt.times||I,Z.intervalFunc=typeof tt.interval=="function"?tt.interval:C7(+tt.interval||D),Z.errorFilter=tt.errorFilter;else if(typeof tt=="number"||typeof tt=="string")Z.times=+tt||I;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof C=="function"?(B=y||ft,y=C):(O(S,C),B=B||ft),typeof y!="function")throw new Error("Invalid arguments for async.retry");var N=E(y),W=1;function J(){N(function(Z){Z&&W++<S.times&&(typeof S.errorFilter!="function"||S.errorFilter(Z))?setTimeout(J,S.intervalFunc(W)):B.apply(null,arguments)})}J()}var A7=function(C,y){y||(y=C,C=null);var B=E(y);return i(function(I,D){function S(O){B.apply(null,I.concat(O))}C?eu(C,S,D):eu(S,D)})};function b7(C,y){sm(Di,C,y)}var nu=Ii(Li(Boolean,Cl)),wl=xi(Li(Boolean,Cl)),ou=ie(wl,1);function v7(C,y,B){var I=E(y);_a(C,function(S,O){I(S,function(N,W){if(N)return O(N);O(null,{value:S,criteria:W})})},function(S,O){if(S)return B(S);B(null,Si(O.sort(D),X9("value")))});function D(S,O){var N=S.criteria,W=O.criteria;return N<W?-1:N>W?1:0}}function y7(C,y,B){var I=E(C);return i(function(D,S){var O=!1,N;function W(){var J=C.name||"anonymous",Z=new Error('Callback function "'+J+'" timed out.');Z.code="ETIMEDOUT",B&&(Z.info=B),O=!0,S(Z)}D.push(function(){O||(S.apply(null,arguments),clearTimeout(N))}),N=setTimeout(W,y),I.apply(null,D)})}var Ez=Math.ceil,Iz=Math.max;function xz(C,y,B,I){for(var D=-1,S=Iz(Ez((y-C)/(B||1)),0),O=Array(S);S--;)O[I?S:++D]=C,C+=B;return O}function ru(C,y,B,I){var D=E(B);Ti(xz(0,C,1),y,D,I)}var k7=ie(ru,1/0),w7=ie(ru,1);function B7(C,y,B,I){arguments.length<=3&&(I=B,B=y,y=pn(C)?[]:{}),I=Fo(I||ft);var D=E(B);Ho(C,function(S,O,N){D(y,S,O,N)},function(S){I(S,y)})}function E7(C,y){var B=null,I;y=y||ft,vl(C,function(D,S){E(D)(function(O,N){arguments.length>2?I=o(arguments,1):I=N,B=O,S(!O)})},function(){y(B,I)})}function I7(C){return function(){return(C.unmemoized||C).apply(null,arguments)}}function am(C,y,B){B=Pn(B||ft);var I=E(y);if(!C())return B(null);var D=function(S){if(S)return B(S);if(C())return I(D);var O=o(arguments,1);B.apply(null,[null].concat(O))};I(D)}function x7(C,y,B){am(function(){return!C.apply(this,arguments)},y,B)}var T7=function(C,y){if(y=Fo(y||ft),!pn(C))return y(new Error("First argument to waterfall must be an array of functions"));if(!C.length)return y();var B=0;function I(S){var O=E(C[B++]);S.push(Pn(D)),O.apply(null,S)}function D(S){if(S||B===C.length)return y.apply(null,arguments);I(o(arguments,1))}I([])},Tz={apply:r,applyEach:x9,applyEachSeries:T9,asyncify:p,auto:Kf,autoInject:_9,cargo:j9,compose:z9,concat:U9,concatLimit:ja,concatSeries:V9,constant:q9,detect:za,detectLimit:Al,detectSeries:Ua,dir:Z9,doDuring:Q9,doUntil:Y9,doWhilst:om,during:J9,each:Va,eachLimit:bl,eachOf:Ho,eachOfLimit:Br,eachOfSeries:Di,eachSeries:vl,ensureAsync:rm,every:Wa,everyLimit:yl,everySeries:Ga,filter:Za,filterLimit:kl,filterSeries:Qa,forever:t7,groupBy:e7,groupByLimit:Ya,groupBySeries:n7,log:o7,map:_a,mapLimit:Ti,mapSeries:Jf,mapValues:r7,mapValuesLimit:Ja,mapValuesSeries:i7,memoize:l7,nextTick:c7,parallel:a7,parallelLimit:u7,priorityQueue:d7,queue:lm,race:h7,reduce:jo,reduceRight:Xa,reflect:tu,reflectAll:f7,reject:g7,rejectLimit:cm,rejectSeries:p7,retry:eu,retryable:A7,seq:nm,series:b7,setImmediate:m,some:nu,someLimit:wl,someSeries:ou,sortBy:v7,timeout:y7,times:k7,timesLimit:ru,timesSeries:w7,transform:B7,tryEach:E7,unmemoize:I7,until:x7,waterfall:T7,whilst:am,all:Wa,allLimit:yl,allSeries:Ga,any:nu,anyLimit:wl,anySeries:ou,find:za,findLimit:Al,findSeries:Ua,forEach:Va,forEachSeries:vl,forEachLimit:bl,forEachOf:Ho,forEachOfSeries:Di,forEachOfLimit:Br,inject:jo,foldl:jo,foldr:Xa,select:Za,selectLimit:kl,selectSeries:Qa,wrapSync:p};e.default=Tz,e.apply=r,e.applyEach=x9,e.applyEachSeries=T9,e.asyncify=p,e.auto=Kf,e.autoInject=_9,e.cargo=j9,e.compose=z9,e.concat=U9,e.concatLimit=ja,e.concatSeries=V9,e.constant=q9,e.detect=za,e.detectLimit=Al,e.detectSeries=Ua,e.dir=Z9,e.doDuring=Q9,e.doUntil=Y9,e.doWhilst=om,e.during=J9,e.each=Va,e.eachLimit=bl,e.eachOf=Ho,e.eachOfLimit=Br,e.eachOfSeries=Di,e.eachSeries=vl,e.ensureAsync=rm,e.every=Wa,e.everyLimit=yl,e.everySeries=Ga,e.filter=Za,e.filterLimit=kl,e.filterSeries=Qa,e.forever=t7,e.groupBy=e7,e.groupByLimit=Ya,e.groupBySeries=n7,e.log=o7,e.map=_a,e.mapLimit=Ti,e.mapSeries=Jf,e.mapValues=r7,e.mapValuesLimit=Ja,e.mapValuesSeries=i7,e.memoize=l7,e.nextTick=c7,e.parallel=a7,e.parallelLimit=u7,e.priorityQueue=d7,e.queue=lm,e.race=h7,e.reduce=jo,e.reduceRight=Xa,e.reflect=tu,e.reflectAll=f7,e.reject=g7,e.rejectLimit=cm,e.rejectSeries=p7,e.retry=eu,e.retryable=A7,e.seq=nm,e.series=b7,e.setImmediate=m,e.some=nu,e.someLimit=wl,e.someSeries=ou,e.sortBy=v7,e.timeout=y7,e.times=k7,e.timesLimit=ru,e.timesSeries=w7,e.transform=B7,e.tryEach=E7,e.unmemoize=I7,e.until=x7,e.waterfall=T7,e.whilst=am,e.all=Wa,e.allLimit=yl,e.allSeries=Ga,e.any=nu,e.anyLimit=wl,e.anySeries=ou,e.find=za,e.findLimit=Al,e.findSeries=Ua,e.forEach=Va,e.forEachSeries=vl,e.forEachLimit=bl,e.forEachOf=Ho,e.forEachOfSeries=Di,e.forEachOfLimit=Br,e.inject=jo,e.foldl=jo,e.foldr=Xa,e.select=Za,e.selectLimit=kl,e.selectSeries=Qa,e.wrapSync=p,Object.defineProperty(e,"__esModule",{value:!0})})})(oh,oh.exports);var _2={exports:{}},rh=_2.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),o=2;e===1/0;o*=2)e=Math.log(Math.pow(2,n/o))/Math.log(t)*o;for(var r=e-Math.floor(e),i="",o=0;o<Math.floor(e);o++){var s=Math.floor(Math.random()*t).toString(t);i=s+i}if(r){var l=Math.pow(t,r),s=Math.floor(Math.random()*l).toString(t);i=s+i}var c=parseInt(i,t);return c!==1/0&&c>=Math.pow(2,n)?rh(n,t):i};rh.rack=function(n,t,e){var o=function(i){var s=0;do{if(s++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=rh(n,t)}while(Object.hasOwnProperty.call(r,l));return r[l]=i,l},r=o.hats={};return o.get=function(i){return o.hats[i]},o.set=function(i,s){return o.hats[i]=s,o},o.bits=n||128,o.base=t||16,o};var F2=ko,yk=P2,kk=$2,Ic=ln,ih=oh.exports,wk=_2.exports,H2=lr.ACTIONS,j2=Ht;function Ht(n,t){if(F2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}F2.mixin(Ht),Ht.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Ht.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Ht.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||wk();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},Ht.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(o){if(o)return t._callbackOrEmit(o,n);var r=Object.keys(t._remotePresenceInstances);ih.parallel([function(i){ih.each(e,function(s,l){t.localPresences[s].destroy(l)},i)},function(i){if(!t._wantsDestroy)return i();ih.each(r,function(s,l){t._remotePresenceInstances[s].destroy(l)},i)}],function(i){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(i,n)})})},Ht.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?H2.presenceSubscribe:H2.presenceUnsubscribe,o=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[o]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,o,this)},Ht.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Ht.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Ht.prototype._receiveUpdate=function(n,t){var e=Ic.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var o=this,r=Ic.digOrCreate(this._remotePresenceInstances,t.id,function(){return o._createRemotePresence(t.id)});r.receiveUpdate(t)},Ht.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Ht.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},Ht.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Ht.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Ht.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var o=this;this.subscribe(function(r){o._callEachOrEmit(n,r)})},Ht.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},Ht.prototype._callbackOrEmit=function(n,t){if(t)return Ic.nextTick(t,n);n&&this.emit("error",n)},Ht.prototype._createLocalPresence=function(n){return new yk(this,n)},Ht.prototype._createRemotePresence=function(n){return new kk(this,n)},Ht.prototype._callEachOrEmit=function(n,t){var e=Ic.callEach(n,t);!e&&t&&this.emit("error",t)};var As=P2,z2=yc,Bk=ln,U2=z2.CODES,Ek=an;function an(n,t){As.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}an.prototype=Object.create(As.prototype),an.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:U2.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,As.prototype.submit.call(this,n,t)},an.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createOrDelHandler),this._doc.removeListener("del",this._createOrDelHandler),this._doc.removeListener("load",this._loadHandler),this._doc.removeListener("destroy",this._destroyHandler),As.prototype.destroy.call(this,n)},an.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},an.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createOrDelHandler),this._doc.on("del",this._createOrDelHandler),this._doc.on("load",this._loadHandler),this._doc.on("destroy",this._destroyHandler)},an.prototype._transformAgainstOp=function(n,t){var e=this,o=this._doc._dataStateVersion;this._pendingMessages.forEach(function(r){var i=e._docDataVersionByPresenceVersion[r.pv];if(!(i>=o))try{r.p=e._transformPresence(r.p,n,t),e._docDataVersionByPresenceVersion[r.pv]=o}catch(l){var s=e._getCallback(r.pv);e._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,t)}catch(r){this.emit("error",r)}},an.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},an.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},an.prototype._message=function(){var n=As.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},an.prototype._transformPresence=function(n,t,e){var o=this._doc.type;if(!Bk.supportsPresence(o))throw new z2(U2.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+o.name);return o.transformPresence(n,t,e)};var V2={};(function(n){var t=gs,e=yc,o=ln,r=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(r.ERR_OT_OP_BADLY_FORMED,"Missing create type");var a=t.map[c];if(a==null||typeof a!="object")return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(r.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(r.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(r.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(r.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(r.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(r.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(r.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(r.ERR_DOC_ALREADY_CREATED,"Document already exists");var a=c.create,d=t.map[a.type];if(!d)return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.create(a.data),l.type=d.uri,l.v++}catch(m){return m}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var f=i(l,c.op);if(f)return f;l.v++}else l.v++};function i(l,c){if(!l.type)return new e(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(r.ERR_OT_OP_NOT_PROVIDED,"Missing op");var a=t.map[l.type];if(!a)return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=a.apply(l.data,c)}catch(d){return new e(r.ERR_OT_OP_NOT_APPLIED,d.message)}}n.transform=function(l,c,a){if(c.v!=null&&c.v!==a.v)return new e(r.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(a.del){if(c.create||"op"in c)return new e(r.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(a.create&&("op"in c||c.create||c.del)||"op"in a&&c.create)return new e(r.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in a&&"op"in c){if(!l)return new e(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,a.op,"left")}catch(d){return d}}}c.v!=null&&c.v++},n.applyOps=function(l,c,a){a=a||{};for(var d=0;d<c.length;d++){var f=c[d];if(a._normalizeLegacyJson0Ops)try{s(l,f)}catch{return new e(r.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=f.v;var m=n.apply(l,f);if(m)return m}},n.transformPresence=function(l,c,a){var d=this.checkOp(c);if(d)return d;var f=l.t;if(typeof f=="string"&&(f=t.map[f]),!f)return{code:r.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!o.supportsPresence(f))return{code:r.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:f.transformPresence(l.p,c.op,a)}catch(m){return{code:r.ERR_PRESENCE_TRANSFORM_FAILED,message:m.message||m}}l.v++};function s(l,c){if(l.type===t.defaultType.uri){var a=c.op;if(!!a){var d=l.data;a.length>1&&(d=o.clone(d));for(var f=0;f<a.length;f++){var m=a[f];typeof m.lm=="string"&&(m.lm=+m.lm);for(var p=m.p,A=d,k=0;k<p.length;k++){var v=p[k];Object.prototype.toString.call(A)=="[object Array]"?p[k]=+v:A.constructor===Object&&(p[k]=v.toString()),A=A[v]}f<a.length-1&&(d=t.defaultType.apply(d,[m]))}}}}})(V2);var bs=$2,Ik=V2,xk=Fe;function Fe(n,t){bs.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}Fe.prototype=Object.create(bs.prototype),Fe.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},Fe.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createDelHandler),this._doc.removeListener("del",this._createDelHandler),this._doc.removeListener("load",this._loadHandler),bs.prototype.destroy.call(this,n)},Fe.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createDelHandler),this._doc.on("del",this._createDelHandler),this._doc.on("load",this._loadHandler)},Fe.prototype._setPendingPresence=function(){if(!this._pendingSetPending){this._pendingSetPending=!0;var n=this;this._doc.whenNothingPending(function(){if(n._pendingSetPending=!1,!!n._pending){if(n._pending.pv<n.presenceVersion)return n._pending=null;if(n._pending.v>n._doc.version)return n._doc.fetch();!n._catchUpStalePresence()||(n.value=n._pending.p,n.presenceVersion=n._pending.pv,n._pending=null,n.presence._updateRemotePresence(n))}})}},Fe.prototype._handleOp=function(n,t,e){var o=e===this.src;this._transformAgainstOp(n,o),this._cacheOp(n,o),this._setPendingPresence()},bs.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},bs.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},Fe.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},Fe.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):Ik.transformPresence(this._pending,t,e)}var o=this._pending.v>=this._doc.version;return o&&this._stopCachingOps(),o},Fe.prototype._startCachingOps=function(){this._opCache=[]},Fe.prototype._stopCachingOps=function(){this._opCache=null},Fe.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var q2=j2,Tk=Ek,Sk=xk;function Vr(n,t,e){var o=Vr.channel(t,e);q2.call(this,n,o),this.collection=t,this.id=e}var Dk=Vr;Vr.prototype=Object.create(q2.prototype),Vr.channel=function(n,t){return n+"."+t},Vr.prototype._createLocalPresence=function(n){return new Tk(this,n)},Vr.prototype._createRemotePresence=function(n){return new Sk(this,n)};var Lk=Mk;function Mk(n,t,e,o,r){this.id=n,this.v=t,this.type=e,this.data=o,this.m=r}var Rk=Lk,W2=ko,G2=vs;function vs(n,t,e,o,r){if(W2.EventEmitter.call(this),typeof r!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=o,this.collection=e,this.callback=r,this.sent=!1}W2.mixin(vs),vs.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},vs.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},vs.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,o=new Rk(this.id,t.v,t.type,t.data,e);this.callback(null,o)};var Z2=G2,Ok=ln,Nk=lr.ACTIONS,Pk=sh;function sh(n,t,e,o,r,i){if(Z2.call(this,n,t,e,o,i),!Ok.isValidVersion(r))throw new Error("Snapshot version must be a positive integer or null");this.version=r}sh.prototype=Object.create(Z2.prototype),sh.prototype._message=function(){return{a:Nk.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var Q2=G2,$k=ln,_k=lr.ACTIONS,Fk=lh;function lh(n,t,e,o,r,i){if(Q2.call(this,n,t,e,o,i),!$k.isValidTimestamp(r))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=r}lh.prototype=Object.create(Q2.prototype),lh.prototype._message=function(){return{a:_k.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var Hk=hk,jk=Ck,zk=j2,Y2=Dk,Uk=Pk,Vk=Fk,J2=ko,qr=yc,At=lr.ACTIONS,K2=gs,un=ln,ys=x2,ks=qr.CODES;function X2(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var qk=X;function X(n){J2.EventEmitter.call(this),this.collections={},this.nextQueryId=1,this.nextSnapshotRequestId=1,this.queries={},this._presences={},this._snapshotRequests={},this.seq=1,this._presenceSeq=1,this.id=null,this.agent=null,this.debug=!1,this.state=X2(n),this.bindToSocket(n)}J2.mixin(X),X.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=X2(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(o){try{var r=typeof o.data=="string"?JSON.parse(o.data):o.data}catch{ys.warn("Failed to parse message",o);return}e.debug&&ys.info("RECV",JSON.stringify(r));var i={data:r};if(e.emit("receive",i),!!i.data)try{e.handleMessage(i.data)}catch(s){un.nextTick(function(){e.emit("error",s)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(o){e.emit("connection error",o)},n.onclose=function(o){o==="closed"||o==="Closed"?e._setState("closed",o):o==="stopped"||o==="Stopped by server"?e._setState("stopped",o):e._setState("disconnected",o)}},X.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=t5(n.error,n),delete n.error),n.a){case At.initLegacy:return this._handleLegacyInit(n);case At.handshake:return this._handleHandshake(t,n);case At.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case At.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case At.queryUnsubscribe:return;case At.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case At.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case At.bulkSubscribe:case At.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case At.snapshotFetch:case At.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case At.fetch:var o=this.getExisting(n.c,n.d);o&&o._handleFetch(t,n.data);return;case At.subscribe:case At.unsubscribe:var o=this.getExisting(n.c,n.d);o&&o._handleSubscribe(t,n.data);return;case At.op:var o=this.getExisting(n.c,n.d);o&&o._handleOp(t,n);return;case At.presence:return this._handlePresence(t,n);case At.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case At.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case At.presenceRequest:return this._handlePresenceRequest(t,n);case At.pingPong:return this._handlePingPong(t);default:ys.warn("Ignoring unrecognized message",n)}};function t5(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}X.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var o in t.data){var r=t.data[o],i=this.getExisting(t.c,o);i&&(n?i[e](n):r.error?i[e](t5(r.error)):i[e](null,r))}else if(Array.isArray(t.b))for(var s=0;s<t.b.length;s++){var o=t.b[s],i=this.getExisting(t.c,o);i&&i[e](n)}else if(t.b)for(var o in t.b){var i=this.getExisting(t.c,o);i&&i[e](n)}else ys.error("Invalid bulk message",t)},X.prototype._reset=function(){this.agent=null},X.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new qr(ks.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var o in this.queries){var r=this.queries[o];r._onConnectionStateChanged()}for(var i in this.collections){var s=this.collections[i];for(var o in s)s[o]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var o in this._snapshotRequests){var c=this._snapshotRequests[o];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},X.prototype.startBulk=function(){this.bulk||(this.bulk={})},X.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},X.prototype._sendBulk=function(n,t,e){if(!!e){var o=[],r={},i=0,s;for(var l in e){var c=e[l];c==null?o.push(l):(r[l]=c,s=l,i++)}if(o.length===1){var l=o[0];this.send({a:n,c:t,d:l})}else o.length&&this.send({a:"b"+n,c:t,b:o});if(i===1){var a=r[s];this.send({a:n,c:t,d:s,v:a})}else i&&this.send({a:"b"+n,c:t,b:r})}},X.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var o=this.bulk[t.collection]||(this.bulk[t.collection]={}),r=o[n]||(o[n]={}),i=r.hasOwnProperty(t.id);return r[t.id]=e,i}else{var s={a:n,c:t.collection,d:t.id,v:e};this.send(s)}},X.prototype.sendFetch=function(n){return this._sendActions(At.fetch,n,n.version)},X.prototype.sendSubscribe=function(n){return this._sendActions(At.subscribe,n,n.version)},X.prototype.sendUnsubscribe=function(n){return this._sendActions(At.unsubscribe,n)},X.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:At.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},X.prototype.send=function(n){this.debug&&ys.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},X.prototype.ping=function(){if(!this.canSend)throw new qr(ks.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:At.pingPong};this.send(n)},X.prototype.close=function(){this.socket.close()},X.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},X.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),o=e[t];return o||(o=e[t]=new Hk(this,n,t),this.emit("doc",o)),o._wantsDestroy=!1,o},X.prototype._destroyDoc=function(n){!n._wantsDestroy||(un.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},X.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},X.prototype._createQuery=function(n,t,e,o,r){var i=this.nextQueryId++,s=new jk(n,this,i,t,e,o,r);return this.queries[i]=s,s.send(),s},X.prototype._destroyQuery=function(n){delete this.queries[n.id]},X.prototype.createFetchQuery=function(n,t,e,o){return this._createQuery(At.queryFetch,n,t,e,o)},X.prototype.createSubscribeQuery=function(n,t,e,o){return this._createQuery(At.querySubscribe,n,t,e,o)},X.prototype.hasPending=function(){return!!(this._firstDoc(xc)||this._firstQuery(xc)||this._firstSnapshotRequest())};function xc(n){return n.hasPending()}X.prototype.hasWritePending=function(){return!!this._firstDoc(Wk)};function Wk(n){return n.hasWritePending()}X.prototype.whenNothingPending=function(n){var t=this._firstDoc(xc);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(xc);if(e){e.once("ready",this._nothingPendingRetry(n));return}var o=this._firstSnapshotRequest();if(o){o.once("ready",this._nothingPendingRetry(n));return}un.nextTick(n)},X.prototype._nothingPendingRetry=function(n){var t=this;return function(){un.nextTick(function(){t.whenNothingPending(n)})}},X.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var o in e){var r=e[o];if(n(r))return r}}},X.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},X.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},X.prototype.fetchSnapshot=function(n,t,e,o){typeof e=="function"&&(o=e,e=null);var r=this.nextSnapshotRequestId++,i=new Uk(this,r,n,t,e,o);this._snapshotRequests[i.requestId]=i,i.send()},X.prototype.fetchSnapshotByTimestamp=function(n,t,e,o){typeof e=="function"&&(o=e,e=null);var r=this.nextSnapshotRequestId++,i=new Vk(this,r,n,t,e,o);this._snapshotRequests[i.requestId]=i,i.send()},X.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},X.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},X.prototype._initializeHandshake=function(){this.send({a:At.handshake,id:this.id})},X.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},X.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},X.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new qr(ks.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(K2.map[n.type]!==K2.defaultType)return this.emit("error",new qr(ks.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new qr(ks.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},X.prototype.getPresence=function(n){var t=this,e=un.digOrCreate(this._presences,n,function(){return new zk(t,n)});return e._wantsDestroy=!1,e},X.prototype.getDocPresence=function(n,t){var e=Y2.channel(n,t),o=this,r=un.digOrCreate(this._presences,e,function(){return new Y2(o,n,t)});return r._wantsDestroy=!1,r},X.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var o={a:n,ch:e.channel,seq:t};return this.send(o),o.seq},X.prototype._addPresence=function(n){un.digOrCreate(this._presences,n.channel,function(){return n})},X.prototype._handlePresenceSubscribe=function(n,t){var e=un.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},X.prototype._handlePresenceUnsubscribe=function(n,t){var e=un.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},X.prototype._handlePresence=function(n,t){var e=un.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},X.prototype._handlePresenceRequest=function(n,t){var e=un.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var e5=qk,Gk=gs;const Tc={err:1001,msg:"user auth error",name:"AuthError"},Zk={err:1002,msg:"you don't have required permission",name:"PermissionError"},ch={err:1003,msg:"Too many user connected",name:"MaxUserError"},ws={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},Qk={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},Yk={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},Bs="x-live-editor-token",Sc="x-live-editor-base-url",pe=w("auth-connection");function Jk(n){try{n()}catch(t){pe.error(t)}}class Kk{constructor(t,e){h(this,"connection");h(this,"ws");h(this,"retryCount");h(this,"events",new hm.EventEmitter);h(this,"token",null);h(this,"resourceToken",null);this.url=t,this.reauthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return Zo(this.getBaseURL())}async auth(t){u(pe,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,o=await window.fetch(e,{method:"GET",headers:{[Bs]:t.token,[Sc]:this.getBase64BaseURL()},credentials:"include"});if(o.status!==200)throw new Error("http auth error");return this.token=t.token,await o.json()}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[Sc]:Zo(this.getBaseURL())}})}async init(t){const e=await this.auth(t);this.resourceToken=e.read,this.ws=new n8.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(e5.prototype),u(pe,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})};const o=this.connection.handleMessage.bind(this.connection);this.connection.handleMessage=r=>{var s;const i=r;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in i||i.a==="pong")this.handleMessage(i);else{Object.prototype.hasOwnProperty.call(i,"a")&&i.a!=="init"&&i.a!=="hs"&&(this.retryCount=0);try{o(i)}catch(l){if((l==null?void 0:l.type)==="writeConflict"){this.emitWriteConflictError(l,i);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l,i);return}throw l}}},e5.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reauthFunc&&this.retryCount<5){this.retryCount+=1,pe.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const t=await this.reauthFunc();await this.auth(t),this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})}}}catch(t){pe.error(t),setTimeout(()=>this.handleAuthError(),0)}}else pe.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const t=new Error(Tc.msg);t.code=Tc.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(ws.msg);t.code=ws.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t,e){t.orgMsg=e,this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const o=e.err;if(o===Tc.err)pe.warn("auth error"),this.handleAuthError();else if(o===ch.err)pe.warn(ch.msg),this.emitMaxUsersError();else if(o===ws.err){pe.warn(ws.msg);try{this.emitRequestReloadError()}catch(r){pe.error(`error occurred while process reload error: ${JSON.stringify(r)}`)}finally{this.end(!1)}}else pe.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError()}get(t,e){return u(pe,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(u(pe,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){u(pe,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){u(pe,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e;this.reauthFunc=void 0,this.events.removeAllListeners(),Jk(()=>{var o;return(o=this.connection)==null?void 0:o.close()}),this.connection=void 0,(e=this.ws)==null||e.close(),this.ws=void 0,t&&this.logout()}}w("utils/file");function Xk(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}Xk();async function tw(n){const e=n.size,o=Math.floor((e+102400-1)/102400),r=new o8.Hash;for(let s=0;s<o;s++){const l=s*102400;let c=l+102400;c>e&&(c=e);const d=await n.slice(l,c,n.type).arrayBuffer();r.update(new Uint8Array(d))}const i=r.digest();return Zo(i)}const xn=w("sharedb-doc/client");class ew{constructor(t,e,o){h(this,"connection");h(this,"auth");h(this,"doc",null);h(this,"reauthFunc");h(this,"clientId",P());h(this,"getDoc",async()=>{const t=o=>new Promise((r,i)=>{o.fetch(s=>{s?i(s):r()})});u(xn,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),xn.debug(e),e});this.auth=t;const r=`${e}/${this.auth.appId}/${this.auth.docId}`;Gk.register(Il.type),this.connection=new Kk(r,o),this.reauthFunc=o}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return u(xn,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,o=>{(t==="error"||this.doc)&&e(o)})}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,o,r,i){try{const s=`${t}/${e}`,l=await this.request(s,{method:"post",headers:{...i},data:{name:o,size:r}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const o=`${this.apiServer()}/resources`;let r=[];t.forEach(l=>{const c=l.split("|");r.push(...c)}),r=Array.from(new Set(r));const i=r.map(l=>this.getFileUrlByHash(o,l,"",0,{[Bs]:this.connection.token}));return await Promise.all(i)}async uploadFile(t,e,o,r,i){let s=e.size;if(s===0)throw new Error("file is empty");s+=500;const l=p=>{xn.info(`on progress: ${p.loaded}`);let A=p.loaded*100/s;A>100&&(A=100),r(A)},c=await tw(e),a=await this.getFileUrlByHash(t,c,e.name,e.size,o);if(a)return r(-1),a;let d=t;i!=null&&i.thumbnail&&(d+="/thumbnail");const f=new FormData;f.append("file-size",`${e.size}`),f.append("file-hash",c),f.append("file",e,e.name);const m=await this.request(d,{method:"post",data:f,withCredentials:!0,headers:{...o},onUploadProgress:l});return xn.info(m),r(100),Array.isArray(m.data)?m.data[0]:m.data}async uploadResource(t,e=()=>{},o){const i=`${this.apiServer()}/resources`;u(xn,this.connection.token,"no connection token");const s=await this.uploadFile(i,t,{[Bs]:this.connection.token},e,o);return u(xn,s,"no result"),s}async request(t,e){var i,s;let o=this.connection.token,r;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),u(xn,o,"no token"),c.headers={...c.headers,[Bs]:o,[Sc]:this.connection.getBase64BaseURL()};try{return await t8.default(t,c)}catch(a){if(r=a,((i=a==null?void 0:a.response)==null?void 0:i.status)===403&&this.reauthFunc){const d=await this.reauthFunc();if(await this.connection.auth(d),!d.token)throw a;o=d.token;continue}throw(s=a.response)!=null&&s.data&&(a.responseData=a.response.data),a}}throw u(xn,r,"no error"),r}async getVersions(){const e=`${this.apiServer()}/versions`,o=await this.request(e),r=o.data.versions,i=o.data.latest;return i&&r.findIndex(s=>s.version===i)===-1&&r.unshift({version:-1,tag:"",published:!1}),r}async getVersion(t){const o=`${this.apiServer()}/versions/${t}`,r=await this.request(o);return JSON.parse(r.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,o=await this.request(e);return JSON.parse(o.data.data)}async getVersionOps(t,e){let r=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(r+=`&from=${e}`);const i=await this.request(r),s=i.data.ops,l=e8.default(s,d=>!!d.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let a;return c?(u(xn,c.create,"no createDoc.create"),a=c.create.data):a=JSON.parse(i.data.data),a.blocks||(a.blocks=[]),{doc:a,ops:i.data.ops}}async revertVersion(t){const o=`${this.apiServer()}/versions/revert/${t}`;await this.request(o,{method:"post",data:{}})}async createVersion(t,e){const r=`${this.apiServer()}/versions`;return(await this.request(r,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const o=`${this.apiServer()}/resources/external/${Zo(t)}`;return(await this.request(o)).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let r=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const i=[];if(e!=null&&e.withToken&&i.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&i.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),i.length>0){const s=i.join("&");r+=`?${s}`}return r}}function nw(){return{blocks:[{id:P(),type:"text",text:[]}],comments:{},meta:{}}}const ah=w("block-ids");class ow{constructor(){h(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((r,i)=>i-r);for(let r=0;r<e.length;r++){const i=e[r];if(i>=t){const s=this.ids.get(i);u(ah,s!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i+1,s)}}const o=P();this.ids.set(t,o)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((o,r)=>o-r);for(let o=0;o<e.length;o++){const r=e[o];if(r>t){const i=this.ids.get(r);u(ah,i!==void 0,"old id is not exists"),this.ids.delete(r),this.ids.set(r-1,i)}}}getId(t){let e=this.ids.get(t);return e||(e=P(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class rw{constructor(){h(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new ow,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let o=0;o<e.length;o++){const r=e[o],i=r[1].getById(t);if(i)return{containerId:r[0],blockIndex:i[0]}}return u(ah,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class n5{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,o)=>{t[o]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const _t=w("op-parser");function Wr(n){return n==="blocks"?"root":n}class iw{constructor(t,e){h(this,"updatingBlockDataDeltaMap",new Map);h(this,"blockIds",new rw);this.handler=t,this.local=e}onDeleteBlock(t,e){const o=this.blockIds.getBlockId(t,e);this.blockIds.onDeleteBlock(t,e);const r=this.updatingBlockDataDeltaMap.get(o);r&&(_t.debug(`ignore update object data before delete block: ${JSON.stringify(r)}`),this.updatingBlockDataDeltaMap.delete(o)),this.handler.onDeleteBlock(Wr(t),e,this.local)}onInsertBlock(t,e,o){this.blockIds.onInsertBlock(t,e),this.handler.onInsertBlock(Wr(t),e,o,this.local)}onUpdateBlockText(t,e,o){this.handler.onUpdateBlockText(Wr(t),e,o,this.local)}onDeleteBlockData(t,e,o){const r=this.blockIds.getBlockId(t,e);let i=this.updatingBlockDataDeltaMap.get(r);i||(i=new n5,this.updatingBlockDataDeltaMap.set(r,i)),i.delete(o)}onInsertBlockData(t,e,o,r){const i=this.blockIds.getBlockId(t,e);let s=this.updatingBlockDataDeltaMap.get(i);s||(s=new n5,this.updatingBlockDataDeltaMap.set(i,s)),s.insert(o,r)}executeUpdateBlockDataActions(){Array.from(this.updatingBlockDataDeltaMap.entries()).forEach(([t,e])=>{const{containerId:o,blockIndex:r}=this.blockIds.getBlockIndexById(t);this.handler.onUpdateBlockData(Wr(o),r,e.toDocBlockDelta(),this.local)})}}class o5{}class uh{constructor(t){h(this,"key");this.key=t}}function sw(n,t,e){const o=t.concat(),r=o[0];if(typeof r!="number"||(o.shift(),o.length===1))return!1;const i=o[0];if(typeof i!="object"||!i.i||Object.keys(i).length!==1)return!1;for(let l=1;l<o.length;l++){const c=o[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const d=c[1];if(typeof d!="object"||d.i===void 0||Object.keys(d).length!==1)return!1}const s=i.i;u(_t,s.id,"block id is required"),u(_t,s.type,"block type is required");for(let l=1;l<o.length;l++){const c=o[l],a=c[0],d=c[1];s[a]=d.i}return e.onInsertBlock(n,r,s),!0}function dh(n,t,e,o){if(e==="upsert"&&sw(n,t,o))return;u(_t,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const r=t.concat(),i=r[0];r.shift();const s=[];for(;r.length>0;){const l=r[0];if(l==="text"){const c=r[1];if(u(_t,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),u(_t,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),r.splice(0,2),e==="upsert"){const d=c.e;o.onUpdateBlockText(n,i,d)}u(_t,r.length===0,`invalid block ops.length !== 0, ${JSON.stringify(r)}`)}else if(Array.isArray(l)){u(_t,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];u(_t,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const a=l[1];if(c==="text"){if(u(_t,typeof a=="object",`invalid opData type, ${JSON.stringify(a)}`),a.i&&e==="upsert"&&o.onInsertBlockData(n,i,c,a.i),a.r&&e==="remove"&&o.onDeleteBlockData(n,i,c),a.et==="rich-text"&&e==="upsert"){const f=a.e;o.onUpdateBlockText(n,i,f)}}else e==="remove"&&a.r&&s.push(new uh(c)),e==="upsert"&&a.i&&o.onInsertBlockData(n,i,c,a.i);r.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&s.push(new o5),e==="upsert"&&c.i&&o.onInsertBlock(n,i,c.i),r.shift()}else{u(_t,typeof l=="string","data is not string"),u(_t,l!=="text","data !== 'text'"),u(_t,r.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(r)}`);const c=l,a=r[1];e==="remove"&&a.r&&s.push(new uh(c)),e==="upsert"&&a.i&&o.onInsertBlockData(n,i,c,a.i),r.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof o5?o.onDeleteBlock(n,i):l instanceof uh?o.onDeleteBlockData(n,i,l.key):u(_t,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function lw(n,t,e,o){_t.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function cw(n,t,e,o){const r=n[1],i=n[2];u(_t,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),u(_t,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?_t.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&o.onUpdateComment(r,e.local):i.i?t==="upsert"&&o.onCreateComment(r,e.local):i.r?t==="remove"&&o.onDeleteComment(r,e.local):_t.error(`unknown comment op, ${JSON.stringify(n)}`)}function hh(n,t,e,o){const r=n[0];if(Array.isArray(r)){r.forEach(l=>{hh(l,t,e,o)});return}const i=r;if(u(_t,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){lw(n);return}if(i==="comments"){cw(n,t,e,o);return}const s=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(l=>{dh(s,l,t,e)}):n.slice(1).forEach(l=>{dh(s,l,t,e)});else if(typeof n[1]=="object"){const l=n[1];l.r&&t==="remove"&&o.onDeleteContainer(Wr(s),e.local),l.i&&t==="upsert"&&o.onCreateContainer(Wr(s),l.i,e.local)}else u(_t,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),dh(s,n.slice(1),t,e)}function r5(n,t,e){const o=new iw(t,e);for(let r=0;r<2;r++){const i=r===0?"remove":"upsert",s=Q.default(n),l=s[0];Array.isArray(l)?s.forEach(c=>{hh(c,i,o,t)}):hh(s,i,o,t)}o.executeUpdateBlockDataActions()}const aw=w("sharedb-comments");function fh(n){if(n.doc)return Q.default(n.doc);const t=n.blocks;u(aw,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([o,r])=>{Array.isArray(r)&&(e.blocks[o]=r)}),Q.default(e)}function i5(n){const{id:t,groupId:e,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:c}=n;return{id:t,groupId:e,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:c}}function mh(n,t){const e={...n,doc:t};return delete e.blocks,Q.default(e)}const yt=w("sharedb-doc/doc-container"),s5="ot-json1";Il.type.registerSubtype(Zy.type),Il.type.name=s5,Il.type.invert=null;class Es extends Pi{constructor(e,o,r=!0){super();h(this,"doc");h(this,"client");h(this,"localPresence");h(this,"remoteCaretHandler",new Wy);h(this,"batching",0);h(this,"status","clean");h(this,"disableLogout");h(this,"destroyed",!1);h(this,"handleNothingPending",()=>{this.setStatus("clean")});h(this,"handleCreate",()=>{this.handleReload("doc created")});h(this,"handleDel",()=>{});h(this,"handleReload",e=>{this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,e)})});h(this,"handleReset",async e=>{const o=new Error(`reset doc: ${e}`);o.code="ResetDoc",this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,o)}),this.destroy()});h(this,"handleWriteConflictError",e=>{this.handleReset(`write conflict: ${e.message}, ${JSON.stringify(e.orgMsg)}`)});h(this,"insertObject",async(e,o,r)=>{const i=[e,o,{i:r}];return this.submitOp(i)});h(this,"deleteObject",async(e,o)=>{const r=[e,o,{r:!0}];return this.submitOp(r)});h(this,"replaceObject",async(e,o,r)=>{const i=[e,o,{r:!0,i:r}];return this.submitOp(i)});h(this,"updateObject",async(e,o,r)=>{const i=this.data()[e][o],s=[e,o];return Object.entries(r).forEach(([l,c])=>{if(!El.default(i[l],c))if(i[l]===void 0){if(c!=null){const a={i:c};s.push([l,a])}}else if(c==null){const a={r:!0};s.push([l,a])}else{const a={r:!0,i:c};s.push([l,a])}}),Object.entries(i).forEach(([l,c])=>{if((r[l]===void 0||r[l]===null)&&c!==void 0){const a={r:!0};s.push([l,a])}}),s.length<=2?Promise.resolve():this.submitOp(s)});h(this,"broadcastMessage",async e=>{const o={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(o)});h(this,"data",()=>this.doc.data);h(this,"submitOp",async e=>new Promise((o,r)=>{if(this.destroyed){yt.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(e,{},i=>{i?(yt.error(`invalid op, ${i.message}, ${JSON.stringify(e)}`),r(i),yt.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):o()}),this.doc.data||(yt.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(e)}`))}));h(this,"createDoc",async e=>new Promise((o,r)=>{this.doc.create(e,s5,i=>{i?r(i):o()})}));h(this,"submitInsertChildContainer",async(e,o)=>{const r=[yo(e),{i:o}];return this.submitOp(r)});h(this,"submitDeleteChildContainer",async e=>{const o=[yo(e),{r:!0}];return this.submitOp(o)});h(this,"submitInsertBlock",async(e,o,r)=>{const i=[yo(e),o,{i:r}];return this.submitOp(i)});h(this,"submitDeleteBlock",async(e,o)=>{const r=[yo(e),o,{r:!0}];return this.submitOp(r)});h(this,"submitUpdateBlockData",async(e,o,r)=>{if(r.delete.length===0&&Object.keys(r.insert).length===0)return Promise.resolve();const i=[yo(e),o],s=new Set(r.delete);Object.entries(r.insert).forEach(([c,a])=>{if(s.has(c)){const d={r:!0,i:a};i.push([c,d])}});const l=new Set(Object.keys(r.insert));return r.delete.forEach(c=>{if(l.has(c))return;const a={r:!0};i.push([c,a])}),Object.entries(r.insert).forEach(([c,a])=>{if(s.has(c))return;const d={i:a};i.push([c,d])}),this.submitOp(i)});h(this,"submitUpdateRichText",async(e,o,r)=>{const i=[yo(e),o,"text",{e:r,et:"rich-text"}];return this.submitOp(i)});h(this,"handleOp",(e,o,r)=>{if(this.destroyed){yt.warn("handleOp: destroyed");return}r5(e,this,!!o)});this.client=e,this.doc=o,this.doc.preventCompose=!0,this.disableLogout=r,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,u(yt,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const o=new ew(e.auth,e.serverUrl,e.reauthFunc),r=await o.getDoc(),i=new Es(o,r,e.disableLogout);if(r.type===null){if(e.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await i.createDoc(e.templateData||nw())}return await i.initPresence(),await i.subscribe(),i.initEvents(),i}catch(o){throw yt.error(o),yt.error(`failed to load doc: ${JSON.stringify(o)}`),o}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onWriteConflictError(this.handleWriteConflictError)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",this.handleDel)}initPresence(){return new Promise((e,o)=>{if(this.localPresence)e();else{const r=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);r.on("receive",(i,s)=>{this.onCustomMessage(s)}),r.subscribe(i=>{i?o(i):(this.localPresence=r.create(P()),e())})}})}subscribe(){return new Promise((e,o)=>{this.doc.subscribe(r=>{r?o(r):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return fs(this.data())}getContainerBlocks(e){const o=this.data();u(yt,o,"no doc data");const r=o[yo(e)];return u(yt,r,`no container data: ${e}`),Q.default(r)}getBlockData(e,o){const r=this.data();u(yt,r,"no doc data");const i=r[yo(e)];u(yt,i,`no container data: ${e}`);const s=i[o];return u(yt,s,`no block data: ${o}`),Q.default(s)}localInsertBlock(e,o,r){return this.submitInsertBlock(e,o,r),this.getBlockData(e,o)}localDeleteBlock(e,o){const r=this.getBlockData(e,o);return this.submitDeleteBlock(e,o),r}localUpdateBlockText(e,o,r){const i=this.getBlockData(e,o);u(yt,i.text,"no block text");const s=Q.default(i.text);this.submitUpdateRichText(e,o,r);const l=ce.apply(s,r);return u(yt,l,"no block text"),l}localUpdateBlockData(e,o,r){const i=Q.default(this.getBlockData(e,o));return this.submitUpdateBlockData(e,o,r),i}localInsertChildContainer(e,o){this.submitInsertChildContainer(e,o)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(o=>{this.submitDeleteChildContainer(o)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(o=>i5(o))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const o=this.data().comments[e];return fh(o)}localCreateComment(e,o){const r=mh(e,o),s=["comments",r.id,{i:r}];return this.submitOp(s)}localDeleteComment(e){const o=["comments",e,{r:!0}];return this.submitOp(o)}localUpdateComment(e,o){const r=mh(e,o),i=["comments",e.id,{r:!0,i:r}];return this.submitOp(i)}destroy(){var e;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(e,o,r){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteBlock)==null?void 0:s.call(i,Ur(e),o,r)})}onInsertBlock(e,o,r,i){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,Ur(e),o,r,i)})}onUpdateBlockData(e,o,r,i){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,Ur(e),o,r,i)})}onUpdateBlockText(e,o,r,i){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,Ur(e),o,r,i)})}onDeleteContainer(e,o){u(yt,this.callbacks.length>0,"no callbacks"),u(yt,e!=="root","should not delete root container in doc"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,Ur(e),o)})}onCreateContainer(e,o,r){u(yt,this.callbacks.length>0,"no callbacks"),u(yt,e!=="root","should not create root container in doc"),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,Ur(e),o,r)})}onDeleteComment(e,o){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteComment)==null?void 0:i.call(r,e,o)})}onCreateComment(e,o){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onCreateComment)==null?void 0:i.call(r,e,o)})}onUpdateComment(e,o){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onUpdateComment)==null?void 0:i.call(r,e,o)})}onCustomMessage(e){const o=e;(o==null?void 0:o.type)==="custom"&&(o==null?void 0:o.clientId)!==this.client.clientId?this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,o.data)}):(o==null?void 0:o.type)==="onlineUsers"&&setTimeout(()=>{const r={type:"custom",data:e,clientId:"-"};this.onCustomMessage(r)})}async addResources(e){return await this.client.getFileUrlsByHashes(e)}async uploadResource(e,o){var i;return{resourceId:await this.client.uploadResource(e,(i=o==null?void 0:o.onProgress)!=null?i:()=>{})}}buildResourceUrl(e,o){return this.client.buildResourceUrl(e,o)}request(e,o){return this.client.request(e,o)}getUser(){const e=this.client.clientId,{permission:o,userId:r,displayName:i,avatarUrl:s}=this.client.auth;return{permission:o,clientId:e,userId:r,displayName:i,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const o=await this.client.getVersion(e);return fs(o)}async getLatestVersion(){const e=await this.client.getLatestVersion();return fs(e)}async getHistoryData(e,o){const{doc:r,ops:i}=await this.client.getVersionOps(e,o),s=i.map(l=>({user:l.meta.createdBy,data:l}));return{doc:fs(r),historyData:s}}async getVersionData(e,o){const{doc:r,ops:i}=await this.client.getVersionOps(e,o);return{doc:fs(r),versionData:i}}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,o){return this.client.createVersion(e,o)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,o){r5(e.data.op,o,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}w("remote-cursor");class l5{constructor(t){h(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});h(this,"broadcastCaretPos",ee.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));h(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const o=this.editor.findBlockById(e);o&&this.editor.reloadBlock(o)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const c5=w("remote-cursor-decorator");class gh{decorateText(t,e,o){const r=t.doc.getRemoteUsers();if(!r)return{};const i=new Map,{containerId:s,blockIndex:l}=e[e.length-1];u(c5,typeof s=="string","invalid path containerId"),u(c5,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(s,l),a=me(o);return r.getSimpleCursors(c.id).forEach((f,m)=>{m>a&&(m=a);const p=f.map(k=>({id:P(),type:"remote-cursor",name:k.user.displayName,time:k.time,rainbowIndex:k.user.rainbowIndex})),A=i.get(m);A?A.push(...p):i.set(m,p)}),{insertions:i}}}class a5 extends Yt.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,o){if(Ct(Pr(this.editor,t)))return;const r=this.editor.getBlockByIndex(t,e),i=U(this.editor.getContainerById(t));i&&this.emit("change",this.editor,i,r,o)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}destroy(){this.editor.doc.unregisterCallback(this)}}function uw(n,t){n.addCustom("child-block-tracker",()=>new a5(n)).addListener("change",t)}function dw(n,t){n.addCustom("child-block-tracker",()=>new a5(n)).removeListener("change",t)}const JU="",hw={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4",name:"\u6587\u672C\u989C\u8272"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},fw={colorPalette:{colorDesc:"Text Color",name:"Text Color",backgroundDesc:"Background Color",reset:"Reset"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}};x.mergeLang({"zh-CN":hw,"en-US":fw});const KU="";w("button");function Bo(n,t,e,o,r){const i=b("button",["editor-button"],null);return i.setAttribute("data-button-id",n),r&&i.setAttribute(`data-editor-tooltip-${r}`,t),e?typeof e=="string"?e.startsWith("<")?i.innerHTML=e:i.innerText=e:i.appendChild(e):i.innerText=t,o&&(o.indexOf("checked")!==-1&&M(i,"checked"),o.indexOf("disabled")!==-1&&(i.disabled=!0)),i}function u5(n,t,e){e?n.setAttribute(`data-editor-tooltip-${e}`,t):n.innerText=t}const XU="",Gr=w("ui-command-bar-base"),mw={itemElementTag:"div",tippyArrow:!1},qf=class extends Yt.TypedEmitter{constructor(e,o,r){var i,s;super();h(this,"content");h(this,"items");h(this,"subBar",null);h(this,"parentItem",null);h(this,"closeable",null);h(this,"options");h(this,"id");h(this,"handleDocumentKeydown",e=>{if(!!this.isVisible&&!e.isComposing){if(this.subBar){this.subBar.handleDocumentKeydown(e);return}if(this.items.length!==0){if(e.key==="Escape"){this.close();return}if(e.key==="ArrowUp"){const o=this.getPrevItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[o].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowDown"){const o=this.getNextItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[o].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowRight"){const o=this.getSelectedItem();o&&o.children&&this.showSubCommandBar(o.childrenMenuId)}else if(e.key==="ArrowLeft")this.parentItem&&this.close();else if(e.key==="Enter"){const o=this.getSelectedItemIndex();if(o===-1)return;const r=this.items[o],i=this.getItemElementById(r.id);i&&this.emit("click",this,r,i)}}}});h(this,"handleDocumentMouseDown",e=>{if(e.target instanceof Element&&!this.isInCommandBar(e.target)){const o=this.listeners("closing");for(let r=0;r<o.length;r++)if(o[r](this,e)===!1)return;this.close()}});h(this,"handleHidden",()=>{this.close(),this.emit("close",this),Wm(this.id)});h(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&M(this.popper,...this.options.classes),this.options.refuseOverflow&&this.popper.classList.add("reference-hidden")),this.emit("show",this),this.options.disablePageScroll&&qm(this.id)});h(this,"lastEnterPauseTime",0);h(this,"startPauseMouseEnter",()=>{this.lastEnterPauseTime=Date.now()});h(this,"handleItemMouseEnter",e=>{if(Date.now()-this.lastEnterPauseTime<100)return;const o=this.getParentCommandItemElement(e.target);if(!o)return;const r=this.getItemElementId(o),i=this.getItemById(r);if(this.selectItem(r),i.manualShowChildren)return;const s=i.childrenMenuId||"";this.showSubCommandBar(s)});h(this,"handleItemMouseLeave",e=>{var r,i;const o=this.getParentCommandItemElement(e.target);!o||((i=(r=this.subBar)==null?void 0:r.parentItem)==null?void 0:i.id)!==this.getItemElementId(o)&&(H(o,"selected"),this.emit("selectionChange",this,""))});h(this,"handleItemClick",e=>{const o=this.getParentCommandItemElement(e.target);if(!o)return;const r=this.getItemElementId(o),i=this.items.find(s=>s.id===r);if(!!i&&!(i.states&&i.states.indexOf("disabled")!==-1)){if(i.children&&i.children.length>0&&i.manualShowChildren){this.showSubCommandBar(i.childrenMenuId);return}i.element||(this.emit("click",this,i,o),this.options.autoClose&&this.close())}});h(this,"handleWheel",e=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const o=e.target;if(!o||!(o instanceof Node))return;const r=o instanceof HTMLElement?o:o.parentElement;if(!r)return;const i=bn(r);if(!wt(this.content,i)){e.stopPropagation(),e.preventDefault();return}e.deltaY<0?i.scrollTop===0&&(e.stopPropagation(),e.preventDefault()):e.deltaY>0&&i.scrollTop+i.clientHeight>=i.scrollHeight&&(e.stopPropagation(),e.preventDefault())});this.id=(i=r==null?void 0:r.id)!=null?i:P(),this.options={...mw,...r},this.items=e,this.parentItem=(s=r==null?void 0:r.parentItem)!=null?s:null,this.closeable=o!=null?o:null,this.content=this.createCommandBarContent(e)}close(){this.subBar&&this.subBar.close(),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(e,o){this.emit("click",this,e,o)}createPopperOptions(){var r;const e={modifiers:[]},o=this.options.overflowBoundary;return o&&((r=e==null?void 0:e.modifiers)==null||r.push({name:"flip",options:{boundary:o,fallbackPlacements:["top","bottom"]}})),e}destroy(){var e;this.close(),this.removeAllListeners(),(e=this.subBar)==null||e.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(e){var r;this.subBar&&e.findIndex(s=>{var l,c;return s.id===((c=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:c.id)})===-1&&((r=this.subBar)==null||r.destroy(),this.subBar=null),this.items=e;const o=this.createCommandBarContent(e);this.content.innerHTML="",Array.from(o.children).forEach(i=>{this.content.appendChild(i)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const e=this.getSelectedItem();return e?this.items.indexOf(e):-1}getPrevItemIndex(e){if(e<=0)return this.items.length-1;let o=e-1;for(;;){const r=this.items[o].type;if(r!=="separator"&&r!=="section")return o;if(o-=1,o<=0)return this.items.length-1}}getNextItemIndex(e){let o=e+1;for(;;){if(!this.items[o])return this.getNextItemIndex(-1);const r=this.items[o].type;if(r!=="separator"&&r!=="section")return o;if(o+=1,o>this.items.length-1)return 0}}clearSelectedItem(){const e=this.getSelectedItem();if(!e)return;const o=this.getItemElementById(e.id);o&&H(o,"selected")}selectItem(e){const o=this.getSelectedItem();if(o){if(o.id===e)return;const i=o.id,s=this.getItemElementById(i);s&&H(s,"selected")}const r=this.getItemElementById(e);r?(M(r,"selected"),this.emit("selectionChange",this,r.getAttribute("data-id")||""),r.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(e){var s,l;const o=this.getSelectedItem();if(!o)return;if(this.subBar){if(((s=this.subBar.parentItem)==null?void 0:s.id)===o.id){o.manualShowChildren&&this.subBar.close();return}this.subBar.destroy(),this.subBar=null}if(!o.children)return;const r=this.getItemElementById(o.id);if(!r)return;const i=qf.createSubCommandBar(o,(l=this.closeable)!=null?l:this,e?{id:e}:{});this.subBar=i,this.subBar.on("click",(c,a,d)=>{this.emit("click",c,a,d)}),this.subBar.on("close",()=>{var c;(c=this.subBar)==null||c.destroy(),this.subBar=null,H(r,"active")}),o.beforePopup&&o.beforePopup(i),this.subBar.manualShow(r,this.getSubBarOptions(o)),M(r,"active")}isInCommandBar(e){if(!e||!(e instanceof Node))return!1;const o=this.getCommandBarRoot();return o&&wt(o,e)||wt(this.content,e)?!0:this.subBar?this.subBar.isInCommandBar(e):!1}createCommandItem(e){var i,s,l,c;let o=(i=this.options.itemElementTag)!=null?i:"div";e.element&&(o="div");const r=b(o,["command-item"],null);return r.setAttribute("data-id",e.id),e.type==="separator"?r.classList.add("separator"):e.type==="section"?(r.classList.add("section","text"),e.element&&(typeof e.element=="function"?r.appendChild(e.element(e)):r.appendChild(e.element))):((s=e.states)!=null&&s.includes("selected")&&r.classList.add("selected"),(l=e.states)!=null&&l.includes("checked")&&r.classList.add("checked"),(c=e.states)!=null&&c.includes("disabled")&&r.classList.add("disabled"),r.onclick=this.handleItemClick,r.onmouseenter=this.handleItemMouseEnter,r.onmouseleave=this.handleItemMouseLeave,e.element?typeof e.element=="function"?r.appendChild(e.element(e)):r.appendChild(e.element):r.classList.add("standard")),this.initItemElement(e,r),r}getItemById(e){const o=this.items.find(r=>r.id===e);return u(Gr,o,`can not find command item for id: ${e}`),o}getSelectedItem(){const e=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(e){const o=this.getItemElementId(e),r=this.items.find(i=>i.id===o);return u(Gr,r,`can not find command item for id: ${o}`),r}return null}getItemElementId(e){const o=e.getAttribute("data-id");return u(Gr,o,"no data-id attribute"),o}getItemElementById(e){const o=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${e}"]`);return u(Gr,o,`no exists command item, id=${e}`),o}getParentCommandItemElement(e){if(!e||!(e instanceof Element))return null;if(rt(e,"command-item"))return e;const o=e.closest(".command-item");return o||null}createCommandBarContent(e){this.content&&this.content.removeEventListener("wheel",this.handleWheel);const o=b("div",["editor-command-bar-root"],null),r=b("div",["editor-command-bar"],o);return e.forEach(i=>{var l;const s=this.createCommandItem(i);r.appendChild(s),i.element&&i.setCloseable&&i.setCloseable((l=this.closeable)!=null?l:this)}),this.initCommandBarElement(r),o.addEventListener("wheel",this.handleWheel,{passive:!1}),o}getSubBarOptions(e){var o;return{placement:(o=e.childrenPlacement)!=null?o:"right-start"}}static registerManualCommandBar(e,o){this.commandBarCreators.set(e,o)}static createSubCommandBar(e,o,r){var l;u(Gr,e.children&&e.children.length>0,"no item children");const i=(l=e.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(i);return u(Gr,s,`no creator for command type: ${i}`),s(e,o,r)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let Zr=qf;h(Zr,"commandBarCreators",new Map),w("ui-command-bar");class Dc extends Zr{constructor(){super(...arguments);h(this,"tippyInstance",null)}manualShow(e,o){var r,i;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=r8.default(e,{interactive:!0,content:this.content,trigger:"manual",triggerTarget:null,hideOnClick:!1,placement:(r=o==null?void 0:o.placement)!=null?r:"bottom-start",maxWidth:650,arrow:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,theme:o==null?void 0:o.theme,getReferenceClientRect:o==null?void 0:o.getReferenceClientRect,offset:(i=o==null?void 0:o.offset)!=null?i:[0,0],popperOptions:this.createPopperOptions()}),o!=null&&o.point){const{x:s,y:l}=o.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(s,l,0,0)})}this.clearSelectedItem(),this.tippyInstance.show(),this.parentItem||(document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)),this.popper&&this.options.id&&this.popper.setAttribute("data-command-bar-id",this.options.id)}}close(){var e;super.close(),this.isVisible&&((e=this.tippyInstance)==null||e.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,o;return(o=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?o:!1}get popper(){return this.content.closest("[data-tippy-root]")}}const d5=w("ui-base");class Is extends Dc{constructor(t,e){var i;const r=[{id:(i=e==null?void 0:e.id)!=null?i:`popup-${P()}`,name:"",element:t}];super(r,void 0,{disablePageScroll:!0})}initCommandBarElement(t){M(t,"popper")}initItemElement(t,e){}get popupContent(){const t=this.items[0];u(d5,t,"no dialog item");const e=typeof t.element=="function"?t.element(t):t.element;return u(d5,e,"no item element"),e}}const Eo=w("filterable-list");function gw(n){var e;const t=b("div",["list-item"],null);return t.setAttribute("data-id",n.id),t.appendChild(b("div",["list-item-text"],null,n.name)),(e=n.states)!=null&&e.includes("selected")&&M(t,"selected"),t}function h5(n){const t=b("div",["list-root"],null);return n.forEach(e=>{t.appendChild(gw(e))}),t}function f5(n,t){let e=n;return t&&(e=n.map(o=>({...o,states:o.id===t?["selected"]:void 0}))),e}function pw(n,t){const e=b("div",["filterable-list"],null),o=b("div",["filter"],e),r=b("div",["filter-container"],o),i=b("input",["filter-input"],r);t&&t.placeholder&&(i.placeholder=t.placeholder);const s=b("div",["list"],e),l=h5(f5(n,t==null?void 0:t.initialSelectedId));return s.appendChild(l),e}function m5(n,t,e){const o=n.querySelector(".list");u(Eo,o,"no list root");const r=h5(f5(t,e)),i=o.querySelector(".list-root");if(u(Eo,i,"no exists menu"),Hi(i,r),e){const s=o.querySelector(".list-item.selected");s&&(u(Eo,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class Cw{constructor(t,e){h(this,"root");h(this,"visibleItems");h(this,"selectedId");h(this,"filter","");h(this,"onSelected",null);h(this,"handleKeydown",t=>{this.processKeyDown(t)});h(this,"handleInputChanged",()=>{const t=this.root.querySelector(".filter-input");u(Eo,t,"no input");const e=t.value.toLocaleLowerCase();this.setFilter(e)});h(this,"handleClick",t=>{this.processClick(t)});var o;this.items=t,this.options=e,this.root=pw(t,e),this.bindEvents(),this.selectedId=(o=e==null?void 0:e.initialSelectedId)!=null?o:"",this.visibleItems=t}bindEvents(){const t=this.root.querySelector(".filter-input");u(Eo,t,"no input"),t.addEventListener("keyup",this.handleInputChanged),t.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const t=this.root.querySelector(".filter-input");u(Eo,t,"no input"),t.removeEventListener("keyup",this.handleInputChanged),t.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(t=>t.id===this.selectedId):-1}setSelectedId(t){this.selectedId=t,m5(this.root,this.visibleItems,t)}focus(){const t=this.root.querySelector(".filter-input");u(Eo,t,"no input"),t.focus()}reset(){this.setFilter("");const t=this.root.querySelector(".filter-input");u(Eo,t,"no input"),t.value=""}setFilter(t){this.filter!==t&&(this.filter=t,this.visibleItems=this.items.filter(e=>e.name.toLocaleLowerCase().includes(t)),m5(this.root,this.visibleItems,this.selectedId))}processClick(t){var s,l;const e=t.target;if(!(e instanceof HTMLElement))return;const o=e.closest(".list-item");if(!o)return;const r=(s=o.getAttribute("data-id"))!=null?s:"",i=(l=this.visibleItems.find(c=>c.id===r))!=null?l:null;this.onSelected&&this.onSelected(this,i)}processKeyDown(t){var e;if(t.key==="ArrowUp"){let o=this.getSelectedIndex();o===-1?o=this.visibleItems.length-1:o>0&&(o-=1);let r="";o!==-1&&(r=this.visibleItems[o].id),this.setSelectedId(r);return}if(t.key==="ArrowDown"){let o=this.getSelectedIndex();o===-1?o=0:o<this.visibleItems.length-1&&(o+=1);let r="";o!==-1&&(r=this.visibleItems[o].id),this.setSelectedId(r);return}if(t.key==="Enter"){const o=(e=this.visibleItems.find(r=>r.id===this.selectedId))!=null?e:null;this.onSelected&&this.onSelected(this,o)}}}class Aw extends Cw{constructor(e,o,r){super(e,r);h(this,"popup");h(this,"onShow",null);h(this,"onHide",null);h(this,"custom",null);h(this,"handleShow",()=>{this.onShow&&this.onShow(this)});h(this,"handleHide",()=>{this.onHide&&this.onHide(this)});h(this,"handleShown",()=>{this.focus()});this.popup=new Is(this.root)}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(e){this.reset(),this.popup.manualShow(e,{theme:"dropdown-list"}),this.focus()}processKeyDown(e){super.processKeyDown(e),(e.key==="Esc"||e.key==="Enter")&&this.popup.close()}processClick(e){super.processClick(e);const o=e.target;!(o instanceof HTMLElement)||!o.closest(".list-item")||this.popup.close()}}const tV="",eV="";function bw(n,t){const e=document.createElement("div");e.classList.add("toast","show"),t!=null&&t.theme&&e.setAttribute("data-theme",t.theme),t!=null&&t.id&&e.setAttribute("data-id",t.id),t!=null&&t.html?e.innerHTML=n:e.textContent=n,t!=null&&t.position&&(e.style.left=`${t.position.x}px`,e.style.top=`${t.position.y}px`,e.classList.add("positioned")),document.body.appendChild(e),setTimeout(()=>{e.classList.remove("show"),setTimeout(()=>{e.remove()},500)},(t==null?void 0:t.duration)||3e3)}const g5=`<?xml version="1.0" ?>
|
|
27
|
+
`)}const av=w("get-text-position");function _r(n,t){const e=t!=null?t:n.selection.range.start;e instanceof qt||u(av,!1,`invalid insert pos type: ${typeof e}`);const{blockId:o}=e,r=n.getBlockById(o),i=K(r),s=z(r),l=V(s),{offset:c}=e;return{block:r,container:s,containerId:l,blockIndex:i,offset:c}}const es=w("insert-text");function qp(n,t,e,o){var s;const r=n.doc.getBlockData(t,e);if(u(es,r,"no block data"),u(es,r.text,"no block text"),me(r.text)===0)return u(es,o===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,r.id);if(o===0)return;const i=Gt(r.text,o-1,1).middle;if(!((s=i[0].attributes)!=null&&s.box))return i[0].attributes}function uv(n,t,e){const o=z(t),r=V(o),i=K(t);return qp(n,r,i,e)}function Wp(n,t,e,o,r){const i=z(t),s=V(i),l=K(t),c=uv(n,t,e),a=Yl(e,o,c!=null?c:null);return n.doc.localUpdateBlockText(s,l,a,r),ge(n,t)}function Gp(n,t,e,o){const r=z(t),i=V(r),s=K(t),l=Yl(e," ",o);return n.doc.localUpdateBlockText(i,s,l),ge(n,t)}function wd(n,t,e,o,r){const i=n.doc.getBlockData(e,o);u(es,i,"no block data"),u(es,i.text,"no block text");const s=qp(n,e,o,r),l=Yl(r,t,s!=null?s:null);return n.doc.localUpdateBlockText(e,o,l),ge(n,n.getBlockById(i.id))}function Bd(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:e,blockIndex:o,offset:r}=_r(n);wd(n,t,e,o,r)}const ac=w("update-composition-text");function Zp(n){const t=n.selection.range.start;t instanceof qt||u(ac,!1,`invalid insert pos type: ${typeof t}`);const{blockId:e}=t,o=n.getBlockById(e);u(ac,_(n,o),"not a text kind block");const r=z(o),i=V(r),s=K(o),l=n.doc.getBlockData(i,s);u(ac,l,"no block data in doc"),u(ac,l.text,"no text data in text block");const c=st(o);Wl(n,ao(o),e,c,l.text)}function Qp(n){FA(n)}function Fr(n,t,e,o,r,i){return n.doc.localInsertBlock(t,e,o,r,i),n.getBlockById(o.id)}const ns=w("delete-block-text");function Ed(n,t,e,o,r){if(!n.isBlockWritable(t))return ns.error("block is not writable"),0;u(ns,_(n,t),"block is not a text kind block");const i=z(t),s=V(i),l=K(t),c=n.doc.getBlockData(s,l);u(ns,c,"no block data in doc"),u(ns,c.text,"no text data in text block");let a=e;le(t,e)||(a=go(t,a));let d=e+o;u(ns,d<=G(n,t),`invalid offset and count: ${e}, ${o}`),le(t,d)||(d=tr(t,d));const f=d-a,m=Xg(a,f);return n.doc.localUpdateBlockText(s,l,m,r),f}const Id=w("break-text-block");function Yp(n,t){const o=n.getBlockData(t).quoted;return o?{quoted:o}:{}}function Hr(n,t,e,o){u(Id,_(n,t),`block is not a text kind block: ${it(t)}`),u(Id,e>=0&&e<=G(n,t),`invalid offset: ${e}`);const r=z(t),i=V(r),s=K(t),l=o!=null&&o.copyBlockAttributes?Yp(n,t):{};if(!(o!=null&&o.forceInsertAfter)&&(e===0||e===G(n,t))){const p=e===0?s:s+1,A={...Vn(""),...l,...o==null?void 0:o.newBlockData},k=Ot(n,t.id,0),v=Fr(n,i,p,A,k);return{block:t,newBlock:v}}u(Id,le(t,e),"not a valid offset");const c=ge(n,t),{right:a}=ve(c,e),d=me(a);d>0&&Ed(n,t,e,d);const f={...Vn(a),...l,...o==null?void 0:o.newBlockData},m=Fr(n,i,s+1,f,Ot(n,f.id,0));return{block:t,newBlock:m}}const dv=w("prepare-insert-new-block");function hv(n,t,e){if(t&&e!==void 0&&e!==null){const a=n.getContainerById(t),d=Mt(a);return u(dv,e>=0&&e<=d.length,`invalid blockIndex: ${e}`),{containerId:t,blockIndex:e}}const o=n.selection.range.start;if(!o.isSimple())return null;const r=n.getBlockById(o.blockId);if(t=V(z(r)),e=K(r),!_(n,r))return{containerId:t,blockIndex:e+1};const s=o.offset;if(s===0||s===G(n,r))return{containerId:t,blockIndex:s===0?e:e+1};const c=Hr(n,r,s).newBlock;return{containerId:t,blockIndex:K(c)}}const fv=w("auto-insert-block");function Jp(n,t,e,o,r,i){const s=hv(n,e,o);u(fv,s,`not an valid insert position: ${n.selection.range}`);const l={blockId:t.id,offset:0},c={anchor:l,focus:l};return Fr(n,s.containerId,s.blockIndex,t,r!=null?r:c,i)}const mv=w("delete-block");function uc(n,t,e){t.children&&(e.push(...t.children),t.children.forEach(o=>{n.getChildContainerData(o).forEach(i=>{uc(n,i,e)})}))}function xd(n,t,e){const o=z(t),r=V(o),i=K(t),s=n.doc.getBlockData(r,i);return u(mv,s,"no block data in doc"),n.doc.localDeleteBlock(r,i,Wt(n,{anchor:e.start,focus:e.end})),s}function Td(n,t,e){return n.undoManager.runInGroup(()=>{const o=z(t);Ze(o)===1&&n.insertTextBlock("",V(o),0);let r=e?ho(n,e):null;if(!r){const l=n.selection.range;jp(t,l)?r=zp(n,t):r=l}const i=xd(n,t,r),s=[];return uc(n,i,s),s.length>0&&n.doc.localDeleteChildContainers(s),i})}function gv(n,t){const e=[t];n.doc.getContainerBlocks(t).forEach(r=>{uc(n,r,e)}),n.doc.localDeleteChildContainers(e)}function Kp(n,t){const e=[...t];t.forEach(o=>{n.doc.getContainerBlocks(o).forEach(i=>{uc(n,i,e)})}),n.doc.localDeleteChildContainers(e)}const Sd=w("merge-text-block");function Xp(n,t,e){u(Sd,_(n,t),"only text block can be merged"),u(Sd,_(n,e),"only text block can be merged");const o=Ao(n,t),r=Ao(n,e),i=o.text,s=r.text;u(Sd,i&&s,"block data has no text");const l=z(t),c=V(l),a=K(t),d=G(n,t),f=wd(n,s,c,a,d),m=Ot(n,t,me(i));return Td(n,e,m),f}const En=w("clear-selected-contents");function dc(n,t){u(En,_(n,t.block),"not a text kind block");const{start:e,end:o}=t;u(En,e.isSimple(),"not a simple block position"),u(En,o.isSimple(),"not a simple block position");const r=e.offset,i=o.offset;u(En,r<=i,`invalid delete text offset: ${r}, ${i}`),r!==i&&n.deleteTextFromBlock(t.block,r,i-r)}function t0(n,t,e){const o=V(t),r=Mt(t),i=e.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",o,0,{newRange:i});e.focus&&n.selection.selectBlock(s,0),r.reverse().forEach(l=>{n.deleteBlock(l)})}function pv(n,t){const{block:e,start:o,end:r}=t;if(_(n,e)){dc(n,t);return}if(Te(e)||o.isSimple()){u(En,r.isSimple(),"invalid range");const s=z(e),l=K(e),c=n.insertTextBlock("",V(s),l);n.selection.selectBlock(c,0),n.deleteBlock(e);return}u(En,at(n,e),"invalid block kind"),u(En,!o.isSimple()&&!r.isSimple(),"invalid range"),Rr(n,e,o,r),n.selection.range.getSelectedContainers().forEach((s,l)=>{t0(n,s,{focus:l===0})})}function Cv(n){if(!n.isWritable())return;const t=n.selection.range;if(t.isCollapsed())return;const e=t.getSelectedBlocks();if(u(En,e.length>0,"no selected block"),e.length===1){pv(n,e[0]);return}const o=e[0],r=o.block,i=z(r);u(En,e.length>1,"no selected block");const s=e[e.length-1],l=s.block;if(_(n,r)){dc(n,o);const d=Ot(n,o.block,o.start.offset);if(e.slice(1,e.length-1).reverse().forEach(m=>n.deleteBlock(m.block)),_(n,l)){dc(n,s),n.mergeTextBlock(r,l,{focus:!0}),n.selection.setRange(d);return}n.deleteBlock(l),n.selection.setRange(d);return}if(_(n,l)){dc(n,s),e.slice(0,e.length-1).reverse().forEach(d=>n.deleteBlock(d.block)),n.selection.selectBlock(s.block,0);return}if(e.length===Ze(i)){t0(n,i,{focus:!0});return}const c=bt(r),a=dt(l);u(En,c||a,"no prev or next block"),e.forEach(d=>n.deleteBlock(d.block))}function Dd(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n);try{n.doc.beginBatchUpdate(),Cv(n)}finally{n.doc.endBatchUpdate()}n.emit("afterClearSelection",n)})}const Av=w("core");function e0(n,t,e){const o=z(t),r=V(o),i=K(t);return n.doc.localUpdateBlockText(r,i,e),setTimeout(()=>{n.selection.updateSelection(null)}),ge(n,t)}function n0(n,t,e){if(!n.isBlockWritable(t)){Av.error("block is not writable");return}const o=n.getBlockText(t),r=ce.diff(o,e);e0(n,t,r)}function hc(n,t,e){const o=ge(n,t),r=typeof e=="string"?Co(e):e,i=ce.diff(o,r);return e0(n,t,i)}const os=w("update-block-data");function fc(n,t,e,o){const r=z(t),i=V(r),s=K(t),l=n.doc.getBlockData(i,s),c={insert:{},delete:[]},a=new Set(Object.keys(l)),d=new Set(Object.keys(e));return a.forEach(m=>{if(!d.has(m)){if(m==="id"||m==="type"||m==="text")return;os.debug(`delete key: ${m}`),c.delete.push(m)}}),Object.entries(e).forEach(([m,p])=>{u(os,m!=="id"&&m!=="type",`invalid block data delta, ${m}`);const A=l[m];if(p==null){A!=null&&(os.debug(`delete key: ${m}`),c.delete.push(m));return}A!==p&&(El.default(A,p)||m==="text"&&ce.diff(A,p).length===0||(a.has(m)?(os.debug(`replace key: ${m}`),c.delete.push(m)):os.debug(`insert key: ${m}`),c.insert[m]=p))}),n.doc.localUpdateBlockData(i,s,c,o),Ao(n,t)}function o0(n,t,e,o){const i={...n.getBlockData(t),embedData:e};return n.updateBlockData(t,i,o)}function Ld(n,t,e){if(!at(n,t)||!(e!=null&&e.tryFocusToChildSimpleBlock)){n.selection.selectBlock(t,0);return}const r=xe(n,t).getChildContainers(n,t)[0],i=Ft(r);Ld(n,i,e)}function rr(n){const t=[];let e={};return n.forEach(o=>{t.push(...o.blocks.root);const{root:r,...i}=o.blocks;e={...e,...i}}),{blocks:{...e,root:t},meta:{},comments:{}}}const rs=w("clone-block");function bo(n,t,e,o){const r=n.getBlockClass(e.type);if(r.blockToDoc)return r.blockToDoc(t,e,(d,f)=>(u(rs,e!==f,"invalid child block"),bo(n,d,e,o)));let i={};const s=new Map,l=Q.default(e);l.children&&(l.children=l.children.map(d=>{const f=P(),m=t.blocks[d];u(rs,Array.isArray(m),"invalid child blocks");const p=m.map(x=>bo(n,t,x,o)),A=rr(p),{root:k,...v}=A.blocks;return i={...i,...v},i[f]=A.blocks.root,s.set(d,f),f}));const c=Array.from(s.entries()),a=d=>{for(const f of c){const[m,p]=f;{const A=`${m}/`;if(d.startsWith(A)){const k=d.substring(A.length),v=`${p}/${k}`;return rs.debug(`replace key: ${d} -> ${v}`),v}}{const A=`${m}_`;if(d.startsWith(A)){const k=d.substring(A.length),v=`${p}_${k}`;return rs.debug(`replace key: ${d} -> ${v}`),v}}}return d};return Array.from(Object.entries(l)).forEach(([d,f])=>{const m=a(d);m!==d&&delete l.key,l[m]=f}),l.id=P(),o&&(o.blockIdMap.set(e.id,l.id),s.forEach((d,f)=>o.containerIdMap.set(f,d))),{blocks:{root:[l],...i},meta:{},comments:{}}}function Md(n,t,e,o){const r=t.blocks[e];u(rs,Array.isArray(r),"invalid child blocks");const i=r.map(l=>bo(n,t,l,o));return rr(i)}function Rd(n,t,e){const o=t.blocks.root.map(r=>bo(n.editorBlocks,t,r,e));return Q.default(rr(o))}const r0=w("insert-doc");function i0(n,t,e,o,r){if(at(n,t)){r0.warn("failed to insert doc into a complex block");return}const i=Rd(n,o,r),s=z(t),l=K(t),c=V(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var E,L,R;Object.entries(i.blocks).forEach(([$,q])=>{$!=="root"&&n.doc.localInsertChildContainer($,q)});const a=i.blocks.root;if(Te(t)){n.deleteBlock(t);let $;a.reverse().forEach(q=>{const ot=n.insertBlock(c,l,q);$||($=ot)}),$&&n.selection.selectBlock($,G(n,$));return}if(u(r0,_(n,t),"not a text block"),Tt(n,t)){const $=K(t);let q;a.forEach((ot,lt)=>{const gt=n.insertBlock(c,$+lt,ot);lt===a.length-1&&(q=gt)}),q&&n.selection.selectBlock(q,G(n,q));return}if(a.length===1){const $=a[0];if(Ui(n,$.type)){n.insertTextToBlock(t,e,(E=$.text)!=null?E:[]);return}n.breakTextBlock(t,e),n.insertBlock(c,l+1,$);return}const d=e===G(n,t),f=e===0,m=a[0],p=a[a.length-1];let A;!d&&!f?A=n.breakTextBlock(t,e,{forceInsertAfter:!0}):A=t;const k=f?l:l+1;d?(A=n.insertBlock(c,l+1,p),n.selection.selectBlock(A,G(n,A))):(n.selection.selectBlock(A,0),Ui(n,p.type)?n.insertTextToBlock(A,0,(L=p.text)!=null?L:[]):n.insertBlock(c,k,p));const v=n.selection.range;let x=k;Ui(n,m.type)?f?(n.insertBlock(c,k,m),x+=1):n.insertTextToBlock(t,e,(R=m.text)!=null?R:[]):(n.insertBlock(c,k,m),x+=1),a.slice(1,a.length-1).reverse().forEach($=>{n.insertBlock(c,x,$)}),n.selection.setRange(v)}),n.doc.endBatchUpdate()}function Od(n,t,e,o,r){const i=Rd(n,o,r),s=V(t),l=[];return n.undoManager.runInGroup(()=>{Object.entries(i.blocks).forEach(([a,d])=>{a!=="root"&&n.doc.localInsertChildContainer(a,d)}),i.blocks.root.reverse().forEach(a=>{const d=n.insertBlock(s,e,a);l.push(d)})}),l}function s0(n,t,e){const o=Ze(t);Od(n,t,o,e);for(let r=0;r<o;r++){const i=Ft(t);n.deleteBlock(i)}}const is=w("add-text-attribute");function bv(n,t,e,o){const{start:r,end:i}=e;u(is,r.blockId===i.blockId&&r.blockId===j(t),"invalid range"),u(is,o,"invalid attribute name");const s=n.getBlockText(t),l=Nr(r.offset,i.offset-r.offset,s,o,void 0,{ignoreValue:!0});return n.setBlockText(t,l),l}function l0(n,t,e,o,r){const{start:i,end:s}=e;u(is,i.blockId===s.blockId&&i.blockId===j(t),"invalid range"),u(is,o,"invalid attribute name");const l=n.getBlockText(t),c=Yi(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(t,c),c}function jr(n,t,e,o,r){const{start:i,end:s}=e;u(is,i.blockId===s.blockId&&i.blockId===j(t),"invalid range");const l=n.getBlockText(t),c=cp(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(t,c),c}function c0(n,t,e,o){const r=en(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:s,start:l,end:c}=i;if(!_(n,s))return;if(Tt(n,s)){o(n,j(s),t,e);return}const a=Wt(n,{anchor:l,focus:c});t==="color"||t==="backgroundColor"?jr(n,s,a,t,e):(jr(n,s,a,"color",null),jr(n,s,a,"backgroundColor",null))})})}function a0(n,t,e){const o=en(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{o.forEach(r=>{const{block:i,start:s,end:l}=r;if(!_(n,i))return;if(Tt(n,i)){(t==="clearColor"||t==="clearAll")&&e(n,j(i),"color",null),(t==="clearBackground"||t==="clearAll")&&e(n,j(i),"backgroundColor",null);return}const c=Wt(n,{anchor:s,focus:l});(t==="clearColor"||t==="clearAll")&&jr(n,i,c,"color",null),(t==="clearBackground"||t==="clearAll")&&jr(n,i,c,"backgroundColor",null)})})}function Nd(n,t){const e=en(n,{simpleBlockOnly:!0}).filter(s=>_(n,s.block));if(e.length===0)return[null,null];const o=s=>{if(G(n,s.block)===0)return t(n,j(s.block));const l=s.start,c=s.end,a=n.getBlockText(s.block);return dp(l.offset,c.offset-l.offset,a)};let[r,i]=o(e[0]);return r===null&&i===null?[r,i]:(e.forEach(s=>{const[l,c]=o(s);l===null||r===null?r=null:r=l===r?r:null,c===null||i===null?i=null:i=c===i?i:null}),[r,i])}const Le=w("adjust-selection-pos");function u0(n){const t=[];for(;n;){const e=z(n);if(t.unshift(e),Ct(e))return t;const o=U(e);u(Le,o,"child container has not parent container"),n=o}u(Le,!1,"should not come here: getParentContainers")}function d0(n,t){for(;t;){const e=z(t);if(e===n)return t;const o=U(e);u(Le,o,"could not find parent block for a child container"),t=o}u(Le,!1,"no parent block in specified container")}function vv(n,t){const e=u0(n),o=u0(t);u(Le,e.length>0&&o.length>0,"block has not parent container"),u(Le,e[0]===o[0],"root container does not equal");let r=e[0];for(let l=1;l<e.length||o.length;l++)if(e[l]!==o[l]){r=e[l-1];break}const i=d0(r,n),s=d0(r,t);return{parentContainer:r,newBlock1:i,newBlock2:s}}function h0(n,t){let e=U(t);for(u(Le,e,"element is not in a block");e;){const o=z(e);u(Le,Ke(o),"not a child container");const r=U(o);if(u(Le,r,"child container has not parent block"),r===n)return o;e=r}u(Le,!1,"failed to find parent container in complex block")}function mc(n,t,e){const o=n.getBlockById(t.blockId),r=n.getBlockById(e.blockId);if(o===r)return t instanceof qt&&e instanceof qt?{anchor:t,focus:e}:t instanceof Xe&&e instanceof Xe?Ul(n,o,t,e):null;const i=z(o),s=z(r);if(i===s)return t instanceof Xe&&(t=F(o,0,"home")),e instanceof Xe&&(e=F(r,G(n,r),"end")),u(Le,t instanceof qt,"not valid position type"),u(Le,e instanceof qt,"not valid position type"),{anchor:t,focus:e};if(o.contains(s))return null;if(r.contains(i)){if(t instanceof qt&&e instanceof Xe){const A=n.getContainerById(e.childContainerId);if(A===i)return{anchor:e,focus:e};const k=U(i);if(k&&k===U(A)){const v=Bt(k,V(i)),x=Bt(k,V(A));return Ul(n,k,v,x)}}return null}const l=Dl(o,r)>0,{newBlock1:c,newBlock2:a}=vv(o,r);if(c===a){const A=c,k=h0(A,o),v=h0(A,r);return t=Bt(c,V(k)),e=Bt(c,V(v)),Le.debug(`select in complex block: ${k.id}, ${v.id}`),Ul(n,A,t,e)}let d=l?G(n,c):0;c===o&&t instanceof qt&&(d=t.offset);let m=l?0:G(n,a);return a===r&&e instanceof qt&&(m=e.offset),t=F(c,d,l?"end":"home"),e=F(a,m,l?"home":"end"),{anchor:t,focus:e}}const yv=w("move-complex-block-position");function kv(n,t,e){const o=n.getBlockById(t.blockId);u(yv,at(n,o),"is not a complex block");const r=xe(n,o),i=n.getContainerById(t.childContainerId),s=r.getNextContainer(n,o,i,e,{noWrap:!0});return s?Bt(o,V(s)):null}const ss=w("move-simple-block-position");function f0(n,t){const e=Se(n,t);u(ss,e.length>0,"complex block has not any child container");const o=e[0];return Ft(o)}function m0(n,t){const e=Se(n,t);u(ss,e.length>0,"complex block has not any child container");const o=e[e.length-1];return Jt(o)}function g0(n,t,e){const o=e?f0(n,t):m0(n,t);return at(n,o)?g0(n,o,e):o}function wv(n,t){const e=n.getBlockById(t.blockId);return at(n,e)&&t.offset===0?f0(n,e):Lr(e)}function Bv(n,t){const e=n.getBlockById(t.blockId);return at(n,e)&&t.offset===1?m0(n,e):Dr(e)}function Pd(n){return n==="ArrowLeft"||n==="ArrowUp"}function $d(n,t,e){const o=z(t);if(Ct(o))return null;const r=U(o);u(ss,r,"child container has not parent block"),u(ss,at(n,r),"is not a complex block");const i=xe(n,r).getNextContainer(n,r,o,e);return i?Pd(e)?Jt(i):Ft(i):$d(n,r,e)}function Ev(n,t,e){const o=z(t);if(Ct(o))return null;const r=U(o);if(u(ss,r,"child container has not parent block"),Pd(e)){const l=bt(r);if(l)return l}else{const l=dt(r);if(l)return l}const i=$d(n,r,e);if(i)return i;let s=r;for(;!Ct(z(s));)s=U(z(s));return Pd(e)?bt(s):dt(s)}function Iv(n,t,e){return!at(n,t)||xe(n,t).enableKeyboardSelect?t:g0(n,t,e==="ArrowDown"||e==="ArrowRight")}function xv(n,t,e){const o=n.getBlockById(t.blockId),i=pt(n,o).moveCaret(n,o,t,e);if(i)return i;let s=e==="ArrowDown"||e==="ArrowRight"?wv(n,t):Bv(n,t);if(s||(s=$d(n,o,e),s||(s=Ev(n,o,e))),!s){if(e==="ArrowDown"||e==="ArrowRight"){if(n.readonly||!Ct(z(o)))return null;const l=n.insertTextBlock("",V(n.rootContainer),Ze(n.rootContainer));return F(l,0,"home")}return null}if(s=Iv(n,s,e),_(n,s)){const l=n.selection.getSuggestedCaretX();if(e==="ArrowDown")return JA(n,s,o,t,l);if(e==="ArrowUp")return YA(n,s,o,t,l)}return e==="ArrowLeft"||e==="ArrowUp"?F(s,G(n,s),"end"):e==="ArrowRight"||e==="ArrowDown"?F(s,0,"home"):null}function Tv(n,t,e){if(t==="ArrowLeft")return e.start;const o=e.end,r=n.getBlockById(o.blockId);if(_(n,r))return o;const i=dt(r);if(i)return F(i,0,"home");if(!Ct(z(r))||n.readonly)return o;const s=n.insertTextBlock("",V(n.rootContainer),Ze(n.rootContainer));return F(s,0,"home")}function Sv(n,t,e){const o=n.selection.range;let r;if(o instanceof Kt)e==="move"&&!o.isCollapsed()&&(t==="ArrowLeft"||t==="ArrowRight")?r=Tv(n,t,o):r=xv(n,o.getFocusedPos(),t);else if(r=kv(n,o.focus,t),e==="move"){const i=r!=null?r:o.focus,s=n.getContainerById(i.childContainerId);if(t==="ArrowLeft"||t==="ArrowUp"){const l=Jt(s);r=F(l,0,"home")}else{const l=Ft(s);r=F(l,G(n,l),"end")}}return r?e==="move"?{anchor:r,focus:r}:mc(n,o.anchor,r):null}function vo(n,t,e){const o=Sv(n,t,e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),(t==="ArrowLeft"||t==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function p0(n){return vo(n,"ArrowLeft","move"),!0}function C0(n){return vo(n,"ArrowRight","move"),!0}function A0(n){return vo(n,"ArrowUp","move"),!0}function b0(n){if(vo(n,"ArrowDown","move")||n.readonly)return!0;const t=n.getFocusedBlock(),e=z(t);if(Ct(e)||Jt(e)!==t)return!0;const o=n.rootContainer;return n.insertTextBlock("",V(o),Ze(o)),!0}function v0(n){return vo(n,"ArrowDown","select"),!0}function y0(n){return vo(n,"ArrowLeft","select"),!0}function k0(n){return vo(n,"ArrowRight","select"),!0}function w0(n){return vo(n,"ArrowUp","select"),!0}const B0=w("word-offset");function _d(n,t){const e=n.selection.range.focus;u(B0,e.isSimple(),"invalid range type");const o=n.getBlockById(e.blockId);if(Tt(n,o))return F(o,0,"home");if(e.offset===0||!_(n,o)){const s=bt(o);if(!s)return null;const l=F(s,G(n,s),"end");if(t==="select"&&_(n,s)){const c=dd(n,s,l.offset);return F(s,c,"normal")}return l}const r=dd(n,o,e.offset);return F(o,r,"normal")}function Fd(n,t){const e=n.selection.range.focus;u(B0,e.isSimple(),"invalid range type");const o=n.getBlockById(e.blockId);if(Tt(n,o))return F(o,0,"end");if(e.offset===G(n,o)||!_(n,o)){const s=dt(o);if(!s)return null;const l=F(s,0,"home");if(t==="select"&&_(n,s)){const c=hd(n,s,l.offset);return F(s,c,"end")}return l}const r=hd(n,o,e.offset);return F(o,r,"normal")}function E0(n){if(!n.selection.range.focus.isSimple())return!1;const e=_d(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function I0(n){if(!n.selection.range.focus.isSimple())return!1;const e=Fd(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function x0(n){if(!n.selection.range.focus.isSimple())return!1;const e=_d(n,"select");return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function T0(n){if(!n.selection.range.focus.isSimple())return!1;const e=Fd(n,"select");return e?(n.selection.setSelection(n.selection.range.anchor,e),n.selection.updateLastCaretRect(),!0):!1}w("find-block");function Hd(n,t){if(!at(n,t))return t;const o=xe(n,t).getChildContainers(n,t)[0],i=Mt(o)[0];return Hd(n,i)}function jd(n,t){if(!at(n,t))return t;const e=xe(n,t).getChildContainers(n,t),o=e[e.length-1],r=Mt(o),i=r[r.length-1];return jd(n,i)}function S0(n){const t=jd(n,Jt(n.rootContainer)),e=F(t,G(n,t),"end");return n.selection.setSelection(e),!0}function D0(n){const t=Hd(n,n.getFirstBlock()),e=F(t,0,"home");return n.selection.setSelection(e),!0}function L0(n){const t=Hd(n,n.getFirstBlock()),e=F(t,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function zd(n){const t=jd(n,Jt(n.rootContainer)),e=F(t,G(n,t),"end");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}const M0=w("line-offset");function R0(n){const t=n.selection.range.focus;u(M0,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===0||!_(n,e))return F(e,0,"home");let r=Zg(e,t).start;const{next:i}=ql(e,r);return i&&Pe(i)&&ji(i)==="br"&&(r+=1),F(e,r,"home")}function O0(n){const t=n.selection.range.focus;u(M0,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===G(n,e)||!_(n,e))return F(e,G(n,e),"end");const o=Zg(e,t);return F(e,o.end,"end")}function N0(n){if(!n.selection.range.focus.isSimple())return!1;const e=R0(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function P0(n){if(!n.selection.range.focus.isSimple())return!1;const e=O0(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function $0(n){if(!n.selection.range.focus.isSimple())return!1;const e=R0(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function _0(n){if(!n.selection.range.focus.isSimple())return!1;const e=O0(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}const F0=w("find-block-position");function Dv(n,t,e,o){u(F0,at(n,t),"is not a complex block");const r=xe(n,t).getChildContainers(n,t);u(F0,r.length>0,"complex block has not any child container");const i=Ye(n,e,o),s=i.left+i.width/2,l=i.top+i.height/2,c=Pg(n,t,s,l);return Ud(n,c,e,o)}function Ud(n,t,e,o){if(at(n,t))return Dv(n,t,e,o);const r=j(t);let i=Number.MAX_SAFE_INTEGER;const s=Ye(n,e,o),l=s.left+s.width/2,c=s.top+s.height/2;let a=F(r,0,"home");const d=G(n,t);for(let f=0;f<=d;f++){const m=F(r,f,"normal"),p=Ye(n,t,m),A=An(p,l,c);A<i&&(i=A,a=m)}return a}const H0=w("page-offset");function Lv(n,t){const e=Fp(n)*.9,r=t.getBoundingClientRect().bottom-e;if(r<tv(n))return n.getFirstBlock();const i=bt(t);if(!i)return n.getFirstBlock();let s=i;for(;s;){if(s.getBoundingClientRect().y<r)return s;s=bt(s)}return n.getFirstBlock()}function Mv(n,t){const e=Fp(n)*.9,o=t.getBoundingClientRect(),r=ev(n),i=o.top+e;if(i>r)return n.getLastBlock();const s=dt(t);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>i)return l;l=dt(l)}return n.getLastBlock()}function j0(n){const t=n.selection.range.focus;u(H0,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),o=Lv(n,e);let r;return o===n.getFirstBlock()?r=F(o,0,"home"):r=Ud(n,o,e,t),r}function z0(n){const t=n.selection.range.focus;u(H0,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),o=Mv(n,e);let r;return o===n.getLastBlock()?r=F(o,G(n,o),"end"):r=Ud(n,o,e,t),r}function U0(n){if(!n.selection.range.focus.isSimple())return!1;const e=j0(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function V0(n){if(!n.selection.range.focus.isSimple())return!1;const e=z0(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function q0(n){if(!n.selection.range.focus.isSimple())return!1;const e=j0(n);if(!e)return!1;const o=mc(n,n.selection.getAnchorPos(),e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}function W0(n){if(!n.selection.range.focus.isSimple())return!1;const e=z0(n);if(!e)return!1;const o=mc(n,n.selection.getAnchorPos(),e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}const ls=w("select-all");function G0(n,t){const e=Ft(n),o=Jt(n);return t.start.offset===0&&t.start.blockId===j(e)&&t.end.offset===G(t.getEditor(),o)&&t.end.blockId===j(o)}function Rv(n,t){const e=t.getEditor(),o=xe(e,n).getChildContainers(e,n),r=o[0],i=o[o.length-1],s=j(n);return t.start.blockId===s&&t.start.childContainerId===V(r)&&t.end.blockId===s&&t.end.childContainerId===V(i)}function Ov(n,t){u(ls,t,"no parent block"),u(ls,at(n,t),"not a complex block");const e=xe(n,t).getChildContainers(n,t),o=e[0],r=e[e.length-1];n.selection.setRange(Wt(n,{anchor:Bt(t,V(o)),focus:Bt(t,V(r))}))}function Z0(n,t){const e=z(t);Vd(n,e)}function Q0(n){const t=n.getFocusedBlock(),e=n.selection.range;if(e.start.isSimple()){if(e.start.blockId===e.end.blockId&&_(n,t)){const r=e.start,i=e.end,s=G(n,t);if(r.offset>0||i.offset<s)return n.selection.selectBlock(t,0,s),!1}return M(n.rootContainer,"select-all"),Z0(n,Ft(n.rootContainer)),!1}return u(ls,!e.isSimple(),"invalid range type"),Rv(t,e)?(Z0(n,t),!1):(u(ls,t,"no parent block"),u(ls,at(n,t),"not a complex block"),Ov(n,t),!0)}function Vd(n,t){const e=Mt(t),o=e[0],r=e[e.length-1],i=F(o,0,"home"),s=F(r,G(n,r),"end");n.selection.setSelection(i,s,{noScroll:!0})}function Y0(n){zd(n),n.focus()}const qd=w("selected-block-to-doc");function J0(n,t,e){!t.children||t.children.forEach(o=>{const r=n.getChildContainerData(o);r.forEach(i=>{J0(n,i,e)}),e.blocks[o]=Q.default(r)})}function gc(n,t){const e=pt(n,t.block);if(e.selectionToDoc)return e.selectionToDoc(n,t);const o=Q.default(Ao(n,t.block));if(_(n,t.block)){const i=t.start,s=t.end;if(u(qd,o.text,"no block text"),i.offset===s.offset)return{blocks:{root:[{...o,text:[]}]},meta:{},comments:{}};const{middle:l}=Gt(o.text,i.offset,s.offset-i.offset);return{blocks:{root:[{...o,text:l}]},meta:{},comments:{}}}if(Te(t.block))return{blocks:{root:[o]},meta:{},comments:{}};u(qd,at(n,t.block),"not complex block"),u(qd,o.children,"no children");const r={blocks:{root:[o]},meta:{},comments:{}};return J0(n,o,r),r}function Wd(n,t){const e=F(t,0,"normal"),o=F(t,G(n,t),"end");return gc(n,{block:t,start:e,end:o})}const Nv=w("block-to-doc");function Pv(n,t){u(Nv,t.length>0,"invalid params, no blocks");const e=t.map(o=>Wd(n,o));return rr(e)}function cs(n){const e=n.selection.range.getSelectedBlocks().map(o=>gc(n,o));return rr(e)}function K0(n,t){const e=n.getContainerById(t),i=Mt(e).map(s=>({start:F(s,0,"home"),end:F(s,G(n,s),"end"),block:s})).map(s=>gc(n,s));return rr(i)}const pc=w("editor-selection");class $v{constructor(t){h(this,"editor");h(this,"caret");h(this,"_range");h(this,"lastCaretRect");h(this,"handleBlockDelete",(t,e,o,r)=>{if(o||r.child)return;const i=this.range;if(jp(e,i)){pc.debug("adjust selection because remote deleted current block");const s=zp(t,e);this.setRange(s,{noScroll:!0})}});this.editor=t;const e=t.getFirstBlock(),o=j(e);this.caret=new Jb(t);const r=F(o,0,"normal");this._range=Wt(t,{anchor:r,focus:r}),this.lastCaretRect=null,this.editor.addListener("blockDeleted",this.handleBlockDelete),setTimeout(()=>{this.updateFocusedBlock(null)})}destroy(){this.caret.destroy()}get range(){return this._range}get focusedBlock(){return this.getFocusedBlock()}get startBlock(){return this.getStartBlock()}get endBlock(){return this.getEndBlock()}getFocusedBlock(){const t=this.range.focus;return this.editor.getBlockById(t.blockId)}getStartBlock(){const t=this.range.start;return this.editor.getBlockById(t.blockId)}getEndBlock(){const t=this.range.end;return this.editor.getBlockById(t.blockId)}selectBlock(t,e,o){const r=F(t,e,"normal");let i;o&&(i=F(t,o,"normal")),this.setSelection(r,i)}setSelection(t,e,o){if(e||(e=t),this.verifyPos(t),this.verifyPos(e),!this.selectionChanging(t,e))return this.range;const r=Wt(this.editor,{anchor:t,focus:e});if(this.range.isEqual(r))return this.range;const i=this._range;return this._range=r,this.selectionChanged(),this.updateFocusedBlock(i),rt(this.editor.rootContainer,"select-all")&&(!r.isSimple()||!sv(this.editor,r))&&H(this.editor.rootContainer,"select-all"),o!=null&&o.noScroll||this.scrollIntoView(),this.range}setRange(t,e){return this.setSelection(t.anchor,t.focus,e)}updateSelection(){this.caret.update(),Kb(this.editor)}getFocusedPos(){return this.range.focus}getAnchorPos(){return this.range.anchor}selectionChanging(t,e){return!0}selectionChanged(){this.updateSelection(),this.editor.emit("selectionChanged",this.editor)}updateLastCaretRect(){const t=this.range.focus;if(!uo(t))return;const e=this.editor.getBlockById(t.blockId);this.lastCaretRect=Ye(this.editor,e,t)}getSuggestedCaretX(){var t;return(t=this.lastCaretRect)==null?void 0:t.x}scrollIntoView(){iv(this.editor)}verifyPos(t){const e=this.editor.getBlockById(t.blockId);if(t.isSimple())t.offset>=0&&t.offset<=G(this.editor,e)||u(pc,!1,"invalid block position, out of range");else{const o=t.childContainerId;!!this.editor.getContainerById(o)||u(pc,!1,"invalid complex block position, no container found")}}updateFocusedBlock(t){if(t&&this.range.start.blockId===t.start.blockId)return;let e;t&&t.start.blockId===t.end.blockId&&(e=this.editor.findBlockById(t.start.blockId));let o;(this.range.isCollapsed()||!this.range.isSimple()||this.range.start.blockId===this.range.end.blockId)&&(o=this.editor.getBlockById(this.range.start.blockId));let r=!1;e&&rt(e,"focused")&&(H(e,"focused"),r=!0),this.removeAllBlockFocusedClass(),o&&this.setBlockFocused(o)&&(r=!0),r&&this.editor.emit("focusBlockChanged",this.editor,o!=null?o:null,e!=null?e:null)}verify(){this.verifyPos(this._range.start),this.verifyPos(this._range.end)}to(t){const e=cs(this.editor);return t==="text"?cc(this.editor,e):t==="markdown"?$r(this.editor,e):Vp(this.editor,e)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(t=>{H(t,"focused"),H(t,"child-focused")})}setBlockFocused(t){if(rt(t,"focused"))return!1;M(t,"focused");let e=z(t);for(;Ke(e);){const o=U(e);u(pc,o,"parent block not found"),M(o,"child-focused"),e=z(o)}return!0}}function _v(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);!e||n.selection.selectBlock(e,0,G(n,e))}function Fv(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);if(!e||!_(n,e))return;let o=_d(n,"select"),r=Fd(n,"select");if(!o||!r)return;const i=t.blockId;o.blockId!==i&&(o=F(e,0,"home")),r.blockId!==i&&(r=F(e,G(n,e),"end")),n.selection.setSelection(o,r)}class Hv{constructor(t){h(this,"editor");h(this,"startPos",null);h(this,"lastCaretRect");h(this,"mouseDownEvent",null);h(this,"handleMouseDown",t=>{this.mouseDownEvent=t;const e=Fg(this.editor,t.x,t.y);if(e){if(e instanceof tn)return;const o=this.editor.selection.range;if(t.shiftKey&&o.isSimple()){const r=o.anchor;this.editor.selection.setSelection(r,e.focus),this.startPos=e.start}else this.editor.selection.setSelection(e.anchor,e.focus),this.startPos=e.start;this.editor.selection.updateLastCaretRect()}});h(this,"handleMouseMove",t=>{if(!this.startPos||!this.mouseDownEvent||Math.abs(this.mouseDownEvent.x-t.x)<3&&Math.abs(this.mouseDownEvent.y-t.y)<3)return;const e=Vl(this.editor,t.x,t.y);if(!e)return;const o=mc(this.editor,this.startPos,e.end);if(!o)return;const{anchor:r,focus:i}=o;this.editor.selection.setSelection(r,i)});h(this,"handleMouseUp",t=>{this.startPos=null});this.editor=t,this.startPos=null,this.lastCaretRect=new DOMRect}isSelecting(){return this.startPos!==null}stopSelection(){this.startPos=null}handleDblClick(t){Fv(this.editor)}handleTripleClick(t){_v(this.editor)}}function jv(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function zv(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const X0=w("delete-text");function t2(n,t,e,o){const r=o!=null?o:n.selection.range.start;r instanceof qt||u(X0,!1,`invalid insert pos type: ${typeof r}`);const{blockId:i}=r,s=n.getBlockById(i);u(X0,_(n,s),"block is not a text kind block");let{offset:l}=r;if(t==="backward"){if(l-e<0)return 0;if(!le(s,l-e)){const c=go(s,l);e=l-c}}else if(t==="forward"&&l+e>G(n,s))return 0;return t==="backward"&&(l-=e),n.deleteTextFromBlock(s,l,e)}function e2(n,t){if(n.getBlockData(t).quoted){const e={quoted:null};return n.updateBlockData(t,e),!0}return!1}const Uv=w("handle-backspace");function Gd(n,t){if(!Tt(n,t))return;const e=z(t);Ze(e)!==1&&n.deleteBlock(t)}function Vv(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,o=n.getBlockById(e.blockId);if(_(n,o))if(e.offset===0){if(e2(n,o))return;const r=bt(o);if(r){if(!n.isBlockWritable(r))return;if(_(n,r))n.mergeTextBlock(r,o,{focus:!0});else if(at(n,r)){Gd(n,o);const i=Vi(n,r);i?n.selection.selectBlock(i,G(n,i)):n.selection.selectBlock(r,0,G(n,r))}else Gd(n,o),u(Uv,Te(r),"prev block is not embed block"),n.selection.selectBlock(r,1)}else{const i=z(o);if(Ke(i)){const s=Rg(n,i);if(s){if(!n.isBlockWritable(s))return;Gd(n,o),n.selection.selectBlock(s,G(n,s))}}}}else t2(n,"backward",1,null),n.selection.updateLastCaretRect();else{const r=K(o),i=z(o);n.insertTextBlock("",V(i),r),n.deleteBlock(o)}}function qv(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,o=n.getBlockById(e.blockId);if(_(n,o))if(e.offset===G(n,o)){const r=dt(o);if(r){if(!n.isBlockWritable(r))return;_(n,r)?n.mergeTextBlock(o,r,{focus:!0}):Tt(n,o)?n.deleteBlock(o,Ot(n,r,0)):n.deleteBlock(r)}}else t2(n,"forward",1,null);else{const r=K(o),i=z(o);n.insertTextBlock("",V(i),r),n.deleteBlock(o)}}function Wv(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const e=n.getFocusedBlock();if(_(n,e)){if(Tt(n,e)&&e2(n,e))return;const o=n.selection.range.start,r=n.breakTextBlock(e,o.offset,{copyBlockAttributes:!0});o.offset!==0?n.selection.selectBlock(r,0):n.selection.scrollIntoView()}else{const o=n.insertTextBlock();n.selection.selectBlock(o,0)}}function Gv(n,t){const e=n.selection.range.getSelectedBlocks()[0],{block:o}=e;if(!_(n,o))return!1;const r=e.end;return n.insertBoxToBlock(o,r.offset,{type:"br",id:P(),box:!0,created:Date.now()}),!0}const Zv=w("input-handler-actions");function Qv(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(Wv(n),!0))}function Yv(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(qv(n),!0))}function Jv(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(Vv(n),!0))}function Kv(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(Gv(n),!0))}function Xv(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(t=>{n.input.handlePasteText(t)}).catch(t=>{Zv.error(t)}),!0)}function n2(n,t,e){if(t.type==="embed"){const s=t.embedData.src;s&&typeof s=="string"&&e.add(s);return}const o=t.text;o&&o.forEach(i=>{i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"&&e.add(i.attributes.src)});const r=t.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{n2(n,l,e)})})}function ty(n,t){const e=new Set;return t.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.getResources?i.getResources(r).forEach(s=>{e.add(s)}):n2(t,r,e)}),Array.from(e)}function as(n,t){return`<!doctype html><html><head><meta charset="utf8" />${`<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${Zo(JSON.stringify(t))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function us(n,t){var i,s,l;const e=(l=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i))!=null?l:{},o=ty(n,t),r={};o.forEach(c=>{const a=n.doc.buildResourceUrl(c,{withToken:!0});r[c]=a}),t.meta={...e,resources:r}}function ey(n,t,e){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;let o=cs(n);const r=e==null?void 0:e(n,t,o);if(r===!0)return;typeof r=="object"&&r!==null&&(o=r),us(n,o);const i=ts(n,o),s=$r(n,o),l=as(i,o);t.clipboardData.setData("text/html",l),t.clipboardData.setData("text/plain",s),t.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(o))}function ny(n){if(n.selection.range.isCollapsed())return;const t=cs(n);us(n,t);const e=ts(n,t),o=as(e,t),r=$r(n,t),i=new Blob([o],{type:"text/html"});Nl([{type:"text/plain",data:new Blob([r],{type:"text/plain"})},{type:"text/html",data:i}])}async function Cc(n,t){const e=Wd(n,t);us(n,e);const o=ts(n,e),r=$r(n,e),i=as(o,e);return Nl([{type:"text/plain",data:new Blob([r],{type:"text/plain"})},{type:"text/html",data:new Blob([i],{type:"text/html"})}])}function oy(n){return ny(n),Dd(n),!0}const Ac={ArrowDown:b0,ArrowUp:A0,ArrowLeft:p0,ArrowRight:C0,"Shift+ArrowDown":v0,"Shift+ArrowUp":w0,"Shift+ArrowLeft":y0,"Shift+ArrowRight":k0,"CtrlOrCmd+ArrowLeft":E0,"CtrlOrCmd+ArrowRight":I0,"CtrlOrCmd+Shift+ArrowLeft":x0,"CtrlOrCmd+Shift+ArrowRight":T0,"CtrlOrCmd+ArrowUp":D0,"CtrlOrCmd+ArrowDown":S0,"CtrlOrCmd+Shift+ArrowUp":L0,"CtrlOrCmd+Shift+ArrowDown":zd,"CtrlOrCmd+A":Q0,Home:$0,End:_0,"Shift+Home":N0,"Shift+End":P0,PageUp:U0,PageDown:V0,"Shift+PageUp":q0,"Shift+PageDown":W0,"CtrlOrCmd+X":oy,"CtrlOrCmd+Z":jv,"CtrlOrCmd+Shift+Z":zv,Enter:Qv,Delete:Yv,Backspace:Jv,"Shift+Enter":Kv,"CtrlOrCmd+Shift+V":Xv};function o2(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function r2(n,t,e){if(t.type==="embed"){const i=t.embedData,s=i.src;if(s&&typeof s=="string"){const l=e.get(s);l&&(i.src=l)}return}const o=t.text;o&&o.forEach(i=>{if(i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"){const s=e.get(i.attributes.src);s&&(i.attributes.src=s)}});const r=t.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{r2(n,l,e)})})}function i2(n,t,e){if(e.size===0)return;t.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.replaceResources?i.replaceResources(r,e):r2(t,r,e)})}async function ry(n,t){const e=t.filter(i=>i.indexOf(":")===-1),o=await n.doc.addResources(e),r=new Map;if(e.length!==o.length)return r;for(let i=0;i<e.length;i++)r.set(e[i],o[i]);return r}function iy(n,t){var i,s;const o=t.meta.serverId;if(!o||typeof o!="string")return!1;const r=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i);return!(!r||r.serverId!==o)}async function sy(n,t){const o=t.meta.resources;if(!o||Object.keys(o).length===0)return;let r=new Map;if(iy(n,t)){const s=Array.from(Object.keys(o));r=await ry(n,s),i2(n,t,r)}const i=new Map;Object.entries(o).forEach(([s,l])=>{r.get(s)===void 0&&s!==l&&i.set(s,l)}),i.size!==0&&i2(n,t,i)}async function ly(n,t){await sy(n,t),n.undoManager.runInGroup(()=>{n.clearSelectedContents();const{block:e,offset:o}=_r(n);n.insertDoc(e,o,t)})}const cy=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function ay(n){let t;for(const e of cy)if(t=n[e],t)break;return t||null}class uy{constructor(t){h(this,"editor");h(this,"handlers",[]);h(this,"onPasteText",async t=>{const e=new DataTransfer;e.setData("text/plain",t);const o=await this.editor.dataConverter.fromData(this.editor,e);o&&this.pasteDocs(o,null)});this.editor=t}onInsertText(t,e){if(!_(this.editor,this.editor.getFocusedBlock()))return;const{containerId:o,blockIndex:r,offset:i}=_r(this.editor);this.handleBeforeInsertText(o,r,i,e)||(this.defaultInsertText(this.editor,o,r,i,e),this.handleAfterInsertText(o,r,i,e),this.editor.selection.updateLastCaretRect())}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];o.handleChanged&&o.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];o.handleRemoteChanged&&o.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:o,offset:r}=_r(this.editor);for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];s.handleCompositionStart&&s.handleCompositionStart(this.editor,e,o,r)}}onUpdateCompositionText(t,e,o){this.editor.updateCompositionText(e,o),this.editor.selection.caret.update();const{containerId:r,blockIndex:i,offset:s}=_r(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,r,i,s,o)}this.editor.selection.updateLastCaretRect()}onCopy(t){ey(this.editor,t,(e,o,r)=>{for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeCopy){const l=s.handleBeforeCopy(this.editor,o,r);if(l===!0)return!0;if(typeof l=="object"&&l!=null)return l}}})}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;this.editor.dataConverter.fromData(this.editor,t.clipboardData).then(async o=>{o&&this.pasteDocs(o,t)})}onFocus(){M(this.editor.rootElement,"active")}onBlur(){H(this.editor.rootElement,"active")}addHandler(t){this.handlers.push(t)}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,t,e,o,r))return!0}return!1}handleAfterInsertText(t,e,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,t,e,o,r))return!0}return!1}handleBeforeKeyDown(t){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,o,r,i){Bd(this.editor,i)}defaultHandleKeydown(t,e){return o2(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];if(o.handleBeforePasteDoc&&await o.handleBeforePasteDoc(this.editor,t))return}await ly(this.editor,t);for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];if(o.handleAfterPasteDoc&&await o.handleAfterPasteDoc(this.editor,t))return}}async pasteDocs(t,e){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePaste&&await i.handleBeforePaste(this.editor,e,t))return}const o=ay(t);if(!!o){await this.pasteDoc(o);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPaste&&await i.handleAfterPaste(this.editor,e,t))return}}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}}function dy(n,t,e){const o=Sr(t,e);return o.remove(),o}w("copy-dom-attributes");const s2=["onabort","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onauxclick","onblur","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","ongotpointercapture","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onlostpointercapture","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onpause","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointermove","onpointerout","onpointerover","onpointerup","onprogress","onratechange","onreset","onresize","onscroll","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectionchange","onselectstart","onslotchange","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onvolumechange","onwaiting","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel"];function hy(n,t){for(let l=0;l<s2.length;l++){const c=s2[l];t[c]=n[c]}const e=n.attributes,o=t.attributes,r=[],i=[];for(let l=0;l<e.length;l++){const c=e[l],a=o.getNamedItem(c.name);a?a.value!==c.value&&(a.value=c.value,i.push(c)):r.push(c)}const s=[];for(let l=0;l<o.length;l++){const c=o[l];e.getNamedItem(c.name)||s.push(c)}r.forEach(l=>{t.setAttribute(l.name,l.value)}),i.forEach(l=>{t.setAttribute(l.name,l.value)}),s.forEach(l=>{t.removeAttribute(l.name)})}function l2(n){const t=Array.from(n.childNodes);return t.forEach(e=>{e instanceof HTMLElement&&e.getAttribute("data-type")==="block-tools"||e.remove()}),t}function c2(n,t,e){var a;const o=n.getContainerById(t),r=Sr(o,e),i=ao(r),s=n.doc.getBlockData(t,e),l=pt(n,r);if((a=l==null?void 0:l.handleUpdateBlock)==null?void 0:a.call(l,n,r,s))n.editorBlockRenders.updateBlock(n,i,r,s);else{const d=n.editorBlocks.createBlock(i,o,s),f=l2(d);l2(r),f.forEach(p=>r.appendChild(p));const m=Hl(d);if(m){const p=Hl(r);p&&p.remove(),r.appendChild(m)}hy(d,r)}yg(n,r,s),n.blockHooks.forEach(d=>{var f;(f=d.update)==null||f.call(d,n,i,o,r,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const fy=w("transform-selection");function a2(n,t,e,o){const{range:r}=n.selection,{anchor:i,focus:s}=r;if(i.blockId!==t&&s.blockId!==t)return r;u(fy,i.isSimple()&&s.isSimple(),"invalid text pos type");let l=i;if(i.blockId===t){const a=ce.transformCursor(i.offset,e,o);l=F(t,a,"normal")}let c=s;if(s.blockId===t){const a=ce.transformCursor(s.offset,e,o);c=F(t,a,"normal")}return Wt(n,{anchor:l,focus:c})}const my=w("handle-block-text-changed");function gy(n,t,e,o,r){const i=n.getContainerById(t),s=Sr(i,e),l=n.doc.getBlockData(t,e);if(u(my,l.text,"no block text"),gg(n,s).setBlockText(n,s,l.text),!r){const c=a2(n,l.id,o,r);n.selection.setRange(c,{noScroll:!0})}}function py(n,t){const e=Q.default(n);return t.delete.forEach(r=>{delete e[r]}),{...e,...t.insert}}function u2(n,t,e,o){const r=pt(n,t);r.handleDeleteBlock&&r.handleDeleteBlock(n,t,e,o),n.emit("blockDeleted",n,t,e,o)}function Cy(n,t,e,o){const r=n.getBlockByIndex(t,e);r.querySelectorAll('[data-type="editor-block"]').forEach(i=>{u2(n,i,o,{child:!0})}),u2(n,r,o,{child:!1})}const on=w("editor-doc");class Ay extends Pi{constructor(e,o,r){super();h(this,"localEvents",[]);this.editor=e,this.externalDoc=o,this.externalDoc.registerCallback(this),this.registerLocalEvents(r)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var o,r;return(r=(o=this.externalDoc).getVersionHelper)==null?void 0:r.call(o)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}getBlockData(e,o){return this.externalDoc.getBlockData(e,o)}verifyBlockWritable(e,o){const r=this.editor.getBlockByIndex(e,o);u(on,this.editor.isBlockWritable(r),`block is not writable, ${e}, ${o}`)}localUpdateBlockText(e,o,r,i){u(on,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,o);const s=this.getBlockData(e,o),l=s.text;u(on,l,`no text, ${e}, ${o}`);const c=a2(this.editor,s.id,r,!0),a=ce.apply(l,r);this.localEvents.forEach(f=>f.onBeforeUpdateBlockText(e,s.id,l,a,c.toDocRange()));const d=this.externalDoc.localUpdateBlockText(e,o,r);return this.editor.selection.setRange(c,i),d}localUpdateBlockData(e,o,r,i){u(on,!this.editor.readonly,"editor is readonly");const s=this.editor.getBlockByIndex(e,o);this.editor.isBlockWritable(s)||u(on,!1,`block is not writable, ${JSON.stringify(r)}}`);const l=Q.default(this.getBlockData(e,o)),c=Q.default(py(l,r));this.localEvents.forEach(d=>d.onBeforeUpdateBlockData(e,l.id,l,c,i));const a=this.externalDoc.localUpdateBlockData(e,o,r,i);return this.editor.selection.setRange(ho(this.editor,i)),a}localInsertBlock(e,o,r,i,s){u(on,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(c=>c.onBeforeInsertBlock(e,o,r,i));const l=this.externalDoc.localInsertBlock(e,o,r,i);return this.editor.selection.setRange(ho(this.editor,i),s),l}localDeleteBlock(e,o,r){u(on,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,o);const i=Q.default(this.getBlockData(e,o));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,o,i,r));const s=this.externalDoc.localDeleteBlock(e,o,r);return this.editor.selection.setRange(ho(this.editor,r)),s}localDeleteChildContainers(e){return u(on,!this.editor.readonly,"editor is readonly"),e.forEach(o=>{const r=Q.default(this.getContainerBlocks(o));this.localEvents.forEach(i=>i.onBeforeDeleteChildContainer(o,r))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainer(e,o){return u(on,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(r=>r.onBeforeInsertChildContainer(e,Q.default(o))),this.externalDoc.localInsertChildContainer(e,o)}onRequestReload(e){on.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,e)});const o=!1;this.editor.emit("docChanged",this.editor,o)}onUpdateBlockText(e,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,e,o,r,i)}),gy(this.editor,e,o,r,i),this.editor.emit("docChanged",this.editor,i)}onUpdateBlockData(e,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,o,r,i)}),c2(this.editor,e,o),this.editor.emit("docChanged",this.editor,i)}onInsertBlock(e,o,r,i){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,o,r,i)});const s=this.editor.getContainerById(e);Hb(this.editor,s,o,r),this.editor.emit("docChanged",this.editor,i)}onDeleteBlock(e,o,r){Cy(this.editor,e,o,r),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,o,r)});const i=this.editor.getContainerById(e);dy(this.editor,i,o),this.editor.emit("docChanged",this.editor,r)}onInsertChildContainer(e,o,r){this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,r)})}onDeleteChildContainer(e,o){this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,e,o)})}onCustomMessage(e){this.callbacks.forEach(o=>{var r;return(r=o.onCustomMessage)==null?void 0:r.call(o,e)})}onStatusChanged(e){this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,e)})}onError(e){this.callbacks.forEach(o=>{var r;return(r=o.onError)==null?void 0:r.call(o,e)})}uploadResource(e,o){return this.externalDoc.uploadResource(e,o)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,o){return this.externalDoc.buildResourceUrl(e,o)}request(e,o){return this.externalDoc.request(e,o)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,o,r;return(r=(o=(e=this.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}reset(e){on.log("reset doc"),this.externalDoc=e,this.externalDoc.registerCallback(this),this.editor.reload()}}function d2(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const Zd=w("undo-action");class zr{constructor(t,e,o){h(this,"beforeRange");h(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=o}undo(t){return!1}redo(t){return!1}combinable(t){return u(Zd,t,"no other action"),!1}combine(t){u(Zd,!1,"no other")}setAfterRange(t){this.afterRange&&Zd.warn("after range has already set"),this.afterRange=t}}const by=w("block-action");class h2 extends zr{constructor(e,o,r,i,s){super(e,o,s);h(this,"blockData");h(this,"blockIndex");this.blockData=Q.default(i),this.blockIndex=r}deleteBlock(e,o){if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockData.id);return i?(u(by,this.blockIndex===K(i),"invalid block index"),xd(e,i,ho(e,o)),!0):!1}insertBlock(e,o){return Fr(e,this.containerId,this.blockIndex,Q.default(this.blockData),o),!0}}class vy extends h2{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class yy extends h2{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class ky extends zr{constructor(e){super(e,V(e.rootContainer),e.selection.range.toDocRange());h(this,"actions",[])}addAction(e){d2(this.actions,e),this.afterRange=e.afterRange}undo(e){let o=!1;return this.actions.concat().reverse().forEach(r=>{r.undo(e)&&(o=!0)}),o}redo(e){let o=!1;return this.actions.forEach(r=>{r.redo(e)&&(o=!0)}),o}setAfterRange(e){this.afterRange=e;const o=this.actions[this.actions.length-1];!o||o instanceof zr&&(o.afterRange||o.setAfterRange(e))}}const ir=w("update-block-data-action");class bc extends zr{constructor(e,o,r,i,s,l){super(e,o,l);h(this,"beforeBlockData");h(this,"afterBlockData");h(this,"blockId");this.blockId=r,u(ir,this.blockId===i.id,"invalid block id"),u(ir,this.blockId===s.id,"invalid block id"),this.beforeBlockData=Q.default(i),this.afterBlockData=Q.default(s),u(ir,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){u(ir,e,"no editor");const o=e.getBlockById(this.blockId);if(!o)return!1;const r=e.getContainerById(this.containerId);return u(ir,r,"no container"),fc(e,o,bc.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){u(ir,e,"no editor");const o=e.getBlockById(this.blockId);if(!o)return!1;const r=e.getContainerById(this.containerId);return u(ir,r,"no container"),fc(e,o,bc.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const o=Q.default(e);return delete o.id,delete o.type,o}}const Qd=w("update-block-text-action");class ds extends zr{constructor(e,o,r,i,s,l){super(e,o,l);h(this,"beforeRichTextData");h(this,"afterRichTextData");h(this,"blockId");h(this,"type");this.blockId=r,this.beforeRichTextData=Q.default(i),this.afterRichTextData=Q.default(s),this.type=ds.calType(i,s)}static calType(e,o){u(Qd,e,"no old data"),u(Qd,o,"no new data");const i=ce.diff(e,o),s=new Set;let l=!1;const c=d=>$m(d)?`cjk_${d}`:Nm(d)?"number":Ll(d)?"space":Pm(d)?"letter":"unknown";let a=!1;return i.forEach(d=>{d.insert?d.insert===" "?s.add("insert_letter"):typeof d.insert=="string"&&d.insert.startsWith(" ")&&d.insert.length>1?(l=!0,a=!0,s.add(`insert_${c(d.insert.substr(1))}`)):s.add(`insert_${c(d.insert)}`):d.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:a}}undo(e){if(!e.getContainerById(this.containerId))return!1;const r=e.getBlockById(this.blockId);return r?(hc(e,r,this.beforeRichTextData),!0):!1}redo(e){if(!e.getContainerById(this.containerId))return!1;const r=e.getBlockById(this.blockId);return r?(hc(e,r,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof ds)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const o=e.beforeRange,r=o.anchor;if(!r.isSimple())return!1;const i=this.afterRange;if(!i)return!1;const s=i.anchor;return!(!s.isSimple()||s.blockId!==o.anchor.blockId||s.offset!==r.offset)}combine(e){u(Qd,e instanceof ds,"invalid action type");const o=e;this.afterRichTextData=o.afterRichTextData,this.afterRange=e.afterRange}}class f2 extends zr{constructor(t,e,o){super(t,e,t.selection.range.toDocRange()),this.blocks=o}deleteChildContainer(t){return t.doc.localDeleteChildContainers([this.containerId]),!0}insertChildContainer(t){return t.doc.localInsertChildContainer(this.containerId,Q.default(this.blocks)),!0}}class wy extends f2{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class By extends f2{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const rn=w("undo");class Ey{constructor(t){h(this,"editor");h(this,"actions",[]);h(this,"undoCursor");h(this,"currentGroup",null);h(this,"groupCounter",0);h(this,"undoRedoing",!1);h(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(d2(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(u(rn,!this.currentGroup,"current group already exists"),this.currentGroup=new ky(this.editor),this.groupCounter=1):(u(rn,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){u(rn,this.currentGroup,"current group not exists"),u(rn,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?rn.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw rn.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange(ho(this.editor,t.beforeRange))}catch(e){rn.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange(ho(this.editor,e)):rn.warn("no after range")}catch(e){rn.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,o,r,i){this.undoRedoing||(this.prepareSaveUndoState(),ce.diff(o,r).length!==0&&this.addAction(new ds(this.editor,t,e,o,r,i)))}onBeforeUpdateBlockData(t,e,o,r,i){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new bc(this.editor,t,e,o,r,i);this.addAction(s)}onBeforeInsertBlock(t,e,o,r){this.undoRedoing||(this.prepareSaveUndoState(),u(rn,e>=0,"invalid block index"),u(rn,o,"no block data"),this.addAction(new vy(this.editor,t,e,o,r)))}onBeforeDeleteBlock(t,e,o,r){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new yy(this.editor,t,e,o,r)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new wy(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new By(this.editor,t,e)))}}class Iy{async fromData(t,e){const o=e.getData("text/x-ones-editor-doc");if(o)return{"text/x-ones-editor-doc":JSON.parse(o)}}}class xy{constructor(){h(this,"converters",[]);this.addConverter(new Iy)}async fromData(t,e){let o={};for(const r of this.converters){const i=await r.fromData(t,e);i&&(o={...o,...i})}return o}addConverter(t){this.converters.push(t)}}class Ty{constructor(t){h(this,"renders",[]);this.editor=t}registerRender(t){this.renders.push(t)}renderText(t,e){const o={classes:[],attributes:{},styles:{}};return this.renders.forEach(r=>{if(r.renderText){const i=r.renderText(this.editor,t,e);i.classes&&o.classes.push(...i.classes),i.attributes&&(o.attributes={...o.attributes,...i.attributes}),i.styles&&(o.styles={...o.styles,...i.styles})}}),o}renderBlock(t,e,o){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBlock){const s=i.renderBlock(this.editor,e,o);s.classes&&r.classes.push(...s.classes),s.attributes&&(r.attributes={...r.attributes,...s.attributes}),s.styles&&(r.styles={...r.styles,...s.styles})}}),r}updateBlock(t,e,o,r){this.renders.forEach(i=>{var s;(s=i.updateBlock)==null||s.call(i,t,e,o,r)})}}class $t extends Yt.TypedEmitter{constructor(e){super();h(this,"hoveringBlock",null);h(this,"hoveringTextChild",null);h(this,"filters",[]);h(this,"finders",[]);h(this,"handleDocumentMouseMove",e=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,e))return}const o=document.elementFromPoint(e.x,e.y);if(!o){this.setHoveringBlock(null,e,null);return}let r=U(o);if((!r||!wt(this.editor.rootContainer,r))&&(r=this.findBlockByFinders(e),!r)){this.setHoveringBlock(null,e,null);return}const i=this.getParentTextContentChild(r,o);this.setHoveringBlock(r,e,i)});this.editor=e,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(e=>e.destroy()),this.filters=[],this.finders.forEach(e=>e.destroy()),this.finders=[]}addFilter(e){this.filters.push(e)}addFinder(e){this.finders.push(e)}hoveringBlockId(){return this.hoveringBlock?j(this.hoveringBlock):""}findBlockByFinders(e){for(let o=0;o<this.finders.length;o++){const i=this.finders[o].findTargetBlock(this.editor,e);if(i)return i}return null}setHoveringBlock(e,o,r){if(this.hoveringBlock===e&&this.hoveringTextChild===r)return;if(this.hoveringBlock!==e){const s=this.hoveringBlock&&wt(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&H(s,"hover"),e&&M(e,"hover"),this.hoveringBlock=e,this.emit("change",this.hoveringBlock,s,o)}const i=this.hoveringTextChild;this.hoveringTextChild=r,this.emit("childChange",this.hoveringBlock,r,i,o)}static get(e){return e.addCustom("standard-hovering-block",()=>new $t(e))}getParentTextContentChild(e,o){if(!_(this.editor,e))return null;const r=st(e);return o.parentElement===r?o:Ru(o)}}const m2="style-color-",g2="style-bg-color-";class Sy{renderText(t,e,o){const r=[],i={};return Object.entries(o).forEach(([s,l])=>{l===!0?s.startsWith(m2)?i["data-style-color"]=s.substring(m2.length):s.startsWith(g2)?i["data-style-bg-color"]=s.substring(g2.length):s.startsWith("style")&&r.push(s):typeof l=="string"&&s==="link"&&(r.push("link"),i.link=l)}),{classes:r,attributes:i}}renderBlock(t,e,o){var l,c;const r={};Object.entries(o).filter(a=>a[0].startsWith("style-")).forEach(([a,d])=>{r[`data-${a}`]=`${d}`});const s=[];return((c=(l=t.selection)==null?void 0:l.range)==null?void 0:c.start.blockId)===o.id&&s.push("focused"),typeof o.align=="string"&&o.align&&(r["data-style-align"]=o.align),o.heading&&(r["data-style-heading"]=String(o.heading)),o.quoted&&(r["data-style-quoted"]="true"),$t.get(t).hoveringBlockId()===o.id&&s.push("hover"),{attributes:r,classes:s}}updateBlock(t,e,o,r){var s,l;Array.from(o.attributes).forEach(c=>{c.name.startsWith("data-style-")&&o.removeAttribute(c.name)}),Object.entries(r).filter(c=>c[0].startsWith("style-")).forEach(([c,a])=>{o.setAttribute(`data-${c}`,`${a}`)}),((l=(s=t.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===r.id&&M(o,"focused"),$t.get(t).hoveringBlockId()===r.id&&M(o,"hover")}}function Dy(n){n.editorBlocks.registerBlockClass(ye),n.editorBlocks.registerBlockClass(Mg),n.editorBoxes.registerBoxClass(Dp),n.editorBoxes.registerBoxClass(Lp),n.editorInsertions.registerInsertionClass(Op),n.editorBlockRenders.registerRender(new Sy)}function Ly(n,t){Dy(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const p2=w("range-commands");function C2(n,t){n.forEach(e=>{e.source=t,e.children&&C2(e.children,t)})}function A2(n,t,e){const o=j(t);u(p2,o===e.start.blockId,"invalid start range"),u(p2,o===e.end.blockId,"invalid end range");const r=n.editorCommandProviders.getCommandProviders();let i=[];return r.forEach(s=>{const l=s.getAvailableCommands(n,t,e);C2(l,s.id),i.push(...l)}),r.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,t,e,i);l&&(i=l)}}),at(n,t)&&Rr(n,t,e.start,e.end).forEach(l=>{Mt(l).forEach(a=>{const d=G(n,a),f=Wt(n,{anchor:F(a,0,"home"),focus:F(a,d,"end")}),m=A2(n,a,f);i.push(...m)})}),i}function b2(n){const t=n.getEditor(),e=n.getSelectedBlocks(),o=[];return e.forEach(r=>{const i=Wt(t,{anchor:r.start,focus:r.end});A2(t,r.block,i).forEach(l=>{o.push(l)})}),o}function v2(n,t,e,o,r,i){var d;const s=n.editorCommandProviders.getCommandProviders();for(let f=0;f<s.length;f++){const m=s[f];if(m.beforeExecuteCommand&&m.beforeExecuteCommand(n,t,e,o,r))return!1}const l=n.editorCommandProviders.getCommandProvider(o.source),c={};if((d=l.executeCommand)!=null&&d.call(l,n,t,e,o,r,{}))return i[j(t)]=c,!0;let a=!1;return at(n,t)&&Rr(n,t,e.start,e.end).forEach(m=>{Mt(m).forEach(A=>{const k=G(n,A),v=Wt(n,{anchor:F(A,0,"home"),focus:F(A,k,"end")});v2(n,A,v,o,r,i)&&(a=!0)})}),s.forEach(f=>{f.afterExecuteCommand&&f.afterExecuteCommand(n,t,e,o,r,i)}),a}function y2(n,t,e){const o=n.getEditor(),r={},i=o.editorCommandProviders.getCommandProvider(t.source);return i.executeRangeCommand&&i.executeRangeCommand(o,n,t,e,r)||n.getSelectedBlocks().forEach(l=>{const c=Wt(o,{anchor:l.start,focus:l.end});v2(o,l.block,c,t,e,r)}),r}const My=w("command-providers");class k2{constructor(t){h(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(o=>o.id===t);return u(My,e,`no command provider, id=${t}`),e}getCommands(t){return b2(t)}executeCommand(t,e,o){return this.editor.undoManager.runInGroup(()=>y2(t,e,o))}getEmptyBlockTextAttributes(t,e){let o={};if(this.providers.forEach(r=>{var s;const i=(s=r.getEmptyBlockTextAttributes)==null?void 0:s.call(r,t,e);i&&(o={...o,...i})}),Object.keys(o).length!==0)return o}}function Ry(n,t){const e=z(t),o=V(e),r=K(t);c2(n,o,r)}const Oy=w("table-scroll");class w2{constructor(t,e,o,r,i){h(this,"handleEvent",t=>{this.handler(this.editor,t,this.data)});this.editor=t,this.dom=e,this.name=o,this.handler=r,this.data=i,e.addEventListener(o,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class Ny{constructor(t){h(this,"handlers",new Map);this.editor=t}destroy(){Array.from(this.handlers.entries()).forEach(([t,e])=>{e.forEach(o=>o.destroy()),this.handlers.delete(t)})}addEventListener(t,e,o,r){const i=this.handlers.get(t);if(i){if(i.find(s=>s.handler===o&&s.name===e)){Oy.warn(`event has already registered: ${e}`);return}i.push(new w2(this.editor,t,e,o,r))}else{const s=new w2(this.editor,t,e,o,r);this.handlers.set(t,[s])}}removeEventListener(t,e,o){if(!t){for(const[i,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const c=s[l];if(e)e===c.name&&o===c.handler&&s.splice(l,1);else if(o===c.handler){s.splice(l,1),c.destroy(),s.length===0&&this.handlers.delete(i);continue}}return}const r=this.handlers.get(t);if(r){const i=r.findIndex(s=>s.handler===o&&s.name===e);if(i!==-1){const s=r[i];r.splice(i,1),s.destroy(),r.length===0&&this.handlers.delete(t)}}}removeAllListeners(t,e){const o=this.handlers.get(t);if(o)if(e)for(let r=0;r<o.length;r++){const i=o[r];i.name===e&&(o.splice(r,1),i.destroy())}else o.forEach(r=>{r.destroy()}),this.handlers.delete(t)}}const B2=w("update-block-text");function Py(n,t){const e=n.getBoxById(t.id),o=U(e);u(B2,o,"no parent block"),u(B2,_(n,o),"not a text block");const r=n.getBlockText(o),i=fp(r,"id",t.id,t);n0(n,o,i)}function $y(n,t){for(const e of n.blockHooks)if(e.writable){const o=e.writable(n,t);if(typeof o=="boolean")return o}return!0}function _y(n){return n.readonly?!1:!en(n).find(o=>!n.isBlockWritable(o.block))}class Fy{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}getItem(t){return window.localStorage.getItem(this.getKey(t))}setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class Hy{constructor(){h(this,"shortcuts",[])}handleKeyboardEvents(t,e){const o=this.shortcuts;for(const r of o){const i=Object.entries(r);for(const[s,l]of i)if(jn(e,s)){const c=l(t,e);if(c!==void 0)return c}}}}const qn=w("editor");class jy extends Yt.TypedEmitter{constructor(e,o,r){var i,s,l,c,a,d,f;super();h(this,"parent");h(this,"rootElement");h(this,"contentElement");h(this,"rootContainerObject");h(this,"rootContainer");h(this,"input");h(this,"selection");h(this,"selectionHandler");h(this,"doc");h(this,"id");h(this,"clientId");h(this,"compositingText","");h(this,"undoManager");h(this,"shortcuts",new Hy);h(this,"dataConverter",new xy);h(this,"editorBlocks",new Tg(this));h(this,"editorBoxes",new Rp(this));h(this,"editorInsertions",new Pp(this));h(this,"editorEmbeds",new Dg(this));h(this,"editorDecorators",new $p(this));h(this,"editorCommandProviders",new k2(this));h(this,"editorBlockRenders",new Ty(this));h(this,"blockHooks",[]);h(this,"domEvents",new Ny(this));h(this,"customs",new Map);h(this,"options");h(this,"inputHandlers",new uy(this));h(this,"settingsProvider");h(this,"_readonly",!1);qn.debug("create editor"),this.setMaxListeners(100),this.options={colors:(i=r==null?void 0:r.colors)!=null?i:["#9923E9","#4587C2","#8BDB7A","#FB28D3","#CBC619","#10FEEB","#812A1A","#8A3F25","#22D742","#A53E74","#555C87","#57E0AA"],componentsOptions:(l=(s=r==null?void 0:r.components)==null?void 0:s.options)!=null?l:{},scrollContainer:r==null?void 0:r.scrollContainer},this.settingsProvider=(c=r==null?void 0:r.settingsProvider)!=null?c:new Fy(this),Ly(this,r==null?void 0:r.components),this.blockHooks.push(...(d=(a=r==null?void 0:r.components)==null?void 0:a.blockHooks)!=null?d:[]),this.id=(f=r==null?void 0:r.id)!=null?f:P(),this.clientId=P(),this.undoManager=new Ey(this),this.doc=new Ay(this,o,this.undoManager),this.parent=e,this.rootElement=b("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=b("div",["editor-content"],this.rootElement),this.rootContainerObject=Ip(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new Yb(this,this.inputHandlers),this.selection=new $v(this),this.selectionHandler=new Hv(this),r!=null&&r.shortcuts&&this.shortcuts.shortcuts.push(...r.shortcuts),xt.isMobile&&M(this.rootElement,"mobile"),xt.isSafari&&M(this.rootElement,"safari"),this._readonly&&M(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?M(this.rootElement,"readonly"):H(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:bn(this.rootContainer)}addCustom(e,o){const r=this.customs.get(e);if(r)return r;const i=o(this);return this.customs.set(e,i),i}getCustom(e){const o=this.customs.get(e);return u(qn,o,`${e} does not exists`),o}replaceCustom(e,o){const r=this.customs.get(e);return r&&r.destroy(),this.customs.set(e,o),o}findCustom(e){return this.customs.get(e)}findCustomByType(e){const o=this.customs.values();for(const r of o)if(r instanceof e)return r;return null}destroyCustom(e){const o=this.customs.get(e);o&&(this.customs.delete(e),o.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,o,r){return this.editorBlocks.createBlock(e,o,r)}createBox(e,o){return this.editorBoxes.createBox(e,o)}createInsertion(e,o){return this.editorInsertions.createInsertion(e,o)}destroy(){qn.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,o){Ld(this,e,o)}isWritable(){return _y(this)}isBlockWritable(e){return $y(this,e)}getChildContainerData(e){const o=this.doc.getContainerBlocks(e);return u(qn,o,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),u(qn,Array.isArray(o),`container data is not an array: ${JSON.stringify(o)}`),o}createChildContainer(e,o,r){return xp(this,e,o,r)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const o=this.rootContainer.querySelector(`#${e}`);return o&&u(qn,Jo(o),"not an valid block element"),o!=null?o:null}findBoxById(e){const o=this.rootContainer.querySelector(`#${e}`);return o&&u(qn,Mu(o),"not an valid box element"),o!=null?o:null}getBlockById(e){const o=this.findBlockById(e);return u(qn,o,`no block, id=${e}`),o}getBoxById(e){const o=this.findBoxById(e);return u(qn,o,`no box, id=${e}`),o}getBlockByIndex(e,o){const r=this.getContainerById(e);return Sr(r,o)}getBlockIndex(e){if(typeof e=="string"){const o=this.getBlockById(e);return K(o)}return K(e)}getContainerById(e){return Pr(this,e)}getParentContainer(e){return z(e)}reloadBlock(e){Ry(this,e)}contains(e){const o=e instanceof Element?e:e.parentElement;return o?o.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,o,r,i,s){const l={blockId:r.id,offset:0},c={anchor:l,focus:l};return Fr(this,e,o,r,i!=null?i:c,s)}insertEmbed(e,o,r,i,s){const l={id:P(),type:"embed",embedType:r,embedData:i};return this.insertBlock(e,o,l,s)}deleteBlock(e,o){Td(this,e,o)}mergeTextBlock(e,o){return Xp(this,e,o)}breakTextBlock(e,o,r){return Hr(this,e,o,r).newBlock}getTextPosition(){return _r(this)}getBlockString(e,o){const r=this.getBlockText(e);return vt(r,o)}getBlockData(e){return Ao(this,e)}getBoxData(e){return vp(this,e)}getBlockText(e){return ge(this,e)}setBlockText(e,o){n0(this,e,o)}deleteTextFromBlock(e,o,r,i){return Ed(this,e,o,r,i)}insertTextToBlock(e,o,r,i){return Wp(this,e,o,r,i)}insertBoxToBlock(e,o,r){return Gp(this,e,o,r)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,o,r,i){i0(this,e,o,r,i)}insertDocAt(e,o,r,i){return Od(this,e,o,r,i)}deleteChildContainers(e){Kp(this,e)}replaceBlockText(e,o){return hc(this,e,o)}updateBlockData(e,o,r){const i={...this.getBlockData(e),...o},{id:s,type:l,...c}=i;return fc(this,e,c,(r!=null?r:this.selection.range).toDocRange())}updateEmbedData(e,o,r){return o0(this,e,o,r)}updateBoxData(e){Py(this,e)}getSelectedText(){const e=cs(this);return cc(this,e)}clearSelectedContents(){Dd(this)}insertTextBlock(e,o,r,i){const s=Vn(e!=null?e:"");return Jp(this,s,o,r,i==null?void 0:i.newRange,i==null?void 0:i.insertBlockOptions)}updateCompositionText(e,o){if(e&&!o&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!o){Qp(this);return}o?(this.compositingText="",bu()||Bd(this,e)):(this.compositingText=e,Zp(this))}getColor(e){const o=this.options.colors;return o.length===0?"#FF1A75":o[e%o.length]}}function hs(n,t,e){return new jy(n,t,e)}function zy(n){const t=(o,r)=>{const i=o.findIndex(l=>l.id===r.id);if(i===-1){o.push(r);return}const s=o[i];if(s.value!==r.value){o.splice(i,1);return}if(!!s.states){if(!r.states){s.states=[];return}s.states=cu.default(s.states,r.states)}},e=[];return n.forEach(o=>{o.forEach(r=>{t(e,r)})}),e}const Uy=["#FBBFBD","#FFDDB6","#FFF897","#C5F0C1","#CEDDFE","#DCC9FC","#E5E6E8","#F76964","#FFA53D","#FFE928","#63D156","#A0BBFE","#C4A5FB","#BBBFC3"];class vc extends Yt.TypedEmitter{constructor(e){super();h(this,"users",new Map);h(this,"cursors",new Map);h(this,"addingUser",!1);h(this,"colors");this.colors=e&&e.length>0?e:Uy}setCursor(e){this.addUser(e.user);const o=this.cursors.get(e.user.userId);if(o&&El.default(o,e))return;this.cursors.set(e.user.userId,e);const r=new Set([e.range.anchor.blockId,e.range.focus.blockId]),i=new Set(r);o&&new Set([o.range.anchor.blockId,o.range.focus.blockId]).forEach(l=>{r.has(l)||i.add(l)}),this.emit("remote-carets-change",[...i])}addUsers(e){this.addingUser=!0,e.forEach(o=>this.addUser(o)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var o;return(o=this.users.get(e))!=null?o:null}removeUser(e){this.users.delete(e),this.cursors.delete(e),this.emit("change",Array.from(this.users.values()))}updateUsers(e){this.users.clear(),this.addingUser=!0;try{e.forEach(o=>{this.addUser(o)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const o=new Map;return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e&&ec(r.range)).forEach(r=>{const i=r.range.focus.offset;let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}),o}getCursors(e){return Array.from(this.cursors.values()).filter(o=>o.range.anchor.blockId===e||o.range.focus.blockId===e)}onUpdateBlockText(e,o,r){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(ec(l.range)){const{anchor:c,focus:a}=l.range;c.blockId===e.id&&(c.offset=ce.transformCursor(c.offset,o,r)),a.blockId===e.id&&(a.offset=ce.transformCursor(a.offset,o,r))}})}getFixedUserColor(e,o){let r=0;Array.from(e).forEach(s=>{r+=s.charCodeAt(0)});const i=r%this.colors.length;return this.colors[i]}destroy(){this.removeAllListeners()}}const ne=w("local-doc");class Yd extends Pi{constructor(e,o){super();h(this,"doc");h(this,"serviceUrl");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[Vn("")]}},this.serviceUrl=(o==null?void 0:o.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Q.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);u(ne,r,`no container data: ${e}`);const i=r[o];return u(ne,i,`no block data: ${o}`),i}localUpdateBlockText(e,o,r){const i=this.getBlockData(e,o);u(ne,i.text,"no text for data");const s=ce.apply(i.text,r);return i.text=s,u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,o,r,!0)}),s}localUpdateBlockData(e,o,r){const i=this.getBlockData(e,o);return r.delete.forEach(s=>delete i[s]),Object.entries(r.insert).forEach(([s,l])=>{i[s]=l}),u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,o,r,!0)}),i}localInsertBlock(e,o,r){const i=this.getContainerBlocks(e);return u(ne,i,`no container data: ${e}`),u(ne,o>=0&&o<=i.length,`invalid block index: ${o}, ${i.length}`),i.splice(o,0,r),u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,e,o,r,!0)}),r}localDeleteBlock(e,o){const r=this.getContainerBlocks(e);u(ne,r,`no container data: ${e}`),u(ne,o>=0&&o<=r.length,`invalid block index: ${o}, ${r.length}`);const i=r[o];return r.splice(o,1),u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,o,!0)}),i}localInsertChildContainer(e,o){this.doc.blocks[e]=o,u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onInsertChildContainer)==null?void 0:i.call(r,e,o,!0)})}localDeleteChildContainers(e){ne.debug(`delete child containers: ${e}`),e.forEach(o=>{u(ne,this.doc.blocks[o],`no child container: ${o}`),delete this.doc.blocks[o]}),e.forEach(o=>{u(ne,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,o,!0)})})}uploadResource(e,o){u(ne,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,o){u(ne,!1,"not implemented")}broadcastMessage(e){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new vc}setDoc(e){this.doc=Q.default(e),this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,"change doc")})}destroy(){this.clearCallbacks()}}function Wn(n){return Ct(z(n))}class Vy{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function Jd(n,t,e){n.addCustom(t,()=>{var i;const o=(i=e())!=null?i:void 0;return new Vy(o)})}const qy=w("remote-cursor");class Wy{constructor(){h(this,"remoteUsers",new vc)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const o=e;this.handleUpdateUsers(o.users)}else e.type==="caret"?this.handleUpdateCaret(e):qy.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function Gy(n){const{blocks:t,meta:e,comments:o,...r}=n;return{rootBlocks:t,meta:e,comments:o,childBlocks:r}}function fs(n){const{childBlocks:t,meta:e,comments:o,rootBlocks:r}=Gy(Q.default(n));return{blocks:{root:r,...t},meta:e,comments:o}}function yo(n){return n==="root"?"blocks":n}function Ur(n){return n==="blocks"?"root":n}const Zy={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new se.default(n)},apply(n,t){const e=new se.default(n),o=new se.default(t);return e.compose(o).ops},compose(n,t){const e=new se.default(n),o=new se.default(t);return e.compose(o).ops},diff(n,t){const e=new se.default(n),o=new se.default(t);return e.diff(o).ops},transform(n,t,e){const o=new se.default(n);return new se.default(t).transform(o,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const o=new se.default(t),r=this.transformCursor(n.index,o,e),i=this.transformCursor(n.index+n.length,o,e);return{...n,index:r,length:i-r}}}};var ms=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ko={},Kd=mm.default.EventEmitter;ko.EventEmitter=Kd,ko.mixin=Qy;function Qy(n){for(var t in Kd.prototype)n.prototype[t]=Kd.prototype[t]}var E2=["info","warn","error"];function I2(){var n={};E2.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var Yy=I2;I2.prototype.setMethods=function(n){n=n||{};var t=this;E2.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var Jy=Yy,Ky=new Jy,x2=Ky;function sr(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,sr):this.stack=new Error().stack}sr.prototype=Object.create(Error.prototype),sr.prototype.constructor=sr,sr.prototype.name="ShareDBError",sr.CODES={ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT:"ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT",ERR_APPLY_SNAPSHOT_NOT_PROVIDED:"ERR_APPLY_SNAPSHOT_NOT_PROVIDED",ERR_CLIENT_ID_BADLY_FORMED:"ERR_CLIENT_ID_BADLY_FORMED",ERR_CANNOT_PING_OFFLINE:"ERR_CANNOT_PING_OFFLINE",ERR_CONNECTION_SEQ_INTEGER_OVERFLOW:"ERR_CONNECTION_SEQ_INTEGER_OVERFLOW",ERR_CONNECTION_STATE_TRANSITION_INVALID:"ERR_CONNECTION_STATE_TRANSITION_INVALID",ERR_DATABASE_ADAPTER_NOT_FOUND:"ERR_DATABASE_ADAPTER_NOT_FOUND",ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE:"ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE",ERR_DATABASE_METHOD_NOT_IMPLEMENTED:"ERR_DATABASE_METHOD_NOT_IMPLEMENTED",ERR_DEFAULT_TYPE_MISMATCH:"ERR_DEFAULT_TYPE_MISMATCH",ERR_DOC_MISSING_VERSION:"ERR_DOC_MISSING_VERSION",ERR_DOC_ALREADY_CREATED:"ERR_DOC_ALREADY_CREATED",ERR_DOC_DOES_NOT_EXIST:"ERR_DOC_DOES_NOT_EXIST",ERR_DOC_TYPE_NOT_RECOGNIZED:"ERR_DOC_TYPE_NOT_RECOGNIZED",ERR_DOC_WAS_DELETED:"ERR_DOC_WAS_DELETED",ERR_INFLIGHT_OP_MISSING:"ERR_INFLIGHT_OP_MISSING",ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION:"ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION",ERR_MAX_SUBMIT_RETRIES_EXCEEDED:"ERR_MAX_SUBMIT_RETRIES_EXCEEDED",ERR_MESSAGE_BADLY_FORMED:"ERR_MESSAGE_BADLY_FORMED",ERR_MILESTONE_ARGUMENT_INVALID:"ERR_MILESTONE_ARGUMENT_INVALID",ERR_OP_ALREADY_SUBMITTED:"ERR_OP_ALREADY_SUBMITTED",ERR_OP_NOT_ALLOWED_IN_PROJECTION:"ERR_OP_NOT_ALLOWED_IN_PROJECTION",ERR_OP_SUBMIT_REJECTED:"ERR_OP_SUBMIT_REJECTED",ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM:"ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM",ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM:"ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM",ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT:"ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT",ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED:"ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED",ERR_OT_OP_BADLY_FORMED:"ERR_OT_OP_BADLY_FORMED",ERR_OT_OP_NOT_APPLIED:"ERR_OT_OP_NOT_APPLIED",ERR_OT_OP_NOT_PROVIDED:"ERR_OT_OP_NOT_PROVIDED",ERR_PRESENCE_TRANSFORM_FAILED:"ERR_PRESENCE_TRANSFORM_FAILED",ERR_PROTOCOL_VERSION_NOT_SUPPORTED:"ERR_PROTOCOL_VERSION_NOT_SUPPORTED",ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED:"ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED",ERR_SNAPSHOT_READ_SILENT_REJECTION:"ERR_SNAPSHOT_READ_SILENT_REJECTION",ERR_SNAPSHOT_READS_REJECTED:"ERR_SNAPSHOT_READS_REJECTED",ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND:"ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND",ERR_TYPE_CANNOT_BE_PROJECTED:"ERR_TYPE_CANNOT_BE_PROJECTED",ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE:"ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE",ERR_UNKNOWN_ERROR:"ERR_UNKNOWN_ERROR"};var yc=sr,gs={},T2=Xy;function Xy(n,t,e,o){var r=function(s,l,c,a){t(c,s,l,"left"),t(a,l,s,"right")},i=n.transformX=function(s,l){e(s),e(l);for(var c=[],a=0;a<l.length;a++){for(var d=l[a],f=[],m=0;m<s.length;){var p=[];if(r(s[m],d,f,p),m++,p.length===1)d=p[0];else if(p.length===0){for(var A=m;A<s.length;A++)o(f,s[A]);d=null;break}else{for(var k=i(s.slice(m),p),v=0;v<k[0].length;v++)o(f,k[0][v]);for(var x=0;x<k[1].length;x++)o(c,k[1][x]);d=null;break}}d!=null&&o(c,d),s=f}return[s,c]};n.transform=function(s,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?t([],s[0],l[0],c):c==="left"?i(s,l)[0]:i(l,s)[1]}}var S2={exports:{}},wo=S2.exports={name:"text0",uri:"http://sharejs.org/types/textv0",create:function(n){if(n!=null&&typeof n!="string")throw new Error("Initial data must be a string");return n||""}},Xd=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},th=function(n){if(typeof n.p!="number")throw new Error("component missing position field");if(typeof n.i=="string"==(typeof n.d=="string"))throw new Error("component needs an i or d field");if(n.p<0)throw new Error("position cannot be negative")},kc=function(n){for(var t=0;t<n.length;t++)th(n[t])};wo.apply=function(n,t){var e;kc(t);for(var o=0;o<t.length;o++){var r=t[o];if(r.i!=null)n=Xd(n,r.p,r.i);else{if(e=n.slice(r.p,r.p+r.d.length),r.d!==e)throw new Error("Delete component '"+r.d+"' does not match deleted text '"+e+"'");n=n.slice(0,r.p)+n.slice(r.p+r.d.length)}}return n};var Gn=wo._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:Xd(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:Xd(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};wo.compose=function(n,t){kc(n),kc(t);for(var e=n.slice(),o=0;o<t.length;o++)Gn(e,t[o]);return e},wo.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var o=n[e];o.p==null&&(o.p=0),Gn(t,o)}return t};var eh=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};wo.transformCursor=function(n,t,e){for(var o=e==="right",r=0;r<t.length;r++)n=eh(n,t[r],o);return n};var tk=wo._tc=function(n,t,e,o){if(th(t),th(e),t.i!=null)Gn(n,{i:t.i,p:eh(t.p,e,o==="right")});else if(e.i!=null){var r=t.d;t.p<e.p&&(Gn(n,{d:r.slice(0,e.p-t.p),p:t.p}),r=r.slice(e.p-t.p)),r!==""&&Gn(n,{d:r,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)Gn(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)Gn(n,t);else{var i={d:"",p:t.p};t.p<e.p&&(i.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(i.d+=t.d.slice(e.p+e.d.length-t.p));var s=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(s-t.p,l-t.p),a=e.d.slice(s-e.p,l-e.p);if(c!==a)throw new Error("Delete ops delete different text in the same region of the document");i.d!==""&&(i.p=eh(i.p,e),Gn(n,i))}return n},ek=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};wo.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=ek(n[t]);return n},T2(wo,tk,kc,Gn);var wc=function(n){return Object.prototype.toString.call(n)=="[object Array]"},nk=function(n){return!!n&&n.constructor===Object},sn=function(n){return JSON.parse(JSON.stringify(n))},et={name:"json0",uri:"http://sharejs.org/types/JSONv0"},Zn={};et.registerSubtype=function(n){Zn[n.name]=n},et.create=function(n){return n===void 0?null:sn(n)},et.invertComponent=function(n){var t={p:n.p};return n.t&&Zn[n.t]&&(t.t=n.t,t.o=Zn[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},et.invert=function(n){for(var t=n.slice().reverse(),e=[],o=0;o<t.length;o++)e.push(et.invertComponent(t[o]));return e},et.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!wc(n[t].p))throw new Error("Missing path")},et.checkList=function(n){if(!wc(n))throw new Error("Referenced element not a list")},et.checkObj=function(n){if(!nk(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function ps(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function Cs(n){n.p.push(n.o[0].p),n.o[0].i!=null&&(n.si=n.o[0].i),n.o[0].d!=null&&(n.sd=n.o[0].d),delete n.t,delete n.o}et.apply=function(n,t){et.checkValidOp(t),t=sn(t);for(var e={data:n},o=0;o<t.length;o++){var r=t[o];(r.si!=null||r.sd!=null)&&ps(r);for(var i=null,s=e,l="data",c=0;c<r.p.length;c++){var a=r.p[c];if(i=s,s=s[l],l=a,i==null)throw new Error("Path invalid")}if(r.t&&r.o!==void 0&&Zn[r.t])s[l]=Zn[r.t].apply(s[l],r.o);else if(r.na!==void 0){if(typeof s[l]!="number")throw new Error("Referenced element not a number");s[l]+=r.na}else if(r.li!==void 0&&r.ld!==void 0)et.checkList(s),s[l]=r.li;else if(r.li!==void 0)et.checkList(s),s.splice(l,0,r.li);else if(r.ld!==void 0)et.checkList(s),s.splice(l,1);else if(r.lm!==void 0){if(et.checkList(s),r.lm!=l){var d=s[l];s.splice(l,1),s.splice(r.lm,0,d)}}else if(r.oi!==void 0)et.checkObj(s),s[l]=r.oi;else if(r.od!==void 0)et.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return e.data},et.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},et.incrementalApply=function(n,t,e){for(var o=0;o<t.length;o++){var r=[t[o]];n=et.apply(n,r),e(r,n)}return n};var ok=et.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var o=0;o<n.length;o++)if(n[o]!==t[o]&&(!e||o!==n.length-1))return!1;return!0};et.append=function(n,t){if(t=sn(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(ps(t),ps(e)),ok(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&Zn[t.t]){if(e.o=Zn[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var o=t.p,r=0;r<e.o.length-1;r++)t.o=[e.o.pop()],t.p=o.slice(),Cs(t),n.push(t);Cs(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Cs(t),Cs(e)),n.push(t)},et.compose=function(n,t){et.checkValidOp(n),et.checkValidOp(t);for(var e=sn(n),o=0;o<t.length;o++)et.append(e,t[o]);return e},et.normalize=function(n){var t=[];n=wc(n)?n:[n];for(var e=0;e<n.length;e++){var o=n[e];o.p==null&&(o.p=[]),et.append(t,o)}return t},et.commonLengthForOps=function(n,t){var e=n.p.length,o=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&o++,e===0)return-1;if(o===0)return null;e--,o--;for(var r=0;r<e;r++){var i=n.p[r];if(r>=o||i!==t.p[r])return null}return e},et.canOpAffectPath=function(n,t){return et.commonLengthForOps({p:t},n)!=null},et.transformComponent=function(n,t,e,o){t=sn(t);var r=et.commonLengthForOps(e,t),i=et.commonLengthForOps(t,e),s=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&s++,(e.na!=null||e.t)&&l++,i!=null&&l>s&&t.p[i]==e.p[i]){if(t.ld!==void 0){var c=sn(e);c.p=c.p.slice(s),t.ld=et.apply(sn(t.ld),[c])}else if(t.od!==void 0){var c=sn(e);c.p=c.p.slice(s),t.od=et.apply(sn(t.od),[c])}}if(r!=null){var a=s==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(ps(t),c=sn(e),ps(c)),c.t&&Zn[c.t]){if(t.t&&t.t===c.t){var d=Zn[t.t].transform(t.o,c.o,o);if(t.si!=null||t.sd!=null)for(var f=t.p,m=0;m<d.length;m++)t.o=[d[m]],t.p=f.slice(),Cs(t),et.append(n,t);else(!wc(d)||d.length>0)&&(t.o=d,et.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[r]===t.p[r])if(a){if(t.ld!==void 0)if(t.li!==void 0&&o==="left")t.ld=sn(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&a&&t.p[r]===e.p[r]?o==="right"&&t.p[r]++:e.p[r]<=t.p[r]&&t.p[r]++,t.lm!==void 0&&a&&e.p[r]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&a){if(e.p[r]===t.p[r])return n;var f=e.p[r],p=t.p[r],A=t.lm;(f<A||f===A&&p<A)&&t.lm--}if(e.p[r]<t.p[r])t.p[r]--;else if(e.p[r]===t.p[r]){if(l<s)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&s===l){var p=t.p[r],A=t.lm,k=e.p[r],v=e.lm;if(k!==v)if(p===k)if(o==="left")t.p[r]=v,p===A&&(t.lm=v);else return n;else p>k&&t.p[r]--,p>v?t.p[r]++:p===v&&k>v&&(t.p[r]++,p===A&&t.lm++),(A>k||A===k&&A>p)&&t.lm--,A>v?t.lm++:A===v&&(v>k&&A>p||v<k&&A<p?o==="right"&&t.lm++:A>p?t.lm++:A===k&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&a){var p=e.p[r],A=e.lm;f=t.p[r],f>p&&t.p[r]--,f>A&&t.p[r]++}else{var p=e.p[r],A=e.lm;f=t.p[r],f===p?t.p[r]=A:(f>p&&t.p[r]--,(f>A||f===A&&p>A)&&t.p[r]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[r]===e.p[r])if(t.oi!==void 0&&a){if(o==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[r]===e.p[r])if(o==="left")et.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[r]==e.p[r]){if(!a)return n;if(t.oi!==void 0)delete t.od;else return n}}}return et.append(n,t),n},T2(et,et.transformComponent,et.checkValidOp,et.append);var rk=S2.exports;et.registerSubtype(rk);var ik=et,sk={type:ik};(function(n){n.defaultType=sk.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(gs);var ln={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var o in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],o=1;o<arguments.length;o++){var r=arguments[o];e=e[r]||(o===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],o=arguments[arguments.length-1],r=1;r<arguments.length-1;r++){var i=arguments[r];e=e[i]||(e[i]=r===arguments.length-2?o():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],o=[e],r=1;r<arguments.length-1;r++){var i=arguments[r];if(!e.hasOwnProperty(i))break;e=e[i],o.push(e)}for(var r=o.length-1;r>=0;r--){var s=o[r],i=arguments[r+1],l=s[i];(r===o.length-1||!n.hasKeys(l))&&delete s[i]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,o){var r=!1;return e.forEach(function(i){i&&(i(o),r=!0)}),r},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];setTimeout(function(){e.apply(null,o)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(ln);var D2=Array.isArray,L2=Object.keys,lk=Object.prototype.hasOwnProperty,ck=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var o=D2(t),r=D2(e),i,s,l;if(o&&r){if(s=t.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!n(t[i],e[i]))return!1;return!0}if(o!=r)return!1;var c=t instanceof Date,a=e instanceof Date;if(c!=a)return!1;if(c&&a)return t.getTime()==e.getTime();var d=t instanceof RegExp,f=e instanceof RegExp;if(d!=f)return!1;if(d&&f)return t.toString()==e.toString();var m=L2(t);if(s=m.length,s!==L2(e).length)return!1;for(i=s;i--!==0;)if(!lk.call(e,m[i]))return!1;for(i=s;i--!==0;)if(l=m[i],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},M2=ko,ak=x2,Me=yc,Bc=gs,cn=ln,uk=cn.clone,dk=ck,ke=Me.CODES,hk=ct;function ct(n,t,e){M2.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}M2.mixin(ct),ct.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},ct.prototype._setType=function(n){if(typeof n=="string"&&(n=Bc.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new Me(ke.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},ct.prototype._setData=function(n){this.data=n,this._dataStateVersion++},ct.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new Me(ke.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new Me(ke.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var o=n.type===void 0?Bc.defaultType:n.type;this._setType(o),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},ct.prototype.whenNothingPending=function(n){var t=this;cn.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},ct.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},ct.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},ct.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},ct.prototype._emitResponseError=function(n,t){if(n&&n.code===ke.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},ct.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var o=this.inflightFetch.shift();if(o&&e.push(o),e.length&&(o=function(r){cn.callEach(e,r)}),n)return this._emitResponseError(n,o);this.ingestSnapshot(t,o),this._emitNothingPending()},ct.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var o=this.pendingFetch;this.pendingFetch=[],e.callback&&o.push(e.callback);var r;if(o.length&&(r=function(i){cn.callEach(o,i)}),n)return this._emitResponseError(n,r);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,r):r&&r(),this._emitNothingPending(),this._flushSubscribe()},ct.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===ke.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=Ec(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var o=0;o<this.pendingOps.length;o++){var e=Ec(this.pendingOps[o],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(r){return this._hardRollback(r)}}},ct.prototype._onConnectionStateChanged=function(){this.connection.canSend?(this.flush(),this._resubscribe()):(this.inflightOp&&(this.pendingOps.unshift(this.inflightOp),this.inflightOp=null),this.subscribed=!1,this.inflightSubscribe&&(this.inflightSubscribe.wantSubscribe?(this.pendingSubscribe.unshift(this.inflightSubscribe),this.inflightSubscribe=null):this._handleSubscribe()),this.inflightFetch.length&&(this.pendingFetch=this.pendingFetch.concat(this.inflightFetch),this.inflightFetch.length=0))},ct.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},ct.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);fk(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},ct.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},ct.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},ct.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,o=e&&e.wantSubscribe===n;if(o){e.callback=mk([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},ct.prototype._flushSubscribe=function(){if(!(this.inflightSubscribe||!this.pendingSubscribe.length)){if(this.connection.canSend){this.inflightSubscribe=this.pendingSubscribe.shift(),this.wantSubscribe=this.inflightSubscribe.wantSubscribe,this.wantSubscribe?this.connection.sendSubscribe(this):(this.subscribed=!1,this.connection.sendUnsubscribe(this));return}if(!this.pendingSubscribe[0].wantSubscribe){this.inflightSubscribe=this.pendingSubscribe.shift();var n=this;cn.nextTick(function(){n._handleSubscribe()})}}};function fk(n,t,e){if(t){var o=n.pop();n.push(function(r){o&&o(r),e&&e(r)})}else n.push(e)}function mk(n){return n=n.filter(cn.truthy),n.length?function(t){cn.callEach(n,t)}:null}ct.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function gk(n){delete n.op,delete n.create,delete n.del}function Ec(n,t){if(n.del)return gk(t);if(t.del)return new Me(ke.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new Me(ke.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new Me(ke.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var o=n.type.transform(n.op,t.op,"left"),r=n.type.transform(t.op,n.op,"right");n.op=o,t.op=r}}}ct.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new Me(ke.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===Bc.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,o=0;o<n.op.length;o++){var r=n.op[o],i={op:[r]};this.emit("before op",i.op,t,n.src);for(var s=e;s<this.applyStack.length;s++){var l=Ec(this.applyStack[s],i);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,i.op)),this.emit("op",i.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},ct.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new Me(ke.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=cn.MAX_SAFE_INTEGER)return this.emit("error",new Me(ke.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},ct.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var o=new Me(ke.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(o):this.emit("error",o)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(i){return this._hardRollback(i)}var r=this;cn.nextTick(function(){r.flush()})},ct.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var o=this._tryCompose(n);if(o){o.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},ct.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var o=this.pendingOps.splice(e),e=0;e<o.length;e++){var t=o[e],r=this._tryCompose(t);r?r.callbacks=r.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},ct.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!dk(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},ct.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var o={op:n},r=t&&t.source;this._submit(o,r,e)},ct.prototype.create=function(n,t,e,o){if(typeof t=="function"?(o=t,e=null,t=null):typeof e=="function"&&(o=e,e=null),t||(t=Bc.defaultType.uri),this.type){var r=new Me(ke.ERR_DOC_ALREADY_CREATED,"Document already exists");return o?o(r):this.emit("error",r)}var i={create:{type:t,data:n}},s=e&&e.source;this._submit(i,s,o)},ct.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new Me(ke.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var o={del:!0},r=n&&n.source;this._submit(o,r,t)},ct.prototype.pause=function(){this.paused=!0},ct.prototype.resume=function(){this.paused=!1,this.flush()},ct.prototype.toSnapshot=function(){return{v:this.version,data:uk(this.data),type:this.type.uri}},ct.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return ak.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},ct.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var o=Ec(this.pendingOps[e],t);if(o)return this._hardRollback(o)}try{this._otApply(t,!1)}catch(r){return this._hardRollback(r)}this._clearInflightOp(n);return}this._hardRollback(n)},ct.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var o=!!t.length,r=0;r<t.length;r++)o=cn.callEach(t[r].callbacks,n)&&o;if(n&&!o)return e.emit("error",n)})},ct.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=cn.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var lr={};lr.ACTIONS={initLegacy:"init",handshake:"hs",queryFetch:"qf",querySubscribe:"qs",queryUnsubscribe:"qu",queryUpdate:"q",bulkFetch:"bf",bulkSubscribe:"bs",bulkUnsubscribe:"bu",fetch:"f",subscribe:"s",unsubscribe:"u",op:"op",snapshotFetch:"nf",snapshotFetchByTimestamp:"nt",pingPong:"pp",presence:"p",presenceSubscribe:"ps",presenceUnsubscribe:"pu",presenceRequest:"pr"};var R2=ko,O2=lr.ACTIONS,pk=ln,Ck=we;function we(n,t,e,o,r,i,s){R2.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=o,this.query=r,this.results=null,i&&i.results&&(this.results=i.results,delete i.results),this.extra=void 0,this.options=i,this.callback=s,this.ready=!1,this.sent=!1}R2.mixin(we),we.prototype.hasPending=function(){return!this.ready},we.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var o=this.results[e];t.push([o.id,o.version])}n.r=t}this.connection.send(n),this.sent=!0}},we.prototype.destroy=function(n){this.connection.canSend&&this.action===O2.querySubscribe&&this.connection.send({a:O2.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&pk.nextTick(n)},we.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},we.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},we.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},we.prototype._handleResponse=function(n,t,e){var o=this.callback;if(this.callback=null,n)return this._finishResponse(n,o);if(!t)return this._finishResponse(null,o);var r=this,i=1,s=function(d){if(d)return r._finishResponse(d,o);--i||r._finishResponse(null,o)};if(Array.isArray(t))i+=t.length,this.results=this._ingestSnapshots(t,s),this.extra=e;else for(var l in t){i++;var c=t[l],a=this.connection.get(c.c||this.collection,l);a.ingestSnapshot(c,s)}s()},we.prototype._ingestSnapshots=function(n,t){for(var e=[],o=0;o<n.length;o++){var r=n[o],i=this.connection.get(r.c||this.collection,r.d);i.ingestSnapshot(r,t),e.push(i)}return e},we.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},we.prototype._handleError=function(n){this.emit("error",n)},we.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var o=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(o)),this.emit("insert",o,e.index);break;case"remove":var i=e.howMany||1,r=this.results.splice(e.index,i);this.emit("remove",r,e.index);break;case"move":var i=e.howMany||1,s=this.results.splice(e.from,i);Array.prototype.splice.apply(this.results,[e.to,0].concat(s)),this.emit("move",s,e.from,e.to);break}}this.emit("changed",this.results)},we.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var N2=ko,Ak=lr.ACTIONS,bk=ln,P2=In;function In(n,t){if(N2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}N2.mixin(In),In.prototype.submit=function(n,t){this.value=n,this.send(t)},In.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},In.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},In.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},In.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},In.prototype._message=function(){return{a:Ak.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},In.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},In.prototype._callbackOrEmit=function(n,t){if(t)return bk.nextTick(t,n);n&&this.emit("error",n)};var vk=ln,$2=nh;function nh(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}nh.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},nh.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&vk.nextTick(n)};var oh={exports:{}};(function(n,t){(function(e,o){o(t)})(ms,function(e){function o(C,y){y=y|0;for(var B=Math.max(C.length-y,0),I=Array(B),D=0;D<B;D++)I[D]=C[y+D];return I}var r=function(C){var y=o(arguments,1);return function(){var B=o(arguments);return C.apply(null,y.concat(B))}},i=function(C){return function(){var y=o(arguments),B=y.pop();C.call(this,y,B)}};function s(C){var y=typeof C;return C!=null&&(y=="object"||y=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function a(C){setTimeout(C,0)}function d(C){return function(y){var B=o(arguments,1);C(function(){y.apply(null,B)})}}var f;l?f=setImmediate:c?f=process.nextTick:f=a;var m=d(f);function p(C){return i(function(y,B){var I;try{I=C.apply(this,y)}catch(D){return B(D)}s(I)&&typeof I.then=="function"?I.then(function(D){A(B,null,D)},function(D){A(B,D.message?D:new Error(D))}):B(null,I)})}function A(C,y,B){try{C(y,B)}catch(I){m(k,I)}}function k(C){throw C}var v=typeof Symbol=="function";function x(C){return v&&C[Symbol.toStringTag]==="AsyncFunction"}function E(C){return x(C)?p(C):C}function L(C){return function(y){var B=o(arguments,1),I=i(function(D,S){var O=this;return C(y,function(N,W){E(N).apply(O,D.concat(W))},S)});return B.length?I.apply(this,B):I}}var R=typeof ms=="object"&&ms&&ms.Object===Object&&ms,$=typeof self=="object"&&self&&self.Object===Object&&self,q=R||$||Function("return this")(),ot=q.Symbol,lt=Object.prototype,gt=lt.hasOwnProperty,ht=lt.toString,kt=ot?ot.toStringTag:void 0;function de(C){var y=gt.call(C,kt),B=C[kt];try{C[kt]=void 0;var I=!0}catch{}var D=ht.call(C);return I&&(y?C[kt]=B:delete C[kt]),D}var oo=Object.prototype,re=oo.toString;function qe(C){return re.call(C)}var $o="[object Null]",kr="[object Undefined]",wr=ot?ot.toStringTag:void 0;function _o(C){return C==null?C===void 0?kr:$o:wr&&wr in Object(C)?de(C):qe(C)}var Na="[object AsyncFunction]",EH="[object Function]",IH="[object GeneratorFunction]",xH="[object Proxy]";function TH(C){if(!s(C))return!1;var y=_o(C);return y==EH||y==IH||y==Na||y==xH}var SH=9007199254740991;function C9(C){return typeof C=="number"&&C>-1&&C%1==0&&C<=SH}function ml(C){return C!=null&&C9(C.length)&&!TH(C)}var Gf={};function ft(){}function Fo(C){return function(){if(C!==null){var y=C;C=null,y.apply(this,arguments)}}}var Zf=typeof Symbol=="function"&&Symbol.iterator,DH=function(C){return Zf&&C[Zf]&&C[Zf]()};function LH(C,y){for(var B=-1,I=Array(C);++B<C;)I[B]=y(B);return I}function Pa(C){return C!=null&&typeof C=="object"}var MH="[object Arguments]";function A9(C){return Pa(C)&&_o(C)==MH}var b9=Object.prototype,RH=b9.hasOwnProperty,OH=b9.propertyIsEnumerable,NH=A9(function(){return arguments}())?A9:function(C){return Pa(C)&&RH.call(C,"callee")&&!OH.call(C,"callee")},pn=Array.isArray;function PH(){return!1}var v9=typeof e=="object"&&e&&!e.nodeType&&e,y9=v9&&!0&&n&&!n.nodeType&&n,$H=y9&&y9.exports===v9,k9=$H?q.Buffer:void 0,_H=k9?k9.isBuffer:void 0,FH=_H||PH,HH=9007199254740991,jH=/^(?:0|[1-9]\d*)$/;function zH(C,y){var B=typeof C;return y=y==null?HH:y,!!y&&(B=="number"||B!="symbol"&&jH.test(C))&&C>-1&&C%1==0&&C<y}var UH="[object Arguments]",VH="[object Array]",qH="[object Boolean]",WH="[object Date]",GH="[object Error]",ZH="[object Function]",QH="[object Map]",YH="[object Number]",JH="[object Object]",KH="[object RegExp]",XH="[object Set]",tj="[object String]",ej="[object WeakMap]",nj="[object ArrayBuffer]",oj="[object DataView]",rj="[object Float32Array]",ij="[object Float64Array]",sj="[object Int8Array]",lj="[object Int16Array]",cj="[object Int32Array]",aj="[object Uint8Array]",uj="[object Uint8ClampedArray]",dj="[object Uint16Array]",hj="[object Uint32Array]",Et={};Et[rj]=Et[ij]=Et[sj]=Et[lj]=Et[cj]=Et[aj]=Et[uj]=Et[dj]=Et[hj]=!0,Et[UH]=Et[VH]=Et[nj]=Et[qH]=Et[oj]=Et[WH]=Et[GH]=Et[ZH]=Et[QH]=Et[YH]=Et[JH]=Et[KH]=Et[XH]=Et[tj]=Et[ej]=!1;function fj(C){return Pa(C)&&C9(C.length)&&!!Et[_o(C)]}function mj(C){return function(y){return C(y)}}var w9=typeof e=="object"&&e&&!e.nodeType&&e,gl=w9&&!0&&n&&!n.nodeType&&n,gj=gl&&gl.exports===w9,Qf=gj&&R.process,B9=function(){try{var C=gl&&gl.require&&gl.require("util").types;return C||Qf&&Qf.binding&&Qf.binding("util")}catch{}}(),E9=B9&&B9.isTypedArray,pj=E9?mj(E9):fj,Cj=Object.prototype,Aj=Cj.hasOwnProperty;function bj(C,y){var B=pn(C),I=!B&&NH(C),D=!B&&!I&&FH(C),S=!B&&!I&&!D&&pj(C),O=B||I||D||S,N=O?LH(C.length,String):[],W=N.length;for(var J in C)(y||Aj.call(C,J))&&!(O&&(J=="length"||D&&(J=="offset"||J=="parent")||S&&(J=="buffer"||J=="byteLength"||J=="byteOffset")||zH(J,W)))&&N.push(J);return N}var vj=Object.prototype;function yj(C){var y=C&&C.constructor,B=typeof y=="function"&&y.prototype||vj;return C===B}function kj(C,y){return function(B){return C(y(B))}}var wj=kj(Object.keys,Object),Bj=Object.prototype,Ej=Bj.hasOwnProperty;function Ij(C){if(!yj(C))return wj(C);var y=[];for(var B in Object(C))Ej.call(C,B)&&B!="constructor"&&y.push(B);return y}function Yf(C){return ml(C)?bj(C):Ij(C)}function xj(C){var y=-1,B=C.length;return function(){return++y<B?{value:C[y],key:y}:null}}function Tj(C){var y=-1;return function(){var I=C.next();return I.done?null:(y++,{value:I.value,key:y})}}function Sj(C){var y=Yf(C),B=-1,I=y.length;return function D(){var S=y[++B];return S==="__proto__"?D():B<I?{value:C[S],key:S}:null}}function Dj(C){if(ml(C))return xj(C);var y=DH(C);return y?Tj(y):Sj(C)}function Pn(C){return function(){if(C===null)throw new Error("Callback was already called.");var y=C;C=null,y.apply(this,arguments)}}function $a(C){return function(y,B,I){if(I=Fo(I||ft),C<=0||!y)return I(null);var D=Dj(y),S=!1,O=0,N=!1;function W(Z,tt){if(O-=1,Z)S=!0,I(Z);else{if(tt===Gf||S&&O<=0)return S=!0,I(null);N||J()}}function J(){for(N=!0;O<C&&!S;){var Z=D();if(Z===null){S=!0,O<=0&&I(null);return}O+=1,B(Z.value,Z.key,Pn(W))}N=!1}J()}}function Br(C,y,B,I){$a(y)(C,E(B),I)}function ie(C,y){return function(B,I,D){return C(B,y,I,D)}}function Lj(C,y,B){B=Fo(B||ft);var I=0,D=0,S=C.length;S===0&&B(null);function O(N,W){N?B(N):(++D===S||W===Gf)&&B(null)}for(;I<S;I++)y(C[I],I,Pn(O))}var Mj=ie(Br,1/0),Ho=function(C,y,B){var I=ml(C)?Lj:Mj;I(C,E(y),B)};function Ii(C){return function(y,B,I){return C(Ho,y,E(B),I)}}function I9(C,y,B,I){I=I||ft,y=y||[];var D=[],S=0,O=E(B);C(y,function(N,W,J){var Z=S++;O(N,function(tt,It){D[Z]=It,J(tt)})},function(N){I(N,D)})}var _a=Ii(I9),x9=L(_a);function xi(C){return function(y,B,I,D){return C($a(B),y,E(I),D)}}var Ti=xi(I9),Jf=ie(Ti,1),T9=L(Jf);function Fa(C,y){for(var B=-1,I=C==null?0:C.length;++B<I&&y(C[B],B,C)!==!1;);return C}function Rj(C){return function(y,B,I){for(var D=-1,S=Object(y),O=I(y),N=O.length;N--;){var W=O[C?N:++D];if(B(S[W],W,S)===!1)break}return y}}var Oj=Rj();function pl(C,y){return C&&Oj(C,y,Yf)}function Nj(C,y,B,I){for(var D=C.length,S=B+(I?1:-1);I?S--:++S<D;)if(y(C[S],S,C))return S;return-1}function Pj(C){return C!==C}function $j(C,y,B){for(var I=B-1,D=C.length;++I<D;)if(C[I]===y)return I;return-1}function Ha(C,y,B){return y===y?$j(C,y,B):Nj(C,Pj,B)}var Kf=function(C,y,B){typeof y=="function"&&(B=y,y=null),B=Fo(B||ft);var I=Yf(C),D=I.length;if(!D)return B(null);y||(y=D);var S={},O=0,N=!1,W=Object.create(null),J=[],Z=[],tt={};pl(C,function(Dt,Lt){if(!pn(Dt)){It(Lt,[Dt]),Z.push(Lt);return}var te=Dt.slice(0,Dt.length-1),ro=te.length;if(ro===0){It(Lt,Dt),Z.push(Lt);return}tt[Lt]=ro,Fa(te,function(Mi){if(!C[Mi])throw new Error("async.auto task `"+Lt+"` has a non-existent dependency `"+Mi+"` in "+te.join(", "));$n(Mi,function(){ro--,ro===0&&It(Lt,Dt)})})}),Sz(),he();function It(Dt,Lt){J.push(function(){_n(Dt,Lt)})}function he(){if(J.length===0&&O===0)return B(null,S);for(;J.length&&O<y;){var Dt=J.shift();Dt()}}function $n(Dt,Lt){var te=W[Dt];te||(te=W[Dt]=[]),te.push(Lt)}function We(Dt){var Lt=W[Dt]||[];Fa(Lt,function(te){te()}),he()}function _n(Dt,Lt){if(!N){var te=Pn(function(Mi,um){if(O--,arguments.length>2&&(um=o(arguments,1)),Mi){var dm={};pl(S,function(Lz,Mz){dm[Mz]=Lz}),dm[Dt]=um,N=!0,W=Object.create(null),B(Mi,dm)}else S[Dt]=um,We(Dt)});O++;var ro=E(Lt[Lt.length-1]);Lt.length>1?ro(S,te):ro(te)}}function Sz(){for(var Dt,Lt=0;Z.length;)Dt=Z.pop(),Lt++,Fa(Dz(Dt),function(te){--tt[te]===0&&Z.push(te)});if(Lt!==D)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function Dz(Dt){var Lt=[];return pl(C,function(te,ro){pn(te)&&Ha(te,Dt,0)>=0&&Lt.push(ro)}),Lt}};function Si(C,y){for(var B=-1,I=C==null?0:C.length,D=Array(I);++B<I;)D[B]=y(C[B],B,C);return D}var _j="[object Symbol]";function Fj(C){return typeof C=="symbol"||Pa(C)&&_o(C)==_j}var Hj=1/0,S9=ot?ot.prototype:void 0,D9=S9?S9.toString:void 0;function Xf(C){if(typeof C=="string")return C;if(pn(C))return Si(C,Xf)+"";if(Fj(C))return D9?D9.call(C):"";var y=C+"";return y=="0"&&1/C==-Hj?"-0":y}function jj(C,y,B){var I=-1,D=C.length;y<0&&(y=-y>D?0:D+y),B=B>D?D:B,B<0&&(B+=D),D=y>B?0:B-y>>>0,y>>>=0;for(var S=Array(D);++I<D;)S[I]=C[I+y];return S}function zj(C,y,B){var I=C.length;return B=B===void 0?I:B,!y&&B>=I?C:jj(C,y,B)}function Uj(C,y){for(var B=C.length;B--&&Ha(y,C[B],0)>-1;);return B}function Vj(C,y){for(var B=-1,I=C.length;++B<I&&Ha(y,C[B],0)>-1;);return B}function qj(C){return C.split("")}var Wj="\\ud800-\\udfff",Gj="\\u0300-\\u036f",Zj="\\ufe20-\\ufe2f",Qj="\\u20d0-\\u20ff",Yj=Gj+Zj+Qj,Jj="\\ufe0e\\ufe0f",Kj="\\u200d",Xj=RegExp("["+Kj+Wj+Yj+Jj+"]");function tz(C){return Xj.test(C)}var L9="\\ud800-\\udfff",ez="\\u0300-\\u036f",nz="\\ufe20-\\ufe2f",oz="\\u20d0-\\u20ff",rz=ez+nz+oz,iz="\\ufe0e\\ufe0f",sz="["+L9+"]",tm="["+rz+"]",em="\\ud83c[\\udffb-\\udfff]",lz="(?:"+tm+"|"+em+")",M9="[^"+L9+"]",R9="(?:\\ud83c[\\udde6-\\uddff]){2}",O9="[\\ud800-\\udbff][\\udc00-\\udfff]",cz="\\u200d",N9=lz+"?",P9="["+iz+"]?",az="(?:"+cz+"(?:"+[M9,R9,O9].join("|")+")"+P9+N9+")*",uz=P9+N9+az,dz="(?:"+[M9+tm+"?",tm,R9,O9,sz].join("|")+")",hz=RegExp(em+"(?="+em+")|"+dz+uz,"g");function fz(C){return C.match(hz)||[]}function $9(C){return tz(C)?fz(C):qj(C)}function mz(C){return C==null?"":Xf(C)}var gz=/^\s+|\s+$/g;function pz(C,y,B){if(C=mz(C),C&&(B||y===void 0))return C.replace(gz,"");if(!C||!(y=Xf(y)))return C;var I=$9(C),D=$9(y),S=Vj(I,D),O=Uj(I,D)+1;return zj(I,S,O).join("")}var Cz=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,Az=/,/,bz=/(=.+)?(\s*)$/,vz=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function yz(C){return C=C.toString().replace(vz,""),C=C.match(Cz)[2].replace(" ",""),C=C?C.split(Az):[],C=C.map(function(y){return pz(y.replace(bz,""))}),C}function _9(C,y){var B={};pl(C,function(I,D){var S,O=x(I),N=!O&&I.length===1||O&&I.length===0;if(pn(I))S=I.slice(0,-1),I=I[I.length-1],B[D]=S.concat(S.length>0?W:I);else if(N)B[D]=I;else{if(S=yz(I),I.length===0&&!O&&S.length===0)throw new Error("autoInject task functions require explicit parameters.");O||S.pop(),B[D]=S.concat(W)}function W(J,Z){var tt=Si(S,function(It){return J[It]});tt.push(Z),E(I).apply(null,tt)}}),Kf(B,y)}function Cn(){this.head=this.tail=null,this.length=0}function F9(C,y){C.length=1,C.head=C.tail=y}Cn.prototype.removeLink=function(C){return C.prev?C.prev.next=C.next:this.head=C.next,C.next?C.next.prev=C.prev:this.tail=C.prev,C.prev=C.next=null,this.length-=1,C},Cn.prototype.empty=function(){for(;this.head;)this.shift();return this},Cn.prototype.insertAfter=function(C,y){y.prev=C,y.next=C.next,C.next?C.next.prev=y:this.tail=y,C.next=y,this.length+=1},Cn.prototype.insertBefore=function(C,y){y.prev=C.prev,y.next=C,C.prev?C.prev.next=y:this.head=y,C.prev=y,this.length+=1},Cn.prototype.unshift=function(C){this.head?this.insertBefore(this.head,C):F9(this,C)},Cn.prototype.push=function(C){this.tail?this.insertAfter(this.tail,C):F9(this,C)},Cn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},Cn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},Cn.prototype.toArray=function(){for(var C=Array(this.length),y=this.head,B=0;B<this.length;B++)C[B]=y.data,y=y.next;return C},Cn.prototype.remove=function(C){for(var y=this.head;y;){var B=y.next;C(y)&&this.removeLink(y),y=B}return this};function H9(C,y,B){if(y==null)y=1;else if(y===0)throw new Error("Concurrency must not be zero");var I=E(C),D=0,S=[],O=!1;function N(tt,It,he){if(he!=null&&typeof he!="function")throw new Error("task callback must be a function");if(Z.started=!0,pn(tt)||(tt=[tt]),tt.length===0&&Z.idle())return m(function(){Z.drain()});for(var $n=0,We=tt.length;$n<We;$n++){var _n={data:tt[$n],callback:he||ft};It?Z._tasks.unshift(_n):Z._tasks.push(_n)}O||(O=!0,m(function(){O=!1,Z.process()}))}function W(tt){return function(It){D-=1;for(var he=0,$n=tt.length;he<$n;he++){var We=tt[he],_n=Ha(S,We,0);_n===0?S.shift():_n>0&&S.splice(_n,1),We.callback.apply(We,arguments),It!=null&&Z.error(It,We.data)}D<=Z.concurrency-Z.buffer&&Z.unsaturated(),Z.idle()&&Z.drain(),Z.process()}}var J=!1,Z={_tasks:new Cn,concurrency:y,payload:B,saturated:ft,unsaturated:ft,buffer:y/4,empty:ft,drain:ft,error:ft,started:!1,paused:!1,push:function(tt,It){N(tt,!1,It)},kill:function(){Z.drain=ft,Z._tasks.empty()},unshift:function(tt,It){N(tt,!0,It)},remove:function(tt){Z._tasks.remove(tt)},process:function(){if(!J){for(J=!0;!Z.paused&&D<Z.concurrency&&Z._tasks.length;){var tt=[],It=[],he=Z._tasks.length;Z.payload&&(he=Math.min(he,Z.payload));for(var $n=0;$n<he;$n++){var We=Z._tasks.shift();tt.push(We),S.push(We),It.push(We.data)}D+=1,Z._tasks.length===0&&Z.empty(),D===Z.concurrency&&Z.saturated();var _n=Pn(W(tt));I(It,_n)}J=!1}},length:function(){return Z._tasks.length},running:function(){return D},workersList:function(){return S},idle:function(){return Z._tasks.length+D===0},pause:function(){Z.paused=!0},resume:function(){Z.paused!==!1&&(Z.paused=!1,m(Z.process))}};return Z}function j9(C,y){return H9(C,1,y)}var Di=ie(Br,1);function jo(C,y,B,I){I=Fo(I||ft);var D=E(B);Di(C,function(S,O,N){D(y,S,function(W,J){y=J,N(W)})},function(S){I(S,y)})}function nm(){var C=Si(arguments,E);return function(){var y=o(arguments),B=this,I=y[y.length-1];typeof I=="function"?y.pop():I=ft,jo(C,y,function(D,S,O){S.apply(B,D.concat(function(N){var W=o(arguments,1);O(N,W)}))},function(D,S){I.apply(B,[D].concat(S))})}}var z9=function(){return nm.apply(null,o(arguments).reverse())},kz=Array.prototype.concat,ja=function(C,y,B,I){I=I||ft;var D=E(B);Ti(C,y,function(S,O){D(S,function(N){return N?O(N):O(null,o(arguments,1))})},function(S,O){for(var N=[],W=0;W<O.length;W++)O[W]&&(N=kz.apply(N,O[W]));return I(S,N)})},U9=ie(ja,1/0),V9=ie(ja,1),q9=function(){var C=o(arguments),y=[null].concat(C);return function(){var B=arguments[arguments.length-1];return B.apply(this,y)}};function Cl(C){return C}function Li(C,y){return function(B,I,D,S){S=S||ft;var O=!1,N;B(I,function(W,J,Z){D(W,function(tt,It){tt?Z(tt):C(It)&&!N?(O=!0,N=y(!0,W),Z(null,Gf)):Z()})},function(W){W?S(W):S(null,O?N:y(!1))})}}function W9(C,y){return y}var za=Ii(Li(Cl,W9)),Al=xi(Li(Cl,W9)),Ua=ie(Al,1);function G9(C){return function(y){var B=o(arguments,1);B.push(function(I){var D=o(arguments,1);typeof console=="object"&&(I?console.error&&console.error(I):console[C]&&Fa(D,function(S){console[C](S)}))}),E(y).apply(null,B)}}var Z9=G9("dir");function Q9(C,y,B){B=Pn(B||ft);var I=E(C),D=E(y);function S(N){if(N)return B(N);var W=o(arguments,1);W.push(O),D.apply(this,W)}function O(N,W){if(N)return B(N);if(!W)return B(null);I(S)}O(null,!0)}function om(C,y,B){B=Pn(B||ft);var I=E(C),D=function(S){if(S)return B(S);var O=o(arguments,1);if(y.apply(this,O))return I(D);B.apply(null,[null].concat(O))};I(D)}function Y9(C,y,B){om(C,function(){return!y.apply(this,arguments)},B)}function J9(C,y,B){B=Pn(B||ft);var I=E(y),D=E(C);function S(N){if(N)return B(N);D(O)}function O(N,W){if(N)return B(N);if(!W)return B(null);I(S)}D(O)}function K9(C){return function(y,B,I){return C(y,I)}}function Va(C,y,B){Ho(C,K9(E(y)),B)}function bl(C,y,B,I){$a(y)(C,K9(E(B)),I)}var vl=ie(bl,1);function rm(C){return x(C)?C:i(function(y,B){var I=!0;y.push(function(){var D=arguments;I?m(function(){B.apply(null,D)}):B.apply(null,D)}),C.apply(this,y),I=!1})}function qa(C){return!C}var Wa=Ii(Li(qa,qa)),yl=xi(Li(qa,qa)),Ga=ie(yl,1);function X9(C){return function(y){return y==null?void 0:y[C]}}function wz(C,y,B,I){var D=new Array(y.length);C(y,function(S,O,N){B(S,function(W,J){D[O]=!!J,N(W)})},function(S){if(S)return I(S);for(var O=[],N=0;N<y.length;N++)D[N]&&O.push(y[N]);I(null,O)})}function Bz(C,y,B,I){var D=[];C(y,function(S,O,N){B(S,function(W,J){W?N(W):(J&&D.push({index:O,value:S}),N())})},function(S){S?I(S):I(null,Si(D.sort(function(O,N){return O.index-N.index}),X9("value")))})}function im(C,y,B,I){var D=ml(y)?wz:Bz;D(C,y,E(B),I||ft)}var Za=Ii(im),kl=xi(im),Qa=ie(kl,1);function t7(C,y){var B=Pn(y||ft),I=E(rm(C));function D(S){if(S)return B(S);I(D)}D()}var Ya=function(C,y,B,I){I=I||ft;var D=E(B);Ti(C,y,function(S,O){D(S,function(N,W){return N?O(N):O(null,{key:W,val:S})})},function(S,O){for(var N={},W=Object.prototype.hasOwnProperty,J=0;J<O.length;J++)if(O[J]){var Z=O[J].key,tt=O[J].val;W.call(N,Z)?N[Z].push(tt):N[Z]=[tt]}return I(S,N)})},e7=ie(Ya,1/0),n7=ie(Ya,1),o7=G9("log");function Ja(C,y,B,I){I=Fo(I||ft);var D={},S=E(B);Br(C,y,function(O,N,W){S(O,N,function(J,Z){if(J)return W(J);D[N]=Z,W()})},function(O){I(O,D)})}var r7=ie(Ja,1/0),i7=ie(Ja,1);function s7(C,y){return y in C}function l7(C,y){var B=Object.create(null),I=Object.create(null);y=y||Cl;var D=E(C),S=i(function(N,W){var J=y.apply(null,N);s7(B,J)?m(function(){W.apply(null,B[J])}):s7(I,J)?I[J].push(W):(I[J]=[W],D.apply(null,N.concat(function(){var Z=o(arguments);B[J]=Z;var tt=I[J];delete I[J];for(var It=0,he=tt.length;It<he;It++)tt[It].apply(null,Z)})))});return S.memo=B,S.unmemoized=C,S}var Ka;c?Ka=process.nextTick:l?Ka=setImmediate:Ka=a;var c7=d(Ka);function sm(C,y,B){B=B||ft;var I=ml(y)?[]:{};C(y,function(D,S,O){E(D)(function(N,W){arguments.length>2&&(W=o(arguments,1)),I[S]=W,O(N)})},function(D){B(D,I)})}function a7(C,y){sm(Ho,C,y)}function u7(C,y,B){sm($a(y),C,B)}var lm=function(C,y){var B=E(C);return H9(function(I,D){B(I[0],D)},y,1)},d7=function(C,y){var B=lm(C,y);return B.push=function(I,D,S){if(S==null&&(S=ft),typeof S!="function")throw new Error("task callback must be a function");if(B.started=!0,pn(I)||(I=[I]),I.length===0)return m(function(){B.drain()});D=D||0;for(var O=B._tasks.head;O&&D>=O.priority;)O=O.next;for(var N=0,W=I.length;N<W;N++){var J={data:I[N],priority:D,callback:S};O?B._tasks.insertBefore(O,J):B._tasks.push(J)}m(B.process)},delete B.unshift,B};function h7(C,y){if(y=Fo(y||ft),!pn(C))return y(new TypeError("First argument to race must be an array of functions"));if(!C.length)return y();for(var B=0,I=C.length;B<I;B++)E(C[B])(y)}function Xa(C,y,B,I){var D=o(C).reverse();jo(D,y,B,I)}function tu(C){var y=E(C);return i(function(I,D){return I.push(function(O,N){if(O)D(null,{error:O});else{var W;arguments.length<=2?W=N:W=o(arguments,1),D(null,{value:W})}}),y.apply(this,I)})}function f7(C){var y;return pn(C)?y=Si(C,tu):(y={},pl(C,function(B,I){y[I]=tu.call(this,B)})),y}function m7(C,y,B,I){im(C,y,function(D,S){B(D,function(O,N){S(O,!N)})},I)}var g7=Ii(m7),cm=xi(m7),p7=ie(cm,1);function C7(C){return function(){return C}}function eu(C,y,B){var I=5,D=0,S={times:I,intervalFunc:C7(D)};function O(Z,tt){if(typeof tt=="object")Z.times=+tt.times||I,Z.intervalFunc=typeof tt.interval=="function"?tt.interval:C7(+tt.interval||D),Z.errorFilter=tt.errorFilter;else if(typeof tt=="number"||typeof tt=="string")Z.times=+tt||I;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof C=="function"?(B=y||ft,y=C):(O(S,C),B=B||ft),typeof y!="function")throw new Error("Invalid arguments for async.retry");var N=E(y),W=1;function J(){N(function(Z){Z&&W++<S.times&&(typeof S.errorFilter!="function"||S.errorFilter(Z))?setTimeout(J,S.intervalFunc(W)):B.apply(null,arguments)})}J()}var A7=function(C,y){y||(y=C,C=null);var B=E(y);return i(function(I,D){function S(O){B.apply(null,I.concat(O))}C?eu(C,S,D):eu(S,D)})};function b7(C,y){sm(Di,C,y)}var nu=Ii(Li(Boolean,Cl)),wl=xi(Li(Boolean,Cl)),ou=ie(wl,1);function v7(C,y,B){var I=E(y);_a(C,function(S,O){I(S,function(N,W){if(N)return O(N);O(null,{value:S,criteria:W})})},function(S,O){if(S)return B(S);B(null,Si(O.sort(D),X9("value")))});function D(S,O){var N=S.criteria,W=O.criteria;return N<W?-1:N>W?1:0}}function y7(C,y,B){var I=E(C);return i(function(D,S){var O=!1,N;function W(){var J=C.name||"anonymous",Z=new Error('Callback function "'+J+'" timed out.');Z.code="ETIMEDOUT",B&&(Z.info=B),O=!0,S(Z)}D.push(function(){O||(S.apply(null,arguments),clearTimeout(N))}),N=setTimeout(W,y),I.apply(null,D)})}var Ez=Math.ceil,Iz=Math.max;function xz(C,y,B,I){for(var D=-1,S=Iz(Ez((y-C)/(B||1)),0),O=Array(S);S--;)O[I?S:++D]=C,C+=B;return O}function ru(C,y,B,I){var D=E(B);Ti(xz(0,C,1),y,D,I)}var k7=ie(ru,1/0),w7=ie(ru,1);function B7(C,y,B,I){arguments.length<=3&&(I=B,B=y,y=pn(C)?[]:{}),I=Fo(I||ft);var D=E(B);Ho(C,function(S,O,N){D(y,S,O,N)},function(S){I(S,y)})}function E7(C,y){var B=null,I;y=y||ft,vl(C,function(D,S){E(D)(function(O,N){arguments.length>2?I=o(arguments,1):I=N,B=O,S(!O)})},function(){y(B,I)})}function I7(C){return function(){return(C.unmemoized||C).apply(null,arguments)}}function am(C,y,B){B=Pn(B||ft);var I=E(y);if(!C())return B(null);var D=function(S){if(S)return B(S);if(C())return I(D);var O=o(arguments,1);B.apply(null,[null].concat(O))};I(D)}function x7(C,y,B){am(function(){return!C.apply(this,arguments)},y,B)}var T7=function(C,y){if(y=Fo(y||ft),!pn(C))return y(new Error("First argument to waterfall must be an array of functions"));if(!C.length)return y();var B=0;function I(S){var O=E(C[B++]);S.push(Pn(D)),O.apply(null,S)}function D(S){if(S||B===C.length)return y.apply(null,arguments);I(o(arguments,1))}I([])},Tz={apply:r,applyEach:x9,applyEachSeries:T9,asyncify:p,auto:Kf,autoInject:_9,cargo:j9,compose:z9,concat:U9,concatLimit:ja,concatSeries:V9,constant:q9,detect:za,detectLimit:Al,detectSeries:Ua,dir:Z9,doDuring:Q9,doUntil:Y9,doWhilst:om,during:J9,each:Va,eachLimit:bl,eachOf:Ho,eachOfLimit:Br,eachOfSeries:Di,eachSeries:vl,ensureAsync:rm,every:Wa,everyLimit:yl,everySeries:Ga,filter:Za,filterLimit:kl,filterSeries:Qa,forever:t7,groupBy:e7,groupByLimit:Ya,groupBySeries:n7,log:o7,map:_a,mapLimit:Ti,mapSeries:Jf,mapValues:r7,mapValuesLimit:Ja,mapValuesSeries:i7,memoize:l7,nextTick:c7,parallel:a7,parallelLimit:u7,priorityQueue:d7,queue:lm,race:h7,reduce:jo,reduceRight:Xa,reflect:tu,reflectAll:f7,reject:g7,rejectLimit:cm,rejectSeries:p7,retry:eu,retryable:A7,seq:nm,series:b7,setImmediate:m,some:nu,someLimit:wl,someSeries:ou,sortBy:v7,timeout:y7,times:k7,timesLimit:ru,timesSeries:w7,transform:B7,tryEach:E7,unmemoize:I7,until:x7,waterfall:T7,whilst:am,all:Wa,allLimit:yl,allSeries:Ga,any:nu,anyLimit:wl,anySeries:ou,find:za,findLimit:Al,findSeries:Ua,forEach:Va,forEachSeries:vl,forEachLimit:bl,forEachOf:Ho,forEachOfSeries:Di,forEachOfLimit:Br,inject:jo,foldl:jo,foldr:Xa,select:Za,selectLimit:kl,selectSeries:Qa,wrapSync:p};e.default=Tz,e.apply=r,e.applyEach=x9,e.applyEachSeries=T9,e.asyncify=p,e.auto=Kf,e.autoInject=_9,e.cargo=j9,e.compose=z9,e.concat=U9,e.concatLimit=ja,e.concatSeries=V9,e.constant=q9,e.detect=za,e.detectLimit=Al,e.detectSeries=Ua,e.dir=Z9,e.doDuring=Q9,e.doUntil=Y9,e.doWhilst=om,e.during=J9,e.each=Va,e.eachLimit=bl,e.eachOf=Ho,e.eachOfLimit=Br,e.eachOfSeries=Di,e.eachSeries=vl,e.ensureAsync=rm,e.every=Wa,e.everyLimit=yl,e.everySeries=Ga,e.filter=Za,e.filterLimit=kl,e.filterSeries=Qa,e.forever=t7,e.groupBy=e7,e.groupByLimit=Ya,e.groupBySeries=n7,e.log=o7,e.map=_a,e.mapLimit=Ti,e.mapSeries=Jf,e.mapValues=r7,e.mapValuesLimit=Ja,e.mapValuesSeries=i7,e.memoize=l7,e.nextTick=c7,e.parallel=a7,e.parallelLimit=u7,e.priorityQueue=d7,e.queue=lm,e.race=h7,e.reduce=jo,e.reduceRight=Xa,e.reflect=tu,e.reflectAll=f7,e.reject=g7,e.rejectLimit=cm,e.rejectSeries=p7,e.retry=eu,e.retryable=A7,e.seq=nm,e.series=b7,e.setImmediate=m,e.some=nu,e.someLimit=wl,e.someSeries=ou,e.sortBy=v7,e.timeout=y7,e.times=k7,e.timesLimit=ru,e.timesSeries=w7,e.transform=B7,e.tryEach=E7,e.unmemoize=I7,e.until=x7,e.waterfall=T7,e.whilst=am,e.all=Wa,e.allLimit=yl,e.allSeries=Ga,e.any=nu,e.anyLimit=wl,e.anySeries=ou,e.find=za,e.findLimit=Al,e.findSeries=Ua,e.forEach=Va,e.forEachSeries=vl,e.forEachLimit=bl,e.forEachOf=Ho,e.forEachOfSeries=Di,e.forEachOfLimit=Br,e.inject=jo,e.foldl=jo,e.foldr=Xa,e.select=Za,e.selectLimit=kl,e.selectSeries=Qa,e.wrapSync=p,Object.defineProperty(e,"__esModule",{value:!0})})})(oh,oh.exports);var _2={exports:{}},rh=_2.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),o=2;e===1/0;o*=2)e=Math.log(Math.pow(2,n/o))/Math.log(t)*o;for(var r=e-Math.floor(e),i="",o=0;o<Math.floor(e);o++){var s=Math.floor(Math.random()*t).toString(t);i=s+i}if(r){var l=Math.pow(t,r),s=Math.floor(Math.random()*l).toString(t);i=s+i}var c=parseInt(i,t);return c!==1/0&&c>=Math.pow(2,n)?rh(n,t):i};rh.rack=function(n,t,e){var o=function(i){var s=0;do{if(s++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=rh(n,t)}while(Object.hasOwnProperty.call(r,l));return r[l]=i,l},r=o.hats={};return o.get=function(i){return o.hats[i]},o.set=function(i,s){return o.hats[i]=s,o},o.bits=n||128,o.base=t||16,o};var F2=ko,yk=P2,kk=$2,Ic=ln,ih=oh.exports,wk=_2.exports,H2=lr.ACTIONS,j2=Ht;function Ht(n,t){if(F2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}F2.mixin(Ht),Ht.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Ht.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Ht.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||wk();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},Ht.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(o){if(o)return t._callbackOrEmit(o,n);var r=Object.keys(t._remotePresenceInstances);ih.parallel([function(i){ih.each(e,function(s,l){t.localPresences[s].destroy(l)},i)},function(i){if(!t._wantsDestroy)return i();ih.each(r,function(s,l){t._remotePresenceInstances[s].destroy(l)},i)}],function(i){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(i,n)})})},Ht.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?H2.presenceSubscribe:H2.presenceUnsubscribe,o=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[o]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,o,this)},Ht.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Ht.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Ht.prototype._receiveUpdate=function(n,t){var e=Ic.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var o=this,r=Ic.digOrCreate(this._remotePresenceInstances,t.id,function(){return o._createRemotePresence(t.id)});r.receiveUpdate(t)},Ht.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Ht.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},Ht.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Ht.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Ht.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var o=this;this.subscribe(function(r){o._callEachOrEmit(n,r)})},Ht.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},Ht.prototype._callbackOrEmit=function(n,t){if(t)return Ic.nextTick(t,n);n&&this.emit("error",n)},Ht.prototype._createLocalPresence=function(n){return new yk(this,n)},Ht.prototype._createRemotePresence=function(n){return new kk(this,n)},Ht.prototype._callEachOrEmit=function(n,t){var e=Ic.callEach(n,t);!e&&t&&this.emit("error",t)};var As=P2,z2=yc,Bk=ln,U2=z2.CODES,Ek=an;function an(n,t){As.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}an.prototype=Object.create(As.prototype),an.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:U2.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,As.prototype.submit.call(this,n,t)},an.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createOrDelHandler),this._doc.removeListener("del",this._createOrDelHandler),this._doc.removeListener("load",this._loadHandler),this._doc.removeListener("destroy",this._destroyHandler),As.prototype.destroy.call(this,n)},an.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},an.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createOrDelHandler),this._doc.on("del",this._createOrDelHandler),this._doc.on("load",this._loadHandler),this._doc.on("destroy",this._destroyHandler)},an.prototype._transformAgainstOp=function(n,t){var e=this,o=this._doc._dataStateVersion;this._pendingMessages.forEach(function(r){var i=e._docDataVersionByPresenceVersion[r.pv];if(!(i>=o))try{r.p=e._transformPresence(r.p,n,t),e._docDataVersionByPresenceVersion[r.pv]=o}catch(l){var s=e._getCallback(r.pv);e._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,t)}catch(r){this.emit("error",r)}},an.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},an.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},an.prototype._message=function(){var n=As.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},an.prototype._transformPresence=function(n,t,e){var o=this._doc.type;if(!Bk.supportsPresence(o))throw new z2(U2.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+o.name);return o.transformPresence(n,t,e)};var V2={};(function(n){var t=gs,e=yc,o=ln,r=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(r.ERR_OT_OP_BADLY_FORMED,"Missing create type");var a=t.map[c];if(a==null||typeof a!="object")return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(r.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(r.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(r.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(r.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(r.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(r.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(r.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(r.ERR_DOC_ALREADY_CREATED,"Document already exists");var a=c.create,d=t.map[a.type];if(!d)return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.create(a.data),l.type=d.uri,l.v++}catch(m){return m}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var f=i(l,c.op);if(f)return f;l.v++}else l.v++};function i(l,c){if(!l.type)return new e(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(r.ERR_OT_OP_NOT_PROVIDED,"Missing op");var a=t.map[l.type];if(!a)return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=a.apply(l.data,c)}catch(d){return new e(r.ERR_OT_OP_NOT_APPLIED,d.message)}}n.transform=function(l,c,a){if(c.v!=null&&c.v!==a.v)return new e(r.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(a.del){if(c.create||"op"in c)return new e(r.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(a.create&&("op"in c||c.create||c.del)||"op"in a&&c.create)return new e(r.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in a&&"op"in c){if(!l)return new e(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,a.op,"left")}catch(d){return d}}}c.v!=null&&c.v++},n.applyOps=function(l,c,a){a=a||{};for(var d=0;d<c.length;d++){var f=c[d];if(a._normalizeLegacyJson0Ops)try{s(l,f)}catch{return new e(r.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=f.v;var m=n.apply(l,f);if(m)return m}},n.transformPresence=function(l,c,a){var d=this.checkOp(c);if(d)return d;var f=l.t;if(typeof f=="string"&&(f=t.map[f]),!f)return{code:r.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!o.supportsPresence(f))return{code:r.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:f.transformPresence(l.p,c.op,a)}catch(m){return{code:r.ERR_PRESENCE_TRANSFORM_FAILED,message:m.message||m}}l.v++};function s(l,c){if(l.type===t.defaultType.uri){var a=c.op;if(!!a){var d=l.data;a.length>1&&(d=o.clone(d));for(var f=0;f<a.length;f++){var m=a[f];typeof m.lm=="string"&&(m.lm=+m.lm);for(var p=m.p,A=d,k=0;k<p.length;k++){var v=p[k];Object.prototype.toString.call(A)=="[object Array]"?p[k]=+v:A.constructor===Object&&(p[k]=v.toString()),A=A[v]}f<a.length-1&&(d=t.defaultType.apply(d,[m]))}}}}})(V2);var bs=$2,Ik=V2,xk=Fe;function Fe(n,t){bs.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}Fe.prototype=Object.create(bs.prototype),Fe.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},Fe.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createDelHandler),this._doc.removeListener("del",this._createDelHandler),this._doc.removeListener("load",this._loadHandler),bs.prototype.destroy.call(this,n)},Fe.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createDelHandler),this._doc.on("del",this._createDelHandler),this._doc.on("load",this._loadHandler)},Fe.prototype._setPendingPresence=function(){if(!this._pendingSetPending){this._pendingSetPending=!0;var n=this;this._doc.whenNothingPending(function(){if(n._pendingSetPending=!1,!!n._pending){if(n._pending.pv<n.presenceVersion)return n._pending=null;if(n._pending.v>n._doc.version)return n._doc.fetch();!n._catchUpStalePresence()||(n.value=n._pending.p,n.presenceVersion=n._pending.pv,n._pending=null,n.presence._updateRemotePresence(n))}})}},Fe.prototype._handleOp=function(n,t,e){var o=e===this.src;this._transformAgainstOp(n,o),this._cacheOp(n,o),this._setPendingPresence()},bs.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},bs.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},Fe.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},Fe.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):Ik.transformPresence(this._pending,t,e)}var o=this._pending.v>=this._doc.version;return o&&this._stopCachingOps(),o},Fe.prototype._startCachingOps=function(){this._opCache=[]},Fe.prototype._stopCachingOps=function(){this._opCache=null},Fe.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var q2=j2,Tk=Ek,Sk=xk;function Vr(n,t,e){var o=Vr.channel(t,e);q2.call(this,n,o),this.collection=t,this.id=e}var Dk=Vr;Vr.prototype=Object.create(q2.prototype),Vr.channel=function(n,t){return n+"."+t},Vr.prototype._createLocalPresence=function(n){return new Tk(this,n)},Vr.prototype._createRemotePresence=function(n){return new Sk(this,n)};var Lk=Mk;function Mk(n,t,e,o,r){this.id=n,this.v=t,this.type=e,this.data=o,this.m=r}var Rk=Lk,W2=ko,G2=vs;function vs(n,t,e,o,r){if(W2.EventEmitter.call(this),typeof r!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=o,this.collection=e,this.callback=r,this.sent=!1}W2.mixin(vs),vs.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},vs.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},vs.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,o=new Rk(this.id,t.v,t.type,t.data,e);this.callback(null,o)};var Z2=G2,Ok=ln,Nk=lr.ACTIONS,Pk=sh;function sh(n,t,e,o,r,i){if(Z2.call(this,n,t,e,o,i),!Ok.isValidVersion(r))throw new Error("Snapshot version must be a positive integer or null");this.version=r}sh.prototype=Object.create(Z2.prototype),sh.prototype._message=function(){return{a:Nk.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var Q2=G2,$k=ln,_k=lr.ACTIONS,Fk=lh;function lh(n,t,e,o,r,i){if(Q2.call(this,n,t,e,o,i),!$k.isValidTimestamp(r))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=r}lh.prototype=Object.create(Q2.prototype),lh.prototype._message=function(){return{a:_k.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var Hk=hk,jk=Ck,zk=j2,Y2=Dk,Uk=Pk,Vk=Fk,J2=ko,qr=yc,At=lr.ACTIONS,K2=gs,un=ln,ys=x2,ks=qr.CODES;function X2(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var qk=X;function X(n){J2.EventEmitter.call(this),this.collections={},this.nextQueryId=1,this.nextSnapshotRequestId=1,this.queries={},this._presences={},this._snapshotRequests={},this.seq=1,this._presenceSeq=1,this.id=null,this.agent=null,this.debug=!1,this.state=X2(n),this.bindToSocket(n)}J2.mixin(X),X.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=X2(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(o){try{var r=typeof o.data=="string"?JSON.parse(o.data):o.data}catch{ys.warn("Failed to parse message",o);return}e.debug&&ys.info("RECV",JSON.stringify(r));var i={data:r};if(e.emit("receive",i),!!i.data)try{e.handleMessage(i.data)}catch(s){un.nextTick(function(){e.emit("error",s)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(o){e.emit("connection error",o)},n.onclose=function(o){o==="closed"||o==="Closed"?e._setState("closed",o):o==="stopped"||o==="Stopped by server"?e._setState("stopped",o):e._setState("disconnected",o)}},X.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=t5(n.error,n),delete n.error),n.a){case At.initLegacy:return this._handleLegacyInit(n);case At.handshake:return this._handleHandshake(t,n);case At.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case At.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case At.queryUnsubscribe:return;case At.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case At.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case At.bulkSubscribe:case At.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case At.snapshotFetch:case At.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case At.fetch:var o=this.getExisting(n.c,n.d);o&&o._handleFetch(t,n.data);return;case At.subscribe:case At.unsubscribe:var o=this.getExisting(n.c,n.d);o&&o._handleSubscribe(t,n.data);return;case At.op:var o=this.getExisting(n.c,n.d);o&&o._handleOp(t,n);return;case At.presence:return this._handlePresence(t,n);case At.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case At.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case At.presenceRequest:return this._handlePresenceRequest(t,n);case At.pingPong:return this._handlePingPong(t);default:ys.warn("Ignoring unrecognized message",n)}};function t5(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}X.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var o in t.data){var r=t.data[o],i=this.getExisting(t.c,o);i&&(n?i[e](n):r.error?i[e](t5(r.error)):i[e](null,r))}else if(Array.isArray(t.b))for(var s=0;s<t.b.length;s++){var o=t.b[s],i=this.getExisting(t.c,o);i&&i[e](n)}else if(t.b)for(var o in t.b){var i=this.getExisting(t.c,o);i&&i[e](n)}else ys.error("Invalid bulk message",t)},X.prototype._reset=function(){this.agent=null},X.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new qr(ks.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var o in this.queries){var r=this.queries[o];r._onConnectionStateChanged()}for(var i in this.collections){var s=this.collections[i];for(var o in s)s[o]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var o in this._snapshotRequests){var c=this._snapshotRequests[o];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},X.prototype.startBulk=function(){this.bulk||(this.bulk={})},X.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},X.prototype._sendBulk=function(n,t,e){if(!!e){var o=[],r={},i=0,s;for(var l in e){var c=e[l];c==null?o.push(l):(r[l]=c,s=l,i++)}if(o.length===1){var l=o[0];this.send({a:n,c:t,d:l})}else o.length&&this.send({a:"b"+n,c:t,b:o});if(i===1){var a=r[s];this.send({a:n,c:t,d:s,v:a})}else i&&this.send({a:"b"+n,c:t,b:r})}},X.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var o=this.bulk[t.collection]||(this.bulk[t.collection]={}),r=o[n]||(o[n]={}),i=r.hasOwnProperty(t.id);return r[t.id]=e,i}else{var s={a:n,c:t.collection,d:t.id,v:e};this.send(s)}},X.prototype.sendFetch=function(n){return this._sendActions(At.fetch,n,n.version)},X.prototype.sendSubscribe=function(n){return this._sendActions(At.subscribe,n,n.version)},X.prototype.sendUnsubscribe=function(n){return this._sendActions(At.unsubscribe,n)},X.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:At.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},X.prototype.send=function(n){this.debug&&ys.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},X.prototype.ping=function(){if(!this.canSend)throw new qr(ks.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:At.pingPong};this.send(n)},X.prototype.close=function(){this.socket.close()},X.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},X.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),o=e[t];return o||(o=e[t]=new Hk(this,n,t),this.emit("doc",o)),o._wantsDestroy=!1,o},X.prototype._destroyDoc=function(n){!n._wantsDestroy||(un.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},X.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},X.prototype._createQuery=function(n,t,e,o,r){var i=this.nextQueryId++,s=new jk(n,this,i,t,e,o,r);return this.queries[i]=s,s.send(),s},X.prototype._destroyQuery=function(n){delete this.queries[n.id]},X.prototype.createFetchQuery=function(n,t,e,o){return this._createQuery(At.queryFetch,n,t,e,o)},X.prototype.createSubscribeQuery=function(n,t,e,o){return this._createQuery(At.querySubscribe,n,t,e,o)},X.prototype.hasPending=function(){return!!(this._firstDoc(xc)||this._firstQuery(xc)||this._firstSnapshotRequest())};function xc(n){return n.hasPending()}X.prototype.hasWritePending=function(){return!!this._firstDoc(Wk)};function Wk(n){return n.hasWritePending()}X.prototype.whenNothingPending=function(n){var t=this._firstDoc(xc);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(xc);if(e){e.once("ready",this._nothingPendingRetry(n));return}var o=this._firstSnapshotRequest();if(o){o.once("ready",this._nothingPendingRetry(n));return}un.nextTick(n)},X.prototype._nothingPendingRetry=function(n){var t=this;return function(){un.nextTick(function(){t.whenNothingPending(n)})}},X.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var o in e){var r=e[o];if(n(r))return r}}},X.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},X.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},X.prototype.fetchSnapshot=function(n,t,e,o){typeof e=="function"&&(o=e,e=null);var r=this.nextSnapshotRequestId++,i=new Uk(this,r,n,t,e,o);this._snapshotRequests[i.requestId]=i,i.send()},X.prototype.fetchSnapshotByTimestamp=function(n,t,e,o){typeof e=="function"&&(o=e,e=null);var r=this.nextSnapshotRequestId++,i=new Vk(this,r,n,t,e,o);this._snapshotRequests[i.requestId]=i,i.send()},X.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},X.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},X.prototype._initializeHandshake=function(){this.send({a:At.handshake,id:this.id})},X.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},X.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},X.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new qr(ks.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(K2.map[n.type]!==K2.defaultType)return this.emit("error",new qr(ks.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new qr(ks.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},X.prototype.getPresence=function(n){var t=this,e=un.digOrCreate(this._presences,n,function(){return new zk(t,n)});return e._wantsDestroy=!1,e},X.prototype.getDocPresence=function(n,t){var e=Y2.channel(n,t),o=this,r=un.digOrCreate(this._presences,e,function(){return new Y2(o,n,t)});return r._wantsDestroy=!1,r},X.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var o={a:n,ch:e.channel,seq:t};return this.send(o),o.seq},X.prototype._addPresence=function(n){un.digOrCreate(this._presences,n.channel,function(){return n})},X.prototype._handlePresenceSubscribe=function(n,t){var e=un.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},X.prototype._handlePresenceUnsubscribe=function(n,t){var e=un.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},X.prototype._handlePresence=function(n,t){var e=un.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},X.prototype._handlePresenceRequest=function(n,t){var e=un.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var e5=qk,Gk=gs;const Tc={err:1001,msg:"user auth error",name:"AuthError"},Zk={err:1002,msg:"you don't have required permission",name:"PermissionError"},ch={err:1003,msg:"Too many user connected",name:"MaxUserError"},ws={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},Qk={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},Yk={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},Bs="x-live-editor-token",Sc="x-live-editor-base-url",pe=w("auth-connection");function Jk(n){try{n()}catch(t){pe.error(t)}}class Kk{constructor(t,e){h(this,"connection");h(this,"ws");h(this,"retryCount");h(this,"events",new hm.EventEmitter);h(this,"token",null);h(this,"resourceToken",null);this.url=t,this.reauthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return Zo(this.getBaseURL())}async auth(t){u(pe,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,o=await window.fetch(e,{method:"GET",headers:{[Bs]:t.token,[Sc]:this.getBase64BaseURL()},credentials:"include"});if(o.status!==200)throw new Error("http auth error");return this.token=t.token,await o.json()}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[Sc]:Zo(this.getBaseURL())}})}async init(t){const e=await this.auth(t);this.resourceToken=e.read,this.ws=new n8.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(e5.prototype),u(pe,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})};const o=this.connection.handleMessage.bind(this.connection);this.connection.handleMessage=r=>{var s;const i=r;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in i||i.a==="pong")this.handleMessage(i);else{Object.prototype.hasOwnProperty.call(i,"a")&&i.a!=="init"&&i.a!=="hs"&&(this.retryCount=0);try{o(i)}catch(l){if((l==null?void 0:l.type)==="writeConflict"){this.emitWriteConflictError(l,i);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l,i);return}throw l}}},e5.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reauthFunc&&this.retryCount<5){this.retryCount+=1,pe.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const t=await this.reauthFunc();await this.auth(t),this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})}}}catch(t){pe.error(t),setTimeout(()=>this.handleAuthError(),0)}}else pe.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const t=new Error(Tc.msg);t.code=Tc.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(ws.msg);t.code=ws.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t,e){t.orgMsg=e,this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const o=e.err;if(o===Tc.err)pe.warn("auth error"),this.handleAuthError();else if(o===ch.err)pe.warn(ch.msg),this.emitMaxUsersError();else if(o===ws.err){pe.warn(ws.msg);try{this.emitRequestReloadError()}catch(r){pe.error(`error occurred while process reload error: ${JSON.stringify(r)}`)}finally{this.end(!1)}}else pe.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError()}get(t,e){return u(pe,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(u(pe,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){u(pe,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){u(pe,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e;this.reauthFunc=void 0,this.events.removeAllListeners(),Jk(()=>{var o;return(o=this.connection)==null?void 0:o.close()}),this.connection=void 0,(e=this.ws)==null||e.close(),this.ws=void 0,t&&this.logout()}}w("utils/file");function Xk(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}Xk();async function tw(n){const e=n.size,o=Math.floor((e+102400-1)/102400),r=new o8.Hash;for(let s=0;s<o;s++){const l=s*102400;let c=l+102400;c>e&&(c=e);const d=await n.slice(l,c,n.type).arrayBuffer();r.update(new Uint8Array(d))}const i=r.digest();return Zo(i)}const xn=w("sharedb-doc/client");class ew{constructor(t,e,o){h(this,"connection");h(this,"auth");h(this,"doc",null);h(this,"reauthFunc");h(this,"clientId",P());h(this,"getDoc",async()=>{const t=o=>new Promise((r,i)=>{o.fetch(s=>{s?i(s):r()})});u(xn,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),xn.debug(e),e});this.auth=t;const r=`${e}/${this.auth.appId}/${this.auth.docId}`;Gk.register(Il.type),this.connection=new Kk(r,o),this.reauthFunc=o}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return u(xn,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,o=>{(t==="error"||this.doc)&&e(o)})}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,o,r,i){try{const s=`${t}/${e}`,l=await this.request(s,{method:"post",headers:{...i},data:{name:o,size:r}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const o=`${this.apiServer()}/resources`;let r=[];t.forEach(l=>{const c=l.split("|");r.push(...c)}),r=Array.from(new Set(r));const i=r.map(l=>this.getFileUrlByHash(o,l,"",0,{[Bs]:this.connection.token}));return await Promise.all(i)}async uploadFile(t,e,o,r,i){let s=e.size;if(s===0)throw new Error("file is empty");s+=500;const l=p=>{xn.info(`on progress: ${p.loaded}`);let A=p.loaded*100/s;A>100&&(A=100),r(A)},c=await tw(e),a=await this.getFileUrlByHash(t,c,e.name,e.size,o);if(a)return r(-1),a;let d=t;i!=null&&i.thumbnail&&(d+="/thumbnail");const f=new FormData;f.append("file-size",`${e.size}`),f.append("file-hash",c),f.append("file",e,e.name);const m=await this.request(d,{method:"post",data:f,withCredentials:!0,headers:{...o},onUploadProgress:l});return xn.info(m),r(100),Array.isArray(m.data)?m.data[0]:m.data}async uploadResource(t,e=()=>{},o){const i=`${this.apiServer()}/resources`;u(xn,this.connection.token,"no connection token");const s=await this.uploadFile(i,t,{[Bs]:this.connection.token},e,o);return u(xn,s,"no result"),s}async request(t,e){var i,s;let o=this.connection.token,r;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),u(xn,o,"no token"),c.headers={...c.headers,[Bs]:o,[Sc]:this.connection.getBase64BaseURL()};try{return await t8.default(t,c)}catch(a){if(r=a,((i=a==null?void 0:a.response)==null?void 0:i.status)===403&&this.reauthFunc){const d=await this.reauthFunc();if(await this.connection.auth(d),!d.token)throw a;o=d.token;continue}throw(s=a.response)!=null&&s.data&&(a.responseData=a.response.data),a}}throw u(xn,r,"no error"),r}async getVersions(){const e=`${this.apiServer()}/versions`,o=await this.request(e),r=o.data.versions,i=o.data.latest;return i&&r.findIndex(s=>s.version===i)===-1&&r.unshift({version:-1,tag:"",published:!1}),r}async getVersion(t){const o=`${this.apiServer()}/versions/${t}`,r=await this.request(o);return JSON.parse(r.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,o=await this.request(e);return JSON.parse(o.data.data)}async getVersionOps(t,e){let r=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(r+=`&from=${e}`);const i=await this.request(r),s=i.data.ops,l=e8.default(s,d=>!!d.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let a;return c?(u(xn,c.create,"no createDoc.create"),a=c.create.data):a=JSON.parse(i.data.data),a.blocks||(a.blocks=[]),{doc:a,ops:i.data.ops}}async revertVersion(t){const o=`${this.apiServer()}/versions/revert/${t}`;await this.request(o,{method:"post",data:{}})}async createVersion(t,e){const r=`${this.apiServer()}/versions`;return(await this.request(r,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const o=`${this.apiServer()}/resources/external/${Zo(t)}`;return(await this.request(o)).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let r=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const i=[];if(e!=null&&e.withToken&&i.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&i.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),i.length>0){const s=i.join("&");r+=`?${s}`}return r}}function nw(){return{blocks:[{id:P(),type:"text",text:[]}],comments:{},meta:{}}}const ah=w("block-ids");class ow{constructor(){h(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((r,i)=>i-r);for(let r=0;r<e.length;r++){const i=e[r];if(i>=t){const s=this.ids.get(i);u(ah,s!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i+1,s)}}const o=P();this.ids.set(t,o)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((o,r)=>o-r);for(let o=0;o<e.length;o++){const r=e[o];if(r>t){const i=this.ids.get(r);u(ah,i!==void 0,"old id is not exists"),this.ids.delete(r),this.ids.set(r-1,i)}}}getId(t){let e=this.ids.get(t);return e||(e=P(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class rw{constructor(){h(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new ow,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let o=0;o<e.length;o++){const r=e[o],i=r[1].getById(t);if(i)return{containerId:r[0],blockIndex:i[0]}}return u(ah,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class n5{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,o)=>{t[o]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const _t=w("op-parser");function Wr(n){return n==="blocks"?"root":n}class iw{constructor(t,e){h(this,"updatingBlockDataDeltaMap",new Map);h(this,"blockIds",new rw);this.handler=t,this.local=e}onDeleteBlock(t,e){const o=this.blockIds.getBlockId(t,e);this.blockIds.onDeleteBlock(t,e);const r=this.updatingBlockDataDeltaMap.get(o);r&&(_t.debug(`ignore update object data before delete block: ${JSON.stringify(r)}`),this.updatingBlockDataDeltaMap.delete(o)),this.handler.onDeleteBlock(Wr(t),e,this.local)}onInsertBlock(t,e,o){this.blockIds.onInsertBlock(t,e),this.handler.onInsertBlock(Wr(t),e,o,this.local)}onUpdateBlockText(t,e,o){this.handler.onUpdateBlockText(Wr(t),e,o,this.local)}onDeleteBlockData(t,e,o){const r=this.blockIds.getBlockId(t,e);let i=this.updatingBlockDataDeltaMap.get(r);i||(i=new n5,this.updatingBlockDataDeltaMap.set(r,i)),i.delete(o)}onInsertBlockData(t,e,o,r){const i=this.blockIds.getBlockId(t,e);let s=this.updatingBlockDataDeltaMap.get(i);s||(s=new n5,this.updatingBlockDataDeltaMap.set(i,s)),s.insert(o,r)}executeUpdateBlockDataActions(){Array.from(this.updatingBlockDataDeltaMap.entries()).forEach(([t,e])=>{const{containerId:o,blockIndex:r}=this.blockIds.getBlockIndexById(t);this.handler.onUpdateBlockData(Wr(o),r,e.toDocBlockDelta(),this.local)})}}class o5{}class uh{constructor(t){h(this,"key");this.key=t}}function sw(n,t,e){const o=t.concat(),r=o[0];if(typeof r!="number"||(o.shift(),o.length===1))return!1;const i=o[0];if(typeof i!="object"||!i.i||Object.keys(i).length!==1)return!1;for(let l=1;l<o.length;l++){const c=o[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const d=c[1];if(typeof d!="object"||d.i===void 0||Object.keys(d).length!==1)return!1}const s=i.i;u(_t,s.id,"block id is required"),u(_t,s.type,"block type is required");for(let l=1;l<o.length;l++){const c=o[l],a=c[0],d=c[1];s[a]=d.i}return e.onInsertBlock(n,r,s),!0}function dh(n,t,e,o){if(e==="upsert"&&sw(n,t,o))return;u(_t,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const r=t.concat(),i=r[0];r.shift();const s=[];for(;r.length>0;){const l=r[0];if(l==="text"){const c=r[1];if(u(_t,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),u(_t,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),r.splice(0,2),e==="upsert"){const d=c.e;o.onUpdateBlockText(n,i,d)}u(_t,r.length===0,`invalid block ops.length !== 0, ${JSON.stringify(r)}`)}else if(Array.isArray(l)){u(_t,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];u(_t,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const a=l[1];if(c==="text"){if(u(_t,typeof a=="object",`invalid opData type, ${JSON.stringify(a)}`),a.i&&e==="upsert"&&o.onInsertBlockData(n,i,c,a.i),a.r&&e==="remove"&&o.onDeleteBlockData(n,i,c),a.et==="rich-text"&&e==="upsert"){const f=a.e;o.onUpdateBlockText(n,i,f)}}else e==="remove"&&a.r&&s.push(new uh(c)),e==="upsert"&&a.i&&o.onInsertBlockData(n,i,c,a.i);r.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&s.push(new o5),e==="upsert"&&c.i&&o.onInsertBlock(n,i,c.i),r.shift()}else{u(_t,typeof l=="string","data is not string"),u(_t,l!=="text","data !== 'text'"),u(_t,r.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(r)}`);const c=l,a=r[1];e==="remove"&&a.r&&s.push(new uh(c)),e==="upsert"&&a.i&&o.onInsertBlockData(n,i,c,a.i),r.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof o5?o.onDeleteBlock(n,i):l instanceof uh?o.onDeleteBlockData(n,i,l.key):u(_t,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function lw(n,t,e,o){_t.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function cw(n,t,e,o){const r=n[1],i=n[2];u(_t,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),u(_t,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?_t.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&o.onUpdateComment(r,e.local):i.i?t==="upsert"&&o.onCreateComment(r,e.local):i.r?t==="remove"&&o.onDeleteComment(r,e.local):_t.error(`unknown comment op, ${JSON.stringify(n)}`)}function hh(n,t,e,o){const r=n[0];if(Array.isArray(r)){r.forEach(l=>{hh(l,t,e,o)});return}const i=r;if(u(_t,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){lw(n);return}if(i==="comments"){cw(n,t,e,o);return}const s=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(l=>{dh(s,l,t,e)}):n.slice(1).forEach(l=>{dh(s,l,t,e)});else if(typeof n[1]=="object"){const l=n[1];l.r&&t==="remove"&&o.onDeleteContainer(Wr(s),e.local),l.i&&t==="upsert"&&o.onCreateContainer(Wr(s),l.i,e.local)}else u(_t,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),dh(s,n.slice(1),t,e)}function r5(n,t,e){const o=new iw(t,e);for(let r=0;r<2;r++){const i=r===0?"remove":"upsert",s=Q.default(n),l=s[0];Array.isArray(l)?s.forEach(c=>{hh(c,i,o,t)}):hh(s,i,o,t)}o.executeUpdateBlockDataActions()}const aw=w("sharedb-comments");function fh(n){if(n.doc)return Q.default(n.doc);const t=n.blocks;u(aw,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([o,r])=>{Array.isArray(r)&&(e.blocks[o]=r)}),Q.default(e)}function i5(n){const{id:t,groupId:e,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:c}=n;return{id:t,groupId:e,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:c}}function mh(n,t){const e={...n,doc:t};return delete e.blocks,Q.default(e)}const yt=w("sharedb-doc/doc-container"),s5="ot-json1";Il.type.registerSubtype(Zy.type),Il.type.name=s5,Il.type.invert=null;class Es extends Pi{constructor(e,o,r=!0){super();h(this,"doc");h(this,"client");h(this,"localPresence");h(this,"remoteCaretHandler",new Wy);h(this,"batching",0);h(this,"status","clean");h(this,"disableLogout");h(this,"destroyed",!1);h(this,"handleNothingPending",()=>{this.setStatus("clean")});h(this,"handleCreate",()=>{this.handleReload("doc created")});h(this,"handleDel",()=>{});h(this,"handleReload",e=>{this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,e)})});h(this,"handleReset",async e=>{const o=new Error(`reset doc: ${e}`);o.code="ResetDoc",this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,o)}),this.destroy()});h(this,"handleWriteConflictError",e=>{this.handleReset(`write conflict: ${e.message}, ${JSON.stringify(e.orgMsg)}`)});h(this,"insertObject",async(e,o,r)=>{const i=[e,o,{i:r}];return this.submitOp(i)});h(this,"deleteObject",async(e,o)=>{const r=[e,o,{r:!0}];return this.submitOp(r)});h(this,"replaceObject",async(e,o,r)=>{const i=[e,o,{r:!0,i:r}];return this.submitOp(i)});h(this,"updateObject",async(e,o,r)=>{const i=this.data()[e][o],s=[e,o];return Object.entries(r).forEach(([l,c])=>{if(!El.default(i[l],c))if(i[l]===void 0){if(c!=null){const a={i:c};s.push([l,a])}}else if(c==null){const a={r:!0};s.push([l,a])}else{const a={r:!0,i:c};s.push([l,a])}}),Object.entries(i).forEach(([l,c])=>{if((r[l]===void 0||r[l]===null)&&c!==void 0){const a={r:!0};s.push([l,a])}}),s.length<=2?Promise.resolve():this.submitOp(s)});h(this,"broadcastMessage",async e=>{const o={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(o)});h(this,"data",()=>this.doc.data);h(this,"submitOp",async e=>new Promise((o,r)=>{if(this.destroyed){yt.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(e,{},i=>{i?(yt.error(`invalid op, ${i.message}, ${JSON.stringify(e)}`),r(i),yt.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):o()}),this.doc.data||(yt.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(e)}`))}));h(this,"createDoc",async e=>new Promise((o,r)=>{this.doc.create(e,s5,i=>{i?r(i):o()})}));h(this,"submitInsertChildContainer",async(e,o)=>{const r=[yo(e),{i:o}];return this.submitOp(r)});h(this,"submitDeleteChildContainer",async e=>{const o=[yo(e),{r:!0}];return this.submitOp(o)});h(this,"submitInsertBlock",async(e,o,r)=>{const i=[yo(e),o,{i:r}];return this.submitOp(i)});h(this,"submitDeleteBlock",async(e,o)=>{const r=[yo(e),o,{r:!0}];return this.submitOp(r)});h(this,"submitUpdateBlockData",async(e,o,r)=>{if(r.delete.length===0&&Object.keys(r.insert).length===0)return Promise.resolve();const i=[yo(e),o],s=new Set(r.delete);Object.entries(r.insert).forEach(([c,a])=>{if(s.has(c)){const d={r:!0,i:a};i.push([c,d])}});const l=new Set(Object.keys(r.insert));return r.delete.forEach(c=>{if(l.has(c))return;const a={r:!0};i.push([c,a])}),Object.entries(r.insert).forEach(([c,a])=>{if(s.has(c))return;const d={i:a};i.push([c,d])}),this.submitOp(i)});h(this,"submitUpdateRichText",async(e,o,r)=>{const i=[yo(e),o,"text",{e:r,et:"rich-text"}];return this.submitOp(i)});h(this,"handleOp",(e,o,r)=>{if(this.destroyed){yt.warn("handleOp: destroyed");return}r5(e,this,!!o)});this.client=e,this.doc=o,this.doc.preventCompose=!0,this.disableLogout=r,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,u(yt,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const o=new ew(e.auth,e.serverUrl,e.reauthFunc),r=await o.getDoc(),i=new Es(o,r,e.disableLogout);if(r.type===null){if(e.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await i.createDoc(e.templateData||nw())}return await i.initPresence(),await i.subscribe(),i.initEvents(),i}catch(o){throw yt.error(o),yt.error(`failed to load doc: ${JSON.stringify(o)}`),o}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onWriteConflictError(this.handleWriteConflictError)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",this.handleDel)}initPresence(){return new Promise((e,o)=>{if(this.localPresence)e();else{const r=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);r.on("receive",(i,s)=>{this.onCustomMessage(s)}),r.subscribe(i=>{i?o(i):(this.localPresence=r.create(P()),e())})}})}subscribe(){return new Promise((e,o)=>{this.doc.subscribe(r=>{r?o(r):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return fs(this.data())}getContainerBlocks(e){const o=this.data();u(yt,o,"no doc data");const r=o[yo(e)];return u(yt,r,`no container data: ${e}`),Q.default(r)}getBlockData(e,o){const r=this.data();u(yt,r,"no doc data");const i=r[yo(e)];u(yt,i,`no container data: ${e}`);const s=i[o];return u(yt,s,`no block data: ${o}`),Q.default(s)}localInsertBlock(e,o,r){return this.submitInsertBlock(e,o,r),this.getBlockData(e,o)}localDeleteBlock(e,o){const r=this.getBlockData(e,o);return this.submitDeleteBlock(e,o),r}localUpdateBlockText(e,o,r){const i=this.getBlockData(e,o);u(yt,i.text,"no block text");const s=Q.default(i.text);this.submitUpdateRichText(e,o,r);const l=ce.apply(s,r);return u(yt,l,"no block text"),l}localUpdateBlockData(e,o,r){const i=Q.default(this.getBlockData(e,o));return this.submitUpdateBlockData(e,o,r),i}localInsertChildContainer(e,o){this.submitInsertChildContainer(e,o)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(o=>{this.submitDeleteChildContainer(o)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(o=>i5(o))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const o=this.data().comments[e];return fh(o)}localCreateComment(e,o){const r=mh(e,o),s=["comments",r.id,{i:r}];return this.submitOp(s)}localDeleteComment(e){const o=["comments",e,{r:!0}];return this.submitOp(o)}localUpdateComment(e,o){const r=mh(e,o),i=["comments",e.id,{r:!0,i:r}];return this.submitOp(i)}destroy(){var e;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(e,o,r){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteBlock)==null?void 0:s.call(i,Ur(e),o,r)})}onInsertBlock(e,o,r,i){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,Ur(e),o,r,i)})}onUpdateBlockData(e,o,r,i){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,Ur(e),o,r,i)})}onUpdateBlockText(e,o,r,i){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,Ur(e),o,r,i)})}onDeleteContainer(e,o){u(yt,this.callbacks.length>0,"no callbacks"),u(yt,e!=="root","should not delete root container in doc"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,Ur(e),o)})}onCreateContainer(e,o,r){u(yt,this.callbacks.length>0,"no callbacks"),u(yt,e!=="root","should not create root container in doc"),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,Ur(e),o,r)})}onDeleteComment(e,o){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteComment)==null?void 0:i.call(r,e,o)})}onCreateComment(e,o){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onCreateComment)==null?void 0:i.call(r,e,o)})}onUpdateComment(e,o){u(yt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onUpdateComment)==null?void 0:i.call(r,e,o)})}onCustomMessage(e){const o=e;(o==null?void 0:o.type)==="custom"&&(o==null?void 0:o.clientId)!==this.client.clientId?this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,o.data)}):(o==null?void 0:o.type)==="onlineUsers"&&setTimeout(()=>{const r={type:"custom",data:e,clientId:"-"};this.onCustomMessage(r)})}async addResources(e){return await this.client.getFileUrlsByHashes(e)}async uploadResource(e,o){var i;return{resourceId:await this.client.uploadResource(e,(i=o==null?void 0:o.onProgress)!=null?i:()=>{})}}buildResourceUrl(e,o){return this.client.buildResourceUrl(e,o)}request(e,o){return this.client.request(e,o)}getUser(){const e=this.client.clientId,{permission:o,userId:r,displayName:i,avatarUrl:s}=this.client.auth;return{permission:o,clientId:e,userId:r,displayName:i,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const o=await this.client.getVersion(e);return fs(o)}async getLatestVersion(){const e=await this.client.getLatestVersion();return fs(e)}async getHistoryData(e,o){const{doc:r,ops:i}=await this.client.getVersionOps(e,o),s=i.map(l=>({user:l.meta.createdBy,data:l}));return{doc:fs(r),historyData:s}}async getVersionData(e,o){const{doc:r,ops:i}=await this.client.getVersionOps(e,o);return{doc:fs(r),versionData:i}}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,o){return this.client.createVersion(e,o)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,o){r5(e.data.op,o,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}w("remote-cursor");class l5{constructor(t){h(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});h(this,"broadcastCaretPos",ee.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));h(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const o=this.editor.findBlockById(e);o&&this.editor.reloadBlock(o)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const c5=w("remote-cursor-decorator");class gh{decorateText(t,e,o){const r=t.doc.getRemoteUsers();if(!r)return{};const i=new Map,{containerId:s,blockIndex:l}=e[e.length-1];u(c5,typeof s=="string","invalid path containerId"),u(c5,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(s,l),a=me(o);return r.getSimpleCursors(c.id).forEach((f,m)=>{m>a&&(m=a);const p=f.map(k=>({id:P(),type:"remote-cursor",name:k.user.displayName,time:k.time,rainbowIndex:k.user.rainbowIndex})),A=i.get(m);A?A.push(...p):i.set(m,p)}),{insertions:i}}}class a5 extends Yt.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,o){if(Ct(Pr(this.editor,t)))return;const r=this.editor.getBlockByIndex(t,e),i=U(this.editor.getContainerById(t));i&&this.emit("change",this.editor,i,r,o)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}destroy(){this.editor.doc.unregisterCallback(this)}}function uw(n,t){n.addCustom("child-block-tracker",()=>new a5(n)).addListener("change",t)}function dw(n,t){n.addCustom("child-block-tracker",()=>new a5(n)).removeListener("change",t)}const JU="",hw={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4",name:"\u6587\u672C\u989C\u8272"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},fw={colorPalette:{colorDesc:"Text Color",name:"Text Color",backgroundDesc:"Background Color",reset:"Reset"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}};T.mergeLang({"zh-CN":hw,"en-US":fw});const KU="";w("button");function Bo(n,t,e,o,r){const i=b("button",["editor-button"],null);return i.setAttribute("data-button-id",n),r&&i.setAttribute(`data-editor-tooltip-${r}`,t),e?typeof e=="string"?e.startsWith("<")?i.innerHTML=e:i.innerText=e:i.appendChild(e):i.innerText=t,o&&(o.indexOf("checked")!==-1&&M(i,"checked"),o.indexOf("disabled")!==-1&&(i.disabled=!0)),i}function u5(n,t,e){e?n.setAttribute(`data-editor-tooltip-${e}`,t):n.innerText=t}const XU="",Gr=w("ui-command-bar-base"),mw={itemElementTag:"div",tippyArrow:!1},qf=class extends Yt.TypedEmitter{constructor(e,o,r){var i,s;super();h(this,"content");h(this,"items");h(this,"subBar",null);h(this,"parentItem",null);h(this,"closeable",null);h(this,"options");h(this,"id");h(this,"handleDocumentKeydown",e=>{if(!!this.isVisible&&!e.isComposing){if(this.subBar){this.subBar.handleDocumentKeydown(e);return}if(this.items.length!==0){if(e.key==="Escape"){this.close();return}if(e.key==="ArrowUp"){const o=this.getPrevItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[o].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowDown"){const o=this.getNextItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[o].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowRight"){const o=this.getSelectedItem();o&&o.children&&this.showSubCommandBar(o.childrenMenuId)}else if(e.key==="ArrowLeft")this.parentItem&&this.close();else if(e.key==="Enter"){const o=this.getSelectedItemIndex();if(o===-1)return;const r=this.items[o],i=this.getItemElementById(r.id);i&&this.emit("click",this,r,i)}}}});h(this,"handleDocumentMouseDown",e=>{if(e.target instanceof Element&&!this.isInCommandBar(e.target)){const o=this.listeners("closing");for(let r=0;r<o.length;r++)if(o[r](this,e)===!1)return;this.close()}});h(this,"handleHidden",()=>{this.close(),this.emit("close",this),Wm(this.id)});h(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&M(this.popper,...this.options.classes),this.options.refuseOverflow&&this.popper.classList.add("reference-hidden")),this.emit("show",this),this.options.disablePageScroll&&qm(this.id)});h(this,"lastEnterPauseTime",0);h(this,"startPauseMouseEnter",()=>{this.lastEnterPauseTime=Date.now()});h(this,"handleItemMouseEnter",e=>{if(Date.now()-this.lastEnterPauseTime<100)return;const o=this.getParentCommandItemElement(e.target);if(!o)return;const r=this.getItemElementId(o),i=this.getItemById(r);if(this.selectItem(r),i.manualShowChildren)return;const s=i.childrenMenuId||"";this.showSubCommandBar(s)});h(this,"handleItemMouseLeave",e=>{var r,i;const o=this.getParentCommandItemElement(e.target);!o||((i=(r=this.subBar)==null?void 0:r.parentItem)==null?void 0:i.id)!==this.getItemElementId(o)&&(H(o,"selected"),this.emit("selectionChange",this,""))});h(this,"handleItemClick",e=>{const o=this.getParentCommandItemElement(e.target);if(!o)return;const r=this.getItemElementId(o),i=this.items.find(s=>s.id===r);if(!!i&&!(i.states&&i.states.indexOf("disabled")!==-1)){if(i.children&&i.children.length>0&&i.manualShowChildren){this.showSubCommandBar(i.childrenMenuId);return}i.element||(this.emit("click",this,i,o),this.options.autoClose&&this.close())}});h(this,"handleWheel",e=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const o=e.target;if(!o||!(o instanceof Node))return;const r=o instanceof HTMLElement?o:o.parentElement;if(!r)return;const i=bn(r);if(!wt(this.content,i)){e.stopPropagation(),e.preventDefault();return}e.deltaY<0?i.scrollTop===0&&(e.stopPropagation(),e.preventDefault()):e.deltaY>0&&i.scrollTop+i.clientHeight>=i.scrollHeight&&(e.stopPropagation(),e.preventDefault())});this.id=(i=r==null?void 0:r.id)!=null?i:P(),this.options={...mw,...r},this.items=e,this.parentItem=(s=r==null?void 0:r.parentItem)!=null?s:null,this.closeable=o!=null?o:null,this.content=this.createCommandBarContent(e)}close(){this.subBar&&this.subBar.close(),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(e,o){this.emit("click",this,e,o)}createPopperOptions(){var r;const e={modifiers:[]},o=this.options.overflowBoundary;return o&&((r=e==null?void 0:e.modifiers)==null||r.push({name:"flip",options:{boundary:o,fallbackPlacements:["top","bottom"]}})),e}destroy(){var e;this.close(),this.removeAllListeners(),(e=this.subBar)==null||e.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(e){var r;this.subBar&&e.findIndex(s=>{var l,c;return s.id===((c=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:c.id)})===-1&&((r=this.subBar)==null||r.destroy(),this.subBar=null),this.items=e;const o=this.createCommandBarContent(e);this.content.innerHTML="",Array.from(o.children).forEach(i=>{this.content.appendChild(i)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const e=this.getSelectedItem();return e?this.items.indexOf(e):-1}getPrevItemIndex(e){if(e<=0)return this.items.length-1;let o=e-1;for(;;){const r=this.items[o].type;if(r!=="separator"&&r!=="section")return o;if(o-=1,o<=0)return this.items.length-1}}getNextItemIndex(e){let o=e+1;for(;;){if(!this.items[o])return this.getNextItemIndex(-1);const r=this.items[o].type;if(r!=="separator"&&r!=="section")return o;if(o+=1,o>this.items.length-1)return 0}}clearSelectedItem(){const e=this.getSelectedItem();if(!e)return;const o=this.getItemElementById(e.id);o&&H(o,"selected")}selectItem(e){const o=this.getSelectedItem();if(o){if(o.id===e)return;const i=o.id,s=this.getItemElementById(i);s&&H(s,"selected")}const r=this.getItemElementById(e);r?(M(r,"selected"),this.emit("selectionChange",this,r.getAttribute("data-id")||""),r.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(e){var s,l;const o=this.getSelectedItem();if(!o)return;if(this.subBar){if(((s=this.subBar.parentItem)==null?void 0:s.id)===o.id){o.manualShowChildren&&this.subBar.close();return}this.subBar.destroy(),this.subBar=null}if(!o.children)return;const r=this.getItemElementById(o.id);if(!r)return;const i=qf.createSubCommandBar(o,(l=this.closeable)!=null?l:this,e?{id:e}:{});this.subBar=i,this.subBar.on("click",(c,a,d)=>{this.emit("click",c,a,d)}),this.subBar.on("close",()=>{var c;(c=this.subBar)==null||c.destroy(),this.subBar=null,H(r,"active")}),o.beforePopup&&o.beforePopup(i),this.subBar.manualShow(r,this.getSubBarOptions(o)),M(r,"active")}isInCommandBar(e){if(!e||!(e instanceof Node))return!1;const o=this.getCommandBarRoot();return o&&wt(o,e)||wt(this.content,e)?!0:this.subBar?this.subBar.isInCommandBar(e):!1}createCommandItem(e){var i,s,l,c;let o=(i=this.options.itemElementTag)!=null?i:"div";e.element&&(o="div");const r=b(o,["command-item"],null);return r.setAttribute("data-id",e.id),e.type==="separator"?r.classList.add("separator"):e.type==="section"?(r.classList.add("section","text"),e.element&&(typeof e.element=="function"?r.appendChild(e.element(e)):r.appendChild(e.element))):((s=e.states)!=null&&s.includes("selected")&&r.classList.add("selected"),(l=e.states)!=null&&l.includes("checked")&&r.classList.add("checked"),(c=e.states)!=null&&c.includes("disabled")&&r.classList.add("disabled"),r.onclick=this.handleItemClick,r.onmouseenter=this.handleItemMouseEnter,r.onmouseleave=this.handleItemMouseLeave,e.element?typeof e.element=="function"?r.appendChild(e.element(e)):r.appendChild(e.element):r.classList.add("standard")),this.initItemElement(e,r),r}getItemById(e){const o=this.items.find(r=>r.id===e);return u(Gr,o,`can not find command item for id: ${e}`),o}getSelectedItem(){const e=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(e){const o=this.getItemElementId(e),r=this.items.find(i=>i.id===o);return u(Gr,r,`can not find command item for id: ${o}`),r}return null}getItemElementId(e){const o=e.getAttribute("data-id");return u(Gr,o,"no data-id attribute"),o}getItemElementById(e){const o=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${e}"]`);return u(Gr,o,`no exists command item, id=${e}`),o}getParentCommandItemElement(e){if(!e||!(e instanceof Element))return null;if(rt(e,"command-item"))return e;const o=e.closest(".command-item");return o||null}createCommandBarContent(e){this.content&&this.content.removeEventListener("wheel",this.handleWheel);const o=b("div",["editor-command-bar-root"],null),r=b("div",["editor-command-bar"],o);return e.forEach(i=>{var l;const s=this.createCommandItem(i);r.appendChild(s),i.element&&i.setCloseable&&i.setCloseable((l=this.closeable)!=null?l:this)}),this.initCommandBarElement(r),o.addEventListener("wheel",this.handleWheel,{passive:!1}),o}getSubBarOptions(e){var o;return{placement:(o=e.childrenPlacement)!=null?o:"right-start"}}static registerManualCommandBar(e,o){this.commandBarCreators.set(e,o)}static createSubCommandBar(e,o,r){var l;u(Gr,e.children&&e.children.length>0,"no item children");const i=(l=e.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(i);return u(Gr,s,`no creator for command type: ${i}`),s(e,o,r)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let Zr=qf;h(Zr,"commandBarCreators",new Map),w("ui-command-bar");class Dc extends Zr{constructor(){super(...arguments);h(this,"tippyInstance",null)}manualShow(e,o){var r,i;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=r8.default(e,{interactive:!0,content:this.content,trigger:"manual",triggerTarget:null,hideOnClick:!1,placement:(r=o==null?void 0:o.placement)!=null?r:"bottom-start",maxWidth:650,arrow:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,theme:o==null?void 0:o.theme,getReferenceClientRect:o==null?void 0:o.getReferenceClientRect,offset:(i=o==null?void 0:o.offset)!=null?i:[0,0],popperOptions:this.createPopperOptions()}),o!=null&&o.point){const{x:s,y:l}=o.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(s,l,0,0)})}this.clearSelectedItem(),this.tippyInstance.show(),this.parentItem||(document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)),this.popper&&this.options.id&&this.popper.setAttribute("data-command-bar-id",this.options.id)}}close(){var e;super.close(),this.isVisible&&((e=this.tippyInstance)==null||e.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,o;return(o=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?o:!1}get popper(){return this.content.closest("[data-tippy-root]")}}const d5=w("ui-base");class Is extends Dc{constructor(t,e){var i;const r=[{id:(i=e==null?void 0:e.id)!=null?i:`popup-${P()}`,name:"",element:t}];super(r,void 0,{disablePageScroll:!0})}initCommandBarElement(t){M(t,"popper")}initItemElement(t,e){}get popupContent(){const t=this.items[0];u(d5,t,"no dialog item");const e=typeof t.element=="function"?t.element(t):t.element;return u(d5,e,"no item element"),e}}const Eo=w("filterable-list");function gw(n){var e;const t=b("div",["list-item"],null);return t.setAttribute("data-id",n.id),t.appendChild(b("div",["list-item-text"],null,n.name)),(e=n.states)!=null&&e.includes("selected")&&M(t,"selected"),t}function h5(n){const t=b("div",["list-root"],null);return n.forEach(e=>{t.appendChild(gw(e))}),t}function f5(n,t){let e=n;return t&&(e=n.map(o=>({...o,states:o.id===t?["selected"]:void 0}))),e}function pw(n,t){const e=b("div",["filterable-list"],null),o=b("div",["filter"],e),r=b("div",["filter-container"],o),i=b("input",["filter-input"],r);t&&t.placeholder&&(i.placeholder=t.placeholder);const s=b("div",["list"],e),l=h5(f5(n,t==null?void 0:t.initialSelectedId));return s.appendChild(l),e}function m5(n,t,e){const o=n.querySelector(".list");u(Eo,o,"no list root");const r=h5(f5(t,e)),i=o.querySelector(".list-root");if(u(Eo,i,"no exists menu"),Hi(i,r),e){const s=o.querySelector(".list-item.selected");s&&(u(Eo,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class Cw{constructor(t,e){h(this,"root");h(this,"visibleItems");h(this,"selectedId");h(this,"filter","");h(this,"onSelected",null);h(this,"handleKeydown",t=>{this.processKeyDown(t)});h(this,"handleInputChanged",()=>{const t=this.root.querySelector(".filter-input");u(Eo,t,"no input");const e=t.value.toLocaleLowerCase();this.setFilter(e)});h(this,"handleClick",t=>{this.processClick(t)});var o;this.items=t,this.options=e,this.root=pw(t,e),this.bindEvents(),this.selectedId=(o=e==null?void 0:e.initialSelectedId)!=null?o:"",this.visibleItems=t}bindEvents(){const t=this.root.querySelector(".filter-input");u(Eo,t,"no input"),t.addEventListener("keyup",this.handleInputChanged),t.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const t=this.root.querySelector(".filter-input");u(Eo,t,"no input"),t.removeEventListener("keyup",this.handleInputChanged),t.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(t=>t.id===this.selectedId):-1}setSelectedId(t){this.selectedId=t,m5(this.root,this.visibleItems,t)}focus(){const t=this.root.querySelector(".filter-input");u(Eo,t,"no input"),t.focus()}reset(){this.setFilter("");const t=this.root.querySelector(".filter-input");u(Eo,t,"no input"),t.value=""}setFilter(t){this.filter!==t&&(this.filter=t,this.visibleItems=this.items.filter(e=>e.name.toLocaleLowerCase().includes(t)),m5(this.root,this.visibleItems,this.selectedId))}processClick(t){var s,l;const e=t.target;if(!(e instanceof HTMLElement))return;const o=e.closest(".list-item");if(!o)return;const r=(s=o.getAttribute("data-id"))!=null?s:"",i=(l=this.visibleItems.find(c=>c.id===r))!=null?l:null;this.onSelected&&this.onSelected(this,i)}processKeyDown(t){var e;if(t.key==="ArrowUp"){let o=this.getSelectedIndex();o===-1?o=this.visibleItems.length-1:o>0&&(o-=1);let r="";o!==-1&&(r=this.visibleItems[o].id),this.setSelectedId(r);return}if(t.key==="ArrowDown"){let o=this.getSelectedIndex();o===-1?o=0:o<this.visibleItems.length-1&&(o+=1);let r="";o!==-1&&(r=this.visibleItems[o].id),this.setSelectedId(r);return}if(t.key==="Enter"){const o=(e=this.visibleItems.find(r=>r.id===this.selectedId))!=null?e:null;this.onSelected&&this.onSelected(this,o)}}}class Aw extends Cw{constructor(e,o,r){super(e,r);h(this,"popup");h(this,"onShow",null);h(this,"onHide",null);h(this,"custom",null);h(this,"handleShow",()=>{this.onShow&&this.onShow(this)});h(this,"handleHide",()=>{this.onHide&&this.onHide(this)});h(this,"handleShown",()=>{this.focus()});this.popup=new Is(this.root)}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(e){this.reset(),this.popup.manualShow(e,{theme:"dropdown-list"}),this.focus()}processKeyDown(e){super.processKeyDown(e),(e.key==="Esc"||e.key==="Enter")&&this.popup.close()}processClick(e){super.processClick(e);const o=e.target;!(o instanceof HTMLElement)||!o.closest(".list-item")||this.popup.close()}}const tV="",eV="";function bw(n,t){const e=document.createElement("div");e.classList.add("toast","show"),t!=null&&t.theme&&e.setAttribute("data-theme",t.theme),t!=null&&t.id&&e.setAttribute("data-id",t.id),t!=null&&t.html?e.innerHTML=n:e.textContent=n,t!=null&&t.position&&(e.style.left=`${t.position.x}px`,e.style.top=`${t.position.y}px`,e.classList.add("positioned")),document.body.appendChild(e),setTimeout(()=>{e.classList.remove("show"),setTimeout(()=>{e.remove()},500)},(t==null?void 0:t.duration)||3e3)}const g5=`<?xml version="1.0" ?>
|
|
28
28
|
<svg
|
|
29
29
|
fill="currentColor"
|
|
30
30
|
xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
|
@@ -337,7 +337,7 @@ xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
|
|
337
337
|
<path d="M5.27137 5.61819C6.60787 5.61819 7.69131 4.53475 7.69131 3.19825C7.69131 1.86176 6.60787 0.77832 5.27137 0.77832C3.93488 0.77832 2.85144 1.86176 2.85144 3.19825C2.85144 4.53475 3.93488 5.61819 5.27137 5.61819Z" stroke="#999999" stroke-linejoin="round" fill="none"/>
|
|
338
338
|
<path d="M9.07413 10.8036H13.2226M11.1484 8.91895V13.1009V8.91895Z" stroke="#999999" stroke-linecap="square" fill="none"/>
|
|
339
339
|
<path d="M8.03712 8.38281H5.20234C3.65344 8.38281 2.87899 8.38281 2.28739 8.68423C1.76699 8.94939 1.3439 9.3725 1.07875 9.89289C0.777313 10.4845 0.777313 11.2589 0.777313 12.8078V13.2227H8.03712" stroke="#999999" stroke-linecap="square" stroke-linejoin="round" fill="none"/>
|
|
340
|
-
</svg>`;function sB(n,t){var e;if(M(t,"menu-item"),!n.element){if(n.type==="section"){const o=b("div",["section-name"],null,n.name);t.appendChild(o)}else if(n.type!=="separator"){if(n.icon){const r=b("div",["menu-item-icon"],null);n.icon&&(r.innerHTML=n.icon),t.appendChild(r)}const o=b("div",["menu-item-name","text"],null,n.name);if(t.appendChild(o),n.subText&&b("div",["item-subtext","text"],t,n.subText),n.children&&!n.element){const r=b("div",["menu-item-sub-indicator"],null);r.innerHTML=A5,t.appendChild(r)}if((e=n.states)!=null&&e.includes("checked")){const r=b("div",["menu-item-checked-icon"],null);r.innerHTML=Hw,t.appendChild(r)}}}}class cr extends Dc{constructor(t,e,o){super(t,e,{autoClose:!0,disablePageScroll:!0,...o})}manualShow(t,e){const o={theme:"menu",...e};super.manualShow(t,o)}initCommandBarElement(t){M(t,"menu")}initItemElement(t,e){sB(t,e)}}function lB(n,t,e){var o;return new cr((o=n.children)!=null?o:[],t,{...e,parentItem:n})}class Ss extends Dc{constructor(t,e,o){super(t,e,{itemElementTag:"button",tippyArrow:!1,...o})}getSubBarOptions(t){var r,i;const e=()=>{const s=this.getItemElementById(t.id),c=this.content.getBoundingClientRect(),a=s.getBoundingClientRect();return new DOMRect(a.left,c.top,a.width,c.height)};return{placement:(r=t.childrenPlacement)!=null?r:"top",getReferenceClientRect:e,offset:(i=t.childrenOffset)!=null?i:[0,4]}}manualShow(t,e){const o={theme:"toolbar",...e};super.manualShow(t,o)}initCommandBarElement(t){M(t,"toolbar")}initItemElement(t,e){e.setAttribute("data-button-id",t.id),this.options.tooltipId&&t.name&&!t.disableTooltip&&(e.setAttribute(`data-editor-tooltip-${this.options.tooltipId}`,t.name),t.desc&&e.setAttribute(`data-editor-tooltip-desc-${this.options.tooltipId}`,t.desc));const o=e;if(!t.element)if(t.icon){const r=b("span",["toolbar-item-icon-container"],o);t.icon.trim().startsWith("<")?r.innerHTML=t.icon:r.innerText=t.icon}else{const r=b("span",["toolbar-item-name-container"],o);r.innerText=t.name}if(t.dropdown){e.setAttribute("data-dropdown","true");const r=b("span",["toolbar-item-dropdown-container"],o);r.innerHTML=ph}t.states&&(t.states.indexOf("checked")!==-1&&M(o,"checked"),t.states.indexOf("disabled")!==-1&&(o.disabled=!0))}}function cB(n,t,e){var o;return new Ss((o=n.children)!=null?o:[],t,{...e,parentItem:n})}const nV="";Zr.registerManualCommandBar("menu",lB),Zr.registerManualCommandBar("toolbar",cB);const oV="",x5=w("ui-base");class Ds extends Dc{constructor(e,o){super(Ds.getCommandItems(e,o),void 0,{disablePageScroll:!0,...o});h(this,"handleDocumentMouseDown",e=>{})}initCommandBarElement(e){M(e,"dialog","manual")}initItemElement(e,o){}show(e,o){this.manualShow(e,{...o,theme:"light"})}get dialogContent(){const e=this.items[0];u(x5,e,"no dialog item");const o=e.element;return u(x5,o,"no item element"),o}static getCommandItems(e,o){var s;return[{id:(s=o==null?void 0:o.id)!=null?s:`manual-dialog-${P()}`,name:"",element:e}]}}const aB=[-1,6,0,1,2,3,4,5],uB=[-1,6,0,1,2,3,4,5,14,13,7,8,9,10,11,12],T5=w("color-palette");function S5(n,t,e,o){u(T5,n>0,"no color in palette");const r=t||1;u(T5,r>0,`invalid palette rows: ${r}`);const i=n/r,s=b("div",["palette-container",o],null);for(let l=0;l<r;l++){const c=b("div",["palette-container-row"],s);for(let a=0;a<i;a++){const d=e(l*i+a);c.appendChild(d)}}return s}function dB(n){const t=b("button",["color-button"],null),e=aB[n];return t.setAttribute("data-color-index",`${e}`),t.innerHTML=C5,t}function hB(n){const t=b("button",["background-color-button"],null),e=uB[n];return t.setAttribute("data-color-index",`${e}`),t}function fB(){const n=b("div",["clear-button-container"],null),t=b("button",["clear-button"],n);return t.innerText=x.t("colorPalette.reset"),n}function mB(n){const t=b("div",["color-palette"],null);return n.color!==!1&&(b("div",["bar-desc"],t,x.t("colorPalette.colorDesc")),t.appendChild(S5(8,1,dB,"color"))),n.backgroundColor!==!1&&(b("div",["bar-desc"],t,x.t("colorPalette.backgroundDesc")),t.appendChild(S5(16,2,hB,"background-color"))),n.clearColorButton!==!1&&t.appendChild(fB()),t}function gB(n,t,e){const o=t==="color"?"color":"background-color",r=n.querySelector(`.${o} button.selected`);r&&H(r,"selected"),e===null&&(e=-1);const i=n.querySelector(`.${o} button[data-color-index="${e}"]`);i&&M(i,"selected")}const rV="",pB={};class CB extends Yt.TypedEmitter{constructor(e=pB){super();h(this,"root");h(this,"handleClick",e=>{const o=e.target;if(!o||!(o instanceof Element))return;const r=o.closest("button");if(!r)return;if(rt(r,"clear-button")){this.setColor("backgroundColor",null),this.setColor("color",null),this.emit("onClick","clearColor",0);return}const i=r.getAttribute("data-color-index");if(!i)return;const s=Number.parseInt(i,10);Number.isNaN(s)||(rt(r,"color-button")?s===-1?(this.setColor("color",null),this.emit("onClick","clearColor",1)):(this.setColor("color",s),this.emit("onClick","color",s)):s===-1?(this.setColor("backgroundColor",null),this.emit("onClick","clearColor",2)):(this.setColor("backgroundColor",s),this.emit("onClick","backgroundColor",s)))});this.options=e,this.root=mB(e),this.root.addEventListener("click",this.handleClick)}destroy(){this.removeAllListeners(),this.root.removeEventListener("click",this.handleClick)}setColor(e,o){gB(this.root,e,o)}}class D5{constructor(t,e){h(this,"name","Color Palette");h(this,"element");h(this,"palette");h(this,"closeable",null);this.id=t,this.palette=new CB(e),this.element=this.palette.root}setCloseable(t){this.closeable=t}destroy(){this.palette.destroy(),this.closeable=null}}function AB(){const n=b("button",["color-button"],null);return n.innerHTML=C5,n}function Th(n,t){const[e,o]=t;e===null?n.removeAttribute("data-color"):n.setAttribute("data-color",`${e}`),o===null?n.removeAttribute("data-background-color"):n.setAttribute("data-background-color",`${o}`)}class bB extends Yt.TypedEmitter{constructor(e){super();h(this,"id","text-color-item");h(this,"name",x.t("colorPalette.name"));h(this,"dropdown",!0);h(this,"manualShowChildren",!0);h(this,"children",[]);h(this,"element");h(this,"colorPaletteItem");h(this,"latestColors",[null,null]);h(this,"handlePaletteClick",(e,o)=>{this.emit("onClick",e,o),e==="color"||e==="backgroundColor"?e==="color"?this.latestColors[0]=o:this.latestColors[1]=o:this.latestColors=[null,null],Th(this.element,this.latestColors)});h(this,"beforePopup",()=>{this.emit("beforePopup")});this.editor=e,this.colorPaletteItem=new D5("text-color-palette-item"),this.colorPaletteItem.palette.addListener("onClick",this.handlePaletteClick),this.children.push(this.colorPaletteItem),this.element=AB()}destroy(){this.colorPaletteItem.destroy()}updatePaletteColor(e){this.colorPaletteItem.palette.setColor("color",e[0]),this.colorPaletteItem.palette.setColor("backgroundColor",e[1]),this.latestColors=e,Th(this.element,this.latestColors)}updateButtonColor(e){this.latestColors=e,Th(this.element,this.latestColors)}}const iV="";function Sh(n,t){const e=b("div",["editor-input-wrap"],n);t!=null&&t.className&&M(e,t==null?void 0:t.className);const o=b("div",["editor-input-label"],e);b("span",[],o,t.label),t.required&&M(o,"required");const r=b("div",["editor-input-container"],e),i=b("input",["editor-input"],r);t.placeholder&&(i.placeholder=t.placeholder),t.defaultValue&&(i.value=t.defaultValue);const s=b("div",["editor-input-error"],e);return i.addEventListener("input",l=>{var c;(c=t.onChange)==null||c.call(t,l),H(e,"error")}),i.addEventListener("keydown",l=>{var c;(c=t.onKeyDown)==null||c.call(t,l)}),{getField:()=>i,getInputValue:()=>i.value,setFieldError:l=>{M(e,"error"),s.innerText=l},focus:()=>{setTimeout(()=>{i.focus()})}}}function Dh(n){const t=document.getSelection();if(!t)return!0;const e=t.focusNode;if(!e)return!0;const o=t.focusOffset,r=e.childNodes[o];if(!r)return!0;if(r instanceof HTMLElement){const i=r.tagName.toLowerCase();if(r===n.input.inputElement)return!0;if(i==="input"||i==="textarea")return!1}return!0}const vB=w("ui-base");class yB{constructor(t,e){h(this,"menu");h(this,"currentText","");h(this,"handleClick",(t,e)=>{this.options.onClickItem(this,e)});h(this,"handleClose",()=>{var t,e;Dh(this.editor)&&this.editor.focus(),(e=(t=this.options).onClose)==null||e.call(t)});h(this,"handleKeydown",t=>{this.menu.handleDocumentKeydown(t)});this.editor=t,this.options=e,this.menu=new cr([],void 0,{id:e.id}),this.menu.addListener("click",this.handleClick),this.menu.addListener("close",this.handleClose)}setItems(t){if(this.menu.updateItems(t),t.length>0){const e=t.find(o=>o.type!=="section"&&o.type!=="separator");e&&this.menu.selectItem(e.id)}}async popup(t,e,o){var a,d;if(((d=(a=this.options).onShow)==null?void 0:d.call(a,this,t,e,o))===!1)return;this.options.showLoading&&this.showLoading();const r=this.editor.getBlockByIndex(t,e);if(!wt(this.editor.rootContainer,r)||G(this.editor,r)<o)return;const i=co(this.editor,r,Ot(this.editor,r,o));if(i.length===0)return;const s=i[0],l=fo(this.editor,r,"editor-auto-suggest-menu",s);this.menu.manualShow(l),this.options.placeholder&&this.showPlaceholder();const c=await this.options.queryItems(this,"");this.highlightText(""),this.setItems(c)}showLoading(){!this.options.showLoading||(this.options.loadingElement?this.setItems([{id:"loading",name:"",element:this.options.loadingElement,states:["disabled"]}]):this.setItems([{id:"loading",name:"loading",states:["disabled"]}]))}showPlaceholder(){this.setItems([{id:"placeholder",name:"enter text to search",states:["disabled"]}])}showNoResultMessage(t){if(this.options.noResultMessage){const e={name:"",id:"placeholder",states:["disabled"]};typeof this.options.noResultMessage=="string"?e.name=this.options.noResultMessage:(this.options.noResultMessage instanceof HTMLElement||typeof this.options.noResultMessage=="function")&&(e.element=this.options.noResultMessage),this.setItems([e])}else this.setItems([{id:"placeholder",name:x.t("search.emptyTips"),states:["disabled"]}])}close(){this.menu.close()}get isVisible(){return this.menu.isVisible}destroy(){this.menu.close(),this.menu.removeAllListeners(),this.menu.destroy()}async handleSearchText(t){this.currentText=t;const e="auto-suggest";try{await Ge.lock(e),this.showLoading();const o=this.currentText,r=await this.options.queryItems(this,o);if(this.currentText===o&&(this.currentText=""),r.length===0){this.showNoResultMessage(t);return}this.setItems(r),this.options.highlight&&this.highlightText(o.replace(/^\s+|\s+$/g,""))}finally{Ge.release(e)}}highlightText(t){vB.debug(`highlight menu text: ${t}`);const e=this.menu.content,o=(i,s)=>{if(!s)return i;let l="";const c=s.length,a=s.toLocaleLowerCase();let d=0;for(d=0;d<=i.length-c;d){let f=i.substring(d,d+c);if(f.toLocaleLowerCase()===a){d+=c;const m=i.charAt(d);let p=!1;f.endsWith(" ")&&(p=!0,f=f.trimEnd()),l+=`<span class="highlight">${f}${m===" "||p?" ":""}</span>`}else l+=i.charAt(d),d++}return d<i.length&&(l+=i.substring(d)),l},r=i=>{if(rt(i,"text")){const s=i.textContent;if(!s)return;const l=o(s,t);i.innerHTML=l;return}Array.from(i.children).forEach(r)};r(e)}}const Lh=w("auto-suggest-menu");class Mh{constructor(t,e){h(this,"menu");h(this,"anchor",null);h(this,"close",()=>{this.menu.close()});h(this,"handleSelectionChanged",t=>{var o,r;if(!((o=this.menu)!=null&&o.isVisible))return;const e=t.selection.range.start;if(e.isSimple()&&e.blockId===((r=this.anchor)==null?void 0:r.blockId)&&e.offset>=this.anchor.offset){const i=t.getBlockById(e.blockId);if(vt(ve(ge(t,i),e.offset).left).startsWith(this.anchor.leftText))return}this.menu.close()});h(this,"deleteTrigger",()=>{const t=this.editor,e=t.selection.range.start;if(!e.isSimple()||!this.anchor)return!1;const{blockId:o,offset:r}=e,i=t.getBlockById(o),s=vt(rc(t,i,r));if(u(Lh,this.anchor,"no anchor"),!s.startsWith(this.anchor.leftText))return!1;const l=this.anchor.offset-this.anchor.trigger.length,c=r-l;return t.selection.selectBlock(i,l),c&&(t.deleteTextFromBlock(i,l,c),this.anchor.offset-=this.anchor.trigger.length),this.anchor.trigger.length||this.menu.close(),!0});h(this,"onClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});h(this,"onShow",(t,e,o,r)=>{var i;if((i=this.options)!=null&&i.onShow)return this.options.onShow(this,e,o,r)});h(this,"onClickItem",(t,e)=>{!this.anchor||(this.options.autoDeleteTrigger&&this.deleteTrigger(),this.options.onClickItem(this,e,this.anchor))});h(this,"queryItems",(t,e)=>this.options.queryItems(this,e));h(this,"renderMenuItem",(t,e)=>{var r,i;return(i=(r=this.options).renderMenuItem)==null?void 0:i.call(r,this,e)});this.editor=t,this.options=e,this.menu=new yB(t,{id:e.id,showLoading:e.showLoading,loadingElement:e.loadingElement,placeholder:e.placeholder,noResultMessage:e.noResultMessage,highlight:e.highlight,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,renderMenuItem:this.renderMenuItem}),t.input.addHandler(this),t.addListener("selectionChanged",this.handleSelectionChanged)}handleBeforeKeyDown(t,e){var o;return!((o=this.menu)!=null&&o.isVisible)||vu(e.key)?!1:zm(e)&&!Go(e)?(setTimeout(()=>{this.resetItems()}),!1):yu(e)?(this.menu.close(),!0):(this.menu.handleKeydown(e),!0)}popup(t,e,o,r){this.anchor={blockId:j(t),offset:e,leftText:o,trigger:r};const i=V(z(t)),s=K(t);this.menu.popup(i,s,e)}handleAfterInsertText(t,e,o,r,i){var d;const s=t.selection.range.start;if(!s.isSimple()||e==="root"&&o===0)return!1;const{blockId:l,offset:c}=s,a=t.getBlockByIndex(e,o);if(j(a)!==l)return!1;if((d=this.menu)!=null&&d.isVisible)this.resetItems();else if(this.options.trigger.indexOf(i)!==-1){if(r>0&&this.options.needSpaceBeforeTrigger&&t.getBlockString(a)[r-1]!==" ")return!1;const f=vt(rc(t,a,c));this.popup(a,c,f,i)}return!1}handleUpdateCompositionText(t,e,o,r,i){var a;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l}=s,c=t.getBlockByIndex(e,o);return j(c)!==l||(a=this.menu)!=null&&a.isVisible&&this.resetItems(),!1}resetItems(){var l;if(!((l=this.menu)!=null&&l.isVisible))return;const t=this.editor,e=t.selection.range.start;if(!e.isSimple())return;const{blockId:o,offset:r}=e,i=t.getBlockById(o),s=vt(rc(t,i,r));if(u(Lh,this.anchor,"no anchor"),s.startsWith(this.anchor.leftText)){const c=s.substring(this.anchor.leftText.length);Lh.debug(`search text: ${c}`),this.menu.handleSearchText(c)}}destroy(){var t;this.editor.input.removeHandler(this),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.menu)==null||t.destroy()}}function kB(){const n={};for(let t=1;t<=8;t++)n[`heading-${t}`]={shortcut:`/h${t}`};return n}const wB={"insert-hr":{shortcut:"/hr"},"insert-uml":{shortcut:"/uml"},"insert-table":{shortcut:"/table"},"insert-image":{shortcut:"/image"},"insert-code":{shortcut:"/code"},"insert-link":{shortcut:"/link"},"insert-drawio":{shortcut:"/uml"},"insert-video":{shortcut:"/video"},"insert-audio":{shortcut:"/audio"},"insert-math":{shortcut:"/math"},"insert-webPage":{shortcut:"/web"},"insert-bilibili":{shortcut:"/bilibili"},"insert-youku":{shortcut:"/youku"},"insert-figma":{shortcut:"/figma"},"insert-modao":{shortcut:"/modao"},"insert-tencent":{shortcut:"/tencent"},"insert-unordered":{shortcut:"/bl"},"insert-ordered":{shortcut:"/nu"},"insert-checkbox":{shortcut:"/todo"},"insert-quote":{shortcut:"/quote"},...kB()};function Ce(n){var t;return(t=wB[n])==null?void 0:t.shortcut}function BB(n){var t;return(t=n.subText)!=null?t:""}const Tn=w("table-dom");function Io(n){return`${j(n)}_scroll`}function jt(n){const t=n.querySelector("div[data-type=table-content] >table");return u(Tn,t instanceof HTMLTableElement,"invalid table"),t}function Sn(n,t){const o=n.getCustom(Io(t)).contentElement.firstElementChild;u(Tn,o instanceof HTMLElement,"invalid table content");let r=o.querySelector(":scope >div[data-type=table-tools]");return r||(r=b("div",[],o),r.setAttribute("data-type","table-tools")),u(Tn,r,"no table tools"),r}function L5(n){const t=[];return Array.from(n.rows).forEach(e=>{t.push(...Array.from(e.cells))}),t}function Ls(n){const t=n.querySelector(":scope div[data-type=editor-container]");return u(Tn,t,"no child container in cell"),t}function EB(n){const o=L5(n).map(r=>{const i=Ls(r),s=V(i),l=r.colSpan,c=r.rowSpan;return`${s}/${l}/${c}`}).join();return Er.default(o)}function Zt(n){return it(n)==="table"}function Rh(n){const t=z(n);if(Ct(t))return null;const e=U(t);return u(Tn,e,"no parent block"),Zt(e)?t:Rh(e)}function Qn(n){if(Zt(n))return n;const t=z(n);if(Ct(t))return null;const e=U(t);return u(Tn,e,"no parent block"),Zt(e)?e:Qn(e)}function IB(n,t){const e=n.querySelector("colgroup");u(Tn,e,"no colgroup");const o=e.children[t];return u(Tn,o,"no col"),u(Tn,o instanceof HTMLTableColElement,`invalid col: ${o.tagName}`),o}function M5(n){try{return jt(n),!0}catch{return!1}}function xB(n){return Rt(n).querySelector(":scope > .block-helper")}function R5(n){const t=U(n.contentElement);u(Tn,t,"no block");const e=xB(t);if(e){const o=Math.min(n.contentElement.offsetLeft,n.rootElement.scrollLeft),r=t.getBoundingClientRect().width;e.style.right=`${o+r}px`}}const Re=w("doc-table-grid");class TB{constructor(t){h(this,"_cells",[]);for(let e=0;e<t;e++)this._cells.push(void 0)}cols(){return this._cells.length}setCell(t,e){u(Re,t>=0&&t<this.cols(),`set cell, invalid col: ${t}`),this._cells[t]=e}getCell(t){u(Re,t>=0&&t<this.cols(),`get cell, invalid col: ${t}`);const e=this._cells[t];return u(Re,e,"get cell, no cell"),e}getCellAllowEmpty(t){return u(Re,t>=0&&t<this.cols(),`get cell, invalid col, ${t}`),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}forEach(t){this._cells.forEach(t)}}class Mc{constructor(t){h(this,"_data");h(this,"_rows");this._data=t,this._rows=[];for(let e=0;e<this.rowCount;e++)this._rows.push(new TB(this.colCount));this.fillGrid(),u(Re,t.colsWidth,"no colsWidth"),u(Re,this.colCount===t.colsWidth.length,"invalid col count")}get rowCount(){return this._data.rows}get colCount(){return this._data.cols}getNextEmptyCell(t,e){let o=t,r=e;for(;;){if(o+=1,o===this.colCount&&(o=0,r+=1),r>=this.rowCount)return null;if(this._rows[r].getCellAllowEmpty(o)===void 0)return{col:o,row:r}}}fillGrid(){const t=this._data.children;u(Re,t,"no children");let e=0,o=0;t.forEach((r,i)=>{const s=this._data[`${r}_colSpan`]||1,l=this._data[`${r}_rowSpan`]||1;for(let a=0;a<l;a++)for(let d=0;d<s;d++)this._rows[o+a].setCell(e+d,{col:e,row:o,containerId:r,virtual:d!==0||a!==0,colSpan:s,rowSpan:l});const c=this.getNextEmptyCell(e,o);c?(e=c.col,o=c.row):u(Re,i===t.length-1,`invalid table data, no next empty cell: ${JSON.stringify(this._data)}`)}),this._rows.forEach(r=>{r.forEach(i=>{u(Re,i,"no cell"),u(Re,i.containerId,"no containerId")})})}getCell(t){const{col:e,row:o}=t,r=this._rows[o];u(Re,r,`get cell, no row: ${o}`);const i=r.getCell(e);return u(Re,i,`get cell, no cell: ${e}`),i}getRow(t){const e=this._rows[t];return u(Re,e,`get row, no row: ${t}`),e}forEach(t){this._rows.forEach(t)}}const Rc=w("table-data");function SB(n){const t=n.firstElementChild;return u(Rc,t,"no child element for cell"),u(Rc,vn(t),"cell first child is not a container"),u(Rc,Ke(t),"cell first child is not a container"),t}function DB(n){const t=U(n);u(Rc,t,"no parent block for table");const e=[],o={};Array.from(n.rows).forEach(l=>{Array.from(l.cells).forEach(c=>{const a=SB(c),d=V(a);e.push(d),(c.colSpan>1||c.rowSpan>1)&&(o[`${d}_colSpan`]=c.colSpan,o[`${d}_rowSpan`]=c.rowSpan)})});const r=n.rows.length,i=Array.from(n.rows[0].cells).map(l=>l.colSpan).reduce((l,c)=>l+c,0);return{id:j(t),type:it(t),rows:r,cols:i,children:e,colsWidth:Array(i).fill(100),...o}}function ar(n){return new Mc(n)}function LB(n){return ar(DB(n))}const Qt=w("table-grid"),MB=60;class RB{constructor(t,e){h(this,"containerId");h(this,"row");h(this,"col");h(this,"colSpan");h(this,"rowSpan");h(this,"virtual");h(this,"table");this.table=t,this.containerId=e.containerId,this.row=e.row,this.col=e.col,this.colSpan=e.colSpan,this.rowSpan=e.rowSpan,this.virtual=e.virtual}get cell(){const e=this.container.closest("td");return u(Qt,e,"no parent cell for child container"),e}get container(){const t=this.table.querySelectorAll(`[data-container-id=${this.containerId}]`);u(Qt,t.length===1,"containers !== 1"),u(Qt,vn(t[0]),"not a container");const e=t[0];return u(Qt,Ke(e),"not a child container"),e}}class OB{constructor(t,e){h(this,"_cells",[]);e.forEach(o=>{this._cells.push(new RB(t,o))})}get cells(){return this._cells}getCell(t){return u(Qt,t<this._cells.length,"get cell, invalid col"),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}getSpannedCell(){return this._cells.find(t=>t.virtual||t.colSpan>1||t.rowSpan>1)}}const Wf=class{constructor(t){h(this,"_rows",[]);this.table=t,LB(t).forEach(r=>{this._rows.push(new OB(t,r))});const o=this.colCount;this._rows.forEach(r=>{u(Qt,r.cells.length===o,"row.cells.length !== colCount")})}get rowCount(){return this._rows.length}get colCount(){return this._rows.length===0?0:(u(Qt,this.rowCount>0,"rowCount <= 0"),this.getRow(0).cells.length)}getRow(t){return this._rows[t]}getCell(t){const e=this.getRow(t.row);return u(Qt,e,"no row"),e.getCell(t.col)}getCellContainer(t){return this.getCell(t).container}getFirstCellContainer(){return this.getCellContainer({row:0,col:0})}getLastCellContainer(){const t=this.rowCount-1,e=this.colCount-1;return this.getCellContainer({row:t,col:e})}getColumnCells(t){u(Qt,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount,o=[];for(let r=0;r<e;r++){const i=this.getCell({row:r,col:t});o.push(i)}return o}toRealCells(t){const e=[];return t.forEach(o=>{const r=this.getRealCell(o);e.findIndex(i=>i.containerId===r.containerId)===-1&&e.push(r)}),e}getColumnRealCells(t){const e=this.getColumnCells(t);return this.toRealCells(e)}getRowRealCells(t){const e=this.getRow(t).cells;return this.toRealCells(e)}getFirstSpannedCell(t){u(Qt,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount;for(let o=0;o<e;o++){const r=this.getCell({row:o,col:t});if(r.virtual||r.colSpan>1||r.rowSpan>1)return r}}getRealCell(t){const e=this.getCell(t);if(!e.virtual)return e;const o=this.getCellById(e.containerId);return u(Qt,!o.virtual,"found a virtual cell"),o}getColumnSpannedRange(t){const e=this.getColumnRealCells(t);let o=1e5,r=-1;return e.forEach(i=>{o=Math.min(i.col,o),r=Math.max(i.col+i.colSpan-1,r)}),u(Qt,o<=r,"min > max"),u(Qt,o>=0,"min < 0"),u(Qt,r<this.colCount,"max >= colCount"),[o,r]}getRowSpannedRange(t){const e=this.getRowRealCells(t);let o=1e5,r=-1;return e.forEach(i=>{o=Math.min(i.row,o),r=Math.max(i.row+i.rowSpan-1,r)}),u(Qt,o<=r,"min > max"),u(Qt,o>=0,"min < 0"),u(Qt,r<this.rowCount,"max >= rowCount"),[o,r]}getSpannedRange(t,e){const o=Math.min(t.row,e.row),r=Math.max(t.row,e.row),i=Math.min(t.col,e.col),s=Math.max(t.col,e.col),l=[];for(let p=o;p<=r;p++)for(let A=i;A<=s;A++)l.push(this.getCell({row:p,col:A}));const c=this.toRealCells(l);let a=1e4,d=1e4,f=-1,m=-1;return c.forEach(p=>{d=Math.min(p.col,d),a=Math.min(p.row,a),m=Math.max(p.col+p.colSpan-1,m),f=Math.max(p.row+p.rowSpan-1,f)}),[{row:a,col:d},{row:f,col:m}]}getAllCells(){return this.getCells({col:0,row:0},{col:this.colCount-1,row:this.rowCount-1})}sub(t,e){const o=[];for(let r=t.row;r<=e.row;r++){const i=[];for(let s=t.col;s<=e.col;s++){const l=this.getCell({row:r,col:s});i.push(l)}o.push(i)}return o}getAllContainers(){return this.getAllCells().map(e=>e.container)}getCells(t,e){const o=[],r=this.getSpannedRange(t,e),i=r[0],s=r[1],l=Math.min(i.row,s.row),c=Math.max(i.row,s.row),a=Math.min(i.col,s.col),d=Math.max(i.col,s.col);for(let f=l;f<=c;f++)for(let m=a;m<=d;m++){const p=this.getCell({row:f,col:m});p.virtual||o.push(p)}return o}map(t){const e=[];for(let o=0;o<this.rowCount;o++){const r=[];for(let i=0;i<this.colCount;i++){const s=this.getCell({row:o,col:i});r.push(t(s))}e.push(r)}return e}getBottomCell(t){const e=this.rowCount;let o=t,r=t.row;for(;o.containerId===t.containerId;){if(r+=1,r>=e)return null;o=this.getCell({row:r,col:t.col})}return this.getRealCell(o)}getTopCell(t){let e=t,o=t.row;for(;e.containerId===t.containerId;){if(o-=1,o<0)return null;e=this.getCell({row:o,col:t.col})}return this.getRealCell(e)}get cells(){let t=[];return this._rows.forEach(e=>{t=t.concat(e.cells)}),t}getVirtualCellContainersGrid(){return this.map(t=>t.containerId)}static virtualCellContainersGridToChildren(t){const e=t,o=[];return e.forEach(r=>{r.forEach(i=>{o.indexOf(i)===-1&&o.push(i)})}),o}getCellById(t){const o=this.cells.find(r=>r.containerId===t);return u(Qt,o,"cell not found"),o}getCellByCellElement(t){const e=Ls(t);return this.getCellByContainerId(V(e))}getCellByContainerId(t){return this.getCellById(t)}static fromTable(t){const e=EB(t),o=this.caches.getSync(e,()=>(Qt.debug("create table grid"),new Wf(t)));return o.table!==t?(this.caches.delete(e),this.fromTable(t)):o}static fromBlock(t){return this.fromTable(jt(t))}};let nt=Wf;h(nt,"caches",new vm(MB));function Oc(n,t){Object.entries(n).forEach(([e])=>{e.startsWith(`${t}/`)&&delete n[e]})}const NB=w("table-selection-range");function dn(n,t,e){var E,L,R,$;const o=nt.fromBlock(n),r=t,i=e,s=o.getCellByContainerId(r.childContainerId),l=o.getCellByContainerId(i.childContainerId),c=r.custom,a=i.custom,d=(E=c==null?void 0:c.rowIndex)!=null?E:s.row,f=(L=c==null?void 0:c.colIndex)!=null?L:s.col,m=(R=a==null?void 0:a.rowIndex)!=null?R:l.row+l.rowSpan-1,p=($=a==null?void 0:a.colIndex)!=null?$:l.col+l.colSpan-1,A=Math.min(d,m),k=Math.max(d,m),v=Math.min(f,p),T=Math.max(f,p);return{fromRow:A,toRow:k,fromCol:v,toCol:T}}function Oh(n,t){const e=new Set,o=new Set,r=n.selection.range;if(!r.isSimple()&&r.start.blockId===j(t)){const i=nt.fromBlock(t),{start:s,end:l}=r;u(NB,!s.isSimple()&&!l.isSimple(),"invalid range");const{fromCol:c,toCol:a,fromRow:d,toRow:f}=dn(t,s,l);if(d===0&&f===i.rowCount-1)for(let m=c;m<=a;m++)o.add(m);if(c===0&&a===i.colCount-1)for(let m=d;m<=f;m++)e.add(m)}return{selectedRows:e,selectedColumns:o}}function Ms(n,t){let e=null;if(t.isCollapsed()&&t.isSimple()){const o=n.getBlockById(t.start.blockId);if(Zt(o)){const r=z(o),i=U(r);i&&(e=Qn(i))}else e=Qn(o)}else{const o=n.getBlockById(t.start.blockId),r=Qn(o),i=n.getBlockById(t.end.blockId),s=Qn(i);r===s&&(e=r)}return e}const Qr=w("delete-columns");function O5(n,t,e){const{start:o,end:r}=e;if(o.blockId!==r.blockId||e.isSimple()||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{fromRow:s,toRow:l}=dn(t,e.start,e.end),c=nt.fromBlock(t);return s===0&&l===c.rowCount-1}function Nh(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{var L;const e=t.getBlockById(n.start.blockId);if(!O5(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromCol:o,toCol:r}=dn(e,n.start,n.end),i=nt.fromBlock(e);if(o===0&&r===i.colCount-1){t.deleteBlock(e);return}const s=new Set,l=i.map(R=>R.containerId);for(let R=0;R<l.length;R++){const $=l[R];for(let q=o;q<=r;q++){const ot=$[q];s.add(ot)}$.splice(o,r-o+1)}const c=new Set(l.flat()),a=new Set(Array.from(s).filter(R=>!c.has(R))),d=r-o+1,f=new Map,m=new Map;s.forEach(R=>{if(a.has(R))return;const $=i.getCellByContainerId(R);if(u(Qr,$.colSpan>1,"invalid effected cell, colSpan === 1"),$.col<o){u(Qr,c.has(R),"invalid effected cell, not exists");let kt=$.col+$.colSpan-1;kt>r&&(kt=r);const de=kt-o+1,oo=$.colSpan-de;f.set(R,oo);return}u(Qr,$.col<=r,"invalid effected cell, col > endCol");const q=$.col,ot=$.col+$.colSpan-1,lt=$.col-o,gt=ot-q+1-d+lt;u(Qr,gt>0,"invalid effected cell, newSpanned <= 0");const ht=Bn(t.doc);m.set(R,{newContainerId:ht,colSpan:gt})});for(let R=0;R<l.length;R++){const $=l[R];for(let q=o;q<$.length;q++){const ot=$[q],lt=m.get(ot);lt&&($[q]=lt.newContainerId)}}const p=Q.default(t.getBlockData(e));p.colsWidth.splice(o,r-o+1),a.forEach(R=>{Oc(p,R)}),f.forEach((R,$)=>{u(Qr,R>=1,"invalid modified colSpan, colSpan < 1"),R===1?p[`${$}_colSpan`]=void 0:p[`${$}_colSpan`]=R}),m.forEach((R,$)=>{Oc(p,$);const{newContainerId:q,colSpan:ot}=R;u(Qr,ot>=1,"invalid newContainerData, colSpan < 1"),ot>1&&(p[`${q}_colSpan`]=ot);const lt=i.getCellByContainerId($).rowSpan;lt>1&&(p[`${q}_rowSpan`]=lt)});const k=(L=l[0][o])!=null?L:l[0][o-1],v=t.getChildContainerData(k)[0],T=nt.virtualCellContainersGridToChildren(l),E={...p,cols:p.cols-d,children:T};ar(E),t.updateBlockData(e,E,Ot(t,v.id,0)),t.deleteChildContainers(Array.from(a)),t.deleteChildContainers(Array.from(m.keys()))})}const Yr=w("delete-rows");function N5(n,t,e){const{start:o,end:r}=e;if(o.blockId!==r.blockId||e.isSimple()||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{fromCol:s,toCol:l}=dn(t,e.start,e.end),c=nt.fromBlock(t);return s===0&&l===c.colCount-1}function Ph(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{const e=t.getBlockById(n.start.blockId);if(!N5(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromRow:o,toRow:r}=dn(e,n.start,n.end),i=nt.fromBlock(e);if(o===0&&r===i.rowCount-1){t.deleteBlock(e);return}const s=new Set,l=i.map(E=>E.containerId);for(let E=r;E>=o;E--)l[E].forEach(R=>s.add(R)),l.splice(E,1);const c=new Set(l.flat()),a=new Set(Array.from(s).filter(E=>!c.has(E))),d=r-o+1,f=new Map,m=new Map;s.forEach(E=>{if(a.has(E))return;const L=i.getCellByContainerId(E);if(u(Yr,L.rowSpan>1,"invalid effected cell, rowSpan === 1"),L.row<o){u(Yr,c.has(E),"invalid effected cell, not exists");let gt=L.row+L.rowSpan-1;gt>r&&(gt=r);const ht=gt-o+1,kt=L.rowSpan-ht;f.set(E,kt);return}u(Yr,L.row<=r,"invalid effected cell, col > endCol");const R=L.row,$=L.row+L.rowSpan-1,q=L.row-o,ot=$-R+1-d+q;u(Yr,ot>0,"invalid effected cell, newSpanned <= 0");const lt=Bn(t.doc);m.set(E,{newContainerId:lt,rowSpan:ot})});for(let E=o;E<l.length;E++){const L=l[E];for(let R=0;R<L.length;R++){const $=L[R],q=m.get($);q&&(L[R]=q.newContainerId)}}const p=Q.default(t.getBlockData(e));a.forEach(E=>{Oc(p,E)}),f.forEach((E,L)=>{u(Yr,E>=1,"invalid modified rowSpan, rowSpan < 1"),E===1?p[`${L}_rowSpan`]=void 0:p[`${L}_rowSpan`]=E}),m.forEach((E,L)=>{Oc(p,L);const{newContainerId:R,rowSpan:$}=E;u(Yr,$>=1,"invalid newContainerData, rowSpan < 1"),$>1&&(p[`${R}_rowSpan`]=$);const q=i.getCellByContainerId(L).colSpan;q>1&&(p[`${R}_colSpan`]=q)});const A=l[o]?l[o][0]:l[o-1][0],k=t.getChildContainerData(A)[0],v=nt.virtualCellContainersGridToChildren(l),T={...p,rows:p.rows-d,children:v};ar(T),t.updateBlockData(e,T,Ot(t,k.id,0)),t.deleteChildContainers(Array.from(a)),t.deleteChildContainers(Array.from(m.keys()))})}const Rs=w("table-range");function Nc(n){u(Rs,!n.isSimple(),"must be complex selection range");const{anchor:t,focus:e}=n;u(Rs,!t.isSimple(),"invalid start pos type"),u(Rs,!e.isSimple(),"invalid end pos type");const o=n.getEditor();u(Rs,t.blockId===e.blockId,"invalid range, not same block");const r=o.getBlockById(t.blockId);u(Rs,it(r)==="table","invalid block type, not a table block");const i=jt(r),s=nt.fromTable(i),l=s.getCellByContainerId(t.childContainerId),c=s.getCellByContainerId(e.childContainerId),a=Math.min(l.row,c.row),d=Math.max(l.row,c.row),f=Math.min(l.col,c.col),m=Math.max(l.col,c.col),p=s.getCell({row:a,col:f}),A=s.getCell({row:d,col:m});return{editor:o,block:r,table:i,startCell:p,endCell:A,startRow:a,startCol:f,endRow:d,endCol:m}}const $h=w("split-cell");function _h(n,t,e){n.undoManager.runInGroup(()=>{const o=nt.fromBlock(t),r=o.getRealCell(e);u($h,!r.virtual,"should not split virtual cell"),u($h,r.colSpan>1||r.rowSpan>1,"cell does not has span data");const i=o.getVirtualCellContainersGrid();for(let f=0;f<r.rowSpan;f++)for(let m=0;m<r.colSpan;m++){if(f===0&&m===0)continue;const p=f+r.row,A=m+r.col,k=Bn(n.doc);i[p][A]=k}const s=n.getBlockData(t),l=Q.default(s);l[`${r.containerId}_colSpan`]=null,l[`${r.containerId}_rowSpan`]=null,l.children=nt.virtualCellContainersGridToChildren(i);const a=n.getChildContainerData(r.containerId)[0];u($h,a,"no child block");const d=Ot(n,a.id,0);ar(l),n.updateBlockData(t,l,d)})}function PB(n,t,e){e.forEach(o=>{const r=nt.fromBlock(t).getCell(o);(r.virtual||r.colSpan>1||r.rowSpan>1)&&_h(n,t,o)})}function P5(n,t,e){if(e.isSimple())return!1;const{start:o,end:r}=e;if(o.blockId!==r.blockId||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{startCell:s,endCell:l}=Nc(e);return!(s.cell!==l.cell||s.colSpan===1&&s.rowSpan===1)}function Fh(n){const{editor:t,block:e,startRow:o,startCol:r,endRow:i,endCol:s}=Nc(n),l=[];for(let c=o;c<=i;c++)for(let a=r;a<=s;a++)l.push({row:c,col:a});return PB(t,e,l),!0}const Jr=w("merge-cells");function $5(n,t,e){if(e.isSimple())return!1;const{start:o,end:r}=e;if(o.blockId!==r.blockId||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{startCell:s,endCell:l}=Nc(e);return s.cell!==l.cell}function _5(n){const t=Nc(n),e=t.editor;e.undoManager.runInGroup(()=>{const o=t.endCell,r=o.row+o.rowSpan-1,i=o.col+o.colSpan-1,s=j(t.block);Fh(n);const l=e.getBlockById(s),c=jt(l),{startRow:a,startCol:d}=t,f=Q.default(e.getBlockData(l));u(Jr,f.children,"no table children");const m=nt.fromTable(c),p=[];for(let gt=a;gt<=r;gt++)for(let ht=d;ht<=i;ht++){const kt=m.getCell({row:gt,col:ht});u(Jr,!kt.virtual,"cell is virtual"),p.push(kt)}u(Jr,p.length>0,"no selected cells");const A=p[0],k=p.slice(1),v=m.getCellByContainerId(A.containerId).container,T=[];k.forEach(gt=>{const ht=m.getCellByContainerId(gt.containerId).container,kt=V(ht);if(!pd(e,ht)){const de=K0(e,kt);e.insertDocAt(v,Ze(v),de)}T.push(kt)});const E=V(v),L=i-d+1,R=r-a+1;f[`${E}_colSpan`]=L,f[`${E}_rowSpan`]=R,T.forEach(gt=>{u(Jr,f.children,"no table children");const ht=f.children.indexOf(gt);u(Jr,ht>0,"no deleted container"),f.children.splice(ht,1)});const $=f,ot=e.getChildContainerData(E)[0];u(Jr,ot,"no child block");const lt=Ot(e,ot.id,0);ar($),e.updateBlockData(l,$,lt),e.deleteChildContainers(T)})}const Hh=10,$B=["table/merge-cells","table/split-cell","table/insert-column","table/insert-row","table/delete-rows","table/delete-columns","table/delete"];class jh{constructor(){h(this,"id","TableBlockCommandProvider")}getAvailableCommands(t,e,o){if(it(e)!=="table")return[];const r={blockId:j(e),blockKind:Je(t,e),blockType:it(e)},i=[];$5(t,e,o)&&i.push({id:"table/merge-cells",name:x.t("table.mergeCell"),icon:Bw,groupIndex:Hh,...r}),P5(t,e,o)&&i.push({id:"table/split-cell",name:x.t("table.splitCell"),icon:Ew,groupIndex:Hh,...r});const s=O5(t,e,o),l=N5(t,e,o);return s&&l&&i.push({id:"table/delete",name:x.t("table.deleteTable"),icon:Iw,groupIndex:Hh,...r}),i}executeCommand(t,e,o,r,i,s){return it(e)!=="table"||!new Set($B).has(r.id)?!1:r.id==="table/merge-cells"?(_5(o),!0):r.id==="table/split-cell"?(Fh(o),!0):r.id==="table/delete-columns"?(Nh(o),!0):r.id==="table/delete-rows"?(Ph(o),!0):r.id==="table/delete"?(t.deleteBlock(e),!0):!1}}var F5=(n=>(n.COL_TITLE_TABLE="col-title-table",n.COL_TITLE_ITEM="col-title-item",n.STRIPE_STYLE_TABLE="stripe-style-table",n.NO_BORDER="table-no-border",n))(F5||{});const zh=6,Os=20,Uh="table-cell-menu-btn";function _B(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),hasColTitle:!0};n.updateBlockData(t,o)}function FB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),hasColTitle:!1};n.updateBlockData(t,o)}function HB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),hasRowTitle:!0};n.updateBlockData(t,o)}function jB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),hasRowTitle:!1};n.updateBlockData(t,o)}function zB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),isStripeStyle:!0};n.updateBlockData(t,o)}function UB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),isStripeStyle:!1};n.updateBlockData(t,o)}function VB(n,t,e){if(!n.isBlockWritable(t))return;const r={...Q.default(n.getBlockData(t)),noBorder:!e};n.updateBlockData(t,r)}const Vh=w("get-selected-containers");function qh(n,t,e,o){u(Vh,e.blockId===o.blockId,"only allow select in single table block"),u(Vh,j(t)===e.blockId,"only allow select in single table block");const r=nt.fromBlock(t),i=r.getCellByContainerId(e.childContainerId),s=r.getCellByContainerId(o.childContainerId);if(e.custom===void 0||o.custom===void 0)return r.getCells(i,s).map(v=>r.getCellContainer(v));const{fromCol:l,toCol:c,fromRow:a,toRow:d}=dn(t,e,o),f=new Set,m=[];return r.sub({row:a,col:l},{row:d,col:c}).forEach(A=>{A.forEach(k=>{const v=r.getCellByContainerId(k.containerId);v.col<l||v.row<a||v.col+v.colSpan-1>c||v.row+v.rowSpan-1>d||f.has(k.containerId)||(f.add(k.containerId),m.push(v.container))})}),m}function qB(n,t,e){u(Vh,t.blockId===e.blockId,"only allow select in single table block");const o=n.getBlockById(t.blockId);return qh(n,o,t,e)}const ur=w("table-cell-dom");function WB(n,t,e){let o=n.getBlockById(e);for(;o;){const r=o.closest("td");u(ur,r,"no parent cell");const i=U(r);if(u(ur,i,"no parent block"),i===t)return r;o=i}return u(ur,!1,"filed to get cell by child block id"),null}function Yn(n,t,e){if(n.getBlockById(e.blockId)===t&&!e.isSimple())return u(ur,e.childContainerId,"block position must have childContainerId attribute"),e;const r=WB(n,t,e.blockId),i=V(Ls(r));return Bt(t,i)}function Wh(n,t){const e=n.selection.range,o=Yn(n,t,e.start),r=Yn(n,t,e.end);return dn(t,o,r)}function H5(n,t,e,o){u(ur,Zt(t),"invalid table block");const r=Sn(n,t),i=()=>{const l=r.querySelector(".table-border-bar-container.top");u(ur,l,"no top border bar container"),l.querySelectorAll(".table-border-bar-cell.top").forEach(a=>{const d=parseInt(a.getAttribute("data-top-index")||"0",10);o.includes(d)?M(a,"danger"):H(a,"danger")})},s=()=>{const l=r.querySelector(".table-border-bar-container.left");u(ur,l,"no left border bar container"),l.querySelectorAll(".table-border-bar-cell.left").forEach(a=>{const d=parseInt(a.getAttribute("data-left-index")||"0",10);e.includes(d)?M(a,"danger"):H(a,"danger")})};i(),s()}function xo(n,t,e=!0,o){const i=nt.fromBlock(t).map(d=>d),{fromCol:s,toCol:l,fromRow:c,toRow:a}=Wh(n,t);for(let d=0;d<i.length;d++){const f=i[d];for(let m=0;m<f.length;m++){const p=f[m],A=o?m>=s&&m+p.colSpan-1<=l:d>=c&&d+p.rowSpan-1<=a;e&&A?p.virtual||M(p.cell,"danger"):p.virtual||H(p.cell,"danger")}}}function To(n,t,e=!0,o){const r=new Set,i=new Set;if(!e){H5(n,t,Array.from(r),Array.from(i));return}const{fromCol:s,toCol:l,fromRow:c,toRow:a}=Wh(n,t);if(o)for(let d=s;d<=l;d++)i.add(d);else for(let d=c;d<=a;d++)r.add(d);H5(n,t,Array.from(r),Array.from(i))}function j5(n,t,e){const{fromCol:o,toCol:r,fromRow:i,toRow:s}=Wh(n,t),l=nt.fromBlock(t);let c=null,a=null;return e?(c=l.getCell({col:o,row:0}),a=l.getCell({col:r,row:l.rowCount-1}),Wt(n,{anchor:Bt(t,c.containerId,{colIndex:o,rowIndex:0}),focus:Bt(t,a.containerId,{colIndex:r,rowIndex:l.rowCount-1})})):(c=l.getCell({col:0,row:i}),a=l.getCell({col:l.colCount-1,row:s}),Wt(n,{anchor:Bt(t,c.containerId,{colIndex:0,rowIndex:i}),focus:Bt(t,a.containerId,{colIndex:l.colCount-1,rowIndex:s})}))}function GB(n,t){const e=n.selection.range,o=Yn(n,t,e.start),r=Yn(n,t,e.end);return qh(n,t,o,r)}const z5=["style-bg-color-0","style-bg-color-1","style-bg-color-2","style-bg-color-3","style-bg-color-4","style-bg-color-5","style-bg-color-6","style-bg-color-7","style-bg-color-8","style-bg-color-9","style-bg-color-10","style-bg-color-11","style-bg-color-12","style-bg-color-13"];function U5(n){return`style-bg-color-${n}`}function Ns(n){return`${n}_background`}function ZB(n,t,e){const o=jt(n),s=(e!=null?e:nt.fromTable(o)).getCell(t).cell;for(let l=0;l<z5.length;l++){const c=z5[l];if(rt(s,c))return c}}function V5(n,t,e){if(!n.isBlockWritable(t))return;const o=n.selection.range,i={...Q.default(n.getBlockData(t))},s=Yn(n,t,o.start),l=Yn(n,t,o.end);if(o.isSimple()){const c=s.childContainerId;e===-1?i[Ns(c)]=void 0:i[Ns(c)]=U5(e)}else{const c=nt.fromBlock(t),a=dn(t,s,l),d=new Set;for(let f=a.fromRow;f<=a.toRow;f++)for(let m=a.fromCol;m<=a.toCol;m++){const p=c.getCell({row:f,col:m});!d.has(p.containerId)&&p.col>=a.fromCol&&p.row>=a.fromRow&&p.col+p.colSpan-1<=a.toCol&&p.row+p.rowSpan-1<=a.toRow&&(d.add(p.containerId),e===-1?i[Ns(p.containerId)]=void 0:i[Ns(p.containerId)]=U5(e))}}n.updateBlockData(t,i)}function QB(n,t,e){if(!n.isBlockWritable(t))return;const r={...Q.default(n.getBlockData(t)),chart:e};n.updateBlockData(t,r)}const q5=w("table-chart");function YB(n,t){const e=Sn(n,t);if(e){const o=e.querySelector(".editor-table-chart");if(o){const r=o.chartObject;r&&r.destroy(),o.remove()}}}async function JB(n,t){if(!n.isBlockWritable(t))return;if(!!!n.getBlockData(t).chart){YB(n,t);return}const r=[],i=nt.fromBlock(t),s=["line","bar","pie","radar"];let l=i.getCell({row:0,col:0}).container.innerText.trim().toLowerCase();new Set(s).has(l)||(l=s[0]);const c=[];for(let k=1;k<i.colCount;k++)c.push(i.getCell({row:0,col:k}).container.innerText);for(let k=1;k<i.rowCount;k++){const v=i.getCell({row:k,col:0}),E=v.container.innerText,L=[];for(let de=1;de<i.colCount;de++){const oo=i.getCell({row:k,col:de}).container.innerText,re=Number.parseFloat(oo)||0;L.push(re)}let R;const $=ZB(t,v,i);$?R=window.getComputedStyle(n.rootElement).getPropertyValue(`--${$}`).trim():R=window.getComputedStyle(n.rootElement).getPropertyValue("--background-color").trim();let[q,ot,lt,gt]=R?su.fromString(R).toRgbaArray():[];if(!q&&!ot&&!lt&&!gt){const de=(k-1)%n.options.colors.length;R=n.options.colors[de],[q,ot,lt,gt]=su.fromString(R).toRgbaArray()}const ht=R,kt=su.fromRgba([q,ot,lt,gt/3]).toHexString();r.push({label:E,data:L,borderColor:ht,backgroundColor:kt,borderWidth:2})}const a=Sn(n,t);let d=null,f=a.querySelector(".editor-table-chart");f?d=f.chartObject:f=b("div",["editor-table-chart"],a);const m=f;u(q5,m,"no chart container");const p=n.getComponentOptions("table"),A=(p==null?void 0:p.chartCdn)||"https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";try{await qo(A,"editor-chartjs"),d&&l!==d.config.type&&(d.destroy(),d=null,Array.from(f.querySelectorAll(".editor-chartjs-canvas")).forEach(T=>{T.remove()}));const k=lu.default({},{type:l,data:{datasets:r,labels:c},options:{onClick:()=>{n.selection.selectBlock(t,0,0)}}});if(d)lu.default(d.config,k),d.update();else{const T=b("canvas",["editor-chartjs-canvas"],m).getContext("2d");d=new window.Chart(T,k),f.chartObject=d}}catch(k){q5.error(`failed to resolve chart cdn: ${JSON.stringify(k)}`)}}async function W5(n,t){await Ge.lock("updateTableChart");try{await JB(n,t)}finally{Ge.release("updateTableChart")}}const G5=ee.default(W5,1e3);let Z5=null;function Gh(n,t,e){if(Z5!==t&&(G5.flush(),Z5=t),e.updateNow){W5(n,t);return}G5(n,t)}function Zh(n,t){Zt(t)&&Gh(n,t,{updateNow:!1})}function KB(n,t){Zt(t)&&Gh(n,t,{updateNow:!0})}const He={SCROLL:"container-scroll-tool",COMMON:"container-border-shadow",RIGHT:"container-right-border-shadow",LEFT:"container-left-border-shadow",LAYOUT_SIGN:"container-layout-border-shadow",ACTIVE:"active"},Pc={SCROLL_BAR:"container-scrollbar",FIXED:"fixed"},So={SCROLL_CONTAINER:"scroll-container",TOOL:"container-scroll-tool",CONTAINER:"scroll-container-root",MAC:"mac",SCROLL_AREA:"scroll-area"};function $c(n,t){return n.containers.get(t)}function Q5(n){return n.closest(`.${So.SCROLL_CONTAINER}`)}function hn(n){return n.firstElementChild}function Oe(n){return n.closest(`.${So.CONTAINER}`)}function Ps(n){const t=Oe(n);let e=t.querySelector(`:scope >.${So.TOOL}`);return e||(e=b("div",[So.TOOL],t)),e}function XB(n){return Oe(n).firstElementChild}function _c(n){let t;return n instanceof HTMLElement?t=n.offsetWidth:t=Number.parseInt(getComputedStyle(n).width,10),n.getBoundingClientRect().width/t}function je(n,t){const e=_c(n);return t/e}function $s(n){const t=window.getComputedStyle(n),e=_c(n);return{paddingBottom:parseFloat(t.paddingBottom)*e,paddingTop:parseFloat(t.paddingTop)*e,paddingLeft:parseFloat(t.paddingLeft)*e,paddingRight:parseFloat(t.paddingRight)*e}}function Kr(n){const t=_c(n);return{scrollLeft:n.scrollLeft*t,scrollWidth:n.scrollWidth*t,clientWidth:n.clientWidth*t,clientHeight:n.clientHeight*t}}function tE(n,t){const e=_c(n);return n[t]*e}function Qh(n,t){const e=Oe(t),o=$c(n,e),r=(o==null?void 0:o.safeRightSpace)||0,i=(o==null?void 0:o.safeLeftSpace)||0,l=(o==null?void 0:o.locatingContainer).getBoundingClientRect(),c=e.getBoundingClientRect(),a=c.width;let d=Math.floor(c.left-l.left-i);d<0&&(d=0);let f=l.right;f-=r;let m=f-c.right;return m<0&&(m=0),d=Math.round(d),m=Math.round(m),{originWidth:a,maxLeft:d,maxRight:m}}function eE(n,t){const e=Qh(n,t),{maxLeft:o}=e;t.style.marginLeft=`${je(t,0-o)}px`,t.style.paddingLeft=`${je(t,o)}px`}function nE(n,t){const e=Qh(n,t);t.style.marginRight=`${je(t,0-e.maxRight)}px`}function oE(n){if(n!==document.documentElement&&n!==document.body)return n.getBoundingClientRect();const t=0,e=0,o=document.documentElement.clientWidth,r=document.documentElement.clientHeight;return new DOMRect(t,e,o,r)}const Y5=w("scroll-bar-handle"),rE=2;function Xr(n){const t=Ps(n);let e=t.querySelector(`.${Pc.SCROLL_BAR}`);return e||(e=b("div",[Pc.SCROLL_BAR],t)),u(Y5,e instanceof HTMLDivElement,"invalid child for container tools"),e.firstElementChild||b("div",[],e),e}function Fc(n,t){const e=Q5(t),o=Xr(e),{scrollWidth:r,clientWidth:i}=Kr(e),{paddingLeft:s,paddingRight:l}=$s(t);e.style.marginLeft="",e.style.paddingLeft="",e.style.marginRight="";const c=Qh(n,e),{originWidth:a,maxRight:d}=c;nE(n,e),eE(n,e);const f=r-i;u(Y5,o.firstElementChild instanceof HTMLDivElement,"invalid child for scroll bar"),o.style.width=`${je(e,a+d-s-l)}px`,o.firstElementChild.style.width=`${je(e,a+d+f-s-l)}px`}function iE(n,t){const e=hn(n),{paddingLeft:o}=$s(e);if(rt(t,"fixed")){const i=Oe(n).getBoundingClientRect();t.style.left=`${je(n,i.left+o)}px`}else t.style.left=`${je(n,o)}px`}function ti(n,t){var E;const e=n.getParentScrollContainer(),o=oE(e),r=t.getBoundingClientRect(),i=Xr(t),s=i.getBoundingClientRect(),l=$c(n,Oe(t)),c=(l==null?void 0:l.barFloatWindowBottom)||0,a=hn(t),{paddingTop:d,paddingBottom:f}=$s(a),{scrollWidth:m,clientWidth:p}=Kr(t),A=document.documentElement.clientHeight-c,k=o.top+Kr(e).clientHeight-A,v=A+Math.min(0,k);if(m>p&&r.top+d<v-s.height&&r.bottom>v-s.height+f&&!((E=l==null?void 0:l.isSetScale)!=null&&E.call(l))){M(i,Pc.FIXED);const L=k>0?c:0;i.style.bottom=`${Math.max(document.documentElement.clientHeight-o.bottom,0)+rE+L}px`}else H(i,Pc.FIXED),i.style.bottom=`${je(t,f-s.height)}px`;iE(t,i)}class sE{constructor(t,e){h(this,"intersectionObserver");h(this,"handleIntersection",t=>{t.forEach(e=>{this.containers.get(Oe(e.target))?(this.handleIntersectionEntry(e),this.callback(e)):this.intersectionObserver.unobserve(e.target)})});h(this,"handleIntersectionEntry",t=>{const e=t.target;ti(this.scrollCore,e);const o=hn(e);Fc(this.scrollCore,o)});this.scrollCore=t,this.callback=e;const r={root:this.scrollCore.getParentScrollContainer(),rootMargin:"20px",threshold:0};this.intersectionObserver=new IntersectionObserver(this.handleIntersection,r)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.intersectionObserver.observe(t)}unbind(t){this.intersectionObserver.unobserve(t)}destroy(){this.intersectionObserver.disconnect()}}const dr=w("container-scroll-shadow");function J5(n,t,e){const o=n,r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),{paddingTop:s,paddingBottom:l}=$s(e);o.style.top=`${je(t,i.top-r.top+s)}px`,o.style.bottom=`${je(t,r.bottom-i.bottom+l)}px`}function K5(n,t){const e=n;t<24?e.style.width=`${(t/3).toFixed(2)}px`:e.style.width=""}function lE(n){const t=Ps(n);u(dr,t,"no container tools");let e=t.querySelector(`.${He.LEFT}`);if(!e){const l=hn(n),c=[He.COMMON,He.LEFT];e=b("div",c,t),u(dr,e instanceof HTMLDivElement,"invalid child for container tools"),J5(e,n,l)}u(dr,e instanceof HTMLElement,"invalid child for container tools");const r=Oe(n).getBoundingClientRect(),i=n.getBoundingClientRect();e.style.left=`${je(n,i.left-r.left)}px`;const s=Kr(n).scrollLeft;u(dr,e instanceof HTMLDivElement,"invalid child for container tools"),K5(e,s),M(e,He.ACTIVE)}function cE(n){const t=Ps(n);let e=t.querySelector(`.${He.RIGHT}`);if(!e){const d=hn(n),f=[He.COMMON,He.RIGHT];e=b("div",f,t),u(dr,e instanceof HTMLDivElement,"no div, create shadow failed"),J5(e,n,d)}u(dr,e instanceof HTMLElement,"");const r=Oe(n).getBoundingClientRect(),i=n.getBoundingClientRect();e.style.right=`${je(n,r.right-i.right)}px`;const{scrollWidth:s,scrollLeft:l,clientWidth:c}=Kr(n),a=s-l-c;u(dr,e instanceof HTMLDivElement,"no shadow element"),K5(e,a),M(e,He.ACTIVE)}function aE(n){const e=Ps(n).querySelector(`.${He.LEFT}`);e&&H(e,He.ACTIVE)}function uE(n){const e=Ps(n).querySelector(`.${He.RIGHT}`);e&&H(e,He.ACTIVE)}function _s(n){const{scrollLeft:t,scrollWidth:e,clientWidth:o}=Kr(n),r=hn(n),{paddingLeft:i,paddingRight:s}=$s(r),l=tE(r,"offsetLeft");e-i<=o-s||e-i<=t+o-s?uE(n):cE(n),r&&t>=l+i?lE(n):aE(n)}class dE{constructor(t,e){h(this,"resizeObserver");h(this,"handleResizeEntry",t=>{const e=t.target,o=hn(e);_s(e),Fc(this.scrollCore,o),ti(this.scrollCore,e),this.callback(e)});h(this,"handleContentResize",t=>{t.forEach(e=>{this.containers.get(Oe(e.target))?this.handleResizeEntry(e):this.unbind(e.target)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new ResizeObserver(this.handleContentResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}const X5=w("container-scroll-observer");class hE{constructor(t,e){h(this,"handleContentScroll",t=>{const e=t.target;u(X5,e instanceof Element,"invalid target for scroll event");const o=Xr(e);o.removeEventListener("scroll",this.handleScroll);const r=!0;this.fixScrollXPos(e,e.scrollLeft,r),this.bind(o),_s(e),this.callback(e)});h(this,"handleScroll",t=>{const e=t.target;u(X5,e instanceof HTMLElement,"");const o=e.scrollLeft,r=!1,i=XB(e);this.unbindContentScroll(i),this.fixScrollXPos(i,o,r),this.bindContentScroll(i),_s(i),this.callback(i)});h(this,"handlePrevent",t=>{t.stopPropagation()});h(this,"bindContentScrollCore",t=>{this.unbindContentScroll(t),t.addEventListener("scroll",this.handleContentScroll)});h(this,"unbindContentScroll",t=>{t.removeEventListener("scroll",this.handleContentScroll)});h(this,"bindContentScroll",ee.default(this.bindContentScrollCore,300));h(this,"bind",ee.default(this.bindCore,200));this.scrollCore=t,this.callback=e}fixScrollXPos(t,e,o){const r=Xr(t);o||(t.scrollLeft=e),o&&r.scrollLeft!==e&&(r.scrollLeft=e)}bindCore(t){this.unbind(t),t.addEventListener("scroll",this.handleScroll),t.addEventListener("mousedown",this.handlePrevent)}unbind(t){t.removeEventListener("scroll",this.handleScroll),t.removeEventListener("mousedown",this.handlePrevent)}}class fE{constructor(t){h(this,"scrollContainers",new Set);h(this,"handleParentContainerScroll",()=>{this.scrollContainers.forEach(t=>{ti(this.scrollCore,t)})});h(this,"bindScrollContainer",t=>{const e=this.scrollContainers.size===0;this.scrollContainers.add(t),e&&this.eventTarget.addEventListener("scroll",this.handleParentContainerScroll)});h(this,"unbindScrollContainer",t=>{let e=!1;this.scrollContainers.has(t)&&(this.scrollContainers.delete(t),e=this.scrollContainers.size===0),e&&this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll)});this.scrollCore=t}get eventTarget(){const t=this.scrollCore.getParentScrollContainer();return t===document.documentElement?document:t}destroy(){this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll),this.scrollContainers.clear()}}const mE=w("scroll-wrap-resize-observer");class gE{constructor(t){h(this,"resizeObserver");h(this,"handleScrollWrapResize",t=>{t.forEach(e=>{this.containers.get(Oe(e.target))?this.handleScrollWrapResizeEntry(e):this.unbind(e.target)})});h(this,"handleScrollWrapResizeEntry",t=>{const e=t.target;u(mE,e instanceof HTMLElement,"invalid target for observer entry");const o=Q5(e);Fc(this.scrollCore,e),_s(o),ti(this.scrollCore,o)});this.scrollCore=t,this.resizeObserver=new ResizeObserver(this.handleScrollWrapResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}class pE{constructor(t,e){h(this,"resizeObserver");h(this,"scrollContainersMap",new Map);h(this,"handleResizeEntry",t=>{t==null||t.forEach(e=>{const o=hn(e);_s(e),Fc(this.scrollCore,o),ti(this.scrollCore,e),this.callback(e)})});h(this,"handleResize",t=>{t.forEach(e=>{const o=this.scrollContainersMap.get(e.target);o!=null&&o.length&&this.handleResizeEntry(o)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new ResizeObserver(this.handleResize)}bind(t){var r,i;const e=Oe(t),o=(r=$c(this.scrollCore,e))==null?void 0:r.locatingContainer;this.scrollContainersMap.has(o)?(i=this.scrollContainersMap.get(o))==null||i.push(t):(this.scrollContainersMap.set(o,[t]),this.resizeObserver.observe(o))}unbind(t){var i,s;const e=Oe(t),o=(i=$c(this.scrollCore,e))==null?void 0:i.locatingContainer;if(!o)return;const r=this.scrollContainersMap.get(o);this.scrollContainersMap.set(o,(r==null?void 0:r.filter(l=>l!==t))||[]),(s=this.scrollContainersMap.get(o))!=null&&s.length||(this.resizeObserver.unobserve(o),this.scrollContainersMap.delete(o))}destroy(){this.scrollContainersMap.clear(),this.resizeObserver.disconnect()}}const sV="";class CE extends Yt.TypedEmitter{constructor(e){super();h(this,"containerIntersectionObserver",null);h(this,"containerResizeObserver",null);h(this,"containerScrollObserver",null);h(this,"parentContainerScrollObserver",null);h(this,"scrollWrapResizeObserve",null);h(this,"locatingContainerResizeObserver",null);h(this,"isWindowEventBind",!1);h(this,"containers",new Map);h(this,"handleScrollContainerScroll",e=>{this.emit("scroll",this,e)});h(this,"handleResize",e=>{this.emit("resize",this,e)});h(this,"handleIntersection",e=>{const o=e.target,r=hn(o);e.isIntersecting?(this.load(),this.bindCore(o,r)):this.unbindCore(o,r)});h(this,"handleWindowEffect",()=>{var e;(e=this.getScrollContainerInViewable())==null||e.forEach(o=>{ti(this,o)})});this.parentContainer=e}load(){this.containerResizeObserver||(this.containerResizeObserver=new dE(this,this.handleResize)),this.containerScrollObserver||(this.containerScrollObserver=new hE(this,this.handleScrollContainerScroll)),this.parentContainerScrollObserver||(this.parentContainerScrollObserver=new fE(this)),this.scrollWrapResizeObserve||(this.scrollWrapResizeObserve=new gE(this)),this.locatingContainerResizeObserver||(this.locatingContainerResizeObserver=new pE(this,this.handleResize)),this.isWindowEventBind||(window.addEventListener("resize",this.handleWindowEffect),this.getParentScrollContainer()!==document.documentElement&&window.addEventListener("scroll",this.handleWindowEffect))}getParentScrollContainer(){return this.parentContainer}getScrollContainerInViewable(){var e;return(e=this.parentContainerScrollObserver)==null?void 0:e.scrollContainers}unbindCore(e,o){var i,s,l,c,a,d;const r=Xr(e);(i=this.containerScrollObserver)==null||i.unbindContentScroll(e),(s=this.containerScrollObserver)==null||s.unbind(r),(l=this.scrollWrapResizeObserve)==null||l.unbind(o),(c=this.containerResizeObserver)==null||c.unbind(e),(a=this.parentContainerScrollObserver)==null||a.unbindScrollContainer(e),(d=this.locatingContainerResizeObserver)==null||d.unbind(e)}bindCore(e,o){var i,s,l,c,a,d;if(this.unbindCore(e,o),!e.closest("body"))return;const r=Xr(e);(i=this.containerScrollObserver)==null||i.bindContentScrollCore(e),(s=this.containerScrollObserver)==null||s.bindCore(r),(l=this.scrollWrapResizeObserve)==null||l.bind(o),(c=this.containerResizeObserver)==null||c.bind(e),(a=this.parentContainerScrollObserver)==null||a.bindScrollContainer(e),(d=this.locatingContainerResizeObserver)==null||d.bind(e)}bind(e,o){this.containers.set(e,o);const r=e.firstElementChild;this.containerIntersectionObserver||(this.containerIntersectionObserver=new sE(this,this.handleIntersection)),this.containerIntersectionObserver.bind(r)}unbind(e){var i;const o=e.firstElementChild,r=hn(o);this.unbindCore(o,r),this.containers.delete(e),(i=this.containerIntersectionObserver)==null||i.unbind(o),this.containers.size||this.destroy()}destroy(){var e,o,r,i,s;this.containers.forEach((l,c)=>{this.unbind(c)}),this.containers.clear(),(e=this.parentContainerScrollObserver)==null||e.destroy(),(o=this.containerIntersectionObserver)==null||o.destroy(),(r=this.containerResizeObserver)==null||r.destroy(),(i=this.scrollWrapResizeObserve)==null||i.destroy(),(s=this.locatingContainerResizeObserver)==null||s.destroy(),window.removeEventListener("resize",this.handleWindowEffect),window.removeEventListener("scroll",this.handleWindowEffect)}}const tC=w("scroll-container"),Hc=new Map;class AE extends Yt.TypedEmitter{constructor(){super(...arguments);h(this,"scrollListener");h(this,"options");h(this,"scrollContainerElement");h(this,"init",e=>{this.options=e;const o=b("div",[So.CONTAINER],e.parentElement);xt.isMac&&M(o,So.MAC);const r=b("div",[So.SCROLL_CONTAINER],o),i=b("div",[So.SCROLL_AREA],r);i.style.paddingLeft=e.paddingLeft?`${e.paddingLeft}px`:"",i.style.paddingTop=e.paddingTop?`${e.paddingTop}px`:"",i.style.paddingBottom=e.paddingBottom?`${e.paddingBottom}px`:"",i.style.paddingRight=e.paddingRight?`${e.paddingRight}px`:"",i.appendChild(e.childElement);const s=e.parentContainer;this.scrollListener=Hc.get(s),this.scrollListener||(this.scrollListener=new CE(s),Hc.set(s,this.scrollListener)),this.scrollListener.unbind(o),this.scrollListener.bind(o,e),this.scrollListener.on("scroll",this.handleContainerScroll),this.scrollListener.on("resize",this.handleResize),this.scrollContainerElement=r});h(this,"handleContainerScroll",(e,o)=>{o===this.scrollContainerElement&&this.emit("scroll",this)});h(this,"handleResize",(e,o)=>{o===this.scrollContainerElement&&this.emit("scroll",this)})}get rootElement(){return this.scrollContainerElement}get contentElement(){return u(tC,this.scrollContainerElement,"scrollContainerElement cannot be undefined"),hn(this.scrollContainerElement)}get scrollOptions(){return u(tC,this.options,"options cannot be undefined"),{...this.options}}handleBaseListenerDestroy(e){e.destroy()}destroy(){var o;(o=this.scrollListener)==null||o.off("scroll",this.handleContainerScroll);const e=Oe(this.contentElement);e&&Hc.forEach((r,i)=>{r.unbind(e),r.containers.size===0&&(this.handleBaseListenerDestroy(r),Hc.delete(i))})}}function bE(){return new AE}const jc=100,vE=40,Yh=w("column-width");function yE(n,t,e){IB(n,t).style.width=`${e}px`}function kE(n){const e=Array.from(n.querySelector("colgroup").children).map(c=>c.getBoundingClientRect().width);if(e[0]!==0)return e;const o=nt.fromTable(n),r=Array(o.colCount).fill(-1),i=n.getBoundingClientRect().left;o.toRealCells(o.cells).forEach(c=>{const a=c.col+c.colSpan-1;r[a]===-1&&(r[a]=c.cell.getBoundingClientRect().right-i)}),Yh.debug(`cellRightOffsets1: ${r.join()}`);for(let c=0;c<r.length;c++){const a=r[c];if(a===-1||c===0)continue;let d=c-1;for(;r[d]===-1&&(d--,d!==-1););const f=d===-1?0:r[d],p=(a-f)/(c-d);for(let A=d+1;A<c;A++)r[A]=f+p*(A-d)}Yh.debug(`cellRightOffsets2: ${r.join()}`);const s=[];let l=0;for(let c=0;c<r.length;c++){const a=r[c];s.push(a-l),l=a}return Yh.debug(`widths: ${s.join()}`),s}function Fs(n){return Array.from(n.querySelector("colgroup").children).map(o=>o.getBoundingClientRect().width||Number.parseInt(o.style.width,10)||100)}const wE=w("table-resize-gripper"),eC=7,Jh=(eC-1)/2,BE=3;function EE(n,t,e){const{rows:o}=n;for(let r=0;r<o.length;r++){const i=o[r],s=Array.from(i.cells);for(let l=0;l<s.length;l++){const c=s[l],a=c.getBoundingClientRect(),d=Math.round(a.right);if(Math.abs(t-d)<=Jh&&a.top<=e&&e<=a.bottom)return c}}return null}function IE(n){return!!n.rootContainer.querySelector(".table-resize-gripper")}function Kh(n,t){return Sn(n,t).querySelector(".table-resize-gripper")}function nC(n,t){const e=Kh(n,t);u(wE,!e,"resize gripper has already exists");const o=Sn(n,t),r=b("div",["table-resize-gripper","table-indicator"],o);return b("div",["table-resize-gripper-indicator"],r),r}function oC(n,t,e){let o=Kh(n,t);o||(o=nC(n,t));const i=jt(t).getBoundingClientRect(),s=e.getBoundingClientRect(),l=0,c=i.height,a=n.getCustom(Io(t)).contentElement.getBoundingClientRect(),d=s.right-a.left;o.style.left=`${d-Jh-zh-Os}px`,o.style.top=`${l}px`,o.style.height=`${c}px`,o.style.width=`${eC}px`}function Xh(n){n.rootContainer.querySelectorAll(".table-resize-gripper").forEach(t=>{t.remove()})}function xE(n,t,e){const r={...n.getBlockData(t),colsWidth:e};n.updateBlockData(t,r)}function TE(n,t,e,o){const r=t,i=nt.fromTable(e),s=i.getCellByCellElement(r),l=s.col+s.colSpan-1,c=Fs(e);let a=o;const d=(m,p)=>{const A=p+1,k=m.col+m.colSpan;return c.slice(A,k).reduce((T,E)=>T+E,0)},f=new Set;for(let m=0;m<i.rowCount;m++){const p=i.getCell({row:m,col:l});if(f.has(p.cell))continue;f.add(p.cell);const A=p.cell,k=A.getBoundingClientRect();let v=o-k.left+Jh-BE;const T=Ls(A),E=gd(n,T)||vE*p.colSpan,L=d(p,l),R=E-L;v<R&&(v=R);const $=k.left+v;a=Math.max(a,$)}return a}const SE=w("table-resize-drag-drop");class DE{constructor(t,e,o,r){h(this,"cursor","col-resize");this.editor=t,this.elem=e,this.data=o,this.onEnd=r}onDragStart(t,e,o){}onDragging(t,e,o,r,i){const{table:s,block:l,draggingRefCell:c}=t.data,d=TE(this.editor,c,s,e.x-t.dragOffsetX)-s.getBoundingClientRect().left;u(SE,c,"no dragging cell");const m=nt.fromTable(s).getCellByCellElement(c),p=m.col+m.colSpan-1,k=Fs(s).slice(0,p).reduce((T,E)=>T+E,0),v=d-k;yE(s,p,v),oC(this.editor,l,c),this.editor.selection.caret.update()}onDragEnd(t,e,o,r,i){const s=Fs(t.data.table);xE(this.editor,t.data.block,s),Xh(this.editor),this.onEnd&&(this.onEnd(e),this.onEnd=null)}}function LE(n,t){const e=document.elementFromPoint(t.x,t.y);if(!e)return null;const o=U(e);return!o||!n.contains(o)||!Zt(o)?null:o}w("table-resize");class ME{constructor(t){h(this,"draggingRefCell",null);h(this,"handleMouseMove",(t,e)=>{if(t.readonly||t.selectionHandler.isSelecting()&&!this.draggingRefCell||this.draggingRefCell)return;const o=e.target;if(!(o instanceof Element)||o.closest(".table-indicator"))return;const i=e,s=LE(t,i);if(!s||!M5(s)||!t.isBlockWritable(s)){Xh(t);return}this.updateGripper(s,i.x,i.y)});this.editor=t,t.domEvents.addEventListener(document,"mousemove",this.handleMouseMove)}destroy(){this.editor.domEvents.removeEventListener(document,"mousemove",this.handleMouseMove)}updateGripper(t,e,o){const r=jt(t),i=EE(r,e,o);if(i){if(!Kh(this.editor,t)){if(IE(this.editor))return;const l=nC(this.editor,t),c={block:t,table:r,draggingRefCell:i};Cu(new DE(this.editor,l,c,a=>{this.updateGripper(t,a.x,a.y)}))}oC(this.editor,t,i)}else Xh(this.editor)}}function rC(n){n.addCustom("table-mouse-event-handler",t=>new ME(t))}const iC=w("table-insert-column");function sC(n,t,e){n.undoManager.runInGroup(()=>{const o=jt(t),r=nt.fromTable(o),i=r.colCount;u(iC,e>=0&&e<=i,`insert index ${e} is out of range [0, ${i}]`);const s=r.map(m=>m.containerId),l=new Set;n.doc.beginBatchUpdate();for(let m=0;m<s.length;m++){const p=s[m],A=p[e-1],k=p[e];if(e===0||e===p.length||A!==k){const v=Bn(n.doc);p.splice(e,0,v)}else p.splice(e,0,A),l.add(A)}n.doc.endBatchUpdate();const c=Q.default(n.getBlockData(t));l.forEach(m=>{const p=`${m}_colSpan`,A=c[p];u(iC,typeof A=="number"&&A>1,`no colSpan for containerId ${m}, ${A}`),c[p]=A+1});const a=c.colsWidth.concat();a.splice(e,0,jc);const d=nt.virtualCellContainersGridToChildren(s),f={...c,cols:c.cols+1,children:d,colsWidth:a};ar(f),n.updateBlockData(t,f)})}const zc=w("table-insert-row");function lC(n,t,e){n.undoManager.runInGroup(()=>{const o=jt(t),r=nt.fromTable(o),i=r.rowCount;u(zc,e>=0&&e<=i,`insert index ${e} is out of range [0, ${i}]`);const s=r.map(m=>m.containerId),l=new Set;n.doc.beginBatchUpdate();const c=[];for(let m=0;m<r.colCount;m++){const p=e>0&&s[e-1][m],A=e<r.rowCount&&s[e][m];if(u(zc,p||A,"no top and bottom cell"),e===0||e===r.rowCount||p!==A){const k=Bn(n.doc);c.push(k)}else u(zc,p,"no top cell"),c.push(p),l.add(p)}n.doc.endBatchUpdate(),s.splice(e,0,c);const a=Q.default(n.getBlockData(t));l.forEach(m=>{const p=`${m}_rowSpan`,A=a[p];u(zc,typeof A=="number"&&A>1,`no rowSpan for containerId ${m}, ${A}`),a[p]=A+1});const d=nt.virtualCellContainersGridToChildren(s),f={...a,rows:a.rows+1,children:d};ar(f),n.updateBlockData(t,f)})}const t1=w("paste-table-in-table-block");function RE(n,t,e,o){let r=nt.fromBlock(e);const i=t.blocks.root[0];u(t1,i,"no table data"),u(t1,i.type==="table",`table data type is not table, but ${i.type}`);const s=i,l=r.getCellByCellElement(o),c=s.cols,a=s.rows,d=l.col,f=l.row,m=d+c,p=f+a,A=[];for(let k=d;k<m&&k<r.colCount;k++)for(let v=f;v<p&&v<r.rowCount;v++){const T=r.getCell({col:k,row:v});T.virtual?T.virtual&&A.push({col:k,row:v}):(T.colSpan>1||T.rowSpan>1)&&A.push({col:k,row:v})}n.undoManager.runInGroup(()=>{if(A.forEach(E=>{const L=nt.fromBlock(e).getCell(E);(L.colSpan>1||L.rowSpan>1)&&_h(n,e,E)}),m>r.colCount)for(let E=r.colCount;E<m;E++)sC(n,e,E);if(p>r.rowCount)for(let E=r.rowCount;E<p;E++)lC(n,e,E);r=nt.fromBlock(e);const k=new Mc(s);let v;for(let E=0;E<k.colCount;E++)for(let L=0;L<k.rowCount;L++){const R=k.getCell({col:E,row:L});if(!R.virtual){const $=Md(n.editorBlocks,t,R.containerId),q=d+E,ot=f+L,lt={col:q,row:ot},gt=r.getCellContainer(lt);s0(n,gt,$),v=gt}}u(t1,v,"no last container");const T=Jt(v);n.selection.selectBlock(T,G(n,T))})}const cC=w("paste-in-table-block");class OE{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePasteDoc(t,e){if(!t.selection.range.isSimple()||t.selection.range.start.offset!==0)return!1;const r=t.selection.startBlock,i=z(r);if(Ct(i)||!pd(t,i))return!1;const s=U(i);if(u(cC,s,"no parent block"),!Zt(s)||e.blocks.root.length!==1||e.blocks.root[0].type!=="table")return!1;cC.debug("paste child table in table");const a=nt.fromBlock(s).getCellByContainerId(V(i)).cell;return RE(t,e,s,a),!0}}function aC(n){n.addCustom("table-block-paste-event",t=>new OE(t))}const e1=w("table-select-columns");function NE(n,t,e,o,r){u(e1,Zt(t),"is not a table block");const i=nt.fromBlock(t);u(e1,e>=0&&e<i.colCount,"invalid from"),u(e1,o>0&&e+o<=i.colCount,"invalid count");const s=i.getCell({row:0,col:e}),l=i.getCell({row:i.rowCount-1,col:e+o-1}),c=Bt(t,s.containerId,{colIndex:e,rowIndex:0}),a=Bt(t,l.containerId,{colIndex:e+o-1,rowIndex:i.rowCount-1});r!=null&&r.reverse?n.selection.setSelection(a,c):n.selection.setSelection(c,a)}const n1=w("table-select-columns");function PE(n,t,e,o,r){u(n1,Zt(t),"is not a table block");const i=nt.fromBlock(t);u(n1,e>=0&&e<i.rowCount,"invalid from"),u(n1,o>0&&e+o<=i.rowCount,"invalid count");const s=i.getCell({row:e,col:0}),l=i.getCell({row:e+o-1,col:i.colCount-1}),c=Bt(t,s.containerId,{rowIndex:e,colIndex:0}),a=Bt(t,l.containerId,{rowIndex:e+o-1,colIndex:i.colCount-1});r!=null&&r.reverse?n.selection.setSelection(a,c):n.selection.setSelection(c,a)}const lV="",uC=w("get-toolbar-reference-client");function $E(n,t){const e=n.selection.range;if(!e.isSimple()){u(uC,e.start.blockId===e.end.blockId,"invalid selection range");const s=n.getBlockById(e.start.blockId);u(uC,at(n,s),"not a complex block");const l=pt(n,s);if(l.getTextToolbarReferenceClient){const c=l.getTextToolbarReferenceClient(n,s);if(c)return c}}const o=e.isReverse()?t.start:t.end,r=Wt(n,{anchor:o,focus:o}),i=co(n,t.block,r);if(i.length!==0)return i[0]}function _E(n){var t,e;if(n.children){let o=!1;const r=[];for(const i of n.children){if((t=i.states)!=null&&t.includes("checked")){o=!0;break}(e=n.defaultCheckedChildren)!=null&&e.includes(i.id)&&r.push(i)}if(!o&&(r==null?void 0:r.length))for(const i of r)Array.isArray(i.states)?i.states.push("checked"):i.states=["checked"]}}function Uc(n){const t=(r,i)=>{const s=r.findIndex(c=>c.id===i.id);if(s===-1){r.push(i);return}const l=r[s];if(l.value!==i.value&&delete l.value,!!l.states){if(!i.states){l.states=[];return}l.states=cu.default(l.states,i.states)}},e=[],o=new Map;return n.forEach(r=>{var i,s;(i=r.children)!=null&&i.length&&(o.has(r.id)?(s=o.get(r.id))==null||s.push(...r.children):o.set(r.id,[...r.children])),t(e,r)}),o.forEach((r,i)=>{const s=e.find(l=>l.id===i);s&&(s.children=Uc(r),_E(s))}),e}function Vc(n){return n.getCustom("toolbar-handler")}const cV="";class FE{constructor(){h(this,"linkPopup",null);h(this,"form",{});h(this,"onFinished",null);h(this,"onClose",null);h(this,"handleOk",async()=>{var t;try{await this.checkValue();const{linkText:e,linkUrl:o}=this.form,r=this.formatUrl(o.getInputValue());(t=this.onFinished)==null||t.call(this,e.getInputValue()||r,r),this._destroy()}catch{}});h(this,"handleClose",()=>{var t;(t=this.onClose)==null||t.call(this),this._destroy()});h(this,"onShow",()=>{setTimeout(()=>{var t;(t=this.form.linkText)==null||t.getField().focus()},400)});h(this,"onChange",()=>{var e;const t=(e=this.linkPopup)==null?void 0:e.content.querySelector(".submit-button");t.disabled=!1});h(this,"handleTextKeyboard",t=>{var e;if(!t.isComposing){if(t.key==="Enter"){(e=this.form.linkUrl)==null||e.getField().focus(),t.stopPropagation();return}t.key==="Escape"&&this.handleClose()}});h(this,"handleUrlKeyboard",t=>{if(!t.isComposing){if(t.key==="Enter"){this.handleOk(),t.preventDefault();return}t.key==="Escape"&&this.handleClose()}})}async checkValue(){const{linkUrl:t}=this.form;if(!t.getInputValue())throw t.setFieldError(x.t("link.urlPlaceholder")),new Error(x.t("link.urlPlaceholder"))}formatUrl(t){if(!t)return"";try{new URL(t)}catch{return`${window.location.protocol}//${t}`}return t}editLink(t){var d,f;const{target:e,linkText:o,linkUrl:r,onFinished:i,onClose:s,placement:l="bottom-start"}=t;this.linkPopup=new Is(this.createPopupContent(o,r)),this.linkPopup.addListener("show",this.onShow),this.linkPopup.manualShow(e,{theme:"light",placement:l}),this.onFinished=i,s&&(this.onClose=s);const c=(d=this.linkPopup)==null?void 0:d.content.querySelector(".submit-button"),a=(f=this.linkPopup)==null?void 0:f.content.querySelector(".cancel-button");c==null||c.addEventListener("click",this.handleOk),a==null||a.addEventListener("click",this.handleClose)}createPopupContent(t,e){const o=b("div",["link-popup-content"],null);this.form.linkText=Sh(o,{label:x.t("link.textLabel"),required:!1,placeholder:x.t("link.textPlaceholder"),defaultValue:t,onChange:this.onChange,onKeyDown:this.handleTextKeyboard}),this.form.linkUrl=Sh(o,{className:"link-popup-gap",label:x.t("link.urlLabel"),required:!0,placeholder:x.t("link.urlPlaceholder"),defaultValue:e,onChange:this.onChange,onKeyDown:this.handleUrlKeyboard});const r=b("div",["link-popup-footer"],o);b("button",["cancel-button"],r,x.t("link.cancelText"));const i=b("button",["submit-button"],r,x.t("link.submitText"));return i.disabled=!0,o}_destroy(){var o,r,i,s;const t=(o=this.linkPopup)==null?void 0:o.content.querySelector(".submit-button"),e=(r=this.linkPopup)==null?void 0:r.content.querySelector(".cancel-button");t==null||t.removeEventListener("click",this.handleOk),e==null||e.removeEventListener("click",this.handleClose),this.onFinished=null,this.onClose=null,this.form={},(i=this.linkPopup)==null||i.removeAllListeners(),(s=this.linkPopup)==null||s.destroy()}destroy(){this._destroy()}}function Hs(n,t){n.addCustom("link-editor",()=>new FE).editLink(t)}const HE=w("link-popup");function jE(n){return rt(n,"link")}function js(n){var t,e;return(e=(t=n.getAttribute("link"))!=null?t:n.textContent)!=null?e:""}function zE(n,t,e){var r,i,s,l;if(n.isBlockWritable(t)&&e&&Pe(e)){const c=e,a=(i=(r=n.editorBoxes.getBoxClass(ji(c))).getBoxProperties)==null?void 0:i.call(r,n,c);return a!=null&&a.boxCommands?(l=(s=a.boxCommands["hovering-toolbar"])==null?void 0:s.commands)!=null?l:[]:[]}if(n.isWritable()&&e&&_(n,t)&&jE(e)){const c=b("a",["link-href-button"],null,js(e));return c.href=js(e),c.target="_blank",c.rel="noopener noreferrer",[{id:"link-text",name:js(e),disableTooltip:!0,element:c},{id:"edit-link",name:"Edit",icon:xh},{id:"remove-link",name:"Remove link",icon:Nw}]}return Bg(n,t,"hovering-toolbar")}function UE(n,t,e){var c;const o=mo(t,e);n.selection.selectBlock(t,o.start,o.end);const r=(c=e.textContent)!=null?c:"",i=js(e);Hs(n,{target:e,linkText:r,linkUrl:i,onFinished:(a,d)=>{try{const f=n.getBlockText(t),m=ed(f,o.start,o.end-o.start),p=po(m,o.start,a,{link:d});n.setBlockText(t,p),n.selection.selectBlock(t,o.start+a.length),n.focus()}catch(f){HE.error(f)}},onClose:()=>{n.selection.selectBlock(t,o.end),n.focus()}})}function VE(n,t,e){const o=mo(t,e),r=n.getBlockText(t),i=js(e),s=Nr(o.start,o.end-o.start,r,"link",i);n.setBlockText(t,s),n.selection.selectBlock(t,o.end)}function qE(n,t,e,o){var s,l,c;if(e){if(n.isBlockWritable(t)&&Pe(e)){const d=e,f=(l=(s=n.editorBoxes.getBoxClass(ji(d))).getBoxProperties)==null?void 0:l.call(s,n,d);if(f!=null&&f.boxCommands){f.boxCommands["hovering-toolbar"].executeCommand(n,t,d,o);return}return}const a=Vc(n);a.disableTextToolbar(),a.hide(),setTimeout(()=>{a.enableTextToolbar()},1e4),o.id==="edit-link"?UE(n,t,e):o.id==="remove-link"&&VE(n,t,e);return}const r=wg(n,t);if(!r)return;const i=(c=r.blockCommands)==null?void 0:c["hovering-toolbar"];!i||i.executeCommand(n,t,o)}function qc(){let n=8;for(;n>0&&!document.querySelector(`div[data-style-heading='${n}']`);)n--;return n}const WE=[Ch,Ah,bh,vh,yh,kh,wh,Bh];class GE{constructor(t){h(this,"id","BlockTurnIntoCommandProvider");this.editor=t}getHeadingIndex(){let t=qc();return t<=4?t=5:t<8&&(t+=1),t}getAvailableCommands(t,e,o){if(_(t,e)){const r=j(e),i=it(e),s=Je(t,e),c=t.getBlockData(e).heading,a=[];for(let f=0;f<this.getHeadingIndex();f++)a.push({id:`heading-${f+1}`,name:x.t("commands.heading",{name:`${f+1}`}),icon:WE[f],states:c===f+1?["checked"]:[],value:`${f+1}`});const d=f=>{var p;const m=b("span",["toolbar-item-name-container"],null);for(const A of f.children)if((p=A.states)!=null&&p.includes("checked"))return m.innerHTML=A.icon||Lc,m;return m.innerHTML=Lc,m};return[{id:"turn-into",name:x.t("commands.headingGroup"),blockId:r,blockType:i,blockKind:s,element:d,groupIndex:200,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["text"],children:[{id:"text",name:x.t("commands.text"),icon:Lc,states:c?[]:["checked"]},...a],childrenType:"menu"}]}return[]}applyHeadingStyle(t,e,o){t.updateBlockData(e,{heading:o})}executeCommand(t,e,o,r){if(_(t,e)&&(r.id.startsWith("heading-")||r.id==="text")){const i=r.value?Number(r.value):null;return this.applyHeadingStyle(t,e,i),!0}return!1}}function Wc(n){const t=n.getAttribute("block-padding-level");return t?Number(t):null}function ZE(n,t){let e;const o=Wc(t);if(!o)e=1;else{if(o>=12)return e=12,!1;e=o+1}return n.updateBlockData(t,{...n.getBlockData(t),padding:e}),!0}function dC(n,t){const e=Wc(t);if(!e)return!1;const o=n.getBlockData(t);return e>1?(n.updateBlockData(t,{...o,padding:e-1}),!0):(n.updateBlockData(t,{...o,padding:null}),!0)}function o1(n){return n.readonly||!n.isWritable()}function QE(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const o=e.block;_(n,o)&&ZE(n,o)}),!0}function YE(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const o=e.block;_(n,o)&&dC(n,o)}),!0}function JE(n){return o1(n)?!1:n.undoManager.runInGroup(()=>(QE(n),!0))}function KE(n){return o1(n)?!1:n.undoManager.runInGroup(()=>(YE(n),!0))}function XE(n){if(o1(n))return!1;if(!n.selection.range.isCollapsed())return;const t=n.selection.focusedBlock;if(!_(n,t))return;const e=n.selection.range.focus;if(!(!e.isSimple()||e.offset!==0||!Wc(t)))return dC(n,t),!0}class tI{renderBlock(t,e,o){const{padding:r}=o;return r?{attributes:{"block-padding-level":r}}:{}}}const aV="",eI={Tab:JE,"Shift+Tab":KE,Backspace:XE},Gc=w("list-block");function ut(n){return it(n)==="list"}function zt(n){u(Gc,ut(n),"not a list block")}function ze(n){zt(n);const t=n.getAttribute("data-list-type");return u(Gc,t,"no list type"),t}function Zc(n){return ut(n)&&ze(n)==="text-only"}function Ue(n){var t,e;return zt(n),(e=Number.parseInt((t=n.getAttribute("data-list-start"))!=null?t:"1",10))!=null?e:1}function Ae(n){var t,e;return zt(n),(e=Number.parseInt((t=n.getAttribute("data-list-level"))!=null?t:"1",10))!=null?e:1}function ei(n){zt(n);const t=n.getAttribute("data-list-group-id");return u(Gc,t,"no group id"),t}function Do(n){var i,s,l,c,a;zt(n);const t=(i=n.getAttribute("data-list-type"))!=null?i:"ordered",e=(l=Number.parseInt((s=n.getAttribute("data-list-start"))!=null?s:"1",10))!=null?l:1,o=(a=Number.parseInt((c=n.getAttribute("data-list-level"))!=null?c:"1",10))!=null?a:1,r=n.getAttribute("data-list-group-id");return u(Gc,r,"no group id"),{type:t,start:e,level:o,groupId:r}}function r1(n){switch(n){case"ordered":return{ordered:!0,checkbox:null,textOnly:null};case"unordered":return{ordered:!1,checkbox:null,textOnly:null};case"checked":return{checkbox:"checked",ordered:!1,textOnly:null};case"unchecked":return{checkbox:"unchecked",ordered:!1,textOnly:null};case"text-only":return{checkbox:null,ordered:!1,textOnly:!0};default:return{checkbox:null,ordered:!0,textOnly:!1}}}function Lo(n,t){zt(n);const{level:e,groupId:o,type:r}=Do(n);let i=bt(n);for(;i;){if(!ut(i))return null;const{level:s,groupId:l,type:c}=Do(i);if(s<e)return null;if(e===s&&((t==null?void 0:t.ignoreGroupId)||o===l)&&(c==="text-only"||r==="text-only"||r===c))return i;i=bt(i)}return null}function hC(n){return Lo(n,{ignoreGroupId:!0})}function hr(n){zt(n);const{level:t,groupId:e,type:o}=Do(n);let r=dt(n);for(;r;){if(ut(r)){const{level:i,groupId:s,type:l}=Do(r);if(t===i&&e===s&&(l==="text-only"||o==="text-only"||o===l))return r;if(i<t)return null}r=dt(r)}return null}function fC(n){zt(n);const t=[];let e=Lo(n);for(;e;)t.unshift(e),e=Lo(e);return t}function zs(n){zt(n);const t=[];let e=hr(n);for(;e;)t.push(e),e=hr(e);return t}function Us(n){zt(n);let t=Lo(n);for(;t;){const e=Lo(t);if(!e)return t;t=e}return n}function nI(n){zt(n);let t=hr(n);for(;t;){const e=hr(t);if(!e)return t;t=e}return null}function mC(n,t){const e=fC(n),o=zs(n);return t.withSelf?[...e,n,...o]:[...e,...o]}function Vs(n,t,e,o){var i;const r=(i=o==null?void 0:o.groupId)!=null?i:P();t.forEach(s=>{const l=n.getBlockData(s);if(l.start!==e||(o==null?void 0:o.resetGroupId)){const c={...l,start:e};o!=null&&o.resetGroupId&&(c.groupId=r),n.updateBlockData(s,c)}l.textOnly||(e+=1)})}function i1(n,t,e,o){const r=mC(t,{withSelf:!0});r.length!==0&&Vs(n,r,e,o)}function oI(n){const t={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};let e="",o=n;return Object.entries(t).forEach(([r,i])=>{for(;o>=i;)e+=r,o-=i}),e.toLowerCase()}const rI="abcdefghijklmnopqrstuvwxyz";function gC(n){if(n<=0)return`${n}`;const t=(n-1)%26,e=Math.floor((n-1)/26),o=rI[t];return e?gC(e)+o:o}function iI(n){return`${n}`}const pC=[iI,gC,oI];function sI(n,t){const e=pC[(n-1)%pC.length];return e(t)}function lI(n){return["\u2022","\u25E6","\u25AA"][(n-1)%3]}class fr{constructor(t,e,o){h(this,"listStart");h(this,"listBrother",null);this.editor=t,this.options=o;const r=Us(e),i=Ue(r);this.listStart=i,this.listBrother=r,o!=null&&o.resetStart&&(this.listStart=1)}fix(){!this.listBrother||i1(this.editor,this.listBrother,this.listStart,this.options)}}function cI(n,t,e=1){if(!t)return null;let o=bt(n);for(;o;){const r=o.getAttribute("data-style-heading"),i=Number(o.getAttribute("data-list-level"));if(r){if(r<t)return null;if(r===t&&i===e)return ut(o)?o:null}o=bt(o)}return null}function aI(n,t){const e=n.getAttribute("data-style-heading"),o=cI(n,e);if(o)return o;const r=bt(n);if(r&&ut(r)&&ze(r)===t)return r;const i=dt(n);return i&&ut(i)&&ze(i)===t?i:null}function uI(n,t,e){var k,v,T;const o=(k=e.data)!=null?k:{};let r=1;if(ut(t))r=Ae(t);else{const E=Wc(t);E&&(r=E+1),r>8&&(r=8)}const i=(v=o.listType)!=null?v:"ordered";if(i==="text-only")return null;const s=n.getBlockData(t);let l=(T=s.text)!=null?T:[],a=vt(l);const d=e.offset||0;d<=me(l)&&(l=ve(l,d).right,a=a.substring(0,d));let f=1;i==="ordered"&&(f=Number.parseInt(a,10)||1);let m=P();const p=aI(t,i);if(p){if(K(t)>K(p))f=Ue(p)+1;else{const E=Ue(p);E>1&&(f=E-1)}m=ei(p)}const A={id:P(),type:"list",level:r,start:f,groupId:m,ordered:!1,text:l};return s.quoted&&(A.quoted=!0),s.heading&&(A.heading=s.heading),i==="ordered"?A.ordered=!0:(i==="checked"||i==="unchecked")&&(A.checkbox=i),{blockData:A,onConverted:(E,L)=>{new fr(E,L).fix()}}}function ni(n){return n.textOnly?"text-only":n.checkbox?n.checkbox:n.ordered?"ordered":"unordered"}function dI(n){var e,o;if(n.checkbox||n.textOnly)return"";const t=(e=n.level)!=null?e:1;return n.ordered?`${sI(t,(o=n.start)!=null?o:1)}.`:lI(t)}function Qc(n){return n==="checked"||n==="unchecked"}function CC(n,t,e,o){const r=t,{containerId:i,blockIndex:s}=o[o.length-1];if(s===0)return!0;const l=e.blocks[i][s-1];if(l.type!=="list")return!0;const c=ni(r),a=ni(l);return c!==a&&(!Qc(c)||!Qc(a))||r.level>l.level}function AC(n,t,e,o){const r=t,{containerId:i,blockIndex:s}=o[o.length-1];if(s===e.blocks[i].length-1)return!0;const l=e.blocks[i][s+1];if(l.type!=="list")return!0;const c=ni(r),a=ni(l);return c!==a&&(!Qc(c)||!Qc(a))||r.level>l.level}function hI(n,t,e,o,r){var s,l,c;const i=t;if(o==="text"){let a=((s=ye.convertTo)==null?void 0:s.call(ye,n,t,e,"text",r))||"";i.checkbox==="checked"?a=`[x] ${a}`:i.checkbox==="unchecked"&&(a=`[ ] ${a}`),i.ordered?a=`${i.start}. ${a}`:a=`- ${a}`;const d=i.level||0;return a=(d>0?" ".repeat(d-1):"")+a,a}if(o==="markdown"){let a=((l=ye.convertTo)==null?void 0:l.call(ye,n,t,e,"markdown",r))||"";i.checkbox==="checked"?a=`[x] ${a}`:i.checkbox==="unchecked"&&(a=`[ ] ${a}`),i.ordered?a=`${i.start}. ${a}`:a=`- ${a}`;const d=i.level||0;return a=(d>0?" ".repeat(d-1):"")+a,CC(n,t,e,r)&&(a=`${a}`),AC(n,t,e,r)&&(a=`${a}`,d<=1&&(a+=`
|
|
340
|
+
</svg>`;function sB(n,t){var e;if(M(t,"menu-item"),!n.element){if(n.type==="section"){const o=b("div",["section-name"],null,n.name);t.appendChild(o)}else if(n.type!=="separator"){if(n.icon){const r=b("div",["menu-item-icon"],null);n.icon&&(r.innerHTML=n.icon),t.appendChild(r)}const o=b("div",["menu-item-name","text"],null,n.name);if(t.appendChild(o),n.subText&&b("div",["item-subtext","text"],t,n.subText),n.children&&!n.element){const r=b("div",["menu-item-sub-indicator"],null);r.innerHTML=A5,t.appendChild(r)}if((e=n.states)!=null&&e.includes("checked")){const r=b("div",["menu-item-checked-icon"],null);r.innerHTML=Hw,t.appendChild(r)}}}}class cr extends Dc{constructor(t,e,o){super(t,e,{autoClose:!0,disablePageScroll:!0,...o})}manualShow(t,e){const o={theme:"menu",...e};super.manualShow(t,o)}initCommandBarElement(t){M(t,"menu")}initItemElement(t,e){sB(t,e)}}function lB(n,t,e){var o;return new cr((o=n.children)!=null?o:[],t,{...e,parentItem:n})}class Ss extends Dc{constructor(t,e,o){super(t,e,{itemElementTag:"button",tippyArrow:!1,...o})}getSubBarOptions(t){var r,i;const e=()=>{const s=this.getItemElementById(t.id),c=this.content.getBoundingClientRect(),a=s.getBoundingClientRect();return new DOMRect(a.left,c.top,a.width,c.height)};return{placement:(r=t.childrenPlacement)!=null?r:"top",getReferenceClientRect:e,offset:(i=t.childrenOffset)!=null?i:[0,4]}}manualShow(t,e){const o={theme:"toolbar",...e};super.manualShow(t,o)}initCommandBarElement(t){M(t,"toolbar")}initItemElement(t,e){e.setAttribute("data-button-id",t.id),this.options.tooltipId&&t.name&&!t.disableTooltip&&(e.setAttribute(`data-editor-tooltip-${this.options.tooltipId}`,t.name),t.desc&&e.setAttribute(`data-editor-tooltip-desc-${this.options.tooltipId}`,t.desc));const o=e;if(!t.element)if(t.icon){const r=b("span",["toolbar-item-icon-container"],o);t.icon.trim().startsWith("<")?r.innerHTML=t.icon:r.innerText=t.icon}else{const r=b("span",["toolbar-item-name-container"],o);r.innerText=t.name}if(t.dropdown){e.setAttribute("data-dropdown","true");const r=b("span",["toolbar-item-dropdown-container"],o);r.innerHTML=ph}t.states&&(t.states.indexOf("checked")!==-1&&M(o,"checked"),t.states.indexOf("disabled")!==-1&&(o.disabled=!0))}}function cB(n,t,e){var o;return new Ss((o=n.children)!=null?o:[],t,{...e,parentItem:n})}const nV="";Zr.registerManualCommandBar("menu",lB),Zr.registerManualCommandBar("toolbar",cB);const oV="",x5=w("ui-base");class Ds extends Dc{constructor(e,o){super(Ds.getCommandItems(e,o),void 0,{disablePageScroll:!0,...o});h(this,"handleDocumentMouseDown",e=>{})}initCommandBarElement(e){M(e,"dialog","manual")}initItemElement(e,o){}show(e,o){this.manualShow(e,{...o,theme:"light"})}get dialogContent(){const e=this.items[0];u(x5,e,"no dialog item");const o=e.element;return u(x5,o,"no item element"),o}static getCommandItems(e,o){var s;return[{id:(s=o==null?void 0:o.id)!=null?s:`manual-dialog-${P()}`,name:"",element:e}]}}const aB=[-1,6,0,1,2,3,4,5],uB=[-1,6,0,1,2,3,4,5,14,13,7,8,9,10,11,12],T5=w("color-palette");function S5(n,t,e,o){u(T5,n>0,"no color in palette");const r=t||1;u(T5,r>0,`invalid palette rows: ${r}`);const i=n/r,s=b("div",["palette-container",o],null);for(let l=0;l<r;l++){const c=b("div",["palette-container-row"],s);for(let a=0;a<i;a++){const d=e(l*i+a);c.appendChild(d)}}return s}function dB(n){const t=b("button",["color-button"],null),e=aB[n];return t.setAttribute("data-color-index",`${e}`),t.innerHTML=C5,t}function hB(n){const t=b("button",["background-color-button"],null),e=uB[n];return t.setAttribute("data-color-index",`${e}`),t}function fB(){const n=b("div",["clear-button-container"],null),t=b("button",["clear-button"],n);return t.innerText=T.t("colorPalette.reset"),n}function mB(n){const t=b("div",["color-palette"],null);return n.color!==!1&&(b("div",["bar-desc"],t,T.t("colorPalette.colorDesc")),t.appendChild(S5(8,1,dB,"color"))),n.backgroundColor!==!1&&(b("div",["bar-desc"],t,T.t("colorPalette.backgroundDesc")),t.appendChild(S5(16,2,hB,"background-color"))),n.clearColorButton!==!1&&t.appendChild(fB()),t}function gB(n,t,e){const o=t==="color"?"color":"background-color",r=n.querySelector(`.${o} button.selected`);r&&H(r,"selected"),e===null&&(e=-1);const i=n.querySelector(`.${o} button[data-color-index="${e}"]`);i&&M(i,"selected")}const rV="",pB={};class CB extends Yt.TypedEmitter{constructor(e=pB){super();h(this,"root");h(this,"handleClick",e=>{const o=e.target;if(!o||!(o instanceof Element))return;const r=o.closest("button");if(!r)return;if(rt(r,"clear-button")){this.setColor("backgroundColor",null),this.setColor("color",null),this.emit("onClick","clearColor",0);return}const i=r.getAttribute("data-color-index");if(!i)return;const s=Number.parseInt(i,10);Number.isNaN(s)||(rt(r,"color-button")?s===-1?(this.setColor("color",null),this.emit("onClick","clearColor",1)):(this.setColor("color",s),this.emit("onClick","color",s)):s===-1?(this.setColor("backgroundColor",null),this.emit("onClick","clearColor",2)):(this.setColor("backgroundColor",s),this.emit("onClick","backgroundColor",s)))});this.options=e,this.root=mB(e),this.root.addEventListener("click",this.handleClick)}destroy(){this.removeAllListeners(),this.root.removeEventListener("click",this.handleClick)}setColor(e,o){gB(this.root,e,o)}}class D5{constructor(t,e){h(this,"name","Color Palette");h(this,"element");h(this,"palette");h(this,"closeable",null);this.id=t,this.palette=new CB(e),this.element=this.palette.root}setCloseable(t){this.closeable=t}destroy(){this.palette.destroy(),this.closeable=null}}function AB(){const n=b("button",["color-button"],null);return n.innerHTML=C5,n}function Th(n,t){const[e,o]=t;e===null?n.removeAttribute("data-color"):n.setAttribute("data-color",`${e}`),o===null?n.removeAttribute("data-background-color"):n.setAttribute("data-background-color",`${o}`)}class bB extends Yt.TypedEmitter{constructor(e){super();h(this,"id","text-color-item");h(this,"name",T.t("colorPalette.name"));h(this,"dropdown",!0);h(this,"manualShowChildren",!0);h(this,"children",[]);h(this,"element");h(this,"colorPaletteItem");h(this,"latestColors",[null,null]);h(this,"handlePaletteClick",(e,o)=>{this.emit("onClick",e,o),e==="color"||e==="backgroundColor"?e==="color"?this.latestColors[0]=o:this.latestColors[1]=o:this.latestColors=[null,null],Th(this.element,this.latestColors)});h(this,"beforePopup",()=>{this.emit("beforePopup")});this.editor=e,this.colorPaletteItem=new D5("text-color-palette-item"),this.colorPaletteItem.palette.addListener("onClick",this.handlePaletteClick),this.children.push(this.colorPaletteItem),this.element=AB()}destroy(){this.colorPaletteItem.destroy()}updatePaletteColor(e){this.colorPaletteItem.palette.setColor("color",e[0]),this.colorPaletteItem.palette.setColor("backgroundColor",e[1]),this.latestColors=e,Th(this.element,this.latestColors)}updateButtonColor(e){this.latestColors=e,Th(this.element,this.latestColors)}}const iV="";function Sh(n,t){const e=b("div",["editor-input-wrap"],n);t!=null&&t.className&&M(e,t==null?void 0:t.className);const o=b("div",["editor-input-label"],e);b("span",[],o,t.label),t.required&&M(o,"required");const r=b("div",["editor-input-container"],e),i=b("input",["editor-input"],r);t.placeholder&&(i.placeholder=t.placeholder),t.defaultValue&&(i.value=t.defaultValue);const s=b("div",["editor-input-error"],e);return i.addEventListener("input",l=>{var c;(c=t.onChange)==null||c.call(t,l),H(e,"error")}),i.addEventListener("keydown",l=>{var c;(c=t.onKeyDown)==null||c.call(t,l)}),{getField:()=>i,getInputValue:()=>i.value,setFieldError:l=>{M(e,"error"),s.innerText=l},focus:()=>{setTimeout(()=>{i.focus()})}}}function Dh(n){const t=document.getSelection();if(!t)return!0;const e=t.focusNode;if(!e)return!0;const o=t.focusOffset,r=e.childNodes[o];if(!r)return!0;if(r instanceof HTMLElement){const i=r.tagName.toLowerCase();if(r===n.input.inputElement)return!0;if(i==="input"||i==="textarea")return!1}return!0}const vB=w("ui-base");class yB{constructor(t,e){h(this,"menu");h(this,"currentText","");h(this,"handleClick",(t,e)=>{this.options.onClickItem(this,e)});h(this,"handleClose",()=>{var t,e;Dh(this.editor)&&this.editor.focus(),(e=(t=this.options).onClose)==null||e.call(t)});h(this,"handleKeydown",t=>{this.menu.handleDocumentKeydown(t)});this.editor=t,this.options=e,this.menu=new cr([],void 0,{id:e.id}),this.menu.addListener("click",this.handleClick),this.menu.addListener("close",this.handleClose)}setItems(t){if(this.menu.updateItems(t),t.length>0){const e=t.find(o=>o.type!=="section"&&o.type!=="separator");e&&this.menu.selectItem(e.id)}}async popup(t,e,o){var a,d;if(((d=(a=this.options).onShow)==null?void 0:d.call(a,this,t,e,o))===!1)return;this.options.showLoading&&this.showLoading();const r=this.editor.getBlockByIndex(t,e);if(!wt(this.editor.rootContainer,r)||G(this.editor,r)<o)return;const i=co(this.editor,r,Ot(this.editor,r,o));if(i.length===0)return;const s=i[0],l=fo(this.editor,r,"editor-auto-suggest-menu",s);this.menu.manualShow(l),this.options.placeholder&&this.showPlaceholder();const c=await this.options.queryItems(this,"");this.highlightText(""),this.setItems(c)}showLoading(){!this.options.showLoading||(this.options.loadingElement?this.setItems([{id:"loading",name:"",element:this.options.loadingElement,states:["disabled"]}]):this.setItems([{id:"loading",name:"loading",states:["disabled"]}]))}showPlaceholder(){this.setItems([{id:"placeholder",name:"enter text to search",states:["disabled"]}])}showNoResultMessage(t){if(this.options.noResultMessage){const e={name:"",id:"placeholder",states:["disabled"]};typeof this.options.noResultMessage=="string"?e.name=this.options.noResultMessage:(this.options.noResultMessage instanceof HTMLElement||typeof this.options.noResultMessage=="function")&&(e.element=this.options.noResultMessage),this.setItems([e])}else this.setItems([{id:"placeholder",name:T.t("search.emptyTips"),states:["disabled"]}])}close(){this.menu.close()}get isVisible(){return this.menu.isVisible}destroy(){this.menu.close(),this.menu.removeAllListeners(),this.menu.destroy()}async handleSearchText(t){this.currentText=t;const e="auto-suggest";try{await Ge.lock(e),this.showLoading();const o=this.currentText,r=await this.options.queryItems(this,o);if(this.currentText===o&&(this.currentText=""),r.length===0){this.showNoResultMessage(t);return}this.setItems(r),this.options.highlight&&this.highlightText(o.replace(/^\s+|\s+$/g,""))}finally{Ge.release(e)}}highlightText(t){vB.debug(`highlight menu text: ${t}`);const e=this.menu.content,o=(i,s)=>{if(!s)return i;let l="";const c=s.length,a=s.toLocaleLowerCase();let d=0;for(d=0;d<=i.length-c;d){let f=i.substring(d,d+c);if(f.toLocaleLowerCase()===a){d+=c;const m=i.charAt(d);let p=!1;f.endsWith(" ")&&(p=!0,f=f.trimEnd()),l+=`<span class="highlight">${f}${m===" "||p?" ":""}</span>`}else l+=i.charAt(d),d++}return d<i.length&&(l+=i.substring(d)),l},r=i=>{if(rt(i,"text")){const s=i.textContent;if(!s)return;const l=o(s,t);i.innerHTML=l;return}Array.from(i.children).forEach(r)};r(e)}}const Lh=w("auto-suggest-menu");class Mh{constructor(t,e){h(this,"menu");h(this,"anchor",null);h(this,"close",()=>{this.menu.close()});h(this,"handleSelectionChanged",t=>{var o,r;if(!((o=this.menu)!=null&&o.isVisible))return;const e=t.selection.range.start;if(e.isSimple()&&e.blockId===((r=this.anchor)==null?void 0:r.blockId)&&e.offset>=this.anchor.offset){const i=t.getBlockById(e.blockId);if(vt(ve(ge(t,i),e.offset).left).startsWith(this.anchor.leftText))return}this.menu.close()});h(this,"deleteTrigger",()=>{const t=this.editor,e=t.selection.range.start;if(!e.isSimple()||!this.anchor)return!1;const{blockId:o,offset:r}=e,i=t.getBlockById(o),s=vt(rc(t,i,r));if(u(Lh,this.anchor,"no anchor"),!s.startsWith(this.anchor.leftText))return!1;const l=this.anchor.offset-this.anchor.trigger.length,c=r-l;return t.selection.selectBlock(i,l),c&&(t.deleteTextFromBlock(i,l,c),this.anchor.offset-=this.anchor.trigger.length),this.anchor.trigger.length||this.menu.close(),!0});h(this,"onClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});h(this,"onShow",(t,e,o,r)=>{var i;if((i=this.options)!=null&&i.onShow)return this.options.onShow(this,e,o,r)});h(this,"onClickItem",(t,e)=>{!this.anchor||(this.options.autoDeleteTrigger&&this.deleteTrigger(),this.options.onClickItem(this,e,this.anchor))});h(this,"queryItems",(t,e)=>this.options.queryItems(this,e));h(this,"renderMenuItem",(t,e)=>{var r,i;return(i=(r=this.options).renderMenuItem)==null?void 0:i.call(r,this,e)});this.editor=t,this.options=e,this.menu=new yB(t,{id:e.id,showLoading:e.showLoading,loadingElement:e.loadingElement,placeholder:e.placeholder,noResultMessage:e.noResultMessage,highlight:e.highlight,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,renderMenuItem:this.renderMenuItem}),t.input.addHandler(this),t.addListener("selectionChanged",this.handleSelectionChanged)}handleBeforeKeyDown(t,e){var o;return!((o=this.menu)!=null&&o.isVisible)||vu(e.key)?!1:zm(e)&&!Go(e)?(setTimeout(()=>{this.resetItems()}),!1):yu(e)?(this.menu.close(),!0):(this.menu.handleKeydown(e),!0)}popup(t,e,o,r){this.anchor={blockId:j(t),offset:e,leftText:o,trigger:r};const i=V(z(t)),s=K(t);this.menu.popup(i,s,e)}handleAfterInsertText(t,e,o,r,i){var d;const s=t.selection.range.start;if(!s.isSimple()||e==="root"&&o===0)return!1;const{blockId:l,offset:c}=s,a=t.getBlockByIndex(e,o);if(j(a)!==l)return!1;if((d=this.menu)!=null&&d.isVisible)this.resetItems();else if(this.options.trigger.indexOf(i)!==-1){if(r>0&&this.options.needSpaceBeforeTrigger&&t.getBlockString(a)[r-1]!==" ")return!1;const f=vt(rc(t,a,c));this.popup(a,c,f,i)}return!1}handleUpdateCompositionText(t,e,o,r,i){var a;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l}=s,c=t.getBlockByIndex(e,o);return j(c)!==l||(a=this.menu)!=null&&a.isVisible&&this.resetItems(),!1}resetItems(){var l;if(!((l=this.menu)!=null&&l.isVisible))return;const t=this.editor,e=t.selection.range.start;if(!e.isSimple())return;const{blockId:o,offset:r}=e,i=t.getBlockById(o),s=vt(rc(t,i,r));if(u(Lh,this.anchor,"no anchor"),s.startsWith(this.anchor.leftText)){const c=s.substring(this.anchor.leftText.length);Lh.debug(`search text: ${c}`),this.menu.handleSearchText(c)}}destroy(){var t;this.editor.input.removeHandler(this),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.menu)==null||t.destroy()}}function kB(){const n={};for(let t=1;t<=8;t++)n[`heading-${t}`]={shortcut:`/h${t}`};return n}const wB={"insert-hr":{shortcut:"/hr"},"insert-uml":{shortcut:"/uml"},"insert-table":{shortcut:"/table"},"insert-image":{shortcut:"/image"},"insert-code":{shortcut:"/code"},"insert-link":{shortcut:"/link"},"insert-drawio":{shortcut:"/uml"},"insert-video":{shortcut:"/video"},"insert-audio":{shortcut:"/audio"},"insert-math":{shortcut:"/math"},"insert-webPage":{shortcut:"/web"},"insert-bilibili":{shortcut:"/bilibili"},"insert-youku":{shortcut:"/youku"},"insert-figma":{shortcut:"/figma"},"insert-modao":{shortcut:"/modao"},"insert-tencent":{shortcut:"/tencent"},"insert-unordered":{shortcut:"/bl"},"insert-ordered":{shortcut:"/nu"},"insert-checkbox":{shortcut:"/todo"},"insert-quote":{shortcut:"/quote"},...kB()};function Ce(n){var t;return(t=wB[n])==null?void 0:t.shortcut}function BB(n){var t;return(t=n.subText)!=null?t:""}const Tn=w("table-dom");function Io(n){return`${j(n)}_scroll`}function jt(n){const t=n.querySelector("div[data-type=table-content] >table");return u(Tn,t instanceof HTMLTableElement,"invalid table"),t}function Sn(n,t){const o=n.getCustom(Io(t)).contentElement.firstElementChild;u(Tn,o instanceof HTMLElement,"invalid table content");let r=o.querySelector(":scope >div[data-type=table-tools]");return r||(r=b("div",[],o),r.setAttribute("data-type","table-tools")),u(Tn,r,"no table tools"),r}function L5(n){const t=[];return Array.from(n.rows).forEach(e=>{t.push(...Array.from(e.cells))}),t}function Ls(n){const t=n.querySelector(":scope div[data-type=editor-container]");return u(Tn,t,"no child container in cell"),t}function EB(n){const o=L5(n).map(r=>{const i=Ls(r),s=V(i),l=r.colSpan,c=r.rowSpan;return`${s}/${l}/${c}`}).join();return Er.default(o)}function Zt(n){return it(n)==="table"}function Rh(n){const t=z(n);if(Ct(t))return null;const e=U(t);return u(Tn,e,"no parent block"),Zt(e)?t:Rh(e)}function Qn(n){if(Zt(n))return n;const t=z(n);if(Ct(t))return null;const e=U(t);return u(Tn,e,"no parent block"),Zt(e)?e:Qn(e)}function IB(n,t){const e=n.querySelector("colgroup");u(Tn,e,"no colgroup");const o=e.children[t];return u(Tn,o,"no col"),u(Tn,o instanceof HTMLTableColElement,`invalid col: ${o.tagName}`),o}function M5(n){try{return jt(n),!0}catch{return!1}}function xB(n){return Rt(n).querySelector(":scope > .block-helper")}function R5(n){const t=U(n.contentElement);u(Tn,t,"no block");const e=xB(t);if(e){const o=Math.min(n.contentElement.offsetLeft,n.rootElement.scrollLeft),r=t.getBoundingClientRect().width;e.style.right=`${o+r}px`}}const Re=w("doc-table-grid");class TB{constructor(t){h(this,"_cells",[]);for(let e=0;e<t;e++)this._cells.push(void 0)}cols(){return this._cells.length}setCell(t,e){u(Re,t>=0&&t<this.cols(),`set cell, invalid col: ${t}`),this._cells[t]=e}getCell(t){u(Re,t>=0&&t<this.cols(),`get cell, invalid col: ${t}`);const e=this._cells[t];return u(Re,e,"get cell, no cell"),e}getCellAllowEmpty(t){return u(Re,t>=0&&t<this.cols(),`get cell, invalid col, ${t}`),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}forEach(t){this._cells.forEach(t)}}class Mc{constructor(t){h(this,"_data");h(this,"_rows");this._data=t,this._rows=[];for(let e=0;e<this.rowCount;e++)this._rows.push(new TB(this.colCount));this.fillGrid(),u(Re,t.colsWidth,"no colsWidth"),u(Re,this.colCount===t.colsWidth.length,"invalid col count")}get rowCount(){return this._data.rows}get colCount(){return this._data.cols}getNextEmptyCell(t,e){let o=t,r=e;for(;;){if(o+=1,o===this.colCount&&(o=0,r+=1),r>=this.rowCount)return null;if(this._rows[r].getCellAllowEmpty(o)===void 0)return{col:o,row:r}}}fillGrid(){const t=this._data.children;u(Re,t,"no children");let e=0,o=0;t.forEach((r,i)=>{const s=this._data[`${r}_colSpan`]||1,l=this._data[`${r}_rowSpan`]||1;for(let a=0;a<l;a++)for(let d=0;d<s;d++)this._rows[o+a].setCell(e+d,{col:e,row:o,containerId:r,virtual:d!==0||a!==0,colSpan:s,rowSpan:l});const c=this.getNextEmptyCell(e,o);c?(e=c.col,o=c.row):u(Re,i===t.length-1,`invalid table data, no next empty cell: ${JSON.stringify(this._data)}`)}),this._rows.forEach(r=>{r.forEach(i=>{u(Re,i,"no cell"),u(Re,i.containerId,"no containerId")})})}getCell(t){const{col:e,row:o}=t,r=this._rows[o];u(Re,r,`get cell, no row: ${o}`);const i=r.getCell(e);return u(Re,i,`get cell, no cell: ${e}`),i}getRow(t){const e=this._rows[t];return u(Re,e,`get row, no row: ${t}`),e}forEach(t){this._rows.forEach(t)}}const Rc=w("table-data");function SB(n){const t=n.firstElementChild;return u(Rc,t,"no child element for cell"),u(Rc,vn(t),"cell first child is not a container"),u(Rc,Ke(t),"cell first child is not a container"),t}function DB(n){const t=U(n);u(Rc,t,"no parent block for table");const e=[],o={};Array.from(n.rows).forEach(l=>{Array.from(l.cells).forEach(c=>{const a=SB(c),d=V(a);e.push(d),(c.colSpan>1||c.rowSpan>1)&&(o[`${d}_colSpan`]=c.colSpan,o[`${d}_rowSpan`]=c.rowSpan)})});const r=n.rows.length,i=Array.from(n.rows[0].cells).map(l=>l.colSpan).reduce((l,c)=>l+c,0);return{id:j(t),type:it(t),rows:r,cols:i,children:e,colsWidth:Array(i).fill(100),...o}}function ar(n){return new Mc(n)}function LB(n){return ar(DB(n))}const Qt=w("table-grid"),MB=60;class RB{constructor(t,e){h(this,"containerId");h(this,"row");h(this,"col");h(this,"colSpan");h(this,"rowSpan");h(this,"virtual");h(this,"table");this.table=t,this.containerId=e.containerId,this.row=e.row,this.col=e.col,this.colSpan=e.colSpan,this.rowSpan=e.rowSpan,this.virtual=e.virtual}get cell(){const e=this.container.closest("td");return u(Qt,e,"no parent cell for child container"),e}get container(){const t=this.table.querySelectorAll(`[data-container-id=${this.containerId}]`);u(Qt,t.length===1,"containers !== 1"),u(Qt,vn(t[0]),"not a container");const e=t[0];return u(Qt,Ke(e),"not a child container"),e}}class OB{constructor(t,e){h(this,"_cells",[]);e.forEach(o=>{this._cells.push(new RB(t,o))})}get cells(){return this._cells}getCell(t){return u(Qt,t<this._cells.length,"get cell, invalid col"),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}getSpannedCell(){return this._cells.find(t=>t.virtual||t.colSpan>1||t.rowSpan>1)}}const Wf=class{constructor(t){h(this,"_rows",[]);this.table=t,LB(t).forEach(r=>{this._rows.push(new OB(t,r))});const o=this.colCount;this._rows.forEach(r=>{u(Qt,r.cells.length===o,"row.cells.length !== colCount")})}get rowCount(){return this._rows.length}get colCount(){return this._rows.length===0?0:(u(Qt,this.rowCount>0,"rowCount <= 0"),this.getRow(0).cells.length)}getRow(t){return this._rows[t]}getCell(t){const e=this.getRow(t.row);return u(Qt,e,"no row"),e.getCell(t.col)}getCellContainer(t){return this.getCell(t).container}getFirstCellContainer(){return this.getCellContainer({row:0,col:0})}getLastCellContainer(){const t=this.rowCount-1,e=this.colCount-1;return this.getCellContainer({row:t,col:e})}getColumnCells(t){u(Qt,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount,o=[];for(let r=0;r<e;r++){const i=this.getCell({row:r,col:t});o.push(i)}return o}toRealCells(t){const e=[];return t.forEach(o=>{const r=this.getRealCell(o);e.findIndex(i=>i.containerId===r.containerId)===-1&&e.push(r)}),e}getColumnRealCells(t){const e=this.getColumnCells(t);return this.toRealCells(e)}getRowRealCells(t){const e=this.getRow(t).cells;return this.toRealCells(e)}getFirstSpannedCell(t){u(Qt,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount;for(let o=0;o<e;o++){const r=this.getCell({row:o,col:t});if(r.virtual||r.colSpan>1||r.rowSpan>1)return r}}getRealCell(t){const e=this.getCell(t);if(!e.virtual)return e;const o=this.getCellById(e.containerId);return u(Qt,!o.virtual,"found a virtual cell"),o}getColumnSpannedRange(t){const e=this.getColumnRealCells(t);let o=1e5,r=-1;return e.forEach(i=>{o=Math.min(i.col,o),r=Math.max(i.col+i.colSpan-1,r)}),u(Qt,o<=r,"min > max"),u(Qt,o>=0,"min < 0"),u(Qt,r<this.colCount,"max >= colCount"),[o,r]}getRowSpannedRange(t){const e=this.getRowRealCells(t);let o=1e5,r=-1;return e.forEach(i=>{o=Math.min(i.row,o),r=Math.max(i.row+i.rowSpan-1,r)}),u(Qt,o<=r,"min > max"),u(Qt,o>=0,"min < 0"),u(Qt,r<this.rowCount,"max >= rowCount"),[o,r]}getSpannedRange(t,e){const o=Math.min(t.row,e.row),r=Math.max(t.row,e.row),i=Math.min(t.col,e.col),s=Math.max(t.col,e.col),l=[];for(let p=o;p<=r;p++)for(let A=i;A<=s;A++)l.push(this.getCell({row:p,col:A}));const c=this.toRealCells(l);let a=1e4,d=1e4,f=-1,m=-1;return c.forEach(p=>{d=Math.min(p.col,d),a=Math.min(p.row,a),m=Math.max(p.col+p.colSpan-1,m),f=Math.max(p.row+p.rowSpan-1,f)}),[{row:a,col:d},{row:f,col:m}]}getAllCells(){return this.getCells({col:0,row:0},{col:this.colCount-1,row:this.rowCount-1})}sub(t,e){const o=[];for(let r=t.row;r<=e.row;r++){const i=[];for(let s=t.col;s<=e.col;s++){const l=this.getCell({row:r,col:s});i.push(l)}o.push(i)}return o}getAllContainers(){return this.getAllCells().map(e=>e.container)}getCells(t,e){const o=[],r=this.getSpannedRange(t,e),i=r[0],s=r[1],l=Math.min(i.row,s.row),c=Math.max(i.row,s.row),a=Math.min(i.col,s.col),d=Math.max(i.col,s.col);for(let f=l;f<=c;f++)for(let m=a;m<=d;m++){const p=this.getCell({row:f,col:m});p.virtual||o.push(p)}return o}map(t){const e=[];for(let o=0;o<this.rowCount;o++){const r=[];for(let i=0;i<this.colCount;i++){const s=this.getCell({row:o,col:i});r.push(t(s))}e.push(r)}return e}getBottomCell(t){const e=this.rowCount;let o=t,r=t.row;for(;o.containerId===t.containerId;){if(r+=1,r>=e)return null;o=this.getCell({row:r,col:t.col})}return this.getRealCell(o)}getTopCell(t){let e=t,o=t.row;for(;e.containerId===t.containerId;){if(o-=1,o<0)return null;e=this.getCell({row:o,col:t.col})}return this.getRealCell(e)}get cells(){let t=[];return this._rows.forEach(e=>{t=t.concat(e.cells)}),t}getVirtualCellContainersGrid(){return this.map(t=>t.containerId)}static virtualCellContainersGridToChildren(t){const e=t,o=[];return e.forEach(r=>{r.forEach(i=>{o.indexOf(i)===-1&&o.push(i)})}),o}getCellById(t){const o=this.cells.find(r=>r.containerId===t);return u(Qt,o,"cell not found"),o}getCellByCellElement(t){const e=Ls(t);return this.getCellByContainerId(V(e))}getCellByContainerId(t){return this.getCellById(t)}static fromTable(t){const e=EB(t),o=this.caches.getSync(e,()=>(Qt.debug("create table grid"),new Wf(t)));return o.table!==t?(this.caches.delete(e),this.fromTable(t)):o}static fromBlock(t){return this.fromTable(jt(t))}};let nt=Wf;h(nt,"caches",new vm(MB));function Oc(n,t){Object.entries(n).forEach(([e])=>{e.startsWith(`${t}/`)&&delete n[e]})}const NB=w("table-selection-range");function dn(n,t,e){var E,L,R,$;const o=nt.fromBlock(n),r=t,i=e,s=o.getCellByContainerId(r.childContainerId),l=o.getCellByContainerId(i.childContainerId),c=r.custom,a=i.custom,d=(E=c==null?void 0:c.rowIndex)!=null?E:s.row,f=(L=c==null?void 0:c.colIndex)!=null?L:s.col,m=(R=a==null?void 0:a.rowIndex)!=null?R:l.row+l.rowSpan-1,p=($=a==null?void 0:a.colIndex)!=null?$:l.col+l.colSpan-1,A=Math.min(d,m),k=Math.max(d,m),v=Math.min(f,p),x=Math.max(f,p);return{fromRow:A,toRow:k,fromCol:v,toCol:x}}function Oh(n,t){const e=new Set,o=new Set,r=n.selection.range;if(!r.isSimple()&&r.start.blockId===j(t)){const i=nt.fromBlock(t),{start:s,end:l}=r;u(NB,!s.isSimple()&&!l.isSimple(),"invalid range");const{fromCol:c,toCol:a,fromRow:d,toRow:f}=dn(t,s,l);if(d===0&&f===i.rowCount-1)for(let m=c;m<=a;m++)o.add(m);if(c===0&&a===i.colCount-1)for(let m=d;m<=f;m++)e.add(m)}return{selectedRows:e,selectedColumns:o}}function Ms(n,t){let e=null;if(t.isCollapsed()&&t.isSimple()){const o=n.getBlockById(t.start.blockId);if(Zt(o)){const r=z(o),i=U(r);i&&(e=Qn(i))}else e=Qn(o)}else{const o=n.getBlockById(t.start.blockId),r=Qn(o),i=n.getBlockById(t.end.blockId),s=Qn(i);r===s&&(e=r)}return e}const Qr=w("delete-columns");function O5(n,t,e){const{start:o,end:r}=e;if(o.blockId!==r.blockId||e.isSimple()||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{fromRow:s,toRow:l}=dn(t,e.start,e.end),c=nt.fromBlock(t);return s===0&&l===c.rowCount-1}function Nh(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{var L;const e=t.getBlockById(n.start.blockId);if(!O5(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromCol:o,toCol:r}=dn(e,n.start,n.end),i=nt.fromBlock(e);if(o===0&&r===i.colCount-1){t.deleteBlock(e);return}const s=new Set,l=i.map(R=>R.containerId);for(let R=0;R<l.length;R++){const $=l[R];for(let q=o;q<=r;q++){const ot=$[q];s.add(ot)}$.splice(o,r-o+1)}const c=new Set(l.flat()),a=new Set(Array.from(s).filter(R=>!c.has(R))),d=r-o+1,f=new Map,m=new Map;s.forEach(R=>{if(a.has(R))return;const $=i.getCellByContainerId(R);if(u(Qr,$.colSpan>1,"invalid effected cell, colSpan === 1"),$.col<o){u(Qr,c.has(R),"invalid effected cell, not exists");let kt=$.col+$.colSpan-1;kt>r&&(kt=r);const de=kt-o+1,oo=$.colSpan-de;f.set(R,oo);return}u(Qr,$.col<=r,"invalid effected cell, col > endCol");const q=$.col,ot=$.col+$.colSpan-1,lt=$.col-o,gt=ot-q+1-d+lt;u(Qr,gt>0,"invalid effected cell, newSpanned <= 0");const ht=Bn(t.doc);m.set(R,{newContainerId:ht,colSpan:gt})});for(let R=0;R<l.length;R++){const $=l[R];for(let q=o;q<$.length;q++){const ot=$[q],lt=m.get(ot);lt&&($[q]=lt.newContainerId)}}const p=Q.default(t.getBlockData(e));p.colsWidth.splice(o,r-o+1),a.forEach(R=>{Oc(p,R)}),f.forEach((R,$)=>{u(Qr,R>=1,"invalid modified colSpan, colSpan < 1"),R===1?p[`${$}_colSpan`]=void 0:p[`${$}_colSpan`]=R}),m.forEach((R,$)=>{Oc(p,$);const{newContainerId:q,colSpan:ot}=R;u(Qr,ot>=1,"invalid newContainerData, colSpan < 1"),ot>1&&(p[`${q}_colSpan`]=ot);const lt=i.getCellByContainerId($).rowSpan;lt>1&&(p[`${q}_rowSpan`]=lt)});const k=(L=l[0][o])!=null?L:l[0][o-1],v=t.getChildContainerData(k)[0],x=nt.virtualCellContainersGridToChildren(l),E={...p,cols:p.cols-d,children:x};ar(E),t.updateBlockData(e,E,Ot(t,v.id,0)),t.deleteChildContainers(Array.from(a)),t.deleteChildContainers(Array.from(m.keys()))})}const Yr=w("delete-rows");function N5(n,t,e){const{start:o,end:r}=e;if(o.blockId!==r.blockId||e.isSimple()||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{fromCol:s,toCol:l}=dn(t,e.start,e.end),c=nt.fromBlock(t);return s===0&&l===c.colCount-1}function Ph(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{const e=t.getBlockById(n.start.blockId);if(!N5(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromRow:o,toRow:r}=dn(e,n.start,n.end),i=nt.fromBlock(e);if(o===0&&r===i.rowCount-1){t.deleteBlock(e);return}const s=new Set,l=i.map(E=>E.containerId);for(let E=r;E>=o;E--)l[E].forEach(R=>s.add(R)),l.splice(E,1);const c=new Set(l.flat()),a=new Set(Array.from(s).filter(E=>!c.has(E))),d=r-o+1,f=new Map,m=new Map;s.forEach(E=>{if(a.has(E))return;const L=i.getCellByContainerId(E);if(u(Yr,L.rowSpan>1,"invalid effected cell, rowSpan === 1"),L.row<o){u(Yr,c.has(E),"invalid effected cell, not exists");let gt=L.row+L.rowSpan-1;gt>r&&(gt=r);const ht=gt-o+1,kt=L.rowSpan-ht;f.set(E,kt);return}u(Yr,L.row<=r,"invalid effected cell, col > endCol");const R=L.row,$=L.row+L.rowSpan-1,q=L.row-o,ot=$-R+1-d+q;u(Yr,ot>0,"invalid effected cell, newSpanned <= 0");const lt=Bn(t.doc);m.set(E,{newContainerId:lt,rowSpan:ot})});for(let E=o;E<l.length;E++){const L=l[E];for(let R=0;R<L.length;R++){const $=L[R],q=m.get($);q&&(L[R]=q.newContainerId)}}const p=Q.default(t.getBlockData(e));a.forEach(E=>{Oc(p,E)}),f.forEach((E,L)=>{u(Yr,E>=1,"invalid modified rowSpan, rowSpan < 1"),E===1?p[`${L}_rowSpan`]=void 0:p[`${L}_rowSpan`]=E}),m.forEach((E,L)=>{Oc(p,L);const{newContainerId:R,rowSpan:$}=E;u(Yr,$>=1,"invalid newContainerData, rowSpan < 1"),$>1&&(p[`${R}_rowSpan`]=$);const q=i.getCellByContainerId(L).colSpan;q>1&&(p[`${R}_colSpan`]=q)});const A=l[o]?l[o][0]:l[o-1][0],k=t.getChildContainerData(A)[0],v=nt.virtualCellContainersGridToChildren(l),x={...p,rows:p.rows-d,children:v};ar(x),t.updateBlockData(e,x,Ot(t,k.id,0)),t.deleteChildContainers(Array.from(a)),t.deleteChildContainers(Array.from(m.keys()))})}const Rs=w("table-range");function Nc(n){u(Rs,!n.isSimple(),"must be complex selection range");const{anchor:t,focus:e}=n;u(Rs,!t.isSimple(),"invalid start pos type"),u(Rs,!e.isSimple(),"invalid end pos type");const o=n.getEditor();u(Rs,t.blockId===e.blockId,"invalid range, not same block");const r=o.getBlockById(t.blockId);u(Rs,it(r)==="table","invalid block type, not a table block");const i=jt(r),s=nt.fromTable(i),l=s.getCellByContainerId(t.childContainerId),c=s.getCellByContainerId(e.childContainerId),a=Math.min(l.row,c.row),d=Math.max(l.row,c.row),f=Math.min(l.col,c.col),m=Math.max(l.col,c.col),p=s.getCell({row:a,col:f}),A=s.getCell({row:d,col:m});return{editor:o,block:r,table:i,startCell:p,endCell:A,startRow:a,startCol:f,endRow:d,endCol:m}}const $h=w("split-cell");function _h(n,t,e){n.undoManager.runInGroup(()=>{const o=nt.fromBlock(t),r=o.getRealCell(e);u($h,!r.virtual,"should not split virtual cell"),u($h,r.colSpan>1||r.rowSpan>1,"cell does not has span data");const i=o.getVirtualCellContainersGrid();for(let f=0;f<r.rowSpan;f++)for(let m=0;m<r.colSpan;m++){if(f===0&&m===0)continue;const p=f+r.row,A=m+r.col,k=Bn(n.doc);i[p][A]=k}const s=n.getBlockData(t),l=Q.default(s);l[`${r.containerId}_colSpan`]=null,l[`${r.containerId}_rowSpan`]=null,l.children=nt.virtualCellContainersGridToChildren(i);const a=n.getChildContainerData(r.containerId)[0];u($h,a,"no child block");const d=Ot(n,a.id,0);ar(l),n.updateBlockData(t,l,d)})}function PB(n,t,e){e.forEach(o=>{const r=nt.fromBlock(t).getCell(o);(r.virtual||r.colSpan>1||r.rowSpan>1)&&_h(n,t,o)})}function P5(n,t,e){if(e.isSimple())return!1;const{start:o,end:r}=e;if(o.blockId!==r.blockId||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{startCell:s,endCell:l}=Nc(e);return!(s.cell!==l.cell||s.colSpan===1&&s.rowSpan===1)}function Fh(n){const{editor:t,block:e,startRow:o,startCol:r,endRow:i,endCol:s}=Nc(n),l=[];for(let c=o;c<=i;c++)for(let a=r;a<=s;a++)l.push({row:c,col:a});return PB(t,e,l),!0}const Jr=w("merge-cells");function $5(n,t,e){if(e.isSimple())return!1;const{start:o,end:r}=e;if(o.blockId!==r.blockId||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{startCell:s,endCell:l}=Nc(e);return s.cell!==l.cell}function _5(n){const t=Nc(n),e=t.editor;e.undoManager.runInGroup(()=>{const o=t.endCell,r=o.row+o.rowSpan-1,i=o.col+o.colSpan-1,s=j(t.block);Fh(n);const l=e.getBlockById(s),c=jt(l),{startRow:a,startCol:d}=t,f=Q.default(e.getBlockData(l));u(Jr,f.children,"no table children");const m=nt.fromTable(c),p=[];for(let gt=a;gt<=r;gt++)for(let ht=d;ht<=i;ht++){const kt=m.getCell({row:gt,col:ht});u(Jr,!kt.virtual,"cell is virtual"),p.push(kt)}u(Jr,p.length>0,"no selected cells");const A=p[0],k=p.slice(1),v=m.getCellByContainerId(A.containerId).container,x=[];k.forEach(gt=>{const ht=m.getCellByContainerId(gt.containerId).container,kt=V(ht);if(!pd(e,ht)){const de=K0(e,kt);e.insertDocAt(v,Ze(v),de)}x.push(kt)});const E=V(v),L=i-d+1,R=r-a+1;f[`${E}_colSpan`]=L,f[`${E}_rowSpan`]=R,x.forEach(gt=>{u(Jr,f.children,"no table children");const ht=f.children.indexOf(gt);u(Jr,ht>0,"no deleted container"),f.children.splice(ht,1)});const $=f,ot=e.getChildContainerData(E)[0];u(Jr,ot,"no child block");const lt=Ot(e,ot.id,0);ar($),e.updateBlockData(l,$,lt),e.deleteChildContainers(x)})}const Hh=10,$B=["table/merge-cells","table/split-cell","table/insert-column","table/insert-row","table/delete-rows","table/delete-columns","table/delete"];class jh{constructor(){h(this,"id","TableBlockCommandProvider")}getAvailableCommands(t,e,o){if(it(e)!=="table")return[];const r={blockId:j(e),blockKind:Je(t,e),blockType:it(e)},i=[];$5(t,e,o)&&i.push({id:"table/merge-cells",name:T.t("table.mergeCell"),icon:Bw,groupIndex:Hh,...r}),P5(t,e,o)&&i.push({id:"table/split-cell",name:T.t("table.splitCell"),icon:Ew,groupIndex:Hh,...r});const s=O5(t,e,o),l=N5(t,e,o);return s&&l&&i.push({id:"table/delete",name:T.t("table.deleteTable"),icon:Iw,groupIndex:Hh,...r}),i}executeCommand(t,e,o,r,i,s){return it(e)!=="table"||!new Set($B).has(r.id)?!1:r.id==="table/merge-cells"?(_5(o),!0):r.id==="table/split-cell"?(Fh(o),!0):r.id==="table/delete-columns"?(Nh(o),!0):r.id==="table/delete-rows"?(Ph(o),!0):r.id==="table/delete"?(t.deleteBlock(e),!0):!1}}var F5=(n=>(n.COL_TITLE_TABLE="col-title-table",n.COL_TITLE_ITEM="col-title-item",n.STRIPE_STYLE_TABLE="stripe-style-table",n.NO_BORDER="table-no-border",n))(F5||{});const zh=6,Os=20,Uh="table-cell-menu-btn";function _B(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),hasColTitle:!0};n.updateBlockData(t,o)}function FB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),hasColTitle:!1};n.updateBlockData(t,o)}function HB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),hasRowTitle:!0};n.updateBlockData(t,o)}function jB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),hasRowTitle:!1};n.updateBlockData(t,o)}function zB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),isStripeStyle:!0};n.updateBlockData(t,o)}function UB(n,t){if(!n.isBlockWritable(t))return;const o={...Q.default(n.getBlockData(t)),isStripeStyle:!1};n.updateBlockData(t,o)}function VB(n,t,e){if(!n.isBlockWritable(t))return;const r={...Q.default(n.getBlockData(t)),noBorder:!e};n.updateBlockData(t,r)}const Vh=w("get-selected-containers");function qh(n,t,e,o){u(Vh,e.blockId===o.blockId,"only allow select in single table block"),u(Vh,j(t)===e.blockId,"only allow select in single table block");const r=nt.fromBlock(t),i=r.getCellByContainerId(e.childContainerId),s=r.getCellByContainerId(o.childContainerId);if(e.custom===void 0||o.custom===void 0)return r.getCells(i,s).map(v=>r.getCellContainer(v));const{fromCol:l,toCol:c,fromRow:a,toRow:d}=dn(t,e,o),f=new Set,m=[];return r.sub({row:a,col:l},{row:d,col:c}).forEach(A=>{A.forEach(k=>{const v=r.getCellByContainerId(k.containerId);v.col<l||v.row<a||v.col+v.colSpan-1>c||v.row+v.rowSpan-1>d||f.has(k.containerId)||(f.add(k.containerId),m.push(v.container))})}),m}function qB(n,t,e){u(Vh,t.blockId===e.blockId,"only allow select in single table block");const o=n.getBlockById(t.blockId);return qh(n,o,t,e)}const ur=w("table-cell-dom");function WB(n,t,e){let o=n.getBlockById(e);for(;o;){const r=o.closest("td");u(ur,r,"no parent cell");const i=U(r);if(u(ur,i,"no parent block"),i===t)return r;o=i}return u(ur,!1,"filed to get cell by child block id"),null}function Yn(n,t,e){if(n.getBlockById(e.blockId)===t&&!e.isSimple())return u(ur,e.childContainerId,"block position must have childContainerId attribute"),e;const r=WB(n,t,e.blockId),i=V(Ls(r));return Bt(t,i)}function Wh(n,t){const e=n.selection.range,o=Yn(n,t,e.start),r=Yn(n,t,e.end);return dn(t,o,r)}function H5(n,t,e,o){u(ur,Zt(t),"invalid table block");const r=Sn(n,t),i=()=>{const l=r.querySelector(".table-border-bar-container.top");u(ur,l,"no top border bar container"),l.querySelectorAll(".table-border-bar-cell.top").forEach(a=>{const d=parseInt(a.getAttribute("data-top-index")||"0",10);o.includes(d)?M(a,"danger"):H(a,"danger")})},s=()=>{const l=r.querySelector(".table-border-bar-container.left");u(ur,l,"no left border bar container"),l.querySelectorAll(".table-border-bar-cell.left").forEach(a=>{const d=parseInt(a.getAttribute("data-left-index")||"0",10);e.includes(d)?M(a,"danger"):H(a,"danger")})};i(),s()}function xo(n,t,e=!0,o){const i=nt.fromBlock(t).map(d=>d),{fromCol:s,toCol:l,fromRow:c,toRow:a}=Wh(n,t);for(let d=0;d<i.length;d++){const f=i[d];for(let m=0;m<f.length;m++){const p=f[m],A=o?m>=s&&m+p.colSpan-1<=l:d>=c&&d+p.rowSpan-1<=a;e&&A?p.virtual||M(p.cell,"danger"):p.virtual||H(p.cell,"danger")}}}function To(n,t,e=!0,o){const r=new Set,i=new Set;if(!e){H5(n,t,Array.from(r),Array.from(i));return}const{fromCol:s,toCol:l,fromRow:c,toRow:a}=Wh(n,t);if(o)for(let d=s;d<=l;d++)i.add(d);else for(let d=c;d<=a;d++)r.add(d);H5(n,t,Array.from(r),Array.from(i))}function j5(n,t,e){const{fromCol:o,toCol:r,fromRow:i,toRow:s}=Wh(n,t),l=nt.fromBlock(t);let c=null,a=null;return e?(c=l.getCell({col:o,row:0}),a=l.getCell({col:r,row:l.rowCount-1}),Wt(n,{anchor:Bt(t,c.containerId,{colIndex:o,rowIndex:0}),focus:Bt(t,a.containerId,{colIndex:r,rowIndex:l.rowCount-1})})):(c=l.getCell({col:0,row:i}),a=l.getCell({col:l.colCount-1,row:s}),Wt(n,{anchor:Bt(t,c.containerId,{colIndex:0,rowIndex:i}),focus:Bt(t,a.containerId,{colIndex:l.colCount-1,rowIndex:s})}))}function GB(n,t){const e=n.selection.range,o=Yn(n,t,e.start),r=Yn(n,t,e.end);return qh(n,t,o,r)}const z5=["style-bg-color-0","style-bg-color-1","style-bg-color-2","style-bg-color-3","style-bg-color-4","style-bg-color-5","style-bg-color-6","style-bg-color-7","style-bg-color-8","style-bg-color-9","style-bg-color-10","style-bg-color-11","style-bg-color-12","style-bg-color-13"];function U5(n){return`style-bg-color-${n}`}function Ns(n){return`${n}_background`}function ZB(n,t,e){const o=jt(n),s=(e!=null?e:nt.fromTable(o)).getCell(t).cell;for(let l=0;l<z5.length;l++){const c=z5[l];if(rt(s,c))return c}}function V5(n,t,e){if(!n.isBlockWritable(t))return;const o=n.selection.range,i={...Q.default(n.getBlockData(t))},s=Yn(n,t,o.start),l=Yn(n,t,o.end);if(o.isSimple()){const c=s.childContainerId;e===-1?i[Ns(c)]=void 0:i[Ns(c)]=U5(e)}else{const c=nt.fromBlock(t),a=dn(t,s,l),d=new Set;for(let f=a.fromRow;f<=a.toRow;f++)for(let m=a.fromCol;m<=a.toCol;m++){const p=c.getCell({row:f,col:m});!d.has(p.containerId)&&p.col>=a.fromCol&&p.row>=a.fromRow&&p.col+p.colSpan-1<=a.toCol&&p.row+p.rowSpan-1<=a.toRow&&(d.add(p.containerId),e===-1?i[Ns(p.containerId)]=void 0:i[Ns(p.containerId)]=U5(e))}}n.updateBlockData(t,i)}function QB(n,t,e){if(!n.isBlockWritable(t))return;const r={...Q.default(n.getBlockData(t)),chart:e};n.updateBlockData(t,r)}const q5=w("table-chart");function YB(n,t){const e=Sn(n,t);if(e){const o=e.querySelector(".editor-table-chart");if(o){const r=o.chartObject;r&&r.destroy(),o.remove()}}}async function JB(n,t){if(!n.isBlockWritable(t))return;if(!!!n.getBlockData(t).chart){YB(n,t);return}const r=[],i=nt.fromBlock(t),s=["line","bar","pie","radar"];let l=i.getCell({row:0,col:0}).container.innerText.trim().toLowerCase();new Set(s).has(l)||(l=s[0]);const c=[];for(let k=1;k<i.colCount;k++)c.push(i.getCell({row:0,col:k}).container.innerText);for(let k=1;k<i.rowCount;k++){const v=i.getCell({row:k,col:0}),E=v.container.innerText,L=[];for(let de=1;de<i.colCount;de++){const oo=i.getCell({row:k,col:de}).container.innerText,re=Number.parseFloat(oo)||0;L.push(re)}let R;const $=ZB(t,v,i);$?R=window.getComputedStyle(n.rootElement).getPropertyValue(`--${$}`).trim():R=window.getComputedStyle(n.rootElement).getPropertyValue("--background-color").trim();let[q,ot,lt,gt]=R?su.fromString(R).toRgbaArray():[];if(!q&&!ot&&!lt&&!gt){const de=(k-1)%n.options.colors.length;R=n.options.colors[de],[q,ot,lt,gt]=su.fromString(R).toRgbaArray()}const ht=R,kt=su.fromRgba([q,ot,lt,gt/3]).toHexString();r.push({label:E,data:L,borderColor:ht,backgroundColor:kt,borderWidth:2})}const a=Sn(n,t);let d=null,f=a.querySelector(".editor-table-chart");f?d=f.chartObject:f=b("div",["editor-table-chart"],a);const m=f;u(q5,m,"no chart container");const p=n.getComponentOptions("table"),A=(p==null?void 0:p.chartCdn)||"https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";try{await qo(A,"editor-chartjs"),d&&l!==d.config.type&&(d.destroy(),d=null,Array.from(f.querySelectorAll(".editor-chartjs-canvas")).forEach(x=>{x.remove()}));const k=lu.default({},{type:l,data:{datasets:r,labels:c},options:{onClick:()=>{n.selection.selectBlock(t,0,0)}}});if(d)lu.default(d.config,k),d.update();else{const x=b("canvas",["editor-chartjs-canvas"],m).getContext("2d");d=new window.Chart(x,k),f.chartObject=d}}catch(k){q5.error(`failed to resolve chart cdn: ${JSON.stringify(k)}`)}}async function W5(n,t){await Ge.lock("updateTableChart");try{await JB(n,t)}finally{Ge.release("updateTableChart")}}const G5=ee.default(W5,1e3);let Z5=null;function Gh(n,t,e){if(Z5!==t&&(G5.flush(),Z5=t),e.updateNow){W5(n,t);return}G5(n,t)}function Zh(n,t){Zt(t)&&Gh(n,t,{updateNow:!1})}function KB(n,t){Zt(t)&&Gh(n,t,{updateNow:!0})}const He={SCROLL:"container-scroll-tool",COMMON:"container-border-shadow",RIGHT:"container-right-border-shadow",LEFT:"container-left-border-shadow",LAYOUT_SIGN:"container-layout-border-shadow",ACTIVE:"active"},Pc={SCROLL_BAR:"container-scrollbar",FIXED:"fixed"},So={SCROLL_CONTAINER:"scroll-container",TOOL:"container-scroll-tool",CONTAINER:"scroll-container-root",MAC:"mac",SCROLL_AREA:"scroll-area"};function $c(n,t){return n.containers.get(t)}function Q5(n){return n.closest(`.${So.SCROLL_CONTAINER}`)}function hn(n){return n.firstElementChild}function Oe(n){return n.closest(`.${So.CONTAINER}`)}function Ps(n){const t=Oe(n);let e=t.querySelector(`:scope >.${So.TOOL}`);return e||(e=b("div",[So.TOOL],t)),e}function XB(n){return Oe(n).firstElementChild}function _c(n){let t;return n instanceof HTMLElement?t=n.offsetWidth:t=Number.parseInt(getComputedStyle(n).width,10),n.getBoundingClientRect().width/t}function je(n,t){const e=_c(n);return t/e}function $s(n){const t=window.getComputedStyle(n),e=_c(n);return{paddingBottom:parseFloat(t.paddingBottom)*e,paddingTop:parseFloat(t.paddingTop)*e,paddingLeft:parseFloat(t.paddingLeft)*e,paddingRight:parseFloat(t.paddingRight)*e}}function Kr(n){const t=_c(n);return{scrollLeft:n.scrollLeft*t,scrollWidth:n.scrollWidth*t,clientWidth:n.clientWidth*t,clientHeight:n.clientHeight*t}}function tE(n,t){const e=_c(n);return n[t]*e}function Qh(n,t){const e=Oe(t),o=$c(n,e),r=(o==null?void 0:o.safeRightSpace)||0,i=(o==null?void 0:o.safeLeftSpace)||0,l=(o==null?void 0:o.locatingContainer).getBoundingClientRect(),c=e.getBoundingClientRect(),a=c.width;let d=Math.floor(c.left-l.left-i);d<0&&(d=0);let f=l.right;f-=r;let m=f-c.right;return m<0&&(m=0),d=Math.round(d),m=Math.round(m),{originWidth:a,maxLeft:d,maxRight:m}}function eE(n,t){const e=Qh(n,t),{maxLeft:o}=e;t.style.marginLeft=`${je(t,0-o)}px`,t.style.paddingLeft=`${je(t,o)}px`}function nE(n,t){const e=Qh(n,t);t.style.marginRight=`${je(t,0-e.maxRight)}px`}function oE(n){if(n!==document.documentElement&&n!==document.body)return n.getBoundingClientRect();const t=0,e=0,o=document.documentElement.clientWidth,r=document.documentElement.clientHeight;return new DOMRect(t,e,o,r)}const Y5=w("scroll-bar-handle"),rE=2;function Xr(n){const t=Ps(n);let e=t.querySelector(`.${Pc.SCROLL_BAR}`);return e||(e=b("div",[Pc.SCROLL_BAR],t)),u(Y5,e instanceof HTMLDivElement,"invalid child for container tools"),e.firstElementChild||b("div",[],e),e}function Fc(n,t){const e=Q5(t),o=Xr(e),{scrollWidth:r,clientWidth:i}=Kr(e),{paddingLeft:s,paddingRight:l}=$s(t);e.style.marginLeft="",e.style.paddingLeft="",e.style.marginRight="";const c=Qh(n,e),{originWidth:a,maxRight:d}=c;nE(n,e),eE(n,e);const f=r-i;u(Y5,o.firstElementChild instanceof HTMLDivElement,"invalid child for scroll bar"),o.style.width=`${je(e,a+d-s-l)}px`,o.firstElementChild.style.width=`${je(e,a+d+f-s-l)}px`}function iE(n,t){const e=hn(n),{paddingLeft:o}=$s(e);if(rt(t,"fixed")){const i=Oe(n).getBoundingClientRect();t.style.left=`${je(n,i.left+o)}px`}else t.style.left=`${je(n,o)}px`}function ti(n,t){var E;const e=n.getParentScrollContainer(),o=oE(e),r=t.getBoundingClientRect(),i=Xr(t),s=i.getBoundingClientRect(),l=$c(n,Oe(t)),c=(l==null?void 0:l.barFloatWindowBottom)||0,a=hn(t),{paddingTop:d,paddingBottom:f}=$s(a),{scrollWidth:m,clientWidth:p}=Kr(t),A=document.documentElement.clientHeight-c,k=o.top+Kr(e).clientHeight-A,v=A+Math.min(0,k);if(m>p&&r.top+d<v-s.height&&r.bottom>v-s.height+f&&!((E=l==null?void 0:l.isSetScale)!=null&&E.call(l))){M(i,Pc.FIXED);const L=k>0?c:0;i.style.bottom=`${Math.max(document.documentElement.clientHeight-o.bottom,0)+rE+L}px`}else H(i,Pc.FIXED),i.style.bottom=`${je(t,f-s.height)}px`;iE(t,i)}class sE{constructor(t,e){h(this,"intersectionObserver");h(this,"handleIntersection",t=>{t.forEach(e=>{this.containers.get(Oe(e.target))?(this.handleIntersectionEntry(e),this.callback(e)):this.intersectionObserver.unobserve(e.target)})});h(this,"handleIntersectionEntry",t=>{const e=t.target;ti(this.scrollCore,e);const o=hn(e);Fc(this.scrollCore,o)});this.scrollCore=t,this.callback=e;const r={root:this.scrollCore.getParentScrollContainer(),rootMargin:"20px",threshold:0};this.intersectionObserver=new IntersectionObserver(this.handleIntersection,r)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.intersectionObserver.observe(t)}unbind(t){this.intersectionObserver.unobserve(t)}destroy(){this.intersectionObserver.disconnect()}}const dr=w("container-scroll-shadow");function J5(n,t,e){const o=n,r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),{paddingTop:s,paddingBottom:l}=$s(e);o.style.top=`${je(t,i.top-r.top+s)}px`,o.style.bottom=`${je(t,r.bottom-i.bottom+l)}px`}function K5(n,t){const e=n;t<24?e.style.width=`${(t/3).toFixed(2)}px`:e.style.width=""}function lE(n){const t=Ps(n);u(dr,t,"no container tools");let e=t.querySelector(`.${He.LEFT}`);if(!e){const l=hn(n),c=[He.COMMON,He.LEFT];e=b("div",c,t),u(dr,e instanceof HTMLDivElement,"invalid child for container tools"),J5(e,n,l)}u(dr,e instanceof HTMLElement,"invalid child for container tools");const r=Oe(n).getBoundingClientRect(),i=n.getBoundingClientRect();e.style.left=`${je(n,i.left-r.left)}px`;const s=Kr(n).scrollLeft;u(dr,e instanceof HTMLDivElement,"invalid child for container tools"),K5(e,s),M(e,He.ACTIVE)}function cE(n){const t=Ps(n);let e=t.querySelector(`.${He.RIGHT}`);if(!e){const d=hn(n),f=[He.COMMON,He.RIGHT];e=b("div",f,t),u(dr,e instanceof HTMLDivElement,"no div, create shadow failed"),J5(e,n,d)}u(dr,e instanceof HTMLElement,"");const r=Oe(n).getBoundingClientRect(),i=n.getBoundingClientRect();e.style.right=`${je(n,r.right-i.right)}px`;const{scrollWidth:s,scrollLeft:l,clientWidth:c}=Kr(n),a=s-l-c;u(dr,e instanceof HTMLDivElement,"no shadow element"),K5(e,a),M(e,He.ACTIVE)}function aE(n){const e=Ps(n).querySelector(`.${He.LEFT}`);e&&H(e,He.ACTIVE)}function uE(n){const e=Ps(n).querySelector(`.${He.RIGHT}`);e&&H(e,He.ACTIVE)}function _s(n){const{scrollLeft:t,scrollWidth:e,clientWidth:o}=Kr(n),r=hn(n),{paddingLeft:i,paddingRight:s}=$s(r),l=tE(r,"offsetLeft");e-i<=o-s||e-i<=t+o-s?uE(n):cE(n),r&&t>=l+i?lE(n):aE(n)}class dE{constructor(t,e){h(this,"resizeObserver");h(this,"handleResizeEntry",t=>{const e=t.target,o=hn(e);_s(e),Fc(this.scrollCore,o),ti(this.scrollCore,e),this.callback(e)});h(this,"handleContentResize",t=>{t.forEach(e=>{this.containers.get(Oe(e.target))?this.handleResizeEntry(e):this.unbind(e.target)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new ResizeObserver(this.handleContentResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}const X5=w("container-scroll-observer");class hE{constructor(t,e){h(this,"handleContentScroll",t=>{const e=t.target;u(X5,e instanceof Element,"invalid target for scroll event");const o=Xr(e);o.removeEventListener("scroll",this.handleScroll);const r=!0;this.fixScrollXPos(e,e.scrollLeft,r),this.bind(o),_s(e),this.callback(e)});h(this,"handleScroll",t=>{const e=t.target;u(X5,e instanceof HTMLElement,"");const o=e.scrollLeft,r=!1,i=XB(e);this.unbindContentScroll(i),this.fixScrollXPos(i,o,r),this.bindContentScroll(i),_s(i),this.callback(i)});h(this,"handlePrevent",t=>{t.stopPropagation()});h(this,"bindContentScrollCore",t=>{this.unbindContentScroll(t),t.addEventListener("scroll",this.handleContentScroll)});h(this,"unbindContentScroll",t=>{t.removeEventListener("scroll",this.handleContentScroll)});h(this,"bindContentScroll",ee.default(this.bindContentScrollCore,300));h(this,"bind",ee.default(this.bindCore,200));this.scrollCore=t,this.callback=e}fixScrollXPos(t,e,o){const r=Xr(t);o||(t.scrollLeft=e),o&&r.scrollLeft!==e&&(r.scrollLeft=e)}bindCore(t){this.unbind(t),t.addEventListener("scroll",this.handleScroll),t.addEventListener("mousedown",this.handlePrevent)}unbind(t){t.removeEventListener("scroll",this.handleScroll),t.removeEventListener("mousedown",this.handlePrevent)}}class fE{constructor(t){h(this,"scrollContainers",new Set);h(this,"handleParentContainerScroll",()=>{this.scrollContainers.forEach(t=>{ti(this.scrollCore,t)})});h(this,"bindScrollContainer",t=>{const e=this.scrollContainers.size===0;this.scrollContainers.add(t),e&&this.eventTarget.addEventListener("scroll",this.handleParentContainerScroll)});h(this,"unbindScrollContainer",t=>{let e=!1;this.scrollContainers.has(t)&&(this.scrollContainers.delete(t),e=this.scrollContainers.size===0),e&&this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll)});this.scrollCore=t}get eventTarget(){const t=this.scrollCore.getParentScrollContainer();return t===document.documentElement?document:t}destroy(){this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll),this.scrollContainers.clear()}}const mE=w("scroll-wrap-resize-observer");class gE{constructor(t){h(this,"resizeObserver");h(this,"handleScrollWrapResize",t=>{t.forEach(e=>{this.containers.get(Oe(e.target))?this.handleScrollWrapResizeEntry(e):this.unbind(e.target)})});h(this,"handleScrollWrapResizeEntry",t=>{const e=t.target;u(mE,e instanceof HTMLElement,"invalid target for observer entry");const o=Q5(e);Fc(this.scrollCore,e),_s(o),ti(this.scrollCore,o)});this.scrollCore=t,this.resizeObserver=new ResizeObserver(this.handleScrollWrapResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}class pE{constructor(t,e){h(this,"resizeObserver");h(this,"scrollContainersMap",new Map);h(this,"handleResizeEntry",t=>{t==null||t.forEach(e=>{const o=hn(e);_s(e),Fc(this.scrollCore,o),ti(this.scrollCore,e),this.callback(e)})});h(this,"handleResize",t=>{t.forEach(e=>{const o=this.scrollContainersMap.get(e.target);o!=null&&o.length&&this.handleResizeEntry(o)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new ResizeObserver(this.handleResize)}bind(t){var r,i;const e=Oe(t),o=(r=$c(this.scrollCore,e))==null?void 0:r.locatingContainer;this.scrollContainersMap.has(o)?(i=this.scrollContainersMap.get(o))==null||i.push(t):(this.scrollContainersMap.set(o,[t]),this.resizeObserver.observe(o))}unbind(t){var i,s;const e=Oe(t),o=(i=$c(this.scrollCore,e))==null?void 0:i.locatingContainer;if(!o)return;const r=this.scrollContainersMap.get(o);this.scrollContainersMap.set(o,(r==null?void 0:r.filter(l=>l!==t))||[]),(s=this.scrollContainersMap.get(o))!=null&&s.length||(this.resizeObserver.unobserve(o),this.scrollContainersMap.delete(o))}destroy(){this.scrollContainersMap.clear(),this.resizeObserver.disconnect()}}const sV="";class CE extends Yt.TypedEmitter{constructor(e){super();h(this,"containerIntersectionObserver",null);h(this,"containerResizeObserver",null);h(this,"containerScrollObserver",null);h(this,"parentContainerScrollObserver",null);h(this,"scrollWrapResizeObserve",null);h(this,"locatingContainerResizeObserver",null);h(this,"isWindowEventBind",!1);h(this,"containers",new Map);h(this,"handleScrollContainerScroll",e=>{this.emit("scroll",this,e)});h(this,"handleResize",e=>{this.emit("resize",this,e)});h(this,"handleIntersection",e=>{const o=e.target,r=hn(o);e.isIntersecting?(this.load(),this.bindCore(o,r)):this.unbindCore(o,r)});h(this,"handleWindowEffect",()=>{var e;(e=this.getScrollContainerInViewable())==null||e.forEach(o=>{ti(this,o)})});this.parentContainer=e}load(){this.containerResizeObserver||(this.containerResizeObserver=new dE(this,this.handleResize)),this.containerScrollObserver||(this.containerScrollObserver=new hE(this,this.handleScrollContainerScroll)),this.parentContainerScrollObserver||(this.parentContainerScrollObserver=new fE(this)),this.scrollWrapResizeObserve||(this.scrollWrapResizeObserve=new gE(this)),this.locatingContainerResizeObserver||(this.locatingContainerResizeObserver=new pE(this,this.handleResize)),this.isWindowEventBind||(window.addEventListener("resize",this.handleWindowEffect),this.getParentScrollContainer()!==document.documentElement&&window.addEventListener("scroll",this.handleWindowEffect))}getParentScrollContainer(){return this.parentContainer}getScrollContainerInViewable(){var e;return(e=this.parentContainerScrollObserver)==null?void 0:e.scrollContainers}unbindCore(e,o){var i,s,l,c,a,d;const r=Xr(e);(i=this.containerScrollObserver)==null||i.unbindContentScroll(e),(s=this.containerScrollObserver)==null||s.unbind(r),(l=this.scrollWrapResizeObserve)==null||l.unbind(o),(c=this.containerResizeObserver)==null||c.unbind(e),(a=this.parentContainerScrollObserver)==null||a.unbindScrollContainer(e),(d=this.locatingContainerResizeObserver)==null||d.unbind(e)}bindCore(e,o){var i,s,l,c,a,d;if(this.unbindCore(e,o),!e.closest("body"))return;const r=Xr(e);(i=this.containerScrollObserver)==null||i.bindContentScrollCore(e),(s=this.containerScrollObserver)==null||s.bindCore(r),(l=this.scrollWrapResizeObserve)==null||l.bind(o),(c=this.containerResizeObserver)==null||c.bind(e),(a=this.parentContainerScrollObserver)==null||a.bindScrollContainer(e),(d=this.locatingContainerResizeObserver)==null||d.bind(e)}bind(e,o){this.containers.set(e,o);const r=e.firstElementChild;this.containerIntersectionObserver||(this.containerIntersectionObserver=new sE(this,this.handleIntersection)),this.containerIntersectionObserver.bind(r)}unbind(e){var i;const o=e.firstElementChild,r=hn(o);this.unbindCore(o,r),this.containers.delete(e),(i=this.containerIntersectionObserver)==null||i.unbind(o),this.containers.size||this.destroy()}destroy(){var e,o,r,i,s;this.containers.forEach((l,c)=>{this.unbind(c)}),this.containers.clear(),(e=this.parentContainerScrollObserver)==null||e.destroy(),(o=this.containerIntersectionObserver)==null||o.destroy(),(r=this.containerResizeObserver)==null||r.destroy(),(i=this.scrollWrapResizeObserve)==null||i.destroy(),(s=this.locatingContainerResizeObserver)==null||s.destroy(),window.removeEventListener("resize",this.handleWindowEffect),window.removeEventListener("scroll",this.handleWindowEffect)}}const tC=w("scroll-container"),Hc=new Map;class AE extends Yt.TypedEmitter{constructor(){super(...arguments);h(this,"scrollListener");h(this,"options");h(this,"scrollContainerElement");h(this,"init",e=>{this.options=e;const o=b("div",[So.CONTAINER],e.parentElement);xt.isMac&&M(o,So.MAC);const r=b("div",[So.SCROLL_CONTAINER],o),i=b("div",[So.SCROLL_AREA],r);i.style.paddingLeft=e.paddingLeft?`${e.paddingLeft}px`:"",i.style.paddingTop=e.paddingTop?`${e.paddingTop}px`:"",i.style.paddingBottom=e.paddingBottom?`${e.paddingBottom}px`:"",i.style.paddingRight=e.paddingRight?`${e.paddingRight}px`:"",i.appendChild(e.childElement);const s=e.parentContainer;this.scrollListener=Hc.get(s),this.scrollListener||(this.scrollListener=new CE(s),Hc.set(s,this.scrollListener)),this.scrollListener.unbind(o),this.scrollListener.bind(o,e),this.scrollListener.on("scroll",this.handleContainerScroll),this.scrollListener.on("resize",this.handleResize),this.scrollContainerElement=r});h(this,"handleContainerScroll",(e,o)=>{o===this.scrollContainerElement&&this.emit("scroll",this)});h(this,"handleResize",(e,o)=>{o===this.scrollContainerElement&&this.emit("scroll",this)})}get rootElement(){return this.scrollContainerElement}get contentElement(){return u(tC,this.scrollContainerElement,"scrollContainerElement cannot be undefined"),hn(this.scrollContainerElement)}get scrollOptions(){return u(tC,this.options,"options cannot be undefined"),{...this.options}}handleBaseListenerDestroy(e){e.destroy()}destroy(){var o;(o=this.scrollListener)==null||o.off("scroll",this.handleContainerScroll);const e=Oe(this.contentElement);e&&Hc.forEach((r,i)=>{r.unbind(e),r.containers.size===0&&(this.handleBaseListenerDestroy(r),Hc.delete(i))})}}function bE(){return new AE}const jc=100,vE=40,Yh=w("column-width");function yE(n,t,e){IB(n,t).style.width=`${e}px`}function kE(n){const e=Array.from(n.querySelector("colgroup").children).map(c=>c.getBoundingClientRect().width);if(e[0]!==0)return e;const o=nt.fromTable(n),r=Array(o.colCount).fill(-1),i=n.getBoundingClientRect().left;o.toRealCells(o.cells).forEach(c=>{const a=c.col+c.colSpan-1;r[a]===-1&&(r[a]=c.cell.getBoundingClientRect().right-i)}),Yh.debug(`cellRightOffsets1: ${r.join()}`);for(let c=0;c<r.length;c++){const a=r[c];if(a===-1||c===0)continue;let d=c-1;for(;r[d]===-1&&(d--,d!==-1););const f=d===-1?0:r[d],p=(a-f)/(c-d);for(let A=d+1;A<c;A++)r[A]=f+p*(A-d)}Yh.debug(`cellRightOffsets2: ${r.join()}`);const s=[];let l=0;for(let c=0;c<r.length;c++){const a=r[c];s.push(a-l),l=a}return Yh.debug(`widths: ${s.join()}`),s}function Fs(n){return Array.from(n.querySelector("colgroup").children).map(o=>o.getBoundingClientRect().width||Number.parseInt(o.style.width,10)||100)}const wE=w("table-resize-gripper"),eC=7,Jh=(eC-1)/2,BE=3;function EE(n,t,e){const{rows:o}=n;for(let r=0;r<o.length;r++){const i=o[r],s=Array.from(i.cells);for(let l=0;l<s.length;l++){const c=s[l],a=c.getBoundingClientRect(),d=Math.round(a.right);if(Math.abs(t-d)<=Jh&&a.top<=e&&e<=a.bottom)return c}}return null}function IE(n){return!!n.rootContainer.querySelector(".table-resize-gripper")}function Kh(n,t){return Sn(n,t).querySelector(".table-resize-gripper")}function nC(n,t){const e=Kh(n,t);u(wE,!e,"resize gripper has already exists");const o=Sn(n,t),r=b("div",["table-resize-gripper","table-indicator"],o);return b("div",["table-resize-gripper-indicator"],r),r}function oC(n,t,e){let o=Kh(n,t);o||(o=nC(n,t));const i=jt(t).getBoundingClientRect(),s=e.getBoundingClientRect(),l=0,c=i.height,a=n.getCustom(Io(t)).contentElement.getBoundingClientRect(),d=s.right-a.left;o.style.left=`${d-Jh-zh-Os}px`,o.style.top=`${l}px`,o.style.height=`${c}px`,o.style.width=`${eC}px`}function Xh(n){n.rootContainer.querySelectorAll(".table-resize-gripper").forEach(t=>{t.remove()})}function xE(n,t,e){const r={...n.getBlockData(t),colsWidth:e};n.updateBlockData(t,r)}function TE(n,t,e,o){const r=t,i=nt.fromTable(e),s=i.getCellByCellElement(r),l=s.col+s.colSpan-1,c=Fs(e);let a=o;const d=(m,p)=>{const A=p+1,k=m.col+m.colSpan;return c.slice(A,k).reduce((x,E)=>x+E,0)},f=new Set;for(let m=0;m<i.rowCount;m++){const p=i.getCell({row:m,col:l});if(f.has(p.cell))continue;f.add(p.cell);const A=p.cell,k=A.getBoundingClientRect();let v=o-k.left+Jh-BE;const x=Ls(A),E=gd(n,x)||vE*p.colSpan,L=d(p,l),R=E-L;v<R&&(v=R);const $=k.left+v;a=Math.max(a,$)}return a}const SE=w("table-resize-drag-drop");class DE{constructor(t,e,o,r){h(this,"cursor","col-resize");this.editor=t,this.elem=e,this.data=o,this.onEnd=r}onDragStart(t,e,o){}onDragging(t,e,o,r,i){const{table:s,block:l,draggingRefCell:c}=t.data,d=TE(this.editor,c,s,e.x-t.dragOffsetX)-s.getBoundingClientRect().left;u(SE,c,"no dragging cell");const m=nt.fromTable(s).getCellByCellElement(c),p=m.col+m.colSpan-1,k=Fs(s).slice(0,p).reduce((x,E)=>x+E,0),v=d-k;yE(s,p,v),oC(this.editor,l,c),this.editor.selection.caret.update()}onDragEnd(t,e,o,r,i){const s=Fs(t.data.table);xE(this.editor,t.data.block,s),Xh(this.editor),this.onEnd&&(this.onEnd(e),this.onEnd=null)}}function LE(n,t){const e=document.elementFromPoint(t.x,t.y);if(!e)return null;const o=U(e);return!o||!n.contains(o)||!Zt(o)?null:o}w("table-resize");class ME{constructor(t){h(this,"draggingRefCell",null);h(this,"handleMouseMove",(t,e)=>{if(t.readonly||t.selectionHandler.isSelecting()&&!this.draggingRefCell||this.draggingRefCell)return;const o=e.target;if(!(o instanceof Element)||o.closest(".table-indicator"))return;const i=e,s=LE(t,i);if(!s||!M5(s)||!t.isBlockWritable(s)){Xh(t);return}this.updateGripper(s,i.x,i.y)});this.editor=t,t.domEvents.addEventListener(document,"mousemove",this.handleMouseMove)}destroy(){this.editor.domEvents.removeEventListener(document,"mousemove",this.handleMouseMove)}updateGripper(t,e,o){const r=jt(t),i=EE(r,e,o);if(i){if(!Kh(this.editor,t)){if(IE(this.editor))return;const l=nC(this.editor,t),c={block:t,table:r,draggingRefCell:i};Cu(new DE(this.editor,l,c,a=>{this.updateGripper(t,a.x,a.y)}))}oC(this.editor,t,i)}else Xh(this.editor)}}function rC(n){n.addCustom("table-mouse-event-handler",t=>new ME(t))}const iC=w("table-insert-column");function sC(n,t,e){n.undoManager.runInGroup(()=>{const o=jt(t),r=nt.fromTable(o),i=r.colCount;u(iC,e>=0&&e<=i,`insert index ${e} is out of range [0, ${i}]`);const s=r.map(m=>m.containerId),l=new Set;n.doc.beginBatchUpdate();for(let m=0;m<s.length;m++){const p=s[m],A=p[e-1],k=p[e];if(e===0||e===p.length||A!==k){const v=Bn(n.doc);p.splice(e,0,v)}else p.splice(e,0,A),l.add(A)}n.doc.endBatchUpdate();const c=Q.default(n.getBlockData(t));l.forEach(m=>{const p=`${m}_colSpan`,A=c[p];u(iC,typeof A=="number"&&A>1,`no colSpan for containerId ${m}, ${A}`),c[p]=A+1});const a=c.colsWidth.concat();a.splice(e,0,jc);const d=nt.virtualCellContainersGridToChildren(s),f={...c,cols:c.cols+1,children:d,colsWidth:a};ar(f),n.updateBlockData(t,f)})}const zc=w("table-insert-row");function lC(n,t,e){n.undoManager.runInGroup(()=>{const o=jt(t),r=nt.fromTable(o),i=r.rowCount;u(zc,e>=0&&e<=i,`insert index ${e} is out of range [0, ${i}]`);const s=r.map(m=>m.containerId),l=new Set;n.doc.beginBatchUpdate();const c=[];for(let m=0;m<r.colCount;m++){const p=e>0&&s[e-1][m],A=e<r.rowCount&&s[e][m];if(u(zc,p||A,"no top and bottom cell"),e===0||e===r.rowCount||p!==A){const k=Bn(n.doc);c.push(k)}else u(zc,p,"no top cell"),c.push(p),l.add(p)}n.doc.endBatchUpdate(),s.splice(e,0,c);const a=Q.default(n.getBlockData(t));l.forEach(m=>{const p=`${m}_rowSpan`,A=a[p];u(zc,typeof A=="number"&&A>1,`no rowSpan for containerId ${m}, ${A}`),a[p]=A+1});const d=nt.virtualCellContainersGridToChildren(s),f={...a,rows:a.rows+1,children:d};ar(f),n.updateBlockData(t,f)})}const t1=w("paste-table-in-table-block");function RE(n,t,e,o){let r=nt.fromBlock(e);const i=t.blocks.root[0];u(t1,i,"no table data"),u(t1,i.type==="table",`table data type is not table, but ${i.type}`);const s=i,l=r.getCellByCellElement(o),c=s.cols,a=s.rows,d=l.col,f=l.row,m=d+c,p=f+a,A=[];for(let k=d;k<m&&k<r.colCount;k++)for(let v=f;v<p&&v<r.rowCount;v++){const x=r.getCell({col:k,row:v});x.virtual?x.virtual&&A.push({col:k,row:v}):(x.colSpan>1||x.rowSpan>1)&&A.push({col:k,row:v})}n.undoManager.runInGroup(()=>{if(A.forEach(E=>{const L=nt.fromBlock(e).getCell(E);(L.colSpan>1||L.rowSpan>1)&&_h(n,e,E)}),m>r.colCount)for(let E=r.colCount;E<m;E++)sC(n,e,E);if(p>r.rowCount)for(let E=r.rowCount;E<p;E++)lC(n,e,E);r=nt.fromBlock(e);const k=new Mc(s);let v;for(let E=0;E<k.colCount;E++)for(let L=0;L<k.rowCount;L++){const R=k.getCell({col:E,row:L});if(!R.virtual){const $=Md(n.editorBlocks,t,R.containerId),q=d+E,ot=f+L,lt={col:q,row:ot},gt=r.getCellContainer(lt);s0(n,gt,$),v=gt}}u(t1,v,"no last container");const x=Jt(v);n.selection.selectBlock(x,G(n,x))})}const cC=w("paste-in-table-block");class OE{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePasteDoc(t,e){if(!t.selection.range.isSimple()||t.selection.range.start.offset!==0)return!1;const r=t.selection.startBlock,i=z(r);if(Ct(i)||!pd(t,i))return!1;const s=U(i);if(u(cC,s,"no parent block"),!Zt(s)||e.blocks.root.length!==1||e.blocks.root[0].type!=="table")return!1;cC.debug("paste child table in table");const a=nt.fromBlock(s).getCellByContainerId(V(i)).cell;return RE(t,e,s,a),!0}}function aC(n){n.addCustom("table-block-paste-event",t=>new OE(t))}const e1=w("table-select-columns");function NE(n,t,e,o,r){u(e1,Zt(t),"is not a table block");const i=nt.fromBlock(t);u(e1,e>=0&&e<i.colCount,"invalid from"),u(e1,o>0&&e+o<=i.colCount,"invalid count");const s=i.getCell({row:0,col:e}),l=i.getCell({row:i.rowCount-1,col:e+o-1}),c=Bt(t,s.containerId,{colIndex:e,rowIndex:0}),a=Bt(t,l.containerId,{colIndex:e+o-1,rowIndex:i.rowCount-1});r!=null&&r.reverse?n.selection.setSelection(a,c):n.selection.setSelection(c,a)}const n1=w("table-select-columns");function PE(n,t,e,o,r){u(n1,Zt(t),"is not a table block");const i=nt.fromBlock(t);u(n1,e>=0&&e<i.rowCount,"invalid from"),u(n1,o>0&&e+o<=i.rowCount,"invalid count");const s=i.getCell({row:e,col:0}),l=i.getCell({row:e+o-1,col:i.colCount-1}),c=Bt(t,s.containerId,{rowIndex:e,colIndex:0}),a=Bt(t,l.containerId,{rowIndex:e+o-1,colIndex:i.colCount-1});r!=null&&r.reverse?n.selection.setSelection(a,c):n.selection.setSelection(c,a)}const lV="",uC=w("get-toolbar-reference-client");function $E(n,t){const e=n.selection.range;if(!e.isSimple()){u(uC,e.start.blockId===e.end.blockId,"invalid selection range");const s=n.getBlockById(e.start.blockId);u(uC,at(n,s),"not a complex block");const l=pt(n,s);if(l.getTextToolbarReferenceClient){const c=l.getTextToolbarReferenceClient(n,s);if(c)return c}}const o=e.isReverse()?t.start:t.end,r=Wt(n,{anchor:o,focus:o}),i=co(n,t.block,r);if(i.length!==0)return i[0]}function _E(n){var t,e;if(n.children){let o=!1;const r=[];for(const i of n.children){if((t=i.states)!=null&&t.includes("checked")){o=!0;break}(e=n.defaultCheckedChildren)!=null&&e.includes(i.id)&&r.push(i)}if(!o&&(r==null?void 0:r.length))for(const i of r)Array.isArray(i.states)?i.states.push("checked"):i.states=["checked"]}}function Uc(n){const t=(r,i)=>{const s=r.findIndex(c=>c.id===i.id);if(s===-1){r.push(i);return}const l=r[s];if(l.value!==i.value&&delete l.value,!!l.states){if(!i.states){l.states=[];return}l.states=cu.default(l.states,i.states)}},e=[],o=new Map;return n.forEach(r=>{var i,s;(i=r.children)!=null&&i.length&&(o.has(r.id)?(s=o.get(r.id))==null||s.push(...r.children):o.set(r.id,[...r.children])),t(e,r)}),o.forEach((r,i)=>{const s=e.find(l=>l.id===i);s&&(s.children=Uc(r),_E(s))}),e}function Vc(n){return n.getCustom("toolbar-handler")}const cV="";class FE{constructor(){h(this,"linkPopup",null);h(this,"form",{});h(this,"onFinished",null);h(this,"onClose",null);h(this,"handleOk",async()=>{var t;try{await this.checkValue();const{linkText:e,linkUrl:o}=this.form,r=this.formatUrl(o.getInputValue());(t=this.onFinished)==null||t.call(this,e.getInputValue()||r,r),this._destroy()}catch{}});h(this,"handleClose",()=>{var t;(t=this.onClose)==null||t.call(this),this._destroy()});h(this,"onShow",()=>{setTimeout(()=>{var t;(t=this.form.linkText)==null||t.getField().focus()},400)});h(this,"onChange",()=>{var e;const t=(e=this.linkPopup)==null?void 0:e.content.querySelector(".submit-button");t.disabled=!1});h(this,"handleTextKeyboard",t=>{var e;if(!t.isComposing){if(t.key==="Enter"){(e=this.form.linkUrl)==null||e.getField().focus(),t.stopPropagation();return}t.key==="Escape"&&this.handleClose()}});h(this,"handleUrlKeyboard",t=>{if(!t.isComposing){if(t.key==="Enter"){this.handleOk(),t.preventDefault();return}t.key==="Escape"&&this.handleClose()}})}async checkValue(){const{linkUrl:t}=this.form;if(!t.getInputValue())throw t.setFieldError(T.t("link.urlPlaceholder")),new Error(T.t("link.urlPlaceholder"))}formatUrl(t){if(!t)return"";try{new URL(t)}catch{return`${window.location.protocol}//${t}`}return t}editLink(t){var d,f;const{target:e,linkText:o,linkUrl:r,onFinished:i,onClose:s,placement:l="bottom-start"}=t;this.linkPopup=new Is(this.createPopupContent(o,r)),this.linkPopup.addListener("show",this.onShow),this.linkPopup.manualShow(e,{theme:"light",placement:l}),this.onFinished=i,s&&(this.onClose=s);const c=(d=this.linkPopup)==null?void 0:d.content.querySelector(".submit-button"),a=(f=this.linkPopup)==null?void 0:f.content.querySelector(".cancel-button");c==null||c.addEventListener("click",this.handleOk),a==null||a.addEventListener("click",this.handleClose)}createPopupContent(t,e){const o=b("div",["link-popup-content"],null);this.form.linkText=Sh(o,{label:T.t("link.textLabel"),required:!1,placeholder:T.t("link.textPlaceholder"),defaultValue:t,onChange:this.onChange,onKeyDown:this.handleTextKeyboard}),this.form.linkUrl=Sh(o,{className:"link-popup-gap",label:T.t("link.urlLabel"),required:!0,placeholder:T.t("link.urlPlaceholder"),defaultValue:e,onChange:this.onChange,onKeyDown:this.handleUrlKeyboard});const r=b("div",["link-popup-footer"],o);b("button",["cancel-button"],r,T.t("link.cancelText"));const i=b("button",["submit-button"],r,T.t("link.submitText"));return i.disabled=!0,o}_destroy(){var o,r,i,s;const t=(o=this.linkPopup)==null?void 0:o.content.querySelector(".submit-button"),e=(r=this.linkPopup)==null?void 0:r.content.querySelector(".cancel-button");t==null||t.removeEventListener("click",this.handleOk),e==null||e.removeEventListener("click",this.handleClose),this.onFinished=null,this.onClose=null,this.form={},(i=this.linkPopup)==null||i.removeAllListeners(),(s=this.linkPopup)==null||s.destroy()}destroy(){this._destroy()}}function Hs(n,t){n.addCustom("link-editor",()=>new FE).editLink(t)}const HE=w("link-popup");function jE(n){return rt(n,"link")}function js(n){var t,e;return(e=(t=n.getAttribute("link"))!=null?t:n.textContent)!=null?e:""}function zE(n,t,e){var r,i,s,l;if(n.isBlockWritable(t)&&e&&Pe(e)){const c=e,a=(i=(r=n.editorBoxes.getBoxClass(ji(c))).getBoxProperties)==null?void 0:i.call(r,n,c);return a!=null&&a.boxCommands?(l=(s=a.boxCommands["hovering-toolbar"])==null?void 0:s.commands)!=null?l:[]:[]}if(n.isWritable()&&e&&_(n,t)&&jE(e)){const c=b("a",["link-href-button"],null,js(e));return c.href=js(e),c.target="_blank",c.rel="noopener noreferrer",[{id:"link-text",name:js(e),disableTooltip:!0,element:c},{id:"edit-link",name:"Edit",icon:xh},{id:"remove-link",name:"Remove link",icon:Nw}]}return Bg(n,t,"hovering-toolbar")}function UE(n,t,e){var c;const o=mo(t,e);n.selection.selectBlock(t,o.start,o.end);const r=(c=e.textContent)!=null?c:"",i=js(e);Hs(n,{target:e,linkText:r,linkUrl:i,onFinished:(a,d)=>{try{const f=n.getBlockText(t),m=ed(f,o.start,o.end-o.start),p=po(m,o.start,a,{link:d});n.setBlockText(t,p),n.selection.selectBlock(t,o.start+a.length),n.focus()}catch(f){HE.error(f)}},onClose:()=>{n.selection.selectBlock(t,o.end),n.focus()}})}function VE(n,t,e){const o=mo(t,e),r=n.getBlockText(t),i=js(e),s=Nr(o.start,o.end-o.start,r,"link",i);n.setBlockText(t,s),n.selection.selectBlock(t,o.end)}function qE(n,t,e,o){var s,l,c;if(e){if(n.isBlockWritable(t)&&Pe(e)){const d=e,f=(l=(s=n.editorBoxes.getBoxClass(ji(d))).getBoxProperties)==null?void 0:l.call(s,n,d);if(f!=null&&f.boxCommands){f.boxCommands["hovering-toolbar"].executeCommand(n,t,d,o);return}return}const a=Vc(n);a.disableTextToolbar(),a.hide(),setTimeout(()=>{a.enableTextToolbar()},1e4),o.id==="edit-link"?UE(n,t,e):o.id==="remove-link"&&VE(n,t,e);return}const r=wg(n,t);if(!r)return;const i=(c=r.blockCommands)==null?void 0:c["hovering-toolbar"];!i||i.executeCommand(n,t,o)}function qc(){let n=8;for(;n>0&&!document.querySelector(`div[data-style-heading='${n}']`);)n--;return n}const WE=[Ch,Ah,bh,vh,yh,kh,wh,Bh];class GE{constructor(t){h(this,"id","BlockTurnIntoCommandProvider");this.editor=t}getHeadingIndex(){let t=qc();return t<=4?t=5:t<8&&(t+=1),t}getAvailableCommands(t,e,o){if(_(t,e)){const r=j(e),i=it(e),s=Je(t,e),c=t.getBlockData(e).heading,a=[];for(let f=0;f<this.getHeadingIndex();f++)a.push({id:`heading-${f+1}`,name:T.t("commands.heading",{name:`${f+1}`}),icon:WE[f],states:c===f+1?["checked"]:[],value:`${f+1}`});const d=f=>{var p;const m=b("span",["toolbar-item-name-container"],null);for(const A of f.children)if((p=A.states)!=null&&p.includes("checked"))return m.innerHTML=A.icon||Lc,m;return m.innerHTML=Lc,m};return[{id:"turn-into",name:T.t("commands.headingGroup"),blockId:r,blockType:i,blockKind:s,element:d,groupIndex:200,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["text"],children:[{id:"text",name:T.t("commands.text"),icon:Lc,states:c?[]:["checked"]},...a],childrenType:"menu"}]}return[]}applyHeadingStyle(t,e,o){t.updateBlockData(e,{heading:o})}executeCommand(t,e,o,r){if(_(t,e)&&(r.id.startsWith("heading-")||r.id==="text")){const i=r.value?Number(r.value):null;return this.applyHeadingStyle(t,e,i),!0}return!1}}function Wc(n){const t=n.getAttribute("block-padding-level");return t?Number(t):null}function ZE(n,t){let e;const o=Wc(t);if(!o)e=1;else{if(o>=12)return e=12,!1;e=o+1}return n.updateBlockData(t,{...n.getBlockData(t),padding:e}),!0}function dC(n,t){const e=Wc(t);if(!e)return!1;const o=n.getBlockData(t);return e>1?(n.updateBlockData(t,{...o,padding:e-1}),!0):(n.updateBlockData(t,{...o,padding:null}),!0)}function o1(n){return n.readonly||!n.isWritable()}function QE(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const o=e.block;_(n,o)&&ZE(n,o)}),!0}function YE(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const o=e.block;_(n,o)&&dC(n,o)}),!0}function JE(n){return o1(n)?!1:n.undoManager.runInGroup(()=>(QE(n),!0))}function KE(n){return o1(n)?!1:n.undoManager.runInGroup(()=>(YE(n),!0))}function XE(n){if(o1(n))return!1;if(!n.selection.range.isCollapsed())return;const t=n.selection.focusedBlock;if(!_(n,t))return;const e=n.selection.range.focus;if(!(!e.isSimple()||e.offset!==0||!Wc(t)))return dC(n,t),!0}class tI{renderBlock(t,e,o){const{padding:r}=o;return r?{attributes:{"block-padding-level":r}}:{}}}const aV="",eI={Tab:JE,"Shift+Tab":KE,Backspace:XE},Gc=w("list-block");function ut(n){return it(n)==="list"}function zt(n){u(Gc,ut(n),"not a list block")}function ze(n){zt(n);const t=n.getAttribute("data-list-type");return u(Gc,t,"no list type"),t}function Zc(n){return ut(n)&&ze(n)==="text-only"}function Ue(n){var t,e;return zt(n),(e=Number.parseInt((t=n.getAttribute("data-list-start"))!=null?t:"1",10))!=null?e:1}function Ae(n){var t,e;return zt(n),(e=Number.parseInt((t=n.getAttribute("data-list-level"))!=null?t:"1",10))!=null?e:1}function ei(n){zt(n);const t=n.getAttribute("data-list-group-id");return u(Gc,t,"no group id"),t}function Do(n){var i,s,l,c,a;zt(n);const t=(i=n.getAttribute("data-list-type"))!=null?i:"ordered",e=(l=Number.parseInt((s=n.getAttribute("data-list-start"))!=null?s:"1",10))!=null?l:1,o=(a=Number.parseInt((c=n.getAttribute("data-list-level"))!=null?c:"1",10))!=null?a:1,r=n.getAttribute("data-list-group-id");return u(Gc,r,"no group id"),{type:t,start:e,level:o,groupId:r}}function r1(n){switch(n){case"ordered":return{ordered:!0,checkbox:null,textOnly:null};case"unordered":return{ordered:!1,checkbox:null,textOnly:null};case"checked":return{checkbox:"checked",ordered:!1,textOnly:null};case"unchecked":return{checkbox:"unchecked",ordered:!1,textOnly:null};case"text-only":return{checkbox:null,ordered:!1,textOnly:!0};default:return{checkbox:null,ordered:!0,textOnly:!1}}}function Lo(n,t){zt(n);const{level:e,groupId:o,type:r}=Do(n);let i=bt(n);for(;i;){if(!ut(i))return null;const{level:s,groupId:l,type:c}=Do(i);if(s<e)return null;if(e===s&&((t==null?void 0:t.ignoreGroupId)||o===l)&&(c==="text-only"||r==="text-only"||r===c))return i;i=bt(i)}return null}function hC(n){return Lo(n,{ignoreGroupId:!0})}function hr(n){zt(n);const{level:t,groupId:e,type:o}=Do(n);let r=dt(n);for(;r;){if(ut(r)){const{level:i,groupId:s,type:l}=Do(r);if(t===i&&e===s&&(l==="text-only"||o==="text-only"||o===l))return r;if(i<t)return null}r=dt(r)}return null}function fC(n){zt(n);const t=[];let e=Lo(n);for(;e;)t.unshift(e),e=Lo(e);return t}function zs(n){zt(n);const t=[];let e=hr(n);for(;e;)t.push(e),e=hr(e);return t}function Us(n){zt(n);let t=Lo(n);for(;t;){const e=Lo(t);if(!e)return t;t=e}return n}function nI(n){zt(n);let t=hr(n);for(;t;){const e=hr(t);if(!e)return t;t=e}return null}function mC(n,t){const e=fC(n),o=zs(n);return t.withSelf?[...e,n,...o]:[...e,...o]}function Vs(n,t,e,o){var i;const r=(i=o==null?void 0:o.groupId)!=null?i:P();t.forEach(s=>{const l=n.getBlockData(s);if(l.start!==e||(o==null?void 0:o.resetGroupId)){const c={...l,start:e};o!=null&&o.resetGroupId&&(c.groupId=r),n.updateBlockData(s,c)}l.textOnly||(e+=1)})}function i1(n,t,e,o){const r=mC(t,{withSelf:!0});r.length!==0&&Vs(n,r,e,o)}function oI(n){const t={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};let e="",o=n;return Object.entries(t).forEach(([r,i])=>{for(;o>=i;)e+=r,o-=i}),e.toLowerCase()}const rI="abcdefghijklmnopqrstuvwxyz";function gC(n){if(n<=0)return`${n}`;const t=(n-1)%26,e=Math.floor((n-1)/26),o=rI[t];return e?gC(e)+o:o}function iI(n){return`${n}`}const pC=[iI,gC,oI];function sI(n,t){const e=pC[(n-1)%pC.length];return e(t)}function lI(n){return["\u2022","\u25E6","\u25AA"][(n-1)%3]}class fr{constructor(t,e,o){h(this,"listStart");h(this,"listBrother",null);this.editor=t,this.options=o;const r=Us(e),i=Ue(r);this.listStart=i,this.listBrother=r,o!=null&&o.resetStart&&(this.listStart=1)}fix(){!this.listBrother||i1(this.editor,this.listBrother,this.listStart,this.options)}}function cI(n,t,e=1){if(!t)return null;let o=bt(n);for(;o;){const r=o.getAttribute("data-style-heading"),i=Number(o.getAttribute("data-list-level"));if(r){if(r<t)return null;if(r===t&&i===e)return ut(o)?o:null}o=bt(o)}return null}function aI(n,t){const e=n.getAttribute("data-style-heading"),o=cI(n,e);if(o)return o;const r=bt(n);if(r&&ut(r)&&ze(r)===t)return r;const i=dt(n);return i&&ut(i)&&ze(i)===t?i:null}function uI(n,t,e){var k,v,x;const o=(k=e.data)!=null?k:{};let r=1;if(ut(t))r=Ae(t);else{const E=Wc(t);E&&(r=E+1),r>8&&(r=8)}const i=(v=o.listType)!=null?v:"ordered";if(i==="text-only")return null;const s=n.getBlockData(t);let l=(x=s.text)!=null?x:[],a=vt(l);const d=e.offset||0;d<=me(l)&&(l=ve(l,d).right,a=a.substring(0,d));let f=1;i==="ordered"&&(f=Number.parseInt(a,10)||1);let m=P();const p=aI(t,i);if(p){if(K(t)>K(p))f=Ue(p)+1;else{const E=Ue(p);E>1&&(f=E-1)}m=ei(p)}const A={id:P(),type:"list",level:r,start:f,groupId:m,ordered:!1,text:l};return s.quoted&&(A.quoted=!0),s.heading&&(A.heading=s.heading),i==="ordered"?A.ordered=!0:(i==="checked"||i==="unchecked")&&(A.checkbox=i),{blockData:A,onConverted:(E,L)=>{new fr(E,L).fix()}}}function ni(n){return n.textOnly?"text-only":n.checkbox?n.checkbox:n.ordered?"ordered":"unordered"}function dI(n){var e,o;if(n.checkbox||n.textOnly)return"";const t=(e=n.level)!=null?e:1;return n.ordered?`${sI(t,(o=n.start)!=null?o:1)}.`:lI(t)}function Qc(n){return n==="checked"||n==="unchecked"}function CC(n,t,e,o){const r=t,{containerId:i,blockIndex:s}=o[o.length-1];if(s===0)return!0;const l=e.blocks[i][s-1];if(l.type!=="list")return!0;const c=ni(r),a=ni(l);return c!==a&&(!Qc(c)||!Qc(a))||r.level>l.level}function AC(n,t,e,o){const r=t,{containerId:i,blockIndex:s}=o[o.length-1];if(s===e.blocks[i].length-1)return!0;const l=e.blocks[i][s+1];if(l.type!=="list")return!0;const c=ni(r),a=ni(l);return c!==a&&(!Qc(c)||!Qc(a))||r.level>l.level}function hI(n,t,e,o,r){var s,l,c;const i=t;if(o==="text"){let a=((s=ye.convertTo)==null?void 0:s.call(ye,n,t,e,"text",r))||"";i.checkbox==="checked"?a=`[x] ${a}`:i.checkbox==="unchecked"&&(a=`[ ] ${a}`),i.ordered?a=`${i.start}. ${a}`:a=`- ${a}`;const d=i.level||0;return a=(d>0?" ".repeat(d-1):"")+a,a}if(o==="markdown"){let a=((l=ye.convertTo)==null?void 0:l.call(ye,n,t,e,"markdown",r))||"";i.checkbox==="checked"?a=`[x] ${a}`:i.checkbox==="unchecked"&&(a=`[ ] ${a}`),i.ordered?a=`${i.start}. ${a}`:a=`- ${a}`;const d=i.level||0;return a=(d>0?" ".repeat(d-1):"")+a,CC(n,t,e,r)&&(a=`${a}`),AC(n,t,e,r)&&(a=`${a}`,d<=1&&(a+=`
|
|
341
341
|
`)),a}if(o==="html"){let a=((c=ye.convertTo)==null?void 0:c.call(ye,n,t,e,"html",r))||"";a=a.replace("<p>","").replace("</p>",""),i.checkbox==="checked"?a=`<input type="checkbox" checked="checked" disabled="disabled" /> ${a}`:i.checkbox==="unchecked"&&(a=`<input type="checkbox" disabled="disabled" /> ${a}`);let d="ul";return i.ordered?(a=`<li value="${i.start}">${a}</li>`,d="ol"):a=`<li>${a}</li>`,CC(n,t,e,r)&&(a=`<${d}>${a}`),AC(n,t,e,r)&&(a=`${a}</${d}>`),a}return""}const fI=8,Nt=w("list-block");class Yc{constructor(t,e){h(this,"listStart",0);h(this,"listBrother",null);if(this.editor=t,Zc(e))return;const o=Us(e),r=Ue(o);this.listStart=r,o===e?this.listBrother=hr(o):this.listBrother=o}fix(){!this.listBrother||i1(this.editor,this.listBrother,this.listStart)}}function mI(n,t,e){n.getBlockData(t).quoted&&(e.quoted=!0)}function s1(n,t,e,o){if(Nt.debug("drag a block on a list block"),!_(n,t))return!1;u(Nt,ut(e),"target is not a list block");const{type:r,start:i,level:s,groupId:l}=Do(e),c=o==="after"?i+1:i,a=n.getBlockData(t),d={id:P(),type:"list",groupId:l,level:s,start:c,text:a.text,...r1(r)};mI(n,e,d);let f=K(e);const m=z(e);o==="after"&&(f+=1);let p=null;ut(t)&&(p=new Yc(n,t));const A=n.insertBlock(V(m),f,d,nc(d.id,0));return n.deleteBlock(t),new fr(n,A).fix(),p==null||p.fix(),!0}function gI(n,t,e,o){if(Nt.debug("drag a list between text blocks"),o==="after"){const a=dt(e);if(a&&ut(a))return s1(n,t,a,"before")}if(o==="before"){const a=bt(e);if(a&&ut(a))return s1(n,t,a,"after")}const i={...n.getBlockData(t),groupId:P(),start:1,level:1};let s=K(e);const l=z(e);o==="after"&&(s+=1),n.insertBlock(V(l),s,i,nc(i.id,0));const c=new Yc(n,t);return n.deleteBlock(t),c.fix(),!0}function pI(n,t,e,o,r){if(Pl(e))return!1;const{blockId:i}=e,s=n.getBlockById(i);u(Nt,s,"no dragged block");const{isSourceBlock:l,targetBlock:c}=r;return!l&&c?(u(Nt,t===c,"block !== target block"),u(Nt,ut(c),"target is not a list block"),s1(n,s,c,o)):gI(n,s,c,o)}const CI=`<?xml version="1.0" ?>
|
|
342
342
|
<svg t="1666868766077" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3547" width="16" height="16">
|
|
343
343
|
<path d="M864 128H160c-17.6 0-32 14.4-32 32v704c0 17.6 14.4 32 32 32h704c17.6 0 32-14.4 32-32V160c0-17.6-14.4-32-32-32zM428 718.4l-45.6 45.6-45.6-45.6-116-117.6 45.6-45.6L383.2 672l367.2-367.2 45.6 45.6-368 368z" p-id="3548" fill="#1296db"></path>
|
|
@@ -359,24 +359,24 @@ xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
|
|
359
359
|
<path d="M9.99978 5.99611L14.5 1.49609" stroke="currentColor" stroke-width="2"/>
|
|
360
360
|
<path d="M1 10.0039H5.99738L5.99608 15" stroke="currentColor" stroke-width="2"/>
|
|
361
361
|
<path d="M14.9971 5.99611H9.99969L10.001 1" stroke="currentColor" stroke-width="2"/>
|
|
362
|
-
</svg>`;async function TI(n,t,e){const o=Rt(t),r=o.querySelector('[data-button-id="mindmap-fullscreen"]');u(Nt,r,"no full screen button");const i=()=>{setTimeout(()=>{e.toMindmap(n,t,{},{reset:!0,mindmapTools:e})},300)},s=()=>{H(o,"fullscreen"),r.innerHTML=vC,u5(r,"Full screen",n.clientId),kC(t)&&setTimeout(()=>{i()},300)};if(document.fullscreenElement===o){try{await yC()}catch(l){Nt.error(l)}s()}else{try{M(o,"fullscreen"),await EI(o),i()}catch(l){Nt.error(l)}r.innerHTML=xI,u5(r,x.t("mindmap.exitFullscreen"),n.clientId)}o.onfullscreenchange=()=>{document.fullscreenElement||s()}}function c1(n,t,e,o,r){if(t.querySelector(`[data-button-id="${e}"]`))return null;const s=Bo(e,o,r,[],n.clientId);return M(s,"mindmap-button"),t.appendChild(s),s}function a1(n,t){return n.querySelector(`[data-button-id="${t}"]`)}function SI(n){return a1(n,"mindmap-fullscreen")}function DI(n){return a1(n,"mindmap-fit")}function LI(n){return a1(n,"mindmap-close")}function MI(n,t,e,o){const r=c1(n,t,"mindmap-close",x.t("mindmap.close"),wI);!r||n.domEvents.addEventListener(r,"click",()=>{o.closeMindmap(n,e)})}function RI(n,t,e,o){const r=c1(n,t,"mindmap-fit",x.t("mindmap.autoFit"),BI);!r||n.domEvents.addEventListener(r,"click",()=>{o.fitMindmap(n,e)})}function OI(n,t,e,o){if(navigator.userAgent.includes("Mobile")&&!navigator.userAgent.includes("iPad"))return;const i=c1(n,t,"mindmap-fullscreen",x.t("mindmap.fullScreen"),vC);!i||n.domEvents.addEventListener(i,"click",()=>{TI(n,e,o)})}function NI(n,t){const e=Hl(t);if(!e)return;const o=DI(e);o&&(o.remove(),n.domEvents.removeAllListeners(o));const r=LI(e);r&&(r.remove(),n.domEvents.removeAllListeners(r));const i=SI(e);i&&(i.remove(),n.domEvents.removeAllListeners(i))}const oi=new Map;function u1(n,t,e){const o=(s,l)=>{s.forEach(c=>{l?M(c.block,"to-mindmap-highlight"):H(c.block,"to-mindmap-highlight"),o(c.children,l)})},r=bC(n,t);if(r.length===0)return;const i=r[0].block;if(e){const s=oi.get(i);s&&(s.forEach(l=>l.cancel()),oi.delete(i)),o(r,!0)}else{const s=setTimeout(()=>{o(r,!1),oi.delete(i)},300),l=()=>{clearTimeout(s),oi.delete(i)},c=oi.get(i);c?c.push({cancel:l}):oi.set(i,[{cancel:l}])}}const{Markmap:PI}=s8;function $I(n,t){zt(t);const e=bC(n,t),o=e[0].block,r=a=>({t:"text",v:st(a.block).textContent,d:1,c:a.children.length>0?a.children.map(f=>r(f)):void 0});let i=null;e.length>1?i={t:"root",v:"root",d:0,c:e.length>0?e.map(a=>r(a)):void 0}:i=r(e[0]);const l=a=>{if(a.length===0)return null;const d=a[a.length-1];return d.children&&d.children.length>0?l(d.children):d},c=l(e);return{root:i,block:o,nodes:e,last:c}}function d1(n,t,e,o){const{root:r,block:i,last:s}=$I(n,t);o.selectBlock&&n.selection.selectBlock(i,0,0),u1(n,i,!1),o.saveData&&n.updateBlockData(i,{viewAsMindmap:!0});const l=Rt(i);let c=l.querySelector(".editor-mindmap-svg");if(o.reset&&(c&&c.remove(),c=null),c)c.innerHTML="";else{const T="http://www.w3.org/2000/svg",E=l.getBoundingClientRect(),L=document.fullscreenElement===l,R=L?`${E.width}`:`${t.getBoundingClientRect().width}`,$=L?`${E.height}`:"600",q=document.createElementNS(T,"svg");q.setAttributeNS(null,"viewBox",`0 0 ${R} ${$}`),q.setAttributeNS(null,"width","100%"),q.setAttributeNS(null,"height",$),q.style.display="block",q.style.width="100%",q.style.height=`${$}px`,q.classList.add("editor-mindmap-svg"),l.appendChild(q),c=q}const a=i,f=`editor-mindmap-root-${j(i)}`;M(a,"editor-in-mindmap-first",f,"readonly"),a.contentEditable="false";const m=dt(i);m&&K(m)<=K(s.block)&&II(m,s.block,["block-hidden",f]);const p=(T,E)=>{if(E.length>0){const L=E[0].parentElement;L&&(L.style.width="100vw",L.style.maxWidth="200px")}E.forEach(L=>{M(L,"editor-mindmap-node")})},A=new PI(c,{...e,autoFit:!0});A.viewHooks.transformHtml.tap(p),A.setData(r),A.fit();const k=Rt(i);let v=k.querySelector(".mindmap-toolbar");v||(v=b("div",["mindmap-toolbar"],k)),RI(n,v,a,o.mindmapTools),OI(n,v,a,o.mindmapTools),MI(n,v,a,o.mindmapTools),n.domEvents.addEventListener(c,"click",()=>{n.selection.selectBlock(i,0),n.input.focus()}),a.mindMap=A}function _I(n){const t=n.classList,e="editor-mindmap-root-";return Array.from(t).find(r=>{if(r.startsWith(e))return r})}async function wC(n,t){const e=_I(t);if(!e)return;n.updateBlockData(t,{viewAsMindmap:null});const o=z(t);Mt(o).forEach(l=>{rt(l,e)&&H(l,e,"editor-in-mindmap-first","block-hidden")});const i=Rt(t);document.fullscreenElement===i&&await yC();const s=i.querySelector(".editor-mindmap-svg");u(Nt,s,"no mindmap svg"),s.remove(),n.domEvents.removeAllListeners(s),t.contentEditable="inherit",NI(n,t),n.selection.selectBlock(t,0)}function FI(n,t){const e=t.mindMap;e&&e.fit()}const BC={toMindmap:d1,closeMindmap:wC,fitMindmap:FI};function EC(n){let t=dt(n);if(!t)return null;const e=hr(n);for(;t!==e;){if(u(Nt,t,"no next block"),ut(t))return Ae(t)>Ae(n)?t:null;if(t=dt(t),!t)return null}return null}function h1(n){const t=[];let e=EC(n);if(!e)return t;for(;e;){const o=hr(e);t.push({block:e,children:h1(e)}),e=o}return t}function HI(n){const t=(o,r)=>{r.push(o.block),o.children.forEach(i=>t(i,r))},e=[];return n.forEach(o=>t(o,e)),e}function IC(n,t){return Ae(t)!==1}function xC(n,t,e){t.forEach(o=>{const r=n.getBlockData(o.block);n.updateBlockData(o.block,{...r,groupId:e,level:r.level-1}),o.children.length&&xC(n,o.children,r.groupId)})}function f1(n,t){if(!IC(n,t))return!1;const e=Ae(t);if(e===1)return!1;let o=P(),r=1,i=ze(t);const s=e-1,l=l1(t);l&&(o=ei(l),r=Ue(l)+1,i!=="text-only"&&(i=ze(l)));const c=h1(t),a=n.getBlockData(t),d={...a,groupId:o,level:s,start:r,...r1(i)};n.updateBlockData(t,d),n.doc.beginBatchUpdate(),xC(n,c,a.groupId),n.doc.endBatchUpdate(),new fr(n,t).fix();const m=EC(t);return m&&new fr(n,m,{resetStart:!0,resetGroupId:!0}).fix(),!0}function ri(n,t){zt(t);const e=n.getBlockData(t),o={id:P(),type:"text",text:e.text};e.heading&&(o.heading=e.heading),e.heading&&(o.heading=e.heading);const r=new Yc(n,t),i=z(t),s=K(t);n.deleteBlock(t);const l=nc(o.id,0);n.insertBlock(V(i),s,o,l),r.fix()}function jI(n){if(!n.selection.range.isCollapsed())return!1;const t=n.selection.focusedBlock;if(!ut(t))return!1;const e=n.selection.range.focus;return!e.isSimple()||e.offset!==0?!1:Ae(t)===1?(ri(n,t),!0):(f1(n,t),!0)}const zI=w("list-block");function UI(n,t,e){u(zI,ut(t),"not a list block");const o={...n.getBlockData(t),id:P()};return e!=null&&e.level&&(o.level=e.level),e!=null&&e.start&&(o.start=e.start),e!=null&&e.keepText||delete o.text,o}function VI(n){if(zt(n),!Zc(n))return n;let t=Lo(n);for(;t;){if(!Zc(t))return t;t=Lo(t)}return null}function qI(n,t,e,o){const r=new fr(n,o),i=Ue(o)+1;Hr(n,t,e,{forceInsertAfter:!0,newBlockData:UI(n,o,{start:i})}),r.fix()}function WI(n){var s;if(n.selection.range.isCollapsed()){const l=n.selection.focusedBlock;if(ut(l)&&G(n,l)===0)return ri(n,l),!0}n.clearSelectedContents();const t=n.selection.focusedBlock;if(!ut(t))return!1;const e=n.selection.range.focus;if(!e.isSimple())return!1;const o=e.offset,i=(s=o===G(n,t)?VI(t):t)!=null?s:t;return qI(n,t,o,i),!0}function TC(n){u(Nt,ut(n),"not a list block");const{level:t}=Do(n);let e=bt(n);for(;e;){if(ut(e)){const{level:o}=Do(e);if(t===o)return e;if(o<t)return null}e=bt(e)}return null}function SC(n,t){return zt(t),TC(t)?Ae(t)<fI:!1}function GI(n,t,e){let o=bt(t);u(Nt,o,"no prev brother");const r=Ae(e);for(;o;){if(o===e)return null;if(ut(o)&&Ae(o)===r+1)return o;o=bt(o)}return null}function DC(n,t){if(!SC(n,t))return!1;zt(t);const e=TC(t);u(Nt,e,"no list prev brother");const o=e,r=GI(n,t,o),i=Ae(o)+1;let s=P(),l=1,c=ze(t);r&&(s=ei(r),l=Ue(r)+1,c=ze(r));const a=h1(t),f={...n.getBlockData(t),groupId:s,level:i,start:l,...r1(c)};return n.updateBlockData(t,f),n.doc.beginBatchUpdate(),HI(a).forEach(p=>{const A=n.getBlockData(p);n.updateBlockData(p,{...A,level:A.level+1})}),n.doc.endBatchUpdate(),!0}function ZI(n,t,e){return t.length===0||!t.every(o=>ut(o.block))?!1:e==="increase"?SC(n,t[0].block):IC(n,t[0].block)}function LC(n,t,e){if(!ZI(n,t,e))return!1;const o=t[0].block,r=Ae(o),i=t.filter(a=>Ae(a.block)<=r),s=mC(o,{withSelf:!1}),l=new Set(i.map(a=>a.block)),c=s.filter(a=>!l.has(a));return n.undoManager.runInGroup(()=>{let a=null;c.length>0&&(a=new fr(n,c[0])),i.forEach(d=>{e==="increase"?DC(n,d.block):f1(n,d.block)}),a==null||a.fix()}),!0}function QI(n,t){return DC(n,t)}function YI(n,t){return f1(n,t)}function JI(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return LC(n,t,"increase"),!0;const e=t[0].block;if(!ut(e))return!1;const o=new Yc(n,e);return QI(n,e)&&(o.fix(),new fr(n,e).fix()),!0}function KI(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return LC(n,t,"decrease"),!0;const e=t[0].block;return ut(e)?(YI(n,e),!0):!1}class XI{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const o=t.selection.range.getSelectedBlocks();if(o.length===0||!o.some(i=>ut(i.block)))return!1;switch(e.key){case"Enter":return this.handleEnter(e);case"Backspace":return this.handleBackspace();case"Tab":return this.handleTab(e);default:return!1}}handleEnter(t){const e=this.editor.selection.range.getSelectedBlocks()[0];return!e.block||!ut(e.block)||jn(t,"Shift+Enter")?!1:this.editor.undoManager.runInGroup(()=>WI(this.editor))}handleBackspace(){return this.editor.undoManager.runInGroup(()=>jI(this.editor))}handleTab(t){return jn(t,"Shift+Tab")?this.editor.undoManager.runInGroup(()=>KI(this.editor)):this.editor.undoManager.runInGroup(()=>JI(this.editor))}}class tx{constructor(t){h(this,"effectedBlockIds",new Map);h(this,"handleBeforeClearSelection",()=>{this.effectedBlockIds.clear();const t=this.editor.selection.range.getSelectedBlocks();if(t.length===0)return;const e=new Set;t.forEach(r=>{const i=r.block;ut(i)&&e.add(i)});const o=new Map;Array.from(e.values()).forEach(r=>{var c;const i=Us(r),{start:s}=Do(i);o.set(j(i),s);const l=(c=nI(r))!=null?c:r;o.set(j(l),s)}),this.effectedBlockIds=o});h(this,"handleAfterClearSelection",()=>{Array.from(this.effectedBlockIds.entries()).forEach(([t,e])=>{const o=this.editor.findBlockById(t);!o||i1(this.editor,o,e)}),this.effectedBlockIds.clear()});this.editor=t,this.editor.addListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.addListener("afterClearSelection",this.handleAfterClearSelection)}destroy(){this.editor.removeListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.removeListener("afterClearSelection",this.handleAfterClearSelection)}}const ex=w("customize-list-start-menu");class nx{constructor(t){h(this,"popup");h(this,"block",null);h(this,"show",(t,e)=>{const o=e.querySelector("div.list-container");u(ex,o,"list-block mark does not exist"),this.block=e,this.popup.manualShow(o,{theme:"light"})});h(this,"createDialogContent",()=>{const t=b("div",["customize-start-panel"],null);b("span",["customize-start-panel-title"],t,x.t("list.numberLabel"));const e=b("input",["customize-start-panel-input"],t);e.type="number",e.setAttribute("min","1");const o=b("button",["customize-start-panel-button"],t,x.t("list.confirm"));return this.editor.domEvents.addEventListener(t,"keydown",this.handleKeydown),this.editor.domEvents.addEventListener(o,"click",this.handleOk),t});h(this,"handleDialogShow",()=>{const t=this.block;if(!t)return;const e=this.popup.popupContent,o=e.querySelector("button.customize-start-panel-button"),r=e.querySelector("input.customize-start-panel-input"),i=Ue(t);!o||!r||requestAnimationFrame(()=>{r.focus(),r.value=String(i)})});h(this,"handleOk",()=>{const e=this.popup.popupContent.querySelector("input.customize-start-panel-input"),o=this.block;if(!o)return;const r=Number(e.value);!r||(this.editor.undoManager.runInGroup(()=>{Vs(this.editor,[o,...zs(o)],r,{resetGroupId:!0})}),this.popup.close())});h(this,"handleKeydown",(t,e)=>{const o=e;o.isComposing||o.key==="Escape"&&this.popup.close()});this.editor=t,this.popup=new Is(this.createDialogContent()),this.popup.on("show",this.handleDialogShow)}destroy(){this.popup.destroy()}}function ox(n,t){return ei(n)===ei(t)}function rx(n,t){const e=hC(t);return e?ox(e,t)?Ue(e)!==Ue(t)-1:!0:!1}function ix(n,t){return Lo(t)?!0:Ue(t)!==1}function sx(n,t){return zt(t),[{id:"continue-numbering",name:x.t("list.continueList"),states:rx(n,t)?[]:["disabled"]},{id:"start-new-list",name:x.t("list.restartList"),states:ix(n,t)?[]:["disabled"]},{id:"set-numbering-value",name:x.t("list.changeNumber")}]}function lx(n,t,e){var o,r;if(zt(t),e.id==="continue-numbering"){const i=hC(t);i&&Vs(n,[t,...zs(t)],Ue(i)+1,{resetGroupId:!0,groupId:ei(i)})}if(e.id==="start-new-list"&&n.undoManager.runInGroup(()=>{Vs(n,[t,...zs(t)],1,{resetGroupId:!0})}),e.id==="set-numbering-value"){const i=(o=n.options.componentsOptions)==null?void 0:o.list;if((r=i==null?void 0:i.onChangeStart)!=null&&r.call(i,n,t,e))return;n.addCustom("list-customize-start-dialog",()=>new nx(n)).show(n,t)}}class cx{constructor(t){h(this,"menu");h(this,"handleClick",(t,e)=>{const o=xr(e,"div.list-container");if(o&&this.editor.isWritable()){const r=U(o);u(Nt,r,"no parent block"),zt(r);const i=t.getBlockData(r);if(i&&i.checkbox){t.updateBlockData(r,{...i,checkbox:i.checkbox==="checked"?"unchecked":"checked"});return}this.menu.updateItems(this.getCommandItems(r)),this.menu.manualShow(o),this.activeList(o,!0)}});h(this,"handleMenuClose",()=>{var e;const t=(e=this.menu.tippyInstance)==null?void 0:e.reference;t&&this.activeList(t,!1)});h(this,"handleMenuClick",(t,e)=>{var r;const o=(r=this.menu.tippyInstance)==null?void 0:r.reference;if(o){const i=U(o);i&&lx(this.editor,i,e)}});this.editor=t,this.editor.addListener("click",this.handleClick),this.menu=new cr([]),this.menu.addListener("close",this.handleMenuClose),this.menu.addListener("click",this.handleMenuClick)}destroy(){this.editor.removeListener("click",this.handleClick),this.menu.removeListener("close",this.handleMenuClose)}getCommandItems(t){return sx(this.editor,t)}activeList(t,e){const o=U(t);!o||(e?(M(t,"active"),M(o,"active")):(H(t,"active"),H(o,"active")))}}class ax{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const o=t.selection.range.getSelectedBlocks();if(o.length===0)return!1;const r=o[0].block;if(!ut(r)||!kC(r))return!1;if(e.key==="ArrowUp"||e.key==="ArrowLeft"){const i=Dr(r);return i&&t.selection.selectBlock(i,G(t,i)),!0}if(e.key==="ArrowDown"||e.key==="ArrowRight"){const i=Lr(r);return i&&t.selection.selectBlock(i,0),!0}return(e.key==="Delete"||e.key==="Backspace"||e.key==="Escape")&&wC(t,r),!0}}function ux(n,t,e,o,r){Jd(n,"list-block-init",()=>{setTimeout(()=>{n.input.addHandler(new ax(n)),n.input.addHandler(new XI(n)),n.addCustom("list-clear-selection-handler",()=>new tx(n)),n.addCustom("list-marker-menu",()=>new cx(n))})});const i=ye.createBlockContent(n,t,e,o,r),s=r,{level:l,start:c,groupId:a}=s,d=ni(s);o.setAttribute("data-list-level",`${l}`),o.setAttribute("data-list-start",`${c||1}`),o.setAttribute("data-list-group-id",`${a}`),o.setAttribute("data-list-type",d);const f=vI(s);return o.insertBefore(f,i),s.viewAsMindmap&&setTimeout(()=>{const m=n.getBlockById(r.id);m&&d1(n,m,{},{mindmapTools:BC,saveData:!1})}),i}const dx=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
362
|
+
</svg>`;async function TI(n,t,e){const o=Rt(t),r=o.querySelector('[data-button-id="mindmap-fullscreen"]');u(Nt,r,"no full screen button");const i=()=>{setTimeout(()=>{e.toMindmap(n,t,{},{reset:!0,mindmapTools:e})},300)},s=()=>{H(o,"fullscreen"),r.innerHTML=vC,u5(r,"Full screen",n.clientId),kC(t)&&setTimeout(()=>{i()},300)};if(document.fullscreenElement===o){try{await yC()}catch(l){Nt.error(l)}s()}else{try{M(o,"fullscreen"),await EI(o),i()}catch(l){Nt.error(l)}r.innerHTML=xI,u5(r,T.t("mindmap.exitFullscreen"),n.clientId)}o.onfullscreenchange=()=>{document.fullscreenElement||s()}}function c1(n,t,e,o,r){if(t.querySelector(`[data-button-id="${e}"]`))return null;const s=Bo(e,o,r,[],n.clientId);return M(s,"mindmap-button"),t.appendChild(s),s}function a1(n,t){return n.querySelector(`[data-button-id="${t}"]`)}function SI(n){return a1(n,"mindmap-fullscreen")}function DI(n){return a1(n,"mindmap-fit")}function LI(n){return a1(n,"mindmap-close")}function MI(n,t,e,o){const r=c1(n,t,"mindmap-close",T.t("mindmap.close"),wI);!r||n.domEvents.addEventListener(r,"click",()=>{o.closeMindmap(n,e)})}function RI(n,t,e,o){const r=c1(n,t,"mindmap-fit",T.t("mindmap.autoFit"),BI);!r||n.domEvents.addEventListener(r,"click",()=>{o.fitMindmap(n,e)})}function OI(n,t,e,o){if(navigator.userAgent.includes("Mobile")&&!navigator.userAgent.includes("iPad"))return;const i=c1(n,t,"mindmap-fullscreen",T.t("mindmap.fullScreen"),vC);!i||n.domEvents.addEventListener(i,"click",()=>{TI(n,e,o)})}function NI(n,t){const e=Hl(t);if(!e)return;const o=DI(e);o&&(o.remove(),n.domEvents.removeAllListeners(o));const r=LI(e);r&&(r.remove(),n.domEvents.removeAllListeners(r));const i=SI(e);i&&(i.remove(),n.domEvents.removeAllListeners(i))}const oi=new Map;function u1(n,t,e){const o=(s,l)=>{s.forEach(c=>{l?M(c.block,"to-mindmap-highlight"):H(c.block,"to-mindmap-highlight"),o(c.children,l)})},r=bC(n,t);if(r.length===0)return;const i=r[0].block;if(e){const s=oi.get(i);s&&(s.forEach(l=>l.cancel()),oi.delete(i)),o(r,!0)}else{const s=setTimeout(()=>{o(r,!1),oi.delete(i)},300),l=()=>{clearTimeout(s),oi.delete(i)},c=oi.get(i);c?c.push({cancel:l}):oi.set(i,[{cancel:l}])}}const{Markmap:PI}=s8;function $I(n,t){zt(t);const e=bC(n,t),o=e[0].block,r=a=>({t:"text",v:st(a.block).textContent,d:1,c:a.children.length>0?a.children.map(f=>r(f)):void 0});let i=null;e.length>1?i={t:"root",v:"root",d:0,c:e.length>0?e.map(a=>r(a)):void 0}:i=r(e[0]);const l=a=>{if(a.length===0)return null;const d=a[a.length-1];return d.children&&d.children.length>0?l(d.children):d},c=l(e);return{root:i,block:o,nodes:e,last:c}}function d1(n,t,e,o){const{root:r,block:i,last:s}=$I(n,t);o.selectBlock&&n.selection.selectBlock(i,0,0),u1(n,i,!1),o.saveData&&n.updateBlockData(i,{viewAsMindmap:!0});const l=Rt(i);let c=l.querySelector(".editor-mindmap-svg");if(o.reset&&(c&&c.remove(),c=null),c)c.innerHTML="";else{const x="http://www.w3.org/2000/svg",E=l.getBoundingClientRect(),L=document.fullscreenElement===l,R=L?`${E.width}`:`${t.getBoundingClientRect().width}`,$=L?`${E.height}`:"600",q=document.createElementNS(x,"svg");q.setAttributeNS(null,"viewBox",`0 0 ${R} ${$}`),q.setAttributeNS(null,"width","100%"),q.setAttributeNS(null,"height",$),q.style.display="block",q.style.width="100%",q.style.height=`${$}px`,q.classList.add("editor-mindmap-svg"),l.appendChild(q),c=q}const a=i,f=`editor-mindmap-root-${j(i)}`;M(a,"editor-in-mindmap-first",f,"readonly"),a.contentEditable="false";const m=dt(i);m&&K(m)<=K(s.block)&&II(m,s.block,["block-hidden",f]);const p=(x,E)=>{if(E.length>0){const L=E[0].parentElement;L&&(L.style.width="100vw",L.style.maxWidth="200px")}E.forEach(L=>{M(L,"editor-mindmap-node")})},A=new PI(c,{...e,autoFit:!0});A.viewHooks.transformHtml.tap(p),A.setData(r),A.fit();const k=Rt(i);let v=k.querySelector(".mindmap-toolbar");v||(v=b("div",["mindmap-toolbar"],k)),RI(n,v,a,o.mindmapTools),OI(n,v,a,o.mindmapTools),MI(n,v,a,o.mindmapTools),n.domEvents.addEventListener(c,"click",()=>{n.selection.selectBlock(i,0),n.input.focus()}),a.mindMap=A}function _I(n){const t=n.classList,e="editor-mindmap-root-";return Array.from(t).find(r=>{if(r.startsWith(e))return r})}async function wC(n,t){const e=_I(t);if(!e)return;n.updateBlockData(t,{viewAsMindmap:null});const o=z(t);Mt(o).forEach(l=>{rt(l,e)&&H(l,e,"editor-in-mindmap-first","block-hidden")});const i=Rt(t);document.fullscreenElement===i&&await yC();const s=i.querySelector(".editor-mindmap-svg");u(Nt,s,"no mindmap svg"),s.remove(),n.domEvents.removeAllListeners(s),t.contentEditable="inherit",NI(n,t),n.selection.selectBlock(t,0)}function FI(n,t){const e=t.mindMap;e&&e.fit()}const BC={toMindmap:d1,closeMindmap:wC,fitMindmap:FI};function EC(n){let t=dt(n);if(!t)return null;const e=hr(n);for(;t!==e;){if(u(Nt,t,"no next block"),ut(t))return Ae(t)>Ae(n)?t:null;if(t=dt(t),!t)return null}return null}function h1(n){const t=[];let e=EC(n);if(!e)return t;for(;e;){const o=hr(e);t.push({block:e,children:h1(e)}),e=o}return t}function HI(n){const t=(o,r)=>{r.push(o.block),o.children.forEach(i=>t(i,r))},e=[];return n.forEach(o=>t(o,e)),e}function IC(n,t){return Ae(t)!==1}function xC(n,t,e){t.forEach(o=>{const r=n.getBlockData(o.block);n.updateBlockData(o.block,{...r,groupId:e,level:r.level-1}),o.children.length&&xC(n,o.children,r.groupId)})}function f1(n,t){if(!IC(n,t))return!1;const e=Ae(t);if(e===1)return!1;let o=P(),r=1,i=ze(t);const s=e-1,l=l1(t);l&&(o=ei(l),r=Ue(l)+1,i!=="text-only"&&(i=ze(l)));const c=h1(t),a=n.getBlockData(t),d={...a,groupId:o,level:s,start:r,...r1(i)};n.updateBlockData(t,d),n.doc.beginBatchUpdate(),xC(n,c,a.groupId),n.doc.endBatchUpdate(),new fr(n,t).fix();const m=EC(t);return m&&new fr(n,m,{resetStart:!0,resetGroupId:!0}).fix(),!0}function ri(n,t){zt(t);const e=n.getBlockData(t),o={id:P(),type:"text",text:e.text};e.heading&&(o.heading=e.heading),e.heading&&(o.heading=e.heading);const r=new Yc(n,t),i=z(t),s=K(t);n.deleteBlock(t);const l=nc(o.id,0);n.insertBlock(V(i),s,o,l),r.fix()}function jI(n){if(!n.selection.range.isCollapsed())return!1;const t=n.selection.focusedBlock;if(!ut(t))return!1;const e=n.selection.range.focus;return!e.isSimple()||e.offset!==0?!1:Ae(t)===1?(ri(n,t),!0):(f1(n,t),!0)}const zI=w("list-block");function UI(n,t,e){u(zI,ut(t),"not a list block");const o={...n.getBlockData(t),id:P()};return e!=null&&e.level&&(o.level=e.level),e!=null&&e.start&&(o.start=e.start),e!=null&&e.keepText||delete o.text,o}function VI(n){if(zt(n),!Zc(n))return n;let t=Lo(n);for(;t;){if(!Zc(t))return t;t=Lo(t)}return null}function qI(n,t,e,o){const r=new fr(n,o),i=Ue(o)+1;Hr(n,t,e,{forceInsertAfter:!0,newBlockData:UI(n,o,{start:i})}),r.fix()}function WI(n){var s;if(n.selection.range.isCollapsed()){const l=n.selection.focusedBlock;if(ut(l)&&G(n,l)===0)return ri(n,l),!0}n.clearSelectedContents();const t=n.selection.focusedBlock;if(!ut(t))return!1;const e=n.selection.range.focus;if(!e.isSimple())return!1;const o=e.offset,i=(s=o===G(n,t)?VI(t):t)!=null?s:t;return qI(n,t,o,i),!0}function TC(n){u(Nt,ut(n),"not a list block");const{level:t}=Do(n);let e=bt(n);for(;e;){if(ut(e)){const{level:o}=Do(e);if(t===o)return e;if(o<t)return null}e=bt(e)}return null}function SC(n,t){return zt(t),TC(t)?Ae(t)<fI:!1}function GI(n,t,e){let o=bt(t);u(Nt,o,"no prev brother");const r=Ae(e);for(;o;){if(o===e)return null;if(ut(o)&&Ae(o)===r+1)return o;o=bt(o)}return null}function DC(n,t){if(!SC(n,t))return!1;zt(t);const e=TC(t);u(Nt,e,"no list prev brother");const o=e,r=GI(n,t,o),i=Ae(o)+1;let s=P(),l=1,c=ze(t);r&&(s=ei(r),l=Ue(r)+1,c=ze(r));const a=h1(t),f={...n.getBlockData(t),groupId:s,level:i,start:l,...r1(c)};return n.updateBlockData(t,f),n.doc.beginBatchUpdate(),HI(a).forEach(p=>{const A=n.getBlockData(p);n.updateBlockData(p,{...A,level:A.level+1})}),n.doc.endBatchUpdate(),!0}function ZI(n,t,e){return t.length===0||!t.every(o=>ut(o.block))?!1:e==="increase"?SC(n,t[0].block):IC(n,t[0].block)}function LC(n,t,e){if(!ZI(n,t,e))return!1;const o=t[0].block,r=Ae(o),i=t.filter(a=>Ae(a.block)<=r),s=mC(o,{withSelf:!1}),l=new Set(i.map(a=>a.block)),c=s.filter(a=>!l.has(a));return n.undoManager.runInGroup(()=>{let a=null;c.length>0&&(a=new fr(n,c[0])),i.forEach(d=>{e==="increase"?DC(n,d.block):f1(n,d.block)}),a==null||a.fix()}),!0}function QI(n,t){return DC(n,t)}function YI(n,t){return f1(n,t)}function JI(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return LC(n,t,"increase"),!0;const e=t[0].block;if(!ut(e))return!1;const o=new Yc(n,e);return QI(n,e)&&(o.fix(),new fr(n,e).fix()),!0}function KI(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return LC(n,t,"decrease"),!0;const e=t[0].block;return ut(e)?(YI(n,e),!0):!1}class XI{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const o=t.selection.range.getSelectedBlocks();if(o.length===0||!o.some(i=>ut(i.block)))return!1;switch(e.key){case"Enter":return this.handleEnter(e);case"Backspace":return this.handleBackspace();case"Tab":return this.handleTab(e);default:return!1}}handleEnter(t){const e=this.editor.selection.range.getSelectedBlocks()[0];return!e.block||!ut(e.block)||jn(t,"Shift+Enter")?!1:this.editor.undoManager.runInGroup(()=>WI(this.editor))}handleBackspace(){return this.editor.undoManager.runInGroup(()=>jI(this.editor))}handleTab(t){return jn(t,"Shift+Tab")?this.editor.undoManager.runInGroup(()=>KI(this.editor)):this.editor.undoManager.runInGroup(()=>JI(this.editor))}}class tx{constructor(t){h(this,"effectedBlockIds",new Map);h(this,"handleBeforeClearSelection",()=>{this.effectedBlockIds.clear();const t=this.editor.selection.range.getSelectedBlocks();if(t.length===0)return;const e=new Set;t.forEach(r=>{const i=r.block;ut(i)&&e.add(i)});const o=new Map;Array.from(e.values()).forEach(r=>{var c;const i=Us(r),{start:s}=Do(i);o.set(j(i),s);const l=(c=nI(r))!=null?c:r;o.set(j(l),s)}),this.effectedBlockIds=o});h(this,"handleAfterClearSelection",()=>{Array.from(this.effectedBlockIds.entries()).forEach(([t,e])=>{const o=this.editor.findBlockById(t);!o||i1(this.editor,o,e)}),this.effectedBlockIds.clear()});this.editor=t,this.editor.addListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.addListener("afterClearSelection",this.handleAfterClearSelection)}destroy(){this.editor.removeListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.removeListener("afterClearSelection",this.handleAfterClearSelection)}}const ex=w("customize-list-start-menu");class nx{constructor(t){h(this,"popup");h(this,"block",null);h(this,"show",(t,e)=>{const o=e.querySelector("div.list-container");u(ex,o,"list-block mark does not exist"),this.block=e,this.popup.manualShow(o,{theme:"light"})});h(this,"createDialogContent",()=>{const t=b("div",["customize-start-panel"],null);b("span",["customize-start-panel-title"],t,T.t("list.numberLabel"));const e=b("input",["customize-start-panel-input"],t);e.type="number",e.setAttribute("min","1");const o=b("button",["customize-start-panel-button"],t,T.t("list.confirm"));return this.editor.domEvents.addEventListener(t,"keydown",this.handleKeydown),this.editor.domEvents.addEventListener(o,"click",this.handleOk),t});h(this,"handleDialogShow",()=>{const t=this.block;if(!t)return;const e=this.popup.popupContent,o=e.querySelector("button.customize-start-panel-button"),r=e.querySelector("input.customize-start-panel-input"),i=Ue(t);!o||!r||requestAnimationFrame(()=>{r.focus(),r.value=String(i)})});h(this,"handleOk",()=>{const e=this.popup.popupContent.querySelector("input.customize-start-panel-input"),o=this.block;if(!o)return;const r=Number(e.value);!r||(this.editor.undoManager.runInGroup(()=>{Vs(this.editor,[o,...zs(o)],r,{resetGroupId:!0})}),this.popup.close())});h(this,"handleKeydown",(t,e)=>{const o=e;o.isComposing||o.key==="Escape"&&this.popup.close()});this.editor=t,this.popup=new Is(this.createDialogContent()),this.popup.on("show",this.handleDialogShow)}destroy(){this.popup.destroy()}}function ox(n,t){return ei(n)===ei(t)}function rx(n,t){const e=hC(t);return e?ox(e,t)?Ue(e)!==Ue(t)-1:!0:!1}function ix(n,t){return Lo(t)?!0:Ue(t)!==1}function sx(n,t){return zt(t),[{id:"continue-numbering",name:T.t("list.continueList"),states:rx(n,t)?[]:["disabled"]},{id:"start-new-list",name:T.t("list.restartList"),states:ix(n,t)?[]:["disabled"]},{id:"set-numbering-value",name:T.t("list.changeNumber")}]}function lx(n,t,e){var o,r;if(zt(t),e.id==="continue-numbering"){const i=hC(t);i&&Vs(n,[t,...zs(t)],Ue(i)+1,{resetGroupId:!0,groupId:ei(i)})}if(e.id==="start-new-list"&&n.undoManager.runInGroup(()=>{Vs(n,[t,...zs(t)],1,{resetGroupId:!0})}),e.id==="set-numbering-value"){const i=(o=n.options.componentsOptions)==null?void 0:o.list;if((r=i==null?void 0:i.onChangeStart)!=null&&r.call(i,n,t,e))return;n.addCustom("list-customize-start-dialog",()=>new nx(n)).show(n,t)}}class cx{constructor(t){h(this,"menu");h(this,"handleClick",(t,e)=>{const o=xr(e,"div.list-container");if(o&&this.editor.isWritable()){const r=U(o);u(Nt,r,"no parent block"),zt(r);const i=t.getBlockData(r);if(i&&i.checkbox){t.updateBlockData(r,{...i,checkbox:i.checkbox==="checked"?"unchecked":"checked"});return}this.menu.updateItems(this.getCommandItems(r)),this.menu.manualShow(o),this.activeList(o,!0)}});h(this,"handleMenuClose",()=>{var e;const t=(e=this.menu.tippyInstance)==null?void 0:e.reference;t&&this.activeList(t,!1)});h(this,"handleMenuClick",(t,e)=>{var r;const o=(r=this.menu.tippyInstance)==null?void 0:r.reference;if(o){const i=U(o);i&&lx(this.editor,i,e)}});this.editor=t,this.editor.addListener("click",this.handleClick),this.menu=new cr([]),this.menu.addListener("close",this.handleMenuClose),this.menu.addListener("click",this.handleMenuClick)}destroy(){this.editor.removeListener("click",this.handleClick),this.menu.removeListener("close",this.handleMenuClose)}getCommandItems(t){return sx(this.editor,t)}activeList(t,e){const o=U(t);!o||(e?(M(t,"active"),M(o,"active")):(H(t,"active"),H(o,"active")))}}class ax{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const o=t.selection.range.getSelectedBlocks();if(o.length===0)return!1;const r=o[0].block;if(!ut(r)||!kC(r))return!1;if(e.key==="ArrowUp"||e.key==="ArrowLeft"){const i=Dr(r);return i&&t.selection.selectBlock(i,G(t,i)),!0}if(e.key==="ArrowDown"||e.key==="ArrowRight"){const i=Lr(r);return i&&t.selection.selectBlock(i,0),!0}return(e.key==="Delete"||e.key==="Backspace"||e.key==="Escape")&&wC(t,r),!0}}function ux(n,t,e,o,r){Jd(n,"list-block-init",()=>{setTimeout(()=>{n.input.addHandler(new ax(n)),n.input.addHandler(new XI(n)),n.addCustom("list-clear-selection-handler",()=>new tx(n)),n.addCustom("list-marker-menu",()=>new cx(n))})});const i=ye.createBlockContent(n,t,e,o,r),s=r,{level:l,start:c,groupId:a}=s,d=ni(s);o.setAttribute("data-list-level",`${l}`),o.setAttribute("data-list-start",`${c||1}`),o.setAttribute("data-list-group-id",`${a}`),o.setAttribute("data-list-type",d);const f=vI(s);return o.insertBefore(f,i),s.viewAsMindmap&&setTimeout(()=>{const m=n.getBlockById(r.id);m&&d1(n,m,{},{mindmapTools:BC,saveData:!1})}),i}const dx=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
363
363
|
<path d="M8 8H15" stroke="currentColor" stroke-linecap="square" stroke-linejoin="round"></path>
|
|
364
364
|
<path d="M8 14H15" stroke="currentColor" stroke-linecap="square" stroke-linejoin="round"></path>
|
|
365
365
|
<path d="M8 2H15" stroke="currentColor" stroke-linecap="square" stroke-linejoin="round"></path>
|
|
366
366
|
<path d="M4 8H0C0 8 0.552283 8 1.33333 8M4 14C2 13.1429 3.33333 8 1.33333 8M4 2C2 2.85714 3.33333 8 1.33333 8" stroke="currentColor" stroke-linecap="square"></path>
|
|
367
367
|
</svg>
|
|
368
|
-
`;function hx(n){const t=b("div",["list-to-mindmap-wrap"],null),e=Bo("list-to-mindmap",x.t("mindmap.viewAsMindMap"),dx,[],n.clientId);return t.appendChild(e),t}const uV="";class Jc{constructor(t){h(this,"toMindmapButton");h(this,"currentBlock",null);h(this,"handleHoveringBlock",t=>{!this.editor.isWritable()||(t&&ut(t)&&ze(t)!=="unchecked"&&ze(t)!=="checked"?Rt(t).appendChild(this.toMindmapButton):this.toMindmapButton.remove())});h(this,"handleMouseEnter",()=>{const t=U(this.toMindmapButton);u(Nt,t&&ut(t),"no parent list"),u1(this.editor,t,!0),this.currentBlock=t});h(this,"handleMouseLeave",()=>{this.currentBlock&&(u1(this.editor,this.currentBlock,!1),this.currentBlock=null)});h(this,"handleClick",()=>{const t=U(this.toMindmapButton);u(Nt,t&&ut(t),"no parent list"),d1(this.editor,t,{},{saveData:!0,selectBlock:!0,mindmapTools:BC})});this.editor=t,$t.get(this.editor).addListener("change",this.handleHoveringBlock),this.toMindmapButton=hx(t),t.domEvents.addEventListener(this.toMindmapButton,"mouseenter",this.handleMouseEnter),t.domEvents.addEventListener(this.toMindmapButton,"mouseleave",this.handleMouseLeave),t.domEvents.addEventListener(this.toMindmapButton,"click",this.handleClick)}static get(t){return t.findCustomByType(Jc)}destroy(){$t.get(this.editor).removeListener("change",this.handleHoveringBlock)}hide(){this.currentBlock&&(this.currentBlock=null),this.toMindmapButton.remove()}}const fx={list:{confirm:"\u786E\u5B9A",setStart:"\u8BBE\u7F6E\u7F16\u53F7",continueList:"\u7EE7\u7EED\u7F16\u53F7",restartList:"\u5F00\u59CB\u65B0\u5217\u8868",changeNumber:"\u4FEE\u6539\u7F16\u53F7\u503C",numberLabel:"\u7F16\u53F7\u987A\u5E8F",mention:{tooltip:"\u63D0\u53CA\u4EBA\u5458\u5E76\u901A\u77E5"}},mindmap:{viewAsMindMap:"\u663E\u793A\u4E3A\u8111\u56FE",autoFit:"\u81EA\u52A8\u7F29\u653E",fullScreen:"\u5168\u5C4F\u67E5\u770B",close:"\u5173\u95ED",exitFullscreen:"\u9000\u51FA\u5168\u5C4F"}},mx={list:{confirm:"OK",setStart:"Set the number",continueList:"Continue numbering",restartList:"Start a new list",changeNumber:"Set numbering value",numberLabel:"Numbering order",mention:{tooltip:"@Mention someone"}},mindmap:{viewAsMindMap:"View as MindMap",autoFit:"Auto fit",fullScreen:"Fullscreen",close:"Close",exitFullscreen:"Exit fullscreen"}};x.mergeLang({"zh-CN":fx,"en-US":mx});const dV="";function gx(n,t,e){var o;t==="beginDrag"&&((o=Jc.get(n))==null||o.hide())}const MC={...ye,blockType:"list",createBlockContent:ux,convertFrom:uI,convertTo:hI,handleDrop:pI,notify:gx},m1=w("paragraph");class px{constructor(t){h(this,"id","BlockParagraphProvider");this.editor=t}isChecked(t,e){return!!(t[e]||t.level&&(t.ordered===!0&&!t.checkbox&&e==="ordered-list"||t.ordered===!1&&!t.checkbox&&e==="unordered-list")||e==="check-list"&&t.checkbox)}getAvailableCommands(t,e){const o=[],r={"unordered-list":[x.t("commands.unordered"),xt.isMac?x.t("commandDesc.mac.unordered"):x.t("commandDesc.window.unordered"),Tw],"ordered-list":[x.t("commands.ordered"),xt.isMac?x.t("commandDesc.mac.ordered"):x.t("commandDesc.window.ordered"),xw],"check-list":[x.t("commands.check"),void 0,Sw],link:[x.t("commands.link"),xt.isMac?x.t("commandDesc.mac.link"):x.t("commandDesc.window.link"),k5],quoted:[x.t("commands.quote"),void 0,Dw]};if(_(t,e)){const i=j(e),s=it(e),l=Je(t,e),c=t.getBlockData(e);Object.entries(r).forEach(([a,[d,f,m]])=>{const p=[];if(this.isChecked(c,a)&&p.push("checked"),a==="link"){if(!t.selection.range.isSimple())return;t.selection.range.getSelectedBlocks().length!==1&&p.push("disabled")}o.push({blockId:i,blockType:s,blockKind:l,id:a,name:d,desc:f,states:p,icon:m,groupIndex:600})})}return o}convertLink(t,e,o){u(m1,uo(e.start),""),u(m1,uo(e.start),"");const r="bottom-start",i=e.start.offset,s=e.end.offset,l=(p,A)=>{t.undoManager.runInGroup(()=>{try{let k=Kl(t.getBlockText(o),i,s,p);k=Yi(i,p.length,k,"link",A),t.setBlockText(o,k),t.selection.selectBlock(o,i+p.length),t.focus()}catch(k){m1.error(k)}})},c=()=>{t.selection.selectBlock(o,s),t.focus()},a=co(t,o,e)[0];if(!a)return;const d=fo(t,o,"link-button-anchor",a),f=t.getBlockText(o),m=Ji(f,i);Hs(t,{target:d,linkText:t.getSelectedText(),linkUrl:(m==null?void 0:m.link)||"",onFinished:l,onClose:c,placement:r})}convertToList(t,e,o){const r=jl(t,e,"list",{offset:0,data:{listType:o}});r&&t.undoManager.runInGroup(()=>{const i=K(e),s=z(e);t.insertBlock(V(s),i,r.blockData),t.deleteBlock(e)})}executeCommand(t,e,o,r){var c;if(!_(t,e))return!1;const i=r.id,s=(c=r.states)==null?void 0:c.includes("checked");let l=!1;if(i==="unordered-list"&&(s?ri(t,e):this.convertToList(t,e,"unordered"),l=!0),i==="ordered-list"&&(s?ri(t,e):this.convertToList(t,e,"ordered"),l=!0),i==="check-list"&&(s?ri(t,e):this.convertToList(t,e,"unchecked"),l=!0),i==="quoted"){const d=t.getBlockData(e).quoted;t.updateBlockData(e,{quoted:d?void 0:!0}),l=!0}if(i==="link"){const a=Vc(t);a.disableTextToolbar(),a.hide(),setTimeout(()=>{a.enableTextToolbar()},1e3),this.convertLink(t,o,e),l=!0}return l}}const Cx={left:xs,right:Eh,center:Ih};class Ax{constructor(t){h(this,"id","BlockAlignProvider");this.editor=t}applyAlignStyle(t,e,o){Object.keys(Cx).includes(o)?t.updateBlockData(e,{align:o}):t.updateBlockData(e,{align:null})}isChecked(t,e){return t.align===e}getAvailableCommands(t,e,o){if(_(t,e)){const r=j(e),i=it(e),s=Je(t,e),l=t.getBlockData(e),c=a=>{var f;const d=b("span",["toolbar-item-name-container"],null);for(const m of a.children)if((f=m.states)!=null&&f.includes("checked"))return d.innerHTML=m.icon||xs,d;return d.innerHTML=xs,d};return[{id:"align",name:x.t("commands.alignGroup"),blockId:r,blockType:i,blockKind:s,groupIndex:700,dropdown:!0,element:c,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["align-left"],children:[{id:"align-left",name:x.t("commands.alignLeft"),icon:xs,states:this.isChecked(l,"left")?["checked"]:[]},{id:"align-center",name:x.t("commands.alignCenter"),icon:Ih,states:this.isChecked(l,"center")?["checked"]:[]},{id:"align-right",name:x.t("commands.alignRight"),icon:Eh,states:this.isChecked(l,"right")?["checked"]:[]}],childrenType:"menu"}]}return[]}executeCommand(t,e,o,r){if(!_(t,e))return!1;if(r.id.startsWith("align")){const i=r.id.replace(/^align-/,"");return this.applyAlignStyle(t,e,i),!0}return!1}}function bx(n){const e=n.selection.range;if(e.isCollapsed()||e.start.blockId!==e.end.blockId||!e.start.isSimple()||!e.end.isSimple()||e.end.offset-e.start.offset!==1)return!1;const o=n.getBlockById(e.start.blockId);return Xi(n,o,e.start.offset).charType==="box"}const vx=w("toolbar-handler"),yx={id:"",name:"",type:"separator"};class ii{constructor(t){h(this,"toolbar");h(this,"toolbarType","object");h(this,"mouseDown",!1);h(this,"oldRange",null);h(this,"hoveringBlock",null);h(this,"hoveringTextChild",null);h(this,"_disableTextToolbar",!1);h(this,"handleButtonClick",(t,e)=>{this.toolbarType==="text"?(this.editor.editorCommandProviders.executeCommand(this.editor.selection.range,e,{}),this.showTextToolbar("click")):this.hoveringBlock&&qE(this.editor,this.hoveringBlock,this.hoveringTextChild,e)});h(this,"handleClose",()=>{Dh(this.editor)&&this.editor.focus()});h(this,"handleClosing",(t,e)=>{if(this.toolbarType==="object"){const o=Im(e);if(this.hoveringBlock===o)return!1}return!0});h(this,"handleDocumentMouseDown",t=>{t.button===0&&(document.addEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!0)});h(this,"handleDocumentMouseUp",()=>{document.removeEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!1,this.handleSelectionChange(this.editor)});h(this,"handleHoveringBlockChildChange",(t,e,o,r)=>{if(!(this.hoveringBlock===t&&this.hoveringTextChild===e)&&(this.hoveringBlock=t,this.hoveringTextChild=e,!(this.toolbar.isVisible&&this.toolbarType==="text"))){if(!t){this.toolbar.close();return}this.showObjectToolbar()}});h(this,"handleSelectionChange",ee.default(t=>{if(u(vx,t===this.editor,"editor mismatch"),t.selection.range.isCollapsed()||this.mouseDown){if(this.toolbarType==="object"&&this.editor.selection.focusedBlock===this.hoveringBlock)return;this.toolbar.close(),this.oldRange=null;return}if(!this.editor.isWritable()){this.toolbar.close(),this.oldRange=null;return}if(t.selection.range.getSelectedBlocks().length===0){this.toolbar.close(),this.oldRange=null;return}this.oldRange&&this.oldRange.isEqual(t.selection.range)||(this.oldRange=t.selection.range,this.showTextToolbar("selectionChange"))},50));this.editor=t;const e=t.options.componentsOptions.popover;this.toolbar=new Ss([],void 0,{tooltipId:t.clientId,id:"editor-toolbar",overflowBoundary:e==null?void 0:e.overflowBoundary,refuseOverflow:!0}),this.toolbar.on("click",this.handleButtonClick),this.toolbar.on("close",this.handleClose),this.toolbar.on("closing",this.handleClosing),this.bindEvents(),t.addListener("selectionChanged",this.handleSelectionChange),$t.get(t).addListener("childChange",this.handleHoveringBlockChildChange),$t.get(t).addFilter(this),t.editorCommandProviders.registerCommandProvider(new GE(t)),t.editorCommandProviders.registerCommandProvider(new px(t)),t.editorCommandProviders.registerCommandProvider(new Ax(t))}disableTextToolbar(){this._disableTextToolbar=!0}enableTextToolbar(){this._disableTextToolbar=!1}hide(){this.toolbar.close()}destroy(){this.unbindEvents(),this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange),$t.get(this.editor).removeListener("childChange",this.handleHoveringBlockChildChange)}isInBlock(t,e){return t!==this.hoveringBlock?!1:!!(e.target&&e.target instanceof Node&&this.toolbar.popper&&wt(this.toolbar.popper,e.target))}bindEvents(){document.addEventListener("mousedown",this.handleDocumentMouseDown)}unbindEvents(){document.removeEventListener("mousedown",this.handleDocumentMouseDown)}update(t){this.showTextToolbar(t)}showTextToolbar(t){if(this._disableTextToolbar||!this.editor.isWritable())return;const o=this.editor.selection.range.getSelectedBlocks();if(o.length===0)return;const r=o[0];if(!r)return;if(o.length===1&&Te(r.block)){t==="click"&&this.showObjectToolbar();return}if(bx(this.editor))return;if(z(r.block)===this.editor.rootContainer&&K(r.block)===0){this.toolbar.close();return}const i=this.editor.editorCommandProviders.getCommands(this.editor.selection.range),s=new Map;i.forEach(d=>{const f=d.groupIndex,m=s.get(f);m?m.push(d):s.set(f,[d])});const l=[[]],c=Array.from(s.entries()).sort((d,f)=>d[0]-f[0]);for(let d=0;d<c.length;d++){const[,f]=c[d];if(f.length===0)continue;let m=l[l.length-1];m.length>0&&m[m.length-1].groupIndex!==f[f.length-1].groupIndex&&(m=[],l.push(m)),m.push(...Uc(f))}if(l.length===0){this.toolbar.close();return}this.toolbarType="text";const a=[];if(l.forEach((d,f)=>{const m=d.sort((p,A)=>{var k,v;return((k=p.order)!=null?k:0)-((v=A.order)!=null?v:0)});a.push(...m),f!==l.length-1&&a.push(yx)}),a.length===0){this.toolbar.close();return}if(this.toolbar.updateItems(a),!this.toolbar.isVisible){const d=o[o.length-1],f=!this.editor.selection.range.isReverse()&&d!==r,m=f?d:r,p=$E(this.editor,m),A=fo(this.editor,m.block,"editor-quick-menu",p);this.toolbar.manualShow(A,{placement:f?"bottom":"top"})}}showObjectToolbar(){var r,i;if(!this.hoveringBlock)return;const t=this.hoveringBlock,e=this.hoveringTextChild,o=zE(this.editor,t,e);if(!o.length){this.toolbar.close();return}this.toolbarType="object",this.toolbar.isVisible&&((i=(r=this.toolbar)==null?void 0:r.tippyInstance)==null?void 0:i.reference)!==t&&this.toolbar.close(),this.toolbar.updateItems(o),this.toolbar.isVisible||this.toolbar.manualShow(e||st(t),{placement:e?"bottom":"top"})}static register(t){return t.addCustom("toolbar-handler",e=>new ii(e))}static get(t){return t.getCustom("toolbar-handler")}}function Kc(n,t,e){n.getBlockData(t).heading===e?n.updateBlockData(t,{heading:null}):n.updateBlockData(t,{heading:e})}function RC(n,t,e){["left","center","right"].includes(e)?n.updateBlockData(t,{align:e}):n.updateBlockData(t,{align:null})}function g1(n,t){const o=n.getBlockData(t).quoted;n.updateBlockData(t,{quoted:o?void 0:!0})}function p1(n,t){return!!(n[t]||n.level&&(n.ordered===!0&&!n.checkbox&&t==="ordered-list"||n.ordered===!1&&!n.checkbox&&t==="unordered-list")||t==="check-list"&&n.checkbox)}function C1(n,t,e){if(!n.selection.range.focus.isSimple())return;const r=n.getBlockData(t);let i;switch(e){case"unordered-list":i=p1(r,"unordered-list")?void 0:"unordered";break;case"ordered-list":i=p1(r,"ordered-list")?void 0:"ordered";break;case"check-list":i=p1(r,"check-list")?void 0:"unchecked";break}if(i){const s=jl(n,t,"list",{offset:0,data:{listType:i}});s&&n.undoManager.runInGroup(()=>{const l=K(t),c=z(t);n.deleteBlock(t),n.insertBlock(V(c),l,s.blockData)})}else ri(n,t)}const kx=Object.freeze(Object.defineProperty({__proto__:null,applyHeadingStyle:Kc,applyAlignStyle:RC,applyQuoteStyle:g1,applyList:C1},Symbol.toStringTag,{value:"Module"})),wx=[Ch,Ah,bh,vh,yh,kh,wh,Bh],Bx={Unordered:E5,Ordered:I5,Checkbox:w5,Quote:B5};function OC(n,t){const e=n;e.blockOptions=t,e.itemType="insert-block",n.children&&n.children.forEach(o=>OC(o,t))}function A1(n=1){var r;const t={name:"basic",insertBlockCommandItems:[]};let e=qc();e<=4?e=5:e<8&&(e+=1);let o=n;for(;o<=e;){const i=`heading-${o}`;(r=t.insertBlockCommandItems)==null||r.push({id:i,icon:wx[o-1],name:x.t("quickMenu.basic.heading.title",{heading:String(o)}),order:o,group:"basics",value:String(o),subText:Ce(i)}),o++}return t}function Ex(){const n={name:"basic",insertBlockCommandItems:[]};return["Unordered","Ordered","Checkbox","Quote"].forEach((e,o)=>{var i;const r=`insert-${e.toLocaleLowerCase()}`;(i=n.insertBlockCommandItems)==null||i.push({id:r,name:x.t(`quickMenu.basic.${e.toLocaleLowerCase()}`),icon:Bx[e],value:e.toLocaleLowerCase(),group:"basics",order:10+o,subText:Ce(r)})}),n}class NC{getCommands(){const t=A1(),e=Ex();return[...t.insertBlockCommandItems||[],...e.insertBlockCommandItems||[]]}updateBlock(t,e,o,r){const{value:i,id:s}=r;return s.startsWith("heading-")?Kc(t,o,Number.parseInt(i!=null?i:"1",10)||1):i==="ordered"||i==="unordered"||i==="checkbox"?C1(t,o,{ordered:"ordered-list",unordered:"unordered-list",checkbox:"check-list"}[i]):i==="quote"&&g1(t,o),null}async handleUpdateBlockCore(t,e){const o=t.getBlockByIndex(e.containerId,e.blockIndex);return this.updateBlock(t,e.containerId,o,e.item)}async handleInsertEmptyBlockCore(t,e){const{containerId:o,blockIndex:r}=e,i=t.insertTextBlock(void 0,o,r);return this.updateBlock(t,e.containerId,i,e.item)}async executeCommand(t,e,o){if(o.from==="quick-menu"){const r=t.getBlockById(o.blockId),i=t.getParentContainer(r),s=V(i),l=t.getBlockIndex(r);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else o.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:o.containerId,blockIndex:o.blockIndex}));return null}}const Ix={basics:100,system:200,common:300,thirdParty:400};class b1{constructor(){h(this,"dataUrl","");h(this,"error",null)}destroy(){}setDataUrl(t){this.error=null,this.dataUrl=t}setError(t){this.dataUrl="",this.error=t}}const xx=w("mathjax-converter"),Tx="MathJax-script";async function Sx(n){var o;window.MathJax||(window.MathJax={options:{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml","body"]}});const t=n.getComponentOptions("mathjax"),e=((o=t==null?void 0:t.cdn)==null?void 0:o.mathjax)||"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js";await qo(e,Tx)}function Dx(){try{window.MathJax&&window.MathJax.texReset()}catch{}}async function PC(n,t){const e="mathjax2Svg";try{await Ge.lock(e),Dx(),await Sx(n);const o=await window.MathJax.tex2svgPromise(t),r=o.querySelector("merror");if(r)throw new Error(r.textContent);return o.querySelector("svg").outerHTML}catch(o){throw xx.error(o),o}finally{Ge.release(e)}}async function $C(n,t){const e=await PC(n,t);return e?await Bu(e,"image/svg+xml"):""}async function v1(n,t){const o=await PC(n,t),r=new File([o],"math.svg");return(await n.doc.uploadResource(r)).resourceId}const _C=w("edit-mathjax");class Lx{constructor(){h(this,"editMathjaxPopup",null);h(this,"onChange",null);h(this,"tex","");h(this,"handleShow",()=>{setTimeout(()=>{this.getTextarea().focus()})});h(this,"handleClose",t=>{var o;const e=t.content.querySelector("textarea");if(e){const r=e.value;r!==this.tex&&((o=this.onChange)==null||o.call(this,r,!0))}});h(this,"handleKeyup",t=>{var e;t.isComposing||(t.key==="Escape"&&((e=this.editMathjaxPopup)==null||e.close()),this.handleChange(t.target.value))});h(this,"handleChange",ee.default(t=>{var e;(e=this.onChange)==null||e.call(this,t,!1)},300))}editMathjax(t,e,o){if(!this.editMathjaxPopup)this.editMathjaxPopup=new Is(this.createPopupContent(e));else{const r=this.getTextarea();r.value=e}this.tex=e,this.editMathjaxPopup.addListener("show",this.handleShow),this.editMathjaxPopup.manualShow(t,{theme:"light"}),this.editMathjaxPopup.removeAllListeners("close"),this.editMathjaxPopup.addListener("close",this.handleClose),this.onChange=o}createPopupContent(t){const e=b("textarea",["mathjax-editor-textarea"],null);return e.value=t,e.addEventListener("keyup",this.handleKeyup),e}getTextarea(){u(_C,this.editMathjaxPopup,"no exists mathjax editor popup");const t=this.editMathjaxPopup.content.querySelector("textarea");return u(_C,t,"no textarea"),t}destroy(){var t;this.onChange=null,(t=this.editMathjaxPopup)==null||t.removeAllListeners()}}function FC(n,t,e,o){n.addCustom("mathjax-editor",()=>new Lx).editMathjax(t,e.trim(),o)}function HC(){return{insert:" ",attributes:{id:P(),box:!0,type:"math",tex:" ",src:"",created:Date.now()}}}function Xc(n,t){const e=n.getBoxData(t),o=U(t);if(!o)return;const r=mo(o,t);n.selection.selectBlock(o,r.start,r.end);const i=async(s,l)=>{if(!s.trim()){n.updateBoxData({...e,tex:s,src:null});return}try{await Ge.lock("convertAndUploadMathjax");const c=await v1(n,s);n.updateBoxData({...e,tex:s,src:c})}catch(c){const a=n.getBoxData(t);n.addCustom(`mathjax-box-${a.id}`,()=>new b1).setError(c),n.updateBoxData({...e,tex:s,src:""})}finally{Ge.release("convertAndUploadMathjax"),l&&n.focus()}};FC(n,t,e.tex,i)}const Mx=w("mathjax-box");function y1(n,t){n.selection.updateSelection(null);const e=t.target;!e||!(e instanceof HTMLElement)||n.domEvents.removeEventListener(e,null,y1)}async function Rx(n,t,e){try{if(!t.tex.trim())return;const o=await $C(n,t.tex),r=n.findBoxById(t.id);if(!r)return;const i=Ou(r);i.innerHTML="";const s=b("img",["mathjax"],i);s.src=o,e.setDataUrl(o),n.domEvents.addEventListener(s,"load",y1)}catch(o){e.setError(o);const r=n.findBoxById(t.id);if(!r)return;const i=r.querySelector(".mathjax-tex-text");M(i,"mathjax-error"),i.innerText=o.message,n.selection.updateSelection(null)}}function Ox(n,t,e,o){const r=o,i=n.addCustom(`mathjax-box-${r.id}`,()=>new b1);if(r.src||i.dataUrl){const c=b("img",["mathjax"],e);c.src=n.doc.buildResourceUrl(r.src||i.dataUrl),n.domEvents.addEventListener(c,"load",y1);return}const s=["mathjax-tex-text"];let l=r.tex;l.trim()?i.error&&(l=i.error.message,s.push("mathjax-error")):l=x.t("mathjax.emptyText"),b("span",s,e,l),Rx(n,r,i)}function Nx(n,t){const e={id:P(),box:!0,type:"math",tex:t,src:"",created:Date.now()};return v1(n,t).then(o=>{if(!n.findBoxById(e.id))return;const i={...e,src:o};n.updateBoxData(i)}).catch(o=>{Mx.error(`failed to convert and upload mathjax: ${JSON.stringify(o)}`)}),e}function Px(n,t,e,o){const r=t;return o==="text"?r.tex:o==="markdown"?` $${r.tex}$ `:r.src?`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`:`<code>$${r.tex}$</code>`}function $x(n,t,e){Xc(n,t)}const ta={boxType:"math",updateBoxContent:Ox,convertFrom:Nx,convertTo:Px,handleClickBox:$x};async function _x(n,t,e){try{const o=t.embedData,r=await $C(n,o.mathjaxText),i=n.findBlockById(t.id);if(!i)return;const s=st(i);s.innerHTML="";const l=b("img",["mathjax"],s);l.src=r,e.setDataUrl(r)}catch(o){e.setError(o)}}function Fx(n,t){if(n.readonly||!t.target||!(t.target instanceof Node))return;const e=U(t.target);if(!e||!Te(e)||Ne(e)!=="math")return;const o=st(e),r=o.querySelector("img")||o.querySelector("span.mathjax-tex-text");if(!r||!wt(r,t.target))return;const s=n.getBlockData(e).embedData;FC(n,r,s.mathjaxText,async l=>{const c=await v1(n,l),a={mathjaxText:l,src:c};n.updateEmbedData(e,a)})}function Hx(n,t,e){const o=e.embedData,r=n.addCustom(`mathjax-block-${e.id}`,()=>new b1);if(n.domEvents.addEventListener(t,"click",Fx),o.src||r.dataUrl){const i=b("img",["mathjax"],t);i.src=n.doc.buildResourceUrl(o.src||r.dataUrl);return}r.error,b("span",["mathjax-tex-text"],t,o.mathjaxText),_x(n,e,r)}function jx(n,t,e){if(!_(n,t))return null;const o=n.getBlockString(t).trim();if(!o||!o.startsWith("$$")||!o.endsWith("$$"))return null;const r=Au(o,"$");if(!r)return null;const i={mathjaxText:r,src:""};return{blockData:{id:P(),type:"embed",embedType:"math",embedData:i}}}function zx(n){return{name:"Mathjax"}}function Ux(n,t){const e=st(t);n.domEvents.removeAllListeners(e)}function Vx(n,t,e,o){const r=t.embedData;return o==="html"?`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`:o==="markdown"?`
|
|
368
|
+
`;function hx(n){const t=b("div",["list-to-mindmap-wrap"],null),e=Bo("list-to-mindmap",T.t("mindmap.viewAsMindMap"),dx,[],n.clientId);return t.appendChild(e),t}const uV="";class Jc{constructor(t){h(this,"toMindmapButton");h(this,"currentBlock",null);h(this,"handleHoveringBlock",t=>{!this.editor.isWritable()||(t&&ut(t)&&ze(t)!=="unchecked"&&ze(t)!=="checked"?Rt(t).appendChild(this.toMindmapButton):this.toMindmapButton.remove())});h(this,"handleMouseEnter",()=>{const t=U(this.toMindmapButton);u(Nt,t&&ut(t),"no parent list"),u1(this.editor,t,!0),this.currentBlock=t});h(this,"handleMouseLeave",()=>{this.currentBlock&&(u1(this.editor,this.currentBlock,!1),this.currentBlock=null)});h(this,"handleClick",()=>{const t=U(this.toMindmapButton);u(Nt,t&&ut(t),"no parent list"),d1(this.editor,t,{},{saveData:!0,selectBlock:!0,mindmapTools:BC})});this.editor=t,$t.get(this.editor).addListener("change",this.handleHoveringBlock),this.toMindmapButton=hx(t),t.domEvents.addEventListener(this.toMindmapButton,"mouseenter",this.handleMouseEnter),t.domEvents.addEventListener(this.toMindmapButton,"mouseleave",this.handleMouseLeave),t.domEvents.addEventListener(this.toMindmapButton,"click",this.handleClick)}static get(t){return t.findCustomByType(Jc)}destroy(){$t.get(this.editor).removeListener("change",this.handleHoveringBlock)}hide(){this.currentBlock&&(this.currentBlock=null),this.toMindmapButton.remove()}}const fx={list:{confirm:"\u786E\u5B9A",setStart:"\u8BBE\u7F6E\u7F16\u53F7",continueList:"\u7EE7\u7EED\u7F16\u53F7",restartList:"\u5F00\u59CB\u65B0\u5217\u8868",changeNumber:"\u4FEE\u6539\u7F16\u53F7\u503C",numberLabel:"\u7F16\u53F7\u987A\u5E8F",mention:{tooltip:"\u63D0\u53CA\u4EBA\u5458\u5E76\u901A\u77E5"}},mindmap:{viewAsMindMap:"\u663E\u793A\u4E3A\u8111\u56FE",autoFit:"\u81EA\u52A8\u7F29\u653E",fullScreen:"\u5168\u5C4F\u67E5\u770B",close:"\u5173\u95ED",exitFullscreen:"\u9000\u51FA\u5168\u5C4F"}},mx={list:{confirm:"OK",setStart:"Set the number",continueList:"Continue numbering",restartList:"Start a new list",changeNumber:"Set numbering value",numberLabel:"Numbering order",mention:{tooltip:"@Mention someone"}},mindmap:{viewAsMindMap:"View as MindMap",autoFit:"Auto fit",fullScreen:"Fullscreen",close:"Close",exitFullscreen:"Exit fullscreen"}};T.mergeLang({"zh-CN":fx,"en-US":mx});const dV="";function gx(n,t,e){var o;t==="beginDrag"&&((o=Jc.get(n))==null||o.hide())}const MC={...ye,blockType:"list",createBlockContent:ux,convertFrom:uI,convertTo:hI,handleDrop:pI,notify:gx},m1=w("paragraph");class px{constructor(t){h(this,"id","BlockParagraphProvider");this.editor=t}isChecked(t,e){return!!(t[e]||t.level&&(t.ordered===!0&&!t.checkbox&&e==="ordered-list"||t.ordered===!1&&!t.checkbox&&e==="unordered-list")||e==="check-list"&&t.checkbox)}getAvailableCommands(t,e){const o=[],r={"unordered-list":[T.t("commands.unordered"),xt.isMac?T.t("commandDesc.mac.unordered"):T.t("commandDesc.window.unordered"),Tw],"ordered-list":[T.t("commands.ordered"),xt.isMac?T.t("commandDesc.mac.ordered"):T.t("commandDesc.window.ordered"),xw],"check-list":[T.t("commands.check"),void 0,Sw],link:[T.t("commands.link"),xt.isMac?T.t("commandDesc.mac.link"):T.t("commandDesc.window.link"),k5],quoted:[T.t("commands.quote"),void 0,Dw]};if(_(t,e)){const i=j(e),s=it(e),l=Je(t,e),c=t.getBlockData(e);Object.entries(r).forEach(([a,[d,f,m]])=>{const p=[];if(this.isChecked(c,a)&&p.push("checked"),a==="link"){if(!t.selection.range.isSimple())return;t.selection.range.getSelectedBlocks().length!==1&&p.push("disabled")}o.push({blockId:i,blockType:s,blockKind:l,id:a,name:d,desc:f,states:p,icon:m,groupIndex:600})})}return o}convertLink(t,e,o){u(m1,uo(e.start),""),u(m1,uo(e.start),"");const r="bottom-start",i=e.start.offset,s=e.end.offset,l=(p,A)=>{t.undoManager.runInGroup(()=>{try{let k=Kl(t.getBlockText(o),i,s,p);k=Yi(i,p.length,k,"link",A),t.setBlockText(o,k),t.selection.selectBlock(o,i+p.length),t.focus()}catch(k){m1.error(k)}})},c=()=>{t.selection.selectBlock(o,s),t.focus()},a=co(t,o,e)[0];if(!a)return;const d=fo(t,o,"link-button-anchor",a),f=t.getBlockText(o),m=Ji(f,i);Hs(t,{target:d,linkText:t.getSelectedText(),linkUrl:(m==null?void 0:m.link)||"",onFinished:l,onClose:c,placement:r})}convertToList(t,e,o){const r=jl(t,e,"list",{offset:0,data:{listType:o}});r&&t.undoManager.runInGroup(()=>{const i=K(e),s=z(e);t.insertBlock(V(s),i,r.blockData),t.deleteBlock(e)})}executeCommand(t,e,o,r){var c;if(!_(t,e))return!1;const i=r.id,s=(c=r.states)==null?void 0:c.includes("checked");let l=!1;if(i==="unordered-list"&&(s?ri(t,e):this.convertToList(t,e,"unordered"),l=!0),i==="ordered-list"&&(s?ri(t,e):this.convertToList(t,e,"ordered"),l=!0),i==="check-list"&&(s?ri(t,e):this.convertToList(t,e,"unchecked"),l=!0),i==="quoted"){const d=t.getBlockData(e).quoted;t.updateBlockData(e,{quoted:d?void 0:!0}),l=!0}if(i==="link"){const a=Vc(t);a.disableTextToolbar(),a.hide(),setTimeout(()=>{a.enableTextToolbar()},1e3),this.convertLink(t,o,e),l=!0}return l}}const Cx={left:xs,right:Eh,center:Ih};class Ax{constructor(t){h(this,"id","BlockAlignProvider");this.editor=t}applyAlignStyle(t,e,o){Object.keys(Cx).includes(o)?t.updateBlockData(e,{align:o}):t.updateBlockData(e,{align:null})}isChecked(t,e){return t.align===e}getAvailableCommands(t,e,o){if(_(t,e)){const r=j(e),i=it(e),s=Je(t,e),l=t.getBlockData(e),c=a=>{var f;const d=b("span",["toolbar-item-name-container"],null);for(const m of a.children)if((f=m.states)!=null&&f.includes("checked"))return d.innerHTML=m.icon||xs,d;return d.innerHTML=xs,d};return[{id:"align",name:T.t("commands.alignGroup"),blockId:r,blockType:i,blockKind:s,groupIndex:700,dropdown:!0,element:c,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["align-left"],children:[{id:"align-left",name:T.t("commands.alignLeft"),icon:xs,states:this.isChecked(l,"left")?["checked"]:[]},{id:"align-center",name:T.t("commands.alignCenter"),icon:Ih,states:this.isChecked(l,"center")?["checked"]:[]},{id:"align-right",name:T.t("commands.alignRight"),icon:Eh,states:this.isChecked(l,"right")?["checked"]:[]}],childrenType:"menu"}]}return[]}executeCommand(t,e,o,r){if(!_(t,e))return!1;if(r.id.startsWith("align")){const i=r.id.replace(/^align-/,"");return this.applyAlignStyle(t,e,i),!0}return!1}}function bx(n){const e=n.selection.range;if(e.isCollapsed()||e.start.blockId!==e.end.blockId||!e.start.isSimple()||!e.end.isSimple()||e.end.offset-e.start.offset!==1)return!1;const o=n.getBlockById(e.start.blockId);return Xi(n,o,e.start.offset).charType==="box"}const vx=w("toolbar-handler"),yx={id:"",name:"",type:"separator"};class ii{constructor(t){h(this,"toolbar");h(this,"toolbarType","object");h(this,"mouseDown",!1);h(this,"oldRange",null);h(this,"hoveringBlock",null);h(this,"hoveringTextChild",null);h(this,"_disableTextToolbar",!1);h(this,"handleButtonClick",(t,e)=>{this.toolbarType==="text"?(this.editor.editorCommandProviders.executeCommand(this.editor.selection.range,e,{}),this.showTextToolbar("click")):this.hoveringBlock&&qE(this.editor,this.hoveringBlock,this.hoveringTextChild,e)});h(this,"handleClose",()=>{Dh(this.editor)&&this.editor.focus()});h(this,"handleClosing",(t,e)=>{if(this.toolbarType==="object"){const o=Im(e);if(this.hoveringBlock===o)return!1}return!0});h(this,"handleDocumentMouseDown",t=>{t.button===0&&(document.addEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!0)});h(this,"handleDocumentMouseUp",()=>{document.removeEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!1,this.handleSelectionChange(this.editor)});h(this,"handleHoveringBlockChildChange",(t,e,o,r)=>{if(!(this.hoveringBlock===t&&this.hoveringTextChild===e)&&(this.hoveringBlock=t,this.hoveringTextChild=e,!(this.toolbar.isVisible&&this.toolbarType==="text"))){if(!t){this.toolbar.close();return}this.showObjectToolbar()}});h(this,"handleSelectionChange",ee.default(t=>{if(u(vx,t===this.editor,"editor mismatch"),t.selection.range.isCollapsed()||this.mouseDown){if(this.toolbarType==="object"&&this.editor.selection.focusedBlock===this.hoveringBlock)return;this.toolbar.close(),this.oldRange=null;return}if(!this.editor.isWritable()){this.toolbar.close(),this.oldRange=null;return}if(t.selection.range.getSelectedBlocks().length===0){this.toolbar.close(),this.oldRange=null;return}this.oldRange&&this.oldRange.isEqual(t.selection.range)||(this.oldRange=t.selection.range,this.showTextToolbar("selectionChange"))},50));this.editor=t;const e=t.options.componentsOptions.popover;this.toolbar=new Ss([],void 0,{tooltipId:t.clientId,id:"editor-toolbar",overflowBoundary:e==null?void 0:e.overflowBoundary,refuseOverflow:!0}),this.toolbar.on("click",this.handleButtonClick),this.toolbar.on("close",this.handleClose),this.toolbar.on("closing",this.handleClosing),this.bindEvents(),t.addListener("selectionChanged",this.handleSelectionChange),$t.get(t).addListener("childChange",this.handleHoveringBlockChildChange),$t.get(t).addFilter(this),t.editorCommandProviders.registerCommandProvider(new GE(t)),t.editorCommandProviders.registerCommandProvider(new px(t)),t.editorCommandProviders.registerCommandProvider(new Ax(t))}disableTextToolbar(){this._disableTextToolbar=!0}enableTextToolbar(){this._disableTextToolbar=!1}hide(){this.toolbar.close()}destroy(){this.unbindEvents(),this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange),$t.get(this.editor).removeListener("childChange",this.handleHoveringBlockChildChange)}isInBlock(t,e){return t!==this.hoveringBlock?!1:!!(e.target&&e.target instanceof Node&&this.toolbar.popper&&wt(this.toolbar.popper,e.target))}bindEvents(){document.addEventListener("mousedown",this.handleDocumentMouseDown)}unbindEvents(){document.removeEventListener("mousedown",this.handleDocumentMouseDown)}update(t){this.showTextToolbar(t)}showTextToolbar(t){if(this._disableTextToolbar||!this.editor.isWritable())return;const o=this.editor.selection.range.getSelectedBlocks();if(o.length===0)return;const r=o[0];if(!r)return;if(o.length===1&&Te(r.block)){t==="click"&&this.showObjectToolbar();return}if(bx(this.editor))return;if(z(r.block)===this.editor.rootContainer&&K(r.block)===0){this.toolbar.close();return}const i=this.editor.editorCommandProviders.getCommands(this.editor.selection.range),s=new Map;i.forEach(d=>{const f=d.groupIndex,m=s.get(f);m?m.push(d):s.set(f,[d])});const l=[[]],c=Array.from(s.entries()).sort((d,f)=>d[0]-f[0]);for(let d=0;d<c.length;d++){const[,f]=c[d];if(f.length===0)continue;let m=l[l.length-1];m.length>0&&m[m.length-1].groupIndex!==f[f.length-1].groupIndex&&(m=[],l.push(m)),m.push(...Uc(f))}if(l.length===0){this.toolbar.close();return}this.toolbarType="text";const a=[];if(l.forEach((d,f)=>{const m=d.sort((p,A)=>{var k,v;return((k=p.order)!=null?k:0)-((v=A.order)!=null?v:0)});a.push(...m),f!==l.length-1&&a.push(yx)}),a.length===0){this.toolbar.close();return}if(this.toolbar.updateItems(a),!this.toolbar.isVisible){const d=o[o.length-1],f=!this.editor.selection.range.isReverse()&&d!==r,m=f?d:r,p=$E(this.editor,m),A=fo(this.editor,m.block,"editor-quick-menu",p);this.toolbar.manualShow(A,{placement:f?"bottom":"top"})}}showObjectToolbar(){var r,i;if(!this.hoveringBlock)return;const t=this.hoveringBlock,e=this.hoveringTextChild,o=zE(this.editor,t,e);if(!o.length){this.toolbar.close();return}this.toolbarType="object",this.toolbar.isVisible&&((i=(r=this.toolbar)==null?void 0:r.tippyInstance)==null?void 0:i.reference)!==t&&this.toolbar.close(),this.toolbar.updateItems(o),this.toolbar.isVisible||this.toolbar.manualShow(e||st(t),{placement:e?"bottom":"top"})}static register(t){return t.addCustom("toolbar-handler",e=>new ii(e))}static get(t){return t.getCustom("toolbar-handler")}}function Kc(n,t,e){n.getBlockData(t).heading===e?n.updateBlockData(t,{heading:null}):n.updateBlockData(t,{heading:e})}function RC(n,t,e){["left","center","right"].includes(e)?n.updateBlockData(t,{align:e}):n.updateBlockData(t,{align:null})}function g1(n,t){const o=n.getBlockData(t).quoted;n.updateBlockData(t,{quoted:o?void 0:!0})}function p1(n,t){return!!(n[t]||n.level&&(n.ordered===!0&&!n.checkbox&&t==="ordered-list"||n.ordered===!1&&!n.checkbox&&t==="unordered-list")||t==="check-list"&&n.checkbox)}function C1(n,t,e){if(!n.selection.range.focus.isSimple())return;const r=n.getBlockData(t);let i;switch(e){case"unordered-list":i=p1(r,"unordered-list")?void 0:"unordered";break;case"ordered-list":i=p1(r,"ordered-list")?void 0:"ordered";break;case"check-list":i=p1(r,"check-list")?void 0:"unchecked";break}if(i){const s=jl(n,t,"list",{offset:0,data:{listType:i}});s&&n.undoManager.runInGroup(()=>{const l=K(t),c=z(t);n.deleteBlock(t),n.insertBlock(V(c),l,s.blockData)})}else ri(n,t)}const kx=Object.freeze(Object.defineProperty({__proto__:null,applyHeadingStyle:Kc,applyAlignStyle:RC,applyQuoteStyle:g1,applyList:C1},Symbol.toStringTag,{value:"Module"})),wx=[Ch,Ah,bh,vh,yh,kh,wh,Bh],Bx={Unordered:E5,Ordered:I5,Checkbox:w5,Quote:B5};function OC(n,t){const e=n;e.blockOptions=t,e.itemType="insert-block",n.children&&n.children.forEach(o=>OC(o,t))}function A1(n=1){var r;const t={name:"basic",insertBlockCommandItems:[]};let e=qc();e<=4?e=5:e<8&&(e+=1);let o=n;for(;o<=e;){const i=`heading-${o}`;(r=t.insertBlockCommandItems)==null||r.push({id:i,icon:wx[o-1],name:T.t("quickMenu.basic.heading.title",{heading:String(o)}),order:o,group:"basics",value:String(o),subText:Ce(i)}),o++}return t}function Ex(){const n={name:"basic",insertBlockCommandItems:[]};return["Unordered","Ordered","Checkbox","Quote"].forEach((e,o)=>{var i;const r=`insert-${e.toLocaleLowerCase()}`;(i=n.insertBlockCommandItems)==null||i.push({id:r,name:T.t(`quickMenu.basic.${e.toLocaleLowerCase()}`),icon:Bx[e],value:e.toLocaleLowerCase(),group:"basics",order:10+o,subText:Ce(r)})}),n}class NC{getCommands(){const t=A1(),e=Ex();return[...t.insertBlockCommandItems||[],...e.insertBlockCommandItems||[]]}updateBlock(t,e,o,r){const{value:i,id:s}=r;return s.startsWith("heading-")?Kc(t,o,Number.parseInt(i!=null?i:"1",10)||1):i==="ordered"||i==="unordered"||i==="checkbox"?C1(t,o,{ordered:"ordered-list",unordered:"unordered-list",checkbox:"check-list"}[i]):i==="quote"&&g1(t,o),null}async handleUpdateBlockCore(t,e){const o=t.getBlockByIndex(e.containerId,e.blockIndex);return this.updateBlock(t,e.containerId,o,e.item)}async handleInsertEmptyBlockCore(t,e){const{containerId:o,blockIndex:r}=e,i=t.insertTextBlock(void 0,o,r);return this.updateBlock(t,e.containerId,i,e.item)}async executeCommand(t,e,o){if(o.from==="quick-menu"){const r=t.getBlockById(o.blockId),i=t.getParentContainer(r),s=V(i),l=t.getBlockIndex(r);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else o.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:o.containerId,blockIndex:o.blockIndex}));return null}}const Ix={basics:100,system:200,common:300,thirdParty:400};class b1{constructor(){h(this,"dataUrl","");h(this,"error",null)}destroy(){}setDataUrl(t){this.error=null,this.dataUrl=t}setError(t){this.dataUrl="",this.error=t}}const xx=w("mathjax-converter"),Tx="MathJax-script";async function Sx(n){var o;window.MathJax||(window.MathJax={options:{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml","body"]}});const t=n.getComponentOptions("mathjax"),e=((o=t==null?void 0:t.cdn)==null?void 0:o.mathjax)||"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js";await qo(e,Tx)}function Dx(){try{window.MathJax&&window.MathJax.texReset()}catch{}}async function PC(n,t){const e="mathjax2Svg";try{await Ge.lock(e),Dx(),await Sx(n);const o=await window.MathJax.tex2svgPromise(t),r=o.querySelector("merror");if(r)throw new Error(r.textContent);return o.querySelector("svg").outerHTML}catch(o){throw xx.error(o),o}finally{Ge.release(e)}}async function $C(n,t){const e=await PC(n,t);return e?await Bu(e,"image/svg+xml"):""}async function v1(n,t){const o=await PC(n,t),r=new File([o],"math.svg");return(await n.doc.uploadResource(r)).resourceId}const _C=w("edit-mathjax");class Lx{constructor(){h(this,"editMathjaxPopup",null);h(this,"onChange",null);h(this,"tex","");h(this,"handleShow",()=>{setTimeout(()=>{this.getTextarea().focus()})});h(this,"handleClose",t=>{var o;const e=t.content.querySelector("textarea");if(e){const r=e.value;r!==this.tex&&((o=this.onChange)==null||o.call(this,r,!0))}});h(this,"handleKeyup",t=>{var e;t.isComposing||(t.key==="Escape"&&((e=this.editMathjaxPopup)==null||e.close()),this.handleChange(t.target.value))});h(this,"handleChange",ee.default(t=>{var e;(e=this.onChange)==null||e.call(this,t,!1)},300))}editMathjax(t,e,o){if(!this.editMathjaxPopup)this.editMathjaxPopup=new Is(this.createPopupContent(e));else{const r=this.getTextarea();r.value=e}this.tex=e,this.editMathjaxPopup.addListener("show",this.handleShow),this.editMathjaxPopup.manualShow(t,{theme:"light"}),this.editMathjaxPopup.removeAllListeners("close"),this.editMathjaxPopup.addListener("close",this.handleClose),this.onChange=o}createPopupContent(t){const e=b("textarea",["mathjax-editor-textarea"],null);return e.value=t,e.addEventListener("keyup",this.handleKeyup),e}getTextarea(){u(_C,this.editMathjaxPopup,"no exists mathjax editor popup");const t=this.editMathjaxPopup.content.querySelector("textarea");return u(_C,t,"no textarea"),t}destroy(){var t;this.onChange=null,(t=this.editMathjaxPopup)==null||t.removeAllListeners()}}function FC(n,t,e,o){n.addCustom("mathjax-editor",()=>new Lx).editMathjax(t,e.trim(),o)}function HC(){return{insert:" ",attributes:{id:P(),box:!0,type:"math",tex:" ",src:"",created:Date.now()}}}function Xc(n,t){const e=n.getBoxData(t),o=U(t);if(!o)return;const r=mo(o,t);n.selection.selectBlock(o,r.start,r.end);const i=async(s,l)=>{if(!s.trim()){n.updateBoxData({...e,tex:s,src:null});return}try{await Ge.lock("convertAndUploadMathjax");const c=await v1(n,s);n.updateBoxData({...e,tex:s,src:c})}catch(c){const a=n.getBoxData(t);n.addCustom(`mathjax-box-${a.id}`,()=>new b1).setError(c),n.updateBoxData({...e,tex:s,src:""})}finally{Ge.release("convertAndUploadMathjax"),l&&n.focus()}};FC(n,t,e.tex,i)}const Mx=w("mathjax-box");function y1(n,t){n.selection.updateSelection(null);const e=t.target;!e||!(e instanceof HTMLElement)||n.domEvents.removeEventListener(e,null,y1)}async function Rx(n,t,e){try{if(!t.tex.trim())return;const o=await $C(n,t.tex),r=n.findBoxById(t.id);if(!r)return;const i=Ou(r);i.innerHTML="";const s=b("img",["mathjax"],i);s.src=o,e.setDataUrl(o),n.domEvents.addEventListener(s,"load",y1)}catch(o){e.setError(o);const r=n.findBoxById(t.id);if(!r)return;const i=r.querySelector(".mathjax-tex-text");M(i,"mathjax-error"),i.innerText=o.message,n.selection.updateSelection(null)}}function Ox(n,t,e,o){const r=o,i=n.addCustom(`mathjax-box-${r.id}`,()=>new b1);if(r.src||i.dataUrl){const c=b("img",["mathjax"],e);c.src=n.doc.buildResourceUrl(r.src||i.dataUrl),n.domEvents.addEventListener(c,"load",y1);return}const s=["mathjax-tex-text"];let l=r.tex;l.trim()?i.error&&(l=i.error.message,s.push("mathjax-error")):l=T.t("mathjax.emptyText"),b("span",s,e,l),Rx(n,r,i)}function Nx(n,t){const e={id:P(),box:!0,type:"math",tex:t,src:"",created:Date.now()};return v1(n,t).then(o=>{if(!n.findBoxById(e.id))return;const i={...e,src:o};n.updateBoxData(i)}).catch(o=>{Mx.error(`failed to convert and upload mathjax: ${JSON.stringify(o)}`)}),e}function Px(n,t,e,o){const r=t;return o==="text"?r.tex:o==="markdown"?` $${r.tex}$ `:r.src?`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`:`<code>$${r.tex}$</code>`}function $x(n,t,e){Xc(n,t)}const ta={boxType:"math",updateBoxContent:Ox,convertFrom:Nx,convertTo:Px,handleClickBox:$x};async function _x(n,t,e){try{const o=t.embedData,r=await $C(n,o.mathjaxText),i=n.findBlockById(t.id);if(!i)return;const s=st(i);s.innerHTML="";const l=b("img",["mathjax"],s);l.src=r,e.setDataUrl(r)}catch(o){e.setError(o)}}function Fx(n,t){if(n.readonly||!t.target||!(t.target instanceof Node))return;const e=U(t.target);if(!e||!Te(e)||Ne(e)!=="math")return;const o=st(e),r=o.querySelector("img")||o.querySelector("span.mathjax-tex-text");if(!r||!wt(r,t.target))return;const s=n.getBlockData(e).embedData;FC(n,r,s.mathjaxText,async l=>{const c=await v1(n,l),a={mathjaxText:l,src:c};n.updateEmbedData(e,a)})}function Hx(n,t,e){const o=e.embedData,r=n.addCustom(`mathjax-block-${e.id}`,()=>new b1);if(n.domEvents.addEventListener(t,"click",Fx),o.src||r.dataUrl){const i=b("img",["mathjax"],t);i.src=n.doc.buildResourceUrl(o.src||r.dataUrl);return}r.error,b("span",["mathjax-tex-text"],t,o.mathjaxText),_x(n,e,r)}function jx(n,t,e){if(!_(n,t))return null;const o=n.getBlockString(t).trim();if(!o||!o.startsWith("$$")||!o.endsWith("$$"))return null;const r=Au(o,"$");if(!r)return null;const i={mathjaxText:r,src:""};return{blockData:{id:P(),type:"embed",embedType:"math",embedData:i}}}function zx(n){return{name:"Mathjax"}}function Ux(n,t){const e=st(t);n.domEvents.removeAllListeners(e)}function Vx(n,t,e,o){const r=t.embedData;return o==="html"?`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`:o==="markdown"?`
|
|
369
369
|
$$${r.mathjaxText}$$
|
|
370
|
-
`:r.mathjaxText}const k1={embedType:"math",createEmbedContent:Hx,getOptions:zx,convertFrom:jx,handleDeleteBlock:Ux,convertTo:Vx},hV="",qx={mathjax:{emptyText:"\u7A7A\u7684\u516C\u5F0F",abstract:"\u516C\u5F0F"}},Wx={mathjax:{emptyText:"Empty Tex",abstract:"TeX"}};x.mergeLang({"zh-CN":qx,"en-US":Wx});function Gx(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=ve(i,o);if(!vt(s).endsWith("$$$$"))return!1;const c=o-4,a=o,d={id:P(),box:!0,type:"math",tex:" ",src:"",created:Date.now()};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,c,a-c),n.insertBoxToBlock(r,c,d),setTimeout(()=>{const f=n.getBoxById(d.id);Xc(n,f)})}),!0}class Zx{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&Gx(t,e,o,r))}}const si=w("inline-box-items");function Qx(n,t,e){return n.undoManager.runInGroup(()=>{var s;let o=n.getBlockByIndex(t,e);Tt(n,o)||(o=n.insertTextBlock([],t,e));const r=HC();n.setBlockText(o,[r]);const i=(s=r.attributes)==null?void 0:s.id;return u(si,i,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(i);Xc(n,l)},100),o})}function Yx(n,t,e){let o=n.getBlockByIndex(t,e),r="bottom-start";return Tt(n,o)||(r="top-start"),Hs(n,{target:o,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{Tt(n,o)||(o=n.insertTextBlock([],t,e));const a=_e(l,{link:c}),d=_e(" ",null),f=[a,d];n.insertTextToBlock(o,0,f),n.selection.selectBlock(o,me(f)),n.focus()}catch(a){si.error(a)}})},onClose:()=>{n.focus()},placement:r}),o}function Jx(n,t,e){return n.undoManager.runInGroup(()=>{var l;const o=n.getBlockByIndex(t,e),r=n.selection.range;u(si,uo(r.start),"invalid block position");const i=HC();n.insertBoxToBlock(o,r.start.offset,i.attributes);const s=(l=i.attributes)==null?void 0:l.id;return u(si,s,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(s);Xc(n,c)},100),o})}function Kx(n,t,e){const o=n.getBlockByIndex(t,e),r=n.selection.range;u(si,uo(r.start),"invalid block position");const i=co(n,o,r);if(i.length===0)return;const s=i[0],l=fo(n,o,"quick-menu-inline-link",s);Hs(n,{target:l,linkText:"",linkUrl:"",onFinished:(d,f)=>{n.undoManager.runInGroup(()=>{try{const m=n.getBlockText(o),p=po(m,r.start.offset,d,{link:f});n.setBlockText(o,p),n.selection.selectBlock(o,r.start.offset+d.length),n.focus()}catch(m){si.error(m)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class Xx{getCommands(){return[{id:"insert-math",name:x.t("quickMenu.inlineBox.math"),icon:Pw,order:900,group:"common",subText:Ce("insert-math")},{id:"insert-link",name:x.t("quickMenu.inlineBox.link"),icon:k5,order:400,group:"common",subText:Ce("insert-link")}]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return Jx(t,e.containerId,e.blockIndex);case"insert-link":return Kx(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return Qx(t,e.containerId,e.blockIndex);case"insert-link":return Yx(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,o){if(o.from==="quick-menu"){const r=t.getBlockById(o.blockId),i=t.getParentContainer(r),s=V(i),l=t.getBlockIndex(r);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else o.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:o.containerId,blockIndex:o.blockIndex}));return null}}function tT(n){var o,r;const t=(r=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:r.commandProviders;if(!t)return[];const e=[];return[...t,new NC,new Xx].forEach(i=>{const s=i.getCommands(n);e.push(...s.map(l=>({...l,itemType:"insert-block",commandProvider:i})))}),e}function eT(n){const t=[];return n.editorBlocks.forEach(e=>{if(!e.getOptions)return;const o=e.getOptions(n);!o.insertBlockCommandItems||(o.insertBlockCommandItems.forEach(r=>{OC(r,o)}),t.push(...o.insertBlockCommandItems))}),t.push(...tT(n)),t}function w1(n){const t=eT(n),e=new Map;t.forEach(i=>{var c;const s=(c=i.group)!=null?c:"";let l=e.get(s);l?l.items.push(i):(l={group:s,order:i.groupOrder||Ix[s]||1e3,items:[i]},e.set(s,l))});const o=Array.from(e.values());o.sort((i,s)=>i.order-s.order),o.forEach(i=>{i.items.sort((s,l)=>{var c,a;return((c=s.order)!=null?c:0)-((a=l.order)!=null?a:0)})});const r=[];return o.forEach((i,s)=>{const l=x.t(`blockMenu.section.${i.group||"common"}`),c=l===i.group?i.group:l;r.push({id:`section-${s}`,name:c,type:"section",group:i.group,itemType:"insert-block"}),r.push(...i.items.map(a=>({...a})))}),r}function nT(n,t,e){const o=n.getFocusedBlock();if(!o)return;const r=n.getParentContainer(o),i=V(r);let l=n.getBlockIndex(o);if(Tt(n,o)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:i,blockIndex:l,item:t})}const jC=w("quick-menu"),oT={id:"quick-menu",trigger:["/"]},rT=3;class ea{constructor(t,e=oT){h(this,"suggest");h(this,"items");h(this,"maxHeading");h(this,"firstEmptyOffset",-1);h(this,"queryItems",async(t,e)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),e){const o=new Set,r=e.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),i=this.items.filter(s=>{var l;return s.type==="section"?!0:s.name.toLocaleLowerCase().indexOf(r)!==-1||BB(s).toLocaleLowerCase().indexOf(r)!==-1||s.group&&((l=s.group)==null?void 0:l.toLocaleLowerCase().indexOf(r))!==-1?(o.add(s.group),!0):!1}).filter(s=>s.type==="section"?o.has(s.group):!0);return i.length||this.handleEmptySearch(),i}return this.items});h(this,"onClose",()=>{this.firstEmptyOffset=-1});h(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Wn(i)){const s=U(z(i));if(s&&it(s)==="code")return!1}return!0});h(this,"onClickItem",(t,e)=>{const o=e;o.itemType==="insert-block"&&(u(jC,o.blockOptions||o.commandProvider,"invalid quick item, no block options or command provider"),u(jC,this.suggest.anchor,"invalid suggest, no anchor"),nT(this.editor,o,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=qc(),this.suggest=new Mh(t,{id:e.id||"quick-menu",trigger:e.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const t=w1(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const o=qc();if(o!==this.maxHeading){const r=new NC,s=r.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:r}));for(let l=0;l<this.items.length;l++)this.items[l].group==="basics"&&(t||(t=l),t&&e++);t&&e&&this.items.splice(t,e,...s),this.maxHeading=o}}handleEmptySearch(){const t=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(t.isSimple()){const{offset:e}=t;this.firstEmptyOffset=e}}else if(t.isSimple()){const{offset:e}=t;e-this.firstEmptyOffset>=rT&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class B1{constructor(t){h(this,"instance");h(this,"mousedown",!1);h(this,"currentInstance",null);h(this,"attributeName","");h(this,"attributeDesc","");h(this,"observer",null);h(this,"observerCallback",null);h(this,"createContent",t=>{var i;const e=(i=t.getAttribute(this.attributeName))!=null?i:"",o=t.getAttribute(this.attributeDesc);if(!o)return e;const r=b("div",[],null);return b("span",[],r,e),o&&b("span",["editor-tooltip-desc"],r,o),r});h(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});h(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});h(this,"handleShown",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});h(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});h(this,"handleShow",t=>{var r;const e=t.reference;if(!e||!wt(document.body,e)||window.isDragging||this.mousedown)return!1;const o=Number.parseInt((r=e.getAttribute("data-tooltip-hide-at"))!=null?r:"",10);return!(o&&Date.now()-o<1e3)});this.editor=t;const e=t.clientId;this.attributeName=`data-editor-tooltip-${e}`,this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=iu.delegate(document.body,{delay:200,target:`[${this.attributeName}]`,content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}visible(){var t;return(t=this.currentInstance)==null?void 0:t.state.isVisible}hide(){var t;(t=this.currentInstance)!=null&&t.state.isVisible&&this.currentInstance.hide()}destroy(){this.destroyObserver(),this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}createObserver(){this.destroyObserver();const t=this.currentInstance;if(!t||!t.reference)return;this.observerCallback=ee.default(()=>{t.reference.closest("body")||(t.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const e=document.body,o={childList:!0,attributes:!1,subtree:!0};this.observer.observe(e,o)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}}const iT={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-strikethrough":"line-through","text/style-code":"code","text/style-subscript":"subscript","text/style-superscript":"superscript"};function sT(n,t){const e=new Set(Object.keys(iT)),o=t.filter(i=>e.has(i.id));return Uc(o)}function na(n,t){if(!n.isWritable())return!1;const e=n.selection.range,o=n.editorCommandProviders.getCommands(e),i=sT(n,o).find(s=>s.id===`text/${t}`);return i?(n.editorCommandProviders.executeCommand(e,i,{}),ii.get(n).update("selectionChange"),!0):!1}const E1={"CtrlOrCmd+B":n=>na(n,"style-bold"),"CtrlOrCmd+I":n=>na(n,"style-italic"),"CtrlOrCmd+U":n=>na(n,"style-underline"),"CtrlOrCmd+D":n=>na(n,"style-strikethrough")},lT={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u4E8B\u9879",quote:"\u5F15\u7528"},inlineBox:{math:"\u516C\u5F0F",link:"\u94FE\u63A5"}},link:{textLabel:"\u6587\u672C",urlLabel:"\u94FE\u63A5\u5730\u5740",textPlaceholder:"\u8BF7\u8F93\u5165\u6587\u672C",urlPlaceholder:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740",submitText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},commands:{unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",check:"\u5F85\u529E\u5217\u8868",link:"\u94FE\u63A5",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u5BF9\u9F50",alignRight:"\u53F3\u5BF9\u9F50",alignCenter:"\u5C45\u4E2D\u5BF9\u9F50",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u6807\u9898 {name}",headingGroup:"\u6807\u9898\u6837\u5F0F",text:"\u6B63\u6587"},commandDesc:{mac:{unordered:"\u2318+\u21E7+L",ordered:"\u2318+\u21E7+U",link:"\u2318+K"},window:{unordered:"Ctrl+Shift+L",ordered:"Ctrl+Shift+U",link:"Ctrl+K"}}},cT={quickMenu:{basic:{heading:{title:"Heading {heading}",space:"{markdown}space"},unordered:"Bulleted list",ordered:"Numbered list",checkbox:"Todo list",quote:"Quote"},inlineBox:{math:"Math",link:"Link"},link:{textLabel:"Text",urlLabel:"Link Address",textPlaceholder:"Please enter text",urlPlaceholder:"Please enter the link address",submitText:"Ok",cancelText:"Cancel"}},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"Todo list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Align center",alignGroup:"Alignment",heading:"Heading {name}",headingGroup:"Text style",text:"Text"},commandDesc:{mac:{unordered:"\u2318+\u21E7+L",ordered:"\u2318+\u21E7+U",link:"\u2318+K"},window:{unordered:"Ctrl+Shift+L",ordered:"Ctrl+Shift+U",link:"Ctrl+K"}}};x.mergeLang({"zh-CN":lT,"en-US":cT});const fV="";function mr(n,...t){const e=Bo(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function zC(n){Vc(n).hide();const e=n.getCustom("table-border-bar");e==null||e.closeToolbar()}function aT(n){return b("div",["insert-column-button","drop-marker"],n)}const uT=w("row-height");function UC(n){const t=nt.fromTable(n),e=n.rows;u(uT,e.length===t.rowCount,"row count mismatch");const o=Array(t.rowCount).fill(0);for(let r=0;r<e.length;){let i=1,l=e[r].getBoundingClientRect().height,c=r+1;for(;c<e.length;){const a=e[c];if(a.cells.length!==0)break;i++,c++,l+=a.getBoundingClientRect().height}for(let a=0;a<i;a++)o[r+a]=l/i;r=c}return o}const Mo=w("table-border-bar-dom");function li(n,t){u(Mo,Zt(t),"invalid table block");const e=jt(t),o=Sn(n,t),r=(a,d,f)=>{const m=b("div",["button-root",d],a),p=b("div",["button-container",d],m);m.setAttribute(`data-${d}-index`,`${f}`),p.setAttribute(`data-editor-tooltip-${n.clientId}`,d==="left"?x.t("table.insertRow"):x.t("table.insertCol")),b("span",["insert-indicator"],p),aT(p)},{selectedRows:i,selectedColumns:s}=Oh(n,t),l=()=>{const a=o.querySelector(".table-border-bar-container.top");u(Mo,a,"no top border bar container");const d=b("div",["table-border-bar-container","top"],null),f=b("div",["table-border-bar","top"],d),m=kE(e);b("span",["table-border-bar-cell","corner"],f);const A=nt.fromTable(e).colCount;n.selection.range.isSimple()&&r(f,"top",0);for(let k=0;k<A;k++){const v=k===A-1?m[k]+2:m[k],T=b("span",["table-border-bar-cell","top"],f);s.has(k)&&T.classList.add("selected"),T.setAttribute("data-top-index",`${k}`),T.style.width=`${v}px`,n.selection.range.isSimple()&&r(f,"top",k+1)}Hi(a,d)},c=()=>{const a=o.querySelector(".table-border-bar-container.left");u(Mo,a,"no left border bar container");const d=b("div",["table-border-bar-container","left"],null),f=b("div",["table-border-bar","left"],d),m=UC(e);n.selection.range.isSimple()&&r(f,"left",0),Array.from(e.rows).forEach((p,A,k)=>{const v=b("span",["table-border-bar-cell","left"],f);i.has(A)&&v.classList.add("selected"),v.setAttribute("data-left-index",`${A}`);const T=A===k.length-1?m[A]+2:m[A];v.style.height=`${T}px`,n.selection.range.isSimple()&&r(f,"left",A+1)}),Hi(a,d)};l(),c()}function VC(n,t){const e=t.target;if(!(e instanceof Element))return;const o=U(e);u(Mo,o&&Zt(o),"invalid table block"),li(n,o),n.selection.caret.update()}function I1(n,t){const e=t.target;if(!(e instanceof Element))return;const o=U(e);u(Mo,o&&Zt(o),"invalid table block");const r=e.closest(".button-root");if(r){if(r.classList.contains("top")){const i=parseInt(r.getAttribute("data-top-index")||"0",10);sC(n,o,i),li(n,o)}else if(r.classList.contains("left")){const i=parseInt(r.getAttribute("data-left-index")||"0",10);lC(n,o,i),li(n,o)}}}function x1(n,t){var s;zC(n),t.preventDefault(),t.stopPropagation();let e=null,o,r;const i=l=>{var c;if(l.target instanceof HTMLElement&&o&&e&&r!==void 0){const a=U(l.target),d=l.target.closest(".table-border-bar");if(a===e&&d){const f=parseInt((c=l.target.getAttribute(`data-${o}-index`))!=null?c:"0",10),m=Math.min(r,f),p=Math.abs(r-f)+1;rt(l.target,"top")&&o==="top"?NE(n,a,m,p,{reverse:!0}):rt(l.target,"left")&&o==="left"&&PE(n,a,m,p,{reverse:!0})}}l.type==="mouseup"&&(e=null,r=void 0,o=void 0,document.body.removeEventListener("mousemove",i),document.body.removeEventListener("mouseup",i))};t.target instanceof HTMLElement&&rt(t.target,"table-border-bar-cell")&&(e=U(t.target),rt(t.target,"top")?o="top":rt(t.target,"left")&&(o="left"),o&&e&&(r=parseInt((s=t.target.getAttribute(`data-${o}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",i),document.body.addEventListener("mouseup",i)))}function qC(n){const t=n.selection.range,e=Ms(n,t);e&&li(n,e)}function dT(n,t){u(Mo,Zt(t),"invalid table block");const e=Sn(n,t),o=b("div",["table-border-bar-container","top"],e),r=b("div",["table-border-bar-container","left"],e);li(n,t),n.domEvents.addEventListener(st(t),"scroll",VC),n.domEvents.addEventListener(o,"click",I1),n.domEvents.addEventListener(r,"click",I1),n.domEvents.addEventListener(o,"mousedown",x1),n.domEvents.addEventListener(r,"mousedown",x1),n.addListener("afterClearSelection",qC)}function WC(n,t){if(!n.isWritable())return;if(Sn(n,t).querySelector(".table-border-bar-container")){li(n,t);return}dT(n,t)}function GC(n,t){u(Mo,Zt(t),"invalid table block"),Sn(n,t).querySelectorAll(".table-border-bar-container").forEach(r=>{n.domEvents.removeEventListener(r,"click",I1),n.domEvents.removeEventListener(r,"mousedown",x1),r.remove()}),n.domEvents.removeEventListener(st(t),"scroll",VC),n.addListener("afterClearSelection",qC)}function hT(n,t){u(Mo,Zt(t),"invalid table block");const o=Sn(n,t).querySelector(".table-border-bar-container.top");return o?o.getBoundingClientRect().height:0}class fT{constructor(t,e){h(this,"toolbar");h(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(xo(this.editor,this.tableBlock,!0,!0),To(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(xo(this.editor,this.tableBlock,!0,!1),To(this.editor,this.tableBlock,!0,!1)):(xo(this.editor,this.tableBlock,!1),To(this.editor,this.tableBlock,!1)))});h(this,"handleClick",(t,e,o)=>{e.id==="delete-columns"?Nh(this.editor.selection.range):e.id==="delete-rows"&&Ph(this.editor.selection.range)});h(this,"handleToolbarClose",()=>{this.tableBlock&&Ms(this.editor,this.editor.selection.range)===this.tableBlock&&(xo(this.editor,this.tableBlock,!1),To(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const o=t.options.componentsOptions.popover;this.toolbar=new Ss([],void 0,{overflowBoundary:o==null?void 0:o.overflowBoundary,refuseOverflow:!0,tooltipId:this.editor.clientId}),this.toolbar.addListener("selectionChange",this.handleSelectionChange),this.toolbar.addListener("click",this.handleClick),this.toolbar.addListener("close",this.handleToolbarClose)}close(){this.toolbar.close()}update(){const{selectedColumns:t,selectedRows:e}=Oh(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close();return}if(t.size===0&&e.size===0){this.toolbar.close();return}const o=co(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!o){this.toolbar.close();return}if(t.size>0){const r={id:"delete-columns",name:x.t("table.deleteCol"),icon:ww};this.toolbar.updateItems([r]);const i=fo(this.editor,this.tableBlock,"table-row-column-delete",o);this.toolbar.manualShow(i,{placement:"top"})}else{const r={id:"delete-rows",name:x.t("table.deleteRow"),icon:kw};this.toolbar.updateItems([r]);const i=new DOMRect(o.left-15,o.top,o.width,o.height),s=fo(this.editor,this.tableBlock,"table-row-column-delete",i);this.toolbar.manualShow(s,{placement:"left"})}}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const T1=w("table-border-bar");class mT{constructor(t,e){h(this,"toolbar");h(this,"resizeObserver");h(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():GC(this.editor,this.tableBlock)});h(this,"handleBlockUpdated",()=>{this.resizeObserver.disconnect(),setTimeout(()=>{const t=this.editor.getBlockById(j(this.tableBlock));this.resizeObserver.observe(jt(t))})});h(this,"handleTableResize",()=>{!this.editor.isWritable()||(console.log("resize"),this.update())});this.editor=t,this.tableBlock=e,u(T1,this.tableBlock,"no table block"),T1.debug("create table border bar"),WC(this.editor,this.tableBlock),this.resizeObserver=new ResizeObserver(this.handleTableResize),this.resizeObserver.observe(jt(this.tableBlock)),this.toolbar=new fT(this.editor,this.tableBlock),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){this.toolbar.close()}destroy(){T1.debug("destroy table border bar"),this.resizeObserver.disconnect(),GC(this.editor,this.tableBlock),this.toolbar.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){WC(this.editor,this.tableBlock),this.toolbar.update()}}const gT=w("table-border-bar");class pT{constructor(t){h(this,"activeTableBar",null);h(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||wt(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});h(this,"handleSelectionChanged",t=>{var r;const e=t.selection.range,o=Ms(t,e);((r=this.activeTableBar)==null?void 0:r.tableBlock)!==o&&this.activeTableBar&&this.hide(),o&&this.show(o)});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new mT(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(u(gT,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function ZC(n,t){const e=n.addCustom("table-border-bar",o=>new pT(o));t==="update"&&e.update()}const Be=w("table-cell-menu"),CT="style-bg-color-";class AT{constructor(t){h(this,"activeTableBlock",null);h(this,"targetButton",null);h(this,"manualMenu",null);h(this,"colorPaletteItem",null);h(this,"handlePrevent",(t,e)=>{e.stopPropagation()});h(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});h(this,"handleSelectionChanged",t=>{const e=t.selection.range,o=Ms(t,e);if(this.hide(),this.activeTableBlock!==o&&(this.activeTableBlock=o),this.activeTableBlock){const r=nt.fromBlock(this.activeTableBlock),i=e.isReverse()?e.start:e.end;let s=null;e.isCollapsed()?s=this.getCellByChildBlockId(r,i.blockId):i instanceof Xe&&(t.getBlockById(i.blockId)===this.activeTableBlock?s=r.getCellByContainerId(i.childContainerId):s=this.getCellByChildBlockId(r,i.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});h(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});h(this,"createBkgColorItem",()=>{const t=b("div",["cell-background-color-item"],null);b("span",[],t,x.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();b("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const r=b("span",["item-sub-indicator"],t);return r.innerHTML=A5,t});h(this,"handleCommand",t=>{var r;u(Be,this.activeTableBlock,"no target table block");const e=((r=t.states)==null?void 0:r.includes("checked"))||!1,o=t.value;switch(t.id){case"delete-select-row":Ph(j5(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":Nh(j5(this.editor,this.activeTableBlock,!0));break;case"merge-cell":_5(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(e);break;case"col-title":this.handleColTitle(e);break;case"stripe-style":this.handleStripeStyle(e);break;case"hide-border":VB(this.editor,this.activeTableBlock,o==="show-border");break;case"show-chart":QB(this.editor,this.activeTableBlock,o==="show-chart"),Gh(this.editor,this.activeTableBlock,{updateNow:!0});break}});h(this,"handleToolbarClose",()=>{this.targetButton&&H(this.targetButton,"active"),this.activeTableBlock&&Ms(this.editor,this.editor.selection.range)===this.activeTableBlock&&(xo(this.editor,this.activeTableBlock,!1),To(this.editor,this.activeTableBlock,!1)),this.editor.focus()});h(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(u(Be,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(xo(this.editor,this.activeTableBlock,!0,!1),To(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(xo(this.editor,this.activeTableBlock,!0,!0),To(this.editor,this.activeTableBlock,!0,!0)):(xo(this.editor,this.activeTableBlock,!1),To(this.editor,this.activeTableBlock,!1)))});h(this,"handleClick",()=>{var t;u(Be,this.activeTableBlock,"no target table block"),u(Be,this.targetButton,"no target button"),zC(this.editor),rt(this.targetButton,"active")?(H(this.targetButton,"active"),(t=this.manualMenu)==null||t.close()):(M(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new cr(this.createCommandMenu()),this.manualMenu.on("click",(e,o)=>{var r;this.handleCommand(o),(r=this.manualMenu)==null||r.close()}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",this.handleToolbarClose)),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"}))});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var t,e;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(t=this.manualMenu)==null||t.destroy(),(e=this.colorPaletteItem)==null||e.destroy()}hide(){var t;(t=this.manualMenu)==null||t.close(),this.targetButton&&(H(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let o=this.editor.getBlockById(e);for(;o;){const r=o.closest("td");u(Be,r,"no parent cell");const i=U(r);if(u(Be,i,"no parent block"),jt(i)===t.table)return t.getCellByCellElement(r);o=i}return u(Be,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${Uh}`)||t.appendChild(this.targetButton):(this.targetButton=b("button",[Uh],t),this.targetButton.innerHTML=ph,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent))}showCellMenuButton(t){this.createTargetButton(t.cell),u(Be,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=nt.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:o,row:r}=this.getCellByChildBlockId(t,e.start.blockId);_h(this.editor,this.activeTableBlock,{col:o,row:r})}else Fh(this.editor.selection.range)}}getSelectedBkgColorIndex(){var r;u(Be,this.activeTableBlock,"no target table block");const t=GB(this.editor,this.activeTableBlock),e=this.editor.getBlockData(this.activeTableBlock),o=new Set;for(const i of t){if(o.size>1)break;const s=V(i),l=e[`${s}_background`];if(l)o.add(Number.parseInt((r=l.substring(CT.length))!=null?r:"0",10));else{o.add(-1);break}}return o.size===1&&[...o][0]!==-1?[...o][0]:-1}createCommandMenu(){u(Be,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=$5(this.editor,this.activeTableBlock,this.editor.selection.range);let o=this.editor.selection.range;if(o.isSimple()){const d=Yn(this.editor,this.activeTableBlock,o.start);o=Wt(this.editor,{anchor:d,focus:d})}const r=P5(this.editor,this.activeTableBlock,o),i=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,a=t.chart;return this.colorPaletteItem=new D5("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(d,f)=>{var m;switch(u(Be,this.activeTableBlock,"no target table block"),d){case"clearColor":V5(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":V5(this.editor,this.activeTableBlock,f);break}(m=this.manualMenu)==null||m.close()}),[{id:"cell-background-color",name:x.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:x.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:x.t("table.splitCell"),states:r?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:x.t("table.deleteSelectRow")},{id:"delete-select-col",name:x.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:x.t("table.tableConfigKey"),children:[{id:"row-title",name:x.t("table.tableConfig.rowTitle"),states:i?["checked"]:[]},{id:"col-title",name:x.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:x.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?x.t("table.tableConfig.showBorder"):x.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:a?x.t("table.tableConfig.hideChart"):x.t("table.tableConfig.showChart"),value:a?"hide-chart":"show-chart"}]}]}handleRowTitle(t){u(Be,this.activeTableBlock,"no target table block"),t?jB(this.editor,this.activeTableBlock):HB(this.editor,this.activeTableBlock)}handleColTitle(t){u(Be,this.activeTableBlock,"no target table block"),t?FB(this.editor,this.activeTableBlock):_B(this.editor,this.activeTableBlock)}handleStripeStyle(t){u(Be,this.activeTableBlock,"no target table block"),t?UB(this.editor,this.activeTableBlock):zB(this.editor,this.activeTableBlock)}}function QC(n){n.addCustom("table-cell-menu",t=>new AT(t))}const oa=w("table-container");function S1(n){const t=n.closest("td");return u(oa,t,"no parent cell for a table cell container"),t}function YC(n){const t=jt(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function D1(n,t,e,o){const r=nt.fromBlock(n),i=r.getCellByContainerId(V(t));if(e==="ArrowDown"){const s=r.getBottomCell(i);return s?s.container:null}if(e==="ArrowUp"){const s=r.getTopCell(i);return s?s.container:null}if(e==="ArrowLeft"){const s=r.getAllContainers(),l=s.indexOf(t);if(u(oa,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return o!=null&&o.noWrap&&r.getCellByContainerId(V(c)).row!==i.row?null:c}if(e==="ArrowRight"){const s=r.getAllContainers(),l=s.indexOf(t);if(u(oa,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return o!=null&&o.noWrap&&r.getCellByContainerId(V(c)).row!==i.row?null:c}u(oa,!1,`invalid navigation type: ${e}`)}const bT=12,vT=90,ra=23,JC=2;class yT{constructor(t){h(this,"scrollTableBlock",null);h(this,"autoScrollDir",null);h(this,"autoScrollTimer",null);h(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const o=U(e);if(o&&wt(this.editor.rootContainer,o)){const r=Qn(o);r&&(this.scrollTableBlock=r,document.addEventListener("mousemove",this.handleAutoScroll))}}});h(this,"handleAutoScroll",l8.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(Io(this.scrollTableBlock)),o=e.rootElement,r=e.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=window.innerHeight-(e.scrollOptions.barFloatWindowBottom||0),l=r.getBoundingClientRect(),c=Math.min(l.bottom,s),a=Math.max(l.top,0);i.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):i.top<a&&t.clientY<=a?this.setAutoScroll("top"):o.scrollLeft>0&&t.clientX<i.left?this.setAutoScroll("left"):o.scrollLeft<o.scrollWidth-o.offsetWidth&&t.clientX>i.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));h(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});h(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const o=t.getBlockById(e.start.blockId),r=Qn(o);if(r){const i=t.getCustom(Io(r)),s=i.rootElement.getBoundingClientRect(),l=Ye(t,o,e.start);if(s.left>l.left){const c=e.start.offset===0?bT:JC;i.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?vT:JC;i.rootElement.scrollLeft+=l.right-s.right+c}}}else{const o=t.getBlockById(e.start.blockId),r=Qn(o),i=t.getBlockById(e.end.blockId),s=Qn(i);if(r&&r===s){const l=t.getCustom(Io(r)),c=l.rootElement.getBoundingClientRect();let a=null;if(e.isSimple())a=e.isReverse()?Ye(t,o,e.start):Ye(t,i,e.end);else{const d=S1(Pr(t,e.start.childContainerId)),f=S1(Pr(t,e.end.childContainerId));a=e.isReverse()?d.getBoundingClientRect():f.getBoundingClientRect()}c.left>a.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-a.left:c.right<a.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=a.right-c.right)}}});h(this,"handleScroll",t=>{R5(t),this.editor.selection.caret.update()});h(this,"handleReset",t=>{R5(t),this.editor.selection.caret.update()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}clearAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null,this.autoScrollDir=null)}setAutoScroll(t){this.autoScrollDir&&this.autoScrollDir!==t&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=t,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const e=this.editor.getCustom(Io(this.scrollTableBlock)),o=e.rootElement,r=e.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=r===document.documentElement?window.innerHeight:r.offsetHeight,l=window.innerHeight-(e.scrollOptions.barFloatWindowBottom||0),c=r.getBoundingClientRect(),a=Math.min(c.bottom,l),d=Math.max(c.top,0);this.autoScrollDir==="left"&&(o.scrollLeft-=ra,o.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(o.scrollLeft+=ra,o.scrollLeft>=o.scrollWidth-o.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(r.scrollTop+=ra,(r.scrollTop>=r.scrollHeight-s||i.bottom<=a)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(r.scrollTop-=ra,(r.scrollTop<=0||i.top>=d)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function KC(n){return n.addCustom("table-scroll-events",t=>new yT(t))}const Dn=w("create-content");function XC(n,t,e){const o=new Mc(e),r=e.rows,i=e.cols;u(Dn,r>=1,`invalid rows: ${r}`),u(Dn,i>=1,`invalid cols: ${i}`),u(Dn,e.children,"no table children");const s=b("table",[],null),l=e.colsWidth,c=b("colgroup",[],s);for(let f=0;f<o.colCount;f++){const m=b("col",[],c);m.style.width=`${l[f]||jc}px`}const a=b("tbody",[],s);let d=0;for(let f=0;f<r;f++){const m=b("tr",[],a);for(let p=0;p<i;p++){const A=o.getCell({col:p,row:f});if(A.virtual)u(Dn,A.colSpan>1||A.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const k=e.children[d],v=b("td",[],m);A.colSpan>1&&(v.colSpan=A.colSpan),A.rowSpan>1&&(v.rowSpan=A.rowSpan);const T=e[Ns(k)];T&&M(v,T),p===0&&e.hasColTitle&&M(v,F5.COL_TITLE_ITEM),n.createChildContainer(t,v,k),d+=1}}}return u(Dn,d===e.children.length,"container count mismatch"),e.noBorder&&M(s,"no-border"),e.chart&&M(s,"editor-table-chart"),e.isStripeStyle&&M(s,"stripe"),e.hasRowTitle&&M(s,"row-title"),e.hasColTitle&&M(s,"col-title"),s}function kT(n,t,e,o,r){u(Dn,r.type==="table","not table data"),u(Dn,V(e)===t[t.length-1].containerId,"invalid path");const i=r,s=lo(o,"div");try{const l=b("div",[],null);l.setAttribute("data-type","table-content");const c=XC(n,t,i);c.classList.add("drag-preview-element"),l.appendChild(c),rC(n),aC(n),ZC(n,"create"),QC(n),uw(n,Zh);const a=n.getComponentOptions("table"),d=n.addCustom(Io(o),()=>bE());d.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Ct(e)?n.scrollContainer:e,locatingContainer:Ct(e)?(a==null?void 0:a.locatingContainer)||n.parent:e,paddingLeft:zh+Os,paddingTop:zh+Os,paddingBottom:Os/2,paddingRight:Os/2,barFloatWindowBottom:a==null?void 0:a.barFloatWindowBottom,isSetScale:a==null?void 0:a.isSetScale});const f=KC(n);d.on("scroll",f.handleReset),d.on("resize",f.handleReset),setTimeout(()=>{KB(n,o)})}catch{const c=`invalid table data: ${JSON.stringify(i)}`;Dn.error(c);const a=b("div",["error"],s);a.innerText=c}return s}function wT(n,t,e){u(Dn,e.type==="table","not table data");const o=e,r=st(t);try{const i=jt(t),s=ao(t),l=XC(n,s,o);l.classList.add("drag-preview-element"),i.insertAdjacentElement("afterend",l),i.remove(),rC(n),aC(n),ZC(n,"update"),QC(n),Zh(n,t)}catch{const s=`invalid table data: ${JSON.stringify(o)}`;Dn.error(s);const l=b("div",["error"],r);l.innerText=s}}function BT(n,t){let e,o,r=!1;if([...t].every(m=>m==="|")?(o=t.length,e=Array(o).fill(""),r=!0):(e=Au(t,"|").split("|"),o=e.length),o<2)return null;const i=3,s=o,l=[];for(let m=0;m<3;m++)e.forEach(p=>{l.push(Bn(n.doc,m===0?p:""))});const c=Array(s).fill(jc),a=l[r?0:s],d=n.doc.getContainerBlocks(a)[0].id;return{blockData:{id:P(),type:"table",rows:i,cols:s,children:l,colsWidth:c},focusBlockId:d}}function ET(n,t){const e=t.rows,o=t.cols;if(e<1||o<1)return null;const r=[];for(let a=0;a<e;a++)for(let d=0;d<o;d++)r.push(Bn(n.doc));const i=Array(o).fill(jc),s=r[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:P(),type:"table",rows:e,cols:o,children:r,colsWidth:i},focusBlockId:l}}const t4=w("table-selection-to-doc");function IT(n,t){const{start:e,end:o,block:r}=t,i=it(r);u(t4,i==="table",`invalid block type: ${i}`);const s=n.getBlockData(r);if(e.isSimple()&&o.isSimple())return bo(n.editorBlocks,n.doc.toJSON(),s);u(t4,!e.isSimple()&&!o.isSimple(),"invalid block pos type");const l=nt.fromBlock(r),{fromCol:c,toCol:a,fromRow:d,toRow:f}=dn(r,e,o),m={},p=[],A=n.doc.toJSON();let k={};l.sub({row:d,col:c},{row:f,col:a}).forEach((q,ot)=>{q.forEach((lt,gt)=>{const ht=lt.containerId;if(p.indexOf(ht)!==-1)return;p.push(ht);let kt;if(lt.virtual){const re=l.getCellByContainerId(lt.containerId),qe=c+gt;let $o=re.col+re.colSpan-1;$o>a&&($o=a);const kr=$o-qe+1;kr>1&&(m[`${ht}_colSpan`]=kr);const wr=d+ot;let _o=re.row+re.rowSpan-1;_o>f&&(_o=f);const Na=_o-wr+1;Na>1&&(m[`${ht}_rowSpan`]=Na),kt=or()}else{if(kt=Md(n.editorBlocks,A,ht),lt.col+lt.colSpan>a+1){const re=a-lt.col+1;re>1&&(m[`${ht}_colSpan`]=re)}else lt.colSpan>1&&(m[`${ht}_colSpan`]=lt.colSpan);if(lt.row+lt.rowSpan>f+1){const re=f-lt.row+1;re>1&&(m[`${ht}_rowSpan`]=re)}else lt.rowSpan>1&&(m[`${ht}_rowSpan`]=lt.rowSpan)}const{root:de,...oo}=kt.blocks;k={...k,...oo,[ht]:de}})});const T=Fs(jt(r)).slice(c,a+1);return{blocks:{root:[{id:P(),type:i,children:p,colsWidth:T,rows:f-d+1,cols:a-c+1,...m}],...k},meta:{},comments:{}}}function xT(n,t){if(t.top===0)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.top-1][e]===n[t.top][e])return!1;return!0}function TT(n,t){if(t.left===0)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.left-1]===n[e][t.left])return!1;return!0}function ST(n,t){if(t.bottom===n.length-1)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.bottom][e]===n[t.bottom+1][e])return!1;return!0}function DT(n,t){if(t.right===n[0].length-1)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.right]===n[e][t.right+1])return!1;return!0}function LT(n,t,e){const o=t.col,r=t.row,i=e.col,s=e.row,l={left:o,top:r,right:i,bottom:s};let c=!1;do{if(c=!1,!xT(n,l)){l.top--,c=!0;continue}if(!TT(n,l)){l.left--,c=!0;continue}if(!ST(n,l)){l.bottom++,c=!0;continue}if(!DT(n,l)){l.right++,c=!0;continue}}while(c);return l}function MT(n,t,e,o){if(e.custom!==void 0||o.custom!==void 0)return{anchor:e,focus:o};const r=nt.fromBlock(t),i=r.map(L=>L.containerId),s=r.getCellByContainerId(e.childContainerId),l=r.getCellByContainerId(o.childContainerId),c=Math.min(s.row,l.row),a=Math.max(s.row,l.row),d=Math.min(s.col,l.col),f=Math.max(s.col,l.col),m=LT(i,{row:c,col:d},{row:a,col:f}),p=r.getCell({row:m.top,col:m.left}),A=r.getCell({row:m.bottom,col:m.right}),k=r.getCell({row:m.top,col:m.right}),v=r.getCell({row:m.bottom,col:m.left});let T,E;return s.row<=l.row?s.col<=l.col?(T=p,E=A):(T=k,E=v):s.col<l.col?(T=v,E=k):(T=A,E=p),console.log(`move ${T.col}, ${T.row}, -> ${E.col}, ${E.row}`),{anchor:Bt(t,T.containerId),focus:Bt(t,E.containerId)}}function e4(n,t,e){if(e.isSimple())return[jt(t).getBoundingClientRect()];const o=jt(t),r=o.getBoundingClientRect(),{fromCol:i,fromRow:s,toCol:l,toRow:c}=dn(t,e.start,e.end),a=Fs(o),d=a.slice(0,i).reduce((k,v)=>k+v,0),f=d+a.slice(i,l+1).reduce((k,v)=>k+v,0),m=UC(o);let p=m.slice(0,s).reduce((k,v)=>k+v,0);const A=p+m.slice(s,c+1).reduce((k,v)=>k+v,0);if(s===0){const k=hT(n,t);p-=k}return[new DOMRect(r.left+d,r.top+p,f-d,A-p)]}w("table-size");const RT=40;function ia(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),o=Number.parseInt(e.borderLeft,10),r=Number.parseInt(e.borderRight,10);return(o+r)/2}function OT(n,t,e){const o=gd(n,e.container);return o!==void 0?o+ia(t):RT*e.colSpan-ia(t)}function NT(n,t,e,o){let r=0;const i=e.colCount;for(let s=0;s<i;s++){const l=e.getRealCell({col:s,row:o});if(l.virtual)continue;let c=OT(n,t,l);const a=Tp(l.container,{withPadding:!0});a&&a>c&&(c=a),r+=c+ia(t)}return r}function PT(n,t){const e=jt(t),o=nt.fromTable(e);let r=0;for(let s=0;s<o.rowCount;s++)r=Math.max(r,NT(n,e,o,s));const i=ia(e);return r+=i,r}const Jn=w("table-creator");async function $T(n,t){return n.undoManager.runInGroup(()=>{var c,a;const e=t.item,o=(c=e.colCount)!=null?c:5,r=(a=e.rowCount)!=null?a:3,i=ET(n,{cols:o,rows:r});if(!i)return null;const{blockData:s,focusBlockId:l}=i;return n.insertBlock(t.containerId,t.blockIndex,s,Ot(n,l,0))})}class _T{constructor(){h(this,"id","insert-table");h(this,"name","Create table");h(this,"element");h(this,"closeable",null);h(this,"colCount");h(this,"rowCount");h(this,"setCloseable",t=>{this.closeable=t});h(this,"destroy",()=>{this.closeable=null});h(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);h(this,"handleTableCreatorClick",t=>{var m,p;t.preventDefault(),t.stopPropagation();const e=t.target;u(Jn,e instanceof HTMLElement,"invalid event target");const o=e.closest(".table-creator");u(Jn,o,"no table creator");const r=o.querySelectorAll(".active");if(r.length===0)return;const s=r[r.length-1].id;u(Jn,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const a=s.substring(l.length).split("-");u(Jn,a.length===2,"invalid cell id");const d=Number.parseInt(a[0],10)+1,f=Number.parseInt(a[1],10)+1;Jn.debug(`${d}, ${f}`),this.colCount=f,this.rowCount=d,(m=this.closeable)==null||m.click(this,this.element),(p=this.closeable)==null||p.close(),this.handleTableCreatorLeave()});h(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const o=this.getTableCreatorCellId(t,e),r=document.getElementById(o);r&&H(r,"active")}});h(this,"handleTableCreatorCellEnter",t=>{const e=t.target;u(Jn,e instanceof HTMLElement,"invalid event target");const o=e.id,r="table-creator-cell-";u(Jn,o.startsWith(r),"invalid cell id");const s=o.substring(r.length).split("-");u(Jn,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let a=0;a<9;a++)for(let d=0;d<9;d++){const f=this.getTableCreatorCellId(a,d),m=document.getElementById(f);u(Jn,m,"no cell"),a<=l&&d<=c?M(m,"active"):H(m,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=b("div",["table-creator"],null),e=(o,r,i)=>{const s=b("div",["table-creator-cell"],o);return s.id=this.getTableCreatorCellId(r,i),s};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let o=0;o<9;o++){const r=b("div",["table-creator-row"],t);for(let i=0;i<9;i++)e(r,o,i).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function FT(){return new _T}function HT(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function n4(n){const t=HT(n);return n.length+t}function jT(n,t){const e=n4(n),o=t-e;return o>0?n+" ".repeat(o):n}function zT(n,t,e,o,r){const i=t,s=new Mc(i);if(o==="markdown"||o==="text"){const l=v=>e.blocks[v].map((L,R)=>o==="markdown"?kd(n,L,e,[...r,{containerId:v,blockIndex:R}]):lc(n,L,e,[...r,{containerId:v,blockIndex:R}])),c=v=>l(v).join(" ").replace(/\n/g," ").trim(),a=new Map,d=new Map;for(let v=0;v<s.colCount;v++){let T=0;for(let E=0;E<s.rowCount;E++){const L=s.getCell({row:E,col:v});let R="";L.virtual||(R=c(L.containerId)),a.set(`${E},${v}`,R),T=Math.max(T,n4(R))}d.set(v,T)}const f=v=>{const T=a.get(`${v.row},${v.col}`)||"",E=d.get(v.col)||0;return jT(T,E)},m=[];let p="|",A="|";for(let v=0;v<s.colCount;v++){const T=f({row:0,col:v});p+=` ${T} |`;const E="-".repeat((d.get(v)||0)+2);A+=`${E}|`}m.push(p),m.push(A);for(let v=1;v<s.rowCount;v++){let T="|";for(let E=0;E<s.colCount;E++){const L=f({row:v,col:E});T+=` ${L} |`}m.push(T)}return`${m.join(`
|
|
370
|
+
`:r.mathjaxText}const k1={embedType:"math",createEmbedContent:Hx,getOptions:zx,convertFrom:jx,handleDeleteBlock:Ux,convertTo:Vx},hV="",qx={mathjax:{emptyText:"\u7A7A\u7684\u516C\u5F0F",abstract:"\u516C\u5F0F"}},Wx={mathjax:{emptyText:"Empty Tex",abstract:"TeX"}};T.mergeLang({"zh-CN":qx,"en-US":Wx});function Gx(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=ve(i,o);if(!vt(s).endsWith("$$$$"))return!1;const c=o-4,a=o,d={id:P(),box:!0,type:"math",tex:" ",src:"",created:Date.now()};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,c,a-c),n.insertBoxToBlock(r,c,d),setTimeout(()=>{const f=n.getBoxById(d.id);Xc(n,f)})}),!0}class Zx{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&Gx(t,e,o,r))}}const si=w("inline-box-items");function Qx(n,t,e){return n.undoManager.runInGroup(()=>{var s;let o=n.getBlockByIndex(t,e);Tt(n,o)||(o=n.insertTextBlock([],t,e));const r=HC();n.setBlockText(o,[r]);const i=(s=r.attributes)==null?void 0:s.id;return u(si,i,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(i);Xc(n,l)},100),o})}function Yx(n,t,e){let o=n.getBlockByIndex(t,e),r="bottom-start";return Tt(n,o)||(r="top-start"),Hs(n,{target:o,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{Tt(n,o)||(o=n.insertTextBlock([],t,e));const a=_e(l,{link:c}),d=_e(" ",null),f=[a,d];n.insertTextToBlock(o,0,f),n.selection.selectBlock(o,me(f)),n.focus()}catch(a){si.error(a)}})},onClose:()=>{n.focus()},placement:r}),o}function Jx(n,t,e){return n.undoManager.runInGroup(()=>{var l;const o=n.getBlockByIndex(t,e),r=n.selection.range;u(si,uo(r.start),"invalid block position");const i=HC();n.insertBoxToBlock(o,r.start.offset,i.attributes);const s=(l=i.attributes)==null?void 0:l.id;return u(si,s,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(s);Xc(n,c)},100),o})}function Kx(n,t,e){const o=n.getBlockByIndex(t,e),r=n.selection.range;u(si,uo(r.start),"invalid block position");const i=co(n,o,r);if(i.length===0)return;const s=i[0],l=fo(n,o,"quick-menu-inline-link",s);Hs(n,{target:l,linkText:"",linkUrl:"",onFinished:(d,f)=>{n.undoManager.runInGroup(()=>{try{const m=n.getBlockText(o),p=po(m,r.start.offset,d,{link:f});n.setBlockText(o,p),n.selection.selectBlock(o,r.start.offset+d.length),n.focus()}catch(m){si.error(m)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class Xx{getCommands(){return[{id:"insert-math",name:T.t("quickMenu.inlineBox.math"),icon:Pw,order:900,group:"common",subText:Ce("insert-math")},{id:"insert-link",name:T.t("quickMenu.inlineBox.link"),icon:k5,order:400,group:"common",subText:Ce("insert-link")}]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return Jx(t,e.containerId,e.blockIndex);case"insert-link":return Kx(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return Qx(t,e.containerId,e.blockIndex);case"insert-link":return Yx(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,o){if(o.from==="quick-menu"){const r=t.getBlockById(o.blockId),i=t.getParentContainer(r),s=V(i),l=t.getBlockIndex(r);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else o.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:o.containerId,blockIndex:o.blockIndex}));return null}}function tT(n){var o,r;const t=(r=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:r.commandProviders;if(!t)return[];const e=[];return[...t,new NC,new Xx].forEach(i=>{const s=i.getCommands(n);e.push(...s.map(l=>({...l,itemType:"insert-block",commandProvider:i})))}),e}function eT(n){const t=[];return n.editorBlocks.forEach(e=>{if(!e.getOptions)return;const o=e.getOptions(n);!o.insertBlockCommandItems||(o.insertBlockCommandItems.forEach(r=>{OC(r,o)}),t.push(...o.insertBlockCommandItems))}),t.push(...tT(n)),t}function w1(n){const t=eT(n),e=new Map;t.forEach(i=>{var c;const s=(c=i.group)!=null?c:"";let l=e.get(s);l?l.items.push(i):(l={group:s,order:i.groupOrder||Ix[s]||1e3,items:[i]},e.set(s,l))});const o=Array.from(e.values());o.sort((i,s)=>i.order-s.order),o.forEach(i=>{i.items.sort((s,l)=>{var c,a;return((c=s.order)!=null?c:0)-((a=l.order)!=null?a:0)})});const r=[];return o.forEach((i,s)=>{const l=T.t(`blockMenu.section.${i.group||"common"}`),c=l===i.group?i.group:l;r.push({id:`section-${s}`,name:c,type:"section",group:i.group,itemType:"insert-block"}),r.push(...i.items.map(a=>({...a})))}),r}function nT(n,t,e){const o=n.getFocusedBlock();if(!o)return;const r=n.getParentContainer(o),i=V(r);let l=n.getBlockIndex(o);if(Tt(n,o)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:i,blockIndex:l,item:t})}const jC=w("quick-menu"),oT={id:"quick-menu",trigger:["/"]},rT=3;class ea{constructor(t,e=oT){h(this,"suggest");h(this,"items");h(this,"maxHeading");h(this,"firstEmptyOffset",-1);h(this,"queryItems",async(t,e)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),e){const o=new Set,r=e.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),i=this.items.filter(s=>{var l;return s.type==="section"?!0:s.name.toLocaleLowerCase().indexOf(r)!==-1||BB(s).toLocaleLowerCase().indexOf(r)!==-1||s.group&&((l=s.group)==null?void 0:l.toLocaleLowerCase().indexOf(r))!==-1?(o.add(s.group),!0):!1}).filter(s=>s.type==="section"?o.has(s.group):!0);return i.length||this.handleEmptySearch(),i}return this.items});h(this,"onClose",()=>{this.firstEmptyOffset=-1});h(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Wn(i)){const s=U(z(i));if(s&&it(s)==="code")return!1}return!0});h(this,"onClickItem",(t,e)=>{const o=e;o.itemType==="insert-block"&&(u(jC,o.blockOptions||o.commandProvider,"invalid quick item, no block options or command provider"),u(jC,this.suggest.anchor,"invalid suggest, no anchor"),nT(this.editor,o,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=qc(),this.suggest=new Mh(t,{id:e.id||"quick-menu",trigger:e.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const t=w1(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const o=qc();if(o!==this.maxHeading){const r=new NC,s=r.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:r}));for(let l=0;l<this.items.length;l++)this.items[l].group==="basics"&&(t||(t=l),t&&e++);t&&e&&this.items.splice(t,e,...s),this.maxHeading=o}}handleEmptySearch(){const t=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(t.isSimple()){const{offset:e}=t;this.firstEmptyOffset=e}}else if(t.isSimple()){const{offset:e}=t;e-this.firstEmptyOffset>=rT&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class B1{constructor(t){h(this,"instance");h(this,"mousedown",!1);h(this,"currentInstance",null);h(this,"attributeName","");h(this,"attributeDesc","");h(this,"observer",null);h(this,"observerCallback",null);h(this,"createContent",t=>{var i;const e=(i=t.getAttribute(this.attributeName))!=null?i:"",o=t.getAttribute(this.attributeDesc);if(!o)return e;const r=b("div",[],null);return b("span",[],r,e),o&&b("span",["editor-tooltip-desc"],r,o),r});h(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});h(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});h(this,"handleShown",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});h(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});h(this,"handleShow",t=>{var r;const e=t.reference;if(!e||!wt(document.body,e)||window.isDragging||this.mousedown)return!1;const o=Number.parseInt((r=e.getAttribute("data-tooltip-hide-at"))!=null?r:"",10);return!(o&&Date.now()-o<1e3)});this.editor=t;const e=t.clientId;this.attributeName=`data-editor-tooltip-${e}`,this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=iu.delegate(document.body,{delay:200,target:`[${this.attributeName}]`,content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}visible(){var t;return(t=this.currentInstance)==null?void 0:t.state.isVisible}hide(){var t;(t=this.currentInstance)!=null&&t.state.isVisible&&this.currentInstance.hide()}destroy(){this.destroyObserver(),this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}createObserver(){this.destroyObserver();const t=this.currentInstance;if(!t||!t.reference)return;this.observerCallback=ee.default(()=>{t.reference.closest("body")||(t.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const e=document.body,o={childList:!0,attributes:!1,subtree:!0};this.observer.observe(e,o)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}}const iT={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-strikethrough":"line-through","text/style-code":"code","text/style-subscript":"subscript","text/style-superscript":"superscript"};function sT(n,t){const e=new Set(Object.keys(iT)),o=t.filter(i=>e.has(i.id));return Uc(o)}function na(n,t){if(!n.isWritable())return!1;const e=n.selection.range,o=n.editorCommandProviders.getCommands(e),i=sT(n,o).find(s=>s.id===`text/${t}`);return i?(n.editorCommandProviders.executeCommand(e,i,{}),ii.get(n).update("selectionChange"),!0):!1}const E1={"CtrlOrCmd+B":n=>na(n,"style-bold"),"CtrlOrCmd+I":n=>na(n,"style-italic"),"CtrlOrCmd+U":n=>na(n,"style-underline"),"CtrlOrCmd+D":n=>na(n,"style-strikethrough")},lT={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u4E8B\u9879",quote:"\u5F15\u7528"},inlineBox:{math:"\u516C\u5F0F",link:"\u94FE\u63A5"}},link:{textLabel:"\u6587\u672C",urlLabel:"\u94FE\u63A5\u5730\u5740",textPlaceholder:"\u8BF7\u8F93\u5165\u6587\u672C",urlPlaceholder:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740",submitText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},commands:{unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",check:"\u5F85\u529E\u5217\u8868",link:"\u94FE\u63A5",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u5BF9\u9F50",alignRight:"\u53F3\u5BF9\u9F50",alignCenter:"\u5C45\u4E2D\u5BF9\u9F50",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u6807\u9898 {name}",headingGroup:"\u6807\u9898\u6837\u5F0F",text:"\u6B63\u6587"},commandDesc:{mac:{unordered:"\u2318+\u21E7+L",ordered:"\u2318+\u21E7+U",link:"\u2318+K"},window:{unordered:"Ctrl+Shift+L",ordered:"Ctrl+Shift+U",link:"Ctrl+K"}}},cT={quickMenu:{basic:{heading:{title:"Heading {heading}",space:"{markdown}space"},unordered:"Bulleted list",ordered:"Numbered list",checkbox:"Todo list",quote:"Quote"},inlineBox:{math:"Math",link:"Link"},link:{textLabel:"Text",urlLabel:"Link Address",textPlaceholder:"Please enter text",urlPlaceholder:"Please enter the link address",submitText:"Ok",cancelText:"Cancel"}},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"Todo list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Align center",alignGroup:"Alignment",heading:"Heading {name}",headingGroup:"Text style",text:"Text"},commandDesc:{mac:{unordered:"\u2318+\u21E7+L",ordered:"\u2318+\u21E7+U",link:"\u2318+K"},window:{unordered:"Ctrl+Shift+L",ordered:"Ctrl+Shift+U",link:"Ctrl+K"}}};T.mergeLang({"zh-CN":lT,"en-US":cT});const fV="";function mr(n,...t){const e=Bo(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function zC(n){Vc(n).hide();const e=n.getCustom("table-border-bar");e==null||e.closeToolbar()}function aT(n){return b("div",["insert-column-button","drop-marker"],n)}const uT=w("row-height");function UC(n){const t=nt.fromTable(n),e=n.rows;u(uT,e.length===t.rowCount,"row count mismatch");const o=Array(t.rowCount).fill(0);for(let r=0;r<e.length;){let i=1,l=e[r].getBoundingClientRect().height,c=r+1;for(;c<e.length;){const a=e[c];if(a.cells.length!==0)break;i++,c++,l+=a.getBoundingClientRect().height}for(let a=0;a<i;a++)o[r+a]=l/i;r=c}return o}const Mo=w("table-border-bar-dom");function li(n,t){u(Mo,Zt(t),"invalid table block");const e=jt(t),o=Sn(n,t),r=(a,d,f)=>{const m=b("div",["button-root",d],a),p=b("div",["button-container",d],m);m.setAttribute(`data-${d}-index`,`${f}`),p.setAttribute(`data-editor-tooltip-${n.clientId}`,d==="left"?T.t("table.insertRow"):T.t("table.insertCol")),b("span",["insert-indicator"],p),aT(p)},{selectedRows:i,selectedColumns:s}=Oh(n,t),l=()=>{const a=o.querySelector(".table-border-bar-container.top");u(Mo,a,"no top border bar container");const d=b("div",["table-border-bar-container","top"],null),f=b("div",["table-border-bar","top"],d),m=kE(e);b("span",["table-border-bar-cell","corner"],f);const A=nt.fromTable(e).colCount;n.selection.range.isSimple()&&r(f,"top",0);for(let k=0;k<A;k++){const v=k===A-1?m[k]+2:m[k],x=b("span",["table-border-bar-cell","top"],f);s.has(k)&&x.classList.add("selected"),x.setAttribute("data-top-index",`${k}`),x.style.width=`${v}px`,n.selection.range.isSimple()&&r(f,"top",k+1)}Hi(a,d)},c=()=>{const a=o.querySelector(".table-border-bar-container.left");u(Mo,a,"no left border bar container");const d=b("div",["table-border-bar-container","left"],null),f=b("div",["table-border-bar","left"],d),m=UC(e);n.selection.range.isSimple()&&r(f,"left",0),Array.from(e.rows).forEach((p,A,k)=>{const v=b("span",["table-border-bar-cell","left"],f);i.has(A)&&v.classList.add("selected"),v.setAttribute("data-left-index",`${A}`);const x=A===k.length-1?m[A]+2:m[A];v.style.height=`${x}px`,n.selection.range.isSimple()&&r(f,"left",A+1)}),Hi(a,d)};l(),c()}function VC(n,t){const e=t.target;if(!(e instanceof Element))return;const o=U(e);u(Mo,o&&Zt(o),"invalid table block"),li(n,o),n.selection.caret.update()}function I1(n,t){const e=t.target;if(!(e instanceof Element))return;const o=U(e);u(Mo,o&&Zt(o),"invalid table block");const r=e.closest(".button-root");if(r){if(r.classList.contains("top")){const i=parseInt(r.getAttribute("data-top-index")||"0",10);sC(n,o,i),li(n,o)}else if(r.classList.contains("left")){const i=parseInt(r.getAttribute("data-left-index")||"0",10);lC(n,o,i),li(n,o)}}}function x1(n,t){var s;zC(n),t.preventDefault(),t.stopPropagation();let e=null,o,r;const i=l=>{var c;if(l.target instanceof HTMLElement&&o&&e&&r!==void 0){const a=U(l.target),d=l.target.closest(".table-border-bar");if(a===e&&d){const f=parseInt((c=l.target.getAttribute(`data-${o}-index`))!=null?c:"0",10),m=Math.min(r,f),p=Math.abs(r-f)+1;rt(l.target,"top")&&o==="top"?NE(n,a,m,p,{reverse:!0}):rt(l.target,"left")&&o==="left"&&PE(n,a,m,p,{reverse:!0})}}l.type==="mouseup"&&(e=null,r=void 0,o=void 0,document.body.removeEventListener("mousemove",i),document.body.removeEventListener("mouseup",i))};t.target instanceof HTMLElement&&rt(t.target,"table-border-bar-cell")&&(e=U(t.target),rt(t.target,"top")?o="top":rt(t.target,"left")&&(o="left"),o&&e&&(r=parseInt((s=t.target.getAttribute(`data-${o}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",i),document.body.addEventListener("mouseup",i)))}function qC(n){const t=n.selection.range,e=Ms(n,t);e&&li(n,e)}function dT(n,t){u(Mo,Zt(t),"invalid table block");const e=Sn(n,t),o=b("div",["table-border-bar-container","top"],e),r=b("div",["table-border-bar-container","left"],e);li(n,t),n.domEvents.addEventListener(st(t),"scroll",VC),n.domEvents.addEventListener(o,"click",I1),n.domEvents.addEventListener(r,"click",I1),n.domEvents.addEventListener(o,"mousedown",x1),n.domEvents.addEventListener(r,"mousedown",x1),n.addListener("afterClearSelection",qC)}function WC(n,t){if(!n.isWritable())return;if(Sn(n,t).querySelector(".table-border-bar-container")){li(n,t);return}dT(n,t)}function GC(n,t){u(Mo,Zt(t),"invalid table block"),Sn(n,t).querySelectorAll(".table-border-bar-container").forEach(r=>{n.domEvents.removeEventListener(r,"click",I1),n.domEvents.removeEventListener(r,"mousedown",x1),r.remove()}),n.domEvents.removeEventListener(st(t),"scroll",VC),n.addListener("afterClearSelection",qC)}function hT(n,t){u(Mo,Zt(t),"invalid table block");const o=Sn(n,t).querySelector(".table-border-bar-container.top");return o?o.getBoundingClientRect().height:0}class fT{constructor(t,e){h(this,"toolbar");h(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(xo(this.editor,this.tableBlock,!0,!0),To(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(xo(this.editor,this.tableBlock,!0,!1),To(this.editor,this.tableBlock,!0,!1)):(xo(this.editor,this.tableBlock,!1),To(this.editor,this.tableBlock,!1)))});h(this,"handleClick",(t,e,o)=>{e.id==="delete-columns"?Nh(this.editor.selection.range):e.id==="delete-rows"&&Ph(this.editor.selection.range)});h(this,"handleToolbarClose",()=>{this.tableBlock&&Ms(this.editor,this.editor.selection.range)===this.tableBlock&&(xo(this.editor,this.tableBlock,!1),To(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const o=t.options.componentsOptions.popover;this.toolbar=new Ss([],void 0,{overflowBoundary:o==null?void 0:o.overflowBoundary,refuseOverflow:!0,tooltipId:this.editor.clientId}),this.toolbar.addListener("selectionChange",this.handleSelectionChange),this.toolbar.addListener("click",this.handleClick),this.toolbar.addListener("close",this.handleToolbarClose)}close(){this.toolbar.close()}update(){const{selectedColumns:t,selectedRows:e}=Oh(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close();return}if(t.size===0&&e.size===0){this.toolbar.close();return}const o=co(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!o){this.toolbar.close();return}if(t.size>0){const r={id:"delete-columns",name:T.t("table.deleteCol"),icon:ww};this.toolbar.updateItems([r]);const i=fo(this.editor,this.tableBlock,"table-row-column-delete",o);this.toolbar.manualShow(i,{placement:"top"})}else{const r={id:"delete-rows",name:T.t("table.deleteRow"),icon:kw};this.toolbar.updateItems([r]);const i=new DOMRect(o.left-15,o.top,o.width,o.height),s=fo(this.editor,this.tableBlock,"table-row-column-delete",i);this.toolbar.manualShow(s,{placement:"left"})}}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const T1=w("table-border-bar");class mT{constructor(t,e){h(this,"toolbar");h(this,"resizeObserver");h(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():GC(this.editor,this.tableBlock)});h(this,"handleBlockUpdated",()=>{this.resizeObserver.disconnect(),setTimeout(()=>{const t=this.editor.getBlockById(j(this.tableBlock));this.resizeObserver.observe(jt(t))})});h(this,"handleTableResize",()=>{!this.editor.isWritable()||(console.log("resize"),this.update())});this.editor=t,this.tableBlock=e,u(T1,this.tableBlock,"no table block"),T1.debug("create table border bar"),WC(this.editor,this.tableBlock),this.resizeObserver=new ResizeObserver(this.handleTableResize),this.resizeObserver.observe(jt(this.tableBlock)),this.toolbar=new fT(this.editor,this.tableBlock),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){this.toolbar.close()}destroy(){T1.debug("destroy table border bar"),this.resizeObserver.disconnect(),GC(this.editor,this.tableBlock),this.toolbar.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){WC(this.editor,this.tableBlock),this.toolbar.update()}}const gT=w("table-border-bar");class pT{constructor(t){h(this,"activeTableBar",null);h(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||wt(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});h(this,"handleSelectionChanged",t=>{var r;const e=t.selection.range,o=Ms(t,e);((r=this.activeTableBar)==null?void 0:r.tableBlock)!==o&&this.activeTableBar&&this.hide(),o&&this.show(o)});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new mT(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(u(gT,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function ZC(n,t){const e=n.addCustom("table-border-bar",o=>new pT(o));t==="update"&&e.update()}const Be=w("table-cell-menu"),CT="style-bg-color-";class AT{constructor(t){h(this,"activeTableBlock",null);h(this,"targetButton",null);h(this,"manualMenu",null);h(this,"colorPaletteItem",null);h(this,"handlePrevent",(t,e)=>{e.stopPropagation()});h(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});h(this,"handleSelectionChanged",t=>{const e=t.selection.range,o=Ms(t,e);if(this.hide(),this.activeTableBlock!==o&&(this.activeTableBlock=o),this.activeTableBlock){const r=nt.fromBlock(this.activeTableBlock),i=e.isReverse()?e.start:e.end;let s=null;e.isCollapsed()?s=this.getCellByChildBlockId(r,i.blockId):i instanceof Xe&&(t.getBlockById(i.blockId)===this.activeTableBlock?s=r.getCellByContainerId(i.childContainerId):s=this.getCellByChildBlockId(r,i.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});h(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});h(this,"createBkgColorItem",()=>{const t=b("div",["cell-background-color-item"],null);b("span",[],t,T.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();b("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const r=b("span",["item-sub-indicator"],t);return r.innerHTML=A5,t});h(this,"handleCommand",t=>{var r;u(Be,this.activeTableBlock,"no target table block");const e=((r=t.states)==null?void 0:r.includes("checked"))||!1,o=t.value;switch(t.id){case"delete-select-row":Ph(j5(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":Nh(j5(this.editor,this.activeTableBlock,!0));break;case"merge-cell":_5(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(e);break;case"col-title":this.handleColTitle(e);break;case"stripe-style":this.handleStripeStyle(e);break;case"hide-border":VB(this.editor,this.activeTableBlock,o==="show-border");break;case"show-chart":QB(this.editor,this.activeTableBlock,o==="show-chart"),Gh(this.editor,this.activeTableBlock,{updateNow:!0});break}});h(this,"handleToolbarClose",()=>{this.targetButton&&H(this.targetButton,"active"),this.activeTableBlock&&Ms(this.editor,this.editor.selection.range)===this.activeTableBlock&&(xo(this.editor,this.activeTableBlock,!1),To(this.editor,this.activeTableBlock,!1)),this.editor.focus()});h(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(u(Be,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(xo(this.editor,this.activeTableBlock,!0,!1),To(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(xo(this.editor,this.activeTableBlock,!0,!0),To(this.editor,this.activeTableBlock,!0,!0)):(xo(this.editor,this.activeTableBlock,!1),To(this.editor,this.activeTableBlock,!1)))});h(this,"handleClick",()=>{var t;u(Be,this.activeTableBlock,"no target table block"),u(Be,this.targetButton,"no target button"),zC(this.editor),rt(this.targetButton,"active")?(H(this.targetButton,"active"),(t=this.manualMenu)==null||t.close()):(M(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new cr(this.createCommandMenu()),this.manualMenu.on("click",(e,o)=>{var r;this.handleCommand(o),(r=this.manualMenu)==null||r.close()}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",this.handleToolbarClose)),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"}))});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var t,e;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(t=this.manualMenu)==null||t.destroy(),(e=this.colorPaletteItem)==null||e.destroy()}hide(){var t;(t=this.manualMenu)==null||t.close(),this.targetButton&&(H(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let o=this.editor.getBlockById(e);for(;o;){const r=o.closest("td");u(Be,r,"no parent cell");const i=U(r);if(u(Be,i,"no parent block"),jt(i)===t.table)return t.getCellByCellElement(r);o=i}return u(Be,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${Uh}`)||t.appendChild(this.targetButton):(this.targetButton=b("button",[Uh],t),this.targetButton.innerHTML=ph,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent))}showCellMenuButton(t){this.createTargetButton(t.cell),u(Be,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=nt.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:o,row:r}=this.getCellByChildBlockId(t,e.start.blockId);_h(this.editor,this.activeTableBlock,{col:o,row:r})}else Fh(this.editor.selection.range)}}getSelectedBkgColorIndex(){var r;u(Be,this.activeTableBlock,"no target table block");const t=GB(this.editor,this.activeTableBlock),e=this.editor.getBlockData(this.activeTableBlock),o=new Set;for(const i of t){if(o.size>1)break;const s=V(i),l=e[`${s}_background`];if(l)o.add(Number.parseInt((r=l.substring(CT.length))!=null?r:"0",10));else{o.add(-1);break}}return o.size===1&&[...o][0]!==-1?[...o][0]:-1}createCommandMenu(){u(Be,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=$5(this.editor,this.activeTableBlock,this.editor.selection.range);let o=this.editor.selection.range;if(o.isSimple()){const d=Yn(this.editor,this.activeTableBlock,o.start);o=Wt(this.editor,{anchor:d,focus:d})}const r=P5(this.editor,this.activeTableBlock,o),i=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,a=t.chart;return this.colorPaletteItem=new D5("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(d,f)=>{var m;switch(u(Be,this.activeTableBlock,"no target table block"),d){case"clearColor":V5(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":V5(this.editor,this.activeTableBlock,f);break}(m=this.manualMenu)==null||m.close()}),[{id:"cell-background-color",name:T.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:T.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:T.t("table.splitCell"),states:r?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:T.t("table.deleteSelectRow")},{id:"delete-select-col",name:T.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:T.t("table.tableConfigKey"),children:[{id:"row-title",name:T.t("table.tableConfig.rowTitle"),states:i?["checked"]:[]},{id:"col-title",name:T.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:T.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?T.t("table.tableConfig.showBorder"):T.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:a?T.t("table.tableConfig.hideChart"):T.t("table.tableConfig.showChart"),value:a?"hide-chart":"show-chart"}]}]}handleRowTitle(t){u(Be,this.activeTableBlock,"no target table block"),t?jB(this.editor,this.activeTableBlock):HB(this.editor,this.activeTableBlock)}handleColTitle(t){u(Be,this.activeTableBlock,"no target table block"),t?FB(this.editor,this.activeTableBlock):_B(this.editor,this.activeTableBlock)}handleStripeStyle(t){u(Be,this.activeTableBlock,"no target table block"),t?UB(this.editor,this.activeTableBlock):zB(this.editor,this.activeTableBlock)}}function QC(n){n.addCustom("table-cell-menu",t=>new AT(t))}const oa=w("table-container");function S1(n){const t=n.closest("td");return u(oa,t,"no parent cell for a table cell container"),t}function YC(n){const t=jt(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function D1(n,t,e,o){const r=nt.fromBlock(n),i=r.getCellByContainerId(V(t));if(e==="ArrowDown"){const s=r.getBottomCell(i);return s?s.container:null}if(e==="ArrowUp"){const s=r.getTopCell(i);return s?s.container:null}if(e==="ArrowLeft"){const s=r.getAllContainers(),l=s.indexOf(t);if(u(oa,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return o!=null&&o.noWrap&&r.getCellByContainerId(V(c)).row!==i.row?null:c}if(e==="ArrowRight"){const s=r.getAllContainers(),l=s.indexOf(t);if(u(oa,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return o!=null&&o.noWrap&&r.getCellByContainerId(V(c)).row!==i.row?null:c}u(oa,!1,`invalid navigation type: ${e}`)}const bT=12,vT=90,ra=23,JC=2;class yT{constructor(t){h(this,"scrollTableBlock",null);h(this,"autoScrollDir",null);h(this,"autoScrollTimer",null);h(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const o=U(e);if(o&&wt(this.editor.rootContainer,o)){const r=Qn(o);r&&(this.scrollTableBlock=r,document.addEventListener("mousemove",this.handleAutoScroll))}}});h(this,"handleAutoScroll",l8.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(Io(this.scrollTableBlock)),o=e.rootElement,r=e.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=window.innerHeight-(e.scrollOptions.barFloatWindowBottom||0),l=r.getBoundingClientRect(),c=Math.min(l.bottom,s),a=Math.max(l.top,0);i.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):i.top<a&&t.clientY<=a?this.setAutoScroll("top"):o.scrollLeft>0&&t.clientX<i.left?this.setAutoScroll("left"):o.scrollLeft<o.scrollWidth-o.offsetWidth&&t.clientX>i.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));h(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});h(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const o=t.getBlockById(e.start.blockId),r=Qn(o);if(r){const i=t.getCustom(Io(r)),s=i.rootElement.getBoundingClientRect(),l=Ye(t,o,e.start);if(s.left>l.left){const c=e.start.offset===0?bT:JC;i.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?vT:JC;i.rootElement.scrollLeft+=l.right-s.right+c}}}else{const o=t.getBlockById(e.start.blockId),r=Qn(o),i=t.getBlockById(e.end.blockId),s=Qn(i);if(r&&r===s){const l=t.getCustom(Io(r)),c=l.rootElement.getBoundingClientRect();let a=null;if(e.isSimple())a=e.isReverse()?Ye(t,o,e.start):Ye(t,i,e.end);else{const d=S1(Pr(t,e.start.childContainerId)),f=S1(Pr(t,e.end.childContainerId));a=e.isReverse()?d.getBoundingClientRect():f.getBoundingClientRect()}c.left>a.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-a.left:c.right<a.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=a.right-c.right)}}});h(this,"handleScroll",t=>{R5(t),this.editor.selection.caret.update()});h(this,"handleReset",t=>{R5(t),this.editor.selection.caret.update()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}clearAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null,this.autoScrollDir=null)}setAutoScroll(t){this.autoScrollDir&&this.autoScrollDir!==t&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=t,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const e=this.editor.getCustom(Io(this.scrollTableBlock)),o=e.rootElement,r=e.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=r===document.documentElement?window.innerHeight:r.offsetHeight,l=window.innerHeight-(e.scrollOptions.barFloatWindowBottom||0),c=r.getBoundingClientRect(),a=Math.min(c.bottom,l),d=Math.max(c.top,0);this.autoScrollDir==="left"&&(o.scrollLeft-=ra,o.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(o.scrollLeft+=ra,o.scrollLeft>=o.scrollWidth-o.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(r.scrollTop+=ra,(r.scrollTop>=r.scrollHeight-s||i.bottom<=a)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(r.scrollTop-=ra,(r.scrollTop<=0||i.top>=d)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function KC(n){return n.addCustom("table-scroll-events",t=>new yT(t))}const Dn=w("create-content");function XC(n,t,e){const o=new Mc(e),r=e.rows,i=e.cols;u(Dn,r>=1,`invalid rows: ${r}`),u(Dn,i>=1,`invalid cols: ${i}`),u(Dn,e.children,"no table children");const s=b("table",[],null),l=e.colsWidth,c=b("colgroup",[],s);for(let f=0;f<o.colCount;f++){const m=b("col",[],c);m.style.width=`${l[f]||jc}px`}const a=b("tbody",[],s);let d=0;for(let f=0;f<r;f++){const m=b("tr",[],a);for(let p=0;p<i;p++){const A=o.getCell({col:p,row:f});if(A.virtual)u(Dn,A.colSpan>1||A.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const k=e.children[d],v=b("td",[],m);A.colSpan>1&&(v.colSpan=A.colSpan),A.rowSpan>1&&(v.rowSpan=A.rowSpan);const x=e[Ns(k)];x&&M(v,x),p===0&&e.hasColTitle&&M(v,F5.COL_TITLE_ITEM),n.createChildContainer(t,v,k),d+=1}}}return u(Dn,d===e.children.length,"container count mismatch"),e.noBorder&&M(s,"no-border"),e.chart&&M(s,"editor-table-chart"),e.isStripeStyle&&M(s,"stripe"),e.hasRowTitle&&M(s,"row-title"),e.hasColTitle&&M(s,"col-title"),s}function kT(n,t,e,o,r){u(Dn,r.type==="table","not table data"),u(Dn,V(e)===t[t.length-1].containerId,"invalid path");const i=r,s=lo(o,"div");try{const l=b("div",[],null);l.setAttribute("data-type","table-content");const c=XC(n,t,i);c.classList.add("drag-preview-element"),l.appendChild(c),rC(n),aC(n),ZC(n,"create"),QC(n),uw(n,Zh);const a=n.getComponentOptions("table"),d=n.addCustom(Io(o),()=>bE());d.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Ct(e)?n.scrollContainer:e,locatingContainer:Ct(e)?(a==null?void 0:a.locatingContainer)||n.parent:e,paddingLeft:zh+Os,paddingTop:zh+Os,paddingBottom:Os/2,paddingRight:Os/2,barFloatWindowBottom:a==null?void 0:a.barFloatWindowBottom,isSetScale:a==null?void 0:a.isSetScale});const f=KC(n);d.on("scroll",f.handleReset),d.on("resize",f.handleReset),setTimeout(()=>{KB(n,o)})}catch{const c=`invalid table data: ${JSON.stringify(i)}`;Dn.error(c);const a=b("div",["error"],s);a.innerText=c}return s}function wT(n,t,e){u(Dn,e.type==="table","not table data");const o=e,r=st(t);try{const i=jt(t),s=ao(t),l=XC(n,s,o);l.classList.add("drag-preview-element"),i.insertAdjacentElement("afterend",l),i.remove(),rC(n),aC(n),ZC(n,"update"),QC(n),Zh(n,t)}catch{const s=`invalid table data: ${JSON.stringify(o)}`;Dn.error(s);const l=b("div",["error"],r);l.innerText=s}}function BT(n,t){let e,o,r=!1;if([...t].every(m=>m==="|")?(o=t.length,e=Array(o).fill(""),r=!0):(e=Au(t,"|").split("|"),o=e.length),o<2)return null;const i=3,s=o,l=[];for(let m=0;m<3;m++)e.forEach(p=>{l.push(Bn(n.doc,m===0?p:""))});const c=Array(s).fill(jc),a=l[r?0:s],d=n.doc.getContainerBlocks(a)[0].id;return{blockData:{id:P(),type:"table",rows:i,cols:s,children:l,colsWidth:c},focusBlockId:d}}function ET(n,t){const e=t.rows,o=t.cols;if(e<1||o<1)return null;const r=[];for(let a=0;a<e;a++)for(let d=0;d<o;d++)r.push(Bn(n.doc));const i=Array(o).fill(jc),s=r[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:P(),type:"table",rows:e,cols:o,children:r,colsWidth:i},focusBlockId:l}}const t4=w("table-selection-to-doc");function IT(n,t){const{start:e,end:o,block:r}=t,i=it(r);u(t4,i==="table",`invalid block type: ${i}`);const s=n.getBlockData(r);if(e.isSimple()&&o.isSimple())return bo(n.editorBlocks,n.doc.toJSON(),s);u(t4,!e.isSimple()&&!o.isSimple(),"invalid block pos type");const l=nt.fromBlock(r),{fromCol:c,toCol:a,fromRow:d,toRow:f}=dn(r,e,o),m={},p=[],A=n.doc.toJSON();let k={};l.sub({row:d,col:c},{row:f,col:a}).forEach((q,ot)=>{q.forEach((lt,gt)=>{const ht=lt.containerId;if(p.indexOf(ht)!==-1)return;p.push(ht);let kt;if(lt.virtual){const re=l.getCellByContainerId(lt.containerId),qe=c+gt;let $o=re.col+re.colSpan-1;$o>a&&($o=a);const kr=$o-qe+1;kr>1&&(m[`${ht}_colSpan`]=kr);const wr=d+ot;let _o=re.row+re.rowSpan-1;_o>f&&(_o=f);const Na=_o-wr+1;Na>1&&(m[`${ht}_rowSpan`]=Na),kt=or()}else{if(kt=Md(n.editorBlocks,A,ht),lt.col+lt.colSpan>a+1){const re=a-lt.col+1;re>1&&(m[`${ht}_colSpan`]=re)}else lt.colSpan>1&&(m[`${ht}_colSpan`]=lt.colSpan);if(lt.row+lt.rowSpan>f+1){const re=f-lt.row+1;re>1&&(m[`${ht}_rowSpan`]=re)}else lt.rowSpan>1&&(m[`${ht}_rowSpan`]=lt.rowSpan)}const{root:de,...oo}=kt.blocks;k={...k,...oo,[ht]:de}})});const x=Fs(jt(r)).slice(c,a+1);return{blocks:{root:[{id:P(),type:i,children:p,colsWidth:x,rows:f-d+1,cols:a-c+1,...m}],...k},meta:{},comments:{}}}function xT(n,t){if(t.top===0)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.top-1][e]===n[t.top][e])return!1;return!0}function TT(n,t){if(t.left===0)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.left-1]===n[e][t.left])return!1;return!0}function ST(n,t){if(t.bottom===n.length-1)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.bottom][e]===n[t.bottom+1][e])return!1;return!0}function DT(n,t){if(t.right===n[0].length-1)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.right]===n[e][t.right+1])return!1;return!0}function LT(n,t,e){const o=t.col,r=t.row,i=e.col,s=e.row,l={left:o,top:r,right:i,bottom:s};let c=!1;do{if(c=!1,!xT(n,l)){l.top--,c=!0;continue}if(!TT(n,l)){l.left--,c=!0;continue}if(!ST(n,l)){l.bottom++,c=!0;continue}if(!DT(n,l)){l.right++,c=!0;continue}}while(c);return l}function MT(n,t,e,o){if(e.custom!==void 0||o.custom!==void 0)return{anchor:e,focus:o};const r=nt.fromBlock(t),i=r.map(L=>L.containerId),s=r.getCellByContainerId(e.childContainerId),l=r.getCellByContainerId(o.childContainerId),c=Math.min(s.row,l.row),a=Math.max(s.row,l.row),d=Math.min(s.col,l.col),f=Math.max(s.col,l.col),m=LT(i,{row:c,col:d},{row:a,col:f}),p=r.getCell({row:m.top,col:m.left}),A=r.getCell({row:m.bottom,col:m.right}),k=r.getCell({row:m.top,col:m.right}),v=r.getCell({row:m.bottom,col:m.left});let x,E;return s.row<=l.row?s.col<=l.col?(x=p,E=A):(x=k,E=v):s.col<l.col?(x=v,E=k):(x=A,E=p),console.log(`move ${x.col}, ${x.row}, -> ${E.col}, ${E.row}`),{anchor:Bt(t,x.containerId),focus:Bt(t,E.containerId)}}function e4(n,t,e){if(e.isSimple())return[jt(t).getBoundingClientRect()];const o=jt(t),r=o.getBoundingClientRect(),{fromCol:i,fromRow:s,toCol:l,toRow:c}=dn(t,e.start,e.end),a=Fs(o),d=a.slice(0,i).reduce((k,v)=>k+v,0),f=d+a.slice(i,l+1).reduce((k,v)=>k+v,0),m=UC(o);let p=m.slice(0,s).reduce((k,v)=>k+v,0);const A=p+m.slice(s,c+1).reduce((k,v)=>k+v,0);if(s===0){const k=hT(n,t);p-=k}return[new DOMRect(r.left+d,r.top+p,f-d,A-p)]}w("table-size");const RT=40;function ia(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),o=Number.parseInt(e.borderLeft,10),r=Number.parseInt(e.borderRight,10);return(o+r)/2}function OT(n,t,e){const o=gd(n,e.container);return o!==void 0?o+ia(t):RT*e.colSpan-ia(t)}function NT(n,t,e,o){let r=0;const i=e.colCount;for(let s=0;s<i;s++){const l=e.getRealCell({col:s,row:o});if(l.virtual)continue;let c=OT(n,t,l);const a=Tp(l.container,{withPadding:!0});a&&a>c&&(c=a),r+=c+ia(t)}return r}function PT(n,t){const e=jt(t),o=nt.fromTable(e);let r=0;for(let s=0;s<o.rowCount;s++)r=Math.max(r,NT(n,e,o,s));const i=ia(e);return r+=i,r}const Jn=w("table-creator");async function $T(n,t){return n.undoManager.runInGroup(()=>{var c,a;const e=t.item,o=(c=e.colCount)!=null?c:5,r=(a=e.rowCount)!=null?a:3,i=ET(n,{cols:o,rows:r});if(!i)return null;const{blockData:s,focusBlockId:l}=i;return n.insertBlock(t.containerId,t.blockIndex,s,Ot(n,l,0))})}class _T{constructor(){h(this,"id","insert-table");h(this,"name","Create table");h(this,"element");h(this,"closeable",null);h(this,"colCount");h(this,"rowCount");h(this,"setCloseable",t=>{this.closeable=t});h(this,"destroy",()=>{this.closeable=null});h(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);h(this,"handleTableCreatorClick",t=>{var m,p;t.preventDefault(),t.stopPropagation();const e=t.target;u(Jn,e instanceof HTMLElement,"invalid event target");const o=e.closest(".table-creator");u(Jn,o,"no table creator");const r=o.querySelectorAll(".active");if(r.length===0)return;const s=r[r.length-1].id;u(Jn,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const a=s.substring(l.length).split("-");u(Jn,a.length===2,"invalid cell id");const d=Number.parseInt(a[0],10)+1,f=Number.parseInt(a[1],10)+1;Jn.debug(`${d}, ${f}`),this.colCount=f,this.rowCount=d,(m=this.closeable)==null||m.click(this,this.element),(p=this.closeable)==null||p.close(),this.handleTableCreatorLeave()});h(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const o=this.getTableCreatorCellId(t,e),r=document.getElementById(o);r&&H(r,"active")}});h(this,"handleTableCreatorCellEnter",t=>{const e=t.target;u(Jn,e instanceof HTMLElement,"invalid event target");const o=e.id,r="table-creator-cell-";u(Jn,o.startsWith(r),"invalid cell id");const s=o.substring(r.length).split("-");u(Jn,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let a=0;a<9;a++)for(let d=0;d<9;d++){const f=this.getTableCreatorCellId(a,d),m=document.getElementById(f);u(Jn,m,"no cell"),a<=l&&d<=c?M(m,"active"):H(m,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=b("div",["table-creator"],null),e=(o,r,i)=>{const s=b("div",["table-creator-cell"],o);return s.id=this.getTableCreatorCellId(r,i),s};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let o=0;o<9;o++){const r=b("div",["table-creator-row"],t);for(let i=0;i<9;i++)e(r,o,i).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function FT(){return new _T}function HT(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function n4(n){const t=HT(n);return n.length+t}function jT(n,t){const e=n4(n),o=t-e;return o>0?n+" ".repeat(o):n}function zT(n,t,e,o,r){const i=t,s=new Mc(i);if(o==="markdown"||o==="text"){const l=v=>e.blocks[v].map((L,R)=>o==="markdown"?kd(n,L,e,[...r,{containerId:v,blockIndex:R}]):lc(n,L,e,[...r,{containerId:v,blockIndex:R}])),c=v=>l(v).join(" ").replace(/\n/g," ").trim(),a=new Map,d=new Map;for(let v=0;v<s.colCount;v++){let x=0;for(let E=0;E<s.rowCount;E++){const L=s.getCell({row:E,col:v});let R="";L.virtual||(R=c(L.containerId)),a.set(`${E},${v}`,R),x=Math.max(x,n4(R))}d.set(v,x)}const f=v=>{const x=a.get(`${v.row},${v.col}`)||"",E=d.get(v.col)||0;return jT(x,E)},m=[];let p="|",A="|";for(let v=0;v<s.colCount;v++){const x=f({row:0,col:v});p+=` ${x} |`;const E="-".repeat((d.get(v)||0)+2);A+=`${E}|`}m.push(p),m.push(A);for(let v=1;v<s.rowCount;v++){let x="|";for(let E=0;E<s.colCount;E++){const L=f({row:v,col:E});x+=` ${L} |`}m.push(x)}return`${m.join(`
|
|
371
371
|
`)}
|
|
372
372
|
`}if(o==="html"){const l=a=>e.blocks[a].map((m,p)=>yd(n,m,e,[...r,{containerId:a,blockIndex:p}])).join(`
|
|
373
373
|
`),c=[];c.push("<table>");for(let a=0;a<s.rowCount;a++){let d="<tr>";for(let f=0;f<s.colCount;f++){const m=s.getCell({row:a,col:f});if(m.virtual)d+="<td></td>";else{const p=l(m.containerId);d+=`<td colSpan="${m.colSpan}" rowSpan="${m.rowSpan}">${p}</td>`}}d+="</tr>",c.push(d)}return c.push("</table>"),c.join(`
|
|
374
|
-
`)}return""}const qs=w("table-block");function UT(n){return 1}function VT(n){return!!n.closest(`.${Uh}`)}function qT(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;let i=r;if(VT(r)&&(i=r.closest("td"),u(qs,i instanceof HTMLTableCellElement,"invalid element")),i instanceof HTMLTableCellElement){const c=jt(t);if(L5(c).indexOf(i)!==-1){const d=Ls(i),f=Bt(t,V(d));return new tn(n,{anchor:f,focus:f})}}if(!vn(r))return null;const s=r;if(YC(t).indexOf(s)===-1)return null;const l=Bt(t,V(s));return new tn(n,{anchor:l,focus:l})}function WT(n,t,e,o){return null}function GT(n,t){return n.getBoundingClientRect()}function o4(n,t,e,o){if(e.isSimple()){u(qs,o.isSimple(),"from is simple position but to is not simple position"),qs.debug("full select table"),M(t,"full-selected");return}u(qs,!o.isSimple(),"from is complex position but end is simple position");const r=Yn(n,t,e),i=Yn(n,t,o);u(qs,r.blockId===i.blockId,"only allow update one table selection"),qB(n,r,i).forEach(l=>{const c=S1(l);M(c,"selected")})}function ZT(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="table"]').forEach(t=>{H(t,"full-selected"),t.querySelectorAll("td.selected").forEach(e=>{H(e,"selected")})})}function QT(n,t){return M5(t)?YC(t):[]}function YT(n,t,e,o,r){return D1(t,e,o,r)}function JT(n,t){return PT(n,t)}function KT(n,t){return _(n,t)?BT(n,n.getBlockString(t).trim()):null}function XT(n){return{name:"TableBlock",insertBlockCommandItems:[{id:"insert-table",name:
|
|
374
|
+
`)}return""}const qs=w("table-block");function UT(n){return 1}function VT(n){return!!n.closest(`.${Uh}`)}function qT(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;let i=r;if(VT(r)&&(i=r.closest("td"),u(qs,i instanceof HTMLTableCellElement,"invalid element")),i instanceof HTMLTableCellElement){const c=jt(t);if(L5(c).indexOf(i)!==-1){const d=Ls(i),f=Bt(t,V(d));return new tn(n,{anchor:f,focus:f})}}if(!vn(r))return null;const s=r;if(YC(t).indexOf(s)===-1)return null;const l=Bt(t,V(s));return new tn(n,{anchor:l,focus:l})}function WT(n,t,e,o){return null}function GT(n,t){return n.getBoundingClientRect()}function o4(n,t,e,o){if(e.isSimple()){u(qs,o.isSimple(),"from is simple position but to is not simple position"),qs.debug("full select table"),M(t,"full-selected");return}u(qs,!o.isSimple(),"from is complex position but end is simple position");const r=Yn(n,t,e),i=Yn(n,t,o);u(qs,r.blockId===i.blockId,"only allow update one table selection"),qB(n,r,i).forEach(l=>{const c=S1(l);M(c,"selected")})}function ZT(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="table"]').forEach(t=>{H(t,"full-selected"),t.querySelectorAll("td.selected").forEach(e=>{H(e,"selected")})})}function QT(n,t){return M5(t)?YC(t):[]}function YT(n,t,e,o,r){return D1(t,e,o,r)}function JT(n,t){return PT(n,t)}function KT(n,t){return _(n,t)?BT(n,n.getBlockString(t).trim()):null}function XT(n){return{name:"TableBlock",insertBlockCommandItems:[{id:"insert-table",name:T.t("table.title"),order:200,icon:$w,children:[FT()],group:"common",subText:Ce("insert-table")}],handleInsertEmptyBlock:$T}}function tS(n,t,e){return wT(n,t,e),setTimeout(()=>{const o=n.selection.range;o.isSimple()?n.selection.caret.update():o4(n,t,o.start,o.end)}),!0}function eS(n,t){let e=0;const{selectedColumns:o}=Oh(n,t);if(o.size>0){const{fromCol:i,toCol:s}=dn(t,n.selection.range.start,n.selection.range.end),l=nt.fromBlock(t);(i!==0||s!==l.colCount-1)&&(e=60)}const r=e4(n,t,n.selection.range)[0];return new DOMRect(r.left,r.top+e,r.width,Math.max(r.height-e*2,0))}function nS(n,t){dw(n,Zh);const e=n.findCustom(Io(t));if(e){const o=KC(n);e.off("scroll",o.handleScroll),e.destroy()}}function oS(){return{abstract:`[${T.t("table.abstract")}]`}}const Ws={blockType:"table",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:kT,getBlockTextLength:UT,getRangeFromPoint:qT,moveCaret:WT,getCaretRect:GT,updateSelection:o4,clearSelection:ZT,getChildContainers:QT,getNextContainer:YT,getMinWidth:JT,getSelectedContainers:qh,convertFrom:KT,convertTo:zT,adjustSelectionPos:MT,getClientRects:e4,selectionToDoc:IT,getOptions:XT,getTextToolbarReferenceClient:eS,handleUpdateBlock:tS,handleDeleteBlock:nS,getBlockProperties:oS},rS={table:{cellBackground:"\u5355\u5143\u683C\u80CC\u666F\u8272",deleteSelectRow:"\u5220\u9664\u6240\u9009\u884C",deleteSelectCol:"\u5220\u9664\u6240\u9009\u5217",mergeCell:"\u5408\u5E76\u5355\u5143\u683C",splitCell:"\u62C6\u5206\u5355\u5143\u683C",tableConfigKey:"\u8868\u683C\u8BBE\u7F6E",deleteTable:"\u5220\u9664\u8868\u683C",insertCol:"\u63D2\u5165\u5217",insertRow:"\u63D2\u5165\u884C",deleteCol:"\u5220\u9664\u5217",deleteRow:"\u5220\u9664\u884C",tableConfig:{rowTitle:"\u884C\u6807\u9898",colTitle:"\u5217\u6807\u9898",stripeStyle:"\u6761\u7EB9\u6837\u5F0F",hideBorder:"\u9690\u85CF\u8868\u683C\u7EBF",showBorder:"\u663E\u793A\u8868\u683C\u7EBF",showChart:"\u663E\u793A\u56FE\u8868",hideChart:"\u9690\u85CF\u56FE\u8868"},title:"\u8868\u683C",abstract:"\u8868\u683C"}},iS={table:{cellBackground:"Cell background",deleteSelectRow:"Delete rows",deleteSelectCol:"Delete columns",mergeCell:"Merge cells",splitCell:"Split cell",tableConfigKey:"Table setting",deleteTable:"Delete table",insertCol:"Insert column",insertRow:"Insert row",deleteCol:"Delete column",deleteRow:"Delete row",tableConfig:{rowTitle:"Row Title",colTitle:"Col Title",stripeStyle:"Stripe style",hideBorder:"Hide border",showBorder:"Show border",showChart:"Show chart",hideChart:"Hide chart"},title:"Table",abstract:"Table"}};T.mergeLang({"zh-CN":rS,"en-US":iS});const gV="",r4=w("table");function i4(n,t){const e=Rh(t);if(!e)return;const o=U(e);u(r4,o&&Zt(o),"not a table block");const r=D1(o,e,"ArrowRight");if(!r){const s=dt(o);return s?(n.selection.selectBlock(s,0),!0):i4(n,o)}const i=Ft(r);return n.selection.selectBlock(i,0),!0}function sS(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!t)return i4(n,t)}function s4(n,t){const e=Rh(t);if(!e)return;const o=U(e);u(r4,o&&Zt(o),"not a table block");const r=D1(o,e,"ArrowLeft");if(!r){const s=bt(o);return s?(n.selection.selectBlock(s,G(n,s)),!0):s4(n,o)}const i=Jt(r);return n.selection.selectBlock(i,G(n,i)),!0}function lS(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!t)return s4(n,t)}const L1={Tab:sS,"Shift+Tab":lS},cS=`<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
375
375
|
<g>
|
|
376
376
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M12 7.61719C11.4477 7.61719 11 7.16947 11 6.61719V3.61719C11 3.0649 11.4477 2.61719 12 2.61719C12.5523 2.61719 13 3.0649 13 3.61719V6.61719C13 7.16947 12.5523 7.61719 12 7.61719ZM4.92893 5.54612C5.31946 5.15559 5.95262 5.1556 6.34315 5.54612L8.46447 7.66744C8.85499 8.05796 8.85499 8.69113 8.46447 9.08165C8.07394 9.47218 7.44078 9.47218 7.05025 9.08165L4.92893 6.96033C4.53841 6.56981 4.53841 5.93664 4.92893 5.54612ZM15.5355 9.08165C15.145 8.69113 15.145 8.05796 15.5355 7.66744L17.6569 5.54612C18.0474 5.1556 18.6805 5.1556 19.0711 5.54612C19.4616 5.93664 19.4616 6.56981 19.0711 6.96033L16.9497 9.08165C16.5592 9.47218 15.9261 9.47218 15.5355 9.08165ZM2 12.6172C2 12.0649 2.44772 11.6172 3 11.6172L6 11.6172C6.55229 11.6172 7 12.0649 7 12.6172C7 13.1695 6.55228 13.6172 6 13.6172L3 13.6172C2.44772 13.6172 2 13.1695 2 12.6172ZM17 12.6172C17 12.0649 17.4477 11.6172 18 11.6172L21 11.6172C21.5523 11.6172 22 12.0649 22 12.6172C22 13.1695 21.5523 13.6172 21 13.6172L18 13.6172C17.4477 13.6172 17 13.1695 17 12.6172ZM15.5355 16.1527C15.9261 15.7622 16.5592 15.7622 16.9497 16.1527L19.0711 18.274C19.4616 18.6646 19.4616 19.2977 19.0711 19.6883C18.6805 20.0788 18.0474 20.0788 17.6569 19.6883L15.5355 17.5669C15.145 17.1764 15.145 16.5432 15.5355 16.1527ZM4.92893 19.6883C4.53841 19.2977 4.53841 18.6646 4.92893 18.274L7.05025 16.1527C7.44078 15.7622 8.07394 15.7622 8.46447 16.1527C8.85499 16.5432 8.85499 17.1764 8.46447 17.5669L6.34315 19.6883C5.95262 20.0788 5.31946 20.0788 4.92893 19.6883ZM12 22.6172C11.4477 22.6172 11 22.1695 11 21.6172V18.6172C11 18.0649 11.4477 17.6172 12 17.6172C12.5523 17.6172 13 18.0649 13 18.6172V21.6172C13 22.1695 12.5523 22.6172 12 22.6172Z" fill="#5587F0"/>
|
|
377
377
|
<animateTransform attributeType="xml" attributeName="transform" type="rotate" values="0 12 12.5;360 12 12.5" dur="2s" repeatCount="indefinite" />
|
|
378
378
|
</g>
|
|
379
|
-
</svg>`,M1=w("webpage");class aS{constructor(t,e){h(this,"currentSrc","");h(this,"loading",null);h(this,"handleMaskMouseMove",(t,e)=>{if(!window.isDragging){if(e.target&&e.target instanceof Element){const o=e.target.closest("webpage-mask");o&&(o.style.display="none")}t.domEvents.addEventListener(document,"mousemove",this.handleDocumentMouseMove)}});h(this,"handleDocumentMouseMove",(t,e)=>{if(!e.target||!(e.target instanceof Element))return;const o=this.editor.findBlockById(this.blockData.id);if(o){const r=this.getExistsMask(o);if(r){if(wt(o,e.target)){r.style.display="none";return}r.style.display=""}}});this.editor=t,this.blockData=e}create(t,e,o,r){const i=e.src,s=b("div",["editor-embed"],null),l=b("iframe",["editor-preview-iframe"],s);this.loading=this.createLoading(s);const c=()=>{u(M1,this.loading,"not created"),this.loading.hide(),this.currentSrc=i};t.domEvents.addEventListener(l,"load",c),l.src=i,this.loading.show(),o.append(s),this.createMask(t,r)}update(t,e,o){if(u(M1,this.loading,"not created"),this.currentSrc===o.src)return;const r=e.querySelector(".editor-preview-iframe");u(M1,r,"no exists iframe"),this.loading.show(),r.src=o.src,this.createMask(t,e)}createLoading(t){const e=b("div",["editor-preview-iframe-loading"],null),o=b("span",[],e);return o.innerHTML=cS,{show(){t.append(e)},hide(){const r=t.querySelector(":scope > .editor-preview-iframe-loading");!r||r.remove()}}}getExistsMask(t){return Rt(t).querySelector(".webpage-mask")}createMask(t,e){const o=Rt(e);let r=this.getExistsMask(e);if(r){r.style.display="";return}r=b("div",["webpage-mask"],o),t.domEvents.addEventListener(r,"mousemove",this.handleMaskMouseMove)}destroy(){const t=this.editor.findBlockById(this.blockData.id);if(t){const e=this.getExistsMask(t);e&&(this.editor.domEvents.removeEventListener(e,"mousemove",this.handleMaskMouseMove),this.editor.domEvents.removeEventListener(document,"mousemove",this.handleDocumentMouseMove))}}}function uS(n,t){b("div",["resize-gripper",t],n).setAttribute("data-resize-type",t)}function R1(n){return Rt(n).querySelector(".block-resizer")}function dS(n){const t=R1(n);t&&H(t,"active")}function l4(n,t,e){const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}function hS(n,t,e,o){const r=R1(n);if(r)return M(r,"active"),l4(n,t,r),r;const i=Rt(n),s=b("div",["block-resizer"],i);return l4(n,t,s),e.resize.forEach(l=>{uS(s,l)}),s.addEventListener("mousedown",o),M(s,"active"),s}function c4(n,t){const e=R1(n);if(!e)return;const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}const pV="",fS=w("block-resizer");class sa extends Yt.TypedEmitter{constructor(e,o){super();h(this,"resizableElement");h(this,"block",null);h(this,"startRect",null);h(this,"startPos",null);h(this,"resizeType",null);h(this,"enabled",!1);h(this,"handleMouseDown",e=>{e.preventDefault(),e.stopPropagation();const o=this.getResizableElement();if(!o||e.button!==0)return;const r=e.target;if(!r||!(r instanceof HTMLElement))return;const i=r.getAttribute("data-resize-type");!i||(this.bindEvents(),this.startRect=o.getBoundingClientRect(),this.startPos=e,this.resizeType=i,Fi(window.getComputedStyle(r).cursor),this.block&&this.editor.selection.selectBlock(this.block,0))});h(this,"handleMouseMove",e=>{if(!this.startPos||!this.startRect||!this.resizeType)return;const o=this.getResizableElement();if(!o||!this.block)return;const r=e.x-this.startPos.x,i=e.y-this.startPos.y,s=this.startRect;let{top:l,left:c,right:a,bottom:d}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(d+=i),(this.resizeType==="top"||this.resizeType==="top-left"||this.resizeType==="top-right")&&(l+=i),(this.resizeType==="left"||this.resizeType==="top-left"||this.resizeType==="bottom-left")&&(c+=r),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(a+=r);const f=a>c?a-c:0,m=d>l?d-l:0,p=new DOMRect(c,l,f,m);this.emit("resizing",this,p),c4(this.block,o)});h(this,"handleMouseUp",e=>{if(e.button!==0)return;Fi(""),this.unbindEvents(),this.emit("resized",this);const o=this.getResizableElement();!o||!this.block||c4(this.block,o)});this.editor=e,this.options=o}enableResize(e,o){this.block=e,this.resizableElement=o,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(dS(this.block),this.enabled=!1)}update(e,o){this.block=e,this.resizableElement=o,this.getResizableElement()&&this.enabled&&this.createResizer()}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?st(this.block):null}createResizer(){const e=this.getResizableElement();!e||!this.block||(u(fS,wt(this.block,e),"not a block child element"),hS(this.block,e,this.options,this.handleMouseDown))}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}function a4(n){return n&&Te(n)&&Ne(n)==="webpage"}const mS=1e3,gS=100;class pS{constructor(t){h(this,"currentBlockElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{this.resizing||!this.editor.isWritable()||(e&&a4(e)&&this.disableBlockResize(e),t&&a4(t)&&this.enableBlockResize(t))});h(this,"handleResizing",(t,e)=>{this.resizing=!0;const o=t.getBlock();if(!o)return;const r=Math.max(Math.min(e.height,mS),gS);o.style.height=`${r}px`,M(o,"resizing")});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!e)return;H(e,"resizing");const o=this.editor.getBlockData(e),r=e.getBoundingClientRect().height;this.editor.updateBlockData(e,{...o,height:r})});this.editor=t,$t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentBlockElement=null,$t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disableBlockResize(t){const e=this.editor.findCustom(`${j(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t){const e=this.editor.addCustom(`${j(t)}-resizer`,()=>new sa(this.editor,{resize:["bottom"]}));e.enableResize(t),e.removeListener("resizing",this.handleResizing),e.removeListener("resized",this.handleResized),e.addListener("resizing",this.handleResizing),e.addListener("resized",this.handleResized),this.currentBlockElement=t}}const CV="",CS=w("editor-dialog");function AS(n,t){const e=b("div",["editor-dialog-container"],null),o=b("div",["dialog-header"],e);b("span",["dialog-header-title"],o,t.title);const r=b("span",["close-icon"],o);r.innerHTML=g5,b("div",["dialog-content"],e).appendChild(n);const s=b("div",["dialog-footer"],e);return b("button",["cancel-button"],s,"Cancel"),b("button",["submit-button"],s,"Ok"),e}class bS extends Ds{constructor(e,o){super(AS(e,o),o);h(this,"_options");h(this,"getReferenceClientRect",()=>{const e=document.documentElement.clientHeight/2,o=document.documentElement.clientWidth/2,r=this.getCommandBarRoot();u(CS,r,"no command bar root");const{width:i,height:s}=r.getBoundingClientRect();return new DOMRect(Math.max(o-i/2,0),Math.max(e-s/2,0),0,0)});h(this,"handleOk",async()=>{var e,o;try{await((o=(e=this._options).onOk)==null?void 0:o.call(e)),this.destroy()}catch{}});h(this,"handleClose",()=>{var e,o;(o=(e=this._options).onClose)==null||o.call(e),this.destroy()});const r=this.content.querySelector(".submit-button"),i=this.content.querySelector(".cancel-button"),s=this.content.querySelector(".close-icon");r==null||r.addEventListener("click",this.handleOk),s==null||s.addEventListener("click",this.handleClose),i==null||i.addEventListener("click",this.handleClose),this._options=o}show(){super.show(document.documentElement,{getReferenceClientRect:this.getReferenceClientRect})}destroy(){const e=this.content.querySelector(".submit-button"),o=this.content.querySelector(".cancel-button"),r=this.content.querySelector(".close-icon");e==null||e.removeEventListener("click",this.handleOk),o==null||o.removeEventListener("click",this.handleClose),r==null||r.removeEventListener("click",this.handleClose),super.destroy()}}const u4=()=>[{name:x.t("webpage.bilibili"),id:"insert-bilibili",icon:jw,group:"thirdParty",subText:Ce("insert-bilibili")},{name:x.t("webpage.youku"),id:"insert-youku",icon:zw,group:"thirdParty",subText:Ce("insert-youku")},{name:x.t("webpage.figma"),id:"insert-figma",icon:Uw,group:"thirdParty",subText:Ce("insert-figma")},{name:x.t("webpage.modao"),id:"insert-modao",icon:Vw,group:"thirdParty",subText:Ce("insert-modao")},{name:x.t("webpage.tencent"),id:"insert-tencent",icon:qw,group:"thirdParty",subText:Ce("insert-tencent")},{id:"insert-webPage",name:x.t("webpage.title"),icon:Ww,group:"common",order:1e3,subText:Ce("insert-webPage")}];function O1(n){return n==="insert-webPage"}async function vS(n,t){return n.doc.externalDoc.recognizeLink?n.doc.externalDoc.recognizeLink(t):null}function yS(n){return n&&!n.startsWith("http://")&&!n.startsWith("https://")&&!n.startsWith("//")?`${window.location.protocol}//${n}`:n}async function kS(n){if(!n)throw new Error(x.t("webpage.dialog.errorEnterUrl"));const t=n;try{new URL(t)}catch{throw new Error(x.t("webpage.dialog.unsupportedUrl"))}}async function wS(n,t){const e=t.item.id,o=u4().find(a=>a.id===e),r=b("div",["webpage-content"],null);if(O1(e)){const a=b("div",["help-container"],r),d=b("div",["help-content"],a),f=b("span",["help-icon"],d);f.innerHTML=b5,b("span",[],d,x.t("webpage.dialog.helpContent"))}const{getInputValue:i,setFieldError:s,focus:l,getField:c}=Sh(r,{required:!0,label:x.t("webpage.dialog.label"),placeholder:x.t("webpage.dialog.placeholder")});if(!O1(e)){const a=b("div",["help-link-container"],r),d=b("a",["help-link-content"],a);b("span",[],d,x.t("webpage.dialog.helpLink"));const f=b("span",["help-link-icon"],d);f.innerHTML=y5;const m=n.getComponentOptions("webpage");d.href=(m==null?void 0:m.helpLink)||"",d.target="_blank"}try{const a=await new Promise((m,p)=>{const A=new bS(r,{title:x.t("webpage.dialog.title",{name:(o==null?void 0:o.name)||""}),async onOk(){var T;const v=yS(i());try{await kS(v);const E=await vS(n,v);m((E==null?void 0:E.url)||"")}catch(E){if(((T=E==null?void 0:E.responseData)==null?void 0:T.statusCode)===415)if(O1(e))m(v);else throw s(x.t("webpage.dialog.unsupportedUrl")),E;else throw s(E.message||""),E}},onClose(){n.focus(),p()}});A.addListener("show",l),A.show(),c().addEventListener("keydown",async v=>{if(!v.isComposing){if(v.key==="Enter"){await A.handleOk(),v.preventDefault();return}v.key==="Escape"&&A.handleClose()}})}),d={id:P(),type:"embed",embedType:"webpage",embedData:{src:a}},f=n.insertBlock(t.containerId,t.blockIndex,d);return n.focus(),f}catch{return null}}const d4=w("embed-block-properties");function la(n,t){var e;for(const o of n.blockHooks){const r=(e=o.commands)==null?void 0:e.call(o,n,t);if(!!r&&r.group==="block-comment-actions")return r.executeCommand(n,t,r.commands[0]),!0}return!1}class N1{constructor(t,e,o){h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:xh},{id:"add-comment",name:"Add Comment",icon:Ts}]);this.editor=t,this.block=e,this.properties=o}get commands(){var o,r,i;if(this.editor.readonly)return[];const t=this._commands;t.forEach(s=>{(s.id==="add-comment"||s.id==="edit")&&(s.states=this.editor.isBlockWritable(this.block)?[]:["disabled"])});const e=(o=this.properties)!=null&&o.presetIds?t.filter(s=>{var l,c;return(c=(l=this.properties)==null?void 0:l.presetIds)==null?void 0:c.includes(s.id)}):[...t];return(i=(r=this.properties)==null?void 0:r.extCommands)!=null&&i.length&&(e.push({id:P(),type:"separator",name:""}),e.push(...this.properties.extCommands)),e}executeCommand(t,e,o){var r,i;if(!((i=(r=this.properties)==null?void 0:r.handleExecuteCommand)!=null&&i.call(r,t,e,o))){if(o.id==="add-comment"){la(t,e)||d4.error("failed to add comment to block");return}d4.error(`unknown command: ${JSON.stringify(o)}`)}}}function P1(n,t,e){return{blockCommands:{"hovering-toolbar":new N1(n,t,e)}}}function BS(n){const t=n.querySelector(".editor-preview-iframe"),e=t.src;t.src="about:blank";const o=setTimeout(()=>{t.src=e,clearTimeout(o)},300);return!0}function ES(n,t){const e=n.getBlockData(t),{embedData:o}=e,r=o.src;return window.open(r,"_blank"),!0}function IS(n,t){const e=P1(n,t,{presetIds:["add-comment"],extCommands:[{id:"refresh",name:"Refresh page",icon:_w},{id:"open-page",name:"Open the original page",icon:y5}],handleExecuteCommand:(r,i,s)=>{switch(s.id){case"refresh":return BS(i);case"open-page":return ES(r,i)}return!1}}),o=`[${x.t("webpage.abstract")}]`;return{...e,abstract:o}}const xS=w("webpage-embed");function TS(n,t,e,o,r,i){const{embedData:s,id:l}=e,{src:c}=s,a=n.addCustom(`webpage-${l}`,()=>new aS(n,e));u(xS,c,"The src from blockData is invalid "),a.create(n,s,t,i),setTimeout(()=>{n.isBlockWritable(i)&&n.addCustom("webpage-resizer",()=>new pS(n))}),e.height&&(i.style.height=`${e.height}px`)}function SS(n,t,e){const{embedData:o,id:r}=e;return n.getCustom(`webpage-${r}`).update(n,t,o),e.height&&(t.style.height=`${e.height}px`),!0}function DS(){return{name:"WebPage",insertEmbedCommandItems:u4(),handleInsertEmptyEmbed:wS}}function LS(n,t,e,o){const i=t.embedData.src;return o==="html"?`<iframe src="${i}" ></iframe>`:o==="markdown"?`[${i}](${i})`:i}const $1={embedType:"webpage",createEmbedContent:TS,getBlockProperties:IS,getOptions:DS,handleUpdateBlock:SS,convertTo:LS},MS={webpage:{title:"\u7F51\u9875",youku:"\u4F18\u9177\u89C6\u9891",modao:"\u58A8\u5200",tencent:"\u817E\u8BAF\u89C6\u9891",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",helpLink:"\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",label:"\u7F51\u9875\u5730\u5740",placeholder:"\u8BF7\u8F93\u5165",title:"\u63D2\u5165{name}",errorEnterUrl:"\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",unsupportedUrl:"\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9"},abstract:"\u7F51\u9875"}},RS={webpage:{title:"Webpage",youku:"Youku",modao:"Modao",tencent:"Tencent Video",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"Due to the limitation of the landing page, some pages may not be previewed successfully.",helpLink:"How to get the URL link",label:"Please enter webpage address",placeholder:"Please enter url",title:"Insert {name}",errorEnterUrl:"Please enter the webpage address",unsupportedUrl:"Unsupported url"},abstract:"Webpage"}};x.mergeLang({"zh-CN":MS,"en-US":RS});const AV="";function OS(n,t,e,o){var f;const r=n.getBlockByIndex(t,e);if(G(n,r)!==o)return!1;const i=vt(n.getBlockText(r));if(![...i].every(m=>m==="|")||i.length<3||!n.editorBlocks.hasBlock("table"))return!1;const s=n.editorBlocks.getBlockClass("table");if(!s.convertFrom)return!1;const l=s.convertFrom(n,r,{offset:o});if(!l)return!1;const{blockData:c,focusBlockId:a}=l;if(!c)return!1;const d=n.insertBlock(t,e,c,Ot(n,a!=null?a:c.id,0));return n.deleteBlock(r),(f=l.onConverted)==null||f.call(l,n,d),!0}const NS={mermaid:{blockType:"embed",reg:/^```mermaid$/,data:{embedType:"mermaid"}},flowchart:{blockType:"embed",reg:/^```flowchart$/,data:{embedType:"flowchart"}},plantuml:{blockType:"embed",reg:/^```plantuml$/,data:{embedType:"plantuml"}},code:{blockType:"code",reg:/^```\S+$/},code2:{blockType:"code",reg:/^```$/},table:{blockType:"table",reg:/^\|.+\|.+\|$/},math:{blockType:"embed",reg:/^\$\$.+\$\$$/},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}},dividing:{blockType:"embed",reg:/^-{3,}$/,data:{embedType:"dividing-line"}},toc:{blockType:"embed",reg:/^\[toc\]/,data:{embedType:"toc"}}},PS={orderedList:{reg:/^(\d)+(\.|。)$/,blockType:"list",data:{listType:"ordered"}},unorderedList1:{reg:/^\*$/,blockType:"list",data:{listType:"unordered"}},unorderedList2:{reg:/^-$/,blockType:"list",data:{listType:"unordered"}},checkList1:{reg:/^\[\s?\]$/,blockType:"list",data:{listType:"unchecked"}},checkList2:{reg:/^\[X\]$/i,blockType:"list",data:{listType:"checked"}},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}}};function h4(n,t,e,o,r){if(r==="enter"&&OS(n,t,e,o))return!0;const i=n.getBlockByIndex(t,e),s=vt(ve(n.getBlockText(i),o).left).trim(),l=r==="enter"?NS:PS;for(const[,c]of Object.entries(l)){if(!s.match(c.reg))continue;return!!n.undoManager.runInGroup(()=>{var A;const d=jl(n,i,c.blockType,{offset:o,data:c.data});if(!d)return null;const{blockData:f,focusBlockId:m}=d;if(!f)return null;const p=n.insertBlock(t,e,f,Ot(n,m!=null?m:f.id,0));return n.deleteBlock(i),(A=d.onConverted)==null||A.call(d,n,p),{newBlock:p,focusBlockId:m}})}return!1}function $S(n,t,e,o){const r=n.getBlockByIndex(t,e);return n.getBlockString(r,{boxReplacement:" "}).substring(0,o)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{quoted:!0},Ot(n,r,0))}),!0)}const _S={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function FS(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockString(r,{boxReplacement:" "}).substring(0,o);let s=_S[i];if(!s)return!1;const l=n.getBlockData(r).heading;return l&&l==s&&(s=null),n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{heading:s},Ot(n,r,0))}),!0}function HS(n,t,e,o){return!!(FS(n,t,e,o)||$S(n,t,e,o))}const jS=w("match-text-style");function zS(n,t){if(n.length<t.length*2+1||!n.endsWith(t)||n.substring(0,n.length-1).endsWith(t))return-1;const e=n.substring(0,n.length-t.length),o=e.lastIndexOf(t);return o===-1?-1:o===0?0:e.substring(o-1).startsWith(t)?-1:o}const US={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-strikethrough"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function VS(n,t,e,o){var m,p;const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=ve(i,o),l=ld(s),c=me(s)-l.length,a=Object.entries(US);for(const[A,k]of a){const v=zS(l,A);if(v===-1)continue;const T=c+v,E=o,L=A.length,R=vt(Gt(i,T+L,E-T-L*2).middle);if(k.type==="style"){const $={};k.styles.forEach(ot=>{$[ot]=!0});const q=Co(R,$);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,T,E-T),n.insertTextToBlock(r,T,q)})}else if(k.type==="box")try{const $=(p=(m=n.editorBoxes.getBoxClass(k.boxType)).convertFrom)==null?void 0:p.call(m,n,R);if(!$)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,T,E-T),n.insertBoxToBlock(r,T,$)})}catch($){jS.warn(`failed to convert to box, ${$.message}`);continue}return!0}const d=/\[([^\]]+)\]\((https?:\/\/\S+)\)\s*$/,f=l.match(d);if(f){const A=f.index,k=f[1],v=f[2],T=A,E=o,R={...Ji(i,T),link:v};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,T,E-T),n.insertTextToBlock(r,T,Co(k,R))}),!0}return!1}class ca{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&(HS(t,e,o,r)||VS(t,e,o,r)))}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(_(t,t.getBlockByIndex(r,i))){if(jn(e,"Enter")){if(h4(t,r,i,s,"enter"))return!0}else if(jn(e,"Space")&&h4(t,r,i,s,"space"))return!0}return!1}}const qS={"en-US":{placeholder:{default:"Type \u2018/\u2019 for commands",heading:"Heading {heading}",list:"List",mention:"Quickly assign tasks @mention yourself or others",quote:"Quote",title:"Enter document title"}},"zh-CN":{placeholder:{default:"\u8F93\u5165\u300C/\u300D\u5FEB\u901F\u63D2\u5165",heading:"\u6807\u9898{heading}",list:"\u5217\u8868",mention:"\u5FEB\u901F\u5206\u914D\u4EFB\u52A1\uFF0C@\u63D0\u53CA\u81EA\u5DF1\u6216\u4ED6\u4EBA",quote:"\u5F15\u7528",title:"\u8BF7\u8F93\u5165\u6587\u6863\u6807\u9898"}}};x.mergeLang(qS);function Gs(n,t){const e=Ao(n,t);return!!(e.text&&me(e.text)===0&&!t.querySelector(".inputting-insertion"))}function f4(n,t){var o;st(t).removeAttribute("data-content-placeholder"),(o=t.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||o.remove()}function aa(n,t,e){var r;if(!Gs(n,t)){f4(n,t);return}const o=st(t);if(typeof e=="string")o.setAttribute("data-content-placeholder",e);else{const i=Rt(t),s=(r=i.querySelector(".block-placeholder-container"))!=null?r:b("div",["block-placeholder-container"],i);s.innerHTML="",s.appendChild(e)}}function WS(n){const t=n.getAttribute("data-style-heading");return t?x.t("placeholder.heading",{heading:t}):n.getAttribute("data-style-quoted")?x.t("placeholder.quote"):null}function GS(n){const t=n.getAttribute("data-list-type");return t?t==="ordered"||t==="unordered"?x.t("placeholder.list"):x.t("placeholder.mention"):null}function m4(n){switch(it(n)){case"text":return WS(n);case"list":return GS(n);default:return null}}function ZS(n){if(Wn(n))return!1;const t=U(z(n));return t?it(t)==="code":!1}function QS(n){return!Wn(n)}function YS(n,t){var d,f;const e=n.selection.focusedBlock,o=it(e),r=t.contentPlaceholder||x.t("placeholder.default");let i=r;if(o&&Ui(n,o)&&e){if(!n.isBlockWritable(e)||ZS(e))return;QS(e)?i=x.t("placeholder.common.contentInTable"):i=(d=m4(e))!=null?d:i}const s=n.getFirstBlock(),l=dt(s);if(!l)return;const c=dt(l);if(c&&!t.addPlaceholderToAllCurrentEmptyBlock)return;if(!c){Gs(n,l)&&aa(n,l,(f=m4(l))!=null?f:r);return}const a=n.getFocusedBlock();!Gs(n,a)||a!==s&&aa(n,a,i)}function JS(n,t){var r,i;const e=n.getFirstBlock(),o=st(e);Gs(n,e)?(o.setAttribute("data-title-placeholder",(r=t.titlePlaceholder)!=null?r:x.t("placeholder.title")),o.setAttribute("data-title-placeholder-readonly",(i=t.readonlyTitlePlaceholder)!=null?i:"")):(o.removeAttribute("data-title-placeholder"),o.removeAttribute("data-title-placeholder-readonly"))}function KS(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(t=>{t.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(t=>{t.remove()})}function XS(n,t){KS(n),n.selection.range.isCollapsed()&&(JS(n,t),YS(n,t))}const yV="",tD=w("enforce-title");class Zs{constructor(t,e={headingLevel:1}){h(this,"handleSelectionChange",t=>{setTimeout(()=>{this.applyPlaceholder(t)})});this.options=e,this.handleChanged(t),this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}destroy(t){t.removeListener("selectionChanged",this.handleSelectionChange)}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(!Zs.isDocumentTitleBlock(r,i)||!jn(e,"Enter"))return!1;let l=!1,c=null;Ze(t.rootContainer)===2&&(c=Sr(t.rootContainer,1),G(t,c)===0&&(l=!0));const a=t.getFirstBlock();return t.undoManager.runInGroup(()=>{t.breakTextBlock(a,s,{forceInsertAfter:!0}),l&&c&&t.deleteBlock(c)}),!0}handleChanged(t){var e;try{const o=t.doc.getContainerBlocks(V(t.rootContainer));u(tD,o.length>0,"root container is empty");const r=o[0];if(r.type!=="text"||r.heading!==this.options.headingLevel){const i=Vn("",{heading:(e=this.options.headingLevel)!=null?e:1});t.insertBlock(V(t.rootContainer),0,i);return}if(o.length>1)return;t.insertTextBlock("",V(t.rootContainer),1,{newRange:t.selection.range.toDocRange()})}finally{this.applyPlaceholder(t)}}handleRemoteChanged(t){setTimeout(()=>{this.applyPlaceholder(t)})}handleUpdateCompositionText(t){this.applyPlaceholder(t)}applyPlaceholder(t){var e,o;!((e=this.options)!=null&&e.titlePlaceholder)&&!((o=this.options)!=null&&o.contentPlaceholder)||XS(t,this.options)}static isDocumentTitleBlock(t,e){return t==="root"&&e===0}}const g4=w("code-dom");function Ro(n){return it(n)==="code"}function p4(n,t,e){e.language?t.setAttribute("data-language",e.language):t.removeAttribute("data-language"),e.nowrap?H(t,"wrap"):M(t,"wrap")}function _1(n){const t=n.closest("div[data-type=editor-block][data-block-type=code]");return u(g4,t,"no parent code block"),u(g4,Ro(t),"not a code block"),t}const ua={plain:{name:"Plain Text",aliases:["txt","text"]},abap:{name:"ABAP",aliases:["abap"]},arduino:{name:"Arduino",aliases:["ino"]},bash:{name:"Bash",aliases:["sh","shell"]},basic:{name:"BASIC",aliases:["bas"]},c:{name:"C",aliases:["c"]},clojure:{name:"Clojure",aliases:["clj"]},cofeescript:{name:"CoffeeScript",aliases:["coffee"]},cpp:{name:"C++",aliases:["cpp","cxx"]},csharp:{name:"C#",aliases:["cs"]},css:{name:"CSS",aliases:["css"]},dart:{name:"Dart",aliases:["dart"]},diff:{name:"Diff",aliases:["diff","patch"]},docker:{name:"Docker",aliases:["dockerfile"]},elixir:{name:"Elixir",aliases:["ex","exs"]},elm:{name:"Elm",aliases:["elm"]},erlang:{name:"Erlang",aliases:["erl"]},flow:{name:"Flow",aliases:["flow"]},fortran:{name:"Fortran",aliases:["f","for","f77","f90"]},fsharp:{name:"F#",aliases:["fsharp"]},gherkin:{name:"Gherkin",aliases:["feature"]},glsl:{name:"GLSL",aliases:["glsl"]},go:{name:"Go",aliases:["go"]},graphql:{name:"GraphQL",aliases:["graphql"]},groovy:{name:"Groovy",aliases:["groovy"]},haskell:{name:"Haskell",aliases:["hs"]},java:{name:"Java",aliases:["java"]},js:{name:"JavaScript",aliases:["js","jsx"]},json:{name:"JSON",aliases:["json"]},julia:{name:"Julia",aliases:["jl"]},kotlin:{name:"Kotlin",aliases:["kt","ktm","kts"]},latex:{name:"LaTeX",aliases:["tex"]},less:{name:"LESS",aliases:["less"]},lisp:{name:"Lisp",aliases:["lisp"]},livescript:{name:"LiveScript",aliases:["ls"]},lua:{name:"Lua",aliases:["lua"]},makefile:{name:"Makefile",aliases:["mk","mak"]},markdown:{name:"Markdown",aliases:["md","mkdown","mkd"]},markup:{name:"HTML / XML",aliases:["html","htm","xml","xsd","xsl","xslt","wsdl"]},matlab:{name:"MATLAB",aliases:["matlab"]},mermaid:{name:"Mermaid",aliases:["mermaid"]},nix:{name:"Nix",aliases:["nix"]},objectivec:{name:"Objective-C",aliases:["m","mm"]},ocaml:{name:"OCaml",aliases:["ml"]},pascal:{name:"Pascal",aliases:["pas"]},perl:{name:"Perl",aliases:["pl","pm"]},php:{name:"PHP",aliases:["php"]},powershell:{name:"PowerShell",aliases:["ps","ps1"]},prolog:{name:"Prolog",aliases:["plg"]},protobuf:{name:"Protocol Buffers",aliases:["proto"]},python:{name:"Python",aliases:["py"]},r:{name:"R",aliases:["r"]},reason:{name:"Reason",aliases:["re","rei"]},ruby:{name:"Ruby",aliases:["rb"]},rust:{name:"Rust",aliases:["rs"]},sass:{name:"Sass",aliases:["sass"]},scala:{name:"Scala",aliases:["scala"]},scheme:{name:"Scheme",aliases:["scm","sm"]},scss:{name:"SCSS",aliases:["scss"]},solidity:{name:"Solidity",aliases:["sol"]},sql:{name:"SQL",aliases:["sql"]},swift:{name:"Swift",aliases:["swift"]},typescript:{name:"TypeScript",aliases:["ts","tsx"]},vbnet:{name:"VB.Net",aliases:["vbnet"]},verilog:{name:"Verilog",aliases:["v"]},vhdl:{name:"VHDL",aliases:["vhdl"]},"visual-basic":{name:"Visual Basic",aliases:["vb","vba"]},wasm:{name:"WebAssembly",aliases:["wasm"]},yaml:{name:"YAML",aliases:["yaml"]}};function eD(n){const t=n.toLocaleLowerCase();let e="";return Object.entries(ua).forEach(([o,r])=>{(o===t||r.aliases.includes(t)||r.name.toLocaleLowerCase()===t)&&(e=o)}),e}function C4(n){const t=n.settingsProvider.getItem("editor-code-lang");return t!=null?t:"plain"}function nD(n,t){return n.settingsProvider.setItem("editor-code-lang",t)}const oD=w("convert-to-code");function rD(n,t){if(!_(n,t))return null;const e={id:P(),type:"text",text:[]},o=P();n.doc.localInsertChildContainer(o,[e]);const r=n.getBlockData(t).text;u(oD,r,"no text");let i=vt(r);i.startsWith("```")&&(i=i.substring(3));const s=eD(i)||C4(n)||"plain";return{blockData:{id:P(),type:"code",language:s,children:[o]},focusBlockId:e.id}}const kV="",F1=w("code-block-child-container");function ci(n){u(F1,Ro(n),"not a code block");const e=st(n).querySelector(":scope > div.editor-code-root > div.code-text-root [data-type=editor-container].child");return u(F1,e,"no code text container"),e}function ai(n){u(F1,Ro(n),"not a code block");const e=st(n).querySelector(":scope > div.editor-code-root > div.code-caption-root [data-type=editor-container].child");return e||null}function da(n){const t=[ci(n)],e=ai(n);return e&&t.push(e),t}function ui(n,t){if(!_(n,t))return!1;const e=z(t),o=U(e);return o?Ro(o)?e===ci(o):it(t)==="code":!1}const H1=w("code-caption");function iD(n,t){if(n.readonly)return;const e=ai(t);if(e){const c=Ft(e);n.selection.selectBlock(c,0);return}const o=Bn(n.doc),r=n.getBlockData(t);u(H1,r.children.length===1,"code block should have only one child");const i={...r,children:[r.children[0],o]};n.updateBlockData(t,i);const s=n.getContainerById(o),l=Ft(s);n.selection.selectBlock(l,0)}function A4(n,t){const e=z(t);if(Ct(e))return!1;const o=U(e);if(u(H1,o,"no parent block"),!Ro(o))return!1;const i=ai(o);return e===i}function sD(n,t){if(n.readonly||!ai(t))return;const o=ci(t),r=Jt(o);n.selection.selectBlock(r,G(n,r));const i=n.getBlockData(t);u(H1,i.children.length===2,"code block should have only one child");const s=i.children[1],l={...i,children:[i.children[0]]};n.updateBlockData(t,l),n.deleteChildContainers([s])}const lD=w("paste-in-table-block");class cD{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePaste(t,e,o){if(!t.selection.range.isSimple())return!1;const r=t.selection.range.start,i=t.getBlockById(r.blockId),s=z(i);if(Ct(s))return!1;const l=U(s);if(u(lD,l,"no parent block"),!Ro(l)||A4(t,i))return!1;const c=o["text/plain"];return c&&t.undoManager.runInGroup(()=>{t.clearSelectedContents(),t.insertDoc(i,r.offset,c)}),!0}}function aD(n){n.addCustom("code-block-paste-event",t=>new cD(t))}class uD{constructor(t){h(this,"id","CodeBlockCommandProvider");setTimeout(()=>{t.editorCommandProviders.registerCommandProvider(this)})}destroy(){}getAvailableCommands(){return[]}executeCommand(){return!1}filterCommands(t,e,o,r){if(ui(t,e))return[]}beforeExecuteCommand(t,e,o,r,i){return!!ui(t,e)}}function dD(n){n.addCustom("code-block-command-provider",t=>new uD(t))}const hD=w("code-caption-input-handler");function j1(n){if(!n.selection.range.isSimple())return null;const t=n.selection.range.start;if(!t.isSimple())return null;const e=n.getBlockById(t.blockId);return A4(n,e)?e:null}function fD(n){const t=j1(n);if(!t)return!1;const e=_1(t),o=dt(e);return o?(n.selection.selectBlock(o,0),!0):(n.insertTextBlock("",V(z(e)),K(e)+1),!0)}function mD(n){const t=j1(n);if(!t)return!1;if(Tt(n,t)){const e=_1(t);return sD(n,e),!0}return!1}class z1{constructor(t){setTimeout(()=>{t.input.addHandler(this)})}destroy(){}handleBeforeKeyDown(t,e){return e.key==="Enter"?fD(t):e.key==="Backspace"?mD(t):!1}async handleBeforePaste(t,e,o){const r=j1(t);if(!r)return!1;const i=o["text/plain"];if(!i)return!0;const s=cc(t,i);return s&&t.undoManager.runInGroup(()=>{t.clearSelectedContents();const l=t.selection.range.start;u(hD,l.isSimple(),"not simple position"),t.insertTextToBlock(r,l.offset,s)}),!0}static init(t){t.addCustom("code-block-caption-input-handler",e=>new z1(e))}}const gD=`
|
|
379
|
+
</svg>`,M1=w("webpage");class aS{constructor(t,e){h(this,"currentSrc","");h(this,"loading",null);h(this,"handleMaskMouseMove",(t,e)=>{if(!window.isDragging){if(e.target&&e.target instanceof Element){const o=e.target.closest("webpage-mask");o&&(o.style.display="none")}t.domEvents.addEventListener(document,"mousemove",this.handleDocumentMouseMove)}});h(this,"handleDocumentMouseMove",(t,e)=>{if(!e.target||!(e.target instanceof Element))return;const o=this.editor.findBlockById(this.blockData.id);if(o){const r=this.getExistsMask(o);if(r){if(wt(o,e.target)){r.style.display="none";return}r.style.display=""}}});this.editor=t,this.blockData=e}create(t,e,o,r){const i=e.src,s=b("div",["editor-embed"],null),l=b("iframe",["editor-preview-iframe"],s);this.loading=this.createLoading(s);const c=()=>{u(M1,this.loading,"not created"),this.loading.hide(),this.currentSrc=i};t.domEvents.addEventListener(l,"load",c),l.src=i,this.loading.show(),o.append(s),this.createMask(t,r)}update(t,e,o){if(u(M1,this.loading,"not created"),this.currentSrc===o.src)return;const r=e.querySelector(".editor-preview-iframe");u(M1,r,"no exists iframe"),this.loading.show(),r.src=o.src,this.createMask(t,e)}createLoading(t){const e=b("div",["editor-preview-iframe-loading"],null),o=b("span",[],e);return o.innerHTML=cS,{show(){t.append(e)},hide(){const r=t.querySelector(":scope > .editor-preview-iframe-loading");!r||r.remove()}}}getExistsMask(t){return Rt(t).querySelector(".webpage-mask")}createMask(t,e){const o=Rt(e);let r=this.getExistsMask(e);if(r){r.style.display="";return}r=b("div",["webpage-mask"],o),t.domEvents.addEventListener(r,"mousemove",this.handleMaskMouseMove)}destroy(){const t=this.editor.findBlockById(this.blockData.id);if(t){const e=this.getExistsMask(t);e&&(this.editor.domEvents.removeEventListener(e,"mousemove",this.handleMaskMouseMove),this.editor.domEvents.removeEventListener(document,"mousemove",this.handleDocumentMouseMove))}}}function uS(n,t){b("div",["resize-gripper",t],n).setAttribute("data-resize-type",t)}function R1(n){return Rt(n).querySelector(".block-resizer")}function dS(n){const t=R1(n);t&&H(t,"active")}function l4(n,t,e){const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}function hS(n,t,e,o){const r=R1(n);if(r)return M(r,"active"),l4(n,t,r),r;const i=Rt(n),s=b("div",["block-resizer"],i);return l4(n,t,s),e.resize.forEach(l=>{uS(s,l)}),s.addEventListener("mousedown",o),M(s,"active"),s}function c4(n,t){const e=R1(n);if(!e)return;const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}const pV="",fS=w("block-resizer");class sa extends Yt.TypedEmitter{constructor(e,o){super();h(this,"resizableElement");h(this,"block",null);h(this,"startRect",null);h(this,"startPos",null);h(this,"resizeType",null);h(this,"enabled",!1);h(this,"handleMouseDown",e=>{e.preventDefault(),e.stopPropagation();const o=this.getResizableElement();if(!o||e.button!==0)return;const r=e.target;if(!r||!(r instanceof HTMLElement))return;const i=r.getAttribute("data-resize-type");!i||(this.bindEvents(),this.startRect=o.getBoundingClientRect(),this.startPos=e,this.resizeType=i,Fi(window.getComputedStyle(r).cursor),this.block&&this.editor.selection.selectBlock(this.block,0))});h(this,"handleMouseMove",e=>{if(!this.startPos||!this.startRect||!this.resizeType)return;const o=this.getResizableElement();if(!o||!this.block)return;const r=e.x-this.startPos.x,i=e.y-this.startPos.y,s=this.startRect;let{top:l,left:c,right:a,bottom:d}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(d+=i),(this.resizeType==="top"||this.resizeType==="top-left"||this.resizeType==="top-right")&&(l+=i),(this.resizeType==="left"||this.resizeType==="top-left"||this.resizeType==="bottom-left")&&(c+=r),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(a+=r);const f=a>c?a-c:0,m=d>l?d-l:0,p=new DOMRect(c,l,f,m);this.emit("resizing",this,p),c4(this.block,o)});h(this,"handleMouseUp",e=>{if(e.button!==0)return;Fi(""),this.unbindEvents(),this.emit("resized",this);const o=this.getResizableElement();!o||!this.block||c4(this.block,o)});this.editor=e,this.options=o}enableResize(e,o){this.block=e,this.resizableElement=o,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(dS(this.block),this.enabled=!1)}update(e,o){this.block=e,this.resizableElement=o,this.getResizableElement()&&this.enabled&&this.createResizer()}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?st(this.block):null}createResizer(){const e=this.getResizableElement();!e||!this.block||(u(fS,wt(this.block,e),"not a block child element"),hS(this.block,e,this.options,this.handleMouseDown))}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}function a4(n){return n&&Te(n)&&Ne(n)==="webpage"}const mS=1e3,gS=100;class pS{constructor(t){h(this,"currentBlockElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{this.resizing||!this.editor.isWritable()||(e&&a4(e)&&this.disableBlockResize(e),t&&a4(t)&&this.enableBlockResize(t))});h(this,"handleResizing",(t,e)=>{this.resizing=!0;const o=t.getBlock();if(!o)return;const r=Math.max(Math.min(e.height,mS),gS);o.style.height=`${r}px`,M(o,"resizing")});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!e)return;H(e,"resizing");const o=this.editor.getBlockData(e),r=e.getBoundingClientRect().height;this.editor.updateBlockData(e,{...o,height:r})});this.editor=t,$t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentBlockElement=null,$t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disableBlockResize(t){const e=this.editor.findCustom(`${j(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t){const e=this.editor.addCustom(`${j(t)}-resizer`,()=>new sa(this.editor,{resize:["bottom"]}));e.enableResize(t),e.removeListener("resizing",this.handleResizing),e.removeListener("resized",this.handleResized),e.addListener("resizing",this.handleResizing),e.addListener("resized",this.handleResized),this.currentBlockElement=t}}const CV="",CS=w("editor-dialog");function AS(n,t){const e=b("div",["editor-dialog-container"],null),o=b("div",["dialog-header"],e);b("span",["dialog-header-title"],o,t.title);const r=b("span",["close-icon"],o);r.innerHTML=g5,b("div",["dialog-content"],e).appendChild(n);const s=b("div",["dialog-footer"],e);return b("button",["cancel-button"],s,"Cancel"),b("button",["submit-button"],s,"Ok"),e}class bS extends Ds{constructor(e,o){super(AS(e,o),o);h(this,"_options");h(this,"getReferenceClientRect",()=>{const e=document.documentElement.clientHeight/2,o=document.documentElement.clientWidth/2,r=this.getCommandBarRoot();u(CS,r,"no command bar root");const{width:i,height:s}=r.getBoundingClientRect();return new DOMRect(Math.max(o-i/2,0),Math.max(e-s/2,0),0,0)});h(this,"handleOk",async()=>{var e,o;try{await((o=(e=this._options).onOk)==null?void 0:o.call(e)),this.destroy()}catch{}});h(this,"handleClose",()=>{var e,o;(o=(e=this._options).onClose)==null||o.call(e),this.destroy()});const r=this.content.querySelector(".submit-button"),i=this.content.querySelector(".cancel-button"),s=this.content.querySelector(".close-icon");r==null||r.addEventListener("click",this.handleOk),s==null||s.addEventListener("click",this.handleClose),i==null||i.addEventListener("click",this.handleClose),this._options=o}show(){super.show(document.documentElement,{getReferenceClientRect:this.getReferenceClientRect})}destroy(){const e=this.content.querySelector(".submit-button"),o=this.content.querySelector(".cancel-button"),r=this.content.querySelector(".close-icon");e==null||e.removeEventListener("click",this.handleOk),o==null||o.removeEventListener("click",this.handleClose),r==null||r.removeEventListener("click",this.handleClose),super.destroy()}}const u4=()=>[{name:T.t("webpage.bilibili"),id:"insert-bilibili",icon:jw,group:"thirdParty",subText:Ce("insert-bilibili")},{name:T.t("webpage.youku"),id:"insert-youku",icon:zw,group:"thirdParty",subText:Ce("insert-youku")},{name:T.t("webpage.figma"),id:"insert-figma",icon:Uw,group:"thirdParty",subText:Ce("insert-figma")},{name:T.t("webpage.modao"),id:"insert-modao",icon:Vw,group:"thirdParty",subText:Ce("insert-modao")},{name:T.t("webpage.tencent"),id:"insert-tencent",icon:qw,group:"thirdParty",subText:Ce("insert-tencent")},{id:"insert-webPage",name:T.t("webpage.title"),icon:Ww,group:"common",order:1e3,subText:Ce("insert-webPage")}];function O1(n){return n==="insert-webPage"}async function vS(n,t){return n.doc.externalDoc.recognizeLink?n.doc.externalDoc.recognizeLink(t):null}function yS(n){return n&&!n.startsWith("http://")&&!n.startsWith("https://")&&!n.startsWith("//")?`${window.location.protocol}//${n}`:n}async function kS(n){if(!n)throw new Error(T.t("webpage.dialog.errorEnterUrl"));const t=n;try{new URL(t)}catch{throw new Error(T.t("webpage.dialog.unsupportedUrl"))}}async function wS(n,t){const e=t.item.id,o=u4().find(a=>a.id===e),r=b("div",["webpage-content"],null);if(O1(e)){const a=b("div",["help-container"],r),d=b("div",["help-content"],a),f=b("span",["help-icon"],d);f.innerHTML=b5,b("span",[],d,T.t("webpage.dialog.helpContent"))}const{getInputValue:i,setFieldError:s,focus:l,getField:c}=Sh(r,{required:!0,label:T.t("webpage.dialog.label"),placeholder:T.t("webpage.dialog.placeholder")});if(!O1(e)){const a=b("div",["help-link-container"],r),d=b("a",["help-link-content"],a);b("span",[],d,T.t("webpage.dialog.helpLink"));const f=b("span",["help-link-icon"],d);f.innerHTML=y5;const m=n.getComponentOptions("webpage");d.href=(m==null?void 0:m.helpLink)||"",d.target="_blank"}try{const a=await new Promise((m,p)=>{const A=new bS(r,{title:T.t("webpage.dialog.title",{name:(o==null?void 0:o.name)||""}),async onOk(){var x;const v=yS(i());try{await kS(v);const E=await vS(n,v);m((E==null?void 0:E.url)||"")}catch(E){if(((x=E==null?void 0:E.responseData)==null?void 0:x.statusCode)===415)if(O1(e))m(v);else throw s(T.t("webpage.dialog.unsupportedUrl")),E;else throw s(E.message||""),E}},onClose(){n.focus(),p()}});A.addListener("show",l),A.show(),c().addEventListener("keydown",async v=>{if(!v.isComposing){if(v.key==="Enter"){await A.handleOk(),v.preventDefault();return}v.key==="Escape"&&A.handleClose()}})}),d={id:P(),type:"embed",embedType:"webpage",embedData:{src:a}},f=n.insertBlock(t.containerId,t.blockIndex,d);return n.focus(),f}catch{return null}}const d4=w("embed-block-properties");function la(n,t){var e;for(const o of n.blockHooks){const r=(e=o.commands)==null?void 0:e.call(o,n,t);if(!!r&&r.group==="block-comment-actions")return r.executeCommand(n,t,r.commands[0]),!0}return!1}class N1{constructor(t,e,o){h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:xh},{id:"add-comment",name:"Add Comment",icon:Ts}]);this.editor=t,this.block=e,this.properties=o}get commands(){var o,r,i;if(this.editor.readonly)return[];const t=this._commands;t.forEach(s=>{(s.id==="add-comment"||s.id==="edit")&&(s.states=this.editor.isBlockWritable(this.block)?[]:["disabled"])});const e=(o=this.properties)!=null&&o.presetIds?t.filter(s=>{var l,c;return(c=(l=this.properties)==null?void 0:l.presetIds)==null?void 0:c.includes(s.id)}):[...t];return(i=(r=this.properties)==null?void 0:r.extCommands)!=null&&i.length&&(e.push({id:P(),type:"separator",name:""}),e.push(...this.properties.extCommands)),e}executeCommand(t,e,o){var r,i;if(!((i=(r=this.properties)==null?void 0:r.handleExecuteCommand)!=null&&i.call(r,t,e,o))){if(o.id==="add-comment"){la(t,e)||d4.error("failed to add comment to block");return}d4.error(`unknown command: ${JSON.stringify(o)}`)}}}function P1(n,t,e){return{blockCommands:{"hovering-toolbar":new N1(n,t,e)}}}function BS(n){const t=n.querySelector(".editor-preview-iframe"),e=t.src;t.src="about:blank";const o=setTimeout(()=>{t.src=e,clearTimeout(o)},300);return!0}function ES(n,t){const e=n.getBlockData(t),{embedData:o}=e,r=o.src;return window.open(r,"_blank"),!0}function IS(n,t){const e=P1(n,t,{presetIds:["add-comment"],extCommands:[{id:"refresh",name:"Refresh page",icon:_w},{id:"open-page",name:"Open the original page",icon:y5}],handleExecuteCommand:(r,i,s)=>{switch(s.id){case"refresh":return BS(i);case"open-page":return ES(r,i)}return!1}}),o=`[${T.t("webpage.abstract")}]`;return{...e,abstract:o}}const xS=w("webpage-embed");function TS(n,t,e,o,r,i){const{embedData:s,id:l}=e,{src:c}=s,a=n.addCustom(`webpage-${l}`,()=>new aS(n,e));u(xS,c,"The src from blockData is invalid "),a.create(n,s,t,i),setTimeout(()=>{n.isBlockWritable(i)&&n.addCustom("webpage-resizer",()=>new pS(n))}),e.height&&(i.style.height=`${e.height}px`)}function SS(n,t,e){const{embedData:o,id:r}=e;return n.getCustom(`webpage-${r}`).update(n,t,o),e.height&&(t.style.height=`${e.height}px`),!0}function DS(){return{name:"WebPage",insertEmbedCommandItems:u4(),handleInsertEmptyEmbed:wS}}function LS(n,t,e,o){const i=t.embedData.src;return o==="html"?`<iframe src="${i}" ></iframe>`:o==="markdown"?`[${i}](${i})`:i}const $1={embedType:"webpage",createEmbedContent:TS,getBlockProperties:IS,getOptions:DS,handleUpdateBlock:SS,convertTo:LS},MS={webpage:{title:"\u7F51\u9875",youku:"\u4F18\u9177\u89C6\u9891",modao:"\u58A8\u5200",tencent:"\u817E\u8BAF\u89C6\u9891",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",helpLink:"\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",label:"\u7F51\u9875\u5730\u5740",placeholder:"\u8BF7\u8F93\u5165",title:"\u63D2\u5165{name}",errorEnterUrl:"\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",unsupportedUrl:"\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9"},abstract:"\u7F51\u9875"}},RS={webpage:{title:"Webpage",youku:"Youku",modao:"Modao",tencent:"Tencent Video",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"Due to the limitation of the landing page, some pages may not be previewed successfully.",helpLink:"How to get the URL link",label:"Please enter webpage address",placeholder:"Please enter url",title:"Insert {name}",errorEnterUrl:"Please enter the webpage address",unsupportedUrl:"Unsupported url"},abstract:"Webpage"}};T.mergeLang({"zh-CN":MS,"en-US":RS});const AV="";function OS(n,t,e,o){var f;const r=n.getBlockByIndex(t,e);if(G(n,r)!==o)return!1;const i=vt(n.getBlockText(r));if(![...i].every(m=>m==="|")||i.length<3||!n.editorBlocks.hasBlock("table"))return!1;const s=n.editorBlocks.getBlockClass("table");if(!s.convertFrom)return!1;const l=s.convertFrom(n,r,{offset:o});if(!l)return!1;const{blockData:c,focusBlockId:a}=l;if(!c)return!1;const d=n.insertBlock(t,e,c,Ot(n,a!=null?a:c.id,0));return n.deleteBlock(r),(f=l.onConverted)==null||f.call(l,n,d),!0}const NS={mermaid:{blockType:"embed",reg:/^```mermaid$/,data:{embedType:"mermaid"}},flowchart:{blockType:"embed",reg:/^```flowchart$/,data:{embedType:"flowchart"}},plantuml:{blockType:"embed",reg:/^```plantuml$/,data:{embedType:"plantuml"}},code:{blockType:"code",reg:/^```\S+$/},code2:{blockType:"code",reg:/^```$/},table:{blockType:"table",reg:/^\|.+\|.+\|$/},math:{blockType:"embed",reg:/^\$\$.+\$\$$/},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}},dividing:{blockType:"embed",reg:/^-{3,}$/,data:{embedType:"dividing-line"}},toc:{blockType:"embed",reg:/^\[toc\]/,data:{embedType:"toc"}}},PS={orderedList:{reg:/^(\d)+(\.|。)$/,blockType:"list",data:{listType:"ordered"}},unorderedList1:{reg:/^\*$/,blockType:"list",data:{listType:"unordered"}},unorderedList2:{reg:/^-$/,blockType:"list",data:{listType:"unordered"}},checkList1:{reg:/^\[\s?\]$/,blockType:"list",data:{listType:"unchecked"}},checkList2:{reg:/^\[X\]$/i,blockType:"list",data:{listType:"checked"}},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}}};function h4(n,t,e,o,r){if(r==="enter"&&OS(n,t,e,o))return!0;const i=n.getBlockByIndex(t,e),s=vt(ve(n.getBlockText(i),o).left).trim(),l=r==="enter"?NS:PS;for(const[,c]of Object.entries(l)){if(!s.match(c.reg))continue;return!!n.undoManager.runInGroup(()=>{var A;const d=jl(n,i,c.blockType,{offset:o,data:c.data});if(!d)return null;const{blockData:f,focusBlockId:m}=d;if(!f)return null;const p=n.insertBlock(t,e,f,Ot(n,m!=null?m:f.id,0));return n.deleteBlock(i),(A=d.onConverted)==null||A.call(d,n,p),{newBlock:p,focusBlockId:m}})}return!1}function $S(n,t,e,o){const r=n.getBlockByIndex(t,e);return n.getBlockString(r,{boxReplacement:" "}).substring(0,o)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{quoted:!0},Ot(n,r,0))}),!0)}const _S={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function FS(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockString(r,{boxReplacement:" "}).substring(0,o);let s=_S[i];if(!s)return!1;const l=n.getBlockData(r).heading;return l&&l==s&&(s=null),n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{heading:s},Ot(n,r,0))}),!0}function HS(n,t,e,o){return!!(FS(n,t,e,o)||$S(n,t,e,o))}const jS=w("match-text-style");function zS(n,t){if(n.length<t.length*2+1||!n.endsWith(t)||n.substring(0,n.length-1).endsWith(t))return-1;const e=n.substring(0,n.length-t.length),o=e.lastIndexOf(t);return o===-1?-1:o===0?0:e.substring(o-1).startsWith(t)?-1:o}const US={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-strikethrough"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function VS(n,t,e,o){var m,p;const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=ve(i,o),l=ld(s),c=me(s)-l.length,a=Object.entries(US);for(const[A,k]of a){const v=zS(l,A);if(v===-1)continue;const x=c+v,E=o,L=A.length,R=vt(Gt(i,x+L,E-x-L*2).middle);if(k.type==="style"){const $={};k.styles.forEach(ot=>{$[ot]=!0});const q=Co(R,$);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,x,E-x),n.insertTextToBlock(r,x,q)})}else if(k.type==="box")try{const $=(p=(m=n.editorBoxes.getBoxClass(k.boxType)).convertFrom)==null?void 0:p.call(m,n,R);if(!$)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,x,E-x),n.insertBoxToBlock(r,x,$)})}catch($){jS.warn(`failed to convert to box, ${$.message}`);continue}return!0}const d=/\[([^\]]+)\]\((https?:\/\/\S+)\)\s*$/,f=l.match(d);if(f){const A=f.index,k=f[1],v=f[2],x=A,E=o,R={...Ji(i,x),link:v};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,x,E-x),n.insertTextToBlock(r,x,Co(k,R))}),!0}return!1}class ca{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&(HS(t,e,o,r)||VS(t,e,o,r)))}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(_(t,t.getBlockByIndex(r,i))){if(jn(e,"Enter")){if(h4(t,r,i,s,"enter"))return!0}else if(jn(e,"Space")&&h4(t,r,i,s,"space"))return!0}return!1}}const qS={"en-US":{placeholder:{default:"Type \u2018/\u2019 for commands",heading:"Heading {heading}",list:"List",mention:"Quickly assign tasks @mention yourself or others",quote:"Quote",title:"Enter document title"}},"zh-CN":{placeholder:{default:"\u8F93\u5165\u300C/\u300D\u5FEB\u901F\u63D2\u5165",heading:"\u6807\u9898{heading}",list:"\u5217\u8868",mention:"\u5FEB\u901F\u5206\u914D\u4EFB\u52A1\uFF0C@\u63D0\u53CA\u81EA\u5DF1\u6216\u4ED6\u4EBA",quote:"\u5F15\u7528",title:"\u8BF7\u8F93\u5165\u6587\u6863\u6807\u9898"}}};T.mergeLang(qS);function Gs(n,t){const e=Ao(n,t);return!!(e.text&&me(e.text)===0&&!t.querySelector(".inputting-insertion"))}function f4(n,t){var o;st(t).removeAttribute("data-content-placeholder"),(o=t.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||o.remove()}function aa(n,t,e){var r;if(!Gs(n,t)){f4(n,t);return}const o=st(t);if(typeof e=="string")o.setAttribute("data-content-placeholder",e);else{const i=Rt(t),s=(r=i.querySelector(".block-placeholder-container"))!=null?r:b("div",["block-placeholder-container"],i);s.innerHTML="",s.appendChild(e)}}function WS(n){const t=n.getAttribute("data-style-heading");return t?T.t("placeholder.heading",{heading:t}):n.getAttribute("data-style-quoted")?T.t("placeholder.quote"):null}function GS(n){const t=n.getAttribute("data-list-type");return t?t==="ordered"||t==="unordered"?T.t("placeholder.list"):T.t("placeholder.mention"):null}function m4(n){switch(it(n)){case"text":return WS(n);case"list":return GS(n);default:return null}}function ZS(n){if(Wn(n))return!1;const t=U(z(n));return t?it(t)==="code":!1}function QS(n){return!Wn(n)}function YS(n,t){var d,f;const e=n.selection.focusedBlock,o=it(e),r=t.contentPlaceholder||T.t("placeholder.default");let i=r;if(o&&Ui(n,o)&&e){if(!n.isBlockWritable(e)||ZS(e))return;QS(e)?i=T.t("placeholder.common.contentInTable"):i=(d=m4(e))!=null?d:i}const s=n.getFirstBlock(),l=dt(s);if(!l)return;const c=dt(l);if(c&&!t.addPlaceholderToAllCurrentEmptyBlock)return;if(!c){Gs(n,l)&&aa(n,l,(f=m4(l))!=null?f:r);return}const a=n.getFocusedBlock();!Gs(n,a)||a!==s&&aa(n,a,i)}function JS(n,t){var r,i;const e=n.getFirstBlock(),o=st(e);Gs(n,e)?(o.setAttribute("data-title-placeholder",(r=t.titlePlaceholder)!=null?r:T.t("placeholder.title")),o.setAttribute("data-title-placeholder-readonly",(i=t.readonlyTitlePlaceholder)!=null?i:"")):(o.removeAttribute("data-title-placeholder"),o.removeAttribute("data-title-placeholder-readonly"))}function KS(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(t=>{t.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(t=>{t.remove()})}function XS(n,t){KS(n),n.selection.range.isCollapsed()&&(JS(n,t),YS(n,t))}const yV="",tD=w("enforce-title");class Zs{constructor(t,e={headingLevel:1}){h(this,"handleSelectionChange",t=>{setTimeout(()=>{this.applyPlaceholder(t)})});this.options=e,this.handleChanged(t),this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}destroy(t){t.removeListener("selectionChanged",this.handleSelectionChange)}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(!Zs.isDocumentTitleBlock(r,i)||!jn(e,"Enter"))return!1;let l=!1,c=null;Ze(t.rootContainer)===2&&(c=Sr(t.rootContainer,1),G(t,c)===0&&(l=!0));const a=t.getFirstBlock();return t.undoManager.runInGroup(()=>{t.breakTextBlock(a,s,{forceInsertAfter:!0}),l&&c&&t.deleteBlock(c)}),!0}handleChanged(t){var e;try{const o=t.doc.getContainerBlocks(V(t.rootContainer));u(tD,o.length>0,"root container is empty");const r=o[0];if(r.type!=="text"||r.heading!==this.options.headingLevel){const i=Vn("",{heading:(e=this.options.headingLevel)!=null?e:1});t.insertBlock(V(t.rootContainer),0,i);return}if(o.length>1)return;t.insertTextBlock("",V(t.rootContainer),1,{newRange:t.selection.range.toDocRange()})}finally{this.applyPlaceholder(t)}}handleRemoteChanged(t){setTimeout(()=>{this.applyPlaceholder(t)})}handleUpdateCompositionText(t){this.applyPlaceholder(t)}applyPlaceholder(t){var e,o;!((e=this.options)!=null&&e.titlePlaceholder)&&!((o=this.options)!=null&&o.contentPlaceholder)||XS(t,this.options)}static isDocumentTitleBlock(t,e){return t==="root"&&e===0}}const g4=w("code-dom");function Ro(n){return it(n)==="code"}function p4(n,t,e){e.language?t.setAttribute("data-language",e.language):t.removeAttribute("data-language"),e.nowrap?H(t,"wrap"):M(t,"wrap")}function _1(n){const t=n.closest("div[data-type=editor-block][data-block-type=code]");return u(g4,t,"no parent code block"),u(g4,Ro(t),"not a code block"),t}const ua={plain:{name:"Plain Text",aliases:["txt","text"]},abap:{name:"ABAP",aliases:["abap"]},arduino:{name:"Arduino",aliases:["ino"]},bash:{name:"Bash",aliases:["sh","shell"]},basic:{name:"BASIC",aliases:["bas"]},c:{name:"C",aliases:["c"]},clojure:{name:"Clojure",aliases:["clj"]},cofeescript:{name:"CoffeeScript",aliases:["coffee"]},cpp:{name:"C++",aliases:["cpp","cxx"]},csharp:{name:"C#",aliases:["cs"]},css:{name:"CSS",aliases:["css"]},dart:{name:"Dart",aliases:["dart"]},diff:{name:"Diff",aliases:["diff","patch"]},docker:{name:"Docker",aliases:["dockerfile"]},elixir:{name:"Elixir",aliases:["ex","exs"]},elm:{name:"Elm",aliases:["elm"]},erlang:{name:"Erlang",aliases:["erl"]},flow:{name:"Flow",aliases:["flow"]},fortran:{name:"Fortran",aliases:["f","for","f77","f90"]},fsharp:{name:"F#",aliases:["fsharp"]},gherkin:{name:"Gherkin",aliases:["feature"]},glsl:{name:"GLSL",aliases:["glsl"]},go:{name:"Go",aliases:["go"]},graphql:{name:"GraphQL",aliases:["graphql"]},groovy:{name:"Groovy",aliases:["groovy"]},haskell:{name:"Haskell",aliases:["hs"]},java:{name:"Java",aliases:["java"]},js:{name:"JavaScript",aliases:["js","jsx"]},json:{name:"JSON",aliases:["json"]},julia:{name:"Julia",aliases:["jl"]},kotlin:{name:"Kotlin",aliases:["kt","ktm","kts"]},latex:{name:"LaTeX",aliases:["tex"]},less:{name:"LESS",aliases:["less"]},lisp:{name:"Lisp",aliases:["lisp"]},livescript:{name:"LiveScript",aliases:["ls"]},lua:{name:"Lua",aliases:["lua"]},makefile:{name:"Makefile",aliases:["mk","mak"]},markdown:{name:"Markdown",aliases:["md","mkdown","mkd"]},markup:{name:"HTML / XML",aliases:["html","htm","xml","xsd","xsl","xslt","wsdl"]},matlab:{name:"MATLAB",aliases:["matlab"]},mermaid:{name:"Mermaid",aliases:["mermaid"]},nix:{name:"Nix",aliases:["nix"]},objectivec:{name:"Objective-C",aliases:["m","mm"]},ocaml:{name:"OCaml",aliases:["ml"]},pascal:{name:"Pascal",aliases:["pas"]},perl:{name:"Perl",aliases:["pl","pm"]},php:{name:"PHP",aliases:["php"]},powershell:{name:"PowerShell",aliases:["ps","ps1"]},prolog:{name:"Prolog",aliases:["plg"]},protobuf:{name:"Protocol Buffers",aliases:["proto"]},python:{name:"Python",aliases:["py"]},r:{name:"R",aliases:["r"]},reason:{name:"Reason",aliases:["re","rei"]},ruby:{name:"Ruby",aliases:["rb"]},rust:{name:"Rust",aliases:["rs"]},sass:{name:"Sass",aliases:["sass"]},scala:{name:"Scala",aliases:["scala"]},scheme:{name:"Scheme",aliases:["scm","sm"]},scss:{name:"SCSS",aliases:["scss"]},solidity:{name:"Solidity",aliases:["sol"]},sql:{name:"SQL",aliases:["sql"]},swift:{name:"Swift",aliases:["swift"]},typescript:{name:"TypeScript",aliases:["ts","tsx"]},vbnet:{name:"VB.Net",aliases:["vbnet"]},verilog:{name:"Verilog",aliases:["v"]},vhdl:{name:"VHDL",aliases:["vhdl"]},"visual-basic":{name:"Visual Basic",aliases:["vb","vba"]},wasm:{name:"WebAssembly",aliases:["wasm"]},yaml:{name:"YAML",aliases:["yaml"]}};function eD(n){const t=n.toLocaleLowerCase();let e="";return Object.entries(ua).forEach(([o,r])=>{(o===t||r.aliases.includes(t)||r.name.toLocaleLowerCase()===t)&&(e=o)}),e}function C4(n){const t=n.settingsProvider.getItem("editor-code-lang");return t!=null?t:"plain"}function nD(n,t){return n.settingsProvider.setItem("editor-code-lang",t)}const oD=w("convert-to-code");function rD(n,t){if(!_(n,t))return null;const e={id:P(),type:"text",text:[]},o=P();n.doc.localInsertChildContainer(o,[e]);const r=n.getBlockData(t).text;u(oD,r,"no text");let i=vt(r);i.startsWith("```")&&(i=i.substring(3));const s=eD(i)||C4(n)||"plain";return{blockData:{id:P(),type:"code",language:s,children:[o]},focusBlockId:e.id}}const kV="",F1=w("code-block-child-container");function ci(n){u(F1,Ro(n),"not a code block");const e=st(n).querySelector(":scope > div.editor-code-root > div.code-text-root [data-type=editor-container].child");return u(F1,e,"no code text container"),e}function ai(n){u(F1,Ro(n),"not a code block");const e=st(n).querySelector(":scope > div.editor-code-root > div.code-caption-root [data-type=editor-container].child");return e||null}function da(n){const t=[ci(n)],e=ai(n);return e&&t.push(e),t}function ui(n,t){if(!_(n,t))return!1;const e=z(t),o=U(e);return o?Ro(o)?e===ci(o):it(t)==="code":!1}const H1=w("code-caption");function iD(n,t){if(n.readonly)return;const e=ai(t);if(e){const c=Ft(e);n.selection.selectBlock(c,0);return}const o=Bn(n.doc),r=n.getBlockData(t);u(H1,r.children.length===1,"code block should have only one child");const i={...r,children:[r.children[0],o]};n.updateBlockData(t,i);const s=n.getContainerById(o),l=Ft(s);n.selection.selectBlock(l,0)}function A4(n,t){const e=z(t);if(Ct(e))return!1;const o=U(e);if(u(H1,o,"no parent block"),!Ro(o))return!1;const i=ai(o);return e===i}function sD(n,t){if(n.readonly||!ai(t))return;const o=ci(t),r=Jt(o);n.selection.selectBlock(r,G(n,r));const i=n.getBlockData(t);u(H1,i.children.length===2,"code block should have only one child");const s=i.children[1],l={...i,children:[i.children[0]]};n.updateBlockData(t,l),n.deleteChildContainers([s])}const lD=w("paste-in-table-block");class cD{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePaste(t,e,o){if(!t.selection.range.isSimple())return!1;const r=t.selection.range.start,i=t.getBlockById(r.blockId),s=z(i);if(Ct(s))return!1;const l=U(s);if(u(lD,l,"no parent block"),!Ro(l)||A4(t,i))return!1;const c=o["text/plain"];return c&&t.undoManager.runInGroup(()=>{t.clearSelectedContents(),t.insertDoc(i,r.offset,c)}),!0}}function aD(n){n.addCustom("code-block-paste-event",t=>new cD(t))}class uD{constructor(t){h(this,"id","CodeBlockCommandProvider");setTimeout(()=>{t.editorCommandProviders.registerCommandProvider(this)})}destroy(){}getAvailableCommands(){return[]}executeCommand(){return!1}filterCommands(t,e,o,r){if(ui(t,e))return[]}beforeExecuteCommand(t,e,o,r,i){return!!ui(t,e)}}function dD(n){n.addCustom("code-block-command-provider",t=>new uD(t))}const hD=w("code-caption-input-handler");function j1(n){if(!n.selection.range.isSimple())return null;const t=n.selection.range.start;if(!t.isSimple())return null;const e=n.getBlockById(t.blockId);return A4(n,e)?e:null}function fD(n){const t=j1(n);if(!t)return!1;const e=_1(t),o=dt(e);return o?(n.selection.selectBlock(o,0),!0):(n.insertTextBlock("",V(z(e)),K(e)+1),!0)}function mD(n){const t=j1(n);if(!t)return!1;if(Tt(n,t)){const e=_1(t);return sD(n,e),!0}return!1}class z1{constructor(t){setTimeout(()=>{t.input.addHandler(this)})}destroy(){}handleBeforeKeyDown(t,e){return e.key==="Enter"?fD(t):e.key==="Backspace"?mD(t):!1}async handleBeforePaste(t,e,o){const r=j1(t);if(!r)return!1;const i=o["text/plain"];if(!i)return!0;const s=cc(t,i);return s&&t.undoManager.runInGroup(()=>{t.clearSelectedContents();const l=t.selection.range.start;u(hD,l.isSimple(),"not simple position"),t.insertTextToBlock(r,l.offset,s)}),!0}static init(t){t.addCustom("code-block-caption-input-handler",e=>new z1(e))}}const gD=`
|
|
380
380
|
<svg fill="currentColor" focusable="false" viewBox="0 0 24 24" aria-hidden="true" tabindex="-1">
|
|
381
381
|
<path d="M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.9959.9959 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z"></path>
|
|
382
382
|
</svg>`,pD=`
|
|
@@ -387,14 +387,14 @@ $$${r.mathjaxText}$$
|
|
|
387
387
|
<svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" tabindex="-1">
|
|
388
388
|
<path fill="currentColor" d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"></path>
|
|
389
389
|
</svg>
|
|
390
|
-
`;function AD(n,t,e){const r={...n.getBlockData(t),language:e};n.updateBlockData(t,r),Se(n,t).forEach(s=>{Mt(s).forEach(l=>{n.reloadBlock(l)})})}function bD(n,t,e){const r={...n.getBlockData(t),nowrap:e};n.updateBlockData(t,r)}const gr=w("code-block-header"),vD=Object.entries(ua).map(([n,t])=>({id:n,name:t.name,language:t}));function b4(n,t,e){u(gr,Ro(t),"not a code block");const o=Ft(ci(t));n.selection.selectBlock(o,0),e.focusToEditor&&n.focus()}function yD(n,t){if(t){const e=n,{editor:o,codeBlock:r}=e.custom;AD(o,r,t.id);const i=r.querySelector(".code-block-header .language-select .name-label");i.innerText=t.name,nD(o,t.id),o.focus()}}function kD(n,t,e){n.addCustom("code-header-language-select-dropdown",i=>{const s=new Aw(vD,i.rootElement,{placeholder:"Search for a language..."});return s.onSelected=yD,s});const o=b("div",["language-select"],null);b("span",["name-label"],o,e);const r=b("span",["arrow-icon"],o);return r.innerHTML=gD,n.domEvents.addEventListener(o,"click",(i,s)=>{const c=s.target.closest(".language-select"),a=U(c);u(gr,a,"no parent block"),u(gr,it(a)==="code","not a code block");const d=i.getBlockData(a),f=i.getCustom("code-header-language-select-dropdown");f.custom={codeBlock:a,editor:i},f.setSelectedId(d.language),f.show(c),b4(i,a,{focusToEditor:!1}),M(t,"editing-language"),f.onHide=()=>{H(t,"editing-language")}}),o}function wD(){return b("div",["code-header-spacer"],null)}function BD(n,t){const e=t.target,o=e.closest(".code-header-button");u(gr,o,"no button");const r=U(e);u(gr,r,"no parent block");const i=o.getAttribute("data-id");if(u(gr,it(r)==="code","not a code block"),i==="wrap"){const s=n.getBlockData(r);bD(n,r,!s.nowrap);return}if(i==="copy"){b4(n,r,{focusToEditor:!0}),Cc(n,r).then(()=>{const s=o.getBoundingClientRect();bw("Copied to clipboard",{position:{x:s.x+s.width/2,y:s.bottom+30}})}).catch(s=>{gr.error(s.message)});return}i==="caption"&&(iD(n,r),setTimeout(()=>{n.focus()}))}function U1(n,t,e,o){const r=b("button",["code-header-button"],null);if(r.setAttribute("data-id",t),o){const i=b("span",["button-icon"],r);i.innerHTML=o}if(e){const i=b("span",["button-label"],r);i.innerHTML=e}return n.domEvents.addEventListener(r,"click",BD),r}function ED(n,t,e){const o=Rt(t),r=b("div",["code-block-header"],o),i=ua[e.language]||ua.plain;r.appendChild(kD(n,t,i.name)),r.appendChild(wD()),r.appendChild(U1(n,"copy","Copy",pD)),r.appendChild(U1(n,"wrap","Wrap",CD)),r.appendChild(U1(n,"caption","Caption",null))}function ID(n,t){!t.target||setTimeout(()=>{n.selection.caret.update()})}function xD(n,t,e,o){z1.init(n);const r=o.children,i=lo(e,"div");i.setAttribute("data-language",o.language||"text"),p4(n,e,o);const s=b("div",["editor-code-root"],i),l=b("div",["code-text-root"],s),c=n.createChildContainer(t,l,r[0]);if(r.length===2){const a=b("div",["code-caption-root"],s);n.createChildContainer(t,a,r[1])}return n.domEvents.addEventListener(c,"scroll",ID),ED(n,e,o),i}async function TD(n){const t={id:P(),type:"text",text:[]},e=P();n.doc.localInsertChildContainer(e,[t]);const o=await C4(n);return{blockData:{id:P(),type:"code",language:o,children:[e]},focusBlockId:t.id}}const Ln=w("list-block");function SD(n,t,e,o,r){aD(n),dD(n),u(Ln,r.type==="code","invalid block data type");const i=r;return u(Ln,i.children,"invalid block data children"),u(Ln,i.children.length===1||i.children.length===2,"invalid block data children length"),xD(n,t,o,i)}function DD(n){return 1}function LD(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!vn(r))return null;const i=da(t);if(!vn(r))return null;const s=r;if(i.indexOf(s)===-1||Ze(s)>1)return null;const l=Bt(t,V(s));return new tn(n,{anchor:l,focus:l})}function MD(n,t,e,o){return null}function RD(n,t){return n.getBoundingClientRect()}function OD(n,t,e,o){if(e.isSimple()){u(Ln,o.isSimple(),"from is simple position but to is not simple position"),Ln.debug("full select list"),M(t,"full-selected");return}u(Ln,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;u(Ln,r.blockId===i.blockId,"only allow update one table selection"),da(t).forEach(l=>{const c=V(l);(c===r.childContainerId||c===i.childContainerId)&&M(l,"selected")})}function ND(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="code"]').forEach(t=>{H(t,"full-selected"),t.querySelectorAll("div[data-type=editor-container].child.selected").forEach(e=>{H(e,"selected")})})}function PD(n,t){return da(t)}function $D(n,t,e,o,r){if(o==="ArrowDown"||o==="ArrowRight"){if(e===ci(t))return ai(t)}else if(e===ai(t))return ci(t);return null}function _D(n,t,e,o){const r=da(t),i=r.map(V),s=i.indexOf(e.childContainerId),l=i.indexOf(o.childContainerId);u(Ln,s!==-1,"invalid start pos"),u(Ln,l!==-1,"invalid end pos");const c=[r[s]];return s!==l&&c.push(r[l]),c}function FD(n,t,e){u(Ln,Ro(t),"invalid block type"),p4(n,t,e)}async function HD(n,t){const e=await TD(n);if(!e)return null;const{blockData:o,focusBlockId:r}=e;return n.insertBlock(t.containerId,t.blockIndex,o,Ot(n,r,0))}function jD(n){return{name:"CodeBlock",insertBlockCommandItems:[{id:"insert-code",name:
|
|
390
|
+
`;function AD(n,t,e){const r={...n.getBlockData(t),language:e};n.updateBlockData(t,r),Se(n,t).forEach(s=>{Mt(s).forEach(l=>{n.reloadBlock(l)})})}function bD(n,t,e){const r={...n.getBlockData(t),nowrap:e};n.updateBlockData(t,r)}const gr=w("code-block-header"),vD=Object.entries(ua).map(([n,t])=>({id:n,name:t.name,language:t}));function b4(n,t,e){u(gr,Ro(t),"not a code block");const o=Ft(ci(t));n.selection.selectBlock(o,0),e.focusToEditor&&n.focus()}function yD(n,t){if(t){const e=n,{editor:o,codeBlock:r}=e.custom;AD(o,r,t.id);const i=r.querySelector(".code-block-header .language-select .name-label");i.innerText=t.name,nD(o,t.id),o.focus()}}function kD(n,t,e){n.addCustom("code-header-language-select-dropdown",i=>{const s=new Aw(vD,i.rootElement,{placeholder:"Search for a language..."});return s.onSelected=yD,s});const o=b("div",["language-select"],null);b("span",["name-label"],o,e);const r=b("span",["arrow-icon"],o);return r.innerHTML=gD,n.domEvents.addEventListener(o,"click",(i,s)=>{const c=s.target.closest(".language-select"),a=U(c);u(gr,a,"no parent block"),u(gr,it(a)==="code","not a code block");const d=i.getBlockData(a),f=i.getCustom("code-header-language-select-dropdown");f.custom={codeBlock:a,editor:i},f.setSelectedId(d.language),f.show(c),b4(i,a,{focusToEditor:!1}),M(t,"editing-language"),f.onHide=()=>{H(t,"editing-language")}}),o}function wD(){return b("div",["code-header-spacer"],null)}function BD(n,t){const e=t.target,o=e.closest(".code-header-button");u(gr,o,"no button");const r=U(e);u(gr,r,"no parent block");const i=o.getAttribute("data-id");if(u(gr,it(r)==="code","not a code block"),i==="wrap"){const s=n.getBlockData(r);bD(n,r,!s.nowrap);return}if(i==="copy"){b4(n,r,{focusToEditor:!0}),Cc(n,r).then(()=>{const s=o.getBoundingClientRect();bw("Copied to clipboard",{position:{x:s.x+s.width/2,y:s.bottom+30}})}).catch(s=>{gr.error(s.message)});return}i==="caption"&&(iD(n,r),setTimeout(()=>{n.focus()}))}function U1(n,t,e,o){const r=b("button",["code-header-button"],null);if(r.setAttribute("data-id",t),o){const i=b("span",["button-icon"],r);i.innerHTML=o}if(e){const i=b("span",["button-label"],r);i.innerHTML=e}return n.domEvents.addEventListener(r,"click",BD),r}function ED(n,t,e){const o=Rt(t),r=b("div",["code-block-header"],o),i=ua[e.language]||ua.plain;r.appendChild(kD(n,t,i.name)),r.appendChild(wD()),r.appendChild(U1(n,"copy","Copy",pD)),r.appendChild(U1(n,"wrap","Wrap",CD)),r.appendChild(U1(n,"caption","Caption",null))}function ID(n,t){!t.target||setTimeout(()=>{n.selection.caret.update()})}function xD(n,t,e,o){z1.init(n);const r=o.children,i=lo(e,"div");i.setAttribute("data-language",o.language||"text"),p4(n,e,o);const s=b("div",["editor-code-root"],i),l=b("div",["code-text-root"],s),c=n.createChildContainer(t,l,r[0]);if(r.length===2){const a=b("div",["code-caption-root"],s);n.createChildContainer(t,a,r[1])}return n.domEvents.addEventListener(c,"scroll",ID),ED(n,e,o),i}async function TD(n){const t={id:P(),type:"text",text:[]},e=P();n.doc.localInsertChildContainer(e,[t]);const o=await C4(n);return{blockData:{id:P(),type:"code",language:o,children:[e]},focusBlockId:t.id}}const Ln=w("list-block");function SD(n,t,e,o,r){aD(n),dD(n),u(Ln,r.type==="code","invalid block data type");const i=r;return u(Ln,i.children,"invalid block data children"),u(Ln,i.children.length===1||i.children.length===2,"invalid block data children length"),xD(n,t,o,i)}function DD(n){return 1}function LD(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!vn(r))return null;const i=da(t);if(!vn(r))return null;const s=r;if(i.indexOf(s)===-1||Ze(s)>1)return null;const l=Bt(t,V(s));return new tn(n,{anchor:l,focus:l})}function MD(n,t,e,o){return null}function RD(n,t){return n.getBoundingClientRect()}function OD(n,t,e,o){if(e.isSimple()){u(Ln,o.isSimple(),"from is simple position but to is not simple position"),Ln.debug("full select list"),M(t,"full-selected");return}u(Ln,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;u(Ln,r.blockId===i.blockId,"only allow update one table selection"),da(t).forEach(l=>{const c=V(l);(c===r.childContainerId||c===i.childContainerId)&&M(l,"selected")})}function ND(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="code"]').forEach(t=>{H(t,"full-selected"),t.querySelectorAll("div[data-type=editor-container].child.selected").forEach(e=>{H(e,"selected")})})}function PD(n,t){return da(t)}function $D(n,t,e,o,r){if(o==="ArrowDown"||o==="ArrowRight"){if(e===ci(t))return ai(t)}else if(e===ai(t))return ci(t);return null}function _D(n,t,e,o){const r=da(t),i=r.map(V),s=i.indexOf(e.childContainerId),l=i.indexOf(o.childContainerId);u(Ln,s!==-1,"invalid start pos"),u(Ln,l!==-1,"invalid end pos");const c=[r[s]];return s!==l&&c.push(r[l]),c}function FD(n,t,e){u(Ln,Ro(t),"invalid block type"),p4(n,t,e)}async function HD(n,t){const e=await TD(n);if(!e)return null;const{blockData:o,focusBlockId:r}=e;return n.insertBlock(t.containerId,t.blockIndex,o,Ot(n,r,0))}function jD(n){return{name:"CodeBlock",insertBlockCommandItems:[{id:"insert-code",name:T.t("code.title"),icon:Jw,order:300,group:"common",subText:Ce("insert-code")}],handleInsertEmptyBlock:HD}}function zD(){return{abstract:`[${T.t("code.abstract")}]`}}function UD(n,t,e,o){const r=t,i=c=>{const a=[];return e.blocks[c].forEach(f=>{var m;a.push(vt((m=f.text)!=null?m:[]))}),a.join(`
|
|
391
391
|
`)},s=i(r.children[0]),l=r.children[1]?i(r.children[1]):"";return o==="text"?`${s}
|
|
392
392
|
${l}`:o==="markdown"?`\`\`\`${r.language}
|
|
393
393
|
${s}
|
|
394
394
|
\`\`\`
|
|
395
395
|
${l}`:`<p><pre><code>${s}</code></pre></p>
|
|
396
396
|
<p>${l}</p>`}function VD(n,t,e,o,r){return!1}const Qs={blockType:"code",blockKind:"complex",createBlockContent:SD,getBlockTextLength:DD,getRangeFromPoint:LD,moveCaret:MD,getCaretRect:RD,updateSelection:OD,clearSelection:ND,getChildContainers:PD,getNextContainer:$D,getSelectedContainers:_D,convertFrom:rD,handleBlockElementUpdated:FD,getOptions:jD,getBlockProperties:zD,convertTo:UD,handleDropOver:VD},V1={...ye,blockType:"code-line"};class qD{constructor(t){h(this,"handleSelectionChange",()=>{const t=this.editor.selection;if(!t.range.isCollapsed())return;const e=t.focusedBlock;if(!ui(this.editor,e))return;const o=e,r=t.range.focus.offset,i=jg(this.editor,o,r,"code-caret");i.scrollIntoView({block:"nearest"}),setTimeout(()=>{i.remove(),this.editor.selection.caret.update()})});this.editor=t,t.addListener("selectionChanged",this.handleSelectionChange)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChange)}}function v4(n,t){const e=n.split(`
|
|
397
|
-
`).map(s=>({id:P(),type:"text",text:Co(s)})),o=P();return{blocks:{root:[{children:[o],type:"code",id:P(),...t}],[o]:e},meta:{},comments:{}}}class WD{handleBeforeCopy(t,e,o){const r=t.getFocusedBlock();if(!ui(t,r))return;const i=_1(r),s=t.getBlockData(i),{language:l,nowrap:c}=s;if(t.selection.range.isCollapsed()){const d=t.getBlockString(r);return v4(d,{language:l,nowrap:c})}const a=t.getSelectedText();return v4(a,{language:l,nowrap:c})}}function GD(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!ui(n,t)){if(n.selection.range.isCollapsed()){const e=n.selection.range.start;return n.insertTextToBlock(t,e.offset," "),!0}return n.undoManager.runInGroup(()=>{en(n).forEach(o=>{n.insertTextToBlock(o.block,0," ")})}),!0}}function ZD(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!ui(n,t))return;const e=[" "," "];return n.undoManager.runInGroup(()=>{en(n).forEach(r=>{const i=vt(n.getBlockText(r.block));for(let s=0;s<e.length;s++){const l=e[s];if(i.startsWith(l)){n.deleteTextFromBlock(r.block,0,l.length);break}}})}),!0}function QD(n){const t=n.getFocusedBlock(),e=z(t);if(Ct(e))return;const o=U(e);if(!o||it(o)!=="code")return;const r=n.selection.range;if(!!r.isSimple()&&!G0(e,r))return Vd(n,e),!0}const YD={Tab:GD,"Shift+Tab":ZD,"CtrlOrCmd+A":QD},Ys=w("code-text-decorate");class Js{decorateText(t,e,o){var p;if(u(Ys,e.length>0,"invalid path"),e.length===1)return{};const r=e[e.length-2];if(t.doc.getBlockData(r.containerId,r.blockIndex).type!=="code")return{};const s=o;if(s.length===0)return{};const l=vt(s),c=t.doc.getBlockData(r.containerId,r.blockIndex),a=Oi.default.tokenize(l,(p=Oi.default.languages[c.language])!=null?p:Oi.default.languages.plain),d=(A,k)=>{if(u(Ys,A,"no token"),typeof A=="string")return[{insert:A,attributes:Q.default(k)}];u(Ys,A instanceof Oi.default.Token,"invalid token type");const v=A.content,T=Q.default(k);return T[`style-code-${A.type}`]=!0,typeof v=="string"?[{insert:v,attributes:T}]:Array.isArray(v)?v.map(R=>d(R,T)).flat():(u(Ys,v instanceof Oi.default.Token,"invalid token"),d(v,T))},m=a.map(A=>d(A,{})).flat();return u(Ys,me(m)===me(s),"failed to highlight code, text length mismatch"),{text:m}}}const JD={code:{title:"\u4EE3\u7801",abstract:"\u4EE3\u7801"}},KD={code:{title:"Code",abstract:"Code"}};x.mergeLang({"zh-CN":JD,"en-US":KD});const XD=w("image-data"),tL=1e3,eL=400,nL=10;function Ks(n){return n.src.startsWith("empty:")||!n.src}function oL(n){return n.src.startsWith("http:")||n.src.startsWith("https:")}function y4(n){return`${Er.default(n)}_width`}function k4(n){return`${Er.default(n)}_height`}function w4(n){return`${n}_flex`}function Xs(n){if(n.every(r=>typeof r.flex=="number"&&r.flex))return;const t=100,o=n.map(r=>r.width/(r.height/t)).reduce((r,i)=>r+i,0);n.forEach(r=>{const i=r.width/(r.height/t);r.flex=i/o})}function di(n){const t=(r,i)=>{r||(r=`empty:${i}`);const s=y4(r),l=k4(r),c=w4(i);let a=n[s],d=n[l],f=n[c];return typeof a=="string"&&(a=Number.parseInt(a,10)),typeof d=="string"&&(d=Number.parseInt(d,10)),typeof f=="string"&&(f=Number.parseInt(f,10)),a&&d?{src:r,width:a,height:d,flex:f,virtualSize:!1}:(a=tL,d=eL,{src:r,width:a,height:d,flex:f,virtualSize:!0})};let e=[];const o=n.src;return Array.isArray(o)?e=o.map(t):typeof o=="string"&&(e=o.split("|").map(t)),Xs(e),e}function fn(n){var o;const t=n.embedData;return di(n.embedData).length>1?100:(o=t.widthPercent)!=null?o:100}function rL(n,t){if(di(t.embedData).length>1)return"100%";const o=fn(t);return`${n.rootContainer.getBoundingClientRect().width*o/100}px`}function ae(n,t){const o={src:n.map(r=>r.src).join("|"),widthPercent:t};return n.forEach((r,i)=>{if(r.width&&r.height&&!r.virtualSize){const l=r.src||`empty:${i}`,c=y4(l);o[c]=r.width;const a=k4(l);o[a]=r.height}u(XD,r.flex,"no image flex");const s=w4(i);o[s]=r.flex}),o}function iL(n,t,e){const o=di(t.embedData),r=o.length===1?n.rootContainer:e,i=fn(t);let s=r.getBoundingClientRect().width*(i/100);if(s-=Number.parseFloat(window.getComputedStyle(r).paddingLeft)+Number.parseFloat(window.getComputedStyle(r).paddingRight),o.length===1){const a=o[0];return a.height/(a.width/s)}s-=(o.length-1)*nL;const l=o.reduce((a,d)=>a+d.flex,0);let c=0;for(const a of o){const f=s*a.flex/l/a.width*a.height;c=Math.max(f,c)}return c}function sL(n){return n.reduce((e,o)=>e+o.flex,0)}const lL=w("image-dom");function B4(n){return n.querySelector(".uploading-progress-mask")}function cL(n){const t=B4(n);if(t)return t;const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e);return b("div",["uploading-progress-bar-value"],o),o}function aL(n){const e=cL(n).querySelector(".uploading-progress-bar-value");return u(lL,e,"no progress value"),e}function E4(n,t){const e=aL(n);e.style.width=`${t}%`}function uL(n){var t;(t=B4(n))==null||t.remove()}function dL(n){let t;return n.forEach((e,o)=>{o.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function hL(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),o=dL(t.headers).toLocaleLowerCase();let r="";if(o){const s=au.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([e],`${Date.now()}.${r}`,{type:o})}catch{return null}}function pr(n,t){const e=typeof t=="string"?t:j(t);return n.getCustom(`image-${e}`)}function ha(n,t){if(!t||!(t instanceof Node))return null;const e=U(t);return e?pr(n,e):null}function Kn(n){return Array.from(n.querySelectorAll(".image-container"))}function fa(n,t,e,o){const r=e!=null?e:n.findBlockById(t.id);if(!r)return;const i=o||z(r),s=rL(n,t),l=iL(n,t,i),c=st(r);c.style.width=s;const a=r.querySelector(".images");!a||(a.style.height=`${l}px`)}const q1=w("table-resize-drag-drop");class fL{constructor(t,e,o,r){h(this,"cursor","col-resize");h(this,"initWidths");this.editor=t,this.elem=e,this.data=o,this.mouseDownEvent=r;const i=this.data.block,l=pr(this.editor,i).getImages(),c=this.data.splitterIndex;u(q1,c>=0&&c<l.length-1,`invalid splitter index: ${c}`);const d=Kn(i).map(f=>f.getBoundingClientRect().width);this.initWidths=d}onDragStart(t,e,o){if(!this.editor.isWritable())return;const r=this.data.block;pr(this.editor,r).setResizing(!0)}onDragging(t,e,o,r,i){const s=this.data.block,l=pr(this.editor,s),c=Q.default(l.getImages()),a=this.data.splitterIndex;u(q1,a>=0&&a<c.length-1,`invalid splitter index: ${a}`);const d=this.initWidths[a],f=this.initWidths[a+1];if(d+f<100)return;let m=r;d+m<50&&(m=50-d),f-m<50&&(m=f-50);const k=[...this.initWidths];k[a]+=m,k[a+1]-=m;const v=Kn(s);u(q1,v.length===c.length,"invalid image data");const T=k.reduce((R,$)=>R+$,0);for(let R=0;R<c.length;R++){const $=k[R]/T;c[R].flex=$,v[R].style.flexGrow=`${$}`}const E=Q.default(this.editor.getBlockData(s)),L=ae(c,fn(E));E.embedData=L,fa(this.editor,E,s,null)}onDragEnd(t,e,o,r,i){const s=this.data.block,l=pr(this.editor,s),a=Kn(s).map(d=>Number.parseFloat(d.style.flexGrow));l.updateFlex(a),l.setResizing(!1)}}function I4(n){var t;return!n||!(n instanceof HTMLElement)?null:rt(n,"image-splitter")?n:(t=n.closest(".image-splitter"))!=null?t:null}function mL(n,t){var s;const e=I4(t.target);if(!e)return;const o=U(e);if(!o)return;pr(n,o).setSelectedIndex(-1),n.selection.selectBlock(o,0);const r=Number.parseInt((s=e.getAttribute("data-index"))!=null?s:"",10);if(Number.isNaN(r)||typeof r!="number")return;const i={block:o,splitterIndex:r};Cu(new fL(n,e,i,t))}function gL(n,t){t.preventDefault(),t.stopPropagation();const e=I4(t.target);if(!e)return;const o=U(e);!o||pr(n,o).resetFlex()}function pL(n,t,e,o){const r=b("div",["image-splitter"],e);b("div",["image-splitter-indicator"],r),r.setAttribute("data-index",`${o}`),n.domEvents.addEventListener(r,"mousedown",mL),n.domEvents.addEventListener(r,"dblclick",gL)}const CL=w("image-item");function x4(n){return!n||!(n instanceof Node)?null:U(n)}function T4(n){const t=x4(n);return t?Kn(t):[]}function W1(n){if(!n||!(n instanceof Node))return null;const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest(".image-container");return e||null}function tl(n){const t=W1(n);return t?T4(n).indexOf(t):-1}async function AL(n,t){const e=ha(n,t.target);if(!e)return;const o=tl(t.target);if(o===-1)return;const r=t.target;if(!(r instanceof HTMLImageElement))return;const i=e.getImages()[o];if(i.virtualSize&&e.fixImageSize(o,r),!i||!oL(i)||i.downloading)return;i.downloading=!0;const s=await hL(i.src);s?e.replaceImage(o,s):CL.warn(`failed to download image: ${i.src}`)}function bL(n,t,e){if(t.querySelector(".load-error"))return;const r=e.src.startsWith("http:")||e.src.startsWith("https:"),i=b("div",["load-error"],t),s=b("div",["error-icon"],i);s.innerHTML=v5;const l=b("div",["error-message"],i);r?(l.innerHTML=x.t("image.load.remote.failed"),n.domEvents.addEventListener(i,"click",(c,a)=>{a.preventDefault(),a.target instanceof HTMLElement&&a.target.tagName==="A"&&window.open(e.src,"_blank")})):(l.innerHTML=x.t("image.load.failed"),n.domEvents.addEventListener(i,"click",(c,a)=>{a.preventDefault(),a.target instanceof HTMLElement&&a.target.tagName==="A"&&wL(c,a.target)}))}function vL(n,t){const e=ha(n,t.target);if(!e)return;const o=tl(t.target);if(o===-1)return;const r=e.getImages()[o];if(!r)return;const i=W1(t.target);!i||(M(i,"error","error-load"),bL(n,i,r))}function yL(n,t,e){if(t.querySelector(".upload-error"))return;const r=b("div",["upload-error"],t),i=b("div",["error-icon"],r);i.innerHTML=v5;const s=b("div",["error-message"],r);s.innerHTML=x.t("image.upload.failed"),n.domEvents.addEventListener(r,"click",(l,c)=>{if(c.preventDefault(),!c.target||!(c.target instanceof Element)||c.target.tagName!=="A")return;const a=ha(l,c.target),d=tl(c.target);!a||d===-1||a.replaceImage(d,e)})}function S4(n,t,e,o,r){const i=Kn(t)[e];!i||(M(i,"error","error-upload"),yL(n,i,r))}function D4(n,t,e,o,r,i){const s=b("div",["image-container"],t);if(s.setAttribute("data-src",e.src),i.length>1&&(s.style.flexShrink=`${e.flex}`,s.style.flexGrow=`${e.flex}`),r===o&&M(s,"active"),Ks(e)){M(s,"empty");const c=b("div",["upload-image-icon"],s);return c.innerHTML=Ow,s}const l=b("img",["editor-image"],s);if(l.src=n.doc.buildResourceUrl(e.src),l.draggable=!0,!Ks(e)&&!n.readonly&&n.domEvents.addEventListener(l,"load",AL),n.domEvents.addEventListener(l,"error",vL),e.src.startsWith("https:")||e.src.startsWith("http:")){const c=b("div",["image-warning"],s);c.innerHTML=b5,c.setAttribute(`data-editor-tooltip-${n.clientId}`,x.t("image.load.remote.tooltip"))}return s}function kL(n,t,e,o,r){const i=b("div",["images"],e);return o.forEach((s,l)=>{l>0&&pL(n,t,i,l-1),D4(n,i,s,l,r,o)}),o.length>1&&M(t,"multi"),i}function L4(n,t,e,o,r,i){const l=Array.from(t.querySelectorAll(".image-container"))[o];if(!l)return;const c=D4(n,null,e,o,r,i);l.insertAdjacentElement("beforebegin",c),l.remove()}function el(n,t){return Kn(n)[t]}function wL(n,t){const e=x4(t);if(!e)return;const o=tl(t);if(o===-1)return;const r=ha(n,t);if(!r)return;const i=r.getImages()[o];L4(n,e,i,o,r.getSelectedIndex(),r.getImages())}function mn(n){return it(n)==="embed"&&Ne(n)==="image"}async function M4(n){return new Promise((t,e)=>{const o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=e,o.src=n})}async function BL(n){const t=await Tr(n);return M4(t)}const R4=w("image-object");class Ut{constructor(t,e){h(this,"images",[]);h(this,"selectedIndex",-1);h(this,"blockResizer");h(this,"resizing",!1);h(this,"parentContainerResizerObserver",null);h(this,"handleMouseDown",async(t,e)=>{const o=tl(e.target);if(o===-1)return;const r=this.images[o];Ks(r)||this.setSelectedIndex(o)});h(this,"handleEditorResize",()=>{if(this.isEmpty()||this.resizing)return;const t=this.editor.findBlockById(this.blockData.id);!t||fa(this.editor,this.blockData,t,null)});h(this,"handleResizing",(t,e)=>{const o=this.editor.findBlockById(this.blockData.id);if(!o)return;const i=this.editor.rootContainer.getBoundingClientRect().width,s=o.getBoundingClientRect();let l=e.width>s.width?s.width:e.width;l<50&&(l=50);const c=l*100/i;this.blockData.embedData.widthPercent=c,fa(this.editor,this.blockData,o,null)});h(this,"handleResized",t=>{const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const o=ae(this.images,fn(this.blockData));this.editor.updateEmbedData(e,o),this.blockResizer.enableResize(e)});h(this,"fixImageSizes",ee.default(()=>{const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=ae(this.images,fn(this.blockData));this.editor.updateEmbedData(t,e)},1e3));this.editor=t,this.blockData=e,this.blockResizer=new sa(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}),this.blockResizer.addListener("resizing",this.handleResizing),this.blockResizer.addListener("resized",this.handleResized),this.images=di(this.blockData.embedData)}destroy(){var t;this.blockResizer.removeAllListeners(),this.blockResizer.destroy(),this.editor.domEvents.removeEventListener(null,null,this.handleMouseDown),(t=this.parentContainerResizerObserver)==null||t.disconnect()}createContent(t,e,o){const r=kL(this.editor,e,o,this.images,this.selectedIndex);this.editor.domEvents.addEventListener(o,"mousedown",this.handleMouseDown),this.editor.addListener("resize",this.handleEditorResize),Ke(t)&&(this.parentContainerResizerObserver=new ResizeObserver(this.handleEditorResize),this.parentContainerResizerObserver.observe(t)),this.isEmpty()?M(r,"empty"):fa(this.editor,this.blockData,e,t),setTimeout(()=>{const i=this.editor.findBlockById(this.blockData.id);i&&this.blockResizer.update(i)})}getImages(){return this.images}getWidthPercent(){return fn(this.blockData)}isEmpty(){return this.images.length===1&&Ks(this.images[0])}setResizing(t){this.resizing=t}getSelectedIndex(){return this.selectedIndex}getBlock(){return this.editor.findBlockById(this.blockData.id)}setSelectedIndex(t){const e=this.getBlock();if(!e||t===this.selectedIndex)return;if(this.selectedIndex!==-1){const r=el(e,this.selectedIndex);r&&H(r,"active")}this.selectedIndex=t;const o=el(e,t);o&&M(o,"active")}async requestUploadImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const o=el(e,t);if(rt(o,"error"))return;const r=await Qo("image/*");await this.replaceImage(t,r)}tryEnableResizer(){const t=this.editor.findBlockById(this.blockData.id);if(!t||!this.editor.isWritable())return;const e=el(t,0);!this.isEmpty()&&this.images.length===1&&!rt(e,"error")&&this.blockResizer.enableResize(t)}disableResizer(){this.blockResizer.disableResize()}fixImageSize(t,e){const o=this.images[t];Ks(o)||(o.width=e.naturalWidth,o.height=e.naturalHeight,o.virtualSize=!1,this.fixImageSizes())}removeImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e||t===-1||t>=this.images.length)return!1;const o=Q.default(this.images);o.splice(t,1),o[0].flex=NaN,Xs(o),this.selectedIndex>=o.length&&(this.selectedIndex=o.length-1);const r=ae(o,fn(this.blockData));return this.editor.updateEmbedData(e,r),!0}async replaceImage(t,e){const o=this.editor.findBlockById(this.blockData.id);if(!o)return!1;try{const i=await Tr(e),s=this.images[t];if(s.virtualSize){const{width:c,height:a}=await M4(i);s.width=c,s.height=a,s.virtualSize=!1;const d=ae(this.images,fn(this.blockData));this.editor.updateEmbedData(o,d)}const l={...s,src:i};L4(this.editor,o,l,t,this.selectedIndex,this.images),setTimeout(()=>{this.blockResizer.update(o)})}catch(i){return S4(this.editor,o,t,i,e),!1}const r=el(o,t);if(!r)return!1;M(r,"uploading"),E4(r,0);try{const i=await this.editor.doc.uploadResource(e,{onProgress:c=>{E4(r,c)}});H(r,"uploading"),this.images[t].src=i.resourceId;const s=this.editor.findBlockById(this.blockData.id);if(!s)return!1;const l=ae(this.images,fn(this.blockData));return this.editor.updateEmbedData(s,l),!0}catch(i){R4.error(i);const s=this.editor.findBlockById(this.blockData.id);return s&&(H(r,"uploading"),uL(r),S4(this.editor,s,t,i,e)),!1}}updateFlex(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;u(R4,t.length===this.images.length,"invalid flex");for(let r=0;r<this.images.length;r++)this.images[r].flex=t[r];const o=ae(this.images,fn(this.blockData));this.editor.updateEmbedData(e,o)}resetFlex(){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=Q.default(this.images);e[0].flex=NaN,Xs(e);const o=ae(e,fn(this.blockData));this.editor.updateEmbedData(t,o)}setData(t){this.blockData=t,this.images=di(t.embedData)}static create(t,e){const o=t.addCustom(`image-${e.id}`,()=>new Ut(t,e));return o.setData(e),o}static getImageObject(t,e){let o;return typeof e=="string"?o=e:o=j(e),t.getCustom(`image-${o}`)}}const wV="";function O4(n,t,e){const o=Ut.getImageObject(n,t),r=Q.default(o.getImages());if(r.length===1){n.deleteBlock(t);return}if(e===-1||e>=r.length)return;const i=sL(r);if(r.splice(e,1),r.length===1){const l=r[0],c=100*(l.flex/i);l.flex=1;const a=ae([l],c);n.updateEmbedData(t,a);return}r[0].flex=NaN,Xs(r);const s=ae(r,o.getWidthPercent());n.updateEmbedData(t,s)}function EL(n,t,e,o){if(t.length===0||o==="after"||o==="before")return!1;let r=o.data;const i=Ut.getImageObject(n,e),s=Q.default(i.getImages());return t.forEach(l=>{const c={src:"",flex:1,width:0,height:0,virtualSize:!0};s.splice(r,0,c);const a=ae(s,i.getWidthPercent());n.updateEmbedData(e,a),i.replaceImage(r,l),r+=1}),!0}function IL(n,t,e,o,r){var s,l,c;if(Pl(e))return EL(n,e,t,o);if(e.type!=="custom"||e.customType!=="image"||!e.data)return;const i=e.data;if(r.isSourceBlock){const a=r.targetBlock,d=z(a);let f=K(a);o==="after"&&(f+=1);const p=100*(i.boundingRect.width/n.rootContainer.getBoundingClientRect().width),A=ae([i.image],p),k={id:P(),type:"embed",embedType:"image",embedData:A},v=(l=(s=n.options.componentsOptions)==null?void 0:s.image)==null?void 0:l.defaultAlign;v&&(k.align=v),n.insertBlock(V(d),f,k),O4(n,t,i.index),(c=n.findCustom("drag-handler"))==null||c.handleDragEnd()}else{if(typeof o=="string")return;const a=t;let d=o.data;const f=Ut.getImageObject(n,a),m=Q.default(f.getImages());d>m.length&&(d=m.length),n.undoManager.runInGroup(()=>{var A,k;const p=n.getBlockById(e.blockId);if(p===a){const v=i.index,T=d,E=i.image;if(v===T||T===v+1)return;let L=T;v<T?(m.splice(T,0,E),m.splice(v,1),L-=1):(m.splice(v,1),m.splice(T,0,E));const R=ae(m,f.getWidthPercent());n.updateEmbedData(a,R),f.setSelectedIndex(L),(A=n.findCustom("drag-handler"))==null||A.handleDragEnd()}else{m.splice(d,0,i.image),m[0].flex=NaN,Xs(m);const v=ae(m,f.getWidthPercent());n.updateEmbedData(a,v),O4(n,p,i.index),(k=n.findCustom("drag-handler"))==null||k.handleDragEnd()}})}return!0}const xL=2;function ma(n,t,e){const o=Kn(t);if(e<=0){const s=o[0].getBoundingClientRect();return new DOMRect(s.left-4,s.top,2,s.height)}if(e===o.length){const s=o[e-1].getBoundingClientRect();return new DOMRect(s.right+2,s.top,2,s.height)}const r=o[e-1].getBoundingClientRect(),i=o[e].getBoundingClientRect();return new DOMRect((i.left+r.right)/2-1,r.top,xL,r.height)}function TL(n,t,e,o,r){for(let i=0;i<e.length;i++){const l=e[i].getBoundingClientRect();if(o<=l.right)return o<=l.left+l.width/2?{rect:ma(n,t,i),data:i}:{rect:ma(n,t,i+1),data:i+1}}return o>e[e.length-1].getBoundingClientRect().right?{rect:ma(n,t,e.length),data:e.length}:{rect:ma(n,t,e.length),data:0}}function SL(n,t,e,o,r){const i=Kn(t);if((e==null?void 0:e.type)==="block"||i.length>=6&&(e==null?void 0:e.blockId)!==j(t))return;const s=j(t);if(!(i.length===1&&s===(e==null?void 0:e.blockId)))return TL(n,t,i,o)}const BV="";function ga(n){const t=Rt(n);let e=t.querySelector(":scope > .block-helper");return e||(e=b("div",["block-helper"],t),b("span",["helper-sizer"],e,"A")),e}function G1(n,t,e){const o=ga(n),i=Array.from(o.children).find(s=>{var c;return Number.parseInt((c=s.getAttribute("data-index"))!=null?c:"0",10)>e});o.insertBefore(t,i!=null?i:null)}const N4=40,DL=20;class LL{findTargetBlock(t,e){const o=e.target;if(o&&o instanceof Element){const c=U(o);if(c&&wt(t.rootContainer,c))return c}let r=e.clientX,i=e.clientY;const s=t.rootContainer.getBoundingClientRect().left;r<s&&s-r<N4&&(r+=N4);let l=document.elementFromPoint(r,i);if(l){const c=U(l);if(c&&wt(t.rootContainer,c))return c}if(i-=DL,l=document.elementFromPoint(r,i),l){const c=U(l);if(c&&wt(t.rootContainer,c))return c}return null}destroy(){}}class ML extends ea{constructor(e){super(e,{trigger:[],id:"empty-block-menu"});h(this,"currentBlock",null)}get isVisible(){return this.suggest.menu.isVisible}isInMenu(e){return this.menu.isInCommandBar(e)}show(){const o=this.editor.selection.focusedBlock;this.suggest.popup(o,0,"","")}setBlock(e){this.currentBlock=e}}function RL(n,t,e){const o=Fu(n,t);if(!o)return[];const r=[];return Object.values(o).forEach(i=>{e!=null&&e.has(i.group)||r.push(...i.commands.map(s=>({...s,source:"block-command",blockMenuItemCustomData:i.group})))}),r}function Z1(n,t){const e=w1(n),o=r=>{r.forEach(i=>{i.source=t,i.children&&o(i.children)})};return o(e),e}function OL(n,t,e,o=!1){var a,d;const r=z(t);let s=K(t);Tt(n,t)||o||(s+=1);const l=V(r),c=e;return c.commandProvider?c.commandProvider.executeCommand(n,e,{from:"block-menu",containerId:l,blockIndex:s}):(d=(a=c.blockOptions)==null?void 0:a.handleInsertEmptyBlock)==null?void 0:d.call(a,n,{containerId:l,blockIndex:s,item:e})}function NL(n,t){const e=Je(n,t),o=n.getBlockData(t);return!(e!=="text"||o.heading)}class PL{constructor(t,e,o){h(this,"source","text-style");h(this,"id","text-style-item");h(this,"name","Text styles");h(this,"element");h(this,"createHeadingItemElement",(t,e,o)=>{var i;const r=A1();this.createItem("text",Lc,e,NL(this.editor,t)),(i=r.insertBlockCommandItems)==null||i.forEach(s=>{s.id&&s.icon&&this.createItem(s.id,s.icon,e,o?o===Number(s.value):!1)})});h(this,"createListItemElement",(t,e,o)=>{const{checkbox:r,ordered:i}=o,l=it(t)==="list",c=l&&i===!1&&!r,a=l&&i,d=l&&!!r;this.createItem("unordered-list",E5,e,c),this.createItem("ordered-list",I5,e,a),this.createItem("check-list",w5,e,d)});h(this,"handleClick",(t,e)=>{var l,c;if(!e.target||!(e.target instanceof Node))return;const o=e.target instanceof Element?e.target:e.target.parentElement;if(!o)return;const r=o.closest(".text-style-item");if(!r)return;const i=r.id,s="heading-";if(i==="text"&&Kc(t,this.block,null),i.startsWith(s)){const a=Number.parseInt(i.substring(s.length),10);a&&Kc(t,this.block,a)}if(i==="blockquote"&&g1(t,this.block),i.startsWith("align")){const a=i.replace(/^align-/,"");RC(t,this.block,a)}(i==="unordered-list"||i==="ordered-list"||i==="check-list")&&C1(t,this.block,i),(c=(l=this.options).onAfterStyleItemClick)==null||c.call(l)});this.editor=t,this.block=e,this.options=o,this.element=this.createItemElement(t,e),t.domEvents.addEventListener(this.element,"click",this.handleClick)}createItemElement(t,e){const o=b("div",["text-styles"],null),r=b("div",["text-style-section"],o),i=t.getBlockData(e),s=i.heading,l=i.quoted,c=i.align||"left";return this.createHeadingItemElement(e,r,s),this.createListItemElement(e,r,i),this.createItem("blockquote",B5,r,!!l),this.createItem("align-left",xs,r,c==="left"),this.createItem("align-center",Ih,r,c==="center"),this.createItem("align-right",Eh,r,c==="right"),o}createItem(t,e,o,r=!1){const i=["style-icon","text-style-item"];r&&i.push("active");const s=Ir(e,i,o);s.id=t}}function P4(){return{source:"separator",type:"separator",id:`section-${P()}`,name:""}}const $4={copy:Kw,cut:Xw,delete:tB,"lock-block":eB,"unlock-block":nB,comment:Ts};function $L(n,t,e){const o=[],r=_(n,t);if(r&&o.push(new PL(n,t,e)),!Tt(n,t)){r&&o.push(P4());const i=RL(n,t,new Set(["hovering-toolbar"]));i.sort((s,l)=>{var c,a;return((c=s.order)!=null?c:0)-((a=l.order)!=null?a:0)}),i.forEach(s=>{s.id in $4&&(s.icon=$4[s.id])}),o.push(...i)}return Tt(n,t)?o.push(...Z1(n,"insert-block")):o.push(P4(),{id:"insert-block-before",icon:oB,name:x.t("blockMenu.command.insertAbove"),children:Z1(n,"insert-block-before"),childrenMenuId:"quick-menu",source:"insert-block-before"},{id:"insert-block-after",icon:rB,name:x.t("blockMenu.command.insertAfter"),children:Z1(n,"insert-block"),source:"insert-block",childrenMenuId:"quick-menu"}),o}function _L(n,t,e){if(e.source==="block-command"){const o=e.blockMenuItemCustomData;xg(n,t,o,e)}else(e.source==="insert-block"||e.source==="insert-block-before")&&OL(n,t,e,e.source==="insert-block-before")}function pa(n,t){return n.getBlockData(t).lock}function Q1(n,t){return!!pa(n,t)}function Ca(n,t){const e=pa(n,t);return e?e.userId===n.doc.getUser().userId:!1}function _4(n,t){const e=pa(n,t);return e?e.userId!==n.doc.getUser().userId:!1}function FL(n,t){if(n.readonly||!n.isBlockWritable(t)||Q1(n,t)&&!Ca(n,t))return;const e=n.doc.getUser(),o={userId:e.userId,displayName:e.displayName,locked:Date.now()},i={...n.getBlockData(t),lock:o};n.updateBlockData(t,i)}function HL(n,t){if(!Ca(n,t))return;const e={lock:null};n.updateBlockData(t,e)}class F4{constructor(){h(this,"executeCommand",(t,e,o)=>{const r=o.data;if(!r||!r.blockId)return;const i=t.getBlockById(r.blockId);r.type==="lock"?FL(t,i):r.type==="unlock"&&HL(t,i)})}create(t,e,o,r,i){const s=i.lock;s&&(s.userId!==t.doc.getUser().userId?M(r,"locked-by-others"):M(r,"locked-by-self"))}update(t,e,o,r,i){const s=i.lock;s?s.userId!==t.doc.getUser().userId?M(r,"locked-by-others"):M(r,"locked-by-self"):(H(r,"locked-by-others"),H(r,"locked-by-self"))}writable(t,e){if(_4(t,e))return!1;if(Wn(e))return;let o=Fl(e);for(;o;){if(_4(t,o))return!1;o=Fl(o)}}commands(t,e){const o=Q1(t,e),r=Ca(t,e),i={blockId:j(e),type:"lock"},s={id:"lock-block",name:"",data:i,order:10};if(o)if(r)s.id="unlock-block",s.name=x.t("locker.unlock"),i.type="unlock";else{const l=pa(t,e);s.name=x.t("locker.lockedBy",{name:(l==null?void 0:l.displayName)||""}),s.states=["disabled"]}else s.name=x.t("locker.lock");return{group:"block-locker",commands:[s],executeCommand:this.executeCommand}}}const EV="",jL={locker:{lock:"\u9501\u5B9A",unlock:"\u89E3\u9664\u9501\u5B9A",lockedBy:"\u88AB {name} \u9501\u5B9A"}},zL={locker:{lock:"Lock",unlock:"Unlock",lockedBy:"Locked by {name}"}};x.mergeLang({"zh-CN":jL,"en-US":zL});class Y1{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(o=>{o.forEach(r=>{delete r.lock})}),!1}}const UL=w("standard-block-actions");class VL{constructor(){h(this,"executeCommand",(t,e,o)=>{const r=o.data;try{const i=t.getBlockById(r);if(o.id==="delete"){t.deleteBlock(i);return}o.id==="copy"&&Cc(t,i),o.id==="cut"&&(Cc(t,i),t.deleteBlock(i))}catch(i){UL.error(`failed to execute block command: ${JSON.stringify(i)}`)}})}commands(t,e){const o=Q1(t,e),r=o&&Ca(t,e),i=j(e);return{group:"standard-block-actions",commands:[{id:"copy",name:"Copy",data:i,order:1},{id:"cut",name:"Cut",data:i,order:2,states:o&&!r?["disabled"]:[]},{id:"delete",name:"Delete",data:i,order:3,states:o&&!r?["disabled"]:[]}],executeCommand:this.executeCommand}}}const H4=w("block-menu");class qL{constructor(t){h(this,"menu");h(this,"currentBlock",null);h(this,"commandBlock",null);h(this,"handleShow",()=>{u(H4,this.currentBlock,"no target block before show block menu");const t=$L(this.editor,this.currentBlock,{onAfterStyleItemClick:this.close});this.menu.updateItems(t),this.commandBlock=this.currentBlock});h(this,"handleClose",()=>{Dh(this.editor)&&this.editor.focus()});h(this,"handleItemClick",(t,e)=>{u(H4,this.commandBlock,"no command block before show block menu"),_L(this.editor,this.commandBlock,e),!e.element&&!e.children&&this.close()});h(this,"close",()=>{this.menu.close()});this.editor=t,this.menu=new cr([],void 0,{id:"block-menu"}),this.menu.on("show",this.handleShow),this.menu.on("close",this.handleClose),this.menu.on("click",this.handleItemClick),t.blockHooks.push(new VL)}show(t){this.menu.manualShow(t,{placement:"bottom-start"})}isInMenu(t){return this.menu.isInCommandBar(t)}setBlock(t){this.currentBlock=t}get isVisible(){return this.menu.isVisible}destroy(){this.menu.destroy()}}const j4=`<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
397
|
+
`).map(s=>({id:P(),type:"text",text:Co(s)})),o=P();return{blocks:{root:[{children:[o],type:"code",id:P(),...t}],[o]:e},meta:{},comments:{}}}class WD{handleBeforeCopy(t,e,o){const r=t.getFocusedBlock();if(!ui(t,r))return;const i=_1(r),s=t.getBlockData(i),{language:l,nowrap:c}=s;if(t.selection.range.isCollapsed()){const d=t.getBlockString(r);return v4(d,{language:l,nowrap:c})}const a=t.getSelectedText();return v4(a,{language:l,nowrap:c})}}function GD(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!ui(n,t)){if(n.selection.range.isCollapsed()){const e=n.selection.range.start;return n.insertTextToBlock(t,e.offset," "),!0}return n.undoManager.runInGroup(()=>{en(n).forEach(o=>{n.insertTextToBlock(o.block,0," ")})}),!0}}function ZD(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!ui(n,t))return;const e=[" "," "];return n.undoManager.runInGroup(()=>{en(n).forEach(r=>{const i=vt(n.getBlockText(r.block));for(let s=0;s<e.length;s++){const l=e[s];if(i.startsWith(l)){n.deleteTextFromBlock(r.block,0,l.length);break}}})}),!0}function QD(n){const t=n.getFocusedBlock(),e=z(t);if(Ct(e))return;const o=U(e);if(!o||it(o)!=="code")return;const r=n.selection.range;if(!!r.isSimple()&&!G0(e,r))return Vd(n,e),!0}const YD={Tab:GD,"Shift+Tab":ZD,"CtrlOrCmd+A":QD},Ys=w("code-text-decorate");class Js{decorateText(t,e,o){var p;if(u(Ys,e.length>0,"invalid path"),e.length===1)return{};const r=e[e.length-2];if(t.doc.getBlockData(r.containerId,r.blockIndex).type!=="code")return{};const s=o;if(s.length===0)return{};const l=vt(s),c=t.doc.getBlockData(r.containerId,r.blockIndex),a=Oi.default.tokenize(l,(p=Oi.default.languages[c.language])!=null?p:Oi.default.languages.plain),d=(A,k)=>{if(u(Ys,A,"no token"),typeof A=="string")return[{insert:A,attributes:Q.default(k)}];u(Ys,A instanceof Oi.default.Token,"invalid token type");const v=A.content,x=Q.default(k);return x[`style-code-${A.type}`]=!0,typeof v=="string"?[{insert:v,attributes:x}]:Array.isArray(v)?v.map(R=>d(R,x)).flat():(u(Ys,v instanceof Oi.default.Token,"invalid token"),d(v,x))},m=a.map(A=>d(A,{})).flat();return u(Ys,me(m)===me(s),"failed to highlight code, text length mismatch"),{text:m}}}const JD={code:{title:"\u4EE3\u7801",abstract:"\u4EE3\u7801"}},KD={code:{title:"Code",abstract:"Code"}};T.mergeLang({"zh-CN":JD,"en-US":KD});const XD=w("image-data"),tL=1e3,eL=400,nL=10;function Ks(n){return n.src.startsWith("empty:")||!n.src}function oL(n){return n.src.startsWith("http:")||n.src.startsWith("https:")}function y4(n){return`${Er.default(n)}_width`}function k4(n){return`${Er.default(n)}_height`}function w4(n){return`${n}_flex`}function Xs(n){if(n.every(r=>typeof r.flex=="number"&&r.flex))return;const t=100,o=n.map(r=>r.width/(r.height/t)).reduce((r,i)=>r+i,0);n.forEach(r=>{const i=r.width/(r.height/t);r.flex=i/o})}function di(n){const t=(r,i)=>{r||(r=`empty:${i}`);const s=y4(r),l=k4(r),c=w4(i);let a=n[s],d=n[l],f=n[c];return typeof a=="string"&&(a=Number.parseInt(a,10)),typeof d=="string"&&(d=Number.parseInt(d,10)),typeof f=="string"&&(f=Number.parseInt(f,10)),a&&d?{src:r,width:a,height:d,flex:f,virtualSize:!1}:(a=tL,d=eL,{src:r,width:a,height:d,flex:f,virtualSize:!0})};let e=[];const o=n.src;return Array.isArray(o)?e=o.map(t):typeof o=="string"&&(e=o.split("|").map(t)),Xs(e),e}function fn(n){var o;const t=n.embedData;return di(n.embedData).length>1?100:(o=t.widthPercent)!=null?o:100}function rL(n,t){if(di(t.embedData).length>1)return"100%";const o=fn(t);return`${n.rootContainer.getBoundingClientRect().width*o/100}px`}function ae(n,t){const o={src:n.map(r=>r.src).join("|"),widthPercent:t};return n.forEach((r,i)=>{if(r.width&&r.height&&!r.virtualSize){const l=r.src||`empty:${i}`,c=y4(l);o[c]=r.width;const a=k4(l);o[a]=r.height}u(XD,r.flex,"no image flex");const s=w4(i);o[s]=r.flex}),o}function iL(n,t,e){const o=di(t.embedData),r=o.length===1?n.rootContainer:e,i=fn(t);let s=r.getBoundingClientRect().width*(i/100);if(s-=Number.parseFloat(window.getComputedStyle(r).paddingLeft)+Number.parseFloat(window.getComputedStyle(r).paddingRight),o.length===1){const a=o[0];return a.height/(a.width/s)}s-=(o.length-1)*nL;const l=o.reduce((a,d)=>a+d.flex,0);let c=0;for(const a of o){const f=s*a.flex/l/a.width*a.height;c=Math.max(f,c)}return c}function sL(n){return n.reduce((e,o)=>e+o.flex,0)}const lL=w("image-dom");function B4(n){return n.querySelector(".uploading-progress-mask")}function cL(n){const t=B4(n);if(t)return t;const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e);return b("div",["uploading-progress-bar-value"],o),o}function aL(n){const e=cL(n).querySelector(".uploading-progress-bar-value");return u(lL,e,"no progress value"),e}function E4(n,t){const e=aL(n);e.style.width=`${t}%`}function uL(n){var t;(t=B4(n))==null||t.remove()}function dL(n){let t;return n.forEach((e,o)=>{o.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function hL(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),o=dL(t.headers).toLocaleLowerCase();let r="";if(o){const s=au.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([e],`${Date.now()}.${r}`,{type:o})}catch{return null}}function pr(n,t){const e=typeof t=="string"?t:j(t);return n.getCustom(`image-${e}`)}function ha(n,t){if(!t||!(t instanceof Node))return null;const e=U(t);return e?pr(n,e):null}function Kn(n){return Array.from(n.querySelectorAll(".image-container"))}function fa(n,t,e,o){const r=e!=null?e:n.findBlockById(t.id);if(!r)return;const i=o||z(r),s=rL(n,t),l=iL(n,t,i),c=st(r);c.style.width=s;const a=r.querySelector(".images");!a||(a.style.height=`${l}px`)}const q1=w("table-resize-drag-drop");class fL{constructor(t,e,o,r){h(this,"cursor","col-resize");h(this,"initWidths");this.editor=t,this.elem=e,this.data=o,this.mouseDownEvent=r;const i=this.data.block,l=pr(this.editor,i).getImages(),c=this.data.splitterIndex;u(q1,c>=0&&c<l.length-1,`invalid splitter index: ${c}`);const d=Kn(i).map(f=>f.getBoundingClientRect().width);this.initWidths=d}onDragStart(t,e,o){if(!this.editor.isWritable())return;const r=this.data.block;pr(this.editor,r).setResizing(!0)}onDragging(t,e,o,r,i){const s=this.data.block,l=pr(this.editor,s),c=Q.default(l.getImages()),a=this.data.splitterIndex;u(q1,a>=0&&a<c.length-1,`invalid splitter index: ${a}`);const d=this.initWidths[a],f=this.initWidths[a+1];if(d+f<100)return;let m=r;d+m<50&&(m=50-d),f-m<50&&(m=f-50);const k=[...this.initWidths];k[a]+=m,k[a+1]-=m;const v=Kn(s);u(q1,v.length===c.length,"invalid image data");const x=k.reduce((R,$)=>R+$,0);for(let R=0;R<c.length;R++){const $=k[R]/x;c[R].flex=$,v[R].style.flexGrow=`${$}`}const E=Q.default(this.editor.getBlockData(s)),L=ae(c,fn(E));E.embedData=L,fa(this.editor,E,s,null)}onDragEnd(t,e,o,r,i){const s=this.data.block,l=pr(this.editor,s),a=Kn(s).map(d=>Number.parseFloat(d.style.flexGrow));l.updateFlex(a),l.setResizing(!1)}}function I4(n){var t;return!n||!(n instanceof HTMLElement)?null:rt(n,"image-splitter")?n:(t=n.closest(".image-splitter"))!=null?t:null}function mL(n,t){var s;const e=I4(t.target);if(!e)return;const o=U(e);if(!o)return;pr(n,o).setSelectedIndex(-1),n.selection.selectBlock(o,0);const r=Number.parseInt((s=e.getAttribute("data-index"))!=null?s:"",10);if(Number.isNaN(r)||typeof r!="number")return;const i={block:o,splitterIndex:r};Cu(new fL(n,e,i,t))}function gL(n,t){t.preventDefault(),t.stopPropagation();const e=I4(t.target);if(!e)return;const o=U(e);!o||pr(n,o).resetFlex()}function pL(n,t,e,o){const r=b("div",["image-splitter"],e);b("div",["image-splitter-indicator"],r),r.setAttribute("data-index",`${o}`),n.domEvents.addEventListener(r,"mousedown",mL),n.domEvents.addEventListener(r,"dblclick",gL)}const CL=w("image-item");function x4(n){return!n||!(n instanceof Node)?null:U(n)}function T4(n){const t=x4(n);return t?Kn(t):[]}function W1(n){if(!n||!(n instanceof Node))return null;const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest(".image-container");return e||null}function tl(n){const t=W1(n);return t?T4(n).indexOf(t):-1}async function AL(n,t){const e=ha(n,t.target);if(!e)return;const o=tl(t.target);if(o===-1)return;const r=t.target;if(!(r instanceof HTMLImageElement))return;const i=e.getImages()[o];if(i.virtualSize&&e.fixImageSize(o,r),!i||!oL(i)||i.downloading)return;i.downloading=!0;const s=await hL(i.src);s?e.replaceImage(o,s):CL.warn(`failed to download image: ${i.src}`)}function bL(n,t,e){if(t.querySelector(".load-error"))return;const r=e.src.startsWith("http:")||e.src.startsWith("https:"),i=b("div",["load-error"],t),s=b("div",["error-icon"],i);s.innerHTML=v5;const l=b("div",["error-message"],i);r?(l.innerHTML=T.t("image.load.remote.failed"),n.domEvents.addEventListener(i,"click",(c,a)=>{a.preventDefault(),a.target instanceof HTMLElement&&a.target.tagName==="A"&&window.open(e.src,"_blank")})):(l.innerHTML=T.t("image.load.failed"),n.domEvents.addEventListener(i,"click",(c,a)=>{a.preventDefault(),a.target instanceof HTMLElement&&a.target.tagName==="A"&&wL(c,a.target)}))}function vL(n,t){const e=ha(n,t.target);if(!e)return;const o=tl(t.target);if(o===-1)return;const r=e.getImages()[o];if(!r)return;const i=W1(t.target);!i||(M(i,"error","error-load"),bL(n,i,r))}function yL(n,t,e){if(t.querySelector(".upload-error"))return;const r=b("div",["upload-error"],t),i=b("div",["error-icon"],r);i.innerHTML=v5;const s=b("div",["error-message"],r);s.innerHTML=T.t("image.upload.failed"),n.domEvents.addEventListener(r,"click",(l,c)=>{if(c.preventDefault(),!c.target||!(c.target instanceof Element)||c.target.tagName!=="A")return;const a=ha(l,c.target),d=tl(c.target);!a||d===-1||a.replaceImage(d,e)})}function S4(n,t,e,o,r){const i=Kn(t)[e];!i||(M(i,"error","error-upload"),yL(n,i,r))}function D4(n,t,e,o,r,i){const s=b("div",["image-container"],t);if(s.setAttribute("data-src",e.src),i.length>1&&(s.style.flexShrink=`${e.flex}`,s.style.flexGrow=`${e.flex}`),r===o&&M(s,"active"),Ks(e)){M(s,"empty");const c=b("div",["upload-image-icon"],s);return c.innerHTML=Ow,s}const l=b("img",["editor-image"],s);if(l.src=n.doc.buildResourceUrl(e.src),l.draggable=!0,!Ks(e)&&!n.readonly&&n.domEvents.addEventListener(l,"load",AL),n.domEvents.addEventListener(l,"error",vL),e.src.startsWith("https:")||e.src.startsWith("http:")){const c=b("div",["image-warning"],s);c.innerHTML=b5,c.setAttribute(`data-editor-tooltip-${n.clientId}`,T.t("image.load.remote.tooltip"))}return s}function kL(n,t,e,o,r){const i=b("div",["images"],e);return o.forEach((s,l)=>{l>0&&pL(n,t,i,l-1),D4(n,i,s,l,r,o)}),o.length>1&&M(t,"multi"),i}function L4(n,t,e,o,r,i){const l=Array.from(t.querySelectorAll(".image-container"))[o];if(!l)return;const c=D4(n,null,e,o,r,i);l.insertAdjacentElement("beforebegin",c),l.remove()}function el(n,t){return Kn(n)[t]}function wL(n,t){const e=x4(t);if(!e)return;const o=tl(t);if(o===-1)return;const r=ha(n,t);if(!r)return;const i=r.getImages()[o];L4(n,e,i,o,r.getSelectedIndex(),r.getImages())}function mn(n){return it(n)==="embed"&&Ne(n)==="image"}async function M4(n){return new Promise((t,e)=>{const o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=e,o.src=n})}async function BL(n){const t=await Tr(n);return M4(t)}const R4=w("image-object");class Ut{constructor(t,e){h(this,"images",[]);h(this,"selectedIndex",-1);h(this,"blockResizer");h(this,"resizing",!1);h(this,"parentContainerResizerObserver",null);h(this,"handleMouseDown",async(t,e)=>{const o=tl(e.target);if(o===-1)return;const r=this.images[o];Ks(r)||this.setSelectedIndex(o)});h(this,"handleEditorResize",()=>{if(this.isEmpty()||this.resizing)return;const t=this.editor.findBlockById(this.blockData.id);!t||fa(this.editor,this.blockData,t,null)});h(this,"handleResizing",(t,e)=>{const o=this.editor.findBlockById(this.blockData.id);if(!o)return;const i=this.editor.rootContainer.getBoundingClientRect().width,s=o.getBoundingClientRect();let l=e.width>s.width?s.width:e.width;l<50&&(l=50);const c=l*100/i;this.blockData.embedData.widthPercent=c,fa(this.editor,this.blockData,o,null)});h(this,"handleResized",t=>{const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const o=ae(this.images,fn(this.blockData));this.editor.updateEmbedData(e,o),this.blockResizer.enableResize(e)});h(this,"fixImageSizes",ee.default(()=>{const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=ae(this.images,fn(this.blockData));this.editor.updateEmbedData(t,e)},1e3));this.editor=t,this.blockData=e,this.blockResizer=new sa(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}),this.blockResizer.addListener("resizing",this.handleResizing),this.blockResizer.addListener("resized",this.handleResized),this.images=di(this.blockData.embedData)}destroy(){var t;this.blockResizer.removeAllListeners(),this.blockResizer.destroy(),this.editor.domEvents.removeEventListener(null,null,this.handleMouseDown),(t=this.parentContainerResizerObserver)==null||t.disconnect()}createContent(t,e,o){const r=kL(this.editor,e,o,this.images,this.selectedIndex);this.editor.domEvents.addEventListener(o,"mousedown",this.handleMouseDown),this.editor.addListener("resize",this.handleEditorResize),Ke(t)&&(this.parentContainerResizerObserver=new ResizeObserver(this.handleEditorResize),this.parentContainerResizerObserver.observe(t)),this.isEmpty()?M(r,"empty"):fa(this.editor,this.blockData,e,t),setTimeout(()=>{const i=this.editor.findBlockById(this.blockData.id);i&&this.blockResizer.update(i)})}getImages(){return this.images}getWidthPercent(){return fn(this.blockData)}isEmpty(){return this.images.length===1&&Ks(this.images[0])}setResizing(t){this.resizing=t}getSelectedIndex(){return this.selectedIndex}getBlock(){return this.editor.findBlockById(this.blockData.id)}setSelectedIndex(t){const e=this.getBlock();if(!e||t===this.selectedIndex)return;if(this.selectedIndex!==-1){const r=el(e,this.selectedIndex);r&&H(r,"active")}this.selectedIndex=t;const o=el(e,t);o&&M(o,"active")}async requestUploadImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const o=el(e,t);if(rt(o,"error"))return;const r=await Qo("image/*");await this.replaceImage(t,r)}tryEnableResizer(){const t=this.editor.findBlockById(this.blockData.id);if(!t||!this.editor.isWritable())return;const e=el(t,0);!this.isEmpty()&&this.images.length===1&&!rt(e,"error")&&this.blockResizer.enableResize(t)}disableResizer(){this.blockResizer.disableResize()}fixImageSize(t,e){const o=this.images[t];Ks(o)||(o.width=e.naturalWidth,o.height=e.naturalHeight,o.virtualSize=!1,this.fixImageSizes())}removeImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e||t===-1||t>=this.images.length)return!1;const o=Q.default(this.images);o.splice(t,1),o[0].flex=NaN,Xs(o),this.selectedIndex>=o.length&&(this.selectedIndex=o.length-1);const r=ae(o,fn(this.blockData));return this.editor.updateEmbedData(e,r),!0}async replaceImage(t,e){const o=this.editor.findBlockById(this.blockData.id);if(!o)return!1;try{const i=await Tr(e),s=this.images[t];if(s.virtualSize){const{width:c,height:a}=await M4(i);s.width=c,s.height=a,s.virtualSize=!1;const d=ae(this.images,fn(this.blockData));this.editor.updateEmbedData(o,d)}const l={...s,src:i};L4(this.editor,o,l,t,this.selectedIndex,this.images),setTimeout(()=>{this.blockResizer.update(o)})}catch(i){return S4(this.editor,o,t,i,e),!1}const r=el(o,t);if(!r)return!1;M(r,"uploading"),E4(r,0);try{const i=await this.editor.doc.uploadResource(e,{onProgress:c=>{E4(r,c)}});H(r,"uploading"),this.images[t].src=i.resourceId;const s=this.editor.findBlockById(this.blockData.id);if(!s)return!1;const l=ae(this.images,fn(this.blockData));return this.editor.updateEmbedData(s,l),!0}catch(i){R4.error(i);const s=this.editor.findBlockById(this.blockData.id);return s&&(H(r,"uploading"),uL(r),S4(this.editor,s,t,i,e)),!1}}updateFlex(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;u(R4,t.length===this.images.length,"invalid flex");for(let r=0;r<this.images.length;r++)this.images[r].flex=t[r];const o=ae(this.images,fn(this.blockData));this.editor.updateEmbedData(e,o)}resetFlex(){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=Q.default(this.images);e[0].flex=NaN,Xs(e);const o=ae(e,fn(this.blockData));this.editor.updateEmbedData(t,o)}setData(t){this.blockData=t,this.images=di(t.embedData)}static create(t,e){const o=t.addCustom(`image-${e.id}`,()=>new Ut(t,e));return o.setData(e),o}static getImageObject(t,e){let o;return typeof e=="string"?o=e:o=j(e),t.getCustom(`image-${o}`)}}const wV="";function O4(n,t,e){const o=Ut.getImageObject(n,t),r=Q.default(o.getImages());if(r.length===1){n.deleteBlock(t);return}if(e===-1||e>=r.length)return;const i=sL(r);if(r.splice(e,1),r.length===1){const l=r[0],c=100*(l.flex/i);l.flex=1;const a=ae([l],c);n.updateEmbedData(t,a);return}r[0].flex=NaN,Xs(r);const s=ae(r,o.getWidthPercent());n.updateEmbedData(t,s)}function EL(n,t,e,o){if(t.length===0||o==="after"||o==="before")return!1;let r=o.data;const i=Ut.getImageObject(n,e),s=Q.default(i.getImages());return t.forEach(l=>{const c={src:"",flex:1,width:0,height:0,virtualSize:!0};s.splice(r,0,c);const a=ae(s,i.getWidthPercent());n.updateEmbedData(e,a),i.replaceImage(r,l),r+=1}),!0}function IL(n,t,e,o,r){var s,l,c;if(Pl(e))return EL(n,e,t,o);if(e.type!=="custom"||e.customType!=="image"||!e.data)return;const i=e.data;if(r.isSourceBlock){const a=r.targetBlock,d=z(a);let f=K(a);o==="after"&&(f+=1);const p=100*(i.boundingRect.width/n.rootContainer.getBoundingClientRect().width),A=ae([i.image],p),k={id:P(),type:"embed",embedType:"image",embedData:A},v=(l=(s=n.options.componentsOptions)==null?void 0:s.image)==null?void 0:l.defaultAlign;v&&(k.align=v),n.insertBlock(V(d),f,k),O4(n,t,i.index),(c=n.findCustom("drag-handler"))==null||c.handleDragEnd()}else{if(typeof o=="string")return;const a=t;let d=o.data;const f=Ut.getImageObject(n,a),m=Q.default(f.getImages());d>m.length&&(d=m.length),n.undoManager.runInGroup(()=>{var A,k;const p=n.getBlockById(e.blockId);if(p===a){const v=i.index,x=d,E=i.image;if(v===x||x===v+1)return;let L=x;v<x?(m.splice(x,0,E),m.splice(v,1),L-=1):(m.splice(v,1),m.splice(x,0,E));const R=ae(m,f.getWidthPercent());n.updateEmbedData(a,R),f.setSelectedIndex(L),(A=n.findCustom("drag-handler"))==null||A.handleDragEnd()}else{m.splice(d,0,i.image),m[0].flex=NaN,Xs(m);const v=ae(m,f.getWidthPercent());n.updateEmbedData(a,v),O4(n,p,i.index),(k=n.findCustom("drag-handler"))==null||k.handleDragEnd()}})}return!0}const xL=2;function ma(n,t,e){const o=Kn(t);if(e<=0){const s=o[0].getBoundingClientRect();return new DOMRect(s.left-4,s.top,2,s.height)}if(e===o.length){const s=o[e-1].getBoundingClientRect();return new DOMRect(s.right+2,s.top,2,s.height)}const r=o[e-1].getBoundingClientRect(),i=o[e].getBoundingClientRect();return new DOMRect((i.left+r.right)/2-1,r.top,xL,r.height)}function TL(n,t,e,o,r){for(let i=0;i<e.length;i++){const l=e[i].getBoundingClientRect();if(o<=l.right)return o<=l.left+l.width/2?{rect:ma(n,t,i),data:i}:{rect:ma(n,t,i+1),data:i+1}}return o>e[e.length-1].getBoundingClientRect().right?{rect:ma(n,t,e.length),data:e.length}:{rect:ma(n,t,e.length),data:0}}function SL(n,t,e,o,r){const i=Kn(t);if((e==null?void 0:e.type)==="block"||i.length>=6&&(e==null?void 0:e.blockId)!==j(t))return;const s=j(t);if(!(i.length===1&&s===(e==null?void 0:e.blockId)))return TL(n,t,i,o)}const BV="";function ga(n){const t=Rt(n);let e=t.querySelector(":scope > .block-helper");return e||(e=b("div",["block-helper"],t),b("span",["helper-sizer"],e,"A")),e}function G1(n,t,e){const o=ga(n),i=Array.from(o.children).find(s=>{var c;return Number.parseInt((c=s.getAttribute("data-index"))!=null?c:"0",10)>e});o.insertBefore(t,i!=null?i:null)}const N4=40,DL=20;class LL{findTargetBlock(t,e){const o=e.target;if(o&&o instanceof Element){const c=U(o);if(c&&wt(t.rootContainer,c))return c}let r=e.clientX,i=e.clientY;const s=t.rootContainer.getBoundingClientRect().left;r<s&&s-r<N4&&(r+=N4);let l=document.elementFromPoint(r,i);if(l){const c=U(l);if(c&&wt(t.rootContainer,c))return c}if(i-=DL,l=document.elementFromPoint(r,i),l){const c=U(l);if(c&&wt(t.rootContainer,c))return c}return null}destroy(){}}class ML extends ea{constructor(e){super(e,{trigger:[],id:"empty-block-menu"});h(this,"currentBlock",null)}get isVisible(){return this.suggest.menu.isVisible}isInMenu(e){return this.menu.isInCommandBar(e)}show(){const o=this.editor.selection.focusedBlock;this.suggest.popup(o,0,"","")}setBlock(e){this.currentBlock=e}}function RL(n,t,e){const o=Fu(n,t);if(!o)return[];const r=[];return Object.values(o).forEach(i=>{e!=null&&e.has(i.group)||r.push(...i.commands.map(s=>({...s,source:"block-command",blockMenuItemCustomData:i.group})))}),r}function Z1(n,t){const e=w1(n),o=r=>{r.forEach(i=>{i.source=t,i.children&&o(i.children)})};return o(e),e}function OL(n,t,e,o=!1){var a,d;const r=z(t);let s=K(t);Tt(n,t)||o||(s+=1);const l=V(r),c=e;return c.commandProvider?c.commandProvider.executeCommand(n,e,{from:"block-menu",containerId:l,blockIndex:s}):(d=(a=c.blockOptions)==null?void 0:a.handleInsertEmptyBlock)==null?void 0:d.call(a,n,{containerId:l,blockIndex:s,item:e})}function NL(n,t){const e=Je(n,t),o=n.getBlockData(t);return!(e!=="text"||o.heading)}class PL{constructor(t,e,o){h(this,"source","text-style");h(this,"id","text-style-item");h(this,"name","Text styles");h(this,"element");h(this,"createHeadingItemElement",(t,e,o)=>{var i;const r=A1();this.createItem("text",Lc,e,NL(this.editor,t)),(i=r.insertBlockCommandItems)==null||i.forEach(s=>{s.id&&s.icon&&this.createItem(s.id,s.icon,e,o?o===Number(s.value):!1)})});h(this,"createListItemElement",(t,e,o)=>{const{checkbox:r,ordered:i}=o,l=it(t)==="list",c=l&&i===!1&&!r,a=l&&i,d=l&&!!r;this.createItem("unordered-list",E5,e,c),this.createItem("ordered-list",I5,e,a),this.createItem("check-list",w5,e,d)});h(this,"handleClick",(t,e)=>{var l,c;if(!e.target||!(e.target instanceof Node))return;const o=e.target instanceof Element?e.target:e.target.parentElement;if(!o)return;const r=o.closest(".text-style-item");if(!r)return;const i=r.id,s="heading-";if(i==="text"&&Kc(t,this.block,null),i.startsWith(s)){const a=Number.parseInt(i.substring(s.length),10);a&&Kc(t,this.block,a)}if(i==="blockquote"&&g1(t,this.block),i.startsWith("align")){const a=i.replace(/^align-/,"");RC(t,this.block,a)}(i==="unordered-list"||i==="ordered-list"||i==="check-list")&&C1(t,this.block,i),(c=(l=this.options).onAfterStyleItemClick)==null||c.call(l)});this.editor=t,this.block=e,this.options=o,this.element=this.createItemElement(t,e),t.domEvents.addEventListener(this.element,"click",this.handleClick)}createItemElement(t,e){const o=b("div",["text-styles"],null),r=b("div",["text-style-section"],o),i=t.getBlockData(e),s=i.heading,l=i.quoted,c=i.align||"left";return this.createHeadingItemElement(e,r,s),this.createListItemElement(e,r,i),this.createItem("blockquote",B5,r,!!l),this.createItem("align-left",xs,r,c==="left"),this.createItem("align-center",Ih,r,c==="center"),this.createItem("align-right",Eh,r,c==="right"),o}createItem(t,e,o,r=!1){const i=["style-icon","text-style-item"];r&&i.push("active");const s=Ir(e,i,o);s.id=t}}function P4(){return{source:"separator",type:"separator",id:`section-${P()}`,name:""}}const $4={copy:Kw,cut:Xw,delete:tB,"lock-block":eB,"unlock-block":nB,comment:Ts};function $L(n,t,e){const o=[],r=_(n,t);if(r&&o.push(new PL(n,t,e)),!Tt(n,t)){r&&o.push(P4());const i=RL(n,t,new Set(["hovering-toolbar"]));i.sort((s,l)=>{var c,a;return((c=s.order)!=null?c:0)-((a=l.order)!=null?a:0)}),i.forEach(s=>{s.id in $4&&(s.icon=$4[s.id])}),o.push(...i)}return Tt(n,t)?o.push(...Z1(n,"insert-block")):o.push(P4(),{id:"insert-block-before",icon:oB,name:T.t("blockMenu.command.insertAbove"),children:Z1(n,"insert-block-before"),childrenMenuId:"quick-menu",source:"insert-block-before"},{id:"insert-block-after",icon:rB,name:T.t("blockMenu.command.insertAfter"),children:Z1(n,"insert-block"),source:"insert-block",childrenMenuId:"quick-menu"}),o}function _L(n,t,e){if(e.source==="block-command"){const o=e.blockMenuItemCustomData;xg(n,t,o,e)}else(e.source==="insert-block"||e.source==="insert-block-before")&&OL(n,t,e,e.source==="insert-block-before")}function pa(n,t){return n.getBlockData(t).lock}function Q1(n,t){return!!pa(n,t)}function Ca(n,t){const e=pa(n,t);return e?e.userId===n.doc.getUser().userId:!1}function _4(n,t){const e=pa(n,t);return e?e.userId!==n.doc.getUser().userId:!1}function FL(n,t){if(n.readonly||!n.isBlockWritable(t)||Q1(n,t)&&!Ca(n,t))return;const e=n.doc.getUser(),o={userId:e.userId,displayName:e.displayName,locked:Date.now()},i={...n.getBlockData(t),lock:o};n.updateBlockData(t,i)}function HL(n,t){if(!Ca(n,t))return;const e={lock:null};n.updateBlockData(t,e)}class F4{constructor(){h(this,"executeCommand",(t,e,o)=>{const r=o.data;if(!r||!r.blockId)return;const i=t.getBlockById(r.blockId);r.type==="lock"?FL(t,i):r.type==="unlock"&&HL(t,i)})}create(t,e,o,r,i){const s=i.lock;s&&(s.userId!==t.doc.getUser().userId?M(r,"locked-by-others"):M(r,"locked-by-self"))}update(t,e,o,r,i){const s=i.lock;s?s.userId!==t.doc.getUser().userId?M(r,"locked-by-others"):M(r,"locked-by-self"):(H(r,"locked-by-others"),H(r,"locked-by-self"))}writable(t,e){if(_4(t,e))return!1;if(Wn(e))return;let o=Fl(e);for(;o;){if(_4(t,o))return!1;o=Fl(o)}}commands(t,e){const o=Q1(t,e),r=Ca(t,e),i={blockId:j(e),type:"lock"},s={id:"lock-block",name:"",data:i,order:10};if(o)if(r)s.id="unlock-block",s.name=T.t("locker.unlock"),i.type="unlock";else{const l=pa(t,e);s.name=T.t("locker.lockedBy",{name:(l==null?void 0:l.displayName)||""}),s.states=["disabled"]}else s.name=T.t("locker.lock");return{group:"block-locker",commands:[s],executeCommand:this.executeCommand}}}const EV="",jL={locker:{lock:"\u9501\u5B9A",unlock:"\u89E3\u9664\u9501\u5B9A",lockedBy:"\u88AB {name} \u9501\u5B9A"}},zL={locker:{lock:"Lock",unlock:"Unlock",lockedBy:"Locked by {name}"}};T.mergeLang({"zh-CN":jL,"en-US":zL});class Y1{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(o=>{o.forEach(r=>{delete r.lock})}),!1}}const UL=w("standard-block-actions");class VL{constructor(){h(this,"executeCommand",(t,e,o)=>{const r=o.data;try{const i=t.getBlockById(r);if(o.id==="delete"){t.deleteBlock(i);return}o.id==="copy"&&Cc(t,i),o.id==="cut"&&(Cc(t,i),t.deleteBlock(i))}catch(i){UL.error(`failed to execute block command: ${JSON.stringify(i)}`)}})}commands(t,e){const o=Q1(t,e),r=o&&Ca(t,e),i=j(e);return{group:"standard-block-actions",commands:[{id:"copy",name:"Copy",data:i,order:1},{id:"cut",name:"Cut",data:i,order:2,states:o&&!r?["disabled"]:[]},{id:"delete",name:"Delete",data:i,order:3,states:o&&!r?["disabled"]:[]}],executeCommand:this.executeCommand}}}const H4=w("block-menu");class qL{constructor(t){h(this,"menu");h(this,"currentBlock",null);h(this,"commandBlock",null);h(this,"handleShow",()=>{u(H4,this.currentBlock,"no target block before show block menu");const t=$L(this.editor,this.currentBlock,{onAfterStyleItemClick:this.close});this.menu.updateItems(t),this.commandBlock=this.currentBlock});h(this,"handleClose",()=>{Dh(this.editor)&&this.editor.focus()});h(this,"handleItemClick",(t,e)=>{u(H4,this.commandBlock,"no command block before show block menu"),_L(this.editor,this.commandBlock,e),!e.element&&!e.children&&this.close()});h(this,"close",()=>{this.menu.close()});this.editor=t,this.menu=new cr([],void 0,{id:"block-menu"}),this.menu.on("show",this.handleShow),this.menu.on("close",this.handleClose),this.menu.on("click",this.handleItemClick),t.blockHooks.push(new VL)}show(t){this.menu.manualShow(t,{placement:"bottom-start"})}isInMenu(t){return this.menu.isInCommandBar(t)}setBlock(t){this.currentBlock=t}get isVisible(){return this.menu.isVisible}destroy(){this.menu.destroy()}}const j4=`<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
398
398
|
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M6.33341 3.48568C6.33341 4.22204 5.73645 4.81901 5.00008 4.81901C4.26371 4.81901 3.66675 4.22204 3.66675 3.48568C3.66675 2.7493 4.26371 2.15234 5.00008 2.15234C5.73645 2.15234 6.33341 2.7493 6.33341 3.48568ZM5.00008 9.48568C5.73645 9.48568 6.33341 8.88871 6.33341 8.15234C6.33341 7.41598 5.73645 6.81901 5.00008 6.81901C4.26371 6.81901 3.66675 7.41598 3.66675 8.15234C3.66675 8.88871 4.26371 9.48568 5.00008 9.48568ZM5.00008 14.1523C5.73645 14.1523 6.33341 13.5554 6.33341 12.819C6.33341 12.0826 5.73645 11.4857 5.00008 11.4857C4.26371 11.4857 3.66675 12.0826 3.66675 12.819C3.66675 13.5554 4.26371 14.1523 5.00008 14.1523Z" />
|
|
399
399
|
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M12.3334 3.48568C12.3334 4.22204 11.7364 4.81901 11.0001 4.81901C10.2637 4.81901 9.66675 4.22204 9.66675 3.48568C9.66675 2.7493 10.2637 2.15234 11.0001 2.15234C11.7364 2.15234 12.3334 2.7493 12.3334 3.48568ZM11.0001 9.48568C11.7364 9.48568 12.3334 8.88871 12.3334 8.15234C12.3334 7.41598 11.7364 6.81901 11.0001 6.81901C10.2637 6.81901 9.66675 7.41598 9.66675 8.15234C9.66675 8.88871 10.2637 9.48568 11.0001 9.48568ZM11.0001 14.1523C11.7364 14.1523 12.3334 13.5554 12.3334 12.819C12.3334 12.0826 11.7364 11.4857 11.0001 11.4857C10.2637 11.4857 9.66675 12.0826 9.66675 12.819C9.66675 13.5554 10.2637 14.1523 11.0001 14.1523Z" />
|
|
400
400
|
</svg>
|
|
@@ -408,12 +408,12 @@ ${s}
|
|
|
408
408
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M12 7.61719C11.4477 7.61719 11 7.16947 11 6.61719V3.61719C11 3.0649 11.4477 2.61719 12 2.61719C12.5523 2.61719 13 3.0649 13 3.61719V6.61719C13 7.16947 12.5523 7.61719 12 7.61719ZM4.92893 5.54612C5.31946 5.15559 5.95262 5.1556 6.34315 5.54612L8.46447 7.66744C8.85499 8.05796 8.85499 8.69113 8.46447 9.08165C8.07394 9.47218 7.44078 9.47218 7.05025 9.08165L4.92893 6.96033C4.53841 6.56981 4.53841 5.93664 4.92893 5.54612ZM15.5355 9.08165C15.145 8.69113 15.145 8.05796 15.5355 7.66744L17.6569 5.54612C18.0474 5.1556 18.6805 5.1556 19.0711 5.54612C19.4616 5.93664 19.4616 6.56981 19.0711 6.96033L16.9497 9.08165C16.5592 9.47218 15.9261 9.47218 15.5355 9.08165ZM2 12.6172C2 12.0649 2.44772 11.6172 3 11.6172L6 11.6172C6.55229 11.6172 7 12.0649 7 12.6172C7 13.1695 6.55228 13.6172 6 13.6172L3 13.6172C2.44772 13.6172 2 13.1695 2 12.6172ZM17 12.6172C17 12.0649 17.4477 11.6172 18 11.6172L21 11.6172C21.5523 11.6172 22 12.0649 22 12.6172C22 13.1695 21.5523 13.6172 21 13.6172L18 13.6172C17.4477 13.6172 17 13.1695 17 12.6172ZM15.5355 16.1527C15.9261 15.7622 16.5592 15.7622 16.9497 16.1527L19.0711 18.274C19.4616 18.6646 19.4616 19.2977 19.0711 19.6883C18.6805 20.0788 18.0474 20.0788 17.6569 19.6883L15.5355 17.5669C15.145 17.1764 15.145 16.5432 15.5355 16.1527ZM4.92893 19.6883C4.53841 19.2977 4.53841 18.6646 4.92893 18.274L7.05025 16.1527C7.44078 15.7622 8.07394 15.7622 8.46447 16.1527C8.85499 16.5432 8.85499 17.1764 8.46447 17.5669L6.34315 19.6883C5.95262 20.0788 5.31946 20.0788 4.92893 19.6883ZM12 22.6172C11.4477 22.6172 11 22.1695 11 21.6172V18.6172C11 18.0649 11.4477 17.6172 12 17.6172C12.5523 17.6172 13 18.0649 13 18.6172V21.6172C13 22.1695 12.5523 22.6172 12 22.6172Z" fill="#5587F0"/>
|
|
409
409
|
<animateTransform attributeType="xml" attributeName="transform" type="rotate" values="0 12 12.5;360 12 12.5" dur="2s" repeatCount="indefinite" />
|
|
410
410
|
</g>
|
|
411
|
-
</svg>`,ZL=1e3;async function QL(n,t){const{width:e}=n.rootContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return o.width>e||o.height>=ZL?"":(await gm.default.toSvg(t)).replace(/margin-block:.*?;/,"").replace(/margin:.*?;/,"")}const YL=w("drag-preview-image");class JL{constructor(t){h(this,"startPosition",null);h(this,"dragContainer",null);h(this,"handleDragStart",async(t,e)=>{const o=t.target;u(YL,o instanceof HTMLButtonElement,`Invalid Drag target:${o}`);const{x:r,y:i}=t;this.startPosition={x:r,y:i};const s=b("div",["drag-image-container"],this.editor.rootContainer),l=b("img",["drag-image"],s),c=b("span",["drag-loading"],s);c.innerHTML=GL;const{x:a,width:d,height:f,y:m}=o.getBoundingClientRect(),p=this.editor.rootContainer.getBoundingClientRect(),A=e.getBoundingClientRect();s.style.left=`${a+d}px`,s.style.top=`${m+f}px`,s.style.width=`${Math.min(p.width/2,A.width)}px`,this.dragContainer=s;const v=await QL(this.editor,e);v?l.src=v:M(s,"drag-placeholder"),hu(s,{status:"loaded"})});h(this,"handleDrag",t=>{if(this.startPosition&&this.dragContainer){const{x:e,y:o}=t;if(e===0&&o===0){this.dragContainer.style.transition="transform 0.15s, opacity .15s",this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:r,y:i}=this.startPosition,s=e-r,l=o-i;this.dragContainer.style.transform=`translate(${s}px, ${l}px)`}});h(this,"handleDragEnd",()=>{this.dragContainer&&(this.dragContainer.remove(),this.startPosition=null,this.dragContainer=null)});this.editor=t}}const z4="drag-preview-element";function KL(n){if(rt(n,z4))return n;const t=n.querySelector(`.${z4}`);return t||(Te(n)?st(n):n)}const J1=w("block-menu-drag-handler");class XL{constructor(t,e){h(this,"dragPreview");h(this,"autoScroll");h(this,"oldPos",{x:0,y:0});h(this,"handleDragStart",t=>{var i,s;const e=t.dataTransfer;e&&(e.dropEffect="move");const o=this.button.blockMenu.currentBlock;if(u(J1,o,"no dragged block"),!this.editor.isBlockWritable(o)){t.preventDefault(),t.stopPropagation();return}(s=(i=pt(this.editor,o)).notify)==null||s.call(i,this.editor,"beginDrag"),oM(this.editor,t,o),window.isDragging=!0,this.button.buttonElement.style.opacity="0";const r=KL(o);this.dragPreview.handleDragStart(t,r),this.autoScroll.active(),M(o,"dragging")});h(this,"handleDrag",t=>{const{target:e,x:o,y:r}=t;this.oldPos.x===o&&this.oldPos.y===r||(this.oldPos={x:o,y:r},u(J1,e instanceof HTMLElement,"target is invalid"),o===0&&r===0&&this.autoScroll.inactive(),this.dragPreview.handleDrag(t))});h(this,"handleDragEnd",()=>{const t=this.button.blockMenu.currentBlock;u(J1,t,"no dragged block"),window.isDragging=!1,this.button.buttonElement.style.opacity="1",this.dragPreview.handleDragEnd(),this.autoScroll.inactive(),H(t,"dragging")});this.editor=t,this.button=e;const o=this.button.buttonElement;o.draggable=!0,o.addEventListener("dragstart",this.handleDragStart),o.addEventListener("dragend",this.handleDragEnd),o.addEventListener("drag",this.handleDrag),this.dragPreview=new JL(t);const r=bn(o);this.autoScroll=new Km({scrollElement:r,trackMouseEvent:"drag",edge:{top:50,bottom:50}})}destroy(){const t=this.button.buttonElement;t.removeEventListener("dragstart",this.handleDragStart),t.removeEventListener("dragend",this.handleDragEnd),t.removeEventListener("drag",this.handleDrag)}}class nl{constructor(t){h(this,"highlightedBlockId","");h(this,"handleSelectionChange",()=>{this.clearHighlightedBlock()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChange)}highlightBlock(t){this.clearHighlightedBlock(),this.highlightedBlockId=j(t),M(t,"highlighted")}clearHighlightedBlock(){if(this.highlightedBlockId){const t=this.editor.findBlockById(this.highlightedBlockId);t&&H(t,"highlighted"),this.highlightedBlockId=""}}destroy(){}static register(t){return t.addCustom("editor-block-highlighter",()=>new nl(t))}static get(t){return t.getCustom("editor-block-highlighter")}}class U4{constructor(t){h(this,"buttonElement");h(this,"emptyBlockMenu");h(this,"blockMenu");h(this,"dragHandler");h(this,"handleHoverBlock",(t,e,o)=>{if(this.emptyBlockMenu.isVisible||this.blockMenu.isVisible||!this.editor.isWritable())return;const r=this.editor.getCustom("editor-tooltip");if(r&&r.visible()&&(r.hide(),this.buttonElement.setAttribute("data-tooltip-hide-at",`${Date.now()}`)),!t){this.buttonElement.parentElement&&(this.blockMenu.isInMenu(o.target)||this.buttonElement.remove());return}const i=_u(t);this.editor.getBlockIndex(i)===0&&this.editor.getBlockData(i).heading===1||(this.updateButton(i),G1(i,this.buttonElement,Number.MAX_SAFE_INTEGER))});h(this,"handleButtonClick",()=>{if(this.buttonElement.getAttribute("data-type")==="move"){const o=this.blockMenu.currentBlock;if(!o)return;this.editor.selection.selectBlock(o,0),this.blockMenu.show(this.buttonElement),setTimeout(()=>{nl.get(this.editor).highlightBlock(o)});return}const e=this.emptyBlockMenu.currentBlock;!e||(this.editor.selection.selectBlock(e,0),setTimeout(()=>{this.editor.focus(),this.updatePlaceholder(e),this.emptyBlockMenu.show()}))});h(this,"updatePlaceholder",t=>{st(t).setAttribute("data-content-placeholder",
|
|
411
|
+
</svg>`,ZL=1e3;async function QL(n,t){const{width:e}=n.rootContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return o.width>e||o.height>=ZL?"":(await gm.default.toSvg(t)).replace(/margin-block:.*?;/,"").replace(/margin:.*?;/,"")}const YL=w("drag-preview-image");class JL{constructor(t){h(this,"startPosition",null);h(this,"dragContainer",null);h(this,"handleDragStart",async(t,e)=>{const o=t.target;u(YL,o instanceof HTMLButtonElement,`Invalid Drag target:${o}`);const{x:r,y:i}=t;this.startPosition={x:r,y:i};const s=b("div",["drag-image-container"],this.editor.rootContainer),l=b("img",["drag-image"],s),c=b("span",["drag-loading"],s);c.innerHTML=GL;const{x:a,width:d,height:f,y:m}=o.getBoundingClientRect(),p=this.editor.rootContainer.getBoundingClientRect(),A=e.getBoundingClientRect();s.style.left=`${a+d}px`,s.style.top=`${m+f}px`,s.style.width=`${Math.min(p.width/2,A.width)}px`,this.dragContainer=s;const v=await QL(this.editor,e);v?l.src=v:M(s,"drag-placeholder"),hu(s,{status:"loaded"})});h(this,"handleDrag",t=>{if(this.startPosition&&this.dragContainer){const{x:e,y:o}=t;if(e===0&&o===0){this.dragContainer.style.transition="transform 0.15s, opacity .15s",this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:r,y:i}=this.startPosition,s=e-r,l=o-i;this.dragContainer.style.transform=`translate(${s}px, ${l}px)`}});h(this,"handleDragEnd",()=>{this.dragContainer&&(this.dragContainer.remove(),this.startPosition=null,this.dragContainer=null)});this.editor=t}}const z4="drag-preview-element";function KL(n){if(rt(n,z4))return n;const t=n.querySelector(`.${z4}`);return t||(Te(n)?st(n):n)}const J1=w("block-menu-drag-handler");class XL{constructor(t,e){h(this,"dragPreview");h(this,"autoScroll");h(this,"oldPos",{x:0,y:0});h(this,"handleDragStart",t=>{var i,s;const e=t.dataTransfer;e&&(e.dropEffect="move");const o=this.button.blockMenu.currentBlock;if(u(J1,o,"no dragged block"),!this.editor.isBlockWritable(o)){t.preventDefault(),t.stopPropagation();return}(s=(i=pt(this.editor,o)).notify)==null||s.call(i,this.editor,"beginDrag"),oM(this.editor,t,o),window.isDragging=!0,this.button.buttonElement.style.opacity="0";const r=KL(o);this.dragPreview.handleDragStart(t,r),this.autoScroll.active(),M(o,"dragging")});h(this,"handleDrag",t=>{const{target:e,x:o,y:r}=t;this.oldPos.x===o&&this.oldPos.y===r||(this.oldPos={x:o,y:r},u(J1,e instanceof HTMLElement,"target is invalid"),o===0&&r===0&&this.autoScroll.inactive(),this.dragPreview.handleDrag(t))});h(this,"handleDragEnd",()=>{const t=this.button.blockMenu.currentBlock;u(J1,t,"no dragged block"),window.isDragging=!1,this.button.buttonElement.style.opacity="1",this.dragPreview.handleDragEnd(),this.autoScroll.inactive(),H(t,"dragging")});this.editor=t,this.button=e;const o=this.button.buttonElement;o.draggable=!0,o.addEventListener("dragstart",this.handleDragStart),o.addEventListener("dragend",this.handleDragEnd),o.addEventListener("drag",this.handleDrag),this.dragPreview=new JL(t);const r=bn(o);this.autoScroll=new Km({scrollElement:r,trackMouseEvent:"drag",edge:{top:50,bottom:50}})}destroy(){const t=this.button.buttonElement;t.removeEventListener("dragstart",this.handleDragStart),t.removeEventListener("dragend",this.handleDragEnd),t.removeEventListener("drag",this.handleDrag)}}class nl{constructor(t){h(this,"highlightedBlockId","");h(this,"handleSelectionChange",()=>{this.clearHighlightedBlock()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChange)}highlightBlock(t){this.clearHighlightedBlock(),this.highlightedBlockId=j(t),M(t,"highlighted")}clearHighlightedBlock(){if(this.highlightedBlockId){const t=this.editor.findBlockById(this.highlightedBlockId);t&&H(t,"highlighted"),this.highlightedBlockId=""}}destroy(){}static register(t){return t.addCustom("editor-block-highlighter",()=>new nl(t))}static get(t){return t.getCustom("editor-block-highlighter")}}class U4{constructor(t){h(this,"buttonElement");h(this,"emptyBlockMenu");h(this,"blockMenu");h(this,"dragHandler");h(this,"handleHoverBlock",(t,e,o)=>{if(this.emptyBlockMenu.isVisible||this.blockMenu.isVisible||!this.editor.isWritable())return;const r=this.editor.getCustom("editor-tooltip");if(r&&r.visible()&&(r.hide(),this.buttonElement.setAttribute("data-tooltip-hide-at",`${Date.now()}`)),!t){this.buttonElement.parentElement&&(this.blockMenu.isInMenu(o.target)||this.buttonElement.remove());return}const i=_u(t);this.editor.getBlockIndex(i)===0&&this.editor.getBlockData(i).heading===1||(this.updateButton(i),G1(i,this.buttonElement,Number.MAX_SAFE_INTEGER))});h(this,"handleButtonClick",()=>{if(this.buttonElement.getAttribute("data-type")==="move"){const o=this.blockMenu.currentBlock;if(!o)return;this.editor.selection.selectBlock(o,0),this.blockMenu.show(this.buttonElement),setTimeout(()=>{nl.get(this.editor).highlightBlock(o)});return}const e=this.emptyBlockMenu.currentBlock;!e||(this.editor.selection.selectBlock(e,0),setTimeout(()=>{this.editor.focus(),this.updatePlaceholder(e),this.emptyBlockMenu.show()}))});h(this,"updatePlaceholder",t=>{st(t).setAttribute("data-content-placeholder",T.t("blockMenu.button.searchPlaceholder"))});h(this,"handleChanged",()=>{const t=this.emptyBlockMenu.currentBlock;if(!t)return;const e=Tt(this.editor,t)?"insert":"move";this.buttonElement.getAttribute("data-type")!==e&&this.setButtonType(e)});this.editor=t,this.buttonElement=this.createButton(),this.emptyBlockMenu=new ML(t),this.blockMenu=new qL(t),this.editor.addListener("docChanged",this.handleChanged),this.buttonElement.addEventListener("click",this.handleButtonClick),this.dragHandler=new XL(this.editor,this);const e=$t.get(t);e.addListener("change",this.handleHoverBlock),e.addFinder(new LL),nl.register(this.editor)}destroy(){$t.get(this.editor).removeListener("change",this.handleHoverBlock),this.buttonElement.removeEventListener("click",this.handleButtonClick),this.editor.removeListener("docChanged",this.handleChanged),this.emptyBlockMenu.destroy(),this.blockMenu.destroy(),this.buttonElement.remove(),this.dragHandler.destroy()}createButton(){const t=b("button",["block-button"],null);return t.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,T.t("blockMenu.button.tips")),t.innerHTML=j4,t}setButtonType(t){this.buttonElement.setAttribute("data-type",t);const e=`data-editor-tooltip-${this.editor.clientId}`;t==="insert"?(this.buttonElement.innerHTML=WL,this.buttonElement.removeAttribute(e)):(this.buttonElement.innerHTML=j4,this.buttonElement.setAttribute(e,T.t("blockMenu.button.tips")))}updateButton(t){this.emptyBlockMenu.setBlock(t),this.blockMenu.setBlock(t),Tt(this.editor,t)?this.setButtonType("insert"):this.setButtonType("move")}}const tM={blockMenu:{section:{basics:"\u57FA\u7840",system:"\u7CFB\u7EDF",styles:"\u6837\u5F0F",common:"\u901A\u7528",actions:"\u64CD\u4F5C",thirdParty:"\u7B2C\u4E09\u65B9\u5185\u5BB9"},command:{insertAbove:"Insert above",insertAfter:"Insert after"},button:{searchPlaceholder:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",tips:`\u957F\u6309\u62D6\u62FD
|
|
412
412
|
\u70B9\u51FB\u6253\u5F00\u83DC\u5355`}}},eM={blockMenu:{section:{basics:"Basics",system:"System",styles:"Styles",common:"Common",actions:"Actions",thirdParty:"Third-party content"},command:{insertAbove:"Insert above",insertAfter:"Insert after"},button:{searchPlaceholder:"Type to filter",tips:`Long press drag
|
|
413
|
-
Click to open the menu`}}};x.mergeLang({"zh-CN":tM,"en-US":eM});const IV="";class nM{constructor(){h(this,"dragObject",null)}setData(t){this.dragObject=t}getData(){return this.dragObject}clearData(){this.dragObject=null}destroy(){}}function Aa(n){return n.addCustom("drag-data",()=>new nM)}function K1(n,t){if(!t)return null;const e=Aa(n).getData();return!e||e.editorId!==n.id?null:e}function V4(n,t){const e=K1(n,t);return e?n.findBlockById(e.blockId):null}function oM(n,t,e){if(!t.dataTransfer)return;const r=z(e),i=V(r),s=j(e),l={type:"block",editorId:n.id,containerId:i,blockId:s};Aa(n).setData(l)}function rM(n,t,e,o,r){if(!t.dataTransfer)return;const s=z(e),l=V(s),c=j(e),a={type:"custom",customType:o,editorId:n.id,containerId:l,blockId:c,data:r};Aa(n).setData(a)}function q4(n){Aa(n).clearData()}const iM=w("drop-indicator"),ba=2;class sM{constructor(t){h(this,"indicator");h(this,"target",null);this.editor=t,this.indicator=b("div",["editor-drop-indicator"],this.editor.contentElement)}show(t,e){const o=this.getIndicatorRect(t,e),r=this.editor.rootElement.getBoundingClientRect(),i=o.top-r.top,s=o.left-r.left;this.indicator.style.top=`${i}px`,this.indicator.style.left=`${s}px`,this.indicator.style.width=`${o.width}px`,this.indicator.style.height=`${o.height}px`,this.indicator.style.display="",this.target={block:t,insertPos:e}}hide(){this.indicator.style.display="none",this.target=null}getIndicatorRect(t,e){if(typeof e!="string")return e.rect;if(e==="before"){const s=Dr(t);if(!s){u(iM,Ke(z(t)),"block does not in a child container");const a=t.getBoundingClientRect();return new DOMRect(a.x,a.y,a.width,ba)}const l=s.getBoundingClientRect(),c=t.getBoundingClientRect();return new DOMRect(l.x,(l.bottom+c.top)/2,l.width,ba)}const o=Lr(t);if(!o){const s=t.getBoundingClientRect();return new DOMRect(s.x,s.bottom,s.width,ba)}const r=t.getBoundingClientRect(),i=o.getBoundingClientRect();return new DOMRect(r.x,(r.bottom+i.top)/2,r.width,ba)}}const lM=w("find-drop-target");function cM(n,t){const e=document.elementFromPoint(n,t);if(!e)return null;if(vn(e)&&Ke(e))return e;const o=e.firstElementChild;return o&&vn(o)&&Ke(o)?o:null}function aM(n,t){const s=t,l=n;for(let c=0;c<2;c++){const a=l+c*50;for(let d=0;d<5;d++){const f=s+d*8,m=document.elementFromPoint(a,f);if(m){const k=U(m);if(k)return k}if(d===0)continue;const p=s-d*8,A=document.elementFromPoint(a,p);if(A){const k=U(A);if(k)return k}}}return null}function uM(n,t,e){const o=document.elementFromPoint(t,e);if(o){const d=U(o);if(d&&!at(n,d))return d}const r=new Set,i=cM(t,e);if(i){const d=i.getBoundingClientRect();e<d.top+d.height/2?r.add(Ft(i)):r.add(Jt(i))}const s=aM(t,e);s&&r.add(s);const l=Array.from(r),c=d=>{for(let f=0;f<l.length;f++){const m=l[f];if(d!==m&&wt(d,m))return!0}return!1},a=l.filter(d=>!c(d));return a.length>0?a[0]:null}function X1(n,t){if(n.readonly)return!1;const e=z(t);if(Ct(e))return!0;const o=U(e);return u(lM,o,"no parent block"),n.isBlockWritable(o)?X1(n,o):!1}const dM=w("drop-target");class hM{constructor(t){h(this,"getEmbedClassByFile",t=>{let e={};return/image/.test(t.type)?e=this.editor.editorEmbeds.getEmbedClass("image"):/audio/.test(t.type)?e=this.editor.editorEmbeds.getEmbedClass("audio"):/video/.test(t.type)&&(e=this.editor.editorEmbeds.getEmbedClass("video")),u(dM,e,`unSupport file type ${t.type}`),e});h(this,"handleDrop",(t,e,o,r)=>{if(Array.isArray(e)){const i=e;if(i.length>0){let s=r;return i.forEach(l=>{var d,f,m;const c=this.getEmbedClassByFile(l),a=V(o);(m=(d=c.getOptions)==null?void 0:(f=d.call(c,t)).handleInsertEmptyEmbed)==null||m.call(f,t,{containerId:a,blockIndex:s,data:{file:l}}),s+=1}),!0}}return!1});this.editor=t}}class ol{constructor(t){h(this,"indicator");h(this,"lastDropOverResult");h(this,"handlers",[]);h(this,"handleDragOver",t=>{if(!this.editor.isWritable())return;const e=i=>{const s=K1(this.editor,i.dataTransfer),l=V4(this.editor,i.dataTransfer),c=this.findTargetBlock(l,i.x,i.y);if(c&&wt(this.editor.rootContainer,c)){const a=this.findInsertPos(l,c,i.x,i.y,s);if(a)return this.indicator.show(c,a),"move"}return this.indicator.hide(),"none"},o=(i,s)=>{i.dataTransfer&&(i.dataTransfer.dropEffect=s),s==="move"&&i.preventDefault()};if(this.lastDropOverResult&&t.x===this.lastDropOverResult.x&&t.y===this.lastDropOverResult.y){const i=this.lastDropOverResult.dropEffect;o(t,i);return}const r=e(t);o(t,r),this.lastDropOverResult={x:t.x,y:t.y,dropEffect:r}});h(this,"handleDrop",t=>{var i,s;setTimeout(()=>{this.indicator.hide()});const e=K1(this.editor,t.dataTransfer),o=Array.from((s=(i=t.dataTransfer)==null?void 0:i.files)!=null?s:[]);if(!e&&o.length===0){t.dataTransfer&&(t.dataTransfer.dropEffect="none");return}const r=this.indicator.target;if(r){const{block:l,insertPos:c}=r,a=V4(this.editor,t.dataTransfer);this.editor.undoManager.runInGroup(()=>{const d=pt(this.editor,l);if(d.handleDrop&&d.handleDrop(this.editor,l,e!=null?e:o,c,{isSourceBlock:!1,targetBlock:l})){t.preventDefault();return}if(a){const f=pt(this.editor,a);if(f.handleDrop&&f.handleDrop(this.editor,a,e!=null?e:o,c,{isSourceBlock:!0,targetBlock:l})){t.preventDefault();return}}if(typeof c=="string"){const f=z(l);let m=K(l);c==="after"&&(m+=1),t.preventDefault();for(let p=0;p<this.handlers.length;p++)if(this.handlers[p].handleDrop(this.editor,a!=null?a:o,f,m))return;if(a){const p=this.editor.getBlockData(a),A=bo(this.editor.editorBlocks,this.editor.doc.toJSON(),p),[k]=this.editor.insertDocAt(f,m,A);this.editor.selection.selectBlock(k,0),nl.get(this.editor).highlightBlock(k),this.editor.deleteBlock(a)}}}),q4(this.editor)}});this.editor=t,this.indicator=new sM(this.editor),this.handlers.push(new hM(this.editor)),this.editor.contentElement.addEventListener("dragover",this.handleDragOver),this.editor.contentElement.addEventListener("drop",this.handleDrop)}destroy(){this.editor.contentElement.removeEventListener("dragover",this.handleDragOver),this.editor.contentElement.removeEventListener("drop",this.handleDrop),this.handlers=[]}addHandler(t){this.handlers.push(t)}static register(t){return t.addCustom("drop-target",()=>new ol(t))}static get(t){return t.getCustom("drop-target")}canInsertAfter(t,e){return t===null?!0:this.editor.readonly||Lr(e)===t?!1:X1(this.editor,e)}canInsertBefore(t,e){return this.editor.readonly?!1:t===null?!0:!(Dr(e)===t||!X1(this.editor,e)||Ct(z(e))&&K(e)===0)}canDrop(t,e){return t===null||t===e?!0:!wt(t,e)}findTargetBlock(t,e,o){const r=uM(this.editor,e,o);return!r||!wt(this.editor.rootContainer,r)||!this.canDrop(t,r)?null:r}findInsertPos(t,e,o,r,i){let s=e;for(;s;){const c=pt(this.editor,s);if(c.handleDropOver){const a=c.handleDropOver(this.editor,s,i,o,r);if(a)return a;if(a===!1)return null}s=Fl(s)}if(t===e)return"";const l=e.getBoundingClientRect();if(l.top<=r&&r<=l.bottom){if(r<l.top+l.height/2){if(this.canInsertBefore(t,e))return"before";if(this.canInsertAfter(t,e))return"after"}else{if(this.canInsertAfter(t,e))return"after";if(this.canInsertBefore(t,e))return"before"}return""}return r<l.top&&this.canInsertBefore(t,e)?"before":l.bottom<r&&this.canInsertAfter(t,e)?"after":""}}async function fM(n){return await gm.default.toSvg(n)}class mM{constructor(t){h(this,"img");h(this,"dragContainer",null);h(this,"startPosition",null);h(this,"handleDragStart",async t=>{var R;const e=t.target;if(!e||!(e instanceof HTMLImageElement))return;const o=U(e);if(!o||!mn(o))return;const r=Ut.getImageObject(this.editor,o),i=W1(t.target);if(!i)return;const l=T4(t.target).indexOf(i);if(l===-1)return;const c=r.getImages()[l];if(!c)return;const a=t.dataTransfer;a&&(a.dropEffect="move");const d={image:c,index:l,boundingRect:i.getBoundingClientRect()};rM(this.editor,t,o,"image",d),(R=t.dataTransfer)==null||R.setDragImage(this.img,0,0);const{x:f,y:m}=t;this.startPosition={x:f,y:m};const{width:p,height:A}=t.target.getBoundingClientRect(),k=Rt(o),v=b("div",["drag-container"],k);v.style.left=`${f-p/4}px`,v.style.top=`${m-A/4}px`,v.style.width=`${Math.max(p/2,16)}px`,v.style.height=`${A/2}px`,this.dragContainer=v;const T=b("img",["drag-target"],v),L=await fM(i);L&&(T.src=L),window.isDragging=!0});h(this,"handleDrag",t=>{if(this.startPosition&&this.dragContainer){const{x:e,y:o}=t;if(e===0&&o===0){this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:r,y:i}=this.startPosition,s=e-r,l=o-i;this.dragContainer.style.transform=`translate(${s}px, ${l}px)`,this.dragContainer.style.opacity="0.5"}});h(this,"handleDragEnd",()=>{q4(this.editor),window.isDragging=!1,this.dragContainer&&this.dragContainer.remove(),this.dragContainer=null,this.startPosition=null});this.editor=t,this.editor.rootContainer.addEventListener("dragstart",this.handleDragStart),this.editor.rootContainer.addEventListener("dragend",this.handleDragEnd),this.editor.rootContainer.addEventListener("drag",this.handleDrag),this.img=new Image,this.img.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}destroy(){this.editor.rootContainer.removeEventListener("dragstart",this.handleDragStart),this.editor.rootContainer.removeEventListener("dragend",this.handleDragEnd),this.editor.rootContainer.removeEventListener("drag",this.handleDrag)}}class gM{constructor(t){h(this,"handleFocusBlockChanged",(t,e,o)=>{const i=this.editor.getFocusedBlock();if(i&&mn(i)){const s=Ut.getImageObject(this.editor,i);s.getImages().length>0&&s.getSelectedIndex()===-1&&s.setSelectedIndex(0)}o&&mn(o)&&Ut.getImageObject(this.editor,o).blockResizer.disableResize()});this.editor=t,this.editor.addListener("focusBlockChanged",this.handleFocusBlockChanged)}destroy(){this.editor.removeListener("focusBlockChanged",this.handleFocusBlockChanged)}}class pM{constructor(t){h(this,"handleHoveringBlockChange",(t,e)=>{if(e&&mn(e)&&Ut.getImageObject(this.editor,e).disableResizer(),t&&mn(t)){const o=Ut.getImageObject(this.editor,t);this.editor.isBlockWritable(t)&&o.tryEnableResizer()}});this.editor=t,$t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){$t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}}const CM={image:{upload:{failed:'<div class="line-1">\u56FE\u7247\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">\u56FE\u7247\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>',remote:{failed:'<div class="line-1">\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5916\u90E8\u94FE\u63A5\u5DF2\u5931\u6548</div><div class="line-2">\u8BF7\u5C06\u539F\u56FE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u4E0A\u4F20\uFF0C <a href="" class="retry-upload">\u6253\u5F00\u56FE\u7247\u94FE\u63A5</a></div>',tooltip:"\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5982\u679C\u94FE\u63A5\u5931\u6548\u56FE\u7247\u5C06\u65E0\u6CD5\u67E5\u770B\uFF0C\u5EFA\u8BAE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u6DFB\u52A0\u5230\u9875\u9762\u4E2D"}},abstract:"\u56FE\u7247"}},AM={image:{upload:{failed:'<div class="line-1">Image upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">Image failed to load</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>',remote:{failed:'<div class="line-1">The picture comes from an external link, and the external link has expired</div><div class="line-2">Please save the original image locally and then upload it. <a href="" class="retry-upload">Open image link</a></div>',tooltip:"\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5982\u679C\u94FE\u63A5\u5931\u6548\u56FE\u7247\u5C06\u65E0\u6CD5\u67E5\u770B\uFF0C\u5EFA\u8BAE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u6DFB\u52A0\u5230\u9875\u9762\u4E2D"}},image:"Image"}};x.mergeLang({"zh-CN":CM,"en-US":AM});function bM(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=ve(i,o),l=vt(s);let c=o;if(l.endsWith("![]()"))c-=5;else if(l.endsWith("![]"))c-=3;else return!1;const a=o;return Qo("image/*").then(d=>{n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,c,a-c);let f=e+1;vt(n.getBlockText(r)).trim()?(Hr(n,r,c,{forceInsertAfter:!0}),c===0&&(n.deleteBlock(r),f--)):(n.deleteBlock(r),f--),Hu(n,"image",t,f,{file:d})})}),!0}class vM{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&bM(t,e,o,r))}}function yM(n){const t=n.getFocusedBlock(),e=Lr(t);if(e&&mn(e)){n.selection.selectBlock(e,0);const o=Ut.getImageObject(n,e);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function kM(n){const t=n.getFocusedBlock(),e=Dr(t);if(e&&mn(e)){n.selection.selectBlock(e,0);const o=Ut.getImageObject(n,e);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function wM(n){const e=n.getFocusedBlock();if(e&&mn(e)){const o=Ut.getImageObject(n,e),r=o.getImages();if(r.length>0){const i=o.getSelectedIndex();if(i===-1)return o.setSelectedIndex(r.length-1),!0;if(i>0)return o.setSelectedIndex(i-1),!0}}}function BM(n){const e=n.getFocusedBlock();if(e&&mn(e)){const o=Ut.getImageObject(n,e),r=o.getImages();if(r.length>0){const i=o.getSelectedIndex();if(i===-1)return o.setSelectedIndex(0),!0;if(i<r.length-1)return o.setSelectedIndex(i+1),!0}}}function EM(n,t,e,o){const r=e.getImages()[o],i=e.getImages().length===1?e.getWidthPercent():r.flex*100,s=ae([r],i),l={id:P(),type:"embed",embedType:"image",embedData:s},c=n.options.componentsOptions.image;c!=null&&c.defaultAlign&&(l.align=c.defaultAlign);const a={blocks:{root:[l]},comments:{},meta:{}},d=document.createElement("canvas");d.width=t.naturalWidth,d.height=t.naturalHeight;const f=d.getContext("2d");if(!f)return;f.drawImage(t,0,0,d.width,d.height);const p=d.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),A=wu(p),k=new File([A],`${Date.now()}.png`,{type:"image/png"});us(n,a);const T=`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`,E=as(T,a),L=$r(n,a),R=new Blob([E],{type:"text/html"});return Nl([{type:"text/plain",data:new Blob([L],{type:"text/plain"})},{type:"text/html",data:R},{type:"image/png",data:k}]),!0}function W4(n){const t=n.selection.range;if(t.start.blockId!==t.end.blockId)return;const o=n.getFocusedBlock();if(o&&mn(o)){const r=Ut.getImageObject(n,o);if(r.getImages().length>0){const s=r.getSelectedIndex();if(s!==-1){const c=Kn(o)[s].querySelector("img");if(c)return EM(n,c,r,s)}}}}function tf(n){const e=n.getFocusedBlock();if(e&&mn(e)){const o=Ut.getImageObject(n,e);if(o.getImages().length>1){const i=o.getSelectedIndex();if(i!==-1)return o.removeImage(i),!0}}}function IM(n){if(W4(n))return tf(n),!0}const xM={ArrowLeft:wM,ArrowRight:BM,ArrowUp:kM,ArrowDown:yM,"CtrlOrCmd+C":W4,"CtrlOrCmd+X":IM,Delete:tf,Backspace:tf};function TM(n,t,e,o,r,i){Ut.create(n,e).createContent(r,i,t),n.addCustom("image-select-handler",()=>new gM(n)),n.addCustom("image-resizer",()=>new pM(n)),setTimeout(()=>{n.addCustom("drag-handler",()=>new mM(n))})}function SM(n,t,e,o){const r=t.embedData,i=di(r);return o==="html"?i.map(s=>`<img src="${n.doc.buildResourceUrl(s.src,{withToken:!0})}">`).join(""):o==="markdown"?`${i.map(l=>`})`).join(`
|
|
413
|
+
Click to open the menu`}}};T.mergeLang({"zh-CN":tM,"en-US":eM});const IV="";class nM{constructor(){h(this,"dragObject",null)}setData(t){this.dragObject=t}getData(){return this.dragObject}clearData(){this.dragObject=null}destroy(){}}function Aa(n){return n.addCustom("drag-data",()=>new nM)}function K1(n,t){if(!t)return null;const e=Aa(n).getData();return!e||e.editorId!==n.id?null:e}function V4(n,t){const e=K1(n,t);return e?n.findBlockById(e.blockId):null}function oM(n,t,e){if(!t.dataTransfer)return;const r=z(e),i=V(r),s=j(e),l={type:"block",editorId:n.id,containerId:i,blockId:s};Aa(n).setData(l)}function rM(n,t,e,o,r){if(!t.dataTransfer)return;const s=z(e),l=V(s),c=j(e),a={type:"custom",customType:o,editorId:n.id,containerId:l,blockId:c,data:r};Aa(n).setData(a)}function q4(n){Aa(n).clearData()}const iM=w("drop-indicator"),ba=2;class sM{constructor(t){h(this,"indicator");h(this,"target",null);this.editor=t,this.indicator=b("div",["editor-drop-indicator"],this.editor.contentElement)}show(t,e){const o=this.getIndicatorRect(t,e),r=this.editor.rootElement.getBoundingClientRect(),i=o.top-r.top,s=o.left-r.left;this.indicator.style.top=`${i}px`,this.indicator.style.left=`${s}px`,this.indicator.style.width=`${o.width}px`,this.indicator.style.height=`${o.height}px`,this.indicator.style.display="",this.target={block:t,insertPos:e}}hide(){this.indicator.style.display="none",this.target=null}getIndicatorRect(t,e){if(typeof e!="string")return e.rect;if(e==="before"){const s=Dr(t);if(!s){u(iM,Ke(z(t)),"block does not in a child container");const a=t.getBoundingClientRect();return new DOMRect(a.x,a.y,a.width,ba)}const l=s.getBoundingClientRect(),c=t.getBoundingClientRect();return new DOMRect(l.x,(l.bottom+c.top)/2,l.width,ba)}const o=Lr(t);if(!o){const s=t.getBoundingClientRect();return new DOMRect(s.x,s.bottom,s.width,ba)}const r=t.getBoundingClientRect(),i=o.getBoundingClientRect();return new DOMRect(r.x,(r.bottom+i.top)/2,r.width,ba)}}const lM=w("find-drop-target");function cM(n,t){const e=document.elementFromPoint(n,t);if(!e)return null;if(vn(e)&&Ke(e))return e;const o=e.firstElementChild;return o&&vn(o)&&Ke(o)?o:null}function aM(n,t){const s=t,l=n;for(let c=0;c<2;c++){const a=l+c*50;for(let d=0;d<5;d++){const f=s+d*8,m=document.elementFromPoint(a,f);if(m){const k=U(m);if(k)return k}if(d===0)continue;const p=s-d*8,A=document.elementFromPoint(a,p);if(A){const k=U(A);if(k)return k}}}return null}function uM(n,t,e){const o=document.elementFromPoint(t,e);if(o){const d=U(o);if(d&&!at(n,d))return d}const r=new Set,i=cM(t,e);if(i){const d=i.getBoundingClientRect();e<d.top+d.height/2?r.add(Ft(i)):r.add(Jt(i))}const s=aM(t,e);s&&r.add(s);const l=Array.from(r),c=d=>{for(let f=0;f<l.length;f++){const m=l[f];if(d!==m&&wt(d,m))return!0}return!1},a=l.filter(d=>!c(d));return a.length>0?a[0]:null}function X1(n,t){if(n.readonly)return!1;const e=z(t);if(Ct(e))return!0;const o=U(e);return u(lM,o,"no parent block"),n.isBlockWritable(o)?X1(n,o):!1}const dM=w("drop-target");class hM{constructor(t){h(this,"getEmbedClassByFile",t=>{let e={};return/image/.test(t.type)?e=this.editor.editorEmbeds.getEmbedClass("image"):/audio/.test(t.type)?e=this.editor.editorEmbeds.getEmbedClass("audio"):/video/.test(t.type)&&(e=this.editor.editorEmbeds.getEmbedClass("video")),u(dM,e,`unSupport file type ${t.type}`),e});h(this,"handleDrop",(t,e,o,r)=>{if(Array.isArray(e)){const i=e;if(i.length>0){let s=r;return i.forEach(l=>{var d,f,m;const c=this.getEmbedClassByFile(l),a=V(o);(m=(d=c.getOptions)==null?void 0:(f=d.call(c,t)).handleInsertEmptyEmbed)==null||m.call(f,t,{containerId:a,blockIndex:s,data:{file:l}}),s+=1}),!0}}return!1});this.editor=t}}class ol{constructor(t){h(this,"indicator");h(this,"lastDropOverResult");h(this,"handlers",[]);h(this,"handleDragOver",t=>{if(!this.editor.isWritable())return;const e=i=>{const s=K1(this.editor,i.dataTransfer),l=V4(this.editor,i.dataTransfer),c=this.findTargetBlock(l,i.x,i.y);if(c&&wt(this.editor.rootContainer,c)){const a=this.findInsertPos(l,c,i.x,i.y,s);if(a)return this.indicator.show(c,a),"move"}return this.indicator.hide(),"none"},o=(i,s)=>{i.dataTransfer&&(i.dataTransfer.dropEffect=s),s==="move"&&i.preventDefault()};if(this.lastDropOverResult&&t.x===this.lastDropOverResult.x&&t.y===this.lastDropOverResult.y){const i=this.lastDropOverResult.dropEffect;o(t,i);return}const r=e(t);o(t,r),this.lastDropOverResult={x:t.x,y:t.y,dropEffect:r}});h(this,"handleDrop",t=>{var i,s;setTimeout(()=>{this.indicator.hide()});const e=K1(this.editor,t.dataTransfer),o=Array.from((s=(i=t.dataTransfer)==null?void 0:i.files)!=null?s:[]);if(!e&&o.length===0){t.dataTransfer&&(t.dataTransfer.dropEffect="none");return}const r=this.indicator.target;if(r){const{block:l,insertPos:c}=r,a=V4(this.editor,t.dataTransfer);this.editor.undoManager.runInGroup(()=>{const d=pt(this.editor,l);if(d.handleDrop&&d.handleDrop(this.editor,l,e!=null?e:o,c,{isSourceBlock:!1,targetBlock:l})){t.preventDefault();return}if(a){const f=pt(this.editor,a);if(f.handleDrop&&f.handleDrop(this.editor,a,e!=null?e:o,c,{isSourceBlock:!0,targetBlock:l})){t.preventDefault();return}}if(typeof c=="string"){const f=z(l);let m=K(l);c==="after"&&(m+=1),t.preventDefault();for(let p=0;p<this.handlers.length;p++)if(this.handlers[p].handleDrop(this.editor,a!=null?a:o,f,m))return;if(a){const p=this.editor.getBlockData(a),A=bo(this.editor.editorBlocks,this.editor.doc.toJSON(),p),[k]=this.editor.insertDocAt(f,m,A);this.editor.selection.selectBlock(k,0),nl.get(this.editor).highlightBlock(k),this.editor.deleteBlock(a)}}}),q4(this.editor)}});this.editor=t,this.indicator=new sM(this.editor),this.handlers.push(new hM(this.editor)),this.editor.contentElement.addEventListener("dragover",this.handleDragOver),this.editor.contentElement.addEventListener("drop",this.handleDrop)}destroy(){this.editor.contentElement.removeEventListener("dragover",this.handleDragOver),this.editor.contentElement.removeEventListener("drop",this.handleDrop),this.handlers=[]}addHandler(t){this.handlers.push(t)}static register(t){return t.addCustom("drop-target",()=>new ol(t))}static get(t){return t.getCustom("drop-target")}canInsertAfter(t,e){return t===null?!0:this.editor.readonly||Lr(e)===t?!1:X1(this.editor,e)}canInsertBefore(t,e){return this.editor.readonly?!1:t===null?!0:!(Dr(e)===t||!X1(this.editor,e)||Ct(z(e))&&K(e)===0)}canDrop(t,e){return t===null||t===e?!0:!wt(t,e)}findTargetBlock(t,e,o){const r=uM(this.editor,e,o);return!r||!wt(this.editor.rootContainer,r)||!this.canDrop(t,r)?null:r}findInsertPos(t,e,o,r,i){let s=e;for(;s;){const c=pt(this.editor,s);if(c.handleDropOver){const a=c.handleDropOver(this.editor,s,i,o,r);if(a)return a;if(a===!1)return null}s=Fl(s)}if(t===e)return"";const l=e.getBoundingClientRect();if(l.top<=r&&r<=l.bottom){if(r<l.top+l.height/2){if(this.canInsertBefore(t,e))return"before";if(this.canInsertAfter(t,e))return"after"}else{if(this.canInsertAfter(t,e))return"after";if(this.canInsertBefore(t,e))return"before"}return""}return r<l.top&&this.canInsertBefore(t,e)?"before":l.bottom<r&&this.canInsertAfter(t,e)?"after":""}}async function fM(n){return await gm.default.toSvg(n)}class mM{constructor(t){h(this,"img");h(this,"dragContainer",null);h(this,"startPosition",null);h(this,"handleDragStart",async t=>{var R;const e=t.target;if(!e||!(e instanceof HTMLImageElement))return;const o=U(e);if(!o||!mn(o))return;const r=Ut.getImageObject(this.editor,o),i=W1(t.target);if(!i)return;const l=T4(t.target).indexOf(i);if(l===-1)return;const c=r.getImages()[l];if(!c)return;const a=t.dataTransfer;a&&(a.dropEffect="move");const d={image:c,index:l,boundingRect:i.getBoundingClientRect()};rM(this.editor,t,o,"image",d),(R=t.dataTransfer)==null||R.setDragImage(this.img,0,0);const{x:f,y:m}=t;this.startPosition={x:f,y:m};const{width:p,height:A}=t.target.getBoundingClientRect(),k=Rt(o),v=b("div",["drag-container"],k);v.style.left=`${f-p/4}px`,v.style.top=`${m-A/4}px`,v.style.width=`${Math.max(p/2,16)}px`,v.style.height=`${A/2}px`,this.dragContainer=v;const x=b("img",["drag-target"],v),L=await fM(i);L&&(x.src=L),window.isDragging=!0});h(this,"handleDrag",t=>{if(this.startPosition&&this.dragContainer){const{x:e,y:o}=t;if(e===0&&o===0){this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:r,y:i}=this.startPosition,s=e-r,l=o-i;this.dragContainer.style.transform=`translate(${s}px, ${l}px)`,this.dragContainer.style.opacity="0.5"}});h(this,"handleDragEnd",()=>{q4(this.editor),window.isDragging=!1,this.dragContainer&&this.dragContainer.remove(),this.dragContainer=null,this.startPosition=null});this.editor=t,this.editor.rootContainer.addEventListener("dragstart",this.handleDragStart),this.editor.rootContainer.addEventListener("dragend",this.handleDragEnd),this.editor.rootContainer.addEventListener("drag",this.handleDrag),this.img=new Image,this.img.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}destroy(){this.editor.rootContainer.removeEventListener("dragstart",this.handleDragStart),this.editor.rootContainer.removeEventListener("dragend",this.handleDragEnd),this.editor.rootContainer.removeEventListener("drag",this.handleDrag)}}class gM{constructor(t){h(this,"handleFocusBlockChanged",(t,e,o)=>{const i=this.editor.getFocusedBlock();if(i&&mn(i)){const s=Ut.getImageObject(this.editor,i);s.getImages().length>0&&s.getSelectedIndex()===-1&&s.setSelectedIndex(0)}o&&mn(o)&&Ut.getImageObject(this.editor,o).blockResizer.disableResize()});this.editor=t,this.editor.addListener("focusBlockChanged",this.handleFocusBlockChanged)}destroy(){this.editor.removeListener("focusBlockChanged",this.handleFocusBlockChanged)}}class pM{constructor(t){h(this,"handleHoveringBlockChange",(t,e)=>{if(e&&mn(e)&&Ut.getImageObject(this.editor,e).disableResizer(),t&&mn(t)){const o=Ut.getImageObject(this.editor,t);this.editor.isBlockWritable(t)&&o.tryEnableResizer()}});this.editor=t,$t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){$t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}}const CM={image:{upload:{failed:'<div class="line-1">\u56FE\u7247\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">\u56FE\u7247\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>',remote:{failed:'<div class="line-1">\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5916\u90E8\u94FE\u63A5\u5DF2\u5931\u6548</div><div class="line-2">\u8BF7\u5C06\u539F\u56FE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u4E0A\u4F20\uFF0C <a href="" class="retry-upload">\u6253\u5F00\u56FE\u7247\u94FE\u63A5</a></div>',tooltip:"\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5982\u679C\u94FE\u63A5\u5931\u6548\u56FE\u7247\u5C06\u65E0\u6CD5\u67E5\u770B\uFF0C\u5EFA\u8BAE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u6DFB\u52A0\u5230\u9875\u9762\u4E2D"}},abstract:"\u56FE\u7247"}},AM={image:{upload:{failed:'<div class="line-1">Image upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">Image failed to load</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>',remote:{failed:'<div class="line-1">The picture comes from an external link, and the external link has expired</div><div class="line-2">Please save the original image locally and then upload it. <a href="" class="retry-upload">Open image link</a></div>',tooltip:"\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5982\u679C\u94FE\u63A5\u5931\u6548\u56FE\u7247\u5C06\u65E0\u6CD5\u67E5\u770B\uFF0C\u5EFA\u8BAE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u6DFB\u52A0\u5230\u9875\u9762\u4E2D"}},image:"Image"}};T.mergeLang({"zh-CN":CM,"en-US":AM});function bM(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=ve(i,o),l=vt(s);let c=o;if(l.endsWith("![]()"))c-=5;else if(l.endsWith("![]"))c-=3;else return!1;const a=o;return Qo("image/*").then(d=>{n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,c,a-c);let f=e+1;vt(n.getBlockText(r)).trim()?(Hr(n,r,c,{forceInsertAfter:!0}),c===0&&(n.deleteBlock(r),f--)):(n.deleteBlock(r),f--),Hu(n,"image",t,f,{file:d})})}),!0}class vM{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&bM(t,e,o,r))}}function yM(n){const t=n.getFocusedBlock(),e=Lr(t);if(e&&mn(e)){n.selection.selectBlock(e,0);const o=Ut.getImageObject(n,e);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function kM(n){const t=n.getFocusedBlock(),e=Dr(t);if(e&&mn(e)){n.selection.selectBlock(e,0);const o=Ut.getImageObject(n,e);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function wM(n){const e=n.getFocusedBlock();if(e&&mn(e)){const o=Ut.getImageObject(n,e),r=o.getImages();if(r.length>0){const i=o.getSelectedIndex();if(i===-1)return o.setSelectedIndex(r.length-1),!0;if(i>0)return o.setSelectedIndex(i-1),!0}}}function BM(n){const e=n.getFocusedBlock();if(e&&mn(e)){const o=Ut.getImageObject(n,e),r=o.getImages();if(r.length>0){const i=o.getSelectedIndex();if(i===-1)return o.setSelectedIndex(0),!0;if(i<r.length-1)return o.setSelectedIndex(i+1),!0}}}function EM(n,t,e,o){const r=e.getImages()[o],i=e.getImages().length===1?e.getWidthPercent():r.flex*100,s=ae([r],i),l={id:P(),type:"embed",embedType:"image",embedData:s},c=n.options.componentsOptions.image;c!=null&&c.defaultAlign&&(l.align=c.defaultAlign);const a={blocks:{root:[l]},comments:{},meta:{}},d=document.createElement("canvas");d.width=t.naturalWidth,d.height=t.naturalHeight;const f=d.getContext("2d");if(!f)return;f.drawImage(t,0,0,d.width,d.height);const p=d.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),A=wu(p),k=new File([A],`${Date.now()}.png`,{type:"image/png"});us(n,a);const x=`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`,E=as(x,a),L=$r(n,a),R=new Blob([E],{type:"text/html"});return Nl([{type:"text/plain",data:new Blob([L],{type:"text/plain"})},{type:"text/html",data:R},{type:"image/png",data:k}]),!0}function W4(n){const t=n.selection.range;if(t.start.blockId!==t.end.blockId)return;const o=n.getFocusedBlock();if(o&&mn(o)){const r=Ut.getImageObject(n,o);if(r.getImages().length>0){const s=r.getSelectedIndex();if(s!==-1){const c=Kn(o)[s].querySelector("img");if(c)return EM(n,c,r,s)}}}}function tf(n){const e=n.getFocusedBlock();if(e&&mn(e)){const o=Ut.getImageObject(n,e);if(o.getImages().length>1){const i=o.getSelectedIndex();if(i!==-1)return o.removeImage(i),!0}}}function IM(n){if(W4(n))return tf(n),!0}const xM={ArrowLeft:wM,ArrowRight:BM,ArrowUp:kM,ArrowDown:yM,"CtrlOrCmd+C":W4,"CtrlOrCmd+X":IM,Delete:tf,Backspace:tf};function TM(n,t,e,o,r,i){Ut.create(n,e).createContent(r,i,t),n.addCustom("image-select-handler",()=>new gM(n)),n.addCustom("image-resizer",()=>new pM(n)),setTimeout(()=>{n.addCustom("drag-handler",()=>new mM(n))})}function SM(n,t,e,o){const r=t.embedData,i=di(r);return o==="html"?i.map(s=>`<img src="${n.doc.buildResourceUrl(s.src,{withToken:!0})}">`).join(""):o==="markdown"?`${i.map(l=>`})`).join(`
|
|
414
414
|
`)}
|
|
415
415
|
`:i.map(s=>n.doc.buildResourceUrl(s.src,{withToken:!0})).join(`
|
|
416
|
-
`)}class DM{constructor(){h(this,"group","image");h(this,"commands",[])}executeCommand(t,e,o){if(o.id==="replace-image"){const{block:r,image:i}=o.data;Ut.getImageObject(t,r).replaceImage(0,i)}}}function LM(){return{blockCommands:{image:new DM},abstract:`[${
|
|
416
|
+
`)}class DM{constructor(){h(this,"group","image");h(this,"commands",[])}executeCommand(t,e,o){if(o.id==="replace-image"){const{block:r,image:i}=o.data;Ut.getImageObject(t,r).replaceImage(0,i)}}}function LM(){return{blockCommands:{image:new DM},abstract:`[${T.t("image.abstract")}]`}}function MM(){return{name:"Image",insertEmbedCommandItems:[{id:"insert-image",name:"Image",icon:Mw,group:"common",subText:"/image",order:100}],handleInsertEmptyEmbed:async(n,t)=>{var m;let e;if((m=t.data)!=null&&m.file&&(e=t.data.file),e=e!=null?e:await Qo("image/*",{}),!e)return null;const o=await BL(e),r=n.rootContainer.clientWidth,i=o.width<r?Math.min(100,o.width/r*100):100,s={src:"",width:o.width,height:o.height,flex:1,virtualSize:!1},l=ae([s],i),c={id:P(),type:"embed",embedType:"image",embedData:l},a=n.options.componentsOptions.image;a!=null&&a.defaultAlign&&(c.align=a.defaultAlign);const d=n.insertBlock(t.containerId,t.blockIndex,c);return Ut.getImageObject(n,d).replaceImage(0,e),d}}}function RM(n,t,e){var d;const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="image"||!_(n,t))return null;const i=r.match(/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/),s=(d=i==null?void 0:i.groups)==null?void 0:d.filename;if(!s)return null;const l={src:s},c={id:P(),type:"embed",embedType:"image",embedData:l},a=n.options.componentsOptions.image.defaultAlign;return a&&(c.align=a),{blockData:c}}function OM(n,t){const e=j(t);n.destroyCustom(`image-${e}`)}const G4={embedType:"image",createEmbedContent:TM,convertTo:SM,convertFrom:RM,getBlockProperties:LM,getOptions:MM,handleDrop:IL,handleDropOver:SL,handleDeleteBlock:OM},Z4={"en-US":{title:"UML",empty:"Empty Graph",loading:"Loading diagram editor...",abstract:"UML"},"zh-CN":{title:"\u6D41\u7A0B\u56FE/UML",empty:"\u7A7A\u56FE\u8868",loading:"\u52A0\u8F7D\u4E2D",abstract:"\u6D41\u7A0B\u56FE/UML"}};function NM(n,t){const e={};t&&Object.entries(Z4).forEach(([o,r])=>{e[o]={[`${t}`]:r}}),T.mergeLang(e||n)}function PM(){NM(Z4,"drawio")}class $M{constructor(){h(this,"isAlreadyInstalled",!1)}stamp(){this.isAlreadyInstalled=!0}isFirstInit(){return this.isAlreadyInstalled===!1}destroy(){}}const _M=w("exclusive-block");function ef(n,t,e){n.style.pointerEvents="none",M(n,"block-exclusive"),n.setAttribute("data-user-name",e),n.setAttribute("data-user-id",t)}function Q4(n){n.style.pointerEvents="",H(n,"block-exclusive"),n.removeAttribute("data-user-name"),n.removeAttribute("data-user-id")}function FM(n,t,e,o,r){_M.debug(`block ${j(t)} ${e?"exclusive":"unexclusive"}, ${o}, ${r}`),e?ef(t,o,r):Q4(t)}function HM(n){return n.classList.contains("block-exclusive")}function Y4(n,t){t.blockIds.forEach(e=>{const o=n.findBlockById(e);o&&FM(n,o,t.exclusive,t.userId,t.displayName)})}class Oo{constructor(t){h(this,"exclusiveBlockIds",new Set);h(this,"exclusiveBlockTimer",0);h(this,"remoteExclusiveBlockIds",new Map);h(this,"handleUserChanged",t=>{const e=new Set(t.map(r=>r.userId));Array.from(this.remoteExclusiveBlockIds.entries()).forEach(([r,i])=>{if(!e.has(i.userId)){this.remoteExclusiveBlockIds.delete(r);const s={...i,exclusive:!1};Y4(this.editor,s)}});const o=Array.from(this.exclusiveBlockIds).map(r=>this.editor.findBlockById(r)).filter(r=>!!r);o.length>0&&this.broadcastExclusiveBlockMessage(o,!0)});this.editor=t,t.doc.registerCallback(this),t.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}destroy(){this.stopExclusiveBlockTimer(),this.editor.doc.unregisterCallback(this),this.editor.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}onCustomMessage(t){if(t.type==="exclusiveBlock"){const e=t;Y4(this.editor,e),e.blockIds.forEach(o=>{e.exclusive?this.remoteExclusiveBlockIds.set(o,e):this.remoteExclusiveBlockIds.delete(o)})}}getExclusiveMessage(t){return this.remoteExclusiveBlockIds.get(t)}broadcastExclusiveBlockMessage(t,e){if(this.editor.readonly||t.length===0)return;const o=this.editor.doc.getUser(),r={type:"exclusiveBlock",userId:o.userId,displayName:o.displayName,blockIds:t.map(i=>j(i)),exclusive:e};this.editor.doc.broadcastMessage(r)}exclusiveBlock(t){this.exclusiveBlockIds.has(j(t))||(this.broadcastExclusiveBlockMessage([t],!0),this.exclusiveBlockIds.add(j(t)),this.exclusiveBlockIds.size===1&&this.startExclusiveBlockTimer())}unexclusiveBlock(t){!this.exclusiveBlockIds.has(j(t))||(this.exclusiveBlockIds.delete(j(t)),this.broadcastExclusiveBlockMessage([t],!1),this.exclusiveBlockIds.size===0&&this.stopExclusiveBlockTimer())}startExclusiveBlockTimer(){this.exclusiveBlockTimer=window.setInterval(()=>{Array.from(this.exclusiveBlockIds.keys()).forEach(t=>{this.broadcastExclusiveBlockMessage([this.editor.getBlockById(t)],!0)})},30*1e3)}stopExclusiveBlockTimer(){clearInterval(this.exclusiveBlockTimer),this.exclusiveBlockTimer=0}static get(t){return t.addCustom("exclusiveBlock",()=>new Oo(t))}static register(t){return this.get(t)}}function J4(n,t){Oo.get(n).exclusiveBlock(t)}function K4(n,t){Oo.get(n).unexclusiveBlock(t)}class X4{writable(t,e){if(HM(e))return!1}create(t,e,o,r,i){const s=Oo.get(t).getExclusiveMessage(i.id);s&&ef(r,s.userId,s.displayName)}update(t,e,o,r,i){const s=Oo.get(t).getExclusiveMessage(i.id);s?ef(r,s.userId,s.displayName):Q4(r)}}const SV="";function jM(n){const t=Object.entries(n);for(let e=0;e<t.length;e++){const[o,r]=t[e];if(o.toLocaleLowerCase()==="content-type")return r}return""}async function zM(n,t,e=!0){try{const o=await n.doc.request(t,{method:"get",responseType:"blob",withCredentials:e}),r=new FileReader,i=new Promise((d,f)=>{r.onload=d,r.onerror=f});r.readAsArrayBuffer(o.data),await i;const s=r.result,l=jM(o.headers).toLocaleLowerCase();let c="";if(l){const d=au.default[l].extensions;d&&d.length>0&&(c=d[0])}return new File([s],`${Date.now()}.${c}`,{type:l})}catch{return null}}async function nf(n,t){return await zM(n,t)}async function t3(n,t){const e=await nf(n,t);return e?await e.text():null}const UM=n=>{const t=n.getBoundingClientRect();return t.width<=1&&t.height<=1},VM=n=>{var i,s;const t=(i=n.getAttribute("width"))!=null?i:"",e=(s=n.getAttribute("height"))!=null?s:"",o=Number.parseInt(t,10),r=Number.parseInt(e,10);return!o||!r||o<=1&&r<=1},qM=n=>n!=null?n[n.textContent===void 0?"text":"textContent"]:"",e3={"zh-CN":"zh","zh-TW":"zh-tw","js-JP":"zh"},WM="https://embed.diagrams.net/?embed=1",GM="https://www.draw.io/embed.js",ZM="https://cdn.jsdelivr.net/npm/pako@2.0.3/dist/pako.es5.js",QM=`
|
|
417
417
|
<mxStylesheet>
|
|
418
418
|
<add as="defaultVertex">
|
|
419
419
|
<add as="shape" value="label"/>
|
|
@@ -523,13 +523,13 @@ ${s}
|
|
|
523
523
|
<add as="fillColor" value="#ffffff"/>
|
|
524
524
|
</add>
|
|
525
525
|
</mxStylesheet>
|
|
526
|
-
`,n3=0,YM=30*1e3,o3="editor-empty-drawio",r3="show-full-screen-iframe",Vt=w("embed-block-drawio");function hi(n){return n.options.componentsOptions.drawIO||{}}function JM(n){const e=hi(n).lang||"zh-CN";return e3[e]||e3["zh-CN"]}function KM(n){var r;const e=((r=(hi(n)||{}).cdn)==null?void 0:r.drawioIframe)||WM,o=JM(n);return ku(e,{spin:1,proto:"json",configure:1,lang:o})}function XM(n){const t=()=>{u(Vt,n,"el does not exist");const o=document.body.clientWidth||document.documentElement.clientWidth,r=document.body.clientHeight||document.documentElement.clientHeight;n.setAttribute("width",`${o-2*n3}`),n.setAttribute("height",`${r-2*n3}`)},e=()=>{window.removeEventListener("resize",t)};return t(),window.addEventListener("resize",t),{disconnect:e}}async function tR(n){const e=(hi(n)||{}).callbacks||{},{onCreateDrawIoFrame:o,onCloseDrawIoFrame:r}=e;let i=null,s;if(o)i=await o(n),u(Vt,i,"iframe create failed"),s=()=>{u(Vt,i,"iframe does not exist"),u(Vt,r,"missing parameters: onCloseDrawIoFrame"),r(n,i)};else{const l=b("div",["editor-drawio-iframe-container","loading"],document.body);l.setAttribute("data-placeholder",x.t("drawio.loading")),i=b("iframe",["drawio-iframe-element"],l),i.setAttribute("frameborder","0"),M(l,r3);const{disconnect:c}=XM(i);s=()=>{u(Vt,i,"iframe does not exist"),c(),document.body.removeChild(l),H(l,r3)}}return{drawioIframe:i,exit:s}}async function eR(n,t,e,o){var r,i;try{o&&Vt.debug("auto saving drawio data");const s=new Blob([e]),l=new File([s],"drawio.svg",{type:"image/svg+xml"});try{const c=n.findBlockById(j(t));if(c){const a=await n.doc.uploadResource(l),{resourceId:d}=a,m={...n.getBlockData(c),embedData:{src:d}};n.updateBlockData(c,m)}else Vt.error("block has been deleted")}catch(c){const a=`failed to upload drawio data: ${c.message}`;Vt.error(a)}}catch(s){const l=`failed to save drawio data: ${s.message}`,c=hi(n);if((r=c.callbacks)!=null&&r.onError){const a=new Error(l);a.code="SaveDrawIo",(i=c.callbacks)==null||i.onError(n,a)}}}function nR(n,t,e,o,r,i,s){const l=()=>{window.removeEventListener("message",c),i()},c=async a=>{var d,f;if(u(Vt,o.contentWindow,"iframe.contentWindow does not exist"),a.data.length>0){const m=JSON.parse(a.data),p=e.xmlSvg||e.xml,A=document.querySelectorAll(".editor-drawio-iframe-container");switch(m.event){case"configure":o.contentWindow.postMessage(JSON.stringify({action:"configure",config:{defaultFonts:["Humor Sans","Helvetica","Times New Roman"]}}),"*");break;case"init":p!=null&&o.contentWindow.postMessage(JSON.stringify({action:"load",saveAndExit:1,noSaveBtn:1,noExitBtn:0,xml:p}),"*"),r(),A.forEach(v=>{H(v,"loading")});break;case"export":const k=Ml(m.data.substring(m.data.indexOf(",")+1));eR(n,t,k,!!((d=m.message)!=null&&d.autoSave)),(f=m.message)!=null&&f.autoSave||l();break;case"save":o.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph"}),"*");break;case"exit":l();break}}};window.addEventListener("message",c)}async function i3(n,t,e,o){if(o)return;o=!0;const r=hi(n)||{},{callbacks:i}=r;let s;i&&(i==null?void 0:i.onBeginInitDrawIo)&&i.onBeginInitDrawIo(n,t);const{drawioIframe:l,exit:c}=await tR(n);if(J4(n,t),e.src){const m=await t3(n,n.doc.buildResourceUrl(e.src));m&&(e.xmlSvg=m)}nR(n,t,e,l,()=>{s=setInterval(()=>{!l||!l.contentWindow||l.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph",autoSave:!0}),"*")},YM)},()=>{c(),s&&clearInterval(s);const m=n.findBlockById(j(t));m&&K4(n,m)});const f=KM(n);l.setAttribute("src",f)}async function oR(n){var r,i;const t=hi(n),e=((r=t.cdn)==null?void 0:r.drawio)||GM,o=((i=t.cdn)==null?void 0:i.pako)||ZM;await qo(o,"editor-pako"),await qo(e,"editor-drawio"),await new Promise(s=>{setTimeout(s,100)})}function s3(n){H(n,o3)}function of(n){n.setAttribute("data-empty-drawio-content",x.t("drawio.empty")),M(n,o3)}function rf(n,t){if(u(Vt,t,"Required data is missing in setGraph"),"src"in t){n.setAttribute("data-src",t.src);return}if("xmlSvg"in t){n.setAttribute("data-xmlsvg",t.xmlSvg);return}if("graph"in t){const{xml:e,graph:o}=t;n.graph=o,n.setAttribute("data-mxfile",e)}}function rR(n,t,e){u(Vt,n,"params error: src"),u(Vt,e,"params error: editor");const o=t,r=e.doc.buildResourceUrl(n),i=document.createElement("img");o.innerHTML="",o.appendChild(i),i.src=r,i.draggable=!1,rf(o,{src:n}),i.onload=()=>{UM(i)?of(t):s3(t)}}function iR(n,t,e){u(Vt,e,"parameter missing"),oR(e).then(()=>{const{mxUtils:o,mxGraph:r,mxCodec:i}=window;u(Vt,o,"External resource loading exception: mxUtils"),u(Vt,r,"External resource loading exception: MxGraph"),u(Vt,i,"External resource loading exception: MxCodec");const s=o.parseXml(n);t.innerHTML="";const l=s.documentElement;u(Vt,l,"Resource parsing exception"),u(Vt,l.nodeName==="mxfile","Resource parsing exception");const c=l.getElementsByTagName("diagram");u(Vt,c.length>0,"Resource parsing exception");let a;const d=c[0];if(d.text||d.textContent){const k=qM(d),v=atob(k),T=window.pako;u(Vt,T,"External resource loading exception: pako");const E=T.inflateRaw(Uint8Array.from(v,R=>R.charCodeAt(0)),{to:"string"}),L=decodeURIComponent(E);a=o.parseXml(L)}else{const k=new XMLSerializer().serializeToString(d.firstChild);a=o.parseXml(k)}const f=new r(t);f.resetViewOnRootChange=!1,f.foldingEnabled=!1,f.setTooltips(!1),f.setEnabled(!1),f.setHtmlLabels(!0);const m=o.parseXml(QM);new i(m).decode(m.documentElement,f.getStylesheet());const A=new i(a);A.decode(A.document.documentElement,f.getModel()),f.maxFitScale=1,f.fit(),f.center(!0,!1),rf(t,{graph:f,xml:n})})}function sR(n,t){t.innerHTML=n,rf(t,{xmlSvg:n});const e=t.querySelectorAll("svg");for(let o=0;o<e.length;o++){const r=e[o];if(!VM(r))return}of(t)}function lR(n,t){return P1(n,t,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){const s=o.getBlockData(r).embedData;return i3(o,r,s,!1),!0}return!1}})}const rl=w("embed-block-drawio"),cR=!1;PM();function l3(n,t,e,o){u(rl,e,`parameter missing: ${e}`),u(rl,n,`parameter missing: ${n}`),i3(n,t,o,cR)}function aR(n,t,e){s3(t);const o=e;o.src?rR(o.src,t,n):o.xml?iR(o.xml,t,n):o.xmlSvg?sR(o.xmlSvg,t):of(t)}function uR(n,t,e,o={isInit:!1}){const{isInit:r}=o,s=b("div",["editor-drawio-content","editor-embed"],null),l=st(t);l.appendChild(s),aR(n,s,e),u(rl,t,"embedContainer parentElement node does not exist"),r&&!n.readonly&&n.domEvents.addEventListener(l,"dblclick",()=>{const c=n.getBlockData(t);l3(n,t,s,c.embedData)})}function dR(n,t,e,o,r,i){const s=e.embedData,l=n.addCustom(`drawio-${e.id}`,()=>new $M),c=l.isFirstInit();c?rl.log("create new embed block"):rl.log("update exists embed block"),l.stamp(),uR(n,i,s,{isInit:c})}function hR(){return{name:"UML",insertEmbedCommandItems:[{id:"insert-drawio",name:x.t("drawio.title"),icon:Qw,group:"common",order:600,subText:Ce("insert-drawio")}],handleInsertEmptyEmbed:async(n,t)=>{const e={src:"",xml:"",xmlSvg:""},o=n.insertEmbed(t.containerId,t.blockIndex,"drawio",e);return setTimeout(()=>{const i=st(o).querySelector(":scope > .editor-drawio-content"),s=n.getBlockData(o);l3(n,o,i,s.embedData)},100),o}}}function fR(n,t,e,o){const{embedData:r}=t,i=r;return o==="html"?i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.xmlSvg?i.xmlSvg:"<p>[drawio]</p>":o==="markdown"?i.src?`})`:i.xmlSvg?i.xmlSvg:"[drawio]":i.src?`[drawio](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:"[drawio]"}const va={embedType:"drawio",getOptions:hR,createEmbedContent:dR,getBlockProperties:lR,convertTo:fR},DV="",LV="",mR=500,gR=300,sf=w("code-editor");function pR(n){const t=n.closest(".embed-code-editor-container");return u(sf,t,"code-editor-container non-existent"),t}function CR(n,t,e){const o=n.target;u(sf,o,"Parameter error: textarea must be an element");const r=o.value;pR(o).remove(),H(t,"editing"),e(r),st(t).style.removeProperty("margin-top")}function AR(n,t){u(sf,n,"Parameter Error: handleCodeUpdate[event]");const e=n.target.value;t(e)}const bR=ee.default(AR,mR);function vR(n,t,e,o,r){n.domEvents.addEventListener(t,"blur",(i,s)=>{CR(s,e,r)}),n.domEvents.addEventListener(t,"keyup",(i,s)=>{const l=s.target;s.key==="Escape"&&l.blur()}),n.domEvents.addEventListener(t,"input",(i,s)=>{bR(s,o)})}function yR(n,t,e){const{height:o,codeValue:r,onChange:i,onEnd:s}=e,l=o||gR,c=st(t),a=Rt(t),d=b("div",["embed-code-editor-container"],a),f=b("textarea",["embed-code-editor-textarea"],d);f.value=r||"",f.setAttribute("spellcheck","false"),d.style.height=`${l}px`,vR(n,f,t,i,s),c.style.marginTop=`${l}px`,M(t,"editing"),window.requestAnimationFrame(()=>{f.setSelectionRange(0,0),f.focus(),f.scrollTop=0})}const kR={mermaid:"https://mermaid-js.github.io/mermaid/",flowchart:"https://flowchart.js.org/",plantuml:"https://plantuml.com/"};class wR extends N1{constructor(e,o,r,i){super(e,o,i);h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:xh},{id:"add-comment",name:"Add comment",icon:Ts},{id:"separator",type:"separator",name:""},{id:"help",name:"Help",icon:Fw}]);this.editor=e,this.block=o,this.graphType=r,this.properties=i}executeCommand(e,o,r){var i,s;(s=(i=this.properties)==null?void 0:i.handleExecuteCommand)!=null&&s.call(i,e,o,r)||r.id==="edit"||r.id==="help"&&window.open(kR[this.graphType])}}function BR(n,t,e,o){return{blockCommands:{"hovering-toolbar":new wR(n,t,e,o)}}}class lf{constructor(t,e,o){h(this,"editor");h(this,"logger");h(this,"editing",!1);this.graphType=e,this.codeEmbedDataKey=o,this.editor=t,this.logger=w(`embed-block-${this.graphType}`)}i18nt(t,e){return x.t(`graph.${t}`,e||{})}getContent(t){u(this.logger,t,"embed-element does not exist");const e=t.parentElement;return u(this.logger,e,"content-element does not exist"),e}getEmbed(t){const e=t.childNodes[0];return u(this.logger,e,"embed-element does not exist"),e}async uploadResource(t){const e=new Blob([t]),o=new File([e],`${this.graphType}.svg`,{type:"image/svg+xml"});try{const r=await this.editor.doc.uploadResource(o);u(this.logger,r,"uploadResource failed");const{resourceId:i}=r;return this.editor.doc.buildResourceUrl(i)}catch(r){return this.logger.error(r),null}}createEmbedContent(t,e){const o=b("div",["graph-embed"],t);this.editor.domEvents.addEventListener(o,"dblclick",(a,d)=>{this.editGraph(t),d.preventDefault(),d.stopPropagation()});const{embedData:r}=e,i=r[`${this.codeEmbedDataKey}`],s=r.src,l=b("div",["embed-graph-img-content"],o),c=b("img",["graph-embed-image"],l);c.draggable=!1,this.updateImage(o,i,s,null)}updateEmbedContent(t,e){const{embedData:o}=e,r=o[this.codeEmbedDataKey],i=o.src,s=t.querySelector(".graph-embed");this.updateImage(s,r,i,null)}async updateImage(t,e,o,r){const i=t.querySelector("img.graph-embed-image");let s=this.editor.doc.buildResourceUrl(o||"");if(!s&&!r&&e)try{s=await this.code2ObjectUrl(e)}catch(l){this.updateImage(t,e,o,l);return}this.updateClasses(t,e,r),s&&(i.src=s)}updateClasses(t,e,o){H(t,"empty-embed","invalid-code");const r=t.querySelector("img.graph-embed-image");if(o){r.src="",M(t,"invalid-code");const i=this.i18nt("invalid",{EmbedName:this.graphType,message:`${o.message}`||""});t.setAttribute("data-invalid-text",i);return}if(!e){r.src="";const i=this.i18nt("empty",{EmbedName:this.graphType});t.setAttribute("data-empty-tips",i),M(t,"empty-embed")}}editGraph(t){this.editing=!0;const e=U(t);u(this.logger,e,`${this.graphType} block does not exist`);const o=t.querySelector(".graph-embed"),r=l=>{this.updateImage(o,l,null,null)},i=async l=>{try{if(this.editing=!1,r(l),!this.hasChanged(e,l))return;const a={src:await this.code2ResourceId(l),[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,a)}catch(c){this.updateClasses(o,l,c);const a={src:"",[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,a)}},s=this.editor.getBlockData(e);yR(this.editor,e,{onChange:r,onEnd:i,codeValue:s.embedData[`${this.codeEmbedDataKey}`]})}getBlockProperties(t,e){return this.editing?{}:BR(this.editor,t,this.graphType,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){if(!o.isBlockWritable(r))return!0;const s=st(r);return this.editGraph(s),!0}return i.id==="add-comment"?(o.readonly||la(o,r),!0):!1}})}hasChanged(t,e){return this.editor.getBlockData(t).embedData[`${this.codeEmbedDataKey}`]!==e}}const ER="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js",IR=["//cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js","//cdnjs.cloudflare.com/ajax/libs/flowchart/1.15.0/flowchart.min.js"],xR="https://www.plantuml.com/plantuml/svg",TR=w("mermaid-helper"),SR="wiz-editor-mermaid";async function c3(n,t){var A;const o=((A=(n.getComponentOptions("mermaid")||{}).cdn)==null?void 0:A.mermaid)||ER;await qo(o,SR);const r=window.mermaid;u(TR,r,"Resource load failed: Mermaid javaScript resource injection failed");const i=P(),l=await new Promise((k,v)=>{try{r.mermaidAPI.render(i,t,T=>{setTimeout(()=>{k(T)})})}catch(T){T.message=T.str,v(T)}}),d=new DOMParser().parseFromString(l,"image/svg+xml").firstChild,f=d.style.maxWidth;return f&&d.setAttribute("width",f),new XMLSerializer().serializeToString(d)}async function DR(n,t){const e=await c3(n,t);return Eu(e,"image/svg+xml",`${P()}.svg`)}async function LR(n,t){const e=await c3(n,t),o=new Blob([e]),r=new File([o],`${P()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class fi extends lf{constructor(t){super(t,"mermaid","mermaidText")}static get(t,e){return t.addCustom(`mermaid-${e.id}`,()=>new fi(t))}code2ObjectUrl(t){return DR(this.editor,t)}code2ResourceId(t){return LR(this.editor,t)}destroy(){}}const MR={graph:{invalid:"\u65E0\u6548\u7684 {EmbedName} \u5185\u5BB9\uFF1A{message}",empty:"\u7A7A\u7684 {EmbedName}",flowchart:{},mermaid:{},plantuml:{}}},RR={invalid:"Invalid {EmbedName} content: {message}",empty:"Empty {EmbedName}",flowchart:{},mermaid:{},plantuml:{}};x.mergeLang({"zh-CN":MR,"en-US":RR});function OR(n,t,e){fi.get(n,e).createEmbedContent(t,e)}function NR(n,t,e){const o=fi.get(n,n.getBlockData(t)),r=st(t);return o.updateEmbedContent(r,e),!0}function PR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="mermaid"||r!=="```mermaid"||!_(n,t))return null;const i={src:"",mermaidText:""};return{blockData:{id:P(),type:"embed",embedType:"mermaid",embedData:i},onConverted:(c,a)=>{fi.get(c,c.getBlockData(a)).editGraph(st(a))}}}function $R(n,t){return fi.get(n,n.getBlockData(t)).getBlockProperties(t)}function _R(n,t,e,o){const{embedData:r}=t,i=r;if(o==="html")return i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.mermaidText?`<div class="mermaid">${i.mermaidText}</div>`:"<p>[mermaid]</p>";if(o==="markdown"){if(i.src)return`})`;if(i.mermaidText)return`\`\`\`mermaid\`\`\`
|
|
526
|
+
`,n3=0,YM=30*1e3,o3="editor-empty-drawio",r3="show-full-screen-iframe",Vt=w("embed-block-drawio");function hi(n){return n.options.componentsOptions.drawIO||{}}function JM(n){const e=hi(n).lang||"zh-CN";return e3[e]||e3["zh-CN"]}function KM(n){var r;const e=((r=(hi(n)||{}).cdn)==null?void 0:r.drawioIframe)||WM,o=JM(n);return ku(e,{spin:1,proto:"json",configure:1,lang:o})}function XM(n){const t=()=>{u(Vt,n,"el does not exist");const o=document.body.clientWidth||document.documentElement.clientWidth,r=document.body.clientHeight||document.documentElement.clientHeight;n.setAttribute("width",`${o-2*n3}`),n.setAttribute("height",`${r-2*n3}`)},e=()=>{window.removeEventListener("resize",t)};return t(),window.addEventListener("resize",t),{disconnect:e}}async function tR(n){const e=(hi(n)||{}).callbacks||{},{onCreateDrawIoFrame:o,onCloseDrawIoFrame:r}=e;let i=null,s;if(o)i=await o(n),u(Vt,i,"iframe create failed"),s=()=>{u(Vt,i,"iframe does not exist"),u(Vt,r,"missing parameters: onCloseDrawIoFrame"),r(n,i)};else{const l=b("div",["editor-drawio-iframe-container","loading"],document.body);l.setAttribute("data-placeholder",T.t("drawio.loading")),i=b("iframe",["drawio-iframe-element"],l),i.setAttribute("frameborder","0"),M(l,r3);const{disconnect:c}=XM(i);s=()=>{u(Vt,i,"iframe does not exist"),c(),document.body.removeChild(l),H(l,r3)}}return{drawioIframe:i,exit:s}}async function eR(n,t,e,o){var r,i;try{o&&Vt.debug("auto saving drawio data");const s=new Blob([e]),l=new File([s],"drawio.svg",{type:"image/svg+xml"});try{const c=n.findBlockById(j(t));if(c){const a=await n.doc.uploadResource(l),{resourceId:d}=a,m={...n.getBlockData(c),embedData:{src:d}};n.updateBlockData(c,m)}else Vt.error("block has been deleted")}catch(c){const a=`failed to upload drawio data: ${c.message}`;Vt.error(a)}}catch(s){const l=`failed to save drawio data: ${s.message}`,c=hi(n);if((r=c.callbacks)!=null&&r.onError){const a=new Error(l);a.code="SaveDrawIo",(i=c.callbacks)==null||i.onError(n,a)}}}function nR(n,t,e,o,r,i,s){const l=()=>{window.removeEventListener("message",c),i()},c=async a=>{var d,f;if(u(Vt,o.contentWindow,"iframe.contentWindow does not exist"),a.data.length>0){const m=JSON.parse(a.data),p=e.xmlSvg||e.xml,A=document.querySelectorAll(".editor-drawio-iframe-container");switch(m.event){case"configure":o.contentWindow.postMessage(JSON.stringify({action:"configure",config:{defaultFonts:["Humor Sans","Helvetica","Times New Roman"]}}),"*");break;case"init":p!=null&&o.contentWindow.postMessage(JSON.stringify({action:"load",saveAndExit:1,noSaveBtn:1,noExitBtn:0,xml:p}),"*"),r(),A.forEach(v=>{H(v,"loading")});break;case"export":const k=Ml(m.data.substring(m.data.indexOf(",")+1));eR(n,t,k,!!((d=m.message)!=null&&d.autoSave)),(f=m.message)!=null&&f.autoSave||l();break;case"save":o.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph"}),"*");break;case"exit":l();break}}};window.addEventListener("message",c)}async function i3(n,t,e,o){if(o)return;o=!0;const r=hi(n)||{},{callbacks:i}=r;let s;i&&(i==null?void 0:i.onBeginInitDrawIo)&&i.onBeginInitDrawIo(n,t);const{drawioIframe:l,exit:c}=await tR(n);if(J4(n,t),e.src){const m=await t3(n,n.doc.buildResourceUrl(e.src));m&&(e.xmlSvg=m)}nR(n,t,e,l,()=>{s=setInterval(()=>{!l||!l.contentWindow||l.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph",autoSave:!0}),"*")},YM)},()=>{c(),s&&clearInterval(s);const m=n.findBlockById(j(t));m&&K4(n,m)});const f=KM(n);l.setAttribute("src",f)}async function oR(n){var r,i;const t=hi(n),e=((r=t.cdn)==null?void 0:r.drawio)||GM,o=((i=t.cdn)==null?void 0:i.pako)||ZM;await qo(o,"editor-pako"),await qo(e,"editor-drawio"),await new Promise(s=>{setTimeout(s,100)})}function s3(n){H(n,o3)}function of(n){n.setAttribute("data-empty-drawio-content",T.t("drawio.empty")),M(n,o3)}function rf(n,t){if(u(Vt,t,"Required data is missing in setGraph"),"src"in t){n.setAttribute("data-src",t.src);return}if("xmlSvg"in t){n.setAttribute("data-xmlsvg",t.xmlSvg);return}if("graph"in t){const{xml:e,graph:o}=t;n.graph=o,n.setAttribute("data-mxfile",e)}}function rR(n,t,e){u(Vt,n,"params error: src"),u(Vt,e,"params error: editor");const o=t,r=e.doc.buildResourceUrl(n),i=document.createElement("img");o.innerHTML="",o.appendChild(i),i.src=r,i.draggable=!1,rf(o,{src:n}),i.onload=()=>{UM(i)?of(t):s3(t)}}function iR(n,t,e){u(Vt,e,"parameter missing"),oR(e).then(()=>{const{mxUtils:o,mxGraph:r,mxCodec:i}=window;u(Vt,o,"External resource loading exception: mxUtils"),u(Vt,r,"External resource loading exception: MxGraph"),u(Vt,i,"External resource loading exception: MxCodec");const s=o.parseXml(n);t.innerHTML="";const l=s.documentElement;u(Vt,l,"Resource parsing exception"),u(Vt,l.nodeName==="mxfile","Resource parsing exception");const c=l.getElementsByTagName("diagram");u(Vt,c.length>0,"Resource parsing exception");let a;const d=c[0];if(d.text||d.textContent){const k=qM(d),v=atob(k),x=window.pako;u(Vt,x,"External resource loading exception: pako");const E=x.inflateRaw(Uint8Array.from(v,R=>R.charCodeAt(0)),{to:"string"}),L=decodeURIComponent(E);a=o.parseXml(L)}else{const k=new XMLSerializer().serializeToString(d.firstChild);a=o.parseXml(k)}const f=new r(t);f.resetViewOnRootChange=!1,f.foldingEnabled=!1,f.setTooltips(!1),f.setEnabled(!1),f.setHtmlLabels(!0);const m=o.parseXml(QM);new i(m).decode(m.documentElement,f.getStylesheet());const A=new i(a);A.decode(A.document.documentElement,f.getModel()),f.maxFitScale=1,f.fit(),f.center(!0,!1),rf(t,{graph:f,xml:n})})}function sR(n,t){t.innerHTML=n,rf(t,{xmlSvg:n});const e=t.querySelectorAll("svg");for(let o=0;o<e.length;o++){const r=e[o];if(!VM(r))return}of(t)}function lR(n,t){return P1(n,t,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){const s=o.getBlockData(r).embedData;return i3(o,r,s,!1),!0}return!1}})}const rl=w("embed-block-drawio"),cR=!1;PM();function l3(n,t,e,o){u(rl,e,`parameter missing: ${e}`),u(rl,n,`parameter missing: ${n}`),i3(n,t,o,cR)}function aR(n,t,e){s3(t);const o=e;o.src?rR(o.src,t,n):o.xml?iR(o.xml,t,n):o.xmlSvg?sR(o.xmlSvg,t):of(t)}function uR(n,t,e,o={isInit:!1}){const{isInit:r}=o,s=b("div",["editor-drawio-content","editor-embed"],null),l=st(t);l.appendChild(s),aR(n,s,e),u(rl,t,"embedContainer parentElement node does not exist"),r&&!n.readonly&&n.domEvents.addEventListener(l,"dblclick",()=>{const c=n.getBlockData(t);l3(n,t,s,c.embedData)})}function dR(n,t,e,o,r,i){const s=e.embedData,l=n.addCustom(`drawio-${e.id}`,()=>new $M),c=l.isFirstInit();c?rl.log("create new embed block"):rl.log("update exists embed block"),l.stamp(),uR(n,i,s,{isInit:c})}function hR(){return{name:"UML",insertEmbedCommandItems:[{id:"insert-drawio",name:T.t("drawio.title"),icon:Qw,group:"common",order:600,subText:Ce("insert-drawio")}],handleInsertEmptyEmbed:async(n,t)=>{const e={src:"",xml:"",xmlSvg:""},o=n.insertEmbed(t.containerId,t.blockIndex,"drawio",e);return setTimeout(()=>{const i=st(o).querySelector(":scope > .editor-drawio-content"),s=n.getBlockData(o);l3(n,o,i,s.embedData)},100),o}}}function fR(n,t,e,o){const{embedData:r}=t,i=r;return o==="html"?i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.xmlSvg?i.xmlSvg:"<p>[drawio]</p>":o==="markdown"?i.src?`})`:i.xmlSvg?i.xmlSvg:"[drawio]":i.src?`[drawio](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:"[drawio]"}const va={embedType:"drawio",getOptions:hR,createEmbedContent:dR,getBlockProperties:lR,convertTo:fR},DV="",LV="",mR=500,gR=300,sf=w("code-editor");function pR(n){const t=n.closest(".embed-code-editor-container");return u(sf,t,"code-editor-container non-existent"),t}function CR(n,t,e){const o=n.target;u(sf,o,"Parameter error: textarea must be an element");const r=o.value;pR(o).remove(),H(t,"editing"),e(r),st(t).style.removeProperty("margin-top")}function AR(n,t){u(sf,n,"Parameter Error: handleCodeUpdate[event]");const e=n.target.value;t(e)}const bR=ee.default(AR,mR);function vR(n,t,e,o,r){n.domEvents.addEventListener(t,"blur",(i,s)=>{CR(s,e,r)}),n.domEvents.addEventListener(t,"keyup",(i,s)=>{const l=s.target;s.key==="Escape"&&l.blur()}),n.domEvents.addEventListener(t,"input",(i,s)=>{bR(s,o)})}function yR(n,t,e){const{height:o,codeValue:r,onChange:i,onEnd:s}=e,l=o||gR,c=st(t),a=Rt(t),d=b("div",["embed-code-editor-container"],a),f=b("textarea",["embed-code-editor-textarea"],d);f.value=r||"",f.setAttribute("spellcheck","false"),d.style.height=`${l}px`,vR(n,f,t,i,s),c.style.marginTop=`${l}px`,M(t,"editing"),window.requestAnimationFrame(()=>{f.setSelectionRange(0,0),f.focus(),f.scrollTop=0})}const kR={mermaid:"https://mermaid-js.github.io/mermaid/",flowchart:"https://flowchart.js.org/",plantuml:"https://plantuml.com/"};class wR extends N1{constructor(e,o,r,i){super(e,o,i);h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:xh},{id:"add-comment",name:"Add comment",icon:Ts},{id:"separator",type:"separator",name:""},{id:"help",name:"Help",icon:Fw}]);this.editor=e,this.block=o,this.graphType=r,this.properties=i}executeCommand(e,o,r){var i,s;(s=(i=this.properties)==null?void 0:i.handleExecuteCommand)!=null&&s.call(i,e,o,r)||r.id==="edit"||r.id==="help"&&window.open(kR[this.graphType])}}function BR(n,t,e,o){return{blockCommands:{"hovering-toolbar":new wR(n,t,e,o)}}}class lf{constructor(t,e,o){h(this,"editor");h(this,"logger");h(this,"editing",!1);this.graphType=e,this.codeEmbedDataKey=o,this.editor=t,this.logger=w(`embed-block-${this.graphType}`)}i18nt(t,e){return T.t(`graph.${t}`,e||{})}getContent(t){u(this.logger,t,"embed-element does not exist");const e=t.parentElement;return u(this.logger,e,"content-element does not exist"),e}getEmbed(t){const e=t.childNodes[0];return u(this.logger,e,"embed-element does not exist"),e}async uploadResource(t){const e=new Blob([t]),o=new File([e],`${this.graphType}.svg`,{type:"image/svg+xml"});try{const r=await this.editor.doc.uploadResource(o);u(this.logger,r,"uploadResource failed");const{resourceId:i}=r;return this.editor.doc.buildResourceUrl(i)}catch(r){return this.logger.error(r),null}}createEmbedContent(t,e){const o=b("div",["graph-embed"],t);this.editor.domEvents.addEventListener(o,"dblclick",(a,d)=>{this.editGraph(t),d.preventDefault(),d.stopPropagation()});const{embedData:r}=e,i=r[`${this.codeEmbedDataKey}`],s=r.src,l=b("div",["embed-graph-img-content"],o),c=b("img",["graph-embed-image"],l);c.draggable=!1,this.updateImage(o,i,s,null)}updateEmbedContent(t,e){const{embedData:o}=e,r=o[this.codeEmbedDataKey],i=o.src,s=t.querySelector(".graph-embed");this.updateImage(s,r,i,null)}async updateImage(t,e,o,r){const i=t.querySelector("img.graph-embed-image");let s=this.editor.doc.buildResourceUrl(o||"");if(!s&&!r&&e)try{s=await this.code2ObjectUrl(e)}catch(l){this.updateImage(t,e,o,l);return}this.updateClasses(t,e,r),s&&(i.src=s)}updateClasses(t,e,o){H(t,"empty-embed","invalid-code");const r=t.querySelector("img.graph-embed-image");if(o){r.src="",M(t,"invalid-code");const i=this.i18nt("invalid",{EmbedName:this.graphType,message:`${o.message}`||""});t.setAttribute("data-invalid-text",i);return}if(!e){r.src="";const i=this.i18nt("empty",{EmbedName:this.graphType});t.setAttribute("data-empty-tips",i),M(t,"empty-embed")}}editGraph(t){this.editing=!0;const e=U(t);u(this.logger,e,`${this.graphType} block does not exist`);const o=t.querySelector(".graph-embed"),r=l=>{this.updateImage(o,l,null,null)},i=async l=>{try{if(this.editing=!1,r(l),!this.hasChanged(e,l))return;const a={src:await this.code2ResourceId(l),[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,a)}catch(c){this.updateClasses(o,l,c);const a={src:"",[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,a)}},s=this.editor.getBlockData(e);yR(this.editor,e,{onChange:r,onEnd:i,codeValue:s.embedData[`${this.codeEmbedDataKey}`]})}getBlockProperties(t,e){return this.editing?{}:BR(this.editor,t,this.graphType,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){if(!o.isBlockWritable(r))return!0;const s=st(r);return this.editGraph(s),!0}return i.id==="add-comment"?(o.readonly||la(o,r),!0):!1}})}hasChanged(t,e){return this.editor.getBlockData(t).embedData[`${this.codeEmbedDataKey}`]!==e}}const ER="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js",IR=["//cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js","//cdnjs.cloudflare.com/ajax/libs/flowchart/1.15.0/flowchart.min.js"],xR="https://www.plantuml.com/plantuml/svg",TR=w("mermaid-helper"),SR="wiz-editor-mermaid";async function c3(n,t){var A;const o=((A=(n.getComponentOptions("mermaid")||{}).cdn)==null?void 0:A.mermaid)||ER;await qo(o,SR);const r=window.mermaid;u(TR,r,"Resource load failed: Mermaid javaScript resource injection failed");const i=P(),l=await new Promise((k,v)=>{try{r.mermaidAPI.render(i,t,x=>{setTimeout(()=>{k(x)})})}catch(x){x.message=x.str,v(x)}}),d=new DOMParser().parseFromString(l,"image/svg+xml").firstChild,f=d.style.maxWidth;return f&&d.setAttribute("width",f),new XMLSerializer().serializeToString(d)}async function DR(n,t){const e=await c3(n,t);return Eu(e,"image/svg+xml",`${P()}.svg`)}async function LR(n,t){const e=await c3(n,t),o=new Blob([e]),r=new File([o],`${P()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class fi extends lf{constructor(t){super(t,"mermaid","mermaidText")}static get(t,e){return t.addCustom(`mermaid-${e.id}`,()=>new fi(t))}code2ObjectUrl(t){return DR(this.editor,t)}code2ResourceId(t){return LR(this.editor,t)}destroy(){}}const MR={graph:{invalid:"\u65E0\u6548\u7684 {EmbedName} \u5185\u5BB9\uFF1A{message}",empty:"\u7A7A\u7684 {EmbedName}",flowchart:{},mermaid:{},plantuml:{}}},RR={invalid:"Invalid {EmbedName} content: {message}",empty:"Empty {EmbedName}",flowchart:{},mermaid:{},plantuml:{}};T.mergeLang({"zh-CN":MR,"en-US":RR});function OR(n,t,e){fi.get(n,e).createEmbedContent(t,e)}function NR(n,t,e){const o=fi.get(n,n.getBlockData(t)),r=st(t);return o.updateEmbedContent(r,e),!0}function PR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="mermaid"||r!=="```mermaid"||!_(n,t))return null;const i={src:"",mermaidText:""};return{blockData:{id:P(),type:"embed",embedType:"mermaid",embedData:i},onConverted:(c,a)=>{fi.get(c,c.getBlockData(a)).editGraph(st(a))}}}function $R(n,t){return fi.get(n,n.getBlockData(t)).getBlockProperties(t)}function _R(n,t,e,o){const{embedData:r}=t,i=r;if(o==="html")return i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.mermaidText?`<div class="mermaid">${i.mermaidText}</div>`:"<p>[mermaid]</p>";if(o==="markdown"){if(i.src)return`})`;if(i.mermaidText)return`\`\`\`mermaid\`\`\`
|
|
527
527
|
${i.mermaidText}
|
|
528
528
|
\`\`\`\`\`\``}return"[mermaid]"}const cf={embedType:"mermaid",convertFrom:PR,handleUpdateBlock:NR,createEmbedContent:OR,getBlockProperties:$R,convertTo:_R},a3=w("flowchart-helper");async function FR(n){var o;const t=n.getComponentOptions("flowchart")||{},e=((o=t==null?void 0:t.cdn)==null?void 0:o.flowchart)||IR;for(let r=0;r<e.length;r+=1){const i=e[r];await qo(i,`flowchart-scripts-${r}`)}}async function u3(n,t){const e=b("div",["flowchart-chart-container"],document.body);e.id=`flowchart-${P()}`,await FR(n);const o=window.flowchart;u(a3,o,"flowchart resource does not exist"),o.parse(t).drawSVG(e.id);const i=e.firstElementChild;u(a3,i,"svg element non-existent");const l=new XMLSerializer().serializeToString(i);return e.remove(),l}async function HR(n,t){const e=await u3(n,t);return Eu(e,"image/svg+xml",`${Date.now()}.svg`)}async function jR(n,t){const e=await u3(n,t),o=new Blob([e]),r=new File([o],`${P()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class mi extends lf{constructor(t){super(t,"flowchart","flowchartText")}static get(t,e){return t.addCustom(`flowchart-${e.id}`,()=>new mi(t))}code2ObjectUrl(t){return HR(this.editor,t)}code2ResourceId(t){return jR(this.editor,t)}destroy(){}}function zR(n,t,e){mi.get(n,e).createEmbedContent(t,e)}function UR(n,t,e){const o=mi.get(n,e),r=st(t);return o.updateEmbedContent(r,e),!0}function VR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="flowchart"||r!=="```flowchart"||!_(n,t))return null;const i={src:"",flowchartText:""};return{blockData:{id:P(),type:"embed",embedType:"flowchart",embedData:i},onConverted:(c,a)=>{mi.get(c,c.getBlockData(a)).editGraph(st(a))}}}function qR(n,t){return mi.get(n,n.getBlockData(t)).getBlockProperties(t)}function WR(n,t,e,o){const{embedData:r}=t,i=r;if(o==="html")return i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.flowchartText?`<div>${i.flowchartText}</div>`:"<p>[flowchart]</p>";if(o==="markdown"){if(i.src)return`})`;if(i.flowchartText)return`\`\`\`flowchart\`\`\`
|
|
529
529
|
${i.flowchartText}
|
|
530
530
|
\`\`\`\`\`\``}return"[flowchart]"}const af={embedType:"flowchart",convertFrom:VR,handleUpdateBlock:UR,createEmbedContent:zR,getBlockProperties:qR,convertTo:WR},GR=w("plantuml-helper");function d3(n,t){var l;let o=((l=(n.getComponentOptions("plantuml")||{}).cdn)==null?void 0:l.plantuml)||xR;o.endsWith("/")||(o+="/");const r=c8.default.encode(t);u(GR,r,r),o+=r;const s=new URLSearchParams(document.location.search).get("doc");return ku(o,{id:`${s}-${P()}`})}async function ZR(n,t){const e=await nf(n,t);return(await n.doc.uploadResource(e)).resourceId}class gi extends lf{constructor(t){super(t,"plantuml","plantumlText")}static get(t,e){return t.addCustom(`plantuml-${e.id}`,()=>new gi(t))}code2ObjectUrl(t){return Promise.resolve(d3(this.editor,t))}code2ResourceId(t){const e=d3(this.editor,t);return ZR(this.editor,e)}destroy(){}}function QR(n,t,e){gi.get(n,e).createEmbedContent(t,e)}function YR(n,t,e){const o=gi.get(n,e),r=st(t);return o.updateEmbedContent(r,e),!0}function JR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="plantuml"||r!=="```plantuml"||!_(n,t))return null;const i={src:"",plantumlText:""};return{blockData:{id:P(),type:"embed",embedType:"plantuml",embedData:i},onConverted:(c,a)=>{gi.get(c,c.getBlockData(a)).editGraph(st(a))}}}function KR(n,t){return gi.get(n,n.getBlockData(t)).getBlockProperties(t)}function XR(n,t,e,o){const{embedData:r}=t,i=r;if(o==="html")return i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.flowchartText?`<div>${i.flowchartText}</div>`:"<p>[plantuml]</p>";if(o==="markdown"){if(i.src)return`})`;if(i.flowchartText)return`\`\`\`plantuml\`\`\`
|
|
531
531
|
${i.flowchartText}
|
|
532
|
-
\`\`\`\`\`\``}return"[plantuml]"}const uf={embedType:"plantuml",convertFrom:JR,handleUpdateBlock:YR,createEmbedContent:QR,getBlockProperties:KR,convertTo:XR},MV="",tO="hr",eO={dividingLine:{type:"\u5206\u5272\u7EBF"}},nO={dividingLine:{type:"dividing-line"}};
|
|
532
|
+
\`\`\`\`\`\``}return"[plantuml]"}const uf={embedType:"plantuml",convertFrom:JR,handleUpdateBlock:YR,createEmbedContent:QR,getBlockProperties:KR,convertTo:XR},MV="",tO="hr",eO={dividingLine:{type:"\u5206\u5272\u7EBF"}},nO={dividingLine:{type:"dividing-line"}};T.mergeLang({"zh-CN":eO,"en-US":nO});function oO(n,t){const e=b("div",["editor-embed-container"],t);b("hr",["editor-embed-hr"],e)}function rO(n,t,e,o){return o==="html"?"<hr />":o==="markdown"?"---":"------------"}function iO(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:T.t("dividingLine.type"),icon:Yw,order:500,group:"common",subText:Ce("insert-hr")}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:o}=t;return n.insertEmbed(e,o,tO,{})}}}function sO(n,t,e){const{data:o}=e;if(!o||o.embedType!=="dividing-line"||!_(n,t))return null;const r={};return{blockData:{id:P(),type:"embed",embedType:"hr",embedData:r}}}const df={embedType:"hr",createEmbedContent:oO,convertTo:rO,getOptions:iO,convertFrom:sO},RV="";class lO{constructor(t,e){h(this,"toolbar");h(this,"anchor",null);h(this,"item");h(this,"docs",null);h(this,"checkedId");h(this,"handlePasteSpecial",(t,e)=>{!e.data||(this.checkedId===e.id?this.checkedId=void 0:this.checkedId=e.id,this.onPasteSpecial(e.data),setTimeout(()=>{this.docs&&this.show(this.docs),this.editor.focus()}))});h(this,"handleClose",()=>{this.editor.focus()});h(this,"handleSelectionChange",()=>{this.hide()});this.editor=t,this.onPasteSpecial=e,this.item={id:"paste-special",name:"Paste special",icon:Rw,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",childrenOffset:[-4,4],children:[]},this.toolbar=new Ss([this.item],void 0,{id:"paste-special-button",tooltipId:this.editor.clientId,refuseOverflow:!0}),this.toolbar.addListener("click",this.handlePasteSpecial),this.toolbar.addListener("close",this.handleClose),this.editor.addListener("selectionChanged",this.handleSelectionChange)}show(t){this.docs=t;const e=this.editor,o=e.selection.range;if(!o.isCollapsed())return;const r=e.getBlockById(o.start.blockId);if(!_(e,r))return;const i=co(e,r,o)[0];if(!i)return;this.anchor&&this.anchor.remove(),this.anchor=fo(e,r,"paste-special-button-anchor",i);const s=this.getCommandItems(t);this.item.children=s,this.toolbar.manualShow(this.anchor)}hide(){this.toolbar.close()}clearCheckedState(){this.checkedId=void 0}destroy(){this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange)}getCommandItems(t){const e=i=>({id:i,states:this.checkedId===i?["checked"]:void 0,name:"Keep origin formats",data:t[i]}),o=[];let r=!0;return t["text/x-ones-editor-doc"]?o.push(e("text/x-ones-editor-doc")):t["text/office-html"]?o.push(e("text/office-html")):t["text/html"]?o.push(e("text/html")):t["text/plain"]&&(o.push(e("text/plain")),r=!1),t["text/plain"]&&(r&&o.push({id:"text/plain",states:this.checkedId==="text/plain"?["checked"]:void 0,name:"Paste as plain text",data:t["text/plain"]}),o.push({id:"text/markdown",states:this.checkedId==="text/markdown"?["checked"]:void 0,name:"Paste as markdown",data:t["text/markdown"]})),o}}const cO=w("paste-special");class hf{constructor(t){h(this,"button");h(this,"lastUndoAction",null);h(this,"event",null);h(this,"handlePasteSpecial",t=>{this.editor.undoManager.runInGroup(()=>{this.editor.undoManager.undoTo(this.lastUndoAction),this.editor.pasteDoc(t)})});this.editor=t,this.button=new lO(t,this.handlePasteSpecial)}destroy(){this.event=null,this.button.destroy()}handleChanged(t,e){this.event=null,this.button.hide()}async handleBeforePaste(t,e){return cO.debug("before paste"),this.lastUndoAction=t.undoManager.lastAction(),!1}async handleAfterPaste(t,e,o){if(Object.keys(o).length<=1)return!1;const r=t.selection.range;if(r.isCollapsed()){const i=t.getBlockById(r.start.blockId);if(!_(t,i))return!1;this.button.clearCheckedState(),this.button.show(o),this.event=e}return!1}}const OV="",aO=w("html-to-doc");function uO(n){const t="ones-editor-doc::",e="::ones-editor-doc";let o=n.indexOf(t);if(o!==-1){o+=t.length;const r=n.indexOf(e,o);if(r!==-1){const i=n.substr(o,r-o);try{const s=Ml(i);return JSON.parse(s)}catch(s){aO.error(`invalid doc data: ${s}, ${i}`)}}}return null}const h3="latex-b172fea480b",dO=n=>({name:"latex-block",level:"block",start(t){var e,o;return(o=(e=t.match(/\$\$[^\$]/))==null?void 0:e.index)!=null?o:-1},tokenizer(t,e){const o=/^\$\$([^\$]+)\$\$/.exec(t);return o?{type:"latex-block",raw:o[0],formula:o[1]}:void 0},renderer(t){return n.lazy?`<span class="${h3}" block>${t.formula}</span>`:n.render(t.formula,!0)}}),hO=n=>({name:"latex",level:"inline",start(t){var e,o;return(o=(e=t.match(/\$[^\$]/))==null?void 0:e.index)!=null?o:-1},tokenizer(t,e){const o=/^\$([^\$]+)\$/.exec(t);return o?{type:"latex",raw:o[0],formula:o[1]}:void 0},renderer(t){return n.lazy?`<span class="${h3}">${t.formula}</span>`:n.render(t.formula,!1)}});var fO=(n={})=>(n.lazy&&n.env!=="test"&&new IntersectionObserver((t,e)=>{for(const o of t){if(!o.isIntersecting)continue;const r=o.target;e.unobserve(r),Promise.resolve(n.render(r.innerText,r.hasAttribute("block"))).then(i=>{r.innerHTML=i}),r.classList.add("latex-rendered")}},{threshold:1}),{extensions:[dO(n),hO(n)]});function pi(n){const t=n.type;if(t==="link")return!!n.tokens.some(pi);switch(t){case"code":case"table":case"hr":case"blockquote":case"list":case"list_item":case"image":case"paragraph":return!0;default:return!1}}function mO(n){return!pi(n)}function gO(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],o=pi(n[0]);for(let r=1;r<n.length;r++){const i=n[r];o===pi(i)?e.push(i):(t.push(e),e=[i],o=pi(i))}return t.push(e),t}function pO(n,t,e){const o=n.href;let r=e.tokensToText(n.tokens,t,e);return r.length===0&&(r=Co(o,t)),r=Jl(r,"link",o),r}let il;function ff(n){il||(il=document.createElement("textarea")),il.innerHTML=n;const t=il.childNodes.length===0?"":il.childNodes[0].nodeValue;return t!=null?t:""}function CO(n,t){const e=ff(n.text);return[_e(e,{...t,"style-code":!0})]}function AO(n,t,e){const r=n.tokens;return r?e.tokensToText(r,t,e):Xu(ff(n.text),t)}const bO=w("token-to-text");function mf(n,t,e){return n.map(r=>r.type==="text"?AO(r,t,e):r.type==="strong"?e.tokensToText(r.tokens,{...t,"style-bold":!0},e):r.type==="em"?e.tokensToText(r.tokens,{...t,"style-italic":!0},e):r.type==="link"?pO(r,t,e):r.type==="codespan"?CO(r,t):r.type==="br"?[{insert:" ",attributes:{id:P(),created:Date.now(),box:!0,type:"br"}}]:r.type==="escape"?Xu(ff(r.text),t):r.type==="latex"?[{insert:" ",attributes:{id:P(),created:Date.now(),box:!0,type:"math",tex:r.formula}}]:(bO.warn(`unknown token in text: ${JSON.stringify(r)}`),[])).flat()}function vO(n,t){const e=mf(n.tokens,{},t);return[{id:P(),type:"text",text:e,heading:n.depth}]}function yO(n,t){const{text:e,children:o}=t.tokensToTextWithChildren(n.tokens,t),r=[];return e.length>0&&r.push({id:P(),type:"text",text:e}),r.push(...o),r}function kO(n,t){const{text:e,children:o}=t.tokensToTextWithChildren([n],t),r=[];return e.length>0&&r.push({id:P(),type:"text",text:e}),r.push(...o),r}function wO(n,t){const e=typeof n.start=="number"?n.start:1,o=n.ordered,r=P(),i=[];return n.items.forEach((l,c)=>{const a={...t,listLevel:t.listLevel+1},{text:d,children:f}=t.tokensToTextWithChildren(l.tokens,a);let m;typeof l.checked=="boolean"&&(m=l.checked?"checked":"unchecked");const p={id:P(),type:"list",groupId:r,ordered:o,checkbox:m,start:e+c,text:d,level:t.listLevel};i.push(p),i.push(...f)}),i}function BO(n,t){const e=t.tokensToBlocks(n.tokens,t);return e.forEach(o=>{o.quoted=!0}),e}const f3=100,EO=20,IO=600;function xO(n,t){const e=t.text;if(e){const o=vt(e);return Math.min(Ol(o,n)+EO,IO)}return f3}function m3(n,t){let e=f3;return t.forEach(o=>{e=Math.max(e,xO(n,o))}),e}function TO(n,t){var l,c;const e=n.header.length,o=n.rows.length+1,r=[],i=Array(e).fill(100);for(let a=0;a<o;a++){let d;a===0?d=n.header:d=n.rows[a-1];for(let f=0;f<e;f++){const m=d[f],p=(l=m==null?void 0:m.tokens)!=null?l:[],A=P();r.push(A);let k;if(p.length===0)k=[Xl()];else if(pi(p[0]))k=t.tokensToBlocks(m.tokens,t),k.length===0&&k.push(Xl());else{const{text:v,children:x}=t.tokensToTextWithChildren(m.tokens,t);k=[{id:P(),type:"text",text:v},...x]}t.doc.blocks[A]=k,i[f]=Math.max(i[f],m3((c=t.font)!=null?c:"",k))}}return[{id:P(),type:"table",cols:e,rows:o,colsWidth:i,children:r}]}function SO(n){return[{id:P(),type:"embed",embedType:"hr",embedData:{}}]}function DO(n,t){var c;const e=n.text;if(!e)return[];try{const a=n.text,d=Ml(a),f=JSON.parse(d);if(f){const{root:m,...p}=f.blocks;return t.doc.blocks={...t.doc.blocks,...p},m}}catch{}const o=(c=n.lang)!=null?c:"Plain Text";if(o==="mermaid")return[{id:P(),type:"embed",embedType:"mermaid",embedData:{mermaidText:e}}];if(o==="plantuml")return[{id:P(),type:"embed",embedType:"plantuml",embedData:{plantumlText:e}}];if(o==="flow"||o==="flowchart")return[{id:P(),type:"embed",embedType:"flowchart",embedData:{flowchartText:e}}];const i=e.split(`
|
|
533
533
|
`).map(a=>({id:P(),type:"text",text:Co(a)})),s=t.doc,l=P();return s.blocks[l]=i,[{id:P(),type:"code",language:o,children:[l]}]}function LO(n){return[{id:P(),type:"embed",embedType:"image",embedData:{src:n.href,title:n.title}}]}function MO(n,t){const{text:e,children:o}=t.tokensToTextWithChildren(n.tokens,t),r=[];return e.length>0&&r.push({id:P(),type:"text",text:e}),r.push(...o),r}function RO(n){const t=n.formula;return t?[{id:P(),type:"embed",embedType:"math",embedData:{mathjaxText:t}}]:[]}const g3=w("markdown-to-doc");function OO(n,t){var e;if(n.type==="heading")return vO(n,t);if(n.type==="paragraph")return yO(n,t);if(n.type==="list")return wO(n,t);if(n.type==="blockquote")return BO(n,t);if(n.type==="table")return TO(n,t);if(n.type==="hr")return SO();if(n.type==="code")return DO(n,t);if(n.type==="image")return LO(n);if(n.type==="link")return MO(n,t);if(n.type==="latex-block")return RO(n);if(n.type==="text")return kO(n,t);if(n.type==="space"){const o=n.raw.replaceAll(" ",""),r=Math.floor(o.split(`
|
|
534
534
|
`).length/2)-1;return r>0?new Array(r).fill("").map(()=>({type:"text",id:P(),text:[]})):[]}if(n.type==="html"){const o=(e=t.htmlToDoc)==null?void 0:e.call(t,n.text);if(!o)return g3.warn(`failed to convert html to doc: ${JSON.stringify(n)}`),[];const{root:r,...i}=o.blocks;return t.doc.blocks={...t.doc.blocks,...i},r}return g3.warn(`unknown block token: ${JSON.stringify(n)}`),[]}function gf(n,t){const e=[];return n.forEach(o=>{const r=OO(o,t);e.push(...r)}),e}w("markdown-to-doc");function NO(n,t){const e={text:[],children:[]};return gO(n).forEach((r,i)=>{const s=r[0];if(i===0&&mO(s)){e.text=mf(r,{},t);return}e.children.push(...gf(r,t))}),e}const PO={render:(n,t)=>""};fm.marked.use(fO(PO));function p3(n,t){const o=new fm.marked.Lexer().lex(n),r={blocks:{root:[]},meta:{},comments:{}},i={font:t==null?void 0:t.font,doc:r,tokensToText:mf,tokensToBlocks:gf,tokensToTextWithChildren:NO,htmlToDoc:t==null?void 0:t.htmlToDoc,listLevel:1},s=gf(o,i);return s.length===0?null:(r.blocks.root.push(...s),r)}function $O(n){if(n.nodeName!=="DIV")return!1;const t=n;return Array.from(t.childNodes).every(e=>e.nodeName==="SPAN"||e instanceof Text)?!!t.querySelector(":scope > .hljs-function, :scope > .hljs-params, :scope > .hljs-string, :scope > .hljs-keyword, :scope > .hljs-attr"):!1}function C3(n){if($O(n)){const t=n,e=t.parentNode,o=document.createElement("pre");Array.from(t.childNodes).forEach(r=>o.appendChild(r)),e==null||e.insertBefore(o,t);return}n.childNodes.forEach(t=>C3(t))}function ya(n){var t;if(n instanceof HTMLBRElement){const e=document.createTextNode(`
|
|
535
535
|
`);(t=n.parentNode)==null||t.insertBefore(e,n),n.remove();return}n.childNodes.forEach(ya)}function _O(n){n.addRule("preOnlyBlockToCode",{filter:t=>t.nodeName!=="PRE"?!1:Array.from(t.childNodes).every(e=>e.nodeName==="SPAN"||e instanceof Text||e.nodeName==="BR"),replacement:(t,e,o)=>{var r;return ya(e),`
|
|
@@ -578,17 +578,17 @@ ${i.flowchartText}
|
|
|
578
578
|
`}})}class qO{constructor(t){h(this,"_grid",[]);h(this,"_needFixSpanData",!1);Array.from(t.rows).forEach((e,o)=>{Array.from(e.cells).forEach(r=>{this._addCell(o,r)})})}_addCell(t,e){const o=this._getNextColIndex(t),r=e.colSpan,i=e.rowSpan;for(let s=0;s<i;s++)for(let l=0;l<r;l++){const c=t+s,a=o+l;if(this._getCell({row:c,col:a})){this._needFixSpanData=!0,console.warn(`invalid table data, cell data already exists, ${c}, ${a}`);continue}this._setCell({row:c,col:a},{cell:e,virtual:!(l===0&&s===0)})}}_getNextColIndex(t){const e=this._grid[t];if(!e)return 0;let o=0;for(let r=0;r<e.length;r++)if(e[r])o+=1;else return o;return o}_setCell(t,e){if(!(e.cell.colSpan===0||e.cell.rowSpan===0)){for(;this._grid.length<=t.row;)this._grid.push([]);for(let o=0;o<this._grid.length;o++){const r=this._grid[o];for(;r.length<=t.col;)r.push(null)}this._grid[t.row][t.col]=e}}_getCell(t){var o;const e=this._grid[t.row];return e&&(o=e[t.col])!=null?o:null}get rowCount(){return this._grid.length}get colCount(){return this._grid[0].length}getCellData(t){const e=this._getCell(t);return e||null}getCellSpan(t){const e=this._getCell(t);if(!e)return{colSpan:1,rowSpan:1};if(e.virtual)return{colSpan:1,rowSpan:1};const o=()=>{let l=t.col+1;for(;;){const c=this._getCell({row:t.row,col:l});if(!c||c.cell!==e.cell)return l-t.col;l+=1}},r=()=>{let l=t.row+1;for(;;){const c=this._getCell({row:l,col:t.col});if(!c||c.cell!==e.cell)return l-t.row;l+=1}},i=o(),s=r();return i!==e.cell.colSpan&&console.warn(`invalid colSpan: ${i} -> ${e.cell.colSpan}`),s!==e.cell.rowSpan&&console.warn(`invalid rowSpan: ${s} -> ${e.cell.rowSpan}`),{colSpan:i,rowSpan:s}}getColumnWidth(t){const r=Array(this.rowCount).fill(0).map((s,l)=>{const c=this.getCellData({row:l,col:t});if(c&&!c.virtual){const a=c.cell.getAttribute("width")||c.cell.style.width;if(a){if(a.endsWith("%")){const f=a.substr(0,a.length-1),m=Number.parseInt(f,10);if(m>0&&m<=100)return Math.floor(720*m/100)}const d=Number.parseInt(a,10);if(d)return d}return c.cell.getBoundingClientRect().width}return 1e9}),i=Math.min(...r);return i===1e9||Number.isNaN(i)||i<30?0:i}}function WO(n){return new qO(n)}function A3(n,t){var c;const e=WO(n),o=[],r={},i=e.rowCount,s=e.colCount,l=Array(s).fill(100);for(let a=0;a<i;a++)for(let d=0;d<s;d++){let f;const m=e.getCellData({row:a,col:d});if(m&&m.virtual)continue;m&&!m.virtual&&(f=t.htmlToBlocks(m.cell.innerHTML,t)),(!f||f.length===0)&&(f=[{id:P(),type:"text",text:[]}]);const p=P();o.push(p);const{colSpan:A,rowSpan:k}=e.getCellSpan({row:a,col:d});k>1&&(r[`${p}_rowSpan`]=k),A>1&&(r[`${p}_colSpan`]=A),t.doc.blocks[p]=f,m&&!m.virtual&&(l[d]=Math.max(l[d],m3((c=t.font)!=null?c:"",f)))}for(let a=0;a<e.colCount;a++)l[a]=e.getColumnWidth(a)||l[a];return o.length===0?[]:[{cols:e.colCount,rows:e.rowCount,id:P(),type:"table",children:o,...r,colsWidth:l}]}function b3(n,t){var e;if(n.tagName==="TABLE"){const o={blocks:{root:[]},meta:{},comments:{}},r=A3(n,{doc:o,...t});if(r.length===0||((e=r[0].children)==null?void 0:e.length)===0)return;o.blocks.root=r;const i=JSON.stringify(o),s=Zo(i),l=document.createElement("div");l.classList.add("highlight-text-wizdoc");const c=document.createElement("pre");l.appendChild(c),c.innerText=s,n.insertAdjacentElement("beforebegin",l),n.remove();return}Array.from(n.children).forEach(o=>b3(o,t))}function v3(n){if(n instanceof HTMLStyleElement){n.remove();return}Array.from(n.children).forEach(v3)}function y3(n){if(n instanceof HTMLElement){if(n.style.display==="none"){n.remove();return}if(n.style.visibility==="hidden"){n.remove();return}}Array.from(n.children).forEach(y3)}function GO(n,t){const e=Rl(n);return e.querySelectorAll("td.js-line-number").forEach(r=>r.remove()),e.querySelectorAll("div.copy-button").forEach(r=>r.remove()),e.querySelectorAll("div.code-copy-button").forEach(r=>r.remove()),e.querySelectorAll("noscript").forEach(r=>r.remove()),Array.from(e.children).forEach(y3),Array.from(e.children).forEach(r=>b3(r,t)),Array.from(e.children).forEach(v3),C3(e),Gm(e)}const Xn=new a8.default;Xn.use(_O),Xn.use(FO),Xn.use(HO),Xn.use(jO),Xn.use(zO),Xn.use(UO),Xn.use(VO),Xn.use(Q7.gfm);function ZO(n,t){const e=k3(n,t);if(!e)return[];const{root:o,...r}=e.blocks;return t.doc.blocks={...t.doc.blocks,...r},o}function k3(n,t){const e=Xn.turndown(n);return p3(e,{htmlToDoc:o=>w3(o,t)})}function w3(n,t){const e=GO(n,{font:t==null?void 0:t.font,htmlToBlocks:ZO});return k3(e)}function B3(n){return n.indexOf('xmlns:o="urn:schemas-microsoft-com:office:office"')!==-1}function ka(n){return["A","B","DEL","I","U","S","SPAN","SUB","SUP"].indexOf(n.tagName)!==-1}function QO(n){return["P","H1","H2","H3","H4","H5","H6","H7","H8","LI"].indexOf(n.tagName)!==-1}function E3(n){return n.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ")}function YO(n){if(!n.tagName)return!1;if(n.tagName.toLocaleLowerCase()==="img")return!0;const t=n.querySelectorAll("img");for(let e=0;e<t.length;e+=1){const o=t[e];if(!o.src||o.getAttribute("width")==="0"||o.getAttribute("height")==="0")return!1}return t.length}function JO(n){return(n.tagName.toLocaleLowerCase()==="img"?[n]:Array.from(n.querySelectorAll("img"))).map(r=>({id:P(),type:"embed",embedType:"image",embedData:{src:r.src,width:r.width,height:r.height}}))}function I3(n){var e;return Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" ")).findIndex(o=>o.startsWith("level"))!==-1}function KO(n){var e;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let o=0;o<t.length;o++){const r=t[o];if(r.startsWith("mso-list:"))return r}return""}function x3(n){var e,o;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let r=0;r<t.length;r++){const i=t[r];if(i.startsWith("level")){const s=(o=Number.parseInt(i.substring(5),10))!=null?o:void 0;if(s)return s}}return 1}function XO(n,t){n.setAttribute("data-group-id",t)}function tN(n){const t={},e=r=>{Array.from(Object.keys(t)).forEach(i=>{Number.parseInt(i,10)>r&&delete t[i]})};let o="";Array.from(n.children).forEach(r=>{if(I3(r)){const i=KO(r);o!==i&&(e(0),o=i);const s=x3(r);e(s);let l=t[`${s}`];l||(l=P(),t[`${s}`]=l),XO(r,l)}})}function T3(n){if(!I3(n))return{};const t=x3(n),e=n.getAttribute("data-group-id")||P();return{start:1,level:t,groupId:e,ordered:!0,type:"list"}}const eN=w("office-list");function S3(n){return n instanceof HTMLOListElement||n instanceof HTMLUListElement}function nN(n,t){u(eN,S3(n),"not list group element");let e=!1,o=1;const r=P();n instanceof HTMLOListElement&&(e=!0,o=n.start);const i=n,s=[];let l;return Array.from(i.children).forEach(c=>{if(c instanceof HTMLLIElement){const d=T3(c),f=t.textElementToBlocks(c,t);l||(l=d.level);const m=f[0];s.push({...m,type:"list",ordered:e,level:l,groupId:r,start:o}),o+=1,s.push(...f.slice(1));return}const a=t.blockElementToBlocks(c,t);s.push(...a)}),s}function D3(n,t){if(n.nodeName==="META")return[];if(n instanceof HTMLTableElement)return A3(n,t);if(S3(n))return[...nN(n,t)];if(YO(n))return[...JO(n)];if(QO(n))return[...t.textElementToBlocks(n,t)];if(!n.children)return[];const e=[];return Array.from(n.children).forEach(o=>{const r=D3(o,t);e.push(...r)}),e}function L3(n,t){const e=[];return n.forEach(o=>{var r;if(o instanceof Element)if(ka(o)){const i=document.createElement("p");i.appendChild(o);const s=t.blockElementToBlocks(i,t);e.push(...s)}else{const i=t.blockElementToBlocks(o,t);e.push(...i)}else if(o instanceof Text){const i=Vn(E3((r=o.textContent)!=null?r:""));e.push(i)}}),e}function oN(n){const t=Array.from(n.children);for(let e=0;e<t.length;e++){const o=t[e];if(!ka(o))continue;let r=e+1;for(;r<t.length&&ka(t[r]);)r+=1;const i=document.createElement("p");o.insertAdjacentElement("beforebegin",i);for(let s=e;s<r;s++)i.appendChild(t[s]);e=r-1}}function rN(n,t){const e=Rl(n);return L3(Array.from(e.childNodes),t)}function iN(n){if(!(n instanceof HTMLElement))return{};const t={};if(n.style.textAlign==="right"?t.align="right":n.style.textAlign==="center"&&(t.align="center"),n.style.marginLeft){const e=Math.ceil(Number.parseInt(n.style.marginLeft,10)/20);e>=1&&e<=12&&(t.padding=e)}return t}function sN(n,t){var o;const e=E3((o=n.nodeValue)!=null?o:" ");return t&&Object.keys(t).length>0?{insert:e,attributes:t}:{insert:e}}function lN(n,t){if(n.nodeName==="B")return{...t,"style-bold":!0};if(n.nodeName==="I")return{...t,"style-italic":!0};if(n.nodeName==="U")return{...t,"style-underline":!0};if(n.nodeName==="S"||n.nodeName==="DEL")return{...t,"style-strikethrough":!0};if(n.nodeName==="SUB")return{...t,"style-sub":!0};if(n.nodeName==="SUP")return{...t,"style-super":!0};if(n.nodeName==="A"&&n.href){const o=n.href;if(o.startsWith("http:")||o.startsWith("https:"))return{...t,link:n.href}}const e={...t};return n instanceof HTMLSpanElement?(n.style.backgroundColor&&(e["inline-style-background-color"]=n.style.backgroundColor),n.style.color&&(e["inline-style-color"]=n.style.color),n.style.fontSize&&(e["inline-style-font-size"]=n.style.fontSize),n.style.fontFamily&&(e["inline-style-font-family"]=n.style.fontFamily),e):t}function M3(n,t,e){if(n instanceof HTMLSpanElement&&n.getAttribute("style")==="mso-list:Ignore")return;const o=lN(n,t);if(n instanceof Text&&n.nodeValue){e.push(sN(n,o));return}n.childNodes.length>0&&Array.from(n.childNodes).forEach(r=>{M3(r,o,e)})}function R3(n){return n instanceof Element?ka(n):!0}function pf(n){return!R3(n)}function cN(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],o=pf(n[0]);for(let r=1;r<n.length;r++){const i=n[r];o===pf(i)?e.push(i):(t.push(e),e=[i],o=pf(i))}return t.push(e),t}function aN(n,t){const e={};if(n.tagName.startsWith("H")){const i=Number.parseInt(n.tagName.substr(1),10);i>=1&&i<=8&&(e.heading=i)}const o=cN(Array.from(n.childNodes)),r=[];return o.forEach((i,s)=>{if(R3(i[0])){const l=[],c={};Array.from(n.childNodes).forEach(d=>{M3(d,c,l)});let a={};s===0&&(a=T3(n)),r.push({id:P(),type:"text",text:l,...a,...e,...iN(n)})}i.forEach(l=>{const c=t.blockElementToBlocks(l,t);r.push(...c)})}),r}function uN(n,t){const e=Rl(n);tN(e),oN(e);const o={blocks:{root:[]},meta:{},comments:{}},r={font:t==null?void 0:t.font,doc:o,blockElementToBlocks:D3,textElementToBlocks:aN,htmlToBlocks:rN},i=L3(Array.from(e.children),r);if(i.length!==0)return o.blocks.root=i,o}const dN=w("html-to-doc");function O3(n,t){if(!n)return null;const e=uO(n);if(e)return e;if(B3(n)){const o=uN(n,t);if(o)return o}try{return w3(n,t)}catch(o){dN.error(o)}return null}class hN{async fromData(t,e){const o={},r=e.getData("text/html");if(r){const i=O3(r,{font:t.rootContainer});i&&(B3(r)?o["text/office-html"]=i:o["text/html"]=i)}return o}}class fN{async fromData(t,e){const o=e.getData("text/plain");if(!o)return;const r=p3(o,{font:t.rootContainer,htmlToDoc:O3});if(!!r)return{"text/markdown":r}}}function mN(n){return/^([\d\w\u4e00-\u9fa5\s]*[\u4e00-\u9fa5\s]{1}|)((https|http|ftp)?:\/\/)[^\s]+/.test(n)}function gN(n){const t=[],e=n.split(/https|http|ftp/)[0],o=n.substring(e.length).trim();if(e&&e.length){const i=_e(e,null);t.push(i,_e(" ",null))}const r=_e(o,{link:o});return t.push(r,_e(" ",null)),t}class pN{async fromData(t,e){const o={},r=e.getData("text/plain");if(r){const l={blocks:{root:r.replace(/\r\n/g,`
|
|
579
579
|
`).replace(/\r/g,`
|
|
580
580
|
`).split(`
|
|
581
|
-
`).map(c=>{const a={id:P(),type:"text"};if(mN(c))return a.text=gN(c),a;const d=c?[_e(c,null)]:[];return a.text=d,a})},meta:{},comments:{}};o["text/plain"]=l}return o}}function CN(n){const t=[];for(let e=0;e<n.length;e++){const o=n[e];o.type.toLocaleLowerCase().startsWith("image/")&&t.push(o)}return t}class N3{constructor(t){t.dataConverter.addConverter(new hN),t.dataConverter.addConverter(new pN),t.dataConverter.addConverter(new fN)}async handleBeforePaste(t,e,o){if(!e)return!1;const r=e.clipboardData;if(r){if(r.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const s=CN(r.files);if(s.length>0&&!o["text/office-html"])return await this.handleInsertImages(t,s),!0}return!1}async handleInsertImages(t,e){const o=t.selection.focusedBlock,r=z(o),i=K(o),s=V(r);let l=i;Tt(t,o)||(l+=1);for(let c=0;c<e.length;c++){const a=e[c],d=await Hu(t,"image",s,l+c,{file:a});d&&Ig(t,d,"image",{id:"replace-image",name:"Replace image",data:{block:d,image:a}})}}}function P3(n){return xt.isSafari&&!!n&&Date.now()-n<100}const $3=w("highlight-data");class wa{constructor(t){h(this,"data",new Map);this.editor=t}add(t,e,o){const r={id:P(),blockId:j(t),oldText:this.editor.getBlockText(t),start:e,end:o};return this.data.set(r.id,r),r}get(t){const e=this.data.get(t);return u($3,e,`no highligh data: ${t}`),e}remove(t){this.data.delete(t)}clearBlockData(t){Array.from(this.data.values()).forEach(e=>{e.blockId===t&&this.data.delete(e.id)})}destroy(){}static getData(t){return t.addCustom("highligh-data",()=>new wa(t))}}function AN(n,t,e,o,r){const s=wa.getData(n).add(t,e,o);return r.setAttribute("data-highlight-id",s.id),s}function Ba(n,t){const e=t.getAttribute("data-highlight-id");return u($3,e,"invalid highlight elem, no id"),wa.getData(n).get(e)}const sl=w("highligh-dom");function bN(n){return rt(n,"editor-highlight")}function Mn(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function vN(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function Cf(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function yN(n){Cf(n).forEach(t=>{t.remove()})}function Ci(n){return Mn(n).length}function kN(n,t){u(sl,t>=0,`invalid highlight index: ${t}`);const e=Mn(n);return e.length===0?null:(u(sl,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function wN(n,t,{left:e,top:o,width:r,height:i},s){const l=["editor-highlight-child"];s&&l.push("editor-highlight-readonly");const c=b("div",l,n);c.style.top=`${o}px`,c.style.left=`${e}px`,c.style.width=`${r}px`,c.style.height=`${i}px`}function _3(n,t,e,o,r){u(sl,o>0,`invalid end: ${o}`);const i=Rt(t),s=t.getBoundingClientRect(),l=co(n,t,Ot(n,t,e,o)),a=b("div",[r==="find"?"editor-highlight":"editor-replace-result-highlight"],i);l.forEach(d=>{wN(a,t,{left:d.left-s.left,width:d.width,top:d.top-s.top,height:d.height})}),AN(n,t,e,o,a)}function BN(n,t,e,o){return _3(n,t,e,o,"find")}function F3(n,t,e,o){return _3(n,t,e,o,"replace")}function Ea(n,t){Mn(n).forEach(s=>{rt(s,"active")&&H(s,"active")}),M(t,"active"),u(sl,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const o=t.firstChild;let i=o.getBoundingClientRect().y;i===0&&(i=o.getBoundingClientRect().y),pu(o,{elementToScroll:n.scrollContainer})}function ll(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function H3(n){return u(sl,n,"no highlight elem"),rt(n,"editor-highlight-readonly")}const Ai=w("highligh-text");function EN(n){vN(n).forEach(e=>{e.remove()})}function Af(n,t){Mn(n).forEach(o=>{o.remove()}),t!=null&&t.keepReplaceResult||EN(n)}function j3(n){const t=ll(n);if(!t)return-1;const o=Mn(n).indexOf(t);return u(Ai,o!==-1,`invalid highlight index: ${o}`),o}function IN(n){const t=Mn(n);if(t.length===0)return 0;const e=ll(n);let o=e?t.indexOf(e):-1;!e||o===-1||o===t.length-1?o=0:o+=1;const r=t[o];return Ea(n,r),o}function xN(n){const t=Mn(n);if(t.length===0)return 0;const e=ll(n);let o=e?t.indexOf(e):-1;!e||o===-1||o===0?o=t.length-1:o-=1;const r=t[o];return Ea(n,r),o}function TN(n,t){const e=Mn(n);e.length>0&&t<e.length&&Ea(n,e[t])}function SN(n,t,e){const o=ll(n);if(!o)return!1;const r=U(o);if(u(Ai,r,"no parent block"),!n.isBlockWritable(r))return!1;const i=Ci(n);let s=j3(n);if(!H3(o)&&n.isBlockWritable(r)){const a=Ba(n,o),d=n.getBlockText(r),{start:f,end:m}=Ba(n,o),[p,A]=ce.transformOffset(a.oldText,d,[f,m]),k=qg(d,p,A-p);if(vt(k).toLowerCase()!==t.toLowerCase())return!1;const v=Kl(d,p,A,e);n.setBlockText(r,v),yN(r),z3(n,r,t),e&&F3(n,r,p,p+e.length)}const l=Ci(n);s>=l?s=0:l>i&&(s+=1);const c=kN(n,s);return c&&Ea(n,c),!0}function DN(n,t,e,o){if(!_(n,t)||!n.isBlockWritable(t))return 0;const r=n.getBlockText(t);u(Ai,r,"no block text");const i={count:0},s=mp(r,e,o,i);return vt(r)===vt(s)?0:(n.setBlockText(t,s),i.count)}function LN(n,t,e){if(u(Ai,bN(t),"not a highlight elem"),H3(t))return;u(Ai,e>0,"invalid highlight length");const o=Ba(n,t),r=U(t);u(Ai,r,"no parent block"),F3(n,r,o.start,o.start+e)}function MN(n,t){Mn(n).forEach(o=>{LN(n,o,t)})}function RN(n,t,e){if(n.readonly)return 0;const o=i=>{let s=0;return Mt(i).forEach(c=>{at(n,c)?Se(n,c).forEach(d=>{s+=o(d)}):s+=DN(n,c,t,e)}),s},r=o(n.rootContainer);return e.length>0&&MN(n,e.length),r}function ON(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),o=t.isSimple()?t.offset:1,r=Cf(e);for(let l=0;l<r.length;l++){const c=r[l],{end:a}=Ba(n,c);if(a>=o)return c}const i=Gu(n,{simpleBlockOnly:!0}),s=i.indexOf(e);if(s===-1)return null;for(let l=s+1;l<i.length;l++){const c=i[l],a=Cf(c);if(a.length>0)return a[0]}return null}function NN(n){const t=Mn(n),e=ON(n);return e?t.indexOf(e):0}function z3(n,t,e){if(!!e&&_(n,t)){const o=n.getBlockText(t),r=cd(o,e);r.length>0&&r.forEach(({start:i,end:s})=>{BN(n,t,i,s)})}}function PN(n,t){if(Af(n),!t)return;Gu(n,{simpleBlockOnly:!0}).forEach(o=>{z3(n,o,t)})}class $N{constructor(t){h(this,"dialog",null);h(this,"root");h(this,"oldText","");h(this,"_compositionEndTime",0);h(this,"components");h(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});h(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});h(this,"handleInput",t=>{if(t.isComposing||P3(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});h(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});h(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!ll(this.editor))return;const o=this.components.replaceInput.value;if(t===o)return;if(SN(this.editor,t,o)){const i=j3(this.editor),s=Ci(this.editor);this.updateSearchStatus(i,s)}this.findNext({keepSearchResult:!0})});h(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;if(t===e)return;RN(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))});h(this,"doSearch",ee.default(this.doSearchNow,300));this.editor=t;const e=b("div",["editor-find-dialog"],null),o=b("div",["editor-find-content"],e),r=b("div",["editor-find-dialog-row"],o),i=Ir(g5,["editor-find-dialog-button-close"],e),s=b("label",["editor-find-dialog-label"],r,x.t("find.findLabel"));s.htmlFor="";const l=b("div",["editor-find-dialog-input-container"],r),c=b("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=x.t("find.findPlaceholder");const a=b("div",["editor-find-dialog-status"],l),d=Ir(vw,["editor-find-dialog-icon-button"],a),f=b("div",["editor-find-dialog-curr"],a,"0/0"),m=Ir(yw,["editor-find-dialog-icon-button"],a);let p;x.t("find.moreButton")?p=b("button",["editor-find-dialog-button"],r,x.t("find.moreButton")):p=Ir(p5,["editor-find-dialog-icon-button-border"],r);const A=b("div",["editor-find-dialog-row"],o),k=b("label",["editor-find-dialog-label"],A,x.t("find.replaceLabel"));k.htmlFor="";const v=b("div",["editor-find-dialog-input-container"],A),T=b("input",["editor-find-dialog-input"],v);T.type="text",T.placeholder=x.t("find.replacePlaceholder");const E=b("div",["editor-find-dialog-row"],o);b("div",["editor-find-dialog-space"],E);const L=b("button",["editor-find-dialog-button"],E,x.t("find.findButton")),R=b("button",["editor-find-dialog-button"],E,x.t("find.replaceButton")),$=b("button",["editor-find-dialog-button"],E,x.t("find.replaceAllButton"));p.onclick=()=>{this.showReplace()},i.onclick=()=>{this.hide()},c.onkeydown=q=>{if(q.isComposing||P3(this._compositionEndTime)){this.doSearch.cancel();return}jm(q)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):yu(q)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,L.onclick=this.handleFind,R.onclick=this.handleReplace,$.onclick=this.handleReplaceAll,T.maxLength=50,m.onclick=()=>{this.gotoNext()},d.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:d,findCurrent:f,findNext:m,replaceInput:T,findButton:L,replaceButton:R,replaceAllButton:$,closeButton:i,showReplaceButton:p,rowReplace:A,rowActions:E,statusContainer:a},this.root=e}findNext(t){this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:t.keepSearchResult,gotoFirstSearchResult:!0})}doSearchNow(t){const e=this.components.findInput.value;if(e||this.clearFind(t),this.oldText===e){this.gotoNext();return}this.oldText=e,PN(this.editor,e);const o=Ci(this.editor),r=NN(this.editor);t.gotoFirstSearchResult&&TN(this.editor,r),this.updateSearchStatus(r,o)}gotoNext(){const t=Ci(this.editor),e=IN(this.editor);this.updateSearchStatus(e,t)}gotoPrev(){const t=Ci(this.editor),e=xN(this.editor);this.updateSearchStatus(e,t)}updateSearchStatus(t,e){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",e===0)this.components.findCurrent.innerText="0/0",this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0,this.components.findButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1}/${e}`;const o=this.editor.readonly;this.components.replaceAllButton.disabled=o,this.components.replaceButton.disabled=o,this.components.findButton.disabled=!1}}clearFind(t){Af(this.editor),this.updateSearchStatus(0,0)}showFindOnly(){this.components.rowReplace.style.display="none",this.components.rowActions.style.display="none",this.components.showReplaceButton.style.display="flex"}showReplace(){this.components.rowReplace.style.display="flex",this.components.rowActions.style.display="flex",this.components.showReplaceButton.style.display="none",this.components.replaceInput.focus(),this.components.replaceInput.select()}hideSearchResult(){this.components.statusContainer.style.display="none"}showSearchResult(){this.components.statusContainer.style.display="flex"}show(t){const e=this.editor.getSelectedText();e.length>0&&e.length<50&&(this.components.findInput.value=e),this.root.style.display="flex",t!=null&&t.showFindAndReplace?(this.showReplace(),this.components.findInput.value&&setTimeout(()=>{this.components.replaceInput.focus()})):this.showFindOnly(),this.hideSearchResult(),this.oldText="",this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0});const o=this.editor.readonly;this.components.replaceButton.disabled=o,this.components.replaceAllButton.disabled=o,this.components.replaceInput.disabled=o,this.dialog||(this.dialog=new Ds(this.root,{disablePageScroll:!1}));const r=this.editor.options.componentsOptions.findDialog,i=(r==null?void 0:r.popoverTarget)||this.editor.rootContainer,s=()=>{var f,m,p,A;const l=r==null?void 0:r.getReferenceClientRect;if(l&&((m=(f=this.dialog)==null?void 0:f.tippyInstance)==null?void 0:m.popper))return l(i,(A=(p=this.dialog)==null?void 0:p.tippyInstance)==null?void 0:A.popper);const c=i.getBoundingClientRect(),a=c.top<0?12:c.top+12,d=c.right-this.root.clientWidth-12;return new DOMRect(d,a,0,0)};this.dialog.show(i,{getReferenceClientRect:s}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close(),Af(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var t;(t=this.dialog)==null||t.destroy()}}const _N={find:{findLabel:"\u67E5\u627E:",replaceLabel:"\u66FF\u6362:",findButton:"\u67E5\u627E",replaceButton:"\u66FF\u6362",replaceAllButton:"\u5168\u90E8\u66FF\u6362",moreButton:"",findPlaceholder:"\u5728\u6587\u6863\u5185\u67E5\u627E",replacePlaceholder:"\u66FF\u6362\u4E3A"}},FN={find:{findLabel:"Find:",replaceLabel:"Replace:",findButton:"Find",replaceButton:"Replace",replaceAllButton:"Replace All",moreButton:"",findPlaceholder:"Find text in document",replacePlaceholder:"Replace to"}};x.mergeLang({"zh-CN":_N,"en-US":FN});function U3(n){return n.addCustom("find-dialog",()=>new $N(n)).show(),!0}const V3={"CtrlOrCmd+F":U3},NV="";function HN(n){U3(n)}function bf(n,t){return t.map(e=>{var i,s;const o=pt(n,e),r=(i=o.getBlockProperties)==null?void 0:i.call(o,n,e);return(s=r==null?void 0:r.abstract)!=null?s:""}).join(" ")}function Ia(n){const{editor:t,commentGroupId:e,abstract:o="text"}=n,r=P(),i=t.doc.getUser(),s=Date.now(),l=e!=null?e:r;return{id:r,groupId:l,userId:i.userId,displayName:i.displayName,avatarUrl:i.avatarUrl,abstract:o,created:s,modified:s}}function q3(n,t,e){const o=e.id,i=n.getBlockData(t).comments;let s;i?s=[...i,o]:s=[o];const l={comments:s};n.updateBlockData(t,l)}function vf(n,t,e){const o=bf(n,[t]),r=Ia({editor:n,abstract:o});q3(n,t,r);const i=or();return e.localCreateComment(r,i),r}const jN=w("standard-block-actions");class zN{constructor(t,e){h(this,"executeCommand",(t,e,o)=>{const r=o.data;try{this.editorComments.showCommentList();const i=t.getBlockById(r);vf(t,i,this.provider)}catch(i){jN.error(`failed to execute block command: ${JSON.stringify(i)}`)}});this.provider=t,this.editorComments=e}commands(t,e){return{group:"block-comment-actions",commands:[{id:"comment",name:"Add comment",data:j(e),order:100,states:t.isBlockWritable(e)?[]:["disabled"]}],executeCommand:this.executeCommand}}}var mt=(n=>(n.SwitchUp="switch-up",n.SwitchDown="switch-down",n.CommentItemReply="comment-item-reply",n.CommentItemMore="comment-item-more",n.CommentItemOk="comment-item-ok",n.CommentItemCancel="comment-item-cancel",n.CommentItemDelete="comment-item-delete",n.CommentItemEdit="comment-item-edit",n.QuickReply="quick-reply",n.QuickReplyOk="quick-reply-ok",n.QuickReplyCancel="quick-reply-cancel",n))(mt||{});const yf="group-item-action",W3="last-comment-item",to="disabled",G3=500;function Cr(n){return n.id!==n.groupId}function Z3(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function UN(n){const t=n.closest(".comment-item-root");return t?t.id:null}function eo(n,t){n.setAttribute(yf,t)}function VN(n){return n.closest(`[${yf}]`)}function qN(n){var t;return(t=n.getAttribute(yf))!=null?t:""}function WN(n){return rt(n,to)}function Q3(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}`);if(!e)return null;const o=e.closest('[data-type="editor-block"]');return o?o.id:null}function Y3(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const J3=w("doc-comments");function K3(n,t,e,o){if(t.comments){const i=t.comments;Array.isArray(i)&&i.forEach(s=>{o.has(s)||(o.add(s),e.push(s))})}t.text&&t.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.attributes).forEach(([c,a])=>{if(c.startsWith(l)){const d=a;o.has(d)||(o.add(d),e.push(d))}})}});const r=t.children;!r||r.forEach(i=>{n.blocks[i].forEach(l=>{K3(n,l,e,o)})})}function GN(n){const t=[],e=new Set;n.blocks.root.forEach(r=>{K3(n,r,t,e)});const o=new Map;return t.forEach((r,i)=>o.set(r,i)),o}function ZN(n){const t=new Map;n.forEach(r=>{if(Cr(r)){const i=t.get(r.groupId);i?i.push(r):t.set(r.groupId,[r])}});const e=[];return n.forEach(r=>{var i;if(!Cr(r)){const s=(i=t.get(r.id))!=null?i:[];t.delete(r.id);const l={...r,children:s};e.push(l)}}),Array.from(t.values()).forEach(r=>{const i=r[0],s=r.slice(1),l={...i,children:s};e.push(l)}),e}function No(n,t){const e=n.doc.toJSON(),o=GN(e);return ZN(t.getComments()).filter(s=>o.has(s.groupId)).sort((s,l)=>{const c=o.get(s.groupId),a=o.get(l.groupId);return u(J3,c!==void 0,`comment not exists in doc, ${s.groupId}`),u(J3,a!==void 0,`comment not exists in doc, ${l.groupId}`),c-a})}function kf(n){const{children:t,...e}=n,o=[e];return t.forEach(r=>{o.push(r)}),o}function QN(n,t){return No(n,t).map(kf).reduce((r,i)=>i.length+r,0)}function wf(n,t){const e=[],o=n.getBlockById(t.blockId);if(_(n,o)){const i=t.blockId,s=t.offset,l=n.getBlockById(i),c=n.getBlockText(l),a=Ji(c,s);a&&Object.entries(a).forEach(([d,f])=>{d.startsWith("comment-")&&e.push(f)})}const r=o.attributes;for(let i=0;i<r.length;i++){const s=r[i];s.name.startsWith("comment-")&&e.push(s.value)}return e}function X3(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return wf(n,t.start);const{start:e,end:o}=t,r=wf(n,e),i=wf(n,o);return cu.default(r,i)}const YN=w("active-comments");function t6(n,t){n.rootContainer.querySelectorAll(`span.text.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(o=>{H(o,"active")})}function e6(n,t){const e=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!t)e&&Y3(e).forEach(r=>t6(n,r));else{const o=t.toLocaleLowerCase();if(e){const i=Y3(e);if(i.length===1&&i[0]===o)return;i.forEach(s=>t6(n,s))}const r=n.rootContainer.querySelectorAll(`span.text.comment[comment-${o}],[data-type=editor-block].comment[comment-${o}]`);if(r){r.forEach(s=>{M(s,"active")});const i=r[0];if(Jo(i))n.selection.selectBlock(i,0);else if(X3(n).indexOf(t)===-1){const l=U(i);u(YN,l,"block not found");const c=mo(l,i);n.selection.selectBlock(l,c.start)}n.focus()}}}const PV="";w("comment-editor");const{t:JN}=x,Bf="comment-editor-readonly",cl="comment-editor-editing";class Ef{constructor(t,e,o){h(this,"root");h(this,"components");h(this,"handleEditorBlur",()=>{this.inactiveEditor()});h(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});h(this,"activeEditor",()=>{rt(this.root,cl)||M(this.root,cl)});h(this,"inactiveEditor",()=>{H(this.root,cl)});h(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=V(t.rootContainer),o=await Qo("image/*",{}),r={src:"",widthPercent:50},i={id:P(),type:"embed",embedType:"image",embedData:r},s=t.options.componentsOptions.image;s!=null&&s.defaultAlign&&(i.align=s.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),a=t.insertBlock(e,c+1,i);Ut.getImageObject(t,a).replaceImage(0,o)});h(this,"handleReadonlyChange",t=>{t.readonly?(H(this.root,cl),M(this.root,Bf)):(M(this.root,cl),H(this.root,Bf))});h(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});h(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});h(this,"isEmpty",()=>tc(this.getDoc()));h(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,Y0(t),this.activeEditor()});h(this,"clear",()=>{const t=or();this.setDoc(t)});h(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});h(this,"destroy",()=>{const{root:t,components:{editor:e,insertImgButton:o}}=this;o.onclick=null,e.destroy(),t.remove()});this.mainEditor=t,this.commentsProvider=e,this.doc=o,this.root=b("div",["comment-editor",Bf],null),this.components=this.createEditor()}createEditor(){const t=b("div",["comment-editor-root"],this.root),{commentsProvider:e,mainEditor:o}=this,r=e.createCommentEditor(t,new Yd(this.doc));r.readonly=!0,r.addListener("readonlyChanged",this.handleReadonlyChange),r.addListener("focus",this.handleEditorFocus),r.addListener("blur",this.handleEditorBlur);const i=mr(this.root,"comment-editor-img",JN("comment.image"),Lw,void 0,o.clientId);return i.classList.add("comment-editor-img"),i.onclick=this.handleInsertImg,{editor:r,insertImgButton:i}}get editor(){return this.components.editor}}class KN{constructor(t){h(this,"handleBeforeKeyDown",(t,e)=>{if(jn(e,"Enter")){const{quickReply:o,updateLastCommentItem:r}=this.groupItem;return o.getReplyEditor().isEmpty()?(o.hideReplyEditor(),!0):(o.reply(),r(),!0)}return!1});this.groupItem=t}}class XN{constructor(t,e,o){h(this,"handleBeforeKeyDown",(t,e)=>{if(jn(e,"Enter")){const{quickReply:o}=this.groupItem,{comment:r,getCommentEditor:i}=this.commentItem,s=i();if(s.isEmpty())this.commentsProvider.localDeleteComment(r.id);else{const l=s.getDoc();this.commentsProvider.localUpdateComment(r,l),s.readonly()}return o.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=o}}const tP=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
581
|
+
`).map(c=>{const a={id:P(),type:"text"};if(mN(c))return a.text=gN(c),a;const d=c?[_e(c,null)]:[];return a.text=d,a})},meta:{},comments:{}};o["text/plain"]=l}return o}}function CN(n){const t=[];for(let e=0;e<n.length;e++){const o=n[e];o.type.toLocaleLowerCase().startsWith("image/")&&t.push(o)}return t}class N3{constructor(t){t.dataConverter.addConverter(new hN),t.dataConverter.addConverter(new pN),t.dataConverter.addConverter(new fN)}async handleBeforePaste(t,e,o){if(!e)return!1;const r=e.clipboardData;if(r){if(r.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const s=CN(r.files);if(s.length>0&&!o["text/office-html"])return await this.handleInsertImages(t,s),!0}return!1}async handleInsertImages(t,e){const o=t.selection.focusedBlock,r=z(o),i=K(o),s=V(r);let l=i;Tt(t,o)||(l+=1);for(let c=0;c<e.length;c++){const a=e[c],d=await Hu(t,"image",s,l+c,{file:a});d&&Ig(t,d,"image",{id:"replace-image",name:"Replace image",data:{block:d,image:a}})}}}function P3(n){return xt.isSafari&&!!n&&Date.now()-n<100}const $3=w("highlight-data");class wa{constructor(t){h(this,"data",new Map);this.editor=t}add(t,e,o){const r={id:P(),blockId:j(t),oldText:this.editor.getBlockText(t),start:e,end:o};return this.data.set(r.id,r),r}get(t){const e=this.data.get(t);return u($3,e,`no highligh data: ${t}`),e}remove(t){this.data.delete(t)}clearBlockData(t){Array.from(this.data.values()).forEach(e=>{e.blockId===t&&this.data.delete(e.id)})}destroy(){}static getData(t){return t.addCustom("highligh-data",()=>new wa(t))}}function AN(n,t,e,o,r){const s=wa.getData(n).add(t,e,o);return r.setAttribute("data-highlight-id",s.id),s}function Ba(n,t){const e=t.getAttribute("data-highlight-id");return u($3,e,"invalid highlight elem, no id"),wa.getData(n).get(e)}const sl=w("highligh-dom");function bN(n){return rt(n,"editor-highlight")}function Mn(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function vN(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function Cf(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function yN(n){Cf(n).forEach(t=>{t.remove()})}function Ci(n){return Mn(n).length}function kN(n,t){u(sl,t>=0,`invalid highlight index: ${t}`);const e=Mn(n);return e.length===0?null:(u(sl,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function wN(n,t,{left:e,top:o,width:r,height:i},s){const l=["editor-highlight-child"];s&&l.push("editor-highlight-readonly");const c=b("div",l,n);c.style.top=`${o}px`,c.style.left=`${e}px`,c.style.width=`${r}px`,c.style.height=`${i}px`}function _3(n,t,e,o,r){u(sl,o>0,`invalid end: ${o}`);const i=Rt(t),s=t.getBoundingClientRect(),l=co(n,t,Ot(n,t,e,o)),a=b("div",[r==="find"?"editor-highlight":"editor-replace-result-highlight"],i);l.forEach(d=>{wN(a,t,{left:d.left-s.left,width:d.width,top:d.top-s.top,height:d.height})}),AN(n,t,e,o,a)}function BN(n,t,e,o){return _3(n,t,e,o,"find")}function F3(n,t,e,o){return _3(n,t,e,o,"replace")}function Ea(n,t){Mn(n).forEach(s=>{rt(s,"active")&&H(s,"active")}),M(t,"active"),u(sl,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const o=t.firstChild;let i=o.getBoundingClientRect().y;i===0&&(i=o.getBoundingClientRect().y),pu(o,{elementToScroll:n.scrollContainer})}function ll(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function H3(n){return u(sl,n,"no highlight elem"),rt(n,"editor-highlight-readonly")}const Ai=w("highligh-text");function EN(n){vN(n).forEach(e=>{e.remove()})}function Af(n,t){Mn(n).forEach(o=>{o.remove()}),t!=null&&t.keepReplaceResult||EN(n)}function j3(n){const t=ll(n);if(!t)return-1;const o=Mn(n).indexOf(t);return u(Ai,o!==-1,`invalid highlight index: ${o}`),o}function IN(n){const t=Mn(n);if(t.length===0)return 0;const e=ll(n);let o=e?t.indexOf(e):-1;!e||o===-1||o===t.length-1?o=0:o+=1;const r=t[o];return Ea(n,r),o}function xN(n){const t=Mn(n);if(t.length===0)return 0;const e=ll(n);let o=e?t.indexOf(e):-1;!e||o===-1||o===0?o=t.length-1:o-=1;const r=t[o];return Ea(n,r),o}function TN(n,t){const e=Mn(n);e.length>0&&t<e.length&&Ea(n,e[t])}function SN(n,t,e){const o=ll(n);if(!o)return!1;const r=U(o);if(u(Ai,r,"no parent block"),!n.isBlockWritable(r))return!1;const i=Ci(n);let s=j3(n);if(!H3(o)&&n.isBlockWritable(r)){const a=Ba(n,o),d=n.getBlockText(r),{start:f,end:m}=Ba(n,o),[p,A]=ce.transformOffset(a.oldText,d,[f,m]),k=qg(d,p,A-p);if(vt(k).toLowerCase()!==t.toLowerCase())return!1;const v=Kl(d,p,A,e);n.setBlockText(r,v),yN(r),z3(n,r,t),e&&F3(n,r,p,p+e.length)}const l=Ci(n);s>=l?s=0:l>i&&(s+=1);const c=kN(n,s);return c&&Ea(n,c),!0}function DN(n,t,e,o){if(!_(n,t)||!n.isBlockWritable(t))return 0;const r=n.getBlockText(t);u(Ai,r,"no block text");const i={count:0},s=mp(r,e,o,i);return vt(r)===vt(s)?0:(n.setBlockText(t,s),i.count)}function LN(n,t,e){if(u(Ai,bN(t),"not a highlight elem"),H3(t))return;u(Ai,e>0,"invalid highlight length");const o=Ba(n,t),r=U(t);u(Ai,r,"no parent block"),F3(n,r,o.start,o.start+e)}function MN(n,t){Mn(n).forEach(o=>{LN(n,o,t)})}function RN(n,t,e){if(n.readonly)return 0;const o=i=>{let s=0;return Mt(i).forEach(c=>{at(n,c)?Se(n,c).forEach(d=>{s+=o(d)}):s+=DN(n,c,t,e)}),s},r=o(n.rootContainer);return e.length>0&&MN(n,e.length),r}function ON(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),o=t.isSimple()?t.offset:1,r=Cf(e);for(let l=0;l<r.length;l++){const c=r[l],{end:a}=Ba(n,c);if(a>=o)return c}const i=Gu(n,{simpleBlockOnly:!0}),s=i.indexOf(e);if(s===-1)return null;for(let l=s+1;l<i.length;l++){const c=i[l],a=Cf(c);if(a.length>0)return a[0]}return null}function NN(n){const t=Mn(n),e=ON(n);return e?t.indexOf(e):0}function z3(n,t,e){if(!!e&&_(n,t)){const o=n.getBlockText(t),r=cd(o,e);r.length>0&&r.forEach(({start:i,end:s})=>{BN(n,t,i,s)})}}function PN(n,t){if(Af(n),!t)return;Gu(n,{simpleBlockOnly:!0}).forEach(o=>{z3(n,o,t)})}class $N{constructor(t){h(this,"dialog",null);h(this,"root");h(this,"oldText","");h(this,"_compositionEndTime",0);h(this,"components");h(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});h(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});h(this,"handleInput",t=>{if(t.isComposing||P3(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});h(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});h(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!ll(this.editor))return;const o=this.components.replaceInput.value;if(t===o)return;if(SN(this.editor,t,o)){const i=j3(this.editor),s=Ci(this.editor);this.updateSearchStatus(i,s)}this.findNext({keepSearchResult:!0})});h(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;if(t===e)return;RN(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))});h(this,"doSearch",ee.default(this.doSearchNow,300));this.editor=t;const e=b("div",["editor-find-dialog"],null),o=b("div",["editor-find-content"],e),r=b("div",["editor-find-dialog-row"],o),i=Ir(g5,["editor-find-dialog-button-close"],e),s=b("label",["editor-find-dialog-label"],r,T.t("find.findLabel"));s.htmlFor="";const l=b("div",["editor-find-dialog-input-container"],r),c=b("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=T.t("find.findPlaceholder");const a=b("div",["editor-find-dialog-status"],l),d=Ir(vw,["editor-find-dialog-icon-button"],a),f=b("div",["editor-find-dialog-curr"],a,"0/0"),m=Ir(yw,["editor-find-dialog-icon-button"],a);let p;T.t("find.moreButton")?p=b("button",["editor-find-dialog-button"],r,T.t("find.moreButton")):p=Ir(p5,["editor-find-dialog-icon-button-border"],r);const A=b("div",["editor-find-dialog-row"],o),k=b("label",["editor-find-dialog-label"],A,T.t("find.replaceLabel"));k.htmlFor="";const v=b("div",["editor-find-dialog-input-container"],A),x=b("input",["editor-find-dialog-input"],v);x.type="text",x.placeholder=T.t("find.replacePlaceholder");const E=b("div",["editor-find-dialog-row"],o);b("div",["editor-find-dialog-space"],E);const L=b("button",["editor-find-dialog-button"],E,T.t("find.findButton")),R=b("button",["editor-find-dialog-button"],E,T.t("find.replaceButton")),$=b("button",["editor-find-dialog-button"],E,T.t("find.replaceAllButton"));p.onclick=()=>{this.showReplace()},i.onclick=()=>{this.hide()},c.onkeydown=q=>{if(q.isComposing||P3(this._compositionEndTime)){this.doSearch.cancel();return}jm(q)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):yu(q)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,L.onclick=this.handleFind,R.onclick=this.handleReplace,$.onclick=this.handleReplaceAll,x.maxLength=50,m.onclick=()=>{this.gotoNext()},d.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:d,findCurrent:f,findNext:m,replaceInput:x,findButton:L,replaceButton:R,replaceAllButton:$,closeButton:i,showReplaceButton:p,rowReplace:A,rowActions:E,statusContainer:a},this.root=e}findNext(t){this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:t.keepSearchResult,gotoFirstSearchResult:!0})}doSearchNow(t){const e=this.components.findInput.value;if(e||this.clearFind(t),this.oldText===e){this.gotoNext();return}this.oldText=e,PN(this.editor,e);const o=Ci(this.editor),r=NN(this.editor);t.gotoFirstSearchResult&&TN(this.editor,r),this.updateSearchStatus(r,o)}gotoNext(){const t=Ci(this.editor),e=IN(this.editor);this.updateSearchStatus(e,t)}gotoPrev(){const t=Ci(this.editor),e=xN(this.editor);this.updateSearchStatus(e,t)}updateSearchStatus(t,e){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",e===0)this.components.findCurrent.innerText="0/0",this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0,this.components.findButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1}/${e}`;const o=this.editor.readonly;this.components.replaceAllButton.disabled=o,this.components.replaceButton.disabled=o,this.components.findButton.disabled=!1}}clearFind(t){Af(this.editor),this.updateSearchStatus(0,0)}showFindOnly(){this.components.rowReplace.style.display="none",this.components.rowActions.style.display="none",this.components.showReplaceButton.style.display="flex"}showReplace(){this.components.rowReplace.style.display="flex",this.components.rowActions.style.display="flex",this.components.showReplaceButton.style.display="none",this.components.replaceInput.focus(),this.components.replaceInput.select()}hideSearchResult(){this.components.statusContainer.style.display="none"}showSearchResult(){this.components.statusContainer.style.display="flex"}show(t){const e=this.editor.getSelectedText();e.length>0&&e.length<50&&(this.components.findInput.value=e),this.root.style.display="flex",t!=null&&t.showFindAndReplace?(this.showReplace(),this.components.findInput.value&&setTimeout(()=>{this.components.replaceInput.focus()})):this.showFindOnly(),this.hideSearchResult(),this.oldText="",this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0});const o=this.editor.readonly;this.components.replaceButton.disabled=o,this.components.replaceAllButton.disabled=o,this.components.replaceInput.disabled=o,this.dialog||(this.dialog=new Ds(this.root,{disablePageScroll:!1}));const r=this.editor.options.componentsOptions.findDialog,i=(r==null?void 0:r.popoverTarget)||this.editor.rootContainer,s=()=>{var f,m,p,A;const l=r==null?void 0:r.getReferenceClientRect;if(l&&((m=(f=this.dialog)==null?void 0:f.tippyInstance)==null?void 0:m.popper))return l(i,(A=(p=this.dialog)==null?void 0:p.tippyInstance)==null?void 0:A.popper);const c=i.getBoundingClientRect(),a=c.top<0?12:c.top+12,d=c.right-this.root.clientWidth-12;return new DOMRect(d,a,0,0)};this.dialog.show(i,{getReferenceClientRect:s}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close(),Af(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var t;(t=this.dialog)==null||t.destroy()}}const _N={find:{findLabel:"\u67E5\u627E:",replaceLabel:"\u66FF\u6362:",findButton:"\u67E5\u627E",replaceButton:"\u66FF\u6362",replaceAllButton:"\u5168\u90E8\u66FF\u6362",moreButton:"",findPlaceholder:"\u5728\u6587\u6863\u5185\u67E5\u627E",replacePlaceholder:"\u66FF\u6362\u4E3A"}},FN={find:{findLabel:"Find:",replaceLabel:"Replace:",findButton:"Find",replaceButton:"Replace",replaceAllButton:"Replace All",moreButton:"",findPlaceholder:"Find text in document",replacePlaceholder:"Replace to"}};T.mergeLang({"zh-CN":_N,"en-US":FN});function U3(n){return n.addCustom("find-dialog",()=>new $N(n)).show(),!0}const V3={"CtrlOrCmd+F":U3},NV="";function HN(n){U3(n)}function bf(n,t){return t.map(e=>{var i,s;const o=pt(n,e),r=(i=o.getBlockProperties)==null?void 0:i.call(o,n,e);return(s=r==null?void 0:r.abstract)!=null?s:""}).join(" ")}function Ia(n){const{editor:t,commentGroupId:e,abstract:o="text"}=n,r=P(),i=t.doc.getUser(),s=Date.now(),l=e!=null?e:r;return{id:r,groupId:l,userId:i.userId,displayName:i.displayName,avatarUrl:i.avatarUrl,abstract:o,created:s,modified:s}}function q3(n,t,e){const o=e.id,i=n.getBlockData(t).comments;let s;i?s=[...i,o]:s=[o];const l={comments:s};n.updateBlockData(t,l)}function vf(n,t,e){const o=bf(n,[t]),r=Ia({editor:n,abstract:o});q3(n,t,r);const i=or();return e.localCreateComment(r,i),r}const jN=w("standard-block-actions");class zN{constructor(t,e){h(this,"executeCommand",(t,e,o)=>{const r=o.data;try{this.editorComments.showCommentList();const i=t.getBlockById(r);vf(t,i,this.provider)}catch(i){jN.error(`failed to execute block command: ${JSON.stringify(i)}`)}});this.provider=t,this.editorComments=e}commands(t,e){return{group:"block-comment-actions",commands:[{id:"comment",name:"Add comment",data:j(e),order:100,states:t.isBlockWritable(e)?[]:["disabled"]}],executeCommand:this.executeCommand}}}var mt=(n=>(n.SwitchUp="switch-up",n.SwitchDown="switch-down",n.CommentItemReply="comment-item-reply",n.CommentItemMore="comment-item-more",n.CommentItemOk="comment-item-ok",n.CommentItemCancel="comment-item-cancel",n.CommentItemDelete="comment-item-delete",n.CommentItemEdit="comment-item-edit",n.QuickReply="quick-reply",n.QuickReplyOk="quick-reply-ok",n.QuickReplyCancel="quick-reply-cancel",n))(mt||{});const yf="group-item-action",W3="last-comment-item",to="disabled",G3=500;function Cr(n){return n.id!==n.groupId}function Z3(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function UN(n){const t=n.closest(".comment-item-root");return t?t.id:null}function eo(n,t){n.setAttribute(yf,t)}function VN(n){return n.closest(`[${yf}]`)}function qN(n){var t;return(t=n.getAttribute(yf))!=null?t:""}function WN(n){return rt(n,to)}function Q3(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}`);if(!e)return null;const o=e.closest('[data-type="editor-block"]');return o?o.id:null}function Y3(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const J3=w("doc-comments");function K3(n,t,e,o){if(t.comments){const i=t.comments;Array.isArray(i)&&i.forEach(s=>{o.has(s)||(o.add(s),e.push(s))})}t.text&&t.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.attributes).forEach(([c,a])=>{if(c.startsWith(l)){const d=a;o.has(d)||(o.add(d),e.push(d))}})}});const r=t.children;!r||r.forEach(i=>{n.blocks[i].forEach(l=>{K3(n,l,e,o)})})}function GN(n){const t=[],e=new Set;n.blocks.root.forEach(r=>{K3(n,r,t,e)});const o=new Map;return t.forEach((r,i)=>o.set(r,i)),o}function ZN(n){const t=new Map;n.forEach(r=>{if(Cr(r)){const i=t.get(r.groupId);i?i.push(r):t.set(r.groupId,[r])}});const e=[];return n.forEach(r=>{var i;if(!Cr(r)){const s=(i=t.get(r.id))!=null?i:[];t.delete(r.id);const l={...r,children:s};e.push(l)}}),Array.from(t.values()).forEach(r=>{const i=r[0],s=r.slice(1),l={...i,children:s};e.push(l)}),e}function No(n,t){const e=n.doc.toJSON(),o=GN(e);return ZN(t.getComments()).filter(s=>o.has(s.groupId)).sort((s,l)=>{const c=o.get(s.groupId),a=o.get(l.groupId);return u(J3,c!==void 0,`comment not exists in doc, ${s.groupId}`),u(J3,a!==void 0,`comment not exists in doc, ${l.groupId}`),c-a})}function kf(n){const{children:t,...e}=n,o=[e];return t.forEach(r=>{o.push(r)}),o}function QN(n,t){return No(n,t).map(kf).reduce((r,i)=>i.length+r,0)}function wf(n,t){const e=[],o=n.getBlockById(t.blockId);if(_(n,o)){const i=t.blockId,s=t.offset,l=n.getBlockById(i),c=n.getBlockText(l),a=Ji(c,s);a&&Object.entries(a).forEach(([d,f])=>{d.startsWith("comment-")&&e.push(f)})}const r=o.attributes;for(let i=0;i<r.length;i++){const s=r[i];s.name.startsWith("comment-")&&e.push(s.value)}return e}function X3(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return wf(n,t.start);const{start:e,end:o}=t,r=wf(n,e),i=wf(n,o);return cu.default(r,i)}const YN=w("active-comments");function t6(n,t){n.rootContainer.querySelectorAll(`span.text.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(o=>{H(o,"active")})}function e6(n,t){const e=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!t)e&&Y3(e).forEach(r=>t6(n,r));else{const o=t.toLocaleLowerCase();if(e){const i=Y3(e);if(i.length===1&&i[0]===o)return;i.forEach(s=>t6(n,s))}const r=n.rootContainer.querySelectorAll(`span.text.comment[comment-${o}],[data-type=editor-block].comment[comment-${o}]`);if(r){r.forEach(s=>{M(s,"active")});const i=r[0];if(Jo(i))n.selection.selectBlock(i,0);else if(X3(n).indexOf(t)===-1){const l=U(i);u(YN,l,"block not found");const c=mo(l,i);n.selection.selectBlock(l,c.start)}n.focus()}}}const PV="";w("comment-editor");const{t:JN}=T,Bf="comment-editor-readonly",cl="comment-editor-editing";class Ef{constructor(t,e,o){h(this,"root");h(this,"components");h(this,"handleEditorBlur",()=>{this.inactiveEditor()});h(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});h(this,"activeEditor",()=>{rt(this.root,cl)||M(this.root,cl)});h(this,"inactiveEditor",()=>{H(this.root,cl)});h(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=V(t.rootContainer),o=await Qo("image/*",{}),r={src:"",widthPercent:50},i={id:P(),type:"embed",embedType:"image",embedData:r},s=t.options.componentsOptions.image;s!=null&&s.defaultAlign&&(i.align=s.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),a=t.insertBlock(e,c+1,i);Ut.getImageObject(t,a).replaceImage(0,o)});h(this,"handleReadonlyChange",t=>{t.readonly?(H(this.root,cl),M(this.root,Bf)):(M(this.root,cl),H(this.root,Bf))});h(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});h(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});h(this,"isEmpty",()=>tc(this.getDoc()));h(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,Y0(t),this.activeEditor()});h(this,"clear",()=>{const t=or();this.setDoc(t)});h(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});h(this,"destroy",()=>{const{root:t,components:{editor:e,insertImgButton:o}}=this;o.onclick=null,e.destroy(),t.remove()});this.mainEditor=t,this.commentsProvider=e,this.doc=o,this.root=b("div",["comment-editor",Bf],null),this.components=this.createEditor()}createEditor(){const t=b("div",["comment-editor-root"],this.root),{commentsProvider:e,mainEditor:o}=this,r=e.createCommentEditor(t,new Yd(this.doc));r.readonly=!0,r.addListener("readonlyChanged",this.handleReadonlyChange),r.addListener("focus",this.handleEditorFocus),r.addListener("blur",this.handleEditorBlur);const i=mr(this.root,"comment-editor-img",JN("comment.image"),Lw,void 0,o.clientId);return i.classList.add("comment-editor-img"),i.onclick=this.handleInsertImg,{editor:r,insertImgButton:i}}get editor(){return this.components.editor}}class KN{constructor(t){h(this,"handleBeforeKeyDown",(t,e)=>{if(jn(e,"Enter")){const{quickReply:o,updateLastCommentItem:r}=this.groupItem;return o.getReplyEditor().isEmpty()?(o.hideReplyEditor(),!0):(o.reply(),r(),!0)}return!1});this.groupItem=t}}class XN{constructor(t,e,o){h(this,"handleBeforeKeyDown",(t,e)=>{if(jn(e,"Enter")){const{quickReply:o}=this.groupItem,{comment:r,getCommentEditor:i}=this.commentItem,s=i();if(s.isEmpty())this.commentsProvider.localDeleteComment(r.id);else{const l=s.getDoc();this.commentsProvider.localUpdateComment(r,l),s.readonly()}return o.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=o}}const tP=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
582
582
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.65499 6.6665C3.09433 6.6665 2.66699 7.1275 2.66699 7.67617C2.66699 8.2255 3.02633 8.64284 3.65499 8.6645C4.23833 8.6645 4.66399 8.26917 4.66399 7.67617C4.66399 7.1275 4.23899 6.6665 3.65499 6.6665ZM12.9883 6.6665C12.4277 6.6665 12.0003 7.1275 12.0003 7.67617C12.0003 8.2255 12.3597 8.64284 12.9883 8.6645C13.5717 8.6645 13.9973 8.26917 13.9973 7.67617C13.9973 7.1275 13.5723 6.6665 12.9883 6.6665ZM8.32166 6.6665C7.76099 6.6665 7.33399 7.1275 7.33399 7.67617C7.33399 8.2255 7.69299 8.64284 8.32166 8.6645C8.90499 8.6645 9.33066 8.26917 9.33066 7.67617C9.33066 7.1275 8.90566 6.6665 8.32166 6.6665Z" fill="currentColor"></path>
|
|
583
583
|
</svg>`,eP=`<svg
|
|
584
584
|
fill="currentColor"
|
|
585
585
|
width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
586
586
|
<path fill-rule="evenodd" clip-rule="evenodd" d="M8.63999 19.5893C8.82172 19.5893 8.9891 19.5427 9.14214 19.4494C9.29518 19.3561 9.48169 19.2115 9.70168 19.0154L12.0403 16.9422H16.2512C16.9255 16.9422 17.497 16.8191 17.9657 16.5728C18.4343 16.3265 18.7906 15.969 19.0345 15.5003C19.2784 15.0317 19.4004 14.4626 19.4004 13.793V8.55629C19.4004 7.88675 19.2784 7.31765 19.0345 6.84897C18.7906 6.38029 18.4343 6.02161 17.9657 5.77293C17.497 5.52424 16.9255 5.3999 16.2512 5.3999H7.5496C6.88007 5.3999 6.31096 5.52305 5.84228 5.76934C5.37361 6.01564 5.01612 6.37432 4.76983 6.84538C4.52354 7.31645 4.40039 7.88675 4.40039 8.55629V13.793C4.40039 14.4626 4.52354 15.0329 4.76983 15.5039C5.01612 15.975 5.37241 16.3325 5.8387 16.5764C6.30498 16.8203 6.86811 16.9422 7.52808 16.9422H7.82937V18.6639C7.82937 18.9461 7.89991 19.1708 8.04099 19.3382C8.18207 19.5056 8.38174 19.5893 8.63999 19.5893ZM8.94845 18.1976V16.2536C8.94845 16.0623 8.90541 15.9248 8.81933 15.8411C8.73325 15.7574 8.59695 15.7155 8.41043 15.7155H7.5783C6.91832 15.7155 6.42932 15.5505 6.11129 15.2206C5.79326 14.8906 5.63425 14.4076 5.63425 13.7715V8.57781C5.63425 7.94175 5.79326 7.45992 6.11129 7.13233C6.42932 6.80473 6.91832 6.64094 7.5783 6.64094H16.2225C16.8825 6.64094 17.3715 6.80473 17.6895 7.13233C18.0075 7.45992 18.1665 7.94175 18.1665 8.57781V13.7715C18.1665 14.4076 18.0075 14.8906 17.6895 15.2206C17.3715 15.5505 16.8825 15.7155 16.2225 15.7155H11.9757C11.7749 15.7155 11.6146 15.7383 11.4951 15.7837C11.3755 15.8291 11.2464 15.9212 11.1077 16.0599L8.94845 18.1976ZM15.584 9.23419C15.5027 9.3131 15.4047 9.35256 15.2899 9.35256H8.42478C8.31479 9.35256 8.22033 9.3131 8.14142 9.23419C8.06251 9.15528 8.02306 9.05844 8.02306 8.94366C8.02306 8.83367 8.06251 8.73802 8.14142 8.65672C8.22033 8.57542 8.31479 8.53477 8.42478 8.53477H15.2899C15.4047 8.53477 15.5027 8.57542 15.584 8.65672C15.6653 8.73802 15.706 8.83367 15.706 8.94366C15.706 9.05844 15.6653 9.15528 15.584 9.23419ZM15.2899 11.5333C15.4047 11.5333 15.5027 11.4939 15.584 11.415C15.6653 11.3361 15.706 11.2392 15.706 11.1244C15.706 11.0097 15.6653 10.9116 15.584 10.8303C15.5027 10.749 15.4047 10.7084 15.2899 10.7084H8.42478C8.31479 10.7084 8.22033 10.749 8.14142 10.8303C8.06251 10.9116 8.02306 11.0097 8.02306 11.1244C8.02306 11.2392 8.06251 11.3361 8.14142 11.415C8.22033 11.4939 8.31479 11.5333 8.42478 11.5333H15.2899ZM13.1845 13.5957C13.1056 13.6747 13.0111 13.7141 12.9011 13.7141H8.42478C8.31479 13.7141 8.22033 13.6747 8.14142 13.5957C8.06251 13.5168 8.02306 13.4224 8.02306 13.3124C8.02306 13.1928 8.06251 13.0924 8.14142 13.0111C8.22033 12.9298 8.31479 12.8891 8.42478 12.8891H12.9011C13.0111 12.8891 13.1056 12.9298 13.1845 13.0111C13.2634 13.0924 13.3028 13.1928 13.3028 13.3124C13.3028 13.4224 13.2634 13.5168 13.1845 13.5957Z"></path>
|
|
587
|
-
</svg>`,$V="";w("comment-item");const{t:bi}=
|
|
587
|
+
</svg>`,$V="";w("comment-item");const{t:bi}=T,n6="comment-item-editing",o6="active";class r6{constructor(t){h(this,"root");h(this,"moreMenu");h(this,"components");h(this,"createRoot",()=>{const t=b("div",["comment-item-root"],null);return t.id=this.comment.id,t});h(this,"handleMore",()=>{const{moreButton:t}=this.components;!t||this.moreMenu.manualShow(t,{placement:"bottom-start"})});h(this,"handleMoreMenuItemShow",()=>{const{headTools:t}=this.components;t.classList.add(o6)});h(this,"handleMoreMenuItemClose",()=>{const{headTools:t}=this.components;t.classList.remove(o6)});h(this,"handleMoreMenuItemClick",(t,e)=>{const o=this.options.groupList.groupItemHandlers,{id:r}=e;r==="edit"&&o.handleCommentItemEdit(this),r==="delete"&&o.handleCommentItemDelete(this)});h(this,"handleEditorReadonlyChange",t=>{const{components:{actions:e},root:o}=this;t.readonly?(o.classList.remove(n6),e.classList.add("hidden")):(o.classList.add(n6),e.classList.remove("hidden"))});h(this,"handleFocus",()=>{const{components:{commentEditor:t,okButton:e}}=this;t.isEmpty()?M(e,to):H(e,to)});h(this,"handleDocChanged",()=>{const{commentEditor:t,okButton:e}=this.components;t.isEmpty()?M(e,to):H(e,to)});h(this,"getCommentEditor",()=>this.components.commentEditor);h(this,"handleReadonlyChanged",t=>{t.readonly?M(this.root,"readonly"):H(this.root,"readonly")});this.options=t,this.root=this.createRoot(),this.components=this.createItem(),this.moreMenu=this.createMoreMenu(),t.mainEditor.on("readonlyChanged",this.handleReadonlyChanged)}get commentOptions(){return this.options.mainEditor.getComponentOptions("comment")}get comment(){return this.options.comment}get doc(){const{comment:t,commentsProvider:e}=this.options;return e.getCommentDoc(t.id)}createMoreMenu(){const t=new cr([{id:"edit",name:bi("comment.edit")},{id:"delete",name:bi("comment.delete")}]);return t.on("click",this.handleMoreMenuItemClick),t.on("close",this.handleMoreMenuItemClose),t.on("show",this.handleMoreMenuItemShow),t}createItem(){var $,q;const{comment:t,commentsProvider:e,mainEditor:o,groupItem:r}=this.options,i=!(($=this.commentOptions)!=null&&$.disableReply)&&!o.readonly,l=!((q=this.commentOptions)!=null&&q.disableEdit)&&!o.readonly&&i,c=b("div",["item-head"],this.root),a=b("img",["item-head-avatar"],c);a.src=t.avatarUrl;const d=b("span",["item-head-username"],c);d.innerText=t.displayName;const f=b("span",["item-head-modified"],c),m=new Date(t.modified);f.innerText=Du(m);const p=b("div",["item-head-tools"],c);let A=null;i&&(A=mr(p,mt.CommentItemReply,bi("comment.reply"),eP,void 0,o.clientId),eo(A,mt.CommentItemReply));let k=null;l&&(k=mr(p,mt.CommentItemMore,bi("comment.more"),tP,void 0,o.clientId),eo(k,mt.CommentItemMore),k.onclick=this.handleMore);const v=b("div",["item-editor"],this.root),x=new Ef(o,e,this.doc);x.editor.addListener("readonlyChanged",this.handleEditorReadonlyChange),x.editor.addListener("docChanged",this.handleDocChanged),x.editor.addListener("focus",this.handleFocus),x.editor.input.addHandler(new XN(e,r,this)),v.append(x.root);const E=b("div",["item-actions","hidden"],this.root),L=Bo(mt.CommentItemCancel,bi("common.cancel"));eo(L,mt.CommentItemCancel);const R=Bo(mt.CommentItemOk,bi("comment.send"));return eo(R,mt.CommentItemOk),E.append(L,R),{head:c,replyButton:A,moreButton:k,commentEditor:x,okButton:R,cancelButton:L,actions:E,headTools:p}}reloadDoc(){const{components:{commentEditor:t}}=this;t.setDoc(this.doc)}edit(){const{components:{commentEditor:t}}=this;t.edit()}destroy(){const{replyButton:t,moreButton:e,commentEditor:o,okButton:r,cancelButton:i}=this.components;e&&(e.onclick=null),t&&(t.onclick=null),r.onclick=null,i.onclick=null,o.destroy(),this.moreMenu.removeAllListeners(),this.moreMenu.destroy(),this.root.remove(),this.options.mainEditor.removeListener("readonlyChanged",this.handleReadonlyChanged)}}const _V="";class i6{constructor(t,e,o){h(this,"root");h(this,"components");h(this,"reloadDoc",()=>{const{mobileCommentEditor:t}=this.components;t.setDoc(this.doc)});this.editor=t,this.commentsProvider=e,this.comment=o,this.root=b("div",["mobile-comment-item"],null),this.components=this.createItem()}get doc(){const{comment:t,commentsProvider:e}=this;return e.getCommentDoc(t.id)}createItem(){const{comment:t,editor:e,commentsProvider:o}=this,r=b("div",["item-head"],this.root),i=b("img",["item-head-avatar"],r);i.src=t.avatarUrl;const s=b("span",["item-head-username"],r);s.innerText=t.displayName;const l=b("span",["item-head-modified"],r),c=new Date(t.modified);l.innerText=Du(c);const a=b("div",["item-editor"],this.root),d=new Ef(e,o,this.doc);return a.append(d.root),{mobileCommentEditor:d}}destroy(){this.root.remove(),this.components.mobileCommentEditor.destroy()}}const FV="";class nP{constructor(t,e){h(this,"root");h(this,"countElement");h(this,"updateCount",t=>{this.countElement.textContent=`${t}`});this.root=b("div",["mini-comment-item"],e),this.root.id=t,this.countElement=b("span",["mini-comment-item-count"],this.root)}}class al extends Yt.TypedEmitter{constructor(e,o,r,i,s){super();h(this,"_items");this.editor=e,this.commentsProvider=o,this.container=r,this.options=s,this._items=this.createList(i)}get items(){return this._items}createList(e){return e.map(r=>{const i=this.createItem(r,"init");return this.container.appendChild(i.root),i})}reloadList(e){this.container.innerHTML="",this.createList(e)}insertItem(e){const o=this.findInsertPos(e);if(o===-1)return null;const r=this.createItem(e,"insert");if(o===this.items.length)this.container.appendChild(r.root);else{const i=this.items[o];this.container.insertBefore(r.root,i.root)}return this.items.splice(o,0,r),r}deleteItem(e){const o=this.findItemIndex(e);if(o!==-1){const r=this.items[o];return this.items.splice(o,1),r.destroy(),!0}return!1}findItemIndex(e){return this.items.findIndex(o=>o.comment.id===e)}findItem(e){const o=this.findItemIndex(e);return o===-1?null:this.items[o]}destroy(){this._items.forEach(e=>e.destroy()),this._items=[]}}class oP extends al{constructor(t){const{editor:e,comments:o,commentsProvider:r,parent:i}=t;super(e,r,i,o,t)}createItem(t){const{editor:e,commentsProvider:o,groupList:r,groupItem:i}=this.options;return new r6({mainEditor:e,commentsProvider:o,comment:t,groupList:r,groupItem:i})}findInsertPos(){return this.items.length}destroy(){this.items.forEach(t=>{t.destroy()})}}const rP=`<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
588
588
|
<path d="M2.00218 11.0005L8.00341 4.99923L14.0046 11.0005" stroke="currentColor" fill="transparent" stroke-width="1.5" stroke-linejoin="bevel"/>
|
|
589
589
|
</svg>`,iP=`<svg width="17" height="16" viewBox="0 0 17 16" xmlns="http://www.w3.org/2000/svg">
|
|
590
590
|
<path d="M14.0029 4.99933L8.00172 11.0006L2.00049 4.99933" stroke="currentColor" fill="transparent" stroke-width="1.5" stroke-linejoin="bevel"/>
|
|
591
|
-
</svg>`,HV="",xa="reply-editor-editing",{t:If}=x;class sP{constructor(t,e,o,r){h(this,"root");h(this,"components");h(this,"handleFocus",()=>{const{replyEditor:t,okButton:e}=this.components;t.isEmpty()&&M(e,to)});h(this,"handleDocChange",()=>{const{replyEditor:t,okButton:e}=this.components,o=t.getDoc();tc(o)?M(e,to):H(e,to)});h(this,"getReplyEditor",()=>this.components.replyEditor);h(this,"showReplyEditor",()=>{rt(this.root,xa)||(M(this.root,xa),this.components.replyEditor.edit())});h(this,"hideReplyEditor",()=>{!rt(this.root,xa)||H(this.root,xa)});h(this,"reply",()=>{const{mainEditor:t,comment:e,components:{replyEditor:o},commentsProvider:r}=this,i=o.getDoc(),s=Ia({editor:t,commentGroupId:e.groupId});r.localCreateComment(s,i),this.hideReplyEditor(),o.clear()});h(this,"cancel",()=>{const{replyEditor:t}=this.components;this.hideReplyEditor(),t.clear()});h(this,"hide",()=>{rt(this.root,"hidden")||M(this.root,"hidden")});h(this,"show",()=>{H(this.root,"hidden")});this.mainEditor=t,this.commentsProvider=e,this.comment=o,this.groupItem=r,this.root=b("div",["comment-quick-reply"],null),this.components=this.createQuickReply()}createQuickReply(){const{commentsProvider:t}=this,e=mr(this.root,mt.QuickReply,If("comment.placeholder"));eo(e,mt.QuickReply),e.classList.add("quick-reply-button");const o=b("div",["quick-reply-editor"],this.root),r=or(),i=new Ef(this.mainEditor,t,r);i.editor.addListener("docChanged",this.handleDocChange),i.editor.addListener("focus",this.handleFocus),i.editor.input.addHandler(new KN(this.groupItem)),o.append(i.root);const s=b("div",["reply-editor-actions"],o),l=Bo(mt.QuickReplyCancel,If("common.cancel"));eo(l,mt.QuickReplyCancel);const c=Bo(mt.QuickReplyOk,If("comment.send"));return eo(c,mt.QuickReplyOk),M(c,to),s.append(l,c),this.hideReplyEditor(),{replyTextButton:e,replyEditor:i,replyEditorContainer:o,okButton:c}}}const no=w("comment-group-item");class lP extends Yt.TypedEmitter{constructor(e,o,r,i){super();h(this,"root");h(this,"header");h(this,"mainItem");h(this,"childrenList");h(this,"resizeObserver");h(this,"quickReply");h(this,"createRoot",()=>b("div",["comment-group-item-root"],null));h(this,"createChildrenList",()=>{const e=b("div",["comment-children-list-container"],this.root);return new oP({editor:this.editor,commentsProvider:this.commentsProvider,comments:this.comment.children,parent:e,groupList:this.groupList,groupItem:this})});h(this,"updateLastCommentItem",()=>{const e=Array.from(this.root.querySelectorAll(":scope .comment-item-root"));u(no,e.length!==0,"current group item not exist comment-item"),e.forEach(r=>{H(r,W3)});const o=e.at(-1);M(o,W3)});h(this,"updateSwitchButton",()=>{const e=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-up"]'),o=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-down"]');u(no,e,"switchUpButton not exist"),u(no,o,"switchDownButton not exist"),H(o,"disabled"),H(e,"disabled"),this.root.previousElementSibling===null&&M(e,"disabled"),this.root.nextElementSibling===null&&M(o,"disabled")});h(this,"handleReadonlyChanged",e=>{e.readonly?M(this.root,"readonly"):H(this.root,"readonly")});h(this,"handleResize",()=>{this.emit("resize")});this.editor=e,this.commentsProvider=o,this.comment=r,this.groupList=i,this.root=this.createRoot(),this.header=this.createHeader(),this.mainItem=this.createItem(),this.childrenList=this.createChildrenList(),this.quickReply=this.createQuickReply(),this.editor.on("readonlyChanged",this.handleReadonlyChanged),this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.root),this.updateLastCommentItem()}get commentCount(){return Z3(this.root)}createQuickReply(){const{editor:e,commentsProvider:o,comment:r}=this,i=new sP(e,o,r,this);return this.root.append(i.root),i}createHeader(){const{comment:e}=this,o=b("div",["comment-item-head"],this.root),r=b("span",["item-head-quote"],o);r.innerText=e.abstract;const i=b("span",["item-head-switch"],o),s=mr(i,mt.SwitchUp,"up",rP),l=mr(i,mt.SwitchDown,"down",iP);return eo(s,mt.SwitchUp),eo(l,mt.SwitchDown),o}createItem(){const e=b("div",["comment-item-container"],this.root),{editor:o,commentsProvider:r,comment:i,groupList:s}=this,l=new r6({mainEditor:o,commentsProvider:r,comment:i,groupList:s,groupItem:this});return e.appendChild(l.root),l}findCommentItem(e){return e?e===this.mainItem.comment.id?this.mainItem:this.childrenList.items.find(o=>o.comment.id===e):null}handleCreateComment(e){return u(no,Cr(e),"invalid comment, not a child comment"),u(no,e.groupId===this.comment.id,"invalid comment, not a child comment"),this.childrenList.createItem(e)}handleUpdateChildComment(e){u(no,e.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(e.id);if(!o){no.error(`can't find child comment item: ${e.id}`);return}o.reloadDoc()}handleUpdateMainComment(e){u(no,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){u(no,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}edit(){this.mainItem.edit()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.root.remove(),this.resizeObserver.disconnect(),this.removeAllListeners(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}}const cP=w("arrange=items"),s6=20;function l6(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}`);if(!e)return-1;const o=n.scrollContainer.getBoundingClientRect(),r=n.scrollContainer.scrollTop;return e.getBoundingClientRect().top-o.top+r}function c6(n,t){return Number.parseInt(t.root.style.top,10)}function a6(n,t,e,o){let r=0;e&&(r=t.indexOf(e),r===-1&&(r=0));for(let i=r;i<t.length;i++){const s=t[i],l=s.comment,c=l6(n,l.groupId);if(s.root.setAttribute("data-target-top",c.toString()),i===r){if(o!==void 0){const f=t[0];f.root.style.top=`${o}px`}else s.root.style.top=`${c}px`;continue}const a=t[i-1],d=c6(n,a)+a.root.getBoundingClientRect().height;d>c?s.root.style.top=`${d+s6}px`:s.root.style.top=`${c}px`}for(let i=r-1;i>=0;i--){const s=t[i],l=s.comment,c=l6(n,l.groupId);s.root.setAttribute("data-target-top",c.toString());const a=s.root.getBoundingClientRect(),d=c+a.height,f=t[i+1];u(cP,f,"no next item");const m=c6(n,f);m<d?s.root.style.top=`${m-a.height-s6}px`:s.root.style.top=`${c}px`}}const Ta=w("comment-group-item-handler");class aP{constructor(t,e){h(this,"handleSwitchUp",t=>{const e=Math.max(0,t-1);this.groupList.setActiveItem(e),this.groupList.updateItemsLayout()});h(this,"handleSwitchDown",t=>{const e=Math.min(t+1,this.groupList.items.length);this.groupList.setActiveItem(e),this.groupList.updateItemsLayout()});h(this,"handleQuickReply",t=>{const{quickReply:e}=t;e.showReplyEditor()});h(this,"handleQuickReplyOk",t=>{const{quickReply:e}=t;e.reply(),t.updateLastCommentItem()});h(this,"handleQuickReplyCancel",t=>{const{quickReply:e}=t;e.cancel()});h(this,"handleCommentItemReply",(t,e)=>{const o=t.findCommentItem(e);u(Ta,o,`the commentItem: ${e} not exist `);const{quickReply:r}=t;r.show(),r.showReplyEditor();const{comment:i}=o,s=r.getReplyEditor(),l=s.editor.getFocusedBlock(),c={type:"mention",id:P(),box:!0,created:Date.now(),text:i.displayName,iconUrl:i.avatarUrl,mentionId:i.userId};s.editor.insertBoxToBlock(l,0,c)});h(this,"handleCommentItemMore",t=>{const{quickReply:e}=t;e.hideReplyEditor(),e.getReplyEditor().clear()});h(this,"handleCommentItemOk",(t,e)=>{const o=t.findCommentItem(e);u(Ta,o,`the commentItem: ${e} not exist `);const{quickReply:r}=t,{comment:i,getCommentEditor:s}=o,l=s(),c=l.getDoc();this.commentsProvider.localUpdateComment(i,c),l.readonly(),r.show()});h(this,"handleCommentItemCancel",(t,e)=>{const o=t.findCommentItem(e);u(Ta,o,`the commentItem: ${e} not exist `);const r=this.commentsProvider.getComment(o.comment.id);if(tc(r.doc)){this.commentsProvider.localDeleteComment(o.comment.id);return}const{quickReply:i}=t,s=o.getCommentEditor();s.setDoc(o.doc),s.readonly(),i.show()});h(this,"handleCommentItemEdit",t=>{const e=this.groupList.findItem(t.comment.groupId);if(!e)return;const{quickReply:o}=e;t.getCommentEditor().edit(),o.hide()});h(this,"handleCommentItemDelete",t=>{const e=this.groupList.findItem(t.comment.groupId);if(!e)return;const{quickReply:o}=e,{comment:r}=t;this.commentsProvider.localDeleteComment(r.id),o.show()});h(this,"execute",(t,e,o,r)=>{const i=VN(t);if(!i||WN(i))return;const s=qN(i);switch(s){case mt.SwitchUp:this.handleSwitchUp(r);break;case mt.SwitchDown:this.handleSwitchDown(r);break;case mt.CommentItemReply:this.handleCommentItemReply(e,o);break;case mt.CommentItemMore:this.handleCommentItemMore(e);break;case mt.CommentItemOk:this.handleCommentItemOk(e,o);break;case mt.CommentItemCancel:this.handleCommentItemCancel(e,o);break;case mt.CommentItemDelete:break;case mt.CommentItemEdit:break;case mt.QuickReply:this.handleQuickReply(e);break;case mt.QuickReplyOk:this.handleQuickReplyOk(e);break;case mt.QuickReplyCancel:this.handleQuickReplyCancel(e);break;default:const l=s;Ta.debug(`not implement handler for ${l}`)}});this.groupList=t,this.commentsProvider=e}destroy(){}}const Sa=w("comment-group-list");class uP extends al{constructor(e,o,r){super(e,o,r,No(e,o),{});h(this,"groupItemHandlers");h(this,"findGroupItem",e=>this.items.find(o=>o.comment.groupId===e));h(this,"handleContainerClick",e=>{if(!e.target||!(e.target instanceof Element))return;const o=e.target.closest(".comment-group-item-root");if(!o)return;const r=UN(e.target),i=this.items.findIndex(s=>s.root===o);if(i!==-1){this.setActiveItem(i);const{groupItemHandlers:s}=this;s.execute(e.target,this.items.at(i),r,i)}});h(this,"handleSelectionChanged",()=>{const e=X3(this.editor);if(e.length>0){const o=e[0],r=this.items.findIndex(i=>i.comment.groupId===o);this.setActiveItem(r),this.emit("selectionOnComment")}else this.setActiveItem(-1)});h(this,"handleEditorResize",()=>{this.updateItemsLayout()});h(this,"handleDocChanged",()=>{this.updateComments()});h(this,"handleItemResize",()=>{this.updateItemsLayout()});h(this,"handleScroll",e=>{if(e.deltaY>=0||this.editor.scrollContainer.scrollTop!==0)return;const o=document.elementFromPoint(e.clientX,e.clientY);if(!o||!(o instanceof HTMLElement)||!this.editor.scrollContainer.contains(o))return;const r=this.container.querySelector(".comment-group-item-root");if(!r)return;const i=Number.parseFloat(r.style.top),s=Number.parseFloat(r.getAttribute("data-target-top")||"0");!Number.isNaN(i)&&!Number.isNaN(s)&&i<s&&a6(this.editor,this.items,null,Math.min(i+(0-e.deltaY)*3,s))});h(this,"updateGroupItemSwitch",()=>{const e=this.activeItem;u(Sa,e,"invalid activeItem"),e.updateSwitchButton()});h(this,"updateComments",ee.default(()=>{const e=No(this.editor,this.commentsProvider);let o=!1;for(let r=0;r<e.length;r++){const i=e[r];if(!this.findGroupItem(i.groupId)){this.handleCreateComment(i,!1),o=!0;continue}}for(let r=this.items.length-1;r>=0;r--){const i=this.items[r];e.findIndex(s=>s.groupId===i.comment.groupId)===-1&&(this.deleteItem(i.comment.id),o=!0)}o&&(this.updateItemsLayout(),this.emit("commentCountChanged"))},100));this.updateItemsLayout(),this.bindEvents(),this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("resize",this.handleEditorResize),this.editor.addListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.addEventListener("wheel",this.handleScroll,{passive:!1}),this.items.forEach(i=>i.addListener("resize",this.handleItemResize)),this.groupItemHandlers=new aP(this,o)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("resize",this.handleEditorResize),this.editor.removeListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.removeEventListener("wheel",this.handleScroll),super.destroy(),this.unbindEvents(),this.removeAllListeners()}updateItemsLayout(){a6(this.editor,this.items,this.activeItem)}bindEvents(){this.container.addEventListener("click",this.handleContainerClick)}unbindEvents(){this.container.removeEventListener("click",this.handleContainerClick)}createItem(e,o){const r=new lP(this.editor,this.commentsProvider,e,this);return o==="insert"&&(M(r.root,"no-animation"),r.root.style.opacity="0",setTimeout(()=>{H(r.root,"no-animation"),r.root.style.opacity="1"},150)),r}findInsertPos(e){const r=No(this.editor,this.commentsProvider).findIndex(i=>i.id===e.id);return r===-1||r>this.items.length?-1:r}insertItem(e,o){const r=super.insertItem(e);return r?(o!=null&&o.active&&this.setActiveItem(this.items.indexOf(r)),this.updateItemsLayout(),r.addListener("resize",this.handleItemResize),r):null}setActiveItem(e){if(u(Sa,e>=-1&&e<this.items.length,`invalid index: ${e}`),e===this.activeIndex)return;const o=this.container.querySelector(".comment-group-item-root.active");if(o&&H(o,"active"),e!==-1){const r=this.items[e];M(r.root,"active"),this.updateItemsLayout(),this.updateGroupItemSwitch()}this.emit("activeItemChanged",e)}get activeIndex(){const e=this.container.querySelector(".comment-group-item-root.active");return e?this.items.findIndex(o=>o.root===e):-1}get activeItem(){const e=this.activeIndex;return e===-1?null:this.items[e]}handleCreateComment(e,o){if(Cr(e)){const l=this.findGroupItem(e.groupId);l&&l.childrenList.insertItem(e)}const r=this.findItem(e.id);u(Sa,!r,"comment group item has already exists");const i={children:[],...e};u(Sa,i.children,"not a comment group");const s=this.insertItem(i,{active:o});!s||o&&setTimeout(()=>{const l=this.items.indexOf(s);this.setActiveItem(l),s.edit(),s.quickReply.hide()})}handleDeleteComment(e){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===e){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(e);return}if(r.childrenList.deleteItem(e)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(e){if(Cr(e)){const r=this.commentsProvider.getComment(e.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(e);return}const o=this.findItem(e.id);o&&o.handleUpdateMainComment(e)}}const dP="comment-mini";w("comment-list");class hP extends Yt.TypedEmitter{constructor(e,o){super();h(this,"root");h(this,"groupsContainer");h(this,"list");h(this,"handleSelectionOnComment",()=>{this.emit("onSelectComment")});h(this,"updateCommentCount",()=>{var o,r;const e=QN(this.editor,this.commentsProvider);(r=(o=this.commentOptions)==null?void 0:o.onCommentCountChange)==null||r.call(o,e)});h(this,"handleActiveItemChanged",()=>{var o;const e=this.list.activeItem;e6(this.editor,(o=e==null?void 0:e.comment.id)!=null?o:"")});h(this,"handleItemLayoutUpdated",()=>{var o,r;const e=rt(this.root,dP);(r=(o=this.commentOptions)==null?void 0:o.onUpdateLayout)==null||r.call(o,this.editor,{expand:e})});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-web-comment-root"],null),this.groupsContainer=b("div",["comment-groups-container"],this.root),this.list=this.createList(),this.commentsProvider.addListener(this),this.list.addListener("activeItemChanged",this.handleActiveItemChanged),this.list.addListener("itemLayoutUpdated",this.handleItemLayoutUpdated),this.list.addListener("selectionOnComment",this.handleSelectionOnComment),this.list.addListener("commentCountChanged",this.updateCommentCount),this.updateCommentCount()}get commentOptions(){return this.editor.getComponentOptions("comment")}destroy(){this.list.removeAllListeners(),this.commentsProvider.removeListener(this),this.list.destroy(),this.root.remove()}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o),this.updateCommentCount()}onDeleteComment(e,o){this.list.handleDeleteComment(e),this.updateCommentCount()}onUpdateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleUpdateComment(r)}createList(){return new uP(this.editor,this.commentsProvider,this.groupsContainer)}show(e){var o;if(H(this.root,"hidden"),e){const r=this.list.findItemIndex(e);this.list.setActiveItem(r)}(o=this.commentOptions)==null||o.controller.showCommentList()}hide(){M(this.root,"hidden")}}class fP extends al{constructor({editor:t,parent:e,commentsProvider:o,comments:r}){super(t,o,e,r,{})}findInsertPos(){return this.items.length}createItem(t){const{editor:e,commentsProvider:o}=this;return new i6(e,o,t)}destroy(){this.items.forEach(t=>{t.destroy()})}}const Da=w("mobile-comment-group-item"),mP=20;class gP extends Yt.TypedEmitter{constructor(e,o,r){super();h(this,"root");h(this,"childrenList");h(this,"mainItem");h(this,"scroller");h(this,"createRoot",()=>b("div",["mobile-group-item-root"],null));h(this,"createMainItem",e=>{const{editor:o,commentsProvider:r,comment:i}=this,s=new i6(o,r,i);return e.append(s.root),s});h(this,"createChildrenList",e=>{const{editor:o,commentsProvider:r,comment:i}=this,s=b("div",["mobile-comment-children-list-container"],e);return new fP({editor:o,commentsProvider:r,comments:i.children,parent:s})});h(this,"handleTouchEnd",()=>{var i;const{scroller:e}=this,{pullThreshold:o=mP}=(i=this.editor.getComponentOptions("comment"))!=null?i:{};let r=null;if(e.y>e.minScrollY+o?(r=this.root.previousElementSibling,r||this.emit("onReachTop")):e.y<e.maxScrollY-o&&(r=this.root.nextElementSibling,r||this.emit("onReachBottom")),r){const s=r.id;this.emit("onSwitchGroup",s,G3)}});h(this,"refreshScroller",()=>{this.scroller.refresh()});this.editor=e,this.commentsProvider=o,this.comment=r,this.root=b("div",["mobile-group-item-root"],null),this.root.id=r.groupId;const i=b("div",["mobile-group-item"],this.root),s=b("div",["mobile-group-item-space"],null),l=b("div",["mobile-group-item-abstract"],null);l.textContent=r.abstract;const c=b("div",["mobile-group-item-list-container"],null);this.mainItem=this.createMainItem(c),this.childrenList=this.createChildrenList(c),i.append(s,l,c),this.scroller=new pm.default(this.root,{stopPropagation:!0,click:!0}),this.scroller.on("touchEnd",this.handleTouchEnd)}get commentCount(){return Z3(this.root,".mobile-group-item")}handleUpdateChildComment(e){u(Da,e.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(e.id);if(!o){Da.error(`can't find child comment item: ${e.id}`);return}o.reloadDoc()}handleUpdateMainComment(e){u(Da,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){u(Da,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.scroller.off("touchEnd",this.handleTouchEnd),this.scroller.destroy(),this.root.remove(),this.removeAllListeners()}}const xf=w("mobile-group-list");class pP extends al{constructor(e,o,r,i){super(e,o,r,No(e,o),{});h(this,"scroller");h(this,"deleteItem",e=>{if(this.items.length<=1)return super.deleteItem(e);const o=this.findItemIndex(e);let r=null;return o===0?r=this.items[o+1].root.id:r=this.items[o-1].root.id,super.deleteItem(e)?(this.scrollToGroup(r,G3),!0):!1});h(this,"setupGroupItem",e=>{e.on("onSwitchGroup",this.scrollToGroup),e.on("onReachBottom",this.handleReachBottom),e.on("onReachTop",this.handleReachTop),e.refreshScroller()});h(this,"handleReachBottom",()=>{this.emit("onReachBottom")});h(this,"handleReachTop",()=>{this.emit("onReachTop")});h(this,"scrollToGroup",(e,o=0)=>{const r=this.findGroupItem(e);u(xf,r,"invalid scroll target"),this.scroller.scrollToElement(r.root,o,!1,!1),e6(this.editor,r.comment.id)});h(this,"findGroupItem",e=>this.items.find(o=>o.comment.groupId===e));h(this,"handleDocChanged",()=>{this.updateComments()});h(this,"updateComments",ee.default(()=>{const e=No(this.editor,this.commentsProvider);for(let o=0;o<e.length;o++){const r=e[o];if(!this.findGroupItem(r.groupId)){this.handleCreateComment(r,!1);continue}}for(let o=this.items.length-1;o>=0;o--){const r=this.items[o];e.findIndex(i=>i.groupId===r.comment.groupId)===-1&&this.deleteItem(r.comment.id)}},100));this.scroller=new pm.default(i),this.scroller.disable(),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(this.setupGroupItem)}createItem(e){return new gP(this.editor,this.commentsProvider,e)}insertItem(e){const o=super.insertItem(e);return o?(this.setupGroupItem(o),o):null}findInsertPos(e){const r=No(this.editor,this.commentsProvider).findIndex(i=>i.id===e.id);return r===-1||r>this.items.length?-1:r}setActiveItem(e){this.scrollToGroup(e)}handleCreateComment(e,o){if(Cr(e)){const s=this.findGroupItem(e.groupId);s&&s.childrenList.insertItem(e)}const r=this.findItem(e.id);u(xf,!r,"comment group item has already exists");const i={children:[],...e};u(xf,i.children,"not a comment group"),this.insertItem(i),this.scroller.refresh()}handleDeleteComment(e){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===e){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(e);return}if(r.childrenList.deleteItem(e)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(e){if(Cr(e)){const r=this.commentsProvider.getComment(e.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(e);return}const o=this.findItem(e.id);o&&o.handleUpdateMainComment(e)}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),this.scroller.destroy(),this.items.forEach(e=>e.destroy())}}const CP=w("mobile-comment-list"),{t:u6}=x;class AP extends Yt.TypedEmitter{constructor(e,o){super();h(this,"root");h(this,"list");h(this,"mask");h(this,"pullInfoContainer");h(this,"handleRootClick",e=>{const o=e.target;u(CP,o instanceof Element,"invalid target"),!(o.closest(".mobile-group-item-abstract")||o.closest(".mobile-group-item-list-container"))&&(this.hide(),this.emit("onCommentListClose"))});h(this,"hidePullInfo",ee.default(()=>{H(this.pullInfoContainer,"active")},1e3*3));h(this,"handleReachBottom",()=>{this.showPullInfo("bottom")});h(this,"handleReachTop",()=>{this.showPullInfo("top")});h(this,"show",e=>{H(this.root,"hidden"),M(document.documentElement,"disabled-scroll"),e&&this.list.setActiveItem(e)});h(this,"hide",()=>{M(this.root,"hidden"),H(document.documentElement,"disabled-scroll")});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-mobile-comments-root"],null),this.mask=b("div",["mobile-comment-mask"],this.root);const r=b("div",["mobile-comment-groups-container"],this.root),i=b("div",["mobile-comment-groups-scroll-container"],r);this.list=new pP(this.editor,this.commentsProvider,i,r),this.pullInfoContainer=this.createPullInfo(),this.commentsProvider.addListener(this),this.list.on("onReachBottom",this.handleReachBottom),this.list.on("onReachTop",this.handleReachTop),this.root.onclick=this.handleRootClick}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o)}onDeleteComment(e,o){this.list.handleDeleteComment(e)}onUpdateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleUpdateComment(r)}createPullInfo(){const e=b("div",["mobile-comment-pull-info-container"],this.root);return b("div",["mobile-comment-pull-info"],e),e}showPullInfo(e){const o=u6(e==="bottom"?"comment.isLast":"comment.isFirst");this.pullInfoContainer.firstElementChild.textContent=o,M(this.pullInfoContainer,"active"),this.hidePullInfo()}destroy(){this.list.removeAllListeners(),this.list.destroy(),this.root.onclick=null}}function d6(n,t){const e=No(n,t),o=new Map;for(const r of e){const i=Q3(n,r.groupId);if(!!i)if(o.has(i)){const s=o.get(i);kf(r).forEach(c=>{s==null||s.commentIds.add(c.id)})}else{const s=kf(r),l=new Set(s.map(c=>c.id));o.set(i,{commentIds:l,firstComment:r})}}return Array.from(o.entries()).map(([r,i])=>({blockId:r,...i}))}const bP=w("mini-group-item");class vP{constructor(t,e){h(this,"root");h(this,"blockId");h(this,"comment");h(this,"miniCommentItem");h(this,"updateCommentItemCount",()=>{this.miniCommentItem.updateCount(this.commentCount)});this.editor=t,this.commentGroup=e,this.root=b("div",["mini-group-item"],null),this.comment=e.firstComment,this.miniCommentItem=new nP(this.comment.id,this.root),this.blockId=this.getBlockId(),this.alignToBlock(),this.updateCommentItemCount()}getBlockId(){return Q3(this.editor,this.comment.groupId)}get commentCount(){return this.commentGroup.commentIds.size}alignToBlock(){const t=this.getBlockId(),e=this.editor.getBlockById(t);u(bP,e,`The blockId: ${t} not exist in doc`);const o=this.editor.scrollContainer.getBoundingClientRect(),i=e.getBoundingClientRect().top-o.top;requestAnimationFrame(()=>{this.root.style.transform=`translateY(${i}px)`})}destroy(){this.root.remove()}}class yP extends al{constructor(e,o,r){super(e,o,r,d6(e,o),{});h(this,"handleDocChanged",ee.default(()=>{this.updateMiniCommentsGroup()},100));h(this,"updateMiniCommentsGroup",()=>{const e=d6(this.editor,this.commentsProvider);this.reloadList(e)});this.editor=e,this.commentsProvider=o,this.editor.addListener("docChanged",this.handleDocChanged)}createItem(e){return new vP(this.editor,e)}findInsertPos(){return-1}handleCreateComment(e,o){this.updateMiniCommentsGroup()}handleDeleteComment(e){this.updateMiniCommentsGroup()}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.removeAllListeners()}}const kP=w("mini-comments-list");class wP extends Yt.TypedEmitter{constructor(e,o){super();h(this,"list");h(this,"root");h(this,"createList",()=>{const e=b("div",["comment-groups-container"],this.root);return this.editor.domEvents.addEventListener(e,"click",this.handleListContainerClick),new yP(this.editor,this.commentsProvider,e)});h(this,"handleListContainerClick",(e,o)=>{const r=o.target;u(kP,r instanceof HTMLElement,"The target is not a valid html element");const i=r.closest(".mini-comment-item");i&&this.emit("onItemClick",i.id)});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-mini-comment-root"],null),this.list=this.createList(),this.commentsProvider.addListener(this)}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o)}onDeleteComment(e,o){this.list.handleDeleteComment(e)}onUpdateComment(e,o){}show(){H(this.root,"hidden")}hide(){M(this.root,"hidden")}destroy(){this.list.destroy(),this.removeAllListeners()}}function h6(n,t,e){if(!t.start.isSimple()||!t.end.isSimple())return;const o=t.block,r=Ot(n,o,t.start.offset,t.end.offset),i=`comment-${e.id.toLocaleLowerCase()}`,s=e.id;l0(n,o,r,i,s)}function BP(n,t,e){const o=en(n).map(s=>s.block),r=bf(n,o),i=Ia({editor:n,abstract:r});return n.undoManager.runInGroup(()=>{en(n,{simpleBlockOnly:!0}).forEach(c=>{!_(n,c.block)||h6(n,c,i)});const l=or();e.localCreateComment(i,l)}),i}class EP{constructor(t,e){h(this,"id","CommentsCommandProvider");this.provider=t,this.editorComments=e}getAvailableCommands(t,e,o){const r=t.selection.range;if(_(t,e)&&!o.isCollapsed()&&r.isSimple()){const i=j(e),s=it(e),l=Je(t,e);return[{id:"add-comment",name:"Add comment",blockId:i,blockType:s,blockKind:l,groupIndex:1e3,icon:Ts}]}return[]}executeRangeCommand(t,e,o,r,i){if(o.id==="add-comment"){this.editorComments.showCommentList();const s=BP(t,e,this.provider);return i["add-comment"]=s,!0}return!1}}class f6{constructor(t,e){h(this,"commentList",null);h(this,"mobileCommentList",null);h(this,"miniCommentList");h(this,"showComment",(t,e)=>{var o,r;t==="mini"&&this.miniCommentList.show(),t==="mobile"&&((o=this.mobileCommentList)==null||o.show(e)),t==="web"&&((r=this.commentList)==null||r.show(e))});h(this,"showCommentList",t=>{this.isMobile?this.showComment("mobile",t):this.showComment("web",t)});h(this,"handleCommentListClose",()=>{this.showComment("mini")});h(this,"handleOnSelectComment",()=>{this.showComment("web")});h(this,"handleMiniCommentItemClick",t=>{this.showCommentList(t)});this.editor=t,this.provider=e,t.editorCommandProviders.registerCommandProvider(new EP(e,this)),t.blockHooks.push(new zN(this.provider,this)),this.isMobile?(this.mobileCommentList=new AP(this.editor,this.provider),this.mobileCommentList.on("onCommentListClose",this.handleCommentListClose)):(this.commentList=new hP(this.editor,this.provider),this.commentList.on("onSelectComment",this.handleOnSelectComment)),this.miniCommentList=new wP(this.editor,this.provider),this.miniCommentList.on("onItemClick",this.handleMiniCommentItemClick)}get commentOptions(){return this.editor.getComponentOptions("comment")}get commentProvider(){return this.provider}get isMobile(){return xt.isMobile}destroy(){var t,e;(t=this.commentList)==null||t.destroy(),(e=this.mobileCommentList)==null||e.destroy(),this.miniCommentList.destroy()}mount(t){var e;t.container&&this.commentList&&t.container.append((e=this.commentList)==null?void 0:e.root),t.miniContainer&&t.miniContainer.append(this.miniCommentList.root),t.mobileContainer&&this.mobileCommentList&&t.mobileContainer.append(this.mobileCommentList.root)}}const jV="",IP={comment:{count:"\u6279\u6CE8 ({num})",hide:"\u9690\u85CF\u6279\u6CE8",show:"\u663E\u793A\u6279\u6CE8",reply:"\u56DE\u590D",quicklyReply:"\u56DE\u590D...",send:"\u786E\u8BA4",placeholder:"\u6DFB\u52A0\u6279\u6CE8...",replyPlaceholder:"\u56DE\u590D\u6216@\u4ED6\u4EBA",edit:"\u7F16\u8F91",delete:"\u5220\u9664",image:"\u56FE\u7247",sendTitle:"\u6309Enter\u53D1\u9001\u6279\u6CE8",replyTitle:"\u6309Enter\u56DE\u590D\u6279\u6CE8",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",comment:"\u6279\u6CE8"}},xP={comment:{count:"Comments ({num})",hide:"Hide Comments",show:"Show Comments",reply:"Reply",quicklyReply:"Reply...",send:"OK",placeholder:"Add a comment...",replyPlaceholder:"Add Comments or @ others",edit:"Edit",delete:"Delete",image:"Image",sendTitle:"Press Enter to send comment",replyTitle:"Press Enter to reply comment",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",more:"more",comment:"Comment"}},TP={comment:{count:"\u30B3\u30E1\u30F3\u30C8 ({num})",hide:"\u30B3\u30E1\u30F3\u30C8\u3092\u975E\u8868\u793A",show:"\u30B3\u30E1\u30F3\u30C8\u3092\u8868\u793A",reply:"\u8FD4\u4FE1",quicklyReply:"\u8FD4\u4FE1...",send:"\u9001\u4FE1",placeholder:"\u30B3\u30E1\u30F3\u30C8\u3092\u8FFD\u52A0...",replyPlaceholder:"\u8FD4\u4FE1\u307E\u305F\u306F\u30E1\u30F3\u30B7\u30E7\u30F3(@)",edit:"\u7DE8\u96C6",delete:"\u524A\u9664",image:"\u753B\u50CF",sendTitle:"Enter\u3092\u62BC\u3057\u3066\u30B3\u30E1\u30F3\u30C8\u3092\u9001\u4FE1",replyTitle:"Enter\u3092\u62BC\u3057\u3066\u30B3\u30E1\u30F3\u30C8\u3092\u8FD4\u4FE1",isFirst:"\u6700\u521D\u306E\u30B3\u30E1\u30F3\u30C8\u3067\u3059",isLast:"\u6700\u5F8C\u306E\u30B3\u30E1\u30F3\u30C8\u3067\u3059",comment:"\u30B3\u30E1\u30F3\u30C8\u3092"}};x.mergeLang({"zh-CN":IP,"en-US":xP,"ja-JP":TP});class m6{renderText(t,e,o){const r=[],i={};return Object.entries(o).forEach(([s,l])=>{s.startsWith("comment-")&&(r.push("comment"),i[s]=l)}),{classes:r,attributes:i}}renderBlock(t,e,o){const r=o.comments;if(!r||r.length===0)return{};const i=["comment"],s={};return r.forEach(l=>{s[`comment-${l.toLocaleLowerCase()}`]=l}),{classes:i,attributes:s}}updateBlock(t,e,o,r){const i=r.comments;H(o,"comment"),Array.from(o.attributes).forEach(s=>{s.name.startsWith("comment-")&&o.removeAttribute(s.name)}),!(!i||i.length===0)&&(M(o,"comment"),i.forEach(s=>{o.setAttribute(`comment-${s.toLocaleLowerCase()}`,s)}))}}class SP{constructor(t){h(this,"handleUpdateCompositionText",(t,e,o,r,i)=>{const s=t.getFocusedBlock(),l=t.getFirstBlock();s===l&&this.applyPlaceholder(t)});h(this,"handleSelectionChange",t=>{this.applyPlaceholder(t)});h(this,"applyPlaceholder",t=>{const e=t.getFirstBlock();aa(t,e,x.t("comment.replyPlaceholder"))});this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}}function DP(n,t,e){const o=n.getBlockData(t),r=o.comments;if((r==null?void 0:r.indexOf(e))!==-1){const s=new Set(r);s.delete(e),n.updateBlockData(t,{comments:Array.from(s)})}const i=o.text;if(!!i&&_(n,t)){const s=id(i,`comment-${e.toLocaleLowerCase()}`,e);n.setBlockText(t,s)}}const LP=w("editor-comment");function MP(n){const t=n.getCustom("editor-comments");if(u(LP,t,"the editor comment not exist"),t.showCommentList(),n.selection.range.isCollapsed()){const s=n.selection.startBlock,l=ao(s);if(l.length>=2){const{containerId:c}=l.at(-1),a=U(Pr(n,c));if(a&&it(a)==="code"){vf(n,a,t.commentProvider);return}}vf(n,s,t.commentProvider);return}const e=en(n,{simpleBlockOnly:!0}),o=e.map(s=>s.block),r=bf(n,o),i=Ia({editor:n,abstract:r});n.undoManager.runInGroup(()=>{e.forEach(l=>{_(n,l.block)?h6(n,l,i):q3(n,l.block,i)});const s=or();t.commentProvider.localCreateComment(i,s)})}const Tf=w("text-styles");function RP(n){const t=o=>{if(!o.attributes)return new Map;const r=Object.entries(o.attributes).filter(([i])=>!!i.startsWith("style-"));return new Map(r)};if(n.length===0)return new Map;let e=t(n[0]);for(let o=1;o<n.length;o++){const r=t(n[o]);e=new Map(Array.from(e.entries()).filter(([i,s])=>r.get(i)===s))}return e}function OP(n,t,e,o,r){u(Tf,e.isSimple(),"invalid range");const{start:i,end:s}=e;u(Tf,i.blockId===s.blockId&&i.blockId===j(t),"invalid range"),u(Tf,o.startsWith("style-"),"invalid style");let c=n.getBlockText(t);return o==="style-subscript"?c=Nr(i.offset,s.offset-i.offset,c,"style-superscript",void 0,{ignoreValue:!0}):o==="style-superscript"&&(c=Nr(i.offset,s.offset-i.offset,c,"style-subscript",void 0,{ignoreValue:!0})),r===!1||r===void 0||r===null?c=Nr(i.offset,s.offset-i.offset,c,o,void 0,{ignoreValue:!0}):c=Yi(i.offset,s.offset-i.offset,c,o,r),n.setBlockText(t,c),c}const NP=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
591
|
+
</svg>`,HV="",xa="reply-editor-editing",{t:If}=T;class sP{constructor(t,e,o,r){h(this,"root");h(this,"components");h(this,"handleFocus",()=>{const{replyEditor:t,okButton:e}=this.components;t.isEmpty()&&M(e,to)});h(this,"handleDocChange",()=>{const{replyEditor:t,okButton:e}=this.components,o=t.getDoc();tc(o)?M(e,to):H(e,to)});h(this,"getReplyEditor",()=>this.components.replyEditor);h(this,"showReplyEditor",()=>{rt(this.root,xa)||(M(this.root,xa),this.components.replyEditor.edit())});h(this,"hideReplyEditor",()=>{!rt(this.root,xa)||H(this.root,xa)});h(this,"reply",()=>{const{mainEditor:t,comment:e,components:{replyEditor:o},commentsProvider:r}=this,i=o.getDoc(),s=Ia({editor:t,commentGroupId:e.groupId});r.localCreateComment(s,i),this.hideReplyEditor(),o.clear()});h(this,"cancel",()=>{const{replyEditor:t}=this.components;this.hideReplyEditor(),t.clear()});h(this,"hide",()=>{rt(this.root,"hidden")||M(this.root,"hidden")});h(this,"show",()=>{H(this.root,"hidden")});this.mainEditor=t,this.commentsProvider=e,this.comment=o,this.groupItem=r,this.root=b("div",["comment-quick-reply"],null),this.components=this.createQuickReply()}createQuickReply(){const{commentsProvider:t}=this,e=mr(this.root,mt.QuickReply,If("comment.placeholder"));eo(e,mt.QuickReply),e.classList.add("quick-reply-button");const o=b("div",["quick-reply-editor"],this.root),r=or(),i=new Ef(this.mainEditor,t,r);i.editor.addListener("docChanged",this.handleDocChange),i.editor.addListener("focus",this.handleFocus),i.editor.input.addHandler(new KN(this.groupItem)),o.append(i.root);const s=b("div",["reply-editor-actions"],o),l=Bo(mt.QuickReplyCancel,If("common.cancel"));eo(l,mt.QuickReplyCancel);const c=Bo(mt.QuickReplyOk,If("comment.send"));return eo(c,mt.QuickReplyOk),M(c,to),s.append(l,c),this.hideReplyEditor(),{replyTextButton:e,replyEditor:i,replyEditorContainer:o,okButton:c}}}const no=w("comment-group-item");class lP extends Yt.TypedEmitter{constructor(e,o,r,i){super();h(this,"root");h(this,"header");h(this,"mainItem");h(this,"childrenList");h(this,"resizeObserver");h(this,"quickReply");h(this,"createRoot",()=>b("div",["comment-group-item-root"],null));h(this,"createChildrenList",()=>{const e=b("div",["comment-children-list-container"],this.root);return new oP({editor:this.editor,commentsProvider:this.commentsProvider,comments:this.comment.children,parent:e,groupList:this.groupList,groupItem:this})});h(this,"updateLastCommentItem",()=>{const e=Array.from(this.root.querySelectorAll(":scope .comment-item-root"));u(no,e.length!==0,"current group item not exist comment-item"),e.forEach(r=>{H(r,W3)});const o=e.at(-1);M(o,W3)});h(this,"updateSwitchButton",()=>{const e=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-up"]'),o=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-down"]');u(no,e,"switchUpButton not exist"),u(no,o,"switchDownButton not exist"),H(o,"disabled"),H(e,"disabled"),this.root.previousElementSibling===null&&M(e,"disabled"),this.root.nextElementSibling===null&&M(o,"disabled")});h(this,"handleReadonlyChanged",e=>{e.readonly?M(this.root,"readonly"):H(this.root,"readonly")});h(this,"handleResize",()=>{this.emit("resize")});this.editor=e,this.commentsProvider=o,this.comment=r,this.groupList=i,this.root=this.createRoot(),this.header=this.createHeader(),this.mainItem=this.createItem(),this.childrenList=this.createChildrenList(),this.quickReply=this.createQuickReply(),this.editor.on("readonlyChanged",this.handleReadonlyChanged),this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.root),this.updateLastCommentItem()}get commentCount(){return Z3(this.root)}createQuickReply(){const{editor:e,commentsProvider:o,comment:r}=this,i=new sP(e,o,r,this);return this.root.append(i.root),i}createHeader(){const{comment:e}=this,o=b("div",["comment-item-head"],this.root),r=b("span",["item-head-quote"],o);r.innerText=e.abstract;const i=b("span",["item-head-switch"],o),s=mr(i,mt.SwitchUp,"up",rP),l=mr(i,mt.SwitchDown,"down",iP);return eo(s,mt.SwitchUp),eo(l,mt.SwitchDown),o}createItem(){const e=b("div",["comment-item-container"],this.root),{editor:o,commentsProvider:r,comment:i,groupList:s}=this,l=new r6({mainEditor:o,commentsProvider:r,comment:i,groupList:s,groupItem:this});return e.appendChild(l.root),l}findCommentItem(e){return e?e===this.mainItem.comment.id?this.mainItem:this.childrenList.items.find(o=>o.comment.id===e):null}handleCreateComment(e){return u(no,Cr(e),"invalid comment, not a child comment"),u(no,e.groupId===this.comment.id,"invalid comment, not a child comment"),this.childrenList.createItem(e)}handleUpdateChildComment(e){u(no,e.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(e.id);if(!o){no.error(`can't find child comment item: ${e.id}`);return}o.reloadDoc()}handleUpdateMainComment(e){u(no,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){u(no,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}edit(){this.mainItem.edit()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.root.remove(),this.resizeObserver.disconnect(),this.removeAllListeners(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}}const cP=w("arrange=items"),s6=20;function l6(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}`);if(!e)return-1;const o=n.scrollContainer.getBoundingClientRect(),r=n.scrollContainer.scrollTop;return e.getBoundingClientRect().top-o.top+r}function c6(n,t){return Number.parseInt(t.root.style.top,10)}function a6(n,t,e,o){let r=0;e&&(r=t.indexOf(e),r===-1&&(r=0));for(let i=r;i<t.length;i++){const s=t[i],l=s.comment,c=l6(n,l.groupId);if(s.root.setAttribute("data-target-top",c.toString()),i===r){if(o!==void 0){const f=t[0];f.root.style.top=`${o}px`}else s.root.style.top=`${c}px`;continue}const a=t[i-1],d=c6(n,a)+a.root.getBoundingClientRect().height;d>c?s.root.style.top=`${d+s6}px`:s.root.style.top=`${c}px`}for(let i=r-1;i>=0;i--){const s=t[i],l=s.comment,c=l6(n,l.groupId);s.root.setAttribute("data-target-top",c.toString());const a=s.root.getBoundingClientRect(),d=c+a.height,f=t[i+1];u(cP,f,"no next item");const m=c6(n,f);m<d?s.root.style.top=`${m-a.height-s6}px`:s.root.style.top=`${c}px`}}const Ta=w("comment-group-item-handler");class aP{constructor(t,e){h(this,"handleSwitchUp",t=>{const e=Math.max(0,t-1);this.groupList.setActiveItem(e),this.groupList.updateItemsLayout()});h(this,"handleSwitchDown",t=>{const e=Math.min(t+1,this.groupList.items.length);this.groupList.setActiveItem(e),this.groupList.updateItemsLayout()});h(this,"handleQuickReply",t=>{const{quickReply:e}=t;e.showReplyEditor()});h(this,"handleQuickReplyOk",t=>{const{quickReply:e}=t;e.reply(),t.updateLastCommentItem()});h(this,"handleQuickReplyCancel",t=>{const{quickReply:e}=t;e.cancel()});h(this,"handleCommentItemReply",(t,e)=>{const o=t.findCommentItem(e);u(Ta,o,`the commentItem: ${e} not exist `);const{quickReply:r}=t;r.show(),r.showReplyEditor();const{comment:i}=o,s=r.getReplyEditor(),l=s.editor.getFocusedBlock(),c={type:"mention",id:P(),box:!0,created:Date.now(),text:i.displayName,iconUrl:i.avatarUrl,mentionId:i.userId};s.editor.insertBoxToBlock(l,0,c)});h(this,"handleCommentItemMore",t=>{const{quickReply:e}=t;e.hideReplyEditor(),e.getReplyEditor().clear()});h(this,"handleCommentItemOk",(t,e)=>{const o=t.findCommentItem(e);u(Ta,o,`the commentItem: ${e} not exist `);const{quickReply:r}=t,{comment:i,getCommentEditor:s}=o,l=s(),c=l.getDoc();this.commentsProvider.localUpdateComment(i,c),l.readonly(),r.show()});h(this,"handleCommentItemCancel",(t,e)=>{const o=t.findCommentItem(e);u(Ta,o,`the commentItem: ${e} not exist `);const r=this.commentsProvider.getComment(o.comment.id);if(tc(r.doc)){this.commentsProvider.localDeleteComment(o.comment.id);return}const{quickReply:i}=t,s=o.getCommentEditor();s.setDoc(o.doc),s.readonly(),i.show()});h(this,"handleCommentItemEdit",t=>{const e=this.groupList.findItem(t.comment.groupId);if(!e)return;const{quickReply:o}=e;t.getCommentEditor().edit(),o.hide()});h(this,"handleCommentItemDelete",t=>{const e=this.groupList.findItem(t.comment.groupId);if(!e)return;const{quickReply:o}=e,{comment:r}=t;this.commentsProvider.localDeleteComment(r.id),o.show()});h(this,"execute",(t,e,o,r)=>{const i=VN(t);if(!i||WN(i))return;const s=qN(i);switch(s){case mt.SwitchUp:this.handleSwitchUp(r);break;case mt.SwitchDown:this.handleSwitchDown(r);break;case mt.CommentItemReply:this.handleCommentItemReply(e,o);break;case mt.CommentItemMore:this.handleCommentItemMore(e);break;case mt.CommentItemOk:this.handleCommentItemOk(e,o);break;case mt.CommentItemCancel:this.handleCommentItemCancel(e,o);break;case mt.CommentItemDelete:break;case mt.CommentItemEdit:break;case mt.QuickReply:this.handleQuickReply(e);break;case mt.QuickReplyOk:this.handleQuickReplyOk(e);break;case mt.QuickReplyCancel:this.handleQuickReplyCancel(e);break;default:const l=s;Ta.debug(`not implement handler for ${l}`)}});this.groupList=t,this.commentsProvider=e}destroy(){}}const Sa=w("comment-group-list");class uP extends al{constructor(e,o,r){super(e,o,r,No(e,o),{});h(this,"groupItemHandlers");h(this,"findGroupItem",e=>this.items.find(o=>o.comment.groupId===e));h(this,"handleContainerClick",e=>{if(!e.target||!(e.target instanceof Element))return;const o=e.target.closest(".comment-group-item-root");if(!o)return;const r=UN(e.target),i=this.items.findIndex(s=>s.root===o);if(i!==-1){this.setActiveItem(i);const{groupItemHandlers:s}=this;s.execute(e.target,this.items.at(i),r,i)}});h(this,"handleSelectionChanged",()=>{const e=X3(this.editor);if(e.length>0){const o=e[0],r=this.items.findIndex(i=>i.comment.groupId===o);this.setActiveItem(r),this.emit("selectionOnComment")}else this.setActiveItem(-1)});h(this,"handleEditorResize",()=>{this.updateItemsLayout()});h(this,"handleDocChanged",()=>{this.updateComments()});h(this,"handleItemResize",()=>{this.updateItemsLayout()});h(this,"handleScroll",e=>{if(e.deltaY>=0||this.editor.scrollContainer.scrollTop!==0)return;const o=document.elementFromPoint(e.clientX,e.clientY);if(!o||!(o instanceof HTMLElement)||!this.editor.scrollContainer.contains(o))return;const r=this.container.querySelector(".comment-group-item-root");if(!r)return;const i=Number.parseFloat(r.style.top),s=Number.parseFloat(r.getAttribute("data-target-top")||"0");!Number.isNaN(i)&&!Number.isNaN(s)&&i<s&&a6(this.editor,this.items,null,Math.min(i+(0-e.deltaY)*3,s))});h(this,"updateGroupItemSwitch",()=>{const e=this.activeItem;u(Sa,e,"invalid activeItem"),e.updateSwitchButton()});h(this,"updateComments",ee.default(()=>{const e=No(this.editor,this.commentsProvider);let o=!1;for(let r=0;r<e.length;r++){const i=e[r];if(!this.findGroupItem(i.groupId)){this.handleCreateComment(i,!1),o=!0;continue}}for(let r=this.items.length-1;r>=0;r--){const i=this.items[r];e.findIndex(s=>s.groupId===i.comment.groupId)===-1&&(this.deleteItem(i.comment.id),o=!0)}o&&(this.updateItemsLayout(),this.emit("commentCountChanged"))},100));this.updateItemsLayout(),this.bindEvents(),this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("resize",this.handleEditorResize),this.editor.addListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.addEventListener("wheel",this.handleScroll,{passive:!1}),this.items.forEach(i=>i.addListener("resize",this.handleItemResize)),this.groupItemHandlers=new aP(this,o)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("resize",this.handleEditorResize),this.editor.removeListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.removeEventListener("wheel",this.handleScroll),super.destroy(),this.unbindEvents(),this.removeAllListeners()}updateItemsLayout(){a6(this.editor,this.items,this.activeItem)}bindEvents(){this.container.addEventListener("click",this.handleContainerClick)}unbindEvents(){this.container.removeEventListener("click",this.handleContainerClick)}createItem(e,o){const r=new lP(this.editor,this.commentsProvider,e,this);return o==="insert"&&(M(r.root,"no-animation"),r.root.style.opacity="0",setTimeout(()=>{H(r.root,"no-animation"),r.root.style.opacity="1"},150)),r}findInsertPos(e){const r=No(this.editor,this.commentsProvider).findIndex(i=>i.id===e.id);return r===-1||r>this.items.length?-1:r}insertItem(e,o){const r=super.insertItem(e);return r?(o!=null&&o.active&&this.setActiveItem(this.items.indexOf(r)),this.updateItemsLayout(),r.addListener("resize",this.handleItemResize),r):null}setActiveItem(e){if(u(Sa,e>=-1&&e<this.items.length,`invalid index: ${e}`),e===this.activeIndex)return;const o=this.container.querySelector(".comment-group-item-root.active");if(o&&H(o,"active"),e!==-1){const r=this.items[e];M(r.root,"active"),this.updateItemsLayout(),this.updateGroupItemSwitch()}this.emit("activeItemChanged",e)}get activeIndex(){const e=this.container.querySelector(".comment-group-item-root.active");return e?this.items.findIndex(o=>o.root===e):-1}get activeItem(){const e=this.activeIndex;return e===-1?null:this.items[e]}handleCreateComment(e,o){if(Cr(e)){const l=this.findGroupItem(e.groupId);l&&l.childrenList.insertItem(e)}const r=this.findItem(e.id);u(Sa,!r,"comment group item has already exists");const i={children:[],...e};u(Sa,i.children,"not a comment group");const s=this.insertItem(i,{active:o});!s||o&&setTimeout(()=>{const l=this.items.indexOf(s);this.setActiveItem(l),s.edit(),s.quickReply.hide()})}handleDeleteComment(e){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===e){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(e);return}if(r.childrenList.deleteItem(e)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(e){if(Cr(e)){const r=this.commentsProvider.getComment(e.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(e);return}const o=this.findItem(e.id);o&&o.handleUpdateMainComment(e)}}const dP="comment-mini";w("comment-list");class hP extends Yt.TypedEmitter{constructor(e,o){super();h(this,"root");h(this,"groupsContainer");h(this,"list");h(this,"handleSelectionOnComment",()=>{this.emit("onSelectComment")});h(this,"updateCommentCount",()=>{var o,r;const e=QN(this.editor,this.commentsProvider);(r=(o=this.commentOptions)==null?void 0:o.onCommentCountChange)==null||r.call(o,e)});h(this,"handleActiveItemChanged",()=>{var o;const e=this.list.activeItem;e6(this.editor,(o=e==null?void 0:e.comment.id)!=null?o:"")});h(this,"handleItemLayoutUpdated",()=>{var o,r;const e=rt(this.root,dP);(r=(o=this.commentOptions)==null?void 0:o.onUpdateLayout)==null||r.call(o,this.editor,{expand:e})});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-web-comment-root"],null),this.groupsContainer=b("div",["comment-groups-container"],this.root),this.list=this.createList(),this.commentsProvider.addListener(this),this.list.addListener("activeItemChanged",this.handleActiveItemChanged),this.list.addListener("itemLayoutUpdated",this.handleItemLayoutUpdated),this.list.addListener("selectionOnComment",this.handleSelectionOnComment),this.list.addListener("commentCountChanged",this.updateCommentCount),this.updateCommentCount()}get commentOptions(){return this.editor.getComponentOptions("comment")}destroy(){this.list.removeAllListeners(),this.commentsProvider.removeListener(this),this.list.destroy(),this.root.remove()}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o),this.updateCommentCount()}onDeleteComment(e,o){this.list.handleDeleteComment(e),this.updateCommentCount()}onUpdateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleUpdateComment(r)}createList(){return new uP(this.editor,this.commentsProvider,this.groupsContainer)}show(e){var o;if(H(this.root,"hidden"),e){const r=this.list.findItemIndex(e);this.list.setActiveItem(r)}(o=this.commentOptions)==null||o.controller.showCommentList()}hide(){M(this.root,"hidden")}}class fP extends al{constructor({editor:t,parent:e,commentsProvider:o,comments:r}){super(t,o,e,r,{})}findInsertPos(){return this.items.length}createItem(t){const{editor:e,commentsProvider:o}=this;return new i6(e,o,t)}destroy(){this.items.forEach(t=>{t.destroy()})}}const Da=w("mobile-comment-group-item"),mP=20;class gP extends Yt.TypedEmitter{constructor(e,o,r){super();h(this,"root");h(this,"childrenList");h(this,"mainItem");h(this,"scroller");h(this,"createRoot",()=>b("div",["mobile-group-item-root"],null));h(this,"createMainItem",e=>{const{editor:o,commentsProvider:r,comment:i}=this,s=new i6(o,r,i);return e.append(s.root),s});h(this,"createChildrenList",e=>{const{editor:o,commentsProvider:r,comment:i}=this,s=b("div",["mobile-comment-children-list-container"],e);return new fP({editor:o,commentsProvider:r,comments:i.children,parent:s})});h(this,"handleTouchEnd",()=>{var i;const{scroller:e}=this,{pullThreshold:o=mP}=(i=this.editor.getComponentOptions("comment"))!=null?i:{};let r=null;if(e.y>e.minScrollY+o?(r=this.root.previousElementSibling,r||this.emit("onReachTop")):e.y<e.maxScrollY-o&&(r=this.root.nextElementSibling,r||this.emit("onReachBottom")),r){const s=r.id;this.emit("onSwitchGroup",s,G3)}});h(this,"refreshScroller",()=>{this.scroller.refresh()});this.editor=e,this.commentsProvider=o,this.comment=r,this.root=b("div",["mobile-group-item-root"],null),this.root.id=r.groupId;const i=b("div",["mobile-group-item"],this.root),s=b("div",["mobile-group-item-space"],null),l=b("div",["mobile-group-item-abstract"],null);l.textContent=r.abstract;const c=b("div",["mobile-group-item-list-container"],null);this.mainItem=this.createMainItem(c),this.childrenList=this.createChildrenList(c),i.append(s,l,c),this.scroller=new pm.default(this.root,{stopPropagation:!0,click:!0}),this.scroller.on("touchEnd",this.handleTouchEnd)}get commentCount(){return Z3(this.root,".mobile-group-item")}handleUpdateChildComment(e){u(Da,e.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(e.id);if(!o){Da.error(`can't find child comment item: ${e.id}`);return}o.reloadDoc()}handleUpdateMainComment(e){u(Da,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){u(Da,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.scroller.off("touchEnd",this.handleTouchEnd),this.scroller.destroy(),this.root.remove(),this.removeAllListeners()}}const xf=w("mobile-group-list");class pP extends al{constructor(e,o,r,i){super(e,o,r,No(e,o),{});h(this,"scroller");h(this,"deleteItem",e=>{if(this.items.length<=1)return super.deleteItem(e);const o=this.findItemIndex(e);let r=null;return o===0?r=this.items[o+1].root.id:r=this.items[o-1].root.id,super.deleteItem(e)?(this.scrollToGroup(r,G3),!0):!1});h(this,"setupGroupItem",e=>{e.on("onSwitchGroup",this.scrollToGroup),e.on("onReachBottom",this.handleReachBottom),e.on("onReachTop",this.handleReachTop),e.refreshScroller()});h(this,"handleReachBottom",()=>{this.emit("onReachBottom")});h(this,"handleReachTop",()=>{this.emit("onReachTop")});h(this,"scrollToGroup",(e,o=0)=>{const r=this.findGroupItem(e);u(xf,r,"invalid scroll target"),this.scroller.scrollToElement(r.root,o,!1,!1),e6(this.editor,r.comment.id)});h(this,"findGroupItem",e=>this.items.find(o=>o.comment.groupId===e));h(this,"handleDocChanged",()=>{this.updateComments()});h(this,"updateComments",ee.default(()=>{const e=No(this.editor,this.commentsProvider);for(let o=0;o<e.length;o++){const r=e[o];if(!this.findGroupItem(r.groupId)){this.handleCreateComment(r,!1);continue}}for(let o=this.items.length-1;o>=0;o--){const r=this.items[o];e.findIndex(i=>i.groupId===r.comment.groupId)===-1&&this.deleteItem(r.comment.id)}},100));this.scroller=new pm.default(i),this.scroller.disable(),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(this.setupGroupItem)}createItem(e){return new gP(this.editor,this.commentsProvider,e)}insertItem(e){const o=super.insertItem(e);return o?(this.setupGroupItem(o),o):null}findInsertPos(e){const r=No(this.editor,this.commentsProvider).findIndex(i=>i.id===e.id);return r===-1||r>this.items.length?-1:r}setActiveItem(e){this.scrollToGroup(e)}handleCreateComment(e,o){if(Cr(e)){const s=this.findGroupItem(e.groupId);s&&s.childrenList.insertItem(e)}const r=this.findItem(e.id);u(xf,!r,"comment group item has already exists");const i={children:[],...e};u(xf,i.children,"not a comment group"),this.insertItem(i),this.scroller.refresh()}handleDeleteComment(e){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===e){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(e);return}if(r.childrenList.deleteItem(e)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(e){if(Cr(e)){const r=this.commentsProvider.getComment(e.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(e);return}const o=this.findItem(e.id);o&&o.handleUpdateMainComment(e)}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),this.scroller.destroy(),this.items.forEach(e=>e.destroy())}}const CP=w("mobile-comment-list"),{t:u6}=T;class AP extends Yt.TypedEmitter{constructor(e,o){super();h(this,"root");h(this,"list");h(this,"mask");h(this,"pullInfoContainer");h(this,"handleRootClick",e=>{const o=e.target;u(CP,o instanceof Element,"invalid target"),!(o.closest(".mobile-group-item-abstract")||o.closest(".mobile-group-item-list-container"))&&(this.hide(),this.emit("onCommentListClose"))});h(this,"hidePullInfo",ee.default(()=>{H(this.pullInfoContainer,"active")},1e3*3));h(this,"handleReachBottom",()=>{this.showPullInfo("bottom")});h(this,"handleReachTop",()=>{this.showPullInfo("top")});h(this,"show",e=>{H(this.root,"hidden"),M(document.documentElement,"disabled-scroll"),e&&this.list.setActiveItem(e)});h(this,"hide",()=>{M(this.root,"hidden"),H(document.documentElement,"disabled-scroll")});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-mobile-comments-root"],null),this.mask=b("div",["mobile-comment-mask"],this.root);const r=b("div",["mobile-comment-groups-container"],this.root),i=b("div",["mobile-comment-groups-scroll-container"],r);this.list=new pP(this.editor,this.commentsProvider,i,r),this.pullInfoContainer=this.createPullInfo(),this.commentsProvider.addListener(this),this.list.on("onReachBottom",this.handleReachBottom),this.list.on("onReachTop",this.handleReachTop),this.root.onclick=this.handleRootClick}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o)}onDeleteComment(e,o){this.list.handleDeleteComment(e)}onUpdateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleUpdateComment(r)}createPullInfo(){const e=b("div",["mobile-comment-pull-info-container"],this.root);return b("div",["mobile-comment-pull-info"],e),e}showPullInfo(e){const o=u6(e==="bottom"?"comment.isLast":"comment.isFirst");this.pullInfoContainer.firstElementChild.textContent=o,M(this.pullInfoContainer,"active"),this.hidePullInfo()}destroy(){this.list.removeAllListeners(),this.list.destroy(),this.root.onclick=null}}function d6(n,t){const e=No(n,t),o=new Map;for(const r of e){const i=Q3(n,r.groupId);if(!!i)if(o.has(i)){const s=o.get(i);kf(r).forEach(c=>{s==null||s.commentIds.add(c.id)})}else{const s=kf(r),l=new Set(s.map(c=>c.id));o.set(i,{commentIds:l,firstComment:r})}}return Array.from(o.entries()).map(([r,i])=>({blockId:r,...i}))}const bP=w("mini-group-item");class vP{constructor(t,e){h(this,"root");h(this,"blockId");h(this,"comment");h(this,"miniCommentItem");h(this,"updateCommentItemCount",()=>{this.miniCommentItem.updateCount(this.commentCount)});this.editor=t,this.commentGroup=e,this.root=b("div",["mini-group-item"],null),this.comment=e.firstComment,this.miniCommentItem=new nP(this.comment.id,this.root),this.blockId=this.getBlockId(),this.alignToBlock(),this.updateCommentItemCount()}getBlockId(){return Q3(this.editor,this.comment.groupId)}get commentCount(){return this.commentGroup.commentIds.size}alignToBlock(){const t=this.getBlockId(),e=this.editor.getBlockById(t);u(bP,e,`The blockId: ${t} not exist in doc`);const o=this.editor.scrollContainer.getBoundingClientRect(),i=e.getBoundingClientRect().top-o.top;requestAnimationFrame(()=>{this.root.style.transform=`translateY(${i}px)`})}destroy(){this.root.remove()}}class yP extends al{constructor(e,o,r){super(e,o,r,d6(e,o),{});h(this,"handleDocChanged",ee.default(()=>{this.updateMiniCommentsGroup()},100));h(this,"updateMiniCommentsGroup",()=>{const e=d6(this.editor,this.commentsProvider);this.reloadList(e)});this.editor=e,this.commentsProvider=o,this.editor.addListener("docChanged",this.handleDocChanged)}createItem(e){return new vP(this.editor,e)}findInsertPos(){return-1}handleCreateComment(e,o){this.updateMiniCommentsGroup()}handleDeleteComment(e){this.updateMiniCommentsGroup()}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.removeAllListeners()}}const kP=w("mini-comments-list");class wP extends Yt.TypedEmitter{constructor(e,o){super();h(this,"list");h(this,"root");h(this,"createList",()=>{const e=b("div",["comment-groups-container"],this.root);return this.editor.domEvents.addEventListener(e,"click",this.handleListContainerClick),new yP(this.editor,this.commentsProvider,e)});h(this,"handleListContainerClick",(e,o)=>{const r=o.target;u(kP,r instanceof HTMLElement,"The target is not a valid html element");const i=r.closest(".mini-comment-item");i&&this.emit("onItemClick",i.id)});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-mini-comment-root"],null),this.list=this.createList(),this.commentsProvider.addListener(this)}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o)}onDeleteComment(e,o){this.list.handleDeleteComment(e)}onUpdateComment(e,o){}show(){H(this.root,"hidden")}hide(){M(this.root,"hidden")}destroy(){this.list.destroy(),this.removeAllListeners()}}function h6(n,t,e){if(!t.start.isSimple()||!t.end.isSimple())return;const o=t.block,r=Ot(n,o,t.start.offset,t.end.offset),i=`comment-${e.id.toLocaleLowerCase()}`,s=e.id;l0(n,o,r,i,s)}function BP(n,t,e){const o=en(n).map(s=>s.block),r=bf(n,o),i=Ia({editor:n,abstract:r});return n.undoManager.runInGroup(()=>{en(n,{simpleBlockOnly:!0}).forEach(c=>{!_(n,c.block)||h6(n,c,i)});const l=or();e.localCreateComment(i,l)}),i}class EP{constructor(t,e){h(this,"id","CommentsCommandProvider");this.provider=t,this.editorComments=e}getAvailableCommands(t,e,o){const r=t.selection.range;if(_(t,e)&&!o.isCollapsed()&&r.isSimple()){const i=j(e),s=it(e),l=Je(t,e);return[{id:"add-comment",name:"Add comment",blockId:i,blockType:s,blockKind:l,groupIndex:1e3,icon:Ts}]}return[]}executeRangeCommand(t,e,o,r,i){if(o.id==="add-comment"){this.editorComments.showCommentList();const s=BP(t,e,this.provider);return i["add-comment"]=s,!0}return!1}}class f6{constructor(t,e){h(this,"commentList",null);h(this,"mobileCommentList",null);h(this,"miniCommentList");h(this,"showComment",(t,e)=>{var o,r;t==="mini"&&this.miniCommentList.show(),t==="mobile"&&((o=this.mobileCommentList)==null||o.show(e)),t==="web"&&((r=this.commentList)==null||r.show(e))});h(this,"showCommentList",t=>{this.isMobile?this.showComment("mobile",t):this.showComment("web",t)});h(this,"handleCommentListClose",()=>{this.showComment("mini")});h(this,"handleOnSelectComment",()=>{this.showComment("web")});h(this,"handleMiniCommentItemClick",t=>{this.showCommentList(t)});this.editor=t,this.provider=e,t.editorCommandProviders.registerCommandProvider(new EP(e,this)),t.blockHooks.push(new zN(this.provider,this)),this.isMobile?(this.mobileCommentList=new AP(this.editor,this.provider),this.mobileCommentList.on("onCommentListClose",this.handleCommentListClose)):(this.commentList=new hP(this.editor,this.provider),this.commentList.on("onSelectComment",this.handleOnSelectComment)),this.miniCommentList=new wP(this.editor,this.provider),this.miniCommentList.on("onItemClick",this.handleMiniCommentItemClick)}get commentOptions(){return this.editor.getComponentOptions("comment")}get commentProvider(){return this.provider}get isMobile(){return xt.isMobile}destroy(){var t,e;(t=this.commentList)==null||t.destroy(),(e=this.mobileCommentList)==null||e.destroy(),this.miniCommentList.destroy()}mount(t){var e;t.container&&this.commentList&&t.container.append((e=this.commentList)==null?void 0:e.root),t.miniContainer&&t.miniContainer.append(this.miniCommentList.root),t.mobileContainer&&this.mobileCommentList&&t.mobileContainer.append(this.mobileCommentList.root)}}const jV="",IP={comment:{count:"\u6279\u6CE8 ({num})",hide:"\u9690\u85CF\u6279\u6CE8",show:"\u663E\u793A\u6279\u6CE8",reply:"\u56DE\u590D",quicklyReply:"\u56DE\u590D...",send:"\u786E\u8BA4",placeholder:"\u6DFB\u52A0\u6279\u6CE8...",replyPlaceholder:"\u56DE\u590D\u6216@\u4ED6\u4EBA",edit:"\u7F16\u8F91",delete:"\u5220\u9664",image:"\u56FE\u7247",sendTitle:"\u6309Enter\u53D1\u9001\u6279\u6CE8",replyTitle:"\u6309Enter\u56DE\u590D\u6279\u6CE8",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",comment:"\u6279\u6CE8"}},xP={comment:{count:"Comments ({num})",hide:"Hide Comments",show:"Show Comments",reply:"Reply",quicklyReply:"Reply...",send:"OK",placeholder:"Add a comment...",replyPlaceholder:"Add Comments or @ others",edit:"Edit",delete:"Delete",image:"Image",sendTitle:"Press Enter to send comment",replyTitle:"Press Enter to reply comment",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",more:"more",comment:"Comment"}},TP={comment:{count:"\u30B3\u30E1\u30F3\u30C8 ({num})",hide:"\u30B3\u30E1\u30F3\u30C8\u3092\u975E\u8868\u793A",show:"\u30B3\u30E1\u30F3\u30C8\u3092\u8868\u793A",reply:"\u8FD4\u4FE1",quicklyReply:"\u8FD4\u4FE1...",send:"\u9001\u4FE1",placeholder:"\u30B3\u30E1\u30F3\u30C8\u3092\u8FFD\u52A0...",replyPlaceholder:"\u8FD4\u4FE1\u307E\u305F\u306F\u30E1\u30F3\u30B7\u30E7\u30F3(@)",edit:"\u7DE8\u96C6",delete:"\u524A\u9664",image:"\u753B\u50CF",sendTitle:"Enter\u3092\u62BC\u3057\u3066\u30B3\u30E1\u30F3\u30C8\u3092\u9001\u4FE1",replyTitle:"Enter\u3092\u62BC\u3057\u3066\u30B3\u30E1\u30F3\u30C8\u3092\u8FD4\u4FE1",isFirst:"\u6700\u521D\u306E\u30B3\u30E1\u30F3\u30C8\u3067\u3059",isLast:"\u6700\u5F8C\u306E\u30B3\u30E1\u30F3\u30C8\u3067\u3059",comment:"\u30B3\u30E1\u30F3\u30C8\u3092"}};T.mergeLang({"zh-CN":IP,"en-US":xP,"ja-JP":TP});class m6{renderText(t,e,o){const r=[],i={};return Object.entries(o).forEach(([s,l])=>{s.startsWith("comment-")&&(r.push("comment"),i[s]=l)}),{classes:r,attributes:i}}renderBlock(t,e,o){const r=o.comments;if(!r||r.length===0)return{};const i=["comment"],s={};return r.forEach(l=>{s[`comment-${l.toLocaleLowerCase()}`]=l}),{classes:i,attributes:s}}updateBlock(t,e,o,r){const i=r.comments;H(o,"comment"),Array.from(o.attributes).forEach(s=>{s.name.startsWith("comment-")&&o.removeAttribute(s.name)}),!(!i||i.length===0)&&(M(o,"comment"),i.forEach(s=>{o.setAttribute(`comment-${s.toLocaleLowerCase()}`,s)}))}}class SP{constructor(t){h(this,"handleUpdateCompositionText",(t,e,o,r,i)=>{const s=t.getFocusedBlock(),l=t.getFirstBlock();s===l&&this.applyPlaceholder(t)});h(this,"handleSelectionChange",t=>{this.applyPlaceholder(t)});h(this,"applyPlaceholder",t=>{const e=t.getFirstBlock();aa(t,e,T.t("comment.replyPlaceholder"))});this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}}function DP(n,t,e){const o=n.getBlockData(t),r=o.comments;if((r==null?void 0:r.indexOf(e))!==-1){const s=new Set(r);s.delete(e),n.updateBlockData(t,{comments:Array.from(s)})}const i=o.text;if(!!i&&_(n,t)){const s=id(i,`comment-${e.toLocaleLowerCase()}`,e);n.setBlockText(t,s)}}const LP=w("editor-comment");function MP(n){const t=n.getCustom("editor-comments");if(u(LP,t,"the editor comment not exist"),t.showCommentList(),n.selection.range.isCollapsed()){const s=n.selection.startBlock,l=ao(s);if(l.length>=2){const{containerId:c}=l.at(-1),a=U(Pr(n,c));if(a&&it(a)==="code"){vf(n,a,t.commentProvider);return}}vf(n,s,t.commentProvider);return}const e=en(n,{simpleBlockOnly:!0}),o=e.map(s=>s.block),r=bf(n,o),i=Ia({editor:n,abstract:r});n.undoManager.runInGroup(()=>{e.forEach(l=>{_(n,l.block)?h6(n,l,i):q3(n,l.block,i)});const s=or();t.commentProvider.localCreateComment(i,s)})}const Tf=w("text-styles");function RP(n){const t=o=>{if(!o.attributes)return new Map;const r=Object.entries(o.attributes).filter(([i])=>!!i.startsWith("style-"));return new Map(r)};if(n.length===0)return new Map;let e=t(n[0]);for(let o=1;o<n.length;o++){const r=t(n[o]);e=new Map(Array.from(e.entries()).filter(([i,s])=>r.get(i)===s))}return e}function OP(n,t,e,o,r){u(Tf,e.isSimple(),"invalid range");const{start:i,end:s}=e;u(Tf,i.blockId===s.blockId&&i.blockId===j(t),"invalid range"),u(Tf,o.startsWith("style-"),"invalid style");let c=n.getBlockText(t);return o==="style-subscript"?c=Nr(i.offset,s.offset-i.offset,c,"style-superscript",void 0,{ignoreValue:!0}):o==="style-superscript"&&(c=Nr(i.offset,s.offset-i.offset,c,"style-subscript",void 0,{ignoreValue:!0})),r===!1||r===void 0||r===null?c=Nr(i.offset,s.offset-i.offset,c,o,void 0,{ignoreValue:!0}):c=Yi(i.offset,s.offset-i.offset,c,o,r),n.setBlockText(t,c),c}const NP=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
592
592
|
<path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M13.3236 18.5C14.2519 18.5 15.0547 18.3458 15.7318 18.0374C16.409 17.729 16.9352 17.2951 17.3103 16.7355C17.6855 16.176 17.8731 15.521 17.8731 14.7707C17.8731 14.1857 17.738 13.6628 17.4677 13.2018C17.1975 12.7408 16.8271 12.372 16.3566 12.0954C15.886 11.8188 15.3424 11.6646 14.7256 11.6328V11.5565C15.4823 11.4548 16.0959 11.1464 16.5664 10.6313C17.0369 10.1163 17.2722 9.49633 17.2722 8.77146C17.2722 7.76045 16.9082 6.96246 16.1801 6.37748C15.4521 5.79249 14.4522 5.5 13.1805 5.5H8.57373C8.07777 5.5 7.69149 5.63989 7.41489 5.91966C7.1383 6.19944 7 6.59367 7 7.10235V16.8977C7 17.4063 7.1383 17.8006 7.41489 18.0803C7.69149 18.3601 8.07777 18.5 8.57373 18.5H13.3236ZM12.0073 10.8793H10.1379V7.68415H12.2076C12.8308 7.68415 13.3172 7.82086 13.6669 8.09428C14.0166 8.36769 14.1915 8.74921 14.1915 9.23881C14.1915 9.75385 13.9976 10.156 13.6097 10.4453C13.2218 10.7347 12.6877 10.8793 12.0073 10.8793ZM10.1379 16.3349H12.3412C13.1042 16.3349 13.686 16.1839 14.0866 15.8819C14.4872 15.5798 14.6875 15.1363 14.6875 14.5514C14.6875 13.9791 14.4776 13.5435 14.058 13.2447C13.6383 12.9458 13.0406 12.7964 12.2649 12.7964H10.1379V16.3349Z" />
|
|
593
593
|
</svg>`,PP=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
594
594
|
<path fill="currentColor" d="M13.5668 18.5C13.8023 18.5 13.9979 18.4316 14.1538 18.2948C14.3097 18.158 14.3877 17.9687 14.3877 17.7269C14.3877 17.4978 14.3129 17.3149 14.1634 17.178C14.0138 17.0412 13.8182 16.9728 13.5764 16.9728H11.6483L13.7959 7.02717H15.7048C15.9466 7.02717 16.1439 6.95876 16.2966 6.82195C16.4493 6.68514 16.5257 6.49584 16.5257 6.25404C16.5257 6.0186 16.4509 5.83407 16.3014 5.70044C16.1519 5.56681 15.9562 5.5 15.7144 5.5H9.94934C9.7139 5.5 9.51982 5.56681 9.36711 5.70044C9.21439 5.83407 9.13803 6.0186 9.13803 6.25404C9.13803 6.49584 9.21598 6.68514 9.37188 6.82195C9.52778 6.95876 9.72345 7.02717 9.95888 7.02717H11.8869L9.73935 16.9728H7.81131C7.56951 16.9728 7.37384 17.0412 7.2243 17.178C7.07477 17.3149 7 17.4978 7 17.7269C7 17.9687 7.07636 18.158 7.22907 18.2948C7.38179 18.4316 7.57905 18.5 7.82085 18.5H13.5668Z" />
|
|
@@ -609,7 +609,7 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
|
609
609
|
<path d="M1.00098 12.9985L10.9995 2.99998" stroke="currentColor"/>
|
|
610
610
|
<path d="M11.9113 6.16809L13.7433 3.79209C13.946 3.52009 14.0473 3.26142 14.0473 3.01609V2.90409C14.0473 2.71209 13.994 2.56009 13.8873 2.44809C13.786 2.33609 13.6473 2.28009 13.4713 2.28009C13.2953 2.28009 13.1567 2.33876 13.0553 2.45609C12.954 2.57342 12.9033 2.73609 12.9033 2.94409V3.07209H11.8873V2.88009C11.8873 2.59209 11.9513 2.33609 12.0793 2.11209C12.2127 1.88809 12.402 1.71209 12.6473 1.58409C12.8927 1.45609 13.1807 1.39209 13.5113 1.39209C13.8313 1.39209 14.1113 1.45876 14.3513 1.59209C14.5967 1.72542 14.7833 1.90409 14.9113 2.12809C15.0447 2.35209 15.1113 2.60009 15.1113 2.87209V3.00809C15.1113 3.24809 15.0687 3.46942 14.9833 3.67209C14.898 3.87476 14.7727 4.08276 14.6073 4.29609L13.2313 6.08009H15.1113V7.00009H11.9113V6.16809Z" fill="currentColor"/>
|
|
611
611
|
</svg>
|
|
612
|
-
`,Ar=w("text-commands");function g6(n){const t={id:"more",name:
|
|
612
|
+
`,Ar=w("text-commands");function g6(n){const t={id:"more",name:T.t("commands.more"),icon:p5,childrenType:"menu",childrenPlacement:"bottom-start",manualShowChildren:!0,children:[]},e={"style-bold":[T.t("commands.bold"),xt.isMac?T.t("commandDesc.mac.bold"):T.t("commandDesc.window.bold"),NP],"style-italic":[T.t("commands.italic"),xt.isMac?T.t("commandDesc.mac.italic"):T.t("commandDesc.window.italic"),PP],"style-underline":[T.t("commands.underline"),xt.isMac?T.t("commandDesc.mac.underline"):T.t("commandDesc.window.underline"),$P],"style-strikethrough":[T.t("commands.strikethrough"),xt.isMac?T.t("commandDesc.mac.strikethrough"):T.t("commandDesc.window.strikethrough"),_P],"style-code":[T.t("commands.code"),void 0,FP]},o={"style-subscript":[T.t("commands.subscript"),void 0,HP],"style-superscript":[T.t("commands.superscript"),void 0,jP]};if(me(n)===0){const l=Object.entries(e).map(([c,[a,d,f]])=>({id:c,name:a,icon:f,desc:d}));return t.children=Object.entries(o).map(([c,[a,d,f]])=>({id:c,name:a,icon:f,desc:d})),l.concat(t)}const r=RP(n);function i([l,[c,a,d]]){const f=r.get(l);return f!==void 0?{id:l,name:c,value:f,states:f===!0?["checked"]:void 0,icon:d,desc:a}:{id:l,name:c,icon:d,desc:a}}const s=Object.entries(e).map(i);return t.children=Object.entries(o).map(i),s.concat(t)}function zP(n,t){const e=j(t),o=it(t),r=Je(n,t);return g6([]).map(i=>({blockId:e,blockType:o,blockKind:r,...i,groupIndex:500}))}function UP(n,t,e){u(Ar,e.isSimple(),"nor a simple range");const{start:o,end:r}=e;u(Ar,o.isSimple(),"is not a simple block position"),u(Ar,r.isSimple(),"is not a simple block position"),u(Ar,_(n,t),"invalid block type, not a text kind block");const i=j(t);u(Ar,o.blockId===i&&r.blockId===i,"invalid range");const s=n.getBlockText(t);let l=[];o.offset===r.offset?o.offset!==0&&(l=Gt(s,o.offset-1,1).middle):l=Gt(s,o.offset,r.offset-o.offset).middle;const c=it(t),a=Je(n,t);return g6(l).map((d,f)=>({blockId:i,blockType:c,blockKind:a,...d,groupIndex:500,order:f*100}))}function VP(n,t,e,o,r,i){if(!_(n,t))return!1;if(!o.startsWith("style-"))return Ar.warn(`unknown command: ${o}`),!1;const s=r==null?void 0:r.value,l=typeof s;if(l!=="string"&&l!=="number"&&l!=="boolean"&&l!=="undefined")return Ar.warn(`invalid value type, accept string | number | boolean | undefined, current is ${l}`),!1;const c=OP(n,t,e,o,s);return i.result=c,!0}const qP=w("text-command-provider");class Rn{constructor(t){h(this,"id","TextCommandProvider");h(this,"emptyTextBlockAttributes",new Map);h(this,"colorItem");h(this,"updateButtonColor",()=>{const t=Nd(this.editor,this.getEmptyTextBlockColor);this.colorItem.updateButtonColor(t)});h(this,"handleChangeColor",(t,e)=>{if(t==="color"||t==="backgroundColor")c0(this.editor,t,e,this.setEmptyTextBlockColor);else{const o=["clearAll","clearColor","clearBackground"];a0(this.editor,o[e],this.setEmptyTextBlockColor)}});h(this,"handleBeforePopupPalette",()=>{const t=Nd(this.editor,this.getEmptyTextBlockColor);this.colorItem.updatePaletteColor(t)});h(this,"getEmptyTextBlockColor",(t,e)=>{const o=this.getEmptyBlockTextAttributes(t,e);return sd(o)});h(this,"setEmptyTextBlockColor",(t,e,o,r)=>{var s;const i=(s=this.emptyTextBlockAttributes.get(e))!=null?s:{};ap(i,o,r),this.emptyTextBlockAttributes.set(e,i)});this.editor=t,this.colorItem=t.addCustom("text-color-item",()=>new bB(t)),this.colorItem.addListener("onClick",this.handleChangeColor),this.colorItem.addListener("beforePopup",this.handleBeforePopupPalette)}destroy(){this.colorItem.destroy()}getAvailableCommands(t,e,o){if(!_(t,e))return[];let r;G(t,e)===0?r=this.getCommandsOnEmptyText(t,e).map(Rn.toTextCommand):r=UP(t,e,o).map(Rn.toTextCommand),this.updateButtonColor();const s={...this.colorItem,blockId:j(e),blockKind:Je(t,e),blockType:it(e),groupIndex:500,order:350};return r.push(s),r}executeCommand(t,e,o,r,i,s){if(!_(t,e))return!1;let l=i.value;l===void 0&&(l=!r.value);const c=Rn.fromTextCommandId(r.id);return c.startsWith("style-")&&G(t,e)===0?this.executeCommandOnEmptyText(e,r,{value:l}):VP(t,e,o,c,{value:l},s)}executeCommandOnEmptyText(t,e,o){let r=this.emptyTextBlockAttributes.get(j(t));r||(r={},this.emptyTextBlockAttributes.set(j(t),r));const i=Rn.fromTextCommandId(e.id),s=o.value;return s==null||s===!1?(delete r[i],!0):(r[i]=o.value,!0)}getCommandsOnEmptyText(t,e){const o=zP(t,e);return this.setCommandsStates(o,e)}setCommandsStates(t,e){var i;const o=j(e),r=(i=this.emptyTextBlockAttributes.get(o))!=null?i:{};return t.map(s=>{const l=r[s.id],c=l?["checked"]:void 0;return s.children&&(s.children=this.setCommandsStates(s.children,e)),{...s,value:l,states:c}})}getEmptyBlockTextAttributes(t,e){var r;const o=Q.default((r=this.emptyTextBlockAttributes.get(e))!=null?r:{});if(Array.from(Object.entries(o)).forEach(([i,s])=>{s||delete o[i]}),Object.keys(o).length!==0)return o}static toTextCommand(t){return t.children&&(t.children=t.children.map(Rn.toTextCommand)),{...t,id:`text/${t.id}`}}static fromTextCommandId(t){const e="text/";return u(qP,t.startsWith(e),`invalid item id: ${t}`),t.substring(e.length)}static fromTextCommand(t){return{...t,id:this.fromTextCommandId(t.id)}}static toTextCommands(t){return t.map(Rn.toTextCommand)}static fromTextCommands(t){return t.map(Rn.fromTextCommand)}}const WP={commands:{bold:"\u7C97\u4F53",italic:"\u659C\u4F53",underline:"\u4E0B\u5212\u7EBF",strikethrough:"\u5220\u9664\u7EBF",code:"\u884C\u5185\u4EE3\u7801",subscript:"\u4E0B\u6807",superscript:"\u4E0A\u6807",more:"\u66F4\u591A"},commandDesc:{mac:{bold:"\u2318+B",italic:"\u2318+I",underline:"\u2318+U",strikethrough:"\u2318+D"},window:{bold:"Ctrl+B",italic:"Ctrl+I",underline:"Ctrl+U",strikethrough:"Ctrl+D"}}},GP={commands:{bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",code:"Inline Code",subscript:"Subscript",superscript:"Superscript",more:"More"},commandDesc:{mac:{bold:"\u2318+B",italic:"\u2318+I",underline:"\u2318+U",strikethrough:"\u2318+D"},window:{bold:"Ctrl+B",italic:"Ctrl+I",underline:"Ctrl+U",strikethrough:"Ctrl+D"}}};T.mergeLang({"zh-CN":WP,"en-US":GP});var p6=(n=>(n.Card="card",n.Preview="preview",n))(p6||{});const ZP=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
|
|
613
613
|
<g clip-path="url(#clip0)">
|
|
614
614
|
<path d="M6.01 10.4886C5.85 10.4886 5.7 10.4286 5.58 10.3086L3.98 8.71859C3.35 8.07859 3 7.23859 3 6.34859C3 5.45859 3.35 4.60859 3.98 3.97859C5.29 2.66859 7.41 2.66859 8.72 3.97859L10.31 5.56859C10.55 5.80859 10.55 6.18859 10.31 6.42859C10.07 6.66859 9.69 6.66859 9.45 6.42859L7.86 4.83859C7.03 4.00859 5.68 4.00859 4.85 4.83859C4.45 5.23859 4.23 5.77859 4.23 6.34859C4.23 6.91859 4.45 7.44859 4.85 7.85859L6.44 9.44859C6.68 9.68859 6.68 10.0686 6.44 10.3086C6.32 10.4286 6.16 10.4886 6.01 10.4886ZM11.65 14.9986C10.79 14.9986 9.93 14.6686 9.28 14.0186L7.4 12.1386C7.16 11.8986 7.16 11.5186 7.4 11.2786C7.64 11.0386 8.02 11.0386 8.26 11.2786L10.14 13.1586C10.97 13.9886 12.32 13.9886 13.15 13.1586C13.55 12.7586 13.77 12.2186 13.77 11.6486C13.77 11.0786 13.55 10.5486 13.15 10.1386L11.28 8.25859C11.04 8.01859 11.04 7.63859 11.28 7.39859C11.52 7.15859 11.9 7.15859 12.14 7.39859L14.02 9.27859C14.65 9.90859 15 10.7486 15 11.6486C15 12.5386 14.65 13.3886 14.02 14.0186C13.37 14.6686 12.51 14.9986 11.65 14.9986Z" fill="#5587F0"/>
|
|
615
615
|
<path d="M10.88 10.8604C10.67 11.0704 10.32 11.0704 10.1 10.8604L7.64004 8.40039C7.43004 8.19039 7.43004 7.84039 7.64004 7.62039C7.85004 7.41039 8.20004 7.41039 8.42004 7.62039L10.88 10.0804C11.1 10.3004 11.1 10.6404 10.88 10.8604Z" fill="#5587F0"/>
|
|
@@ -686,6 +686,6 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
|
|
|
686
686
|
</defs>
|
|
687
687
|
</svg>`,k6={dwg:[],rvt:[],skp:[],img:["image/png","image/jpg","image/jpeg","image/bmp","image/ico","image/icon","image/gif"],txt:["text/plain"],zip:["application/zip","application/x-rar-compressed","application/x-7z-compressed","application/x-tar","application/x-bzip2","application/java-archive"],ppt:["application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],excel:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pdf:["application/pdf"],word:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},Df={dwg:t$,rvt:e$,skp:n$,img:o$,txt:r$,zip:y6,rar:y6,ppt:i$,excel:s$,pdf:l$,word:c$};function w6(n,t){const e=Object.keys(k6);for(let r=0;r<e.length;r+=1){const i=e[r];if(k6[i].includes(t))return Df[i]}const o=Iu(n.toLowerCase());return Df[o]?Df[o]:a$}async function u$(n,t,e){var k;const{fileName:o,fileType:r,fileSize:i}=e,s=b("div",["card-root"],t),l=b("div",["file-icon"],s),{renderFileCardIcon:c}=((k=n.options.componentsOptions)==null?void 0:k.file)||{};if(!c)l.innerHTML=w6(o,r);else{const v=c&&await c(n,e);v?l.append(v):l.innerHTML=w6(o,r)}const a=b("div",["file-details"],s),d=Iu(o),f=o.length-d.length-3,m=b("div",["file-name"],a);f>0?(b("span",["file-name-pre"],m,o.slice(0,f)),b("span",[],m,o.slice(f))):m.textContent=o,b("div",["file-size"],a,Xm(i));const p=b("div",["file-actions"],s),A=b("button",["download"],p);return A.innerHTML=Sf,{card:s,downloadButton:A}}const UV="";function B6(n,t){const o=n.getBlockData(t).embedData,r=n.options.componentsOptions.file;if(r!=null&&r.onDownloadFile){r.onDownloadFile(n,o);return}const i=n.doc.buildResourceUrl(o.src,{downloadFileName:o.fileName});$l(i,o.fileName)}async function d$(n,t,e){const{embedData:o}=e,r=o,{card:i,downloadButton:s}=await u$(n,t,r);n.domEvents.addEventListener(s,"click",(l,c)=>{if(!c.target)return;const a=U(c.target);!a||B6(l,a)}),n.domEvents.addEventListener(i,"click",(l,c)=>{if(!c.target)return;const a=U(c.target);if(!a||xr(c,"button"))return;const d=l.options.componentsOptions.file;if(d!=null&&d.onClick){d.onClick(l,a,c);return}const m=l.getBlockData(a).embedData,p=l.doc.buildResourceUrl(m.src,{downloadFileName:m.fileName});$l(p,m.fileName)})}class h${constructor(){h(this,"group","file-card");h(this,"commands",[{id:"download",name:"Download",icon:Sf},{id:"sep",name:"",type:"separator"},{id:"to-link",name:"To link",icon:C6},{id:"to-card",name:"To card",icon:A6,states:["checked"]},{id:"sep",name:"",type:"separator"},{id:"add-comment",name:"Add Comment",icon:Ts}])}executeCommand(t,e,o){if(o.id==="to-link"){const r=z(e),i=V(r),s=K(e),l=t.getBlockData(e),{embedData:c}=l,a=c,d={id:P(),box:!0,type:"file",created:Date.now(),src:a.src,fileName:a.fileName,fileSize:a.fileSize,fileType:a.fileType};t.undoManager.runInGroup(()=>{t.deleteBlock(e);const f=[op(d)];t.insertTextBlock(f,i,s)})}else o.id==="download"?B6(t,e):o.id==="add-comment"&&la(t,e)}}function f$(n,t){const e=n.getBlockData(t),{embedData:o,id:r}=e,i=o;return{blockCommands:{"hovering-toolbar":new h$},abstract:i.fileName}}function m$(n,t,e,o){const{embedData:r}=t,i=r;return o==="html"?i.src?`<p><a href="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" >${i.fileName}</a></p>`:`<p>[${i.fileName}]</p>`:o==="markdown"?i.src?`})
|
|
688
688
|
`:`[${i.fileName}]
|
|
689
|
-
`:i.src?`[${i.fileName}](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:`[${i.fileName}]`}const g$={embedType:"office",createEmbedContent:d$,getBlockProperties:f$,convertTo:m$};function p$(n){const t=/(\s|^)(http|https):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$/;return t.test(n)?n.search(t):-1}function C$(n){const t=n.selection.range;if(!t.isCollapsed()||!t.isSimple())return;const{start:e}=t,o=n.getBlockById(e.blockId);if(!_(n,o))return;const r=n.getBlockText(o),s=ld(r).slice(0,e.offset),l=p$(s);if(l===-1)return;const c=s.slice(l),a=s.length;let d=Yi(l,a-l,r,"link",c);return d=po(d,a," ",null),n.setBlockText(o,d),n.selection.selectBlock(o,a+1),!0}const A$={Space:C$},VV="",b$={media:{upload:{failed:'<div class="line-1">{name} \u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">{name} \u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},v$={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}};x.mergeLang({"zh-CN":b$,"en-US":v$});var gn=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(gn||{}),ul=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(ul||{});const E6=10*1024*1024,y$=["wav","mp3","aac","ogg","webm","flac"],k$=["ogg","mp4","webm"],w$=()=>{};function I6(n){var d,f,m,p,A,k;const t=(d=n.getComponentOptions("media"))!=null?d:{},{allowedMedias:e,maxSize:o,callbacks:r}=t,i=(f=e==null?void 0:e.audio)!=null?f:y$,s=(m=e==null?void 0:e.video)!=null?m:k$,l=(p=o==null?void 0:o.audio)!=null?p:E6,c=(A=o==null?void 0:o.video)!=null?A:E6,a=(k=r==null?void 0:r.onError)!=null?k:w$;return{allowedMedias:{audio:i,video:s},maxSize:{audio:l,video:c},callbacks:{onError:a}}}const B$=w("file-utils");function E$(n){u(B$,n instanceof File,`The file: ${n} isn't instance of File`);const{name:t}=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function x6(n,t){const e=i=>i.map(s=>`.${s}`).join(","),{allowedMedias:o}=I6(n),r=o[t];return r?e(r):"*"}function I$(n,t,e){const{maxSize:o,callbacks:r,allowedMedias:i}=I6(t),{[e]:s}=o,{[e]:l}=i;if(s&&n.size>s){const a=new Error("media is too large");return a.code=`MaxMediaSize-${e}`,r!=null&&r.onError&&(r==null||r.onError(t,a)),a}const c=E$(n);if(l&&!l.includes(c)){const a=new Error(`media file is not allowed: ${c}`);return a.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(t,a)),a}return!0}function x$(n){return n===ul.Empty||n===ul.Error}const ue=w("media");class T${constructor(t){h(this,"mediaContainer",null);h(this,"media",null);h(this,"abstract",null);h(this,"handleMediaLoadError",(t,e)=>{if(!e.target||!(e.target instanceof Node)||!(e.target instanceof Element?e.target:e.target.parentElement))return;const r=U(e.target);if(!r||!r.contains(this.mediaContainer))return;const i=this.renderError();this.updateMediaContent(i)});h(this,"handleRetry",async t=>{if(t.readonly)return;u(ue,this.abstract,"no abstract");const{mediaType:e}=this.abstract,o=x6(t,e),r=await Qo(o);this.handleUploadFile(r)});h(this,"handleUploadFile",async t=>{u(ue,this.abstract,"no abstract"),u(ue,this.mediaContainer,"The media element not exist");const{editor:e}=this.options,{mediaType:o}=this.abstract,r=U(this.mediaContainer);u(ue,r,"The block element not exist");const i=e.getBlockData(r);if(!!I$(t,e,o)){try{const{resourceId:s}=await e.doc.uploadResource(t,{onProgress:f=>{this.renderProgress(f,t)}}),{name:l,type:c,size:a}=t,d={...i,embedData:{...i.embedData,src:s,fileName:l,fileSize:a,fileType:c}};e.updateBlockData(r,d)}catch{this.renderRetry()}H(r,"media-block-uploading")}});h(this,"destroy",()=>{this.mediaContainer=null});this.options=t}bindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(t){u(ue,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(t)}renderError(){u(ue,this.abstract,"no abstract");const{editor:t,createMediaElement:e}=this.options,{mediaIcon:o,mediaName:r}=this.abstract;u(ue,this.mediaContainer,"The media element not exist");const i=U(this.mediaContainer);u(ue,i,"The block element not exist");const s=t.getBlockData(i),l=s.embedData.src,c=b("div",["media-error","embed-selected-content","embed-hover-content"],null),a=b("span",["media-error-icon"],c);a.innerHTML=o;const d=b("div",[],c);d.innerHTML=x.t("media.load.failed",{name:r}),c.appendChild(d);const f=d.querySelector("a");return u(ue,f,"The element not exist"),t.domEvents.addEventListener(f,"click",(m,p)=>{if(p.preventDefault(),p.target instanceof HTMLElement&&p.target.tagName==="A"){const A=b("div",["media-element"],null),k=this.getResourceUrl(l),v=e(m,A,s,k);this.unbindMediaEvent(),this.media=v,this.bindMediaEvent(),this.updateMediaContent(A)}}),c}renderRetry(){u(ue,this.abstract,"no abstract");const{editor:t}=this.options,{mediaIcon:e,mediaName:o}=this.abstract,r=b("div",["media-error","embed-selected-content","embed-hover-content"],null),i=b("span",["media-error-icon"],r);i.innerHTML=e;const s=b("div",[],r);s.innerHTML=x.t("media.upload.failed",{name:o}),r.appendChild(s);const l=s.querySelector("a");u(ue,l,"The element not exist"),t.domEvents.addEventListener(l,"click",this.handleRetry),this.updateMediaContent(r)}renderProgress(t,e){u(ue,this.mediaContainer,"The media element not exist");const o=this.mediaContainer.querySelector(":scope .media-progress"),r=t===-1||t===100?100:t;if(o){const{updateProgressElement:i}=this.options;i(o,r)}else{const{createProgressElement:i}=this.options,s=U(this.mediaContainer);u(ue,s,"The element not exist"),M(s,"media-block-uploading");const l=b("div",["media-progress"],null);i(l,r,e),this.updateMediaContent(l)}}renderMediaElement(t){u(ue,this.mediaContainer,"The media element not exist");const e=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:o,updateMediaElement:r,editor:i}=this.options,s=this.getResourceUrl(t.embedData.src);if(e){const l=r(i,e,t,s);this.unbindMediaEvent(),this.media=l,this.bindMediaEvent()}else{const l=b("div",["media-element"],null),c=o(i,l,t,s);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent(),this.updateMediaContent(l)}}renderEmpty(){u(ue,this.abstract,"no abstract"),u(ue,this.mediaContainer,"The media element not exist");const t=b("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);t.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(t)}getResourceUrl(t){const{editor:e}=this.options;return e.doc.buildResourceUrl(t)}render(t,e){const{src:o}=t.embedData;(!this.mediaContainer||!e.contains(this.mediaContainer))&&(this.mediaContainer=b("div",["media"],e)),x$(o)?o===ul.Empty&&this.renderEmpty():this.renderMediaElement(t)}setAbstract(t){this.abstract=t}}w("media-embed");class T6{constructor(){h(this,"handleInsertEmptyEmbed",async(t,e)=>{var d;const{containerId:o,blockIndex:r}=e;let i;(d=e.data)!=null&&d.file&&(i=e.data.file);const s=x6(t,this.embedType);if(i=i!=null?i:await Qo(s,{}),!i)return null;const l={id:P(),type:"embed",embedType:this.embedType,embedData:{src:ul.Empty}},c=t.insertBlock(o,r,l);return await this.getMedia(t,l.id).handleUploadFile(i),c})}getMedia(t,e){const o=t.addCustom(`media-${e}`,()=>new T$({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return o.setAbstract({...this.abstract}),o}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:o,order:r,group:i}=this.abstract;return{name:o,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:r,group:i,subText:Ce(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,o){const{id:r}=o;this.getMedia(t,r).render(o,e)}handleUpdateBlock(t,e,o){const{id:r}=o,i=this.getMedia(t,r),s=st(e);return i.render(o,s),!0}handleDeleteBlock(t,e){const o=e.id;this.getMedia(t,o).destroy()}convertTo(t,e,o,r){const i=e.embedData,s=t.doc.buildResourceUrl(i.src,{withToken:!0});return r==="html"?`<${i.type} src="${s}" />`:r==="markdown"?``:s}}function S6(n,t){const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e),r=b("div",["uploading-progress-bar-value"],o);r.style.width=`${t}%`}function D6(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const S$=w("media-audio");class D$ extends T6{constructor(){super(...arguments);h(this,"embedType",gn.AUDIO);h(this,"abstract",{mediaIcon:Gw,mediaName:x.t(`media.${gn.AUDIO}.menuItem`),menuItem:x.t(`media.${gn.AUDIO}.menuItem`),order:800,mediaType:gn.AUDIO,group:"common"});h(this,"updateProgressElement",D6)}getBlockProperties(){return{abstract:`[${x.t(`media.${gn.AUDIO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["audio-container","embed-hover-content","embed-selected-content"],o),l=b("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=i,l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .audio-container > audio");return u(S$,s,"The media element not exist"),s.src!==i&&(s.src=i),s}createProgressElement(e,o){const r=b("audio",[],e);r.innerHTML="Your browser does not support the <code>audio</code> element.",r.controls=!0,r.src="about:blank",S6(e,o)}}const Lf=new D$;w("video-resizer");function L6(n){return n&&Te(n)&&Ne(n)==="video"}const L$=50;class M${constructor(t){h(this,"currentResizableElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&(e&&L6(e)&&this.disableBlockResize(e),t&&L6(t))){const o=this.getVideoElement(t);if(!o)return;this.enableBlockResize(t,o)}});h(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const o=t.getBlock();if(!o)return;const r=o.getBoundingClientRect().width,i=Math.min(Math.max(e.width,L$),r);this.currentResizableElement.style.width=`${i}px`});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const o=this.editor.getBlockData(e),{width:r}=this.currentResizableElement.getBoundingClientRect();this.editor.updateBlockData(e,{...o,width:r})});this.editor=t,$t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,$t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return st(t).querySelector(":scope .video-container > video")}disableBlockResize(t){const e=this.editor.findCustom(`${j(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const o=this.editor.addCustom(`${j(t)}-resizer`,()=>new sa(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));o.enableResize(t,e),o.removeListener("resizing",this.handleResizing),o.removeListener("resized",this.handleResized),o.addListener("resizing",this.handleResizing),o.addListener("resized",this.handleResized),this.currentResizableElement=e}}const R$=w("video");class O$ extends T6{constructor(){super(...arguments);h(this,"embedType",gn.VIDEO);h(this,"abstract",{mediaName:x.t(`media.${gn.VIDEO}.menuItem`),mediaIcon:Zw,menuItem:x.t(`media.${gn.VIDEO}.menuItem`),order:700,mediaType:gn.VIDEO,group:"common"});h(this,"updateProgressElement",D6);h(this,"createProgressElement",(e,o,r)=>{const i=b("video",["progress-video"],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,S6(e,o),Tr(r).then(s=>{const l=e.querySelector(".progress-video");l&&Pu(e)&&(l.src=s)})})}getBlockProperties(){return{abstract:`[${x.t(`media.${gn.VIDEO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["video-container","embed-selected-content","drag-preview-element"],o),l=b("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=i,e.addCustom("video-resizer",()=>new M$(e)),r.width&&(l.style.width=`${r.width}px`),l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .video-container > video");return u(R$,s,"The media element not exist"),s.src!==i&&(s.src=i),s}}const Mf=new O$,qV="",N$={version:{latest:"\u5F53\u524D\u7248\u672C",insert:"{name} \u6DFB\u52A0",delete:"{name} \u5220\u9664",goBack:"\u8FD4\u56DE",revertVersion:"\u8FD8\u539F\u5185\u5BB9",play:"\u64AD\u653E\u5386\u53F2\u64CD\u4F5C",versionList:"\u5386\u53F2\u7248\u672C {count}",unknown:"\u672A\u77E5\u7248\u672C",restoreFrom:"\u56DE\u6EDA\u81EA\u7248\u672C {from}",restoreInfo:"\u56DE\u6EDA\u7684\u7248\u672C\u6682\u4E0D\u652F\u6301\u4E0E\u4E0A\u4E00\u7248\u672C\u5BF9\u6BD4"}},P$={version:{latest:"Latest",insert:"Added by {name}",delete:"Deleted by {name}",goBack:"Back",revertVersion:"Revert",play:"Play",versionList:"Versions ({count})",unknown:"Unknown version",restoreFrom:"Reverted from {from}",restoreInfo:"The rolled back version does not currently support comparison with the previous version."}};x.mergeLang({"zh-CN":N$,"en-US":P$});var M6=(n=>(n.NEW="history-new",n.NEW_CHILD="history-new-child",n.DELETED="history-deleted",n.UPDATED="history-updated",n.HISTORY="history",n))(M6||{});const vi="--op-color",yi="--op-selected-color",WV="";class $${constructor(t){h(this,"root");this.content=t;const e=b("div",["dialog-root"],null);e.append(t),this.root=e}show(t=document.body){t.append(this.root)}hide(){this.root.remove()}destroy(){}}const{t:ki}=x,R6=w("version-list");class _${constructor(t){h(this,"activeVersionElement");h(this,"versionsList");h(this,"versionsListHeader");h(this,"handleClickVersionItem",t=>{const o=t.target.closest(".dialog-version-list-item");if(this.isVersionElement(o)){this.toggleActiveVersionElement(o);const r=this.getVersionFromElement(o),{onSelectVersion:i}=this.options;i(r)}});this.options=t;const{versions:e,defaultSelectedIndex:o=0}=t,r=b("div",["version-dialog-list-header"],null,"count");r.innerText=ki("version.versionList",{count:`${e.length}`});const i=b("div",["version-dialog-list"],null),s=this.convertVersionsToFragment(e);i.append(s);const l=i.children[o];M(l,"active"),this.activeVersionElement=l,this.versionsList=i,this.versionsListHeader=r,i.onclick=this.handleClickVersionItem}get isSelectedFirstVersion(){return!!this.activeVersionElement&&this.versionsList.firstChild===this.activeVersionElement}get isSelectedLastVersion(){return!!this.activeVersionElement&&this.versionsList.lastChild===this.activeVersionElement}get beforeVersion(){return u(R6,this.activeVersionElement,"No active version element"),this.activeVersionElement.nextElementSibling?this.activeVersionElement.nextElementSibling.versionData:null}get beforeMajorVersion(){u(R6,this.activeVersionElement,"No active version element");let t=this.activeVersionElement.nextElementSibling;for(;t;){if(t.versionData.type)return t.versionData;t=t.nextElementSibling}return null}convertVersionsToFragment(t){const e=document.createDocumentFragment(),o=i=>{var l;let s;if(i.version!==-1){const c=new Date((l=i.created)!=null?l:i.version);s=`${c.toLocaleDateString()} ${c.toLocaleTimeString()}`}else s=ki("version.latest");return s},r=(i,s,l,c=!1)=>{var p;const a=b("div",["dialog-version-list-item"],e);a.versionData=i,s&&M(a,"child");const d=b("div",["dialog-version-list-item-title"],a);if(b("div",["dialog-version-list-item-date"],d,o(i)),c&&b("div",["dialog-version-list-item-now-ver"],d,ki("version.latest")),typeof i.source=="object"&&((p=i.source)==null?void 0:p.restore)){const A=i.source.restore,k=l.find(R=>R.version==A),v=k?o(k):ki("version.unknown"),T=ki("version.restoreFrom",{from:v}),E=ki("version.restoreInfo"),L=b("div",["dialog-version-item-from-container"],a);b("div",["dialog-version-item-from-main"],L,T),b("div",["dialog-version-item-from-info"],L,E)}const f=b("ul",["dialog-version-list-item-authors"],a),m=A=>{const k=b("li",["dialog-version-list-item-author"],f),v=b("span",["dialog-version-list-item-mark-author"],k);v.style.background=this.options.getMarkColor(A),b("span",["dialog-version-list-item-author-name"],k,A.displayName)};if(this.options.useCreatedBy)if(i.createdBy){const A=i.createdBy;m(A)}else i.authors&&i.authors.length>0&&i.authors.forEach(A=>{m(A)});else if(i.authors&&i.authors.length>0)i.authors.forEach(A=>{m(A)});else if(i.createdBy){const A=i.createdBy;m(A)}};return t.forEach((i,s)=>{r(i,!1,t,s===0),i.minorVersions&&i.minorVersions.length>0&&i.minorVersions.forEach(l=>{r(l,!0,t,!1)})}),e}isVersionElement(t){return t?rt(t,"dialog-version-list-item"):!1}getVersionFromElement(t){return t.versionData}get activeVersion(){return this.getVersionFromElement(this.activeVersionElement)}toggleActiveVersionElement(t){this.activeVersionElement!==t&&(H(this.activeVersionElement,"active"),M(t,"active"),this.activeVersionElement=t)}selectVersionByVersionNum(t){const e=Array.from(this.versionsList.children).find(o=>o.versionData.version===t);return this.isVersionElement(e)?(this.toggleActiveVersionElement(e),this.getVersionFromElement(e)):null}render(t){t.innerHTML="",t.append(this.versionsListHeader,this.versionsList)}destroy(){this.versionsList.onclick=null}}class F${constructor(t,e){this.doc=t,this.user=e}onDeleteBlock(t,e){this.doc.onDeleteBlock(t,e,this.user)}onInsertBlock(t,e,o){this.doc.onInsertBlock(t,e,o,this.user)}onUpdateBlockText(t,e,o){this.doc.onUpdateBlockText(t,e,o,this.user)}onUpdateBlockData(t,e,o){this.doc.onUpdateBlockData(t,e,o,this.user)}onCreateContainer(t,e){this.doc.onCreateContainer(t,e,this.user)}onCreateComment(){}onDeleteComment(){}onDeleteContainer(){}onUpdateComment(){}}function H$(n){return new Promise(t=>{setTimeout(t,n)})}async function j$(n,t,e,o){for(const r of e){const i=new F$(n,r.user);t.parseHistoryData(r,i),o.play&&await H$(o.speed||150)}}const z$=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
|
689
|
+
`:i.src?`[${i.fileName}](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:`[${i.fileName}]`}const g$={embedType:"office",createEmbedContent:d$,getBlockProperties:f$,convertTo:m$};function p$(n){const t=/(\s|^)(http|https):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])?$/;return t.test(n)?n.search(t):-1}function C$(n){const t=n.selection.range;if(!t.isCollapsed()||!t.isSimple())return;const{start:e}=t,o=n.getBlockById(e.blockId);if(!_(n,o))return;const r=n.getBlockText(o),s=ld(r).slice(0,e.offset),l=p$(s);if(l===-1)return;const c=s.slice(l),a=s.length;let d=Yi(l,a-l,r,"link",c);return d=po(d,a," ",null),n.setBlockText(o,d),n.selection.selectBlock(o,a+1),!0}const A$={Space:C$},VV="",b$={media:{upload:{failed:'<div class="line-1">{name} \u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">{name} \u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},v$={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}};T.mergeLang({"zh-CN":b$,"en-US":v$});var gn=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(gn||{}),ul=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(ul||{});const E6=10*1024*1024,y$=["wav","mp3","aac","ogg","webm","flac"],k$=["ogg","mp4","webm"],w$=()=>{};function I6(n){var d,f,m,p,A,k;const t=(d=n.getComponentOptions("media"))!=null?d:{},{allowedMedias:e,maxSize:o,callbacks:r}=t,i=(f=e==null?void 0:e.audio)!=null?f:y$,s=(m=e==null?void 0:e.video)!=null?m:k$,l=(p=o==null?void 0:o.audio)!=null?p:E6,c=(A=o==null?void 0:o.video)!=null?A:E6,a=(k=r==null?void 0:r.onError)!=null?k:w$;return{allowedMedias:{audio:i,video:s},maxSize:{audio:l,video:c},callbacks:{onError:a}}}const B$=w("file-utils");function E$(n){u(B$,n instanceof File,`The file: ${n} isn't instance of File`);const{name:t}=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function x6(n,t){const e=i=>i.map(s=>`.${s}`).join(","),{allowedMedias:o}=I6(n),r=o[t];return r?e(r):"*"}function I$(n,t,e){const{maxSize:o,callbacks:r,allowedMedias:i}=I6(t),{[e]:s}=o,{[e]:l}=i;if(s&&n.size>s){const a=new Error("media is too large");return a.code=`MaxMediaSize-${e}`,r!=null&&r.onError&&(r==null||r.onError(t,a)),a}const c=E$(n);if(l&&!l.includes(c)){const a=new Error(`media file is not allowed: ${c}`);return a.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(t,a)),a}return!0}function x$(n){return n===ul.Empty||n===ul.Error}const ue=w("media");class T${constructor(t){h(this,"mediaContainer",null);h(this,"media",null);h(this,"abstract",null);h(this,"handleMediaLoadError",(t,e)=>{if(!e.target||!(e.target instanceof Node)||!(e.target instanceof Element?e.target:e.target.parentElement))return;const r=U(e.target);if(!r||!r.contains(this.mediaContainer))return;const i=this.renderError();this.updateMediaContent(i)});h(this,"handleRetry",async t=>{if(t.readonly)return;u(ue,this.abstract,"no abstract");const{mediaType:e}=this.abstract,o=x6(t,e),r=await Qo(o);this.handleUploadFile(r)});h(this,"handleUploadFile",async t=>{u(ue,this.abstract,"no abstract"),u(ue,this.mediaContainer,"The media element not exist");const{editor:e}=this.options,{mediaType:o}=this.abstract,r=U(this.mediaContainer);u(ue,r,"The block element not exist");const i=e.getBlockData(r);if(!!I$(t,e,o)){try{const{resourceId:s}=await e.doc.uploadResource(t,{onProgress:f=>{this.renderProgress(f,t)}}),{name:l,type:c,size:a}=t,d={...i,embedData:{...i.embedData,src:s,fileName:l,fileSize:a,fileType:c}};e.updateBlockData(r,d)}catch{this.renderRetry()}H(r,"media-block-uploading")}});h(this,"destroy",()=>{this.mediaContainer=null});this.options=t}bindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(t){u(ue,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(t)}renderError(){u(ue,this.abstract,"no abstract");const{editor:t,createMediaElement:e}=this.options,{mediaIcon:o,mediaName:r}=this.abstract;u(ue,this.mediaContainer,"The media element not exist");const i=U(this.mediaContainer);u(ue,i,"The block element not exist");const s=t.getBlockData(i),l=s.embedData.src,c=b("div",["media-error","embed-selected-content","embed-hover-content"],null),a=b("span",["media-error-icon"],c);a.innerHTML=o;const d=b("div",[],c);d.innerHTML=T.t("media.load.failed",{name:r}),c.appendChild(d);const f=d.querySelector("a");return u(ue,f,"The element not exist"),t.domEvents.addEventListener(f,"click",(m,p)=>{if(p.preventDefault(),p.target instanceof HTMLElement&&p.target.tagName==="A"){const A=b("div",["media-element"],null),k=this.getResourceUrl(l),v=e(m,A,s,k);this.unbindMediaEvent(),this.media=v,this.bindMediaEvent(),this.updateMediaContent(A)}}),c}renderRetry(){u(ue,this.abstract,"no abstract");const{editor:t}=this.options,{mediaIcon:e,mediaName:o}=this.abstract,r=b("div",["media-error","embed-selected-content","embed-hover-content"],null),i=b("span",["media-error-icon"],r);i.innerHTML=e;const s=b("div",[],r);s.innerHTML=T.t("media.upload.failed",{name:o}),r.appendChild(s);const l=s.querySelector("a");u(ue,l,"The element not exist"),t.domEvents.addEventListener(l,"click",this.handleRetry),this.updateMediaContent(r)}renderProgress(t,e){u(ue,this.mediaContainer,"The media element not exist");const o=this.mediaContainer.querySelector(":scope .media-progress"),r=t===-1||t===100?100:t;if(o){const{updateProgressElement:i}=this.options;i(o,r)}else{const{createProgressElement:i}=this.options,s=U(this.mediaContainer);u(ue,s,"The element not exist"),M(s,"media-block-uploading");const l=b("div",["media-progress"],null);i(l,r,e),this.updateMediaContent(l)}}renderMediaElement(t){u(ue,this.mediaContainer,"The media element not exist");const e=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:o,updateMediaElement:r,editor:i}=this.options,s=this.getResourceUrl(t.embedData.src);if(e){const l=r(i,e,t,s);this.unbindMediaEvent(),this.media=l,this.bindMediaEvent()}else{const l=b("div",["media-element"],null),c=o(i,l,t,s);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent(),this.updateMediaContent(l)}}renderEmpty(){u(ue,this.abstract,"no abstract"),u(ue,this.mediaContainer,"The media element not exist");const t=b("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);t.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(t)}getResourceUrl(t){const{editor:e}=this.options;return e.doc.buildResourceUrl(t)}render(t,e){const{src:o}=t.embedData;(!this.mediaContainer||!e.contains(this.mediaContainer))&&(this.mediaContainer=b("div",["media"],e)),x$(o)?o===ul.Empty&&this.renderEmpty():this.renderMediaElement(t)}setAbstract(t){this.abstract=t}}w("media-embed");class T6{constructor(){h(this,"handleInsertEmptyEmbed",async(t,e)=>{var d;const{containerId:o,blockIndex:r}=e;let i;(d=e.data)!=null&&d.file&&(i=e.data.file);const s=x6(t,this.embedType);if(i=i!=null?i:await Qo(s,{}),!i)return null;const l={id:P(),type:"embed",embedType:this.embedType,embedData:{src:ul.Empty}},c=t.insertBlock(o,r,l);return await this.getMedia(t,l.id).handleUploadFile(i),c})}getMedia(t,e){const o=t.addCustom(`media-${e}`,()=>new T$({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return o.setAbstract({...this.abstract}),o}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:o,order:r,group:i}=this.abstract;return{name:o,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:r,group:i,subText:Ce(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,o){const{id:r}=o;this.getMedia(t,r).render(o,e)}handleUpdateBlock(t,e,o){const{id:r}=o,i=this.getMedia(t,r),s=st(e);return i.render(o,s),!0}handleDeleteBlock(t,e){const o=e.id;this.getMedia(t,o).destroy()}convertTo(t,e,o,r){const i=e.embedData,s=t.doc.buildResourceUrl(i.src,{withToken:!0});return r==="html"?`<${i.type} src="${s}" />`:r==="markdown"?``:s}}function S6(n,t){const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e),r=b("div",["uploading-progress-bar-value"],o);r.style.width=`${t}%`}function D6(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const S$=w("media-audio");class D$ extends T6{constructor(){super(...arguments);h(this,"embedType",gn.AUDIO);h(this,"abstract",{mediaIcon:Gw,mediaName:T.t(`media.${gn.AUDIO}.menuItem`),menuItem:T.t(`media.${gn.AUDIO}.menuItem`),order:800,mediaType:gn.AUDIO,group:"common"});h(this,"updateProgressElement",D6)}getBlockProperties(){return{abstract:`[${T.t(`media.${gn.AUDIO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["audio-container","embed-hover-content","embed-selected-content"],o),l=b("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=i,l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .audio-container > audio");return u(S$,s,"The media element not exist"),s.src!==i&&(s.src=i),s}createProgressElement(e,o){const r=b("audio",[],e);r.innerHTML="Your browser does not support the <code>audio</code> element.",r.controls=!0,r.src="about:blank",S6(e,o)}}const Lf=new D$;w("video-resizer");function L6(n){return n&&Te(n)&&Ne(n)==="video"}const L$=50;class M${constructor(t){h(this,"currentResizableElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&(e&&L6(e)&&this.disableBlockResize(e),t&&L6(t))){const o=this.getVideoElement(t);if(!o)return;this.enableBlockResize(t,o)}});h(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const o=t.getBlock();if(!o)return;const r=o.getBoundingClientRect().width,i=Math.min(Math.max(e.width,L$),r);this.currentResizableElement.style.width=`${i}px`});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const o=this.editor.getBlockData(e),{width:r}=this.currentResizableElement.getBoundingClientRect();this.editor.updateBlockData(e,{...o,width:r})});this.editor=t,$t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,$t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return st(t).querySelector(":scope .video-container > video")}disableBlockResize(t){const e=this.editor.findCustom(`${j(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const o=this.editor.addCustom(`${j(t)}-resizer`,()=>new sa(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));o.enableResize(t,e),o.removeListener("resizing",this.handleResizing),o.removeListener("resized",this.handleResized),o.addListener("resizing",this.handleResizing),o.addListener("resized",this.handleResized),this.currentResizableElement=e}}const R$=w("video");class O$ extends T6{constructor(){super(...arguments);h(this,"embedType",gn.VIDEO);h(this,"abstract",{mediaName:T.t(`media.${gn.VIDEO}.menuItem`),mediaIcon:Zw,menuItem:T.t(`media.${gn.VIDEO}.menuItem`),order:700,mediaType:gn.VIDEO,group:"common"});h(this,"updateProgressElement",D6);h(this,"createProgressElement",(e,o,r)=>{const i=b("video",["progress-video"],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,S6(e,o),Tr(r).then(s=>{const l=e.querySelector(".progress-video");l&&Pu(e)&&(l.src=s)})})}getBlockProperties(){return{abstract:`[${T.t(`media.${gn.VIDEO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["video-container","embed-selected-content","drag-preview-element"],o),l=b("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=i,e.addCustom("video-resizer",()=>new M$(e)),r.width&&(l.style.width=`${r.width}px`),l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .video-container > video");return u(R$,s,"The media element not exist"),s.src!==i&&(s.src=i),s}}const Mf=new O$,qV="",N$={version:{latest:"\u5F53\u524D\u7248\u672C",insert:"{name} \u6DFB\u52A0",delete:"{name} \u5220\u9664",goBack:"\u8FD4\u56DE",revertVersion:"\u8FD8\u539F\u5185\u5BB9",play:"\u64AD\u653E\u5386\u53F2\u64CD\u4F5C",versionList:"\u5386\u53F2\u7248\u672C {count}",unknown:"\u672A\u77E5\u7248\u672C",restoreFrom:"\u56DE\u6EDA\u81EA\u7248\u672C {from}",restoreInfo:"\u56DE\u6EDA\u7684\u7248\u672C\u6682\u4E0D\u652F\u6301\u4E0E\u4E0A\u4E00\u7248\u672C\u5BF9\u6BD4"}},P$={version:{latest:"Latest",insert:"Added by {name}",delete:"Deleted by {name}",goBack:"Back",revertVersion:"Revert",play:"Play",versionList:"Versions ({count})",unknown:"Unknown version",restoreFrom:"Reverted from {from}",restoreInfo:"The rolled back version does not currently support comparison with the previous version."}};T.mergeLang({"zh-CN":N$,"en-US":P$});var M6=(n=>(n.NEW="history-new",n.NEW_CHILD="history-new-child",n.DELETED="history-deleted",n.UPDATED="history-updated",n.HISTORY="history",n))(M6||{});const vi="--op-color",yi="--op-selected-color",WV="";class $${constructor(t){h(this,"root");this.content=t;const e=b("div",["dialog-root"],null);e.append(t),this.root=e}show(t=document.body){t.append(this.root)}hide(){this.root.remove()}destroy(){}}const{t:ki}=T,R6=w("version-list");class _${constructor(t){h(this,"activeVersionElement");h(this,"versionsList");h(this,"versionsListHeader");h(this,"handleClickVersionItem",t=>{const o=t.target.closest(".dialog-version-list-item");if(this.isVersionElement(o)){this.toggleActiveVersionElement(o);const r=this.getVersionFromElement(o),{onSelectVersion:i}=this.options;i(r)}});this.options=t;const{versions:e,defaultSelectedIndex:o=0}=t,r=b("div",["version-dialog-list-header"],null,"count");r.innerText=ki("version.versionList",{count:`${e.length}`});const i=b("div",["version-dialog-list"],null),s=this.convertVersionsToFragment(e);i.append(s);const l=i.children[o];M(l,"active"),this.activeVersionElement=l,this.versionsList=i,this.versionsListHeader=r,i.onclick=this.handleClickVersionItem}get isSelectedFirstVersion(){return!!this.activeVersionElement&&this.versionsList.firstChild===this.activeVersionElement}get isSelectedLastVersion(){return!!this.activeVersionElement&&this.versionsList.lastChild===this.activeVersionElement}get beforeVersion(){return u(R6,this.activeVersionElement,"No active version element"),this.activeVersionElement.nextElementSibling?this.activeVersionElement.nextElementSibling.versionData:null}get beforeMajorVersion(){u(R6,this.activeVersionElement,"No active version element");let t=this.activeVersionElement.nextElementSibling;for(;t;){if(t.versionData.type)return t.versionData;t=t.nextElementSibling}return null}convertVersionsToFragment(t){const e=document.createDocumentFragment(),o=i=>{var l;let s;if(i.version!==-1){const c=new Date((l=i.created)!=null?l:i.version);s=`${c.toLocaleDateString()} ${c.toLocaleTimeString()}`}else s=ki("version.latest");return s},r=(i,s,l,c=!1)=>{var p;const a=b("div",["dialog-version-list-item"],e);a.versionData=i,s&&M(a,"child");const d=b("div",["dialog-version-list-item-title"],a);if(b("div",["dialog-version-list-item-date"],d,o(i)),c&&b("div",["dialog-version-list-item-now-ver"],d,ki("version.latest")),typeof i.source=="object"&&((p=i.source)==null?void 0:p.restore)){const A=i.source.restore,k=l.find(R=>R.version==A),v=k?o(k):ki("version.unknown"),x=ki("version.restoreFrom",{from:v}),E=ki("version.restoreInfo"),L=b("div",["dialog-version-item-from-container"],a);b("div",["dialog-version-item-from-main"],L,x),b("div",["dialog-version-item-from-info"],L,E)}const f=b("ul",["dialog-version-list-item-authors"],a),m=A=>{const k=b("li",["dialog-version-list-item-author"],f),v=b("span",["dialog-version-list-item-mark-author"],k);v.style.background=this.options.getMarkColor(A),b("span",["dialog-version-list-item-author-name"],k,A.displayName)};if(this.options.useCreatedBy)if(i.createdBy){const A=i.createdBy;m(A)}else i.authors&&i.authors.length>0&&i.authors.forEach(A=>{m(A)});else if(i.authors&&i.authors.length>0)i.authors.forEach(A=>{m(A)});else if(i.createdBy){const A=i.createdBy;m(A)}};return t.forEach((i,s)=>{r(i,!1,t,s===0),i.minorVersions&&i.minorVersions.length>0&&i.minorVersions.forEach(l=>{r(l,!0,t,!1)})}),e}isVersionElement(t){return t?rt(t,"dialog-version-list-item"):!1}getVersionFromElement(t){return t.versionData}get activeVersion(){return this.getVersionFromElement(this.activeVersionElement)}toggleActiveVersionElement(t){this.activeVersionElement!==t&&(H(this.activeVersionElement,"active"),M(t,"active"),this.activeVersionElement=t)}selectVersionByVersionNum(t){const e=Array.from(this.versionsList.children).find(o=>o.versionData.version===t);return this.isVersionElement(e)?(this.toggleActiveVersionElement(e),this.getVersionFromElement(e)):null}render(t){t.innerHTML="",t.append(this.versionsListHeader,this.versionsList)}destroy(){this.versionsList.onclick=null}}class F${constructor(t,e){this.doc=t,this.user=e}onDeleteBlock(t,e){this.doc.onDeleteBlock(t,e,this.user)}onInsertBlock(t,e,o){this.doc.onInsertBlock(t,e,o,this.user)}onUpdateBlockText(t,e,o){this.doc.onUpdateBlockText(t,e,o,this.user)}onUpdateBlockData(t,e,o){this.doc.onUpdateBlockData(t,e,o,this.user)}onCreateContainer(t,e){this.doc.onCreateContainer(t,e,this.user)}onCreateComment(){}onDeleteComment(){}onDeleteContainer(){}onUpdateComment(){}}function H$(n){return new Promise(t=>{setTimeout(t,n)})}async function j$(n,t,e,o){for(const r of e){const i=new F$(n,r.user);t.parseHistoryData(r,i),o.play&&await H$(o.speed||150)}}const z$=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
|
|
690
690
|
<path d="M0 0h24v24H0z" fill="none"/><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
|
|
691
|
-
</svg>`,{t:Rf}=x;class U${constructor(t){h(this,"goBackButton");h(this,"playButton");h(this,"revertButton");this.options=t;const e=b("button",["dialog-text-button"],null),o=b("span",["dialog-button-icon"],e);o.innerHTML=z$,b("span",["dialog-button-text"],e,Rf("version.goBack"));const r=b("button",["dialog-version-button"],null,Rf("version.play")),i=b("button",["dialog-version-button"],null,Rf("version.revertVersion"));this.goBackButton=e,this.playButton=r,this.revertButton=i,this.bindEvent()}bindEvent(){const{onBack:t,onPlay:e,onRevert:o}=this.options;this.playButton.onclick=e,this.goBackButton.onclick=t,this.revertButton.onclick=o}disabledButton(){}render(t,e=!1){e||t.append(this.goBackButton,this.playButton,this.revertButton)}destroy(){this.playButton.onclick=null,this.goBackButton.onclick=null,this.revertButton.onclick=null}}const be=w("split-text-actions");function O6(n){return n.length>2?!1:n.length===1?n[0].insert!==void 0:(u(be,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].insert!==void 0)}function N6(n){return n.length>2?!1:n.length===1?n[0].delete!==void 0:(u(be,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].delete!==void 0)}function P6(n){return n.length>2?!1:n.length===1?n[0].insert===void 0&&n[0].delete===void 0&&n[0].attributes!==void 0:(u(be,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].attributes!==void 0)}function V$(n){const t=[],e=Q.default(n);if(e.length===0)return[];if(e.length===1)return[n];if(e.length===2&&(N6(n)||O6(n)||P6(n)))return[n];const o=(i,s)=>i>0?[{retain:i},s]:[s];let r=0;for(;e.length>0;){const i=e[0];if(i.retain!==void 0&&i.attributes===void 0){u(be,i.retain>0,`invalid text op: ${JSON.stringify(i)}`),u(be,e.length>1,`invalid text op: ${JSON.stringify(i)}`);const s=e[1];u(be,s.delete||s.insert!==void 0||s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=i.retain,t.push(o(r,s)),s.delete!==void 0?r-=s.delete:s.insert!==void 0?r+=s.insert.length:(u(be,s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),u(be,s.retain!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=s.retain),e.splice(0,2)}else u(be,i.delete||i.insert!==void 0||i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),t.push(o(r,i)),e.shift(),i.retain!==void 0&&(u(be,i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),r+=i.retain),i.insert&&(r+=i.insert.length)}return t}function $6(n){if(u(be,n.length===1||n.length===2,`not a single action op: ${JSON.stringify(n)}`),n.length===1)return 0;const t=n[0].retain;return u(be,typeof t=="number"&&t>0,`invalid retain: ${JSON.stringify(n)}`),t}let _6=0;function q$(n,t,e){const o=_6;_6+=1;const r=vt(n);return{insert:" ",attributes:{box:!0,id:P(),type:"history-deleted-box",user:e,created:Date.now(),text:r,deletedOffset:t,deletedOrder:o}}}function W$(n,t,e){const o=$6(t),r=t.length===1?t[0].delete:t[1].delete;u(be,typeof r=="number",`not a delete op: ${JSON.stringify(t)}`);const{left:i,middle:s,right:l}=Gt(n,o,r),c=q$(s,o,e);return[...i,c,...l]}function G$(n,t,e){const o=$6(t),r=t.length===1?t[0].insert:t[1].insert;u(be,typeof r=="string",`invalid insert op: ${JSON.stringify(t)}`);const i=t.length===1?t[0].attributes:t[1].attributes,l=Jl([{insert:r,attributes:i}],"insertedBy",e);return po(n,o,l,null)}function Z$(n,t,e){const o=V$(t).reverse();let r=n;for(const i of o)N6(i)?r=W$(r,i,e):O6(i)?r=G$(r,i,e):(u(be,P6(i),`unknown op: ${JSON.stringify(i)}`),r=ce.apply(r,i));return r}const Q$=w("history-update-block-text");function F6(n){const t=[],e=[];let o=0;return n.forEach(r=>{var i;if((i=r.attributes)!=null&&i.box){const s=r.attributes;if(s.type==="history-deleted-box"){t.push({boxData:s,offset:o});return}}e.push(r),o+=nd(r)}),t.sort((r,i)=>i.offset-r.offset),{deletedBoxes:t,newText:e}}function Y$(n,t,e){let o=n;return t.forEach(r=>{const i=ce.transformCursor(r.offset,e,!1);o=po(o,i,[{insert:" ",attributes:r.boxData}],null)}),o}function J$(n){n.sort((t,e)=>t.boxData.deletedOffset!==e.boxData.deletedOffset?t.boxData.deletedOffset-e.boxData.deletedOffset:t.boxData.deletedOrder-e.boxData.deletedOrder)}function K$(n){if(n.length<=1)return n;const t=n[0].offset;n.forEach(e=>{u(Q$,e.offset===t,`invalid boxes group, ${JSON.stringify(n)}`)}),J$(n);for(let e=n.length-1;e>=1;e--){const o=n[e],r=n[e-1];o.boxData.user.userId===r.boxData.user.userId&&(r.boxData.text+=o.boxData.text,n.splice(e,1))}return n}function X$(n){let{newText:t,deletedBoxes:e}=F6(n);const o=new Map;return e.forEach(i=>{let s=o.get(i.offset);s||(s=[],o.set(i.offset,s)),s.push(i),s.sort((l,c)=>l.boxData.deletedOffset-c.boxData.deletedOffset)}),Array.from(o.values()).sort((i,s)=>s[0].offset-i[0].offset).forEach(i=>{const s=i[0].offset;K$(i).reverse().forEach(l=>{t=po(t,s,[{insert:" ",attributes:l.boxData}],null)})}),t}function t_(n,t,e){let{newText:o,deletedBoxes:r}=F6(n);return o=Z$(o,t,e),o=Y$(o,r,t),o=X$(o),o}const On=w("history-doc");function Nn(n){u(On,!1,"no local actions for history doc")}class e_ extends Pi{constructor(e,o){super();h(this,"doc");h(this,"editor");this.doc=Q.default(e),this.editor=o}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Q.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);u(On,r,`no container data: ${e}`);const i=r[o];return u(On,i,`no block data: ${o}`),i}localUpdateBlockText(){Nn()}localUpdateBlockData(){Nn()}localInsertBlock(){Nn()}localDeleteBlock(){Nn()}localInsertChildContainer(){Nn()}localDeleteChildContainers(){Nn()}uploadResource(){Nn()}async addResources(e){Nn()}getServerMeta(){var e,o,r;return(r=(o=(e=this.editor.doc.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}buildResourceUrl(e){return this.editor.doc.externalDoc.buildResourceUrl(e)}request(){Nn()}broadcastMessage(){Nn()}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new vc}destroy(){this.clearCallbacks()}transformBlockIndex(e,o,r){const i=this.doc.blocks[e];u(On,i,`no container blocks: ${e}`);let s=0;for(let l=0;l<i.length;l++)if(!i[l].deletedBy){if(s===o)return l;s++}return r&&u(On,!1,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),u(On,s===o,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),i.length}onDeleteBlock(e,o,r){const i=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e][i];u(On,!l.deleted,`block has already deleted: ${e}/${o}`),l.deletedBy=r,this.callbacks.forEach(c=>{var a;return(a=c.onUpdateBlockData)==null?void 0:a.call(c,e,i,{insert:{},delete:[]},!0)})}onInsertBlock(e,o,r,i){const s=this.transformBlockIndex(e,o,!1),l=this.doc.blocks[e],c=Q.default(r);c.insertedBy=i,l.splice(s,0,c),this.callbacks.forEach(a=>{var d;return(d=a.onInsertBlock)==null?void 0:d.call(a,e,s,c,!0)})}onUpdateBlockText(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),c=this.doc.blocks[e][s];u(On,!c.deleted,`block has already deleted: ${e}/${o}`);const a=c.text;u(On,a,`no text for block: ${JSON.stringify(c)}`);const d=t_(a,r,i);c.text=d,this.callbacks.forEach(f=>{var m;return(m=f.onUpdateBlockText)==null?void 0:m.call(f,e,o,r,!0)})}onUpdateBlockData(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e],c=l[s];u(On,!c.deleted,`block has already deleted: ${e}/${o}`);const a=Q.default(c);a.updatedBy=i,r.delete.forEach(d=>delete a[d]),Object.entries(r.insert).forEach(([d,f])=>{a[d]=f}),l[s]=a,this.callbacks.forEach(d=>{var f;return(f=d.onUpdateBlockData)==null?void 0:f.call(d,e,s,r,!0)})}onCreateContainer(e,o,r){this.doc.blocks[e]=Q.default(o),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,!0)})}}const{t:H6}=x;function wi(n,t){return t==="insert"?H6("version.insert",{name:n.displayName}):H6("version.delete",{name:n.displayName})}function br(n,t){const{userId:e}=t;return["flag","selection"].reduce((r,i)=>{const s=n.doc.getRemoteUsers().getFixedUserColor(e,i);return r[i]=s,r},{})}class n_{renderText(t,e,o){if(!o.box&&o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=br(t,o.insertedBy);return{classes:["history-inserted-text"],attributes:{"history-inserted-by":r.displayName,"data-op-description":wi(r,"insert")},styles:{[vi]:i,[yi]:s}}}return{}}renderBlock(t,e,o){if(o.deletedBy){const r=o.deletedBy,{flag:i,selection:s}=br(t,r);return{classes:["history-deleted-block"],attributes:{"history-deleted-by":r.displayName,"data-op-description":wi(r,"delete")},styles:{[vi]:i,[yi]:s}}}if(o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=br(t,r);return{classes:["history-inserted-block"],attributes:{"history-inserted-by":r.displayName,"data-op-description":wi(r,"insert")},styles:{[vi]:i,[yi]:s}}}return{}}updateBlock(t,e,o,r){if(r.deletedBy){const i=r.deletedBy,{flag:s,selection:l}=br(t,i);M(o,"history-deleted-block"),fu(o,{"history-inserted-by":i.displayName,"data-op-description":wi(i,"delete")}),mu(o,{[vi]:s,[yi]:l});return}if(r.insertedBy){const i=r.insertedBy,{flag:s,selection:l}=br(t,i);M(o,"history-inserted-block"),fu(o,{"history-inserted-by":i.displayName,"data-op-description":wi(i,"insert")}),mu(o,{[vi]:s,[yi]:l})}}}const j6=w("history-deleted-box");function o_(n,t,e,o){const r=o;u(j6,r.text,`no text for text box data: ${JSON.stringify(o)}`),u(j6,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`);const i=b("span",["history-deleted-box"],e,r.text),s=r.user,{flag:l,selection:c}=br(n,s);i.setAttribute("history-deleted-by",s.displayName),i.setAttribute("data-op-description",wi(s,"delete")),i.style.setProperty(vi,l),i.style.setProperty(yi,c)}function r_(n,t,e,o){return t.text}const i_={boxType:"history-deleted-box",updateBoxContent:o_,convertTo:r_},Ee=w("version-dialog");class s_{constructor(t,e){h(this,"editor");h(this,"dialog",null);h(this,"oldViewer",null);h(this,"versionOptions");h(this,"versionList",null);h(this,"actionButtons",null);h(this,"provider");h(this,"components");h(this,"handleClose",()=>{var t;(t=this.dialog)==null||t.hide()});h(this,"handlePlay",()=>{var e;u(Ee,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;u(Ee,t,`The version: ${t} is invalid`),this.viewVersion(t,{play:!0,speed:150})});h(this,"handleRevert",async()=>{var e,o;u(Ee,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;u(Ee,t,`The version: ${t} is invalid`),await this.versionHelper.revertVersion(t.version),(o=this.dialog)==null||o.hide()});h(this,"handleSelectVersion",t=>{u(Ee,t,`The version: ${t} is invalid`),this.viewVersion(t)});h(this,"viewVersion",async(t,e={play:!1,speed:1e3})=>{var p,A,k;this.oldViewer&&(this.oldViewer.destroy(),this.oldViewer=null),u(Ee,this.versionList,"The versionList did not render"),u(Ee,this.actionButtons,"The actionButtons did not render");const o=t.type==="minor"?this.versionList.beforeVersion:this.versionList.beforeMajorVersion,r=o?o.version:0,i=this.versionList.isSelectedFirstVersion,s=this.versionList.isSelectedLastVersion;this.actionButtons.revertButton.disabled=i,this.actionButtons.playButton.disabled=i;let l=(p=this.versionOptions)==null?void 0:p.hideOps;if((A=this.versionOptions)!=null&&A.onWillChangeVersion){const v=this.versionOptions.onWillChangeVersion(this.editor,t,i,s);v!=null&&v.hideOps&&(l=!0)}let c,a;if(l)c=await this.versionHelper.getVersion(t.version),a=[];else{const v=await this.versionHelper.getHistoryData(t.version,r);c=v.doc,a=v.historyData}const{editorElement:d}=this.components;d.innerHTML="";const f=new e_(c,this.editor),m=this.provider.createHistoryEditor(d,f);m.editorBlockRenders.registerRender(new n_),m.editorBoxes.registerBoxClass(i_),M(m.rootElement,M6.HISTORY);try{await j$(f,this.versionHelper,a,e)}finally{this.oldViewer=m}(k=this.versionOptions)!=null&&k.onVersionChanged&&this.versionOptions.onVersionChanged(this.editor,m,t,i,s)});h(this,"setShowOps",t=>{var e;if(this.versionOptions){this.versionOptions.hideOps=!t;const o=(e=this.versionList)==null?void 0:e.activeVersion;u(Ee,o,`The version: ${o} is invalid`),this.viewVersion(o)}});this.editor=t,this.provider=e;const o=b("div",["version-dialog"],null),r=b("div",["version-dialog-note-viewer"],o),i=b("div",["version-dialog-action-container"],r),s=b("div",["version-dialog-editor"],r),l=b("div",["version-dialog-versions-list"],o);this.components={root:o,editorElement:s,actionContainer:i,versionsListContainer:l}}get versionHelper(){u(Ee,this.editor.doc.getVersionHelper,"Can not get getVersionHelper from doc");const t=this.editor.doc.getVersionHelper();return u(Ee,t,"current doc does not support version"),t}renderContent(t){var s,l;const{actionContainer:e,versionsListContainer:o}=this.components;e.innerHTML="";const r=new U$({onBack:this.handleClose,onPlay:this.handlePlay,onRevert:this.handleRevert});r.render(e,(s=this.versionOptions)==null?void 0:s.hideActions),this.actionButtons=r,o.innerHTML="";const i=new _$({versions:t,useCreatedBy:(l=this.versionOptions)==null?void 0:l.useCreatedBy,onSelectVersion:this.handleSelectVersion,getMarkColor:c=>{const{flag:a}=br(this.editor,c);return a}});i.render(o),this.versionList=i}initViewVersion(){var t;if((t=this.versionOptions)!=null&&t.initSelectedVersion){u(Ee,this.versionList,"The versionList did not render");const{initSelectedVersion:e}=this.versionOptions,o=this.versionList.selectVersionByVersionNum(e);u(Ee,o,`The version: ${o} is invalid`),this.viewVersion(o)}else{u(Ee,this.versionList,"The versionList did not render");const e=this.versionList.activeVersion;u(Ee,e,`The version: ${e} is invalid`),this.viewVersion(e)}}async show(t){this.versionOptions={...this.versionOptions,...t};const e=await this.versionHelper.getVersions();if(this.versionOptions.hideNonVersionedOps&&e.length&&e[0].version===-1&&e.shift(),this.versionOptions.onVersionsLoaded&&this.versionOptions.onVersionsLoaded(this.editor,e),this.renderContent(e),this.initViewVersion(),!this.dialog){const{root:o}=this.components;this.dialog=new $$(o)}this.dialog.show(t.container)}destroy(){var t,e,o;(t=this.dialog)==null||t.destroy(),(e=this.versionList)==null||e.destroy(),(o=this.actionButtons)==null||o.destroy()}}function l_(n,t,e){const o=n.addCustom("version-dialog",()=>new s_(n,t));return o.show(e),{setShowOps:o.setShowOps}}const GV="",c_=w("heading-collapse");function Of(n){var e;const t=Number.parseInt((e=n.getAttribute("data-style-heading"))!=null?e:"",10);return u(c_,t,"not a heading block"),t}function Ve(n){return!!n.getAttribute("data-style-heading")}function a_(n){return!rt(n,"heading-collapsed")}function vr(n){return rt(n,"heading-collapsed")}function z6(n){if(bt(n))return!1;const e=z(n);return Ct(e)}const u_=w("heading-collapse");function Nf(n){u(u_,Ve(n),"not a heading block");const t=[],e=Of(n);let o=dt(n);for(;o&&!(Ve(o)&&Of(o)<=e);)t.push(o),o=dt(o);return t}function U6(n,t){if(!Wn(t))return;n.selection.selectBlock(t,0),Nf(t).forEach(o=>{rg(o)}),M(t,"heading-collapsed")}function Bi(n,t){Nf(t).forEach(o=>{ig(o)}),H(t,"heading-collapsed")}function d_(n,t){a_(t)?U6(n,t):Bi(n,t)}const h_=[Ch,Ah,bh,vh,yh,kh,wh,Bh];function f_(n){const t=b("button",["heading-collapse-button"],null);return t.setAttribute(`data-editor-tooltip-${n.clientId}`,"Collapse / Expand"),t.innerHTML=ph,t}function V6(n){return ga(n).querySelector("button.heading-collapse-button")}function q6(n,t){V6(t)||z6(t)||!Wn(t)||G1(t,f_(n),-1)}function m_(n){var t;(t=V6(n))==null||t.remove()}function W6(n,t){ga(t).querySelector("button.heading-collapse-button")||q6(n,t)}function g_(n){const t=Of(n),e=b("button",["heading-marker"],null);return e.innerHTML=h_[t-1],e}function G6(n){return ga(n).querySelector("button.heading-marker")}function Pf(n){G6(n)||z6(n)||!Wn(n)||G1(n,g_(n),1)}function Z6(n){const t=G6(n);t==null||t.remove()}function Q6(n){Z6(n),Ve(n)&&Pf(n)}class p_{handleDrop(t,e,o,r){if(Pl(e)||!Ve(e)||!vr(e))return;const i=Nf(e);i.unshift(e);const s=i.reverse();let l=null;return t.doc.beginBatchUpdate(),s.forEach((c,a,d)=>{const f=t.getBlockData(c),m=bo(t.editorBlocks,t.doc.toJSON(),f),p=t.insertDocAt(o,r,m)[0];a===d.length-1&&(l=p)}),t.doc.endBatchUpdate(),t.doc.beginBatchUpdate(),s.forEach(c=>{t.deleteBlock(c)}),t.doc.endBatchUpdate(),l&&U6(t,l),!0}}const C_=w("heading-collapse");class A_{constructor(t){h(this,"handleLoad",()=>{this.showCollapseButtons()});h(this,"handleHoverBlock",(t,e)=>{e&&(H(e,"hovering-heading"),Ve(e)&&Ct(z(e))&&(Pf(e),vr(e)||m_(e))),t&&Ve(t)&&Ct(z(t))&&(M(t,"hovering-heading"),Z6(t),q6(this.editor,t))});h(this,"handleClick",(t,e)=>{const o=xr(e,"button.heading-collapse-button");if(!o)return;const r=U(o);!r||(u(C_,Ve(r),"not a heading block"),d_(this.editor,r),W6(this.editor,r))});this.editor=t,t.addListener("load",this.handleLoad),t.addListener("click",this.handleClick),$t.get(t).addListener("change",this.handleHoverBlock),this.showCollapseButtons(),setTimeout(()=>{ol.get(t).addHandler(new p_)})}showCollapseButtons(){const t=Mt(this.editor.rootContainer).filter(Ve);t.length!==0&&(t[0]===Ft(this.editor.rootContainer)&&t.splice(0,1),t.forEach(Pf))}destroy(){this.editor.removeListener("load",this.handleLoad),this.editor.removeListener("click",this.handleClick)}}function La(n){const t=n.selection.range;if(t.isCollapsed()||t.start.blockId===t.end.blockId)return;const e=n.getBlockById(t.start.blockId),o=n.getBlockById(t.end.blockId);vr(e)&&Bi(n,e),vr(o)&&Bi(n,o)}function b_(n){La(n);const t=n.getFocusedBlock();!Ve(t)||vr(t)&&Bi(n,t)}function v_(n){La(n);const t=n.getFocusedBlock();if(!Ve(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===G(n,t)&&vr(t)&&Bi(n,t)}function y_(n){La(n);const t=n.getFocusedBlock();if(!Ve(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===0&&vr(t)&&Bi(n,t)}class k_{handleBeforeKeyDown(t,e){return vu(e.key)&&La(t),e.key==="Enter"?(b_(t),!1):e.key==="Delete"?(v_(t),!1):(e.key==="Backspace"&&y_(t),!1)}}class w_{constructor(t){this.editor=t}onInsertBlock(t,e,o,r){this.updateBlockIfNeeded(o.id)}onUpdateBlockData(t,e,o,r){const i=this.editor.doc.getBlockData(t,e);this.updateBlockIfNeeded(i.id,o)}updateBlockIfNeeded(t,e){setTimeout(()=>{const o=this.editor.findBlockById(t);if(!!o){if(!Ve(o)){e&&e.delete.includes("heading")&&Q6(o);return}rt(o,"hovering-heading")&&W6(this.editor,o),Q6(o)}},100)}}function B_(n){return!!n.heading}function Y6(n){var e;const t=n.heading;return(e=Number.parseInt(`${t}`,10))!=null?e:1}function J6(n,t){var e;return{parentNode:t,children:[],text:vt((e=n.text)!=null?e:[]),level:Y6(n),block:n}}class dl{constructor(){h(this,"nodes",[])}appendBlock(t){const e=this.findParent(Y6(t),this.nodes);e?e.children.push(J6(t,e)):this.nodes.push(J6(t,null))}findParent(t,e){const o=e[e.length-1];if(!o||t<=1)return null;if(o.level===t-1)return o;const r=this.findParent(t,o.children);return r||(o.level<t?o:null)}static buildToc(t){const e=new dl,o=t.blocks.root;for(let r=0;r<o.length;r++){const i=o[r];B_(i)&&e.appendBlock(i)}return e}}class yr extends Yt.TypedEmitter{constructor(e){super();h(this,"toc",new dl);h(this,"updateToc",ee.default(()=>{this.updateTocNow()},500));this.editor=e,e.doc.registerCallback(this),this.updateToc()}destroy(){this.editor.doc.unregisterCallback(this)}isHeadingBlock(e){return!!e.heading}onInsertBlock(e,o,r,i){e==="root"&&this.isHeadingBlock(r)&&this.updateToc()}onDeleteBlock(e,o,r){e==="root"&&this.updateToc()}onUpdateBlockText(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}onUpdateBlockData(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}static register(e){return e.addCustom("editor-toc",()=>new yr(e))}static get(e){return e.getCustom("editor-toc")}updateTocNow(){this.toc=dl.buildToc(this.editor.doc.toJSON()),this.emit("change",this.editor,this.toc)}}const ZV="";function E_(n){return n.nodes.length===0?!0:n.nodes.length>1?!1:n.nodes[0].children.length===0}function $f(n,t){t.forEach(e=>{const o=b("div",["toc-node"],n),r=b("div",["toc-title"],o);if(b("span",["toc-text"],r,e.text).setAttribute("data-block-id",e.block.id),e.children.length>0){const s=b("div",["toc-children"],o);$f(s,e.children)}})}function I_(n,t){const e=xr(t,".toc-text");if(!e)return;const o=e.getAttribute("data-block-id");if(!o)return;const r=n.findBlockById(o);!r||(t.preventDefault(),t.stopPropagation(),n.selection.selectBlock(r,0))}function K6(n,t,e){if(H(t,"loading"),t.innerHTML="",E_(e)){b("div",["toc-empty-message"],t,"No toc");return}e.nodes.length===1?$f(t,e.nodes[0].children):$f(t,e.nodes),Jd(n,"toc-click-handler",()=>{n.addListener("click",I_)})}class x_{constructor(t){h(this,"handleUpdateToc",(t,e)=>{Array.from(t.rootContainer.querySelectorAll('.embed-block[data-type="editor-block"][data-embed-type="toc"]')).forEach(r=>{const i=r.querySelector(".editor-toc-container");i&&K6(t,i,e)})});this.editor=t,yr.register(t).addListener("change",this.handleUpdateToc)}destroy(){yr.register(this.editor).removeListener("change",this.handleUpdateToc)}get toc(){return yr.register(this.editor).toc}}function T_(n,t){const e=b("div",["editor-toc-container"],t),r=n.addCustom("init-editor-toc",()=>new x_(n)).toc;r.nodes.length===0?M(e,"loading"):K6(n,e,r)}function S_(n,t,e,o){return o==="markdown"?"[toc]":""}function D_(n,t,e){const{data:o}=e;if(!o||o.embedType!=="toc"||!_(n,t))return null;const r={};return{blockData:{id:P(),type:"embed",embedType:"toc",embedData:r}}}const X6={embedType:"toc",createEmbedContent:T_,convertTo:S_,convertFrom:D_};function L_(n){return!!n.getAttribute("data-style-heading")}function _f(n,t){return L_(t)&&G(n,t)>0}function M_(n){const t=bn(n.rootElement);let e=0,o=0,r=0;if(t===document.documentElement){const i=n.rootContainer.getBoundingClientRect();e=i.left+i.width/2,o=10,r=t.offsetHeight}else{const i=t.getBoundingClientRect();e=i.left+i.width/2,o=i.top+10,r=i.bottom}for(;o<r;){const i=document.elementsFromPoint(e,o);for(let s=0;s<i.length;s++){const l=U(i[s]);if(l&&n.rootContainer.contains(l))return l}o+=10}return null}function Ff(n,t){let e=t;for(;e&&!_f(n,e);)e=dt(e);return e}function t9(n){if(bt(n))return!1;const e=z(n);return Ct(e)}function Ma(n,t){let e=t;for(;e&&!_f(n,e);)e=bt(e),e&&t9(e)&&(e=null);return e}const R_=.3;class O_ extends Yt.TypedEmitter{constructor(e){super();h(this,"scrollContainer");h(this,"scrollEventTarget");h(this,"scrollStatus",{curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null});h(this,"handleScroll",ee.default(()=>{const e={curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null};let o=M_(this.editor);if(o&&(o=_u(o)),!o||!this.scrollContainer){this.setStatus(e);return}if(t9(o)&&(o=dt(o)),!o){this.setStatus(e);return}if(_f(this.editor,o)){e.curHeadingBlock=o,e.previousHeadingBlock=Ma(this.editor,o),e.nextHeadingBlock=Ff(this.editor,o),this.setStatus(e);return}const r=this.scrollContainer.getBoundingClientRect(),i=Ff(this.editor,o);if(i){const l=i.getBoundingClientRect();if(l.top>r.top&&l.top<r.top+r.height*R_){e.curHeadingBlock=i,e.previousHeadingBlock=Ma(this.editor,i),e.nextHeadingBlock=Ff(this.editor,i),this.setStatus(e);return}e.nextHeadingBlock=i}const s=Ma(this.editor,o);s&&(e.curHeadingBlock=s,e.previousHeadingBlock=Ma(this.editor,s)),this.setStatus(e)},200));this.editor=e,setTimeout(()=>{this.start()},50)}setStatus(e){this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock&&this.scrollStatus.nextHeadingBlock===e.nextHeadingBlock&&this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock||(this.scrollStatus=e,this.emit("change",this.editor,e))}start(){this.stop(),this.scrollContainer=bn(this.editor.rootElement),this.scrollEventTarget=this.scrollContainer===document.documentElement?document:this.scrollContainer,this.scrollEventTarget.addEventListener("scroll",this.handleScroll),this.handleScroll()}stop(){this.scrollEventTarget&&this.scrollEventTarget.removeEventListener("scroll",this.handleScroll)}destroy(){this.stop(),this.scrollEventTarget=void 0}}class N_{constructor(t,e){h(this,"suggest");h(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Wn(i)){const s=U(z(i));if(s&&it(s)==="code")return!1}return!0});h(this,"onClickItem",(t,e,o)=>{const r=e.data,i={id:P(),type:"mention",box:!0,created:Date.now(),iconUrl:r.avatarUrl,text:r.displayName,mentionId:r.userId},s=this.editor.selection.range;if(!s.isCollapsed()||!s.isSimple())return;const l=s.focus,c=this.editor.getBlockById(l.blockId);this.editor.insertBoxToBlock(c,l.offset,i)});h(this,"queryItems",async(t,e)=>(await this.options.queryUsers(this.editor,e)).map(i=>({id:i.userId,name:i.displayName,icon:`<img src="${i.avatarUrl}" class="mention-user-avatar">`,element:i.element,data:i,subText:i.email})));this.editor=t,this.options=e,this.suggest=new Mh(t,{id:"editor-mention",trigger:["@"],autoDeleteTrigger:!0,showLoading:!0,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}destroy(){}}w("mathjax-box");function P_(n,t,e,o){const r=o,i=b("a",["mention-container"],e);b("span",["mention-name"],i,`@${r.text}`),i.setAttribute("data-mention-id",r.mentionId)}function $_(n,t,e){}function __(n,t,e,o){return`@${t.text}`}const Hf={boxType:"mention",updateBoxContent:P_,handleClickBox:$_,convertTo:__};function F_(n){const t=b("div",["mention-button-wrap"],null),e=Bo("mention-button",x.t("list.mention.tooltip"),iB,[],n.clientId);return t.appendChild(e),t}class H_{constructor(t){h(this,"mentionButton");h(this,"handleHoveringBlock",t=>{var e;!this.editor.isWritable()||(t&&this.shouldBlockShowMention(t)?Rt(t).appendChild(this.mentionButton):(e=this.mentionButton)==null||e.remove())});h(this,"handleMouseDown",(t,e)=>{e.preventDefault(),e.stopPropagation();const o=U(this.mentionButton);if(!o||!_(t,o))return;const r=t.selection.range.focus;if(!r.isSimple())return;let i;t.selection.focusedBlock!==o?i=G(t,o):i=r.offset,setTimeout(()=>{const s=t.insertTextToBlock(o,i,"@");i+=1;const l=vt(ve(s,i).left);this.editor.selection.selectBlock(o,i),this.editor.focus(),t.getCustom("mention").suggest.popup(o,i,l,"@")})});h(this,"destroy",()=>{$t.get(this.editor).removeListener("change",this.handleHoveringBlock)});this.editor=t,this.mentionButton=F_(t),$t.get(this.editor).addListener("change",this.handleHoveringBlock),t.domEvents.addEventListener(this.mentionButton,"mousedown",this.handleMouseDown)}shouldBlockShowMention(t){if(!_(this.editor,t)||!ut(t))return!1;const e=ze(t);return!(e==="ordered"||e==="unordered")}}const QV="",j_={templates:{title:"\u9009\u62E9\u6A21\u677F\uFF0C\u5FEB\u901F\u521B\u5EFA",create:"\u65B0\u5EFA\u6A21\u677F",choose:"\u5168\u90E8\u6A21\u677F",customizedMark:"\u81EA\u5B9A\u4E49"}},z_={templates:{title:"Choose a template",create:"New template",choose:"All templates",customizedMark:"Custom"}};x.mergeLang({"zh-CN":j_,"en-US":z_});const YV="",U_="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cmVjdCB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTQ4IDU5QzQ4IDU0LjU4MTcgNTEuNTgxNyA1MSA1NiA1MUg5M0M5OC41MjI4IDUxIDEwMyA1NS40NzcyIDEwMyA2MVY4OEMxMDMgOTEuODY2IDk5Ljg2NiA5NSA5NiA5NUg1NkM1MS41ODE3IDk1IDQ4IDkxLjQxODMgNDggODdWNTlaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGQ9Ik0xOCA2NEMxOCA2Mi4zNDMxIDE5LjM0MzEgNjEgMjEgNjFINTZDNjAuNDE4MyA2MSA2NCA2NC41ODE3IDY0IDY5VjgzQzY0IDg1LjIwOTEgNjIuMjA5MSA4NyA2MCA4N0gyNkMyMS41ODE3IDg3IDE4IDgzLjQxODMgMTggNzlWNjRaIiBmaWxsPSIjRUFFNEY2Ii8+CjxyZWN0IHg9IjI0IiB5PSIzMSIgd2lkdGg9IjY1IiBoZWlnaHQ9IjUwIiByeD0iNSIgZmlsbD0iIzk5QzdGMiIvPgo8cmVjdCB4PSIzMy41IiB5PSI0MyIgd2lkdGg9IjQ2IiBoZWlnaHQ9IjUiIHJ4PSIyLjUiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjMzLjUiIHk9IjU0IiB3aWR0aD0iNDYiIGhlaWdodD0iNSIgcng9IjIuNSIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iMjQiIHk9IjMxIiB3aWR0aD0iNjUiIGhlaWdodD0iNTAiIHJ4PSI1IiBzdHJva2U9IiNGOEY4RjgiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01MCA4NS4yNjhDNTMuODI2MyA4My4wNTg5IDU1LjEzNzMgNzguMTY2MiA1Mi45MjgyIDc0LjMzOThMNjMuMzIwNSA2OC4zMzk4QzY4Ljg0MzMgNzcuOTA1NyA2NS41NjU4IDkwLjEzNzUgNTYgOTUuNjYwNEM0Ni40MzQxIDEwMS4xODMgMzQuMjAyMyA5Ny45MDU3IDI4LjY3OTQgODguMzM5OEwzOS4wNzE3IDgyLjMzOThDNDEuMjgwOSA4Ni4xNjYyIDQ2LjE3MzYgODcuNDc3MiA1MCA4NS4yNjhaIiBmaWxsPSIjQUI5M0RDIi8+CjxyZWN0IHg9IjU5IiB5PSI2NSIgd2lkdGg9IjQyIiBoZWlnaHQ9IjI4IiByeD0iNSIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTYzIDg4VjczLjA4MDhDNjMgNzEuNzA5NiA2My4zNjE0IDcwLjY4NjcgNjQuMDg0MSA3MC4wMTJDNjQuODI4NyA2OS4zMzczIDY1Ljg1OCA2OSA2Ny4xNzIgNjlIOTIuODYwOUM5NS42MjAzIDY5IDk3IDcwLjM2MDMgOTcgNzMuMDgwOFY4OEg5My41MTc5TDg3LjM3NDkgODAuNjIyQzg3LjA5MDIgODAuMzE3MyA4Ni43NjE3IDgwLjA4ODggODYuMzg5NCA3OS45MzY0Qzg2LjAxNzEgNzkuNzg0MSA4NS42NDQ4IDc5LjcwNzkgODUuMjcyNSA3OS43MDc5Qzg0LjkwMDIgNzkuNzA3OSA4NC41Mjc5IDc5Ljc4NDEgODQuMTU1NiA3OS45MzY0QzgzLjgwNTIgODAuMDg4OCA4My40NTQ4IDgwLjMxNzMgODMuMTA0MyA4MC42MjJMNzYuNzMxNCA4Ni4yMzcxTDc0LjIwMTkgODMuOTUxOUM3My42MzI1IDgzLjQyOTYgNzMuMDA4NCA4My4xNjg0IDcyLjMyOTUgODMuMTY4NEM3MS42NTA2IDgzLjE2ODQgNzEuMDM3NCA4My40Mjk2IDcwLjQ4OTkgODMuOTUxOUw2Ni40NDkzIDg4SDYzWk03NC40NjQ3IDgwLjYyMkM3NS4zNjI2IDgwLjYyMiA3Ni4xNDAxIDgwLjI5NTUgNzYuNzk3MSA3OS42NDI2Qzc3LjQ3NiA3OC45ODk3IDc3LjgxNTUgNzguMjE3MSA3Ny44MTU1IDc3LjMyNDdDNzcuODE1NSA3Ni40MTA3IDc3LjQ3NiA3NS42MzggNzYuNzk3MSA3NS4wMDY5Qzc2LjE0MDEgNzQuMzU0IDc1LjM2MjYgNzQuMDE2NiA3NC40NjQ3IDczLjk5NDhDNzMuNTQ0OSA3My45NTEzIDcyLjc1NjUgNzQuMjY2OSA3Mi4wOTk1IDc0Ljk0MTZDNzEuNDQyNSA3NS42MTYzIDcxLjExNCA3Ni40MTA3IDcxLjExNCA3Ny4zMjQ3QzcxLjExNCA3OC4yMTcxIDcxLjQ0MjUgNzguOTg5NyA3Mi4wOTk1IDc5LjY0MjZDNzIuNzU2NSA4MC4yOTU1IDczLjU0NDkgODAuNjIyIDc0LjQ2NDcgODAuNjIyWiIgZmlsbD0iI0Y3RDA3RiIvPgo8Y2lyY2xlIGN4PSI5NSIgY3k9IjQyIiByPSIyIiBzdHJva2U9IiM1MEMzOTgiIHN0cm9rZS13aWR0aD0iMiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTk0Ljc1MDEgMjQuNDY4N0wxMDAuNzgxIDI3LjkxNDlMOTQuNzE5IDMxLjQxNDlMOTQuNzUwMSAyNC40Njg3WiIgc3Ryb2tlPSIjNUNBNUVBIiBzdHJva2Utd2lkdGg9IjEuOCIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwNSAzOEMxMDUgMzguNTUyMyAxMDUuNDQ4IDM5IDEwNiAzOUMxMDYuNTUyIDM5IDEwNyAzOC41NTIzIDEwNyAzOFYzNkgxMDlDMTA5LjU1MiAzNiAxMTAgMzUuNTUyMyAxMTAgMzVDMTEwIDM0LjQ0NzcgMTA5LjU1MiAzNCAxMDkgMzRIMTA3VjMyQzEwNyAzMS40NDc3IDEwNi41NTIgMzEgMTA2IDMxQzEwNS40NDggMzEgMTA1IDMxLjQ0NzcgMTA1IDMyVjM0SDEwM0MxMDIuNDQ4IDM0IDEwMiAzNC40NDc3IDEwMiAzNUMxMDIgMzUuNTUyMyAxMDIuNDQ4IDM2IDEwMyAzNkgxMDVWMzhaIiBmaWxsPSIjQUI5M0RDIi8+Cjwvc3ZnPgo=",V_="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgdmlld0JveD0iMCAwIDM3MiAyNzkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8xMjU2XzM3MTY4KSI+CjxyZWN0IHdpZHRoPSIzNzIiIGhlaWdodD0iMjc5IiBmaWxsPSJ3aGl0ZSIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSIzOS41NzQ3IiB3aWR0aD0iMTE4LjcyMyIgaGVpZ2h0PSIxNS44Mjk4IiByeD0iNy45MTQ4OSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSI3MS4yMzM5IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSI5MS4wMjE1IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSIxMTAuODA5IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSI0MC41NjM4IiB5PSIxMzUuNTQzIiB3aWR0aD0iMjkwLjg3MiIgaGVpZ2h0PSIxMDAuOTE1IiByeD0iMi45NjgwOSIgc3Ryb2tlPSIjRUFGM0ZDIiBzdHJva2Utd2lkdGg9IjEuOTc4NzIiLz4KPHBhdGggZD0iTTM5LjU3NDUgMTM4LjUxMUMzOS41NzQ1IDEzNi4zMjUgNDEuMzQ2MyAxMzQuNTUzIDQzLjUzMTkgMTM0LjU1M0gzMjguNDY4QzMzMC42NTQgMTM0LjU1MyAzMzIuNDI2IDEzNi4zMjUgMzMyLjQyNiAxMzguNTExVjE1Mi4zNjJIMzkuNTc0NVYxMzguNTExWiIgZmlsbD0iI0Q2RTlGQSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTg3LjA2MzcgMTY5LjE4MUM4Ny4wNjM3IDE2Ny41NDIgODguMzkyNiAxNjYuMjEzIDkwLjAzMTggMTY2LjIxM0gzMTcuNTg1QzMxOS4yMjQgMTY2LjIxMyAzMjAuNTUzIDE2Ny41NDIgMzIwLjU1MyAxNjkuMTgxQzMyMC41NTMgMTcwLjgyIDMxOS4yMjQgMTcyLjE0OSAzMTcuNTg1IDE3Mi4xNDlIOTAuMDMxOEM4OC4zOTI2IDE3Mi4xNDkgODcuMDYzNyAxNzAuODIgODcuMDYzNyAxNjkuMTgxWk0xMDQuODcyIDE5Mi45MjZDMTA0Ljg3MiAxOTEuMjg2IDEwNi4yMDEgMTg5Ljk1NyAxMDcuODQgMTg5Ljk1N0gzMTcuNTg1QzMxOS4yMjQgMTg5Ljk1NyAzMjAuNTUzIDE5MS4yODYgMzIwLjU1MyAxOTIuOTI2QzMyMC41NTMgMTk0LjU2NSAzMTkuMjI0IDE5NS44OTQgMzE3LjU4NSAxOTUuODk0SDEwNy44NEMxMDYuMjAxIDE5NS44OTQgMTA0Ljg3MiAxOTQuNTY1IDEwNC44NzIgMTkyLjkyNlpNMTA3Ljg0IDIxMy43MDJDMTA2LjIwMSAyMTMuNzAyIDEwNC44NzIgMjE1LjAzMSAxMDQuODcyIDIxNi42N0MxMDQuODcyIDIxOC4zMDkgMTA2LjIwMSAyMTkuNjM4IDEwNy44NCAyMTkuNjM4SDMxNy41ODVDMzE5LjIyNCAyMTkuNjM4IDMyMC41NTMgMjE4LjMwOSAzMjAuNTUzIDIxNi42N0MzMjAuNTUzIDIxNS4wMzEgMzE5LjIyNCAyMTMuNzAyIDMxNy41ODUgMjEzLjcwMkgxMDcuODRaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNTEuNDQ2OCAxNjkuMTgxQzUxLjQ0NjggMTY3LjU0MiA1Mi43NzU2IDE2Ni4yMTMgNTQuNDE0OSAxNjYuMjEzSDYwLjM1MUM2MS45OTAzIDE2Ni4yMTMgNjMuMzE5MSAxNjcuNTQyIDYzLjMxOTEgMTY5LjE4MUM2My4zMTkxIDE3MC44MiA2MS45OTAzIDE3Mi4xNDkgNjAuMzUxIDE3Mi4xNDlINTQuNDE0OUM1Mi43NzU2IDE3Mi4xNDkgNTEuNDQ2OCAxNzAuODIgNTEuNDQ2OCAxNjkuMTgxWk01MS40NDY4IDE5Mi45MjZDNTEuNDQ2OCAxOTEuMjg2IDUyLjc3NTcgMTg5Ljk1NyA1NC40MTQ5IDE4OS45NTdINjAuMzUxMUM2MS45OTAzIDE4OS45NTcgNjMuMzE5MSAxOTEuMjg2IDYzLjMxOTEgMTkyLjkyNkM2My4zMTkxIDE5NC41NjUgNjEuOTkwMyAxOTUuODk0IDYwLjM1MTEgMTk1Ljg5NEg1NC40MTQ5QzUyLjc3NTcgMTk1Ljg5NCA1MS40NDY4IDE5NC41NjUgNTEuNDQ2OCAxOTIuOTI2Wk01NC40MTQ5IDIxMy43MDJDNTIuNzc1NyAyMTMuNzAyIDUxLjQ0NjggMjE1LjAzMSA1MS40NDY4IDIxNi42N0M1MS40NDY4IDIxOC4zMDkgNTIuNzc1NyAyMTkuNjM4IDU0LjQxNDkgMjE5LjYzOEg2MC4zNTExQzYxLjk5MDMgMjE5LjYzOCA2My4zMTkxIDIxOC4zMDkgNjMuMzE5MSAyMTYuNjdDNjMuMzE5MSAyMTUuMDMxIDYxLjk5MDMgMjEzLjcwMiA2MC4zNTExIDIxMy43MDJINTQuNDE0OVoiIGZpbGw9IiM5OUM3RjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik02OS4yNTU0IDE2OS4xODFDNjkuMjU1NCAxNjcuNTQyIDcwLjU4NDMgMTY2LjIxMyA3Mi4yMjM1IDE2Ni4yMTNINzguMTU5N0M3OS43OTg5IDE2Ni4yMTMgODEuMTI3OCAxNjcuNTQyIDgxLjEyNzggMTY5LjE4MUM4MS4xMjc4IDE3MC44MiA3OS43OTg5IDE3Mi4xNDkgNzguMTU5NyAxNzIuMTQ5SDcyLjIyMzVDNzAuNTg0MyAxNzIuMTQ5IDY5LjI1NTQgMTcwLjgyIDY5LjI1NTQgMTY5LjE4MVpNNjkuMjU1NCAxOTIuOTI2QzY5LjI1NTQgMTkxLjI4NiA3MC41ODQyIDE4OS45NTcgNzIuMjIzNSAxODkuOTU3SDc4LjE1OTZDNzkuNzk4OSAxODkuOTU3IDgxLjEyNzcgMTkxLjI4NiA4MS4xMjc3IDE5Mi45MjZDODEuMTI3NyAxOTQuNTY1IDc5Ljc5ODkgMTk1Ljg5NCA3OC4xNTk2IDE5NS44OTRINzIuMjIzNUM3MC41ODQyIDE5NS44OTQgNjkuMjU1NCAxOTQuNTY1IDY5LjI1NTQgMTkyLjkyNlpNNzIuMjIzNSAyMTMuNzAyQzcwLjU4NDIgMjEzLjcwMiA2OS4yNTU0IDIxNS4wMzEgNjkuMjU1NCAyMTYuNjdDNjkuMjU1NCAyMTguMzA5IDcwLjU4NDIgMjE5LjYzOCA3Mi4yMjM1IDIxOS42MzhINzguMTU5NkM3OS43OTg5IDIxOS42MzggODEuMTI3NyAyMTguMzA5IDgxLjEyNzcgMjE2LjY3QzgxLjEyNzcgMjE1LjAzMSA3OS43OTg5IDIxMy43MDIgNzguMTU5NiAyMTMuNzAySDcyLjIyMzVaIiBmaWxsPSIjRjdEMDdGIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuMDMxOCAxODkuOTU4Qzg4LjM5MjYgMTg5Ljk1OCA4Ny4wNjM3IDE5MS4yODYgODcuMDYzNyAxOTIuOTI2Qzg3LjA2MzcgMTk0LjU2NSA4OC4zOTI2IDE5NS44OTQgOTAuMDMxOCAxOTUuODk0SDk1Ljk2OEM5Ny42MDcyIDE5NS44OTQgOTguOTM2MSAxOTQuNTY1IDk4LjkzNjEgMTkyLjkyNkM5OC45MzYxIDE5MS4yODYgOTcuNjA3MiAxODkuOTU4IDk1Ljk2OCAxODkuOTU4SDkwLjAzMThaTTkwLjAzMTkgMjEzLjcwMkM4OC4zOTI3IDIxMy43MDIgODcuMDYzOCAyMTUuMDMxIDg3LjA2MzggMjE2LjY3Qzg3LjA2MzggMjE4LjMwOSA4OC4zOTI3IDIxOS42MzggOTAuMDMxOSAyMTkuNjM4SDk1Ljk2ODFDOTcuNjA3MyAyMTkuNjM4IDk4LjkzNjIgMjE4LjMwOSA5OC45MzYyIDIxNi42N0M5OC45MzYyIDIxNS4wMzEgOTcuNjA3MyAyMTMuNzAyIDk1Ljk2ODEgMjEzLjcwMkg5MC4wMzE5WiIgZmlsbD0iIzkxRDlCRSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEyNTZfMzcxNjgiPgo8cmVjdCB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",e9=w("templates");function jf(n){const t=n.rootElement.querySelector(":scope .editor-templates");if(!t)return null;const e=t.querySelector(":scope .editor-templates-cards");return u(e9,e,"no card container"),{root:t,cardContainer:e}}function q_(n){const t=jf(n);if(t)return t.cardContainer.innerHTML="",t;const e=b("div",["editor-templates"],n.rootElement);b("div",["editor-templates-title"],e,x.t("templates.title"));const o=b("div",["editor-templates-cards"],e);return{root:e,cardContainer:o}}function n9(n,t,e,o,r){var f;const i=(f=n.options.componentsOptions)==null?void 0:f.templates,s=b("div",["editor-template-card",...o],null),l=b("div",["editor-template-thumb-container"],s),c=b("img",["editor-template-thumb"],l);c.src=t,c.style.display="none",c.onerror=()=>{var p;const m=(p=i==null?void 0:i.placeHolderImageSrc)!=null?p:V_;c.src!==m&&(c.src=m)},c.onload=()=>{c.style.display=""};const a=b("div",["editor-template-name"],s),d=b("span",[],a,e);return i!=null&&i.showTemplateTitleAttr&&d.setAttribute("title",e),s.onclick=()=>r(s),s}function W_(n,t){return t.thumbnailUrl?t.thumbnailUrl:n.doc.buildResourceUrl("thumbnail.png")}function G_(n,t){const e=W_(n,t);return n9(n,e,t.name,[],async()=>{var r,i;const o=(r=n.options.componentsOptions)==null?void 0:r.templates;(i=o==null?void 0:o.onApplyTemplate)==null||i.call(o,n,t)})}function Z_(n,t){return n9(n,t,x.t("templates.choose"),["more"],()=>{var o,r;const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onChooseTemplate)==null||r.call(e,n)})}function Q_(n,t){var f,m;const e=(f=n.options.componentsOptions)==null?void 0:f.templates;if(!e)return;const r=Jt(n.rootContainer).getBoundingClientRect().width;let i=1;const s=U_,l=jf(n);if(l){if(t!=null&&t.reset){const p=Array.from(l.cardContainer.children),A=l.cardContainer.firstElementChild;if(u(e9,A,"no first card"),rt(A,"new")||rt(A,"more"))return;const k=window.getComputedStyle(A),v=parseFloat(k.marginLeft),T=parseFloat(k.marginRight),E=A.getBoundingClientRect().width+v+T;i=Math.floor(r/E);const R=Math.max(1,i-1-1),$=p.length-1;p.forEach((q,ot)=>{ot>R&&ot<$?q.style.display="none":(ot>=$&&rt(q,"more"),q.style.display="")})}return}const c=e.templates,{cardContainer:a}=q_(n);c.forEach((p,A)=>{const k=G_(n,p);if(A>0&&A>=i&&(k.style.display="none"),a.appendChild(k),A===0){const v=window.getComputedStyle(k),T=parseFloat(v.marginLeft),E=parseFloat(v.marginRight),L=k.getBoundingClientRect().width+T+E;i=Math.floor(r/L)-1}});const d=Z_(n,s);a.appendChild(d),(m=e==null?void 0:e.onTemplateChooserStatusChanged)==null||m.call(e,n,a,"visible")}const o9=ee.default(Q_,50);function Y_(n){var o,r;const t=jf(n);if(!t)return;t.root.remove();const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onTemplateChooserStatusChanged)==null||r.call(e,n,null,"hide")}function J_(n){const t=n.blocks.root;if(t.length===0)return!0;if(t.length>5)return!1;const e=[...t];e[0].type==="text"&&e[0].heading&&e.splice(0,1);const o=r=>{var i;return r.type!=="text"&&r.type!=="list"?!1:r.text?((i=r.text)==null?void 0:i.length)===0:!0};return e.every(r=>o(r))}function zf(n,t){J_(n.doc.toJSON())?o9(n,t):(o9.cancel(),Y_(n))}const K_=800;class X_{constructor(t){h(this,"longPressTimeout",0);h(this,"handleSelectionChange",()=>{});h(this,"handleLongPress",t=>{const e=t.touches[0],o=Vl(this.editor,e.clientX,e.clientY);!o||console.log(o)});h(this,"handleTouchStart",t=>{t.touches.length===1&&(this.longPressTimeout=window.setTimeout(()=>{this.handleLongPress(t)},K_))});h(this,"handleTouchEnd",t=>{this.longPressTimeout&&(window.clearTimeout(this.longPressTimeout),this.longPressTimeout=0)});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChange),document.addEventListener("touchstart",this.handleTouchStart),document.addEventListener("touchend",this.handleTouchEnd)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChange),document.removeEventListener("touchstart",this.handleTouchStart),document.removeEventListener("touchend",this.handleTouchEnd)}}class hl{constructor(t,e){h(this,"_decrypted",!1);this.editor=t,this.blockData=e}get decrypted(){return this._decrypted||this.blockData.owner===this.editor.doc.getUser().userId}setDecrypted(){this._decrypted=!0}destroy(){}static getState(t,e){return t.addCustom(`encrypted-block-${e.id}`,()=>new hl(t,e))}}const JV="",Po=w("encrypted-block");function tF(n,t,e,o,r){const i=r,s=lo(o,"div"),l=hl.getState(n,i);if(l.decrypted)n.createChildContainer(t,s,i.children[0]),M(o,"decrypted");else{M(o,"encrypted");const c=Rt(o),a=b("div",["password-container"],c),d=b("input",[],a);d.type="text",d.onkeydown=f=>{if(f.key==="Enter"){const m=d.value;if(i.password===Er.default(`${i.owner}-${m}`)){l.setDecrypted(),n.reloadBlock(o);const p=qu(n,n.getBlockById(i.id));p&&(n.selection.selectBlock(p,0),n.focus())}}}}return s}function eF(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!vn(r))return null;const i=r;if(n.getBlockData(t).children[0]!==V(i))return null;const l=Bt(t,V(i));return new tn(n,{anchor:l,focus:l})}function nF(n,t,e,o){if(hl.getState(n,n.getBlockData(t)).decrypted)return null;if(o==="ArrowDown"||o==="ArrowRight"){const s=dt(t);return s?F(s,G(n,s),"end"):F(t,1,"end")}const i=bt(t);return F(i||t,0,"home")}function oF(n,t){return n.getBoundingClientRect()}function rF(n,t,e,o){if(e.isSimple()){u(Po,o.isSimple(),"from is simple position but to is not simple position"),Po.debug("full select table"),M(t,"full-selected");return}u(Po,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;u(Po,r.blockId===i.blockId,"only allow update one table selection"),u(Po,r.childContainerId===i.childContainerId,"only one container");const s=n.getBlockData(t),l=n.getContainerById(s.children[0]);M(l,"selected")}function iF(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="encrypted"]').forEach(t=>{H(t,"full-selected"),t.querySelectorAll("selected").forEach(e=>{H(e,"selected")})})}function sF(n,t){const e=n.getBlockData(t);return hl.getState(n,e).decrypted?[n.getContainerById(e.children[0])]:[]}function lF(n,t,e,o,r){return null}function cF(n,t,e,o){u(Po,e.blockId===o.blockId,"only allow select in single block"),u(Po,j(t)===e.blockId,"only allow select in single block");const r=n.getBlockData(t);return u(Po,e.childContainerId===r.children[0],"only one container"),[n.getContainerById(r.children[0])]}function aF(n){return{name:"EncryptedBlock",insertBlockCommandItems:[{id:"insert-encrypted-block",name:"Encrypted Block"}],async handleInsertEmptyBlock(t,e){const o=Bn(t.doc),r={id:P(),type:"encrypted",children:[o],owner:t.doc.getUser().userId,ownerDisplayName:t.doc.getUser().displayName,password:Er.default(`${t.doc.getUser().userId}-1234`)},i=t.doc.getContainerBlocks(o)[0];return t.insertBlock(e.containerId,e.blockIndex,r,Ot(t,i.id,0))}}}function uF(n,t,e,o){return o==="text"||o==="markdown"?"[Encrypted Block]":"<p>[Encrypted Block]</p>"}const dF={blockType:"encrypted",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:tF,getBlockTextLength:()=>1,getRangeFromPoint:eF,moveCaret:nF,getCaretRect:oF,updateSelection:rF,clearSelection:iF,getChildContainers:sF,getNextContainer:lF,getSelectedContainers:cF,getOptions:aF,convertTo:uF};function hF(n,t,e){const o=hs(n,t,{components:{blocks:[Ws,Qs,dF],decorators:[new Js],embeds:[va,$1,cf,af,uf,k1,df,Mf,Lf],boxes:[ta],options:{...e.componentsOptions}}});return o.readonly=!0,o}class fF{constructor(t){this.createOptions=t}createHistoryEditor(t,e){return hF(t,e,this.createOptions)}}w("create-editor");function r9({root:n,childDoc:t,doc:e}){t.uploadResource=e.uploadResource.bind(e),t.buildResourceUrl=e.buildResourceUrl.bind(e);const o=hs(n,t,{shortcuts:[Ac],components:{blocks:[Ws,Qs],decorators:[new Js],embeds:[G4,va,$1,cf,af,uf,k1,df,Mf,Lf],boxes:[ta,Hf],options:{image:{defaultAlign:"left"}}}});return o.input.addHandler(new ca),o.input.addHandler(new hf(o)),o.input.addHandler(new SP(o)),o.input.addHandler(new Y1),o}function mF(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),o=new Set;e.forEach(r=>{const i=U(r);i&&o.add(i)}),o.forEach(r=>{DP(n,r,t)})}class gF{constructor(t){h(this,"listeners",new Set);h(this,"doc");this.editor=t,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const o=e.groupId;this.getComments().filter(i=>i.groupId===o).length===0&&mF(this.editor,o)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return r9({root:t,childDoc:e,doc:this.doc})}}class pF{constructor(t,e){h(this,"listeners",new Set);this.editor=t,this.localDoc=e}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(t){return this.doc.comments[t]}getCommentDoc(t){const e=this.doc.comments[t];return fh(e)}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}localCreateComment(t,e){}localDeleteComment(t){}localUpdateComment(t,e){}createCommentEditor(t,e){return r9({root:t,childDoc:e,doc:this.localDoc})}}const CF={placeholder:{common:{title:"\u8BF7\u8F93\u5165\u6807\u9898",readonlyTitle:"\u8BF7\u8F93\u5165\u6807\u9898",content:"\u70B9\u51FB + \uFF0C\u6216\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6",contentInTable:"\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6"},local:{readonlyTitle:"\u672A\u547D\u540D"}}},AF={placeholder:{common:{title:"Enter a title",readonlyTitle:"Enter a title",content:'Click "+", or enter "/" to insert components quickly',contentInTable:'Enter "/" to insert components quickly'},local:{readonlyTitle:"Untitled"}}};x.mergeLang({"zh-CN":CF,"en-US":AF});function bF(n){let t;return n.forEach((e,o)=>{o.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function vF(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),o=bF(t.headers).toLocaleLowerCase();let r="";if(o){const s=au.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([e],`${Date.now()}.${r}`,{type:o})}catch{return null}}function yF(n){const o=new DOMParser().parseFromString(n,"text/html").querySelector("svg");if(!o)return null;const r=o.getAttribute("viewBox");if(!r)return null;const i=r.split(" ");if(i.length===4){const s=i[2],l=i[3];return o.setAttribute("width",s),o.setAttribute("height",l),o.outerHTML}return null}function i9(n,t,e=!0){const o=new Image,r=document.createElement("canvas"),i=r.getContext("2d");if(!i){t(new Error("failed to get context"),null);return}o.onload=()=>{if(r.width=o.naturalWidth,r.height=o.naturalHeight,e&&(r.width===0||r.height===0)){const s=n.substring(26);if(s){const l=atob(s),c=yF(l);if(c){Bu(c,"image/svg+xml").then(a=>{i9(a,t,!1)});return}}t(null,null);return}i.drawImage(o,0,0),r.toBlob(s=>{t(null,s)},"image/png")},o.src=n}async function kF(n){const t=await Tr(n);return new Promise((e,o)=>{i9(t,(r,i)=>{if(r){o(r);return}if(!i){o(new Error("Failed to get image blob"));return}e(i)})})}const s9="Untitled";function wF(n){const t=Ft(n.rootContainer);return!t||!_(n,t)?s9:n.getBlockString(t)||s9}const BF="UEsDBBQABgAIAAAAIQBk9WPugQEAACkGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0lMtqwzAQRfeF/oPRtsRKuiilxMmij2UbaArdKvI4EdULaZzH33fsJKYUJy5NsjHIM/feowHNcLw2OllCiMrZjA3SPkvASpcrO8/Yx/Sld8+SiMLmQjsLGdtAZOPR9dVwuvEQE1LbmLEFon/gPMoFGBFT58FSpXDBCKRjmHMv5JeYA7/t9++4dBbBYg8rDzYaPkEhSo3J85p+b0kC6MiSx21jlZUx4b1WUiDV+dLmv1J6u4SUlHVPXCgfb6iB8daEqnI4YKd7o9EElUMyEQFfhaEuvnIh57mTpSFletymhdMVhZLQ6Cs3H5yEGGnmRqcIxtMNIDVC2T1/G4csIzrzaTRXpJkE5+PgZJzGtPKDgAqaGR6chS3NDALRn38YjXUnRMSNhnh+gq1vdzwgkuASADvnToQVzN4vRvHDvBOkoNypmGk4P0Zj3QmBtIpg+z39VdQ2xyKps36AtNrCP669312Vuuf/9PKaRLI++X5QrcUc8pZsXi/60TcAAAD//wMAUEsDBBQABgAIAAAAIQAekRq37wAAAE4CAAALAAgCX3JlbHMvLnJlbHMgogQCKKAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJLBasMwDEDvg/2D0b1R2sEYo04vY9DbGNkHCFtJTBPb2GrX/v082NgCXelhR8vS05PQenOcRnXglF3wGpZVDYq9Cdb5XsNb+7x4AJWFvKUxeNZw4gyb5vZm/cojSSnKg4tZFYrPGgaR+IiYzcAT5SpE9uWnC2kiKc/UYySzo55xVdf3mH4zoJkx1dZqSFt7B6o9Rb6GHbrOGX4KZj+xlzMtkI/C3rJdxFTqk7gyjWop9SwabDAvJZyRYqwKGvC80ep6o7+nxYmFLAmhCYkv+3xmXBJa/ueK5hk/Nu8hWbRf4W8bnF1B8wEAAP//AwBQSwMEFAAGAAgAAAAhADPCW79BAQAA5wQAABwACAF3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJQxT8MwEIV3JP5D5B07LVAQatoFkDqwQJFYneSSWI3tyL6Q9t9zojRNRYkYPN6z7r1P57Pny62uo09wXlmTsAmPWQQms7kyZcLe189X9yzyKE0ua2sgYTvwbLm4vJi/Qi2RmnylGh+Ri/EJqxCbByF8VoGWntsGDJ0U1mmJVLpSNDLbyBLENI5nwg092OLEM1rlCXOrnPLXuwb+422LQmXwaLNWg8EzEQKpF8hQuhIwYd/lXpxwMmPiPMN1SAaPu5qG2EPs67H4u5DxhTW4lmk9GEMvjUFMQ0KYVqfgaMeOEL00BjEJCZG1Hq3+oLQegvOjKhSCHl2LWUiaipxcrczmSPNj23UdT6XKW55ZLQ7HLzan5KctgjPyT8TbkIgdpG+ASHc0WN+BODarm6BP6BfFQTkgiJPvafEFAAD//wMAUEsDBBQABgAIAAAAIQBOMo6QFgYAAKYkAAARAAAAd29yZC9kb2N1bWVudC54bWzUWttu40QYvkfiHSJfLRKtz4eYTVeOD7uVQKoo+wCuPUmstT3WeNI0XC0XC1wguOBiuWClLgjBE4AEiIdZ0T28BTM+JM6h7cTZkm0vEnv+mW+++eb7/0yc3r13lsSdU4DyCKY9TtwXuA5IAxhG6bDHPfzM2zO4To79NPRjmIIeNwU5d+/g/ffuTswQBuMEpLhDINLcnGRBjxthnJk8nwcjkPj5fhIFCOZwgPcDmPBwMIgCwE8gCnlJEIXiKkMwAHlO5rP99NTPuQouOGNDC5E/IYMpoMIHIx9hcDbHEDcGUfkub6wCSS2AyAolcRVK3hhK4ymrFSClFRBhtYKktkNaszitHZK0iqS3Q5JXkYx2SCt2SlYNDjOQkuAAosTH5BYN+cRHj8bZHgHOfBydRHGEpwRT0GoYP0oftWBERs0QEjncGEHnExiCWA5rFNjjxig1q/F7s/GUulmOr97qEYhl/eUQpyoOxcp5BGKiBUzzUZTNMjxpi0aCoxrk9KpFnCZx3W+SiYzpcll5ckop54As9Cv9k7hkfjWiKDDsCIWYjWChsDhnzSQhLpxP3EqahrgiYwGpAaQVAC0AjAW/xjAqDD6YZyjFiRhTo8Ypd4XiRHNhRcY6tkymAZCDzSDUmkc+TRoryobb2fY+guNsjhZth3Y4L0ITehzYAKuyfzMl8+3IHI/8jNSmJDAPhylE/klMGBEzd4gfO8UO0FeyrfStuARnHVoIuANyfDmB4ZS+ZySimJmP/EPiHEV2dE+3La5oJcUf01a9+iOtJjkqhZ/2OEEQJE1z5FmTAwb+OMY04nUVRRfryFGjqZjwCBVvx3gaE4bmqR/3uAfAp2cukeNpDJVdYj8d1h1AuvfwmEb5KszPkMqX6tqDKc7JoFGUEi7Az7GVR35z4MTEBy/Pv3rz0w+0CZeBZZwrp6ajxIXBlMwaMT2l6wh9lUHMRcnejpjSDYrJoND2GksMGquOY+iu7exIY/m2ayyzaKwaqi4YNNd3obFy2zVWGDTW+7Il296uaoX6LmisMugkKIpouJqwI5202+5FjUFjTfQ8S7OMHWms33aNdQaNJd3qqoq8q5pq3HaNDRaNNcFzRafLoLGtaF2JdlzReDFSaFw1NTTeRMf1XBVLNcSux+KHnXOVBddQLEm6DVxVSxf6nubdPNfFPLNhCCqWdRxBOHARIj3wNCNf1YbIT46xj3CVi6WxA5jmMAb7MRzeWUqQtQhuGi6Mf/H4xxGIY/hhh3xbjMMXj5998BFDrsiSZnuiYjPoZLiC7fV3rVM+zTFI9uEY72eI1KA4baPWnZZyiYYu2oLFlK6u2C3OzqtyLURaytXME8Zvv//+9fOr8y8unj1lWKjqeroraMpWvliMFAutmoq9WDp9aJohGzrLN7o2M7asLrVj6MMbM8/8gBgqQyAH6BRwB5RlZ8l/1HgFrSO0NH29Wws7e5jGUQoa+zvbLgwuQ26YiBGX2SOvn39z8eWT0ik3tbAzvIzMuiuXbkRndSfW+1rRlb7nKExng00SeDuXXcK1qwiWJi99hmme4uiaRfNkJ1wXt2u78+Dr35+8+vPXJTeMSNVGxDuPOsiMyILRYahR/qMoxxBNSREuTbdox+vy4UGNem06MPB+8/0/L7/9ZdluM+JvV6SX539c/P0dg7eFru3alrhUs1VH6kuqPD/gULUcRVAdd51fFiM35m21L3ueJNOJGlwFQ1FFxZ0beQ3Xcrs3WkDV1FjA4qfrx8RZR4QYOSlko3JX0nFS9ozi07juJ8xih2HdVjy65mcDGlmyljCbK5rbf/H109fPf7u6FjfA2R5Rq47sCZq2JL/ueo5o2VfK//8oXf0g8K4rvcf0c4DrGX25v3TElmzV1foiLe47tfrGZf16xWbiLMlTh/yTCmauWA4CfDST+jopimUNjz8nwQnxhSQp9LmgOSLXqqFUWZoNP/EpIoYZaVfKLigajvD89gRiDJP5fQwGjegI+CEg8+oCfSRmDiDEjdvhGBe31XQBjKle1cmE9imaQxjcR/SnOJOeho4iHBCWslYM4ut1F5flD3P8/B+MDv4DAAD//wMAUEsDBBQABgAIAAAAIQC29GeY0gYAAMkgAAAVAAAAd29yZC90aGVtZS90aGVtZTEueG1s7FlLixtHEL4H8h+Guct6zehhrDXSSPJr1zbetYOPvVJrpq2eadHd2rUwhmCfcgkEnJBDDLnlEEIMMcTkkh9jsEmcH5HqHkkzLfXEj12DCbuCVT++qv66qrq6NHPh4v2YOkeYC8KSjls9V3EdnIzYmCRhx719MCy1XEdIlIwRZQnuuAss3Is7n392AZ2XEY6xA/KJOI86biTl7Hy5LEYwjMQ5NsMJzE0Yj5GELg/LY46OQW9My7VKpVGOEUlcJ0ExqL0xmZARdg6USndnpXxA4V8ihRoYUb6vVGNDQmPH06r6EgsRUO4cIdpxYZ0xOz7A96XrUCQkTHTciv5zyzsXymshKgtkc3JD/beUWwqMpzUtx8PDtaDn+V6ju9avAVRu4wbNQWPQWOvTADQawU5TLqbOZi3wltgcKG1adPeb/XrVwOf017fwXV99DLwGpU1vCz8cBpkNc6C06W/h/V671zf1a1DabGzhm5Vu32saeA2KKEmmW+iK36gHq92uIRNGL1vhbd8bNmtLeIYq56IrlU9kUazF6B7jQwBo5yJJEkcuZniCRoALECWHnDi7JIwg8GYoYQKGK7XKsFKH/+rj6Zb2KDqPUU46HRqJrSHFxxEjTmay414FrW4O8urFi5ePnr989PvLx49fPvp1ufa23GWUhHm5Nz9988/TL52/f/vxzZNv7XiRx7/+5avXf/z5X+qlQeu7Z6+fP3v1/dd//fzEAu9ydJiHH5AYC+c6PnZusRg2aFkAH/L3kziIEMlLdJNQoAQpGQt6ICMDfX2BKLLgeti04x0O6cIGvDS/ZxDej/hcEgvwWhQbwD3GaI9x656uqbXyVpgnoX1xPs/jbiF0ZFs72PDyYD6DuCc2lUGEDZo3KbgchTjB0lFzbIqxRewuIYZd98iIM8Em0rlLnB4iVpMckEMjmjKhyyQGvyxsBMHfhm327jg9Rm3q+/jIRMLZQNSmElPDjJfQXKLYyhjFNI/cRTKykdxf8JFhcCHB0yGmzBmMsRA2mRt8YdC9BmnG7vY9uohNJJdkakPuIsbyyD6bBhGKZ1bOJIny2CtiCiGKnJtMWkkw84SoPvgBJYXuvkOw4e63n+3bkIbsAaJm5tx2JDAzz+OCThC2Ke/y2EixXU6s0dGbh0Zo72JM0TEaY+zcvmLDs5lh84z01QiyymVss81VZMaq6idYQK2kihuLY4kwQnYfh6yAz95iI/EsUBIjXqT5+tQMmQFcdbE1XuloaqRSwtWhtZO4IWJjf4Vab0bICCvVF/Z4XXDDf+9yxkDm3gfI4PeWgcT+zrY5QNRYIAuYAwRVhi3dgojh/kxEHSctNrfKTcxDm7mhvFH0xCR5awW0Ufv4H6/2gQrj1Q9PLdjTqXfswJNUOkXJZLO+KcJtVjUB42Py6Rc1fTRPbmK4RyzQs5rmrKb539c0Ref5rJI5q2TOKhm7yEeoZLLiRT8CWj3o0Vriwqc+E0LpvlxQvCt02SPg7I+HMKg7Wmj9kGkWQXO5nIELOdJthzP5BZHRfoRmsExVrxCKpepQODMmoHDSw1bdaoLO4z02Tker1dVzTRBAMhuHwms1DmWaTEcbzewB3lq97oX6QeuKgJJ9HxK5xUwSdQuJ5mrwLST0zk6FRdvCoqXUF7LQX0uvwOXkIPVI3PdSRhBuENJj5adUfuXdU/d0kTHNbdcs22srrqfjaYNELtxMErkwjODy2Bw+ZV+3M5ca9JQptmk0Wx/D1yqJbOQGmpg95xjOXN0HNSM067gT+MkEzXgG+oTKVIiGSccdyaWhPySzzLiQfSSiFKan0v3HRGLuUBJDrOfdQJOMW7XWVHv8RMm1K5+e5fRX3sl4MsEjWTCSdWEuVWKdPSFYddgcSO9H42PnkM75LQSG8ptVZcAxEXJtzTHhueDOrLiRrpZH0Xjfkh1RRGcRWt4o+WSewnV7TSe3D810c1dmf7mZw1A56cS37tuF1EQuaRZcIOrWtOePj3fJ51hled9glabuzVzXXuW6olvi5BdCjlq2mEFNMbZQy0ZNaqdYEOSWW4dm0R1x2rfBZtSqC2JVV+re1ottdngPIr8P1eqcSqGpwq8WjoLVK8k0E+jRVXa5L505Jx33QcXvekHND0qVlj8oeXWvUmr53Xqp6/v16sCvVvq92kMwioziqp+uPYQf+3SxfG+vx7fe3cerUvvciMVlpuvgshbW7+6rteJ39w4Byzxo1IbtervXKLXr3WHJ6/dapXbQ6JX6jaDZH/YDv9UePnSdIw32uvXAawxapUY1CEpeo6Lot9qlplerdb1mtzXwug+Xtoadr75X5tW8dv4FAAD//wMAUEsDBBQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAd29yZC9zZXR0aW5ncy54bWy0Vttu2zgQfV9g/8HQ8zq6WHZsoU4R3zYp4nZRebHPlETZRHgRSMqu8/U7pETLu3ELp0VeEmrOzJkh53DoDx+/MdrbY6mI4FMvvAm8Hua5KAjfTr2/N6v+2OspjXiBqOB46h2x8j7e/f7bh0OisNbgpnpAwVXC8qm307pKfF/lO8yQuhEV5gCWQjKk4VNufYbkc131c8EqpElGKNFHPwqCkdfSiKlXS560FH1GcimUKLUJSURZkhy3/1yEvCZvE7IQec0w1zajLzGFGgRXO1Ipx8Z+lg3AnSPZ/2gTe0ad3yEMrtjuQcjiFHFNeSagkiLHSkGDGHUFEt4ljl8RnXLfQO52i5YKwsPArs4rH76NIHpFMMrxt7dxjFsOHyLPeUjxNp7RiYd0BxuOfq6YMwKF30YxdHWoI+t2pOg1PW6gJ5JJJJsb1DaY5cnjlguJMgrlQKN70Kuerc78hS2bf3YJOe/gIr8IwXqHpMIyBzXDFAgCzzdABtXBaFiIz0KntZSi5sUDRmD7LrwSQrcwKFCUqUYa8iZbiRjc/amXU4x4Q1/gEtVUb1CWalGB0x7B1m+jNnu+QxLlwJZWKAcdzwXXUlDnV5i0c5gjEmTeRtipYla1wqvlEzqKWp8haTOxgIEjBofznym0FgWMFAiV5PoumgBbTTg8L+H/iQRMWEkKvDFNSfWR4hVsJiUv+J4Xn2qlCTDaWfQLFfyoAMxN5i8go82xwiuMdA3H9k7JbGdWlFRrAqKQj7wAWb1bMlKWWEICAkJbg5yIFAd7zo1S3ysvKOwfcIZbPNiATJ9nQmvBHo7VDs761zpp9e+fyxme50K5xVe4YifXYBEHw8WyqdSgHRJEo9FicAkJV9Eyvr+EjJfBfDW7hMxm0WB+ewmZx6NJNLmILMPJ+GIFCyhiPL+IfHc/q0kc39qe+KcTYYl5dv+SbmWuVY81EXPEMklQb20eZt94ZPJ5RrjDMwzzFJ8jaZ05sN9vAMUQpStosANsc1hSEFUtcGnXdI3ktuNtPeRFK8y8TycuM26x/BMGZ9WgB4mq5ro4lzCO20jC9RNhzq7qLHVRHF6AMwim8Je9tOfUHc8h0SA/O3aekJWx9cW8P/9shIeR0veKoKn3sjOmRvlUpka1eI2qqhF/tg2nHiXbnQ5NmIavAn7S2Y9sG7VYZLGowewHys1mwbtddLbI2c78Bs426Gyxs8Wdbehsw842craRse1g3ElK+DPcQ7c09lJQKg64eOjwVyb3SuUERJAeWdY9PjcNRomCwVDBO6WFdNgfFgvjpBD5o3ls48Y+nIwXy8mg0XY4tO+btrMDjvYrLmdI4aJRt/tpffcvAAAA//8DAFBLAwQUAAYACAAAACEAQMH/8TkBAAAjAwAAFAAAAHdvcmQvd2ViU2V0dGluZ3MueG1snNJfT8IwEADwdxO/w9J36CCykIVBYgzGF2OifoDS3aCx7S294sBP720CYnhhvvT//XLXdrbYOZt8QiCDvhCjYSoS8BpL49eFeH9bDqYioah8qSx6KMQeSCzmtzezJm9g9Qox8klKWPGUO12ITYx1LiXpDThFQ6zB82aFwanI07CWToWPbT3Q6GoVzcpYE/dynKaZODDhGgWrymh4QL114GMXLwNYFtHTxtR01JprtAZDWQfUQMT1OPvjOWX8iRndXUDO6ICEVRxyMYeMOorDR2k3cvYXmPQDxhdApmHXz5geDMmR544p+znZyTHlmfO/ZM4Agn7E5JgH7V1bkdP509pjUCvLEr9RwtecdHDbcrZt1w35+Jx/LdbROPMFSwz3ARuCINtlZS02L8+PPJF/vvb8GwAA//8DAFBLAwQUAAYACAAAACEAOdtFTLkFAAAnWgAAEgAAAHdvcmQvbnVtYmVyaW5nLnhtbOyczW7qRhiG95V6D8j7xP8/oEOOwECV6rQ60knV9WAGsGKPrbGB0FV7Ke266q430EvpDfQWOuOxzZ9DbIMw5MwmDuP5Xs/3zjfDk0nCh48vvtdaQhy5AeoK8r0ktCBygomLZl3hp6fRnSW0ohigCfACBLvCGkbCx4dvv/mw6qCFP4aYdGwRDRR1VqHTFeZxHHZEMXLm0AfRve86OIiCaXzvBL4YTKeuA8VVgCeiIslS8l2IAwdGEdGxAVqCSEjlnJdyahMMViSYCmqiMwc4hi8bDbmyiC62RetQSKkhRDJU5EMptbKUIdJRHQhptYTIqA6U9HpKBckZ9ZSUQyWznpJ6qGTVUzooJ/+wwIMQInJzGmAfxOQlnok+wM+L8I4IhyB2x67nxmuiKRmZDHDRc40RkahcwVcnlRVM0Q8m0FMnmUrQFRYYddL4uzyeDr3D4tNLFoHL5M9CBoGz8CGKk8xFDD3iRYCiuRvmK9yvq0ZuzjOR5bEklr6X9VuFcsnl8tr2NGBWbgTLDD/13/fYyI8rylKJGaESeUSZIew+MxuJT6pw8+Ba1myZK5fcQDIB5UDAcGDJDT/TsFIN0dmsUKrjllwamQ6bFarjboyVS+5j+4PZEohgNQk9G0e09rcyCmenle13OFiEGzX3NLXHzSa0ojxQQSst/+0lGZ02mC9zEJK9yXc6jzMUYDD2yIhIMbdIPbaSGaBfybTSS/ItfGnRjUB4IPwCxlGMgRP/uPBbO68eSQERDiIiHQwJ/GDayFCnN40h7mMInmkXqoIiKt9ZAo+0jJS+ItuKINI7/sKL3U9wCb2ndQizPkmrR1tZr9gPveyeatvSUJE0dsdb0hsuuWTPSsaSdZZZL0JhIz9vHC88D8Z5/BN8yW/9++sfefv3TtbqwWnaPfyM6cVFNB3a3BU0hdrQmQM0S3iQviZ9xbwzTi+jAMURNTFyXFJgP5PelCCjJLpHLNpvcxGRn8ApIG6wx4+Tr25uJWuNfskalCRfMX2mmKSx75J8ukv//F7VJEu7nEkbO2T9bTuU0+3477e/q/ohK8alDDmevnqO9P+snL5hXUf6bJM7Mf2/qqavyNJ1pK83UvyKfrEt83j6RiPFr7QvthkeT99spPhV9Uq2PquR4lfNxrY+cQfg6DOO0p1ch+4Uua1LumWw/KvTXbsvGX1LS+O3p+sMdJc+r/xkXRPblYEZznY7dnC2Oz19znbV0udsx9mOsx1nuwunX5HtlDpsp2rKSB5ItdlOaxu2aitWbms+Xfzk7kIndzXW9OXwjsMchzkOc4Xpc5hroPg5zHGYuwWYU2vBXNvWTcsasvyLYW6+HmN38sMRpDN7pqbpmpabm09a4l0cek5XsI2BNVRNu8Y0hl/itZeP55MbxZ8BBjMMwnnhPH8FJ3y5rZakS0N5dAZ2fl9nfrlBw/5Is4b9s7x5XDM4VrWI7hepRZImtSVJYlUFUQxidwnP9JPGLcPmvkHMsjMbdMs4um8QazmzQbcMrPsGXccSuyKk3TfoOpbYFUHvvkHXscRuB4vpLl4HiwdqXxqw/KufcQ7aQ0Oib/2ZrfmEvv8zTn6ayU8z+WkmP818M31+mtlA8fPTTH6aeQvYRjG3Mrbplq0aZttm+VfHNsM2FG3YTk9Dt6frDNhWY7FybOPYtsmeYxvHNo5tHNsaTZ9jWwPFfzvYRk+8K2ObOVBHqmFpLP/q2NYb9CRTVtL47el679jGIe317DmkNVD6HNI4pHFI45DWaPoc0o5DGv2te3VIG/ZNc9QbsPyrQxrZGwzLlL/Kf/vgZ2sc2zi2cWx7M32ObQ0UP8c2jm1Xgm0owTWUffIKbdphtywjNZVDBWHsDbQwLPmf3VfC2BtPYVj2x+RFYQefD7gJM4+EsY2uMEw7EsY2iMKw5JMEXwljC6swLJvrojBWkIVhGcYlYezKIPrhfwAAAP//AwBQSwMEFAAGAAgAAAAhAPiVyO/8DgAA85kAAA8AAAB3b3JkL3N0eWxlcy54bWzsXd9zo0YSfr+q+x8oPSUPG/+QLTtbcVJr2T67btdxVt5L3eMIRhZnYHSA1uv89TczDAjUDKKHjuu8m6RqLQH9MczXX890A5qffvkSR95nnmahSM5GBz/sjzye+CIIk4ez0af7qzenIy/LWRKwSCT8bPTMs9EvP//9bz89vc3y54hnngRIsrexfzZa5vnq7d5e5i95zLIfxIoncudCpDHL5df0YS9m6eN69cYX8Yrl4TyMwvx573B/fzIyMGkfFLFYhD6/EP465kmu7fdSHklEkWTLcJWVaE990J5EGqxS4fMskxcdRwVezMKkgjk4AkBx6KciE4v8B3kxpkUaSpof7OtPcbQBOMYBHAKAic+/4DBODcaetKzjhAEOZ1LhhEENx60xNYCM4yCOy3Zkz7G6oth/e/OQiJTNI4kkOfJkN3saWP0rW6v+6I/y8J+lwwbCv+ALto7yTH1N71Lz1XzTf65Ekmfe01uW+WF4L9slweNQnuf6XZKFI7mHsyx/l4WsvvPSbFP7l+rAVks/y2ubz8MgHO2pk2Z/yJ2fWXQ2Ojwqt0xVIxrbIpY8lNt48mZ6W2/M2eiPpdk0l7hnI5a+mb1Thnvm2oq/tSteVd+Ko7a6R+pJqmtWiFzu5Yv3wn/kwSyXO85G++pUcuOnm7s0FKkU8tnoxx/NxhmPw+swCHhSOzBZhgH/fcmTTxkPNtt/u9JiNBt8sU7k5/HJRFMWZcHlF5+vlLTl3oSp3rtVBpE6eh1uTq7N/1uCHZg+a7Nfcqbim3ewDaGbj4I4VBZZ7WrbMddb166PQp1o/FInOnqpEx2/1IkmL3Wik5c60elLnUjD/JknCpOAfymECE8DUHfhWNSIxrGIDY1j0RIaxyIVNI5FCWgci6OjcSx+jMaxuCkCJxe+zQtrzj62eHs37u4xwg1395Dghrt7BHDD3R3w3XB3x3c33N3h3A13d/R2w90drPG4xVTLu5EyS/LBKlsIkSci517OvwxHY4nE0kkfDZ4a9HhKcpEEMEVkMwPxYDSf6e+7PUSL1H08z1U25omFtwgf1inPBjecJ595JLN2jwWBxCMETHm+Ti094uLTKV/wlCc+p3RsOtAoTLiXrOM5gW+u2AMZFk8C4u4rEUmCQuXQbJ0vlUhCAqeOmZ+K4U0TjCw+vA+z4X2lQLzzdRRxIqxbGhfTWMNzAw0zPDXQMMMzAw0zPDGocUbVRQaNqKcMGlGHGTSifiv8k6rfDBpRvxk0on4zaMP77T7MIx3i67OOg/61u2kkVJl+cDtm4UPC5ARg+HBjaqbeHUvZQ8pWS0+VkNth69eMPc+5CJ69e4oxrUKimtdrF5nKqw6T9fAObaBRiavCI5JXhUcksApvuMQ+yGmymqBd0+Qzs/U8bxWtRuol2hmL1sWEdrjaWD7cwzYCuArTjEwG7bAEHnyrprOKTorIt2nl8IZtsIbLajsqkTbPQBK0MhL+I00Yvn5e8VSmZY+Dka5EFIknHtAhzvJUFL5Wl/yhpqSX5C/j1ZJloc6VGhD9h/ryBr/3ga0GX9BdxMKEhrfLNzELI49uBnF9/+G9dy9WKs1UHUMDeC7yXMRkmKYS+N3vfP49TQPfySQ4eSa62ndE5SENNg0JBpkCSQRESHKaGSYhyRiq8f7Jn+eCpQEN2l3Ki2dqck6EOGPxqph0EGhLxsUnGX8IZkMa718sDVVdiEpU9yRgtbJhtp7/h/vDQ92t8EgqQ7+uc11/1FNdbU0HN3ya0IAbPkXQbMrhQfkvwcU24IZfbAOO6mKnEcuy0HoL1RmP6nJLPOrrHZ78GTwRiXSxjug6sAQk68ESkKwLRbSOk4zyijUe4QVrPOrrJXQZjUdQktN4/0jDgIwMDUbFhAajokGDUXGgwUgJGP6ETg1s+GM6NbDhz+oUYERTgBoYlZ+RDv9Ed3lqYFR+psGo/EyDUfmZBqPys/GFxxcLOQmmG2JqkFQ+V4OkG2iSnMcrkbL0mQjyMuIPjKBAWqDdpWKhXrYQSfEQNwGkqlFHhJPtAo6K5N/5nKxpCouyXQQVURZFQhDV1jYDjrZsPru2y0y/czG4CXcR8/lSRAFPLddkt5X58mzFfFOmB7f7epU934cPy9ybLatqfx1msr/TskzYG2a7T9jW55PDDrMPPAjXcdlQ+DLFZNzfWHt0w7h856XDeDOTaFge97SE55zsttzMkhuWJz0t4TlPe1pqnTYsu/RwwdLHVkc46fKfKsezON9JlxdVxq2n7XKkyrLNBU+6vKghFe+d76u7BZCdfpqx2/cTj90eoyI7CkZOdpTeurJDdAnsI/8cqpEdEzT1+aqnJ0Dc15PoXpHzt7Uo6vaNG079X+q6kROnJONeK864/42rRpSx92PvcGOH6B137BC9A5AdolckspqjQpIdpXdsskP0DlJ2CHS0giMCLlpBe1y0gvYu0QqiuESrAbMAO0Tv6YAdAi1UCIEW6oCZgh0CJVRg7iRUiIIWKoRACxVCoIUKJ2A4oUJ7nFChvYtQIYqLUCEKWqgQAi1UCIEWKoRACxVCoIXqOLe3mjsJFaKghQoh0EKFEGih6vniAKFCe5xQob2LUCGKi1AhClqoEAItVAiBFiqEQAsVQqCFCiFQQgXmTkKFKGihQgi0UCEEWqjFq4buQoX2OKFCexehQhQXoUIUtFAhBFqoEAItVAiBFiqEQAsVQqCECsydhApR0EKFEGihQgi0UPXNwgFChfY4oUJ7F6FCFBehQhS0UCEEWqgQAi1UCIEWKoRACxVCoIQKzJ2EClHQQoUQaKFCiC7/NLcobY/ZH+CrntYn9vvfujKN+lh/lbsONe4PVbbKjtX/XYRzIR691hcPxzrf6AcSzqNQ6BK15bZ6HVc/EoG68fnrtPsNnzr6wB9dMu9C6HumAPyoryWoqRx1uXzdEiR5R12eXrcEs86jruhbtwTD4FFX0NW6LB9KkcMRMO4KMzXjA4t5V7SumcMu7orRNUPYw12RuWYIO7grHtcMjz0VnLetj3v206R6vhQgdLljDeHEjtDllpCrMhxDYfQlzY7Qlz07Ql8a7QgoPq0weGLtUGiG7VBuVEOZYal2F6odAUs1RHCiGsC4Uw2hnKmGUG5Uw8CIpRoiYKl2D852BCeqAYw71RDKmWoI5UY1HMqwVEMELNUQAUv1wAHZCuNONYRyphpCuVENJ3dYqiEClmqIgKUaIjhRDWDcqYZQzlRDKDeqQZaMphoiYKmGCFiqIYIT1QDGnWoI5Uw1hOqiWldRGlSjGK6Z4yZhNUPcgFwzxAXnmqFDtlSzdsyWagiO2RLkquQcly3VSbMj9GXPjtCXRjsCik8rDJ5YOxSaYTuUG9W4bKmNaneh2hGwVOOyJSvVuGypk2pcttRJNS5bslONy5baqMZlS21UuwdnO4IT1bhsqZNqXLbUSTUuW7JTjcuW2qjGZUttVOOypTaqBw7IVhh3qnHZUifVuGzJTjUuW2qjGpcttVGNy5baqMZlS1aqcdlSJ9W4bKmTaly2ZKcaly21UY3LltqoxmVLbVTjsiUr1bhsqZNqXLbUSTUuW/ogTUKCn4CaxSzNPbrfi7tm2TJnw3+c8FOS8kxEn3ng0V7qe9RV7j01lr9S2Hq1O3l8LvtM/QJ67XWloPgFWAOoD7wJqmWqlLFqiWeW7jKbdYPN7Vr9Oc1kTm2O2d8/Pz8cT43UVsXSZFnxZqk8Rv1a0dloPNGvJKkvH9dqDTS2zoVpvTbZM43Z0fyqweb+8wFo8mbBLN2eOZM99avqYXBBifqxxZbtysnK7eVppkuWFns37l8eYwRu75+Lo/3ji8tG/zxyvrqV59fb1BfJOc/0t03XzdXvlHG1qJoRvyh+/On956gCr/ehZWE4qcRyrTrv3+yaNxaGa92pV4Vr3eNnZ6P7MOaZd8ufvI8iZon3nemkzJvOvje9rv/1VfjYdIP6T2HodeV0aDkbqd+9N0xtFpYrb5TXF5Yb60hTWx/OxVsOrd5i4hiNtxz28JamlP9kB7L7TxlBvir/GZuJQ2NhQr1toP+Mrf5jHgqh8Z/x6/GfUpVfl/9QxJojq6+Y6EbjK0evx1e0Rv5ffSWcFhfk7DPlSDzEZ46tPmMeAKPxmePX4zNaK19DfBnoGcUKs22eYcY6Gs+YvB7P0Ir4yzMeTqyeYTIyGs84eT2eUc70vppxZqCHnFo9xBS3aDzk9PV4iFbGq4gdhyfq/3bPKDfeh2oV8gtDZiPp6ek+vmSO+eYnxy0VIrN0UPXbN3rhoG3HsqwvZHGKchJVlbnafcTe7lzVKTvarOuYnaWtotRp9VrjtrtaKNszjwonkh9uEuXET2aV96KlwRdWQMn9Ux5FH1hxtFjZD434QmlP7j3Y1780ubV/XiyaYLVPdXXdCrDXbEzxtdtPimUUw+K1D2slUZWQW7pbv4M0tKd7+rC/zmTXzNQB2+1rVPS2W2l2egfeJphtRcdWHdhiovFwazy0B7y/KnlIQouim43QQyJCTZ3wmyV0SGkNSWhRBbMROiYi1BTuvl1C/xw1FmUpG3lHROSZ6PLqyXup4hOSxKJOZCPxmIhEU9r6phRITlVRuLFRNSGiygT/v6gaQlVRSbFRdUJElSn+fJOhkZyyorRho+yUiDKTwH9d6nqZAkaj/tXBp17ibptHvbGNvX5Pv5xe7k+vzoujTEFpdR7U0nt9nFoI2qyb9oe6raE+rJhftlD32eapmCr532GrPwPbqjDgdOaybOBwalVSM5eeLasu8iPOCqHVjpZfF2Ek916eXE4u9YNl2heu9MY58x8fUrFOgn43mKciyUTE9O+BbFx8FsaztX4oy3h2/bBWl9aLsFbuHDFdT9QXwZM3n2a0weUmUWXJVpes7cKFFWuRrZ//EnVv0eagCgKJSCof0mHb+JD+DByQ1HVoWNwMCNVTiNuUbfYMZayshbWUGZvMTS8Pfjw1CaxhrjlMHk/G002YNbF32WzoujzaSH1A52weiCyfh9zupJZHJql6a3eNFtd5k/3jy+Mp1iMPLq4uLhzGrKoPVZF08/vy2/2nn87d7G7ru/qgBXtrbFJm1F2XZB0XH8Jo68kfve+msi5Ha2MAwnZPKZafsp//BwAA//8DAFBLAwQUAAYACAAAACEAzJJQVH0BAADxAgAAEQAIAWRvY1Byb3BzL2NvcmUueG1sIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjJLLTsMwEEX3SPxD5H1qJ+WlKE3FQ6yoQKIViJ2xJ60hsS17IPTvcZI2JYgFO4/n+GRy7Xz+VVfRJzivjJ6RZMJIBFoYqfR6RlbL2/iCRB65lrwyGmZkC57Mi+OjXNhMGAcPzlhwqMBHwaR9JuyMbBBtRqkXG6i5nwRCh2ZpXM0xlG5NLRfvfA00ZeyM1oBccuS0FcZ2MJKdUopBaT9c1QmkoFBBDRo9TSYJPbAIrvZ/Hug6P8ha4dbCn+i+OdBfXg1g0zSTZtqhYf6EPi/uHrtfjZVusxJAilyKDBVWUOT0sAwr//H6BgL77aEIa+GAo3HFQglnvCkxui9LJSBaeXAdvSfa7N9h2xgnffCMqoBJ8MIpi+FG+6+MNgJdcY+LcMWlAnm1LS5Pz9OzTvOr0bIOPlX7NoqkI4Yy3wXdDwUyCgFlfZz7ztP0+mZ5S4qUpUnMTuIpW7I0O00zxl7auUbnD8J6N8A/jdOMnYyNe0EfzfiRFt8AAAD//wMAUEsDBBQABgAIAAAAIQAiURHx1QEAAN4DAAAQAAgBZG9jUHJvcHMvYXBwLnhtbCCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJxTwW7bMAy9D9g/GLo3crKh6AJFxZBi6GFDA8Rtz5xMJ8JsSZDYINnXj7YTT9l2mk/vkfTTE0mp+2PXFgeMyXq3EvNZKQp0xtfW7VbiufpycyeKROBqaL3DlThhEvf6/Tu1iT5gJIupYAmXVmJPFJZSJrPHDtKM044zjY8dENO4k75prMEHb946dCQXZXkr8UjoaqxvwiQoRsXlgf5XtPam95deqlNgPa0q7EILhJrOYFZ7Oio5xVXlCdrKdqjnJccnpjaww6TnSo5AvfpYJ724U3JEar2HCIa4h3p++0HJjKvPIbTWAHF39Tdrok++oeJpsFz0/yuZlyi+xhbNW7R00mwjp+qrdaOREbCxCLsIYX92NzG1NdDimhugG2gTKvk7oB4R+uFuwPb+DrQ8oCEfi2R/8ngXovgOCfu2rcQBogVHYiwbyYDbkCjqylLL2hMfYF6WY/uxNzmC68KBDB4YX7sbTkhPDd+N/mF2npsdPIxWMzu5s8sZf6iufRfAcX/lhLjBP9JzqPxDvxrnHl4Hs6m/WtpvA5h+OJ/KfP5ZRm05ijUPdJrJFFCPfIPY9vr8r9thfan5O9Fv1Mv4XHnbZiV/wwpdYrwI0zvSvwAAAP//AwBQSwMEFAAGAAgAAAAhAIg/pb/hAAAAVQEAABgAKABjdXN0b21YbWwvaXRlbVByb3BzMS54bWwgoiQAKKAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnJDBasMwEETvhf6D2bsiObFdEyyHuE4g19JCroq8tgWWZCS5tJT+e2V6So89LbPDzhu2OnzoKXlH55U1HNINgwSNtJ0yA4e31zMpIfFBmE5M1iAHY+FQPz5Und93IggfrMNLQJ3EhYrz0nL4ykvW5E87Rsr2nJLilDXkmKUNKTKWt8fnU8pY8Q1JRJsY4zmMIcx7Sr0cUQu/sTOaaPbWaRGidAO1fa8ktlYuGk2g25hA5RLx+qonqNc+v9cv2Pt7uVZbnPov5aZuk7KDE/P4CbSu6B/Uqu9eUf8AAAD//wMAUEsDBBQABgAIAAAAIQDBJ8sItgAAACEBAAATACgAY3VzdG9tWG1sL2l0ZW0xLnhtbCCiJAAooCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACskE0OgjAQRq9CegCKLlgQfmKiWzEhcV/KAE3aGdIOBm5v1egJXE7mfS/zTdlsziYP8MEQVuKQZiIJrHBQlhAqgSSauuyLjlavISSRxlD0lZiZl0LKoGdwKqS0AMbdSN4pjqOfJI2j0XAmvTpAlscsy2Vvemto8mqZd/GR/UfVgQXNMHS823i2PN1Ondl4vgyGY7P2LWjRGoR0CzYGXuBVuQhHViT37wtyUZfyV7h+AgAA//8DAFBLAwQUAAYACAAAACEAdD85esIAAAAoAQAAHgAIAWN1c3RvbVhtbC9fcmVscy9pdGVtMS54bWwucmVscyCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIzPsYrDMAwG4P3g3sFob5zcUMoRp0spdDtKDroaR0lMY8tYamnfvuamK3ToKIn/+1G7vYVFXTGzp2igqWpQGB0NPk4Gfvv9agOKxcbBLhTRwB0Ztt3nR3vExUoJ8ewTq6JENjCLpG+t2c0YLFeUMJbLSDlYKWOedLLubCfUX3W91vm/Ad2TqQ6DgXwYGlD9PeE7No2jd7gjdwkY5UWFdhcWCqew/GQqjaq3eUIx4AXD36qpigm6a/XTf90DAAD//wMAUEsDBBQABgAIAAAAIQDrgGBMUwMAAI8OAAASAAAAd29yZC9mb250VGFibGUueG1szJbPb9MwFMfvSPwPUU7jwJqkXZdV66Y2WzQk2IEVAUc3cVqL2I7itF3/AA6IE+LI38C4gwb/DNPYf8FznLRZm25LQbBGzY9n+5vnT57f8+7+KQ21MY4F4aytm5uGrmHmcZ+wQVt/0XMf27omEsR8FHKG2/oUC31/7+GD3Ukr4CwRGoxnokW9tj5MkqhVqwlviCkSmzzCDBoDHlOUwGM8qFEUvxlFjz1OI5SQPglJMq1ZhtHUM5n4Lio8CIiHD7g3opgl6fhajENQ5EwMSSRytcld1CY89qOYe1gImDMNlR5FhM1kzMaSECVezAUPkk2YTOZRKgXDTSO9o+FcYKuagLUk0PTwaTUNO9OowciiDvGr6TRnOsQv6KznTEFA4GoSW7kfYkrljKjXejJgPEb9EJTgG2mAWUuF5Rm8lZf0FrrvZfGqTVoMURjwEj62DHKRNkWIcYFNaB2jsK0bW8bST6/Jjt4QxQJLmbRj40CZA0RJOM2tPvbAr4SMsWqNSOIN88Yxion0WTUJMoCGkegb8Fb1q+vKYsJyzN+tLNasT26pX7d4qY6tDGZmMQt94J01BWIJSI9QLLRjPNGec4pYKRYLjqZRBzwN+Ftw1yjFktO6jiVOdasQgaVoWB17e04km9syEfsmIoqH61Yj4qCQ9GOygoSbEpBHAzhYlUiICRGiEomOdNY6TGegSDSkwdjuVosN9bxTkcQBZoNXJAsKFCbHYM19vvz87vLrj2wyS5RMiBcIabhmRyklu1lGCY0SvgakbgFS3XbcbcftLEIym7dAknQrQnqWZy/tNTrCKmwWWF18P/t1/uXq09urbx9WEetCXMl4knGVnisQqx5X6XqyiivM6jhu3dmy1kFmVkS2kHO0jSOM0qSsOSePygAuJqmVDJsZvWyF/oUs5eMAjcLkxoQB+w8eovKSorzaWTNjUO7juMytgJxif/m7HsrSYamMN88XrjOzzPPFzu2Zs2q+OCH0ZFSaLS7O3v88/3gvskU2j0K5tWzbzadfOVv8WbnVNrrcn96PsGc86cUj3JtGeK1lkFcL7SkZDJPVNSNrvw+x8H8rR7bRKPAq226oovBvthuHEkenmD4caWmUbDfukD5u3XhlN2LvNwAAAP//AwBQSwECLQAUAAYACAAAACEAZPVj7oEBAAApBgAAEwAAAAAAAAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQItABQABgAIAAAAIQAekRq37wAAAE4CAAALAAAAAAAAAAAAAAAAALoDAABfcmVscy8ucmVsc1BLAQItABQABgAIAAAAIQAzwlu/QQEAAOcEAAAcAAAAAAAAAAAAAAAAANoGAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAE4yjpAWBgAApiQAABEAAAAAAAAAAAAAAAAAXQkAAHdvcmQvZG9jdW1lbnQueG1sUEsBAi0AFAAGAAgAAAAhALb0Z5jSBgAAySAAABUAAAAAAAAAAAAAAAAAog8AAHdvcmQvdGhlbWUvdGhlbWUxLnhtbFBLAQItABQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAAAAAAAAAAAAAAKcWAAB3b3JkL3NldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQBAwf/xOQEAACMDAAAUAAAAAAAAAAAAAAAAAMsaAAB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQA520VMuQUAACdaAAASAAAAAAAAAAAAAAAAADYcAAB3b3JkL251bWJlcmluZy54bWxQSwECLQAUAAYACAAAACEA+JXI7/wOAADzmQAADwAAAAAAAAAAAAAAAAAfIgAAd29yZC9zdHlsZXMueG1sUEsBAi0AFAAGAAgAAAAhAMySUFR9AQAA8QIAABEAAAAAAAAAAAAAAAAASDEAAGRvY1Byb3BzL2NvcmUueG1sUEsBAi0AFAAGAAgAAAAhACJREfHVAQAA3gMAABAAAAAAAAAAAAAAAAAA/DMAAGRvY1Byb3BzL2FwcC54bWxQSwECLQAUAAYACAAAACEAiD+lv+EAAABVAQAAGAAAAAAAAAAAAAAAAAAHNwAAY3VzdG9tWG1sL2l0ZW1Qcm9wczEueG1sUEsBAi0AFAAGAAgAAAAhAMEnywi2AAAAIQEAABMAAAAAAAAAAAAAAAAARjgAAGN1c3RvbVhtbC9pdGVtMS54bWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAABVOQAAY3VzdG9tWG1sL19yZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAOuAYExTAwAAjw4AABIAAAAAAAAAAAAAAAAAWzsAAHdvcmQvZm9udFRhYmxlLnhtbFBLBQYAAAAADwAPANQDAADePgAAAAA=",EF=()=>wu(BF);async function IF(n){return new Promise((t,e)=>{const o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=e,o.src=n})}async function l9(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};const e=await Tr(new File([t],"",{})),o=await IF(e);return o.width===void 0||o.height===void 0?{width:345,height:230,buffer:t}:n.width||n.height?{width:n.width||o.width*n.height/o.height,height:n.height||o.height*n.width/o.width,buffer:t}:{width:o.width,height:o.height,buffer:t}}function xF(n,t){let e=n.filter(s=>s!=null);const o=t-(e.length-1)*20,r=.87,i=e.reduce((s,l)=>s+l.width,0);return i>o&&(e=e.map(s=>({width:s.width*o/i,height:s.height*o/i,buffer:s.buffer}))),e.map(s=>({width:s.width*r,height:s.height*r,buffer:s.buffer}))}function c9(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let o;switch(e%3){case 0:o=Y.LevelFormat.DECIMAL;break;case 1:o=Y.LevelFormat.LOWER_LETTER;break;default:o=Y.LevelFormat.LOWER_ROMAN;break}return{level:e,format:o,text:`%${e+1}. `,alignment:Y.AlignmentType.START,start:t,style:{paragraph:{indent:{left:Y.convertInchesToTwip(.3*(e+1)),hanging:Y.convertInchesToTwip(.2)}}}}})}function TF(){return[0,1,2,3,4,5,6,7].map(n=>{let t;switch(n%3){case 0:t="\u2022";break;case 1:t="\u25E6";break;default:t="\u25AA";break}return{level:n,format:Y.LevelFormat.BULLET,text:t,alignment:Y.AlignmentType.START,style:{paragraph:{indent:{left:Y.convertInchesToTwip(.3*(n+1)),hanging:Y.convertInchesToTwip(.2)}}}}})}function SF(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Y.LevelFormat.BULLET,text:"\u2611",alignment:Y.AlignmentType.START,style:{paragraph:{indent:{left:Y.convertInchesToTwip(.3*(n+1)),hanging:Y.convertInchesToTwip(.2)}}}}))}function DF(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Y.LevelFormat.BULLET,text:"\u2610",alignment:Y.AlignmentType.START,style:{paragraph:{indent:{left:Y.convertInchesToTwip(.3*(n+1)),hanging:Y.convertInchesToTwip(.2)}}}}))}var fl=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(fl||{});const LF=[{levels:c9(),reference:"number-numbering-reference"},{levels:TF(),reference:"number-bullet-reference"},{levels:SF(),reference:"checked-bullet-reference"},{levels:DF(),reference:"unchecked-bullet-reference"}];function MF(n){switch(n){case"style-color-0":return"d83931";case"style-color-1":return"de7802";case"style-color-2":return"dc9b04";case"style-color-3":return"2ea121";case"style-color-4":return"245bdb";case"style-color-5":return"6425d0";case"style-color-6":return"8f959e";default:return}}function RF(n){switch(n){case"style-bg-color-1":case"style-bg-color-2":case"style-bg-color-8":case"style-bg-color-9":return"yellow";case"style-bg-color-0":case"style-bg-color-5":return"magenta";case"style-bg-color-3":return"green";case"style-bg-color-4":case"style-bg-color-11":return"blue";case"style-bg-color-6":return"lightGray";case"style-bg-color-7":return"red";case"style-bg-color-10":return"darkGreen";case"style-bg-color-12":return"darkMagenta";case"style-bg-color-13":return"darkGray";default:return}}function OF(n){switch(n){case"style-bg-color-0":return"fbbab6";case"style-bg-color-1":return"ffdcb0";case"style-bg-color-2":return"fff7a0";case"style-bg-color-3":return"ceefc5";case"style-bg-color-4":return"d1ddfb";case"style-bg-color-5":return"d9cbf8";case"style-bg-color-6":return"eaeaea";case"style-bg-color-7":return"fe837c";case"style-bg-color-8":return"ffbd6a";case"style-bg-color-9":return"ffe662";case"style-bg-color-10":return"a8f393";case"style-bg-color-11":return"98b5ff";case"style-bg-color-12":return"b394f8";case"style-bg-color-13":return"b1b1b1";default:return}}const NF=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function a9(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(NF);if(t){const e=s=>{let l=Number(s).toString(16);return l.length<2&&(l=`0${l}`),l},o=e(t[1]),r=e(t[2]),i=e(t[3]);return`${o}${r}${i}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function oe(n,t){if(n&&n.attributes&&n.attributes[t])return n.attributes[t];if(n&&n.attributes&&n.attributes.box&&n.attributes.inputType&&t==="style-underline")return!0}function u9(n,t,e){for(let o=0;o<=e;++o){const r=`${t}${o}`;if(oe(n,r))return r}}function Ra(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function Uf(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"}function d9(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function PF(n){const t=oe(n,"inlineStyle");if(t==null)return;const e=t.split(";");for(const o of e){const r=o.split(":");if(r.length!==2)continue;const i=r[0].trim().toLowerCase(),s=r[1].trim().toLowerCase();i==="font-size"&&Ra(n,"inline-style-font-size",s),i==="color"&&Ra(n,"inline-style-color",s),i==="background-color"&&Ra(n,"inline-style-background-color",s),i==="font-family"&&Ra(n,"inline-style-font-family",s)}}function $F(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function _F(n){const t=`${oe(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function FF(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` ${n.attributes.text} `;if(n.attributes&&n.attributes.box&&n.attributes.inputType)return n.attributes.value?`${n.attributes.value}`:" "}function HF(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function jF(n){return oe(n,"inline-style-font-family")}function zF(n){const t=oe(n,"inline-style-background-color");return a9(t)}function UF(n){const t=oe(n,"inline-style-color");return a9(t)}function VF(n){PF(n);const t=oe(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!oe(n,"style-code"),link:d9(oe(n,"link")),size:_F(n),text:t?HF(n):FF(n)||n.insert,bold:!!oe(n,"style-bold"),underline:!!oe(n,"style-underline"),italics:!!oe(n,"style-italic"),strike:!!oe(n,"style-strikethrough"),superScript:!!oe(n,"style-super"),subScript:!!oe(n,"style-sub"),math:oe(n,"type")==="math"?oe(n,"src"):void 0,mention:t,fontFamily:jF(n),background:zF(n),color:t?"338fe5":MF(u9(n,"style-color-",6))||UF(n),highlight:u9(n,"style-bg-color-",13)}}function qF(){return[new Y.Paragraph({border:{top:{color:"auto",style:Y.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new Y.Paragraph({spacing:{line:0}})]}function WF(){return new Y.Paragraph({children:[new Y.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Y.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function GF(){return new Y.Paragraph({children:[new Y.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Y.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function ZF(n,t){return new Y.Paragraph({children:[new Y.ExternalHyperlink({children:[new Y.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function h9(n){if(n.heading!=null)return`Heading${n.heading}`}function f9(n){if(n.alignment!=null){if(n.alignment==="center")return Y.AlignmentType.CENTER;if(n.alignment==="right")return Y.AlignmentType.RIGHT;if(n.alignment==="left")return Y.AlignmentType.LEFT}}function QF(n){if(n.indent)return{left:Y.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:Y.convertInchesToTwip(.3*n.padding)}}function YF(n){return{type:Y.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function JF(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function m9(n,t){let e;e=n.inlineCode?"InlineCode":void 0,e=n.link?"Hyperlink":e;const o=n.size||t,r=o!=null?Math.floor(o*1.5+.5):void 0;return new Y.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:Y.UnderlineType.SINGLE}:void 0,italics:n.italics||void 0,strike:n.strike||void 0,superScript:n.superScript||void 0,subScript:n.subScript||void 0,size:r,style:e,font:n.fontFamily?JF(n.fontFamily):void 0,shading:n.background?YF(n.background):void 0,color:n.color,highlight:RF(n.highlight)})}function KF(n,t){if(n.link)return new Y.ExternalHyperlink({children:[m9(n,t)],link:n.link})}async function g9(n,t,e,o,r){const i=await r(n,t,e);if(i==null)return;const s=await l9({width:o||0,height:0,src:e},i);return new Y.ImageRun({data:i,transformation:{width:s.width||100,height:s.height||20}})}function XF(n){if(n.heading||n.heading)return n.heading}function tH(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function eH(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function nH(n,t){var o;const e=[];if(n.text&&Array.isArray(n.text)){for(let r=0;r<n.text.length;r++){const i=n.text[r];if(((o=i.attributes)==null?void 0:o.box)===!0&&t){const s=await t(i);if(s){n.text.splice(r+1,0,...s);continue}}e.push(VF(i))}return e}}function oH(n){if(n.type==="list"&&n.textOnly!==!0)return{checkbox:n.checkbox,groupId:n.groupId,ordered:!!n.ordered,level:n.level||1,start:n.start||0}}function rH(n,t){if(n.type==="embed"&&n.embedType&&Uf(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(o=>{const r=t(o),i=n.embedData[`${r}_width`],s=n.embedData[`${r}_height`];return{src:o,width:i,height:s}})}function iH(n){if(n.padding)return n.padding}function sH(n){return!!(n.type==="embed"&&n.embedType&&Uf(n.embedType)&&n.embedData&&n.embedData.src)}async function Oa(n,t,e){return{quoted:!!n.quoted,heading:XF(n),alignment:tH(n),indent:eH(n),padding:iH(n),texts:await nH(n,e),list:oH(n),images:rH(n,t),border:sH(n)}}async function lH(n,t,e,o){const r=[];if(!n.children)return[];for(const i of n.children){const s=[];for(const l of t.blocks[i])s.push(await Oa(l,e,o));r.push(s)}return r}const cH=w("to-docx");function aH(n,t){return Array(n).fill(0).map(()=>Array(t).fill(0).map(()=>({cellId:void 0,color:void 0,from:void 0,rowSpan:1,colSpan:1,width:0,originalWidth:void 0,align:void 0})))}function uH(n,t,e,o){const r=!!n.hasColTitle,i=!!n.hasRowTitle,s=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let a=0;a<e;a++)(r&&a===0||i&&c===0||s&&c%2===1)&&(o[c][a].color=l)}function dH(n){u(cH,n.children,"no table children");const t=n.rows,e=n.cols,o=n.colsWidth;if(o)for(let s=0;s<o.length;s++)o[s]===0&&(o[s]=100);const r=aH(t,e);let i=0;for(let s=0;s<t;++s)for(let l=0;l<e;++l){if(r[s][l].originalWidth=o?o[l]:void 0,r[s][l].from!==void 0)continue;const c=n.children[i];i+=1,r[s][l].cellId=c,r[s][l].color=OF(n[`${c}_background`]),r[s][l].width=o?o[l]:100,r[s][l].align=n[`${c}_align`];const a=n[`${c}_rowSpan`]||1,d=n[`${c}_colSpan`]||1;if(r[s][l].rowSpan=a,r[s][l].colSpan=d,a>1||d>1){let f=0;for(let m=0;m<a;m++)for(let p=0;p<d;p++)m===0&&(f+=o?o[l+p]:80),!(m===0&&p===0)&&(r[s+m][l+p].from=[s,l]);r[s][l].width=f}}return uH(n,t,e,r),r}async function hH(n,t,e,o,r,i,s,l,c,a){async function d(p){if(l){const A=await l(r,i,p);if(A){await o.addDoc(n,A,a);return}}if(p.type==="text"||p.textOnly===!0){const A=await Oa(p,s,c);await o.addTextBlock(A);return}if(p.type==="code"){const A=await lH(p,e,s,c);await o.addCodeBlockObject(A);return}if(p.type==="list"&&p.textOnly!==!0){const A=await Oa(p,s,c);await o.addListBlockObject(n,A);return}if(p.type==="embed"&&p.embedType){const A=p,k=A.embedData,v=A.embedType;if(Uf(v)){const T=await Oa(p,s,c);await o.addImagesBlockObject(T,a)}else p.embedType==="hr"?o.addSeparatorBlock():p.embedType==="video"?o.addVideoPlaceholder():p.embedType==="audio"?o.addAudioPlaceholder():p.embedType==="webpage"?o.addHyperlinkParagraph(d9(k.src),k.title):o.addOtherEmbedBlock(v,p.embedData);return}if(p.type==="table"){let A=[];if(p.colsWidth)A=p.colsWidth;else{const T=p.cols;A=new Array(T);for(let E=0;E<A.length;E++)A[E]=100;p.colsWidth=A}const k=dH(p),v=p.converterData||e;await o.addTableMatrix(A,k,v),o.addEmptyParagraph()}}function f(p){const A=[];for(const{type:k,data:v}of p.embedData.exportSpec){if(k==="text"){const T={id:P(),text:[{insert:v}],type:"text"};A.push(T);continue}if(k==="image"){const T={id:P(),type:"embed",embedType:"image",align:"left",embedData:{src:v}};A.push(T);continue}if(k==="link"){const T={id:P(),type:"embed",embedType:"webpage",embedData:{src:v.url,title:v.title}};A.push(T);continue}}return A}function m(p){var A;return(A=p==null?void 0:p.embedData)!=null&&A.exportSpec?f(p):[p]}for(const p of t)for(const A of m(p))await d(A)}function fH(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const mH=w("to-docx");class gH{constructor(t,e,o,r,i,s){h(this,"paragraphs");this.appId=t,this.docId=e,this.state=o,this.readImageFunc=r,this.convertBlocksFunc=i,this.defaultFontSize=s,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new Y.Paragraph({heading:h9(t),alignment:f9(t),children:await this.paragraphsFromBlockTexts(t),indent:QF(t)}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=$F(this.defaultFontSize,t.heading),o=[];for(const r of t.texts){if(r.link){const i=KF(r,e);i&&o.push(i);continue}if(r.box&&r.box.type&&r.box.type==="br"){o.push(new Y.TextRun({text:"",break:1}));continue}if(r.box&&r.box.type&&r.box.type==="image"){const i=await g9(this.appId,this.docId,r.box.src,r.box.width,this.readImageFunc);i&&o.push(i);continue}if(r.math){const i=await g9(this.appId,this.docId,r.math,0,this.readImageFunc);i&&o.push(i);continue}o.push(m9(r,e))}return o}async addCodeBlockObject(t){for(const e of t)for(const o of e){const r={style:Y.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new Y.Paragraph({style:"Code",border:{left:{...r},right:{...r},top:{...r},bottom:{...r}},children:await this.paragraphsFromBlockTexts(o)}))}}async addListBlockObject(t,e){if(e.list==null)return;let o;const r=e.list.checkbox?`${t}-${e.list.groupId}-${e.list.checkbox}`:`${t}-${e.list.groupId}`;if(this.state.listInstMap[r])o=this.state.listInstMap[r];else if(o=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[r]=o,e.list.start>0&&e.list.ordered){const s=`number-numbering-reference-${o}`,l=c9([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:s,inst:o}),this.state.listRefMap[r]=s}else e.list.ordered?this.state.listRefMap[r]=fl.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[r]=fl.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[r]=fl.UNCHECKED:this.state.listRefMap[r]=fl.BULLET;const i=h9(e);e.texts&&this.paragraphs.push(new Y.Paragraph({heading:i,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[r],level:e.list.level-1,instance:o}}))}imageDimWithBufferToImageRun(t){return new Y.ImageRun({data:t.buffer,transformation:{width:t.width,height:t.height}})}async addImagesBlockObject(t,e){if(t.images==null)return;const o=await Promise.all(t.images.map(async s=>{const l=await this.readImageFunc(this.appId,this.docId,s.src);if(l)return l9(s,l)})),r=xF(o,e),i={style:Y.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new Y.Paragraph({border:t.border?{left:{...i},right:{...i},top:{...i},bottom:{...i}}:void 0,alignment:f9(t)||Y.AlignmentType.CENTER,children:r.map(s=>this.imageDimWithBufferToImageRun(s)).flatMap((s,l,c)=>s==null?[]:c.length-1!==l?[s,new Y.TextRun({text:" "})]:s)}))}addSeparatorBlock(){qF().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new Y.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(WF())}addAudioPlaceholder(){this.paragraphs.push(GF())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(ZF(t,e))}async addTableMatrix(t,e,o){const r=t.map(i=>i!==0?i*15:1500);this.paragraphs.push(new Y.Table({rows:await this.generateTableRows(e,o),columnWidths:r}))}async generateRowCells(t,e){const o=[];for(const r of t){const i=r.cellId;if(i===void 0)continue;const s=r.width*.9;o.push(new Y.TableCell({children:await this.convertBlocksFunc(i,e.blocks[i],e,this.appId,this.docId,this.state,s),columnSpan:r.colSpan,rowSpan:r.rowSpan,width:{type:Y.WidthType.DXA,size:r.width*15},shading:r.color?{fill:r.color,type:Y.ShadingType.CLEAR,color:"auto"}:void 0}))}return o}async generateTableRows(t,e){const o=[];for(const r of t)o.push(new Y.TableRow({children:await this.generateRowCells(r,e)}));return o}async addDoc(t,e,o){const r=await this.convertBlocksFunc(t,e.blocks.root,e,this.appId,this.docId,this.state,o);r&&(this.paragraphs=this.paragraphs.concat(r))}async addOtherEmbedBlock(){}}class pH{constructor(t,e,o,r,i,s,l,c){h(this,"convertBlocks",async(t,e,o,r,i,s,l=720)=>{const c=new gH(r,i,s,this.readImage,this.convertBlocks,this.defaultFontSize);return await hH(t,e,o,c,r,i,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=o,this.readImage=r,this.defaultFontSize=i,this.getDocByBlock=s,this.getTextsByBox=l,this.backgroundImageOptions=c}async convert(t,e){return this.snapshot2docx(this.docData,t,e)}async snapshot2docx(t,e,o){const r=new Y.ImportDotx,i=this.templateData?await r.extract(this.templateData):void 0,s=t.blocks.root;u(mH,s,"data must have blocks");const l=fH(),c=await this.convertBlocks("blocks",s,t,e,o,l),a=this.backgroundImageOptions?{default:new Y.Header({children:[new Y.Paragraph({children:[new Y.ImageRun(this.backgroundImageOptions)]})]})}:{},d=new Y.Document({numbering:{config:[...LF,...l.levelConfigs]},sections:[{headers:a,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:i});return Y.Packer.toBlob(d)}}async function CH(n,t,e,o){const r=n.doc.buildResourceUrl(o,{withToken:!0});let i=await vF(r);if(!i)return;if(i.type.indexOf("/svg")!==-1){const l=await kF(i);l&&(i=new File([l],i.name))}return await i.arrayBuffer()}async function AH(n,t,e){const o=n.editorBlocks.getBlockClass(e.type);if(o.toStandardDoc)return o.toStandardDoc(n,e,t)}async function bH(n,t){const e=t.attributes,o=n.editorBoxes.getBoxClass(e.type);if(o.toStandardText)return o.toStandardText(n,e)}async function vH(n,t){let{template:e,download:o,backgroundImageOptions:r}=t!=null?t:{};e||(e=EF());const i=n.doc.toJSON(),s=(f,m,p)=>CH(n,f,m,p),l=async(f,m,p)=>AH(n,i,p),c=async f=>bH(n,f),d=await new pH(e,i,Er.default,s,void 0,l,c,r).convert("_appId","_docId");if(o){const f=URL.createObjectURL(d),m=document.createElement("a");m.setAttribute("download",`${wF(n)}.docx`),m.setAttribute("href",`${f}`),m.click(),m.remove()}return d}const Vf=w("create-editor"),p9=[va,$1,cf,af,uf,k1,df,Mf,Lf,G4,X6,g$];async function yH(n,t){var s,l,c,a,d,f,m,p,A,k,v,T,E;u(Vf,n,"app does not exists"),t.lang&&x.setLang(t.lang),so.level=(s=t.logLevel)!=null?s:Ni.DEBUG;const e=t.onReauth?async()=>{var q;const L=t.user.userId,R=t.docId,$=await((q=t.onReauth)==null?void 0:q.call(t,L,R,t.permission));return{userId:L,docId:R,permission:t.permission,appId:t.appId,token:$,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,o={auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl,reauthFunc:e,disableLogout:t.disableLogout},r=await Es.load(o),i=hs(n,r,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,components:{blocks:[Ws,Qs,V1,MC],commandProviders:[new jh,...((l=t.components)==null?void 0:l.commandProviders)||[]],decorators:[new Js,new gh],embeds:[...p9,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[ta,Hf,v6,...((a=t.components)==null?void 0:a.boxes)||[]],insertions:[Cd],blockHooks:[new F4,new X4,...((d=t.components)==null?void 0:d.blockHooks)||[]],textRenders:[new m6,new tI],options:{...t.componentsOptions}},shortcuts:[YD,xM,L1,V3,eI,E1,A$,Ac],colors:["#338FE5","#24B47E","#F0A100","#E52727","#9678D3","#2CB2AE","#EB6414","#8AAB3F"]});if(i.editorCommandProviders.registerCommandProvider(new Rn(i)),i.input.addHandler(new k_),i.input.addHandler(new ca),i.input.addHandler(new Zx),i.input.addHandler(new vM),i.input.addHandler(new Zs(i,{headingLevel:1,titlePlaceholder:x.t("placeholder.common.title"),contentPlaceholder:x.t("placeholder.common.content"),readonlyTitlePlaceholder:x.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new ea(i,(f=t.componentsOptions)==null?void 0:f.quickMenu)),i.input.addHandler(new hf(i)),i.input.addHandler(new N3(i)),i.input.addHandler(new WD),i.input.addHandler(new Y1),i.doc.registerCallback(new w_(i)),i.addCustom("remote-cursor",()=>new l5(i)),i.addCustom("block-menu",L=>new U4(L)),i.addCustom("editor-tooltip",()=>new B1(i)),t!=null&&t.enableComments&&i.addCustom("editor-comments",L=>new f6(L,new gF(L))),i.addCustom("create-options",()=>new Am(i,t)),i.addCustom("drop-target",()=>new ol(i)),i.addCustom("list-to-mindmap",()=>new Jc(i)),i.addCustom("list-to-mention",()=>new H_(i)),i.addCustom("mobile-helper",()=>new X_(i)),i.addCustom("code-caret",()=>new qD(i)),(m=t.componentsOptions)!=null&&m.mention){const L=t.componentsOptions.mention;i.addCustom("mention",()=>new N_(i,L))}if(i.addCustom("heading-collapse",()=>new A_(i)),ii.register(i),ol.register(i),yr.register(i),Oo.register(i),(A=(p=t.componentsOptions)==null?void 0:p.remoteCarets)!=null&&A.onUserChanged){const L=(v=(k=t.componentsOptions)==null?void 0:k.remoteCarets)==null?void 0:v.onUserChanged;i.doc.getRemoteUsers().on("change",R=>{L(i,R)})}return(E=(T=t.componentsOptions)==null?void 0:T.templates)!=null&&E.templates.length&&(i.addListener("docChanged",()=>{zf(i)}),i.addListener("resize",()=>{zf(i,{reset:!0})}),setTimeout(()=>{zf(i)},100)),i.doc.registerCallback({onError:async L=>{if(L.code==="ResetDoc"){Vf.error(`reset doc: ${L.message}`);const R=await Es.load(o);i.doc.reset(R)}}}),i}function kH(n){return n.toJSON!==void 0}async function wH(n,t,e){var i,s,l;u(Vf,n,"app does not exists");const o=kH(t)?t:new Yd(t,{serverUrl:e.serverUrl||""});e.lang&&x.setLang(e.lang);const r=hs(n,o,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[Ws,Qs,V1,MC],commandProviders:[new jh],decorators:[new Js,new gh],embeds:[...p9,...((i=e.components)==null?void 0:i.embeds)||[]],boxes:[ta,Hf,v6],insertions:[Cd],blockHooks:[new F4,...((s=e.components)==null?void 0:s.blockHooks)||[]],textRenders:[new m6],options:{...e.componentsOptions}},shortcuts:[L1,V3,E1,Ac]});return r.editorCommandProviders.registerCommandProvider(new Rn(r)),r.input.addHandler(new ca),r.input.addHandler(new Zs(r,{headingLevel:1,titlePlaceholder:x.t("placeholder.common.title"),contentPlaceholder:x.t("placeholder.common.content"),readonlyTitlePlaceholder:x.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),r.input.addHandler(new ea(r,(l=e.componentsOptions)==null?void 0:l.quickMenu)),r.input.addHandler(new hf(r)),r.input.addHandler(new N3(r)),r.input.addHandler(new Y1),r.addCustom("block-menu",c=>new U4(c)),r.addCustom("editor-tooltip",()=>new B1(r)),e!=null&&e.enableComments&&r.addCustom("editor-comments",c=>new f6(c,new pF(c,o))),r.addListener("clickLink",(c,a,d)=>{var m;if((m=e==null?void 0:e.events)!=null&&m.onClickLink){e.events.onClickLink(c,a,d);return}const f=d.getAttribute("link");f&&(c.readonly||a.ctrlKey||a.metaKey)&&window.open(f,"_blank")}),ii.register(r),r}function BH(n,t){var l;const e=n.doc;if(!((l=e.getVersionHelper)==null?void 0:l.call(e)))throw new Error("the editor does not support to show versions");const r=n.getCustom("create-options");if(!r)throw new Error("the editor does not support to show versions");const i=r.getData(),s=new fF(i);return l_(n,s,t)}g.tippy=i8,g.AuthError=Tc,g.AuthHeader=Bs,g.AutoScroll=Km,g.BaseURLHeader=Sc,g.BasicCommands=kx,g.BlockExclusiveHook=X4,g.BlockResizer=sa,g.BrBox=Lp,g.CodeBlock=Qs,g.CodeLineBlock=V1,g.CodeTextDecorator=Js,g.DefaultShortcuts=Ac,g.DocIdError=Qk,g.DragDrop=Rm,g.DrawioEmbed=va,g.EditorBlocks=Tg,g.EditorBoxes=Rp,g.EditorCommandProviders=k2,g.EditorComplexBlockPosition=Xe,g.EditorComplexSelectionRange=tn,g.EditorDecorators=$p,g.EditorEmbeds=Dg,g.EditorInsertions=Pp,g.EditorSimpleBlockPosition=qt,g.EditorSimpleSelectionRange=Kt,g.EmbedBlock=Mg,g.EnforceWithDocumentTitleHandler=Zs,g.EventCallbacks=Pi,g.FILL_CHAR=pb,g.FileExtError=Yk,g.HeadingBlockScrollListener=O_,g.InputtingInsertion=Op,g.LocalDoc=Yd,g.LogLevel=Ni,g.Logger=so,g.MIN_DISTANCE_THRESHOLD=Lm,g.ManualCloseDialog=Ds,g.ManualMenu=cr,g.ManualToolbar=Ss,g.MarkdownInputHandler=ca,g.MaxUserError=ch,g.OnesEditorAutoSuggest=Mh,g.OnesEditorCustomDataWrapper=Am,g.OnesEditorExclusiveBlock=Oo,g.OnesEditorHoveringBlock=$t,g.OnesEditorQuickMenu=ea,g.OnesEditorToc=dl,g.OnesEditorTocProvider=yr,g.OnesEditorToolbar=ii,g.OnesEditorTooltip=B1,g.PermissionError=Zk,g.Popup=Is,g.RemoteCarets=l5,g.RemoteCaretsDecorator=gh,g.RemoteCaretsInsertion=Cd,g.RemoteUsers=vc,g.RequestReloadError=ws,g.RichText=ce,g.ShareDBDoc=Es,g.SimpleCache=vm,g.StandardEmbedBlockCommands=N1,g.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=rd,g.TEXT_STYLE_COLOR_PREFIX=od,g.TableBlock=Ws,g.TableBlockCommandProvider=jh,g.TableShortcuts=L1,g.TextBlock=ye,g.TextBox=Dp,g.TextStyleShortcuts=E1,g.TocEmbed=X6,g.ZERO_WIDTH_SPACE_CHAR=$i,g.addAttribute=Jl,g.addClass=M,g.addCommentToBlock=la,g.addDays=Z8,g.addMetaToDoc=us,g.addMonths=G8,g.animateScrollTo=pu,g.applyPlaceholderToBlock=aa,g.assert=u,g.blockToDoc=Wd,g.blockToHtml=yd,g.blockToMarkdown=kd,g.blockToText=lc,g.blocksToDoc=Pv,g.clearAllSelection=Ag,g.clientType=xt,g.cloneBlock=bo,g.cloneChildContainer=Md,g.cloneDoc=Rd,g.cloneText=hp,g.commentToShareDbComment=mh,g.compareElement=Dl,g.comparePosition=Uu,g.complexBlockAdjustSelectionPos=Ul,g.complexBlockFindNearestChildBlock=Pg,g.complexBlockGeFirstSimpleChild=qu,g.complexBlockGetAllChildContainers=Se,g.complexBlockGetBottomChildContainers=Ng,g.complexBlockGetLastSimpleChild=Vi,g.complexBlockGetSelectedContainers=Rr,g.complexBlockGetTopChildContainers=Og,g.containerToDoc=K0,g.continuousScroll=Jm,g.convertBlockFrom=jl,g.copyBlockAttributes=Yp,g.createBlockAnchor=fo,g.createBlockCaretAnchor=jg,g.createBlockContentElement=lo,g.createBlockElement=lg,g.createBlockSimpleDocRange=nc,g.createBlockSimpleRange=Ot,g.createBoxContentElement=ug,g.createBoxElement=cg,g.createBoxOp=op,g.createChildContainer=xp,g.createComplexBlockPosition=Bt,g.createComplexDocPos=Ap,g.createComplexDocRange=bb,g.createContainer=gp,g.createContainerElement=fd,g.createDeleteOps=Xg,g.createEditor=hs,g.createEditorSelectionRange=Wt,g.createElement=b,g.createEmptyContainer=Bn,g.createEmptyDoc=or,g.createEmptyTextBlockData=Xl,g.createExpandedRange=Tl,g.createIconButton=Ir,g.createImage=ym,g.createInsertOps=Yl,g.createInsertionContentElement=fg,g.createInsertionElement=dg,g.createLocalEditor=wH,g.createOnesEditor=yH,g.createRange=km,g.createRichText=Co,g.createRootContainer=Ip,g.createSimpleBlockPosition=F,g.createSimpleDocPos=Cp,g.createTextBlockData=Vn,g.createTextButton=mr,g.createTextOp=_e,g.createTextWithReplaceSoftReturn=Xu,g.daysAfter=Tu,g.deleteText=ed,g.diffDays=Q8,g.disablePageScroll=qm,g.docToHtml=Vp,g.docToHtmlFragment=ts,g.docToMarkdown=$r,g.docToText=cc,g.downloadObjectToFile=nf,g.downloadSvgToString=t3,g.editLink=Hs,g.editorAddComment=MP,g.editorAddTextAttribute=l0,g.editorAutoInsertBlock=Jp,g.editorBreakTextBlock=Hr,g.editorClearCompositionText=Qp,g.editorClearSelectedContents=Dd,g.editorCopyBlock=Cc,g.editorDeleteBlock=Td,g.editorDeleteBlockText=Ed,g.editorDeleteBlockWithoutChildren=xd,g.editorDeleteChildContainer=gv,g.editorDeleteChildContainers=Kp,g.editorFocusToBlock=Ld,g.editorFocusToEnd=Y0,g.editorGetBlockData=Ao,g.editorGetBlockText=ge,g.editorGetBlockTextEx=rc,g.editorGetBoxData=vp,g.editorHandleKeyboardEvent=o2,g.editorInsertBlock=Fr,g.editorInsertBoxToBlock=Gp,g.editorInsertDoc=i0,g.editorInsertDocAt=Od,g.editorInsertText=Bd,g.editorInsertTextToBlock=Wp,g.editorInsertTextToBlockEx=wd,g.editorMergeTextBlock=Xp,g.editorMoveDown=b0,g.editorMoveEnd=S0,g.editorMoveHome=D0,g.editorMoveLeft=p0,g.editorMoveLineEnd=_0,g.editorMoveLineHome=$0,g.editorMovePageDown=V0,g.editorMovePageUp=U0,g.editorMoveRight=C0,g.editorMoveUp=A0,g.editorMoveWordEnd=I0,g.editorMoveWordLeft=E0,g.editorRangeClearColor=a0,g.editorRangeGetColor=Nd,g.editorRangeSetColor=c0,g.editorRemoveTextAttribute=bv,g.editorReplaceBlockText=hc,g.editorReplaceContainer=s0,g.editorRunOnce=Jd,g.editorSelectAll=Q0,g.editorSelectContainer=Vd,g.editorSelectDown=v0,g.editorSelectEnd=zd,g.editorSelectHome=L0,g.editorSelectLeft=y0,g.editorSelectLineEnd=P0,g.editorSelectLineHome=N0,g.editorSelectPageDown=W0,g.editorSelectPageUp=q0,g.editorSelectRight=k0,g.editorSelectUp=w0,g.editorSelectWordEnd=T0,g.editorSelectWordLeft=x0,g.editorSetTextColor=jr,g.editorShowFindDialog=HN,g.editorToDocx=vH,g.editorUpdateBlockData=fc,g.editorUpdateCompositionText=Zp,g.editorUpdateEmbedData=o0,g.enablePageScroll=Wm,g.escapeHtmlText=Tm,g.escapeRegExp=Lu,g.escapeSpace=D8,g.exclusiveBlock=J4,g.executeBlockCommand=xg,g.executeEmbedBlockCommand=Ig,g.executeRangeCommand=y2,g.fileToDataUrl=Tr,g.findAfterOffsetNotType=ud,g.findAllText=cd,g.findEventTargetBlock=Im,g.findInsertionById=hg,g.findNextOffset=Pb,g.findPrevOffset=Nb,g.findPrevOffsetNotType=ad,g.findPrevSimpleBlockBeforeChildContainer=Rg,g.findTarget=xr,g.findWordEnd=hd,g.findWordLeft=dd,g.format=xu,g.formatBytes=Xm,g.formatDate=ng,g.fragmentToHtml=Gm,g.fromBase64=Ml,g.fromBase64ToBlob=wu,g.fromBase64ToUint8Array=z8,g.fromDocRange=ho,g.fromNowString=Du,g.genId=P,g.getAllChildBlocks=Gu,g.getAllQuickMenuItems=w1,g.getAllSelectedBlocks=en,g.getAttributesAt=Ji,g.getBlockBackground=sg,g.getBlockByIndex=Sr,g.getBlockCaretRect=Ye,g.getBlockClass=pt,g.getBlockClassByType=Mr,g.getBlockClientRects=co,g.getBlockCommandsWithHook=Fu,g.getBlockContent=st,g.getBlockId=j,g.getBlockIndex=K,g.getBlockKind=Je,g.getBlockMinWidth=vg,g.getBlockNearestRangeFromPoint=Fg,g.getBlockOptions=tA,g.getBlockPath=ao,g.getBlockProperties=wg,g.getBlockRangeFromPoint=Vl,g.getBlockStyles=X8,g.getBlockTextLength=G,g.getBlockTools=Rt,g.getBlockType=it,g.getBoxContent=Ou,g.getBoxId=ag,g.getBoxTypeFromElement=ji,g.getChildBlockCount=Ze,g.getChildBlocks=Mt,g.getChildOffset=mo,g.getColorFromAttributes=sd,g.getComplexBlockClass=xe,g.getContainerBlockPath=wp,g.getContainerBlocks=Cg,g.getContainerBlocksElement=sc,g.getContainerById=Pr,g.getContainerId=V,g.getContainerMinWidth=gd,g.getContainerToolsElement=$b,g.getContainerWidth=Tp,g.getDistanceSquare=An,g.getElementOffset=_i,g.getEmbedType=Ne,g.getExistsBlockTools=Hl,g.getExistsContainerById=kp,g.getFileExt=Iu,g.getFirstChildBlock=Ft,g.getFirstClientRect=Sl,g.getHeadingMenuOptions=A1,g.getHorizontalPadding=du,g.getInsertionContent=Nu,g.getLastChildBlock=Jt,g.getLastClientRect=Vo,g.getListAllNextBrothers=zs,g.getLogger=w,g.getNextBlock=dt,g.getNextValidOffset=tr,g.getNextVisibleBlock=Lr,g.getOffsetInfoAfter=Xi,g.getOffsetInfoBefore=ic,g.getOpAt=ip,g.getOpLength=nd,g.getParentBlock=U,g.getParentBlockExcludeSelf=Fl,g.getParentBox=Ru,g.getParentContainer=z,g.getPrevBlock=bt,g.getPrevValidOffset=go,g.getPrevVisibleBlock=Dr,g.getRangeCommands=b2,g.getRootBlock=_u,g.getScrollContainer=bn,g.getSpecialBlockCommands=Bg,g.getStandardEmbedBlockProperties=P1,g.getTextAfterOffset=Rb,g.getTextBeforeOffset=Ob,g.getTextBlockChild=ql,g.getTextBlockClass=gg,g.getTextBlockContentChildTextLength=$e,g.getTextBlockContentChildType=Hg,g.getTextBlockContentChildren=yn,g.getTextLength=me,g.getTextOpLength=Zu,g.getTextWidth=Ol,g.getToolbar=Vc,g.handleBlockElementUpdated=yg,g.hasAltOnly=P8,g.hasClass=rt,g.hasCtrlOrCmd=Hm,g.hasCtrlOrCmdOnly=N8,g.hideBlock=rg,g.htmlToFragment=Rl,g.i18n=x,g.injectDocToHtmlFragment=as,g.injectStyle=Dm,g.insertEmptyBlock=nA,g.insertEmptyEmbedBlock=Hu,g.insertText=po,g.intersectionCommands=zy,g.isBackspace=zm,g.isBlock=Jo,g.isBox=Mu,g.isCJK=$m,g.isChildContainer=Ke,g.isChildNode=wt,g.isCollapsedRange=Ab,g.isComplexBlockPosition=zu,g.isComplexKindBlock=at,g.isContainer=vn,g.isContainerSelectedAllChildBlocks=G0,g.isControlEvent=Go,g.isDelete=_8,g.isDraggingFiles=Pl,g.isElementVisible=gu,g.isEmbedBlock=Te,g.isEmptyContainer=pd,g.isEmptyDoc=tc,g.isEmptyTextBlock=Tt,g.isEmptyTextBlockWithoutCompositionText=Gs,g.isEnterOnly=jm,g.isEscape=yu,g.isFirefox=bu,g.isFirstChildBlockInComplexBlock=LA,g.isHighSurrogate=B8,g.isInBlock=Pu,g.isInBlockTools=zi,g.isLetter=Pm,g.isLowSurrogate=uu,g.isMatchShortcut=jn,g.isMoveForward=R8,g.isNavigationEvent=M8,g.isNavigationKey=Fm,g.isNodeRemoved=Bm,g.isNumber=Nm,g.isPrintableKey=vu,g.isRootBlock=Wn,g.isRootContainer=Ct,g.isSafari=_m,g.isSameDay=Su,g.isShiftEnter=$8,g.isShiftTab=H8,g.isShortcutEvent=O8,g.isSimpleBlock=K8,g.isSimpleBlockPosition=uo,g.isSimplePos=pp,g.isSimpleRange=ec,g.isSpace=Ll,g.isTab=F8,g.isTextBlockContentBoxChild=Pe,g.isTextBlockContentChild=qi,g.isTextBlockContentInsertionChild=Un,g.isTextBlockContentTextChild=Wi,g.isTextKindBlock=_,g.isTextKindBlockType=Ui,g.isToday=tg,g.isValidOffset=le,g.isVisibleBlock=_l,g.isYesterday=eg,g.loadJs=Em,g.loadJsPromise=qo,g.lockers=Ge,g.mergeCommands=Uc,g.mergeDocs=rr,g.mergeOps=td,g.mergeText=hb,g.multiSplitText=Vg,g.parseShortcut=Um,g.patchNode=Hi,g.pointInRect=Wo,g.rangeAddAttribute=Yi,g.rangeGetTextColor=dp,g.rangeRemoveAttribute=Nr,g.rangeSetTextColor=cp,g.rangeTransformText=sp,g.registerDragDrop=Cu,g.removeAttribute=id,g.removeClass=H,g.removeLastBr=cb,g.removePlaceholderFromBlock=f4,g.removeStyle=Sm,g.replaceAll=Y8,g.replaceAllCaseInsensitive=J8,g.replaceAllText=mp,g.replaceText=Kl,g.requestDownload=$l,g.resetListStart=Vs,g.scrollable=Ym,g.selectFile=Qo,g.selectedBlockToDoc=gc,g.selectionToDoc=cs,g.setAttributes=fu,g.setClipboardData=Nl,g.setClipboardDataByEvent=W8,g.setColorToAttributes=ap,g.setDataset=hu,g.setDefaultCursor=Fi,g.setStyles=mu,g.shareDBCommentToDocObject=fh,g.shareDBDocCommentToComment=i5,g.shortcutToDisplayText=j8,g.showBlock=ig,g.showDocVersions=BH,g.splitText=ve,g.splitToThree=Gt,g.stringToDataUrl=Bu,g.stringToObjectUrl=Eu,g.subText=qg,g.textNodeOffsetFromPoint=wm,g.toBase64URL=Zo,g.toPlainText=vt,g.toPlainTextKeepLength=ld,g.trimChar=Au,g.unexclusiveBlock=K4,g.unicodeLength=E8,g.unicodeSubstr=I8,g.updateBlockSelection=bg,g.updateOpAttributes=fp,g.updateTextBlockContent=Mb,g.updateUrl=ku,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
691
|
+
</svg>`,{t:Rf}=T;class U${constructor(t){h(this,"goBackButton");h(this,"playButton");h(this,"revertButton");this.options=t;const e=b("button",["dialog-text-button"],null),o=b("span",["dialog-button-icon"],e);o.innerHTML=z$,b("span",["dialog-button-text"],e,Rf("version.goBack"));const r=b("button",["dialog-version-button"],null,Rf("version.play")),i=b("button",["dialog-version-button"],null,Rf("version.revertVersion"));this.goBackButton=e,this.playButton=r,this.revertButton=i,this.bindEvent()}bindEvent(){const{onBack:t,onPlay:e,onRevert:o}=this.options;this.playButton.onclick=e,this.goBackButton.onclick=t,this.revertButton.onclick=o}disabledButton(){}render(t,e=!1){e||t.append(this.goBackButton,this.playButton,this.revertButton)}destroy(){this.playButton.onclick=null,this.goBackButton.onclick=null,this.revertButton.onclick=null}}const be=w("split-text-actions");function O6(n){return n.length>2?!1:n.length===1?n[0].insert!==void 0:(u(be,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].insert!==void 0)}function N6(n){return n.length>2?!1:n.length===1?n[0].delete!==void 0:(u(be,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].delete!==void 0)}function P6(n){return n.length>2?!1:n.length===1?n[0].insert===void 0&&n[0].delete===void 0&&n[0].attributes!==void 0:(u(be,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].attributes!==void 0)}function V$(n){const t=[],e=Q.default(n);if(e.length===0)return[];if(e.length===1)return[n];if(e.length===2&&(N6(n)||O6(n)||P6(n)))return[n];const o=(i,s)=>i>0?[{retain:i},s]:[s];let r=0;for(;e.length>0;){const i=e[0];if(i.retain!==void 0&&i.attributes===void 0){u(be,i.retain>0,`invalid text op: ${JSON.stringify(i)}`),u(be,e.length>1,`invalid text op: ${JSON.stringify(i)}`);const s=e[1];u(be,s.delete||s.insert!==void 0||s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=i.retain,t.push(o(r,s)),s.delete!==void 0?r-=s.delete:s.insert!==void 0?r+=s.insert.length:(u(be,s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),u(be,s.retain!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=s.retain),e.splice(0,2)}else u(be,i.delete||i.insert!==void 0||i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),t.push(o(r,i)),e.shift(),i.retain!==void 0&&(u(be,i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),r+=i.retain),i.insert&&(r+=i.insert.length)}return t}function $6(n){if(u(be,n.length===1||n.length===2,`not a single action op: ${JSON.stringify(n)}`),n.length===1)return 0;const t=n[0].retain;return u(be,typeof t=="number"&&t>0,`invalid retain: ${JSON.stringify(n)}`),t}let _6=0;function q$(n,t,e){const o=_6;_6+=1;const r=vt(n);return{insert:" ",attributes:{box:!0,id:P(),type:"history-deleted-box",user:e,created:Date.now(),text:r,deletedOffset:t,deletedOrder:o}}}function W$(n,t,e){const o=$6(t),r=t.length===1?t[0].delete:t[1].delete;u(be,typeof r=="number",`not a delete op: ${JSON.stringify(t)}`);const{left:i,middle:s,right:l}=Gt(n,o,r),c=q$(s,o,e);return[...i,c,...l]}function G$(n,t,e){const o=$6(t),r=t.length===1?t[0].insert:t[1].insert;u(be,typeof r=="string",`invalid insert op: ${JSON.stringify(t)}`);const i=t.length===1?t[0].attributes:t[1].attributes,l=Jl([{insert:r,attributes:i}],"insertedBy",e);return po(n,o,l,null)}function Z$(n,t,e){const o=V$(t).reverse();let r=n;for(const i of o)N6(i)?r=W$(r,i,e):O6(i)?r=G$(r,i,e):(u(be,P6(i),`unknown op: ${JSON.stringify(i)}`),r=ce.apply(r,i));return r}const Q$=w("history-update-block-text");function F6(n){const t=[],e=[];let o=0;return n.forEach(r=>{var i;if((i=r.attributes)!=null&&i.box){const s=r.attributes;if(s.type==="history-deleted-box"){t.push({boxData:s,offset:o});return}}e.push(r),o+=nd(r)}),t.sort((r,i)=>i.offset-r.offset),{deletedBoxes:t,newText:e}}function Y$(n,t,e){let o=n;return t.forEach(r=>{const i=ce.transformCursor(r.offset,e,!1);o=po(o,i,[{insert:" ",attributes:r.boxData}],null)}),o}function J$(n){n.sort((t,e)=>t.boxData.deletedOffset!==e.boxData.deletedOffset?t.boxData.deletedOffset-e.boxData.deletedOffset:t.boxData.deletedOrder-e.boxData.deletedOrder)}function K$(n){if(n.length<=1)return n;const t=n[0].offset;n.forEach(e=>{u(Q$,e.offset===t,`invalid boxes group, ${JSON.stringify(n)}`)}),J$(n);for(let e=n.length-1;e>=1;e--){const o=n[e],r=n[e-1];o.boxData.user.userId===r.boxData.user.userId&&(r.boxData.text+=o.boxData.text,n.splice(e,1))}return n}function X$(n){let{newText:t,deletedBoxes:e}=F6(n);const o=new Map;return e.forEach(i=>{let s=o.get(i.offset);s||(s=[],o.set(i.offset,s)),s.push(i),s.sort((l,c)=>l.boxData.deletedOffset-c.boxData.deletedOffset)}),Array.from(o.values()).sort((i,s)=>s[0].offset-i[0].offset).forEach(i=>{const s=i[0].offset;K$(i).reverse().forEach(l=>{t=po(t,s,[{insert:" ",attributes:l.boxData}],null)})}),t}function t_(n,t,e){let{newText:o,deletedBoxes:r}=F6(n);return o=Z$(o,t,e),o=Y$(o,r,t),o=X$(o),o}const On=w("history-doc");function Nn(n){u(On,!1,"no local actions for history doc")}class e_ extends Pi{constructor(e,o){super();h(this,"doc");h(this,"editor");this.doc=Q.default(e),this.editor=o}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Q.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);u(On,r,`no container data: ${e}`);const i=r[o];return u(On,i,`no block data: ${o}`),i}localUpdateBlockText(){Nn()}localUpdateBlockData(){Nn()}localInsertBlock(){Nn()}localDeleteBlock(){Nn()}localInsertChildContainer(){Nn()}localDeleteChildContainers(){Nn()}uploadResource(){Nn()}async addResources(e){Nn()}getServerMeta(){var e,o,r;return(r=(o=(e=this.editor.doc.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}buildResourceUrl(e){return this.editor.doc.externalDoc.buildResourceUrl(e)}request(){Nn()}broadcastMessage(){Nn()}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new vc}destroy(){this.clearCallbacks()}transformBlockIndex(e,o,r){const i=this.doc.blocks[e];u(On,i,`no container blocks: ${e}`);let s=0;for(let l=0;l<i.length;l++)if(!i[l].deletedBy){if(s===o)return l;s++}return r&&u(On,!1,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),u(On,s===o,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),i.length}onDeleteBlock(e,o,r){const i=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e][i];u(On,!l.deleted,`block has already deleted: ${e}/${o}`),l.deletedBy=r,this.callbacks.forEach(c=>{var a;return(a=c.onUpdateBlockData)==null?void 0:a.call(c,e,i,{insert:{},delete:[]},!0)})}onInsertBlock(e,o,r,i){const s=this.transformBlockIndex(e,o,!1),l=this.doc.blocks[e],c=Q.default(r);c.insertedBy=i,l.splice(s,0,c),this.callbacks.forEach(a=>{var d;return(d=a.onInsertBlock)==null?void 0:d.call(a,e,s,c,!0)})}onUpdateBlockText(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),c=this.doc.blocks[e][s];u(On,!c.deleted,`block has already deleted: ${e}/${o}`);const a=c.text;u(On,a,`no text for block: ${JSON.stringify(c)}`);const d=t_(a,r,i);c.text=d,this.callbacks.forEach(f=>{var m;return(m=f.onUpdateBlockText)==null?void 0:m.call(f,e,o,r,!0)})}onUpdateBlockData(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e],c=l[s];u(On,!c.deleted,`block has already deleted: ${e}/${o}`);const a=Q.default(c);a.updatedBy=i,r.delete.forEach(d=>delete a[d]),Object.entries(r.insert).forEach(([d,f])=>{a[d]=f}),l[s]=a,this.callbacks.forEach(d=>{var f;return(f=d.onUpdateBlockData)==null?void 0:f.call(d,e,s,r,!0)})}onCreateContainer(e,o,r){this.doc.blocks[e]=Q.default(o),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,!0)})}}const{t:H6}=T;function wi(n,t){return t==="insert"?H6("version.insert",{name:n.displayName}):H6("version.delete",{name:n.displayName})}function br(n,t){const{userId:e}=t;return["flag","selection"].reduce((r,i)=>{const s=n.doc.getRemoteUsers().getFixedUserColor(e,i);return r[i]=s,r},{})}class n_{renderText(t,e,o){if(!o.box&&o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=br(t,o.insertedBy);return{classes:["history-inserted-text"],attributes:{"history-inserted-by":r.displayName,"data-op-description":wi(r,"insert")},styles:{[vi]:i,[yi]:s}}}return{}}renderBlock(t,e,o){if(o.deletedBy){const r=o.deletedBy,{flag:i,selection:s}=br(t,r);return{classes:["history-deleted-block"],attributes:{"history-deleted-by":r.displayName,"data-op-description":wi(r,"delete")},styles:{[vi]:i,[yi]:s}}}if(o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=br(t,r);return{classes:["history-inserted-block"],attributes:{"history-inserted-by":r.displayName,"data-op-description":wi(r,"insert")},styles:{[vi]:i,[yi]:s}}}return{}}updateBlock(t,e,o,r){if(r.deletedBy){const i=r.deletedBy,{flag:s,selection:l}=br(t,i);M(o,"history-deleted-block"),fu(o,{"history-inserted-by":i.displayName,"data-op-description":wi(i,"delete")}),mu(o,{[vi]:s,[yi]:l});return}if(r.insertedBy){const i=r.insertedBy,{flag:s,selection:l}=br(t,i);M(o,"history-inserted-block"),fu(o,{"history-inserted-by":i.displayName,"data-op-description":wi(i,"insert")}),mu(o,{[vi]:s,[yi]:l})}}}const j6=w("history-deleted-box");function o_(n,t,e,o){const r=o;u(j6,r.text,`no text for text box data: ${JSON.stringify(o)}`),u(j6,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`);const i=b("span",["history-deleted-box"],e,r.text),s=r.user,{flag:l,selection:c}=br(n,s);i.setAttribute("history-deleted-by",s.displayName),i.setAttribute("data-op-description",wi(s,"delete")),i.style.setProperty(vi,l),i.style.setProperty(yi,c)}function r_(n,t,e,o){return t.text}const i_={boxType:"history-deleted-box",updateBoxContent:o_,convertTo:r_},Ee=w("version-dialog");class s_{constructor(t,e){h(this,"editor");h(this,"dialog",null);h(this,"oldViewer",null);h(this,"versionOptions");h(this,"versionList",null);h(this,"actionButtons",null);h(this,"provider");h(this,"components");h(this,"handleClose",()=>{var t;(t=this.dialog)==null||t.hide()});h(this,"handlePlay",()=>{var e;u(Ee,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;u(Ee,t,`The version: ${t} is invalid`),this.viewVersion(t,{play:!0,speed:150})});h(this,"handleRevert",async()=>{var e,o;u(Ee,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;u(Ee,t,`The version: ${t} is invalid`),await this.versionHelper.revertVersion(t.version),(o=this.dialog)==null||o.hide()});h(this,"handleSelectVersion",t=>{u(Ee,t,`The version: ${t} is invalid`),this.viewVersion(t)});h(this,"viewVersion",async(t,e={play:!1,speed:1e3})=>{var p,A,k;this.oldViewer&&(this.oldViewer.destroy(),this.oldViewer=null),u(Ee,this.versionList,"The versionList did not render"),u(Ee,this.actionButtons,"The actionButtons did not render");const o=t.type==="minor"?this.versionList.beforeVersion:this.versionList.beforeMajorVersion,r=o?o.version:0,i=this.versionList.isSelectedFirstVersion,s=this.versionList.isSelectedLastVersion;this.actionButtons.revertButton.disabled=i,this.actionButtons.playButton.disabled=i;let l=(p=this.versionOptions)==null?void 0:p.hideOps;if((A=this.versionOptions)!=null&&A.onWillChangeVersion){const v=this.versionOptions.onWillChangeVersion(this.editor,t,i,s);v!=null&&v.hideOps&&(l=!0)}let c,a;if(l)c=await this.versionHelper.getVersion(t.version),a=[];else{const v=await this.versionHelper.getHistoryData(t.version,r);c=v.doc,a=v.historyData}const{editorElement:d}=this.components;d.innerHTML="";const f=new e_(c,this.editor),m=this.provider.createHistoryEditor(d,f);m.editorBlockRenders.registerRender(new n_),m.editorBoxes.registerBoxClass(i_),M(m.rootElement,M6.HISTORY);try{await j$(f,this.versionHelper,a,e)}finally{this.oldViewer=m}(k=this.versionOptions)!=null&&k.onVersionChanged&&this.versionOptions.onVersionChanged(this.editor,m,t,i,s)});h(this,"setShowOps",t=>{var e;if(this.versionOptions){this.versionOptions.hideOps=!t;const o=(e=this.versionList)==null?void 0:e.activeVersion;u(Ee,o,`The version: ${o} is invalid`),this.viewVersion(o)}});this.editor=t,this.provider=e;const o=b("div",["version-dialog"],null),r=b("div",["version-dialog-note-viewer"],o),i=b("div",["version-dialog-action-container"],r),s=b("div",["version-dialog-editor"],r),l=b("div",["version-dialog-versions-list"],o);this.components={root:o,editorElement:s,actionContainer:i,versionsListContainer:l}}get versionHelper(){u(Ee,this.editor.doc.getVersionHelper,"Can not get getVersionHelper from doc");const t=this.editor.doc.getVersionHelper();return u(Ee,t,"current doc does not support version"),t}renderContent(t){var s,l;const{actionContainer:e,versionsListContainer:o}=this.components;e.innerHTML="";const r=new U$({onBack:this.handleClose,onPlay:this.handlePlay,onRevert:this.handleRevert});r.render(e,(s=this.versionOptions)==null?void 0:s.hideActions),this.actionButtons=r,o.innerHTML="";const i=new _$({versions:t,useCreatedBy:(l=this.versionOptions)==null?void 0:l.useCreatedBy,onSelectVersion:this.handleSelectVersion,getMarkColor:c=>{const{flag:a}=br(this.editor,c);return a}});i.render(o),this.versionList=i}initViewVersion(){var t;if((t=this.versionOptions)!=null&&t.initSelectedVersion){u(Ee,this.versionList,"The versionList did not render");const{initSelectedVersion:e}=this.versionOptions,o=this.versionList.selectVersionByVersionNum(e);u(Ee,o,`The version: ${o} is invalid`),this.viewVersion(o)}else{u(Ee,this.versionList,"The versionList did not render");const e=this.versionList.activeVersion;u(Ee,e,`The version: ${e} is invalid`),this.viewVersion(e)}}async show(t){this.versionOptions={...this.versionOptions,...t};const e=await this.versionHelper.getVersions();if(this.versionOptions.hideNonVersionedOps&&e.length&&e[0].version===-1&&e.shift(),this.versionOptions.onVersionsLoaded&&this.versionOptions.onVersionsLoaded(this.editor,e),this.renderContent(e),this.initViewVersion(),!this.dialog){const{root:o}=this.components;this.dialog=new $$(o)}this.dialog.show(t.container)}destroy(){var t,e,o;(t=this.dialog)==null||t.destroy(),(e=this.versionList)==null||e.destroy(),(o=this.actionButtons)==null||o.destroy()}}function l_(n,t,e){const o=n.addCustom("version-dialog",()=>new s_(n,t));return o.show(e),{setShowOps:o.setShowOps}}const GV="",c_=w("heading-collapse");function Of(n){var e;const t=Number.parseInt((e=n.getAttribute("data-style-heading"))!=null?e:"",10);return u(c_,t,"not a heading block"),t}function Ve(n){return!!n.getAttribute("data-style-heading")}function a_(n){return!rt(n,"heading-collapsed")}function vr(n){return rt(n,"heading-collapsed")}function z6(n){if(bt(n))return!1;const e=z(n);return Ct(e)}const u_=w("heading-collapse");function Nf(n){u(u_,Ve(n),"not a heading block");const t=[],e=Of(n);let o=dt(n);for(;o&&!(Ve(o)&&Of(o)<=e);)t.push(o),o=dt(o);return t}function U6(n,t){if(!Wn(t))return;n.selection.selectBlock(t,0),Nf(t).forEach(o=>{rg(o)}),M(t,"heading-collapsed")}function Bi(n,t){Nf(t).forEach(o=>{ig(o)}),H(t,"heading-collapsed")}function d_(n,t){a_(t)?U6(n,t):Bi(n,t)}const h_=[Ch,Ah,bh,vh,yh,kh,wh,Bh];function f_(n){const t=b("button",["heading-collapse-button"],null);return t.setAttribute(`data-editor-tooltip-${n.clientId}`,"Collapse / Expand"),t.innerHTML=ph,t}function V6(n){return ga(n).querySelector("button.heading-collapse-button")}function q6(n,t){V6(t)||z6(t)||!Wn(t)||G1(t,f_(n),-1)}function m_(n){var t;(t=V6(n))==null||t.remove()}function W6(n,t){ga(t).querySelector("button.heading-collapse-button")||q6(n,t)}function g_(n){const t=Of(n),e=b("button",["heading-marker"],null);return e.innerHTML=h_[t-1],e}function G6(n){return ga(n).querySelector("button.heading-marker")}function Pf(n){G6(n)||z6(n)||!Wn(n)||G1(n,g_(n),1)}function Z6(n){const t=G6(n);t==null||t.remove()}function Q6(n){Z6(n),Ve(n)&&Pf(n)}class p_{handleDrop(t,e,o,r){if(Pl(e)||!Ve(e)||!vr(e))return;const i=Nf(e);i.unshift(e);const s=i.reverse();let l=null;return t.doc.beginBatchUpdate(),s.forEach((c,a,d)=>{const f=t.getBlockData(c),m=bo(t.editorBlocks,t.doc.toJSON(),f),p=t.insertDocAt(o,r,m)[0];a===d.length-1&&(l=p)}),t.doc.endBatchUpdate(),t.doc.beginBatchUpdate(),s.forEach(c=>{t.deleteBlock(c)}),t.doc.endBatchUpdate(),l&&U6(t,l),!0}}const C_=w("heading-collapse");class A_{constructor(t){h(this,"handleLoad",()=>{this.showCollapseButtons()});h(this,"handleHoverBlock",(t,e)=>{e&&(H(e,"hovering-heading"),Ve(e)&&Ct(z(e))&&(Pf(e),vr(e)||m_(e))),t&&Ve(t)&&Ct(z(t))&&(M(t,"hovering-heading"),Z6(t),q6(this.editor,t))});h(this,"handleClick",(t,e)=>{const o=xr(e,"button.heading-collapse-button");if(!o)return;const r=U(o);!r||(u(C_,Ve(r),"not a heading block"),d_(this.editor,r),W6(this.editor,r))});this.editor=t,t.addListener("load",this.handleLoad),t.addListener("click",this.handleClick),$t.get(t).addListener("change",this.handleHoverBlock),this.showCollapseButtons(),setTimeout(()=>{ol.get(t).addHandler(new p_)})}showCollapseButtons(){const t=Mt(this.editor.rootContainer).filter(Ve);t.length!==0&&(t[0]===Ft(this.editor.rootContainer)&&t.splice(0,1),t.forEach(Pf))}destroy(){this.editor.removeListener("load",this.handleLoad),this.editor.removeListener("click",this.handleClick)}}function La(n){const t=n.selection.range;if(t.isCollapsed()||t.start.blockId===t.end.blockId)return;const e=n.getBlockById(t.start.blockId),o=n.getBlockById(t.end.blockId);vr(e)&&Bi(n,e),vr(o)&&Bi(n,o)}function b_(n){La(n);const t=n.getFocusedBlock();!Ve(t)||vr(t)&&Bi(n,t)}function v_(n){La(n);const t=n.getFocusedBlock();if(!Ve(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===G(n,t)&&vr(t)&&Bi(n,t)}function y_(n){La(n);const t=n.getFocusedBlock();if(!Ve(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===0&&vr(t)&&Bi(n,t)}class k_{handleBeforeKeyDown(t,e){return vu(e.key)&&La(t),e.key==="Enter"?(b_(t),!1):e.key==="Delete"?(v_(t),!1):(e.key==="Backspace"&&y_(t),!1)}}class w_{constructor(t){this.editor=t}onInsertBlock(t,e,o,r){this.updateBlockIfNeeded(o.id)}onUpdateBlockData(t,e,o,r){const i=this.editor.doc.getBlockData(t,e);this.updateBlockIfNeeded(i.id,o)}updateBlockIfNeeded(t,e){setTimeout(()=>{const o=this.editor.findBlockById(t);if(!!o){if(!Ve(o)){e&&e.delete.includes("heading")&&Q6(o);return}rt(o,"hovering-heading")&&W6(this.editor,o),Q6(o)}},100)}}function B_(n){return!!n.heading}function Y6(n){var e;const t=n.heading;return(e=Number.parseInt(`${t}`,10))!=null?e:1}function J6(n,t){var e;return{parentNode:t,children:[],text:vt((e=n.text)!=null?e:[]),level:Y6(n),block:n}}class dl{constructor(){h(this,"nodes",[])}appendBlock(t){const e=this.findParent(Y6(t),this.nodes);e?e.children.push(J6(t,e)):this.nodes.push(J6(t,null))}findParent(t,e){const o=e[e.length-1];if(!o||t<=1)return null;if(o.level===t-1)return o;const r=this.findParent(t,o.children);return r||(o.level<t?o:null)}static buildToc(t){const e=new dl,o=t.blocks.root;for(let r=0;r<o.length;r++){const i=o[r];B_(i)&&e.appendBlock(i)}return e}}class yr extends Yt.TypedEmitter{constructor(e){super();h(this,"toc",new dl);h(this,"updateToc",ee.default(()=>{this.updateTocNow()},500));this.editor=e,e.doc.registerCallback(this),this.updateToc()}destroy(){this.editor.doc.unregisterCallback(this)}isHeadingBlock(e){return!!e.heading}onInsertBlock(e,o,r,i){e==="root"&&this.isHeadingBlock(r)&&this.updateToc()}onDeleteBlock(e,o,r){e==="root"&&this.updateToc()}onUpdateBlockText(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}onUpdateBlockData(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}static register(e){return e.addCustom("editor-toc",()=>new yr(e))}static get(e){return e.getCustom("editor-toc")}updateTocNow(){this.toc=dl.buildToc(this.editor.doc.toJSON()),this.emit("change",this.editor,this.toc)}}const ZV="";function E_(n){return n.nodes.length===0?!0:n.nodes.length>1?!1:n.nodes[0].children.length===0}function $f(n,t){t.forEach(e=>{const o=b("div",["toc-node"],n),r=b("div",["toc-title"],o);if(b("span",["toc-text"],r,e.text).setAttribute("data-block-id",e.block.id),e.children.length>0){const s=b("div",["toc-children"],o);$f(s,e.children)}})}function I_(n,t){const e=xr(t,".toc-text");if(!e)return;const o=e.getAttribute("data-block-id");if(!o)return;const r=n.findBlockById(o);!r||(t.preventDefault(),t.stopPropagation(),n.selection.selectBlock(r,0))}function K6(n,t,e){if(H(t,"loading"),t.innerHTML="",E_(e)){b("div",["toc-empty-message"],t,"No toc");return}e.nodes.length===1?$f(t,e.nodes[0].children):$f(t,e.nodes),Jd(n,"toc-click-handler",()=>{n.addListener("click",I_)})}class x_{constructor(t){h(this,"handleUpdateToc",(t,e)=>{Array.from(t.rootContainer.querySelectorAll('.embed-block[data-type="editor-block"][data-embed-type="toc"]')).forEach(r=>{const i=r.querySelector(".editor-toc-container");i&&K6(t,i,e)})});this.editor=t,yr.register(t).addListener("change",this.handleUpdateToc)}destroy(){yr.register(this.editor).removeListener("change",this.handleUpdateToc)}get toc(){return yr.register(this.editor).toc}}function T_(n,t){const e=b("div",["editor-toc-container"],t),r=n.addCustom("init-editor-toc",()=>new x_(n)).toc;r.nodes.length===0?M(e,"loading"):K6(n,e,r)}function S_(n,t,e,o){return o==="markdown"?"[toc]":""}function D_(n,t,e){const{data:o}=e;if(!o||o.embedType!=="toc"||!_(n,t))return null;const r={};return{blockData:{id:P(),type:"embed",embedType:"toc",embedData:r}}}const X6={embedType:"toc",createEmbedContent:T_,convertTo:S_,convertFrom:D_};function L_(n){return!!n.getAttribute("data-style-heading")}function _f(n,t){return L_(t)&&G(n,t)>0}function M_(n){const t=bn(n.rootElement);let e=0,o=0,r=0;if(t===document.documentElement){const i=n.rootContainer.getBoundingClientRect();e=i.left+i.width/2,o=10,r=t.offsetHeight}else{const i=t.getBoundingClientRect();e=i.left+i.width/2,o=i.top+10,r=i.bottom}for(;o<r;){const i=document.elementsFromPoint(e,o);for(let s=0;s<i.length;s++){const l=U(i[s]);if(l&&n.rootContainer.contains(l))return l}o+=10}return null}function Ff(n,t){let e=t;for(;e&&!_f(n,e);)e=dt(e);return e}function t9(n){if(bt(n))return!1;const e=z(n);return Ct(e)}function Ma(n,t){let e=t;for(;e&&!_f(n,e);)e=bt(e),e&&t9(e)&&(e=null);return e}const R_=.3;class O_ extends Yt.TypedEmitter{constructor(e){super();h(this,"scrollContainer");h(this,"scrollEventTarget");h(this,"scrollStatus",{curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null});h(this,"handleScroll",ee.default(()=>{const e={curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null};let o=M_(this.editor);if(o&&(o=_u(o)),!o||!this.scrollContainer){this.setStatus(e);return}if(t9(o)&&(o=dt(o)),!o){this.setStatus(e);return}if(_f(this.editor,o)){e.curHeadingBlock=o,e.previousHeadingBlock=Ma(this.editor,o),e.nextHeadingBlock=Ff(this.editor,o),this.setStatus(e);return}const r=this.scrollContainer.getBoundingClientRect(),i=Ff(this.editor,o);if(i){const l=i.getBoundingClientRect();if(l.top>r.top&&l.top<r.top+r.height*R_){e.curHeadingBlock=i,e.previousHeadingBlock=Ma(this.editor,i),e.nextHeadingBlock=Ff(this.editor,i),this.setStatus(e);return}e.nextHeadingBlock=i}const s=Ma(this.editor,o);s&&(e.curHeadingBlock=s,e.previousHeadingBlock=Ma(this.editor,s)),this.setStatus(e)},200));this.editor=e,setTimeout(()=>{this.start()},50)}setStatus(e){this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock&&this.scrollStatus.nextHeadingBlock===e.nextHeadingBlock&&this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock||(this.scrollStatus=e,this.emit("change",this.editor,e))}start(){this.stop(),this.scrollContainer=bn(this.editor.rootElement),this.scrollEventTarget=this.scrollContainer===document.documentElement?document:this.scrollContainer,this.scrollEventTarget.addEventListener("scroll",this.handleScroll),this.handleScroll()}stop(){this.scrollEventTarget&&this.scrollEventTarget.removeEventListener("scroll",this.handleScroll)}destroy(){this.stop(),this.scrollEventTarget=void 0}}class N_{constructor(t,e){h(this,"suggest");h(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Wn(i)){const s=U(z(i));if(s&&it(s)==="code")return!1}return!0});h(this,"onClickItem",(t,e,o)=>{const r=e.data,i={id:P(),type:"mention",box:!0,created:Date.now(),iconUrl:r.avatarUrl,text:r.displayName,mentionId:r.userId},s=this.editor.selection.range;if(!s.isCollapsed()||!s.isSimple())return;const l=s.focus,c=this.editor.getBlockById(l.blockId);this.editor.insertBoxToBlock(c,l.offset,i)});h(this,"queryItems",async(t,e)=>(await this.options.queryUsers(this.editor,e)).map(i=>({id:i.userId,name:i.displayName,icon:`<img src="${i.avatarUrl}" class="mention-user-avatar">`,element:i.element,data:i,subText:i.email})));this.editor=t,this.options=e,this.suggest=new Mh(t,{id:"editor-mention",trigger:["@"],autoDeleteTrigger:!0,showLoading:!0,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}destroy(){}}w("mathjax-box");function P_(n,t,e,o){const r=o,i=b("a",["mention-container"],e);b("span",["mention-name"],i,`@${r.text}`),i.setAttribute("data-mention-id",r.mentionId)}function $_(n,t,e){}function __(n,t,e,o){return`@${t.text}`}const Hf={boxType:"mention",updateBoxContent:P_,handleClickBox:$_,convertTo:__};function F_(n){const t=b("div",["mention-button-wrap"],null),e=Bo("mention-button",T.t("list.mention.tooltip"),iB,[],n.clientId);return t.appendChild(e),t}class H_{constructor(t){h(this,"mentionButton");h(this,"handleHoveringBlock",t=>{var e;!this.editor.isWritable()||(t&&this.shouldBlockShowMention(t)?Rt(t).appendChild(this.mentionButton):(e=this.mentionButton)==null||e.remove())});h(this,"handleMouseDown",(t,e)=>{e.preventDefault(),e.stopPropagation();const o=U(this.mentionButton);if(!o||!_(t,o))return;const r=t.selection.range.focus;if(!r.isSimple())return;let i;t.selection.focusedBlock!==o?i=G(t,o):i=r.offset,setTimeout(()=>{const s=t.insertTextToBlock(o,i,"@");i+=1;const l=vt(ve(s,i).left);this.editor.selection.selectBlock(o,i),this.editor.focus(),t.getCustom("mention").suggest.popup(o,i,l,"@")})});h(this,"destroy",()=>{$t.get(this.editor).removeListener("change",this.handleHoveringBlock)});this.editor=t,this.mentionButton=F_(t),$t.get(this.editor).addListener("change",this.handleHoveringBlock),t.domEvents.addEventListener(this.mentionButton,"mousedown",this.handleMouseDown)}shouldBlockShowMention(t){if(!_(this.editor,t)||!ut(t))return!1;const e=ze(t);return!(e==="ordered"||e==="unordered")}}const QV="",j_={templates:{title:"\u9009\u62E9\u6A21\u677F\uFF0C\u5FEB\u901F\u521B\u5EFA",create:"\u65B0\u5EFA\u6A21\u677F",choose:"\u5168\u90E8\u6A21\u677F",customizedMark:"\u81EA\u5B9A\u4E49"}},z_={templates:{title:"Choose a template",create:"New template",choose:"All templates",customizedMark:"Custom"}};T.mergeLang({"zh-CN":j_,"en-US":z_});const YV="",U_="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cmVjdCB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTQ4IDU5QzQ4IDU0LjU4MTcgNTEuNTgxNyA1MSA1NiA1MUg5M0M5OC41MjI4IDUxIDEwMyA1NS40NzcyIDEwMyA2MVY4OEMxMDMgOTEuODY2IDk5Ljg2NiA5NSA5NiA5NUg1NkM1MS41ODE3IDk1IDQ4IDkxLjQxODMgNDggODdWNTlaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGQ9Ik0xOCA2NEMxOCA2Mi4zNDMxIDE5LjM0MzEgNjEgMjEgNjFINTZDNjAuNDE4MyA2MSA2NCA2NC41ODE3IDY0IDY5VjgzQzY0IDg1LjIwOTEgNjIuMjA5MSA4NyA2MCA4N0gyNkMyMS41ODE3IDg3IDE4IDgzLjQxODMgMTggNzlWNjRaIiBmaWxsPSIjRUFFNEY2Ii8+CjxyZWN0IHg9IjI0IiB5PSIzMSIgd2lkdGg9IjY1IiBoZWlnaHQ9IjUwIiByeD0iNSIgZmlsbD0iIzk5QzdGMiIvPgo8cmVjdCB4PSIzMy41IiB5PSI0MyIgd2lkdGg9IjQ2IiBoZWlnaHQ9IjUiIHJ4PSIyLjUiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjMzLjUiIHk9IjU0IiB3aWR0aD0iNDYiIGhlaWdodD0iNSIgcng9IjIuNSIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iMjQiIHk9IjMxIiB3aWR0aD0iNjUiIGhlaWdodD0iNTAiIHJ4PSI1IiBzdHJva2U9IiNGOEY4RjgiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01MCA4NS4yNjhDNTMuODI2MyA4My4wNTg5IDU1LjEzNzMgNzguMTY2MiA1Mi45MjgyIDc0LjMzOThMNjMuMzIwNSA2OC4zMzk4QzY4Ljg0MzMgNzcuOTA1NyA2NS41NjU4IDkwLjEzNzUgNTYgOTUuNjYwNEM0Ni40MzQxIDEwMS4xODMgMzQuMjAyMyA5Ny45MDU3IDI4LjY3OTQgODguMzM5OEwzOS4wNzE3IDgyLjMzOThDNDEuMjgwOSA4Ni4xNjYyIDQ2LjE3MzYgODcuNDc3MiA1MCA4NS4yNjhaIiBmaWxsPSIjQUI5M0RDIi8+CjxyZWN0IHg9IjU5IiB5PSI2NSIgd2lkdGg9IjQyIiBoZWlnaHQ9IjI4IiByeD0iNSIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTYzIDg4VjczLjA4MDhDNjMgNzEuNzA5NiA2My4zNjE0IDcwLjY4NjcgNjQuMDg0MSA3MC4wMTJDNjQuODI4NyA2OS4zMzczIDY1Ljg1OCA2OSA2Ny4xNzIgNjlIOTIuODYwOUM5NS42MjAzIDY5IDk3IDcwLjM2MDMgOTcgNzMuMDgwOFY4OEg5My41MTc5TDg3LjM3NDkgODAuNjIyQzg3LjA5MDIgODAuMzE3MyA4Ni43NjE3IDgwLjA4ODggODYuMzg5NCA3OS45MzY0Qzg2LjAxNzEgNzkuNzg0MSA4NS42NDQ4IDc5LjcwNzkgODUuMjcyNSA3OS43MDc5Qzg0LjkwMDIgNzkuNzA3OSA4NC41Mjc5IDc5Ljc4NDEgODQuMTU1NiA3OS45MzY0QzgzLjgwNTIgODAuMDg4OCA4My40NTQ4IDgwLjMxNzMgODMuMTA0MyA4MC42MjJMNzYuNzMxNCA4Ni4yMzcxTDc0LjIwMTkgODMuOTUxOUM3My42MzI1IDgzLjQyOTYgNzMuMDA4NCA4My4xNjg0IDcyLjMyOTUgODMuMTY4NEM3MS42NTA2IDgzLjE2ODQgNzEuMDM3NCA4My40Mjk2IDcwLjQ4OTkgODMuOTUxOUw2Ni40NDkzIDg4SDYzWk03NC40NjQ3IDgwLjYyMkM3NS4zNjI2IDgwLjYyMiA3Ni4xNDAxIDgwLjI5NTUgNzYuNzk3MSA3OS42NDI2Qzc3LjQ3NiA3OC45ODk3IDc3LjgxNTUgNzguMjE3MSA3Ny44MTU1IDc3LjMyNDdDNzcuODE1NSA3Ni40MTA3IDc3LjQ3NiA3NS42MzggNzYuNzk3MSA3NS4wMDY5Qzc2LjE0MDEgNzQuMzU0IDc1LjM2MjYgNzQuMDE2NiA3NC40NjQ3IDczLjk5NDhDNzMuNTQ0OSA3My45NTEzIDcyLjc1NjUgNzQuMjY2OSA3Mi4wOTk1IDc0Ljk0MTZDNzEuNDQyNSA3NS42MTYzIDcxLjExNCA3Ni40MTA3IDcxLjExNCA3Ny4zMjQ3QzcxLjExNCA3OC4yMTcxIDcxLjQ0MjUgNzguOTg5NyA3Mi4wOTk1IDc5LjY0MjZDNzIuNzU2NSA4MC4yOTU1IDczLjU0NDkgODAuNjIyIDc0LjQ2NDcgODAuNjIyWiIgZmlsbD0iI0Y3RDA3RiIvPgo8Y2lyY2xlIGN4PSI5NSIgY3k9IjQyIiByPSIyIiBzdHJva2U9IiM1MEMzOTgiIHN0cm9rZS13aWR0aD0iMiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTk0Ljc1MDEgMjQuNDY4N0wxMDAuNzgxIDI3LjkxNDlMOTQuNzE5IDMxLjQxNDlMOTQuNzUwMSAyNC40Njg3WiIgc3Ryb2tlPSIjNUNBNUVBIiBzdHJva2Utd2lkdGg9IjEuOCIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwNSAzOEMxMDUgMzguNTUyMyAxMDUuNDQ4IDM5IDEwNiAzOUMxMDYuNTUyIDM5IDEwNyAzOC41NTIzIDEwNyAzOFYzNkgxMDlDMTA5LjU1MiAzNiAxMTAgMzUuNTUyMyAxMTAgMzVDMTEwIDM0LjQ0NzcgMTA5LjU1MiAzNCAxMDkgMzRIMTA3VjMyQzEwNyAzMS40NDc3IDEwNi41NTIgMzEgMTA2IDMxQzEwNS40NDggMzEgMTA1IDMxLjQ0NzcgMTA1IDMyVjM0SDEwM0MxMDIuNDQ4IDM0IDEwMiAzNC40NDc3IDEwMiAzNUMxMDIgMzUuNTUyMyAxMDIuNDQ4IDM2IDEwMyAzNkgxMDVWMzhaIiBmaWxsPSIjQUI5M0RDIi8+Cjwvc3ZnPgo=",V_="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgdmlld0JveD0iMCAwIDM3MiAyNzkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8xMjU2XzM3MTY4KSI+CjxyZWN0IHdpZHRoPSIzNzIiIGhlaWdodD0iMjc5IiBmaWxsPSJ3aGl0ZSIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSIzOS41NzQ3IiB3aWR0aD0iMTE4LjcyMyIgaGVpZ2h0PSIxNS44Mjk4IiByeD0iNy45MTQ4OSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSI3MS4yMzM5IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSI5MS4wMjE1IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSIxMTAuODA5IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSI0MC41NjM4IiB5PSIxMzUuNTQzIiB3aWR0aD0iMjkwLjg3MiIgaGVpZ2h0PSIxMDAuOTE1IiByeD0iMi45NjgwOSIgc3Ryb2tlPSIjRUFGM0ZDIiBzdHJva2Utd2lkdGg9IjEuOTc4NzIiLz4KPHBhdGggZD0iTTM5LjU3NDUgMTM4LjUxMUMzOS41NzQ1IDEzNi4zMjUgNDEuMzQ2MyAxMzQuNTUzIDQzLjUzMTkgMTM0LjU1M0gzMjguNDY4QzMzMC42NTQgMTM0LjU1MyAzMzIuNDI2IDEzNi4zMjUgMzMyLjQyNiAxMzguNTExVjE1Mi4zNjJIMzkuNTc0NVYxMzguNTExWiIgZmlsbD0iI0Q2RTlGQSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTg3LjA2MzcgMTY5LjE4MUM4Ny4wNjM3IDE2Ny41NDIgODguMzkyNiAxNjYuMjEzIDkwLjAzMTggMTY2LjIxM0gzMTcuNTg1QzMxOS4yMjQgMTY2LjIxMyAzMjAuNTUzIDE2Ny41NDIgMzIwLjU1MyAxNjkuMTgxQzMyMC41NTMgMTcwLjgyIDMxOS4yMjQgMTcyLjE0OSAzMTcuNTg1IDE3Mi4xNDlIOTAuMDMxOEM4OC4zOTI2IDE3Mi4xNDkgODcuMDYzNyAxNzAuODIgODcuMDYzNyAxNjkuMTgxWk0xMDQuODcyIDE5Mi45MjZDMTA0Ljg3MiAxOTEuMjg2IDEwNi4yMDEgMTg5Ljk1NyAxMDcuODQgMTg5Ljk1N0gzMTcuNTg1QzMxOS4yMjQgMTg5Ljk1NyAzMjAuNTUzIDE5MS4yODYgMzIwLjU1MyAxOTIuOTI2QzMyMC41NTMgMTk0LjU2NSAzMTkuMjI0IDE5NS44OTQgMzE3LjU4NSAxOTUuODk0SDEwNy44NEMxMDYuMjAxIDE5NS44OTQgMTA0Ljg3MiAxOTQuNTY1IDEwNC44NzIgMTkyLjkyNlpNMTA3Ljg0IDIxMy43MDJDMTA2LjIwMSAyMTMuNzAyIDEwNC44NzIgMjE1LjAzMSAxMDQuODcyIDIxNi42N0MxMDQuODcyIDIxOC4zMDkgMTA2LjIwMSAyMTkuNjM4IDEwNy44NCAyMTkuNjM4SDMxNy41ODVDMzE5LjIyNCAyMTkuNjM4IDMyMC41NTMgMjE4LjMwOSAzMjAuNTUzIDIxNi42N0MzMjAuNTUzIDIxNS4wMzEgMzE5LjIyNCAyMTMuNzAyIDMxNy41ODUgMjEzLjcwMkgxMDcuODRaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNTEuNDQ2OCAxNjkuMTgxQzUxLjQ0NjggMTY3LjU0MiA1Mi43NzU2IDE2Ni4yMTMgNTQuNDE0OSAxNjYuMjEzSDYwLjM1MUM2MS45OTAzIDE2Ni4yMTMgNjMuMzE5MSAxNjcuNTQyIDYzLjMxOTEgMTY5LjE4MUM2My4zMTkxIDE3MC44MiA2MS45OTAzIDE3Mi4xNDkgNjAuMzUxIDE3Mi4xNDlINTQuNDE0OUM1Mi43NzU2IDE3Mi4xNDkgNTEuNDQ2OCAxNzAuODIgNTEuNDQ2OCAxNjkuMTgxWk01MS40NDY4IDE5Mi45MjZDNTEuNDQ2OCAxOTEuMjg2IDUyLjc3NTcgMTg5Ljk1NyA1NC40MTQ5IDE4OS45NTdINjAuMzUxMUM2MS45OTAzIDE4OS45NTcgNjMuMzE5MSAxOTEuMjg2IDYzLjMxOTEgMTkyLjkyNkM2My4zMTkxIDE5NC41NjUgNjEuOTkwMyAxOTUuODk0IDYwLjM1MTEgMTk1Ljg5NEg1NC40MTQ5QzUyLjc3NTcgMTk1Ljg5NCA1MS40NDY4IDE5NC41NjUgNTEuNDQ2OCAxOTIuOTI2Wk01NC40MTQ5IDIxMy43MDJDNTIuNzc1NyAyMTMuNzAyIDUxLjQ0NjggMjE1LjAzMSA1MS40NDY4IDIxNi42N0M1MS40NDY4IDIxOC4zMDkgNTIuNzc1NyAyMTkuNjM4IDU0LjQxNDkgMjE5LjYzOEg2MC4zNTExQzYxLjk5MDMgMjE5LjYzOCA2My4zMTkxIDIxOC4zMDkgNjMuMzE5MSAyMTYuNjdDNjMuMzE5MSAyMTUuMDMxIDYxLjk5MDMgMjEzLjcwMiA2MC4zNTExIDIxMy43MDJINTQuNDE0OVoiIGZpbGw9IiM5OUM3RjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik02OS4yNTU0IDE2OS4xODFDNjkuMjU1NCAxNjcuNTQyIDcwLjU4NDMgMTY2LjIxMyA3Mi4yMjM1IDE2Ni4yMTNINzguMTU5N0M3OS43OTg5IDE2Ni4yMTMgODEuMTI3OCAxNjcuNTQyIDgxLjEyNzggMTY5LjE4MUM4MS4xMjc4IDE3MC44MiA3OS43OTg5IDE3Mi4xNDkgNzguMTU5NyAxNzIuMTQ5SDcyLjIyMzVDNzAuNTg0MyAxNzIuMTQ5IDY5LjI1NTQgMTcwLjgyIDY5LjI1NTQgMTY5LjE4MVpNNjkuMjU1NCAxOTIuOTI2QzY5LjI1NTQgMTkxLjI4NiA3MC41ODQyIDE4OS45NTcgNzIuMjIzNSAxODkuOTU3SDc4LjE1OTZDNzkuNzk4OSAxODkuOTU3IDgxLjEyNzcgMTkxLjI4NiA4MS4xMjc3IDE5Mi45MjZDODEuMTI3NyAxOTQuNTY1IDc5Ljc5ODkgMTk1Ljg5NCA3OC4xNTk2IDE5NS44OTRINzIuMjIzNUM3MC41ODQyIDE5NS44OTQgNjkuMjU1NCAxOTQuNTY1IDY5LjI1NTQgMTkyLjkyNlpNNzIuMjIzNSAyMTMuNzAyQzcwLjU4NDIgMjEzLjcwMiA2OS4yNTU0IDIxNS4wMzEgNjkuMjU1NCAyMTYuNjdDNjkuMjU1NCAyMTguMzA5IDcwLjU4NDIgMjE5LjYzOCA3Mi4yMjM1IDIxOS42MzhINzguMTU5NkM3OS43OTg5IDIxOS42MzggODEuMTI3NyAyMTguMzA5IDgxLjEyNzcgMjE2LjY3QzgxLjEyNzcgMjE1LjAzMSA3OS43OTg5IDIxMy43MDIgNzguMTU5NiAyMTMuNzAySDcyLjIyMzVaIiBmaWxsPSIjRjdEMDdGIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuMDMxOCAxODkuOTU4Qzg4LjM5MjYgMTg5Ljk1OCA4Ny4wNjM3IDE5MS4yODYgODcuMDYzNyAxOTIuOTI2Qzg3LjA2MzcgMTk0LjU2NSA4OC4zOTI2IDE5NS44OTQgOTAuMDMxOCAxOTUuODk0SDk1Ljk2OEM5Ny42MDcyIDE5NS44OTQgOTguOTM2MSAxOTQuNTY1IDk4LjkzNjEgMTkyLjkyNkM5OC45MzYxIDE5MS4yODYgOTcuNjA3MiAxODkuOTU4IDk1Ljk2OCAxODkuOTU4SDkwLjAzMThaTTkwLjAzMTkgMjEzLjcwMkM4OC4zOTI3IDIxMy43MDIgODcuMDYzOCAyMTUuMDMxIDg3LjA2MzggMjE2LjY3Qzg3LjA2MzggMjE4LjMwOSA4OC4zOTI3IDIxOS42MzggOTAuMDMxOSAyMTkuNjM4SDk1Ljk2ODFDOTcuNjA3MyAyMTkuNjM4IDk4LjkzNjIgMjE4LjMwOSA5OC45MzYyIDIxNi42N0M5OC45MzYyIDIxNS4wMzEgOTcuNjA3MyAyMTMuNzAyIDk1Ljk2ODEgMjEzLjcwMkg5MC4wMzE5WiIgZmlsbD0iIzkxRDlCRSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEyNTZfMzcxNjgiPgo8cmVjdCB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",e9=w("templates");function jf(n){const t=n.rootElement.querySelector(":scope .editor-templates");if(!t)return null;const e=t.querySelector(":scope .editor-templates-cards");return u(e9,e,"no card container"),{root:t,cardContainer:e}}function q_(n){const t=jf(n);if(t)return t.cardContainer.innerHTML="",t;const e=b("div",["editor-templates"],n.rootElement);b("div",["editor-templates-title"],e,T.t("templates.title"));const o=b("div",["editor-templates-cards"],e);return{root:e,cardContainer:o}}function n9(n,t,e,o,r){var f;const i=(f=n.options.componentsOptions)==null?void 0:f.templates,s=b("div",["editor-template-card",...o],null),l=b("div",["editor-template-thumb-container"],s),c=b("img",["editor-template-thumb"],l);c.src=t,c.style.display="none",c.onerror=()=>{var p;const m=(p=i==null?void 0:i.placeHolderImageSrc)!=null?p:V_;c.src!==m&&(c.src=m)},c.onload=()=>{c.style.display=""};const a=b("div",["editor-template-name"],s),d=b("span",[],a,e);return i!=null&&i.showTemplateTitleAttr&&d.setAttribute("title",e),s.onclick=()=>r(s),s}function W_(n,t){return t.thumbnailUrl?t.thumbnailUrl:n.doc.buildResourceUrl("thumbnail.png")}function G_(n,t){const e=W_(n,t);return n9(n,e,t.name,[],async()=>{var r,i;const o=(r=n.options.componentsOptions)==null?void 0:r.templates;(i=o==null?void 0:o.onApplyTemplate)==null||i.call(o,n,t)})}function Z_(n,t){return n9(n,t,T.t("templates.choose"),["more"],()=>{var o,r;const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onChooseTemplate)==null||r.call(e,n)})}function Q_(n,t){var f,m;const e=(f=n.options.componentsOptions)==null?void 0:f.templates;if(!e)return;const r=Jt(n.rootContainer).getBoundingClientRect().width;let i=1;const s=U_,l=jf(n);if(l){if(t!=null&&t.reset){const p=Array.from(l.cardContainer.children),A=l.cardContainer.firstElementChild;if(u(e9,A,"no first card"),rt(A,"new")||rt(A,"more"))return;const k=window.getComputedStyle(A),v=parseFloat(k.marginLeft),x=parseFloat(k.marginRight),E=A.getBoundingClientRect().width+v+x;i=Math.floor(r/E);const R=Math.max(1,i-1-1),$=p.length-1;p.forEach((q,ot)=>{ot>R&&ot<$?q.style.display="none":(ot>=$&&rt(q,"more"),q.style.display="")})}return}const c=e.templates,{cardContainer:a}=q_(n);c.forEach((p,A)=>{const k=G_(n,p);if(A>0&&A>=i&&(k.style.display="none"),a.appendChild(k),A===0){const v=window.getComputedStyle(k),x=parseFloat(v.marginLeft),E=parseFloat(v.marginRight),L=k.getBoundingClientRect().width+x+E;i=Math.floor(r/L)-1}});const d=Z_(n,s);a.appendChild(d),(m=e==null?void 0:e.onTemplateChooserStatusChanged)==null||m.call(e,n,a,"visible")}const o9=ee.default(Q_,50);function Y_(n){var o,r;const t=jf(n);if(!t)return;t.root.remove();const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onTemplateChooserStatusChanged)==null||r.call(e,n,null,"hide")}function J_(n){const t=n.blocks.root;if(t.length===0)return!0;if(t.length>5)return!1;const e=[...t];e[0].type==="text"&&e[0].heading&&e.splice(0,1);const o=r=>{var i;return r.type!=="text"&&r.type!=="list"?!1:r.text?((i=r.text)==null?void 0:i.length)===0:!0};return e.every(r=>o(r))}function zf(n,t){J_(n.doc.toJSON())?o9(n,t):(o9.cancel(),Y_(n))}const K_=800;class X_{constructor(t){h(this,"longPressTimeout",0);h(this,"handleSelectionChange",()=>{});h(this,"handleLongPress",t=>{const e=t.touches[0],o=Vl(this.editor,e.clientX,e.clientY);!o||console.log(o)});h(this,"handleTouchStart",t=>{t.touches.length===1&&(this.longPressTimeout=window.setTimeout(()=>{this.handleLongPress(t)},K_))});h(this,"handleTouchEnd",t=>{this.longPressTimeout&&(window.clearTimeout(this.longPressTimeout),this.longPressTimeout=0)});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChange),document.addEventListener("touchstart",this.handleTouchStart),document.addEventListener("touchend",this.handleTouchEnd)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChange),document.removeEventListener("touchstart",this.handleTouchStart),document.removeEventListener("touchend",this.handleTouchEnd)}}class hl{constructor(t,e){h(this,"_decrypted",!1);this.editor=t,this.blockData=e}get decrypted(){return this._decrypted||this.blockData.owner===this.editor.doc.getUser().userId}setDecrypted(){this._decrypted=!0}destroy(){}static getState(t,e){return t.addCustom(`encrypted-block-${e.id}`,()=>new hl(t,e))}}const JV="",Po=w("encrypted-block");function tF(n,t,e,o,r){const i=r,s=lo(o,"div"),l=hl.getState(n,i);if(l.decrypted)n.createChildContainer(t,s,i.children[0]),M(o,"decrypted");else{M(o,"encrypted");const c=Rt(o),a=b("div",["password-container"],c),d=b("input",[],a);d.type="text",d.onkeydown=f=>{if(f.key==="Enter"){const m=d.value;if(i.password===Er.default(`${i.owner}-${m}`)){l.setDecrypted(),n.reloadBlock(o);const p=qu(n,n.getBlockById(i.id));p&&(n.selection.selectBlock(p,0),n.focus())}}}}return s}function eF(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!vn(r))return null;const i=r;if(n.getBlockData(t).children[0]!==V(i))return null;const l=Bt(t,V(i));return new tn(n,{anchor:l,focus:l})}function nF(n,t,e,o){if(hl.getState(n,n.getBlockData(t)).decrypted)return null;if(o==="ArrowDown"||o==="ArrowRight"){const s=dt(t);return s?F(s,G(n,s),"end"):F(t,1,"end")}const i=bt(t);return F(i||t,0,"home")}function oF(n,t){return n.getBoundingClientRect()}function rF(n,t,e,o){if(e.isSimple()){u(Po,o.isSimple(),"from is simple position but to is not simple position"),Po.debug("full select table"),M(t,"full-selected");return}u(Po,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;u(Po,r.blockId===i.blockId,"only allow update one table selection"),u(Po,r.childContainerId===i.childContainerId,"only one container");const s=n.getBlockData(t),l=n.getContainerById(s.children[0]);M(l,"selected")}function iF(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="encrypted"]').forEach(t=>{H(t,"full-selected"),t.querySelectorAll("selected").forEach(e=>{H(e,"selected")})})}function sF(n,t){const e=n.getBlockData(t);return hl.getState(n,e).decrypted?[n.getContainerById(e.children[0])]:[]}function lF(n,t,e,o,r){return null}function cF(n,t,e,o){u(Po,e.blockId===o.blockId,"only allow select in single block"),u(Po,j(t)===e.blockId,"only allow select in single block");const r=n.getBlockData(t);return u(Po,e.childContainerId===r.children[0],"only one container"),[n.getContainerById(r.children[0])]}function aF(n){return{name:"EncryptedBlock",insertBlockCommandItems:[{id:"insert-encrypted-block",name:"Encrypted Block"}],async handleInsertEmptyBlock(t,e){const o=Bn(t.doc),r={id:P(),type:"encrypted",children:[o],owner:t.doc.getUser().userId,ownerDisplayName:t.doc.getUser().displayName,password:Er.default(`${t.doc.getUser().userId}-1234`)},i=t.doc.getContainerBlocks(o)[0];return t.insertBlock(e.containerId,e.blockIndex,r,Ot(t,i.id,0))}}}function uF(n,t,e,o){return o==="text"||o==="markdown"?"[Encrypted Block]":"<p>[Encrypted Block]</p>"}const dF={blockType:"encrypted",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:tF,getBlockTextLength:()=>1,getRangeFromPoint:eF,moveCaret:nF,getCaretRect:oF,updateSelection:rF,clearSelection:iF,getChildContainers:sF,getNextContainer:lF,getSelectedContainers:cF,getOptions:aF,convertTo:uF};function hF(n,t,e){const o=hs(n,t,{components:{blocks:[Ws,Qs,dF],decorators:[new Js],embeds:[va,$1,cf,af,uf,k1,df,Mf,Lf],boxes:[ta],options:{...e.componentsOptions}}});return o.readonly=!0,o}class fF{constructor(t){this.createOptions=t}createHistoryEditor(t,e){return hF(t,e,this.createOptions)}}w("create-editor");function r9({root:n,childDoc:t,doc:e}){t.uploadResource=e.uploadResource.bind(e),t.buildResourceUrl=e.buildResourceUrl.bind(e);const o=hs(n,t,{shortcuts:[Ac],components:{blocks:[Ws,Qs],decorators:[new Js],embeds:[G4,va,$1,cf,af,uf,k1,df,Mf,Lf],boxes:[ta,Hf],options:{image:{defaultAlign:"left"}}}});return o.input.addHandler(new ca),o.input.addHandler(new hf(o)),o.input.addHandler(new SP(o)),o.input.addHandler(new Y1),o}function mF(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),o=new Set;e.forEach(r=>{const i=U(r);i&&o.add(i)}),o.forEach(r=>{DP(n,r,t)})}class gF{constructor(t){h(this,"listeners",new Set);h(this,"doc");this.editor=t,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const o=e.groupId;this.getComments().filter(i=>i.groupId===o).length===0&&mF(this.editor,o)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return r9({root:t,childDoc:e,doc:this.doc})}}class pF{constructor(t,e){h(this,"listeners",new Set);this.editor=t,this.localDoc=e}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(t){return this.doc.comments[t]}getCommentDoc(t){const e=this.doc.comments[t];return fh(e)}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}localCreateComment(t,e){}localDeleteComment(t){}localUpdateComment(t,e){}createCommentEditor(t,e){return r9({root:t,childDoc:e,doc:this.localDoc})}}const CF={placeholder:{common:{title:"\u8BF7\u8F93\u5165\u6807\u9898",readonlyTitle:"\u8BF7\u8F93\u5165\u6807\u9898",content:"\u70B9\u51FB + \uFF0C\u6216\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6",contentInTable:"\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6"},local:{readonlyTitle:"\u672A\u547D\u540D"}}},AF={placeholder:{common:{title:"Enter a title",readonlyTitle:"Enter a title",content:'Click "+", or enter "/" to insert components quickly',contentInTable:'Enter "/" to insert components quickly'},local:{readonlyTitle:"Untitled"}}};T.mergeLang({"zh-CN":CF,"en-US":AF});function bF(n){let t;return n.forEach((e,o)=>{o.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function vF(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),o=bF(t.headers).toLocaleLowerCase();let r="";if(o){const s=au.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([e],`${Date.now()}.${r}`,{type:o})}catch{return null}}function yF(n){const o=new DOMParser().parseFromString(n,"text/html").querySelector("svg");if(!o)return null;const r=o.getAttribute("viewBox");if(!r)return null;const i=r.split(" ");if(i.length===4){const s=i[2],l=i[3];return o.setAttribute("width",s),o.setAttribute("height",l),o.outerHTML}return null}function i9(n,t,e=!0){const o=new Image,r=document.createElement("canvas"),i=r.getContext("2d");if(!i){t(new Error("failed to get context"),null);return}o.onload=()=>{if(r.width=o.naturalWidth,r.height=o.naturalHeight,e&&(r.width===0||r.height===0)){const s=n.substring(26);if(s){const l=atob(s),c=yF(l);if(c){Bu(c,"image/svg+xml").then(a=>{i9(a,t,!1)});return}}t(null,null);return}i.drawImage(o,0,0),r.toBlob(s=>{t(null,s)},"image/png")},o.src=n}async function kF(n){const t=await Tr(n);return new Promise((e,o)=>{i9(t,(r,i)=>{if(r){o(r);return}if(!i){o(new Error("Failed to get image blob"));return}e(i)})})}const s9="Untitled";function wF(n){const t=Ft(n.rootContainer);return!t||!_(n,t)?s9:n.getBlockString(t)||s9}const BF="UEsDBBQABgAIAAAAIQBk9WPugQEAACkGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0lMtqwzAQRfeF/oPRtsRKuiilxMmij2UbaArdKvI4EdULaZzH33fsJKYUJy5NsjHIM/feowHNcLw2OllCiMrZjA3SPkvASpcrO8/Yx/Sld8+SiMLmQjsLGdtAZOPR9dVwuvEQE1LbmLEFon/gPMoFGBFT58FSpXDBCKRjmHMv5JeYA7/t9++4dBbBYg8rDzYaPkEhSo3J85p+b0kC6MiSx21jlZUx4b1WUiDV+dLmv1J6u4SUlHVPXCgfb6iB8daEqnI4YKd7o9EElUMyEQFfhaEuvnIh57mTpSFletymhdMVhZLQ6Cs3H5yEGGnmRqcIxtMNIDVC2T1/G4csIzrzaTRXpJkE5+PgZJzGtPKDgAqaGR6chS3NDALRn38YjXUnRMSNhnh+gq1vdzwgkuASADvnToQVzN4vRvHDvBOkoNypmGk4P0Zj3QmBtIpg+z39VdQ2xyKps36AtNrCP669312Vuuf/9PKaRLI++X5QrcUc8pZsXi/60TcAAAD//wMAUEsDBBQABgAIAAAAIQAekRq37wAAAE4CAAALAAgCX3JlbHMvLnJlbHMgogQCKKAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJLBasMwDEDvg/2D0b1R2sEYo04vY9DbGNkHCFtJTBPb2GrX/v082NgCXelhR8vS05PQenOcRnXglF3wGpZVDYq9Cdb5XsNb+7x4AJWFvKUxeNZw4gyb5vZm/cojSSnKg4tZFYrPGgaR+IiYzcAT5SpE9uWnC2kiKc/UYySzo55xVdf3mH4zoJkx1dZqSFt7B6o9Rb6GHbrOGX4KZj+xlzMtkI/C3rJdxFTqk7gyjWop9SwabDAvJZyRYqwKGvC80ep6o7+nxYmFLAmhCYkv+3xmXBJa/ueK5hk/Nu8hWbRf4W8bnF1B8wEAAP//AwBQSwMEFAAGAAgAAAAhADPCW79BAQAA5wQAABwACAF3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJQxT8MwEIV3JP5D5B07LVAQatoFkDqwQJFYneSSWI3tyL6Q9t9zojRNRYkYPN6z7r1P57Pny62uo09wXlmTsAmPWQQms7kyZcLe189X9yzyKE0ua2sgYTvwbLm4vJi/Qi2RmnylGh+Ri/EJqxCbByF8VoGWntsGDJ0U1mmJVLpSNDLbyBLENI5nwg092OLEM1rlCXOrnPLXuwb+422LQmXwaLNWg8EzEQKpF8hQuhIwYd/lXpxwMmPiPMN1SAaPu5qG2EPs67H4u5DxhTW4lmk9GEMvjUFMQ0KYVqfgaMeOEL00BjEJCZG1Hq3+oLQegvOjKhSCHl2LWUiaipxcrczmSPNj23UdT6XKW55ZLQ7HLzan5KctgjPyT8TbkIgdpG+ASHc0WN+BODarm6BP6BfFQTkgiJPvafEFAAD//wMAUEsDBBQABgAIAAAAIQBOMo6QFgYAAKYkAAARAAAAd29yZC9kb2N1bWVudC54bWzUWttu40QYvkfiHSJfLRKtz4eYTVeOD7uVQKoo+wCuPUmstT3WeNI0XC0XC1wguOBiuWClLgjBE4AEiIdZ0T28BTM+JM6h7cTZkm0vEnv+mW+++eb7/0yc3r13lsSdU4DyCKY9TtwXuA5IAxhG6bDHPfzM2zO4To79NPRjmIIeNwU5d+/g/ffuTswQBuMEpLhDINLcnGRBjxthnJk8nwcjkPj5fhIFCOZwgPcDmPBwMIgCwE8gCnlJEIXiKkMwAHlO5rP99NTPuQouOGNDC5E/IYMpoMIHIx9hcDbHEDcGUfkub6wCSS2AyAolcRVK3hhK4ymrFSClFRBhtYKktkNaszitHZK0iqS3Q5JXkYx2SCt2SlYNDjOQkuAAosTH5BYN+cRHj8bZHgHOfBydRHGEpwRT0GoYP0oftWBERs0QEjncGEHnExiCWA5rFNjjxig1q/F7s/GUulmOr97qEYhl/eUQpyoOxcp5BGKiBUzzUZTNMjxpi0aCoxrk9KpFnCZx3W+SiYzpcll5ckop54As9Cv9k7hkfjWiKDDsCIWYjWChsDhnzSQhLpxP3EqahrgiYwGpAaQVAC0AjAW/xjAqDD6YZyjFiRhTo8Ypd4XiRHNhRcY6tkymAZCDzSDUmkc+TRoryobb2fY+guNsjhZth3Y4L0ITehzYAKuyfzMl8+3IHI/8jNSmJDAPhylE/klMGBEzd4gfO8UO0FeyrfStuARnHVoIuANyfDmB4ZS+ZySimJmP/EPiHEV2dE+3La5oJcUf01a9+iOtJjkqhZ/2OEEQJE1z5FmTAwb+OMY04nUVRRfryFGjqZjwCBVvx3gaE4bmqR/3uAfAp2cukeNpDJVdYj8d1h1AuvfwmEb5KszPkMqX6tqDKc7JoFGUEi7Az7GVR35z4MTEBy/Pv3rz0w+0CZeBZZwrp6ajxIXBlMwaMT2l6wh9lUHMRcnejpjSDYrJoND2GksMGquOY+iu7exIY/m2ayyzaKwaqi4YNNd3obFy2zVWGDTW+7Il296uaoX6LmisMugkKIpouJqwI5202+5FjUFjTfQ8S7OMHWms33aNdQaNJd3qqoq8q5pq3HaNDRaNNcFzRafLoLGtaF2JdlzReDFSaFw1NTTeRMf1XBVLNcSux+KHnXOVBddQLEm6DVxVSxf6nubdPNfFPLNhCCqWdRxBOHARIj3wNCNf1YbIT46xj3CVi6WxA5jmMAb7MRzeWUqQtQhuGi6Mf/H4xxGIY/hhh3xbjMMXj5998BFDrsiSZnuiYjPoZLiC7fV3rVM+zTFI9uEY72eI1KA4baPWnZZyiYYu2oLFlK6u2C3OzqtyLURaytXME8Zvv//+9fOr8y8unj1lWKjqeroraMpWvliMFAutmoq9WDp9aJohGzrLN7o2M7asLrVj6MMbM8/8gBgqQyAH6BRwB5RlZ8l/1HgFrSO0NH29Wws7e5jGUQoa+zvbLgwuQ26YiBGX2SOvn39z8eWT0ik3tbAzvIzMuiuXbkRndSfW+1rRlb7nKExng00SeDuXXcK1qwiWJi99hmme4uiaRfNkJ1wXt2u78+Dr35+8+vPXJTeMSNVGxDuPOsiMyILRYahR/qMoxxBNSREuTbdox+vy4UGNem06MPB+8/0/L7/9ZdluM+JvV6SX539c/P0dg7eFru3alrhUs1VH6kuqPD/gULUcRVAdd51fFiM35m21L3ueJNOJGlwFQ1FFxZ0beQ3Xcrs3WkDV1FjA4qfrx8RZR4QYOSlko3JX0nFS9ozi07juJ8xih2HdVjy65mcDGlmyljCbK5rbf/H109fPf7u6FjfA2R5Rq47sCZq2JL/ueo5o2VfK//8oXf0g8K4rvcf0c4DrGX25v3TElmzV1foiLe47tfrGZf16xWbiLMlTh/yTCmauWA4CfDST+jopimUNjz8nwQnxhSQp9LmgOSLXqqFUWZoNP/EpIoYZaVfKLigajvD89gRiDJP5fQwGjegI+CEg8+oCfSRmDiDEjdvhGBe31XQBjKle1cmE9imaQxjcR/SnOJOeho4iHBCWslYM4ut1F5flD3P8/B+MDv4DAAD//wMAUEsDBBQABgAIAAAAIQC29GeY0gYAAMkgAAAVAAAAd29yZC90aGVtZS90aGVtZTEueG1s7FlLixtHEL4H8h+Guct6zehhrDXSSPJr1zbetYOPvVJrpq2eadHd2rUwhmCfcgkEnJBDDLnlEEIMMcTkkh9jsEmcH5HqHkkzLfXEj12DCbuCVT++qv66qrq6NHPh4v2YOkeYC8KSjls9V3EdnIzYmCRhx719MCy1XEdIlIwRZQnuuAss3Is7n392AZ2XEY6xA/KJOI86biTl7Hy5LEYwjMQ5NsMJzE0Yj5GELg/LY46OQW9My7VKpVGOEUlcJ0ExqL0xmZARdg6USndnpXxA4V8ihRoYUb6vVGNDQmPH06r6EgsRUO4cIdpxYZ0xOz7A96XrUCQkTHTciv5zyzsXymshKgtkc3JD/beUWwqMpzUtx8PDtaDn+V6ju9avAVRu4wbNQWPQWOvTADQawU5TLqbOZi3wltgcKG1adPeb/XrVwOf017fwXV99DLwGpU1vCz8cBpkNc6C06W/h/V671zf1a1DabGzhm5Vu32saeA2KKEmmW+iK36gHq92uIRNGL1vhbd8bNmtLeIYq56IrlU9kUazF6B7jQwBo5yJJEkcuZniCRoALECWHnDi7JIwg8GYoYQKGK7XKsFKH/+rj6Zb2KDqPUU46HRqJrSHFxxEjTmay414FrW4O8urFi5ePnr989PvLx49fPvp1ufa23GWUhHm5Nz9988/TL52/f/vxzZNv7XiRx7/+5avXf/z5X+qlQeu7Z6+fP3v1/dd//fzEAu9ydJiHH5AYC+c6PnZusRg2aFkAH/L3kziIEMlLdJNQoAQpGQt6ICMDfX2BKLLgeti04x0O6cIGvDS/ZxDej/hcEgvwWhQbwD3GaI9x656uqbXyVpgnoX1xPs/jbiF0ZFs72PDyYD6DuCc2lUGEDZo3KbgchTjB0lFzbIqxRewuIYZd98iIM8Em0rlLnB4iVpMckEMjmjKhyyQGvyxsBMHfhm327jg9Rm3q+/jIRMLZQNSmElPDjJfQXKLYyhjFNI/cRTKykdxf8JFhcCHB0yGmzBmMsRA2mRt8YdC9BmnG7vY9uohNJJdkakPuIsbyyD6bBhGKZ1bOJIny2CtiCiGKnJtMWkkw84SoPvgBJYXuvkOw4e63n+3bkIbsAaJm5tx2JDAzz+OCThC2Ke/y2EixXU6s0dGbh0Zo72JM0TEaY+zcvmLDs5lh84z01QiyymVss81VZMaq6idYQK2kihuLY4kwQnYfh6yAz95iI/EsUBIjXqT5+tQMmQFcdbE1XuloaqRSwtWhtZO4IWJjf4Vab0bICCvVF/Z4XXDDf+9yxkDm3gfI4PeWgcT+zrY5QNRYIAuYAwRVhi3dgojh/kxEHSctNrfKTcxDm7mhvFH0xCR5awW0Ufv4H6/2gQrj1Q9PLdjTqXfswJNUOkXJZLO+KcJtVjUB42Py6Rc1fTRPbmK4RyzQs5rmrKb539c0Ref5rJI5q2TOKhm7yEeoZLLiRT8CWj3o0Vriwqc+E0LpvlxQvCt02SPg7I+HMKg7Wmj9kGkWQXO5nIELOdJthzP5BZHRfoRmsExVrxCKpepQODMmoHDSw1bdaoLO4z02Tker1dVzTRBAMhuHwms1DmWaTEcbzewB3lq97oX6QeuKgJJ9HxK5xUwSdQuJ5mrwLST0zk6FRdvCoqXUF7LQX0uvwOXkIPVI3PdSRhBuENJj5adUfuXdU/d0kTHNbdcs22srrqfjaYNELtxMErkwjODy2Bw+ZV+3M5ca9JQptmk0Wx/D1yqJbOQGmpg95xjOXN0HNSM067gT+MkEzXgG+oTKVIiGSccdyaWhPySzzLiQfSSiFKan0v3HRGLuUBJDrOfdQJOMW7XWVHv8RMm1K5+e5fRX3sl4MsEjWTCSdWEuVWKdPSFYddgcSO9H42PnkM75LQSG8ptVZcAxEXJtzTHhueDOrLiRrpZH0Xjfkh1RRGcRWt4o+WSewnV7TSe3D810c1dmf7mZw1A56cS37tuF1EQuaRZcIOrWtOePj3fJ51hled9glabuzVzXXuW6olvi5BdCjlq2mEFNMbZQy0ZNaqdYEOSWW4dm0R1x2rfBZtSqC2JVV+re1ottdngPIr8P1eqcSqGpwq8WjoLVK8k0E+jRVXa5L505Jx33QcXvekHND0qVlj8oeXWvUmr53Xqp6/v16sCvVvq92kMwioziqp+uPYQf+3SxfG+vx7fe3cerUvvciMVlpuvgshbW7+6rteJ39w4Byzxo1IbtervXKLXr3WHJ6/dapXbQ6JX6jaDZH/YDv9UePnSdIw32uvXAawxapUY1CEpeo6Lot9qlplerdb1mtzXwug+Xtoadr75X5tW8dv4FAAD//wMAUEsDBBQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAd29yZC9zZXR0aW5ncy54bWy0Vttu2zgQfV9g/8HQ8zq6WHZsoU4R3zYp4nZRebHPlETZRHgRSMqu8/U7pETLu3ELp0VeEmrOzJkh53DoDx+/MdrbY6mI4FMvvAm8Hua5KAjfTr2/N6v+2OspjXiBqOB46h2x8j7e/f7bh0OisNbgpnpAwVXC8qm307pKfF/lO8yQuhEV5gCWQjKk4VNufYbkc131c8EqpElGKNFHPwqCkdfSiKlXS560FH1GcimUKLUJSURZkhy3/1yEvCZvE7IQec0w1zajLzGFGgRXO1Ipx8Z+lg3AnSPZ/2gTe0ad3yEMrtjuQcjiFHFNeSagkiLHSkGDGHUFEt4ljl8RnXLfQO52i5YKwsPArs4rH76NIHpFMMrxt7dxjFsOHyLPeUjxNp7RiYd0BxuOfq6YMwKF30YxdHWoI+t2pOg1PW6gJ5JJJJsb1DaY5cnjlguJMgrlQKN70Kuerc78hS2bf3YJOe/gIr8IwXqHpMIyBzXDFAgCzzdABtXBaFiIz0KntZSi5sUDRmD7LrwSQrcwKFCUqUYa8iZbiRjc/amXU4x4Q1/gEtVUb1CWalGB0x7B1m+jNnu+QxLlwJZWKAcdzwXXUlDnV5i0c5gjEmTeRtipYla1wqvlEzqKWp8haTOxgIEjBofznym0FgWMFAiV5PoumgBbTTg8L+H/iQRMWEkKvDFNSfWR4hVsJiUv+J4Xn2qlCTDaWfQLFfyoAMxN5i8go82xwiuMdA3H9k7JbGdWlFRrAqKQj7wAWb1bMlKWWEICAkJbg5yIFAd7zo1S3ysvKOwfcIZbPNiATJ9nQmvBHo7VDs761zpp9e+fyxme50K5xVe4YifXYBEHw8WyqdSgHRJEo9FicAkJV9Eyvr+EjJfBfDW7hMxm0WB+ewmZx6NJNLmILMPJ+GIFCyhiPL+IfHc/q0kc39qe+KcTYYl5dv+SbmWuVY81EXPEMklQb20eZt94ZPJ5RrjDMwzzFJ8jaZ05sN9vAMUQpStosANsc1hSEFUtcGnXdI3ktuNtPeRFK8y8TycuM26x/BMGZ9WgB4mq5ro4lzCO20jC9RNhzq7qLHVRHF6AMwim8Je9tOfUHc8h0SA/O3aekJWx9cW8P/9shIeR0veKoKn3sjOmRvlUpka1eI2qqhF/tg2nHiXbnQ5NmIavAn7S2Y9sG7VYZLGowewHys1mwbtddLbI2c78Bs426Gyxs8Wdbehsw842craRse1g3ElK+DPcQ7c09lJQKg64eOjwVyb3SuUERJAeWdY9PjcNRomCwVDBO6WFdNgfFgvjpBD5o3ls48Y+nIwXy8mg0XY4tO+btrMDjvYrLmdI4aJRt/tpffcvAAAA//8DAFBLAwQUAAYACAAAACEAQMH/8TkBAAAjAwAAFAAAAHdvcmQvd2ViU2V0dGluZ3MueG1snNJfT8IwEADwdxO/w9J36CCykIVBYgzGF2OifoDS3aCx7S294sBP720CYnhhvvT//XLXdrbYOZt8QiCDvhCjYSoS8BpL49eFeH9bDqYioah8qSx6KMQeSCzmtzezJm9g9Qox8klKWPGUO12ITYx1LiXpDThFQ6zB82aFwanI07CWToWPbT3Q6GoVzcpYE/dynKaZODDhGgWrymh4QL114GMXLwNYFtHTxtR01JprtAZDWQfUQMT1OPvjOWX8iRndXUDO6ICEVRxyMYeMOorDR2k3cvYXmPQDxhdApmHXz5geDMmR544p+znZyTHlmfO/ZM4Agn7E5JgH7V1bkdP509pjUCvLEr9RwtecdHDbcrZt1w35+Jx/LdbROPMFSwz3ARuCINtlZS02L8+PPJF/vvb8GwAA//8DAFBLAwQUAAYACAAAACEAOdtFTLkFAAAnWgAAEgAAAHdvcmQvbnVtYmVyaW5nLnhtbOyczW7qRhiG95V6D8j7xP8/oEOOwECV6rQ60knV9WAGsGKPrbGB0FV7Ke266q430EvpDfQWOuOxzZ9DbIMw5MwmDuP5Xs/3zjfDk0nCh48vvtdaQhy5AeoK8r0ktCBygomLZl3hp6fRnSW0ohigCfACBLvCGkbCx4dvv/mw6qCFP4aYdGwRDRR1VqHTFeZxHHZEMXLm0AfRve86OIiCaXzvBL4YTKeuA8VVgCeiIslS8l2IAwdGEdGxAVqCSEjlnJdyahMMViSYCmqiMwc4hi8bDbmyiC62RetQSKkhRDJU5EMptbKUIdJRHQhptYTIqA6U9HpKBckZ9ZSUQyWznpJ6qGTVUzooJ/+wwIMQInJzGmAfxOQlnok+wM+L8I4IhyB2x67nxmuiKRmZDHDRc40RkahcwVcnlRVM0Q8m0FMnmUrQFRYYddL4uzyeDr3D4tNLFoHL5M9CBoGz8CGKk8xFDD3iRYCiuRvmK9yvq0ZuzjOR5bEklr6X9VuFcsnl8tr2NGBWbgTLDD/13/fYyI8rylKJGaESeUSZIew+MxuJT6pw8+Ba1myZK5fcQDIB5UDAcGDJDT/TsFIN0dmsUKrjllwamQ6bFarjboyVS+5j+4PZEohgNQk9G0e09rcyCmenle13OFiEGzX3NLXHzSa0ojxQQSst/+0lGZ02mC9zEJK9yXc6jzMUYDD2yIhIMbdIPbaSGaBfybTSS/ItfGnRjUB4IPwCxlGMgRP/uPBbO68eSQERDiIiHQwJ/GDayFCnN40h7mMInmkXqoIiKt9ZAo+0jJS+ItuKINI7/sKL3U9wCb2ndQizPkmrR1tZr9gPveyeatvSUJE0dsdb0hsuuWTPSsaSdZZZL0JhIz9vHC88D8Z5/BN8yW/9++sfefv3TtbqwWnaPfyM6cVFNB3a3BU0hdrQmQM0S3iQviZ9xbwzTi+jAMURNTFyXFJgP5PelCCjJLpHLNpvcxGRn8ApIG6wx4+Tr25uJWuNfskalCRfMX2mmKSx75J8ukv//F7VJEu7nEkbO2T9bTuU0+3477e/q/ohK8alDDmevnqO9P+snL5hXUf6bJM7Mf2/qqavyNJ1pK83UvyKfrEt83j6RiPFr7QvthkeT99spPhV9Uq2PquR4lfNxrY+cQfg6DOO0p1ch+4Uua1LumWw/KvTXbsvGX1LS+O3p+sMdJc+r/xkXRPblYEZznY7dnC2Oz19znbV0udsx9mOsx1nuwunX5HtlDpsp2rKSB5ItdlOaxu2aitWbms+Xfzk7kIndzXW9OXwjsMchzkOc4Xpc5hroPg5zHGYuwWYU2vBXNvWTcsasvyLYW6+HmN38sMRpDN7pqbpmpabm09a4l0cek5XsI2BNVRNu8Y0hl/itZeP55MbxZ8BBjMMwnnhPH8FJ3y5rZakS0N5dAZ2fl9nfrlBw/5Is4b9s7x5XDM4VrWI7hepRZImtSVJYlUFUQxidwnP9JPGLcPmvkHMsjMbdMs4um8QazmzQbcMrPsGXccSuyKk3TfoOpbYFUHvvkHXscRuB4vpLl4HiwdqXxqw/KufcQ7aQ0Oib/2ZrfmEvv8zTn6ayU8z+WkmP818M31+mtlA8fPTTH6aeQvYRjG3Mrbplq0aZttm+VfHNsM2FG3YTk9Dt6frDNhWY7FybOPYtsmeYxvHNo5tHNsaTZ9jWwPFfzvYRk+8K2ObOVBHqmFpLP/q2NYb9CRTVtL47el679jGIe317DmkNVD6HNI4pHFI45DWaPoc0o5DGv2te3VIG/ZNc9QbsPyrQxrZGwzLlL/Kf/vgZ2sc2zi2cWx7M32ObQ0UP8c2jm1Xgm0owTWUffIKbdphtywjNZVDBWHsDbQwLPmf3VfC2BtPYVj2x+RFYQefD7gJM4+EsY2uMEw7EsY2iMKw5JMEXwljC6swLJvrojBWkIVhGcYlYezKIPrhfwAAAP//AwBQSwMEFAAGAAgAAAAhAPiVyO/8DgAA85kAAA8AAAB3b3JkL3N0eWxlcy54bWzsXd9zo0YSfr+q+x8oPSUPG/+QLTtbcVJr2T67btdxVt5L3eMIRhZnYHSA1uv89TczDAjUDKKHjuu8m6RqLQH9MczXX890A5qffvkSR95nnmahSM5GBz/sjzye+CIIk4ez0af7qzenIy/LWRKwSCT8bPTMs9EvP//9bz89vc3y54hnngRIsrexfzZa5vnq7d5e5i95zLIfxIoncudCpDHL5df0YS9m6eN69cYX8Yrl4TyMwvx573B/fzIyMGkfFLFYhD6/EP465kmu7fdSHklEkWTLcJWVaE990J5EGqxS4fMskxcdRwVezMKkgjk4AkBx6KciE4v8B3kxpkUaSpof7OtPcbQBOMYBHAKAic+/4DBODcaetKzjhAEOZ1LhhEENx60xNYCM4yCOy3Zkz7G6oth/e/OQiJTNI4kkOfJkN3saWP0rW6v+6I/y8J+lwwbCv+ALto7yTH1N71Lz1XzTf65Ekmfe01uW+WF4L9slweNQnuf6XZKFI7mHsyx/l4WsvvPSbFP7l+rAVks/y2ubz8MgHO2pk2Z/yJ2fWXQ2Ojwqt0xVIxrbIpY8lNt48mZ6W2/M2eiPpdk0l7hnI5a+mb1Thnvm2oq/tSteVd+Ko7a6R+pJqmtWiFzu5Yv3wn/kwSyXO85G++pUcuOnm7s0FKkU8tnoxx/NxhmPw+swCHhSOzBZhgH/fcmTTxkPNtt/u9JiNBt8sU7k5/HJRFMWZcHlF5+vlLTl3oSp3rtVBpE6eh1uTq7N/1uCHZg+a7Nfcqbim3ewDaGbj4I4VBZZ7WrbMddb166PQp1o/FInOnqpEx2/1IkmL3Wik5c60elLnUjD/JknCpOAfymECE8DUHfhWNSIxrGIDY1j0RIaxyIVNI5FCWgci6OjcSx+jMaxuCkCJxe+zQtrzj62eHs37u4xwg1395Dghrt7BHDD3R3w3XB3x3c33N3h3A13d/R2w90drPG4xVTLu5EyS/LBKlsIkSci517OvwxHY4nE0kkfDZ4a9HhKcpEEMEVkMwPxYDSf6e+7PUSL1H08z1U25omFtwgf1inPBjecJ595JLN2jwWBxCMETHm+Ti094uLTKV/wlCc+p3RsOtAoTLiXrOM5gW+u2AMZFk8C4u4rEUmCQuXQbJ0vlUhCAqeOmZ+K4U0TjCw+vA+z4X2lQLzzdRRxIqxbGhfTWMNzAw0zPDXQMMMzAw0zPDGocUbVRQaNqKcMGlGHGTSifiv8k6rfDBpRvxk0on4zaMP77T7MIx3i67OOg/61u2kkVJl+cDtm4UPC5ARg+HBjaqbeHUvZQ8pWS0+VkNth69eMPc+5CJ69e4oxrUKimtdrF5nKqw6T9fAObaBRiavCI5JXhUcksApvuMQ+yGmymqBd0+Qzs/U8bxWtRuol2hmL1sWEdrjaWD7cwzYCuArTjEwG7bAEHnyrprOKTorIt2nl8IZtsIbLajsqkTbPQBK0MhL+I00Yvn5e8VSmZY+Dka5EFIknHtAhzvJUFL5Wl/yhpqSX5C/j1ZJloc6VGhD9h/ryBr/3ga0GX9BdxMKEhrfLNzELI49uBnF9/+G9dy9WKs1UHUMDeC7yXMRkmKYS+N3vfP49TQPfySQ4eSa62ndE5SENNg0JBpkCSQRESHKaGSYhyRiq8f7Jn+eCpQEN2l3Ki2dqck6EOGPxqph0EGhLxsUnGX8IZkMa718sDVVdiEpU9yRgtbJhtp7/h/vDQ92t8EgqQ7+uc11/1FNdbU0HN3ya0IAbPkXQbMrhQfkvwcU24IZfbAOO6mKnEcuy0HoL1RmP6nJLPOrrHZ78GTwRiXSxjug6sAQk68ESkKwLRbSOk4zyijUe4QVrPOrrJXQZjUdQktN4/0jDgIwMDUbFhAajokGDUXGgwUgJGP6ETg1s+GM6NbDhz+oUYERTgBoYlZ+RDv9Ed3lqYFR+psGo/EyDUfmZBqPys/GFxxcLOQmmG2JqkFQ+V4OkG2iSnMcrkbL0mQjyMuIPjKBAWqDdpWKhXrYQSfEQNwGkqlFHhJPtAo6K5N/5nKxpCouyXQQVURZFQhDV1jYDjrZsPru2y0y/czG4CXcR8/lSRAFPLddkt5X58mzFfFOmB7f7epU934cPy9ybLatqfx1msr/TskzYG2a7T9jW55PDDrMPPAjXcdlQ+DLFZNzfWHt0w7h856XDeDOTaFge97SE55zsttzMkhuWJz0t4TlPe1pqnTYsu/RwwdLHVkc46fKfKsezON9JlxdVxq2n7XKkyrLNBU+6vKghFe+d76u7BZCdfpqx2/cTj90eoyI7CkZOdpTeurJDdAnsI/8cqpEdEzT1+aqnJ0Dc15PoXpHzt7Uo6vaNG079X+q6kROnJONeK864/42rRpSx92PvcGOH6B137BC9A5AdolckspqjQpIdpXdsskP0DlJ2CHS0giMCLlpBe1y0gvYu0QqiuESrAbMAO0Tv6YAdAi1UCIEW6oCZgh0CJVRg7iRUiIIWKoRACxVCoIUKJ2A4oUJ7nFChvYtQIYqLUCEKWqgQAi1UCIEWKoRACxVCoIXqOLe3mjsJFaKghQoh0EKFEGih6vniAKFCe5xQob2LUCGKi1AhClqoEAItVAiBFiqEQAsVQqCFCiFQQgXmTkKFKGihQgi0UCEEWqjFq4buQoX2OKFCexehQhQXoUIUtFAhBFqoEAItVAiBFiqEQAsVQqCECsydhApR0EKFEGihQgi0UPXNwgFChfY4oUJ7F6FCFBehQhS0UCEEWqgQAi1UCIEWKoRACxVCoIQKzJ2EClHQQoUQaKFCiC7/NLcobY/ZH+CrntYn9vvfujKN+lh/lbsONe4PVbbKjtX/XYRzIR691hcPxzrf6AcSzqNQ6BK15bZ6HVc/EoG68fnrtPsNnzr6wB9dMu9C6HumAPyoryWoqRx1uXzdEiR5R12eXrcEs86jruhbtwTD4FFX0NW6LB9KkcMRMO4KMzXjA4t5V7SumcMu7orRNUPYw12RuWYIO7grHtcMjz0VnLetj3v206R6vhQgdLljDeHEjtDllpCrMhxDYfQlzY7Qlz07Ql8a7QgoPq0weGLtUGiG7VBuVEOZYal2F6odAUs1RHCiGsC4Uw2hnKmGUG5Uw8CIpRoiYKl2D852BCeqAYw71RDKmWoI5UY1HMqwVEMELNUQAUv1wAHZCuNONYRyphpCuVENJ3dYqiEClmqIgKUaIjhRDWDcqYZQzlRDKDeqQZaMphoiYKmGCFiqIYIT1QDGnWoI5Uw1hOqiWldRGlSjGK6Z4yZhNUPcgFwzxAXnmqFDtlSzdsyWagiO2RLkquQcly3VSbMj9GXPjtCXRjsCik8rDJ5YOxSaYTuUG9W4bKmNaneh2hGwVOOyJSvVuGypk2pcttRJNS5bslONy5baqMZlS21UuwdnO4IT1bhsqZNqXLbUSTUuW7JTjcuW2qjGZUttVOOypTaqBw7IVhh3qnHZUifVuGzJTjUuW2qjGpcttVGNy5baqMZlS1aqcdlSJ9W4bKmTaly2ZKcaly21UY3LltqoxmVLbVTjsiUr1bhsqZNqXLbUSTUuW/ogTUKCn4CaxSzNPbrfi7tm2TJnw3+c8FOS8kxEn3ng0V7qe9RV7j01lr9S2Hq1O3l8LvtM/QJ67XWloPgFWAOoD7wJqmWqlLFqiWeW7jKbdYPN7Vr9Oc1kTm2O2d8/Pz8cT43UVsXSZFnxZqk8Rv1a0dloPNGvJKkvH9dqDTS2zoVpvTbZM43Z0fyqweb+8wFo8mbBLN2eOZM99avqYXBBifqxxZbtysnK7eVppkuWFns37l8eYwRu75+Lo/3ji8tG/zxyvrqV59fb1BfJOc/0t03XzdXvlHG1qJoRvyh+/On956gCr/ehZWE4qcRyrTrv3+yaNxaGa92pV4Vr3eNnZ6P7MOaZd8ufvI8iZon3nemkzJvOvje9rv/1VfjYdIP6T2HodeV0aDkbqd+9N0xtFpYrb5TXF5Yb60hTWx/OxVsOrd5i4hiNtxz28JamlP9kB7L7TxlBvir/GZuJQ2NhQr1toP+Mrf5jHgqh8Z/x6/GfUpVfl/9QxJojq6+Y6EbjK0evx1e0Rv5ffSWcFhfk7DPlSDzEZ46tPmMeAKPxmePX4zNaK19DfBnoGcUKs22eYcY6Gs+YvB7P0Ir4yzMeTqyeYTIyGs84eT2eUc70vppxZqCHnFo9xBS3aDzk9PV4iFbGq4gdhyfq/3bPKDfeh2oV8gtDZiPp6ek+vmSO+eYnxy0VIrN0UPXbN3rhoG3HsqwvZHGKchJVlbnafcTe7lzVKTvarOuYnaWtotRp9VrjtrtaKNszjwonkh9uEuXET2aV96KlwRdWQMn9Ux5FH1hxtFjZD434QmlP7j3Y1780ubV/XiyaYLVPdXXdCrDXbEzxtdtPimUUw+K1D2slUZWQW7pbv4M0tKd7+rC/zmTXzNQB2+1rVPS2W2l2egfeJphtRcdWHdhiovFwazy0B7y/KnlIQouim43QQyJCTZ3wmyV0SGkNSWhRBbMROiYi1BTuvl1C/xw1FmUpG3lHROSZ6PLqyXup4hOSxKJOZCPxmIhEU9r6phRITlVRuLFRNSGiygT/v6gaQlVRSbFRdUJElSn+fJOhkZyyorRho+yUiDKTwH9d6nqZAkaj/tXBp17ibptHvbGNvX5Pv5xe7k+vzoujTEFpdR7U0nt9nFoI2qyb9oe6raE+rJhftlD32eapmCr532GrPwPbqjDgdOaybOBwalVSM5eeLasu8iPOCqHVjpZfF2Ek916eXE4u9YNl2heu9MY58x8fUrFOgn43mKciyUTE9O+BbFx8FsaztX4oy3h2/bBWl9aLsFbuHDFdT9QXwZM3n2a0weUmUWXJVpes7cKFFWuRrZ//EnVv0eagCgKJSCof0mHb+JD+DByQ1HVoWNwMCNVTiNuUbfYMZayshbWUGZvMTS8Pfjw1CaxhrjlMHk/G002YNbF32WzoujzaSH1A52weiCyfh9zupJZHJql6a3eNFtd5k/3jy+Mp1iMPLq4uLhzGrKoPVZF08/vy2/2nn87d7G7ru/qgBXtrbFJm1F2XZB0XH8Jo68kfve+msi5Ha2MAwnZPKZafsp//BwAA//8DAFBLAwQUAAYACAAAACEAzJJQVH0BAADxAgAAEQAIAWRvY1Byb3BzL2NvcmUueG1sIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjJLLTsMwEEX3SPxD5H1qJ+WlKE3FQ6yoQKIViJ2xJ60hsS17IPTvcZI2JYgFO4/n+GRy7Xz+VVfRJzivjJ6RZMJIBFoYqfR6RlbL2/iCRB65lrwyGmZkC57Mi+OjXNhMGAcPzlhwqMBHwaR9JuyMbBBtRqkXG6i5nwRCh2ZpXM0xlG5NLRfvfA00ZeyM1oBccuS0FcZ2MJKdUopBaT9c1QmkoFBBDRo9TSYJPbAIrvZ/Hug6P8ha4dbCn+i+OdBfXg1g0zSTZtqhYf6EPi/uHrtfjZVusxJAilyKDBVWUOT0sAwr//H6BgL77aEIa+GAo3HFQglnvCkxui9LJSBaeXAdvSfa7N9h2xgnffCMqoBJ8MIpi+FG+6+MNgJdcY+LcMWlAnm1LS5Pz9OzTvOr0bIOPlX7NoqkI4Yy3wXdDwUyCgFlfZz7ztP0+mZ5S4qUpUnMTuIpW7I0O00zxl7auUbnD8J6N8A/jdOMnYyNe0EfzfiRFt8AAAD//wMAUEsDBBQABgAIAAAAIQAiURHx1QEAAN4DAAAQAAgBZG9jUHJvcHMvYXBwLnhtbCCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJxTwW7bMAy9D9g/GLo3crKh6AJFxZBi6GFDA8Rtz5xMJ8JsSZDYINnXj7YTT9l2mk/vkfTTE0mp+2PXFgeMyXq3EvNZKQp0xtfW7VbiufpycyeKROBqaL3DlThhEvf6/Tu1iT5gJIupYAmXVmJPFJZSJrPHDtKM044zjY8dENO4k75prMEHb946dCQXZXkr8UjoaqxvwiQoRsXlgf5XtPam95deqlNgPa0q7EILhJrOYFZ7Oio5xVXlCdrKdqjnJccnpjaww6TnSo5AvfpYJ724U3JEar2HCIa4h3p++0HJjKvPIbTWAHF39Tdrok++oeJpsFz0/yuZlyi+xhbNW7R00mwjp+qrdaOREbCxCLsIYX92NzG1NdDimhugG2gTKvk7oB4R+uFuwPb+DrQ8oCEfi2R/8ngXovgOCfu2rcQBogVHYiwbyYDbkCjqylLL2hMfYF6WY/uxNzmC68KBDB4YX7sbTkhPDd+N/mF2npsdPIxWMzu5s8sZf6iufRfAcX/lhLjBP9JzqPxDvxrnHl4Hs6m/WtpvA5h+OJ/KfP5ZRm05ijUPdJrJFFCPfIPY9vr8r9thfan5O9Fv1Mv4XHnbZiV/wwpdYrwI0zvSvwAAAP//AwBQSwMEFAAGAAgAAAAhAIg/pb/hAAAAVQEAABgAKABjdXN0b21YbWwvaXRlbVByb3BzMS54bWwgoiQAKKAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnJDBasMwEETvhf6D2bsiObFdEyyHuE4g19JCroq8tgWWZCS5tJT+e2V6So89LbPDzhu2OnzoKXlH55U1HNINgwSNtJ0yA4e31zMpIfFBmE5M1iAHY+FQPz5Und93IggfrMNLQJ3EhYrz0nL4ykvW5E87Rsr2nJLilDXkmKUNKTKWt8fnU8pY8Q1JRJsY4zmMIcx7Sr0cUQu/sTOaaPbWaRGidAO1fa8ktlYuGk2g25hA5RLx+qonqNc+v9cv2Pt7uVZbnPov5aZuk7KDE/P4CbSu6B/Uqu9eUf8AAAD//wMAUEsDBBQABgAIAAAAIQDBJ8sItgAAACEBAAATACgAY3VzdG9tWG1sL2l0ZW0xLnhtbCCiJAAooCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACskE0OgjAQRq9CegCKLlgQfmKiWzEhcV/KAE3aGdIOBm5v1egJXE7mfS/zTdlsziYP8MEQVuKQZiIJrHBQlhAqgSSauuyLjlavISSRxlD0lZiZl0LKoGdwKqS0AMbdSN4pjqOfJI2j0XAmvTpAlscsy2Vvemto8mqZd/GR/UfVgQXNMHS823i2PN1Ondl4vgyGY7P2LWjRGoR0CzYGXuBVuQhHViT37wtyUZfyV7h+AgAA//8DAFBLAwQUAAYACAAAACEAdD85esIAAAAoAQAAHgAIAWN1c3RvbVhtbC9fcmVscy9pdGVtMS54bWwucmVscyCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIzPsYrDMAwG4P3g3sFob5zcUMoRp0spdDtKDroaR0lMY8tYamnfvuamK3ToKIn/+1G7vYVFXTGzp2igqWpQGB0NPk4Gfvv9agOKxcbBLhTRwB0Ztt3nR3vExUoJ8ewTq6JENjCLpG+t2c0YLFeUMJbLSDlYKWOedLLubCfUX3W91vm/Ad2TqQ6DgXwYGlD9PeE7No2jd7gjdwkY5UWFdhcWCqew/GQqjaq3eUIx4AXD36qpigm6a/XTf90DAAD//wMAUEsDBBQABgAIAAAAIQDrgGBMUwMAAI8OAAASAAAAd29yZC9mb250VGFibGUueG1szJbPb9MwFMfvSPwPUU7jwJqkXZdV66Y2WzQk2IEVAUc3cVqL2I7itF3/AA6IE+LI38C4gwb/DNPYf8FznLRZm25LQbBGzY9n+5vnT57f8+7+KQ21MY4F4aytm5uGrmHmcZ+wQVt/0XMf27omEsR8FHKG2/oUC31/7+GD3Ukr4CwRGoxnokW9tj5MkqhVqwlviCkSmzzCDBoDHlOUwGM8qFEUvxlFjz1OI5SQPglJMq1ZhtHUM5n4Lio8CIiHD7g3opgl6fhajENQ5EwMSSRytcld1CY89qOYe1gImDMNlR5FhM1kzMaSECVezAUPkk2YTOZRKgXDTSO9o+FcYKuagLUk0PTwaTUNO9OowciiDvGr6TRnOsQv6KznTEFA4GoSW7kfYkrljKjXejJgPEb9EJTgG2mAWUuF5Rm8lZf0FrrvZfGqTVoMURjwEj62DHKRNkWIcYFNaB2jsK0bW8bST6/Jjt4QxQJLmbRj40CZA0RJOM2tPvbAr4SMsWqNSOIN88Yxion0WTUJMoCGkegb8Fb1q+vKYsJyzN+tLNasT26pX7d4qY6tDGZmMQt94J01BWIJSI9QLLRjPNGec4pYKRYLjqZRBzwN+Ftw1yjFktO6jiVOdasQgaVoWB17e04km9syEfsmIoqH61Yj4qCQ9GOygoSbEpBHAzhYlUiICRGiEomOdNY6TGegSDSkwdjuVosN9bxTkcQBZoNXJAsKFCbHYM19vvz87vLrj2wyS5RMiBcIabhmRyklu1lGCY0SvgakbgFS3XbcbcftLEIym7dAknQrQnqWZy/tNTrCKmwWWF18P/t1/uXq09urbx9WEetCXMl4knGVnisQqx5X6XqyiivM6jhu3dmy1kFmVkS2kHO0jSOM0qSsOSePygAuJqmVDJsZvWyF/oUs5eMAjcLkxoQB+w8eovKSorzaWTNjUO7juMytgJxif/m7HsrSYamMN88XrjOzzPPFzu2Zs2q+OCH0ZFSaLS7O3v88/3gvskU2j0K5tWzbzadfOVv8WbnVNrrcn96PsGc86cUj3JtGeK1lkFcL7SkZDJPVNSNrvw+x8H8rR7bRKPAq226oovBvthuHEkenmD4caWmUbDfukD5u3XhlN2LvNwAAAP//AwBQSwECLQAUAAYACAAAACEAZPVj7oEBAAApBgAAEwAAAAAAAAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQItABQABgAIAAAAIQAekRq37wAAAE4CAAALAAAAAAAAAAAAAAAAALoDAABfcmVscy8ucmVsc1BLAQItABQABgAIAAAAIQAzwlu/QQEAAOcEAAAcAAAAAAAAAAAAAAAAANoGAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAE4yjpAWBgAApiQAABEAAAAAAAAAAAAAAAAAXQkAAHdvcmQvZG9jdW1lbnQueG1sUEsBAi0AFAAGAAgAAAAhALb0Z5jSBgAAySAAABUAAAAAAAAAAAAAAAAAog8AAHdvcmQvdGhlbWUvdGhlbWUxLnhtbFBLAQItABQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAAAAAAAAAAAAAAKcWAAB3b3JkL3NldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQBAwf/xOQEAACMDAAAUAAAAAAAAAAAAAAAAAMsaAAB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQA520VMuQUAACdaAAASAAAAAAAAAAAAAAAAADYcAAB3b3JkL251bWJlcmluZy54bWxQSwECLQAUAAYACAAAACEA+JXI7/wOAADzmQAADwAAAAAAAAAAAAAAAAAfIgAAd29yZC9zdHlsZXMueG1sUEsBAi0AFAAGAAgAAAAhAMySUFR9AQAA8QIAABEAAAAAAAAAAAAAAAAASDEAAGRvY1Byb3BzL2NvcmUueG1sUEsBAi0AFAAGAAgAAAAhACJREfHVAQAA3gMAABAAAAAAAAAAAAAAAAAA/DMAAGRvY1Byb3BzL2FwcC54bWxQSwECLQAUAAYACAAAACEAiD+lv+EAAABVAQAAGAAAAAAAAAAAAAAAAAAHNwAAY3VzdG9tWG1sL2l0ZW1Qcm9wczEueG1sUEsBAi0AFAAGAAgAAAAhAMEnywi2AAAAIQEAABMAAAAAAAAAAAAAAAAARjgAAGN1c3RvbVhtbC9pdGVtMS54bWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAABVOQAAY3VzdG9tWG1sL19yZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAOuAYExTAwAAjw4AABIAAAAAAAAAAAAAAAAAWzsAAHdvcmQvZm9udFRhYmxlLnhtbFBLBQYAAAAADwAPANQDAADePgAAAAA=",EF=()=>wu(BF);async function IF(n){return new Promise((t,e)=>{const o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=e,o.src=n})}async function l9(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};const e=await Tr(new File([t],"",{})),o=await IF(e);return o.width===void 0||o.height===void 0?{width:345,height:230,buffer:t}:n.width||n.height?{width:n.width||o.width*n.height/o.height,height:n.height||o.height*n.width/o.width,buffer:t}:{width:o.width,height:o.height,buffer:t}}function xF(n,t){let e=n.filter(s=>s!=null);const o=t-(e.length-1)*20,r=.87,i=e.reduce((s,l)=>s+l.width,0);return i>o&&(e=e.map(s=>({width:s.width*o/i,height:s.height*o/i,buffer:s.buffer}))),e.map(s=>({width:s.width*r,height:s.height*r,buffer:s.buffer}))}function c9(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let o;switch(e%3){case 0:o=Y.LevelFormat.DECIMAL;break;case 1:o=Y.LevelFormat.LOWER_LETTER;break;default:o=Y.LevelFormat.LOWER_ROMAN;break}return{level:e,format:o,text:`%${e+1}. `,alignment:Y.AlignmentType.START,start:t,style:{paragraph:{indent:{left:Y.convertInchesToTwip(.3*(e+1)),hanging:Y.convertInchesToTwip(.2)}}}}})}function TF(){return[0,1,2,3,4,5,6,7].map(n=>{let t;switch(n%3){case 0:t="\u2022";break;case 1:t="\u25E6";break;default:t="\u25AA";break}return{level:n,format:Y.LevelFormat.BULLET,text:t,alignment:Y.AlignmentType.START,style:{paragraph:{indent:{left:Y.convertInchesToTwip(.3*(n+1)),hanging:Y.convertInchesToTwip(.2)}}}}})}function SF(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Y.LevelFormat.BULLET,text:"\u2611",alignment:Y.AlignmentType.START,style:{paragraph:{indent:{left:Y.convertInchesToTwip(.3*(n+1)),hanging:Y.convertInchesToTwip(.2)}}}}))}function DF(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:Y.LevelFormat.BULLET,text:"\u2610",alignment:Y.AlignmentType.START,style:{paragraph:{indent:{left:Y.convertInchesToTwip(.3*(n+1)),hanging:Y.convertInchesToTwip(.2)}}}}))}var fl=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(fl||{});const LF=[{levels:c9(),reference:"number-numbering-reference"},{levels:TF(),reference:"number-bullet-reference"},{levels:SF(),reference:"checked-bullet-reference"},{levels:DF(),reference:"unchecked-bullet-reference"}];function MF(n){switch(n){case"style-color-0":return"d83931";case"style-color-1":return"de7802";case"style-color-2":return"dc9b04";case"style-color-3":return"2ea121";case"style-color-4":return"245bdb";case"style-color-5":return"6425d0";case"style-color-6":return"8f959e";default:return}}function RF(n){switch(n){case"style-bg-color-1":case"style-bg-color-2":case"style-bg-color-8":case"style-bg-color-9":return"yellow";case"style-bg-color-0":case"style-bg-color-5":return"magenta";case"style-bg-color-3":return"green";case"style-bg-color-4":case"style-bg-color-11":return"blue";case"style-bg-color-6":return"lightGray";case"style-bg-color-7":return"red";case"style-bg-color-10":return"darkGreen";case"style-bg-color-12":return"darkMagenta";case"style-bg-color-13":return"darkGray";default:return}}function OF(n){switch(n){case"style-bg-color-0":return"fbbab6";case"style-bg-color-1":return"ffdcb0";case"style-bg-color-2":return"fff7a0";case"style-bg-color-3":return"ceefc5";case"style-bg-color-4":return"d1ddfb";case"style-bg-color-5":return"d9cbf8";case"style-bg-color-6":return"eaeaea";case"style-bg-color-7":return"fe837c";case"style-bg-color-8":return"ffbd6a";case"style-bg-color-9":return"ffe662";case"style-bg-color-10":return"a8f393";case"style-bg-color-11":return"98b5ff";case"style-bg-color-12":return"b394f8";case"style-bg-color-13":return"b1b1b1";default:return}}const NF=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function a9(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(NF);if(t){const e=s=>{let l=Number(s).toString(16);return l.length<2&&(l=`0${l}`),l},o=e(t[1]),r=e(t[2]),i=e(t[3]);return`${o}${r}${i}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function oe(n,t){if(n&&n.attributes&&n.attributes[t])return n.attributes[t];if(n&&n.attributes&&n.attributes.box&&n.attributes.inputType&&t==="style-underline")return!0}function u9(n,t,e){for(let o=0;o<=e;++o){const r=`${t}${o}`;if(oe(n,r))return r}}function Ra(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function Uf(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"}function d9(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function PF(n){const t=oe(n,"inlineStyle");if(t==null)return;const e=t.split(";");for(const o of e){const r=o.split(":");if(r.length!==2)continue;const i=r[0].trim().toLowerCase(),s=r[1].trim().toLowerCase();i==="font-size"&&Ra(n,"inline-style-font-size",s),i==="color"&&Ra(n,"inline-style-color",s),i==="background-color"&&Ra(n,"inline-style-background-color",s),i==="font-family"&&Ra(n,"inline-style-font-family",s)}}function $F(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function _F(n){const t=`${oe(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function FF(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` ${n.attributes.text} `;if(n.attributes&&n.attributes.box&&n.attributes.inputType)return n.attributes.value?`${n.attributes.value}`:" "}function HF(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function jF(n){return oe(n,"inline-style-font-family")}function zF(n){const t=oe(n,"inline-style-background-color");return a9(t)}function UF(n){const t=oe(n,"inline-style-color");return a9(t)}function VF(n){PF(n);const t=oe(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!oe(n,"style-code"),link:d9(oe(n,"link")),size:_F(n),text:t?HF(n):FF(n)||n.insert,bold:!!oe(n,"style-bold"),underline:!!oe(n,"style-underline"),italics:!!oe(n,"style-italic"),strike:!!oe(n,"style-strikethrough"),superScript:!!oe(n,"style-super"),subScript:!!oe(n,"style-sub"),math:oe(n,"type")==="math"?oe(n,"src"):void 0,mention:t,fontFamily:jF(n),background:zF(n),color:t?"338fe5":MF(u9(n,"style-color-",6))||UF(n),highlight:u9(n,"style-bg-color-",13)}}function qF(){return[new Y.Paragraph({border:{top:{color:"auto",style:Y.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new Y.Paragraph({spacing:{line:0}})]}function WF(){return new Y.Paragraph({children:[new Y.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Y.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function GF(){return new Y.Paragraph({children:[new Y.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:Y.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function ZF(n,t){return new Y.Paragraph({children:[new Y.ExternalHyperlink({children:[new Y.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function h9(n){if(n.heading!=null)return`Heading${n.heading}`}function f9(n){if(n.alignment!=null){if(n.alignment==="center")return Y.AlignmentType.CENTER;if(n.alignment==="right")return Y.AlignmentType.RIGHT;if(n.alignment==="left")return Y.AlignmentType.LEFT}}function QF(n){if(n.indent)return{left:Y.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:Y.convertInchesToTwip(.3*n.padding)}}function YF(n){return{type:Y.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function JF(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function m9(n,t){let e;e=n.inlineCode?"InlineCode":void 0,e=n.link?"Hyperlink":e;const o=n.size||t,r=o!=null?Math.floor(o*1.5+.5):void 0;return new Y.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:Y.UnderlineType.SINGLE}:void 0,italics:n.italics||void 0,strike:n.strike||void 0,superScript:n.superScript||void 0,subScript:n.subScript||void 0,size:r,style:e,font:n.fontFamily?JF(n.fontFamily):void 0,shading:n.background?YF(n.background):void 0,color:n.color,highlight:RF(n.highlight)})}function KF(n,t){if(n.link)return new Y.ExternalHyperlink({children:[m9(n,t)],link:n.link})}async function g9(n,t,e,o,r){const i=await r(n,t,e);if(i==null)return;const s=await l9({width:o||0,height:0,src:e},i);return new Y.ImageRun({data:i,transformation:{width:s.width||100,height:s.height||20}})}function XF(n){if(n.heading||n.heading)return n.heading}function tH(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function eH(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function nH(n,t){var o;const e=[];if(n.text&&Array.isArray(n.text)){for(let r=0;r<n.text.length;r++){const i=n.text[r];if(((o=i.attributes)==null?void 0:o.box)===!0&&t){const s=await t(i);if(s){n.text.splice(r+1,0,...s);continue}}e.push(VF(i))}return e}}function oH(n){if(n.type==="list"&&n.textOnly!==!0)return{checkbox:n.checkbox,groupId:n.groupId,ordered:!!n.ordered,level:n.level||1,start:n.start||0}}function rH(n,t){if(n.type==="embed"&&n.embedType&&Uf(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(o=>{const r=t(o),i=n.embedData[`${r}_width`],s=n.embedData[`${r}_height`];return{src:o,width:i,height:s}})}function iH(n){if(n.padding)return n.padding}function sH(n){return!!(n.type==="embed"&&n.embedType&&Uf(n.embedType)&&n.embedData&&n.embedData.src)}async function Oa(n,t,e){return{quoted:!!n.quoted,heading:XF(n),alignment:tH(n),indent:eH(n),padding:iH(n),texts:await nH(n,e),list:oH(n),images:rH(n,t),border:sH(n)}}async function lH(n,t,e,o){const r=[];if(!n.children)return[];for(const i of n.children){const s=[];for(const l of t.blocks[i])s.push(await Oa(l,e,o));r.push(s)}return r}const cH=w("to-docx");function aH(n,t){return Array(n).fill(0).map(()=>Array(t).fill(0).map(()=>({cellId:void 0,color:void 0,from:void 0,rowSpan:1,colSpan:1,width:0,originalWidth:void 0,align:void 0})))}function uH(n,t,e,o){const r=!!n.hasColTitle,i=!!n.hasRowTitle,s=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let a=0;a<e;a++)(r&&a===0||i&&c===0||s&&c%2===1)&&(o[c][a].color=l)}function dH(n){u(cH,n.children,"no table children");const t=n.rows,e=n.cols,o=n.colsWidth;if(o)for(let s=0;s<o.length;s++)o[s]===0&&(o[s]=100);const r=aH(t,e);let i=0;for(let s=0;s<t;++s)for(let l=0;l<e;++l){if(r[s][l].originalWidth=o?o[l]:void 0,r[s][l].from!==void 0)continue;const c=n.children[i];i+=1,r[s][l].cellId=c,r[s][l].color=OF(n[`${c}_background`]),r[s][l].width=o?o[l]:100,r[s][l].align=n[`${c}_align`];const a=n[`${c}_rowSpan`]||1,d=n[`${c}_colSpan`]||1;if(r[s][l].rowSpan=a,r[s][l].colSpan=d,a>1||d>1){let f=0;for(let m=0;m<a;m++)for(let p=0;p<d;p++)m===0&&(f+=o?o[l+p]:80),!(m===0&&p===0)&&(r[s+m][l+p].from=[s,l]);r[s][l].width=f}}return uH(n,t,e,r),r}async function hH(n,t,e,o,r,i,s,l,c,a){async function d(p){if(l){const A=await l(r,i,p);if(A){await o.addDoc(n,A,a);return}}if(p.type==="text"||p.textOnly===!0){const A=await Oa(p,s,c);await o.addTextBlock(A);return}if(p.type==="code"){const A=await lH(p,e,s,c);await o.addCodeBlockObject(A);return}if(p.type==="list"&&p.textOnly!==!0){const A=await Oa(p,s,c);await o.addListBlockObject(n,A);return}if(p.type==="embed"&&p.embedType){const A=p,k=A.embedData,v=A.embedType;if(Uf(v)){const x=await Oa(p,s,c);await o.addImagesBlockObject(x,a)}else p.embedType==="hr"?o.addSeparatorBlock():p.embedType==="video"?o.addVideoPlaceholder():p.embedType==="audio"?o.addAudioPlaceholder():p.embedType==="webpage"?o.addHyperlinkParagraph(d9(k.src),k.title):o.addOtherEmbedBlock(v,p.embedData);return}if(p.type==="table"){let A=[];if(p.colsWidth)A=p.colsWidth;else{const v=p.cols;A=new Array(v);for(let x=0;x<A.length;x++)A[x]=100;p.colsWidth=A}const k=dH(p);await o.addTableMatrix(A,k,e),o.addEmptyParagraph()}}function f(p){const A=[];for(const{type:k,data:v}of p.embedData.exportSpec){if(k==="text"){const x={id:P(),text:[{insert:v}],type:"text"};A.push(x);continue}if(k==="image"){const x={id:P(),type:"embed",embedType:"image",align:"left",embedData:{src:v}};A.push(x);continue}if(k==="link"){const x={id:P(),type:"embed",embedType:"webpage",embedData:{src:v.url,title:v.title}};A.push(x);continue}}return A}function m(p){var A;return(A=p==null?void 0:p.embedData)!=null&&A.exportSpec?f(p):[p]}for(const p of t)for(const A of m(p))await d(A)}function fH(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const mH=w("to-docx");class gH{constructor(t,e,o,r,i,s){h(this,"paragraphs");this.appId=t,this.docId=e,this.state=o,this.readImageFunc=r,this.convertBlocksFunc=i,this.defaultFontSize=s,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new Y.Paragraph({heading:h9(t),alignment:f9(t),children:await this.paragraphsFromBlockTexts(t),indent:QF(t)}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=$F(this.defaultFontSize,t.heading),o=[];for(const r of t.texts){if(r.link){const i=KF(r,e);i&&o.push(i);continue}if(r.box&&r.box.type&&r.box.type==="br"){o.push(new Y.TextRun({text:"",break:1}));continue}if(r.box&&r.box.type&&r.box.type==="image"){const i=await g9(this.appId,this.docId,r.box.src,r.box.width,this.readImageFunc);i&&o.push(i);continue}if(r.math){const i=await g9(this.appId,this.docId,r.math,0,this.readImageFunc);i&&o.push(i);continue}o.push(m9(r,e))}return o}async addCodeBlockObject(t){for(const e of t)for(const o of e){const r={style:Y.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new Y.Paragraph({style:"Code",border:{left:{...r},right:{...r},top:{...r},bottom:{...r}},children:await this.paragraphsFromBlockTexts(o)}))}}async addListBlockObject(t,e){if(e.list==null)return;let o;const r=e.list.checkbox?`${t}-${e.list.groupId}-${e.list.checkbox}`:`${t}-${e.list.groupId}`;if(this.state.listInstMap[r])o=this.state.listInstMap[r];else if(o=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[r]=o,e.list.start>0&&e.list.ordered){const s=`number-numbering-reference-${o}`,l=c9([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:s,inst:o}),this.state.listRefMap[r]=s}else e.list.ordered?this.state.listRefMap[r]=fl.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[r]=fl.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[r]=fl.UNCHECKED:this.state.listRefMap[r]=fl.BULLET;const i=h9(e);e.texts&&this.paragraphs.push(new Y.Paragraph({heading:i,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[r],level:e.list.level-1,instance:o}}))}imageDimWithBufferToImageRun(t){return new Y.ImageRun({data:t.buffer,transformation:{width:t.width,height:t.height}})}async addImagesBlockObject(t,e){if(t.images==null)return;const o=await Promise.all(t.images.map(async s=>{const l=await this.readImageFunc(this.appId,this.docId,s.src);if(l)return l9(s,l)})),r=xF(o,e),i={style:Y.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new Y.Paragraph({border:t.border?{left:{...i},right:{...i},top:{...i},bottom:{...i}}:void 0,alignment:f9(t)||Y.AlignmentType.CENTER,children:r.map(s=>this.imageDimWithBufferToImageRun(s)).flatMap((s,l,c)=>s==null?[]:c.length-1!==l?[s,new Y.TextRun({text:" "})]:s)}))}addSeparatorBlock(){qF().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new Y.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(WF())}addAudioPlaceholder(){this.paragraphs.push(GF())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(ZF(t,e))}async addTableMatrix(t,e,o){const r=t.map(i=>i!==0?i*15:1500);this.paragraphs.push(new Y.Table({rows:await this.generateTableRows(e,o),columnWidths:r}))}async generateRowCells(t,e){const o=[];for(const r of t){const i=r.cellId;if(i===void 0)continue;const s=r.width*.9;o.push(new Y.TableCell({children:await this.convertBlocksFunc(i,e.blocks[i],e,this.appId,this.docId,this.state,s),columnSpan:r.colSpan,rowSpan:r.rowSpan,width:{type:Y.WidthType.DXA,size:r.width*15},shading:r.color?{fill:r.color,type:Y.ShadingType.CLEAR,color:"auto"}:void 0}))}return o}async generateTableRows(t,e){const o=[];for(const r of t)o.push(new Y.TableRow({children:await this.generateRowCells(r,e)}));return o}async addDoc(t,e,o){const r=await this.convertBlocksFunc(t,e.blocks.root,e,this.appId,this.docId,this.state,o);r&&(this.paragraphs=this.paragraphs.concat(r))}async addOtherEmbedBlock(){}}class pH{constructor(t,e,o,r,i,s,l,c){h(this,"convertBlocks",async(t,e,o,r,i,s,l=720)=>{const c=new gH(r,i,s,this.readImage,this.convertBlocks,this.defaultFontSize);return await hH(t,e,o,c,r,i,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=o,this.readImage=r,this.defaultFontSize=i,this.getDocByBlock=s,this.getTextsByBox=l,this.backgroundImageOptions=c}async convert(t,e){return this.snapshot2docx(this.docData,t,e)}async snapshot2docx(t,e,o){const r=new Y.ImportDotx,i=this.templateData?await r.extract(this.templateData):void 0,s=t.blocks.root;u(mH,s,"data must have blocks");const l=fH(),c=await this.convertBlocks("blocks",s,t,e,o,l),a=this.backgroundImageOptions?{default:new Y.Header({children:[new Y.Paragraph({children:[new Y.ImageRun(this.backgroundImageOptions)]})]})}:{},d=new Y.Document({numbering:{config:[...LF,...l.levelConfigs]},sections:[{headers:a,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:i});return Y.Packer.toBlob(d)}}async function CH(n,t,e,o){const r=n.doc.buildResourceUrl(o,{withToken:!0});let i=await vF(r);if(!i)return;if(i.type.indexOf("/svg")!==-1){const l=await kF(i);l&&(i=new File([l],i.name))}return await i.arrayBuffer()}async function AH(n,t,e){const o=n.editorBlocks.getBlockClass(e.type);if(o.toStandardDoc)return o.toStandardDoc(n,e,t)}async function bH(n,t){const e=t.attributes,o=n.editorBoxes.getBoxClass(e.type);if(o.toStandardText)return o.toStandardText(n,e)}async function vH(n,t){let{template:e,download:o,backgroundImageOptions:r}=t!=null?t:{};e||(e=EF());const i=n.doc.toJSON(),s=(f,m,p)=>CH(n,f,m,p),l=async(f,m,p)=>AH(n,i,p),c=async f=>bH(n,f),d=await new pH(e,i,Er.default,s,void 0,l,c,r).convert("_appId","_docId");if(o){const f=URL.createObjectURL(d),m=document.createElement("a");m.setAttribute("download",`${wF(n)}.docx`),m.setAttribute("href",`${f}`),m.click(),m.remove()}return d}const Vf=w("create-editor"),p9=[va,$1,cf,af,uf,k1,df,Mf,Lf,G4,X6,g$];async function yH(n,t){var s,l,c,a,d,f,m,p,A,k,v,x,E;u(Vf,n,"app does not exists"),t.lang&&T.setLang(t.lang),so.level=(s=t.logLevel)!=null?s:Ni.DEBUG;const e=t.onReauth?async()=>{var q;const L=t.user.userId,R=t.docId,$=await((q=t.onReauth)==null?void 0:q.call(t,L,R,t.permission));return{userId:L,docId:R,permission:t.permission,appId:t.appId,token:$,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,o={auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl,reauthFunc:e,disableLogout:t.disableLogout},r=await Es.load(o),i=hs(n,r,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,components:{blocks:[Ws,Qs,V1,MC],commandProviders:[new jh,...((l=t.components)==null?void 0:l.commandProviders)||[]],decorators:[new Js,new gh],embeds:[...p9,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[ta,Hf,v6,...((a=t.components)==null?void 0:a.boxes)||[]],insertions:[Cd],blockHooks:[new F4,new X4,...((d=t.components)==null?void 0:d.blockHooks)||[]],textRenders:[new m6,new tI],options:{...t.componentsOptions}},shortcuts:[YD,xM,L1,V3,eI,E1,A$,Ac],colors:["#338FE5","#24B47E","#F0A100","#E52727","#9678D3","#2CB2AE","#EB6414","#8AAB3F"]});if(i.editorCommandProviders.registerCommandProvider(new Rn(i)),i.input.addHandler(new k_),i.input.addHandler(new ca),i.input.addHandler(new Zx),i.input.addHandler(new vM),i.input.addHandler(new Zs(i,{headingLevel:1,titlePlaceholder:T.t("placeholder.common.title"),contentPlaceholder:T.t("placeholder.common.content"),readonlyTitlePlaceholder:T.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new ea(i,(f=t.componentsOptions)==null?void 0:f.quickMenu)),i.input.addHandler(new hf(i)),i.input.addHandler(new N3(i)),i.input.addHandler(new WD),i.input.addHandler(new Y1),i.doc.registerCallback(new w_(i)),i.addCustom("remote-cursor",()=>new l5(i)),i.addCustom("block-menu",L=>new U4(L)),i.addCustom("editor-tooltip",()=>new B1(i)),t!=null&&t.enableComments&&i.addCustom("editor-comments",L=>new f6(L,new gF(L))),i.addCustom("create-options",()=>new Am(i,t)),i.addCustom("drop-target",()=>new ol(i)),i.addCustom("list-to-mindmap",()=>new Jc(i)),i.addCustom("list-to-mention",()=>new H_(i)),i.addCustom("mobile-helper",()=>new X_(i)),i.addCustom("code-caret",()=>new qD(i)),(m=t.componentsOptions)!=null&&m.mention){const L=t.componentsOptions.mention;i.addCustom("mention",()=>new N_(i,L))}if(i.addCustom("heading-collapse",()=>new A_(i)),ii.register(i),ol.register(i),yr.register(i),Oo.register(i),(A=(p=t.componentsOptions)==null?void 0:p.remoteCarets)!=null&&A.onUserChanged){const L=(v=(k=t.componentsOptions)==null?void 0:k.remoteCarets)==null?void 0:v.onUserChanged;i.doc.getRemoteUsers().on("change",R=>{L(i,R)})}return(E=(x=t.componentsOptions)==null?void 0:x.templates)!=null&&E.templates.length&&(i.addListener("docChanged",()=>{zf(i)}),i.addListener("resize",()=>{zf(i,{reset:!0})}),setTimeout(()=>{zf(i)},100)),i.doc.registerCallback({onError:async L=>{if(L.code==="ResetDoc"){Vf.error(`reset doc: ${L.message}`);const R=await Es.load(o);i.doc.reset(R)}}}),i}function kH(n){return n.toJSON!==void 0}async function wH(n,t,e){var i,s,l,c;u(Vf,n,"app does not exists");const o=kH(t)?t:new Yd(t,{serverUrl:e.serverUrl||""});e.lang&&T.setLang(e.lang);const r=hs(n,o,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[Ws,Qs,V1,MC],commandProviders:[new jh],decorators:[new Js,new gh],embeds:[...p9,...((i=e.components)==null?void 0:i.embeds)||[]],boxes:[ta,Hf,v6,...((s=e.components)==null?void 0:s.boxes)||[]],insertions:[Cd],blockHooks:[new F4,...((l=e.components)==null?void 0:l.blockHooks)||[]],textRenders:[new m6],options:{...e.componentsOptions}},shortcuts:[L1,V3,E1,Ac]});return r.editorCommandProviders.registerCommandProvider(new Rn(r)),r.input.addHandler(new ca),r.input.addHandler(new Zs(r,{headingLevel:1,titlePlaceholder:T.t("placeholder.common.title"),contentPlaceholder:T.t("placeholder.common.content"),readonlyTitlePlaceholder:T.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),r.input.addHandler(new ea(r,(c=e.componentsOptions)==null?void 0:c.quickMenu)),r.input.addHandler(new hf(r)),r.input.addHandler(new N3(r)),r.input.addHandler(new Y1),r.addCustom("block-menu",a=>new U4(a)),r.addCustom("editor-tooltip",()=>new B1(r)),e!=null&&e.enableComments&&r.addCustom("editor-comments",a=>new f6(a,new pF(a,o))),r.addListener("clickLink",(a,d,f)=>{var p;if((p=e==null?void 0:e.events)!=null&&p.onClickLink){e.events.onClickLink(a,d,f);return}const m=f.getAttribute("link");m&&(a.readonly||d.ctrlKey||d.metaKey)&&window.open(m,"_blank")}),ii.register(r),r}function BH(n,t){var l;const e=n.doc;if(!((l=e.getVersionHelper)==null?void 0:l.call(e)))throw new Error("the editor does not support to show versions");const r=n.getCustom("create-options");if(!r)throw new Error("the editor does not support to show versions");const i=r.getData(),s=new fF(i);return l_(n,s,t)}g.tippy=i8,g.AuthError=Tc,g.AuthHeader=Bs,g.AutoScroll=Km,g.BaseURLHeader=Sc,g.BasicCommands=kx,g.BlockExclusiveHook=X4,g.BlockResizer=sa,g.BrBox=Lp,g.CodeBlock=Qs,g.CodeLineBlock=V1,g.CodeTextDecorator=Js,g.DefaultShortcuts=Ac,g.DocIdError=Qk,g.DragDrop=Rm,g.DrawioEmbed=va,g.EditorBlocks=Tg,g.EditorBoxes=Rp,g.EditorCommandProviders=k2,g.EditorComplexBlockPosition=Xe,g.EditorComplexSelectionRange=tn,g.EditorDecorators=$p,g.EditorEmbeds=Dg,g.EditorInsertions=Pp,g.EditorSimpleBlockPosition=qt,g.EditorSimpleSelectionRange=Kt,g.EmbedBlock=Mg,g.EnforceWithDocumentTitleHandler=Zs,g.EventCallbacks=Pi,g.FILL_CHAR=pb,g.FileExtError=Yk,g.HeadingBlockScrollListener=O_,g.InputtingInsertion=Op,g.LocalDoc=Yd,g.LogLevel=Ni,g.Logger=so,g.MIN_DISTANCE_THRESHOLD=Lm,g.ManualCloseDialog=Ds,g.ManualMenu=cr,g.ManualToolbar=Ss,g.MarkdownInputHandler=ca,g.MaxUserError=ch,g.OnesEditorAutoSuggest=Mh,g.OnesEditorCustomDataWrapper=Am,g.OnesEditorExclusiveBlock=Oo,g.OnesEditorHoveringBlock=$t,g.OnesEditorQuickMenu=ea,g.OnesEditorToc=dl,g.OnesEditorTocProvider=yr,g.OnesEditorToolbar=ii,g.OnesEditorTooltip=B1,g.PermissionError=Zk,g.Popup=Is,g.RemoteCarets=l5,g.RemoteCaretsDecorator=gh,g.RemoteCaretsInsertion=Cd,g.RemoteUsers=vc,g.RequestReloadError=ws,g.RichText=ce,g.ShareDBDoc=Es,g.SimpleCache=vm,g.StandardEmbedBlockCommands=N1,g.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=rd,g.TEXT_STYLE_COLOR_PREFIX=od,g.TableBlock=Ws,g.TableBlockCommandProvider=jh,g.TableShortcuts=L1,g.TextBlock=ye,g.TextBox=Dp,g.TextStyleShortcuts=E1,g.TocEmbed=X6,g.ZERO_WIDTH_SPACE_CHAR=$i,g.addAttribute=Jl,g.addClass=M,g.addCommentToBlock=la,g.addDays=Z8,g.addMetaToDoc=us,g.addMonths=G8,g.animateScrollTo=pu,g.applyPlaceholderToBlock=aa,g.assert=u,g.blockToDoc=Wd,g.blockToHtml=yd,g.blockToMarkdown=kd,g.blockToText=lc,g.blocksToDoc=Pv,g.clearAllSelection=Ag,g.clientType=xt,g.cloneBlock=bo,g.cloneChildContainer=Md,g.cloneDoc=Rd,g.cloneText=hp,g.commentToShareDbComment=mh,g.compareElement=Dl,g.comparePosition=Uu,g.complexBlockAdjustSelectionPos=Ul,g.complexBlockFindNearestChildBlock=Pg,g.complexBlockGeFirstSimpleChild=qu,g.complexBlockGetAllChildContainers=Se,g.complexBlockGetBottomChildContainers=Ng,g.complexBlockGetLastSimpleChild=Vi,g.complexBlockGetSelectedContainers=Rr,g.complexBlockGetTopChildContainers=Og,g.containerToDoc=K0,g.continuousScroll=Jm,g.convertBlockFrom=jl,g.copyBlockAttributes=Yp,g.createBlockAnchor=fo,g.createBlockCaretAnchor=jg,g.createBlockContentElement=lo,g.createBlockElement=lg,g.createBlockSimpleDocRange=nc,g.createBlockSimpleRange=Ot,g.createBoxContentElement=ug,g.createBoxElement=cg,g.createBoxOp=op,g.createChildContainer=xp,g.createComplexBlockPosition=Bt,g.createComplexDocPos=Ap,g.createComplexDocRange=bb,g.createContainer=gp,g.createContainerElement=fd,g.createDeleteOps=Xg,g.createEditor=hs,g.createEditorSelectionRange=Wt,g.createElement=b,g.createEmptyContainer=Bn,g.createEmptyDoc=or,g.createEmptyTextBlockData=Xl,g.createExpandedRange=Tl,g.createIconButton=Ir,g.createImage=ym,g.createInsertOps=Yl,g.createInsertionContentElement=fg,g.createInsertionElement=dg,g.createLocalEditor=wH,g.createOnesEditor=yH,g.createRange=km,g.createRichText=Co,g.createRootContainer=Ip,g.createSimpleBlockPosition=F,g.createSimpleDocPos=Cp,g.createTextBlockData=Vn,g.createTextButton=mr,g.createTextOp=_e,g.createTextWithReplaceSoftReturn=Xu,g.daysAfter=Tu,g.deleteText=ed,g.diffDays=Q8,g.disablePageScroll=qm,g.docToHtml=Vp,g.docToHtmlFragment=ts,g.docToMarkdown=$r,g.docToText=cc,g.downloadObjectToFile=nf,g.downloadSvgToString=t3,g.editLink=Hs,g.editorAddComment=MP,g.editorAddTextAttribute=l0,g.editorAutoInsertBlock=Jp,g.editorBreakTextBlock=Hr,g.editorClearCompositionText=Qp,g.editorClearSelectedContents=Dd,g.editorCopyBlock=Cc,g.editorDeleteBlock=Td,g.editorDeleteBlockText=Ed,g.editorDeleteBlockWithoutChildren=xd,g.editorDeleteChildContainer=gv,g.editorDeleteChildContainers=Kp,g.editorFocusToBlock=Ld,g.editorFocusToEnd=Y0,g.editorGetBlockData=Ao,g.editorGetBlockText=ge,g.editorGetBlockTextEx=rc,g.editorGetBoxData=vp,g.editorHandleKeyboardEvent=o2,g.editorInsertBlock=Fr,g.editorInsertBoxToBlock=Gp,g.editorInsertDoc=i0,g.editorInsertDocAt=Od,g.editorInsertText=Bd,g.editorInsertTextToBlock=Wp,g.editorInsertTextToBlockEx=wd,g.editorMergeTextBlock=Xp,g.editorMoveDown=b0,g.editorMoveEnd=S0,g.editorMoveHome=D0,g.editorMoveLeft=p0,g.editorMoveLineEnd=_0,g.editorMoveLineHome=$0,g.editorMovePageDown=V0,g.editorMovePageUp=U0,g.editorMoveRight=C0,g.editorMoveUp=A0,g.editorMoveWordEnd=I0,g.editorMoveWordLeft=E0,g.editorRangeClearColor=a0,g.editorRangeGetColor=Nd,g.editorRangeSetColor=c0,g.editorRemoveTextAttribute=bv,g.editorReplaceBlockText=hc,g.editorReplaceContainer=s0,g.editorRunOnce=Jd,g.editorSelectAll=Q0,g.editorSelectContainer=Vd,g.editorSelectDown=v0,g.editorSelectEnd=zd,g.editorSelectHome=L0,g.editorSelectLeft=y0,g.editorSelectLineEnd=P0,g.editorSelectLineHome=N0,g.editorSelectPageDown=W0,g.editorSelectPageUp=q0,g.editorSelectRight=k0,g.editorSelectUp=w0,g.editorSelectWordEnd=T0,g.editorSelectWordLeft=x0,g.editorSetTextColor=jr,g.editorShowFindDialog=HN,g.editorToDocx=vH,g.editorUpdateBlockData=fc,g.editorUpdateCompositionText=Zp,g.editorUpdateEmbedData=o0,g.enablePageScroll=Wm,g.escapeHtmlText=Tm,g.escapeRegExp=Lu,g.escapeSpace=D8,g.exclusiveBlock=J4,g.executeBlockCommand=xg,g.executeEmbedBlockCommand=Ig,g.executeRangeCommand=y2,g.fileToDataUrl=Tr,g.findAfterOffsetNotType=ud,g.findAllText=cd,g.findEventTargetBlock=Im,g.findInsertionById=hg,g.findNextOffset=Pb,g.findPrevOffset=Nb,g.findPrevOffsetNotType=ad,g.findPrevSimpleBlockBeforeChildContainer=Rg,g.findTarget=xr,g.findWordEnd=hd,g.findWordLeft=dd,g.format=xu,g.formatBytes=Xm,g.formatDate=ng,g.fragmentToHtml=Gm,g.fromBase64=Ml,g.fromBase64ToBlob=wu,g.fromBase64ToUint8Array=z8,g.fromDocRange=ho,g.fromNowString=Du,g.genId=P,g.getAllChildBlocks=Gu,g.getAllQuickMenuItems=w1,g.getAllSelectedBlocks=en,g.getAttributesAt=Ji,g.getBlockBackground=sg,g.getBlockByIndex=Sr,g.getBlockCaretRect=Ye,g.getBlockClass=pt,g.getBlockClassByType=Mr,g.getBlockClientRects=co,g.getBlockCommandsWithHook=Fu,g.getBlockContent=st,g.getBlockId=j,g.getBlockIndex=K,g.getBlockKind=Je,g.getBlockMinWidth=vg,g.getBlockNearestRangeFromPoint=Fg,g.getBlockOptions=tA,g.getBlockPath=ao,g.getBlockProperties=wg,g.getBlockRangeFromPoint=Vl,g.getBlockStyles=X8,g.getBlockTextLength=G,g.getBlockTools=Rt,g.getBlockType=it,g.getBoxContent=Ou,g.getBoxId=ag,g.getBoxTypeFromElement=ji,g.getChildBlockCount=Ze,g.getChildBlocks=Mt,g.getChildOffset=mo,g.getColorFromAttributes=sd,g.getComplexBlockClass=xe,g.getContainerBlockPath=wp,g.getContainerBlocks=Cg,g.getContainerBlocksElement=sc,g.getContainerById=Pr,g.getContainerId=V,g.getContainerMinWidth=gd,g.getContainerToolsElement=$b,g.getContainerWidth=Tp,g.getDistanceSquare=An,g.getElementOffset=_i,g.getEmbedType=Ne,g.getExistsBlockTools=Hl,g.getExistsContainerById=kp,g.getFileExt=Iu,g.getFirstChildBlock=Ft,g.getFirstClientRect=Sl,g.getHeadingMenuOptions=A1,g.getHorizontalPadding=du,g.getInsertionContent=Nu,g.getLastChildBlock=Jt,g.getLastClientRect=Vo,g.getListAllNextBrothers=zs,g.getLogger=w,g.getNextBlock=dt,g.getNextValidOffset=tr,g.getNextVisibleBlock=Lr,g.getOffsetInfoAfter=Xi,g.getOffsetInfoBefore=ic,g.getOpAt=ip,g.getOpLength=nd,g.getParentBlock=U,g.getParentBlockExcludeSelf=Fl,g.getParentBox=Ru,g.getParentContainer=z,g.getPrevBlock=bt,g.getPrevValidOffset=go,g.getPrevVisibleBlock=Dr,g.getRangeCommands=b2,g.getRootBlock=_u,g.getScrollContainer=bn,g.getSpecialBlockCommands=Bg,g.getStandardEmbedBlockProperties=P1,g.getTextAfterOffset=Rb,g.getTextBeforeOffset=Ob,g.getTextBlockChild=ql,g.getTextBlockClass=gg,g.getTextBlockContentChildTextLength=$e,g.getTextBlockContentChildType=Hg,g.getTextBlockContentChildren=yn,g.getTextLength=me,g.getTextOpLength=Zu,g.getTextWidth=Ol,g.getToolbar=Vc,g.handleBlockElementUpdated=yg,g.hasAltOnly=P8,g.hasClass=rt,g.hasCtrlOrCmd=Hm,g.hasCtrlOrCmdOnly=N8,g.hideBlock=rg,g.htmlToFragment=Rl,g.i18n=T,g.injectDocToHtmlFragment=as,g.injectStyle=Dm,g.insertEmptyBlock=nA,g.insertEmptyEmbedBlock=Hu,g.insertText=po,g.intersectionCommands=zy,g.isBackspace=zm,g.isBlock=Jo,g.isBox=Mu,g.isCJK=$m,g.isChildContainer=Ke,g.isChildNode=wt,g.isCollapsedRange=Ab,g.isComplexBlockPosition=zu,g.isComplexKindBlock=at,g.isContainer=vn,g.isContainerSelectedAllChildBlocks=G0,g.isControlEvent=Go,g.isDelete=_8,g.isDraggingFiles=Pl,g.isElementVisible=gu,g.isEmbedBlock=Te,g.isEmptyContainer=pd,g.isEmptyDoc=tc,g.isEmptyTextBlock=Tt,g.isEmptyTextBlockWithoutCompositionText=Gs,g.isEnterOnly=jm,g.isEscape=yu,g.isFirefox=bu,g.isFirstChildBlockInComplexBlock=LA,g.isHighSurrogate=B8,g.isInBlock=Pu,g.isInBlockTools=zi,g.isLetter=Pm,g.isLowSurrogate=uu,g.isMatchShortcut=jn,g.isMoveForward=R8,g.isNavigationEvent=M8,g.isNavigationKey=Fm,g.isNodeRemoved=Bm,g.isNumber=Nm,g.isPrintableKey=vu,g.isRootBlock=Wn,g.isRootContainer=Ct,g.isSafari=_m,g.isSameDay=Su,g.isShiftEnter=$8,g.isShiftTab=H8,g.isShortcutEvent=O8,g.isSimpleBlock=K8,g.isSimpleBlockPosition=uo,g.isSimplePos=pp,g.isSimpleRange=ec,g.isSpace=Ll,g.isTab=F8,g.isTextBlockContentBoxChild=Pe,g.isTextBlockContentChild=qi,g.isTextBlockContentInsertionChild=Un,g.isTextBlockContentTextChild=Wi,g.isTextKindBlock=_,g.isTextKindBlockType=Ui,g.isToday=tg,g.isValidOffset=le,g.isVisibleBlock=_l,g.isYesterday=eg,g.loadJs=Em,g.loadJsPromise=qo,g.lockers=Ge,g.mergeCommands=Uc,g.mergeDocs=rr,g.mergeOps=td,g.mergeText=hb,g.multiSplitText=Vg,g.parseShortcut=Um,g.patchNode=Hi,g.pointInRect=Wo,g.rangeAddAttribute=Yi,g.rangeGetTextColor=dp,g.rangeRemoveAttribute=Nr,g.rangeSetTextColor=cp,g.rangeTransformText=sp,g.registerDragDrop=Cu,g.removeAttribute=id,g.removeClass=H,g.removeLastBr=cb,g.removePlaceholderFromBlock=f4,g.removeStyle=Sm,g.replaceAll=Y8,g.replaceAllCaseInsensitive=J8,g.replaceAllText=mp,g.replaceText=Kl,g.requestDownload=$l,g.resetListStart=Vs,g.scrollable=Ym,g.selectFile=Qo,g.selectedBlockToDoc=gc,g.selectionToDoc=cs,g.setAttributes=fu,g.setClipboardData=Nl,g.setClipboardDataByEvent=W8,g.setColorToAttributes=ap,g.setDataset=hu,g.setDefaultCursor=Fi,g.setStyles=mu,g.shareDBCommentToDocObject=fh,g.shareDBDocCommentToComment=i5,g.shortcutToDisplayText=j8,g.showBlock=ig,g.showDocVersions=BH,g.splitText=ve,g.splitToThree=Gt,g.stringToDataUrl=Bu,g.stringToObjectUrl=Eu,g.subText=qg,g.textNodeOffsetFromPoint=wm,g.toBase64URL=Zo,g.toPlainText=vt,g.toPlainTextKeepLength=ld,g.trimChar=Au,g.unexclusiveBlock=K4,g.unicodeLength=E8,g.unicodeSubstr=I8,g.updateBlockSelection=bg,g.updateOpAttributes=fp,g.updateTextBlockContent=Mb,g.updateUrl=ku,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|